From 6f214ac0ef5899987197c2e4c9baa0b51a04c197 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Mon, 7 Sep 2009 22:24:48 +0200 Subject: [PATCH] Enable warnings and fix them, all of them This involved adding prototypes for most functions and fixing all errors revealed by this. The outcome should be a much more stable Micropolis, as now all functions are called with their defined arguments and also have a defined return value. This should fix debian bug #522529 in a different way than the patch in the bug description --- src/sim/g_ani.c | 1 + src/sim/g_bigmap.c | 4 +- src/sim/g_map.c | 49 ++++++--- src/sim/g_setup.c | 17 +-- src/sim/g_smmaps.c | 32 +++--- src/sim/headers/sim.h | 244 +++++++++++++++++++++++++++++++++++++++++- src/sim/makefile | 4 +- src/sim/rand.c | 5 +- src/sim/s_alloc.c | 2 +- src/sim/s_disast.c | 17 ++- src/sim/s_eval.c | 26 ++++- src/sim/s_fileio.c | 46 +++++--- src/sim/s_gen.c | 45 +++++++- src/sim/s_init.c | 11 +- src/sim/s_msg.c | 27 ++++- src/sim/s_power.c | 8 +- src/sim/s_scan.c | 35 +++++- src/sim/s_sim.c | 67 ++++++++++-- src/sim/s_traf.c | 24 ++++- src/sim/s_zone.c | 61 ++++++++++- src/sim/sim.c | 21 +++- src/sim/w_budget.c | 44 +++++--- src/sim/w_con.c | 9 ++ src/sim/w_date.c | 37 ++++--- src/sim/w_editor.c | 37 +++++-- src/sim/w_eval.c | 19 +++- src/sim/w_graph.c | 30 +++--- src/sim/w_inter.c | 15 ++- src/sim/w_keys.c | 5 +- src/sim/w_map.c | 30 ++++-- src/sim/w_piem.c | 38 +++---- src/sim/w_resrc.c | 5 +- src/sim/w_sim.c | 64 ++--------- src/sim/w_sound.c | 21 +++- src/sim/w_sprite.c | 70 +++++++++--- src/sim/w_stubs.c | 31 ++++-- src/sim/w_tk.c | 52 +++++---- src/sim/w_tool.c | 56 ++++++---- src/sim/w_update.c | 35 ++++-- src/sim/w_util.c | 28 ++++- src/sim/w_x.c | 46 +++++--- 41 files changed, 1057 insertions(+), 361 deletions(-) diff --git a/src/sim/g_ani.c b/src/sim/g_ani.c index b5a9e49..a272d6b 100644 --- a/src/sim/g_ani.c +++ b/src/sim/g_ani.c @@ -64,6 +64,7 @@ /* comefrom: moveWorld doEditWindow scoreDoer doMapInFront graphDoer */ +void animateTiles(void) { unsigned short tilevalue, tileflags; diff --git a/src/sim/g_bigmap.c b/src/sim/g_bigmap.c index d70225d..55bb06f 100644 --- a/src/sim/g_bigmap.c +++ b/src/sim/g_bigmap.c @@ -63,14 +63,15 @@ int dynamicFilter(int c, int r); -int WireDrawBeegMapRect(SimView *view, short x, short y, short w, short h); +void drawBeegMaps() { sim_update_editors(); } +void MemDrawBeegMapRect(SimView *view, int x, int y, int w, int h) { int lineBytes = view->line_bytes; @@ -264,6 +265,7 @@ MemDrawBeegMapRect(SimView *view, int x, int y, int w, int h) } +void WireDrawBeegMapRect(SimView *view, short x, short y, short w, short h) { unsigned short *map; diff --git a/src/sim/g_map.c b/src/sim/g_map.c index 4aea2c1..5a65e00 100644 --- a/src/sim/g_map.c +++ b/src/sim/g_map.c @@ -83,23 +83,21 @@ short valGrayMap[] = { }; -int (*mapProcs[NMAPS])(); - -int drawAll(SimView *view); -int drawRes(SimView *view); -int drawCom(SimView *view); -int drawInd(SimView *view); -int drawPower(SimView *view); -int drawLilTransMap(SimView *view); -int drawPopDensity(SimView *view); -int drawRateOfGrowth(SimView *view); -int drawTrafMap(SimView *view); -int drawPolMap(SimView *view); -int drawCrimeMap(SimView *view); -int drawLandMap(SimView *view); -int drawFireRadius(SimView *view); -int drawPoliceRadius(SimView *view); -int drawDynamic(SimView *view); +void (*mapProcs[NMAPS])(); + +void drawPopDensity(SimView *view); +void drawRateOfGrowth(SimView *view); +void drawTrafMap(SimView *view); +void drawPolMap(SimView *view); +void drawCrimeMap(SimView *view); +void drawLandMap(SimView *view); +void drawFireRadius(SimView *view); +void drawPoliceRadius(SimView *view); +void ditherMap(SimView *view); +void drawRect(SimView *view, int pixel, int solid, + int x, int y, int w, int h); +void maybeDrawRect(SimView *view, int val, + int x, int y, int w, int h); short GetCI(short x) @@ -112,6 +110,7 @@ short GetCI(short x) } +void drawPopDensity(SimView *view) { short x, y; @@ -126,6 +125,7 @@ drawPopDensity(SimView *view) } +void drawRateOfGrowth(SimView *view) { short x, y; @@ -153,6 +153,7 @@ drawRateOfGrowth(SimView *view) } +void drawTrafMap(SimView *view) { short x; @@ -169,6 +170,7 @@ drawTrafMap(SimView *view) } +void drawPolMap(SimView *view) { short x, y; @@ -184,6 +186,7 @@ drawPolMap(SimView *view) } +void drawCrimeMap(SimView *view) { short x, y; @@ -199,6 +202,7 @@ drawCrimeMap(SimView *view) } +void drawLandMap(SimView *view) { short x, y; @@ -214,6 +218,7 @@ drawLandMap(SimView *view) } +void drawFireRadius(SimView *view) { short x, y; @@ -228,6 +233,7 @@ drawFireRadius(SimView *view) } +void drawPoliceRadius(SimView *view) { short x, y; @@ -242,6 +248,7 @@ drawPoliceRadius(SimView *view) } +void setUpMapProcs(void) { mapProcs[ALMAP] = drawAll; @@ -262,6 +269,7 @@ setUpMapProcs(void) } +void MemDrawMap(SimView *view) { (*mapProcs[view->map_state])(view); @@ -275,6 +283,7 @@ MemDrawMap(SimView *view) } +void ditherMap(SimView *view) { int i, x, y, width, height; @@ -346,6 +355,7 @@ ditherMap(SimView *view) } +void maybeDrawRect(SimView *view, int val, int x, int y, int w, int h) { @@ -359,6 +369,7 @@ maybeDrawRect(SimView *view, int val, } +void drawRect(SimView *view, int pixel, int solid, int x, int y, int w, int h) { @@ -385,8 +396,10 @@ drawRect(SimView *view, int pixel, int solid, if (w && h) { int i, j, stipple = (x ^ y) & 1; +#if 0 unsigned char *data = view->x->color ? view->data : view->data8; +#endif /* In the case of black and white, we use an 8 bit buffer and dither it. */ int pixelBytes = @@ -394,8 +407,10 @@ drawRect(SimView *view, int pixel, int solid, QUAD line = view->x->color ? view->line_bytes : view->line_bytes8; +#if 0 unsigned char *image = &(data[(line * y) + (x * pixelBytes)]); +#endif switch (pixelBytes) { diff --git a/src/sim/g_setup.c b/src/sim/g_setup.c index 61204fe..8cd13ba 100644 --- a/src/sim/g_setup.c +++ b/src/sim/g_setup.c @@ -70,7 +70,7 @@ #define gray25_width 16 #define gray25_height 16 -static unsigned char gray25_bits[] = { +static char gray25_bits[] = { 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, @@ -92,7 +92,7 @@ static unsigned char gray25_bits[] = { #define gray50_width 16 #define gray50_height 16 -static unsigned char gray50_bits[] = { +static char gray50_bits[] = { 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, @@ -114,7 +114,7 @@ static unsigned char gray50_bits[] = { #define gray75_width 16 #define gray75_height 16 -static unsigned char gray75_bits[] = { +static char gray75_bits[] = { 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, @@ -135,7 +135,7 @@ static unsigned char gray75_bits[] = { #define vert_width 16 #define vert_height 16 -static unsigned char vert_bits[] = { +static char vert_bits[] = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, @@ -157,7 +157,7 @@ static unsigned char vert_bits[] = { #define horiz_width 16 #define horiz_height 16 -static unsigned char horiz_bits[] = { +static char horiz_bits[] = { 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, @@ -179,7 +179,7 @@ static unsigned char horiz_bits[] = { #define diag_width 16 #define diag_height 16 -static unsigned char diag_bits[] = { +static char diag_bits[] = { 0x55, 0x55, 0xee, 0xee, 0x55, 0x55, @@ -239,6 +239,7 @@ GetObjectXpms(XDisplay *xd, int id, int frames) } +void GetPixmaps(XDisplay *xd) { if (xd->gray25_stipple == None) { @@ -286,6 +287,7 @@ GetPixmaps(XDisplay *xd) } +void GetViewTiles(SimView *view) { char name[256]; @@ -363,10 +365,9 @@ GetViewTiles(SimView *view) } } - { int x, y, b, tile; + { int x, y, tile; unsigned char *from, *to; int pixelBytes = view->pixel_bytes; - int rowBytes = view->x->small_tile_image->bytes_per_line; if (pixelBytes == 0) { /* handle the case of monochrome display (8 bit map) */ diff --git a/src/sim/g_smmaps.c b/src/sim/g_smmaps.c index 8b5f345..e66ad40 100644 --- a/src/sim/g_smmaps.c +++ b/src/sim/g_smmaps.c @@ -367,29 +367,29 @@ int dynamicFilter(int col, int row) c = col >>1; if (((DynamicData[0] > DynamicData[1]) || - ((x = PopDensity[c][r]) >= DynamicData[0]) && - (x <= DynamicData[1])) && + (((x = PopDensity[c][r]) >= DynamicData[0]) && + (x <= DynamicData[1]))) && ((DynamicData[2] > DynamicData[3]) || - ((x = RateOGMem[c>>2][r>>2]) >= ((2 * DynamicData[2]) - 256)) && - (x <= ((2 * DynamicData[3]) - 256))) && + (((x = RateOGMem[c>>2][r>>2]) >= ((2 * DynamicData[2]) - 256)) && + (x <= ((2 * DynamicData[3]) - 256)))) && ((DynamicData[4] > DynamicData[5]) || - ((x = TrfDensity[c][r]) >= DynamicData[4]) && - (x <= DynamicData[5])) && + (((x = TrfDensity[c][r]) >= DynamicData[4]) && + (x <= DynamicData[5]))) && ((DynamicData[6] > DynamicData[7]) || - ((x = PollutionMem[c][r]) >= DynamicData[6]) && - (x <= DynamicData[7])) && + (((x = PollutionMem[c][r]) >= DynamicData[6]) && + (x <= DynamicData[7]))) && ((DynamicData[8] > DynamicData[9]) || - ((x = CrimeMem[c][r]) >= DynamicData[8]) && - (x <= DynamicData[9])) && + (((x = CrimeMem[c][r]) >= DynamicData[8]) && + (x <= DynamicData[9]))) && ((DynamicData[10] > DynamicData[11]) || - ((x = LandValueMem[c][r]) >= DynamicData[10]) && - (x <= DynamicData[11])) && + (((x = LandValueMem[c][r]) >= DynamicData[10]) && + (x <= DynamicData[11]))) && ((DynamicData[12] > DynamicData[13]) || - ((x = PoliceMapEffect[c>>2][r>>2]) >= DynamicData[12]) && - (x <= DynamicData[13])) && + (((x = PoliceMapEffect[c>>2][r>>2]) >= DynamicData[12]) && + (x <= DynamicData[13]))) && ((DynamicData[14] > DynamicData[15]) || - ((x = FireRate[c>>2][r>>2]) >= DynamicData[14]) && - (x <= DynamicData[15]))) { + (((x = FireRate[c>>2][r>>2]) >= DynamicData[14]) && + (x <= DynamicData[15])))) { return 1; } else { return 0; diff --git a/src/sim/headers/sim.h b/src/sim/headers/sim.h index 7ecd002..4529a38 100644 --- a/src/sim/headers/sim.h +++ b/src/sim/headers/sim.h @@ -679,9 +679,243 @@ extern SimSprite *GetSprite(); extern SimSprite *MakeSprite(); extern SimSprite *MakeNewSprite(); -extern int setSpeed(short speed); -extern int setSkips(int skips); -extern int SetGameLevel(short level); -extern int SetGameLevelFunds(short level); - extern struct XDisplay *XDisplays; + +/* Functions referenced from other files */ +/* g_ani.c */ +void animateTiles(void); +/* g_bigmap.c */ +void WireDrawBeegMapRect(SimView *view, short x, short y, short w, short h); +void MemDrawBeegMapRect(SimView *view, int x, int y, int w, int h); +/* g_map.c */ +void setUpMapProcs(void); +void MemDrawMap(SimView *view); +/* g_setup.c */ +void GetViewTiles(SimView *view); +void GetPixmaps(XDisplay *xd); +/* g_smmaps.c */ +void drawAll(SimView *view); +void drawRes(SimView *view); +void drawCom(SimView *view); +void drawInd(SimView *view); +void drawLilTransMap(SimView *view); +void drawPower(SimView *view); +void drawDynamic(SimView *view); +/* rand.c */ +int sim_rand(void); +void sim_srand(u_int seed); +/* sim.c */ +void sim_exit(int val); +void sim_update_editors(void); +void sim_update(void); +void sim_init(void); +void sim_really_exit(int val); +void sim_loop(int doSim); +/* s_alloc.c */ +void initMapArrays(void); +/* s_disast.c */ +void DoDisasters(void); +void DoFlood(void); +void MakeFlood(void); +void MakeEarthquake(void); +void MakeMeltdown(void); +void MakeFire(void); +void FireBomb(void); +/* s_eval.c */ +void EvalInit(void); +void CityEvaluation(void); +int GetFire(void); +int GetUnemployment(void); +int AverageTrf(void); +/* s_fileio.c */ +int LoadCity(char *filename); +void SaveCity(void); +void SaveCityAs(char *filename); +void LoadScenario(short s); +/* s_gen.c */ +void ClearMap(void); +void SmoothTrees(void); +void SmoothRiver(void); +void GenerateSomeCity(int r); +void ClearUnnatural(void); +void SmoothWater(void); +void GenerateNewCity(void); +/* s_init.c */ +void ResetMapState(void); +void ResetEditorState(void); +void InitWillStuff(void); +/* s_msg.c */ +void SendMessages(void); +void SendMesAt(short Mnum, short x, short y); +void ClearMes(void); +int SendMes(int Mnum); +void SendMesAt(short Mnum, short x, short y); +void doMessage(void); +/* s_power.c */ +void PushPowerStack(void); +void DoPowerScan(void); +int MoveMapSim (short MDir); +/* s_scan.c */ +void FireAnalysis(void); +void PopDenScan(void); +void CrimeScan(void); +void PTLScan(void); +/* s_sim.c */ +void SimFrame(void); +void DoSimInit(void); +void SeedRand(int seed); +void DoMeltdown(int SX, int SY); +void FireZone(int Xloc, int Yloc, int ch); +int Rand16(void); +int Rand16Signed(void); +void RandomlySeedRand(); +void RepairZone(short ZCent, short zsize); +void DoSPZone(short PwrOn); +void UpdateFundEffects(void); +/* s_traf.c */ +int FindPRoad(void); +int MakeTraf(int Zt); +/* s_zone.c */ +void DoZone(void); +int SetZPower(void); +int RZPop(int Ch9); +int CZPop(int Ch9); +int IZPop(int Ch9); +int DoFreePop (void); +/* w_budget.c */ +void UpdateBudgetWindow(void); +void InitFundingLevel(void); +void drawCurrPercents(void); +void DoBudget(void); +void drawBudgetWindow(void); +void DoBudgetFromMenu(void); +void UpdateBudget(void); +/* w_con.c */ +int ConnecTile(short x, short y, short *TileAdrPtr, short Command); +/* w_date.c */ +void date_command_init(void); +/* w_editor.c */ +void DoUpdateEditor(SimView *view); +void editor_command_init(void); +void DoNewEditor(SimView *view); +/* w_eval.c */ +void scoreDoer(void); +void ChangeEval(void); +/* w_graph.c */ +void graphDoer(void); +void initGraphs(void); +void ChangeCensus(void); +void doAllGraphs(void); +void DestroyGraph(SimGraph *graph); +void InitGraphMax(void); +void graph_command_init(void); +int ConfigureSimGraph(Tcl_Interp *interp, SimGraph *graph, int argc, char **argv, int flags); +/* w_keys.c */ +void ResetLastKeys(void); +void doKeyUp(SimView *view, short charCode); +void doKeyDown(SimView *view, short charCode); +/* w_map.c */ +int DoUpdateMap(SimView *view); +void map_command_init(void); +void DoNewMap(SimView *view); +/* w_resrc.c */ +void GetIndString(char *str, int id, short num); +/* w_sim.c */ +void sim_command_init(void); +/* w_sound.c */ +void InitializeSound(void); +void MakeSound(char *channel, char *id); +void MakeSoundOn(SimView *view, char *channel, char *id); +void SoundOff(void); +void StartBulldozer(void); +void StopBulldozer(void); +void sound_command_init(void); +/* w_sprite.c */ +void MoveObjects(void); +void MakeExplosion(int x, int y); +void MakeExplosionAt(int x, int y); +void GenerateShip(void); +void GeneratePlane(int x, int y); +void GenerateCopter(int x, int y); +void GenerateTrain(int x, int y); +void MakeMonster(void); +void MakeTornado(void); +void MakeAirCrash(void); +void DestroyAllSprites(void); +void DrawObjects(SimView *view); +void sprite_command_init(void); +/* w_stubs.c */ +void SetFunds(int dollars); +void Spend(int dollars); +void DropFireBombs(void); +QUAD TickCount(void); +void GameStarted(void); +void InitGame(void); +void ReallyQuit(void); +/* w_tk.c */ +void tk_main(void); +void StopEarthquake(void); +void CancelRedrawView(SimView *view); +void RedrawMaps(void); +void EventuallyRedrawView(SimView *view); +void StopToolkit(void); +void InvalidateEditors(void); +int Eval(char *buf); +void DoEarthQuake(void); +void Kick(void); +void InvalidateMaps(void); +int ConfigureTileView(Tcl_Interp *interp, SimView *view, int argc, char **argv, int flags); +void DidStopPan(SimView *view); +void RedrawEditors(void); +void StartMicropolisTimer(void); +void StopMicropolisTimer(void); +/* w_tool.c */ +void ToolDrag(SimView *view, int px, int py); +void ToolUp(SimView *view, int x, int y); +void ChalkTo(SimView *view, int x, int y); +void ChalkStart(SimView *view, int x, int y, int color); +short tally(short tileValue); +int bulldozer_tool(SimView *view, short x, short y); +void setWandState(SimView *view, short state); +void ToolDown(SimView *view, int x, int y); +void DoTool(SimView *view, short tool, short x, short y); +/* w_update.c */ +void DoUpdateHeads(void); +void UpdateFunds(void); +void UpdateEvaluation(void); +void UpdateGraphs(void); +void UpdateEditors(void); +void UpdateMaps(void); +void UpdateHeads(void); +void doTimeStuff(void); +/* w_util.c */ +void DoNewGame(void); +void setCityName(char *name); +void setAnyCityName(char *name); +void DoSetMapState(SimView *view, short state); +void makeDollarDecimalStr(char *numStr, char *dollarStr); +int CurrentYear(void); +void SetYear(int year); +void Pause(void); +void Resume(void); +void setSpeed(short speed); +void setSkips(int skips); +void SetGameLevel(short level); +void SetGameLevelFunds(short level); +/* w_x.c */ +void DoTimeoutListen(void); +void DoStopMicropolis(void); +void UpdateFlush(void); +void DoPanTo(struct SimView *view, int x, int y); +void DoResizeView(SimView *view, int w, int h); +void DestroyView(SimView *view); +void ViewToPixelCoords(SimView *view, int x, int y, int *outx, int *outy); +void FreeInk(Ink *ink); +void AddInk(Ink *ink, int x, int y); +void StartInk(Ink *ink, int x, int y); +void DoPanBy(struct SimView *view, int dx, int dy); +void ViewToTileCoords(SimView *view, int x, int y, int *outx, int *outy); +void EraseOverlay(void); +SimView *InitNewView(SimView *view, char *title, int class, int w, int h); +void IncRefDisplay(XDisplay *xd); +void DecRefDisplay(XDisplay *xd); diff --git a/src/sim/makefile b/src/sim/makefile index 7e4dd05..f773cd9 100644 --- a/src/sim/makefile +++ b/src/sim/makefile @@ -14,9 +14,9 @@ OPTFLAGS = -O3 #OPTFLAGS = -g #DEFINES = -DIS_LINUX -DCAM -DNET -DEFINES = -DIS_LINUX -DNO_AIRCRASH +DEFINES = -DIS_LINUX #-DNO_AIRCRASH -CFLAGS += $(OPTFLAGS) $(DEFINES) +CFLAGS += $(OPTFLAGS) $(DEFINES) -Wall #LDFLAGS = -Bstatic LDFLAGS=-L/usr/X11/lib -L/usr/X11R6/lib diff --git a/src/sim/rand.c b/src/sim/rand.c index 6311526..54dc9e8 100644 --- a/src/sim/rand.c +++ b/src/sim/rand.c @@ -41,15 +41,14 @@ static unsigned QUAD next = 1; int -sim_rand() +sim_rand(void) { next = next * 1103515245 + 12345; return ((next % ((SIM_RAND_MAX + 1) <<8)) >>8); } void -sim_srand(seed) -u_int seed; +sim_srand(u_int seed) { next = seed; } diff --git a/src/sim/s_alloc.c b/src/sim/s_alloc.c index 25be874..24b9b4b 100644 --- a/src/sim/s_alloc.c +++ b/src/sim/s_alloc.c @@ -147,7 +147,7 @@ short *MiscHis; short *PowerMap; -int initMapArrays(void) +void initMapArrays(void) { short i; unsigned short *auxPtr, *temp1; diff --git a/src/sim/s_disast.c b/src/sim/s_disast.c index 384e152..65b914d 100644 --- a/src/sim/s_disast.c +++ b/src/sim/s_disast.c @@ -69,8 +69,12 @@ short ShakeNow; short FloodCnt; short FloodX, FloodY; +void SetFire(void); +int Vunerable(int tem); +void ScenarioDisaster(void); /* comefrom: Simulate */ +void DoDisasters(void) { /* Chance of disasters at lev 0 1 2 */ @@ -115,10 +119,9 @@ DoDisasters(void) /* comefrom: DoDisasters */ +void ScenarioDisaster(void) { - int x, y; - switch (DisasterEvent) { case 1: /* Dullsville */ break; @@ -148,6 +151,7 @@ ScenarioDisaster(void) /* comefrom: ScenarioDisaster */ +void MakeMeltdown(void) { short x, y; @@ -164,7 +168,8 @@ MakeMeltdown(void) } -FireBomb() +void +FireBomb(void) { CrashX = Rand(WORLD_X - 1); CrashY = Rand(WORLD_Y - 1); @@ -175,6 +180,7 @@ FireBomb() /* comefrom: DoDisasters ScenarioDisaster */ +void MakeEarthquake(void) { register short x, y, z; @@ -202,6 +208,7 @@ MakeEarthquake(void) /* comefrom: DoDisasters */ +void SetFire(void) { register short x, y, z; @@ -222,6 +229,7 @@ SetFire(void) /* comefrom: DoDisasters */ +void MakeFire(void) { short t, x, y, z; @@ -243,6 +251,7 @@ MakeFire(void) /* comefrom: MakeEarthquake */ +int Vunerable(int tem) { register int tem2; @@ -257,6 +266,7 @@ Vunerable(int tem) /* comefrom: DoDisasters ScenarioDisaster */ +void MakeFlood(void) { static short Dx[4] = { 0, 1, 0,-1}; @@ -290,6 +300,7 @@ MakeFlood(void) /* comefrom: MapScan */ +void DoFlood(void) { static short Dx[4] = { 0, 1, 0,-1}; diff --git a/src/sim/s_eval.c b/src/sim/s_eval.c index acbb6ed..e308229 100644 --- a/src/sim/s_eval.c +++ b/src/sim/s_eval.c @@ -77,8 +77,16 @@ short CityClass; /* 0..5 */ short CityScore, deltaCityScore, AverageCityScore; short TrafficAverage; +void DoVotes(void); +void GetScore(void); +void VoteProblems(void); +void DoProblems(void); +void DoPopNum(void); +void GetAssValue(void); + /* comefrom: SpecialInit Simulate */ +void CityEvaluation(void) { EvalValid = 0; @@ -98,6 +106,7 @@ CityEvaluation(void) /* comefrom: CityEvaluation SetCommonInits */ +void EvalInit(void) { register short x, z; @@ -120,6 +129,7 @@ EvalInit(void) /* comefrom: CityEvaluation */ +void GetAssValue(void) { QUAD z; @@ -139,6 +149,7 @@ GetAssValue(void) /* comefrom: CityEvaluation */ +void DoPopNum(void) { QUAD OldCityPop; @@ -160,10 +171,11 @@ DoPopNum(void) /* comefrom: CityEvaluation */ +void DoProblems(void) { register short x, z; - short ThisProb, Max; + short ThisProb = 0, Max; for (z = 0; z < PROBNUM; z++) ProblemTable[z] = 0; @@ -198,9 +210,10 @@ DoProblems(void) /* comefrom: DoProblems */ +void VoteProblems(void) { - register x, z, count; + register int x, z, count; for (z = 0; z < PROBNUM; z++) ProblemVotes[z] = 0; @@ -221,6 +234,7 @@ VoteProblems(void) /* comefrom: DoProblems */ +int AverageTrf(void) { QUAD TrfTotal; @@ -241,6 +255,7 @@ AverageTrf(void) /* comefrom: DoProblems */ +int GetUnemployment(void) { float r; @@ -260,6 +275,7 @@ GetUnemployment(void) /* comefrom: DoProblems GetScore */ +int GetFire(void) { short z; @@ -273,9 +289,10 @@ GetFire(void) /* comefrom: CityEvaluation */ +void GetScore(void) { - register x, z; + register int x, z; short OldCityScore; float SM, TM; @@ -329,9 +346,10 @@ GetScore(void) /* comefrom: CityEvaluation */ +void DoVotes(void) { - register z; + register int z; CityYes = 0; CityNo = 0; diff --git a/src/sim/s_fileio.c b/src/sim/s_fileio.c index 37637f7..37c2a98 100644 --- a/src/sim/s_fileio.c +++ b/src/sim/s_fileio.c @@ -61,6 +61,13 @@ */ #include "sim.h" +void DoSaveCityAs(void); +void DidSaveCity(void); +void DidntSaveCity(char *msg); +void DidLoadCity(void); +void DidntLoadCity(char *msg); +void DidLoadScenario(void); + #define SWAP_SHORTS(a,b) _swap_shorts(a,b) #define SWAP_LONGS(a,b) _swap_longs(a,b) @@ -82,6 +89,7 @@ _swap_shorts(short *buf, int len) } } +#if 0 static void _swap_longs(long *buf, int len) { @@ -100,6 +108,7 @@ _swap_longs(long *buf, int len) buf++; } } +#endif static void _half_swap_longs(long *buf, int len) @@ -130,6 +139,7 @@ _load_short(short *buf, int len, FILE *f) } +#if 0 static int _load_long(long *buf, int len, FILE *f) { @@ -140,6 +150,7 @@ _load_long(long *buf, int len, FILE *f) return 1; } +#endif static int @@ -157,6 +168,7 @@ _save_short(short *buf, int len, FILE *f) } +#if 0 static int _save_long(long *buf, int len, FILE *f) { @@ -170,6 +182,7 @@ _save_long(long *buf, int len, FILE *f) return 1; } +#endif static @@ -373,9 +386,10 @@ int saveFile(char *filename) } +void LoadScenario(short s) { - char *name, *fname; + char *name = NULL, *fname = NULL; if (CityFileName != NULL) { ckfree(CityFileName); @@ -468,7 +482,8 @@ LoadScenario(short s) } -DidLoadScenario() +void +DidLoadScenario(void) { Eval("UIDidLoadScenario"); } @@ -485,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 @@ -514,12 +529,14 @@ int LoadCity(char *filename) } -DidLoadCity() +void +DidLoadCity(void) { Eval("UIDidLoadCity"); } +void DidntLoadCity(char *msg) { char buf[1024]; @@ -528,7 +545,8 @@ DidntLoadCity(char *msg) } -SaveCity() +void +SaveCity(void) { char msg[256]; @@ -547,18 +565,21 @@ SaveCity() } -DoSaveCityAs() +void +DoSaveCityAs(void) { Eval("UISaveCityAs"); } -DidSaveCity() +void +DidSaveCity(void) { Eval("UIDidSaveCity"); } +void DidntSaveCity(char *msg) { char buf[1024]; @@ -567,6 +588,7 @@ DidntSaveCity(char *msg) } +void SaveCityAs(char *filename) { char msg[256]; @@ -578,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 diff --git a/src/sim/s_gen.c b/src/sim/s_gen.c index 448781a..08bb2e1 100644 --- a/src/sim/s_gen.c +++ b/src/sim/s_gen.c @@ -78,13 +78,27 @@ int LakeLevel = -1; /* level for lake creation */ int CurveLevel = -1; /* level for river curviness */ int CreateIsland = -1; /* -1 => 10%, 0 => never, 1 => always */ - +void DoBRiv(void); +void DoSRiv(void); +void BRivPlop(void); +void SRivPlop(void); +void DoRivers(void); +void DoTrees(void); +void GetRandStart(void); +void MakeLakes(void); +void MakeIsland(void); +void MakeNakedIsland(void); +void GenerateMap(int r); + + +void GenerateNewCity(void) { GenerateSomeCity(Rand16()); } +void GenerateSomeCity(int r) { if (CityFileName != NULL) { @@ -112,6 +126,7 @@ GenerateSomeCity(int r) } +int ERand(short limit) { short x, z; @@ -124,6 +139,7 @@ ERand(short limit) } +void GenerateMap(int r) { SeedRand(r); @@ -154,6 +170,7 @@ GenerateMap(int r) } +void ClearMap(void) { register short x, y; @@ -164,6 +181,7 @@ ClearMap(void) } +void ClearUnnatural(void) { register short x, y; @@ -180,7 +198,8 @@ ClearUnnatural(void) #define RADIUS 18 -MakeNakedIsland() +void +MakeNakedIsland(void) { register int x, y; @@ -215,6 +234,7 @@ MakeNakedIsland() } +void MakeIsland(void) { MakeNakedIsland(); @@ -223,6 +243,7 @@ MakeIsland(void) } +void MakeLakes(void) { short Lim1, Lim2, t, z; @@ -249,6 +270,7 @@ MakeLakes(void) } +void GetRandStart(void) { XStart = 40 + Rand(WORLD_X - 80); @@ -258,6 +280,7 @@ GetRandStart(void) } +void MoveMap(short dir) { static short DirTab[2][8] = { { 0, 1, 1, 1, 0, -1, -1, -1}, @@ -268,10 +291,11 @@ MoveMap(short dir) } +void TreeSplash(short xloc, short yloc) { short dis, dir; - register short xoff, yoff, z; + register short z; if (TreeLevel < 0) { dis = Rand(150) + 50; @@ -291,6 +315,7 @@ TreeSplash(short xloc, short yloc) } +void DoTrees(void) { short Amount, x, xloc, yloc; @@ -310,6 +335,7 @@ DoTrees(void) } +void SmoothRiver(void) { static short DX[4] = {-1, 0, 1, 0}; @@ -346,6 +372,7 @@ SmoothRiver(void) } +int IsTree(int cell) { if (((cell & LOMASK) >= WOODS_LOW) && @@ -355,6 +382,7 @@ IsTree(int cell) } +void SmoothTrees(void) { static short DX[4] = {-1, 0, 1, 0}; @@ -393,6 +421,7 @@ SmoothTrees(void) } +void DoRivers(void) { @@ -411,6 +440,7 @@ DoRivers(void) } +void DoBRiv(void) { int r1, r2; @@ -436,6 +466,7 @@ DoBRiv(void) } +void DoSRiv(void) { int r1, r2; @@ -461,6 +492,7 @@ DoSRiv(void) } +void PutOnMap(short Mchar, short Xoff, short Yoff) { register short Xloc, Yloc, temp; @@ -471,7 +503,7 @@ PutOnMap(short Mchar, short Xoff, short Yoff) Yloc = MapY + Yoff; if (TestBounds(Xloc, Yloc) == FALSE) return; - if (temp = Map[Xloc][Yloc]) { + if ((temp = Map[Xloc][Yloc])) { temp = temp & LOMASK; if (temp == RIVER) if (Mchar != CHANNEL) @@ -483,6 +515,7 @@ PutOnMap(short Mchar, short Xoff, short Yoff) } +void BRivPlop(void) { static short BRMatrix[9][9] = { @@ -503,6 +536,7 @@ BRivPlop(void) } +void SRivPlop(void) { static short SRMatrix[6][6] = { @@ -520,7 +554,8 @@ SRivPlop(void) } -SmoothWater() +void +SmoothWater(void) { int x, y; diff --git a/src/sim/s_init.c b/src/sim/s_init.c index 7f26308..6283281 100644 --- a/src/sim/s_init.c +++ b/src/sim/s_init.c @@ -66,9 +66,10 @@ /* comefrom: loadFile bootUp main doMessage */ -InitWillStuff() +void +InitWillStuff(void) { - register short x, y, z; + register short x, y; RandomlySeedRand(); InitGraphMax(); @@ -131,7 +132,8 @@ InitWillStuff() } -ResetMapState() +void +ResetMapState(void) { SimView *view; @@ -141,7 +143,8 @@ ResetMapState() } -ResetEditorState() +void +ResetEditorState(void) { SimView *view; diff --git a/src/sim/s_msg.c b/src/sim/s_msg.c index d820607..075949b 100644 --- a/src/sim/s_msg.c +++ b/src/sim/s_msg.c @@ -68,13 +68,20 @@ short LastPicNum; short autoGo; short HaveLastMessage = 0; char LastMessage[256]; -int DoAutoGoto(short x, short y, char *msg); -int DoShowPicture(short id); + +void DoAutoGoto(short x, short y, char *msg); +void DoShowPicture(short id); +void DoLoseGame(void); +void SetMessageField(char *str); +void DoScenarioScore(int type); +void CheckGrowth(void); + /* comefrom: Simulate */ +void SendMessages(void) { - register z; + register int z; short PowerPop; float TM; @@ -186,6 +193,7 @@ SendMessages(void) /* comefrom: SendMessages */ +void CheckGrowth(void) { QUAD ThisCityPop; @@ -212,6 +220,7 @@ CheckGrowth(void) /* comefrom: SendMessages */ +void DoScenarioScore(int type) { short z; @@ -251,6 +260,7 @@ DoScenarioScore(int type) } +void ClearMes(void) { MessagePort = 0; @@ -262,6 +272,7 @@ ClearMes(void) /* comefrom: MakeEarthquake MakeFire MakeFire MakeFlood SendMessages CheckGrowth DoScenarioScore DoPowerScan */ +int SendMes(int Mnum) { if (Mnum < 0) { @@ -294,6 +305,7 @@ void SendMesAt(short Mnum, short x, short y) } +void doMessage(void) { char messageStr[256]; @@ -401,6 +413,7 @@ doMessage(void) } +void DoAutoGoto(short x, short y, char *msg) { char buf[256]; @@ -411,6 +424,7 @@ DoAutoGoto(short x, short y, char *msg) } +void SetMessageField(char *str) { char buf[256]; @@ -425,6 +439,7 @@ SetMessageField(char *str) } +void DoShowPicture(short id) { char buf[256]; @@ -434,13 +449,15 @@ DoShowPicture(short id) } -DoLoseGame() +void +DoLoseGame(void) { Eval("UILoseGame"); } -DoWinGame() +void +DoWinGame(void) { Eval("UIWinGame"); } diff --git a/src/sim/s_power.c b/src/sim/s_power.c index 5d309b3..16d69fe 100644 --- a/src/sim/s_power.c +++ b/src/sim/s_power.c @@ -69,8 +69,11 @@ int PowerStackNum; char PowerStackX[PWRSTKSIZE], PowerStackY[PWRSTKSIZE]; QUAD MaxPower, NumPower; +void PullPowerStack(void); + /* comefrom: TestForCond DoPowerScan TryGo */ +int MoveMapSim (short MDir) { switch (MDir) { @@ -183,7 +186,8 @@ short TestForCond(short TFDir) /* comefrom: Simulate SpecialInit InitSimMemory */ -DoPowerScan() +void +DoPowerScan(void) { short ADir; register int ConNum, Dir, x; @@ -230,6 +234,7 @@ DoPowerScan() /* comefrom: DoPowerScan DoSPZone */ +void PushPowerStack(void) { if (PowerStackNum < (PWRSTKSIZE - 2)) { @@ -241,6 +246,7 @@ PushPowerStack(void) /* comefrom: DoPowerScan */ +void PullPowerStack(void) { if (PowerStackNum > 0) { diff --git a/src/sim/s_scan.c b/src/sim/s_scan.c index 20a7d62..35cc082 100644 --- a/src/sim/s_scan.c +++ b/src/sim/s_scan.c @@ -72,11 +72,23 @@ short PolMaxX, PolMaxY; short CrimeMaxX, CrimeMaxY; QUAD DonDither = 0; +void DistIntMarket(void); +void SmoothPSMap(void); +void SmoothFSMap(void); +void ClrTemArray(void); +void DoSmooth (void); +void DoSmooth2 (void); +void SmoothTerrain(void); +int GetPValue(int loc); +int GetDisCC(int x, int y); +int GetPDen(int Ch9); + /* comefrom: Simulate SpecialInit */ +void FireAnalysis(void) /* Make firerate map from firestation map */ { - register x,y; + register int x,y; SmoothFSMap(); SmoothFSMap(); @@ -90,6 +102,7 @@ FireAnalysis(void) /* Make firerate map from firestation map */ /* comefrom: Simulate SpecialInit */ +void PopDenScan(void) /* sets: PopDensity, , , ComRate */ { QUAD Xtot, Ytot, Ztot; @@ -139,12 +152,13 @@ PopDenScan(void) /* sets: PopDensity, , , ComRate */ /* comefrom: PopDenScan */ +int GetPDen(int Ch9) { register int pop; if (Ch9 == FREEZ) { - pop = DoFreePop(Ch9); + pop = DoFreePop(/*Ch9*/); return (pop); } if (Ch9 < COMBASE) { @@ -164,6 +178,7 @@ GetPDen(int Ch9) /* comefrom: Simulate SpecialInit */ +void PTLScan(void) /* Does pollution, terrain, land value */ { QUAD ptot, LVtot; @@ -183,7 +198,7 @@ PTLScan(void) /* Does pollution, terrain, land value */ zy = y <<1; for (Mx = zx; Mx <= zx + 1; Mx++) for (My = zy; My <= zy + 1; My++) { - if (loc = (Map[Mx][My] & LOMASK)) { + if ((loc = (Map[Mx][My] & LOMASK))) { if (loc < RUBBLE) { Qtem[x >>1][y >>1] += 15; /* inc terrainMem */ continue; @@ -254,6 +269,7 @@ PTLScan(void) /* Does pollution, terrain, land value */ /* comefrom: PTLScan */ +int GetPValue(int loc) { if (loc < POWERBASE) { @@ -274,6 +290,7 @@ GetPValue(int loc) /* comefrom: PTLScan DistIntMarket */ +int GetDisCC(int x, int y) { short xdis, ydis, z; @@ -297,6 +314,7 @@ GetDisCC(int x, int y) /* comefrom: Simulate SpecialInit */ +void CrimeScan(void) { short numz; @@ -312,7 +330,7 @@ CrimeScan(void) cmax = 0; for (x = 0; x < HWLDX; x++) for (y = 0; y < HWLDY; y++) { - if (z = LandValueMem[x][y]) { + if ((z = LandValueMem[x][y])) { ++numz; z = 128 - z; z += PopDensity[x][y]; @@ -344,6 +362,7 @@ CrimeScan(void) /* comefrom: PTLScan */ +void SmoothTerrain(void) { if (DonDither & 1) { @@ -378,6 +397,7 @@ SmoothTerrain(void) } /* comefrom: PopDenScan */ +void DoSmooth (void) /* smooths data in tem[x][y] into tem2[x][y] */ { if (DonDither & 2) { @@ -425,6 +445,7 @@ DoSmooth (void) /* smooths data in tem[x][y] into tem2[x][y] */ /* comefrom: PopDenScan */ +void DoSmooth2 (void) /* smooths data in tem2[x][y] into tem[x][y] */ { if (DonDither & 4) { @@ -472,6 +493,7 @@ DoSmooth2 (void) /* smooths data in tem2[x][y] into tem[x][y] */ /* comefrom: PopDenScan */ +void ClrTemArray(void) { register short x, y, z; @@ -484,6 +506,7 @@ ClrTemArray(void) /* comefrom: FireAnalysis */ +void SmoothFSMap(void) { register short x, y, edge; @@ -505,9 +528,10 @@ SmoothFSMap(void) /* comefrom: CrimeScan */ +void SmoothPSMap(void) { - register x, y, edge; + register int x, y, edge; for (x = 0; x < SmX; x++) for (y = 0; y < SmY; y++) { @@ -526,6 +550,7 @@ SmoothPSMap(void) /* comefrom: PopDenScan */ +void DistIntMarket(void) { register short x, y, z; diff --git a/src/sim/s_sim.c b/src/sim/s_sim.c index 6f4b0bb..9d0e4c6 100644 --- a/src/sim/s_sim.c +++ b/src/sim/s_sim.c @@ -85,12 +85,31 @@ short Spdcycle = 0; short DoInitialEval = 0; short MeltX, MeltY; +void CoalSmoke(int mx, int my); +void DoAirport(void); +void DrawStadium(int z); +void DoFire(void); +int GetBoatDis(void); +int DoBridge(void); +void DoRoad(void); +void DoRadTile(void); +void DoRail(void); +void MapScan(int x1, int x2); +void CollectTax(void); +void Take2Census(void); +void TakeCensus(void); +void ClearCensus(void); +void SetValves(void); +void SetCommonInits(void); +void SimLoadInit(void); +void InitSimMemory(void); +void DecROGMem(void); +void DecTrafficMem(void); +void Simulate(int mod16); /* comefrom: doEditWindow scoreDoer doMapInFront graphDoer doNilEvent */ -SimFrame(void) +void SimFrame(void) { - short i; - if (SimSpeed == 0) return; @@ -110,6 +129,7 @@ SimFrame(void) /* comefrom: SimFrame */ +void Simulate(int mod16) { static short SpdPwr[4] = { 1, 2, 4, 5 }; @@ -204,6 +224,7 @@ Simulate(int mod16) /* comefrom: Simulate */ +void DoSimInit(void) { Fcycle = 0; @@ -235,6 +256,7 @@ DoSimInit(void) /* comefrom: SimLoadInit */ +void DoNilPower(void) { register short x, y, z; @@ -253,13 +275,14 @@ DoNilPower(void) /* comefrom: Simulate */ +void DecTrafficMem(void) /* tends to empty TrfDensity */ { register short x, y, z; for (x = 0; x < HWLDX; x++) for (y = 0; y < HWLDY; y++) - if (z = TrfDensity[x][y]) { + if ((z = TrfDensity[x][y])) { if (z > 24) { if (z > 200) TrfDensity[x][y] = z - 34; else TrfDensity[x][y] = z - 24; @@ -270,6 +293,7 @@ DecTrafficMem(void) /* tends to empty TrfDensity */ /* comefrom: Simulate */ +void DecROGMem(void) /* tends to empty RateOGMem */ { register short x, y, z; @@ -292,6 +316,7 @@ DecROGMem(void) /* tends to empty RateOGMem */ /* comefrom: DoSimInit */ +void InitSimMemory(void) { register short x, z; @@ -330,6 +355,7 @@ InitSimMemory(void) /* comefrom: DoSimInit */ +void SimLoadInit(void) { static short DisTab[9] = { 0, 2, 10, 5, 20, 3, 5, 5, 2 * 48}; @@ -395,6 +421,7 @@ SimLoadInit(void) /* comefrom: InitSimMemory SimLoadInit */ +void SetCommonInits(void) { EvalInit(); @@ -411,6 +438,7 @@ SetCommonInits(void) /* comefrom: Simulate DoSimInit */ +void SetValves(void) { static short TaxTable[21] = { @@ -448,7 +476,7 @@ SetValves(void) Births = NormResPop * (.02); /* Birth Rate */ PjResPop = NormResPop + Migration + Births; /* Projected Res.Pop */ - if (temp = (ComHis[1] + IndHis[1])) LaborBase = (ResHis[1] / temp); + if ((temp = (ComHis[1] + IndHis[1]))) LaborBase = (ResHis[1] / temp); else LaborBase = 1; if (LaborBase > 1.3) LaborBase = 1.3; if (LaborBase < 0) LaborBase = 0; /* LB > 1 - .1 */ @@ -521,6 +549,7 @@ SetValves(void) /* comefrom: Simulate DoSimInit */ +void ClearCensus(void) { register short x, y, z; @@ -556,6 +585,7 @@ ClearCensus(void) /* comefrom: Simulate */ +void TakeCensus(void) { short x; @@ -608,6 +638,7 @@ TakeCensus(void) /* comefrom: Simulate */ +void Take2Census(void) /* Long Term Graphs */ { short x; @@ -638,6 +669,7 @@ Take2Census(void) /* Long Term Graphs */ /* comefrom: Simulate */ +void CollectTax(void) { static float RLevels[3] = { 0.7, 0.9, 1.2 }; @@ -667,6 +699,7 @@ CollectTax(void) } +void UpdateFundEffects(void) { if (RoadFund) @@ -692,13 +725,14 @@ UpdateFundEffects(void) /* comefrom: Simulate DoSimInit */ +void MapScan(int x1, int x2) { register short x, y; for (x = x1; x < x2; x++) { for (y = 0; y < WORLD_Y; y++) { - if (CChr = Map[x][y]) { + if ((CChr = Map[x][y])) { CChr9 = CChr & LOMASK; /* Mask off status bits */ if (CChr9 >= FLOOD) { SMapX = x; @@ -744,6 +778,7 @@ MapScan(int x1, int x2) /* comefrom: MapScan */ +void DoRail(void) { RailTotal++; @@ -762,6 +797,7 @@ DoRail(void) /* comefrom: MapScan */ +void DoRadTile(void) { if (!(Rand16() & 4095)) Map[SMapX][SMapY] = 0; /* Radioactive decay */ @@ -769,6 +805,7 @@ DoRadTile(void) /* comefrom: MapScan */ +void DoRoad(void) { register short Density, tden, z; @@ -810,6 +847,7 @@ DoRoad(void) /* comefrom: MapScan */ +int DoBridge(void) { static short HDx[7] = { -2, 2, -2, -1, 0, 1, 2 }; @@ -828,7 +866,7 @@ DoBridge(void) static short VBRTAB2[7] = { VBRIDGE | BULLBIT, RIVER, VBRIDGE | BULLBIT, VBRIDGE | BULLBIT, VBRIDGE | BULLBIT, VBRIDGE | BULLBIT, RIVER }; - register z, x, y, MPtem; + register int z, x, y, MPtem; if (CChr9 == BRWV) { /* Vertical bridge close */ if ((!(Rand16() & 3)) && @@ -918,6 +956,7 @@ GetBoatDis(void) /* comefrom: MapScan */ +void DoFire(void) { static short DX[4] = { -1, 0, 1, 0 }; @@ -955,6 +994,7 @@ DoFire(void) /* comefrom: DoFire MakeFlood */ +void FireZone(int Xloc, int Yloc, int ch) { register short Xtem, Ytem; @@ -985,6 +1025,7 @@ FireZone(int Xloc, int Yloc, int ch) /* comefrom: DoSPZone DoHospChur */ +void RepairZone(short ZCent, short zsize) { short cnt; @@ -1011,10 +1052,11 @@ RepairZone(short ZCent, short zsize) /* comefrom: DoZone */ +void DoSPZone(short PwrOn) { static short MltdwnTab[3] = { 30000, 20000, 10000 }; /* simadj */ - register z; + register int z; switch (CChr9) { @@ -1117,6 +1159,7 @@ DoSPZone(short PwrOn) /* comefrom: DoSPZone */ +void DrawStadium(int z) { register int x, y; @@ -1130,6 +1173,7 @@ DrawStadium(int z) /* comefrom: DoSPZone */ +void DoAirport(void) { if (!(Rand(5))) { @@ -1142,6 +1186,7 @@ DoAirport(void) /* comefrom: DoSPZone */ +void CoalSmoke(int mx, int my) { static short SmTb[4] = { COALSMOKE1, COALSMOKE2, COALSMOKE3, COALSMOKE4 }; @@ -1156,9 +1201,10 @@ CoalSmoke(int mx, int my) /* comefrom: DoSPZone MakeMeltdown */ +void DoMeltdown(int SX, int SY) { - register x, y, z, t; + register int x, y, z, t; MeltX = SX; MeltY = SY; @@ -1224,6 +1270,7 @@ Rand16Signed(void) } +void RandomlySeedRand() { struct timeval time; @@ -1233,7 +1280,7 @@ RandomlySeedRand() SeedRand(time.tv_usec ^ time.tv_sec ^ sim_rand()); } - +void SeedRand(int seed) { sim_srand(seed); diff --git a/src/sim/s_traf.c b/src/sim/s_traf.c index 37f1d45..1aa043d 100644 --- a/src/sim/s_traf.c +++ b/src/sim/s_traf.c @@ -72,8 +72,17 @@ short LDir; short Zsource; short TrafMaxX, TrafMaxY; +int GetFromMap(int x); +int DriveDone(void); +int TryGo(int z); +int RoadTest(int x); +void PullPos(void); +void SetTrafMem(void); +int TryDrive(void); + /* comefrom: DoIndustrial DoCommercial DoResidential */ +int MakeTraf(int Zt) { short xtem, ytem; @@ -106,6 +115,7 @@ MakeTraf(int Zt) /* comefrom: MakeTraf */ +void SetTrafMem(void) { register short x, z; @@ -139,6 +149,7 @@ SetTrafMem(void) /* comefrom: TryGo */ +void PushPos(void) { PosStackN++; @@ -148,6 +159,7 @@ PushPos(void) /* comefrom: SetTrafMem */ +void PullPos(void) { SMapX = SMapXStack[PosStackN]; @@ -157,6 +169,7 @@ PullPos(void) /* comefrom: DoSPZone MakeTraf */ +int FindPRoad(void) /* look for road on edges of zone */ { static short PerimX[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2}; @@ -178,6 +191,7 @@ FindPRoad(void) /* look for road on edges of zone */ } +int FindPTele(void) /* look for telecommunication on edges of zone */ { static short PerimX[12] = {-1, 0, 1, 2, 2, 2, 1, 0,-1,-2,-2,-2}; @@ -199,6 +213,7 @@ FindPTele(void) /* look for telecommunication on edges of zone */ /* comefrom: MakeTraf */ +int TryDrive(void) { short z; @@ -221,6 +236,7 @@ TryDrive(void) /* comefrom: TryDrive */ +int TryGo(int z) { short x, rdir, realdir; @@ -246,6 +262,7 @@ TryGo(int z) /* comefrom: TryGo DriveDone */ +int GetFromMap(int x) { switch (x) { @@ -272,11 +289,15 @@ GetFromMap(int x) /* comefrom: TryDrive */ +int DriveDone(void) { static short TARGL[3] = {COMBASE, LHTHR, LHTHR}; static short TARGH[3] = {NUCLEAR, PORT, COMBASE}; /* for destinations */ - register short x, z, l, h; +#if 0 + register short x; +#endif + register short z, l, h; /* unwound -Don */ #if 0 @@ -316,6 +337,7 @@ DriveDone(void) /* comefrom: TryGo FindPRoad */ +int RoadTest(int x) { x = x & LOMASK; diff --git a/src/sim/s_zone.c b/src/sim/s_zone.c index ab9f3d7..4ba6cde 100644 --- a/src/sim/s_zone.c +++ b/src/sim/s_zone.c @@ -64,8 +64,31 @@ /* Zone Stuff */ - -DoZone(void) +void ZonePlop (int base); +void IndPlop (int Den, int Value); +void ComPlop (int Den, int Value); +void ResPlop (int Den, int Value); +int EvalLot (int x, int y); +void BuildHouse(int value); +void DoIndOut(int pop, int value); +void DoComOut(int pop, int value); +void DoResOut(int pop, int value); +void IncROG(int amount); +void DoIndIn(int pop, int value); +void DoComIn(int pop, int value); +void DoResIn(int pop, int value); +void MakeHosp(void); +void DoResidential(int ZonePwrFlg); +int EvalRes (int traf); +int EvalCom (int traf); +int GetCRVal(void); +void DoCommercial(int ZonePwrFlg); +void DoIndustrial(int ZonePwrFlg); +int EvalInd (int traf); +void DoHospChur(void); + + +void DoZone(void) { short ZonePwrFlg; @@ -94,6 +117,7 @@ DoZone(void) } +void DoHospChur(void) { if (CChr9 == HOSPITAL) { @@ -118,13 +142,16 @@ DoHospChur(void) #define ASCBIT (ANIMBIT | CONDBIT | BURNBIT) #define REGBIT (CONDBIT | BURNBIT) +void SetSmoke(int ZonePower) { static short AniThis[8] = { T, F, T, T, F, F, T, T }; static short DX1[8] = { -1, 0, 1, 0, 0, 0, 0, 1 }; static short DY1[8] = { -1, 0, -1, -1, 0, 0, -1, -1 }; +#if 0 static short DX2[8] = { -1, 0, 1, 1, 0, 0, 1, 1 }; static short DY2[8] = { -1, 0, 0, -1, 0, 0, -1, 0 }; +#endif static short AniTabA[8] = { 0, 0, 32, 40, 0, 0, 48, 56 }; static short AniTabB[8] = { 0, 0, 36, 44, 0, 0, 52, 60 }; static short AniTabC[8] = { IND1, 0, IND2, IND4, 0, 0, IND6, IND8 }; @@ -158,6 +185,7 @@ SetSmoke(int ZonePower) } +void DoIndustrial(int ZonePwrFlg) { short tpop, zscore, TrfGood; @@ -189,6 +217,7 @@ DoIndustrial(int ZonePwrFlg) } +void DoCommercial(int ZonePwrFlg) { register short tpop, TrfGood; @@ -227,6 +256,7 @@ DoCommercial(int ZonePwrFlg) } +void DoResidential(int ZonePwrFlg) { short tpop, zscore, locvalve, value, TrfGood; @@ -269,6 +299,7 @@ DoResidential(int ZonePwrFlg) } +void MakeHosp(void) { if (NeedHosp > 0) { @@ -284,6 +315,7 @@ MakeHosp(void) } +int GetCRVal(void) { register short LVal; @@ -297,6 +329,7 @@ GetCRVal(void) } +void DoResIn(int pop, int value) { short z; @@ -324,6 +357,7 @@ DoResIn(int pop, int value) } +void DoComIn(int pop, int value) { register short z; @@ -339,6 +373,7 @@ DoComIn(int pop, int value) } +void DoIndIn(int pop, int value) { if (pop < 4) { @@ -348,12 +383,14 @@ DoIndIn(int pop, int value) } +void IncROG(int amount) { RateOGMem[SMapX>>3][SMapY>>3] += amount<<2; } +void DoResOut(int pop, int value) { static short Brdr[9] = {0,3,6,1,4,7,2,5,8}; @@ -397,6 +434,7 @@ DoResOut(int pop, int value) } +void DoComOut(int pop, int value) { if (pop > 1) { @@ -411,6 +449,7 @@ DoComOut(int pop, int value) } +void DoIndOut(int pop, int value) { if (pop > 1) { @@ -425,6 +464,7 @@ DoIndOut(int pop, int value) } +int RZPop(int Ch9) { short CzDen; @@ -434,6 +474,7 @@ RZPop(int Ch9) } +int CZPop(int Ch9) { short CzDen; @@ -444,6 +485,7 @@ CZPop(int Ch9) } +int IZPop(int Ch9) { short CzDen; @@ -454,6 +496,7 @@ IZPop(int Ch9) } +void BuildHouse(int value) { short z, score, hscore, BestLoc; @@ -487,6 +530,7 @@ BuildHouse(int value) } +void ResPlop (int Den, int Value) { short base; @@ -496,6 +540,7 @@ ResPlop (int Den, int Value) } +void ComPlop (int Den, int Value) { short base; @@ -505,6 +550,7 @@ ComPlop (int Den, int Value) } +void IndPlop (int Den, int Value) { short base; @@ -514,6 +560,7 @@ IndPlop (int Den, int Value) } +int EvalLot (int x, int y) { short z, score; @@ -538,6 +585,7 @@ EvalLot (int x, int y) } +void ZonePlop (int base) { short z, x; @@ -549,7 +597,7 @@ ZonePlop (int base) int yy = SMapY + Zy[z]; if (TestBounds(xx, yy)) { x = Map[xx][yy] & LOMASK; - if ((x >= FLOOD) && (x < ROADBASE)) return (FALSE); + if ((x >= FLOOD) && (x < ROADBASE)) return; } } for (z = 0; z < 9; z++) { @@ -566,6 +614,7 @@ ZonePlop (int base) } +int EvalRes (int traf) { register short Value; @@ -585,6 +634,7 @@ EvalRes (int traf) } +int EvalCom (int traf) { short Value; @@ -595,6 +645,7 @@ EvalCom (int traf) } +int EvalInd (int traf) { if (traf < 0) return (-1000); @@ -602,6 +653,7 @@ EvalInd (int traf) } +int DoFreePop (void) { short count; @@ -621,9 +673,12 @@ DoFreePop (void) } +int SetZPower(void) /* set bit in MapWord depending on powermap */ { +#if 0 short z; +#endif QUAD PowerWrd; /* TestPowerBit was taking alot of time so I inlined it. -Don */ diff --git a/src/sim/sim.c b/src/sim/sim.c index 79a7817..4b2748c 100644 --- a/src/sim/sim.c +++ b/src/sim/sim.c @@ -61,6 +61,12 @@ */ #include "sim.h" +void signal_init(); +void sim_update_evaluations(void); +void sim_update_editors(void); +void sim_update_budgets(void); +void sim_update_graphs(void); +void sim_update_maps(void); /* Sim City */ @@ -97,6 +103,7 @@ char *FirstDisplay = NULL; int ExitReturn = 0; +void sim_exit(int val) { tkMustExit = 1; @@ -104,7 +111,7 @@ sim_exit(int val) } -sim_really_exit(int val) +void sim_really_exit(int val) { DoStopMicropolis(); @@ -236,6 +243,7 @@ SignalExitHandler() } +void signal_init() { signal(SIGHUP, (void (*)())SignalExitHandler); @@ -246,7 +254,7 @@ signal_init() void -sim_update() +sim_update(void) { gettimeofday(&now_time, NULL); @@ -267,6 +275,7 @@ sim_update() } +void sim_update_editors(void) { SimView *view; @@ -285,6 +294,7 @@ sim_update_editors(void) } +void sim_update_maps(void) { SimView *view; @@ -319,12 +329,14 @@ sim_update_maps(void) } +void sim_update_graphs(void) { graphDoer(); } +void sim_update_budgets(void) { if ((sim_skips != 0) && @@ -336,6 +348,7 @@ sim_update_budgets(void) } +void sim_update_evaluations(void) { if ((sim_skips != 0) && @@ -409,7 +422,7 @@ short *CellDst = NULL; void sim_heat(void) { - int x, y, l, r, u, d; + int x, y; static int a = 0; short *src, *dst; register int fl = heat_flow; @@ -546,7 +559,6 @@ sim_heat(void) } } - void sim_timeout_loop(short doSim) { @@ -557,6 +569,7 @@ sim_timeout_loop(short doSim) } +void sim_loop(int doSim) { #ifdef CAM diff --git a/src/sim/w_budget.c b/src/sim/w_budget.c index 5fc5e4f..ce0651e 100644 --- a/src/sim/w_budget.c +++ b/src/sim/w_budget.c @@ -73,8 +73,14 @@ QUAD policeMaxValue; QUAD fireMaxValue; int MustDrawCurrPercents = 0; int MustDrawBudgetWindow = 0; -int SetBudget(char *flowStr, char *previousStr, - char *currentStr, char *collectedStr, short tax); + +void SetBudget(char *flowStr, char *previousStr, + char *currentStr, char *collectedStr, short tax); +void SetBudgetValues(char *roadGot, char *roadWant, + char *policeGot, char *policeWant, + char *fireGot, char *fireWant); +void ShowBudgetWindowAndStartWaiting(void); +void DoBudgetNow(int fromMenu); void InitFundingLevel(void) @@ -90,18 +96,21 @@ void InitFundingLevel(void) } -DoBudget() +void +DoBudget(void) { DoBudgetNow(0); } -DoBudgetFromMenu() +void +DoBudgetFromMenu(void) { DoBudgetNow(1); } +void DoBudgetNow(int fromMenu) { QUAD yumDuckets; @@ -218,12 +227,14 @@ DoBudgetNow(int fromMenu) } +void drawBudgetWindow(void) { MustDrawBudgetWindow = 1; } +void ReallyDrawBudgetWindow(void) { short cashFlow, cashFlow2; @@ -244,38 +255,40 @@ ReallyDrawBudgetWindow(void) sprintf(flowStr, "+%s", dollarStr); } - sprintf(numStr, "%d", TotalFunds); + sprintf(numStr, "%ld", TotalFunds); makeDollarDecimalStr(numStr, previousStr); - sprintf(numStr, "%d", cashFlow2 + TotalFunds); + sprintf(numStr, "%ld", cashFlow2 + TotalFunds); makeDollarDecimalStr(numStr, currentStr); - sprintf(numStr, "%d", TaxFund); + sprintf(numStr, "%ld", TaxFund); makeDollarDecimalStr(numStr, collectedStr); SetBudget(flowStr, previousStr, currentStr, collectedStr, CityTax); } +void drawCurrPercents(void) { MustDrawCurrPercents = 1; } +void ReallyDrawCurrPercents(void) { char num[256]; char fireWant[256], policeWant[256], roadWant[256]; char fireGot[256], policeGot[256], roadGot[256]; - sprintf(num, "%d", fireMaxValue); + sprintf(num, "%ld", fireMaxValue); makeDollarDecimalStr(num, fireWant); - sprintf(num, "%d", policeMaxValue); + sprintf(num, "%ld", policeMaxValue); makeDollarDecimalStr(num, policeWant); - sprintf(num, "%d", roadMaxValue); + sprintf(num, "%ld", roadMaxValue); makeDollarDecimalStr(num, roadWant); sprintf(num, "%d", (int)(fireMaxValue * firePercent)); @@ -293,7 +306,8 @@ ReallyDrawCurrPercents(void) } -UpdateBudgetWindow() +void +UpdateBudgetWindow(void) { if (MustDrawCurrPercents) { ReallyDrawCurrPercents(); @@ -306,7 +320,8 @@ UpdateBudgetWindow() } -UpdateBudget() +void +UpdateBudget(void) { drawCurrPercents(); drawBudgetWindow(); @@ -314,7 +329,8 @@ UpdateBudget() } -ShowBudgetWindowAndStartWaiting() +void +ShowBudgetWindowAndStartWaiting(void) { Eval("UIShowBudgetAndWait"); @@ -322,6 +338,7 @@ ShowBudgetWindowAndStartWaiting() } +void SetBudget(char *flowStr, char *previousStr, char *currentStr, char *collectedStr, short tax) { @@ -333,6 +350,7 @@ SetBudget(char *flowStr, char *previousStr, } +void SetBudgetValues(char *roadGot, char *roadWant, char *policeGot, char *policeWant, char *fireGot, char *fireWant) diff --git a/src/sim/w_con.c b/src/sim/w_con.c index 0d20c9a..9f25893 100644 --- a/src/sim/w_con.c +++ b/src/sim/w_con.c @@ -61,6 +61,13 @@ */ #include "sim.h" +void _FixSingle(int x, int y, short *TileAdrPtr); +void _FixZone(int x, int y, short *TileAdrPtr); +int _LayDoze(int x, int y, short *TileAdrPtr); +int _LayRoad(int x, int y, short *TileAdrPtr); +int _LayRail(int x, int y, short *TileAdrPtr); +int _LayWire(int x, int y, short *TileAdrPtr); + short _RoadTable[16] = { 66, 67, 66, 68, @@ -494,6 +501,7 @@ _LayWire(int x, int y, short *TileAdrPtr) /* comefrom: ConnecTile */ +void _FixZone(int x, int y, short *TileAdrPtr) { _FixSingle(x,y, &TileAdrPtr[0]); @@ -518,6 +526,7 @@ _FixZone(int x, int y, short *TileAdrPtr) /* comefrom: _FixZone */ +void _FixSingle(int x, int y, short *TileAdrPtr) { short Tile; diff --git a/src/sim/w_date.c b/src/sim/w_date.c index 049227b..342f0f3 100644 --- a/src/sim/w_date.c +++ b/src/sim/w_date.c @@ -66,6 +66,14 @@ short NewDate = 0; Tcl_HashTable DateCmds; int DateUpdateTime = 200; +void DoUpdateDate(SimDate *date); +void DoNewDate(SimDate *date); +void DoResizeDate(SimDate *date, int w, int h); +void DestroyDate(SimDate *date); +void InitNewDate(SimDate *date); +int ConfigureSimDate(Tcl_Interp *interp, SimDate *date, + int argc, char **argv, int flags); + #define DEF_DATE_FONT "-Adobe-Helvetica-Bold-R-Normal-*-140-*" #define DEF_DATE_BG_COLOR "#b0b0b0" @@ -111,8 +119,6 @@ DisplaySimDate(ClientData clientData) { SimDate *date = (SimDate *) clientData; Tk_Window tkwin = date->tkwin; - Pixmap pm = None; - Drawable d; date->flags &= ~VIEW_REDRAW_PENDING; //fprintf(stderr, "DisplaySimDate cleared VIEW_REDRAW_PENDING\n"); @@ -138,6 +144,7 @@ DestroySimDate(ClientData clientData) } +void EventuallyRedrawDate(SimDate *date) { if (!(date->flags & VIEW_REDRAW_PENDING)) { @@ -255,8 +262,6 @@ int DateCmdconfigure(DATE_ARGS) int DateCmdposition(DATE_ARGS) { - int result = TCL_OK; - if ((argc != 2) && (argc != 4)) { return TCL_ERROR; } @@ -320,8 +325,6 @@ int DateCmdVisible(DATE_ARGS) int DateCmdReset(DATE_ARGS) { - int range; - if (argc != 2) { Tcl_AppendResult(interp, "wrong # args", (char *) NULL); return TCL_ERROR; @@ -339,8 +342,6 @@ int DateCmdReset(DATE_ARGS) int DateCmdSet(DATE_ARGS) { - int range; - if (argc != 4) { Tcl_AppendResult(interp, "wrong # args", (char *) NULL); return TCL_ERROR; @@ -379,7 +380,7 @@ DoDateCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&DateCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&DateCmds, argv[1]))) { cmd = (int (*)())ent->clientData; Tk_Preserve((ClientData) date); result = cmd(date, interp, argc, argv); @@ -472,10 +473,9 @@ ConfigureSimDate(Tcl_Interp *interp, SimDate *date, } -date_command_init() +void +date_command_init(void) { - int new; - Tcl_CreateCommand(tk_mainInterp, "dateview", DateViewCmd, (ClientData)MainWindow, (void (*)()) NULL); @@ -492,11 +492,9 @@ date_command_init() } +void InitNewDate(SimDate *date) { - int d = 8; - struct XDisplay *xd; - date->next = NULL; /* This stuff was initialized in our caller (DateCmd) */ @@ -537,6 +535,7 @@ InitNewDate(SimDate *date) } +void DestroyDate(SimDate *date) { SimDate **gp; @@ -562,10 +561,9 @@ DestroyDate(SimDate *date) } +void DoResizeDate(SimDate *date, int w, int h) { - int resize = 0; - date->w_width = w; date->w_height = h; if (date->pixmap != None) { @@ -584,6 +582,7 @@ DoResizeDate(SimDate *date, int w, int h) } +void DoNewDate(SimDate *date) { sim->dates++; date->next = sim->date; sim->date = date; @@ -594,15 +593,15 @@ DoNewDate(SimDate *date) #define BORDER 1 +void DoUpdateDate(SimDate *date) { Display *dpy; GC gc; Pixmap pm; int *pix; - int w, h, i, j, x, y; + int w, h, x, y; int tx, ty; - float sx, sy; if (!date->visible) { return; diff --git a/src/sim/w_editor.c b/src/sim/w_editor.c index b13e326..7b0c658 100644 --- a/src/sim/w_editor.c +++ b/src/sim/w_editor.c @@ -69,6 +69,16 @@ int BobHeight = 8; extern Tk_ConfigSpec TileViewConfigSpecs[]; +void ClipTheOverlay(SimView *view); +void DrawTheOverlay(SimView *view, GC gc, Pixmap pm, int color, + int top, int bottom, int left, int right, + int onoverlay); +void DrawOverlay(SimView *view); +void DrawCursor(SimView *view); +void DrawPending(SimView *view); +void DrawOutside(SimView *view); +void HandleAutoGoto(SimView *view); + int EditorCmdconfigure(VIEW_ARGS) { @@ -409,8 +419,6 @@ int EditorCmdPanBy(VIEW_ARGS) int EditorCmdTweakCursor(VIEW_ARGS) { - int x, y; - XWarpPointer (view->x->dpy, None, None, 0, 0, 0, 0, 0, 0); return TCL_OK; @@ -642,7 +650,6 @@ int EditorCmdShowMe(VIEW_ARGS) int EditorCmdFollow(VIEW_ARGS) { - int id; SimSprite *sprite; if ((argc != 2) && (argc != 3)) { @@ -736,8 +743,10 @@ int EditorCmdDynamicFilter(VIEW_ARGS) int EditorCmdWriteJpeg(VIEW_ARGS) { +#if 0 int val; char *fileName = argv[2]; +#endif if (argc != 3) { return TCL_ERROR; @@ -749,9 +758,9 @@ int EditorCmdWriteJpeg(VIEW_ARGS) } -editor_command_init() +void +editor_command_init(void) { - int new; extern int TileViewCmd(CLIENT_ARGS); Tcl_CreateCommand(tk_mainInterp, "editorview", TileViewCmd, @@ -810,7 +819,7 @@ DoEditorCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&EditorCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&EditorCmds, argv[1]))) { cmd = (int (*)())ent->clientData; Tk_Preserve((ClientData) view); result = cmd(view, interp, argc, argv); @@ -828,6 +837,7 @@ DoEditorCmd(CLIENT_ARGS) /*************************************************************************/ +void DoNewEditor(SimView *view) { sim->editors++; view->next = sim->editor; sim->editor = view; @@ -835,6 +845,7 @@ DoNewEditor(SimView *view) } +void DoUpdateEditor(SimView *view) { int dx, dy, i; @@ -852,12 +863,12 @@ DoUpdateEditor(SimView *view) view->skips)) { if (sim_skips) { if (sim_skip > 0) { - return 0; + return; } } else { if (view->skip > 0) { --view->skip; - return 0; + return; } else { view->skip = view->skips; } @@ -918,6 +929,7 @@ DoUpdateEditor(SimView *view) } +void HandleAutoGoto(SimView *view) { if (view->follow != NULL) { @@ -932,7 +944,7 @@ HandleAutoGoto(SimView *view) view->auto_going && (view->tool_mode == 0)) { int dx, dy; - int panx, pany, speed; + int speed; double dist, sloth; speed = view->auto_speed; @@ -977,6 +989,7 @@ HandleAutoGoto(SimView *view) } } +void DrawOutside(SimView *view) { Pixmap pm = view->pixmap2; @@ -1014,6 +1027,7 @@ DrawOutside(SimView *view) char CursorDashes[] = { 4, 4 }; +void DrawPending(SimView *view) { Pixmap pm = view->pixmap2; @@ -1078,6 +1092,7 @@ DrawPending(SimView *view) } +void DrawCursor(SimView *view) { Pixmap pm = Tk_WindowId(view->tkwin); @@ -1406,6 +1421,7 @@ DrawCursor(SimView *view) } +void TimeElapsed(struct timeval *elapsed, struct timeval *start, struct timeval *finish) @@ -1423,6 +1439,7 @@ TimeElapsed(struct timeval *elapsed, +void DrawOverlay(SimView *view) { int width = view->w_width; @@ -1512,6 +1529,7 @@ DrawOverlay(SimView *view) } +void DrawTheOverlay(SimView *view, GC gc, Pixmap pm, int color, int top, int bottom, int left, int right, int onoverlay) @@ -1555,6 +1573,7 @@ DrawTheOverlay(SimView *view, GC gc, Pixmap pm, int color, } +void ClipTheOverlay(SimView *view) { if (view->x->color) { diff --git a/src/sim/w_eval.c b/src/sim/w_eval.c index dd628f4..ec0cf33 100644 --- a/src/sim/w_eval.c +++ b/src/sim/w_eval.c @@ -61,6 +61,13 @@ */ #include "sim.h" +void SetEvaluation(char *changed, char *score, + char *ps0, char *ps1, char *ps2, char *ps3, + char *pv0, char *pv1, char *pv2, char *pv3, + char *pop, char *delta, char *assessed_dollars, + char *cityclass, char *citylevel, + char *goodyes, char *goodno, char *title); + char *cityClassStr[6] = { "VILLAGE", "TOWN", "CITY", "CAPITAL", "METROPOLIS", "MEGALOPOLIS" @@ -77,6 +84,7 @@ char *probStr[10] = { /* comefrom: DoSubUpDate scoreDoer */ +void doScoreCard(void) { char title[256], @@ -103,9 +111,9 @@ doScoreCard(void) sprintf(prob1, "%d%%", ProblemVotes[ProblemOrder[1]]); sprintf(prob2, "%d%%", ProblemVotes[ProblemOrder[2]]); sprintf(prob3, "%d%%", ProblemVotes[ProblemOrder[3]]); - sprintf(pop, "%d", CityPop); - sprintf(delta, "%d", deltaCityPop); - sprintf(assessed, "%d", CityAssValue); + sprintf(pop, "%ld", CityPop); + sprintf(delta, "%ld", deltaCityPop); + sprintf(assessed, "%ld", CityAssValue); makeDollarDecimalStr(assessed, assessed_dollars); sprintf(score, "%d", CityScore); @@ -126,12 +134,14 @@ doScoreCard(void) } -ChangeEval() +void +ChangeEval(void) { EvalChanged = 1; } +void scoreDoer(void) { if (EvalChanged) { @@ -141,6 +151,7 @@ scoreDoer(void) } +void SetEvaluation(char *changed, char *score, char *ps0, char *ps1, char *ps2, char *ps3, char *pv0, char *pv1, char *pv2, char *pv3, diff --git a/src/sim/w_graph.c b/src/sim/w_graph.c index 950799f..b86d959 100644 --- a/src/sim/w_graph.c +++ b/src/sim/w_graph.c @@ -71,6 +71,11 @@ short Graph10Max, Graph120Max; Tcl_HashTable GraphCmds; int GraphUpdateTime = 100; +void DoUpdateGraph(SimGraph *graph); +void DoNewGraph(SimGraph *graph); +void DoResizeGraph(SimGraph *graph, int w, int h); +void InitNewGraph(SimGraph *graph); + #define DEF_GRAPH_FONT "-Adobe-Helvetica-Bold-R-Normal-*-140-*" #define DEF_GRAPH_BG_COLOR "#b0b0b0" @@ -104,8 +109,6 @@ DisplaySimGraph(ClientData clientData) { SimGraph *graph = (SimGraph *) clientData; Tk_Window tkwin = graph->tkwin; - Pixmap pm = None; - Drawable d; graph->flags &= ~VIEW_REDRAW_PENDING; @@ -133,6 +136,7 @@ DestroySimGraph(ClientData clientData) } +void EventuallyRedrawGraph(SimGraph *graph) { if (!(graph->flags & VIEW_REDRAW_PENDING)) { @@ -209,8 +213,6 @@ int GraphCmdconfigure(GRAPH_ARGS) int GraphCmdposition(GRAPH_ARGS) { - int result = TCL_OK; - if ((argc != 2) && (argc != 4)) { return TCL_ERROR; } @@ -336,7 +338,7 @@ DoGraphCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&GraphCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&GraphCmds, argv[1]))) { cmd = (int (*)())ent->clientData; Tk_Preserve((ClientData) graph); result = cmd(graph, interp, argc, argv); @@ -434,10 +436,9 @@ unsigned char HistColor[] = { }; -graph_command_init() +void +graph_command_init(void) { - int new; - Tcl_CreateCommand(tk_mainInterp, "graphview", GraphViewCmd, (ClientData)MainWindow, (void (*)()) NULL); @@ -568,9 +569,10 @@ initGraphs(void) /* comefrom: InitWillStuff */ +void InitGraphMax(void) { - register x; + register int x; ResHisMax = 0; ComHisMax = 0; @@ -604,11 +606,9 @@ InitGraphMax(void) } +void InitNewGraph(SimGraph *graph) { - int d = 8; - struct XDisplay *xd; - graph->next = NULL; graph->range = 10; graph->mask = ALL_HISTORIES; @@ -641,6 +641,7 @@ InitNewGraph(SimGraph *graph) } +void DestroyGraph(SimGraph *graph) { SimGraph **gp; @@ -666,10 +667,9 @@ DestroyGraph(SimGraph *graph) } +void DoResizeGraph(SimGraph *graph, int w, int h) { - int resize = 0; - graph->w_width = w; graph->w_height = h; if (graph->pixmap != None) { @@ -688,6 +688,7 @@ DoResizeGraph(SimGraph *graph, int w, int h) } +void DoNewGraph(SimGraph *graph) { sim->graphs++; graph->next = sim->graph; sim->graph = graph; @@ -698,6 +699,7 @@ DoNewGraph(SimGraph *graph) #define BORDER 5 +void DoUpdateGraph(SimGraph *graph) { Display *dpy; diff --git a/src/sim/w_inter.c b/src/sim/w_inter.c index 33e7771..cf7c7c9 100644 --- a/src/sim/w_inter.c +++ b/src/sim/w_inter.c @@ -295,6 +295,8 @@ static void TrackInterval _ANSI_ARGS_((Interval *intervalPtr, static void StartTrackInterval _ANSI_ARGS_((Interval *intervalPtr, int value)); static int ValueToPixel _ANSI_ARGS_((Interval *intervalPtr, int value)); + +static void NotifyInterval(register Interval *intervalPtr); /* *-------------------------------------------------------------- @@ -799,7 +801,7 @@ DisplayVerticalInterval(clientData) register Interval *intervalPtr = (Interval *) clientData; register Tk_Window tkwin = intervalPtr->tkwin; int tickRightEdge, valueRightEdge, labelLeftEdge, intervalLeftEdge; - int totalPixels, x, y, width, height, tickValue, min, max; + int totalPixels, x, width, height, tickValue, min, max; int relief; Tk_3DBorder sliderBorder; @@ -1013,7 +1015,7 @@ DisplayHorizontalInterval(clientData) register Interval *intervalPtr = (Interval *) clientData; register Tk_Window tkwin = intervalPtr->tkwin; int tickBottom, valueBottom, labelBottom, intervalBottom; - int totalPixels, x, y, width, height, tickValue, min, max; + int totalPixels, y, width, height, tickValue, min, max; int relief; Tk_3DBorder sliderBorder; @@ -1438,9 +1440,6 @@ StartTrackInterval(intervalPtr, value) int value; /* New value for interval. Gets * adjusted if it's off the interval. */ { - int result; - char string[20]; - if ((value < intervalPtr->fromValue) ^ (intervalPtr->toValue < intervalPtr->fromValue)) { value = intervalPtr->fromValue; @@ -1467,8 +1466,6 @@ TrackInterval(intervalPtr, value) register Interval *intervalPtr; /* Info about widget. */ int value; { - int result; - char string[20]; int min, max, delta, lastmin, lastmax; @@ -1548,8 +1545,8 @@ SetInterval(intervalPtr, min, max, notify) } -NotifyInterval(intervalPtr) - register Interval *intervalPtr; /* Info about widget. */ +static void +NotifyInterval(register Interval *intervalPtr) { int result; char string[256]; diff --git a/src/sim/w_keys.c b/src/sim/w_keys.c index 64c5105..3e448f7 100644 --- a/src/sim/w_keys.c +++ b/src/sim/w_keys.c @@ -79,7 +79,8 @@ static char LastKeys[5]; */ -ResetLastKeys() +void +ResetLastKeys(void) { LastKeys[0] = ' '; LastKeys[1] = ' '; @@ -91,6 +92,7 @@ ResetLastKeys() /* comefrom: processEvent */ +void doKeyDown(SimView *view, short charCode) { LastKeys[0] = LastKeys[1]; @@ -291,6 +293,7 @@ doKeyDown(SimView *view, short charCode) /* comefrom: processEvent */ +void doKeyUp(SimView *view, short charCode) { switch(charCode) { diff --git a/src/sim/w_map.c b/src/sim/w_map.c index 8d4e5b8..2157088 100644 --- a/src/sim/w_map.c +++ b/src/sim/w_map.c @@ -69,8 +69,12 @@ extern Tk_ConfigSpec TileViewConfigSpecs[]; Ink *NewInk(); +void DrawMapInk(SimView *view); +void WireDrawMap(SimView *view); +void DrawMapEditorViews(SimView *view); +int MapCmdconfigure(VIEW_ARGS) { int result = TCL_OK; @@ -88,6 +92,7 @@ MapCmdconfigure(VIEW_ARGS) return result; } +int MapCmdposition(VIEW_ARGS) { if ((argc != 2) && (argc != 4)) { @@ -103,6 +108,7 @@ MapCmdposition(VIEW_ARGS) return TCL_OK; } +int MapCmdsize(VIEW_ARGS) { if ((argc != 2) && (argc != 4)) { @@ -124,6 +130,7 @@ MapCmdsize(VIEW_ARGS) return TCL_OK; } +int MapCmdMapState(VIEW_ARGS) { int state; @@ -145,6 +152,7 @@ MapCmdMapState(VIEW_ARGS) return TCL_OK; } +int MapCmdShowEditors(VIEW_ARGS) { int val; @@ -165,6 +173,7 @@ MapCmdShowEditors(VIEW_ARGS) return TCL_OK; } +int MapCmdPanStart(VIEW_ARGS) { int x, y, left, right, top, bottom, width, height; @@ -208,6 +217,7 @@ gotit: return TCL_OK; } +int MapCmdPanTo(VIEW_ARGS) { int x, y, dx, dy; @@ -238,6 +248,7 @@ MapCmdPanTo(VIEW_ARGS) return TCL_OK; } +int MapCmdVisible(VIEW_ARGS) { int visible; @@ -260,6 +271,7 @@ MapCmdVisible(VIEW_ARGS) return TCL_OK; } +int MapCmdViewAt(VIEW_ARGS) { int x, y; @@ -280,9 +292,9 @@ MapCmdViewAt(VIEW_ARGS) } -map_command_init() +void +map_command_init(void) { - int new; extern int TileViewCmd(CLIENT_ARGS); Tcl_CreateCommand(tk_mainInterp, "mapview", TileViewCmd, @@ -316,7 +328,7 @@ DoMapCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&MapCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&MapCmds, argv[1]))) { cmd = (int (*)())ent->clientData; Tk_Preserve((ClientData) view); result = cmd(view, interp, argc, argv); @@ -332,6 +344,7 @@ DoMapCmd(CLIENT_ARGS) /*************************************************************************/ +void DoNewMap(SimView *view) { sim->maps++; view->next = sim->map; sim->map = view; @@ -417,12 +430,12 @@ int DoUpdateMap(SimView *view) } +void DrawMapEditorViews(SimView *view) { Pixmap pm = Tk_WindowId(view->tkwin); struct SimView *ed; int left, right, top, bottom, width, height; - int mine; XSetLineAttributes(view->x->dpy, view->x->gc, 1, LineSolid, CapButt, JoinBevel); @@ -481,6 +494,7 @@ struct Pix { struct Pix pix[MAX_PIX]; +int CompareColor(struct Pix *p1, struct Pix *p2) { register char c1 = p1->color, c2 = p2->color; @@ -491,11 +505,15 @@ CompareColor(struct Pix *p1, struct Pix *p2) } +void WireDrawMap(SimView *view) { - int different, x, y, i, last, pts; + int different, x, y; unsigned char *old, *new; +#if 0 XPoint *points; + int i, last, pts; +#endif if (!view->x->color) { MemDrawMap(view); @@ -570,10 +588,10 @@ WireDrawMap(SimView *view) } +void DrawMapInk(SimView *view) { Pixmap pm = view->pixmap2; - SimView *v; Ink *ink, *ink2 = NewInk(); int i, X, Y, x, y; diff --git a/src/sim/w_piem.c b/src/sim/w_piem.c index 60b7ea9..17d302f 100644 --- a/src/sim/w_piem.c +++ b/src/sim/w_piem.c @@ -368,6 +368,9 @@ static void NeverPopupPieMenu _ANSI_ARGS_((PieMenu *menuPtr)); static void EventuallyPopupPieMenu _ANSI_ARGS_((PieMenu *menuPtr)); static void DeferPopupPieMenu _ANSI_ARGS_((PieMenu *menuPtr)); static void ShapePieMenu _ANSI_ARGS_((PieMenu *menuPtr)); +static void LayoutPieMenu(PieMenu *menu); +static void UpdatePieMenuEntries(PieMenu *menuPtr); +static int CalcPieMenuItem(PieMenu *menu, int x, int y); /* @@ -546,8 +549,6 @@ PieMenuWidgetCmd(clientData, interp, argc, argv) DeferPopupPieMenu(menuPtr); } else if ((c == 's') && (strncmp(argv[1], "show", length) == 0) && (length >= 2)) { - int index; - if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " show\"", (char *) NULL); @@ -556,8 +557,6 @@ PieMenuWidgetCmd(clientData, interp, argc, argv) NowPopupPieMenu(menuPtr); } else if ((c == 'p') && (strncmp(argv[1], "pending", length) == 0) && (length >= 2)) { - int index; - if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " pending\"", (char *) NULL); @@ -567,8 +566,6 @@ PieMenuWidgetCmd(clientData, interp, argc, argv) (menuPtr->flags & POPUP_PENDING) ? 1 : 0); } else if ((c == 'd') && (strncmp(argv[1], "defer", length) == 0) && (length >= 2)) { - int index; - if (argc != 2) { Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " defer\"", (char *) NULL); @@ -768,7 +765,10 @@ PieMenuWidgetCmd(clientData, interp, argc, argv) } Tk_Release((ClientData) mePtr); } else if ((c == 'p') && (strncmp(argv[1], "post", length) == 0)) { - int x, y, ix, iy, tmp, err; + int x, y; +#if 0 + int ix, iy, tmp, err; +#endif Tk_Uid group; if ((argc != 4) && (argc != 5)) { @@ -1355,7 +1355,6 @@ DisplayPieMenu(clientData) register PieMenu *menuPtr = (PieMenu *) clientData; register Tk_Window tkwin = menuPtr->tkwin; XFontStruct *fontPtr; - int index; menuPtr->flags &= ~REDRAW_PENDING; if ((menuPtr->tkwin == NULL) || !Tk_IsMapped(menuPtr->tkwin)) { @@ -1428,8 +1427,8 @@ UpdatePieMenu(clientData) } -UpdatePieMenuEntries(menuPtr) - PieMenu *menuPtr; +static void +UpdatePieMenuEntries(PieMenu *menuPtr) { register PieMenuEntry *mePtr; register Tk_Window tkwin = menuPtr->tkwin; @@ -1521,7 +1520,7 @@ GetPieMenuIndex(interp, menuPtr, string, indexPtr) * manual entry for valid .*/ int *indexPtr; /* Where to store converted relief. */ { - int i, y; + int i; if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { *indexPtr = menuPtr->active; @@ -1787,10 +1786,7 @@ UnpostSubPieMenu(interp, menuPtr) * reporting errors. */ register PieMenu *menuPtr; /* Information about menu as a whole. */ { - char string[30]; - int result, x, y, win_x, win_y; - unsigned int key_buttons; - Window root, child; + int result; if (menuPtr->postedPie == NULL) { return TCL_OK; @@ -1909,13 +1905,11 @@ ActivatePieMenuEntry(menuPtr, index, preview) } -int -CalcPieMenuItem(menu, x, y) - PieMenu *menu; - int x, y; +static int +CalcPieMenuItem(PieMenu *menu, int x, int y) { register PieMenuEntry *it, *last_it; - int i, j, order, quadrant; + int i, order = 0, quadrant; int numerator, denominator; int first, last_i, last_order; @@ -2072,8 +2066,8 @@ case 3: /* } -LayoutPieMenu(menu) - PieMenu *menu; +static void +LayoutPieMenu(PieMenu *menu) { int i; int total_slice, radius; diff --git a/src/sim/w_resrc.c b/src/sim/w_resrc.c index 89e7538..23fc2aa 100644 --- a/src/sim/w_resrc.c +++ b/src/sim/w_resrc.c @@ -63,10 +63,10 @@ #ifdef MSDOS -#define PATHSTR "%s\\%c%c%c%c.%d" +#define PATHSTR "%s\\%c%c%c%c.%ld" #define PERMSTR "rb" #else -#define PATHSTR "%s/%c%c%c%c.%d" +#define PATHSTR "%s/%c%c%c%c.%ld" #define PERMSTR "r" #endif @@ -162,6 +162,7 @@ ResourceID(Handle h) } +void GetIndString(char *str, int id, short num) { struct StringTable **tp, *st = NULL; diff --git a/src/sim/w_sim.c b/src/sim/w_sim.c index c256e1e..fcfa60f 100644 --- a/src/sim/w_sim.c +++ b/src/sim/w_sim.c @@ -325,8 +325,6 @@ int SimCmdDelay(ARGS) int SimCmdWorldX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -338,8 +336,6 @@ int SimCmdWorldX(ARGS) int SimCmdWorldY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -502,7 +498,7 @@ int SimCmdFunds(ARGS) Kick(); } - sprintf(interp->result, "%d", TotalFunds); + sprintf(interp->result, "%ld", TotalFunds); return (TCL_OK); } @@ -731,8 +727,6 @@ int SimCmdSound(ARGS) int SimCmdFlush(ARGS) { - int style; - if (argc != 2) { return (TCL_ERROR); } @@ -778,7 +772,7 @@ int SimCmdDonDither(ARGS) DonDither = dd; } - sprintf(interp->result, "%d", DonDither); + sprintf(interp->result, "%ld", DonDither); return (TCL_OK); } @@ -935,7 +929,7 @@ int SimCmdFill(ARGS) int SimCmdDynamicData(ARGS) { - int index, val; + int index; if ((argc != 3) && (argc != 4)) { return (TCL_ERROR); @@ -1019,8 +1013,6 @@ int SimCmdUpdate(ARGS) int SimCmdLandValue(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1032,8 +1024,6 @@ int SimCmdLandValue(ARGS) int SimCmdTraffic(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1045,8 +1035,6 @@ int SimCmdTraffic(ARGS) int SimCmdCrime(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1058,8 +1046,6 @@ int SimCmdCrime(ARGS) int SimCmdUnemployment(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1071,8 +1057,6 @@ int SimCmdUnemployment(ARGS) int SimCmdFires(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1084,8 +1068,6 @@ int SimCmdFires(ARGS) int SimCmdPollution(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1097,8 +1079,6 @@ int SimCmdPollution(ARGS) int SimCmdPolMaxX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1110,8 +1090,6 @@ int SimCmdPolMaxX(ARGS) int SimCmdPolMaxY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1123,8 +1101,6 @@ int SimCmdPolMaxY(ARGS) int SimCmdTrafMaxX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1136,8 +1112,6 @@ int SimCmdTrafMaxX(ARGS) int SimCmdTrafMaxY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1149,8 +1123,6 @@ int SimCmdTrafMaxY(ARGS) int SimCmdMeltX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1162,8 +1134,6 @@ int SimCmdMeltX(ARGS) int SimCmdMeltY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1175,8 +1145,6 @@ int SimCmdMeltY(ARGS) int SimCmdCrimeMaxX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1188,8 +1156,6 @@ int SimCmdCrimeMaxX(ARGS) int SimCmdCrimeMaxY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1201,8 +1167,6 @@ int SimCmdCrimeMaxY(ARGS) int SimCmdCenterX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1214,8 +1178,6 @@ int SimCmdCenterX(ARGS) int SimCmdCenterY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1227,8 +1189,6 @@ int SimCmdCenterY(ARGS) int SimCmdFloodX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1240,8 +1200,6 @@ int SimCmdFloodX(ARGS) int SimCmdFloodY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1253,8 +1211,6 @@ int SimCmdFloodY(ARGS) int SimCmdCrashX(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1266,8 +1222,6 @@ int SimCmdCrashX(ARGS) int SimCmdCrashY(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1279,8 +1233,6 @@ int SimCmdCrashY(ARGS) int SimCmdDollars(ARGS) { - int val; - if (argc != 2) { return (TCL_ERROR); } @@ -1390,7 +1342,7 @@ int SimCmdPlatform(ARGS) int SimCmdVersion(ARGS) { - sprintf(interp->result, MicropolisVersion); + strcpy(interp->result, MicropolisVersion); return (TCL_OK); } @@ -1420,7 +1372,6 @@ int SimCmdOpenWebBrowser(ARGS) int SimCmdQuoteURL(ARGS) { - int result = 1; char buf[2048]; char *from, *to; int ch; @@ -1542,7 +1493,7 @@ SimCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&SimCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&SimCmds, argv[1]))) { cmd = (int (*)())ent->clientData; result = cmd(interp, argc, argv); } else { @@ -1552,10 +1503,9 @@ SimCmd(CLIENT_ARGS) } -sim_command_init() +void +sim_command_init(void) { - int new; - Tcl_CreateCommand(tk_mainInterp, "sim", SimCmd, (ClientData)MainWindow, (void (*)()) NULL); diff --git a/src/sim/w_sound.c b/src/sim/w_sound.c index 7558e47..a903ae7 100644 --- a/src/sim/w_sound.c +++ b/src/sim/w_sound.c @@ -145,7 +145,8 @@ static int SoundInitialized = 0; Mix_Chunk *rumble; -InitializeSound() +void +InitializeSound(void) { int reserved_chans; char buf[256]; @@ -184,6 +185,7 @@ InitializeSound() } +void ShutDownSound() { int i; @@ -204,6 +206,7 @@ ShutDownSound() } +void MakeSound(char *channel, char *id) { char buf[256]; @@ -237,6 +240,7 @@ MakeSound(char *channel, char *id) fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError()); } +void StartBulldozer(void) { if (!UserSoundOn) return; @@ -249,6 +253,7 @@ StartBulldozer(void) } +void StopBulldozer(void) { if (!UserSoundOn) return; @@ -258,16 +263,19 @@ StopBulldozer(void) } #else /* WITH_SDL_MIXER */ +void InitializeSound() { SoundInitialized = 1; } +void ShutDownSound() { SoundInitialized = 0; } +void MakeSound(char *channel, char *id) { char filename[256], player[256]; @@ -315,17 +323,20 @@ MakeSound(char *channel, char *id) } } +void StartBulldozer(void) { MakeSound(0, "Rumble"); } +void StopBulldozer(void) { } #endif +void MakeSoundOn(SimView *view, char *channel, char *id) { if (!UserSoundOn) return; @@ -336,22 +347,26 @@ MakeSoundOn(SimView *view, char *channel, char *id) /* XXX comefrom: doKeyEvent */ +void SoundOff(void) { ShutDownSound(); } +void DoStartSound(char *channel, char *id) { MakeSound(channel, id); } +void DoStopSound(char *id) { StopBulldozer(); } +int SoundCmd(CLIENT_ARGS) { if (!strcmp(argv[2], "Rumble")) @@ -361,13 +376,15 @@ SoundCmd(CLIENT_ARGS) return 0; } +int DozerCmd(CLIENT_ARGS) { StopBulldozer(); return 0; } -sound_command_init() +void +sound_command_init(void) { Tcl_CreateCommand(tk_mainInterp, "playsound", SoundCmd, (ClientData)NULL, (void (*)()) NULL); diff --git a/src/sim/w_sprite.c b/src/sim/w_sprite.c index 7ecc045..1268e3d 100644 --- a/src/sim/w_sprite.c +++ b/src/sim/w_sprite.c @@ -70,6 +70,23 @@ short Cycle; SimSprite *GlobalSprites[OBJN]; SimSprite *NewSprite(char *name, int type, int x, int y); +void MonsterHere(int x, int y); +void MakeShipHere(int x, int y); +void StartFire(int x, int y); +void OFireZone(int Xloc, int Yloc, int ch); +void Destroy(int ox, int oy); +void ExplodeSprite(SimSprite *sprite); +int CanDriveOn(int x, int y); +void DoBusSprite(SimSprite *sprite); +void DoExplosionSprite(SimSprite *sprite); +void DoTornadoSprite(SimSprite *sprite); +void DoMonsterSprite(SimSprite *sprite); +void DoShipSprite(SimSprite *sprite); +void DoAirplaneSprite(SimSprite *sprite); +void DoCopterSprite(SimSprite *sprite); +void DoTrainSprite(SimSprite *sprite); +void DrawSprite(SimView *view, SimSprite *sprite); +void InitSprite(SimSprite *sprite, int x, int y); #define TRA_GROOVE_X -39 @@ -109,7 +126,7 @@ DoSpriteCmd(CLIENT_ARGS) return TCL_ERROR; } - if (ent = Tcl_FindHashEntry(&SpriteCmds, argv[1])) { + if ((ent = Tcl_FindHashEntry(&SpriteCmds, argv[1]))) { cmd = (int (*)())ent->clientData; Tk_Preserve((ClientData) sprite); result = cmd(sprite, interp, argc, argv); @@ -198,7 +215,8 @@ int SpriteCmdInit(SPRITE_ARGS) } -sprite_command_init() +void +sprite_command_init(void) { int i; @@ -269,6 +287,7 @@ NewSprite(char *name, int type, int x, int y) } +void InitSprite(SimSprite *sprite, int x, int y) { sprite->x = x; sprite->y = y; @@ -381,7 +400,8 @@ InitSprite(SimSprite *sprite, int x, int y) } -DestroyAllSprites() +void +DestroyAllSprites(void) { SimSprite *sprite; @@ -391,6 +411,7 @@ DestroyAllSprites() } +void DestroySprite(SimSprite *sprite) { SimView *view; @@ -458,6 +479,7 @@ MakeNewSprite(int type, int x, int y) } +void DrawObjects(SimView *view) { SimSprite *sprite; @@ -479,6 +501,7 @@ DrawObjects(SimView *view) } +void DrawSprite(SimView *view, SimSprite *sprite) { Pixmap pict, mask; @@ -533,6 +556,7 @@ short TurnTo(int p, int d) } +int TryOther(int Tpoo, int Told, int Tnew) { register short z; @@ -588,6 +612,7 @@ short GetDir(int orgX, int orgY, int desX, int desY) } +int GetDis(int x1, int y1, int x2, int y2) { register short dispX, dispY; @@ -611,7 +636,7 @@ int CheckSpriteCollision(SimSprite *s1, SimSprite *s2) } -MoveObjects() +void MoveObjects(void) { SimSprite *sprite; @@ -660,6 +685,7 @@ MoveObjects() } +void DoTrainSprite(SimSprite *sprite) { static short Cx[4] = { 0, 16, 0, -16 }; @@ -710,6 +736,7 @@ DoTrainSprite(SimSprite *sprite) } +void DoCopterSprite(SimSprite *sprite) { static short CDx[9] = { 0, 0, 3, 5, 3, 0, -3, -5, -3 }; @@ -782,6 +809,7 @@ DoCopterSprite(SimSprite *sprite) } +void DoAirplaneSprite(SimSprite *sprite) { static short CDx[12] = { 0, 0, 6, 8, 6, 0, -6, -8, -6, 8, 8, 8 }; @@ -833,6 +861,7 @@ DoAirplaneSprite(SimSprite *sprite) } +void DoShipSprite(SimSprite *sprite) { static short BDx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 }; @@ -910,6 +939,7 @@ DoShipSprite(SimSprite *sprite) } +void DoMonsterSprite(SimSprite *sprite) { static short Gx[5] = { 2, 2, -2, -2, 0 }; @@ -1046,6 +1076,7 @@ DoMonsterSprite(SimSprite *sprite) } +void DoTornadoSprite(SimSprite *sprite) { static short CDx[9] = { 2, 3, 2, 0, -2, -3 }; @@ -1097,6 +1128,7 @@ DoTornadoSprite(SimSprite *sprite) } +void DoExplosionSprite(SimSprite *sprite) { short x, y; @@ -1124,15 +1156,15 @@ DoExplosionSprite(SimSprite *sprite) } +void DoBusSprite(SimSprite *sprite) { static short Dx[5] = { 0, 1, 0, -1, 0 }; static short Dy[5] = { -1, 0, 1, 0, 0 }; static short Dir2Frame[4] = { 1, 2, 1, 2 }; - register int dir, dir2; - int c, dx, dy, crossed, tx, ty, otx, oty; + int dx, dy, tx, ty, otx, oty; int turned = 0; - int speed, z; + int speed = 0, z; #ifdef DEBUGBUS printf("Bus dir %d turn %d frame %d\n", @@ -1350,6 +1382,7 @@ CanDriveOn(int x, int y) } +void ExplodeSprite(SimSprite *sprite) { int x, y; @@ -1406,6 +1439,7 @@ int checkWet(int x) } +void Destroy(int ox, int oy) { short t, z, x, y; @@ -1439,6 +1473,7 @@ Destroy(int ox, int oy) } +void OFireZone(int Xloc, int Yloc, int ch) { register short Xtem, Ytem; @@ -1463,9 +1498,10 @@ OFireZone(int Xloc, int Yloc, int ch) } +void StartFire(int x, int y) { - register t, z; + register int t, z; x >>= 4; y >>= 4; @@ -1481,6 +1517,7 @@ StartFire(int x, int y) } +void GenerateTrain(int x, int y) { if ((TotalPop > 20) && @@ -1491,6 +1528,7 @@ GenerateTrain(int x, int y) } +void GenerateBus(int x, int y) { if ((GetSprite(BUS) == NULL) && @@ -1500,6 +1538,7 @@ GenerateBus(int x, int y) } +void GenerateShip(void) { register short x, y; @@ -1531,15 +1570,17 @@ GenerateShip(void) } -MakeShipHere(int x, int y, int z) +void +MakeShipHere(int x, int y) { MakeSprite(SHI, (x <<4) - (48 - 1), (y <<4)); } +void MakeMonster(void) { - register x, y, z, done = 0; + register int x, y, z, done = 0; SimSprite *sprite; if ((sprite = GetSprite(GOD)) != NULL) { @@ -1564,16 +1605,16 @@ MakeMonster(void) } +void MonsterHere(int x, int y) { - short z; - MakeSprite(GOD, (x <<4) + 48, (y <<4)); ClearMes(); SendMesAt(-21, x + 5, y); } +void GenerateCopter(int x, int y) { if (GetSprite(COP) != NULL) return; @@ -1582,6 +1623,7 @@ GenerateCopter(int x, int y) } +void GeneratePlane(int x, int y) { if (GetSprite(AIR) != NULL) return; @@ -1590,6 +1632,7 @@ GeneratePlane(int x, int y) } +void MakeAirCrash(void) { #ifndef NO_AIRCRASH @@ -1607,6 +1650,7 @@ MakeAirCrash(void) } +void MakeTornado(void) { short x, y; @@ -1625,6 +1669,7 @@ MakeTornado(void) } +void MakeExplosion(int x, int y) { if ((x >= 0) && (x < WORLD_X) && @@ -1634,6 +1679,7 @@ MakeExplosion(int x, int y) } +void MakeExplosionAt(int x, int y) { MakeNewSprite(EXP, x - 40, y - 16); diff --git a/src/sim/w_stubs.c b/src/sim/w_stubs.c index d55ce03..9f4040a 100644 --- a/src/sim/w_stubs.c +++ b/src/sim/w_stubs.c @@ -81,13 +81,20 @@ short MesNum; short EvalChanged; short flagBlink; +void DoStartScenario(int scenario); +void DoStartLoad(void); +void DoReallyStartGame(void); +void DoPlayNewCity(void); + +void Spend(int dollars) { SetFunds(TotalFunds - dollars); } +void SetFunds(int dollars) { TotalFunds = dollars; @@ -97,7 +104,7 @@ SetFunds(int dollars) /* Mac */ -QUAD TickCount() +QUAD TickCount(void) { struct timeval time; @@ -117,7 +124,8 @@ int size; /* w_hlhandlers.c */ -GameStarted() +void +GameStarted(void) { InvalidateMaps(); InvalidateEditors(); @@ -150,24 +158,28 @@ GameStarted() } -DoPlayNewCity() +void +DoPlayNewCity(void) { Eval("UIPlayNewCity"); } -DoReallyStartGame() +void +DoReallyStartGame(void) { Eval("UIReallyStartGame"); } -DoStartLoad() +void +DoStartLoad(void) { Eval("UIStartLoad"); } +void DoStartScenario(int scenario) { char buf[256]; @@ -177,20 +189,23 @@ DoStartScenario(int scenario) } -DropFireBombs() +void +DropFireBombs(void) { Eval("DropFireBombs"); } -InitGame() +void +InitGame(void) { sim_skips = sim_skip = sim_paused = sim_paused_speed = heat_steps = 0; setSpeed(0); } -ReallyQuit() +void +ReallyQuit(void) { sim_exit(0); // Just sets tkMustExit and ExitReturn } diff --git a/src/sim/w_tk.c b/src/sim/w_tk.c index 08c16f9..3ae9037 100644 --- a/src/sim/w_tk.c +++ b/src/sim/w_tk.c @@ -104,14 +104,8 @@ Tk_ConfigSpec TileViewConfigSpecs[] = { int TileViewCmd(CLIENT_ARGS); -int ConfigureTileView(Tcl_Interp *interp, SimView *view, - int argc, char **argv, int flags); static void TileViewEventProc(ClientData clientData, XEvent *eventPtr); static void DestroyTileView(ClientData clientData); - -int ConfigureSimGraph(Tcl_Interp *interp, SimGraph *graph, - int argc, char **argv, int flags); - static void MicropolisTimerProc(ClientData clientData); int SimCmd(CLIENT_ARGS); @@ -241,7 +235,8 @@ ConfigureTileView(Tcl_Interp *interp, SimView *view, } -InvalidateMaps() +void +InvalidateMaps(void) { SimView *view; @@ -255,7 +250,8 @@ InvalidateMaps() } -InvalidateEditors() +void +InvalidateEditors(void) { SimView *view; @@ -269,7 +265,8 @@ InvalidateEditors() } -RedrawMaps() +void +RedrawMaps(void) { SimView *view; @@ -283,7 +280,8 @@ RedrawMaps() } -RedrawEditors() +void +RedrawEditors(void) { SimView *view; @@ -302,8 +300,6 @@ DisplayTileView(ClientData clientData) { SimView *view = (SimView *) clientData; Tk_Window tkwin = view->tkwin; - Pixmap pm = None; - Drawable d; view->flags &= ~VIEW_REDRAW_PENDING; if (view->visible && (tkwin != NULL) && Tk_IsMapped(tkwin)) { @@ -334,6 +330,7 @@ DisplayTileView(ClientData clientData) EraserTo */ +void EventuallyRedrawView(SimView *view) { if (!(view->flags & VIEW_REDRAW_PENDING)) { @@ -344,6 +341,7 @@ EventuallyRedrawView(SimView *view) } +void CancelRedrawView(SimView *view) { if (view->flags & VIEW_REDRAW_PENDING) { @@ -361,7 +359,7 @@ TileAutoScrollProc(ClientData clientData) if (view->tool_mode != 0) { int dx = 0, dy = 0; - int result, root_x, root_y, x, y; + int root_x, root_y, x, y; unsigned int key_buttons; Window root, child; @@ -433,7 +431,7 @@ TileViewEventProc(ClientData clientData, XEvent *eventPtr) (eventPtr->type == MotionNotify))) { int last_x = view->tool_x, last_y = view->tool_y, last_showing = view->tool_showing; - int x, y, showing, autoscroll; + int x, y, showing; if (eventPtr->type == EnterNotify) { showing = 1; @@ -547,6 +545,7 @@ StructureProc(ClientData clientData, XEvent *eventPtr) } +#if 0 static void DelayedMap(ClientData clientData) { @@ -558,8 +557,10 @@ DelayedMap(ClientData clientData) } Tk_MapWindow(MainWindow); } +#endif +void DidStopPan(SimView *view) { char buf[256]; @@ -621,7 +622,8 @@ ReallyStartMicropolisTimer(ClientData clientData) } -StartMicropolisTimer() +void +StartMicropolisTimer(void) { if (sim_timer_idle == 0) { sim_timer_idle = 1; @@ -632,7 +634,8 @@ StartMicropolisTimer() } -StopMicropolisTimer() +void +StopMicropolisTimer(void) { if (sim_timer_idle != 0) { sim_timer_idle = 0; @@ -651,10 +654,11 @@ StopMicropolisTimer() } +void FixMicropolisTimer() { if (sim_timer_set) { - StartMicropolisTimer(NULL); + StartMicropolisTimer(); } } @@ -669,7 +673,8 @@ DelayedUpdate(ClientData clientData) } -Kick() +void +Kick(void) { if (!UpdateDelayed) { UpdateDelayed = 1; @@ -679,7 +684,7 @@ Kick() void -StopEarthquake() +StopEarthquake(void) { ShakeNow = 0; if (earthquake_timer_set) { @@ -689,6 +694,7 @@ StopEarthquake() } +void DoEarthQuake(void) { MakeSound("city", "Explosion-Low"); @@ -702,7 +708,8 @@ DoEarthQuake(void) } -StopToolkit() +void +StopToolkit(void) { if (tk_mainInterp != NULL) { Eval("catch {DoStopMicropolis}"); @@ -710,6 +717,7 @@ StopToolkit() } +int Eval(char *buf) { int result = Tcl_Eval(tk_mainInterp, buf, 0, (char **) NULL); @@ -724,10 +732,8 @@ Eval(char *buf) } -tk_main() +void tk_main(void) { - char *p, *msg; - char buf[20]; char initCmd[256]; Tk_3DBorder border; diff --git a/src/sim/w_tool.c b/src/sim/w_tool.c index d678137..1143b06 100644 --- a/src/sim/w_tool.c +++ b/src/sim/w_tool.c @@ -124,14 +124,18 @@ QUAD toolColors[] = { Ink *NewInk(); -short tally(short tileValue); -int DoSetWandState(SimView *view, short state); +void DoSetWandState(SimView *view, short state); +void DoPendTool(SimView *view, int tool, int x, int y); +void EraserTo(SimView *view, int x, int y); +void EraserStart(SimView *view, int x, int y); +void DoShowZoneStatus(char *str, char *s0, char *s1, char *s2, char *s3, char *s4, int x, int y); /*************************************************************************/ /* UTILITIES */ +void setWandState(SimView *view, short state) { #if 0 @@ -440,14 +444,14 @@ check3x3(SimView *view, short mapH, short mapV, short base, short tool) void check4x4border(short xMap, short yMap) { - Ptr tilePtr; + short *tilePtr; short xPos, yPos; short cnt; xPos = xMap; yPos = yMap - 1; for (cnt = 0; cnt < 4; cnt++) { /* this will do the upper bordering row */ - tilePtr = (Ptr) &Map[xPos][yPos]; + tilePtr = &Map[xPos][yPos]; ConnecTile(xPos, yPos, tilePtr, 0); xPos++; } @@ -455,7 +459,7 @@ check4x4border(short xMap, short yMap) xPos = xMap - 1; yPos = yMap; for (cnt = 0; cnt < 4; cnt++) { /* this will do the left bordering row */ - tilePtr = (Ptr) &Map[xPos][yPos]; + tilePtr = &Map[xPos][yPos]; ConnecTile(xPos, yPos, tilePtr, 0); yPos++; } @@ -463,7 +467,7 @@ check4x4border(short xMap, short yMap) xPos = xMap; yPos = yMap + 4; for (cnt = 0; cnt < 4;cnt++) { /* this will do the bottom bordering row */ - tilePtr = (Ptr) &Map[xPos][yPos]; + tilePtr = &Map[xPos][yPos]; ConnecTile(xPos, yPos, tilePtr, 0); xPos++; } @@ -471,7 +475,7 @@ check4x4border(short xMap, short yMap) xPos = xMap + 4; yPos = yMap; for (cnt = 0; cnt < 4; cnt++) { /* this will do the right bordering row */ - tilePtr = (Ptr) &Map[xPos][yPos]; + tilePtr = &Map[xPos][yPos]; ConnecTile(xPos, yPos, tilePtr, 0); yPos++; } @@ -637,12 +641,13 @@ check6x6(SimView *view, short mapH, short mapV, short base, short tool) if (autoBulldoze) { /* if autoDoze is enabled, add up the cost of bulldozed tiles */ - if (tileValue != 0) + if (tileValue != 0) { if (tally(tileValue)) { cost++; } else { flag = 0; } + } } else { /* check and see if the tile is clear or not */ if (tileValue != 0) { @@ -762,9 +767,11 @@ int getDensityStr(short catNo, short mapH, short mapV) if (z > 100) return (19); return (18); } + return 0; } +void doZoneStatus(short mapH, short mapV) { char localStr[256]; @@ -805,6 +812,7 @@ doZoneStatus(short mapH, short mapV) } +void DoShowZoneStatus(char *str, char *s0, char *s1, char *s2, char *s3, char *s4, int x, int y) { @@ -817,9 +825,10 @@ DoShowZoneStatus(char *str, char *s0, char *s1, char *s2, char *s3, char *s4, /* comefrom: processWand */ +void put3x3Rubble(short x, short y) { - register xx, yy, zz; + register int xx, yy, zz; for (xx = x - 1; xx < x + 2; xx++) { for (yy = y - 1; yy < y + 2; yy++) { @@ -839,9 +848,10 @@ put3x3Rubble(short x, short y) /* comefrom: processWand */ +void put4x4Rubble(short x, short y) { - register xx, yy, zz; + register int xx, yy, zz; for (xx = x - 1; xx < x + 3; xx++) { for (yy = y - 1; yy < y + 3; yy++) { @@ -861,9 +871,10 @@ put4x4Rubble(short x, short y) /* comefrom: processWand */ +void put6x6Rubble(short x, short y) { - register xx, yy, zz; + register int xx, yy, zz; for (xx = x - 1; xx < x + 5; xx++) { for (yy = y - 1; yy < y + 5; yy++) { @@ -882,6 +893,7 @@ put6x6Rubble(short x, short y) } +void DidTool(SimView *view, char *name, short x, short y) { char buf[256]; @@ -894,6 +906,7 @@ DidTool(SimView *view, char *name, short x, short y) } +void DoSetWandState(SimView *view, short state) { char buf[256]; @@ -1306,6 +1319,7 @@ ChalkTool(SimView *view, short x, short y, short color, short first) } +void ChalkStart(SimView *view, int x, int y, int color) { Ink *ink; @@ -1325,9 +1339,12 @@ ChalkStart(SimView *view, int x, int y, int color) } +void ChalkTo(SimView *view, int x, int y) { +#ifdef MOTIONBUFFER int x0, y0, lx, ly; +#endif Ink *ink = (Ink *)view->track_info; #ifdef MOTIONBUFFER @@ -1390,6 +1407,7 @@ EraserTool(SimView *view, short x, short y, short first) } +int InkInBox(Ink *ink, int left, int top, int right, int bottom) { if ((left <= ink->right) && @@ -1424,15 +1442,16 @@ InkInBox(Ink *ink, int left, int top, int right, int bottom) } +void EraserStart(SimView *view, int x, int y) { EraserTo(view, x, y); } +void EraserTo(SimView *view, int x, int y) { - SimView *v; Ink **ip, *ink; for (ip = &sim->overlay; *ip != NULL;) { @@ -1541,6 +1560,7 @@ current_tool(SimView *view, short x, short y, short first) } +void DoTool(SimView *view, short tool, short x, short y) { int result; @@ -1563,6 +1583,7 @@ DoTool(SimView *view, short tool, short x, short y) } +void ToolDown(SimView *view, int x, int y) { int result; @@ -1591,16 +1612,14 @@ ToolDown(SimView *view, int x, int y) } +void ToolUp(SimView *view, int x, int y) { - int result; - - result = ToolDrag(view, x, y); - - return (result); + ToolDrag(view, x, y); } +void ToolDrag(SimView *view, int px, int py) { int x, y, dx, dy, adx, ady, lx, ly, dist; @@ -1623,8 +1642,6 @@ ToolDrag(SimView *view, int px, int py) lx = view->last_x >> 4; ly = view->last_y >> 4; - reset: - dx = x - lx; dy = y - ly; @@ -1684,6 +1701,7 @@ ToolDrag(SimView *view, int px, int py) } +void DoPendTool(SimView *view, int tool, int x, int y) { char buf[256]; diff --git a/src/sim/w_update.c b/src/sim/w_update.c index 168d626..248a311 100644 --- a/src/sim/w_update.c +++ b/src/sim/w_update.c @@ -70,13 +70,21 @@ QUAD LastCityMonth; QUAD LastFunds; QUAD LastR, LastC, LastI; +void UpdateOptionsMenu(int options); +void updateOptions(void); +void SetDemand(double r, double c, double i); +void drawValve(void); +void showValves(void); +void updateDate(void); +void ReallyUpdateFunds(void); + char *dateStr[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; -void DoUpdateHeads() +void DoUpdateHeads(void) { showValves(); doTimeStuff(); @@ -85,38 +93,39 @@ void DoUpdateHeads() } -void UpdateEditors() +void UpdateEditors(void) { InvalidateEditors(); DoUpdateHeads(); } -void UpdateMaps() +void UpdateMaps(void) { InvalidateMaps(); } -void UpdateGraphs() +void UpdateGraphs(void) { ChangeCensus(); } -void UpdateEvaluation() +void UpdateEvaluation(void) { ChangeEval(); } -void UpdateHeads() +void UpdateHeads(void) { MustUpdateFunds = ValveFlag = 1; LastCityTime = LastCityYear = LastCityMonth = LastFunds = LastR = -999999; DoUpdateHeads(); } +void UpdateFunds(void) { MustUpdateFunds = 1; @@ -124,6 +133,7 @@ UpdateFunds(void) } +void ReallyUpdateFunds(void) { char localStr[256], dollarStr[256], buf[256]; @@ -136,7 +146,7 @@ ReallyUpdateFunds(void) if (TotalFunds != LastFunds) { LastFunds = TotalFunds; - sprintf(localStr, "%d", TotalFunds); + sprintf(localStr, "%ld", TotalFunds); makeDollarDecimalStr(localStr, dollarStr); sprintf(localStr, "Funds: %s", dollarStr); @@ -147,7 +157,8 @@ ReallyUpdateFunds(void) } -doTimeStuff(void) +void +doTimeStuff(void) { // if ((CityTime >> 2) != LastCityTime) { updateDate(); @@ -155,6 +166,7 @@ doTimeStuff(void) } +void updateDate(void) { int y; @@ -191,6 +203,7 @@ updateDate(void) } +void showValves(void) { if (ValveFlag) { @@ -200,6 +213,7 @@ showValves(void) } +void drawValve(void) { double r, c, i; @@ -227,6 +241,7 @@ drawValve(void) } +void SetDemand(double r, double c, double i) { char buf[256]; @@ -237,7 +252,8 @@ SetDemand(double r, double c, double i) } -updateOptions() +void +updateOptions(void) { int options; @@ -258,6 +274,7 @@ updateOptions() } +void UpdateOptionsMenu(int options) { char buf[256]; diff --git a/src/sim/w_util.c b/src/sim/w_util.c index 9f9db36..c3c5eb8 100644 --- a/src/sim/w_util.c +++ b/src/sim/w_util.c @@ -61,9 +61,12 @@ */ #include "sim.h" +void UpdateGameLevel(void); + /* comefrom: drawTaxesCollected incBoxValue decBoxValue drawCurrentFunds drawActualBox UpdateFunds updateCurrentCost */ +void makeDollarDecimalStr(char *numStr, char *dollarStr) { register short leftMostSet; @@ -121,7 +124,8 @@ makeDollarDecimalStr(char *numStr, char *dollarStr) } -Pause() +void +Pause(void) { if (!sim_paused) { sim_paused_speed = SimMetaSpeed; @@ -131,7 +135,8 @@ Pause() } -Resume() +void +Resume(void) { if (sim_paused) { sim_paused = 0; @@ -140,6 +145,7 @@ Resume() } +void setSpeed(short speed) { if (speed < 0) speed = 0; @@ -167,6 +173,7 @@ setSpeed(short speed) } +void setSkips(int skips) { sim_skips = skips; @@ -174,6 +181,7 @@ setSkips(int skips) } +void SetGameLevelFunds(short level) { switch (level) { @@ -194,6 +202,7 @@ SetGameLevelFunds(short level) } +void SetGameLevel(short level) { GameLevel = level; @@ -201,7 +210,8 @@ SetGameLevel(short level) } -UpdateGameLevel() +void +UpdateGameLevel(void) { char buf[256]; @@ -210,6 +220,7 @@ UpdateGameLevel() } +void setCityName(char *name) { char *cp = name; @@ -223,6 +234,7 @@ setCityName(char *name) } +void setAnyCityName(char *name) { char buf[1024]; @@ -233,6 +245,7 @@ setAnyCityName(char *name) } +void SetYear(int year) { // Must prevent year from going negative, since it screws up the non-floored modulo arithmetic. @@ -247,12 +260,13 @@ SetYear(int year) int -CurrentYear() +CurrentYear(void) { return (CityTime/48 + StartingYear); } +void DoSetMapState(SimView *view, short state) { char buf[256]; @@ -266,24 +280,28 @@ DoSetMapState(SimView *view, short state) } -DoNewGame() +void +DoNewGame(void) { Eval("UINewGame"); } +void DoGeneratedCityImage(char *name, int time, int pop, char *class, int score) { /* XXX: TODO: print city */ } +void DoStartElmd() { /* XXX: TODO: start elm daemon */ } +void DoPopUpMessage(char *msg) { char buf[1024]; diff --git a/src/sim/w_x.c b/src/sim/w_x.c index ef42536..b7cc9e9 100644 --- a/src/sim/w_x.c +++ b/src/sim/w_x.c @@ -91,7 +91,11 @@ unsigned char ColorIntensities[] = { /* COLOR_BLACK */ 0, }; +void FreeTiles(SimView *view); +void AllocTiles(SimView *view); +void DoAdjustPan(struct SimView *view); +void ViewToTileCoords(SimView *view, int x, int y, int *outx, int *outy) { x = (view->pan_x - ((view->w_width >>1) - x)) >>4; @@ -120,6 +124,7 @@ ViewToTileCoords(SimView *view, int x, int y, int *outx, int *outy) } +void ViewToPixelCoords(SimView *view, int x, int y, int *outx, int *outy) { x = view->pan_x - ((view->w_width >>1) - x); @@ -148,7 +153,8 @@ ViewToPixelCoords(SimView *view, int x, int y, int *outx, int *outy) } -UpdateFlush() +void +UpdateFlush(void) { struct XDisplay *xd; @@ -216,7 +222,8 @@ printf("GOT X ERROR code %d request code %d %d\n", } -DoStopMicropolis() +void +DoStopMicropolis(void) { (void)XSetErrorHandler(CatchXError); @@ -244,7 +251,8 @@ DoStopMicropolis() } -DoTimeoutListen() +void +DoTimeoutListen(void) { while (Tk_DoOneEvent(TK_DONT_WAIT)) ; } @@ -273,10 +281,7 @@ XDisplay * FindXDisplay(Tk_Window tkwin) { XDisplay *xd; - int d = 8; - unsigned long valuemask = 0; - XGCValues values; - XColor rgb, *color; + XColor *color; Display *dpy = Tk_Display(tkwin); Screen *screen = Tk_Screen(tkwin); #ifdef IS_LINUX @@ -333,6 +338,7 @@ FindXDisplay(Tk_Window tkwin) (((color->green >> (8 + 2)) & 0x1f) << (5)) | \ (((color->blue >> (8 + 3)) & 0x1f) << (0)); \ } else { \ + xd->pixels[i] = \ (((color->blue >> (8 + 3)) & 0x1f) << (5 + 5)) | \ (((color->green >> (8 + 2)) & 0x1f) << (5)) | \ (((color->red >> (8 + 3)) & 0x1f) << (0)); \ @@ -485,12 +491,14 @@ FindXDisplay(Tk_Window tkwin) } +void IncRefDisplay(XDisplay *xd) { xd->references++; } +void DecRefDisplay(XDisplay *xd) { if ((--xd->references) == 0) { @@ -502,14 +510,8 @@ DecRefDisplay(XDisplay *xd) SimView * InitNewView(SimView *view, char *title, int class, int w, int h) { - int type, i; int test = 1; - int d = 8; - unsigned long valuemask = 0; char *t; - struct XDisplay *xd; - XGCValues values; - XColor rgb, *color; t = (char *)ckalloc(strlen(title) + 1); strcpy(t, title); @@ -615,6 +617,7 @@ InitNewView(SimView *view, char *title, int class, int w, int h) } +void DestroyView(SimView *view) { SimView **vp; @@ -723,6 +726,7 @@ AllocPixels(int len, unsigned char pixel) } +void DoResizeView(SimView *view, int w, int h) { int resize = 0; @@ -934,7 +938,7 @@ DoResizeView(SimView *view, int w, int h) if (!GotXError) { attached = 1; view->pixmap = XShmCreatePixmap(view->x->dpy, view->x->root, - view->data, view->shminfo, + (char*)view->data, view->shminfo, view->m_width, view->m_height, view->x->depth); XSync(view->x->dpy, False); @@ -1248,12 +1252,14 @@ DoResizeView(SimView *view, int w, int h) } +void DoPanBy(struct SimView *view, int dx, int dy) { DoPanTo(view, view->pan_x + dx, view->pan_y + dy); } +void DoPanTo(struct SimView *view, int x, int y) { if (view->class != Editor_Class) { @@ -1274,12 +1280,12 @@ DoPanTo(struct SimView *view, int x, int y) /* #define DEBUG_PAN */ +void DoAdjustPan(struct SimView *view) { int ww2 = view->w_width >>1, wh2 = view->w_height >>1; int px = view->pan_x, py = view->pan_y; int last_tile_x = view->tile_x, last_tile_y = view->tile_y; - int last_tile_width = view->tile_width, last_tile_height = view->tile_height; int total_width = view->m_width >>4, total_height = view->m_height >>4; //fprintf(stderr, "DoAdjustPan\n"); @@ -1392,6 +1398,7 @@ DoAdjustPan(struct SimView *view) } +void AllocTiles(SimView *view) { int row, col; @@ -1423,6 +1430,7 @@ AllocTiles(SimView *view) } +void FreeTiles(SimView *view) { int col; @@ -1467,6 +1475,7 @@ NewInk() } +void FreeInk(Ink *ink) { ink->next = OldInk; @@ -1474,6 +1483,7 @@ FreeInk(Ink *ink) } +void StartInk(Ink *ink, int x, int y) { ink->length = 1; @@ -1482,6 +1492,7 @@ StartInk(Ink *ink, int x, int y) } +void AddInk(Ink *ink, int x, int y) { int dx = x - ink->last_x; @@ -1515,7 +1526,7 @@ AddInk(Ink *ink, int x, int y) ink->points[ink->length].y = dy; ink->length++; - ADJUST: + /* ADJUST: */ if (x < ink->left) ink->left = x; if (x > ink->right) @@ -1553,7 +1564,8 @@ AddInk(Ink *ink, int x, int y) } -EraseOverlay() +void +EraseOverlay(void) { Ink *ink; -- 2.39.2