From 7883043adc3f0440df93d1a918d68a17502f3583 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 7 Jul 2019 13:18:39 +0200 Subject: [PATCH] Clean up files with dirty headers --- Source/codec.h | 2 +- Source/cursor.cpp | 26 +++++++++---------- Source/cursor.h | 26 +++++++++---------- Source/engine.cpp | 52 ++++---------------------------------- Source/engine.h | 10 ++++---- Source/fault.h | 2 +- Source/path.cpp | 64 ++++++++++++++++++++++++++++++----------------- Source/path.h | 4 +-- 8 files changed, 81 insertions(+), 105 deletions(-) diff --git a/Source/codec.h b/Source/codec.h index 8ad33ac38..0cae27849 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/cursor.cpp b/Source/cursor.cpp index 1e538c389..c1041dab2 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,23 +1,23 @@ #include "diablo.h" -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] = { diff --git a/Source/cursor.h b/Source/cursor.h index 10ca56a85..64a336921 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/engine.cpp b/Source/engine.cpp index 53ca7e36a..1f75eb67b 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -6,15 +6,15 @@ #endif char gbPixelCol; // automap pixel color 8-bit (palette entry) -int gbRotateMap; // BOOLEAN flip - if y < x -int orgseed; // weak +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; @@ -388,7 +388,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) { @@ -576,7 +575,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) { @@ -602,7 +600,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 @@ -646,7 +643,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 @@ -691,8 +687,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 @@ -810,7 +804,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) { @@ -924,7 +917,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 @@ -1171,8 +1163,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) { @@ -1374,8 +1364,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 @@ -1419,7 +1407,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 @@ -1461,8 +1448,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 @@ -1587,8 +1572,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) { @@ -2029,7 +2012,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) { @@ -2056,7 +2038,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) { @@ -2088,10 +2069,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: @@ -2301,9 +2278,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) { @@ -2351,9 +2325,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() { @@ -2361,8 +2332,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) { @@ -2942,7 +2911,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) { @@ -3093,7 +3061,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 @@ -3138,7 +3105,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 @@ -3334,7 +3300,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 @@ -3379,7 +3344,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) { @@ -3553,7 +3517,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 @@ -3606,7 +3569,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) { @@ -3770,8 +3732,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 @@ -3816,7 +3776,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) { @@ -3828,4 +3787,3 @@ void PlayInGameMovie(char *pszMovie) PaletteFadeIn(8); drawpanflag = 255; } -// 52571C: using guessed type int drawpanflag; diff --git a/Source/engine.h b/Source/engine.h index 333f88ed0..ba29eb01e 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); diff --git a/Source/fault.h b/Source/fault.h index ec669c7ac..beb2e61ab 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/path.cpp b/Source/path.cpp index faf7c1611..516e1ed02 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -34,7 +34,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 */ @@ -83,7 +84,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); @@ -96,7 +99,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, @@ -110,8 +114,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() { @@ -128,13 +132,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) { @@ -156,10 +162,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) { @@ -180,10 +186,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) { @@ -251,7 +257,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; @@ -260,7 +268,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; @@ -269,8 +279,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; @@ -292,7 +303,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; @@ -319,7 +332,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; @@ -327,15 +342,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 6c453d6ae..04d30e278 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);