From 9c7001c8e2c77f8c47b237170839d0a46f5d1840 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 21 Apr 2019 17:07:07 +0200 Subject: [PATCH 01/53] Clean up CheckThemeReqs --- Source/themes.cpp | 107 +++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 63 deletions(-) diff --git a/Source/themes.cpp b/Source/themes.cpp index e0ac7098a..d052b84df 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -214,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 1: + case 3: + case 5: + 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 7: + if (!bFountainFlag) { + rv = FALSE; } - v9 = v8 - 1; - if (!v9) { - v6 = tFountainFlag == 0; - goto LABEL_21; + break; + case 9: + if (!pFountainFlag) { + rv = FALSE; } - if (v9 != 2) { - return rv; + break; + case 10: + if (leveltype == DTYPE_CATHEDRAL) { + rv = FALSE; } - goto LABEL_16; - } - if (leveltype == DTYPE_HELL) { - v6 = cauldronFlag == 0; - goto LABEL_21; + break; + case 12: + if (leveltype != DTYPE_HELL || !cauldronFlag) { + rv = FALSE; + } + break; + case 13: + if (!mFountainFlag) { + rv = FALSE; + } + break; + case 14: + if (!tFountainFlag) { + rv = FALSE; + } + break; + case 16: + if (leveltype == DTYPE_CATHEDRAL) { + rv = FALSE; + } + break; } - return 0; + + return rv; } // 6AAA58: using guessed type int mFountainFlag; // 6AAA5C: using guessed type int cauldronFlag; From 540892ff9d6482a6aedba6c2b236c5f09a410951 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sat, 20 Apr 2019 23:24:50 -0500 Subject: [PATCH 02/53] Preliminary support for fixed header files --- Source/appfat.cpp | 5 ++- Source/automap.cpp | 4 +-- Source/capture.cpp | 4 +-- Source/codec.cpp | 4 +-- Source/control.cpp | 4 +-- Source/cursor.cpp | 4 +-- Source/dead.cpp | 4 +-- Source/debug.cpp | 4 +-- Source/diablo.cpp | 6 ++-- Source/diablo.h | 76 ++++++++++++++++++++++++++++++++++++++++ Source/doom.cpp | 4 +-- Source/drlg_l1.cpp | 4 +-- Source/drlg_l2.cpp | 4 +-- Source/drlg_l3.cpp | 4 +-- Source/drlg_l4.cpp | 4 +-- Source/dthread.cpp | 5 ++- Source/dx.cpp | 5 ++- Source/effects.cpp | 5 ++- Source/encrypt.cpp | 5 ++- Source/engine.cpp | 5 ++- Source/error.cpp | 4 +-- Source/fault.cpp | 4 +-- Source/gamemenu.cpp | 4 +-- Source/gendung.cpp | 4 +-- Source/gmenu.cpp | 4 +-- Source/help.cpp | 4 +-- Source/init.cpp | 6 ++-- Source/interfac.cpp | 5 ++- Source/inv.cpp | 4 +-- Source/items.cpp | 4 +-- Source/lighting.cpp | 4 +-- Source/list.h | 2 ++ Source/loadsave.cpp | 4 +-- Source/logging.cpp | 5 ++- Source/mainmenu.cpp | 6 ++-- Source/minitext.cpp | 4 +-- Source/missiles.cpp | 4 +-- Source/monster.cpp | 5 ++- Source/movie.cpp | 5 ++- Source/mpqapi.cpp | 5 ++- Source/msg.cpp | 6 ++-- Source/msgcmd.cpp | 4 +-- Source/multi.cpp | 6 ++-- Source/nthread.cpp | 5 ++- Source/objects.cpp | 4 +-- Source/pack.cpp | 5 ++- Source/palette.cpp | 5 ++- Source/path.cpp | 4 +-- Source/pfile.cpp | 6 ++-- Source/player.cpp | 5 ++- Source/plrmsg.cpp | 4 +-- Source/portal.cpp | 4 +-- Source/quests.cpp | 4 +-- Source/render.cpp | 4 +-- Source/restrict.cpp | 4 +-- Source/scrollrt.cpp | 5 ++- Source/setmaps.cpp | 4 +-- Source/sha.cpp | 4 +-- Source/sound.cpp | 5 ++- Source/spells.cpp | 4 +-- Source/stores.cpp | 4 +-- Source/sync.cpp | 4 +-- Source/textdat.cpp | 4 +-- Source/themes.cpp | 4 +-- Source/tmsg.cpp | 4 +-- Source/town.cpp | 4 +-- Source/towners.cpp | 4 +-- Source/track.cpp | 5 ++- Source/trigs.cpp | 4 +-- Source/wave.cpp | 5 ++- types.h | 84 --------------------------------------------- 71 files changed, 177 insertions(+), 288 deletions(-) diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 2dd9f9b56..d9c908a8b 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" char sz_error_buf[256]; BOOL terminating; diff --git a/Source/automap.cpp b/Source/automap.cpp index 24953eb63..a3298c53f 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" // BUGFIX: only the first 256 elements are ever read WORD automaptype[512]; diff --git a/Source/capture.cpp b/Source/capture.cpp index 904e541e0..067496703 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" void CaptureScreen() { diff --git a/Source/codec.cpp b/Source/codec.cpp index b844f4c84..5b5d6747b 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int codec_decode(void *pbSrcDst, int size, char *pszPassword) { diff --git a/Source/control.cpp b/Source/control.cpp index 08c2bcfdf..7652c4995 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" char sgbNextTalkSave; // weak char sgbTalkSavePos; // weak diff --git a/Source/cursor.cpp b/Source/cursor.cpp index ecce10c05..124ba1a76 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int cursH; // weak int icursH28; // idb diff --git a/Source/dead.cpp b/Source/dead.cpp index dcc69bcb6..eb4f87273 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" // unused, this was probably for blood boil/burn int spurtndx; diff --git a/Source/debug.cpp b/Source/debug.cpp index 08274a6e2..1673d9e93 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" void *pSquareCel; char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 01d9c3cec..bd42dd964 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" HWND ghMainWnd; int glMid1Seed[NUMLEVELS]; diff --git a/Source/diablo.h b/Source/diablo.h index b6592fba0..1780d17ee 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]; diff --git a/Source/doom.cpp b/Source/doom.cpp index 3fd729259..eff49b2ed 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int doom_quest_time; int doom_stars_drawn; diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index edf60e3b1..c268d22bd 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" char L5dungeon[80][80]; unsigned char L5dflags[DMAXX][DMAXY]; diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 05381c410..0e71ab0e1 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int nSx1; int nSx2; // weak diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 7851ff4f3..3c598c6bd 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" char lavapool; // weak int abyssx; // weak diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index ecc57126a..46b668ba8 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int diabquad1x; // weak int diabquad1y; // weak diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 34c7199c1..1aabb4f66 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" #ifdef __cplusplus static CCritSect sgMemCrit; diff --git a/Source/dx.cpp b/Source/dx.cpp index e145b22af..141efe610 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" BYTE *sgpBackBuf; LPDIRECTDRAW lpDDInterface; diff --git a/Source/effects.cpp b/Source/effects.cpp index 0df91e16a..e6997cbe0 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" int sfxdelay; // weak int sfxdnum; diff --git a/Source/encrypt.cpp b/Source/encrypt.cpp index d678cadeb..a1d287217 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" DWORD hashtable[1280]; diff --git a/Source/engine.cpp b/Source/engine.cpp index ee46817a7..6e77744cb 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" #if (_MSC_VER >= 800) && (_MSC_VER <= 1200) #pragma warning(disable : 4731) // frame pointer register 'ebp' modified by inline assembly code diff --git a/Source/error.cpp b/Source/error.cpp index 7e9c3f3b0..97681dd36 100644 --- a/Source/error.cpp +++ b/Source/error.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" char msgtable[MAX_SEND_STR_LEN]; char msgdelay; diff --git a/Source/fault.cpp b/Source/fault.cpp index ec6cdd6f9..459a724b1 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; diff --git a/Source/gamemenu.cpp b/Source/gamemenu.cpp index 47e450df7..49fecb8d1 100644 --- a/Source/gamemenu.cpp +++ b/Source/gamemenu.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" TMenuItem sgSingleMenu[6] = { // clang-format off diff --git a/Source/gendung.cpp b/Source/gendung.cpp index 84a6361dc..631556b4c 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" WORD level_frame_types[MAXTILES]; int themeCount; diff --git a/Source/gmenu.cpp b/Source/gmenu.cpp index 7a1788a80..bd0e538c7 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" void *optbar_cel; BOOLEAN byte_634464; // weak diff --git a/Source/help.cpp b/Source/help.cpp index 819ecd698..085d2f17f 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int help_select_line; // weak int dword_634494; // weak diff --git a/Source/init.cpp b/Source/init.cpp index 0ab42f056..eafa5fe9c 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" _SNETVERSIONDATA fileinfo; int gbActive; // weak diff --git a/Source/interfac.cpp b/Source/interfac.cpp index 47a11f5c9..4fd3e57fd 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" void *sgpBackCel; int sgdwProgress; diff --git a/Source/inv.cpp b/Source/inv.cpp index 79216766a..7663a14aa 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" BOOL invflag; void *pInvCels; diff --git a/Source/items.cpp b/Source/items.cpp index c6c1ac798..8c52ae8fc 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int itemactive[MAXITEMS]; int uitemflag; diff --git a/Source/lighting.cpp b/Source/lighting.cpp index d0eab5468..2c0233e9d 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" LightListStruct VisionList[MAXVISION]; unsigned char lightactive[MAXLIGHTS]; diff --git a/Source/list.h b/Source/list.h index 49706c9d0..4c511a8c1 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" + #ifdef _MSC_VER #pragma warning (disable : 4291) // no matching operator delete found #endif diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 3be16f8b5..db21b657b 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" unsigned char *tbuff; diff --git a/Source/logging.cpp b/Source/logging.cpp index cb8844216..203ad3d96 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" #ifdef __cplusplus static CCritSect sgMemCrit; diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 2a7dc4146..3ad64ec5b 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" char gszHero[16]; diff --git a/Source/minitext.cpp b/Source/minitext.cpp index 3f068854f..c10b2bdbf 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int qtexty; // weak char *qtextptr; diff --git a/Source/missiles.cpp b/Source/missiles.cpp index 19061e6af..7d679faba 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int missileactive[MAXMISSILES]; int missileavail[MAXMISSILES]; diff --git a/Source/monster.cpp b/Source/monster.cpp index 47c04b892..c0ec0467a 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" // Tracks which missile files are already loaded int MissileFileFlag; diff --git a/Source/movie.cpp b/Source/movie.cpp index 380d07fd5..c447c59ea 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" BYTE movie_playing; BOOL loop_movie; diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index dacd6d778..d566d79ec 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" int sgdwMpqOffset; // idb char mpq_buf[4096]; diff --git a/Source/msg.cpp b/Source/msg.cpp index a025569f9..4c09184d5 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" static DWORD sgdwOwnerWait; static DWORD sgdwRecvOffset; diff --git a/Source/msgcmd.cpp b/Source/msgcmd.cpp index c04c90a99..f97f20e50 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" #define COMMAND_LEN 128 diff --git a/Source/multi.cpp b/Source/multi.cpp index 2efc98316..455e450aa 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -1,6 +1,6 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" +#include "../DiabloUI/diabloui.h" BOOLEAN gbSomebodyWonGameKludge; // weak TBuffer sgHiPriBuf; diff --git a/Source/nthread.cpp b/Source/nthread.cpp index 52f528090..d660ce340 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" char byte_679704; // weak int gdwMsgLenTbl[MAX_PLRS]; diff --git a/Source/objects.cpp b/Source/objects.cpp index 3b261d2a7..89e288649 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int trapid; // weak int trapdir; // weak diff --git a/Source/pack.cpp b/Source/pack.cpp index 5478da58a..c79f6ebf4 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" void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield) { diff --git a/Source/palette.cpp b/Source/palette.cpp index 96092e804..a3a198fc1 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -1,6 +1,5 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" +#include "../3rdParty/Storm/Source/storm.h" PALETTEENTRY logical_palette[256]; PALETTEENTRY system_palette[256]; diff --git a/Source/path.cpp b/Source/path.cpp index b417905db..e6b93dbec 100644 --- a/Source/path.cpp +++ b/Source/path.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" // preallocated nodes, search is terminated after 300 nodes are visited PATHNODE path_nodes[MAXPATHNODES]; diff --git a/Source/pfile.cpp b/Source/pfile.cpp index ea888c301..d9eae78f7 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" #define PASSWORD_SINGLE "xrgyrkj1" #define PASSWORD_MULTI "szqnlsk1" diff --git a/Source/player.cpp b/Source/player.cpp index ed220abc6..1c2146da4 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" int plr_lframe_size; int plr_wframe_size; diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index a644c480a..0ffc1c06b 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" static unsigned char plr_msg_slot; _plrmsg plr_msgs[PMSG_COUNT]; diff --git a/Source/portal.cpp b/Source/portal.cpp index b0d5dc19c..e98e1a8d3 100644 --- a/Source/portal.cpp +++ b/Source/portal.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" PortalStruct portal[MAXPORTAL]; int portalindex; diff --git a/Source/quests.cpp b/Source/quests.cpp index ce2ec71ed..c4bc57b8a 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int qtopline; // idb BOOL questlog; diff --git a/Source/render.cpp b/Source/render.cpp index 103283978..c439cd2cb 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" #include "_asm.cpp" int WorldBoolFlag = 0; diff --git a/Source/restrict.cpp b/Source/restrict.cpp index 380c4b8fd..643c54c5b 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" BOOL SystemSupported() { diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 656d30d96..d95fa9fe5 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" int light_table_index; // weak int PitchTbl[1024]; diff --git a/Source/setmaps.cpp b/Source/setmaps.cpp index 3e195f6e8..262c9b979 100644 --- a/Source/setmaps.cpp +++ b/Source/setmaps.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" // BUGFIX: constant data should be const unsigned char SkelKingTrans1[8] = { diff --git a/Source/sha.cpp b/Source/sha.cpp index c7ef540a4..2a4d19bd5 100644 --- a/Source/sha.cpp +++ b/Source/sha.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" SHA1Context sgSHA1[3]; diff --git a/Source/sound.cpp b/Source/sound.cpp index 524dfb4e0..70356ebd0 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" LPDIRECTSOUNDBUFFER DSBs[8]; LPDIRECTSOUND sglpDS; diff --git a/Source/spells.cpp b/Source/spells.cpp index cc1b8ce9e..05afd9861 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" SpellData spelldata[MAX_SPELLS] = { // clang-format off diff --git a/Source/stores.cpp b/Source/stores.cpp index 051edbdd3..c2d3f1e42 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int stextup; // weak int storenumh; // weak diff --git a/Source/sync.cpp b/Source/sync.cpp index f49991f07..e97509eee 100644 --- a/Source/sync.cpp +++ b/Source/sync.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" WORD sync_word_6AA708[MAXMONSTERS]; int sgnMonsters; diff --git a/Source/textdat.cpp b/Source/textdat.cpp index fabb5f94f..fb7c0b693 100644 --- a/Source/textdat.cpp +++ b/Source/textdat.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" /* todo: move text out of struct */ diff --git a/Source/themes.cpp b/Source/themes.cpp index e0ac7098a..9a6b33208 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int numthemes; // idb BOOL armorFlag; diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index fd673f728..d5b20a79f 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" static TMsg *sgpTimedMsgHead; diff --git a/Source/town.cpp b/Source/town.cpp index 1f37e3486..1ac1a9485 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" void town_clear_upper_buf(BYTE *pBuff) { diff --git a/Source/towners.cpp b/Source/towners.cpp index 081b89ba7..3ced7f25f 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int storeflag; // weak int sgnCowMsg; diff --git a/Source/track.cpp b/Source/track.cpp index fc02a7a96..86f3d5f1c 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" static BYTE sgbIsScrolling; static DWORD sgdwLastWalk; diff --git a/Source/trigs.cpp b/Source/trigs.cpp index f3fd0d911..7af6c48a5 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -1,6 +1,4 @@ -//HEADER_GOES_HERE - -#include "../types.h" +#include "diablo.h" int trigflag_0; int trigflag_1; diff --git a/Source/wave.cpp b/Source/wave.cpp index 2dbde315a..ebb75cea4 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" BOOL WCloseFile(HANDLE file) { diff --git a/types.h b/types.h index ef715d13d..2ce7dfefd 100644 --- a/types.h +++ b/types.h @@ -42,10 +42,6 @@ #include "enums.h" #include "structs.h" -#include "DiabloUI/diabloui.h" -#include "3rdParty/Storm/Source/storm.h" -#include "3rdParty/PKWare/pkware.h" - // If defined, use copy protection [Default -> Defined] //#define COPYPROT @@ -61,84 +57,4 @@ // 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 - #endif From e47a2d4b5d13d46a2a435d2ff1747784259561b4 Mon Sep 17 00:00:00 2001 From: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com> Date: Sun, 21 Apr 2019 19:32:27 +0200 Subject: [PATCH 03/53] InitL4Triggers bin exact --- Source/trigs.cpp | 109 ++++++++++++++--------------------------------- 1 file changed, 33 insertions(+), 76 deletions(-) diff --git a/Source/trigs.cpp b/Source/trigs.cpp index 7af6c48a5..658197caa 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -247,88 +247,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; } From 1397258cf7848d2e63d59470ca578b418f8b4411 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Sun, 21 Apr 2019 12:29:59 +0300 Subject: [PATCH 04/53] Clean up OperateBook. --- Source/objects.cpp | 134 +++++++++++++++++++++------------------------ 1 file changed, 61 insertions(+), 73 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 89e288649..680d761d0 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2820,88 +2820,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; From 3dad3bb7d6138b2fe75ebd71c8392defb59aa8ca Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Sun, 21 Apr 2019 12:40:40 +0300 Subject: [PATCH 05/53] Clean up OperateTrapLvr. --- Source/objects.cpp | 57 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 680d761d0..fa7d3d000 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3096,41 +3096,32 @@ 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 + int frame; + int j; + int oi; - 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); + 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; } } } From 24b5b0c751eb717ebe0f00abc282e22c20da71cf Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Sun, 21 Apr 2019 12:51:38 +0300 Subject: [PATCH 06/53] Clean up OperatePedistal [sic] --- Source/objects.cpp | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index fa7d3d000..3588b8e9b 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3175,38 +3175,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; } } } From 9dd6b7f504409c14bed1707b0ea6335614ed371b Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Sun, 21 Apr 2019 19:26:04 +0300 Subject: [PATCH 07/53] Clean up OperateFountains. --- Source/objects.cpp | 247 ++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 109 insertions(+), 140 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 3588b8e9b..78c39b43e 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -3919,158 +3919,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; diff --git a/Source/objects.h b/Source/objects.h index 670a789b3..ad84693ae 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -123,7 +123,7 @@ 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); From a62a9b2dec2964b1fbd7011bb89c64a08ecd1adf Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 21 Apr 2019 23:38:14 +0200 Subject: [PATCH 08/53] Clean up S_StartConfirm --- Source/stores.cpp | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index c2d3f1e42..ba31d0944 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -1248,8 +1248,8 @@ void S_StartNoRoom() void S_StartConfirm() { - BOOL idprint; // esi - char iclr; // [esp+Ch] [ebp-4h] + BOOL idprint; + char iclr; StartStore(stextshold); stextscrl = 0; @@ -1283,47 +1283,34 @@ 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() { From 55793ef55fb8678dfe78de4b9e81fdd1b8a1b811 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Sun, 21 Apr 2019 19:51:42 -0500 Subject: [PATCH 09/53] dx_init and windowed mode (#967) --- Source/dx.cpp | 92 +++++++++++++++++++++++++++------------------ Source/missiles.cpp | 5 +++ Source/missiles.h | 1 + 3 files changed, 62 insertions(+), 36 deletions(-) diff --git a/Source/dx.cpp b/Source/dx.cpp index 141efe610..2ed2fa0af 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -20,26 +20,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__ @@ -49,37 +49,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) { + MI_Dummy2(); /* break_exception(); */ + } 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) { + MI_Dummy2(); /* break_exception(); */ + } 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, 8); #else - v8 = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, v6, v7, 8); + hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, 8); #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, 8); +#else + hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, 8); +#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/missiles.cpp b/Source/missiles.cpp index 7d679faba..c03e1e13e 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2841,6 +2841,11 @@ void MI_Dummy(int i) return; } +void MI_Dummy2() +{ + return; +} + void MI_Golem(int i) { int CrawlNum[6] = { 0, 3, 12, 45, 94, 159 }; diff --git a/Source/missiles.h b/Source/missiles.h index d49e82f03..f177ec4a8 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -98,6 +98,7 @@ void AddDiabApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienem int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micaster, int id, int midam, int spllvl); int Sentfire(int i, int sx, int sy); void MI_Dummy(int i); +void MI_Dummy2(); void MI_Golem(int i); void MI_SetManashield(int i); void MI_LArrow(int i); From 777c517b8e41490377118d6d2e52e339e696825e Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 22 Apr 2019 02:23:12 -0500 Subject: [PATCH 10/53] Change ASM macro --- Source/control.cpp | 12 ++++++------ Source/drlg_l1.cpp | 4 ++-- Source/drlg_l2.cpp | 4 ++-- Source/drlg_l3.cpp | 4 ++-- Source/drlg_l4.cpp | 4 ++-- Source/engine.cpp | 40 ++++++++++++++++++++-------------------- Source/gendung.cpp | 12 ++++++------ Source/inv.cpp | 2 +- Source/items.cpp | 2 +- Source/minitext.cpp | 2 +- Source/objects.cpp | 2 +- Source/render.cpp | 2 +- Source/scrollrt.cpp | 6 +++--- Source/stores.cpp | 2 +- Source/town.cpp | 10 +++++----- types.h | 4 ++++ 16 files changed, 58 insertions(+), 54 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 7652c4995..14b4e1fa2 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -177,7 +177,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 @@ -627,7 +627,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 @@ -939,7 +939,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 @@ -1015,7 +1015,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 @@ -1042,7 +1042,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 @@ -2309,7 +2309,7 @@ void RedBack() /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM if (leveltype != DTYPE_HELL) { __asm { mov edi, gpBuffer diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index c268d22bd..e893bdce9 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -208,7 +208,7 @@ void DRLG_L1Pass3() lv = 22 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -251,7 +251,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 diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 0e71ab0e1..11290beb9 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -456,7 +456,7 @@ void DRLG_L2Pass3() lv = 12 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -498,7 +498,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 diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 3c598c6bd..c243c467d 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1817,7 +1817,7 @@ void DRLG_L3Pass3() lv = 8 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -1859,7 +1859,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 46b668ba8..46d201800 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -2066,7 +2066,7 @@ void DRLG_L4Pass3() lv = 30 - 1; -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, pMegaTiles mov eax, lv @@ -2108,7 +2108,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/engine.cpp b/Source/engine.cpp index 6e77744cb..dcef97274 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -1,7 +1,7 @@ #include "diablo.h" #include "../3rdParty/Storm/Source/storm.h" -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM #pragma warning(disable : 4731) // frame pointer register 'ebp' modified by inline assembly code #endif @@ -30,7 +30,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 @@ -248,7 +248,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 @@ -403,7 +403,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 @@ -739,7 +739,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 @@ -824,7 +824,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 @@ -1016,7 +1016,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 @@ -1187,7 +1187,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 @@ -1503,7 +1503,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 { @@ -1596,7 +1596,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 @@ -1717,7 +1717,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 @@ -1858,7 +1858,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 @@ -2037,7 +2037,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 @@ -2069,7 +2069,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 @@ -2549,7 +2549,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 @@ -2733,7 +2733,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 @@ -2945,7 +2945,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 @@ -3182,7 +3182,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 @@ -3383,7 +3383,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 @@ -3607,7 +3607,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/gendung.cpp b/Source/gendung.cpp index 631556b4c..648894c4f 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -128,7 +128,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; @@ -161,7 +161,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 @@ -186,7 +186,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 @@ -219,7 +219,7 @@ void MakeSpeedCels() } #endif } else { -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov ebx, pDungeonCels mov eax, i @@ -320,7 +320,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 @@ -356,7 +356,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/inv.cpp b/Source/inv.cpp index 7663a14aa..1afa53578 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -118,7 +118,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 8c52ae8fc..721237364 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3647,7 +3647,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; diff --git a/Source/minitext.cpp b/Source/minitext.cpp index c10b2bdbf..f5c1b75a5 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -100,7 +100,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/objects.cpp b/Source/objects.cpp index 78c39b43e..1bd665ba5 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2188,7 +2188,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 diff --git a/Source/render.cpp b/Source/render.cpp index c439cd2cb..65200cac5 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -111,7 +111,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/scrollrt.cpp b/Source/scrollrt.cpp index d95fa9fe5..175a53993 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2127,7 +2127,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 @@ -2192,7 +2192,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) @@ -2642,7 +2642,7 @@ void DoBlitScreen(DWORD dwX, DWORD dwY, DWORD dwWdt, DWORD dwHgt) /// ASSERT: assert(gpBuffer); -#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#ifdef USE_ASM __asm { mov esi, gpBuffer mov edi, DDS_desc.lpSurface diff --git a/Source/stores.cpp b/Source/stores.cpp index ba31d0944..76457df68 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -271,7 +271,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 diff --git a/Source/town.cpp b/Source/town.cpp index 1ac1a9485..4ef5ede50 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -4,7 +4,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 @@ -67,7 +67,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 @@ -942,7 +942,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 @@ -1107,7 +1107,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 @@ -1173,7 +1173,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/types.h b/types.h index 2ce7dfefd..f750691cc 100644 --- a/types.h +++ b/types.h @@ -42,6 +42,10 @@ #include "enums.h" #include "structs.h" +#if (_MSC_VER >= 800) && (_MSC_VER <= 1200) +#define USE_ASM +#endif + // If defined, use copy protection [Default -> Defined] //#define COPYPROT From 55a0396f8fa1a82fd9a800bfd21f6e6d117e3801 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 21 Apr 2019 18:48:34 +0200 Subject: [PATCH 11/53] Clean up mem_free_dbg style --- Source/cursor.cpp | 7 +------ Source/debug.cpp | 4 +--- Source/doom.cpp | 4 +--- Source/drlg_l1.cpp | 6 +----- Source/drlg_l2.cpp | 17 +++++------------ Source/drlg_l4.cpp | 6 +----- Source/dthread.cpp | 10 ++++------ Source/gmenu.cpp | 22 +++++----------------- Source/interfac.cpp | 6 +----- Source/inv.cpp | 5 +---- Source/items.cpp | 7 ++----- Source/lighting.cpp | 6 +----- Source/minitext.cpp | 15 +++------------ Source/monster.cpp | 5 +---- Source/mpqapi.cpp | 11 ++--------- Source/msg.cpp | 6 +----- Source/objects.cpp | 21 ++++++++------------- Source/player.cpp | 38 +++++++++----------------------------- Source/stores.cpp | 14 +++----------- Source/tmsg.cpp | 8 ++++---- Source/towners.cpp | 9 ++------- Source/wave.cpp | 4 +--- 22 files changed, 58 insertions(+), 173 deletions(-) diff --git a/Source/cursor.cpp b/Source/cursor.cpp index 124ba1a76..62649c80f 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -75,12 +75,7 @@ void InitCursor() void FreeCursor() { - void *p; - - p = pCursCels; - pCursCels = NULL; - mem_free_dbg(p); - + MemFreeDbg(pCursCels); ClearCursor(); } diff --git a/Source/debug.cpp b/Source/debug.cpp index 1673d9e93..9139765bb 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -13,9 +13,7 @@ void LoadDebugGFX() void FreeDebugGFX() { - void *temp = pSquareCel; - pSquareCel = NULL; - mem_free_dbg(temp); + MemFreeDbg(pSquareCel); } void CheckDungeonClear() diff --git a/Source/doom.cpp b/Source/doom.cpp index eff49b2ed..f20768b65 100644 --- a/Source/doom.cpp +++ b/Source/doom.cpp @@ -42,9 +42,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 e893bdce9..3a085c727 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -425,11 +425,7 @@ void DRLG_LoadL1SP() void DRLG_FreeL1SP() { - void *ptr; - - ptr = pSetPiece; - pSetPiece = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pSetPiece); } void DRLG_L5(int entry) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 11290beb9..6ba5edf2b 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -650,11 +650,7 @@ void DRLG_LoadL2SP() void DRLG_FreeL2SP() { - char *ptr; - - ptr = pSetPiece_2; - pSetPiece_2 = NULL; - mem_free_dbg(ptr); + MemFreeDbg(pSetPiece_2); } void DRLG_L2(int entry) @@ -1517,21 +1513,18 @@ void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd) void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd) { - HALLNODE *p1; - HALLNODE *p2; + HALLNODE *p; - p1 = pHallList->pNext; + p = pHallList->pNext; *nX1 = pHallList->nHallx1; *nY1 = pHallList->nHally1; *nX2 = pHallList->nHallx2; *nY2 = pHallList->nHally2; *nHd = pHallList->nHalldir; - p2 = pHallList; - pHallList = NULL; - mem_free_dbg(p2); + MemFreeDbg(pHallList); - pHallList = p1; + pHallList = p; } void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 46d201800..6a69341e3 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -304,11 +304,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) diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 1aabb4f66..ed4304495 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -127,7 +127,7 @@ unsigned int __stdcall dthread_handler(void *unused) void dthread_cleanup() { char *error_buf; - TMegaPkt *tmp1, *tmp2; + TMegaPkt *tmp; if (sghWorkToDoEvent == NULL) { return; @@ -147,10 +147,8 @@ 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/gmenu.cpp b/Source/gmenu.cpp index bd0e538c7..7698406fc 100644 --- a/Source/gmenu.cpp +++ b/Source/gmenu.cpp @@ -70,23 +70,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/interfac.cpp b/Source/interfac.cpp index 4fd3e57fd..f56c16594 100644 --- a/Source/interfac.cpp +++ b/Source/interfac.cpp @@ -243,11 +243,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 1afa53578..0bed8ed3b 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -90,10 +90,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() diff --git a/Source/items.cpp b/Source/items.cpp index 721237364..ab14c9229 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3124,13 +3124,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]); } } diff --git a/Source/lighting.cpp b/Source/lighting.cpp index 2c0233e9d..0406e0439 100644 --- a/Source/lighting.cpp +++ b/Source/lighting.cpp @@ -751,11 +751,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/minitext.cpp b/Source/minitext.cpp index f5c1b75a5..3be0ffe2b 100644 --- a/Source/minitext.cpp +++ b/Source/minitext.cpp @@ -39,24 +39,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; diff --git a/Source/monster.cpp b/Source/monster.cpp index c0ec0467a..d050c6eb8 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -5861,15 +5861,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/mpqapi.cpp b/Source/mpqapi.cpp index d566d79ec..05e686ba0 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -575,16 +575,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/msg.cpp b/Source/msg.cpp index 4c09184d5..3bdd8a09f 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -106,13 +106,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; } } diff --git a/Source/objects.cpp b/Source/objects.cpp index 1bd665ba5..20c5aed5a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -394,12 +394,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; } @@ -4666,21 +4663,19 @@ 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; diff --git a/Source/player.cpp b/Source/player.cpp index 1c2146da4..76eeb199c 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -345,39 +345,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/stores.cpp b/Source/stores.cpp index 76457df68..672b10bed 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -130,17 +130,9 @@ void SetupTownStores() 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() diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index d5b20a79f..9bdc34fd2 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -38,11 +38,11 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen) 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/towners.cpp b/Source/towners.cpp index 3ced7f25f..ef2f6f5fc 100644 --- a/Source/towners.cpp +++ b/Source/towners.cpp @@ -391,22 +391,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/wave.cpp b/Source/wave.cpp index ebb75cea4..36858871f 100644 --- a/Source/wave.cpp +++ b/Source/wave.cpp @@ -102,9 +102,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) From deb428884949438a6f49cd4acf27c0f6c942d07e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 21 Apr 2019 18:48:50 +0200 Subject: [PATCH 12/53] Code style --- Source/items.cpp | 22 +++++++++++----------- Source/stores.cpp | 11 ++--------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index ab14c9229..c0496e1aa 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1367,7 +1367,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); @@ -1408,7 +1408,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; @@ -1420,7 +1420,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; @@ -4730,11 +4730,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; } } @@ -4746,7 +4746,7 @@ void NextItemRecord(int i) { gnNumGetRecords--; - if(gnNumGetRecords == 0) { + if (gnNumGetRecords == 0) { return; } @@ -4762,7 +4762,7 @@ void SetItemRecord(int nSeed, WORD wCI, int nIndex) dwTicks = GetTickCount(); - if(gnNumGetRecords == MAXITEMS) { + if (gnNumGetRecords == MAXITEMS) { return; } @@ -4780,11 +4780,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/stores.cpp b/Source/stores.cpp index 672b10bed..f389c33f1 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -74,7 +74,7 @@ char *talkname[9] = { void InitStores() { - int i; // eax + int i; pSTextBoxCels = LoadFileInMem("Data\\TextBox2.CEL", 0); pCelBuff = LoadFileInMem("Data\\PentSpn2.CEL", 0); @@ -93,16 +93,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) { @@ -126,7 +120,6 @@ void SetupTownStores() SpawnBoy(plr[myplr]._pLevel); SpawnPremium(plr[myplr]._pLevel); } -// 679660: using guessed type char gbMaxPlayers; void FreeStoreMem() { From d6c8e6e44cc276f7360df4ceffd0e8947523794e Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 14:30:40 +0300 Subject: [PATCH 13/53] Clean up OperateObject. (#1003) Also correct argument type for some functions it calls. They did not lost their binary exactness. --- Source/objects.cpp | 153 ++++++++++++++++++++++----------------------- Source/objects.h | 8 +-- 2 files changed, 78 insertions(+), 83 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 20c5aed5a..62d920110 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2963,7 +2963,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; @@ -3069,7 +3069,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; @@ -3123,7 +3123,7 @@ void OperateTrapLvr(int i) } } -void OperateSarc(int pnum, int i, unsigned char sendmsg) +void OperateSarc(int pnum, int i, BOOL sendmsg) { if (object[i]._oSelFlag) { if (!deltaload) @@ -3828,7 +3828,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; @@ -4105,32 +4105,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: @@ -4138,99 +4161,71 @@ 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; } } diff --git a/Source/objects.h b/Source/objects.h index ad84693ae..5ca062bd7 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -104,12 +104,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,7 +118,7 @@ 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); From 0a2b767b28273109803113870f3636c504df54d2 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 22 Apr 2019 13:59:07 +0200 Subject: [PATCH 14/53] Clean up InitControlPan (#1001) --- Source/control.cpp | 88 +++++++++++++++++++--------------------------- Source/control.h | 8 ++--- 2 files changed, 40 insertions(+), 56 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index 14b4e1fa2..9d8e71ae2 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -6,8 +6,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; @@ -18,14 +18,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 @@ -1176,64 +1176,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(); @@ -1254,23 +1248,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() { @@ -2580,8 +2564,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 From 4b75a07141ad4bd6d7fda2d12162712978e16001 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 22 Apr 2019 19:15:58 +0200 Subject: [PATCH 15/53] Clean up DrawSArrows --- Source/stores.cpp | 54 ++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index f389c33f1..f45ed3bfa 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -288,46 +288,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 - 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 = stextsel; + if (storenumh > 1) + yd3 = 1000 * (stextsval + ((yd3 - stextup) >> 2)) / (storenumh - 1) * (SStringY[y2] - SStringY[y1] - 24) / 1000; + else + 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() { From be3526054cc65829f0dbfb297ef3a30944e5897a Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 22 Apr 2019 14:41:42 +0200 Subject: [PATCH 16/53] Apply theme_id enums --- Source/objects.cpp | 202 ++++++++++++++++++++++----------------------- Source/themes.cpp | 28 +++---- enums.h | 2 +- 3 files changed, 116 insertions(+), 116 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 3b261d2a7..4b85b58af 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -131,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] = { @@ -368,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; diff --git a/Source/themes.cpp b/Source/themes.cpp index d052b84df..bc4867a3e 100644 --- a/Source/themes.cpp +++ b/Source/themes.cpp @@ -218,44 +218,44 @@ BOOL CheckThemeReqs(int t) rv = TRUE; switch (t) { - case 1: - case 3: - case 5: + case THEME_SHRINE: + case THEME_SKELROOM: + case THEME_LIBRARY: if (leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) { rv = FALSE; } break; - case 7: + case THEME_BLOODFOUNTAIN: if (!bFountainFlag) { rv = FALSE; } break; - case 9: + case THEME_PURIFYINGFOUNTAIN: if (!pFountainFlag) { rv = FALSE; } break; - case 10: + case THEME_ARMORSTAND: if (leveltype == DTYPE_CATHEDRAL) { rv = FALSE; } break; - case 12: + case THEME_CAULDRON: if (leveltype != DTYPE_HELL || !cauldronFlag) { rv = FALSE; } break; - case 13: + case THEME_MURKYFOUNTAIN: if (!mFountainFlag) { rv = FALSE; } break; - case 14: + case THEME_TEARFOUNTAIN: if (!tFountainFlag) { rv = FALSE; } break; - case 16: + case THEME_WEAPONRACK: if (leveltype == DTYPE_CATHEDRAL) { rv = FALSE; } @@ -432,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/enums.h b/enums.h index f42cd41c3..9e4fc0351 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 { From 5e8a7a5b7fdfa7423595b94d7168cd5169135718 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 21:43:22 +0300 Subject: [PATCH 17/53] Clean up BreakCrux. --- Source/objects.cpp | 56 ++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 70a79b0aa..a9b4ce995 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4390,42 +4390,30 @@ 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 + int j, oi; + BOOL triggered; - 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); + 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; From 090e3d36fdffbd2b298797af191cab590d0ad954 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 22:44:34 +0300 Subject: [PATCH 18/53] Clean up BreakBarrel. --- Source/objects.cpp | 160 ++++++++++++++++++--------------------------- Source/objects.h | 2 +- 2 files changed, 64 insertions(+), 98 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index a9b4ce995..cd61288aa 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4417,107 +4417,73 @@ void BreakCrux(int i) } // 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; diff --git a/Source/objects.h b/Source/objects.h index 5ca062bd7..55657ceae 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -133,7 +133,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); From c5ad888cc1426c9f7ff6b0cfc51ccc6661ea85a5 Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 22 Apr 2019 23:54:49 +0200 Subject: [PATCH 19/53] multi_player_joins bin exact (#1009) --- Source/multi.cpp | 80 ++++++++++++++++++------------------------------ Source/multi.h | 2 +- 2 files changed, 31 insertions(+), 51 deletions(-) diff --git a/Source/multi.cpp b/Source/multi.cpp index 455e450aa..fe2068844 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -5,7 +5,7 @@ BOOLEAN gbSomebodyWonGameKludge; // weak 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]; @@ -928,60 +928,40 @@ BOOL multi_upgrade(int *pfExitProgram) 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; + char *msg; + if (myplr != pnum) { - v5 = &sgwPackPlrOffsetTbl[pnum]; - if (*v5 == cmd->wOffset || (*v5 = 0, !cmd->wOffset)) { - if (!a3 && !*v5) { + if (sgwPackPlrOffsetTbl[pnum] == cmd->wOffset || (sgwPackPlrOffsetTbl[pnum] = 0, !cmd->wOffset)) { + if (!a3 && !sgwPackPlrOffsetTbl[pnum]) { 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); + memcpy((char *)&netplr[pnum] + cmd->wOffset, &cmd[1], cmd->wBytes); + sgwPackPlrOffsetTbl[pnum] += cmd->wBytes; + if (sgwPackPlrOffsetTbl[pnum] == 1266) { + sgwPackPlrOffsetTbl[pnum] = 0; + multi_player_left_msg(pnum, 0); + plr[pnum]._pGFXLoad = 0; + UnPackPlayer(&netplr[pnum], pnum, 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; + gbActivePlayers++; + plr[pnum].plractive = 1; + msg = "Player '%s' (level %d) just joined the game"; + if (sgbPlayerTurnBitTbl[pnum] == 0) + msg = "Player '%s' (level %d) is already in the game"; + EventPlrMsg(msg, 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 { - StartStand(v3, 0); + plr[pnum]._pgfxnum = 0; + LoadPlrGFX(pnum, PFILE_DEATH); + plr[pnum]._pmode = 8; + 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; } } } diff --git a/Source/multi.h b/Source/multi.h index ac3a2cfb5..c85662ee0 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; From d13f45341041eaf0d35e669394d20d7838579fc1 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 22 Apr 2019 18:53:50 -0500 Subject: [PATCH 20/53] multi_player_joins + dumphist --- Source/msg.cpp | 2 +- Source/multi.cpp | 141 ++++++++++++++++++++++++++++++++++------------- Source/multi.h | 5 +- 3 files changed, 108 insertions(+), 40 deletions(-) diff --git a/Source/msg.cpp b/Source/msg.cpp index 3bdd8a09f..19b4f1466 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -2230,7 +2230,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/multi.cpp b/Source/multi.cpp index fe2068844..fc807a43a 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -3,6 +3,9 @@ #include "../DiabloUI/diabloui.h" BOOLEAN gbSomebodyWonGameKludge; // weak +#ifdef _DEBUG +DWORD gdwHistTicks; +#endif TBuffer sgHiPriBuf; char szPlayerDescript[128]; WORD sgwPackPlrOffsetTbl[MAX_PLRS]; @@ -33,6 +36,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) { @@ -722,6 +759,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(); @@ -926,46 +967,70 @@ BOOL multi_upgrade(int *pfExitProgram) return result; } -void multi_player_joins(int pnum, TCmdPlrInfoHdr *cmd, int a3) +void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv) { - char *msg; + char *szEvent; - if (myplr != pnum) { - if (sgwPackPlrOffsetTbl[pnum] == cmd->wOffset || (sgwPackPlrOffsetTbl[pnum] = 0, !cmd->wOffset)) { - if (!a3 && !sgwPackPlrOffsetTbl[pnum]) { - multi_send_pinfo(pnum, CMD_ACK_PLRINFO); - } - memcpy((char *)&netplr[pnum] + cmd->wOffset, &cmd[1], cmd->wBytes); - sgwPackPlrOffsetTbl[pnum] += cmd->wBytes; - if (sgwPackPlrOffsetTbl[pnum] == 1266) { - sgwPackPlrOffsetTbl[pnum] = 0; - multi_player_left_msg(pnum, 0); - plr[pnum]._pGFXLoad = 0; - UnPackPlayer(&netplr[pnum], pnum, 1); - if (a3) { - gbActivePlayers++; - plr[pnum].plractive = 1; - msg = "Player '%s' (level %d) just joined the game"; - if (sgbPlayerTurnBitTbl[pnum] == 0) - msg = "Player '%s' (level %d) is already in the game"; - EventPlrMsg(msg, 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 = 8; - 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; - } - } - } - } + 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 } diff --git a/Source/multi.h b/Source/multi.h index c85662ee0..6ad6ca242 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -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); @@ -51,7 +54,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 */ From 3a636fdcc6894024ae052de8851e50f90179fd7a Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 22 Apr 2019 20:21:52 -0500 Subject: [PATCH 21/53] Add missing functions for MI_Dummy (#1004) --- Source/dx.cpp | 4 ++-- Source/engine.cpp | 15 +++++++++++++++ Source/engine.h | 1 + Source/fault.cpp | 11 +++++++++++ Source/fault.h | 1 + Source/init.cpp | 2 +- Source/missiles.cpp | 5 ----- Source/missiles.h | 1 - Source/mpqapi.cpp | 16 +++++++++++++++- Source/mpqapi.h | 2 +- Source/multi.cpp | 6 +----- Source/multi.h | 1 - Source/pfile.cpp | 2 +- Source/tmsg.cpp | 5 +++++ Source/tmsg.h | 1 + 15 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Source/dx.cpp b/Source/dx.cpp index 2ed2fa0af..89395019d 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -59,7 +59,7 @@ void dx_init(HWND hWnd) hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #endif if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { - MI_Dummy2(); /* break_exception(); */ + break_exception(); } else if(hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Diablo\\Direct\\dx.cpp", 155); } @@ -71,7 +71,7 @@ void dx_init(HWND hWnd) hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); #endif if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { - MI_Dummy2(); /* break_exception(); */ + break_exception(); } else if(hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); } diff --git a/Source/engine.cpp b/Source/engine.cpp index dcef97274..ca8d97122 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -2392,6 +2392,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; 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/fault.cpp b/Source/fault.cpp index 459a724b1..0389c4dda 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -32,6 +32,17 @@ LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter() return fault_reset_filter(&fault_unused); } +void break_exception() +{ +/* + LPTOP_LEVEL_EXCEPTION_FILTER pFilter; + + pFilter = SetUnhandledExceptionFilter(TopLevelExceptionFilter); + __asm int 3 + SetUnhandledExceptionFilter(pFilter); +*/ +} + LONG __stdcall TopLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) { PEXCEPTION_RECORD xcpt; diff --git a/Source/fault.h b/Source/fault.h index ec669c7ac..5b5c6250a 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -13,6 +13,7 @@ extern LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; void fault_init_filter(); void fault_cleanup_filter_atexit(); LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter(); +void break_exception(); LONG __stdcall TopLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo); void fault_hex_format(BYTE *ptr, unsigned int numBytes); void fault_unknown_module(LPCVOID lpAddress, LPSTR lpModuleName, int iMaxLength, int *sectionNum, int *sectionOffset); diff --git a/Source/init.cpp b/Source/init.cpp index eafa5fe9c..a7c41fd15 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -43,7 +43,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/missiles.cpp b/Source/missiles.cpp index c03e1e13e..7d679faba 100644 --- a/Source/missiles.cpp +++ b/Source/missiles.cpp @@ -2841,11 +2841,6 @@ void MI_Dummy(int i) return; } -void MI_Dummy2() -{ - return; -} - void MI_Golem(int i) { int CrawlNum[6] = { 0, 3, 12, 45, 94, 159 }; diff --git a/Source/missiles.h b/Source/missiles.h index f177ec4a8..d49e82f03 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -98,7 +98,6 @@ void AddDiabApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienem int AddMissile(int sx, int sy, int dx, int dy, int midir, int mitype, char micaster, int id, int midam, int spllvl); int Sentfire(int i, int sx, int sy); void MI_Dummy(int i); -void MI_Dummy2(); void MI_Golem(int i); void MI_SetManashield(int i); void MI_LArrow(int i); diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 05e686ba0..041153479 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -97,8 +97,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) 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/multi.cpp b/Source/multi.cpp index fe2068844..e9e8aca62 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -732,7 +732,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; @@ -767,10 +767,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; diff --git a/Source/multi.h b/Source/multi.h index c85662ee0..e4a78606a 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -43,7 +43,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); diff --git a/Source/pfile.cpp b/Source/pfile.cpp index d9eae78f7..e35783d19 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -104,7 +104,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/tmsg.cpp b/Source/tmsg.cpp index 9bdc34fd2..634d1b21a 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -36,6 +36,11 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen) *tail = msg; } +void tmsg_start() +{ + /// ASSERT: assert(! sgpTimedMsgHead); +} + void *tmsg_cleanup() { TMsg *next; 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__ */ From b76156e206cf75ecf2355774f749ed68c1ea11d8 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Mon, 22 Apr 2019 21:13:34 -0500 Subject: [PATCH 22/53] Implement breakpoint handler --- Source/appfat.cpp | 38 ++++++++++++++++++++++++++++++++++++++ Source/appfat.h | 4 ++++ Source/dx.cpp | 4 ++-- Source/fault.cpp | 11 ----------- Source/fault.h | 1 - 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/Source/appfat.cpp b/Source/appfat.cpp index d9c908a8b..427110f46 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -13,6 +13,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; @@ -421,6 +456,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/dx.cpp b/Source/dx.cpp index 89395019d..fea1fdff3 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -59,7 +59,7 @@ void dx_init(HWND hWnd) hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_NORMAL | DDSCL_ALLOWREBOOT); #endif if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { - break_exception(); + TriggerBreak(); } else if(hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Diablo\\Direct\\dx.cpp", 155); } @@ -71,7 +71,7 @@ void dx_init(HWND hWnd) hDDVal = lpDDInterface->lpVtbl->SetCooperativeLevel(lpDDInterface, hWnd, DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT | DDSCL_FULLSCREEN); #endif if(hDDVal == DDERR_EXCLUSIVEMODEALREADYSET) { - break_exception(); + TriggerBreak(); } else if(hDDVal != DD_OK) { ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); } diff --git a/Source/fault.cpp b/Source/fault.cpp index 0389c4dda..459a724b1 100644 --- a/Source/fault.cpp +++ b/Source/fault.cpp @@ -32,17 +32,6 @@ LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter() return fault_reset_filter(&fault_unused); } -void break_exception() -{ -/* - LPTOP_LEVEL_EXCEPTION_FILTER pFilter; - - pFilter = SetUnhandledExceptionFilter(TopLevelExceptionFilter); - __asm int 3 - SetUnhandledExceptionFilter(pFilter); -*/ -} - LONG __stdcall TopLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo) { PEXCEPTION_RECORD xcpt; diff --git a/Source/fault.h b/Source/fault.h index 5b5c6250a..ec669c7ac 100644 --- a/Source/fault.h +++ b/Source/fault.h @@ -13,7 +13,6 @@ extern LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter; void fault_init_filter(); void fault_cleanup_filter_atexit(); LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter(); -void break_exception(); LONG __stdcall TopLevelExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo); void fault_hex_format(BYTE *ptr, unsigned int numBytes); void fault_unknown_module(LPCVOID lpAddress, LPSTR lpModuleName, int iMaxLength, int *sectionNum, int *sectionOffset); From 12811e1f64f90a3d980e6b68ee7f215c200a94b1 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 07:49:54 +0300 Subject: [PATCH 23/53] Clean up SyncBreakObj. --- Source/objects.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index cd61288aa..b2d0ef60f 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4519,11 +4519,8 @@ void BreakObject(int pnum, int oi) 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) From bceb08c32f9f754e7ff4d5ed6829ce9765551556 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 07:57:07 +0300 Subject: [PATCH 24/53] Clean up SyncL1Doors. --- Source/objects.cpp | 50 +++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index b2d0ef60f..c224dcb9c 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4525,36 +4525,32 @@ void SyncBreakObj(int pnum, int oi) 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) From 0cef1bfb29207fb2611c046f3e79e43dc1977e52 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 08:03:38 +0300 Subject: [PATCH 25/53] Clean up SyncCrux. --- Source/objects.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index c224dcb9c..cffa95244 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4555,27 +4555,20 @@ void SyncL1Doors(int i) void SyncCrux(int i) { - signed int v1; // ebx - int v2; // edx - int v3; // eax - int v4; // esi - - 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: + BOOL found; + int j, oi, type; + + 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); } From 5ac60b3aae4679944ccaa232a1635ed9b596a587 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 10:26:15 +0300 Subject: [PATCH 26/53] Clean up SyncL2Doors. Interesting trivia - storing object[i]._otype in local variable makes compiler optimize away double check generated in original binary. --- Source/objects.cpp | 51 +++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index cffa95244..5838d1a23 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4617,40 +4617,31 @@ void SyncPedistal(int i) 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); } } From f444628a7a801ce2a8bd763cc63ccd36b3bd14e0 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 10:32:39 +0300 Subject: [PATCH 27/53] Clean up SyncL3Doors. --- Source/objects.cpp | 47 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 5838d1a23..f721567cd 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4647,39 +4647,26 @@ void SyncL2Doors(int i) void SyncL3Doors(int i) { - int v1; // eax - int v2; // esi - int v3; // ecx - int v4; // edx - int v5; // ebx - int v6; // eax + int x, y; - 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); + 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); } } From 2ccfda1edbe508ff18ea1d71b2902cecabfe9e87 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 08:59:53 +0300 Subject: [PATCH 28/53] Clean up SyncLever. --- Source/objects.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index f721567cd..f49cb8f8c 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4574,11 +4574,8 @@ void SyncCrux(int i) 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) From 1d14b6e22237cd47c211134666f07f1876657fc7 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 06:24:17 +0300 Subject: [PATCH 29/53] Clean up SyncOpL1Door. --- Source/objects.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index f49cb8f8c..4bc30a4a8 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4232,25 +4232,24 @@ void OperateObject(int pnum, int i, BOOL TeleFlag) 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); } } From f31e170d48b803d97751ffcf36efbd4cd4d2ffce Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 06:28:05 +0300 Subject: [PATCH 30/53] Clean up SyncOpL2Door. --- Source/objects.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 4bc30a4a8..f784b2de8 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4255,25 +4255,24 @@ void SyncOpL1Door(int pnum, int cmd, int i) 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); } } From be19543db5008544baa4dfe50a57ff0c8eac68fe Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 06:29:07 +0300 Subject: [PATCH 31/53] Clean up SyncOpL3Door. --- Source/objects.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index f784b2de8..175759204 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4278,25 +4278,24 @@ void SyncOpL2Door(int pnum, int cmd, int i) 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); } } From 174d2c1eba7f9a3f52a1c52afdf7baf88fe5673b Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Mon, 22 Apr 2019 06:39:12 +0300 Subject: [PATCH 32/53] Clean up SyncOpObject. --- Source/objects.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 175759204..257c7bf70 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4306,6 +4306,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); @@ -4316,14 +4324,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: @@ -4340,18 +4349,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); @@ -4369,6 +4366,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); @@ -4377,7 +4377,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); From 520e94b49b57b01e916f56ab79eaa9cb7b71aef9 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 23 Apr 2019 23:31:48 +0300 Subject: [PATCH 33/53] Clean up SyncObjectAnim. --- Source/objects.cpp | 97 +++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 257c7bf70..e80dc8b29 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4666,60 +4666,51 @@ void SyncL3Doors(int i) 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; } } From ed3f57bb035a7bbb80c304515e548684474f2bff Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 00:28:20 +0300 Subject: [PATCH 34/53] Clean up OperateL1RDoor. --- Source/objects.cpp | 98 +++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 45 insertions(+), 55 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index e80dc8b29..5050c045b 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2350,67 +2350,57 @@ 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, pn; - 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); + 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(); + } else { + 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); + pn = object[oi]._oVar1; + object[oi]._oVar4 = 0; + object[oi]._oSelFlag = 3; + ObjSetMicro(xp, yp, pn); + if (object[oi]._oVar2 != 50) { + ObjSetMicro(xp - 1, yp, object[oi]._oVar2); } else { - ObjSetMicro(v5 - 1, v6, object[v3]._oVar2); + if (dPiece[xp - 1][yp] == 396) + ObjSetMicro(xp - 1, yp, 411); + else + ObjSetMicro(xp - 1, yp, 50); } - object[v3]._oAnimFrame -= 2; - object[v3]._oPreFlag = FALSE; + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); } 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; + object[oi]._oVar4 = 2; } - RedoPlayerVision(); - return; } - if (!deltaload) - PlaySfxLoc(IS_DOORCLOS, object[v3]._ox, object[v3]._oy); } // 676190: using guessed type int deltaload; diff --git a/Source/objects.h b/Source/objects.h index 55657ceae..910e2cae5 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -90,7 +90,7 @@ 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 OperateL1RDoor(int pnum, int oi, BOOL 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); From 0fdaed886c750d5af346d98ac89a40527eb57ee4 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 24 Apr 2019 03:41:48 -0500 Subject: [PATCH 35/53] DRLG_L4 function --- Source/drlg_l4.cpp | 269 +++++++++++++++++++-------------------------- 1 file changed, 114 insertions(+), 155 deletions(-) diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index 6a69341e3..ccfc3ce74 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -533,195 +533,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; From fe4f391673eaee901e5020b76a535d69f39fa204 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 21:52:15 +0300 Subject: [PATCH 36/53] Clean up OperateL1LDoor. --- Source/objects.cpp | 104 ++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 48 insertions(+), 58 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 5050c045b..5f6319ed6 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2404,70 +2404,60 @@ void OperateL1RDoor(int pnum, int oi, BOOL sendflag) } // 676190: using guessed type int deltaload; -void OperateL1LDoor(int pnum, int oi, unsigned char sendflag) +void OperateL1LDoor(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[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 (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); + 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, 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); - if (object[v3]._oVar1 == 214) - ObjSetMicro(v5, v6, 408); + if (dPiece[xp][yp - 1] == 396) + ObjSetMicro(xp, yp - 1, 412); 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, 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; diff --git a/Source/objects.h b/Source/objects.h index 910e2cae5..6faa3e1da 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -91,7 +91,7 @@ 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, BOOL sendflag); -void OperateL1LDoor(int pnum, int oi, unsigned char sendflag); +void OperateL1LDoor(int pnum, int oi, BOOL 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); From 4e137f975e9a406d3f1728c8a4c331e5c336e997 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 22:04:46 +0300 Subject: [PATCH 37/53] Clean up OperateL2RDoor. --- Source/objects.cpp | 73 +++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 5f6319ed6..95dab140a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2461,52 +2461,45 @@ void OperateL1LDoor(int pnum, int oi, BOOL sendflag) } // 676190: using guessed type int deltaload; -void OperateL2RDoor(int pnum, int oi, unsigned char sendflag) +void OperateL2RDoor(int pnum, int oi, BOOL 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] + int xp, yp; - 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; - } + 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; diff --git a/Source/objects.h b/Source/objects.h index 6faa3e1da..5040cfbd2 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -92,7 +92,7 @@ void DoorSet(int oi, int dx, int dy); void RedoPlayerVision(); void OperateL1RDoor(int pnum, int oi, BOOL sendflag); void OperateL1LDoor(int pnum, int oi, BOOL sendflag); -void OperateL2RDoor(int pnum, int oi, unsigned char sendflag); +void OperateL2RDoor(int pnum, int oi, BOOL 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); From d60740e5d9b0beaf652e2769aed8e725e862295e Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 22:09:28 +0300 Subject: [PATCH 38/53] Clean up OperateL2LDoor. --- Source/objects.cpp | 74 +++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 95dab140a..0077d49ea 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2503,52 +2503,46 @@ void OperateL2RDoor(int pnum, int oi, BOOL sendflag) } // 676190: using guessed type int deltaload; -void OperateL2LDoor(int pnum, int oi, unsigned char sendflag) +void OperateL2LDoor(int pnum, int oi, BOOL 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] + int xp, yp; - 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; - } + 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[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, 538); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } } // 676190: using guessed type int deltaload; diff --git a/Source/objects.h b/Source/objects.h index 5040cfbd2..1553d58ff 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -93,7 +93,7 @@ void RedoPlayerVision(); 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, unsigned char sendflag); +void OperateL2LDoor(int pnum, int oi, BOOL sendflag); void OperateL3RDoor(int pnum, int oi, unsigned char sendflag); void OperateL3LDoor(int pnum, int oi, unsigned char sendflag); void MonstCheckDoors(int m); From 48787364c5effb96abd008fc56a333e3fe8853c1 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 22:16:28 +0300 Subject: [PATCH 39/53] Clean up OperateL3RDoor. --- Source/objects.cpp | 74 +++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 0077d49ea..bedc050f6 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2546,52 +2546,46 @@ void OperateL2LDoor(int pnum, int oi, BOOL sendflag) } // 676190: using guessed type int deltaload; -void OperateL3RDoor(int pnum, int oi, unsigned char sendflag) +void OperateL3RDoor(int pnum, int oi, BOOL 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] + int xp, yp; - 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; - } 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 (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[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, 534); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } } // 676190: using guessed type int deltaload; diff --git a/Source/objects.h b/Source/objects.h index 1553d58ff..6e4722feb 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -94,7 +94,7 @@ 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, unsigned char sendflag); +void OperateL3RDoor(int pnum, int oi, BOOL sendflag); void OperateL3LDoor(int pnum, int oi, unsigned char sendflag); void MonstCheckDoors(int m); void ObjChangeMap(int x1, int y1, int x2, int y2); From b099d74e0662533bbe96e89c183981a6416cd52c Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 22:18:05 +0300 Subject: [PATCH 40/53] Clean up OperateL3LDoor. --- Source/objects.cpp | 74 +++++++++++++++++++++------------------------- Source/objects.h | 2 +- 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index bedc050f6..555971485 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2589,52 +2589,46 @@ void OperateL3RDoor(int pnum, int oi, BOOL sendflag) } // 676190: using guessed type int deltaload; -void OperateL3LDoor(int pnum, int oi, unsigned char sendflag) +void OperateL3LDoor(int pnum, int oi, BOOL 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] + int xp, yp; - 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; - } + 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[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, 531); + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; + } } // 676190: using guessed type int deltaload; diff --git a/Source/objects.h b/Source/objects.h index 6e4722feb..8931e0287 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -95,7 +95,7 @@ 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, unsigned char 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); From 82bbef8ab7de7a328d38bc6374ff3685e296a207 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Wed, 24 Apr 2019 22:29:00 +0300 Subject: [PATCH 41/53] Stylistic changes for OperateL1RDoor. --- Source/objects.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 555971485..5de7ff8e5 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -2352,7 +2352,7 @@ void RedoPlayerVision() void OperateL1RDoor(int pnum, int oi, BOOL sendflag) { - int xp, yp, pn; + int xp, yp; if (object[oi]._oVar4 == 2) { if (!deltaload) @@ -2376,30 +2376,30 @@ void OperateL1RDoor(int pnum, int oi, BOOL sendflag) object[oi]._oVar4 = 1; object[oi]._oSelFlag = 2; RedoPlayerVision(); - } else { - 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); - pn = object[oi]._oVar1; - object[oi]._oVar4 = 0; - object[oi]._oSelFlag = 3; - ObjSetMicro(xp, yp, pn); - if (object[oi]._oVar2 != 50) { - ObjSetMicro(xp - 1, yp, object[oi]._oVar2); - } else { - if (dPiece[xp - 1][yp] == 396) - ObjSetMicro(xp - 1, yp, 411); - else - ObjSetMicro(xp - 1, yp, 50); - } - object[oi]._oAnimFrame -= 2; - object[oi]._oPreFlag = FALSE; - RedoPlayerVision(); + return; + } + + 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 { - object[oi]._oVar4 = 2; + if (dPiece[xp - 1][yp] == 396) + ObjSetMicro(xp - 1, yp, 411); + else + ObjSetMicro(xp - 1, yp, 50); } + object[oi]._oAnimFrame -= 2; + object[oi]._oPreFlag = FALSE; + RedoPlayerVision(); + } else { + object[oi]._oVar4 = 2; } } // 676190: using guessed type int deltaload; From 1db78d96ef8be12919fc69e8ffcea9a3b8ad368d Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Wed, 24 Apr 2019 23:18:32 -0500 Subject: [PATCH 42/53] DRLG_L2 CreateDungeon --- Source/drlg_l2.cpp | 369 +++++++++++++++++++-------------------------- Source/drlg_l2.h | 2 +- 2 files changed, 159 insertions(+), 212 deletions(-) diff --git a/Source/drlg_l2.cpp b/Source/drlg_l2.cpp index 6ba5edf2b..083b1c218 100644 --- a/Source/drlg_l2.cpp +++ b/Source/drlg_l2.cpp @@ -234,22 +234,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() @@ -629,22 +621,18 @@ 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; @@ -1110,104 +1098,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) @@ -1410,121 +1395,83 @@ 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 *p; + HALLNODE *p1; - p = pHallList->pNext; + p1 = pHallList->pNext; *nX1 = pHallList->nHallx1; *nY1 = pHallList->nHally1; *nX2 = pHallList->nHallx2; *nY2 = pHallList->nHally2; *nHd = pHallList->nHalldir; - MemFreeDbg(pHallList); - - pHallList = p; + pHallList = p1; } void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd) 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); From 6374bb0cb64c14ede5f593530a876bb7bcb5e5f0 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Thu, 25 Apr 2019 16:38:06 +0900 Subject: [PATCH 43/53] L5makeDungeon bin exact (#1022) Fixes #232. --- Source/drlg_l1.cpp | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/Source/drlg_l1.cpp b/Source/drlg_l1.cpp index 3a085c727..d6fa3afe7 100644 --- a/Source/drlg_l1.cpp +++ b/Source/drlg_l1.cpp @@ -1025,29 +1025,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() From f303e86da10646b30b11c239dd1994e4abea0a1d Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Thu, 25 Apr 2019 02:38:25 -0500 Subject: [PATCH 44/53] L4makeDungeon (#1023) --- Source/drlg_l4.cpp | 140 ++++++++++++++------------------------------- 1 file changed, 42 insertions(+), 98 deletions(-) diff --git a/Source/drlg_l4.cpp b/Source/drlg_l4.cpp index ccfc3ce74..8a8c2b123 100644 --- a/Source/drlg_l4.cpp +++ b/Source/drlg_l4.cpp @@ -1435,104 +1435,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() From 792fc65bea78d1479d6a094af1c6f88754126625 Mon Sep 17 00:00:00 2001 From: galaxyhaxz Date: Thu, 25 Apr 2019 02:39:24 -0500 Subject: [PATCH 45/53] Add support for 32-bit colors (#1018) --- Source/dx.cpp | 8 ++++---- Source/palette.cpp | 2 ++ Source/scrollrt.cpp | 14 +++++++++++--- defs.h | 14 ++++++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Source/dx.cpp b/Source/dx.cpp index fea1fdff3..1c223091d 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -76,17 +76,17 @@ void dx_init(HWND hWnd) ErrDlg(IDD_DIALOG1, hDDVal, "C:\\Src\\Diablo\\Source\\dx.cpp", 170); } #ifdef __cplusplus - hDDVal = lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, 8); + hDDVal = lpDDInterface->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); #else - hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, 8); + hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP); #endif if(hDDVal != DD_OK) { winw = GetSystemMetrics(SM_CXSCREEN); winh = GetSystemMetrics(SM_CYSCREEN); #ifdef __cplusplus - hDDVal = lpDDInterface->SetDisplayMode(winw, winh, 8); + hDDVal = lpDDInterface->SetDisplayMode(winw, winh, SCREEN_BPP); #else - hDDVal = lpDDInterface->lpVtbl->SetDisplayMode(lpDDInterface, winw, winh, 8); + 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); diff --git a/Source/palette.cpp b/Source/palette.cpp index a3a198fc1..663fd19f3 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -37,8 +37,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/scrollrt.cpp b/Source/scrollrt.cpp index 175a53993..c8218c072 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -2633,16 +2633,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); -#ifdef USE_ASM +#if defined(USE_ASM) && !defined(RGBMODE) __asm { mov esi, gpBuffer mov edi, DDS_desc.lpSurface @@ -2668,7 +2668,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/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)) From 0c71dd35fc1c6a4e83bb592cfbe4de5f3b777161 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Thu, 25 Apr 2019 08:18:55 +0300 Subject: [PATCH 46/53] Add 6 functions duplicating some existing ones. Necessary to get AddObject bin exact. Order and names provided by @galaxyhaxz. --- Source/objects.cpp | 39 ++++++++++++++++++++++++++++++++++++++- Source/objects.h | 6 ++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 5de7ff8e5..2739b2b4b 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1505,6 +1505,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; @@ -1527,6 +1537,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(); @@ -1551,7 +1588,7 @@ void AddMagicCircle(int i) object[i]._oVar6 = 0; } -void AddBookstand(int i) +void AddBrnCross(int i) { object[i]._oRndSeed = GetRndSeed(); } diff --git a/Source/objects.h b/Source/objects.h index 8931e0287..1939a441b 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -61,10 +61,16 @@ 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); From bef1e7d616429b4d108371b6e1133560902c085f Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Thu, 25 Apr 2019 08:22:47 +0300 Subject: [PATCH 47/53] Clean up AddObject. Also adds unused arguments to AddBarrel and AddTrap. --- Source/objects.cpp | 279 ++++++++++++++++++++++----------------------- Source/objects.h | 4 +- 2 files changed, 137 insertions(+), 146 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 2739b2b4b..e1037497f 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1427,7 +1427,7 @@ void AddFlameLvr(int i) } // 679768: using guessed type int trapid; -void AddTrap(int i) +void AddTrap(int i, int t) { int mt; @@ -1451,7 +1451,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(); @@ -1689,150 +1689,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) diff --git a/Source/objects.h b/Source/objects.h index 1939a441b..4ca48534c 100644 --- a/Source/objects.h +++ b/Source/objects.h @@ -54,9 +54,9 @@ 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); From dd6a237390fa14a9b983d43560b00dc99eb46afd Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 25 Apr 2019 15:10:46 +0200 Subject: [PATCH 48/53] Clean up AddTrap --- Source/objects.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index e1037497f..018cdd327 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -1431,7 +1431,8 @@ 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) From 2e75119773c6787fab4c2ca2fda3613dae5b4f48 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 25 Apr 2019 14:40:08 +0200 Subject: [PATCH 49/53] Clean up PrintStoreItem --- Source/stores.cpp | 86 +++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index f45ed3bfa..995ab46f1 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -502,78 +502,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); } } From 97ce7b0aa5fecc500dfba9a344cde8d767a5233e Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 25 Apr 2019 18:06:38 +0200 Subject: [PATCH 50/53] Clean S_StartSRepair --- Source/stores.cpp | 210 ++++++++++++++++------------------------------ Source/stores.h | 2 +- 2 files changed, 74 insertions(+), 138 deletions(-) diff --git a/Source/stores.cpp b/Source/stores.cpp index f45ed3bfa..dbf9851b1 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -16,7 +16,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; @@ -83,7 +83,7 @@ void InitStores() stextflag = STORE_NONE; InStoreFlag = 1; stextsize = 0; - stextscrl = 0; + stextscrl = FALSE; numpremium = 0; premiumlevel = 1; @@ -444,7 +444,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); @@ -459,7 +459,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) { @@ -582,7 +581,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); @@ -601,7 +600,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) { @@ -671,7 +669,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); @@ -693,7 +691,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) @@ -781,7 +778,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); @@ -789,7 +786,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); @@ -804,7 +801,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) { @@ -824,96 +820,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) { @@ -942,7 +900,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); @@ -955,7 +913,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) { @@ -1003,7 +960,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); @@ -1030,7 +987,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) { @@ -1100,7 +1056,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); @@ -1108,7 +1064,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); @@ -1123,7 +1079,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) { @@ -1176,7 +1131,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); @@ -1184,7 +1139,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); @@ -1200,22 +1155,20 @@ 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() { @@ -1223,7 +1176,7 @@ void S_StartConfirm() char iclr; StartStore(stextshold); - stextscrl = 0; + stextscrl = FALSE; ClearSText(5, 23); iclr = COL_WHITE; @@ -1286,7 +1239,7 @@ void S_StartConfirm() 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) { @@ -1302,14 +1255,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); @@ -1331,12 +1283,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); @@ -1349,7 +1300,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) { @@ -1386,7 +1336,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); @@ -1412,12 +1362,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); @@ -1426,7 +1375,6 @@ void S_StartStory() AddSLine(5); } // 6A09E0: using guessed type char stextsize; -// 6A6BB8: using guessed type int stextscrl; BOOL IdItemOk(ItemStruct *i) { @@ -1499,7 +1447,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); @@ -1507,7 +1455,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); @@ -1522,14 +1470,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; @@ -1543,7 +1490,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() { @@ -1559,7 +1505,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); @@ -1599,12 +1545,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); @@ -1615,12 +1560,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); @@ -1630,12 +1574,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); @@ -1645,7 +1588,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) { @@ -1805,7 +1747,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() @@ -1934,7 +1875,6 @@ void STextUp() } } // 69F108: using guessed type int stextup; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; void STextDown() @@ -1980,7 +1920,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; @@ -2000,7 +1939,6 @@ void STextPrior() } } // 69F108: using guessed type int stextup; -// 6A6BB8: using guessed type int stextscrl; // 6A8A28: using guessed type int stextsel; void STextNext() @@ -2018,7 +1956,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; @@ -3230,7 +3167,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; From a36c6276cecc02146a8ba0599edc2b18b2e1e31e Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 25 Apr 2019 20:25:15 +0200 Subject: [PATCH 51/53] BreakObject bin exact (#1027) --- Source/objects.cpp | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Source/objects.cpp b/Source/objects.cpp index 018cdd327..3728f5c3a 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -4470,31 +4470,26 @@ void BreakBarrel(int pnum, int i, int dam, BOOL forcebreak, int sendmsg) 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; } } From 0757eb4774869ebdc4effb041b46b9a339366fa4 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Fri, 26 Apr 2019 03:35:32 +0900 Subject: [PATCH 52/53] GetAutomapType bin exact Fixes #224. --- Source/automap.cpp | 47 +++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/Source/automap.cpp b/Source/automap.cpp index a3298c53f..ed9829473 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -506,28 +506,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() From f6e66e15af4c628ce0273386ddc30c7d3a394424 Mon Sep 17 00:00:00 2001 From: qndel Date: Thu, 25 Apr 2019 20:48:58 +0200 Subject: [PATCH 53/53] CalcItemValue bin exact --- Source/items.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/items.cpp b/Source/items.cpp index c0496e1aa..f0ad2b1a1 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1565,24 +1565,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)