diff --git a/.clang-format b/.clang-format index 11c49919..ea436110 100644 --- a/.clang-format +++ b/.clang-format @@ -1,11 +1,9 @@ -{ - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, - AlignConsecutiveAssignments: true, - TabWidth: 4, - UseTab: ForIndentation, - SortIncludes: false, -} +BasedOnStyle: webkit +AlignTrailingComments: true +AllowShortBlocksOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +PointerAlignment: Right +AlignConsecutiveAssignments: true +TabWidth: 4 +UseTab: ForIndentation +SortIncludes: false diff --git a/.gitignore b/.gitignore index d14076ae..97e810c1 100644 --- a/.gitignore +++ b/.gitignore @@ -373,3 +373,4 @@ ASALocalRun/ *.pubxml.user # End of https://www.gitignore.io/api/visualstudio +/docs/html/ diff --git a/.travis.yml b/.travis.yml index 9edeec26..69e1eac2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ addons: homebrew: packages: - mingw-w64 + update: true env: - MAKE_BUILD=make diff --git a/DiabloUI/_temp_funcs.h b/DiabloUI/_temp_funcs.h index a7c7a62a..17e057d2 100644 --- a/DiabloUI/_temp_funcs.h +++ b/DiabloUI/_temp_funcs.h @@ -76,7 +76,7 @@ void __cdecl Connect_cpp_init(); BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, int a5); BOOL __stdcall UiSoundCallback(int a1, int type, int a3); BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax); -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCategoryCallback(int a1, int a2, int a3, int a4, int a5, DWORD *a6, DWORD *a7); int __fastcall Connect_GetRankFromLevel(char *str); BOOL __fastcall Connect_DiffFromString(char *str, _gamedata *gamedata, int a3, int a4); @@ -84,8 +84,8 @@ void __fastcall Connect_SetDiffString(_gamedata *gamedata, const char *str1, cha BOOL __fastcall Connect_GetHeroInfoConc(const char *a1, _uiheroinfo *pInfo); void __fastcall Connect_MakeDescString(_uiheroinfo *a1, char *name, size_t size); void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str); -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc); -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type); +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc); +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type); void __fastcall Connect_CopyPlrDescStrings(char *str1, int size1, char *str2, int size2); BOOL __stdcall UiCopyProtError(int *pdwResult); @@ -283,7 +283,7 @@ void __fastcall local_SetDiabloCursor(HWND hWnd); void __cdecl j_MainMenu_cpp_init(); void __cdecl MainMenu_cpp_init(); -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut); LRESULT __stdcall MainMenu_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); void __fastcall MainMenu_KillAndFreeMenu(HWND hWnd); void __fastcall MainMenu_SetMenuTimer(HWND hWnd); diff --git a/DiabloUI/connect.cpp b/DiabloUI/connect.cpp index 1eb03e4a..58600228 100644 --- a/DiabloUI/connect.cpp +++ b/DiabloUI/connect.cpp @@ -450,7 +450,7 @@ BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPS } // ref: 0x10003710 -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8) +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8) { HDC *v8; // ebx HDC v9; // esi @@ -525,7 +525,7 @@ BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, cha GetCurrentPositionEx(v17, (LPPOINT)&a8a[7]); SetTextAlign(v8[6], 0); connect_color_text = 1; - UiDrawDescCallback(arg0, 2u, (LPCSTR)a8, a4, 0, 1u, 0, a8a); + UiDrawDescCallback(game_type, 2u, (LPCSTR)a8, a4, 0, 1u, 0, a8a); connect_color_text = 0; if (a7) { SetTextAlign(v8[6], 1u); @@ -599,7 +599,7 @@ BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, cha goto LABEL_45; } if (a5 & 8) { - v25 = (arg0 != 'BNET') - 1; + v25 = (game_type != 'BNET') - 1; v25 = v25 & 0xFD; v24 = v25 + 4; goto LABEL_46; @@ -847,7 +847,7 @@ void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str) } // ref: 0x10003FD6 -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc) +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc) { connect_charname = (char *)mode; Connect_MakeDescString(info, desc, 0x80u); @@ -855,7 +855,7 @@ BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc } // ref: 0x10003FF7 -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type) +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type) { connect_charname = (char *)type; SStrCopy(connect_plrinfostr, infostr, 128); diff --git a/DiabloUI/diabloui.cpp b/DiabloUI/diabloui.cpp index b8e2b2f7..2f663500 100644 --- a/DiabloUI/diabloui.cpp +++ b/DiabloUI/diabloui.cpp @@ -138,7 +138,7 @@ BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) } else { local_DelUiPalette(); } - return 1; + return TRUE; } // ref: 0x10005CEA diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index 923a2639..4e93c744 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -35,7 +35,7 @@ BOOL __fastcall UiValidPlayerName(char *name); /* check __stdcall */ BOOL __stdcall UiSelHeroMultDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, BOOL *hero_is_created, char *name); BOOL __stdcall UiSelHeroSingDialog(BOOL(__stdcall *fninfo)(BOOL(__stdcall *fninfofunc)(_uiheroinfo *)), BOOL(__stdcall *fncreate)(_uiheroinfo *), BOOL(__stdcall *fnremove)(_uiheroinfo *), BOOL(__stdcall *fnstats)(unsigned int, _uidefaultstats *), int *dlgresult, char *name, int *difficulty); BOOL __stdcall UiCreditsDialog(int a1); -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4); +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut); BOOL __stdcall UiProgressDialog(HWND window, char *msg, int enable, int(*fnfunc)(), int rate); const char **__stdcall UiProfileGetString(); void __cdecl UiProfileCallback(); @@ -45,13 +45,13 @@ BOOL __stdcall UiGetDataCallback(int game_type, int data_code, void *a3, int a4, BOOL __stdcall UiAuthCallback(int a1, char *a2, char *a3, char a4, char *a5, LPSTR lpBuffer, int cchBufferMax); BOOL __stdcall UiSoundCallback(int a1, int type, int a3); void __stdcall UiMessageBoxCallback(HWND hWnd, char *lpText, LPCSTR lpCaption, UINT uType); -BOOL __stdcall UiDrawDescCallback(int arg0, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); +BOOL __stdcall UiDrawDescCallback(int game_type, COLORREF color, LPCSTR lpString, char *a4, int a5, UINT align, time_t a7, HDC *a8); BOOL __stdcall UiCreateGameCallback(int a1, int a2, int a3, int a4, int a5, int a6); BOOL __stdcall UiArtCallback(int game_type, unsigned int art_code, PALETTEENTRY *pPalette, BYTE *pBuffer, DWORD dwBuffersize, DWORD *pdwWidth, DWORD *pdwHeight, DWORD *pdwBpp); int __stdcall UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *a6); int __stdcall UiSelectProvider(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, _SNETVERSIONDATA *file_info, int *type); -BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, int mode, char *desc); -void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, int type); +BOOL __stdcall UiCreatePlayerDescription(_uiheroinfo *info, DWORD mode, char *desc); +void __stdcall UiSetupPlayerInfo(char *infostr, _uiheroinfo *pInfo, DWORD type); void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str); BOOL __stdcall UiGetDefaultStats(int pclass, _uidefaultstats *pStats); BOOL __stdcall UiBetaDisclaimer(int a1); diff --git a/DiabloUI/mainmenu.cpp b/DiabloUI/mainmenu.cpp index fa3a2f45..64d32021 100644 --- a/DiabloUI/mainmenu.cpp +++ b/DiabloUI/mainmenu.cpp @@ -7,12 +7,12 @@ void __cdecl MainMenu_cpp_init() // 1002A0D4: using guessed type int mainmenu_cpp_float; // ref: 0x1000816F -BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int a4) +BOOL __stdcall UiMainMenuDialog(char *name, int *pdwResult, void(__stdcall *fnSound)(char *file), int attractTimeOut) { int v4; // eax int v5; // esi - menu_item_timer = a4; + menu_item_timer = attractTimeOut; TitleSnd_SetSoundFunction(fnSound); artfont_LoadAllFonts(); menu_version_str[0] = 0; diff --git a/Source/.clang-format b/Source/.clang-format index 7074a477..0d8567a2 100644 --- a/Source/.clang-format +++ b/Source/.clang-format @@ -1,10 +1,8 @@ -{ - BasedOnStyle: webkit, - AlignTrailingComments: true, - AllowShortBlocksOnASingleLine: true, - AllowShortFunctionsOnASingleLine: None, - PointerAlignment: Right, - TabWidth: 4, - UseTab: ForIndentation, - SortIncludes: false, -} +BasedOnStyle: webkit +AlignTrailingComments: true +AllowShortBlocksOnASingleLine: true +AllowShortFunctionsOnASingleLine: None +PointerAlignment: Right +TabWidth: 4 +UseTab: ForIndentation +SortIncludes: false diff --git a/Source/all.h b/Source/all.h new file mode 100644 index 00000000..24693dba --- /dev/null +++ b/Source/all.h @@ -0,0 +1,91 @@ +/** + * @file all.h + * + * Include all aplication headers. + */ +#ifndef __ALL_H__ +#define __ALL_H__ + +#include "../types.h" + +#ifdef __cplusplus +extern "C" { +#endif +#include "appfat.h" +#include "automap.h" +#include "capture.h" +#include "codec.h" +#include "control.h" +#include "cursor.h" +#include "dead.h" +#include "debug.h" +#include "diablo.h" +#include "doom.h" +#include "drlg_l1.h" +#include "drlg_l2.h" +#include "drlg_l3.h" +#include "drlg_l4.h" +#include "dthread.h" +#include "dx.h" +#include "effects.h" +#include "encrypt.h" +#include "engine.h" +#include "error.h" +#include "fault.h" +#include "gamemenu.h" +#include "gendung.h" +#include "gmenu.h" +#include "help.h" +#include "init.h" +#include "interfac.h" +#include "inv.h" +#include "itemdat.h" +#include "items.h" +#include "lighting.h" +#include "loadsave.h" +#include "logging.h" +#include "mainmenu.h" +#include "minitext.h" +#include "misdat.h" +#include "missiles.h" +#include "monstdat.h" +#include "monster.h" +#include "movie.h" +#include "mpqapi.h" +#include "msg.h" +#include "msgcmd.h" +#include "multi.h" +#include "nthread.h" +#include "objdat.h" +#include "objects.h" +#include "pack.h" +#include "palette.h" +#include "path.h" +#include "pfile.h" +#include "player.h" +#include "plrmsg.h" +#include "portal.h" +#include "quests.h" +#include "restrict.h" +#include "scrollrt.h" +#include "setmaps.h" +#include "sha.h" +#include "sound.h" +#include "spelldat.h" +#include "spells.h" +#include "stores.h" +#include "sync.h" +#include "textdat.h" // check file name +#include "themes.h" +#include "tmsg.h" +#include "town.h" +#include "towners.h" +#include "track.h" +#include "trigs.h" +#include "wave.h" +#include "render.h" // linked last, likely .s/.asm +#ifdef __cplusplus +} +#endif + +#endif /* __ALL_H__ */ diff --git a/Source/appfat.cpp b/Source/appfat.cpp index f2f784ed..898a6347 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -1,8 +1,15 @@ -#include "diablo.h" +/** + * @file appfat.cpp + * + * Implementation of error dialogs. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" char sz_error_buf[256]; +/** Set to true when a fatal error is encountered and the application should shut down. */ BOOL terminating; +/** Thread id of the last callee to FreeDlg(). */ int cleanup_thread_id; // delete overloads the delete operator. @@ -80,6 +87,12 @@ char *GetErrorStr(DWORD error_code) return sz_error_buf; } +/** + * @brief Generate a textual message for DirectDraw error codes + * @param hError DirectDraw error code + * @param pszBuffer Buffer for the error message + * @param dwMaxChars Length of pszBuffer + */ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; @@ -390,6 +403,12 @@ void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) strncpy(pszBuffer, szError, dwMaxChars); } +/** + * @brief Generate a textual message for DirectSound error codes + * @param hError DirectSound error code + * @param pszBuffer Buffer for the error message + * @param dwMaxChars Length of pszBuffer + */ void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars) { const char *szError; diff --git a/Source/appfat.h b/Source/appfat.h index 97c49825..ea335f09 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file appfat.h + * + * Interface of error dialogs. + */ #ifndef __APPFAT_H__ #define __APPFAT_H__ diff --git a/Source/automap.cpp b/Source/automap.cpp index 3e0861aa..59537a7f 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,26 +1,37 @@ -#include "diablo.h" +/** + * @file automap.cpp + * + * Implementation of the in-game map overlay. + */ +#include "all.h" -// BUGFIX: only the first 256 elements are ever read +/** + * Maps from tile_id to automap type. + * BUGFIX: only the first 256 elements are ever read + */ WORD automaptype[512]; -static int MapX; -static int MapY; +static int AutoMapX; +static int AutoMapY; +/** Specifies whether the automap is enabled. */ BOOL automapflag; -char AmShiftTab[32]; // [31]? +char AmShiftTab[32]; +/** Tracks the explored areas of the map. */ BOOLEAN automapview[DMAXX][DMAXY]; +/** Specifies the scale of the automap. */ int AutoMapScale; int AutoMapXOfs; int AutoMapYOfs; -int AutoMapPosBits; -int AutoMapXPos; -int AutoMapYPos; -int AMPlayerX; -int AMPlayerY; +int AmLine64; +int AmLine32; +int AmLine16; +int AmLine8; +int AmLine4; -// color used to draw the player's arrow +/** color used to draw the player's arrow */ #define COLOR_PLAYER (PAL8_ORANGE + 1) -// color for bright map lines (doors, stairs etc.) +/** color for bright map lines (doors, stairs etc.) */ #define COLOR_BRIGHT PAL8_YELLOW -// color for dim map lines/dots +/** color for dim map lines/dots */ #define COLOR_DIM (PAL16_YELLOW + 8) #ifdef HELLFIRE // color for items on automap @@ -28,25 +39,25 @@ int AMPlayerY; #endif #define MAPFLAG_TYPE 0x000F -// these are in the second byte +/** these are in the second byte */ #define MAPFLAG_VERTDOOR 0x01 #define MAPFLAG_HORZDOOR 0x02 #define MAPFLAG_VERTARCH 0x04 #define MAPFLAG_HORZARCH 0x08 #define MAPFLAG_VERTGRATE 0x10 #define MAPFLAG_HORZGRATE 0x20 -#define MAPFLAG_SQUARE 0x40 +#define MAPFLAG_DIRT 0x40 #define MAPFLAG_STAIRS 0x80 void InitAutomapOnce() { automapflag = FALSE; AutoMapScale = 50; - AutoMapPosBits = 32; - AutoMapXPos = 16; - AutoMapYPos = 8; - AMPlayerX = 4; - AMPlayerY = 2; + AmLine64 = 32; + AmLine32 = 16; + AmLine16 = 8; + AmLine8 = 4; + AmLine4 = 2; } void InitAutomap() @@ -156,11 +167,11 @@ void AutomapZoomIn() { if (AutoMapScale < 200) { AutoMapScale += 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } } @@ -168,11 +179,11 @@ void AutomapZoomOut() { if (AutoMapScale > 50) { AutoMapScale -= 5; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } } @@ -184,46 +195,46 @@ void DrawAutomap() int mapx, mapy; if (leveltype == DTYPE_TOWN) { - DrawAutomapGame(); + DrawAutomapText(); return; } gpBufEnd = &gpBuffer[(PANEL_Y)*BUFFER_WIDTH]; - MapX = (ViewX - 16) >> 1; - while (MapX + AutoMapXOfs < 0) + AutoMapX = (ViewX - 16) >> 1; + while (AutoMapX + AutoMapXOfs < 0) AutoMapXOfs++; - while (MapX + AutoMapXOfs >= DMAXX) + while (AutoMapX + AutoMapXOfs >= DMAXX) AutoMapXOfs--; - MapX += AutoMapXOfs; + AutoMapX += AutoMapXOfs; - MapY = (ViewY - 16) >> 1; - while (MapY + AutoMapYOfs < 0) + AutoMapY = (ViewY - 16) >> 1; + while (AutoMapY + AutoMapYOfs < 0) AutoMapYOfs++; - while (MapY + AutoMapYOfs >= DMAXY) + while (AutoMapY + AutoMapYOfs >= DMAXY) AutoMapYOfs--; - MapY += AutoMapYOfs; + AutoMapY += AutoMapYOfs; cells = AmShiftTab[(AutoMapScale - 50) / 5]; if (ScrollInfo._sxoff + ScrollInfo._syoff) cells++; - mapx = MapX - cells; - mapy = MapY - 1; + mapx = AutoMapX - cells; + mapy = AutoMapY - 1; if (cells & 1) { - sx = 384 - AutoMapPosBits * ((cells - 1) >> 1); - sy = 336 - AutoMapXPos * ((cells + 1) >> 1); + sx = 384 - AmLine64 * ((cells - 1) >> 1); + sy = 336 - AmLine32 * ((cells + 1) >> 1); } else { - sx = 384 - AutoMapPosBits * (cells >> 1) + AutoMapXPos; - sy = 336 - AutoMapXPos * (cells >> 1) - AutoMapYPos; + sx = 384 - AmLine64 * (cells >> 1) + AmLine32; + sy = 336 - AmLine32 * (cells >> 1) - AmLine16; } if (ViewX & 1) { - sx -= AutoMapYPos; - sy -= AMPlayerX; + sx -= AmLine16; + sy -= AmLine8; } if (ViewY & 1) { - sx += AutoMapYPos; - sy -= AMPlayerX; + sx += AmLine16; + sy -= AmLine8; } sx += AutoMapScale * ScrollInfo._sxoff / 100 >> 1; @@ -242,30 +253,30 @@ void DrawAutomap() for (j = 0; j < cells; j++) { WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); if (maptype) - DrawAutomapType(x, sy, maptype); - x += AutoMapPosBits; + DrawAutomapTile(x, sy, maptype); + x += AmLine64; } mapy++; - x = sx - AutoMapXPos; - y = sy + AutoMapYPos; + x = sx - AmLine32; + y = sy + AmLine16; for (j = 0; j <= cells; j++) { WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE); if (maptype) - DrawAutomapType(x, y, maptype); - x += AutoMapPosBits; + DrawAutomapTile(x, y, maptype); + x += AmLine64; } mapx++; - sy += AutoMapXPos; + sy += AmLine32; } DrawAutomapPlr(); #ifdef HELLFIRE if (AutoMapShowItems) SearchAutomapItem(); #endif - DrawAutomapGame(); + DrawAutomapText(); } -void DrawAutomapType(int sx, int sy, WORD automap_type) +void DrawAutomapTile(int sx, int sy, WORD automap_type) { BOOL do_vert; BOOL do_horz; @@ -275,30 +286,30 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) BYTE flags = automap_type >> 8; - if (flags & MAPFLAG_SQUARE) { + if (flags & MAPFLAG_DIRT) { ENG_set_pixel(sx, sy, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AutoMapYPos, sy, COLOR_DIM); - ENG_set_pixel(sx + AutoMapYPos, sy, COLOR_DIM); - ENG_set_pixel(sx, sy - AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX - AutoMapXPos, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX + AutoMapXPos, sy + AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx - AutoMapYPos, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx + AutoMapYPos, sy + AMPlayerX, COLOR_DIM); - ENG_set_pixel(sx - AMPlayerX, sy + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx + AMPlayerX, sy + AutoMapYPos - AMPlayerY, COLOR_DIM); - ENG_set_pixel(sx, sy + AutoMapYPos, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy - AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy - AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine16, sy, COLOR_DIM); + ENG_set_pixel(sx + AmLine16, sy, COLOR_DIM); + ENG_set_pixel(sx, sy - AmLine8, COLOR_DIM); + ENG_set_pixel(sx, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx + AmLine8 - AmLine32, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine8 + AmLine32, sy + AmLine4, COLOR_DIM); + ENG_set_pixel(sx - AmLine16, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx + AmLine16, sy + AmLine8, COLOR_DIM); + ENG_set_pixel(sx - AmLine8, sy + AmLine16 - AmLine4, COLOR_DIM); + ENG_set_pixel(sx + AmLine8, sy + AmLine16 - AmLine4, COLOR_DIM); + ENG_set_pixel(sx, sy + AmLine16, COLOR_DIM); } if (flags & MAPFLAG_STAIRS) { - DrawLine(sx - AMPlayerX, sy - AMPlayerX - AMPlayerY, sx + AMPlayerX + AutoMapYPos, sy + AMPlayerY, COLOR_BRIGHT); - DrawLine(sx - AutoMapYPos, sy - AMPlayerX, sx + AutoMapYPos, sy + AMPlayerX, COLOR_BRIGHT); - DrawLine(sx - AutoMapYPos - AMPlayerX, sy - AMPlayerY, sx + AMPlayerX, sy + AMPlayerX + AMPlayerY, COLOR_BRIGHT); - DrawLine(sx - AutoMapXPos, sy, sx, sy + AutoMapYPos, COLOR_BRIGHT); + DrawLine(sx - AmLine8, sy - AmLine8 - AmLine4, sx + AmLine8 + AmLine16, sy + AmLine4, COLOR_BRIGHT); + DrawLine(sx - AmLine16, sy - AmLine8, sx + AmLine16, sy + AmLine8, COLOR_BRIGHT); + DrawLine(sx - AmLine16 - AmLine8, sy - AmLine4, sx + AmLine8, sy + AmLine8 + AmLine4, COLOR_BRIGHT); + DrawLine(sx - AmLine32, sy, sx, sy + AmLine16, COLOR_BRIGHT); } do_vert = FALSE; @@ -307,10 +318,10 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) do_cave_vert = FALSE; switch (automap_type & MAPFLAG_TYPE) { case 1: // stand-alone column or other unpassable object - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); DrawLine(sx, sy, x1, y2, COLOR_DIM); @@ -350,27 +361,27 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) if (do_vert) { // right-facing obstacle if (flags & MAPFLAG_VERTDOOR) { // two wall segments with a door in the middle - x1 = sx - AutoMapXPos; - x2 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine32; + x2 = sx - AmLine16; + y1 = sy - AmLine16; + y2 = sy - AmLine8; - DrawLine(sx, y1, sx - AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x1, sy, x1 + AMPlayerX, sy - AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx - AmLine8, y1 + AmLine4, COLOR_DIM); + DrawLine(x1, sy, x1 + AmLine8, sy - AmLine4, COLOR_DIM); DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); DrawLine(x2, y1, sx, y2, COLOR_BRIGHT); DrawLine(x2, sy, x1, y2, COLOR_BRIGHT); DrawLine(x2, sy, sx, y2, COLOR_BRIGHT); } if (flags & MAPFLAG_VERTGRATE) { // right-facing half-wall - DrawLine(sx - AutoMapYPos, sy - AMPlayerX, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx - AmLine16, sy - AmLine8, sx - AmLine32, sy, COLOR_DIM); flags |= MAPFLAG_VERTARCH; } if (flags & MAPFLAG_VERTARCH) { // window or passable column - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); @@ -378,32 +389,32 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) DrawLine(sx, sy, x2, y2, COLOR_DIM); } if (!(flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH))) - DrawLine(sx, sy - AutoMapYPos, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy - AmLine16, sx - AmLine32, sy, COLOR_DIM); } if (do_horz) { // left-facing obstacle if (flags & MAPFLAG_HORZDOOR) { - x1 = sx + AutoMapYPos; - x2 = sx + AutoMapXPos; - y1 = sy - AutoMapYPos; - y2 = sy - AMPlayerX; + x1 = sx + AmLine16; + x2 = sx + AmLine32; + y1 = sy - AmLine16; + y2 = sy - AmLine8; - DrawLine(sx, y1, sx + AMPlayerX, y1 + AMPlayerY, COLOR_DIM); - DrawLine(x2, sy, x2 - AMPlayerX, sy - AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx + AmLine8, y1 + AmLine4, COLOR_DIM); + DrawLine(x2, sy, x2 - AmLine8, sy - AmLine4, COLOR_DIM); DrawLine(x1, y1, sx, y2, COLOR_BRIGHT); DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); DrawLine(x1, sy, sx, y2, COLOR_BRIGHT); DrawLine(x1, sy, x2, y2, COLOR_BRIGHT); } if (flags & MAPFLAG_HORZGRATE) { - DrawLine(sx + AutoMapYPos, sy - AMPlayerX, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx + AmLine16, sy - AmLine8, sx + AmLine32, sy, COLOR_DIM); flags |= MAPFLAG_HORZARCH; } if (flags & MAPFLAG_HORZARCH) { - x1 = sx - AutoMapYPos; - y1 = sy - AutoMapYPos; - x2 = x1 + AutoMapXPos; - y2 = sy - AMPlayerX; + x1 = sx - AmLine16; + y1 = sy - AmLine16; + x2 = x1 + AmLine32; + y2 = sy - AmLine8; DrawLine(sx, y1, x1, y2, COLOR_DIM); DrawLine(sx, y1, x2, y2, COLOR_DIM); @@ -411,42 +422,42 @@ void DrawAutomapType(int sx, int sy, WORD automap_type) DrawLine(sx, sy, x2, y2, COLOR_DIM); } if (!(flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH))) - DrawLine(sx, sy - AutoMapYPos, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy - AmLine16, sx + AmLine32, sy, COLOR_DIM); } // for caves the horz/vert flags are switched if (do_cave_horz) { if (flags & MAPFLAG_VERTDOOR) { - x1 = sx - AutoMapXPos; - x2 = sx - AutoMapYPos; - y1 = sy + AutoMapYPos; - y2 = sy + AMPlayerX; + x1 = sx - AmLine32; + x2 = sx - AmLine16; + y1 = sy + AmLine16; + y2 = sy + AmLine8; - DrawLine(sx, y1, sx - AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x1, sy, x1 + AMPlayerX, sy + AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx - AmLine8, y1 - AmLine4, COLOR_DIM); + DrawLine(x1, sy, x1 + AmLine8, sy + AmLine4, COLOR_DIM); DrawLine(x2, y1, x1, y2, COLOR_BRIGHT); DrawLine(x2, y1, sx, y2, COLOR_BRIGHT); DrawLine(x2, sy, x1, y2, COLOR_BRIGHT); DrawLine(x2, sy, sx, y2, COLOR_BRIGHT); } else - DrawLine(sx, sy + AutoMapYPos, sx - AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy + AmLine16, sx - AmLine32, sy, COLOR_DIM); } if (do_cave_vert) { if (flags & MAPFLAG_HORZDOOR) { - x1 = sx + AutoMapYPos; - x2 = sx + AutoMapXPos; - y1 = sy + AutoMapYPos; - y2 = sy + AMPlayerX; + x1 = sx + AmLine16; + x2 = sx + AmLine32; + y1 = sy + AmLine16; + y2 = sy + AmLine8; - DrawLine(sx, y1, sx + AMPlayerX, y1 - AMPlayerY, COLOR_DIM); - DrawLine(x2, sy, x2 - AMPlayerX, sy + AMPlayerY, COLOR_DIM); + DrawLine(sx, y1, sx + AmLine8, y1 - AmLine4, COLOR_DIM); + DrawLine(x2, sy, x2 - AmLine8, sy + AmLine4, COLOR_DIM); DrawLine(x1, y1, sx, y2, COLOR_BRIGHT); DrawLine(x1, y1, x2, y2, COLOR_BRIGHT); DrawLine(x1, sy, sx, y2, COLOR_BRIGHT); DrawLine(x1, sy, x2, y2, COLOR_BRIGHT); } else - DrawLine(sx, sy + AutoMapYPos, sx + AutoMapXPos, sy, COLOR_DIM); + DrawLine(sx, sy + AmLine16, sx + AmLine32, sy, COLOR_DIM); } } #ifdef HELLFIRE @@ -500,14 +511,14 @@ void SearchAutomapItem() px = i - 2 * AutoMapXOfs - ViewX; py = j - 2 * AutoMapYOfs - ViewY; - x = (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AutoMapYPos + 384; - y = (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AMPlayerX + 336; + x = (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + 384; + y = (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + 336; if (invflag || sbookflag) x -= 160; if (chrflag || questlog) x += 160; - y -= AMPlayerX; + y -= AmLine8; DrawAutomapItem(x, y, COLOR_ITEM); } } @@ -518,10 +529,10 @@ void DrawAutomapItem(int x, int y, BYTE color) { int x1, y1, x2, y2; - x1 = x - AutoMapXPos / 2; - y1 = y - AutoMapYPos / 2; - x2 = AutoMapPosBits / 2 + x1; - y2 = y1 + AutoMapXPos / 2; + x1 = x - AmLine32 / 2; + y1 = y - AmLine16 / 2; + x2 = AmLine64 / 2 + x1; + y2 = y1 + AmLine32 / 2; DrawLine(x, y1, x1, y, color); DrawLine(x, y1, x2, y, color); DrawLine(x, y2, x1, y, color); @@ -548,55 +559,55 @@ void DrawAutomapPlr() px = x - 2 * AutoMapXOfs - ViewX; py = y - 2 * AutoMapYOfs - ViewY; - x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AutoMapYPos + 384; - y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AMPlayerX + 336; + x = (plr[myplr]._pxoff * AutoMapScale / 100 >> 1) + (ScrollInfo._sxoff * AutoMapScale / 100 >> 1) + (px - py) * AmLine16 + 384; + y = (plr[myplr]._pyoff * AutoMapScale / 100 >> 1) + (ScrollInfo._syoff * AutoMapScale / 100 >> 1) + (px + py) * AmLine8 + 336; if (invflag || sbookflag) x -= 160; if (chrflag || questlog) x += 160; - y -= AMPlayerX; + y -= AmLine8; switch (plr[myplr]._pdir) { case DIR_N: - DrawLine(x, y, x, y - AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x - AMPlayerY, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x, y - AutoMapYPos, x + AMPlayerY, y - AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x, y - AmLine16, COLOR_PLAYER); + DrawLine(x, y - AmLine16, x - AmLine4, y - AmLine8, COLOR_PLAYER); + DrawLine(x, y - AmLine16, x + AmLine4, y - AmLine8, COLOR_PLAYER); break; case DIR_NE: - DrawLine(x, y, x + AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y - AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y - AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y - AmLine8, x + AmLine8, y - AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y - AmLine8, x + AmLine8 + AmLine4, y, COLOR_PLAYER); break; case DIR_E: - DrawLine(x, y, x + AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y, x + AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y, COLOR_PLAYER); + DrawLine(x + AmLine16, y, x + AmLine8, y - AmLine4, COLOR_PLAYER); + DrawLine(x + AmLine16, y, x + AmLine8, y + AmLine4, COLOR_PLAYER); break; case DIR_SE: - DrawLine(x, y, x + AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX + AMPlayerY, y, COLOR_PLAYER); - DrawLine(x + AutoMapYPos, y + AMPlayerX, x + AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x + AmLine16, y + AmLine8, COLOR_PLAYER); + DrawLine(x + AmLine16, y + AmLine8, x + AmLine8 + AmLine4, y, COLOR_PLAYER); + DrawLine(x + AmLine16, y + AmLine8, x + AmLine8, y + AmLine8, COLOR_PLAYER); break; case DIR_S: - DrawLine(x, y, x, y + AutoMapYPos, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x + AMPlayerY, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x, y + AutoMapYPos, x - AMPlayerY, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x, y + AmLine16, COLOR_PLAYER); + DrawLine(x, y + AmLine16, x + AmLine4, y + AmLine8, COLOR_PLAYER); + DrawLine(x, y + AmLine16, x - AmLine4, y + AmLine8, COLOR_PLAYER); break; case DIR_SW: - DrawLine(x, y, x - AutoMapYPos, y + AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y + AMPlayerX, x - AMPlayerX, y + AMPlayerX, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y + AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y + AmLine8, x - AmLine4 - AmLine8, y, COLOR_PLAYER); + DrawLine(x - AmLine16, y + AmLine8, x - AmLine8, y + AmLine8, COLOR_PLAYER); break; case DIR_W: - DrawLine(x, y, x - AutoMapYPos, y, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y - AMPlayerY, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y, x - AMPlayerX, y + AMPlayerY, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y, COLOR_PLAYER); + DrawLine(x - AmLine16, y, x - AmLine8, y - AmLine4, COLOR_PLAYER); + DrawLine(x - AmLine16, y, x - AmLine8, y + AmLine4, COLOR_PLAYER); break; case DIR_NW: - DrawLine(x, y, x - AutoMapYPos, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerX, y - AMPlayerX, COLOR_PLAYER); - DrawLine(x - AutoMapYPos, y - AMPlayerX, x - AMPlayerY - AMPlayerX, y, COLOR_PLAYER); + DrawLine(x, y, x - AmLine16, y - AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y - AmLine8, x - AmLine8, y - AmLine8, COLOR_PLAYER); + DrawLine(x - AmLine16, y - AmLine8, x - AmLine4 - AmLine8, y, COLOR_PLAYER); break; } } @@ -606,18 +617,18 @@ WORD GetAutomapType(int x, int y, BOOL view) WORD rv; if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) { - if (GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8)) { + if (GetAutomapType(0, y, FALSE) & (MAPFLAG_DIRT << 8)) { return 0; } else { - return MAPFLAG_SQUARE << 8; + return MAPFLAG_DIRT << 8; } } if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) { - if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8)) { + if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_DIRT << 8)) { return 0; } else { - return MAPFLAG_SQUARE << 8; + return MAPFLAG_DIRT << 8; } } @@ -647,7 +658,7 @@ WORD GetAutomapType(int x, int y, BOOL view) return rv; } -void DrawAutomapGame() +void DrawAutomapText() { char desc[256]; int nextline = 20; @@ -757,9 +768,9 @@ void AutomapZoomReset() { AutoMapXOfs = 0; AutoMapYOfs = 0; - AutoMapPosBits = (AutoMapScale << 6) / 100; - AutoMapXPos = AutoMapPosBits >> 1; - AutoMapYPos = AutoMapXPos >> 1; - AMPlayerX = AutoMapYPos >> 1; - AMPlayerY = AMPlayerX >> 1; + AmLine64 = (AutoMapScale << 6) / 100; + AmLine32 = AmLine64 >> 1; + AmLine16 = AmLine32 >> 1; + AmLine8 = AmLine16 >> 1; + AmLine4 = AmLine8 >> 1; } diff --git a/Source/automap.h b/Source/automap.h index 3583836c..8b3b6444 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file automap.h + * + * Interface of the in-game map overlay. + */ #ifndef __AUTOMAP_H__ #define __AUTOMAP_H__ @@ -9,11 +13,11 @@ extern BOOLEAN automapview[DMAXX][DMAXY]; extern int AutoMapScale; extern int AutoMapXOfs; extern int AutoMapYOfs; -extern int AutoMapPosBits; -extern int AutoMapXPos; -extern int AutoMapYPos; -extern int AMPlayerX; -extern int AMPlayerY; +extern int AmLine64; +extern int AmLine32; +extern int AmLine16; +extern int AmLine8; +extern int AmLine4; void InitAutomapOnce(); void InitAutomap(); @@ -25,14 +29,14 @@ void AutomapRight(); void AutomapZoomIn(); void AutomapZoomOut(); void DrawAutomap(); -void DrawAutomapType(int screen_x, int screen_y, WORD automap_type); +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 DrawAutomapGame(); +void DrawAutomapText(); void SetAutomapView(int x, int y); void AutomapZoomReset(); diff --git a/Source/capture.cpp b/Source/capture.cpp index b0583f53..552b43e2 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -1,5 +1,17 @@ -#include "diablo.h" +/** + * @file capture.cpp + * + * Implementation of the screenshot function. + */ +#include "all.h" +/** + * @brief Write the PCX-file header + * @param hFile File handler for the PCX file. + * @param width Image width + * @param height Image height + * @return True on success + */ static BOOL CaptureHdr(HANDLE hFile, short width, short height) { DWORD lpNumBytes; diff --git a/Source/capture.h b/Source/capture.h index c1e86c10..9a54e2d1 100644 --- a/Source/capture.h +++ b/Source/capture.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file capture.h + * + * Interface of the screenshot function. + */ #ifndef __CAPTURE_H__ #define __CAPTURE_H__ diff --git a/Source/codec.cpp b/Source/codec.cpp index 157c2314..04f81d0f 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -1,11 +1,16 @@ -#include "diablo.h" +/** + * @file codec.cpp + * + * Implementation of save game encryption algorithm. + */ +#include "all.h" -struct CodecSignature { +typedef struct CodecSignature { DWORD checksum; BYTE error; BYTE last_chunk_size; WORD unused; -}; +} CodecSignature; int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword) { diff --git a/Source/codec.h b/Source/codec.h index 0cae2784..00c11cea 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file codec.h + * + * Interface of save game encryption algorithm. + */ #ifndef __CODEC_H__ #define __CODEC_H__ diff --git a/Source/control.cpp b/Source/control.cpp index c87e9e39..ca90b88f 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file control.cpp + * + * Implementation of the character and main control panels + */ +#include "all.h" BYTE sgbNextTalkSave; BYTE sgbTalkSavePos; @@ -18,7 +23,8 @@ BOOL drawmanaflag; BOOL chrbtnactive; char sgszTalkMsg[MAX_SEND_STR_LEN]; BYTE *pPanelText; -int nGoldFrame; /** current frame # for the pentagram caret in gold input */ +/** current frame # for the pentagram caret in gold input */ +int nGoldFrame; BYTE *pLifeBuff; BYTE *pBtmBuff; BYTE *pTalkBtns; @@ -36,7 +42,8 @@ char tempstr[256]; BOOLEAN whisper[MAX_PLRS]; int sbooktab; int pSplType; -int frame; /** current frame # for the pentagram caret in chat input */ +/** current frame # for the pentagram caret in chat input */ +int frame; int initialDropGoldIndex; BOOL talkflag; BYTE *pSBkIconCels; @@ -44,7 +51,7 @@ BOOL sbookflag; BOOL chrflag; BOOL drawbtnflag; BYTE *pSpellBkCel; -char infostr[MAX_PATH]; +char infostr[256]; int numpanbtns; BYTE *pStatusPanel; char panelstr[4][64]; @@ -54,8 +61,9 @@ int initialDropGoldValue; BYTE *pSpellCels; BOOL panbtndown; BYTE *pTalkPanel; -int spselflag; +BOOL spselflag; +/** Maps from font index to smaltext.cel frame number. */ const BYTE fontframe[128] = { 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, @@ -66,6 +74,12 @@ const BYTE fontframe[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 40, 66, 41, 67, 0 }; + +/** + * Maps from smaltext.cel frame number to character width. Note, the + * character width may be distinct from the frame width, which is 13 for every + * smaltext.cel frame. + */ const BYTE fontkern[68] = { 8, 10, 7, 9, 8, 7, 6, 8, 8, 3, 3, 8, 6, 11, 9, 10, 6, 9, 9, 6, @@ -76,36 +90,36 @@ const BYTE fontkern[68] = { 4, 4, 9, 6, 6, 12, 3, 7 }; /** - * Line height for info box when displaying 1, 2, 3, 4 and 5 lines respectivly + * Line start position for info box text when displaying 1, 2, 3, 4 and 5 lines respectivly */ const int lineOffsets[5][5] = { { SCREENXY(177, 434), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32 + 180, + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(116, -128), }, { SCREENXY(177, 422), SCREENXY(177, 446), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), + SCREENXY(-64, -128), + SCREENXY(-64, -128), }, { SCREENXY(177, 416), SCREENXY(177, 434), SCREENXY(177, 452), - BUFFER_WIDTH * 32, - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), + SCREENXY(-64, -128), }, { SCREENXY(177, 412), SCREENXY(177, 427), SCREENXY(177, 441), SCREENXY(177, 456), - BUFFER_WIDTH * 32, + SCREENXY(-64, -128), }, { SCREENXY(177, 410), @@ -115,6 +129,12 @@ const int lineOffsets[5][5] = { SCREENXY(177, 457), } }; + +/** + * Maps ASCII character code to font index, as used by the + * small, medium and large sized fonts; which corresponds to smaltext.cel, + * medtexts.cel and bigtgold.cel respectively. + */ const BYTE gbFontTransTbl[256] = { // clang-format off '\0', 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, @@ -138,6 +158,7 @@ const BYTE gbFontTransTbl[256] = { /* data */ +/** Maps from spell_id to spelicon.cel frame number. */ char SpellITbl[MAX_SPELLS] = { #ifdef HELLFIRE 27, @@ -198,7 +219,9 @@ char SpellITbl[MAX_SPELLS] = { 35, #endif }; +/** Maps from panel_button_id to the position and dimensions of a panel button. */ int PanBtnPos[8][5] = { + // clang-format off { PANEL_LEFT + 9, PANEL_TOP + 9, 71, 19, 1 }, // char button { PANEL_LEFT + 9, PANEL_TOP + 35, 71, 19, 0 }, // quests button { PANEL_LEFT + 9, PANEL_TOP + 75, 71, 19, 1 }, // map button @@ -207,8 +230,11 @@ int PanBtnPos[8][5] = { { PANEL_LEFT + 560, PANEL_TOP + 35, 71, 19, 0 }, // spells button { PANEL_LEFT + 87, PANEL_TOP + 91, 33, 32, 1 }, // chat button { PANEL_LEFT + 527, PANEL_TOP + 91, 33, 32, 1 }, // friendly fire button + // clang-format on }; +/** Maps from panel_button_id to hotkey name. */ char *PanBtnHotKey[8] = { "'c'", "'q'", "Tab", "Esc", "'i'", "'b'", "Enter", NULL }; +/** Maps from panel_button_id to panel button description. */ char *PanBtnStr[8] = { "Character Information", "Quests log", @@ -219,6 +245,7 @@ char *PanBtnStr[8] = { "Send Message", "Player Attack" }; +/** Maps from attribute_id to the rectangle on screen used for attribute increment buttons. */ RECT32 ChrBtnsRect[4] = { { 137, 138, 41, 22 }, { 137, 166, 41, 22 }, @@ -226,6 +253,7 @@ RECT32 ChrBtnsRect[4] = { { 137, 223, 41, 22 } }; +/** Maps from spellbook page number and position to spell_id. */ int SpellPages[6][7] = { { SPL_NULL, SPL_FIREBOLT, SPL_CBOLT, SPL_HBOLT, SPL_HEAL, SPL_HEALOTHER, SPL_FLAME }, { SPL_RESURRECT, SPL_FIREWALL, SPL_TELEKINESIS, SPL_LIGHTNING, SPL_TOWN, SPL_FLASH, SPL_STONE }, @@ -241,8 +269,8 @@ int SpellPages[6][7] = { /** * Draw spell cell onto the back buffer. - * @param xp Backbuffer coordinate - * @param yp Backbuffer coordinate + * @param xp Back buffer coordinate + * @param yp Back buffer coordinate * @param Trans Pointer to the cel buffer. * @param nCel Index of the cel frame to draw. 0 based. * @param w Width of the frame. @@ -601,8 +629,8 @@ void DrawSpellList() void SetSpell() { - spselflag = 0; - if (pSpell != -1) { + spselflag = FALSE; + if (pSpell != SPL_INVALID) { ClearPanel(); plr[myplr]._pRSpell = pSpell; plr[myplr]._pRSplType = pSplType; @@ -655,12 +683,12 @@ void ToggleSpell(int slot) } /** - * @brief Print letter to the backbuffer - * @param nOffset Backbuffer offset + * @brief Print letter to the back buffer + * @param nOffset Back buffer offset * @param nCel Number of letter in Windows-1252 * @param col text_color color value */ -void CPrintString(int nOffset, int nCel, char col) +void PrintChar(int nOffset, int nCel, char col) { /// ASSERT: assert(gpBuffer); @@ -1047,8 +1075,8 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) * @param pCelBuff Buffer of the empty flask cel. * @param min Top of the flask cel section to draw. * @param max Bottom of the flask cel section to draw. - * @param sx X Backbuffer coordinate - * @param sy Y Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int sx, int sy) { @@ -1337,7 +1365,7 @@ void InitControlPan() drawhpflag = TRUE; drawmanaflag = TRUE; chrflag = FALSE; - spselflag = 0; + spselflag = FALSE; pSpellBkCel = LoadFileInMem("Data\\SpellBk.CEL", NULL); pSBkBtnCel = LoadFileInMem("Data\\SpellBkB.CEL", NULL); pSBkIconCels = LoadFileInMem("Data\\SpellI2.CEL", NULL); @@ -1369,7 +1397,7 @@ void InitControlPan() nGoldFrame = 1; } -void ClearCtrlPan() +void DrawCtrlPan() { DrawPanelBox(0, sgbPlrTalkTbl + 16, PANEL_WIDTH, PANEL_HEIGHT, PANEL_X, PANEL_Y); DrawInfoBox(); @@ -1379,7 +1407,7 @@ void ClearCtrlPan() * Draws the control panel buttons in their current state. If the button is in the default * state draw it from the panel cel(extract its sub-rect). Else draw it from the buttons cel. */ -void DrawCtrlPan() +void DrawCtrlBtns() { int i; @@ -1407,7 +1435,7 @@ void DoSpeedBook() unsigned __int64 spells, spell; int xo, yo, X, Y, i, j; - spselflag = 1; + spselflag = TRUE; xo = PANEL_X + 12 + 56 * 10; yo = PANEL_Y - 17; X = PANEL_LEFT + 12 + 56 * 10 + 56 / 2; @@ -1518,15 +1546,14 @@ void DoAutoMap() */ void CheckPanelInfo() { - int i, c, v, s; + int i, c, v, s, xend, yend; panelflag = FALSE; ClearPanel(); for (i = 0; i < numpanbtns; i++) { - if (MouseX >= PanBtnPos[i][0] - && MouseX <= PanBtnPos[i][0] + PanBtnPos[i][2] - && MouseY >= PanBtnPos[i][1] - && MouseY <= PanBtnPos[i][1] + PanBtnPos[i][3]) { + xend = PanBtnPos[i][0] + PanBtnPos[i][2]; + yend = PanBtnPos[i][1] + PanBtnPos[i][3]; + if (MouseX >= PanBtnPos[i][0] && MouseX <= xend && MouseY >= PanBtnPos[i][1] && MouseY <= yend) { if (i != 7) { strcpy(infostr, PanBtnStr[i]); } else { @@ -1575,14 +1602,14 @@ void CheckPanelInfo() AddPanelString(tempstr, TRUE); s = 0; for (i = 0; i < plr[myplr]._pNumInv; i++) { - if (plr[myplr].InvList[i]._itype != -1 + if (plr[myplr].InvList[i]._itype != ITYPE_NONE && (plr[myplr].InvList[i]._iMiscId == IMISC_SCROLL || plr[myplr].InvList[i]._iMiscId == IMISC_SCROLLT) && plr[myplr].InvList[i]._iSpell == v) { s++; } } for (i = 0; i < MAXBELTITEMS; i++) { - if (plr[myplr].SpdList[i]._itype != -1 + if (plr[myplr].SpdList[i]._itype != ITYPE_NONE && (plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLL || plr[myplr].SpdList[i]._iMiscId == IMISC_SCROLLT) && plr[myplr].SpdList[i]._iSpell == v) { s++; @@ -1794,10 +1821,10 @@ void DrawInfoBox() } } if (infostr[0] || pnumlines) - control_draw_info_str(); + PrintInfo(); } -void control_draw_info_str() +void PrintInfo() { int yo, lo, i; @@ -1805,18 +1832,18 @@ void control_draw_info_str() yo = 0; lo = 1; if (infostr[0]) { - control_print_info_str(0, infostr, TRUE, pnumlines); + CPrintString(0, infostr, TRUE, pnumlines); yo = 1; lo = 0; } for (i = 0; i < pnumlines; i++) { - control_print_info_str(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); + CPrintString(i + yo, panelstr[i], pstrjust[i], pnumlines - lo); } } } -void control_print_info_str(int y, char *str, BOOL center, int lines) +void CPrintString(int y, char *str, BOOL center, int lines) { BYTE c; char *tmp; @@ -1841,7 +1868,7 @@ void control_print_info_str(int y, char *str, BOOL center, int lines) lineOffset += fontkern[c] + 2; if (c) { if (lineOffset < 288) { - CPrintString(lineStart, c, infoclr); + PrintChar(lineStart, c, infoclr); } } lineStart += fontkern[c] + 2; @@ -1857,7 +1884,7 @@ void PrintGameStr(int x, int y, char *str, int color) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - CPrintString(off, c, color); + PrintChar(off, c, color); off += fontkern[c] + 1; } } @@ -2094,7 +2121,7 @@ void ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col) line += fontkern[c] + 1; if (c) { if (line < widthOffset) - CPrintString(nOffset, c, col); + PrintChar(nOffset, c, col); } nOffset += fontkern[c] + 1; } @@ -2133,7 +2160,7 @@ void MY_PlrStringXY(int x, int y, int endX, char *pszStr, char col, int base) line += fontkern[c] + base; if (c) { if (line < widthOffset) - CPrintString(nOffset, c, col); + PrintChar(nOffset, c, col); } nOffset += fontkern[c] + base; } @@ -2491,7 +2518,7 @@ void PrintSBookStr(int x, int y, BOOL cjustflag, char *pszStr, char col) line += fontkern[c] + 1; if (c) { if (line <= 222) - CPrintString(width, c, col); + PrintChar(width, c, col); } width += fontkern[c] + 1; } @@ -2605,15 +2632,15 @@ void control_remove_gold(int pnum, int gold_index) { int gi; - if (gold_index <= 46) { - gi = gold_index - 7; + if (gold_index <= INVITEM_INV_LAST) { + gi = gold_index - INVITEM_INV_FIRST; plr[pnum].InvList[gi]._ivalue -= dropGoldValue; if (plr[pnum].InvList[gi]._ivalue > 0) SetGoldCurs(pnum, gi); else RemoveInvItem(pnum, gi); } else { - gi = gold_index - 47; + gi = gold_index - INVITEM_BELT_FIRST; plr[pnum].SpdList[gi]._ivalue -= dropGoldValue; if (plr[pnum].SpdList[gi]._ivalue > 0) SetSpdbarGoldCurs(pnum, gi); @@ -2623,7 +2650,7 @@ void control_remove_gold(int pnum, int gold_index) SetPlrHandItem(&plr[pnum].HoldItem, IDI_GOLD); GetGoldSeed(pnum, &plr[pnum].HoldItem); plr[pnum].HoldItem._ivalue = dropGoldValue; - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; control_set_gold_curs(pnum); plr[pnum]._pGold = CalculateGold(pnum); dropGoldValue = 0; @@ -2717,7 +2744,7 @@ char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color) return msg; msg++; if (c) { - CPrintString(*nOffset, c, color); + PrintChar(*nOffset, c, color); } *nOffset += fontkern[c] + 1; } diff --git a/Source/control.h b/Source/control.h index b4ef27a1..7acced9b 100644 --- a/Source/control.h +++ b/Source/control.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file control.h + * + * Interface of the character and main control panels + */ #ifndef __CONTROL_H__ #define __CONTROL_H__ @@ -41,7 +45,7 @@ extern BOOL sbookflag; extern BOOL chrflag; extern BOOL drawbtnflag; extern BYTE *pSpellBkCel; -extern char infostr[MAX_PATH]; +extern char infostr[256]; extern int numpanbtns; extern BYTE *pStatusPanel; extern char panelstr[4][64]; @@ -51,7 +55,7 @@ extern int initialDropGoldValue; extern BYTE *pSpellCels; extern BOOL panbtndown; extern BYTE *pTalkPanel; -extern int spselflag; +extern BOOL spselflag; void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w); void SetSpellTrans(char t); @@ -60,7 +64,7 @@ void DrawSpellList(); void SetSpell(); void SetSpeedSpell(int slot); void ToggleSpell(int slot); -void CPrintString(int nOffset, int nCel, char col); +void PrintChar(int nOffset, int nCel, char col); void AddPanelString(char *str, BOOL just); void ClearPanel(); void DrawPanelBox(int x, int y, int w, int h, int sx, int sy); @@ -73,8 +77,8 @@ void DrawManaFlask(); void control_update_life_mana(); void UpdateManaFlask(); void InitControlPan(); -void ClearCtrlPan(); void DrawCtrlPan(); +void DrawCtrlBtns(); void DoSpeedBook(); void DoPanBtn(); void control_set_button_down(int btn_id); @@ -85,8 +89,8 @@ void CheckBtnUp(); void FreeControlPan(); BOOL control_WriteStringToBuffer(BYTE *str); void DrawInfoBox(); -void control_draw_info_str(); -void control_print_info_str(int y, char *str, BOOL center, int lines); +void PrintInfo(); +void CPrintString(int y, char *str, BOOL center, int lines); void PrintGameStr(int x, int y, char *str, int color); void DrawChr(); void ADD_PlrStringXY(int x, int y, int width, char *pszStr, char col); diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 4c652a1c..88d346ef 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file cursor.cpp + * + * Implementation of cursor tracking functionality. + */ +#include "all.h" int cursW; int cursH; @@ -10,7 +15,7 @@ BYTE *pCursCels; BYTE *pCursCels2; #endif -// inv_item value +/** inv_item value */ char pcursinvitem; int icursW; int icursH; @@ -23,6 +28,7 @@ int pcurstemp; int pcurs; /* rdata */ +/** Maps from objcurs.cel frame number to frame width. */ const int InvItemWidth[] = { // Cursors 0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23, @@ -54,6 +60,7 @@ const int InvItemWidth[] = { #endif }; +/** Maps from objcurs.cel frame number to frame height. */ const int InvItemHeight[] = { // Cursors 0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35, @@ -231,7 +238,7 @@ void CheckCursMove() fx -= (plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8; fy -= (plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8; - if (ScrollInfo._sdir != 0) { + if (ScrollInfo._sdir != SDIR_NONE) { sx -= fx; sy -= fy; } diff --git a/Source/cursor.h b/Source/cursor.h index de634227..826276b7 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file cursor.h + * + * Interface of cursor tracking functionality. + */ #ifndef __CURSOR_H__ #define __CURSOR_H__ diff --git a/Source/dead.cpp b/Source/dead.cpp index eb4f8727..ba72cd0a 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -1,6 +1,11 @@ -#include "diablo.h" +/** + * @file dead.cpp + * + * Implementation of functions for placing dead monsters. + */ +#include "all.h" -// unused, this was probably for blood boil/burn +/** unused, this was probably for blood boil/burn */ int spurtndx; DeadStruct dead[MAXDEAD]; int stonendx; diff --git a/Source/dead.h b/Source/dead.h index bc16374d..f9e992a2 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dead.h + * + * Interface of functions for placing dead monsters. + */ #ifndef __DEAD_H__ #define __DEAD_H__ diff --git a/Source/debug.cpp b/Source/debug.cpp index 4cedf1bc..a53fd20f 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file debug.cpp + * + * Implementation of debug functions. + */ +#include "all.h" #ifdef _DEBUG BOOL update_seed_check = FALSE; @@ -118,12 +123,12 @@ void StoresCheat() numpremium = 0; for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) - premiumitem[i]._itype = -1; + premiumitem[i]._itype = ITYPE_NONE; SpawnPremium(30); for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; + witchitem[i]._itype = ITYPE_NONE; SpawnWitch(30); #endif @@ -142,7 +147,7 @@ void TakeGoldCheat() for (i = 0; i < MAXBELTITEMS; i++) { if (plr[myplr].SpdList[i]._itype == ITYPE_GOLD) - plr[myplr].SpdList[i]._itype = -1; + plr[myplr].SpdList[i]._itype = ITYPE_NONE; } plr[myplr]._pGold = 0; @@ -243,11 +248,11 @@ void PrintDebugMonster(int m) sprintf(dstr, "Mode = %i, Var1 = %i", monster[m]._mmode, monster[m]._mVar1); NetSendCmdString(1 << myplr, dstr); - bActive = 0; + bActive = FALSE; for (i = 0; i < nummonsters; i++) { if (monstactive[i] == m) - bActive = 1; + bActive = TRUE; } sprintf(dstr, "Active List = %i, Squelch = %i", bActive, monster[m]._msquelch); diff --git a/Source/debug.h b/Source/debug.h index d3dacf70..439fc9c8 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file debug.h + * + * Interface of debug functions. + */ #ifndef __DEBUG_H__ #define __DEBUG_H__ diff --git a/Source/diablo.cpp b/Source/diablo.cpp index f4630442..805128fd 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file diablo.cpp + * + * Implementation of the main game initialization functions. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -22,11 +27,13 @@ int DebugMonsters[10]; BOOLEAN cineflag; int force_redraw; BOOL visiondebug; -BOOL scrollflag; /* unused */ +/** unused */ +BOOL scrollflag; BOOL light4flag; BOOL leveldebug; BOOL monstdebug; -BOOL trigdebug; /* unused */ +/** unused */ +BOOL trigdebug; int setseed; int debugmonsttypes; int PauseMode; @@ -44,6 +51,10 @@ int color_cycle_timer; /* rdata */ +/** + * Specifies whether to give the game exclusive access to the + * screen, as needed for efficient rendering in fullscreen mode. + */ BOOL fullscreen = TRUE; #ifdef _DEBUG int showintrodebug = 1; @@ -63,13 +74,16 @@ int frameend; int framerate; int framestart; #endif +/** Specifies whether players are in non-PvP mode. */ BOOL FriendlyMode = TRUE; +/** Default quick messages */ char *spszMsgTbl[4] = { "I need help! Come Here!", "Follow me.", "Here's something for you.", "Now you DIE!" }; +/** INI files variable names for quick message keys */ char *spszMsgHotKeyTbl[4] = { "F9", "F10", "F11", "F12" }; void FreeGameMem() @@ -85,7 +99,7 @@ void FreeGameMem() FreeMissiles(); FreeMonsters(); FreeObjectGFX(); - FreeEffects(); + FreeMonsterSnd(); FreeTownerGFX(); } @@ -94,7 +108,7 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer) BOOL fExitProgram; unsigned int uMsg; - gbGameUninitialized = TRUE; + gbSelectProvider = TRUE; do { fExitProgram = FALSE; @@ -107,7 +121,7 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer) break; } - gbGameUninitialized = FALSE; + gbSelectProvider = FALSE; if (bNewGame || !gbValidSaveFile) { InitLevels(); @@ -149,7 +163,7 @@ void run_game_loop(unsigned int uMsg) /// ASSERT: assert(ghMainWnd); saveProc = SetWindowProc(GM_Game); control_update_life_mana(); - msg_process_net_packets(); + run_delta_info(); gbRunGame = TRUE; gbProcessPlayers = TRUE; gbRunGameResult = TRUE; @@ -260,6 +274,13 @@ BOOL diablo_get_not_running() return GetLastError() != ERROR_ALREADY_EXISTS; } +/** + * @brief Main entry point, check env, initialize systesm, play intros, start main menu, shut down + * @param hInstance A handle to the current instance of the application. + * @param hPrevInstance Always null + * @param lpCmdLine The command line for the application + * @param nCmdShow Initial window state + */ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HINSTANCE hInst; @@ -321,7 +342,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi #endif diablo_parse_flags(lpCmdLine); init_create_window(nCmdShow); - sound_init(); + ui_sound_init(); UiInitialize(); #ifdef SPAWN UiSetSpawned(TRUE); @@ -705,13 +726,13 @@ BOOL PressEscKey() rv = TRUE; } if (helpflag) { - helpflag = 0; + helpflag = FALSE; rv = TRUE; } if (qtextflag) { - qtextflag = 0; - sfx_stop(); + qtextflag = FALSE; + stream_stop(); rv = TRUE; } else if (stextflag) { STextESC(); @@ -731,7 +752,7 @@ BOOL PressEscKey() rv = TRUE; } if (spselflag) { - spselflag = 0; + spselflag = FALSE; rv = TRUE; } @@ -864,7 +885,7 @@ LRESULT CALLBACK GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) pfile_write_hero(); nthread_ignore_mutex(TRUE); PaletteFadeOut(8); - FreeMonsterSnd(); + sound_stop(); music_stop(); track_repeat_walk(FALSE); sgbMouseDown = 0; @@ -895,12 +916,12 @@ BOOL LeftMouseDown(int wParam) } else if (stextflag) { CheckStoreBtn(); } else if (MouseY < PANEL_TOP) { - if (!gmenu_exception() && !TryIconCurs()) { + if (!gmenu_is_active() && !TryIconCurs()) { if (questlog && MouseX > 32 && MouseX < 288 && MouseY > 32 && MouseY < 308) { QuestlogESC(); } else if (qtextflag) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } else if (chrflag && MouseX < 320) { CheckChrBtns(); } else if (invflag && MouseX > RIGHT_PANEL) { @@ -921,7 +942,7 @@ BOOL LeftMouseDown(int wParam) } } } else { - if (!talkflag && !dropGoldFlag && !gmenu_exception()) + if (!talkflag && !dropGoldFlag && !gmenu_is_active()) CheckInvScrn(); DoPanBtn(); if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) @@ -1063,7 +1084,7 @@ void LeftMouseUp() void RightMouseDown() { - if (!gmenu_exception() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { + if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) { if (doomflag) { doom_close(); } else if (!stextflag) { @@ -1076,7 +1097,7 @@ void RightMouseDown() if (pcurs == 1) { if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem)) CheckPlrSpell(); - } else if (pcurs > 1 && pcurs < 12) { + } else if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) { SetCursor_(CURSOR_HAND); } } @@ -1086,7 +1107,7 @@ void RightMouseDown() BOOL PressSysKey(int wParam) { - if (gmenu_exception() || wParam != VK_F10) + if (gmenu_is_active() || wParam != VK_F10) return FALSE; diablo_hotkey_msg(1); return TRUE; @@ -1154,7 +1175,7 @@ void PressKey(int vkey) if (vkey == VK_ESCAPE) { if (!PressEscKey()) { track_repeat_walk(FALSE); - gamemenu_previous(); + gamemenu_on(); } return; } @@ -1180,20 +1201,20 @@ void PressKey(int vkey) } } else if (vkey == VK_F1) { if (helpflag) { - helpflag = 0; + helpflag = FALSE; } else if (stextflag) { ClearPanel(); AddPanelString("No help available", TRUE); /// BUGFIX: message isn't displayed AddPanelString("while in stores", TRUE); track_repeat_walk(FALSE); } else { - invflag = 0; + invflag = FALSE; chrflag = FALSE; sbookflag = FALSE; - spselflag = 0; + spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } questlog = FALSE; automapflag = FALSE; @@ -1229,31 +1250,31 @@ void PressKey(int vkey) #endif else if (vkey == VK_F5) { if (spselflag) { - ToggleSpell(0); + SetSpeedSpell(0); return; } - SetSpeedSpell(0); + ToggleSpell(0); return; } else if (vkey == VK_F6) { if (spselflag) { - ToggleSpell(1); + SetSpeedSpell(1); return; } - SetSpeedSpell(1); + ToggleSpell(1); return; } else if (vkey == VK_F7) { if (spselflag) { - ToggleSpell(2); + SetSpeedSpell(2); return; } - SetSpeedSpell(2); + ToggleSpell(2); return; } else if (vkey == VK_F8) { if (spselflag) { - ToggleSpell(3); + SetSpeedSpell(3); return; } - SetSpeedSpell(3); + ToggleSpell(3); return; } else if (vkey == VK_F9) { diablo_hotkey_msg(0); @@ -1308,14 +1329,14 @@ void PressKey(int vkey) if (!invflag && chrflag && MouseX > 160 && MouseY < PANEL_TOP) { SetCursorPos(MouseX - 160, MouseY); } - helpflag = 0; + helpflag = FALSE; invflag = FALSE; chrflag = FALSE; sbookflag = FALSE; - spselflag = 0; + spselflag = FALSE; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } questlog = FALSE; automapflag = FALSE; @@ -1332,17 +1353,19 @@ void diablo_pause_game() PauseMode = 0; } else { PauseMode = 2; - FreeMonsterSnd(); + sound_stop(); track_repeat_walk(FALSE); } force_redraw = 255; } } -/* NOTE: `return` must be used instead of `break` to be bin exact as C++ */ +/** + * @internal `return` must be used instead of `break` to be bin exact as C++ + */ void PressChar(int vkey) { - if (gmenu_exception() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { + if (gmenu_is_active() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { return; } if ((char)vkey == 'p' || (char)vkey == 'P') { @@ -1424,7 +1447,7 @@ void PressChar(int vkey) if (!spselflag) { DoSpeedBook(); } else { - spselflag = 0; + spselflag = FALSE; } track_repeat_walk(FALSE); } @@ -1466,43 +1489,43 @@ void PressChar(int vkey) return; case '!': case '1': - if (plr[myplr].SpdList[0]._itype != -1 && plr[myplr].SpdList[0]._itype != 11) { + if (plr[myplr].SpdList[0]._itype != ITYPE_NONE && plr[myplr].SpdList[0]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST); } return; case '@': case '2': - if (plr[myplr].SpdList[1]._itype != -1 && plr[myplr].SpdList[1]._itype != 11) { + if (plr[myplr].SpdList[1]._itype != ITYPE_NONE && plr[myplr].SpdList[1]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 1); } return; case '#': case '3': - if (plr[myplr].SpdList[2]._itype != -1 && plr[myplr].SpdList[2]._itype != 11) { + if (plr[myplr].SpdList[2]._itype != ITYPE_NONE && plr[myplr].SpdList[2]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 2); } return; case '$': case '4': - if (plr[myplr].SpdList[3]._itype != -1 && plr[myplr].SpdList[3]._itype != 11) { + if (plr[myplr].SpdList[3]._itype != ITYPE_NONE && plr[myplr].SpdList[3]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 3); } return; case '%': case '5': - if (plr[myplr].SpdList[4]._itype != -1 && plr[myplr].SpdList[4]._itype != 11) { + if (plr[myplr].SpdList[4]._itype != ITYPE_NONE && plr[myplr].SpdList[4]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 4); } return; case '^': case '6': - if (plr[myplr].SpdList[5]._itype != -1 && plr[myplr].SpdList[5]._itype != 11) { + if (plr[myplr].SpdList[5]._itype != ITYPE_NONE && plr[myplr].SpdList[5]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 5); } return; case '&': case '7': - if (plr[myplr].SpdList[6]._itype != -1 && plr[myplr].SpdList[6]._itype != 11) { + if (plr[myplr].SpdList[6]._itype != ITYPE_NONE && plr[myplr].SpdList[6]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 6); } return; @@ -1514,7 +1537,7 @@ void PressChar(int vkey) return; } #endif - if (plr[myplr].SpdList[7]._itype != -1 && plr[myplr].SpdList[7]._itype != 11) { + if (plr[myplr].SpdList[7]._itype != ITYPE_NONE && plr[myplr].SpdList[7]._itype != ITYPE_GOLD) { UseInvItem(myplr, INVITEM_BELT_FIRST + 7); } return; @@ -1973,7 +1996,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) { items_427ABA(RowOfCornerStone, ColOfCornerStone); } - if ( quests[QTYPE_NAKRUL]._qactive == 3 && currlevel == 24 ) // TODO: fix quest struct + if ( quests[Q_NAKRUL]._qactive == 3 && currlevel == 24 ) // TODO: fix quest struct { objects_454BA8(); } @@ -1993,7 +2016,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir) ; #ifndef SPAWN - if (setlevel && setlvlnum == SL_SKELKING && quests[QTYPE_KING]._qactive == 2) + if (setlevel && setlvlnum == SL_SKELKING && quests[Q_SKELKING]._qactive == QUEST_ACTIVE) PlaySFX(USFX_SKING1); #endif } @@ -2025,12 +2048,12 @@ void game_logic() if (PauseMode == 1) { PauseMode = 2; } - if (gbMaxPlayers == 1 && gmenu_exception()) { + if (gbMaxPlayers == 1 && gmenu_is_active()) { force_redraw |= 1; return; } - if (!gmenu_exception() && sgnTimeoutCurs == 0) { + if (!gmenu_is_active() && sgnTimeoutCurs == 0) { CheckCursMove(); track_process(); } @@ -2076,7 +2099,7 @@ void timeout_cursor(BOOL bTimeout) SetCursor_(CURSOR_HOURGLASS); force_redraw = 255; } - scrollrt_draw_game_screen(1); + scrollrt_draw_game_screen(TRUE); } else if (sgnTimeoutCurs) { SetCursor_(sgnTimeoutCurs); sgnTimeoutCurs = 0; diff --git a/Source/diablo.h b/Source/diablo.h index 3035e527..d59cee47 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -1,88 +1,11 @@ -//HEADER_GOES_HERE +/** + * @file diablo.h + * + * Interface of the main game initialization functions. + */ #ifndef __DIABLO_H__ #define __DIABLO_H__ -#include "../types.h" - -#ifdef __cplusplus -extern "C" { -#endif -#include "appfat.h" -#include "automap.h" -#include "capture.h" -#include "codec.h" -#include "control.h" -#include "cursor.h" -#include "dead.h" -#include "debug.h" -#include "doom.h" -#include "drlg_l1.h" -#include "drlg_l2.h" -#include "drlg_l3.h" -#include "drlg_l4.h" -#include "dthread.h" -#include "dx.h" -#include "effects.h" -#include "encrypt.h" -#include "engine.h" -#include "error.h" -#include "fault.h" -#include "gamemenu.h" -#include "gendung.h" -#include "gmenu.h" -#include "help.h" -#include "init.h" -#include "interfac.h" -#include "inv.h" -#include "itemdat.h" -#include "items.h" -#include "lighting.h" -#include "loadsave.h" -#include "logging.h" -#include "mainmenu.h" -#include "minitext.h" -#include "misdat.h" -#include "missiles.h" -#include "monstdat.h" -#include "monster.h" -#include "movie.h" -#include "mpqapi.h" -#include "msg.h" -#include "msgcmd.h" -#include "multi.h" -#include "nthread.h" -#include "objdat.h" -#include "objects.h" -#include "pack.h" -#include "palette.h" -#include "path.h" -#include "pfile.h" -#include "player.h" -#include "plrmsg.h" -#include "portal.h" -#include "quests.h" -#include "restrict.h" -#include "scrollrt.h" -#include "setmaps.h" -#include "sha.h" -#include "sound.h" -#include "spelldat.h" -#include "spells.h" -#include "stores.h" -#include "sync.h" -#include "textdat.h" // check file name -#include "themes.h" -#include "tmsg.h" -#include "town.h" -#include "towners.h" -#include "track.h" -#include "trigs.h" -#include "wave.h" -#include "render.h" // linked last, likely .s/.asm -#ifdef __cplusplus -} -#endif - extern HWND ghMainWnd; extern int glMid1Seed[NUMLEVELS]; extern int glMid2Seed[NUMLEVELS]; @@ -103,11 +26,13 @@ extern int DebugMonsters[10]; extern BOOLEAN cineflag; extern int force_redraw; extern BOOL visiondebug; -extern BOOL scrollflag; /* unused */ +/** unused */ +extern BOOL scrollflag; extern BOOL light4flag; extern BOOL leveldebug; extern BOOL monstdebug; -extern BOOL trigdebug; /* unused */ +/** unused */ +extern BOOL trigdebug; extern int setseed; extern int debugmonsttypes; extern int PauseMode; diff --git a/Source/doom.cpp b/Source/doom.cpp index 0a652021..c77d98f6 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file doom.cpp + * + * Implementation of the map of the stars quest. + */ +#include "all.h" int doom_quest_time; int doom_stars_drawn; diff --git a/Source/doom.h b/Source/doom.h index bdff7e17..4dbf96b8 100644 --- a/Source/doom.h +++ b/Source/doom.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file doom.h + * + * Interface of the map of the stars quest. + */ #ifndef __DOOM_H__ #define __DOOM_H__ diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index c2a79a32..39c5c2d2 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file drlg_l1.cpp + * + * Implementation of the cathedral level generation algorithms. + */ +#include "all.h" BYTE L5dungeon[80][80]; BYTE L5dflags[DMAXX][DMAXY]; @@ -246,7 +251,7 @@ void DRLG_InitL5Vals() } else { continue; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } } @@ -785,8 +790,8 @@ static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, in DRLG_MRectTrans(sx, sy + 2, sx + 5, sy + 4); TransVal = t; - quests[QTYPE_PW]._qtx = 2 * sx + 21; - quests[QTYPE_PW]._qty = 2 * sy + 22; + quests[Q_PWATER]._qtx = 2 * sx + 21; + quests[Q_PWATER]._qty = 2 * sy + 22; } if (setview == TRUE) { @@ -917,15 +922,15 @@ static void DRLG_L1Pass3() static void DRLG_LoadL1SP() { L5setloadflag = FALSE; - if (QuestStatus(QTYPE_BUTCH)) { + if (QuestStatus(Q_BUTCHER)) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", NULL); L5setloadflag = TRUE; } - if (QuestStatus(QTYPE_KING) && gbMaxPlayers == 1) { + if (QuestStatus(Q_SKELKING) && gbMaxPlayers == 1) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", NULL); L5setloadflag = TRUE; } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { L5pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", NULL); L5setloadflag = TRUE; } @@ -947,7 +952,7 @@ void DRLG_Init_Globals() memset(dObject, 0, sizeof(dObject)); memset(dItem, 0, sizeof(dItem)); memset(dMissile, 0, sizeof(dMissile)); - memset(dArch, 0, sizeof(dArch)); + memset(dSpecial, 0, sizeof(dSpecial)); if (!lightflag) { if (light4flag) c = 3; @@ -996,7 +1001,7 @@ static void DRLG_InitL1Vals() } else { continue; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } } @@ -2369,7 +2374,7 @@ static void DRLG_L5(int entry) doneflag = TRUE; - if (QuestStatus(QTYPE_PW)) { + if (QuestStatus(Q_PWATER)) { if (entry == 0) { if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0) doneflag = FALSE; @@ -2379,7 +2384,7 @@ static void DRLG_L5(int entry) ViewY--; } } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { if (entry == 0) { if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0) doneflag = FALSE; diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index f8faebe2..fdccf1ef 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l1.h + * + * Interface of the cathedral level generation algorithms. + */ #ifndef __DRLG_L1_H__ #define __DRLG_L1_H__ diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index c74c3a23..17608cba 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1,5 +1,10 @@ +/** + * @file drlg_l2.cpp + * + * Implementation of the catacombs level generation algorithms. + */ #ifndef SPAWN -#include "diablo.h" +#include "all.h" int nSx1; int nSy1; @@ -465,13 +470,13 @@ static void DRLG_LoadL2SP() { setloadflag = FALSE; - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); setloadflag = TRUE; - } else if (QuestStatus(QTYPE_BLOOD)) { + } else if (QuestStatus(Q_BLOOD)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Blood1.DUN", NULL); setloadflag = TRUE; - } else if (QuestStatus(QTYPE_BONE)) { + } else if (QuestStatus(Q_SCHAMB)) { pSetPiece = LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", NULL); setloadflag = TRUE; } @@ -1378,21 +1383,21 @@ static BOOL CreateDungeon() switch (currlevel) { case 5: - if (quests[QTYPE_BLOOD]._qactive) { + if (quests[Q_BLOOD]._qactive) { ForceHW = TRUE; ForceH = 20; ForceW = 14; } break; case 6: - if (quests[QTYPE_BONE]._qactive) { + if (quests[Q_SCHAMB]._qactive) { ForceHW = TRUE; ForceW = 10; ForceH = 10; } break; case 7: - if (quests[QTYPE_BLIND]._qactive) { + if (quests[Q_BLIND]._qactive) { ForceHW = TRUE; ForceW = 15; ForceH = 15; @@ -1960,17 +1965,17 @@ static void DRLG_InitL2Vals() } else { continue; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } @@ -2044,17 +2049,17 @@ void LoadL2Dungeon(char *sFileName, int vx, int vy) if (dPiece[i][j] == 17) { pc = 6; } - dArch[i][j] = pc; + dSpecial[i][j] = pc; } } for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } @@ -2118,13 +2123,13 @@ void LoadPreL2Dungeon(char *sFileName, int vx, int vy) void CreateL2Dungeon(DWORD rseed, int entry) { if (gbMaxPlayers == 1) { - if (currlevel == 7 && !quests[QTYPE_BLIND]._qactive) { + if (currlevel == 7 && !quests[Q_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 7; } if (currlevel == 8) { - if (!quests[QTYPE_BLIND]._qactive) { + if (!quests[Q_BLIND]._qactive) { currlevel = 6; CreateL2Dungeon(glSeedTbl[6], 4); currlevel = 8; diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index d45c2f4c..c0a7a018 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l2.h + * + * Interface of the catacombs level generation algorithms. + */ #ifndef __DRLG_L2_H__ #define __DRLG_L2_H__ diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 895e0790..ffa97a56 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1,5 +1,10 @@ +/** + * @file drlg_l3.cpp + * + * Implementation of the caves level generation algorithms. + */ #ifndef SPAWN -#include "diablo.h" +#include "all.h" BOOLEAN lavapool; int abyssx; @@ -1622,7 +1627,7 @@ static void DRLG_L3(int entry) DRLG_L3CreateBlock(x2, y1, 2, 1); DRLG_L3CreateBlock(x1, y2, 2, 2); DRLG_L3CreateBlock(x1, y1, 2, 3); - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { x1 = random_(0, 10) + 10; y1 = random_(0, 10) + 10; x2 = x1 + 12; @@ -1732,7 +1737,7 @@ static void DRLG_L3(int entry) } } } - if (!genok && QuestStatus(QTYPE_ANVIL)) { + if (!genok && QuestStatus(Q_ANVIL)) { genok = DRLG_L3Anvil(); } } while (genok == TRUE); @@ -1792,7 +1797,7 @@ static void DRLG_L3(int entry) #endif DRLG_L3River(); - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { dungeon[setpc_x + 7][setpc_y + 5] = 7; dungeon[setpc_x + 8][setpc_y + 5] = 7; dungeon[setpc_x + 9][setpc_y + 5] = 7; diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index e9252d26..e63372c3 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l3.h + * + * Interface of the caves level generation algorithms. + */ #ifndef __DRLG_L3_H__ #define __DRLG_L3_H__ diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index fdc76017..0be518c0 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file drlg_l4.cpp + * + * Implementation of the hell level generation algorithms. + */ +#include "all.h" int diabquad1x; int diabquad1y; @@ -339,7 +344,7 @@ static void InitL4Dungeon() void DRLG_LoadL4SP() { setloadflag = FALSE; - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { pSetPiece = LoadFileInMem("Levels\\L4Data\\Warlord.DUN", NULL); setloadflag = TRUE; } @@ -1318,11 +1323,11 @@ static void L4firstRoom() int x, y, w, h, rndx, rndy, xmin, xmax, ymin, ymax, tx, ty; if (currlevel != 16) { - if (currlevel == quests[QTYPE_WARLRD]._qlevel && quests[QTYPE_WARLRD]._qactive) { + if (currlevel == quests[Q_WARLORD]._qlevel && quests[Q_WARLORD]._qactive) { /// ASSERT: assert(gbMaxPlayers == 1); w = 11; h = 11; - } else if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + } else if (currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { w = 11; h = 11; } else { @@ -1357,7 +1362,7 @@ static void L4firstRoom() l4holdx = x; l4holdy = y; } - if (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (QuestStatus(Q_WARLORD) || currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { SP4x1 = x + 1; SP4y1 = y + 1; SP4x2 = SP4x1 + w; @@ -1525,8 +1530,8 @@ static BOOL DRLG_L4PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, } if (currlevel == 15) { - quests[QTYPE_VB]._qtx = sx + 1; - quests[QTYPE_VB]._qty = sy + 1; + quests[Q_BETRAYER]._qtx = sx + 1; + quests[Q_BETRAYER]._qty = sy + 1; } if (setview == TRUE) { ViewX = 2 * sx + 21; @@ -1742,7 +1747,7 @@ static void DRLG_L4(int entry) if (currlevel == 16) { L4SaveQuads(); } - if (QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (QuestStatus(Q_WARLORD) || currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { for (spi = SP4x1; spi < SP4x2; spi++) { for (spj = SP4y1; spj < SP4y2; spj++) { dflags[spi][spj] = 1; @@ -1758,7 +1763,7 @@ static void DRLG_L4(int entry) if (currlevel == 16) { DRLG_LoadDiabQuads(TRUE); } - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { if (entry == 0) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if (doneflag && currlevel == 13) { @@ -1812,7 +1817,7 @@ static void DRLG_L4(int entry) if (entry == 0) { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); if (doneflag) { - if (gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + if (gbMaxPlayers == 1 && quests[Q_DIABLO]._qactive != QUEST_ACTIVE) { doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 0, 1); } else { doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 0, 1); @@ -1822,7 +1827,7 @@ static void DRLG_L4(int entry) } else { doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); if (doneflag) { - if (gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + if (gbMaxPlayers == 1 && quests[Q_DIABLO]._qactive != QUEST_ACTIVE) { doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 1, 1); } else { doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 1, 1); @@ -1844,7 +1849,7 @@ static void DRLG_L4(int entry) DRLG_L4Subs(); DRLG_Init_Globals(); - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { for (j = 0; j < DMAXY; j++) { for (i = 0; i < DMAXX; i++) { pdungeon[i][j] = dungeon[i][j]; diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index 8ec11f23..b2e52c77 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file drlg_l4.h + * + * Interface of the hell level generation algorithms. + */ #ifndef __DRLG_L4_H__ #define __DRLG_L4_H__ diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 2c268c25..d6f5ea27 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file dthread.cpp + * + * Implementation of functions for updating game state from network commands. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef __cplusplus @@ -81,14 +86,14 @@ void dthread_start() } } -unsigned int __stdcall dthread_handler(void *) +unsigned int __stdcall dthread_handler(void *data) { char *error_buf; TMegaPkt *pkt; DWORD dwMilliseconds; while (dthread_running) { - if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) { + if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, INFINITE) == -1) { error_buf = TraceLastError(); app_fatal("dthread4:\n%s", error_buf); } @@ -135,7 +140,7 @@ void dthread_cleanup() dthread_running = FALSE; SetEvent(sghWorkToDoEvent); if (sghThread != INVALID_HANDLE_VALUE && glpDThreadId != GetCurrentThreadId()) { - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + if (WaitForSingleObject(sghThread, INFINITE) == -1) { error_buf = TraceLastError(); app_fatal("dthread3:\n(%s)", error_buf); } diff --git a/Source/dthread.h b/Source/dthread.h index 4ad5d3fb..f4dc99c6 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dthread.h + * + * Interface of functions for updating game state from network commands. + */ #ifndef __DTHREAD_H__ #define __DTHREAD_H__ @@ -8,7 +12,7 @@ extern BOOLEAN dthread_running; void dthread_remove_player(int pnum); void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen); void dthread_start(); -unsigned int __stdcall dthread_handler(void *); +unsigned int __stdcall dthread_handler(void *data); void dthread_cleanup(); /* data */ diff --git a/Source/dx.cpp b/Source/dx.cpp index 149541f1..2ead8b68 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file dx.cpp + * + * Implementation of functions setting up the graphics pipeline. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BYTE *sgpBackBuf; diff --git a/Source/dx.h b/Source/dx.h index 39c0fbef..1a13e3b1 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file dx.h + * + * Interface of functions setting up the graphics pipeline. + */ #ifndef __DX_H__ #define __DX_H__ diff --git a/Source/effects.cpp b/Source/effects.cpp index 380628c4..b2acb2db 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1,15 +1,29 @@ -#include "diablo.h" +/** + * @file effects.cpp + * + * Implementation of functions for loading and playing sounds. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" int sfxdelay; int sfxdnum; -HANDLE sfx_stream; -TSFX *sfx_data_cur; +/** A handle to the current sound effect playing. */ +HANDLE sghStream; +/** Specifies the sound file and the playback state of the current sound effect. */ +TSFX *sgpStreamSFX; +/** + * Monster sound type prefix + * a: Attack + * h: Hit + * d: Death + * s: Special + */ const char MonstSndChar[] = { 'a', 'h', 'd', 's' }; /* data */ - +/** List of all sounds, except monsters and music */ TSFX sgSFX[] = { // clang-format off // bFlags, pszName, pSnd @@ -1087,18 +1101,18 @@ BOOL effect_is_playing(int nSFX) return snd_playing(sfx->pSnd); if (sfx->bFlags & SFX_STREAM) - return sfx == sfx_data_cur; + return sfx == sgpStreamSFX; return FALSE; } -void sfx_stop() +void stream_stop() { - if (sfx_stream) { - SFileDdaEnd(sfx_stream); - SFileCloseFile(sfx_stream); - sfx_stream = NULL; - sfx_data_cur = NULL; + if (sghStream) { + SFileDdaEnd(sghStream); + SFileCloseFile(sghStream); + sghStream = NULL; + sgpStreamSFX = NULL; } } @@ -1129,7 +1143,7 @@ void InitMonsterSND(int monst) } } -void FreeEffects() +void FreeMonsterSnd() { int mtype, i, j, k; char *file; @@ -1248,7 +1262,7 @@ void stream_play(TSFX *pSFX, int lVolume, int lPan) /// ASSERT: assert(pSFX); /// ASSERT: assert(pSFX->bFlags & sfx_STREAM); - sfx_stop(); + stream_stop(); lVolume += sound_get_or_set_sound_volume(1); if (lVolume >= VOLUME_MIN) { if (lVolume > VOLUME_MAX) @@ -1256,17 +1270,17 @@ void stream_play(TSFX *pSFX, int lVolume, int lPan) #ifdef _DEBUG SFileEnableDirectAccess(FALSE); #endif - success = SFileOpenFile(pSFX->pszName, &sfx_stream); + success = SFileOpenFile(pSFX->pszName, &sghStream); #ifdef _DEBUG SFileEnableDirectAccess(TRUE); #endif if (!success) { - sfx_stream = 0; + sghStream = 0; } else { - if (!SFileDdaBeginEx(sfx_stream, 0x40000, 0, 0, lVolume, lPan, 0)) - sfx_stop(); + if (!SFileDdaBeginEx(sghStream, 0x40000, 0, 0, lVolume, lPan, 0)) + stream_stop(); else - sfx_data_cur = pSFX; + sgpStreamSFX = pSFX; } } } @@ -1327,13 +1341,13 @@ void PlaySfxLoc(int psfx, int x, int y) PlaySFX_priv(&sgSFX[psfx], TRUE, x, y); } -void FreeMonsterSnd() +void sound_stop() { int i, j, k; snd_update(TRUE); + stream_stop(); sfx_stop(); - sound_stop(); for (i = 0; i < nummtypes; i++) { for (j = 0; j < 4; j++) { @@ -1344,7 +1358,7 @@ void FreeMonsterSnd() } } -void sound_stop() +void sfx_stop() { int i; TSFX *snd; @@ -1364,15 +1378,15 @@ void sound_update() } snd_update(FALSE); - effects_update(); + stream_update(); } -void effects_update() +void stream_update() { DWORD current, end; - if (sfx_stream != NULL && SFileDdaGetPos(sfx_stream, ¤t, &end) && current >= end) { - sfx_stop(); + if (sghStream != NULL && SFileDdaGetPos(sghStream, ¤t, &end) && current >= end) { + stream_stop(); } } @@ -1380,7 +1394,7 @@ void effects_cleanup_sfx() { DWORD i; - FreeMonsterSnd(); + sound_stop(); for (i = 0; i < sizeof(sgSFX) / sizeof(TSFX); i++) { if (sgSFX[i].pSnd) { @@ -1390,7 +1404,7 @@ void effects_cleanup_sfx() } } -void stream_update() +void sound_init() { BYTE mask = 0; if (gbMaxPlayers > 1) { @@ -1460,7 +1474,7 @@ void priv_sound_init(BYTE bLoadMask) } } -void sound_init() +void ui_sound_init() { priv_sound_init(SFX_UI); } diff --git a/Source/effects.h b/Source/effects.h index 8ed845e6..46aeb95d 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -1,16 +1,20 @@ -//HEADER_GOES_HERE +/** + * @file effects.h + * + * Interface of functions for loading and playing sounds. + */ #ifndef __EFFECTS_H__ #define __EFFECTS_H__ extern int sfxdelay; extern int sfxdnum; -extern HANDLE sfx_stream; -extern TSFX *sfx_data_cur; +extern HANDLE sghStream; +extern TSFX *sgpStreamSFX; BOOL effect_is_playing(int nSFX); -void sfx_stop(); +void stream_stop(); void InitMonsterSND(int monst); -void FreeEffects(); +void FreeMonsterSnd(); void PlayEffect(int i, int mode); BOOL calc_snd_position(int x, int y, int *plVolume, int *plPan); void PlaySFX(int psfx); @@ -18,14 +22,14 @@ void PlaySFX_priv(TSFX *pSFX, BOOL loc, int x, int y); void stream_play(TSFX *pSFX, int lVolume, int lPan); int RndSFX(int psfx); void PlaySfxLoc(int psfx, int x, int y); -void FreeMonsterSnd(); void sound_stop(); +void sfx_stop(); void sound_update(); -void effects_update(); -void effects_cleanup_sfx(); void stream_update(); -void priv_sound_init(BYTE bLoadMask); +void effects_cleanup_sfx(); void sound_init(); +void priv_sound_init(BYTE bLoadMask); +void ui_sound_init(); void __stdcall effects_play_sound(char *snd_file); /* rdata */ diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index a1d28721..dd4d0a4a 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file encrypt.cpp + * + * Implementation of functions for compression and decompressing MPQ data. + */ +#include "all.h" #include "../3rdParty/PKWare/pkware.h" DWORD hashtable[1280]; diff --git a/Source/encrypt.h b/Source/encrypt.h index 0d76b0f8..552bed22 100644 --- a/Source/encrypt.h +++ b/Source/encrypt.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file encrypt.h + * + * Interface of functions for compression and decompressing MPQ data. + */ #ifndef __ENCRYPT_H__ #define __ENCRYPT_H__ diff --git a/Source/engine.cpp b/Source/engine.cpp index d71fa31f..fb460826 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,4 +1,16 @@ -#include "diablo.h" +/** + * @file engine.cpp + * + * Implementation of basic engine helper functions: + * - Sprite blitting + * - Drawing + * - Angle calculation + * - RNG + * - Memory allocation + * - File loading + * - Video playback + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef USE_ASM @@ -8,7 +20,9 @@ char gbPixelCol; // automap pixel color 8-bit (palette entry) BOOL gbRotateMap; // flip - if y < x int orgseed; +/** Width of sprite being blitted */ int sgnWidth; +/** Current game seed */ int sglGameSeed; #ifdef __cplusplus static CCritSect sgMemCrit; @@ -16,9 +30,22 @@ static CCritSect sgMemCrit; int SeedCount; BOOL gbNotInView; // valid - if x/y are in bounds +/** + * Specifies the increment used in the Borland C/C++ pseudo-random. + */ const int RndInc = 1; + +/** + * Specifies the multiplier used in the Borland C/C++ pseudo-random number generator algorithm. + */ const int RndMult = 0x015A4E35; +/** + * @brief Find the start of a CEL frame + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nDataSize Will be set to frame size + */ __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize) { DWORD *pFrameTable; @@ -31,6 +58,12 @@ __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize) return pCelBuff + nCellStart; } +/** + * @brief Calculate the size of a CEL frame + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @return Size of CEL in bytes + */ __FINLINE int CelGetFrameSize(BYTE *pCelBuff, int nCel) { DWORD *pFrameTable; @@ -40,6 +73,13 @@ __FINLINE int CelGetFrameSize(BYTE *pCelBuff, int nCel) return SwapLE32(pFrameTable[nCel + 1]) - SwapLE32(pFrameTable[nCel]); } +/** + * @brief Blit CEL sprite to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -139,6 +179,14 @@ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) #endif } +/** + * @brief Blit CEL sprite to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -155,6 +203,13 @@ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) CelBlit(&gpBuffer[sx + PitchTbl[sy]], pRLEBytes, nDataSize, nWidth); } +/** + * @brief Blit a given CEL frame to the given buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -172,6 +227,12 @@ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth) } /** + * @brief Same as CelDraw but with the option to skip parts of the top and bottom of the sprite + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -213,6 +274,11 @@ void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce } /** + * @brief Same as CelBlit but with the option to skip parts of the top and bottom of the sprite + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -249,6 +315,13 @@ void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSk CelBlit(pBuff, pRLEBytes + nDataStart, nDataSize, nWidth); } +/** + * @brief Blit CEL sprite, and apply lighting, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -402,6 +475,13 @@ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) #endif } +/** + * @brief Blit CEL sprite, and apply lighting, to the given buffer, with transparancy applied + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite + */ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { int w; @@ -589,6 +669,14 @@ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWid #endif } +/** + * @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite + */ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) { int nDataSize; @@ -611,6 +699,12 @@ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth) } /** + * @brief Same as CelDrawLight but with the option to skip parts of the top and bottom of the sprite + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -654,6 +748,11 @@ void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i } /** + * @brief Same as CelBlitLightTrans but with the option to skip parts of the top and bottom of the sprite + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -698,8 +797,15 @@ void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, } /** + * @brief Blit CEL sprite, and apply lighting, to the back buffer at the given coordinates, translated to a red hue + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -816,6 +922,10 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C /** * @brief Same as CelBlit but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -931,6 +1041,12 @@ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Same as CelClippedDraw but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -972,6 +1088,11 @@ void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in } /** + * @brief Same as CelClippedBlit but checks for drawing outside the buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1010,6 +1131,10 @@ void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int C /** * @brief Same as CelBlitLight but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -1181,6 +1306,10 @@ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt /** * @brief Same as CelBlitLightTrans but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CEL pixel stream (run-length encoded) + * @param nDataSize Size of CEL in bytes + * @param nWidth Width of sprite */ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { @@ -1384,6 +1513,12 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int } /** + * @brief Same as CelDrawLight but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1427,6 +1562,11 @@ void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int } /** + * @brief Same as CelClippedBlitLightTrans but checks for drawing outside the buffer + * @param pBuff Target buffer + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1469,8 +1609,14 @@ void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWi /** * @brief Same as CelDrawLightRed but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff Cel data + * @param nCel CEL frame number + * @param nWidth Width of cel * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -1600,7 +1746,7 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i * @param y Cordinate in pBuff buffer * @param wdt Width of pBuff * @param pCelBuff Cel data - * @param nCel Frame of cel + * @param nCel CEL frame number * @param nWidth Width of cel */ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, int nWidth) @@ -1718,6 +1864,13 @@ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel, } /** + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CEL buffer + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -1860,6 +2013,12 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid /** * @brief Same as CelBlitOutline but checks for drawing outside the buffer + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CEL buffer + * @param nCel CEL frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2042,6 +2201,12 @@ void CelBlitOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int #endif } +/** + * @brief Set the value of a single pixel in the back buffer, checks bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param col Color index from current palette + */ void ENG_set_pixel(int sx, int sy, BYTE col) { BYTE *dst; @@ -2068,6 +2233,11 @@ void ENG_set_pixel(int sx, int sy, BYTE col) #endif } +/** + * @brief Set the value of a single pixel in the back buffer to that of gbPixelCol, checks bounds + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + */ void engine_draw_pixel(int sx, int sy) { BYTE *dst; @@ -2099,26 +2269,34 @@ void engine_draw_pixel(int sx, int sy) #endif } -// Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c -// Except: -// * not in view checks -// * global variable instead of reverse flag -// * condition for pixels_left < 0 removed - -/* -Symmetric Double Step Line Algorithm -by Brian Wyvill -from "Graphics Gems", Academic Press, 1990 -*/ - +/** Macro used in DrawLine() */ #define GG_SWAP(A, B) \ { \ (A) ^= (B); \ (B) ^= (A); \ (A) ^= (B); \ } +/** Macro used in DrawLine() */ #define GG_ABSOLUTE(I, J, K) (((I) - (J)) * ((K) = (((I) - (J)) < 0 ? -1 : 1))) +/** + * Symmetric Double Step Line Algorithm + * by Brian Wyvill + * from "Graphics Gems", Academic Press, 1990 + * + * Exact copy from https://github.com/erich666/GraphicsGems/blob/dad26f941e12c8bf1f96ea21c1c04cd2206ae7c9/gems/DoubleLine.c + * Except: + * - not in view checks + * - global variable instead of reverse flag + * - condition for pixels_left < 0 removed + * + * @brief Draw a line on the back buffer + * @param x0 Back buffer coordinate + * @param y0 Back buffer coordinate + * @param x1 Back buffer coordinate + * @param y1 Back buffer coordinate + * @param col Color index from current palette + */ void DrawLine(int x0, int y0, int x1, int y1, BYTE col) { int dx, dy, incr1, incr2, D, x, y, xend, c, pixels_left; @@ -2308,6 +2486,14 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col) } } +/** + * @brief Calculate the best fit direction between two points + * @param x1 Tile coordinate + * @param y1 Tile coordinate + * @param x2 Tile coordinate + * @param y2 Tile coordinate + * @return A value from the direction enum + */ int GetDirection(int x1, int y1, int x2, int y2) { int mx, my; @@ -2349,6 +2535,10 @@ int GetDirection(int x1, int y1, int x2, int y2) return md; } +/** + * @brief Set the RNG seed + * @param s RNG seed + */ void SetRndSeed(int s) { SeedCount = 0; @@ -2356,6 +2546,10 @@ void SetRndSeed(int s) orgseed = s; } +/** + * @brief Get the current RNG seed + * @return RNG seed + */ int GetRndSeed() { SeedCount++; @@ -2363,6 +2557,12 @@ int GetRndSeed() return abs(sglGameSeed); } +/** + * @brief Main RNG function + * @param idx Unused + * @param v The upper limit for the return value + * @return A random number from 0 to (v-1) + */ int random_(BYTE idx, int v) { if (v <= 0) @@ -2372,6 +2572,10 @@ int random_(BYTE idx, int v) return GetRndSeed() % v; } +/** + * @brief Unallocate all remaining pointers + * @param show_cursor unused + */ void engine_debug_trap(BOOL show_cursor) { /* @@ -2387,6 +2591,10 @@ void engine_debug_trap(BOOL show_cursor) */ } +/** + * @brief Multithreaded safe malloc + * @param dwBytes Byte size to allocate + */ BYTE *DiabloAllocPtr(DWORD dwBytes) { BYTE *buf; @@ -2406,6 +2614,10 @@ BYTE *DiabloAllocPtr(DWORD dwBytes) return buf; } +/** + * @brief Multithreaded safe memfree + * @param p Memory pointer to free + */ void mem_free_dbg(void *p) { if (p) { @@ -2419,6 +2631,12 @@ void mem_free_dbg(void *p) } } +/** + * @brief Load a file in to a buffer + * @param pszName Path of file + * @param pdwFileLen Will be set to file size if non-NULL + * @return Buffer with content of file + */ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen) { HANDLE file; @@ -2442,6 +2660,12 @@ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen) return buf; } +/** + * @brief Load a file in to the given buffer + * @param pszName Path of file + * @param p Target buffer + * @return Size of file + */ DWORD LoadFileWithMem(const char *pszName, void *p) { DWORD dwFileLen; @@ -2467,6 +2691,9 @@ DWORD LoadFileWithMem(const char *pszName, void *p) /** * @brief Apply the color swaps to a CL2 sprite + * @param p CL2 buffer + * @param ttbl Palette translation table + * @param nCel Frame number in CL2 file */ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) { @@ -2508,6 +2735,12 @@ void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel) } /** + * @brief Blit CL2 sprite, to the back buffer at the given coordianates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2548,6 +2781,13 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, nWidth); } +/** + * @brief Blit CL2 sprite to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + */ void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { #ifdef USE_ASM @@ -2690,6 +2930,13 @@ void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the back buffer at the given coordianates + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -2731,6 +2978,14 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid col); } +/** + * @brief Blit a solid colder shape one pixel larger then the given sprite shape, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param col Color index from current palette + */ void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { #ifdef USE_ASM @@ -2894,8 +3149,15 @@ void Cl2BlitOutline(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, } /** + * @brief Blit CL2 sprite, and apply a given lighting, to the back buffer at the given coordianates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light Light shade to use */ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -2945,6 +3207,14 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C &pLightTbl[idx]); } +/** + * @brief Blit CL2 sprite, and apply lighting, to the given buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param pTable Light color table + */ void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { #ifdef USE_ASM @@ -3096,6 +3366,12 @@ void Cl2BlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, B } /** + * @brief Blit CL2 sprite, and apply lighting, to the back buffer at the given coordinates + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3140,6 +3416,12 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelS } /** + * @brief Same as Cl2Draw but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3180,6 +3462,13 @@ void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSk nWidth); } +/** + * @brief Same as Cl2Blit but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + */ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { #ifdef USE_ASM @@ -3335,6 +3624,13 @@ void Cl2BlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) } /** + * @brief Same as Cl2DrawOutline but checks for drawing outside the buffer + * @param col Color index from current palette + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3378,6 +3674,14 @@ void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int gpBufEnd += BUFFER_WIDTH; } +/** + * @brief Same as Cl2BlitOutline but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth Width of sprite + * @param col Color index from current palette + */ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { #ifdef USE_ASM @@ -3552,8 +3856,15 @@ void Cl2BlitOutlineSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi } /** + * @brief Same as Cl2DrawLightTbl but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 + * @param light light shade to use */ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap, char light) { @@ -3603,6 +3914,14 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i &pLightTbl[idx]); } +/** + * @brief Same as Cl2BlitLight but checks for drawing outside the buffer + * @param pDecodeTo The output buffer + * @param pRLEBytes CL2 pixel stream (run-length encoded) + * @param nDataSize Size of CL2 in bytes + * @param nWidth With of CL2 sprite + * @param pTable Light color table + */ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { #ifdef USE_ASM @@ -3767,6 +4086,12 @@ void Cl2BlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt } /** + * @brief Same as Cl2DrawLight but checks for drawing outside the buffer + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate + * @param pCelBuff CL2 buffer + * @param nCel CL2 frame number + * @param nWidth Width of sprite * @param CelSkip Skip lower parts of sprite, must be multiple of 2, max 8 * @param CelCap Amount of sprite to render from lower to upper, must be multiple of 2, max 8 */ @@ -3810,13 +4135,17 @@ void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cl2BlitSafe(pDecodeTo, pRLEBytes, nSize, nWidth); } +/** + * @brief Fade to black and play a video + * @param pszMovie file path of movie + */ void PlayInGameMovie(char *pszMovie) { PaletteFadeOut(8); play_movie(pszMovie, FALSE); ClearScreenBuffer(); force_redraw = 255; - scrollrt_draw_game_screen(1); + scrollrt_draw_game_screen(TRUE); PaletteFadeIn(8); force_redraw = 255; } diff --git a/Source/engine.h b/Source/engine.h index 26075080..9027445b 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -1,15 +1,31 @@ -//HEADER_GOES_HERE +/** + * @file engine.h + * + * of basic engine helper functions: + * - Sprite blitting + * - Drawing + * - Angle calculation + * - RNG + * - Memory allocation + * - File loading + * - Video playback + */ #ifndef __ENGINE_H__ #define __ENGINE_H__ //offset 0 //pCelBuff->pFrameTable[0] -extern char gbPixelCol; // automap pixel color 8-bit (palette entry) -extern BOOL gbRotateMap; // flip - if y < x +/** automap pixel color 8-bit (palette entry) */ +extern char gbPixelCol; +/** flip - if y < x */ +extern BOOL gbRotateMap; +/** Seed value before the most recent call to SetRndSeed() */ extern int orgseed; +/** Track number of calls to GetRndSeed() since last call to SetRndSeed() */ extern int SeedCount; -extern BOOL gbNotInView; // valid - if x/y are in bounds +/** valid - if x/y are in bounds */ +extern BOOL gbNotInView; __FINLINE BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize); diff --git a/Source/error.cpp b/Source/error.cpp index f17865f4..4495e862 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -1,10 +1,16 @@ -#include "diablo.h" +/** + * @file error.cpp + * + * Implementation of in-game message functions. + */ +#include "all.h" char msgtable[MAX_SEND_STR_LEN]; char msgdelay; char msgflag; char msgcnt; +/** Maps from error_id to error message. */ char *MsgStrings[] = { "", "No automap available in town", @@ -140,7 +146,7 @@ void DrawDiabloMsg() for (i = 0; i < len; i++) { c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; if (c != '\0') { - CPrintString(off, c, COL_GOLD); + PrintChar(off, c, COL_GOLD); } off += fontkern[c] + 1; } diff --git a/Source/error.h b/Source/error.h index c4a69c8b..770506b1 100644 --- a/Source/error.h +++ b/Source/error.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file error.h + * + * Interface of in-game message functions. + */ #ifndef __ERROR_H__ #define __ERROR_H__ diff --git a/Source/fault.cpp b/Source/fault.cpp index 72326f63..43e14f5e 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file fault.cpp + * + * Implementation of exception logging functionality. + */ +#include "all.h" LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; diff --git a/Source/fault.h b/Source/fault.h index 0dc743cb..4ed85ea1 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file fault.h + * + * Interface of exception logging functionality. + */ #ifndef __FAULT_H__ #define __FAULT_H__ diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index a6fe8363..a00bfa9c 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,10 +1,17 @@ -#include "diablo.h" + +/** + * @file gamemenu.cpp + * + * Implementation of the in-game menu functions. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef HELLFIRE BOOL jogging_opt = TRUE; #endif +/** Contains the game menu items of the single player menu. */ TMenuItem sgSingleMenu[6] = { // clang-format off // dwFlags, pszStr, fnMenu @@ -16,6 +23,7 @@ TMenuItem sgSingleMenu[6] = { { GMENU_ENABLED, NULL, NULL } // clang-format on }; +/** Contains the game menu items of the multi player menu. */ TMenuItem sgMultiMenu[5] = { // clang-format off // dwFlags, pszStr, fnMenu @@ -37,36 +45,39 @@ TMenuItem sgOptionsMenu[6] = { #else { GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_loadjog }, #endif - { GMENU_ENABLED , "Previous Menu", &j_gamemenu_previous }, + { GMENU_ENABLED , "Previous Menu", &gamemenu_previous }, { GMENU_ENABLED , NULL, NULL } // clang-format on }; +/** Specifies the menu names for music enabled and disabled. */ char *music_toggle_names[] = { "Music", "Music Disabled" }; +/** Specifies the menu names for sound enabled and disabled. */ char *sound_toggle_names[] = { "Sound", "Sound Disabled" }; #ifdef HELLFIRE char *jogging_toggle_names[] = { "Jog", "Walk", "Fast Walk" }; #endif #ifndef HELLFIRE +/** Specifies the menu names for colour cycling disabled and enabled. */ char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" }; #endif -void gamemenu_previous() +void gamemenu_on() { void (*proc)(TMenuItem *); TMenuItem *item; if (gbMaxPlayers == 1) { - proc = gamemenu_enable_single; + proc = gamemenu_update_single; item = sgSingleMenu; } else { - proc = gamemenu_enable_multi; + proc = gamemenu_update_multi; item = sgMultiMenu; } - gmenu_call_proc(item, proc); + gmenu_set_items(item, proc); PressEscKey(); } -void gamemenu_enable_single(TMenuItem *pMenuItems) +void gamemenu_update_single(TMenuItem *pMenuItems) { BOOL enable; @@ -79,27 +90,27 @@ void gamemenu_enable_single(TMenuItem *pMenuItems) gmenu_enable(sgSingleMenu, enable); } -void gamemenu_enable_multi(TMenuItem *pMenuItems) +void gamemenu_update_multi(TMenuItem *pMenuItems) { gmenu_enable(&sgMultiMenu[2], deathflag); } void gamemenu_off() { - gmenu_call_proc(0, NULL); + gmenu_set_items(0, NULL); } void gamemenu_handle_previous() { - if (gmenu_exception()) + if (gmenu_is_active()) gamemenu_off(); else - gamemenu_previous(); + gamemenu_on(); } -void j_gamemenu_previous(BOOL bActivate) +void gamemenu_previous(BOOL bActivate) { - gamemenu_previous(); + gamemenu_on(); } void gamemenu_new_game(BOOL bActivate) @@ -196,7 +207,7 @@ void gamemenu_options(BOOL bActivate) #ifndef HELLFIRE gamemenu_get_color_cycling(); #endif - gmenu_call_proc(sgOptionsMenu, NULL); + gmenu_set_items(sgOptionsMenu, NULL); } void gamemenu_get_music() @@ -310,7 +321,7 @@ void gamemenu_sound_volume(BOOL bActivate) if (bActivate) { if (gbSoundOn) { gbSoundOn = FALSE; - FreeMonsterSnd(); + sound_stop(); sound_get_or_set_sound_volume(VOLUME_MIN); } else { gbSoundOn = TRUE; @@ -322,7 +333,7 @@ void gamemenu_sound_volume(BOOL bActivate) if (volume == VOLUME_MIN) { if (gbSoundOn) { gbSoundOn = FALSE; - FreeMonsterSnd(); + sound_stop(); } } else if (!gbSoundOn) { gbSoundOn = TRUE; diff --git a/Source/gamemenu.h b/Source/gamemenu.h index de7b930b..3ce5c498 100644 --- a/Source/gamemenu.h +++ b/Source/gamemenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gamemenu.h + * + * Interface of the in-game menu functions. + */ #ifndef __GAMEMENU_H__ #define __GAMEMENU_H__ @@ -6,12 +10,12 @@ extern BOOL jogging_opt; #endif -void gamemenu_previous(); -void gamemenu_enable_single(TMenuItem *pMenuItems); -void gamemenu_enable_multi(TMenuItem *pMenuItems); +void gamemenu_on(); +void gamemenu_update_single(TMenuItem *pMenuItems); +void gamemenu_update_multi(TMenuItem *pMenuItems); void gamemenu_off(); void gamemenu_handle_previous(); -void j_gamemenu_previous(BOOL bActivate); +void gamemenu_previous(BOOL bActivate); void gamemenu_new_game(BOOL bActivate); void gamemenu_quit_game(BOOL bActivate); void gamemenu_load_game(BOOL bActivate); diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 586314de..ba488e28 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file gendung.cpp + * + * Implementation of general dungeon generation code. + */ +#include "all.h" BYTE dungeon[DMAXX][DMAXY]; BYTE pdungeon[DMAXX][DMAXY]; @@ -15,15 +20,30 @@ BYTE *pLevelPieces; BYTE *pDungeonCels; BYTE *pSpeedCels; int SpeedFrameTbl[128][16]; +/** + * List of transparancy masks to use for dPieces + */ char block_lvid[2049]; int level_frame_count[MAXTILES]; int tile_defs[MAXTILES]; WORD level_frame_types[MAXTILES]; int level_frame_sizes[MAXTILES]; int nlevel_frames; +/** + * List of light blocking dPieces + */ BOOLEAN nBlockTable[2049]; +/** + * List of path blocking dPieces + */ BOOLEAN nSolidTable[2049]; +/** + * List of transparent dPieces + */ BOOLEAN nTransTable[2049]; +/** + * List of missile blocking dPieces + */ BOOLEAN nMissileTable[2049]; BOOLEAN nTrapTable[2049]; int dminx; @@ -38,10 +58,10 @@ BYTE setlvlnum; char setlvltype; int ViewX; int ViewY; -int scr_pix_width; -int scr_pix_height; -int dword_5C2FF8; -int dword_5C2FFC; +int ViewBX; +int ViewBY; +int ViewDX; +int ViewDY; ScrollStruct ScrollInfo; int LvlViewX; int LvlViewY; @@ -61,7 +81,7 @@ char dDead[MAXDUNX][MAXDUNY]; char dObject[MAXDUNX][MAXDUNY]; char dItem[MAXDUNX][MAXDUNY]; char dMissile[MAXDUNX][MAXDUNY]; -char dArch[MAXDUNX][MAXDUNY]; +char dSpecial[MAXDUNX][MAXDUNY]; int themeCount; THEME_LOC themeLoc[MAXTHEMES]; @@ -556,15 +576,15 @@ void SetDungeonMicros() SetSpeedCels(); if (zoomflag) { - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; } else { - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = ZOOM_HEIGHT / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = ZOOM_HEIGHT / 32; } } @@ -959,10 +979,10 @@ BOOL SkipThemeRoom(int x, int y) for (i = 0; i < themeCount; i++) { if (x >= themeLoc[i].x - 2 && x <= themeLoc[i].x + themeLoc[i].width + 2 && y >= themeLoc[i].y - 2 && y <= themeLoc[i].y + themeLoc[i].height + 2) - return 0; + return FALSE; } - return 1; + return TRUE; } void InitLevels() diff --git a/Source/gendung.h b/Source/gendung.h index 808ef8b5..3a34834b 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gendung.h + * + * Interface of general dungeon generation code. + */ #ifndef __GENDUNG_H__ #define __GENDUNG_H__ @@ -40,10 +44,10 @@ extern BYTE setlvlnum; extern char setlvltype; extern int ViewX; extern int ViewY; -extern int scr_pix_width; -extern int scr_pix_height; -extern int dword_5C2FF8; -extern int dword_5C2FFC; +extern int ViewBX; +extern int ViewBY; +extern int ViewDX; +extern int ViewDY; extern ScrollStruct ScrollInfo; extern int LvlViewX; extern int LvlViewY; @@ -63,7 +67,7 @@ extern char dDead[MAXDUNX][MAXDUNY]; extern char dObject[MAXDUNX][MAXDUNY]; extern char dItem[MAXDUNX][MAXDUNY]; extern char dMissile[MAXDUNX][MAXDUNY]; -extern char dArch[MAXDUNX][MAXDUNY]; +extern char dSpecial[MAXDUNX][MAXDUNY]; extern int themeCount; extern THEME_LOC themeLoc[MAXTHEMES]; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 485050ff..f970b13e 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file gmenu.cpp + * + * Implementation of the in-game navigation and interaction. + */ +#include "all.h" BYTE *optbar_cel; BOOLEAN mouseNavigation; @@ -17,6 +22,7 @@ BYTE *option_cel; BYTE *sgpLogo; int sgCurrentMenuIdx; +/** Maps from font index to bigtgold.cel frame number. */ const BYTE lfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -32,6 +38,8 @@ const BYTE lfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 0, 21, 0 }; + +/** Maps from bigtgold.cel frame number to character width. */ const BYTE lfontkern[56] = { 18, 33, 21, 26, 28, 19, 19, 26, 25, 11, 12, 25, 19, 34, 28, 32, 20, 32, 28, 20, @@ -95,12 +103,12 @@ void gmenu_init_menu() optbar_cel = LoadFileInMem("Data\\optbar.CEL", NULL); } -BOOL gmenu_exception() +BOOL gmenu_is_active() { return sgpCurrentMenu != 0; } -void gmenu_call_proc(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)) +void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)) { int i; @@ -262,7 +270,7 @@ int gmenu_get_lfont(TMenuItem *pItem) BOOL gmenu_presskeys(int vkey) { if (!sgpCurrentMenu) - return 0; + return FALSE; switch (vkey) { case VK_RETURN: if ((sgpCurrItem->dwFlags & GMENU_ENABLED) != 0) { @@ -272,7 +280,7 @@ BOOL gmenu_presskeys(int vkey) break; case VK_ESCAPE: PlaySFX(IS_TITLEMOV); - gmenu_call_proc(0, 0); + gmenu_set_items(0, 0); break; case VK_SPACE: return FALSE; @@ -319,7 +327,7 @@ BOOL gmenu_on_mouse_move() if (!mouseNavigation) return FALSE; - gmenu_valid_mouse_pos(&step); + gmenu_get_mouse_slider(&step); nSteps = (int)(sgpCurrItem->dwFlags & 0xFFF000) >> 12; step *= nSteps; step /= 256; @@ -330,19 +338,19 @@ BOOL gmenu_on_mouse_move() return TRUE; } -BOOLEAN gmenu_valid_mouse_pos(int *plOffset) +BOOLEAN gmenu_get_mouse_slider(int *plOffset) { *plOffset = 282; if (MouseX < 282 + PANEL_LEFT) { *plOffset = 0; - return 0; + return FALSE; } if (MouseX > 538 + PANEL_LEFT) { *plOffset = 256; - return 0; + return FALSE; } *plOffset = MouseX - 282 - PANEL_LEFT; - return 1; + return TRUE; } BOOL gmenu_left_mouse(BOOL isDown) @@ -387,7 +395,7 @@ BOOL gmenu_left_mouse(BOOL isDown) sgpCurrItem = pItem; PlaySFX(IS_TITLEMOV); if (pItem->dwFlags & GMENU_SLIDER) { - mouseNavigation = gmenu_valid_mouse_pos(&dummy); + mouseNavigation = gmenu_get_mouse_slider(&dummy); gmenu_on_mouse_move(); } else { sgpCurrItem->fnMenu(TRUE); diff --git a/Source/gmenu.h b/Source/gmenu.h index 997aaffe..8cdb3878 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file gmenu.h + * + * Interface of the in-game navigation and interaction. + */ #ifndef __GMENU_H__ #define __GMENU_H__ @@ -17,8 +21,8 @@ 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 *)); +BOOL gmenu_is_active(); +void gmenu_set_items(TMenuItem *pItem, void (*gmFunc)(TMenuItem *)); void gmenu_up_down(BOOL isDown); void gmenu_draw(); void gmenu_draw_menu_item(TMenuItem *pItem, int y); @@ -27,7 +31,7 @@ int gmenu_get_lfont(TMenuItem *pItem); BOOL gmenu_presskeys(int vkey); void gmenu_left_right(BOOL isRight); BOOL gmenu_on_mouse_move(); -BOOLEAN gmenu_valid_mouse_pos(int *plOffset); +BOOLEAN gmenu_get_mouse_slider(int *plOffset); BOOL gmenu_left_mouse(BOOL isDown); void gmenu_enable(TMenuItem *pMenuItem, BOOL enable); void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma); diff --git a/Source/help.cpp b/Source/help.cpp index 960c572e..60f5ca4e 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -1,8 +1,13 @@ -#include "diablo.h" +/** + * @file help.cpp + * + * Implementation of the in-game help text. + */ +#include "all.h" int help_select_line; int dword_634494; -int helpflag; +BOOL helpflag; int displayinghelp[22]; /* check, does nothing? */ int HelpTop; @@ -437,7 +442,7 @@ const char gszHelpText[] = { void InitHelp() { - helpflag = 0; + helpflag = FALSE; dword_634494 = 0; displayinghelp[0] = 0; } @@ -545,7 +550,7 @@ void DrawHelpLine(int always_0, int help_line_nr, char *text, char color) width += fontkern[c] + 1; if (c) { if (width <= 577) - CPrintString(off, c, color); + PrintChar(off, c, color); } off += fontkern[c] + 1; } @@ -554,7 +559,7 @@ void DrawHelpLine(int always_0, int help_line_nr, char *text, char color) void DisplayHelp() { help_select_line = 0; - helpflag = 1; + helpflag = TRUE; HelpTop = 5000; } diff --git a/Source/help.h b/Source/help.h index a96c5fb5..52fb3bf3 100644 --- a/Source/help.h +++ b/Source/help.h @@ -1,10 +1,14 @@ -//HEADER_GOES_HERE +/** + * @file help.h + * + * Interface of the in-game help text. + */ #ifndef __HELP_H__ #define __HELP_H__ extern int help_select_line; extern int dword_634494; -extern int helpflag; +extern BOOL helpflag; extern int displayinghelp[22]; extern int HelpTop; diff --git a/Source/init.cpp b/Source/init.cpp index 9921acb3..76d52695 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file init.cpp + * + * Implementation of routines for initializing the environment, disable screen saver, load MPQ. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" diff --git a/Source/init.h b/Source/init.h index aa5cd470..0114d717 100644 --- a/Source/init.h +++ b/Source/init.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file init.h + * + * Interface of routines for initializing the environment, disable screen saver, load MPQ. + */ #ifndef __INIT_H__ #define __INIT_H__ diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 9a46bd6d..2781c986 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -1,11 +1,18 @@ -#include "diablo.h" +/** + * @file interfac.cpp + * + * Implementation of load screens. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" void *sgpBackCel; int sgdwProgress; int progress_id; +/** The colour used for the progress bar as an index into the palette. */ const BYTE BarColor[3] = { 138, 43, 254 }; +/** The screen position of the top left corner of the progress bar. */ const int BarPos[3][2] = { { 53, 37 }, { 53, 421 }, { 53, 37 } }; void interface_msg_pump() @@ -47,7 +54,7 @@ void DrawCutscene() unlock_buf(1); force_redraw = 255; - scrollrt_draw_game_screen(0); + scrollrt_draw_game_screen(FALSE); } void DrawProgress(int screen_x, int screen_y, int progress_id) @@ -80,7 +87,7 @@ void ShowProgress(unsigned int uMsg) DrawCutscene(); PaletteFadeIn(8); IncProgress(); - stream_update(); + sound_init(); IncProgress(); switch (uMsg) { diff --git a/Source/interfac.h b/Source/interfac.h index 5049b2b1..a88a864e 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file interfac.h + * + * Interface of load screens. + */ #ifndef __INTERFAC_H__ #define __INTERFAC_H__ diff --git a/Source/inv.cpp b/Source/inv.cpp index 079a9572..dec30592 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1,10 +1,31 @@ -#include "diablo.h" +/** + * @file inv.cpp + * + * Implementation of player inventory. + */ +#include "all.h" BOOL invflag; BYTE *pInvCels; BOOL drawsbarflag; int sgdwLastTime; // check name +/** + * Maps from inventory slot to screen position. The inventory slots are + * arranged as follows: + * 00 01 + * 02 03 06 + * 07 08 19 20 13 14 + * 09 10 21 22 15 16 + * 11 12 23 24 17 18 + * 04 05 + * 25 26 27 28 29 30 31 32 33 34 + * 35 36 37 38 39 40 41 42 43 44 + * 45 46 47 48 49 50 51 52 53 54 + * 55 56 57 58 59 60 61 62 63 64 + * 65 66 67 68 69 70 71 72 + * @see graphics/inv/inventory.png + */ const InvXY InvRect[73] = { // clang-format off // X, Y @@ -85,7 +106,7 @@ const InvXY InvRect[73] = { }; /* data */ - +/** Specifies the starting inventory slots for placement of 2x2 items. */ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; void FreeInvGFX() @@ -698,7 +719,7 @@ void DrawInvBelt() && plr[myplr].SpdList[i]._itype != ITYPE_GOLD) { fi = i + 49; ff = fontframe[gbFontTransTbl[fi]]; - CPrintString(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1] - fontkern[ff] + 28, ff, 0); + PrintChar(InvRect[i + SLOTXY_BELT_FIRST].X + SCREEN_X + PitchTbl[InvRect[i + SLOTXY_BELT_FIRST].Y + SCREEN_Y - 1] - fontkern[ff] + 28, ff, 0); } } } @@ -1409,7 +1430,7 @@ void CheckInvPaste(int pnum, int mx, int my) plr[pnum].SpdList[ii] = plr[pnum].HoldItem; } else { cn = SwapItem(&plr[pnum].SpdList[ii], &plr[pnum].HoldItem); - if (plr[pnum].HoldItem._itype == 11) + if (plr[pnum].HoldItem._itype == ITYPE_GOLD) plr[pnum]._pGold = CalculateGold(pnum); } drawsbarflag = TRUE; @@ -1780,8 +1801,8 @@ void CheckBookLevel(int pnum) void CheckQuestItem(int pnum) { if (plr[pnum].HoldItem.IDidx == IDI_OPTAMULET) - quests[QTYPE_BLIND]._qactive = 3; - if (plr[pnum].HoldItem.IDidx == IDI_MUSHROOM && quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qvar1 == QS_MUSHSPAWNED) { + quests[Q_BLIND]._qactive = QUEST_DONE; + if (plr[pnum].HoldItem.IDidx == IDI_MUSHROOM && quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && quests[Q_MUSHROOM]._qvar1 == QS_MUSHSPAWNED) { #ifndef SPAWN sfxdelay = 10; if (plr[pnum]._pClass == PC_WARRIOR) { // BUGFIX: Voice for this quest might be wrong in MP @@ -1801,15 +1822,15 @@ void CheckQuestItem(int pnum) } #endif #endif - quests[QTYPE_BLKM]._qvar1 = QS_MUSHPICKED; + quests[Q_MUSHROOM]._qvar1 = QS_MUSHPICKED; } if (plr[pnum].HoldItem.IDidx == IDI_ANVIL) { - if (quests[QTYPE_ANVIL]._qactive == 1) { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; + if (quests[Q_ANVIL]._qactive == QUEST_INIT) { + quests[Q_ANVIL]._qactive = QUEST_ACTIVE; + quests[Q_ANVIL]._qvar1 = 1; } #ifndef SPAWN - if (quests[QTYPE_ANVIL]._qlog == 1) { + if (quests[Q_ANVIL]._qlog == 1) { sfxdelay = 10; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR89; @@ -1852,12 +1873,12 @@ void CheckQuestItem(int pnum) } #endif if (plr[pnum].HoldItem.IDidx == IDI_ROCK) { - if (quests[QTYPE_INFRA]._qactive == 1) { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; + if (quests[Q_ROCK]._qactive == QUEST_INIT) { + quests[Q_ROCK]._qactive = QUEST_ACTIVE; + quests[Q_ROCK]._qvar1 = 1; } #ifndef SPAWN - if (quests[QTYPE_INFRA]._qlog == 1) { + if (quests[Q_ROCK]._qlog == 1) { sfxdelay = 10; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR87; @@ -1879,7 +1900,7 @@ void CheckQuestItem(int pnum) #endif } if (plr[pnum].HoldItem.IDidx == IDI_ARMOFVAL) { - quests[QTYPE_BLOOD]._qactive = 3; + quests[Q_BLOOD]._qactive = QUEST_DONE; #ifndef SPAWN sfxdelay = 20; if (plr[myplr]._pClass == PC_WARRIOR) { @@ -1902,9 +1923,9 @@ void CheckQuestItem(int pnum) } #ifdef HELLFIRE if (plr[pnum].HoldItem.IDidx == IDI_MAPOFDOOM) { - quests[QTYPE_GRAVE]._qlog = 0; - quests[QTYPE_GRAVE]._qactive = 2; - quests[QTYPE_GRAVE]._qvar1 = 1; + quests[Q_GRAVE]._qlog = 0; + quests[Q_GRAVE]._qactive = 2; + quests[Q_GRAVE]._qvar1 = 1; sfxdelay = 10; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR79; @@ -2407,18 +2428,18 @@ int InvPutItem(int pnum, int x, int y) xp = cursmx; if (plr[pnum].HoldItem._iCurs == ICURS_RUNE_BOMB && xp >= 79 && xp <= 82 && yp >= 61 && yp <= 64) { NetSendCmdLocParam2(0, CMD_OPENHIVE, plr[pnum].WorldX, plr[pnum].WorldY, xx, yy); - quests[QTYPE_FARMER]._qactive = 3; + quests[Q_FARMER]._qactive = 3; if (gbMaxPlayers != 1) { - NetSendCmdQuest(TRUE, QTYPE_FARMER); + NetSendCmdQuest(TRUE, Q_FARMER); return -1; } return -1; } if (plr[pnum].HoldItem.IDidx == IDI_MAPOFDOOM && xp >= 35 && xp <= 38 && yp >= 20 && yp <= 24) { NetSendCmd(FALSE, CMD_OPENCRYPT); - quests[QTYPE_GRAVE]._qactive = 3; + quests[Q_GRAVE]._qactive = 3; if (gbMaxPlayers != 1) { - NetSendCmdQuest(TRUE, QTYPE_GRAVE); + NetSendCmdQuest(TRUE, Q_GRAVE); } return -1; } @@ -2441,8 +2462,8 @@ int InvPutItem(int pnum, int x, int y) if (currlevel == 21 && x == RowOfCornerStone && y == ColOfCornerStone) { CornerItemMaybe = item[ii]; InitQTextMsg(296); - quests[QTYPE_CORNSTN]._qlog = 0; - quests[QTYPE_CORNSTN]._qactive = 3; + quests[Q_CORNSTN]._qlog = 0; + quests[Q_CORNSTN]._qactive = 3; } #endif SetCursor_(CURSOR_HAND); @@ -2541,8 +2562,8 @@ int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, in if (currlevel == 21 && x == RowOfCornerStone && y == ColOfCornerStone) { CornerItemMaybe = item[ii]; InitQTextMsg(296); - quests[QTYPE_CORNSTN]._qlog = 0; - quests[QTYPE_CORNSTN]._qactive = 3; + quests[Q_CORNSTN]._qlog = 0; + quests[Q_CORNSTN]._qactive = 3; } #endif return ii; @@ -2760,23 +2781,23 @@ BOOL UseInvItem(int pnum, int cii) return TRUE; if (stextflag) return TRUE; - if (cii <= 5) + if (cii <= INVITEM_HAND_RIGHT) return FALSE; - if (cii <= 46) { - c = cii - 7; + if (cii <= INVITEM_INV_LAST) { + c = cii - INVITEM_INV_FIRST; Item = &plr[pnum].InvList[c]; speedlist = FALSE; } else { if (talkflag) return TRUE; - c = cii - 47; + c = cii - INVITEM_BELT_FIRST; Item = &plr[pnum].SpdList[c]; speedlist = TRUE; } switch (Item->IDidx) { - case 17: + case IDI_MUSHROOM: sfxdelay = 10; #ifndef SPAWN if (plr[pnum]._pClass == PC_WARRIOR) { @@ -2797,7 +2818,7 @@ BOOL UseInvItem(int pnum, int cii) } #endif return TRUE; - case 19: + case IDI_FUNGALTM: PlaySFX(IS_IBOOK); sfxdelay = 10; if (plr[pnum]._pClass == PC_WARRIOR) { diff --git a/Source/inv.h b/Source/inv.h index 4f229c14..89ce171c 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file inv.h + * + * Interface of player inventory. + */ #ifndef __INV_H__ #define __INV_H__ diff --git a/Source/itemdat.cpp b/Source/itemdat.cpp index 412d36dc..9a22e6bc 100644 --- a/Source/itemdat.cpp +++ b/Source/itemdat.cpp @@ -1,5 +1,11 @@ -#include "diablo.h" +/** + * @file itemdat.cpp + * + * Implementation of all item data. + */ +#include "all.h" +/** Contains the data related to each item ID. */ ItemDataStruct AllItemsList[] = { // clang-format off // iRnd, iClass, iLoc, iCurs, itype, iItemId, iName, iSName, iMinMLvl, iDurability, iMinDam, iMaxDam, iMinAC, iMaxAC, iMinStr, iMinMag, iMinDex, iFlags, iMiscId, iSpell, iUsable, iValue, iMaxValue @@ -203,6 +209,7 @@ ItemDataStruct AllItemsList[] = { // clang-format on }; +/** Contains the data related to each item prefix. */ const PLStruct PL_Prefix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal @@ -310,6 +317,7 @@ const PLStruct PL_Prefix[] = { // clang-format on }; +/** Contains the data related to each item suffix. */ const PLStruct PL_Suffix[] = { // clang-format off // PLName, PLPower, PLParam1, PLParam2, PLMinLvl, PLIType, PLGOE, PLDouble, PLOk, PLMinVal, PLMaxVal, PLMultVal @@ -458,6 +466,7 @@ const PLStruct PL_Suffix[] = { // clang-format on }; +/** Contains the data related to each unique item ID. */ const UItemStruct UniqueItemList[] = { // clang-format off // UIName, UIItemId, UIMinLvl, UINumPL, UIValue, UIPower1, UIParam1, UIParam2, UIPower2, UIParam3, UIParam4, UIPower3, UIParam5, UIParam6, UIPower4, UIParam7, UIParam8, UIPower5, UIParam9, UIParam10, UIPower6, UIParam11, UIParam12 diff --git a/Source/itemdat.h b/Source/itemdat.h index e84ce0c9..7d038985 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file itemdat.h + * + * Interface of all item data. + */ #ifndef __ITEMDAT_H__ #define __ITEMDAT_H__ diff --git a/Source/items.cpp b/Source/items.cpp index 4b4343bd..b4175ba3 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file items.cpp + * + * Implementation of item functionality. + */ +#include "all.h" #ifdef HELLFIRE #include "../3rdParty/Storm/Source/storm.h" #endif @@ -581,14 +586,14 @@ void InitItems() GetItemAttrs(0, IDI_GOLD, 1); golditem = item[0]; - golditem._iStatFlag = 1; + golditem._iStatFlag = TRUE; numitems = 0; for (i = 0; i < MAXITEMS; i++) { item[i]._itype = ITYPE_MISC; item[i]._ix = 0; item[i]._iy = 0; - item[i]._iAnimFlag = 0; + item[i]._iAnimFlag = FALSE; item[i]._iSelFlag = 0; item[i]._iIdentified = FALSE; item[i]._iPostDraw = FALSE; @@ -601,9 +606,9 @@ void InitItems() if (!setlevel) { s = GetRndSeed(); /* unused */ - if (QuestStatus(QTYPE_INFRA)) + if (QuestStatus(Q_ROCK)) SpawnRock(); - if (QuestStatus(QTYPE_ANVIL)) + if (QuestStatus(Q_ANVIL)) SpawnQuestItem(IDI_ANVIL, 2 * setpc_x + 27, 2 * setpc_y + 27, 0, 1); #ifdef HELLFIRE if (UseCowFarmer && currlevel == 20) @@ -638,7 +643,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx) int btohit = 0; // bonus chance to hit int bac = 0; // bonus accuracy - int iflgs = 0; // item_special_effect flags + int iflgs = ISPL_NONE; // item_special_effect flags int sadd = 0; // added strength int madd = 0; // added magic @@ -1607,7 +1612,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood) #ifndef HELLFIRE if (!random_(17, 4)) { - GetItemPower(i, lvl >> 1, lvl, 256, onlygood); + GetItemPower(i, lvl >> 1, lvl, PLT_STAFF, onlygood); } else #endif { @@ -2219,19 +2224,19 @@ void GetItemBonus(int i, int idata, int minlvl, int maxlvl, BOOL onlygood) case ITYPE_SWORD: case ITYPE_AXE: case ITYPE_MACE: - GetItemPower(i, minlvl, maxlvl, 0x1000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_WEAP, onlygood); break; case ITYPE_BOW: - GetItemPower(i, minlvl, maxlvl, 0x10, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_BOW, onlygood); break; case ITYPE_SHIELD: - GetItemPower(i, minlvl, maxlvl, 0x10000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_SHLD, onlygood); break; case ITYPE_LARMOR: case ITYPE_HELM: case ITYPE_MARMOR: case ITYPE_HARMOR: - GetItemPower(i, minlvl, maxlvl, 0x100000, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_ARMO, onlygood); break; case ITYPE_STAFF: #ifdef HELLFIRE @@ -2245,7 +2250,7 @@ void GetItemBonus(int i, int idata, int minlvl, int maxlvl, BOOL onlygood) break; case ITYPE_RING: case ITYPE_AMULET: - GetItemPower(i, minlvl, maxlvl, 1, onlygood); + GetItemPower(i, minlvl, maxlvl, PLT_MISC, onlygood); break; } } @@ -2342,7 +2347,7 @@ int RndUItem(int m) okflag = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) okflag = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) okflag = FALSE; if (AllItemsList[i].iMiscId == IMISC_BOOK) okflag = TRUE; @@ -2453,7 +2458,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate) if (!numu) return -1; - random_(29, 10); + random_(29, 10); /// BUGFIX: unused, last unique in array always gets chosen idata = 0; while (numu > 0) { if (uok[idata]) @@ -2584,8 +2589,13 @@ void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE) ItemRndDur(ii); } else { - if (item[ii]._iLoc != ILOC_UNEQUIPABLE) - GetUniqueItem(ii, iseed); + if (item[ii]._iLoc != ILOC_UNEQUIPABLE) { + //uid = CheckUnique(ii, iblvl, uper, recreate); + //if (uid != UITYPE_INVALID) { + // GetUniqueItem(ii, uid); + //} + GetUniqueItem(ii, iseed); // BUG: the second argument to GetUniqueItem should be uid. + } } SetupItem(ii); } @@ -2601,7 +2611,7 @@ void SpawnItem(int m, int x, int y, BOOL sendmsg) return; } onlygood = 1; - } else if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 != QS_MUSHGIVEN) { + } else if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 != QS_MUSHGIVEN) { idx = RndItem(m); if (!idx) return; @@ -2614,7 +2624,7 @@ void SpawnItem(int m, int x, int y, BOOL sendmsg) } } else { idx = IDI_BRAIN; - quests[QTYPE_BLKM]._qvar1 = QS_BRAINSPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_BRAINSPAWNED; } if (numitems < MAXITEMS) { @@ -3939,7 +3949,7 @@ void PrintUString(int x, int y, BOOL cjustflag, char *str, int col) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } @@ -4203,7 +4213,7 @@ void UseItem(int p, int Mid, int spl) switch (Mid) { case IMISC_HEAL: - case IMISC_HEAL_1C: + case IMISC_MEAT: j = plr[p]._pMaxHP >> 8; l = ((j >> 1) + random_(39, j)) << 6; if (plr[p]._pClass == PC_WARRIOR) @@ -4441,7 +4451,7 @@ BOOL SmithItemOk(int i) rv = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) rv = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) rv = FALSE; #ifdef HELLFIRE if (AllItemsList[i].itype == ITYPE_STAFF && AllItemsList[i].iSpell) @@ -4553,7 +4563,7 @@ BOOL PremiumItemOk(int i) rv = TRUE; #ifdef HELLFIRE - if (AllItemsList[i].itype == ITYPE_MISC || AllItemsList[i].itype == ITYPE_GOLD || AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MISC || AllItemsList[i].itype == ITYPE_GOLD || AllItemsList[i].itype == ITYPE_MEAT) rv = FALSE; if (gbMaxPlayers != 1) { @@ -4565,7 +4575,7 @@ BOOL PremiumItemOk(int i) rv = FALSE; if (AllItemsList[i].itype == ITYPE_GOLD) rv = FALSE; - if (AllItemsList[i].itype == ITYPE_0E) + if (AllItemsList[i].itype == ITYPE_MEAT) rv = FALSE; if (AllItemsList[i].itype == ITYPE_STAFF) rv = FALSE; @@ -4773,15 +4783,15 @@ void SpawnWitch(int lvl) GetItemAttrs(0, IDI_MANA, 1); witchitem[0] = item[0]; witchitem[0]._iCreateInfo = lvl; - witchitem[0]._iStatFlag = 1; + witchitem[0]._iStatFlag = TRUE; GetItemAttrs(0, IDI_FULLMANA, 1); witchitem[1] = item[0]; witchitem[1]._iCreateInfo = lvl; - witchitem[1]._iStatFlag = 1; + witchitem[1]._iStatFlag = TRUE; GetItemAttrs(0, IDI_PORTAL, 1); witchitem[2] = item[0]; witchitem[2]._iCreateInfo = lvl; - witchitem[2]._iStatFlag = 1; + witchitem[2]._iStatFlag = TRUE; iCnt = random_(51, 8) + 10; for (i = 3; i < iCnt; i++) { diff --git a/Source/items.h b/Source/items.h index 52a9591e..d410293d 100644 --- a/Source/items.h +++ b/Source/items.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file items.h + * + * Interface of item functionality. + */ #ifndef __ITEMS_H__ #define __ITEMS_H__ diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 03e631fe..c4c5e7a4 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file lighting.cpp + * + * Implementation of light and vision. + */ +#include "all.h" LightListStruct VisionList[MAXVISION]; BYTE lightactive[MAXLIGHTS]; @@ -14,28 +19,29 @@ int visionid; BYTE *pLightTbl; BOOL lightflag; -// CrawlTable specifies X- and Y-coordinate deltas from a missile target -// coordinate. -// -// n=4 -// -// y -// ^ -// | 1 -// | 3#4 -// | 2 -// +-----> x -// -// n=16 -// -// y -// ^ -// | 314 -// | B7 8C -// | F # G -// | D9 AE -// | 526 -// +-------> x +/** + * CrawlTable specifies X- and Y-coordinate deltas from a missile target coordinate. + * + * n=4 + * + * y + * ^ + * | 1 + * | 3#4 + * | 2 + * +-----> x + * + * n=16 + * + * y + * ^ + * | 314 + * | B7 8C + * | F # G + * | D9 AE + * | 526 + * +-------> x + */ char CrawlTable[2749] = { 1, 0, 0, @@ -400,8 +406,7 @@ char CrawlTable[2749] = { -18, -1, 18, -1, -18, 0, 18, 0 }; -// pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from -// the center of a circle. +/** pCrawlTable maps from circle radius to the X- and Y-coordinate deltas from the center of a circle. */ char *pCrawlTable[19] = { CrawlTable, CrawlTable + 3, @@ -423,6 +428,7 @@ char *pCrawlTable[19] = { CrawlTable + 2187, CrawlTable + 2460 }; +/** vCrawlTable specifies the X- Y-coordinate offsets of lighting visions. */ 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 }, @@ -448,28 +454,29 @@ BYTE 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 } }; -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 }, - { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } - }; +/** unused */ +BYTE byte_49463C[18][18] = { + { 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 }, + { 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 } +}; +/** RadiusAdj maps from vCrawlTable index to lighting vision radius adjustment. */ 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) diff --git a/Source/lighting.h b/Source/lighting.h index 5b593423..ac4b1278 100644 --- a/Source/lighting.h +++ b/Source/lighting.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file lighting.h + * + * Interface of light and vision. + */ #ifndef __LIGHTING_H__ #define __LIGHTING_H__ diff --git a/Source/list.h b/Source/list.h index 154f9bec..7a2c35fc 100644 --- a/Source/list.h +++ b/Source/list.h @@ -1,4 +1,6 @@ -/* Intrusive double-linked list implementation, +/** + * @file list.h + * Intrusive double-linked list implementation, * based on https://github.com/webcoyote/coho/blob/master/Base/List.h */ @@ -7,22 +9,22 @@ #define OBJECT_NAME(obj) (((const char *)&typeid(obj)) + 8) /****************************************************************************** -* -* List definition macros -* -***/ + * + * List definition macros + * + ***/ -// Define a field within a structure that will be used to link it into a list +/** Define a field within a structure that will be used to link it into a list */ #define LIST_LINK(T) TLink template class TLink; /****************************************************************************** -* -* TList -* -***/ + * + * TList + * + ***/ //============================================================================= template @@ -159,10 +161,10 @@ void TList::UnlinkAll() } /****************************************************************************** -* -* TLink -* -***/ + * + * TLink + * + ***/ //============================================================================= template diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 9d815bb3..946517f2 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file loadsave.cpp + * + * Implementation of save game functionality. + */ +#include "all.h" BYTE *tbuff; diff --git a/Source/loadsave.h b/Source/loadsave.h index 71309f5f..376d4af3 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file loadsave.h + * + * Interface of save game functionality. + */ #ifndef __LOADSAVE_H__ #define __LOADSAVE_H__ diff --git a/Source/logging.cpp b/Source/logging.cpp index 9b935dae..f039182a 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file logging.cpp + * + * Implementation of logging functionality. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifdef __cplusplus @@ -11,7 +16,9 @@ DWORD nNumberOfBytesToWrite; /* data */ -BOOL log_not_created = 1; +/** Has the log file not yet been created. */ +BOOL log_not_created = TRUE; +/** Handle to the log file. */ HANDLE log_file = INVALID_HANDLE_VALUE; void __cdecl log_flush(BOOL force_close) diff --git a/Source/logging.h b/Source/logging.h index 13b0ec7c..b88d8e42 100644 --- a/Source/logging.h +++ b/Source/logging.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file logging.h + * + * Interface of logging functionality. + */ #ifndef __LOGGING_H__ #define __LOGGING_H__ diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 6323001f..444747dc 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file mainmenu.cpp + * + * Implementation of functions for interacting with the main menu. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -6,6 +11,7 @@ char gszHero[16]; /* data */ +/** The active music track id for the main menu. */ int menu_music_track_id = TMUSIC_INTRO; void mainmenu_refresh_music() diff --git a/Source/mainmenu.h b/Source/mainmenu.h index c2bc0dd6..dc0ddb34 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file mainmenu.h + * + * Interface of functions for interacting with the main menu. + */ #ifndef __MAINMENU_H__ #define __MAINMENU_H__ diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 0a250b00..54ca65f1 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file minitext.cpp + * + * Implementation of scrolling dialog text. + */ +#include "all.h" int qtexty; char *qtextptr; @@ -9,6 +14,7 @@ int sgLastScroll; BYTE *pMedTextCels; BYTE *pTextBoxCels; +/** Maps from font index to medtexts.cel frame number. */ const BYTE mfontframe[127] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -24,6 +30,11 @@ const BYTE mfontframe[127] = { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 48, 0, 49, 0 }; +/** + * Maps from medtexts.cel frame number to character width. Note, the + * character width may be distinct from the frame width, which is 22 for every + * medtexts.cel frame. + */ const BYTE mfontkern[56] = { 5, 15, 10, 13, 14, 10, 9, 13, 11, 5, 5, 11, 10, 16, 13, 16, 10, 15, 12, 10, @@ -36,7 +47,8 @@ const BYTE mfontkern[56] = { /* data */ /** - * Positive numbers will delay scrolling 1 out of n frames, negative numbers will scroll 1+(-n) pixels. + * Text scroll speeds. Positive numbers will delay scrolling 1 out of n frames, + * negative numbers will scroll 1+(-n) pixels. */ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; diff --git a/Source/minitext.h b/Source/minitext.h index 3be2aeea..568e51b6 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file minitext.h + * + * Interface of scrolling dialog text. + */ #ifndef __MINITEXT_H__ #define __MINITEXT_H__ diff --git a/Source/misdat.cpp b/Source/misdat.cpp index cd8f52bc..ef309466 100644 --- a/Source/misdat.cpp +++ b/Source/misdat.cpp @@ -1,5 +1,11 @@ -#include "diablo.h" +/** + * @file misdat.cpp + * + * Implementation of data related to missiles. + */ +#include "all.h" +/** Data related to each missile ID. */ MissileData missiledata[] = { // clang-format off // mName, mAddProc, mProc, mDraw, mType, mResist, mFileNum, miSFX, mlSFX; @@ -53,7 +59,7 @@ MissileData missiledata[] = { #ifdef HELLFIRE { MIS_BLODBOIL, &miss_null_1F, &MI_Blodboil, FALSE, 1, 0, MFILE_NONE, -1, -1 }, #else - { MIS_BLODBOIL, &miss_null_1F, &MI_Blodboil, TRUE, 1, 0, MFILE_NONE, -1, LS_BLODBOIL }, + { MIS_BLODBOIL, &AddBlodboil, &MI_Blodboil, TRUE, 1, 0, MFILE_NONE, -1, LS_BLODBOIL }, #endif { MIS_APOCA, &AddApoca, &MI_Apoca, TRUE, 1, MISR_MAGIC, MFILE_NEWEXP, LS_APOC, -1 }, { MIS_REPAIR, &AddRepair, &MI_Dummy, FALSE, 2, 0, MFILE_NONE, -1, -1 }, @@ -124,6 +130,7 @@ MissileData missiledata[] = { // clang-format on }; +/** Data related to each missile graphic ID. */ MisFileData misfiledata[] = { // clang-format off // mAnimName, mAnimFAmt, mName, mFlags, mAnimData[16], mAnimDelay[16], mAnimLen[16], mAnimWidth[16], mAnimWidth2[16] diff --git a/Source/misdat.h b/Source/misdat.h index d32f8173..bab38abd 100644 --- a/Source/misdat.h +++ b/Source/misdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file misdat.h + * + * Interface of data related to missiles. + */ #ifndef __MISDAT_H__ #define __MISDAT_H__ diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 9b55420b..a01d5593 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file missiles.cpp + * + * Implementation of missile functionality. + */ +#include "all.h" int missileactive[MAXMISSILES]; int missileavail[MAXMISSILES]; @@ -9,7 +14,9 @@ ChainStruct chain[MAXMISSILES]; BOOL MissilePreFlag; int numchains; +/** Maps from direction to X-offset. */ int XDirAdd[8] = { 1, 0, -1, -1, -1, 0, 1, 1 }; +/** Maps from direction to Y-offset. */ int YDirAdd[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; #ifdef HELLFIRE int CrawlNum[19] = { 0, 3, 12, 45, 94, 159, 240, 337, 450, 579, 724, 885, 1062, 1255, 1464, 1689, 1930, 2187, 2460 }; @@ -664,10 +671,10 @@ BOOL MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, BOOLE return ret; #ifdef _DEBUG if (hit >= hper && !debug_mode_key_inverted_v && !debug_mode_dollar_sign) - return 0; + return FALSE; #else if (hit >= hper) - return 0; + return FALSE; #endif if (t == MIS_BONESPIRIT) { dam = monster[m]._mhitpoints / 3 >> 6; @@ -999,7 +1006,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, { int oi; - if (missile[i]._miAnimType != 4 && missile[i]._misource != -1) { + if (missile[i]._miAnimType != MFILE_FIREWAL && missile[i]._misource != -1) { if (!missile[i]._micaster) { if (dMonster[mx][my] > 0) { if (MonsterMHit( @@ -1016,7 +1023,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, } } else { if (dMonster[mx][my] < 0 - && monster[-(dMonster[mx][my] + 1)]._mmode == 15 + && monster[-(dMonster[mx][my] + 1)]._mmode == MM_STONE && MonsterMHit( missile[i]._misource, -(dMonster[mx][my] + 1), @@ -1070,7 +1077,7 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my, } } else { if (dMonster[mx][my] > 0) { - if (missile[i]._miAnimType == 4) { + if (missile[i]._miAnimType == MFILE_FIREWAL) { if (MonsterMHit( missile[i]._misource, dMonster[mx][my] - 1, @@ -1177,12 +1184,13 @@ void InitMissileGFX() void FreeMissileGFX(int mi) { int i; - DWORD *pFrameTable; + DWORD *p; if (misfiledata[mi].mFlags & MFLAG_ALLOW_SPECIAL) { if (misfiledata[mi].mAnimData[0]) { - pFrameTable = (DWORD *)misfiledata[mi].mAnimData[0]; - mem_free_dbg(&pFrameTable[-misfiledata[mi].mAnimFAmt]); // TODO find a cleaner way to access the offeset + p = (DWORD *)misfiledata[mi].mAnimData[0]; + p -= misfiledata[mi].mAnimFAmt; + MemFreeDbg(p); misfiledata[mi].mAnimData[0] = NULL; } return; @@ -1190,9 +1198,7 @@ void FreeMissileGFX(int mi) for (i = 0; i < misfiledata[mi].mAnimFAmt; i++) { if (misfiledata[mi].mAnimData[i]) { - pFrameTable = (DWORD *)misfiledata[mi].mAnimData[i]; - misfiledata[mi].mAnimData[i] = NULL; - mem_free_dbg(pFrameTable); + MemFreeDbg(misfiledata[mi].mAnimData[i]); } } } @@ -1973,31 +1979,6 @@ void missiles_hbolt_arrow(int mi, int sx, int sy, int dx, int dy, int midir, cha missile[mi]._miVar2 = sy; missile[mi]._mlid = AddLight(sx, sy, 8); } - -void AddBlodboil(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) -{ - int lvl; - - if (id == -1 || plr[id]._pSpellFlags & 6 || plr[id]._pHitPoints <= plr[id]._pLevel << 6) { - missile[mi]._miDelFlag = TRUE; - } else { - int blodboilSFX[NUM_CLASSES] = { PS_WARR70, PS_ROGUE70, PS_MAGE70, PS_MAGE70, PS_ROGUE70, PS_WARR70 }; // BUGFIX: change second PS_MAGE70 to PS_MONK70? - UseMana(id, 22); - missile[mi]._miVar1 = id; - int tmp = 3 * plr[id]._pLevel; - tmp <<= 7; - plr[id]._pSpellFlags |= 2u; - missile[mi]._miVar2 = tmp; - if (2 * (id > 0)) - lvl = plr[id]._pLevel; - else - lvl = 1; - missile[mi]._mirange = lvl + 10 * missile[mi]._mispllvl + 245; - CalcPlrItemVals(id, TRUE); - force_redraw = 255; - PlaySfxLoc(blodboilSFX[plr[id]._pClass], plr[id].WorldX, plr[id].WorldY); - } -} #endif void AddLArrow(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) @@ -3085,6 +3066,35 @@ void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, in missile[mi]._mirange = 1; } +void AddBlodboil(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) +{ +#ifdef HELLFIRE + int lvl; + + if (id == -1 || plr[id]._pSpellFlags & 6 || plr[id]._pHitPoints <= plr[id]._pLevel << 6) { + missile[mi]._miDelFlag = TRUE; + } else { + int blodboilSFX[NUM_CLASSES] = { PS_WARR70, PS_ROGUE70, PS_MAGE70, PS_MAGE70, PS_ROGUE70, PS_WARR70 }; // BUGFIX: change second PS_MAGE70 to PS_MONK70? + UseMana(id, 22); + missile[mi]._miVar1 = id; + int tmp = 3 * plr[id]._pLevel; + tmp <<= 7; + plr[id]._pSpellFlags |= 2u; + missile[mi]._miVar2 = tmp; + if (2 * (id > 0)) + lvl = plr[id]._pLevel; + else + lvl = 1; + missile[mi]._mirange = lvl + 10 * missile[mi]._mispllvl + 245; + CalcPlrItemVals(id, TRUE); + force_redraw = 255; + PlaySfxLoc(blodboilSFX[plr[id]._pClass], plr[id].WorldX, plr[id].WorldY); + } +#else + missile[mi]._miDelFlag = 1; +#endif +} + void AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam) { missile[mi]._miDelFlag = TRUE; @@ -3363,7 +3373,7 @@ int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micas missile[mi]._mispllvl = spllvl; missile[mi]._mimfnum = midir; - if (missile[mi]._miAnimType == 255 || misfiledata[missile[mi]._miAnimType].mAnimFAmt < 8) + if (missile[mi]._miAnimType == MFILE_NONE || misfiledata[missile[mi]._miAnimType].mAnimFAmt < 8) SetMissDir(mi, 0); else SetMissDir(mi, midir); @@ -4982,17 +4992,18 @@ void MI_Stone(int i) } if (monster[m]._mmode != MM_STONE) { missile[i]._miDelFlag = TRUE; - } else { - if (!missile[i]._mirange) { - missile[i]._miDelFlag = TRUE; - if (monster[m]._mhitpoints > 0) - monster[m]._mmode = missile[i]._miVar1; - else - AddDead(monster[m]._mx, monster[m]._my, stonendx, (direction)monster[m]._mdir); - } - if (missile[i]._miAnimType == MFILE_SHATTER1) - PutMissile(i); + return; } + + if (!missile[i]._mirange) { + missile[i]._miDelFlag = TRUE; + if (monster[m]._mhitpoints > 0) + monster[m]._mmode = missile[i]._miVar1; + else + AddDead(monster[m]._mx, monster[m]._my, stonendx, (direction)monster[m]._mdir); + } + if (missile[i]._miAnimType == MFILE_SHATTER1) + PutMissile(i); } void MI_Boom(int i) diff --git a/Source/missiles.h b/Source/missiles.h index dc524b32..b5d9c871 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file missiles.h + * + * Interface of missile functionality. + */ #ifndef __MISSILES_H__ #define __MISSILES_H__ @@ -112,6 +116,7 @@ void AddFirewallC(int mi, int sx, int sy, int dx, int dy, int midir, char mienem void AddInfra(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddWave(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddNova(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); +void AddBlodboil(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddRepair(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddRecharge(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); void AddDisarm(int mi, int sx, int sy, int dx, int dy, int midir, char mienemy, int id, int dam); diff --git a/Source/monstdat.cpp b/Source/monstdat.cpp index 10c5b38c..1c08a34c 100644 --- a/Source/monstdat.cpp +++ b/Source/monstdat.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file monstdat.cpp + * + * Implementation of all monster data. + */ +#include "all.h" MonsterData monsterdata[] = { // clang-format off @@ -365,16 +370,16 @@ BYTE MonstAvailTbl[] = { UniqMonstStruct UniqMonst[] = { // clang-format off - // mtype, mName, mTrnName, mlevel, mmaxhp, mAi, mint, mMinDamage, mMaxDamage, mMagicRes, mUnqAttr, mUnqVar1, mUnqVar2, mtalkmsg - { MT_NGOATMC, "Gharbad the Weak", "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_GARBUD1 }, + // mtype, mName, mTrnName, mlevel, mmaxhp, mAi, mint, mMinDamage, mMaxDamage, mMagicRes, mUnqAttr, mUnqVar1, mUnqVar2, mtalkmsg + { MT_NGOATMC, "Gharbad the Weak", "BSDB", 4, 120, AI_GARBUD, 3, 8, 16, IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_GARBUD1 }, { MT_SKING, "Skeleton King", "GENRL", 0, 240, AI_SKELKING, 3, 6, 16, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 1, 0, 0, 0 }, - { MT_COUNSLR, "Zhar the Mad", "GENERAL", 8, 360, AI_ZHAR, 3, 16, 40, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, QUEST_ZHAR1 }, - { MT_BFALLSP, "Snotspill", "BNG", 4, 220, AI_SNOTSPIL, 3, 10, 18, RESIST_LIGHTNING , 0, 0, 0, QUEST_BANNER10 }, - { MT_ADVOCATE, "Arch-Bishop Lazarus", "GENERAL", 0, 600, AI_LAZURUS, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_HLSPWN, "Red Vex", "REDV", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_HLSPWN, "BlackJade", "BLKJD", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_VILE13 }, - { MT_RBLACK, "Lachdanan", "BHKA", 14, 500, AI_LACHDAN, 3, 0, 0, 0 , 0, 0, 0, QUEST_VEIL9 }, - { MT_BTBLACK, "Warlord of Blood", "GENERAL", 13, 850, AI_WARLORD, 3, 35, 50, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, QUEST_WARLRD9 }, + { MT_COUNSLR, "Zhar the Mad", "GENERAL", 8, 360, AI_ZHAR, 3, 16, 40, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, TEXT_ZHAR1 }, + { MT_BFALLSP, "Snotspill", "BNG", 4, 220, AI_SNOTSPIL, 3, 10, 18, RESIST_LIGHTNING , 0, 0, 0, TEXT_BANNER10 }, + { MT_ADVOCATE, "Arch-Bishop Lazarus", "GENERAL", 0, 600, AI_LAZURUS, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_HLSPWN, "Red Vex", "REDV", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_FIRE | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_HLSPWN, "BlackJade", "BLKJD", 0, 400, AI_LAZHELP, 3, 30, 50, IMUNE_MAGIC | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_VILE13 }, + { MT_RBLACK, "Lachdanan", "BHKA", 14, 500, AI_LACHDAN, 3, 0, 0, 0 , 0, 0, 0, TEXT_VEIL9 }, + { MT_BTBLACK, "Warlord of Blood", "GENERAL", 13, 850, AI_WARLORD, 3, 35, 50, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, TEXT_WARLRD9 }, { MT_CLEAVER, "The Butcher", "GENRL", 0, 220, AI_CLEAVER, 3, 6, 12, RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 0, 0, 0, 0 }, #ifdef HELLFIRE { MT_HORKDMN, "Hork Demon", "GENRL", 19, 300, AI_HORKDMN, 3, 20, 35, RESIST_LIGHTNING , 0, 0, 0, 0 }, @@ -382,9 +387,9 @@ UniqMonstStruct UniqMonst[] = { { MT_NAKRUL, "Na-Krul", "GENRL", 0, 1332, AI_SKELSD, 3, 40, 50, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_LIGHTNING | IMUNE_NULL_40, 3, 0, 0, 0 }, #endif { MT_TSKELAX, "Bonehead Keenaxe", "BHKA", 2, 91, AI_SKELSD, 2, 4, 10, IMUNE_MAGIC | IMUNE_NULL_40, 7, 100, 0, 0 }, - { MT_RFALLSD, "Bladeskin the Slasher", "BSTS", 2, 51, AI_FALLEN, 0, 6, 18, RESIST_FIRE , 11, 45, 0, 0 }, - { MT_NZOMBIE, "Soulpus", "GENERAL", 2, 133, AI_ZOMBIE, 0, 4, 8, RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, 0 }, - { MT_RFALLSP, "Pukerat the Unclean", "PTU", 2, 77, AI_FALLEN, 3, 1, 5, RESIST_FIRE , 0, 0, 0, 0 }, + { MT_RFALLSD, "Bladeskin the Slasher", "BSTS", 2, 51, AI_FALLEN, 0, 6, 18, RESIST_FIRE , 11, 45, 0, 0 }, + { MT_NZOMBIE, "Soulpus", "GENERAL", 2, 133, AI_ZOMBIE, 0, 4, 8, RESIST_FIRE | RESIST_LIGHTNING , 0, 0, 0, 0 }, + { MT_RFALLSP, "Pukerat the Unclean", "PTU", 2, 77, AI_FALLEN, 3, 1, 5, RESIST_FIRE , 0, 0, 0, 0 }, { MT_WSKELAX, "Boneripper", "BR", 2, 54, AI_BAT, 0, 6, 15, IMUNE_MAGIC | IMUNE_FIRE | IMUNE_NULL_40, 3, 0, 0, 0 }, { MT_NZOMBIE, "Rotfeast the Hungry", "ETH", 2, 85, AI_SKELSD, 3, 4, 12, IMUNE_MAGIC | IMUNE_NULL_40, 3, 0, 0, 0 }, { MT_DFALLSD, "Gutshank the Quick", "GTQ", 3, 66, AI_BAT, 2, 6, 16, RESIST_FIRE , 3, 0, 0, 0 }, @@ -419,7 +424,7 @@ UniqMonstStruct UniqMonst[] = { { MT_GARGOYLE, "Nightwing the Cold", "GENERAL", 7, 342, AI_BAT, 1, 18, 26, IMUNE_MAGIC | RESIST_LIGHTNING | IMUNE_NULL_40, 3, 0, 0, 0 }, { MT_GGOATBW, "Gorestone", "GENERAL", 7, 303, AI_GOATBOW, 1, 15, 28, RESIST_LIGHTNING | IMUNE_NULL_40, 7, 70, 0, 0 }, { MT_BMAGMA, "Bronzefist Firestone", "GENERAL", 8, 360, AI_MAGMA, 0, 30, 36, IMUNE_MAGIC | RESIST_FIRE , 3, 0, 0, 0 }, - { MT_INCIN, "Wrathfire the Doomed", "WFTD", 8, 270, AI_SKELSD, 2, 20, 30, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 3, 0, 0, 0 }, + { MT_INCIN, "Wrathfire the Doomed", "WFTD", 8, 270, AI_SKELSD, 2, 20, 30, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING , 3, 0, 0, 0 }, { MT_NMAGMA, "Firewound the Grim", "BHKA", 8, 303, AI_MAGMA, 0, 18, 22, IMUNE_MAGIC | RESIST_FIRE , 3, 0, 0, 0 }, { MT_MUDMAN, "Baron Sludge", "BSM", 8, 315, AI_SNEAK, 3, 25, 34, IMUNE_MAGIC | RESIST_FIRE | RESIST_LIGHTNING | IMUNE_NULL_40, 11, 75, 0, 0 }, { MT_GGOATMC, "Blighthorn Steelmace", "BHSM", 7, 250, AI_RHINO, 0, 20, 28, RESIST_LIGHTNING , 11, 45, 0, 0 }, diff --git a/Source/monstdat.h b/Source/monstdat.h index 5a1d9baf..809a51eb 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file monstdat.h + * + * Interface of all monster data. + */ #ifndef __MONSTDAT_H__ #define __MONSTDAT_H__ diff --git a/Source/monster.cpp b/Source/monster.cpp index 56c88d92..bf8ecc91 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1,7 +1,12 @@ -#include "diablo.h" +/** + * @file monster.cpp + * + * Implementation of monster functionality, AI, actions, spawning, loading, etc. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" -// Tracks which missile files are already loaded +/** Tracks which missile files are already loaded */ int MissileFileFlag; // BUGFIX: replace monstkills[MAXMONSTERS] with monstkills[NUM_MTYPES]. @@ -63,7 +68,7 @@ int opposite[8] = { 4, 5, 6, 7, 0, 1, 2, 3 }; int offset_x[8] = { 1, 0, -1, -1, -1, 0, 1, 1 }; int offset_y[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; -/* unused */ +/** unused */ int rnd5[4] = { 5, 10, 15, 20 }; int rnd10[4] = { 10, 15, 20, 30 }; int rnd20[4] = { 20, 30, 40, 50 }; @@ -232,20 +237,20 @@ void GetLevelMTypes() #endif if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) + if (QuestStatus(Q_BUTCHER)) AddMonsterType(MT_CLEAVER, 2); - if (QuestStatus(QTYPE_GARB)) + if (QuestStatus(Q_GARBUD)) AddMonsterType(UniqMonst[UMT_GARBUD].mtype, 4); - if (QuestStatus(QTYPE_ZHAR)) + if (QuestStatus(Q_ZHAR)) AddMonsterType(UniqMonst[UMT_ZHAR].mtype, 4); - if (QuestStatus(QTYPE_BOL)) + if (QuestStatus(Q_LTBANNER)) AddMonsterType(UniqMonst[UMT_SNOTSPIL].mtype, 4); - if (QuestStatus(QTYPE_VEIL)) + if (QuestStatus(Q_VEIL)) AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 4); - if (QuestStatus(QTYPE_WARLRD)) + if (QuestStatus(Q_WARLORD)) AddMonsterType(UniqMonst[UMT_WARLORD].mtype, 4); - if (gbMaxPlayers != 1 && currlevel == quests[QTYPE_KING]._qlevel) { + if (gbMaxPlayers != 1 && currlevel == quests[Q_SKELKING]._qlevel) { AddMonsterType(MT_SKING, 4); @@ -640,7 +645,7 @@ void monster_some_crypt() if (currlevel == 24 && UberDiabloMonsterIndex >= 0 && UberDiabloMonsterIndex < nummonsters) { mon = &monster[UberDiabloMonsterIndex]; PlayEffect(UberDiabloMonsterIndex, 2); - quests[QTYPE_NAKRUL]._qlog = 0; + quests[Q_NAKRUL]._qlog = 0; mon->mArmorClass -= 50; hp = mon->_mmaxhp / 2; mon->mMagicRes = 0; @@ -831,7 +836,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize) if (Monst->_mAi == AI_LAZHELP) Monst->mtalkmsg = 0; #ifndef HELLFIRE - if (Monst->_mAi != AI_LAZURUS || quests[QTYPE_VB]._qvar1 <= 3) { + if (Monst->_mAi != AI_LAZURUS || quests[Q_BETRAYER]._qvar1 <= 3) { if (Monst->mtalkmsg) { Monst->_mgoal = MGOAL_INQUIRING; } @@ -914,11 +919,11 @@ void PlaceQuestMonsters() BYTE *setp; if (!setlevel) { - if (QuestStatus(QTYPE_BUTCH)) { + if (QuestStatus(Q_BUTCHER)) { PlaceUniqueMonst(UMT_BUTCHER, 0, 0); } - if (currlevel == quests[QTYPE_KING]._qlevel && gbMaxPlayers != 1) { + if (currlevel == quests[Q_SKELKING]._qlevel && gbMaxPlayers != 1) { skeltype = 0; for (skeltype = 0; skeltype < nummtypes; skeltype++) { @@ -930,40 +935,40 @@ void PlaceQuestMonsters() PlaceUniqueMonst(UMT_SKELKING, skeltype, 30); } - if (QuestStatus(QTYPE_BOL)) { + if (QuestStatus(Q_LTBANNER)) { setp = LoadFileInMem("Levels\\L1Data\\Banner1.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { setp = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL); SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - if (QuestStatus(QTYPE_ANVIL)) { + if (QuestStatus(Q_ANVIL)) { 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)) { + if (QuestStatus(Q_WARLORD)) { 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); } - if (QuestStatus(QTYPE_VEIL)) { + if (QuestStatus(Q_VEIL)) { AddMonsterType(UniqMonst[UMT_LACHDAN].mtype, 1); } - if (QuestStatus(QTYPE_ZHAR) && zharlib == -1) { - quests[QTYPE_ZHAR]._qactive = 0; + if (QuestStatus(Q_ZHAR) && zharlib == -1) { + quests[Q_ZHAR]._qactive = QUEST_NOTAVAIL; } - if (currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + if (currlevel == quests[Q_BETRAYER]._qlevel && gbMaxPlayers != 1) { AddMonsterType(UniqMonst[UMT_LAZURUS].mtype, 4); AddMonsterType(UniqMonst[UMT_RED_VEX].mtype, 4); PlaceUniqueMonst(UMT_LAZURUS, 0, 0); @@ -1031,7 +1036,7 @@ void PlaceGroup(int mtype, int num, int leaderf, int leader) } j = 0; - for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) { + for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) { /// BUGFIX: `yp += offset_y` if (!MonstPlace(xp, yp) || (dTransVal[xp][yp] != dTransVal[x1][y1]) || (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) { @@ -1187,15 +1192,15 @@ void PlaceUniques() done = (Monsters[mt].mtype == UniqMonst[u].mtype); } mt--; - if (u == UMT_GARBUD && quests[QTYPE_GARB]._qactive == 0) + if (u == UMT_GARBUD && quests[Q_GARBUD]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_ZHAR && quests[QTYPE_ZHAR]._qactive == 0) + if (u == UMT_ZHAR && quests[Q_ZHAR]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_SNOTSPIL && quests[QTYPE_BOL]._qactive == 0) + if (u == UMT_SNOTSPIL && quests[Q_LTBANNER]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_LACHDAN && quests[QTYPE_VEIL]._qactive == 0) + if (u == UMT_LACHDAN && quests[Q_VEIL]._qactive == QUEST_NOTAVAIL) done = FALSE; - if (u == UMT_WARLORD && quests[QTYPE_WARLRD]._qactive == 0) + if (u == UMT_WARLORD && quests[Q_WARLORD]._qactive == QUEST_NOTAVAIL) done = FALSE; if (done) PlaceUniqueMonst(u, mt, 8); @@ -1440,7 +1445,7 @@ void M_CheckEFlag(int i) } #endif - if (f | dArch[x][y]) + if (f | dSpecial[x][y]) monster[i]._meflag = TRUE; else { monster[i]._meflag = FALSE; @@ -1779,9 +1784,9 @@ void M_DiabloDeath(int i, BOOL sendmsg) #ifndef SPAWN PlaySFX(USFX_DIABLOD); #endif - quests[QTYPE_MOD]._qactive = 3; + quests[Q_DIABLO]._qactive = QUEST_DONE; if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_DIABLO); gbProcessPlayers = FALSE; sgbSaveSoundOn = gbSoundOn; for (j = 0; j < nummonsters; j++) { @@ -1828,12 +1833,12 @@ void SpawnLoot(int i, BOOL sendmsg) MonsterStruct *Monst; Monst = &monster[i]; - if (QuestStatus(QTYPE_GARB) && Monst->mName == UniqMonst[UMT_GARBUD].mName) { + if (QuestStatus(Q_GARBUD) && Monst->mName == UniqMonst[UMT_GARBUD].mName) { CreateTypeItem(Monst->_mx + 1, Monst->_my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE); } else if (Monst->mName == UniqMonst[UMT_DEFILER].mName) { if (effect_is_playing(USFX_DEFILER8)) sfx_stop(); - quests[QTYPE_DEFILER]._qlog = 0; + quests[Q_DEFILER]._qlog = 0; SpawnMapOfDoom(Monst->_mx, Monst->_my); } else if (Monst->mName == UniqMonst[UMT_HORKDMN].mName) { if (UseTheoQuest) { @@ -1848,7 +1853,7 @@ void SpawnLoot(int i, BOOL sendmsg) nSFX = USFX_NAKRUL6; if (effect_is_playing(nSFX)) sfx_stop(); - quests[QTYPE_NAKRUL]._qlog = 0; + quests[Q_NAKRUL]._qlog = 0; UberDiabloMonsterIndex = -2; CreateMagicWeapon(Monst->_mx, Monst->_my, ITYPE_SWORD, ICURS_GREAT_SWORD, FALSE, TRUE); CreateMagicWeapon(Monst->_mx, Monst->_my, ITYPE_STAFF, ICURS_WAR_STAFF, FALSE, TRUE); @@ -1937,9 +1942,9 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg) #ifdef HELLFIRE SpawnLoot(i, sendmsg); #else - if (QuestStatus(QTYPE_GARB) && Monst->mName == UniqMonst[UMT_GARBUD].mName) { + if (QuestStatus(Q_GARBUD) && Monst->mName == UniqMonst[UMT_GARBUD].mName) { CreateTypeItem(Monst->_mx + 1, Monst->_my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE); - } else if (i > 3) { + } else if (i > MAX_PLRS - 1) { // Golems should not spawn items SpawnItem(i, Monst->_mx, Monst->_my, sendmsg); } #endif @@ -2737,55 +2742,55 @@ int M_DoTalk(int i) return FALSE; InitQTextMsg(Monst->mtalkmsg); if (Monst->mName == UniqMonst[UMT_GARBUD].mName) { - if (Monst->mtalkmsg == QUEST_GARBUD1) - quests[QTYPE_GARB]._qactive = 2; - quests[QTYPE_GARB]._qlog = TRUE; - if (Monst->mtalkmsg == QUEST_GARBUD2 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_GARBUD1) + quests[Q_GARBUD]._qactive = QUEST_ACTIVE; + quests[Q_GARBUD]._qlog = TRUE; + if (Monst->mtalkmsg == TEXT_GARBUD2 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { SpawnItem(i, Monst->_mx + 1, Monst->_my + 1, TRUE); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } } if (Monst->mName == UniqMonst[UMT_ZHAR].mName - && Monst->mtalkmsg == QUEST_ZHAR1 + && Monst->mtalkmsg == TEXT_ZHAR1 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { - quests[QTYPE_ZHAR]._qactive = 2; - quests[QTYPE_ZHAR]._qlog = TRUE; + quests[Q_ZHAR]._qactive = QUEST_ACTIVE; + quests[Q_ZHAR]._qlog = TRUE; CreateTypeItem(Monst->_mx + 1, Monst->_my + 1, FALSE, ITYPE_MISC, IMISC_BOOK, TRUE, FALSE); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } if (Monst->mName == UniqMonst[UMT_SNOTSPIL].mName) { - if (Monst->mtalkmsg == QUEST_BANNER10 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_BANNER10 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { ObjChangeMap(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 2, (setpc_h >> 1) + setpc_y - 2); tren = TransVal; TransVal = 9; DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); TransVal = tren; - quests[QTYPE_BOL]._qvar1 = 2; - if (quests[QTYPE_BOL]._qactive == 1) - quests[QTYPE_BOL]._qactive = 2; + quests[Q_LTBANNER]._qvar1 = 2; + if (quests[Q_LTBANNER]._qactive == QUEST_INIT) + quests[Q_LTBANNER]._qactive = QUEST_ACTIVE; Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } - if (quests[QTYPE_BOL]._qvar1 < 2) { + if (quests[Q_LTBANNER]._qvar1 < 2) { sprintf(tempstr, "SS Talk = %i, Flags = %i", Monst->mtalkmsg, Monst->_mFlags); app_fatal(tempstr); } } if (Monst->mName == UniqMonst[UMT_LACHDAN].mName) { - if (Monst->mtalkmsg == QUEST_VEIL9) { - quests[QTYPE_VEIL]._qactive = 2; - quests[QTYPE_VEIL]._qlog = TRUE; + if (Monst->mtalkmsg == TEXT_VEIL9) { + quests[Q_VEIL]._qactive = QUEST_ACTIVE; + quests[Q_VEIL]._qlog = TRUE; } - if (Monst->mtalkmsg == QUEST_VEIL11 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { + if (Monst->mtalkmsg == TEXT_VEIL11 && !(Monst->_mFlags & MFLAG_QUEST_COMPLETE)) { SpawnUnique(UITEM_STEELVEIL, Monst->_mx + 1, Monst->_my + 1); Monst->_mFlags |= MFLAG_QUEST_COMPLETE; } } if (Monst->mName == UniqMonst[UMT_WARLORD].mName) - quests[QTYPE_WARLRD]._qvar1 = 2; + quests[Q_WARLORD]._qvar1 = 2; if (Monst->mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; + quests[Q_BETRAYER]._qvar1 = 6; Monst->_mgoal = MGOAL_NORMAL; } return FALSE; @@ -4475,7 +4480,7 @@ void MAI_Rhino(int i) Monst->_mgoalvar1 = 0; Monst->_mgoalvar2 = random_(133, 2); } - Monst->_mgoal = 4; + Monst->_mgoal = MGOAL_MOVE; if (abs(mx) > abs(my)) { dist = abs(mx); } else { @@ -4687,8 +4692,8 @@ void MAI_Garbud(int i) _my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg < QUEST_GARBUD4 - && Monst->mtalkmsg > QUEST_DOOM10 + if (Monst->mtalkmsg < TEXT_GARBUD4 + && Monst->mtalkmsg > TEXT_DOOM10 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_INQUIRING; @@ -4697,7 +4702,7 @@ void MAI_Garbud(int i) if (dFlags[_mx][_my] & BFLAG_VISIBLE) { #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_GARBUD4) { + if (Monst->mtalkmsg == TEXT_GARBUD4) { if (!effect_is_playing(USFX_GARBUD4) && Monst->_mgoal == MGOAL_TALKING) { Monst->_mgoal = MGOAL_NORMAL; Monst->_msquelch = UCHAR_MAX; @@ -4732,8 +4737,8 @@ void MAI_Zhar(int i) mx = Monst->_mx; my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_ZHAR2; + if (Monst->mtalkmsg == TEXT_ZHAR1 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_ZHAR2; Monst->_mgoal = MGOAL_INQUIRING; } @@ -4745,7 +4750,7 @@ void MAI_Zhar(int i) else abs(_my); #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_ZHAR2) { + if (Monst->mtalkmsg == TEXT_ZHAR2) { if (!effect_is_playing(USFX_ZHAR2) && Monst->_mgoal == MGOAL_TALKING) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; @@ -4781,22 +4786,22 @@ void MAI_SnotSpil(int i) my = Monst->_my; md = M_GetDir(i); - if (Monst->mtalkmsg == QUEST_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_BANNER11; + if (Monst->mtalkmsg == TEXT_BANNER10 && !(dFlags[mx][my] & BFLAG_VISIBLE) && Monst->_mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_BANNER11; Monst->_mgoal = MGOAL_INQUIRING; } - if (Monst->mtalkmsg == QUEST_BANNER11 && quests[QTYPE_BOL]._qvar1 == 3) { + if (Monst->mtalkmsg == TEXT_BANNER11 && quests[Q_LTBANNER]._qvar1 == 3) { Monst->mtalkmsg = 0; Monst->_mgoal = MGOAL_NORMAL; } if (dFlags[mx][my] & BFLAG_VISIBLE) { #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_BANNER12) { + if (Monst->mtalkmsg == TEXT_BANNER12) { if (!effect_is_playing(USFX_SNOT3) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMap(setpc_x, setpc_y, setpc_x + setpc_w + 1, setpc_y + setpc_h + 1); - quests[QTYPE_BOL]._qvar1 = 3; + quests[Q_LTBANNER]._qvar1 = 3; RedoPlayerVision(); Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; @@ -4804,7 +4809,7 @@ void MAI_SnotSpil(int i) } } #endif - if (quests[QTYPE_BOL]._qvar1 == 3) { + if (quests[Q_LTBANNER]._qvar1 == 3) { if (Monst->_mgoal == MGOAL_NORMAL || Monst->_mgoal == MGOAL_SHOOT) MAI_Fallen(i); } @@ -4834,25 +4839,25 @@ void MAI_Lazurus(int i) md = M_GetDir(i); if (dFlags[mx][my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { - if (Monst->mtalkmsg == QUEST_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == QUEST_VILE13 && plr[myplr].WorldY == 46) { + if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == TEXT_VILE13 && plr[myplr].WorldY == 46) { PlayInGameMovie("gendata\\fprst3.smk"); Monst->_mmode = MM_TALK; - quests[QTYPE_VB]._qvar1 = 5; + quests[Q_BETRAYER]._qvar1 = 5; } #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_VILE13 && !effect_is_playing(USFX_LAZ1) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == TEXT_VILE13 && !effect_is_playing(USFX_LAZ1) && Monst->_mgoal == MGOAL_TALKING) { ObjChangeMapResync(1, 18, 20, 24); RedoPlayerVision(); Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; - quests[QTYPE_VB]._qvar1 = 6; + quests[Q_BETRAYER]._qvar1 = 6; Monst->_mgoal = MGOAL_NORMAL; } #endif } - if (gbMaxPlayers != 1 && Monst->mtalkmsg == QUEST_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && quests[QTYPE_VB]._qvar1 <= 3) { + if (gbMaxPlayers != 1 && Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && quests[Q_BETRAYER]._qvar1 <= 3) { Monst->_mmode = MM_TALK; } } @@ -4886,7 +4891,7 @@ void MAI_Lazhelp(int i) if (dFlags[_mx][_my] & BFLAG_VISIBLE) { if (gbMaxPlayers == 1) { - if (quests[QTYPE_VB]._qvar1 <= 5) { + if (quests[Q_BETRAYER]._qvar1 <= 5) { Monst->_mgoal = MGOAL_INQUIRING; } else { Monst->mtalkmsg = 0; @@ -4923,16 +4928,16 @@ void MAI_Lachdanan(int i) _my = Monst->_my; md = M_GetDir(i); #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { - Monst->mtalkmsg = QUEST_VEIL10; + if (Monst->mtalkmsg == TEXT_VEIL9 && !(dFlags[_mx][_my] & BFLAG_VISIBLE) && monster[i]._mgoal == MGOAL_TALKING) { + Monst->mtalkmsg = TEXT_VEIL10; monster[i]._mgoal = MGOAL_INQUIRING; } if (dFlags[_mx][_my] & BFLAG_VISIBLE) { - if (Monst->mtalkmsg == QUEST_VEIL11) { + if (Monst->mtalkmsg == TEXT_VEIL11) { if (!effect_is_playing(USFX_LACH3) && Monst->_mgoal == MGOAL_TALKING) { Monst->mtalkmsg = 0; - quests[QTYPE_VEIL]._qactive = 3; + quests[Q_VEIL]._qactive = QUEST_DONE; M_StartKill(i, -1); } } @@ -4966,10 +4971,10 @@ void MAI_Warlord(int i) my = Monst->_my; md = M_GetDir(i); if (dFlags[mx][my] & BFLAG_VISIBLE) { - if (Monst->mtalkmsg == QUEST_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING) + if (Monst->mtalkmsg == TEXT_WARLRD9 && Monst->_mgoal == MGOAL_INQUIRING) Monst->_mmode = MM_TALK; #ifndef SPAWN - if (Monst->mtalkmsg == QUEST_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && Monst->_mgoal == MGOAL_TALKING) { + if (Monst->mtalkmsg == TEXT_WARLRD9 && !effect_is_playing(USFX_WARLRD1) && Monst->_mgoal == MGOAL_TALKING) { Monst->_msquelch = UCHAR_MAX; Monst->mtalkmsg = 0; Monst->_mgoal = MGOAL_NORMAL; @@ -6064,16 +6069,16 @@ void TalktoMonster(int i) pnum = Monst->_menemy; Monst->_mmode = MM_TALK; if (Monst->_mAi == AI_SNOTSPIL || Monst->_mAi == AI_LACHDAN) { - if (QuestStatus(QTYPE_BOL) && quests[QTYPE_BOL]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, itm)) { + if (QuestStatus(Q_LTBANNER) && quests[Q_LTBANNER]._qvar1 == 2 && PlrHasItem(pnum, IDI_BANNER, itm)) { RemoveInvItem(pnum, itm); - quests[QTYPE_BOL]._qactive = 3; - Monst->mtalkmsg = QUEST_BANNER12; + quests[Q_LTBANNER]._qactive = QUEST_DONE; + Monst->mtalkmsg = TEXT_BANNER12; Monst->_mgoal = MGOAL_INQUIRING; } - if (QuestStatus(QTYPE_VEIL) && Monst->mtalkmsg >= QUEST_VEIL9) { + if (QuestStatus(Q_VEIL) && Monst->mtalkmsg >= TEXT_VEIL9) { if (PlrHasItem(pnum, IDI_GLDNELIX, itm)) { RemoveInvItem(pnum, itm); - Monst->mtalkmsg = QUEST_VEIL11; + Monst->mtalkmsg = TEXT_VEIL11; Monst->_mgoal = MGOAL_INQUIRING; } } diff --git a/Source/monster.h b/Source/monster.h index 31018d19..91d7f6a7 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file monster.h + * + * Interface of monster functionality, AI, actions, spawning, loading, etc. + */ #ifndef __MONSTER_H__ #define __MONSTER_H__ @@ -207,7 +211,7 @@ extern int opposite[8]; extern int offset_x[8]; extern int offset_y[8]; -/* unused */ +/** unused */ extern int rnd5[4]; extern int rnd10[4]; extern int rnd20[4]; diff --git a/Source/movie.cpp b/Source/movie.cpp index e8d819fc..1e3f8129 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -1,7 +1,14 @@ -#include "diablo.h" +/** + * @file movie.cpp + * + * Implementation of video playback. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" +/** Should the movie continue playing. */ BYTE movie_playing; +/** Should the movie play in a loop. */ BOOL loop_movie; void play_movie(char *pszMovie, BOOL user_can_close) @@ -18,7 +25,7 @@ void play_movie(char *pszMovie, BOOL user_can_close) UpdateWindow(ghMainWnd); movie_playing = TRUE; sound_disable_music(TRUE); - sfx_stop(); + stream_stop(); effects_play_sound("Sfx\\Misc\\blank.wav"); SVidPlayBegin(pszMovie, 0, 0, 0, 0, loop_movie ? 0x100C0808 : 0x10280808, &video_stream); diff --git a/Source/movie.h b/Source/movie.h index 03fcab32..f61ba789 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file movie.h + * + * Interface of video playback. + */ #ifndef __MOVIE_H__ #define __MOVIE_H__ diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 2bb69920..6d33ffdb 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -1,11 +1,18 @@ -#include "diablo.h" +/** + * @file mpqapi.cpp + * + * Implementation of functions for creating and editing MPQ files. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" DWORD sgdwMpqOffset; char mpq_buf[4096]; _HASHENTRY *sgpHashTbl; +/** Has the savegame-file been modified in memory. */ BOOL save_archive_modified; _BLOCKENTRY *sgpBlockTbl; +/** Is the savegame-file currently open. */ BOOLEAN save_archive_open; //note: 32872 = 32768 + 104 (sizeof(_FILEHEADER)) @@ -202,7 +209,7 @@ _BLOCKENTRY *mpqapi_new_block(int *block_index) blockEntry++; if (i >= 2048) { app_fatal("Out of free block entries"); - return 0; + return NULL; } } if (block_index) @@ -593,9 +600,9 @@ BOOL WriteMPQHeader() fhdr.blockcount = 2048; if (SetFilePointer(sghArchive, 0, NULL, FILE_BEGIN) == -1) - return 0; + return FALSE; if (!WriteFile(sghArchive, &fhdr, sizeof(fhdr), &NumberOfBytesWritten, 0)) - return 0; + return FALSE; return NumberOfBytesWritten == 104; } diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 9afe8fe9..ff6e6112 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file mpqapi.h + * + * Interface of functions for creating and editing MPQ files. + */ #ifndef __MPQAPI_H__ #define __MPQAPI_H__ diff --git a/Source/msg.cpp b/Source/msg.cpp index 4b043efb..a7ffd796 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file msg.cpp + * + * Implementation of function for sending and reciving network messages. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -17,7 +22,7 @@ static BOOLEAN sgbDeltaChanged; static BYTE sgbDeltaChunks; BOOL deltaload; BYTE gbBufferMsgs; -int pkt_counter; +int dwRecCount; void msg_send_drop_pkt(int pnum, int reason) { @@ -49,7 +54,7 @@ void msg_send_packet(int pnum, const void *packet, DWORD dwSize) sgpCurrPkt->dwSpaceLeft -= dwSize; } -TMegaPkt *msg_get_next_packet() +void msg_get_next_packet() { TMegaPkt *result; @@ -62,8 +67,6 @@ TMegaPkt *msg_get_next_packet() result = result->pNext; } result->pNext = sgpCurrPkt; - - return result; } BOOL msg_wait_resync() @@ -140,7 +143,7 @@ int msg_wait_for_turns() return 100 * sgbDeltaChunks / 21; } -void msg_process_net_packets() +void run_delta_info() { if (gbMaxPlayers != 1) { gbBufferMsgs = 2; @@ -983,7 +986,7 @@ void NetSendCmdString(int pmask, const char *pszStr) multi_send_msg_packet(pmask, (BYTE *)&cmd.bCmd, dwStrLen + 2); } -void RemovePlrPortal(int pnum) +void delta_close_portal(int pnum) { memset(&sgJunk.portal[pnum], 0xFF, sizeof(sgJunk.portal[pnum])); sgbDeltaChanged = TRUE; @@ -2470,7 +2473,7 @@ DWORD On_DEACTIVATEPORTAL(TCmd *pCmd, int pnum) if (PortalOnLevel(pnum)) RemovePortalMissile(pnum); DeactivatePortal(pnum); - RemovePlrPortal(pnum); + delta_close_portal(pnum); } return sizeof(*pCmd); @@ -2695,7 +2698,7 @@ DWORD On_NAKRUL(TCmd *pCmd, int pnum) { operate_lv24_lever(); IsUberRoomOpened = 1; - quests[QTYPE_NAKRUL]._qactive = 3; + quests[Q_NAKRUL]._qactive = 3; monster_some_crypt(); } return sizeof(*pCmd); diff --git a/Source/msg.h b/Source/msg.h index 877a7dba..2ab70f4e 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -1,18 +1,22 @@ -//HEADER_GOES_HERE +/** + * @file msg.h + * + * Interface of function for sending and reciving network messages. + */ #ifndef __MSG_H__ #define __MSG_H__ extern BOOL deltaload; extern BYTE gbBufferMsgs; -extern int pkt_counter; +extern int dwRecCount; void msg_send_drop_pkt(int pnum, int reason); void msg_send_packet(int pnum, const void *packet, DWORD dwSize); -TMegaPkt *msg_get_next_packet(); +void msg_get_next_packet(); BOOL msg_wait_resync(); void msg_free_packets(); int msg_wait_for_turns(); -void msg_process_net_packets(); +void run_delta_info(); void msg_pre_packet(); void DeltaExportData(int pnum); BYTE *DeltaExportItem(BYTE *dst, TCmdPItem *src); @@ -54,7 +58,7 @@ void NetSendCmdDamage(BOOL bHiPri, BYTE bPlr, DWORD dwDam); void NetSendCmdMonDmg(BOOL bHiPri, WORD bMon, DWORD dwDam); #endif void NetSendCmdString(int pmask, const char *pszStr); -void RemovePlrPortal(int pnum); +void delta_close_portal(int pnum); DWORD ParseCmd(int pnum, TCmd *pCmd); DWORD On_DLEVEL(int pnum, TCmd *pCmd); void DeltaImportData(BYTE cmd, DWORD recv_offset); diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index 48d6004b..32777447 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -1,9 +1,16 @@ +/** + * @file msgcmd.cpp + * + * Functions for sending commands to Battle.net. + * + * See http://classic.battle.net/info/commands.shtml for a list of commands. + */ #ifndef HELLFIRE #include // for placement new #include // for offsetof #include // for typeid -#include "diablo.h" +#include "all.h" #include "list.h" #define COMMAND_LEN 128 diff --git a/Source/msgcmd.h b/Source/msgcmd.h index be57db0f..db3b451e 100644 --- a/Source/msgcmd.h +++ b/Source/msgcmd.h @@ -1,4 +1,10 @@ -//HEADER_GOES_HERE +/** + * @file msgcmd.h + * + * Interface for sending commands to Battle.net. + * + * See http://classic.battle.net/info/commands.shtml for a list of commands. + */ #ifndef __MSGCMD_H__ #define __MSGCMD_H__ diff --git a/Source/multi.cpp b/Source/multi.cpp index e64ee052..a86d0b53 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file multi.cpp + * + * Implementation of functions for keeping multiplaye games in sync. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -18,11 +23,15 @@ BYTE gbActivePlayers; BOOLEAN gbGameDestroyed; BOOLEAN sgbSendDeltaTbl[MAX_PLRS]; _gamedata sgGameInitInfo; -BOOLEAN gbGameUninitialized; +BOOLEAN gbSelectProvider; int sglTimeoutStart; int sgdwPlayerLeftReasonTbl[MAX_PLRS]; TBuffer sgLoPriBuf; DWORD sgdwGameLoops; +/** + * Specifies the maximum number of players in a game, where 1 + * represents a single player game and 4 represents a multi player game. + */ BYTE gbMaxPlayers; BOOLEAN sgbTimeout; char szPlayerName[128]; @@ -30,6 +39,10 @@ BYTE gbDeltaSender; BOOL sgbNetInited; int player_state[MAX_PLRS]; +/** + * Contains the set of supported event types supported by the multiplayer + * event handler. + */ const int event_types[3] = { EVENT_TYPE_PLAYER_LEAVE_GAME, EVENT_TYPE_PLAYER_CREATE_GAME, @@ -272,7 +285,7 @@ void multi_player_left_msg(int pnum, int left) RemovePlrFromMap(pnum); RemovePortalMissile(pnum); DeactivatePortal(pnum); - RemovePlrPortal(pnum); + delta_close_portal(pnum); RemovePlrMissiles(pnum); if (left) { pszFmt = "Player '%s' just left the game"; @@ -449,7 +462,7 @@ void multi_process_network_packets() multi_clear_left_tbl(); multi_process_tmsgs(); while (SNetReceiveMessage((int *)&dwID, &data, (int *)&dwMsgSize)) { - pkt_counter++; + dwRecCount++; multi_clear_left_tbl(); pkt = (TPktHdr *)data; if (dwMsgSize < sizeof(TPktHdr)) @@ -756,7 +769,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) if (sgbPlayerTurnBitTbl[myplr] == 0 || msg_wait_resync()) break; NetClose(); - gbGameUninitialized = FALSE; + gbSelectProvider = FALSE; } gnDifficulty = sgGameInitInfo.bDiff; SetRndSeed(sgGameInitInfo.dwSeed); @@ -872,7 +885,7 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, for (first = TRUE;; first = FALSE) { type = 0x00; - if (gbGameUninitialized) { + if (gbSelectProvider) { if (!UiSelectProvider(0, client_info, user_info, ui_info, &fileinfo, &type) && (!first || SErrGetLastError() != STORM_ERROR_REQUIRES_UPGRADE || !multi_upgrade(pfExitProgram))) { return FALSE; @@ -887,7 +900,7 @@ BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, if (UiSelectGame(1, client_info, user_info, ui_info, &fileinfo, &playerId)) break; - gbGameUninitialized = TRUE; + gbSelectProvider = TRUE; } if ((DWORD)playerId >= MAX_PLRS) { diff --git a/Source/multi.h b/Source/multi.h index f02eea78..73cae280 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file multi.h + * + * Interface of functions for keeping multiplaye games in sync. + */ #ifndef __MULTI_H__ #define __MULTI_H__ @@ -9,7 +13,7 @@ extern PkPlayerStruct netplr[MAX_PLRS]; extern BOOL gbShouldValidatePackage; extern BYTE gbActivePlayers; extern BOOLEAN gbGameDestroyed; -extern BOOLEAN gbGameUninitialized; +extern BOOLEAN gbSelectProvider; extern BYTE gbMaxPlayers; extern char szPlayerName[128]; extern BYTE gbDeltaSender; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 53cacc3e..43aa04c5 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file nthread.cpp + * + * Implementation of functions for managing game ticks. + */ +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BYTE sgbNetUpdateRate; @@ -91,7 +96,7 @@ BOOL nthread_recv_turns(BOOL *pfSendAsync) sgbTicsOutOfSync = FALSE; sgbSyncCountdown = 1; sgbPacketCountdown = 1; - return 0; + return FALSE; } else { if (!sgbTicsOutOfSync) { sgbTicsOutOfSync = TRUE; @@ -168,7 +173,7 @@ void nthread_start(BOOL set_turn_upper_bit) } } -unsigned int __stdcall nthread_handler(void *) +unsigned int __stdcall nthread_handler(void *data) { int delta; BOOL received; @@ -211,7 +216,7 @@ void nthread_cleanup() if (!sgbThreadIsRunning) sgMemCrit.Leave(); #endif - if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) { + if (WaitForSingleObject(sghThread, INFINITE) == -1) { app_fatal("nthread3:\n(%s)", TraceLastError()); } CloseHandle(sghThread); diff --git a/Source/nthread.h b/Source/nthread.h index 84263e95..bcd4a187 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file nthread.h + * + * Interface of functions for managing game ticks. + */ #ifndef __NTHREAD_H__ #define __NTHREAD_H__ @@ -20,7 +24,7 @@ DWORD nthread_send_and_recv_turn(DWORD cur_turn, int turn_delta); BOOL nthread_recv_turns(BOOL *pfSendAsync); void nthread_set_turn_upper_bit(); void nthread_start(BOOL set_turn_upper_bit); -unsigned int __stdcall nthread_handler(void *); +unsigned int __stdcall nthread_handler(void *data); void nthread_cleanup(); void nthread_ignore_mutex(BOOL bStart); BOOL nthread_has_500ms_passed(BOOL unused); diff --git a/Source/objdat.cpp b/Source/objdat.cpp index d21bb893..a835be14 100644 --- a/Source/objdat.cpp +++ b/Source/objdat.cpp @@ -1,5 +1,6 @@ -#include "diablo.h" +#include "all.h" +/** Maps from dun_object_id to object_id. */ int ObjTypeConv[113] = { 0, 4, @@ -116,6 +117,7 @@ int ObjTypeConv[113] = { 94 }; +/** Contains the data related to each object ID. */ ObjDataStruct AllObjects[99] = { // clang-format off // oload, ofindex, ominlvl, omaxlvl, olvltype, otheme, oquest, oAnimFlag, oAnimDelay, oAnimLen, oAnimWidth, oSolidFlag, oMissFlag, oLightFlag, oBreak, oSelFlag, oTrapFlag @@ -221,8 +223,8 @@ ObjDataStruct AllObjects[99] = { // clang-format on }; -// might be const -char *ObjMasterLoadList[56] = { +/** Maps from object_graphic_id to object CEL name. */ +char *ObjMasterLoadList[56] = { // might be const "L1Braz", "L1Doors", "Lever", diff --git a/Source/objects.cpp b/Source/objects.cpp index 8554d12b..7282aacd 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int trapid; int trapdir; @@ -55,7 +55,7 @@ char shrinemax[NUM_SHRINETYPE] = { 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 }; -// 0 - sp+mp, 1 - sp only, 2 - mp only +/** 0 - sp+mp, 1 - sp only, 2 - mp only */ BYTE shrineavail[NUM_SHRINETYPE] = { 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, @@ -73,9 +73,9 @@ char *StoryBookName[9] = { "The Black King" }; int StoryText[3][3] = { - { QUEST_BOOK11, QUEST_BOOK12, QUEST_BOOK13 }, - { QUEST_BOOK21, QUEST_BOOK22, QUEST_BOOK23 }, - { QUEST_BOOK31, QUEST_BOOK32, QUEST_BOOK33 } + { TEXT_BOOK11, TEXT_BOOK12, TEXT_BOOK13 }, + { TEXT_BOOK21, TEXT_BOOK22, TEXT_BOOK23 }, + { TEXT_BOOK31, TEXT_BOOK32, TEXT_BOOK33 } }; void InitObjectGFX() @@ -289,8 +289,8 @@ void AddCandles() { int tx, ty; - tx = quests[QTYPE_PW]._qtx; - ty = quests[QTYPE_PW]._qty; + tx = quests[Q_PWATER]._qtx; + ty = quests[Q_PWATER]._qty; AddObject(OBJ_STORYCANDLE, tx - 2, ty + 1); AddObject(OBJ_STORYCANDLE, tx + 3, ty + 1); AddObject(OBJ_STORYCANDLE, tx - 1, ty + 2); @@ -321,11 +321,11 @@ void AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, in } } - if (QuestStatus(QTYPE_BLIND)) + if (QuestStatus(Q_BLIND)) AddObject(OBJ_BLINDBOOK, xp, yp); - if (QuestStatus(QTYPE_WARLRD)) + if (QuestStatus(Q_WARLORD)) AddObject(OBJ_STEELTOME, xp, yp); - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { xp = 2 * setpc_x + 25; yp = 2 * setpc_y + 40; AddObject(OBJ_BLOODBOOK, xp, yp); @@ -866,7 +866,7 @@ void InitObjects() GetRndSeed(); if (currlevel == 9 && gbMaxPlayers == 1) AddSlainHero(); - if (currlevel == quests[QTYPE_BLKM]._qlevel && quests[QTYPE_BLKM]._qactive == 1) + if (currlevel == quests[Q_MUSHROOM]._qlevel && quests[Q_MUSHROOM]._qactive == QUEST_INIT) AddMushPatch(); #ifdef HELLFIRE @@ -893,11 +893,11 @@ void InitObjects() AddStoryBooks(); #endif if (leveltype == DTYPE_CATHEDRAL) { - if (QuestStatus(QTYPE_BUTCH)) + if (QuestStatus(Q_BUTCHER)) AddTortures(); - if (QuestStatus(QTYPE_PW)) + if (QuestStatus(Q_PWATER)) AddCandles(); - if (QuestStatus(QTYPE_BOL)) + if (QuestStatus(Q_LTBANNER)) AddObject(OBJ_SIGNCHEST, 2 * setpc_x + 26, 2 * setpc_y + 19); InitRndLocBigObj(10, 15, OBJ_SARC); #ifdef HELLFIRE @@ -909,51 +909,51 @@ void InitObjects() InitRndBarrels(); } if (leveltype == DTYPE_CATACOMBS) { - if (QuestStatus(QTYPE_INFRA)) + if (QuestStatus(Q_ROCK)) InitRndLocObj5x5(1, 1, OBJ_STAND); - if (QuestStatus(QTYPE_BONE)) + if (QuestStatus(Q_SCHAMB)) InitRndLocObj5x5(1, 1, OBJ_BOOK2R); AddL2Objs(0, 0, MAXDUNX, MAXDUNY); AddL2Torches(); - if (QuestStatus(QTYPE_BLIND)) { + if (QuestStatus(Q_BLIND)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLINDING; + sp_id = TEXT_BLINDING; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLINDING; + sp_id = TEXT_RBLINDING; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLINDING; + sp_id = TEXT_MBLINDING; #ifdef HELLFIRE } else if (plr[myplr]._pClass == PC_MONK) { - sp_id = QUEST_HBLINDING; + sp_id = TEXT_HBLINDING; } else if (plr[myplr]._pClass == PC_BARD) { - sp_id = QUEST_BBLINDING; + sp_id = TEXT_BBLINDING; } else if (plr[myplr]._pClass == PC_BARBARIAN) { - sp_id = QUEST_BLINDING; + sp_id = TEXT_BLINDING; #endif } - quests[QTYPE_BLIND]._qmsg = sp_id; + quests[Q_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", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } - if (QuestStatus(QTYPE_BLOOD)) { + if (QuestStatus(Q_BLOOD)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLOODY; + sp_id = TEXT_BLOODY; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLOODY; + sp_id = TEXT_RBLOODY; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLOODY; + sp_id = TEXT_MBLOODY; #ifdef HELLFIRE } else if (plr[myplr]._pClass == PC_MONK) { - sp_id = QUEST_HBLOODY; + sp_id = TEXT_HBLOODY; } else if (plr[myplr]._pClass == PC_BARD) { - sp_id = QUEST_BBLOODY; + sp_id = TEXT_BBLOODY; } else if (plr[myplr]._pClass == PC_BARBARIAN) { - sp_id = QUEST_BLOODY; + sp_id = TEXT_BLOODY; #endif } - quests[QTYPE_BLOOD]._qmsg = sp_id; + quests[Q_BLOOD]._qmsg = sp_id; AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, sp_id); AddObject(OBJ_PEDISTAL, 2 * setpc_x + 25, 2 * setpc_y + 32); } @@ -964,29 +964,29 @@ void InitObjects() InitRndBarrels(); } if (leveltype == DTYPE_HELL) { - if (QuestStatus(QTYPE_WARLRD)) { + if (QuestStatus(Q_WARLORD)) { if (plr[myplr]._pClass == PC_WARRIOR) { - sp_id = QUEST_BLOODWAR; + sp_id = TEXT_BLOODWAR; } else if (plr[myplr]._pClass == PC_ROGUE) { - sp_id = QUEST_RBLOODWAR; + sp_id = TEXT_RBLOODWAR; } else if (plr[myplr]._pClass == PC_SORCERER) { - sp_id = QUEST_MBLOODWAR; + sp_id = TEXT_MBLOODWAR; #ifdef HELLFIRE } else if (plr[myplr]._pClass == PC_MONK) { - sp_id = QUEST_HBLOODWAR; + sp_id = TEXT_HBLOODWAR; } else if (plr[myplr]._pClass == PC_BARD) { - sp_id = QUEST_BBLOODWAR; + sp_id = TEXT_BBLOODWAR; } else if (plr[myplr]._pClass == PC_BARBARIAN) { - sp_id = QUEST_BLOODWAR; + sp_id = TEXT_BLOODWAR; #endif } - quests[QTYPE_WARLRD]._qmsg = sp_id; + quests[Q_WARLORD]._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", NULL); LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(mem); } - if (QuestStatus(QTYPE_VB) && gbMaxPlayers == 1) + if (QuestStatus(Q_BETRAYER) && gbMaxPlayers == 1) AddLazStand(); InitRndBarrels(); AddL4Goodies(); @@ -1225,7 +1225,7 @@ void AddFlameTrap(int i) void AddFlameLvr(int i) { object[i]._oVar1 = trapid; - object[i]._oVar2 = 49; + object[i]._oVar2 = MIS_FLAMEC; } void AddTrap(int i, int ot) @@ -1781,8 +1781,8 @@ void Obj_Circle(int i) if (ox == 35 && oy == 36 && object[i]._oVar5 == 3) { object[i]._oVar6 = 4; ObjChangeMapResync(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); - if (quests[QTYPE_VB]._qactive == 2) - quests[QTYPE_VB]._qvar1 = 4; + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) + quests[Q_BETRAYER]._qvar1 = 4; AddMissile(plr[myplr].WorldX, plr[myplr].WorldY, 35, 46, plr[myplr]._pdir, MIS_RNDTELEPORT, 0, myplr, 0, 0); track_repeat_walk(FALSE); sgbMouseDown = 0; @@ -2180,35 +2180,35 @@ void ObjL1Special(int x1, int y1, int x2, int y2) for (i = y1; i <= y2; ++i) { for (j = x1; j <= x2; ++j) { - dArch[j][i] = 0; + dSpecial[j][i] = 0; if (dPiece[j][i] == 12) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 11) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 71) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 259) - dArch[j][i] = 5; + dSpecial[j][i] = 5; if (dPiece[j][i] == 249) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 325) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 321) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 255) - dArch[j][i] = 4; + dSpecial[j][i] = 4; if (dPiece[j][i] == 211) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 344) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 341) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 331) - dArch[j][i] = 2; + dSpecial[j][i] = 2; if (dPiece[j][i] == 418) - dArch[j][i] = 1; + dSpecial[j][i] = 1; if (dPiece[j][i] == 421) - dArch[j][i] = 2; + dSpecial[j][i] = 2; } } } @@ -2219,32 +2219,32 @@ void ObjL2Special(int x1, int y1, int x2, int y2) for (j = y1; j <= y2; j++) { for (i = x1; i <= x2; i++) { - dArch[i][j] = 0; + dSpecial[i][j] = 0; if (dPiece[i][j] == 541) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 178) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 551) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 542) - dArch[i][j] = 6; + dSpecial[i][j] = 6; if (dPiece[i][j] == 553) - dArch[i][j] = 6; + dSpecial[i][j] = 6; if (dPiece[i][j] == 13) - dArch[i][j] = 5; + dSpecial[i][j] = 5; if (dPiece[i][j] == 17) - dArch[i][j] = 6; + dSpecial[i][j] = 6; } } for (j = y1; j <= y2; j++) { for (i = x1; i <= x2; i++) { if (dPiece[i][j] == 132) { - dArch[i][j + 1] = 2; - dArch[i][j + 2] = 1; + dSpecial[i][j + 1] = 2; + dSpecial[i][j + 2] = 1; } if (dPiece[i][j] == 135 || dPiece[i][j] == 139) { - dArch[i + 1][j] = 3; - dArch[i + 2][j] = 4; + dSpecial[i + 1][j] = 3; + dSpecial[i + 2][j] = 4; } } } @@ -2368,15 +2368,15 @@ void OperateL1RDoor(int pnum, int oi, DIABOOL sendflag) ObjSetMicro(xp, yp, 209); } if (currlevel < 17) { - dArch[xp][yp] = 8; + dSpecial[xp][yp] = 8; } else { - dArch[xp][yp] = 2; + dSpecial[xp][yp] = 2; } #else if (!deltaload) PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); ObjSetMicro(xp, yp, 395); - dArch[xp][yp] = 8; + dSpecial[xp][yp] = 8; #endif objects_set_door_piece(xp, yp - 1); object[oi]._oAnimFrame += 2; @@ -2473,9 +2473,9 @@ void OperateL1LDoor(int pnum, int oi, DIABOOL sendflag) ObjSetMicro(xp, yp, 206); } if (currlevel < 17) { - dArch[xp][yp] = 7; + dSpecial[xp][yp] = 7; } else { - dArch[xp][yp] = 1; + dSpecial[xp][yp] = 1; } #else if (!deltaload) @@ -2484,7 +2484,7 @@ void OperateL1LDoor(int pnum, int oi, DIABOOL sendflag) ObjSetMicro(xp, yp, 408); else ObjSetMicro(xp, yp, 393); - dArch[xp][yp] = 7; + dSpecial[xp][yp] = 7; #endif objects_set_door_piece(xp - 1, yp); object[oi]._oAnimFrame += 2; @@ -2844,7 +2844,7 @@ void OperateLever(int pnum, int i) operate_lv24_lever(); IsUberLeverActivated = 1; mapflag = FALSE; - quests[QTYPE_NAKRUL]._qactive = 3; + quests[Q_NAKRUL]._qactive = 3; } #endif if (mapflag) @@ -2900,7 +2900,7 @@ void OperateBook(int pnum, int i) plr[myplr]._pMemSpells |= ((__int64)1 << (SPL_GUARDIAN - 1)); if (plr[pnum]._pSplLvl[SPL_GUARDIAN] < 15) plr[myplr]._pSplLvl[SPL_GUARDIAN]++; - quests[QTYPE_BONE]._qactive = 3; + quests[Q_SCHAMB]._qactive = QUEST_DONE; if (!deltaload) PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); InitDiabloMsg(EMSG_BONECHAMB); @@ -2934,24 +2934,24 @@ void OperateBookLever(int pnum, int i) x = 2 * setpc_x + 16; y = 2 * setpc_y + 16; if (object[i]._oSelFlag != 0 && !qtextflag) { - if (object[i]._otype == OBJ_BLINDBOOK && !quests[QTYPE_BLIND]._qvar1) { - quests[QTYPE_BLIND]._qactive = 2; - quests[QTYPE_BLIND]._qlog = 1; - quests[QTYPE_BLIND]._qvar1 = 1; + if (object[i]._otype == OBJ_BLINDBOOK && !quests[Q_BLIND]._qvar1) { + quests[Q_BLIND]._qactive = QUEST_ACTIVE; + quests[Q_BLIND]._qlog = 1; + quests[Q_BLIND]._qvar1 = 1; } - if (object[i]._otype == OBJ_BLOODBOOK && !quests[QTYPE_BLOOD]._qvar1) { - quests[QTYPE_BLOOD]._qactive = 2; - quests[QTYPE_BLOOD]._qlog = 1; - quests[QTYPE_BLOOD]._qvar1 = 1; + if (object[i]._otype == OBJ_BLOODBOOK && !quests[Q_BLOOD]._qvar1) { + quests[Q_BLOOD]._qactive = QUEST_ACTIVE; + quests[Q_BLOOD]._qlog = 1; + quests[Q_BLOOD]._qvar1 = 1; SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 19, 2 * setpc_y + 26, 0, 1); SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 31, 2 * setpc_y + 26, 0, 1); SpawnQuestItem(IDI_BLDSTONE, 2 * setpc_x + 25, 2 * setpc_y + 33, 0, 1); } object[i]._otype = object[i]._otype; - if (object[i]._otype == OBJ_STEELTOME && !quests[QTYPE_WARLRD]._qvar1) { - quests[QTYPE_WARLRD]._qactive = 2; - quests[QTYPE_WARLRD]._qlog = 1; - quests[QTYPE_WARLRD]._qvar1 = 1; + if (object[i]._otype == OBJ_STEELTOME && !quests[Q_WARLORD]._qvar1) { + quests[Q_WARLORD]._qactive = QUEST_ACTIVE; + quests[Q_WARLORD]._qlog = 1; + quests[Q_WARLORD]._qvar1 = 1; } if (object[i]._oAnimFrame != object[i]._oVar6) { if (object[i]._otype != OBJ_BLOODBOOK) @@ -2982,26 +2982,26 @@ void OperateSChambBk(int pnum, int i) SyncObjectAnim(objectactive[j]); } object[i]._oAnimFrame = object[i]._oVar6; - if (quests[QTYPE_BONE]._qactive == 1) { - quests[QTYPE_BONE]._qactive = 2; - quests[QTYPE_BONE]._qlog = 1; + if (quests[Q_SCHAMB]._qactive == QUEST_INIT) { + quests[Q_SCHAMB]._qactive = QUEST_ACTIVE; + quests[Q_SCHAMB]._qlog = 1; } if (plr[myplr]._pClass == PC_WARRIOR) { - textdef = QUEST_BONER; + textdef = TEXT_BONER; } else if (plr[myplr]._pClass == PC_ROGUE) { - textdef = QUEST_RBONER; + textdef = TEXT_RBONER; } else if (plr[myplr]._pClass == PC_SORCERER) { - textdef = QUEST_MBONER; + textdef = TEXT_MBONER; #ifdef HELLFIRE } else if (plr[myplr]._pClass == PC_MONK) { - textdef = QUEST_HBONER; + textdef = TEXT_HBONER; } else if (plr[myplr]._pClass == PC_BARD) { - textdef = QUEST_BBONER; + textdef = TEXT_BBONER; } else if (plr[myplr]._pClass == PC_BARBARIAN) { - textdef = QUEST_BONER; + textdef = TEXT_BONER; #endif } - quests[QTYPE_BONE]._qmsg = textdef; + quests[Q_SCHAMB]._qmsg = textdef; InitQTextMsg(textdef); } } @@ -3069,7 +3069,7 @@ void OperateMushPatch(int pnum, int i) { int x, y; - if (quests[QTYPE_BLKM]._qactive != 2 || quests[QTYPE_BLKM]._qvar1 < QS_TOMEGIVEN) { + if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 < QS_TOMEGIVEN) { if (!deltaload && pnum == myplr) { if (plr[myplr]._pClass == PC_WARRIOR) { PlaySFX(PS_WARR13); @@ -3098,7 +3098,7 @@ void OperateMushPatch(int pnum, int i) if (!deltaload) { GetSuperItemLoc(object[i]._ox, object[i]._oy, x, y); SpawnQuestItem(IDI_MUSHROOM, x, y, 0, 0); - quests[QTYPE_BLKM]._qvar1 = QS_MUSHSPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_MUSHSPAWNED; } } } @@ -3108,7 +3108,7 @@ void OperateInnSignChest(int pnum, int i) { int x, y; - if (quests[QTYPE_BOL]._qvar1 != 2) { + if (quests[Q_LTBANNER]._qvar1 != 2) { if (!deltaload && pnum == myplr) { if (plr[myplr]._pClass == PC_WARRIOR) { PlaySFX(PS_WARR24); @@ -3422,8 +3422,8 @@ void OperateShrine(int pnum, int i, int sType) } if (cnt == 0) break; - r = random_(0, 7); - if (plr[pnum].InvBody[r]._itype == -1 || plr[pnum].InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || plr[pnum].InvBody[r]._iMaxDur == 0) + r = random_(0, NUM_INVLOC); + if (plr[pnum].InvBody[r]._itype == ITYPE_NONE || plr[pnum].InvBody[r]._iMaxDur == DUR_INDESTRUCTIBLE || plr[pnum].InvBody[r]._iMaxDur == 0) continue; plr[pnum].InvBody[r]._iDurability -= 20; @@ -3672,14 +3672,14 @@ void OperateShrine(int pnum, int i, int sType) || plr[pnum].InvList[j]._iMiscId == IMISC_MANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_REJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].InvList[j] = plr[pnum].HoldItem; } if (plr[pnum].InvList[j]._iMiscId == IMISC_FULLHEAL || plr[pnum].InvList[j]._iMiscId == IMISC_FULLMANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_FULLREJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].InvList[j] = plr[pnum].HoldItem; } } @@ -3690,14 +3690,14 @@ void OperateShrine(int pnum, int i, int sType) || plr[pnum].SpdList[j]._iMiscId == IMISC_MANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_REJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].SpdList[j] = plr[pnum].HoldItem; } if (plr[pnum].SpdList[j]._iMiscId == IMISC_FULLHEAL || plr[pnum].SpdList[j]._iMiscId == IMISC_FULLMANA) { SetPlrHandItem(&plr[pnum].HoldItem, ItemMiscIdIdx(IMISC_FULLREJUV)); GetPlrHandSeed(&plr[pnum].HoldItem); - plr[pnum].HoldItem._iStatFlag = 1; + plr[pnum].HoldItem._iStatFlag = TRUE; plr[pnum].SpdList[j] = plr[pnum].HoldItem; } } @@ -4139,11 +4139,11 @@ void OperateBookCase(int pnum, int i, DIABOOL sendmsg) if (!deltaload) { SetRndSeed(object[i]._oRndSeed); CreateTypeItem(object[i]._ox, object[i]._oy, FALSE, ITYPE_MISC, IMISC_BOOK, sendmsg, FALSE); - if (QuestStatus(QTYPE_ZHAR) + if (QuestStatus(Q_ZHAR) && monster[MAX_PLRS].mName == UniqMonst[UMT_ZHAR].mName && monster[MAX_PLRS]._msquelch == UCHAR_MAX && monster[MAX_PLRS]._mhitpoints) { - monster[MAX_PLRS].mtalkmsg = QUEST_ZHAR2; + monster[MAX_PLRS].mtalkmsg = TEXT_ZHAR2; M_StartStand(0, monster[MAX_PLRS]._mdir); monster[MAX_PLRS]._mgoal = MGOAL_SHOOT; monster[MAX_PLRS]._mmode = MM_TALK; @@ -4405,14 +4405,14 @@ void OperateStoryBook(int pnum, int i) PlaySfxLoc(IS_ISCROL, object[i]._ox, object[i]._oy); #ifdef HELLFIRE if (object[i]._oVar8 && currlevel == 24) { - if (IsUberLeverActivated != 1 && quests[QTYPE_NAKRUL]._qactive != 3 && objects_lv_24_454B04(object[i]._oVar8)) { + if (IsUberLeverActivated != 1 && quests[Q_NAKRUL]._qactive != 3 && objects_lv_24_454B04(object[i]._oVar8)) { NetSendCmd(FALSE, CMD_NAKRUL); return; } } else if (currlevel >= 21) { - quests[QTYPE_NAKRUL]._qactive = 2; - quests[QTYPE_NAKRUL]._qlog = 1; - quests[QTYPE_NAKRUL]._qmsg = object[i]._oVar2; + quests[Q_NAKRUL]._qactive = 2; + quests[Q_NAKRUL]._qlog = 1; + quests[Q_NAKRUL]._qmsg = object[i]._oVar2; } #endif InitQTextMsg(object[i]._oVar2); @@ -4854,12 +4854,12 @@ void SyncL1Doors(int i) ObjSetMicro(x, y, 408); else ObjSetMicro(x, y, 393); - dArch[x][y] = 7; + dSpecial[x][y] = 7; objects_set_door_piece(x - 1, y); y--; } else { ObjSetMicro(x, y, 395); - dArch[x][y] = 8; + dSpecial[x][y] = 8; objects_set_door_piece(x, y - 1); x--; } diff --git a/Source/pack.cpp b/Source/pack.cpp index 33c283c5..cdd25adb 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #ifndef HELLFIRE @@ -6,7 +6,7 @@ static #endif void PackItem(PkItemStruct *id, ItemStruct *is) { - if (is->_itype == -1) { + if (is->_itype == ITYPE_NONE) { id->idx = 0xFFFF; } else { id->idx = is->IDidx; @@ -116,15 +116,21 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) #endif } -// Note: last slot of item[MAXITEMS+1] used as temporary buffer -// find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] +/** + * Expand a PkItemStruct in to a ItemStruct + * + * Note: last slot of item[MAXITEMS+1] used as temporary buffer + * find real name reference below, possibly [sizeof(item[])/sizeof(ItemStruct)] + * @param is The source packed item + * @param id The distination item + */ #ifndef HELLFIRE static #endif void UnPackItem(PkItemStruct *is, ItemStruct *id) { if (is->idx == 0xFFFF) { - id->_itype = -1; + id->_itype = ITYPE_NONE; } else { if (is->idx == IDI_EAR) { RecreateEar( @@ -250,7 +256,7 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok) if (pnum == myplr) { for (i = 0; i < 20; i++) - witchitem[i]._itype = -1; + witchitem[i]._itype = ITYPE_NONE; } CalcPlrInv(pnum, FALSE); diff --git a/Source/palette.cpp b/Source/palette.cpp index 1d4e124c..9cf0e753 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" PALETTEENTRY logical_palette[256]; diff --git a/Source/path.cpp b/Source/path.cpp index 9988ca72..39906fe5 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -1,30 +1,37 @@ -#include "diablo.h" +/** + * @file path.cpp + * + * Implementation of the path finding algorithms. + */ +#include "all.h" -// preallocated nodes, search is terminated after 300 nodes are visited +/** Notes visisted by the path finding algorithm. */ PATHNODE path_nodes[MAXPATHNODES]; -// size of the pnode_tblptr stack +/** size of the pnode_tblptr stack */ int gdwCurPathStep; -// the number of in-use nodes in path_nodes +/** the number of in-use nodes in path_nodes */ int gdwCurNodes; -/* for reconstructing the path after the A* search is done. The longest +/** + * for reconstructing the path after the A* search is done. The longest * possible path is actually 24 steps, even though we can fit 25 */ -int pnode_vals[25]; -// a linked list of all visited nodes +int pnode_vals[MAX_PATH_LENGTH]; +/** A linked list of all visited nodes */ PATHNODE *pnode_ptr; -// a stack for recursively searching nodes +/** A stack for recursively searching nodes */ PATHNODE *pnode_tblptr[MAXPATHNODES]; -// a linked list of the A* frontier, sorted by distance +/** A linked list of the A* frontier, sorted by distance */ PATHNODE *path_2_nodes; PATHNODE path_unusednodes[MAXPATHNODES]; -// for iterating over the 8 possible movement directions +/** For iterating over the 8 possible movement directions */ const char pathxdir[8] = { -1, -1, 1, 1, -1, 0, 1, 0 }; const char pathydir[8] = { -1, 1, -1, 1, 0, -1, 0, 1 }; /* data */ -/* each step direction is assigned a number like this: +/** + * each step direction is assigned a number like this: * dx * -1 0 1 * +----- @@ -59,17 +66,16 @@ int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, // A* search until we find (dx,dy) or fail while ((next_node = GetNextPath())) { // reached the end, success! - if (next_node->x == dx && next_node->y == dy) - { + if (next_node->x == dx && next_node->y == dy) { current = next_node; path_length = 0; while (current->Parent) { - if (path_length >= 25) + if (path_length >= MAX_PATH_LENGTH) break; pnode_vals[path_length++] = path_directions[3 * (current->y - current->Parent->y) - current->Parent->x + 4 + current->x]; current = current->Parent; } - if (path_length != 25) { + if (path_length != MAX_PATH_LENGTH) { for (i = 0; i < path_length; i++) path[i] = pnode_vals[path_length - i - 1]; return i; diff --git a/Source/path.h b/Source/path.h index 04d30e27..83191d34 100644 --- a/Source/path.h +++ b/Source/path.h @@ -1,11 +1,15 @@ -//HEADER_GOES_HERE +/** + * @file path.h + * + * Interface of the path finding algorithms. + */ #ifndef __PATH_H__ #define __PATH_H__ extern PATHNODE path_nodes[MAXPATHNODES]; extern int gdwCurPathStep; extern int gdwCurNodes; -extern int pnode_vals[25]; +extern int pnode_vals[MAX_PATH_LENGTH]; extern PATHNODE *pnode_ptr; extern PATHNODE *pnode_tblptr[MAXPATHNODES]; extern PATHNODE *path_2_nodes; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index cf8790ec..64e4a504 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" #include "../DiabloUI/diabloui.h" @@ -10,6 +10,7 @@ #define PASSWORD_MULTI "szqnlsk1" #endif +/** List of character names for the character selection screen. */ static char hero_names[MAX_CHARACTERS][PLR_NAME_LEN]; BOOL gbValidSaveFile; diff --git a/Source/player.cpp b/Source/player.cpp index 7170ad68..2d714b82 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" int plr_lframe_size; @@ -65,7 +65,7 @@ int PWVel[3][3] = { { 2048, 1024, 512 }, { 2048, 1024, 512 } }; -// Total number of frames in walk animation. +/** Total number of frames in walk animation. */ int AnimLenFromClass[3] = { 8, 8, 8 }; @@ -310,7 +310,7 @@ void InitPlrGFXMem(int pnum) if (GetPlrGFXSize("ST") > GetPlrGFXSize("AS")) { plr_sframe_size = GetPlrGFXSize("ST"); //TOWN } else { - plr_sframe_size = GetPlrGFXSize("AS"); //DUNGION + plr_sframe_size = GetPlrGFXSize("AS"); //DUNGEON } } plr[pnum]._pNData = DiabloAllocPtr(plr_sframe_size); @@ -320,7 +320,7 @@ void InitPlrGFXMem(int pnum) if (GetPlrGFXSize("WL") > GetPlrGFXSize("AW")) { plr_wframe_size = GetPlrGFXSize("WL"); //TOWN } else { - plr_wframe_size = GetPlrGFXSize("AW"); //DUNGION + plr_wframe_size = GetPlrGFXSize("AW"); //DUNGEON } } plr[pnum]._pWData = DiabloAllocPtr(plr_wframe_size); @@ -1107,7 +1107,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | nSolidTable[dPiece[x][y]] | dArch[x][y]) { + if (bitflags | nSolidTable[dPiece[x][y]] | dSpecial[x][y]) { plr[pnum]._peflag = 1; } else { plr[pnum]._peflag = 0; @@ -1126,7 +1126,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | dArch[x][y]) { + if (bitflags | dSpecial[x][y]) { return; } @@ -1139,7 +1139,7 @@ void CheckEFlag(int pnum, BOOL flag) bitflags |= pieces->mt[i]; } - if (bitflags | dArch[x][y]) { + if (bitflags | dSpecial[x][y]) { plr[pnum]._peflag = 2; } } @@ -2200,7 +2200,7 @@ void InitLevelChange(int pnum) RemovePlrMissiles(pnum); if (pnum == myplr && qtextflag) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } RemovePlrFromMap(pnum); @@ -3281,7 +3281,7 @@ BOOL PM_DoDeath(int pnum) if (deathdelay == 1) { deathflag = TRUE; if (gbMaxPlayers == 1) { - gamemenu_previous(); + gamemenu_on(); } } } @@ -3338,7 +3338,7 @@ void CheckNewPath(int pnum) if (x < 2 && y < 2) { ClrPlrPath(pnum); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartAttack(pnum, d); @@ -3385,11 +3385,11 @@ void CheckNewPath(int pnum) break; } - for (i = 1; i < 25; i++) { + for (i = 1; i < MAX_PATH_LENGTH; i++) { plr[pnum].walkpath[i - 1] = plr[pnum].walkpath[i]; } - plr[pnum].walkpath[24] = WALK_NONE; + plr[pnum].walkpath[MAX_PATH_LENGTH - 1] = WALK_NONE; if (plr[pnum]._pmode == PM_STAND) { StartStand(pnum, plr[pnum]._pdir); @@ -3415,7 +3415,7 @@ void CheckNewPath(int pnum) y = abs(plr[pnum].WorldY - monster[i]._mfuty); if (x <= 1 && y <= 1) { d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartAttack(pnum, d); @@ -3438,7 +3438,7 @@ void CheckNewPath(int pnum) case ACTION_RATTACKMON: i = plr[pnum].destParam1; d = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mfutx, monster[i]._mfuty); - if (monster[i].mtalkmsg && monster[i].mtalkmsg != QUEST_VILE14) { + if (monster[i].mtalkmsg && monster[i].mtalkmsg != TEXT_VILE14) { TalktoMonster(i); } else { StartRangeAttack(pnum, d, monster[i]._mfutx, monster[i]._mfuty); @@ -4595,9 +4595,9 @@ void PlayDungMsgs() } else if (currlevel == 17 && !plr[myplr]._pLvlVisited[17] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs2 & 1)) { sfxdelay = 10; sfxdnum = USFX_DEFILER1; - quests[QTYPE_DEFILER]._qactive = 2; - quests[QTYPE_DEFILER]._qlog = 1; - quests[QTYPE_DEFILER]._qmsg = 286; + quests[Q_DEFILER]._qactive = 2; + quests[Q_DEFILER]._qlog = 1; + quests[Q_DEFILER]._qmsg = 286; plr[myplr].pDungMsgs2 |= 1; } else if (currlevel == 19 && !plr[myplr]._pLvlVisited[19] && gbMaxPlayers == 1 && !(plr[myplr].pDungMsgs2 & 4)) { sfxdelay = 10; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index 09c6fe84..d745df86 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -1,8 +1,9 @@ -#include "diablo.h" +#include "all.h" static BYTE plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; +/** Maps from player_num to text colour, as used in chat messages. */ const char text_color_from_player_num[MAX_PLRS + 1] = { COL_WHITE, COL_WHITE, COL_WHITE, COL_WHITE, COL_GOLD }; void plrmsg_delay(BOOL delay) @@ -133,7 +134,7 @@ void PrintPlrMsg(DWORD x, DWORD y, DWORD width, const char *str, BYTE col) c = gbFontTransTbl[(BYTE)*str++]; c = fontframe[c]; if (c) - CPrintString(screen, c, col); + PrintChar(screen, c, col); screen += fontkern[c] + 1; } diff --git a/Source/portal.cpp b/Source/portal.cpp index edf94618..88df7ac7 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -1,9 +1,13 @@ -#include "diablo.h" +#include "all.h" +/** In-game state of portals. */ PortalStruct portal[MAXPORTAL]; +/** Current portal number (a portal array index). */ int portalindex; +/** X-coordinate of each players portal in town. */ int WarpDropX[MAXPORTAL] = { 57, 59, 61, 63 }; +/** Y-coordinate of each players portal in town. */ int WarpDropY[MAXPORTAL] = { 40, 40, 40, 40 }; void InitPortals() diff --git a/Source/quests.cpp b/Source/quests.cpp index 1910d285..38beb04e 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int qtopline; BOOL questlog; @@ -17,31 +17,31 @@ int ReturnLvl; QuestData questlist[MAXQUESTS] = { // clang-format off // _qdlvl, _qdmultlvl, _qlvlt, _qdtype, _qdrnd, _qslvl, _qflags, _qdmsg, _qlstr - { 5, -1, DTYPE_NONE, QTYPE_INFRA, 100, 0, 0, QUEST_INFRA5, "The Magic Rock" }, - { 9, -1, DTYPE_NONE, QTYPE_BLKM, 100, 0, 0, QUEST_MUSH8, "Black Mushroom" }, - { 4, -1, DTYPE_NONE, QTYPE_GARB, 100, 0, 0, QUEST_GARBUD1, "Gharbad The Weak" }, - { 8, -1, DTYPE_NONE, QTYPE_ZHAR, 100, 0, 0, QUEST_ZHAR1, "Zhar the Mad" }, - { 14, -1, DTYPE_NONE, QTYPE_VEIL, 100, 0, 0, QUEST_VEIL9, "Lachdanan" }, - { 15, -1, DTYPE_NONE, QTYPE_MOD, 100, 0, 1, QUEST_VILE3, "Diablo" }, - { 2, 2, DTYPE_NONE, QTYPE_BUTCH, 100, 0, 1, QUEST_BUTCH9, "The Butcher" }, - { 4, -1, DTYPE_NONE, QTYPE_BOL, 100, 0, 0, QUEST_BANNER2, "Ogden's Sign" }, - { 7, -1, DTYPE_NONE, QTYPE_BLIND, 100, 0, 0, QUEST_BLINDING, "Halls of the Blind" }, - { 5, -1, DTYPE_NONE, QTYPE_BLOOD, 100, 0, 0, QUEST_BLOODY, "Valor" }, - { 10, -1, DTYPE_NONE, QTYPE_ANVIL, 100, 0, 0, QUEST_ANVIL5, "Anvil of Fury" }, - { 13, -1, DTYPE_NONE, QTYPE_WARLRD, 100, 0, 0, QUEST_BLOODWAR, "Warlord of Blood" }, - { 3, 3, DTYPE_CATHEDRAL, QTYPE_KING, 100, 1, 1, QUEST_KING2, "The Curse of King Leoric" }, - { 2, -1, DTYPE_CAVES, QTYPE_PW, 100, 4, 0, QUEST_POISON3, "Poisoned Water Supply" }, - { 6, -1, DTYPE_CATACOMBS, QTYPE_BONE, 100, 2, 0, QUEST_BONER, "The Chamber of Bone" }, - { 15, 15, DTYPE_CATHEDRAL, QTYPE_VB, 100, 5, 1, QUEST_VILE1, "Archbishop Lazarus" }, + { 5, -1, DTYPE_NONE, Q_ROCK, 100, 0, 0, TEXT_INFRA5, "The Magic Rock" }, + { 9, -1, DTYPE_NONE, Q_MUSHROOM, 100, 0, 0, TEXT_MUSH8, "Black Mushroom" }, + { 4, -1, DTYPE_NONE, Q_GARBUD, 100, 0, 0, TEXT_GARBUD1, "Gharbad The Weak" }, + { 8, -1, DTYPE_NONE, Q_ZHAR, 100, 0, 0, TEXT_ZHAR1, "Zhar the Mad" }, + { 14, -1, DTYPE_NONE, Q_VEIL, 100, 0, 0, TEXT_VEIL9, "Lachdanan" }, + { 15, -1, DTYPE_NONE, Q_DIABLO, 100, 0, 1, TEXT_VILE3, "Diablo" }, + { 2, 2, DTYPE_NONE, Q_BUTCHER, 100, 0, 1, TEXT_BUTCH9, "The Butcher" }, + { 4, -1, DTYPE_NONE, Q_LTBANNER, 100, 0, 0, TEXT_BANNER2, "Ogden's Sign" }, + { 7, -1, DTYPE_NONE, Q_BLIND, 100, 0, 0, TEXT_BLINDING, "Halls of the Blind" }, + { 5, -1, DTYPE_NONE, Q_BLOOD, 100, 0, 0, TEXT_BLOODY, "Valor" }, + { 10, -1, DTYPE_NONE, Q_ANVIL, 100, 0, 0, TEXT_ANVIL5, "Anvil of Fury" }, + { 13, -1, DTYPE_NONE, Q_WARLORD, 100, 0, 0, TEXT_BLOODWAR, "Warlord of Blood" }, + { 3, 3, DTYPE_CATHEDRAL, Q_SKELKING, 100, 1, 1, TEXT_KING2, "The Curse of King Leoric" }, + { 2, -1, DTYPE_CAVES, Q_PWATER, 100, 4, 0, TEXT_POISON3, "Poisoned Water Supply" }, + { 6, -1, DTYPE_CATACOMBS, Q_SCHAMB, 100, 2, 0, TEXT_BONER, "The Chamber of Bone" }, + { 15, 15, DTYPE_CATHEDRAL, Q_BETRAYER, 100, 5, 1, TEXT_VILE1, "Archbishop Lazarus" }, #ifdef HELLFIRE - { 17, 17, DTYPE_NONE, QTYPE_GRAVE, 100, 0, 1, QUEST_GRAVE7, "Grave Matters" }, - { 9, 9, DTYPE_NONE, QTYPE_FARMER, 100, 0, 1, QUEST_FARMER1, "Farmer's Orchard" }, - { 17, -1, DTYPE_NONE, QTYPE_GIRL, 100, 0, 0, QUEST_GIRL2, "Little Girl" }, - { 19, -1, DTYPE_NONE, QTYPE_TRADER, 100, 0, 0, QUEST_TRADER, "Wandering Trader" }, - { 17, 17, DTYPE_NONE, QTYPE_DEFILER,100, 0, 1, QUEST_DEFILER1, "The Defiler" }, - { 21, 21, DTYPE_NONE, QTYPE_NAKRUL, 100, 0, 1, QUEST_NAKRUL1, "Na-Krul" }, - { 21, -1, DTYPE_NONE, QTYPE_CORNSTN,100, 0, 0, QUEST_CORNSTN, "Cornerstone of the World" }, - { 9, 9, DTYPE_NONE, QTYPE_JERSEY, 100, 0, 1, QUEST_JERSEY4, "The Jersey's Jersey" }, + { 17, 17, DTYPE_NONE, Q_GRAVE, 100, 0, 1, TEXT_GRAVE7, "Grave Matters" }, + { 9, 9, DTYPE_NONE, Q_FARMER, 100, 0, 1, TEXT_FARMER1, "Farmer's Orchard" }, + { 17, -1, DTYPE_NONE, Q_GIRL, 100, 0, 0, TEXT_GIRL2, "Little Girl" }, + { 19, -1, DTYPE_NONE, Q_TRADER, 100, 0, 0, TEXT_TRADER, "Wandering Trader" }, + { 17, 17, DTYPE_NONE, Q_DEFILER,100, 0, 1, TEXT_DEFILER1, "The Defiler" }, + { 21, 21, DTYPE_NONE, Q_NAKRUL, 100, 0, 1, TEXT_NAKRUL1, "Na-Krul" }, + { 21, -1, DTYPE_NONE, Q_CORNSTN,100, 0, 0, TEXT_CORNSTN, "Cornerstone of the World" }, + { 9, 9, DTYPE_NONE, Q_JERSEY, 100, 0, 1, TEXT_JERSEY4, "The Jersey's Jersey" }, #endif // clang-format on }; @@ -54,10 +54,10 @@ char *questtrigstr[5] = { "A Dark Passage", "Unholy Altar" }; -int QuestGroup1[3] = { QTYPE_BUTCH, QTYPE_BOL, QTYPE_GARB }; -int QuestGroup2[3] = { QTYPE_BLIND, QTYPE_INFRA, QTYPE_BLOOD }; -int QuestGroup3[3] = { QTYPE_BLKM, QTYPE_ZHAR, QTYPE_ANVIL }; -int QuestGroup4[2] = { QTYPE_VEIL, QTYPE_WARLRD }; +int QuestGroup1[3] = { Q_BUTCHER, Q_LTBANNER, Q_GARBUD }; +int QuestGroup2[3] = { Q_BLIND, Q_ROCK, Q_BLOOD }; +int QuestGroup3[3] = { Q_MUSHROOM, Q_ZHAR, Q_ANVIL }; +int QuestGroup4[2] = { Q_VEIL, Q_WARLORD }; void InitQuests() { @@ -66,12 +66,12 @@ void InitQuests() if (gbMaxPlayers == 1) { for (i = 0; i < MAXQUESTS; i++) { - quests[i]._qactive = 0; + quests[i]._qactive = QUEST_NOTAVAIL; } } else { for (i = 0; i < MAXQUESTS; i++) { if (!(questlist[i]._qflags & 1)) { - quests[i]._qactive = 0; + quests[i]._qactive = QUEST_NOTAVAIL; } } } @@ -87,13 +87,13 @@ void InitQuests() if (gbMaxPlayers > 1) { quests[z]._qlevel = questlist[z]._qdmultlvl; if (!delta_quest_inited(initiatedQuests)) { - quests[z]._qactive = 1; + quests[z]._qactive = QUEST_INIT; quests[z]._qvar1 = 0; quests[z]._qlog = 0; } initiatedQuests++; } else { - quests[z]._qactive = 1; + quests[z]._qactive = QUEST_INIT; quests[z]._qlevel = questlist[z]._qdlvl; quests[z]._qvar1 = 0; quests[z]._qlog = 0; @@ -112,33 +112,33 @@ void InitQuests() if (gbMaxPlayers == 1) { SetRndSeed(glSeedTbl[15]); if (random_(0, 2)) - quests[QTYPE_PW]._qactive = 0; + quests[Q_PWATER]._qactive = QUEST_NOTAVAIL; else - quests[QTYPE_KING]._qactive = 0; + quests[Q_SKELKING]._qactive = QUEST_NOTAVAIL; - quests[QuestGroup1[random_(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = 0; - quests[QuestGroup2[random_(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = 0; - quests[QuestGroup3[random_(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = 0; - quests[QuestGroup4[random_(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = 0; + quests[QuestGroup1[random_(0, sizeof(QuestGroup1) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup2[random_(0, sizeof(QuestGroup2) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup3[random_(0, sizeof(QuestGroup3) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; + quests[QuestGroup4[random_(0, sizeof(QuestGroup4) / sizeof(int))]]._qactive = QUEST_NOTAVAIL; } #ifdef _DEBUG if (questdebug != -1) - quests[questdebug]._qactive = 2; + quests[questdebug]._qactive = QUEST_ACTIVE; #endif #ifdef SPAWN for (z = 0; z < MAXQUESTS; z++) { - quests[z]._qactive = 0; + quests[z]._qactive = QUEST_NOTAVAIL; } #endif - if (!quests[QTYPE_KING]._qactive) - quests[QTYPE_KING]._qvar2 = 2; - if (!quests[QTYPE_INFRA]._qactive) - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_BOL]._qvar1 = 1; + if (!quests[Q_SKELKING]._qactive) + quests[Q_SKELKING]._qvar2 = 2; + if (!quests[Q_ROCK]._qactive) + quests[Q_ROCK]._qvar2 = 2; + quests[Q_LTBANNER]._qvar1 = 1; if (gbMaxPlayers != 1) - quests[QTYPE_VB]._qvar1 = 2; + quests[Q_BETRAYER]._qvar1 = 2; } void CheckQuests() @@ -146,49 +146,49 @@ void CheckQuests() #ifndef SPAWN int i, rportx, rporty; - if (QuestStatus(QTYPE_VB) && gbMaxPlayers != 1 && quests[QTYPE_VB]._qvar1 == 2) { + if (QuestStatus(Q_BETRAYER) && gbMaxPlayers != 1 && quests[Q_BETRAYER]._qvar1 == 2) { AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); - quests[QTYPE_VB]._qvar1 = 3; - NetSendCmdQuest(TRUE, QTYPE_VB); + quests[Q_BETRAYER]._qvar1 = 3; + NetSendCmdQuest(TRUE, Q_BETRAYER); } if (gbMaxPlayers != 1) { return; } - if (currlevel == quests[QTYPE_VB]._qlevel + if (currlevel == quests[Q_BETRAYER]._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; + && quests[Q_BETRAYER]._qvar1 >= 2 + && (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE || quests[Q_BETRAYER]._qactive == QUEST_DONE) + && (quests[Q_BETRAYER]._qvar2 == 0 || quests[Q_BETRAYER]._qvar2 == 2)) { + quests[Q_BETRAYER]._qtx = 2 * quests[Q_BETRAYER]._qtx + 16; + quests[Q_BETRAYER]._qty = 2 * quests[Q_BETRAYER]._qty + 16; + rportx = quests[Q_BETRAYER]._qtx; + rporty = quests[Q_BETRAYER]._qty; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 1; - if (quests[QTYPE_VB]._qactive == 2) { - quests[QTYPE_VB]._qvar1 = 3; + quests[Q_BETRAYER]._qvar2 = 1; + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) { + quests[Q_BETRAYER]._qvar1 = 3; } } - if (quests[QTYPE_VB]._qactive == 3 + if (quests[Q_BETRAYER]._qactive == QUEST_DONE && setlevel && setlvlnum == SL_VILEBETRAYER - && quests[QTYPE_VB]._qvar2 == 4) { + && quests[Q_BETRAYER]._qvar2 == 4) { rportx = 35; rporty = 32; AddMissile(rportx, rporty, rportx, rporty, 0, MIS_RPORTAL, 0, myplr, 0, 0); - quests[QTYPE_VB]._qvar2 = 3; + quests[Q_BETRAYER]._qvar2 = 3; } if (setlevel) { - if (setlvlnum == quests[QTYPE_PW]._qslvl - && quests[QTYPE_PW]._qactive != 1 - && leveltype == quests[QTYPE_PW]._qlvltype + if (setlvlnum == quests[Q_PWATER]._qslvl + && quests[Q_PWATER]._qactive != QUEST_INIT + && leveltype == quests[Q_PWATER]._qlvltype && nummonsters == 4 - && quests[QTYPE_PW]._qactive != 3) { - quests[QTYPE_PW]._qactive = 3; + && quests[Q_PWATER]._qactive != QUEST_DONE) { + quests[Q_PWATER]._qactive = QUEST_DONE; PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY); LoadPalette("Levels\\L3Data\\L3pwater.pal"); WaterDone = 32; @@ -201,7 +201,7 @@ void CheckQuests() for (i = 0; i < MAXQUESTS; i++) { if (currlevel == quests[i]._qlevel && quests[i]._qslvl != 0 - && quests[i]._qactive != 0 + && quests[i]._qactive != QUEST_NOTAVAIL && plr[myplr].WorldX == quests[i]._qtx && plr[myplr].WorldY == quests[i]._qty) { if (quests[i]._qlvltype != 255) { @@ -225,7 +225,7 @@ BOOL ForceQuests() for (i = 0; i < MAXQUESTS; i++) { - if (i != QTYPE_VB && currlevel == quests[i]._qlevel && quests[i]._qslvl != 0) { + if (i != Q_BETRAYER && currlevel == quests[i]._qlevel && quests[i]._qslvl != 0) { ql = quests[quests[i]._qidx]._qslvl - 1; qx = quests[i]._qtx; qy = quests[i]._qty; @@ -264,7 +264,7 @@ void CheckQuestKill(int m, BOOL sendmsg) int i, j; if (monster[m].MType->mtype == MT_SKING) { - quests[QTYPE_KING]._qactive = 3; + quests[Q_SKELKING]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR82; @@ -283,10 +283,10 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } else if (monster[m].MType->mtype == MT_CLEAVER) { - quests[QTYPE_BUTCH]._qactive = 3; + quests[Q_BUTCHER]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR80; @@ -305,9 +305,9 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif if (sendmsg) - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + NetSendCmdQuest(TRUE, Q_BUTCHER); } else if (monster[m].mName == UniqMonst[UMT_GARBUD].mName) { //"Gharbad the Weak" - quests[QTYPE_GARB]._qactive = 3; + quests[Q_GARBUD]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR61; @@ -326,7 +326,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif } else if (monster[m].mName == UniqMonst[UMT_ZHAR].mName) { //"Zhar the Mad" - quests[QTYPE_ZHAR]._qactive = 3; + quests[Q_ZHAR]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR62; @@ -345,10 +345,10 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers != 1) { //"Arch-Bishop Lazarus" - quests[QTYPE_VB]._qactive = 3; - quests[QTYPE_VB]._qvar1 = 7; + quests[Q_BETRAYER]._qactive = QUEST_DONE; + quests[Q_BETRAYER]._qvar1 = 7; sfxdelay = 30; - quests[QTYPE_MOD]._qactive = 2; + quests[Q_DIABLO]._qactive = QUEST_ACTIVE; for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { @@ -377,16 +377,16 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif if (sendmsg) { - NetSendCmdQuest(TRUE, QTYPE_VB); - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_BETRAYER); + NetSendCmdQuest(TRUE, Q_DIABLO); } } else if (monster[m].mName == UniqMonst[UMT_LAZURUS].mName && gbMaxPlayers == 1) { //"Arch-Bishop Lazarus" - quests[QTYPE_VB]._qactive = 3; + quests[Q_BETRAYER]._qactive = QUEST_DONE; sfxdelay = 30; InitVPTriggers(); - quests[QTYPE_VB]._qvar1 = 7; - quests[QTYPE_VB]._qvar2 = 4; - quests[QTYPE_MOD]._qactive = 2; + quests[Q_BETRAYER]._qvar1 = 7; + quests[Q_BETRAYER]._qvar2 = 4; + quests[Q_DIABLO]._qactive = QUEST_ACTIVE; AddMissile(35, 32, 35, 32, 0, MIS_RPORTAL, 0, myplr, 0, 0); if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR83; @@ -405,7 +405,7 @@ void CheckQuestKill(int m, BOOL sendmsg) } #endif } else if (monster[m].mName == UniqMonst[UMT_WARLORD].mName) { //"Warlord of Blood" - quests[QTYPE_WARLRD]._qactive = 3; + quests[Q_WARLORD]._qactive = QUEST_DONE; sfxdelay = 30; if (plr[myplr]._pClass == PC_WARRIOR) { sfxdnum = PS_WARR94; @@ -592,25 +592,25 @@ void DRLG_CheckQuests(int x, int y) for (i = 0; i < MAXQUESTS; i++) { if (QuestStatus(i)) { switch (quests[i]._qtype) { - case QTYPE_BUTCH: + case Q_BUTCHER: DrawButcher(); break; - case QTYPE_BOL: + case Q_LTBANNER: DrawLTBanner(x, y); break; - case QTYPE_BLIND: + case Q_BLIND: DrawBlind(x, y); break; - case QTYPE_BLOOD: + case Q_BLOOD: DrawBlood(x, y); break; - case QTYPE_WARLRD: + case Q_WARLORD: DrawWarLord(x, y); break; - case QTYPE_KING: + case Q_SKELKING: DrawSkelKing(i, x, y); break; - case QTYPE_BONE: + case Q_SCHAMB: DrawSChamber(i, x, y); break; } @@ -622,27 +622,27 @@ void SetReturnLvlPos() { switch (setlvlnum) { case SL_SKELKING: - ReturnLvlX = quests[QTYPE_KING]._qtx + 1; - ReturnLvlY = quests[QTYPE_KING]._qty; - ReturnLvl = quests[QTYPE_KING]._qlevel; + ReturnLvlX = quests[Q_SKELKING]._qtx + 1; + ReturnLvlY = quests[Q_SKELKING]._qty; + ReturnLvl = quests[Q_SKELKING]._qlevel; ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_BONECHAMB: - ReturnLvlX = quests[QTYPE_BONE]._qtx + 1; - ReturnLvlY = quests[QTYPE_BONE]._qty; - ReturnLvl = quests[QTYPE_BONE]._qlevel; + ReturnLvlX = quests[Q_SCHAMB]._qtx + 1; + ReturnLvlY = quests[Q_SCHAMB]._qty; + ReturnLvl = quests[Q_SCHAMB]._qlevel; ReturnLvlT = DTYPE_CATACOMBS; break; case SL_POISONWATER: - ReturnLvlX = quests[QTYPE_PW]._qtx; - ReturnLvlY = quests[QTYPE_PW]._qty + 1; - ReturnLvl = quests[QTYPE_PW]._qlevel; + ReturnLvlX = quests[Q_PWATER]._qtx; + ReturnLvlY = quests[Q_PWATER]._qty + 1; + ReturnLvl = quests[Q_PWATER]._qlevel; ReturnLvlT = DTYPE_CATHEDRAL; break; case SL_VILEBETRAYER: - ReturnLvlX = quests[QTYPE_VB]._qtx + 1; - ReturnLvlY = quests[QTYPE_VB]._qty - 1; - ReturnLvl = quests[QTYPE_VB]._qlevel; + ReturnLvlX = quests[Q_BETRAYER]._qtx + 1; + ReturnLvlY = quests[Q_BETRAYER]._qty - 1; + ReturnLvl = quests[Q_BETRAYER]._qlevel; ReturnLvlT = DTYPE_HELL; break; } @@ -650,8 +650,8 @@ void SetReturnLvlPos() void GetReturnLvlPos() { - if (quests[QTYPE_VB]._qactive == 3) - quests[QTYPE_VB]._qvar2 = 2; + if (quests[Q_BETRAYER]._qactive == QUEST_DONE) + quests[Q_BETRAYER]._qvar2 = 2; ViewX = ReturnLvlX; ViewY = ReturnLvlY; currlevel = ReturnLvl; @@ -661,40 +661,40 @@ void GetReturnLvlPos() void ResyncMPQuests() { #ifndef SPAWN - if (quests[QTYPE_KING]._qactive == 1 - && currlevel >= quests[QTYPE_KING]._qlevel - 1 - && currlevel <= quests[QTYPE_KING]._qlevel + 1) { - quests[QTYPE_KING]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_KING); + if (quests[Q_SKELKING]._qactive == QUEST_INIT + && currlevel >= quests[Q_SKELKING]._qlevel - 1 + && currlevel <= quests[Q_SKELKING]._qlevel + 1) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_SKELKING); } - if (quests[QTYPE_BUTCH]._qactive == 1 - && currlevel >= quests[QTYPE_BUTCH]._qlevel - 1 - && currlevel <= quests[QTYPE_BUTCH]._qlevel + 1) { - quests[QTYPE_BUTCH]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + if (quests[Q_BUTCHER]._qactive == QUEST_INIT + && currlevel >= quests[Q_BUTCHER]._qlevel - 1 + && currlevel <= quests[Q_BUTCHER]._qlevel + 1) { + quests[Q_BUTCHER]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_BUTCHER); } - if (quests[QTYPE_VB]._qactive == 1 && currlevel == quests[QTYPE_VB]._qlevel - 1) { - quests[QTYPE_VB]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_VB); + if (quests[Q_BETRAYER]._qactive == QUEST_INIT && currlevel == quests[Q_BETRAYER]._qlevel - 1) { + quests[Q_BETRAYER]._qactive = QUEST_ACTIVE; + NetSendCmdQuest(TRUE, Q_BETRAYER); } - if (QuestStatus(QTYPE_VB)) + if (QuestStatus(Q_BETRAYER)) AddObject(OBJ_ALTBOY, 2 * setpc_x + 20, 2 * setpc_y + 22); #ifdef HELLFIRE - if (quests[QTYPE_GRAVE]._qactive == 1 && currlevel == quests[QTYPE_GRAVE]._qlevel - 1) { - quests[QTYPE_GRAVE]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_GRAVE); + if (quests[Q_GRAVE]._qactive == 1 && currlevel == quests[Q_GRAVE]._qlevel - 1) { + quests[Q_GRAVE]._qactive = 2; + NetSendCmdQuest(TRUE, Q_GRAVE); } - if (quests[QTYPE_DEFILER]._qactive == 1 && currlevel == quests[QTYPE_DEFILER]._qlevel - 1) { - quests[QTYPE_DEFILER]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_DEFILER); + if (quests[Q_DEFILER]._qactive == 1 && currlevel == quests[Q_DEFILER]._qlevel - 1) { + quests[Q_DEFILER]._qactive = 2; + NetSendCmdQuest(TRUE, Q_DEFILER); } - if (quests[QTYPE_NAKRUL]._qactive == 1 && currlevel == quests[QTYPE_NAKRUL]._qlevel - 1) { - quests[QTYPE_NAKRUL]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_NAKRUL); + if (quests[Q_NAKRUL]._qactive == 1 && currlevel == quests[Q_NAKRUL]._qlevel - 1) { + quests[Q_NAKRUL]._qactive = 2; + NetSendCmdQuest(TRUE, Q_NAKRUL); } - if (quests[QTYPE_JERSEY]._qactive == 1 && currlevel == quests[QTYPE_JERSEY]._qlevel - 1) { - quests[QTYPE_JERSEY]._qactive = 2; - NetSendCmdQuest(TRUE, QTYPE_JERSEY); + if (quests[Q_JERSEY]._qactive == 1 && currlevel == quests[Q_JERSEY]._qlevel - 1) { + quests[Q_JERSEY]._qactive = 2; + NetSendCmdQuest(TRUE, Q_JERSEY); } #endif #endif @@ -705,9 +705,9 @@ void ResyncQuests() #ifndef SPAWN int i, tren, x, y; - if (setlevel && setlvlnum == quests[QTYPE_PW]._qslvl && quests[QTYPE_PW]._qactive != 1 && leveltype == quests[QTYPE_PW]._qlvltype) { + if (setlevel && setlvlnum == quests[Q_PWATER]._qslvl && quests[Q_PWATER]._qactive != QUEST_INIT && leveltype == quests[Q_PWATER]._qlvltype) { - if (quests[QTYPE_PW]._qactive == 3) + if (quests[Q_PWATER]._qactive == QUEST_DONE) LoadPalette("Levels\\L3Data\\L3pwater.pal"); else LoadPalette("Levels\\L3Data\\L3pfoul.pal"); @@ -716,14 +716,14 @@ void ResyncQuests() palette_update_quest_palette(i); } - if (QuestStatus(QTYPE_BOL)) { - if (quests[QTYPE_BOL]._qvar1 == 1) + if (QuestStatus(Q_LTBANNER)) { + if (quests[Q_LTBANNER]._qvar1 == 1) ObjChangeMapResync( setpc_w + setpc_x - 2, setpc_h + setpc_y - 2, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1); - if (quests[QTYPE_BOL]._qvar1 == 2) { + if (quests[Q_LTBANNER]._qvar1 == 2) { ObjChangeMapResync( setpc_w + setpc_x - 2, setpc_h + setpc_y - 2, @@ -737,7 +737,7 @@ void ResyncQuests() DRLG_MRectTrans(setpc_x, setpc_y, (setpc_w >> 1) + setpc_x + 4, setpc_y + (setpc_h >> 1)); TransVal = tren; } - if (quests[QTYPE_BOL]._qvar1 == 3) { + if (quests[Q_LTBANNER]._qvar1 == 3) { x = setpc_x; y = setpc_y; ObjChangeMapResync(x, y, x + setpc_w + 1, y + setpc_h + 1); @@ -749,40 +749,40 @@ void ResyncQuests() TransVal = tren; } } - if (currlevel == quests[QTYPE_BLKM]._qlevel) { - if (quests[QTYPE_BLKM]._qactive == 1 && !quests[QTYPE_BLKM]._qvar1) { + if (currlevel == quests[Q_MUSHROOM]._qlevel) { + if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && !quests[Q_MUSHROOM]._qvar1) { SpawnQuestItem(IDI_FUNGALTM, 0, 0, 5, 1); - quests[QTYPE_BLKM]._qvar1 = QS_TOMESPAWNED; + quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED; } else { - if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 >= QS_MUSHGIVEN) { + if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { + if (quests[Q_MUSHROOM]._qvar1 >= QS_MUSHGIVEN) { Qtalklist[TOWN_WITCH]._qblkm = -1; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; - } else if (quests[QTYPE_BLKM]._qvar1 >= QS_BRAINGIVEN) { + Qtalklist[TOWN_HEALER]._qblkm = TEXT_MUSH3; + } else if (quests[Q_MUSHROOM]._qvar1 >= QS_BRAINGIVEN) { Qtalklist[TOWN_HEALER]._qblkm = -1; } } } } - if (currlevel == quests[QTYPE_VEIL]._qlevel + 1 && quests[QTYPE_VEIL]._qactive == 2 && !quests[QTYPE_VEIL]._qvar1) { - quests[QTYPE_VEIL]._qvar1 = 1; + if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && !quests[Q_VEIL]._qvar1) { + quests[Q_VEIL]._qvar1 = 1; SpawnQuestItem(IDI_GLDNELIX, 0, 0, 5, 1); } if (setlevel && setlvlnum == SL_VILEBETRAYER) { - if (quests[QTYPE_VB]._qvar1 >= 4) + if (quests[Q_BETRAYER]._qvar1 >= 4) ObjChangeMapResync(1, 11, 20, 18); - if (quests[QTYPE_VB]._qvar1 >= 6) + if (quests[Q_BETRAYER]._qvar1 >= 6) ObjChangeMapResync(1, 18, 20, 24); - if (quests[QTYPE_VB]._qvar1 >= 7) + if (quests[Q_BETRAYER]._qvar1 >= 7) InitVPTriggers(); for (i = 0; i < nobjects; i++) SyncObjectAnim(objectactive[i]); } - if (currlevel == quests[QTYPE_VB]._qlevel + if (currlevel == quests[Q_BETRAYER]._qlevel && !setlevel - && (quests[QTYPE_VB]._qvar2 == 1 || quests[QTYPE_VB]._qvar2 >= 3) - && (quests[QTYPE_VB]._qactive == 2 || quests[QTYPE_VB]._qactive == 3)) { - quests[QTYPE_VB]._qvar2 = 2; + && (quests[Q_BETRAYER]._qvar2 == 1 || quests[Q_BETRAYER]._qvar2 >= 3) + && (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE || quests[Q_BETRAYER]._qactive == QUEST_DONE)) { + quests[Q_BETRAYER]._qvar2 = 2; } #endif } @@ -811,7 +811,7 @@ void PrintQLString(int x, int y, BOOL cjustflag, char *str, int col) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= 257) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } @@ -841,7 +841,7 @@ void StartQuestlog() numqlines = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && quests[i]._qlog) { qlist[numqlines] = i; numqlines++; } @@ -916,7 +916,7 @@ void QuestlogESC() void SetMultiQuest(int q, int s, int l, int v1) { #ifndef SPAWN - if (quests[q]._qactive != 3) { + if (quests[q]._qactive != QUEST_DONE) { if (s > quests[q]._qactive) quests[q]._qactive = s; quests[q]._qlog |= l; diff --git a/Source/render.cpp b/Source/render.cpp index bf740a63..7d1327f9 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "_asm.cpp" int WorldBoolFlag = 0; @@ -84,7 +84,7 @@ int WorldTbl3x16[48] = { 60, 60, 60 }; -// slope/angle tables, left and right +/** slope/angle tables, left and right */ int WorldTbl17_1[17] = { 0, 4, 8, 16, 24, 36, 48, 64, 80, 100, 120, 144, 168, 196, 224, 256, 288 }; int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, 240, 248, 252, 256, 288 }; @@ -114,6 +114,11 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, #ifdef USE_ASM #include "_render.cpp" #else +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit upper part of transparent world CELs + * @param pBuff Output buffer + */ void drawTopArchesUpperScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -1137,6 +1142,12 @@ void drawTopArchesUpperScreen(BYTE *pBuff) } } +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit lower part of transparent world CELs + * @param pBuff Output buffer + * @param pMask Transparancy pattern + */ void drawBottomArchesUpperScreen(BYTE *pBuff, DWORD *pMask) { BYTE *dst, *src; @@ -1769,6 +1780,11 @@ void drawBottomArchesUpperScreen(BYTE *pBuff, DWORD *pMask) } } +/** + * While blitting this function will check for the upper bound of the buffer + * @brief Blit current world CEL to the given buffer + * @param pBuff Output buffer + */ void drawUpperScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -2386,6 +2402,11 @@ void drawUpperScreen(BYTE *pBuff) } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit upper part of transparent world CELs + * @param pBuff Output buffer + */ void drawTopArchesLowerScreen(BYTE *pBuff) { BYTE *dst, *src; @@ -3622,6 +3643,12 @@ LABEL_11: } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit lower part of transparent world CELs + * @param pBuff Output buffer + * @param pMask Transparancy pattern + */ void drawBottomArchesLowerScreen(BYTE *pBuff, DWORD *pMask) { BYTE *dst, *src; @@ -4414,6 +4441,11 @@ void drawBottomArchesLowerScreen(BYTE *pBuff, DWORD *pMask) } } +/** + * While blitting this function will check for the lower bound of the buffer + * @brief Blit current world CEL to the given buffer + * @param pBuff Output buffer + */ void drawLowerScreen(BYTE *pBuff) { BYTE *dst, *src; diff --git a/Source/restrict.cpp b/Source/restrict.cpp index 643c54c5..0522480c 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL SystemSupported() { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 0bdfc1e2..afefcb46 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1,26 +1,54 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" +/** + * Specifies the current light entry. + */ int light_table_index; int PitchTbl[1024]; DWORD sgdwCursWdtOld; DWORD sgdwCursX; DWORD sgdwCursY; +/** + * Lower bound of back buffer. + */ BYTE *gpBufEnd; DWORD sgdwCursHgt; + +/** + * Specifies the current MIN block of the level CEL file, as used during rendering of the level tiles. + * + * frameNum := block & 0x0FFF + * frameType := block & 0x7000 >> 12 + */ DWORD level_cel_block; DWORD sgdwCursXOld; DWORD sgdwCursYOld; #ifdef HELLFIRE BOOLEAN AutoMapShowItems; #endif +/** + * Specifies the type of arches to render. + */ char arch_draw_type; +/** + * Describes the surface being rendered. + */ DDSURFACEDESC DDS_desc; +/** + * Specifies whether transparency is active for the current CEL file being decoded. + */ int cel_transparency_active; +/** + * Specifies the current dungeon piece ID of the level, as used during rendering of the level tiles. + */ int level_piece_id; DWORD sgdwCursWdt; void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); BYTE sgSaveBack[8192]; +/** + * Specifies the monster_num to render. + */ int draw_monster_num; DWORD sgdwCursHgtOld; @@ -63,6 +91,9 @@ char *szPlrModeAssert[12] = { "quitting" }; +/** + * @brief Clear cursor state + */ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp { sgdwCursWdt = 0; @@ -70,7 +101,7 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp } /** - * @brief Remove the cursor from the backbuffer + * @brief Remove the cursor from the back buffer */ static void scrollrt_draw_cursor_back_buffer() { @@ -102,7 +133,7 @@ static void scrollrt_draw_cursor_back_buffer() } /** - * @brief Draw the cursor on the backbuffer + * @brief Draw the cursor on the back buffer */ static void scrollrt_draw_cursor_item() { @@ -192,11 +223,11 @@ static void scrollrt_draw_cursor_item() } /** - * @brief Render a missile sprite + * @brief Render a missile sprites for a given tile * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param pre Is the sprite in the background @@ -274,8 +305,8 @@ void DrawMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL pre * @brief Render a missile sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param pre Is the sprite in the background @@ -353,8 +384,8 @@ void DrawClippedMissile(int x, int y, int sx, int sy, int CelSkip, int CelCap, B * @brief Render a monster sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param mx Backbuffer coordinate - * @param my Backbuffer coordinate + * @param mx Back buffer coordinate + * @param my Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw */ @@ -415,8 +446,8 @@ static void DrawMonster(int x, int y, int mx, int my, int m, int CelSkip, int Ce * @brief Render a monster sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param mx Backbuffer coordinate - * @param my Backbuffer coordinate + * @param mx Back buffer coordinate + * @param my Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw */ @@ -474,12 +505,12 @@ static void DrawClippedMonster(int x, int y, int mx, int my, int m, int CelSkip, } /** - * @brief Render a monster sprite + * @brief Render a player sprite * @param pnum Player id * @param x dPiece coordinate * @param y dPiece coordinate - * @param px Backbuffer coordinate - * @param py Backbuffer coordinate + * @param px Back buffer coordinate + * @param py Back buffer coordinate * @param pCelBuff sprite buffer * @param nCel frame * @param nWidth width @@ -570,8 +601,8 @@ static void DrawPlayer(int pnum, int x, int y, int px, int py, BYTE *pCelBuff, i * @param pnum Player id * @param x dPiece coordinate * @param y dPiece coordinate - * @param px Backbuffer coordinate - * @param py Backbuffer coordinate + * @param px Back buffer coordinate + * @param py Back buffer coordinate * @param pCelBuff sprite buffer * @param nCel frame * @param nWidth width @@ -658,11 +689,11 @@ static void DrawClippedPlayer(int pnum, int x, int y, int px, int py, BYTE *pCel } /** - * @brief Render a monster sprite + * @brief Render a player sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw * @param clipped check for overdraw on lower screen @@ -707,8 +738,8 @@ void DrawDeadPlayer(int x, int y, int sx, int sy, int CelSkip, int CelCap, BOOL * @brief Render an object sprite * @param x dPiece coordinate * @param y dPiece coordinate - * @param ox Backbuffer coordinate - * @param oy Backbuffer coordinate + * @param ox Back buffer coordinate + * @param oy Back buffer coordinate * @param pre Is the sprite in the background * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw @@ -777,8 +808,8 @@ static void DrawObject(int x, int y, int ox, int oy, BOOL pre, int CelSkip, int * @brief Render an object sprite, check for overdraw on lower screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param ox Backbuffer coordinate - * @param oy Backbuffer coordinate + * @param ox Back buffer coordinate + * @param oy Back buffer coordinate * @param pre Is the sprite in the background * @param CelSkip Skip part of sprite, see Cl2Draw * @param CelCap Skip part of sprite, see Cl2Draw @@ -846,8 +877,8 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i * @param pBuff Pointer to output buffer at location sx,sy * @param y dPiece coordinate * @param x dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int sy) { @@ -902,8 +933,8 @@ static void scrollrt_draw_clipped_e_flag(BYTE *pBuff, int x, int y, int sx, int * @param pBuff where to render to with sx,sy already applied * @param sx dPiece coordinate * @param sy dPiece coordinate - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, int dy, int eflag) @@ -924,7 +955,7 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -1124,8 +1155,8 @@ static void scrollrt_draw_clipped_dungeon(BYTE *pBuff, int sx, int sy, int dx, i * @brief Render a row of tile * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param eflag is it an even (0) or odd (1) row */ @@ -1288,8 +1319,8 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row * @param x dPiece coordinate * @param row The current row being rendered * @param CelSkip chunks of cell to skip - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, int CelSkip, int sx, int sy) { @@ -1367,8 +1398,8 @@ static void scrollrt_draw_clipped_e_flag_2(BYTE *pBuff, int x, int y, int row, i * @param sy dPiece coordinate * @param row The current row being rendered * @param CelSkip chunks of cell to skip - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, int dx, int dy, int eflag) @@ -1389,7 +1420,7 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -1589,8 +1620,8 @@ static void scrollrt_draw_clipped_dungeon_2(BYTE *pBuff, int sx, int sy, int row * @brief Render a row of tile, checking for overdrawing on lower part of screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param row current row being rendered * @param eflag is it an even (0) or odd (1) row @@ -1706,8 +1737,8 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC * @param x dPiece coordinate * @param row The current row being rendered * @param CelCap chunks of cell to skip - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate */ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, int sy) { @@ -1765,8 +1796,8 @@ static void scrollrt_draw_e_flag(BYTE *pBuff, int x, int y, int row, int CelCap, * @param sy dPiece coordinate * @param row The current row being rendered * @param CelCap chunks of cell to skip - * @param dx Backbuffer coordinate - * @param dy Backbuffer coordinate + * @param dx Back buffer coordinate + * @param dy Back buffer coordinate * @param eflag Should the sorting workaround be applied */ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelCap, int dx, int dy, int eflag) @@ -1787,7 +1818,7 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC bObj = dObject[sx][sy]; bItem = dItem[sx][sy]; bPlr = dPlayer[sx][sy]; - bArch = dArch[sx][sy]; + bArch = dSpecial[sx][sy]; bMap = dTransVal[sx][sy]; nMon = dMonster[sx][sy]; @@ -1977,8 +2008,8 @@ static void scrollrt_draw_dungeon(BYTE *pBuff, int sx, int sy, int row, int CelC * @brief Render a row of tile, checking for overdrawing on upper part of screen * @param x dPiece coordinate * @param y dPiece coordinate - * @param sx Backbuffer coordinate - * @param sy Backbuffer coordinate + * @param sx Back buffer coordinate + * @param sy Back buffer coordinate * @param chunks tile width of row * @param row current row being rendered * @param eflag is it an even (0) or odd (1) row @@ -2140,10 +2171,10 @@ static void DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + SCREEN_X; sy = ScrollInfo._syoff + SCREEN_Y + 15; @@ -2248,10 +2279,10 @@ static void DrawZoom(int x, int y) int i, sx, sy, chunks, blocks; int wdt, nSrcOff, nDstOff; - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT - 32; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = (ZOOM_HEIGHT - 32) / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT - 32; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = (ZOOM_HEIGHT - 32) / 32; sx = ScrollInfo._sxoff + SCREEN_X; sy = ScrollInfo._syoff + SCREEN_Y - 17; @@ -2261,8 +2292,6 @@ static void DrawZoom(int x, int y) blocks = 3; switch (ScrollInfo._sdir) { - case SDIR_NONE: - break; case SDIR_NE: chunks++; case SDIR_N: @@ -2626,11 +2655,11 @@ static void DrawFPS() #endif /** - * @brief Update part of the screen from the backbuffer - * @param dwX Backbuffer coordinate - * @param dwY Backbuffer coordinate - * @param dwWdt Backbuffer coordinate - * @param dwHgt Backbuffer coordinate + * @brief Update part of the screen from the back buffer + * @param dwX Back buffer coordinate + * @param dwY Back buffer coordinate + * @param dwWdt Back buffer coordinate + * @param dwHgt Back buffer coordinate */ static void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) { @@ -2857,6 +2886,10 @@ static void DrawMain(int dwHgt, BOOL draw_desc, BOOL draw_hp, BOOL draw_mana, BO #endif } +/** + * @brief Redraw screen + * @param draw_cursor + */ void scrollrt_draw_game_screen(BOOL draw_cursor) { int hgt; @@ -2920,7 +2953,7 @@ void DrawAndBlit() T_DrawView(ViewX, ViewY); } if (ctrlPan) { - ClearCtrlPan(); + DrawCtrlPan(); } if (drawhpflag) { UpdateLifeFlask(); @@ -2929,7 +2962,7 @@ void DrawAndBlit() UpdateManaFlask(); } if (drawbtnflag) { - DrawCtrlPan(); + DrawCtrlBtns(); } if (drawsbarflag) { DrawInvBelt(); diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 84d5714e..d3dd3949 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -33,7 +33,7 @@ void DrawAndBlit(); /* data */ -/* used in 1.00 debug */ +/** used in 1.00 debug */ extern char *szMonModeAssert[18]; extern char *szPlrModeAssert[12]; diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 273eea86..286d6cd0 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" // BUGFIX: constant data should be const BYTE SkelKingTrans1[8] = { @@ -54,6 +54,7 @@ BYTE SkelChamTrans3[36] = { 50, 43, 59, 51 }; +/** Maps from quest level to quest level names. */ char *quest_level_names[] = { "", "Skeleton King's Lair", @@ -132,9 +133,9 @@ void LoadSetMap() { switch (setlvlnum) { case SL_SKELKING: - if (quests[QTYPE_KING]._qactive == 1) { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; + if (quests[Q_SKELKING]._qactive == QUEST_INIT) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + quests[Q_SKELKING]._qvar1 = 1; } LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45); LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45); @@ -166,18 +167,18 @@ void LoadSetMap() DRLG_SetMapTrans("Levels\\L1Data\\Lv1MazeA.DUN"); break; case SL_POISONWATER: - if (quests[QTYPE_PW]._qactive == 1) - quests[QTYPE_PW]._qactive = 2; + if (quests[Q_PWATER]._qactive == QUEST_INIT) + quests[Q_PWATER]._qactive = QUEST_ACTIVE; LoadPreL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 19, 50); LoadL3Dungeon("Levels\\L3Data\\Foulwatr.DUN", 20, 50); LoadPalette("Levels\\L3Data\\L3pfoul.pal"); InitPWaterTriggers(); break; case SL_VILEBETRAYER: - if (quests[QTYPE_VB]._qactive == 3) { - quests[QTYPE_VB]._qvar2 = 4; - } else if (quests[QTYPE_VB]._qactive == 2) { - quests[QTYPE_VB]._qvar2 = 3; + if (quests[Q_BETRAYER]._qactive == QUEST_DONE) { + quests[Q_BETRAYER]._qvar2 = 4; + } else if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE) { + quests[Q_BETRAYER]._qvar2 = 3; } LoadPreL1Dungeon("Levels\\L1Data\\Vile1.DUN", 35, 36); LoadL1Dungeon("Levels\\L1Data\\Vile2.DUN", 35, 36); diff --git a/Source/sha.cpp b/Source/sha.cpp index 2e851435..14ac7133 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" SHA1Context sgSHA1[3]; diff --git a/Source/sound.cpp b/Source/sound.cpp index 0fbeca1a..e742025d 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" LPDIRECTSOUNDBUFFER DSBs[8]; @@ -7,7 +7,7 @@ BOOLEAN gbSndInited; int sglMusicVolume; int sglSoundVolume; HMODULE hDsound_dll; -HANDLE sgpMusicTrack; +HANDLE sghMusic; LPDIRECTSOUNDBUFFER sglpDSB; /* data */ @@ -310,10 +310,10 @@ void sound_file_cleanup(TSnd *sound_file) void snd_init(HWND hWnd) { int error_code; - sound_load_volume("Sound Volume", &sglSoundVolume); + snd_get_volume("Sound Volume", &sglSoundVolume); gbSoundOn = sglSoundVolume > VOLUME_MIN; - sound_load_volume("Music Volume", &sglMusicVolume); + snd_get_volume("Music Volume", &sglMusicVolume); gbMusicOn = sglMusicVolume > VOLUME_MIN; error_code = sound_DirectSoundCreate(NULL, &sglpDS, NULL); @@ -333,7 +333,7 @@ void snd_init(HWND hWnd) gbSndInited = sglpDS != NULL; } -void sound_load_volume(char *value_name, int *value) +void snd_get_volume(char *value_name, int *value) { int v = *value; if (!SRegLoadValue(APP_NAME, value_name, 0, &v)) { @@ -437,22 +437,22 @@ void sound_cleanup() if (gbSndInited) { gbSndInited = FALSE; - sound_store_volume("Sound Volume", sglSoundVolume); - sound_store_volume("Music Volume", sglMusicVolume); + snd_set_volume("Sound Volume", sglSoundVolume); + snd_set_volume("Music Volume", sglMusicVolume); } } -void sound_store_volume(char *key, int value) +void snd_set_volume(char *key, int value) { SRegSaveValue(APP_NAME, key, 0, value); } void music_stop() { - if (sgpMusicTrack) { - SFileDdaEnd(sgpMusicTrack); - SFileCloseFile(sgpMusicTrack); - sgpMusicTrack = NULL; + if (sghMusic) { + SFileDdaEnd(sghMusic); + SFileCloseFile(sghMusic); + sghMusic = NULL; sgnMusicTrack = NUM_MUSIC; } } @@ -467,15 +467,15 @@ void music_start(int nTrack) #ifdef _DEBUG SFileEnableDirectAccess(FALSE); #endif - success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); + success = SFileOpenFile(sgszMusicTracks[nTrack], &sghMusic); #ifdef _DEBUG SFileEnableDirectAccess(TRUE); #endif - sound_create_primary_buffer(sgpMusicTrack); + sound_create_primary_buffer(sghMusic); if (!success) { - sgpMusicTrack = NULL; + sghMusic = NULL; } else { - SFileDdaBeginEx(sgpMusicTrack, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); + SFileDdaBeginEx(sghMusic, 0x40000, 0x40000, 0, sglMusicVolume, 0, 0); sgnMusicTrack = nTrack; } } @@ -497,8 +497,8 @@ int sound_get_or_set_music_volume(int volume) sglMusicVolume = volume; - if (sgpMusicTrack) - SFileDdaSetVolume(sgpMusicTrack, volume, 0); + if (sghMusic) + SFileDdaSetVolume(sghMusic, volume, 0); return sglMusicVolume; } diff --git a/Source/sound.h b/Source/sound.h index f584f4e7..bd14be41 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -16,11 +16,11 @@ TSnd *sound_file_load(char *path); void sound_CreateSoundBuffer(TSnd *sound_file); void sound_file_cleanup(TSnd *sound_file); void snd_init(HWND hWnd); -void sound_load_volume(char *value_name, int *value); +void snd_get_volume(char *value_name, int *value); void sound_create_primary_buffer(HANDLE music_track); HRESULT sound_DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); void sound_cleanup(); -void sound_store_volume(char *key, int value); +void snd_set_volume(char *key, int value); void music_stop(); void music_start(int nTrack); void sound_disable_music(BOOL disable); diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index 85891d84..779eda21 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -1,5 +1,6 @@ -#include "diablo.h" +#include "all.h" +/** Data related to each spell ID. */ SpellData spelldata[MAX_SPELLS] = { // clang-format off // sName, sManaCost, sType, sNameText, sSkillText, sBookLvl, sStaffLvl, sTargeted, sTownSpell, sMinInt, sSFX, sMissiles[3], sManaAdj, sMinMana, sStaffMin, sStaffMax, sBookCost, sStaffCost diff --git a/Source/spells.cpp b/Source/spells.cpp index efe41dd3..372501ee 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int GetManaAmount(int id, int sn) { diff --git a/Source/stores.cpp b/Source/stores.cpp index 9f848b55..a16f4609 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" int stextup; int storenumh; @@ -64,6 +64,7 @@ int SStringY[24] = { 264, 276 }; +/** Maps from towner IDs to NPC names. */ char *talkname[9] = { "Griswold", "Pepin", @@ -185,7 +186,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val) c = fontframe[gbFontTransTbl[(BYTE)str[i]]]; k += fontkern[c] + 1; if (c && k <= yy) { - CPrintString(off, c, col); + PrintChar(off, c, col); } off += fontkern[c] + 1; } @@ -196,7 +197,7 @@ void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val) c = fontframe[gbFontTransTbl[(BYTE)valstr[i]]]; off -= fontkern[c] + 1; if (c) { - CPrintString(off, c, col); + PrintChar(off, c, col); } } } @@ -253,7 +254,7 @@ void DrawSLine(int y) #endif } -void DrawSArrows(int y1, int y2) +void DrawSSlider(int y1, int y2) { int yd1, yd2, yd3; @@ -501,7 +502,7 @@ void PrintStoreItem(ItemStruct *x, int l, char iclr) } else { strcat(sstr, "Indestructible, "); } - if (!x->_itype) + if (x->_itype == ITYPE_MISC) sstr[0] = '\0'; str = x->_iMinStr; dex = x->_iMinDex; @@ -564,7 +565,7 @@ void S_ScrollSPBuy(int idx) } for (l = 5; l < 20 && idx < 6; l += 4) { - if (premiumitem[idx]._itype != -1) { + if (premiumitem[idx]._itype != ITYPE_NONE) { iclr = COL_WHITE; if (premiumitem[idx]._iMagical) iclr = COL_BLUE; @@ -626,7 +627,7 @@ BOOL SmithSellOk(int i) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) return FALSE; - if (plr[myplr].InvList[i]._itype == ITYPE_0E) + if (plr[myplr].InvList[i]._itype == ITYPE_MEAT) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_STAFF) return FALSE; @@ -758,7 +759,7 @@ BOOL SmithRepairOk(int i) return FALSE; if (plr[myplr].InvList[i]._itype == ITYPE_GOLD) return FALSE; - if (plr[myplr].InvList[i]._itype == ITYPE_0E) + if (plr[myplr].InvList[i]._itype == ITYPE_MEAT) return FALSE; if (plr[myplr].InvList[i]._iDurability == plr[myplr].InvList[i]._iMaxDur) return FALSE; @@ -1455,7 +1456,7 @@ void S_StartTalk() #else sn = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) sn++; } @@ -1470,7 +1471,7 @@ void S_StartTalk() sn2 = sn - 2; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { AddSText(0, sn, 1, questlist[i]._qlstr, COL_WHITE, 1); sn += la; } @@ -1659,7 +1660,7 @@ void DrawSText() } if (stextscrl) - DrawSArrows(4, 20); + DrawSSlider(4, 20); InStoreFlag = (InStoreFlag & 7) + 1; } @@ -1669,7 +1670,7 @@ void STextESC() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else { switch (stextflag) { case STORE_SMITH: @@ -1849,8 +1850,8 @@ void S_SmithEnter() talker = 0; stextlhold = 10; stextshold = STORE_SMITH; - gossipstart = QUEST_GRISWOLD2; - gossipend = QUEST_GRISWOLD13; + gossipstart = TEXT_GRISWOLD2; + gossipend = TEXT_GRISWOLD13; StartStore(STORE_GOSSIP); break; case 12: @@ -2088,7 +2089,7 @@ BOOL StoreGoldFit(int idx) SetCursor_(CURSOR_HAND); if (numsqrs >= sz) - return 1; + return TRUE; for (i = 0; i < 40; i++) { if (!plr[myplr].InvGrid[i]) @@ -2247,8 +2248,8 @@ void S_WitchEnter() stextlhold = 12; talker = 6; stextshold = STORE_WITCH; - gossipstart = QUEST_ADRIA2; - gossipend = QUEST_ADRIA13; + gossipstart = TEXT_ADRIA2; + gossipend = TEXT_ADRIA13; StartStore(STORE_GOSSIP); return; case 14: @@ -2401,8 +2402,8 @@ void S_BoyEnter() talker = 8; stextshold = STORE_BOY; stextlhold = stextsel; - gossipstart = QUEST_WIRT2; - gossipend = QUEST_WIRT12; + gossipstart = TEXT_WIRT2; + gossipend = TEXT_WIRT12; StartStore(STORE_GOSSIP); } else { stextflag = STORE_NONE; @@ -2579,8 +2580,8 @@ void S_HealerEnter() stextlhold = 12; talker = 1; stextshold = STORE_HEALER; - gossipstart = QUEST_PEPIN2; - gossipend = QUEST_PEPIN11; + gossipstart = TEXT_PEPIN2; + gossipend = TEXT_PEPIN11; StartStore(STORE_GOSSIP); break; case 14: @@ -2638,8 +2639,8 @@ void S_StoryEnter() stextlhold = 12; talker = 4; stextshold = STORE_STORY; - gossipstart = QUEST_STORY2; - gossipend = QUEST_STORY11; + gossipstart = TEXT_STORY2; + gossipend = TEXT_STORY11; StartStore(STORE_GOSSIP); break; case 14: @@ -2683,7 +2684,7 @@ void S_TalkEnter() sn = 0; for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) sn++; } if (sn > 6) { @@ -2702,7 +2703,7 @@ void S_TalkEnter() } for (i = 0; i < MAXQUESTS; i++) { - if (quests[i]._qactive == 2 && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { + if (quests[i]._qactive == QUEST_ACTIVE && ((DWORD *)&Qtalklist[talker])[i] != -1 && quests[i]._qlog) { if (sn == stextsel) { InitQTextMsg(((DWORD *)&Qtalklist[talker])[i]); } @@ -2718,8 +2719,8 @@ void S_TavernEnter() stextlhold = 12; talker = 3; stextshold = STORE_TAVERN; - gossipstart = QUEST_OGDEN2; - gossipend = QUEST_OGDEN10; + gossipstart = TEXT_OGDEN2; + gossipend = TEXT_OGDEN10; StartStore(STORE_GOSSIP); break; case 18: @@ -2735,8 +2736,8 @@ void S_BarmaidEnter() stextlhold = 12; talker = 7; stextshold = STORE_BARMAID; - gossipstart = QUEST_GILLIAN2; - gossipend = QUEST_GILLIAN10; + gossipstart = TEXT_GILLIAN2; + gossipend = TEXT_GILLIAN10; StartStore(STORE_GOSSIP); break; case 18: @@ -2752,8 +2753,8 @@ void S_DrunkEnter() stextlhold = 12; talker = 5; stextshold = STORE_DRUNK; - gossipstart = QUEST_FARNHAM2; - gossipend = QUEST_FARNHAM13; + gossipstart = TEXT_FARNHAM2; + gossipend = TEXT_FARNHAM13; StartStore(STORE_GOSSIP); break; case 18: @@ -2767,7 +2768,7 @@ void STextEnter() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else { PlaySFX(IS_TITLSLCT); switch (stextflag) { @@ -2851,7 +2852,7 @@ void CheckStoreBtn() if (qtextflag) { qtextflag = FALSE; if (leveltype == DTYPE_TOWN) - sfx_stop(); + stream_stop(); } else if (stextsel != -1 && MouseY >= 32 && MouseY <= 320) { if (!stextsize) { if (MouseX < 344 + PANEL_LEFT || MouseX > 616 + PANEL_LEFT) diff --git a/Source/stores.h b/Source/stores.h index 750b4e62..d17ea9f1 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -46,7 +46,7 @@ void FreeStoreMem(); void DrawSTextBack(); void PrintSString(int x, int y, BOOL cjustflag, char *str, char col, int val); void DrawSLine(int y); -void DrawSArrows(int y1, int y2); +void DrawSSlider(int y1, int y2); void DrawSTextHelp(); void ClearSText(int s, int e); void AddSLine(int y); diff --git a/Source/sync.cpp b/Source/sync.cpp index 5d071030..636c8afc 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" WORD sync_word_6AA708[MAXMONSTERS]; int sgnMonsters; @@ -170,7 +170,7 @@ void SyncPlrInv(TSyncHeader *pHdr) /// ASSERT: assert((DWORD) sgnSyncPInv < NUM_INVLOC); pItem = &plr[myplr].InvBody[sgnSyncPInv]; - if (pItem->_itype != -1) { + if (pItem->_itype != ITYPE_NONE) { pHdr->bPInvLoc = sgnSyncPInv; pHdr->wPInvIndx = pItem->IDidx; pHdr->wPInvCI = pItem->_iCreateInfo; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index 3c19eeec..6b42dbba 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -1,7 +1,8 @@ -#include "diablo.h" +#include "all.h" /* todo: move text out of struct */ +/** Contains the data related to each speech ID. */ const TextDataStruct alltext[] = { #ifdef SPAWN { "Nice try... ", 0, 0, TSFX_TAVERN36 }, @@ -918,4 +919,5 @@ const TextDataStruct alltext[] = { { "Efficio Obitus Ut Inimicus. |", 1, 5, PS_ROGUE56 }, #endif }; -const DWORD gdwAllTextEntries = 259; /* unused */ +/** unused */ +const DWORD gdwAllTextEntries = 259; diff --git a/Source/themes.cpp b/Source/themes.cpp index 125089c6..7340c684 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -1,4 +1,9 @@ -#include "diablo.h" +/** + * @file themes.cpp + * + * Implementation of the theme room placing algorithms. + */ +#include "all.h" int numthemes; BOOL armorFlag; @@ -65,7 +70,7 @@ BOOL TFit_Shrine(int i) && dObject[xp + 1][yp - 1] == 0) { found = 1; } - if (!found + if (found == 0 && nTrapTable[dPiece[xp - 1][yp]] && !nSolidTable[dPiece[xp][yp - 1]] && !nSolidTable[dPiece[xp][yp + 1]] @@ -426,7 +431,7 @@ void InitThemes() if (leveltype == DTYPE_CATACOMBS || leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) { for (i = 0; i < themeCount; i++) themes[i].ttype = THEME_NONE; - if (QuestStatus(QTYPE_ZHAR)) { + if (QuestStatus(Q_ZHAR)) { for (j = 0; j < themeCount; j++) { themes[j].ttval = themeLoc[j].ttval; if (SpecialThemeFit(j, THEME_LIBRARY)) { @@ -451,7 +456,9 @@ void InitThemes() } } -// HoldThemeRooms marks theme rooms as populated. +/** + * @brief HoldThemeRooms marks theme rooms as populated. + */ void HoldThemeRooms() { int i, x, y; @@ -475,11 +482,12 @@ void HoldThemeRooms() } } -// PlaceThemeMonsts places theme monsters with the specified frequency. -// -// Parameters: -// - t: theme number (index into themes array). -// - f: frequency (1/f likelihood of adding monster). +/** + * PlaceThemeMonsts places theme monsters with the specified frequency. + * + * @param t theme number (index into themes array). + * @param f frequency (1/f likelihood of adding monster). + */ void PlaceThemeMonsts(int t, int f) { int xp, yp; @@ -509,10 +517,11 @@ void PlaceThemeMonsts(int t, int f) } } -// Theme_Barrel initializes the barrel theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Barrel initializes the barrel theme. + * + * @param t theme number (index into themes array). + */ void Theme_Barrel(int t) { int xp, yp, r; @@ -536,10 +545,11 @@ void Theme_Barrel(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Shrine initializes the shrine theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Shrine initializes the shrine theme. + * + * @param t theme number (index into themes array). + */ void Theme_Shrine(int t) { char monstrnd[4] = { 6, 6, 3, 9 }; @@ -557,10 +567,11 @@ void Theme_Shrine(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_MonstPit initializes the monster pit theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_MonstPit initializes the monster pit theme. + * + * @param t theme number (index into themes array). + */ void Theme_MonstPit(int t) { int r; @@ -593,10 +604,11 @@ void Theme_MonstPit(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_SkelRoom initializes the skeleton room theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_SkelRoom initializes the skeleton room theme. + * + * @param t theme number (index into themes array). + */ void Theme_SkelRoom(int t) { int xp, yp, i; @@ -662,10 +674,11 @@ void Theme_SkelRoom(int t) } } -// Theme_Treasure initializes the treasure theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Treasure initializes the treasure theme. + * + * @param t theme number (index into themes array). + */ void Theme_Treasure(int t) { int xp, yp; @@ -699,10 +712,11 @@ void Theme_Treasure(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Library initializes the library theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Library initializes the library theme. + * + * @param t theme number (index into themes array). + */ void Theme_Library(int t) { int xp, yp, oi; @@ -734,7 +748,7 @@ void Theme_Library(int t) } } - if (QuestStatus(QTYPE_ZHAR)) { + if (QuestStatus(Q_ZHAR)) { if (t == zharlib) { return; } @@ -744,10 +758,11 @@ void Theme_Library(int t) } } -// Theme_Torture initializes the torture theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Torture initializes the torture theme. + * + * @param t theme number (index into themes array). + */ void Theme_Torture(int t) { int xp, yp; @@ -768,10 +783,10 @@ void Theme_Torture(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_BloodFountain initializes the blood fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_BloodFountain initializes the blood fountain theme. + * @param t Theme number (index into themes array). + */ void Theme_BloodFountain(int t) { char monstrnd[4] = { 6, 8, 3, 9 }; @@ -781,10 +796,11 @@ void Theme_BloodFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_Decap initializes the decapitated theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Decap initializes the decapitated theme. + * + * @param t theme number (index into themes array). + */ void Theme_Decap(int t) { int xp, yp; @@ -805,10 +821,11 @@ void Theme_Decap(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_PurifyingFountain initializes the purifying fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_PurifyingFountain initializes the purifying fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_PurifyingFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -818,10 +835,11 @@ void Theme_PurifyingFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_ArmorStand initializes the armor stand theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_ArmorStand initializes the armor stand theme. + * + * @param t theme number (index into themes array). + */ void Theme_ArmorStand(int t) { int xp, yp; @@ -847,10 +865,11 @@ void Theme_ArmorStand(int t) armorFlag = FALSE; } -// Theme_GoatShrine initializes the goat shrine theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_GoatShrine initializes the goat shrine theme. + * + * @param t theme number (index into themes array). + */ void Theme_GoatShrine(int t) { int xx, yy; @@ -866,10 +885,11 @@ void Theme_GoatShrine(int t) } } -// Theme_Cauldron initializes the cauldron theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_Cauldron initializes the cauldron theme. + * + * @param t theme number (index into themes array). + */ void Theme_Cauldron(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -879,10 +899,11 @@ void Theme_Cauldron(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_MurkyFountain initializes the murky fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_MurkyFountain initializes the murky fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_MurkyFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -892,10 +913,11 @@ void Theme_MurkyFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_TearFountain initializes the tear fountain theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_TearFountain initializes the tear fountain theme. + * + * @param t theme number (index into themes array). + */ void Theme_TearFountain(int t) { char monstrnd[4] = { 6, 7, 3, 9 }; @@ -905,10 +927,11 @@ void Theme_TearFountain(int t) PlaceThemeMonsts(t, monstrnd[leveltype - 1]); } -// Theme_BrnCross initializes the burning cross theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_BrnCross initializes the burning cross theme. + * + * @param t theme number (index into themes array). + */ void Theme_BrnCross(int t) { int xp, yp; @@ -930,10 +953,11 @@ void Theme_BrnCross(int t) bCrossFlag = TRUE; } -// Theme_WeaponRack initializes the weapon rack theme. -// -// Parameters: -// - t: theme number (index into themes array). +/** + * Theme_WeaponRack initializes the weapon rack theme. + * + * @param t theme number (index into themes array). + */ void Theme_WeaponRack(int t) { int xp, yp; @@ -959,7 +983,9 @@ void Theme_WeaponRack(int t) weaponFlag = FALSE; } -// UpdateL4Trans sets each value of the transparency map to 1. +/** + * UpdateL4Trans sets each value of the transparency map to 1. + */ void UpdateL4Trans() { int i, j; @@ -973,7 +999,9 @@ void UpdateL4Trans() } } -// CreateThemeRooms adds thematic elements to rooms. +/** + * CreateThemeRooms adds thematic elements to rooms. + */ void CreateThemeRooms() { int i; diff --git a/Source/themes.h b/Source/themes.h index 5ee91827..35c4cb08 100644 --- a/Source/themes.h +++ b/Source/themes.h @@ -1,4 +1,8 @@ -//HEADER_GOES_HERE +/** + * @file themes.h + * + * Interface of the theme room placing algorithms. + */ #ifndef __THEMES_H__ #define __THEMES_H__ diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index 634d1b21..27783f1e 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" static TMsg *sgpTimedMsgHead; diff --git a/Source/town.cpp b/Source/town.cpp index c7622c01..1ec3efd4 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" /** * Used under building to avoid HOM and outside of level @@ -488,8 +488,8 @@ void town_draw_clipped_town(BYTE *pBuff, int sx, int sy, int dx, int dy, int efl if (dFlags[sx][sy] & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, 0, 8, 0); } - if (dArch[sx][sy] != 0) { - town_special_lower(pBuff, dArch[sx][sy]); + if (dSpecial[sx][sy] != 0) { + town_special_lower(pBuff, dSpecial[sx][sy]); } } @@ -702,8 +702,8 @@ void town_draw_clipped_town_2(BYTE *pBuff, int sx, int sy, int row, int CelSkip, if (dFlags[sx][sy] & BFLAG_MISSILE) { DrawClippedMissile(sx, sy, dx, dy, CelSkip, 8, 0); } - if (dArch[sx][sy] != 0) { - town_special_lower(&pBuff[PitchTbl[16 * CelSkip]], dArch[sx][sy]); + if (dSpecial[sx][sy] != 0) { + town_special_lower(&pBuff[PitchTbl[16 * CelSkip]], dSpecial[sx][sy]); } } @@ -929,8 +929,8 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int row, int CelCap, int sx, if (dFlags[x][y] & BFLAG_MISSILE) { DrawMissile(x, y, sx, sy, 0, CelCap, FALSE); } - if (dArch[x][y] != 0) { - town_special_upper(pBuff, dArch[x][y]); + if (dSpecial[x][y] != 0) { + town_special_upper(pBuff, dSpecial[x][y]); } } @@ -1049,10 +1049,10 @@ void T_DrawGame(int x, int y) { int i, sx, sy, chunks, blocks; - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 175; @@ -1168,10 +1168,10 @@ void T_DrawZoom(int x, int y) int i, sx, sy, chunks, blocks; int wdt, nSrcOff, nDstOff; - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = 192; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = 192 / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = 192; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = 192 / 32; sx = ScrollInfo._sxoff + 64; sy = ScrollInfo._syoff + 143; @@ -1396,6 +1396,9 @@ void T_DrawView(int StartX, int StartY) DrawManaFlask(); } +/** + * @brief Build tile columns + */ void SetTownMicros() { int i, x, y, lv; @@ -1421,15 +1424,15 @@ void SetTownMicros() } if (zoomflag) { - scr_pix_width = SCREEN_WIDTH; - scr_pix_height = VIEWPORT_HEIGHT; - dword_5C2FF8 = SCREEN_WIDTH / 64; - dword_5C2FFC = VIEWPORT_HEIGHT / 32; + ViewDX = SCREEN_WIDTH; + ViewDY = VIEWPORT_HEIGHT; + ViewBX = SCREEN_WIDTH / 64; + ViewBY = VIEWPORT_HEIGHT / 32; } else { - scr_pix_width = ZOOM_WIDTH; - scr_pix_height = ZOOM_HEIGHT; - dword_5C2FF8 = ZOOM_WIDTH / 64; - dword_5C2FFC = ZOOM_HEIGHT / 32; + ViewDX = ZOOM_WIDTH; + ViewDY = ZOOM_HEIGHT; + ViewBX = ZOOM_WIDTH / 64; + ViewBY = ZOOM_HEIGHT / 32; } } @@ -1730,8 +1733,8 @@ void T_Pass3() #ifndef SPAWN if (gbMaxPlayers == 1) { #ifdef HELLFIRE - if(quests[QTYPE_FARMER]._qactive == 3 || quests[QTYPE_FARMER]._qactive == 10 - || quests[QTYPE_JERSEY]._qactive == 3 || quests[QTYPE_JERSEY]._qactive == 10) + if(quests[Q_FARMER]._qactive == 3 || quests[Q_FARMER]._qactive == 10 + || quests[Q_JERSEY]._qactive == 3 || quests[Q_JERSEY]._qactive == 10) { town_4751C6(); } @@ -1739,7 +1742,7 @@ void T_Pass3() { town_475379(); } - if ( quests[QTYPE_GRAVE]._qactive == 3 || plr[myplr]._pLvlVisited[21] ) + if ( quests[Q_GRAVE]._qactive == 3 || plr[myplr]._pLvlVisited[21] ) town_475595(); else town_47552C(); @@ -1779,8 +1782,8 @@ void T_Pass3() #ifdef HELLFIRE else { - if(quests[QTYPE_FARMER]._qactive == 3 || quests[QTYPE_FARMER]._qactive == 10 - || quests[QTYPE_JERSEY]._qactive == 3 || quests[QTYPE_JERSEY]._qactive == 10) + if(quests[Q_FARMER]._qactive == 3 || quests[Q_FARMER]._qactive == 10 + || quests[Q_JERSEY]._qactive == 3 || quests[Q_JERSEY]._qactive == 10) { town_4751C6(); } @@ -1788,14 +1791,14 @@ void T_Pass3() { town_475379(); } - if ( quests[QTYPE_GRAVE]._qactive == 3 || plr[myplr]._pLvlVisited[21] ) + if ( quests[Q_GRAVE]._qactive == 3 || plr[myplr]._pLvlVisited[21] ) town_475595(); else town_47552C(); } #endif - if (quests[QTYPE_PW]._qactive != 3 && quests[QTYPE_PW]._qactive) { + if (quests[Q_PWATER]._qactive != QUEST_DONE && quests[Q_PWATER]._qactive) { T_FillTile(P3Tiles, 60, 70, 342); } else { T_FillTile(P3Tiles, 60, 70, 71); @@ -1855,40 +1858,40 @@ void CreateTown(int entry) memset(dMonster, 0, sizeof(dMonster)); memset(dObject, 0, sizeof(dObject)); memset(dItem, 0, sizeof(dItem)); - memset(dArch, 0, sizeof(dArch)); + memset(dSpecial, 0, sizeof(dSpecial)); for (y = 0; y < MAXDUNY; y++) { for (x = 0; x < MAXDUNX; x++) { if (dPiece[x][y] == 360) { - dArch[x][y] = 1; + dSpecial[x][y] = 1; } else if (dPiece[x][y] == 358) { - dArch[x][y] = 2; + dSpecial[x][y] = 2; } else if (dPiece[x][y] == 129) { - dArch[x][y] = 6; + dSpecial[x][y] = 6; } else if (dPiece[x][y] == 130) { - dArch[x][y] = 7; + dSpecial[x][y] = 7; } else if (dPiece[x][y] == 128) { - dArch[x][y] = 8; + dSpecial[x][y] = 8; } else if (dPiece[x][y] == 117) { - dArch[x][y] = 9; + dSpecial[x][y] = 9; } else if (dPiece[x][y] == 157) { - dArch[x][y] = 10; + dSpecial[x][y] = 10; } else if (dPiece[x][y] == 158) { - dArch[x][y] = 11; + dSpecial[x][y] = 11; } else if (dPiece[x][y] == 156) { - dArch[x][y] = 12; + dSpecial[x][y] = 12; } else if (dPiece[x][y] == 162) { - dArch[x][y] = 13; + dSpecial[x][y] = 13; } else if (dPiece[x][y] == 160) { - dArch[x][y] = 14; + dSpecial[x][y] = 14; } else if (dPiece[x][y] == 214) { - dArch[x][y] = 15; + dSpecial[x][y] = 15; } else if (dPiece[x][y] == 212) { - dArch[x][y] = 16; + dSpecial[x][y] = 16; } else if (dPiece[x][y] == 217) { - dArch[x][y] = 17; + dSpecial[x][y] = 17; } else if (dPiece[x][y] == 216) { - dArch[x][y] = 18; + dSpecial[x][y] = 18; } } } diff --git a/Source/towners.cpp b/Source/towners.cpp index 1076ac86..f338191b 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -1,10 +1,11 @@ -#include "diablo.h" +#include "all.h" BOOL storeflag; int sgnCowMsg; int numtowners; DWORD sgdwCowClicks; -BOOL bannerflag; // unused 0x6AAC28 +/** unused 0x6AAC28 */ +BOOL bannerflag; BOOL boyloadflag; BYTE *pCowCels; TownerStruct towner[16]; @@ -100,15 +101,15 @@ QuestTalkData Qtalklist[] = { // clang-format off #ifdef HELLFIRE // _qinfra, _qblkm, _qgarb, _qzhar, _qveil, _qmod, _qbutch, _qbol, _qblind, _qblood, _qanvil, _qwarlrd, _qking, _qpw, _qbone, _qvb, _qgrv, _qfarm, _qgirl, _qtrade, _qdefiler, _qnakrul, _qjersy, _qhf8 - { QUEST_INFRA6, QUEST_MUSH6, -1, -1, QUEST_VEIL5, -1, QUEST_BUTCH5, QUEST_BANNER6, QUEST_BLIND5, QUEST_BLOOD5, QUEST_ANVIL6, QUEST_WARLRD5, QUEST_KING7, QUEST_POISON7, QUEST_BONE5, QUEST_VILE9, QUEST_GRAVE2, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA3, -1, -1, -1, QUEST_VEIL3, -1, QUEST_BUTCH3, QUEST_BANNER4, QUEST_BLIND3, QUEST_BLOOD3, QUEST_ANVIL3, QUEST_WARLRD3, QUEST_KING5, QUEST_POISON4, QUEST_BONE3, QUEST_VILE7, QUEST_GRAVE3, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA6, TEXT_MUSH6, -1, -1, TEXT_VEIL5, -1, TEXT_BUTCH5, TEXT_BANNER6, TEXT_BLIND5, TEXT_BLOOD5, TEXT_ANVIL6, TEXT_WARLRD5, TEXT_KING7, TEXT_POISON7, TEXT_BONE5, TEXT_VILE9, TEXT_GRAVE2, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA3, -1, -1, -1, TEXT_VEIL3, -1, TEXT_BUTCH3, TEXT_BANNER4, TEXT_BLIND3, TEXT_BLOOD3, TEXT_ANVIL3, TEXT_WARLRD3, TEXT_KING5, TEXT_POISON4, TEXT_BONE3, TEXT_VILE7, TEXT_GRAVE3, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA2, QUEST_MUSH2, -1, -1, QUEST_VEIL2, -1, QUEST_BUTCH2, -1, QUEST_BLIND2, QUEST_BLOOD2, QUEST_ANVIL2, QUEST_WARLRD2, QUEST_KING3, QUEST_POISON2, QUEST_BONE2, QUEST_VILE4, QUEST_GRAVE5, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA1, QUEST_MUSH1, -1, -1, QUEST_VEIL1, QUEST_VILE3, QUEST_BUTCH1, QUEST_BANNER1, QUEST_BLIND1, QUEST_BLOOD1, QUEST_ANVIL1, QUEST_WARLRD1, QUEST_KING1, QUEST_POISON1, QUEST_BONE1, QUEST_VILE2, QUEST_GRAVE6, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA8, QUEST_MUSH7, -1, -1, QUEST_VEIL6, -1, QUEST_BUTCH6, QUEST_BANNER7, QUEST_BLIND6, QUEST_BLOOD6, QUEST_ANVIL8, QUEST_WARLRD6, QUEST_KING8, QUEST_POISON8, QUEST_BONE6, QUEST_VILE10, QUEST_GRAVE7, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA9, QUEST_MUSH9, -1, -1, QUEST_VEIL7, -1, QUEST_BUTCH7, QUEST_BANNER8, QUEST_BLIND7, QUEST_BLOOD7, QUEST_ANVIL9, QUEST_WARLRD7, QUEST_KING9, QUEST_POISON9, QUEST_BONE7, QUEST_VILE11, QUEST_GRAVE1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA4, QUEST_MUSH5, -1, -1, QUEST_VEIL4, -1, QUEST_BUTCH4, QUEST_BANNER5, QUEST_BLIND4, QUEST_BLOOD4, QUEST_ANVIL4, QUEST_WARLRD4, QUEST_KING6, QUEST_POISON6, QUEST_BONE4, QUEST_VILE8, QUEST_GRAVE8, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA10, QUEST_MUSH13, -1, -1, QUEST_VEIL8, -1, QUEST_BUTCH8, QUEST_BANNER9, QUEST_BLIND8, QUEST_BLOOD8, QUEST_ANVIL10,QUEST_WARLRD8, QUEST_KING10, QUEST_POISON10, QUEST_BONE8, QUEST_VILE12, QUEST_GRAVE9, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA2, TEXT_MUSH2, -1, -1, TEXT_VEIL2, -1, TEXT_BUTCH2, -1, TEXT_BLIND2, TEXT_BLOOD2, TEXT_ANVIL2, TEXT_WARLRD2, TEXT_KING3, TEXT_POISON2, TEXT_BONE2, TEXT_VILE4, TEXT_GRAVE5, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA1, TEXT_MUSH1, -1, -1, TEXT_VEIL1, TEXT_VILE3, TEXT_BUTCH1, TEXT_BANNER1, TEXT_BLIND1, TEXT_BLOOD1, TEXT_ANVIL1, TEXT_WARLRD1, TEXT_KING1, TEXT_POISON1, TEXT_BONE1, TEXT_VILE2, TEXT_GRAVE6, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA8, TEXT_MUSH7, -1, -1, TEXT_VEIL6, -1, TEXT_BUTCH6, TEXT_BANNER7, TEXT_BLIND6, TEXT_BLOOD6, TEXT_ANVIL8, TEXT_WARLRD6, TEXT_KING8, TEXT_POISON8, TEXT_BONE6, TEXT_VILE10, TEXT_GRAVE7, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA9, TEXT_MUSH9, -1, -1, TEXT_VEIL7, -1, TEXT_BUTCH7, TEXT_BANNER8, TEXT_BLIND7, TEXT_BLOOD7, TEXT_ANVIL9, TEXT_WARLRD7, TEXT_KING9, TEXT_POISON9, TEXT_BONE7, TEXT_VILE11, TEXT_GRAVE1, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA4, TEXT_MUSH5, -1, -1, TEXT_VEIL4, -1, TEXT_BUTCH4, TEXT_BANNER5, TEXT_BLIND4, TEXT_BLOOD4, TEXT_ANVIL4, TEXT_WARLRD4, TEXT_KING6, TEXT_POISON6, TEXT_BONE4, TEXT_VILE8, TEXT_GRAVE8, -1, -1, -1, -1, -1, -1, -1 }, + { TEXT_INFRA10, TEXT_MUSH13, -1, -1, TEXT_VEIL8, -1, TEXT_BUTCH8, TEXT_BANNER9, TEXT_BLIND8, TEXT_BLOOD8, TEXT_ANVIL10,TEXT_WARLRD8, TEXT_KING10, TEXT_POISON10, TEXT_BONE8, TEXT_VILE12, TEXT_GRAVE9, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, @@ -116,17 +117,17 @@ QuestTalkData Qtalklist[] = { { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, #else // _qinfra, _qblkm, _qgarb, _qzhar, _qveil, _qmod, _qbutch, _qbol, _qblind, _qblood, _qanvil, _qwarlrd, _qking, _qpw, _qbone, _qvb - { QUEST_INFRA6, QUEST_MUSH6, -1, -1, QUEST_VEIL5, -1, QUEST_BUTCH5, QUEST_BANNER6, QUEST_BLIND5, QUEST_BLOOD5, QUEST_ANVIL6, QUEST_WARLRD5, QUEST_KING7, QUEST_POISON7, QUEST_BONE5, QUEST_VILE9 }, - { QUEST_INFRA3, -1, -1, -1, QUEST_VEIL3, -1, QUEST_BUTCH3, QUEST_BANNER4, QUEST_BLIND3, QUEST_BLOOD3, QUEST_ANVIL3, QUEST_WARLRD3, QUEST_KING5, QUEST_POISON4, QUEST_BONE3, QUEST_VILE7 }, + { TEXT_INFRA6, TEXT_MUSH6, -1, -1, TEXT_VEIL5, -1, TEXT_BUTCH5, TEXT_BANNER6, TEXT_BLIND5, TEXT_BLOOD5, TEXT_ANVIL6, TEXT_WARLRD5, TEXT_KING7, TEXT_POISON7, TEXT_BONE5, TEXT_VILE9 }, + { TEXT_INFRA3, -1, -1, -1, TEXT_VEIL3, -1, TEXT_BUTCH3, TEXT_BANNER4, TEXT_BLIND3, TEXT_BLOOD3, TEXT_ANVIL3, TEXT_WARLRD3, TEXT_KING5, TEXT_POISON4, TEXT_BONE3, TEXT_VILE7 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_INFRA2, QUEST_MUSH2, -1, -1, QUEST_VEIL2, -1, QUEST_BUTCH2, -1, QUEST_BLIND2, QUEST_BLOOD2, QUEST_ANVIL2, QUEST_WARLRD2, QUEST_KING3, QUEST_POISON2, QUEST_BONE2, QUEST_VILE4 }, - { QUEST_INFRA1, QUEST_MUSH1, -1, -1, QUEST_VEIL1, QUEST_VILE3, QUEST_BUTCH1, QUEST_BANNER1, QUEST_BLIND1, QUEST_BLOOD1, QUEST_ANVIL1, QUEST_WARLRD1, QUEST_KING1, QUEST_POISON1, QUEST_BONE1, QUEST_VILE2 }, - { QUEST_INFRA8, QUEST_MUSH7, -1, -1, QUEST_VEIL6, -1, QUEST_BUTCH6, QUEST_BANNER7, QUEST_BLIND6, QUEST_BLOOD6, QUEST_ANVIL8, QUEST_WARLRD6, QUEST_KING8, QUEST_POISON8, QUEST_BONE6, QUEST_VILE10 }, - { QUEST_INFRA9, QUEST_MUSH9, -1, -1, QUEST_VEIL7, -1, QUEST_BUTCH7, QUEST_BANNER8, QUEST_BLIND7, QUEST_BLOOD7, QUEST_ANVIL9, QUEST_WARLRD7, QUEST_KING9, QUEST_POISON9, QUEST_BONE7, QUEST_VILE11 }, - { QUEST_INFRA4, QUEST_MUSH5, -1, -1, QUEST_VEIL4, -1, QUEST_BUTCH4, QUEST_BANNER5, QUEST_BLIND4, QUEST_BLOOD4, QUEST_ANVIL4, QUEST_WARLRD4, QUEST_KING6, QUEST_POISON6, QUEST_BONE4, QUEST_VILE8 }, - { QUEST_INFRA10, QUEST_MUSH13, -1, -1, QUEST_VEIL8, -1, QUEST_BUTCH8, QUEST_BANNER9, QUEST_BLIND8, QUEST_BLOOD8, QUEST_ANVIL10,QUEST_WARLRD8, QUEST_KING10, QUEST_POISON10, QUEST_BONE8, QUEST_VILE12 }, + { TEXT_INFRA2, TEXT_MUSH2, -1, -1, TEXT_VEIL2, -1, TEXT_BUTCH2, -1, TEXT_BLIND2, TEXT_BLOOD2, TEXT_ANVIL2, TEXT_WARLRD2, TEXT_KING3, TEXT_POISON2, TEXT_BONE2, TEXT_VILE4 }, + { TEXT_INFRA1, TEXT_MUSH1, -1, -1, TEXT_VEIL1, TEXT_VILE3, TEXT_BUTCH1, TEXT_BANNER1, TEXT_BLIND1, TEXT_BLOOD1, TEXT_ANVIL1, TEXT_WARLRD1, TEXT_KING1, TEXT_POISON1, TEXT_BONE1, TEXT_VILE2 }, + { TEXT_INFRA8, TEXT_MUSH7, -1, -1, TEXT_VEIL6, -1, TEXT_BUTCH6, TEXT_BANNER7, TEXT_BLIND6, TEXT_BLOOD6, TEXT_ANVIL8, TEXT_WARLRD6, TEXT_KING8, TEXT_POISON8, TEXT_BONE6, TEXT_VILE10 }, + { TEXT_INFRA9, TEXT_MUSH9, -1, -1, TEXT_VEIL7, -1, TEXT_BUTCH7, TEXT_BANNER8, TEXT_BLIND7, TEXT_BLOOD7, TEXT_ANVIL9, TEXT_WARLRD7, TEXT_KING9, TEXT_POISON9, TEXT_BONE7, TEXT_VILE11 }, + { TEXT_INFRA4, TEXT_MUSH5, -1, -1, TEXT_VEIL4, -1, TEXT_BUTCH4, TEXT_BANNER5, TEXT_BLIND4, TEXT_BLOOD4, TEXT_ANVIL4, TEXT_WARLRD4, TEXT_KING6, TEXT_POISON6, TEXT_BONE4, TEXT_VILE8 }, + { TEXT_INFRA10, TEXT_MUSH13, -1, -1, TEXT_VEIL8, -1, TEXT_BUTCH8, TEXT_BANNER9, TEXT_BLIND8, TEXT_BLOOD8, TEXT_ANVIL10,TEXT_WARLRD8, TEXT_KING10, TEXT_POISON10, TEXT_BONE8, TEXT_VILE12 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, - { QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1, QUEST_KING1 } + { TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1, TEXT_KING1 } #endif // clang-format on }; @@ -190,7 +191,7 @@ void InitTownerInfo(int i, int w, int sel, int t, int x, int y, int ao, int tp) towner[i]._tSelFlag = sel; towner[i]._tAnimWidth = w; towner[i]._tAnimWidth2 = (w - 64) >> 1; - towner[i]._tMsgSaid = 0; + towner[i]._tMsgSaid = FALSE; towner[i]._ttype = t; towner[i]._tx = x; towner[i]._ty = y; @@ -419,7 +420,7 @@ void InitCowFarmer() InitTownerInfo(numtowners, 96, 1, TOWN_COWFARM, 61, 22, -1, 10); InitQstSnds(numtowners); - if (quests[QTYPE_JERSEY]._qactive != 3) { + if (quests[Q_JERSEY]._qactive != 3) { towner[numtowners]._tNData = LoadFileInMem("Towners\\Farmer\\cfrmrn2.CEL", NULL); } else { towner[numtowners]._tNData = LoadFileInMem("Towners\\Farmer\\mfrmrn2.CEL", NULL); @@ -439,7 +440,7 @@ void InitGirl() InitTownerInfo(numtowners, 96, 1, TOWN_GIRL, 77, 43, -1, 10); InitQstSnds(numtowners); - if (quests[QTYPE_GIRL]._qactive != 3) { + if (quests[Q_GIRL]._qactive != 3) { towner[numtowners]._tNData = LoadFileInMem("Towners\\Girl\\Girlw1.CEL", NULL); } else { towner[numtowners]._tNData = LoadFileInMem("Towners\\Girl\\Girls1.CEL", NULL); @@ -460,7 +461,7 @@ void InitTowners() boyloadflag = FALSE; InitSmith(); InitHealer(); - if (quests[QTYPE_BUTCH]._qactive && quests[QTYPE_BUTCH]._qactive != 3) + if (quests[Q_BUTCHER]._qactive && quests[Q_BUTCHER]._qactive != QUEST_DONE) InitTownDead(); InitBarOwner(); InitTeller(); @@ -472,7 +473,7 @@ void InitTowners() #ifdef HELLFIRE if (UseCowFarmer) { InitCowFarmer(); - } else if (quests[QTYPE_FARMER]._qactive != 10) { + } else if (quests[Q_FARMER]._qactive != 10) { InitFarmer(); } if (UseTheoQuest && plr->_pLvlVisited[17]) { @@ -516,7 +517,7 @@ void TownCtrlMsg(int i) towner[i]._tbtcnt = 0; if (!towner[i]._tbtcnt) { qtextflag = FALSE; - sfx_stop(); + stream_stop(); } #endif } @@ -545,16 +546,16 @@ void TownDead() tidx = GetActiveTowner(TOWN_DEADGUY); TownCtrlMsg(tidx); if (!qtextflag) { - if (quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qlog == 0) { + if (quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qlog == 0) { return; } - if (quests[QTYPE_BUTCH]._qactive != 1) { + if (quests[Q_BUTCHER]._qactive != QUEST_INIT) { towner[tidx]._tAnimDelay = 1000; towner[tidx]._tAnimFrame = 1; strcpy(towner[tidx]._tName, "Slain Townsman"); } } - if (quests[QTYPE_BUTCH]._qactive != 1) + if (quests[Q_BUTCHER]._qactive != QUEST_INIT) towner[tidx]._tAnimCnt = 0; } @@ -765,57 +766,57 @@ void TalkToTowner(int p, int t) if (!plr[p]._pLvlVisited[0] && !towner[t]._tMsgSaid) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INTRO); + InitQTextMsg(TEXT_INTRO); towner[t]._tMsgSaid = TRUE; } - if ((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive != 0) { - if (quests[QTYPE_KING]._qvar2 == 0 && !towner[t]._tMsgSaid) { - quests[QTYPE_KING]._qvar2 = 1; - quests[QTYPE_KING]._qlog = TRUE; - if (quests[QTYPE_KING]._qactive == 1) { - quests[QTYPE_KING]._qactive = 2; - quests[QTYPE_KING]._qvar1 = 1; + if ((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[Q_SKELKING]._qactive != QUEST_NOTAVAIL) { + if (quests[Q_SKELKING]._qvar2 == 0 && !towner[t]._tMsgSaid) { + quests[Q_SKELKING]._qvar2 = 1; + quests[Q_SKELKING]._qlog = TRUE; + if (quests[Q_SKELKING]._qactive == QUEST_INIT) { + quests[Q_SKELKING]._qactive = QUEST_ACTIVE; + quests[Q_SKELKING]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_KING2); + InitQTextMsg(TEXT_KING2); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } - if (quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[t]._tMsgSaid) { - quests[QTYPE_KING]._qvar2 = 2; - quests[QTYPE_KING]._qvar1 = 2; + if (quests[Q_SKELKING]._qactive == QUEST_DONE && quests[Q_SKELKING]._qvar2 == 1 && !towner[t]._tMsgSaid) { + quests[Q_SKELKING]._qvar2 = 2; + quests[Q_SKELKING]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_KING4); + InitQTextMsg(TEXT_KING4); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_KING); + NetSendCmdQuest(TRUE, Q_SKELKING); } } - if (gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive != 0) { - if ((quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && quests[QTYPE_BOL]._qvar2 == 0 && !towner[t]._tMsgSaid) { - quests[QTYPE_BOL]._qvar2 = 1; - if (quests[QTYPE_BOL]._qactive == 1) { - quests[QTYPE_BOL]._qvar1 = 1; - quests[QTYPE_BOL]._qactive = 2; + if (gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[Q_LTBANNER]._qactive != QUEST_NOTAVAIL) { + if ((quests[Q_LTBANNER]._qactive == QUEST_INIT || quests[Q_LTBANNER]._qactive == QUEST_ACTIVE) && quests[Q_LTBANNER]._qvar2 == 0 && !towner[t]._tMsgSaid) { + quests[Q_LTBANNER]._qvar2 = 1; + if (quests[Q_LTBANNER]._qactive == QUEST_INIT) { + quests[Q_LTBANNER]._qvar1 = 1; + quests[Q_LTBANNER]._qactive = QUEST_ACTIVE; } - quests[QTYPE_BOL]._qlog = TRUE; + quests[Q_LTBANNER]._qlog = TRUE; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_BANNER2); + InitQTextMsg(TEXT_BANNER2); towner[t]._tMsgSaid = TRUE; } - if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, i) != NULL) { + if (quests[Q_LTBANNER]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, i) != NULL) { #ifndef HELLFIRE if (!towner[t]._tMsgSaid) { #endif - quests[QTYPE_BOL]._qactive = 3; - quests[QTYPE_BOL]._qvar1 = 3; + quests[Q_LTBANNER]._qactive = QUEST_DONE; + quests[Q_LTBANNER]._qvar1 = 3; RemoveInvItem(p, i); CreateItem(UITEM_HARCREST, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_BANNER3); + InitQTextMsg(TEXT_BANNER3); towner[t]._tMsgSaid = TRUE; #ifndef HELLFIRE } @@ -823,16 +824,16 @@ void TalkToTowner(int p, int t) } } if (!qtextflag) { - TownerTalk(QUEST_OGDEN1, t); + TownerTalk(TEXT_OGDEN1, t); if (storeflag) { StartStore(STORE_TAVERN); } } } else if (t == GetActiveTowner(TOWN_DEADGUY)) { - if (quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 1) { + if (quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qvar1 == 1) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BUTCH]._qvar1 = 1; + quests[Q_BUTCHER]._qvar1 = 1; #ifndef SPAWN if (plr[p]._pClass == PC_WARRIOR && !effect_is_playing(PS_WARR8)) { PlaySFX(PS_WARR8); @@ -851,83 +852,83 @@ void TalkToTowner(int p, int t) } #endif towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BUTCH]._qactive == 3 && quests[QTYPE_BUTCH]._qvar1 == 1) { - quests[QTYPE_BUTCH]._qvar1 = 1; + } else if (quests[Q_BUTCHER]._qactive == QUEST_DONE && quests[Q_BUTCHER]._qvar1 == 1) { + quests[Q_BUTCHER]._qvar1 = 1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BUTCH]._qactive == 1 || quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 0) { - quests[QTYPE_BUTCH]._qactive = 2; - quests[QTYPE_BUTCH]._qlog = TRUE; - quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9; - quests[QTYPE_BUTCH]._qvar1 = 1; + } else if (quests[Q_BUTCHER]._qactive == QUEST_INIT || quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qvar1 == 0) { + quests[Q_BUTCHER]._qactive = QUEST_ACTIVE; + quests[Q_BUTCHER]._qlog = TRUE; + quests[Q_BUTCHER]._qmsg = TEXT_BUTCH9; + quests[Q_BUTCHER]._qvar1 = 1; towner[t]._tbtcnt = 50; towner[t]._tVar1 = p; towner[t]._tVar2 = 3; - InitQTextMsg(QUEST_BUTCH9); + InitQTextMsg(TEXT_BUTCH9); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_BUTCH); + NetSendCmdQuest(TRUE, Q_BUTCHER); } } else if (t == GetActiveTowner(TOWN_SMITH)) { if (gbMaxPlayers == 1) { - if (plr[p]._pLvlVisited[4] && quests[QTYPE_INFRA]._qactive != 0) { - if (quests[QTYPE_INFRA]._qvar2 == 0) { - quests[QTYPE_INFRA]._qvar2 = 1; - quests[QTYPE_INFRA]._qlog = TRUE; - if (quests[QTYPE_INFRA]._qactive == 1) { - quests[QTYPE_INFRA]._qactive = 2; - quests[QTYPE_INFRA]._qvar1 = 1; + if (plr[p]._pLvlVisited[4] && quests[Q_ROCK]._qactive != QUEST_NOTAVAIL) { + if (quests[Q_ROCK]._qvar2 == 0) { + quests[Q_ROCK]._qvar2 = 1; + quests[Q_ROCK]._qlog = TRUE; + if (quests[Q_ROCK]._qactive == QUEST_INIT) { + quests[Q_ROCK]._qactive = QUEST_ACTIVE; + quests[Q_ROCK]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INFRA5); + InitQTextMsg(TEXT_INFRA5); towner[t]._tMsgSaid = TRUE; } - if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, i) != NULL) { + if (quests[Q_ROCK]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, i) != NULL) { #ifndef HELLFIRE if (!towner[t]._tMsgSaid) { #endif - quests[QTYPE_INFRA]._qactive = 3; - quests[QTYPE_INFRA]._qvar2 = 2; - quests[QTYPE_INFRA]._qvar1 = 2; + quests[Q_ROCK]._qactive = QUEST_DONE; + quests[Q_ROCK]._qvar2 = 2; + quests[Q_ROCK]._qvar1 = 2; RemoveInvItem(p, i); CreateItem(UITEM_INFRARING, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_INFRA7); + InitQTextMsg(TEXT_INFRA7); towner[t]._tMsgSaid = TRUE; #ifndef HELLFIRE } #endif } } - if (plr[p]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive != 0) { - if ((quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && quests[QTYPE_ANVIL]._qvar2 == 0 && !towner[t]._tMsgSaid) { - if (quests[QTYPE_INFRA]._qvar2 == 2 || quests[QTYPE_INFRA]._qactive == 2 && quests[QTYPE_INFRA]._qvar2 == 1) { - quests[QTYPE_ANVIL]._qvar2 = 1; - quests[QTYPE_ANVIL]._qlog = TRUE; - if (quests[QTYPE_ANVIL]._qactive == 1) { - quests[QTYPE_ANVIL]._qactive = 2; - quests[QTYPE_ANVIL]._qvar1 = 1; + if (plr[p]._pLvlVisited[9] && quests[Q_ANVIL]._qactive != QUEST_NOTAVAIL) { + if ((quests[Q_ANVIL]._qactive == QUEST_INIT || quests[Q_ANVIL]._qactive == QUEST_ACTIVE) && quests[Q_ANVIL]._qvar2 == 0 && !towner[t]._tMsgSaid) { + if (quests[Q_ROCK]._qvar2 == 2 || quests[Q_ROCK]._qactive == QUEST_ACTIVE && quests[Q_ROCK]._qvar2 == 1) { + quests[Q_ANVIL]._qvar2 = 1; + quests[Q_ANVIL]._qlog = TRUE; + if (quests[Q_ANVIL]._qactive == QUEST_INIT) { + quests[Q_ANVIL]._qactive = QUEST_ACTIVE; + quests[Q_ANVIL]._qvar1 = 1; } towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_ANVIL5); + InitQTextMsg(TEXT_ANVIL5); towner[t]._tMsgSaid = TRUE; } } - if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, i) != NULL) { + if (quests[Q_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, i) != NULL) { #ifndef HELLFIRE if (!towner[t]._tMsgSaid) { #endif - quests[QTYPE_ANVIL]._qactive = 3; - quests[QTYPE_ANVIL]._qvar2 = 2; - quests[QTYPE_ANVIL]._qvar1 = 2; + quests[Q_ANVIL]._qactive = QUEST_DONE; + quests[Q_ANVIL]._qvar2 = 2; + quests[Q_ANVIL]._qvar1 = 2; RemoveInvItem(p, i); CreateItem(UITEM_GRISWOLD, towner[t]._tx, towner[t]._ty + 1); towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_ANVIL7); + InitQTextMsg(TEXT_ANVIL7); towner[t]._tMsgSaid = TRUE; #ifndef HELLFIRE } @@ -936,38 +937,38 @@ void TalkToTowner(int p, int t) } } if (!qtextflag) { - TownerTalk(QUEST_GRISWOLD1, t); + TownerTalk(TEXT_GRISWOLD1, t); if (storeflag) { StartStore(STORE_SMITH); } } } else if (t == GetActiveTowner(TOWN_WITCH)) { - if (quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, i) != NULL) { + if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && PlrHasItem(p, IDI_FUNGALTM, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_BLKM]._qactive = 2; - quests[QTYPE_BLKM]._qlog = TRUE; - quests[QTYPE_BLKM]._qvar1 = 2; + quests[Q_MUSHROOM]._qactive = QUEST_ACTIVE; + quests[Q_MUSHROOM]._qlog = TRUE; + quests[Q_MUSHROOM]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_MUSH8); + InitQTextMsg(TEXT_MUSH8); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BLKM]._qactive == 2) { - if (quests[QTYPE_BLKM]._qvar1 >= 2 && quests[QTYPE_BLKM]._qvar1 <= 4) { + } else if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { + if (quests[Q_MUSHROOM]._qvar1 >= 2 && quests[Q_MUSHROOM]._qvar1 <= 4) { if (PlrHasItem(p, IDI_MUSHROOM, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_BLKM]._qvar1 = 5; - Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; + quests[Q_MUSHROOM]._qvar1 = 5; + Qtalklist[TOWN_HEALER]._qblkm = TEXT_MUSH3; Qtalklist[TOWN_WITCH]._qblkm = -1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qmsg = QUEST_MUSH10; - InitQTextMsg(QUEST_MUSH10); + quests[Q_MUSHROOM]._qmsg = TEXT_MUSH10; + InitQTextMsg(TEXT_MUSH10); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_BLKM]._qmsg != QUEST_MUSH9) { + } else if (quests[Q_MUSHROOM]._qmsg != TEXT_MUSH9) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qmsg = QUEST_MUSH9; - InitQTextMsg(QUEST_MUSH9); + quests[Q_MUSHROOM]._qmsg = TEXT_MUSH9; + InitQTextMsg(TEXT_MUSH9); towner[t]._tMsgSaid = TRUE; } } else { @@ -975,21 +976,21 @@ void TalkToTowner(int p, int t) if (Item != NULL) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_MUSH12); - quests[QTYPE_BLKM]._qactive = 3; + InitQTextMsg(TEXT_MUSH12); + quests[Q_MUSHROOM]._qactive = QUEST_DONE; towner[t]._tMsgSaid = TRUE; AllItemsList[Item->IDidx].iUsable = TRUE; - } else if (PlrHasItem(p, IDI_BRAIN, i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) { + } else if (PlrHasItem(p, IDI_BRAIN, i) != NULL && quests[Q_MUSHROOM]._qvar2 != TEXT_MUSH11) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11; - InitQTextMsg(QUEST_MUSH11); + quests[Q_MUSHROOM]._qvar2 = TEXT_MUSH11; + InitQTextMsg(TEXT_MUSH11); towner[t]._tMsgSaid = TRUE; } } } if (!qtextflag) { - TownerTalk(QUEST_ADRIA1, t); + TownerTalk(TEXT_ADRIA1, t); if (storeflag) { StartStore(STORE_WITCH); } @@ -997,22 +998,22 @@ void TalkToTowner(int p, int t) } else if (t == GetActiveTowner(TOWN_BMAID)) { #ifdef HELLFIRE if (plr[p]._pLvlVisited[21] == false && PlrHasItem(p, IDI_MAPOFDOOM, i)) { - quests[QTYPE_GRAVE]._qactive = 2; - quests[QTYPE_GRAVE]._qlog = 1; - quests[QTYPE_GRAVE]._qmsg = QUEST_GRAVE8; - InitQTextMsg(QUEST_GRAVE8); + quests[Q_GRAVE]._qactive = 2; + quests[Q_GRAVE]._qlog = 1; + quests[Q_GRAVE]._qmsg = TEXT_GRAVE8; + InitQTextMsg(Q_GRAVE); towner[t]._tMsgSaid = TRUE; } #endif if (!qtextflag) { - TownerTalk(QUEST_GILLIAN1, t); + TownerTalk(TEXT_GILLIAN1, t); if (storeflag) { StartStore(STORE_BARMAID); } } } else if (t == GetActiveTowner(TOWN_DRUNK)) { if (!qtextflag) { - TownerTalk(QUEST_FARNHAM1, t); + TownerTalk(TEXT_FARNHAM1, t); if (storeflag) { StartStore(STORE_DRUNK); } @@ -1024,86 +1025,86 @@ void TalkToTowner(int p, int t) #else if (plr[p]._pLvlVisited[1] && !towner[t]._tMsgSaid) { #endif - if (quests[QTYPE_PW]._qactive == 1) { - quests[QTYPE_PW]._qactive = 2; - quests[QTYPE_PW]._qlog = TRUE; - quests[QTYPE_PW]._qmsg = QUEST_POISON3; - quests[QTYPE_PW]._qvar1 = 1; + if (quests[Q_PWATER]._qactive == QUEST_INIT) { + quests[Q_PWATER]._qactive = QUEST_ACTIVE; + quests[Q_PWATER]._qlog = TRUE; + quests[Q_PWATER]._qmsg = TEXT_POISON3; + quests[Q_PWATER]._qvar1 = 1; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_POISON3); + InitQTextMsg(TEXT_POISON3); towner[t]._tMsgSaid = TRUE; - } else if (quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2) { - quests[QTYPE_PW]._qvar1 = 2; + } else if (quests[Q_PWATER]._qactive == QUEST_DONE && quests[Q_PWATER]._qvar1 != 2) { + quests[Q_PWATER]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_POISON5); + InitQTextMsg(TEXT_POISON5); CreateItem(UITEM_TRING, towner[t]._tx, towner[t]._ty + 1); towner[t]._tMsgSaid = TRUE; } } - if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, i) != NULL) { + if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE && quests[Q_MUSHROOM]._qmsg == TEXT_MUSH10 && PlrHasItem(p, IDI_BRAIN, i) != NULL) { RemoveInvItem(p, i); SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0); - InitQTextMsg(QUEST_MUSH4); - quests[QTYPE_BLKM]._qvar1 = 7; + InitQTextMsg(TEXT_MUSH4); + quests[Q_MUSHROOM]._qvar1 = 7; Qtalklist[TOWN_HEALER]._qblkm = -1; } } if (!qtextflag) { - TownerTalk(QUEST_PEPIN1, t); + TownerTalk(TEXT_PEPIN1, t); if (storeflag) { StartStore(STORE_HEALER); } } } else if (t == GetActiveTowner(TOWN_PEGBOY)) { if (!qtextflag) { - TownerTalk(QUEST_WIRT1, t); + TownerTalk(TEXT_WIRT1, t); if (storeflag) { StartStore(STORE_BOY); } } } else if (t == GetActiveTowner(TOWN_STORY)) { if (gbMaxPlayers == 1) { - if (quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, i) != NULL) { + if (quests[Q_BETRAYER]._qactive == QUEST_INIT && PlrHasItem(p, IDI_LAZSTAFF, i) != NULL) { RemoveInvItem(p, i); - quests[QTYPE_VB]._qvar1 = 2; + quests[Q_BETRAYER]._qvar1 = 2; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE1); + InitQTextMsg(TEXT_VILE1); towner[t]._tMsgSaid = TRUE; - quests[QTYPE_VB]._qactive = 2; - quests[QTYPE_VB]._qlog = TRUE; - } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { - quests[QTYPE_VB]._qvar1 = 8; + quests[Q_BETRAYER]._qactive = QUEST_ACTIVE; + quests[Q_BETRAYER]._qlog = TRUE; + } else if (quests[Q_BETRAYER]._qactive == QUEST_DONE && quests[Q_BETRAYER]._qvar1 == 7) { + quests[Q_BETRAYER]._qvar1 = 8; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE3); + InitQTextMsg(TEXT_VILE3); towner[t]._tMsgSaid = TRUE; - quests[QTYPE_MOD]._qlog = TRUE; + quests[Q_DIABLO]._qlog = TRUE; } } if (gbMaxPlayers != 1) { - if (quests[QTYPE_VB]._qactive == 2 && !quests[QTYPE_VB]._qlog) { + if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE && !quests[Q_BETRAYER]._qlog) { towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE1); + InitQTextMsg(TEXT_VILE1); towner[t]._tMsgSaid = TRUE; - quests[QTYPE_VB]._qlog = TRUE; - NetSendCmdQuest(TRUE, QTYPE_VB); - } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { - quests[QTYPE_VB]._qvar1 = 8; + quests[Q_BETRAYER]._qlog = TRUE; + NetSendCmdQuest(TRUE, Q_BETRAYER); + } else if (quests[Q_BETRAYER]._qactive == QUEST_DONE && quests[Q_BETRAYER]._qvar1 == 7) { + quests[Q_BETRAYER]._qvar1 = 8; towner[t]._tbtcnt = 150; towner[t]._tVar1 = p; - InitQTextMsg(QUEST_VILE3); + InitQTextMsg(TEXT_VILE3); towner[t]._tMsgSaid = TRUE; - NetSendCmdQuest(TRUE, QTYPE_VB); - quests[QTYPE_MOD]._qlog = TRUE; - NetSendCmdQuest(TRUE, QTYPE_MOD); + NetSendCmdQuest(TRUE, Q_BETRAYER); + quests[Q_DIABLO]._qlog = TRUE; + NetSendCmdQuest(TRUE, Q_DIABLO); } } if (!qtextflag) { - TownerTalk(QUEST_STORY1, t); + TownerTalk(TEXT_STORY1, t); if (storeflag) { StartStore(STORE_STORY); } @@ -1114,143 +1115,143 @@ void TalkToTowner(int p, int t) #ifdef HELLFIRE } else if (towner[t]._ttype == TOWN_FARMER) { if (!qtextflag) { - switch (quests[QTYPE_FARMER]._qactive) { + switch (quests[Q_FARMER]._qactive) { case 0: if (PlrHasItem(p, IDI_RUNEBOMB, i)) { - qt = QUEST_FARMER2; - quests[QTYPE_FARMER]._qactive = 2; - quests[QTYPE_FARMER]._qvar1 = 1; - quests[QTYPE_FARMER]._qlog = 1; - quests[QTYPE_FARMER]._qmsg = QUEST_FARMER1; + qt = TEXT_FARMER2; + quests[Q_FARMER]._qactive = 2; + quests[Q_FARMER]._qvar1 = 1; + quests[Q_FARMER]._qlog = 1; + quests[Q_FARMER]._qmsg = TEXT_FARMER1; } else if (!plr[myplr]._pLvlVisited[9] && plr[myplr]._pLevel < 15) { - qt = !PlrHasItem(p, IDI_RUNEBOMB, i) ? QUEST_FARMER3 : QUEST_FARMER2; + qt = !PlrHasItem(p, IDI_RUNEBOMB, i) ? TEXT_FARMER3 : TEXT_FARMER2; } else { - qt = QUEST_FARMER1; - quests[QTYPE_FARMER]._qactive = 2; - quests[QTYPE_FARMER]._qvar1 = 1; - quests[QTYPE_FARMER]._qlog = 1; - quests[QTYPE_FARMER]._qmsg = QUEST_FARMER1; + qt = TEXT_FARMER1; + quests[Q_FARMER]._qactive = 2; + quests[Q_FARMER]._qvar1 = 1; + quests[Q_FARMER]._qlog = 1; + quests[Q_FARMER]._qmsg = TEXT_FARMER1; SpawnRuneBomb(towner[t]._tx + 1, towner[t]._ty); } break; case 1: if (PlrHasItem(p, IDI_RUNEBOMB, i)) { - qt = QUEST_FARMER2; - quests[QTYPE_FARMER]._qactive = 2; - quests[QTYPE_FARMER]._qvar1 = 1; - quests[QTYPE_FARMER]._qmsg = QUEST_FARMER1; - quests[QTYPE_FARMER]._qlog = 1; + qt = TEXT_FARMER2; + quests[Q_FARMER]._qactive = 2; + quests[Q_FARMER]._qvar1 = 1; + quests[Q_FARMER]._qmsg = TEXT_FARMER1; + quests[Q_FARMER]._qlog = 1; } else if (!plr[myplr]._pLvlVisited[9] && plr[myplr]._pLevel < 15) { - qt = QUEST_FARMER8; + qt = TEXT_FARMER8; if (plr[myplr]._pLvlVisited[2]) { - qt = QUEST_FARMER5; + qt = TEXT_FARMER5; } if (plr[myplr]._pLvlVisited[5]) { - qt = QUEST_FARMER7; + qt = TEXT_FARMER7; } if (plr[myplr]._pLvlVisited[7]) { - qt = QUEST_FARMER9; + qt = TEXT_FARMER9; } } else { - qt = QUEST_FARMER1; - quests[QTYPE_FARMER]._qactive = 2; - quests[QTYPE_FARMER]._qvar1 = 1; - quests[QTYPE_FARMER]._qlog = 1; - quests[QTYPE_FARMER]._qmsg = QUEST_FARMER1; + qt = TEXT_FARMER1; + quests[Q_FARMER]._qactive = 2; + quests[Q_FARMER]._qvar1 = 1; + quests[Q_FARMER]._qlog = 1; + quests[Q_FARMER]._qmsg = TEXT_FARMER1; SpawnRuneBomb(towner[t]._tx + 1, towner[t]._ty); } break; case 2: - qt = !PlrHasItem(p, IDI_RUNEBOMB, i) ? QUEST_FARMER3 : QUEST_FARMER2; + qt = !PlrHasItem(p, IDI_RUNEBOMB, i) ? TEXT_FARMER3 : TEXT_FARMER2; break; case 3: - qt = QUEST_FARMER4; + qt = TEXT_FARMER4; SpawnRewardItem(IDI_AURIC, towner[t]._tx + 1, towner[t]._ty); - quests[QTYPE_FARMER]._qactive = 10; - quests[QTYPE_FARMER]._qlog = 0; + quests[Q_FARMER]._qactive = 10; + quests[Q_FARMER]._qlog = 0; break; case 10: qt = -1; break; default: - quests[QTYPE_FARMER]._qactive = 0; - qt = QUEST_FARMER4; + quests[Q_FARMER]._qactive = 0; + qt = TEXT_FARMER4; break; } if (qt != -1) { InitQTextMsg(qt); } if (gbMaxPlayers != 1) { - NetSendCmdQuest(TRUE, QTYPE_FARMER); + NetSendCmdQuest(TRUE, Q_FARMER); } } } else if (towner[t]._ttype == TOWN_COWFARM) { if (!qtextflag) { if (PlrHasItem(p, IDI_GREYSUIT, i)) { - qt = QUEST_JERSEY7; + qt = TEXT_JERSEY7; RemoveInvItem(p, i); } else if (PlrHasItem(p, IDI_BROWNSUIT, i)) { CreateItem(UITEM_BOVINE, towner[t]._tx + 1, towner[t]._ty); RemoveInvItem(p, i); - qt = QUEST_JERSEY8; - quests[QTYPE_JERSEY]._qactive = 3; + qt = TEXT_JERSEY8; + quests[Q_JERSEY]._qactive = 3; } else if (PlrHasItem(p, IDI_RUNEBOMB, i)) { - qt = QUEST_JERSEY5; - quests[QTYPE_JERSEY]._qactive = 2; - quests[QTYPE_JERSEY]._qvar1 = 1; - quests[QTYPE_JERSEY]._qmsg = QUEST_JERSEY4; - quests[QTYPE_JERSEY]._qlog = 1; + qt = TEXT_JERSEY5; + quests[Q_JERSEY]._qactive = 2; + quests[Q_JERSEY]._qvar1 = 1; + quests[Q_JERSEY]._qmsg = TEXT_JERSEY4; + quests[Q_JERSEY]._qlog = 1; } else { - switch (quests[QTYPE_JERSEY]._qactive) { + switch (quests[Q_JERSEY]._qactive) { case 0: - qt = QUEST_JERSEY1; - quests[QTYPE_JERSEY]._qactive = 7; + qt = TEXT_JERSEY1; + quests[Q_JERSEY]._qactive = 7; break; case 1: - qt = QUEST_JERSEY5; + qt = TEXT_JERSEY5; break; case 2: - qt = QUEST_JERSEY1; + qt = TEXT_JERSEY1; break; case 3: - qt = QUEST_JERSEY5; + qt = TEXT_JERSEY5; break; case 7: - qt = QUEST_JERSEY2; - quests[QTYPE_JERSEY]._qactive = 8; + qt = TEXT_JERSEY2; + quests[Q_JERSEY]._qactive = 8; break; case 8: - qt = QUEST_JERSEY3; - quests[QTYPE_JERSEY]._qactive = 9; + qt = TEXT_JERSEY3; + quests[Q_JERSEY]._qactive = 9; break; case 9: if (!plr[myplr]._pLvlVisited[9] && plr[myplr]._pLevel < 15) { switch (random_(0, 4)) { case 0: - qt = QUEST_JERSEY9; + qt = TEXT_JERSEY9; break; case 1: - qt = QUEST_JERSEY10; + qt = TEXT_JERSEY10; break; case 2: - qt = QUEST_JERSEY11; + qt = TEXT_JERSEY11; break; default: - qt = QUEST_JERSEY12; + qt = TEXT_JERSEY12; break; } } else { - qt = QUEST_JERSEY4; - quests[QTYPE_JERSEY]._qactive = 2; - quests[QTYPE_JERSEY]._qvar1 = 1; - quests[QTYPE_JERSEY]._qmsg = QUEST_JERSEY4; - quests[QTYPE_JERSEY]._qlog = 1; + qt = TEXT_JERSEY4; + quests[Q_JERSEY]._qactive = 2; + quests[Q_JERSEY]._qvar1 = 1; + quests[Q_JERSEY]._qmsg = TEXT_JERSEY4; + quests[Q_JERSEY]._qlog = 1; SpawnRuneBomb(towner[t]._tx + 1, towner[t]._ty); } break; default: - qt = QUEST_JERSEY5; - quests[QTYPE_JERSEY]._qactive = 0; + qt = TEXT_JERSEY5; + quests[Q_JERSEY]._qactive = 0; break; } } @@ -1258,48 +1259,48 @@ void TalkToTowner(int p, int t) InitQTextMsg(qt); } if (gbMaxPlayers != 1) { - NetSendCmdQuest(TRUE, QTYPE_JERSEY); + NetSendCmdQuest(TRUE, Q_JERSEY); } } } else if (towner[t]._ttype == TOWN_GIRL) { if (!qtextflag) { t2 = 0; - if (!PlrHasItem(p, IDI_THEODORE, i) || quests[QTYPE_GIRL]._qactive == 3) { - switch (quests[QTYPE_FARMER]._qactive) { + if (!PlrHasItem(p, IDI_THEODORE, i) || quests[Q_GIRL]._qactive == 3) { + switch (quests[Q_FARMER]._qactive) { case 0: - qt = QUEST_GIRL2; - quests[QTYPE_GIRL]._qactive = 2; - quests[QTYPE_GIRL]._qvar1 = 1; - quests[QTYPE_GIRL]._qlog = 1; - quests[QTYPE_GIRL]._qmsg = QUEST_GIRL2; + qt = TEXT_GIRL2; + quests[Q_GIRL]._qactive = 2; + quests[Q_GIRL]._qvar1 = 1; + quests[Q_GIRL]._qlog = 1; + quests[Q_GIRL]._qmsg = TEXT_GIRL2; t2 = 1; break; case 1: - qt = QUEST_GIRL2; - quests[QTYPE_GIRL]._qvar1 = 1; - quests[QTYPE_GIRL]._qlog = 1; - quests[QTYPE_GIRL]._qmsg = QUEST_GIRL2; - quests[QTYPE_GIRL]._qactive = 2; + qt = TEXT_GIRL2; + quests[Q_GIRL]._qvar1 = 1; + quests[Q_GIRL]._qlog = 1; + quests[Q_GIRL]._qmsg = TEXT_GIRL2; + quests[Q_GIRL]._qactive = 2; t2 = 1; break; case 2: - qt = QUEST_GIRL3; + qt = TEXT_GIRL3; t2 = 1; break; case 3: qt = -1; break; default: - quests[QTYPE_GIRL]._qactive = 0; - qt = QUEST_GIRL1; + quests[Q_GIRL]._qactive = 0; + qt = TEXT_GIRL1; break; } } else { - qt = QUEST_GIRL4; + qt = TEXT_GIRL4; RemoveInvItem(p, i); CreateAmulet(towner[t]._tx, towner[t]._ty, 13, 0, 1); - quests[QTYPE_GIRL]._qlog = 0; - quests[QTYPE_GIRL]._qactive = 3; + quests[Q_GIRL]._qlog = 0; + quests[Q_GIRL]._qactive = 3; t2 = 1; } if (qt != -1) { @@ -1310,7 +1311,7 @@ void TalkToTowner(int p, int t) } } if (gbMaxPlayers != 1) { - NetSendCmdQuest(TRUE, QTYPE_GIRL); + NetSendCmdQuest(TRUE, Q_GIRL); } } #endif diff --git a/Source/track.cpp b/Source/track.cpp index 86f3d5f1..11552f0d 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" static BYTE sgbIsScrolling; diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 8d66c5b2..77ab6ad0 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" BOOL townwarps[3]; BOOL trigflag; @@ -188,7 +188,7 @@ void InitTownTriggers() numtrigs++; } #ifdef HELLFIRE - if (quests[QTYPE_GRAVE]._qactive == 3) { + if (quests[Q_GRAVE]._qactive == 3) { trigs[numtrigs]._tx = 36; trigs[numtrigs]._ty = 24; trigs[numtrigs]._tmsg = WM_DIABTOWNWARP; @@ -269,7 +269,7 @@ void InitL2Triggers() numtrigs = 0; for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { - if (dPiece[i][j] == 267 && (i != quests[QTYPE_BONE]._qtx || j != quests[QTYPE_BONE]._qty)) { + if (dPiece[i][j] == 267 && (i != quests[Q_SCHAMB]._qtx || j != quests[Q_SCHAMB]._qty)) { trigs[numtrigs]._tx = i; trigs[numtrigs]._ty = j; trigs[numtrigs]._tmsg = WM_DIABPREVLVL; @@ -392,7 +392,7 @@ void InitL4Triggers() for (j = 0; j < MAXDUNY; j++) { for (i = 0; i < MAXDUNX; i++) { - if (dPiece[i][j] == 370 && quests[QTYPE_VB]._qactive == 3) { + if (dPiece[i][j] == 370 && quests[Q_BETRAYER]._qactive == QUEST_DONE) { trigs[numtrigs]._tx = i; trigs[numtrigs]._ty = j; trigs[numtrigs]._tmsg = WM_DIABNEXTLVL; @@ -850,7 +850,7 @@ BOOL ForceSKingTrig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_KING]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_SKELKING]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; @@ -867,7 +867,7 @@ BOOL ForceSChambTrig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_BONE]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_SCHAMB]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; @@ -884,7 +884,7 @@ BOOL ForcePWaterTrig() for (i = 0; L3DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L3DownList[i]) { - sprintf(infostr, "Back to Level %i", quests[QTYPE_PW]._qlevel); + sprintf(infostr, "Back to Level %i", quests[Q_PWATER]._qlevel); cursmx = trigs[0]._tx; cursmy = trigs[0]._ty; diff --git a/Source/wave.cpp b/Source/wave.cpp index 48e47064..af07ab33 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -1,4 +1,4 @@ -#include "diablo.h" +#include "all.h" #include "../3rdParty/Storm/Source/storm.h" BOOL WCloseFile(HANDLE file) diff --git a/comparer-config/diablo.toml b/comparer-config/diablo.toml index bff95c25..41c12fd3 100644 --- a/comparer-config/diablo.toml +++ b/comparer-config/diablo.toml @@ -153,7 +153,7 @@ addr = 0x401FBD size = 0x276 [[func]] -name = "DrawAutomapType" +name = "DrawAutomapTile" addr = 0x402233 size = 0x745 @@ -168,7 +168,7 @@ addr = 0x402D83 size = 0xC7 [[func]] -name = "DrawAutomapGame" +name = "DrawAutomapText" addr = 0x402E4A size = 0xDD @@ -273,7 +273,7 @@ addr = 0x404017 size = 0xC3 [[func]] -name = "CPrintString" +name = "PrintChar" addr = 0x4040DA size = 0x13E @@ -333,12 +333,12 @@ addr = 0x404616 size = 0x31E [[func]] -name = "ClearCtrlPan" +name = "DrawCtrlPan" addr = 0x404934 size = 0x25 [[func]] -name = "DrawCtrlPan" +name = "DrawCtrlBtns" addr = 0x404959 size = 0xB1 @@ -393,12 +393,12 @@ addr = 0x4052C8 size = 0x289 [[func]] -name = "control_draw_info_str" +name = "PrintInfo" addr = 0x405551 size = 0x6B [[func]] -name = "control_print_info_str" +name = "CPrintString" addr = 0x4055BC size = 0xC5 @@ -1628,7 +1628,7 @@ addr = 0x4158B9 size = 0x29 [[func]] -name = "sfx_stop" +name = "stream_stop" addr = 0x4158E2 size = 0x29 @@ -1638,7 +1638,7 @@ addr = 0x41590B size = 0xD0 [[func]] -name = "FreeEffects" +name = "FreeMonsterSnd" addr = 0x4159DB size = 0x6A @@ -1678,12 +1678,12 @@ addr = 0x415D01 size = 0x38 [[func]] -name = "FreeMonsterSnd" +name = "sound_stop" addr = 0x415D39 size = 0x61 [[func]] -name = "sound_stop" +name = "sfx_stop" addr = 0x415D9A size = 0x20 @@ -1693,7 +1693,7 @@ addr = 0x415DBA size = 0x16 [[func]] -name = "effects_update" +name = "stream_update" addr = 0x415DD0 size = 0x2F @@ -1703,7 +1703,7 @@ addr = 0x415DFF size = 0x2B [[func]] -name = "stream_update" +name = "sound_init" addr = 0x415E2A size = 0x4D @@ -1713,7 +1713,7 @@ addr = 0x415E77 size = 0x61 [[func]] -name = "sound_init" +name = "ui_sound_init" addr = 0x415ED8 size = 0x7 @@ -2078,17 +2078,17 @@ addr = 0x418860 size = 0x6 [[func]] -name = "gamemenu_previous" +name = "gamemenu_on" addr = 0x418866 size = 0x29 [[func]] -name = "gamemenu_enable_single" +name = "gamemenu_update_single" addr = 0x41888F size = 0x39 [[func]] -name = "gamemenu_enable_multi" +name = "gamemenu_update_multi" addr = 0x4188C8 size = 0x10 @@ -2103,7 +2103,7 @@ addr = 0x4188E1 size = 0x13 [[func]] -name = "j_gamemenu_previous" +name = "gamemenu_previous" addr = 0x4188F4 size = 0x5 @@ -2323,12 +2323,12 @@ addr = 0x419F70 size = 0x78 [[func]] -name = "gmenu_exception" +name = "gmenu_is_active" addr = 0x419FE8 size = 0xC [[func]] -name = "gmenu_call_proc" +name = "gmenu_set_items" addr = 0x419FF4 size = 0x5A @@ -2373,7 +2373,7 @@ addr = 0x41A37A size = 0x58 [[func]] -name = "gmenu_valid_mouse_pos" +name = "gmenu_get_mouse_slider" addr = 0x41A3D2 size = 0x2F @@ -5243,7 +5243,7 @@ addr = 0x43BD19 size = 0xD2 [[func]] -name = "msg_process_net_packets" +name = "run_delta_info" addr = 0x43BDEB size = 0x22 @@ -5438,7 +5438,7 @@ addr = 0x43D064 size = 0x39 [[func]] -name = "RemovePlrPortal" +name = "delta_close_portal" addr = 0x43D09D size = 0x1F @@ -8153,7 +8153,7 @@ addr = 0x45708B size = 0xA0 [[func]] -name = "sound_load_volume" +name = "snd_get_volume" addr = 0x45712B size = 0x51 @@ -8173,7 +8173,7 @@ addr = 0x4572FF size = 0x59 [[func]] -name = "sound_store_volume" +name = "snd_set_volume" addr = 0x457358 size = 0xF @@ -8268,7 +8268,7 @@ addr = 0x457DE2 size = 0x80 [[func]] -name = "DrawSArrows" +name = "DrawSSlider" addr = 0x457E62 size = 0xF0 diff --git a/comparer-config/spawn.toml b/comparer-config/spawn.toml index 08d16891..5a6fd8cb 100644 --- a/comparer-config/spawn.toml +++ b/comparer-config/spawn.toml @@ -153,7 +153,7 @@ addr = 0x401FBD size = 0x276 [[func]] -name = "DrawAutomapType" +name = "DrawAutomapTile" addr = 0x402233 size = 0x745 @@ -168,7 +168,7 @@ addr = 0x402D83 size = 0xC7 [[func]] -name = "DrawAutomapGame" +name = "DrawAutomapText" addr = 0x402E4A size = 0xDD @@ -273,7 +273,7 @@ addr = 0x404017 size = 0xC3 [[func]] -name = "CPrintString" +name = "PrintChar" addr = 0x4040DA size = 0x13E @@ -333,12 +333,12 @@ addr = 0x404616 size = 0x2FC [[func]] -name = "ClearCtrlPan" +name = "DrawCtrlPan" addr = 0x404912 size = 0x25 [[func]] -name = "DrawCtrlPan" +name = "DrawCtrlBtns" addr = 0x404937 size = 0xB1 @@ -393,12 +393,12 @@ addr = 0x4052A6 size = 0x289 [[func]] -name = "control_draw_info_str" +name = "PrintInfo" addr = 0x40552F size = 0x6B [[func]] -name = "control_print_info_str" +name = "CPrintString" addr = 0x40559A size = 0xC5 @@ -1098,7 +1098,7 @@ addr = 0x40D741 size = 0x29 [[func]] -name = "sfx_stop" +name = "stream_stop" addr = 0x40D76A size = 0x29 @@ -1108,7 +1108,7 @@ addr = 0x40D793 size = 0xD0 [[func]] -name = "FreeEffects" +name = "FreeMonsterSnd" addr = 0x40D863 size = 0x6A @@ -1148,12 +1148,12 @@ addr = 0x40DB71 size = 0x38 [[func]] -name = "FreeMonsterSnd" +name = "sound_stop" addr = 0x40DBA9 size = 0x61 [[func]] -name = "sound_stop" +name = "sfx_stop" addr = 0x40DC0A size = 0x20 @@ -1163,7 +1163,7 @@ addr = 0x40DC2A size = 0x16 [[func]] -name = "effects_update" +name = "stream_update" addr = 0x40DC40 size = 0x2F @@ -1173,7 +1173,7 @@ addr = 0x40DC6F size = 0x2B [[func]] -name = "stream_update" +name = "sound_init" addr = 0x40DC9A size = 0x4D @@ -1183,7 +1183,7 @@ addr = 0x40DCE7 size = 0x61 [[func]] -name = "sound_init" +name = "ui_sound_init" addr = 0x40DD48 size = 0x7 @@ -1548,17 +1548,17 @@ addr = 0x4106D0 size = 0x6 [[func]] -name = "gamemenu_previous" +name = "gamemenu_on" addr = 0x4106D6 size = 0x29 [[func]] -name = "gamemenu_enable_single" +name = "gamemenu_update_single" addr = 0x4106FF size = 0x39 [[func]] -name = "gamemenu_enable_multi" +name = "gamemenu_update_multi" addr = 0x410738 size = 0x10 @@ -1573,7 +1573,7 @@ addr = 0x410751 size = 0x13 [[func]] -name = "j_gamemenu_previous" +name = "gamemenu_previous" addr = 0x410764 size = 0x5 @@ -1763,12 +1763,12 @@ addr = 0x4115EC size = 0x78 [[func]] -name = "gmenu_exception" +name = "gmenu_is_active" addr = 0x411664 size = 0xC [[func]] -name = "gmenu_call_proc" +name = "gmenu_set_items" addr = 0x411670 size = 0x5A @@ -1813,7 +1813,7 @@ addr = 0x4119F6 size = 0x58 [[func]] -name = "gmenu_valid_mouse_pos" +name = "gmenu_get_mouse_slider" addr = 0x411A4E size = 0x2F @@ -4653,7 +4653,7 @@ addr = 0x432327 size = 0xD2 [[func]] -name = "msg_process_net_packets" +name = "run_delta_info" addr = 0x4323F9 size = 0x22 @@ -4848,7 +4848,7 @@ addr = 0x433672 size = 0x39 [[func]] -name = "RemovePlrPortal" +name = "delta_close_portal" addr = 0x4336AB size = 0x1F @@ -7528,7 +7528,7 @@ addr = 0x44C454 size = 0xA0 [[func]] -name = "sound_load_volume" +name = "snd_get_volume" addr = 0x44C4F4 size = 0x51 @@ -7548,7 +7548,7 @@ addr = 0x44C6C8 size = 0x59 [[func]] -name = "sound_store_volume" +name = "snd_set_volume" addr = 0x44C721 size = 0xF @@ -7643,7 +7643,7 @@ addr = 0x44D1AB size = 0x80 [[func]] -name = "DrawSArrows" +name = "DrawSSlider" addr = 0x44D22B size = 0xF0 diff --git a/defs.h b/defs.h index d228697e..db937e26 100644 --- a/defs.h +++ b/defs.h @@ -1,4 +1,8 @@ -// some global definitions, found in debug release +/** + * @file defs.h + * + * Global definitions and Macros. + */ #ifdef HELLFIRE #define DIABOOL BOOLEAN @@ -105,6 +109,8 @@ #define MAXPATHNODES 300 +#define MAX_PATH_LENGTH 25 + // 256 kilobytes + 3 bytes (demo leftover) for file magic (262147) // final game uses 4-byte magic instead of 3 #define FILEBUFF ((256*1024)+3) diff --git a/doxygen.config b/doxygen.config new file mode 100644 index 00000000..6e90f746 --- /dev/null +++ b/doxygen.config @@ -0,0 +1,35 @@ +PROJECT_NAME = "Devilution" +PROJECT_BRIEF = "Diablo devolved - magic behind the 1996 computer game" +USE_MDFILE_AS_MAINPAGE = README.md +OUTPUT_DIRECTORY = docs +INPUT = ./ ./Source ./docs +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.c \ + *.cpp \ + *.h \ + *.inc \ + *.md + +GENERATE_LATEX = NO +WARNINGS = YES +SOURCE_BROWSER = YES +EXTRACT_STATIC = YES +JAVADOC_AUTOBRIEF = YES +OPTIMIZE_OUTPUT_FOR_C = YES +SEPARATE_MEMBER_PAGES = YES +DOT_IMAGE_FORMAT = svg +INTERACTIVE_SVG = YES +HTML_COLORSTYLE_HUE = 0 +HTML_COLORSTYLE_SAT = 125 +HTML_COLORSTYLE_GAMMA = 200 + +# Call graphces alows logical navigation of the docs +CALL_GRAPH = YES +CALLER_GRAPH = YES + +# all.h includes everything and everything inclues it so the graph is usless past depth 1 +MAX_DOT_GRAPH_DEPTH = 1 + +# Not all files are documented yet +EXTRACT_ALL = YES + diff --git a/enums.h b/enums.h index 9cf3c981..4f3dbb5d 100644 --- a/enums.h +++ b/enums.h @@ -1,3 +1,9 @@ +/** + * @file enums.h + * + * Various global enumerators. + */ + typedef enum item_quality { ITEM_QUALITY_NORMAL = 0, ITEM_QUALITY_MAGIC = 1, @@ -1858,345 +1864,345 @@ typedef enum missile_resistance { } missile_resistance; typedef enum _speech_id { - QUEST_KING1 = 0x0, - QUEST_KING2 = 0x1, - QUEST_KING3 = 0x2, - QUEST_KING4 = 0x3, - QUEST_KING5 = 0x4, - QUEST_KING6 = 0x5, - QUEST_KING7 = 0x6, - QUEST_KING8 = 0x7, - QUEST_KING9 = 0x8, - QUEST_KING10 = 0x9, - QUEST_KING11 = 0xA, - QUEST_BANNER1 = 0xB, - QUEST_BANNER2 = 0xC, - QUEST_BANNER3 = 0xD, - QUEST_BANNER4 = 0xE, - QUEST_BANNER5 = 0xF, - QUEST_BANNER6 = 0x10, - QUEST_BANNER7 = 0x11, - QUEST_BANNER8 = 0x12, - QUEST_BANNER9 = 0x13, - QUEST_BANNER10 = 0x14, - QUEST_BANNER11 = 0x15, - QUEST_BANNER12 = 0x16, - QUEST_VILE1 = 0x17, - QUEST_VILE2 = 0x18, - QUEST_VILE3 = 0x19, - QUEST_VILE4 = 0x1A, - QUEST_VILE5 = 0x1B, - QUEST_VILE6 = 0x1C, - QUEST_VILE7 = 0x1D, - QUEST_VILE8 = 0x1E, - QUEST_VILE9 = 0x1F, - QUEST_VILE10 = 0x20, - QUEST_VILE11 = 0x21, - QUEST_VILE12 = 0x22, - QUEST_VILE13 = 0x23, - QUEST_VILE14 = 0x24, - QUEST_POISON1 = 0x25, - QUEST_POISON2 = 0x26, - QUEST_POISON3 = 0x27, - QUEST_POISON4 = 0x28, - QUEST_POISON5 = 0x29, - QUEST_POISON6 = 0x2A, - QUEST_POISON7 = 0x2B, - QUEST_POISON8 = 0x2C, - QUEST_POISON9 = 0x2D, - QUEST_POISON10 = 0x2E, - QUEST_BONE1 = 0x2F, - QUEST_BONE2 = 0x30, - QUEST_BONE3 = 0x31, - QUEST_BONE4 = 0x32, - QUEST_BONE5 = 0x33, - QUEST_BONE6 = 0x34, - QUEST_BONE7 = 0x35, - QUEST_BONE8 = 0x36, - QUEST_BUTCH1 = 0x37, - QUEST_BUTCH2 = 0x38, - QUEST_BUTCH3 = 0x39, - QUEST_BUTCH4 = 0x3A, - QUEST_BUTCH5 = 0x3B, - QUEST_BUTCH6 = 0x3C, - QUEST_BUTCH7 = 0x3D, - QUEST_BUTCH8 = 0x3E, - QUEST_BUTCH9 = 0x3F, - QUEST_BUTCH10 = 0x40, - QUEST_BLIND1 = 0x41, - QUEST_BLIND2 = 0x42, - QUEST_BLIND3 = 0x43, - QUEST_BLIND4 = 0x44, - QUEST_BLIND5 = 0x45, - QUEST_BLIND6 = 0x46, - QUEST_BLIND7 = 0x47, - QUEST_BLIND8 = 0x48, - QUEST_VEIL1 = 0x49, - QUEST_VEIL2 = 0x4A, - QUEST_VEIL3 = 0x4B, - QUEST_VEIL4 = 0x4C, - QUEST_VEIL5 = 0x4D, - QUEST_VEIL6 = 0x4E, - QUEST_VEIL7 = 0x4F, - QUEST_VEIL8 = 0x50, - QUEST_VEIL9 = 0x51, - QUEST_VEIL10 = 0x52, - QUEST_VEIL11 = 0x53, - QUEST_ANVIL1 = 0x54, - QUEST_ANVIL2 = 0x55, - QUEST_ANVIL3 = 0x56, - QUEST_ANVIL4 = 0x57, - QUEST_ANVIL5 = 0x58, - QUEST_ANVIL6 = 0x59, - QUEST_ANVIL7 = 0x5A, - QUEST_ANVIL8 = 0x5B, - QUEST_ANVIL9 = 0x5C, - QUEST_ANVIL10 = 0x5D, - QUEST_BLOOD1 = 0x5E, - QUEST_BLOOD2 = 0x5F, - QUEST_BLOOD3 = 0x60, - QUEST_BLOOD4 = 0x61, - QUEST_BLOOD5 = 0x62, - QUEST_BLOOD6 = 0x63, - QUEST_BLOOD7 = 0x64, - QUEST_BLOOD8 = 0x65, - QUEST_WARLRD1 = 0x66, - QUEST_WARLRD2 = 0x67, - QUEST_WARLRD3 = 0x68, - QUEST_WARLRD4 = 0x69, - QUEST_WARLRD5 = 0x6A, - QUEST_WARLRD6 = 0x6B, - QUEST_WARLRD7 = 0x6C, - QUEST_WARLRD8 = 0x6D, - QUEST_WARLRD9 = 0x6E, - QUEST_INFRA1 = 0x6F, - QUEST_INFRA2 = 0x70, - QUEST_INFRA3 = 0x71, - QUEST_INFRA4 = 0x72, - QUEST_INFRA5 = 0x73, - QUEST_INFRA6 = 0x74, - QUEST_INFRA7 = 0x75, - QUEST_INFRA8 = 0x76, - QUEST_INFRA9 = 0x77, - QUEST_INFRA10 = 0x78, - QUEST_MUSH1 = 0x79, - QUEST_MUSH2 = 0x7A, - QUEST_MUSH3 = 0x7B, - QUEST_MUSH4 = 0x7C, - QUEST_MUSH5 = 0x7D, - QUEST_MUSH6 = 0x7E, - QUEST_MUSH7 = 0x7F, - QUEST_MUSH8 = 0x80, - QUEST_MUSH9 = 0x81, - QUEST_MUSH10 = 0x82, - QUEST_MUSH11 = 0x83, - QUEST_MUSH12 = 0x84, - QUEST_MUSH13 = 0x85, - QUEST_DOOM1 = 0x86, - QUEST_DOOM2 = 0x87, - QUEST_DOOM3 = 0x88, - QUEST_DOOM4 = 0x89, - QUEST_DOOM5 = 0x8A, - QUEST_DOOM6 = 0x8B, - QUEST_DOOM7 = 0x8C, - QUEST_DOOM8 = 0x8D, - QUEST_DOOM9 = 0x8E, - QUEST_DOOM10 = 0x8F, - QUEST_GARBUD1 = 0x90, - QUEST_GARBUD2 = 0x91, - QUEST_GARBUD3 = 0x92, - QUEST_GARBUD4 = 0x93, - QUEST_ZHAR1 = 0x94, - QUEST_ZHAR2 = 0x95, - QUEST_STORY1 = 0x96, - QUEST_STORY2 = 0x97, - QUEST_STORY3 = 0x98, - QUEST_STORY4 = 0x99, - QUEST_STORY5 = 0x9A, - QUEST_STORY6 = 0x9B, - QUEST_STORY7 = 0x9C, - QUEST_STORY9 = 0x9D, - QUEST_STORY10 = 0x9E, - QUEST_STORY11 = 0x9F, - QUEST_OGDEN1 = 0xA0, - QUEST_OGDEN2 = 0xA1, - QUEST_OGDEN3 = 0xA2, - QUEST_OGDEN4 = 0xA3, - QUEST_OGDEN5 = 0xA4, - QUEST_OGDEN6 = 0xA5, - QUEST_OGDEN8 = 0xA6, - QUEST_OGDEN9 = 0xA7, - QUEST_OGDEN10 = 0xA8, - QUEST_PEPIN1 = 0xA9, - QUEST_PEPIN2 = 0xAA, - QUEST_PEPIN3 = 0xAB, - QUEST_PEPIN4 = 0xAC, - QUEST_PEPIN5 = 0xAD, - QUEST_PEPIN6 = 0xAE, - QUEST_PEPIN7 = 0xAF, - QUEST_PEPIN9 = 0xB0, - QUEST_PEPIN10 = 0xB1, - QUEST_PEPIN11 = 0xB2, - QUEST_GILLIAN1 = 0xB3, - QUEST_GILLIAN2 = 0xB4, - QUEST_GILLIAN3 = 0xB5, - QUEST_GILLIAN4 = 0xB6, - QUEST_GILLIAN5 = 0xB7, - QUEST_GILLIAN6 = 0xB8, - QUEST_GILLIAN7 = 0xB9, - QUEST_GILLIAN9 = 0xBA, - QUEST_GILLIAN10 = 0xBB, - QUEST_GRISWOLD1 = 0xBC, - QUEST_GRISWOLD2 = 0xBD, - QUEST_GRISWOLD3 = 0xBE, - QUEST_GRISWOLD4 = 0xBF, - QUEST_GRISWOLD5 = 0xC0, - QUEST_GRISWOLD6 = 0xC1, - QUEST_GRISWOLD7 = 0xC2, - QUEST_GRISWOLD8 = 0xC3, - QUEST_GRISWOLD9 = 0xC4, - QUEST_GRISWOLD10 = 0xC5, - QUEST_GRISWOLD12 = 0xC6, - QUEST_GRISWOLD13 = 0xC7, - QUEST_FARNHAM1 = 0xC8, - QUEST_FARNHAM2 = 0xC9, - QUEST_FARNHAM3 = 0xCA, - QUEST_FARNHAM4 = 0xCB, - QUEST_FARNHAM5 = 0xCC, - QUEST_FARNHAM6 = 0xCD, - QUEST_FARNHAM8 = 0xCE, - QUEST_FARNHAM9 = 0xCF, - QUEST_FARNHAM10 = 0xD0, - QUEST_FARNHAM11 = 0xD1, - QUEST_FARNHAM12 = 0xD2, - QUEST_FARNHAM13 = 0xD3, - QUEST_ADRIA1 = 0xD4, - QUEST_ADRIA2 = 0xD5, - QUEST_ADRIA3 = 0xD6, - QUEST_ADRIA4 = 0xD7, - QUEST_ADRIA5 = 0xD8, - QUEST_ADRIA6 = 0xD9, - QUEST_ADRIA7 = 0xDA, - QUEST_ADRIA8 = 0xDB, - QUEST_ADRIA9 = 0xDC, - QUEST_ADRIA10 = 0xDD, - QUEST_ADRIA12 = 0xDE, - QUEST_ADRIA13 = 0xDF, - QUEST_WIRT1 = 0xE0, - QUEST_WIRT2 = 0xE1, - QUEST_WIRT3 = 0xE2, - QUEST_WIRT4 = 0xE3, - QUEST_WIRT5 = 0xE4, - QUEST_WIRT6 = 0xE5, - QUEST_WIRT7 = 0xE6, - QUEST_WIRT8 = 0xE7, - QUEST_WIRT9 = 0xE8, - QUEST_WIRT11 = 0xE9, - QUEST_WIRT12 = 0xEA, - QUEST_BONER = 0xEB, - QUEST_BLOODY = 0xEC, - QUEST_BLINDING = 0xED, - QUEST_BLOODWAR = 0xEE, - QUEST_MBONER = 0xEF, - QUEST_MBLOODY = 0xF0, - QUEST_MBLINDING = 0xF1, - QUEST_MBLOODWAR = 0xF2, - QUEST_RBONER = 0xF3, - QUEST_RBLOODY = 0xF4, - QUEST_RBLINDING = 0xF5, - QUEST_RBLOODWAR = 0xF6, - QUEST_COW1 = 0xF7, - QUEST_COW2 = 0xF8, - QUEST_BOOK11 = 0xF9, - QUEST_BOOK12 = 0xFA, - QUEST_BOOK13 = 0xFB, - QUEST_BOOK21 = 0xFC, - QUEST_BOOK22 = 0xFD, - QUEST_BOOK23 = 0xFE, - QUEST_BOOK31 = 0xFF, - QUEST_BOOK32 = 0x100, - QUEST_BOOK33 = 0x101, - QUEST_INTRO = 0x102, + TEXT_KING1 = 0x0, + TEXT_KING2 = 0x1, + TEXT_KING3 = 0x2, + TEXT_KING4 = 0x3, + TEXT_KING5 = 0x4, + TEXT_KING6 = 0x5, + TEXT_KING7 = 0x6, + TEXT_KING8 = 0x7, + TEXT_KING9 = 0x8, + TEXT_KING10 = 0x9, + TEXT_KING11 = 0xA, + TEXT_BANNER1 = 0xB, + TEXT_BANNER2 = 0xC, + TEXT_BANNER3 = 0xD, + TEXT_BANNER4 = 0xE, + TEXT_BANNER5 = 0xF, + TEXT_BANNER6 = 0x10, + TEXT_BANNER7 = 0x11, + TEXT_BANNER8 = 0x12, + TEXT_BANNER9 = 0x13, + TEXT_BANNER10 = 0x14, + TEXT_BANNER11 = 0x15, + TEXT_BANNER12 = 0x16, + TEXT_VILE1 = 0x17, + TEXT_VILE2 = 0x18, + TEXT_VILE3 = 0x19, + TEXT_VILE4 = 0x1A, + TEXT_VILE5 = 0x1B, + TEXT_VILE6 = 0x1C, + TEXT_VILE7 = 0x1D, + TEXT_VILE8 = 0x1E, + TEXT_VILE9 = 0x1F, + TEXT_VILE10 = 0x20, + TEXT_VILE11 = 0x21, + TEXT_VILE12 = 0x22, + TEXT_VILE13 = 0x23, + TEXT_VILE14 = 0x24, + TEXT_POISON1 = 0x25, + TEXT_POISON2 = 0x26, + TEXT_POISON3 = 0x27, + TEXT_POISON4 = 0x28, + TEXT_POISON5 = 0x29, + TEXT_POISON6 = 0x2A, + TEXT_POISON7 = 0x2B, + TEXT_POISON8 = 0x2C, + TEXT_POISON9 = 0x2D, + TEXT_POISON10 = 0x2E, + TEXT_BONE1 = 0x2F, + TEXT_BONE2 = 0x30, + TEXT_BONE3 = 0x31, + TEXT_BONE4 = 0x32, + TEXT_BONE5 = 0x33, + TEXT_BONE6 = 0x34, + TEXT_BONE7 = 0x35, + TEXT_BONE8 = 0x36, + TEXT_BUTCH1 = 0x37, + TEXT_BUTCH2 = 0x38, + TEXT_BUTCH3 = 0x39, + TEXT_BUTCH4 = 0x3A, + TEXT_BUTCH5 = 0x3B, + TEXT_BUTCH6 = 0x3C, + TEXT_BUTCH7 = 0x3D, + TEXT_BUTCH8 = 0x3E, + TEXT_BUTCH9 = 0x3F, + TEXT_BUTCH10 = 0x40, + TEXT_BLIND1 = 0x41, + TEXT_BLIND2 = 0x42, + TEXT_BLIND3 = 0x43, + TEXT_BLIND4 = 0x44, + TEXT_BLIND5 = 0x45, + TEXT_BLIND6 = 0x46, + TEXT_BLIND7 = 0x47, + TEXT_BLIND8 = 0x48, + TEXT_VEIL1 = 0x49, + TEXT_VEIL2 = 0x4A, + TEXT_VEIL3 = 0x4B, + TEXT_VEIL4 = 0x4C, + TEXT_VEIL5 = 0x4D, + TEXT_VEIL6 = 0x4E, + TEXT_VEIL7 = 0x4F, + TEXT_VEIL8 = 0x50, + TEXT_VEIL9 = 0x51, + TEXT_VEIL10 = 0x52, + TEXT_VEIL11 = 0x53, + TEXT_ANVIL1 = 0x54, + TEXT_ANVIL2 = 0x55, + TEXT_ANVIL3 = 0x56, + TEXT_ANVIL4 = 0x57, + TEXT_ANVIL5 = 0x58, + TEXT_ANVIL6 = 0x59, + TEXT_ANVIL7 = 0x5A, + TEXT_ANVIL8 = 0x5B, + TEXT_ANVIL9 = 0x5C, + TEXT_ANVIL10 = 0x5D, + TEXT_BLOOD1 = 0x5E, + TEXT_BLOOD2 = 0x5F, + TEXT_BLOOD3 = 0x60, + TEXT_BLOOD4 = 0x61, + TEXT_BLOOD5 = 0x62, + TEXT_BLOOD6 = 0x63, + TEXT_BLOOD7 = 0x64, + TEXT_BLOOD8 = 0x65, + TEXT_WARLRD1 = 0x66, + TEXT_WARLRD2 = 0x67, + TEXT_WARLRD3 = 0x68, + TEXT_WARLRD4 = 0x69, + TEXT_WARLRD5 = 0x6A, + TEXT_WARLRD6 = 0x6B, + TEXT_WARLRD7 = 0x6C, + TEXT_WARLRD8 = 0x6D, + TEXT_WARLRD9 = 0x6E, + TEXT_INFRA1 = 0x6F, + TEXT_INFRA2 = 0x70, + TEXT_INFRA3 = 0x71, + TEXT_INFRA4 = 0x72, + TEXT_INFRA5 = 0x73, + TEXT_INFRA6 = 0x74, + TEXT_INFRA7 = 0x75, + TEXT_INFRA8 = 0x76, + TEXT_INFRA9 = 0x77, + TEXT_INFRA10 = 0x78, + TEXT_MUSH1 = 0x79, + TEXT_MUSH2 = 0x7A, + TEXT_MUSH3 = 0x7B, + TEXT_MUSH4 = 0x7C, + TEXT_MUSH5 = 0x7D, + TEXT_MUSH6 = 0x7E, + TEXT_MUSH7 = 0x7F, + TEXT_MUSH8 = 0x80, + TEXT_MUSH9 = 0x81, + TEXT_MUSH10 = 0x82, + TEXT_MUSH11 = 0x83, + TEXT_MUSH12 = 0x84, + TEXT_MUSH13 = 0x85, + TEXT_DOOM1 = 0x86, + TEXT_DOOM2 = 0x87, + TEXT_DOOM3 = 0x88, + TEXT_DOOM4 = 0x89, + TEXT_DOOM5 = 0x8A, + TEXT_DOOM6 = 0x8B, + TEXT_DOOM7 = 0x8C, + TEXT_DOOM8 = 0x8D, + TEXT_DOOM9 = 0x8E, + TEXT_DOOM10 = 0x8F, + TEXT_GARBUD1 = 0x90, + TEXT_GARBUD2 = 0x91, + TEXT_GARBUD3 = 0x92, + TEXT_GARBUD4 = 0x93, + TEXT_ZHAR1 = 0x94, + TEXT_ZHAR2 = 0x95, + TEXT_STORY1 = 0x96, + TEXT_STORY2 = 0x97, + TEXT_STORY3 = 0x98, + TEXT_STORY4 = 0x99, + TEXT_STORY5 = 0x9A, + TEXT_STORY6 = 0x9B, + TEXT_STORY7 = 0x9C, + TEXT_STORY9 = 0x9D, + TEXT_STORY10 = 0x9E, + TEXT_STORY11 = 0x9F, + TEXT_OGDEN1 = 0xA0, + TEXT_OGDEN2 = 0xA1, + TEXT_OGDEN3 = 0xA2, + TEXT_OGDEN4 = 0xA3, + TEXT_OGDEN5 = 0xA4, + TEXT_OGDEN6 = 0xA5, + TEXT_OGDEN8 = 0xA6, + TEXT_OGDEN9 = 0xA7, + TEXT_OGDEN10 = 0xA8, + TEXT_PEPIN1 = 0xA9, + TEXT_PEPIN2 = 0xAA, + TEXT_PEPIN3 = 0xAB, + TEXT_PEPIN4 = 0xAC, + TEXT_PEPIN5 = 0xAD, + TEXT_PEPIN6 = 0xAE, + TEXT_PEPIN7 = 0xAF, + TEXT_PEPIN9 = 0xB0, + TEXT_PEPIN10 = 0xB1, + TEXT_PEPIN11 = 0xB2, + TEXT_GILLIAN1 = 0xB3, + TEXT_GILLIAN2 = 0xB4, + TEXT_GILLIAN3 = 0xB5, + TEXT_GILLIAN4 = 0xB6, + TEXT_GILLIAN5 = 0xB7, + TEXT_GILLIAN6 = 0xB8, + TEXT_GILLIAN7 = 0xB9, + TEXT_GILLIAN9 = 0xBA, + TEXT_GILLIAN10 = 0xBB, + TEXT_GRISWOLD1 = 0xBC, + TEXT_GRISWOLD2 = 0xBD, + TEXT_GRISWOLD3 = 0xBE, + TEXT_GRISWOLD4 = 0xBF, + TEXT_GRISWOLD5 = 0xC0, + TEXT_GRISWOLD6 = 0xC1, + TEXT_GRISWOLD7 = 0xC2, + TEXT_GRISWOLD8 = 0xC3, + TEXT_GRISWOLD9 = 0xC4, + TEXT_GRISWOLD10 = 0xC5, + TEXT_GRISWOLD12 = 0xC6, + TEXT_GRISWOLD13 = 0xC7, + TEXT_FARNHAM1 = 0xC8, + TEXT_FARNHAM2 = 0xC9, + TEXT_FARNHAM3 = 0xCA, + TEXT_FARNHAM4 = 0xCB, + TEXT_FARNHAM5 = 0xCC, + TEXT_FARNHAM6 = 0xCD, + TEXT_FARNHAM8 = 0xCE, + TEXT_FARNHAM9 = 0xCF, + TEXT_FARNHAM10 = 0xD0, + TEXT_FARNHAM11 = 0xD1, + TEXT_FARNHAM12 = 0xD2, + TEXT_FARNHAM13 = 0xD3, + TEXT_ADRIA1 = 0xD4, + TEXT_ADRIA2 = 0xD5, + TEXT_ADRIA3 = 0xD6, + TEXT_ADRIA4 = 0xD7, + TEXT_ADRIA5 = 0xD8, + TEXT_ADRIA6 = 0xD9, + TEXT_ADRIA7 = 0xDA, + TEXT_ADRIA8 = 0xDB, + TEXT_ADRIA9 = 0xDC, + TEXT_ADRIA10 = 0xDD, + TEXT_ADRIA12 = 0xDE, + TEXT_ADRIA13 = 0xDF, + TEXT_WIRT1 = 0xE0, + TEXT_WIRT2 = 0xE1, + TEXT_WIRT3 = 0xE2, + TEXT_WIRT4 = 0xE3, + TEXT_WIRT5 = 0xE4, + TEXT_WIRT6 = 0xE5, + TEXT_WIRT7 = 0xE6, + TEXT_WIRT8 = 0xE7, + TEXT_WIRT9 = 0xE8, + TEXT_WIRT11 = 0xE9, + TEXT_WIRT12 = 0xEA, + TEXT_BONER = 0xEB, + TEXT_BLOODY = 0xEC, + TEXT_BLINDING = 0xED, + TEXT_BLOODWAR = 0xEE, + TEXT_MBONER = 0xEF, + TEXT_MBLOODY = 0xF0, + TEXT_MBLINDING = 0xF1, + TEXT_MBLOODWAR = 0xF2, + TEXT_RBONER = 0xF3, + TEXT_RBLOODY = 0xF4, + TEXT_RBLINDING = 0xF5, + TEXT_RBLOODWAR = 0xF6, + TEXT_COW1 = 0xF7, + TEXT_COW2 = 0xF8, + TEXT_BOOK11 = 0xF9, + TEXT_BOOK12 = 0xFA, + TEXT_BOOK13 = 0xFB, + TEXT_BOOK21 = 0xFC, + TEXT_BOOK22 = 0xFD, + TEXT_BOOK23 = 0xFE, + TEXT_BOOK31 = 0xFF, + TEXT_BOOK32 = 0x100, + TEXT_BOOK33 = 0x101, + TEXT_INTRO = 0x102, #ifdef HELLFIRE - QUEST_HBONER = 0x103, - QUEST_HBLOODY = 0x104, - QUEST_HBLINDING = 0x105, - QUEST_HBLOODWAR = 0x106, - QUEST_BBONER = 0x107, - QUEST_BBLOODY = 0x108, - QUEST_BBLINDING = 0x109, - QUEST_BBLOODWAR = 0x10A, - QUEST_GRAVE1 = 0x10B, - QUEST_GRAVE2 = 0x10C, - QUEST_GRAVE3 = 0x10D, - QUEST_GRAVE4 = 0x10E, - QUEST_GRAVE5 = 0x10F, - QUEST_GRAVE6 = 0x110, - QUEST_GRAVE7 = 0x111, - QUEST_GRAVE8 = 0x112, - QUEST_GRAVE9 = 0x113, - QUEST_GRAVE10 = 0x114, - QUEST_FARMER1 = 0x115, - QUEST_FARMER2 = 0x116, - QUEST_FARMER3 = 0x117, - QUEST_FARMER4 = 0x118, - QUEST_FARMER5 = 0x119, - QUEST_GIRL1 = 0x11A, - QUEST_GIRL2 = 0x11B, - QUEST_GIRL3 = 0x11C, - QUEST_GIRL4 = 0x11D, - QUEST_DEFILER1 = 0x11E, - QUEST_DEFILER2 = 0x11F, - QUEST_DEFILER3 = 0x120, - QUEST_DEFILER4 = 0x121, - QUEST_DEFILER5 = 0x122, - QUEST_NAKRUL1 = 0x123, - QUEST_NAKRUL2 = 0x124, - QUEST_NAKRUL3 = 0x125, - QUEST_NAKRUL4 = 0x126, - QUEST_NAKRUL5 = 0x127, - QUEST_CORNSTN = 0x128, - QUEST_JERSEY1 = 0x129, - QUEST_JERSEY2 = 0x12A, - QUEST_JERSEY3 = 0x12B, - QUEST_JERSEY4 = 0x12C, - QUEST_JERSEY5 = 0x12D, - QUEST_JERSEY6 = 0x12E, - QUEST_JERSEY7 = 0x12F, - QUEST_JERSEY8 = 0x130, - QUEST_JERSEY9 = 0x131, - QUEST_TRADER = 0x132, - QUEST_FARMER6 = 0x133, - QUEST_FARMER7 = 0x134, - QUEST_FARMER8 = 0x135, - QUEST_FARMER9 = 0x136, - QUEST_FARMER10 = 0x137, - QUEST_JERSEY10 = 0x138, - QUEST_JERSEY11 = 0x139, - QUEST_JERSEY12 = 0x13A, - QUEST_JERSEY13 = 0x13B, - QUEST_SKLJRN = 0x13C, - QUEST_BOOK4 = 0x13D, - QUEST_BOOK5 = 0x13E, - QUEST_BOOK6 = 0x13F, - QUEST_BOOK7 = 0x140, - QUEST_BOOK8 = 0x141, - QUEST_BOOK9 = 0x142, - QUEST_BOOKA = 0x143, - QUEST_BOOKB = 0x144, - QUEST_BOOKC = 0x145, - QUEST_OBOOKA = 0x146, - QUEST_OBOOKB = 0x147, - QUEST_OBOOKC = 0x148, - QUEST_MBOOKA = 0x149, - QUEST_MBOOKB = 0x14A, - QUEST_MBOOKC = 0x14B, - QUEST_RBOOKA = 0x14C, - QUEST_RBOOKB = 0x14D, - QUEST_RBOOKC = 0x14E, - QUEST_BBOOKA = 0x14F, - QUEST_BBOOKB = 0x150, - QUEST_BBOOKC = 0x151, + TEXT_HBONER = 0x103, + TEXT_HBLOODY = 0x104, + TEXT_HBLINDING = 0x105, + TEXT_HBLOODWAR = 0x106, + TEXT_BBONER = 0x107, + TEXT_BBLOODY = 0x108, + TEXT_BBLINDING = 0x109, + TEXT_BBLOODWAR = 0x10A, + TEXT_GRAVE1 = 0x10B, + TEXT_GRAVE2 = 0x10C, + TEXT_GRAVE3 = 0x10D, + TEXT_GRAVE4 = 0x10E, + TEXT_GRAVE5 = 0x10F, + TEXT_GRAVE6 = 0x110, + TEXT_GRAVE7 = 0x111, + TEXT_GRAVE8 = 0x112, + TEXT_GRAVE9 = 0x113, + TEXT_GRAVE10 = 0x114, + TEXT_FARMER1 = 0x115, + TEXT_FARMER2 = 0x116, + TEXT_FARMER3 = 0x117, + TEXT_FARMER4 = 0x118, + TEXT_FARMER5 = 0x119, + TEXT_GIRL1 = 0x11A, + TEXT_GIRL2 = 0x11B, + TEXT_GIRL3 = 0x11C, + TEXT_GIRL4 = 0x11D, + TEXT_DEFILER1 = 0x11E, + TEXT_DEFILER2 = 0x11F, + TEXT_DEFILER3 = 0x120, + TEXT_DEFILER4 = 0x121, + TEXT_DEFILER5 = 0x122, + TEXT_NAKRUL1 = 0x123, + TEXT_NAKRUL2 = 0x124, + TEXT_NAKRUL3 = 0x125, + TEXT_NAKRUL4 = 0x126, + TEXT_NAKRUL5 = 0x127, + TEXT_CORNSTN = 0x128, + TEXT_JERSEY1 = 0x129, + TEXT_JERSEY2 = 0x12A, + TEXT_JERSEY3 = 0x12B, + TEXT_JERSEY4 = 0x12C, + TEXT_JERSEY5 = 0x12D, + TEXT_JERSEY6 = 0x12E, + TEXT_JERSEY7 = 0x12F, + TEXT_JERSEY8 = 0x130, + TEXT_JERSEY9 = 0x131, + TEXT_TRADER = 0x132, + TEXT_FARMER6 = 0x133, + TEXT_FARMER7 = 0x134, + TEXT_FARMER8 = 0x135, + TEXT_FARMER9 = 0x136, + TEXT_FARMER10 = 0x137, + TEXT_JERSEY10 = 0x138, + TEXT_JERSEY11 = 0x139, + TEXT_JERSEY12 = 0x13A, + TEXT_JERSEY13 = 0x13B, + TEXT_SKLJRN = 0x13C, + TEXT_BOOK4 = 0x13D, + TEXT_BOOK5 = 0x13E, + TEXT_BOOK6 = 0x13F, + TEXT_BOOK7 = 0x140, + TEXT_BOOK8 = 0x141, + TEXT_BOOK9 = 0x142, + TEXT_BOOKA = 0x143, + TEXT_BOOKB = 0x144, + TEXT_BOOKC = 0x145, + TEXT_OBOOKA = 0x146, + TEXT_OBOOKB = 0x147, + TEXT_OBOOKC = 0x148, + TEXT_MBOOKA = 0x149, + TEXT_MBOOKB = 0x14A, + TEXT_MBOOKC = 0x14B, + TEXT_RBOOKA = 0x14C, + TEXT_RBOOKB = 0x14D, + TEXT_RBOOKC = 0x14E, + TEXT_BBOOKA = 0x14F, + TEXT_BBOOKB = 0x150, + TEXT_BBOOKC = 0x151, #endif } _speech_id; @@ -2914,7 +2920,7 @@ typedef enum item_misc_id { IMISC_RING = 0x19, IMISC_AMULET = 0x1A, IMISC_UNIQUE = 0x1B, - IMISC_HEAL_1C = 0x1C, + IMISC_MEAT = 0x1C, /* from demo/PSX */ IMISC_OILFIRST = 0x1D, IMISC_OILOF = 0x1E, /* oils are beta or hellfire only */ IMISC_OILACC = 0x1F, @@ -2960,7 +2966,7 @@ typedef enum item_type { ITYPE_GOLD = 0xB, ITYPE_RING = 0xC, ITYPE_AMULET = 0xD, - ITYPE_0E = 0xE, + ITYPE_MEAT = 0xE, /* used in demo, might be generic for 'food' */ ITYPE_NONE = -1, } item_type; @@ -3029,35 +3035,42 @@ typedef enum _setlevels { } _setlevels; typedef enum quest_id { - QTYPE_INFRA = 0x0, - QTYPE_BLKM = 0x1, - QTYPE_GARB = 0x2, - QTYPE_ZHAR = 0x3, - QTYPE_VEIL = 0x4, - QTYPE_MOD = 0x5, - QTYPE_BUTCH = 0x6, - QTYPE_BOL = 0x7, - QTYPE_BLIND = 0x8, - QTYPE_BLOOD = 0x9, - QTYPE_ANVIL = 0xA, - QTYPE_WARLRD = 0xB, - QTYPE_KING = 0xC, - QTYPE_PW = 0xD, - QTYPE_BONE = 0xE, - QTYPE_VB = 0xF, + Q_ROCK = 0x0, + Q_MUSHROOM = 0x1, + Q_GARBUD = 0x2, + Q_ZHAR = 0x3, + Q_VEIL = 0x4, + Q_DIABLO = 0x5, + Q_BUTCHER = 0x6, + Q_LTBANNER = 0x7, + Q_BLIND = 0x8, + Q_BLOOD = 0x9, + Q_ANVIL = 0xA, + Q_WARLORD = 0xB, + Q_SKELKING = 0xC, + Q_PWATER = 0xD, + Q_SCHAMB = 0xE, + Q_BETRAYER = 0xF, #ifdef HELLFIRE - QTYPE_GRAVE = 0x10, - QTYPE_FARMER = 0x11, - QTYPE_GIRL = 0x12, - QTYPE_TRADER = 0x13, - QTYPE_DEFILER = 0x14, - QTYPE_NAKRUL = 0x15, - QTYPE_CORNSTN = 0x16, - QTYPE_JERSEY = 0x17, + Q_GRAVE = 0x10, + Q_FARMER = 0x11, + Q_GIRL = 0x12, + Q_TRADER = 0x13, + Q_DEFILER = 0x14, + Q_NAKRUL = 0x15, + Q_CORNSTN = 0x16, + Q_JERSEY = 0x17, #endif - QTYPE_INVALID = -1, + Q_INVALID = -1, } quest_id; +typedef enum quest_state { + QUEST_NOTAVAIL = 0, + QUEST_INIT = 1, + QUEST_ACTIVE = 2, + QUEST_DONE = 3 +} quest_state; + typedef enum quest_mush_state { QS_INIT = 0, QS_TOMESPAWNED = 1, diff --git a/resource.h b/resource.h index bcfe205a..962c2838 100644 --- a/resource.h +++ b/resource.h @@ -1,7 +1,10 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Diablo.rc -// +/** + * @file resource.h + * + * Microsoft Developer Studio generated include file. + * Used by Diablo.rc + */ + #define IDI_ICON1 101 #define IDD_DIALOG1 104 // DX #define IDD_DIALOG2 105 // NOMEMORY @@ -16,7 +19,7 @@ #define IDD_DIALOG11 114 // READONLY // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 diff --git a/structs.h b/structs.h index e7f9dd56..82b8e52c 100644 --- a/structs.h +++ b/structs.h @@ -1,3 +1,9 @@ +/** + * @file structs.h + * + * Various global structures. + */ + ////////////////////////////////////////////////// // control ////////////////////////////////////////////////// @@ -102,7 +108,7 @@ typedef struct ItemStruct { int _iAnimFrame; int _iAnimWidth; int _iAnimWidth2; // width 2? - BOOL _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 + BOOL _iDelFlag; // set when item is flagged for deletion, deprecated in 1.02 char _iSelFlag; BOOL _iPostDraw; BOOL _iIdentified; @@ -174,7 +180,7 @@ typedef struct ItemStruct { typedef struct PlayerStruct { int _pmode; - char walkpath[25]; + char walkpath[MAX_PATH_LENGTH]; BOOLEAN plractive; int destAction; int destParam1; @@ -384,8 +390,8 @@ typedef struct TextDataStruct { typedef struct MissileData { unsigned char mName; - void(* mAddProc)(int, int, int, int, int, int, char, int, int); - void(* mProc)(int); + void (*mAddProc)(int, int, int, int, int, int, char, int, int); + void (*mProc)(int); BOOL mDraw; unsigned char mType; unsigned char mResist; @@ -1057,7 +1063,7 @@ typedef struct QuestData { typedef struct TMenuItem { DWORD dwFlags; char *pszStr; - void(* fnMenu)(BOOL); /* fix, should have one arg */ + void (*fnMenu)(BOOL); /* fix, should have one arg */ } TMenuItem; // TPDEF PTR FCN VOID TMenuUpdateFcn @@ -1120,7 +1126,7 @@ typedef struct TownerStruct { int _teflag; int _tbtcnt; int _tSelFlag; - int _tMsgSaid; + BOOL _tMsgSaid; TNQ qsts[MAXQUESTS]; int _tSeed; int _tVar1; @@ -1379,21 +1385,21 @@ typedef struct _SNETUIDATA { int size; int uiflags; HWND parentwindow; - void(* artcallback)(); - void(* authcallback)(); - void(* createcallback)(); - void(* drawdesccallback)(); - void(* selectedcallback)(); - void(* messageboxcallback)(); - void(* soundcallback)(); - void(* statuscallback)(); - void(* getdatacallback)(); - void(* categorycallback)(); - void(* categorylistcallback)(); - void(* newaccountcallback)(); - void(* profilecallback)(); + void (*artcallback)(); + void (*authcallback)(); + void (*createcallback)(); + void (*drawdesccallback)(); + void (*selectedcallback)(); + void (*messageboxcallback)(); + void (*soundcallback)(); + void (*statuscallback)(); + void (*getdatacallback)(); + void (*categorycallback)(); + void (*categorylistcallback)(); + void (*newaccountcallback)(); + void (*profilecallback)(); const char **profilefields; - void(* profilebitmapcallback)(); + void (*profilebitmapcallback)(); int(__stdcall *selectnamecallback)( const struct _SNETPROGRAMDATA *, const struct _SNETPLAYERDATA *, @@ -1403,8 +1409,8 @@ typedef struct _SNETUIDATA { char *, DWORD, /* character name will be copied here */ char *, DWORD, /* character "description" will be copied here (used to advertise games) */ BOOL * /* new character? - unsure about this */ - ); - void(* changenamecallback)(); + ); + void (*changenamecallback)(); } _SNETUIDATA; typedef struct _SNETVERSIONDATA { diff --git a/types.h b/types.h index 5b51454d..6553268d 100644 --- a/types.h +++ b/types.h @@ -1,5 +1,8 @@ -// temporary file - +/** + * @file types.h + * + * Include OS headers and set compiler state. + */ #ifndef _TYPES_H #define _TYPES_H