diff --git a/.clang-format b/.clang-format index 6c69a182f9a..11c499191b4 100644 --- a/.clang-format +++ b/.clang-format @@ -1,10 +1,11 @@ { - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, - AlignConsecutiveAssignments: true, + BasedOnStyle: webkit, + AlignTrailingComments: true, + AllowShortBlocksOnASingleLine: true, + AllowShortFunctionsOnASingleLine: None, + PointerAlignment: Right, + AlignConsecutiveAssignments: true, TabWidth: 4, UseTab: ForIndentation, + SortIncludes: false, } diff --git a/Source/.clang-format b/Source/.clang-format index 7b78b700021..7074a477520 100644 --- a/Source/.clang-format +++ b/Source/.clang-format @@ -6,4 +6,5 @@ PointerAlignment: Right, TabWidth: 4, UseTab: ForIndentation, + SortIncludes: false, } diff --git a/Source/automap.cpp b/Source/automap.cpp index ab35e6af0d0..d8bd700982c 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -8,7 +8,7 @@ static int MapX; static int MapY; BOOL automapflag; char AmShiftTab[32]; // [31]? -unsigned char automapview[DMAXX][DMAXY]; +BOOLEAN automapview[DMAXX][DMAXY]; int AutoMapScale; int AutoMapXOfs; int AutoMapYOfs; @@ -72,19 +72,19 @@ void InitAutomap() switch (leveltype) { case DTYPE_CATHEDRAL: - pAFile = LoadFileInMem("Levels\\L1Data\\L1.AMP", (int *)&dwTiles); + pAFile = LoadFileInMem("Levels\\L1Data\\L1.AMP", &dwTiles); dwTiles >>= 1; break; case DTYPE_CATACOMBS: - pAFile = LoadFileInMem("Levels\\L2Data\\L2.AMP", (int *)&dwTiles); + pAFile = LoadFileInMem("Levels\\L2Data\\L2.AMP", &dwTiles); dwTiles >>= 1; break; case DTYPE_CAVES: - pAFile = LoadFileInMem("Levels\\L3Data\\L3.AMP", (int *)&dwTiles); + pAFile = LoadFileInMem("Levels\\L3Data\\L3.AMP", &dwTiles); dwTiles >>= 1; break; case DTYPE_HELL: - pAFile = LoadFileInMem("Levels\\L4Data\\L4.AMP", (int *)&dwTiles); + pAFile = LoadFileInMem("Levels\\L4Data\\L4.AMP", &dwTiles); dwTiles >>= 1; break; default: diff --git a/Source/automap.h b/Source/automap.h index 0d8a1e374fd..1793005b37d 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -5,7 +5,7 @@ extern WORD automaptype[512]; extern BOOL automapflag; extern char AmShiftTab[32]; -extern unsigned char automapview[DMAXX][DMAXY]; +extern BOOLEAN automapview[DMAXX][DMAXY]; extern int AutoMapScale; extern int AutoMapXOfs; extern int AutoMapYOfs; diff --git a/Source/codec.h b/Source/codec.h index 8ad33ac3821..0cae278498b 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -5,6 +5,6 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword); void codec_init_key(int unused, char *pszPassword); DWORD codec_get_encoded_len(DWORD dwSrcBytes); -void codec_encode(BYTE* pbSrcDst, DWORD size, int size_64, char *pszPassword); +void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, char *pszPassword); #endif /* __CODEC_H__ */ diff --git a/Source/control.cpp b/Source/control.cpp index 6af4b739f8f..56fa7de4405 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1124,24 +1124,24 @@ void InitControlPan() memset(pManaBuff, 0, 88 * 88); pLifeBuff = DiabloAllocPtr(88 * 88); memset(pLifeBuff, 0, 88 * 88); - pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); - pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); - pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); + pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", NULL); + pChrPanel = LoadFileInMem("Data\\Char.CEL", NULL); + pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", NULL); SetSpellTrans(RSPLTYPE_SKILL); - pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); + pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", NULL); CelDecodeRect(pBtmBuff, 0, 143, 640, pStatusPanel, 1, 640); MemFreeDbg(pStatusPanel); - pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); + pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", NULL); CelDecodeRect(pLifeBuff, 0, 87, 88, pStatusPanel, 1, 88); CelDecodeRect(pManaBuff, 0, 87, 88, pStatusPanel, 2, 88); MemFreeDbg(pStatusPanel); talkflag = 0; if (gbMaxPlayers != 1) { - pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); + pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", NULL); CelDecodeRect(pBtmBuff, 0, 287, 640, pTalkPanel, 1, 640); MemFreeDbg(pTalkPanel); - pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); - pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); + pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", NULL); + pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", NULL); sgbPlrTalkTbl = 0; sgszTalkMsg[0] = 0; for (i = 0; i < MAX_PLRS; i++) @@ -1151,7 +1151,7 @@ void InitControlPan() } panelflag = 0; lvlbtndown = 0; - pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); + pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", NULL); for (i = 0; i < sizeof(panbtn) / sizeof(panbtn[0]); i++) panbtn[i] = 0; panbtndown = 0; @@ -1159,20 +1159,20 @@ void InitControlPan() numpanbtns = 6; else numpanbtns = 8; - pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); + pChrButtons = LoadFileInMem("Data\\CharBut.CEL", NULL); for (i = 0; i < sizeof(chrbtn) / sizeof(chrbtn[0]); i++) chrbtn[i] = 0; chrbtnactive = FALSE; - pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); + pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", NULL); strcpy(infostr, ""); ClearPanel(); drawhpflag = TRUE; drawmanaflag = TRUE; chrflag = 0; spselflag = 0; - pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", 0); - pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", 0); - pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", 0); + pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", NULL); + pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", NULL); + pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", NULL); sbooktab = 0; sbookflag = 0; if (plr[myplr]._pClass == PC_WARRIOR) { @@ -1182,8 +1182,8 @@ void InitControlPan() } else if (plr[myplr]._pClass == PC_SORCERER) { SpellPages[0][0] = SPL_RECHARGE; } - pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); - pGBoxBuff = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); + pQLogCel = LoadFileInMem("Data\\Quest.CEL", NULL); + pGBoxBuff = LoadFileInMem("CtrlPan\\Golddrop.cel", NULL); dropGoldFlag = FALSE; dropGoldValue = 0; initialDropGoldValue = 0; @@ -2044,38 +2044,38 @@ void DrawDurIcon() } } -int DrawDurIcon4Item(ItemStruct *item, int x, int frame) +int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) { - if (item->_itype == ITYPE_NONE) + if (pItem->_itype == ITYPE_NONE) return x; - if (item->_iDurability > 5) + if (pItem->_iDurability > 5) return x; - if (frame == 0) { - if (item->_iClass == ICLASS_WEAPON) { - switch (item->_itype) { + if (c == 0) { + if (pItem->_iClass == ICLASS_WEAPON) { + switch (pItem->_itype) { case ITYPE_SWORD: - frame = 2; + c = 2; break; case ITYPE_AXE: - frame = 6; + c = 6; break; case ITYPE_BOW: - frame = 7; + c = 7; break; case ITYPE_MACE: - frame = 5; + c = 5; break; case ITYPE_STAFF: - frame = 8; + c = 8; break; } } else { - frame = 1; + c = 1; } } - if (item->_iDurability > 2) - frame += 8; - CelDecodeOnly(x, 495, pDurIcons, frame, 32); + if (pItem->_iDurability > 2) + c += 8; + CelDecodeOnly(x, 495, pDurIcons, c, 32); return x - 40; } diff --git a/Source/control.h b/Source/control.h index d87ca6cc82d..f1f96361168 100644 --- a/Source/control.h +++ b/Source/control.h @@ -97,7 +97,7 @@ void DrawLevelUpIcon(); void CheckChrBtns(); void ReleaseChrBtns(); void DrawDurIcon(); -int DrawDurIcon4Item(ItemStruct *item, int x, int frame); +int DrawDurIcon4Item(ItemStruct *pItem, int x, int c); void RedBack(); char GetSBookTrans(int ii, BOOL townok); void DrawSpellBook(); diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 923f07c3fd3..cbf1bb033ff 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -2,24 +2,24 @@ DEVILUTION_BEGIN_NAMESPACE -int cursH; // weak -int icursH28; // idb -int cursW; // idb -int pcursmonst; // idb -int icursW28; // idb +int cursH; +int icursH28; +int cursW; +int pcursmonst; +int icursW28; void *pCursCels; -int icursH; // weak +int icursH; // inv_item value -char pcursinvitem; // weak -int icursW; // weak -char pcursitem; // weak -char pcursobj; // weak -char pcursplr; // weak +char pcursinvitem; +int icursW; +char pcursitem; +char pcursobj; +char pcursplr; int cursmx; int cursmy; -int pcurstemp; // weak -int pcurs; // idb +int pcurstemp; +int pcurs; /* rdata */ const int InvItemWidth[180] = { @@ -71,7 +71,7 @@ const int InvItemHeight[180] = { void InitCursor() { /// ASSERT: assert(! pCursCels); - pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", 0); + pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", NULL); ClearCursor(); } diff --git a/Source/cursor.h b/Source/cursor.h index 10ca56a85f2..64a3369212b 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -2,22 +2,22 @@ #ifndef __CURSOR_H__ #define __CURSOR_H__ -extern int cursH; // weak -extern int icursH28; // idb -extern int cursW; // idb -extern int pcursmonst; // idb -extern int icursW28; // idb +extern int cursH; +extern int icursH28; +extern int cursW; +extern int pcursmonst; +extern int icursW28; extern void *pCursCels; -extern int icursH; // weak -extern char pcursinvitem; // weak -extern int icursW; // weak -extern char pcursitem; // weak -extern char pcursobj; // weak -extern char pcursplr; // weak +extern int icursH; +extern char pcursinvitem; +extern int icursW; +extern char pcursitem; +extern char pcursobj; +extern char pcursplr; extern int cursmx; extern int cursmy; -extern int pcurstemp; // weak -extern int pcurs; // idb +extern int pcurstemp; +extern int pcurs; void InitCursor(); void FreeCursor(); diff --git a/Source/debug.cpp b/Source/debug.cpp index 05000ed100f..af4e40b90c9 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -17,7 +17,7 @@ char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; void LoadDebugGFX() { if (visiondebug) - pSquareCel = LoadFileInMem("Data\\Square.CEL", 0); + pSquareCel = LoadFileInMem("Data\\Square.CEL", NULL); } void FreeDebugGFX() diff --git a/Source/diablo.cpp b/Source/diablo.cpp index ffd284eb0ef..feb5644b8f8 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -11,7 +11,7 @@ int gnLevelTypeTbl[NUMLEVELS]; int MouseY; // idb int MouseX; // idb BOOL gbGameLoopStartup; // idb -int glSeedTbl[NUMLEVELS]; +DWORD glSeedTbl[NUMLEVELS]; BOOL gbRunGame; int glMid3Seed[NUMLEVELS]; BOOL gbRunGameResult; @@ -1537,34 +1537,34 @@ void LoadLvlGFX() switch ((unsigned char)leveltype) { case DTYPE_TOWN: - pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\TownData\\Town.MIN", 0); - pSpecialCels = LoadFileInMem("Levels\\TownData\\TownS.CEL", 0); + pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", NULL); + pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", NULL); + pLevelPieces = LoadFileInMem("Levels\\TownData\\Town.MIN", NULL); + pSpecialCels = LoadFileInMem("Levels\\TownData\\TownS.CEL", NULL); break; case DTYPE_CATHEDRAL: - pDungeonCels = LoadFileInMem("Levels\\L1Data\\L1.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L1Data\\L1.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L1Data\\L1.MIN", 0); - pSpecialCels = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); + pDungeonCels = LoadFileInMem("Levels\\L1Data\\L1.CEL", NULL); + pMegaTiles = LoadFileInMem("Levels\\L1Data\\L1.TIL", NULL); + pLevelPieces = LoadFileInMem("Levels\\L1Data\\L1.MIN", NULL); + pSpecialCels = LoadFileInMem("Levels\\L1Data\\L1S.CEL", NULL); break; case DTYPE_CATACOMBS: - pDungeonCels = LoadFileInMem("Levels\\L2Data\\L2.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L2Data\\L2.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L2Data\\L2.MIN", 0); - pSpecialCels = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); + pDungeonCels = LoadFileInMem("Levels\\L2Data\\L2.CEL", NULL); + pMegaTiles = LoadFileInMem("Levels\\L2Data\\L2.TIL", NULL); + pLevelPieces = LoadFileInMem("Levels\\L2Data\\L2.MIN", NULL); + pSpecialCels = LoadFileInMem("Levels\\L2Data\\L2S.CEL", NULL); break; case DTYPE_CAVES: - pDungeonCels = LoadFileInMem("Levels\\L3Data\\L3.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L3Data\\L3.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L3Data\\L3.MIN", 0); - pSpecialCels = LoadFileInMem("Levels\\L1Data\\L1S.CEL", 0); + pDungeonCels = LoadFileInMem("Levels\\L3Data\\L3.CEL", NULL); + pMegaTiles = LoadFileInMem("Levels\\L3Data\\L3.TIL", NULL); + pLevelPieces = LoadFileInMem("Levels\\L3Data\\L3.MIN", NULL); + pSpecialCels = LoadFileInMem("Levels\\L1Data\\L1S.CEL", NULL); break; case DTYPE_HELL: - pDungeonCels = LoadFileInMem("Levels\\L4Data\\L4.CEL", 0); - pMegaTiles = LoadFileInMem("Levels\\L4Data\\L4.TIL", 0); - pLevelPieces = LoadFileInMem("Levels\\L4Data\\L4.MIN", 0); - pSpecialCels = LoadFileInMem("Levels\\L2Data\\L2S.CEL", 0); + pDungeonCels = LoadFileInMem("Levels\\L4Data\\L4.CEL", NULL); + pMegaTiles = LoadFileInMem("Levels\\L4Data\\L4.TIL", NULL); + pLevelPieces = LoadFileInMem("Levels\\L4Data\\L4.MIN", NULL); + pSpecialCels = LoadFileInMem("Levels\\L2Data\\L2S.CEL", NULL); break; default: app_fatal("LoadLvlGFX"); diff --git a/Source/diablo.h b/Source/diablo.h index c26a50511e9..f80160d0393 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -90,7 +90,7 @@ extern int gnLevelTypeTbl[NUMLEVELS]; extern int MouseY; // idb extern int MouseX; // idb extern BOOL gbGameLoopStartup; // idb -extern int glSeedTbl[NUMLEVELS]; +extern DWORD glSeedTbl[NUMLEVELS]; extern BOOL gbRunGame; extern int glMid3Seed[NUMLEVELS]; extern BOOL gbRunGameResult; @@ -151,8 +151,6 @@ void diablo_color_cyc_logic(); /* data */ -extern int diablo_inf; // weak - /* rdata */ extern BOOL fullscreen; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 89cbaf8c4d2..3e839d94107 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -140,7 +140,7 @@ void LoadL1Dungeon(char *sFileName, int vx, int vy) dmaxy = 96; DRLG_InitTrans(); - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { @@ -335,7 +335,7 @@ void LoadPreL1Dungeon(char *sFileName, int vx, int vy) dmaxx = 96; dmaxy = 96; - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { @@ -373,7 +373,7 @@ void LoadPreL1Dungeon(char *sFileName, int vx, int vy) mem_free_dbg(pLevelMap); } -void CreateL5Dungeon(int rseed, int entry) +void CreateL5Dungeon(DWORD rseed, int entry) { SetRndSeed(rseed); @@ -396,15 +396,15 @@ void DRLG_LoadL1SP() { setloadflag = FALSE; if (QuestStatus(QTYPE_BUTCH)) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", 0); + pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", NULL); setloadflag = TRUE; } if (QuestStatus(QTYPE_KING) && gbMaxPlayers == 1) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", 0); + pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", NULL); setloadflag = TRUE; } if (QuestStatus(QTYPE_BOL)) { - pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", 0); + pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", NULL); setloadflag = TRUE; } } diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index 38e572e9aa3..ae9f38a6181 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -3,7 +3,7 @@ #define __DRLG_L1_H__ extern char L5dungeon[80][80]; -extern BYTE L5dflags[40][40]; +extern BYTE L5dflags[DMAXX][DMAXY]; extern BOOL setloadflag; extern int HR1; extern int HR2; @@ -19,7 +19,7 @@ void DRLG_L1Floor(); void DRLG_L1Pass3(); void DRLG_InitL1Vals(); void LoadPreL1Dungeon(char *sFileName, int vx, int vy); -void CreateL5Dungeon(int rseed, int entry); +void CreateL5Dungeon(DWORD rseed, int entry); void DRLG_LoadL1SP(); void DRLG_FreeL1SP(); void DRLG_L5(int entry); diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index e3f9621d812..a4cd386ef3c 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -3,134 +3,134 @@ DEVILUTION_BEGIN_NAMESPACE int nSx1; -int nSx2; // weak +int nSx2; int nSy1; -int nSy2; // weak +int nSy2; int nRoomCnt; -unsigned char predungeon[40][40]; +BYTE predungeon[DMAXX][DMAXY]; ROOMNODE RoomList[81]; HALLNODE *pHallList; -int Area_Min = 2; // weak -int Room_Max = 10; // weak -int Room_Min = 4; // weak +int Area_Min = 2; +int Room_Max = 10; +int Room_Min = 4; int Dir_Xadd[5] = { 0, 0, 1, 0, -1 }; int Dir_Yadd[5] = { 0, -1, 0, 1, 0 }; ShadowStruct SPATSL2[2] = { { 6u, 3u, 0u, 3u, 48u, 0u, 50u }, { 9u, 3u, 0u, 3u, 48u, 0u, 50u } }; //short word_48489A = 0; // weak -unsigned char BTYPESL2[161] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 17, 18, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char BSTYPESL2[161] = { 0, 1, 2, 3, 0, 0, 6, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 6, 6, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 6, 2, 2, 2, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 3, 3, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char VARCH1[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH2[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH3[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH4[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH5[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH6[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH7[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH8[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH9[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 7, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH10[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 8, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH11[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 6, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH12[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 9, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH13[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 14, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH14[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 13, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH15[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 16, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH16[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 15, 48, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH17[] = { 2, 3, 2, 7, 3, 4, 0, 7, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH18[] = { 2, 3, 2, 7, 3, 4, 0, 8, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH19[] = { 2, 3, 2, 7, 3, 4, 0, 6, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH20[] = { 2, 3, 2, 7, 3, 4, 0, 9, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH21[] = { 2, 3, 2, 7, 3, 4, 0, 14, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH22[] = { 2, 3, 2, 7, 3, 4, 0, 13, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH23[] = { 2, 3, 2, 7, 3, 4, 0, 16, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH24[] = { 2, 3, 2, 7, 3, 4, 0, 15, 141, 39, 47, 44, 0, 0 }; -unsigned char VARCH25[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH26[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH27[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH28[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH29[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH30[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH31[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH32[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 }; -unsigned char VARCH33[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 7, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH34[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 8, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH35[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 6, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH36[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 9, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH37[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 14, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH38[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 13, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH39[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 16, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char VARCH40[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 15, 142, 0, 51, 42, 47, 44, 0, 0 }; -unsigned char HARCH1[] = { 3, 2, 3, 3, 0, 2, 5, 9, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH2[] = { 3, 2, 3, 3, 0, 2, 5, 6, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH3[] = { 3, 2, 3, 3, 0, 2, 5, 8, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH4[] = { 3, 2, 3, 3, 0, 2, 5, 7, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH5[] = { 3, 2, 3, 3, 0, 2, 5, 15, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH6[] = { 3, 2, 3, 3, 0, 2, 5, 16, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH7[] = { 3, 2, 3, 3, 0, 2, 5, 13, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH8[] = { 3, 2, 3, 3, 0, 2, 5, 14, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH9[] = { 3, 2, 3, 3, 0, 8, 5, 9, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH10[] = { 3, 2, 3, 3, 0, 8, 5, 6, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH11[] = { 3, 2, 3, 3, 0, 8, 5, 8, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH12[] = { 3, 2, 3, 3, 0, 8, 5, 7, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH13[] = { 3, 2, 3, 3, 0, 8, 5, 15, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH14[] = { 3, 2, 3, 3, 0, 8, 5, 16, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH15[] = { 3, 2, 3, 3, 0, 8, 5, 13, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH16[] = { 3, 2, 3, 3, 0, 8, 5, 14, 49, 46, 0, 43, 45, 0 }; -unsigned char HARCH17[] = { 3, 2, 1, 3, 0, 8, 5, 9, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH18[] = { 3, 2, 1, 3, 0, 8, 5, 6, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH19[] = { 3, 2, 1, 3, 0, 8, 5, 8, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH20[] = { 3, 2, 1, 3, 0, 8, 5, 7, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH21[] = { 3, 2, 1, 3, 0, 8, 5, 15, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH22[] = { 3, 2, 1, 3, 0, 8, 5, 16, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH23[] = { 3, 2, 1, 3, 0, 8, 5, 13, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH24[] = { 3, 2, 1, 3, 0, 8, 5, 14, 140, 46, 0, 43, 45, 0 }; -unsigned char HARCH25[] = { 3, 2, 3, 3, 0, 5, 2, 9, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH26[] = { 3, 2, 3, 3, 0, 5, 2, 6, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH27[] = { 3, 2, 3, 3, 0, 5, 2, 8, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH28[] = { 3, 2, 3, 3, 0, 5, 2, 7, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH29[] = { 3, 2, 3, 3, 0, 5, 2, 15, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH30[] = { 3, 2, 3, 3, 0, 5, 2, 16, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH31[] = { 3, 2, 3, 3, 0, 5, 2, 13, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH32[] = { 3, 2, 3, 3, 0, 5, 2, 14, 49, 46, 0, 40, 45, 0 }; -unsigned char HARCH33[] = { 3, 2, 1, 3, 0, 9, 5, 9, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH34[] = { 3, 2, 1, 3, 0, 9, 5, 6, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH35[] = { 3, 2, 1, 3, 0, 9, 5, 8, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH36[] = { 3, 2, 1, 3, 0, 9, 5, 7, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH37[] = { 3, 2, 1, 3, 0, 9, 5, 15, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH38[] = { 3, 2, 1, 3, 0, 9, 5, 16, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH39[] = { 3, 2, 1, 3, 0, 9, 5, 13, 140, 46, 0, 40, 45, 0 }; -unsigned char HARCH40[] = { 3, 2, 1, 3, 0, 9, 5, 14, 140, 46, 0, 40, 45, 0 }; -unsigned char USTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 72, 77, 0, 0, 76, 0, 0, 0, 0, 0, 0 }; -unsigned char DSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 48, 71, 0, 0, 50, 78, 0, 0, 0, 0, 0 }; -unsigned char WARPSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 158, 160, 0, 0, 159, 0, 0, 0, 0, 0, 0 }; -unsigned char CRUSHCOL[] = { 3, 3, 3, 1, 3, 2, 6, 3, 3, 3, 3, 0, 0, 0, 0, 83, 0, 0, 0, 0 }; -unsigned char BIG1[] = { 2, 2, 3, 3, 3, 3, 113, 0, 112, 0 }; -unsigned char BIG2[] = { 2, 2, 3, 3, 3, 3, 114, 115, 0, 0 }; -unsigned char BIG3[] = { 1, 2, 1, 1, 117, 116 }; -unsigned char BIG4[] = { 2, 1, 2, 2, 118, 119 }; -unsigned char BIG5[] = { 2, 2, 3, 3, 3, 3, 120, 122, 121, 123 }; -unsigned char BIG6[] = { 1, 2, 1, 1, 125, 124 }; -unsigned char BIG7[] = { 2, 1, 2, 2, 126, 127 }; -unsigned char BIG8[] = { 2, 2, 3, 3, 3, 3, 128, 130, 129, 131 }; -unsigned char BIG9[] = { 2, 2, 1, 3, 1, 3, 133, 135, 132, 134 }; -unsigned char BIG10[] = { 2, 2, 2, 2, 3, 3, 136, 137, 3, 3 }; -unsigned char RUINS1[] = { 1, 1, 1, 80 }; -unsigned char RUINS2[] = { 1, 1, 1, 81 }; -unsigned char RUINS3[] = { 1, 1, 1, 82 }; -unsigned char RUINS4[] = { 1, 1, 2, 84 }; -unsigned char RUINS5[] = { 1, 1, 2, 85 }; -unsigned char RUINS6[] = { 1, 1, 2, 86 }; -unsigned char RUINS7[] = { 1, 1, 8, 87 }; -unsigned char PANCREAS1[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char PANCREAS2[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0 }; -unsigned char CTRDOOR1[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 9, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR2[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 8, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR3[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 6, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR4[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 7, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR5[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 15, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR6[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 13, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR7[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 16, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; -unsigned char CTRDOOR8[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 14, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE BTYPESL2[161] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 17, 18, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +BYTE BSTYPESL2[161] = { 0, 1, 2, 3, 0, 0, 6, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 6, 6, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 6, 2, 2, 2, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 3, 3, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +BYTE VARCH1[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH2[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH3[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH4[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH5[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH6[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH7[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH8[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH9[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 7, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH10[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 8, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH11[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 6, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH12[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 9, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH13[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 14, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH14[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 13, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH15[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 16, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH16[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 15, 48, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH17[] = { 2, 3, 2, 7, 3, 4, 0, 7, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH18[] = { 2, 3, 2, 7, 3, 4, 0, 8, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH19[] = { 2, 3, 2, 7, 3, 4, 0, 6, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH20[] = { 2, 3, 2, 7, 3, 4, 0, 9, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH21[] = { 2, 3, 2, 7, 3, 4, 0, 14, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH22[] = { 2, 3, 2, 7, 3, 4, 0, 13, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH23[] = { 2, 3, 2, 7, 3, 4, 0, 16, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH24[] = { 2, 3, 2, 7, 3, 4, 0, 15, 141, 39, 47, 44, 0, 0 }; +BYTE VARCH25[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH26[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH27[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH28[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH29[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH30[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH31[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH32[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 }; +BYTE VARCH33[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 7, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH34[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 8, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH35[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 6, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH36[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 9, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH37[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 14, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH38[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 13, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH39[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 16, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE VARCH40[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 15, 142, 0, 51, 42, 47, 44, 0, 0 }; +BYTE HARCH1[] = { 3, 2, 3, 3, 0, 2, 5, 9, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH2[] = { 3, 2, 3, 3, 0, 2, 5, 6, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH3[] = { 3, 2, 3, 3, 0, 2, 5, 8, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH4[] = { 3, 2, 3, 3, 0, 2, 5, 7, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH5[] = { 3, 2, 3, 3, 0, 2, 5, 15, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH6[] = { 3, 2, 3, 3, 0, 2, 5, 16, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH7[] = { 3, 2, 3, 3, 0, 2, 5, 13, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH8[] = { 3, 2, 3, 3, 0, 2, 5, 14, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH9[] = { 3, 2, 3, 3, 0, 8, 5, 9, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH10[] = { 3, 2, 3, 3, 0, 8, 5, 6, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH11[] = { 3, 2, 3, 3, 0, 8, 5, 8, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH12[] = { 3, 2, 3, 3, 0, 8, 5, 7, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH13[] = { 3, 2, 3, 3, 0, 8, 5, 15, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH14[] = { 3, 2, 3, 3, 0, 8, 5, 16, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH15[] = { 3, 2, 3, 3, 0, 8, 5, 13, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH16[] = { 3, 2, 3, 3, 0, 8, 5, 14, 49, 46, 0, 43, 45, 0 }; +BYTE HARCH17[] = { 3, 2, 1, 3, 0, 8, 5, 9, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH18[] = { 3, 2, 1, 3, 0, 8, 5, 6, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH19[] = { 3, 2, 1, 3, 0, 8, 5, 8, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH20[] = { 3, 2, 1, 3, 0, 8, 5, 7, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH21[] = { 3, 2, 1, 3, 0, 8, 5, 15, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH22[] = { 3, 2, 1, 3, 0, 8, 5, 16, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH23[] = { 3, 2, 1, 3, 0, 8, 5, 13, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH24[] = { 3, 2, 1, 3, 0, 8, 5, 14, 140, 46, 0, 43, 45, 0 }; +BYTE HARCH25[] = { 3, 2, 3, 3, 0, 5, 2, 9, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH26[] = { 3, 2, 3, 3, 0, 5, 2, 6, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH27[] = { 3, 2, 3, 3, 0, 5, 2, 8, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH28[] = { 3, 2, 3, 3, 0, 5, 2, 7, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH29[] = { 3, 2, 3, 3, 0, 5, 2, 15, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH30[] = { 3, 2, 3, 3, 0, 5, 2, 16, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH31[] = { 3, 2, 3, 3, 0, 5, 2, 13, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH32[] = { 3, 2, 3, 3, 0, 5, 2, 14, 49, 46, 0, 40, 45, 0 }; +BYTE HARCH33[] = { 3, 2, 1, 3, 0, 9, 5, 9, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH34[] = { 3, 2, 1, 3, 0, 9, 5, 6, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH35[] = { 3, 2, 1, 3, 0, 9, 5, 8, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH36[] = { 3, 2, 1, 3, 0, 9, 5, 7, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH37[] = { 3, 2, 1, 3, 0, 9, 5, 15, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH38[] = { 3, 2, 1, 3, 0, 9, 5, 16, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH39[] = { 3, 2, 1, 3, 0, 9, 5, 13, 140, 46, 0, 40, 45, 0 }; +BYTE HARCH40[] = { 3, 2, 1, 3, 0, 9, 5, 14, 140, 46, 0, 40, 45, 0 }; +BYTE USTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 72, 77, 0, 0, 76, 0, 0, 0, 0, 0, 0 }; +BYTE DSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 48, 71, 0, 0, 50, 78, 0, 0, 0, 0, 0 }; +BYTE WARPSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 158, 160, 0, 0, 159, 0, 0, 0, 0, 0, 0 }; +BYTE CRUSHCOL[] = { 3, 3, 3, 1, 3, 2, 6, 3, 3, 3, 3, 0, 0, 0, 0, 83, 0, 0, 0, 0 }; +BYTE BIG1[] = { 2, 2, 3, 3, 3, 3, 113, 0, 112, 0 }; +BYTE BIG2[] = { 2, 2, 3, 3, 3, 3, 114, 115, 0, 0 }; +BYTE BIG3[] = { 1, 2, 1, 1, 117, 116 }; +BYTE BIG4[] = { 2, 1, 2, 2, 118, 119 }; +BYTE BIG5[] = { 2, 2, 3, 3, 3, 3, 120, 122, 121, 123 }; +BYTE BIG6[] = { 1, 2, 1, 1, 125, 124 }; +BYTE BIG7[] = { 2, 1, 2, 2, 126, 127 }; +BYTE BIG8[] = { 2, 2, 3, 3, 3, 3, 128, 130, 129, 131 }; +BYTE BIG9[] = { 2, 2, 1, 3, 1, 3, 133, 135, 132, 134 }; +BYTE BIG10[] = { 2, 2, 2, 2, 3, 3, 136, 137, 3, 3 }; +BYTE RUINS1[] = { 1, 1, 1, 80 }; +BYTE RUINS2[] = { 1, 1, 1, 81 }; +BYTE RUINS3[] = { 1, 1, 1, 82 }; +BYTE RUINS4[] = { 1, 1, 2, 84 }; +BYTE RUINS5[] = { 1, 1, 2, 85 }; +BYTE RUINS6[] = { 1, 1, 2, 86 }; +BYTE RUINS7[] = { 1, 1, 8, 87 }; +BYTE PANCREAS1[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0 }; +BYTE PANCREAS2[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0 }; +BYTE CTRDOOR1[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 9, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR2[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 8, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR3[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 6, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR4[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 7, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR5[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 15, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR6[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 13, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR7[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 16, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; +BYTE CTRDOOR8[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 14, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 }; int Patterns[100][10] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 }, { 0, 0, 0, 0, 2, 0, 0, 0, 0, 3 }, @@ -238,8 +238,8 @@ void InitDungeon() { int i, j; - for(j = 0; j < DMAXY; j++) { - for(i = 0; i < DMAXX; i++) { + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { predungeon[i][j] = 32; dflags[i][j] = 0; } @@ -251,61 +251,61 @@ void L2LockoutFix() int i, j; BOOL doorok; - for(j = 0; j < DMAXY; j++) { - for(i = 0; i < DMAXX; i++) { - if(dungeon[i][j] == 4 && dungeon[i - 1][j] != 3) { + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { + if (dungeon[i][j] == 4 && dungeon[i - 1][j] != 3) { dungeon[i][j] = 1; } - if(dungeon[i][j] == 5 && dungeon[i][j - 1] != 3) { + if (dungeon[i][j] == 5 && dungeon[i][j - 1] != 3) { dungeon[i][j] = 2; } } } - for(j = 1; j < DMAXY - 1; j++) { - for(i = 1; i < DMAXX - 1; i++) { - if(dflags[i][j] & 0x80) { + for (j = 1; j < DMAXY - 1; j++) { + for (i = 1; i < DMAXX - 1; i++) { + if (dflags[i][j] & 0x80) { continue; } - if((dungeon[i][j] == 2 || dungeon[i][j] == 5) && dungeon[i][j - 1] == 3 && dungeon[i][j + 1] == 3) { + if ((dungeon[i][j] == 2 || dungeon[i][j] == 5) && dungeon[i][j - 1] == 3 && dungeon[i][j + 1] == 3) { doorok = FALSE; - while(1) { - if(dungeon[i][j] != 2 && dungeon[i][j] != 5) { + while (1) { + if (dungeon[i][j] != 2 && dungeon[i][j] != 5) { break; } - if(dungeon[i][j - 1] != 3 || dungeon[i][j + 1] != 3) { + if (dungeon[i][j - 1] != 3 || dungeon[i][j + 1] != 3) { break; } - if(dungeon[i][j] == 5) { + if (dungeon[i][j] == 5) { doorok = TRUE; } i++; } - if(!doorok && !(dflags[i - 1][j] & 0x80)) { + if (!doorok && !(dflags[i - 1][j] & 0x80)) { dungeon[i - 1][j] = 5; } } } } - for(j = 1; j < DMAXX - 1; j++) { /* check: might be flipped */ - for(i = 1; i < DMAXY - 1; i++) { - if(dflags[j][i] & 0x80) { + for (j = 1; j < DMAXX - 1; j++) { /* check: might be flipped */ + for (i = 1; i < DMAXY - 1; i++) { + if (dflags[j][i] & 0x80) { continue; } - if((dungeon[j][i] == 1 || dungeon[j][i] == 4) && dungeon[j - 1][i] == 3 && dungeon[j + 1][i] == 3) { + if ((dungeon[j][i] == 1 || dungeon[j][i] == 4) && dungeon[j - 1][i] == 3 && dungeon[j + 1][i] == 3) { doorok = FALSE; - while(1) { - if(dungeon[j][i] != 1 && dungeon[j][i] != 4) { + while (1) { + if (dungeon[j][i] != 1 && dungeon[j][i] != 4) { break; } - if(dungeon[j - 1][i] != 3 || dungeon[j + 1][i] != 3) { + if (dungeon[j - 1][i] != 3 || dungeon[j + 1][i] != 3) { break; } - if(dungeon[j][i] == 4) { + if (dungeon[j][i] == 4) { doorok = TRUE; } i++; } - if(!doorok && !(dflags[j][i - 1] & 0x80)) { + if (!doorok && !(dflags[j][i - 1] & 0x80)) { dungeon[j][i - 1] = 4; } } @@ -317,12 +317,12 @@ void L2DoorFix() { int i, j; - for(j = 1; j < 40; j++) { - for(i = 1; i < 40; i++) { - if(dungeon[i][j] == 4 && dungeon[i][j - 1] == 3) { + for (j = 1; j < 40; j++) { + for (i = 1; i < 40; i++) { + if (dungeon[i][j] == 4 && dungeon[i][j - 1] == 3) { dungeon[i][j] = 7; } - if(dungeon[i][j] == 5 && dungeon[i - 1][j] == 3) { + if (dungeon[i][j] == 5 && dungeon[i - 1][j] == 3) { dungeon[i][j] = 9; } } @@ -336,7 +336,7 @@ void LoadL2Dungeon(char *sFileName, int vx, int vy) InitDungeon(); DRLG_InitTrans(); - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { @@ -511,7 +511,7 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) InitDungeon(); DRLG_InitTrans(); - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { @@ -553,16 +553,16 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) mem_free_dbg(pLevelMap); } -void CreateL2Dungeon(unsigned int rseed, int entry) +void CreateL2Dungeon(DWORD rseed, int entry) { - if(gbMaxPlayers == 1) { - if(currlevel == 7 && !quests[8]._qactive) { + if (gbMaxPlayers == 1) { + if (currlevel == 7 && !quests[8]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 7; } - if(currlevel == 8) { - if(!quests[8]._qactive) { + if (currlevel == 8) { + if (!quests[8]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 8; @@ -570,7 +570,6 @@ void CreateL2Dungeon(unsigned int rseed, int entry) currlevel = 7; CreateL2Dungeon(glSeedTbl[7], 4); currlevel = 8; - } } } @@ -591,28 +590,22 @@ void CreateL2Dungeon(unsigned int rseed, int entry) DRLG_InitL2Vals(); DRLG_SetPC(); } -// 5CF328: using guessed type int dmaxx; -// 5CF32C: using guessed type int dmaxy; -// 5D2458: using guessed type int dminx; -// 5D245C: using guessed type int dminy; -// 679660: using guessed type char gbMaxPlayers; void DRLG_LoadL2SP() { setloadflag_2 = 0; - if(QuestStatus(QTYPE_BLIND)) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + if (QuestStatus(QTYPE_BLIND)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); setloadflag_2 = 1; - } else if(QuestStatus(QTYPE_BLOOD)) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blood1.DUN", 0); + } else if (QuestStatus(QTYPE_BLOOD)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blood1.DUN", NULL); setloadflag_2 = 1; - } else if(QuestStatus(QTYPE_BONE)) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", 0); + } else if (QuestStatus(QTYPE_BONE)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", NULL); setloadflag_2 = 1; } } -// 5B50D8: using guessed type int setloadflag_2; void DRLG_FreeL2SP() { @@ -625,42 +618,42 @@ void DRLG_L2(int entry) BOOL doneflag; doneflag = FALSE; - while(!doneflag) { + while (!doneflag) { nRoomCnt = 0; InitDungeon(); DRLG_InitTrans(); - if(!CreateDungeon()) { + if (!CreateDungeon()) { continue; } L2TileFix(); - if(setloadflag_2) { + if (setloadflag_2) { DRLG_L2SetRoom(nSx1, nSy1); } DRLG_L2FloodTVal(); DRLG_L2TransFix(); - if(entry == 0) { + if (entry == 0) { doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 1, 0); - if(doneflag) { + if (doneflag) { doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1); - if(doneflag && currlevel == 5) { + if (doneflag && currlevel == 5) { doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6); } } ViewY -= 2; - } else if(entry == 1) { + } else if (entry == 1) { doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 0, 0); - if(doneflag) { + if (doneflag) { doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 1, 1); - if(doneflag && currlevel == 5) { + if (doneflag && currlevel == 5) { doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6); } } ViewX--; } else { doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 0, 0); - if(doneflag) { + if (doneflag) { doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1); - if(doneflag && currlevel == 5) { + if (doneflag && currlevel == 5) { doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 1, 6); } } @@ -784,8 +777,8 @@ void DRLG_L2(int entry) DRLG_L2Subs(); DRLG_L2Shadows(); - for(j = 0; j < 40; j++) { - for(i = 0; i < 40; i++) { + for (j = 0; j < 40; j++) { + for (i = 0; i < 40; i++) { pdungeon[i][j] = dungeon[i][j]; } } @@ -793,9 +786,8 @@ void DRLG_L2(int entry) DRLG_Init_Globals(); DRLG_CheckQuests(nSx1, nSy1); } -// 5B50D8: using guessed type int setloadflag_2; -BOOL DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir) +BOOL DRLG_L2PlaceMiniSet(BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir) { int sx, sy, sw, sh, xx, yy, i, ii, numt, bailcnt; BOOL found; @@ -803,61 +795,61 @@ BOOL DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int sw = miniset[0]; sh = miniset[1]; - if(tmax - tmin == 0) { + if (tmax - tmin == 0) { numt = 1; } else { numt = random(0, tmax - tmin) + tmin; } - for(i = 0; i < numt; i++) { + for (i = 0; i < numt; i++) { sx = random(0, 40 - sw); sy = random(0, 40 - sh); found = FALSE; - for(bailcnt = 0; !found && bailcnt < 200; bailcnt++) { + for (bailcnt = 0; !found && bailcnt < 200; bailcnt++) { found = TRUE; - if(sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { + if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { found = FALSE; } - if(cx != -1 && sx >= cx - sw && sx <= cx + 12) { + if (cx != -1 && sx >= cx - sw && sx <= cx + 12) { sx = random(0, 40 - sw); sy = random(0, 40 - sh); found = FALSE; } - if(cy != -1 && sy >= cy - sh && sy <= cy + 12) { + if (cy != -1 && sy >= cy - sh && sy <= cy + 12) { sx = random(0, 40 - sw); sy = random(0, 40 - sh); found = FALSE; } ii = 2; - for(yy = 0; yy < sh && found == TRUE; yy++) { - for(xx = 0; xx < sw && found == TRUE; xx++) { - if(miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) { + for (yy = 0; yy < sh && found == TRUE; yy++) { + for (xx = 0; xx < sw && found == TRUE; xx++) { + if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) { found = FALSE; } - if(dflags[xx + sx][yy + sy] != 0) { + if (dflags[xx + sx][yy + sy] != 0) { found = FALSE; } ii++; } } - if(!found) { + if (!found) { sx++; - if(sx == 40 - sw) { + if (sx == 40 - sw) { sx = 0; sy++; - if(sy == 40 - sh) { + if (sy == 40 - sh) { sy = 0; } } } } - if(bailcnt >= 200) { + if (bailcnt >= 200) { return FALSE; } ii = sw * sh + 2; - for(yy = 0; yy < sh; yy++) { - for(xx = 0; xx < sw; xx++) { - if(miniset[ii] != 0) { + for (yy = 0; yy < sh; yy++) { + for (xx = 0; xx < sw; xx++) { + if (miniset[ii] != 0) { dungeon[xx + sx][yy + sy] = miniset[ii]; } ii++; @@ -865,27 +857,23 @@ BOOL DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int } } - if(setview == TRUE) { + if (setview == TRUE) { ViewX = 2 * sx + 21; ViewY = 2 * sy + 22; } - if(ldir == 0) { + if (ldir == 0) { LvlViewX = 2 * sx + 21; LvlViewY = 2 * sy + 22; } - if(ldir == 6) { + if (ldir == 6) { LvlViewX = 2 * sx + 21; LvlViewY = 2 * sy + 22; } return TRUE; } -// 5276CC: using guessed type int nSx2; -// 5276D4: using guessed type int nSy2; -// 5CF320: using guessed type int LvlViewY; -// 5CF324: using guessed type int LvlViewX; -void DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper) +void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper) { int sx, sy, sw, sh, xx, yy, ii, kk; BOOL found; @@ -893,38 +881,39 @@ void DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper) sw = miniset[0]; sh = miniset[1]; - for(sy = 0; sy < 40 - sh; sy++) { - for(sx = 0; sx < 40 - sw; sx++) { + for (sy = 0; sy < DMAXY - sh; sy++) { + for (sx = 0; sx < DMAXX - sw; sx++) { found = TRUE; ii = 2; - if(sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { + if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) { found = FALSE; } - for(yy = 0; yy < sh && found == TRUE; yy++) { - for(xx = 0; xx < sw && found == TRUE; xx++) { - if(miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) { + for (yy = 0; yy < sh && found == TRUE; yy++) { + for (xx = 0; xx < sw && found == TRUE; xx++) { + if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) { found = FALSE; } - if(dflags[xx + sx][yy + sy] != 0) { + if (dflags[xx + sx][yy + sy] != 0) { found = FALSE; } ii++; } } kk = sw * sh + 2; - if(found == TRUE) { - for(yy = sy - sh; yy < sy + 2 * sh && found == TRUE; yy++) { - for(xx = sx - sw; xx < sx + 2 * sw; xx++) { - if(dungeon[xx][yy] == miniset[kk]) { + if (found == TRUE) { + for (yy = sy - sh; yy < sy + 2 * sh && found == TRUE; yy++) { + for (xx = sx - sw; xx < sx + 2 * sw; xx++) { + // BUGFIX: yy and xx can go out of bounds + if (dungeon[xx][yy] == miniset[kk]) { found = FALSE; } } } } - if(found == TRUE && random(0, 100) < rndper) { - for(yy = 0; yy < sh; yy++) { - for(xx = 0; xx < sw; xx++) { - if(miniset[kk] != 0) { + if (found == TRUE && random(0, 100) < rndper) { + for (yy = 0; yy < sh; yy++) { + for (xx = 0; xx < sw; xx++) { + if (miniset[kk] != 0) { dungeon[xx + sx][yy + sy] = miniset[kk]; } kk++; @@ -934,39 +923,37 @@ void DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper) } } } -// 5276CC: using guessed type int nSx2; -// 5276D4: using guessed type int nSy2; void DRLG_L2Subs() { int x, y, i, j, k, rv; - unsigned char c; + BYTE c; - for(y = 0; y < 40; y++) { - for(x = 0; x < 40; x++) { - if((x < nSx1 || x > nSx2) && (y < nSy1 || y > nSy2) && random(0, 4) == 0) { + for (y = 0; y < 40; y++) { + for (x = 0; x < 40; x++) { + if ((x < nSx1 || x > nSx2) && (y < nSy1 || y > nSy2) && random(0, 4) == 0) { c = BTYPESL2[dungeon[x][y]]; - if(c != 0) { + if (c != 0) { rv = random(0, 16); k = -1; - while(rv >= 0) { + while (rv >= 0) { k++; - if(k == sizeof(BTYPESL2)) { + if (k == sizeof(BTYPESL2)) { k = 0; } - if(c == BTYPESL2[k]) { + if (c == BTYPESL2[k]) { rv--; } } - for(j = y - 2; j < y + 2; j++) { - for(i = x - 2; i < x + 2; i++) { - if(dungeon[i][j] == k) { + for (j = y - 2; j < y + 2; j++) { + for (i = x - 2; i < x + 2; i++) { + if (dungeon[i][j] == k) { j = y + 3; i = x + 2; } } } - if(j < y + 3) { + if (j < y + 3) { dungeon[x][y] = k; } } @@ -974,41 +961,39 @@ void DRLG_L2Subs() } } } -// 5276CC: using guessed type int nSx2; -// 5276D4: using guessed type int nSy2; void DRLG_L2Shadows() { int x, y, i; BOOL patflag; - unsigned char sd[2][2]; + BYTE sd[2][2]; - for(y = 1; y < 40; y++) { - for(x = 1; x < 40; x++) { + for (y = 1; y < 40; y++) { + for (x = 1; x < 40; x++) { sd[0][0] = BSTYPESL2[dungeon[x][y]]; sd[1][0] = BSTYPESL2[dungeon[x - 1][y]]; sd[0][1] = BSTYPESL2[dungeon[x][y - 1]]; sd[1][1] = BSTYPESL2[dungeon[x - 1][y - 1]]; - for(i = 0; i < 2; i++) { - if(SPATSL2[i].strig == sd[0][0]) { + for (i = 0; i < 2; i++) { + if (SPATSL2[i].strig == sd[0][0]) { patflag = TRUE; - if(SPATSL2[i].s1 != 0 && SPATSL2[i].s1 != sd[1][1]) { + if (SPATSL2[i].s1 != 0 && SPATSL2[i].s1 != sd[1][1]) { patflag = FALSE; } - if(SPATSL2[i].s2 != 0 && SPATSL2[i].s2 != sd[0][1]) { + if (SPATSL2[i].s2 != 0 && SPATSL2[i].s2 != sd[0][1]) { patflag = FALSE; } - if(SPATSL2[i].s3 != 0 && SPATSL2[i].s3 != sd[1][0]) { + if (SPATSL2[i].s3 != 0 && SPATSL2[i].s3 != sd[1][0]) { patflag = FALSE; } - if(patflag == TRUE) { - if(SPATSL2[i].nv1 != 0) { + if (patflag == TRUE) { + if (SPATSL2[i].nv1 != 0) { dungeon[x - 1][y - 1] = SPATSL2[i].nv1; } - if(SPATSL2[i].nv2 != 0) { + if (SPATSL2[i].nv2 != 0) { dungeon[x][y - 1] = SPATSL2[i].nv2; } - if(SPATSL2[i].nv3 != 0) { + if (SPATSL2[i].nv3 != 0) { dungeon[x - 1][y] = SPATSL2[i].nv3; } } @@ -1017,26 +1002,25 @@ void DRLG_L2Shadows() } } } -// 48489A: using guessed type short word_48489A; void DRLG_L2SetRoom(int rx1, int ry1) { int rw, rh, i, j; - unsigned char *sp; + BYTE *sp; - rw = (unsigned char)pSetPiece_2[0]; - rh = (unsigned char)pSetPiece_2[2]; + rw = (BYTE)pSetPiece_2[0]; + rh = (BYTE)pSetPiece_2[2]; setpc_x = rx1; setpc_y = ry1; setpc_w = rw; setpc_h = rh; - sp = (unsigned char *)&pSetPiece_2[4]; + sp = (BYTE *)&pSetPiece_2[4]; - for(j = 0; j < rh; j++) { - for(i = 0; i < rw; i++) { - if(*sp != 0) { + for (j = 0; j < rh; j++) { + for (i = 0; i < rw; i++) { + if (*sp != 0) { dungeon[i + rx1][j + ry1] = *sp; dflags[i + rx1][j + ry1] |= 0x80; } else { @@ -1046,28 +1030,26 @@ void DRLG_L2SetRoom(int rx1, int ry1) } } } -// 5CF330: using guessed type int setpc_h; -// 5CF334: using guessed type int setpc_w; void L2TileFix() { int i, j; - for(j = 0; j < 40; j++) { - for(i = 0; i < 40; i++) { - if(dungeon[i][j] == 1 && dungeon[i][j + 1] == 3) { + for (j = 0; j < 40; j++) { + for (i = 0; i < 40; i++) { + if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 3) { dungeon[i][j + 1] = 1; } - if(dungeon[i][j] == 3 && dungeon[i][j + 1] == 1) { + if (dungeon[i][j] == 3 && dungeon[i][j + 1] == 1) { dungeon[i][j + 1] = 3; } - if(dungeon[i][j] == 3 && dungeon[i + 1][j] == 7) { + if (dungeon[i][j] == 3 && dungeon[i + 1][j] == 7) { dungeon[i + 1][j] = 3; } - if(dungeon[i][j] == 2 && dungeon[i + 1][j] == 3) { + if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 3) { dungeon[i + 1][j] = 2; } - if(dungeon[i][j] == 11 && dungeon[i + 1][j] == 14) { + if (dungeon[i][j] == 11 && dungeon[i + 1][j] == 14) { dungeon[i + 1][j] = 16; } } @@ -1083,23 +1065,23 @@ BOOL CreateDungeon() ForceH = 0; ForceHW = FALSE; - switch(currlevel) { + switch (currlevel) { case 5: - if(quests[QTYPE_BLOOD]._qactive) { + if (quests[QTYPE_BLOOD]._qactive) { ForceHW = TRUE; ForceH = 20; ForceW = 14; } break; case 6: - if(quests[QTYPE_BONE]._qactive) { + if (quests[QTYPE_BONE]._qactive) { ForceHW = TRUE; ForceW = 10; ForceH = 10; } break; case 7: - if(quests[QTYPE_BLIND]._qactive) { + if (quests[QTYPE_BLIND]._qactive) { ForceHW = TRUE; ForceW = 15; ForceH = 15; @@ -1111,61 +1093,61 @@ BOOL CreateDungeon() CreateRoom(2, 2, 39, 39, 0, 0, ForceHW, ForceH, ForceW); - while(pHallList != NULL) { + while (pHallList != NULL) { GetHall(&nHx1, &nHy1, &nHx2, &nHy2, &nHd); ConnectHall(nHx1, nHy1, nHx2, nHy2, nHd); } - for(j = 0; j <= DMAXY; j++) { /// BUGFIX: change '<=' to '<' - for(i = 0; i <= DMAXX; i++) { /// BUGFIX: change '<=' to '<' - if(predungeon[i][j] == 67) { + for (j = 0; j <= DMAXY; j++) { /// BUGFIX: change '<=' to '<' + for (i = 0; i <= DMAXX; i++) { /// BUGFIX: change '<=' to '<' + if (predungeon[i][j] == 67) { predungeon[i][j] = 35; } - if(predungeon[i][j] == 66) { + if (predungeon[i][j] == 66) { predungeon[i][j] = 35; } - if(predungeon[i][j] == 69) { + if (predungeon[i][j] == 69) { predungeon[i][j] = 35; } - if(predungeon[i][j] == 65) { + if (predungeon[i][j] == 65) { predungeon[i][j] = 35; } - if(predungeon[i][j] == 44) { + if (predungeon[i][j] == 44) { predungeon[i][j] = 46; - if(predungeon[i - 1][j - 1] == 32) { + if (predungeon[i - 1][j - 1] == 32) { predungeon[i - 1][j - 1] = 35; } - if(predungeon[i - 1][j] == 32) { + if (predungeon[i - 1][j] == 32) { predungeon[i - 1][j] = 35; } - if(predungeon[i - 1][1 + j] == 32) { + if (predungeon[i - 1][1 + j] == 32) { predungeon[i - 1][1 + j] = 35; } - if(predungeon[i + 1][j - 1] == 32) { + if (predungeon[i + 1][j - 1] == 32) { predungeon[i + 1][j - 1] = 35; } - if(predungeon[i + 1][j] == 32) { + if (predungeon[i + 1][j] == 32) { predungeon[i + 1][j] = 35; } - if(predungeon[i + 1][1 + j] == 32) { + if (predungeon[i + 1][1 + j] == 32) { predungeon[i + 1][1 + j] = 35; } - if(predungeon[i][j - 1] == 32) { + if (predungeon[i][j - 1] == 32) { predungeon[i][j - 1] = 35; } - if(predungeon[i][j + 1] == 32) { + if (predungeon[i][j + 1] == 32) { predungeon[i][j + 1] = 35; } } } } - if(!DL2_FillVoids()) { + if (!DL2_FillVoids()) { return FALSE; } - for(j = 0; j < DMAXY; j++) { - for(i = 0; i < DMAXX; i++) { + for (j = 0; j < DMAXY; j++) { + for (i = 0; i < DMAXX; i++) { DoPatternCheck(i, j); } } @@ -1177,32 +1159,32 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL { int nAw, nAh, nRw, nRh, nRx1, nRy1, nRx2, nRy2, nHw, nHh, nHx1, nHy1, nHx2, nHy2, nRid; - if(nRoomCnt >= 80) { + if (nRoomCnt >= 80) { return; } nAw = nX2 - nX1; nAh = nY2 - nY1; - if(nAw < Area_Min || nAh < Area_Min) { + if (nAw < Area_Min || nAh < Area_Min) { return; } - if(nAw > Room_Max) { + if (nAw > Room_Max) { nRw = random(0, Room_Max - Room_Min) + Room_Min; - } else if(nAw > Room_Min) { + } else if (nAw > Room_Min) { nRw = random(0, nAw - Room_Min) + Room_Min; } else { nRw = nAw; } - if(nAh > Room_Max) { + if (nAh > Room_Max) { nRh = random(0, Room_Max - Room_Min) + Room_Min; - } else if(nAh > Room_Min) { + } else if (nAh > Room_Min) { nRh = random(0, nAh - Room_Min) + Room_Min; } else { nRh = nAh; } - if(ForceHW == TRUE) { + if (ForceHW == TRUE) { nRw = nW; nRh = nH; } @@ -1211,42 +1193,42 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL nRy1 = random(0, nY2 - nY1) + nY1; nRx2 = nRw + nRx1; nRy2 = nRh + nRy1; - if(nRx2 > nX2) { + if (nRx2 > nX2) { nRx2 = nX2; nRx1 = nX2 - nRw; } - if(nRy2 > nY2) { + if (nRy2 > nY2) { nRy2 = nY2; nRy1 = nY2 - nRh; } - if(nRx1 >= 38) { + if (nRx1 >= 38) { nRx1 = 38; } - if(nRy1 >= 38) { + if (nRy1 >= 38) { nRy1 = 38; } - if(nRx1 <= 1) { + if (nRx1 <= 1) { nRx1 = 1; } - if(nRy1 <= 1) { + if (nRy1 <= 1) { nRy1 = 1; } - if(nRx2 >= 38) { + if (nRx2 >= 38) { nRx2 = 38; } - if(nRy2 >= 38) { + if (nRy2 >= 38) { nRy2 = 38; } - if(nRx2 <= 1) { + if (nRx2 <= 1) { nRx2 = 1; } - if(nRy2 <= 1) { + if (nRy2 <= 1) { nRy2 = 1; } DefineRoom(nRx1, nRy1, nRx2, nRy2, ForceHW); - if(ForceHW == TRUE) { + if (ForceHW == TRUE) { nSx1 = nRx1 + 2; nSy1 = nRy1 + 2; nSx2 = nRx2; @@ -1256,29 +1238,29 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL nRid = nRoomCnt; RoomList[nRid].nRoomDest = nRDest; - if(nRDest != 0) { - if(nHDir == 1) { + if (nRDest != 0) { + if (nHDir == 1) { nHx1 = random(0, nRx2 - nRx1 - 2) + nRx1 + 1; nHy1 = nRy1; nHw = RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2; nHx2 = random(0, nHw) + RoomList[nRDest].nRoomx1 + 1; nHy2 = RoomList[nRDest].nRoomy2; } - if(nHDir == 3) { + if (nHDir == 3) { nHx1 = random(0, nRx2 - nRx1 - 2) + nRx1 + 1; nHy1 = nRy2; nHw = RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2; nHx2 = random(0, nHw) + RoomList[nRDest].nRoomx1 + 1; nHy2 = RoomList[nRDest].nRoomy1; } - if(nHDir == 2) { + if (nHDir == 2) { nHx1 = nRx2; nHy1 = random(0, nRy2 - nRy1 - 2) + nRy1 + 1; nHx2 = RoomList[nRDest].nRoomx1; nHh = RoomList[nRDest].nRoomy2 - RoomList[nRDest].nRoomy1 - 2; nHy2 = random(0, nHh) + RoomList[nRDest].nRoomy1 + 1; } - if(nHDir == 4) { + if (nHDir == 4) { nHx1 = nRx1; nHy1 = random(0, nRy2 - nRy1 - 2) + nRy1 + 1; nHx2 = RoomList[nRDest].nRoomx2; @@ -1288,7 +1270,7 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL AddHall(nHx1, nHy1, nHx2, nHy2, nHDir); } - if(nRh > nRw) { + if (nRh > nRw) { CreateRoom(nX1 + 2, nY1 + 2, nRx1 - 2, nRy2 - 2, nRid, 2, 0, 0, 0); CreateRoom(nRx2 + 2, nRy1 + 2, nX2 - 2, nY2 - 2, nRid, 4, 0, 0, 0); CreateRoom(nX1 + 2, nRy2 + 2, nRx2 - 2, nY2 - 2, nRid, 1, 0, 0, 0); @@ -1300,11 +1282,6 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL CreateRoom(nRx2 + 2, nY1 + 2, nX2 - 2, nRy2 - 2, nRid, 4, 0, 0, 0); } } -// 484858: using guessed type int Area_Min; -// 48485C: using guessed type int Room_Max; -// 484860: using guessed type int Room_Min; -// 5276CC: using guessed type int nSx2; -// 5276D4: using guessed type int nSy2; void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW) { @@ -1321,23 +1298,23 @@ void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW) RoomList[nRoomCnt].nRoomy1 = nY1; RoomList[nRoomCnt].nRoomy2 = nY2; - if(ForceHW == TRUE) { - for(i = nX1; i < nX2; i++) { - while(i < nY2) { + if (ForceHW == TRUE) { + for (i = nX1; i < nX2; i++) { + while (i < nY2) { dflags[i][nY1] |= 0x80; i++; } } } - for(i = nX1 + 1; i <= nX2 - 1; i++) { + for (i = nX1 + 1; i <= nX2 - 1; i++) { predungeon[i][nY1] = 35; predungeon[i][nY2] = 35; } nY2--; - for(j = nY1 + 1; j <= nY2; j++) { + for (j = nY1 + 1; j <= nY2; j++) { predungeon[nX1][j] = 35; predungeon[nX2][j] = 35; - for(i = nX1 + 1; i < nX2; i++) { + for (i = nX1 + 1; i < nX2; i++) { predungeon[i][j] = 46; } } @@ -1347,7 +1324,7 @@ void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) { HALLNODE *p1, *p2; - if(pHallList == NULL) { + if (pHallList == NULL) { pHallList = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList)); pHallList->nHallx1 = nX1; pHallList->nHally1 = nY1; @@ -1364,7 +1341,7 @@ void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) p1->nHalldir = nHd; p1->pNext = NULL; p2 = pHallList; - while(p2->pNext != NULL) { + while (p2->pNext != NULL) { p2 = p2->pNext; } p2->pNext = p1; @@ -1405,46 +1382,46 @@ void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) predungeon[nX2][nY2] = 44; fInroom = FALSE; - while(!fDoneflag) { - if(nX1 >= 38 && nCurrd == 2) { + while (!fDoneflag) { + if (nX1 >= 38 && nCurrd == 2) { nCurrd = 4; } - if(nY1 >= 38 && nCurrd == 3) { + if (nY1 >= 38 && nCurrd == 3) { nCurrd = 1; } - if(nX1 <= 1 && nCurrd == 4) { + if (nX1 <= 1 && nCurrd == 4) { nCurrd = 2; } - if(nY1 <= 1 && nCurrd == 1) { + if (nY1 <= 1 && nCurrd == 1) { nCurrd = 3; } - if(predungeon[nX1][nY1] == 67 && (nCurrd == 1 || nCurrd == 4)) { + if (predungeon[nX1][nY1] == 67 && (nCurrd == 1 || nCurrd == 4)) { nCurrd = 2; } - if(predungeon[nX1][nY1] == 66 && (nCurrd == 1 || nCurrd == 2)) { + if (predungeon[nX1][nY1] == 66 && (nCurrd == 1 || nCurrd == 2)) { nCurrd = 3; } - if(predungeon[nX1][nY1] == 69 && (nCurrd == 4 || nCurrd == 3)) { + if (predungeon[nX1][nY1] == 69 && (nCurrd == 4 || nCurrd == 3)) { nCurrd = 1; } - if(predungeon[nX1][nY1] == 65 && (nCurrd == 2 || nCurrd == 3)) { + if (predungeon[nX1][nY1] == 65 && (nCurrd == 2 || nCurrd == 3)) { nCurrd = 4; } nX1 += Dir_Xadd[nCurrd]; nY1 += Dir_Yadd[nCurrd]; - if(predungeon[nX1][nY1] == 32) { - if(fInroom) { + if (predungeon[nX1][nY1] == 32) { + if (fInroom) { CreateDoorType(nX1 - Dir_Xadd[nCurrd], nY1 - Dir_Yadd[nCurrd]); } else { - if(fMinusFlag < 50) { - if(nCurrd != 1 && nCurrd != 3) { + if (fMinusFlag < 50) { + if (nCurrd != 1 && nCurrd != 3) { PlaceHallExt(nX1, nY1 - 1); } else { PlaceHallExt(nX1 - 1, nY1); } } - if(fPlusFlag < 50) { - if(nCurrd != 1 && nCurrd != 3) { + if (fPlusFlag < 50) { + if (nCurrd != 1 && nCurrd != 3) { PlaceHallExt(nX1, nY1 + 1); } else { PlaceHallExt(nX1 + 1, nY1); @@ -1454,22 +1431,22 @@ void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) predungeon[nX1][nY1] = 44; fInroom = FALSE; } else { - if(!fInroom && predungeon[nX1][nY1] == 35) { + if (!fInroom && predungeon[nX1][nY1] == 35) { CreateDoorType(nX1, nY1); } - if(predungeon[nX1][nY1] != 44) { + if (predungeon[nX1][nY1] != 44) { fInroom = TRUE; } } nDx = abs(nX2 - nX1); nDy = abs(nY2 - nY1); - if(nDx > nDy) { + if (nDx > nDy) { nRp = 2 * nDx; - if(nRp > 30) { + if (nRp > 30) { nRp = 30; } - if(random(0, 100) < nRp) { - if(nX2 <= nX1 || nX1 >= 40) { + if (random(0, 100) < nRp) { + if (nX2 <= nX1 || nX1 >= 40) { nCurrd = 4; } else { nCurrd = 2; @@ -1477,60 +1454,60 @@ void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) } } else { nRp = 5 * nDy; - if(nRp > 80) { + if (nRp > 80) { nRp = 80; } - if(random(0, 100) < nRp) { - if(nY2 <= nY1 || nY1 >= 40) { + if (random(0, 100) < nRp) { + if (nY2 <= nY1 || nY1 >= 40) { nCurrd = 1; } else { nCurrd = 3; } } } - if(nDy < 10 && nX1 == nX2 && (nCurrd == 2 || nCurrd == 4)) { - if(nY2 <= nY1 || nY1 >= 40) { + if (nDy < 10 && nX1 == nX2 && (nCurrd == 2 || nCurrd == 4)) { + if (nY2 <= nY1 || nY1 >= 40) { nCurrd = 1; } else { nCurrd = 3; } } - if(nDx < 10 && nY1 == nY2 && (nCurrd == 1 || nCurrd == 3)) { - if(nX2 <= nX1 || nX1 >= 40) { + if (nDx < 10 && nY1 == nY2 && (nCurrd == 1 || nCurrd == 3)) { + if (nX2 <= nX1 || nX1 >= 40) { nCurrd = 4; } else { nCurrd = 2; } } - if(nDy == 1 && nDx > 1 && (nCurrd == 1 || nCurrd == 3)) { - if(nX2 <= nX1 || nX1 >= 40) { + if (nDy == 1 && nDx > 1 && (nCurrd == 1 || nCurrd == 3)) { + if (nX2 <= nX1 || nX1 >= 40) { nCurrd = 4; } else { nCurrd = 2; } } - if(nDx == 1 && nDy > 1 && (nCurrd == 2 || nCurrd == 4)) { - if(nY2 <= nY1 || nX1 >= 40) { + if (nDx == 1 && nDy > 1 && (nCurrd == 2 || nCurrd == 4)) { + if (nY2 <= nY1 || nX1 >= 40) { nCurrd = 1; } else { nCurrd = 3; } } - if(nDx == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 2 || nCurrd == 4)) { - if(nX2 <= nOrigX1 || nX1 >= 40) { + if (nDx == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 2 || nCurrd == 4)) { + if (nX2 <= nOrigX1 || nX1 >= 40) { nCurrd = 1; } else { nCurrd = 3; } } - if(nDy == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 1 || nCurrd == 3)) { - if(nY2 <= nOrigY1 || nY1 >= 40) { + if (nDy == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 1 || nCurrd == 3)) { + if (nY2 <= nOrigY1 || nY1 >= 40) { nCurrd = 4; } else { nCurrd = 2; } } - if(nX1 == nX2 && nY1 == nY2) { + if (nX1 == nX2 && nY1 == nY2) { fDoneflag = TRUE; } } @@ -1542,30 +1519,30 @@ void CreateDoorType(int nX, int nY) fDoneflag = FALSE; - if(predungeon[nX - 1][nY] == 68) { + if (predungeon[nX - 1][nY] == 68) { fDoneflag = TRUE; } - if(predungeon[nX + 1][nY] == 68) { + if (predungeon[nX + 1][nY] == 68) { fDoneflag = TRUE; } - if(predungeon[nX][nY - 1] == 68) { + if (predungeon[nX][nY - 1] == 68) { fDoneflag = TRUE; } - if(predungeon[nX][nY + 1] == 68) { + if (predungeon[nX][nY + 1] == 68) { fDoneflag = TRUE; } - if(predungeon[nX][nY] == 66 || predungeon[nX][nY] == 67 || predungeon[nX][nY] == 65 || predungeon[nX][nY] == 69) { + if (predungeon[nX][nY] == 66 || predungeon[nX][nY] == 67 || predungeon[nX][nY] == 65 || predungeon[nX][nY] == 69) { fDoneflag = TRUE; } - if(!fDoneflag) { + if (!fDoneflag) { predungeon[nX][nY] = 68; } } void PlaceHallExt(int nX, int nY) { - if(predungeon[nX][nY] == 32) { + if (predungeon[nX][nY] == 32) { predungeon[nX][nY] = 44; } } @@ -1574,58 +1551,58 @@ void DoPatternCheck(int i, int j) { int k, l, x, y, nOk; - for(k = 0; Patterns[k][4] != 255; k++) { + for (k = 0; Patterns[k][4] != 255; k++) { x = i - 1; y = j - 1; nOk = 254; - for(l = 0; l < 9 && nOk == 254; l++) { + for (l = 0; l < 9 && nOk == 254; l++) { nOk = 255; - if(l == 3 || l == 6) { + if (l == 3 || l == 6) { y++; x = i - 1; } - if(x >= 0 && x < 40 && y >= 0 && y < 40) { - switch(Patterns[k][l]) { + if (x >= 0 && x < 40 && y >= 0 && y < 40) { + switch (Patterns[k][l]) { case 0: nOk = 254; break; case 1: - if(predungeon[x][y] == 35) { + if (predungeon[x][y] == 35) { nOk = 254; } break; case 2: - if(predungeon[x][y] == 46) { + if (predungeon[x][y] == 46) { nOk = 254; } break; case 4: - if(predungeon[x][y] == 32) { + if (predungeon[x][y] == 32) { nOk = 254; } break; case 3: - if(predungeon[x][y] == 68) { + if (predungeon[x][y] == 68) { nOk = 254; } break; case 5: - if(predungeon[x][y] == 68 || predungeon[x][y] == 46) { + if (predungeon[x][y] == 68 || predungeon[x][y] == 46) { nOk = 254; } break; case 6: - if(predungeon[x][y] == 68 || predungeon[x][y] == 35) { + if (predungeon[x][y] == 68 || predungeon[x][y] == 35) { nOk = 254; } break; case 7: - if(predungeon[x][y] == 32 || predungeon[x][y] == 46) { + if (predungeon[x][y] == 32 || predungeon[x][y] == 46) { nOk = 254; } break; case 8: - if(predungeon[x][y] == 68 || predungeon[x][y] == 35 || predungeon[x][y] == 46) { + if (predungeon[x][y] == 68 || predungeon[x][y] == 35 || predungeon[x][y] == 46) { nOk = 254; } break; @@ -1635,7 +1612,7 @@ void DoPatternCheck(int i, int j) } x++; } - if(nOk == 254) { + if (nOk == 254) { dungeon[i][j] = Patterns[k][9]; } } @@ -1648,259 +1625,259 @@ BOOL DL2_FillVoids() int to; to = 0; - while(DL2_NumNoChar() > 700 && to < 100) { + while (DL2_NumNoChar() > 700 && to < 100) { xx = random(0, 38) + 1; yy = random(0, 38) + 1; - if(predungeon[xx][yy] != 35) { + if (predungeon[xx][yy] != 35) { continue; } xf1 = xf2 = yf1 = yf2 = FALSE; - if(predungeon[xx - 1][yy] == 32 && predungeon[xx + 1][yy] == 46) { - if(predungeon[xx + 1][yy - 1] == 46 - && predungeon[xx + 1][yy + 1] == 46 - && predungeon[xx - 1][yy - 1] == 32 - && predungeon[xx - 1][yy + 1] == 32) { + if (predungeon[xx - 1][yy] == 32 && predungeon[xx + 1][yy] == 46) { + if (predungeon[xx + 1][yy - 1] == 46 + && predungeon[xx + 1][yy + 1] == 46 + && predungeon[xx - 1][yy - 1] == 32 + && predungeon[xx - 1][yy + 1] == 32) { xf1 = yf1 = yf2 = TRUE; } - } else if(predungeon[xx + 1][yy] == 32 && predungeon[xx - 1][yy] == 46) { - if(predungeon[xx - 1][yy - 1] == 46 - && predungeon[xx - 1][yy + 1] == 46 - && predungeon[xx + 1][yy - 1] == 32 - && predungeon[xx + 1][yy + 1] == 32) { + } else if (predungeon[xx + 1][yy] == 32 && predungeon[xx - 1][yy] == 46) { + if (predungeon[xx - 1][yy - 1] == 46 + && predungeon[xx - 1][yy + 1] == 46 + && predungeon[xx + 1][yy - 1] == 32 + && predungeon[xx + 1][yy + 1] == 32) { xf2 = yf1 = yf2 = TRUE; } - } else if(predungeon[xx][yy - 1] == 32 && predungeon[xx][yy + 1] == 46) { - if(predungeon[xx - 1][yy + 1] == 46 - && predungeon[xx + 1][yy + 1] == 46 - && predungeon[xx - 1][yy - 1] == 32 - && predungeon[xx + 1][yy - 1] == 32) { + } else if (predungeon[xx][yy - 1] == 32 && predungeon[xx][yy + 1] == 46) { + if (predungeon[xx - 1][yy + 1] == 46 + && predungeon[xx + 1][yy + 1] == 46 + && predungeon[xx - 1][yy - 1] == 32 + && predungeon[xx + 1][yy - 1] == 32) { yf1 = xf1 = xf2 = TRUE; } - } else if(predungeon[xx][yy + 1] == 32 && predungeon[xx][yy - 1] == 46) { - if(predungeon[xx - 1][yy - 1] == 46 - && predungeon[xx + 1][yy - 1] == 46 - && predungeon[xx - 1][yy + 1] == 32 - && predungeon[xx + 1][yy + 1] == 32) { + } else if (predungeon[xx][yy + 1] == 32 && predungeon[xx][yy - 1] == 46) { + if (predungeon[xx - 1][yy - 1] == 46 + && predungeon[xx + 1][yy - 1] == 46 + && predungeon[xx - 1][yy + 1] == 32 + && predungeon[xx + 1][yy + 1] == 32) { yf2 = xf1 = xf2 = TRUE; } } - if(DL2_Cont(xf1, yf1, xf2, yf2)) { - if(xf1) { + if (DL2_Cont(xf1, yf1, xf2, yf2)) { + if (xf1) { x1 = xx - 1; } else { x1 = xx; } - if(xf2) { + if (xf2) { x2 = xx + 1; } else { x2 = xx; } - if(yf1) { + if (yf1) { y1 = yy - 1; } else { y1 = yy; } - if(yf2) { + if (yf2) { y2 = yy + 1; } else { y2 = yy; } - if(!xf1) { - while(yf1 || yf2) { - if(y1 == 0) { + if (!xf1) { + while (yf1 || yf2) { + if (y1 == 0) { yf1 = FALSE; } - if(y2 == 39) { + if (y2 == 39) { yf2 = FALSE; } - if(y2 - y1 >= 14) { + if (y2 - y1 >= 14) { yf1 = FALSE; yf2 = FALSE; } - if(yf1) { + if (yf1) { y1--; } - if(yf2) { + if (yf2) { y2++; } - if(predungeon[x2][y1] != 32) { + if (predungeon[x2][y1] != 32) { yf1 = FALSE; } - if(predungeon[x2][y2] != 32) { + if (predungeon[x2][y2] != 32) { yf2 = FALSE; } } y1 += 2; y2 -= 2; - if(y2 - y1 > 5) { - while(xf2) { - if(x2 == 39) { + if (y2 - y1 > 5) { + while (xf2) { + if (x2 == 39) { xf2 = FALSE; } - if(x2 - x1 >= 12) { + if (x2 - x1 >= 12) { xf2 = FALSE; } - for(jj = y1; jj <= y2; jj++) { - if(predungeon[x2][jj] != 32) { + for (jj = y1; jj <= y2; jj++) { + if (predungeon[x2][jj] != 32) { xf2 = FALSE; } } - if(xf2) { + if (xf2) { x2++; } } x2 -= 2; - if(x2 - x1 > 5) { + if (x2 - x1 > 5) { DL2_DrawRoom(x1, y1, x2, y2); DL2_KnockWalls(x1, y1, x2, y2); } } - } else if(!xf2) { - while(yf1 || yf2) { - if(y1 == 0) { + } else if (!xf2) { + while (yf1 || yf2) { + if (y1 == 0) { yf1 = FALSE; } - if(y2 == 39) { + if (y2 == 39) { yf2 = FALSE; } - if(y2 - y1 >= 14) { + if (y2 - y1 >= 14) { yf1 = FALSE; yf2 = FALSE; } - if(yf1) { + if (yf1) { y1--; } - if(yf2) { + if (yf2) { y2++; } - if(predungeon[x1][y1] != 32) { + if (predungeon[x1][y1] != 32) { yf1 = FALSE; } - if(predungeon[x1][y2] != 32) { + if (predungeon[x1][y2] != 32) { yf2 = FALSE; } } y1 += 2; y2 -= 2; - if(y2 - y1 > 5) { - while(xf1) { - if(x1 == 0) { + if (y2 - y1 > 5) { + while (xf1) { + if (x1 == 0) { xf1 = FALSE; } - if(x2 - x1 >= 12) { + if (x2 - x1 >= 12) { xf1 = FALSE; } - for(jj = y1; jj <= y2; jj++) { - if(predungeon[x1][jj] != 32) { + for (jj = y1; jj <= y2; jj++) { + if (predungeon[x1][jj] != 32) { xf1 = FALSE; } } - if(xf1) { + if (xf1) { x1--; } } x1 += 2; - if(x2 - x1 > 5) { + if (x2 - x1 > 5) { DL2_DrawRoom(x1, y1, x2, y2); DL2_KnockWalls(x1, y1, x2, y2); } } - } else if(!yf1) { - while(xf1 || xf2) { - if(x1 == 0) { + } else if (!yf1) { + while (xf1 || xf2) { + if (x1 == 0) { xf1 = FALSE; } - if(x2 == 39) { + if (x2 == 39) { xf2 = FALSE; } - if(x2 - x1 >= 14) { + if (x2 - x1 >= 14) { xf1 = FALSE; xf2 = FALSE; } - if(xf1) { + if (xf1) { x1--; } - if(xf2) { + if (xf2) { x2++; } - if(predungeon[x1][y2] != 32) { + if (predungeon[x1][y2] != 32) { xf1 = FALSE; } - if(predungeon[x2][y2] != 32) { + if (predungeon[x2][y2] != 32) { xf2 = FALSE; } } x1 += 2; x2 -= 2; - if(x2 - x1 > 5) { - while(yf2) { - if(y2 == 39) { + if (x2 - x1 > 5) { + while (yf2) { + if (y2 == 39) { yf2 = FALSE; } - if(y2 - y1 >= 12) { + if (y2 - y1 >= 12) { yf2 = FALSE; } - for(ii = x1; ii <= x2; ii++) { - if(predungeon[ii][y2] != 32) { + for (ii = x1; ii <= x2; ii++) { + if (predungeon[ii][y2] != 32) { yf2 = FALSE; } } - if(yf2) { + if (yf2) { y2++; } } y2 -= 2; - if(y2 - y1 > 5) { + if (y2 - y1 > 5) { DL2_DrawRoom(x1, y1, x2, y2); DL2_KnockWalls(x1, y1, x2, y2); } } - } else if(!yf2) { - while(xf1 || xf2) { - if(x1 == 0) { + } else if (!yf2) { + while (xf1 || xf2) { + if (x1 == 0) { xf1 = FALSE; } - if(x2 == 39) { + if (x2 == 39) { xf2 = FALSE; } - if(x2 - x1 >= 14) { + if (x2 - x1 >= 14) { xf1 = FALSE; xf2 = FALSE; } - if(xf1) { + if (xf1) { x1--; } - if(xf2) { + if (xf2) { x2++; } - if(predungeon[x1][y1] != 32) { + if (predungeon[x1][y1] != 32) { xf1 = FALSE; } - if(predungeon[x2][y1] != 32) { + if (predungeon[x2][y1] != 32) { xf2 = FALSE; } } x1 += 2; x2 -= 2; - if(x2 - x1 > 5) { - while(yf1) { - if(y1 == 0) { + if (x2 - x1 > 5) { + while (yf1) { + if (y1 == 0) { yf1 = FALSE; } - if(y2 - y1 >= 12) { + if (y2 - y1 >= 12) { yf1 = FALSE; } - for(ii = x1; ii <= x2; ii++) { - if(predungeon[ii][y1] != 32) { + for (ii = x1; ii <= x2; ii++) { + if (predungeon[ii][y1] != 32) { yf1 = FALSE; } } - if(yf1) { + if (yf1) { y1--; } } y1 += 2; - if(y2 - y1 > 5) { + if (y2 - y1 > 5) { DL2_DrawRoom(x1, y1, x2, y2); DL2_KnockWalls(x1, y1, x2, y2); } @@ -1915,13 +1892,13 @@ BOOL DL2_FillVoids() BOOL DL2_Cont(BOOL x1f, BOOL y1f, BOOL x2f, BOOL y2f) { - if(x1f && x2f && y1f && y2f) { + if (x1f && x2f && y1f && y2f) { return FALSE; } - if(x1f && x2f && (y1f || y2f)) { + if (x1f && x2f && (y1f || y2f)) { return TRUE; } - if(y1f && y2f && (x1f || x2f)) { + if (y1f && y2f && (x1f || x2f)) { return TRUE; } @@ -1933,9 +1910,9 @@ int DL2_NumNoChar() int t, ii, jj; t = 0; - for(jj = 0; jj < 40; jj++) { - for(ii = 0; ii < 40; ii++) { - if(predungeon[ii][jj] == 32) { + for (jj = 0; jj < 40; jj++) { + for (ii = 0; ii < 40; ii++) { + if (predungeon[ii][jj] == 32) { t++; } } @@ -1948,16 +1925,16 @@ void DL2_DrawRoom(int x1, int y1, int x2, int y2) { int ii, jj; - for(jj = y1; jj <= y2; jj++) { - for(ii = x1; ii <= x2; ii++) { + for (jj = y1; jj <= y2; jj++) { + for (ii = x1; ii <= x2; ii++) { predungeon[ii][jj] = 46; } } - for(jj = y1; jj <= y2; jj++) { + for (jj = y1; jj <= y2; jj++) { predungeon[x1][jj] = 35; predungeon[x2][jj] = 35; } - for(ii = x1; ii <= x2; ii++) { + for (ii = x1; ii <= x2; ii++) { predungeon[ii][y1] = 35; predungeon[ii][y2] = 35; } @@ -1967,31 +1944,31 @@ void DL2_KnockWalls(int x1, int y1, int x2, int y2) { int ii, jj; - for(ii = x1 + 1; ii < x2; ii++) { - if(predungeon[ii][y1 - 1] == 46 && predungeon[ii][y1 + 1] == 46) { + for (ii = x1 + 1; ii < x2; ii++) { + if (predungeon[ii][y1 - 1] == 46 && predungeon[ii][y1 + 1] == 46) { predungeon[ii][y1] = 46; } - if(predungeon[ii][y2 - 1] == 46 && predungeon[ii][y2 + 1] == 46) { + if (predungeon[ii][y2 - 1] == 46 && predungeon[ii][y2 + 1] == 46) { predungeon[ii][y2] = 46; } - if(predungeon[ii][y1 - 1] == 68) { + if (predungeon[ii][y1 - 1] == 68) { predungeon[ii][y1 - 1] = 46; } - if(predungeon[ii][y2 + 1] == 68) { + if (predungeon[ii][y2 + 1] == 68) { predungeon[ii][y2 + 1] = 46; } } - for(jj = y1 + 1; jj < y2; jj++) { - if(predungeon[x1 - 1][jj] == 46 && predungeon[x1 + 1][jj] == 46) { + for (jj = y1 + 1; jj < y2; jj++) { + if (predungeon[x1 - 1][jj] == 46 && predungeon[x1 + 1][jj] == 46) { predungeon[x1][jj] = 46; } - if(predungeon[x2 - 1][jj] == 46 && predungeon[x2 + 1][jj] == 46) { + if (predungeon[x2 - 1][jj] == 46 && predungeon[x2 + 1][jj] == 46) { predungeon[x2][jj] = 46; } - if(predungeon[x1 - 1][jj] == 68) { + if (predungeon[x1 - 1][jj] == 68) { predungeon[x1 - 1][jj] = 46; } - if(predungeon[x2 + 1][jj] == 68) { + if (predungeon[x2 + 1][jj] == 68) { predungeon[x2 + 1][jj] = 46; } } @@ -2002,10 +1979,10 @@ void DRLG_L2FloodTVal() int i, j, xx, yy; yy = 16; - for(j = 0; j < 40; j++) { + for (j = 0; j < 40; j++) { xx = 16; - for(i = 0; i < 40; i++) { - if(dungeon[i][j] == 3 && dTransVal[xx][yy] == 0) { + for (i = 0; i < 40; i++) { + if (dungeon[i][j] == 3 && dTransVal[xx][yy] == 0) { DRLG_L2FTVR(i, j, xx, yy, 0); TransVal++; } @@ -2014,37 +1991,36 @@ void DRLG_L2FloodTVal() yy += 2; } } -// 5A5590: using guessed type char TransVal; void DRLG_L2FTVR(int i, int j, int x, int y, int d) { - if(dTransVal[x][y] != 0 || dungeon[i][j] != 3) { - if(d == 1) { + if (dTransVal[x][y] != 0 || dungeon[i][j] != 3) { + if (d == 1) { dTransVal[x][y] = TransVal; dTransVal[x][y + 1] = TransVal; } - if(d == 2) { + if (d == 2) { dTransVal[x + 1][y] = TransVal; dTransVal[x + 1][y + 1] = TransVal; } - if(d == 3) { + if (d == 3) { dTransVal[x][y] = TransVal; dTransVal[x + 1][y] = TransVal; } - if(d == 4) { + if (d == 4) { dTransVal[x][y + 1] = TransVal; dTransVal[x + 1][y + 1] = TransVal; } - if(d == 5) { + if (d == 5) { dTransVal[x + 1][y + 1] = TransVal; } - if(d == 6) { + if (d == 6) { dTransVal[x][y + 1] = TransVal; } - if(d == 7) { + if (d == 7) { dTransVal[x + 1][y] = TransVal; } - if(d == 8) { + if (d == 8) { dTransVal[x][y] = TransVal; } } else { @@ -2062,33 +2038,32 @@ void DRLG_L2FTVR(int i, int j, int x, int y, int d) DRLG_L2FTVR(i + 1, j + 1, x + 2, y + 2, 8); } } -// 5A5590: using guessed type char TransVal; void DRLG_L2TransFix() { int i, j, xx, yy; yy = 16; - for(j = 0; j < 40; j++) { + for (j = 0; j < 40; j++) { xx = 16; - for(i = 0; i < 40; i++) { - if(dungeon[i][j] == 14 && dungeon[i][j - 1] == 10) { + for (i = 0; i < 40; i++) { + if (dungeon[i][j] == 14 && dungeon[i][j - 1] == 10) { dTransVal[xx + 1][yy] = dTransVal[xx][yy]; dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy]; } - if(dungeon[i][j] == 15 && dungeon[i + 1][j] == 11) { + if (dungeon[i][j] == 15 && dungeon[i + 1][j] == 11) { dTransVal[xx][yy + 1] = dTransVal[xx][yy]; dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy]; } - if(dungeon[i][j] == 10) { + if (dungeon[i][j] == 10) { dTransVal[xx + 1][yy] = dTransVal[xx][yy]; dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy]; } - if(dungeon[i][j] == 11) { + if (dungeon[i][j] == 11) { dTransVal[xx][yy + 1] = dTransVal[xx][yy]; dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy]; } - if(dungeon[i][j] == 16) { + if (dungeon[i][j] == 16) { dTransVal[xx + 1][yy] = dTransVal[xx][yy]; dTransVal[xx][yy + 1] = dTransVal[xx][yy]; dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy]; @@ -2103,24 +2078,24 @@ void L2DirtFix() { int i, j; - for(j = 0; j < 40; j++) { - for(i = 0; i < 40; i++) { - if(dungeon[i][j] == 13 && dungeon[i + 1][j] != 11) { + for (j = 0; j < 40; j++) { + for (i = 0; i < 40; i++) { + if (dungeon[i][j] == 13 && dungeon[i + 1][j] != 11) { dungeon[i][j] = 146; } - if(dungeon[i][j] == 11 && dungeon[i + 1][j] != 11) { + if (dungeon[i][j] == 11 && dungeon[i + 1][j] != 11) { dungeon[i][j] = 144; } - if(dungeon[i][j] == 15 && dungeon[i + 1][j] != 11) { + if (dungeon[i][j] == 15 && dungeon[i + 1][j] != 11) { dungeon[i][j] = 148; } - if(dungeon[i][j] == 10 && dungeon[i][j + 1] != 10) { + if (dungeon[i][j] == 10 && dungeon[i][j + 1] != 10) { dungeon[i][j] = 143; } - if(dungeon[i][j] == 13 && dungeon[i][j + 1] != 10) { + if (dungeon[i][j] == 13 && dungeon[i][j + 1] != 10) { dungeon[i][j] = 146; } - if(dungeon[i][j] == 14 && dungeon[i][j + 1] != 15) { + if (dungeon[i][j] == 14 && dungeon[i][j + 1] != 15) { dungeon[i][j] = 147; } } @@ -2131,21 +2106,21 @@ void DRLG_InitL2Vals() { int i, j, pc; - for(j = 0; j < 112; j++) { - for(i = 0; i < 112; i++) { - if(dPiece[i][j] == 541) { + for (j = 0; j < 112; j++) { + for (i = 0; i < 112; i++) { + if (dPiece[i][j] == 541) { pc = 5; - } else if(dPiece[i][j] == 178) { + } else if (dPiece[i][j] == 178) { pc = 5; - } else if(dPiece[i][j] == 551) { + } else if (dPiece[i][j] == 551) { pc = 5; - } else if(dPiece[i][j] == 542) { + } else if (dPiece[i][j] == 542) { pc = 6; - } else if(dPiece[i][j] == 553) { + } else if (dPiece[i][j] == 553) { pc = 6; - } else if(dPiece[i][j] == 13) { + } else if (dPiece[i][j] == 13) { pc = 5; - } else if(dPiece[i][j] == 17) { + } else if (dPiece[i][j] == 17) { pc = 6; } else { continue; @@ -2153,12 +2128,12 @@ void DRLG_InitL2Vals() dArch[i][j] = pc; } } - for(j = 0; j < 112; j++) { - for(i = 0; i < 112; i++) { - if(dPiece[i][j] == 132) { + for (j = 0; j < 112; j++) { + for (i = 0; i < 112; i++) { + if (dPiece[i][j] == 132) { dArch[i][j + 1] = 2; dArch[i][j + 2] = 1; - } else if(dPiece[i][j] == 135 || dPiece[i][j] == 139) { + } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { dArch[i + 1][j] = 3; dArch[i + 2][j] = 4; } diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index ea6df087c63..82d34acdf5a 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -3,11 +3,11 @@ #define __DRLG_L2_H__ extern int nSx1; -extern int nSx2; // weak +extern int nSx2; extern int nSy1; -extern int nSy2; // weak +extern int nSy2; extern int nRoomCnt; -extern unsigned char predungeon[40][40]; +extern BYTE predungeon[DMAXX][DMAXY]; extern ROOMNODE RoomList[81]; extern HALLNODE *pHallList; @@ -17,12 +17,12 @@ void L2DoorFix(); void LoadL2Dungeon(char *sFileName, int vx, int vy); void DRLG_L2Pass3(); void LoadPreL2Dungeon(char *sFileName, int vx, int vy); -void CreateL2Dungeon(unsigned int rseed, int entry); +void CreateL2Dungeon(DWORD rseed, int entry); void DRLG_LoadL2SP(); void DRLG_FreeL2SP(); void DRLG_L2(int entry); -BOOL DRLG_L2PlaceMiniSet(unsigned char *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir); -void DRLG_L2PlaceRndSet(unsigned char *miniset, int rndper); +BOOL DRLG_L2PlaceMiniSet(BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir); +void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper); void DRLG_L2Subs(); void DRLG_L2Shadows(); void DRLG_L2SetRoom(int rx1, int ry1); @@ -48,126 +48,126 @@ void L2DirtFix(); void DRLG_InitL2Vals(); /* rdata */ -extern int Area_Min; // weak -extern int Room_Max; // weak -extern int Room_Min; // weak +extern int Area_Min; +extern int Room_Max; +extern int Room_Min; extern int Dir_Xadd[5]; extern int Dir_Yadd[5]; extern ShadowStruct SPATSL2[2]; //short word_48489A; -extern unsigned char BTYPESL2[161]; -extern unsigned char BSTYPESL2[161]; -extern unsigned char VARCH1[]; -extern unsigned char VARCH2[]; -extern unsigned char VARCH3[]; -extern unsigned char VARCH4[]; -extern unsigned char VARCH5[]; -extern unsigned char VARCH6[]; -extern unsigned char VARCH7[]; -extern unsigned char VARCH8[]; -extern unsigned char VARCH9[]; -extern unsigned char VARCH10[]; -extern unsigned char VARCH11[]; -extern unsigned char VARCH12[]; -extern unsigned char VARCH13[]; -extern unsigned char VARCH14[]; -extern unsigned char VARCH15[]; -extern unsigned char VARCH16[]; -extern unsigned char VARCH17[]; -extern unsigned char VARCH18[]; -extern unsigned char VARCH19[]; -extern unsigned char VARCH20[]; -extern unsigned char VARCH21[]; -extern unsigned char VARCH22[]; -extern unsigned char VARCH23[]; -extern unsigned char VARCH24[]; -extern unsigned char VARCH25[]; -extern unsigned char VARCH26[]; -extern unsigned char VARCH27[]; -extern unsigned char VARCH28[]; -extern unsigned char VARCH29[]; -extern unsigned char VARCH30[]; -extern unsigned char VARCH31[]; -extern unsigned char VARCH32[]; -extern unsigned char VARCH33[]; -extern unsigned char VARCH34[]; -extern unsigned char VARCH35[]; -extern unsigned char VARCH36[]; -extern unsigned char VARCH37[]; -extern unsigned char VARCH38[]; -extern unsigned char VARCH39[]; -extern unsigned char VARCH40[]; -extern unsigned char HARCH1[]; -extern unsigned char HARCH2[]; -extern unsigned char HARCH3[]; -extern unsigned char HARCH4[]; -extern unsigned char HARCH5[]; -extern unsigned char HARCH6[]; -extern unsigned char HARCH7[]; -extern unsigned char HARCH8[]; -extern unsigned char HARCH9[]; -extern unsigned char HARCH10[]; -extern unsigned char HARCH11[]; -extern unsigned char HARCH12[]; -extern unsigned char HARCH13[]; -extern unsigned char HARCH14[]; -extern unsigned char HARCH15[]; -extern unsigned char HARCH16[]; -extern unsigned char HARCH17[]; -extern unsigned char HARCH18[]; -extern unsigned char HARCH19[]; -extern unsigned char HARCH20[]; -extern unsigned char HARCH21[]; -extern unsigned char HARCH22[]; -extern unsigned char HARCH23[]; -extern unsigned char HARCH24[]; -extern unsigned char HARCH25[]; -extern unsigned char HARCH26[]; -extern unsigned char HARCH27[]; -extern unsigned char HARCH28[]; -extern unsigned char HARCH29[]; -extern unsigned char HARCH30[]; -extern unsigned char HARCH31[]; -extern unsigned char HARCH32[]; -extern unsigned char HARCH33[]; -extern unsigned char HARCH34[]; -extern unsigned char HARCH35[]; -extern unsigned char HARCH36[]; -extern unsigned char HARCH37[]; -extern unsigned char HARCH38[]; -extern unsigned char HARCH39[]; -extern unsigned char HARCH40[]; -extern unsigned char USTAIRS[]; -extern unsigned char DSTAIRS[]; -extern unsigned char WARPSTAIRS[]; -extern unsigned char CRUSHCOL[]; -extern unsigned char BIG1[]; -extern unsigned char BIG2[]; -extern unsigned char BIG3[]; -extern unsigned char BIG4[]; -extern unsigned char BIG5[]; -extern unsigned char BIG6[]; -extern unsigned char BIG7[]; -extern unsigned char BIG8[]; -extern unsigned char BIG9[]; -extern unsigned char BIG10[]; -extern unsigned char RUINS1[]; -extern unsigned char RUINS2[]; -extern unsigned char RUINS3[]; -extern unsigned char RUINS4[]; -extern unsigned char RUINS5[]; -extern unsigned char RUINS6[]; -extern unsigned char RUINS7[]; -extern unsigned char PANCREAS1[]; -extern unsigned char PANCREAS2[]; -extern unsigned char CTRDOOR1[]; -extern unsigned char CTRDOOR2[]; -extern unsigned char CTRDOOR3[]; -extern unsigned char CTRDOOR4[]; -extern unsigned char CTRDOOR5[]; -extern unsigned char CTRDOOR6[]; -extern unsigned char CTRDOOR7[]; -extern unsigned char CTRDOOR8[]; +extern BYTE BTYPESL2[161]; +extern BYTE BSTYPESL2[161]; +extern BYTE VARCH1[]; +extern BYTE VARCH2[]; +extern BYTE VARCH3[]; +extern BYTE VARCH4[]; +extern BYTE VARCH5[]; +extern BYTE VARCH6[]; +extern BYTE VARCH7[]; +extern BYTE VARCH8[]; +extern BYTE VARCH9[]; +extern BYTE VARCH10[]; +extern BYTE VARCH11[]; +extern BYTE VARCH12[]; +extern BYTE VARCH13[]; +extern BYTE VARCH14[]; +extern BYTE VARCH15[]; +extern BYTE VARCH16[]; +extern BYTE VARCH17[]; +extern BYTE VARCH18[]; +extern BYTE VARCH19[]; +extern BYTE VARCH20[]; +extern BYTE VARCH21[]; +extern BYTE VARCH22[]; +extern BYTE VARCH23[]; +extern BYTE VARCH24[]; +extern BYTE VARCH25[]; +extern BYTE VARCH26[]; +extern BYTE VARCH27[]; +extern BYTE VARCH28[]; +extern BYTE VARCH29[]; +extern BYTE VARCH30[]; +extern BYTE VARCH31[]; +extern BYTE VARCH32[]; +extern BYTE VARCH33[]; +extern BYTE VARCH34[]; +extern BYTE VARCH35[]; +extern BYTE VARCH36[]; +extern BYTE VARCH37[]; +extern BYTE VARCH38[]; +extern BYTE VARCH39[]; +extern BYTE VARCH40[]; +extern BYTE HARCH1[]; +extern BYTE HARCH2[]; +extern BYTE HARCH3[]; +extern BYTE HARCH4[]; +extern BYTE HARCH5[]; +extern BYTE HARCH6[]; +extern BYTE HARCH7[]; +extern BYTE HARCH8[]; +extern BYTE HARCH9[]; +extern BYTE HARCH10[]; +extern BYTE HARCH11[]; +extern BYTE HARCH12[]; +extern BYTE HARCH13[]; +extern BYTE HARCH14[]; +extern BYTE HARCH15[]; +extern BYTE HARCH16[]; +extern BYTE HARCH17[]; +extern BYTE HARCH18[]; +extern BYTE HARCH19[]; +extern BYTE HARCH20[]; +extern BYTE HARCH21[]; +extern BYTE HARCH22[]; +extern BYTE HARCH23[]; +extern BYTE HARCH24[]; +extern BYTE HARCH25[]; +extern BYTE HARCH26[]; +extern BYTE HARCH27[]; +extern BYTE HARCH28[]; +extern BYTE HARCH29[]; +extern BYTE HARCH30[]; +extern BYTE HARCH31[]; +extern BYTE HARCH32[]; +extern BYTE HARCH33[]; +extern BYTE HARCH34[]; +extern BYTE HARCH35[]; +extern BYTE HARCH36[]; +extern BYTE HARCH37[]; +extern BYTE HARCH38[]; +extern BYTE HARCH39[]; +extern BYTE HARCH40[]; +extern BYTE USTAIRS[]; +extern BYTE DSTAIRS[]; +extern BYTE WARPSTAIRS[]; +extern BYTE CRUSHCOL[]; +extern BYTE BIG1[]; +extern BYTE BIG2[]; +extern BYTE BIG3[]; +extern BYTE BIG4[]; +extern BYTE BIG5[]; +extern BYTE BIG6[]; +extern BYTE BIG7[]; +extern BYTE BIG8[]; +extern BYTE BIG9[]; +extern BYTE BIG10[]; +extern BYTE RUINS1[]; +extern BYTE RUINS2[]; +extern BYTE RUINS3[]; +extern BYTE RUINS4[]; +extern BYTE RUINS5[]; +extern BYTE RUINS6[]; +extern BYTE RUINS7[]; +extern BYTE PANCREAS1[]; +extern BYTE PANCREAS2[]; +extern BYTE CTRDOOR1[]; +extern BYTE CTRDOOR2[]; +extern BYTE CTRDOOR3[]; +extern BYTE CTRDOOR4[]; +extern BYTE CTRDOOR5[]; +extern BYTE CTRDOOR6[]; +extern BYTE CTRDOOR7[]; +extern BYTE CTRDOOR8[]; extern int Patterns[100][10]; #endif /* __DRLG_L2_H__ */ diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index edb49f646ee..817c1d53f63 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -5,7 +5,7 @@ DEVILUTION_BEGIN_NAMESPACE BOOLEAN lavapool; int abyssx; int lockoutcnt; -BOOLEAN lockout[40][40]; +BOOLEAN lockout[DMAXX][DMAXY]; const BYTE L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 }; const BYTE L3UP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 51, 50, 0, 48, 49, 0, 0, 0, 0 }; @@ -289,7 +289,7 @@ BOOL DRLG_L3Lockout() return t == lockoutcnt; } -void CreateL3Dungeon(int rseed, int entry) +void CreateL3Dungeon(DWORD rseed, int entry) { int i, j; @@ -791,6 +791,8 @@ void DRLG_L3River() rivercnt = 0; bail = FALSE; trys = 0; + /// BUGFIX: pdir is uninitialized, add code `pdir = -1;`(fixed) + pdir = -1; while (trys < 200 && rivercnt < 4) { bail = FALSE; @@ -1058,6 +1060,8 @@ void DRLG_L3Pool() poolchance = random(0, 100); for (j = duny - totarea; j < duny + totarea; j++) { for (i = dunx - totarea; i < dunx + totarea; i++) { + // BUGFIX: In the following swap the order to first do the + // index checks and only then access dungeon[i][j] if (dungeon[i][j] & 0x80 && j >= 0 && j < 40 && i >= 0 && i < 40) { dungeon[i][j] &= ~0x80; if (totarea > 4 && poolchance < 25 && !found) { @@ -1181,8 +1185,8 @@ void DRLG_L3PoolFix() { int dunx, duny; - for (duny = 0; duny < DMAXY; duny++) { - for (dunx = 0; dunx < DMAXX; dunx++) { + for (duny = 0; duny < DMAXY; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1' + for (dunx = 0; dunx < DMAXX; dunx++) { // BUGFIX: Change '0' to '1' and 'DMAXX' to 'DMAXX - 1' if (dungeon[dunx][duny] == 8) { if (dungeon[dunx - 1][duny - 1] >= 25 && dungeon[dunx - 1][duny - 1] <= 41 && dungeon[dunx - 1][duny] >= 25 && dungeon[dunx - 1][duny] <= 41 @@ -1305,6 +1309,7 @@ void DRLG_L3PlaceRndSet(const BYTE *miniset, int rndper) } kk = sw * sh + 2; if (miniset[kk] >= 84 && miniset[kk] <= 100 && found == TRUE) { + // BUGFIX: accesses to dungeon can go out of bounds if (dungeon[sx - 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) { found = FALSE; } @@ -1337,8 +1342,8 @@ void DRLG_L3Wood() int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2; BOOL skip; - for (j = 0; j < DMAXY - 1; j++) { - for (i = 0; i < DMAXX - 1; i++) { + for (j = 0; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' + for (i = 0; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1' if (dungeon[i][j] == 10 && random(0, 2) != 0) { x = i; while (dungeon[x][j] == 10) { @@ -1407,8 +1412,8 @@ void DRLG_L3Wood() } } - for (j = 0; j < DMAXY; j++) { - for (i = 0; i < DMAXX; i++) { + for (j = 0; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' + for (i = 0; i < DMAXX; i++) { // BUGFIX: Change '0' to '1' if (dungeon[i][j] != 7 || random(0, 1) != 0 || !SkipThemeRoom(i, j)) { continue; } @@ -1730,7 +1735,7 @@ void LoadL3Dungeon(char *sFileName, int vx, int vy) dmaxx = 96; dmaxy = 96; DRLG_InitTrans(); - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); lm = pLevelMap; rw = *lm; @@ -1788,7 +1793,7 @@ void LoadPreL3Dungeon(char *sFileName, int vx, int vy) InitL3Dungeon(); DRLG_InitTrans(); - pLevelMap = LoadFileInMem(sFileName, 0); + pLevelMap = LoadFileInMem(sFileName, NULL); lm = pLevelMap; rw = *lm; diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index 4266d99b02e..01deec67748 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -5,7 +5,7 @@ extern BOOLEAN lavapool; extern int abyssx; extern int lockoutcnt; -extern BOOLEAN lockout[40][40]; +extern BOOLEAN lockout[DMAXX][DMAXY]; void AddFenceDoors(); void FenceDoorFix(); @@ -14,7 +14,7 @@ void FixL3Warp(); void FixL3HallofHeroes(); void DRLG_L3LockRec(int x, int y); BOOL DRLG_L3Lockout(); -void CreateL3Dungeon( int rseed, int entry); +void CreateL3Dungeon(DWORD rseed, int entry); void DRLG_L3(int entry); void InitL3Dungeon(); BOOL DRLG_L3FillRoom(int x1, int y1, int x2, int y2); diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index c95f7c2f364..25c465dacb6 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -2,27 +2,27 @@ DEVILUTION_BEGIN_NAMESPACE -int diabquad1x; // weak -int diabquad1y; // weak -int diabquad3x; // idb -int diabquad3y; // idb -int diabquad2x; // idb -int diabquad2y; // idb -int diabquad4x; // idb -int diabquad4y; // idb +int diabquad1x; +int diabquad1y; +int diabquad3x; +int diabquad3y; +int diabquad2x; +int diabquad2y; +int diabquad4x; +int diabquad4y; BOOL hallok[20]; -int l4holdx; // weak -int l4holdy; // weak -int SP4x1; // idb -int SP4x2; // weak -int SP4y1; // idb -int SP4y2; // weak -unsigned char L4dungeon[80][80]; -unsigned char dung[20][20]; +int l4holdx; +int l4holdy; +int SP4x1; +int SP4x2; +int SP4y1; +int SP4y2; +BYTE L4dungeon[80][80]; +BYTE dung[20][20]; //int dword_52A4DC; // weak -const unsigned char L4ConvTbl[16] = { 30u, 6u, 1u, 6u, 2u, 6u, 6u, 6u, 9u, 6u, 1u, 6u, 2u, 6u, 3u, 6u }; -const unsigned char L4USTAIRS[42] = { +const BYTE L4ConvTbl[16] = { 30u, 6u, 1u, 6u, 2u, 6u, 6u, 6u, 9u, 6u, 1u, 6u, 2u, 6u, 3u, 6u }; +const BYTE L4USTAIRS[42] = { 4u, 5u, 6u, @@ -66,7 +66,7 @@ const unsigned char L4USTAIRS[42] = { 0u, 0u }; -const unsigned char L4TWARP[42] = { +const BYTE L4TWARP[42] = { 4u, 5u, 6u, @@ -110,7 +110,7 @@ const unsigned char L4TWARP[42] = { 0u, 0u }; -const unsigned char L4DSTAIRS[52] = { +const BYTE L4DSTAIRS[52] = { 5u, 5u, 6u, @@ -164,7 +164,7 @@ const unsigned char L4DSTAIRS[52] = { 0u, 0u }; -const unsigned char L4PENTA[52] = { +const BYTE L4PENTA[52] = { 5u, 5u, 6u, @@ -218,7 +218,7 @@ const unsigned char L4PENTA[52] = { 0u, 0u }; -const unsigned char L4PENTA2[52] = { +const BYTE L4PENTA2[52] = { 5u, 5u, 6u, @@ -272,7 +272,7 @@ const unsigned char L4PENTA2[52] = { 0u, 0u }; -const unsigned char L4BTYPES[140] = { +const BYTE L4BTYPES[140] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -293,16 +293,14 @@ void DRLG_LoadL4SP() { setloadflag_2 = 0; if (QuestStatus(QTYPE_WARLRD)) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); setloadflag_2 = 1; } if (currlevel == 15 && gbMaxPlayers != 1) { - pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L4Data\\Vile1.DUN", NULL); setloadflag_2 = 1; } } -// 5B50D8: using guessed type int setloadflag_2; -// 679660: using guessed type char gbMaxPlayers; void DRLG_FreeL4SP() { @@ -312,17 +310,17 @@ void DRLG_FreeL4SP() void DRLG_L4SetSPRoom(int rx1, int ry1) { int rw, rh, i, j; - unsigned char *sp; + BYTE *sp; - rw = (unsigned char)pSetPiece_2[0]; - rh = (unsigned char)pSetPiece_2[2]; + rw = (BYTE)pSetPiece_2[0]; + rh = (BYTE)pSetPiece_2[2]; setpc_x = rx1; setpc_y = ry1; setpc_w = rw; setpc_h = rh; - sp = (unsigned char *)&pSetPiece_2[4]; + sp = (BYTE *)&pSetPiece_2[4]; for (j = 0; j < rh; j++) { for (i = 0; i < rw; i++) { @@ -336,8 +334,6 @@ void DRLG_L4SetSPRoom(int rx1, int ry1) } } } -// 5CF330: using guessed type int setpc_h; -// 5CF334: using guessed type int setpc_w; void L4SaveQuads() { @@ -356,8 +352,6 @@ void L4SaveQuads() y++; } } -// 528A34: using guessed type int l4holdx; -// 528A38: using guessed type int l4holdy; void DRLG_L4SetRoom(BYTE *pSetPiece, int rx1, int ry1) { @@ -385,16 +379,16 @@ void DRLG_LoadDiabQuads(BOOL preflag) { BYTE *lpSetPiece; - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", NULL); diabquad1x = 4 + l4holdx; diabquad1y = 4 + l4holdy; DRLG_L4SetRoom(lpSetPiece, diabquad1x, diabquad1y); mem_free_dbg(lpSetPiece); if (preflag) { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2b.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2b.DUN", NULL); } else { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", NULL); } diabquad2x = 27 - l4holdx; diabquad2y = 1 + l4holdy; @@ -402,9 +396,9 @@ void DRLG_LoadDiabQuads(BOOL preflag) mem_free_dbg(lpSetPiece); if (preflag) { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3b.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3b.DUN", NULL); } else { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", NULL); } diabquad3x = 1 + l4holdx; diabquad3y = 27 - l4holdy; @@ -412,9 +406,9 @@ void DRLG_LoadDiabQuads(BOOL preflag) mem_free_dbg(lpSetPiece); if (preflag) { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4b.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4b.DUN", NULL); } else { - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", NULL); } diabquad4x = 28 - l4holdx; diabquad4y = 28 - l4holdy; @@ -477,7 +471,7 @@ void DRLG_L4GeneralFix() } } -void CreateL4Dungeon(unsigned int rseed, int entry) +void CreateL4Dungeon(DWORD rseed, int entry) { SetRndSeed(rseed); @@ -1451,6 +1445,7 @@ void uShape() hallok[j] = FALSE; } if (dung[i][j] == 1) { + // BUGFIX: check that i + 1 < 20 and j + 1 < 20 if (dung[i][j + 1] == 1 && dung[i + 1][j + 1] == 0) { hallok[j] = TRUE; } else { @@ -1487,6 +1482,7 @@ void uShape() hallok[i] = FALSE; } if (dung[i][j] == 1) { + // BUGFIX: check that i + 1 < 20 and j + 1 < 20 if (dung[i + 1][j] == 1 && dung[i + 1][j + 1] == 0) { hallok[i] = TRUE; } else { @@ -1538,7 +1534,7 @@ long GetArea() void L4firstRoom() { - int x, y, w, h, rndx, rndy; /* xmin, xmax, ymin, ymax */ + int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax; if (currlevel != 16) { if (currlevel == quests[QTYPE_WARLRD]._qlevel && quests[QTYPE_WARLRD]._qactive) { @@ -1557,13 +1553,17 @@ void L4firstRoom() h = 14; } - rndx = random(0, 19 - w - ((20 - w) >> 1) + 1) + ((20 - w) >> 1); + xmin = (20 - w) >> 1; + xmax = 19 - w; + rndx = random(0, xmax - xmin + 1) + xmin; if (rndx + w > 19) { x = 19 - w + 1; } else { x = rndx; } - rndy = random(0, 19 - h - ((20 - h) >> 1) + 1) + ((20 - h) >> 1); + ymin = (20 - h) >> 1; + ymax = 19 - h; + rndy = random(0, ymax - ymin + 1) + ymin; if (rndy + h > 19) { y = 19 - h + 1; } else { @@ -1680,7 +1680,7 @@ BOOL L4checkRoom(int x, int y, int width, int height) return TRUE; } -BOOL DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir) +BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir) { int sx, sy, sw, sh, xx, yy, i, ii, numt, bailcnt; BOOL found; diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index 76262ab0dea..635870b7318 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -2,21 +2,21 @@ #ifndef __DRLG_L4_H__ #define __DRLG_L4_H__ -extern int diabquad1x; // weak -extern int diabquad1y; // weak -extern int diabquad3x; // idb -extern int diabquad3y; // idb -extern int diabquad2x; // idb -extern int diabquad2y; // idb -extern int diabquad4x; // idb -extern int diabquad4y; // idb +extern int diabquad1x; +extern int diabquad1y; +extern int diabquad3x; +extern int diabquad3y; +extern int diabquad2x; +extern int diabquad2y; +extern int diabquad4x; +extern int diabquad4y; extern BOOL hallok[20]; -extern int l4holdx; // weak -extern int l4holdy; // weak -extern int SP4x1; // idb -extern int SP4x2; // weak -extern int SP4y1; // idb -extern int SP4y2; // weak +extern int l4holdx; +extern int l4holdy; +extern int SP4x1; +extern int SP4x2; +extern int SP4y1; +extern int SP4y2; extern unsigned char L4dungeon[80][80]; extern unsigned char dung[20][20]; //int dword_52A4DC; // weak @@ -25,13 +25,13 @@ void DRLG_LoadL4SP(); void DRLG_FreeL4SP(); void DRLG_L4SetSPRoom(int rx1, int ry1); void L4SaveQuads(); -void DRLG_L4SetRoom(unsigned char *pSetPiece, int rx1, int ry1); +void DRLG_L4SetRoom(BYTE *pSetPiece, int rx1, int ry1); void DRLG_LoadDiabQuads(BOOL preflag); BOOL IsDURWall(char d); BOOL IsDLLWall(char dd); void L4FixRim(); void DRLG_L4GeneralFix(); -void CreateL4Dungeon(unsigned int rseed, int entry); +void CreateL4Dungeon(DWORD rseed, int entry); void DRLG_L4(int entry); void DRLG_L4Shadows(); void InitL4Dungeon(); @@ -50,7 +50,7 @@ void L4firstRoom(); void L4drawRoom(int x, int y, int width, int height); void L4roomGen(int x, int y, int w, int h, int dir); BOOL L4checkRoom(int x, int y, int width, int height); -BOOL DRLG_L4PlaceMiniSet(const unsigned char *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir); +BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir); void DRLG_L4FloodTVal(); void DRLG_L4FTVR(int i, int j, int x, int y, int d); void DRLG_L4TransFix(); diff --git a/Source/dthread.h b/Source/dthread.h index 49e1704c8df..c029a277b86 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -12,6 +12,5 @@ unsigned int __stdcall dthread_handler(void *unused); void dthread_cleanup(); /* data */ -extern int dthread_inf; // weak #endif /* __DTHREAD_H__ */ diff --git a/Source/dx.cpp b/Source/dx.cpp index 2e030e7003d..0df985e671b 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -5,7 +5,7 @@ DEVILUTION_BEGIN_NAMESPACE BYTE *sgpBackBuf; LPDIRECTDRAW lpDDInterface; -IDirectDrawPalette *lpDDPalette; // idb +IDirectDrawPalette *lpDDPalette; int sgdwLockCount; BYTE *gpBuffer; IDirectDrawSurface *lpDDSBackBuf; @@ -16,9 +16,9 @@ int locktbl[256]; #ifdef __cplusplus static CCritSect sgMemCrit; #endif -char gbBackBuf; // weak -char gbEmulate; // weak -HMODULE ghDiabMod; // idb +char gbBackBuf; +char gbEmulate; +HMODULE ghDiabMod; void dx_init(HWND hWnd) { @@ -35,11 +35,11 @@ void dx_init(HWND hWnd) ShowWindow(hWnd, SW_SHOWNORMAL); lpGUID = NULL; - if(gbEmulate) { + if (gbEmulate) { lpGUID = (GUID *)DDCREATE_EMULATIONONLY; } hDDVal = dx_DirectDrawCreate(lpGUID, &lpDDInterface, NULL); - if(hDDVal != DD_OK) { + if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); } @@ -54,15 +54,15 @@ void dx_init(HWND hWnd) #ifndef _DEBUG fullscreen = TRUE; #endif - if(!fullscreen) { + if (!fullscreen) { #ifdef __cplusplus hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #else hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #endif - if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { + if (hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { TriggerBreak(); - } else if(hDDVal != DD_OK) { + } else if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Diablo\\Direct\\dx.cpp", 155); } SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); @@ -72,9 +72,9 @@ void dx_init(HWND hWnd) #else hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); #endif - if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { + if (hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { TriggerBreak(); - } else if(hDDVal != DD_OK) { + } else if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); } #ifdef __cplusplus @@ -82,7 +82,7 @@ void dx_init(HWND hWnd) #else hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); #endif - if(hDDVal != DD_OK) { + if (hDDVal != DD_OK) { winw = GetSystemMetrics(SM_CXSCREEN); winh = GetSystemMetrics(SM_CYSCREEN); #ifdef __cplusplus @@ -91,7 +91,7 @@ void dx_init(HWND hWnd) hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, SCREEN_BPP); #endif } - if(hDDVal != DD_OK) { + if (hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); } } @@ -103,7 +103,6 @@ void dx_init(HWND hWnd) bSuccess = SDrawManualInitialize(hWnd, lpDDInterface, lpDDSPrimary, NULL, NULL, lpDDSBackBuf, lpDDPalette, NULL); /// ASSERT: assert(bSuccess); } -// 52A549: using guessed type char gbEmulate; void dx_create_back_buffer() { @@ -162,7 +161,6 @@ void dx_create_back_buffer() if (error_code != DD_OK) ErrDlg(IDD_DIALOG1, error_code, "C:\\Src\\Diablo\\Source\\dx.cpp", 96); } -// 52A548: using guessed type char gbBackBuf; void dx_create_primary_surface() { diff --git a/Source/dx.h b/Source/dx.h index bdf3dede147..91344a85d6a 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -3,13 +3,13 @@ #define __DX_H__ extern IDirectDraw *lpDDInterface; -extern IDirectDrawPalette *lpDDPalette; // idb +extern IDirectDrawPalette *lpDDPalette; extern BYTE *gpBuffer; extern IDirectDrawSurface *lpDDSBackBuf; extern IDirectDrawSurface *lpDDSPrimary; -extern char gbBackBuf; // weak -extern char gbEmulate; // weak -extern HMODULE ghDiabMod; // idb +extern char gbBackBuf; +extern char gbEmulate; +extern HMODULE ghDiabMod; void dx_init(HWND hWnd); void dx_create_back_buffer(); @@ -25,6 +25,4 @@ void j_dx_reinit(); /* data */ -extern int dx_inf; // weak - #endif /* __DX_H__ */ diff --git a/Source/effects.cpp b/Source/effects.cpp index a46dff509fc..1583e620bb7 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1180,7 +1180,7 @@ void effects_cleanup_sfx() void stream_update() { - UCHAR mask = 0; + BYTE mask = 0; if (gbMaxPlayers > 1) { mask = SFX_WARRIOR | SFX_ROGUE | SFX_SORCEROR; } else if (plr[myplr]._pClass == PC_WARRIOR) { @@ -1196,9 +1196,9 @@ void stream_update() priv_sound_init(mask); } -void priv_sound_init(UCHAR bLoadMask) +void priv_sound_init(BYTE bLoadMask) { - UCHAR pc, bFlags; + BYTE pc, bFlags; DWORD i; if (!gbSndInited) { diff --git a/Source/effects.h b/Source/effects.h index 20d52c7a9c9..300bf145897 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -24,13 +24,12 @@ void sound_update(); void effects_update(); void effects_cleanup_sfx(); void stream_update(); -void priv_sound_init(UCHAR bLoadMask); +void priv_sound_init(BYTE bLoadMask); void sound_init(); void __stdcall effects_play_sound(char *snd_file); /* rdata */ -extern const int effects_inf; // weak extern const char monster_action_sounds[]; /* data */ diff --git a/Source/engine.cpp b/Source/engine.cpp index 219795e8e9e..14260e4a389 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -7,16 +7,16 @@ DEVILUTION_BEGIN_NAMESPACE #pragma warning(disable : 4731) // frame pointer register 'ebp' modified by inline assembly code #endif -char gbPixelCol; // automap pixel color 8-bit (palette entry) -int gbRotateMap; // BOOLEAN flip - if y < x -int orgseed; // weak +char gbPixelCol; // automap pixel color 8-bit (palette entry) +BOOL gbRotateMap; // flip - if y < x +int orgseed; int sgnWidth; -int sglGameSeed; // weak +int sglGameSeed; #ifdef __cplusplus static CCritSect sgMemCrit; #endif -int SeedCount; // weak -int gbNotInView; // BOOLEAN valid - if x/y are in bounds +int SeedCount; +BOOL gbNotInView; // valid - if x/y are in bounds const int rand_increment = 1; const int rand_multiplier = 0x015A4E35; @@ -390,7 +390,6 @@ void CelDecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } #endif } -// 69BEF8: using guessed type int light_table_index; void CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -578,7 +577,6 @@ void CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW } #endif } -// 69BEF8: using guessed type int light_table_index; void CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { @@ -604,7 +602,6 @@ void CelDecodeLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) else CelDrawDatOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -648,7 +645,6 @@ void CelDecodeHdrLightOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, else CelDrawDatOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -693,8 +689,6 @@ void CelDecodeHdrLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, i else CelDrawDatOnly(pBuff, pRLEBytes, nDataSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; -// 69CF94: using guessed type int cel_transparency_active; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -812,7 +806,6 @@ void CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in } #endif } -// 525728: using guessed type int light4flag; void Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -926,7 +919,6 @@ void Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } #endif } -// 69CF0C: using guessed type int gpBufEnd; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -1173,8 +1165,6 @@ void Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW } #endif } -// 69BEF8: using guessed type int light_table_index; -// 69CF0C: using guessed type int gpBufEnd; void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -1376,8 +1366,6 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n } #endif } -// 69BEF8: using guessed type int light_table_index; -// 69CF0C: using guessed type int gpBufEnd; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -1421,7 +1409,6 @@ void Cel2DecodeHdrLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in else Cel2DecDatOnly(pDecodeTo, pRLEBytes, nDataSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -1463,8 +1450,6 @@ void Cel2DecodeLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int else Cel2DecDatOnly(pBuff, pRLEBytes, nDataSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; -// 69CF94: using guessed type int cel_transparency_active; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -1589,8 +1574,6 @@ void Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i } #endif } -// 525728: using guessed type int light4flag; -// 69CF0C: using guessed type int gpBufEnd; void CelDecodeRect(BYTE *pBuff, int CelSkip, int hgt, int wdt, BYTE *pCelBuff, int nCel, int nWidth) { @@ -2031,7 +2014,6 @@ void CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWi } #endif } -// 69CF0C: using guessed type int gpBufEnd; void ENG_set_pixel(int sx, int sy, BYTE col) { @@ -2058,7 +2040,6 @@ void ENG_set_pixel(int sx, int sy, BYTE col) *dst = col; #endif } -// 69CF0C: using guessed type int gpBufEnd; void engine_draw_pixel(int sx, int sy) { @@ -2090,10 +2071,6 @@ void engine_draw_pixel(int sx, int sy) *dst = gbPixelCol; #endif } -// 52B96C: using guessed type char gbPixelCol; -// 52B970: using guessed type int gbRotateMap; -// 52B99C: using guessed type int gbNotInView; -// 69CF0C: using guessed type int gpBufEnd; // Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c // Except: @@ -2303,9 +2280,6 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col) } } } -// 52B96C: using guessed type char gbPixelCol; -// 52B970: using guessed type int gbRotateMap; -// 52B99C: using guessed type int gbNotInView; int GetDirection(int x1, int y1, int x2, int y2) { @@ -2353,9 +2327,6 @@ void SetRndSeed(int s) sglGameSeed = s; orgseed = s; } -// 52B974: using guessed type int orgseed; -// 52B97C: using guessed type int sglGameSeed; -// 52B998: using guessed type int SeedCount; int GetRndSeed() { @@ -2363,8 +2334,6 @@ int GetRndSeed() sglGameSeed = rand_multiplier * sglGameSeed + rand_increment; return abs(sglGameSeed); } -// 52B97C: using guessed type int sglGameSeed; -// 52B998: using guessed type int SeedCount; int random(BYTE idx, int v) { @@ -2390,7 +2359,7 @@ void engine_debug_trap(BOOL show_cursor) */ } -unsigned char *DiabloAllocPtr(int dwBytes) +BYTE *DiabloAllocPtr(DWORD dwBytes) { BYTE *buf; @@ -2422,7 +2391,7 @@ void mem_free_dbg(void *p) } } -BYTE *LoadFileInMem(char *pszName, int *pdwFileLen) +BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen) { HANDLE file; BYTE *buf; @@ -2944,7 +2913,6 @@ void Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel nWidth, &pLightTbl[idx]); } -// 525728: using guessed type int light4flag; void Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { @@ -3095,7 +3063,6 @@ void Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } #endif } -// 52B978: using guessed type int sgnWidth; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -3140,7 +3107,6 @@ void Cl2DecodeLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int else Cl2DecDatFrm1(pDecodeTo, pRLEBytes, nSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -3336,7 +3302,6 @@ void Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } #endif } -// 69CF0C: using guessed type int gpBufEnd; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -3381,7 +3346,6 @@ void Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid col); gpBufEnd += BUFFER_WIDTH; } -// 69CF0C: using guessed type int gpBufEnd; void Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { @@ -3555,7 +3519,6 @@ void Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, } #endif } -// 69CF0C: using guessed type int gpBufEnd; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -3608,7 +3571,6 @@ void Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel nWidth, &pLightTbl[idx]); } -// 525728: using guessed type int light4flag; void Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { @@ -3772,8 +3734,6 @@ void Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } #endif } -// 52B978: using guessed type int sgnWidth; -// 69CF0C: using guessed type int gpBufEnd; /** * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 @@ -3818,7 +3778,6 @@ void Cl2DecodeFrm6(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel else Cl2DecDatFrm4(pDecodeTo, pRLEBytes, nSize, nWidth); } -// 69BEF8: using guessed type int light_table_index; void PlayInGameMovie(char *pszMovie) { @@ -3830,6 +3789,5 @@ void PlayInGameMovie(char *pszMovie) PaletteFadeIn(8); drawpanflag = 255; } -// 52571C: using guessed type int drawpanflag; DEVILUTION_END_NAMESPACE diff --git a/Source/engine.h b/Source/engine.h index 74f038b79ce..ba29eb01e4a 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -5,11 +5,11 @@ //offset 0 //pCelBuff->pFrameTable[0] -extern char gbPixelCol; // automap pixel color 8-bit (palette entry) -extern int gbRotateMap; // bool flip - if y < x -extern int orgseed; // weak -extern int SeedCount; // weak -extern int gbNotInView; // bool valid - if x/y are in bounds +extern char gbPixelCol; // automap pixel color 8-bit (palette entry) +extern BOOL gbRotateMap; // flip - if y < x +extern int orgseed; +extern int SeedCount; +extern BOOL gbNotInView; // valid - if x/y are in bounds void CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth); void CelDecodeOnly(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth); @@ -41,9 +41,9 @@ void SetRndSeed(int s); int GetRndSeed(); int random(BYTE idx, int v); void engine_debug_trap(BOOL show_cursor); -unsigned char *DiabloAllocPtr(int dwBytes); +BYTE *DiabloAllocPtr(DWORD dwBytes); void mem_free_dbg(void *p); -BYTE *LoadFileInMem(char *pszName, int *pdwFileLen); +BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen); DWORD LoadFileWithMem(const char *pszName, void *p); void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel); void Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap); @@ -64,7 +64,6 @@ void PlayInGameMovie(char *pszMovie); /* rdata */ -extern const int engine_inf; // weak extern const int rand_increment; // unused extern const int rand_multiplier; // unused diff --git a/Source/fault.h b/Source/fault.h index ec669c7ac48..beb2e61ab5b 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -18,7 +18,7 @@ void fault_hex_format(BYTE *ptr, unsigned int numBytes); void fault_unknown_module(LPCVOID lpAddress, LPSTR lpModuleName, int iMaxLength, int *sectionNum, int *sectionOffset); void fault_call_stack(void *instr, STACK_FRAME *stackAddr); char *fault_get_error_type(DWORD dwMessageId, LPSTR lpString1, DWORD nSize); -void * fault_set_filter(void *unused); +void *fault_set_filter(void *unused); LPTOP_LEVEL_EXCEPTION_FILTER fault_reset_filter(void *unused); LPTOP_LEVEL_EXCEPTION_FILTER fault_get_filter(); diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 35d3da3fb4e..dbb5aaf8828 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -10,7 +10,7 @@ int dMonster[MAXDUNX][MAXDUNY]; BYTE dungeon[DMAXX][DMAXY]; char dObject[MAXDUNX][MAXDUNY]; BYTE *pSpeedCels; -int nlevel_frames; // weak +int nlevel_frames; char pdungeon[DMAXX][DMAXY]; char dDead[MAXDUNX][MAXDUNY]; MICROS dpiece_defs_map_1[MAXDUNX * MAXDUNY]; @@ -20,17 +20,17 @@ int MicroTileLen; char dflags[DMAXX][DMAXY]; int dPiece[MAXDUNX][MAXDUNY]; char dLight[MAXDUNX][MAXDUNY]; -int setloadflag_2; // weak +int setloadflag_2; int tile_defs[MAXTILES]; BYTE *pMegaTiles; BYTE *pLevelPieces; -int gnDifficulty; // idb +int gnDifficulty; char block_lvid[2049]; //char byte_5B78EB; char dTransVal[MAXDUNX][MAXDUNY]; BOOLEAN nTrapTable[2049]; BYTE leveltype; -unsigned char currlevel; // idb +BYTE currlevel; char TransList[256]; BOOLEAN nSolidTable[2049]; int level_frame_count[MAXTILES]; @@ -39,10 +39,10 @@ BYTE *pDungeonCels; int SpeedFrameTbl[128][16]; 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 +int dword_5C2FF8; +int dword_5C2FFC; +int scr_pix_width; +int scr_pix_height; char dArch[MAXDUNX][MAXDUNY]; char nBlockTable[2049]; BYTE *pSpecialCels; @@ -52,28 +52,28 @@ BYTE setlvlnum; int level_frame_sizes[MAXTILES]; char nMissileTable[2049]; char *pSetPiece_2; -char setlvltype; // weak +char setlvltype; BOOLEAN setlevel; -int LvlViewY; // weak -int LvlViewX; // weak -int dmaxx; // weak -int dmaxy; // weak -int setpc_h; // weak -int setpc_w; // weak -int setpc_x; // idb -int ViewX; // idb -int ViewY; // idb -int setpc_y; // idb +int LvlViewY; +int LvlViewX; +int dmaxx; +int dmaxy; +int setpc_h; +int setpc_w; +int setpc_x; +int ViewX; +int ViewY; +int setpc_y; char dMissile[MAXDUNX][MAXDUNY]; -int dminx; // weak -int dminy; // weak +int dminx; +int dminy; MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY]; void FillSolidBlockTbls() { - unsigned char bv; - unsigned int dwTiles; - unsigned char *pSBFile, *pTmp; + BYTE bv; + DWORD dwTiles; + BYTE *pSBFile, *pTmp; int i; memset(nBlockTable, 0, sizeof(nBlockTable)); @@ -84,19 +84,19 @@ void FillSolidBlockTbls() switch (leveltype) { case DTYPE_TOWN: - pSBFile = LoadFileInMem("Levels\\TownData\\Town.SOL", (int *)&dwTiles); + pSBFile = LoadFileInMem("Levels\\TownData\\Town.SOL", &dwTiles); break; case DTYPE_CATHEDRAL: - pSBFile = LoadFileInMem("Levels\\L1Data\\L1.SOL", (int *)&dwTiles); + pSBFile = LoadFileInMem("Levels\\L1Data\\L1.SOL", &dwTiles); break; case DTYPE_CATACOMBS: - pSBFile = LoadFileInMem("Levels\\L2Data\\L2.SOL", (int *)&dwTiles); + pSBFile = LoadFileInMem("Levels\\L2Data\\L2.SOL", &dwTiles); break; case DTYPE_CAVES: - pSBFile = LoadFileInMem("Levels\\L3Data\\L3.SOL", (int *)&dwTiles); + pSBFile = LoadFileInMem("Levels\\L3Data\\L3.SOL", &dwTiles); break; case DTYPE_HELL: - pSBFile = LoadFileInMem("Levels\\L4Data\\L4.SOL", (int *)&dwTiles); + pSBFile = LoadFileInMem("Levels\\L4Data\\L4.SOL", &dwTiles); break; default: app_fatal("FillSolidBlockTbls"); @@ -447,8 +447,6 @@ void MakeSpeedCels() } } } -// 525728: using guessed type int light4flag; -// 53CD4C: using guessed type int nlevel_frames; void SortTiles(int frames) { @@ -555,11 +553,6 @@ void SetDungeonMicros() dword_5C2FFC = 7; } } -// 52569C: using guessed type int zoomflag; -// 5C2FF8: using guessed type int dword_5C2FF8; -// 5C2FFC: using guessed type int dword_5C2FFC; -// 5C3000: using guessed type int scr_pix_width; -// 5C3004: using guessed type int scr_pix_height; void DRLG_InitTrans() { @@ -567,7 +560,6 @@ void DRLG_InitTrans() memset(TransList, 0, sizeof(TransList)); TransVal = 1; } -// 5A5590: using guessed type char TransVal; void DRLG_MRectTrans(int x1, int y1, int x2, int y2) { @@ -586,7 +578,6 @@ void DRLG_MRectTrans(int x1, int y1, int x2, int y2) TransVal++; } -// 5A5590: using guessed type char TransVal; void DRLG_RectTrans(int x1, int y1, int x2, int y2) { @@ -599,17 +590,16 @@ void DRLG_RectTrans(int x1, int y1, int x2, int y2) } TransVal++; } -// 5A5590: using guessed type char TransVal; void DRLG_CopyTrans(int sx, int sy, int dx, int dy) { dTransVal[dx][dy] = dTransVal[sx][sy]; } -void DRLG_ListTrans(int num, unsigned char *List) +void DRLG_ListTrans(int num, BYTE *List) { int i; - unsigned char x1, x2, y1, y2; + BYTE x1, x2, y1, y2; for (i = 0; i < num; i++) { x1 = *List++; @@ -620,10 +610,10 @@ void DRLG_ListTrans(int num, unsigned char *List) } } -void DRLG_AreaTrans(int num, unsigned char *List) +void DRLG_AreaTrans(int num, BYTE *List) { int i; - unsigned char x1, x2, y1, y2; + BYTE x1, x2, y1, y2; for (i = 0; i < num; i++) { x1 = *List++; @@ -635,7 +625,6 @@ void DRLG_AreaTrans(int num, unsigned char *List) } ++TransVal; } -// 5A5590: using guessed type char TransVal; void DRLG_InitSetPC() { @@ -644,8 +633,6 @@ void DRLG_InitSetPC() setpc_w = 0; setpc_h = 0; } -// 5CF330: using guessed type int setpc_h; -// 5CF334: using guessed type int setpc_w; void DRLG_SetPC() { @@ -662,8 +649,6 @@ void DRLG_SetPC() } } } -// 5CF330: using guessed type int setpc_h; -// 5CF334: using guessed type int setpc_w; void Make_SetPC(int x, int y, int w, int h) { @@ -694,6 +679,7 @@ BOOL DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, in xCount = 0; yCount = 0; + // BUGFIX: change '&&' to '||' if (x > DMAXX - maxSize && y > DMAXY - maxSize) { return FALSE; } @@ -764,8 +750,6 @@ BOOL DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, in *height = ySmallest - 2; return TRUE; } -// 41965B: using guessed type int var_6C[20]; -// 41965B: using guessed type int var_BC[20]; void DRLG_CreateThemeRoom(int themeIndex) { @@ -971,7 +955,5 @@ void InitLevels() setlevel = 0; } } -// 52572C: using guessed type int leveldebug; -// 5CF31D: using guessed type char setlevel; DEVILUTION_END_NAMESPACE diff --git a/Source/gendung.h b/Source/gendung.h index e2c4afe9f53..742101daec4 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -10,27 +10,27 @@ extern int dMonster[MAXDUNX][MAXDUNY]; extern BYTE dungeon[DMAXX][DMAXY]; extern char dObject[MAXDUNX][MAXDUNY]; extern BYTE *pSpeedCels; -extern int nlevel_frames; // weak +extern int nlevel_frames; extern char pdungeon[DMAXX][DMAXY]; extern char dDead[MAXDUNX][MAXDUNY]; extern MICROS dpiece_defs_map_1[MAXDUNX * MAXDUNY]; extern char dPreLight[MAXDUNX][MAXDUNY]; -extern char TransVal; // weak +extern char TransVal; extern int MicroTileLen; extern char dflags[DMAXX][DMAXY]; extern int dPiece[MAXDUNX][MAXDUNY]; extern char dLight[MAXDUNX][MAXDUNY]; -extern int setloadflag_2; // weak +extern int setloadflag_2; extern int tile_defs[MAXTILES]; extern BYTE *pMegaTiles; extern BYTE *pLevelPieces; -extern int gnDifficulty; // idb +extern int gnDifficulty; extern char block_lvid[2049]; //char byte_5B78EB; extern char dTransVal[MAXDUNX][MAXDUNY]; extern BOOLEAN nTrapTable[2049]; extern BYTE leveltype; -extern unsigned char currlevel; // idb +extern BYTE currlevel; extern char TransList[256]; extern BOOLEAN nSolidTable[2049]; extern int level_frame_count[MAXTILES]; @@ -39,10 +39,10 @@ extern BYTE *pDungeonCels; extern int SpeedFrameTbl[128][16]; 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 int dword_5C2FF8; +extern int dword_5C2FFC; +extern int scr_pix_width; +extern int scr_pix_height; extern char dArch[MAXDUNX][MAXDUNY]; extern char nBlockTable[2049]; extern BYTE *pSpecialCels; @@ -52,21 +52,21 @@ extern BYTE setlvlnum; extern int level_frame_sizes[MAXTILES]; extern char nMissileTable[2049]; extern char *pSetPiece_2; -extern char setlvltype; // weak +extern char setlvltype; extern BOOLEAN setlevel; -extern int LvlViewY; // weak -extern int LvlViewX; // weak -extern int dmaxx; // weak -extern int dmaxy; // weak -extern int setpc_h; // weak -extern int setpc_w; // weak -extern int setpc_x; // idb -extern int ViewX; // idb -extern int ViewY; // idb -extern int setpc_y; // idb +extern int LvlViewY; +extern int LvlViewX; +extern int dmaxx; +extern int dmaxy; +extern int setpc_h; +extern int setpc_w; +extern int setpc_x; +extern int ViewX; +extern int ViewY; +extern int setpc_y; extern char dMissile[MAXDUNX][MAXDUNY]; -extern int dminx; // weak -extern int dminy; // weak +extern int dminx; +extern int dminy; extern MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY]; void FillSolidBlockTbls(); @@ -80,8 +80,8 @@ void DRLG_InitTrans(); void DRLG_MRectTrans(int x1, int y1, int x2, int y2); void DRLG_RectTrans(int x1, int y1, int x2, int y2); void DRLG_CopyTrans(int sx, int sy, int dx, int dy); -void DRLG_ListTrans(int num, unsigned char *List); -void DRLG_AreaTrans(int num, unsigned char *List); +void DRLG_ListTrans(int num, BYTE *List); +void DRLG_AreaTrans(int num, BYTE *List); void DRLG_InitSetPC(); void DRLG_SetPC(); void Make_SetPC(int x, int y, int w, int h); diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 03e11f04a9f..4dd26c8aaba 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -15,7 +15,7 @@ BYTE *option_cel; BYTE *sgpLogo; int sgCurrentMenuIdx; -const unsigned char lfontframe[127] = { +const BYTE lfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -30,7 +30,7 @@ const unsigned char lfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0 }; -const unsigned char lfontkern[56] = { +const BYTE lfontkern[56] = { 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, 28, 36, 35, 46, 33, 33, 24, 11, 23, 22, @@ -79,11 +79,11 @@ void gmenu_init_menu() dword_63447C = 0; sgCurrentMenuIdx = 0; mouseNavigation = FALSE; - sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", 0); - BigTGold_cel = LoadFileInMem("Data\\BigTGold.CEL", 0); - PentSpin_cel = LoadFileInMem("Data\\PentSpin.CEL", 0); - option_cel = LoadFileInMem("Data\\option.CEL", 0); - optbar_cel = LoadFileInMem("Data\\optbar.CEL", 0); + sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", NULL); + BigTGold_cel = LoadFileInMem("Data\\BigTGold.CEL", NULL); + PentSpin_cel = LoadFileInMem("Data\\PentSpin.CEL", NULL); + option_cel = LoadFileInMem("Data\\option.CEL", NULL); + optbar_cel = LoadFileInMem("Data\\optbar.CEL", NULL); } BOOL gmenu_exception() diff --git a/Source/gmenu.h b/Source/gmenu.h index 4a0c2ca44a9..c4ac6da3f86 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -3,22 +3,22 @@ #define __GMENU_H__ extern BYTE *optbar_cel; -extern BOOLEAN mouseNavigation; // weak +extern BOOLEAN mouseNavigation; extern BYTE *PentSpin_cel; extern BYTE *BigTGold_cel; -extern int dword_634474; // weak -extern char byte_634478; // weak -extern void(*dword_63447C)(TMenuItem *); -extern TMenuItem *sgpCurrentMenu; // idb +extern int dword_634474; +extern char byte_634478; +extern void (*dword_63447C)(TMenuItem *); +extern TMenuItem *sgpCurrentMenu; extern BYTE *option_cel; -extern int sgCurrentMenuIdx; // weak +extern int sgCurrentMenuIdx; void gmenu_draw_pause(); void gmenu_print_text(int x, int y, char *pszStr); void FreeGMenu(); void gmenu_init_menu(); BOOL gmenu_exception(); -void gmenu_call_proc(TMenuItem *pItem, void(*gmFunc)(TMenuItem *)); +void gmenu_call_proc(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)); void gmenu_up_down(BOOL isDown); void gmenu_draw(); void gmenu_draw_menu_item(TMenuItem *pItem, int a2); @@ -36,7 +36,7 @@ void gmenu_slider_steps(TMenuItem *pItem, int dwTicks); /* rdata */ -extern const unsigned char lfontframe[127]; -extern const unsigned char lfontkern[56]; +extern const BYTE lfontframe[127]; +extern const BYTE lfontkern[56]; #endif /* __GMENU_H__ */ diff --git a/Source/init.cpp b/Source/init.cpp index 5da55a72e61..43555e3b5b5 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -5,7 +5,7 @@ DEVILUTION_BEGIN_NAMESPACE _SNETVERSIONDATA fileinfo; -int gbActive; // weak +int gbActive; char diablo_exe_path[MAX_PATH]; HANDLE unused_mpq; char patch_rt_mpq_path[MAX_PATH]; @@ -13,7 +13,7 @@ WNDPROC CurrentProc; HANDLE diabdat_mpq; char diabdat_mpq_path[MAX_PATH]; HANDLE patch_rt_mpq; -BOOL killed_mom_parent; // weak +BOOL killed_mom_parent; BOOLEAN screensaver_enabled_prev; /* data */ @@ -69,7 +69,6 @@ void init_run_office_from_start_menu() init_run_office(szPath); } } -// 634CA0: using guessed type int killed_mom_parent; void init_run_office(char *dir) { @@ -112,28 +111,25 @@ void init_run_office(char *dir) void init_disable_screensaver(BOOLEAN disable) { - BOOLEAN v1; // al - char Data[16]; // [esp+4h] [ebp-20h] - DWORD Type; // [esp+14h] [ebp-10h] - DWORD cbData; // [esp+18h] [ebp-Ch] - HKEY phkResult; // [esp+1Ch] [ebp-8h] - BOOLEAN v6; // [esp+20h] [ebp-4h] + BOOLEAN enabled; + char Data[16]; + DWORD Type, cbData; + HKEY phkResult; // BUGFIX: this is probably the worst possible way to do this. Alternatives: ExtEscape() with SETPOWERMANAGEMENT, // SystemParametersInfo() with SPI_SETSCREENSAVEACTIVE/SPI_SETPOWEROFFACTIVE/SPI_SETLOWPOWERACTIVE - v6 = disable; if (!RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ | KEY_WRITE, (PHKEY)&phkResult)) { - if (v6) { + if (disable) { cbData = 16; if (!RegQueryValueEx(phkResult, "ScreenSaveActive", 0, &Type, (LPBYTE)Data, &cbData)) screensaver_enabled_prev = Data[0] != '0'; - v1 = 0; + enabled = FALSE; } else { - v1 = screensaver_enabled_prev; + enabled = screensaver_enabled_prev; } Data[1] = 0; - Data[0] = (v1 != 0) + '0'; + Data[0] = enabled ? '1' : '0'; RegSetValueEx(phkResult, "ScreenSaveActive", 0, REG_SZ, (const BYTE *)Data, 2u); RegCloseKey(phkResult); } @@ -183,31 +179,29 @@ void init_create_window(int nCmdShow) void init_kill_mom_parent() { - HWND v0; // eax + HWND handle; - v0 = init_find_mom_parent(); - if (v0) { - PostMessage(v0, WM_CLOSE, 0, 0); + handle = init_find_mom_parent(); + if (handle) { + PostMessage(handle, WM_CLOSE, 0, 0); killed_mom_parent = TRUE; } } -// 634CA0: using guessed type int killed_mom_parent; HWND init_find_mom_parent() { - HWND i; // eax - HWND v1; // esi - char ClassName[256]; // [esp+4h] [ebp-100h] + HWND i, handle; + char ClassName[256]; - for (i = GetForegroundWindow();; i = GetWindow(v1, GW_HWNDNEXT)) { - v1 = i; + for (i = GetForegroundWindow();; i = GetWindow(handle, GW_HWNDNEXT)) { + handle = i; if (!i) break; GetClassName(i, ClassName, 255); if (!_strcmpi(ClassName, "MOM Parent")) break; } - return v1; + return handle; } void init_await_mom_parent_exit() @@ -314,7 +308,7 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags char *init_strip_trailing_slash(char *path) { - char *result; // eax + char *result; result = strrchr(path, '\\'); if (result) { @@ -358,20 +352,18 @@ BOOL init_read_test_file(char *pszPath, char *pszArchive, int flags, HANDLE *phA void init_get_file_info() { - int v0; // eax - DWORD v1; // edi - void *v2; // ebx - unsigned int uBytes; // [esp+8h] [ebp-Ch] - DWORD dwHandle; // [esp+Ch] [ebp-8h] - VS_FIXEDFILEINFO *lpBuffer; // [esp+10h] [ebp-4h] + DWORD dwLen; + void *pBlock; + unsigned int uBytes; + DWORD dwHandle; + VS_FIXEDFILEINFO *lpBuffer; if (GetModuleFileName(ghInst, diablo_exe_path, sizeof(diablo_exe_path))) { - v0 = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); - v1 = v0; - if (v0) { - v2 = DiabloAllocPtr(v0); - if (GetFileVersionInfo(diablo_exe_path, 0, v1, v2)) { - if (VerQueryValue(v2, "\\", (LPVOID *)&lpBuffer, &uBytes)) + dwLen = GetFileVersionInfoSize(diablo_exe_path, &dwHandle); + if (dwLen) { + pBlock = DiabloAllocPtr(dwLen); + if (GetFileVersionInfo(diablo_exe_path, 0, dwLen, pBlock)) { + if (VerQueryValue(pBlock, "\\", (LPVOID *)&lpBuffer, &uBytes)) sprintf( gszVersionNumber, "version %d.%d.%d.%d", @@ -380,7 +372,7 @@ void init_get_file_info() lpBuffer->dwProductVersionLS >> 16, lpBuffer->dwProductVersionLS & 0xFFFF); } - mem_free_dbg(v2); + mem_free_dbg(pBlock); } } } @@ -417,11 +409,10 @@ LRESULT __stdcall MainWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hWnd, Msg, wParam, lParam); } -// 52571C: using guessed type int drawpanflag; void init_activate_window(HWND hWnd, BOOL bActive) { - LONG dwNewLong; // eax + LONG dwNewLong; gbActive = bActive; UiAppActivate(bActive); @@ -439,23 +430,18 @@ void init_activate_window(HWND hWnd, BOOL bActive) ResetPal(); } } -// 52571C: using guessed type int drawpanflag; -// 634980: using guessed type int gbActive; LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - LRESULT result; // eax - if (CurrentProc) - result = CurrentProc(hWnd, Msg, wParam, lParam); - else - result = MainWndProc(hWnd, Msg, wParam, lParam); - return result; + return CurrentProc(hWnd, Msg, wParam, lParam); + + return MainWndProc(hWnd, Msg, wParam, lParam); } WNDPROC SetWindowProc(WNDPROC NewProc) { - WNDPROC OldProc; // eax + WNDPROC OldProc; OldProc = CurrentProc; CurrentProc = NewProc; diff --git a/Source/init.h b/Source/init.h index 7b7a46ac92c..5478888972e 100644 --- a/Source/init.h +++ b/Source/init.h @@ -33,7 +33,6 @@ LRESULT __stdcall WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); WNDPROC SetWindowProc(WNDPROC NewProc); /* rdata */ -extern const int init_inf; // weak /* data */ diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 276e7f50ecd..9c74011def2 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -249,38 +249,38 @@ void InitCutscene(unsigned int uMsg) case WM_DIABNEXTLVL: switch (gnLevelTypeTbl[currlevel]) { case 0: - sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", NULL); LoadPalette("Gendata\\Cuttt.pal"); progress_id = 1; break; case 1: - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; break; case 2: - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", NULL); LoadPalette("Gendata\\Cut2.pal"); progress_id = 2; break; case 3: - sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", NULL); LoadPalette("Gendata\\Cut3.pal"); progress_id = 1; break; case 4: if (currlevel < 15) { - sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", NULL); LoadPalette("Gendata\\Cut4.pal"); progress_id = 1; } else { - sgpBackCel = LoadFileInMem("Gendata\\Cutgate.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutgate.CEL", NULL); LoadPalette("Gendata\\Cutgate.pal"); progress_id = 1; } break; default: - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; break; @@ -288,38 +288,38 @@ void InitCutscene(unsigned int uMsg) break; case WM_DIABPREVLVL: if (gnLevelTypeTbl[currlevel - 1] == 0) { - sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", NULL); LoadPalette("Gendata\\Cuttt.pal"); progress_id = 1; } else { switch (gnLevelTypeTbl[currlevel]) { case 0: - sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", NULL); LoadPalette("Gendata\\Cuttt.pal"); progress_id = 1; break; case 1: - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; break; case 2: - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", NULL); LoadPalette("Gendata\\Cut2.pal"); progress_id = 2; break; case 3: - sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", NULL); LoadPalette("Gendata\\Cut3.pal"); progress_id = 1; break; case 4: - sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", NULL); LoadPalette("Gendata\\Cut4.pal"); progress_id = 1; break; default: - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; break; @@ -328,46 +328,46 @@ void InitCutscene(unsigned int uMsg) break; case WM_DIABSETLVL: if (setlvlnum == SL_BONECHAMB) { - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", NULL); LoadPalette("Gendata\\Cut2.pal"); progress_id = 2; } else if (setlvlnum == SL_VILEBETRAYER) { - sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", NULL); LoadPalette("Gendata\\Cutportr.pal"); progress_id = 1; } else { - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; } break; case WM_DIABRTNLVL: if (setlvlnum == SL_BONECHAMB) { - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", NULL); LoadPalette("Gendata\\Cut2.pal"); progress_id = 2; } else if (setlvlnum == SL_VILEBETRAYER) { - sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", NULL); LoadPalette("Gendata\\Cutportr.pal"); progress_id = 1; } else { - sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutl1d.CEL", NULL); LoadPalette("Gendata\\Cutl1d.pal"); progress_id = 0; } break; case WM_DIABWARPLVL: - sgpBackCel = LoadFileInMem("Gendata\\Cutportl.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutportl.CEL", NULL); LoadPalette("Gendata\\Cutportl.pal"); progress_id = 1; break; case WM_DIABLOADGAME: - sgpBackCel = LoadFileInMem("Gendata\\Cutstart.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutstart.CEL", NULL); LoadPalette("Gendata\\Cutstart.pal"); progress_id = 1; break; case WM_DIABNEWGAME: - sgpBackCel = LoadFileInMem("Gendata\\Cutstart.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cutstart.CEL", NULL); LoadPalette("Gendata\\Cutstart.pal"); progress_id = 1; break; @@ -375,29 +375,29 @@ void InitCutscene(unsigned int uMsg) case WM_DIABTWARPUP: switch (gnLevelTypeTbl[plr[myplr].plrlevel]) { case 0: - sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", NULL); LoadPalette("Gendata\\Cuttt.pal"); progress_id = 1; break; case 2: - sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", NULL); LoadPalette("Gendata\\Cut2.pal"); progress_id = 2; break; case 3: - sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut3.CEL", NULL); LoadPalette("Gendata\\Cut3.pal"); progress_id = 1; break; case 4: - sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", NULL); LoadPalette("Gendata\\Cut4.pal"); progress_id = 1; break; } break; case WM_DIABRETOWN: - sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); + sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", NULL); LoadPalette("Gendata\\Cuttt.pal"); progress_id = 1; break; diff --git a/Source/interfac.h b/Source/interfac.h index d093f69fa35..7686471b696 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -14,7 +14,6 @@ void InitCutscene(unsigned int uMsg); /* rdata */ -extern const int interfac_inf; // weak extern const unsigned char progress_bar_colours[3]; extern const int progress_bar_screen_pos[3][2]; diff --git a/Source/inv.cpp b/Source/inv.cpp index 9cde50b3d33..073ae65fe38 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -88,7 +88,7 @@ const InvXY InvRect[73] = { /* data */ -int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak +int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; void FreeInvGFX() { @@ -98,11 +98,11 @@ void FreeInvGFX() void InitInv() { if (plr[myplr]._pClass == PC_WARRIOR) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", 0); + pInvCels = LoadFileInMem("Data\\Inv\\Inv.CEL", NULL); } else if (plr[myplr]._pClass == PC_ROGUE) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", 0); + pInvCels = LoadFileInMem("Data\\Inv\\Inv_rog.CEL", NULL); } else if (plr[myplr]._pClass == PC_SORCERER) { - pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", 0); + pInvCels = LoadFileInMem("Data\\Inv\\Inv_Sor.CEL", NULL); } invflag = 0; @@ -409,10 +409,6 @@ void DrawInv() } } } -// 4B8CB8: using guessed type char pcursinvitem; -// 69BEF8: using guessed type int light_table_index; -// 69CF94: using guessed type int cel_transparency_active; -// 41B8C4: using guessed type int var_A0[40]; void DrawInvBelt() { @@ -457,8 +453,6 @@ void DrawInvBelt() } } } -// 4B8960: using guessed type int talkflag; -// 4B8CB8: using guessed type char pcursinvitem; BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag) { @@ -647,7 +641,7 @@ BOOL GoldAutoPlace(int pnum) return done; } -int WeaponAutoPlace(int pnum) +BOOL WeaponAutoPlace(int pnum) { if (plr[pnum].HoldItem._iLoc != ILOC_TWOHAND) { if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON) @@ -1466,7 +1460,6 @@ void CheckQuestItem(int pnum) } } } -// 52A554: using guessed type int sfxdelay; void InvGetItem(int pnum, int ii) { @@ -1499,7 +1492,6 @@ void InvGetItem(int pnum, int ii) SetCursor_(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); } } -// 4B8CC0: using guessed type char pcursitem; void AutoGetItem(int pnum, int ii) { @@ -1630,9 +1622,8 @@ void AutoGetItem(int pnum, int ii) plr[pnum].HoldItem._itype = ITYPE_NONE; } } -// 48E9A8: using guessed type int AP2x2Tbl[10]; -int FindGetItem(int indx, WORD ci, int iseed) +int FindGetItem(int idx, WORD ci, int iseed) { int i, ii; @@ -1642,7 +1633,7 @@ int FindGetItem(int indx, WORD ci, int iseed) while (1) { ii = itemactive[i]; - if (item[ii].IDidx == indx && item[ii]._iSeed == iseed && item[ii]._iCreateInfo == ci) + if (item[ii].IDidx == idx && item[ii]._iSeed == iseed && item[ii]._iCreateInfo == ci) break; i++; @@ -1827,7 +1818,7 @@ int InvPutItem(int pnum, int x, int y) return ii; } -int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff) +int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, DWORD ibuff) { BOOL done; int d, ii; @@ -1993,7 +1984,6 @@ char CheckInvHLight() return rv; } -// 4B883C: using guessed type int infoclr; void RemoveScroll(int pnum) { @@ -2083,8 +2073,6 @@ void StartGoldDrop() if (talkflag) control_reset_talk(); } -// 4B8960: using guessed type int talkflag; -// 4B8CB8: using guessed type char pcursinvitem; BOOL UseInvItem(int pnum, int cii) { @@ -2183,9 +2171,6 @@ BOOL UseInvItem(int pnum, int cii) return TRUE; } -// 4B8960: using guessed type int talkflag; -// 52A554: using guessed type int sfxdelay; -// 6AA705: using guessed type char stextflag; void DoTelekinesis() { @@ -2197,8 +2182,6 @@ void DoTelekinesis() NetSendCmdParam1(TRUE, CMD_KNOCKBACK, pcursmonst); SetCursor_(CURSOR_HAND); } -// 4B8CC0: using guessed type char pcursitem; -// 4B8CC1: using guessed type char pcursobj; int CalculateGold(int pnum) { @@ -2218,7 +2201,6 @@ int CalculateGold(int pnum) return gold; } -// 52571C: using guessed type int drawpanflag; BOOL DropItemBeforeTrig() { diff --git a/Source/inv.h b/Source/inv.h index 1c79e9b1278..0ef9c39cacf 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -13,7 +13,7 @@ void DrawInvBelt(); BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag); BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag); BOOL GoldAutoPlace(int pnum); -int WeaponAutoPlace(int pnum); +BOOL WeaponAutoPlace(int pnum); int SwapItem(ItemStruct *a, ItemStruct *b); void CheckInvPaste(int pnum, int mx, int my); void CheckInvSwap(int pnum, BYTE bLoc, int idx, WORD wCI, int seed, BOOL bId); @@ -28,13 +28,13 @@ void CheckBookLevel(int pnum); void CheckQuestItem(int pnum); void InvGetItem(int pnum, int ii); void AutoGetItem(int pnum, int ii); -int FindGetItem(int indx, WORD ci, int iseed); +int FindGetItem(int idx, WORD ci, int iseed); void SyncGetItem(int x, int y, int idx, WORD ci, int iseed); BOOL CanPut(int x, int y); BOOL TryInvPut(); void DrawInvMsg(char *msg); int InvPutItem(int pnum, int x, int y); -int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff); +int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, DWORD ibuff); char CheckInvHLight(); void RemoveScroll(int pnum); BOOL UseScroll(); @@ -48,6 +48,6 @@ BOOL DropItemBeforeTrig(); /* data */ -extern int AP2x2Tbl[10]; // weak +extern int AP2x2Tbl[10]; #endif /* __INV_H__ */ diff --git a/Source/itemdat.h b/Source/itemdat.h index 4641b5de192..00f17860884 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -1,10 +1,10 @@ -//HEADER_GOES_HERE -#ifndef __ITEMDAT_H__ -#define __ITEMDAT_H__ - -extern ItemDataStruct AllItemsList[157]; -extern const PLStruct PL_Prefix[84]; -extern const PLStruct PL_Suffix[96]; -extern const UItemStruct UniqueItemList[91]; - -#endif /* __ITEMDAT_H__ */ +//HEADER_GOES_HERE +#ifndef __ITEMDAT_H__ +#define __ITEMDAT_H__ + +extern ItemDataStruct AllItemsList[157]; +extern const PLStruct PL_Prefix[84]; +extern const PLStruct PL_Suffix[96]; +extern const UItemStruct UniqueItemList[91]; + +#endif /* __ITEMDAT_H__ */ diff --git a/Source/items.cpp b/Source/items.cpp index 9f40a6556a5..e67a9c6b32f 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -9,14 +9,14 @@ ItemStruct curruitem; ItemGetRecordStruct itemrecord[MAXITEMS]; ItemStruct item[MAXITEMS + 1]; BOOL itemhold[3][3]; -unsigned char *itemanims[35]; +BYTE *itemanims[35]; BOOL UniqueItemFlag[128]; int numitems; int gnNumGetRecords; /* data */ -unsigned char ItemCAnimTbl[169] = { +BYTE ItemCAnimTbl[169] = { 20, 16, 16, 16, 4, 4, 4, 12, 12, 12, 12, 12, 12, 12, 12, 21, 21, 25, 12, 28, 28, 28, 0, 0, 0, 32, 0, 0, 0, 24, @@ -72,7 +72,7 @@ char *ItemDropStrs[35] = { "Fanvil", "FLazStaf" }; -unsigned char ItemAnimLs[35] = { +BYTE ItemAnimLs[35] = { 15u, 13u, 16u, @@ -183,7 +183,7 @@ int ItemInvSnds[35] = { IS_IANVL, IS_ISTAF }; -int idoppely = 16; // weak +int idoppely = 16; int premiumlvladd[6] = { -1, -1, 0, 0, 1, 2 }; void InitItemGFX() @@ -193,7 +193,7 @@ void InitItemGFX() for (i = 0; i < 35; i++) { sprintf(arglist, "Items\\%s.CEL", ItemDropStrs[i]); - itemanims[i] = LoadFileInMem(arglist, 0); + itemanims[i] = LoadFileInMem(arglist, NULL); } memset(UniqueItemFlag, 0, sizeof(UniqueItemFlag)); } @@ -629,13 +629,13 @@ void CalcPlrScrolls(int p) } } -void CalcPlrStaff(int pnum) +void CalcPlrStaff(int p) { - plr[pnum]._pISpells = 0; - if (plr[pnum].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE - && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iStatFlag - && plr[pnum].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { - plr[pnum]._pISpells |= (__int64)1 << (plr[pnum].InvBody[INVLOC_HAND_LEFT]._iSpell - 1); + plr[p]._pISpells = 0; + if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE + && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag + && plr[p].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) { + plr[p]._pISpells |= (__int64)1 << (plr[p].InvBody[INVLOC_HAND_LEFT]._iSpell - 1); } } @@ -1652,7 +1652,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood) pre = random(23, 4); post = random(23, 3); - if (pre && !post) { + if (pre != 0 && post == 0) { if (random(23, 2)) post = 1; else @@ -1694,7 +1694,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood) goe = PL_Prefix[preidx].PLGOE; } } - if (post) { + if (post != 0) { nl = 0; for (j = 0; PL_Suffix[j].PLPower != -1; j++) { if (PL_Suffix[j].PLIType & flgs @@ -1735,7 +1735,6 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood) if (preidx != -1 || sufidx != -1) CalcItemValue(i); } -// 4215EF: using guessed type int var_494[256]; void GetItemBonus(int i, int idata, int minlvl, int maxlvl, int onlygood) { @@ -2220,14 +2219,14 @@ void CreateTypeItem(int x, int y, BOOL onlygood, int itype, int imisc, BOOL send } } -void RecreateItem(int ii, int idx, unsigned short ic, int iseed, int ivalue) +void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue) { int uper, onlygood, recreate, pregen; if (!idx) { SetPlrHandItem(&item[ii], IDI_GOLD); item[ii]._iSeed = iseed; - item[ii]._iCreateInfo = ic; + item[ii]._iCreateInfo = icreateinfo; item[ii]._ivalue = ivalue; if (ivalue >= GOLD_MEDIUM_LIMIT) item[ii]._iCurs = ICURS_GOLD_LARGE; @@ -2236,36 +2235,36 @@ void RecreateItem(int ii, int idx, unsigned short ic, int iseed, int ivalue) else item[ii]._iCurs = ICURS_GOLD_MEDIUM; } else { - if (!ic) { + if (!icreateinfo) { SetPlrHandItem(&item[ii], idx); SetPlrHandSeed(&item[ii], iseed); } else { - if (ic & 0x7C00) { - RecreateTownItem(ii, idx, ic, iseed, ivalue); - } else if ((ic & 0x0180) == 0x0180) { - SetupAllUseful(ii, iseed, ic & 0x3F); + if (icreateinfo & 0x7C00) { + RecreateTownItem(ii, idx, icreateinfo, iseed, ivalue); + } else if ((icreateinfo & 0x0180) == 0x0180) { + SetupAllUseful(ii, iseed, icreateinfo & 0x3F); } else { uper = 0; onlygood = 0; recreate = 0; pregen = 0; - if (ic & 0x0100) + if (icreateinfo & 0x0100) uper = 1; - if (ic & 0x80) + if (icreateinfo & 0x80) uper = 15; - if (ic & 0x40) + if (icreateinfo & 0x40) onlygood = 1; - if (ic & 0x0200) + if (icreateinfo & 0x0200) recreate = 1; - if (ic & 0x8000) + if (icreateinfo & 0x8000) pregen = 1; - SetupAllItems(ii, idx, iseed, ic & 0x3F, uper, onlygood, recreate, pregen); + SetupAllItems(ii, idx, iseed, icreateinfo & 0x3F, uper, onlygood, recreate, pregen); } } } } -void RecreateEar(int ii, unsigned short ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff) +void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff) { SetPlrHandItem(&item[ii], IDI_EAR); tempstr[0] = (ic >> 8) & 0x7F; @@ -3785,29 +3784,29 @@ void SpawnStoreGold() golditem._iStatFlag = TRUE; } -void RecreateSmithItem(int ii, int idx, int plvl, int iseed) +void RecreateSmithItem(int ii, int idx, int lvl, int iseed) { int itype; SetRndSeed(iseed); - itype = RndSmithItem(plvl) - 1; - GetItemAttrs(ii, itype, plvl); + itype = RndSmithItem(lvl) - 1; + GetItemAttrs(ii, itype, lvl); - item[ii]._iCreateInfo = plvl | 0x400; + item[ii]._iCreateInfo = lvl | 0x400; item[ii]._iSeed = iseed; item[ii]._iIdentified = TRUE; } -void RecreatePremiumItem(int ii, int idx, int lvl, int iseed) +void RecreatePremiumItem(int ii, int idx, int plvl, int iseed) { int itype; SetRndSeed(iseed); - itype = RndPremiumItem(lvl >> 2, lvl) - 1; - GetItemAttrs(ii, itype, lvl); - GetItemBonus(ii, itype, lvl >> 1, lvl, 1); + itype = RndPremiumItem(plvl >> 2, plvl) - 1; + GetItemAttrs(ii, itype, plvl); + GetItemBonus(ii, itype, plvl >> 1, plvl, 1); - item[ii]._iCreateInfo = lvl | 0x800; + item[ii]._iCreateInfo = plvl | 0x800; item[ii]._iSeed = iseed; item[ii]._iIdentified = TRUE; } @@ -3865,7 +3864,7 @@ void RecreateHealerItem(int ii, int idx, int lvl, int iseed) item[ii]._iIdentified = TRUE; } -void RecreateTownItem(int ii, int idx, unsigned short icreateinfo, int iseed, int ivalue) +void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue) { if (icreateinfo & 0x400) RecreateSmithItem(ii, idx, icreateinfo & 0x3F, iseed); diff --git a/Source/items.h b/Source/items.h index 5010cd9a8ed..90ac1b8c80c 100644 --- a/Source/items.h +++ b/Source/items.h @@ -9,7 +9,7 @@ extern ItemStruct curruitem; extern ItemGetRecordStruct itemrecord[MAXITEMS]; extern ItemStruct item[MAXITEMS + 1]; extern BOOL itemhold[3][3]; -extern unsigned char *itemanims[35]; +extern BYTE *itemanims[35]; extern BOOL UniqueItemFlag[128]; extern int numitems; extern int gnNumGetRecords; @@ -20,7 +20,7 @@ void AddInitItems(); void InitItems(); void CalcPlrItemVals(int p, BOOL Loadgfx); void CalcPlrScrolls(int p); -void CalcPlrStaff(int pnum); +void CalcPlrStaff(int p); void CalcSelfItems(int pnum); void CalcPlrItemMin(int pnum); BOOL ItemMinStats(PlayerStruct *p, ItemStruct *x); @@ -62,8 +62,8 @@ void CreateRndItem(int x, int y, BOOL onlygood, BOOL sendmsg, int delta); void SetupAllUseful(int ii, int iseed, int lvl); void CreateRndUseful(int pnum, int x, int y, BOOL sendmsg); void CreateTypeItem(int x, int y, BOOL onlygood, int itype, int imisc, BOOL sendmsg, int delta); -void RecreateItem(int ii, int idx, unsigned short ic, int iseed, int ivalue); -void RecreateEar(int ii, unsigned short ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff); +void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue); +void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff); void SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag); void SpawnRock(); void RespawnItem(int i, BOOL FlipFlag); @@ -110,12 +110,12 @@ int RndHealerItem(int lvl); void SortHealer(); void SpawnHealer(int lvl); void SpawnStoreGold(); -void RecreateSmithItem(int ii, int idx, int plvl, int iseed); -void RecreatePremiumItem(int ii, int idx, int lvl, int iseed); +void RecreateSmithItem(int ii, int idx, int lvl, int iseed); +void RecreatePremiumItem(int ii, int idx, int plvl, int iseed); void RecreateBoyItem(int ii, int idx, int lvl, int iseed); void RecreateWitchItem(int ii, int idx, int lvl, int iseed); void RecreateHealerItem(int ii, int idx, int lvl, int iseed); -void RecreateTownItem(int ii, int idx, unsigned short icreateinfo, int iseed, int ivalue); +void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue); void RecalcStoreStats(); int ItemNoFlippy(); void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, int delta); @@ -128,12 +128,12 @@ void PutItemRecord(int nSeed, WORD wCI, int nIndex); /* data */ -extern unsigned char ItemCAnimTbl[169]; +extern BYTE ItemCAnimTbl[169]; extern char *ItemDropStrs[35]; -extern unsigned char ItemAnimLs[35]; +extern BYTE ItemAnimLs[35]; extern int ItemDropSnds[35]; extern int ItemInvSnds[35]; -extern int idoppely; // weak +extern int idoppely; extern int premiumlvladd[6]; #endif /* __ITEMS_H__ */ diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 136cc023d7e..4521cad567b 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -3,7 +3,7 @@ DEVILUTION_BEGIN_NAMESPACE LightListStruct VisionList[MAXVISION]; -unsigned char lightactive[MAXLIGHTS]; +BYTE lightactive[MAXLIGHTS]; LightListStruct LightList[MAXLIGHTS]; int numlights; BYTE lightradius[16][128]; @@ -402,7 +402,7 @@ char *pCrawlTable[19] = /* figure out what this is for */ CrawlTable + 2187, CrawlTable + 2460 }; -unsigned char vCrawlTable[23][30] = { +BYTE vCrawlTable[23][30] = { { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0 }, { 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1 }, { 1, 0, 2, 0, 3, 0, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 2, 13, 2, 14, 2, 15, 2 }, @@ -427,7 +427,7 @@ unsigned char vCrawlTable[23][30] = { { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15 }, { 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15 } }; -unsigned char byte_49463C[18][18] = /* unused */ +BYTE byte_49463C[18][18] = /* unused */ { { 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, { 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, @@ -449,7 +449,7 @@ unsigned char byte_49463C[18][18] = /* unused */ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } }; -unsigned char RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; +BYTE RadiusAdj[23] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0 }; void RotateRadius(int *x, int *y, int *dx, int *dy, int *lx, int *ly, int *bx, int *by) { @@ -725,7 +725,7 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible) break; } if (nCrawlX >= 0 && nCrawlX <= MAXDUNX && nCrawlY >= 0 && nCrawlY <= MAXDUNY) { - nBlockerFlag = (unsigned char)nBlockTable[dPiece[nCrawlX][nCrawlY]]; + nBlockerFlag = (BYTE)nBlockTable[dPiece[nCrawlX][nCrawlY]]; if (!nBlockTable[dPiece[x1adj + nCrawlX][y1adj + nCrawlY]] || !nBlockTable[dPiece[x2adj + nCrawlX][y2adj + nCrawlY]]) { if (doautomap) { @@ -878,13 +878,13 @@ void MakeLightTable() tbl += 224; } - trn = LoadFileInMem("PlrGFX\\Infra.TRN", 0); + trn = LoadFileInMem("PlrGFX\\Infra.TRN", NULL); for (i = 0; i < 256; i++) { *tbl++ = trn[i]; } mem_free_dbg(trn); - trn = LoadFileInMem("PlrGFX\\Stone.TRN", 0); + trn = LoadFileInMem("PlrGFX\\Stone.TRN", NULL); for (i = 0; i < 256; i++) { *tbl++ = trn[i]; } @@ -1099,7 +1099,7 @@ void ChangeLight(int i, int x, int y, int r) void ProcessLightList() { int i, j; - unsigned char temp; + BYTE temp; if (lightflag) { return; diff --git a/Source/lighting.h b/Source/lighting.h index 7f395f04ddc..b755bd6d5d1 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -3,7 +3,7 @@ #define __LIGHTING_H__ extern LightListStruct VisionList[MAXVISION]; -extern unsigned char lightactive[MAXLIGHTS]; +extern BYTE lightactive[MAXLIGHTS]; extern LightListStruct LightList[MAXLIGHTS]; extern int numlights; extern BYTE lightradius[16][128]; @@ -49,8 +49,8 @@ void lighting_color_cycling(); extern char CrawlTable[2749]; extern char *pCrawlTable[19]; -extern unsigned char vCrawlTable[23][30]; -extern unsigned char byte_49463C[18][18]; -extern unsigned char RadiusAdj[23]; +extern BYTE vCrawlTable[23][30]; +extern BYTE byte_49463C[18][18]; +extern BYTE RadiusAdj[23]; #endif /* __LIGHTING_H__ */ diff --git a/Source/list.h b/Source/list.h index ac45f39585e..2f095c6d59d 100644 --- a/Source/list.h +++ b/Source/list.h @@ -171,8 +171,8 @@ template class TLink { public: TLink() - : m_prevLink(NULL) - , m_nextNode(NULL) + : m_prevLink(NULL) + , m_nextNode(NULL) { } ~TLink() diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index e5180d911d2..c227c5b8f30 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -207,42 +207,537 @@ BOOL OLoad() return FALSE; } +void CopyInt(const void *src, void *dst) +{ + memcpy(dst, src, 4); + tbuff += 4; +} + +void CopyShort(const void *src, void *dst) +{ + memcpy(dst, src, 2); + tbuff += 2; +} + +void CopyShorts(const void *src, const int n, void *dst) +{ + memcpy(dst, src, 2 * n); + tbuff += 2 * n; +} + +void CopyInts(const void *src, const int n, void *dst) +{ + memcpy(dst, src, 4 * n); + tbuff += 4 * n; +} + +void CopyBytes(const void *src, const int n, void *dst) +{ + memcpy(dst, src, n); + tbuff += n; +} + +void CopyChar(const void *src, void *dst) +{ + memcpy(dst, src, 1); + tbuff += 1; +} + +void CopyInt64(const void *src, void *dst) +{ + memcpy(dst, src, 8); + tbuff += 8; +} + void LoadPlayer(int i) { - memcpy(&plr[i], tbuff, sizeof(*plr) - (10 * sizeof(void *))); - tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers + PlayerStruct *pPlayer = &plr[i]; + + CopyInt(tbuff, &pPlayer->_pmode); + + CopyBytes(tbuff, 25, pPlayer->walkpath); + CopyBytes(tbuff, 1, &pPlayer->plractive); + tbuff += 2; + + CopyInt(tbuff, &pPlayer->destAction); + CopyInt(tbuff, &pPlayer->destParam1); + CopyInt(tbuff, &pPlayer->destParam2); + CopyInt(tbuff, &pPlayer->destParam3); + CopyInt(tbuff, &pPlayer->destParam4); + CopyInt(tbuff, &pPlayer->plrlevel); + CopyInt(tbuff, &pPlayer->WorldX); + CopyInt(tbuff, &pPlayer->WorldY); + CopyInt(tbuff, &pPlayer->_px); + CopyInt(tbuff, &pPlayer->_py); + CopyInt(tbuff, &pPlayer->_ptargx); + CopyInt(tbuff, &pPlayer->_ptargy); + CopyInt(tbuff, &pPlayer->_pownerx); + CopyInt(tbuff, &pPlayer->_pownery); + CopyInt(tbuff, &pPlayer->_poldx); + CopyInt(tbuff, &pPlayer->_poldy); + CopyInt(tbuff, &pPlayer->_pxoff); + CopyInt(tbuff, &pPlayer->_pyoff); + CopyInt(tbuff, &pPlayer->_pxvel); + CopyInt(tbuff, &pPlayer->_pyvel); + CopyInt(tbuff, &pPlayer->_pdir); + CopyInt(tbuff, &pPlayer->_nextdir); + CopyInt(tbuff, &pPlayer->_pgfxnum); + tbuff += 4; // Skip pointers + CopyInt(tbuff, &pPlayer->_pAnimDelay); + CopyInt(tbuff, &pPlayer->_pAnimCnt); + CopyInt(tbuff, &pPlayer->_pAnimLen); + CopyInt(tbuff, &pPlayer->_pAnimFrame); + CopyInt(tbuff, &pPlayer->_pAnimWidth); + CopyInt(tbuff, &pPlayer->_pAnimWidth2); + CopyInt(tbuff, &pPlayer->_peflag); + CopyInt(tbuff, &pPlayer->_plid); + CopyInt(tbuff, &pPlayer->_pvid); + + CopyInt(tbuff, &pPlayer->_pSpell); + CopyChar(tbuff, &pPlayer->_pSplType); + CopyChar(tbuff, &pPlayer->_pSplFrom); + tbuff += 2; + CopyInt(tbuff, &pPlayer->_pTSpell); + CopyChar(tbuff, &pPlayer->_pTSplType); + tbuff += 3; + CopyInt(tbuff, &pPlayer->_pRSpell); + CopyChar(tbuff, &pPlayer->_pRSplType); + tbuff += 3; + CopyInt(tbuff, &pPlayer->_pSBkSpell); + CopyChar(tbuff, &pPlayer->_pSBkSplType); + + CopyBytes(tbuff, 64, &pPlayer->_pSplLvl); + tbuff += 7; + CopyInt64(tbuff, &pPlayer->_pMemSpells); + CopyInt64(tbuff, &pPlayer->_pAblSpells); + CopyInt64(tbuff, &pPlayer->_pScrlSpells); + CopyChar(tbuff, &pPlayer->_pSpellFlags); + tbuff += 3; + CopyInts(tbuff, 4, &pPlayer->_pSplHotKey); + CopyBytes(tbuff, 4, &pPlayer->_pSplTHotKey); + CopyInt(tbuff, &pPlayer->_pwtype); + CopyChar(tbuff, &pPlayer->_pBlockFlag); + CopyChar(tbuff, &pPlayer->_pInvincible); + CopyChar(tbuff, &pPlayer->_pLightRad); + CopyChar(tbuff, &pPlayer->_pLvlChanging); + CopyBytes(tbuff, PLR_NAME_LEN, &pPlayer->_pName); + CopyChar(tbuff, &pPlayer->_pClass); + tbuff += 3; + CopyInt(tbuff, &pPlayer->_pStrength); + CopyInt(tbuff, &pPlayer->_pBaseStr); + CopyInt(tbuff, &pPlayer->_pMagic); + CopyInt(tbuff, &pPlayer->_pBaseMag); + CopyInt(tbuff, &pPlayer->_pDexterity); + CopyInt(tbuff, &pPlayer->_pBaseDex); + CopyInt(tbuff, &pPlayer->_pVitality); + CopyInt(tbuff, &pPlayer->_pBaseVit); + CopyInt(tbuff, &pPlayer->_pStatPts); + CopyInt(tbuff, &pPlayer->_pDamageMod); + CopyInt(tbuff, &pPlayer->_pBaseToBlk); + CopyInt(tbuff, &pPlayer->_pHPBase); + CopyInt(tbuff, &pPlayer->_pMaxHPBase); + CopyInt(tbuff, &pPlayer->_pHitPoints); + CopyInt(tbuff, &pPlayer->_pMaxHP); + CopyInt(tbuff, &pPlayer->_pHPPer); + CopyInt(tbuff, &pPlayer->_pManaBase); + CopyInt(tbuff, &pPlayer->_pMaxManaBase); + CopyInt(tbuff, &pPlayer->_pMana); + CopyInt(tbuff, &pPlayer->_pMaxMana); + CopyInt(tbuff, &pPlayer->_pManaPer); + CopyChar(tbuff, &pPlayer->_pLevel); + CopyChar(tbuff, &pPlayer->_pMaxLvl); + tbuff += 2; + CopyInt(tbuff, &pPlayer->_pExperience); + CopyInt(tbuff, &pPlayer->_pMaxExp); + CopyInt(tbuff, &pPlayer->_pNextExper); + CopyChar(tbuff, &pPlayer->_pArmorClass); + CopyChar(tbuff, &pPlayer->_pMagResist); + CopyChar(tbuff, &pPlayer->_pFireResist); + CopyChar(tbuff, &pPlayer->_pLghtResist); + CopyInt(tbuff, &pPlayer->_pGold); + CopyInt(tbuff, &pPlayer->_pInfraFlag); + CopyInt(tbuff, &pPlayer->_pVar1); + CopyInt(tbuff, &pPlayer->_pVar2); + CopyInt(tbuff, &pPlayer->_pVar3); + CopyInt(tbuff, &pPlayer->_pVar4); + CopyInt(tbuff, &pPlayer->_pVar5); + CopyInt(tbuff, &pPlayer->_pVar6); + CopyInt(tbuff, &pPlayer->_pVar7); + CopyInt(tbuff, &pPlayer->_pVar8); + CopyBytes(tbuff, NUMLEVELS, &pPlayer->_pLvlVisited); + CopyBytes(tbuff, NUMLEVELS, &pPlayer->_pSLvlVisited); + tbuff += 2; + CopyInt(tbuff, &pPlayer->_pGFXLoad); + + tbuff += sizeof(DWORD) * 8; + CopyInt(tbuff, &pPlayer->_pNFrames); + CopyInt(tbuff, &pPlayer->_pNWidth); + + tbuff += sizeof(DWORD) * 8; + + CopyInt(tbuff, &pPlayer->_pWFrames); + CopyInt(tbuff, &pPlayer->_pWWidth); + + tbuff += sizeof(DWORD) * 8; + + CopyInt(tbuff, &pPlayer->_pAFrames); + CopyInt(tbuff, &pPlayer->_pAWidth); + CopyInt(tbuff, &pPlayer->_pAFNum); + + tbuff += sizeof(DWORD) * 24; + + CopyInt(tbuff, &pPlayer->_pSFrames); + CopyInt(tbuff, &pPlayer->_pSWidth); + CopyInt(tbuff, &pPlayer->_pSFNum); + + tbuff += sizeof(DWORD) * 8; + + CopyInt(tbuff, &pPlayer->_pHFrames); + CopyInt(tbuff, &pPlayer->_pHWidth); + + tbuff += sizeof(DWORD) * 8; + + CopyInt(tbuff, &pPlayer->_pDFrames); + CopyInt(tbuff, &pPlayer->_pDWidth); + + tbuff += sizeof(DWORD) * 8; + + CopyInt(tbuff, &pPlayer->_pBFrames); + CopyInt(tbuff, &pPlayer->_pBWidth); + CopyItems(NUM_INVLOC, pPlayer->InvBody); + CopyItems(NUM_INV_GRID_ELEM, pPlayer->InvList); + CopyInt(tbuff, &pPlayer->_pNumInv); + CopyBytes(tbuff, NUM_INV_GRID_ELEM, pPlayer->InvGrid); + CopyItems(MAXBELTITEMS, pPlayer->SpdList); + CopyItem(&pPlayer->HoldItem); + CopyInt(tbuff, &pPlayer->_pIMinDam); + CopyInt(tbuff, &pPlayer->_pIMaxDam); + CopyInt(tbuff, &pPlayer->_pIAC); + CopyInt(tbuff, &pPlayer->_pIBonusDam); + CopyInt(tbuff, &pPlayer->_pIBonusToHit); + CopyInt(tbuff, &pPlayer->_pIBonusAC); + CopyInt(tbuff, &pPlayer->_pIBonusDamMod); + tbuff += 4; + CopyInt64(tbuff, &pPlayer->_pISpells); + CopyInt(tbuff, &pPlayer->_pIFlags); + CopyInt(tbuff, &pPlayer->_pIGetHit); + + CopyChar(tbuff, &pPlayer->_pISplLvlAdd); + CopyChar(tbuff, &pPlayer->_pISplCost); + tbuff += 2; + + CopyInt(tbuff, &pPlayer->_pISplDur); + CopyInt(tbuff, &pPlayer->_pIEnAc); + CopyInt(tbuff, &pPlayer->_pIFMinDam); + CopyInt(tbuff, &pPlayer->_pIFMaxDam); + CopyInt(tbuff, &pPlayer->_pILMinDam); + CopyInt(tbuff, &pPlayer->_pILMaxDam); + CopyInt(tbuff, &pPlayer->_pOilType); + + CopyChar(tbuff, &pPlayer->pTownWarps); + CopyChar(tbuff, &pPlayer->pDungMsgs); + CopyChar(tbuff, &pPlayer->pLvlLoad); + CopyChar(tbuff, &pPlayer->pBattleNet); + + CopyChar(tbuff, &pPlayer->pManaShield); + CopyBytes(tbuff, 3, &pPlayer->bReserved); + + CopyShorts(tbuff, 8, &pPlayer->wReserved); + + CopyInt(tbuff, &pPlayer->pDiabloKillLevel); + CopyInts(tbuff, 7, &pPlayer->dwReserved); + + // Omit 10 pointers } void LoadMonster(int i) { - memcpy(&monster[i], tbuff, sizeof(*monster) - (3 * sizeof(void *))); - tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers + MonsterStruct *pMonster = &monster[i]; + + CopyInt(tbuff, &pMonster->_mMTidx); + CopyInt(tbuff, &pMonster->_mmode); + + CopyChar(tbuff, &pMonster->_mgoal); + tbuff += 3; + + CopyInt(tbuff, &pMonster->_mgoalvar1); + CopyInt(tbuff, &pMonster->_mgoalvar2); + CopyInt(tbuff, &pMonster->_mgoalvar3); + CopyInt(tbuff, &pMonster->field_18); + + CopyChar(tbuff, &pMonster->_pathcount); + tbuff += 3; + + CopyInt(tbuff, &pMonster->_mx); + CopyInt(tbuff, &pMonster->_my); + CopyInt(tbuff, &pMonster->_mfutx); + CopyInt(tbuff, &pMonster->_mfuty); + CopyInt(tbuff, &pMonster->_moldx); + CopyInt(tbuff, &pMonster->_moldy); + CopyInt(tbuff, &pMonster->_mxoff); + CopyInt(tbuff, &pMonster->_myoff); + CopyInt(tbuff, &pMonster->_mxvel); + CopyInt(tbuff, &pMonster->_myvel); + CopyInt(tbuff, &pMonster->_mdir); + CopyInt(tbuff, &pMonster->_menemy); + + CopyChar(tbuff, &pMonster->_menemyx); + CopyChar(tbuff, &pMonster->_menemyy); + CopyShort(tbuff, &pMonster->falign_52); + + tbuff += 4; // Skip pointer + CopyInt(tbuff, &pMonster->_mAnimDelay); + CopyInt(tbuff, &pMonster->_mAnimCnt); + CopyInt(tbuff, &pMonster->_mAnimLen); + CopyInt(tbuff, &pMonster->_mAnimFrame); + CopyInt(tbuff, &pMonster->_meflag); + CopyInt(tbuff, &pMonster->_mDelFlag); + CopyInt(tbuff, &pMonster->_mVar1); + CopyInt(tbuff, &pMonster->_mVar2); + CopyInt(tbuff, &pMonster->_mVar3); + CopyInt(tbuff, &pMonster->_mVar4); + CopyInt(tbuff, &pMonster->_mVar5); + CopyInt(tbuff, &pMonster->_mVar6); + CopyInt(tbuff, &pMonster->_mVar7); + CopyInt(tbuff, &pMonster->_mVar8); + CopyInt(tbuff, &pMonster->_mmaxhp); + CopyInt(tbuff, &pMonster->_mhitpoints); + + CopyChar(tbuff, &pMonster->_mAi); + CopyChar(tbuff, &pMonster->_mint); + CopyShort(tbuff, &pMonster->falign_9A); + + CopyInt(tbuff, &pMonster->_mFlags); + + CopyChar(tbuff, &pMonster->_msquelch); + tbuff += 3; + + CopyInt(tbuff, &pMonster->falign_A4); + CopyInt(tbuff, &pMonster->_lastx); + CopyInt(tbuff, &pMonster->_lasty); + CopyInt(tbuff, &pMonster->_mRndSeed); + CopyInt(tbuff, &pMonster->_mAISeed); + CopyInt(tbuff, &pMonster->falign_B8); + + CopyChar(tbuff, &pMonster->_uniqtype); + CopyChar(tbuff, &pMonster->_uniqtrans); + CopyChar(tbuff, &pMonster->_udeadval); + CopyChar(tbuff, &pMonster->mWhoHit); + + CopyChar(tbuff, &pMonster->mLevel); + tbuff += 1; + CopyShort(tbuff, &pMonster->mExp); + + CopyChar(tbuff, &pMonster->mHit); + CopyChar(tbuff, &pMonster->mMinDamage); + CopyChar(tbuff, &pMonster->mMaxDamage); + CopyChar(tbuff, &pMonster->mHit2); + + CopyChar(tbuff, &pMonster->mMinDamage2); + CopyChar(tbuff, &pMonster->mMaxDamage2); + CopyChar(tbuff, &pMonster->mArmorClass); + CopyChar(tbuff, &pMonster->falign_CB); + + CopyShort(tbuff, &pMonster->mMagicRes); + tbuff += 2; + + CopyInt(tbuff, &pMonster->mtalkmsg); + + CopyChar(tbuff, &pMonster->leader); + CopyChar(tbuff, &pMonster->leaderflag); + CopyChar(tbuff, &pMonster->packsize); + CopyChar(tbuff, &pMonster->mlid); + SyncMonsterAnim(i); } void LoadMissile(int i) { - memcpy(&missile[i], tbuff, sizeof(*missile)); - tbuff += sizeof(*missile); + MissileStruct *pMissile = &missile[i]; + + CopyInt(tbuff, &pMissile->_mitype); + CopyInt(tbuff, &pMissile->_mix); + CopyInt(tbuff, &pMissile->_miy); + CopyInt(tbuff, &pMissile->_mixoff); + CopyInt(tbuff, &pMissile->_miyoff); + CopyInt(tbuff, &pMissile->_mixvel); + CopyInt(tbuff, &pMissile->_miyvel); + CopyInt(tbuff, &pMissile->_misx); + CopyInt(tbuff, &pMissile->_misy); + CopyInt(tbuff, &pMissile->_mitxoff); + CopyInt(tbuff, &pMissile->_mityoff); + CopyInt(tbuff, &pMissile->_mimfnum); + CopyInt(tbuff, &pMissile->_mispllvl); + CopyInt(tbuff, &pMissile->_miDelFlag); + CopyChar(tbuff, &pMissile->_miAnimType); + tbuff += 3; + + CopyInt(tbuff, &pMissile->_miAnimFlags); + tbuff += 4; + CopyInt(tbuff, &pMissile->_miAnimDelay); + CopyInt(tbuff, &pMissile->_miAnimLen); + CopyInt(tbuff, &pMissile->_miAnimWidth); + CopyInt(tbuff, &pMissile->_miAnimWidth2); + CopyInt(tbuff, &pMissile->_miAnimCnt); + CopyInt(tbuff, &pMissile->_miAnimAdd); + CopyInt(tbuff, &pMissile->_miAnimFrame); + CopyInt(tbuff, &pMissile->_miDrawFlag); + CopyInt(tbuff, &pMissile->_miLightFlag); + CopyInt(tbuff, &pMissile->_miPreFlag); + CopyInt(tbuff, &pMissile->_miUniqTrans); + CopyInt(tbuff, &pMissile->_mirange); + CopyInt(tbuff, &pMissile->_misource); + CopyInt(tbuff, &pMissile->_micaster); + CopyInt(tbuff, &pMissile->_midam); + CopyInt(tbuff, &pMissile->_miHitFlag); + CopyInt(tbuff, &pMissile->_midist); + CopyInt(tbuff, &pMissile->_mlid); + CopyInt(tbuff, &pMissile->_mirnd); + CopyInt(tbuff, &pMissile->_miVar1); + CopyInt(tbuff, &pMissile->_miVar2); + CopyInt(tbuff, &pMissile->_miVar3); + CopyInt(tbuff, &pMissile->_miVar4); + CopyInt(tbuff, &pMissile->_miVar5); + CopyInt(tbuff, &pMissile->_miVar6); + CopyInt(tbuff, &pMissile->_miVar7); + CopyInt(tbuff, &pMissile->_miVar8); } void LoadObject(int i) { - memcpy(&object[i], tbuff, sizeof(*object)); - tbuff += sizeof(*object); + ObjectStruct *pObject = &object[i]; + CopyInt(tbuff, &pObject->_otype); + CopyInt(tbuff, &pObject->_ox); + CopyInt(tbuff, &pObject->_oy); + CopyInt(tbuff, &pObject->_oLight); + CopyInt(tbuff, &pObject->_oAnimFlag); + tbuff += 4; + CopyInt(tbuff, &pObject->_oAnimDelay); + CopyInt(tbuff, &pObject->_oAnimCnt); + CopyInt(tbuff, &pObject->_oAnimLen); + CopyInt(tbuff, &pObject->_oAnimFrame); + CopyInt(tbuff, &pObject->_oAnimWidth); + CopyInt(tbuff, &pObject->_oAnimWidth2); + CopyInt(tbuff, &pObject->_oDelFlag); + + CopyChar(tbuff, &pObject->_oBreak); + tbuff += 3; + + CopyInt(tbuff, &pObject->_oSolidFlag); + CopyInt(tbuff, &pObject->_oMissFlag); + + CopyChar(tbuff, &pObject->_oSelFlag); + tbuff += 3; + + CopyInt(tbuff, &pObject->_oPreFlag); + CopyInt(tbuff, &pObject->_oTrapFlag); + CopyInt(tbuff, &pObject->_oDoorFlag); + CopyInt(tbuff, &pObject->_olid); + CopyInt(tbuff, &pObject->_oRndSeed); + CopyInt(tbuff, &pObject->_oVar1); + CopyInt(tbuff, &pObject->_oVar2); + CopyInt(tbuff, &pObject->_oVar3); + CopyInt(tbuff, &pObject->_oVar4); + CopyInt(tbuff, &pObject->_oVar5); + CopyInt(tbuff, &pObject->_oVar6); + CopyInt(tbuff, &pObject->_oVar7); + CopyInt(tbuff, &pObject->_oVar8); } void LoadItem(int i) { - memcpy(&item[i], tbuff, sizeof(*item)); - tbuff += sizeof(*item); + CopyItem(&item[i]); GetItemFrm(i); } +void CopyItem(ItemStruct *pItem) +{ + CopyInt(tbuff, &pItem->_iSeed); + CopyShort(tbuff, &pItem->_iCreateInfo); + tbuff += 2; + CopyInt(tbuff, &pItem->_itype); + CopyInt(tbuff, &pItem->_ix); + CopyInt(tbuff, &pItem->_iy); + CopyInt(tbuff, &pItem->_iAnimFlag); + tbuff += 4; // Skip pointer _iAnimData + CopyInt(tbuff, &pItem->_iAnimLen); + CopyInt(tbuff, &pItem->_iAnimFrame); + CopyInt(tbuff, &pItem->_iAnimWidth); + CopyInt(tbuff, &pItem->_iAnimWidth2); + CopyInt(tbuff, &pItem->_isin); + CopyChar(tbuff, &pItem->_iSelFlag); + tbuff += 3; + CopyInt(tbuff, &pItem->_iPostDraw); + CopyInt(tbuff, &pItem->_iIdentified); + CopyChar(tbuff, &pItem->_iMagical); + CopyBytes(tbuff, 64, &pItem->_iName); + CopyBytes(tbuff, 64, &pItem->_iIName); + CopyChar(tbuff, &pItem->_iLoc); + CopyChar(tbuff, &pItem->_iClass); + tbuff += 1; + CopyInt(tbuff, &pItem->_iCurs); + CopyInt(tbuff, &pItem->_ivalue); + CopyInt(tbuff, &pItem->_iIvalue); + CopyInt(tbuff, &pItem->_iMinDam); + CopyInt(tbuff, &pItem->_iMaxDam); + CopyInt(tbuff, &pItem->_iAC); + CopyInt(tbuff, &pItem->_iFlags); + CopyInt(tbuff, &pItem->_iMiscId); + CopyInt(tbuff, &pItem->_iSpell); + CopyInt(tbuff, &pItem->_iCharges); + CopyInt(tbuff, &pItem->_iMaxCharges); + CopyInt(tbuff, &pItem->_iDurability); + CopyInt(tbuff, &pItem->_iMaxDur); + CopyInt(tbuff, &pItem->_iPLDam); + CopyInt(tbuff, &pItem->_iPLToHit); + CopyInt(tbuff, &pItem->_iPLAC); + CopyInt(tbuff, &pItem->_iPLStr); + CopyInt(tbuff, &pItem->_iPLMag); + CopyInt(tbuff, &pItem->_iPLDex); + CopyInt(tbuff, &pItem->_iPLVit); + CopyInt(tbuff, &pItem->_iPLFR); + CopyInt(tbuff, &pItem->_iPLLR); + CopyInt(tbuff, &pItem->_iPLMR); + CopyInt(tbuff, &pItem->_iPLMana); + CopyInt(tbuff, &pItem->_iPLHP); + CopyInt(tbuff, &pItem->_iPLDamMod); + CopyInt(tbuff, &pItem->_iPLGetHit); + CopyInt(tbuff, &pItem->_iPLLight); + CopyChar(tbuff, &pItem->_iSplLvlAdd); + CopyChar(tbuff, &pItem->_iRequest); + tbuff += 2; + CopyInt(tbuff, &pItem->_iUid); + CopyInt(tbuff, &pItem->_iFMinDam); + CopyInt(tbuff, &pItem->_iFMaxDam); + CopyInt(tbuff, &pItem->_iLMinDam); + CopyInt(tbuff, &pItem->_iLMaxDam); + CopyInt(tbuff, &pItem->_iPLEnAc); + CopyChar(tbuff, &pItem->_iPrePower); + CopyChar(tbuff, &pItem->_iSufPower); + tbuff += 2; + CopyInt(tbuff, &pItem->_iVAdd1); + CopyInt(tbuff, &pItem->_iVMult1); + CopyInt(tbuff, &pItem->_iVAdd2); + CopyInt(tbuff, &pItem->_iVMult2); + CopyChar(tbuff, &pItem->_iMinStr); + CopyChar(tbuff, &pItem->_iMinMag); + CopyChar(tbuff, &pItem->_iMinDex); + tbuff += 1; + CopyInt(tbuff, &pItem->_iStatFlag); + CopyInt(tbuff, &pItem->IDidx); + CopyInt(tbuff, &pItem->offs016C); +} + +void CopyItems(const int n, ItemStruct *pItem) +{ + for (int i = 0; i < n; i++) { + CopyItem(&pItem[i]); + } +} + void LoadPremium(int i) { - memcpy(&premiumitem[i], tbuff, sizeof(*premiumitem)); - tbuff += sizeof(*premiumitem); + CopyItem(&premiumitem[i]); } void LoadQuest(int i) @@ -348,7 +843,7 @@ void SaveGame() for (i = 0; i < MAXITEMS; i++) BSave(itemavail[i]); for (i = 0; i < numitems; i++) - SaveItem(itemactive[i]); + SaveItem(&item[itemactive[i]]); for (i = 0; i < 128; i++) OSave(UniqueItemFlag[i]); @@ -446,40 +941,491 @@ void OSave(BOOL v) *tbuff++ = FALSE; } + + void SavePlayer(int i) { - memcpy(tbuff, &plr[i], sizeof(*plr) - (10 * sizeof(void *))); - tbuff += sizeof(*plr) - (10 * sizeof(void *)); // omit last 10 pointers + PlayerStruct *pPlayer = &plr[i]; + + CopyInt(&pPlayer->_pmode, tbuff); + + CopyBytes(&pPlayer->walkpath, 25, tbuff); + CopyBytes(&pPlayer->plractive, 1, tbuff); + tbuff += 2; + + CopyInt(&pPlayer->destAction, tbuff); + CopyInt(&pPlayer->destParam1, tbuff); + CopyInt(&pPlayer->destParam2, tbuff); + CopyInt(&pPlayer->destParam3, tbuff); + CopyInt(&pPlayer->destParam4, tbuff); + CopyInt(&pPlayer->plrlevel, tbuff); + CopyInt(&pPlayer->WorldX, tbuff); + CopyInt(&pPlayer->WorldY, tbuff); + CopyInt(&pPlayer->_px, tbuff); + CopyInt(&pPlayer->_py, tbuff); + CopyInt(&pPlayer->_ptargx, tbuff); + CopyInt(&pPlayer->_ptargy, tbuff); + CopyInt(&pPlayer->_pownerx, tbuff); + CopyInt(&pPlayer->_pownery, tbuff); + CopyInt(&pPlayer->_poldx, tbuff); + CopyInt(&pPlayer->_poldy, tbuff); + CopyInt(&pPlayer->_pxoff, tbuff); + CopyInt(&pPlayer->_pyoff, tbuff); + CopyInt(&pPlayer->_pxvel, tbuff); + CopyInt(&pPlayer->_pyvel, tbuff); + CopyInt(&pPlayer->_pdir, tbuff); + CopyInt(&pPlayer->_nextdir, tbuff); + CopyInt(&pPlayer->_pgfxnum, tbuff); + tbuff += 4; // Skip pointers + CopyInt(&pPlayer->_pAnimDelay, tbuff); + CopyInt(&pPlayer->_pAnimCnt, tbuff); + CopyInt(&pPlayer->_pAnimLen, tbuff); + CopyInt(&pPlayer->_pAnimFrame, tbuff); + CopyInt(&pPlayer->_pAnimWidth, tbuff); + CopyInt(&pPlayer->_pAnimWidth2, tbuff); + CopyInt(&pPlayer->_peflag, tbuff); + CopyInt(&pPlayer->_plid, tbuff); + CopyInt(&pPlayer->_pvid, tbuff); + + CopyInt(&pPlayer->_pSpell, tbuff); + + CopyChar(&pPlayer->_pSplType, tbuff); + CopyChar(&pPlayer->_pSplFrom, tbuff); + tbuff += 2; + + CopyInt(&pPlayer->_pTSpell, tbuff); + CopyChar(&pPlayer->_pTSplType, tbuff); + tbuff += 3; + CopyInt(&pPlayer->_pRSpell, tbuff); + CopyChar(&pPlayer->_pRSplType, tbuff); + tbuff += 3; + CopyInt(&pPlayer->_pSBkSpell, tbuff); + CopyChar(&pPlayer->_pSBkSplType, tbuff); + + CopyBytes(&pPlayer->_pSplLvl, 64, tbuff); + tbuff += 7; + CopyInt64(&pPlayer->_pMemSpells, tbuff); + CopyInt64(&pPlayer->_pAblSpells, tbuff); + CopyInt64(&pPlayer->_pScrlSpells, tbuff); + CopyChar(&pPlayer->_pSpellFlags, tbuff); + tbuff += 3; + CopyInts(&pPlayer->_pSplHotKey, 4, tbuff); + CopyBytes(&pPlayer->_pSplTHotKey, 4, tbuff); + CopyInt(&pPlayer->_pwtype, tbuff); + CopyChar(&pPlayer->_pBlockFlag, tbuff); + CopyChar(&pPlayer->_pInvincible, tbuff); + CopyChar(&pPlayer->_pLightRad, tbuff); + CopyChar(&pPlayer->_pLvlChanging, tbuff); + CopyBytes(&pPlayer->_pName, PLR_NAME_LEN, tbuff); + CopyChar(&pPlayer->_pClass, tbuff); + tbuff += 3; + CopyInt(&pPlayer->_pStrength, tbuff); + CopyInt(&pPlayer->_pBaseStr, tbuff); + CopyInt(&pPlayer->_pMagic, tbuff); + CopyInt(&pPlayer->_pBaseMag, tbuff); + CopyInt(&pPlayer->_pDexterity, tbuff); + CopyInt(&pPlayer->_pBaseDex, tbuff); + CopyInt(&pPlayer->_pVitality, tbuff); + CopyInt(&pPlayer->_pBaseVit, tbuff); + CopyInt(&pPlayer->_pStatPts, tbuff); + CopyInt(&pPlayer->_pDamageMod, tbuff); + CopyInt(&pPlayer->_pBaseToBlk, tbuff); + CopyInt(&pPlayer->_pHPBase, tbuff); + CopyInt(&pPlayer->_pMaxHPBase, tbuff); + CopyInt(&pPlayer->_pHitPoints, tbuff); + CopyInt(&pPlayer->_pMaxHP, tbuff); + CopyInt(&pPlayer->_pHPPer, tbuff); + CopyInt(&pPlayer->_pManaBase, tbuff); + CopyInt(&pPlayer->_pMaxManaBase, tbuff); + CopyInt(&pPlayer->_pMana, tbuff); + CopyInt(&pPlayer->_pMaxMana, tbuff); + CopyInt(&pPlayer->_pManaPer, tbuff); + CopyChar(&pPlayer->_pLevel, tbuff); + CopyChar(&pPlayer->_pMaxLvl, tbuff); + tbuff += 2; + CopyInt(&pPlayer->_pExperience, tbuff); + CopyInt(&pPlayer->_pMaxExp, tbuff); + CopyInt(&pPlayer->_pNextExper, tbuff); + CopyChar(&pPlayer->_pArmorClass, tbuff); + CopyChar(&pPlayer->_pMagResist, tbuff); + CopyChar(&pPlayer->_pFireResist, tbuff); + CopyChar(&pPlayer->_pLghtResist, tbuff); + CopyInt(&pPlayer->_pGold, tbuff); + CopyInt(&pPlayer->_pInfraFlag, tbuff); + CopyInt(&pPlayer->_pVar1, tbuff); + CopyInt(&pPlayer->_pVar2, tbuff); + CopyInt(&pPlayer->_pVar3, tbuff); + CopyInt(&pPlayer->_pVar4, tbuff); + CopyInt(&pPlayer->_pVar5, tbuff); + CopyInt(&pPlayer->_pVar6, tbuff); + CopyInt(&pPlayer->_pVar7, tbuff); + CopyInt(&pPlayer->_pVar8, tbuff); + CopyBytes(&pPlayer->_pLvlVisited, NUMLEVELS, tbuff); + CopyBytes(&pPlayer->_pSLvlVisited, NUMLEVELS, tbuff); // only 10 used + tbuff += 2; + CopyInt(&pPlayer->_pGFXLoad, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + CopyInt(&pPlayer->_pNFrames, tbuff); + CopyInt(&pPlayer->_pNWidth, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + + CopyInt(&pPlayer->_pWFrames, tbuff); + CopyInt(&pPlayer->_pWWidth, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + + CopyInt(&pPlayer->_pAFrames, tbuff); + CopyInt(&pPlayer->_pAWidth, tbuff); + CopyInt(&pPlayer->_pAFNum, tbuff); + + tbuff += sizeof(DWORD) * 24; // Skip 24 pointers + + CopyInt(&pPlayer->_pSFrames, tbuff); + CopyInt(&pPlayer->_pSWidth, tbuff); + CopyInt(&pPlayer->_pSFNum, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + + CopyInt(&pPlayer->_pHFrames, tbuff); + CopyInt(&pPlayer->_pHWidth, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + + CopyInt(&pPlayer->_pDFrames, tbuff); + CopyInt(&pPlayer->_pDWidth, tbuff); + + tbuff += sizeof(DWORD) * 8; // Skip 8 pointers + + CopyInt(&pPlayer->_pBFrames, tbuff); + CopyInt(&pPlayer->_pBWidth, tbuff); + SaveItems(pPlayer->InvBody, NUM_INVLOC); + SaveItems(pPlayer->InvList, NUM_INV_GRID_ELEM); + CopyInt(&pPlayer->_pNumInv, tbuff); + CopyBytes(pPlayer->InvGrid, NUM_INV_GRID_ELEM, tbuff); + SaveItems(pPlayer->SpdList, MAXBELTITEMS); + SaveItem(&pPlayer->HoldItem); + CopyInt(&pPlayer->_pIMinDam, tbuff); + CopyInt(&pPlayer->_pIMaxDam, tbuff); + CopyInt(&pPlayer->_pIAC, tbuff); + CopyInt(&pPlayer->_pIBonusDam, tbuff); + CopyInt(&pPlayer->_pIBonusToHit, tbuff); + CopyInt(&pPlayer->_pIBonusAC, tbuff); + CopyInt(&pPlayer->_pIBonusDamMod, tbuff); + tbuff += 4; + CopyInt64(&pPlayer->_pISpells, tbuff); + CopyInt(&pPlayer->_pIFlags, tbuff); + CopyInt(&pPlayer->_pIGetHit, tbuff); + + CopyChar(&pPlayer->_pISplLvlAdd, tbuff); + CopyChar(&pPlayer->_pISplCost, tbuff); + tbuff += 2; + + CopyInt(&pPlayer->_pISplDur, tbuff); + CopyInt(&pPlayer->_pIEnAc, tbuff); + CopyInt(&pPlayer->_pIFMinDam, tbuff); + CopyInt(&pPlayer->_pIFMaxDam, tbuff); + CopyInt(&pPlayer->_pILMinDam, tbuff); + CopyInt(&pPlayer->_pILMaxDam, tbuff); + CopyInt(&pPlayer->_pOilType, tbuff); + + CopyChar(&pPlayer->pTownWarps, tbuff); + CopyChar(&pPlayer->pDungMsgs, tbuff); + CopyChar(&pPlayer->pLvlLoad, tbuff); + CopyChar(&pPlayer->pBattleNet, tbuff); + + CopyChar(&pPlayer->pManaShield, tbuff); + CopyBytes(&pPlayer->bReserved, 3, tbuff); + + CopyShorts(&pPlayer->wReserved, 8, tbuff); + + CopyInt(&pPlayer->pDiabloKillLevel, tbuff); + CopyInts(&pPlayer->dwReserved, 7, tbuff); + + // Omit 10 pointers } void SaveMonster(int i) { - memcpy(tbuff, &monster[i], sizeof(*monster) - (3 * sizeof(void *))); - tbuff += sizeof(*monster) - (3 * sizeof(void *)); // omit last 3 pointers + MonsterStruct *pMonster = &monster[i]; + + CopyInt(&pMonster->_mMTidx, tbuff); + CopyInt(&pMonster->_mmode, tbuff); + + CopyChar(&pMonster->_mgoal, tbuff); + tbuff += 3; + + CopyInt(&pMonster->_mgoalvar1, tbuff); + CopyInt(&pMonster->_mgoalvar2, tbuff); + CopyInt(&pMonster->_mgoalvar3, tbuff); + CopyInt(&pMonster->field_18, tbuff); + + CopyChar(&pMonster->_pathcount, tbuff); + tbuff += 3; + + CopyInt(&pMonster->_mx, tbuff); + CopyInt(&pMonster->_my, tbuff); + CopyInt(&pMonster->_mfutx, tbuff); + CopyInt(&pMonster->_mfuty, tbuff); + CopyInt(&pMonster->_moldx, tbuff); + CopyInt(&pMonster->_moldy, tbuff); + CopyInt(&pMonster->_mxoff, tbuff); + CopyInt(&pMonster->_myoff, tbuff); + CopyInt(&pMonster->_mxvel, tbuff); + CopyInt(&pMonster->_myvel, tbuff); + CopyInt(&pMonster->_mdir, tbuff); + CopyInt(&pMonster->_menemy, tbuff); + + CopyChar(&pMonster->_menemyx, tbuff); + CopyChar(&pMonster->_menemyy, tbuff); + CopyShort(&pMonster->falign_52, tbuff); + + tbuff += 4; // Skip pointer + CopyInt(&pMonster->_mAnimDelay, tbuff); + CopyInt(&pMonster->_mAnimCnt, tbuff); + CopyInt(&pMonster->_mAnimLen, tbuff); + CopyInt(&pMonster->_mAnimFrame, tbuff); + CopyInt(&pMonster->_meflag, tbuff); + CopyInt(&pMonster->_mDelFlag, tbuff); + CopyInt(&pMonster->_mVar1, tbuff); + CopyInt(&pMonster->_mVar2, tbuff); + CopyInt(&pMonster->_mVar3, tbuff); + CopyInt(&pMonster->_mVar4, tbuff); + CopyInt(&pMonster->_mVar5, tbuff); + CopyInt(&pMonster->_mVar6, tbuff); + CopyInt(&pMonster->_mVar7, tbuff); + CopyInt(&pMonster->_mVar8, tbuff); + CopyInt(&pMonster->_mmaxhp, tbuff); + CopyInt(&pMonster->_mhitpoints, tbuff); + + CopyChar(&pMonster->_mAi, tbuff); + CopyChar(&pMonster->_mint, tbuff); + CopyShort(&pMonster->falign_9A, tbuff); + + CopyInt(&pMonster->_mFlags, tbuff); + + CopyChar(&pMonster->_msquelch, tbuff); + tbuff += 3; + + CopyInt(&pMonster->falign_A4, tbuff); + CopyInt(&pMonster->_lastx, tbuff); + CopyInt(&pMonster->_lasty, tbuff); + CopyInt(&pMonster->_mRndSeed, tbuff); + CopyInt(&pMonster->_mAISeed, tbuff); + CopyInt(&pMonster->falign_B8, tbuff); + + CopyChar(&pMonster->_uniqtype, tbuff); + CopyChar(&pMonster->_uniqtrans, tbuff); + CopyChar(&pMonster->_udeadval, tbuff); + CopyChar(&pMonster->mWhoHit, tbuff); + + CopyChar(&pMonster->mLevel, tbuff); + tbuff += 1; + CopyShort(&pMonster->mExp, tbuff); + + CopyChar(&pMonster->mHit, tbuff); + CopyChar(&pMonster->mMinDamage, tbuff); + CopyChar(&pMonster->mMaxDamage, tbuff); + CopyChar(&pMonster->mHit2, tbuff); + + CopyChar(&pMonster->mMinDamage2, tbuff); + CopyChar(&pMonster->mMaxDamage2, tbuff); + CopyChar(&pMonster->mArmorClass, tbuff); + CopyChar(&pMonster->falign_CB, tbuff); + + CopyShort(&pMonster->mMagicRes, tbuff); + tbuff += 2; + + CopyInt(&pMonster->mtalkmsg, tbuff); + + CopyChar(&pMonster->leader, tbuff); + CopyChar(&pMonster->leaderflag, tbuff); + CopyChar(&pMonster->packsize, tbuff); + CopyChar(&pMonster->mlid, tbuff); } void SaveMissile(int i) { - memcpy(tbuff, &missile[i], sizeof(*missile)); - tbuff += sizeof(*missile); + MissileStruct *pMissile = &missile[i]; + + CopyInt(&pMissile->_mitype, tbuff); + CopyInt(&pMissile->_mix, tbuff); + CopyInt(&pMissile->_miy, tbuff); + CopyInt(&pMissile->_mixoff, tbuff); + CopyInt(&pMissile->_miyoff, tbuff); + CopyInt(&pMissile->_mixvel, tbuff); + CopyInt(&pMissile->_miyvel, tbuff); + CopyInt(&pMissile->_misx, tbuff); + CopyInt(&pMissile->_misy, tbuff); + CopyInt(&pMissile->_mitxoff, tbuff); + CopyInt(&pMissile->_mityoff, tbuff); + CopyInt(&pMissile->_mimfnum, tbuff); + CopyInt(&pMissile->_mispllvl, tbuff); + CopyInt(&pMissile->_miDelFlag, tbuff); + CopyChar(&pMissile->_miAnimType, tbuff); + tbuff += 3; + + CopyInt(&pMissile->_miAnimFlags, tbuff); + tbuff += 4; + CopyInt(&pMissile->_miAnimDelay, tbuff); + CopyInt(&pMissile->_miAnimLen, tbuff); + CopyInt(&pMissile->_miAnimWidth, tbuff); + CopyInt(&pMissile->_miAnimWidth2, tbuff); + CopyInt(&pMissile->_miAnimCnt, tbuff); + CopyInt(&pMissile->_miAnimAdd, tbuff); + CopyInt(&pMissile->_miAnimFrame, tbuff); + CopyInt(&pMissile->_miDrawFlag, tbuff); + CopyInt(&pMissile->_miLightFlag, tbuff); + CopyInt(&pMissile->_miPreFlag, tbuff); + CopyInt(&pMissile->_miUniqTrans, tbuff); + CopyInt(&pMissile->_mirange, tbuff); + CopyInt(&pMissile->_misource, tbuff); + CopyInt(&pMissile->_micaster, tbuff); + CopyInt(&pMissile->_midam, tbuff); + CopyInt(&pMissile->_miHitFlag, tbuff); + CopyInt(&pMissile->_midist, tbuff); + CopyInt(&pMissile->_mlid, tbuff); + CopyInt(&pMissile->_mirnd, tbuff); + CopyInt(&pMissile->_miVar1, tbuff); + CopyInt(&pMissile->_miVar2, tbuff); + CopyInt(&pMissile->_miVar3, tbuff); + CopyInt(&pMissile->_miVar4, tbuff); + CopyInt(&pMissile->_miVar5, tbuff); + CopyInt(&pMissile->_miVar6, tbuff); + CopyInt(&pMissile->_miVar7, tbuff); + CopyInt(&pMissile->_miVar8, tbuff); } void SaveObject(int i) { - memcpy(tbuff, &object[i], sizeof(*object)); - tbuff += sizeof(*object); + ObjectStruct *pObject = &object[i]; + CopyInt(&pObject->_otype, tbuff); + CopyInt(&pObject->_ox, tbuff); + CopyInt(&pObject->_oy, tbuff); + CopyInt(&pObject->_oLight, tbuff); + CopyInt(&pObject->_oAnimFlag, tbuff); + tbuff += 4; + CopyInt(&pObject->_oAnimDelay, tbuff); + CopyInt(&pObject->_oAnimCnt, tbuff); + CopyInt(&pObject->_oAnimLen, tbuff); + CopyInt(&pObject->_oAnimFrame, tbuff); + CopyInt(&pObject->_oAnimWidth, tbuff); + CopyInt(&pObject->_oAnimWidth2, tbuff); + CopyInt(&pObject->_oDelFlag, tbuff); + + CopyChar(&pObject->_oBreak, tbuff); + tbuff += 3; + + CopyInt(&pObject->_oSolidFlag, tbuff); + CopyInt(&pObject->_oMissFlag, tbuff); + + CopyChar(&pObject->_oSelFlag, tbuff); + tbuff += 3; + + CopyInt(&pObject->_oPreFlag, tbuff); + CopyInt(&pObject->_oTrapFlag, tbuff); + CopyInt(&pObject->_oDoorFlag, tbuff); + CopyInt(&pObject->_olid, tbuff); + CopyInt(&pObject->_oRndSeed, tbuff); + CopyInt(&pObject->_oVar1, tbuff); + CopyInt(&pObject->_oVar2, tbuff); + CopyInt(&pObject->_oVar3, tbuff); + CopyInt(&pObject->_oVar4, tbuff); + CopyInt(&pObject->_oVar5, tbuff); + CopyInt(&pObject->_oVar6, tbuff); + CopyInt(&pObject->_oVar7, tbuff); + CopyInt(&pObject->_oVar8, tbuff); } -void SaveItem(int i) +void SaveItem(ItemStruct *pItem) { - memcpy(tbuff, &item[i], sizeof(*item)); - tbuff += sizeof(*item); + CopyInt(&pItem->_iSeed, tbuff); + CopyShort(&pItem->_iCreateInfo, tbuff); + tbuff += 2; + CopyInt(&pItem->_itype, tbuff); + CopyInt(&pItem->_ix, tbuff); + CopyInt(&pItem->_iy, tbuff); + CopyInt(&pItem->_iAnimFlag, tbuff); + tbuff += 4; // Skip pointer _iAnimData + CopyInt(&pItem->_iAnimLen, tbuff); + CopyInt(&pItem->_iAnimFrame, tbuff); + CopyInt(&pItem->_iAnimWidth, tbuff); + CopyInt(&pItem->_iAnimWidth2, tbuff); // width 2? + CopyInt(&pItem->_isin, tbuff); // set when item is flagged for deletion, deprecated in 1.02 + CopyChar(&pItem->_iSelFlag, tbuff); + tbuff += 3; + CopyInt(&pItem->_iPostDraw, tbuff); + CopyInt(&pItem->_iIdentified, tbuff); + CopyChar(&pItem->_iMagical, tbuff); + CopyBytes(&pItem->_iName, 64, tbuff); + CopyBytes(&pItem->_iIName, 64, tbuff); + CopyChar(&pItem->_iLoc, tbuff); + CopyChar(&pItem->_iClass, tbuff); + tbuff += 1; + CopyInt(&pItem->_iCurs, tbuff); + CopyInt(&pItem->_ivalue, tbuff); + CopyInt(&pItem->_iIvalue, tbuff); + CopyInt(&pItem->_iMinDam, tbuff); + CopyInt(&pItem->_iMaxDam, tbuff); + CopyInt(&pItem->_iAC, tbuff); + CopyInt(&pItem->_iFlags, tbuff); + CopyInt(&pItem->_iMiscId, tbuff); + CopyInt(&pItem->_iSpell, tbuff); + CopyInt(&pItem->_iCharges, tbuff); + CopyInt(&pItem->_iMaxCharges, tbuff); + CopyInt(&pItem->_iDurability, tbuff); + CopyInt(&pItem->_iMaxDur, tbuff); + CopyInt(&pItem->_iPLDam, tbuff); + CopyInt(&pItem->_iPLToHit, tbuff); + CopyInt(&pItem->_iPLAC, tbuff); + CopyInt(&pItem->_iPLStr, tbuff); + CopyInt(&pItem->_iPLMag, tbuff); + CopyInt(&pItem->_iPLDex, tbuff); + CopyInt(&pItem->_iPLVit, tbuff); + CopyInt(&pItem->_iPLFR, tbuff); + CopyInt(&pItem->_iPLLR, tbuff); + CopyInt(&pItem->_iPLMR, tbuff); + CopyInt(&pItem->_iPLMana, tbuff); + CopyInt(&pItem->_iPLHP, tbuff); + CopyInt(&pItem->_iPLDamMod, tbuff); + CopyInt(&pItem->_iPLGetHit, tbuff); + CopyInt(&pItem->_iPLLight, tbuff); + CopyChar(&pItem->_iSplLvlAdd, tbuff); + CopyChar(&pItem->_iRequest, tbuff); + tbuff += 2; + CopyInt(&pItem->_iUid, tbuff); + CopyInt(&pItem->_iFMinDam, tbuff); + CopyInt(&pItem->_iFMaxDam, tbuff); + CopyInt(&pItem->_iLMinDam, tbuff); + CopyInt(&pItem->_iLMaxDam, tbuff); + CopyInt(&pItem->_iPLEnAc, tbuff); + CopyChar(&pItem->_iPrePower, tbuff); + CopyChar(&pItem->_iSufPower, tbuff); + tbuff += 2; + CopyInt(&pItem->_iVAdd1, tbuff); + CopyInt(&pItem->_iVMult1, tbuff); + CopyInt(&pItem->_iVAdd2, tbuff); + CopyInt(&pItem->_iVMult2, tbuff); + CopyChar(&pItem->_iMinStr, tbuff); + CopyChar(&pItem->_iMinMag, tbuff); + CopyChar(&pItem->_iMinDex, tbuff); + tbuff += 1; + CopyInt(&pItem->_iStatFlag, tbuff); + CopyInt(&pItem->IDidx, tbuff); + CopyInt(&pItem->offs016C, tbuff); +} + +void SaveItems(ItemStruct *pItem, const int n) +{ + for (int i = 0; i < n; i++) { + SaveItem(&pItem[i]); + } } void SavePremium(int i) { - memcpy(tbuff, &premiumitem[i], sizeof(*premiumitem)); - tbuff += sizeof(*premiumitem); + SaveItem(&premiumitem[i]); } void SaveQuest(int i) @@ -554,7 +1500,7 @@ void SaveLevel() for (i = 0; i < MAXITEMS; i++) BSave(itemavail[i]); for (i = 0; i < numitems; i++) - SaveItem(itemactive[i]); + SaveItem(&item[itemactive[i]]); for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) diff --git a/Source/loadsave.h b/Source/loadsave.h index 71309f5feda..fa03d7dbbea 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -9,6 +9,11 @@ char BLoad(); int WLoad(); int ILoad(); BOOL OLoad(); +void CopyItems(const int n, ItemStruct *pItem); +void CopyItem(ItemStruct *pItem); +void SaveItem(ItemStruct *pItem); +void SaveItems(ItemStruct *pItem, const int n); + void LoadPlayer(int i); void LoadMonster(int i); void LoadMissile(int i); diff --git a/Source/logging.cpp b/Source/logging.cpp index 36ca5422bc8..0b60dc7d281 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -6,10 +6,10 @@ DEVILUTION_BEGIN_NAMESPACE #ifdef __cplusplus static CCritSect sgMemCrit; #endif -CHAR FileName[MAX_PATH]; // idb +CHAR FileName[MAX_PATH]; char log_buffer[388]; -LPCVOID lpAddress; // idb -DWORD nNumberOfBytesToWrite; // idb +LPCVOID lpAddress; +DWORD nNumberOfBytesToWrite; /* data */ @@ -95,7 +95,6 @@ HANDLE log_create() log_not_created = FALSE; return fh; } -// 4947D4: using guessed type int log_not_created; void log_get_version(VS_FIXEDFILEINFO *file_info) { @@ -157,10 +156,10 @@ void __cdecl log_printf(const char *pszFmt, ...) void log_dump_computer_info() { - char Buffer[64]; // [esp+0h] [ebp-88h] - VS_FIXEDFILEINFO file_info; // [esp+40h] [ebp-48h] - SYSTEMTIME SystemTime; // [esp+74h] [ebp-14h] - DWORD pcbBuffer; // [esp+84h] [ebp-4h] + char Buffer[64]; + VS_FIXEDFILEINFO file_info; + SYSTEMTIME SystemTime; + DWORD pcbBuffer; GetLocalTime(&SystemTime); pcbBuffer = 64; diff --git a/Source/logging.h b/Source/logging.h index de6289aea74..13b0ec7c0d8 100644 --- a/Source/logging.h +++ b/Source/logging.h @@ -2,24 +2,22 @@ #ifndef __LOGGING_H__ #define __LOGGING_H__ -extern CHAR FileName[MAX_PATH]; // idb +extern CHAR FileName[MAX_PATH]; extern char log_buffer[388]; -extern LPCVOID lpAddress; // idb -extern DWORD nNumberOfBytesToWrite; // idb +extern LPCVOID lpAddress; +extern DWORD nNumberOfBytesToWrite; void __cdecl log_flush(BOOL force_close); -HANDLE log_create(); // should be HANDLE +HANDLE log_create(); void log_get_version(VS_FIXEDFILEINFO *file_info); void __cdecl log_printf(const char *pszFmt, ...); // LogMessage void log_dump_computer_info(); /* rdata */ -extern const int log_inf; // weak - /* data */ -extern int log_not_created; // weak -extern HANDLE log_file; // idb +extern int log_not_created; +extern HANDLE log_file; #endif /* __LOGGING_H__ */ diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index fa551e2890c..52b50690ea4 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -20,10 +20,10 @@ void mainmenu_refresh_music() } while (!menu_music_track_id || menu_music_track_id == 1); } -void __stdcall mainmenu_create_hero(int arg1, int arg2, int arg3, int arg4, char *name_1, char *name_2) +void __stdcall mainmenu_change_name(int arg1, int arg2, int arg3, int arg4, char *name_1, char *name_2) { if (UiValidPlayerName(name_2)) - pfile_create_save_file(name_1, name_2); + pfile_rename_hero(name_1, name_2); } int __stdcall mainmenu_select_hero_dialog( @@ -49,7 +49,6 @@ int __stdcall mainmenu_select_hero_dialog( &gnDifficulty)) app_fatal("Unable to display SelHeroSing"); - if (dlgresult == LOAD_GAME) gbLoadGame = TRUE; else diff --git a/Source/mainmenu.h b/Source/mainmenu.h index a9155438ea9..897856a84ec 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -5,7 +5,7 @@ extern char gszHero[16]; void mainmenu_refresh_music(); -void __stdcall mainmenu_create_hero(int arg1, int arg2, int arg3, int arg4, char *name_1, char *name_2); +void __stdcall mainmenu_change_name(int arg1, int arg2, int arg3, int arg4, char *name_1, char *name_2); int __stdcall mainmenu_select_hero_dialog( const _SNETPROGRAMDATA *client_info, const _SNETPLAYERDATA *user_info, @@ -23,8 +23,6 @@ void mainmenu_play_intro(); /* rdata */ -extern const int mainmenu_inf; // weak - /* data */ extern int menu_music_track_id; // idb diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 8cea8c2defb..2c78ffded90 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -2,12 +2,12 @@ DEVILUTION_BEGIN_NAMESPACE -int qtexty; // weak +int qtexty; char *qtextptr; -int qtextSpd; // weak -char qtextflag; // weak -int scrolltexty; // weak -int sgLastScroll; // weak +int qtextSpd; +char qtextflag; +int scrolltexty; +int sgLastScroll; void *pMedTextCels; void *pTextBoxCels; @@ -47,11 +47,10 @@ void FreeQuestText() void InitQuestText() { - pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0); - pTextBoxCels = LoadFileInMem("Data\\TextBox.CEL", 0); + pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", NULL); + pTextBoxCels = LoadFileInMem("Data\\TextBox.CEL", NULL); qtextflag = FALSE; } -// 646D00: using guessed type char qtextflag; void InitQTextMsg(int m) { @@ -66,11 +65,6 @@ void InitQTextMsg(int m) } PlaySFX(alltext[m].sfxnr); } -// 646CF4: using guessed type int qtexty; -// 646CFC: using guessed type int qtextSpd; -// 646D00: using guessed type char qtextflag; -// 646D04: using guessed type int scrolltexty; -// 646D08: using guessed type int sgLastScroll; void DrawQTextBack() { @@ -291,11 +285,5 @@ void DrawQText() } } } -// 646CF4: using guessed type int qtexty; -// 646CFC: using guessed type int qtextSpd; -// 646D00: using guessed type char qtextflag; -// 646D04: using guessed type int scrolltexty; -// 646D08: using guessed type int sgLastScroll; -// 428202: using guessed type char qstr[128]; DEVILUTION_END_NAMESPACE diff --git a/Source/minitext.h b/Source/minitext.h index 0e1499814e0..e83883d3e17 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -2,11 +2,11 @@ #ifndef __MINITEXT_H__ #define __MINITEXT_H__ -extern int qtexty; // weak +extern int qtexty; extern char *qtextptr; -extern int qtextSpd; // weak -extern char qtextflag; // weak -extern int scrolltexty; // weak +extern int qtextSpd; +extern char qtextflag; +extern int scrolltexty; extern void *pMedTextCels; extern void *pTextBoxCels; diff --git a/Source/misdat.h b/Source/misdat.h index 1dd8a4297c9..d64cc993df6 100644 --- a/Source/misdat.h +++ b/Source/misdat.h @@ -1,8 +1,8 @@ -//HEADER_GOES_HERE -#ifndef __MISDAT_H__ -#define __MISDAT_H__ - -extern MissileData missiledata[68]; -extern MisFileData misfiledata[47]; - -#endif /* __MISDAT_H__ */ +//HEADER_GOES_HERE +#ifndef __MISDAT_H__ +#define __MISDAT_H__ + +extern MissileData missiledata[68]; +extern MisFileData misfiledata[47]; + +#endif /* __MISDAT_H__ */ diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 889c0673c72..2306690ea38 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -5,11 +5,11 @@ DEVILUTION_BEGIN_NAMESPACE int missileactive[MAXMISSILES]; int missileavail[MAXMISSILES]; MissileStruct missile[MAXMISSILES]; -int nummissiles; // idb +int nummissiles; int ManashieldFlag; ChainStruct chain[MAXMISSILES]; -int MissilePreFlag; // weak -int numchains; // weak +int MissilePreFlag; +int numchains; int XDirAdd[8] = { 1, 0, -1, -1, -1, 0, 1, 1 }; int YDirAdd[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; @@ -22,30 +22,30 @@ void GetDamageAmt(int i, int *mind, int *maxd) /// ASSERT: assert((DWORD)i < 64); sl = plr[myplr]._pSplLvl[i] + plr[myplr]._pISplLvlAdd; - switch(i) { + switch (i) { case SPL_FIREBOLT: *mind = (plr[myplr]._pMagic >> 3) + sl + 1; *maxd = (plr[myplr]._pMagic >> 3) + sl + 10; break; case SPL_HEAL: /// BUGFIX: healing calculation is unused *mind = plr[myplr]._pLevel + sl + 1; - if(plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == PC_WARRIOR) { *mind *= 2; } - if(plr[myplr]._pClass == PC_ROGUE) { + if (plr[myplr]._pClass == PC_ROGUE) { *mind += *mind >> 1; } *maxd = 10; - for(k = 0; k < plr[myplr]._pLevel; k++) { + for (k = 0; k < plr[myplr]._pLevel; k++) { *maxd += 4; } - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += 6; } - if(plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == PC_WARRIOR) { *maxd *= 2; } - if(plr[myplr]._pClass == PC_ROGUE) { + if (plr[myplr]._pClass == PC_ROGUE) { *maxd += *maxd >> 1; } *mind = -1; @@ -57,7 +57,7 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_FLASH: *mind = plr[myplr]._pLevel; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *mind += *mind >> 3; } *mind += *mind >> 1; @@ -90,21 +90,21 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_FIREBALL: *mind = 2 * plr[myplr]._pLevel + 4; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *mind += *mind >> 3; } *maxd = 2 * plr[myplr]._pLevel + 40; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += *maxd >> 3; } break; case SPL_GUARDIAN: *mind = (plr[myplr]._pLevel >> 1) + 1; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *mind += *mind >> 3; } *maxd = (plr[myplr]._pLevel >> 1) + 10; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += *maxd >> 3; } break; @@ -118,12 +118,12 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_NOVA: *mind = (plr[myplr]._pLevel + 5) >> 1; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *mind += *mind >> 3; } *mind *= 5; *maxd = (plr[myplr]._pLevel + 30) >> 1; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += *maxd >> 3; } *maxd *= 5; @@ -139,22 +139,22 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_APOCA: *mind = 0; - for(k = 0; k < plr[myplr]._pLevel; k++) { + for (k = 0; k < plr[myplr]._pLevel; k++) { *mind += 1; } *maxd = 0; - for(k = 0; k < plr[myplr]._pLevel; k++) { + for (k = 0; k < plr[myplr]._pLevel; k++) { *maxd += 6; } break; case SPL_ELEMENT: *mind = 2 * plr[myplr]._pLevel + 4; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *mind += *mind >> 3; } /// BUGFIX: add here '*mind >>= 1;' *maxd = 2 * plr[myplr]._pLevel + 40; - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += *maxd >> 3; } /// BUGFIX: add here '*maxd >>= 1;' @@ -169,23 +169,23 @@ void GetDamageAmt(int i, int *mind, int *maxd) break; case SPL_HEALOTHER: /// BUGFIX: healing calculation is unused *mind = plr[myplr]._pLevel + sl + 1; - if(plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == PC_WARRIOR) { *mind *= 2; } - if(plr[myplr]._pClass == PC_ROGUE) { + if (plr[myplr]._pClass == PC_ROGUE) { *mind += *mind >> 1; } *maxd = 10; - for(k = 0; k < plr[myplr]._pLevel; k++) { + for (k = 0; k < plr[myplr]._pLevel; k++) { *maxd += 4; } - for(k = 0; k < sl; k++) { + for (k = 0; k < sl; k++) { *maxd += 6; } - if(plr[myplr]._pClass == PC_WARRIOR) { + if (plr[myplr]._pClass == PC_WARRIOR) { *maxd *= 2; } - if(plr[myplr]._pClass == PC_ROGUE) { + if (plr[myplr]._pClass == PC_ROGUE) { *maxd += *maxd >> 1; } *mind = -1; @@ -225,7 +225,7 @@ int FindClosest(int sx, int sy, int rad) for (i = 1; i < rad; i++) { cr = CrawlNum[i] + 2; - for (j = (unsigned char)CrawlTable[CrawlNum[i]]; j > 0; j--) { + for (j = (BYTE)CrawlTable[CrawlNum[i]]; j > 0; j--) { tx = sx + CrawlTable[cr - 1]; ty = sy + CrawlTable[cr]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) { @@ -256,7 +256,7 @@ int GetSpellLevel(int id, int sn) int GetDirection8(int x1, int y1, int x2, int y2) { - unsigned char Dirs[16][16] = { + BYTE Dirs[16][16] = { { 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, @@ -276,9 +276,9 @@ int GetDirection8(int x1, int y1, int x2, int y2) }; int mx, my, md; ALIGN_BY_1 BYTE urtoll[] = { 3, 4, 5 }, - ultolr[] = { 3, 2, 1 }, - lrtoul[] = { 7, 6, 5 }, - lltour[] = { 7, 0, 1 }; + ultolr[] = { 3, 2, 1 }, + lrtoul[] = { 7, 6, 5 }, + lltour[] = { 7, 0, 1 }; mx = abs(x2 - x1); if (mx > 15) @@ -395,7 +395,6 @@ void PutMissile(int i) MissilePreFlag = 1; } } -// 64CCD4: using guessed type int MissilePreFlag; void GetMissilePos(int i) { @@ -805,7 +804,7 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA if (plr[pnum]._pHitPoints >> 6 <= 0) { SyncPlrKill(pnum, earflag); - } else{ + } else { if (plr[pnum]._pClass == PC_WARRIOR) { PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY); } else if (plr[pnum]._pClass == PC_ROGUE) { @@ -814,15 +813,15 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY); } drawhpflag = TRUE; - } + } } else { if (blk < blkper) { if (m != -1) { tac = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[m]._mx, monster[m]._my); - } else { + } else { tac = plr[pnum]._pdir; - } - StartPlrBlock(pnum, tac); + } + StartPlrBlock(pnum, tac); } else { if (pnum == myplr) { plr[pnum]._pHitPoints -= dam; @@ -1106,18 +1105,18 @@ void LoadMissileGFX(BYTE mi) mfd = &misfiledata[mi]; if (mfd->mFlags & MFLAG_ALLOW_SPECIAL) { sprintf(pszName, "Missiles\\%s.CL2", mfd->mName); - file = LoadFileInMem(pszName, 0); + file = LoadFileInMem(pszName, NULL); for (i = 0; i < mfd->mAnimFAmt; i++) mfd->mAnimData[i] = &file[((int *)file)[i]]; } else if (mfd->mAnimFAmt == 1) { sprintf(pszName, "Missiles\\%s.CL2", mfd->mName); if (!mfd->mAnimData[0]) - mfd->mAnimData[0] = LoadFileInMem(pszName, 0); + mfd->mAnimData[0] = LoadFileInMem(pszName, NULL); } else { for (i = 0; i < mfd->mAnimFAmt; i++) { sprintf(pszName, "Missiles\\%s%i.CL2", mfd->mName, i + 1); if (!mfd->mAnimData[i]) { - file = LoadFileInMem(pszName, 0); + file = LoadFileInMem(pszName, NULL); mfd->mAnimData[i] = file; } } @@ -1209,7 +1208,6 @@ void InitMissiles() } } } -// 64CCD8: using guessed type int numchains; void AddLArrow(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { @@ -1318,7 +1316,6 @@ void AddRndTeleport(int mi, int sx, int sy, int dx, int dy, int midir, char mien } } } -// 5CF31D: using guessed type char setlevel; void AddFirebolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster, int id, int dam) { @@ -1384,7 +1381,7 @@ void AddTeleport(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy for (i = 0; i < 6; i++) { k = CrawlNum[i]; pn = k + 2; - for (j = (unsigned char)CrawlTable[k]; j > 0; j--) { + for (j = (BYTE)CrawlTable[k]; j > 0; j--) { tx = dx + CrawlTable[pn - 1]; ty = dy + CrawlTable[pn]; if (0 < tx && tx < MAXDUNX && 0 < ty && ty < MAXDUNY) { @@ -1572,11 +1569,11 @@ void AddTown(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in missile[mi]._miDelFlag = TRUE; for (j = 0; j < 6; j++) { k = CrawlNum[j] + 2; - for (i = (unsigned char)CrawlTable[CrawlNum[j]]; i > 0; i--) { + for (i = (BYTE)CrawlTable[CrawlNum[j]]; i > 0; i--) { tx = dx + CrawlTable[k - 1]; ty = dy + CrawlTable[k]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) { - if (!(dObject[tx][ty] | dPlayer[tx][ty] | dMissile[tx][ty] | nSolidTable[dPiece[tx][ty]] | (unsigned char)nMissileTable[dPiece[tx][ty]])) { + if (!(dObject[tx][ty] | dPlayer[tx][ty] | dMissile[tx][ty] | nSolidTable[dPiece[tx][ty]] | (BYTE)nMissileTable[dPiece[tx][ty]])) { if (!CheckIfTrig(tx, ty)) { missile[mi]._miDelFlag = FALSE; missile[mi]._mix = tx; @@ -1616,7 +1613,6 @@ void AddTown(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in } } } -// 5CF31D: using guessed type char setlevel; void AddFlash(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { @@ -1703,13 +1699,13 @@ void AddGuardian(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy for (i = 0; i < 6; i++) { pn = CrawlNum[i]; k = pn + 2; - for (j = (unsigned char)CrawlTable[pn]; j > 0; j--) { + for (j = (BYTE)CrawlTable[pn]; j > 0; j--) { tx = dx + CrawlTable[k - 1]; ty = dy + CrawlTable[k]; pn = dPiece[tx][ty]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) { if (LineClear(sx, sy, tx, ty)) { - if (!(dMonster[tx][ty] | dObject[tx][ty] | dMissile[tx][ty] | nSolidTable[pn] | (unsigned char)nMissileTable[pn])) { + if (!(dMonster[tx][ty] | dObject[tx][ty] | dMissile[tx][ty] | nSolidTable[pn] | (BYTE)nMissileTable[pn])) { missile[mi]._miDelFlag = FALSE; missile[mi]._mix = tx; missile[mi]._miy = ty; @@ -1916,7 +1912,7 @@ void AddStone(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, i for (i = 0; i < 6; i++) { k = CrawlNum[i]; l = k + 2; - for (j = (unsigned char)CrawlTable[k]; j > 0; j--) { + for (j = (BYTE)CrawlTable[k]; j > 0; j--) { tx = dx + CrawlTable[l - 1]; ty = dy + CrawlTable[l]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY) { @@ -2105,7 +2101,6 @@ void AddIdentify(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy SetCursor_(CURSOR_IDENTIFY); } } -// 4B8968: using guessed type int sbookflag; void AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { @@ -2116,7 +2111,7 @@ void AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, char mienem for (i = 0; i < 6; i++) { k = CrawlNum[i]; pn = k + 2; - for (j = (unsigned char)CrawlTable[k]; j > 0; j--) { + for (j = (BYTE)CrawlTable[k]; j > 0; j--) { tx = dx + CrawlTable[pn - 1]; ty = dy + CrawlTable[pn]; if (0 < tx && tx < MAXDUNX && 0 < ty && ty < MAXDUNY) { @@ -2202,7 +2197,6 @@ void AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, SetCursor_(CURSOR_REPAIR); } } -// 4B8968: using guessed type int sbookflag; void AddRecharge(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { @@ -2216,7 +2210,6 @@ void AddRecharge(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy SetCursor_(CURSOR_RECHARGE); } } -// 4B8968: using guessed type int sbookflag; void AddDisarm(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { @@ -2293,11 +2286,11 @@ void AddFlamec(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, void AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster, int id, int dam) { if (micaster == 0) { - if (id != -1) - missile[mi]._mirnd = random(63, 15) + 1; - else - missile[mi]._mirnd = random(63, 15) + 1; - missile[mi]._midam = random(68, plr[id]._pMagic >> 2) + 1; + if (id != -1) + missile[mi]._mirnd = random(63, 15) + 1; + else + missile[mi]._mirnd = random(63, 15) + 1; + missile[mi]._midam = random(68, plr[id]._pMagic >> 2) + 1; } else { missile[mi]._mirnd = random(63, 15) + 1; missile[mi]._midam = 15; @@ -2306,11 +2299,11 @@ void AddCbolt(int mi, int sx, int sy, int dx, int dy, int midir, char micaster, if (sx == dx && sy == dy) { dx += XDirAdd[midir]; dy += YDirAdd[midir]; - } + } missile[mi]._miAnimFrame = random(63, 8) + 1; - missile[mi]._mlid = AddLight(sx, sy, 5); - + missile[mi]._mlid = AddLight(sx, sy, 5); + GetMissileVel(mi, sx, sy, dx, dy, 8); missile[mi]._miVar1 = 5; missile[mi]._miVar2 = midir; @@ -2422,7 +2415,6 @@ void AddDiabApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienem } missile[mi]._miDelFlag = TRUE; } -// 679660: using guessed type char gbMaxPlayers; int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micaster, int id, int midam, int spllvl) { @@ -2523,7 +2515,7 @@ void MI_Golem(int i) for (l = 0; l < 6; l++) { k = CrawlNum[l]; tid = k + 2; - for (m = (unsigned char)CrawlTable[k]; m > 0; m--) { + for (m = (BYTE)CrawlTable[k]; m > 0; m--) { tx = missile[i]._miVar4 + CrawlTable[tid - 1]; ty = missile[i]._miVar5 + CrawlTable[tid]; if (0 < tx && tx < MAXDUNX && 0 < ty && ty < MAXDUNY) { @@ -2885,12 +2877,12 @@ void MI_Fireball(int i) } if (missile[i]._miyvel > 0 && (TransList[dTransVal[mx + 1][my]] && nSolidTable[dPiece[mx + 1][my]] - || TransList[dTransVal[mx - 1][my]] && nSolidTable[dPiece[mx - 1][my]])) { + || TransList[dTransVal[mx - 1][my]] && nSolidTable[dPiece[mx - 1][my]])) { missile[i]._miyoff -= 32; } if (missile[i]._mixvel > 0 && (TransList[dTransVal[mx][my + 1]] && nSolidTable[dPiece[mx][my + 1]] - || TransList[dTransVal[mx][my - 1]] && nSolidTable[dPiece[mx][my - 1]])) { + || TransList[dTransVal[mx][my - 1]] && nSolidTable[dPiece[mx][my - 1]])) { missile[i]._mixoff -= 32; } missile[i]._mimfnum = 0; @@ -2914,8 +2906,8 @@ void MI_Lightctrl(int i) missile[i]._mirange--; p = missile[i]._misource; - if(p != -1) { - if(missile[i]._micaster == 0) { + if (p != -1) { + if (missile[i]._micaster == 0) { dam = (random(79, 2) + random(79, plr[p]._pLevel) + 2) << 6; } else { dam = 2 * (monster[p].mMinDamage + random(80, monster[p].mMaxDamage - monster[p].mMinDamage + 1)); @@ -2935,61 +2927,61 @@ void MI_Lightctrl(int i) pn = dPiece[mx][my]; /// ASSERT: assert((DWORD)pn <= MAXTILES); - if(missile[i]._misource == -1) { - if((mx != missile[i]._misx || my != missile[i]._misy) && nMissileTable[pn] != 0) { + if (missile[i]._misource == -1) { + if ((mx != missile[i]._misx || my != missile[i]._misy) && nMissileTable[pn] != 0) { missile[i]._mirange = 0; } - } else if(nMissileTable[pn] != 0) { + } else if (nMissileTable[pn] != 0) { missile[i]._mirange = 0; } - if(nMissileTable[pn] == 0) { - if((mx != missile[i]._miVar1 || my != missile[i]._miVar2) && mx > 0 && my > 0 && mx < MAXDUNX && my < MAXDUNY) { - if(missile[i]._misource != -1) { - if(missile[i]._micaster == 1 - && monster[missile[i]._misource].MType->mtype >= MT_STORM - && monster[missile[i]._misource].MType->mtype <= MT_MAEL) { + if (nMissileTable[pn] == 0) { + if ((mx != missile[i]._miVar1 || my != missile[i]._miVar2) && mx > 0 && my > 0 && mx < MAXDUNX && my < MAXDUNY) { + if (missile[i]._misource != -1) { + if (missile[i]._micaster == 1 + && monster[missile[i]._misource].MType->mtype >= MT_STORM + && monster[missile[i]._misource].MType->mtype <= MT_MAEL) { AddMissile( - mx, - my, - missile[i]._misx, - missile[i]._misy, - i, - MIS_LIGHTNING2, - missile[i]._micaster, - missile[i]._misource, - dam, - missile[i]._mispllvl); + mx, + my, + missile[i]._misx, + missile[i]._misy, + i, + MIS_LIGHTNING2, + missile[i]._micaster, + missile[i]._misource, + dam, + missile[i]._mispllvl); } else { AddMissile( - mx, - my, - missile[i]._misx, - missile[i]._misy, - i, - MIS_LIGHTNING, - missile[i]._micaster, - missile[i]._misource, - dam, - missile[i]._mispllvl); + mx, + my, + missile[i]._misx, + missile[i]._misy, + i, + MIS_LIGHTNING, + missile[i]._micaster, + missile[i]._misource, + dam, + missile[i]._mispllvl); } } else { AddMissile( - mx, - my, - missile[i]._misx, - missile[i]._misy, - i, - MIS_LIGHTNING, - missile[i]._micaster, - missile[i]._misource, - dam, - missile[i]._mispllvl); + mx, + my, + missile[i]._misx, + missile[i]._misy, + i, + MIS_LIGHTNING, + missile[i]._micaster, + missile[i]._misource, + dam, + missile[i]._mispllvl); } missile[i]._miVar1 = missile[i]._mix; missile[i]._miVar2 = missile[i]._miy; } } - if(missile[i]._mirange == 0 || mx <= 0 || my <= 0 || mx >= MAXDUNX || my > MAXDUNY) { + if (missile[i]._mirange == 0 || mx <= 0 || my <= 0 || mx >= MAXDUNX || my > MAXDUNY) { missile[i]._miDelFlag = TRUE; } } @@ -3246,42 +3238,42 @@ void MI_Guardian(int i) sy1 = 0; missile[i]._mirange--; - if(missile[i]._miVar2 > 0) { + if (missile[i]._miVar2 > 0) { missile[i]._miVar2--; } - if(missile[i]._mirange == missile[i]._miVar1 || missile[i]._mimfnum == MFILE_GUARD && missile[i]._miVar2 == 0) { + if (missile[i]._mirange == missile[i]._miVar1 || missile[i]._mimfnum == MFILE_GUARD && missile[i]._miVar2 == 0) { SetMissDir(i, 1); } - if(!(missile[i]._mirange % 16)) { + if (!(missile[i]._mirange % 16)) { ex = 0; - for(j = 0; j < 23 && ex != -1; j++) { - for(k = 10; k >= 0 && ex != -1 && (vCrawlTable[j][k] != 0 || vCrawlTable[j][k + 1] != 0); k -= 2) { - if(sx1 == vCrawlTable[j][k] && sy1 == vCrawlTable[j][k + 1]) { + for (j = 0; j < 23 && ex != -1; j++) { + for (k = 10; k >= 0 && ex != -1 && (vCrawlTable[j][k] != 0 || vCrawlTable[j][k + 1] != 0); k -= 2) { + if (sx1 == vCrawlTable[j][k] && sy1 == vCrawlTable[j][k + 1]) { continue; } sx = missile[i]._mix + vCrawlTable[j][k]; sy = missile[i]._miy + vCrawlTable[j][k + 1]; ex = Sentfire(i, sx, sy); - if(ex == -1) { + if (ex == -1) { break; } sx = missile[i]._mix - vCrawlTable[j][k]; sy = missile[i]._miy - vCrawlTable[j][k + 1]; ex = Sentfire(i, sx, sy); - if(ex == -1) { + if (ex == -1) { break; } sx = missile[i]._mix + vCrawlTable[j][k]; sy = missile[i]._miy - vCrawlTable[j][k + 1]; ex = Sentfire(i, sx, sy); - if(ex == -1) { + if (ex == -1) { break; } sx = missile[i]._mix - vCrawlTable[j][k]; sy = missile[i]._miy + vCrawlTable[j][k + 1]; ex = Sentfire(i, sx, sy); - if(ex == -1) { + if (ex == -1) { break; } sx1 = vCrawlTable[j][k]; @@ -3290,7 +3282,7 @@ void MI_Guardian(int i) } } - if(missile[i]._mirange == 14) { + if (missile[i]._mirange == 14) { SetMissDir(i, 0); missile[i]._miAnimFrame = 15; missile[i]._miAnimAdd = -1; @@ -3298,13 +3290,13 @@ void MI_Guardian(int i) missile[i]._miVar3 += missile[i]._miAnimAdd; - if(missile[i]._miVar3 > 15) { + if (missile[i]._miVar3 > 15) { missile[i]._miVar3 = 15; - } else if(missile[i]._miVar3 > 0) { + } else if (missile[i]._miVar3 > 0) { ChangeLight(missile[i]._mlid, missile[i]._mix, missile[i]._miy, missile[i]._miVar3); } - if(missile[i]._mirange == 0) { + if (missile[i]._mirange == 0) { missile[i]._miDelFlag = TRUE; AddUnLight(missile[i]._mlid); } @@ -3328,7 +3320,7 @@ void MI_Chain(int i) for (m = 1; m < rad; m++) { k = CrawlNum[m]; l = k + 2; - for (n = (unsigned char)CrawlTable[k]; n > 0; n--) { + for (n = (BYTE)CrawlTable[k]; n > 0; n--) { tx = sx + CrawlTable[l - 1]; ty = sy + CrawlTable[l]; if (tx > 0 && tx < MAXDUNX && ty > 0 && ty < MAXDUNY && dMonster[tx][ty] > 0) { @@ -4082,7 +4074,6 @@ void ProcessMissiles() } } } -// 64CCD4: using guessed type int MissilePreFlag; void missiles_process_charge() { diff --git a/Source/missiles.h b/Source/missiles.h index f63f3b6821b..466bae2714d 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -5,11 +5,11 @@ extern int missileactive[MAXMISSILES]; extern int missileavail[MAXMISSILES]; extern MissileStruct missile[MAXMISSILES]; -extern int nummissiles; // idb +extern int nummissiles; extern int ManashieldFlag; extern ChainStruct chain[MAXMISSILES]; -extern int MissilePreFlag; // weak -extern int numchains; // weak +extern int MissilePreFlag; +extern int numchains; void GetDamageAmt(int i, int *mind, int *maxd); BOOL CheckBlock(int fx, int fy, int tx, int ty); diff --git a/Source/monstdat.h b/Source/monstdat.h index c15d9934f3a..b61679b2e91 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -1,10 +1,10 @@ -//HEADER_GOES_HERE -#ifndef __MONSTDAT_H__ -#define __MONSTDAT_H__ - -extern MonsterData monsterdata[112]; -extern char MonstConvTbl[128]; -extern unsigned char MonstAvailTbl[112]; -extern UniqMonstStruct UniqMonst[98]; - -#endif /* __MONSTDAT_H__ */ +//HEADER_GOES_HERE +#ifndef __MONSTDAT_H__ +#define __MONSTDAT_H__ + +extern MonsterData monsterdata[112]; +extern char MonstConvTbl[128]; +extern unsigned char MonstAvailTbl[112]; +extern UniqMonstStruct UniqMonst[98]; + +#endif /* __MONSTDAT_H__ */ diff --git a/Source/monster.cpp b/Source/monster.cpp index 3d8c5453668..31426b387d3 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -555,7 +555,7 @@ void PlaceMonster(int i, int mtype, int x, int y) InitMonster(i, rd, mtype, x, y); } -void PlaceUniqueMonst(int uniqindex, int miniontype, int packsize) +void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize) { int xp, yp, x, y, i; int uniqtype; @@ -749,7 +749,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int packsize) nummonsters++; if (Uniq->mUnqAttr & 1) { - PlaceGroup(miniontype, packsize, Uniq->mUnqAttr, nummonsters - 1); + PlaceGroup(miniontype, unpackfilesize, Uniq->mUnqAttr, nummonsters - 1); } if (Monst->_mAi != AI_GARG) { @@ -783,27 +783,27 @@ void PlaceQuestMonsters() } if (QuestStatus(QTYPE_BOL)) { - setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", 0); + setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } if (QuestStatus(QTYPE_BLOOD)) { - setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } if (QuestStatus(QTYPE_BLIND)) { - setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } if (QuestStatus(QTYPE_ANVIL)) { - setp = LoadFileInMem("Levels\\L3Data\\Anvil.DUN", 0); + setp = LoadFileInMem("Levels\\L3Data\\Anvil.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x + 2, 2 * setpc_y + 2); mem_free_dbg(setp); } if (QuestStatus(QTYPE_WARLRD)) { - setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + setp = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 1); @@ -821,7 +821,7 @@ void PlaceQuestMonsters() PlaceUniqueMonst(UMT_LAZURUS, 0, 0); PlaceUniqueMonst(UMT_RED_VEX, 0, 0); PlaceUniqueMonst(UMT_BLACKJADE, 0, 0); - setp = LoadFileInMem("Levels\\L4Data\\Vile1.DUN", 0); + setp = LoadFileInMem("Levels\\L4Data\\Vile1.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } @@ -914,16 +914,16 @@ void LoadDiabMonsts() { BYTE *lpSetPiece; - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", NULL); SetMapMonsters(lpSetPiece, 2 * diabquad1x, 2 * diabquad1y); mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", NULL); SetMapMonsters(lpSetPiece, 2 * diabquad2x, 2 * diabquad2y); mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", NULL); SetMapMonsters(lpSetPiece, 2 * diabquad3x, 2 * diabquad3y); mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab4a.DUN", NULL); SetMapMonsters(lpSetPiece, 2 * diabquad4x, 2 * diabquad4y); mem_free_dbg(lpSetPiece); } @@ -5178,7 +5178,7 @@ BOOL PosOkMonst(int i, int x, int y) if (ret && dMissile[x][y] && i >= 0) { mi = dMissile[x][y]; if (mi > 0) { - if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: 'mi' should be 'mi - 1' (corrected) + if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (done) fire = TRUE; } else { for (j = 0; j < nummissiles; j++) { @@ -5210,7 +5210,7 @@ BOOL PosOkMonst2(int i, int x, int y) if (ret && dMissile[x][y] && i >= 0) { mi = dMissile[x][y]; if (mi > 0) { - if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: 'mi' should be 'mi - 1' (corrected) + if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (done) fire = TRUE; } else { for (j = 0; j < nummissiles; j++) { @@ -5251,7 +5251,7 @@ BOOL PosOkMonst3(int i, int x, int y) if (ret && dMissile[x][y] != 0 && i >= 0) { mi = dMissile[x][y]; if (mi > 0) { - if (missile[mi]._mitype == MIS_FIREWALL) { + if (missile[mi]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' fire = TRUE; } else { for (j = 0; j < nummissiles; j++) { diff --git a/Source/monster.h b/Source/monster.h index 96e03b70ec2..c59d5e69044 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -24,7 +24,7 @@ void InitMonster(int i, int rd, int mtype, int x, int y); void ClrAllMonsters(); BOOL MonstPlace(int xp, int yp); void PlaceMonster(int i, int mtype, int x, int y); -void PlaceUniqueMonst(int uniqindex, int miniontype, int packsize); +void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize); void PlaceQuestMonsters(); void PlaceGroup(int mtype, int num, int leaderf, int leader); void LoadDiabMonsts(); diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index d8881164489..0b4d2673659 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -8,7 +8,7 @@ char mpq_buf[4096]; _HASHENTRY *sgpHashTbl; BOOL save_archive_modified; _BLOCKENTRY *sgpBlockTbl; -BOOLEAN save_archive_open; // weak +BOOLEAN save_archive_open; //note: 32872 = 32768 + 104 (sizeof(_FILEHEADER)) @@ -122,7 +122,7 @@ BOOLEAN mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen) } while (i); } - return SRegSaveData("Diablo", "Video Player ", 0, (unsigned char *)pbData, dwLen); + return SRegSaveData("Diablo", "Video Player ", 0, (BYTE *)pbData, dwLen); } void mpqapi_remove_hash_entry(const char *pszName) diff --git a/Source/mpqapi.h b/Source/mpqapi.h index c1451b360d5..9afe8fe961a 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -3,8 +3,8 @@ #define __MPQAPI_H__ extern char mpq_buf[4096]; -extern BOOL save_archive_modified; // weak -extern BOOLEAN save_archive_open; // weak +extern BOOL save_archive_modified; +extern BOOLEAN save_archive_open; BOOL mpqapi_set_hidden(const char *pszArchive, BOOL hidden); void mpqapi_store_creation_time(const char *pszArchive, DWORD dwChar); diff --git a/Source/msg.cpp b/Source/msg.cpp index 8d4a55004d7..f89f8690e7c 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -50,7 +50,6 @@ void msg_send_packet(int pnum, const void *packet, DWORD dwSize) memcpy((char *)&packeta[1] - packeta->dwSpaceLeft, packet, dwSize); sgpCurrPkt->dwSpaceLeft -= dwSize; } -// 65AB24: using guessed type int sgnCurrMegaPlayer; TMegaPkt *msg_get_next_packet() { @@ -100,11 +99,6 @@ BOOL msg_wait_resync() return TRUE; } -// 65AB18: using guessed type int sgdwOwnerWait; -// 65AB24: using guessed type int sgnCurrMegaPlayer; -// 67618D: using guessed type char sgbDeltaChunks; -// 676194: using guessed type char gbBufferMsgs; -// 67862D: using guessed type char gbGameDestroyed; void msg_free_packets() { @@ -147,10 +141,6 @@ int msg_wait_for_turns() } return 100 * sgbDeltaChunks / 21; } -// 65AB18: using guessed type int sgdwOwnerWait; -// 67618D: using guessed type char sgbDeltaChunks; -// 67862D: using guessed type char gbGameDestroyed; -// 6796E4: using guessed type char gbDeltaSender; void msg_process_net_packets() { @@ -161,8 +151,6 @@ void msg_process_net_packets() msg_free_packets(); } } -// 676194: using guessed type char gbBufferMsgs; -// 679660: using guessed type char gbMaxPlayers; void msg_pre_packet() { @@ -315,7 +303,6 @@ void delta_init() memset(sgLocals, 0, sizeof(sgLocals)); deltaload = FALSE; } -// 676190: using guessed type int deltaload; void delta_kill_monster(int mi, BYTE x, BYTE y, BYTE bLevel) { @@ -330,7 +317,6 @@ void delta_kill_monster(int mi, BYTE x, BYTE y, BYTE bLevel) pD->_mhitpoints = 0; } } -// 679660: using guessed type char gbMaxPlayers; void delta_monster_hp(int mi, int hp, BYTE bLevel) { @@ -343,7 +329,6 @@ void delta_monster_hp(int mi, int hp, BYTE bLevel) pD->_mhitpoints = hp; } } -// 679660: using guessed type char gbMaxPlayers; void delta_sync_monster(const TSyncMonster *pSync, BYTE bLevel) { @@ -365,7 +350,6 @@ void delta_sync_monster(const TSyncMonster *pSync, BYTE bLevel) pD->_menemy = pSync->_menemy; } } -// 679660: using guessed type char gbMaxPlayers; void delta_sync_golem(TCmdGolem *pG, int pnum, BYTE bLevel) { @@ -382,7 +366,6 @@ void delta_sync_golem(TCmdGolem *pG, int pnum, BYTE bLevel) pD->_mhitpoints = pG->_mhitpoints; } } -// 679660: using guessed type char gbMaxPlayers; void delta_leave_sync(BYTE bLevel) { @@ -411,8 +394,6 @@ void delta_leave_sync(BYTE bLevel) } } } -// 43C17D: could not find valid save-restore pair for edi -// 679660: using guessed type char gbMaxPlayers; BOOL delta_portal_inited(int i) { @@ -433,7 +414,7 @@ void DeltaAddItem(int ii) return; } pD = sgLevels[currlevel].item; - for (i = 0; i < MAXITEMS; i++,pD++) { + for (i = 0; i < MAXITEMS; i++, pD++) { if (pD->bCmd != 0xFF && pD->wIndx == item[ii].IDidx && pD->wCI == item[ii]._iCreateInfo @@ -477,7 +458,6 @@ void DeltaSaveLevel() delta_leave_sync(currlevel); } } -// 679660: using guessed type char gbMaxPlayers; void DeltaLoadLevel() { @@ -628,7 +608,6 @@ void DeltaLoadLevel() } deltaload = FALSE; } -// 679660: using guessed type char gbMaxPlayers; void NetSendCmd(BOOL bHiPri, BYTE bCmd) { @@ -997,7 +976,7 @@ void RemovePlrPortal(int pnum) sgbDeltaChanged = TRUE; } -int ParseCmd(int pnum, TCmd *pCmd) +DWORD ParseCmd(int pnum, TCmd *pCmd) { sbLastCmd = pCmd->bCmd; if (sgwPackPlrOffsetTbl[pnum] != 0 && sbLastCmd != CMD_ACK_PLRINFO && sbLastCmd != CMD_SEND_PLRINFO) @@ -1007,139 +986,139 @@ int ParseCmd(int pnum, TCmd *pCmd) case CMD_SYNCDATA: return On_SYNCDATA(pCmd, pnum); case CMD_WALKXY: - return On_WALKXY((TCmdLoc *)pCmd, pnum); + return On_WALKXY(pCmd, pnum); case CMD_ADDSTR: - return On_ADDSTR((TCmdParam1 *)pCmd, pnum); + return On_ADDSTR(pCmd, pnum); case CMD_ADDDEX: - return On_ADDDEX((TCmdParam1 *)pCmd, pnum); + return On_ADDDEX(pCmd, pnum); case CMD_ADDMAG: - return On_ADDMAG((TCmdParam1 *)pCmd, pnum); + return On_ADDMAG(pCmd, pnum); case CMD_ADDVIT: - return On_ADDVIT((TCmdParam1 *)pCmd, pnum); + return On_ADDVIT(pCmd, pnum); case CMD_SBSPELL: - return On_SBSPELL((TCmdParam1 *)pCmd, pnum); + return On_SBSPELL(pCmd, pnum); case CMD_GOTOGETITEM: - return On_GOTOGETITEM((TCmdLocParam1 *)pCmd, pnum); + return On_GOTOGETITEM(pCmd, pnum); case CMD_REQUESTGITEM: - return On_REQUESTGITEM((TCmdGItem *)pCmd, pnum); + return On_REQUESTGITEM(pCmd, pnum); case CMD_GETITEM: - return On_GETITEM((TCmdGItem *)pCmd, pnum); + return On_GETITEM(pCmd, pnum); case CMD_GOTOAGETITEM: - return On_GOTOAGETITEM((TCmdLocParam1 *)pCmd, pnum); + return On_GOTOAGETITEM(pCmd, pnum); case CMD_REQUESTAGITEM: - return On_REQUESTAGITEM((TCmdGItem *)pCmd, pnum); + return On_REQUESTAGITEM(pCmd, pnum); case CMD_AGETITEM: - return On_AGETITEM((TCmdGItem *)pCmd, pnum); + return On_AGETITEM(pCmd, pnum); case CMD_ITEMEXTRA: - return On_ITEMEXTRA((TCmdGItem *)pCmd, pnum); + return On_ITEMEXTRA(pCmd, pnum); case CMD_PUTITEM: - return On_PUTITEM((TCmdPItem *)pCmd, pnum); + return On_PUTITEM(pCmd, pnum); case CMD_SYNCPUTITEM: - return On_SYNCPUTITEM((TCmdPItem *)pCmd, pnum); + return On_SYNCPUTITEM(pCmd, pnum); case CMD_RESPAWNITEM: - return On_RESPAWNITEM((TCmdPItem *)pCmd, pnum); + return On_RESPAWNITEM(pCmd, pnum); case CMD_ATTACKXY: - return On_ATTACKXY((TCmdLoc *)pCmd, pnum); + return On_ATTACKXY(pCmd, pnum); case CMD_SATTACKXY: - return On_SATTACKXY((TCmdLoc *)pCmd, pnum); + return On_SATTACKXY(pCmd, pnum); case CMD_RATTACKXY: - return On_RATTACKXY((TCmdLoc *)pCmd, pnum); + return On_RATTACKXY(pCmd, pnum); case CMD_SPELLXYD: - return On_SPELLXYD((TCmdLocParam3 *)pCmd, pnum); + return On_SPELLXYD(pCmd, pnum); case CMD_SPELLXY: - return On_SPELLXY((TCmdLocParam2 *)pCmd, pnum); + return On_SPELLXY(pCmd, pnum); case CMD_TSPELLXY: - return On_TSPELLXY((TCmdLocParam2 *)pCmd, pnum); + return On_TSPELLXY(pCmd, pnum); case CMD_OPOBJXY: - return On_OPOBJXY((TCmdLocParam1 *)pCmd, pnum); + return On_OPOBJXY(pCmd, pnum); case CMD_DISARMXY: - return On_DISARMXY((TCmdLocParam1 *)pCmd, pnum); + return On_DISARMXY(pCmd, pnum); case CMD_OPOBJT: - return On_OPOBJT((TCmdParam1 *)pCmd, pnum); + return On_OPOBJT(pCmd, pnum); case CMD_ATTACKID: - return On_ATTACKID((TCmdParam1 *)pCmd, pnum); + return On_ATTACKID(pCmd, pnum); case CMD_ATTACKPID: - return On_ATTACKPID((TCmdParam1 *)pCmd, pnum); + return On_ATTACKPID(pCmd, pnum); case CMD_RATTACKID: - return On_RATTACKID((TCmdParam1 *)pCmd, pnum); + return On_RATTACKID(pCmd, pnum); case CMD_RATTACKPID: - return On_RATTACKPID((TCmdParam1 *)pCmd, pnum); + return On_RATTACKPID(pCmd, pnum); case CMD_SPELLID: - return On_SPELLID((TCmdParam3 *)pCmd, pnum); + return On_SPELLID(pCmd, pnum); case CMD_SPELLPID: - return On_SPELLPID((TCmdParam3 *)pCmd, pnum); + return On_SPELLPID(pCmd, pnum); case CMD_TSPELLID: - return On_TSPELLID((TCmdParam3 *)pCmd, pnum); + return On_TSPELLID(pCmd, pnum); case CMD_TSPELLPID: - return On_TSPELLPID((TCmdParam3 *)pCmd, pnum); + return On_TSPELLPID(pCmd, pnum); case CMD_KNOCKBACK: - return On_KNOCKBACK((TCmdParam1 *)pCmd, pnum); + return On_KNOCKBACK(pCmd, pnum); case CMD_RESURRECT: - return On_RESURRECT((TCmdParam1 *)pCmd, pnum); + return On_RESURRECT(pCmd, pnum); case CMD_HEALOTHER: - return On_HEALOTHER((TCmdParam1 *)pCmd, pnum); + return On_HEALOTHER(pCmd, pnum); case CMD_TALKXY: - return On_TALKXY((TCmdLocParam1 *)pCmd, pnum); + return On_TALKXY(pCmd, pnum); case CMD_DEBUG: return On_DEBUG(pCmd, pnum); case CMD_NEWLVL: - return On_NEWLVL((TCmdParam2 *)pCmd, pnum); + return On_NEWLVL(pCmd, pnum); case CMD_WARP: - return On_WARP((TCmdParam1 *)pCmd, pnum); + return On_WARP(pCmd, pnum); case CMD_MONSTDEATH: - return On_MONSTDEATH((TCmdLocParam1 *)pCmd, pnum); + return On_MONSTDEATH(pCmd, pnum); case CMD_KILLGOLEM: - return On_KILLGOLEM((TCmdLocParam1 *)pCmd, pnum); + return On_KILLGOLEM(pCmd, pnum); case CMD_AWAKEGOLEM: - return On_AWAKEGOLEM((TCmdGolem *)pCmd, pnum); + return On_AWAKEGOLEM(pCmd, pnum); case CMD_MONSTDAMAGE: - return On_MONSTDAMAGE((TCmdParam2 *)pCmd, pnum); + return On_MONSTDAMAGE(pCmd, pnum); case CMD_PLRDEAD: - return On_PLRDEAD((TCmdParam1 *)pCmd, pnum); + return On_PLRDEAD(pCmd, pnum); case CMD_PLRDAMAGE: - return On_PLRDAMAGE((TCmdDamage *)pCmd, pnum); + return On_PLRDAMAGE(pCmd, pnum); case CMD_OPENDOOR: - return On_OPENDOOR((TCmdParam1 *)pCmd, pnum); + return On_OPENDOOR(pCmd, pnum); case CMD_CLOSEDOOR: - return On_CLOSEDOOR((TCmdParam1 *)pCmd, pnum); + return On_CLOSEDOOR(pCmd, pnum); case CMD_OPERATEOBJ: - return On_OPERATEOBJ((TCmdParam1 *)pCmd, pnum); + return On_OPERATEOBJ(pCmd, pnum); case CMD_PLROPOBJ: - return On_PLROPOBJ((TCmdParam2 *)pCmd, pnum); + return On_PLROPOBJ(pCmd, pnum); case CMD_BREAKOBJ: - return On_BREAKOBJ((TCmdParam2 *)pCmd, pnum); + return On_BREAKOBJ(pCmd, pnum); case CMD_CHANGEPLRITEMS: - return On_CHANGEPLRITEMS((TCmdChItem *)pCmd, pnum); + return On_CHANGEPLRITEMS(pCmd, pnum); case CMD_DELPLRITEMS: - return On_DELPLRITEMS((TCmdDelItem *)pCmd, pnum); + return On_DELPLRITEMS(pCmd, pnum); case CMD_PLRLEVEL: - return On_PLRLEVEL((TCmdParam1 *)pCmd, pnum); + return On_PLRLEVEL(pCmd, pnum); case CMD_DROPITEM: - return On_DROPITEM((TCmdPItem *)pCmd, pnum); + return On_DROPITEM(pCmd, pnum); case CMD_ACK_PLRINFO: - return On_ACK_PLRINFO((TCmdPlrInfoHdr *)pCmd, pnum); + return On_ACK_PLRINFO(pCmd, pnum); case CMD_SEND_PLRINFO: - return On_SEND_PLRINFO((TCmdPlrInfoHdr *)pCmd, pnum); + return On_SEND_PLRINFO(pCmd, pnum); case CMD_PLAYER_JOINLEVEL: - return On_PLAYER_JOINLEVEL((TCmdLocParam1 *)pCmd, pnum); + return On_PLAYER_JOINLEVEL(pCmd, pnum); case CMD_ACTIVATEPORTAL: - return On_ACTIVATEPORTAL((TCmdLocParam3 *)pCmd, pnum); + return On_ACTIVATEPORTAL(pCmd, pnum); case CMD_DEACTIVATEPORTAL: return On_DEACTIVATEPORTAL(pCmd, pnum); case CMD_RETOWN: return On_RETOWN(pCmd, pnum); case CMD_SETSTR: - return On_SETSTR((TCmdParam1 *)pCmd, pnum); + return On_SETSTR(pCmd, pnum); case CMD_SETMAG: - return On_SETMAG((TCmdParam1 *)pCmd, pnum); + return On_SETMAG(pCmd, pnum); case CMD_SETDEX: - return On_SETDEX((TCmdParam1 *)pCmd, pnum); + return On_SETDEX(pCmd, pnum); case CMD_SETVIT: - return On_SETVIT((TCmdParam1 *)pCmd, pnum); + return On_SETVIT(pCmd, pnum); case CMD_STRING: - return On_STRING((TCmdString *)pCmd, pnum); + return On_STRING(pCmd, pnum); case CMD_SYNCQUEST: - return On_SYNCQUEST((TCmdQuest *)pCmd, pnum); + return On_SYNCQUEST(pCmd, pnum); case CMD_ENDSHIELD: return On_ENDSHIELD(pCmd, pnum); case CMD_CHEAT_EXPERIENCE: @@ -1147,7 +1126,7 @@ int ParseCmd(int pnum, TCmd *pCmd) case CMD_CHEAT_SPELL_LEVEL: return On_CHEAT_SPELL_LEVEL(pCmd, pnum); case CMD_NOVA: - return On_NOVA((TCmdLoc *)pCmd, pnum); + return On_NOVA(pCmd, pnum); case CMD_SETSHIELD: return On_SETSHIELD(pCmd, pnum); case CMD_REMSHIELD: @@ -1161,40 +1140,35 @@ int ParseCmd(int pnum, TCmd *pCmd) return On_DLEVEL(pnum, pCmd); } -// 66E4A9: using guessed type char sbLastCmd; -// 67618D: using guessed type char sgbDeltaChunks; -// 6796E4: using guessed type char gbDeltaSender; -int On_DLEVEL(int pnum, TCmd *pCmd) +DWORD On_DLEVEL(int pnum, TCmd *pCmd) { - TCmdPlrInfoHdr *p; - - p = (TCmdPlrInfoHdr *)pCmd; + TCmdPlrInfoHdr *p = (TCmdPlrInfoHdr *)pCmd; - if(gbDeltaSender != pnum) { - if(p->bCmd == CMD_DLEVEL_END) { + if (gbDeltaSender != pnum) { + if (p->bCmd == CMD_DLEVEL_END) { gbDeltaSender = pnum; sgbRecvCmd = CMD_DLEVEL_END; - } else if(p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) { + } else if (p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) { gbDeltaSender = pnum; sgbRecvCmd = CMD_DLEVEL_END; } else { return p->wBytes + sizeof(*p); } } - if(sgbRecvCmd == CMD_DLEVEL_END) { - if(p->bCmd == CMD_DLEVEL_END) { + if (sgbRecvCmd == CMD_DLEVEL_END) { + if (p->bCmd == CMD_DLEVEL_END) { sgbDeltaChunks = 20; return p->wBytes + sizeof(*p); - } else if(p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) { + } else if (p->bCmd == CMD_DLEVEL_0 && p->wOffset == 0) { sgdwRecvOffset = 0; sgbRecvCmd = p->bCmd; } else { return p->wBytes + sizeof(*p); } - } else if(sgbRecvCmd != p->bCmd) { + } else if (sgbRecvCmd != p->bCmd) { DeltaImportData(sgbRecvCmd, sgdwRecvOffset); - if(p->bCmd == CMD_DLEVEL_END) { + if (p->bCmd == CMD_DLEVEL_END) { sgbDeltaChunks = 20; sgbRecvCmd = CMD_DLEVEL_END; return p->wBytes + sizeof(*p); @@ -1233,7 +1207,6 @@ void DeltaImportData(BYTE cmd, DWORD recv_offset) sgbDeltaChunks++; sgbDeltaChanged = TRUE; } -// 67618D: using guessed type char sgbDeltaChunks; BYTE *DeltaImportItem(BYTE *src, TCmdPItem *dst) { @@ -1313,67 +1286,79 @@ void DeltaImportJunk(BYTE *src) } } -int On_SYNCDATA(void *packet, int pnum) +DWORD On_SYNCDATA(TCmd *pCmd, int pnum) { - return sync_update(pnum, (const BYTE *)packet); + return sync_update(pnum, (const BYTE *)pCmd); } -int On_WALKXY(TCmdLoc *pCmd, int pnum) +DWORD On_WALKXY(TCmd *pCmd, int pnum) { + TCmdLoc *p = (TCmdLoc *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(pnum); - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + MakePlrPath(pnum, p->x, p->y, TRUE); plr[pnum].destAction = ACTION_NONE; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ADDSTR(TCmdParam1 *pCmd, int pnum) +DWORD On_ADDSTR(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrStr(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 256) + ModifyPlrStr(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_ADDMAG(TCmdParam1 *pCmd, int pnum) +DWORD On_ADDMAG(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrMag(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 256) + ModifyPlrMag(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_ADDDEX(TCmdParam1 *pCmd, int pnum) +DWORD On_ADDDEX(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrDex(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 256) + ModifyPlrDex(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_ADDVIT(TCmdParam1 *pCmd, int pnum) +DWORD On_ADDVIT(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 256) - ModifyPlrVit(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 256) + ModifyPlrVit(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_SBSPELL(TCmdParam1 *pCmd, int pnum) +DWORD On_SBSPELL(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { - plr[pnum]._pSpell = pCmd->wParam1; + if (currlevel != 0 || spelldata[p->wParam1].sTownSpell) { + plr[pnum]._pSpell = p->wParam1; plr[pnum]._pSplType = plr[pnum]._pSBkSplType; plr[pnum]._pSplFrom = 1; plr[pnum].destAction = ACTION_SPELL; @@ -1381,7 +1366,7 @@ int On_SBSPELL(TCmdParam1 *pCmd, int pnum) msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } void __cdecl msg_errorf(const char *pszFmt, ...) @@ -1401,35 +1386,39 @@ void __cdecl msg_errorf(const char *pszFmt, ...) va_end(va); } -int On_GOTOGETITEM(TCmdLocParam1 *pCmd, int pnum) +DWORD On_GOTOGETITEM(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + MakePlrPath(pnum, p->x, p->y, FALSE); plr[pnum].destAction = ACTION_PICKUPITEM; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_REQUESTGITEM(TCmdGItem *pCmd, int pnum) +DWORD On_REQUESTGITEM(TCmd *pCmd, int pnum) { + TCmdGItem *p = (TCmdGItem *)pCmd; + if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { - if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (GetItemRecord(p->dwSeed, p->wCI, p->wIndx)) { + int ii = FindGetItem(p->wIndx, p->wCI, p->dwSeed); if (ii != -1) { - NetSendCmdGItem2(FALSE, CMD_GETITEM, myplr, pCmd->bPnum, pCmd); - if (pCmd->bPnum != myplr) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + NetSendCmdGItem2(FALSE, CMD_GETITEM, myplr, p->bPnum, p); + if (p->bPnum != myplr) + SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); else InvGetItem(myplr, ii); - SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - } else if (!NetSendCmdReq2(CMD_REQUESTGITEM, myplr, pCmd->bPnum, pCmd)) - NetSendCmdExtra(pCmd); + SetItemRecord(p->dwSeed, p->wCI, p->wIndx); + } else if (!NetSendCmdReq2(CMD_REQUESTGITEM, myplr, p->bPnum, p)) + NetSendCmdExtra(p); } } - return sizeof(*pCmd); + return sizeof(*p); } BOOL i_own_level(int nReqLevel) @@ -1446,31 +1435,32 @@ BOOL i_own_level(int nReqLevel) return i == myplr; } -// 676194: using guessed type char gbBufferMsgs; -int On_GETITEM(TCmdGItem *pCmd, int pnum) +DWORD On_GETITEM(TCmd *pCmd, int pnum) { + TCmdGItem *p = (TCmdGItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (delta_get_item(pCmd, pCmd->bLevel)) { - if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { - if (pCmd->bPnum == myplr) { - if (currlevel != pCmd->bLevel) { - ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + int ii = FindGetItem(p->wIndx, p->wCI, p->dwSeed); + if (delta_get_item(p, p->bLevel)) { + if ((currlevel == p->bLevel || p->bPnum == myplr) && p->bMaster != myplr) { + if (p->bPnum == myplr) { + if (currlevel != p->bLevel) { + ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); if (ii != -1) InvGetItem(myplr, ii); } else InvGetItem(myplr, ii); } else - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); } } else - NetSendCmdGItem2(TRUE, CMD_GETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); + NetSendCmdGItem2(TRUE, CMD_GETITEM, p->bMaster, p->bPnum, p); } - return sizeof(*pCmd); + return sizeof(*p); } BOOL delta_get_item(TCmdGItem *pI, BYTE bLevel) @@ -1532,100 +1522,109 @@ BOOL delta_get_item(TCmdGItem *pI, BYTE bLevel) } return result; } -// 679660: using guessed type char gbMaxPlayers; -int On_GOTOAGETITEM(TCmdLocParam1 *pCmd, int pnum) +DWORD On_GOTOAGETITEM(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + MakePlrPath(pnum, p->x, p->y, FALSE); plr[pnum].destAction = ACTION_PICKUPAITEM; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_REQUESTAGITEM(TCmdGItem *pCmd, int pnum) +DWORD On_REQUESTAGITEM(TCmd *pCmd, int pnum) { + TCmdGItem *p = (TCmdGItem *)pCmd; + if (gbBufferMsgs != 1 && i_own_level(plr[pnum].plrlevel)) { - if (GetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx)) { - int ii = FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + if (GetItemRecord(p->dwSeed, p->wCI, p->wIndx)) { + int ii = FindGetItem(p->wIndx, p->wCI, p->dwSeed); if (ii != -1) { - NetSendCmdGItem2(FALSE, CMD_AGETITEM, myplr, pCmd->bPnum, pCmd); - if (pCmd->bPnum != myplr) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + NetSendCmdGItem2(FALSE, CMD_AGETITEM, myplr, p->bPnum, p); + if (p->bPnum != myplr) + SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); else - AutoGetItem(myplr, pCmd->bCursitem); - SetItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - } else if (!NetSendCmdReq2(CMD_REQUESTAGITEM, myplr, pCmd->bPnum, pCmd)) - NetSendCmdExtra(pCmd); + AutoGetItem(myplr, p->bCursitem); + SetItemRecord(p->dwSeed, p->wCI, p->wIndx); + } else if (!NetSendCmdReq2(CMD_REQUESTAGITEM, myplr, p->bPnum, p)) + NetSendCmdExtra(p); } } - return sizeof(*pCmd); + return sizeof(*p); } -int On_AGETITEM(TCmdGItem *pCmd, int pnum) +DWORD On_AGETITEM(TCmd *pCmd, int pnum) { + TCmdGItem *p = (TCmdGItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - FindGetItem(pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); - if (delta_get_item(pCmd, pCmd->bLevel)) { - if ((currlevel == pCmd->bLevel || pCmd->bPnum == myplr) && pCmd->bMaster != myplr) { - if (pCmd->bPnum == myplr) { - if (currlevel != pCmd->bLevel) { - int ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + FindGetItem(p->wIndx, p->wCI, p->dwSeed); + if (delta_get_item(p, p->bLevel)) { + if ((currlevel == p->bLevel || p->bPnum == myplr) && p->bMaster != myplr) { + if (p->bPnum == myplr) { + if (currlevel != p->bLevel) { + int ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); if (ii != -1) AutoGetItem(myplr, ii); } else - AutoGetItem(myplr, pCmd->bCursitem); + AutoGetItem(myplr, p->bCursitem); } else - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); } } else - NetSendCmdGItem2(TRUE, CMD_AGETITEM, pCmd->bMaster, pCmd->bPnum, pCmd); + NetSendCmdGItem2(TRUE, CMD_AGETITEM, p->bMaster, p->bPnum, p); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ITEMEXTRA(TCmdGItem *pCmd, int pnum) +DWORD On_ITEMEXTRA(TCmd *pCmd, int pnum) { + TCmdGItem *p = (TCmdGItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - delta_get_item(pCmd, pCmd->bLevel); + delta_get_item(p, p->bLevel); if (currlevel == plr[pnum].plrlevel) - SyncGetItem(pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed); + SyncGetItem(p->x, p->y, p->wIndx, p->wCI, p->dwSeed); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_PUTITEM(TCmdPItem *pCmd, int pnum) +DWORD On_PUTITEM(TCmd *pCmd, int pnum) { + TCmdPItem *p = (TCmdPItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (currlevel == plr[pnum].plrlevel) { int ii; if (pnum == myplr) - ii = InvPutItem(pnum, pCmd->x, pCmd->y); + ii = InvPutItem(pnum, p->x, p->y); else - ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + ii = SyncPutItem(pnum, p->x, p->y, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); if (ii != -1) { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); + PutItemRecord(p->dwSeed, p->wCI, p->wIndx); + delta_put_item(p, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); check_update_plr(pnum); } - return sizeof(*pCmd); + return sizeof(*p); } else { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + PutItemRecord(p->dwSeed, p->wCI, p->wIndx); + delta_put_item(p, p->x, p->y, plr[pnum].plrlevel); check_update_plr(pnum); } - return sizeof(*pCmd); + return sizeof(*p); } void delta_put_item(TCmdPItem *pI, int x, int y, BYTE bLevel) @@ -1667,392 +1666,447 @@ void check_update_plr(int pnum) if (gbMaxPlayers != 1 && pnum == myplr) pfile_update(1); } -// 679660: using guessed type char gbMaxPlayers; -int On_SYNCPUTITEM(TCmdPItem *pCmd, int pnum) +DWORD On_SYNCPUTITEM(TCmd *pCmd, int pnum) { + TCmdPItem *p = (TCmdPItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (currlevel == plr[pnum].plrlevel) { - int ii = SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); + int ii = SyncPutItem(pnum, p->x, p->y, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); if (ii != -1) { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); + PutItemRecord(p->dwSeed, p->wCI, p->wIndx); + delta_put_item(p, item[ii]._ix, item[ii]._iy, plr[pnum].plrlevel); check_update_plr(pnum); } - return sizeof(*pCmd); + return sizeof(*p); } else { - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + PutItemRecord(p->dwSeed, p->wCI, p->wIndx); + delta_put_item(p, p->x, p->y, plr[pnum].plrlevel); check_update_plr(pnum); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_RESPAWNITEM(TCmdPItem *pCmd, int pnum) +DWORD On_RESPAWNITEM(TCmd *pCmd, int pnum) { + TCmdPItem *p = (TCmdPItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel && pnum != myplr) - SyncPutItem(pnum, pCmd->x, pCmd->y, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId, pCmd->bDur, pCmd->bMDur, pCmd->bCh, pCmd->bMCh, pCmd->wValue, pCmd->dwBuff); - PutItemRecord(pCmd->dwSeed, pCmd->wCI, pCmd->wIndx); - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + SyncPutItem(pnum, p->x, p->y, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff); + PutItemRecord(p->dwSeed, p->wCI, p->wIndx); + delta_put_item(p, p->x, p->y, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ATTACKXY(TCmdLoc *pCmd, int pnum) +DWORD On_ATTACKXY(TCmd *pCmd, int pnum) { + TCmdLoc *p = (TCmdLoc *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + MakePlrPath(pnum, p->x, p->y, FALSE); plr[pnum].destAction = ACTION_ATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SATTACKXY(TCmdLoc *pCmd, int pnum) +DWORD On_SATTACKXY(TCmd *pCmd, int pnum) { + TCmdLoc *p = (TCmdLoc *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_ATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_RATTACKXY(TCmdLoc *pCmd, int pnum) +DWORD On_RATTACKXY(TCmd *pCmd, int pnum) { + TCmdLoc *p = (TCmdLoc *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_RATTACK; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SPELLXYD(TCmdLocParam3 *pCmd, int pnum) +DWORD On_SPELLXYD(TCmd *pCmd, int pnum) { + TCmdLocParam3 *p = (TCmdLocParam3 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam1].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELLWALL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum].destParam4 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; + plr[pnum].destParam3 = p->wParam2; + plr[pnum].destParam4 = p->wParam3; + plr[pnum]._pSpell = p->wParam1; plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SPELLXY(TCmdLocParam2 *pCmd, int pnum) +DWORD On_SPELLXY(TCmd *pCmd, int pnum) { + TCmdLocParam2 *p = (TCmdLocParam2 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam1].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; + plr[pnum].destParam3 = p->wParam2; + plr[pnum]._pSpell = p->wParam1; plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_TSPELLXY(TCmdLocParam2 *pCmd, int pnum) +DWORD On_TSPELLXY(TCmd *pCmd, int pnum) { + TCmdLocParam2 *p = (TCmdLocParam2 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam1].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam1].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; - plr[pnum].destParam3 = pCmd->wParam2; - plr[pnum]._pSpell = pCmd->wParam1; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; + plr[pnum].destParam3 = p->wParam2; + plr[pnum]._pSpell = p->wParam1; plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_OPOBJXY(TCmdLocParam1 *pCmd, int pnum) +DWORD On_OPOBJXY(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag) + MakePlrPath(pnum, p->x, p->y, FALSE); else - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + MakePlrPath(pnum, p->x, p->y, TRUE); plr[pnum].destAction = ACTION_OPERATE; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_DISARMXY(TCmdLocParam1 *pCmd, int pnum) +DWORD On_DISARMXY(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (object[pCmd->wParam1]._oSolidFlag || object[pCmd->wParam1]._oDoorFlag) - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + if (object[p->wParam1]._oSolidFlag || object[p->wParam1]._oDoorFlag) + MakePlrPath(pnum, p->x, p->y, FALSE); else - MakePlrPath(pnum, pCmd->x, pCmd->y, TRUE); + MakePlrPath(pnum, p->x, p->y, TRUE); plr[pnum].destAction = ACTION_DISARM; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_OPOBJT(TCmdParam1 *pCmd, int pnum) +DWORD On_OPOBJT(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { plr[pnum].destAction = ACTION_OPERATETK; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 =p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ATTACKID(TCmdParam1 *pCmd, int pnum) +DWORD On_ATTACKID(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - int distx = abs(plr[pnum].WorldX - monster[pCmd->wParam1]._mfutx); - int disty = abs(plr[pnum].WorldY - monster[pCmd->wParam1]._mfuty); + int distx = abs(plr[pnum].WorldX - monster[p->wParam1]._mfutx); + int disty = abs(plr[pnum].WorldY - monster[p->wParam1]._mfuty); if (distx > 1 || disty > 1) - MakePlrPath(pnum, monster[pCmd->wParam1]._mfutx, monster[pCmd->wParam1]._mfuty, FALSE); + MakePlrPath(pnum, monster[p->wParam1]._mfutx, monster[p->wParam1]._mfuty, FALSE); plr[pnum].destAction = ACTION_ATTACKMON; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ATTACKPID(TCmdParam1 *pCmd, int pnum) +DWORD On_ATTACKPID(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, plr[pCmd->wParam1]._px, plr[pCmd->wParam1]._py, FALSE); + MakePlrPath(pnum, plr[p->wParam1]._px, plr[p->wParam1]._py, FALSE); plr[pnum].destAction = ACTION_ATTACKPLR; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_RATTACKID(TCmdParam1 *pCmd, int pnum) +DWORD On_RATTACKID(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_RATTACKMON; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_RATTACKPID(TCmdParam1 *pCmd, int pnum) +DWORD On_RATTACKPID(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_RATTACKPLR; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SPELLID(TCmdParam3 *pCmd, int pnum) +DWORD On_SPELLID(TCmd *pCmd, int pnum) { + TCmdParam3 *p = (TCmdParam3 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam2].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELLMON; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum].destParam1 = p->wParam1; + plr[pnum].destParam2 = p->wParam3; + plr[pnum]._pSpell = p->wParam2; plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SPELLPID(TCmdParam3 *pCmd, int pnum) +DWORD On_SPELLPID(TCmd *pCmd, int pnum) { + TCmdParam3 *p = (TCmdParam3 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam2].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELLPLR; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum].destParam1 = p->wParam1; + plr[pnum].destParam2 = p->wParam3; + plr[pnum]._pSpell = p->wParam2; plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_TSPELLID(TCmdParam3 *pCmd, int pnum) +DWORD On_TSPELLID(TCmd *pCmd, int pnum) { + TCmdParam3 *p = (TCmdParam3 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam2].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELLMON; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum].destParam1 = p->wParam1; + plr[pnum].destParam2 = p->wParam3; + plr[pnum]._pSpell = p->wParam2; plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_TSPELLPID(TCmdParam3 *pCmd, int pnum) +DWORD On_TSPELLPID(TCmd *pCmd, int pnum) { + TCmdParam3 *p = (TCmdParam3 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - if (currlevel != 0 || spelldata[pCmd->wParam2].sTownSpell) { + if (currlevel != 0 || spelldata[p->wParam2].sTownSpell) { ClrPlrPath(pnum); plr[pnum].destAction = ACTION_SPELLPLR; - plr[pnum].destParam1 = pCmd->wParam1; - plr[pnum].destParam2 = pCmd->wParam3; - plr[pnum]._pSpell = pCmd->wParam2; + plr[pnum].destParam1 = p->wParam1; + plr[pnum].destParam2 = p->wParam3; + plr[pnum]._pSpell = p->wParam2; plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else msg_errorf("%s has cast an illegal spell.", plr[pnum]._pName); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_KNOCKBACK(TCmdParam1 *pCmd, int pnum) +DWORD On_KNOCKBACK(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - M_GetKnockback(pCmd->wParam1); - M_StartHit(pCmd->wParam1, pnum, 0); + M_GetKnockback(p->wParam1); + M_StartHit(p->wParam1, pnum, 0); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_RESURRECT(TCmdParam1 *pCmd, int pnum) +DWORD On_RESURRECT(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - DoResurrect(pnum, pCmd->wParam1); + DoResurrect(pnum, p->wParam1); check_update_plr(pnum); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_HEALOTHER(TCmdParam1 *pCmd, int pnum) +DWORD On_HEALOTHER(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) - DoHealOther(pnum, pCmd->wParam1); + DoHealOther(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_TALKXY(TCmdLocParam1 *pCmd, int pnum) +DWORD On_TALKXY(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) { - MakePlrPath(pnum, pCmd->x, pCmd->y, FALSE); + MakePlrPath(pnum, p->x, p->y, FALSE); plr[pnum].destAction = ACTION_TALK; - plr[pnum].destParam1 = pCmd->wParam1; + plr[pnum].destParam1 = p->wParam1; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_NEWLVL(TCmdParam2 *pCmd, int pnum) +DWORD On_NEWLVL(TCmd *pCmd, int pnum) { + TCmdParam2 *p = (TCmdParam2 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) - StartNewLvl(pnum, pCmd->wParam1, pCmd->wParam2); + StartNewLvl(pnum, p->wParam1, p->wParam2); - return sizeof(*pCmd); + return sizeof(*p); } -int On_WARP(TCmdParam1 *pCmd, int pnum) +DWORD On_WARP(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - StartWarpLvl(pnum, pCmd->wParam1); + StartWarpLvl(pnum, p->wParam1); if (pnum == myplr && pcurs >= CURSOR_FIRSTITEM) { item[MAXITEMS] = plr[myplr].HoldItem; AutoGetItem(myplr, MAXITEMS); } } - return sizeof(*pCmd); + return sizeof(*p); } -int On_MONSTDEATH(TCmdLocParam1 *pCmd, int pnum) +DWORD On_MONSTDEATH(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) { if (currlevel == plr[pnum].plrlevel) - M_SyncStartKill(pCmd->wParam1, pCmd->x, pCmd->y, pnum); - delta_kill_monster(pCmd->wParam1, pCmd->x, pCmd->y, plr[pnum].plrlevel); + M_SyncStartKill(p->wParam1, p->x, p->y, pnum); + delta_kill_monster(p->wParam1, p->x, p->y, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_KILLGOLEM(TCmdLocParam1 *pCmd, int pnum) +DWORD On_KILLGOLEM(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) { - if (currlevel == pCmd->wParam1) - M_SyncStartKill(pnum, pCmd->x, pCmd->y, pnum); - delta_kill_monster(pnum, pCmd->x, pCmd->y, plr[pnum].plrlevel); + if (currlevel == p->wParam1) + M_SyncStartKill(pnum, p->x, p->y, pnum); + delta_kill_monster(pnum, p->x, p->y, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_AWAKEGOLEM(TCmdGolem *pCmd, int pnum) +DWORD On_AWAKEGOLEM(TCmd *pCmd, int pnum) { + TCmdGolem *p = (TCmdGolem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (currlevel != plr[pnum].plrlevel) - delta_sync_golem(pCmd, pnum, pCmd->_currlevel); + delta_sync_golem(p, pnum, p->_currlevel); else if (pnum != myplr) { int i; // check if this player already has an active golem @@ -2065,52 +2119,58 @@ int On_AWAKEGOLEM(TCmdGolem *pCmd, int pnum) } } if (addGolem) - AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, pCmd->_mx, pCmd->_my, pCmd->_mdir, MIS_GOLEM, 0, pnum, 0, 1); + AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, p->_mx, p->_my, p->_mdir, MIS_GOLEM, 0, pnum, 0, 1); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_MONSTDAMAGE(TCmdParam2 *pCmd, int pnum) +DWORD On_MONSTDAMAGE(TCmd *pCmd, int pnum) { + TCmdParam2 *p = (TCmdParam2 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) { if (currlevel == plr[pnum].plrlevel) { - monster[pCmd->wParam1].mWhoHit |= 1 << pnum; + monster[p->wParam1].mWhoHit |= 1 << pnum; - if (monster[pCmd->wParam1]._mhitpoints) { - monster[pCmd->wParam1]._mhitpoints -= pCmd->wParam2; - if ((monster[pCmd->wParam1]._mhitpoints >> 6) < 1) - monster[pCmd->wParam1]._mhitpoints = 1 << 6; - delta_monster_hp(pCmd->wParam1, monster[pCmd->wParam1]._mhitpoints, plr[pnum].plrlevel); + if (monster[p->wParam1]._mhitpoints) { + monster[p->wParam1]._mhitpoints -= p->wParam2; + if ((monster[p->wParam1]._mhitpoints >> 6) < 1) + monster[p->wParam1]._mhitpoints = 1 << 6; + delta_monster_hp(p->wParam1, monster[p->wParam1]._mhitpoints, plr[pnum].plrlevel); } } } - return sizeof(*pCmd); + return sizeof(*p); } -int On_PLRDEAD(TCmdParam1 *pCmd, int pnum) +DWORD On_PLRDEAD(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) - StartPlayerKill(pnum, pCmd->wParam1); + StartPlayerKill(pnum, p->wParam1); else check_update_plr(pnum); - return sizeof(*pCmd); + return sizeof(*p); } -int On_PLRDAMAGE(TCmdDamage *pCmd, int pnum) +DWORD On_PLRDAMAGE(TCmd *pCmd, int pnum) { - if (pCmd->bPlr == myplr && currlevel != 0) { - if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pCmd->dwDam <= 192000) { + TCmdDamage *p = (TCmdDamage *)pCmd; + + if (p->bPlr == myplr && currlevel != 0) { + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && p->dwDam <= 192000) { if ((plr[myplr]._pHitPoints >> 6) > 0) { drawhpflag = TRUE; - plr[myplr]._pHitPoints -= pCmd->dwDam; - plr[myplr]._pHPBase -= pCmd->dwDam; + plr[myplr]._pHitPoints -= p->dwDam; + plr[myplr]._pHPBase -= p->dwDam; if (plr[myplr]._pHitPoints > plr[myplr]._pMaxHP) { plr[myplr]._pHitPoints = plr[myplr]._pMaxHP; plr[myplr]._pHPBase = plr[myplr]._pMaxHPBase; @@ -2121,20 +2181,22 @@ int On_PLRDAMAGE(TCmdDamage *pCmd, int pnum) } } - return sizeof(*pCmd); + return sizeof(*p); } -int On_OPENDOOR(TCmdParam1 *pCmd, int pnum) +DWORD On_OPENDOOR(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_OPENDOOR, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_OPENDOOR, plr[pnum].plrlevel); + SyncOpObject(pnum, CMD_OPENDOOR, p->wParam1); + delta_sync_object(p->wParam1, CMD_OPENDOOR, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } void delta_sync_object(int oi, BYTE bCmd, BYTE bLevel) @@ -2144,119 +2206,138 @@ void delta_sync_object(int oi, BYTE bCmd, BYTE bLevel) sgLevels[bLevel].object[oi].bCmd = bCmd; } } -// 679660: using guessed type char gbMaxPlayers; -int On_CLOSEDOOR(TCmdParam1 *pCmd, int pnum) +DWORD On_CLOSEDOOR(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_CLOSEDOOR, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_CLOSEDOOR, plr[pnum].plrlevel); + SyncOpObject(pnum, CMD_CLOSEDOOR, p->wParam1); + delta_sync_object(p->wParam1, CMD_CLOSEDOOR, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_OPERATEOBJ(TCmdParam1 *pCmd, int pnum) +DWORD On_OPERATEOBJ(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pnum, CMD_OPERATEOBJ, pCmd->wParam1); - delta_sync_object(pCmd->wParam1, CMD_OPERATEOBJ, plr[pnum].plrlevel); + SyncOpObject(pnum, CMD_OPERATEOBJ, p->wParam1); + delta_sync_object(p->wParam1, CMD_OPERATEOBJ, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_PLROPOBJ(TCmdParam2 *pCmd, int pnum) +DWORD On_PLROPOBJ(TCmd *pCmd, int pnum) { + TCmdParam2 *p = (TCmdParam2 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel) - SyncOpObject(pCmd->wParam1, CMD_PLROPOBJ, pCmd->wParam2); - delta_sync_object(pCmd->wParam2, CMD_PLROPOBJ, plr[pnum].plrlevel); + SyncOpObject(p->wParam1, CMD_PLROPOBJ, p->wParam2); + delta_sync_object(p->wParam2, CMD_PLROPOBJ, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_BREAKOBJ(TCmdParam2 *pCmd, int pnum) +DWORD On_BREAKOBJ(TCmd *pCmd, int pnum) { + TCmdParam2 *p = (TCmdParam2 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (currlevel == plr[pnum].plrlevel) - SyncBreakObj(pCmd->wParam1, pCmd->wParam2); - delta_sync_object(pCmd->wParam2, CMD_BREAKOBJ, plr[pnum].plrlevel); + SyncBreakObj(p->wParam1, p->wParam2); + delta_sync_object(p->wParam2, CMD_BREAKOBJ, plr[pnum].plrlevel); } - return sizeof(*pCmd); + return sizeof(*p); } -int On_CHANGEPLRITEMS(TCmdChItem *pCmd, int pnum) +DWORD On_CHANGEPLRITEMS(TCmd *pCmd, int pnum) { + TCmdChItem *p = (TCmdChItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) - CheckInvSwap(pnum, pCmd->bLoc, pCmd->wIndx, pCmd->wCI, pCmd->dwSeed, pCmd->bId); + CheckInvSwap(pnum, p->bLoc, p->wIndx, p->wCI, p->dwSeed, p->bId); - return sizeof(*pCmd); + return sizeof(*p); } -int On_DELPLRITEMS(TCmdDelItem *pCmd, int pnum) +DWORD On_DELPLRITEMS(TCmd *pCmd, int pnum) { + TCmdDelItem *p = (TCmdDelItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else if (pnum != myplr) - inv_update_rem_item(pnum, pCmd->bLoc); + inv_update_rem_item(pnum, p->bLoc); - return sizeof(*pCmd); + return sizeof(*p); } -int On_PLRLEVEL(TCmdParam1 *pCmd, int pnum) +DWORD On_PLRLEVEL(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= MAXCHARLEVEL && pnum != myplr) - plr[pnum]._pLevel = pCmd->wParam1; + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= MAXCHARLEVEL && pnum != myplr) + plr[pnum]._pLevel = p->wParam1; - return sizeof(*pCmd); + return sizeof(*p); } -int On_DROPITEM(TCmdPItem *pCmd, int pnum) +DWORD On_DROPITEM(TCmd *pCmd, int pnum) { + TCmdPItem *p = (TCmdPItem *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else - delta_put_item(pCmd, pCmd->x, pCmd->y, plr[pnum].plrlevel); + delta_put_item(p, p->x, p->y, plr[pnum].plrlevel); - return sizeof(*pCmd); + return sizeof(*p); } -int On_SEND_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum) +DWORD On_SEND_PLRINFO(TCmd *pCmd, int pnum) { + TCmdPlrInfoHdr *p = (TCmdPlrInfoHdr *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, pCmd->wBytes + sizeof(*pCmd)); + msg_send_packet(pnum, p, p->wBytes + sizeof(*p)); else - recv_plrinfo(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO); + recv_plrinfo(pnum, p, p->bCmd == CMD_ACK_PLRINFO); - return pCmd->wBytes + sizeof(*pCmd); + return p->wBytes + sizeof(*p); } -int On_ACK_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum) +DWORD On_ACK_PLRINFO(TCmd *pCmd, int pnum) { return On_SEND_PLRINFO(pCmd, pnum); } -int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum) +DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum) { + TCmdLocParam1 *p = (TCmdLocParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { plr[pnum]._pLvlChanging = 0; if (plr[pnum]._pName[0] && !plr[pnum].plractive) { @@ -2266,9 +2347,9 @@ int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum) } if (plr[pnum].plractive && myplr != pnum) { - plr[pnum].WorldX = pCmd->x; - plr[pnum].WorldY = pCmd->y; - plr[pnum].plrlevel = pCmd->wParam1; + plr[pnum].WorldX = p->x; + plr[pnum].WorldY = p->y; + plr[pnum].plrlevel = p->wParam1; plr[pnum]._pGFXLoad = 0; if (currlevel == plr[pnum].plrlevel) { LoadPlrGFX(pnum, PFILE_STAND); @@ -2291,15 +2372,17 @@ int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum) } } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ACTIVATEPORTAL(TCmdLocParam3 *pCmd, int pnum) +DWORD On_ACTIVATEPORTAL(TCmd *pCmd, int pnum) { + TCmdLocParam3 *p = (TCmdLocParam3 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { - ActivatePortal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); + ActivatePortal(pnum, p->x, p->y, p->wParam1, p->wParam2, p->wParam3); if (pnum != myplr) { if (currlevel == 0) AddInTownPortal(pnum); @@ -2314,14 +2397,14 @@ int On_ACTIVATEPORTAL(TCmdLocParam3 *pCmd, int pnum) } } if (addPortal) - AddWarpMissile(pnum, pCmd->x, pCmd->y); + AddWarpMissile(pnum, p->x, p->y); } else RemovePortalMissile(pnum); } - delta_open_portal(pnum, pCmd->x, pCmd->y, pCmd->wParam1, pCmd->wParam2, pCmd->wParam3); + delta_open_portal(pnum, p->x, p->y, p->wParam1, p->wParam2, p->wParam3); } - return sizeof(*pCmd); + return sizeof(*p); } void delta_open_portal(int pnum, BYTE x, BYTE y, BYTE bLevel, BYTE bLType, BYTE bSetLvl) @@ -2334,7 +2417,7 @@ void delta_open_portal(int pnum, BYTE x, BYTE y, BYTE bLevel, BYTE bLType, BYTE sgJunk.portal[pnum].setlvl = bSetLvl; } -int On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum) +DWORD On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum) { if (gbBufferMsgs == 1) msg_send_packet(pnum, pCmd, sizeof(*pCmd)); @@ -2348,7 +2431,7 @@ int On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_RETOWN(TCmd *pCmd, int pnum) +DWORD On_RETOWN(TCmd *pCmd, int pnum) { if (gbBufferMsgs == 1) msg_send_packet(pnum, pCmd, sizeof(*pCmd)); @@ -2363,74 +2446,86 @@ int On_RETOWN(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_SETSTR(TCmdParam1 *pCmd, int pnum) +DWORD On_SETSTR(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrStr(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 750 && pnum != myplr) + SetPlrStr(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_SETDEX(TCmdParam1 *pCmd, int pnum) +DWORD On_SETDEX(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrDex(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 750 && pnum != myplr) + SetPlrDex(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_SETMAG(TCmdParam1 *pCmd, int pnum) +DWORD On_SETMAG(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrMag(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 750 && pnum != myplr) + SetPlrMag(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_SETVIT(TCmdParam1 *pCmd, int pnum) +DWORD On_SETVIT(TCmd *pCmd, int pnum) { + TCmdParam1 *p = (TCmdParam1 *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); - else if (pCmd->wParam1 <= 750 && pnum != myplr) - SetPlrVit(pnum, pCmd->wParam1); + msg_send_packet(pnum, p, sizeof(*p)); + else if (p->wParam1 <= 750 && pnum != myplr) + SetPlrVit(pnum, p->wParam1); - return sizeof(*pCmd); + return sizeof(*p); } -int On_STRING(TCmdString *pCmd, int pnum) +DWORD On_STRING(TCmd *pCmd, int pnum) { return On_STRING2(pnum, pCmd); } -int On_STRING2(int pnum, TCmdString *pCmd) +DWORD On_STRING2(int pnum, TCmd *pCmd) { - int len = strlen(pCmd->str); + TCmdString *p = (TCmdString *)pCmd; + + int len = strlen(p->str); if (!gbBufferMsgs) - SendPlrMsg(pnum, pCmd->str); + SendPlrMsg(pnum, p->str); - return len + 2; // length of string + nul terminator + sizeof(pCmd->bCmd) + return len + 2; // length of string + nul terminator + sizeof(p->bCmd) } -int On_SYNCQUEST(TCmdQuest *pCmd, int pnum) +DWORD On_SYNCQUEST(TCmd *pCmd, int pnum) { + TCmdQuest *p = (TCmdQuest *)pCmd; + if (gbBufferMsgs == 1) - msg_send_packet(pnum, pCmd, sizeof(*pCmd)); + msg_send_packet(pnum, p, sizeof(*p)); else { if (pnum != myplr) - SetMultiQuest(pCmd->q, pCmd->qstate, pCmd->qlog, pCmd->qvar1); + SetMultiQuest(p->q, p->qstate, p->qlog, p->qvar1); sgbDeltaChanged = TRUE; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_ENDSHIELD(TCmd *pCmd, int pnum) +DWORD On_ENDSHIELD(TCmd *pCmd, int pnum) { int i; @@ -2447,7 +2542,7 @@ int On_ENDSHIELD(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_CHEAT_EXPERIENCE(TCmd *pCmd, int pnum) +DWORD On_CHEAT_EXPERIENCE(TCmd *pCmd, int pnum) { #ifdef _DEBUG if (gbBufferMsgs == 1) @@ -2460,7 +2555,7 @@ int On_CHEAT_EXPERIENCE(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_CHEAT_SPELL_LEVEL(TCmd *pCmd, int pnum) +DWORD On_CHEAT_SPELL_LEVEL(TCmd *pCmd, int pnum) { #ifdef _DEBUG if (gbBufferMsgs == 1) @@ -2471,27 +2566,29 @@ int On_CHEAT_SPELL_LEVEL(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_DEBUG(TCmd *pCmd, int pnum) +DWORD On_DEBUG(TCmd *pCmd, int pnum) { return sizeof(*pCmd); } -int On_NOVA(TCmdLoc *pCmd, int pnum) +DWORD On_NOVA(TCmd *pCmd, int pnum) { + TCmdLoc *p = (TCmdLoc *)pCmd; + if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel && pnum != myplr) { ClrPlrPath(pnum); plr[pnum]._pSpell = SPL_NOVA; plr[pnum]._pSplType = 4; plr[pnum]._pSplFrom = 3; plr[pnum].destAction = ACTION_SPELL; - plr[pnum].destParam1 = pCmd->x; - plr[pnum].destParam2 = pCmd->y; + plr[pnum].destParam1 = p->x; + plr[pnum].destParam2 = p->y; } - return sizeof(*pCmd); + return sizeof(*p); } -int On_SETSHIELD(TCmd *pCmd, int pnum) +DWORD On_SETSHIELD(TCmd *pCmd, int pnum) { if (gbBufferMsgs != 1) plr[pnum].pManaShield = TRUE; @@ -2499,7 +2596,7 @@ int On_SETSHIELD(TCmd *pCmd, int pnum) return sizeof(*pCmd); } -int On_REMSHIELD(TCmd *pCmd, int pnum) +DWORD On_REMSHIELD(TCmd *pCmd, int pnum) { if (gbBufferMsgs != 1) plr[pnum].pManaShield = FALSE; diff --git a/Source/msg.h b/Source/msg.h index 7bf75c73d01..3b2123f432c 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -52,94 +52,94 @@ void NetSendCmdDItem(BOOL bHiPri, int ii); void NetSendCmdDamage(BOOL bHiPri, BYTE bPlr, DWORD dwDam); void NetSendCmdString(int pmask, const char *pszStr); void RemovePlrPortal(int pnum); -int ParseCmd(int pnum, TCmd *pCmd); -int On_DLEVEL(int pnum, TCmd *pCmd); +DWORD ParseCmd(int pnum, TCmd *pCmd); +DWORD On_DLEVEL(int pnum, TCmd *pCmd); void DeltaImportData(BYTE cmd, DWORD recv_offset); BYTE *DeltaImportItem(BYTE *src, TCmdPItem *dst); BYTE *DeltaImportObject(BYTE *src, DObjectStr *dst); BYTE *DeltaImportMonster(BYTE *src, DMonsterStr *dst); void DeltaImportJunk(BYTE *src); -int On_SYNCDATA(void *packet, int pnum); -int On_WALKXY(TCmdLoc *pCmd, int pnum); -int On_ADDSTR(TCmdParam1 *pCmd, int pnum); -int On_ADDMAG(TCmdParam1 *pCmd, int pnum); -int On_ADDDEX(TCmdParam1 *pCmd, int pnum); -int On_ADDVIT(TCmdParam1 *pCmd, int pnum); -int On_SBSPELL(TCmdParam1 *pCmd, int pnum); +DWORD On_SYNCDATA(TCmd *pCmd, int pnum); +DWORD On_WALKXY(TCmd *pCmd, int pnum); +DWORD On_ADDSTR(TCmd *pCmd, int pnum); +DWORD On_ADDMAG(TCmd *pCmd, int pnum); +DWORD On_ADDDEX(TCmd *pCmd, int pnum); +DWORD On_ADDVIT(TCmd *pCmd, int pnum); +DWORD On_SBSPELL(TCmd *pCmd, int pnum); void __cdecl msg_errorf(const char *pszFmt, ...); -int On_GOTOGETITEM(TCmdLocParam1 *pCmd, int pnum); -int On_REQUESTGITEM(TCmdGItem *pCmd, int pnum); +DWORD On_GOTOGETITEM(TCmd *pCmd, int pnum); +DWORD On_REQUESTGITEM(TCmd *pCmd, int pnum); BOOL i_own_level(int nReqLevel); -int On_GETITEM(TCmdGItem *pCmd, int pnum); +DWORD On_GETITEM(TCmd *pCmd, int pnum); BOOL delta_get_item(TCmdGItem *pI, BYTE bLevel); -int On_GOTOAGETITEM(TCmdLocParam1 *pCmd, int pnum); -int On_REQUESTAGITEM(TCmdGItem *pCmd, int pnum); -int On_AGETITEM(TCmdGItem *pCmd, int pnum); -int On_ITEMEXTRA(TCmdGItem *pCmd, int pnum); -int On_PUTITEM(TCmdPItem *pCmd, int pnum); +DWORD On_GOTOAGETITEM(TCmd *pCmd, int pnum); +DWORD On_REQUESTAGITEM(TCmd *pCmd, int pnum); +DWORD On_AGETITEM(TCmd *pCmd, int pnum); +DWORD On_ITEMEXTRA(TCmd *pCmd, int pnum); +DWORD On_PUTITEM(TCmd *pCmd, int pnum); void delta_put_item(TCmdPItem *pI, int x, int y, BYTE bLevel); void check_update_plr(int pnum); -int On_SYNCPUTITEM(TCmdPItem *pCmd, int pnum); -int On_RESPAWNITEM(TCmdPItem *pCmd, int pnum); -int On_ATTACKXY(TCmdLoc *pCmd, int pnum); -int On_SATTACKXY(TCmdLoc *pCmd, int pnum); -int On_RATTACKXY(TCmdLoc *pCmd, int pnum); -int On_SPELLXYD(TCmdLocParam3 *pCmd, int pnum); -int On_SPELLXY(TCmdLocParam2 *pCmd, int pnum); -int On_TSPELLXY(TCmdLocParam2 *pCmd, int pnum); -int On_OPOBJXY(TCmdLocParam1 *pCmd, int pnum); -int On_DISARMXY(TCmdLocParam1 *pCmd, int pnum); -int On_OPOBJT(TCmdParam1 *pCmd, int pnum); -int On_ATTACKID(TCmdParam1 *pCmd, int pnum); -int On_ATTACKPID(TCmdParam1 *pCmd, int pnum); -int On_RATTACKID(TCmdParam1 *pCmd, int pnum); -int On_RATTACKPID(TCmdParam1 *pCmd, int pnum); -int On_SPELLID(TCmdParam3 *pCmd, int pnum); -int On_SPELLPID(TCmdParam3 *pCmd, int pnum); -int On_TSPELLID(TCmdParam3 *pCmd, int pnum); -int On_TSPELLPID(TCmdParam3 *pCmd, int pnum); -int On_KNOCKBACK(TCmdParam1 *pCmd, int pnum); -int On_RESURRECT(TCmdParam1 *pCmd, int pnum); -int On_HEALOTHER(TCmdParam1 *pCmd, int pnum); -int On_TALKXY(TCmdLocParam1 *pCmd, int pnum); -int On_NEWLVL(TCmdParam2 *pCmd, int pnum); -int On_WARP(TCmdParam1 *pCmd, int pnum); -int On_MONSTDEATH(TCmdLocParam1 *pCmd, int pnum); -int On_KILLGOLEM(TCmdLocParam1 *pCmd, int pnum); -int On_AWAKEGOLEM(TCmdGolem *pCmd, int pnum); -int On_MONSTDAMAGE(TCmdParam2 *pCmd, int pnum); -int On_PLRDEAD(TCmdParam1 *pCmd, int pnum); -int On_PLRDAMAGE(TCmdDamage *pCmd, int pnum); -int On_OPENDOOR(TCmdParam1 *pCmd, int pnum); +DWORD On_SYNCPUTITEM(TCmd *pCmd, int pnum); +DWORD On_RESPAWNITEM(TCmd *pCmd, int pnum); +DWORD On_ATTACKXY(TCmd *pCmd, int pnum); +DWORD On_SATTACKXY(TCmd *pCmd, int pnum); +DWORD On_RATTACKXY(TCmd *pCmd, int pnum); +DWORD On_SPELLXYD(TCmd *pCmd, int pnum); +DWORD On_SPELLXY(TCmd *pCmd, int pnum); +DWORD On_TSPELLXY(TCmd *pCmd, int pnum); +DWORD On_OPOBJXY(TCmd *pCmd, int pnum); +DWORD On_DISARMXY(TCmd *pCmd, int pnum); +DWORD On_OPOBJT(TCmd *pCmd, int pnum); +DWORD On_ATTACKID(TCmd *pCmd, int pnum); +DWORD On_ATTACKPID(TCmd *pCmd, int pnum); +DWORD On_RATTACKID(TCmd *pCmd, int pnum); +DWORD On_RATTACKPID(TCmd *pCmd, int pnum); +DWORD On_SPELLID(TCmd *pCmd, int pnum); +DWORD On_SPELLPID(TCmd *pCmd, int pnum); +DWORD On_TSPELLID(TCmd *pCmd, int pnum); +DWORD On_TSPELLPID(TCmd *pCmd, int pnum); +DWORD On_KNOCKBACK(TCmd *pCmd, int pnum); +DWORD On_RESURRECT(TCmd *pCmd, int pnum); +DWORD On_HEALOTHER(TCmd *pCmd, int pnum); +DWORD On_TALKXY(TCmd *pCmd, int pnum); +DWORD On_NEWLVL(TCmd *pCmd, int pnum); +DWORD On_WARP(TCmd *pCmd, int pnum); +DWORD On_MONSTDEATH(TCmd *pCmd, int pnum); +DWORD On_KILLGOLEM(TCmd *pCmd, int pnum); +DWORD On_AWAKEGOLEM(TCmd *pCmd, int pnum); +DWORD On_MONSTDAMAGE(TCmd *pCmd, int pnum); +DWORD On_PLRDEAD(TCmd *pCmd, int pnum); +DWORD On_PLRDAMAGE(TCmd *pCmd, int pnum); +DWORD On_OPENDOOR(TCmd *pCmd, int pnum); void delta_sync_object(int oi, BYTE bCmd, BYTE bLevel); -int On_CLOSEDOOR(TCmdParam1 *pCmd, int pnum); -int On_OPERATEOBJ(TCmdParam1 *pCmd, int pnum); -int On_PLROPOBJ(TCmdParam2 *pCmd, int pnum); -int On_BREAKOBJ(TCmdParam2 *pCmd, int pnum); -int On_CHANGEPLRITEMS(TCmdChItem *pCmd, int pnum); -int On_DELPLRITEMS(TCmdDelItem *pCmd, int pnum); -int On_PLRLEVEL(TCmdParam1 *pCmd, int pnum); -int On_DROPITEM(TCmdPItem *pCmd, int pnum); -int On_SEND_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum); -int On_ACK_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum); -int On_PLAYER_JOINLEVEL(TCmdLocParam1 *pCmd, int pnum); -int On_ACTIVATEPORTAL(TCmdLocParam3 *pCmd, int pnum); +DWORD On_CLOSEDOOR(TCmd *pCmd, int pnum); +DWORD On_OPERATEOBJ(TCmd *pCmd, int pnum); +DWORD On_PLROPOBJ(TCmd *pCmd, int pnum); +DWORD On_BREAKOBJ(TCmd *pCmd, int pnum); +DWORD On_CHANGEPLRITEMS(TCmd *pCmd, int pnum); +DWORD On_DELPLRITEMS(TCmd *pCmd, int pnum); +DWORD On_PLRLEVEL(TCmd *pCmd, int pnum); +DWORD On_DROPITEM(TCmd *pCmd, int pnum); +DWORD On_SEND_PLRINFO(TCmd *pCmd, int pnum); +DWORD On_ACK_PLRINFO(TCmd *pCmd, int pnum); +DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum); +DWORD On_ACTIVATEPORTAL(TCmd *pCmd, int pnum); void delta_open_portal(int pnum, BYTE x, BYTE y, BYTE bLevel, BYTE bLType, BYTE bSetLvl); -int On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum); -int On_RETOWN(TCmd *pCmd, int pnum); -int On_SETSTR(TCmdParam1 *pCmd, int pnum); -int On_SETDEX(TCmdParam1 *pCmd, int pnum); -int On_SETMAG(TCmdParam1 *pCmd, int pnum); -int On_SETVIT(TCmdParam1 *pCmd, int pnum); -int On_STRING(TCmdString *pCmd, int pnum); -int On_STRING2(int pnum, TCmdString *pCmd); -int On_SYNCQUEST(TCmdQuest *pCmd, int pnum); -int On_ENDSHIELD(TCmd *pCmd, int pnum); -int On_CHEAT_EXPERIENCE(TCmd *pCmd, int pnum); -int On_CHEAT_SPELL_LEVEL(TCmd *pCmd, int pnum); -int On_DEBUG(TCmd *pCmd, int pnum); -int On_NOVA(TCmdLoc *pCmd, int pnum); -int On_SETSHIELD(TCmd *pCmd, int pnum); -int On_REMSHIELD(TCmd *pCmd, int pnum); +DWORD On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum); +DWORD On_RETOWN(TCmd *pCmd, int pnum); +DWORD On_SETSTR(TCmd *pCmd, int pnum); +DWORD On_SETDEX(TCmd *pCmd, int pnum); +DWORD On_SETMAG(TCmd *pCmd, int pnum); +DWORD On_SETVIT(TCmd *pCmd, int pnum); +DWORD On_STRING(TCmd *pCmd, int pnum); +DWORD On_STRING2(int pnum, TCmd *pCmd); +DWORD On_SYNCQUEST(TCmd *pCmd, int pnum); +DWORD On_ENDSHIELD(TCmd *pCmd, int pnum); +DWORD On_CHEAT_EXPERIENCE(TCmd *pCmd, int pnum); +DWORD On_CHEAT_SPELL_LEVEL(TCmd *pCmd, int pnum); +DWORD On_DEBUG(TCmd *pCmd, int pnum); +DWORD On_NOVA(TCmd *pCmd, int pnum); +DWORD On_SETSHIELD(TCmd *pCmd, int pnum); +DWORD On_REMSHIELD(TCmd *pCmd, int pnum); #endif /* __MSG_H__ */ diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index c047b46c232..35c9fe0507d 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -12,7 +12,8 @@ DEVILUTION_BEGIN_NAMESPACE // static float msgcmd_init_cpp_value = 0x7F800000; struct EXTERNMESSAGE { - LIST_LINK(EXTERNMESSAGE) m_Link; + LIST_LINK(EXTERNMESSAGE) + m_Link; char command[COMMAND_LEN]; void *operator new(size_t n, DWORD extralen, int flags) { @@ -35,7 +36,7 @@ void *EXTERNMESSAGE::Delete(DWORD flags) if ((flags & 0x1) && this) { SMemFree(this, "delete", SLOG_FUNCTION, 0); } - return this; + return this; } static TList sgChat_Cmd; diff --git a/Source/multi.cpp b/Source/multi.cpp index a7badae5642..f9e1082a356 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -4,7 +4,7 @@ DEVILUTION_BEGIN_NAMESPACE -BOOLEAN gbSomebodyWonGameKludge; // weak +BOOLEAN gbSomebodyWonGameKludge; #ifdef _DEBUG DWORD gdwHistTicks; #endif @@ -14,22 +14,22 @@ WORD sgwPackPlrOffsetTbl[MAX_PLRS]; PkPlayerStruct netplr[MAX_PLRS]; BOOLEAN sgbPlayerTurnBitTbl[MAX_PLRS]; BOOLEAN sgbPlayerLeftGameTbl[MAX_PLRS]; -int sgbSentThisCycle; // idb +int sgbSentThisCycle; BOOL gbShouldValidatePackage; -BYTE gbActivePlayers; // weak +BYTE gbActivePlayers; BOOLEAN gbGameDestroyed; BOOLEAN sgbSendDeltaTbl[MAX_PLRS]; _gamedata sgGameInitInfo; -char byte_678640; // weak -int sglTimeoutStart; // weak +char byte_678640; +int sglTimeoutStart; int sgdwPlayerLeftReasonTbl[MAX_PLRS]; TBuffer sgLoPriBuf; -unsigned int sgdwGameLoops; // idb +unsigned int sgdwGameLoops; BYTE gbMaxPlayers; BOOLEAN sgbTimeout; char szPlayerName[128]; BYTE gbDeltaSender; -BOOL sgbNetInited; // weak +BOOL sgbNetInited; int player_state[MAX_PLRS]; const int event_types[3] = { @@ -153,7 +153,6 @@ void NetSendHiPri(BYTE *pbMsg, BYTE bLen) nthread_terminate_game("SNetSendMessage"); } } -// 679760: using guessed type int gdwNormalMsgSize; BYTE *multi_recv_packet(TBuffer *packet, BYTE *body, int *size) { @@ -427,9 +426,6 @@ void multi_begin_timeout() multi_check_drop_player(); } } -// 67862D: using guessed type char gbGameDestroyed; -// 678644: using guessed type int sglTimeoutStart; -// 679661: using guessed type char sgbTimeout; void multi_check_drop_player() { @@ -512,8 +508,6 @@ void multi_process_network_packets() if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) nthread_terminate_game("SNetReceiveMsg"); } -// 676194: using guessed type char gbBufferMsgs; -// 676198: using guessed type int pkt_counter; void multi_handle_all_packets(int pnum, BYTE *pData, int nSize) { @@ -574,7 +568,6 @@ void multi_send_zero_packet(DWORD pnum, char a2, void *pbSrc, DWORD dwLen) v5 += *(WORD *)&pkt.body[3]; } } -// 67975C: using guessed type int gdwLargestMsgSize; void NetClose() { @@ -683,7 +676,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) UiData.getdatacallback = (void (*)())UiGetDataCallback; UiData.categorycallback = (void (*)())UiCategoryCallback; UiData.selectnamecallback = mainmenu_select_hero_dialog; - UiData.changenamecallback = (void (*)())mainmenu_create_hero; + UiData.changenamecallback = (void (*)())mainmenu_change_name; UiData.profilebitmapcallback = (void (*)())UiProfileDraw; UiData.profilecallback = (void (*)())UiProfileCallback; UiData.profilefields = UiProfileGetString(); diff --git a/Source/multi.h b/Source/multi.h index be7aad6e698..7449a097b7e 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -2,17 +2,17 @@ #ifndef __MULTI_H__ #define __MULTI_H__ -extern BOOLEAN gbSomebodyWonGameKludge; // weak +extern BOOLEAN gbSomebodyWonGameKludge; extern char szPlayerDescript[128]; extern WORD sgwPackPlrOffsetTbl[MAX_PLRS]; extern PkPlayerStruct netplr[MAX_PLRS]; extern BOOL gbShouldValidatePackage; extern BYTE gbActivePlayers; -extern BOOLEAN gbGameDestroyed; // weak -extern char byte_678640; // weak +extern BOOLEAN gbGameDestroyed; +extern char byte_678640; extern BYTE gbMaxPlayers; extern char szPlayerName[128]; -extern BYTE gbDeltaSender; // weak +extern BYTE gbDeltaSender; extern int player_state[MAX_PLRS]; #ifdef _DEBUG @@ -57,7 +57,6 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv); /* rdata */ -extern const int multi_inf; // weak extern const int event_types[3]; #endif /* __MULTI_H__ */ diff --git a/Source/objdat.h b/Source/objdat.h index 9a949bb6d41..ff879f15ca1 100644 --- a/Source/objdat.h +++ b/Source/objdat.h @@ -1,9 +1,9 @@ -//HEADER_GOES_HERE -#ifndef __OBJDAT_H__ -#define __OBJDAT_H__ - -extern int ObjTypeConv[113]; -extern ObjDataStruct AllObjects[99]; -extern char *ObjMasterLoadList[56]; - -#endif /* __OBJDAT_H__ */ +//HEADER_GOES_HERE +#ifndef __OBJDAT_H__ +#define __OBJDAT_H__ + +extern int ObjTypeConv[113]; +extern ObjDataStruct AllObjects[99]; +extern char *ObjMasterLoadList[56]; + +#endif /* __OBJDAT_H__ */ diff --git a/Source/objects.cpp b/Source/objects.cpp index 1627f430983..876de89ea88 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -108,7 +108,7 @@ void InitObjectGFX() if (fileload[i]) { ObjFileList[numobjfiles] = i; sprintf(filestr, "Objects\\%s.CEL", ObjMasterLoadList[i]); - pObjCels[numobjfiles] = LoadFileInMem(filestr, 0); + pObjCels[numobjfiles] = LoadFileInMem(filestr, NULL); numobjfiles++; } } @@ -600,13 +600,13 @@ void AddDiabObjs() { BYTE *lpSetPiece; - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab1.DUN", NULL); LoadMapObjects(lpSetPiece, 2 * diabquad1x, 2 * diabquad1y, diabquad2x, diabquad2y, 11, 12, 1); mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab2a.DUN", NULL); LoadMapObjects(lpSetPiece, 2 * diabquad2x, 2 * diabquad2y, diabquad3x, diabquad3y, 11, 11, 2); mem_free_dbg(lpSetPiece); - lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", 0); + lpSetPiece = LoadFileInMem("Levels\\L4Data\\diab3a.DUN", NULL); LoadMapObjects(lpSetPiece, 2 * diabquad3x, 2 * diabquad3y, diabquad4x, diabquad4y, 9, 9, 3); mem_free_dbg(lpSetPiece); } @@ -786,7 +786,7 @@ void InitObjects() } quests[QTYPE_BLIND]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, sp_id); - mem = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + mem = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } @@ -819,7 +819,7 @@ void InitObjects() } quests[QTYPE_WARLRD]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, sp_id); - mem = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", 0); + mem = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } @@ -884,7 +884,7 @@ void SetMapObjects(unsigned char *pMap, int startx, int starty) ObjFileList[numobjfiles] = i; sprintf(filestr, "Objects\\%s.CEL", ObjMasterLoadList[i]); - pObjCels[numobjfiles] = LoadFileInMem(filestr, 0); + pObjCels[numobjfiles] = LoadFileInMem(filestr, NULL); numobjfiles++; } @@ -1067,7 +1067,7 @@ void AddFlameLvr(int i) object[i]._oVar2 = 49; } -void AddTrap(int i, int t) +void AddTrap(int i, int ot) { int mt; @@ -2794,7 +2794,7 @@ void OperatePedistal(int pnum, int i) if (!deltaload) PlaySfxLoc(LS_BLODSTAR, object[i]._ox, object[i]._oy); ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); - mem = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + mem = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); CreateItem(7, 2 * setpc_x + 25, 2 * setpc_y + 19); @@ -4249,7 +4249,7 @@ void SyncPedistal(int i) } if (object[i]._oVar6 == 3) { ObjChangeMapResync(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); - setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL); LoadMapObjs(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } diff --git a/Source/objects.h b/Source/objects.h index 2864a5a179a..50a7ea51eb2 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -54,7 +54,7 @@ void AddL3Door(int i, int x, int y, int ot); void AddSarc(int i); void AddFlameTrap(int i); void AddFlameLvr(int i); -void AddTrap(int i, int t); +void AddTrap(int i, int ot); void AddObjLight(int i, int r); void AddBarrel(int i, int t); void AddShrine(int i); diff --git a/Source/path.cpp b/Source/path.cpp index 25c2b8df5fe..8f50b07cc5e 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -36,7 +36,8 @@ const char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 }; */ char path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 }; -/* find the shortest path from (sx,sy) to (dx,dy), using PosOk(PosOkArg,x,y) to +/** + * find the shortest path from (sx,sy) to (dx,dy), using PosOk(PosOkArg,x,y) to * check that each step is a valid position. Store the step directions (see * path_directions) in path, which must have room for 24 steps */ @@ -85,7 +86,9 @@ int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, return 0; } -/* heuristic, estimated cost from (sx,sy) to (dx,dy) */ +/** + * @brief heuristic, estimated cost from (sx,sy) to (dx,dy) + */ int path_get_h_cost(int sx, int sy, int dx, int dy) { int delta_x = abs(sx - dx); @@ -98,7 +101,8 @@ int path_get_h_cost(int sx, int sy, int dx, int dy) return 2 * (min + max); } -/* return 2 if pPath is horizontally/vertically aligned with (dx,dy), else 3 +/** + * @brief return 2 if pPath is horizontally/vertically aligned with (dx,dy), else 3 * * This approximates that diagonal movement on a square grid should have a cost * of sqrt(2). That's approximately 1.5, so they multiply all step costs by 2, @@ -112,8 +116,8 @@ int path_check_equal(PATHNODE *pPath, int dx, int dy) return 3; } -/* get the next node on the A* frontier to explore (estimated to be closest to - * the goal), mark it as visited, and return it +/** + * @brief get the next node on the A* frontier to explore (estimated to be closest to the goal), mark it as visited, and return it */ PATHNODE *GetNextPath() { @@ -130,13 +134,15 @@ PATHNODE *GetNextPath() return result; } -/* check if stepping from pPath to (dx,dy) cuts a corner. If you step from A to - * B, both Xs need to be clear: +/** + * @brief check if stepping from pPath to (dx,dy) cuts a corner. + * + * If you step from A to B, both Xs need to be clear: * * AX * XB * - * return true if step is allowed + * @return true if step is allowed */ BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy) { @@ -158,10 +164,10 @@ BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy) return rv; } -/* perform a single step of A* bread-first search by trying to step in every - * possible direction from pPath with goal (x,y). Check each step with PosOk +/** + * @brief perform a single step of A* bread-first search by trying to step in every possible direction from pPath with goal (x,y). Check each step with PosOk * - * return 0 if we ran out of preallocated nodes to use, else 1 + * @return FALSE if we ran out of preallocated nodes to use, else TRUE */ BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y) { @@ -182,10 +188,10 @@ BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, return TRUE; } -/* add a step from pPath to (dx,dy), return 1 if successful, and update the - * frontier/visited nodes accordingly +/** + * @brief add a step from pPath to (dx,dy), return 1 if successful, and update the frontier/visited nodes accordingly * - * return 1 if step successfully added, 0 if we ran out of nodes to use + * @return TRUE if step successfully added, FALSE if we ran out of nodes to use */ BOOL path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy) { @@ -253,7 +259,9 @@ BOOL path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy) return TRUE; } -/* return a node for (dx,dy) on the frontier, or NULL if not found */ +/** + * @brief return a node for (dx,dy) on the frontier, or NULL if not found + */ PATHNODE *path_get_node1(int dx, int dy) { PATHNODE *result = path_2_nodes->NextNode; @@ -262,7 +270,9 @@ PATHNODE *path_get_node1(int dx, int dy) return result; } -/* return a node for (dx,dy) if it was visited, or NULL if not found */ +/** + * @brief return a node for (dx,dy) if it was visited, or NULL if not found + */ PATHNODE *path_get_node2(int dx, int dy) { PATHNODE *result = pnode_ptr->NextNode; @@ -271,8 +281,9 @@ PATHNODE *path_get_node2(int dx, int dy) return result; } -/* insert pPath into the frontier (keeping the frontier sorted by total - * distance) */ +/** + * @brief insert pPath into the frontier (keeping the frontier sorted by total distance) + */ void path_next_node(PATHNODE *pPath) { PATHNODE *next, *current; @@ -294,7 +305,9 @@ void path_next_node(PATHNODE *pPath) } } -/* update all path costs using depth-first search starting at pPath */ +/** + * @brief update all path costs using depth-first search starting at pPath + */ void path_set_coords(PATHNODE *pPath) { PATHNODE *PathOld; @@ -321,7 +334,9 @@ void path_set_coords(PATHNODE *pPath) } } -/* push pPath onto the pnode_tblptr stack */ +/** + * @brief push pPath onto the pnode_tblptr stack + */ void path_push_active_step(PATHNODE *pPath) { int stack_index = gdwCurPathStep; @@ -329,15 +344,18 @@ void path_push_active_step(PATHNODE *pPath) pnode_tblptr[stack_index] = pPath; } -/* pop and return a node from the pnode_tblptr stack */ +/** + * @brief pop and return a node from the pnode_tblptr stack + */ PATHNODE *path_pop_active_step() { gdwCurPathStep--; return pnode_tblptr[gdwCurPathStep]; } -/* zero one of the preallocated nodes and return a pointer to it, or NULL if - * none are available */ +/** + * @brief zero one of the preallocated nodes and return a pointer to it, or NULL if none are available + */ PATHNODE *path_new_step() { PATHNODE *new_node; diff --git a/Source/path.h b/Source/path.h index 6c453d6ae63..04d30e2788f 100644 --- a/Source/path.h +++ b/Source/path.h @@ -11,12 +11,12 @@ extern PATHNODE *pnode_tblptr[MAXPATHNODES]; extern PATHNODE *path_2_nodes; extern PATHNODE path_unusednodes[MAXPATHNODES]; -int FindPath(BOOL(*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path); +int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path); int path_get_h_cost(int sx, int sy, int dx, int dy); int path_check_equal(PATHNODE *pPath, int dx, int dy); PATHNODE *GetNextPath(); BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy); -BOOL path_get_path(BOOL(*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y); +BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y); BOOL path_parent_path(PATHNODE *pPath, int dx, int dy, int sx, int sy); PATHNODE *path_get_node1(int dx, int dy); PATHNODE *path_get_node2(int dx, int dy); diff --git a/Source/pfile.cpp b/Source/pfile.cpp index a8253a9da0c..6efb7454737 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -159,7 +159,7 @@ BOOL pfile_create_player_description(char *dst, DWORD len) return TRUE; } -BOOL pfile_create_save_file(const char *name_1, const char *name_2) +BOOL pfile_rename_hero(const char *name_1, const char *name_2) { int i; DWORD save_num; @@ -567,26 +567,31 @@ BOOL __stdcall GetTempSaveNames(DWORD dwIndex, char *szTemp) void pfile_rename_temp_to_perm() { - DWORD save_num, i; - char TempName[MAX_PATH]; - char PermName[MAX_PATH]; + DWORD dwChar, dwIndex; + BOOL bResult; + char szTemp[MAX_PATH]; + char szPerm[MAX_PATH]; - save_num = pfile_get_save_num_from_name(plr[myplr]._pName); - if (!pfile_open_archive(FALSE, save_num)) + dwChar = pfile_get_save_num_from_name(plr[myplr]._pName); + /// ASSERT: assert(dwChar < MAX_CHARACTERS); + /// ASSERT: assert(gbMaxPlayers == 1); + if (!pfile_open_archive(FALSE, dwChar)) app_fatal("Unable to write to save file archive"); - i = 0; - while (GetTempSaveNames(i, TempName)) { - GetPermSaveNames(i, PermName); - i++; - if (mpqapi_has_file(TempName)) { - if (mpqapi_has_file(PermName)) - mpqapi_remove_hash_entry(PermName); - mpqapi_rename(TempName, PermName); + dwIndex = 0; + while (GetTempSaveNames(dwIndex, szTemp)) { + bResult = GetPermSaveNames(dwIndex, szPerm); + /// ASSERT: assert(bResult); + dwIndex++; + if (mpqapi_has_file(szTemp)) { + if (mpqapi_has_file(szPerm)) + mpqapi_remove_hash_entry(szPerm); + mpqapi_rename(szTemp, szPerm); } } - GetPermSaveNames(i, PermName); - pfile_flush(TRUE, save_num); + /// ASSERT: assert(! GetPermSaveNames(dwIndex,szPerm)); + GetPermSaveNames(dwIndex, szPerm); + pfile_flush(TRUE, dwChar); } BOOL __stdcall GetPermSaveNames(DWORD dwIndex, char *szPerm) diff --git a/Source/pfile.h b/Source/pfile.h index 6580e83277a..045a8067107 100644 --- a/Source/pfile.h +++ b/Source/pfile.h @@ -13,7 +13,7 @@ BOOL pfile_open_archive(BOOL a1, DWORD save_num); void pfile_get_save_path(char *pszBuf, DWORD dwBufSize, DWORD save_num); void pfile_flush(BOOL is_single_player, DWORD save_num); BOOL pfile_create_player_description(char *dst, DWORD len); -BOOL pfile_create_save_file(const char *name_1, const char *name_2); +BOOL pfile_rename_hero(const char *name_1, const char *name_2); void pfile_flush_W(); void game_2_ui_player(const PlayerStruct *p, _uiheroinfo *heroinfo, BOOL bHasSaveFile); unsigned char game_2_ui_class(const PlayerStruct *p); diff --git a/Source/player.cpp b/Source/player.cpp index dcd2fb871c3..632aa0240ce 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -5,7 +5,7 @@ DEVILUTION_BEGIN_NAMESPACE int plr_lframe_size; int plr_wframe_size; -UCHAR plr_gfx_flag = 0; +BYTE plr_gfx_flag = 0; int plr_aframe_size; int myplr; PlayerStruct plr[MAX_PLRS]; @@ -14,7 +14,7 @@ int plr_qframe_size; BOOL deathflag; int plr_hframe_size; int plr_bframe_size; -UCHAR plr_gfx_bflag = 0; +BYTE plr_gfx_bflag = 0; int plr_sframe_size; int deathdelay; int plr_dframe_size; @@ -105,9 +105,9 @@ int ExpLvlsTbl[MAXCHARLEVEL] = { 1583495809 }; char *ClassStrTbl[3] = { "Warrior", "Rogue", "Sorceror" }; -unsigned char fix[9] = { 0u, 0u, 3u, 3u, 3u, 6u, 6u, 6u, 8u }; /* PM_ChangeLightOff local type */ +BYTE fix[9] = { 0u, 0u, 3u, 3u, 3u, 6u, 6u, 6u, 8u }; /* PM_ChangeLightOff local type */ -void SetPlayerGPtrs(UCHAR *pData, UCHAR **pAnim) +void SetPlayerGPtrs(BYTE *pData, BYTE **pAnim) { int i; @@ -123,7 +123,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) char *szCel; PlayerStruct *p; char *cs; - UCHAR *pData, *pAnim; + BYTE *pData, *pAnim; DWORD i; if ((DWORD)pnum >= MAX_PLRS) { @@ -146,7 +146,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) szCel = "ST"; } pData = p->_pNData; - pAnim = (UCHAR *)p->_pNAnim; + pAnim = (BYTE *)p->_pNAnim; break; case PFILE_WALK: szCel = "AW"; @@ -154,7 +154,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) szCel = "WL"; } pData = p->_pWData; - pAnim = (UCHAR *)p->_pWAnim; + pAnim = (BYTE *)p->_pWAnim; break; case PFILE_ATTACK: if (leveltype == DTYPE_TOWN) { @@ -162,7 +162,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "AT"; pData = p->_pAData; - pAnim = (UCHAR *)p->_pAAnim; + pAnim = (BYTE *)p->_pAAnim; break; case PFILE_HIT: if (leveltype == DTYPE_TOWN) { @@ -170,7 +170,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "HT"; pData = p->_pHData; - pAnim = (UCHAR *)p->_pHAnim; + pAnim = (BYTE *)p->_pHAnim; break; case PFILE_LIGHTNING: if (leveltype == DTYPE_TOWN) { @@ -178,7 +178,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "LM"; pData = p->_pLData; - pAnim = (UCHAR *)p->_pLAnim; + pAnim = (BYTE *)p->_pLAnim; break; case PFILE_FIRE: if (leveltype == DTYPE_TOWN) { @@ -186,7 +186,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "FM"; pData = p->_pFData; - pAnim = (UCHAR *)p->_pFAnim; + pAnim = (BYTE *)p->_pFAnim; break; case PFILE_MAGIC: if (leveltype == DTYPE_TOWN) { @@ -194,7 +194,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "QM"; pData = p->_pTData; - pAnim = (UCHAR *)p->_pTAnim; + pAnim = (BYTE *)p->_pTAnim; break; case PFILE_DEATH: if (p->_pgfxnum & 0xF) { @@ -202,7 +202,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) } szCel = "DT"; pData = p->_pDData; - pAnim = (UCHAR *)p->_pDAnim; + pAnim = (BYTE *)p->_pDAnim; break; case PFILE_BLOCK: if (leveltype == DTYPE_TOWN) { @@ -214,7 +214,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) szCel = "BL"; pData = p->_pBData; - pAnim = (UCHAR *)p->_pBAnim; + pAnim = (BYTE *)p->_pBAnim; break; default: app_fatal("PLR:2"); @@ -223,7 +223,7 @@ void LoadPlrGFX(int pnum, player_graphic gfxflag) sprintf(pszName, "PlrGFX\\%s\\%s\\%s%s.CL2", cs, prefix, prefix, szCel); LoadFileWithMem(pszName, pData); - SetPlayerGPtrs((UCHAR *)pData, (UCHAR **)pAnim); + SetPlayerGPtrs((BYTE *)pData, (BYTE **)pAnim); p->_pGFXLoad |= i; } } @@ -370,7 +370,7 @@ void FreePlayerGFX(int pnum) plr[pnum]._pGFXLoad = 0; } -void NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Delay, int width) +void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("NewPlrAnim: illegal player %d", pnum); @@ -1055,7 +1055,7 @@ void SetPlayerOld(int pnum) plr[pnum]._poldy = plr[pnum].WorldY; } -void FixPlayerLocation(int pnum, int dir) +void FixPlayerLocation(int pnum, int bDir) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("FixPlayerLocation: illegal player %d", pnum); @@ -1068,7 +1068,7 @@ void FixPlayerLocation(int pnum, int dir) plr[pnum]._pxoff = 0; plr[pnum]._pyoff = 0; CheckEFlag(pnum, FALSE); - plr[pnum]._pdir = dir; + plr[pnum]._pdir = bDir; if (pnum == myplr) { ScrollInfo._sxoff = 0; ScrollInfo._syoff = 0; @@ -2652,7 +2652,7 @@ BOOL PM_DoAttack(int pnum) } didhit = PlrHitMonst(pnum, m); } else if (dPlayer[dx][dy] && !FriendlyMode) { - UCHAR p = dPlayer[dx][dy]; + BYTE p = dPlayer[dx][dy]; if (dPlayer[dx][dy] > 0) { p = dPlayer[dx][dy] - 1; } else { @@ -3281,21 +3281,21 @@ void CheckNewPath(int pnum) } } -BOOL PlrDeathModeOK(int pnum) +BOOL PlrDeathModeOK(int p) { - if (pnum != myplr) { + if (p != myplr) { return TRUE; } - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("PlrDeathModeOK: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("PlrDeathModeOK: illegal player %d", p); } - if (plr[pnum]._pmode == PM_DEATH) { + if (plr[p]._pmode == PM_DEATH) { return TRUE; - } else if (plr[pnum]._pmode == PM_QUIT) { + } else if (plr[p]._pmode == PM_QUIT) { return TRUE; - } else if (plr[pnum]._pmode == PM_NEWLVL) { + } else if (plr[p]._pmode == PM_NEWLVL) { return TRUE; } @@ -3488,43 +3488,43 @@ void ClrPlrPath(int pnum) memset(plr[pnum].walkpath, WALK_NONE, sizeof(plr[pnum].walkpath)); } -BOOL PosOkPlayer(int pnum, int px, int py) +BOOL PosOkPlayer(int pnum, int x, int y) { BOOL PosOK; DWORD p; char bv; PosOK = FALSE; - if (px >= 0 && px < MAXDUNX && py >= 0 && py < MAXDUNY && !SolidLoc(px, py) && dPiece[px][py]) { + if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY && !SolidLoc(x, y) && dPiece[x][y]) { - if (dPlayer[px][py]) { - if (dPlayer[px][py] > 0) { - p = dPlayer[px][py] - 1; + if (dPlayer[x][y]) { + if (dPlayer[x][y] > 0) { + p = dPlayer[x][y] - 1; } else { - p = -(dPlayer[px][py] + 1); + p = -(dPlayer[x][y] + 1); } if (p != pnum && p < MAX_PLRS && plr[p]._pHitPoints) { return FALSE; } } - if (dMonster[px][py]) { + if (dMonster[x][y]) { if (currlevel == 0) { return FALSE; } - if (dMonster[px][py] <= 0) { + if (dMonster[x][y] <= 0) { return FALSE; } - if ((monster[dMonster[px][py] - 1]._mhitpoints >> 6) > 0) { + if ((monster[dMonster[x][y] - 1]._mhitpoints >> 6) > 0) { return FALSE; } } - if (dObject[px][py]) { - if (dObject[px][py] > 0) { - bv = dObject[px][py] - 1; + if (dObject[x][y]) { + if (dObject[x][y] > 0) { + bv = dObject[x][y] - 1; } else { - bv = -(dObject[px][py] + 1); + bv = -(dObject[x][y] + 1); } if (object[bv]._oSolidFlag) { return FALSE; @@ -3798,271 +3798,271 @@ void SyncInitPlr(int pnum) SyncInitPlrPos(pnum); } -void CheckStats(int pnum) +void CheckStats(int p) { int c, i; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("CheckStats: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("CheckStats: illegal player %d", p); } - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == PC_WARRIOR) { c = PC_WARRIOR; - } else if (plr[pnum]._pClass == PC_ROGUE) { + } else if (plr[p]._pClass == PC_ROGUE) { c = PC_ROGUE; - } else if (plr[pnum]._pClass == PC_SORCERER) { + } else if (plr[p]._pClass == PC_SORCERER) { c = PC_SORCERER; } for (i = 0; i < 4; i++) { switch (i) { case ATTRIB_STR: - if (plr[pnum]._pBaseStr > MaxStats[c][ATTRIB_STR]) { - plr[pnum]._pBaseStr = MaxStats[c][ATTRIB_STR]; - } else if (plr[pnum]._pBaseStr < 0) { - plr[pnum]._pBaseStr = 0; + if (plr[p]._pBaseStr > MaxStats[c][ATTRIB_STR]) { + plr[p]._pBaseStr = MaxStats[c][ATTRIB_STR]; + } else if (plr[p]._pBaseStr < 0) { + plr[p]._pBaseStr = 0; } break; case ATTRIB_MAG: - if (plr[pnum]._pBaseMag > MaxStats[c][ATTRIB_MAG]) { - plr[pnum]._pBaseMag = MaxStats[c][ATTRIB_MAG]; - } else if (plr[pnum]._pBaseMag < 0) { - plr[pnum]._pBaseMag = 0; + if (plr[p]._pBaseMag > MaxStats[c][ATTRIB_MAG]) { + plr[p]._pBaseMag = MaxStats[c][ATTRIB_MAG]; + } else if (plr[p]._pBaseMag < 0) { + plr[p]._pBaseMag = 0; } break; case ATTRIB_DEX: - if (plr[pnum]._pBaseDex > MaxStats[c][ATTRIB_DEX]) { - plr[pnum]._pBaseDex = MaxStats[c][ATTRIB_DEX]; - } else if (plr[pnum]._pBaseDex < 0) { - plr[pnum]._pBaseDex = 0; + if (plr[p]._pBaseDex > MaxStats[c][ATTRIB_DEX]) { + plr[p]._pBaseDex = MaxStats[c][ATTRIB_DEX]; + } else if (plr[p]._pBaseDex < 0) { + plr[p]._pBaseDex = 0; } break; case ATTRIB_VIT: - if (plr[pnum]._pBaseVit > MaxStats[c][ATTRIB_VIT]) { - plr[pnum]._pBaseVit = MaxStats[c][ATTRIB_VIT]; - } else if (plr[pnum]._pBaseVit < 0) { - plr[pnum]._pBaseVit = 0; + if (plr[p]._pBaseVit > MaxStats[c][ATTRIB_VIT]) { + plr[p]._pBaseVit = MaxStats[c][ATTRIB_VIT]; + } else if (plr[p]._pBaseVit < 0) { + plr[p]._pBaseVit = 0; } break; } } } -void ModifyPlrStr(int pnum, int l) +void ModifyPlrStr(int p, int l) { int max; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("ModifyPlrStr: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("ModifyPlrStr: illegal player %d", p); } - max = MaxStats[plr[pnum]._pClass][ATTRIB_STR]; - if (plr[pnum]._pBaseStr + l > max) { - l = max - plr[pnum]._pBaseStr; + max = MaxStats[plr[p]._pClass][ATTRIB_STR]; + if (plr[p]._pBaseStr + l > max) { + l = max - plr[p]._pBaseStr; } - plr[pnum]._pStrength += l; - plr[pnum]._pBaseStr += l; + plr[p]._pStrength += l; + plr[p]._pBaseStr += l; - if (plr[pnum]._pClass == PC_ROGUE) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + if (plr[p]._pClass == PC_ROGUE) { + plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100; } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(p, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETSTR, plr[pnum]._pBaseStr); //60 + if (p == myplr) { + NetSendCmdParam1(FALSE, CMD_SETSTR, plr[p]._pBaseStr); //60 } } -void ModifyPlrMag(int pnum, int l) +void ModifyPlrMag(int p, int l) { int max, ms; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("ModifyPlrMag: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("ModifyPlrMag: illegal player %d", p); } - max = MaxStats[plr[pnum]._pClass][ATTRIB_MAG]; - if (plr[pnum]._pBaseMag + l > max) { - l = max - plr[pnum]._pBaseMag; + max = MaxStats[plr[p]._pClass][ATTRIB_MAG]; + if (plr[p]._pBaseMag + l > max) { + l = max - plr[p]._pBaseMag; } - plr[pnum]._pMagic += l; - plr[pnum]._pBaseMag += l; + plr[p]._pMagic += l; + plr[p]._pBaseMag += l; ms = l << 6; - if (plr[pnum]._pClass == PC_SORCERER) { + if (plr[p]._pClass == PC_SORCERER) { ms *= 2; } - plr[pnum]._pMaxManaBase += ms; - plr[pnum]._pMaxMana += ms; - if (!(plr[pnum]._pIFlags & ISPL_NOMANA)) { - plr[pnum]._pManaBase += ms; - plr[pnum]._pMana += ms; + plr[p]._pMaxManaBase += ms; + plr[p]._pMaxMana += ms; + if (!(plr[p]._pIFlags & ISPL_NOMANA)) { + plr[p]._pManaBase += ms; + plr[p]._pMana += ms; } - CalcPlrInv(pnum, TRUE); + CalcPlrInv(p, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETMAG, plr[pnum]._pBaseMag); + if (p == myplr) { + NetSendCmdParam1(FALSE, CMD_SETMAG, plr[p]._pBaseMag); } } -void ModifyPlrDex(int pnum, int l) +void ModifyPlrDex(int p, int l) { int max; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("ModifyPlrDex: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("ModifyPlrDex: illegal player %d", p); } - max = MaxStats[plr[pnum]._pClass][ATTRIB_DEX]; - if (plr[pnum]._pBaseDex + l > max) { - l = max - plr[pnum]._pBaseDex; + max = MaxStats[plr[p]._pClass][ATTRIB_DEX]; + if (plr[p]._pBaseDex + l > max) { + l = max - plr[p]._pBaseDex; } - plr[pnum]._pDexterity += l; - plr[pnum]._pBaseDex += l; - CalcPlrInv(pnum, TRUE); + plr[p]._pDexterity += l; + plr[p]._pBaseDex += l; + CalcPlrInv(p, TRUE); - if (plr[pnum]._pClass == PC_ROGUE) { - plr[pnum]._pDamageMod = plr[pnum]._pLevel * (plr[pnum]._pDexterity + plr[pnum]._pStrength) / 200; + if (plr[p]._pClass == PC_ROGUE) { + plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pDexterity + plr[p]._pStrength) / 200; } - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETDEX, plr[pnum]._pBaseDex); + if (p == myplr) { + NetSendCmdParam1(FALSE, CMD_SETDEX, plr[p]._pBaseDex); } } -void ModifyPlrVit(int pnum, int l) +void ModifyPlrVit(int p, int l) { int max, ms; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("ModifyPlrVit: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("ModifyPlrVit: illegal player %d", p); } - max = MaxStats[plr[pnum]._pClass][ATTRIB_VIT]; - if (plr[pnum]._pBaseVit + l > max) { - l = max - plr[pnum]._pBaseVit; + max = MaxStats[plr[p]._pClass][ATTRIB_VIT]; + if (plr[p]._pBaseVit + l > max) { + l = max - plr[p]._pBaseVit; } - plr[pnum]._pVitality += l; - plr[pnum]._pBaseVit += l; + plr[p]._pVitality += l; + plr[p]._pBaseVit += l; ms = l << 6; - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == PC_WARRIOR) { ms *= 2; } - plr[pnum]._pHPBase += ms; - plr[pnum]._pMaxHPBase += ms; - plr[pnum]._pHitPoints += ms; - plr[pnum]._pMaxHP += ms; + plr[p]._pHPBase += ms; + plr[p]._pMaxHPBase += ms; + plr[p]._pHitPoints += ms; + plr[p]._pMaxHP += ms; - CalcPlrInv(pnum, TRUE); + CalcPlrInv(p, TRUE); - if (pnum == myplr) { - NetSendCmdParam1(FALSE, CMD_SETVIT, plr[pnum]._pBaseVit); + if (p == myplr) { + NetSendCmdParam1(FALSE, CMD_SETVIT, plr[p]._pBaseVit); } } -void SetPlayerHitPoints(int pnum, int newhp) +void SetPlayerHitPoints(int pnum, int val) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("SetPlayerHitPoints: illegal player %d", pnum); } - plr[pnum]._pHitPoints = newhp; - plr[pnum]._pHPBase = newhp + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; + plr[pnum]._pHitPoints = val; + plr[pnum]._pHPBase = val + plr[pnum]._pMaxHPBase - plr[pnum]._pMaxHP; if (pnum == myplr) { drawhpflag = TRUE; } } -void SetPlrStr(int pnum, int v) +void SetPlrStr(int p, int v) { int dm; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("SetPlrStr: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("SetPlrStr: illegal player %d", p); } - plr[pnum]._pBaseStr = v; - CalcPlrInv(pnum, TRUE); + plr[p]._pBaseStr = v; + CalcPlrInv(p, TRUE); - if (plr[pnum]._pClass == PC_ROGUE) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + if (plr[p]._pClass == PC_ROGUE) { + dm = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { - dm = plr[pnum]._pLevel * plr[pnum]._pStrength / 100; + dm = plr[p]._pLevel * plr[p]._pStrength / 100; } - plr[pnum]._pDamageMod = dm; + plr[p]._pDamageMod = dm; } -void SetPlrMag(int pnum, int v) +void SetPlrMag(int p, int v) { int m; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("SetPlrMag: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("SetPlrMag: illegal player %d", p); } - plr[pnum]._pBaseMag = v; + plr[p]._pBaseMag = v; m = v << 6; - if (plr[pnum]._pClass == PC_SORCERER) { + if (plr[p]._pClass == PC_SORCERER) { m *= 2; } - plr[pnum]._pMaxManaBase = m; - plr[pnum]._pMaxMana = m; - CalcPlrInv(pnum, TRUE); + plr[p]._pMaxManaBase = m; + plr[p]._pMaxMana = m; + CalcPlrInv(p, TRUE); } -void SetPlrDex(int pnum, int v) +void SetPlrDex(int p, int v) { int dm; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("SetPlrDex: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("SetPlrDex: illegal player %d", p); } - plr[pnum]._pBaseDex = v; - CalcPlrInv(pnum, TRUE); + plr[p]._pBaseDex = v; + CalcPlrInv(p, TRUE); - if (plr[pnum]._pClass == PC_ROGUE) { - dm = plr[pnum]._pLevel * (plr[pnum]._pStrength + plr[pnum]._pDexterity) / 200; + if (plr[p]._pClass == PC_ROGUE) { + dm = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200; } else { - dm = plr[pnum]._pStrength * plr[pnum]._pLevel / 100; + dm = plr[p]._pStrength * plr[p]._pLevel / 100; } - plr[pnum]._pDamageMod = dm; + plr[p]._pDamageMod = dm; } -void SetPlrVit(int pnum, int v) +void SetPlrVit(int p, int v) { int hp; - if ((DWORD)pnum >= MAX_PLRS) { - app_fatal("SetPlrVit: illegal player %d", pnum); + if ((DWORD)p >= MAX_PLRS) { + app_fatal("SetPlrVit: illegal player %d", p); } - plr[pnum]._pBaseVit = v; + plr[p]._pBaseVit = v; hp = v << 6; - if (plr[pnum]._pClass == PC_WARRIOR) { + if (plr[p]._pClass == PC_WARRIOR) { hp *= 2; } - plr[pnum]._pHPBase = hp; - plr[pnum]._pMaxHPBase = hp; - CalcPlrInv(pnum, TRUE); + plr[p]._pHPBase = hp; + plr[p]._pMaxHPBase = hp; + CalcPlrInv(p, TRUE); } void InitDungMsgs(int pnum) diff --git a/Source/player.h b/Source/player.h index 7513b24df49..7ef1d8e2e61 100644 --- a/Source/player.h +++ b/Source/player.h @@ -2,29 +2,29 @@ #ifndef __PLAYER_H__ #define __PLAYER_H__ -extern int plr_lframe_size; // idb -extern int plr_wframe_size; // idb -extern UCHAR plr_gfx_flag; -extern int plr_aframe_size; // idb +extern int plr_lframe_size; +extern int plr_wframe_size; +extern BYTE plr_gfx_flag; +extern int plr_aframe_size; extern int myplr; extern PlayerStruct plr[MAX_PLRS]; -extern int plr_fframe_size; // idb -extern int plr_qframe_size; // idb -extern BOOL deathflag; // idb -extern int plr_hframe_size; // idb -extern int plr_bframe_size; // idb -extern UCHAR plr_gfx_bflag; -extern int plr_sframe_size; // idb -extern int deathdelay; // weak -extern int plr_dframe_size; // idb +extern int plr_fframe_size; +extern int plr_qframe_size; +extern BOOL deathflag; +extern int plr_hframe_size; +extern int plr_bframe_size; +extern BYTE plr_gfx_bflag; +extern int plr_sframe_size; +extern int deathdelay; +extern int plr_dframe_size; -void SetPlayerGPtrs(UCHAR *pData, UCHAR **pAnim); /* unsigned char *+** */ +void SetPlayerGPtrs(BYTE *pData, BYTE **pAnim); void LoadPlrGFX(int pnum, player_graphic gfxflag); void InitPlayerGFX(int pnum); void InitPlrGFXMem(int pnum); DWORD GetPlrGFXSize(char *szCel); void FreePlayerGFX(int pnum); -void NewPlrAnim(int pnum, unsigned char *Peq, int numFrames, int Delay, int width); +void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width); void ClearPlrPVars(int pnum); void SetPlrAnims(int pnum); void ClearPlrRVars(PlayerStruct *p); @@ -41,7 +41,7 @@ BOOL PlrDirOK(int pnum, int dir); void PlrClrTrans(int x, int y); void PlrDoTrans(int x, int y); void SetPlayerOld(int pnum); -void FixPlayerLocation(int pnum, int dir); +void FixPlayerLocation(int pnum, int bDir); void StartStand(int pnum, int dir); void StartWalkStand(int pnum); void PM_ChangeLightOff(int pnum); @@ -85,27 +85,27 @@ BOOL PM_DoGotHit(int pnum); void ArmorDur(int pnum); BOOL PM_DoDeath(int pnum); void CheckNewPath(int pnum); -BOOL PlrDeathModeOK(int pnum); +BOOL PlrDeathModeOK(int p); void ValidatePlayer(); void ProcessPlayers(); void CheckCheatStats(int pnum); void ClrPlrPath(int pnum); -BOOL PosOkPlayer(int pnum, int px, int py); +BOOL PosOkPlayer(int pnum, int x, int y); void MakePlrPath(int pnum, int xx, int yy, BOOL endspace); void CheckPlrSpell(); void SyncPlrAnim(int pnum); void SyncInitPlrPos(int pnum); void SyncInitPlr(int pnum); -void CheckStats(int pnum); -void ModifyPlrStr(int pnum, int l); -void ModifyPlrMag(int pnum, int l); -void ModifyPlrDex(int pnum, int l); -void ModifyPlrVit(int pnum, int l); -void SetPlayerHitPoints(int pnum, int newhp); -void SetPlrStr(int pnum, int v); -void SetPlrMag(int pnum, int v); -void SetPlrDex(int pnum, int v); -void SetPlrVit(int pnum, int v); +void CheckStats(int p); +void ModifyPlrStr(int p, int l); +void ModifyPlrMag(int p, int l); +void ModifyPlrDex(int p, int l); +void ModifyPlrVit(int p, int l); +void SetPlayerHitPoints(int pnum, int val); +void SetPlrStr(int p, int v); +void SetPlrMag(int p, int v); +void SetPlrDex(int p, int v); +void SetPlrVit(int p, int v); void InitDungMsgs(int pnum); void PlayDungMsgs(); @@ -132,6 +132,6 @@ extern char *ClassStrTblOld[3]; extern int MaxStats[3][4]; extern int ExpLvlsTbl[MAXCHARLEVEL]; extern char *ClassStrTbl[3]; -extern unsigned char fix[9]; +extern BYTE fix[9]; #endif /* __PLAYER_H__ */ diff --git a/Source/quests.cpp b/Source/quests.cpp index 845701fccd9..c307661ef4e 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -2,19 +2,19 @@ DEVILUTION_BEGIN_NAMESPACE -int qtopline; // idb +int qtopline; BOOL questlog; BYTE *pQLogCel; QuestStruct quests[MAXQUESTS]; -int qline; // weak +int qline; int qlist[MAXQUESTS]; -int numqlines; // weak -int WaterDone; // idb -int ReturnLvlY; // idb -int ReturnLvlX; // idb -int ReturnLvlT; // idb -int ALLQUESTS; // idb -int ReturnLvl; // idb +int numqlines; +int WaterDone; +int ReturnLvlY; +int ReturnLvlX; +int ReturnLvlT; +int ALLQUESTS; +int ReturnLvl; QuestData questlist[MAXQUESTS] = { // clang-format off @@ -130,65 +130,65 @@ void CheckQuests() { int i, rportx, rporty; - if(QuestStatus(QTYPE_VB) && gbMaxPlayers != 1 && quests[QTYPE_VB]._qvar1 == 2) { + if (QuestStatus(QTYPE_VB) && gbMaxPlayers != 1 && quests[QTYPE_VB]._qvar1 == 2) { AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); quests[QTYPE_VB]._qvar1 = 3; NetSendCmdQuest(TRUE, QTYPE_VB); } - if(gbMaxPlayers != 1) { + if (gbMaxPlayers != 1) { return; } - if(currlevel == quests[QTYPE_VB]._qlevel - && !setlevel - && quests[QTYPE_VB]._qvar1 >= 2 - && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3) - && (quests[QTYPE_VB]._qvar2 == 0 || quests[QTYPE_VB]._qvar2 == 2)) { + if (currlevel == quests[QTYPE_VB]._qlevel + && !setlevel + && quests[QTYPE_VB]._qvar1 >= 2 + && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3) + && (quests[QTYPE_VB]._qvar2 == 0 || quests[QTYPE_VB]._qvar2 == 2)) { quests[QTYPE_VB]._qtx = 2 * quests[QTYPE_VB]._qtx + 16; quests[QTYPE_VB]._qty = 2 * quests[QTYPE_VB]._qty + 16; rportx = quests[QTYPE_VB]._qtx; rporty = quests[QTYPE_VB]._qty; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); quests[QTYPE_VB]._qvar2 = 1; - if(quests[QTYPE_VB]._qactive == 2) { + if (quests[QTYPE_VB]._qactive == 2) { quests[QTYPE_VB]._qvar1 = 3; } } - if(quests[QTYPE_VB]._qactive == 3 - && setlevel - && setlvlnum == SL_VILEBETRAYER - && quests[QTYPE_VB]._qvar2 == 4) { + if (quests[QTYPE_VB]._qactive == 3 + && setlevel + && setlvlnum == SL_VILEBETRAYER + && quests[QTYPE_VB]._qvar2 == 4) { rportx = 35; rporty = 32; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); quests[QTYPE_VB]._qvar2 = 3; } - if(setlevel) { - if(setlvlnum == quests[QTYPE_PW]._qslvl - && quests[QTYPE_PW]._qactive != 1 - && leveltype == quests[QTYPE_PW]._qlvltype - && nummonsters == 4 - && quests[QTYPE_PW]._qactive != 3) { + if (setlevel) { + if (setlvlnum == quests[QTYPE_PW]._qslvl + && quests[QTYPE_PW]._qactive != 1 + && leveltype == quests[QTYPE_PW]._qlvltype + && nummonsters == 4 + && quests[QTYPE_PW]._qactive != 3) { quests[QTYPE_PW]._qactive = 3; PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY); LoadPalette("Levels\\L3Data\\L3pwater.pal"); WaterDone = 32; } - if(WaterDone > 0) { + if (WaterDone > 0) { palette_update_quest_palette(WaterDone); WaterDone--; } - } else if(plr[myplr]._pmode == PM_STAND) { - for(i = 0; i < MAXQUESTS; i++) { - if(currlevel == quests[i]._qlevel - && quests[i]._qslvl != 0 - && quests[i]._qactive != 0 - && plr[myplr].WorldX == quests[i]._qtx - && plr[myplr].WorldY == quests[i]._qty) { - if(quests[i]._qlvltype != 255) { + } else if (plr[myplr]._pmode == PM_STAND) { + for (i = 0; i < MAXQUESTS; i++) { + if (currlevel == quests[i]._qlevel + && quests[i]._qslvl != 0 + && quests[i]._qactive != 0 + && plr[myplr].WorldX == quests[i]._qtx + && plr[myplr].WorldY == quests[i]._qty) { + if (quests[i]._qlvltype != 255) { setlvltype = quests[i]._qlvltype; } StartNewLvl(myplr, WM_DIABSETLVL, quests[i]._qslvl); @@ -196,11 +196,6 @@ void CheckQuests() } } } -// 5BB1ED: using guessed type char leveltype; -// 5CF31C: using guessed type char setlvltype; -// 5CF31D: using guessed type char setlevel; -// 679660: using guessed type char gbMaxPlayers; -// 69BE90: using guessed type int qline; BOOL ForceQuests() { @@ -685,11 +680,6 @@ void ResyncQuests() quests[QTYPE_VB]._qvar2 = 2; } } -// 5A5590: using guessed type char TransVal; -// 5BB1ED: using guessed type char leveltype; -// 5CF31D: using guessed type char setlevel; -// 5CF330: using guessed type int setpc_h; -// 5CF334: using guessed type int setpc_w; void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) { @@ -720,7 +710,7 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) off += fontkern[c] + 1; } if (qline == y) { - CelDecodeOnly(cjustflag ? x + k + 100 : 340 - x, s + 205, pCelBuff, ALLQUESTS, 12); + CelDecodeOnly(cjustflag ? x + k + 100 : 340 - x, s + 205, pCelBuff, ALLQUESTS, 12); } } diff --git a/Source/quests.h b/Source/quests.h index 2c4cbeed792..3d4ee9ccf50 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -2,19 +2,19 @@ #ifndef __QUESTS_H__ #define __QUESTS_H__ -extern int qtopline; // idb +extern int qtopline; extern BOOL questlog; extern BYTE *pQLogCel; extern QuestStruct quests[MAXQUESTS]; -extern int qline; // weak +extern int qline; extern int qlist[MAXQUESTS]; -extern int numqlines; // weak -extern int WaterDone; // idb -extern int ReturnLvlY; // idb -extern int ReturnLvlX; // idb -extern int ReturnLvlT; // idb -extern int ALLQUESTS; // idb -extern int ReturnLvl; // idb +extern int numqlines; +extern int WaterDone; +extern int ReturnLvlY; +extern int ReturnLvlX; +extern int ReturnLvlT; +extern int ALLQUESTS; +extern int ReturnLvl; void InitQuests(); void CheckQuests(); diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index ec9d4d27b4e..87b861facd6 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -15,10 +15,10 @@ DWORD sgdwCursXOld; DWORD sgdwCursYOld; char arch_draw_type; DDSURFACEDESC DDS_desc; -int cel_transparency_active; // weak +int cel_transparency_active; int level_piece_id; DWORD sgdwCursWdt; -void(*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); +void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); BYTE sgSaveBack[8192]; int draw_monster_num; DWORD sgdwCursHgtOld; @@ -206,7 +206,7 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL for (i = 0; i < MAX_PLRS; i++) { p = &plr[i]; - if (p->plractive && !p->_pHitPoints && p->plrlevel == (unsigned char)currlevel && p->WorldX == x && p->WorldY == y) { + if (p->plractive && !p->_pHitPoints && p->plrlevel == (BYTE)currlevel && p->WorldX == x && p->WorldY == y) { pCelBuff = p->_pAnimData; if (!pCelBuff) { // app_fatal("Drawing dead player %d \"%s\": NULL Cel Buffer", i, p->_pName); @@ -374,50 +374,50 @@ void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i void DrawView(int StartX, int StartY) { - if(zoomflag) { + if (zoomflag) { DrawGame(StartX, StartY); } else { DrawZoom(StartX, StartY); } - if(automapflag) { + if (automapflag) { DrawAutomap(); } - if(invflag) { + if (invflag) { DrawInv(); - } else if(sbookflag) { + } else if (sbookflag) { DrawSpellBook(); } DrawDurIcon(); - if(chrflag) { + if (chrflag) { DrawChr(); - } else if(questlog) { + } else if (questlog) { DrawQuestLog(); - } else if(plr[myplr]._pStatPts != 0 && !spselflag) { + } else if (plr[myplr]._pStatPts != 0 && !spselflag) { DrawLevelUpIcon(); } - if(uitemflag) { + if (uitemflag) { DrawUniqueInfo(); } - if(qtextflag) { + if (qtextflag) { DrawQText(); } - if(spselflag) { + if (spselflag) { DrawSpellList(); } - if(dropGoldFlag) { + if (dropGoldFlag) { DrawGoldSplit(dropGoldValue); } - if(helpflag) { + if (helpflag) { DrawHelp(); } - if(msgflag) { + if (msgflag) { DrawDiabloMsg(); } - if(deathflag) { + if (deathflag) { RedBack(); - } else if(PauseMode != 0) { + } else if (PauseMode != 0) { gmenu_draw_pause(); } @@ -547,7 +547,7 @@ void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) light_table_index = dLight[x][y]; if (level_piece_id != 0) { dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); arch_draw_type = 2; level_cel_block = pMap->mt[1]; if (level_cel_block != 0) { @@ -604,7 +604,7 @@ void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } else { dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); arch_draw_type = 1; level_cel_block = pMap->mt[0]; if (level_cel_block != 0) { @@ -643,7 +643,7 @@ void scrollrt_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } else { dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); arch_draw_type = 1; level_cel_block = pMap->mt[0]; if (level_cel_block != 0) { @@ -741,7 +741,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, pItem = &item[bItem - 1]; if (!pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -861,7 +861,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, pItem = &item[bItem - 1]; if (pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -889,7 +889,7 @@ void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, } } if (bArch != 0) { - cel_transparency_active = (unsigned char)TransList[bMap]; + cel_transparency_active = (BYTE)TransList[bMap]; Cel2DecodeLightTrans(pBuff, pSpecialCels, bArch, 64, 0, 8); } } @@ -973,7 +973,7 @@ void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int } /// ASSERT: assert((unsigned char)bv < MAXOBJECTS); - if ((unsigned char)bv >= MAXOBJECTS) + if ((BYTE)bv >= MAXOBJECTS) return; pCelBuff = object[bv]._oAnimData; @@ -997,7 +997,7 @@ void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int Cel2DrawHdrOnly(sx, sy, object[bv]._oAnimData, object[bv]._oAnimFrame, object[bv]._oAnimWidth, CelSkip, CelCap); } -void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int a4, int a5) +void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) { int i, lti_old, cta_old, lpi_old; BYTE *dst; @@ -1009,7 +1009,7 @@ void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int a4, int a5) level_piece_id = dPiece[x][y]; light_table_index = dLight[x][y]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; dst = pBuff; @@ -1038,7 +1038,7 @@ void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int a4, int a5) } } - scrollrt_draw_clipped_dungeon(pBuff, x, y, a4, a5, 0); + scrollrt_draw_clipped_dungeon(pBuff, x, y, sx, sy, 0); light_table_index = lti_old; cel_transparency_active = cta_old; @@ -1062,7 +1062,7 @@ void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChu light_table_index = dLight[x][y]; if (level_piece_id != 0) { dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { if (skipChunks <= i) { level_cel_block = pMap->mt[2 * i + 3]; @@ -1095,7 +1095,7 @@ void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChu light_table_index = dLight[x][y]; if (level_piece_id != 0) { dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); i = 0; while (i < (MicroTileLen >> 1) - 1) { if (skipChunks <= i) { @@ -1122,23 +1122,25 @@ void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChu pMap++; } - if (eflag && (DWORD)y < MAXDUNY && (DWORD)x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { - if (skipChunks <= i) { - level_cel_block = pMap->mt[2 * i + 2]; - if (level_cel_block != 0) { - drawLowerScreen(dst); + if (eflag) { + if ((DWORD)y < MAXDUNY && (DWORD)x < MAXDUNX) { + level_piece_id = dPiece[x][y]; + light_table_index = dLight[x][y]; + if (level_piece_id != 0) { + dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + for (i = 0; i < (MicroTileLen >> 1) - 1; i++) { + if (skipChunks <= i) { + level_cel_block = pMap->mt[2 * i + 2]; + if (level_cel_block != 0) { + drawLowerScreen(dst); + } } + dst -= BUFFER_WIDTH * 32; + } + if (CelSkip < 8) { + scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 0); } - dst -= BUFFER_WIDTH * 32; - } - if (CelSkip < 8) { - scrollrt_draw_clipped_dungeon_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 0); } } } @@ -1205,7 +1207,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks pItem = &item[bItem - 1]; if (!pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -1325,7 +1327,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks pItem = &item[bItem - 1]; if (pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -1353,7 +1355,7 @@ void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks } } if (bArch != 0) { - cel_transparency_active = (unsigned char)TransList[bMap]; + cel_transparency_active = (BYTE)TransList[bMap]; Cel2DecodeLightTrans(pBuff, pSpecialCels, bArch, 64, CelSkip, 8); } } @@ -1371,7 +1373,7 @@ void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, s level_piece_id = dPiece[x][y]; light_table_index = dLight[x][y]; dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; switch (skipChunks) { @@ -1446,7 +1448,7 @@ void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks light_table_index = dLight[x][y]; if (level_piece_id != 0) { dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); if (capChunks >= 0) { level_cel_block = pMap->mt[1]; if (level_cel_block != 0) { @@ -1494,7 +1496,7 @@ void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks light_table_index = dLight[x][y]; if (level_piece_id != 0) { dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); arch_draw_type = 1; level_cel_block = pMap->mt[0]; if (level_cel_block != 0) { @@ -1530,44 +1532,46 @@ void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks pMap++; } - if (eflag && y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { - level_piece_id = dPiece[x][y]; - light_table_index = dLight[x][y]; - if (level_piece_id != 0) { - dst = &gpBuffer[sx + PitchTbl[sy]]; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); - arch_draw_type = 1; - if (capChunks >= 0) { - level_cel_block = pMap->mt[0]; - if (level_cel_block != 0) { - drawUpperScreen(dst); + if (eflag) { + if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { + level_piece_id = dPiece[x][y]; + light_table_index = dLight[x][y]; + if (level_piece_id != 0) { + dst = &gpBuffer[sx + PitchTbl[sy]]; + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + arch_draw_type = 1; + if (capChunks >= 0) { + level_cel_block = pMap->mt[0]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } } - } - arch_draw_type = 0; - dst -= BUFFER_WIDTH * 32; - if (capChunks >= 1) { - level_cel_block = pMap->mt[2]; - if (level_cel_block != 0) { - drawUpperScreen(dst); + arch_draw_type = 0; + dst -= BUFFER_WIDTH * 32; + if (capChunks >= 1) { + level_cel_block = pMap->mt[2]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } } - } - dst -= BUFFER_WIDTH * 32; - if (capChunks >= 2) { - level_cel_block = pMap->mt[4]; - if (level_cel_block != 0) { - drawUpperScreen(dst); + dst -= BUFFER_WIDTH * 32; + if (capChunks >= 2) { + level_cel_block = pMap->mt[4]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } } - } - dst -= BUFFER_WIDTH * 32; - if (capChunks >= 3) { - level_cel_block = pMap->mt[6]; - if (level_cel_block != 0) { - drawUpperScreen(dst); + dst -= BUFFER_WIDTH * 32; + if (capChunks >= 3) { + level_cel_block = pMap->mt[6]; + if (level_cel_block != 0) { + drawUpperScreen(dst); + } } + scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); + } else { + world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } - scrollrt_draw_dungeon(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); - } else { - world_draw_black_tile(&gpBuffer[sx + PitchTbl[sy]]); } } } @@ -1633,7 +1637,7 @@ void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCa pItem = &item[bItem - 1]; if (!pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -1746,7 +1750,7 @@ void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCa pItem = &item[bItem - 1]; if (pItem->_iPostDraw) { /// ASSERT: assert((unsigned char)bItem <= MAXITEMS); - if ((unsigned char)bItem <= MAXITEMS) { + if ((BYTE)bItem <= MAXITEMS) { pCelBuff = pItem->_iAnimData; if (pCelBuff != NULL) { pFrameTable = (DWORD *)pCelBuff; @@ -1767,7 +1771,7 @@ void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCa } } if (bArch != 0) { - cel_transparency_active = (unsigned char)TransList[bMap]; + cel_transparency_active = (BYTE)TransList[bMap]; CelDecodeHdrLightTrans(pBuff, pSpecialCels, bArch, 64, 0, CelCap); } } @@ -1851,7 +1855,7 @@ void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int CelCap) } /// ASSERT: assert((unsigned char)bv < MAXOBJECTS); - if ((unsigned char)bv >= MAXOBJECTS) + if ((BYTE)bv >= MAXOBJECTS) return; pCelBuff = object[bv]._oAnimData; @@ -1891,7 +1895,7 @@ void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, level_piece_id = dPiece[x][y]; light_table_index = dLight[x][y]; dst = pBuff; - cel_transparency_active = (unsigned char)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); + cel_transparency_active = (BYTE)(nTransTable[level_piece_id] & TransList[dTransVal[x][y]]); pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; arch_draw_type = 1; @@ -2582,11 +2586,11 @@ void DrawAndBlit() int hgt; BOOL ddsdesc, ctrlPan; - if(!gbRunGame) { + if (!gbRunGame) { return; } - if(drawpanflag == 255) { + if (drawpanflag == 255) { drawhpflag = TRUE; drawmanaflag = TRUE; drawbtnflag = TRUE; @@ -2594,7 +2598,7 @@ void DrawAndBlit() ddsdesc = FALSE; ctrlPan = TRUE; hgt = 480; - } else if(drawpanflag == 1) { + } else if (drawpanflag == 1) { ddsdesc = TRUE; ctrlPan = FALSE; hgt = 352; @@ -2605,27 +2609,27 @@ void DrawAndBlit() drawpanflag = 0; lock_buf(0); - if(leveltype != DTYPE_TOWN) { + if (leveltype != DTYPE_TOWN) { DrawView(ViewX, ViewY); } else { T_DrawView(ViewX, ViewY); } - if(ctrlPan) { + if (ctrlPan) { ClearCtrlPan(); } - if(drawhpflag) { + if (drawhpflag) { UpdateLifeFlask(); } - if(drawmanaflag) { + if (drawmanaflag) { UpdateManaFlask(); } - if(drawbtnflag) { + if (drawbtnflag) { DrawCtrlPan(); } - if(drawsbarflag) { + if (drawsbarflag) { DrawInvBelt(); } - if(talkflag) { + if (talkflag) { DrawTalkPan(); hgt = 480; } diff --git a/Source/scrollrt.h b/Source/scrollrt.h index baeac29ba9c..3510660c3f1 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -28,7 +28,7 @@ void DrawClippedObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy); void scrollrt_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag); void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag); -void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, signed int CelSkip, int sx, int sy); +void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy); void scrollrt_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag); void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int capChunks, int CelCap, int dx, int dy, int eflag); void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int CelCap); diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 3db21409d3a..1a31bc1f964 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -106,8 +106,8 @@ void DRLG_SetMapTrans(char *sFileName) { int x, y; int i, j; - UCHAR *pLevelMap; - UCHAR *d; + BYTE *pLevelMap; + BYTE *d; DWORD dwOffset; pLevelMap = LoadFileInMem(sFileName, NULL); diff --git a/Source/spelldat.h b/Source/spelldat.h index 6b524f5dafd..adb185c720f 100644 --- a/Source/spelldat.h +++ b/Source/spelldat.h @@ -1,7 +1,7 @@ -//HEADER_GOES_HERE -#ifndef __SPELLDAT_H__ -#define __SPELLDAT_H__ - -extern SpellData spelldata[MAX_SPELLS]; - -#endif /* __SPELLDAT_H__ */ +//HEADER_GOES_HERE +#ifndef __SPELLDAT_H__ +#define __SPELLDAT_H__ + +extern SpellData spelldata[MAX_SPELLS]; + +#endif /* __SPELLDAT_H__ */ diff --git a/Source/spells.cpp b/Source/spells.cpp index f7fc0b9973c..345f266b327 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -81,7 +81,7 @@ void UseMana(int id, int sn) } } -BOOL CheckSpell(int id, int sn, BYTE st, BOOL manaonly) +BOOL CheckSpell(int id, int sn, char st, BOOL manaonly) { BOOL result; diff --git a/Source/spells.h b/Source/spells.h index 9376d27c3da..f8887d47ee7 100644 --- a/Source/spells.h +++ b/Source/spells.h @@ -4,7 +4,7 @@ int GetManaAmount(int id, int sn); void UseMana(int id, int sn); -BOOL CheckSpell(int id, int sn, BYTE st, BOOL manaonly); +BOOL CheckSpell(int id, int sn, char st, BOOL manaonly); void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int caster, int spllvl); void DoResurrect(int pnum, int rid); void PlacePlayer(int pnum); diff --git a/Source/stores.cpp b/Source/stores.cpp index 55c4accce17..15b373f1d54 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -78,9 +78,9 @@ void InitStores() { int i; - pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0); - pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0); - pSTextSlidCels = LoadFileInMem("Data\\TextSlid.CEL", 0); + pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", NULL); + pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", NULL); + pSTextSlidCels = LoadFileInMem("Data\\TextSlid.CEL", NULL); ClearSText(0, 24); stextflag = STORE_NONE; InStoreFlag = 1; diff --git a/Source/town.cpp b/Source/town.cpp index a4cfb8b3f91..91ab97b4035 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -388,75 +388,75 @@ void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) town_draw_clipped_town(pBuff, x, y, sx, sy, 0); } -void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some_flag) +void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) { int mi, px, py; char bv; /// ASSERT: assert(gpBuffer); - pBuff = &gpBuffer[sx + PitchTbl[sy]]; + pBuff = &gpBuffer[dx + PitchTbl[dy]]; - if (dItem[x][y] != 0) { - bv = dItem[x][y] - 1; - px = sx - item[bv]._iAnimWidth2; + if (dItem[sx][sy] != 0) { + bv = dItem[sx][sy] - 1; + px = dx - item[bv]._iAnimWidth2; if (bv == pcursitem) { - CelDrawHdrClrHL(181, px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, 8); + CelDrawHdrClrHL(181, px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, 8); } - Cel2DrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, 8); + Cel2DrawHdrOnly(px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, 8); } - if (dFlags[x][y] & BFLAG_MONSTLR) { - mi = -(dMonster[x][y - 1] + 1); - px = sx - towner[mi]._tAnimWidth2; + if (dFlags[sx][sy] & BFLAG_MONSTLR) { + mi = -(dMonster[sx][sy - 1] + 1); + px = dx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDrawHdrClrHL(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); + CelDrawHdrClrHL(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); } - Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); + Cel2DrawHdrOnly(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); } - if (dMonster[x][y] > 0) { - mi = dMonster[x][y] - 1; - px = sx - towner[mi]._tAnimWidth2; + if (dMonster[sx][sy] > 0) { + mi = dMonster[sx][sy] - 1; + px = dx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDrawHdrClrHL(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); + CelDrawHdrClrHL(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); } - Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); + Cel2DrawHdrOnly(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, 8); } - if (dFlags[x][y] & BFLAG_PLAYERLR) { - bv = -(dPlayer[x][y - 1] + 1); - px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = sy + plr[bv]._pyoff; + if (dFlags[sx][sy] & BFLAG_PLAYERLR) { + bv = -(dPlayer[sx][sy - 1] + 1); + px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; + py = dy + plr[bv]._pyoff; if (bv == pcursplr) { Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, 8); } Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, 8); - if (some_flag && plr[bv]._peflag) { - town_draw_clipped_e_flag(pBuff - 64, x - 1, y + 1, sx - 64, sy); + if (eflag && plr[bv]._peflag) { + town_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } - if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(x, y, sx, sy, 0, 8, 1); + if (dFlags[sx][sy] & BFLAG_DEAD_PLAYER) { + DrawDeadPlayer(sx, sy, dx, dy, 0, 8, 1); } - if (dPlayer[x][y] > 0) { - bv = dPlayer[x][y] - 1; - px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = sy + plr[bv]._pyoff; + if (dPlayer[sx][sy] > 0) { + bv = dPlayer[sx][sy] - 1; + px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; + py = dy + plr[bv]._pyoff; if (bv == pcursplr) { Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, 8); } Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, 8); - if (some_flag && plr[bv]._peflag) { - town_draw_clipped_e_flag(pBuff - 64, x - 1, y + 1, sx - 64, sy); + if (eflag && plr[bv]._peflag) { + town_draw_clipped_e_flag(pBuff - 64, sx - 1, sy + 1, dx - 64, dy); } } - if (dFlags[x][y] & BFLAG_MISSILE) { - DrawClippedMissile(x, y, sx, sy, 0, 8, 0); + if (dFlags[sx][sy] & BFLAG_MISSILE) { + DrawClippedMissile(sx, sy, dx, dy, 0, 8, 0); } - if (dArch[x][y] != 0) { - town_special_lower(pBuff, dArch[x][y]); + if (dArch[sx][sy] != 0) { + town_special_lower(pBuff, dArch[sx][sy]); } } -void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) +void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag) { int i, j; BYTE *dst; @@ -464,7 +464,7 @@ void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) /// ASSERT: assert(gpBuffer); - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { @@ -489,7 +489,7 @@ void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) sx += 64; } - for (j = 0; j < a5 - some_flag; j++) { + for (j = 0; j < chunks - eflag; j++) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { @@ -518,7 +518,7 @@ void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) sx += 64; } - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { @@ -541,22 +541,22 @@ void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag) } } -void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, int sy) +void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy) { int i; BYTE *dst; MICROS *pMap; - if (a4 == 0) { + if (skipChunks == 0) { dst = pBuff; } else { - dst = &pBuff[BUFFER_WIDTH * 32 * a4]; + dst = &pBuff[BUFFER_WIDTH * 32 * skipChunks]; } pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 6; i++) { - if (a4 <= i) { + if (skipChunks <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -569,93 +569,93 @@ void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int a4, int a5, int s dst -= BUFFER_WIDTH * 32; } - if (a5 < 8) { - town_draw_clipped_town_2(pBuff, x, y, a4, a5, sx, sy, 0); + if (CelSkip < 8) { + town_draw_clipped_town_2(pBuff, x, y, skipChunks, CelSkip, sx, sy, 0); } } -void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, int sy, BOOL some_flag) +void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag) { int mi, px, py; char bv; - if (dItem[x][y] != 0) { - bv = dItem[x][y] - 1; - px = sx - item[bv]._iAnimWidth2; + if (dItem[sx][sy] != 0) { + bv = dItem[sx][sy] - 1; + px = dx - item[bv]._iAnimWidth2; if (bv == pcursitem) { - CelDrawHdrClrHL(181, px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, a5, 8); + CelDrawHdrClrHL(181, px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, CelSkip, 8); } - Cel2DrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, a5, 8); + Cel2DrawHdrOnly(px, dy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, CelSkip, 8); } - if (dFlags[x][y] & BFLAG_MONSTLR) { - mi = -(dMonster[x][y - 1] + 1); - px = sx - towner[mi]._tAnimWidth2; + if (dFlags[sx][sy] & BFLAG_MONSTLR) { + mi = -(dMonster[sx][sy - 1] + 1); + px = dx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDrawHdrClrHL(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, a5, 8); + CelDrawHdrClrHL(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, CelSkip, 8); } - Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, a5, 8); + Cel2DrawHdrOnly(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, CelSkip, 8); } - if (dMonster[x][y] > 0) { - mi = dMonster[x][y] - 1; - px = sx - towner[mi]._tAnimWidth2; + if (dMonster[sx][sy] > 0) { + mi = dMonster[sx][sy] - 1; + px = dx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDrawHdrClrHL(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, a5, 8); + CelDrawHdrClrHL(166, px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, CelSkip, 8); } - Cel2DrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, a5, 8); + Cel2DrawHdrOnly(px, dy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, CelSkip, 8); } - if (dFlags[x][y] & BFLAG_PLAYERLR) { - bv = -(dPlayer[x][y - 1] + 1); - px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = sy + plr[bv]._pyoff; + if (dFlags[sx][sy] & BFLAG_PLAYERLR) { + bv = -(dPlayer[sx][sy - 1] + 1); + px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; + py = dy + plr[bv]._pyoff; if (bv == pcursplr) { - Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, a5, 8); + Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); } - Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, a5, 8); - if (some_flag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, x - 1, y + 1, a4, a5, sx - 64, sy); + Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); + if (eflag && plr[bv]._peflag) { + town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); } } - if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(x, y, sx, sy, a5, 8, 1); + if (dFlags[sx][sy] & BFLAG_DEAD_PLAYER) { + DrawDeadPlayer(sx, sy, dx, dy, CelSkip, 8, 1); } - if (dPlayer[x][y] > 0) { - bv = dPlayer[x][y] - 1; - px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; - py = sy + plr[bv]._pyoff; + if (dPlayer[sx][sy] > 0) { + bv = dPlayer[sx][sy] - 1; + px = dx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; + py = dy + plr[bv]._pyoff; if (bv == pcursplr) { - Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, a5, 8); + Cl2DecodeClrHL(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); } - Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, a5, 8); - if (some_flag && plr[bv]._peflag) { - town_draw_clipped_e_flag_2(pBuff - 64, x - 1, y + 1, a4, a5, sx - 64, sy); + Cl2DecodeFrm4(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, CelSkip, 8); + if (eflag && plr[bv]._peflag) { + town_draw_clipped_e_flag_2(pBuff - 64, sx - 1, sy + 1, skipChunks, CelSkip, dx - 64, dy); } } - if (dFlags[x][y] & BFLAG_MISSILE) { - DrawClippedMissile(x, y, sx, sy, a5, 8, 0); + if (dFlags[sx][sy] & BFLAG_MISSILE) { + DrawClippedMissile(sx, sy, dx, dy, CelSkip, 8, 0); } - if (dArch[x][y] != 0) { - town_special_lower(&pBuff[PitchTbl[16 * a5]], dArch[x][y]); + if (dArch[sx][sy] != 0) { + town_special_lower(&pBuff[PitchTbl[16 * CelSkip]], dArch[sx][sy]); } } -void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag) +void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag) { - int i, j, dir; + int i, j, CelSkip; BYTE *dst; MICROS *pMap; /// ASSERT: assert(gpBuffer); - dir = 2 * a6 + 2; + CelSkip = 2 * skipChunks + 2; - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx - (BUFFER_WIDTH * 32 - 32) + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 <= i) { + if (skipChunks <= i) { level_cel_block = pMap->mt[2 * i + 3]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -663,8 +663,8 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl } dst -= BUFFER_WIDTH * 32; } - if (dir < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, a6, dir, sx, sy, 0); + if (CelSkip < 8) { + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, CelSkip, sx, sy, 0); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -677,14 +677,14 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl sx += 64; } - for (j = 0; j < a5 - some_flag; j++) { + for (j = 0; j < chunks - eflag; j++) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 <= i) { + if (skipChunks <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -696,8 +696,8 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl } dst -= BUFFER_WIDTH * 32; } - if (dir < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * dir], x, y, a6, dir, sx, sy, 1); + if (CelSkip < 8) { + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy] - BUFFER_WIDTH * 16 * CelSkip], x, y, skipChunks, CelSkip, sx, sy, 1); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -710,14 +710,14 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl sx += 64; } - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx - BUFFER_WIDTH * 32 + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 <= i) { + if (skipChunks <= i) { level_cel_block = pMap->mt[2 * i + 2]; if (level_cel_block != 0) { drawLowerScreen(dst); @@ -725,8 +725,8 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl } dst -= BUFFER_WIDTH * 32; } - if (dir < 8) { - town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, a6, dir, sx, sy, 0); + if (CelSkip < 8) { + town_draw_clipped_town_2(&gpBuffer[sx + PitchTbl[sy]], x, y, skipChunks, CelSkip, sx, sy, 0); } } else { town_clear_low_buf(&gpBuffer[sx + PitchTbl[sy]]); @@ -737,7 +737,7 @@ void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_fl } } -void town_draw_e_flag(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy) +void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy) { int i; BYTE *dst; @@ -747,7 +747,7 @@ void town_draw_e_flag(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a4 >= i) { + if (capChunks >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -760,10 +760,10 @@ void town_draw_e_flag(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(pBuff, x, y, a4, dir, sx, sy, 0); + town_draw_town_all(pBuff, x, y, capChunks, CelCap, sx, sy, 0); } -void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy, BOOL some_flag) +void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy, int eflag) { int mi, px, py; char bv; @@ -772,87 +772,87 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int bv = dItem[x][y] - 1; px = sx - item[bv]._iAnimWidth2; if (bv == pcursitem) { - CelDecodeClr(181, px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, dir); + CelDecodeClr(181, px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, CelCap); } /// ASSERT: assert(item[bv]._iAnimData); - CelDrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, dir); + CelDrawHdrOnly(px, sy, item[bv]._iAnimData, item[bv]._iAnimFrame, item[bv]._iAnimWidth, 0, CelCap); } if (dFlags[x][y] & BFLAG_MONSTLR) { mi = -(dMonster[x][y - 1] + 1); px = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDecodeClr(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDecodeClr(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, CelCap); } /// ASSERT: assert(towner[mi]._tAnimData); - CelDrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, CelCap); } if (dMonster[x][y] > 0) { mi = dMonster[x][y] - 1; px = sx - towner[mi]._tAnimWidth2; if (mi == pcursmonst) { - CelDecodeClr(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDecodeClr(166, px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, CelCap); } /// ASSERT: assert(towner[mi]._tAnimData); - CelDrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, dir); + CelDrawHdrOnly(px, sy, towner[mi]._tAnimData, towner[mi]._tAnimFrame, towner[mi]._tAnimWidth, 0, CelCap); } if (dFlags[x][y] & BFLAG_PLAYERLR) { bv = -(dPlayer[x][y - 1] + 1); px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; py = sy + plr[bv]._pyoff; if (bv == pcursplr) { - Cl2DecodeFrm2(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, dir); + Cl2DecodeFrm2(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); } /// ASSERT: assert(plr[bv]._pAnimData); - Cl2DecodeFrm1(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, dir); - if (some_flag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, a4, dir, sx - 64, sy); + Cl2DecodeFrm1(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); + if (eflag && plr[bv]._peflag) { + town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, CelCap, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_DEAD_PLAYER) { - DrawDeadPlayer(x, y, sx, sy, 0, dir, 0); + DrawDeadPlayer(x, y, sx, sy, 0, CelCap, 0); } if (dPlayer[x][y] > 0) { bv = dPlayer[x][y] - 1; px = sx + plr[bv]._pxoff - plr[bv]._pAnimWidth2; py = sy + plr[bv]._pyoff; if (bv == pcursplr) { - Cl2DecodeFrm2(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, dir); + Cl2DecodeFrm2(165, px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); } /// ASSERT: assert(plr[bv]._pAnimData); - Cl2DecodeFrm1(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, dir); - if (some_flag && plr[bv]._peflag) { - town_draw_e_flag(pBuff - 64, x - 1, y + 1, a4, dir, sx - 64, sy); + Cl2DecodeFrm1(px, py, plr[bv]._pAnimData, plr[bv]._pAnimFrame, plr[bv]._pAnimWidth, 0, CelCap); + if (eflag && plr[bv]._peflag) { + town_draw_e_flag(pBuff - 64, x - 1, y + 1, capChunks, CelCap, sx - 64, sy); } } if (dFlags[x][y] & BFLAG_MISSILE) { - DrawMissile(x, y, sx, sy, 0, dir, 0); + DrawMissile(x, y, sx, sy, 0, CelCap, 0); } if (dArch[x][y] != 0) { town_special_upper(pBuff, dArch[x][y]); } } -void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag) +void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag) { - int i, j, dir; + int i, j, CelCap; BYTE *dst; MICROS *pMap; /// ASSERT: assert(gpBuffer); - dir = 2 * a6 + 2; - if (dir > 8) { - dir = 8; + CelCap = 2 * capChunks + 2; + if (CelCap > 8) { + CelCap = 8; } - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx + 32 + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 >= i) { + if (capChunks >= i) { level_cel_block = pMap->mt[2 * i + 1]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -860,7 +860,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, a6, dir, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -872,14 +872,14 @@ void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag sx += 64; } - for (j = 0; j < a5 - some_flag; j++) { + for (j = 0; j < chunks - eflag; j++) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 >= i) { + if (capChunks >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -891,7 +891,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, a6, dir, sx, sy, 1); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 1); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -903,14 +903,14 @@ void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag sx += 64; } - if (some_flag) { + if (eflag) { if (y >= 0 && y < MAXDUNY && x >= 0 && x < MAXDUNX) { level_cel_block = dPiece[x][y]; if (level_cel_block != 0) { dst = &gpBuffer[sx + PitchTbl[sy]]; pMap = &dpiece_defs_map_1[IsometricCoord(x, y)]; for (i = 0; i < 7; i++) { - if (a6 >= i) { + if (capChunks >= i) { level_cel_block = pMap->mt[2 * i]; if (level_cel_block != 0) { drawUpperScreen(dst); @@ -918,7 +918,7 @@ void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag } dst -= BUFFER_WIDTH * 32; } - town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, a6, dir, sx, sy, 0); + town_draw_town_all(&gpBuffer[sx + PitchTbl[sy]], x, y, capChunks, CelCap, sx, sy, 0); } else { town_clear_upper_buf(&gpBuffer[sx + PitchTbl[sy]]); } @@ -1018,7 +1018,7 @@ void T_DrawGame(int x, int y) sy += 16; } /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[512]]; + gpBufEnd = &gpBuffer[PitchTbl[VIEWPORT_HEIGHT + SCREEN_Y]]; for (i = 0; i < blocks; i++) { town_draw_lower(x, y, sx, sy, chunks, 0); y++; @@ -1107,7 +1107,7 @@ void T_DrawZoom(int x, int y) } /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[143]]; + gpBufEnd = &gpBuffer[PitchTbl[-17 + SCREEN_Y]]; for (i = 0; i < 7; i++) { town_draw_upper(x, y, sx, sy, chunks, i, 0); y++; @@ -1119,7 +1119,7 @@ void T_DrawZoom(int x, int y) sy += 16; } /// ASSERT: assert(gpBuffer); - gpBufEnd = &gpBuffer[PitchTbl[320]]; + gpBufEnd = &gpBuffer[PitchTbl[160 + SCREEN_Y]]; for (i = 0; i < blocks; i++) { town_draw_lower(x, y, sx, sy, chunks, 0); y++; @@ -1213,12 +1213,14 @@ void T_DrawView(int StartX, int StartY) { light_table_index = 0; cel_transparency_active = 0; - if (zoomflag) + if (zoomflag) { T_DrawGame(StartX, StartY); - else + } else { T_DrawZoom(StartX, StartY); - if (automapflag) + } + if (automapflag) { DrawAutomap(); + } if (stextflag && !qtextflag) DrawSText(); if (invflag) { @@ -1226,28 +1228,38 @@ void T_DrawView(int StartX, int StartY) } else if (sbookflag) { DrawSpellBook(); } + DrawDurIcon(); + if (chrflag) { DrawChr(); } else if (questlog) { DrawQuestLog(); - } else if (plr[myplr]._pStatPts && !spselflag) { + } else if (plr[myplr]._pStatPts != 0 && !spselflag) { DrawLevelUpIcon(); } - if (uitemflag) + if (uitemflag) { DrawUniqueInfo(); - if (qtextflag) + } + if (qtextflag) { DrawQText(); - if (spselflag) + } + if (spselflag) { DrawSpellList(); - if (dropGoldFlag) + } + if (dropGoldFlag) { DrawGoldSplit(dropGoldValue); - if (helpflag) + } + if (helpflag) { DrawHelp(); - if (msgflag) + } + if (msgflag) { DrawDiabloMsg(); - if (PauseMode && !deathflag) + } + if (PauseMode != 0 && !deathflag) { gmenu_draw_pause(); + } + DrawPlrMsg(); gmenu_draw(); doom_draw(); @@ -1293,7 +1305,7 @@ void SetTownMicros() } } -void T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h) +void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h) { int i, j, xx, yy; long v1, v2, v3, v4, ii; @@ -1365,7 +1377,7 @@ void T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi } } -void T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) +void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t) { long v1, v2, v3, v4; @@ -1413,7 +1425,7 @@ void T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) void T_Pass3() { int xx, yy, x; - unsigned char *P3Tiles, *pSector; + BYTE *P3Tiles, *pSector; for (yy = 0; yy < MAXDUNY; yy += 2) { for (xx = 0; xx < MAXDUNX; xx += 2) { @@ -1424,17 +1436,17 @@ void T_Pass3() } } - P3Tiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); - pSector = LoadFileInMem("Levels\\TownData\\Sector1s.DUN", 0); + P3Tiles = LoadFileInMem("Levels\\TownData\\Town.TIL", NULL); + pSector = LoadFileInMem("Levels\\TownData\\Sector1s.DUN", NULL); T_FillSector(P3Tiles, pSector, 46, 46, 25, 25); mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector2s.DUN", 0); + pSector = LoadFileInMem("Levels\\TownData\\Sector2s.DUN", NULL); T_FillSector(P3Tiles, pSector, 46, 0, 25, 23); mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector3s.DUN", 0); + pSector = LoadFileInMem("Levels\\TownData\\Sector3s.DUN", NULL); T_FillSector(P3Tiles, pSector, 0, 46, 23, 25); mem_free_dbg(pSector); - pSector = LoadFileInMem("Levels\\TownData\\Sector4s.DUN", 0); + pSector = LoadFileInMem("Levels\\TownData\\Sector4s.DUN", NULL); T_FillSector(P3Tiles, pSector, 0, 0, 23, 23); mem_free_dbg(pSector); diff --git a/Source/town.h b/Source/town.h index 4e6021382e6..842a43c7c38 100644 --- a/Source/town.h +++ b/Source/town.h @@ -7,20 +7,20 @@ void town_clear_low_buf(BYTE *pBuff); void town_special_lower(BYTE *pBuff, int nCel); void town_special_upper(BYTE *pBuff, int nCel); void town_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy); -void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some_flag); -void town_draw_lower(int x, int y, int sx, int sy, int a5, int some_flag); -void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, int sy); -void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx, int sy, BOOL some_flag); -void town_draw_lower_2(int x, int y, int sx, int sy, int a5, int a6, int some_flag); -void town_draw_e_flag(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy); -void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int sy, BOOL some_flag); -void town_draw_upper(int x, int y, int sx, int sy, int a5, int a6, int some_flag); +void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag); +void town_draw_lower(int x, int y, int sx, int sy, int chunks, int eflag); +void town_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int skipChunks, int CelSkip, int sx, int sy); +void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int skipChunks, int CelSkip, int dx, int dy, int eflag); +void town_draw_lower_2(int x, int y, int sx, int sy, int chunks, int skipChunks, int eflag); +void town_draw_e_flag(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy); +void town_draw_town_all(BYTE *pBuff, int x, int y, int capChunks, int CelCap, int sx, int sy, int eflag); +void town_draw_upper(int x, int y, int sx, int sy, int chunks, int capChunks, int eflag); void T_DrawGame(int x, int y); void T_DrawZoom(int x, int y); void T_DrawView(int StartX, int StartY); void SetTownMicros(); -void T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi, int w, int h); -void T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t); +void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h); +void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t); void T_Pass3(); void CreateTown(int entry); diff --git a/Source/towners.cpp b/Source/towners.cpp index e55f7f86aed..0e7a5437373 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -151,7 +151,7 @@ void SetTownerGPtrs(BYTE *pData, BYTE **pAnim) #endif } -void NewTownerAnim(int tnum, unsigned char *pAnim, int numFrames, int Delay) +void NewTownerAnim(int tnum, BYTE *pAnim, int numFrames, int Delay) { towner[tnum]._tAnimCnt = 0; towner[tnum]._tAnimLen = numFrames; @@ -198,7 +198,7 @@ void InitSmith() InitTownerInfo(numtowners, 96, 1, TOWN_SMITH, 62, 63, 0, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\Smith\\SmithN.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\Smith\\SmithN.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -215,7 +215,7 @@ void InitBarOwner() bannerflag = 0; // unused InitTownerInfo(numtowners, 96, 1, TOWN_TAVERN, 55, 62, 3, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\TwnF\\TwnFN.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\TwnF\\TwnFN.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -232,7 +232,7 @@ void InitTownDead() InitTownerInfo(numtowners, 96, 1, TOWN_DEADGUY, 24, 32, -1, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\Butch\\Deadguy.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\Butch\\Deadguy.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -248,7 +248,7 @@ void InitWitch() InitTownerInfo(numtowners, 96, 1, TOWN_WITCH, 80, 20, 5, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\Witch.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\Witch.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -264,7 +264,7 @@ void InitBarmaid() InitTownerInfo(numtowners, 96, 1, TOWN_BMAID, 43, 66, -1, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\WmnN.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\TownWmn1\\WmnN.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -281,7 +281,7 @@ void InitBoy() boyloadflag = 1; InitTownerInfo(numtowners, 96, 1, TOWN_PEGBOY, 11, 53, -1, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\TownBoy\\PegKid1.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\TownBoy\\PegKid1.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -298,7 +298,7 @@ void InitHealer() InitTownerInfo(numtowners, 96, 1, TOWN_HEALER, 55, 79, 1, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\Healer\\Healer.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\Healer\\Healer.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -314,7 +314,7 @@ void InitTeller() InitTownerInfo(numtowners, 96, 1, TOWN_STORY, 62, 71, 2, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\Strytell\\Strytell.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\Strytell\\Strytell.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -330,7 +330,7 @@ void InitDrunk() InitTownerInfo(numtowners, 96, 1, TOWN_DRUNK, 71, 84, 4, 10); InitQstSnds(numtowners); - towner[numtowners]._tNData = LoadFileInMem("Towners\\Drunk\\TwnDrunk.CEL", 0); + towner[numtowners]._tNData = LoadFileInMem("Towners\\Drunk\\TwnDrunk.CEL", NULL); for (i = 0; i < 8; i++) { towner[numtowners]._tNAnim[i] = towner[numtowners]._tNData; } @@ -347,7 +347,7 @@ void InitCows() //if ( pCowCels ) // assertion_failed(300, "C:\\Diablo\\Direct\\towners.cpp", "! pCowCels"); - pCowCels = LoadFileInMem("Towners\\Animals\\Cow.CEL", 0); + pCowCels = LoadFileInMem("Towners\\Animals\\Cow.CEL", NULL); for (i = 0; i < 3; i++) { x = TownCowX[i]; y = TownCowY[i]; diff --git a/Source/towners.h b/Source/towners.h index 9a45f003f3d..310d84e3c16 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -5,8 +5,8 @@ extern TownerStruct towner[16]; int GetActiveTowner(int t); -void SetTownerGPtrs(BYTE *pData, BYTE **pAnim); /* unsigned char *+** */ -void NewTownerAnim(int tnum, unsigned char *pAnim, int numFrames, int Delay); +void SetTownerGPtrs(BYTE *pData, BYTE **pAnim); +void NewTownerAnim(int tnum, BYTE *pAnim, int numFrames, int Delay); void InitTownerInfo(int i, int w, int sel, int t, int x, int y, int ao, int tp); void InitQstSnds(int i); void InitSmith(); diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 7cf7691b11b..4b6d55eee38 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -723,48 +723,80 @@ constexpr auto DVL_WM_PALETTECHANGED = 0x0311; constexpr auto DVL_SC_CLOSE = 0xF060; -constexpr auto DVL_VK_RETURN = 0x0D; -constexpr auto DVL_VK_BACK = 0x08; -constexpr auto DVL_VK_SHIFT = 0x10; -constexpr auto DVL_VK_ESCAPE = 0x1B; -constexpr auto DVL_VK_SPACE = 0x20; -constexpr auto DVL_VK_LEFT = 0x25; -constexpr auto DVL_VK_UP = 0x26; -constexpr auto DVL_VK_RIGHT = 0x27; -constexpr auto DVL_VK_DOWN = 0x28; - -constexpr auto DVL_VK_F1 = 0x70; -constexpr auto DVL_VK_F2 = 0x71; -constexpr auto DVL_VK_F3 = 0x72; -constexpr auto DVL_VK_F4 = 0x73; -constexpr auto DVL_VK_F5 = 0x74; -constexpr auto DVL_VK_F6 = 0x75; -constexpr auto DVL_VK_F7 = 0x76; -constexpr auto DVL_VK_F8 = 0x77; -constexpr auto DVL_VK_F9 = 0x78; -constexpr auto DVL_VK_F10 = 0x79; -constexpr auto DVL_VK_F11 = 0x7A; -constexpr auto DVL_VK_F12 = 0x7B; - -constexpr auto DVL_VK_TAB = 0x09; -constexpr auto DVL_VK_PAUSE = 0x13; -constexpr auto DVL_VK_PRIOR = 0x21; -constexpr auto DVL_VK_NEXT = 0x22; -constexpr auto DVL_VK_SNAPSHOT = 0x2C; - -constexpr auto DVL_VK_OEM_1 = 0xBA; -constexpr auto DVL_VK_OEM_PLUS = 0xBB; -constexpr auto DVL_VK_OEM_COMMA = 0xBC; -constexpr auto DVL_VK_OEM_MINUS = 0xBD; -constexpr auto DVL_VK_OEM_PERIOD = 0xBE; -constexpr auto DVL_VK_OEM_2 = 0xBF; -constexpr auto DVL_VK_OEM_3 = 0xC0; -constexpr auto DVL_VK_OEM_4 = 0xDB; -constexpr auto DVL_VK_OEM_5 = 0xDC; -constexpr auto DVL_VK_OEM_6 = 0xDD; -constexpr auto DVL_VK_OEM_7 = 0xDE; -//constexpr auto DVL_VK_OEM_8 = 0xDF; -//constexpr auto DVL_VK_OEM_102 = 0xE2; +// Virtual key codes. +// +// ref: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes +constexpr auto DVL_VK_BACK = 0x08; // BACKSPACE key +constexpr auto DVL_VK_TAB = 0x09; // TAB key +constexpr auto DVL_VK_RETURN = 0x0D; // ENTER key +constexpr auto DVL_VK_SHIFT = 0x10; // SHIFT key +constexpr auto DVL_VK_CONTROL = 0x11; // CONTROL key +constexpr auto DVL_VK_MENU = 0x12; // ALT key +constexpr auto DVL_VK_PAUSE = 0x13; // PAUSE key +constexpr auto DVL_VK_CAPITAL = 0x14; // CAPS LOCK key +constexpr auto DVL_VK_ESCAPE = 0x1B; // ESC key +constexpr auto DVL_VK_SPACE = 0x20; // SPACEBAR +constexpr auto DVL_VK_PRIOR = 0x21; // PAGE UP key +constexpr auto DVL_VK_NEXT = 0x22; // PAGE DOWN key +constexpr auto DVL_VK_END = 0x23; // END key +constexpr auto DVL_VK_HOME = 0x24; // HOME key +constexpr auto DVL_VK_LEFT = 0x25; // LEFT ARROW key +constexpr auto DVL_VK_UP = 0x26; // UP ARROW key +constexpr auto DVL_VK_RIGHT = 0x27; // RIGHT ARROW key +constexpr auto DVL_VK_DOWN = 0x28; // DOWN ARROW key +constexpr auto DVL_VK_SNAPSHOT = 0x2C; // PRINT SCREEN key +constexpr auto DVL_VK_INSERT = 0x2D; // INS key +constexpr auto DVL_VK_DELETE = 0x2E; // DEL key +// DVL_VK_0 through DVL_VK_9 correspond to '0' - '9' +// DVL_VK_A through DVL_VK_Z correspond to 'A' - 'Z' +constexpr auto DVL_VK_LWIN = 0x5B; // Left Windows key (Natural keyboard) +constexpr auto DVL_VK_RWIN = 0x5C; // Right Windows key (Natural keyboard) +constexpr auto DVL_VK_NUMPAD0 = 0x60; // Numeric keypad 0 key +constexpr auto DVL_VK_NUMPAD1 = 0x61; // Numeric keypad 1 key +constexpr auto DVL_VK_NUMPAD2 = 0x62; // Numeric keypad 2 key +constexpr auto DVL_VK_NUMPAD3 = 0x63; // Numeric keypad 3 key +constexpr auto DVL_VK_NUMPAD4 = 0x64; // Numeric keypad 4 key +constexpr auto DVL_VK_NUMPAD5 = 0x65; // Numeric keypad 5 key +constexpr auto DVL_VK_NUMPAD6 = 0x66; // Numeric keypad 6 key +constexpr auto DVL_VK_NUMPAD7 = 0x67; // Numeric keypad 7 key +constexpr auto DVL_VK_NUMPAD8 = 0x68; // Numeric keypad 8 key +constexpr auto DVL_VK_NUMPAD9 = 0x69; // Numeric keypad 9 key +constexpr auto DVL_VK_MULTIPLY = 0x6A; // Multiply key +constexpr auto DVL_VK_ADD = 0x6B; // Add key +constexpr auto DVL_VK_SUBTRACT = 0x6D; // Subtract key +constexpr auto DVL_VK_DECIMAL = 0x6E; // Decimal key +constexpr auto DVL_VK_DIVIDE = 0x6F; // Divide key +constexpr auto DVL_VK_F1 = 0x70; // F1 key +constexpr auto DVL_VK_F2 = 0x71; // F2 key +constexpr auto DVL_VK_F3 = 0x72; // F3 key +constexpr auto DVL_VK_F4 = 0x73; // F4 key +constexpr auto DVL_VK_F5 = 0x74; // F5 key +constexpr auto DVL_VK_F6 = 0x75; // F6 key +constexpr auto DVL_VK_F7 = 0x76; // F7 key +constexpr auto DVL_VK_F8 = 0x77; // F8 key +constexpr auto DVL_VK_F9 = 0x78; // F9 key +constexpr auto DVL_VK_F10 = 0x79; // F10 key +constexpr auto DVL_VK_F11 = 0x7A; // F11 key +constexpr auto DVL_VK_F12 = 0x7B; // F12 key +constexpr auto DVL_VK_NUMLOCK = 0x90; // NUM LOCK key +constexpr auto DVL_VK_SCROLL = 0x91; // SCROLL LOCK key +constexpr auto DVL_VK_LSHIFT = 0xA0; // Left SHIFT key +constexpr auto DVL_VK_RSHIFT = 0xA1; // Right SHIFT key +constexpr auto DVL_VK_LCONTROL = 0xA2; // Left CONTROL key +constexpr auto DVL_VK_RCONTROL = 0xA3; // Right CONTROL key +constexpr auto DVL_VK_LMENU = 0xA4; // Left MENU key +constexpr auto DVL_VK_RMENU = 0xA5; // Right MENU key +constexpr auto DVL_VK_OEM_1 = 0xBA; // For the US standard keyboard, the ';:' key +constexpr auto DVL_VK_OEM_PLUS = 0xBB; // For any country/region, the '+' key +constexpr auto DVL_VK_OEM_COMMA = 0xBC; // For any country/region, the ',' key +constexpr auto DVL_VK_OEM_MINUS = 0xBD; // For any country/region, the '-' key +constexpr auto DVL_VK_OEM_PERIOD = 0xBE; // For any country/region, the '.' key +constexpr auto DVL_VK_OEM_2 = 0xBF; // For the US standard keyboard, the '/?' key +constexpr auto DVL_VK_OEM_3 = 0xC0; // For the US standard keyboard, the '`~' key +constexpr auto DVL_VK_OEM_4 = 0xDB; // For the US standard keyboard, the '[{' key +constexpr auto DVL_VK_OEM_5 = 0xDC; // For the US standard keyboard, the '\|' key +constexpr auto DVL_VK_OEM_6 = 0xDD; // For the US standard keyboard, the ']}' key +constexpr auto DVL_VK_OEM_7 = 0xDE; // For the US standard keyboard, the 'single-quote/double-quote' key constexpr auto DVL_MK_SHIFT = 0x0004; constexpr auto DVL_MK_LBUTTON = 0x0001; diff --git a/SourceS/miniwin/misc_macro.h b/SourceS/miniwin/misc_macro.h index 2bfe82a899b..6aff296b2ea 100644 --- a/SourceS/miniwin/misc_macro.h +++ b/SourceS/miniwin/misc_macro.h @@ -282,48 +282,80 @@ #define SC_CLOSE DVL_SC_CLOSE -#define VK_RETURN DVL_VK_RETURN -#define VK_BACK DVL_VK_BACK -#define VK_SHIFT DVL_VK_SHIFT -#define VK_ESCAPE DVL_VK_ESCAPE -#define VK_SPACE DVL_VK_SPACE -#define VK_LEFT DVL_VK_LEFT -#define VK_UP DVL_VK_UP -#define VK_RIGHT DVL_VK_RIGHT -#define VK_DOWN DVL_VK_DOWN - -#define VK_F1 DVL_VK_F1 -#define VK_F2 DVL_VK_F2 -#define VK_F3 DVL_VK_F3 -#define VK_F4 DVL_VK_F4 -#define VK_F5 DVL_VK_F5 -#define VK_F6 DVL_VK_F6 -#define VK_F7 DVL_VK_F7 -#define VK_F8 DVL_VK_F8 -#define VK_F9 DVL_VK_F9 -#define VK_F10 DVL_VK_F10 -#define VK_F11 DVL_VK_F11 -#define VK_F12 DVL_VK_F12 - -#define VK_TAB DVL_VK_TAB -#define VK_PAUSE DVL_VK_PAUSE -#define VK_PRIOR DVL_VK_PRIOR -#define VK_NEXT DVL_VK_NEXT -#define VK_SNAPSHOT DVL_VK_SNAPSHOT - -#define VK_OEM_1 DVL_VK_OEM_1 -#define VK_OEM_PLUS DVL_VK_OEM_PLUS -#define VK_OEM_COMMA DVL_VK_OEM_COMMA -#define VK_OEM_MINUS DVL_VK_OEM_MINUS -#define VK_OEM_PERIOD DVL_VK_OEM_PERIOD -#define VK_OEM_2 DVL_VK_OEM_2 -#define VK_OEM_3 DVL_VK_OEM_3 -#define VK_OEM_4 DVL_VK_OEM_4 -#define VK_OEM_5 DVL_VK_OEM_5 -#define VK_OEM_6 DVL_VK_OEM_6 -#define VK_OEM_7 DVL_VK_OEM_7 -//#define VK_OEM_8 DVL_VK_OEM_8 -//#define VK_OEM_102 DVL_VK_OEM_102 +// Virtual key codes. +// +// ref: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes +#define VK_BACK DVL_VK_BACK // BACKSPACE key +#define VK_TAB DVL_VK_TAB // TAB key +#define VK_RETURN DVL_VK_RETURN // ENTER key +#define VK_SHIFT DVL_VK_SHIFT // SHIFT key +#define VK_CONTROL DVL_VK_CONTROL // CONTROL key +#define VK_MENU DVL_VK_MENU // ALT key +#define VK_PAUSE DVL_VK_PAUSE // PAUSE key +#define VK_CAPITAL DVL_VK_CAPITAL // CAPS LOCK key +#define VK_ESCAPE DVL_VK_ESCAPE // ESC key +#define VK_SPACE DVL_VK_SPACE // SPACEBAR +#define VK_PRIOR DVL_VK_PRIOR // PAGE UP key +#define VK_NEXT DVL_VK_NEXT // PAGE DOWN key +#define VK_END DVL_VK_END // END key +#define VK_HOME DVL_VK_HOME // HOME key +#define VK_LEFT DVL_VK_LEFT // LEFT ARROW key +#define VK_UP DVL_VK_UP // UP ARROW key +#define VK_RIGHT DVL_VK_RIGHT // RIGHT ARROW key +#define VK_DOWN DVL_VK_DOWN // DOWN ARROW key +#define VK_SNAPSHOT DVL_VK_SNAPSHOT // PRINT SCREEN key +#define VK_INSERT DVL_VK_INSERT // INS key +#define VK_DELETE DVL_VK_DELETE // DEL key +// VK_0 through VK_9 correspond to '0' - '9' +// VK_A through VK_Z correspond to 'A' - 'Z' +#define VK_LWIN DVL_VK_LWIN // Left Windows key (Natural keyboard) +#define VK_RWIN DVL_VK_RWIN // Right Windows key (Natural keyboard) +#define VK_NUMPAD0 DVL_VK_NUMPAD0 // Numeric keypad 0 key +#define VK_NUMPAD1 DVL_VK_NUMPAD1 // Numeric keypad 1 key +#define VK_NUMPAD2 DVL_VK_NUMPAD2 // Numeric keypad 2 key +#define VK_NUMPAD3 DVL_VK_NUMPAD3 // Numeric keypad 3 key +#define VK_NUMPAD4 DVL_VK_NUMPAD4 // Numeric keypad 4 key +#define VK_NUMPAD5 DVL_VK_NUMPAD5 // Numeric keypad 5 key +#define VK_NUMPAD6 DVL_VK_NUMPAD6 // Numeric keypad 6 key +#define VK_NUMPAD7 DVL_VK_NUMPAD7 // Numeric keypad 7 key +#define VK_NUMPAD8 DVL_VK_NUMPAD8 // Numeric keypad 8 key +#define VK_NUMPAD9 DVL_VK_NUMPAD9 // Numeric keypad 9 key +#define VK_MULTIPLY DVL_VK_MULTIPLY // Multiply key +#define VK_ADD DVL_VK_ADD // Add key +#define VK_SUBTRACT DVL_VK_SUBTRACT // Subtract key +#define VK_DECIMAL DVL_VK_DECIMAL // Decimal key +#define VK_DIVIDE DVL_VK_DIVIDE // Divide key +#define VK_F1 DVL_VK_F1 // F1 key +#define VK_F2 DVL_VK_F2 // F2 key +#define VK_F3 DVL_VK_F3 // F3 key +#define VK_F4 DVL_VK_F4 // F4 key +#define VK_F5 DVL_VK_F5 // F5 key +#define VK_F6 DVL_VK_F6 // F6 key +#define VK_F7 DVL_VK_F7 // F7 key +#define VK_F8 DVL_VK_F8 // F8 key +#define VK_F9 DVL_VK_F9 // F9 key +#define VK_F10 DVL_VK_F10 // F10 key +#define VK_F11 DVL_VK_F11 // F11 key +#define VK_F12 DVL_VK_F12 // F12 key +#define VK_NUMLOCK DVL_VK_NUMLOCK // NUM LOCK key +#define VK_SCROLL DVL_VK_SCROLL // SCROLL LOCK key +#define VK_LSHIFT DVL_VK_LSHIFT // Left SHIFT key +#define VK_RSHIFT DVL_VK_RSHIFT // Right SHIFT key +#define VK_LCONTROL DVL_VK_LCONTROL // Left CONTROL key +#define VK_RCONTROL DVL_VK_RCONTROL // Right CONTROL key +#define VK_LMENU DVL_VK_LMENU // Left MENU key +#define VK_RMENU DVL_VK_RMENU // Right MENU key +#define VK_OEM_1 DVL_VK_OEM_1 // For the US standard keyboard, the ';:' key +#define VK_OEM_PLUS DVL_VK_OEM_PLUS // For any country/region, the '+' key +#define VK_OEM_COMMA DVL_VK_OEM_COMMA // For any country/region, the ',' key +#define VK_OEM_MINUS DVL_VK_OEM_MINUS // For any country/region, the '-' key +#define VK_OEM_PERIOD DVL_VK_OEM_PERIOD // For any country/region, the '.' key +#define VK_OEM_2 DVL_VK_OEM_2 // For the US standard keyboard, the '/?' key +#define VK_OEM_3 DVL_VK_OEM_3 // For the US standard keyboard, the '`~' key +#define VK_OEM_4 DVL_VK_OEM_4 // For the US standard keyboard, the '[{' key +#define VK_OEM_5 DVL_VK_OEM_5 // For the US standard keyboard, the '\|' key +#define VK_OEM_6 DVL_VK_OEM_6 // For the US standard keyboard, the ']}' key +#define VK_OEM_7 DVL_VK_OEM_7 // For the US standard keyboard, the 'single-quote/double-quote' key #define MK_SHIFT DVL_MK_SHIFT #define MK_LBUTTON DVL_MK_LBUTTON diff --git a/SourceX/miniwin/misc_msg.cpp b/SourceX/miniwin/misc_msg.cpp index 28e009f9434..31bf16d06a0 100644 --- a/SourceX/miniwin/misc_msg.cpp +++ b/SourceX/miniwin/misc_msg.cpp @@ -15,68 +15,154 @@ static std::deque message_queue; static int translate_sdl_key(SDL_Keysym key) { + // ref: https://wiki.libsdl.org/SDL_Keycode + // ref: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes int sym = key.sym; switch (sym) { - case SDLK_ESCAPE: - return DVL_VK_ESCAPE; - case SDLK_RETURN: - case SDLK_KP_ENTER: - return DVL_VK_RETURN; + case SDLK_BACKSPACE: + return DVL_VK_BACK; case SDLK_TAB: return DVL_VK_TAB; + case SDLK_RETURN: + return DVL_VK_RETURN; + case SDLK_ESCAPE: + return DVL_VK_ESCAPE; case SDLK_SPACE: return DVL_VK_SPACE; - case SDLK_BACKSPACE: - return DVL_VK_BACK; - - case SDLK_DOWN: - return DVL_VK_DOWN; - case SDLK_LEFT: - return DVL_VK_LEFT; - case SDLK_RIGHT: - return DVL_VK_RIGHT; - case SDLK_UP: - return DVL_VK_UP; - - case SDLK_PAGEUP: - return DVL_VK_PRIOR; - case SDLK_PAGEDOWN: - return DVL_VK_NEXT; - - case SDLK_PAUSE: - return DVL_VK_PAUSE; - + case SDLK_QUOTE: + return DVL_VK_OEM_7; + case SDLK_COMMA: + return DVL_VK_OEM_COMMA; + case SDLK_MINUS: + return DVL_VK_OEM_MINUS; + case SDLK_PERIOD: + return DVL_VK_OEM_PERIOD; + case SDLK_SLASH: + return DVL_VK_OEM_2; case SDLK_SEMICOLON: return DVL_VK_OEM_1; - case SDLK_QUESTION: - return DVL_VK_OEM_2; - case SDLK_BACKQUOTE: - return DVL_VK_OEM_3; + case SDLK_EQUALS: + return DVL_VK_OEM_PLUS; case SDLK_LEFTBRACKET: return DVL_VK_OEM_4; case SDLK_BACKSLASH: return DVL_VK_OEM_5; case SDLK_RIGHTBRACKET: return DVL_VK_OEM_6; - case SDLK_QUOTE: - return DVL_VK_OEM_7; - case SDLK_MINUS: + case SDLK_BACKQUOTE: + return DVL_VK_OEM_3; + case SDLK_DELETE: + return DVL_VK_DELETE; + case SDLK_CAPSLOCK: + return DVL_VK_CAPITAL; + case SDLK_F1: + return DVL_VK_F1; + case SDLK_F2: + return DVL_VK_F2; + case SDLK_F3: + return DVL_VK_F3; + case SDLK_F4: + return DVL_VK_F4; + case SDLK_F5: + return DVL_VK_F5; + case SDLK_F6: + return DVL_VK_F6; + case SDLK_F7: + return DVL_VK_F7; + case SDLK_F8: + return DVL_VK_F8; + case SDLK_F9: + return DVL_VK_F9; + case SDLK_F10: + return DVL_VK_F10; + case SDLK_F11: + return DVL_VK_F11; + case SDLK_F12: + return DVL_VK_F12; + case SDLK_PRINTSCREEN: + return DVL_VK_SNAPSHOT; + case SDLK_SCROLLLOCK: + return DVL_VK_SCROLL; + case SDLK_PAUSE: + return DVL_VK_PAUSE; + case SDLK_INSERT: + return DVL_VK_INSERT; + case SDLK_HOME: + return DVL_VK_HOME; + case SDLK_PAGEUP: + return DVL_VK_PRIOR; + case SDLK_END: + return DVL_VK_END; + case SDLK_PAGEDOWN: + return DVL_VK_NEXT; + case SDLK_RIGHT: + return DVL_VK_RIGHT; + case SDLK_LEFT: + return DVL_VK_LEFT; + case SDLK_DOWN: + return DVL_VK_DOWN; + case SDLK_UP: + return DVL_VK_UP; + case SDLK_NUMLOCKCLEAR: + return DVL_VK_NUMLOCK; + case SDLK_KP_DIVIDE: + return DVL_VK_DIVIDE; + case SDLK_KP_MULTIPLY: + return DVL_VK_MULTIPLY; case SDLK_KP_MINUS: + // Returning DVL_VK_OEM_MINUS to play nice with Devilution automap zoom. + // + // For a distinct keypad key-code, DVL_VK_SUBTRACT should be returned. return DVL_VK_OEM_MINUS; - case SDLK_PLUS: - case SDLK_EQUALS: case SDLK_KP_PLUS: + // Returning DVL_VK_OEM_PLUS to play nice with Devilution automap zoom. + // + // For a distinct keypad key-code, DVL_VK_ADD should be returned. return DVL_VK_OEM_PLUS; - case SDLK_PERIOD: - return DVL_VK_OEM_PERIOD; - case SDLK_COMMA: + case SDLK_KP_ENTER: + return DVL_VK_RETURN; + case SDLK_KP_1: + return DVL_VK_NUMPAD1; + case SDLK_KP_2: + return DVL_VK_NUMPAD2; + case SDLK_KP_3: + return DVL_VK_NUMPAD3; + case SDLK_KP_4: + return DVL_VK_NUMPAD4; + case SDLK_KP_5: + return DVL_VK_NUMPAD5; + case SDLK_KP_6: + return DVL_VK_NUMPAD6; + case SDLK_KP_7: + return DVL_VK_NUMPAD7; + case SDLK_KP_8: + return DVL_VK_NUMPAD8; + case SDLK_KP_9: + return DVL_VK_NUMPAD9; + case SDLK_KP_0: + return DVL_VK_NUMPAD0; + case SDLK_KP_PERIOD: + return DVL_VK_DECIMAL; + case SDLK_MENU: + return DVL_VK_MENU; + case SDLK_KP_COMMA: return DVL_VK_OEM_COMMA; + case SDLK_LCTRL: + return DVL_VK_LCONTROL; case SDLK_LSHIFT: + return DVL_VK_LSHIFT; + case SDLK_LALT: + return DVL_VK_LMENU; + case SDLK_LGUI: + return DVL_VK_LWIN; + case SDLK_RCTRL: + return DVL_VK_RCONTROL; case SDLK_RSHIFT: - return DVL_VK_SHIFT; - case SDLK_PRINTSCREEN: - return DVL_VK_SNAPSHOT; - + return DVL_VK_RSHIFT; + case SDLK_RALT: + return DVL_VK_RMENU; + case SDLK_RGUI: + return DVL_VK_RWIN; default: if (sym >= SDLK_a && sym <= SDLK_z) { return 'A' + (sym - SDLK_a); diff --git a/docker/arch/Dockerfile b/docker/arch/Dockerfile deleted file mode 100644 index ea199b7ea53..00000000000 --- a/docker/arch/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM base/archlinux - -RUN echo -e "[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf -RUN pacman -Sy -RUN pacman --noconfirm -Sy \ - make gcc cmake pkg-config nasm lib32-gcc-libs lib32-sdl2 - -WORKDIR /build -VOLUME /src diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100644 index 04db988da35..00000000000 --- a/docker/build.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# -# Build script to run inside a Docker container -# - -set -e - -cmake /src -make -j$(nproc) diff --git a/docker/ubuntu/Dockerfile b/docker/ubuntu/Dockerfile deleted file mode 100644 index 7f6da8a978c..00000000000 --- a/docker/ubuntu/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu:16.04 - -RUN dpkg --add-architecture i386 - -RUN apt-get update -RUN apt-get update && apt-get install -y --no-install-recommends \ - g++-multilib cmake nasm pkg-config libsdl2-dev:i386 - -WORKDIR /build -VOLUME /src diff --git a/structs.h b/structs.h index 454bd94e1f3..051fa76dbe1 100644 --- a/structs.h +++ b/structs.h @@ -655,6 +655,7 @@ typedef struct ObjDataStruct { BOOL oTrapFlag; } ObjDataStruct; +#pragma pack(push, 4) typedef struct ObjectStruct { int _otype; int _ox; @@ -687,11 +688,13 @@ typedef struct ObjectStruct { int _oVar7; int _oVar8; } ObjectStruct; +#pragma pack(pop) ////////////////////////////////////////////////// // portal ////////////////////////////////////////////////// +#pragma pack(push, 4) typedef struct PortalStruct { BOOL open; int x; @@ -700,6 +703,7 @@ typedef struct PortalStruct { int ltype; BOOL setlvl; } PortalStruct; +#pragma pack(pop) ////////////////////////////////////////////////// // msg @@ -966,6 +970,7 @@ typedef struct TBuffer { // quests ////////////////////////////////////////////////// +#pragma pack(push, 4) typedef struct QuestStruct { unsigned char _qlevel; unsigned char _qtype; @@ -980,6 +985,7 @@ typedef struct QuestStruct { unsigned char _qvar2; int _qlog; } QuestStruct; +#pragma pack(pop) typedef struct QuestData { unsigned char _qdlvl;