X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/micropolis/blobdiff_plain/6a5fa4e03967ab980cdc7ef96a42400bc29b4414..e049e4ba47308629d2233fdd3f85d49352463d9c:/src/sim/s_fileio.c diff --git a/src/sim/s_fileio.c b/src/sim/s_fileio.c index 3768f01..37c2a98 100644 --- a/src/sim/s_fileio.c +++ b/src/sim/s_fileio.c @@ -61,18 +61,27 @@ */ #include "sim.h" +void DoSaveCityAs(void); +void DidSaveCity(void); +void DidntSaveCity(char *msg); +void DidLoadCity(void); +void DidntLoadCity(char *msg); +void DidLoadScenario(void); -#if defined(MSDOS) || defined(OSF1) || defined(IS_INTEL) #define SWAP_SHORTS(a,b) _swap_shorts(a,b) #define SWAP_LONGS(a,b) _swap_longs(a,b) #define HALF_SWAP_LONGS(a,b) _half_swap_longs(a,b) +#define NOOP_ON_BE { int test = 1; if (!(*(unsigned char*) (&test))) return; } + static void _swap_shorts(short *buf, int len) { int i; + NOOP_ON_BE; + /* Flip bytes in each short! */ for (i = 0; i < len; i++) { *buf = ((*buf & 0xFF) <<8) | ((*buf &0xFF00) >>8); @@ -80,11 +89,14 @@ _swap_shorts(short *buf, int len) } } +#if 0 static void _swap_longs(long *buf, int len) { int i; + NOOP_ON_BE; + /* Flip bytes in each long! */ for (i = 0; i < len; i++) { long l = *buf; @@ -96,12 +108,15 @@ _swap_longs(long *buf, int len) buf++; } } +#endif static void _half_swap_longs(long *buf, int len) { int i; + NOOP_ON_BE + /* Flip bytes in each long! */ for (i = 0; i < len; i++) { long l = *buf; @@ -112,15 +127,6 @@ _half_swap_longs(long *buf, int len) } } -#else - -#define SWAP_SHORTS(a, b) -#define SWAP_LONGS(a, b) -#define HALF_SWAP_LONGS(a, b) - -#endif - - static int _load_short(short *buf, int len, FILE *f) { @@ -133,6 +139,7 @@ _load_short(short *buf, int len, FILE *f) } +#if 0 static int _load_long(long *buf, int len, FILE *f) { @@ -143,6 +150,7 @@ _load_long(long *buf, int len, FILE *f) return 1; } +#endif static int @@ -160,6 +168,7 @@ _save_short(short *buf, int len, FILE *f) } +#if 0 static int _save_long(long *buf, int len, FILE *f) { @@ -173,6 +182,7 @@ _save_long(long *buf, int len, FILE *f) return 1; } +#endif static @@ -376,9 +386,10 @@ int saveFile(char *filename) } +void LoadScenario(short s) { - char *name, *fname; + char *name = NULL, *fname = NULL; if (CityFileName != NULL) { ckfree(CityFileName); @@ -471,7 +482,8 @@ LoadScenario(short s) } -DidLoadScenario() +void +DidLoadScenario(void) { Eval("UIDidLoadScenario"); } @@ -488,12 +500,12 @@ int LoadCity(char *filename) CityFileName = (char *)ckalloc(strlen(filename) + 1); strcpy(CityFileName, filename); - if (cp = (char *)rindex(filename, '.')) + if ((cp = (char *)rindex(filename, '.'))) *cp = 0; #ifdef MSDOS - if (cp = (char *)rindex(filename, '\\')) + if ((cp = (char *)rindex(filename, '\\'))) #else - if (cp = (char *)rindex(filename, '/')) + if ((cp = (char *)rindex(filename, '/'))) #endif cp++; else @@ -517,12 +529,14 @@ int LoadCity(char *filename) } -DidLoadCity() +void +DidLoadCity(void) { Eval("UIDidLoadCity"); } +void DidntLoadCity(char *msg) { char buf[1024]; @@ -531,7 +545,8 @@ DidntLoadCity(char *msg) } -SaveCity() +void +SaveCity(void) { char msg[256]; @@ -550,18 +565,21 @@ SaveCity() } -DoSaveCityAs() +void +DoSaveCityAs(void) { Eval("UISaveCityAs"); } -DidSaveCity() +void +DidSaveCity(void) { Eval("UIDidSaveCity"); } +void DidntSaveCity(char *msg) { char buf[1024]; @@ -570,6 +588,7 @@ DidntSaveCity(char *msg) } +void SaveCityAs(char *filename) { char msg[256]; @@ -581,12 +600,12 @@ SaveCityAs(char *filename) strcpy(CityFileName, filename); if (saveFile(CityFileName)) { - if (cp = (char *)rindex(filename, '.')) + if ((cp = (char *)rindex(filename, '.'))) *cp = 0; #ifdef MSDOS - if (cp = (char *)rindex(filename, '\\')) + if ((cp = (char *)rindex(filename, '\\'))) #else - if (cp = (char *)rindex(filename, '/')) + if ((cp = (char *)rindex(filename, '/'))) #endif cp++; else