diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index 6ce7ffa8d..8a229ab0a 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -11,7 +11,8 @@ #else -#include "miniwin.h" +#include "miniwin/pushdecl.inc" +namespace dvl { #endif @@ -1348,4 +1349,9 @@ BOOL __stdcall SFileEnableDirectAccess(BOOL enable); } #endif +#ifdef DEVILUTION_STUB +} +#include "miniwin/popdecl.inc" +#endif + #endif diff --git a/DiabloUI/diabloui.h b/DiabloUI/diabloui.h index bdf32a804..14035d4d6 100644 --- a/DiabloUI/diabloui.h +++ b/DiabloUI/diabloui.h @@ -2,10 +2,15 @@ #ifndef __DIABLOUI_H__ #define __DIABLOUI_H__ -#if defined(__GNUC__) || defined(__cplusplus) -extern "C" { +#ifdef DEVILUTION_STUB +#include "miniwin/pushdecl.inc" +namespace dvl { #endif +//#if defined(__GNUC__) || defined(__cplusplus) +//extern "C" { +//#endif + struct FontStruct { unsigned char fontbin[258]; HANDLE fonttrans[256]; @@ -55,8 +60,13 @@ void __stdcall UiCreateGameCriteria(_uiheroinfo *pInfo, char *str); BOOL __stdcall UiGetDefaultStats(int pclass, _uidefaultstats *pStats); BOOL __stdcall UiBetaDisclaimer(int a1); -#if defined(__GNUC__) || defined(__cplusplus) +//#if defined(__GNUC__) || defined(__cplusplus) +//} +//#endif + +#ifdef DEVILUTION_STUB } +#include "miniwin/popdecl.inc" #endif #endif /* __DIABLOUI_H__ */ diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 21012f3f0..d5b884cfe 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -16,6 +15,41 @@ int cleanup_thread_id; // } //} +void TriggerBreak() +{ +#ifdef _DEBUG + LPTOP_LEVEL_EXCEPTION_FILTER pFilter; + + pFilter = SetUnhandledExceptionFilter(BreakFilter); +#ifdef USE_ASM + __asm { + int 3 + } +#else + __debugbreak(); +#endif + SetUnhandledExceptionFilter(pFilter); +#endif +} + +#ifdef _DEBUG +LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc) +{ + if(pExc->ExceptionRecord == NULL) { + return 0; + } + if(pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) { + return 0; + } + + if(((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3 + pExc->ContextRecord->Eip++; + } + + return -1; +} +#endif + char *GetErrorStr(DWORD error_code) { DWORD upper_code; @@ -424,6 +458,9 @@ void __cdecl app_fatal(const char *pszFmt, ...) va_start(va, pszFmt); FreeDlg(); +#ifdef _DEBUG + TriggerBreak(); +#endif if (pszFmt) MsgBox(pszFmt, va); diff --git a/Source/appfat.h b/Source/appfat.h index bab1a4c2c..77d9c620a 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -6,6 +6,10 @@ extern char sz_error_buf[256]; extern int terminating; // weak extern int cleanup_thread_id; // weak +void TriggerBreak(); +#ifdef _DEBUG +LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc); +#endif char *GetErrorStr(DWORD error_code); void TraceErrorDD(HRESULT hError, char *pszBuffer, DWORD dwMaxChars); void TraceErrorDS(HRESULT hError, char *pszBuffer, DWORD dwMaxChars); diff --git a/Source/automap.cpp b/Source/automap.cpp index 5682abb0c..7ab898b41 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -510,28 +508,41 @@ void DrawAutomapPlr() WORD GetAutomapType(int x, int y, BOOL view) { - if (view) { - if (x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) - return ~GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8); - if (y == -1) { - if (x < 0) - return 0; - if (x < DMAXX && automapview[x][0]) - return ~GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8); + WORD rv; + + if (view && x == -1 && y >= 0 && y < DMAXY && automapview[0][y]) { + if (GetAutomapType(0, y, FALSE) & (MAPFLAG_SQUARE << 8)) { + return 0; + } else { + return MAPFLAG_SQUARE << 8; } } - if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) { - if (automapview[x][y] || !view) { - WORD type = automaptype[(BYTE)dungeon[x][y]]; - if (type == 7 && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) - && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { - type = 1; - } - return type; + if (view && y == -1 && x >= 0 && x < DMAXY && automapview[x][0]) { + if (GetAutomapType(x, 0, FALSE) & (MAPFLAG_SQUARE << 8)) { + return 0; + } else { + return MAPFLAG_SQUARE << 8; } } - return 0; + + if (x < 0 || x >= DMAXX) { + return 0; + } + if (y < 0 || y >= DMAXX) { + return 0; + } + if (!automapview[x][y] && view) { + return 0; + } + + rv = automaptype[(BYTE)dungeon[x][y]]; + if (rv == 7 + && GetAutomapType(x - 1, y, FALSE) & (MAPFLAG_HORZARCH << 8) + && GetAutomapType(x, y - 1, FALSE) & (MAPFLAG_VERTARCH << 8)) { + rv = 1; + } + return rv; } void DrawAutomapGame() diff --git a/Source/capture.cpp b/Source/capture.cpp index d81abde7b..225a8282f 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/codec.cpp b/Source/codec.cpp index aac99fe25..af530210d 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/control.cpp b/Source/control.cpp index 7d24f64dd..a75980d4a 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -10,8 +8,8 @@ void *pDurIcons; void *pChrButtons; BOOL drawhpflag; // idb BOOL dropGoldFlag; -int panbtn[8]; -BOOL chrbtn[4]; +WORD panbtn[8]; +WORD chrbtn[4]; void *pMultiBtns; void *pPanelButtons; void *pChrPanel; @@ -22,14 +20,14 @@ BOOL drawmanaflag; // idb BOOL chrbtnactive; char sgszTalkMsg[MAX_SEND_STR_LEN]; BYTE *pPanelText; -int frame_4B8800; // idb +int nGoldFrame; BYTE *pLifeBuff; BYTE *pBtmBuff; void *pTalkBtns; int pstrjust[4]; int pnumlines; // idb BOOL pinfoflag; -int talkbtndown[3]; +WORD talkbtndown[3]; int pSpell; // weak BYTE *pManaBuff; char infoclr; // weak @@ -181,7 +179,7 @@ void DrawSpellCel(int xp, int yp, BYTE *Trans, int nCel, int w) dst = &gpBuffer[xp + PitchTbl[yp]]; tbl = SplTransTbl; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, Trans mov eax, nCel @@ -632,7 +630,7 @@ void CPrintString(int nOffset, int nCel, char col) { /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pPanelText mov eax, nCel @@ -944,7 +942,7 @@ void DrawPanelBox(int x, int y, int w, int h, int sx, int sy) nSrcOff = x + 640 * y; nDstOff = sx + 768 * sy; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pBtmBuff add esi, nSrcOff @@ -1020,7 +1018,7 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r) nDstOff = c + 768 * r; w = max - min; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pCelBuff add esi, nSrcOff @@ -1047,7 +1045,7 @@ void SetFlaskHeight(BYTE *pCelBuff, int min, int max, int c, int r) void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int h) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pCelBuff add esi, nSrcOff @@ -1181,64 +1179,58 @@ void UpdateManaFlask() void InitControlPan() { - size_t v0; // esi - void *v1; // ecx - void *v2; // ecx - void *v3; // ecx - unsigned char *v5; // eax - - v0 = 144 * 640; - if (gbMaxPlayers != 1) - v0 = 288 * 640; - pBtmBuff = DiabloAllocPtr(v0); - memset(pBtmBuff, 0, v0); - pManaBuff = DiabloAllocPtr(0x1E40); - memset(pManaBuff, 0, 0x1E40); - pLifeBuff = DiabloAllocPtr(0x1E40); - memset(pLifeBuff, 0, 0x1E40); + int i; + + if (gbMaxPlayers == 1) { + pBtmBuff = DiabloAllocPtr(144 * 640); + memset(pBtmBuff, 0, 144 * 640); + } else { + pBtmBuff = DiabloAllocPtr(288 * 640); + memset(pBtmBuff, 0, 288 * 640); + } + pManaBuff = DiabloAllocPtr(88 * 88); + memset(pManaBuff, 0, 88 * 88); + pLifeBuff = DiabloAllocPtr(88 * 88); + memset(pLifeBuff, 0, 88 * 88); pPanelText = LoadFileInMem("CtrlPan\\SmalText.CEL", 0); pChrPanel = LoadFileInMem("Data\\Char.CEL", 0); pSpellCels = LoadFileInMem("CtrlPan\\SpelIcon.CEL", 0); SetSpellTrans(RSPLTYPE_SKILL); pStatusPanel = LoadFileInMem("CtrlPan\\Panel8.CEL", 0); CelDecodeRect((BYTE *)pBtmBuff, 0, 143, 640, (BYTE *)pStatusPanel, 1, 640); - v1 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v1); + MemFreeDbg(pStatusPanel); pStatusPanel = LoadFileInMem("CtrlPan\\P8Bulbs.CEL", 0); CelDecodeRect((BYTE *)pLifeBuff, 0, 87, 88, (BYTE *)pStatusPanel, 1, 88); CelDecodeRect((BYTE *)pManaBuff, 0, 87, 88, (BYTE *)pStatusPanel, 2, 88); - v2 = pStatusPanel; - pStatusPanel = 0; - mem_free_dbg(v2); + MemFreeDbg(pStatusPanel); talkflag = 0; if (gbMaxPlayers != 1) { pTalkPanel = LoadFileInMem("CtrlPan\\TalkPanl.CEL", 0); CelDecodeRect((BYTE *)pBtmBuff, 0, 287, 640, (BYTE *)pTalkPanel, 1, 640); - v3 = pTalkPanel; - pTalkPanel = 0; - mem_free_dbg(v3); + MemFreeDbg(pTalkPanel); pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", 0); pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", 0); sgbPlrTalkTbl = 0; - *(_DWORD *)byte_4B894C = 0x1010101; - talkbtndown[0] = 0; - talkbtndown[1] = 0; sgszTalkMsg[0] = 0; - talkbtndown[2] = 0; + for (i = 0; i < sizeof(byte_4B894C); i++) + byte_4B894C[i] = 1; + for (i = 0; i < sizeof(talkbtndown); i++) + talkbtndown[i] = 0; } panelflag = 0; lvlbtndown = 0; pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", 0); - memset(panbtn, 0, sizeof(panbtn)); + for (i = 0; i < sizeof(panbtn); i++) + panbtn[i] = 0; panbtndown = 0; - numpanbtns = 2 * (gbMaxPlayers != 1) + 6; + if (gbMaxPlayers == 1) + numpanbtns = 6; + else + numpanbtns = 8; pChrButtons = LoadFileInMem("Data\\CharBut.CEL", 0); - chrbtn[0] = 0; - chrbtn[1] = 0; - chrbtn[2] = 0; + for (i = 0; i < sizeof(chrbtn); i++) + chrbtn[i] = 0; chrbtnactive = FALSE; - chrbtn[3] = 0; pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", 0); strcpy(infostr, ""); ClearPanel(); @@ -1259,23 +1251,13 @@ void InitControlPan() SpellPages[0][0] = SPL_RECHARGE; } pQLogCel = LoadFileInMem("Data\\Quest.CEL", 0); - v5 = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); - frame_4B8800 = 1; + pGBoxBuff = LoadFileInMem("CtrlPan\\Golddrop.cel", 0); dropGoldFlag = FALSE; dropGoldValue = 0; initialDropGoldValue = 0; initialDropGoldIndex = 0; - pGBoxBuff = v5; + nGoldFrame = 1; } -// 4B851C: using guessed type int lvlbtndown; -// 4B8840: using guessed type int sgbPlrTalkTbl; -// 4B8950: using guessed type int sbooktab; -// 4B8960: using guessed type int talkflag; -// 4B8968: using guessed type int sbookflag; -// 4B8A7C: using guessed type int numpanbtns; -// 4B8B84: using guessed type int panelflag; -// 4B8C98: using guessed type int spselflag; -// 679660: using guessed type char gbMaxPlayers; void ClearCtrlPan() { @@ -2314,7 +2296,7 @@ void RedBack() /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM if (leveltype != DTYPE_HELL) { __asm { mov edi, gpBuffer @@ -2585,8 +2567,8 @@ void DrawGoldSplit(int amount) } screen_xa = screen_x + 452; } - CelDecodeOnly(screen_xa, 300, (BYTE *)pCelBuff, frame_4B8800, 12); - frame_4B8800 = (frame_4B8800 & 7) + 1; + CelDecodeOnly(screen_xa, 300, (BYTE *)pCelBuff, nGoldFrame, 12); + nGoldFrame = (nGoldFrame & 7) + 1; } void control_drop_gold(char vkey) diff --git a/Source/control.h b/Source/control.h index 31d8859f2..40fa51e41 100644 --- a/Source/control.h +++ b/Source/control.h @@ -6,8 +6,8 @@ extern void *pDurIcons; extern void *pChrButtons; extern BOOL drawhpflag; // idb extern BOOL dropGoldFlag; -extern int panbtn[8]; -extern BOOL chrbtn[4]; +extern WORD panbtn[8]; +extern WORD chrbtn[4]; extern void *pMultiBtns; extern void *pPanelButtons; extern void *pChrPanel; @@ -16,14 +16,14 @@ extern int dropGoldValue; // idb extern BOOL drawmanaflag; // idb extern BOOL chrbtnactive; extern BYTE *pPanelText; -extern int frame_4B8800; // idb +extern int nGoldFrame; extern BYTE *pLifeBuff; extern BYTE *pBtmBuff; extern void *pTalkBtns; extern int pstrjust[4]; extern int pnumlines; // idb extern BOOL pinfoflag; -extern int talkbtndown[3]; +extern WORD talkbtndown[3]; extern int pSpell; // weak extern BYTE *pManaBuff; extern char infoclr; // weak diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 915575354..d18ffe62a 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -79,12 +77,7 @@ void InitCursor() void FreeCursor() { - void *p; - - p = pCursCels; - pCursCels = NULL; - mem_free_dbg(p); - + MemFreeDbg(pCursCels); ClearCursor(); } diff --git a/Source/dead.cpp b/Source/dead.cpp index a14ac42d9..7bb978e88 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/debug.cpp b/Source/debug.cpp index a8f273504..697fed265 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -17,9 +15,7 @@ void LoadDebugGFX() void FreeDebugGFX() { - void *temp = pSquareCel; - pSquareCel = NULL; - mem_free_dbg(temp); + MemFreeDbg(pSquareCel); } void CheckDungeonClear() diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 787b8a4d1..d4f0e23dc 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/diablo.h b/Source/diablo.h index b6592fba0..10f4fb8c7 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -2,6 +2,82 @@ #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 "items.h" +#include "lighting.h" +#include "loadsave.h" +#include "logging.h" +#include "mainmenu.h" +#include "minitext.h" +#include "missiles.h" +#include "monster.h" +#include "movie.h" +#include "mpqapi.h" +#include "msg.h" +#include "msgcmd.h" +#include "multi.h" +#include "nthread.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 "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]; @@ -97,4 +173,10 @@ extern BOOL FriendlyMode; extern char *spszMsgTbl[4]; // weak extern char *spszMsgKeyTbl[4]; // weak +#ifdef DEVILUTION_STUB +#include "miniwin/popdecl.inc" +#endif + +DEVILUTION_END_NAMESPACE + #endif /* __DIABLO_H__ */ diff --git a/Source/doom.cpp b/Source/doom.cpp index dcac1bd41..5a8aaa664 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -46,9 +44,7 @@ void doom_alloc_cel() void doom_cleanup() { - void *ptr = pDoomCel; - pDoomCel = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pDoomCel); } void doom_load_graphics() diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index acfc9d630..469546d1b 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -212,7 +210,7 @@ void DRLG_L1Pass3() lv = 22 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -255,7 +253,7 @@ void DRLG_L1Pass3() for (i = 0; i < DMAXX; i++) { lv = (unsigned char)dungeon[i][j] - 1; /// ASSERT: assert(lv >= 0); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -429,11 +427,7 @@ void DRLG_LoadL1SP() void DRLG_FreeL1SP() { - void *ptr; - - ptr = pSetPiece; - pSetPiece = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pSetPiece); } void DRLG_L5(int entry) @@ -1033,29 +1027,19 @@ int L5GetArea() void L5makeDungeon() { - signed int v0; // edi - signed int v1; // esi - char *v2; // edx - char v3; // cl - int v4; // eax - int v5; // eax - - v0 = 0; - do { - v1 = 0; - v2 = (char *)dungeon + v0; - do { - v3 = *v2; - v2 += 40; - v4 = 160 * v1++; - v5 = v4 + 2 * v0; - L5dungeon[0][v5] = v3; - L5dungeon[0][v5 + 1] = v3; - L5dungeon[1][v5] = v3; - L5dungeon[1][v5 + 1] = v3; - } while (v1 < 40); - ++v0; - } while (v0 < 40); + int i, j; + int i_2, j_2; + + for (j = 0; j < 40; j++) { + for (i = 0; i < 40; i++) { + j_2 = j << 1; + i_2 = i << 1; + L5dungeon[i_2][j_2] = dungeon[i][j]; + L5dungeon[i_2][j_2 + 1] = dungeon[i][j]; + L5dungeon[i_2 + 1][j_2] = dungeon[i][j]; + L5dungeon[i_2 + 1][j_2 + 1] = dungeon[i][j]; + } + } } void L5makeDmt() diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 2e08fc74e..59f7f18cc 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -238,22 +236,14 @@ int Patterns[100][10] = { void InitDungeon() { - signed int v0; // edx - signed int v1; // eax - signed int v2; // ecx + int i, j; - v0 = 0; - do { - v1 = v0; - v2 = 40; - do { - dflags[0][v1] = 0; - predungeon[0][v1] = 32; - v1 += 40; - --v2; - } while (v2); - ++v0; - } while (v0 < 40); + for(j = 0; j < DMAXY; j++) { + for(i = 0; i < DMAXX; i++) { + predungeon[i][j] = 32; + dflags[i][j] = 0; + } + } } void L2LockoutFix() @@ -460,7 +450,7 @@ void DRLG_L2Pass3() lv = 12 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -502,7 +492,7 @@ void DRLG_L2Pass3() xx = 16; for (i = 0; i < DMAXX; i++) { lv = (unsigned char)dungeon[i][j] - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -633,32 +623,24 @@ void CreateL2Dungeon(unsigned int rseed, int entry) void DRLG_LoadL2SP() { - char *v1; // ecx - setloadflag_2 = 0; - if (QuestStatus(QTYPE_BLIND)) { - v1 = "Levels\\L2Data\\Blind2.DUN"; - } else { - if (QuestStatus(QTYPE_BLOOD)) { - v1 = "Levels\\L2Data\\Blood1.DUN"; - } else { - if (!QuestStatus(QTYPE_BONE)) - return; - v1 = "Levels\\L2Data\\Bonestr2.DUN"; - } + + if(QuestStatus(QTYPE_BLIND)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blind2.DUN", 0); + setloadflag_2 = 1; + } else if(QuestStatus(QTYPE_BLOOD)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Blood1.DUN", 0); + setloadflag_2 = 1; + } else if(QuestStatus(QTYPE_BONE)) { + pSetPiece_2 = (char *)LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", 0); + setloadflag_2 = 1; } - pSetPiece_2 = (char *)LoadFileInMem(v1, 0); - setloadflag_2 = 1; } // 5B50D8: using guessed type int setloadflag_2; void DRLG_FreeL2SP() { - char *ptr; - - ptr = pSetPiece_2; - pSetPiece_2 = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pSetPiece_2); } void DRLG_L2(int entry) @@ -1118,104 +1100,101 @@ void L2TileFix() BOOL CreateDungeon() { - int v0; // esi - int v1; // edx - int v2; // ecx - signed int v3; // esi - char *v4; // eax - signed int v5; // ebx - _BYTE *v6; // ecx - BOOL v7; // zf - BOOL v8; // eax - int v9; // edi - int v10; // esi - signed int v12; // [esp-4h] [ebp-20h] - int nX1; // [esp+8h] [ebp-14h] - int nY1; // [esp+Ch] [ebp-10h] - int nX2; // [esp+10h] [ebp-Ch] - int nY2; // [esp+14h] [ebp-8h] - int nHd; // [esp+18h] [ebp-4h] + int i, j, nHx1, nHy1, nHx2, nHy2, nHd, ForceH, ForceW; + BOOL ForceHW; + + ForceW = 0; + ForceH = 0; + ForceHW = FALSE; + + switch(currlevel) { + case 5: + if(quests[QTYPE_BLOOD]._qactive) { + ForceHW = TRUE; + ForceH = 20; + ForceW = 14; + } + break; + case 6: + if(quests[QTYPE_BONE]._qactive) { + ForceHW = TRUE; + ForceW = 10; + ForceH = 10; + } + break; + case 7: + if(quests[QTYPE_BLIND]._qactive) { + ForceHW = TRUE; + ForceW = 15; + ForceH = 15; + } + break; + case 8: + break; + } - v0 = 0; - v1 = 0; - v2 = 0; - if (currlevel == 5) { - if (!quests[QTYPE_BLOOD]._qactive) - goto LABEL_12; - v1 = 20; - v0 = 14; - } else { - if (currlevel == 6) { - if (!quests[QTYPE_BONE]._qactive) - goto LABEL_12; - v12 = 10; - } else { - if (currlevel != 7 || !quests[QTYPE_BLIND]._qactive) - goto LABEL_12; - v12 = 15; + CreateRoom(2, 2, 39, 39, 0, 0, ForceHW, ForceH, ForceW); + + while(pHallList != NULL) { + GetHall(&nHx1, &nHy1, &nHx2, &nHy2, &nHd); + ConnectHall(nHx1, nHy1, nHx2, nHy2, nHd); + } + + for(j = 0; j <= DMAXY; j++) { /// BUGFIX: change '<=' to '<' + for(i = 0; i <= DMAXX; i++) { /// BUGFIX: change '<=' to '<' + if(predungeon[i][j] == 67) { + predungeon[i][j] = 35; + } + if(predungeon[i][j] == 66) { + predungeon[i][j] = 35; + } + if(predungeon[i][j] == 69) { + predungeon[i][j] = 35; + } + if(predungeon[i][j] == 65) { + predungeon[i][j] = 35; + } + if(predungeon[i][j] == 44) { + predungeon[i][j] = 46; + if(predungeon[i - 1][j - 1] == 32) { + predungeon[i - 1][j - 1] = 35; + } + if(predungeon[i - 1][j] == 32) { + predungeon[i - 1][j] = 35; + } + if(predungeon[i - 1][1 + j] == 32) { + predungeon[i - 1][1 + j] = 35; + } + if(predungeon[i + 1][j - 1] == 32) { + predungeon[i + 1][j - 1] = 35; + } + if(predungeon[i + 1][j] == 32) { + predungeon[i + 1][j] = 35; + } + if(predungeon[i + 1][1 + j] == 32) { + predungeon[i + 1][1 + j] = 35; + } + if(predungeon[i][j - 1] == 32) { + predungeon[i][j - 1] = 35; + } + if(predungeon[i][j + 1] == 32) { + predungeon[i][j + 1] = 35; + } + } } - v0 = v12; - v1 = v12; } - v2 = 1; -LABEL_12: - CreateRoom(2, 2, 39, 39, 0, 0, v2, v1, v0); - while (pHallList) { - GetHall(&nX1, &nY1, &nX2, &nY2, &nHd); - ConnectHall(nX1, nY1, nX2, nY2, nHd); + + if(!DL2_FillVoids()) { + return FALSE; } - v3 = 0; - do { - v4 = (char *)&predungeon[-1][v3]; - v5 = 41; - do { - v6 = (unsigned char *)v4 + 40; - if (v4[40] == 67) - *v6 = 35; - if (*v6 == 66) - *v6 = 35; - if (*v6 == 69) - *v6 = 35; - if (*v6 == 65) - *v6 = 35; - if (*v6 == 44) { - v7 = *(v4 - 1) == 32; - *v6 = 46; - if (v7) - *(v4 - 1) = 35; - if (*v4 == 32) - *v4 = 35; - if (v4[1] == 32) - v4[1] = 35; - if (v4[79] == 32) - v4[79] = 35; - if (v4[80] == 32) - v4[80] = 35; - if (v4[81] == 32) - v4[81] = 35; - if (v4[39] == 32) - v4[39] = 35; - if (v4[41] == 32) - v4[41] = 35; - } - --v5; - v4 += 40; - } while (v5); - ++v3; - } while (v3 <= 40); - v8 = DL2_FillVoids(); - if (v8) { - v9 = 0; - do { - v10 = 0; - do - DoPatternCheck(v10++, v9); - while (v10 < 40); - ++v9; - } while (v9 < 40); - v8 = 1; + + for(j = 0; j < DMAXY; j++) { + for(i = 0; i < DMAXX; i++) { + DoPatternCheck(i, j); + } } - return v8; + + return TRUE; } void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW) @@ -1418,111 +1397,74 @@ void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int F // 5276CC: using guessed type int nSx2; // 5276D4: using guessed type int nSy2; -void DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW) +void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW) { - int v5; // esi - int v6; // edi - int v7; // eax - int i; // eax - BOOLEAN v9; // zf - int v10; // ecx - char *v11; // eax - char *v12; // ebx - int v13; // eax - int v14; // [esp+10h] [ebp-4h] - int v15; // [esp+10h] [ebp-4h] - int nY2a; // [esp+20h] [ebp+Ch] - char *ForceHWa; // [esp+24h] [ebp+10h] - - v5 = nX1; - v6 = nX2; - predungeon[v5][nY1] = 67; - predungeon[v5][nY2] = 69; - predungeon[v6][nY1] = 66; - predungeon[v6][nY2] = 65; - v7 = nRoomCnt + 1; - nRoomCnt = v7; - v7 *= 20; - *(int *)((char *)&RoomList[0].nRoomx1 + v7) = nX1; - *(int *)((char *)&RoomList[0].nRoomx2 + v7) = nX2; - *(int *)((char *)&RoomList[0].nRoomy1 + v7) = nY1; - *(int *)((char *)&RoomList[0].nRoomy2 + v7) = nY2; - if (ForceHW == 1) { - for (i = nX1; i < nX2; ++i) { - if (i < nY2) { - ForceHWa = &dflags[i][nY1]; - v14 = nY2 - i; - i = nY2; - do { - *ForceHWa |= DFLAG_EXPLORED; - v9 = v14-- == 1; - ForceHWa += 40; - } while (!v9); + int i, j; + + predungeon[nX1][nY1] = 67; + predungeon[nX1][nY2] = 69; + predungeon[nX2][nY1] = 66; + predungeon[nX2][nY2] = 65; + + nRoomCnt++; + RoomList[nRoomCnt].nRoomx1 = nX1; + RoomList[nRoomCnt].nRoomx2 = nX2; + RoomList[nRoomCnt].nRoomy1 = nY1; + RoomList[nRoomCnt].nRoomy2 = nY2; + + if(ForceHW == TRUE) { + for(i = nX1; i < nX2; i++) { + while(i < nY2) { + dflags[i][nY1] |= 0x80; + i++; } } } - v10 = nX1 + 1; - if (v10 <= nX2 - 1) { - v15 = nX2 - v10; - v11 = (char *)&predungeon[v10][nY2]; - do { - v11[nY1 - nY2] = 35; - *v11 = 35; - v11 += 40; - --v15; - } while (v15); + for(i = nX1 + 1; i <= nX2 - 1; i++) { + predungeon[i][nY1] = 35; + predungeon[i][nY2] = 35; } - nY2a = nY2 - 1; - while (++nY1 <= nY2a) { - predungeon[v5][nY1] = 35; - predungeon[v6][nY1] = 35; - if (v10 < nX2) { - v12 = (char *)&predungeon[v10][nY1]; - v13 = nX2 - v10; - do { - *v12 = 46; - v12 += 40; - --v13; - } while (v13); + nY2--; + for(j = nY1 + 1; j <= nY2; j++) { + predungeon[nX1][j] = 35; + predungeon[nX2][j] = 35; + for(i = nX1 + 1; i < nX2; i++) { + predungeon[i][j] = 46; } } } void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) { - int v5; // edi - int v6; // esi - HALLNODE *v7; // eax - HALLNODE *i; // ecx - - v5 = nX1; - v6 = nY1; - if (pHallList) { - v7 = (HALLNODE *)DiabloAllocPtr(24); - v7->pNext = 0; - v7->nHallx2 = nX2; - v7->nHally2 = nY2; - v7->nHallx1 = v5; - v7->nHally1 = v6; - v7->nHalldir = nHd; - for (i = pHallList; i->pNext; i = i->pNext) - ; - i->pNext = v7; - } else { - pHallList = (HALLNODE *)DiabloAllocPtr(24); - pHallList->nHallx1 = v5; - pHallList->nHally1 = v6; + HALLNODE *p1, *p2; + + if(pHallList == NULL) { + pHallList = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList)); + pHallList->nHallx1 = nX1; + pHallList->nHally1 = nY1; pHallList->nHallx2 = nX2; pHallList->nHally2 = nY2; pHallList->nHalldir = nHd; - pHallList->pNext = 0; + pHallList->pNext = NULL; + } else { + p1 = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList)); + p1->nHallx1 = nX1; + p1->nHally1 = nY1; + p1->nHallx2 = nX2; + p1->nHally2 = nY2; + p1->nHalldir = nHd; + p1->pNext = NULL; + p2 = pHallList; + while(p2->pNext != NULL) { + p2 = p2->pNext; + } + p2->pNext = p1; } } void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd) { HALLNODE *p1; - HALLNODE *p2; p1 = pHallList->pNext; *nX1 = pHallList->nHallx1; @@ -1530,11 +1472,7 @@ void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd) *nX2 = pHallList->nHallx2; *nY2 = pHallList->nHally2; *nHd = pHallList->nHalldir; - - p2 = pHallList; - pHallList = NULL; - mem_free_dbg(p2); - + MemFreeDbg(pHallList); pHallList = p1; } diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index 3f34d1eb9..5e1624f4a 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -29,7 +29,7 @@ void DRLG_L2SetRoom(int rx1, int ry1); void L2TileFix(); BOOL CreateDungeon(); void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, int ForceHW, int nH, int nW); -void DefineRoom(int nX1, int nY1, int nX2, int nY2, int ForceHW); +void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW); void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd); void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd); void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd); diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index bbf891934..f6f6dda44 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -1821,7 +1819,7 @@ void DRLG_L3Pass3() lv = 8 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -1863,7 +1861,7 @@ void DRLG_L3Pass3() xx = 16; for (i = 0; i < DMAXX; i++) { lv = (unsigned char)dungeon[i][j] - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM if (lv >= 0) { __asm { mov esi, pMegaTiles diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index ea1c75428..7dbbc1a0a 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -308,11 +306,7 @@ void DRLG_LoadL4SP() void DRLG_FreeL4SP() { - char *ptr; - - ptr = pSetPiece_2; - pSetPiece_2 = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pSetPiece_2); } void DRLG_L4SetSPRoom(int rx1, int ry1) @@ -541,195 +535,154 @@ void CreateL4Dungeon(unsigned int rseed, int entry) void DRLG_L4(int entry) { - signed int v1; // ebp - //int v2; // eax - int v3; // edx - char *v4; // edi - char v5; // bp - unsigned int v6; // ecx - char *v7; // edi - int v8; // ecx - //int v9; // eax - int v10; // eax - unsigned char *v11; // ecx - unsigned char *v12; // ecx - //int v13; // eax - signed int v14; // eax - signed int v15; // ecx - int v16; // ebx - int v17; // edi - char *v18; // ebp - signed int v19; // ecx - signed int v20; // eax - signed int v21; // esi - int v22; // [esp-8h] [ebp-20h] - int v23; // [esp+10h] [ebp-8h] - int v24; // [esp+14h] [ebp-4h] - - v1 = 0; - v23 = entry; + int i, j, spi, spj; + BOOL doneflag; + do { DRLG_InitTrans(); do { InitL4Dungeon(); L4firstRoom(); L4FixRim(); - } while (GetArea() < 173); + } while(GetArea() < 173); uShape(); L4makeDungeon(); L4makeDmt(); L4tileFix(); - if (currlevel == 16) + if(currlevel == 16) { L4SaveQuads(); - //_LOBYTE(v2) = QuestStatus(QTYPE_WARLRD); - if ((QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) && SP4x1 < SP4x2) { - v3 = SP4x1; - v24 = SP4x2 - SP4x1; - do { - if (SP4y1 < SP4y2) { - v4 = &dflags[v3][SP4y1]; - v5 = SP4y2 - SP4y1; - v6 = (unsigned int)(SP4y2 - SP4y1) >> 2; - memset(v4, 1u, 4 * v6); - v7 = &v4[4 * v6]; - v8 = v5 & 3; - v1 = 0; - memset(v7, 1, v8); + } + if(QuestStatus(QTYPE_WARLRD) || currlevel == quests[QTYPE_VB]._qlevel && gbMaxPlayers != 1) { + for(spi = SP4x1; spi < SP4x2; spi++) { + for(spj = SP4y1; spj < SP4y2; spj++) { + dflags[spi][spj] = 1; } - ++v3; - --v24; - } while (v24); + } } L4AddWall(); DRLG_L4FloodTVal(); DRLG_L4TransFix(); - if (setloadflag_2) + if(setloadflag_2) { DRLG_L4SetSPRoom(SP4x1, SP4y1); - if (currlevel == 16) - DRLG_LoadDiabQuads(1); - //_LOBYTE(v9) = QuestStatus(QTYPE_WARLRD); - if (!QuestStatus(QTYPE_WARLRD)) { - if (currlevel == 15) { - if (!v23) { - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); - if (v10) { - if (gbMaxPlayers != 1 || (v11 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2)) - v11 = (unsigned char *)L4PENTA2; - v10 = DRLG_L4PlaceMiniSet(v11, 1, 1, -1, -1, 0, 1); - } - goto LABEL_35; + } + if(currlevel == 16) { + DRLG_LoadDiabQuads(TRUE); + } + if(QuestStatus(QTYPE_WARLRD)) { + if(entry == 0) { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); } - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if (v10) { - if (gbMaxPlayers != 1 || (v12 = (unsigned char *)L4PENTA, quests[QTYPE_MOD]._qactive == 2)) - v12 = (unsigned char *)L4PENTA2; - v10 = DRLG_L4PlaceMiniSet(v12, 1, 1, -1, -1, 1, 1); + ViewX++; + } else if(entry == 1) { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); } + ViewX = 2 * setpc_x + 22; + ViewY = 2 * setpc_y + 22; } else { - if (!v23) { - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); - if (v10) { - if (currlevel != 16) - v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); - goto LABEL_31; - } - LABEL_35: - ++ViewX; - continue; + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 1, 6); } - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if (v23 != 1) { - if (v10) { - if (currlevel != 16) - v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); - LABEL_46: - if (v10) { - if (currlevel == 13) { - v22 = 1; - LABEL_34: - v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, v22, 6); - goto LABEL_35; - } - } + ViewX++; + } + } else if(currlevel != 15) { + if(entry == 0) { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); + if(doneflag && currlevel != 16) { + doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); + } + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); + } + ViewX++; + } else if(entry == 1) { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); + if(doneflag && currlevel != 16) { + doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1); + } + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); + } + ViewY++; + } else { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); + if(doneflag && currlevel != 16) { + doneflag = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 0, 1); + } + if(doneflag && currlevel == 13) { + doneflag = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 1, 6); + } + ViewX++; + } + } else { + if(entry == 0) { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); + if(doneflag) { + if(gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 0, 1); + } else { + doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 0, 1); } - goto LABEL_35; } - if (v10) { - if (currlevel != 16) - v10 = DRLG_L4PlaceMiniSet(L4DSTAIRS, 1, 1, -1, -1, 1, 1); - if (v10 && currlevel == 13) - v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); + ViewX++; + } else { + doneflag = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); + if(doneflag) { + if(gbMaxPlayers == 1 && quests[QTYPE_MOD]._qactive != 2) { + doneflag = DRLG_L4PlaceMiniSet(L4PENTA, 1, 1, -1, -1, 1, 1); + } else { + doneflag = DRLG_L4PlaceMiniSet(L4PENTA2, 1, 1, -1, -1, 1, 1); + } } + ViewY++; } - ++ViewY; - continue; } - if (!v23) { - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 1, 0); - LABEL_31: - if (!v10 || currlevel != 13) - goto LABEL_35; - v22 = 0; - goto LABEL_34; - } - v10 = DRLG_L4PlaceMiniSet(L4USTAIRS, 1, 1, -1, -1, 0, 0); - if (v23 != 1) - goto LABEL_46; - if (v10 && currlevel == 13) - v10 = DRLG_L4PlaceMiniSet(L4TWARP, 1, 1, -1, -1, 0, 6); - ViewX = 2 * setpc_x + 22; - ViewY = 2 * setpc_y + 22; - } while (!v10); + } while(!doneflag); + DRLG_L4GeneralFix(); - if (currlevel != 16) + + if(currlevel != 16) { DRLG_PlaceThemeRooms(7, 10, 6, 8, 1); + } + DRLG_L4Shadows(); DRLG_L4Corners(); DRLG_L4Subs(); DRLG_Init_Globals(); - //_LOBYTE(v13) = QuestStatus(QTYPE_WARLRD); - if (QuestStatus(QTYPE_WARLRD)) { - do { - v14 = v1; - v15 = 40; - do { - pdungeon[0][v14] = dungeon[0][v14]; - v14 += 40; - --v15; - } while (v15); - ++v1; - } while (v1 < 40); + + if(QuestStatus(QTYPE_WARLRD)) { + for(j = 0; j < DMAXY; j++) { + for(i = 0; i < DMAXX; i++) { + pdungeon[i][j] = dungeon[i][j]; + } + } } + DRLG_CheckQuests(SP4x1, SP4y1); - if (currlevel == 15) { - v16 = -1; - do { - v17 = -1; - v18 = (char *)&dungeon[0][v16 + 1]; - do { - if (*v18 == 98) - Make_SetPC(v17, v16, 5, 5); - if (*v18 == 107) - Make_SetPC(v17, v16, 5, 5); - v18 += 40; - ++v17; - } while (v17 + 1 < 40); - ++v16; - } while (v16 < 39); - } - if (currlevel == 16) { - v19 = 0; - do { - v20 = v19; - v21 = 40; - do { - pdungeon[0][v20] = dungeon[0][v20]; - v20 += 40; - --v21; - } while (v21); - ++v19; - } while (v19 < 40); - DRLG_LoadDiabQuads(0); + + if(currlevel == 15) { + for(j = 0; j < DMAXY; j++) { + for(i = 0; i < DMAXX; i++) { + if(dungeon[i][j] == 98) { + Make_SetPC(i - 1, j - 1, 5, 5); + } + if(dungeon[i][j] == 107) { + Make_SetPC(i - 1, j - 1, 5, 5); + } + } + } + } + if(currlevel == 16) { + for(j = 0; j < DMAXY; j++) { + for(i = 0; i < DMAXX; i++) { + pdungeon[i][j] = dungeon[i][j]; + } + } + DRLG_LoadDiabQuads(FALSE); } } // 528A40: using guessed type int SP4x2; @@ -1484,104 +1437,48 @@ void DRLG_L4Subs() void L4makeDungeon() { - signed int v0; // ebx - signed int v1; // esi - char *v2; // edx - char v3; // cl - int v4; // eax - int v5; // eax - int v6; // ebx - char *v7; // esi - signed int v8; // edx - char v9; // cl - int v10; // eax - int v11; // eax - signed int v12; // ebx - signed int v13; // esi - char *v14; // edx - char v15; // cl - int v16; // eax - int v17; // eax - int v18; // ebx - char *v19; // esi - signed int v20; // edx - char v21; // cl - int v22; // eax - int v23; // eax - signed int v24; // [esp+Ch] [ebp-8h] - char *v25; // [esp+10h] [ebp-4h] - char *v26; // [esp+10h] [ebp-4h] - - v0 = 0; - do { - v1 = 0; - v2 = (char *)dung + v0; - do { - v3 = *v2; - v2 += 20; - v4 = 160 * v1++; - v5 = v4 + 2 * v0; - L4dungeon[0][v5] = v3; - L4dungeon[0][v5 + 1] = v3; - L4dungeon[1][v5] = v3; - L4dungeon[1][v5 + 1] = v3; - } while (v1 < 20); - ++v0; - } while (v0 < 20); - v6 = 0; - v25 = (char *)&dung[0][19]; - v24 = 20; - do { - v7 = v25; - v8 = 0; - do { - v9 = *v7; - v7 += 20; - v10 = 160 * v8++; - v11 = v10 + 2 * v6; - L4dungeon[0][v11 + 40] = v9; - L4dungeon[0][v11 + 41] = v9; - L4dungeon[1][v11 + 40] = v9; - L4dungeon[1][v11 + 41] = v9; - } while (v8 < 20); - ++v6; - --v25; - --v24; - } while (v24); - v12 = 0; - do { - v13 = 0; - v14 = (char *)&dung[19][v12]; - do { - v15 = *v14; - v14 -= 20; - v16 = 160 * v13++; - v17 = v16 + 2 * v12; - L4dungeon[40][v17] = v15; - L4dungeon[40][v17 + 1] = v15; - L4dungeon[41][v17] = v15; - L4dungeon[41][v17 + 1] = v15; - } while (v13 < 20); - ++v12; - } while (v12 < 20); - v18 = 0; - v26 = (char *)&dung[19][19]; - do { - v19 = v26; - v20 = 0; - do { - v21 = *v19; - v19 -= 20; - v22 = 160 * v20++; - v23 = v22 + 2 * v18; - L4dungeon[40][v23 + 40] = v21; - L4dungeon[40][v23 + 41] = v21; - L4dungeon[41][v23 + 40] = v21; - L4dungeon[41][v23 + 41] = v21; - } while (v20 < 20); - ++v18; - --v26; - } while ((signed int)v26 > (signed int)&dung[18][19]); + int i, j, k, l; + + for(j = 0; j < 20; j++) { + for(i = 0; i < 20; i++) { + k = i << 1; + l = j << 1; + L4dungeon[k][l] = dung[i][j]; + L4dungeon[k][l + 1] = dung[i][j]; + L4dungeon[k + 1][l] = dung[i][j]; + L4dungeon[k + 1][l + 1] = dung[i][j]; + } + } + for(j = 0; j < 20; j++) { + for(i = 0; i < 20; i++) { + k = i << 1; + l = j << 1; + L4dungeon[k][l + 40] = dung[i][19 - j]; + L4dungeon[k][l + 41] = dung[i][19 - j]; + L4dungeon[k + 1][l + 40] = dung[i][19 - j]; + L4dungeon[k + 1][l + 41] = dung[i][19 - j]; + } + } + for(j = 0; j < 20; j++) { + for(i = 0; i < 20; i++) { + k = i << 1; + l = j << 1; + L4dungeon[k + 40][l] = dung[19 - i][j]; + L4dungeon[k + 40][l + 1] = dung[19 - i][j]; + L4dungeon[k + 41][l] = dung[19 - i][j]; + L4dungeon[k + 41][l + 1] = dung[19 - i][j]; + } + } + for(j = 0; j < 20; j++) { + for(i = 0; i < 20; i++) { + k = i << 1; + l = j << 1; + L4dungeon[k + 40][l + 40] = dung[19 - i][19 - j]; + L4dungeon[k + 40][l + 41] = dung[19 - i][19 - j]; + L4dungeon[k + 41][l + 40] = dung[19 - i][19 - j]; + L4dungeon[k + 41][l + 41] = dung[19 - i][19 - j]; + } + } } void uShape() @@ -2070,7 +1967,7 @@ void DRLG_L4Pass3() lv = 30 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -2112,7 +2009,7 @@ void DRLG_L4Pass3() xx = 16; for (i = 0; i < DMAXX; i++) { lv = (unsigned char)dungeon[i][j] - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM if (lv >= 0) { __asm { mov esi, pMegaTiles diff --git a/Source/dthread.cpp b/Source/dthread.cpp index a60e40d40..5a22563cb 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -130,7 +129,7 @@ unsigned int __stdcall dthread_handler(void *unused) void dthread_cleanup() { char *error_buf; - TMegaPkt *tmp1, *tmp2; + TMegaPkt *tmp; if (sghWorkToDoEvent == NULL) { return; @@ -150,11 +149,9 @@ void dthread_cleanup() sghWorkToDoEvent = NULL; while (sgpInfoHead) { - tmp1 = sgpInfoHead->pNext; - tmp2 = sgpInfoHead; - sgpInfoHead = NULL; - mem_free_dbg(tmp2); - sgpInfoHead = tmp1; + tmp = sgpInfoHead->pNext; + MemFreeDbg(sgpInfoHead); + sgpInfoHead = tmp; } } diff --git a/Source/dx.cpp b/Source/dx.cpp index cb3afe5e2..a3fe6f35d 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -23,26 +22,26 @@ HMODULE ghDiabMod; // idb void dx_init(HWND hWnd) { - HWND v1; // esi - GUID *v2; // ecx - int v3; // eax - int v4; // eax - //int v5; // ecx - int v6; // edi - int v7; // eax - int v8; // eax - HWND hWnda; // [esp+1Ch] [ebp-4h] - - v1 = hWnd; - hWnda = hWnd; + HRESULT hDDVal; + int winw, winh; + BOOL bSuccess; + GUID *lpGUID; + + /// ASSERT: assert(! gpBuffer); + /// ASSERT: assert(! sgdwLockCount); + /// ASSERT: assert(! sgpBackBuf); + SetFocus(hWnd); - ShowWindow(v1, SW_SHOWNORMAL); - v2 = NULL; - if (gbEmulate) - v2 = (GUID *)DDCREATE_EMULATIONONLY; - v3 = dx_DirectDrawCreate(v2, &lpDDInterface, NULL); - if (v3) - ErrDlg(IDD_DIALOG1, v3, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); + ShowWindow(hWnd, SW_SHOWNORMAL); + + lpGUID = (GUID *)DDCREATE_EMULATIONONLY; + if(!gbEmulate) { + lpGUID = NULL; + } + hDDVal = dx_DirectDrawCreate(lpGUID, &lpDDInterface, NULL); + if(hDDVal != DD_OK) { + ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 149); + } #ifdef COLORFIX #ifdef __DDRAWI_INCLUDED__ @@ -52,37 +51,57 @@ void dx_init(HWND hWnd) #endif #endif - fullscreen = 1; +#ifndef _DEBUG + fullscreen = TRUE; +#endif + if(!fullscreen) { #ifdef __cplusplus - v4 = lpDDInterface->SetCooperativeLevel(v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); + hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #else - v4 = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, v1, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); + hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #endif - if (v4 == DDERR_EXCLUSIVEMODEALREADYSET) { - MI_Dummy(0); // v5 - } else if (v4) { - ErrDlg(IDD_DIALOG1, v4, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); - } + if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { + TriggerBreak(); + } else if(hDDVal != DD_OK) { + ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Diablo\\Direct\\dx.cpp", 155); + } + SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); + } else { #ifdef __cplusplus - if (lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8)) { + hDDVal = lpDDInterface->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); #else - if (lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, 8)) { + hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); #endif - v6 = GetSystemMetrics(SM_CXSCREEN); - v7 = GetSystemMetrics(SM_CYSCREEN); + if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { + TriggerBreak(); + } else if(hDDVal != DD_OK) { + ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); + } #ifdef __cplusplus - v8 = lpDDInterface->SetDisplayMode(v6, v7, 8); + hDDVal = lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); #else - v8 = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, v6, v7, 8); + hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); #endif - if (v8) - ErrDlg(IDD_DIALOG1, v8, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); + if(hDDVal != DD_OK) { + winw = GetSystemMetrics(SM_CXSCREEN); + winh = GetSystemMetrics(SM_CYSCREEN); +#ifdef __cplusplus + hDDVal = lpDDInterface->SetDisplayMode(winw, winh, SCREEN_BPP); +#else + hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, SCREEN_BPP); +#endif + if(hDDVal != DD_OK) { + ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 183); + } + } } + dx_create_primary_surface(); palette_init(); GdiSetBatchLimit(1); dx_create_back_buffer(); - SDrawManualInitialize(hWnda, lpDDInterface, lpDDSPrimary, 0, 0, lpDDSBackBuf, lpDDPalette, 0); + bSuccess = SDrawManualInitialize(hWnd, lpDDInterface, lpDDSPrimary, NULL, NULL, lpDDSBackBuf, lpDDPalette, NULL); + /// ASSERT: assert(bSuccess); } // 52A549: using guessed type char gbEmulate; diff --git a/Source/effects.cpp b/Source/effects.cpp index 6c4e201a5..eba0a101a 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index 05bdbbdea..bc4d0b76d 100644 --- a/Source/encrypt.cpp +++ b/Source/encrypt.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/PKWare/pkware.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/engine.cpp b/Source/engine.cpp index 247497381..7197dc238 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,10 +1,9 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM #pragma warning(disable : 4731) // frame pointer register 'ebp' modified by inline assembly code #endif @@ -33,7 +32,7 @@ void CelDrawDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) if (!pRLEBytes) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pRLEBytes mov edi, pDecodeTo @@ -251,7 +250,7 @@ void CelDecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWi if (!pRLEBytes) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov eax, light_table_index shl eax, 8 @@ -406,7 +405,7 @@ void CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW if (!pRLEBytes) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov eax, light_table_index shl eax, 8 @@ -742,7 +741,7 @@ void CelDrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in tbl = &pLightTbl[idx]; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, src mov edi, dst @@ -827,7 +826,7 @@ void Cel2DecDatOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) if (!gpBuffer) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pRLEBytes mov edi, pDecodeTo @@ -1019,7 +1018,7 @@ void Cel2DecDatLightOnly(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW if (!gpBuffer) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov eax, light_table_index shl eax, 8 @@ -1190,7 +1189,7 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n if (!gpBuffer) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov eax, light_table_index shl eax, 8 @@ -1506,7 +1505,7 @@ void Cel2DrawHdrLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i tbl = &pLightTbl[idx]; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM w = 768 + nWidth; __asm { @@ -1599,7 +1598,7 @@ void CelDecodeRect(BYTE *pBuff, int CelSkip, int hgt, int wdt, BYTE *pCelBuff, i if (!pBuff) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pCelBuff mov eax, nCel @@ -1720,7 +1719,7 @@ void CelDecodeClr(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth if (!gpBuffer) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pCelBuff mov eax, nCel @@ -1861,7 +1860,7 @@ void CelDrawHdrClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWi if (!gpBuffer) return; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pCelBuff mov eax, nCel @@ -2040,7 +2039,7 @@ void ENG_set_pixel(int sx, int sy, BYTE col) dst = &gpBuffer[sx + PitchTbl[sy]]; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, dst cmp edi, gpBufEnd @@ -2072,7 +2071,7 @@ void engine_draw_pixel(int sx, int sy) dst = &gpBuffer[sx + PitchTbl[sy]]; } -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, dst cmp edi, gpBufEnd @@ -2395,6 +2394,21 @@ int random(BYTE idx, int v) return (GetRndSeed() >> 16) % v; } +void engine_debug_trap(BOOL show_cursor) +{ +/* + TMemBlock *pCurr; + + sgMemCrit.Enter(); + while(sgpMemBlock != NULL) { + pCurr = sgpMemBlock->pNext; + SMemFree(sgpMemBlock, "C:\\Diablo\\Direct\\ENGINE.CPP", 1970); + sgpMemBlock = pCurr; + } + sgMemCrit.Leave(); +*/ +} + unsigned char *DiabloAllocPtr(int dwBytes) { BYTE *buf; @@ -2552,7 +2566,7 @@ void Cl2DecodeFrm1(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel void Cl2DecDatFrm1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi @@ -2736,7 +2750,7 @@ void Cl2DecodeFrm2(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidt void Cl2DecDatFrm2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi @@ -2948,7 +2962,7 @@ void Cl2DecodeFrm3(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel void Cl2DecDatLightTbl1(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi @@ -3185,7 +3199,7 @@ void Cl2DecodeFrm4(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel void Cl2DecDatFrm4(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi @@ -3386,7 +3400,7 @@ void Cl2DecodeClrHL(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid void Cl2DecDatClrHL(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, char col) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi @@ -3610,7 +3624,7 @@ void Cl2DecodeFrm5(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Cel void Cl2DecDatLightTbl2(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE *pTable) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { push ebx push esi diff --git a/Source/engine.h b/Source/engine.h index ba1095ef1..6faab8baa 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -40,6 +40,7 @@ int GetDirection(int x1, int y1, int x2, int y2); void SetRndSeed(int s); int GetRndSeed(); int random(BYTE idx, int v); +void engine_debug_trap(BOOL show_cursor); unsigned char *DiabloAllocPtr(int dwBytes); void mem_free_dbg(void *p); BYTE *LoadFileInMem(char *pszName, int *pdwFileLen); diff --git a/Source/error.cpp b/Source/error.cpp index b81894aa4..e47832d27 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/fault.cpp b/Source/fault.cpp index f42e8834e..24749f417 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 2d5e70c84..4886ae38e 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 54382cf81..04928eceb 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -132,7 +130,7 @@ void MakeSpeedCels() BOOL blood_flag; WORD *pMap; DWORD *pFrameTable; -#if (_MSC_VER < 800) || (_MSC_VER > 1200) +#ifndef USE_ASM int k, l; BYTE width, pix; BYTE *src, *dst, *tbl; @@ -165,7 +163,7 @@ void MakeSpeedCels() nlevel_frames = pFrameTable[0] & 0xFFFF; for (i = 1; i < nlevel_frames; i++) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pDungeonCels mov eax, i @@ -190,7 +188,7 @@ void MakeSpeedCels() blood_flag = TRUE; if (level_frame_count[i]) { if (level_frame_types[i] != 0x1000) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM j = level_frame_sizes[i]; __asm { mov ebx, pDungeonCels @@ -223,7 +221,7 @@ void MakeSpeedCels() } #endif } else { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pDungeonCels mov eax, i @@ -324,7 +322,7 @@ void MakeSpeedCels() lfs_adder = level_frame_sizes[i]; for (j = 1; j < blk_cnt; j++) { SpeedFrameTbl[i][j] = frameidx; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pDungeonCels mov eax, currtile @@ -360,7 +358,7 @@ void MakeSpeedCels() } else { for (j = 1; j < blk_cnt; j++) { SpeedFrameTbl[i][j] = frameidx; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pDungeonCels mov eax, currtile diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 29873ee7f..06db02ac3 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -74,23 +72,11 @@ void gmenu_print_text(int x, int y, char *pszStr) void FreeGMenu() { - void *ptr; - - ptr = sgpLogo; - sgpLogo = NULL; - mem_free_dbg(ptr); - ptr = BigTGold_cel; - BigTGold_cel = NULL; - mem_free_dbg(ptr); - ptr = PentSpin_cel; - PentSpin_cel = NULL; - mem_free_dbg(ptr); - ptr = option_cel; - option_cel = NULL; - mem_free_dbg(ptr); - ptr = optbar_cel; - optbar_cel = NULL; - mem_free_dbg(ptr); + MemFreeDbg(sgpLogo); + MemFreeDbg(BigTGold_cel); + MemFreeDbg(PentSpin_cel); + MemFreeDbg(option_cel); + MemFreeDbg(optbar_cel); } void gmenu_init_menu() diff --git a/Source/help.cpp b/Source/help.cpp index 647f9cae3..3b8f9d3d7 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/init.cpp b/Source/init.cpp index f747e8cbc..897277b96 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE @@ -45,7 +45,7 @@ void init_cleanup(BOOL show_cursor) sound_cleanup(); NetClose(); dx_cleanup(); - MI_Dummy(show_cursor); + engine_debug_trap(show_cursor); StormDestroy(); if (show_cursor) diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 6523c8f6c..2489bd2f3 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -246,11 +245,7 @@ void ShowProgress(unsigned int uMsg) void FreeInterface() { - void *ptr; - - ptr = sgpBackCel; - sgpBackCel = NULL; - mem_free_dbg(ptr); + MemFreeDbg(sgpBackCel); } void InitCutscene(unsigned int uMsg) diff --git a/Source/inv.cpp b/Source/inv.cpp index a60932370..3039f1126 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -94,10 +92,7 @@ int AP2x2Tbl[10] = { 8, 28, 6, 26, 4, 24, 2, 22, 0, 20 }; // weak void FreeInvGFX() { - void *invCels = pInvCels; - - pInvCels = NULL; - mem_free_dbg(invCels); + MemFreeDbg(pInvCels); } void InitInv() @@ -122,7 +117,7 @@ void InvDrawSlotBack(int X, int Y, int W, int H) dst = &gpBuffer[X + PitchTbl[Y]]; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, dst xor edx, edx diff --git a/Source/items.cpp b/Source/items.cpp index 19408108a..69378967d 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -1371,7 +1369,7 @@ void CreatePlrItems(int p) GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]); #ifdef _DEBUG - if(!debug_mode_key_w) { + if (!debug_mode_key_w) { #endif SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB); GetPlrHandSeed(&plr[p].HoldItem); @@ -1412,7 +1410,7 @@ void CreatePlrItems(int p) GetPlrHandSeed(&plr[p].HoldItem); #ifdef _DEBUG - if(!debug_mode_key_w) { + if (!debug_mode_key_w) { #endif plr[p].HoldItem._ivalue = 100; plr[p].HoldItem._iCurs = ICURS_GOLD_SMALL; @@ -1424,7 +1422,7 @@ void CreatePlrItems(int p) plr[p].HoldItem._ivalue = 5000; plr[p].HoldItem._iCurs = ICURS_GOLD_LARGE; plr[p]._pGold = plr[p].HoldItem._ivalue * 40; - for(i = 0; i < 40; i++) { + for (i = 0; i < 40; i++) { GetPlrHandSeed(&plr[p].HoldItem); plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem; plr[p].InvGrid[i] = plr[p]._pNumInv; @@ -1569,24 +1567,20 @@ void GetSuperItemLoc(int x, int y, int *xx, int *yy) void CalcItemValue(int i) { - int v1; // ecx - int v2; // esi - BOOLEAN v3; // sf - int v4; // esi - - v1 = i; - v2 = item[v1]._iVMult1 + item[v1]._iVMult2; - v3 = v2 < 0; - if (v2 > 0) { - v2 *= item[v1]._ivalue; - v3 = v2 < 0; - } - if (v3) - v2 = item[v1]._ivalue / v2; - v4 = item[v1]._iVAdd1 + item[v1]._iVAdd2 + v2; - if (v4 <= 0) - v4 = 1; - item[v1]._iIvalue = v4; + int v; + + v = item[i]._iVMult1 + item[i]._iVMult2; + if (v > 0) { + v *= item[i]._ivalue; + } + if (v < 0) { + v = item[i]._ivalue / v; + } + v = item[i]._iVAdd1 + item[i]._iVAdd2 + v; + if (v <= 0) { + v = 1; + } + item[i]._iIvalue = v; } void GetBookSpell(int i, int lvl) @@ -3128,13 +3122,10 @@ void ProcessItems() void FreeItemGFX() { - int i; // esi - void *v1; // ecx + int i; for (i = 0; i < 35; i++) { - v1 = (void *)itemanims[i]; - itemanims[i] = 0; - mem_free_dbg(v1); + MemFreeDbg(itemanims[i]); } } @@ -3651,7 +3642,7 @@ void DrawULine(int y) { /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM int yy; yy = PitchTbl[SStringY[y] + 198] + 26 + 64; @@ -4737,11 +4728,11 @@ BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex) dwTicks = GetTickCount(); - for(i = 0; i < gnNumGetRecords; i++) { - if(dwTicks - itemrecord[i].dwTimestamp > 6000) { + for (i = 0; i < gnNumGetRecords; i++) { + if (dwTicks - itemrecord[i].dwTimestamp > 6000) { NextItemRecord(i); i--; - } else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) { + } else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) { return FALSE; } } @@ -4753,7 +4744,7 @@ void NextItemRecord(int i) { gnNumGetRecords--; - if(gnNumGetRecords == 0) { + if (gnNumGetRecords == 0) { return; } @@ -4769,7 +4760,7 @@ void SetItemRecord(int nSeed, WORD wCI, int nIndex) dwTicks = GetTickCount(); - if(gnNumGetRecords == MAXITEMS) { + if (gnNumGetRecords == MAXITEMS) { return; } @@ -4787,11 +4778,11 @@ void PutItemRecord(int nSeed, WORD wCI, int nIndex) dwTicks = GetTickCount(); - for(i = 0; i < gnNumGetRecords; i++) { - if(dwTicks - itemrecord[i].dwTimestamp > 6000) { + for (i = 0; i < gnNumGetRecords; i++) { + if (dwTicks - itemrecord[i].dwTimestamp > 6000) { NextItemRecord(i); i--; - } else if(nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) { + } else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) { NextItemRecord(i); break; } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index f1cb80358..b5c34a095 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -755,11 +753,7 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible) void FreeLightTable() { - BYTE *ptr; - - ptr = pLightTbl; - pLightTbl = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pLightTbl); } void InitLightTable() diff --git a/Source/list.h b/Source/list.h index 79c84a249..015c2064d 100644 --- a/Source/list.h +++ b/Source/list.h @@ -6,6 +6,8 @@ #include // for offsetof #include // for typeid +#include "../3rdParty/Storm/Source/storm.h" + DEVILUTION_BEGIN_NAMESPACE #ifdef _MSC_VER #pragma warning (disable : 4291) // no matching operator delete found diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index e0583289c..fe6fa1721 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/logging.cpp b/Source/logging.cpp index d3985c3e9..fa8a31eba 100644 --- a/Source/logging.cpp +++ b/Source/logging.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index e52ddb9df..878af98ed 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/minitext.cpp b/Source/minitext.cpp index fa5c0f798..718eda206 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -43,24 +41,15 @@ int qscroll_spd_tbl[9] = { 2, 4, 6, 8, 0, -1, -2, -3, -4 }; void FreeQuestText() { - void *ptr; - - ptr = pMedTextCels; - pMedTextCels = NULL; - mem_free_dbg(ptr); - ptr = pTextBoxCels; - pTextBoxCels = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pMedTextCels); + MemFreeDbg(pTextBoxCels); } void InitQuestText() { - unsigned char *v0; // eax - pMedTextCels = LoadFileInMem("Data\\MedTextS.CEL", 0); - v0 = LoadFileInMem("Data\\TextBox.CEL", 0); + pTextBoxCels = LoadFileInMem("Data\\TextBox.CEL", 0); qtextflag = FALSE; - pTextBoxCels = v0; } // 646D00: using guessed type char qtextflag; @@ -104,7 +93,7 @@ void PrintQTextChr(int sx, int sy, BYTE *pCelBuff, int nCel) pStart = &gpBuffer[PitchTbl[209]]; pEnd = &gpBuffer[PitchTbl[469]]; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pCelBuff mov eax, nCel diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 31433f9ce..9a3305d0d 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/monster.cpp b/Source/monster.cpp index 18434403b..c9e519b2f 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -5864,15 +5863,12 @@ void FreeMonsters() { int mtype; int i, j; - void *ptr; for (i = 0; i < nummtypes; i++) { mtype = Monsters[i].mtype; for (j = 0; j < 6; j++) { if (animletter[j] != 's' || monsterdata[mtype].has_special) { - ptr = Monsters[i].Anims[j].CMem; - Monsters[i].Anims[j].CMem = NULL; - mem_free_dbg(ptr); + MemFreeDbg(Monsters[i].Anims[j].CMem); } } } diff --git a/Source/movie.cpp b/Source/movie.cpp index 976b53cac..5b5f3def3 100644 --- a/Source/movie.cpp +++ b/Source/movie.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 29965d5a8..5c6d19316 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -100,8 +99,22 @@ void mpqapi_xor_buf(char *pbData) } while (v3); } -void mpqapi_update_multi_creation_time(DWORD dwChar) +void mpqapi_store_default_time(DWORD dwChar) { +/* + DWORD idx; + char dst[160]; + + if(gbMaxPlayers == 1) { + return; + } + + /// ASSERT: assert(dwChar < MAX_CHARACTERS); + idx = 16 * dwChar; + mpqapi_reg_load_modification_time(dst, sizeof(dst)); + *(_DWORD *)&dst[idx + 4] = 0x78341348; // dwHighDateTime + mpqapi_reg_store_modification_time(dst, sizeof(dst)); +*/ } BOOLEAN mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen) @@ -578,16 +591,9 @@ BOOLEAN mpqapi_parse_archive_header(_FILEHEADER *pHdr, int *pdwNextFileStart) // void mpqapi_close_archive(const char *pszArchive, BOOL bFree, int dwChar) // CloseMPQ { - _BLOCKENTRY *blockEntry; - _HASHENTRY *hashEntry; - if (bFree) { - blockEntry = sgpBlockTbl; - sgpBlockTbl = NULL; - mem_free_dbg(blockEntry); - hashEntry = sgpHashTbl; - sgpHashTbl = NULL; - mem_free_dbg(hashEntry); + MemFreeDbg(sgpBlockTbl); + MemFreeDbg(sgpHashTbl); } if (sghArchive != INVALID_HANDLE_VALUE) { CloseHandle(sghArchive); diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 3d078959f..c58d0126e 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -10,7 +10,7 @@ BOOL mpqapi_set_hidden(const char *pszArchive, BOOL hidden); void mpqapi_store_creation_time(const char *pszArchive, int dwChar); BOOL mpqapi_reg_load_modification_time(char *dst, int size); void mpqapi_xor_buf(char *pbData); -void mpqapi_update_multi_creation_time(DWORD dwChar); +void mpqapi_store_default_time(DWORD dwChar); BOOLEAN mpqapi_reg_store_modification_time(char *pbData, DWORD dwLen); _BLOCKENTRY *j_mpqapi_remove_hash_entry(char *pszName); void mpqapi_remove_hash_entry(const char *pszName); diff --git a/Source/msg.cpp b/Source/msg.cpp index f769c9f6a..21423597a 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE @@ -108,13 +108,9 @@ BOOL msg_wait_resync() void msg_free_packets() { - TMegaPkt *tmp; - while (sgpMegaPkt) { sgpCurrPkt = sgpMegaPkt->pNext; - tmp = sgpMegaPkt; - sgpMegaPkt = NULL; - mem_free_dbg(tmp); + MemFreeDbg(sgpMegaPkt); sgpMegaPkt = sgpCurrPkt; } } @@ -2236,7 +2232,7 @@ int On_SEND_PLRINFO(TCmdPlrInfoHdr *pCmd, int pnum) if (gbBufferMsgs == 1) msg_send_packet(pnum, pCmd, pCmd->wBytes + sizeof(*pCmd)); else - multi_player_joins(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO); + recv_plrinfo(pnum, pCmd, pCmd->bCmd == CMD_ACK_PLRINFO); return pCmd->wBytes + sizeof(*pCmd); } diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index b53150958..9336a9ac3 100644 --- a/Source/msgcmd.cpp +++ b/Source/msgcmd.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" #include "list.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/multi.cpp b/Source/multi.cpp index 4b5ce0daa..f9d3a23db 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -1,13 +1,16 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE BOOLEAN gbSomebodyWonGameKludge; // weak +#ifdef _DEBUG +DWORD gdwHistTicks; +#endif TBuffer sgHiPriBuf; char szPlayerDescript[128]; -short sgwPackPlrOffsetTbl[MAX_PLRS]; +WORD sgwPackPlrOffsetTbl[MAX_PLRS]; PkPlayerStruct netplr[MAX_PLRS]; BOOLEAN sgbPlayerTurnBitTbl[MAX_PLRS]; char sgbPlayerLeftGameTbl[MAX_PLRS]; @@ -35,6 +38,40 @@ const int event_types[3] = { EVENT_TYPE_PLAYER_MESSAGE }; +#ifdef _DEBUG +void __cdecl dumphist(const char *pszFmt, ...) +{ + static FILE *sgpHistFile = NULL; + DWORD dwTicks; + va_list va; + + va_start(va, pszFmt); + + if(sgpHistFile == NULL) { + sgpHistFile = fopen("c:\\dumphist.txt", "wb"); + if(sgpHistFile == NULL) { + return; + } + } + + dwTicks = GetTickCount(); + fprintf(sgpHistFile, "%4u.%02u ", (dwTicks - gdwHistTicks) / 1000, (dwTicks - gdwHistTicks) % 1000 / 10); + vfprintf(sgpHistFile, pszFmt, va); + fprintf( + sgpHistFile, + "\r\n (%d,%d)(%d,%d)(%d,%d)(%d,%d)\r\n", + plr[0].plractive, + player_state[0], + plr[1].plractive, + player_state[1], + plr[2].plractive, + player_state[2], + plr[3].plractive, + player_state[3]); + fflush(sgpHistFile); +} +#endif + void multi_msg_add(BYTE *a1, unsigned char a2) { if (a1) { @@ -724,6 +761,10 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) if (!multi_init_multi(&ProgramData, &plrdata, &UiData, pfExitProgram)) return FALSE; } +#ifdef _DEBUG + gdwHistTicks = GetTickCount(); + dumphist("(%d) new game started", myplr); +#endif sgbNetInited = TRUE; sgbTimeout = FALSE; delta_init(); @@ -734,7 +775,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) sync_init(); nthread_start(sgbPlayerTurnBitTbl[myplr]); dthread_start(); - dummy_nop_used_in_NetInit(); + tmsg_start(); sgdwGameLoops = 0; sgbSentThisCycle = 0; gbDeltaSender = myplr; @@ -769,10 +810,6 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram) // 6796E4: using guessed type char gbDeltaSender; // 6796E8: using guessed type int sgbNetInited; -void dummy_nop_used_in_NetInit() -{ -} - void buffer_init(TBuffer *pBuf) { pBuf->dwNextWriteOffset = 0; @@ -928,68 +965,72 @@ BOOL multi_upgrade(int *pfExitProgram) return result; } -void multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3) -{ - int v3; // ebx - TCmdPlrInfoHdr *v4; // edi - short *v5; // esi - int v6; // esi - BOOLEAN v7; // zf - char *v8; // eax - int v9; // ST08_4 - unsigned char *v10; // edx - int v11; // eax - int v12; // ecx - int v13; // eax - - v3 = pnum; - v4 = cmd; - if (myplr != pnum) { - v5 = &sgwPackPlrOffsetTbl[pnum]; - if (*v5 == cmd->wOffset || (*v5 = 0, !cmd->wOffset)) { - if (!a3 && !*v5) { - multi_send_pinfo(pnum, CMD_ACK_PLRINFO); - } - memcpy((char *)&netplr[v3] + (unsigned short)v4->wOffset, &v4[1], (unsigned short)v4->wBytes); - *v5 += v4->wBytes; - if (*v5 == 1266) { - *v5 = 0; - multi_player_left_msg(v3, 0); - v6 = v3; - plr[v3]._pGFXLoad = 0; - UnPackPlayer(&netplr[v3], v3, 1); - if (a3) { - ++gbActivePlayers; - v7 = sgbPlayerTurnBitTbl[v3] == 0; - plr[v6].plractive = 1; - v8 = "Player '%s' (level %d) just joined the game"; - if (v7) - v8 = "Player '%s' (level %d) is already in the game"; - EventPlrMsg(v8, plr[v6]._pName, plr[v6]._pLevel); - LoadPlrGFX(v3, PFILE_STAND); - SyncInitPlr(v3); - if (plr[v6].plrlevel == currlevel) { - if (plr[v6]._pHitPoints >> 6 <= 0) { - plr[v6]._pgfxnum = 0; - LoadPlrGFX(v3, PFILE_DEATH); - v9 = plr[v6]._pDWidth; - v10 = plr[v6]._pDAnim[0]; - plr[v6]._pmode = 8; - NewPlrAnim(v3, v10, plr[v6]._pDFrames, 1, v9); - v11 = plr[v6]._pAnimLen; - v12 = v11 - 1; - plr[v6]._pVar8 = 2 * v11; - v13 = plr[v6].WorldX; - plr[v6]._pAnimFrame = v12; - dFlags[v13][plr[v6].WorldY] |= DFLAG_DEAD_PLAYER; - } else { - StartStand(v3, 0); - } - } - } - } +void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv) +{ + char *szEvent; + + if(myplr == pnum) { + return; + } + /// ASSERT: assert((DWORD)pnum < MAX_PLRS); + + if(sgwPackPlrOffsetTbl[pnum] != p->wOffset) { + sgwPackPlrOffsetTbl[pnum] = 0; + if(p->wOffset != 0) { + return; + } + } + if(!recv && sgwPackPlrOffsetTbl[pnum] == 0) { + multi_send_pinfo(pnum, CMD_ACK_PLRINFO); + } + + memcpy((char *)&netplr[pnum] + p->wOffset, &p[1], p->wBytes); /* todo: cast? */ + sgwPackPlrOffsetTbl[pnum] += p->wBytes; + if(sgwPackPlrOffsetTbl[pnum] != sizeof(*netplr)) { + return; + } + + sgwPackPlrOffsetTbl[pnum] = 0; + multi_player_left_msg(pnum, 0); + plr[pnum]._pGFXLoad = 0; + UnPackPlayer(&netplr[pnum], pnum, 1); + + if(!recv) { +#ifdef _DEBUG + dumphist("(%d) received all %d plrinfo", myplr, pnum); +#endif + return; + } + + plr[pnum].plractive = 1; + gbActivePlayers++; + + if(sgbPlayerTurnBitTbl[pnum] != 0) { + szEvent = "Player '%s' (level %d) just joined the game"; + } else { + szEvent = "Player '%s' (level %d) is already in the game"; + } + EventPlrMsg(szEvent, plr[pnum]._pName, plr[pnum]._pLevel); + + LoadPlrGFX(pnum, PFILE_STAND); + SyncInitPlr(pnum); + + if(plr[pnum].plrlevel == currlevel) { + if(plr[pnum]._pHitPoints >> 6 > 0) { + StartStand(pnum, 0); + } else { + plr[pnum]._pgfxnum = 0; + LoadPlrGFX(pnum, PFILE_DEATH); + plr[pnum]._pmode = PM_DEATH; + NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth); + plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1; + plr[pnum]._pVar8 = 2 * plr[pnum]._pAnimLen; + dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= DFLAG_DEAD_PLAYER; } } +#ifdef _DEBUG + dumphist("(%d) making %d active -- recv_plrinfo", myplr, pnum); +#endif } DEVILUTION_END_NAMESPACE diff --git a/Source/multi.h b/Source/multi.h index ac3a2cfb5..8480fa2d5 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -4,7 +4,7 @@ extern BOOLEAN gbSomebodyWonGameKludge; // weak extern char szPlayerDescript[128]; -extern short sgwPackPlrOffsetTbl[MAX_PLRS]; +extern WORD sgwPackPlrOffsetTbl[MAX_PLRS]; extern PkPlayerStruct netplr[MAX_PLRS]; extern BOOL gbShouldValidatePackage; extern BYTE gbActivePlayers; @@ -15,6 +15,9 @@ extern char szPlayerName[128]; extern BYTE gbDeltaSender; // weak extern int player_state[MAX_PLRS]; +#ifdef _DEBUG +void __cdecl dumphist(const char *pszFmt, ...); +#endif void multi_msg_add(BYTE *a1, unsigned char a2); void NetSendLoPri(BYTE *pbMsg, BYTE bLen); void multi_copy_packet(TBuffer *a1, void *packet, BYTE size); @@ -43,7 +46,6 @@ void NetClose(); char multi_event_handler(int a1); void __stdcall multi_handle_events(_SNETEVENT *pEvt); BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram); -void dummy_nop_used_in_NetInit(); void buffer_init(TBuffer *pBuf); void multi_send_pinfo(int pnum, char cmd); int InitNewSeed(int newseed); @@ -51,7 +53,7 @@ void SetupLocalCoords(); BOOL multi_init_single(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info); BOOL multi_init_multi(_SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_info, _SNETUIDATA *ui_info, int *pfExitProgram); BOOL multi_upgrade(int *pfExitProgram); -void multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3); +void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv); /* rdata */ diff --git a/Source/nthread.cpp b/Source/nthread.cpp index e7a9f15a1..080d5f734 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/objects.cpp b/Source/objects.cpp index 4b8da3396..c9bec6a7a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -133,106 +131,106 @@ int ObjTypeConv[113] = { }; ObjDataStruct AllObjects[99] = { // clang-format off - // oload, ofindex, ominlvl, omaxlvl, olvltype, otheme, oquest, oAnimFlag, oAnimDelay, oAnimLen, oAnimWidth, oSolidFlag, oMissFlag, oLightFlag, oBreak, oSelFlag, oTrapFlag - { 1, OFILE_L1BRAZ, 1, 4, 1, -1, -1, 1, 1, 26, 64, TRUE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_L1DOORS, 1, 4, 1, -1, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, - { 1, OFILE_L1DOORS, 1, 4, 1, -1, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, - { 3, OFILE_SKULFIRE, 0, 0, 0, 3, -1, 1, 2, 11, 96, TRUE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_LEVER, 1, 4, 1, -1, -1, 0, 1, 1, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_CHEST1, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_CHEST2, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_CHEST3, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 3, OFILE_CANDLE2, 0, 0, 0, 1, -1, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 3, OFILE_BANNER, 0, 0, 0, 3, -1, 0, 2, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 3, OFILE_BANNER, 0, 0, 0, 3, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 3, OFILE_BANNER, 0, 0, 0, 3, -1, 0, 3, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_SKULPILE, 1, 4, 0, -1, -1, 0, 0, 1, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_L1BRAZ, 0, 0, 0, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_CRUXSK1, 0, 0, 0, -1, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, - { 2, OFILE_CRUXSK2, 0, 0, 0, -1, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, - { 2, OFILE_CRUXSK3, 0, 0, 0, -1, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, - { 1, OFILE_ROCKSTAN, 5, 5, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_ANGEL, 0, 0, 0, -1, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 2, OFILE_BOOK2, 0, 0, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 2, OFILE_BURNCROS, 0, 0, 0, -1, -1, 1, 0, 10, 160, TRUE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_NUDE2, 0, 0, 0, -1, -1, 1, 3, 6, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_SWITCH4, 16, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_TNUDEM, 13, 16, 0, -1, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEM, 13, 16, 0, 6, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEM, 13, 16, 0, 6, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEM, 13, 16, 0, 6, 6, 0, 4, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEW, 13, 16, 0, 6, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEW, 13, 16, 0, 6, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TNUDEW, 13, 16, 0, 6, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TSOUL, 13, 16, 0, -1, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TSOUL, 13, 16, 0, -1, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TSOUL, 13, 16, 0, -1, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TSOUL, 13, 16, 0, -1, 6, 0, 4, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TSOUL, 13, 16, 0, -1, 6, 0, 5, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_BOOK2, 6, 6, 0, -1, -1, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_L2DOORS, 5, 8, 2, -1, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, - { 1, OFILE_L2DOORS, 5, 8, 2, -1, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, FALSE }, - { 1, OFILE_WTORCH4, 5, 8, 2, -1, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_WTORCH3, 5, 8, 2, -1, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_WTORCH1, 5, 8, 2, -1, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_WTORCH2, 5, 8, 2, -1, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, - { 1, OFILE_SARC, 1, 4, 1, -1, -1, 0, 1, 5, 128, TRUE, TRUE, TRUE, 0, 3, TRUE }, - { 2, OFILE_FLAME1, 1, 4, 1, -1, -1, 0, 1, 20, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_LEVER, 1, 4, 1, -1, -1, 0, 1, 2, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 2, OFILE_MINIWATR, 1, 4, 1, -1, -1, 1, 1, 10, 64, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_BOOK1, 3, 4, 1, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_TRAPHOLE, 1, 16, 0, -1, -1, 0, 1, 0, 64, FALSE, TRUE, TRUE, 0, 0, FALSE }, - { 1, OFILE_TRAPHOLE, 1, 16, 0, -1, -1, 0, 2, 0, 64, FALSE, TRUE, TRUE, 0, 0, FALSE }, - { 2, OFILE_BCASE, 0, 0, 0, -1, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 2, OFILE_WEAPSTND, 0, 0, 0, -1, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 1, OFILE_BARREL, 1, 16, 0, -1, -1, 0, 1, 9, 96, TRUE, TRUE, TRUE, 1, 3, FALSE }, - { 1, OFILE_BARRELEX, 1, 16, 0, -1, -1, 0, 1, 10, 96, TRUE, TRUE, TRUE, 1, 3, FALSE }, - { 3, OFILE_LSHRINEG, 0, 0, 0, 1, -1, 0, 1, 11, 128, FALSE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_RSHRINEG, 0, 0, 0, 1, -1, 0, 1, 11, 128, FALSE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_BOOK2, 0, 0, 0, 3, -1, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 3, OFILE_BCASE, 0, 0, 0, 5, -1, 0, 3, 0, 96, FALSE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_BCASE, 0, 0, 0, 5, -1, 0, 4, 0, 96, FALSE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_BOOK2, 0, 0, 0, 5, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 3, OFILE_CANDLE2, 0, 0, 0, 5, -1, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 3, OFILE_BLOODFNT, 0, 0, 0, 7, -1, 1, 2, 10, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_DECAP, 13, 16, 0, 8, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, FALSE }, - { 1, OFILE_CHEST1, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_CHEST2, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_CHEST3, 1, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { 1, OFILE_BOOK1, 7, 7, 2, -1, 8, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_BOOK1, 5, 5, 2, -1, 9, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_PEDISTL, 5, 5, 2, -1, 9, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_L3DOORS, 9, 12, 3, -1, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, - { 1, OFILE_L3DOORS, 9, 12, 3, -1, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, - { 3, OFILE_PFOUNTN, 0, 0, 0, 9, -1, 1, 2, 10, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 3, OFILE_ARMSTAND, 0, 0, 0, 10, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_ARMSTAND, 0, 0, 0, 10, -1, 0, 2, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 3, OFILE_GOATSHRN, 0, 0, 0, 11, -1, 1, 2, 10, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_CAULDREN, 13, 16, 0, -1, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 3, OFILE_MFOUNTN, 0, 0, 0, 13, -1, 1, 2, 10, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 3, OFILE_TFOUNTN, 0, 0, 0, 14, -1, 1, 2, 4, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_ALTBOY, 0, 0, 1, -1, 15, 0, 1, 0, 128, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 1, OFILE_MCIRL, 0, 0, 1, -1, 15, 0, 1, 0, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, - { 1, OFILE_MCIRL, 0, 0, 1, -1, 15, 0, 1, 0, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, - { 1, OFILE_BKSLBRNT, 4, 12, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_CANDLE2, 2, 12, 0, -1, 15, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, - { 1, OFILE_BOOK1, 13, 13, 4, -1, 11, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, - { 1, OFILE_ARMSTAND, 13, 13, 0, -1, 11, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 2, OFILE_WEAPSTND, 13, 13, 0, -1, 11, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 2, OFILE_BURNCROS, 0, 0, 0, 15, -1, 1, 0, 10, 160, TRUE, FALSE, FALSE, 0, 0, FALSE }, - { 2, OFILE_WEAPSTND, 0, 0, 0, 16, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 2, OFILE_WEAPSTND, 0, 0, 0, 16, -1, 0, 2, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, - { 2, OFILE_MUSHPTCH, 0, 0, 0, -1, 1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, TRUE }, - { 2, OFILE_LZSTAND, 0, 0, 0, -1, 15, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 3, FALSE }, - { 1, OFILE_DECAP, 9, 9, 3, -1, -1, 0, 2, 0, 96, TRUE, TRUE, TRUE, 0, 1, FALSE }, - { 2, OFILE_CHEST3, 0, 0, 0, -1, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, - { -1, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE } + // oload, ofindex, ominlvl, omaxlvl, olvltype, otheme, oquest, oAnimFlag, oAnimDelay, oAnimLen, oAnimWidth, oSolidFlag, oMissFlag, oLightFlag, oBreak, oSelFlag, oTrapFlag + { 1, OFILE_L1BRAZ, 1, 4, 1, THEME_NONE, -1, 1, 1, 26, 64, TRUE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_L1DOORS, 1, 4, 1, THEME_NONE, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, + { 1, OFILE_L1DOORS, 1, 4, 1, THEME_NONE, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, + { 3, OFILE_SKULFIRE, 0, 0, 0, THEME_SKELROOM, -1, 1, 2, 11, 96, TRUE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_LEVER, 1, 4, 1, THEME_NONE, -1, 0, 1, 1, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_CHEST1, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_CHEST2, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_CHEST3, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 3, OFILE_CANDLE2, 0, 0, 0, THEME_SHRINE, -1, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 3, OFILE_BANNER, 0, 0, 0, THEME_SKELROOM, -1, 0, 2, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 3, OFILE_BANNER, 0, 0, 0, THEME_SKELROOM, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 3, OFILE_BANNER, 0, 0, 0, THEME_SKELROOM, -1, 0, 3, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_SKULPILE, 1, 4, 0, THEME_NONE, -1, 0, 0, 1, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_L1BRAZ, 0, 0, 0, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_CRUXSK1, 0, 0, 0, THEME_NONE, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, + { 2, OFILE_CRUXSK2, 0, 0, 0, THEME_NONE, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, + { 2, OFILE_CRUXSK3, 0, 0, 0, THEME_NONE, -1, 0, 1, 15, 96, TRUE, FALSE, TRUE, 1, 3, FALSE }, + { 1, OFILE_ROCKSTAN, 5, 5, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_ANGEL, 0, 0, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 2, OFILE_BOOK2, 0, 0, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 2, OFILE_BURNCROS, 0, 0, 0, THEME_NONE, -1, 1, 0, 10, 160, TRUE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_NUDE2, 0, 0, 0, THEME_NONE, -1, 1, 3, 6, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_SWITCH4, 16, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_TNUDEM, 13, 16, 0, THEME_NONE, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEM, 13, 16, 0, THEME_TORTURE, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEM, 13, 16, 0, THEME_TORTURE, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEM, 13, 16, 0, THEME_TORTURE, 6, 0, 4, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEW, 13, 16, 0, THEME_TORTURE, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEW, 13, 16, 0, THEME_TORTURE, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TNUDEW, 13, 16, 0, THEME_TORTURE, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TSOUL, 13, 16, 0, THEME_NONE, 6, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TSOUL, 13, 16, 0, THEME_NONE, 6, 0, 2, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TSOUL, 13, 16, 0, THEME_NONE, 6, 0, 3, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TSOUL, 13, 16, 0, THEME_NONE, 6, 0, 4, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TSOUL, 13, 16, 0, THEME_NONE, 6, 0, 5, 0, 128, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_BOOK2, 6, 6, 0, THEME_NONE, -1, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_L2DOORS, 5, 8, 2, THEME_NONE, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, + { 1, OFILE_L2DOORS, 5, 8, 2, THEME_NONE, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, FALSE }, + { 1, OFILE_WTORCH4, 5, 8, 2, THEME_NONE, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_WTORCH3, 5, 8, 2, THEME_NONE, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_WTORCH1, 5, 8, 2, THEME_NONE, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_WTORCH2, 5, 8, 2, THEME_NONE, -1, 1, 1, 9, 96, FALSE, TRUE, FALSE, 0, 0, FALSE }, + { 1, OFILE_SARC, 1, 4, 1, THEME_NONE, -1, 0, 1, 5, 128, TRUE, TRUE, TRUE, 0, 3, TRUE }, + { 2, OFILE_FLAME1, 1, 4, 1, THEME_NONE, -1, 0, 1, 20, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_LEVER, 1, 4, 1, THEME_NONE, -1, 0, 1, 2, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 2, OFILE_MINIWATR, 1, 4, 1, THEME_NONE, -1, 1, 1, 10, 64, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_BOOK1, 3, 4, 1, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_TRAPHOLE, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 64, FALSE, TRUE, TRUE, 0, 0, FALSE }, + { 1, OFILE_TRAPHOLE, 1, 16, 0, THEME_NONE, -1, 0, 2, 0, 64, FALSE, TRUE, TRUE, 0, 0, FALSE }, + { 2, OFILE_BCASE, 0, 0, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 2, OFILE_WEAPSTND, 0, 0, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 1, OFILE_BARREL, 1, 16, 0, THEME_NONE, -1, 0, 1, 9, 96, TRUE, TRUE, TRUE, 1, 3, FALSE }, + { 1, OFILE_BARRELEX, 1, 16, 0, THEME_NONE, -1, 0, 1, 10, 96, TRUE, TRUE, TRUE, 1, 3, FALSE }, + { 3, OFILE_LSHRINEG, 0, 0, 0, THEME_SHRINE, -1, 0, 1, 11, 128, FALSE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_RSHRINEG, 0, 0, 0, THEME_SHRINE, -1, 0, 1, 11, 128, FALSE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_BOOK2, 0, 0, 0, THEME_SKELROOM, -1, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 3, OFILE_BCASE, 0, 0, 0, THEME_LIBRARY, -1, 0, 3, 0, 96, FALSE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_BCASE, 0, 0, 0, THEME_LIBRARY, -1, 0, 4, 0, 96, FALSE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_BOOK2, 0, 0, 0, THEME_LIBRARY, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 3, OFILE_CANDLE2, 0, 0, 0, THEME_LIBRARY, -1, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 3, OFILE_BLOODFNT, 0, 0, 0, THEME_BLOODFOUNTAIN, -1, 1, 2, 10, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_DECAP, 13, 16, 0, THEME_DECAPITATED, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, FALSE }, + { 1, OFILE_CHEST1, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_CHEST2, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_CHEST3, 1, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { 1, OFILE_BOOK1, 7, 7, 2, THEME_NONE, 8, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_BOOK1, 5, 5, 2, THEME_NONE, 9, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_PEDISTL, 5, 5, 2, THEME_NONE, 9, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_L3DOORS, 9, 12, 3, THEME_NONE, -1, 0, 1, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, + { 1, OFILE_L3DOORS, 9, 12, 3, THEME_NONE, -1, 0, 2, 0, 64, FALSE, FALSE, TRUE, 0, 3, TRUE }, + { 3, OFILE_PFOUNTN, 0, 0, 0, THEME_PURIFYINGFOUNTAIN, -1, 1, 2, 10, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 3, OFILE_ARMSTAND, 0, 0, 0, THEME_ARMORSTAND, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_ARMSTAND, 0, 0, 0, THEME_ARMORSTAND, -1, 0, 2, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 3, OFILE_GOATSHRN, 0, 0, 0, THEME_GOATSHRINE, -1, 1, 2, 10, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_CAULDREN, 13, 16, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 3, OFILE_MFOUNTN, 0, 0, 0, THEME_MURKYFOUNTAIN, -1, 1, 2, 10, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 3, OFILE_TFOUNTN, 0, 0, 0, THEME_TEARFOUNTAIN, -1, 1, 2, 4, 128, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_ALTBOY, 0, 0, 1, THEME_NONE, 15, 0, 1, 0, 128, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 1, OFILE_MCIRL, 0, 0, 1, THEME_NONE, 15, 0, 1, 0, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, + { 1, OFILE_MCIRL, 0, 0, 1, THEME_NONE, 15, 0, 1, 0, 96, FALSE, TRUE, TRUE, 0, 0, FALSE }, + { 1, OFILE_BKSLBRNT, 4, 12, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_CANDLE2, 2, 12, 0, THEME_NONE, 15, 1, 2, 4, 96, TRUE, TRUE, TRUE, 0, 0, FALSE }, + { 1, OFILE_BOOK1, 13, 13, 4, THEME_NONE, 11, 0, 4, 0, 96, TRUE, TRUE, TRUE, 0, 3, FALSE }, + { 1, OFILE_ARMSTAND, 13, 13, 0, THEME_NONE, 11, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 2, OFILE_WEAPSTND, 13, 13, 0, THEME_NONE, 11, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 2, OFILE_BURNCROS, 0, 0, 0, THEME_BRNCROSS, -1, 1, 0, 10, 160, TRUE, FALSE, FALSE, 0, 0, FALSE }, + { 2, OFILE_WEAPSTND, 0, 0, 0, THEME_WEAPONRACK, -1, 0, 1, 0, 96, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 2, OFILE_WEAPSTND, 0, 0, 0, THEME_WEAPONRACK, -1, 0, 2, 0, 96, TRUE, FALSE, TRUE, 0, 0, FALSE }, + { 2, OFILE_MUSHPTCH, 0, 0, 0, THEME_NONE, 1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 3, TRUE }, + { 2, OFILE_LZSTAND, 0, 0, 0, THEME_NONE, 15, 0, 1, 0, 128, TRUE, FALSE, TRUE, 0, 3, FALSE }, + { 1, OFILE_DECAP, 9, 9, 3, THEME_NONE, -1, 0, 2, 0, 96, TRUE, TRUE, TRUE, 0, 1, FALSE }, + { 2, OFILE_CHEST3, 0, 0, 0, THEME_NONE, -1, 0, 1, 0, 96, TRUE, TRUE, TRUE, 0, 1, TRUE }, + { -1, 0, 0, 0, -1, THEME_NONE, -1, 0, 0, 0, 0, FALSE, FALSE, FALSE, 0, 0, FALSE } // clang-format on }; char *ObjMasterLoadList[56] = { @@ -370,7 +368,7 @@ void InitObjectGFX() && (int)currlevel <= AllObjects[i].omaxlvl) { fileload[AllObjects[i].ofindex] = TRUE; } - if (AllObjects[i].otheme != -1) { + if (AllObjects[i].otheme != THEME_NONE) { for (j = 0; j < numthemes; j++) { if (themes[j].ttype == AllObjects[i].otheme) fileload[AllObjects[i].ofindex] = TRUE; @@ -398,12 +396,9 @@ void InitObjectGFX() void FreeObjectGFX() { int i; - void *ptr; for (i = 0; i < numobjfiles; i++) { - ptr = pObjCels[i]; - pObjCels[i] = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pObjCels[i]); } numobjfiles = 0; } @@ -1434,11 +1429,12 @@ void AddFlameLvr(int i) } // 679768: using guessed type int trapid; -void AddTrap(int i) +void AddTrap(int i, int t) { int mt; - mt = random(148, 1 + currlevel / 3); + mt = currlevel / 3 + 1; + mt = random(148, mt); if (mt == 0) object[i]._oVar3 = 0; // arrow if (mt == 1) @@ -1458,7 +1454,7 @@ void AddObjLight(int i, int r) } } -void AddBarrel(int i) +void AddBarrel(int i, int t) { object[i]._oVar1 = 0; object[i]._oRndSeed = GetRndSeed(); @@ -1512,6 +1508,16 @@ void AddBookcase(int i) object[i]._oPreFlag = TRUE; } +void AddBookstand(int i) +{ + object[i]._oRndSeed = GetRndSeed(); +} + +void AddBloodFtn(int i) +{ + object[i]._oRndSeed = GetRndSeed(); +} + void AddPurifyingFountain(int i) { int ox, oy; @@ -1534,6 +1540,33 @@ void AddArmorStand(int i) object[i]._oRndSeed = GetRndSeed(); } +void AddGoatShrine(int i) +{ + object[i]._oRndSeed = GetRndSeed(); +} + +void AddCauldron(int i) +{ + object[i]._oRndSeed = GetRndSeed(); +} + +void AddMurkyFountain(int i) +{ + int ox, oy; + + ox = object[i]._ox; + oy = object[i]._oy; + dObject[ox][oy - 1] = -1 - i; + dObject[ox - 1][oy] = -1 - i; + dObject[ox - 1][oy - 1] = -1 - i; + object[i]._oRndSeed = GetRndSeed(); +} + +void AddTearFountain(int i) +{ + object[i]._oRndSeed = GetRndSeed(); +} + void AddDecap(int i) { object[i]._oRndSeed = GetRndSeed(); @@ -1558,7 +1591,7 @@ void AddMagicCircle(int i) object[i]._oVar6 = 0; } -void AddBookstand(int i) +void AddBrnCross(int i) { object[i]._oRndSeed = GetRndSeed(); } @@ -1659,150 +1692,141 @@ void AddSlainHero() void AddObject(int ot, int ox, int oy) { - int v3; // ebp - int v4; // esi - //unsigned int v5; // eax - int v6; // ebx - int v7; // ebx - int v8; // eax + int oi; - v3 = ox; - v4 = ot; - if (nobjects < MAXOBJECTS) { - //v5 = 4 * nobjects; - v6 = objectavail[0]; - objectactive[nobjects] = objectavail[0]; - objectavail[0] = objectavail[-nobjects + 126]; /* double check, MAXOBJECTS */ - dObject[ox][oy] = v6 + 1; - SetupObject(v6, ox, oy, ot); - switch (v4) { - case OBJ_L1LIGHT: - case OBJ_SKFIRE: - case OBJ_CANDLE1: - case OBJ_CANDLE2: - case OBJ_BOOKCANDLE: - goto LABEL_31; - case OBJ_L1LDOOR: - case OBJ_L1RDOOR: - AddL1Door(v6, v3, oy, v4); - break; - case OBJ_CHEST1: - case OBJ_CHEST2: - case OBJ_CHEST3: - case OBJ_TCHEST1: - case OBJ_TCHEST2: - case OBJ_TCHEST3: - AddChest(v6, v4); - break; - case OBJ_BOOK2L: - AddVilebook(v6); - break; - case OBJ_BCROSS: - case OBJ_TBCROSS: - AddBookstand(v6); - LABEL_31: - AddObjLight(v6, 5); - break; - case OBJ_TNUDEM2: - AddTorturedBody(v6); - break; - case OBJ_BOOK2R: - AddSCambBook(v6); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - AddL2Door(v6, v3, oy, v4); - break; - case OBJ_TORCHL: - case OBJ_TORCHR: - case OBJ_TORCHL2: - case OBJ_TORCHR2: - AddObjLight(v6, 8); - break; - case OBJ_SARC: - AddSarc(v6); - break; - case OBJ_FLAMEHOLE: - AddFlameTrap(v6); - break; - case OBJ_FLAMELVR: - AddFlameLvr(v6); - break; - case OBJ_WATER: - object[v6]._oAnimFrame = 1; - break; - case OBJ_TRAPL: - case OBJ_TRAPR: - AddTrap(v6); - break; - case OBJ_BARREL: - case OBJ_BARRELEX: - AddBarrel(v6); - break; - case OBJ_SHRINEL: - case OBJ_SHRINER: - AddShrine(v6); - break; - case OBJ_SKELBOOK: - case OBJ_BOOKSTAND: - AddBookstand(v6); - break; - case OBJ_BOOKCASEL: - case OBJ_BOOKCASER: - AddBookcase(v6); - break; - case OBJ_BLOODFTN: - AddBookstand(v6); - break; - case OBJ_DECAP: - AddDecap(v6); - break; - case OBJ_PEDISTAL: - AddPedistal(v6); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - AddL3Door(v6, v3, oy, v4); - break; - case OBJ_PURIFYINGFTN: - AddPurifyingFountain(v6); - break; - case OBJ_ARMORSTAND: - case OBJ_WARARMOR: - AddArmorStand(v6); - break; - case OBJ_GOATSHRINE: - AddBookstand(v6); - break; - case OBJ_CAULDRON: - AddBookstand(v6); - break; - case OBJ_MURKYFTN: - AddPurifyingFountain(v6); - break; - case OBJ_TEARFTN: - AddBookstand(v6); - break; - case OBJ_MCIRCLE1: - case OBJ_MCIRCLE2: - AddMagicCircle(v6); - break; - case OBJ_STORYBOOK: - AddStoryBook(v6); - break; - case OBJ_STORYCANDLE: - AddObjLight(v6, 3); - break; - case OBJ_WARWEAP: - case OBJ_WEAPONRACK: - AddWeaponRack(v6); - break; - } - v7 = v6; - v8 = object[v7]._oAnimWidth - 64; - ++nobjects; - object[v7]._oAnimWidth2 = v8 >> 1; + if (nobjects >= MAXOBJECTS) + return; + + oi = objectavail[0]; + objectavail[0] = objectavail[126 - nobjects]; + objectactive[nobjects] = oi; + dObject[ox][oy] = oi + 1; + SetupObject(oi, ox, oy, ot); + switch (ot) { + case OBJ_STORYCANDLE: + AddObjLight(oi, 3); + break; + case OBJ_TORCHL: + case OBJ_TORCHR: + case OBJ_TORCHL2: + case OBJ_TORCHR2: + AddObjLight(oi, 8); + break; + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + AddL1Door(oi, ox, oy, ot); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + AddL2Door(oi, ox, oy, ot); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + AddL3Door(oi, ox, oy, ot); + break; + case OBJ_BOOK2R: + AddSCambBook(oi); + break; + case OBJ_CHEST1: + case OBJ_CHEST2: + case OBJ_CHEST3: + case OBJ_TCHEST1: + case OBJ_TCHEST2: + case OBJ_TCHEST3: + AddChest(oi, ot); + break; + case OBJ_SARC: + AddSarc(oi); + break; + case OBJ_FLAMEHOLE: + AddFlameTrap(oi); + break; + case OBJ_FLAMELVR: + AddFlameLvr(oi); + break; + case OBJ_WATER: + object[oi]._oAnimFrame = 1; + break; + case OBJ_TRAPL: + case OBJ_TRAPR: + AddTrap(oi, ot); + break; + case OBJ_BARREL: + case OBJ_BARRELEX: + AddBarrel(oi, ot); + break; + case OBJ_SHRINEL: + case OBJ_SHRINER: + AddShrine(oi); + break; + case OBJ_BOOKCASEL: + case OBJ_BOOKCASER: + AddBookcase(oi); + break; + case OBJ_SKELBOOK: + case OBJ_BOOKSTAND: + AddBookstand(oi); + break; + case OBJ_BLOODFTN: + AddBloodFtn(oi); + break; + case OBJ_DECAP: + AddDecap(oi); + break; + case OBJ_PURIFYINGFTN: + AddPurifyingFountain(oi); + break; + case OBJ_ARMORSTAND: + case OBJ_WARARMOR: + AddArmorStand(oi); + break; + case OBJ_GOATSHRINE: + AddGoatShrine(oi); + break; + case OBJ_CAULDRON: + AddCauldron(oi); + break; + case OBJ_MURKYFTN: + AddMurkyFountain(oi); + break; + case OBJ_TEARFTN: + AddTearFountain(oi); + break; + case OBJ_BOOK2L: + AddVilebook(oi); + break; + case OBJ_MCIRCLE1: + case OBJ_MCIRCLE2: + AddMagicCircle(oi); + break; + case OBJ_STORYBOOK: + AddStoryBook(oi); + break; + case OBJ_BCROSS: + case OBJ_TBCROSS: + AddBrnCross(oi); + AddObjLight(oi, 5); + break; + case OBJ_L1LIGHT: + case OBJ_SKFIRE: + case OBJ_CANDLE1: + case OBJ_CANDLE2: + case OBJ_BOOKCANDLE: + AddObjLight(oi, 5); + break; + case OBJ_PEDISTAL: + AddPedistal(oi); + break; + case OBJ_WARWEAP: + case OBJ_WEAPONRACK: + AddWeaponRack(oi); + break; + case OBJ_TNUDEM2: + AddTorturedBody(oi); + break; } + object[oi]._oAnimWidth2 = (object[oi]._oAnimWidth - 64) >> 1; + nobjects++; } void Obj_Light(int i, int lr) @@ -2192,7 +2216,7 @@ void ObjSetMini(int x, int y, int v) int xx, yy; long v1, v2, v3, v4; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles xor eax, eax @@ -2357,342 +2381,297 @@ void RedoPlayerVision() } } -void OperateL1RDoor(int pnum, int oi, unsigned char sendflag) +void OperateL1RDoor(int pnum, int oi, BOOL sendflag) { - int v3; // esi - int v4; // eax - int v5; // ebx - int v6; // edi - int v7; // ST04_4 - int v8; // [esp+Ch] [ebp-Ch] - int v9; // [esp+10h] [ebp-8h] - int param1; // [esp+14h] [ebp-4h] + int xp, yp; - v3 = oi; - param1 = oi; - v9 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._ox; - v6 = object[v3]._oy; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); - v8 = v6 + 112 * v5; - if (dDead[0][v8] != 0 || dMonster[0][v8] != 0 || dItem[0][v8] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v9 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - v7 = object[v3]._oVar1; - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v5, v6, v7); - if (object[v3]._oVar2 == 50) { - if (dPiece[-1][v8] == 396) /* check *(_DWORD *)&dflags[28][4 * v8 + 32] == 396 ) */ - ObjSetMicro(v5 - 1, v6, 411); - else - ObjSetMicro(v5 - 1, v6, 50); - } else { - ObjSetMicro(v5 - 1, v6, object[v3]._oVar2); - } - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v5, v6, 395); - dArch[v5][v6] = 8; - objects_set_door_piece(v5, v6 - 1); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - DoorSet(param1, v5 - 1, v6); - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); + return; + } + + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + ObjSetMicro(xp, yp, 395); + dArch[xp][yp] = 8; + objects_set_door_piece(xp, yp - 1); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + DoorSet(oi, xp - 1, yp); + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; RedoPlayerVision(); return; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); -} -// 676190: using guessed type int deltaload; -void OperateL1LDoor(int pnum, int oi, unsigned char sendflag) -{ - int v3; // esi - int v4; // eax - int v5; // ebx - int v6; // edi - int v7; // ST04_4 - int v8; // [esp+Ch] [ebp-Ch] - int v9; // [esp+10h] [ebp-8h] - int param1; // [esp+14h] [ebp-4h] - - v3 = oi; - param1 = oi; - v9 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._ox; - v6 = object[v3]._oy; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, v5, object[v3]._oy); - v8 = v6 + 112 * v5; - if (dDead[v5][v6] != 0 || dMonster[0][v8] != 0 || dItem[v5][v6] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v9 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - v7 = object[v3]._oVar1; - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v5, v6, v7); - if (object[v3]._oVar2 == 50) { - if (dPiece[0][v8 - 1] == 396) /* check *(_DWORD *)&dflags[39][v8 * 4 + 36] == 396 ) */ - ObjSetMicro(v5, v6 - 1, 412); - else - ObjSetMicro(v5, v6 - 1, 50); - } else { - ObjSetMicro(v5, v6 - 1, object[v3]._oVar2); - } - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, xp, object[oi]._oy); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, object[oi]._oVar1); + if (object[oi]._oVar2 != 50) { + ObjSetMicro(xp - 1, yp, object[oi]._oVar2); } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - if (object[v3]._oVar1 == 214) - ObjSetMicro(v5, v6, 408); + if (dPiece[xp - 1][yp] == 396) + ObjSetMicro(xp - 1, yp, 411); else - ObjSetMicro(v5, v6, 393); - dArch[v5][v6] = 7; - objects_set_door_piece(v5 - 1, v6); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - DoorSet(param1, v5, v6 - 1); - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; + ObjSetMicro(xp - 1, yp, 50); } + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; RedoPlayerVision(); - return; + } else { + object[oi]._oVar4 = 2; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; -void OperateL2RDoor(int pnum, int oi, unsigned char sendflag) -{ - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] - - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[v8][v5] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 540); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 17); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } - RedoPlayerVision(); +void OperateL1LDoor(int pnum, int oi, BOOL sendflag) +{ + int xp, yp; + + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); return; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); -} -// 676190: using guessed type int deltaload; -void OperateL2LDoor(int pnum, int oi, unsigned char sendflag) -{ - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] - - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[v8][v5] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 538); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 13); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + if (object[oi]._oVar1 == 214) + ObjSetMicro(xp, yp, 408); + else + ObjSetMicro(xp, yp, 393); + dArch[xp][yp] = 7; + objects_set_door_piece(xp - 1, yp); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + DoorSet(oi, xp, yp - 1); + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; RedoPlayerVision(); return; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); -} -// 676190: using guessed type int deltaload; -void OperateL3RDoor(int pnum, int oi, unsigned char sendflag) -{ - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] - - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[v8][v5] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 534); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, xp, object[oi]._oy); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, object[oi]._oVar1); + if (object[oi]._oVar2 != 50) { + ObjSetMicro(xp, yp - 1, object[oi]._oVar2); } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 541); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; + if (dPiece[xp][yp - 1] == 396) + ObjSetMicro(xp, yp - 1, 412); + else + ObjSetMicro(xp, yp - 1, 50); } + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; RedoPlayerVision(); - return; + } else { + object[oi]._oVar4 = 2; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; -void OperateL3LDoor(int pnum, int oi, unsigned char sendflag) -{ - int v3; // esi - int v4; // eax - int v5; // ebx - short param1; // [esp+Ch] [ebp-Ch] - int v7; // [esp+10h] [ebp-8h] - int v8; // [esp+14h] [ebp-4h] - - v3 = oi; - param1 = oi; - v7 = pnum; - v4 = object[oi]._oVar4; - if (v4 != 2) { - v5 = object[v3]._oy; - v8 = object[v3]._ox; - if (v4) { - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, v5); - if (dDead[v8][v5] != 0 || dMonster[v8][v5] != 0 || dItem[v8][v5] != 0) { - object[v3]._oVar4 = 2; - return; - } - if (v7 == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, param1); - object[v3]._oVar4 = 0; - object[v3]._oSelFlag = 3; - ObjSetMicro(v8, v5, 531); - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; - } else { - if (pnum == myplr && sendflag) - NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); - if (!deltaload) - PlaySfxLoc(IS_DOOROPEN, object[v3]._ox, object[v3]._oy); - ObjSetMicro(v8, v5, 538); - object[v3]._oAnimFrame += 2; - object[v3]._oPreFlag = TRUE; - object[v3]._oVar4 = 1; - object[v3]._oSelFlag = 2; - } +void OperateL2RDoor(int pnum, int oi, BOOL sendflag) +{ + int xp, yp; + + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); + return; + } + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + ObjSetMicro(xp, yp, 17); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; RedoPlayerVision(); return; } + if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, yp); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, 540); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } } // 676190: using guessed type int deltaload; -void MonstCheckDoors(int m) +void OperateL2LDoor(int pnum, int oi, BOOL sendflag) { - int i, oi; - int dpx, dpy, mx, my; + int xp, yp; - mx = monster[m]._mx; - my = monster[m]._my; - if (dObject[mx - 1][my - 1] - || dObject[mx][my - 1] + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); + return; + } + + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + ObjSetMicro(xp, yp, 13); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; + RedoPlayerVision(); + return; + } + + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, yp); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, 538); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } +} +// 676190: using guessed type int deltaload; + +void OperateL3RDoor(int pnum, int oi, BOOL sendflag) +{ + int xp, yp; + + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); + return; + } + + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + ObjSetMicro(xp, yp, 541); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; + RedoPlayerVision(); + return; + } + + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, yp); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, 534); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } +} +// 676190: using guessed type int deltaload; + +void OperateL3LDoor(int pnum, int oi, BOOL sendflag) +{ + int xp, yp; + + if (object[oi]._oVar4 == 2) { + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, object[oi]._oy); + return; + } + + xp = object[oi]._ox; + yp = object[oi]._oy; + if (object[oi]._oVar4 == 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_OPENDOOR, oi); + if (!deltaload) + PlaySfxLoc(IS_DOOROPEN, object[oi]._ox, object[oi]._oy); + ObjSetMicro(xp, yp, 538); + object[oi]._oAnimFrame += 2; + object[oi]._oPreFlag = TRUE; + object[oi]._oVar4 = 1; + object[oi]._oSelFlag = 2; + RedoPlayerVision(); + return; + } + + if (!deltaload) + PlaySfxLoc(IS_DOORCLOS, object[oi]._ox, yp); + if (((dDead[xp][yp] != 0 ? 0 : 1) & (dMonster[xp][yp] != 0 ? 0 : 1) & (dItem[xp][yp] != 0 ? 0 : 1)) != 0) { + if (pnum == myplr && sendflag) + NetSendCmdParam1(TRUE, CMD_CLOSEDOOR, oi); + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, 531); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } +} +// 676190: using guessed type int deltaload; + +void MonstCheckDoors(int m) +{ + int i, oi; + int dpx, dpy, mx, my; + + mx = monster[m]._mx; + my = monster[m]._my; + if (dObject[mx - 1][my - 1] + || dObject[mx][my - 1] || dObject[mx + 1][my - 1] || dObject[mx - 1][my] || dObject[mx + 1][my] @@ -2824,88 +2803,76 @@ void OperateLever(int pnum, int i) void OperateBook(int pnum, int i) { - signed int v4; // ecx - int v5; // eax - BOOLEAN v6; // zf - int j; // esi - signed int v11; // [esp+10h] [ebp-10h] - signed int v1; // [esp+14h] [ebp-Ch] - signed int v2; // [esp+18h] [ebp-8h] - int v14; // [esp+1Ch] [ebp-4h] + BOOL do_add_missile; + int oi; + int j; + BOOL missile_added; + int dx, dy; if (!object[i]._oSelFlag) return; - if (!setlevel || setlvlnum != SL_VILEBETRAYER) - goto LABEL_17; - v4 = 0; - v11 = 0; - v14 = 0; - if (nobjects > 0) { - while (1) { - v5 = objectactive[v14]; - if (object[v5]._otype == OBJ_MCIRCLE2) { - if (object[v5]._oVar6 == 1) { - v1 = 27; - v2 = 29; - object[v5]._oVar6 = 4; - v4 = 1; + if (setlevel && setlvlnum == SL_VILEBETRAYER) { + do_add_missile = FALSE; + missile_added = FALSE; + for (j = 0; j < nobjects; j++) { + oi = objectactive[j]; + if (object[oi]._otype == OBJ_MCIRCLE2) { + if (object[oi]._oVar6 == 1) { + dx = 27; + dy = 29; + object[oi]._oVar6 = 4; + do_add_missile = TRUE; } - if (object[v5]._oVar6 == 2) { - v1 = 43; - v2 = 29; - object[v5]._oVar6 = 4; - v4 = 1; + if (object[oi]._oVar6 == 2) { + dx = 43; + dy = 29; + object[oi]._oVar6 = 4; + do_add_missile = TRUE; } } - if (v4) { - ++object[dObject[35][36] - 1]._oVar5; // ++objectavail[30 * dObject[35][36] + 123]; /* fix */ - AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, v1, v2, plr[pnum]._pdir, MIS_RNDTELEPORT, 0, pnum, 0, 0); - v11 = 1; - v4 = 0; + if (do_add_missile) { + object[dObject[35][36] - 1]._oVar5++; + AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, dx, dy, plr[pnum]._pdir, MIS_RNDTELEPORT, 0, pnum, 0, 0); + missile_added = TRUE; + do_add_missile = FALSE; } - if (++v14 >= nobjects) - break; } - if (v11) { - LABEL_17: - ++object[i]._oAnimFrame; - v6 = setlevel == 0; - object[i]._oSelFlag = 0; - if (!v6) { - if (setlvlnum == SL_BONECHAMB) { - 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; - if (!deltaload) - PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); - InitDiabloMsg(EMSG_BONECHAMB); - AddMissile( - plr[myplr].WorldX, - plr[myplr].WorldY, - object[i]._ox - 2, - object[i]._oy - 4, - plr[myplr]._pdir, - MIS_GUARDIAN, - 0, - myplr, - 0, - 0); - } - if (setlevel) { - if (setlvlnum == SL_VILEBETRAYER) { - ObjChangeMapResync( - object[i]._oVar1, - object[i]._oVar2, - object[i]._oVar3, - object[i]._oVar4); - for (j = 0; j < nobjects; ++j) - SyncObjectAnim(objectactive[j]); - } - } - } + if (!missile_added) return; - } + } + object[i]._oAnimFrame++; + object[i]._oSelFlag = 0; + if (setlevel == 0) + return; + + if (setlvlnum == SL_BONECHAMB) { + 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; + if (!deltaload) + PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy); + InitDiabloMsg(EMSG_BONECHAMB); + AddMissile( + plr[myplr].WorldX, + plr[myplr].WorldY, + object[i]._ox - 2, + object[i]._oy - 4, + plr[myplr]._pdir, + MIS_GUARDIAN, + 0, + myplr, + 0, + 0); + } + if (setlevel != 0 && setlvlnum == SL_VILEBETRAYER) { + ObjChangeMapResync( + object[i]._oVar1, + object[i]._oVar2, + object[i]._oVar3, + object[i]._oVar4); + for (j = 0; j < nobjects; j++) + SyncObjectAnim(objectactive[j]); } } // 5CF31D: using guessed type char setlevel; @@ -2982,7 +2949,7 @@ void OperateSChambBk(int pnum, int i) } } -void OperateChest(int pnum, int i, unsigned char sendmsg) +void OperateChest(int pnum, int i, BOOL sendmsg) { int j, mdir, mtype; @@ -3088,7 +3055,7 @@ void OperateInnSignChest(int pnum, int i) } // 676190: using guessed type int deltaload; -void OperateSlainHero(int pnum, int i, unsigned char sendmsg) +void OperateSlainHero(int pnum, int i, BOOL sendmsg) { if (object[i]._oSelFlag) { object[i]._oSelFlag = 0; @@ -3112,46 +3079,37 @@ void OperateSlainHero(int pnum, int i, unsigned char sendmsg) void OperateTrapLvr(int i) { - int v1; // ecx - int v2; // eax - int v3; // esi - int v4; // edx - int v5; // eax - int v6; // eax - - v1 = i; - v2 = object[v1]._oAnimFrame; - v3 = nobjects; - v4 = 0; - if (v2 == 1) { - object[v1]._oAnimFrame = 2; - if (v3 > 0) { - do { - v5 = objectactive[v4]; - if (object[v5]._otype == object[v1]._oVar2 && object[v5]._oVar1 == object[v1]._oVar1) { - object[v5]._oAnimFlag = 0; - object[v5]._oVar2 = 1; - } - ++v4; - } while (v4 < v3); + int frame; + int j; + int oi; + + frame = object[i]._oAnimFrame; + j = 0; + + if (frame == 1) { + object[i]._oAnimFrame = 2; + for (; j < nobjects; j++) { + oi = objectactive[j]; + if (object[oi]._otype == object[i]._oVar2 && object[oi]._oVar1 == object[i]._oVar1) { + object[oi]._oAnimFlag = 0; + object[oi]._oVar2 = 1; + } } - } else { - object[v1]._oAnimFrame = v2 - 1; - if (v3 > 0) { - do { - v6 = objectactive[v4]; - if (object[v6]._otype == object[v1]._oVar2 && object[v6]._oVar1 == object[v1]._oVar1) { - object[v6]._oVar2 = 0; - if (object[v6]._oVar4) - object[v6]._oAnimFlag = 1; - } - ++v4; - } while (v4 < v3); + return; + } + + object[i]._oAnimFrame = frame - 1; + for (; j < nobjects; j++) { + oi = objectactive[j]; + if (object[oi]._otype == object[i]._oVar2 && object[oi]._oVar1 == object[i]._oVar1) { + object[oi]._oVar2 = 0; + if (object[oi]._oVar4 != 0) + object[oi]._oAnimFlag = 1; } } } -void OperateSarc(int pnum, int i, unsigned char sendmsg) +void OperateSarc(int pnum, int i, BOOL sendmsg) { if (object[i]._oSelFlag) { if (!deltaload) @@ -3200,38 +3158,34 @@ void OperateL3Door(int pnum, int i, unsigned char sendflag) void OperatePedistal(int pnum, int i) { - int v2; // esi - int v3; // edi - unsigned char *v4; // edi - int inv_item_num; // [esp+8h] [ebp-4h] + unsigned char *mem; + int iv; - v2 = i; - v3 = pnum; if (object[i]._oVar6 != 3) { - if (PlrHasItem(pnum, 21, &inv_item_num)) { - RemoveInvItem(v3, inv_item_num); - ++object[v2]._oAnimFrame; - ++object[v2]._oVar6; + if (PlrHasItem(pnum, IDI_BLDSTONE, &iv)) { + RemoveInvItem(pnum, iv); + object[i]._oAnimFrame++; + object[i]._oVar6++; } - if (object[v2]._oVar6 == 1) { + if (object[i]._oVar6 == 1) { if (!deltaload) - PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); + PlaySfxLoc(LS_PUDDLE, object[i]._ox, object[i]._oy); ObjChangeMap(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); } - if (object[v2]._oVar6 == 2) { + if (object[i]._oVar6 == 2) { if (!deltaload) - PlaySfxLoc(LS_PUDDLE, object[v2]._ox, object[v2]._oy); + PlaySfxLoc(LS_PUDDLE, object[i]._ox, object[i]._oy); ObjChangeMap(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); } - if (object[v2]._oVar6 == 3) { + if (object[i]._oVar6 == 3) { if (!deltaload) - PlaySfxLoc(LS_BLODSTAR, object[v2]._ox, object[v2]._oy); - ObjChangeMap(object[v2]._oVar1, object[v2]._oVar2, object[v2]._oVar3, object[v2]._oVar4); - v4 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - LoadMapObjs(v4, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v4); + PlaySfxLoc(LS_BLODSTAR, object[i]._ox, object[i]._oy); + ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); + mem = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + LoadMapObjs(mem, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(mem); CreateItem(7, 2 * setpc_x + 25, 2 * setpc_y + 19); - object[v2]._oSelFlag = 0; + object[i]._oSelFlag = 0; } } } @@ -3860,7 +3814,7 @@ void OperateBookCase(int pnum, int i, BOOL sendmsg) } // 676190: using guessed type int deltaload; -void OperateDecap(int pnum, int i, unsigned char sendmsg) +void OperateDecap(int pnum, int i, BOOL sendmsg) { if (object[i]._oSelFlag) { object[i]._oSelFlag = 0; @@ -3948,158 +3902,127 @@ void OperateCauldron(int pnum, int i, int sType) } // 52571C: using guessed type int drawpanflag; -BOOLEAN OperateFountains(int pnum, int i) -{ - unsigned short v2; // bx - int v3; // esi - int v4; // edi - BOOLEAN v5; // bp - signed int v7; // ebx - int v8; // ebp - int v10; // eax - int v11; // esi - int v12; // eax - int v13; // eax - int v14; // edi - int v15; // edx - int v16; // edx - int v17; // ecx - int *v18; // eax - int v19; // ecx - int v20; // edi - int v21; // edx - int v22; // ecx - int v23; // [esp-4h] [ebp-20h] - signed int v24; // [esp+10h] [ebp-Ch] - signed int v25; // [esp+14h] [ebp-8h] - short param1; // [esp+18h] [ebp-4h] +BOOL OperateFountains(int pnum, int i) +{ + BOOL applied; + int prev; + int add; + int rnd; + int cnt; + BOOL done; - v2 = i; - v3 = i; - v4 = pnum; - param1 = i; - v5 = 0; + applied = FALSE; SetRndSeed(object[i]._oRndSeed); - switch (object[v3]._otype) { + switch (object[i]._otype) { case OBJ_BLOODFTN: - if (!deltaload && v4 == myplr) { - v20 = v4; - v23 = object[v3]._oy; - v15 = object[v3]._ox; - if (plr[v20]._pHitPoints < plr[v20]._pMaxHP) { - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - plr[v20]._pHitPoints += 64; - v21 = plr[v20]._pHitPoints; - v22 = plr[v20]._pMaxHP; - v18 = &plr[v20]._pHPBase; - *v18 += 64; - if (v21 <= v22) - goto LABEL_39; - plr[v20]._pHitPoints = v22; - v19 = plr[v20]._pMaxHPBase; - goto LABEL_38; + if (deltaload) + return FALSE; + if (pnum != myplr) + return FALSE; + + if (plr[pnum]._pHitPoints < plr[pnum]._pMaxHP) { + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + plr[pnum]._pHitPoints += 64; + plr[pnum]._pHPBase += 64; + if (plr[pnum]._pHitPoints > plr[pnum]._pMaxHP) { + plr[pnum]._pHitPoints = plr[pnum]._pMaxHP; + plr[pnum]._pHPBase = plr[pnum]._pMaxHPBase; } - LABEL_45: - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - break; - } - return 0; + applied = TRUE; + } else + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + break; case OBJ_PURIFYINGFTN: - if (!deltaload && v4 == myplr) { - v14 = v4; - v23 = object[v3]._oy; - v15 = object[v3]._ox; - if (plr[v14]._pMana < plr[v14]._pMaxMana) { - PlaySfxLoc(LS_FOUNTAIN, v15, v23); - plr[v14]._pMana += 64; - v16 = plr[v14]._pMana; - v17 = plr[v14]._pMaxMana; - v18 = &plr[v14]._pManaBase; - *v18 += 64; - if (v16 <= v17) { - LABEL_39: - v5 = 1; - break; - } - plr[v14]._pMana = v17; - v19 = plr[v14]._pMaxManaBase; - LABEL_38: - *v18 = v19; - goto LABEL_39; + if (deltaload) + return FALSE; + if (pnum != myplr) + return FALSE; + + if (plr[pnum]._pMana < plr[pnum]._pMaxMana) { + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + + plr[pnum]._pMana += 64; + plr[pnum]._pManaBase += 64; + if (plr[pnum]._pMana > plr[pnum]._pMaxMana) { + plr[pnum]._pMana = plr[pnum]._pMaxMana; + plr[pnum]._pManaBase = plr[pnum]._pMaxManaBase; } - goto LABEL_45; - } - return 0; + + applied = TRUE; + } else + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + break; case OBJ_MURKYFTN: - if (object[v3]._oSelFlag) { - if (!deltaload) - PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); - object[v3]._oSelFlag = 0; - if (deltaload) - return 0; - AddMissile( - plr[v4].WorldX, - plr[v4].WorldY, - plr[v4].WorldX, - plr[v4].WorldY, - plr[v4]._pdir, - MIS_INFRA, - -1, - v4, - 0, - 2 * leveltype); - v5 = 1; - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, v2); - } + if (!object[i]._oSelFlag) + break; + if (!deltaload) + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + object[i]._oSelFlag = 0; + if (deltaload) + return FALSE; + AddMissile( + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum].WorldX, + plr[pnum].WorldY, + plr[pnum]._pdir, + MIS_INFRA, + -1, + pnum, + 0, + 2 * leveltype); + applied = TRUE; + if (pnum == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, i); break; - default: - if (object[v3]._otype == OBJ_TEARFTN && object[v3]._oSelFlag) { - v7 = -1; - v8 = -1; - v25 = 0; - v24 = 0; - if (!deltaload) - PlaySfxLoc(LS_FOUNTAIN, object[v3]._ox, object[v3]._oy); - object[v3]._oSelFlag = 0; - if (deltaload || v4 != myplr) - return 0; - do { - v10 = random(0, 4); - v11 = v10; - if (v10 != v7) { - if (v10) { - v12 = v10 - 1; - if (v12) { - v13 = v12 - 1; - if (v13) { - if (v13 == 1) - ModifyPlrVit(v4, v8); - } else { - ModifyPlrDex(v4, v8); - } - } else { - ModifyPlrMag(v4, v8); - } - } else { - ModifyPlrStr(v4, v8); - } - v7 = v11; - v8 = 1; - ++v24; + case OBJ_TEARFTN: + if (!object[i]._oSelFlag) + break; + prev = -1; + add = -1; + done = FALSE; + cnt = 0; + if (!deltaload) + PlaySfxLoc(LS_FOUNTAIN, object[i]._ox, object[i]._oy); + object[i]._oSelFlag = 0; + if (deltaload) + return FALSE; + if (pnum != myplr) + return FALSE; + while (!done) { + rnd = random(0, 4); + if (rnd != prev) { + switch (rnd) { + case 0: + ModifyPlrStr(pnum, add); + break; + case 1: + ModifyPlrMag(pnum, add); + break; + case 2: + ModifyPlrDex(pnum, add); + break; + case 3: + ModifyPlrVit(pnum, add); + break; } - if (v24 > 1) - v25 = 1; - } while (!v25); - CheckStats(v4); - v5 = 1; - if (v4 == myplr) - NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, param1); + prev = rnd; + add = 1; + cnt++; + } + if (cnt <= 1) + continue; + + done = TRUE; } + CheckStats(pnum); + applied = TRUE; + if (pnum == myplr) + NetSendCmdParam1(FALSE, CMD_OPERATEOBJ, i); break; } drawpanflag = 255; - return v5; + return applied; } // 52571C: using guessed type int drawpanflag; // 676190: using guessed type int deltaload; @@ -4168,32 +4091,55 @@ void OperateLazStand(int pnum, int i) void OperateObject(int pnum, int i, BOOL TeleFlag) { - int v3; // esi - int v4; // edi - ObjectStruct *v5; // ebx - int v6; // ecx - BOOLEAN sendmsg; // [esp+Ch] [ebp-4h] + BOOL sendmsg; - v3 = pnum; - v4 = i; - sendmsg = pnum == myplr; - v5 = &object[i]; - v6 = v5->_otype; - switch (v5->_otype) { + sendmsg = (pnum == myplr); + switch (object[i]._otype) { case OBJ_L1LDOOR: case OBJ_L1RDOOR: if (TeleFlag) { - if (v6 == OBJ_L1LDOOR) - OperateL1LDoor(v3, i, OBJ_L1LDOOR); - if (v5->_otype == OBJ_L1RDOOR) - OperateL1RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL1Door(v3, i, 1u); + if (object[i]._otype == OBJ_L1LDOOR) + OperateL1LDoor(pnum, i, 1); + if (object[i]._otype == OBJ_L1RDOOR) + OperateL1RDoor(pnum, i, 1); + break; + } + if (pnum == myplr) + OperateL1Door(pnum, i, 1); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + if (TeleFlag) { + if (object[i]._otype == OBJ_L2LDOOR) + OperateL2LDoor(pnum, i, 1); + if (object[i]._otype == OBJ_L2RDOOR) + OperateL2RDoor(pnum, i, 1); + break; + } + if (pnum == myplr) + OperateL2Door(pnum, i, 1); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + if (TeleFlag) { + if (object[i]._otype == OBJ_L3LDOOR) + OperateL3LDoor(pnum, i, 1); + if (object[i]._otype == OBJ_L3RDOOR) + OperateL3RDoor(pnum, i, 1); + break; } + if (pnum == myplr) + OperateL3Door(pnum, i, 1); break; case OBJ_LEVER: case OBJ_SWITCHSKL: - OperateLever(v3, i); + OperateLever(pnum, i); + break; + case OBJ_BOOK2L: + OperateBook(pnum, i); + break; + case OBJ_BOOK2R: + OperateSChambBk(pnum, i); break; case OBJ_CHEST1: case OBJ_CHEST2: @@ -4201,172 +4147,141 @@ void OperateObject(int pnum, int i, BOOL TeleFlag) case OBJ_TCHEST1: case OBJ_TCHEST2: case OBJ_TCHEST3: - OperateChest(v3, i, sendmsg); - break; - case OBJ_BOOK2L: - OperateBook(v3, i); - break; - case OBJ_BOOK2R: - OperateSChambBk(v3, i); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - if (TeleFlag) { - if (v6 == OBJ_L2LDOOR) - OperateL2LDoor(v3, i, 1u); - if (v5->_otype == OBJ_L2RDOOR) - OperateL2RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL2Door(v3, i, 1u); - } + OperateChest(pnum, i, sendmsg); break; case OBJ_SARC: - OperateSarc(v3, i, sendmsg); + OperateSarc(pnum, i, sendmsg); break; case OBJ_FLAMELVR: OperateTrapLvr(i); break; + case OBJ_BLINDBOOK: + case OBJ_BLOODBOOK: + case OBJ_STEELTOME: + OperateBookLever(pnum, i); + break; case OBJ_SHRINEL: case OBJ_SHRINER: - OperateShrine(v3, i, IS_MAGIC); + OperateShrine(pnum, i, IS_MAGIC); break; case OBJ_SKELBOOK: case OBJ_BOOKSTAND: - OperateSkelBook(v3, i, sendmsg); + OperateSkelBook(pnum, i, sendmsg); break; case OBJ_BOOKCASEL: case OBJ_BOOKCASER: - OperateBookCase(v3, i, sendmsg); - break; - case OBJ_BLOODFTN: - case OBJ_PURIFYINGFTN: - case OBJ_MURKYFTN: - case OBJ_TEARFTN: - OperateFountains(v3, i); + OperateBookCase(pnum, i, sendmsg); break; case OBJ_DECAP: - OperateDecap(v3, i, sendmsg); - break; - case OBJ_BLINDBOOK: - case OBJ_BLOODBOOK: - case OBJ_STEELTOME: - OperateBookLever(v3, i); - break; - case OBJ_PEDISTAL: - OperatePedistal(v3, i); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - if (TeleFlag) { - if (v6 == OBJ_L3LDOOR) - OperateL3LDoor(v3, i, 1u); - if (v5->_otype == OBJ_L3RDOOR) - OperateL3RDoor(v3, v4, 1u); - } else if (v3 == myplr) { - OperateL3Door(v3, i, 1u); - } + OperateDecap(pnum, i, sendmsg); break; case OBJ_ARMORSTAND: case OBJ_WARARMOR: - OperateArmorStand(v3, i, sendmsg); + OperateArmorStand(pnum, i, sendmsg); break; case OBJ_GOATSHRINE: - OperateGoatShrine(v3, i, LS_GSHRINE); + OperateGoatShrine(pnum, i, LS_GSHRINE); break; case OBJ_CAULDRON: - OperateCauldron(v3, i, LS_CALDRON); + OperateCauldron(pnum, i, LS_CALDRON); + break; + case OBJ_BLOODFTN: + case OBJ_PURIFYINGFTN: + case OBJ_MURKYFTN: + case OBJ_TEARFTN: + OperateFountains(pnum, i); break; case OBJ_STORYBOOK: - OperateStoryBook(v3, i); + OperateStoryBook(pnum, i); + break; + case OBJ_PEDISTAL: + OperatePedistal(pnum, i); break; case OBJ_WARWEAP: case OBJ_WEAPONRACK: - OperateWeaponRack(v3, i, sendmsg); + OperateWeaponRack(pnum, i, sendmsg); break; case OBJ_MUSHPATCH: - OperateMushPatch(v3, i); + OperateMushPatch(pnum, i); break; case OBJ_LAZSTAND: - OperateLazStand(v3, i); + OperateLazStand(pnum, i); break; case OBJ_SLAINHERO: - OperateSlainHero(v3, i, sendmsg); + OperateSlainHero(pnum, i, sendmsg); break; case OBJ_SIGNCHEST: - OperateInnSignChest(v3, i); + OperateInnSignChest(pnum, i); break; } } void SyncOpL1Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + BOOL do_sync; - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == 1) - OperateL1LDoor(-1, i, 0); - if (v4->_otype == OBJ_L1RDOOR) - OperateL1RDoor(-1, i, 0); - } + if (pnum == myplr) + return; + + do_sync = FALSE; + if (cmd == CMD_OPENDOOR) { + if (object[i]._oVar4 != 0) + return; + do_sync = TRUE; + } + if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1) + do_sync = TRUE; + if (do_sync) { + if (object[i]._otype == OBJ_L1LDOOR) + OperateL1LDoor(-1, i, 0); + if (object[i]._otype == OBJ_L1RDOOR) + OperateL1RDoor(-1, i, 0); } } void SyncOpL2Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + BOOL do_sync; - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == OBJ_L2LDOOR) - OperateL2LDoor(-1, i, 0); - if (v4->_otype == OBJ_L2RDOOR) - OperateL2RDoor(-1, i, 0); - } + if (pnum == myplr) + return; + + do_sync = FALSE; + if (cmd == CMD_OPENDOOR) { + if (object[i]._oVar4 != 0) + return; + do_sync = TRUE; + } + if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1) + do_sync = TRUE; + if (do_sync) { + if (object[i]._otype == OBJ_L2LDOOR) + OperateL2LDoor(-1, i, 0); + if (object[i]._otype == OBJ_L2RDOOR) + OperateL2RDoor(-1, i, 0); } } void SyncOpL3Door(int pnum, int cmd, int i) { - signed int v3; // eax - ObjectStruct *v4; // esi + BOOL do_sync; - if (pnum != myplr) { - v3 = 0; - if (cmd == 43) { - if (object[i]._oVar4) - return; - v3 = 1; - } - if (cmd == 44 && object[i]._oVar4 == 1) - v3 = 1; - if (v3) { - v4 = &object[i]; - if (v4->_otype == OBJ_L3LDOOR) - OperateL3LDoor(-1, i, 0); - if (v4->_otype == OBJ_L3RDOOR) - OperateL3RDoor(-1, i, 0); - } + if (pnum == myplr) + return; + + do_sync = FALSE; + if (cmd == CMD_OPENDOOR) { + if (object[i]._oVar4 != 0) + return; + do_sync = TRUE; + } + if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1) + do_sync = TRUE; + if (do_sync) { + if (object[i]._otype == OBJ_L3LDOOR) + OperateL2LDoor(-1, i, 0); + if (object[i]._otype == OBJ_L3RDOOR) + OperateL2RDoor(-1, i, 0); } } @@ -4377,6 +4292,14 @@ void SyncOpObject(int pnum, int cmd, int i) case OBJ_L1RDOOR: SyncOpL1Door(pnum, cmd, i); break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + SyncOpL2Door(pnum, cmd, i); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + SyncOpL3Door(pnum, cmd, i); + break; case OBJ_LEVER: case OBJ_SWITCHSKL: OperateLever(pnum, i); @@ -4387,14 +4310,15 @@ void SyncOpObject(int pnum, int cmd, int i) case OBJ_TCHEST1: case OBJ_TCHEST2: case OBJ_TCHEST3: - OperateChest(pnum, i, 0); - break; - case OBJ_L2LDOOR: - case OBJ_L2RDOOR: - SyncOpL2Door(pnum, cmd, i); + OperateChest(pnum, i, FALSE); break; case OBJ_SARC: - OperateSarc(pnum, i, 0); + OperateSarc(pnum, i, FALSE); + break; + case OBJ_BLINDBOOK: + case OBJ_BLOODBOOK: + case OBJ_STEELTOME: + OperateBookLever(pnum, i); break; case OBJ_SHRINEL: case OBJ_SHRINER: @@ -4411,18 +4335,6 @@ void SyncOpObject(int pnum, int cmd, int i) case OBJ_DECAP: OperateDecap(pnum, i, 0); break; - case OBJ_BLINDBOOK: - case OBJ_BLOODBOOK: - case OBJ_STEELTOME: - OperateBookLever(pnum, i); - break; - case OBJ_PEDISTAL: - OperatePedistal(pnum, i); - break; - case OBJ_L3LDOOR: - case OBJ_L3RDOOR: - SyncOpL3Door(pnum, cmd, i); - break; case OBJ_ARMORSTAND: case OBJ_WARARMOR: OperateArmorStand(pnum, i, 0); @@ -4440,6 +4352,9 @@ void SyncOpObject(int pnum, int cmd, int i) case OBJ_STORYBOOK: OperateStoryBook(pnum, i); break; + case OBJ_PEDISTAL: + OperatePedistal(pnum, i); + break; case OBJ_WARWEAP: case OBJ_WEAPONRACK: OperateWeaponRack(pnum, i, FALSE); @@ -4448,7 +4363,7 @@ void SyncOpObject(int pnum, int cmd, int i) OperateMushPatch(pnum, i); break; case OBJ_SLAINHERO: - OperateSlainHero(pnum, i, 0); + OperateSlainHero(pnum, i, FALSE); break; case OBJ_SIGNCHEST: OperateInnSignChest(pnum, i); @@ -4458,255 +4373,187 @@ void SyncOpObject(int pnum, int cmd, int i) void BreakCrux(int i) { - int v1; // esi - int v2; // edi - int v3; // edx - signed int v4; // eax - int v5; // ecx - int v6; // ebx - - v1 = i; - v2 = nobjects; - object[v1]._oBreak = -1; - object[v1]._oSelFlag = 0; - v3 = 0; - v4 = 1; - object[v1]._oAnimFlag = 1; - object[v1]._oAnimFrame = 1; - object[v1]._oAnimDelay = 1; - object[v1]._oSolidFlag = TRUE; - object[v1]._oMissFlag = TRUE; - if (v2 <= 0) - goto LABEL_15; - do { - v5 = objectactive[v3]; - v6 = object[v5]._otype; - if ((v6 == OBJ_CRUX1 || v6 == OBJ_CRUX2 || v6 == OBJ_CRUX3) - && object[v1]._oVar8 == object[v5]._oVar8 - && object[v5]._oBreak != -1) { - v4 = 0; - } - ++v3; - } while (v3 < v2); - if (v4) { - LABEL_15: - if (!deltaload) - PlaySfxLoc(IS_LEVER, object[v1]._ox, object[v1]._oy); - ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + int j, oi; + BOOL triggered; + + object[i]._oBreak = -1; + object[i]._oSelFlag = 0; + object[i]._oAnimFlag = 1; + object[i]._oAnimFrame = 1; + object[i]._oAnimDelay = 1; + object[i]._oSolidFlag = TRUE; + object[i]._oMissFlag = TRUE; + triggered = TRUE; + for (j = 0; j < nobjects; j++) { + oi = objectactive[j]; + if (object[oi]._otype != OBJ_CRUX1 && object[oi]._otype != OBJ_CRUX2 && object[oi]._otype != OBJ_CRUX3) + continue; + if (object[i]._oVar8 != object[oi]._oVar8 || object[oi]._oBreak == -1) + continue; + triggered = FALSE; } + if (!triggered) + return; + if (!deltaload) + PlaySfxLoc(IS_LEVER, object[i]._ox, object[i]._oy); + ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); } // 676190: using guessed type int deltaload; -void BreakBarrel(int pnum, int i, int dam, unsigned char forcebreak, int sendmsg) -{ - int v5; // esi - BOOLEAN v6; // zf - int v7; // eax - int v8; // edx - int v9; // eax - int v10; // eax - int v11; // eax - char v12; // al - char v13; // al - int v14; // edx - int v15; // [esp-4h] [ebp-24h] - short param2; // [esp+Ch] [ebp-14h] - int param1; // [esp+10h] [ebp-10h] - int v18; // [esp+14h] [ebp-Ch] - int *v19; // [esp+18h] [ebp-8h] - int v20; // [esp+1Ch] [ebp-4h] - int forcebreaka; // [esp+2Ch] [ebp+Ch] - - param2 = i; - v5 = i; - param1 = pnum; - if (object[i]._oSelFlag) { - if (forcebreak) { - object[v5]._oVar1 = 0; - } else { - object[v5]._oVar1 -= dam; - if (pnum != myplr && object[v5]._oVar1 <= 0) - object[v5]._oVar1 = 1; - } - if (object[v5]._oVar1 <= 0) { - object[v5]._oBreak = -1; - v6 = deltaload == 0; - object[v5]._oVar1 = 0; - object[v5]._oAnimFlag = 1; - object[v5]._oAnimFrame = 1; - object[v5]._oAnimDelay = 1; - object[v5]._oSolidFlag = FALSE; - object[v5]._oMissFlag = TRUE; - object[v5]._oSelFlag = 0; - object[v5]._oPreFlag = TRUE; - if (v6) { - v8 = object[v5]._ox; - v15 = object[v5]._oy; - if (object[v5]._otype == OBJ_BARRELEX) { - PlaySfxLoc(IS_BARLFIRE, v8, v15); - v9 = object[v5]._oy; - v20 = v9 - 1; - if (v9 - 1 <= v9 + 1) { - do { - v10 = object[v5]._ox; - v18 = v10 - 1; - if (v10 - 1 <= v10 + 1) { - forcebreaka = 112 * (v10 - 1) + v20; - v19 = (int *)((char *)dMonster + 4 * forcebreaka); - do { - v11 = *v19; - if (*v19 > 0) - MonsterTrapHit(v11 - 1, 1, 4, 0, 1, 0); - v12 = dPlayer[0][forcebreaka]; - if (v12 > 0) - PlayerMHit(v12 - 1, -1, 0, 8, 16, 1, 0, 0); - v13 = dObject[0][forcebreaka]; - if (v13 > 0) { - v14 = v13 - 1; - if (object[v14]._otype == OBJ_BARRELEX && object[v14]._oBreak != -1) - BreakBarrel(param1, v14, dam, 1u, sendmsg); - } - ++v18; - v19 += 112; - forcebreaka += 112; - } while (v18 <= object[v5]._ox + 1); - } - ++v20; - } while (v20 <= object[v5]._oy + 1); - } - } else { - PlaySfxLoc(IS_BARREL, v8, v15); - SetRndSeed(object[v5]._oRndSeed); - if (object[v5]._oVar2 <= 1) { - if (object[v5]._oVar3) - CreateRndItem(object[v5]._ox, object[v5]._oy, 0, sendmsg, 0); - else - CreateRndUseful(param1, object[v5]._ox, object[v5]._oy, sendmsg); - } - if (object[v5]._oVar2 >= 8) - SpawnSkeleton(object[v5]._oVar4, object[v5]._ox, object[v5]._oy); +void BreakBarrel(int pnum, int i, int dam, BOOL forcebreak, int sendmsg) +{ + int oi; + int xp, yp; + + if (!object[i]._oSelFlag) + return; + if (forcebreak) { + object[i]._oVar1 = 0; + } else { + object[i]._oVar1 -= dam; + if (pnum != myplr && object[i]._oVar1 <= 0) + object[i]._oVar1 = 1; + } + if (object[i]._oVar1 > 0) { + if (deltaload) + return; + + PlaySfxLoc(IS_IBOW, object[i]._ox, object[i]._oy); + return; + } + + object[i]._oBreak = -1; + object[i]._oVar1 = 0; + object[i]._oAnimFlag = 1; + object[i]._oAnimFrame = 1; + object[i]._oAnimDelay = 1; + object[i]._oSolidFlag = FALSE; + object[i]._oMissFlag = TRUE; + object[i]._oSelFlag = 0; + object[i]._oPreFlag = TRUE; + if (deltaload != 0) { + object[i]._oAnimCnt = 0; + object[i]._oAnimFrame = object[i]._oAnimLen; + object[i]._oAnimDelay = 1000; + return; + } + + if (object[i]._otype == OBJ_BARRELEX) { + PlaySfxLoc(IS_BARLFIRE, object[i]._ox, object[i]._oy); + for (yp = object[i]._oy - 1; yp <= object[i]._oy + 1; yp++) { + for (xp = object[i]._ox - 1; xp <= object[i]._ox + 1; xp++) { + if (dMonster[xp][yp] > 0) + MonsterTrapHit(dMonster[xp][yp] - 1, 1, 4, 0, 1, 0); + if (dPlayer[xp][yp] > 0) + PlayerMHit(dPlayer[xp][yp] - 1, -1, 0, 8, 16, 1, 0, 0); + if (dObject[xp][yp] > 0) { + oi = dObject[xp][yp] - 1; + if (object[oi]._otype == OBJ_BARRELEX && object[oi]._oBreak != -1) + BreakBarrel(pnum, oi, dam, TRUE, sendmsg); } - if (param1 == myplr) - NetSendCmdParam2(FALSE, CMD_BREAKOBJ, param1, param2); - } else { - v7 = object[v5]._oAnimLen; - object[v5]._oAnimCnt = 0; - object[v5]._oAnimFrame = v7; - object[v5]._oAnimDelay = 1000; } - } else if (!deltaload) { - PlaySfxLoc(IS_IBOW, object[v5]._ox, object[v5]._oy); } + } else { + PlaySfxLoc(IS_BARREL, object[i]._ox, object[i]._oy); + SetRndSeed(object[i]._oRndSeed); + if (object[i]._oVar2 <= 1) { + if (!object[i]._oVar3) + CreateRndUseful(pnum, object[i]._ox, object[i]._oy, sendmsg); + else + CreateRndItem(object[i]._ox, object[i]._oy, 0, sendmsg, 0); + } + if (object[i]._oVar2 >= 8) + SpawnSkeleton(object[i]._oVar4, object[i]._ox, object[i]._oy); } + if (pnum == myplr) + NetSendCmdParam2(FALSE, CMD_BREAKOBJ, pnum, i); } // 676190: using guessed type int deltaload; void BreakObject(int pnum, int oi) { - int v2; // ebx - int v3; // ebp - int v4; // esi - int v5; // edi - int v6; // ecx - int v7; // ecx - int v8; // eax - - v2 = pnum; - v3 = oi; - if (pnum == -1) { - v7 = 10; + int objdam, mind, maxd; + + if (pnum != -1) { + mind = plr[pnum]._pIMinDam; + maxd = random(163, plr[pnum]._pIMaxDam - mind + 1); + objdam = maxd + mind; + objdam += plr[pnum]._pDamageMod + plr[pnum]._pIBonusDamMod + objdam * plr[pnum]._pIBonusDam / 100; } else { - v4 = pnum; - v5 = plr[v2]._pIMinDam; - v6 = v5 + random(163, plr[v2]._pIMaxDam - v5 + 1); - v7 = plr[v4]._pIBonusDamMod + plr[v4]._pDamageMod + v6 * plr[v4]._pIBonusDam / 100 + v6; - } - v8 = object[v3]._otype; - if (v8 >= OBJ_CRUX1) { - if (v8 <= OBJ_CRUX3) { - BreakCrux(v3); - } else if (v8 > OBJ_WEAPRACK && v8 <= OBJ_BARRELEX) { - BreakBarrel(v2, v3, v7, 0, 1); - } + objdam = 10; + } + switch (object[oi]._otype) { + case OBJ_CRUX1: + case OBJ_CRUX2: + case OBJ_CRUX3: + BreakCrux(oi); + break; + case OBJ_BARREL: + case OBJ_BARRELEX: + BreakBarrel(pnum, oi, objdam, 0, 1); + break; } } void SyncBreakObj(int pnum, int oi) { - int v2; // eax - - v2 = object[oi]._otype; - if (v2 >= OBJ_BARREL && v2 <= OBJ_BARRELEX) - BreakBarrel(pnum, oi, 0, 1u, 0); + if (object[oi]._otype >= OBJ_BARREL && object[oi]._otype <= OBJ_BARRELEX) + BreakBarrel(pnum, oi, 0, TRUE, 0); } void SyncL1Doors(int i) { - int v1; // ebx - int v2; // eax - int v3; // esi - int v4; // edi - BOOLEAN v5; // zf + int x, y; - v1 = i; - v2 = i; - if (object[i]._oVar4) { - v3 = object[v2]._oy; - v4 = object[v2]._ox; - v5 = object[v2]._otype == 1; - object[v2]._oMissFlag = TRUE; - object[v2]._oSelFlag = 2; - if (v5) { - if (object[v2]._oVar1 == 214) - ObjSetMicro(v4, v3, 408); - else - ObjSetMicro(v4, v3, 393); - dArch[v4][v3] = 7; - objects_set_door_piece(v4 - 1, v3--); - } else { - ObjSetMicro(v4, v3, 395); - dArch[v4][v3] = 8; - objects_set_door_piece(v4--, v3 - 1); - } - DoorSet(v1, v4, v3); + if (object[i]._oVar4 != 0) { + object[i]._oMissFlag = FALSE; + return; + } + + y = object[i]._oy; + x = object[i]._ox; + object[i]._oMissFlag = TRUE; + object[i]._oSelFlag = 2; + if (object[i]._otype == OBJ_L1LDOOR) { + if (object[i]._oVar1 == 214) + ObjSetMicro(x, y, 408); + else + ObjSetMicro(x, y, 393); + dArch[x][y] = 7; + objects_set_door_piece(x - 1, y); + y--; } else { - object[v2]._oMissFlag = FALSE; + ObjSetMicro(x, y, 395); + dArch[x][y] = 8; + objects_set_door_piece(x, y - 1); + x--; } + DoorSet(i, x, y); } void SyncCrux(int i) { - signed int v1; // ebx - int v2; // edx - int v3; // eax - int v4; // esi + BOOL found; + int j, oi, type; - v1 = 1; - v2 = 0; - if (nobjects <= 0) - goto LABEL_13; - do { - v3 = objectactive[v2]; - v4 = object[v3]._otype; - if ((v4 == OBJ_CRUX1 || v4 == OBJ_CRUX2 || v4 == OBJ_CRUX3) - && object[i]._oVar8 == object[v3]._oVar8 - && object[v3]._oBreak != -1) { - v1 = 0; - } - ++v2; - } while (v2 < nobjects); - if (v1) - LABEL_13: + found = TRUE; + for (j = 0; j < nobjects; j++) { + oi = objectactive[j]; + type = object[oi]._otype; + if (type != OBJ_CRUX1 && type != OBJ_CRUX2 && type != OBJ_CRUX3) + continue; + if (object[i]._oVar8 != object[oi]._oVar8 || object[oi]._oBreak == -1) + continue; + found = FALSE; + } + if (found) ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); } void SyncLever(int i) { - int v1; // ecx - - v1 = i; - if (!object[v1]._oSelFlag) - ObjChangeMap(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); + if (!object[i]._oSelFlag) + ObjChangeMap(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); } void SyncQSTLever(int i) @@ -4726,158 +4573,125 @@ void SyncQSTLever(int i) void SyncPedistal(int i) { - int v1; // esi - unsigned char *v2; // esi + BYTE *setp; - v1 = i; if (object[i]._oVar6 == 1) ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - if (object[v1]._oVar6 == 2) { + if (object[i]._oVar6 == 2) { ObjChangeMapResync(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); ObjChangeMapResync(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); } - if (object[v1]._oVar6 == 3) { - ObjChangeMapResync(object[v1]._oVar1, object[v1]._oVar2, object[v1]._oVar3, object[v1]._oVar4); - v2 = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); - LoadMapObjs(v2, 2 * setpc_x, 2 * setpc_y); - mem_free_dbg(v2); + if (object[i]._oVar6 == 3) { + ObjChangeMapResync(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4); + setp = LoadFileInMem("Levels\\L2Data\\Blood2.DUN", 0); + LoadMapObjs(setp, 2 * setpc_x, 2 * setpc_y); + mem_free_dbg(setp); } } // 5CF334: using guessed type int setpc_w; void SyncL2Doors(int i) { - int v1; // eax - int v2; // esi - int v3; // ecx - int v4; // edx - int v5; // eax + int val; + int x, y; - v1 = i; - v2 = object[i]._oVar4; - if (v2) - object[v1]._oMissFlag = TRUE; + val = object[i]._oVar4; + if (!val) + object[i]._oMissFlag = FALSE; else - object[v1]._oMissFlag = FALSE; - v3 = object[v1]._ox; - v4 = object[v1]._oy; - object[v1]._oSelFlag = 2; - v5 = object[v1]._otype; - if (v5 != OBJ_L2LDOOR) - goto LABEL_18; - if (!v2) { - ObjSetMicro(v3, v4, 538); + object[i]._oMissFlag = TRUE; + x = object[i]._ox; + y = object[i]._oy; + object[i]._oSelFlag = 2; + if (object[i]._otype == OBJ_L2LDOOR && val == 0) { + ObjSetMicro(x, y, 538); return; } - if (v2 != 1 && v2 != 2) { - LABEL_18: - if (v5 == OBJ_L2RDOOR) { - if (v2) { - if (v2 == 1 || v2 == 2) - ObjSetMicro(v3, v4, 17); - } else { - ObjSetMicro(v3, v4, 540); - } - } - } else { - ObjSetMicro(v3, v4, 13); + if (object[i]._otype == OBJ_L2LDOOR && (val == 1 || val == 2)) { + ObjSetMicro(x, y, 13); + return; + } + if (object[i]._otype == OBJ_L2RDOOR && val == 0) { + ObjSetMicro(x, y, 540); + return; + } + if (object[i]._otype == OBJ_L2RDOOR && (val == 1 || val == 2)) { + ObjSetMicro(x, y, 17); } } void SyncL3Doors(int i) { - int v1; // eax - int v2; // esi - int v3; // ecx - int v4; // edx - int v5; // ebx - int v6; // eax - - v1 = i; - v2 = object[i]._otype; - v3 = object[i]._ox; - v4 = object[v1]._oy; - object[v1]._oMissFlag = TRUE; - object[v1]._oSelFlag = 2; - if (v2 != OBJ_L3LDOOR) - goto LABEL_15; - if (!object[v1]._oVar4) { - ObjSetMicro(v3, v4, 531); + int x, y; + + object[i]._oMissFlag = TRUE; + x = object[i]._ox; + y = object[i]._oy; + object[i]._oSelFlag = 2; + if (object[i]._otype == OBJ_L3LDOOR && object[i]._oVar4 == 0) { + ObjSetMicro(x, y, 531); return; } - v5 = object[v1]._oVar4; - if (v5 != 1 && v5 != 2) { - LABEL_15: - if (v2 == OBJ_L3RDOOR) { - if (object[v1]._oVar4) { - v6 = object[v1]._oVar4; - if (v6 == 1 || v6 == 2) - ObjSetMicro(v3, v4, 541); - } else { - ObjSetMicro(v3, v4, 534); - } - } - } else { - ObjSetMicro(v3, v4, 538); + if (object[i]._otype == OBJ_L3LDOOR && (object[i]._oVar4 == 1 || object[i]._oVar4 == 2)) { + ObjSetMicro(x, y, 538); + return; + } + if (object[i]._otype == OBJ_L3RDOOR && object[i]._oVar4 == 0) { + ObjSetMicro(x, y, 534); + return; + } + if (object[i]._otype == OBJ_L3RDOOR && (object[i]._oVar4 == 1 || object[i]._oVar4 == 2)) { + ObjSetMicro(x, y, 541); } } void SyncObjectAnim(int o) { - int v1; // edx - int v2; // ebx - int v3; // esi - - v1 = object[o]._otype; - v2 = ObjFileList[0]; - v3 = 0; - while (v2 != (char)AllObjects[object[o]._otype].ofindex) - v2 = ObjFileList[v3++ + 1]; - object[o]._oAnimData = pObjCels[v3]; - if (v1 <= OBJ_BOOK2R) { - if (v1 != OBJ_BOOK2R) { - if (v1 > OBJ_L1LIGHT) { - if (v1 <= OBJ_L1RDOOR) { - SyncL1Doors(o); - } else { - if (v1 == OBJ_LEVER) - goto LABEL_30; - if (v1 > OBJ_SKSTICK5) { - if (v1 <= OBJ_CRUX3) { - SyncCrux(o); - return; - } - if (v1 == OBJ_BOOK2L || v1 == OBJ_SWITCHSKL) - LABEL_30: - SyncLever(o); - } - } - } - return; - } - LABEL_24: - SyncQSTLever(o); - return; + int file; + int i; + int ofindex; + + file = ObjFileList[0]; + ofindex = AllObjects[object[o]._otype].ofindex; + i = 0; + while (file != ofindex) { + file = ObjFileList[i + 1]; + i++; } - if (v1 >= OBJ_L2LDOOR) { - if (v1 <= OBJ_L2RDOOR) { - SyncL2Doors(o); - return; - } - if (v1 == OBJ_BLINDBOOK) - goto LABEL_24; - if (v1 == OBJ_PEDISTAL) { - SyncPedistal(o); - return; - } - if (v1 > OBJ_PEDISTAL) { - if (v1 <= OBJ_L3RDOOR) { - SyncL3Doors(o); - return; - } - if (v1 == OBJ_STEELTOME) - goto LABEL_24; - } + object[o]._oAnimData = pObjCels[i]; + switch (object[o]._otype) { + case OBJ_BOOK2R: + case OBJ_BLINDBOOK: + case OBJ_STEELTOME: + SyncQSTLever(o); + break; + case OBJ_L1LIGHT: + break; + case OBJ_L1LDOOR: + case OBJ_L1RDOOR: + SyncL1Doors(o); + break; + case OBJ_L2LDOOR: + case OBJ_L2RDOOR: + SyncL2Doors(o); + break; + case OBJ_L3LDOOR: + case OBJ_L3RDOOR: + SyncL3Doors(o); + break; + case OBJ_LEVER: + case OBJ_BOOK2L: + case OBJ_SWITCHSKL: + SyncLever(o); + break; + case OBJ_CRUX1: + case OBJ_CRUX2: + case OBJ_CRUX3: + SyncCrux(o); + break; + case OBJ_PEDISTAL: + SyncPedistal(o); + break; } } diff --git a/Source/objects.h b/Source/objects.h index 670a789b3..4ca48534c 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -54,17 +54,23 @@ void AddL3Door(int i, int x, int y, int ot); void AddSarc(int i); void AddFlameTrap(int i); void AddFlameLvr(int i); -void AddTrap(int i); +void AddTrap(int i, int t); void AddObjLight(int i, int r); -void AddBarrel(int i); +void AddBarrel(int i, int t); void AddShrine(int i); void AddBookcase(int i); void AddPurifyingFountain(int i); void AddArmorStand(int i); +void AddGoatShrine(int i); +void AddCauldron(int i); +void AddMurkyFountain(int i); +void AddTearFountain(int i); void AddDecap(int i); void AddVilebook(int i); void AddMagicCircle(int i); +void AddBrnCross(int i); void AddBookstand(int i); +void AddBloodFtn(int i); void AddPedistal(int i); void AddStoryBook(int i); void AddWeaponRack(int i); @@ -90,12 +96,12 @@ void ObjL1Special(int x1, int y1, int x2, int y2); void ObjL2Special(int x1, int y1, int x2, int y2); void DoorSet(int oi, int dx, int dy); void RedoPlayerVision(); -void OperateL1RDoor(int pnum, int oi, unsigned char sendflag); -void OperateL1LDoor(int pnum, int oi, unsigned char sendflag); -void OperateL2RDoor(int pnum, int oi, unsigned char sendflag); -void OperateL2LDoor(int pnum, int oi, unsigned char sendflag); -void OperateL3RDoor(int pnum, int oi, unsigned char sendflag); -void OperateL3LDoor(int pnum, int oi, unsigned char sendflag); +void OperateL1RDoor(int pnum, int oi, BOOL sendflag); +void OperateL1LDoor(int pnum, int oi, BOOL sendflag); +void OperateL2RDoor(int pnum, int oi, BOOL sendflag); +void OperateL2LDoor(int pnum, int oi, BOOL sendflag); +void OperateL3RDoor(int pnum, int oi, BOOL sendflag); +void OperateL3LDoor(int pnum, int oi, BOOL sendflag); void MonstCheckDoors(int m); void ObjChangeMap(int x1, int y1, int x2, int y2); void ObjChangeMapResync(int x1, int y1, int x2, int y2); @@ -104,12 +110,12 @@ void OperateLever(int pnum, int i); void OperateBook(int pnum, int i); void OperateBookLever(int pnum, int i); void OperateSChambBk(int pnum, int i); -void OperateChest(int pnum, int i, unsigned char sendmsg); +void OperateChest(int pnum, int i, BOOL sendmsg); void OperateMushPatch(int pnum, int i); void OperateInnSignChest(int pnum, int i); -void OperateSlainHero(int pnum, int i, unsigned char sendmsg); +void OperateSlainHero(int pnum, int i, BOOL sendmsg); void OperateTrapLvr(int i); -void OperateSarc(int pnum, int i, unsigned char sendmsg); +void OperateSarc(int pnum, int i, BOOL sendmsg); void OperateL2Door(int pnum, int i, unsigned char sendflag); void OperateL3Door(int pnum, int i, unsigned char sendflag); void OperatePedistal(int pnum, int i); @@ -118,12 +124,12 @@ int ItemMiscIdIdx(int imiscid); void OperateShrine(int pnum, int i, int sType); void OperateSkelBook(int pnum, int i, BOOL sendmsg); void OperateBookCase(int pnum, int i, BOOL sendmsg); -void OperateDecap(int pnum, int i, unsigned char sendmsg); +void OperateDecap(int pnum, int i, BOOL sendmsg); void OperateArmorStand(int pnum, int i, BOOL sendmsg); int FindValidShrine(int i); void OperateGoatShrine(int pnum, int i, int sType); void OperateCauldron(int pnum, int i, int sType); -BOOLEAN OperateFountains(int pnum, int i); +BOOL OperateFountains(int pnum, int i); void OperateWeaponRack(int pnum, int i, BOOL sendmsg); void OperateStoryBook(int pnum, int i); void OperateLazStand(int pnum, int i); @@ -133,7 +139,7 @@ void SyncOpL2Door(int pnum, int cmd, int i); void SyncOpL3Door(int pnum, int cmd, int i); void SyncOpObject(int pnum, int cmd, int i); void BreakCrux(int i); -void BreakBarrel(int pnum, int i, int dam, unsigned char forcebreak, int sendmsg); +void BreakBarrel(int pnum, int i, int dam, BOOL forcebreak, int sendmsg); void BreakObject(int pnum, int oi); void SyncBreakObj(int pnum, int oi); void SyncL1Doors(int i); diff --git a/Source/pack.cpp b/Source/pack.cpp index 0cd5c11ab..df1fc525a 100644 --- a/Source/pack.cpp +++ b/Source/pack.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/palette.cpp b/Source/palette.cpp index 23cd484b9..e15e32396 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -1,5 +1,5 @@ -//HEADER_GOES_HERE -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -39,8 +39,10 @@ void palette_init() #else error_code = lpDDSPrimary->lpVtbl->SetPalette(lpDDSPrimary, lpDDPalette); #endif +#ifndef RGBMODE if (error_code) ErrDlg(IDD_DIALOG8, error_code, "C:\\Src\\Diablo\\Source\\PALETTE.CPP", 146); +#endif } void LoadGamma() diff --git a/Source/path.cpp b/Source/path.cpp index 4ce00ea82..d8a3078e3 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/pfile.cpp b/Source/pfile.cpp index 3be728734..20ece7d5e 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" DEVILUTION_BEGIN_NAMESPACE @@ -106,7 +106,7 @@ BOOL pfile_open_archive(BOOL a1, unsigned int save_num) return TRUE; if (a1 && gbMaxPlayers > 1) - mpqapi_update_multi_creation_time(save_num); + mpqapi_store_default_time(save_num); return FALSE; } diff --git a/Source/player.cpp b/Source/player.cpp index 020e3d7c8..da1f427c6 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -355,39 +354,19 @@ DWORD GetPlrGFXSize(char *szCel) void FreePlayerGFX(int pnum) { - void *ptr; - if ((DWORD)pnum >= MAX_PLRS) { app_fatal("FreePlayerGFX: illegal player %d", pnum); } - ptr = plr[pnum]._pNData; - plr[pnum]._pNData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pWData; - plr[pnum]._pWData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pAData; - plr[pnum]._pAData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pHData; - plr[pnum]._pHData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pLData; - plr[pnum]._pLData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pFData; - plr[pnum]._pFData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pTData; - plr[pnum]._pTData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pDData; - plr[pnum]._pDData = NULL; - mem_free_dbg(ptr); - ptr = plr[pnum]._pBData; - plr[pnum]._pBData = NULL; - mem_free_dbg(ptr); + MemFreeDbg(plr[pnum]._pNData); + MemFreeDbg(plr[pnum]._pWData); + MemFreeDbg(plr[pnum]._pAData); + MemFreeDbg(plr[pnum]._pHData); + MemFreeDbg(plr[pnum]._pLData); + MemFreeDbg(plr[pnum]._pFData); + MemFreeDbg(plr[pnum]._pTData); + MemFreeDbg(plr[pnum]._pDData); + MemFreeDbg(plr[pnum]._pBData); plr[pnum]._pGFXLoad = 0; } diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index b6c0c8a02..40b5e4b02 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/portal.cpp b/Source/portal.cpp index b6cf18672..a40f032bc 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/quests.cpp b/Source/quests.cpp index 1c192744c..cabfdddd1 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/render.cpp b/Source/render.cpp index ca2e48091..57f2f752d 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -1,8 +1,7 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE + #include "_asm.cpp" int WorldBoolFlag = 0; @@ -115,7 +114,7 @@ int WorldTbl17_2[17] = { 0, 32, 60, 88, 112, 136, 156, 176, 192, 208, 220, 232, |/ */ -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM #include "_render.cpp" #else void drawTopArchesUpperScreen(BYTE *pBuff) diff --git a/Source/restrict.cpp b/Source/restrict.cpp index 5d981b5c0..e7b972506 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 51ca254cd..5b05487ec 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -2130,7 +2129,7 @@ void DrawZoom(int x, int y) /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, gpBuffer mov edx, nDstOff @@ -2195,7 +2194,7 @@ void ClearScreenBuffer() /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, gpBuffer add edi, SCREENXY(0, 0) @@ -2636,16 +2635,16 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) } } else { nSrcOff = SCREENXY(dwX, dwY); - nDstOff = dwX + dwY * DDS_desc.lPitch; + nDstOff = dwX * (SCREEN_BPP / 8) + dwY * DDS_desc.lPitch; nSrcWdt = BUFFER_WIDTH - dwWdt; - nDstWdt = DDS_desc.lPitch - dwWdt; + nDstWdt = DDS_desc.lPitch - dwWdt * (SCREEN_BPP / 8); dwWdt >>= 2; lock_buf(6); /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#if defined(USE_ASM) && !defined(RGBMODE) __asm { mov esi, gpBuffer mov edi, DDS_desc.lpSurface @@ -2671,7 +2670,15 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) for (hgt = 0; hgt < dwHgt; hgt++, src += nSrcWdt, dst += nDstWdt) { for (wdt = 0; wdt < 4 * dwWdt; wdt++) { +#ifndef RGBMODE *dst++ = *src++; +#else + PALETTEENTRY pal = system_palette[*src++]; + dst[0] = pal.peBlue; + dst[1] = pal.peGreen; + dst[2] = pal.peRed; + dst += 4; +#endif } } #endif diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 998237ae7..3db21409d 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/sha.cpp b/Source/sha.cpp index 7d0d16f8c..25a751663 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/sound.cpp b/Source/sound.cpp index ab1d1a85a..88d7e5c25 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/spells.cpp b/Source/spells.cpp index ca848cb76..f8a6594b5 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/stores.cpp b/Source/stores.cpp index cd24f5bdd..885927cb3 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -20,7 +18,7 @@ int InStoreFlag; // idb ItemStruct storehold[48]; int gossipstart; // weak ItemStruct witchitem[20]; -int stextscrl; +BOOL stextscrl; int numpremium; // idb ItemStruct healitem[20]; ItemStruct golditem; @@ -78,7 +76,7 @@ char *talkname[9] = { void InitStores() { - int i; // eax + int i; pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0); pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0); @@ -87,7 +85,7 @@ void InitStores() stextflag = STORE_NONE; InStoreFlag = 1; stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; numpremium = 0; premiumlevel = 1; @@ -97,16 +95,10 @@ void InitStores() boyitem._itype = -1; boylevel = 0; } -// 69FB38: using guessed type int talker; -// 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; -// 6A8A3C: using guessed type int boylevel; -// 6AA705: using guessed type char stextflag; void SetupTownStores() { - int i; // eax - int l; // esi + int i, l; SetRndSeed(glSeedTbl[currlevel] * GetTickCount()); if (gbMaxPlayers == 1) { @@ -130,21 +122,12 @@ void SetupTownStores() SpawnBoy(plr[myplr]._pLevel); SpawnPremium(plr[myplr]._pLevel); } -// 679660: using guessed type char gbMaxPlayers; void FreeStoreMem() { - void *p; - - p = pSTextBoxCels; - pSTextBoxCels = NULL; - mem_free_dbg(p); - p = pCelBuff; - pCelBuff = NULL; - mem_free_dbg(p); - p = pSTextSlidCels; - pSTextSlidCels = NULL; - mem_free_dbg(p); + MemFreeDbg(pSTextBoxCels); + MemFreeDbg(pCelBuff); + MemFreeDbg(pSTextSlidCels); } void DrawSTextBack() @@ -275,7 +258,7 @@ void DrawSLine(int y) /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, gpBuffer mov edi, esi @@ -307,46 +290,32 @@ void DrawSLine(int y) void DrawSArrows(int y1, int y2) { - int *v2; // ebp - int v3; // ebx - int v4; // edi - int v5; // esi - int v6; // eax - int v7; // eax - - v2 = &SStringY[y2]; - v3 = y1; - v4 = SStringY[y1] + 204; - v5 = *v2 + 204; - if (stextscrlubtn == -1) - CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 10, 12); + int yd1, yd2, yd3; + + yd1 = SStringY[y1] + 204; + yd2 = SStringY[y2] + 204; + if (stextscrlubtn != -1) + CelDecodeOnly(665, yd1, (BYTE *)pSTextSlidCels, 12, 12); else - CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 12, 12); - if (stextscrldbtn == -1) - CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 9, 12); + CelDecodeOnly(665, yd1, (BYTE *)pSTextSlidCels, 10, 12); + if (stextscrldbtn != -1) + CelDecodeOnly(665, yd2, (BYTE *)pSTextSlidCels, 11, 12); else - CelDecodeOnly(665, v5, (BYTE *)pSTextSlidCels, 11, 12); - while (1) { - v4 += 12; - if (v4 >= v5) - break; - CelDecodeOnly(665, v4, (BYTE *)pSTextSlidCels, 14, 12); + CelDecodeOnly(665, yd2, (BYTE *)pSTextSlidCels, 9, 12); + yd1 += 12; + for (yd3 = yd1; yd3 < yd2; yd3 += 12) { + CelDecodeOnly(665, yd3, (BYTE *)pSTextSlidCels, 14, 12); } - v6 = stextsel; if (stextsel == 22) - v6 = stextlhold; - if (storenumh <= 1) - v7 = 0; + yd3 = stextlhold; + else + yd3 = stextsel; + if (storenumh > 1) + yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (SStringY[y2] - SStringY[y1] - 24) / 1000; else - v7 = (*v2 - SStringY[v3] - 24) * (1000 * (stextsval + ((v6 - stextup) >> 2)) / (storenumh - 1)) / 1000; - CelDecodeOnly(665, SStringY[v3 + 1] + v7 + 204, (BYTE *)pSTextSlidCels, 13, 12); + yd3 = 0; + CelDecodeOnly(665, SStringY[y1 + 1] + 204 + yd3, (BYTE *)pSTextSlidCels, 13, 12); } -// 69F108: using guessed type int stextup; -// 69F10C: using guessed type int storenumh; -// 69F110: using guessed type int stextlhold; -// 6A8A28: using guessed type int stextsel; -// 6A8A2C: using guessed type char stextscrldbtn; -// 6AA704: using guessed type char stextscrlubtn; void DrawSTextHelp() { @@ -477,7 +446,7 @@ void StoreAutoPlace() void S_StartSmith() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); AddSText(0, 3, 1u, "Blacksmith's shop", COL_GOLD, 0); AddSText(0, 7, 1u, "Would you like to:", COL_GOLD, 0); @@ -492,7 +461,6 @@ void S_StartSmith() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_ScrollSBuy(int idx) { @@ -535,78 +503,62 @@ void S_ScrollSBuy(int idx) void PrintStoreItem(ItemStruct *x, int l, char iclr) { - ItemStruct *v3; // esi - char v5; // cl - char v6; // cl - int v7; // eax - char v8; // al - unsigned char v9; // al - char v10; // al - int v11; // edi - char sstr[128]; // [esp+Ch] [ebp-84h] - int y; // [esp+8Ch] [ebp-4h] - - sstr[0] = 0; - v3 = x; - y = l; + char sstr[128]; + + sstr[0] = '\0'; if (x->_iIdentified) { if (x->_iMagical != ITEM_QUALITY_UNIQUE) { - v5 = x->_iPrePower; - if (v5 != -1) { - PrintItemPower(v5, v3); + if (x->_iPrePower != -1) { + PrintItemPower(x->_iPrePower, x); strcat(sstr, tempstr); } } - v6 = v3->_iSufPower; - if (v6 != -1) { - PrintItemPower(v6, v3); + if (x->_iSufPower != -1) { + PrintItemPower(x->_iSufPower, x); if (sstr[0]) strcat(sstr, ", "); strcat(sstr, tempstr); } } - if (v3->_iMiscId == IMISC_STAFF && v3->_iMaxCharges) { - sprintf(tempstr, "Charges: %i/%i", v3->_iCharges, v3->_iMaxCharges); + if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { + sprintf(tempstr, "Charges: %i/%i", x->_iCharges, x->_iMaxCharges); if (sstr[0]) strcat(sstr, ", "); strcat(sstr, tempstr); } - if (sstr[0]) - AddSText(40, y++, 0, sstr, iclr, 0); - sstr[0] = 0; - if (v3->_iClass == ICLASS_WEAPON) - sprintf(sstr, "Damage: %i-%i ", v3->_iMinDam, v3->_iMaxDam); - if (v3->_iClass == ICLASS_ARMOR) - sprintf(sstr, "Armor: %i ", v3->_iAC); - v7 = v3->_iMaxDur; - if (v7 != 255 && v7) { - sprintf(tempstr, "Dur: %i/%i, ", v3->_iDurability, v3->_iMaxDur); + if (sstr[0]) { + AddSText(40, l, 0, sstr, iclr, 0); + l++; + } + sstr[0] = '\0'; + if (x->_iClass == ICLASS_WEAPON) + sprintf(sstr, "Damage: %i-%i ", x->_iMinDam, x->_iMaxDam); + if (x->_iClass == ICLASS_ARMOR) + sprintf(sstr, "Armor: %i ", x->_iAC); + if (x->_iMaxDur != 255 && x->_iMaxDur) { + sprintf(tempstr, "Dur: %i/%i, ", x->_iDurability, x->_iMaxDur); strcat(sstr, tempstr); } else { strcat(sstr, "Indestructible, "); } - if (!v3->_itype) - sstr[0] = 0; - if (v3->_iMinStr + (unsigned char)v3->_iMinMag + v3->_iMinDex) { + if (!x->_itype) + sstr[0] = '\0'; + if (!(x->_iMinStr + x->_iMinMag + x->_iMinDex)) { + strcat(sstr, "No required attributes"); + } else { strcpy(tempstr, "Required:"); - v8 = v3->_iMinStr; - if (v8) - sprintf(tempstr, "%s %i Str", tempstr, v8); - v9 = v3->_iMinMag; - if (v9) - sprintf(tempstr, "%s %i Mag", tempstr, v9); - v10 = v3->_iMinDex; - if (v10) - sprintf(tempstr, "%s %i Dex", tempstr, v10); + if (x->_iMinStr) + sprintf(tempstr, "%s %i Str", tempstr, x->_iMinStr); + if (x->_iMinMag) + sprintf(tempstr, "%s %i Mag", tempstr, x->_iMinMag); + if (x->_iMinDex) + sprintf(tempstr, "%s %i Dex", tempstr, x->_iMinDex); strcat(sstr, tempstr); - } else { - strcat(sstr, "No required attributes"); } - v11 = y; - AddSText(40, y, 0, sstr, iclr, 0); - if (v3->_iMagical == ITEM_QUALITY_UNIQUE) { - if (v3->_iIdentified) - AddSText(40, v11 + 1, 0, "Unique Item", iclr, 0); + AddSText(40, l, 0, sstr, iclr, 0); + if (x->_iMagical == ITEM_QUALITY_UNIQUE) { + if (x->_iIdentified) + AddSText(40, l + 1, 0, "Unique Item", iclr, 0); } } @@ -615,7 +567,7 @@ void S_StartSBuy() int i; stextsize = 1; - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; sprintf(tempstr, "I have these items for sale : Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1, tempstr, COL_GOLD, 0); @@ -634,7 +586,6 @@ void S_StartSBuy() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; void S_ScrollSPBuy(int idx) { @@ -704,7 +655,7 @@ BOOL S_StartSPBuy() } stextsize = 1; - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; sprintf(tempstr, "I have these premium items for sale : Your gold : %i", plr[myplr]._pGold); @@ -726,7 +677,6 @@ BOOL S_StartSPBuy() // 69FB38: using guessed type int talker; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; BOOL SmithSellOk(int i) @@ -814,7 +764,7 @@ void S_StartSSell() } if (!sellok) { - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1, tempstr, COL_GOLD, 0); AddSLine(3); @@ -822,7 +772,7 @@ void S_StartSSell() AddSText(0, 22, 1, "Back", COL_WHITE, 1); OffsetSTextY(22, 6); } else { - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; stextsmax = plr[myplr]._pNumInv; sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); @@ -837,7 +787,6 @@ void S_StartSSell() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; BOOL SmithRepairOk(int i) { @@ -857,96 +806,58 @@ BOOL SmithRepairOk(int i) void S_StartSRepair() { - int v0; // ebp - int *v1; // eax - int v2; // esi - int v3; // eax - int v4; // eax - int v5; // eax - int v6; // eax - int v7; // edi - //int v8; // eax - int v9; // esi - int v10; // eax - int v11; // [esp-4h] [ebp-1Ch] - signed int v12; // [esp+10h] [ebp-8h] - int v13; // [esp+14h] [ebp-4h] - - v0 = 0; + BOOL repairok; + int i; + stextsize = 1; - v12 = 0; + repairok = FALSE; storenumh = 0; - v1 = &storehold[0]._itype; - do { - *v1 = -1; - v1 += 92; - } while ((signed int)v1 < (signed int)&storehold[48]._itype); - v2 = myplr; - v3 = myplr; - if (plr[myplr].InvBody[INVLOC_HEAD]._itype != -1 && plr[v3].InvBody[INVLOC_HEAD]._iDurability != plr[v3].InvBody[INVLOC_HEAD]._iMaxDur) { - v12 = 1; - AddStoreHoldRepair(plr[v3].InvBody, -1); - v2 = myplr; - } - v4 = v2; - if (plr[v2].InvBody[INVLOC_CHEST]._itype != -1 && plr[v4].InvBody[INVLOC_CHEST]._iDurability != plr[v4].InvBody[INVLOC_CHEST]._iMaxDur) { - v12 = 1; - AddStoreHoldRepair(&plr[v4].InvBody[INVLOC_CHEST], -2); - v2 = myplr; - } - v5 = v2; - if (plr[v2].InvBody[INVLOC_HAND_LEFT]._itype != -1 && plr[v5].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[v5].InvBody[INVLOC_HAND_LEFT]._iMaxDur) { - v12 = 1; - AddStoreHoldRepair(&plr[v5].InvBody[INVLOC_HAND_LEFT], -3); - v2 = myplr; - } - v6 = v2; - if (plr[v2].InvBody[INVLOC_HAND_RIGHT]._itype != -1 && plr[v6].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[v6].InvBody[INVLOC_HAND_RIGHT]._iMaxDur) { - v12 = 1; - AddStoreHoldRepair(&plr[v6].InvBody[INVLOC_HAND_RIGHT], -4); - v2 = myplr; - } - v7 = 21720 * v2; - if (plr[v2]._pNumInv > 0) { - v13 = 0; - do { - //_LOBYTE(v8) = SmithRepairOk(v0); - if (SmithRepairOk(v0)) { - v12 = 1; - AddStoreHoldRepair((ItemStruct *)((char *)&plr[0].InvList[v13] + v7), v0); - v2 = myplr; - } - ++v13; - v7 = 21720 * v2; - ++v0; - } while (v0 < plr[v2]._pNumInv); - } - v9 = v2; - v11 = plr[v9]._pGold; - if (v12) { - stextsval = 0; - v10 = plr[v9]._pNumInv; - stextscrl = 1; - stextsmax = v10; - sprintf(tempstr, "Repair which item? Your gold : %i", v11); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); - AddSLine(3); - AddSLine(21); - S_ScrollSSell(stextsval); - } else { - stextscrl = 0; - sprintf(tempstr, "You have nothing to repair. Your gold : %i", v11); - AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); + for (i = 0; i < 40; i++) + storehold[i]._itype = ITYPE_NONE; + if (plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HEAD]._iDurability != plr[myplr].InvBody[INVLOC_HEAD]._iMaxDur) { + repairok = TRUE; + AddStoreHoldRepair(plr[myplr].InvBody, -1); + } + if (plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_CHEST]._iDurability != plr[myplr].InvBody[INVLOC_CHEST]._iMaxDur) { + repairok = TRUE; + AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_CHEST], -2); + } + if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HAND_LEFT]._iDurability != plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMaxDur) { + repairok = TRUE; + AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_HAND_LEFT], -3); + } + if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE && plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iDurability != plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMaxDur) { + repairok = TRUE; + AddStoreHoldRepair(&plr[myplr].InvBody[INVLOC_HAND_RIGHT], -4); + } + for (i = 0; i < plr[myplr]._pNumInv; i++) { + if (SmithRepairOk(i)) { + repairok = TRUE; + AddStoreHoldRepair(&plr[myplr].InvList[i], i); + } + } + if (!repairok) { + stextscrl = FALSE; + sprintf(tempstr, "You have nothing to repair. Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, 3, 0); AddSLine(3); AddSLine(21); + AddSText(0, 22, 1, "Back", 0, 1); + OffsetSTextY(22, 6); + return; } - AddSText(0, 22, 1u, "Back", COL_WHITE, 1); + + stextscrl = TRUE; + stextsval = 0; + stextsmax = plr[myplr]._pNumInv; + sprintf(tempstr, "Repair which item? Your gold : %i", plr[myplr]._pGold); + AddSText(0, 1, 1, tempstr, 3, 0); + AddSLine(3); + AddSLine(21); + S_ScrollSSell(stextsval); + AddSText(0, 22, 1, "Back", 0, 1); OffsetSTextY(22, 6); } -// 69F10C: using guessed type int storenumh; -// 6A09E0: using guessed type char stextsize; -// 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; void AddStoreHoldRepair(ItemStruct *itm, int i) { @@ -975,7 +886,7 @@ void AddStoreHoldRepair(ItemStruct *itm, int i) void S_StartWitch() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 2, 1u, "Witch's shack", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); AddSText(0, 12, 1u, "Talk to Adria", COL_BLUE, 1); @@ -988,7 +899,6 @@ void S_StartWitch() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_ScrollWBuy(int idx) { @@ -1036,7 +946,7 @@ void S_StartWBuy() v0 = plr[myplr]._pGold; stextsize = 1; - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; stextsmax = 20; sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); @@ -1063,7 +973,6 @@ void S_StartWBuy() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; BOOL WitchSellOk(int i) { @@ -1133,7 +1042,7 @@ void S_StartWSell() } if (!sellok) { - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "You have nothing I want. Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1, tempstr, COL_GOLD, 0); AddSLine(3); @@ -1141,7 +1050,7 @@ void S_StartWSell() AddSText(0, 22, 1, "Back", COL_WHITE, 1); OffsetSTextY(22, 6); } else { - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; stextsmax = plr[myplr]._pNumInv; sprintf(tempstr, "Which item is for sale? Your gold : %i", plr[myplr]._pGold); @@ -1156,7 +1065,6 @@ void S_StartWSell() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; BOOL WitchRechargeOk(int i) { @@ -1209,7 +1117,7 @@ void S_StartWRecharge() } if (!rechargeok) { - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "You have nothing to recharge. Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1, tempstr, COL_GOLD, 0); AddSLine(3); @@ -1217,7 +1125,7 @@ void S_StartWRecharge() AddSText(0, 22, 1, "Back", COL_WHITE, 1); OffsetSTextY(22, 6); } else { - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; stextsmax = plr[myplr]._pNumInv; sprintf(tempstr, "Recharge which item? Your gold : %i", plr[myplr]._pGold); @@ -1233,30 +1141,28 @@ void S_StartWRecharge() void S_StartNoMoney() { StartStore((unsigned char)stextshold); - stextscrl = 0; + stextscrl = FALSE; stextsize = 1; ClearSText(5, 23); AddSText(0, 14, 1u, "You do not have enough gold", COL_WHITE, 1); } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartNoRoom() { StartStore((unsigned char)stextshold); - stextscrl = 0; + stextscrl = FALSE; ClearSText(5, 23); AddSText(0, 14, 1u, "You do not have enough room in inventory", COL_WHITE, 1); } -// 6A6BB8: using guessed type int stextscrl; void S_StartConfirm() { - BOOL idprint; // esi - char iclr; // [esp+Ch] [ebp-4h] + BOOL idprint; + char iclr; StartStore(stextshold); - stextscrl = 0; + stextscrl = FALSE; ClearSText(5, 23); iclr = COL_WHITE; @@ -1287,52 +1193,39 @@ void S_StartConfirm() AddSTextVal(8, plr[myplr].HoldItem._iIvalue); PrintStoreItem(&plr[myplr].HoldItem, 9, iclr); - if (stextshold > STORE_WRECHARGE) { - if (stextshold == STORE_BBOY) { - strcpy(tempstr, "Do we have a deal?"); - goto LABEL_37; - } - if (stextshold != STORE_HBUY) { - if (stextshold == STORE_SIDENTIFY) { - strcpy(tempstr, "Are you sure you want to identify this item?"); - goto LABEL_37; - } - if (stextshold != STORE_SPBUY) - goto LABEL_37; - } - LABEL_34: - strcpy(tempstr, "Are you sure you want to buy this item?"); - goto LABEL_37; - } switch (stextshold) { + case STORE_BBOY: + strcpy(tempstr, "Do we have a deal?"); + break; + case STORE_SIDENTIFY: + strcpy(tempstr, "Are you sure you want to identify this item?"); + break; + case STORE_HBUY: + case STORE_SPBUY: + case STORE_WBUY: + case STORE_SBUY: + strcpy(tempstr, "Are you sure you want to buy this item?"); + break; case STORE_WRECHARGE: strcpy(tempstr, "Are you sure you want to recharge this item?"); break; - case STORE_SBUY: - goto LABEL_34; case STORE_SSELL: - LABEL_27: + case STORE_WSELL: strcpy(tempstr, "Are you sure you want to sell this item?"); break; case STORE_SREPAIR: strcpy(tempstr, "Are you sure you want to repair this item?"); break; - case STORE_WBUY: - goto LABEL_34; - case STORE_WSELL: - goto LABEL_27; } -LABEL_37: AddSText(0, 15, 1u, tempstr, COL_WHITE, 0); AddSText(0, 18, 1u, "Yes", COL_WHITE, 1); AddSText(0, 20, 1u, "No", COL_WHITE, 1); } -// 6A6BB8: using guessed type int stextscrl; void S_StartBoy() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 2, 1u, "Wirt the Peg-legged boy", COL_GOLD, 0); AddSLine(5); if (boyitem._itype != -1) { @@ -1348,14 +1241,13 @@ void S_StartBoy() } } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartBBoy() { int iclr; // esi stextsize = 1; - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "I have this item for sale : Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); AddSLine(3); @@ -1377,12 +1269,11 @@ void S_StartBBoy() OffsetSTextY(22, 6); } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartHealer() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); AddSText(0, 3, 1u, "Healer's home", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); @@ -1395,7 +1286,6 @@ void S_StartHealer() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_ScrollHBuy(int idx) { @@ -1432,7 +1322,7 @@ void S_StartHBuy() v0 = plr[myplr]._pGold; stextsize = 1; - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; sprintf(tempstr, "I have these items for sale : Your gold : %i", v0); AddSText(0, 1, 1u, tempstr, COL_GOLD, 0); @@ -1458,12 +1348,11 @@ void S_StartHBuy() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; void S_StartStory() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 2, 1u, "The Town Elder", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); AddSText(0, 12, 1u, "Talk to Cain", COL_BLUE, 1); @@ -1472,7 +1361,6 @@ void S_StartStory() AddSLine(5); } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; BOOL IdItemOk(ItemStruct *i) { @@ -1545,7 +1433,7 @@ void S_StartSIdentify() } if (!idok) { - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "You have nothing to identify. Your gold : %i", plr[myplr]._pGold); AddSText(0, 1, 1, tempstr, COL_GOLD, 0); AddSLine(3); @@ -1553,7 +1441,7 @@ void S_StartSIdentify() AddSText(0, 22, 1, "Back", COL_WHITE, 1); OffsetSTextY(22, 6); } else { - stextscrl = 1; + stextscrl = TRUE; stextsval = 0; stextsmax = plr[myplr]._pNumInv; sprintf(tempstr, "Identify which item? Your gold : %i", plr[myplr]._pGold); @@ -1568,14 +1456,13 @@ void S_StartSIdentify() // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; void S_StartIdShow() { char iclr; // [esp+4h] [ebp-4h] StartStore(stextshold); - stextscrl = 0; + stextscrl = FALSE; ClearSText(5, 23); iclr = COL_WHITE; @@ -1589,7 +1476,6 @@ void S_StartIdShow() PrintStoreItem(&plr[myplr].HoldItem, 12, iclr); AddSText(0, 18, 1u, "Done", COL_WHITE, 1); } -// 6A6BB8: using guessed type int stextscrl; void S_StartTalk() { @@ -1605,7 +1491,7 @@ void S_StartTalk() int y; // [esp+14h] [ebp-4h] stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; sprintf(tempstr, "Talk to %s", talkname[talker]); AddSText(0, 2, 1u, tempstr, COL_GOLD, 0); AddSLine(5); @@ -1645,12 +1531,11 @@ void S_StartTalk() } // 69FB38: using guessed type int talker; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartTavern() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 1, 1u, "Welcome to the", COL_GOLD, 0); AddSText(0, 3, 1u, "Rising Sun", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); @@ -1661,12 +1546,11 @@ void S_StartTavern() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartBarMaid() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 2, 1u, "Gillian", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); AddSText(0, 12, 1u, "Talk to Gillian", COL_BLUE, 1); @@ -1676,12 +1560,11 @@ void S_StartBarMaid() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void S_StartDrunk() { stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; AddSText(0, 2, 1u, "Farnham the Drunk", COL_GOLD, 0); AddSText(0, 9, 1u, "Would you like to:", COL_GOLD, 0); AddSText(0, 12, 1u, "Talk to Farnham", COL_BLUE, 1); @@ -1691,7 +1574,6 @@ void S_StartDrunk() } // 69F10C: using guessed type int storenumh; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; void StartStore(char s) { @@ -1851,7 +1733,6 @@ LABEL_19: InStoreFlag = (InStoreFlag & 7) + 1; } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; // 6AA705: using guessed type char stextflag; void STextESC() @@ -1980,7 +1861,6 @@ void STextUp() } } // 69F108: using guessed type int stextup; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; void STextDown() @@ -2026,7 +1906,6 @@ void STextDown() } } // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; // 6AA700: using guessed type int stextdown; @@ -2046,7 +1925,6 @@ void STextPrior() } } // 69F108: using guessed type int stextup; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; void STextNext() @@ -2064,7 +1942,6 @@ void STextNext() } } // 6A09E4: using guessed type int stextsmax; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; // 6AA700: using guessed type int stextdown; @@ -3276,7 +3153,6 @@ void CheckStoreBtn() } // 646D00: using guessed type char qtextflag; // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; // 6A8A2C: using guessed type char stextscrldbtn; // 6AA704: using guessed type char stextscrlubtn; diff --git a/Source/stores.h b/Source/stores.h index c104a7734..70dd743c3 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -18,7 +18,7 @@ extern int InStoreFlag; // idb extern ItemStruct storehold[48]; extern int gossipstart; // weak extern ItemStruct witchitem[20]; -extern int stextscrl; +extern BOOL stextscrl; extern int numpremium; // idb extern ItemStruct healitem[20]; extern ItemStruct golditem; diff --git a/Source/sync.cpp b/Source/sync.cpp index 4be1f80fe..9b1d59e26 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/textdat.cpp b/Source/textdat.cpp index 8377c005f..f79e86c3f 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/themes.cpp b/Source/themes.cpp index 9fc7b177b..48b1d4259 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -216,74 +214,55 @@ BOOL TFit_Obj3(int t) BOOL CheckThemeReqs(int t) { - BOOLEAN rv; // al - int v2; // ecx - int v3; // ecx - int v4; // ecx - int v5; // ecx - BOOLEAN v6; // zf - int v7; // ecx - int v8; // ecx - int v9; // ecx - - rv = 1; - if (t <= 10) { - if (t != 10) { - v2 = t - 1; - if (v2) { - v3 = v2 - 2; - if (v3) { - v4 = v3 - 2; - if (v4) { - v5 = v4 - 2; - if (v5) { - if (v5 != 2) { - return rv; - } - v6 = pFountainFlag == 0; - } else { - v6 = bFountainFlag == 0; - } - LABEL_21: - if (!v6) { - return rv; - } - return 0; - } - } - } - if (leveltype != 3) { - v6 = leveltype == DTYPE_HELL; - goto LABEL_21; - } - return 0; + BOOL rv; + + rv = TRUE; + switch (t) { + case THEME_SHRINE: + case THEME_SKELROOM: + case THEME_LIBRARY: + if (leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) { + rv = FALSE; } - LABEL_16: - v6 = leveltype == DTYPE_CATHEDRAL; - goto LABEL_21; - } - v7 = t - 12; - if (v7) { - v8 = v7 - 1; - if (!v8) { - v6 = mFountainFlag == 0; - goto LABEL_21; + break; + case THEME_BLOODFOUNTAIN: + if (!bFountainFlag) { + rv = FALSE; + } + break; + case THEME_PURIFYINGFOUNTAIN: + if (!pFountainFlag) { + rv = FALSE; } - v9 = v8 - 1; - if (!v9) { - v6 = tFountainFlag == 0; - goto LABEL_21; + break; + case THEME_ARMORSTAND: + if (leveltype == DTYPE_CATHEDRAL) { + rv = FALSE; + } + break; + case THEME_CAULDRON: + if (leveltype != DTYPE_HELL || !cauldronFlag) { + rv = FALSE; } - if (v9 != 2) { - return rv; + break; + case THEME_MURKYFOUNTAIN: + if (!mFountainFlag) { + rv = FALSE; } - goto LABEL_16; - } - if (leveltype == DTYPE_HELL) { - v6 = cauldronFlag == 0; - goto LABEL_21; + break; + case THEME_TEARFOUNTAIN: + if (!tFountainFlag) { + rv = FALSE; + } + break; + case THEME_WEAPONRACK: + if (leveltype == DTYPE_CATHEDRAL) { + rv = FALSE; + } + break; } - return 0; + + return rv; } // 6AAA58: using guessed type int mFountainFlag; // 6AAA5C: using guessed type int cauldronFlag; @@ -453,19 +432,19 @@ void InitThemes() } if (leveltype == 2 || leveltype == 3 || leveltype == 4) { for (i = 0; i < themeCount; i++) - themes[i].ttype = -1; + themes[i].ttype = THEME_NONE; if (QuestStatus(QTYPE_ZHAR)) { for (j = 0; j < themeCount; j++) { themes[j].ttval = themeLoc[j].ttval; - if (SpecialThemeFit(j, 5)) { - themes[j].ttype = 5; + if (SpecialThemeFit(j, THEME_LIBRARY)) { + themes[j].ttype = THEME_LIBRARY; zharlib = j; break; } } } for (i = 0; i < themeCount; i++) { - if (themes[i].ttype == -1) { + if (themes[i].ttype == THEME_NONE) { themes[i].ttval = themeLoc[i].ttval; for (j = ThemeGood[random(0, 4)];; j = random(0, 17)) { if (SpecialThemeFit(i, j)) { diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index 17debfcf1..7bfb5ef9f 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -40,13 +38,18 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen) *tail = msg; } +void tmsg_start() +{ + /// ASSERT: assert(! sgpTimedMsgHead); +} + void *tmsg_cleanup() { + TMsg *next; + while (sgpTimedMsgHead) { - TMsg *next = sgpTimedMsgHead->hdr.pNext; - TMsg *head = sgpTimedMsgHead; - sgpTimedMsgHead = NULL; - mem_free_dbg(head); + next = sgpTimedMsgHead->hdr.pNext; + MemFreeDbg(sgpTimedMsgHead); sgpTimedMsgHead = next; } return sgpTimedMsgHead; diff --git a/Source/tmsg.h b/Source/tmsg.h index b58ec5bf3..465181f72 100644 --- a/Source/tmsg.h +++ b/Source/tmsg.h @@ -4,6 +4,7 @@ int tmsg_get(BYTE *pbMsg, DWORD dwMaxLen); void tmsg_add(BYTE *pbMsg, BYTE bLen); +void tmsg_start(); void *tmsg_cleanup(); #endif /* __TMSG_H__ */ diff --git a/Source/town.cpp b/Source/town.cpp index 845355f82..fc4bac542 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -8,7 +6,7 @@ void town_clear_upper_buf(BYTE *pBuff) { /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, pBuff mov edx, 30 @@ -71,7 +69,7 @@ void town_clear_low_buf(BYTE *pBuff) { /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov edi, pBuff mov edx, 30 @@ -946,7 +944,7 @@ void T_DrawZoom(int x, int y) /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, gpBuffer mov edx, nDstOff @@ -1111,7 +1109,7 @@ void T_FillSector(unsigned char *P3Tiles, unsigned char *pSector, int xi, int yi for (j = 0; j < h; j++) { xx = xi; for (i = 0; i < w; i++) { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pSector mov eax, ii @@ -1177,7 +1175,7 @@ void T_FillTile(unsigned char *P3Tiles, int xx, int yy, int t) { long v1, v2, v3, v4; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov eax, t dec eax diff --git a/Source/towners.cpp b/Source/towners.cpp index 943105cd1..f489e4f07 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -395,22 +393,17 @@ void InitTowners() void FreeTownerGFX() { - void *tmp; int i; for (i = 0; i < 16; i++) { if (towner[i]._tNData == pCowCels) { towner[i]._tNData = NULL; } else if (towner[i]._tNData) { - tmp = towner[i]._tNData; - towner[i]._tNData = NULL; - mem_free_dbg(tmp); + MemFreeDbg(towner[i]._tNData); } } - tmp = pCowCels; - pCowCels = NULL; - mem_free_dbg(tmp); + MemFreeDbg(pCowCels); } void TownCtrlMsg(int i) diff --git a/Source/track.cpp b/Source/track.cpp index 38245a035..5ad937bcd 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 51cd3d8fb..63b6c0c2d 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" DEVILUTION_BEGIN_NAMESPACE @@ -251,88 +249,45 @@ void InitL3Triggers() void InitL4Triggers() { - signed int v0; // edi - int *v1; // esi - int *v2; // edx - TriggerStruct *v3; // ecx - int *v4; // eax - int v5; // edx - int(*v6)[112]; // edi - signed int v7; // ecx - int *v8; // eax - int(*v9)[112]; // [esp+Ch] [ebp-Ch] - int(*v10)[112]; // [esp+Ch] [ebp-Ch] - int v11; // [esp+10h] [ebp-8h] - int(*v12)[112]; // [esp+14h] [ebp-4h] + int i, j; trigflag_4 = 0; - v11 = 0; - v9 = dPiece; - do { - v0 = 0; - v12 = v9; - v1 = &trigs[trigflag_4]._tmsg; - v2 = &trigs[trigflag_4]._ty; - v3 = &trigs[trigflag_4]; - v4 = &trigs[trigflag_4]._tlvl; - do { - if ((*v12)[0] == 83) { - ++trigflag_4; - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABPREVLVL; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) { + if (dPiece[i][j] == 83) { + trigs[trigflag_4]._tx = i; + trigs[trigflag_4]._ty = j; + trigs[trigflag_4]._tmsg = WM_DIABPREVLVL; + trigflag_4++; } - if ((*v12)[0] == 422) { - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABTWARPUP; - *v4 = 0; - ++trigflag_4; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; + + if (dPiece[i][j] == 422) { + trigs[trigflag_4]._tx = i; + trigs[trigflag_4]._ty = j; + trigs[trigflag_4]._tmsg = WM_DIABTWARPUP; + trigs[trigflag_4]._tlvl = 0; + trigflag_4++; } - if ((*v12)[0] == 120) { - ++trigflag_4; - v3->_tx = v0; - *v2 = v11; - *v1 = WM_DIABNEXTLVL; - v4 += 4; - ++v3; - v2 += 4; - v1 += 4; + + if (dPiece[i][j] == 120) { + trigs[trigflag_4]._tx = i; + trigs[trigflag_4]._ty = j; + trigs[trigflag_4]._tmsg = WM_DIABNEXTLVL; + trigflag_4++; } - ++v12; - ++v0; - } while (v0 < 112); - v9 = (int(*)[112])((char *)v9 + 4); - ++v11; - } while ((signed int)v9 < (signed int)dPiece[1]); - v5 = 0; - v10 = dPiece; - do { - v6 = v10; - v7 = 0; - v8 = &trigs[trigflag_4]._ty; - do { - if ((*v6)[0] == 370 && quests[QTYPE_VB]._qactive == 3) { - ++trigflag_4; - *(v8 - 1) = v7; - *v8 = v5; - v8[1] = WM_DIABNEXTLVL; - v8 += 4; + } + } + + for (j = 0; j < MAXDUNY; j++) { + for (i = 0; i < MAXDUNX; i++) { + if (dPiece[i][j] == 370 && quests[QTYPE_VB]._qactive == 3) { + trigs[trigflag_4]._tx = i; + trigs[trigflag_4]._ty = j; + trigs[trigflag_4]._tmsg = WM_DIABNEXTLVL; + trigflag_4++; } - ++v7; - ++v6; - } while (v7 < 112); - v10 = (int(*)[112])((char *)v10 + 4); - ++v5; - } while ((signed int)v10 < (signed int)dPiece[1]); + } + } trigflag_3 = 0; } diff --git a/Source/wave.cpp b/Source/wave.cpp index a7f4230a5..855465242 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" DEVILUTION_BEGIN_NAMESPACE @@ -105,9 +104,7 @@ void *AllocateMemFile(HANDLE hsFile, MEMFILE *pMemFile, DWORD dwPos) void FreeMemFile(MEMFILE *pMemFile) { - void *mem = pMemFile->buf; - pMemFile->buf = NULL; - mem_free_dbg(mem); + MemFreeDbg(pMemFile->buf); } BOOL ReadWaveFile(MEMFILE *pMemFile, WAVEFORMATEX *pwfx, CKINFO *chunk) diff --git a/SourceS/devilution.h b/SourceS/devilution.h index fa95d570b..36e65d597 100644 --- a/SourceS/devilution.h +++ b/SourceS/devilution.h @@ -1 +1,2 @@ -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" diff --git a/SourceS/miniwin/misc.h b/SourceS/miniwin/misc.h index 9840f632d..753ea0b6c 100644 --- a/SourceS/miniwin/misc.h +++ b/SourceS/miniwin/misc.h @@ -544,6 +544,8 @@ WINBOOL WINAPI DeleteFileA(LPCSTR lpFileName); WINBOOL WINAPI CopyFileA(LPCSTR lpExistingFileName, LPCSTR lpNewFileName, WINBOOL bFailIfExists); HFILE WINAPI OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uStyle); +void __debugbreak(); + typedef struct _CONTEXT { // diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index 0969b1a40..7f80a94c8 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -1,7 +1,7 @@ +#include "devilution.h" +#include "DiabloUI/diabloui.h" #include "miniwin/ddraw.h" -#include "../types.h" - namespace dvl { BYTE *sgpBackBuf; diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index 73c4a5903..bdae16452 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -1,9 +1,9 @@ #include #include "devilution.h" +#include "DiabloUI/diabloui.h" #include "stubs.h" #include "miniwin/ddraw.h" -#include "DiabloUI/diabloui.h" #include #ifdef _MSC_VER #define strcasecmp _stricmp @@ -757,4 +757,9 @@ LONG SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) return 0; } +void __debugbreak() +{ + DUMMY(); +} + } diff --git a/defs.h b/defs.h index 0496dfcf0..45f3feae1 100644 --- a/defs.h +++ b/defs.h @@ -87,8 +87,18 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 -#define BUFFER_WIDTH 768 -#define BUFFER_HEIGHT 656 + +// If defined, use 32-bit colors instead of 8-bit [Default -> Undefined] +//#define RGBMODE + +#ifndef RGBMODE +#define SCREEN_BPP 8 +#else +#define SCREEN_BPP 32 +#endif + +#define BUFFER_WIDTH (64 + SCREEN_WIDTH + 64) +#define BUFFER_HEIGHT (160 + SCREEN_HEIGHT + 16) #define TILE_SIZE 32 #define SCREENXY(x, y) ((x) + 64 + (((y) + 160) * 768)) diff --git a/enums.h b/enums.h index a688e0a3f..e719c0590 100644 --- a/enums.h +++ b/enums.h @@ -1915,7 +1915,7 @@ typedef enum theme_id { THEME_TEARFOUNTAIN = 0xE, THEME_BRNCROSS = 0xF, THEME_WEAPONRACK = 0x10, - THEME_NONE = 0xFF, + THEME_NONE = -1, } theme_id; typedef enum event_type { diff --git a/types.h b/types.h index fc3e25c61..baa13ad4d 100644 --- a/types.h +++ b/types.h @@ -59,9 +59,9 @@ DEVILUTION_BEGIN_NAMESPACE #include "enums.h" #include "structs.h" -#include "DiabloUI/diabloui.h" -#include "3rdParty/Storm/Source/storm.h" -#include "3rdParty/PKWare/pkware.h" +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#define USE_ASM +#endif // If defined, use copy protection [Default -> Defined] //#define COPYPROT @@ -78,88 +78,4 @@ DEVILUTION_BEGIN_NAMESPACE // If defined, fix palette glitch in Windows Vista+ [Default -> Undefined] //#define COLORFIX -// If defined, use standard memcpy() in place of qmemcpy() [Default -> Undefined] -// Will be replaced with [rep movsd] if optimization is used -#define FAST_MEMCPY - -// header files -//#ifdef __cplusplus -//extern "C" { -//#endif -#include "Source/appfat.h" -#include "Source/automap.h" -#include "Source/capture.h" -#include "Source/codec.h" -#include "Source/control.h" -#include "Source/cursor.h" -#include "Source/dead.h" -#include "Source/debug.h" -#include "Source/diablo.h" -#include "Source/doom.h" -#include "Source/drlg_l1.h" -#include "Source/drlg_l2.h" -#include "Source/drlg_l3.h" -#include "Source/drlg_l4.h" -#include "Source/dthread.h" -#include "Source/dx.h" -#include "Source/effects.h" -#include "Source/encrypt.h" -#include "Source/engine.h" -#include "Source/error.h" -#include "Source/fault.h" -#include "Source/gamemenu.h" -#include "Source/gendung.h" -#include "Source/gmenu.h" -#include "Source/help.h" -#include "Source/init.h" -#include "Source/interfac.h" -#include "Source/inv.h" -#include "Source/items.h" -#include "Source/lighting.h" -#include "Source/loadsave.h" -#include "Source/logging.h" -#include "Source/mainmenu.h" -#include "Source/minitext.h" -#include "Source/missiles.h" -#include "Source/monster.h" -#include "Source/movie.h" -#include "Source/mpqapi.h" -#include "Source/msg.h" -#include "Source/msgcmd.h" -#include "Source/multi.h" -#include "Source/nthread.h" -#include "Source/objects.h" -#include "Source/pack.h" -#include "Source/palette.h" -#include "Source/path.h" -#include "Source/pfile.h" -#include "Source/player.h" -#include "Source/plrmsg.h" -#include "Source/portal.h" -#include "Source/quests.h" -#include "Source/restrict.h" -#include "Source/scrollrt.h" -#include "Source/setmaps.h" -#include "Source/sha.h" -#include "Source/sound.h" -#include "Source/spells.h" -#include "Source/stores.h" -#include "Source/sync.h" -#include "Source/textdat.h" // check file name -#include "Source/themes.h" -#include "Source/tmsg.h" -#include "Source/town.h" -#include "Source/towners.h" -#include "Source/track.h" -#include "Source/trigs.h" -#include "Source/wave.h" -#include "Source/render.h" // linked last, likely .s/.asm -//#ifdef __cplusplus -//} -//#endif - -#include "miniwin/popdecl.inc" - -DEVILUTION_END_NAMESPACE - #endif