From fa64b2148db4b8a7256da1bb407c878d8cdfc6d6 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 15 Aug 2018 22:13:15 -0500 Subject: [PATCH] Add defines [W.I.P] (#160) --- DiabloUI/diabloui.cpp | 5 ++ Source/dead.cpp | 4 +- Source/dead.h | 2 +- Source/debug.cpp | 12 ++-- Source/debug.h | 4 +- Source/diablo.cpp | 20 +++--- Source/diablo.h | 12 ++-- Source/effects.cpp | 10 +-- Source/effects.h | 2 +- Source/gendung.cpp | 30 ++++---- Source/gendung.h | 30 ++++---- Source/items.cpp | 52 +++++++------- Source/items.h | 8 +-- Source/lighting.cpp | 2 +- Source/loadsave.cpp | 62 ++++++++-------- Source/missiles.cpp | 18 ++--- Source/missiles.h | 8 +-- Source/monster.cpp | 160 +++++++++++++++++++++--------------------- Source/monster.h | 6 +- Source/msg.cpp | 10 +-- Source/msg.h | 4 +- Source/multi.cpp | 38 +++++----- Source/multi.h | 14 ++-- Source/objects.cpp | 18 ++--- Source/objects.h | 6 +- Source/pack.cpp | 20 +++--- Source/player.cpp | 122 ++++++++++++++++---------------- Source/player.h | 2 +- Source/portal.cpp | 12 ++-- Source/portal.h | 6 +- Source/quests.cpp | 20 +++--- Source/quests.h | 6 +- Source/scrollrt.cpp | 10 +-- Source/scrollrt.h | 2 +- Source/sync.cpp | 4 +- Source/sync.h | 4 +- Source/themes.cpp | 4 +- Source/themes.h | 2 +- Source/trigs.cpp | 4 +- Source/trigs.h | 4 +- defs.h | 6 ++ structs.h | 12 ++-- types.h | 4 +- 43 files changed, 396 insertions(+), 385 deletions(-) diff --git a/DiabloUI/diabloui.cpp b/DiabloUI/diabloui.cpp index 34aae837a..54a0571d4 100644 --- a/DiabloUI/diabloui.cpp +++ b/DiabloUI/diabloui.cpp @@ -8,6 +8,11 @@ #include #include +#ifdef _MSC_VER +#pragma warning (disable : 4018) // signed/unsigned mismatch +#endif + +#include "..\defs.h" #include "..\structs.h" #include "diabloui.h" diff --git a/Source/dead.cpp b/Source/dead.cpp index 90fd29a1e..28471d299 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -3,7 +3,7 @@ #include "../types.h" int spurtndx; // weak -DeadStruct dead[31]; +DeadStruct dead[MAXDEAD]; int stonendx; void __cdecl InitDead() @@ -21,7 +21,7 @@ void __cdecl InitDead() CMonster *v10; // ecx char *v11; // edi int *v12; // ebx - int mtypes[200]; // [esp+Ch] [ebp-330h] + int mtypes[MAXMONSTERS]; // [esp+Ch] [ebp-330h] int *v14; // [esp+32Ch] [ebp-10h] int *v15; // [esp+330h] [ebp-Ch] int v16; // [esp+334h] [ebp-8h] diff --git a/Source/dead.h b/Source/dead.h index dfb9de0a8..cc482e1aa 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -3,7 +3,7 @@ #define __DEAD_H__ extern int spurtndx; // weak -extern DeadStruct dead[31]; +extern DeadStruct dead[MAXDEAD]; extern int stonendx; void __cdecl InitDead(); diff --git a/Source/debug.cpp b/Source/debug.cpp index b943b3a5a..03e11200d 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -3,8 +3,8 @@ #include "../types.h" void *pSquareCel; -char dMonsDbg[17][112][112]; -char dFlagDbg[17][112][112]; +char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; +char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; void __cdecl LoadDebugGFX() { @@ -27,9 +27,9 @@ void __cdecl CheckDungeonClear() int i; int j; - for(i = 0; i < 112; i++) + for(i = 0; i < MAXDUNX; i++) { - for(j = 0; j < 112; j++) + for(j = 0; j < MAXDUNY; j++) { if ( dMonster[i][j] ) TermMsg("Monsters not cleared"); @@ -178,7 +178,7 @@ void __cdecl PrintDebugQuest() sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); NetSendCmdString(1 << myplr, dstr); - if ( ++dbgqst == 16 ) + if ( ++dbgqst == MAXQUESTS ) dbgqst = 0; } @@ -236,7 +236,7 @@ void __cdecl NextDebugMonster() { char dstr[128]; // [esp+0h] [ebp-80h] - if ( dbgmon++ == 200 ) + if ( dbgmon++ == MAXMONSTERS ) dbgmon = 0; sprintf(dstr, "Current debug monster = %i", dbgmon); diff --git a/Source/debug.h b/Source/debug.h index b77dd91ab..165e6fe2c 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -3,8 +3,8 @@ #define __DEBUG_H__ extern void *pSquareCel; -extern char dMonsDbg[17][112][112]; -extern char dFlagDbg[17][112][112]; +extern char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; +extern char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; void __cdecl LoadDebugGFX(); void __cdecl FreeDebugGFX(); diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 6f6a7a3fa..41e155ea4 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -4,19 +4,19 @@ int diablo_cpp_init_value; // weak HWND ghMainWnd; -int glMid1Seed[17]; -int glMid2Seed[17]; -int gnLevelTypeTbl[17]; +int glMid1Seed[NUMLEVELS]; +int glMid2Seed[NUMLEVELS]; +int gnLevelTypeTbl[NUMLEVELS]; int MouseY; // idb int MouseX; // idb bool gbGameLoopStartup; // idb -int glSeedTbl[17]; +int glSeedTbl[NUMLEVELS]; int gbRunGame; // weak -int glMid3Seed[17]; +int glMid3Seed[NUMLEVELS]; int gbRunGameResult; // weak int zoomflag; // weak int gbProcessPlayers; // weak -int glEndSeed[17]; +int glEndSeed[NUMLEVELS]; int dword_5256E8; // weak HINSTANCE ghInst; // idb int DebugMonsters[10]; @@ -261,7 +261,7 @@ void __cdecl free_game() FreeQuestText(); FreeStoreMem(); - for(i = 0; i < 4; i++) + for(i = 0; i < MAX_PLRS; i++) FreePlayerGFX(i); FreeItemGFX(); @@ -1982,7 +1982,7 @@ void __fastcall LoadGameLevel(bool firstflag, int lvldir) GetPortalLvlPos(); IncProgress(); - for(i = 0; i < 4; i++) + for(i = 0; i < MAX_PLRS; i++) { if ( plr[i].plractive ) { @@ -2080,7 +2080,7 @@ void __fastcall LoadGameLevel(bool firstflag, int lvldir) if ( lvldir == 5 ) GetPortalLvlPos(); - for(i = 0; i < 4; i++) + for(i = 0; i < MAX_PLRS; i++) { if ( plr[i].plractive ) { @@ -2110,7 +2110,7 @@ void __fastcall LoadGameLevel(bool firstflag, int lvldir) LABEL_72: SyncPortals(); - for(i = 0; i < 4; i++) + for(i = 0; i < MAX_PLRS; i++) { if ( plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr) ) { diff --git a/Source/diablo.h b/Source/diablo.h index 6e86a22d8..c8c7f2172 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -4,19 +4,19 @@ extern int diablo_cpp_init_value; // weak extern HWND ghMainWnd; -extern int glMid1Seed[17]; -extern int glMid2Seed[17]; -extern int gnLevelTypeTbl[17]; +extern int glMid1Seed[NUMLEVELS]; +extern int glMid2Seed[NUMLEVELS]; +extern int gnLevelTypeTbl[NUMLEVELS]; extern int MouseY; // idb extern int MouseX; // idb extern bool gbGameLoopStartup; // idb -extern int glSeedTbl[17]; +extern int glSeedTbl[NUMLEVELS]; extern int gbRunGame; // weak -extern int glMid3Seed[17]; +extern int glMid3Seed[NUMLEVELS]; extern int gbRunGameResult; // weak extern int zoomflag; // weak extern int gbProcessPlayers; // weak -extern int glEndSeed[17]; +extern int glEndSeed[NUMLEVELS]; extern int dword_5256E8; // weak extern HINSTANCE ghInst; // idb extern int DebugMonsters[10]; diff --git a/Source/effects.cpp b/Source/effects.cpp index 9364a5d89..1c7043168 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -13,7 +13,7 @@ char monster_action_sounds[] = { 'a', 'h', 'd', 's' }; // idb /* rdata */ -TSFX sgSFX[858] = +TSFX sgSFX[NUM_SFX] = { { 2u, "Sfx\\Misc\\Walk1.wav", NULL }, { 2u, "Sfx\\Misc\\Walk2.wav", NULL }, @@ -1256,7 +1256,7 @@ void __cdecl sound_stop() { int i; // edi - for(i = 0; i < 858; i++) + for(i = 0; i < NUM_SFX; i++) { if ( sgSFX[i].pSnd ) snd_stop_snd(sgSFX[i].pSnd); @@ -1308,7 +1308,7 @@ void __cdecl effects_cleanup_sfx() } ++v0; } - while ( v0 < 858 ); + while ( v0 < NUM_SFX ); } void __cdecl stream_update() @@ -1377,7 +1377,7 @@ void __fastcall priv_sound_init(int bLoadMask) } ++v3; } - while ( v3 < 858 ); + while ( v3 < NUM_SFX ); } } @@ -1401,7 +1401,7 @@ void __stdcall effects_play_sound(char *snd_file) { ++v2; ++v1; - if ( v2 >= 858 ) + if ( v2 >= NUM_SFX ) return; } v3 = &sgSFX[v1].pSnd; diff --git a/Source/effects.h b/Source/effects.h index d54d45029..7ddd8b4e5 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -36,6 +36,6 @@ extern char monster_action_sounds[]; // idb /* rdata */ -extern TSFX sgSFX[858]; +extern TSFX sgSFX[NUM_SFX]; #endif /* __EFFECTS_H__ */ diff --git a/Source/gendung.cpp b/Source/gendung.cpp index e763ea820..50122dc90 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -6,20 +6,20 @@ short level_frame_types[2048]; int themeCount; char nTransTable[2049]; //int dword_52D204; -int dMonster[112][112]; +int dMonster[MAXDUNX][MAXDUNY]; char dungeon[40][40]; -char dObject[112][112]; +char dObject[MAXDUNX][MAXDUNY]; void *pSpeedCels; int nlevel_frames; // weak char pdungeon[40][40]; -char dDead[112][112]; -short dpiece_defs_map_1[16][112][112]; -char dTransVal2[112][112]; +char dDead[MAXDUNX][MAXDUNY]; +short dpiece_defs_map_1[16][MAXDUNX][MAXDUNY]; +char dTransVal2[MAXDUNX][MAXDUNY]; char TransVal; // weak int dword_5A5594; char dflags[40][40]; -int dPiece[112][112]; -char dTransVal[112][112]; +int dPiece[MAXDUNX][MAXDUNY]; +char dTransVal[MAXDUNX][MAXDUNY]; int setloadflag_2; // weak Tile tile_defs[1024]; void *pMegaTiles; @@ -27,7 +27,7 @@ void *pLevelPieces; int gnDifficulty; // idb char block_lvid[2049]; //char byte_5B78EB; -char dung_map[112][112]; +char dung_map[MAXDUNX][MAXDUNY]; char nTrapTable[2049]; char leveltype; // weak unsigned char currlevel; // idb @@ -37,17 +37,17 @@ int level_frame_count[2049]; ScrollStruct ScrollInfo; void *pDungeonCels; int speed_cel_frame_num_from_light_index_frame_num[16][128]; -THEME_LOC themeLoc[50]; -char dPlayer[112][112]; +THEME_LOC themeLoc[MAXTHEMES]; +char dPlayer[MAXDUNX][MAXDUNY]; int dword_5C2FF8; // weak int dword_5C2FFC; // weak int scr_pix_width; // weak int scr_pix_height; // weak -char dArch[112][112]; +char dArch[MAXDUNX][MAXDUNY]; char nBlockTable[2049]; void *level_special_cel; -char dFlags[112][112]; -char dItem[112][112]; +char dFlags[MAXDUNX][MAXDUNY]; +char dItem[MAXDUNX][MAXDUNY]; char setlvlnum; // weak int level_frame_sizes[2048]; char nMissileTable[2049]; @@ -64,10 +64,10 @@ int setpc_x; // idb int ViewX; // idb int ViewY; // idb int setpc_y; // idb -char dMissile[112][112]; +char dMissile[MAXDUNX][MAXDUNY]; int dminx; // weak int dminy; // weak -short dpiece_defs_map_2[16][112][112]; +short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY]; void __cdecl FillSolidBlockTbls() { diff --git a/Source/gendung.h b/Source/gendung.h index 942bcc2ce..35f163edb 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -6,20 +6,20 @@ extern short level_frame_types[2048]; extern int themeCount; extern char nTransTable[2049]; //int dword_52D204; -extern int dMonster[112][112]; +extern int dMonster[MAXDUNX][MAXDUNY]; extern char dungeon[40][40]; -extern char dObject[112][112]; +extern char dObject[MAXDUNX][MAXDUNY]; extern void *pSpeedCels; extern int nlevel_frames; // weak extern char pdungeon[40][40]; -extern char dDead[112][112]; -extern short dpiece_defs_map_1[16][112][112]; -extern char dTransVal2[112][112]; +extern char dDead[MAXDUNX][MAXDUNY]; +extern short dpiece_defs_map_1[16][MAXDUNX][MAXDUNY]; +extern char dTransVal2[MAXDUNX][MAXDUNY]; extern char TransVal; // weak extern int dword_5A5594; extern char dflags[40][40]; -extern int dPiece[112][112]; -extern char dTransVal[112][112]; +extern int dPiece[MAXDUNX][MAXDUNY]; +extern char dTransVal[MAXDUNX][MAXDUNY]; extern int setloadflag_2; // weak extern Tile tile_defs[1024]; extern void *pMegaTiles; @@ -27,7 +27,7 @@ extern void *pLevelPieces; extern int gnDifficulty; // idb extern char block_lvid[2049]; //char byte_5B78EB; -extern char dung_map[112][112]; +extern char dung_map[MAXDUNX][MAXDUNY]; extern char nTrapTable[2049]; extern char leveltype; // weak extern unsigned char currlevel; // idb @@ -37,17 +37,17 @@ extern int level_frame_count[2049]; extern ScrollStruct ScrollInfo; extern void *pDungeonCels; extern int speed_cel_frame_num_from_light_index_frame_num[16][128]; -extern THEME_LOC themeLoc[50]; -extern char dPlayer[112][112]; +extern THEME_LOC themeLoc[MAXTHEMES]; +extern char dPlayer[MAXDUNX][MAXDUNY]; extern int dword_5C2FF8; // weak extern int dword_5C2FFC; // weak extern int scr_pix_width; // weak extern int scr_pix_height; // weak -extern char dArch[112][112]; +extern char dArch[MAXDUNX][MAXDUNY]; extern char nBlockTable[2049]; extern void *level_special_cel; -extern char dFlags[112][112]; -extern char dItem[112][112]; +extern char dFlags[MAXDUNX][MAXDUNY]; +extern char dItem[MAXDUNX][MAXDUNY]; extern char setlvlnum; // weak extern int level_frame_sizes[2048]; extern char nMissileTable[2049]; @@ -64,10 +64,10 @@ extern int setpc_x; // idb extern int ViewX; // idb extern int ViewY; // idb extern int setpc_y; // idb -extern char dMissile[112][112]; +extern char dMissile[MAXDUNX][MAXDUNY]; extern int dminx; // weak extern int dminy; // weak -extern short dpiece_defs_map_2[16][112][112]; +extern short dpiece_defs_map_2[16][MAXDUNX][MAXDUNY]; void __cdecl FillSolidBlockTbls(); void __cdecl gendung_418D91(); diff --git a/Source/items.cpp b/Source/items.cpp index 6de9257cd..b42e23624 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2,12 +2,12 @@ #include "../types.h" -int itemactive[127]; +int itemactive[MAXITEMS]; int uitemflag; -int itemavail[127]; +int itemavail[MAXITEMS]; ItemStruct curruitem; -ItemGetRecordStruct itemrecord[127]; -ItemStruct item[128]; +ItemGetRecordStruct itemrecord[MAXITEMS]; +ItemStruct item[MAXITEMS+1]; char itemhold[3][3]; char byte_641234[28]; /* check if part of above */ int Item2Frm[35]; @@ -732,7 +732,7 @@ void __cdecl InitItems() v0[10] = 0; v0 += 92; } - while ( (signed int)v0 < (signed int)&item[128]._ix ); + while ( (signed int)v0 < (signed int)&item[MAXITEMS+1]._ix ); v1 = 0; memset(itemactive, 0, sizeof(itemactive)); do @@ -740,7 +740,7 @@ void __cdecl InitItems() itemavail[v1] = v1; ++v1; } - while ( v1 < 127 ); + while ( v1 < MAXITEMS ); if ( !setlevel ) { GetRndSeed(); @@ -2959,13 +2959,13 @@ void __fastcall SpawnUnique(int uid, int x, int y) int ii; // esi int itype; // edx - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itype = 0; itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ if ( AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId ) { @@ -3084,12 +3084,12 @@ void __fastcall SpawnItem(int m, int x, int y, unsigned char sendmsg) goto LABEL_10; onlygood = 1; LABEL_13: - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ if ( !monster[m]._uniqtype ) SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 1, onlygood, 0, 0); @@ -3108,13 +3108,13 @@ void __fastcall CreateItem(int uid, int x, int y) int ii; // esi int idx; // edx - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); idx = 0; itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ if ( AllItemsList[0].iItemId != UniqueItemList[uid].UIItemId ) { @@ -3143,12 +3143,12 @@ void __fastcall CreateRndItem(int x, int y, unsigned char onlygood, unsigned cha else idx = RndAllItems(); - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); if ( sendmsg ) @@ -3183,12 +3183,12 @@ void __fastcall CreateRndUseful(int pnum, int x, int y, unsigned char sendmsg) { int ii; // esi - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ SetupAllUseful(ii, GetRndSeed(), currlevel); if ( sendmsg ) @@ -3208,12 +3208,12 @@ void __fastcall CreateTypeItem(int x, int y, unsigned char onlygood, int itype, else idx = RndTypeItems(itype, imisc); - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, 0, delta); if ( sendmsg ) @@ -3360,14 +3360,14 @@ void __fastcall SpawnQuestItem(int itemid, int x, int y, int randarea, int selfl } } LABEL_13: - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { v12 = itemavail[0]; v13 = itemavail[0]; item[v13]._ix = x; itemactive[numitems] = v12; item[v13]._iy = y; - itemavail[0] = itemavail[-numitems + 126]; /* double check */ + itemavail[0] = itemavail[-numitems + 126]; /* double check, MAXITEMS */ dItem[x][y] = v12 + 1; GetItemAttrs(v12, itemid, currlevel); SetupItem(v12); @@ -3483,7 +3483,7 @@ void __fastcall DeleteItem(int ii, int i) v2 = numitems - 1; v3 = numitems == 1; v4 = numitems - 1 < 0; - itemavail[-numitems + 127] = ii; + itemavail[-numitems + MAXITEMS] = ii; numitems = v2; if ( !v4 && !v3 && i != v2 ) itemactive[i] = itemactive[v2]; @@ -5504,12 +5504,12 @@ void __fastcall CreateSpellBook(int x, int y, int ispell, bool sendmsg, int delt done = 0; idx = RndTypeItems(0, 24); - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ do { SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, 1, 0, delta); @@ -5532,12 +5532,12 @@ void __fastcall CreateMagicItem(int x, int y, int imisc, int icurs, int sendmsg, bool done; // [esp+Ch] [ebp-4h] done = 0; - if ( numitems < 127 ) + if ( numitems < MAXITEMS ) { ii = itemavail[0]; GetSuperItemSpace(x, y, itemavail[0]); itemactive[numitems] = ii; - itemavail[0] = itemavail[-numitems + 126]; + itemavail[0] = itemavail[-numitems + 126]; /* MAXITEMS */ idx = RndTypeItems(imisc, 0); do { @@ -5617,7 +5617,7 @@ void __fastcall SetItemRecord(int dwSeed, int CI, int indx) { int i; // ecx - if ( gnNumGetRecords != 127 ) + if ( gnNumGetRecords != MAXITEMS ) { i = gnNumGetRecords++; itemrecord[i].dwTimestamp = GetTickCount(); diff --git a/Source/items.h b/Source/items.h index ee2854d27..ea474433a 100644 --- a/Source/items.h +++ b/Source/items.h @@ -2,12 +2,12 @@ #ifndef __ITEMS_H__ #define __ITEMS_H__ -extern int itemactive[127]; +extern int itemactive[MAXITEMS]; extern int uitemflag; -extern int itemavail[127]; +extern int itemavail[MAXITEMS]; extern ItemStruct curruitem; -extern ItemGetRecordStruct itemrecord[127]; -extern ItemStruct item[128]; +extern ItemGetRecordStruct itemrecord[MAXITEMS]; +extern ItemStruct item[MAXITEMS+1]; extern char itemhold[3][3]; extern char byte_641234[28]; /* check if part of above */ extern int Item2Frm[35]; diff --git a/Source/lighting.cpp b/Source/lighting.cpp index d63996ee0..d3eb12d51 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1043,7 +1043,7 @@ void __cdecl FreeLightTable() void __cdecl InitLightTable() { - pLightTbl = (char *)DiabloAllocPtr(6912); + pLightTbl = (char *)DiabloAllocPtr(LIGHTSIZE); } void __cdecl MakeLightTable() diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 52ef145c8..7eacbe24d 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -90,11 +90,11 @@ void __fastcall LoadGame(bool firstflag) quest_num = 0; do LoadQuest(quest_num++); - while ( quest_num < 16 ); + while ( quest_num < MAXQUESTS ); quest_num = 0; do LoadPortal(quest_num++); - while ( quest_num < 4 ); + while ( quest_num < MAXPORTAL ); LoadGameLevel(firstflag, 4); SyncInitPlr(myplr); SyncPlrAnim(myplr); @@ -110,7 +110,7 @@ void __fastcall LoadGame(bool firstflag) *v11 = ILoad_2(); ++v11; } - while ( (signed int)v11 < (signed int)&monstkills[200] ); + while ( (signed int)v11 < (signed int)&monstkills[MAXMONSTERS] ); if ( leveltype ) { v12 = monstactive; @@ -119,7 +119,7 @@ void __fastcall LoadGame(bool firstflag) *v12 = ILoad(); ++v12; } - while ( (signed int)v12 < (signed int)&monstactive[200] ); + while ( (signed int)v12 < (signed int)&monstactive[MAXMONSTERS] ); for ( i = 0; i < nummonsters; ++i ) LoadMonster(monstactive[i]); v14 = missileactive; @@ -128,14 +128,14 @@ void __fastcall LoadGame(bool firstflag) *v14 = BLoad(); ++v14; } - while ( (signed int)v14 < (signed int)&missileactive[125] ); + while ( (signed int)v14 < (signed int)&missileactive[MAXMISSILES] ); v15 = missileavail; do { *v15 = BLoad(); ++v15; } - while ( (signed int)v15 < (signed int)&missileavail[125] ); + while ( (signed int)v15 < (signed int)&missileavail[MAXMISSILES] ); for ( j = 0; j < nummissiles; ++j ) LoadMissile(missileactive[j]); v17 = objectactive; @@ -144,14 +144,14 @@ void __fastcall LoadGame(bool firstflag) *v17 = BLoad(); ++v17; } - while ( (signed int)v17 < (signed int)&objectactive[127] ); + while ( (signed int)v17 < (signed int)&objectactive[MAXOBJECTS] ); v18 = objectavail; do { *v18 = BLoad(); ++v18; } - while ( (signed int)v18 < (signed int)&objectavail[127] ); + while ( (signed int)v18 < (signed int)&objectavail[MAXOBJECTS] ); for ( k = 0; k < nobjects; ++k ) LoadObject(objectactive[k]); for ( l = 0; l < nobjects; ++l ) @@ -179,14 +179,14 @@ void __fastcall LoadGame(bool firstflag) *v24 = BLoad(); ++v24; } - while ( (signed int)v24 < (signed int)&itemactive[127] ); + while ( (signed int)v24 < (signed int)&itemactive[MAXITEMS] ); v25 = itemavail; do { *v25 = BLoad(); ++v25; } - while ( (signed int)v25 < (signed int)&itemavail[127] ); + while ( (signed int)v25 < (signed int)&itemavail[MAXITEMS] ); for ( n = 0; n < numitems; ++n ) LoadItem(itemactive[n]); v27 = UniqueItemFlag; @@ -597,23 +597,23 @@ void __cdecl SaveGame() ISave(gnLevelTypeTbl[v2]); ++v2; } - while ( v2 < 17 ); + while ( v2 < NUMLEVELS ); SavePlayer(myplr); v3 = 0; do SaveQuest(v3++); - while ( v3 < 16 ); + while ( v3 < MAXQUESTS ); v4 = 0; do SavePortal(v4++); - while ( v4 < 4 ); + while ( v4 < MAXPORTAL ); v5 = monstkills; do { ISave_2(*v5); ++v5; } - while ( (signed int)v5 < (signed int)&monstkills[200] ); + while ( (signed int)v5 < (signed int)&monstkills[MAXMONSTERS] ); if ( leveltype ) { v6 = monstactive; @@ -622,7 +622,7 @@ void __cdecl SaveGame() ISave(*v6); ++v6; } - while ( (signed int)v6 < (signed int)&monstactive[200] ); + while ( (signed int)v6 < (signed int)&monstactive[MAXMONSTERS] ); for ( i = 0; i < nummonsters; ++i ) SaveMonster(monstactive[i]); v8 = missileactive; @@ -631,14 +631,14 @@ void __cdecl SaveGame() BSave(*(_BYTE *)v8); ++v8; } - while ( (signed int)v8 < (signed int)&missileactive[125] ); + while ( (signed int)v8 < (signed int)&missileactive[MAXMISSILES] ); v9 = missileavail; do { BSave(*(_BYTE *)v9); ++v9; } - while ( (signed int)v9 < (signed int)&missileavail[125] ); + while ( (signed int)v9 < (signed int)&missileavail[MAXMISSILES] ); for ( j = 0; j < nummissiles; ++j ) SaveMissile(missileactive[j]); v11 = objectactive; @@ -647,14 +647,14 @@ void __cdecl SaveGame() BSave(*(_BYTE *)v11); ++v11; } - while ( (signed int)v11 < (signed int)&objectactive[127] ); + while ( (signed int)v11 < (signed int)&objectactive[MAXOBJECTS] ); v12 = objectavail; do { BSave(*(_BYTE *)v12); ++v12; } - while ( (signed int)v12 < (signed int)&objectavail[127] ); + while ( (signed int)v12 < (signed int)&objectavail[MAXOBJECTS] ); for ( k = 0; k < nobjects; ++k ) SaveObject(objectactive[k]); ISave(numlights); @@ -675,14 +675,14 @@ void __cdecl SaveGame() BSave(*(_BYTE *)v17); ++v17; } - while ( (signed int)v17 < (signed int)&itemactive[127] ); + while ( (signed int)v17 < (signed int)&itemactive[MAXITEMS] ); v18 = itemavail; do { BSave(*(_BYTE *)v18); ++v18; } - while ( (signed int)v18 < (signed int)&itemavail[127] ); + while ( (signed int)v18 < (signed int)&itemavail[MAXITEMS] ); for ( n = 0; n < numitems; ++n ) SaveItem(itemactive[n]); v20 = UniqueItemFlag; @@ -1016,26 +1016,26 @@ void __cdecl SaveLevel() if ( leveltype ) { - for(i = 0; i < 200; i++) + for(i = 0; i < MAXMONSTERS; i++) ISave(monstactive[i]); for(i = 0; i < nummonsters; i++) SaveMonster(monstactive[i]); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXOBJECTS; i++) BSave(objectactive[i]); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXOBJECTS; i++) BSave(objectavail[i]); for(i = 0; i < nobjects; i++) SaveObject(objectactive[i]); } - for(i = 0; i < 127; i++) + for(i = 0; i < MAXITEMS; i++) BSave(itemactive[i]); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXITEMS; i++) BSave(itemavail[i]); for(i = 0; i < numitems; i++) @@ -1153,16 +1153,16 @@ void __cdecl LoadLevel() if ( leveltype ) { - for(i = 0; i < 200; i++) + for(i = 0; i < MAXMONSTERS; i++) monstactive[i] = ILoad(); for(i = 0; i < nummonsters; i++) LoadMonster(monstactive[i]); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXOBJECTS; i++) objectactive[i] = BLoad(); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXOBJECTS; i++) objectavail[i] = BLoad(); for(i = 0; i < nobjects; i++) @@ -1172,10 +1172,10 @@ void __cdecl LoadLevel() SyncObjectAnim(objectactive[i]); } - for(i = 0; i < 127; i++) + for(i = 0; i < MAXITEMS; i++) itemactive[i] = BLoad(); - for(i = 0; i < 127; i++) + for(i = 0; i < MAXITEMS; i++) itemavail[i] = BLoad(); for(i = 0; i < numitems; i++) diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 086f0362f..6e61ea863 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2,12 +2,12 @@ #include "../types.h" -int missileactive[125]; -int missileavail[125]; -MissileStruct missile[125]; +int missileactive[MAXMISSILES]; +int missileavail[MAXMISSILES]; +MissileStruct missile[MAXMISSILES]; int nummissiles; // idb int ManashieldFlag; -unk_missile_struct misflagstruct_unknown[125]; +unk_missile_struct misflagstruct_unknown[MAXMISSILES]; int MissilePreFlag; // weak int unk_missile_flag; // weak @@ -1084,7 +1084,7 @@ void __fastcall DeleteMissile(int mi, int i) v5 = nummissiles - 1; v6 = nummissiles == 1; v7 = nummissiles - 1 < 0; - missileavail[-nummissiles + 125] = v2; /* *(&missile[0]._mitype - nummissiles) = v2; */ + missileavail[-nummissiles + MAXMISSILES] = v2; /* *(&missile[0]._mitype - nummissiles) = v2; */ nummissiles = v5; if ( !v7 && !v6 && v3 != v5 ) missileactive[v3] = missileactive[v5]; @@ -2315,7 +2315,7 @@ void __cdecl InitMissiles() missileavail[v4] = v4; ++v4; } - while ( v4 < 125 ); + while ( v4 < MAXMISSILES ); unk_missile_flag = 0; v5 = &misflagstruct_unknown[0].field_4; do @@ -2325,7 +2325,7 @@ void __cdecl InitMissiles() v5[1] = 0; v5 += 3; } - while ( (signed int)v5 < (signed int)&misflagstruct_unknown[125].field_4 ); + while ( (signed int)v5 < (signed int)&misflagstruct_unknown[MAXMISSILES].field_4 ); v6 = 0; do { @@ -4524,7 +4524,7 @@ int __fastcall AddMissile(int sx, int sy, int v1, int v2, int midir, int mitype, sya = sy; sxa = sx; - if ( nummissiles >= 125 ) + if ( nummissiles >= MAXMISSILES ) return -1; if ( mitype != 13 || plr[id].pManaShield != 1 ) goto LABEL_9; @@ -4544,7 +4544,7 @@ int __fastcall AddMissile(int sx, int sy, int v1, int v2, int midir, int mitype, LABEL_9: v12 = nummissiles; v13 = missileavail[0]; - v14 = missileavail[-nummissiles++ + 124]; + v14 = missileavail[-nummissiles++ + 124]; /* MAXMISSILES */ missileavail[0] = v14; v15 = v13; missile[v15]._mitype = mitype; diff --git a/Source/missiles.h b/Source/missiles.h index 1be8cd9b1..ddafcb9a8 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -2,12 +2,12 @@ #ifndef __MISSILES_H__ #define __MISSILES_H__ -extern int missileactive[125]; -extern int missileavail[125]; -extern MissileStruct missile[125]; +extern int missileactive[MAXMISSILES]; +extern int missileavail[MAXMISSILES]; +extern MissileStruct missile[MAXMISSILES]; extern int nummissiles; // idb extern int ManashieldFlag; -extern unk_missile_struct misflagstruct_unknown[125]; +extern unk_missile_struct misflagstruct_unknown[MAXMISSILES]; extern int MissilePreFlag; // weak extern int unk_missile_flag; // weak diff --git a/Source/monster.cpp b/Source/monster.cpp index e5dc641a9..ec4495458 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4,11 +4,11 @@ int MissileFileFlag; // weak int monster_cpp_init_value; // weak -int monstkills[200]; -int monstactive[200]; +int monstkills[MAXMONSTERS]; +int monstactive[MAXMONSTERS]; int nummonsters; int sgbSaveSoundOn; // weak -MonsterStruct monster[200]; +MonsterStruct monster[MAXMONSTERS]; int totalmonsters; // weak CMonster Monsters[16]; // int END_Monsters_17; // weak @@ -419,9 +419,9 @@ void __cdecl InitLevelMonsters() ClrAllMonsters(); nummonsters = 0; - totalmonsters = 200; + totalmonsters = MAXMONSTERS; - for(i = 0; i < 200; i++) + for(i = 0; i < MAXMONSTERS; i++) monstactive[i] = i; uniquetrans = 0; @@ -484,7 +484,7 @@ void __cdecl GetLevelMTypes() /* note-decompile this function again and check */ int *v20; // esi int v21; // eax //int v22; // [esp+8h] [ebp-328h] - int typelist[200]; // [esp+Ch] [ebp-324h] + int typelist[MAXMONSTERS]; // [esp+Ch] [ebp-324h] int skeltypes[111]; // [esp+170h] [ebp-1C0h] int max; // [esp+32Ch] [ebp-4h] @@ -926,7 +926,7 @@ void __cdecl ClrAllMonsters() int i; // edi int v6; // eax - for(i = 0; i < 200; i++) + for(i = 0; i < MAXMONSTERS; i++) { ClearMVars(i); monster[i].mName = "Invalid Monster"; @@ -1037,7 +1037,7 @@ void __fastcall PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesi v4 = (CMonster *)&UniqMonst[uniqindex]; v43 = miniontype; v44 = v4; - if ( (uniquetrans + 19) << 8 < 6912 ) + if ( (uniquetrans + 19) << 8 < LIGHTSIZE ) { mtype = 0; if ( nummtypes > 0 ) @@ -1859,7 +1859,7 @@ int __fastcall AddMonster(int x, int y, int dir, int mtype, int InMap) { int i; // esi - if ( nummonsters >= 200 ) + if ( nummonsters >= MAXMONSTERS ) return -1; i = monstactive[nummonsters++]; if ( InMap ) @@ -2663,7 +2663,7 @@ void __fastcall M2MStartHit(int mid, int i, int dam) v3 = mid; v4 = i; v11 = i; - if ( (unsigned int)mid >= 0xC8 ) + if ( (unsigned int)mid >= MAXMONSTERS ) TermMsg("Invalid monster %d getting hit by monster", mid); v5 = v3; if ( !monster[v3].MType ) @@ -2726,7 +2726,7 @@ void __fastcall MonstStartKill(int i, int pnum, unsigned char sendmsg) v3 = i; v4 = pnum; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MonstStartKill: Invalid monster %d", i); v5 = v3; if ( !monster[v3].MType ) @@ -2795,7 +2795,7 @@ void __fastcall M2MStartKill(int i, int mid) v2 = i; v3 = mid; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) { TermMsg("M2MStartKill: Invalid monster (attacker) %d", i); TermMsg("M2MStartKill: Invalid monster (killed) %d", v3); @@ -2854,7 +2854,7 @@ void __fastcall M_StartKill(int i, int pnum) v2 = i; v3 = pnum; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_StartKill: Invalid monster %d", i); if ( myplr == v3 ) { @@ -2883,7 +2883,7 @@ void __fastcall M_SyncStartKill(int i, int x, int y, int pnum) v4 = i; v5 = x; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_SyncStartKill: Invalid monster %d", i); v6 = v4; if ( monster[v6]._mhitpoints && monster[v6]._mmode != MM_DEATH ) @@ -2921,7 +2921,7 @@ void __fastcall M_StartFadein(int i, int md, unsigned char backwards) v3 = i; v4 = md; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_StartFadein: Invalid monster %d", i); v5 = v3; if ( !monster[v5].MType ) @@ -2959,7 +2959,7 @@ void __fastcall M_StartFadeout(int i, int md, unsigned char backwards) v3 = i; mda = md; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_StartFadeout: Invalid monster %d", i); v4 = v3; v5 = &monster[v3].MType; @@ -2994,7 +2994,7 @@ void __fastcall M_StartHeal(int i) int v5; // eax v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_StartHeal: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -3022,7 +3022,7 @@ void __fastcall M_ChangeLightOffset(int monst) signed int v9; // esi v1 = monst; - if ( (unsigned int)monst >= 0xC8 ) + if ( (unsigned int)monst >= MAXMONSTERS ) TermMsg("M_ChangeLightOffset: Invalid monster %d", monst); v2 = v1; v3 = monster[v1]._myoff; @@ -3061,7 +3061,7 @@ int __fastcall M_DoStand(int i) int v5; // eax v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoStand: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -3096,7 +3096,7 @@ int __fastcall M_DoWalk(int i) int v13; // ecx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoWalk: Invalid monster %d", i); v2 = v1; v3 = 0; @@ -3149,7 +3149,7 @@ int __fastcall M_DoWalk2(int i) int v9; // ecx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoWalk2: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -3203,7 +3203,7 @@ int __fastcall M_DoWalk3(int i) int v14; // ecx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoWalk3: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -3263,7 +3263,7 @@ void __fastcall M_TryM2MHit(int i, int mid, int hper, int mind, int maxd) v5 = mid; *(_DWORD *)arglist = mid; *(_DWORD *)v13 = i; - if ( (unsigned int)mid >= 0xC8 ) + if ( (unsigned int)mid >= MAXMONSTERS ) { TermMsg("M_TryM2MHit: Invalid monster %d", mid); //i = v6; @@ -3345,7 +3345,7 @@ void __fastcall M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam) v5 = i; plr_num = pnum; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_TryH2HHit: Invalid monster %d", i); v6 = v5; if ( !monster[v5].MType ) @@ -3540,7 +3540,7 @@ int __fastcall M_DoAttack(int i) unsigned char v5; // al v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoAttack: Invalid monster %d", i); v2 = v1; v3 = &monster[v1].MType; @@ -3601,7 +3601,7 @@ int __fastcall M_DoRAttack(int i) int v6; // edi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoRAttack: Invalid monster %d", i); v2 = v1; v3 = &monster[v1].MType; @@ -3655,7 +3655,7 @@ int __fastcall M_DoRSpAttack(int i) int v5; // ecx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoRSpAttack: Invalid monster %d", i); v2 = v1; v3 = &monster[v1].MType; @@ -3710,7 +3710,7 @@ int __fastcall M_DoSAttack(int i) bool v4; // zf v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoSAttack: Invalid monster %d", i); v2 = v1; v3 = &monster[v1].MType; @@ -3741,7 +3741,7 @@ int __fastcall M_DoFadein(int i) int v2; // esi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoFadein: Invalid monster %d", i); v2 = v1; if ( (!(monster[v1]._mFlags & 2) || monster[v2]._mAnimFrame != 1) @@ -3764,7 +3764,7 @@ int __fastcall M_DoFadeout(int i) int v6; // edx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoFadeout: Invalid monster %d", i); v2 = v1; v3 = monster[v1]._mFlags; @@ -3796,7 +3796,7 @@ int __fastcall M_DoHeal(int i) int v8; // esi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoHeal: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mFlags & 8 ) @@ -3840,7 +3840,7 @@ int __fastcall M_DoTalk(int i) char *v9; // eax v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoTalk: Invalid monster %d", i); v2 = v1; M_StartStand(v1, monster[v1]._mdir); @@ -3946,7 +3946,7 @@ void __fastcall M_Teleport(int i) v1 = i; a1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) { TermMsg("M_Teleport: Invalid monster %d", i); //i = v2; @@ -4010,7 +4010,7 @@ int __fastcall M_DoGotHit(int i) int v2; // esi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoGotHit: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -4030,7 +4030,7 @@ void __fastcall M_UpdateLeader(int i) unsigned char *v5; // eax v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_UpdateLeader: Invalid monster %d", i); v2 = nummonsters; for ( j = 0; j < v2; ++j ) @@ -4143,7 +4143,7 @@ int __fastcall M_DoDeath(int i) int v11; // eax v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoDeath: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -4194,7 +4194,7 @@ int __fastcall M_DoSpStand(int i) int v2; // esi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoSpStand: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -4218,7 +4218,7 @@ int __fastcall M_DoDelay(int i) int v7; // ebx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoDelay: Invalid monster %d", i); v2 = v1; if ( !monster[v1].MType ) @@ -4249,7 +4249,7 @@ int __fastcall M_DoStone(int i) int v3; // ecx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_DoStone: Invalid monster %d", i); v2 = v1; if ( !monster[v1]._mhitpoints ) @@ -4282,7 +4282,7 @@ void __fastcall M_WalkDir(int i, int md) v2 = i; v3 = md; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_WalkDir: Invalid monster %d", i); v4 = monster[v2].MType->Anims[1].Rate - 1; switch ( v3 ) @@ -4357,7 +4357,7 @@ void __fastcall GroupUnity(int i) //int v13; // [esp+10h] [ebp-4h] v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("GroupUnity: Invalid monster %d", i); v2 = v1; if ( monster[v1].leaderflag ) @@ -4537,7 +4537,7 @@ bool __fastcall M_PathWalk(int i) char path[25]; // [esp+4h] [ebp-1Ch] v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("M_PathWalk: Invalid monster %d", i); Check = PosOkMonst3; if ( !(monster[v1]._mFlags & 0x200) ) @@ -4698,7 +4698,7 @@ void __fastcall MAI_Zombie(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) { TermMsg("MAI_Zombie: Invalid monster %d", i); //i = v2; @@ -4768,7 +4768,7 @@ void __fastcall MAI_SkelSd(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_SkelSd: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND && v2->_msquelch ) @@ -4826,7 +4826,7 @@ bool __fastcall MAI_Path(int i) unsigned char v5; // al v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Path: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->MType->mtype != MT_GOLEM ) @@ -4905,7 +4905,7 @@ void __fastcall MAI_Snake(int i) esi1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Snake: Invalid monster %d", i); pattern[2] = 0; pattern[3] = -1; @@ -5084,7 +5084,7 @@ void __fastcall MAI_Bat(int i) esi1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Bat: Invalid monster %d", i); esi3 = &monster[esi1]; micaster = esi3->_menemy; @@ -5193,7 +5193,7 @@ void __fastcall MAI_SkelBow(int i) v18 = 0; v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_SkelBow: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND && v2->_msquelch ) @@ -5254,7 +5254,7 @@ void __fastcall MAI_Fat(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Fat: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND && v2->_msquelch ) @@ -5314,7 +5314,7 @@ void __fastcall MAI_Sneak(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Sneak: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND ) @@ -5419,7 +5419,7 @@ void __fastcall MAI_Fireman(int i) esi1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Fireman: Invalid monster %d", i); esi3 = esi1; if ( monster[esi3]._mmode || !monster[esi3]._msquelch ) @@ -5527,7 +5527,7 @@ void __fastcall MAI_Fallen(int i) int v16; // esi v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) { TermMsg("MAI_Fallen: Invalid monster %d", i); //i = v2; @@ -5630,7 +5630,7 @@ void __fastcall MAI_Cleaver(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Cleaver: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND && v2->_msquelch ) @@ -5683,7 +5683,7 @@ void __fastcall MAI_Round(int i, unsigned char special) v2 = i; v27 = special; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Round: Invalid monster %d", i); v3 = &monster[v2]; if ( v3->_mmode == MM_STAND && v3->_msquelch ) @@ -5802,7 +5802,7 @@ void __fastcall MAI_Ranged(int i, int missile_type, unsigned char special) v3 = i; missile_typea = missile_type; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Ranged: Invalid monster %d", i); v4 = v3; if ( monster[v3]._mmode == MM_STAND ) @@ -5899,7 +5899,7 @@ void __fastcall MAI_Scav(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Scav: Invalid monster %d", i); v2 = v1; v20 = 0; @@ -6047,7 +6047,7 @@ void __fastcall MAI_Garg(int i) int v8; // [esp+10h] [ebp-4h] v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Garg: Invalid monster %d", i); v2 = &monster[v1]; v3 = v2->_mx - v2->_lastx; @@ -6125,7 +6125,7 @@ void __fastcall MAI_RoundRanged(int i, int missile_type, unsigned char checkdoor v5 = i; missile_typea = missile_type; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_RoundRanged: Invalid monster %d", i); v6 = &monster[v5]; if ( v6->_mmode == MM_STAND && v6->_msquelch ) @@ -6300,7 +6300,7 @@ void __fastcall MAI_RR2(int i, int mistype, int dam) v3 = i; missile_type = mistype; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_RR2: Invalid monster %d", i); v4 = &monster[v3]; v5 = v4->_my - (unsigned char)v4->_menemyy; @@ -6458,7 +6458,7 @@ void __fastcall MAI_Golum(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Golum: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mx != 1 || monster[v2]._my ) @@ -6583,7 +6583,7 @@ void __fastcall MAI_SkelKing(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_SkelKing: Invalid monster %d", i); v2 = &monster[v1]; if ( v2->_mmode == MM_STAND && v2->_msquelch ) @@ -6661,7 +6661,7 @@ void __fastcall MAI_SkelKing(int i) { v21 = v2->_mx + offset_x[md]; v22 = v2->_my + offset_y[md]; - if ( PosOkMonst(arglist, v21, v22) && nummonsters < 200 ) + if ( PosOkMonst(arglist, v21, v22) && nummonsters < MAXMONSTERS ) { M_SpawnSkel(v21, v22, md); M_StartSpStand(arglist, md); @@ -6734,7 +6734,7 @@ void __fastcall MAI_Rhino(int i) esi1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Rhino: Invalid monster %d", i); esi3 = &monster[esi1]; if ( esi3->_mmode == MM_STAND && esi3->_msquelch ) @@ -6893,7 +6893,7 @@ void __fastcall MAI_Counselor(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Counselor: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND && monster[v2]._msquelch ) @@ -7038,7 +7038,7 @@ void __fastcall MAI_Garbud(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Garbud: Invalid monster %d", i); v2 = v1; if ( monster[v2]._mmode == MM_STAND ) @@ -7093,7 +7093,7 @@ void __fastcall MAI_Zhar(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Zhar: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND ) @@ -7148,7 +7148,7 @@ void __fastcall MAI_SnotSpil(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_SnotSpil: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND ) @@ -7210,7 +7210,7 @@ void __fastcall MAI_Lazurus(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Lazurus: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND ) @@ -7276,7 +7276,7 @@ void __fastcall MAI_Lazhelp(int i) v1 = i; ia = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Lazhelp: Invalid monster %d", i); v2 = v1; if ( monster[v2]._mmode == MM_STAND ) @@ -7317,7 +7317,7 @@ void __fastcall MAI_Lachdanan(int i) int v6; // [esp+8h] [ebp-4h] v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Lachdanan: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND ) @@ -7362,7 +7362,7 @@ void __fastcall MAI_Warlord(int i) v1 = i; arglist = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("MAI_Warlord: Invalid monster %d", i); v2 = v1; if ( monster[v1]._mmode == MM_STAND ) @@ -7488,7 +7488,7 @@ void __cdecl ProcessMonsters() if ( monster[v1]._mFlags & 0x10 ) { v5 = monster[v1]._menemy; - if ( v5 >= 0xC8 ) + if ( v5 >= MAXMONSTERS ) TermMsg("Illegal enemy monster %d for monster \"%s\"", v5, monster[v1].mName); v6 = monster[v1]._menemy; v7 = monster[v6]._mfutx; @@ -7501,7 +7501,7 @@ void __cdecl ProcessMonsters() else { v9 = monster[v1]._menemy; - if ( v9 >= 4 ) + if ( v9 >= MAX_PLRS ) TermMsg("Illegal enemy player %d for monster \"%s\"", v9, monster[v1].mName); v10 = monster[v1]._menemy; v11 = (*v4 & 2) == 0; @@ -7700,7 +7700,7 @@ bool __fastcall DirOK(int i, int mdir) v3 = mdir; v25 = mdir; a1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("DirOK: Invalid monster %d", i); v4 = v2; v5 = offset_y[v3]; @@ -8103,7 +8103,7 @@ void __fastcall SyncMonsterAnim(int i) int v13; // edx v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("SyncMonsterAnim: Invalid monster %d", i); v2 = v1; v3 = monster[v1]._mMTidx; @@ -8405,7 +8405,7 @@ void __fastcall MissToMonst(int i, int x, int y) v4 = &missile[v3]; v5 = v4->_misource; ia = v4->_misource; - if ( v5 >= 0xC8 ) + if ( v5 >= MAXMONSTERS ) TermMsg("MissToMonst: Invalid monster %d", v5); v32 = v4->_mix; v31 = v4->_miy; @@ -8923,7 +8923,7 @@ void __fastcall TalktoMonster(int i) int inv_item_num; // [esp+8h] [ebp-4h] v1 = i; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("TalktoMonster: Invalid monster %d", i); v2 = &monster[v1]; v3 = v2->_mAi; @@ -8965,7 +8965,7 @@ void __fastcall SpawnGolum(int i, int x, int y, int mi) v4 = i; v5 = x; - if ( (unsigned int)i >= 0xC8 ) + if ( (unsigned int)i >= MAXMONSTERS ) TermMsg("SpawnGolum: Invalid monster %d", i); v6 = v4; monster[v6]._mx = v5; @@ -9011,7 +9011,7 @@ bool __fastcall CanTalkToMonst(int m) bool result; // al v1 = m; - if ( (unsigned int)m >= 0xC8 ) + if ( (unsigned int)m >= MAXMONSTERS ) TermMsg("CanTalkToMonst: Invalid monster %d", m); v2 = monster[v1]._mgoal; if ( v2 == 6 ) @@ -9032,7 +9032,7 @@ bool __fastcall CheckMonsterHit(int m, bool *ret) v2 = m; v3 = ret; - if ( (unsigned int)m >= 0xC8 ) + if ( (unsigned int)m >= MAXMONSTERS ) TermMsg("CheckMonsterHit: Invalid monster %d", m); v4 = v2; if ( monster[v2]._mAi == AI_GARG && (v5 = monster[v4]._mFlags, v5 & 4) ) diff --git a/Source/monster.h b/Source/monster.h index b3cb8abab..e650dd0c7 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -4,11 +4,11 @@ extern int MissileFileFlag; // weak extern int monster_cpp_init_value; // weak -extern int monstkills[200]; -extern int monstactive[200]; +extern int monstkills[MAXMONSTERS]; +extern int monstactive[MAXMONSTERS]; extern int nummonsters; extern int sgbSaveSoundOn; // weak -extern MonsterStruct monster[200]; +extern MonsterStruct monster[MAXMONSTERS]; extern int totalmonsters; // weak extern CMonster Monsters[16]; // int END_Monsters_17; // weak diff --git a/Source/msg.cpp b/Source/msg.cpp index db1b85f3f..684050e25 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -6,12 +6,12 @@ int sgdwOwnerWait; // weak int msg_cpp_init_value; // weak int sgdwRecvOffset; // idb int sgnCurrMegaPlayer; // weak -DLevel sgLevels[17]; +DLevel sgLevels[NUMLEVELS]; char sbLastCmd; // weak TMegaPkt *sgpCurrPkt; char sgRecvBuf[4722]; unsigned char sgbRecvCmd; // idb -LocalLevel sgLocals[17]; +LocalLevel sgLocals[NUMLEVELS]; DJunk sgJunk[4]; TMegaPkt *sgpMegaPkt; char sgbDeltaChanged; // weak @@ -269,7 +269,7 @@ void __fastcall DeltaExportData(int pnum) dthread_send_delta(player_num, (_BYTE)v11++ + CMD_DLEVEL_0, v1, v7); v2 += 4721; } - while ( (signed int)v2 < (signed int)&sgLevels[17].object ); + while ( (signed int)v2 < (signed int)&sgLevels[NUMLEVELS].object ); v8 = DeltaExportJunk((char *)v3); v9 = msg_comp_level(v1, (int)v8); dthread_send_delta(player_num, CMD_DLEVEL_JUNK, v1, v9); @@ -324,7 +324,7 @@ void *__fastcall DeltaExportMonster(void *dst, void *src) v2 = (unsigned char *)src; v3 = (unsigned char *)dst; - v4 = 200; + v4 = MAXMONSTERS; do { if ( *v2 == -1 ) @@ -1665,7 +1665,7 @@ void *__fastcall DeltaImportMonster(void *src, void *dst) v2 = (char *)dst; v3 = (unsigned char *)src; - v4 = 200; + v4 = MAXMONSTERS; do { if ( *v3 == -1 ) diff --git a/Source/msg.h b/Source/msg.h index e3501b239..2ec0c159c 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -6,12 +6,12 @@ extern int sgdwOwnerWait; // weak extern int msg_cpp_init_value; // weak extern int sgdwRecvOffset; // idb extern int sgnCurrMegaPlayer; // weak -extern DLevel sgLevels[17]; +extern DLevel sgLevels[NUMLEVELS]; extern char sbLastCmd; // weak extern TMegaPkt *sgpCurrPkt; extern char sgRecvBuf[4722]; extern unsigned char sgbRecvCmd; // idb -extern LocalLevel sgLocals[17]; +extern LocalLevel sgLocals[NUMLEVELS]; extern DJunk sgJunk[4]; extern TMegaPkt *sgpMegaPkt; extern char sgbDeltaChanged; // weak diff --git a/Source/multi.cpp b/Source/multi.cpp index 77a6e1377..e2bb5df0c 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -5,20 +5,20 @@ char gbSomebodyWonGameKludge; // weak char pkdata_6761C0[4100]; char szPlayerDescript[128]; -short sgwPackPlrOffsetTbl[4]; -PkPlayerStruct pkplr[4]; -char sgbPlayerTurnBitTbl[4]; -char sgbPlayerLeftGameTbl[4]; +short sgwPackPlrOffsetTbl[MAX_PLRS]; +PkPlayerStruct pkplr[MAX_PLRS]; +char sgbPlayerTurnBitTbl[MAX_PLRS]; +char sgbPlayerLeftGameTbl[MAX_PLRS]; int multi_cpp_init_value; // weak int sgbSentThisCycle; // idb int dword_678628; // weak char gbActivePlayers; // weak char gbGameDestroyed; // weak -char sgbSendDeltaTbl[4]; +char sgbSendDeltaTbl[MAX_PLRS]; _gamedata sgGameInitInfo; char byte_678640; // weak int sglTimeoutStart; // weak -int sgdwPlayerLeftReasonTbl[4]; +int sgdwPlayerLeftReasonTbl[MAX_PLRS]; char pkdata_678658[4100]; unsigned int sgdwGameLoops; // idb char gbMaxPlayers; // weak @@ -26,7 +26,7 @@ char sgbTimeout; // weak char szPlayerName[128]; char gbDeltaSender; // weak int sgbNetInited; // weak -int player_state[4]; +int player_state[MAX_PLRS]; int multi_inf = 0x7F800000; // weak event_type event_types[3] = @@ -235,7 +235,7 @@ void __cdecl multi_msg_countdown() } ++v0; } - while ( v0 < 4 ); + while ( v0 < MAX_PLRS ); } void __fastcall multi_parse_turn(int pnum, int turn) @@ -269,7 +269,7 @@ void __fastcall multi_handle_turn_upper_bit(int pnum) break; ++v1; } - while ( v1 < 4 ); + while ( v1 < MAX_PLRS ); if ( myplr == v1 ) { sgbSendDeltaTbl[pnum] = 1; @@ -306,7 +306,7 @@ void __cdecl multi_clear_left_tbl() } ++v0; } - while ( v0 < 4 ); + while ( v0 < MAX_PLRS ); } // 676194: using guessed type char gbBufferMsgs; @@ -380,7 +380,7 @@ int __cdecl multi_handle_delta() } ++v0; } - while ( v0 < 4 ); + while ( v0 < MAX_PLRS ); sgbSentThisCycle = nthread_send_and_recv_turn(sgbSentThisCycle, 1); if ( !nthread_recv_turns(&recieved) ) { @@ -432,7 +432,7 @@ void __cdecl multi_mon_seeds() *v2 = v3; v2 += 57; } - while ( (signed int)v2 < (signed int)&monster[200]._mAISeed ); + while ( (signed int)v2 < (signed int)&monster[MAXMONSTERS]._mAISeed ); } void __cdecl multi_begin_timeout() @@ -481,7 +481,7 @@ void __cdecl multi_begin_timeout() } ++v4; } - while ( v4 < 4 ); + while ( v4 < MAX_PLRS ); if ( bGroupPlayers >= v6 && (bGroupPlayers != v6 || nLowestPlayer == nLowestActive) ) { if ( nLowestActive == myplr ) @@ -520,7 +520,7 @@ void __cdecl multi_check_drop_player() } ++v0; } - while ( v0 < 4 ); + while ( v0 < MAX_PLRS ); } void __cdecl multi_process_network_packets() @@ -543,7 +543,7 @@ void __cdecl multi_process_network_packets() //int v15; // eax TPktHdr *pkt; // [esp+0h] [ebp-Ch] int len; // [esp+4h] [ebp-8h] - char arglist[4]; // [esp+8h] [ebp-4h] + char arglist[4]; // [esp+8h] [ebp-4h] /* fix, int */ multi_clear_left_tbl(); multi_process_tmsgs(); @@ -817,11 +817,11 @@ int __fastcall NetInit(int bSinglePlayer, int *pfExitProgram) ProgramData.programdescription = gszVersionNumber; ProgramData.programid = 'DRTL'; ProgramData.versionid = 42; - ProgramData.maxplayers = 4; + ProgramData.maxplayers = MAX_PLRS; ProgramData.initdata = &sgGameInitInfo; ProgramData.initdatabytes = 8; ProgramData.optcategorybits = 15; - ProgramData.lcid = 1033; + ProgramData.lcid = 1033; /* LANG_ENGLISH */ memset(&a2, 0, 0x10u); a2.size = 16; memset(&UiData, 0, 0x50u); @@ -1050,10 +1050,10 @@ int __fastcall multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA * break; byte_678640 = 1; } - if ( (unsigned int)a6 >= 4 ) + if ( (unsigned int)a6 >= MAX_PLRS ) return 0; myplr = a6; - gbMaxPlayers = 4; + gbMaxPlayers = MAX_PLRS; pfile_read_player_from_save(); if ( type == 'BNET' ) plr[myplr].pBattleNet = 1; diff --git a/Source/multi.h b/Source/multi.h index 612957f78..faf4aa96b 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -5,20 +5,20 @@ extern char gbSomebodyWonGameKludge; // weak extern char pkdata_6761C0[4100]; extern char szPlayerDescript[128]; -extern short sgwPackPlrOffsetTbl[4]; -extern PkPlayerStruct pkplr[4]; -extern char sgbPlayerTurnBitTbl[4]; -extern char sgbPlayerLeftGameTbl[4]; +extern short sgwPackPlrOffsetTbl[MAX_PLRS]; +extern PkPlayerStruct pkplr[MAX_PLRS]; +extern char sgbPlayerTurnBitTbl[MAX_PLRS]; +extern char sgbPlayerLeftGameTbl[MAX_PLRS]; extern int multi_cpp_init_value; // weak extern int sgbSentThisCycle; // idb extern int dword_678628; // weak extern char gbActivePlayers; // weak extern char gbGameDestroyed; // weak -extern char sgbSendDeltaTbl[4]; +extern char sgbSendDeltaTbl[MAX_PLRS]; extern _gamedata sgGameInitInfo; extern char byte_678640; // weak extern int sglTimeoutStart; // weak -extern int sgdwPlayerLeftReasonTbl[4]; +extern int sgdwPlayerLeftReasonTbl[MAX_PLRS]; extern char pkdata_678658[4100]; extern unsigned int sgdwGameLoops; // idb extern char gbMaxPlayers; // weak @@ -26,7 +26,7 @@ extern char sgbTimeout; // weak extern char szPlayerName[128]; extern char gbDeltaSender; // weak extern int sgbNetInited; // weak -extern int player_state[4]; +extern int player_state[MAX_PLRS]; void __cdecl multi_cpp_init(); void __fastcall multi_msg_add(unsigned char *a1, unsigned char a2); diff --git a/Source/objects.cpp b/Source/objects.cpp index 4f03e47d2..696c41ef4 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -6,11 +6,11 @@ int trapid; // weak int trapdir; // weak int pObjCels[40]; char ObjFileList[40]; -int objectactive[127]; +int objectactive[MAXOBJECTS]; int nobjects; // idb int leverid; // idb -int objectavail[127]; -ObjectStruct object[127]; +int objectavail[MAXOBJECTS]; +ObjectStruct object[MAXOBJECTS]; int InitObjFlag; // weak int numobjfiles; // weak @@ -647,7 +647,7 @@ void __cdecl ClrAllObjects() v0[23] = 0; v0 += 30; } - while ( (signed int)v0 < (signed int)&object[127]._oy ); + while ( (signed int)v0 < (signed int)&object[MAXOBJECTS]._oy ); v1 = 0; memset(objectactive, 0, sizeof(objectactive)); nobjects = 0; @@ -656,7 +656,7 @@ void __cdecl ClrAllObjects() objectavail[v1] = v1; ++v1; } - while ( v1 < 127 ); + while ( v1 < MAXOBJECTS ); trapdir = 0; trapid = 1; leverid = 1; @@ -1752,7 +1752,7 @@ void __fastcall DeleteObject(int oi, int i) v2 = nobjects - 1; v3 = nobjects == 1; v4 = nobjects - 1 < 0; - objectavail[-nobjects + 127] = oi; /* *(&object[0]._otype - nobjects) = oi; */ + objectavail[-nobjects + MAXOBJECTS] = oi; /* *(&object[0]._otype - nobjects) = oi; */ nobjects = v2; if ( !v4 && !v3 && i != v2 ) objectactive[i] = objectactive[v2]; @@ -2287,7 +2287,7 @@ void __cdecl AddMushPatch() int y; // [esp+0h] [ebp-8h] int x; // [esp+4h] [ebp-4h] - if ( nobjects < 127 ) + if ( nobjects < MAXOBJECTS ) { i = objectavail[0]; GetRndObjLoc(5, &x, &y); @@ -2318,12 +2318,12 @@ void __fastcall AddObject(int ot, int ox, int oy) v3 = ox; v4 = ot; - if ( nobjects < 127 ) + if ( nobjects < MAXOBJECTS ) { //v5 = 4 * nobjects; v6 = objectavail[0]; objectactive[nobjects] = objectavail[0]; - objectavail[0] = objectavail[-nobjects + 126]; /* double check */ + objectavail[0] = objectavail[-nobjects + 126]; /* double check, MAXOBJECTS */ dObject[ox][oy] = v6 + 1; SetupObject(v6, ox, oy, ot); switch ( v4 ) diff --git a/Source/objects.h b/Source/objects.h index 03a5c6d9d..c36a30b9c 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -6,11 +6,11 @@ extern int trapid; // weak extern int trapdir; // weak extern int pObjCels[40]; extern char ObjFileList[40]; -extern int objectactive[127]; +extern int objectactive[MAXOBJECTS]; extern int nobjects; // idb extern int leverid; // idb -extern int objectavail[127]; -extern ObjectStruct object[127]; +extern int objectavail[MAXOBJECTS]; +extern ObjectStruct object[MAXOBJECTS]; extern int InitObjFlag; // weak extern int numobjfiles; // weak diff --git a/Source/pack.cpp b/Source/pack.cpp index d93533d48..a21d10a61 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -241,6 +241,8 @@ void __fastcall UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool killok) pPlayer->pManaShield = pPack->pManaShield; } +// Note: last slot of item[MAXITEMS+1] used as temporary buffer +// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id) { PkItemStruct *v2; // esi @@ -259,7 +261,7 @@ void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id) if ( is->idx == IDI_EAR ) { RecreateEar( - 127, + MAXITEMS, is->iCreateInfo, is->iSeed, is->bId, @@ -274,14 +276,14 @@ void __fastcall UnPackItem(PkItemStruct *is, ItemStruct *id) { v5 = (unsigned short)is->wValue; _LOWORD(v5) = v2->iCreateInfo; - RecreateItem(127, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue); - item[127]._iMagical = (unsigned char)v2->bId >> 1; - item[127]._iIdentified = v2->bId & 1; - item[127]._iDurability = (unsigned char)v2->bDur; - item[127]._iMaxDur = (unsigned char)v2->bMDur; - item[127]._iCharges = (unsigned char)v2->bCh; - item[127]._iMaxCharges = (unsigned char)v2->bMCh; + RecreateItem(MAXITEMS, is->idx, v5, v2->iSeed, (unsigned short)v2->wValue); + item[MAXITEMS]._iMagical = (unsigned char)v2->bId >> 1; + item[MAXITEMS]._iIdentified = v2->bId & 1; + item[MAXITEMS]._iDurability = (unsigned char)v2->bDur; + item[MAXITEMS]._iMaxDur = (unsigned char)v2->bMDur; + item[MAXITEMS]._iCharges = (unsigned char)v2->bCh; + item[MAXITEMS]._iMaxCharges = (unsigned char)v2->bMCh; } - qmemcpy(v3, &item[127], sizeof(ItemStruct)); + qmemcpy(v3, &item[MAXITEMS], sizeof(ItemStruct)); } } diff --git a/Source/player.cpp b/Source/player.cpp index 567a77d57..dc90b5367 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -8,7 +8,7 @@ char plr_gfx_flag; // weak int player_cpp_init_value; // weak int plr_aframe_size; // idb int myplr; -PlayerStruct plr[4]; +PlayerStruct plr[MAX_PLRS]; int plr_fframe_size; // idb int plr_qframe_size; // idb int deathflag; // idb @@ -152,7 +152,7 @@ void __fastcall LoadPlrGFX(int pnum, int gfxflag) v2 = pnum; v16 = gfxflag; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("LoadPlrGFX: illegal player %d", pnum); v3 = &plr[v2]; sprintf( @@ -294,7 +294,7 @@ void __fastcall InitPlayerGFX(int pnum) int v2; // edx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("InitPlayerGFX: illegal player %d", pnum); if ( plr[v1]._pHitPoints & 0xFFFFFFC0 ) { @@ -330,7 +330,7 @@ void __fastcall InitPlrGFXMem(int pnum) void *v18; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("InitPlrGFXMem: illegal player %d", pnum); if ( !(plr_gfx_flag & 1) ) { @@ -481,7 +481,7 @@ void __fastcall FreePlayerGFX(int pnum) void *v11; // ecx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("FreePlayerGFX: illegal player %d", pnum); v2 = v1; v3 = plr[v2]._pNData; @@ -522,7 +522,7 @@ void __fastcall NewPlrAnim(int pnum, int Peq, int numFrames, int Delay, int widt v5 = pnum; v6 = Peq; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("NewPlrAnim: illegal player %d", pnum); v7 = v5; plr[v7]._pAnimLen = numFrames; @@ -540,7 +540,7 @@ void __fastcall ClearPlrPVars(int pnum) int v2; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ClearPlrPVars: illegal player %d", pnum); v2 = v1; plr[v2]._pVar1 = 0; @@ -564,7 +564,7 @@ void __fastcall SetPlrAnims(int pnum) int v7; // ecx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlrAnims: illegal player %d", pnum); v2 = leveltype; v3 = v1; @@ -715,7 +715,7 @@ void __fastcall CreatePlayer(int pnum, char c) ClearPlrRVars(&plr[pnum]); v5 = GetTickCount(); SetRndSeed(v5); - if ( v2 >= 4 ) + if ( v2 >= MAX_PLRS ) TermMsg("CreatePlayer: illegal player %d", v2); v6 = v3; _LOBYTE(plr[v4]._pClass) = v3; @@ -882,7 +882,7 @@ void __fastcall NextPlrLevel(int pnum) int v11; // edx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("NextPlrLevel: illegal player %d", pnum); v2 = v1; v3 = &plr[v1]._pLevel; @@ -945,7 +945,7 @@ void __fastcall AddPlrExperience(int pnum, int lvl, int exp) arglist = pnum; if ( pnum == myplr ) { - if ( (unsigned int)myplr >= 4 ) + if ( (unsigned int)myplr >= MAX_PLRS ) { TermMsg("AddPlrExperience: illegal player %d", myplr); v3 = myplr; @@ -1059,7 +1059,7 @@ void __fastcall InitPlayer(int pnum, bool FirstTime) v2 = pnum; v20 = FirstTime; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("InitPlayer: illegal player %d", pnum); v3 = v2; v4 = &plr[v2]; @@ -1199,7 +1199,7 @@ void __cdecl InitMultiView() { int v0; // eax - if ( (unsigned int)myplr >= 4 ) + if ( (unsigned int)myplr >= MAX_PLRS ) TermMsg("InitPlayer: illegal player %d", myplr); v0 = plr[myplr].WorldY; ViewX = plr[myplr].WorldX; @@ -1229,7 +1229,7 @@ void __fastcall InitPlayerLoc(int pnum, bool flag) v2 = pnum; v13 = flag; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("InitPlayer: illegal player %d", pnum); v3 = v2; v14 = 0; @@ -1296,7 +1296,7 @@ bool __fastcall PlrDirOK(int pnum, int dir) v2 = pnum; v3 = dir; p = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PlrDirOK: illegal player %d", pnum); v4 = v2; v5 = plr[v2].WorldX + offset_x[v3]; @@ -1419,7 +1419,7 @@ void __fastcall SetPlayerOld(int pnum) int v2; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlayerOld: illegal player %d", pnum); v2 = v1; plr[v2]._poldx = plr[v1].WorldX; @@ -1439,7 +1439,7 @@ void __fastcall FixPlayerLocation(int pnum, int dir) v2 = pnum; v3 = dir; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("FixPlayerLocation: illegal player %d", pnum); v4 = v2; v5 = plr[v2].WorldY; @@ -1473,7 +1473,7 @@ void __fastcall StartStand(int pnum, int dir) v2 = pnum; v3 = dir; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartStand: illegal player %d", pnum); v4 = v2; if ( !plr[v2]._pInvincible || plr[v4]._pHitPoints || v2 != myplr ) @@ -1502,7 +1502,7 @@ void __fastcall StartWalkStand(int pnum) int v5; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartWalkStand: illegal player %d", pnum); v2 = v1; v3 = plr[v1].WorldX; @@ -1543,7 +1543,7 @@ void __fastcall PM_ChangeLightOff(int pnum) int lx; // [esp+18h] [ebp-4h] v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_ChangeLightOff: illegal player %d", pnum); v2 = v1; v3 = -1; @@ -1596,7 +1596,7 @@ void __fastcall PM_ChangeOffset(int pnum) v1 = pnum; arglist = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_ChangeOffset: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pVar6; @@ -1644,7 +1644,7 @@ void __fastcall StartWalk(int pnum, int xvel, int yvel, int xadd, int yadd, int v7 = pnum; v18 = xvel; arglist = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartWalk: illegal player %d", pnum); v8 = v7; if ( plr[v7]._pInvincible && !plr[v8]._pHitPoints && v7 == myplr ) @@ -1745,7 +1745,7 @@ void __fastcall StartWalk2(int pnum, int xvel, int yvel, int xoff, int yoff, int v9 = pnum; v24 = xvel; arglist = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartWalk2: illegal player %d", pnum); v10 = v9; if ( plr[v9]._pInvincible && !plr[v10]._pHitPoints && v9 == myplr ) @@ -1856,7 +1856,7 @@ void __fastcall StartWalk3(int pnum, int xvel, int yvel, int xoff, int yoff, int v11 = pnum; v25 = xvel; arglist = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartWalk3: illegal player %d", pnum); v12 = v11; if ( plr[v11]._pInvincible && !plr[v12]._pHitPoints && v11 == myplr ) @@ -1956,7 +1956,7 @@ void __fastcall StartAttack(int pnum, int d) v2 = pnum; v3 = d; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartAttack: illegal player %d", pnum); v4 = v2; if ( !plr[v2]._pInvincible || plr[v4]._pHitPoints || v2 != myplr ) @@ -1984,7 +1984,7 @@ void __fastcall StartRangeAttack(int pnum, int d, int cx, int cy) v4 = pnum; a2a = d; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartRangeAttack: illegal player %d", pnum); v5 = v4; if ( !plr[v4]._pInvincible || plr[v5]._pHitPoints || v4 != myplr ) @@ -2014,7 +2014,7 @@ void __fastcall StartPlrBlock(int pnum, int dir) v2 = pnum; v3 = dir; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartPlrBlock: illegal player %d", pnum); v4 = v2; if ( !plr[v2]._pInvincible || plr[v4]._pHitPoints || v2 != myplr ) @@ -2045,7 +2045,7 @@ void __fastcall StartSpell(int pnum, int d, int cx, int cy) v4 = pnum; a2 = d; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartSpell: illegal player %d", pnum); v5 = v4; if ( plr[v4]._pInvincible && !plr[v5]._pHitPoints && v4 == myplr ) @@ -2108,7 +2108,7 @@ void __fastcall FixPlrWalkTags(int pnum) char *v15; // [esp+10h] [ebp-4h] v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("FixPlrWalkTags: illegal player %d", pnum); v13 = v1 + 1; v2 = -1 - v1; @@ -2221,7 +2221,7 @@ void __fastcall StartPlrHit(int pnum, int dam, unsigned char forcehit) v3 = pnum; v4 = dam; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("StartPlrHit: illegal player %d", pnum); v5 = v3; if ( plr[v3]._pInvincible && !plr[v5]._pHitPoints && v3 == myplr ) @@ -2472,7 +2472,7 @@ void __fastcall PlrDeadItem(int pnum, struct ItemStruct *itm, int xx, int yy) v4 = pnum; if ( itm->_itype != -1 ) { - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PlrDeadItem: illegal player %d", pnum); v5 = v4; v6 = yy + plr[v5].WorldY; @@ -2552,7 +2552,7 @@ void __fastcall DropHalfPlayersGold(int pnum) signed int ic; // [esp+10h] [ebp-4h] v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("DropHalfPlayersGold: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pGold >> 1; @@ -2968,7 +2968,7 @@ int __fastcall PM_DoWalk(int pnum) int result; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoWalk: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pAnimFrame; @@ -3035,7 +3035,7 @@ int __fastcall PM_DoWalk2(int pnum) int result; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoWalk2: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pAnimFrame; @@ -3098,7 +3098,7 @@ int __fastcall PM_DoWalk3(int pnum) int result; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoWalk3: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pAnimFrame; @@ -3629,7 +3629,7 @@ int __fastcall PM_DoAttack(int pnum) v1 = pnum; arglist = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoAttack: illegal player %d", pnum); v2 = v1; v3 = plr[v2]._pIFlags; @@ -3730,7 +3730,7 @@ int __fastcall PM_DoRangeAttack(int pnum) //int v6; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoRangeAttack: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pIFlags; @@ -3772,7 +3772,7 @@ void __fastcall ShieldDur(int pnum) v1 = pnum; if ( pnum == myplr ) { - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ShieldDur: illegal player %d", pnum); v2 = v1; if ( plr[v1].InvBody[4]._itype == ITYPE_SHIELD ) @@ -3813,7 +3813,7 @@ int __fastcall PM_DoBlock(int pnum) int v2; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoBlock: illegal player %d", pnum); v2 = v1; if ( plr[v1]._pIFlags & 0x1000000 && plr[v2]._pAnimFrame != 1 ) @@ -3833,7 +3833,7 @@ int __fastcall PM_DoSpell(int pnum) int v2; // esi v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoSpell: illegal player %d", pnum); v2 = v1; if ( plr[v1]._pVar8 == plr[v1]._pSFNum ) @@ -3894,7 +3894,7 @@ int __fastcall PM_DoGotHit(int pnum) int v4; // ecx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoGotHit: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pIFlags; @@ -3929,7 +3929,7 @@ void __fastcall ArmorDur(int pnum) v1 = pnum; if ( pnum == myplr ) { - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) { TermMsg("ArmorDur: illegal player %d", pnum); //pnum = v2; @@ -3982,7 +3982,7 @@ int __fastcall PM_DoDeath(int pnum) int v5; // eax v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PM_DoDeath: illegal player %d", pnum); v2 = v1; if ( plr[v1]._pVar8 >= 2 * plr[v1]._pDFrames ) @@ -4117,7 +4117,7 @@ void __fastcall CheckNewPath(int pnum) v1 = pnum; p = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("CheckNewPath: illegal player %d", pnum); v2 = v1; if ( plr[v1].destAction == 20 ) @@ -4536,7 +4536,7 @@ bool __fastcall PlrDeathModeOK(int pnum) v1 = pnum; if ( pnum != myplr ) goto LABEL_10; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("PlrDeathModeOK: illegal player %d", pnum); v3 = plr[v1]._pmode; if ( v3 == PM_DEATH || v3 == PM_QUIT ) @@ -4752,7 +4752,7 @@ void __cdecl ProcessPlayers() v5 += 5430; ++v4; } - while ( (signed int)v5 < (signed int)&plr[4]._pHitPoints ); + while ( (signed int)v5 < (signed int)&plr[MAX_PLRS]._pHitPoints ); } // 52A554: using guessed type int sfxdelay; @@ -4782,7 +4782,7 @@ void __fastcall ClrPlrPath(int pnum) int v1; // esi v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ClrPlrPath: illegal player %d", pnum); memset(plr[v1].walkpath, -1, 0x19u); } @@ -4831,7 +4831,7 @@ void __fastcall MakePlrPath(int pnum, int xx, int yy, unsigned char endspace) v4 = pnum; v5 = xx; a2 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("MakePlrPath: illegal player %d", pnum); v6 = v4; v7 = yy; @@ -5044,7 +5044,7 @@ void __fastcall SyncPlrAnim(int pnum) int v5; // edx v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SyncPlrAnim: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pdir; @@ -5183,7 +5183,7 @@ void __fastcall SyncInitPlr(int pnum) int v1; // esi v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SyncInitPlr: illegal player %d", pnum); SetPlrAnims(v1); SyncInitPlrPos(v1); @@ -5207,7 +5207,7 @@ void __fastcall CheckStats(int pnum) //signed int v14; // [esp+Ch] [ebp-4h] v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("CheckStats: illegal player %d", pnum); v2 = v1; v3 = plr[v1]._pClass; @@ -5313,7 +5313,7 @@ void __fastcall ModifyPlrStr(int pnum, int l) v2 = pnum; v3 = l; p = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ModifyPlrStr: illegal player %d", pnum); v4 = v2; v5 = plr[v4]._pClass; @@ -5355,7 +5355,7 @@ void __fastcall ModifyPlrMag(int pnum, int l) v2 = pnum; v3 = l; p = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ModifyPlrMag: illegal player %d", pnum); v4 = v2; v5 = plr[v4]._pClass; @@ -5391,7 +5391,7 @@ void __fastcall ModifyPlrDex(int pnum, int l) v2 = pnum; v3 = l; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ModifyPlrDex: illegal player %d", pnum); v4 = v2; v5 = MaxStats[SLOBYTE(plr[v2]._pClass)][2]; @@ -5422,7 +5422,7 @@ void __fastcall ModifyPlrVit(int pnum, int l) v2 = pnum; v3 = l; p = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("ModifyPlrVit: illegal player %d", pnum); v4 = v2; v5 = plr[v4]._pClass; @@ -5455,7 +5455,7 @@ void __fastcall SetPlayerHitPoints(int pnum, int newhp) v2 = pnum; v3 = newhp; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlayerHitPoints: illegal player %d", pnum); v4 = v2; v5 = plr[v2]._pMaxHPBase; @@ -5476,7 +5476,7 @@ void __fastcall SetPlrStr(int pnum, int v) v2 = pnum; v3 = v; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlrStr: illegal player %d", pnum); v4 = v2; plr[v2]._pBaseStr = v3; @@ -5503,7 +5503,7 @@ void __fastcall SetPlrMag(int pnum, int v) v2 = pnum; v3 = v; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlrMag: illegal player %d", pnum); v4 = v2; plr[v2]._pBaseMag = v3; @@ -5525,7 +5525,7 @@ void __fastcall SetPlrDex(int pnum, int v) v2 = pnum; v3 = v; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlrDex: illegal player %d", pnum); v4 = v2; plr[v2]._pBaseDex = v3; @@ -5552,7 +5552,7 @@ void __fastcall SetPlrVit(int pnum, int v) v2 = pnum; v3 = v; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("SetPlrVit: illegal player %d", pnum); v4 = v2; plr[v2]._pBaseVit = v3; @@ -5569,7 +5569,7 @@ void __fastcall InitDungMsgs(int pnum) int v1; // esi v1 = pnum; - if ( (unsigned int)pnum >= 4 ) + if ( (unsigned int)pnum >= MAX_PLRS ) TermMsg("InitDungMsgs: illegal player %d", pnum); plr[v1].pDungMsgs = 0; } diff --git a/Source/player.h b/Source/player.h index 407760b73..d9875981e 100644 --- a/Source/player.h +++ b/Source/player.h @@ -8,7 +8,7 @@ extern char plr_gfx_flag; // weak extern int player_cpp_init_value; // weak extern int plr_aframe_size; // idb extern int myplr; -extern PlayerStruct plr[4]; +extern PlayerStruct plr[MAX_PLRS]; extern int plr_fframe_size; // idb extern int plr_qframe_size; // idb extern int deathflag; // idb diff --git a/Source/portal.cpp b/Source/portal.cpp index 6633bd33c..d913cb629 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -2,17 +2,17 @@ #include "../types.h" -PortalStruct portal[4]; +PortalStruct portal[MAXPORTAL]; int portalindex; -int WarpDropX[4] = { 57, 59, 61, 63 }; -int WarpDropY[4] = { 40, 40, 40, 40 }; +int WarpDropX[MAXPORTAL] = { 57, 59, 61, 63 }; +int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 }; void __cdecl InitPortals() { int i; // edi - for(i = 0; i < 4; i++) + for(i = 0; i < MAXPORTAL; i++) { if(delta_portal_inited(i)) portal[i].open = 0; @@ -76,7 +76,7 @@ void __cdecl SyncPortals() v1 += 6; ++v0; } - while ( (signed int)v1 < (signed int)&portal[4].level ); + while ( (signed int)v1 < (signed int)&portal[MAXPORTAL].level ); } // 5CCB10: using guessed type char setlvlnum; // 5CF31D: using guessed type char setlevel; @@ -204,7 +204,7 @@ bool __fastcall PosOkPortal(int lvl, int x, int y) while ( !*(v3 - 1) || v3[2] != lvl || (*v3 != x || v3[1] != y) && (*v3 != x - 1 || v3[1] != y - 1) ) { v3 += 6; - if ( (signed int)v3 >= (signed int)&portal[4].x ) + if ( (signed int)v3 >= (signed int)&portal[MAXPORTAL].x ) return 0; } return 1; diff --git a/Source/portal.h b/Source/portal.h index b22956aa6..f97623fdd 100644 --- a/Source/portal.h +++ b/Source/portal.h @@ -2,7 +2,7 @@ #ifndef __PORTAL_H__ #define __PORTAL_H__ -extern PortalStruct portal[4]; +extern PortalStruct portal[MAXPORTAL]; extern int portalindex; // int END_portalstruct; // weak @@ -21,7 +21,7 @@ void __cdecl GetPortalLvlPos(); bool __fastcall PosOkPortal(int lvl, int x, int y); /* rdata */ -extern int WarpDropX[4]; -extern int WarpDropY[4]; +extern int WarpDropX[MAXPORTAL]; +extern int WarpDropY[MAXPORTAL]; #endif /* __PORTAL_H__ */ diff --git a/Source/quests.cpp b/Source/quests.cpp index 710cbb7b2..483b809ec 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -5,9 +5,9 @@ int qtopline; // idb int questlog; // weak void *pQLogCel; -QuestStruct quests[16]; +QuestStruct quests[MAXQUESTS]; int qline; // weak -int qlist[16]; +int qlist[MAXQUESTS]; int numqlines; // weak int WaterDone; // idb int ReturnLvlY; // idb @@ -16,7 +16,7 @@ int ReturnLvlT; // idb int ALLQUESTS; // idb int ReturnLvl; // idb -QuestData questlist[16] = +QuestData questlist[MAXQUESTS] = { { 5, -1, DTYPE_NONE, 0, 100, 0, 0, QUEST_INFRA5, "The Magic Rock" }, { 9, -1, DTYPE_NONE, 1, 100, 0, 0, QUEST_MUSH8, "Black Mushroom" }, @@ -79,7 +79,7 @@ void __cdecl InitQuests() *v2 = 0; v2 += 24; } - while ( (signed int)v2 < (signed int)&quests[16]._qactive ); + while ( (signed int)v2 < (signed int)&quests[MAXQUESTS]._qactive ); } else { @@ -92,7 +92,7 @@ void __cdecl InitQuests() v4 += 5; v3 += 24; } - while ( (signed int)v4 < (signed int)&questlist[16]._qflags ); + while ( (signed int)v4 < (signed int)&questlist[MAXQUESTS]._qflags ); } v5 = 0; questlog = 0; @@ -140,7 +140,7 @@ void __cdecl InitQuests() ++v6; v1 += 24; } - while ( v6 < 16 ); + while ( v6 < MAXQUESTS ); if ( v0 == 1 ) { SetRndSeed(glSeedTbl[15]); @@ -260,7 +260,7 @@ void __cdecl CheckQuests() } v1 += 24; } - while ( (signed int)v1 < (signed int)&quests[16]._qactive ); + while ( (signed int)v1 < (signed int)&quests[MAXQUESTS]._qactive ); } } // 5BB1ED: using guessed type char leveltype; @@ -284,7 +284,7 @@ bool __cdecl ForceQuests() { LABEL_10: ++v0; - if ( (signed int)v0 >= (signed int)&quests[16]._qslvl ) /* fix */ + if ( (signed int)v0 >= (signed int)&quests[MAXQUESTS]._qslvl ) /* fix */ return 0; } v1 = *(_DWORD *)&v0[-1]._qvar2; @@ -911,7 +911,7 @@ void __fastcall DRLG_CheckQuests(int x, int y) v5 += 24; ++v4; } - while ( (signed int)v5 < (signed int)&quests[16]._qtype ); + while ( (signed int)v5 < (signed int)&quests[MAXQUESTS]._qtype ); } // 69BE90: using guessed type int qline; @@ -1218,7 +1218,7 @@ void __cdecl StartQuestlog() ++v2; ++v1; } - while ( v2 < 16 ); + while ( v2 < MAXQUESTS ); numqlines = v0; if ( v0 <= 5 ) v3 = 8; diff --git a/Source/quests.h b/Source/quests.h index 6bacbbd3f..0d29aa7e4 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -5,9 +5,9 @@ extern int qtopline; // idb extern int questlog; // weak extern void *pQLogCel; -extern QuestStruct quests[16]; +extern QuestStruct quests[MAXQUESTS]; extern int qline; // weak -extern int qlist[16]; +extern int qlist[MAXQUESTS]; extern int numqlines; // weak extern int WaterDone; // idb extern int ReturnLvlY; // idb @@ -43,7 +43,7 @@ void __cdecl QuestlogESC(); void __fastcall SetMultiQuest(int q, int s, unsigned char l, int v1); /* rdata */ -extern QuestData questlist[16]; +extern QuestData questlist[MAXQUESTS]; extern char questxoff[7]; extern char questyoff[7]; extern char *questtrigstr[5]; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 9bda4cde2..e78044f15 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -19,7 +19,7 @@ int cel_transparency_active; // weak int level_piece_id; // weak int sgdwCursWdt; int (__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); -char cursor_draw_back_buffer[8192]; +char sgSaveBack[8192]; int draw_monster_num; // weak int sgdwCursHgtOld; // idb @@ -116,7 +116,7 @@ void __fastcall DrawMissile(int x, int y, int sx, int sy, int a5, int a6, int de for ( i = 0; i < nummissiles; v9 = i++ + 1 ) { v10 = missileactive[v9]; - if ( v10 >= 125 ) + if ( v10 >= MAXMISSILES ) break; v11 = &missile[v10]; if ( v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == del_flag && v11->_miDrawFlag ) @@ -215,7 +215,7 @@ void __fastcall DrawClippedMissile(int x, int y, int sx, int sy, int a5, int a6, for ( i = 0; i < nummissiles; v9 = i++ + 1 ) { v10 = missileactive[v9]; - if ( v10 >= 125 ) + if ( v10 >= MAXMISSILES ) break; v11 = &missile[v10]; if ( v11->_mix == v26 && v11->_miy == v7 && v11->_miPreFlag == a7 && v11->_miDrawFlag ) @@ -3000,7 +3000,7 @@ void __cdecl scrollrt_draw_cursor_back_buffer() if ( sgdwCursWdt ) { v1 = sgdwCursY; - v2 = cursor_draw_back_buffer; + v2 = sgSaveBack; v3 = &gpBuffer->row[sgdwCursY].pixels[sgdwCursX]; v4 = sgdwCursHgt; if ( sgdwCursHgt ) @@ -3082,7 +3082,7 @@ void __cdecl scrollrt_draw_cursor_item() v5 = cursH + v3 + 1; if ( v5 > 0x1DF ) v5 = 479; - v14 = cursor_draw_back_buffer; + v14 = sgSaveBack; v6 = 1 - v3 + v5; sgdwCursHgt = v6; v7 = &gpBuffer->row[v3].pixels[v2 & 0xFFFFFFFC]; diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 3d89bf754..bfff8c79e 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -19,7 +19,7 @@ extern int cel_transparency_active; // weak extern int level_piece_id; // weak extern int sgdwCursWdt; extern int (__fastcall *DrawPlrProc)(int player_num, int x, int y, int screen_x, int screen_y, void *cl2_buf, int frame, int frame_width, int a9, int a10); -extern char cursor_draw_back_buffer[8192]; +extern char sgSaveBack[8192]; extern int draw_monster_num; // weak extern int sgdwCursHgtOld; // idb diff --git a/Source/sync.cpp b/Source/sync.cpp index 51ace29ff..b84be630d 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -2,9 +2,9 @@ #include "../types.h" -short sync_word_6AA708[200]; +short sync_word_6AA708[MAXMONSTERS]; int dword_6AA898; // weak -short sync_word_6AA89C[200]; +short sync_word_6AA89C[MAXMONSTERS]; int dword_6AAA2C[2]; int sgnSyncPInv; // weak diff --git a/Source/sync.h b/Source/sync.h index def6e891e..341d7ec4c 100644 --- a/Source/sync.h +++ b/Source/sync.h @@ -2,9 +2,9 @@ #ifndef __SYNC_H__ #define __SYNC_H__ -extern short sync_word_6AA708[200]; +extern short sync_word_6AA708[MAXMONSTERS]; extern int dword_6AA898; // weak -extern short sync_word_6AA89C[200]; +extern short sync_word_6AA89C[MAXMONSTERS]; extern int dword_6AAA2C[2]; extern int sgnSyncPInv; // weak diff --git a/Source/themes.cpp b/Source/themes.cpp index 622468277..6fa7e0ed2 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -14,7 +14,7 @@ int zharlib; // weak int themex; // idb int themey; // idb int themeVar1; // idb -ThemeStruct themes[50]; +ThemeStruct themes[MAXTHEMES]; bool pFountainFlag; // weak bool bFountainFlag; // weak bool bCrossFlag; // weak @@ -581,7 +581,7 @@ void __cdecl InitThemes() v2 = 0; do { - if ( v0 >= 50 ) + if ( v0 >= MAXTHEMES ) break; //_LOBYTE(v3) = CheckThemeRoom(v2); if ( CheckThemeRoom(v2) ) diff --git a/Source/themes.h b/Source/themes.h index b671ef10a..cacdff44f 100644 --- a/Source/themes.h +++ b/Source/themes.h @@ -14,7 +14,7 @@ extern int zharlib; // weak extern int themex; // idb extern int themey; // idb extern int themeVar1; // idb -extern ThemeStruct themes[50]; +extern ThemeStruct themes[MAXTHEMES]; extern bool pFountainFlag; // weak extern bool bFountainFlag; // weak extern bool bCrossFlag; // weak diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 4b2d21dd8..71b9d1be5 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -2,8 +2,8 @@ #include "../types.h" -int trigflag[5]; -TriggerStruct trigs[5]; +int trigflag[MAXTRIGGERS]; +TriggerStruct trigs[MAXTRIGGERS]; int TWarpFrom; // weak int TownDownList[11] = { 716, 715, 719, 720, 721, 723, 724, 725, 726, 727, -1 }; diff --git a/Source/trigs.h b/Source/trigs.h index 9a7b20058..bfdbbd5f0 100644 --- a/Source/trigs.h +++ b/Source/trigs.h @@ -2,8 +2,8 @@ #ifndef __TRIGS_H__ #define __TRIGS_H__ -extern int trigflag[5]; -extern TriggerStruct trigs[5]; +extern int trigflag[MAXTRIGGERS]; +extern TriggerStruct trigs[MAXTRIGGERS]; extern int TWarpFrom; // weak void __cdecl InitNoTriggers(); diff --git a/defs.h b/defs.h index 66d4c08fb..97323ea63 100644 --- a/defs.h +++ b/defs.h @@ -27,6 +27,12 @@ #define MDMAXX 40 #define MDMAXY 40 +// todo: enums +#define NUM_CLASSES 3 +#define NUM_INVLOC 7 +#define NUM_SFX 858 +#define NUMLEVELS 17 + // from diablo 2 beta #define MAXEXP 2000000000 diff --git a/structs.h b/structs.h index 4d65cf0ce..d5e010d5e 100644 --- a/structs.h +++ b/structs.h @@ -622,9 +622,9 @@ struct TCmdPItem /* __declspec(align(1))*/ struct DLevel { - TCmdPItem item[127]; - DObjectStr object[127]; - DMonsterStr monster[200]; + TCmdPItem item[MAXITEMS]; + DObjectStr object[MAXOBJECTS]; + DMonsterStr monster[MAXMONSTERS]; }; struct DPortal @@ -645,8 +645,8 @@ struct MultiQuests struct DJunk { - DPortal portal[4]; - MultiQuests quests[4]; + DPortal portal[MAXPORTAL]; + MultiQuests quests[MAXMULTIQUESTS]; }; /* __declspec(align(1)) */ @@ -861,7 +861,7 @@ struct PlayerStruct int _pVar6; int _pVar7; int _pVar8; - unsigned char _pLvlVisited[17]; + unsigned char _pLvlVisited[17]; // NUMLEVELS unsigned char _pSLvlVisited[10]; char gap20F[9]; int _pGFXLoad; diff --git a/types.h b/types.h index d11698ef3..027771f2b 100644 --- a/types.h +++ b/types.h @@ -32,6 +32,7 @@ #pragma warning (disable : 4146) // negative unsigned #endif +#include "defs.h" #include "enums.h" #include "structs.h" @@ -39,9 +40,6 @@ #include "3rdParty/Storm/Source/storm.h" #include "3rdParty/PKWare/pkware.h" - -#include "defs.h" - // temporarily enable debug features for all builds #ifndef _DEBUG #define _DEBUG