Browse Source

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

pull/704/head
Anders Jenbo 6 years ago
parent
commit
7108145a04
  1. 24
      Source/appfat.cpp
  2. 70
      Source/automap.cpp
  3. 39
      Source/codec.cpp
  4. 30
      Source/control.cpp
  5. 37
      Source/cursor.cpp
  6. 8
      Source/cursor.h
  7. 2
      Source/debug.cpp
  8. 110
      Source/diablo.cpp
  9. 12
      Source/diablo.h
  10. 5
      Source/drlg_l2.cpp
  11. 2
      Source/drlg_l2.h
  12. 17
      Source/drlg_l4.cpp
  13. 6
      Source/drlg_l4.h
  14. 2
      Source/dthread.cpp
  15. 1748
      Source/effects.cpp
  16. 32
      Source/encrypt.cpp
  17. 10
      Source/encrypt.h
  18. 12
      Source/engine.cpp
  19. 4
      Source/engine.h
  20. 6
      Source/error.cpp
  21. 2
      Source/error.h
  22. 97
      Source/gamemenu.cpp
  23. 115
      Source/gendung.cpp
  24. 91
      Source/gendung.h
  25. 16
      Source/gmenu.cpp
  26. 4
      Source/gmenu.h
  27. 2
      Source/help.cpp
  28. 24
      Source/interfac.cpp
  29. 97
      Source/inv.cpp
  30. 2
      Source/itemdat.cpp
  31. 85
      Source/items.cpp
  32. 10
      Source/items.h
  33. 39
      Source/lighting.cpp
  34. 26
      Source/loadsave.cpp
  35. 10
      Source/minitext.cpp
  36. 2
      Source/minitext.h
  37. 140
      Source/missiles.cpp
  38. 377
      Source/monstdat.cpp
  39. 2
      Source/monstdat.h
  40. 159
      Source/monster.cpp
  41. 1
      Source/monster.h
  42. 17
      Source/mpqapi.cpp
  43. 5
      Source/mpqapi.h
  44. 20
      Source/msg.cpp
  45. 40
      Source/multi.cpp
  46. 228
      Source/objdat.cpp
  47. 2
      Source/objdat.h
  48. 244
      Source/objects.cpp
  49. 8
      Source/pack.cpp
  50. 8
      Source/palette.cpp
  51. 451
      Source/player.cpp
  52. 8
      Source/quests.cpp
  53. 2
      Source/quests.h
  54. 10
      Source/scrollrt.cpp
  55. 30
      Source/setmaps.cpp
  56. 14
      Source/spells.cpp
  57. 10
      Source/sync.cpp
  58. 2
      Source/textdat.cpp
  59. 2
      Source/textdat.h
  60. 2
      Source/themes.cpp
  61. 2
      Source/tmsg.cpp
  62. 74
      Source/towners.cpp
  63. 2
      Source/towners.h
  64. 16
      Source/trigs.cpp
  65. 4
      Source/wave.cpp
  66. 2
      Source/wave.h
  67. 35
      SourceT/effects_test.cpp
  68. 47
      SourceX/controls/plrctrls.cpp
  69. 2
      SourceX/sound.cpp
  70. 4
      defs.h
  71. 60
      enums.h
  72. 6
      structs.h

24
Source/appfat.cpp

@ -15,6 +15,9 @@ BOOL terminating;
/** Thread id of the last callee to FreeDlg(). */
int cleanup_thread_id;
/**
* @brief Terminates the game and displays an error message box.
*/
void app_fatal(const char *pszFmt, ...)
{
va_list va;
@ -30,6 +33,9 @@ void app_fatal(const char *pszFmt, ...)
diablo_quit(1);
}
/**
* @brief Displays an error message box based on the given format string and variable argument list.
*/
void MsgBox(const char *pszFmt, va_list va)
{
char text[256];
@ -39,6 +45,9 @@ void MsgBox(const char *pszFmt, va_list va)
UiErrorOkDialog("Error", text);
}
/**
* @brief Cleans up after a fatal application error.
*/
void FreeDlg()
{
if (terminating && cleanup_thread_id != SDL_GetThreadID(NULL))
@ -55,6 +64,9 @@ void FreeDlg()
SNetDestroy();
}
/**
* @brief Displays a warning message box based on the given formatted error message.
*/
void DrawDlg(char *pszFmt, ...)
{
char text[256];
@ -74,6 +86,9 @@ void assert_fail(int nLineNo, const char *pszFile, const char *pszFail)
}
#endif
/**
* @brief Terminates the game and displays an error dialog box based on the given dialog_id.
*/
void ErrDlg(const char *title, const char *error, char *log_file_path, int log_line_nr)
{
char text[1024];
@ -86,6 +101,9 @@ void ErrDlg(const char *title, const char *error, char *log_file_path, int log_l
app_fatal(NULL);
}
/**
* @brief Terminates the game with a file not found error dialog.
*/
void FileErrDlg(const char *error)
{
char text[1024];
@ -110,6 +128,9 @@ void FileErrDlg(const char *error)
app_fatal(NULL);
}
/**
* @brief Terminates the game with an insert CD error dialog.
*/
void InsertCDDlg(const char *fileName)
{
char text[1024];
@ -125,6 +146,9 @@ void InsertCDDlg(const char *fileName)
app_fatal(NULL);
}
/**
* @brief Terminates the game with a read-only directory error dialog.
*/
void DirErrorDlg(char *error)
{
char text[1024];

70
Source/automap.cpp

@ -47,6 +47,9 @@ int AmLine4;
#define MAPFLAG_DIRT 0x40
#define MAPFLAG_STAIRS 0x80
/**
* @brief Initializes the automap.
*/
void InitAutomapOnce()
{
automapflag = FALSE;
@ -58,6 +61,9 @@ void InitAutomapOnce()
AmLine4 = 2;
}
/**
* @brief Loads the mapping between tile IDs and automap shapes.
*/
void InitAutomap()
{
BYTE b1, b2;
@ -98,7 +104,7 @@ void InitAutomap()
return;
}
dwTiles >>= 1;
dwTiles /= 2;
pTmp = pAFile;
for (i = 1; i <= dwTiles; i++) {
@ -116,6 +122,9 @@ void InitAutomap()
}
}
/**
* @brief Displays the automap.
*/
void StartAutomap()
{
AutoMapXOfs = 0;
@ -123,30 +132,45 @@ void StartAutomap()
automapflag = TRUE;
}
/**
* @brief Scrolls the automap upwards.
*/
void AutomapUp()
{
AutoMapXOfs--;
AutoMapYOfs--;
}
/**
* @brief Scrolls the automap downwards.
*/
void AutomapDown()
{
AutoMapXOfs++;
AutoMapYOfs++;
}
/**
* @brief Scrolls the automap leftwards.
*/
void AutomapLeft()
{
AutoMapXOfs--;
AutoMapYOfs++;
}
/**
* @brief Scrolls the automap rightwards.
*/
void AutomapRight()
{
AutoMapXOfs++;
AutoMapYOfs--;
}
/**
* @brief Increases the zoom level of the automap.
*/
void AutomapZoomIn()
{
if (AutoMapScale < 200) {
@ -159,6 +183,9 @@ void AutomapZoomIn()
}
}
/**
* @brief Decreases the zoom level of the automap.
*/
void AutomapZoomOut()
{
if (AutoMapScale > 50) {
@ -171,6 +198,9 @@ void AutomapZoomOut()
}
}
/**
* @brief Renders the automap on screen.
*/
void DrawAutomap()
{
int cells;
@ -236,7 +266,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;
}
@ -245,7 +275,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;
}
@ -257,6 +287,9 @@ void DrawAutomap()
gpBufEnd = &gpBuffer[BUFFER_WIDTH * (SCREEN_HEIGHT + SCREEN_Y)];
}
/**
* @brief Renders the given automap shape at the specified screen coordinates.
*/
void DrawAutomapTile(int sx, int sy, WORD automap_type)
{
BOOL do_vert;
@ -369,7 +402,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);
}
@ -402,7 +435,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);
}
@ -442,21 +475,24 @@ void DrawAutomapTile(int sx, int sy, WORD automap_type)
}
}
/**
* @brief Renders an arrow on the automap, centered on and facing the direction of the player.
*/
void DrawAutomapPlr()
{
int px, py;
int x, y;
if (plr[myplr]._pmode == PM_WALK3) {
x = plr[myplr]._px;
y = plr[myplr]._py;
x = plr[myplr]._pfutx;
y = plr[myplr]._pfuty;
if (plr[myplr]._pdir == DIR_W)
x++;
else
y++;
} else {
x = plr[myplr].WorldX;
y = plr[myplr].WorldY;
x = plr[myplr]._px;
y = plr[myplr]._py;
}
px = x - 2 * AutoMapXOfs - ViewX;
py = y - 2 * AutoMapYOfs - ViewY;
@ -514,6 +550,9 @@ void DrawAutomapPlr()
}
}
/**
* @brief Returns the automap shape at the given coordinate.
*/
WORD GetAutomapType(int x, int y, BOOL view)
{
WORD rv;
@ -555,6 +594,9 @@ WORD GetAutomapType(int x, int y, BOOL view)
return rv;
}
/**
* @brief Renders game info, such as the name of the current level, and in multi player the name of the game and the game password.
*/
void DrawAutomapText()
{
char desc[256];
@ -570,14 +612,17 @@ void DrawAutomapText()
nextline = 50;
}
}
if (setlevel)
if (setlevel) {
PrintGameStr(8, nextline, quest_level_names[(BYTE)setlvlnum], COL_GOLD);
else if (currlevel) {
} else if (currlevel) {
sprintf(desc, "Level: %i", currlevel);
PrintGameStr(8, nextline, desc, COL_GOLD);
}
}
/**
* @brief Marks the given coordinate as within view on the automap.
*/
void SetAutomapView(int x, int y)
{
WORD maptype, solid;
@ -650,6 +695,9 @@ void SetAutomapView(int x, int y)
}
}
/**
* @brief Resets the zoom level of the automap.
*/
void AutomapZoomReset()
{
AutoMapXOfs = 0;

39
Source/codec.cpp

@ -17,6 +17,8 @@ typedef struct CodecSignature {
WORD unused;
} CodecSignature;
#define BLOCKSIZE 64
int codec_decode(BYTE *pbSrcDst, DWORD size, char *pszPassword)
{
char buf[128];
@ -25,20 +27,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));
@ -53,7 +55,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:
@ -95,9 +97,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)
@ -115,19 +117,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));
@ -135,10 +137,9 @@ 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();
}
DEVILUTION_END_NAMESPACE

30
Source/control.cpp

