X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/micropolis/blobdiff_plain/368d83ae8d59a7368779f94b48b302c03e8cfa01..e049e4ba47308629d2233fdd3f85d49352463d9c:/src/sim/w_sprite.c diff --git a/src/sim/w_sprite.c b/src/sim/w_sprite.c index ff1e679..c8837d5 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 }; @@ -849,7 +878,7 @@ DoShipSprite(SimSprite *sprite) if ((Rand16() & 3) == 1) { if ((ScenarioID == 2) && /* San Francisco */ (Rand(10) < 5)) { - MakeSound("city", "HonkHonk-Low -speed 80"); + MakeSound("city", "HonkHonk-Low"); } else { MakeSound("city", "HonkHonk-Low"); } @@ -898,16 +927,19 @@ DoShipSprite(SimSprite *sprite) sprite->frame = 0; return; } - for (z = 0; z < 8; z++) { - if (t == BtClrTab[z]) break; - if (z == 7) { - ExplodeSprite(sprite); - Destroy(sprite->x + 48, sprite->y); + if (!NoDisasters) { + for (z = 0; z < 8; z++) { + if (t == BtClrTab[z]) break; + if (z == 7) { + ExplodeSprite(sprite); + Destroy(sprite->x + 48, sprite->y); + } } } } +void DoMonsterSprite(SimSprite *sprite) { static short Gx[5] = { 2, 2, -2, -2, 0 }; @@ -983,7 +1015,7 @@ DoMonsterSprite(SimSprite *sprite) else z = ND2[d]; d = 4; if (!sprite->sound_count) { - MakeSound("city", "Monster -speed [MonsterSpeed]"); /* monster */ + MakeSound("city", "Monster"); /* monster */ sprite->sound_count = 50 + Rand(100); } } @@ -1020,10 +1052,14 @@ DoMonsterSprite(SimSprite *sprite) if (sprite->count > 0) sprite->count--; c = GetChar(sprite->x + sprite->x_hot, sprite->y + sprite->y_hot); - if ((c == -1) || - ((c == RIVER) && + if ((c == -1) +#ifndef ORIGINAL_MONSTER_BEHAVIOUR + || ((c == RIVER) && (sprite->count != 0) && - (sprite->control == -1))) { + (sprite->count < 900) && + (sprite->control == -1)) +#endif + ) { sprite->frame = 0; /* kill zilla */ } @@ -1044,6 +1080,7 @@ DoMonsterSprite(SimSprite *sprite) } +void DoTornadoSprite(SimSprite *sprite) { static short CDx[9] = { 2, 3, 2, 0, -2, -3 }; @@ -1095,6 +1132,7 @@ DoTornadoSprite(SimSprite *sprite) } +void DoExplosionSprite(SimSprite *sprite) { short x, y; @@ -1122,15 +1160,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", @@ -1348,6 +1386,7 @@ CanDriveOn(int x, int y) } +void ExplodeSprite(SimSprite *sprite) { int x, y; @@ -1404,6 +1443,7 @@ int checkWet(int x) } +void Destroy(int ox, int oy) { short t, z, x, y; @@ -1437,6 +1477,7 @@ Destroy(int ox, int oy) } +void OFireZone(int Xloc, int Yloc, int ch) { register short Xtem, Ytem; @@ -1461,9 +1502,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; @@ -1479,6 +1521,7 @@ StartFire(int x, int y) } +void GenerateTrain(int x, int y) { if ((TotalPop > 20) && @@ -1489,6 +1532,7 @@ GenerateTrain(int x, int y) } +void GenerateBus(int x, int y) { if ((GetSprite(BUS) == NULL) && @@ -1498,6 +1542,7 @@ GenerateBus(int x, int y) } +void GenerateShip(void) { register short x, y; @@ -1529,15 +1574,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) { @@ -1562,16 +1609,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; @@ -1580,6 +1627,7 @@ GenerateCopter(int x, int y) } +void GeneratePlane(int x, int y) { if (GetSprite(AIR) != NULL) return; @@ -1588,6 +1636,7 @@ GeneratePlane(int x, int y) } +void MakeAirCrash(void) { #ifndef NO_AIRCRASH @@ -1605,6 +1654,7 @@ MakeAirCrash(void) } +void MakeTornado(void) { short x, y; @@ -1623,6 +1673,7 @@ MakeTornado(void) } +void MakeExplosion(int x, int y) { if ((x >= 0) && (x < WORLD_X) && @@ -1632,6 +1683,7 @@ MakeExplosion(int x, int y) } +void MakeExplosionAt(int x, int y) { MakeNewSprite(EXP, x - 40, y - 16);