Browse Source

Merge branch 'master' of github.com:diasurgical/devilution into hellfire

pull/876/head
Anders Jenbo 6 years ago
parent
commit
630655d9e4
  1. 16
      Source/automap.cpp
  2. 42
      Source/codec.cpp
  3. 21
      Source/control.cpp
  4. 10
      Source/cursor.cpp
  5. 123
      Source/diablo.cpp
  6. 8
      Source/diablo.h
  7. 2
      Source/doom.cpp
  8. 6
      Source/dthread.cpp
  9. 12
      Source/dx.cpp
  10. 2074
      Source/effects.cpp
  11. 32
      Source/encrypt.cpp
  12. 10
      Source/encrypt.h
  13. 174
      Source/engine.cpp
  14. 2
      Source/engine.h
  15. 2
      Source/error.cpp
  16. 68
      Source/gamemenu.cpp
  17. 26
      Source/gendung.cpp
  18. 12
      Source/gendung.h
  19. 16
      Source/gmenu.cpp
  20. 4
      Source/gmenu.h
  21. 8
      Source/items.cpp
  22. 467
      Source/monstdat.cpp
  23. 3
      Source/monstdat.h
  24. 14
      Source/mpqapi.cpp
  25. 2
      Source/mpqapi.h
  26. 22
      enums.h

16
Source/automap.cpp

@ -114,7 +114,7 @@ void InitAutomap()
return;
}
dwTiles >>= 1;
dwTiles /= 2;
pTmp = pAFile;
for (i = 1; i <= dwTiles; i++) {
@ -252,7 +252,7 @@ void DrawAutomap()
for (j = 0; j < cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype)
if (maptype != 0)
DrawAutomapTile(x, sy, maptype);
x += AmLine64;
}
@ -261,7 +261,7 @@ void DrawAutomap()
y = sy + AmLine16;
for (j = 0; j <= cells; j++) {
WORD maptype = GetAutomapType(mapx + j, mapy - j, TRUE);
if (maptype)
if (maptype != 0)
DrawAutomapTile(x, y, maptype);
x += AmLine64;
}
@ -388,7 +388,7 @@ void DrawAutomapTile(int sx, int sy, WORD automap_type)
DrawLine(sx, sy, x1, y2, COLOR_DIM);
DrawLine(sx, sy, x2, y2, COLOR_DIM);
}
if (!(flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH)))
if ((flags & (MAPFLAG_VERTDOOR | MAPFLAG_VERTGRATE | MAPFLAG_VERTARCH)) == 0)
DrawLine(sx, sy - AmLine16, sx - AmLine32, sy, COLOR_DIM);
}
@ -421,7 +421,7 @@ void DrawAutomapTile(int sx, int sy, WORD automap_type)
DrawLine(sx, sy, x1, y2, COLOR_DIM);
DrawLine(sx, sy, x2, y2, COLOR_DIM);
}
if (!(flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH)))
if ((flags & (MAPFLAG_HORZDOOR | MAPFLAG_HORZGRATE | MAPFLAG_HORZARCH)) == 0)
DrawLine(sx, sy - AmLine16, sx + AmLine32, sy, COLOR_DIM);
}
@ -531,7 +531,7 @@ void DrawAutomapItem(int x, int y, BYTE color)
x1 = x - AmLine32 / 2;
y1 = y - AmLine16 / 2;
x2 = AmLine64 / 2 + x1;
x2 = x1 + AmLine64 / 2;
y2 = y1 + AmLine32 / 2;
DrawLine(x, y1, x1, y, color);
DrawLine(x, y1, x2, y, color);
@ -673,9 +673,9 @@ void DrawAutomapText()
nextline = 50;
}
}
if (setlevel)
if (setlevel) {
PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD);
else if (currlevel) {
} else if (currlevel) {
#ifdef HELLFIRE
if (currlevel < 17 || currlevel > 20) {
if (currlevel < 21 || currlevel > 24)

42
Source/codec.cpp

@ -12,6 +12,8 @@ typedef struct CodecSignature {
WORD unused;
} CodecSignature;
#define BLOCKSIZE 64
int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword)
{
char buf[128];
@ -20,20 +22,20 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword)
CodecSignature *sig;
codec_init_key(0, pszPassword);
if (size <= 8)
if (size <= sizeof(CodecSignature))
return 0;
size = size - 8;
if (size % 64 != 0)
size -= sizeof(CodecSignature);
if (size % BLOCKSIZE != 0)
return 0;
for (i = size; i != 0; pbSrcDst += 64, i -= 64) {
memcpy(buf, pbSrcDst, 64);
for (i = size; i != 0; pbSrcDst += BLOCKSIZE, i -= BLOCKSIZE) {
memcpy(buf, pbSrcDst, BLOCKSIZE);
SHA1Result(0, dst);
for (int j = 0; j < 64; j++) {
for (int j = 0; j < BLOCKSIZE; j++) {
buf[j] ^= dst[j % SHA1HashSize];
}
SHA1Calculate(0, buf, NULL);
memset(dst, 0, sizeof(dst));
memcpy(pbSrcDst, buf, 64);
memcpy(pbSrcDst, buf, BLOCKSIZE);
}
memset(buf, 0, sizeof(buf));
@ -48,7 +50,7 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword)
goto error;
}
size += sig->last_chunk_size - 64;
size += sig->last_chunk_size - BLOCKSIZE;
SHA1Clear();
return size;
error:
@ -67,7 +69,7 @@ void codec_init_key(int unused, char *pszPassword)
srand(0x7058);
keyInit = key;
for (i = 0; i < 136; i++) {
for (i = 0; i < sizeof(key); i++) {
*keyInit = rand();
keyInit++;
}
@ -81,7 +83,7 @@ void codec_init_key(int unused, char *pszPassword)
SHA1Reset(0);
SHA1Calculate(0, pw, digest);
SHA1Clear();
for (i = 0; (DWORD)i < 136; i++)
for (i = 0; i < sizeof(key); i++)
key[i] ^= digest[i % SHA1HashSize];
memset(pw, 0, sizeof(pw));
memset(digest, 0, sizeof(digest));
@ -94,9 +96,9 @@ void codec_init_key(int unused, char *pszPassword)
DWORD codec_get_encoded_len(DWORD dwSrcBytes)
{
if (dwSrcBytes % 64 != 0)
dwSrcBytes += 64 - (dwSrcBytes % 64);
return dwSrcBytes + 8;
if (dwSrcBytes % BLOCKSIZE != 0)
dwSrcBytes += BLOCKSIZE - (dwSrcBytes % BLOCKSIZE);
return dwSrcBytes + sizeof(CodecSignature);
}
void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, char *pszPassword)
@ -114,19 +116,19 @@ void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, char *pszPassword)
last_chunk = 0;
while (size != 0) {
chunk = size < 64 ? size : 64;
chunk = size < BLOCKSIZE ? size : BLOCKSIZE;
memcpy(buf, pbSrcDst, chunk);
if (chunk < 64)
memset(buf + chunk, 0, 64 - chunk);
if (chunk < BLOCKSIZE)
memset(buf + chunk, 0, BLOCKSIZE - chunk);
SHA1Result(0, dst);
SHA1Calculate(0, buf, NULL);
for (int j = 0; j < 64; j++) {
for (int j = 0; j < BLOCKSIZE; j++) {
buf[j] ^= dst[j % SHA1HashSize];
}
memset(dst, 0, sizeof(dst));
memcpy(pbSrcDst, buf, 64);
memcpy(pbSrcDst, buf, BLOCKSIZE);
last_chunk = chunk;
pbSrcDst += 64;
pbSrcDst += BLOCKSIZE;
size -= chunk;
}
memset(buf, 0, sizeof(buf));
@ -134,7 +136,7 @@ void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, char *pszPassword)
sig = (CodecSignature *)pbSrcDst;
sig->error = 0;
sig->unused = 0;
sig->checksum = *(DWORD *)tmp;
sig->checksum = *(DWORD *)&tmp[0];
sig->last_chunk_size = last_chunk;
SHA1Clear();
}

21
Source/control.cpp