@ -646,9 +646,12 @@ void DrawFlask(BYTE *pCelBuff, int w, int nSrcOff, BYTE *pBuff, int nDstOff, int
*/
void DrawLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
plr[myplr]._pHPPer = filled;
double p;
int filled;
p = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
plr[myplr]._pHPPer = p;
filled = plr[myplr]._pHPPer;
if (filled > 80)
filled = 80;
filled = 80 - filled;
@ -668,7 +671,10 @@ void DrawLifeFlask()
*/
void UpdateLifeFlask()
{
int filled = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
double p;
int filled;
p = (double)plr[myplr]._pHitPoints / (double)plr[myplr]._pMaxHP * 80.0;
filled = p;
plr[myplr]._pHPPer = filled;
if (filled > 69)
@ -778,7 +784,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++)
@ -1279,7 +1285,7 @@ void CPrintString(int y, char *str, BOOL center, int lines)
lineOffset = 0;
sx = 177 + PANEL_X;
sy = lineOffsets[lines][y] + PANEL_Y;
if (center == 1) {
if (center == TRUE) {
strWidth = 0;
tmp = str;
while (*tmp) {
@ -1580,7 +1586,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);
@ -1911,7 +1917,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;
}
@ -1946,7 +1952,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;
@ -2075,7 +2081,7 @@ char *control_print_talk_msg(char *msg, int *x, int y, int color)
if (width > 514 + PANEL_LEFT)
return msg;
msg++;
if (c) {
if (c != 0) {
PrintChar(*x, y + 22 + PANEL_Y, c, color);
}
*x += fontkern[c] + 1;
@ -2137,7 +2143,7 @@ void control_reset_talk_msg(char *msg)
if (whisper[i])
pmask |= 1 << i;
}
NetSendCmdString(pmask, sgszTalkMsg);
NetSendCmdString(pmask, sgszTalkMsg);
}
void control_type_message()
@ -2149,7 +2155,7 @@ void control_type_message()
}
talkflag = TRUE;
sgszTalkMsg[0] = 0;
sgszTalkMsg[0] = '\0';
PentSpn2Frame = 1;
for (i = 0; i < 3; i++) {
talkbtndown[i] = FALSE;
@ -2225,7 +2231,7 @@ void control_press_enter()
int i;
BYTE talk_save;
if (sgszTalkMsg[0]) {
if (sgszTalkMsg[0] != 0) {
control_reset_talk_msg(sgszTalkMsg);
for (i = 0; i < 8; i++) {
if (!strcmp(sgszTalkSave[i], sgszTalkMsg))

37
Source/cursor.cpp

@ -7,17 +7,17 @@
DEVILUTION_BEGIN_NAMESPACE
int cursH;
int icursH28;
int cursW;
int cursH;
int pcursmonst = -1;
int icursW28;
int icursH28;
BYTE *pCursCels;
int icursH;
/** inv_item value */
char pcursinvitem;
int icursW;
int icursH;
char pcursitem;
char pcursobj;
char pcursplr;
@ -28,7 +28,8 @@ int pcurs;
/* rdata */
/** Maps from objcurs.cel frame number to frame width. */
const int InvItemWidth[180] = {
const int InvItemWidth[] = {
// clang-format off
// Cursors
0, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 23,
// Items
@ -48,11 +49,13 @@ const int InvItemWidth[180] = {
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28
2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28, 2 * 28,
// clang-format on
};
/** Maps from objcurs.cel frame number to frame height. */
const int InvItemHeight[180] = {
const int InvItemHeight[] = {
// clang-format off
// Cursors
0, 29, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35,
// Items
@ -72,12 +75,13 @@ const int InvItemHeight[180] = {
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28
3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28, 3 * 28,
// clang-format on
};
void InitCursor()
{
/// ASSERT: assert(! pCursCels);
assert(!pCursCels);
pCursCels = LoadFileInMem("Data\\Inv\\Objcurs.CEL", NULL);
ClearCursor();
}
@ -186,17 +190,16 @@ void CheckCursMove()
sx = MouseX;
sy = MouseY;
if (PANELS_COVER) {
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;
}
@ -238,8 +241,8 @@ void CheckCursMove()
sy = SCREEN_HEIGHT;
}
tx = sx >> 6; // sx / 64
ty = sy >> 5; // sy / 32
tx = sx >> 6; // sx / 64
ty = sy >> 5; // sy / 32
px = sx & 0x3F; // sx % 64
py = sy & 0x1F; // sx % 32
mx = ViewX + tx + ty - (zoomflag ? (SCREEN_WIDTH / 64) : (SCREEN_WIDTH / 2 / 64));
@ -495,7 +498,7 @@ void CheckCursMove()
}
if (dFlags[mx][my] & BFLAG_DEAD_PLAYER) {
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].WorldX == mx && plr[i].WorldY == my && i != myplr) {
if (plr[i]._px == mx && plr[i]._py == my && i != myplr) {
cursmx = mx;
cursmy = my;
pcursplr = i;
@ -507,7 +510,7 @@ void CheckCursMove()
for (yy = -1; yy < 2; yy++) {
if (dFlags[mx + xx][my + yy] & BFLAG_DEAD_PLAYER) {
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].WorldX == mx + xx && plr[i].WorldY == my + yy && i != myplr) {
if (plr[i]._px == mx + xx && plr[i]._py == my + yy && i != myplr) {
cursmx = mx + xx;
cursmy = my + yy;
pcursplr = i;

8
Source/cursor.h

@ -6,11 +6,11 @@
#ifndef __CURSOR_H__
#define __CURSOR_H__
extern int cursH;
extern int icursH28;
extern int cursW;
extern int cursH;
extern int pcursmonst;
extern int icursW28;
extern int icursH28;
extern BYTE *pCursCels;
extern int icursH;
extern char pcursinvitem;
@ -34,7 +34,7 @@ void CheckRportal();
void CheckCursMove();
/* rdata */
extern const int InvItemWidth[180];
extern const int InvItemHeight[180];
extern const int InvItemWidth[];
extern const int InvItemHeight[];
#endif /* __CURSOR_H__ */

2
Source/debug.cpp

@ -161,7 +161,7 @@ void PrintDebugPlayer(BOOL bNextPlayer)
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " Lvl = %i : Change = %i", plr[dbgplr].plrlevel, plr[dbgplr]._pLvlChanging);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", plr[dbgplr].WorldX, plr[dbgplr].WorldY, plr[dbgplr]._ptargx, plr[dbgplr]._ptargy);
sprintf(dstr, " x = %i, y = %i : tx = %i, ty = %i", plr[dbgplr]._px, plr[dbgplr]._py, plr[dbgplr]._ptargx, plr[dbgplr]._ptargy);
NetSendCmdString(1 << myplr, dstr);
sprintf(dstr, " mode = %i : daction = %i : walk[0] = %i", plr[dbgplr]._pmode, plr[dbgplr].destAction, plr[dbgplr].walkpath[0]);
NetSendCmdString(1 << myplr, dstr);

110
Source/diablo.cpp

@ -11,19 +11,19 @@
DEVILUTION_BEGIN_NAMESPACE
SDL_Window *ghMainWnd;
DWORD glSeedTbl[NUMLEVELS];
int gnLevelTypeTbl[NUMLEVELS];
int glEndSeed[NUMLEVELS];
int glMid1Seed[NUMLEVELS];
int glMid2Seed[NUMLEVELS];
int gnLevelTypeTbl[NUMLEVELS];
int MouseY;
int glMid3Seed[NUMLEVELS];
int MouseX;
int MouseY;
BOOL gbGameLoopStartup;
DWORD glSeedTbl[NUMLEVELS];
BOOL gbRunGame;
int glMid3Seed[NUMLEVELS];
BOOL gbRunGameResult;
BOOL zoomflag;
BOOL gbProcessPlayers;
int glEndSeed[NUMLEVELS];
BOOL gbLoadGame;
int DebugMonsters[10];
BOOLEAN cineflag;
@ -126,11 +126,11 @@ BOOL StartGame(BOOL bNewGame, BOOL bSinglePlayer)
InitPortals();
InitDungMsgs(myplr);
}
if (!gbValidSaveFile || !gbLoadGame)
if (!gbValidSaveFile || !gbLoadGame) {
uMsg = WM_DIABNEWGAME;
else
} else {
uMsg = WM_DIABLOADGAME;
}
run_game_loop(uMsg);
NetClose();
pfile_create_player_description(0, 0);
@ -155,7 +155,7 @@ static bool ProcessInput()
return false;
}
if (!gmenu_is_active() && sgnTimeoutCurs == 0) {
if (!gmenu_is_active() && sgnTimeoutCurs == CURSOR_NONE) {
#ifndef USE_SDL1
finish_simulated_mouse_clicks(MouseX, MouseY);
#endif
@ -219,7 +219,7 @@ void run_game_loop(unsigned int uMsg)
pfile_flush_W();
PaletteFadeOut(8);
SetCursor_(CURSOR_NONE);
NewCursor(CURSOR_NONE);
ClearScreenBuffer();
force_redraw = 255;
scrollrt_draw_game_screen(TRUE);
@ -323,9 +323,9 @@ void diablo_deinit()
if (was_archives_init)
init_cleanup();
if (was_window_init)
dx_cleanup(); // Cleanup SDL surfaces stuff, so we have to do it before SDL_Quit().
dx_cleanup(); // Cleanup SDL surfaces stuff, so we have to do it before SDL_Quit().
if (was_fonts_init)
FontsCleanup();
FontsCleanup();
if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC))
SDL_Quit();
}
@ -394,25 +394,25 @@ void diablo_parse_flags(int argc, char **argv)
basePath += '/';
#endif
} else if (strcasecmp("-n", argv[i]) == 0) {
showintrodebug = 0;
showintrodebug = FALSE;
} else if (strcasecmp("-f", argv[i]) == 0) {
EnableFrameCount();
} else if (strcasecmp("-x", argv[i]) == 0) {
fullscreen = FALSE;
#ifdef _DEBUG
} else if (strcasecmp("-^", argv[i]) == 0) {
debug_mode_key_inverted_v = 1;
debug_mode_key_inverted_v = TRUE;
} else if (strcasecmp("-$", argv[i]) == 0) {
debug_mode_dollar_sign = 1;
/*
debug_mode_dollar_sign = TRUE;
/*
} else if (strcasecmp("-b", argv[i]) == 0) {
debug_mode_key_b = 1;
*/
} else if (strcasecmp("-d", argv[i]) == 0) {
debug_mode_key_d = 1;
debug_mode_key_d = TRUE;
} else if (strcasecmp("-i", argv[i]) == 0) {
debug_mode_key_i = 1;
/*
debug_mode_key_i = TRUE;
/*
} else if (strcasecmp("-j", argv[i]) == 0) {
debug_mode_key_J_trigger = argv[++i];
*/
@ -430,7 +430,7 @@ void diablo_parse_flags(int argc, char **argv)
} else if (strcasecmp("-r", argv[i]) == 0) {
setseed = SDL_atoi(argv[++i]);
} else if (strcasecmp("-s", argv[i]) == 0) {
debug_mode_key_s = 1;
debug_mode_key_s = TRUE;
} else if (strcasecmp("-t", argv[i]) == 0) {
leveldebug = TRUE;
setlevel = TRUE;
@ -438,7 +438,7 @@ void diablo_parse_flags(int argc, char **argv)
} else if (strcasecmp("-v", argv[i]) == 0) {
visiondebug = TRUE;
} else if (strcasecmp("-w", argv[i]) == 0) {
debug_mode_key_w = 1;
debug_mode_key_w = TRUE;
#endif
} else {
printf("unrecognized option '%s'\n", argv[i]);
@ -645,7 +645,7 @@ LRESULT 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) {
@ -653,7 +653,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 || MouseX < PANEL_LEFT || MouseX > PANEL_LEFT + PANEL_WIDTH) {
if (!gmenu_is_active() && !TryIconCurs()) {
@ -672,10 +672,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);
@ -686,7 +686,7 @@ BOOL LeftMouseDown(int wParam)
CheckInvScrn();
DoPanBtn();
if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM)
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
}
}
@ -698,7 +698,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)
@ -708,7 +708,7 @@ BOOL LeftMouseCmd(BOOL bShift)
if (pcursitem == -1 && pcursmonst == -1 && pcursplr == -1)
return TRUE;
} else {
bNear = abs(plr[myplr].WorldX - cursmx) < 2 && abs(plr[myplr].WorldY - cursmy) < 2;
bNear = abs(plr[myplr]._px - cursmx) < 2 && abs(plr[myplr]._py - cursmy) < 2;
if (pcursitem != -1 && pcurs == CURSOR_HAND && !bShift) {
NetSendCmdLocParam1(TRUE, invflag ? CMD_GOTOGETITEM : CMD_GOTOAGETITEM, cursmx, cursmy, pcursitem);
} else if (pcursobj != -1 && (!bShift || bNear && object[pcursobj]._oBreak == 1)) {
@ -764,21 +764,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;
} else if (pcurs == CURSOR_TELEPORT) {
@ -789,10 +789,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;
}
@ -809,7 +809,7 @@ void LeftMouseUp()
ReleaseChrBtns();
if (lvlbtndown)
ReleaseLvlBtn();
if (stextflag)
if (stextflag != STORE_NONE)
ReleaseStoreBtn();
}
@ -818,7 +818,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
@ -829,7 +829,7 @@ void RightMouseDown()
if (pcursinvitem == -1 || !UseInvItem(myplr, pcursinvitem))
CheckPlrSpell();
} else if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) {
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
}
}
@ -852,7 +852,7 @@ void diablo_hotkey_msg(DWORD dwMsg)
return;
}
/// ASSERT: assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
assert(dwMsg < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]));
if (!getIniValue("NetMsg", spszMsgHotKeyTbl[dwMsg], szMsg, MAX_SEND_STR_LEN)) {
snprintf(szMsg, MAX_SEND_STR_LEN, "%s", spszMsgTbl[dwMsg]);
setIniValue("NetMsg", spszMsgHotKeyTbl[dwMsg], szMsg);
@ -874,7 +874,7 @@ void PressKey(int vkey)
}
if (deathflag) {
if (sgnTimeoutCurs != 0) {
if (sgnTimeoutCurs != CURSOR_NONE) {
return;
}
if (vkey == VK_F9) {
@ -904,7 +904,7 @@ void PressKey(int vkey)
return;
}
if (sgnTimeoutCurs != 0 || dropGoldFlag) {
if (sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag) {
return;
}
if (vkey == VK_PAUSE) {
@ -928,7 +928,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);
@ -1091,7 +1091,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') {
@ -1121,7 +1121,7 @@ void PressChar(int vkey)
return;
case 'I':
case 'i':
if (!stextflag) {
if (stextflag == STORE_NONE) {
sbookflag = FALSE;
invflag = !invflag;
if (!invflag || chrflag) {
@ -1137,7 +1137,7 @@ void PressChar(int vkey)
return;
case 'C':
case 'c':
if (!stextflag) {
if (stextflag == STORE_NONE) {
questlog = FALSE;
chrflag = !chrflag;
if (!chrflag || invflag) {
@ -1153,7 +1153,7 @@ void PressChar(int vkey)
return;
case 'Q':
case 'q':
if (!stextflag) {
if (stextflag == STORE_NONE) {
chrflag = FALSE;
if (!questlog) {
StartQuestlog();
@ -1168,7 +1168,7 @@ void PressChar(int vkey)
return;
case 'S':
case 's':
if (!stextflag) {
if (stextflag == STORE_NONE) {
invflag = FALSE;
if (!spselflag) {
DoSpeedBook();
@ -1180,7 +1180,7 @@ void PressChar(int vkey)
return;
case 'B':
case 'b':
if (!stextflag) {
if (stextflag == STORE_NONE) {
invflag = FALSE;
sbookflag = !sbookflag;
}
@ -1328,7 +1328,7 @@ void PressChar(int vkey)
case 'T':
case 't':
if (debug_mode_key_inverted_v) {
sprintf(tempstr, "PX = %i PY = %i", plr[myplr].WorldX, plr[myplr].WorldY);
sprintf(tempstr, "PX = %i PY = %i", plr[myplr]._px, plr[myplr]._py);
NetSendCmdString(1 << myplr, tempstr);
sprintf(tempstr, "CX = %i CY = %i DP = %i", cursmx, cursmy, dungeon[cursmx][cursmy]);
NetSendCmdString(1 << myplr, tempstr);
@ -1350,7 +1350,7 @@ void PressChar(int vkey)
void LoadLvlGFX()
{
/// ASSERT: assert(! pDungeonCels);
assert(!pDungeonCels);
switch (leveltype) {
case DTYPE_TOWN:
@ -1453,7 +1453,7 @@ void LoadGameLevel(BOOL firstflag, int lvldir)
glSeedTbl[currlevel] = setseed;
music_stop();
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
SetRndSeed(glSeedTbl[currlevel]);
IncProgress();
MakeLightTable();
@ -1636,11 +1636,11 @@ void LoadGameLevel(BOOL firstflag, int lvldir)
if (plr[i].plractive && plr[i].plrlevel == currlevel && (!plr[i]._pLvlChanging || i == myplr)) {
if (plr[i]._pHitPoints > 0) {
if (gbMaxPlayers == 1)
dPlayer[plr[i].WorldX][plr[i].WorldY] = i + 1;
dPlayer[plr[i]._px][plr[i]._py] = i + 1;
else
SyncInitPlrPos(i);
} else {
dFlags[plr[i].WorldX][plr[i].WorldY] |= BFLAG_DEAD_PLAYER;
dFlags[plr[i]._px][plr[i]._py] |= BFLAG_DEAD_PLAYER;
}
}
}
@ -1739,13 +1739,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) {
SetCursor_(sgnTimeoutCurs);
sgnTimeoutCurs = 0;
} else if (sgnTimeoutCurs != CURSOR_NONE) {
NewCursor(sgnTimeoutCurs);
sgnTimeoutCurs = CURSOR_NONE;
ClearPanel();
force_redraw = 255;
}

12
Source/diablo.h

@ -7,26 +7,26 @@
#define __DIABLO_H__
extern SDL_Window *ghMainWnd;
extern DWORD glSeedTbl[NUMLEVELS];
extern int gnLevelTypeTbl[NUMLEVELS];
extern int glEndSeed[NUMLEVELS];
extern int glMid1Seed[NUMLEVELS];
extern int glMid2Seed[NUMLEVELS];
extern int gnLevelTypeTbl[NUMLEVELS];
extern int MouseY;
extern int glMid3Seed[NUMLEVELS];
extern int MouseX;
extern int MouseY;
extern BOOL gbGameLoopStartup;
extern DWORD glSeedTbl[NUMLEVELS];
extern BOOL gbRunGame;
extern int glMid3Seed[NUMLEVELS];
extern BOOL gbRunGameResult;
extern BOOL zoomflag;
extern BOOL gbProcessPlayers;
extern int glEndSeed[NUMLEVELS];
extern BOOL gbLoadGame;
extern HINSTANCE ghInst;
extern int DebugMonsters[10];
extern BOOLEAN cineflag;
extern int force_redraw;
extern BOOL visiondebug;
/* These are defined in fonts.h */
/* These are defined in fonts.h */
extern BOOL was_fonts_init;
extern void FontsCleanup();
/** unused */

5
Source/drlg_l2.cpp

@ -12,8 +12,8 @@
DEVILUTION_BEGIN_NAMESPACE
int nSx1;
int nSx2;
int nSy1;
int nSx2;
int nSy2;
int nRoomCnt;
BYTE predungeon[DMAXX][DMAXY];
@ -1490,8 +1490,7 @@ static void DRLG_L2Pass3()
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2)
{
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;

2
Source/drlg_l2.h

@ -7,8 +7,8 @@
#define __DRLG_L2_H__
extern int nSx1;
extern int nSx2;
extern int nSy1;
extern int nSx2;
extern int nSy2;
extern int nRoomCnt;
extern BYTE predungeon[DMAXX][DMAXY];

17
Source/drlg_l4.cpp

@ -9,10 +9,10 @@ DEVILUTION_BEGIN_NAMESPACE
int diabquad1x;
int diabquad1y;
int diabquad3x;
int diabquad3y;
int diabquad2x;
int diabquad2y;
int diabquad3x;
int diabquad3y;
int diabquad4x;
int diabquad4y;
#ifndef SPAWN
@ -20,8 +20,8 @@ BOOL hallok[20];
int l4holdx;
int l4holdy;
int SP4x1;
int SP4x2;
int SP4y1;
int SP4x2;
int SP4y2;
BYTE L4dungeon[80][80];
BYTE dung[20][20];
@ -1144,8 +1144,8 @@ static void uShape()
}
if (dung[i][j] == 1) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20 (fixed)
if (i + 1 < 20 && j + 1 < 20 &&
dung[i][j + 1] == 1 && dung[i + 1][j + 1] == 0) {
if (i + 1 < 20 && j + 1 < 20
&& dung[i][j + 1] == 1 && dung[i + 1][j + 1] == 0) {
hallok[j] = TRUE;
} else {
hallok[j] = FALSE;
@ -1182,8 +1182,8 @@ static void uShape()
}
if (dung[i][j] == 1) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20 (fixed)
if (i + 1 < 20 && j + 1 < 20 &&
dung[i + 1][j] == 1 && dung[i + 1][j + 1] == 0) {
if (i + 1 < 20 && j + 1 < 20
&& dung[i + 1][j] == 1 && dung[i + 1][j + 1] == 0) {
hallok[i] = TRUE;
} else {
hallok[i] = FALSE;
@ -1899,8 +1899,7 @@ static void DRLG_L4Pass3()
v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
for (j = 0; j < MAXDUNY; j += 2)
{
for (j = 0; j < MAXDUNY; j += 2) {
for (i = 0; i < MAXDUNX; i += 2) {
dPiece[i][j] = v1;
dPiece[i + 1][j] = v2;

6
Source/drlg_l4.h

@ -8,18 +8,18 @@
extern int diabquad1x;
extern int diabquad1y;
extern int diabquad3x;
extern int diabquad3y;
extern int diabquad2x;
extern int diabquad2y;
extern int diabquad3x;
extern int diabquad3y;
extern int diabquad4x;
extern int diabquad4y;
extern BOOL hallok[20];
extern int l4holdx;
extern int l4holdy;
extern int SP4x1;
extern int SP4x2;
extern int SP4y1;
extern int SP4x2;
extern int SP4y2;
extern BYTE L4dungeon[80][80];
extern BYTE dung[20][20];

2
Source/dthread.cpp

@ -64,7 +64,7 @@ void dthread_start()
}
sghWorkToDoEvent = StartEvent();
if (!sghWorkToDoEvent) {
if (sghWorkToDoEvent == NULL) {
error_buf = TraceLastError();
app_fatal("dthread:1\n%s", error_buf);
}

1748
Source/effects.cpp

File diff suppressed because it is too large Load Diff

32
Source/encrypt.cpp

@ -8,18 +8,16 @@
DEVILUTION_BEGIN_NAMESPACE
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++) {
DWORD t = SwapLE32(*castBlock);
seed += hashtable[0x400 + (key & 0xFF)];
seed += hashtable[4][(key & 0xFF)];
t ^= seed + key;
*castBlock = t;
seed += t + (seed << 5) + 3;
@ -28,16 +26,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++) {
DWORD t = ch = *castBlock;
seed += hashtable[0x400 + (key & 0xFF)];
seed += hashtable[4][(key & 0xFF)];
t ^= seed + key;
*castBlock = SwapLE32(t);
seed += ch + (seed << 5) + 3;
@ -56,7 +52,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;
@ -74,24 +70,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[j][i] = 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);
@ -145,14 +140,13 @@ void 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 PkwareBufferRead(char *buf, unsigned int *size, void *param);
void 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__ */

12
Source/engine.cpp

@ -165,7 +165,7 @@ void CelDrawLightRed(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -460,7 +460,7 @@ void CelDrawLightRedSafe(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, c
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;
@ -667,7 +667,7 @@ void DrawLine(int x0, int y0, int x1, int y1, BYTE col)
sx = x0;
sy = y0;
for(i = 0; i <= steps; i++, sx += ix, sy += iy) {
for (i = 0; i <= steps; i++, sx += ix, sy += iy) {
ENG_set_pixel(sx, sy, col);
}
}
@ -772,7 +772,7 @@ BYTE *DiabloAllocPtr(DWORD dwBytes)
if (buf == NULL) {
char *text = "System memory exhausted.\n"
"Make sure you have at least 64MB of free system memory before running the game";
"Make sure you have at least 64MB of free system memory before running the game";
ERR_DLG("Out of Memory Error", text);
}
@ -827,7 +827,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;
@ -1134,7 +1134,7 @@ void Cl2DrawLightTbl(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth, char
idx = light4flag ? 1024 : 4096;
if (light == 2)
idx += 256;
idx += 256; // gray colors
if (light >= 4)
idx += (light - 1) << 8;

4
Source/engine.h

@ -42,7 +42,7 @@ inline BYTE *CelGetFrame(BYTE *pCelBuff, int nCel, int *nDataSize)
DWORD nCellStart;
nCellStart = LOAD_LE32(&pCelBuff[nCel * 4]);
*nDataSize = LOAD_LE32(&pCelBuff[(nCel+1) * 4]) - nCellStart;
*nDataSize = LOAD_LE32(&pCelBuff[(nCel + 1) * 4]) - nCellStart;
return pCelBuff + nCellStart;
}
@ -82,7 +82,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);
void Cl2DrawOutline(char col, int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth);

6
Source/error.cpp

@ -13,7 +13,7 @@ char msgflag;
char msgcnt;
/** Maps from error_id to error message. */
char *MsgStrings[44] = {
char *MsgStrings[] = {
"",
"No automap available in town",
"No multiplayer functions in demo",
@ -57,7 +57,7 @@ char *MsgStrings[44] = {
"You must be at least level 8 to use this.",
"You must be at least level 13 to use this.",
"You must be at least level 17 to use this.",
"Arcane knowledge gained!"
"Arcane knowledge gained!",
};
void InitDiabloMsg(char e)
@ -113,7 +113,7 @@ void DrawDiabloMsg()
sy += 12;
}
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
trans_rect(PANEL_LEFT + 104, DIALOG_TOP - 8, 432, 54);

2
Source/error.h

@ -16,6 +16,6 @@ void ClrDiabloMsg();
void DrawDiabloMsg();
/* data */
extern char *MsgStrings[44];
extern char *MsgStrings[];
#endif /* __ERROR_H__ */

97
Source/gamemenu.cpp

@ -8,59 +8,59 @@
DEVILUTION_BEGIN_NAMESPACE
/** Contains the game menu items of the single player menu. */
TMenuItem sgSingleMenu[6] = {
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 }
// 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] = {
TMenuItem sgMultiMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
// 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 }
{ GMENU_ENABLED, NULL, NULL },
// clang-format on
};
TMenuItem sgOptionsMenu[6] = {
TMenuItem sgOptionsMenu[] = {
// clang-format off
// dwFlags, pszStr, fnMenu
// 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 },
{ GMENU_ENABLED , NULL, &gamemenu_color_cycling },
{ GMENU_ENABLED , "Previous Menu", &gamemenu_previous },
{ GMENU_ENABLED , NULL, NULL }
{ 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",
};
/** Specifies the menu names for colour cycling disabled and enabled. */
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();
}
@ -74,7 +74,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)
@ -84,7 +84,7 @@ void gamemenu_update_multi(TMenuItem *pMenuItems)
void gamemenu_off()
{
gmenu_set_items(0, NULL);
gmenu_set_items(NULL, NULL);
}
void gamemenu_handle_previous()
@ -219,42 +219,31 @@ void gamemenu_get_gamma()
void gamemenu_music_volume(BOOL bActivate)
{
int volume;
if (bActivate) {
if (gbMusicOn) {
gbMusicOn = FALSE;
music_stop();
sound_get_or_set_music_volume(VOLUME_MIN);
gamemenu_get_music();
return;
} else {
gbMusicOn = TRUE;
sound_get_or_set_music_volume(VOLUME_MAX);
music_start(leveltype);
}
gbMusicOn = TRUE;
sound_get_or_set_music_volume(VOLUME_MAX);
music_start(leveltype);
gamemenu_get_music();
return;
}
volume = gamemenu_slider_music_sound(sgOptionsMenu);
sound_get_or_set_music_volume(volume);
if (volume == VOLUME_MIN) {
} else {
volume = gamemenu_slider_music_sound(&sgOptionsMenu[0]);
sound_get_or_set_music_volume(volume);
if (gbMusicOn) {
gbMusicOn = FALSE;
music_stop();
if (volume == VOLUME_MIN) {
if (gbMusicOn) {
gbMusicOn = FALSE;
music_stop();
}
} else if (!gbMusicOn) {
gbMusicOn = TRUE;
music_start(leveltype);
}
gamemenu_get_music();
return;
}
if (gbMusicOn) {
gamemenu_get_music();
return;
}
gbMusicOn = TRUE;
music_start(leveltype);
gamemenu_get_music();
}

115
Source/gendung.cpp

@ -7,76 +7,85 @@
DEVILUTION_BEGIN_NAMESPACE
WORD level_frame_types[MAXTILES];
int themeCount;
/**
* List of transparent dPieces
*/
BOOLEAN nTransTable[2049];
//int dword_52D204;
int dMonster[MAXDUNX][MAXDUNY];
BYTE dungeon[DMAXX][DMAXY];
char dObject[MAXDUNX][MAXDUNY];
BYTE pdungeon[DMAXX][DMAXY];
char dDead[MAXDUNX][MAXDUNY];
char dPreLight[MAXDUNX][MAXDUNY];
char TransVal;
int MicroTileLen;
char dflags[DMAXX][DMAXY];
int dPiece[MAXDUNX][MAXDUNY];
char dLight[MAXDUNX][MAXDUNY];
int setpc_x;
int setpc_y;
int setpc_w;
int setpc_h;
BYTE *pSetPiece;
BOOL setloadflag;
BYTE *pSpecialCels;
BYTE *pMegaTiles;
BYTE *pLevelPieces;
int gnDifficulty;
BYTE *pDungeonCels;
BYTE *pSpeedCels;
int SpeedFrameTbl[128][16];
/**
* List of transparancy masks to use for dPieces
*/
char block_lvid[2049];
//char byte_5B78EB;
char dTransVal[MAXDUNX][MAXDUNY];
BOOLEAN nTrapTable[2049];
BYTE leveltype;
BYTE currlevel;
BOOLEAN TransList[256];
char block_lvid[MAXTILES + 1];
int level_frame_count[MAXTILES];
int tile_defs[MAXTILES];
WORD level_frame_types[MAXTILES];
int level_frame_sizes[MAXTILES];
int nlevel_frames;
/**
* List of light blocking dPieces
*/
BOOLEAN nBlockTable[MAXTILES + 1];
/**
* List of path blocking dPieces
*/
BOOLEAN nSolidTable[2049];
ScrollStruct ScrollInfo;
BYTE *pDungeonCels;
THEME_LOC themeLoc[MAXTHEMES];
char dPlayer[MAXDUNX][MAXDUNY];
char dSpecial[MAXDUNX][MAXDUNY];
BOOLEAN nSolidTable[MAXTILES + 1];
/**
* List of light blocking dPieces
* List of transparent dPieces
*/
BOOLEAN nBlockTable[2049];
BYTE *pSpecialCels;
char dFlags[MAXDUNX][MAXDUNY];
char dItem[MAXDUNX][MAXDUNY];
BYTE setlvlnum;
BOOLEAN nTransTable[MAXTILES + 1];
/**
* List of missile blocking dPieces
*/
BOOLEAN nMissileTable[2049];
BYTE *pSetPiece;
char setlvltype;
BOOLEAN setlevel;
int LvlViewY;
int LvlViewX;
BOOLEAN nMissileTable[MAXTILES + 1];
BOOLEAN nTrapTable[MAXTILES + 1];
int dminx;
int dminy;
int dmaxx;
int dmaxy;
int setpc_h;
int setpc_w;
int setpc_x;
int gnDifficulty;
BYTE leveltype;
BYTE currlevel;
BOOLEAN setlevel;
BYTE setlvlnum;
char setlvltype;
int ViewX;
int ViewY;
int setpc_y;
char dMissile[MAXDUNX][MAXDUNY];
int dminx;
int dminy;
int ViewBX;
int ViewBY;
int ViewDX;
int ViewDY;
ScrollStruct ScrollInfo;
int LvlViewX;
int LvlViewY;
int MicroTileLen;
char TransVal;
BOOLEAN TransList[256];
int dPiece[MAXDUNX][MAXDUNY];
MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY];
MICROS dpiece_defs_map_1[MAXDUNX * MAXDUNY];
char dTransVal[MAXDUNX][MAXDUNY];
char dLight[MAXDUNX][MAXDUNY];
char dPreLight[MAXDUNX][MAXDUNY];
char dFlags[MAXDUNX][MAXDUNY];
char dPlayer[MAXDUNX][MAXDUNY];
int dMonster[MAXDUNX][MAXDUNY];
char dDead[MAXDUNX][MAXDUNY];
char dObject[MAXDUNX][MAXDUNY];
char dItem[MAXDUNX][MAXDUNY];
char dMissile[MAXDUNX][MAXDUNY];
char dSpecial[MAXDUNX][MAXDUNY];
int themeCount;
THEME_LOC themeLoc[MAXTHEMES];
void FillSolidBlockTbls()
{
@ -152,7 +161,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 && leveltype != DTYPE_TOWN)
pPiece = (WORD *)&pLevelPieces[20 * lv];
@ -214,7 +223,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++;
@ -228,7 +237,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++;
@ -261,7 +270,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;
}
}
}
@ -278,7 +287,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;
}
}
}

91
Source/gendung.h

@ -6,65 +6,70 @@
#ifndef __GENDUNG_H__
#define __GENDUNG_H__
extern WORD level_frame_types[MAXTILES];
extern int themeCount;
extern BOOLEAN nTransTable[2049];
//int dword_52D204;
extern int dMonster[MAXDUNX][MAXDUNY];
extern BYTE dungeon[DMAXX][DMAXY];
extern char dObject[MAXDUNX][MAXDUNY];
extern BYTE pdungeon[DMAXX][DMAXY];
extern char dDead[MAXDUNX][MAXDUNY];
extern char dPreLight[MAXDUNX][MAXDUNY];
extern char TransVal;
extern int MicroTileLen;
extern char dflags[DMAXX][DMAXY];
extern int dPiece[MAXDUNX][MAXDUNY];
extern char dLight[MAXDUNX][MAXDUNY];
extern int setpc_x;
extern int setpc_y;
extern int setpc_w;
extern int setpc_h;
extern BYTE *pSetPiece;
extern BOOL setloadflag;
extern BYTE *pSpecialCels;
extern BYTE *pMegaTiles;
extern BYTE *pLevelPieces;
extern BYTE *pDungeonCels;
extern BYTE *pSpeedCels;
extern int SpeedFrameTbl[128][16];
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[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;
extern int dmaxy;
extern int gnDifficulty;
extern char block_lvid[2049];
//char byte_5B78EB;
extern char dTransVal[MAXDUNX][MAXDUNY];
extern BOOLEAN nTrapTable[2049];
extern BYTE leveltype;
extern BYTE currlevel;
extern BOOLEAN TransList[256];
extern BOOLEAN nSolidTable[2049];
extern ScrollStruct ScrollInfo;
extern BYTE *pDungeonCels;
extern THEME_LOC themeLoc[MAXTHEMES];
extern char dPlayer[MAXDUNX][MAXDUNY];
extern BOOLEAN setlevel;
extern BYTE setlvlnum;
extern char setlvltype;
extern int ViewX;
extern int ViewY;
extern int ViewBX;
extern int ViewBY;
extern int ViewDX;
extern int ViewDY;
extern char dSpecial[MAXDUNX][MAXDUNY];
extern BOOLEAN nBlockTable[2049];
extern BYTE *pSpecialCels;
extern ScrollStruct ScrollInfo;
extern int LvlViewX;
extern int LvlViewY;
extern int MicroTileLen;
extern char TransVal;
extern BOOLEAN TransList[256];
extern int dPiece[MAXDUNX][MAXDUNY];
extern MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY];
extern MICROS dpiece_defs_map_1[MAXDUNX * MAXDUNY];
extern char dTransVal[MAXDUNX][MAXDUNY];
extern char dLight[MAXDUNX][MAXDUNY];
extern char dPreLight[MAXDUNX][MAXDUNY];
extern char dFlags[MAXDUNX][MAXDUNY];
extern char dPlayer[MAXDUNX][MAXDUNY];
extern int dMonster[MAXDUNX][MAXDUNY];
extern char dDead[MAXDUNX][MAXDUNY];
extern char dObject[MAXDUNX][MAXDUNY];
extern char dItem[MAXDUNX][MAXDUNY];
extern BYTE setlvlnum;
extern BOOLEAN nMissileTable[2049];
extern BYTE *pSetPiece;
extern char setlvltype;
extern BOOLEAN setlevel;
extern int LvlViewY;
extern int LvlViewX;
extern int dmaxx;
extern int dmaxy;
extern int setpc_h;
extern int setpc_w;
extern int setpc_x;
extern int ViewX;
extern int ViewY;
extern int setpc_y;
extern char dMissile[MAXDUNX][MAXDUNY];
extern int dminx;
extern int dminy;
extern MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY];
extern char dSpecial[MAXDUNX][MAXDUNY];
extern int themeCount;
extern THEME_LOC themeLoc[MAXTHEMES];
void FillSolidBlockTbls();
void SetDungeonMicros();

16
Source/gmenu.cpp

@ -21,7 +21,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,
@ -34,11 +34,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,
@ -64,7 +64,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, NULL);
x += lfontkern[c] + 2;
}
@ -83,8 +83,8 @@ void gmenu_init_menu()
{
PentSpin_frame = 1;
sgpCurrentMenu = NULL;
sgpCurrItem = 0;
dword_63447C = 0;
sgpCurrItem = NULL;
dword_63447C = NULL;
sgCurrentMenuIdx = 0;
mouseNavigation = FALSE;
sgpLogo = LoadFileInMem("Data\\Diabsmal.CEL", NULL);
@ -248,7 +248,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;
@ -386,7 +386,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__ */

2
Source/help.cpp

@ -460,7 +460,7 @@ void DrawHelp()
PrintSString(0, 2, TRUE, "Diablo Help", COL_GOLD, 0);
DrawSLine(5);
s = gszHelpText;
s = &gszHelpText[0];
for (i = 0; i < help_select_line; i++) {
c = 0;

24
Source/interfac.cpp

@ -7,7 +7,7 @@
DEVILUTION_BEGIN_NAMESPACE
void *sgpBackCel;
BYTE *sgpBackCel;
int sgdwProgress;
int progress_id;
@ -44,7 +44,7 @@ void DrawCutscene()
DWORD i;
lock_buf(1);
CelDraw(PANEL_X, 480 + SCREEN_Y - 1, (BYTE *)sgpBackCel, 1, 640);
CelDraw(PANEL_X, 480 + SCREEN_Y - 1, sgpBackCel, 1, 640);
for (i = 0; i < sgdwProgress; i++) {
DrawProgress(
@ -77,7 +77,7 @@ void ShowProgress(unsigned int uMsg)
gbSomebodyWonGameKludge = FALSE;
plrmsg_delay(TRUE);
/// ASSERT: assert(ghMainWnd);
assert(ghMainWnd);
saveProc = SetWindowProc(DisableInputWndProc);
interface_msg_pump();
@ -119,7 +119,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel++;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 0);
IncProgress();
@ -135,7 +135,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel--;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 1);
IncProgress();
@ -196,7 +196,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 6);
IncProgress();
@ -212,7 +212,7 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 7);
IncProgress();
@ -228,22 +228,22 @@ void ShowProgress(unsigned int uMsg)
FreeGameMem();
currlevel = plr[myplr].plrlevel;
leveltype = gnLevelTypeTbl[currlevel];
/// ASSERT: assert(plr[myplr].plrlevel == currlevel);
assert(plr[myplr].plrlevel == currlevel);
IncProgress();
LoadGameLevel(FALSE, 0);
IncProgress();
break;
}
/// ASSERT: assert(ghMainWnd);
assert(ghMainWnd);
PaletteFadeOut(8);
FreeInterface();
saveProc = SetWindowProc(saveProc);
/// ASSERT: assert(saveProc == DisableInputWndProc);
assert(saveProc == DisableInputWndProc);
NetSendCmdLocParam1(TRUE, CMD_PLAYER_JOINLEVEL, plr[myplr].WorldX, plr[myplr].WorldY, plr[myplr].plrlevel);
NetSendCmdLocParam1(TRUE, CMD_PLAYER_JOINLEVEL, plr[myplr]._px, plr[myplr]._py, plr[myplr].plrlevel);
plrmsg_delay(FALSE);
ResetPal();
@ -261,7 +261,7 @@ void FreeInterface()
void InitCutscene(unsigned int uMsg)
{
/// ASSERT: assert(! sgpBackCel);
assert(!sgpBackCel);
switch (uMsg) {
case WM_DIABNEXTLVL:

97
Source/inv.cpp

@ -28,7 +28,7 @@ int sgdwLastTime; // check name
* 65 66 67 68 69 70 71 72
* @see graphics/inv/inventory.png
*/
const InvXY InvRect[73] = {
const InvXY InvRect[] = {
// clang-format off
// X, Y
{ RIGHT_PANEL + 132, 31 }, // helmet
@ -136,7 +136,7 @@ void InvDrawSlotBack(int X, int Y, int W, int H)
{
BYTE *dst;
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
dst = &gpBuffer[X + BUFFER_WIDTH * Y];
@ -290,14 +290,14 @@ void DrawInv()
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND) {
InvDrawSlotBack(RIGHT_PANEL_X + 247, 160 + SCREEN_Y, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
light_table_index = 0;
cel_transparency_active = 1;
cel_transparency_active = TRUE;
pBuff = frame_width == INV_SLOT_SIZE_PX
? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)];
? &gpBuffer[SCREENXY(RIGHT_PANEL_X + 197, SCREEN_Y)]
: &gpBuffer[SCREENXY(RIGHT_PANEL_X + 183, SCREEN_Y)];
CelClippedBlitLightTrans(pBuff, pCursCels, frame, frame_width);
cel_transparency_active = 0;
cel_transparency_active = FALSE;
}
}
if (plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE) {
@ -1203,7 +1203,7 @@ void CheckInvCut(int pnum, int mx, int my)
if (r >= SLOTXY_INV_FIRST && r <= SLOTXY_INV_LAST) {
ig = r - SLOTXY_INV_FIRST;
ii = plr[pnum].InvGrid[ig];
if (ii) {
if (ii != 0) {
iv = ii;
if (ii <= 0) {
iv = -ii;
@ -1378,7 +1378,7 @@ void CheckBookLevel(int pnum)
if (plr[pnum].HoldItem._iMiscId == IMISC_BOOK) {
plr[pnum].HoldItem._iMinMag = spelldata[plr[pnum].HoldItem._iSpell].sMinInt;
slvl = plr[pnum]._pSplLvl[plr[pnum].HoldItem._iSpell];
while (slvl) {
while (slvl != 0) {
plr[pnum].HoldItem._iMinMag += 20 * plr[pnum].HoldItem._iMinMag / 100;
slvl--;
if (plr[pnum].HoldItem._iMinMag + 20 * plr[pnum].HoldItem._iMinMag / 100 > 255) {
@ -1412,7 +1412,7 @@ void CheckQuestItem(int pnum)
quests[Q_ANVIL]._qvar1 = 1;
}
#ifndef SPAWN
if (quests[Q_ANVIL]._qlog == 1) {
if (quests[Q_ANVIL]._qlog == TRUE) {
sfxdelay = 10;
if (plr[myplr]._pClass == PC_WARRIOR) {
sfxdnum = PS_WARR89;
@ -1442,7 +1442,7 @@ void CheckQuestItem(int pnum)
quests[Q_ROCK]._qvar1 = 1;
}
#ifndef SPAWN
if (quests[Q_ROCK]._qlog == 1) {
if (quests[Q_ROCK]._qlog == TRUE) {
sfxdelay = 10;
if (plr[myplr]._pClass == PC_WARRIOR) {
sfxdnum = PS_WARR87;
@ -1478,9 +1478,9 @@ void InvGetItem(int pnum, int ii)
dropGoldValue = 0;
}
if (dItem[item[ii]._ix][item[ii]._iy]) {
if (dItem[item[ii]._ix][item[ii]._iy] != 0) {
if (myplr == pnum && pcurs >= CURSOR_FIRSTITEM)
NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr].WorldX, plr[myplr].WorldY);
NetSendCmdPItem(TRUE, CMD_SYNCPUTITEM, plr[myplr]._px, plr[myplr]._py);
item[ii]._iCreateInfo &= ~0x8000;
plr[pnum].HoldItem = item[ii];
CheckQuestItem(pnum);
@ -1516,8 +1516,9 @@ void AutoGetItem(int pnum, int ii)
dropGoldValue = 0;
}
if (ii != MAXITEMS && !dItem[item[ii]._ix][item[ii]._iy]) {
return;
if (ii != MAXITEMS) {
if (dItem[item[ii]._ix][item[ii]._iy] == 0)
return;
}
item[ii]._iCreateInfo &= 0x7FFF;
@ -1704,7 +1705,7 @@ BOOL CanPut(int x, int y)
if (nSolidTable[dPiece[x][y]])
return FALSE;
if (dObject[x][y]) {
if (dObject[x][y] != 0) {
if (object[dObject[x][y] > 0 ? dObject[x][y] - 1 : -1 - dObject[x][y]]._oSolidFlag)
return FALSE;
}
@ -1739,22 +1740,22 @@ BOOL TryInvPut()
if (numitems >= 127)
return FALSE;
dir = GetDirection(plr[myplr].WorldX, plr[myplr].WorldY, cursmx, cursmy);
if (CanPut(plr[myplr].WorldX + offset_x[dir], plr[myplr].WorldY + offset_y[dir])) {
dir = GetDirection(plr[myplr]._px, plr[myplr]._py, cursmx, cursmy);
if (CanPut(plr[myplr]._px + offset_x[dir], plr[myplr]._py + offset_y[dir])) {
return TRUE;
}
dir = (dir - 1) & 7;
if (CanPut(plr[myplr].WorldX + offset_x[dir], plr[myplr].WorldY + offset_y[dir])) {
if (CanPut(plr[myplr]._px + offset_x[dir], plr[myplr]._py + offset_y[dir])) {
return TRUE;
}
dir = (dir + 2) & 7;
if (CanPut(plr[myplr].WorldX + offset_x[dir], plr[myplr].WorldY + offset_y[dir])) {
if (CanPut(plr[myplr]._px + offset_x[dir], plr[myplr]._py + offset_y[dir])) {
return TRUE;
}
return CanPut(plr[myplr].WorldX, plr[myplr].WorldY);
return CanPut(plr[myplr]._px, plr[myplr]._py);
}
void DrawInvMsg(char *msg)
@ -1784,28 +1785,28 @@ int InvPutItem(int pnum, int x, int y)
SyncGetItem(x, y, plr[pnum].HoldItem.IDidx, plr[pnum].HoldItem._iCreateInfo, plr[pnum].HoldItem._iSeed);
}
d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, x, y);
xx = x - plr[pnum].WorldX;
yy = y - plr[pnum].WorldY;
d = GetDirection(plr[pnum]._px, plr[pnum]._py, x, y);
xx = x - plr[pnum]._px;
yy = y - plr[pnum]._py;
if (abs(xx) > 1 || abs(yy) > 1) {
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
}
if (!CanPut(x, y)) {
d = (d - 1) & 7;
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
if (!CanPut(x, y)) {
d = (d + 2) & 7;
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
if (!CanPut(x, y)) {
done = FALSE;
for (l = 1; l < 50 && !done; l++) {
for (j = -l; j <= l && !done; j++) {
yp = j + plr[pnum].WorldY;
yp = j + plr[pnum]._py;
for (i = -l; i <= l && !done; i++) {
xp = i + plr[pnum].WorldX;
xp = i + plr[pnum]._px;
if (CanPut(xp, yp)) {
done = TRUE;
x = xp;
@ -1833,7 +1834,7 @@ int InvPutItem(int pnum, int x, int y)
item[ii]._iy = y;
RespawnItem(ii, TRUE);
numitems++;
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return ii;
}
@ -1853,28 +1854,28 @@ int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, in
SyncGetItem(x, y, idx, icreateinfo, iseed);
}
d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, x, y);
xx = x - plr[pnum].WorldX;
yy = y - plr[pnum].WorldY;
d = GetDirection(plr[pnum]._px, plr[pnum]._py, x, y);
xx = x - plr[pnum]._px;
yy = y - plr[pnum]._py;
if (abs(xx) > 1 || abs(yy) > 1) {
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
}
if (!CanPut(x, y)) {
d = (d - 1) & 7;
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
if (!CanPut(x, y)) {
d = (d + 2) & 7;
x = plr[pnum].WorldX + offset_x[d];
y = plr[pnum].WorldY + offset_y[d];
x = plr[pnum]._px + offset_x[d];
y = plr[pnum]._py + offset_y[d];
if (!CanPut(x, y)) {
done = FALSE;
for (l = 1; l < 50 && !done; l++) {
for (j = -l; j <= l && !done; j++) {
yp = j + plr[pnum].WorldY;
yp = j + plr[pnum]._py;
for (i = -l; i <= l && !done; i++) {
xp = i + plr[pnum].WorldX;
xp = i + plr[pnum]._px;
if (CanPut(xp, yp)) {
done = TRUE;
x = xp;
@ -1967,7 +1968,7 @@ char CheckInvHLight()
pi = &p->InvBody[rv];
} else if (r >= 25 && r <= 64) {
r = abs(p->InvGrid[r - 25]);
if (!r)
if (r == 0)
return -1;
ii = r - 1;
rv = ii + 7;
@ -2104,7 +2105,7 @@ BOOL UseInvItem(int pnum, int cii)
return TRUE;
if (pcurs != CURSOR_HAND)
return TRUE;
if (stextflag)
if (stextflag != STORE_NONE)
return TRUE;
if (cii <= INVITEM_HAND_RIGHT)
return FALSE;
@ -2209,9 +2210,9 @@ void DoTelekinesis()
NetSendCmdParam1(TRUE, CMD_OPOBJT, pcursobj);
if (pcursitem != -1)
NetSendCmdGItem(TRUE, CMD_REQUESTAGITEM, myplr, myplr, pcursitem);
if (pcursmonst != -1 && !M_Talker(pcursmonst) && !monster[pcursmonst].mtalkmsg)
if (pcursmonst != -1 && !M_Talker(pcursmonst) && monster[pcursmonst].mtalkmsg == 0)
NetSendCmdParam1(TRUE, CMD_KNOCKBACK, pcursmonst);
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
}
int CalculateGold(int pnum)
@ -2237,7 +2238,7 @@ BOOL DropItemBeforeTrig()
{
if (TryInvPut()) {
NetSendCmdPItem(TRUE, CMD_PUTITEM, cursmx, cursmy);
SetCursor_(CURSOR_HAND);
NewCursor(CURSOR_HAND);
return TRUE;
}

2
Source/itemdat.cpp

@ -19,7 +19,7 @@ ItemDataStruct AllItemsList[] = {
{ IDROP_NEVER, ICLASS_WEAPON, ILOC_TWOHAND, ICURS_SHORT_STAFF, 10, UITYPE_NONE, "Short Staff of Charged Bolt", NULL, 1, 25, 2, 4, 0, 0, 0, 20, 0, ISPL_NONE, IMISC_STAFF, SPL_CBOLT, FALSE, 520, 520 },
{ IDROP_NEVER, ICLASS_WEAPON, ILOC_TWOHAND, ICURS_CLEAVER, 2, UITYPE_CLEAVER, "Cleaver", NULL, 10, 10, 4, 24, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_UNIQUE, SPL_NULL, FALSE, 2000, 2000 },
{ IDROP_NEVER, ICLASS_ARMOR, ILOC_HELM, ICURS_THE_UNDEAD_CROWN, 7, UITYPE_SKCROWN, "The Undead Crown", NULL, 0, 50, 0, 0, 15, 15, 0, 0, 0, ISPL_RNDSTEALLIFE, IMISC_UNIQUE, SPL_NULL, FALSE, 10000, 10000 },
{ IDROP_NEVER, ICLASS_MISC, ILOC_RING, ICURS_EMPYREAN_BAND, 12, UITYPE_INFRARING, "Empyrean Band", NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_UNIQUE, SPL_NULL, FALSE, 8000, 8000 },
{ IDROP_NEVER, ICLASS_MISC, ILOC_RING, ICURS_EMPYREAN_BAND, 12, UITYPE_INFRARING, "Empyrean Band", NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_UNIQUE, SPL_NULL, FALSE, 8000, 8000 },
{ IDROP_NEVER, ICLASS_QUEST, ILOC_UNEQUIPABLE, ICURS_MAGIC_ROCK, 0, UITYPE_NONE, "Magic Rock", NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_NONE, SPL_NULL, FALSE, 0, 0 },
{ IDROP_NEVER, ICLASS_MISC, ILOC_AMULET, ICURS_OPTIC_AMULET, 13, UITYPE_OPTAMULET, "Optic Amulet", NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_UNIQUE, SPL_NULL, FALSE, 5000, 5000 },
{ IDROP_NEVER, ICLASS_MISC, ILOC_RING, ICURS_RING_OF_TRUTH, 12, UITYPE_TRING, "Ring of Truth", NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, ISPL_NONE, IMISC_UNIQUE, SPL_NULL, FALSE, 1000, 1000 },

85
Source/items.cpp

@ -21,7 +21,7 @@ int gnNumGetRecords;
/* data */
BYTE ItemCAnimTbl[169] = {
BYTE ItemCAnimTbl[] = {
20, 16, 16, 16, 4, 4, 4, 12, 12, 12,
12, 12, 12, 12, 12, 21, 21, 25, 12, 28,
28, 28, 0, 0, 0, 32, 0, 0, 0, 24,
@ -40,7 +40,7 @@ BYTE ItemCAnimTbl[169] = {
14, 17, 17, 17, 0, 34, 1, 0, 3, 17,
8, 8, 6, 1, 3, 3, 11, 3, 4
};
char *ItemDropNames[ITEMTYPES] = {
char *ItemDropNames[] = {
"Armor2",
"Axe",
"FBttle",
@ -75,9 +75,9 @@ char *ItemDropNames[ITEMTYPES] = {
"Innsign",
"Bldstn",
"Fanvil",
"FLazStaf"
"FLazStaf",
};
BYTE ItemAnimLs[ITEMTYPES] = {
BYTE ItemAnimLs[] = {
15,
13,
16,
@ -112,9 +112,9 @@ BYTE ItemAnimLs[ITEMTYPES] = {
13,
13,
13,
8
8,
};
int ItemDropSnds[ITEMTYPES] = {
int ItemDropSnds[] = {
IS_FHARM,
IS_FAXE,
IS_FPOT,
@ -149,9 +149,9 @@ int ItemDropSnds[ITEMTYPES] = {
IS_ISIGN,
IS_FBLST,
IS_FANVL,
IS_FSTAF
IS_FSTAF,
};
int ItemInvSnds[ITEMTYPES] = {
int ItemInvSnds[] = {
IS_IHARM,
IS_IAXE,
IS_IPOT,
@ -186,7 +186,7 @@ int ItemInvSnds[ITEMTYPES] = {
IS_ISIGN,
IS_IBLST,
IS_IANVL,
IS_ISTAF
IS_ISTAF,
};
int idoppely = 16;
int premiumlvladd[6] = { -1, -1, 0, 0, 1, 2 };
@ -205,13 +205,13 @@ void InitItemGFX()
BOOL ItemPlace(int xp, int yp)
{
if (dMonster[xp][yp])
if (dMonster[xp][yp] != 0)
return FALSE;
if (dPlayer[xp][yp])
if (dPlayer[xp][yp] != 0)
return FALSE;
if (dItem[xp][yp])
if (dItem[xp][yp] != 0)
return FALSE;
if (dObject[xp][yp])
if (dObject[xp][yp] != 0)
return FALSE;
if (dFlags[xp][yp] & BFLAG_POPULATED)
return FALSE;
@ -342,8 +342,8 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
ItemStruct *itm = &plr[p].InvBody[i];
if (itm->_itype != ITYPE_NONE && itm->_iStatFlag) {
mind += itm->_iMinDam;
tac += itm->_iAC;
mind += itm->_iMinDam;
maxd += itm->_iMaxDam;
if (itm->_iSpell != SPL_NULL) {
@ -359,7 +359,6 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
tmpac = 1;
bac += tmpac;
}
dmod += itm->_iPLDamMod;
iflgs |= itm->_iFlags;
sadd += itm->_iPLStr;
madd += itm->_iPLMag;
@ -368,6 +367,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
fr += itm->_iPLFR;
lr += itm->_iPLLR;
mr += itm->_iPLMR;
dmod += itm->_iPLDamMod;
ghit += itm->_iPLGetHit;
lrad += itm->_iPLLight;
ihp += itm->_iPLHP;
@ -395,15 +395,15 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
}
}
plr[p]._pIMinDam = mind;
plr[p]._pIMaxDam = maxd;
plr[p]._pIAC = tac;
plr[p]._pIBonusDam = bdam;
plr[p]._pIBonusToHit = btohit;
plr[p]._pIBonusAC = bac;
plr[p]._pIFlags = iflgs;
plr[p]._pIGetHit = ghit;
plr[p]._pIMinDam = mind;
plr[p]._pIBonusDamMod = dmod;
plr[p]._pIGetHit = ghit;
if (lrad < 2) {
lrad = 2;
@ -471,19 +471,16 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
lr = 0;
}
if (mr > 75) {
mr = 75;
}
if (mr > MAXRESIST)
mr = MAXRESIST;
plr[p]._pMagResist = mr;
if (fr > 75) {
fr = 75;
}
if (fr > MAXRESIST)
fr = MAXRESIST;
plr[p]._pFireResist = fr;
if (lr > 75) {
lr = 75;
}
if (lr > MAXRESIST)
lr = MAXRESIST;
plr[p]._pLghtResist = lr;
if (plr[p]._pClass == PC_WARRIOR) {
@ -585,7 +582,7 @@ void CalcPlrItemVals(int p, BOOL Loadgfx)
d = plr[p]._pdir;
// TODO: Add debug assert here ( plr[p]._pNAnim[d] != NULL )
assert(plr[p]._pNAnim[d]);
plr[p]._pAnimData = plr[p]._pNAnim[d];
plr[p]._pAnimLen = plr[p]._pNFrames;
@ -736,7 +733,7 @@ void CalcPlrBookVals(int p)
{
int i, slvl;
if (!currlevel) {
if (currlevel == 0) {
for (i = 1; witchitem[i]._itype != ITYPE_NONE; i++) {
WitchBookLevel(i);
witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]);
@ -748,7 +745,7 @@ void CalcPlrBookVals(int p)
plr[p].InvList[i]._iMinMag = spelldata[plr[p].InvList[i]._iSpell].sMinInt;
slvl = plr[p]._pSplLvl[plr[p].InvList[i]._iSpell];
while (slvl) {
while (slvl != 0) {
plr[p].InvList[i]._iMinMag += 20 * plr[p].InvList[i]._iMinMag / 100;
slvl--;
if (plr[p].InvList[i]._iMinMag + 20 * plr[p].InvList[i]._iMinMag / 100 > 255) {
@ -771,7 +768,7 @@ void CalcPlrInv(int p, BOOL Loadgfx)
CalcPlrBookVals(p);
CalcPlrScrolls(p);
CalcPlrStaff(p);
if (p == myplr && !currlevel)
if (p == myplr && currlevel == 0)
RecalcStoreStats();
}
}
@ -881,7 +878,7 @@ void CreatePlrItems(int p)
plr[p]._pNumInv = 0;
pi = plr[p].SpdList;
pi = &plr[p].SpdList[0];
for (i = MAXBELTITEMS; i != 0; i--) {
pi->_itype = ITYPE_NONE;
pi++;
@ -970,16 +967,16 @@ BOOL ItemSpaceOk(int i, int j)
if (i < 0 || i + 1 >= MAXDUNX || j < 0 || j + 1 >= MAXDUNY)
return FALSE;
if (dMonster[i][j])
if (dMonster[i][j] != 0)
return FALSE;
if (dPlayer[i][j])
if (dPlayer[i][j] != 0)
return FALSE;
if (dItem[i][j])
if (dItem[i][j] != 0)
return FALSE;
if (dObject[i][j]) {
if (dObject[i][j] != 0) {
oi = dObject[i][j] > 0 ? dObject[i][j] - 1 : -(dObject[i][j] + 1);
if (object[oi]._oSolidFlag)
return FALSE;
@ -1124,7 +1121,7 @@ void GetBookSpell(int i, int lvl)
if (lvl > 5)
lvl = 5;
#endif
s = 1;
s = SPL_FIREBOLT;
while (rv > 0) {
if (spelldata[s].sBookLvl != -1 && lvl >= spelldata[s].sBookLvl) {
rv--;
@ -1229,7 +1226,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
if (lvl > 10)
lvl = 10;
#endif
s = 1;
s = SPL_FIREBOLT;
while (rv > 0) {
if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) {
rv--;
@ -1241,7 +1238,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
if (gbMaxPlayers == 1 && s == SPL_HEALOTHER)
s = SPL_FLARE;
if (s == MAX_SPELLS)
s = 1;
s = SPL_FIREBOLT;
}
sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText);
if (!control_WriteStringToBuffer((BYTE *)istr))
@ -1700,7 +1697,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
}
}
}
if (nt) {
if (nl != 0) {
preidx = l[random_(23, nt)];
sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
strcpy(item[i]._iIName, istr);
@ -1728,7 +1725,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
nl++;
}
}
if (nl) {
if (nl != 0) {
sufidx = l[random_(23, nl)];
sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
strcpy(item[i]._iIName, istr);
@ -1963,7 +1960,7 @@ int CheckUnique(int i, int lvl, int uper, BOOL recreate)
}
}
if (!numu)
if (numu == 0)
return -1;
random_(29, 10); /// BUGFIX: unused, last unique in array always gets chosen
@ -2483,7 +2480,7 @@ void FreeItemGFX()
{
int i;
for (i = 0; i < 35; i++) {
for (i = 0; i < ITEMTYPES; i++) {
MemFreeDbg(itemanims[i]);
}
}
@ -2535,7 +2532,7 @@ void DoRepair(int pnum, int cii)
ItemStruct *pi;
p = &plr[pnum];
PlaySfxLoc(IS_REPAIR, p->WorldX, p->WorldY);
PlaySfxLoc(IS_REPAIR, p->_px, p->_py);
if (cii >= NUM_INVLOC) {
pi = &p->InvList[cii - NUM_INVLOC];
@ -2959,7 +2956,7 @@ void PrintUString(int x, int y, BOOL cjustflag, char *str, int col)
void DrawULine(int y)
{
/// ASSERT: assert(gpBuffer);
assert(gpBuffer);
int i;
BYTE *src, *dst;

10
Source/items.h

@ -132,11 +132,11 @@ void PutItemRecord(int nSeed, WORD wCI, int nIndex);
/* data */
extern BYTE ItemCAnimTbl[169];
extern char *ItemDropNames[ITEMTYPES];
extern BYTE ItemAnimLs[ITEMTYPES];
extern int ItemDropSnds[ITEMTYPES];
extern int ItemInvSnds[ITEMTYPES];
extern BYTE ItemCAnimTbl[];
extern char *ItemDropNames[];
extern BYTE ItemAnimLs[];
extern int ItemDropSnds[];
extern int ItemInvSnds[];
extern int idoppely;
extern int premiumlvladd[6];

39
Source/lighting.cpp

@ -656,9 +656,8 @@ void DoUnLight(int nXPos, int nYPos, int nRadius)
for (y = min_y; y < max_y; y++) {
for (x = min_x; x < max_x; x++) {
if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY) {
if (x >= 0 && x < MAXDUNX && y >= 0 && y < MAXDUNY)
dLight[x][y] = dPreLight[x][y];
}
}
}
}
@ -758,9 +757,9 @@ void DoVision(int nXPos, int nYPos, int nRadius, BOOL doautomap, BOOL visible)
if (nCrawlX >= 0 && nCrawlX < MAXDUNX && nCrawlY >= 0 && nCrawlY < MAXDUNY) {
nBlockerFlag = nBlockTable[dPiece[nCrawlX][nCrawlY]];
if ((x1adj + nCrawlX >= 0 && x1adj + nCrawlX < MAXDUNX && y1adj + nCrawlY >= 0 && y1adj + nCrawlY < MAXDUNY
&& !nBlockTable[dPiece[x1adj + nCrawlX][y1adj + nCrawlY]])
&& !nBlockTable[dPiece[x1adj + nCrawlX][y1adj + nCrawlY]])
|| (x2adj + nCrawlX >= 0 && x2adj + nCrawlX < MAXDUNX && y2adj + nCrawlY >= 0 && y2adj + nCrawlY < MAXDUNY
&& !nBlockTable[dPiece[x2adj + nCrawlX][y2adj + nCrawlY]])) {
&& !nBlockTable[dPiece[x2adj + nCrawlX][y2adj + nCrawlY]])) {
if (doautomap) {
if (dFlags[nCrawlX][nCrawlY] >= 0) {
SetAutomapView(nCrawlX, nCrawlY);
@ -791,7 +790,7 @@ void FreeLightTable()
void InitLightTable()
{
/// ASSERT: assert(! pLightTbl);
assert(!pLightTbl);
pLightTbl = DiabloAllocPtr(LIGHTSIZE);
}
@ -983,13 +982,13 @@ void ToggleLighting()
lightflag ^= TRUE;
if (lightflag) {
if (lightflag != 0) {
memset(dLight, 0, sizeof(dLight));
} else {
memcpy(dLight, dPreLight, sizeof(dLight));
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive && plr[i].plrlevel == currlevel) {
DoLighting(plr[i].WorldX, plr[i].WorldY, plr[i]._pLightRad, -1);
DoLighting(plr[i]._px, plr[i]._py, plr[i]._pLightRad, -1);
}
}
}
@ -1022,7 +1021,7 @@ int AddLight(int x, int y, int r)
{
int lid;
if (lightflag) {
if (lightflag != 0) {
return -1;
}
@ -1035,8 +1034,8 @@ int AddLight(int x, int y, int r)
LightList[lid]._lradius = r;
LightList[lid]._xoff = 0;
LightList[lid]._yoff = 0;
LightList[lid]._ldel = 0;
LightList[lid]._lunflag = 0;
LightList[lid]._ldel = FALSE;
LightList[lid]._lunflag = FALSE;
dolighting = TRUE;
}
@ -1049,7 +1048,7 @@ void AddUnLight(int i)
return;
}
LightList[i]._ldel = 1;
LightList[i]._ldel = TRUE;
dolighting = TRUE;
}
@ -1059,7 +1058,7 @@ void ChangeLightRadius(int i, int r)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1073,7 +1072,7 @@ void ChangeLightXY(int i, int x, int y)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1088,7 +1087,7 @@ void ChangeLightOff(int i, int x, int y)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1103,7 +1102,7 @@ void ChangeLight(int i, int x, int y, int r)
return;
}
LightList[i]._lunflag = 1;
LightList[i]._lunflag = TRUE;
LightList[i]._lunx = LightList[i]._lx;
LightList[i]._luny = LightList[i]._ly;
LightList[i]._lunr = LightList[i]._lradius;
@ -1118,7 +1117,7 @@ void ProcessLightList()
int i, j;
BYTE temp;
if (lightflag) {
if (lightflag != 0) {
return;
}
@ -1130,7 +1129,7 @@ void ProcessLightList()
}
if (LightList[j]._lunflag) {
DoUnLight(LightList[j]._lunx, LightList[j]._luny, LightList[j]._lunr);
LightList[j]._lunflag = 0;
LightList[j]._lunflag = FALSE;
}
}
for (i = 0; i < numlights; i++) {
@ -1199,7 +1198,7 @@ void ChangeVisionRadius(int id, int r)
for (i = 0; i < numvision; i++) {
if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = 1;
VisionList[i]._lunflag = TRUE;
VisionList[i]._lunx = VisionList[i]._lx;
VisionList[i]._luny = VisionList[i]._ly;
VisionList[i]._lunr = VisionList[i]._lradius;
@ -1215,7 +1214,7 @@ void ChangeVisionXY(int id, int x, int y)
for (i = 0; i < numvision; i++) {
if (VisionList[i]._lid == id) {
VisionList[i]._lunflag = 1;
VisionList[i]._lunflag = TRUE;
VisionList[i]._lunx = VisionList[i]._lx;
VisionList[i]._luny = VisionList[i]._ly;
VisionList[i]._lunr = VisionList[i]._lradius;
@ -1238,7 +1237,7 @@ void ProcessVisionList()
}
if (VisionList[i]._lunflag) {
DoUnVision(VisionList[i]._lunx, VisionList[i]._luny, VisionList[i]._lunr);
VisionList[i]._lunflag = 0;
VisionList[i]._lunflag = FALSE;
}
}
for (i = 0; i < TransVal; i++) {

26
Source/loadsave.cpp

@ -220,7 +220,7 @@ void CopyBytes(const void *src, const int n, void *dst)
void CopyChar(const void *src, void *dst)
{
*(char*)dst = *(char*)src;
*(char *)dst = *(char *)src;
tbuff += 1;
}
@ -237,9 +237,10 @@ void CopyShorts(const void *src, const int n, void *dst)
{
const auto *s = reinterpret_cast<const unsigned short *>(src);
auto *d = reinterpret_cast<unsigned short *>(dst);
for(int i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
CopyShort(s, d);
++d; ++s;
++d;
++s;
}
}
@ -256,9 +257,10 @@ void CopyInts(const void *src, const int n, void *dst)
{
const auto *s = reinterpret_cast<const unsigned int *>(src);
auto *d = reinterpret_cast<unsigned int *>(dst);
for(int i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
CopyInt(s, d);
++d; ++s;
++d;
++s;
}
}
@ -285,10 +287,10 @@ void LoadPlayer(int i)
CopyInt(tbuff, &pPlayer->destParam3);
CopyInt(tbuff, &pPlayer->destParam4);
CopyInt(tbuff, &pPlayer->plrlevel);
CopyInt(tbuff, &pPlayer->WorldX);
CopyInt(tbuff, &pPlayer->WorldY);
CopyInt(tbuff, &pPlayer->_px);
CopyInt(tbuff, &pPlayer->_py);
CopyInt(tbuff, &pPlayer->_pfutx);
CopyInt(tbuff, &pPlayer->_pfuty);
CopyInt(tbuff, &pPlayer->_ptargx);
CopyInt(tbuff, &pPlayer->_ptargy);
CopyInt(tbuff, &pPlayer->_pownerx);
@ -1010,10 +1012,10 @@ void SavePlayer(int i)
CopyInt(&pPlayer->destParam3, tbuff);
CopyInt(&pPlayer->destParam4, tbuff);
CopyInt(&pPlayer->plrlevel, tbuff);
CopyInt(&pPlayer->WorldX, tbuff);
CopyInt(&pPlayer->WorldY, tbuff);
CopyInt(&pPlayer->_px, tbuff);
CopyInt(&pPlayer->_py, tbuff);
CopyInt(&pPlayer->_pfutx, tbuff);
CopyInt(&pPlayer->_pfuty, tbuff);
CopyInt(&pPlayer->_ptargx, tbuff);
CopyInt(&pPlayer->_ptargy, tbuff);
CopyInt(&pPlayer->_pownerx, tbuff);
@ -1113,7 +1115,7 @@ void SavePlayer(int i)
CopyInt(&pPlayer->_pVar8, tbuff);
CopyBytes(&pPlayer->_pLvlVisited, NUMLEVELS, tbuff);
CopyBytes(&pPlayer->_pSLvlVisited, NUMLEVELS, tbuff); // only 10 used
tbuff += 2; // Alignment
tbuff += 2; // Alignment
CopyInt(&pPlayer->_pGFXLoad, tbuff);
tbuff += 4 * 8; // Skip pointers _pNAnim
@ -1549,7 +1551,7 @@ void SaveLevel()
int dwLen;
BYTE *SaveBuff;
if (!currlevel)
if (currlevel == 0)
glSeedTbl[0] = GetRndSeed();
dwLen = codec_get_encoded_len(FILEBUFF);
@ -1722,7 +1724,7 @@ void LoadLevel()
for (i = 0; i < MAX_PLRS; i++) {
if (plr[i].plractive && currlevel == plr[i].plrlevel)
LightList[plr[i]._plid]._lunflag = 1;
LightList[plr[i]._plid]._lunflag = TRUE;
}
mem_free_dbg(LoadBuff);

10
Source/minitext.cpp

@ -74,11 +74,11 @@ void InitQTextMsg(int m)
qtextptr = alltext[m].txtstr;
qtextflag = TRUE;
qtexty = 500;
sgLastScroll = qscroll_spd_tbl[alltext[m].txtspd - 1];
if (sgLastScroll <= 0)
scrolltexty = 50 / -(sgLastScroll - 1);
qtextSpd = qscroll_spd_tbl[alltext[m].txtspd - 1];
if (qtextSpd <= 0)
scrolltexty = 50 / -(qtextSpd - 1);
else
scrolltexty = ((sgLastScroll + 1) * 50) / sgLastScroll;
scrolltexty = ((qtextSpd + 1) * 50) / qtextSpd;
qtextSpd = SDL_GetTicks();
}
PlaySFX(alltext[m].sfxnr);
@ -168,7 +168,7 @@ void DrawQText()
}
}
for (currTime = SDL_GetTicks(); qtextSpd + scrolltexty < currTime; qtextSpd += scrolltexty) {
for (currTime = SDL_GetTicks(); sgLastScroll + scrolltexty < currTime; sgLastScroll += scrolltexty) {
qtexty--;
if (qtexty <= 209) {
qtexty += 38;

2
Source/minitext.h

@ -8,9 +8,7 @@
extern int qtexty;
extern char *qtextptr;
extern int qtextSpd;
extern BOOLEAN qtextflag;
extern int scrolltexty;
extern BYTE *pMedTextCels;
extern BYTE *pTextBoxCels;

140
Source/missiles.cpp

@ -670,8 +670,8 @@ BOOL MonsterMHit(int pnum, int m, int mindam, int maxdam, int dist, int t, BOOLE
if (!monster[m]._msquelch) {
monster[m]._msquelch = UCHAR_MAX;
monster[m]._lastx = plr[pnum].WorldX;
monster[m]._lasty = plr[pnum].WorldY;
monster[m]._lastx = plr[pnum]._px;
monster[m]._lasty = plr[pnum]._py;
}
return TRUE;
}
@ -798,12 +798,12 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
SyncPlrKill(pnum, earflag);
} else {
if (plr[pnum]._pClass == PC_WARRIOR) {
PlaySfxLoc(PS_WARR69, plr[pnum].WorldX, plr[pnum].WorldY);
PlaySfxLoc(PS_WARR69, plr[pnum]._px, plr[pnum]._py);
#ifndef SPAWN
} else if (plr[pnum]._pClass == PC_ROGUE) {
PlaySfxLoc(PS_ROGUE69, plr[pnum].WorldX, plr[pnum].WorldY);
PlaySfxLoc(PS_ROGUE69, plr[pnum]._px, plr[pnum]._py);
} else if (plr[pnum]._pClass == PC_SORCERER) {
PlaySfxLoc(PS_MAGE69, plr[pnum].WorldX, plr[pnum].WorldY);
PlaySfxLoc(PS_MAGE69, plr[pnum]._px, plr[pnum]._py);
#endif
}
drawhpflag = TRUE;
@ -811,7 +811,7 @@ BOOL PlayerMHit(int pnum, int m, int dist, int mind, int maxd, int mtype, BOOLEA
} else {
if (blk < blkper) {
if (m != -1) {
tac = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[m]._mx, monster[m]._my);
tac = GetDirection(plr[pnum]._px, plr[pnum]._py, monster[m]._mx, monster[m]._my);
} else {
tac = plr[pnum]._pdir;
}
@ -935,10 +935,10 @@ BOOL Plr2PlrMHit(int pnum, int p, int mindam, int maxdam, int dist, int mtype, B
} else {
return TRUE;
}
PlaySfxLoc(tac, plr[pnum].WorldX, plr[pnum].WorldY);
PlaySfxLoc(tac, plr[pnum]._px, plr[pnum]._py);
} else {
if (blkper < blk) {
StartPlrBlock(p, GetDirection(plr[p].WorldX, plr[p].WorldY, plr[pnum].WorldX, plr[pnum].WorldY));
StartPlrBlock(p, GetDirection(plr[p]._px, plr[p]._py, plr[pnum]._px, plr[pnum]._py));
} else {
if (pnum == myplr)
NetSendCmdDamage(TRUE, p, dam);
@ -973,13 +973,13 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my,
if (dMonster[mx][my] < 0
&& monster[-(dMonster[mx][my] + 1)]._mmode == MM_STONE
&& MonsterMHit(
missile[i]._misource,
-(dMonster[mx][my] + 1),
mindam,
maxdam,
missile[i]._midist,
missile[i]._mitype,
shift)) {
missile[i]._misource,
-(dMonster[mx][my] + 1),
mindam,
maxdam,
missile[i]._midist,
missile[i]._mitype,
shift)) {
if (!nodel)
missile[i]._mirange = 0;
missile[i]._miHitFlag = TRUE;
@ -988,13 +988,13 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my,
if (dPlayer[mx][my] > 0
&& dPlayer[mx][my] - 1 != missile[i]._misource
&& Plr2PlrMHit(
missile[i]._misource,
dPlayer[mx][my] - 1,
mindam,
maxdam,
missile[i]._midist,
missile[i]._mitype,
shift)) {
missile[i]._misource,
dPlayer[mx][my] - 1,
mindam,
maxdam,
missile[i]._midist,
missile[i]._mitype,
shift)) {
if (!nodel)
missile[i]._mirange = 0;
missile[i]._miHitFlag = TRUE;
@ -1010,14 +1010,14 @@ void CheckMissileCol(int i, int mindam, int maxdam, BOOL shift, int mx, int my,
}
if (dPlayer[mx][my] > 0
&& PlayerMHit(
dPlayer[mx][my] - 1,
missile[i]._misource,
missile[i]._midist,
mindam,
maxdam,
missile[i]._mitype,
shift,
0)) {
dPlayer[mx][my] - 1,
missile[i]._misource,
missile[i]._midist,
mindam,
maxdam,
missile[i]._mitype,
shift,
0)) {
if (!nodel)
missile[i]._mirange = 0;
missile[i]._miHitFlag = TRUE;
@ -1074,9 +1074,9 @@ void SetMissAnim(int mi, int animtype)
{
int dir = missile[mi]._mimfnum;
if (animtype > MFILE_NULL) {
animtype = MFILE_NULL;
}
if (animtype > MFILE_NULL) {
animtype = MFILE_NULL;
}
missile[mi]._miAnimType = animtype;
missile[mi]._miAnimFlags = misfiledata[animtype].mFlags;
@ -1415,8 +1415,8 @@ void AddLightball(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
missile[mi]._miVar1 = sx;
missile[mi]._miVar2 = sy;
} else {
missile[mi]._miVar1 = plr[id].WorldX;
missile[mi]._miVar2 = plr[id].WorldY;
missile[mi]._miVar1 = plr[id]._px;
missile[mi]._miVar2 = plr[id]._py;
}
}
@ -2444,8 +2444,8 @@ void AddDiabApoca(int mi, int sx, int sy, int dx, int dy, int midir, char mienem
for (pnum = 0; pnum < gbMaxPlayers; pnum++) {
if (plr[pnum].plractive) {
if (LineClear(sx, sy, plr[pnum]._px, plr[pnum]._py)) {
AddMissile(0, 0, plr[pnum]._px, plr[pnum]._py, 0, MIS_BOOM2, mienemy, id, dam, 0);
if (LineClear(sx, sy, plr[pnum]._pfutx, plr[pnum]._pfuty)) {
AddMissile(0, 0, plr[pnum]._pfutx, plr[pnum]._pfuty, 0, MIS_BOOM2, mienemy, id, dam, 0);
}
}
}
@ -2869,8 +2869,8 @@ void MI_Fireball(int i)
missile[i]._mirange--;
if (missile[i]._micaster == 0) {
px = plr[id].WorldX;
py = plr[id].WorldY;
px = plr[id]._px;
py = plr[id]._py;
} else {
px = monster[id]._mx;
py = monster[id]._my;
@ -2917,12 +2917,12 @@ void MI_Fireball(int i)
}
if (missile[i]._miyvel > 0
&& (TransList[dTransVal[mx + 1][my]] && nSolidTable[dPiece[mx + 1][my]]
|| TransList[dTransVal[mx - 1][my]] && nSolidTable[dPiece[mx - 1][my]])) {
|| TransList[dTransVal[mx - 1][my]] && nSolidTable[dPiece[mx - 1][my]])) {
missile[i]._miyoff -= 32;
}
if (missile[i]._mixvel > 0
&& (TransList[dTransVal[mx][my + 1]] && nSolidTable[dPiece[mx][my + 1]]
|| TransList[dTransVal[mx][my - 1]] && nSolidTable[dPiece[mx][my - 1]])) {
|| TransList[dTransVal[mx][my - 1]] && nSolidTable[dPiece[mx][my - 1]])) {
missile[i]._mixoff -= 32;
}
missile[i]._mimfnum = 0;
@ -3060,7 +3060,7 @@ void MI_Town(int i)
}
for (p = 0; p < MAX_PLRS; p++) {
if (plr[p].plractive && currlevel == plr[p].plrlevel && !plr[p]._pLvlChanging && plr[p]._pmode == PM_STAND && plr[p].WorldX == missile[i]._mix && plr[p].WorldY == missile[i]._miy) {
if (plr[p].plractive && currlevel == plr[p].plrlevel && !plr[p]._pLvlChanging && plr[p]._pmode == PM_STAND && plr[p]._px == missile[i]._mix && plr[p]._py == missile[i]._miy) {
ClrPlrPath(p);
if (p == myplr) {
NetSendCmdParam1(TRUE, CMD_WARP, missile[i]._misource);
@ -3124,16 +3124,16 @@ void MI_Manashield(int i)
int id, diff;
id = missile[i]._misource;
missile[i]._mix = plr[id].WorldX;
missile[i]._miy = plr[id].WorldY;
missile[i]._mix = plr[id]._px;
missile[i]._miy = plr[id]._py;
missile[i]._mitxoff = plr[id]._pxoff << 16;
missile[i]._mityoff = plr[id]._pyoff << 16;
if (plr[id]._pmode == PM_WALK3) {
missile[i]._misx = plr[id]._pfutx;
missile[i]._misy = plr[id]._pfuty;
} else {
missile[i]._misx = plr[id]._px;
missile[i]._misy = plr[id]._py;
} else {
missile[i]._misx = plr[id].WorldX;
missile[i]._misy = plr[id].WorldY;
}
GetMissilePos(i);
if (plr[id]._pmode == PM_WALK3) {
@ -3200,16 +3200,16 @@ void MI_Etherealize(int i)
missile[i]._mirange--;
src = missile[i]._misource;
missile[i]._mix = plr[src].WorldX;
missile[i]._miy = plr[src].WorldY;
missile[i]._mix = plr[src]._px;
missile[i]._miy = plr[src]._py;
missile[i]._mitxoff = plr[src]._pxoff << 16;
missile[i]._mityoff = plr[src]._pyoff << 16;
if (plr[src]._pmode == PM_WALK3) {
missile[i]._misx = plr[src]._pfutx;
missile[i]._misy = plr[src]._pfuty;
} else {
missile[i]._misx = plr[src]._px;
missile[i]._misy = plr[src]._py;
} else {
missile[i]._misx = plr[src].WorldX;
missile[i]._misy = plr[src].WorldY;
}
GetMissilePos(i);
if (plr[src]._pmode == PM_WALK3) {
@ -3464,24 +3464,24 @@ void MI_Teleport(int i)
if (missile[i]._mirange <= 0) {
missile[i]._miDelFlag = TRUE;
} else {
dPlayer[plr[id].WorldX][plr[id].WorldY] = 0;
PlrClrTrans(plr[id].WorldX, plr[id].WorldY);
plr[id].WorldX = missile[i]._mix;
plr[id].WorldY = missile[i]._miy;
plr[id]._px = plr[id].WorldX;
plr[id]._py = plr[id].WorldY;
plr[id]._poldx = plr[id].WorldX;
plr[id]._poldy = plr[id].WorldY;
PlrDoTrans(plr[id].WorldX, plr[id].WorldY);
dPlayer[plr[id]._px][plr[id]._py] = 0;
PlrClrTrans(plr[id]._px, plr[id]._py);
plr[id]._px = missile[i]._mix;
plr[id]._py = missile[i]._miy;
plr[id]._pfutx = plr[id]._px;
plr[id]._pfuty = plr[id]._py;
plr[id]._poldx = plr[id]._px;
plr[id]._poldy = plr[id]._py;
PlrDoTrans(plr[id]._px, plr[id]._py);
missile[i]._miVar1 = 1;
dPlayer[plr[id].WorldX][plr[id].WorldY] = id + 1;
dPlayer[plr[id]._px][plr[id]._py] = id + 1;
if (leveltype != DTYPE_TOWN) {
ChangeLightXY(plr[id]._plid, plr[id].WorldX, plr[id].WorldY);
ChangeVisionXY(plr[id]._pvid, plr[id].WorldX, plr[id].WorldY);
ChangeLightXY(plr[id]._plid, plr[id]._px, plr[id]._py);
ChangeVisionXY(plr[id]._pvid, plr[id]._px, plr[id]._py);
}
if (id == myplr) {
ViewX = plr[id].WorldX - ScrollInfo._sdx;
ViewY = plr[id].WorldY - ScrollInfo._sdy;
ViewX = plr[id]._px - ScrollInfo._sdx;
ViewY = plr[id]._py - ScrollInfo._sdy;
}
}
}
@ -3587,8 +3587,8 @@ void mi_null_32(int i)
by = missile[i]._miy;
enemy = monster[src]._menemy;
if (!(monster[src]._mFlags & MFLAG_TARGETS_MONSTER)) {
cx = plr[enemy].WorldX;
cy = plr[enemy].WorldY;
cx = plr[enemy]._px;
cy = plr[enemy]._py;
} else {
cx = monster[enemy]._mx;
cy = monster[enemy]._my;
@ -3917,8 +3917,8 @@ void MI_Element(int i)
if (missile[i]._miAnimType == MFILE_BIGEXP) {
cx = missile[i]._mix;
cy = missile[i]._miy;
px = plr[id].WorldX;
py = plr[id].WorldY;
px = plr[id]._px;
py = plr[id]._py;
ChangeLight(missile[i]._mlid, cx, cy, missile[i]._miAnimFrame);
if (!CheckBlock(px, py, cx, cy))
CheckMissileCol(i, dam, dam, TRUE, cx, cy, TRUE);

377
Source/monstdat.cpp

@ -125,140 +125,259 @@ 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
*/
BYTE MonstConvTbl[] = {
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,
};
#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
*/
BYTE MonstAvailTbl[] = {
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
0, // Lord Sayter
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
0, // Devil Kin Brute
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
0, // Unraveler
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_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
MAT_NEVER, // Lord Sayter
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
MAT_NEVER, // Devil Kin Brute
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
MAT_NEVER, // Unraveler
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
};
UniqMonstStruct UniqMonst[] = {

2
Source/monstdat.h

@ -7,7 +7,7 @@
#define __MONSTDAT_H__
extern MonsterData monsterdata[];
extern char MonstConvTbl[128];
extern BYTE MonstConvTbl[];
extern BYTE MonstAvailTbl[];
extern UniqMonstStruct UniqMonst[];

159
Source/monster.cpp

@ -19,6 +19,7 @@ BOOLEAN sgbSaveSoundOn;
MonsterStruct monster[MAXMONSTERS];
int totalmonsters;
CMonster Monsters[MAX_LVLMTYPES];
BYTE GraphicTable[NUMLEVELS][MAX_LVLMTYPES];
int monstimgtot;
int uniquetrans;
int nummtypes;
@ -513,8 +514,8 @@ void ClrAllMonsters()
Monst->_mFlags = 0;
Monst->_mDelFlag = FALSE;
Monst->_menemy = random_(89, gbActivePlayers);
Monst->_menemyx = plr[Monst->_menemy]._px;
Monst->_menemyy = plr[Monst->_menemy]._py;
Monst->_menemyx = plr[Monst->_menemy]._pfutx;
Monst->_menemyy = plr[Monst->_menemy]._pfuty;
}
}
@ -691,15 +692,9 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
Monst->mtalkmsg = Uniq->mtalkmsg;
Monst->mlid = AddLight(Monst->_mx, Monst->_my, 3);
if (gbMaxPlayers == 1) {
if (Monst->mtalkmsg) {
Monst->_mgoal = MGOAL_INQUIRING;
}
} else {
if (Monst->_mAi == AI_LAZHELP) {
if (gbMaxPlayers != 1) {
if (Monst->_mAi == AI_LAZHELP)
Monst->mtalkmsg = 0;
}
if (Monst->_mAi != AI_LAZURUS || quests[Q_BETRAYER]._qvar1 <= 3) {
if (Monst->mtalkmsg) {
Monst->_mgoal = MGOAL_INQUIRING;
@ -707,11 +702,12 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
} else {
Monst->_mgoal = MGOAL_NORMAL;
}
}
} else if (Monst->mtalkmsg)
Monst->_mgoal = MGOAL_INQUIRING;
if (gnDifficulty == DIFF_NIGHTMARE) {
Monst->mLevel += 15;
Monst->_mmaxhp = 3 * Monst->_mmaxhp + 64;
Monst->mLevel += 15;
Monst->_mhitpoints = Monst->_mmaxhp;
Monst->mExp = 2 * (Monst->mExp + 1000);
Monst->mMinDamage = 2 * (Monst->mMinDamage + 2);
@ -721,8 +717,8 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int unpackfilesize)
}
if (gnDifficulty == DIFF_HELL) {
Monst->mLevel += 30;
Monst->_mmaxhp = 4 * Monst->_mmaxhp + 192;
Monst->mLevel += 30;
Monst->_mhitpoints = Monst->_mmaxhp;
Monst->mExp = 4 * (Monst->mExp + 1000);
Monst->mMinDamage = 4 * Monst->mMinDamage + 6;
@ -1138,22 +1134,22 @@ void M_Enemy(int i)
for (pnum = 0; pnum < MAX_PLRS; pnum++) {
if (!plr[pnum].plractive || currlevel != plr[pnum].plrlevel || plr[pnum]._pLvlChanging || (plr[pnum]._pHitPoints == 0 && gbMaxPlayers != 1))
continue;
if (dTransVal[Monst->_mx][Monst->_my] == dTransVal[plr[pnum].WorldX][plr[pnum].WorldY])
if (dTransVal[Monst->_mx][Monst->_my] == dTransVal[plr[pnum]._px][plr[pnum]._py])
sameroom = TRUE;
else
sameroom = FALSE;
if (abs(Monst->_mx - plr[pnum].WorldX) > abs(Monst->_my - plr[pnum].WorldY))
dist = Monst->_mx - plr[pnum].WorldX;
if (abs(Monst->_mx - plr[pnum]._px) > abs(Monst->_my - plr[pnum]._py))
dist = Monst->_mx - plr[pnum]._px;
else
dist = Monst->_my - plr[pnum].WorldY;
dist = Monst->_my - plr[pnum]._py;
dist = abs(dist);
if ((sameroom && !bestsameroom)
|| ((sameroom || !bestsameroom) && dist < best_dist)
|| (_menemy == -1)) {
Monst->_mFlags &= ~MFLAG_TARGETS_MONSTER;
_menemy = pnum;
enemyx = plr[pnum]._px;
enemyy = plr[pnum]._py;
enemyx = plr[pnum]._pfutx;
enemyy = plr[pnum]._pfuty;
best_dist = dist;
bestsameroom = sameroom;
}
@ -1169,7 +1165,7 @@ void M_Enemy(int i)
continue;
if (!(Monst->_mFlags & MFLAG_GOLEM)
&& ((abs(monster[mi]._mx - Monst->_mx) >= 2 || abs(monster[mi]._my - Monst->_my) >= 2) && !M_Ranged(i)
|| (!(Monst->_mFlags & MFLAG_GOLEM) && !(monster[mi]._mFlags & MFLAG_GOLEM)))) {
|| (!(Monst->_mFlags & MFLAG_GOLEM) && !(monster[mi]._mFlags & MFLAG_GOLEM)))) {
continue;
}
sameroom = dTransVal[Monst->_mx][Monst->_my] == dTransVal[monster[mi]._mx][monster[mi]._my];
@ -1469,8 +1465,8 @@ void M_StartHit(int i, int pnum, int dam)
if (pnum >= 0) {
monster[i]._mFlags &= ~MFLAG_TARGETS_MONSTER;
monster[i]._menemy = pnum;
monster[i]._menemyx = plr[pnum]._px;
monster[i]._menemyy = plr[pnum]._py;
monster[i]._menemyx = plr[pnum]._pfutx;
monster[i]._menemyy = plr[pnum]._pfuty;
monster[i]._mdir = M_GetDir(i);
}
if (monster[i].MType->mtype == MT_BLINK) {
@ -1593,6 +1589,7 @@ void M2MStartHit(int mid, int i, int dam)
void MonstStartKill(int i, int pnum, BOOL sendmsg)
{
int md;
MonsterStruct *Monst;
if ((DWORD)i >= MAXMONSTERS) {
app_fatal("MonstStartKill: Invalid monster %d", i);
@ -1601,19 +1598,20 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg)
app_fatal("MonstStartKill: Monster %d \"%s\" MType NULL", i, monster[i].mName);
}
Monst = &monster[i];
if (pnum >= 0)
monster[i].mWhoHit |= 1 << pnum;
Monst->mWhoHit |= 1 << pnum;
if (pnum < MAX_PLRS && i > MAX_PLRS)
AddPlrMonstExper(monster[i].mLevel, monster[i].mExp, monster[i].mWhoHit);
monstkills[monster[i].MType->mtype]++;
monster[i]._mhitpoints = 0;
SetRndSeed(monster[i]._mRndSeed);
if (QuestStatus(Q_GARBUD) && monster[i].mName == UniqMonst[UMT_GARBUD].mName) {
CreateTypeItem(monster[i]._mx + 1, monster[i]._my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE);
AddPlrMonstExper(Monst->mLevel, Monst->mExp, Monst->mWhoHit);
monstkills[Monst->MType->mtype]++;
Monst->_mhitpoints = 0;
SetRndSeed(Monst->_mRndSeed);
if (QuestStatus(Q_GARBUD) && Monst->mName == UniqMonst[UMT_GARBUD].mName) {
CreateTypeItem(Monst->_mx + 1, Monst->_my + 1, TRUE, ITYPE_MACE, IMISC_NONE, TRUE, FALSE);
} else if (i > MAX_PLRS - 1) { // Golems should not spawn items
SpawnItem(i, monster[i]._mx, monster[i]._my, sendmsg);
SpawnItem(i, Monst->_mx, Monst->_my, sendmsg);
}
if (monster[i].MType->mtype == MT_DIABLO)
if (Monst->MType->mtype == MT_DIABLO)
M_DiabloDeath(i, TRUE);
else
PlayEffect(i, 2);
@ -1621,23 +1619,23 @@ void MonstStartKill(int i, int pnum, BOOL sendmsg)
if (pnum >= 0)
md = M_GetDir(i);
else
md = monster[i]._mdir;
monster[i]._mdir = md;
NewMonsterAnim(i, &monster[i].MType->Anims[MA_DEATH], md);
monster[i]._mmode = MM_DEATH;
monster[i]._mxoff = 0;
monster[i]._myoff = 0;
monster[i]._mVar1 = 0;
monster[i]._mx = monster[i]._moldx;
monster[i]._my = monster[i]._moldy;
monster[i]._mfutx = monster[i]._moldx;
monster[i]._mfuty = monster[i]._moldy;
md = Monst->_mdir;
Monst->_mdir = md;
NewMonsterAnim(i, &Monst->MType->Anims[MA_DEATH], md);
Monst->_mmode = MM_DEATH;
Monst->_mxoff = 0;
Monst->_myoff = 0;
Monst->_mVar1 = 0;
Monst->_mx = Monst->_moldx;
Monst->_my = Monst->_moldy;
Monst->_mfutx = Monst->_moldx;
Monst->_mfuty = Monst->_moldy;
M_ClearSquares(i);
dMonster[monster[i]._mx][monster[i]._my] = i + 1;
dMonster[Monst->_mx][Monst->_my] = i + 1;
CheckQuestKill(i, sendmsg);
M_FallenFear(monster[i]._mx, monster[i]._my);
if (monster[i].MType->mtype >= MT_NACID && monster[i].MType->mtype <= MT_XACID)
AddMissile(monster[i]._mx, monster[i]._my, 0, 0, 0, MIS_ACIDPUD, 1, i, monster[i]._mint + 1, 0);
M_FallenFear(Monst->_mx, Monst->_my);
if (Monst->MType->mtype >= MT_NACID && Monst->MType->mtype <= MT_XACID)
AddMissile(Monst->_mx, Monst->_my, 0, 0, 0, MIS_ACIDPUD, 1, i, Monst->_mint + 1, 0);
}
void M2MStartKill(int i, int mid)
@ -2005,8 +2003,8 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
}
if (plr[pnum]._pHitPoints >> 6 <= 0 || plr[pnum]._pInvincible || plr[pnum]._pSpellFlags & 1)
return;
dx = abs(monster[i]._mx - plr[pnum].WorldX);
dy = abs(monster[i]._my - plr[pnum].WorldY);
dx = abs(monster[i]._mx - plr[pnum]._px);
dy = abs(monster[i]._my - plr[pnum]._py);
if (dx >= 2 || dy >= 2)
return;
@ -2045,7 +2043,7 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (hper >= hit)
return;
if (blkper < blk) {
StartPlrBlock(pnum, GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, monster[i]._mx, monster[i]._my));
StartPlrBlock(pnum, GetDirection(plr[pnum]._px, plr[pnum]._py, monster[i]._mx, monster[i]._my));
return;
}
if (monster[i].MType->mtype == MT_YZOMBIE && pnum == myplr) {
@ -2109,11 +2107,11 @@ void M_TryH2HHit(int i, int pnum, int Hit, int MinDam, int MaxDam)
if (monster[i]._mFlags & MFLAG_KNOCKBACK) {
if (plr[pnum]._pmode != PM_GOTHIT)
StartPlrHit(pnum, 0, TRUE);
newx = plr[pnum].WorldX + offset_x[monster[i]._mdir];
newy = plr[pnum].WorldY + offset_y[monster[i]._mdir];
newx = plr[pnum]._px + offset_x[monster[i]._mdir];
newy = plr[pnum]._py + offset_y[monster[i]._mdir];
if (PosOkPlayer(pnum, newx, newy)) {
plr[pnum].WorldX = newx;
plr[pnum].WorldY = newy;
plr[pnum]._px = newx;
plr[pnum]._py = newy;
FixPlayerLocation(pnum, plr[pnum]._pdir);
FixPlrWalkTags(pnum);
dPlayer[newx][newy] = pnum + 1;
@ -3598,11 +3596,11 @@ void MAI_Scav(int i)
continue;
done = dDead[Monst->_mx + x][Monst->_my + y] != 0
&& LineClearF(
CheckNoSolid,
Monst->_mx,
Monst->_my,
Monst->_mx + x,
Monst->_my + y);
CheckNoSolid,
Monst->_mx,
Monst->_my,
Monst->_mx + x,
Monst->_my + y);
}
}
x--;
@ -3615,11 +3613,11 @@ void MAI_Scav(int i)
continue;
done = dDead[Monst->_mx + x][Monst->_my + y] != 0
&& LineClearF(
CheckNoSolid,
Monst->_mx,
Monst->_my,
Monst->_mx + x,
Monst->_my + y);
CheckNoSolid,
Monst->_mx,
Monst->_my,
Monst->_mx + x,
Monst->_my + y);
}
}
x++;
@ -4046,8 +4044,8 @@ void MAI_Rhino(int i)
v = random_(134, 100);
if (v >= 2 * Monst->_mint + 33
&& (Monst->_mVar1 != MM_WALK && Monst->_mVar1 != MM_WALK2 && Monst->_mVar1 != MM_WALK3
|| Monst->_mVar2
|| v >= 2 * Monst->_mint + 83)) {
|| Monst->_mVar2
|| v >= 2 * Monst->_mint + 83)) {
M_StartDelay(i, random_(135, 10) + 10);
} else {
M_CallWalk(i, md);
@ -4299,7 +4297,7 @@ void MAI_Lazurus(int i)
md = M_GetDir(i);
if (dFlags[mx][my] & BFLAG_VISIBLE) {
if (gbMaxPlayers == 1) {
if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr].WorldX == TEXT_VILE13 && plr[myplr].WorldY == 46) {
if (Monst->mtalkmsg == TEXT_VILE13 && Monst->_mgoal == MGOAL_INQUIRING && plr[myplr]._px == TEXT_VILE13 && plr[myplr]._py == 46) {
PlayInGameMovie("gendata\\fprst3.smk");
Monst->_mmode = MM_TALK;
quests[Q_BETRAYER]._qvar1 = 5;
@ -4516,12 +4514,12 @@ void ProcessMonsters()
if ((DWORD)_menemy >= MAX_PLRS) {
app_fatal("Illegal enemy player %d for monster \"%s\"", _menemy, Monst->mName);
}
Monst->_menemyx = plr[Monst->_menemy]._px;
Monst->_menemyy = plr[Monst->_menemy]._py;
Monst->_menemyx = plr[Monst->_menemy]._pfutx;
Monst->_menemyy = plr[Monst->_menemy]._pfuty;
if (dFlags[mx][my] & BFLAG_VISIBLE) {
Monst->_msquelch = 255;
Monst->_lastx = plr[Monst->_menemy]._px;
Monst->_lasty = plr[Monst->_menemy]._py;
Monst->_lastx = plr[Monst->_menemy]._pfutx;
Monst->_lasty = plr[Monst->_menemy]._pfuty;
} else if (Monst->_msquelch != 0 && Monst->_mAi != MT_DIABLO) { /// BUGFIX: change '_mAi' to 'MType->mtype'
Monst->_msquelch--;
}
@ -5109,8 +5107,8 @@ void MissToMonst(int i, int x, int y)
newx = oldx + offset_x[Monst->_mdir];
newy = oldy + offset_y[Monst->_mdir];
if (PosOkPlayer(pnum, newx, newy)) {
plr[pnum].WorldX = newx;
plr[pnum].WorldY = newy;
plr[pnum]._px = newx;
plr[pnum]._py = newy;
FixPlayerLocation(pnum, plr[pnum]._pdir);
FixPlrWalkTags(pnum);
dPlayer[newx][newy] = pnum + 1;
@ -5466,19 +5464,20 @@ BOOL CheckMonsterHit(int m, BOOL *ret)
}
if (monster[m]._mAi == AI_GARG && monster[m]._mFlags & MFLAG_ALLOW_SPECIAL) {
monster[m]._mmode = MM_SATTACK;
monster[m]._mFlags &= ~MFLAG_ALLOW_SPECIAL;
monster[m]._mmode = MM_SATTACK;
*ret = TRUE;
return TRUE;
}
if (monster[m].MType->mtype < MT_COUNSLR || monster[m].MType->mtype > MT_ADVOCATE || monster[m]._mgoal == MGOAL_NORMAL) {
return FALSE;
} else {
*ret = FALSE;
if (monster[m].MType->mtype >= MT_COUNSLR && monster[m].MType->mtype <= MT_ADVOCATE) {
if (monster[m]._mgoal != MGOAL_NORMAL) {
*ret = FALSE;
return TRUE;
}
}
return TRUE;
return FALSE;
}
int encode_enemy(int m)
@ -5494,8 +5493,8 @@ void decode_enemy(int m, int enemy)
if (enemy < MAX_PLRS) {
monster[m]._mFlags &= ~MFLAG_TARGETS_MONSTER;
monster[m]._menemy = enemy;
monster[m]._menemyx = plr[enemy]._px;
monster[m]._menemyy = plr[enemy]._py;
monster[m]._menemyx = plr[enemy]._pfutx;
monster[m]._menemyy = plr[enemy]._pfuty;
} else {
monster[m]._mFlags |= MFLAG_TARGETS_MONSTER;
enemy -= MAX_PLRS;

1
Source/monster.h

@ -14,6 +14,7 @@ extern BOOLEAN sgbSaveSoundOn;
extern MonsterStruct monster[MAXMONSTERS];
extern int totalmonsters;
extern CMonster Monsters[MAX_LVLMTYPES];
extern BYTE GraphicTable[NUMLEVELS][MAX_LVLMTYPES];
extern int monstimgtot;
extern int uniquetrans;
extern int nummtypes;

17
Source/mpqapi.cpp

@ -244,7 +244,8 @@ struct Archive {
return result;
}
bool WriteHeaderAndTables() {
bool WriteHeaderAndTables()
{
return WriteHeader() && WriteBlockTable() && WriteHashTable();
}
@ -276,17 +277,17 @@ private:
bool WriteBlockTable()
{
Encrypt(sgpBlockTbl, kBlockEntrySize, Hash("(block table)", 3));
Encrypt((DWORD *)sgpBlockTbl, kBlockEntrySize, Hash("(block table)", 3));
const bool success = stream.write(reinterpret_cast<const char *>(sgpBlockTbl), kBlockEntrySize);
Decrypt(sgpBlockTbl, kBlockEntrySize, Hash("(block table)", 3));
Decrypt((DWORD *)sgpBlockTbl, kBlockEntrySize, Hash("(block table)", 3));
return success;
}
bool WriteHashTable()
{
Encrypt(sgpHashTbl, kHashEntrySize, Hash("(hash table)", 3));
Encrypt((DWORD *)sgpHashTbl, kHashEntrySize, Hash("(hash table)", 3));
const bool success = stream.write(reinterpret_cast<const char *>(sgpHashTbl), kHashEntrySize);
Decrypt(sgpHashTbl, kHashEntrySize, Hash("(hash table)", 3));
Decrypt((DWORD *)sgpHashTbl, kHashEntrySize, Hash("(hash table)", 3));
return success;
}
};
@ -560,7 +561,7 @@ BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD d
if (!cur_archive.stream.write(mpq_buf, len))
return FALSE;
sectoroffsettable[cur_sector++] = SwapLE32(destsize);
destsize += len; // compressed length
destsize += len; // compressed length
if (dwLen > kSectorSize)
dwLen -= kSectorSize;
else
@ -661,7 +662,7 @@ BOOL OpenMPQ(const char *pszArchive, DWORD dwChar)
if (!cur_archive.stream.read(reinterpret_cast<char *>(cur_archive.sgpBlockTbl), kBlockEntrySize))
goto on_error;
key = Hash("(block table)", 3);
Decrypt(cur_archive.sgpBlockTbl, kBlockEntrySize, key);
Decrypt((DWORD *)cur_archive.sgpBlockTbl, kBlockEntrySize, key);
}
cur_archive.sgpHashTbl = new _HASHENTRY[kHashEntrySize / sizeof(_HASHENTRY)];
std::memset(cur_archive.sgpHashTbl, 255, kHashEntrySize);
@ -669,7 +670,7 @@ BOOL OpenMPQ(const char *pszArchive, DWORD dwChar)
if (!cur_archive.stream.read(reinterpret_cast<char *>(cur_archive.sgpHashTbl), kHashEntrySize))
goto on_error;
key = Hash("(hash table)", 3);
Decrypt(cur_archive.sgpHashTbl, kHashEntrySize, key);
Decrypt((DWORD *)cur_archive.sgpHashTbl, kHashEntrySize, key);
}
#ifndef CAN_SEEKP_BEYOND_EOF

5
Source/mpqapi.h

@ -7,13 +7,16 @@
#define __MPQAPI_H__
#include <stdint.h>
extern BYTE mpq_buf[4096];
extern BOOL save_archive_modified;
extern BOOLEAN save_archive_open;
void mpqapi_remove_hash_entry(const char *pszName);
void mpqapi_alloc_block(uint32_t block_offset, uint32_t block_size);
_BLOCKENTRY *mpqapi_new_block(int *block_index);
int FetchHandle(const char *pszName);
int mpqapi_get_hash_index(short index, int hash_a, int hash_b, int locale);
void mpqapi_remove_hash_entries(BOOL(*fnGetName)(DWORD, char *));
void mpqapi_remove_hash_entries(BOOL (*fnGetName)(DWORD, char *));
BOOL mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen);
_BLOCKENTRY *mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int block_index);
BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD dwLen, _BLOCKENTRY *pBlk);

20
Source/msg.cpp

@ -1451,7 +1451,7 @@ DWORD On_GETITEM(TCmd *pCmd, int pnum)
if ((currlevel == p->bLevel || p->bPnum == myplr) && p->bMaster != myplr) {
if (p->bPnum == myplr) {
if (currlevel != p->bLevel) {
ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff);
ii = SyncPutItem(myplr, plr[myplr]._px, plr[myplr]._py, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff);
if (ii != -1)
InvGetItem(myplr, ii);
} else
@ -1573,7 +1573,7 @@ DWORD On_AGETITEM(TCmd *pCmd, int pnum)
if ((currlevel == p->bLevel || p->bPnum == myplr) && p->bMaster != myplr) {
if (p->bPnum == myplr) {
if (currlevel != p->bLevel) {
int ii = SyncPutItem(myplr, plr[myplr].WorldX, plr[myplr].WorldY, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff);
int ii = SyncPutItem(myplr, plr[myplr]._px, plr[myplr]._py, p->wIndx, p->wCI, p->dwSeed, p->bId, p->bDur, p->bMDur, p->bCh, p->bMCh, p->wValue, p->dwBuff);
if (ii != -1)
AutoGetItem(myplr, ii);
} else
@ -1865,8 +1865,8 @@ DWORD On_ATTACKID(TCmd *pCmd, int pnum)
TCmdParam1 *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
int distx = abs(plr[pnum].WorldX - monster[p->wParam1]._mfutx);
int disty = abs(plr[pnum].WorldY - monster[p->wParam1]._mfuty);
int distx = abs(plr[pnum]._px - monster[p->wParam1]._mfutx);
int disty = abs(plr[pnum]._py - monster[p->wParam1]._mfuty);
if (distx > 1 || disty > 1)
MakePlrPath(pnum, monster[p->wParam1]._mfutx, monster[p->wParam1]._mfuty, FALSE);
plr[pnum].destAction = ACTION_ATTACKMON;
@ -1881,7 +1881,7 @@ DWORD On_ATTACKPID(TCmd *pCmd, int pnum)
TCmdParam1 *p = (TCmdParam1 *)pCmd;
if (gbBufferMsgs != 1 && currlevel == plr[pnum].plrlevel) {
MakePlrPath(pnum, plr[p->wParam1]._px, plr[p->wParam1]._py, FALSE);
MakePlrPath(pnum, plr[p->wParam1]._pfutx, plr[p->wParam1]._pfuty, FALSE);
plr[pnum].destAction = ACTION_ATTACKPLR;
plr[pnum].destParam1 = p->wParam1;
}
@ -2123,7 +2123,7 @@ DWORD On_AWAKEGOLEM(TCmd *pCmd, int pnum)
}
}
if (addGolem)
AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, p->_mx, p->_my, p->_mdir, MIS_GOLEM, 0, pnum, 0, 1);
AddMissile(plr[pnum]._px, plr[pnum]._py, p->_mx, p->_my, p->_mdir, MIS_GOLEM, 0, pnum, 0, 1);
}
return sizeof(*p);
@ -2351,8 +2351,8 @@ DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum)
}
if (plr[pnum].plractive && myplr != pnum) {
plr[pnum].WorldX = p->x;
plr[pnum].WorldY = p->y;
plr[pnum]._px = p->x;
plr[pnum]._py = p->y;
plr[pnum].plrlevel = p->wParam1;
plr[pnum]._pGFXLoad = 0;
if (currlevel == plr[pnum].plrlevel) {
@ -2367,10 +2367,10 @@ DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum)
NewPlrAnim(pnum, plr[pnum]._pDAnim[0], plr[pnum]._pDFrames, 1, plr[pnum]._pDWidth);
plr[pnum]._pAnimFrame = plr[pnum]._pAnimLen - 1;
plr[pnum]._pVar8 = plr[pnum]._pAnimLen << 1;
dFlags[plr[pnum].WorldX][plr[pnum].WorldY] |= BFLAG_DEAD_PLAYER;
dFlags[plr[pnum]._px][plr[pnum]._py] |= BFLAG_DEAD_PLAYER;
}
plr[pnum]._pvid = AddVision(plr[pnum].WorldX, plr[pnum].WorldY, plr[pnum]._pLightRad, pnum == myplr);
plr[pnum]._pvid = AddVision(plr[pnum]._px, plr[pnum]._py, plr[pnum]._pLightRad, pnum == myplr);
plr[pnum]._plid = -1;
}
}

40
Source/multi.cpp

@ -93,8 +93,8 @@ void multi_send_packet(void *packet, BYTE dwSize)
void NetRecvPlrData(TPkt *pkt)
{
pkt->hdr.wCheck = 'ip';
pkt->hdr.px = plr[myplr].WorldX;
pkt->hdr.py = plr[myplr].WorldY;
pkt->hdr.px = plr[myplr]._px;
pkt->hdr.py = plr[myplr]._py;
pkt->hdr.targx = plr[myplr]._ptargx;
pkt->hdr.targy = plr[myplr]._ptargy;
pkt->hdr.php = plr[myplr]._pHitPoints;
@ -328,7 +328,7 @@ void multi_mon_seeds()
DWORD l;
sgdwGameLoops++;
l = (sgdwGameLoops >> 8) | (sgdwGameLoops << 24); // _rotr(sgdwGameLoops, 8)
l = (sgdwGameLoops >> 8) | (sgdwGameLoops << 24); // _rotr(sgdwGameLoops, 8)
for (i = 0; i < MAXMONSTERS; i++)
monster[i]._mAISeed = l + i;
}
@ -440,31 +440,31 @@ void multi_process_network_packets()
plr[dwID]._pBaseDex = pkt->bdex;
if (!cond && plr[dwID].plractive && plr[dwID]._pHitPoints) {
if (currlevel == plr[dwID].plrlevel && !plr[dwID]._pLvlChanging) {
dx = abs(plr[dwID].WorldX - pkt->px);
dy = abs(plr[dwID].WorldY - pkt->py);
dx = abs(plr[dwID]._px - pkt->px);
dy = abs(plr[dwID]._py - pkt->py);
if ((dx > 3 || dy > 3) && dPlayer[pkt->px][pkt->py] == 0) {
FixPlrWalkTags(dwID);
plr[dwID]._poldx = plr[dwID].WorldX;
plr[dwID]._poldy = plr[dwID].WorldY;
plr[dwID]._poldx = plr[dwID]._px;
plr[dwID]._poldy = plr[dwID]._py;
FixPlrWalkTags(dwID);
plr[dwID].WorldX = pkt->px;
plr[dwID].WorldY = pkt->py;
plr[dwID]._px = pkt->px;
plr[dwID]._py = pkt->py;
dPlayer[plr[dwID].WorldX][plr[dwID].WorldY] = dwID + 1;
plr[dwID]._pfutx = pkt->px;
plr[dwID]._pfuty = pkt->py;
dPlayer[plr[dwID]._px][plr[dwID]._py] = dwID + 1;
}
dx = abs(plr[dwID]._px - plr[dwID].WorldX);
dy = abs(plr[dwID]._py - plr[dwID].WorldY);
dx = abs(plr[dwID]._pfutx - plr[dwID]._px);
dy = abs(plr[dwID]._pfuty - plr[dwID]._py);
if (dx > 1 || dy > 1) {
plr[dwID]._px = plr[dwID].WorldX;
plr[dwID]._py = plr[dwID].WorldY;
plr[dwID]._pfutx = plr[dwID]._px;
plr[dwID]._pfuty = plr[dwID]._py;
}
MakePlrPath(dwID, pkt->targx, pkt->targy, TRUE);
} else {
plr[dwID].WorldX = pkt->px;
plr[dwID].WorldY = pkt->py;
plr[dwID]._px = pkt->px;
plr[dwID]._py = pkt->py;
plr[dwID]._pfutx = pkt->px;
plr[dwID]._pfuty = pkt->py;
plr[dwID]._ptargx = pkt->targx;
plr[dwID]._ptargy = pkt->targy;
}
@ -721,7 +721,7 @@ BOOL NetInit(BOOL bSinglePlayer, BOOL *pfExitProgram)
gnDifficulty = sgGameInitInfo.bDiff;
SetRndSeed(sgGameInitInfo.dwSeed);
for (i = 0; i < 17; i++) {
for (i = 0; i < NUMLEVELS; i++) {
glSeedTbl[i] = GetRndSeed();
gnLevelTypeTbl[i] = InitLevelType(i);
}
@ -780,10 +780,10 @@ void SetupLocalCoords()
#endif
x += plrxoff[myplr];
y += plryoff[myplr];
plr[myplr].WorldX = x;
plr[myplr].WorldY = y;
plr[myplr]._px = x;
plr[myplr]._py = y;
plr[myplr]._pfutx = x;
plr[myplr]._pfuty = y;
plr[myplr]._ptargx = x;
plr[myplr]._ptargy = y;
plr[myplr].plrlevel = currlevel;
@ -931,7 +931,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, BOOL recv)
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] |= BFLAG_DEAD_PLAYER;
dFlags[plr[pnum]._px][plr[pnum]._py] |= BFLAG_DEAD_PLAYER;
}
}
}

228
Source/objdat.cpp

@ -3,120 +3,120 @@
DEVILUTION_BEGIN_NAMESPACE
/** Maps from dun_object_id to object_id. */
int ObjTypeConv[113] = {
0,
4,
20,
21,
22,
24,
11,
12,
13,
0,
0,
0,
0,
0,
25,
41,
26,
0,
8,
9,
10,
80,
0,
0,
0,
0,
0,
0,
0,
0,
49,
0,
0,
0,
0,
0,
84,
85,
3,
14,
15,
16,
17,
18,
19,
0,
0,
0,
0,
0,
0,
28,
0,
53,
54,
36,
37,
38,
39,
40,
0,
0,
0,
0,
0,
27,
0,
0,
0,
0,
29,
30,
31,
32,
33,
34,
35,
5,
5,
5,
6,
6,
6,
7,
7,
7,
0,
0,
0,
0,
0,
73,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
83,
0,
0,
89,
90,
47,
46,
94
int ObjTypeConv[] = {
OBJ_L1LIGHT,
OBJ_LEVER,
OBJ_CRUX1,
OBJ_CRUX2,
OBJ_CRUX3,
OBJ_ANGEL,
OBJ_BANNERL,
OBJ_BANNERM,
OBJ_BANNERR,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_BOOK2L,
OBJ_BOOK2R,
OBJ_BCROSS,
OBJ_L1LIGHT,
OBJ_CANDLE1,
OBJ_CANDLE2,
OBJ_CANDLEO,
OBJ_CAULDRON,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_FLAMEHOLE,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_MCIRCLE1,
OBJ_MCIRCLE2,
OBJ_SKFIRE,
OBJ_SKPILE,
OBJ_SKSTICK1,
OBJ_SKSTICK2,
OBJ_SKSTICK3,
OBJ_SKSTICK4,
OBJ_SKSTICK5,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_SWITCHSKL,
OBJ_L1LIGHT,
OBJ_TRAPL,
OBJ_TRAPR,
OBJ_TORTURE1,
OBJ_TORTURE2,
OBJ_TORTURE3,
OBJ_TORTURE4,
OBJ_TORTURE5,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_NUDEW2R,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_TNUDEM1,
OBJ_TNUDEM2,
OBJ_TNUDEM3,
OBJ_TNUDEM4,
OBJ_TNUDEW1,
OBJ_TNUDEW2,
OBJ_TNUDEW3,
OBJ_CHEST1,
OBJ_CHEST1,
OBJ_CHEST1,
OBJ_CHEST2,
OBJ_CHEST2,
OBJ_CHEST2,
OBJ_CHEST3,
OBJ_CHEST3,
OBJ_CHEST3,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_PEDISTAL,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_ALTBOY,
OBJ_L1LIGHT,
OBJ_L1LIGHT,
OBJ_WARARMOR,
OBJ_WARWEAP,
OBJ_TORCHR2,
OBJ_TORCHL2,
OBJ_MUSHPATCH,
};
/** Contains the data related to each object ID. */

2
Source/objdat.h

@ -2,7 +2,7 @@
#ifndef __OBJDAT_H__
#define __OBJDAT_H__
extern int ObjTypeConv[113];
extern int ObjTypeConv[];
extern ObjDataStruct AllObjects[99];
extern char *ObjMasterLoadList[56];

244
Source/objects.cpp

@ -198,12 +198,13 @@ void InitRndLocBigObj(int min, int max, int objtype)
void InitRndLocObj5x5(int min, int max, int objtype)
{
BOOL exit;
int xp, yp, numobjs, i, k, m, n;
int xp, yp, numobjs, i, cnt, m, n;
numobjs = min + random_(139, max - min);
for (i = 0; i < numobjs; i++) {
k = 0;
for (;;) {
cnt = 0;
exit = FALSE;
while (!exit) {
exit = TRUE;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
@ -213,11 +214,11 @@ void InitRndLocObj5x5(int min, int max, int objtype)
exit = FALSE;
}
}
if (exit)
break;
k++;
if (k > 20000)
return;
if (!exit) {
cnt++;
if (cnt > 20000)
return;
}
}
AddObject(objtype, xp, yp);
}
@ -288,11 +289,12 @@ void AddCandles()
void AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, int y2, int msg)
{
BOOL exit;
int xp, yp, ob, k, m, n;
DIABOOL exit;
int xp, yp, ob, cnt, m, n;
k = 0;
for (;;) {
cnt = 0;
exit = FALSE;
while (!exit) {
exit = TRUE;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
@ -302,11 +304,11 @@ void AddBookLever(int lx1, int ly1, int lx2, int ly2, int x1, int y1, int x2, in
exit = FALSE;
}
}
if (exit)
break;
k++;
if (k > 20000)
return;
if (!exit) {
cnt++;
if (cnt > 20000)
return;
}
}
if (QuestStatus(Q_BLIND))
@ -621,7 +623,8 @@ void AddStoryBooks()
BOOL done;
cnt = 0;
while (TRUE) {
done = FALSE;
while (!done) {
done = TRUE;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
@ -631,11 +634,11 @@ void AddStoryBooks()
done = FALSE;
}
}
if (done)
break;
cnt++;
if (cnt > 20000)
return;
if (!done) {
cnt++;
if (cnt > 20000)
return;
}
}
AddObject(OBJ_STORYBOOK, xp, yp);
AddObject(OBJ_STORYCANDLE, xp - 2, yp + 1);
@ -709,8 +712,9 @@ void AddLazStand()
BOOL found;
cnt = 0;
while (TRUE) {
found = 1;
found = FALSE;
while (!found) {
found = TRUE;
xp = random_(139, 80) + 16;
yp = random_(139, 80) + 16;
for (yy = -3; yy <= 3; yy++) {
@ -719,13 +723,12 @@ void AddLazStand()
found = FALSE;
}
}
if (found)
break;
cnt++;
if (cnt > 10000) {
InitRndLocObj(1, 1, OBJ_LAZSTAND);
return;
if (!found) {
cnt++;
if (cnt > 10000) {
InitRndLocObj(1, 1, OBJ_LAZSTAND);
return;
}
}
}
AddObject(OBJ_LAZSTAND, xp, yp);
@ -831,9 +834,9 @@ void InitObjects()
InitRndBarrels();
AddL4Goodies();
}
InitRndLocObj(5, 10, 5);
InitRndLocObj(3, 6, 6);
InitRndLocObj(1, 5, 7);
InitRndLocObj(5, 10, OBJ_CHEST1);
InitRndLocObj(3, 6, OBJ_CHEST2);
InitRndLocObj(1, 5, OBJ_CHEST3);
if (leveltype != DTYPE_HELL)
AddObjTraps();
if (leveltype > DTYPE_CATHEDRAL)
@ -1106,7 +1109,8 @@ void AddBarrel(int i, int t)
void AddShrine(int i)
{
int val, j, slist[NUM_SHRINETYPE];
int val, j;
BOOL slist[NUM_SHRINETYPE];
object[i]._oPreFlag = TRUE;
for (j = 0; j < NUM_SHRINETYPE; j++) {
@ -1115,22 +1119,16 @@ void AddShrine(int i)
} else {
slist[j] = 1;
}
if (gbMaxPlayers != 1) {
if (shrineavail[j] == 1) {
slist[j] = 0;
}
} else {
if (shrineavail[j] == 2) {
slist[j] = 0;
}
if (gbMaxPlayers != 1 && shrineavail[j] == 1) {
slist[j] = 0;
}
}
while (1) {
val = random_(150, NUM_SHRINETYPE);
if (slist[val]) {
break;
if (gbMaxPlayers == 1 && shrineavail[j] == 2) {
slist[j] = 0;
}
}
do {
val = random_(150, NUM_SHRINETYPE);
} while (!slist[val]);
object[i]._oVar1 = val;
if (random_(150, 2)) {
@ -1478,8 +1476,8 @@ void Obj_Light(int i, int lr)
for (p = 0; p < MAX_PLRS && !turnon; p++) {
if (plr[p].plractive) {
if (currlevel == plr[p].plrlevel) {
dx = abs(plr[p].WorldX - ox);
dy = abs(plr[p].WorldY - oy);
dx = abs(plr[p]._px - ox);
dy = abs(plr[p]._py - oy);
if (dx < tr && dy < tr)
turnon = TRUE;
}
@ -1504,8 +1502,8 @@ void Obj_Circle(int i)
ox = object[i]._ox;
oy = object[i]._oy;
wx = plr[myplr].WorldX;
wy = plr[myplr].WorldY;
wx = plr[myplr]._px;
wy = plr[myplr]._py;
if (wx == ox && wy == oy) {
if (object[i]._otype == OBJ_MCIRCLE1)
object[i]._oAnimFrame = 2;
@ -1523,7 +1521,7 @@ void Obj_Circle(int i)
ObjChangeMapResync(object[i]._oVar1, object[i]._oVar2, object[i]._oVar3, object[i]._oVar4);
if (quests[Q_BETRAYER]._qactive == QUEST_ACTIVE)
quests[Q_BETRAYER]._qvar1 = 4;
AddMissile(plr[myplr].WorldX, plr[myplr].WorldY, 35, 46, plr[myplr]._pdir, MIS_RNDTELEPORT, 0, myplr, 0, 0);
AddMissile(plr[myplr]._px, plr[myplr]._py, 35, 46, plr[myplr]._pdir, MIS_RNDTELEPORT, 0, myplr, 0, 0);
track_repeat_walk(FALSE);
sgbMouseDown = 0;
ClrPlrPath(myplr);
@ -1549,21 +1547,21 @@ void Obj_StopAnim(int i)
void Obj_Door(int i)
{
int dx, dy;
BOOL dok;
if (!object[i]._oVar4) {
object[i]._oMissFlag = FALSE;
if (object[i]._oVar4 == 0) {
object[i]._oSelFlag = 3;
object[i]._oMissFlag = FALSE;
} else {
dy = object[i]._oy;
dx = object[i]._ox;
dy = object[i]._oy;
dok = !dMonster[dx][dy];
dok = dok & !dItem[dx][dy];
dok = dok & !dDead[dx][dy];
dok = dok & !dPlayer[dx][dy];
object[i]._oSelFlag = 2;
object[i]._oVar4 = dok ? 1 : 2;
object[i]._oMissFlag = TRUE;
object[i]._oVar4 = (((dItem[dx][dy] == 0 ? 1 : 0)
& (dDead[dx][dy] == 0 ? 1 : 0)
& (dPlayer[dx][dy] == 0 ? 1 : 0)
& (dMonster[dx][dy] == 0 ? 1 : 0))
== 0)
+ 1;
}
}
@ -1696,7 +1694,7 @@ void Obj_BCrossDamage(int i)
if (fire_resist > 0)
damage[leveltype - 1] -= fire_resist * damage[leveltype - 1] / 100;
if (plr[myplr].WorldX != object[i]._ox || plr[myplr].WorldY != object[i]._oy - 1)
if (plr[myplr]._px != object[i]._ox || plr[myplr]._py != object[i]._oy - 1)
return;
plr[myplr]._pHitPoints -= damage[leveltype - 1];
@ -1705,12 +1703,12 @@ void Obj_BCrossDamage(int i)
SyncPlrKill(myplr, 0);
} else {
if (plr[myplr]._pClass == PC_WARRIOR) {
PlaySfxLoc(PS_WARR68, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_WARR68, plr[myplr]._px, plr[myplr]._py);
#ifndef SPAWN
} else if (plr[myplr]._pClass == PC_ROGUE) {
PlaySfxLoc(PS_ROGUE68, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_ROGUE68, plr[myplr]._px, plr[myplr]._py);
} else if (plr[myplr]._pClass == PC_SORCERER) {
PlaySfxLoc(PS_MAGE68, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_MAGE68, plr[myplr]._px, plr[myplr]._py);
#endif
}
}
@ -1816,12 +1814,12 @@ void ObjSetMicro(int dx, int dy, int pn)
if (leveltype != DTYPE_HELL) {
v = (WORD *)pLevelPieces + 10 * pn;
for (i = 0; i < 10; i++) {
defs->mt[i] = SDL_SwapLE16(v[(i & 1) - (i & 0xE) + 8]);
defs->mt[i] = SDL_SwapLE16(v[(i & 1) - (i & 0xE) + 8]);
}
} else {
v = (WORD *)pLevelPieces + 16 * pn;
for (i = 0; i < 16; i++) {
defs->mt[i] = SDL_SwapLE16(v[(i & 1) - (i & 0xE) + 14]);
defs->mt[i] = SDL_SwapLE16(v[(i & 1) - (i & 0xE) + 14]);
}
}
}
@ -1982,7 +1980,7 @@ void RedoPlayerVision()
for (p = 0; p < MAX_PLRS; p++) {
if (plr[p].plractive && currlevel == plr[p].plrlevel) {
ChangeVisionXY(plr[p]._pvid, plr[p].WorldX, plr[p].WorldY);
ChangeVisionXY(plr[p]._pvid, plr[p]._px, plr[p]._py);
}
}
}
@ -2349,8 +2347,8 @@ void OperateL1Door(int pnum, int i, BOOL sendflag)
{
int dpx, dpy;
dpx = abs(object[i]._ox - plr[pnum].WorldX);
dpy = abs(object[i]._oy - plr[pnum].WorldY);
dpx = abs(object[i]._ox - plr[pnum]._px);
dpy = abs(object[i]._oy - plr[pnum]._py);
if (dpx == 1 && dpy <= 1 && object[i]._otype == OBJ_L1LDOOR)
OperateL1LDoor(pnum, i, sendflag);
if (dpx <= 1 && dpy == 1 && object[i]._otype == OBJ_L1RDOOR)
@ -2389,6 +2387,7 @@ void OperateBook(int pnum, int i)
{
int j, oi;
int dx, dy;
int otype;
BOOL do_add_missile, missile_added;
if (object[i]._oSelFlag == 0)
@ -2398,23 +2397,22 @@ void OperateBook(int pnum, int i)
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[oi]._oVar6 == 2) {
dx = 43;
dy = 29;
object[oi]._oVar6 = 4;
do_add_missile = TRUE;
}
otype = object[oi]._otype;
if (otype == OBJ_MCIRCLE2 && object[oi]._oVar6 == 1) {
dx = 27;
dy = 29;
object[oi]._oVar6 = 4;
do_add_missile = TRUE;
}
if (otype == OBJ_MCIRCLE2 && object[oi]._oVar6 == 2) {
dx = 43;
dy = 29;
object[oi]._oVar6 = 4;
do_add_missile = TRUE;
}
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);
AddMissile(plr[pnum]._px, plr[pnum]._py, dx, dy, plr[pnum]._pdir, MIS_RNDTELEPORT, 0, pnum, 0, 0);
missile_added = TRUE;
do_add_missile = FALSE;
}
@ -2422,8 +2420,8 @@ void OperateBook(int pnum, int i)
if (!missile_added)
return;
}
object[i]._oAnimFrame++;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame++;
if (!setlevel)
return;
@ -2436,8 +2434,8 @@ void OperateBook(int pnum, int i)
PlaySfxLoc(IS_QUESTDN, object[i]._ox, object[i]._oy);
InitDiabloMsg(EMSG_BONECHAMB);
AddMissile(
plr[myplr].WorldX,
plr[myplr].WorldY,
plr[myplr]._px,
plr[myplr]._py,
object[i]._ox - 2,
object[i]._oy - 4,
plr[myplr]._pdir,
@ -2536,8 +2534,8 @@ void OperateChest(int pnum, int i, BOOL sendmsg)
if (object[i]._oSelFlag != 0) {
if (!deltaload)
PlaySfxLoc(IS_CHEST, object[i]._ox, object[i]._oy);
object[i]._oAnimFrame += 2;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame += 2;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
if (setlevel) {
@ -2553,7 +2551,7 @@ void OperateChest(int pnum, int i, BOOL sendmsg)
}
}
if (object[i]._oTrapFlag && object[i]._otype >= OBJ_TCHEST1 && object[i]._otype <= OBJ_TCHEST3) {
mdir = GetDirection(object[i]._ox, object[i]._oy, plr[pnum].WorldX, plr[pnum].WorldY);
mdir = GetDirection(object[i]._ox, object[i]._oy, plr[pnum]._px, plr[pnum]._py);
switch (object[i]._oVar4) {
case 0:
mtype = MIS_ARROW;
@ -2565,7 +2563,7 @@ void OperateChest(int pnum, int i, BOOL sendmsg)
mtype = MIS_NOVA;
break;
}
AddMissile(object[i]._ox, object[i]._oy, plr[pnum].WorldX, plr[pnum].WorldY, mdir, mtype, 1, -1, 0, 0);
AddMissile(object[i]._ox, object[i]._oy, plr[pnum]._px, plr[pnum]._py, mdir, mtype, 1, -1, 0, 0);
object[i]._oTrapFlag = FALSE;
}
if (pnum == myplr)
@ -2626,8 +2624,8 @@ void OperateInnSignChest(int pnum, int i)
if (object[i]._oSelFlag != 0) {
if (!deltaload)
PlaySfxLoc(IS_CHEST, object[i]._ox, object[i]._oy);
object[i]._oAnimFrame += 2;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame += 2;
if (!deltaload) {
GetSuperItemLoc(object[i]._ox, object[i]._oy, &x, &y);
SpawnQuestItem(IDI_BANNER, x, y, 0, 0);
@ -2644,17 +2642,17 @@ void OperateSlainHero(int pnum, int i, BOOL sendmsg)
if (plr[pnum]._pClass == PC_WARRIOR) {
CreateMagicArmor(object[i]._ox, object[i]._oy, ITYPE_HARMOR, ICURS_BREAST_PLATE, FALSE, TRUE);
#ifndef SPAWN
PlaySfxLoc(PS_WARR9, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_WARR9, plr[myplr]._px, plr[myplr]._py);
#endif
} else if (plr[pnum]._pClass == PC_ROGUE) {
CreateMagicWeapon(object[i]._ox, object[i]._oy, ITYPE_BOW, ICURS_LONG_WAR_BOW, FALSE, TRUE);
#ifndef SPAWN
PlaySfxLoc(PS_ROGUE9, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_ROGUE9, plr[myplr]._px, plr[myplr]._py);
#endif
} else if (plr[pnum]._pClass == PC_SORCERER) {
CreateSpellBook(object[i]._ox, object[i]._oy, SPL_LIGHTNING, FALSE, TRUE);
#ifndef SPAWN
PlaySfxLoc(PS_MAGE9, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(PS_MAGE9, plr[myplr]._px, plr[myplr]._py);
#endif
}
if (pnum == myplr)
@ -2719,8 +2717,8 @@ void OperateL2Door(int pnum, int i, BOOL sendflag)
{
int dpx, dpy;
dpx = abs(object[i]._ox - plr[pnum].WorldX);
dpy = abs(object[i]._oy - plr[pnum].WorldY);
dpx = abs(object[i]._ox - plr[pnum]._px);
dpy = abs(object[i]._oy - plr[pnum]._py);
if (dpx == 1 && dpy <= 1 && object[i]._otype == OBJ_L2LDOOR)
OperateL2LDoor(pnum, i, sendflag);
if (dpx <= 1 && dpy == 1 && object[i]._otype == OBJ_L2RDOOR)
@ -2731,8 +2729,8 @@ void OperateL3Door(int pnum, int i, BOOL sendflag)
{
int dpx, dpy;
dpx = abs(object[i]._ox - plr[pnum].WorldX);
dpy = abs(object[i]._oy - plr[pnum].WorldY);
dpx = abs(object[i]._ox - plr[pnum]._px);
dpy = abs(object[i]._oy - plr[pnum]._py);
if (dpx == 1 && dpy <= 1 && object[i]._otype == OBJ_L3RDOOR)
OperateL3RDoor(pnum, i, sendflag);
if (dpx <= 1 && dpy == 1 && object[i]._otype == OBJ_L3LDOOR)
@ -2996,10 +2994,10 @@ void OperateShrine(int pnum, int i, int sType)
if (deltaload)
return;
AddMissile(
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._pdir,
MIS_MANASHIELD,
-1,
@ -3126,10 +3124,10 @@ void OperateShrine(int pnum, int i, int sType)
if (deltaload)
return;
AddMissile(
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._pdir,
MIS_NOVA,
-1,
@ -3224,7 +3222,7 @@ void OperateShrine(int pnum, int i, int sType)
break;
lv = dPiece[xx][yy];
} while (nSolidTable[lv] || dObject[xx][yy] || dMonster[xx][yy]);
AddMissile(plr[pnum].WorldX, plr[pnum].WorldY, xx, yy, plr[pnum]._pdir, MIS_RNDTELEPORT, -1, pnum, 0, 2 * leveltype);
AddMissile(plr[pnum]._px, plr[pnum]._py, xx, yy, plr[pnum]._pdir, MIS_RNDTELEPORT, -1, pnum, 0, 2 * leveltype);
if (pnum != myplr)
return;
InitDiabloMsg(EMSG_SHRINE_HOLY);
@ -3424,8 +3422,8 @@ void OperateSkelBook(int pnum, int i, BOOL sendmsg)
if (object[i]._oSelFlag != 0) {
if (!deltaload)
PlaySfxLoc(IS_ISCROL, object[i]._ox, object[i]._oy);
object[i]._oAnimFrame += 2;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame += 2;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
if (random_(161, 5))
@ -3443,8 +3441,8 @@ void OperateBookCase(int pnum, int i, BOOL sendmsg)
if (object[i]._oSelFlag != 0) {
if (!deltaload)
PlaySfxLoc(IS_ISCROL, object[i]._ox, object[i]._oy);
object[i]._oAnimFrame -= 2;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame -= 2;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
CreateTypeItem(object[i]._ox, object[i]._oy, FALSE, ITYPE_MISC, IMISC_BOOK, sendmsg, FALSE);
@ -3481,8 +3479,8 @@ void OperateArmorStand(int pnum, int i, BOOL sendmsg)
BOOL uniqueRnd;
if (object[i]._oSelFlag != 0) {
object[i]._oAnimFrame++;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame++;
if (!deltaload) {
SetRndSeed(object[i]._oRndSeed);
uniqueRnd = random_(0, 2);
@ -3603,10 +3601,10 @@ BOOL OperateFountains(int pnum, int i)
if (deltaload)
return FALSE;
AddMissile(
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum].WorldX,
plr[pnum].WorldY,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._px,
plr[pnum]._py,
plr[pnum]._pdir,
MIS_INFRA,
-1,
@ -3690,8 +3688,8 @@ void OperateWeaponRack(int pnum, int i, BOOL sendmsg)
break;
}
object[i]._oAnimFrame++;
object[i]._oSelFlag = 0;
object[i]._oAnimFrame++;
if (deltaload)
return;
@ -3860,9 +3858,7 @@ void SyncOpL1Door(int pnum, int cmd, int i)
return;
do_sync = FALSE;
if (cmd == CMD_OPENDOOR) {
if (object[i]._oVar4 != 0)
return;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0) {
do_sync = TRUE;
}
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)
@ -3883,9 +3879,7 @@ void SyncOpL2Door(int pnum, int cmd, int i)
return;
do_sync = FALSE;
if (cmd == CMD_OPENDOOR) {
if (object[i]._oVar4 != 0)
return;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0) {
do_sync = TRUE;
}
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)
@ -3906,9 +3900,7 @@ void SyncOpL3Door(int pnum, int cmd, int i)
return;
do_sync = FALSE;
if (cmd == CMD_OPENDOOR) {
if (object[i]._oVar4 != 0)
return;
if (cmd == CMD_OPENDOOR && object[i]._oVar4 == 0) {
do_sync = TRUE;
}
if (cmd == CMD_CLOSEDOOR && object[i]._oVar4 == 1)

8
Source/pack.cpp

@ -45,8 +45,8 @@ void PackPlayer(PkPlayerStruct *pPack, int pnum, BOOL manashield)
pPack->destParam1 = pPlayer->destParam1;
pPack->destParam2 = pPlayer->destParam2;
pPack->plrlevel = pPlayer->plrlevel;
pPack->px = pPlayer->WorldX;
pPack->py = pPlayer->WorldY;
pPack->px = pPlayer->_px;
pPack->py = pPlayer->_py;
pPack->targx = pPlayer->_ptargx;
pPack->targy = pPlayer->_ptargy;
strcpy(pPack->pName, pPlayer->_pName);
@ -174,10 +174,10 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, BOOL killok)
pPlayer = &plr[pnum];
ClearPlrRVars(pPlayer);
pPlayer->WorldX = pPack->px;
pPlayer->WorldY = pPack->py;
pPlayer->_px = pPack->px;
pPlayer->_py = pPack->py;
pPlayer->_pfutx = pPack->px;
pPlayer->_pfuty = pPack->py;
pPlayer->_ptargx = pPack->targx;
pPlayer->_ptargy = pPack->targy;
pPlayer->plrlevel = pPack->plrlevel;

8
Source/palette.cpp

@ -42,8 +42,8 @@ void ApplyGamma(SDL_Color *dst, const SDL_Color *src, int n)
void SaveGamma()
{
SRegSaveValue("Diablo", "Gamma Correction", 0, gamma_correction);
SRegSaveValue("Diablo", "Color Cycling", FALSE, color_cycling_enabled);
SRegSaveValue(APP_NAME, "Gamma Correction", 0, gamma_correction);
SRegSaveValue(APP_NAME, "Color Cycling", FALSE, color_cycling_enabled);
}
static void LoadGamma()
@ -52,7 +52,7 @@ static void LoadGamma()
int value;
value = gamma_correction;
if (!SRegLoadValue("Diablo", "Gamma Correction", 0, &value))
if (!SRegLoadValue(APP_NAME, "Gamma Correction", 0, &value))
value = 100;
gamma_value = value;
if (value < 30) {
@ -61,7 +61,7 @@ static void LoadGamma()
gamma_value = 100;
}
gamma_correction = gamma_value - gamma_value % 5;
if (!SRegLoadValue("Diablo", "Color Cycling", 0, &value))
if (!SRegLoadValue(APP_NAME, "Color Cycling", 0, &value))
value = 1;
color_cycling_enabled = value;
}

451
Source/player.cpp

File diff suppressed because it is too large Load Diff

8
Source/quests.cpp

@ -10,8 +10,8 @@ int qline;
int qlist[MAXQUESTS];
int numqlines;
int WaterDone;
int ReturnLvlY;
int ReturnLvlX;
int ReturnLvlY;
int ReturnLvlT;
int ReturnLvl;
@ -180,7 +180,7 @@ void CheckQuests()
&& nummonsters == 4
&& quests[Q_PWATER]._qactive != QUEST_DONE) {
quests[Q_PWATER]._qactive = QUEST_DONE;
PlaySfxLoc(IS_QUESTDN, plr[myplr].WorldX, plr[myplr].WorldY);
PlaySfxLoc(IS_QUESTDN, plr[myplr]._px, plr[myplr]._py);
LoadPalette("Levels\\L3Data\\L3pwater.pal");
WaterDone = 32;
}
@ -193,8 +193,8 @@ void CheckQuests()
if (currlevel == quests[i]._qlevel
&& quests[i]._qslvl != 0
&& quests[i]._qactive != QUEST_NOTAVAIL
&& plr[myplr].WorldX == quests[i]._qtx
&& plr[myplr].WorldY == quests[i]._qty) {
&& plr[myplr]._px == quests[i]._qtx
&& plr[myplr]._py == quests[i]._qty) {
if (quests[i]._qlvltype != DTYPE_NONE) {
setlvltype = quests[i]._qlvltype;
}

2
Source/quests.h

@ -10,8 +10,8 @@ extern int qline;
extern int qlist[MAXQUESTS];
extern int numqlines;
extern int WaterDone;
extern int ReturnLvlY;
extern int ReturnLvlX;
extern int ReturnLvlY;
extern int ReturnLvlT;
extern int ALLQUESTS;
extern int ReturnLvl;

10
Source/scrollrt.cpp

@ -139,7 +139,7 @@ static void scrollrt_draw_cursor_item()
int i, mx, my, col;
BYTE *src, *dst;
assert(! sgdwCursWdt);
assert(!sgdwCursWdt);
if (pcurs <= CURSOR_NONE || cursW == 0 || cursH == 0) {
return;
@ -433,7 +433,7 @@ void DrawDeadPlayer(int x, int y, int sx, int sy)
for (i = 0; i < MAX_PLRS; i++) {
p = &plr[i];
if (p->plractive && !p->_pHitPoints && p->plrlevel == (BYTE)currlevel && p->WorldX == x && p->WorldY == y) {
if (p->plractive && !p->_pHitPoints && p->plrlevel == (BYTE)currlevel && p->_px == x && p->_py == y) {
pCelBuff = p->_pAnimData;
if (!pCelBuff) {
// app_fatal("Drawing dead player %d \"%s\": NULL Cel Buffer", i, p->_pName);
@ -723,7 +723,7 @@ static void scrollrt_draw_dungeon(int sx, int sy, int dx, int dy)
DrawObject(sx, sy, dx, dy, 1);
DrawItem(sx, sy, dx, dy, 1);
if (bFlag & BFLAG_PLAYERLR) {
assert((DWORD)(sy-1) < MAXDUNY);
assert((DWORD)(sy - 1) < MAXDUNY);
DrawPlayerHelper(sx, sy, -1, dx, dy);
}
if (bFlag & BFLAG_MONSTLR && negMon < 0) {
@ -1042,7 +1042,7 @@ void DrawView(int StartX, int StartY)
DrawQuestLog();
}
if (!chrflag && plr[myplr]._pStatPts != 0 && !spselflag
&& (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) {
&& (!questlog || SCREEN_HEIGHT >= SPANEL_HEIGHT + PANEL_HEIGHT + 74 || SCREEN_WIDTH >= 4 * SPANEL_WIDTH)) {
DrawLevelUpIcon();
}
if (uitemflag) {
@ -1317,7 +1317,7 @@ void scrollrt_draw_game_screen(BOOL draw_cursor)
unlock_buf(0);
}
DrawMain(hgt, 0, 0, 0, 0, 0);
DrawMain(hgt, FALSE, FALSE, FALSE, FALSE, FALSE);
if (draw_cursor) {
lock_buf(0);

30
Source/setmaps.cpp

@ -3,17 +3,17 @@
DEVILUTION_BEGIN_NAMESPACE
// BUGFIX: constant data should be const
BYTE SkelKingTrans1[8] = {
BYTE SkelKingTrans1[] = {
19, 47, 26, 55,
26, 49, 30, 53
};
BYTE SkelKingTrans2[8] = {
BYTE SkelKingTrans2[] = {
33, 19, 47, 29,
37, 29, 43, 39
};
BYTE SkelKingTrans3[20] = {
BYTE SkelKingTrans3[] = {
27, 53, 35, 61,
27, 35, 34, 42,
45, 35, 53, 43,
@ -21,7 +21,7 @@ BYTE SkelKingTrans3[20] = {
31, 39, 49, 57
};
BYTE SkelKingTrans4[28] = {
BYTE SkelKingTrans4[] = {
49, 45, 58, 51,
57, 31, 62, 37,
63, 31, 69, 40,
@ -31,7 +31,7 @@ BYTE SkelKingTrans4[28] = {
79, 43, 89, 53
};
BYTE SkelChamTrans1[20] = {
BYTE SkelChamTrans1[] = {
43, 19, 50, 26,
51, 19, 59, 26,
35, 27, 42, 34,
@ -39,12 +39,12 @@ BYTE SkelChamTrans1[20] = {
50, 27, 59, 34
};
BYTE SkelChamTrans2[8] = {
BYTE SkelChamTrans2[] = {
19, 31, 34, 47,
34, 35, 42, 42
};
BYTE SkelChamTrans3[36] = {
BYTE SkelChamTrans3[] = {
43, 35, 50, 42,
51, 35, 62, 42,
63, 31, 66, 46,
@ -63,7 +63,7 @@ char *quest_level_names[] = {
"Bone Chamber",
"Maze",
"Poisoned Water Supply",
"Archbishop Lazarus' Lair"
"Archbishop Lazarus' Lair",
};
int ObjIndex(int x, int y)
@ -142,10 +142,10 @@ void LoadSetMap()
LoadPreL1Dungeon("Levels\\L1Data\\SklKng1.DUN", 83, 45);
LoadL1Dungeon("Levels\\L1Data\\SklKng2.DUN", 83, 45);
LoadPalette("Levels\\L1Data\\L1_2.pal");
DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, SkelKingTrans1);
DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, SkelKingTrans2);
DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, SkelKingTrans3);
DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, SkelKingTrans4);
DRLG_AreaTrans(sizeof(SkelKingTrans1) / 4, &SkelKingTrans1[0]);
DRLG_ListTrans(sizeof(SkelKingTrans2) / 4, &SkelKingTrans2[0]);
DRLG_AreaTrans(sizeof(SkelKingTrans3) / 4, &SkelKingTrans3[0]);
DRLG_ListTrans(sizeof(SkelKingTrans4) / 4, &SkelKingTrans4[0]);
AddL1Objs(0, 0, MAXDUNX, MAXDUNY);
AddSKingObjs();
InitSKingTriggers();
@ -154,9 +154,9 @@ void LoadSetMap()
LoadPreL2Dungeon("Levels\\L2Data\\Bonecha2.DUN", 69, 39);
LoadL2Dungeon("Levels\\L2Data\\Bonecha1.DUN", 69, 39);
LoadPalette("Levels\\L2Data\\L2_2.pal");
DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, SkelChamTrans1);
DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, SkelChamTrans2);
DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, SkelChamTrans3);
DRLG_ListTrans(sizeof(SkelChamTrans1) / 4, &SkelChamTrans1[0]);
DRLG_AreaTrans(sizeof(SkelChamTrans2) / 4, &SkelChamTrans2[0]);
DRLG_ListTrans(sizeof(SkelChamTrans3) / 4, &SkelChamTrans3[0]);
AddL2Objs(0, 0, MAXDUNX, MAXDUNY);
AddSChamObjs();
InitSChambTriggers();

14
Source/spells.cpp

@ -148,8 +148,8 @@ static void PlacePlayer(int pnum)
if (plr[pnum].plrlevel == currlevel) {
for (i = 0; i < 8; i++) {
nx = plr[pnum].WorldX + plrxoff2[i];
ny = plr[pnum].WorldY + plryoff2[i];
nx = plr[pnum]._px + plrxoff2[i];
ny = plr[pnum]._py + plryoff2[i];
if (PosOkPlayer(pnum, nx, ny)) {
break;
@ -161,10 +161,10 @@ static void PlacePlayer(int pnum)
for (max = 1, min = -1; min > -50 && !done; max++, min--) {
for (y = min; y <= max && !done; y++) {
ny = plr[pnum].WorldY + y;
ny = plr[pnum]._py + y;
for (x = min; x <= max && !done; x++) {
nx = plr[pnum].WorldX + x;
nx = plr[pnum]._px + x;
if (PosOkPlayer(pnum, nx, ny)) {
done = TRUE;
@ -174,8 +174,8 @@ static void PlacePlayer(int pnum)
}
}
plr[pnum].WorldX = nx;
plr[pnum].WorldY = ny;
plr[pnum]._px = nx;
plr[pnum]._py = ny;
dPlayer[nx][ny] = pnum + 1;
@ -195,7 +195,7 @@ void DoResurrect(int pnum, int rid)
int hp;
if ((char)rid != -1) {
AddMissile(plr[rid].WorldX, plr[rid].WorldY, plr[rid].WorldX, plr[rid].WorldY, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0);
AddMissile(plr[rid]._px, plr[rid]._py, plr[rid]._px, plr[rid]._py, 0, MIS_RESURRECTBEAM, 0, pnum, 0, 0);
}
if (pnum == myplr) {

10
Source/sync.cpp

@ -29,7 +29,7 @@ DWORD sync_all_monsters(const BYTE *pbBuf, DWORD dwMaxLen)
pHdr->bLevel = currlevel;
pHdr->wLen = 0;
SyncPlrInv(pHdr);
/// ASSERT: assert(dwMaxLen <= 0xffff);
assert(dwMaxLen <= 0xffff);
sync_one_monster();
for (i = 0; i < nummonsters && dwMaxLen >= sizeof(TSyncMonster); i++) {
@ -57,7 +57,7 @@ void sync_one_monster()
for (i = 0; i < nummonsters; i++) {
m = monstactive[i];
sync_word_6AA708[m] = abs(plr[myplr].WorldX - monster[m]._mx) + abs(plr[myplr].WorldY - monster[m]._my);
sync_word_6AA708[m] = abs(plr[myplr]._px - monster[m]._mx) + abs(plr[myplr]._py - monster[m]._my);
if (monster[m]._msquelch == 0) {
sync_word_6AA708[m] += 0x1000;
} else if (sgwLRU[m] != 0) {
@ -170,7 +170,7 @@ void SyncPlrInv(TSyncHeader *pHdr)
pHdr->bItemI = -1;
}
/// ASSERT: assert((DWORD) sgnSyncPInv < NUM_INVLOC);
assert((DWORD)sgnSyncPInv < NUM_INVLOC);
pItem = &plr[myplr].InvBody[sgnSyncPInv];
if (pItem->_itype != ITYPE_NONE) {
pHdr->bPInvLoc = sgnSyncPInv;
@ -217,7 +217,7 @@ DWORD sync_update(int pnum, const BYTE *pbBuf)
pbBuf += sizeof(TSyncMonster);
}
/// ASSERT: assert(wLen == 0);
assert(wLen == 0);
return pHdr->wLen + sizeof(*pHdr);
}
@ -239,7 +239,7 @@ void sync_monster(int pnum, const TSyncMonster *p)
}
}
delta = abs(plr[myplr].WorldX - monster[ndx]._mx) + abs(plr[myplr].WorldY - monster[ndx]._my);
delta = abs(plr[myplr]._px - monster[ndx]._mx) + abs(plr[myplr]._py - monster[ndx]._my);
if (delta > 255) {
delta = 255;
}

2
Source/textdat.cpp

@ -785,7 +785,7 @@ const TextDataStruct alltext[] = {
1, 3, PS_NAR9 },
#endif
{ "Thank goodness you've returned!\nMuch has changed since you lived here, my friend. All was peaceful until the dark riders came and destroyed our village. Many were cut down where they stood, and those who took up arms were slain or dragged away to become slaves - or worse. The church at the edge of town has been desecrated and is being used for dark rituals. The screams that echo in the night are inhuman, but some of our townsfolk may yet survive. Follow the path that lies between my tavern and the blacksmith shop to find the church and save who you can. \n \nPerhaps I can tell you more if we speak again. Good luck.|",
1, 5, TSFX_TAVERN0 }
1, 5, TSFX_TAVERN0 },
};
/** unused */
const DWORD gdwAllTextEntries = 259;

2
Source/textdat.h

@ -2,7 +2,7 @@
#ifndef __TEXTDAT_H__
#define __TEXTDAT_H__
extern const TextDataStruct alltext[259];
extern const TextDataStruct alltext[];
extern const DWORD gdwAllTextEntries;
#endif /* __TEXTDAT_H__ */

2
Source/themes.cpp

@ -990,7 +990,7 @@ void UpdateL4Trans()
for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) {
if (dTransVal[i][j]) {
if (dTransVal[i][j] != 0) {
dTransVal[i][j] = 1;
}
}

2
Source/tmsg.cpp

@ -40,7 +40,7 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen)
void tmsg_start()
{
assert(! sgpTimedMsgHead);
assert(!sgpTimedMsgHead);
}
void tmsg_cleanup()

74
Source/towners.cpp

@ -93,7 +93,7 @@ int TownCowY[3] = { 16, 14, 20 };
int TownCowDir[3] = { 1, 3, 4 };
int cowoffx[8] = { -1, 0, -1, -1, -1, 0, -1, -1 };
int cowoffy[8] = { -1, -1, -1, 0, -1, -1, -1, 0 };
QuestTalkData Qtalklist[11] = {
QuestTalkData Qtalklist[] = {
// clang-format off
// _qinfra, _qblkm, _qgarb, _qzhar, _qveil, _qmod, _qbutch, _qbol, _qblind, _qblood, _qanvil, _qwarlrd, _qking, _qpw, _qbone, _qvb
{ TEXT_INFRA6, TEXT_MUSH6, -1, -1, TEXT_VEIL5, -1, TEXT_BUTCH5, TEXT_BANNER6, TEXT_BLIND5, TEXT_BLOOD5, TEXT_ANVIL6, TEXT_WARLRD5, TEXT_KING7, TEXT_POISON7, TEXT_BONE5, TEXT_VILE9 },
@ -328,7 +328,7 @@ void InitCows()
int x, y, xo, yo;
//if ( pCowCels )
// assertion_failed(__LINE__, __FILE__, "! pCowCels");
// assertion_failed(__LINE__, __FILE__, "! pCowCels");
pCowCels = LoadFileInMem("Towners\\Animals\\Cow.CEL", NULL);
for (i = 0; i < 3; i++) {
x = TownCowX[i];
@ -395,8 +395,8 @@ void TownCtrlMsg(int i)
if (towner[i]._tbtcnt) {
p = towner[i]._tVar1;
dx = abs(towner[i]._tx - plr[p].WorldX);
dy = abs(towner[i]._ty - plr[p].WorldY);
dx = abs(towner[i]._tx - plr[p]._px);
dy = abs(towner[i]._ty - plr[p]._py);
if (dx >= 2 || dy >= 2)
towner[i]._tbtcnt = 0;
if (!towner[i]._tbtcnt) {
@ -429,12 +429,13 @@ void TownDead()
tidx = GetActiveTowner(TOWN_DEADGUY);
TownCtrlMsg(tidx);
if (!qtextflag) {
if ((quests[Q_BUTCHER]._qactive != QUEST_ACTIVE || quests[Q_BUTCHER]._qlog) && quests[Q_BUTCHER]._qactive != QUEST_INIT) {
if (quests[Q_BUTCHER]._qactive == QUEST_ACTIVE && quests[Q_BUTCHER]._qlog == 0) {
return;
}
if (quests[Q_BUTCHER]._qactive != QUEST_INIT) {
towner[tidx]._tAnimDelay = 1000;
towner[tidx]._tAnimFrame = 1;
strcpy(towner[tidx]._tName, "Slain Townsman");
} else {
return;
}
}
if (quests[Q_BUTCHER]._qactive != QUEST_INIT)
@ -582,8 +583,8 @@ void TalkToTowner(int p, int t)
rv2 = random_(6, 4); /* unused */
rv3 = random_(6, 5); /* unused */
dx = abs(plr[p].WorldX - towner[t]._tx);
dy = abs(plr[p].WorldY - towner[t]._ty);
dx = abs(plr[p]._px - towner[t]._tx);
dy = abs(plr[p]._py - towner[t]._ty);
#ifdef _DEBUG
if (!debug_mode_key_d && (dx >= 2 || dy >= 2)) {
return;
@ -648,15 +649,17 @@ void TalkToTowner(int p, int t)
InitQTextMsg(TEXT_BANNER2);
towner[t]._tMsgSaid = TRUE;
}
if (quests[Q_LTBANNER]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, &i) != NULL && !towner[t]._tMsgSaid) {
quests[Q_LTBANNER]._qactive = QUEST_DONE;
quests[Q_LTBANNER]._qvar1 = 3;
RemoveInvItem(p, i);
CreateItem(UITEM_HARCREST, towner[t]._tx, towner[t]._ty + 1);
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_BANNER3);
towner[t]._tMsgSaid = TRUE;
if (quests[Q_LTBANNER]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, &i) != NULL) {
if (!towner[t]._tMsgSaid) {
quests[Q_LTBANNER]._qactive = QUEST_DONE;
quests[Q_LTBANNER]._qvar1 = 3;
RemoveInvItem(p, i);
CreateItem(UITEM_HARCREST, towner[t]._tx, towner[t]._ty + 1);
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_BANNER3);
towner[t]._tMsgSaid = TRUE;
}
}
}
if (!qtextflag) {
@ -712,16 +715,18 @@ void TalkToTowner(int p, int t)
InitQTextMsg(TEXT_INFRA5);
towner[t]._tMsgSaid = TRUE;
}
if (quests[Q_ROCK]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, &i) != NULL && !towner[t]._tMsgSaid) {
quests[Q_ROCK]._qactive = QUEST_DONE;
quests[Q_ROCK]._qvar2 = 2;
quests[Q_ROCK]._qvar1 = 2;
RemoveInvItem(p, i);
CreateItem(UITEM_INFRARING, towner[t]._tx, towner[t]._ty + 1);
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_INFRA7);
towner[t]._tMsgSaid = TRUE;
if (quests[Q_ROCK]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, &i) != NULL) {
if (!towner[t]._tMsgSaid) {
quests[Q_ROCK]._qactive = QUEST_DONE;
quests[Q_ROCK]._qvar2 = 2;
quests[Q_ROCK]._qvar1 = 2;
RemoveInvItem(p, i);
CreateItem(UITEM_INFRARING, towner[t]._tx, towner[t]._ty + 1);
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_INFRA7);
towner[t]._tMsgSaid = TRUE;
}
}
}
if (plr[p]._pLvlVisited[9] && quests[Q_ANVIL]._qactive != QUEST_NOTAVAIL) {
@ -877,16 +882,16 @@ void TalkToTowner(int p, int t)
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_VILE1);
towner[t]._tMsgSaid = TRUE;
quests[Q_BETRAYER]._qactive = QUEST_ACTIVE;
quests[Q_BETRAYER]._qlog = TRUE;
towner[t]._tMsgSaid = TRUE;
} else if (quests[Q_BETRAYER]._qactive == QUEST_DONE && quests[Q_BETRAYER]._qvar1 == 7) {
quests[Q_BETRAYER]._qvar1 = 8;
towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p;
InitQTextMsg(TEXT_VILE3);
quests[Q_DIABLO]._qlog = TRUE;
towner[t]._tMsgSaid = TRUE;
quests[Q_DIABLO]._qlog = TRUE;
}
}
if (gbMaxPlayers != 1) {
@ -914,8 +919,9 @@ void TalkToTowner(int p, int t)
StartStore(STORE_STORY);
}
}
} else if (towner[t]._ttype == TOWN_COW && !qtextflag) {
CowSFX(p);
} else if (towner[t]._ttype == TOWN_COW) {
if (!qtextflag)
CowSFX(p);
}
}
@ -932,7 +938,7 @@ void CowSFX(int pnum)
}
#else
if (sgdwCowClicks >= 8) {
PlaySfxLoc(TSFX_COW1, plr[pnum].WorldX, plr[pnum].WorldY + 5);
PlaySfxLoc(TSFX_COW1, plr[pnum]._px, plr[pnum]._py + 5);
sgdwCowClicks = 4;
CowPlaying = snSFX[sgnCowMsg][plr[pnum]._pClass]; /* snSFX is local */
sgnCowMsg++;
@ -942,7 +948,7 @@ void CowSFX(int pnum)
CowPlaying = sgdwCowClicks == 4 ? TSFX_COW2 : TSFX_COW1;
}
#endif
PlaySfxLoc(CowPlaying, plr[pnum].WorldX, plr[pnum].WorldY);
PlaySfxLoc(CowPlaying, plr[pnum]._px, plr[pnum]._py);
}
}

2
Source/towners.h

@ -40,6 +40,6 @@ void CowSFX(int pnum);
/* data */
extern QuestTalkData Qtalklist[11];
extern QuestTalkData Qtalklist[];
#endif /* __TOWNERS_H__ */

16
Source/trigs.cpp

@ -653,7 +653,7 @@ void CheckTriggers()
return;
for (i = 0; i < numtrigs; i++) {
if (plr[myplr].WorldX != trigs[i]._tx || plr[myplr].WorldY != trigs[i]._ty) {
if (plr[myplr]._px != trigs[i]._tx || plr[myplr]._py != trigs[i]._ty) {
continue;
}
@ -661,7 +661,7 @@ void CheckTriggers()
case WM_DIABNEXTLVL:
#ifdef SPAWN
if (currlevel >= 2) {
NetSendCmdLoc(TRUE, CMD_WALKXY, plr[myplr].WorldX, plr[myplr].WorldY + 1);
NetSendCmdLoc(TRUE, CMD_WALKXY, plr[myplr]._px, plr[myplr]._py + 1);
PlaySFX(PS_WARR18);
InitDiabloMsg(EMSG_NOT_IN_SHAREWARE);
} else {
@ -687,22 +687,22 @@ void CheckTriggers()
if (trigs[i]._tlvl == 5 && plr[myplr]._pLevel < 8) {
abort = TRUE;
x = plr[myplr].WorldX;
y = plr[myplr].WorldY + 1;
x = plr[myplr]._px;
y = plr[myplr]._py + 1;
abortflag = EMSG_REQUIRES_LVL_8;
}
if (trigs[i]._tlvl == 9 && plr[myplr]._pLevel < 13) {
abort = TRUE;
x = plr[myplr].WorldX + 1;
y = plr[myplr].WorldY;
x = plr[myplr]._px + 1;
y = plr[myplr]._py;
abortflag = EMSG_REQUIRES_LVL_13;
}
if (trigs[i]._tlvl == 13 && plr[myplr]._pLevel < 17) {
abort = TRUE;
x = plr[myplr].WorldX;
y = plr[myplr].WorldY + 1;
x = plr[myplr]._px;
y = plr[myplr]._py + 1;
abortflag = EMSG_REQUIRES_LVL_17;
}

4
Source/wave.cpp

@ -3,9 +3,9 @@
DEVILUTION_BEGIN_NAMESPACE
BOOL WCloseFile(HANDLE file)
void WCloseFile(HANDLE file)
{
return SFileCloseFile(file);
SFileCloseFile(file);
}
LONG WGetFileSize(HANDLE hsFile, DWORD *lpFileSizeHigh, const char *FileName)

2
Source/wave.h

@ -2,7 +2,7 @@
#ifndef __WAVE_H__
#define __WAVE_H__
BOOL WCloseFile(HANDLE file);
void WCloseFile(HANDLE file);
LONG WGetFileSize(HANDLE hsFile, DWORD *lpFileSizeHigh, const char *FileName);
void WGetFileArchive(HANDLE hsFile, DWORD *retry, const char *FileName);
BOOL WOpenFile(const char *FileName, HANDLE *phsFile, BOOL mayNotExist);

35
SourceT/effects_test.cpp

@ -1,9 +1,10 @@
#include <gtest/gtest.h>
#include "all.h"
TEST(Drlg_l4, calc_snd_position_center) {
dvl::plr[dvl::myplr].WorldX = 50;
dvl::plr[dvl::myplr].WorldY = 50;
TEST(Drlg_l4, calc_snd_position_center)
{
dvl::plr[dvl::myplr]._px = 50;
dvl::plr[dvl::myplr]._py = 50;
int plVolume = 0;
int plPan = 0;
EXPECT_EQ(dvl::calc_snd_position(50, 50, &plVolume, &plPan), true);
@ -11,9 +12,10 @@ TEST(Drlg_l4, calc_snd_position_center) {
EXPECT_EQ(plPan, 0);
}
TEST(Drlg_l4, calc_snd_position_near) {
dvl::plr[dvl::myplr].WorldX = 50;
dvl::plr[dvl::myplr].WorldY = 50;
TEST(Drlg_l4, calc_snd_position_near)
{
dvl::plr[dvl::myplr]._px = 50;
dvl::plr[dvl::myplr]._py = 50;
int plVolume = 0;
int plPan = 0;
EXPECT_EQ(dvl::calc_snd_position(55, 50, &plVolume, &plPan), true);
@ -21,9 +23,10 @@ TEST(Drlg_l4, calc_snd_position_near) {
EXPECT_EQ(plPan, 1280);
}
TEST(Drlg_l4, calc_snd_position_out_of_range) {
dvl::plr[dvl::myplr].WorldX = 12;
dvl::plr[dvl::myplr].WorldY = 12;
TEST(Drlg_l4, calc_snd_position_out_of_range)
{
dvl::plr[dvl::myplr]._px = 12;
dvl::plr[dvl::myplr]._py = 12;
int plVolume = 0;
int plPan = 0;
EXPECT_EQ(dvl::calc_snd_position(112, 112, &plVolume, &plPan), false);
@ -31,9 +34,10 @@ TEST(Drlg_l4, calc_snd_position_out_of_range) {
EXPECT_EQ(plPan, 0);
}
TEST(Drlg_l4, calc_snd_position_extream_right) {
dvl::plr[dvl::myplr].WorldX = 50;
dvl::plr[dvl::myplr].WorldY = 50;
TEST(Drlg_l4, calc_snd_position_extream_right)
{
dvl::plr[dvl::myplr]._px = 50;
dvl::plr[dvl::myplr]._py = 50;
int plVolume = 0;
int plPan = 0;
EXPECT_EQ(dvl::calc_snd_position(76, 50, &plVolume, &plPan), false);
@ -41,9 +45,10 @@ TEST(Drlg_l4, calc_snd_position_extream_right) {
EXPECT_GT(plPan, 6400);
}
TEST(Drlg_l4, calc_snd_position_extream_left) {
dvl::plr[dvl::myplr].WorldX = 50;
dvl::plr[dvl::myplr].WorldY = 50;
TEST(Drlg_l4, calc_snd_position_extream_left)
{
dvl::plr[dvl::myplr]._px = 50;
dvl::plr[dvl::myplr]._py = 50;
int plVolume = 0;
int plPan = 0;
EXPECT_EQ(dvl::calc_snd_position(24, 50, &plVolume, &plPan), false);

47
SourceX/controls/plrctrls.cpp

@ -44,11 +44,11 @@ int GetRotaryDistance(int x, int y)
{
int d, d1, d2;
if (plr[myplr]._px == x && plr[myplr]._py == y)
if (plr[myplr]._pfutx == x && plr[myplr]._pfuty == y)
return -1;
d1 = plr[myplr]._pdir;
d2 = GetDirection(plr[myplr]._px, plr[myplr]._py, x, y);
d2 = GetDirection(plr[myplr]._pfutx, plr[myplr]._pfuty, x, y);
d = abs(d1 - d2);
if (d > 4)
@ -64,7 +64,7 @@ int GetRotaryDistance(int x, int y)
*/
int GetMinDistance(int dx, int dy)
{
return std::max(abs(plr[myplr]._px - dx), abs(plr[myplr]._py - dy));
return std::max(abs(plr[myplr]._pfutx - dx), abs(plr[myplr]._pfuty - dy));
}
/**
@ -81,7 +81,7 @@ int GetDistance(int dx, int dy, int maxDistance)
}
char walkpath[MAX_PATH_LENGTH];
int steps = FindPath(PosOkPlayer, myplr, plr[myplr]._px, plr[myplr]._py, dx, dy, walkpath);
int steps = FindPath(PosOkPlayer, myplr, plr[myplr]._pfutx, plr[myplr]._pfuty, dx, dy, walkpath);
if (steps > maxDistance)
return 0;
@ -95,16 +95,16 @@ int GetDistance(int dx, int dy, int maxDistance)
*/
int GetDistanceRanged(int dx, int dy)
{
int a = plr[myplr]._px - dx;
int b = plr[myplr]._py - dy;
int a = plr[myplr]._pfutx - dx;
int b = plr[myplr]._pfuty - dy;
return sqrt(a * a + b * b);
}
void FindItemOrObject()
{
int mx = plr[myplr]._px;
int my = plr[myplr]._py;
int mx = plr[myplr]._pfutx;
int my = plr[myplr]._pfuty;
int rotations = 5;
// As the player can not stand on the edge fo the map this is safe from OOB
@ -201,8 +201,8 @@ void FindRangedTarget()
// The first MAX_PLRS monsters are reserved for players' golems.
for (int mi = MAX_PLRS; mi < MAXMONSTERS; mi++) {
const auto &monst = monster[mi];
const int mx = monst._mx;
const int my = monst._my;
const int mx = monst._mfutx;
const int my = monst._mfuty;
if (!CanTargetMonster(mi))
continue;
@ -238,8 +238,8 @@ void FindMeleeTarget()
std::list<SearchNode> queue;
{
const int start_x = plr[myplr]._px;
const int start_y = plr[myplr]._py;
const int start_x = plr[myplr]._pfutx;
const int start_y = plr[myplr]._pfuty;
visited[start_x][start_y] = true;
queue.push_back({ start_x, start_y, 0 });
}
@ -319,8 +319,8 @@ void CheckPlayerNearby()
for (int i = 0; i < MAX_PLRS; i++) {
if (i == myplr)
continue;
const int mx = plr[i].WorldX;
const int my = plr[i].WorldY;
const int mx = plr[i]._pfutx;
const int my = plr[i]._pfuty;
if (dPlayer[mx][my] == 0
|| !(dFlags[mx][my] & BFLAG_LIT)
|| (plr[i]._pHitPoints == 0 && spl != SPL_RESURRECT))
@ -801,8 +801,8 @@ bool IsPathBlocked(int x, int y, int dir)
void WalkInDir(MoveDirection dir)
{
const int x = plr[myplr]._px;
const int y = plr[myplr]._py;
const int x = plr[myplr]._pfutx;
const int y = plr[myplr]._pfuty;
if (dir.x == MoveDirectionX::NONE && dir.y == MoveDirectionY::NONE) {
if (sgbControllerActive && plr[myplr].walkpath[0] != WALK_NONE && plr[myplr].destAction == ACTION_NONE)
@ -872,7 +872,8 @@ struct RightStickAccumulator {
} // namespace
bool IsAutomapActive() {
bool IsAutomapActive()
{
return automapflag && leveltype != DTYPE_TOWN;
}
@ -1022,8 +1023,8 @@ void UpdateSpellTarget()
if (plr[myplr]._pRSpell == SPL_TELEPORT)
range = 4;
cursmx = player._px + kOffsets[player._pdir][0] * range;
cursmy = player._py + kOffsets[player._pdir][1] * range;
cursmx = player._pfutx + kOffsets[player._pdir][0] * range;
cursmy = player._pfuty + kOffsets[player._pdir][1] * range;
}
/**
@ -1031,12 +1032,12 @@ void UpdateSpellTarget()
*/
bool TryDropItem()
{
cursmx = plr[myplr].WorldX + 1;
cursmy = plr[myplr].WorldY;
cursmx = plr[myplr]._pfutx + 1;
cursmy = plr[myplr]._pfuty;
if (!DropItemBeforeTrig()) {
// Try to drop on the other side
cursmx = plr[myplr].WorldX;
cursmy = plr[myplr].WorldY + 1;
cursmx = plr[myplr]._pfutx;
cursmy = plr[myplr]._pfuty + 1;
DropItemBeforeTrig();
}

2
SourceX/sound.cpp

@ -188,7 +188,7 @@ void music_start(int nTrack)
{
BOOL success;
assert((DWORD) nTrack < NUM_MUSIC);
assert((DWORD)nTrack < NUM_MUSIC);
music_stop();
if (gbMusicOn) {
success = SFileOpenFile(sgszMusicTracks[nTrack], &sghMusic);

4
defs.h

@ -4,6 +4,10 @@
* Global definitions and Macros.
*/
#define DIABOOL BOOL
#define GAME_NAME "DIABLO"
#define APP_NAME "Diablo"
#define DMAXX 40
#define DMAXY 40

60
enums.h

@ -1167,14 +1167,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 {
@ -1482,7 +1482,8 @@ typedef enum _monster_id {
MT_ADVOCATE = 0x6C,
MT_GOLEM = 0x6D,
MT_DIABLO = 0x6E,
NUM_MTYPES,
MT_DARKMAGE = 0x6F,
NUM_MTYPES = 0x6F, /// BUGFIX the count is off by one
} _monster_id;
// this enum contains indexes from UniqMonst array for special unique monsters (usually quest related)
@ -1802,7 +1803,7 @@ typedef enum _speech_id {
TEXT_BOOK31 = 0xFF,
TEXT_BOOK32 = 0x100,
TEXT_BOOK33 = 0x101,
TEXT_INTRO = 0x102
TEXT_INTRO = 0x102,
} _speech_id;
typedef enum object_graphic_id {
@ -2545,22 +2546,23 @@ typedef enum _setlevels {
} _setlevels;
typedef enum quest_id {
Q_ROCK = 0x0,
Q_MUSHROOM = 0x1,
Q_GARBUD = 0x2,
Q_ZHAR = 0x3,
Q_VEIL = 0x4,
Q_DIABLO = 0x5,
Q_BUTCHER = 0x6,
Q_LTBANNER = 0x7,
Q_BLIND = 0x8,
Q_BLOOD = 0x9,
Q_ANVIL = 0xA,
Q_WARLORD = 0xB,
Q_SKELKING = 0xC,
Q_PWATER = 0xD,
Q_SCHAMB = 0xE,
Q_BETRAYER = 0xF
Q_ROCK = 0x0,
Q_MUSHROOM = 0x1,
Q_GARBUD = 0x2,
Q_ZHAR = 0x3,
Q_VEIL = 0x4,
Q_DIABLO = 0x5,
Q_BUTCHER = 0x6,
Q_LTBANNER = 0x7,
Q_BLIND = 0x8,
Q_BLOOD = 0x9,
Q_ANVIL = 0xA,
Q_WARLORD = 0xB,
Q_SKELKING = 0xC,
Q_PWATER = 0xD,
Q_SCHAMB = 0xE,
Q_BETRAYER = 0xF,
Q_INVALID = -1,
} quest_id;
typedef enum quest_state {
@ -2710,9 +2712,9 @@ typedef enum plr_class {
} plr_class;
typedef enum _ui_classes {
UI_WARRIOR = 0x0,
UI_ROGUE = 0x1,
UI_SORCERER = 0x2,
UI_WARRIOR = 0x0,
UI_ROGUE = 0x1,
UI_SORCERER = 0x2,
UI_NUM_CLASSES,
} _ui_classes;

6
structs.h

@ -185,10 +185,10 @@ typedef struct PlayerStruct {
int destParam3;
int destParam4;
int plrlevel;
int WorldX;
int WorldY;
int _px;
int _py;
int _pfutx;
int _pfuty;
int _ptargx;
int _ptargy;
int _pownerx;
@ -1338,7 +1338,7 @@ typedef struct _SNETUIDATA {
void (*profilecallback)();
const char **profilefields;
void (*profilebitmapcallback)();
int(*selectnamecallback)(
int (*selectnamecallback)(
const struct _SNETPROGRAMDATA *,
const struct _SNETPLAYERDATA *,
const struct _SNETUIDATA *,

Loading…
Cancel
Save