From 5f556a93b70e2a246439b8b4768abc68191d4dbe Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 25 Oct 2020 23:35:26 +0000 Subject: [PATCH 01/12] SFileSetBasePath: char * -> const char * Follow-up to https://github.com/diasurgical/devilution/commit/ec329e645c4794b63a8239f6589260ed8a7c0b2e --- 3rdParty/Storm/Source/storm.cpp | 2 +- 3rdParty/Storm/Source/storm.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index c09968d57..ef9bbde9d 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -227,7 +227,7 @@ int STORMAPI SBigToBinaryBuffer(void *buffer, int length, int a3, int a4) rInt; void __stdcall SDrawMessageBox(const char *,const char *,int) rVoid; void __cdecl SDrawDestroy(void) rVoid; BOOLEAN __cdecl StormDestroy(void) rBool; -BOOL __stdcall SFileSetBasePath(char *) rBool; +BOOL __stdcall SFileSetBasePath(const char *) rBool; void __cdecl SDrawRealizePalette(void) rVoid; BOOL __cdecl SVidPlayContinue(void) rBool; BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *) rBool; diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index d3d3e5eac..9cbd6aae4 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -1323,7 +1323,7 @@ int STORMAPI SBigToBinaryBuffer(void *buffer, int length, int a3, int a4); void __stdcall SDrawMessageBox(const char *,const char *,int); void __cdecl SDrawDestroy(void); BOOLEAN __cdecl StormDestroy(void); -BOOL __stdcall SFileSetBasePath(char *); +BOOL __stdcall SFileSetBasePath(const char *); void __cdecl SDrawRealizePalette(void); BOOL __cdecl SVidPlayContinue(void); BOOL __stdcall SNetGetOwnerTurnsWaiting(DWORD *); From 619d90bccae113e7ba1601e98053addf9fdc4cee Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 25 Oct 2020 23:56:35 +0000 Subject: [PATCH 02/12] Make _SNETVERSIONDATA char* fields const Follow-up to https://github.com/diasurgical/devilution/commit/ec329e645c4794b63a8239f6589260ed8a7c0b2 --- structs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/structs.h b/structs.h index 3e37fc907..dbcc3ab2e 100644 --- a/structs.h +++ b/structs.h @@ -1428,10 +1428,10 @@ typedef struct _SNETUIDATA { typedef struct _SNETVERSIONDATA { int size; - char *versionstring; - char *executablefile; - char *originalarchivefile; - char *patcharchivefile; + const char *versionstring; + const char *executablefile; + const char *originalarchivefile; + const char *patcharchivefile; } _SNETVERSIONDATA; // TPDEF PTR FCN UCHAR SNETSPIBIND From 4e8df866bc6b38f5f8c75d607a20b5e2a98edd18 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 26 Oct 2020 01:15:51 +0100 Subject: [PATCH 03/12] Fix function order [sha.cpp] --- Source/sha.cpp | 109 ++++++++++++++++++++++++++----------------------- Source/sha.h | 10 ----- 2 files changed, 58 insertions(+), 61 deletions(-) diff --git a/Source/sha.cpp b/Source/sha.cpp index 38d84f91a..472c88d20 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -5,53 +5,27 @@ */ #include "all.h" -SHA1Context sgSHA1[3]; - -void SHA1Clear() -{ - memset(sgSHA1, 0, sizeof(sgSHA1)); -} +/** + * Define the SHA1 circular left shift macro + */ +#define SHA1CircularShift(bits, word) \ + (((word) << (bits)) | ((word) >> (32 - (bits)))) -void SHA1Result(int n, char Message_Digest[SHA1HashSize]) -{ - DWORD *Message_Digest_Block; - int i; - Message_Digest_Block = (DWORD *)Message_Digest; - if (Message_Digest) { - for (i = 0; i < 5; i++) { - *Message_Digest_Block = sgSHA1[n].state[i]; - Message_Digest_Block++; - } - } -} - -void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]) -{ - SHA1Input(&sgSHA1[n], data, 64); - if (Message_Digest) - SHA1Result(n, Message_Digest); -} +SHA1Context sgSHA1[3]; -void SHA1Input(SHA1Context *context, const char *message_array, int len) +static void SHA1Init(SHA1Context *context) { - int i, count; - - count = context->count[0] + 8 * len; - if (count < context->count[0]) - context->count[1]++; - - context->count[0] = count; - context->count[1] += len >> 29; - - for (i = len; i >= 64; i -= 64) { - memcpy(context->buffer, message_array, sizeof(context->buffer)); - SHA1ProcessMessageBlock(context); - message_array += 64; - } + context->count[0] = 0; + context->count[1] = 0; + context->state[0] = 0x67452301; + context->state[1] = 0xEFCDAB89; + context->state[2] = 0x98BADCFE; + context->state[3] = 0x10325476; + context->state[4] = 0xC3D2E1F0; } -void SHA1ProcessMessageBlock(SHA1Context *context) +static void SHA1ProcessMessageBlock(SHA1Context *context) { int i, temp; int W[80]; @@ -114,18 +88,51 @@ void SHA1ProcessMessageBlock(SHA1Context *context) context->state[4] += E; } -void SHA1Reset(int n) +static void SHA1Input(SHA1Context *context, const char *message_array, int len) { - SHA1Init(&sgSHA1[n]); + int i, count; + + count = context->count[0] + 8 * len; + if (count < context->count[0]) + context->count[1]++; + + context->count[0] = count; + context->count[1] += len >> 29; + + for (i = len; i >= 64; i -= 64) { + memcpy(context->buffer, message_array, sizeof(context->buffer)); + SHA1ProcessMessageBlock(context); + message_array += 64; + } } -void SHA1Init(SHA1Context *context) +void SHA1Clear() { - context->count[0] = 0; - context->count[1] = 0; - context->state[0] = 0x67452301; - context->state[1] = 0xEFCDAB89; - context->state[2] = 0x98BADCFE; - context->state[3] = 0x10325476; - context->state[4] = 0xC3D2E1F0; + memset(sgSHA1, 0, sizeof(sgSHA1)); +} + +void SHA1Result(int n, char Message_Digest[SHA1HashSize]) +{ + DWORD *Message_Digest_Block; + int i; + + Message_Digest_Block = (DWORD *)Message_Digest; + if (Message_Digest) { + for (i = 0; i < 5; i++) { + *Message_Digest_Block = sgSHA1[n].state[i]; + Message_Digest_Block++; + } + } +} + +void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]) +{ + SHA1Input(&sgSHA1[n], data, 64); + if (Message_Digest) + SHA1Result(n, Message_Digest); +} + +void SHA1Reset(int n) +{ + SHA1Init(&sgSHA1[n]); } diff --git a/Source/sha.h b/Source/sha.h index 7dc287743..e88f34b92 100644 --- a/Source/sha.h +++ b/Source/sha.h @@ -6,21 +6,11 @@ #ifndef __SHA_H__ #define __SHA_H__ -/** - * Define the SHA1 circular left shift macro - */ -#define SHA1CircularShift(bits, word) \ - (((word) << (bits)) | ((word) >> (32 - (bits)))) #define SHA1HashSize 20 -//sha - void SHA1Clear(); void SHA1Result(int n, char Message_Digest[SHA1HashSize]); void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]); -void SHA1Input(SHA1Context *context, const char *message_array, int len); -void SHA1ProcessMessageBlock(SHA1Context *context); void SHA1Reset(int n); -void SHA1Init(SHA1Context *context); #endif /* __SHA_H__ */ From 6580222d1ce9f44e2efc39b9120970025bd1300b Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 26 Oct 2020 01:39:06 +0100 Subject: [PATCH 04/12] Add enums for level entrances --- Source/diablo.cpp | 18 +++++++++--------- Source/drlg_l1.cpp | 8 ++++---- Source/drlg_l2.cpp | 4 ++-- Source/drlg_l3.cpp | 4 ++-- Source/drlg_l4.cpp | 10 +++++----- Source/interfac.cpp | 18 +++++++++--------- Source/loadsave.cpp | 2 +- Source/town.cpp | 6 +++--- enums.h | 11 +++++++++++ 9 files changed, 46 insertions(+), 35 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 30ceac5e4..d6ddf48ed 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1830,7 +1830,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) IncProgress(); InitAutomap(); - if (leveltype != DTYPE_TOWN && lvldir != 4) { + if (leveltype != DTYPE_TOWN && lvldir != ENTRY_LOAD) { InitLighting(); InitVision(); } @@ -1854,9 +1854,9 @@ void LoadGameLevel(BOOL firstflag, int lvldir) IncProgress(); - if (lvldir == 3) + if (lvldir == ENTRY_RTNLVL) GetReturnLvlPos(); - if (lvldir == 5) + if (lvldir == ENTRY_WARPLVL) GetPortalLvlPos(); IncProgress(); @@ -1864,7 +1864,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) for (i = 0; i < MAX_PLRS; i++) { if (plr[i].plractive && currlevel == plr[i].plrlevel) { InitPlayerGFX(i); - if (lvldir != 4) + if (lvldir != ENTRY_LOAD) InitPlayer(i, firstflag); } } @@ -1882,7 +1882,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) SetRndSeed(glSeedTbl[currlevel]); if (leveltype != DTYPE_TOWN) { - if (firstflag || lvldir == 4 || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) { + if (firstflag || lvldir == ENTRY_LOAD || !plr[myplr]._pLvlVisited[currlevel] || gbMaxPlayers != 1) { HoldThemeRooms(); glMid1Seed[currlevel] = GetRndSeed(); InitMonsters(); @@ -1922,7 +1922,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) InitMissiles(); IncProgress(); - if (!firstflag && lvldir != 4 && plr[myplr]._pLvlVisited[currlevel] && gbMaxPlayers == 1) + if (!firstflag && lvldir != ENTRY_LOAD && plr[myplr]._pLvlVisited[currlevel] && gbMaxPlayers == 1) LoadLevel(); if (gbMaxPlayers != 1) DeltaLoadLevel(); @@ -1946,13 +1946,13 @@ void LoadGameLevel(BOOL firstflag, int lvldir) FillSolidBlockTbls(); IncProgress(); - if (lvldir == 5) + if (lvldir == ENTRY_WARPLVL) GetPortalLvlPos(); for (i = 0; i < MAX_PLRS; i++) { if (plr[i].plractive && currlevel == plr[i].plrlevel) { InitPlayerGFX(i); - if (lvldir != 4) + if (lvldir != ENTRY_LOAD) InitPlayer(i, firstflag); } } @@ -1960,7 +1960,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) InitMultiView(); IncProgress(); - if (firstflag || lvldir == 4 || !plr[myplr]._pSLvlVisited[setlvlnum]) { + if (firstflag || lvldir == ENTRY_LOAD || !plr[myplr]._pSLvlVisited[setlvlnum]) { InitItems(); SavePreLighting(); } else { diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index e960fe02a..1d76c8629 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -2620,7 +2620,7 @@ static void DRLG_L5(int entry) doneflag = TRUE; if (QuestStatus(Q_PWATER)) { - if (entry == 0) { + if (entry == ENTRY_MAIN) { if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, TRUE, -1, 0) < 0) doneflag = FALSE; } else { @@ -2630,13 +2630,13 @@ static void DRLG_L5(int entry) } } if (QuestStatus(Q_LTBANNER)) { - if (entry == 0) { + if (entry == ENTRY_MAIN) { if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, TRUE, -1, 0) < 0) doneflag = FALSE; } else { if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, FALSE, -1, 0) < 0) doneflag = FALSE; - if (entry == 1) { + if (entry == ENTRY_PREV) { ViewX = 2 * setpc_x + 20; ViewY = 2 * setpc_y + 28; } else { @@ -2725,7 +2725,7 @@ static void DRLG_L5(int entry) } } #else - } else if (entry == 0) { + } else if (entry == ENTRY_MAIN) { if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, TRUE, -1, 0) < 0) doneflag = FALSE; else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, FALSE, -1, 1) < 0) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 1509b88e5..28324e638 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -3169,7 +3169,7 @@ static void DRLG_L2(int entry) } DRLG_L2FloodTVal(); DRLG_L2TransFix(); - if (entry == 0) { + if (entry == ENTRY_MAIN) { doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, TRUE, 0); if (doneflag) { doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, FALSE, 1); @@ -3178,7 +3178,7 @@ static void DRLG_L2(int entry) } } ViewY -= 2; - } else if (entry == 1) { + } else if (entry == ENTRY_PREV) { doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, FALSE, 0); if (doneflag) { doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, TRUE, 1); diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index b3f072fbb..548fb888d 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -2352,7 +2352,7 @@ static void DRLG_L3(int entry) } } while (!found); DRLG_L3MakeMegas(); - if (entry == 0) { + if (entry == ENTRY_MAIN) { #ifdef HELLFIRE if (currlevel < 17) { #endif @@ -2380,7 +2380,7 @@ static void DRLG_L3(int entry) genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, FALSE, 6); } } - } else if (entry == 1) { + } else if (entry == ENTRY_PREV) { #ifdef HELLFIRE if (currlevel < 17) { #endif diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 23d3c207d..14c6a920a 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1615,13 +1615,13 @@ static void DRLG_L4(int entry) DRLG_LoadDiabQuads(TRUE); } if (QuestStatus(Q_WARLORD)) { - if (entry == 0) { + if (entry == ENTRY_MAIN) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, TRUE, 0); if (doneflag && currlevel == 13) { doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, FALSE, 6); } ViewX++; - } else if (entry == 1) { + } else if (entry == ENTRY_PREV) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, FALSE, 0); if (doneflag && currlevel == 13) { doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, FALSE, 6); @@ -1636,7 +1636,7 @@ static void DRLG_L4(int entry) ViewX++; } } else if (currlevel != 15) { - if (entry == 0) { + if (entry == ENTRY_MAIN) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, TRUE, 0); if (doneflag && currlevel != 16) { doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, FALSE, 1); @@ -1645,7 +1645,7 @@ static void DRLG_L4(int entry) doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, FALSE, 6); } ViewX++; - } else if (entry == 1) { + } else if (entry == ENTRY_PREV) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, FALSE, 0); if (doneflag && currlevel != 16) { doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, TRUE, 1); @@ -1665,7 +1665,7 @@ static void DRLG_L4(int entry) ViewX++; } } else { - if (entry == 0) { + if (entry == ENTRY_MAIN) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, TRUE, 0); if (doneflag) { if (gbMaxPlayers == 1 && quests[Q_DIABLO]._qactive != QUEST_ACTIVE) { diff --git a/Source/interfac.cpp b/Source/interfac.cpp index e024c5876..875113dd6 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -101,7 +101,7 @@ void ShowProgress(unsigned int uMsg) FreeGameMem(); IncProgress(); pfile_remove_temp_files(); - LoadGameLevel(TRUE, 0); + LoadGameLevel(TRUE, ENTRY_MAIN); IncProgress(); break; case WM_DIABNEXTLVL: @@ -116,7 +116,7 @@ void ShowProgress(unsigned int uMsg) leveltype = gnLevelTypeTbl[currlevel]; assert(plr[myplr].plrlevel == currlevel); IncProgress(); - LoadGameLevel(FALSE, 0); + LoadGameLevel(FALSE, ENTRY_MAIN); IncProgress(); break; case WM_DIABPREVLVL: @@ -132,7 +132,7 @@ void ShowProgress(unsigned int uMsg) leveltype = gnLevelTypeTbl[currlevel]; assert(plr[myplr].plrlevel == currlevel); IncProgress(); - LoadGameLevel(FALSE, 1); + LoadGameLevel(FALSE, ENTRY_PREV); IncProgress(); break; case WM_DIABSETLVL: @@ -146,7 +146,7 @@ void ShowProgress(unsigned int uMsg) leveltype = setlvltype; FreeGameMem(); IncProgress(); - LoadGameLevel(FALSE, 2); + LoadGameLevel(FALSE, ENTRY_SETLVL); IncProgress(); break; case WM_DIABRTNLVL: @@ -159,7 +159,7 @@ void ShowProgress(unsigned int uMsg) FreeGameMem(); IncProgress(); GetReturnLvlPos(); - LoadGameLevel(FALSE, 3); + LoadGameLevel(FALSE, ENTRY_RTNLVL); IncProgress(); break; case WM_DIABWARPLVL: @@ -172,7 +172,7 @@ void ShowProgress(unsigned int uMsg) FreeGameMem(); GetPortalLevel(); IncProgress(); - LoadGameLevel(FALSE, 5); + LoadGameLevel(FALSE, ENTRY_WARPLVL); IncProgress(); break; case WM_DIABTOWNWARP: @@ -187,7 +187,7 @@ void ShowProgress(unsigned int uMsg) leveltype = gnLevelTypeTbl[currlevel]; assert(plr[myplr].plrlevel == currlevel); IncProgress(); - LoadGameLevel(FALSE, 6); + LoadGameLevel(FALSE, ENTRY_TWARPDN); IncProgress(); break; case WM_DIABTWARPUP: @@ -202,7 +202,7 @@ void ShowProgress(unsigned int uMsg) leveltype = gnLevelTypeTbl[currlevel]; assert(plr[myplr].plrlevel == currlevel); IncProgress(); - LoadGameLevel(FALSE, 7); + LoadGameLevel(FALSE, ENTRY_TWARPUP); IncProgress(); break; case WM_DIABRETOWN: @@ -217,7 +217,7 @@ void ShowProgress(unsigned int uMsg) leveltype = gnLevelTypeTbl[currlevel]; assert(plr[myplr].plrlevel == currlevel); IncProgress(); - LoadGameLevel(FALSE, 0); + LoadGameLevel(FALSE, ENTRY_MAIN); IncProgress(); break; } diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index e4a8f6013..f5b08d6a8 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -62,7 +62,7 @@ void LoadGame(BOOL firstflag) for (i = 0; i < MAXPORTAL; i++) LoadPortal(i); - LoadGameLevel(firstflag, 4); + LoadGameLevel(firstflag, ENTRY_LOAD); SyncInitPlr(myplr); SyncPlrAnim(myplr); diff --git a/Source/town.cpp b/Source/town.cpp index be3b50a72..ef23ed36d 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1829,13 +1829,13 @@ void CreateTown(int entry) dmaxx = 84; dmaxy = 84; - if (entry == 0) { + if (entry == ENTRY_MAIN) { // New game ViewX = 75; ViewY = 68; - } else if (entry == 1) { + } else if (entry == ENTRY_PREV) { // Cathedral ViewX = 25; ViewY = 31; - } else if (entry == 7) { + } else if (entry == ENTRY_TWARPUP) { if (TWarpFrom == 5) { ViewX = 49; ViewY = 22; diff --git a/enums.h b/enums.h index c5e496ecd..1cdbc62d3 100644 --- a/enums.h +++ b/enums.h @@ -2570,6 +2570,17 @@ typedef enum interface_mode { // WM_DIAVNEWLVL = 0x40D, // psx only } interface_mode; +typedef enum lvl_entry { + ENTRY_MAIN = 0, + ENTRY_PREV = 1, + ENTRY_SETLVL = 2, + ENTRY_RTNLVL = 3, + ENTRY_LOAD = 4, + ENTRY_WARPLVL = 5, + ENTRY_TWARPDN = 6, + ENTRY_TWARPUP = 7, +} lvl_entry; + typedef enum game_info { GAMEINFO_NAME = 1, GAMEINFO_PASSWORD = 2, From 064173fef138abd455cbb6b90ae831aacbe49b3e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 1 Nov 2020 05:55:57 +0100 Subject: [PATCH 05/12] Add description for nthread_has_500ms_passed (#2141) --- Source/nthread.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 50b1ee6ef..7c68d7b41 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -222,6 +222,12 @@ void nthread_ignore_mutex(BOOL bStart) } } +/** + * @brief Checks if it's time for the logic to advance + * @param unused + * @return True if the engine should tick + + */ BOOL nthread_has_500ms_passed(BOOL unused) { DWORD currentTickCount; From f0c80d87f1784ea1d2d1cfb71089914527dc97aa Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 00:57:40 +0100 Subject: [PATCH 06/12] Reorder codec.cpp --- Source/codec.cpp | 72 ++++++++++++++++++++++++------------------------ Source/codec.h | 1 - 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Source/codec.cpp b/Source/codec.cpp index 0411fcefd..3b232c6b9 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -14,6 +14,42 @@ typedef struct CodecSignature { #define BLOCKSIZE 64 +static void codec_init_key(int unused, char *pszPassword) +{ + int i, ch, n; + char key[136]; // last 64 bytes are the SHA1 + char pw[64]; + char digest[SHA1HashSize]; + char *keyInit; + + srand(0x7058); + + keyInit = key; + for (i = 0; i < sizeof(key); i++) { + *keyInit = rand(); + keyInit++; + } + ch = 0; + for (i = 0; i < 64; i++) { + if (!pszPassword[ch]) + ch = 0; + pw[i] = pszPassword[ch]; + ch++; + } + SHA1Reset(0); + SHA1Calculate(0, pw, digest); + SHA1Clear(); + for (i = 0; i < sizeof(key); i++) + key[i] ^= digest[i % SHA1HashSize]; + memset(pw, 0, sizeof(pw)); + memset(digest, 0, sizeof(digest)); + for (n = 0; n < 3; n++) { + SHA1Reset(n); + SHA1Calculate(n, &key[72], NULL); + } + memset(key, 0, sizeof(key)); +} + int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword) { char buf[128]; @@ -58,42 +94,6 @@ error: return 0; } -void codec_init_key(int unused, char *pszPassword) -{ - int i, ch, n; - char key[136]; // last 64 bytes are the SHA1 - char pw[64]; - char digest[SHA1HashSize]; - char *keyInit; - - srand(0x7058); - - keyInit = key; - for (i = 0; i < sizeof(key); i++) { - *keyInit = rand(); - keyInit++; - } - ch = 0; - for (i = 0; i < 64; i++) { - if (!pszPassword[ch]) - ch = 0; - pw[i] = pszPassword[ch]; - ch++; - } - SHA1Reset(0); - SHA1Calculate(0, pw, digest); - SHA1Clear(); - for (i = 0; i < sizeof(key); i++) - key[i] ^= digest[i % SHA1HashSize]; - memset(pw, 0, sizeof(pw)); - memset(digest, 0, sizeof(digest)); - for (n = 0; n < 3; n++) { - SHA1Reset(n); - SHA1Calculate(n, &key[72], NULL); - } - memset(key, 0, sizeof(key)); -} - DWORD codec_get_encoded_len(DWORD dwSrcBytes) { if (dwSrcBytes % BLOCKSIZE != 0) diff --git a/Source/codec.h b/Source/codec.h index 00c11ceab..4a3175783 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -7,7 +7,6 @@ #define __CODEC_H__ 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); From 30e61ed9a0d5b5d36729168f4f6dba64533ac431 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 00:52:09 +0100 Subject: [PATCH 07/12] Reorder automap.cpp --- Source/automap.cpp | 220 ++++++++++++++++++++++----------------------- Source/automap.h | 17 ---- 2 files changed, 110 insertions(+), 127 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index bdebed289..bc1d6d52a 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -214,102 +214,10 @@ void AutomapZoomOut() } } -/** - * @brief Renders the automap on screen. - */ -void DrawAutomap() -{ - int cells; - int sx, sy; - int i, j; - int mapx, mapy; - - if (leveltype == DTYPE_TOWN) { - DrawAutomapText(); - return; - } - - gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_Y + VIEWPORT_HEIGHT)]; - - AutoMapX = (ViewX - 16) >> 1; - while (AutoMapX + AutoMapXOfs < 0) - AutoMapXOfs++; - while (AutoMapX + AutoMapXOfs >= DMAXX) - AutoMapXOfs--; - AutoMapX += AutoMapXOfs; - - AutoMapY = (ViewY - 16) >> 1; - while (AutoMapY + AutoMapYOfs < 0) - AutoMapYOfs++; - while (AutoMapY + AutoMapYOfs >= DMAXY) - AutoMapYOfs--; - AutoMapY += AutoMapYOfs; - - cells = AmShiftTab[(AutoMapScale - 50) / 5]; - if (ScrollInfo._sxoff + ScrollInfo._syoff) - cells++; - mapx = AutoMapX - cells; - mapy = AutoMapY - 1; - - if (cells & 1) { - sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * ((cells - 1) >> 1); - sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * ((cells + 1) >> 1); - } else { - sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * (cells >> 1) + AmLine32; - sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * (cells >> 1) - AmLine16; - } - if (ViewX & 1) { - sx -= AmLine16; - sy -= AmLine8; - } - if (ViewY & 1) { - sx += AmLine16; - sy -= AmLine8; - } - - sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; - sy += AutoMapScale * ScrollInfo._syoff / 100 >> 1; - if (invflag || sbookflag) { - sx -= SCREEN_WIDTH / 4; - } - if (chrflag || questlog) { - sx += SCREEN_WIDTH / 4; - } - - for (i = 0; i <= cells + 1; i++) { - int x = sx; - int y; - - for (j = 0; j < cells; j++) { - WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); - if (maptype != 0) - DrawAutomapTile(x, sy, maptype); - x += AmLine64; - } - mapy++; - x = sx - AmLine32; - y = sy + AmLine16; - for (j = 0; j <= cells; j++) { - WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); - if (maptype != 0) - DrawAutomapTile(x, y, maptype); - x += AmLine64; - } - mapx++; - sy += AmLine32; - } - DrawAutomapPlr(); -#ifdef HELLFIRE - if (AutoMapShowItems) - SearchAutomapItem(); -#endif - DrawAutomapText(); -} - /** * @brief Renders the given automap shape at the specified screen coordinates. */ -void DrawAutomapTile(int sx, int sy, WORD automap_type) +static void DrawAutomapTile(int sx, int sy, WORD automap_type) { BOOL do_vert; BOOL do_horz; @@ -493,7 +401,21 @@ void DrawAutomapTile(int sx, int sy, WORD automap_type) DrawLine(sx, sy + AmLine16, sx + AmLine32, sy, COLOR_DIM); } } + #ifdef HELLFIRE +static void DrawAutomapItem(int x, int y, BYTE color) +{ + int x1, y1, x2, y2; + + x1 = x - AmLine32 / 2; + y1 = y - AmLine16 / 2; + x2 = x1 + AmLine64 / 2; + y2 = y1 + AmLine32 / 2; + DrawLine(x, y1, x1, y, color); + DrawLine(x, y1, x2, y, color); + DrawLine(x, y2, x1, y, color); + DrawLine(x, y2, x2, y, color); +} void SearchAutomapItem() { @@ -557,26 +479,12 @@ void SearchAutomapItem() } } } - -void DrawAutomapItem(int x, int y, BYTE color) -{ - int x1, y1, x2, y2; - - x1 = x - AmLine32 / 2; - y1 = y - AmLine16 / 2; - x2 = x1 + AmLine64 / 2; - y2 = y1 + AmLine32 / 2; - DrawLine(x, y1, x1, y, color); - DrawLine(x, y1, x2, y, color); - DrawLine(x, y2, x1, y, color); - DrawLine(x, y2, x2, y, color); -} #endif /** * @brief Renders an arrow on the automap, centered on and facing the direction of the player. */ -void DrawAutomapPlr() +static void DrawAutomapPlr() { int px, py; int x, y; @@ -651,7 +559,7 @@ void DrawAutomapPlr() /** * @brief Returns the automap shape at the given coordinate. */ -WORD GetAutomapType(int x, int y, BOOL view) +static WORD GetAutomapType(int x, int y, BOOL view) { WORD rv; @@ -700,7 +608,7 @@ WORD GetAutomapType(int x, int y, BOOL view) /** * @brief Renders game info, such as the name of the current level, and in multi player the name of the game and the game password. */ -void DrawAutomapText() +static void DrawAutomapText() { char desc[256]; int nextline = 20; @@ -734,6 +642,98 @@ void DrawAutomapText() } } +/** + * @brief Renders the automap on screen. + */ +void DrawAutomap() +{ + int cells; + int sx, sy; + int i, j; + int mapx, mapy; + + if (leveltype == DTYPE_TOWN) { + DrawAutomapText(); + return; + } + + gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_Y + VIEWPORT_HEIGHT)]; + + AutoMapX = (ViewX - 16) >> 1; + while (AutoMapX + AutoMapXOfs < 0) + AutoMapXOfs++; + while (AutoMapX + AutoMapXOfs >= DMAXX) + AutoMapXOfs--; + AutoMapX += AutoMapXOfs; + + AutoMapY = (ViewY - 16) >> 1; + while (AutoMapY + AutoMapYOfs < 0) + AutoMapYOfs++; + while (AutoMapY + AutoMapYOfs >= DMAXY) + AutoMapYOfs--; + AutoMapY += AutoMapYOfs; + + cells = AmShiftTab[(AutoMapScale - 50) / 5]; + if (ScrollInfo._sxoff + ScrollInfo._syoff) + cells++; + mapx = AutoMapX - cells; + mapy = AutoMapY - 1; + + if (cells & 1) { + sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * ((cells - 1) >> 1); + sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * ((cells + 1) >> 1); + } else { + sx = SCREEN_WIDTH / 2 + SCREEN_X - AmLine64 * (cells >> 1) + AmLine32; + sy = (SCREEN_HEIGHT - PANEL_HEIGHT) / 2 + SCREEN_Y - AmLine32 * (cells >> 1) - AmLine16; + } + if (ViewX & 1) { + sx -= AmLine16; + sy -= AmLine8; + } + if (ViewY & 1) { + sx += AmLine16; + sy -= AmLine8; + } + + sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; + sy += AutoMapScale * ScrollInfo._syoff / 100 >> 1; + if (invflag || sbookflag) { + sx -= SCREEN_WIDTH / 4; + } + if (chrflag || questlog) { + sx += SCREEN_WIDTH / 4; + } + + for (i = 0; i <= cells + 1; i++) { + int x = sx; + int y; + + for (j = 0; j < cells; j++) { + WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); + if (maptype != 0) + DrawAutomapTile(x, sy, maptype); + x += AmLine64; + } + mapy++; + x = sx - AmLine32; + y = sy + AmLine16; + for (j = 0; j <= cells; j++) { + WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); + if (maptype != 0) + DrawAutomapTile(x, y, maptype); + x += AmLine64; + } + mapx++; + sy += AmLine32; + } + DrawAutomapPlr(); +#ifdef HELLFIRE + if (AutoMapShowItems) + SearchAutomapItem(); +#endif + DrawAutomapText(); +} + /** * @brief Marks the given coordinate as within view on the automap. */ diff --git a/Source/automap.h b/Source/automap.h index 8b3b64446..5fca8d903 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -6,18 +6,9 @@ #ifndef __AUTOMAP_H__ #define __AUTOMAP_H__ -extern WORD automaptype[512]; extern BOOL automapflag; -extern char AmShiftTab[32]; extern BOOLEAN automapview[DMAXX][DMAXY]; extern int AutoMapScale; -extern int AutoMapXOfs; -extern int AutoMapYOfs; -extern int AmLine64; -extern int AmLine32; -extern int AmLine16; -extern int AmLine8; -extern int AmLine4; void InitAutomapOnce(); void InitAutomap(); @@ -29,14 +20,6 @@ void AutomapRight(); void AutomapZoomIn(); void AutomapZoomOut(); void DrawAutomap(); -void DrawAutomapTile(int screen_x, int screen_y, WORD automap_type); -#ifdef HELLFIRE -void SearchAutomapItem(); -void DrawAutomapItem(int x, int y, BYTE color); -#endif -void DrawAutomapPlr(); -WORD GetAutomapType(int x, int y, BOOL view); -void DrawAutomapText(); void SetAutomapView(int x, int y); void AutomapZoomReset(); From 5a8f8eadb10efb88dc6f8f75564ea1cc1edbd068 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 00:23:25 +0100 Subject: [PATCH 08/12] Clean up appfat.cpp --- Source/appfat.cpp | 180 +++++++++++++++++++++++---------------------- Source/appfat.h | 16 +--- Source/dthread.cpp | 6 +- Source/nthread.cpp | 2 +- 4 files changed, 98 insertions(+), 106 deletions(-) diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 6b7e21276..431187476 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -21,25 +21,8 @@ void __cdecl operator delete(void *ptr) } } -void TriggerBreak() -{ -#ifdef _DEBUG - LPTOP_LEVEL_EXCEPTION_FILTER pFilter; - - pFilter = SetUnhandledExceptionFilter(BreakFilter); -#ifdef USE_ASM - __asm { - int 3 - } -#else - __debugbreak(); -#endif - SetUnhandledExceptionFilter(pFilter); -#endif -} - #ifdef _DEBUG -LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc) +static LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc) { if (pExc->ExceptionRecord == NULL) { return EXCEPTION_CONTINUE_SEARCH; @@ -56,38 +39,21 @@ LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc) } #endif -/** - * @brief Returns a formatted error message based on the given error code. - * @param error_code DirectX error code - - */ -char *GetErrorStr(DWORD error_code) +void TriggerBreak() { - int size; - char *chr; - - if (HRESULT_FACILITY(error_code) == _FACDS) { - TraceErrorDS(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])); - } else if (HRESULT_FACILITY(error_code) == _FACDD) { - TraceErrorDD(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])); - } else if (!SErrGetErrorStr(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])) - && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]), NULL)) { - wsprintf(sz_error_buf, "unknown error 0x%08x", error_code); - } - - size = strlen(sz_error_buf); - - chr = &sz_error_buf[size - 1]; - while (size-- > 0) { - chr--; - - if (*chr != '\r' && *chr != '\n') - break; +#ifdef _DEBUG + LPTOP_LEVEL_EXCEPTION_FILTER pFilter; - *chr = 0x00; + pFilter = SetUnhandledExceptionFilter(BreakFilter); +#ifdef USE_ASM + __asm { + int 3 } - - return sz_error_buf; +#else + __debugbreak(); +#endif + SetUnhandledExceptionFilter(pFilter); +#endif } /** @@ -96,7 +62,7 @@ char *GetErrorStr(DWORD error_code) * @param pszBuffer Buffer for the error message * @param dwMaxChars Length of pszBuffer */ -void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) +static void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; @@ -412,7 +378,7 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) * @param pszBuffer Buffer for the error message * @param dwMaxChars Length of pszBuffer */ -void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) +static void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; @@ -468,36 +434,44 @@ void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) } /** - * @brief Returns a formatted error message of the last error. + * @brief Returns a formatted error message based on the given error code. + * @param error_code DirectX error code */ -char *TraceLastError() +const char *GetErrorStr(DWORD error_code) { - return GetErrorStr(GetLastError()); -} + int size; + char *chr; -/** - * @brief Terminates the game and displays an error message box. - * @param pszFmt Optional error message. - * @param ... (see printf) - */ -void __cdecl app_fatal(const char *pszFmt, ...) -{ - va_list va; + if (HRESULT_FACILITY(error_code) == _FACDS) { + TraceErrorDS(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])); + } else if (HRESULT_FACILITY(error_code) == _FACDD) { + TraceErrorDD(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])); + } else if (!SErrGetErrorStr(error_code, sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0])) + && !FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), sz_error_buf, sizeof(sz_error_buf) / sizeof(sz_error_buf[0]), NULL)) { + wsprintf(sz_error_buf, "unknown error 0x%08x", error_code); + } - va_start(va, pszFmt); - FreeDlg(); -#ifdef _DEBUG - TriggerBreak(); -#endif + size = strlen(sz_error_buf); - if (pszFmt) - MsgBox(pszFmt, va); + chr = &sz_error_buf[size - 1]; + while (size-- > 0) { + chr--; - va_end(va); + if (*chr != '\r' && *chr != '\n') + break; - init_cleanup(FALSE); - exit(1); - ExitProcess(1); + *chr = 0x00; + } + + return sz_error_buf; +} + +/** + * @brief Returns a formatted error message of the last error. + */ +const char *TraceLastError() +{ + return GetErrorStr(GetLastError()); } /** @@ -505,7 +479,7 @@ void __cdecl app_fatal(const char *pszFmt, ...) * @param pszFmt Error message format * @param va Additional parameters for message format */ -void MsgBox(const char *pszFmt, va_list va) +static void MsgBox(const char *pszFmt, va_list va) { char Text[256]; @@ -518,7 +492,7 @@ void MsgBox(const char *pszFmt, va_list va) /** * @brief Cleans up after a fatal application error. */ -void FreeDlg() +static void FreeDlg() { if (terminating && cleanup_thread_id != GetCurrentThreadId()) Sleep(20000); @@ -537,6 +511,34 @@ void FreeDlg() ShowCursor(TRUE); } +/** + * @brief Terminates the game and displays an error message box. + * @param pszFmt Optional error message. + * @param ... (see printf) + */ +#ifdef HELLFIRE +__declspec(naked) +#endif +void __cdecl app_fatal(const char *pszFmt, ...) +{ + va_list va; + + va_start(va, pszFmt); + FreeDlg(); +#if defined(_DEBUG) || defined(HELLFIRE) + TriggerBreak(); +#endif + + if (pszFmt) + MsgBox(pszFmt, va); + + va_end(va); + + init_cleanup(FALSE); + exit(1); + ExitProcess(1); +} + /** * @brief Displays a warning message box based on the given formatted error message. * @param pszFmt Error message format @@ -571,7 +573,7 @@ void assert_fail(int nLineNo, const char *pszFile, const char *pszFail) */ void DDErrMsg(DWORD error_code, int log_line_nr, const char *log_file_path) { - char *msg; + const char *msg; if (error_code) { msg = GetErrorStr(error_code); @@ -584,7 +586,7 @@ void DDErrMsg(DWORD error_code, int log_line_nr, const char *log_file_path) */ void DSErrMsg(DWORD error_code, int log_line_nr, const char *log_file_path) { - char *msg; + const char *msg; if (error_code) { msg = GetErrorStr(error_code); @@ -615,6 +617,17 @@ void center_window(HWND hDlg) } } +/** + * @brief Sets the text of the given dialog. + */ +static void TextDlg(HWND hDlg, const char *text) +{ + center_window(hDlg); + + if (text) + SetDlgItemText(hDlg, 1000, text); +} + /** * @brief Callback function which processes messages sent to the given dialog box. */ @@ -659,17 +672,7 @@ void ErrDlg(int dialog_id, DWORD error_code, const char *log_file_path, int log_ app_fatal(NULL); } -/** - * @brief Sets the text of the given dialog. - */ -static void TextDlg(HWND hDlg, const char *text) -{ - center_window(hDlg); - - if (text) - SetDlgItemText(hDlg, 1000, text); -} - +#ifndef HELLFIRE /** * @brief Displays a warning dialog box based on the given dialog_id and error code. */ @@ -685,6 +688,7 @@ void ErrOkDlg(int dialog_id, DWORD error_code, const char *log_file_path, int lo wsprintf((LPSTR)dwInitParam, "%s\nat: %s line %d", GetErrorStr(error_code), log_file_path, log_line_nr); DialogBoxParam(ghInst, MAKEINTRESOURCE(dialog_id), ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam); } +#endif /** * @brief Terminates the game with a file not found error dialog. @@ -733,6 +737,7 @@ BOOL InsertCDDlg() return nResult == IDOK; } +#ifndef HELLFIRE /** * @brief Terminates the game with a read-only directory error dialog. */ @@ -745,3 +750,4 @@ void DirErrorDlg(const char *error) app_fatal(NULL); } +#endif diff --git a/Source/appfat.h b/Source/appfat.h index 2b1daa3a9..c38a33b0e 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -6,30 +6,16 @@ #ifndef __APPFAT_H__ #define __APPFAT_H__ -extern char sz_error_buf[256]; -extern BOOL terminating; -extern int cleanup_thread_id; - void TriggerBreak(); -#ifdef _DEBUG -LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc); -#endif -char *GetErrorStr(DWORD error_code); -void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars); -void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars); -char *TraceLastError(); +const char *TraceLastError(); void __cdecl app_fatal(const char *pszFmt, ...); -void MsgBox(const char *pszFmt, va_list va); -void FreeDlg(); void __cdecl DrawDlg(const char *pszFmt, ...); #ifdef _DEBUG void assert_fail(int nLineNo, const char *pszFile, const char *pszFail); #endif void DDErrMsg(DWORD error_code, int log_line_nr, const char *log_file_path); void DSErrMsg(DWORD error_code, int log_line_nr, const char *log_file_path); -void center_window(HWND hDlg); void ErrDlg(int template_id, DWORD error_code, const char *log_file_path, int log_line_nr); -void TextDlg(HWND hDlg, const char *text); void ErrOkDlg(int template_id, DWORD error_code, const char *log_file_path, int log_line_nr); void FileErrDlg(const char *error); void DiskFreeDlg(const char *error); diff --git a/Source/dthread.cpp b/Source/dthread.cpp index b525bc783..1e96a605e 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -55,7 +55,7 @@ void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen) void dthread_start() { - char *error_buf; + const char *error_buf; if (gbMaxPlayers == 1) { return; @@ -78,7 +78,7 @@ void dthread_start() unsigned int __stdcall dthread_handler(void *data) { - char *error_buf; + const char *error_buf; TMegaPkt *pkt; DWORD dwMilliseconds; @@ -116,7 +116,7 @@ unsigned int __stdcall dthread_handler(void *data) void dthread_cleanup() { - char *error_buf; + const char *error_buf; TMegaPkt *tmp; if (sghWorkToDoEvent == NULL) { diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 7c68d7b41..776629608 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -114,7 +114,7 @@ void nthread_set_turn_upper_bit() void nthread_start(BOOL set_turn_upper_bit) { - char *err, *err2; + const char *err, *err2; DWORD largestMsgSize; _SNETCAPS caps; From 086cdf6afe4c20690e11d8b98083cd2a3b5b9072 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 02:36:12 +0100 Subject: [PATCH 09/12] Re order control.cpp --- Source/control.cpp | 482 ++++++++++++++++++++++----------------------- Source/control.h | 52 ----- 2 files changed, 241 insertions(+), 293 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 74a42e1fe..dfd17db13 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1761,6 +1761,57 @@ BOOL control_WriteStringToBuffer(BYTE *str) return TRUE; } +static void CPrintString(int y, const char *str, BOOL center, int lines) +{ + BYTE c; + const char *tmp; + int strWidth, lineOffset, lineStart; + + lineOffset = 0; + lineStart = lineOffsets[lines][y] + PANEL_LEFT; + if (center == TRUE) { + strWidth = 0; + tmp = str; + while (*tmp) { + c = gbFontTransTbl[(BYTE)*tmp++]; + strWidth += fontkern[fontframe[c]] + 2; + } + if (strWidth < 288) + lineOffset = (288 - strWidth) >> 1; + lineStart += lineOffset; + } + while (*str) { + c = gbFontTransTbl[(BYTE)*str++]; + c = fontframe[c]; + lineOffset += fontkern[c] + 2; + if (c) { + if (lineOffset < 288) { + PrintChar(lineStart, c, infoclr); + } + } + lineStart += fontkern[c] + 2; + } +} + +static void PrintInfo() +{ + int yo, lo, i; + + if (!talkflag) { + yo = 0; + lo = 1; + if (infostr[0] != '\0') { + CPrintString(0, infostr, TRUE, pnumlines); + yo = 1; + lo = 0; + } + + for (i = 0; i < pnumlines; i++) { + CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); + } + } +} + /** * Sets a string to be drawn in the info box and then draws it. */ @@ -1832,54 +1883,36 @@ void DrawInfoBox() PrintInfo(); } -void PrintInfo() -{ - int yo, lo, i; - - if (!talkflag) { - yo = 0; - lo = 1; - if (infostr[0] != '\0') { - CPrintString(0, infostr, TRUE, pnumlines); - yo = 1; - lo = 0; - } - - for (i = 0; i < pnumlines; i++) { - CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); - } - } -} - -void CPrintString(int y, const char *str, BOOL center, int lines) +/** + * @brief Identical to MY_PlrStringXY(x, y, width, pszStr, col, 1) + */ +static void ADD_PlrStringXY(int x, int y, int width, const char *pszStr, char col) { BYTE c; const char *tmp; - int strWidth, lineOffset, lineStart; + int nOffset, screen_x, line, widthOffset; - lineOffset = 0; - lineStart = lineOffsets[lines][y] + PANEL_LEFT; - if (center == TRUE) { - strWidth = 0; - tmp = str; - while (*tmp) { - c = gbFontTransTbl[(BYTE)*tmp++]; - strWidth += fontkern[fontframe[c]] + 2; - } - if (strWidth < 288) - lineOffset = (288 - strWidth) >> 1; - lineStart += lineOffset; + nOffset = x + PitchTbl[y + SCREEN_Y] + SCREEN_X; + widthOffset = width - x + 1; + line = 0; + screen_x = 0; + tmp = pszStr; + while (*tmp) { + c = gbFontTransTbl[(BYTE)*tmp++]; + screen_x += fontkern[fontframe[c]] + 1; } - while (*str) { - c = gbFontTransTbl[(BYTE)*str++]; + if (screen_x < widthOffset) + line = (widthOffset - screen_x) >> 1; + nOffset += line; + while (*pszStr) { + c = gbFontTransTbl[(BYTE)*pszStr++]; c = fontframe[c]; - lineOffset += fontkern[c] + 2; + line += fontkern[c] + 1; if (c) { - if (lineOffset < 288) { - PrintChar(lineStart, c, infoclr); - } + if (line < widthOffset) + PrintChar(nOffset, c, col); } - lineStart += fontkern[c] + 2; + nOffset += fontkern[c] + 1; } } @@ -1897,6 +1930,45 @@ void PrintGameStr(int x, int y, const char *str, int color) } } +/** + * @brief Render text string to back buffer + * @param x Screen coordinate + * @param y Screen coordinate + * @param endX End of line in screen coordinate + * @param pszStr String to print, in Windows-1252 encoding + * @param col text_color color value + * @param base Letter spacing + */ +static void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col, int base) +{ + BYTE c; + const char *tmp; + int nOffset, screen_x, line, widthOffset; + + nOffset = x + PitchTbl[y + SCREEN_Y] + SCREEN_X; + widthOffset = endX - x + 1; + line = 0; + screen_x = 0; + tmp = pszStr; + while (*tmp) { + c = gbFontTransTbl[(BYTE)*tmp++]; + screen_x += fontkern[fontframe[c]] + base; + } + if (screen_x < widthOffset) + line = (widthOffset - screen_x) >> 1; + nOffset += line; + while (*pszStr) { + c = gbFontTransTbl[(BYTE)*pszStr++]; + c = fontframe[c]; + line += fontkern[c] + base; + if (c) { + if (line < widthOffset) + PrintChar(nOffset, c, col); + } + nOffset += fontkern[c] + base; + } +} + void DrawChr() { char col; @@ -2121,78 +2193,6 @@ void DrawChr() ADD_PlrStringXY(143, 332, 174, chrstr, col); } -/** - * @brief Identical to MY_PlrStringXY(x, y, width, pszStr, col, 1) - */ -void ADD_PlrStringXY(int x, int y, int width, const char *pszStr, char col) -{ - BYTE c; - const char *tmp; - int nOffset, screen_x, line, widthOffset; - - nOffset = x + PitchTbl[y + SCREEN_Y] + SCREEN_X; - widthOffset = width - x + 1; - line = 0; - screen_x = 0; - tmp = pszStr; - while (*tmp) { - c = gbFontTransTbl[(BYTE)*tmp++]; - screen_x += fontkern[fontframe[c]] + 1; - } - if (screen_x < widthOffset) - line = (widthOffset - screen_x) >> 1; - nOffset += line; - while (*pszStr) { - c = gbFontTransTbl[(BYTE)*pszStr++]; - c = fontframe[c]; - line += fontkern[c] + 1; - if (c) { - if (line < widthOffset) - PrintChar(nOffset, c, col); - } - nOffset += fontkern[c] + 1; - } -} - -/** - * @brief Render text string to back buffer - * @param x Screen coordinate - * @param y Screen coordinate - * @param endX End of line in screen coordinate - * @param pszStr String to print, in Windows-1252 encoding - * @param col text_color color value - * @param base Letter spacing - */ -void MY_PlrStringXY(int x, int y, int endX, const char *pszStr, char col, int base) -{ - BYTE c; - const char *tmp; - int nOffset, screen_x, line, widthOffset; - - nOffset = x + PitchTbl[y + SCREEN_Y] + SCREEN_X; - widthOffset = endX - x + 1; - line = 0; - screen_x = 0; - tmp = pszStr; - while (*tmp) { - c = gbFontTransTbl[(BYTE)*tmp++]; - screen_x += fontkern[fontframe[c]] + base; - } - if (screen_x < widthOffset) - line = (widthOffset - screen_x) >> 1; - nOffset += line; - while (*pszStr) { - c = gbFontTransTbl[(BYTE)*pszStr++]; - c = fontframe[c]; - line += fontkern[c] + base; - if (c) { - if (line < widthOffset) - PrintChar(nOffset, c, col); - } - nOffset += fontkern[c] + base; - } -} - void CheckLvlBtn() { if (!lvlbtndown && MouseX >= 40 + PANEL_LEFT && MouseX <= 81 + PANEL_LEFT && MouseY >= -39 + PANEL_TOP && MouseY <= -17 + PANEL_TOP) @@ -2292,26 +2292,7 @@ void ReleaseChrBtns() } } -void DrawDurIcon() -{ - PlayerStruct *p; - int x; - - if ((chrflag || questlog) && (invflag || sbookflag)) - return; - - x = PANEL_X + PANEL_WIDTH - 32 - 16; - if (invflag || sbookflag) - x -= SPANEL_WIDTH; - - p = &plr[myplr]; - x = DrawDurIcon4Item(&p->InvBody[INVLOC_HEAD], x, 4); - x = DrawDurIcon4Item(&p->InvBody[INVLOC_CHEST], x, 3); - x = DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_LEFT], x, 0); - DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_RIGHT], x, 0); -} - -int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) +static int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) { if (pItem->_itype == ITYPE_NONE) return x; @@ -2346,6 +2327,25 @@ int DrawDurIcon4Item(ItemStruct *pItem, int x, int c) return x - 32 - 8; } +void DrawDurIcon() +{ + PlayerStruct *p; + int x; + + if ((chrflag || questlog) && (invflag || sbookflag)) + return; + + x = PANEL_X + PANEL_WIDTH - 32 - 16; + if (invflag || sbookflag) + x -= SPANEL_WIDTH; + + p = &plr[myplr]; + x = DrawDurIcon4Item(&p->InvBody[INVLOC_HEAD], x, 4); + x = DrawDurIcon4Item(&p->InvBody[INVLOC_CHEST], x, 3); + x = DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_LEFT], x, 0); + DrawDurIcon4Item(&p->InvBody[INVLOC_HAND_RIGHT], x, 0); +} + void RedBack() { int idx; @@ -2422,6 +2422,37 @@ void RedBack() #endif } +static void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char col) +{ + BYTE c; + const char *tmp; + int screen_x, line, width; + + width = PitchTbl[y] + x + RIGHT_PANEL_X + SPLICONLENGTH; + line = 0; + if (cjustflag) { + screen_x = 0; + tmp = pszStr; + while (*tmp) { + c = gbFontTransTbl[(BYTE)*tmp++]; + screen_x += fontkern[fontframe[c]] + 1; + } + if (screen_x < 222) + line = (222 - screen_x) >> 1; + width += line; + } + while (*pszStr) { + c = gbFontTransTbl[(BYTE)*pszStr++]; + c = fontframe[c]; + line += fontkern[c] + 1; + if (c) { + if (line <= 222) + PrintChar(width, c, col); + } + width += fontkern[c] + 1; + } +} + char GetSBookTrans(int ii, BOOL townok) { char st; @@ -2520,37 +2551,6 @@ void DrawSpellBook() } } -void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char col) -{ - BYTE c; - const char *tmp; - int screen_x, line, width; - - width = PitchTbl[y] + x + RIGHT_PANEL_X + SPLICONLENGTH; - line = 0; - if (cjustflag) { - screen_x = 0; - tmp = pszStr; - while (*tmp) { - c = gbFontTransTbl[(BYTE)*tmp++]; - screen_x += fontkern[fontframe[c]] + 1; - } - if (screen_x < 222) - line = (222 - screen_x) >> 1; - width += line; - } - while (*pszStr) { - c = gbFontTransTbl[(BYTE)*pszStr++]; - c = fontframe[c]; - line += fontkern[c] + 1; - if (c) { - if (line <= 222) - PrintChar(width, c, col); - } - width += fontkern[c] + 1; - } -} - void CheckSBook() { int sn; @@ -2698,6 +2698,31 @@ void control_set_gold_curs(int pnum) NewCursor(plr[pnum].HoldItem._iCurs + CURSOR_FIRSTITEM); } +static char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color) +{ + BYTE c; + int width; + + x += 200 + SCREEN_X; + y += 22 + PANEL_Y; + width = x; + *nOffset = PitchTbl[y] + x; + while (*msg) { + + c = gbFontTransTbl[(BYTE)*msg]; + c = fontframe[c]; + width += fontkern[c] + 1; + if (width > 450 + PANEL_X) + return msg; + msg++; + if (c != 0) { + PrintChar(*nOffset, c, color); + } + *nOffset += fontkern[c] + 1; + } + return NULL; +} + void DrawTalkPan() { int i, off, talk_btn, color, nCel, x; @@ -2758,31 +2783,6 @@ void DrawTalkPan() } } -char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color) -{ - BYTE c; - int width; - - x += 200 + SCREEN_X; - y += 22 + PANEL_Y; - width = x; - *nOffset = PitchTbl[y] + x; - while (*msg) { - - c = gbFontTransTbl[(BYTE)*msg]; - c = fontframe[c]; - width += fontkern[c] + 1; - if (width > 450 + PANEL_X) - return msg; - msg++; - if (c != 0) { - PrintChar(*nOffset, c, color); - } - *nOffset += fontkern[c] + 1; - } - return NULL; -} - BOOL control_check_talk_btn() { int i; @@ -2870,6 +2870,46 @@ void control_reset_talk() force_redraw = 255; } +static void control_press_enter() +{ + int i; + BYTE talk_save; + + if (sgszTalkMsg[0] != 0) { +#ifdef HELLFIRE + int pmask; + pmask = 0; + + for (i = 0; i < MAX_PLRS; i++) { + if (whisper[i]) + pmask |= 1 << i; + } + NetSendCmdString(pmask, sgszTalkMsg); +#else + control_reset_talk_msg(sgszTalkMsg); +#endif + for (i = 0; i < 8; i++) { + if (!strcmp(sgszTalkSave[i], sgszTalkMsg)) + break; + } + if (i >= 8) { + strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg); + sgbNextTalkSave++; + sgbNextTalkSave &= 7; + } else { + talk_save = sgbNextTalkSave - 1; + talk_save &= 7; + if (i != talk_save) { + strcpy(sgszTalkSave[i], sgszTalkSave[talk_save]); + strcpy(sgszTalkSave[talk_save], sgszTalkMsg); + } + } + sgszTalkMsg[0] = '\0'; + sgbTalkSavePos = sgbNextTalkSave; + } + control_reset_talk(); +} + BOOL control_talk_last_key(int vkey) { int result; @@ -2891,6 +2931,19 @@ BOOL control_talk_last_key(int vkey) return TRUE; } +static void control_up_down(int v) +{ + int i; + + for (i = 0; i < 8; i++) { + sgbTalkSavePos = (v + sgbTalkSavePos) & 7; + if (sgszTalkSave[sgbTalkSavePos][0]) { + strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]); + return; + } + } +} + BOOL control_presskeys(int vkey) { int len; @@ -2923,56 +2976,3 @@ BOOL control_presskeys(int vkey) } return ret; } - -void control_press_enter() -{ - int i; - BYTE talk_save; - - if (sgszTalkMsg[0] != 0) { -#ifdef HELLFIRE - int pmask; - pmask = 0; - - for (i = 0; i < MAX_PLRS; i++) { - if (whisper[i]) - pmask |= 1 << i; - } - NetSendCmdString(pmask, sgszTalkMsg); -#else - control_reset_talk_msg(sgszTalkMsg); -#endif - for (i = 0; i < 8; i++) { - if (!strcmp(sgszTalkSave[i], sgszTalkMsg)) - break; - } - if (i >= 8) { - strcpy(sgszTalkSave[sgbNextTalkSave], sgszTalkMsg); - sgbNextTalkSave++; - sgbNextTalkSave &= 7; - } else { - talk_save = sgbNextTalkSave - 1; - talk_save &= 7; - if (i != talk_save) { - strcpy(sgszTalkSave[i], sgszTalkSave[talk_save]); - strcpy(sgszTalkSave[talk_save], sgszTalkMsg); - } - } - sgszTalkMsg[0] = '\0'; - sgbTalkSavePos = sgbNextTalkSave; - } - control_reset_talk(); -} - -void control_up_down(int v) -{ - int i; - - for (i = 0; i < 8; i++) { - sgbTalkSavePos = (v + sgbTalkSavePos) & 7; - if (sgszTalkSave[sgbTalkSavePos][0]) { - strcpy(sgszTalkMsg, sgszTalkSave[sgbTalkSavePos]); - return; - } - } -} diff --git a/Source/control.h b/Source/control.h index c313d6887..795fa6e2c 100644 --- a/Source/control.h +++ b/Source/control.h @@ -6,60 +6,33 @@ #ifndef __CONTROL_H__ #define __CONTROL_H__ -extern BYTE *pDurIcons; -extern BYTE *pChrButtons; extern BOOL drawhpflag; extern BOOL dropGoldFlag; extern BOOL panbtn[8]; extern BOOL chrbtn[4]; -extern BYTE *pMultiBtns; -extern BYTE *pPanelButtons; -extern BYTE *pChrPanel; extern BOOL lvlbtndown; extern int dropGoldValue; extern BOOL drawmanaflag; extern BOOL chrbtnactive; -extern BYTE *pPanelText; -extern int nGoldFrame; -extern BYTE *pLifeBuff; -extern BYTE *pBtmBuff; -extern BYTE *pTalkBtns; -extern int pstrjust[4]; -extern int pnumlines; extern BOOL pinfoflag; -extern BOOL talkbtndown[3]; extern int pSpell; -extern BYTE *pManaBuff; extern char infoclr; -extern BYTE *pGBoxBuff; -extern BYTE *pSBkBtnCel; extern char tempstr[256]; extern BOOLEAN whisper[MAX_PLRS]; -extern int sbooktab; extern int pSplType; extern int frame; extern int initialDropGoldIndex; extern BOOL talkflag; -extern BYTE *pSBkIconCels; extern BOOL sbookflag; extern BOOL chrflag; extern BOOL drawbtnflag; -extern BYTE *pSpellBkCel; extern char infostr[256]; -extern int numpanbtns; -extern BYTE *pStatusPanel; extern char panelstr[4][64]; extern BOOL panelflag; -extern BYTE SplTransTbl[256]; extern int initialDropGoldValue; -extern BYTE *pSpellCels; extern BOOL panbtndown; -extern BYTE *pTalkPanel; extern BOOL spselflag; -void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w); -void SetSpellTrans(char t); -void DrawSpell(); void DrawSpellList(); void SetSpell(); void SetSpeedSpell(int slot); @@ -68,9 +41,6 @@ void PrintChar(int nOffset, int nCel, char col); void AddPanelString(const char *str, BOOL just); void ClearPanel(); void DrawPanelBox(int x, int y, int w, int h, int sx, int sy); -void InitPanelStr(); -void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy); -void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h); void DrawLifeFlask(); void UpdateLifeFlask(); void DrawManaFlask(); @@ -81,7 +51,6 @@ void DrawCtrlPan(); void DrawCtrlBtns(); void DoSpeedBook(); void DoPanBtn(); -void control_set_button_down(int btn_id); void control_check_btn_press(); void DoAutoMap(); void CheckPanelInfo(); @@ -89,23 +58,16 @@ void CheckBtnUp(); void FreeControlPan(); BOOL control_WriteStringToBuffer(BYTE *str); void DrawInfoBox(); -void PrintInfo(); -void CPrintString(int y, const char *str, BOOL center, int lines); void PrintGameStr(int x, int y, const char *str, int color); void DrawChr(); -void ADD_PlrStringXY(int x, int y, int width, const char *pszStr, char col); -void MY_PlrStringXY(int x, int y, int width, const char *pszStr, char col, int base); void CheckLvlBtn(); void ReleaseLvlBtn(); void DrawLevelUpIcon(); void CheckChrBtns(); void ReleaseChrBtns(); void DrawDurIcon(); -int DrawDurIcon4Item(ItemStruct *pItem, int x, int c); void RedBack(); -char GetSBookTrans(int ii, BOOL townok); void DrawSpellBook(); -void PrintSBookStr(int x, int y, BOOL cjustflag, const char *pszStr, char col); void CheckSBook(); const char *get_pieces_str(int nGold); void DrawGoldSplit(int amount); @@ -113,30 +75,16 @@ void control_drop_gold(char vkey); void control_remove_gold(int pnum, int gold_index); void control_set_gold_curs(int pnum); void DrawTalkPan(); -char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int just); BOOL control_check_talk_btn(); void control_release_talk_btn(); -void control_reset_talk_msg(); void control_type_message(); void control_reset_talk(); BOOL control_talk_last_key(int vkey); BOOL control_presskeys(int vkey); -void control_press_enter(); -void control_up_down(int v); /* rdata */ extern const BYTE fontframe[128]; extern const BYTE fontkern[68]; -extern const int lineOffsets[5][5]; extern const BYTE gbFontTransTbl[256]; -/* data */ - -extern char SpellITbl[MAX_SPELLS]; -extern int PanBtnPos[8][5]; -extern const char *const PanBtnHotKey[8]; -extern const char *const PanBtnStr[8]; -extern RECT32 ChrBtnsRect[4]; -extern int SpellPages[6][7]; - #endif /* __CONTROL_H__ */ From 2baa93ccde05a7290cc4140fc3061647df098522 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 02:44:06 +0100 Subject: [PATCH 10/12] Clean up cursor.h --- Source/cursor.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/cursor.h b/Source/cursor.h index 826276b7d..eb6e1540f 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -23,7 +23,6 @@ extern char pcursobj; extern char pcursplr; extern int cursmx; extern int cursmy; -extern int pcurstemp; extern int pcurs; void InitCursor(); @@ -32,8 +31,6 @@ void SetICursor(int i); void SetCursor_(int i); void NewCursor(int i); void InitLevelCursor(); -void CheckTown(); -void CheckRportal(); void CheckCursMove(); /* rdata */ From 34952d2b8d098d72cb951f0e4091c2e7f0e54a5f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 02:51:50 +0100 Subject: [PATCH 11/12] Clean up dead.h --- Source/dead.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/dead.h b/Source/dead.h index f9e992a22..e8e55144e 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -6,7 +6,6 @@ #ifndef __DEAD_H__ #define __DEAD_H__ -extern int spurtndx; extern DeadStruct dead[MAXDEAD]; extern int stonendx; From 926b2ee2ae779b40106db1d9b9c80fe9ad20f0bb Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 2 Nov 2020 02:56:37 +0100 Subject: [PATCH 12/12] Cleanup debug.h --- Source/debug.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/debug.h b/Source/debug.h index 439fc9c8a..ea06f7da6 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -7,8 +7,6 @@ #define __DEBUG_H__ extern BYTE *pSquareCel; -extern char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; -extern char dFlagDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; void LoadDebugGFX(); void FreeDebugGFX(); @@ -24,11 +22,9 @@ void GiveGoldCheat(); void StoresCheat(); void TakeGoldCheat(); void MaxSpellsCheat(); -void SetSpellLevelCheat(char spl, int spllvl); void SetAllSpellsCheat(); void PrintDebugPlayer(BOOL bNextPlayer); void PrintDebugQuest(); -void PrintDebugMonster(int m); void GetDebugMonster(); void NextDebugMonster(); #endif