@ -1335,7 +1335,7 @@ void InitControlPan()
pMultiBtns = LoadFileInMem("CtrlPan\\P8But2.CEL", NULL);
pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", NULL);
sgbPlrTalkTbl = 0;
sgszTalkMsg[0] = 0;
sgszTalkMsg[0] = '\0';
for (i = 0; i < MAX_PLRS; i++)
whisper[i] = TRUE;
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++)
@ -1847,7 +1847,7 @@ void CPrintString(int y, char *str, BOOL center, int lines)
lineOffset = 0;
lineStart = lineOffsets[lines][y] + PANEL_LEFT;
if (center == 1) {
if (center == TRUE) {
strWidth = 0;
tmp = str;
while (*tmp) {
@ -2179,7 +2179,7 @@ void DrawLevelUpIcon()
{
int nCel;
if (!stextflag) {
if (stextflag == STORE_NONE) {
nCel = lvlbtndown ? 3 : 2;
ADD_PlrStringXY(PANEL_LEFT + 0, PANEL_TOP - 49, PANEL_LEFT + 120, "Level Up", COL_WHITE);
CelDraw(40 + PANEL_X, -17 + PANEL_Y, pChrButtons, nCel, 41);
@ -2572,7 +2572,7 @@ void DrawGoldSplit(int amount)
ADD_PlrStringXY(366, 121, 600, "you want to remove?", COL_GOLD);
if (amount > 0) {
sprintf(tempstr, "%u", amount);
PrintGameStr(388, 140, tempstr, 0);
PrintGameStr(388, 140, tempstr, COL_WHITE);
for (i = 0; i < tempstr[i]; i++) {
screen_x += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
}
@ -2607,7 +2607,7 @@ void control_drop_gold(char vkey)
input[strlen(input) - 1] = '\0';
dropGoldValue = atoi(input);
} else if (vkey - '0' >= 0 && vkey - '0' <= 9) {
if (dropGoldValue || atoi(input) <= initialDropGoldValue) {
if (dropGoldValue != 0 || atoi(input) <= initialDropGoldValue) {
input[strlen(input)] = vkey;
if (atoi(input) > initialDropGoldValue)
return;
@ -2690,7 +2690,7 @@ void DrawTalkPan()
CelBlitFrame(gpBuffer + x, pSPentSpn2Cels, frame, 12);
frame = (frame & 7) + 1;
talk_btn = 0;
for (i = 0; i < 4; i++) {
for (i = 0; i < MAX_PLRS; i++) {
if (i == myplr)
continue;
if (whisper[i]) {
@ -2726,8 +2726,9 @@ char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color)
int width;
x += 264;
y += 182 + PANEL_TOP;
width = x;
*nOffset = PitchTbl[y + 182 + PANEL_TOP] + x;
*nOffset = PitchTbl[y] + x;
while (*msg) {
c = fontframe[gbFontTransTbl[(BYTE)*msg]];
@ -2735,7 +2736,7 @@ char *control_print_talk_msg(char *msg, int x, int y, int *nOffset, int color)
if (width > 514 + PANEL_LEFT)
return msg;
msg++;
if (c) {
if (c != 0) {
PrintChar(*nOffset, c, color);
}
*nOffset += fontkern[c] + 1;
@ -2813,7 +2814,7 @@ void control_type_message()
}
talkflag = TRUE;
sgszTalkMsg[0] = 0;
sgszTalkMsg[0] = '\0';
frame = 1;
for (i = 0; i < 3; i++) {
talkbtndown[i] = FALSE;
@ -2889,7 +2890,7 @@ void control_press_enter()
int i;
BYTE talk_save;
if (sgszTalkMsg[0]) {
if (sgszTalkMsg[0] != 0) {
#ifdef HELLFIRE
int pmask;
pmask = 0;

10
Source/cursor.cpp

@ -94,7 +94,7 @@ const int InvItemHeight[] = {
void InitCursor()
{
/// ASSERT: assert(! pCursCels);
assert(! pCursCels);
pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", NULL);
#ifdef HELLFIRE
pCursCels2 = LoadFileInMem("Data\\Inv\\Objcurs2.CEL", NULL);
@ -210,14 +210,14 @@ void CheckCursMove()
sy = MouseY;
if (chrflag || questlog) {
if (sx >= 160) {
sx -= 160;
if (sx >= SCREEN_WIDTH / 4) {
sx -= SCREEN_WIDTH / 4;
} else {
sx = 0;
}
} else if (invflag || sbookflag) {
if (sx <= 320) {
sx += 160;
if (sx <= SCREEN_WIDTH / 2) {
sx += SCREEN_WIDTH / 4;
} else {
sx = 0;
}

123
Source/diablo.cpp

@ -8,19 +8,19 @@
#include "../DiabloUI/diabloui.h"
HWND ghMainWnd;
int glMid1Seed[NUMLEVELS];
int glMid2Seed[NUMLEVELS];
int glMid1Seed[NUMLEVELS + 1];
int glMid2Seed[NUMLEVELS + 1];
int gnLevelTypeTbl[NUMLEVELS];
int MouseX;
int MouseY;
BOOL gbGameLoopStartup;
DWORD glSeedTbl[NUMLEVELS];
BOOL gbRunGame;
int glMid3Seed[NUMLEVELS];
int glMid3Seed[NUMLEVELS + 1];
BOOL gbRunGameResult;
BOOL zoomflag;
BOOL gbProcessPlayers;
int glEndSeed[NUMLEVELS];
int glEndSeed[NUMLEVELS + 1];
BOOL gbLoadGame;
HINSTANCE ghInst;
int DebugMonsters[10];
@ -334,7 +334,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
if (lpCmdLine[0] == '\0') {
content[0] = '\0';
if (file = fopen("command.txt", "r")) {
fgets(content, 255, file);
fgets(content, sizeof(content) / sizeof(char), file);
lpCmdLine = content;
fclose(file);
}
@ -400,19 +400,22 @@ void diablo_parse_flags(char *args)
while (isspace(*args)) {
args++;
}
if (_strnicmp("dd_emulate", args, strlen("dd_emulate")) == 0) {
gbEmulate = 1;
args += strlen("dd_emulate");
static char de[] = "dd_emulate";
if (_strnicmp(de, args, strlen(de)) == 0) {
gbEmulate = TRUE;
args += strlen(de);
continue;
}
if (_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) {
gbBackBuf = 1;
args += strlen("dd_backbuf");
static char db[] = "dd_backbuf";
if (_strnicmp(db, args, strlen(db)) == 0) {
gbBackBuf = TRUE;
args += strlen(db);
continue;
}
if (_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) {
static char ds[] = "ds_noduplicates";
if (_strnicmp(ds, args, strlen(ds)) == 0) {
gbDupSounds = FALSE;
args += strlen("ds_noduplicates");
args += strlen(ds);
continue;
}
#ifdef HELLFIRE
@ -458,25 +461,25 @@ void diablo_parse_flags(char *args)
#ifdef _DEBUG
switch (c) {
case '^':
debug_mode_key_inverted_v = 1;
debug_mode_key_inverted_v = TRUE;
break;
case '$':
debug_mode_dollar_sign = 1;
debug_mode_dollar_sign = TRUE;
break;
case 'b':
/*
debug_mode_key_b = 1;
debug_mode_key_b = TRUE;
*/
break;
case 'd':
showintrodebug = 0;
debug_mode_key_d = 1;
showintrodebug = FALSE;
debug_mode_key_d = TRUE;
break;
case 'f':
EnableFrameCount();
break;
case 'i':
debug_mode_key_i = 1;
debug_mode_key_i = TRUE;
break;
case 'j':
/*
@ -527,7 +530,7 @@ void diablo_parse_flags(char *args)
DebugMonsters[debugmonsttypes++] = i;
break;
case 'n':
showintrodebug = 0;
showintrodebug = FALSE;
break;
case 'q':
while (isspace(*args)) {
@ -552,7 +555,7 @@ void diablo_parse_flags(char *args)
setseed = i;
break;
case 's':
debug_mode_key_s = 1;
debug_mode_key_s = TRUE;
break;
case 't':
leveldebug = TRUE;
@ -571,7 +574,7 @@ void diablo_parse_flags(char *args)
visiondebug = TRUE;
break;
case 'w':
debug_mode_key_w = 1;
debug_mode_key_w = TRUE;
break;
case 'x':
fullscreen = FALSE;
@ -603,11 +606,11 @@ void diablo_init_screen()
LONG __stdcall diablo_TopLevelExceptionFilter(PEXCEPTION_POINTERS pExc)
{
dx_cleanup();
init_cleanup(0);
init_cleanup(FALSE);
if (lpTopLevelExceptionFilter)
return lpTopLevelExceptionFilter(pExc);
return 0;
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
@ -615,12 +618,12 @@ BOOL diablo_find_window(LPCSTR lpClassName)
{
HWND hWnd, active;
hWnd = FindWindow(lpClassName, 0);
if (!hWnd)
hWnd = FindWindow(lpClassName, NULL);
if (hWnd == NULL)
return FALSE;
active = GetLastActivePopup(hWnd);
if (active)
if (active != NULL)
hWnd = active;
active = GetTopWindow(hWnd);
@ -688,7 +691,7 @@ void diablo_reload_process(HINSTANCE hInstance)
ExitProcess(0);
}
if (InterlockedIncrement(plMap) == 0) {
if (InterlockedIncrement(&plMap[0]) == 0) {
plMap[1] = GetCurrentProcessId();
} else {
hPrev = GetForegroundWindow();
@ -905,7 +908,7 @@ LRESULT CALLBACK GM_Game(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
BOOL LeftMouseDown(int wParam)
{
if (!gmenu_left_mouse(TRUE) && !control_check_talk_btn() && !sgnTimeoutCurs) {
if (!gmenu_left_mouse(TRUE) && !control_check_talk_btn() && sgnTimeoutCurs == CURSOR_NONE) {
if (deathflag) {
control_check_btn_press();
} else if (PauseMode != 2) {
@ -913,7 +916,7 @@ BOOL LeftMouseDown(int wParam)
doom_close();
} else if (spselflag) {
SetSpell();
} else if (stextflag) {
} else if (stextflag != STORE_NONE) {
CheckStoreBtn();
} else if (MouseY < PANEL_TOP) {
if (!gmenu_is_active() && !TryIconCurs()) {
@ -932,10 +935,10 @@ BOOL LeftMouseDown(int wParam)
} else if (pcurs >= CURSOR_FIRSTITEM) {
if (TryInvPut()) {
NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy);
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
} else {
if (plr[myplr]._pStatPts && !spselflag)
if (plr[myplr]._pStatPts != 0 && !spselflag)
CheckLvlBtn();
if (!lvlbtndown)
return LeftMouseCmd(wParam == MK_SHIFT + MK_LBUTTON);
@ -946,7 +949,7 @@ BOOL LeftMouseDown(int wParam)
CheckInvScrn();
DoPanBtn();
if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM)
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
}
}
@ -958,7 +961,7 @@ BOOL LeftMouseCmd(BOOL bShift)
{
BOOL bNear;
/// ASSERT: assert(MouseY < 352); // PANEL_TOP
assert(MouseY < PANEL_TOP); // 352
if (leveltype == DTYPE_TOWN) {
if (pcursitem != -1 && pcurs == CURSOR_HAND)
@ -1024,21 +1027,21 @@ BOOL TryIconCurs()
if (pcursinvitem != -1) {
CheckIdentify(myplr, pcursinvitem);
} else {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
return TRUE;
} else if (pcurs == CURSOR_REPAIR) {
if (pcursinvitem != -1) {
DoRepair(myplr, pcursinvitem);
} else {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
return TRUE;
} else if (pcurs == CURSOR_RECHARGE) {
if (pcursinvitem != -1) {
DoRecharge(myplr, pcursinvitem);
} else {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
return TRUE;
#ifdef HELLFIRE
@ -1058,10 +1061,10 @@ BOOL TryIconCurs()
} else {
NetSendCmdLocParam2(TRUE, CMD_TSPELLXY, cursmx, cursmy, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell));
}
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return TRUE;
} else if (pcurs == CURSOR_DISARM && pcursobj == -1) {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return TRUE;
}
@ -1078,7 +1081,7 @@ void LeftMouseUp()
ReleaseChrBtns();
if (lvlbtndown)
ReleaseLvlBtn();
if (stextflag)
if (stextflag != STORE_NONE)
ReleaseStoreBtn();
}
@ -1087,7 +1090,7 @@ void RightMouseDown()
if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE && PauseMode != 2 && !plr[myplr]._pInvincible) {
if (doomflag) {
doom_close();
} else if (!stextflag) {
} else if (stextflag == STORE_NONE) {
if (spselflag) {
SetSpell();
} else if (MouseY >= SPANEL_HEIGHT
@ -1098,7 +1101,7 @@ void RightMouseDown()
if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem))
CheckPlrSpell();
} else if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
}
}
@ -1132,7 +1135,7 @@ void diablo_hotkey_msg(DWORD dwMsg)
}
strcat(szFileName, "\\Diablo.ini");
/// ASSERT: assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
GetPrivateProfileString("NetMsg", spszMsgHotKeyTbl[dwMsg], spszMsgTbl[dwMsg], szMsg, sizeof(szMsg), szFileName);
NetSendCmdString(-1, szMsg);
}
@ -1150,7 +1153,7 @@ void PressKey(int vkey)
}
if (deathflag) {
if (sgnTimeoutCurs != 0) {
if (sgnTimeoutCurs != CURSOR_NONE) {
return;
}
if (vkey == VK_F9) {
@ -1180,7 +1183,7 @@ void PressKey(int vkey)
return;
}
if (sgnTimeoutCurs != 0 || dropGoldFlag) {
if (sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag) {
return;
}
if (vkey == VK_PAUSE) {
@ -1202,7 +1205,7 @@ void PressKey(int vkey)
} else if (vkey == VK_F1) {
if (helpflag) {
helpflag = FALSE;
} else if (stextflag) {
} else if (stextflag != STORE_NONE) {
ClearPanel();
AddPanelString("No help available", TRUE); /// BUGFIX: message isn't displayed
AddPanelString("while in stores", TRUE);
@ -1365,7 +1368,7 @@ void diablo_pause_game()
*/
void PressChar(int vkey)
{
if (gmenu_is_active() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) {
if (gmenu_is_active() || control_talk_last_key(vkey) || sgnTimeoutCurs != CURSOR_NONE || deathflag) {
return;
}
if ((char)vkey == 'p' || (char)vkey == 'P') {
@ -1395,7 +1398,7 @@ void PressChar(int vkey)
return;
case 'I':
case 'i':
if (!stextflag) {
if (stextflag == STORE_NONE) {
sbookflag = FALSE;
invflag = !invflag;
if (!invflag || chrflag) {
@ -1411,7 +1414,7 @@ void PressChar(int vkey)
return;
case 'C':
case 'c':
if (!stextflag) {
if (stextflag == STORE_NONE) {
questlog = FALSE;
chrflag = !chrflag;
if (!chrflag || invflag) {
@ -1427,7 +1430,7 @@ void PressChar(int vkey)
return;
case 'Q':
case 'q':
if (!stextflag) {
if (stextflag == STORE_NONE) {
chrflag = FALSE;
if (!questlog) {
StartQuestlog();
@ -1442,7 +1445,7 @@ void PressChar(int vkey)
return;
case 'S':
case 's':
if (!stextflag) {
if (stextflag == STORE_NONE) {
invflag = FALSE;
if (!spselflag) {
DoSpeedBook();
@ -1454,7 +1457,7 @@ void PressChar(int vkey)
return;
case 'B':
case 'b':
if (!stextflag) {
if (stextflag == STORE_NONE) {
invflag = FALSE;
sbookflag = !sbookflag;
}
@ -1640,7 +1643,7 @@ void PressChar(int vkey)
void LoadLvlGFX()
{
/// ASSERT: assert(! pDungeonCels);
assert(! pDungeonCels);
switch (leveltype) {
case DTYPE_TOWN:
@ -1710,7 +1713,7 @@ void LoadLvlGFX()
void LoadAllGFX()
{
/// ASSERT: assert(! pSpeedCels);
assert(! pSpeedCels);
pSpeedCels = DiabloAllocPtr(0x100000);
IncProgress();
IncProgress();
@ -1921,7 +1924,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir)
ResyncMPQuests();
#ifndef SPAWN
} else {
/// ASSERT: assert(! pSpeedCels);
assert(! pSpeedCels);
pSpeedCels = DiabloAllocPtr(0x100000);
LoadSetMap();
IncProgress();
@ -1996,7 +1999,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir)
{
items_427ABA(RowOfCornerStone, ColOfCornerStone);
}
if ( quests[Q_NAKRUL]._qactive == 3 && currlevel == 24 ) // TODO: fix quest struct
if ( quests[Q_NAKRUL]._qactive == QUEST_DONE && currlevel == 24 ) // TODO: fix quest struct
{
objects_454BA8();
}
@ -2053,7 +2056,7 @@ void game_logic()
return;
}
if (!gmenu_is_active() && sgnTimeoutCurs == 0) {
if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE) {
CheckCursMove();
track_process();
}
@ -2096,13 +2099,13 @@ void timeout_cursor(BOOL bTimeout)
ClearPanel();
AddPanelString("-- Network timeout --", TRUE);
AddPanelString("-- Waiting for players --", TRUE);
SetCursor_(CURSOR_HOURGLASS);
NewCursor(CURSOR_HOURGLASS);
force_redraw = 255;
}
scrollrt_draw_game_screen(TRUE);
} else if (sgnTimeoutCurs) {
} else if (sgnTimeoutCurs != CURSOR_NONE) {
SetCursor_(sgnTimeoutCurs);
sgnTimeoutCurs = 0;
sgnTimeoutCurs = CURSOR_NONE;
ClearPanel();
force_redraw = 255;
}

8
Source/diablo.h

@ -7,19 +7,19 @@
#define __DIABLO_H__
extern HWND ghMainWnd;
extern int glMid1Seed[NUMLEVELS];
extern int glMid2Seed[NUMLEVELS];
extern int glMid1Seed[NUMLEVELS + 1];
extern int glMid2Seed[NUMLEVELS + 1];
extern int gnLevelTypeTbl[NUMLEVELS];
extern int MouseX;
extern int MouseY;
extern BOOL gbGameLoopStartup;
extern DWORD glSeedTbl[NUMLEVELS];
extern BOOL gbRunGame;
extern int glMid3Seed[NUMLEVELS];
extern int glMid3Seed[NUMLEVELS + 1];
extern BOOL gbRunGameResult;
extern BOOL zoomflag;
extern BOOL gbProcessPlayers;
extern int glEndSeed[NUMLEVELS];
extern int glEndSeed[NUMLEVELS + 1];
extern BOOL gbLoadGame;
extern HINSTANCE ghInst;
extern int DebugMonsters[10];

2
Source/doom.cpp

@ -58,7 +58,7 @@ void doom_alloc_cel()
void doom_cleanup()
{
#ifdef HELLFIRE
if (pDoomCel) {
if (pDoomCel != NULL) {
MemFreeDbg(pDoomCel);
pDoomCel = NULL;
}

6
Source/dthread.cpp

@ -62,7 +62,7 @@ void dthread_start()
}
sghWorkToDoEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (!sghWorkToDoEvent) {
if (sghWorkToDoEvent == NULL) {
error_buf = TraceLastError();
app_fatal("dthread:1\n%s", error_buf);
}
@ -83,7 +83,7 @@ unsigned int __stdcall dthread_handler(void *data)
DWORD dwMilliseconds;
while (dthread_running) {
if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, INFINITE) == -1) {
if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, INFINITE) == WAIT_FAILED) {
error_buf = TraceLastError();
app_fatal("dthread4:\n%s", error_buf);
}
@ -126,7 +126,7 @@ void dthread_cleanup()
dthread_running = FALSE;
SetEvent(sghWorkToDoEvent);
if (sghThread != INVALID_HANDLE_VALUE && glpDThreadId != GetCurrentThreadId()) {
if (WaitForSingleObject(sghThread, INFINITE) == -1) {
if (WaitForSingleObject(sghThread, INFINITE) == WAIT_FAILED) {
error_buf = TraceLastError();
app_fatal("dthread3:\n(%s)", error_buf);
}

12
Source/dx.cpp

@ -44,12 +44,12 @@ static void dx_create_back_buffer()
}
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwWidth = BUFFER_WIDTH;
ddsd.lPitch = BUFFER_WIDTH;
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
ddsd.dwHeight = BUFFER_HEIGHT;
ddsd.dwWidth = BUFFER_WIDTH;
ddsd.lPitch = BUFFER_WIDTH;
ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
error_code = lpDDSPrimary->GetPixelFormat(&ddsd.ddpfPixelFormat);
if (error_code != DD_OK)
@ -99,9 +99,9 @@ void dx_init(HWND hWnd)
BOOL bSuccess;
GUID *lpGUID;
/// ASSERT: assert(! gpBuffer);
/// ASSERT: assert(! sgdwLockCount);
/// ASSERT: assert(! sgpBackBuf);
assert(! gpBuffer);
assert(! sgdwLockCount);
assert(! sgpBackBuf);
SetFocus(hWnd);
ShowWindow(hWnd, SW_SHOWNORMAL);
@ -157,7 +157,7 @@ void dx_init(HWND hWnd)
GdiSetBatchLimit(1);
dx_create_back_buffer();
bSuccess = SDrawManualInitialize(hWnd, lpDDInterface, lpDDSPrimary, NULL, NULL, lpDDSBackBuf, lpDDPalette, NULL);
/// ASSERT: assert(bSuccess);
assert(bSuccess);
}
static void lock_buf_priv()

2074
Source/effects.cpp

File diff suppressed because it is too large Load Diff

32
Source/encrypt.cpp

@ -6,17 +6,15 @@
#include "all.h"
#include "../3rdParty/PKWare/pkware.h"
DWORD hashtable[1280];
DWORD hashtable[5][256];
void Decrypt(void *block, DWORD size, DWORD key)
void Decrypt(DWORD *castBlock, DWORD size, DWORD key)
{
DWORD *castBlock;
DWORD seed, i;
castBlock = (DWORD *)block;
seed = 0xEEEEEEEE;
for (i = 0; i < (size >> 2); i++) {
seed += hashtable[0x400 + (key & 0xFF)];
seed += hashtable[4][(key & 0xFF)];
*castBlock ^= seed + key;
seed += *castBlock + (seed << 5) + 3;
key = ((~key << 0x15) + 0x11111111) | (key >> 0x0B);
@ -24,16 +22,14 @@ void Decrypt(void *block, DWORD size, DWORD key)
}
}
void Encrypt(void *block, DWORD size, DWORD key)
void Encrypt(DWORD *castBlock, DWORD size, DWORD key)
{
DWORD *castBlock;
DWORD seed, i, ch;
castBlock = (DWORD *)block;
seed = 0xEEEEEEEE;
for (i = 0; i < (size >> 2); i++) {
ch = *castBlock;
seed += hashtable[0x400 + (key & 0xFF)];
seed += hashtable[4][(key & 0xFF)];
*castBlock ^= seed + key;
seed += ch + (seed << 5) + 3;
key = ((~key << 0x15) + 0x11111111) | (key >> 0x0B);
@ -51,7 +47,7 @@ DWORD Hash(const char *s, int type)
while (s != NULL && *s) {
ch = *s++;
ch = toupper(ch);
seed1 = hashtable[(type << 8) + ch] ^ (seed1 + seed2);
seed1 = hashtable[type][ch] ^ (seed1 + seed2);
seed2 += ch + seed1 + (seed2 << 5) + 3;
}
return seed1;
@ -69,24 +65,23 @@ void InitHash()
seed = (125 * seed + 3) % 0x2AAAAB;
ch = (seed & 0xFFFF);
seed = (125 * seed + 3) % 0x2AAAAB;
hashtable[i + j * 256] = ch << 16 | (seed & 0xFFFF);
hashtable[i][j] = ch << 16 | (seed & 0xFFFF);
}
}
}
int PkwareCompress(void *buf, int size)
int PkwareCompress(BYTE *srcData, int size)
{
BYTE *srcData, *destData;
BYTE *destData;
char *ptr;
unsigned int destSize, type, dsize;
TDataInfo param;
srcData = (BYTE *)buf;
ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE);
destSize = 2 * size;
if (destSize < 8192)
destSize = 8192;
if (destSize < 2 * 4096)
destSize = 2 * 4096;
destData = (BYTE *)DiabloAllocPtr(destSize);
@ -140,14 +135,13 @@ void __cdecl PkwareBufferWrite(char *buf, unsigned int *size, void *param)
pInfo->destOffset += *size;
}
void PkwareDecompress(void *param, int recv_size, int dwMaxBytes)
void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes)
{
char *ptr;
BYTE *pbInBuff, *pbOutBuff;
BYTE *pbOutBuff;
TDataInfo info;
ptr = (char *)DiabloAllocPtr(CMP_BUFFER_SIZE);
pbInBuff = (BYTE *)param;
pbOutBuff = DiabloAllocPtr(dwMaxBytes);
info.srcData = pbInBuff;

10
Source/encrypt.h

@ -6,15 +6,15 @@
#ifndef __ENCRYPT_H__
#define __ENCRYPT_H__
extern DWORD hashtable[1280];
extern DWORD hashtable[5][256];
void Decrypt(void *block, DWORD size, DWORD key);
void Encrypt(void *block, DWORD size, DWORD key);
void Decrypt(DWORD *castBlock, DWORD size, DWORD key);
void Encrypt(DWORD *castBlock, DWORD size, DWORD key);
DWORD Hash(const char *s, int type);
void InitHash();
int PkwareCompress(void *buf, int size);
int PkwareCompress(BYTE *srcData, int size);
unsigned int __cdecl PkwareBufferRead(char *buf, unsigned int *size, void *param);
void __cdecl PkwareBufferWrite(char *buf, unsigned int *size, void *param);
void PkwareDecompress(void *param, int recv_size, int dwMaxBytes);
void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes);
#endif /* __ENCRYPT_H__ */

174
Source/engine.cpp

@ -83,10 +83,10 @@ void CelBlit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
int w;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
#ifdef USE_ASM
@ -191,10 +191,10 @@ void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
BYTE *pRLEBytes;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pRLEBytes = CelGetFrame(pCelBuff, nCel, &nDataSize);
@ -214,10 +214,10 @@ void CelBlitFrame(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth)
BYTE *pRLEBytes;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
if (!pBuff)
if (pBuff == NULL)
return;
pRLEBytes = CelGetFrame(pCelBuff, nCel, &nDataSize);
@ -241,10 +241,10 @@ void CelClippedDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int Ce
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -287,10 +287,10 @@ void CelClippedBlit(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int CelSk
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
if (!pBuff)
if (pBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -326,10 +326,10 @@ void CelBlitLight(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
#ifdef USE_ASM
@ -487,10 +487,10 @@ void CelBlitLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWid
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
#ifdef USE_ASM
@ -681,10 +681,10 @@ void CelDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
BYTE *pDecodeTo, *pRLEBytes;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pRLEBytes = CelGetFrame(pCelBuff, nCel, &nDataSize);
@ -713,10 +713,10 @@ void CelClippedDrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -761,10 +761,10 @@ void CelClippedBlitLightTrans(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth,
DWORD *pFrameTable;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
if (!pBuff)
if (pBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -812,10 +812,10 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -840,7 +840,7 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -930,13 +930,13 @@ void CelBlitSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth)
int w;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
#ifdef USE_ASM
@ -1055,10 +1055,10 @@ void CelClippedDrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, in
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -1101,10 +1101,10 @@ void CelClippedBlitSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWidth, int C
int nDataStart, nDataSize, nDataCap;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
if (!pBuff)
if (pBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -1140,13 +1140,13 @@ void CelBlitLightSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidt
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
#ifdef USE_ASM
@ -1316,13 +1316,13 @@ void CelBlitLightTransSafe(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int
BYTE *tbl;
/// ASSERT: assert(pDecodeTo != NULL);
if (!pDecodeTo)
if (pDecodeTo == NULL)
return;
/// ASSERT: assert(pRLEBytes != NULL);
if (!pRLEBytes)
if (pRLEBytes == NULL)
return;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
#ifdef USE_ASM
@ -1527,10 +1527,10 @@ void CelDrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -1575,7 +1575,7 @@ void CelClippedBlitLightTransSafe(BYTE *pBuff, BYTE *pCelBuff, int nCel, int nWi
DWORD *pFrameTable;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -1623,10 +1623,10 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
pFrameTable = (DWORD *)pCelBuff;
@ -1651,7 +1651,7 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -1752,10 +1752,10 @@ void CelBlitWidth(BYTE *pBuff, int x, int y, int wdt, BYTE *pCelBuff, int nCel,
BYTE *pRLEBytes, *dst, *end;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(pBuff != NULL);
if (!pBuff)
if (pBuff == NULL)
return;
#ifdef USE_ASM
@ -1878,10 +1878,10 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
BYTE *pRLEBytes, *dst;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
#ifdef USE_ASM
@ -1906,11 +1906,11 @@ void CelBlitOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
mov nDataCap, eax
}
if (!nDataStart) return;
if (nDataStart == 0) return;
if (CelCap == 8)
nDataCap = 0;
if (nDataCap)
if (nDataCap != 0)
nDataSize = nDataCap - nDataStart;
else
nDataSize -= nDataStart;
@ -2026,10 +2026,10 @@ void CelBlitOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int
BYTE *pRLEBytes, *dst;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(gpBuffer);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
#ifdef USE_ASM
@ -2054,11 +2054,11 @@ void CelBlitOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int
mov nDataCap, eax
}
if (!nDataStart) return;
if (nDataStart == 0) return;
if (CelCap == 8)
nDataCap = 0;
if (nDataCap)
if (nDataCap != 0)
nDataSize = nDataCap - nDataStart;
else
nDataSize -= nDataStart;
@ -2656,7 +2656,7 @@ BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen)
* @param p Target buffer
* @return Size of file
*/
DWORD LoadFileWithMem(const char *pszName, void *p)
DWORD LoadFileWithMem(const char *pszName, BYTE *p)
{
DWORD dwFileLen;
HANDLE hsFile;
@ -2741,17 +2741,17 @@ void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip,
int nDataStart, nDataSize;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -2937,17 +2937,17 @@ void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWid
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3156,17 +3156,17 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3185,7 +3185,7 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int C
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -3372,17 +3372,17 @@ void Cl2DrawLight(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelS
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3422,17 +3422,17 @@ void Cl2DrawSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSk
int nDataStart, nDataSize;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3631,17 +3631,17 @@ void Cl2DrawOutlineSafe(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3863,17 +3863,17 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)
@ -3892,7 +3892,7 @@ void Cl2DrawLightTblSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, i
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -4092,17 +4092,17 @@ void Cl2DrawLightSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int
DWORD *pFrameTable;
/// ASSERT: assert(gpBuffer != NULL);
if (!gpBuffer)
if (gpBuffer == NULL)
return;
/// ASSERT: assert(pCelBuff != NULL);
if (!pCelBuff)
if (pCelBuff == NULL)
return;
/// ASSERT: assert(nCel > 0);
assert(nCel > 0);
if (nCel <= 0)
return;
pFrameTable = (DWORD *)pCelBuff;
/// ASSERT: assert(nCel <= (int) pFrameTable[0]);
assert(nCel <= (int)pFrameTable[0]);
pRLEBytes = &pCelBuff[pFrameTable[nCel]];
nDataStart = *(WORD *)&pRLEBytes[CelSkip];
if (!nDataStart)

2
Source/engine.h

@ -62,7 +62,7 @@ void engine_debug_trap(BOOL show_cursor);
BYTE *DiabloAllocPtr(DWORD dwBytes);
void mem_free_dbg(void *p);
BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen);
DWORD LoadFileWithMem(const char *pszName, void *p);
DWORD LoadFileWithMem(const char *pszName, BYTE *p);
void Cl2ApplyTrans(BYTE *p, BYTE *ttbl, int nCel);
void Cl2Draw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, int CelSkip, int CelCap);
void Cl2Blit(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nWidth);

2
Source/error.cpp

@ -122,7 +122,7 @@ void DrawDiabloMsg()
sy += 12;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
#define TRANS_RECT_X (PANEL_LEFT + 104)
#define TRANS_RECT_Y (DIALOG_TOP - 8)

68
Source/gamemenu.cpp

@ -12,31 +12,31 @@ BOOL jogging_opt = TRUE;
#endif
/** Contains the game menu items of the single player menu. */
TMenuItem sgSingleMenu[6] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, "Save Game", &gamemenu_save_game },
{ GMENU_ENABLED, "Options", &gamemenu_options },
{ GMENU_ENABLED, "New Game", &gamemenu_new_game },
{ GMENU_ENABLED, "Load Game", &gamemenu_load_game },
{ GMENU_ENABLED, "Quit Diablo", &gamemenu_quit_game },
{ GMENU_ENABLED, NULL, NULL }
// clang-format on
TMenuItem sgSingleMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, "Save Game", &gamemenu_save_game },
{ GMENU_ENABLED, "Options", &gamemenu_options },
{ GMENU_ENABLED, "New Game", &gamemenu_new_game },
{ GMENU_ENABLED, "Load Game", &gamemenu_load_game },
{ GMENU_ENABLED, "Quit Diablo", &gamemenu_quit_game },
{ GMENU_ENABLED, NULL, NULL }
// clang-format on
};
/** Contains the game menu items of the multi player menu. */
TMenuItem sgMultiMenu[5] = {
// clang-format off
// dwFlags, pszStr, fnMenu
TMenuItem sgMultiMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED, "Options", &gamemenu_options },
{ GMENU_ENABLED, "New Game", &gamemenu_new_game },
{ GMENU_ENABLED, "Restart In Town", &gamemenu_restart_town },
{ GMENU_ENABLED, "Quit Diablo", &gamemenu_quit_game },
{ GMENU_ENABLED, NULL, NULL }
// clang-format on
{ GMENU_ENABLED, NULL, NULL },
// clang-format on
};
TMenuItem sgOptionsMenu[6] = {
// clang-format off
// dwFlags, pszStr, fnMenu
TMenuItem sgOptionsMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
{ GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_music_volume },
{ GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_sound_volume },
{ GMENU_ENABLED | GMENU_SLIDER, "Gamma", &gamemenu_gamma },
@ -45,14 +45,20 @@ TMenuItem sgOptionsMenu[6] = {
#else
{ GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_loadjog },
#endif
{ GMENU_ENABLED , "Previous Menu", &gamemenu_previous },
{ GMENU_ENABLED , NULL, NULL }
// clang-format on
{ GMENU_ENABLED , "Previous Menu", &gamemenu_previous },
{ GMENU_ENABLED , NULL, NULL },
// clang-format on
};
/** Specifies the menu names for music enabled and disabled. */
char *music_toggle_names[] = { "Music", "Music Disabled" };
char *music_toggle_names[] = {
"Music",
"Music Disabled",
};
/** Specifies the menu names for sound enabled and disabled. */
char *sound_toggle_names[] = { "Sound", "Sound Disabled" };
char *sound_toggle_names[] = {
"Sound",
"Sound Disabled",
};
#ifdef HELLFIRE
char *jogging_toggle_names[] = { "Jog", "Walk", "Fast Walk" };
#endif
@ -63,17 +69,11 @@ char *color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" }
void gamemenu_on()
{
void (*proc)(TMenuItem *);
TMenuItem *item;
if (gbMaxPlayers == 1) {
proc = gamemenu_update_single;
item = sgSingleMenu;
gmenu_set_items(sgSingleMenu, gamemenu_update_single);
} else {
proc = gamemenu_update_multi;
item = sgMultiMenu;
gmenu_set_items(sgMultiMenu, gamemenu_update_multi);
}
gmenu_set_items(item, proc);
PressEscKey();
}
@ -87,7 +87,7 @@ void gamemenu_update_single(TMenuItem *pMenuItems)
if (plr[myplr]._pmode != PM_DEATH && !deathflag)
enable = TRUE;
gmenu_enable(sgSingleMenu, enable);
gmenu_enable(&sgSingleMenu[0], enable);
}
void gamemenu_update_multi(TMenuItem *pMenuItems)
@ -97,7 +97,7 @@ void gamemenu_update_multi(TMenuItem *pMenuItems)
void gamemenu_off()
{
gmenu_set_items(0, NULL);
gmenu_set_items(NULL, NULL);
}
void gamemenu_handle_previous()
@ -283,7 +283,7 @@ void gamemenu_music_volume(BOOL bActivate)
#endif
}
} else {
volume = gamemenu_slider_music_sound(sgOptionsMenu);
volume = gamemenu_slider_music_sound(&sgOptionsMenu[0]);
sound_get_or_set_music_volume(volume);
if (volume == VOLUME_MIN) {
if (gbMusicOn) {

26
Source/gendung.cpp

@ -23,7 +23,7 @@ int SpeedFrameTbl[128][16];
/**
* List of transparancy masks to use for dPieces
*/
char block_lvid[2049];
char block_lvid[MAXTILES + 1];
int level_frame_count[MAXTILES];
int tile_defs[MAXTILES];
WORD level_frame_types[MAXTILES];
@ -32,20 +32,20 @@ int nlevel_frames;
/**
* List of light blocking dPieces
*/
BOOLEAN nBlockTable[2049];
BOOLEAN nBlockTable[MAXTILES + 1];
/**
* List of path blocking dPieces
*/
BOOLEAN nSolidTable[2049];
BOOLEAN nSolidTable[MAXTILES + 1];
/**
* List of transparent dPieces
*/
BOOLEAN nTransTable[2049];
BOOLEAN nTransTable[MAXTILES + 1];
/**
* List of missile blocking dPieces
*/
BOOLEAN nMissileTable[2049];
BOOLEAN nTrapTable[2049];
BOOLEAN nMissileTable[MAXTILES + 1];
BOOLEAN nTrapTable[MAXTILES + 1];
int dminx;
int dminy;
int dmaxx;
@ -382,7 +382,7 @@ void MakeSpeedCels()
if (total_frames > 128)
total_frames = 128;
frameidx = 0; /* move into loop ? */
frameidx = 0;
if (light4flag)
blk_cnt = 3;
@ -501,7 +501,7 @@ void MakeSpeedCels()
for (y = 0; y < MAXDUNY; y++) {
for (x = 0; x < MAXDUNX; x++) {
if (dPiece[x][y]) {
if (dPiece[x][y] != 0) {
pMap = &dpiece_defs_map_2[x][y];
for (i = 0; i < blocks; i++) {
if (pMap->mt[i]) {
@ -557,7 +557,7 @@ void SetDungeonMicros()
for (x = 0; x < MAXDUNX; x++) {
lv = dPiece[x][y];
pMap = &dpiece_defs_map_2[x][y];
if (lv) {
if (lv != 0) {
lv--;
if (leveltype != DTYPE_HELL)
pPiece = (WORD *)&pLevelPieces[20 * lv];
@ -634,7 +634,7 @@ void DRLG_CopyTrans(int sx, int sy, int dx, int dy)
void DRLG_ListTrans(int num, BYTE *List)
{
int i;
BYTE x1, x2, y1, y2;
BYTE x1, y1, x2, y2;
for (i = 0; i < num; i++) {
x1 = *List++;
@ -648,7 +648,7 @@ void DRLG_ListTrans(int num, BYTE *List)
void DRLG_AreaTrans(int num, BYTE *List)
{
int i;
BYTE x1, x2, y1, y2;
BYTE x1, y1, x2, y2;
for (i = 0; i < num; i++) {
x1 = *List++;
@ -681,7 +681,7 @@ void DRLG_SetPC()
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
dFlags[i + x][j + y] |= 8;
dFlags[i + x][j + y] |= BFLAG_POPULATED;
}
}
}
@ -698,7 +698,7 @@ void Make_SetPC(int x, int y, int w, int h)
for (j = 0; j < dh; j++) {
for (i = 0; i < dw; i++) {
dFlags[i + dx][j + dy] |= 8;
dFlags[i + dx][j + dy] |= BFLAG_POPULATED;
}
}
}

12
Source/gendung.h

@ -21,17 +21,17 @@ extern BYTE *pLevelPieces;
extern BYTE *pDungeonCels;
extern BYTE *pSpeedCels;
extern int SpeedFrameTbl[128][16];
extern char block_lvid[2049];
extern char block_lvid[MAXTILES + 1];
extern int level_frame_count[MAXTILES];
extern int tile_defs[MAXTILES];
extern WORD level_frame_types[MAXTILES];
extern int level_frame_sizes[MAXTILES];
extern int nlevel_frames;
extern BOOLEAN nBlockTable[2049];
extern BOOLEAN nSolidTable[2049];
extern BOOLEAN nTransTable[2049];
extern BOOLEAN nMissileTable[2049];
extern BOOLEAN nTrapTable[2049];
extern BOOLEAN nBlockTable[MAXTILES + 1];
extern BOOLEAN nSolidTable[MAXTILES + 1];
extern BOOLEAN nTransTable[MAXTILES + 1];
extern BOOLEAN nMissileTable[MAXTILES + 1];
extern BOOLEAN nTrapTable[MAXTILES + 1];
extern int dminx;
extern int dminy;
extern int dmaxx;

16
Source/gmenu.cpp

@ -23,7 +23,7 @@ BYTE *sgpLogo;
int sgCurrentMenuIdx;
/** Maps from font index to bigtgold.cel frame number. */
const BYTE lfontframe[127] = {
const BYTE lfontframe[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -36,11 +36,11 @@ const BYTE lfontframe[127] = {
26, 42, 0, 43, 0, 0, 0, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 20, 0, 21, 0
24, 25, 26, 20, 0, 21, 0, 0
};
/** Maps from bigtgold.cel frame number to character width. */
const BYTE lfontkern[56] = {
const BYTE lfontkern[] = {
18, 33, 21, 26, 28, 19, 19, 26, 25, 11,
12, 25, 19, 34, 28, 32, 20, 32, 28, 20,
28, 36, 35, 46, 33, 33, 24, 11, 23, 22,
@ -66,7 +66,7 @@ void gmenu_print_text(int x, int y, char *pszStr)
while (*pszStr) {
c = gbFontTransTbl[(BYTE)*pszStr++];
c = lfontframe[c];
if (c)
if (c != 0)
CelDrawLight(x, y, BigTGold_cel, c, 46);
x += lfontkern[c] + 2;
}
@ -88,8 +88,8 @@ void gmenu_init_menu()
LogoAnim_frame = 1;
#endif
sgpCurrentMenu = NULL;
sgpCurrItem = 0;
dword_63447C = 0;
sgpCurrItem = NULL;
dword_63447C = NULL;
sgCurrentMenuIdx = 0;
mouseNavigation = FALSE;
#ifdef HELLFIRE
@ -280,7 +280,7 @@ BOOL gmenu_presskeys(int vkey)
break;
case VK_ESCAPE:
PlaySFX(IS_TITLEMOV);
gmenu_set_items(0, 0);
gmenu_set_items(NULL, NULL);
break;
case VK_SPACE:
return FALSE;
@ -418,7 +418,7 @@ void gmenu_slider_set(TMenuItem *pItem, int min, int max, int value)
{
int nSteps;
/// ASSERT: assertassert(pItem, "gmenu.cpp", 445);
assert(pItem);
nSteps = (int)(pItem->dwFlags & 0xFFF000) >> 12;
if (nSteps < 2)
nSteps = 2;

4
Source/gmenu.h

@ -40,7 +40,7 @@ void gmenu_slider_steps(TMenuItem *pItem, int dwTicks);
/* rdata */
extern const BYTE lfontframe[127];
extern const BYTE lfontkern[56];
extern const BYTE lfontframe[];
extern const BYTE lfontkern[];
#endif /* __GMENU_H__ */

8
Source/items.cpp

@ -139,7 +139,7 @@ char *ItemDropNames[] = {
"teddys1",
"cows1",
"donkys1",
"mooses1"
"mooses1",
#endif
};
BYTE ItemAnimLs[] = {
@ -186,7 +186,7 @@ BYTE ItemAnimLs[] = {
10,
15,
15,
15
15,
#endif
};
int ItemDropSnds[] = {
@ -233,7 +233,7 @@ int ItemDropSnds[] = {
IS_FMUSH,
IS_FHARM,
IS_FLARM,
IS_FLARM
IS_FLARM,
#endif
};
int ItemInvSnds[] = {
@ -280,7 +280,7 @@ int ItemInvSnds[] = {
IS_IMUSH,
IS_IHARM,
IS_ILARM,
IS_ILARM
IS_ILARM,
#endif
};
#ifdef HELLFIRE

467
Source/monstdat.cpp

@ -188,183 +188,334 @@ MonsterData monsterdata[] = {
// clang-format on
};
char MonstConvTbl[128] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 29, 30,
31, 32, 34, 35, 36, 37, 38, 40, 39, 41,
42, 43, 44, 45, 46, 47, 48, 49, 50, 52,
53, 54, 55, 56, 57, 59, 58, 60, 61, 62,
63, 64, 65, 66, 67, 68, 69, 70, 71, 0,
0, 0, 0, 72, 73, 74, 75, 0, 0, 0,
0, 77, 76, 78, 79, 81, 82, 83, 84, 85,
86, 87, 88, 89, 90, 92, 91, 93, 94, 95,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106, 107, 108, 0, 110, 0, 109, 0, 0, 0,
0, 0, 0, 0, 0, 0, 80, 111
/**
* Map between .DUN file value and monster type enum
*/
#ifdef HELLFIRE
int MonstConvTbl[] = {
#else
BYTE MonstConvTbl[] = {
#endif
MT_NZOMBIE,
MT_BZOMBIE,
MT_GZOMBIE,
MT_YZOMBIE,
MT_RFALLSP,
MT_DFALLSP,
MT_YFALLSP,
MT_BFALLSP,
MT_WSKELAX,
MT_TSKELAX,
MT_RSKELAX,
MT_XSKELAX,
MT_RFALLSD,
MT_DFALLSD,
MT_YFALLSD,
MT_BFALLSD,
MT_NSCAV,
MT_BSCAV,
MT_WSCAV,
MT_YSCAV,
MT_WSKELBW,
MT_TSKELBW,
MT_RSKELBW,
MT_XSKELBW,
MT_WSKELSD,
MT_TSKELSD,
MT_RSKELSD,
MT_XSKELSD,
MT_SNEAK,
MT_STALKER,
MT_UNSEEN,
MT_ILLWEAV,
MT_NGOATMC,
MT_BGOATMC,
MT_RGOATMC,
MT_GGOATMC,
MT_FIEND,
MT_GLOOM,
MT_BLINK,
MT_FAMILIAR,
MT_NGOATBW,
MT_BGOATBW,
MT_RGOATBW,
MT_GGOATBW,
MT_NACID,
MT_RACID,
MT_BACID,
MT_XACID,
MT_SKING,
MT_FAT,
MT_MUDMAN,
MT_TOAD,
MT_FLAYED,
MT_WYRM,
MT_CAVSLUG,
MT_DEVOUR,
MT_DVLWYRM,
MT_NMAGMA,
MT_YMAGMA,
MT_BMAGMA,
MT_WMAGMA,
MT_HORNED,
MT_MUDRUN,
MT_FROSTC,
MT_OBLORD,
MT_BONEDMN,
MT_REDDTH,
MT_LTCHDMN,
MT_UDEDBLRG,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_INCIN,
MT_FLAMLRD,
MT_DOOMFIRE,
MT_HELLBURN,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_RSTORM,
MT_STORM,
MT_STORML,
MT_MAEL,
MT_WINGED,
MT_GARGOYLE,
MT_BLOODCLW,
MT_DEATHW,
MT_MEGA,
MT_GUARD,
MT_VTEXLRD,
MT_BALROG,
MT_NSNAKE,
MT_RSNAKE,
MT_GSNAKE,
MT_BSNAKE,
MT_NBLACK,
MT_RTBLACK,
MT_BTBLACK,
MT_RBLACK,
MT_UNRAV,
MT_HOLOWONE,
MT_PAINMSTR,
MT_REALWEAV,
MT_SUCCUBUS,
MT_SNOWWICH,
MT_HLSPWN,
MT_SOLBRNR,
MT_COUNSLR,
MT_MAGISTR,
MT_CABALIST,
MT_ADVOCATE,
MT_NZOMBIE,
MT_DIABLO,
MT_NZOMBIE,
MT_GOLEM,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_NZOMBIE,
MT_BIGFALL,
MT_DARKMAGE,
#ifdef HELLFIRE
MT_HELLBOAR,
MT_STINGER,
MT_PSYCHORB,
MT_ARACHNON,
MT_FELLTWIN,
MT_HORKSPWN,
MT_STINGER,
MT_PSYCHORB,
MT_ARACHNON,
MT_LASHWORM,
MT_TORCHANT,
MT_HORKDMN,
MT_DEFILER,
MT_GRAVEDIG,
MT_TOMBRAT,
MT_FIREBAT,
MT_SKLWING,
MT_LICH,
MT_CRYPTDMN,
MT_FIREBAT,
MT_SKLWING,
MT_LICH,
MT_BICLOPS,
MT_FLESTHNG,
MT_REAPER,
MT_NAKRUL,
#endif
};
#define MAT_NEVER 0
#define MAT_ALWAYS 1
#define MAT_RETAIL 2
/**
* 0 = Never avalible
* 1 = Avalible in retail and shareware
* 2 = avalible in retail only
* Define what version a monster type is available in
*/
#ifdef HELLFIRE
int MonstAvailTbl[] = {
#else
BYTE MonstAvailTbl[] = {
#endif
1, // Zombie
1, // Ghoul
1, // Rotting Carcass
1, // Black Death
1, // Fallen One
1, // Carver
1, // Devil Kin
1, // Dark One
1, // Skeleton
1, // Corpse Axe
1, // Burning Dead
1, // Horror
1, // Fallen One
1, // Carver
1, // Devil Kin
1, // Dark One
1, // Scavenger
1, // Plague Eater
1, // Shadow Beast
1, // Bone Gasher
1, // Skeleton
1, // Corpse Bow
1, // Burning Dead
1, // Horror
1, // Skeleton Captain
1, // Corpse Captain
1, // Burning Dead Captain
1, // Horror Captain
0, // Invisible Lord
2, // Hidden
2, // Stalker
2, // Unseen
2, // Illusion Weaver
MAT_ALWAYS, // Zombie
MAT_ALWAYS, // Ghoul
MAT_ALWAYS, // Rotting Carcass
MAT_ALWAYS, // Black Death
MAT_ALWAYS, // Fallen One
MAT_ALWAYS, // Carver
MAT_ALWAYS, // Devil Kin
MAT_ALWAYS, // Dark One
MAT_ALWAYS, // Skeleton
MAT_ALWAYS, // Corpse Axe
MAT_ALWAYS, // Burning Dead
MAT_ALWAYS, // Horror
MAT_ALWAYS, // Fallen One
MAT_ALWAYS, // Carver
MAT_ALWAYS, // Devil Kin
MAT_ALWAYS, // Dark One
MAT_ALWAYS, // Scavenger
MAT_ALWAYS, // Plague Eater
MAT_ALWAYS, // Shadow Beast
MAT_ALWAYS, // Bone Gasher
MAT_ALWAYS, // Skeleton
MAT_ALWAYS, // Corpse Bow
MAT_ALWAYS, // Burning Dead
MAT_ALWAYS, // Horror
MAT_ALWAYS, // Skeleton Captain
MAT_ALWAYS, // Corpse Captain
MAT_ALWAYS, // Burning Dead Captain
MAT_ALWAYS, // Horror Captain
MAT_NEVER, // Invisible Lord
MAT_RETAIL, // Hidden
MAT_RETAIL, // Stalker
MAT_RETAIL, // Unseen
MAT_RETAIL, // Illusion Weaver
#ifdef HELLFIRE
2, // Satyr Lord
MAT_RETAIL, // Satyr Lord
#else
0, // Lord Sayter
MAT_NEVER, // Lord Sayter
#endif
2, // Flesh Clan
2, // Stone Clan
2, // Fire Clan
2, // Night Clan
1, // Fiend
1, // Blink
1, // Gloom
1, // Familiar
2, // Flesh Clan
2, // Stone Clan
2, // Fire Clan
2, // Night Clan
2, // Acid Beast
2, // Poison Spitter
2, // Pit Beast
2, // Lava Maw
0, // Skeleton King
0, // The Butcher
2, // Overlord
2, // Mud Man
2, // Toad Demon
2, // Flayed One
0, // Wyrm
0, // Cave Slug
0, // Devil Wyrm
0, // Devourer
2, // Magma Demon
2, // Blood Stone
2, // Hell Stone
2, // Lava Lord
2, // Horned Demon
2, // Mud Runner
2, // Frost Charger
2, // Obsidian Lord
0, // Bone Demon (oldboned in Hellfire)
0, // Red Death
0, // Litch Demon
0, // Undead Balrog
0, // Incinerator
0, // Flame Lord
0, // Doom Fire
0, // Hell Burner
2, // Red Storm
2, // Storm Rider
2, // Storm Lord
2, // Maelstorm
MAT_RETAIL, // Flesh Clan
MAT_RETAIL, // Stone Clan
MAT_RETAIL, // Fire Clan
MAT_RETAIL, // Night Clan
MAT_ALWAYS, // Fiend
MAT_ALWAYS, // Blink
MAT_ALWAYS, // Gloom
MAT_ALWAYS, // Familiar
MAT_RETAIL, // Flesh Clan
MAT_RETAIL, // Stone Clan
MAT_RETAIL, // Fire Clan
MAT_RETAIL, // Night Clan
MAT_RETAIL, // Acid Beast
MAT_RETAIL, // Poison Spitter
MAT_RETAIL, // Pit Beast
MAT_RETAIL, // Lava Maw
MAT_NEVER, // Skeleton King
MAT_NEVER, // The Butcher
MAT_RETAIL, // Overlord
MAT_RETAIL, // Mud Man
MAT_RETAIL, // Toad Demon
MAT_RETAIL, // Flayed One
MAT_NEVER, // Wyrm
MAT_NEVER, // Cave Slug
MAT_NEVER, // Devil Wyrm
MAT_NEVER, // Devourer
MAT_RETAIL, // Magma Demon
MAT_RETAIL, // Blood Stone
MAT_RETAIL, // Hell Stone
MAT_RETAIL, // Lava Lord
MAT_RETAIL, // Horned Demon
MAT_RETAIL, // Mud Runner
MAT_RETAIL, // Frost Charger
MAT_RETAIL, // Obsidian Lord
MAT_NEVER, // Bone Demon (oldboned in Hellfire)
MAT_NEVER, // Red Death
MAT_NEVER, // Litch Demon
MAT_NEVER, // Undead Balrog
MAT_NEVER, // Incinerator
MAT_NEVER, // Flame Lord
MAT_NEVER, // Doom Fire
MAT_NEVER, // Hell Burner
MAT_RETAIL, // Red Storm
MAT_RETAIL, // Storm Rider
MAT_RETAIL, // Storm Lord
MAT_RETAIL, // Maelstorm
#ifdef HELLFIRE
2, // Devil Kin Brute
MAT_RETAIL, // Devil Kin Brute
#else
0, // Devil Kin Brute
MAT_NEVER, // Devil Kin Brute
#endif
2, // Winged-Demon
2, // Gargoyle
2, // Blood Claw
2, // Death Wing
2, // Slayer
2, // Guardian
2, // Vortex Lord
2, // Balrog
2, // Cave Viper
2, // Fire Drake
2, // Gold Viper
2, // Azure Drake
2, // Black Knight
2, // Doom Guard
2, // Steel Lord
2, // Blood Knight
MAT_RETAIL, // Winged-Demon
MAT_RETAIL, // Gargoyle
MAT_RETAIL, // Blood Claw
MAT_RETAIL, // Death Wing
MAT_RETAIL, // Slayer
MAT_RETAIL, // Guardian
MAT_RETAIL, // Vortex Lord
MAT_RETAIL, // Balrog
MAT_RETAIL, // Cave Viper
MAT_RETAIL, // Fire Drake
MAT_RETAIL, // Gold Viper
MAT_RETAIL, // Azure Drake
MAT_RETAIL, // Black Knight
MAT_RETAIL, // Doom Guard
MAT_RETAIL, // Steel Lord
MAT_RETAIL, // Blood Knight
#ifdef HELLFIRE
2, // The Shredded
MAT_RETAIL, // The Shredded
#else
0, // Unraveler
MAT_NEVER, // Unraveler
#endif
0, // Hollow One
0, // Pain Master
0, // Reality Weaver
2, // Succubus
2, // Snow Witch
2, // Hell Spawn
2, // Soul Burner
2, // Counselor
2, // Magistrate
2, // Cabalist
2, // Advocate
0, // Golem
0, // The Dark Lord
0, // The Arch-Litch Malignus
MAT_NEVER, // Hollow One
MAT_NEVER, // Pain Master
MAT_NEVER, // Reality Weaver
MAT_RETAIL, // Succubus
MAT_RETAIL, // Snow Witch
MAT_RETAIL, // Hell Spawn
MAT_RETAIL, // Soul Burner
MAT_RETAIL, // Counselor
MAT_RETAIL, // Magistrate
MAT_RETAIL, // Cabalist
MAT_RETAIL, // Advocate
MAT_NEVER, // Golem
MAT_NEVER, // The Dark Lord
MAT_NEVER, // The Arch-Litch Malignus
#ifdef HELLFIRE
2, // Hellboar
2, // Stinger
2, // Psychorb
2, // Arachnon
2, // Felltwin
2, // Hork Spawn
2, // Venomtail
2, // Necromorb
2, // Spider Lord
2, // Lashworm
2, // Torchant
0, // Hork Demon
0, // Hell Bug
2, // Gravedigger
2, // Tomb Rat
2, // Firebat
2, // Skullwing
2, // Lich
2, // Crypt Demon
2, // Hellbat
2, // Bone Demon
2, // Arch Lich
2, // Biclops
2, // Flesh Thing
2, // Reaper
0, // Na-Krul
MAT_RETAIL, // Hellboar
MAT_RETAIL, // Stinger
MAT_RETAIL, // Psychorb
MAT_RETAIL, // Arachnon
MAT_RETAIL, // Felltwin
MAT_RETAIL, // Hork Spawn
MAT_RETAIL, // Venomtail
MAT_RETAIL, // Necromorb
MAT_RETAIL, // Spider Lord
MAT_RETAIL, // Lashworm
MAT_RETAIL, // Torchant
MAT_NEVER, // Hork Demon
MAT_NEVER, // Hell Bug
MAT_RETAIL, // Gravedigger
MAT_RETAIL, // Tomb Rat
MAT_RETAIL, // Firebat
MAT_RETAIL, // Skullwing
MAT_RETAIL, // Lich
MAT_RETAIL, // Crypt Demon
MAT_RETAIL, // Hellbat
MAT_RETAIL, // Bone Demon
MAT_RETAIL, // Arch Lich
MAT_RETAIL, // Biclops
MAT_RETAIL, // Flesh Thing
MAT_RETAIL, // Reaper
MAT_NEVER, // Na-Krul
#endif
};

3
Source/monstdat.h

@ -7,10 +7,11 @@
#define __MONSTDAT_H__
extern MonsterData monsterdata[];
extern char MonstConvTbl[128];
#ifdef HELLFIRE
extern int MonstConvTbl[];
extern int MonstAvailTbl[];
#else
extern BYTE MonstConvTbl[];
extern BYTE MonstAvailTbl[];
#endif
extern UniqMonstStruct UniqMonst[];

14
Source/mpqapi.cpp

@ -7,7 +7,7 @@
#include "../3rdParty/Storm/Source/storm.h"
DWORD sgdwMpqOffset;
char mpq_buf[4096];
BYTE mpq_buf[4096];
_HASHENTRY *sgpHashTbl;
/** Has the savegame-file been modified in memory. */
BOOL save_archive_modified;
@ -466,7 +466,7 @@ BOOL OpenMPQ(const char *pszArchive, BOOL hidden, DWORD dwChar)
if (!ReadFile(sghArchive, sgpBlockTbl, 0x8000, &dwTemp, NULL))
goto on_error;
key = Hash("(block table)", 3);
Decrypt(sgpBlockTbl, 0x8000, key);
Decrypt((DWORD *)sgpBlockTbl, 0x8000, key);
}
sgpHashTbl = (_HASHENTRY *)DiabloAllocPtr(0x8000);
memset(sgpHashTbl, 255, 0x8000);
@ -476,7 +476,7 @@ BOOL OpenMPQ(const char *pszArchive, BOOL hidden, DWORD dwChar)
if (!ReadFile(sghArchive, sgpHashTbl, 0x8000, &dwTemp, NULL))
goto on_error;
key = Hash("(hash table)", 3);
Decrypt(sgpHashTbl, 0x8000, key);
Decrypt((DWORD *)sgpHashTbl, 0x8000, key);
}
return TRUE;
}
@ -615,9 +615,9 @@ BOOL mpqapi_write_block_table()
if (SetFilePointer(sghArchive, 104, NULL, FILE_BEGIN) == -1)
return FALSE;
Encrypt(sgpBlockTbl, 0x8000, Hash("(block table)", 3));
Encrypt((DWORD *)sgpBlockTbl, 0x8000, Hash("(block table)", 3));
success = WriteFile(sghArchive, sgpBlockTbl, 0x8000, &NumberOfBytesWritten, 0);
Decrypt(sgpBlockTbl, 0x8000, Hash("(block table)", 3));
Decrypt((DWORD *)sgpBlockTbl, 0x8000, Hash("(block table)", 3));
return success && NumberOfBytesWritten == 0x8000;
}
@ -629,9 +629,9 @@ BOOL mpqapi_write_hash_table()
if (SetFilePointer(sghArchive, 32872, NULL, FILE_BEGIN) == -1)
return FALSE;
Encrypt(sgpHashTbl, 0x8000, Hash("(hash table)", 3));
Encrypt((DWORD *)sgpHashTbl, 0x8000, Hash("(hash table)", 3));
success = WriteFile(sghArchive, sgpHashTbl, 0x8000, &NumberOfBytesWritten, 0);
Decrypt(sgpHashTbl, 0x8000, Hash("(hash table)", 3));
Decrypt((DWORD *)sgpHashTbl, 0x8000, Hash("(hash table)", 3));
return success && NumberOfBytesWritten == 0x8000;
}

2
Source/mpqapi.h

@ -6,7 +6,7 @@
#ifndef __MPQAPI_H__
#define __MPQAPI_H__
extern char mpq_buf[4096];
extern BYTE mpq_buf[4096];
extern BOOL save_archive_modified;
extern BOOLEAN save_archive_open;

22
enums.h

@ -1386,14 +1386,14 @@ typedef enum _sfx_id {
} _sfx_id;
typedef enum sfx_flag {
SFX_STREAM = 0x01,
SFX_MISC = 0x02,
SFX_UI = 0x04,
SFX_MONK = 0x08,
SFX_ROGUE = 0x10,
SFX_WARRIOR = 0x20,
SFX_SORCEROR = 0x40,
SFX_LOADED = 0x80,
sfx_STREAM = 0x01,
sfx_MISC = 0x02,
sfx_UI = 0x04,
sfx_MONK = 0x08,
sfx_ROGUE = 0x10,
sfx_WARRIOR = 0x20,
sfx_SORCEROR = 0x40,
sfx_LOADED = 0x80,
} sfx_flag;
typedef enum item_equip_type {
@ -1768,8 +1768,8 @@ typedef enum _monster_id {
MT_ADVOCATE = 0x6C,
MT_GOLEM = 0x6D,
MT_DIABLO = 0x6E,
MT_DARKMAGE = 0x6F,
#ifdef HELLFIRE
MT_DARKMAGE = 0x6F, /* not counted in enum in vanilla */
MT_HELLBOAR = 0x70,
MT_STINGER = 0x71,
MT_PSYCHORB = 0x72,
@ -1796,8 +1796,10 @@ typedef enum _monster_id {
MT_FLESTHNG = 0x87,
MT_REAPER = 0x88,
MT_NAKRUL = 0x89,
#endif
NUM_MTYPES,
#else
NUM_MTYPES = 0x6F, /// BUGFIX the count is off by one
#endif
} _monster_id;
// this enum contains indexes from UniqMonst array for special unique monsters (usually quest related)

Loading…
Cancel
Save