Browse Source

Format bin exact code

pull/133/head
Anders Jenbo 7 years ago
parent
commit
a7788ccddf
  1. 6
      Source/appfat.cpp
  2. 6
      Source/capture.cpp
  3. 7
      Source/codec.cpp
  4. 2
      Source/control.cpp
  5. 212
      Source/cursor.cpp
  6. 20
      Source/debug.cpp
  7. 352
      Source/diablo.cpp
  8. 24
      Source/drlg_l1.cpp
  9. 816
      Source/drlg_l3.cpp
  10. 612
      Source/drlg_l4.cpp
  11. 3
      Source/effects.cpp
  12. 18
      Source/error.cpp
  13. 2
      Source/fault.cpp
  14. 134
      Source/gendung.cpp
  15. 37
      Source/init.cpp
  16. 20
      Source/interfac.cpp
  17. 36
      Source/minitext.cpp
  18. 135
      Source/monster.cpp
  19. 2
      Source/mpqapi.cpp
  20. 48
      Source/multi.cpp
  21. 7
      Source/objects.cpp
  22. 4
      Source/path.cpp
  23. 30
      Source/themes.cpp
  24. 6
      Source/town.cpp
  25. 158
      Source/towners.cpp
  26. 28
      Source/trigs.cpp
  27. 19
      format.sh

6
Source/appfat.cpp

@ -33,14 +33,14 @@ void TriggerBreak()
#ifdef _DEBUG #ifdef _DEBUG
LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc) LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc)
{ {
if(pExc->ExceptionRecord == NULL) { if (pExc->ExceptionRecord == NULL) {
return 0; return 0;
} }
if(pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) { if (pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) {
return 0; return 0;
} }
if(((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3 if (((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3
pExc->ContextRecord->Eip++; pExc->ContextRecord->Eip++;
} }

6
Source/capture.cpp

@ -68,9 +68,9 @@ BOOL CapturePal(HANDLE hFile, PALETTEENTRY *palette)
pcx_palette[0] = 12; pcx_palette[0] = 12;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
pcx_palette[1 + 3*i + 0] = palette[i].peRed; pcx_palette[1 + 3 * i + 0] = palette[i].peRed;
pcx_palette[1 + 3*i + 1] = palette[i].peGreen; pcx_palette[1 + 3 * i + 1] = palette[i].peGreen;
pcx_palette[1 + 3*i + 2] = palette[i].peBlue; pcx_palette[1 + 3 * i + 2] = palette[i].peBlue;
} }
return WriteFile(hFile, pcx_palette, 769, &NumberOfBytesWritten, 0) && NumberOfBytesWritten == 769; return WriteFile(hFile, pcx_palette, 769, &NumberOfBytesWritten, 0) && NumberOfBytesWritten == 769;

7
Source/codec.cpp

@ -1,7 +1,6 @@
#include "diablo.h" #include "diablo.h"
struct CodecSignature struct CodecSignature {
{
DWORD checksum; DWORD checksum;
BYTE error; BYTE error;
BYTE last_chunk_size; BYTE last_chunk_size;
@ -94,7 +93,7 @@ DWORD codec_get_encoded_len(DWORD dwSrcBytes)
return dwSrcBytes + 8; return dwSrcBytes + 8;
} }
void codec_encode(BYTE* pbSrcDst, DWORD size, int size_64, char *pszPassword) void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, char *pszPassword)
{ {
char buf[128]; char buf[128];
char tmp[SHA1HashSize]; char tmp[SHA1HashSize];
@ -126,7 +125,7 @@ void codec_encode(BYTE* pbSrcDst, DWORD size, int size_64, char *pszPassword)
} }
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
SHA1Result(0, tmp); SHA1Result(0, tmp);
sig = (CodecSignature*) pbSrcDst; sig = (CodecSignature *)pbSrcDst;
sig->error = 0; sig->error = 0;
sig->unused = 0; sig->unused = 0;
sig->checksum = *(DWORD *)tmp; sig->checksum = *(DWORD *)tmp;

2
Source/control.cpp

@ -1730,7 +1730,7 @@ void DrawChr()
mindam += plr[myplr]._pDamageMod; mindam += plr[myplr]._pDamageMod;
} }
maxdam = plr[myplr]._pIMaxDam; maxdam = plr[myplr]._pIMaxDam;
maxdam += plr[myplr]._pIBonusDam * maxdam / 100; maxdam += plr[myplr]._pIBonusDam * maxdam / 100;
maxdam += plr[myplr]._pIBonusDamMod; maxdam += plr[myplr]._pIBonusDamMod;
if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW) { if (plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_BOW) {
if (plr[myplr]._pClass == PC_ROGUE) if (plr[myplr]._pClass == PC_ROGUE)

212
Source/cursor.cpp

@ -17,7 +17,7 @@ char pcursplr; // weak
int cursmx; int cursmx;
int cursmy; int cursmy;
int pcurstemp; // weak int pcurstemp; // weak
int pcurs; // idb int pcurs; // idb
/* rdata */ /* rdata */
const int InvItemWidth[180] = { const int InvItemWidth[180] = {
@ -177,23 +177,23 @@ void CheckCursMove()
sx = MouseX; sx = MouseX;
sy = MouseY; sy = MouseY;
if(chrflag || questlog) { if (chrflag || questlog) {
if(sx >= 160) { if (sx >= 160) {
sx -= 160; sx -= 160;
} else { } else {
sx = 0; sx = 0;
} }
} else if(invflag || sbookflag) { } else if (invflag || sbookflag) {
if(sx <= 320) { if (sx <= 320) {
sx += 160; sx += 160;
} else { } else {
sx = 0; sx = 0;
} }
} }
if(sy > VIEWPORT_HEIGHT - 1 && track_isscrolling()) { if (sy > VIEWPORT_HEIGHT - 1 && track_isscrolling()) {
sy = VIEWPORT_HEIGHT - 1; sy = VIEWPORT_HEIGHT - 1;
} }
if(!zoomflag) { if (!zoomflag) {
sx >>= 1; sx >>= 1;
sy >>= 1; sy >>= 1;
} }
@ -201,21 +201,21 @@ void CheckCursMove()
sx -= ScrollInfo._sxoff; sx -= ScrollInfo._sxoff;
sy -= ScrollInfo._syoff; sy -= ScrollInfo._syoff;
if(ScrollInfo._sdir != 0) { if (ScrollInfo._sdir != 0) {
sx += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8); sx += ((plr[myplr]._pVar6 + plr[myplr]._pxvel) >> 8) - (plr[myplr]._pVar6 >> 8);
sy += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8); sy += ((plr[myplr]._pVar7 + plr[myplr]._pyvel) >> 8) - (plr[myplr]._pVar7 >> 8);
} }
if(sx < 0) { if (sx < 0) {
sx = 0; sx = 0;
} }
if(sx >= 640) { if (sx >= 640) {
sx = 640; sx = 640;
} }
if(sy < 0) { if (sy < 0) {
sy = 0; sy = 0;
} }
if(sy >= 480) { if (sy >= 480) {
sy = 480; sy = 480;
} }
@ -226,25 +226,25 @@ void CheckCursMove()
mx = ViewX + tx + ty - (zoomflag ? 10 : 5); mx = ViewX + tx + ty - (zoomflag ? 10 : 5);
my = ViewY + ty - tx; my = ViewY + ty - tx;
flipy = py < px >> 1; flipy = py<px>> 1;
if(flipy) { if (flipy) {
my--; my--;
} }
flipx = py >= 32 - (px >> 1); flipx = py >= 32 - (px >> 1);
if(flipx) { if (flipx) {
mx++; mx++;
} }
if(mx < 0) { if (mx < 0) {
mx = 0; mx = 0;
} }
if(mx >= MAXDUNX) { if (mx >= MAXDUNX) {
mx = MAXDUNX - 1; mx = MAXDUNX - 1;
} }
if(my < 0) { if (my < 0) {
my = 0; my = 0;
} }
if(my >= MAXDUNY) { if (my >= MAXDUNY) {
my = MAXDUNY - 1; my = MAXDUNY - 1;
} }
@ -254,7 +254,7 @@ void CheckCursMove()
pcursmonst = -1; pcursmonst = -1;
pcursobj = -1; pcursobj = -1;
pcursitem = -1; pcursitem = -1;
if(pcursinvitem != -1) { if (pcursinvitem != -1) {
drawsbarflag = TRUE; drawsbarflag = TRUE;
} }
pcursinvitem = -1; pcursinvitem = -1;
@ -263,232 +263,232 @@ void CheckCursMove()
panelflag = 0; panelflag = 0;
trigflag = FALSE; trigflag = FALSE;
if(plr[myplr]._pInvincible) { if (plr[myplr]._pInvincible) {
return; return;
} }
if(pcurs >= CURSOR_FIRSTITEM || spselflag) { if (pcurs >= CURSOR_FIRSTITEM || spselflag) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
return; return;
} }
if(MouseY > VIEWPORT_HEIGHT) { if (MouseY > VIEWPORT_HEIGHT) {
CheckPanelInfo(); CheckPanelInfo();
return; return;
} }
if(doomflag) { if (doomflag) {
return; return;
} }
if(invflag && MouseX > 320) { if (invflag && MouseX > 320) {
pcursinvitem = CheckInvHLight(); pcursinvitem = CheckInvHLight();
return; return;
} }
if(sbookflag && MouseX > 320) { if (sbookflag && MouseX > 320) {
return; return;
} }
if((chrflag || questlog) && MouseX < 320) { if ((chrflag || questlog) && MouseX < 320) {
return; return;
} }
if(leveltype != DTYPE_TOWN) { if (leveltype != DTYPE_TOWN) {
if(pcurstemp != -1) { if (pcurstemp != -1) {
if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) { if (!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) {
mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1); mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 1; /// BUGFIX: 'mx + 2' cursmx = mx + 1; /// BUGFIX: 'mx + 2'
cursmy = my + 2; /// BUGFIX: 'my + 1' cursmy = my + 2; /// BUGFIX: 'my + 1'
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) { if (flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) {
mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1); mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 2; cursmy = my + 2;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) { if (dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) {
mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1); mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 2; cursmx = mx + 2;
cursmy = my + 2; cursmy = my + 2;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) { if (!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) {
mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1); mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) { if (flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) {
mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1); mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) { if (dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) {
mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1); mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) { if (dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) {
mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1); mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1);
if(mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (mi == pcurstemp && monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) { if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) {
pcursmonst = -1; pcursmonst = -1;
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
} }
if(pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) { if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
pcursmonst = -1; pcursmonst = -1;
} }
if(pcursmonst != -1) { if (pcursmonst != -1) {
return; return;
} }
} }
if(!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) { if (!flipflag && dMonster[mx + 2][my + 1] != 0 && dFlags[mx + 2][my + 1] & BFLAG_LIT) {
mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1); mi = dMonster[mx + 2][my + 1] > 0 ? dMonster[mx + 2][my + 1] - 1 : -(dMonster[mx + 2][my + 1] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 2; cursmx = mx + 2;
cursmy = my + 1; cursmy = my + 1;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) { if (flipflag && dMonster[mx + 1][my + 2] != 0 && dFlags[mx + 1][my + 2] & BFLAG_LIT) {
mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1); mi = dMonster[mx + 1][my + 2] > 0 ? dMonster[mx + 1][my + 2] - 1 : -(dMonster[mx + 1][my + 2] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 2; cursmy = my + 2;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) { if (dMonster[mx + 2][my + 2] != 0 && dFlags[mx + 2][my + 2] & BFLAG_LIT) {
mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1); mi = dMonster[mx + 2][my + 2] > 0 ? dMonster[mx + 2][my + 2] - 1 : -(dMonster[mx + 2][my + 2] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 4) {
cursmx = mx + 2; cursmx = mx + 2;
cursmy = my + 2; cursmy = my + 2;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) { if (!flipflag && dMonster[mx + 1][my] != 0 && dFlags[mx + 1][my] & BFLAG_LIT) {
mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1); mi = dMonster[mx + 1][my] > 0 ? dMonster[mx + 1][my] - 1 : -(dMonster[mx + 1][my] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) { if (flipflag && dMonster[mx][my + 1] != 0 && dFlags[mx][my + 1] & BFLAG_LIT) {
mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1); mi = dMonster[mx][my + 1] > 0 ? dMonster[mx][my + 1] - 1 : -(dMonster[mx][my + 1] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) { if (dMonster[mx][my] != 0 && dFlags[mx][my] & BFLAG_LIT) {
mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1); mi = dMonster[mx][my] > 0 ? dMonster[mx][my] - 1 : -(dMonster[mx][my] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 1) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) { if (dMonster[mx + 1][my + 1] != 0 && dFlags[mx + 1][my + 1] & BFLAG_LIT) {
mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1); mi = dMonster[mx + 1][my + 1] > 0 ? dMonster[mx + 1][my + 1] - 1 : -(dMonster[mx + 1][my + 1] + 1);
if(monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) { if (monster[mi]._mhitpoints >> 6 > 0 && monster[mi].MData->mSelFlag & 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
pcursmonst = mi; pcursmonst = mi;
} }
} }
if(pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) { if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_HIDDEN) {
pcursmonst = -1; pcursmonst = -1;
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
} }
if(pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) { if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
pcursmonst = -1; pcursmonst = -1;
} }
} else { } else {
if(!flipflag && dMonster[mx + 1][my] > 0) { if (!flipflag && dMonster[mx + 1][my] > 0) {
pcursmonst = dMonster[mx + 1][my] - 1; pcursmonst = dMonster[mx + 1][my] - 1;
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
} }
if(flipflag && dMonster[mx][my + 1] > 0) { if (flipflag && dMonster[mx][my + 1] > 0) {
pcursmonst = dMonster[mx][my + 1] - 1; pcursmonst = dMonster[mx][my + 1] - 1;
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
} }
if(dMonster[mx][my] > 0) { if (dMonster[mx][my] > 0) {
pcursmonst = dMonster[mx][my] - 1; pcursmonst = dMonster[mx][my] - 1;
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
} }
if(dMonster[mx + 1][my + 1] > 0) { if (dMonster[mx + 1][my + 1] > 0) {
pcursmonst = dMonster[mx + 1][my + 1] - 1; pcursmonst = dMonster[mx + 1][my + 1] - 1;
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
} }
if(!towner[pcursmonst]._tSelFlag) { /// BUGFIX: Add check 'pcursmonst != -1' if (!towner[pcursmonst]._tSelFlag) { /// BUGFIX: Add check 'pcursmonst != -1'
pcursmonst = -1; pcursmonst = -1;
} }
} }
if(pcursmonst == -1) { if (pcursmonst == -1) {
if(!flipflag && dPlayer[mx + 1][my] != 0) { if (!flipflag && dPlayer[mx + 1][my] != 0) {
bv = dPlayer[mx + 1][my] > 0 ? dPlayer[mx + 1][my] - 1 : -(dPlayer[mx + 1][my] + 1); bv = dPlayer[mx + 1][my] > 0 ? dPlayer[mx + 1][my] - 1 : -(dPlayer[mx + 1][my] + 1);
if(bv != myplr && plr[bv]._pHitPoints != 0) { if (bv != myplr && plr[bv]._pHitPoints != 0) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
pcursplr = bv; pcursplr = bv;
} }
} }
if(flipflag && dPlayer[mx][my + 1] != 0) { if (flipflag && dPlayer[mx][my + 1] != 0) {
bv = dPlayer[mx][my + 1] > 0 ? dPlayer[mx][my + 1] - 1 : -(dPlayer[mx][my + 1] + 1); bv = dPlayer[mx][my + 1] > 0 ? dPlayer[mx][my + 1] - 1 : -(dPlayer[mx][my + 1] + 1);
if(bv != myplr && plr[bv]._pHitPoints != 0) { if (bv != myplr && plr[bv]._pHitPoints != 0) {
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
pcursplr = bv; pcursplr = bv;
} }
} }
if(dPlayer[mx][my] != 0) { if (dPlayer[mx][my] != 0) {
bv = dPlayer[mx][my] > 0 ? dPlayer[mx][my] - 1 : -(dPlayer[mx][my] + 1); bv = dPlayer[mx][my] > 0 ? dPlayer[mx][my] - 1 : -(dPlayer[mx][my] + 1);
if(bv != myplr) { if (bv != myplr) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursplr = bv; pcursplr = bv;
} }
} }
if(dFlags[mx][my] & BFLAG_DEAD_PLAYER) { if (dFlags[mx][my] & BFLAG_DEAD_PLAYER) {
for(i = 0; i < MAX_PLRS; i++) { for (i = 0; i < MAX_PLRS; i++) {
if(plr[i].WorldX == mx && plr[i].WorldY == my && i != myplr) { if (plr[i].WorldX == mx && plr[i].WorldY == my && i != myplr) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursplr = i; pcursplr = i;
} }
} }
} }
if(pcurs == CURSOR_RESURRECT) { if (pcurs == CURSOR_RESURRECT) {
for(xx = -1; xx < 2; xx++) { for (xx = -1; xx < 2; xx++) {
for(yy = -1; yy < 2; yy++) { for (yy = -1; yy < 2; yy++) {
if(dFlags[mx + xx][my + yy] & BFLAG_DEAD_PLAYER) { if (dFlags[mx + xx][my + yy] & BFLAG_DEAD_PLAYER) {
for(i = 0; i < MAX_PLRS; i++) { for (i = 0; i < MAX_PLRS; i++) {
if(plr[i].WorldX == mx + xx && plr[i].WorldY == my + yy && i != myplr) { if (plr[i].WorldX == mx + xx && plr[i].WorldY == my + yy && i != myplr) {
cursmx = mx + xx; cursmx = mx + xx;
cursmy = my + yy; cursmy = my + yy;
pcursplr = i; pcursplr = i;
@ -498,83 +498,83 @@ void CheckCursMove()
} }
} }
} }
if(dPlayer[mx + 1][my + 1] != 0) { if (dPlayer[mx + 1][my + 1] != 0) {
bv = dPlayer[mx + 1][my + 1] > 0 ? dPlayer[mx + 1][my + 1] - 1 : -(dPlayer[mx + 1][my + 1] + 1); bv = dPlayer[mx + 1][my + 1] > 0 ? dPlayer[mx + 1][my + 1] - 1 : -(dPlayer[mx + 1][my + 1] + 1);
if(bv != myplr && plr[bv]._pHitPoints != 0) { if (bv != myplr && plr[bv]._pHitPoints != 0) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
pcursplr = bv; pcursplr = bv;
} }
} }
} }
if(pcursmonst == -1 && pcursplr == -1) { if (pcursmonst == -1 && pcursplr == -1) {
if(!flipflag && dObject[mx + 1][my] != 0) { if (!flipflag && dObject[mx + 1][my] != 0) {
bv = dObject[mx + 1][my] > 0 ? dObject[mx + 1][my] - 1 : -(dObject[mx + 1][my] + 1); bv = dObject[mx + 1][my] > 0 ? dObject[mx + 1][my] - 1 : -(dObject[mx + 1][my] + 1);
if(object[bv]._oSelFlag >= 2) { if (object[bv]._oSelFlag >= 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
pcursobj = bv; pcursobj = bv;
} }
} }
if(flipflag && dObject[mx][my + 1] != 0) { if (flipflag && dObject[mx][my + 1] != 0) {
bv = dObject[mx][my + 1] > 0 ? dObject[mx][my + 1] - 1 : -(dObject[mx][my + 1] + 1); bv = dObject[mx][my + 1] > 0 ? dObject[mx][my + 1] - 1 : -(dObject[mx][my + 1] + 1);
if(object[bv]._oSelFlag >= 2) { if (object[bv]._oSelFlag >= 2) {
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
pcursobj = bv; pcursobj = bv;
} }
} }
if(dObject[mx][my] != 0) { if (dObject[mx][my] != 0) {
bv = dObject[mx][my] > 0 ? dObject[mx][my] - 1 : -(dObject[mx][my] + 1); bv = dObject[mx][my] > 0 ? dObject[mx][my] - 1 : -(dObject[mx][my] + 1);
if(object[bv]._oSelFlag == 1 || object[bv]._oSelFlag == 3) { if (object[bv]._oSelFlag == 1 || object[bv]._oSelFlag == 3) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursobj = bv; pcursobj = bv;
} }
} }
if(dObject[mx + 1][my + 1] != 0) { if (dObject[mx + 1][my + 1] != 0) {
bv = dObject[mx + 1][my + 1] > 0 ? dObject[mx + 1][my + 1] - 1 : -(dObject[mx + 1][my + 1] + 1); bv = dObject[mx + 1][my + 1] > 0 ? dObject[mx + 1][my + 1] - 1 : -(dObject[mx + 1][my + 1] + 1);
if(object[bv]._oSelFlag >= 2) { if (object[bv]._oSelFlag >= 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
pcursobj = bv; pcursobj = bv;
} }
} }
} }
if(pcursplr == -1 && pcursobj == -1 && pcursmonst == -1) { if (pcursplr == -1 && pcursobj == -1 && pcursmonst == -1) {
if(!flipflag && dItem[mx + 1][my] > 0) { if (!flipflag && dItem[mx + 1][my] > 0) {
bv = dItem[mx + 1][my] - 1; bv = dItem[mx + 1][my] - 1;
if(item[bv]._iSelFlag >= 2) { if (item[bv]._iSelFlag >= 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my; cursmy = my;
pcursitem = bv; pcursitem = bv;
} }
} }
if(flipflag && dItem[mx][my + 1] > 0) { if (flipflag && dItem[mx][my + 1] > 0) {
bv = dItem[mx][my + 1] - 1; bv = dItem[mx][my + 1] - 1;
if(item[bv]._iSelFlag >= 2) { if (item[bv]._iSelFlag >= 2) {
cursmx = mx; cursmx = mx;
cursmy = my + 1; cursmy = my + 1;
pcursitem = bv; pcursitem = bv;
} }
} }
if(dItem[mx][my] > 0) { if (dItem[mx][my] > 0) {
bv = dItem[mx][my] - 1; bv = dItem[mx][my] - 1;
if(item[bv]._iSelFlag == 1 || item[bv]._iSelFlag == 3) { if (item[bv]._iSelFlag == 1 || item[bv]._iSelFlag == 3) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
pcursitem = bv; pcursitem = bv;
} }
} }
if(dItem[mx + 1][my + 1] > 0) { if (dItem[mx + 1][my + 1] > 0) {
bv = dItem[mx + 1][my + 1] - 1; bv = dItem[mx + 1][my + 1] - 1;
if(item[bv]._iSelFlag >= 2) { if (item[bv]._iSelFlag >= 2) {
cursmx = mx + 1; cursmx = mx + 1;
cursmy = my + 1; cursmy = my + 1;
pcursitem = bv; pcursitem = bv;
} }
} }
if(pcursitem == -1) { if (pcursitem == -1) {
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
CheckTrigForce(); CheckTrigForce();
@ -583,14 +583,14 @@ void CheckCursMove()
} }
} }
if(pcurs == CURSOR_IDENTIFY) { if (pcurs == CURSOR_IDENTIFY) {
pcursobj = -1; pcursobj = -1;
pcursmonst = -1; pcursmonst = -1;
pcursitem = -1; pcursitem = -1;
cursmx = mx; cursmx = mx;
cursmy = my; cursmy = my;
} }
if(pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) { if (pcursmonst != -1 && monster[pcursmonst]._mFlags & MFLAG_GOLEM) {
pcursmonst = -1; pcursmonst = -1;
} }
} }

20
Source/debug.cpp

@ -28,20 +28,20 @@ void init_seed_desync()
{ {
int i; int i;
for(i = 0; i < 4096; i++) { for (i = 0; i < 4096; i++) {
seed_table[i] = -1; seed_table[i] = -1;
} }
seed_index = 0; seed_index = 0;
for(i = 0; i < NUMLEVELS; i++) { for (i = 0; i < NUMLEVELS; i++) {
level_seeds[i] = 0; level_seeds[i] = 0;
} }
} }
void seed_desync_index_get() void seed_desync_index_get()
{ {
if(currlevel == 0) { if (currlevel == 0) {
return; return;
} }
@ -51,7 +51,7 @@ void seed_desync_index_get()
void seed_desync_index_set() void seed_desync_index_set()
{ {
if(currlevel == 0) { if (currlevel == 0) {
return; return;
} }
@ -61,13 +61,13 @@ void seed_desync_index_set()
void seed_desync_check(int seed) void seed_desync_check(int seed)
{ {
if(!update_seed_check || seed_index == 4096 || currlevel == 0) { if (!update_seed_check || seed_index == 4096 || currlevel == 0) {
return; return;
} }
if(seed_table[seed_index] == -1) { if (seed_table[seed_index] == -1) {
seed_table[seed_index] = seed; seed_table[seed_index] = seed;
} else if(seed != seed_table[seed_index]) { } else if (seed != seed_table[seed_index]) {
app_fatal("Seeds desynced"); app_fatal("Seeds desynced");
} }
@ -220,7 +220,7 @@ void PrintDebugQuest()
sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1);
NetSendCmdString(1 << myplr, dstr); NetSendCmdString(1 << myplr, dstr);
dbgqst++; dbgqst++;
if (dbgqst == MAXQUESTS) if (dbgqst == MAXQUESTS)
dbgqst = 0; dbgqst = 0;
@ -229,8 +229,8 @@ void PrintDebugQuest()
void PrintDebugMonster(int m) void PrintDebugMonster(int m)
{ {
BOOL bActive; BOOL bActive;
int i; int i;
char dstr[128]; char dstr[128];
sprintf(dstr, "Monster %i = %s", m, monster[m].mName); sprintf(dstr, "Monster %i = %s", m, monster[m].mName);
NetSendCmdString(1 << myplr, dstr); NetSendCmdString(1 << myplr, dstr);

352
Source/diablo.cpp

@ -142,12 +142,12 @@ void run_game_loop(unsigned int uMsg)
gbGameLoopStartup = TRUE; gbGameLoopStartup = TRUE;
nthread_ignore_mutex(FALSE); nthread_ignore_mutex(FALSE);
while(gbRunGame) { while (gbRunGame) {
diablo_color_cyc_logic(); diablo_color_cyc_logic();
if(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if(msg.message == WM_QUIT) { if (msg.message == WM_QUIT) {
gbRunGameResult = FALSE; gbRunGameResult = FALSE;
gbRunGame = FALSE; gbRunGame = FALSE;
break; break;
@ -157,10 +157,10 @@ void run_game_loop(unsigned int uMsg)
} }
bLoop = gbRunGame && nthread_has_500ms_passed(FALSE); bLoop = gbRunGame && nthread_has_500ms_passed(FALSE);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
if(!bLoop) { if (!bLoop) {
continue; continue;
} }
} else if(!nthread_has_500ms_passed(FALSE)) { } else if (!nthread_has_500ms_passed(FALSE)) {
#ifdef SLEEPFIX #ifdef SLEEPFIX
Sleep(1); Sleep(1);
#endif #endif
@ -173,7 +173,7 @@ void run_game_loop(unsigned int uMsg)
DrawAndBlit(); DrawAndBlit();
} }
if(gbMaxPlayers > 1) { if (gbMaxPlayers > 1) {
pfile_write_hero(); pfile_write_hero();
} }
@ -187,7 +187,7 @@ void run_game_loop(unsigned int uMsg)
/// ASSERT: assert(saveProc == GM_Game); /// ASSERT: assert(saveProc == GM_Game);
free_game(); free_game();
if(cineflag) { if (cineflag) {
cineflag = FALSE; cineflag = FALSE;
DoEnding(); DoEnding();
} }
@ -323,24 +323,24 @@ void diablo_parse_flags(char *args)
int i; int i;
#endif #endif
while(*args != '\0') { while (*args != '\0') {
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
if(_strnicmp("dd_emulate", args, strlen("dd_emulate")) == 0) { if (_strnicmp("dd_emulate", args, strlen("dd_emulate")) == 0) {
gbEmulate = 1; gbEmulate = 1;
args += strlen("dd_emulate"); args += strlen("dd_emulate");
} else if(_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) { } else if (_strnicmp("dd_backbuf", args, strlen("dd_backbuf")) == 0) {
gbBackBuf = 1; gbBackBuf = 1;
args += strlen("dd_backbuf"); args += strlen("dd_backbuf");
} else if(_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) { } else if (_strnicmp("ds_noduplicates", args, strlen("ds_noduplicates")) == 0) {
gbDupSounds = 0; gbDupSounds = 0;
args += strlen("ds_noduplicates"); args += strlen("ds_noduplicates");
} else { } else {
c = tolower(*args); c = tolower(*args);
args++; args++;
#ifdef _DEBUG #ifdef _DEBUG
switch(c) { switch (c) {
case '^': case '^':
debug_mode_key_inverted_v = 1; debug_mode_key_inverted_v = 1;
break; break;
@ -348,7 +348,7 @@ void diablo_parse_flags(char *args)
debug_mode_dollar_sign = 1; debug_mode_dollar_sign = 1;
break; break;
case 'b': case 'b':
/* /*
debug_mode_key_b = 1; debug_mode_key_b = 1;
*/ */
break; break;
@ -363,7 +363,7 @@ void diablo_parse_flags(char *args)
debug_mode_key_i = 1; debug_mode_key_i = 1;
break; break;
case 'j': case 'j':
/* /*
while(isspace(*args)) { while(isspace(*args)) {
args++; args++;
} }
@ -378,20 +378,20 @@ void diablo_parse_flags(char *args)
case 'l': case 'l':
setlevel = 0; setlevel = 0;
leveldebug = 1; leveldebug = 1;
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
leveltype = i; leveltype = i;
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
@ -400,11 +400,11 @@ void diablo_parse_flags(char *args)
break; break;
case 'm': case 'm':
monstdebug = 1; monstdebug = 1;
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
@ -414,22 +414,22 @@ void diablo_parse_flags(char *args)
showintrodebug = 0; showintrodebug = 0;
break; break;
case 'q': case 'q':
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
questdebug = i; questdebug = i;
break; break;
case 'r': case 'r':
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
@ -441,11 +441,11 @@ void diablo_parse_flags(char *args)
case 't': case 't':
leveldebug = 1; leveldebug = 1;
setlevel = 1; setlevel = 1;
while(isspace(*args)) { while (isspace(*args)) {
args++; args++;
} }
i = 0; i = 0;
while(isdigit(*args)) { while (isdigit(*args)) {
i = *args + 10 * i - '0'; i = *args + 10 * i - '0';
args++; args++;
} }
@ -525,29 +525,29 @@ void diablo_reload_process(HINSTANCE hInstance)
GetModuleFileName(hInstance, szFileName, sizeof(szFileName)); GetModuleFileName(hInstance, szFileName, sizeof(szFileName));
wsprintf(szReload, "Reload-%s", szFileName); wsprintf(szReload, "Reload-%s", szFileName);
for(s = szReload; *s != '\0'; s++) { for (s = szReload; *s != '\0'; s++) {
if(*s == '\\') { if (*s == '\\') {
*s = '/'; *s = '/';
} }
} }
GetSystemInfo(&sinf); GetSystemInfo(&sinf);
dwSize = sinf.dwPageSize; dwSize = sinf.dwPageSize;
if(dwSize < 4096) { if (dwSize < 4096) {
dwSize = 4096; dwSize = 4096;
} }
hMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, dwSize, szReload); hMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, SEC_COMMIT | PAGE_READWRITE, 0, dwSize, szReload);
bNoExist = GetLastError() != ERROR_ALREADY_EXISTS; bNoExist = GetLastError() != ERROR_ALREADY_EXISTS;
if(hMap == NULL) { if (hMap == NULL) {
return; return;
} }
plMap = (long *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, dwSize); plMap = (long *)MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, dwSize);
if(plMap == NULL) { if (plMap == NULL) {
return; return;
} }
if(bNoExist) { if (bNoExist) {
plMap[0] = -1; plMap[0] = -1;
plMap[1] = 0; plMap[1] = 0;
memset(&si, 0, sizeof(si)); memset(&si, 0, sizeof(si));
@ -556,7 +556,7 @@ void diablo_reload_process(HINSTANCE hInstance)
WaitForInputIdle(pi.hProcess, INFINITE); WaitForInputIdle(pi.hProcess, INFINITE);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
while(plMap[0] < 0) { while (plMap[0] < 0) {
Sleep(1000); Sleep(1000);
} }
UnmapViewOfFile(plMap); UnmapViewOfFile(plMap);
@ -564,26 +564,26 @@ void diablo_reload_process(HINSTANCE hInstance)
ExitProcess(0); ExitProcess(0);
} }
if(InterlockedIncrement(plMap) == 0) { if (InterlockedIncrement(plMap) == 0) {
plMap[1] = GetCurrentProcessId(); plMap[1] = GetCurrentProcessId();
} else { } else {
hPrev = GetForegroundWindow(); hPrev = GetForegroundWindow();
hWnd = hPrev; hWnd = hPrev;
while(1) { while (1) {
hPrev = GetWindow(hPrev, GW_HWNDPREV); hPrev = GetWindow(hPrev, GW_HWNDPREV);
if(hPrev == NULL) { if (hPrev == NULL) {
break; break;
} }
hWnd = hPrev; hWnd = hPrev;
} }
while(1) { while (1) {
GetWindowThreadProcessId(hWnd, &dwProcessId); GetWindowThreadProcessId(hWnd, &dwProcessId);
if(dwProcessId == plMap[1]) { if (dwProcessId == plMap[1]) {
SetForegroundWindow(hWnd); SetForegroundWindow(hWnd);
break; break;
} }
hWnd = GetWindow(hWnd, GW_HWNDNEXT); hWnd = GetWindow(hWnd, GW_HWNDNEXT);
if(hWnd == NULL) { if (hWnd == NULL) {
break; break;
} }
} }
@ -829,7 +829,7 @@ BOOL LeftMouseDown(int wParam)
} }
} else { } else {
if (!talkflag && !dropGoldFlag && !gmenu_exception()) if (!talkflag && !dropGoldFlag && !gmenu_exception())
CheckInvScrn(); CheckInvScrn();
DoPanBtn(); DoPanBtn();
if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM) if (pcurs > CURSOR_HAND && pcurs < CURSOR_FIRSTITEM)
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
@ -897,47 +897,47 @@ BOOL LeftMouseCmd(BOOL bShift)
BOOL TryIconCurs() BOOL TryIconCurs()
{ {
if(pcurs == CURSOR_RESURRECT) { if (pcurs == CURSOR_RESURRECT) {
NetSendCmdParam1(TRUE, CMD_RESURRECT, pcursplr); NetSendCmdParam1(TRUE, CMD_RESURRECT, pcursplr);
return TRUE; return TRUE;
} else if(pcurs == CURSOR_HEALOTHER) { } else if (pcurs == CURSOR_HEALOTHER) {
NetSendCmdParam1(TRUE, CMD_HEALOTHER, pcursplr); NetSendCmdParam1(TRUE, CMD_HEALOTHER, pcursplr);
return TRUE; return TRUE;
} else if(pcurs == CURSOR_TELEKINESIS) { } else if (pcurs == CURSOR_TELEKINESIS) {
DoTelekinesis(); DoTelekinesis();
return TRUE; return TRUE;
} else if(pcurs == CURSOR_IDENTIFY) { } else if (pcurs == CURSOR_IDENTIFY) {
if(pcursinvitem != -1) { if (pcursinvitem != -1) {
CheckIdentify(myplr, pcursinvitem); CheckIdentify(myplr, pcursinvitem);
} else { } else {
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
} }
return TRUE; return TRUE;
} else if(pcurs == CURSOR_REPAIR) { } else if (pcurs == CURSOR_REPAIR) {
if(pcursinvitem != -1) { if (pcursinvitem != -1) {
DoRepair(myplr, pcursinvitem); DoRepair(myplr, pcursinvitem);
} else { } else {
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
} }
return TRUE; return TRUE;
} else if(pcurs == CURSOR_RECHARGE) { } else if (pcurs == CURSOR_RECHARGE) {
if(pcursinvitem != -1) { if (pcursinvitem != -1) {
DoRecharge(myplr, pcursinvitem); DoRecharge(myplr, pcursinvitem);
} else { } else {
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
} }
return TRUE; return TRUE;
} else if(pcurs == CURSOR_TELEPORT) { } else if (pcurs == CURSOR_TELEPORT) {
if(pcursmonst != -1) { if (pcursmonst != -1) {
NetSendCmdParam3(TRUE, CMD_TSPELLID, pcursmonst, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell)); NetSendCmdParam3(TRUE, CMD_TSPELLID, pcursmonst, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell));
} else if(pcursplr != -1) { } else if (pcursplr != -1) {
NetSendCmdParam3(TRUE, CMD_TSPELLPID, pcursplr, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell)); NetSendCmdParam3(TRUE, CMD_TSPELLPID, pcursplr, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell));
} else { } else {
NetSendCmdLocParam2(TRUE, CMD_TSPELLXY, cursmx, cursmy, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell)); NetSendCmdLocParam2(TRUE, CMD_TSPELLXY, cursmx, cursmy, plr[myplr]._pTSpell, GetSpellLevel(myplr, plr[myplr]._pTSpell));
} }
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
return TRUE; return TRUE;
} else if(pcurs == CURSOR_DISARM && pcursobj == -1) { } else if (pcurs == CURSOR_DISARM && pcursobj == -1) {
SetCursor_(CURSOR_HAND); SetCursor_(CURSOR_HAND);
return TRUE; return TRUE;
} }
@ -1007,15 +1007,15 @@ void diablo_hotkey_msg(DWORD dwMsg)
char szFileName[MAX_PATH]; char szFileName[MAX_PATH];
char szMsg[MAX_SEND_STR_LEN]; char szMsg[MAX_SEND_STR_LEN];
if(gbMaxPlayers == 1) { if (gbMaxPlayers == 1) {
return; return;
} }
if(GetModuleFileName(ghInst, szFileName, sizeof(szFileName)) == 0) { if (GetModuleFileName(ghInst, szFileName, sizeof(szFileName)) == 0) {
app_fatal("Can't get program name"); app_fatal("Can't get program name");
} }
s = strrchr(szFileName, '\\'); s = strrchr(szFileName, '\\');
if(s != NULL) { if (s != NULL) {
*s = '\0'; *s = '\0';
} }
@ -1036,64 +1036,64 @@ void ReleaseKey(int vkey)
void PressKey(int vkey) void PressKey(int vkey)
{ {
if(gmenu_presskeys(vkey) || control_presskeys(vkey)) { if (gmenu_presskeys(vkey) || control_presskeys(vkey)) {
return; return;
} }
if(deathflag) { if (deathflag) {
if(sgnTimeoutCurs != 0) { if (sgnTimeoutCurs != 0) {
return; return;
} }
if(vkey == VK_F9) { if (vkey == VK_F9) {
diablo_hotkey_msg(0); diablo_hotkey_msg(0);
} }
if(vkey == VK_F10) { if (vkey == VK_F10) {
diablo_hotkey_msg(1); diablo_hotkey_msg(1);
} }
if(vkey == VK_F11) { if (vkey == VK_F11) {
diablo_hotkey_msg(2); diablo_hotkey_msg(2);
} }
if(vkey == VK_F12) { if (vkey == VK_F12) {
diablo_hotkey_msg(3); diablo_hotkey_msg(3);
} }
if(vkey == VK_RETURN) { if (vkey == VK_RETURN) {
control_type_message(); control_type_message();
} }
if(vkey != VK_ESCAPE) { if (vkey != VK_ESCAPE) {
return; return;
} }
} }
if(vkey == VK_ESCAPE) { if (vkey == VK_ESCAPE) {
if(!PressEscKey()) { if (!PressEscKey()) {
track_repeat_walk(0); track_repeat_walk(0);
gamemenu_previous(); gamemenu_previous();
} }
return; return;
} }
if(sgnTimeoutCurs != 0 || dropGoldFlag) { if (sgnTimeoutCurs != 0 || dropGoldFlag) {
return; return;
} }
if(vkey == VK_PAUSE) { if (vkey == VK_PAUSE) {
diablo_pause_game(); diablo_pause_game();
return; return;
} }
if(PauseMode == 2) { if (PauseMode == 2) {
return; return;
} }
if(vkey == VK_RETURN) { if (vkey == VK_RETURN) {
if(stextflag) { if (stextflag) {
STextEnter(); STextEnter();
} else if(questlog) { } else if (questlog) {
QuestlogEnter(); QuestlogEnter();
} else { } else {
control_type_message(); control_type_message();
} }
} else if(vkey == VK_F1) { } else if (vkey == VK_F1) {
if(helpflag) { if (helpflag) {
helpflag = 0; helpflag = 0;
} else if(stextflag) { } else if (stextflag) {
ClearPanel(); ClearPanel();
AddPanelString("No help available", TRUE); /// BUGFIX: message isn't displayed AddPanelString("No help available", TRUE); /// BUGFIX: message isn't displayed
AddPanelString("while in stores", TRUE); AddPanelString("while in stores", TRUE);
@ -1103,7 +1103,7 @@ void PressKey(int vkey)
chrflag = 0; chrflag = 0;
sbookflag = 0; sbookflag = 0;
spselflag = 0; spselflag = 0;
if(qtextflag && leveltype == DTYPE_TOWN) { if (qtextflag && leveltype == DTYPE_TOWN) {
qtextflag = 0; qtextflag = 0;
sfx_stop(); sfx_stop();
} }
@ -1116,18 +1116,18 @@ void PressKey(int vkey)
} }
} }
#ifdef _DEBUG #ifdef _DEBUG
else if(vkey == VK_F2) { else if (vkey == VK_F2) {
} }
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
else if(vkey == VK_F3) { else if (vkey == VK_F3) {
if(pcursitem != -1) { if (pcursitem != -1) {
sprintf( sprintf(
tempstr, tempstr,
"IDX = %i : Seed = %i : CF = %i", "IDX = %i : Seed = %i : CF = %i",
item[pcursitem].IDidx, item[pcursitem].IDidx,
item[pcursitem]._iSeed, item[pcursitem]._iSeed,
item[pcursitem]._iCreateInfo); item[pcursitem]._iCreateInfo);
NetSendCmdString(1 << myplr, tempstr); NetSendCmdString(1 << myplr, tempstr);
} }
sprintf(tempstr, "Numitems : %i", numitems); sprintf(tempstr, "Numitems : %i", numitems);
@ -1135,85 +1135,85 @@ void PressKey(int vkey)
} }
#endif #endif
#ifdef _DEBUG #ifdef _DEBUG
else if(vkey == VK_F4) { else if (vkey == VK_F4) {
PrintDebugQuest(); PrintDebugQuest();
} }
#endif #endif
else if(vkey == VK_F5) { else if (vkey == VK_F5) {
if(spselflag) { if (spselflag) {
SetSpeedSpell(0); SetSpeedSpell(0);
} else { } else {
ToggleSpell(0); ToggleSpell(0);
} }
} else if(vkey == VK_F6) { } else if (vkey == VK_F6) {
if(spselflag) { if (spselflag) {
SetSpeedSpell(1); SetSpeedSpell(1);
} else { } else {
ToggleSpell(1); ToggleSpell(1);
} }
} else if(vkey == VK_F7) { } else if (vkey == VK_F7) {
if(spselflag) { if (spselflag) {
SetSpeedSpell(2); SetSpeedSpell(2);
} else { } else {
ToggleSpell(2); ToggleSpell(2);
} }
} else if(vkey == VK_F8) { } else if (vkey == VK_F8) {
if(spselflag) { if (spselflag) {
SetSpeedSpell(3); SetSpeedSpell(3);
} else { } else {
ToggleSpell(3); ToggleSpell(3);
} }
} else if(vkey == VK_F9) { } else if (vkey == VK_F9) {
diablo_hotkey_msg(0); diablo_hotkey_msg(0);
} else if(vkey == VK_F10) { } else if (vkey == VK_F10) {
diablo_hotkey_msg(1); diablo_hotkey_msg(1);
} else if(vkey == VK_F11) { } else if (vkey == VK_F11) {
diablo_hotkey_msg(2); diablo_hotkey_msg(2);
} else if(vkey == VK_F12) { } else if (vkey == VK_F12) {
diablo_hotkey_msg(3); diablo_hotkey_msg(3);
} else if(vkey == VK_UP) { } else if (vkey == VK_UP) {
if(stextflag) { if (stextflag) {
STextUp(); STextUp();
} else if(questlog) { } else if (questlog) {
QuestlogUp(); QuestlogUp();
} else if(helpflag) { } else if (helpflag) {
HelpScrollUp(); HelpScrollUp();
} else if(automapflag) { } else if (automapflag) {
AutomapUp(); AutomapUp();
} }
} else if(vkey == VK_DOWN) { } else if (vkey == VK_DOWN) {
if(stextflag) { if (stextflag) {
STextDown(); STextDown();
} else if(questlog) { } else if (questlog) {
QuestlogDown(); QuestlogDown();
} else if(helpflag) { } else if (helpflag) {
HelpScrollDown(); HelpScrollDown();
} else if(automapflag) { } else if (automapflag) {
AutomapDown(); AutomapDown();
} }
} else if(vkey == VK_PRIOR) { } else if (vkey == VK_PRIOR) {
if(stextflag) { if (stextflag) {
STextPrior(); STextPrior();
} }
} else if(vkey == VK_NEXT) { } else if (vkey == VK_NEXT) {
if(stextflag) { if (stextflag) {
STextNext(); STextNext();
} }
} else if(vkey == VK_LEFT) { } else if (vkey == VK_LEFT) {
if(automapflag && !talkflag) { if (automapflag && !talkflag) {
AutomapLeft(); AutomapLeft();
} }
} else if(vkey == VK_RIGHT) { } else if (vkey == VK_RIGHT) {
if(automapflag && !talkflag) { if (automapflag && !talkflag) {
AutomapRight(); AutomapRight();
} }
} else if(vkey == VK_TAB) { } else if (vkey == VK_TAB) {
DoAutoMap(); DoAutoMap();
} else if(vkey == VK_SPACE) { } else if (vkey == VK_SPACE) {
if(!chrflag && invflag && MouseX < 480 && MouseY < VIEWPORT_HEIGHT) { if (!chrflag && invflag && MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY); SetCursorPos(MouseX + 160, MouseY);
} }
if(!invflag && chrflag && MouseX > 160 && MouseY < VIEWPORT_HEIGHT) { if (!invflag && chrflag && MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY); SetCursorPos(MouseX - 160, MouseY);
} }
helpflag = 0; helpflag = 0;
@ -1221,7 +1221,7 @@ void PressKey(int vkey)
chrflag = 0; chrflag = 0;
sbookflag = 0; sbookflag = 0;
spselflag = 0; spselflag = 0;
if(qtextflag && leveltype == DTYPE_TOWN) { if (qtextflag && leveltype == DTYPE_TOWN) {
qtextflag = 0; qtextflag = 0;
sfx_stop(); sfx_stop();
} }
@ -1260,26 +1260,26 @@ void diablo_pause_game()
/* NOTE: `return` must be used instead of `break` to be bin exact as C++ */ /* NOTE: `return` must be used instead of `break` to be bin exact as C++ */
void PressChar(int vkey) void PressChar(int vkey)
{ {
if(gmenu_exception() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) { if (gmenu_exception() || control_talk_last_key(vkey) || sgnTimeoutCurs != 0 || deathflag) {
return; return;
} }
if((char)vkey == 'p' || (char)vkey == 'P') { if ((char)vkey == 'p' || (char)vkey == 'P') {
diablo_pause_game(); diablo_pause_game();
return; return;
} }
if(PauseMode == 2) { if (PauseMode == 2) {
return; return;
} }
if(doomflag) { if (doomflag) {
doom_close(); doom_close();
return; return;
} }
if(dropGoldFlag) { if (dropGoldFlag) {
control_drop_gold(vkey); control_drop_gold(vkey);
return; return;
} }
switch(vkey) { switch (vkey) {
case 'G': case 'G':
case 'g': case 'g':
DecreaseGamma(); DecreaseGamma();
@ -1290,15 +1290,15 @@ void PressChar(int vkey)
return; return;
case 'I': case 'I':
case 'i': case 'i':
if(!stextflag) { if (!stextflag) {
sbookflag = 0; sbookflag = 0;
invflag = invflag == 0; invflag = invflag == 0;
if(!invflag || chrflag) { if (!invflag || chrflag) {
if(MouseX < 480 && MouseY < VIEWPORT_HEIGHT) { if (MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY); SetCursorPos(MouseX + 160, MouseY);
} }
} else { } else {
if(MouseX > 160 && MouseY < VIEWPORT_HEIGHT) { if (MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY); SetCursorPos(MouseX - 160, MouseY);
} }
} }
@ -1306,15 +1306,15 @@ void PressChar(int vkey)
return; return;
case 'C': case 'C':
case 'c': case 'c':
if(!stextflag) { if (!stextflag) {
questlog = FALSE; questlog = FALSE;
chrflag = chrflag == 0; chrflag = chrflag == 0;
if(!chrflag || invflag) { if (!chrflag || invflag) {
if(MouseX > 160 && MouseY < VIEWPORT_HEIGHT) { if (MouseX > 160 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX - 160, MouseY); SetCursorPos(MouseX - 160, MouseY);
} }
} else { } else {
if(MouseX < 480 && MouseY < VIEWPORT_HEIGHT) { if (MouseX < 480 && MouseY < VIEWPORT_HEIGHT) {
SetCursorPos(MouseX + 160, MouseY); SetCursorPos(MouseX + 160, MouseY);
} }
} }
@ -1322,9 +1322,9 @@ void PressChar(int vkey)
return; return;
case 'Q': case 'Q':
case 'q': case 'q':
if(!stextflag) { if (!stextflag) {
chrflag = 0; chrflag = 0;
if(!questlog) { if (!questlog) {
StartQuestlog(); StartQuestlog();
} else { } else {
questlog = FALSE; questlog = FALSE;
@ -1337,9 +1337,9 @@ void PressChar(int vkey)
return; return;
case 'S': case 'S':
case 's': case 's':
if(!stextflag) { if (!stextflag) {
invflag = 0; invflag = 0;
if(!spselflag) { if (!spselflag) {
DoSpeedBook(); DoSpeedBook();
} else { } else {
spselflag = 0; spselflag = 0;
@ -1349,20 +1349,20 @@ void PressChar(int vkey)
return; return;
case 'B': case 'B':
case 'b': case 'b':
if(!stextflag) { if (!stextflag) {
invflag = 0; invflag = 0;
sbookflag = sbookflag == 0; sbookflag = sbookflag == 0;
} }
return; return;
case '+': case '+':
case '=': case '=':
if(automapflag) { if (automapflag) {
AutomapZoomIn(); AutomapZoomIn();
} }
return; return;
case '-': case '-':
case '_': case '_':
if(automapflag) { if (automapflag) {
AutomapZoomOut(); AutomapZoomOut();
} }
return; return;
@ -1374,95 +1374,95 @@ void PressChar(int vkey)
return; return;
case '!': case '!':
case '1': case '1':
if(plr[myplr].SpdList[0]._itype != -1 && plr[myplr].SpdList[0]._itype != 11) { if (plr[myplr].SpdList[0]._itype != -1 && plr[myplr].SpdList[0]._itype != 11) {
UseInvItem(myplr, 47); UseInvItem(myplr, 47);
} }
return; return;
case '@': case '@':
case '2': case '2':
if(plr[myplr].SpdList[1]._itype != -1 && plr[myplr].SpdList[1]._itype != 11) { if (plr[myplr].SpdList[1]._itype != -1 && plr[myplr].SpdList[1]._itype != 11) {
UseInvItem(myplr, 48); UseInvItem(myplr, 48);
} }
return; return;
case '#': case '#':
case '3': case '3':
if(plr[myplr].SpdList[2]._itype != -1 && plr[myplr].SpdList[2]._itype != 11) { if (plr[myplr].SpdList[2]._itype != -1 && plr[myplr].SpdList[2]._itype != 11) {
UseInvItem(myplr, 49); UseInvItem(myplr, 49);
} }
return; return;
case '$': case '$':
case '4': case '4':
if(plr[myplr].SpdList[3]._itype != -1 && plr[myplr].SpdList[3]._itype != 11) { if (plr[myplr].SpdList[3]._itype != -1 && plr[myplr].SpdList[3]._itype != 11) {
UseInvItem(myplr, 50); UseInvItem(myplr, 50);
} }
return; return;
case '%': case '%':
case '5': case '5':
if(plr[myplr].SpdList[4]._itype != -1 && plr[myplr].SpdList[4]._itype != 11) { if (plr[myplr].SpdList[4]._itype != -1 && plr[myplr].SpdList[4]._itype != 11) {
UseInvItem(myplr, 51); UseInvItem(myplr, 51);
} }
return; return;
case '^': case '^':
case '6': case '6':
if(plr[myplr].SpdList[5]._itype != -1 && plr[myplr].SpdList[5]._itype != 11) { if (plr[myplr].SpdList[5]._itype != -1 && plr[myplr].SpdList[5]._itype != 11) {
UseInvItem(myplr, 52); UseInvItem(myplr, 52);
} }
return; return;
case '&': case '&':
case '7': case '7':
if(plr[myplr].SpdList[6]._itype != -1 && plr[myplr].SpdList[6]._itype != 11) { if (plr[myplr].SpdList[6]._itype != -1 && plr[myplr].SpdList[6]._itype != 11) {
UseInvItem(myplr, 53); UseInvItem(myplr, 53);
} }
return; return;
case '*': case '*':
case '8': case '8':
#ifdef _DEBUG #ifdef _DEBUG
if(debug_mode_key_inverted_v || debug_mode_key_w) { if (debug_mode_key_inverted_v || debug_mode_key_w) {
NetSendCmd(TRUE, CMD_CHEAT_EXPERIENCE); NetSendCmd(TRUE, CMD_CHEAT_EXPERIENCE);
return; return;
} }
#endif #endif
if(plr[myplr].SpdList[7]._itype != -1 && plr[myplr].SpdList[7]._itype != 11) { if (plr[myplr].SpdList[7]._itype != -1 && plr[myplr].SpdList[7]._itype != 11) {
UseInvItem(myplr, 54); UseInvItem(myplr, 54);
} }
return; return;
#ifdef _DEBUG #ifdef _DEBUG
case ')': case ')':
case '0': case '0':
if(debug_mode_key_inverted_v) { if (debug_mode_key_inverted_v) {
if(arrowdebug > 2) { if (arrowdebug > 2) {
arrowdebug = 0; arrowdebug = 0;
} }
if(arrowdebug == 0) { if (arrowdebug == 0) {
plr[myplr]._pIFlags &= ~ISPL_FIRE_ARROWS; plr[myplr]._pIFlags &= ~ISPL_FIRE_ARROWS;
plr[myplr]._pIFlags &= ~ISPL_LIGHT_ARROWS; plr[myplr]._pIFlags &= ~ISPL_LIGHT_ARROWS;
} }
if(arrowdebug == 1) { if (arrowdebug == 1) {
plr[myplr]._pIFlags |= ISPL_FIRE_ARROWS; plr[myplr]._pIFlags |= ISPL_FIRE_ARROWS;
} }
if(arrowdebug == 2) { if (arrowdebug == 2) {
plr[myplr]._pIFlags |= ISPL_LIGHT_ARROWS; plr[myplr]._pIFlags |= ISPL_LIGHT_ARROWS;
} }
arrowdebug++; arrowdebug++;
} }
return; return;
case ':': case ':':
if(currlevel == 0 && debug_mode_key_w) { if (currlevel == 0 && debug_mode_key_w) {
SetAllSpellsCheat(); SetAllSpellsCheat();
} }
return; return;
case '[': case '[':
if(currlevel == 0 && debug_mode_key_w) { if (currlevel == 0 && debug_mode_key_w) {
TakeGoldCheat(); TakeGoldCheat();
} }
return; return;
case ']': case ']':
if(currlevel == 0 && debug_mode_key_w) { if (currlevel == 0 && debug_mode_key_w) {
MaxSpellsCheat(); MaxSpellsCheat();
} }
return; return;
case 'a': case 'a':
if(debug_mode_key_inverted_v) { if (debug_mode_key_inverted_v) {
spelldata[SPL_TELEPORT].sTownSpell = 1; spelldata[SPL_TELEPORT].sTownSpell = 1;
plr[myplr]._pSplLvl[plr[myplr]._pSpell]++; plr[myplr]._pSplLvl[plr[myplr]._pSpell]++;
} }
@ -1474,14 +1474,14 @@ void PressChar(int vkey)
PrintDebugPlayer(FALSE); PrintDebugPlayer(FALSE);
return; return;
case 'e': case 'e':
if(debug_mode_key_d) { if (debug_mode_key_d) {
sprintf(tempstr, "EFlag = %i", plr[myplr]._peflag); sprintf(tempstr, "EFlag = %i", plr[myplr]._peflag);
NetSendCmdString(1 << myplr, tempstr); NetSendCmdString(1 << myplr, tempstr);
} }
return; return;
case 'L': case 'L':
case 'l': case 'l':
if(debug_mode_key_inverted_v) { if (debug_mode_key_inverted_v) {
ToggleLighting(); ToggleLighting();
} }
return; return;
@ -1502,7 +1502,7 @@ void PressChar(int vkey)
return; return;
case 'T': case 'T':
case 't': case 't':
if(debug_mode_key_inverted_v) { 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].WorldX, plr[myplr].WorldY);
NetSendCmdString(1 << myplr, tempstr); NetSendCmdString(1 << myplr, tempstr);
sprintf(tempstr, "CX = %i CY = %i DP = %i", cursmx, cursmy, dungeon[cursmx][cursmy]); sprintf(tempstr, "CX = %i CY = %i DP = %i", cursmx, cursmy, dungeon[cursmx][cursmy]);
@ -1510,12 +1510,12 @@ void PressChar(int vkey)
} }
return; return;
case '|': case '|':
if(currlevel == 0 && debug_mode_key_w) { if (currlevel == 0 && debug_mode_key_w) {
GiveGoldCheat(); GiveGoldCheat();
} }
return; return;
case '~': case '~':
if(currlevel == 0 && debug_mode_key_w) { if (currlevel == 0 && debug_mode_key_w) {
StoresCheat(); StoresCheat();
} }
return; return;
@ -1533,7 +1533,7 @@ void LoadLvlGFX()
{ {
/// ASSERT: assert(! pDungeonCels); /// ASSERT: assert(! pDungeonCels);
switch((unsigned char)leveltype) { switch ((unsigned char)leveltype) {
case DTYPE_TOWN: case DTYPE_TOWN:
pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", 0); pDungeonCels = LoadFileInMem("Levels\\TownData\\Town.CEL", 0);
pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0); pMegaTiles = LoadFileInMem("Levels\\TownData\\Town.TIL", 0);
@ -1584,7 +1584,7 @@ void LoadAllGFX()
void CreateLevel(int lvldir) void CreateLevel(int lvldir)
{ {
switch(leveltype) { switch (leveltype) {
case DTYPE_TOWN: case DTYPE_TOWN:
CreateTown(lvldir); CreateTown(lvldir);
InitTownTriggers(); InitTownTriggers();
@ -1859,25 +1859,25 @@ void game_loop(BOOL bStartup)
void game_logic() void game_logic()
{ {
if(PauseMode == 2) { if (PauseMode == 2) {
return; return;
} }
if(PauseMode == 1) { if (PauseMode == 1) {
PauseMode = 2; PauseMode = 2;
} }
if(gbMaxPlayers == 1 && gmenu_exception()) { if (gbMaxPlayers == 1 && gmenu_exception()) {
drawpanflag |= 1; drawpanflag |= 1;
return; return;
} }
if(!gmenu_exception() && sgnTimeoutCurs == 0) { if (!gmenu_exception() && sgnTimeoutCurs == 0) {
CheckCursMove(); CheckCursMove();
track_process(); track_process();
} }
if(gbProcessPlayers) { if (gbProcessPlayers) {
ProcessPlayers(); ProcessPlayers();
} }
if(leveltype != DTYPE_TOWN) { if (leveltype != DTYPE_TOWN) {
ProcessMonsters(); ProcessMonsters();
ProcessObjects(); ProcessObjects();
ProcessMissiles(); ProcessMissiles();
@ -1891,7 +1891,7 @@ void game_logic()
} }
#ifdef _DEBUG #ifdef _DEBUG
if(debug_mode_key_inverted_v && GetAsyncKeyState(VK_SHIFT) & 0x8000) { if (debug_mode_key_inverted_v && GetAsyncKeyState(VK_SHIFT) & 0x8000) {
ScrollView(); ScrollView();
} }
#endif #endif

24
Source/drlg_l1.cpp

@ -1495,7 +1495,7 @@ void DRLG_L5GChamber(int sx, int sy, BOOL topflag, BOOL bottomflag, BOOL leftfla
{ {
int i, j; int i, j;
if(topflag == TRUE) { if (topflag == TRUE) {
dungeon[sx + 2][sy] = 12; dungeon[sx + 2][sy] = 12;
dungeon[sx + 3][sy] = 12; dungeon[sx + 3][sy] = 12;
dungeon[sx + 4][sy] = 3; dungeon[sx + 4][sy] = 3;
@ -1503,19 +1503,19 @@ void DRLG_L5GChamber(int sx, int sy, BOOL topflag, BOOL bottomflag, BOOL leftfla
dungeon[sx + 8][sy] = 12; dungeon[sx + 8][sy] = 12;
dungeon[sx + 9][sy] = 2; dungeon[sx + 9][sy] = 2;
} }
if(bottomflag == TRUE) { if (bottomflag == TRUE) {
sy += 11; sy += 11;
dungeon[sx + 2][sy] = 10; dungeon[sx + 2][sy] = 10;
dungeon[sx + 3][sy] = 12; dungeon[sx + 3][sy] = 12;
dungeon[sx + 4][sy] = 8; dungeon[sx + 4][sy] = 8;
dungeon[sx + 7][sy] = 5; dungeon[sx + 7][sy] = 5;
dungeon[sx + 8][sy] = 12; dungeon[sx + 8][sy] = 12;
if(dungeon[sx + 9][sy] != 4) { if (dungeon[sx + 9][sy] != 4) {
dungeon[sx + 9][sy] = 21; dungeon[sx + 9][sy] = 21;
} }
sy -= 11; sy -= 11;
} }
if(leftflag == TRUE) { if (leftflag == TRUE) {
dungeon[sx][sy + 2] = 11; dungeon[sx][sy + 2] = 11;
dungeon[sx][sy + 3] = 11; dungeon[sx][sy + 3] = 11;
dungeon[sx][sy + 4] = 3; dungeon[sx][sy + 4] = 3;
@ -1523,21 +1523,21 @@ void DRLG_L5GChamber(int sx, int sy, BOOL topflag, BOOL bottomflag, BOOL leftfla
dungeon[sx][sy + 8] = 11; dungeon[sx][sy + 8] = 11;
dungeon[sx][sy + 9] = 1; dungeon[sx][sy + 9] = 1;
} }
if(rightflag == TRUE) { if (rightflag == TRUE) {
sx += 11; sx += 11;
dungeon[sx][sy + 2] = 14; dungeon[sx][sy + 2] = 14;
dungeon[sx][sy + 3] = 11; dungeon[sx][sy + 3] = 11;
dungeon[sx][sy + 4] = 9; dungeon[sx][sy + 4] = 9;
dungeon[sx][sy + 7] = 5; dungeon[sx][sy + 7] = 5;
dungeon[sx][sy + 8] = 11; dungeon[sx][sy + 8] = 11;
if(dungeon[sx][sy + 9] != 4) { if (dungeon[sx][sy + 9] != 4) {
dungeon[sx][sy + 9] = 21; dungeon[sx][sy + 9] = 21;
} }
sx -= 11; sx -= 11;
} }
for(j = 1; j < 11; j++) { for (j = 1; j < 11; j++) {
for(i = 1; i < 11; i++) { for (i = 1; i < 11; i++) {
dungeon[i + sx][j + sy] = 13; dungeon[i + sx][j + sy] = 13;
L5dflags[i + sx][j + sy] |= 0x40; L5dflags[i + sx][j + sy] |= 0x40;
} }
@ -1720,13 +1720,13 @@ void DRLG_L5CornerFix()
{ {
int i, j; int i, j;
for(j = 1; j < DMAXY - 1; j++) { for (j = 1; j < DMAXY - 1; j++) {
for(i = 1; i < DMAXX - 1; i++) { for (i = 1; i < DMAXX - 1; i++) {
if(!(L5dflags[i][j] & 0x80) && dungeon[i][j] == 17 && dungeon[i - 1][j] == 13 && dungeon[i][j - 1] == 1) { if (!(L5dflags[i][j] & 0x80) && dungeon[i][j] == 17 && dungeon[i - 1][j] == 13 && dungeon[i][j - 1] == 1) {
dungeon[i][j] = 16; dungeon[i][j] = 16;
L5dflags[i][j - 1] &= 0x80; L5dflags[i][j - 1] &= 0x80;
} }
if(dungeon[i][j] == 202 && dungeon[i + 1][j] == 13 && dungeon[i][j + 1] == 1) { if (dungeon[i][j] == 202 && dungeon[i + 1][j] == 13 && dungeon[i][j + 1] == 1) {
dungeon[i][j] = 8; dungeon[i][j] = 8;
} }
} }

816
Source/drlg_l3.cpp

File diff suppressed because it is too large Load Diff

612
Source/drlg_l4.cpp

File diff suppressed because it is too large Load Diff

3
Source/effects.cpp

@ -1095,7 +1095,7 @@ int RndSFX(int psfx)
nRand = 3; nRand = 3;
else else
return psfx; return psfx;
return psfx + random(165, nRand); return psfx + random(165, nRand);
} }
void PlaySfxLoc(int psfx, int x, int y) void PlaySfxLoc(int psfx, int x, int y)
@ -1162,7 +1162,6 @@ void effects_update()
} }
} }
void effects_cleanup_sfx() void effects_cleanup_sfx()
{ {
DWORD i; DWORD i;

18
Source/error.cpp

@ -91,13 +91,13 @@ void DrawDiabloMsg()
CelDecodeOnly(591, 366, (BYTE *)pSTextSlidCels, 3, 12); CelDecodeOnly(591, 366, (BYTE *)pSTextSlidCels, 3, 12);
sx = 173; sx = 173;
for(i = 0; i < 35; i++) { for (i = 0; i < 35; i++) {
CelDecodeOnly(sx, 318, (BYTE *)pSTextSlidCels, 5, 12); CelDecodeOnly(sx, 318, (BYTE *)pSTextSlidCels, 5, 12);
CelDecodeOnly(sx, 366, (BYTE *)pSTextSlidCels, 7, 12); CelDecodeOnly(sx, 366, (BYTE *)pSTextSlidCels, 7, 12);
sx += 12; sx += 12;
} }
sy = 330; sy = 330;
for(i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
CelDecodeOnly(165, sy, (BYTE *)pSTextSlidCels, 6, 12); CelDecodeOnly(165, sy, (BYTE *)pSTextSlidCels, 6, 12);
CelDecodeOnly(591, sy, (BYTE *)pSTextSlidCels, 8, 12); CelDecodeOnly(591, sy, (BYTE *)pSTextSlidCels, 8, 12);
sy += 12; sy += 12;
@ -116,29 +116,29 @@ void DrawDiabloMsg()
len = strlen(tempstr); len = strlen(tempstr);
width = 0; width = 0;
for(i = 0; i < len; i++) { for (i = 0; i < len; i++) {
width += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1; width += fontkern[fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]] + 1;
} }
if(width < 442) { if (width < 442) {
off += (442 - width) >> 1; off += (442 - width) >> 1;
} }
for(i = 0; i < len; i++) { for (i = 0; i < len; i++) {
c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; c = fontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
if(c != '\0') { if (c != '\0') {
CPrintString(off, c, COL_GOLD); CPrintString(off, c, COL_GOLD);
} }
off += fontkern[c] + 1; off += fontkern[c] + 1;
} }
if(msgdelay > 0) { if (msgdelay > 0) {
msgdelay--; msgdelay--;
} }
if(msgdelay == 0) { if (msgdelay == 0) {
msgcnt--; msgcnt--;
msgdelay = 70; msgdelay = 70;
if(msgcnt == 0) { if (msgcnt == 0) {
msgflag = 0; msgflag = 0;
} else { } else {
msgflag = msgtable[msgcnt]; msgflag = msgtable[msgcnt];

2
Source/fault.cpp

@ -24,7 +24,7 @@ void fault_init_filter()
void fault_cleanup_filter_atexit() void fault_cleanup_filter_atexit()
{ {
atexit((void (__cdecl *)(void ))fault_cleanup_filter); atexit((void(__cdecl *)(void))fault_cleanup_filter);
} }
LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter() LPTOP_LEVEL_EXCEPTION_FILTER __cdecl fault_cleanup_filter()

134
Source/gendung.cpp

@ -52,16 +52,16 @@ char nMissileTable[2049];
char *pSetPiece_2; char *pSetPiece_2;
char setlvltype; // weak char setlvltype; // weak
BOOLEAN setlevel; BOOLEAN setlevel;
int LvlViewY; // weak int LvlViewY; // weak
int LvlViewX; // weak int LvlViewX; // weak
int dmaxx; // weak int dmaxx; // weak
int dmaxy; // weak int dmaxy; // weak
int setpc_h; // weak int setpc_h; // weak
int setpc_w; // weak int setpc_w; // weak
int setpc_x; // idb int setpc_x; // idb
int ViewX; // idb int ViewX; // idb
int ViewY; // idb int ViewY; // idb
int setpc_y; // idb int setpc_y; // idb
char dMissile[MAXDUNX][MAXDUNY]; char dMissile[MAXDUNX][MAXDUNY];
int dminx; // weak int dminx; // weak
int dminy; // weak int dminy; // weak
@ -122,14 +122,14 @@ void FillSolidBlockTbls()
void MakeSpeedCels() void MakeSpeedCels()
{ {
int i, j, k, x, y, mt, t, z; int i, j, x, y, mt, t, z;
int total_frames, blocks, total_size, frameidx, blk_cnt, nDataSize; int total_frames, blocks, total_size, frameidx, blk_cnt, nDataSize;
WORD m; WORD m;
BOOL blood_flag; BOOL blood_flag;
DWORD *pFrameTable; DWORD *pFrameTable;
MICROS *pMap; MICROS *pMap;
#ifndef USE_ASM #ifndef USE_ASM
int l; int l, k;
BYTE width, pix; BYTE width, pix;
BYTE *src, *dst, *tbl; BYTE *src, *dst, *tbl;
#endif #endif
@ -576,8 +576,8 @@ void DRLG_MRectTrans(int x1, int y1, int x2, int y2)
x2 = 2 * x2 + 16; x2 = 2 * x2 + 16;
y2 = 2 * y2 + 16; y2 = 2 * y2 + 16;
for(j = y1; j <= y2; j++) { for (j = y1; j <= y2; j++) {
for(i = x1; i <= x2; i++) { for (i = x1; i <= x2; i++) {
dTransVal[i][j] = TransVal; dTransVal[i][j] = TransVal;
} }
} }
@ -769,60 +769,60 @@ void DRLG_CreateThemeRoom(int themeIndex)
{ {
int xx, yy; int xx, yy;
for(yy = themeLoc[themeIndex].y; yy < themeLoc[themeIndex].y + themeLoc[themeIndex].height; yy++) { for (yy = themeLoc[themeIndex].y; yy < themeLoc[themeIndex].y + themeLoc[themeIndex].height; yy++) {
for(xx = themeLoc[themeIndex].x; xx < themeLoc[themeIndex].x + themeLoc[themeIndex].width; xx++) { for (xx = themeLoc[themeIndex].x; xx < themeLoc[themeIndex].x + themeLoc[themeIndex].width; xx++) {
if(leveltype == DTYPE_CATACOMBS) { if (leveltype == DTYPE_CATACOMBS) {
if(yy == themeLoc[themeIndex].y if (yy == themeLoc[themeIndex].y
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width
|| yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1 || yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) { && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) {
dungeon[xx][yy] = 2; dungeon[xx][yy] = 2;
} else if(xx == themeLoc[themeIndex].x } else if (xx == themeLoc[themeIndex].x
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height
|| xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1 || xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) { && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) {
dungeon[xx][yy] = 1; dungeon[xx][yy] = 1;
} else { } else {
dungeon[xx][yy] = 3; dungeon[xx][yy] = 3;
} }
} }
if(leveltype == DTYPE_CAVES) { if (leveltype == DTYPE_CAVES) {
if(yy == themeLoc[themeIndex].y if (yy == themeLoc[themeIndex].y
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width
|| yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1 || yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) { && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) {
dungeon[xx][yy] = 134; dungeon[xx][yy] = 134;
} else if(xx == themeLoc[themeIndex].x } else if (xx == themeLoc[themeIndex].x
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height
|| xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1 || xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) { && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) {
dungeon[xx][yy] = 137; dungeon[xx][yy] = 137;
} else { } else {
dungeon[xx][yy] = 7; dungeon[xx][yy] = 7;
} }
} }
if(leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
if(yy == themeLoc[themeIndex].y if (yy == themeLoc[themeIndex].y
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width
|| yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1 || yy == themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1
&& xx >= themeLoc[themeIndex].x && xx >= themeLoc[themeIndex].x
&& xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) { && xx <= themeLoc[themeIndex].x + themeLoc[themeIndex].width) {
dungeon[xx][yy] = 2; dungeon[xx][yy] = 2;
} else if(xx == themeLoc[themeIndex].x } else if (xx == themeLoc[themeIndex].x
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height
|| xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1 || xx == themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1
&& yy >= themeLoc[themeIndex].y && yy >= themeLoc[themeIndex].y
&& yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) { && yy <= themeLoc[themeIndex].y + themeLoc[themeIndex].height) {
dungeon[xx][yy] = 1; dungeon[xx][yy] = 1;
} else { } else {
dungeon[xx][yy] = 6; dungeon[xx][yy] = 6;
@ -831,27 +831,27 @@ void DRLG_CreateThemeRoom(int themeIndex)
} }
} }
if(leveltype == DTYPE_CATACOMBS) { if (leveltype == DTYPE_CATACOMBS) {
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 8; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 8;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 7; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 7;
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 9; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 9;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 6; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 6;
} }
if(leveltype == DTYPE_CAVES) { if (leveltype == DTYPE_CAVES) {
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 150; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 150;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 151; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 151;
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 152; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 152;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 138; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 138;
} }
if(leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 9; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y] = 9;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 16; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y] = 16;
dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 15; dungeon[themeLoc[themeIndex].x][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 15;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 12; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height - 1] = 12;
} }
if(leveltype == DTYPE_CATACOMBS) { if (leveltype == DTYPE_CATACOMBS) {
switch(random(0, 2)) { switch (random(0, 2)) {
case 0: case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 4; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 4;
break; break;
@ -860,8 +860,8 @@ void DRLG_CreateThemeRoom(int themeIndex)
break; break;
} }
} }
if(leveltype == DTYPE_CAVES) { if (leveltype == DTYPE_CAVES) {
switch(random(0, 2)) { switch (random(0, 2)) {
case 0: case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 147; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 147;
break; break;
@ -870,8 +870,8 @@ void DRLG_CreateThemeRoom(int themeIndex)
break; break;
} }
} }
if(leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
switch(random(0, 2)) { switch (random(0, 2)) {
case 0: case 0:
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2 - 1] = 53; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2 - 1] = 53;
dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 6; dungeon[themeLoc[themeIndex].x + themeLoc[themeIndex].width - 1][themeLoc[themeIndex].y + themeLoc[themeIndex].height / 2] = 6;
@ -934,9 +934,9 @@ void DRLG_HoldThemeRooms()
{ {
int i, x, y, xx, yy; int i, x, y, xx, yy;
for(i = 0; i < themeCount; i++) { for (i = 0; i < themeCount; i++) {
for(y = themeLoc[i].y; y < themeLoc[i].y + themeLoc[i].height - 1; y++) { for (y = themeLoc[i].y; y < themeLoc[i].y + themeLoc[i].height - 1; y++) {
for(x = themeLoc[i].x; x < themeLoc[i].x + themeLoc[i].width - 1; x++) { for (x = themeLoc[i].x; x < themeLoc[i].x + themeLoc[i].width - 1; x++) {
xx = 2 * x + 16; xx = 2 * x + 16;
yy = 2 * y + 16; yy = 2 * y + 16;
dFlags[xx][yy] |= BFLAG_POPULATED; dFlags[xx][yy] |= BFLAG_POPULATED;

37
Source/init.cpp

@ -54,7 +54,7 @@ void init_run_office_from_start_menu()
{ {
LPITEMIDLIST idl; LPITEMIDLIST idl;
if(!killed_mom_parent) { if (!killed_mom_parent) {
return; return;
} }
@ -62,7 +62,7 @@ void init_run_office_from_start_menu()
char szPath[256] = ""; /// BUGFIX: size should be at least 'MAX_PATH' char szPath[256] = ""; /// BUGFIX: size should be at least 'MAX_PATH'
idl = NULL; idl = NULL;
if(SHGetSpecialFolderLocation(GetDesktopWindow(), CSIDL_STARTMENU, &idl) == NOERROR) { if (SHGetSpecialFolderLocation(GetDesktopWindow(), CSIDL_STARTMENU, &idl) == NOERROR) {
SHGetPathFromIDList(idl, szPath); SHGetPathFromIDList(idl, szPath);
init_run_office(szPath); init_run_office(szPath);
} }
@ -76,31 +76,31 @@ void init_run_office(char *dir)
char szFirst[MAX_PATH]; char szFirst[MAX_PATH];
strcpy(szFirst, dir); strcpy(szFirst, dir);
if(szFirst[0] != '\0' && szFirst[strlen(szFirst) - 1] == '\\') { if (szFirst[0] != '\0' && szFirst[strlen(szFirst) - 1] == '\\') {
strcat(szFirst, "*"); strcat(szFirst, "*");
} else { } else {
strcat(szFirst, "\\*"); strcat(szFirst, "\\*");
} }
hSearch = FindFirstFile(szFirst, &find); hSearch = FindFirstFile(szFirst, &find);
if(hSearch == INVALID_HANDLE_VALUE) { if (hSearch == INVALID_HANDLE_VALUE) {
return; return;
} }
while(1) { while (1) {
if(find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
if(strcmp(find.cFileName, ".") != 0 && strcmp(find.cFileName, "..") != 0) { if (strcmp(find.cFileName, ".") != 0 && strcmp(find.cFileName, "..") != 0) {
char szNext[MAX_PATH] = ""; char szNext[MAX_PATH] = "";
if(dir[0] != '\0' && dir[strlen(dir) - 1] == '\\') { if (dir[0] != '\0' && dir[strlen(dir) - 1] == '\\') {
sprintf(szNext, "%s%s\\", dir, find.cFileName); sprintf(szNext, "%s%s\\", dir, find.cFileName);
} else { } else {
sprintf(szNext, "%s\\%s\\", dir, find.cFileName); sprintf(szNext, "%s\\%s\\", dir, find.cFileName);
} }
init_run_office(szNext); init_run_office(szNext);
} }
} else if(_strcmpi(find.cFileName, "Microsoft Office Shortcut Bar.lnk") == 0) { } else if (_strcmpi(find.cFileName, "Microsoft Office Shortcut Bar.lnk") == 0) {
ShellExecute(GetDesktopWindow(), "open", find.cFileName, "", dir, SW_SHOWNORMAL); ShellExecute(GetDesktopWindow(), "open", find.cFileName, "", dir, SW_SHOWNORMAL);
} }
if(!FindNextFile(hSearch, &find)) { if (!FindNextFile(hSearch, &find)) {
break; break;
} }
} }
@ -227,8 +227,8 @@ void init_archives()
#ifdef COPYPROT #ifdef COPYPROT
int result; int result;
#endif #endif
memset (&fileinfo, 0, sizeof (fileinfo)); memset(&fileinfo, 0, sizeof(fileinfo));
fileinfo.size = sizeof (fileinfo); fileinfo.size = sizeof(fileinfo);
fileinfo.versionstring = gszVersionNumber; fileinfo.versionstring = gszVersionNumber;
fileinfo.executablefile = diablo_exe_path; fileinfo.executablefile = diablo_exe_path;
fileinfo.originalarchivefile = diabdat_mpq_path; fileinfo.originalarchivefile = diabdat_mpq_path;
@ -329,22 +329,23 @@ BOOL init_read_test_file(char *pszPath, char *pszArchive, int flags, HANDLE *phA
char szDrive[MAX_PATH]; char szDrive[MAX_PATH];
dwSize = GetLogicalDriveStrings(sizeof(szDrive), szDrive); dwSize = GetLogicalDriveStrings(sizeof(szDrive), szDrive);
if(dwSize == 0 || dwSize > sizeof(szDrive)) { if (dwSize == 0 || dwSize > sizeof(szDrive)) {
return FALSE; return FALSE;
} }
while(*pszArchive == '\\') { while (*pszArchive == '\\') {
pszArchive++; pszArchive++;
} }
pszDrive = szDrive; pszDrive = szDrive;
while(*pszDrive != '\0') { while (*pszDrive != '\0') {
pszRoot = pszDrive; pszRoot = pszDrive;
while(*pszDrive++ != '\0'); while (*pszDrive++ != '\0')
if(GetDriveType(pszRoot) == DRIVE_CDROM) { ;
if (GetDriveType(pszRoot) == DRIVE_CDROM) {
strcpy(pszPath, pszRoot); strcpy(pszPath, pszRoot);
strcat(pszPath, pszArchive); strcat(pszPath, pszArchive);
if(SFileOpenArchive(pszPath, flags, 1, phArchive)) { if (SFileOpenArchive(pszPath, flags, 1, phArchive)) {
return TRUE; return TRUE;
} }
} }

20
Source/interfac.cpp

@ -243,9 +243,9 @@ void InitCutscene(unsigned int uMsg)
{ {
/// ASSERT: assert(! sgpBackCel); /// ASSERT: assert(! sgpBackCel);
switch(uMsg) { switch (uMsg) {
case WM_DIABNEXTLVL: case WM_DIABNEXTLVL:
switch(gnLevelTypeTbl[currlevel]) { switch (gnLevelTypeTbl[currlevel]) {
case 0: case 0:
sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
LoadPalette("Gendata\\Cuttt.pal"); LoadPalette("Gendata\\Cuttt.pal");
@ -267,7 +267,7 @@ void InitCutscene(unsigned int uMsg)
progress_id = 1; progress_id = 1;
break; break;
case 4: case 4:
if(currlevel < 15) { if (currlevel < 15) {
sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cut4.CEL", 0);
LoadPalette("Gendata\\Cut4.pal"); LoadPalette("Gendata\\Cut4.pal");
progress_id = 1; progress_id = 1;
@ -285,12 +285,12 @@ void InitCutscene(unsigned int uMsg)
} }
break; break;
case WM_DIABPREVLVL: case WM_DIABPREVLVL:
if(gnLevelTypeTbl[currlevel - 1] == 0) { if (gnLevelTypeTbl[currlevel - 1] == 0) {
sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
LoadPalette("Gendata\\Cuttt.pal"); LoadPalette("Gendata\\Cuttt.pal");
progress_id = 1; progress_id = 1;
} else { } else {
switch(gnLevelTypeTbl[currlevel]) { switch (gnLevelTypeTbl[currlevel]) {
case 0: case 0:
sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
LoadPalette("Gendata\\Cuttt.pal"); LoadPalette("Gendata\\Cuttt.pal");
@ -325,11 +325,11 @@ void InitCutscene(unsigned int uMsg)
} }
break; break;
case WM_DIABSETLVL: case WM_DIABSETLVL:
if(setlvlnum == SL_BONECHAMB) { if (setlvlnum == SL_BONECHAMB) {
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal"); LoadPalette("Gendata\\Cut2.pal");
progress_id = 2; progress_id = 2;
} else if(setlvlnum == SL_VILEBETRAYER) { } else if (setlvlnum == SL_VILEBETRAYER) {
sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0);
LoadPalette("Gendata\\Cutportr.pal"); LoadPalette("Gendata\\Cutportr.pal");
progress_id = 1; progress_id = 1;
@ -340,11 +340,11 @@ void InitCutscene(unsigned int uMsg)
} }
break; break;
case WM_DIABRTNLVL: case WM_DIABRTNLVL:
if(setlvlnum == SL_BONECHAMB) { if (setlvlnum == SL_BONECHAMB) {
sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cut2.CEL", 0);
LoadPalette("Gendata\\Cut2.pal"); LoadPalette("Gendata\\Cut2.pal");
progress_id = 2; progress_id = 2;
} else if(setlvlnum == SL_VILEBETRAYER) { } else if (setlvlnum == SL_VILEBETRAYER) {
sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cutportr.CEL", 0);
LoadPalette("Gendata\\Cutportr.pal"); LoadPalette("Gendata\\Cutportr.pal");
progress_id = 1; progress_id = 1;
@ -371,7 +371,7 @@ void InitCutscene(unsigned int uMsg)
break; break;
case WM_DIABTOWNWARP: case WM_DIABTOWNWARP:
case WM_DIABTWARPUP: case WM_DIABTWARPUP:
switch(gnLevelTypeTbl[plr[myplr].plrlevel]) { switch (gnLevelTypeTbl[plr[myplr].plrlevel]) {
case 0: case 0:
sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0); sgpBackCel = LoadFileInMem("Gendata\\Cuttt.CEL", 0);
LoadPalette("Gendata\\Cuttt.pal"); LoadPalette("Gendata\\Cuttt.pal");

36
Source/minitext.cpp

@ -215,14 +215,14 @@ void DrawQText()
ty = qtexty; ty = qtexty;
doneflag = FALSE; doneflag = FALSE;
while(!doneflag) { while (!doneflag) {
w = 0; w = 0;
s = p; s = p;
l = 0; l = 0;
while(*s != '\n' && *s != '|' && w < 543) { while (*s != '\n' && *s != '|' && w < 543) {
c = gbFontTransTbl[(BYTE)*s]; c = gbFontTransTbl[(BYTE)*s];
s++; s++;
if(c != '\0') { if (c != '\0') {
tempstr[l] = c; tempstr[l] = c;
w += mfontkern[mfontframe[c]] + 2; w += mfontkern[mfontframe[c]] + 2;
} else { } else {
@ -231,60 +231,60 @@ void DrawQText()
l++; l++;
} }
tempstr[l] = '\0'; tempstr[l] = '\0';
if(*s == '|') { if (*s == '|') {
tempstr[l] = '\0'; tempstr[l] = '\0';
doneflag = TRUE; doneflag = TRUE;
} else if(*s != '\n') { } else if (*s != '\n') {
while(tempstr[l] != ' ' && l > 0) { while (tempstr[l] != ' ' && l > 0) {
tempstr[l] = '\0'; tempstr[l] = '\0';
l--; l--;
} }
} }
for(i = 0; tempstr[i]; i++) { for (i = 0; tempstr[i]; i++) {
p++; p++;
c = mfontframe[gbFontTransTbl[(BYTE)tempstr[i]]]; c = mfontframe[gbFontTransTbl[(BYTE)tempstr[i]]];
if(*p == '\n') { if (*p == '\n') {
p++; p++;
} }
if(c != 0) { if (c != 0) {
PrintQTextChr(tx, ty, (BYTE *)pMedTextCels, c); PrintQTextChr(tx, ty, (BYTE *)pMedTextCels, c);
} }
tx += mfontkern[c] + 2; tx += mfontkern[c] + 2;
} }
if(pnl == NULL) { if (pnl == NULL) {
pnl = p; pnl = p;
} }
tx = 112; tx = 112;
ty += 38; ty += 38;
if(ty > 501) { if (ty > 501) {
doneflag = TRUE; doneflag = TRUE;
} }
} }
currTime = GetTickCount(); currTime = GetTickCount();
while(1) { while (1) {
if(sgLastScroll <= 0) { if (sgLastScroll <= 0) {
qtexty--; qtexty--;
qtexty += sgLastScroll; qtexty += sgLastScroll;
} else { } else {
scrolltexty--; scrolltexty--;
if(scrolltexty != 0) { if (scrolltexty != 0) {
qtexty--; qtexty--;
} }
} }
if(scrolltexty == 0) { if (scrolltexty == 0) {
scrolltexty = sgLastScroll; scrolltexty = sgLastScroll;
} }
if(qtexty <= 209) { if (qtexty <= 209) {
qtexty += 38; qtexty += 38;
qtextptr = pnl; qtextptr = pnl;
if(*pnl == '|') { if (*pnl == '|') {
qtextflag = 0; qtextflag = 0;
} }
break; break;
} }
qtextSpd += 50; qtextSpd += 50;
if(currTime - qtextSpd >= 0x7FFFFFFF) { if (currTime - qtextSpd >= 0x7FFFFFFF) {
break; break;
} }
} }

135
Source/monster.cpp

@ -60,7 +60,7 @@ int rnd10[4] = { 10, 15, 20, 30 };
int rnd20[4] = { 20, 30, 40, 50 }; int rnd20[4] = { 20, 30, 40, 50 };
int rnd60[4] = { 60, 70, 80, 90 }; int rnd60[4] = { 60, 70, 80, 90 };
void(*AiProc[])(int i) = { void (*AiProc[])(int i) = {
&MAI_Zombie, &MAI_Zombie,
&MAI_Fat, &MAI_Fat,
&MAI_SkelSd, &MAI_SkelSd,
@ -1045,7 +1045,7 @@ void SetMapMonsters(unsigned char *pMap, int startx, int starty)
PlaceUniqueMonst(UMT_RED_VEX, 0, 0); PlaceUniqueMonst(UMT_RED_VEX, 0, 0);
PlaceUniqueMonst(UMT_BLACKJADE, 0, 0); PlaceUniqueMonst(UMT_BLACKJADE, 0, 0);
} }
lm = (WORD*)pMap; lm = (WORD *)pMap;
rw = *lm; rw = *lm;
lm++; lm++;
rh = *lm; rh = *lm;
@ -1167,7 +1167,7 @@ void M_Enemy(int i)
continue; continue;
if (!(Monst->_mFlags & MFLAG_GOLEM) if (!(Monst->_mFlags & MFLAG_GOLEM)
&& ((abs(monster[mi]._mx - Monst->_mx) >= 2 || abs(monster[mi]._my - Monst->_my) >= 2) && !M_Ranged(i) && ((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; continue;
} }
sameroom = dTransVal[Monst->_mx][Monst->_my] == dTransVal[monster[mi]._mx][monster[mi]._my]; sameroom = dTransVal[Monst->_mx][Monst->_my] == dTransVal[monster[mi]._mx][monster[mi]._my];
@ -1564,17 +1564,17 @@ void M_DiabloDeath(int i, BOOL sendmsg)
AddLight(Monst->_mx, Monst->_my, 8); AddLight(Monst->_mx, Monst->_my, 8);
DoVision(Monst->_mx, Monst->_my, 8, FALSE, TRUE); DoVision(Monst->_mx, Monst->_my, 8, FALSE, TRUE);
if (abs(ViewX - Monst->_mx) > abs(ViewY - Monst->_my)) if (abs(ViewX - Monst->_mx) > abs(ViewY - Monst->_my))
dist = abs (ViewX - Monst->_mx); dist = abs(ViewX - Monst->_mx);
else else
dist = abs (ViewY - Monst->_my); dist = abs(ViewY - Monst->_my);
if (dist > 20) if (dist > 20)
dist = 20; dist = 20;
j = ViewX << 16; j = ViewX << 16;
k = ViewY << 16; k = ViewY << 16;
Monst->_mVar3 = j; Monst->_mVar3 = j;
Monst->_mVar4 = k; Monst->_mVar4 = k;
Monst->_mVar5 = (int) ((j - (Monst->_mx << 16)) / (double)dist); Monst->_mVar5 = (int)((j - (Monst->_mx << 16)) / (double)dist);
Monst->_mVar6 = (int) ((k - (Monst->_my << 16)) / (double)dist); Monst->_mVar6 = (int)((k - (Monst->_my << 16)) / (double)dist);
} }
void M2MStartHit(int mid, int i, int dam) void M2MStartHit(int mid, int i, int dam)
@ -2808,7 +2808,7 @@ BOOL M_CallWalk(int i, int md)
BOOL M_PathWalk(int i) BOOL M_PathWalk(int i)
{ {
char path[25]; char path[25];
BOOL(* Check) BOOL(*Check)
(int, int, int); (int, int, int);
if ((DWORD)i >= MAXMONSTERS) if ((DWORD)i >= MAXMONSTERS)
@ -3632,11 +3632,11 @@ void MAI_Scav(int i)
continue; continue;
done = dDead[Monst->_mx + x][Monst->_my + y] != 0 done = dDead[Monst->_mx + x][Monst->_my + y] != 0
&& LineClearF( && LineClearF(
CheckNoSolid, CheckNoSolid,
Monst->_mx, Monst->_mx,
Monst->_my, Monst->_my,
Monst->_mx + x, Monst->_mx + x,
Monst->_my + y); Monst->_my + y);
} }
} }
x--; x--;
@ -3649,11 +3649,11 @@ void MAI_Scav(int i)
continue; continue;
done = dDead[Monst->_mx + x][Monst->_my + y] != 0 done = dDead[Monst->_mx + x][Monst->_my + y] != 0
&& LineClearF( && LineClearF(
CheckNoSolid, CheckNoSolid,
Monst->_mx, Monst->_mx,
Monst->_my, Monst->_my,
Monst->_mx + x, Monst->_mx + x,
Monst->_my + y); Monst->_my + y);
} }
} }
x++; x++;
@ -4080,8 +4080,8 @@ void MAI_Rhino(int i)
v = random(134, 100); v = random(134, 100);
if (v >= 2 * Monst->_mint + 33 if (v >= 2 * Monst->_mint + 33
&& (Monst->_mVar1 != MM_WALK && Monst->_mVar1 != MM_WALK2 && Monst->_mVar1 != MM_WALK3 && (Monst->_mVar1 != MM_WALK && Monst->_mVar1 != MM_WALK2 && Monst->_mVar1 != MM_WALK3
|| Monst->_mVar2 || Monst->_mVar2
|| v >= 2 * Monst->_mint + 83)) { || v >= 2 * Monst->_mint + 83)) {
M_StartDelay(i, random(135, 10) + 10); M_StartDelay(i, random(135, 10) + 10);
} else { } else {
M_CallWalk(i, md); M_CallWalk(i, md);
@ -4164,8 +4164,8 @@ void MAI_Counselor(int i)
} }
} }
if (Monst->_mmode == MM_STAND) { if (Monst->_mmode == MM_STAND) {
M_StartDelay(i, random(125, 10) + 5); M_StartDelay(i, random(125, 10) + 5);
} }
} }
} }
@ -4500,16 +4500,16 @@ void ProcessMonsters()
DeleteMonsterList(); DeleteMonsterList();
/// ASSERT: assert((DWORD)nummonsters <= MAXMONSTERS); /// ASSERT: assert((DWORD)nummonsters <= MAXMONSTERS);
for(i = 0; i < nummonsters; i++) { for (i = 0; i < nummonsters; i++) {
mi = monstactive[i]; mi = monstactive[i];
Monst = &monster[mi]; Monst = &monster[mi];
raflag = FALSE; raflag = FALSE;
if(gbMaxPlayers > 1) { if (gbMaxPlayers > 1) {
SetRndSeed(Monst->_mAISeed); SetRndSeed(Monst->_mAISeed);
Monst->_mAISeed = GetRndSeed(); Monst->_mAISeed = GetRndSeed();
} }
if(!(monster[mi]._mFlags & MFLAG_NOHEAL) && Monst->_mhitpoints < Monst->_mmaxhp && Monst->_mhitpoints >> 6 > 0) { if (!(monster[mi]._mFlags & MFLAG_NOHEAL) && Monst->_mhitpoints < Monst->_mmaxhp && Monst->_mhitpoints >> 6 > 0) {
if(Monst->mLevel <= 1) { if (Monst->mLevel <= 1) {
Monst->_mhitpoints += Monst->mLevel; Monst->_mhitpoints += Monst->mLevel;
} else { } else {
Monst->_mhitpoints += Monst->mLevel >> 1; Monst->_mhitpoints += Monst->mLevel >> 1;
@ -4517,12 +4517,12 @@ void ProcessMonsters()
} }
mx = Monst->_mx; mx = Monst->_mx;
my = Monst->_my; my = Monst->_my;
if(dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0 && Monst->MType->mtype == MT_CLEAVER) { if (dFlags[mx][my] & BFLAG_VISIBLE && Monst->_msquelch == 0 && Monst->MType->mtype == MT_CLEAVER) {
PlaySFX(USFX_CLEAVER); PlaySFX(USFX_CLEAVER);
} }
if(Monst->_mFlags & MFLAG_TARGETS_MONSTER) { if (Monst->_mFlags & MFLAG_TARGETS_MONSTER) {
_menemy = Monst->_menemy; _menemy = Monst->_menemy;
if((DWORD)_menemy >= MAXMONSTERS) { if ((DWORD)_menemy >= MAXMONSTERS) {
app_fatal("Illegal enemy monster %d for monster \"%s\"", _menemy, Monst->mName); app_fatal("Illegal enemy monster %d for monster \"%s\"", _menemy, Monst->mName);
} }
Monst->_lastx = monster[Monst->_menemy]._mfutx; Monst->_lastx = monster[Monst->_menemy]._mfutx;
@ -4531,26 +4531,26 @@ void ProcessMonsters()
Monst->_menemyy = Monst->_lasty; Monst->_menemyy = Monst->_lasty;
} else { } else {
_menemy = Monst->_menemy; _menemy = Monst->_menemy;
if((DWORD)_menemy >= MAX_PLRS) { if ((DWORD)_menemy >= MAX_PLRS) {
app_fatal("Illegal enemy player %d for monster \"%s\"", _menemy, Monst->mName); app_fatal("Illegal enemy player %d for monster \"%s\"", _menemy, Monst->mName);
} }
Monst->_menemyx = plr[Monst->_menemy]._px; Monst->_menemyx = plr[Monst->_menemy]._px;
Monst->_menemyy = plr[Monst->_menemy]._py; Monst->_menemyy = plr[Monst->_menemy]._py;
if(dFlags[mx][my] & BFLAG_VISIBLE) { if (dFlags[mx][my] & BFLAG_VISIBLE) {
Monst->_msquelch = 255; Monst->_msquelch = 255;
Monst->_lastx = plr[Monst->_menemy]._px; Monst->_lastx = plr[Monst->_menemy]._px;
Monst->_lasty = plr[Monst->_menemy]._py; Monst->_lasty = plr[Monst->_menemy]._py;
} else if(Monst->_msquelch != 0 && Monst->_mAi != MT_DIABLO) { /// BUGFIX: change '_mAi' to 'MType->mtype' } else if (Monst->_msquelch != 0 && Monst->_mAi != MT_DIABLO) { /// BUGFIX: change '_mAi' to 'MType->mtype'
Monst->_msquelch--; Monst->_msquelch--;
} }
} }
do { do {
if(!(Monst->_mFlags & MFLAG_SEARCH)) { if (!(Monst->_mFlags & MFLAG_SEARCH)) {
AiProc[Monst->_mAi](mi); AiProc[Monst->_mAi](mi);
} else if(!MAI_Path(mi)) { } else if (!MAI_Path(mi)) {
AiProc[Monst->_mAi](mi); AiProc[Monst->_mAi](mi);
} }
switch(Monst->_mmode) { switch (Monst->_mmode) {
case MM_STAND: case MM_STAND:
raflag = M_DoStand(mi); raflag = M_DoStand(mi);
break; break;
@ -4606,22 +4606,22 @@ void ProcessMonsters()
raflag = M_DoTalk(mi); raflag = M_DoTalk(mi);
break; break;
} }
if(raflag) { if (raflag) {
GroupUnity(mi); GroupUnity(mi);
} }
} while(raflag); } while (raflag);
if(Monst->_mmode != MM_STONE) { if (Monst->_mmode != MM_STONE) {
Monst->_mAnimCnt++; Monst->_mAnimCnt++;
if(!(Monst->_mFlags & MFLAG_ALLOW_SPECIAL) && Monst->_mAnimCnt >= Monst->_mAnimDelay) { if (!(Monst->_mFlags & MFLAG_ALLOW_SPECIAL) && Monst->_mAnimCnt >= Monst->_mAnimDelay) {
Monst->_mAnimCnt = 0; Monst->_mAnimCnt = 0;
if(Monst->_mFlags & MFLAG_LOCK_ANIMATION) { if (Monst->_mFlags & MFLAG_LOCK_ANIMATION) {
Monst->_mAnimFrame--; Monst->_mAnimFrame--;
if(Monst->_mAnimFrame == 0) { if (Monst->_mAnimFrame == 0) {
Monst->_mAnimFrame = Monst->_mAnimLen; Monst->_mAnimFrame = Monst->_mAnimLen;
} }
} else { } else {
Monst->_mAnimFrame++; Monst->_mAnimFrame++;
if(Monst->_mAnimFrame > Monst->_mAnimLen) { if (Monst->_mAnimFrame > Monst->_mAnimLen) {
Monst->_mAnimFrame = 1; Monst->_mAnimFrame = 1;
} }
} }
@ -4670,12 +4670,12 @@ BOOL DirOK(int i, int mdir)
return FALSE; return FALSE;
} }
if (mdir == DIR_N) { if (mdir == DIR_N) {
if (SolidLoc(fx + 1, fy) || SolidLoc(fx, fy + 1)) if (SolidLoc(fx + 1, fy) || SolidLoc(fx, fy + 1))
return FALSE; return FALSE;
} }
if (mdir == DIR_S) if (mdir == DIR_S)
if (SolidLoc(fx - 1, fy) || SolidLoc(fx, fy - 1)) if (SolidLoc(fx - 1, fy) || SolidLoc(fx, fy - 1))
return FALSE; return FALSE;
if (monster[i].leaderflag == 1) { if (monster[i].leaderflag == 1) {
if (abs(fx - monster[monster[i].leader]._mfutx) >= 4 if (abs(fx - monster[monster[i].leader]._mfutx) >= 4
|| abs(fy - monster[monster[i].leader]._mfuty) >= 4) { || abs(fy - monster[monster[i].leader]._mfuty) >= 4) {
@ -4691,12 +4691,14 @@ BOOL DirOK(int i, int mdir)
if (y < 0 || y >= MAXDUNY || x < 0 || x >= MAXDUNX) if (y < 0 || y >= MAXDUNY || x < 0 || x >= MAXDUNX)
continue; continue;
mi = dMonster[x][y]; mi = dMonster[x][y];
if (mi < 0) mi = -mi; if (mi < 0)
if (mi != 0) mi--; mi = -mi;
if (mi != 0)
mi--;
if (monster[mi].leaderflag == 1 if (monster[mi].leaderflag == 1
&& monster[mi].leader == i && monster[mi].leader == i
&& monster[mi]._mfutx == x && monster[mi]._mfutx == x
&& monster[mi]._mfuty == y) { && monster[mi]._mfuty == y) {
mcount++; mcount++;
} }
} }
@ -4714,7 +4716,7 @@ BOOL CheckNoSolid(int x, int y)
return nSolidTable[dPiece[x][y]] == 0; return nSolidTable[dPiece[x][y]] == 0;
} }
BOOL LineClearF(BOOL(*Clear)(int, int), int x1, int y1, int x2, int y2) BOOL LineClearF(BOOL (*Clear)(int, int), int x1, int y1, int x2, int y2)
{ {
int xorg, yorg; int xorg, yorg;
int dx, dy; int dx, dy;
@ -4801,7 +4803,7 @@ BOOL LineClear(int x1, int y1, int x2, int y2)
return LineClearF(PosOkMissile, x1, y1, x2, y2); return LineClearF(PosOkMissile, x1, y1, x2, y2);
} }
BOOL LineClearF1(BOOL(*Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2) BOOL LineClearF1(BOOL (*Clear)(int, int, int), int monst, int x1, int y1, int x2, int y2)
{ {
int xorg, yorg; int xorg, yorg;
int dx, dy; int dx, dy;
@ -5027,7 +5029,7 @@ void PrintMonstHistory(int mt)
if (!res) { if (!res) {
strcpy(tempstr, "No magic resistance"); strcpy(tempstr, "No magic resistance");
AddPanelString(tempstr, TRUE); AddPanelString(tempstr, TRUE);
} else{ } else {
if (res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING)) { if (res & (RESIST_MAGIC | RESIST_FIRE | RESIST_LIGHTNING)) {
strcpy(tempstr, "Resists : "); strcpy(tempstr, "Resists : ");
if (res & RESIST_MAGIC) if (res & RESIST_MAGIC)
@ -5231,34 +5233,34 @@ BOOL PosOkMonst3(int i, int x, int y)
ret = TRUE; ret = TRUE;
isdoor = FALSE; isdoor = FALSE;
if(ret && dObject[x][y] != 0) { if (ret && dObject[x][y] != 0) {
oi = dObject[x][y] > 0 ? dObject[x][y] - 1 : -(dObject[x][y] + 1); oi = dObject[x][y] > 0 ? dObject[x][y] - 1 : -(dObject[x][y] + 1);
objtype = object[oi]._otype; objtype = object[oi]._otype;
isdoor = objtype == OBJ_L1LDOOR || objtype == OBJ_L1RDOOR isdoor = objtype == OBJ_L1LDOOR || objtype == OBJ_L1RDOOR
|| objtype == OBJ_L2LDOOR || objtype == OBJ_L2RDOOR || objtype == OBJ_L2LDOOR || objtype == OBJ_L2RDOOR
|| objtype == OBJ_L3LDOOR || objtype == OBJ_L3RDOOR; || objtype == OBJ_L3LDOOR || objtype == OBJ_L3RDOOR;
if(object[oi]._oSolidFlag && !isdoor) { if (object[oi]._oSolidFlag && !isdoor) {
ret = FALSE; ret = FALSE;
} }
} }
if(ret) { if (ret) {
ret = (!SolidLoc(x, y) || isdoor) && dPlayer[x][y] == 0 && dMonster[x][y] == 0; ret = (!SolidLoc(x, y) || isdoor) && dPlayer[x][y] == 0 && dMonster[x][y] == 0;
} }
if(ret && dMissile[x][y] != 0 && i >= 0) { if (ret && dMissile[x][y] != 0 && i >= 0) {
mi = dMissile[x][y]; mi = dMissile[x][y];
if(mi > 0) { if (mi > 0) {
if(missile[mi]._mitype == MIS_FIREWALL) { if (missile[mi]._mitype == MIS_FIREWALL) {
fire = TRUE; fire = TRUE;
} else { } else {
for(j = 0; j < nummissiles; j++) { for (j = 0; j < nummissiles; j++) {
mi = missileactive[j]; mi = missileactive[j];
if(missile[mi]._mitype == MIS_FIREWALL) { if (missile[mi]._mitype == MIS_FIREWALL) {
fire = TRUE; fire = TRUE;
} }
} }
} }
} }
if(fire && (!(monster[i].mMagicRes & IMUNE_FIRE) || monster[i].MType->mtype == MT_DIABLO)) { if (fire && (!(monster[i].mMagicRes & IMUNE_FIRE) || monster[i].MType->mtype == MT_DIABLO)) {
ret = FALSE; ret = FALSE;
} }
} }
@ -5526,4 +5528,3 @@ void decode_enemy(int m, int enemy)
monster[m]._menemyy = monster[enemy]._mfuty; monster[m]._menemyy = monster[enemy]._mfuty;
} }
} }

2
Source/mpqapi.cpp

@ -437,7 +437,7 @@ BOOL OpenMPQ(const char *pszArchive, BOOL hidden, DWORD dwChar)
save_archive_open = FALSE; save_archive_open = FALSE;
sghArchive = CreateFile(pszArchive, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL); sghArchive = CreateFile(pszArchive, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL);
if (sghArchive == INVALID_HANDLE_VALUE) { if (sghArchive == INVALID_HANDLE_VALUE) {
sghArchive = CreateFile(pszArchive, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, dwFlagsAndAttributes | (hidden ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0), NULL); sghArchive = CreateFile(pszArchive, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, dwFlagsAndAttributes | (hidden ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0), NULL);
if (sghArchive == INVALID_HANDLE_VALUE) if (sghArchive == INVALID_HANDLE_VALUE)
return FALSE; return FALSE;
save_archive_open = TRUE; save_archive_open = TRUE;

48
Source/multi.cpp

@ -14,7 +14,7 @@ BOOLEAN sgbPlayerTurnBitTbl[MAX_PLRS];
BOOLEAN sgbPlayerLeftGameTbl[MAX_PLRS]; BOOLEAN sgbPlayerLeftGameTbl[MAX_PLRS];
int sgbSentThisCycle; // idb int sgbSentThisCycle; // idb
BOOL gbShouldValidatePackage; BOOL gbShouldValidatePackage;
BYTE gbActivePlayers; // weak BYTE gbActivePlayers; // weak
BOOLEAN gbGameDestroyed; BOOLEAN gbGameDestroyed;
BOOLEAN sgbSendDeltaTbl[MAX_PLRS]; BOOLEAN sgbSendDeltaTbl[MAX_PLRS];
_gamedata sgGameInitInfo; _gamedata sgGameInitInfo;
@ -360,21 +360,21 @@ void multi_begin_timeout()
int i, nTicks, nState, nLowestActive, nLowestPlayer; int i, nTicks, nState, nLowestActive, nLowestPlayer;
BYTE bGroupPlayers, bGroupCount; BYTE bGroupPlayers, bGroupCount;
if(!sgbTimeout) { if (!sgbTimeout) {
return; return;
} }
#ifdef _DEBUG #ifdef _DEBUG
if(debug_mode_key_i) { if (debug_mode_key_i) {
return; return;
} }
#endif #endif
nTicks = GetTickCount() - sglTimeoutStart; nTicks = GetTickCount() - sglTimeoutStart;
if(nTicks > 20000) { if (nTicks > 20000) {
gbRunGame = FALSE; gbRunGame = FALSE;
return; return;
} }
if(nTicks < 10000) { if (nTicks < 10000) {
return; return;
} }
@ -382,15 +382,15 @@ void multi_begin_timeout()
nLowestPlayer = -1; nLowestPlayer = -1;
bGroupPlayers = 0; bGroupPlayers = 0;
bGroupCount = 0; bGroupCount = 0;
for(i = 0; i < MAX_PLRS; i++) { for (i = 0; i < MAX_PLRS; i++) {
nState = player_state[i]; nState = player_state[i];
if(nState & 0x10000) { if (nState & 0x10000) {
if(nLowestPlayer == -1) { if (nLowestPlayer == -1) {
nLowestPlayer = i; nLowestPlayer = i;
} }
if(nState & 0x40000) { if (nState & 0x40000) {
bGroupPlayers++; bGroupPlayers++;
if(nLowestActive == -1) { if (nLowestActive == -1) {
nLowestActive = i; nLowestActive = i;
} }
} else { } else {
@ -405,23 +405,23 @@ void multi_begin_timeout()
#ifdef _DEBUG #ifdef _DEBUG
dumphist( dumphist(
"(%d) grp:%d ngrp:%d lowp:%d lowa:%d", "(%d) grp:%d ngrp:%d lowp:%d lowa:%d",
myplr, myplr,
bGroupPlayers, bGroupPlayers,
bGroupCount, bGroupCount,
nLowestPlayer, nLowestPlayer,
nLowestActive); nLowestActive);
#endif #endif
if(bGroupPlayers < bGroupCount) { if (bGroupPlayers < bGroupCount) {
gbGameDestroyed = TRUE; gbGameDestroyed = TRUE;
} else if(bGroupPlayers == bGroupCount) { } else if (bGroupPlayers == bGroupCount) {
if(nLowestPlayer != nLowestActive) { if (nLowestPlayer != nLowestActive) {
gbGameDestroyed = TRUE; gbGameDestroyed = TRUE;
} else if(nLowestActive == myplr) { } else if (nLowestActive == myplr) {
multi_check_drop_player(); multi_check_drop_player();
} }
} else if(nLowestActive == myplr) { } else if (nLowestActive == myplr) {
multi_check_drop_player(); multi_check_drop_player();
} }
} }
@ -505,7 +505,7 @@ void multi_process_network_packets()
} }
} }
} }
multi_handle_all_packets(dwID, (BYTE *)(pkt + 1), dwMsgSize - sizeof (TPktHdr)); multi_handle_all_packets(dwID, (BYTE *)(pkt + 1), dwMsgSize - sizeof(TPktHdr));
} }
if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING) if (SErrGetLastError() != STORM_ERROR_NO_MESSAGES_WAITING)
nthread_terminate_game("SNetReceiveMsg"); nthread_terminate_game("SNetReceiveMsg");
@ -517,9 +517,9 @@ void multi_handle_all_packets(int pnum, BYTE *pData, int nSize)
{ {
int nLen; int nLen;
while(nSize != 0) { while (nSize != 0) {
nLen = ParseCmd(pnum, (TCmd *)pData); nLen = ParseCmd(pnum, (TCmd *)pData);
if(nLen == 0) { if (nLen == 0) {
break; break;
} }
pData += nLen; pData += nLen;

7
Source/objects.cpp

@ -1515,11 +1515,10 @@ void Obj_Circle(int i)
object[i]._oVar6 = 2; object[i]._oVar6 = 2;
return; return;
} }
} } else {
else {
if (object[i]._ox == 26 && object[i]._oy == 46) { if (object[i]._ox == 26 && object[i]._oy == 46) {
object[i]._oVar6 = 1; object[i]._oVar6 = 1;
return; return;
} }
} }
object[i]._oVar6 = 0; object[i]._oVar6 = 0;

4
Source/path.cpp

@ -38,7 +38,7 @@ char path_directions[9] = { 5, 1, 6, 2, 0, 3, 8, 4, 7 };
* check that each step is a valid position. Store the step directions (see * check that each step is a valid position. Store the step directions (see
* path_directions) in path, which must have room for 24 steps * path_directions) in path, which must have room for 24 steps
*/ */
int FindPath(BOOL(*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path) int FindPath(BOOL (*PosOk)(int, int, int), int PosOkArg, int sx, int sy, int dx, int dy, char *path)
{ {
PATHNODE *path_start, *next_node, *current; PATHNODE *path_start, *next_node, *current;
int path_length, i; int path_length, i;
@ -161,7 +161,7 @@ BOOL path_solid_pieces(PATHNODE *pPath, int dx, int dy)
* *
* return 0 if we ran out of preallocated nodes to use, else 1 * return 0 if we ran out of preallocated nodes to use, else 1
*/ */
BOOL path_get_path(BOOL(*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y) BOOL path_get_path(BOOL (*PosOk)(int, int, int), int PosOkArg, PATHNODE *pPath, int x, int y)
{ {
int dx, dy; int dx, dy;
int i; int i;

30
Source/themes.cpp

@ -600,7 +600,7 @@ void Theme_SkelRoom(int t)
AddObject(OBJ_SKFIRE, xp, yp); AddObject(OBJ_SKFIRE, xp, yp);
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp - 1); SpawnSkeleton(i, xp - 1, yp - 1);
} else { } else {
@ -610,25 +610,25 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp - 1); SpawnSkeleton(i, xp, yp - 1);
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp - 1); SpawnSkeleton(i, xp + 1, yp - 1);
} else { } else {
AddObject(OBJ_BANNERR, xp + 1, yp - 1); AddObject(OBJ_BANNERR, xp + 1, yp - 1);
} }
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp); SpawnSkeleton(i, xp - 1, yp);
} else { } else {
AddObject(OBJ_BANNERM, xp - 1, yp); AddObject(OBJ_BANNERM, xp - 1, yp);
} }
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp); SpawnSkeleton(i, xp + 1, yp);
} else { } else {
AddObject(OBJ_BANNERM, xp + 1, yp); AddObject(OBJ_BANNERM, xp + 1, yp);
} }
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp + 1); SpawnSkeleton(i, xp - 1, yp + 1);
} else { } else {
@ -638,17 +638,17 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp + 1); SpawnSkeleton(i, xp, yp + 1);
if(random(0, monstrnd[leveltype - 1]) != 0) { if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton(); i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp + 1); SpawnSkeleton(i, xp + 1, yp + 1);
} else { } else {
AddObject(OBJ_BANNERL, xp + 1, yp + 1); AddObject(OBJ_BANNERL, xp + 1, yp + 1);
} }
if(dObject[xp][yp - 3] == 0) { if (dObject[xp][yp - 3] == 0) {
AddObject(OBJ_SKELBOOK, xp, yp - 2); AddObject(OBJ_SKELBOOK, xp, yp - 2);
} }
if(dObject[xp][yp + 3] == 0) { if (dObject[xp][yp + 3] == 0) {
AddObject(OBJ_SKELBOOK, xp, yp + 2); AddObject(OBJ_SKELBOOK, xp, yp + 2);
} }
} }
@ -702,7 +702,7 @@ void Theme_Library(int t)
TFit_Shrine(t); TFit_Shrine(t);
if(themeVar1 == 1) { if (themeVar1 == 1) {
AddObject(OBJ_BOOKCANDLE, themex - 1, themey); AddObject(OBJ_BOOKCANDLE, themex - 1, themey);
AddObject(OBJ_BOOKCASER, themex, themey); AddObject(OBJ_BOOKCASER, themex, themey);
AddObject(OBJ_BOOKCANDLE, themex + 1, themey); AddObject(OBJ_BOOKCANDLE, themex + 1, themey);
@ -712,11 +712,11 @@ void Theme_Library(int t)
AddObject(OBJ_BOOKCANDLE, themex, themey + 1); AddObject(OBJ_BOOKCANDLE, themex, themey + 1);
} }
for(yp = 1; yp < MAXDUNY - 1; yp++) { for (yp = 1; yp < MAXDUNY - 1; yp++) {
for(xp = 1; xp < MAXDUNX - 1; xp++) { for (xp = 1; xp < MAXDUNX - 1; xp++) {
if(CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random(0, librnd[leveltype - 1]) == 0) { if (CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random(0, librnd[leveltype - 1]) == 0) {
AddObject(OBJ_BOOKSTAND, xp, yp); AddObject(OBJ_BOOKSTAND, xp, yp);
if(random(0, 2 * librnd[leveltype - 1]) != 0) { if (random(0, 2 * librnd[leveltype - 1]) != 0) {
oi = dObject[xp][yp] - 1; oi = dObject[xp][yp] - 1;
object[oi]._oSelFlag = 0; object[oi]._oSelFlag = 0;
object[oi]._oAnimFrame += 2; object[oi]._oAnimFrame += 2;
@ -725,9 +725,9 @@ void Theme_Library(int t)
} }
} }
if(!QuestStatus(QTYPE_ZHAR)) { if (!QuestStatus(QTYPE_ZHAR)) {
PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1` PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1`
} else if(t != zharlib) { } else if (t != zharlib) {
PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1` PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1`
} }
} }

6
Source/town.cpp

@ -449,7 +449,7 @@ void town_draw_clipped_town(BYTE *pBuff, int x, int y, int sx, int sy, BOOL some
if (dFlags[x][y] & BFLAG_MISSILE) { if (dFlags[x][y] & BFLAG_MISSILE) {
DrawClippedMissile(x, y, sx, sy, 0, 8, 0); DrawClippedMissile(x, y, sx, sy, 0, 8, 0);
} }
if(dArch[x][y] != 0) { if (dArch[x][y] != 0) {
town_special_lower(pBuff, dArch[x][y]); town_special_lower(pBuff, dArch[x][y]);
} }
} }
@ -631,7 +631,7 @@ void town_draw_clipped_town_2(BYTE *pBuff, int x, int y, int a4, int a5, int sx,
if (dFlags[x][y] & BFLAG_MISSILE) { if (dFlags[x][y] & BFLAG_MISSILE) {
DrawClippedMissile(x, y, sx, sy, a5, 8, 0); DrawClippedMissile(x, y, sx, sy, a5, 8, 0);
} }
if(dArch[x][y] != 0) { if (dArch[x][y] != 0) {
town_special_lower(&pBuff[PitchTbl[16 * a5]], dArch[x][y]); town_special_lower(&pBuff[PitchTbl[16 * a5]], dArch[x][y]);
} }
} }
@ -825,7 +825,7 @@ void town_draw_town_all(BYTE *pBuff, int x, int y, int a4, int dir, int sx, int
if (dFlags[x][y] & BFLAG_MISSILE) { if (dFlags[x][y] & BFLAG_MISSILE) {
DrawMissile(x, y, sx, sy, 0, dir, 0); DrawMissile(x, y, sx, sy, 0, dir, 0);
} }
if(dArch[x][y] != 0) { if (dArch[x][y] != 0) {
town_special_upper(pBuff, dArch[x][y]); town_special_upper(pBuff, dArch[x][y]);
} }
} }

158
Source/towners.cpp

@ -124,7 +124,7 @@ void SetTownerGPtrs(BYTE *pData, BYTE **pAnim)
#ifdef USE_ASM #ifdef USE_ASM
BYTE *src; BYTE *src;
for(i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
src = pData; src = pData;
__asm { __asm {
mov eax, src mov eax, src
@ -143,7 +143,7 @@ void SetTownerGPtrs(BYTE *pData, BYTE **pAnim)
pFrameTable = (DWORD *)pData; pFrameTable = (DWORD *)pData;
for(i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
pAnim[i] = &pData[pFrameTable[i]]; pAnim[i] = &pData[pFrameTable[i]];
} }
#endif #endif
@ -182,8 +182,8 @@ void InitQstSnds(int i)
tl++; tl++;
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
towner[i].qsts[j]._qsttype = quests[j]._qtype; towner[i].qsts[j]._qsttype = quests[j]._qtype;
towner[i].qsts[j]._qstmsg = ((int*)(Qtalklist + tl))[j]; towner[i].qsts[j]._qstmsg = ((int *)(Qtalklist + tl))[j];
if (((int*)(Qtalklist + tl))[j] != -1) if (((int *)(Qtalklist + tl))[j] != -1)
towner[i].qsts[j]._qstmsgact = TRUE; towner[i].qsts[j]._qstmsgact = TRUE;
else else
towner[i].qsts[j]._qstmsgact = FALSE; towner[i].qsts[j]._qstmsgact = FALSE;
@ -607,37 +607,37 @@ void TalkToTowner(int p, int t)
dx = abs(plr[p].WorldX - towner[t]._tx); dx = abs(plr[p].WorldX - towner[t]._tx);
dy = abs(plr[p].WorldY - towner[t]._ty); dy = abs(plr[p].WorldY - towner[t]._ty);
#ifdef _DEBUG #ifdef _DEBUG
if(!debug_mode_key_d && (dx >= 2 || dy >= 2)) { if (!debug_mode_key_d && (dx >= 2 || dy >= 2)) {
return; return;
} }
#else #else
if(dx >= 2 || dy >= 2) { if (dx >= 2 || dy >= 2) {
return; return;
} }
#endif #endif
if(qtextflag) { if (qtextflag) {
return; return;
} }
towner[t]._tMsgSaid = FALSE; towner[t]._tMsgSaid = FALSE;
if(pcurs >= CURSOR_FIRSTITEM && !DropItemBeforeTrig()) { if (pcurs >= CURSOR_FIRSTITEM && !DropItemBeforeTrig()) {
return; return;
} }
if(t == GetActiveTowner(TOWN_TAVERN)) { if (t == GetActiveTowner(TOWN_TAVERN)) {
if(!plr[p]._pLvlVisited[0] && !towner[t]._tMsgSaid) { if (!plr[p]._pLvlVisited[0] && !towner[t]._tMsgSaid) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
InitQTextMsg(QUEST_INTRO); InitQTextMsg(QUEST_INTRO);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
if((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive != 0) { if ((plr[p]._pLvlVisited[2] || plr[p]._pLvlVisited[4]) && quests[QTYPE_KING]._qactive != 0) {
if(quests[QTYPE_KING]._qvar2 == 0 && !towner[t]._tMsgSaid) { if (quests[QTYPE_KING]._qvar2 == 0 && !towner[t]._tMsgSaid) {
quests[QTYPE_KING]._qvar2 = 1; quests[QTYPE_KING]._qvar2 = 1;
quests[QTYPE_KING]._qlog = TRUE; quests[QTYPE_KING]._qlog = TRUE;
if(quests[QTYPE_KING]._qactive == 1) { if (quests[QTYPE_KING]._qactive == 1) {
quests[QTYPE_KING]._qactive = 2; quests[QTYPE_KING]._qactive = 2;
quests[QTYPE_KING]._qvar1 = 1; quests[QTYPE_KING]._qvar1 = 1;
} }
@ -647,7 +647,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
NetSendCmdQuest(TRUE, QTYPE_KING); NetSendCmdQuest(TRUE, QTYPE_KING);
} }
if(quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[t]._tMsgSaid) { if (quests[QTYPE_KING]._qactive == 3 && quests[QTYPE_KING]._qvar2 == 1 && !towner[t]._tMsgSaid) {
quests[QTYPE_KING]._qvar2 = 2; quests[QTYPE_KING]._qvar2 = 2;
quests[QTYPE_KING]._qvar1 = 2; quests[QTYPE_KING]._qvar1 = 2;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
@ -657,10 +657,10 @@ void TalkToTowner(int p, int t)
NetSendCmdQuest(TRUE, QTYPE_KING); NetSendCmdQuest(TRUE, QTYPE_KING);
} }
} }
if(gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive != 0) { if (gbMaxPlayers == 1 && plr[p]._pLvlVisited[3] && quests[QTYPE_BOL]._qactive != 0) {
if((quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && quests[QTYPE_BOL]._qvar2 == 0 && !towner[t]._tMsgSaid) { if ((quests[QTYPE_BOL]._qactive == 1 || quests[QTYPE_BOL]._qactive == 2) && quests[QTYPE_BOL]._qvar2 == 0 && !towner[t]._tMsgSaid) {
quests[QTYPE_BOL]._qvar2 = 1; quests[QTYPE_BOL]._qvar2 = 1;
if(quests[QTYPE_BOL]._qactive == 1) { if (quests[QTYPE_BOL]._qactive == 1) {
quests[QTYPE_BOL]._qvar1 = 1; quests[QTYPE_BOL]._qvar1 = 1;
quests[QTYPE_BOL]._qactive = 2; quests[QTYPE_BOL]._qactive = 2;
} }
@ -670,7 +670,7 @@ void TalkToTowner(int p, int t)
InitQTextMsg(QUEST_BANNER2); InitQTextMsg(QUEST_BANNER2);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
if(quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, &i) != NULL && !towner[t]._tMsgSaid) { if (quests[QTYPE_BOL]._qvar2 == 1 && PlrHasItem(p, IDI_BANNER, &i) != NULL && !towner[t]._tMsgSaid) {
quests[QTYPE_BOL]._qactive = 3; quests[QTYPE_BOL]._qactive = 3;
quests[QTYPE_BOL]._qvar1 = 3; quests[QTYPE_BOL]._qvar1 = 3;
RemoveInvItem(p, i); RemoveInvItem(p, i);
@ -681,31 +681,31 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
} }
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_OGDEN1, t); TownerTalk(QUEST_OGDEN1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_TAVERN); StartStore(STORE_TAVERN);
} }
} }
} else if(t == GetActiveTowner(TOWN_DEADGUY)) { } else if (t == GetActiveTowner(TOWN_DEADGUY)) {
if(quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 1) { if (quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 1) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
quests[QTYPE_BUTCH]._qvar1 = 1; quests[QTYPE_BUTCH]._qvar1 = 1;
if(plr[p]._pClass == 0 && !effect_is_playing(PS_WARR8)) { if (plr[p]._pClass == 0 && !effect_is_playing(PS_WARR8)) {
PlaySFX(PS_WARR8); PlaySFX(PS_WARR8);
} else if(plr[p]._pClass == 1 && !effect_is_playing(PS_ROGUE8)) { } else if (plr[p]._pClass == 1 && !effect_is_playing(PS_ROGUE8)) {
PlaySFX(PS_ROGUE8); PlaySFX(PS_ROGUE8);
} else if(plr[p]._pClass == 2 && !effect_is_playing(PS_MAGE8)) { } else if (plr[p]._pClass == 2 && !effect_is_playing(PS_MAGE8)) {
PlaySFX(PS_MAGE8); PlaySFX(PS_MAGE8);
} }
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_BUTCH]._qactive == 3 && quests[QTYPE_BUTCH]._qvar1 == 1) { } else if (quests[QTYPE_BUTCH]._qactive == 3 && quests[QTYPE_BUTCH]._qvar1 == 1) {
quests[QTYPE_BUTCH]._qvar1 = 1; quests[QTYPE_BUTCH]._qvar1 = 1;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_BUTCH]._qactive == 1 || quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 0) { } else if (quests[QTYPE_BUTCH]._qactive == 1 || quests[QTYPE_BUTCH]._qactive == 2 && quests[QTYPE_BUTCH]._qvar1 == 0) {
quests[QTYPE_BUTCH]._qactive = 2; quests[QTYPE_BUTCH]._qactive = 2;
quests[QTYPE_BUTCH]._qlog = TRUE; quests[QTYPE_BUTCH]._qlog = TRUE;
quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9; quests[QTYPE_BUTCH]._qmsg = QUEST_BUTCH9;
@ -717,13 +717,13 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
NetSendCmdQuest(TRUE, QTYPE_BUTCH); NetSendCmdQuest(TRUE, QTYPE_BUTCH);
} }
} else if(t == GetActiveTowner(TOWN_SMITH)) { } else if (t == GetActiveTowner(TOWN_SMITH)) {
if(gbMaxPlayers == 1) { if (gbMaxPlayers == 1) {
if(plr[p]._pLvlVisited[4] && quests[QTYPE_INFRA]._qactive != 0) { if (plr[p]._pLvlVisited[4] && quests[QTYPE_INFRA]._qactive != 0) {
if(quests[QTYPE_INFRA]._qvar2 == 0) { if (quests[QTYPE_INFRA]._qvar2 == 0) {
quests[QTYPE_INFRA]._qvar2 = 1; quests[QTYPE_INFRA]._qvar2 = 1;
quests[QTYPE_INFRA]._qlog = TRUE; quests[QTYPE_INFRA]._qlog = TRUE;
if(quests[QTYPE_INFRA]._qactive == 1) { if (quests[QTYPE_INFRA]._qactive == 1) {
quests[QTYPE_INFRA]._qactive = 2; quests[QTYPE_INFRA]._qactive = 2;
quests[QTYPE_INFRA]._qvar1 = 1; quests[QTYPE_INFRA]._qvar1 = 1;
} }
@ -732,7 +732,7 @@ void TalkToTowner(int p, int t)
InitQTextMsg(QUEST_INFRA5); InitQTextMsg(QUEST_INFRA5);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
if(quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, &i) != NULL && !towner[t]._tMsgSaid) { if (quests[QTYPE_INFRA]._qvar2 == 1 && PlrHasItem(p, IDI_ROCK, &i) != NULL && !towner[t]._tMsgSaid) {
quests[QTYPE_INFRA]._qactive = 3; quests[QTYPE_INFRA]._qactive = 3;
quests[QTYPE_INFRA]._qvar2 = 2; quests[QTYPE_INFRA]._qvar2 = 2;
quests[QTYPE_INFRA]._qvar1 = 2; quests[QTYPE_INFRA]._qvar1 = 2;
@ -744,15 +744,15 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
} }
if(plr[p]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive != 0) { if (plr[p]._pLvlVisited[9] && quests[QTYPE_ANVIL]._qactive != 0) {
if((quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && quests[QTYPE_ANVIL]._qvar2 == 0) { if ((quests[QTYPE_ANVIL]._qactive == 1 || quests[QTYPE_ANVIL]._qactive == 2) && quests[QTYPE_ANVIL]._qvar2 == 0) {
if(towner[t]._tMsgSaid) { if (towner[t]._tMsgSaid) {
goto SKIPANVIL; /* TODO: fix */ goto SKIPANVIL; /* TODO: fix */
} }
if(quests[QTYPE_INFRA]._qvar2 == 2 || quests[QTYPE_INFRA]._qactive == 2 && quests[QTYPE_INFRA]._qvar2 == 1) { if (quests[QTYPE_INFRA]._qvar2 == 2 || quests[QTYPE_INFRA]._qactive == 2 && quests[QTYPE_INFRA]._qvar2 == 1) {
quests[QTYPE_ANVIL]._qvar2 = 1; quests[QTYPE_ANVIL]._qvar2 = 1;
quests[QTYPE_ANVIL]._qlog = TRUE; quests[QTYPE_ANVIL]._qlog = TRUE;
if(quests[QTYPE_ANVIL]._qactive == 1) { if (quests[QTYPE_ANVIL]._qactive == 1) {
quests[QTYPE_ANVIL]._qactive = 2; quests[QTYPE_ANVIL]._qactive = 2;
quests[QTYPE_ANVIL]._qvar1 = 1; quests[QTYPE_ANVIL]._qvar1 = 1;
} }
@ -762,7 +762,7 @@ void TalkToTowner(int p, int t)
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
} }
if(quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, &i) != NULL && !towner[t]._tMsgSaid) { if (quests[QTYPE_ANVIL]._qvar2 == 1 && PlrHasItem(p, IDI_ANVIL, &i) != NULL && !towner[t]._tMsgSaid) {
quests[QTYPE_ANVIL]._qactive = 3; quests[QTYPE_ANVIL]._qactive = 3;
quests[QTYPE_ANVIL]._qvar2 = 2; quests[QTYPE_ANVIL]._qvar2 = 2;
quests[QTYPE_ANVIL]._qvar1 = 2; quests[QTYPE_ANVIL]._qvar1 = 2;
@ -775,15 +775,15 @@ void TalkToTowner(int p, int t)
} }
} }
} }
SKIPANVIL: SKIPANVIL:
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_GRISWOLD1, t); TownerTalk(QUEST_GRISWOLD1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_SMITH); StartStore(STORE_SMITH);
} }
} }
} else if(t == GetActiveTowner(TOWN_WITCH)) { } else if (t == GetActiveTowner(TOWN_WITCH)) {
if(quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, &i) != NULL) { if (quests[QTYPE_BLKM]._qactive == 1 && PlrHasItem(p, IDI_FUNGALTM, &i) != NULL) {
RemoveInvItem(p, i); RemoveInvItem(p, i);
quests[QTYPE_BLKM]._qactive = 2; quests[QTYPE_BLKM]._qactive = 2;
quests[QTYPE_BLKM]._qlog = TRUE; quests[QTYPE_BLKM]._qlog = TRUE;
@ -792,9 +792,9 @@ SKIPANVIL:
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
InitQTextMsg(QUEST_MUSH8); InitQTextMsg(QUEST_MUSH8);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_BLKM]._qactive == 2) { } else if (quests[QTYPE_BLKM]._qactive == 2) {
if(quests[QTYPE_BLKM]._qvar1 >= 2 && quests[QTYPE_BLKM]._qvar1 <= 4) { if (quests[QTYPE_BLKM]._qvar1 >= 2 && quests[QTYPE_BLKM]._qvar1 <= 4) {
if(PlrHasItem(p, IDI_MUSHROOM, &i) != NULL) { if (PlrHasItem(p, IDI_MUSHROOM, &i) != NULL) {
RemoveInvItem(p, i); RemoveInvItem(p, i);
quests[QTYPE_BLKM]._qvar1 = 5; quests[QTYPE_BLKM]._qvar1 = 5;
Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3; Qtalklist[TOWN_HEALER]._qblkm = QUEST_MUSH3;
@ -804,7 +804,7 @@ SKIPANVIL:
quests[QTYPE_BLKM]._qmsg = QUEST_MUSH10; quests[QTYPE_BLKM]._qmsg = QUEST_MUSH10;
InitQTextMsg(QUEST_MUSH10); InitQTextMsg(QUEST_MUSH10);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_BLKM]._qmsg != QUEST_MUSH9) { } else if (quests[QTYPE_BLKM]._qmsg != QUEST_MUSH9) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
quests[QTYPE_BLKM]._qmsg = QUEST_MUSH9; quests[QTYPE_BLKM]._qmsg = QUEST_MUSH9;
@ -813,14 +813,14 @@ SKIPANVIL:
} }
} else { } else {
Item = PlrHasItem(p, IDI_SPECELIX, &i); Item = PlrHasItem(p, IDI_SPECELIX, &i);
if(Item != NULL) { if (Item != NULL) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
InitQTextMsg(QUEST_MUSH12); InitQTextMsg(QUEST_MUSH12);
quests[QTYPE_BLKM]._qactive = 3; quests[QTYPE_BLKM]._qactive = 3;
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
AllItemsList[Item->IDidx].iUsable = TRUE; AllItemsList[Item->IDidx].iUsable = TRUE;
} else if(PlrHasItem(p, IDI_BRAIN, &i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) { } else if (PlrHasItem(p, IDI_BRAIN, &i) != NULL && quests[QTYPE_BLKM]._qvar2 != QUEST_MUSH11) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11; quests[QTYPE_BLKM]._qvar2 = QUEST_MUSH11;
@ -829,30 +829,30 @@ SKIPANVIL:
} }
} }
} }
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_ADRIA1, t); TownerTalk(QUEST_ADRIA1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_WITCH); StartStore(STORE_WITCH);
} }
} }
} else if(t == GetActiveTowner(TOWN_BMAID)) { } else if (t == GetActiveTowner(TOWN_BMAID)) {
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_GILLIAN1, t); TownerTalk(QUEST_GILLIAN1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_BARMAID); StartStore(STORE_BARMAID);
} }
} }
} else if(t == GetActiveTowner(TOWN_DRUNK)) { } else if (t == GetActiveTowner(TOWN_DRUNK)) {
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_FARNHAM1, t); TownerTalk(QUEST_FARNHAM1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_DRUNK); StartStore(STORE_DRUNK);
} }
} }
} else if(t == GetActiveTowner(TOWN_HEALER)) { } else if (t == GetActiveTowner(TOWN_HEALER)) {
if(gbMaxPlayers == 1) { if (gbMaxPlayers == 1) {
if(plr[p]._pLvlVisited[1] && !towner[t]._tMsgSaid) { if (plr[p]._pLvlVisited[1] && !towner[t]._tMsgSaid) {
if(quests[QTYPE_PW]._qactive == 1) { if (quests[QTYPE_PW]._qactive == 1) {
quests[QTYPE_PW]._qactive = 2; quests[QTYPE_PW]._qactive = 2;
quests[QTYPE_PW]._qlog = TRUE; quests[QTYPE_PW]._qlog = TRUE;
quests[QTYPE_PW]._qmsg = QUEST_POISON3; quests[QTYPE_PW]._qmsg = QUEST_POISON3;
@ -861,7 +861,7 @@ SKIPANVIL:
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
InitQTextMsg(QUEST_POISON3); InitQTextMsg(QUEST_POISON3);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2) { } else if (quests[QTYPE_PW]._qactive == 3 && quests[QTYPE_PW]._qvar1 != 2) {
quests[QTYPE_PW]._qvar1 = 2; quests[QTYPE_PW]._qvar1 = 2;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
@ -870,7 +870,7 @@ SKIPANVIL:
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
} }
if(quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, &i) != NULL) { if (quests[QTYPE_BLKM]._qactive == 2 && quests[QTYPE_BLKM]._qmsg == QUEST_MUSH10 && PlrHasItem(p, IDI_BRAIN, &i) != NULL) {
RemoveInvItem(p, i); RemoveInvItem(p, i);
SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0); SpawnQuestItem(IDI_SPECELIX, towner[t]._tx, towner[t]._ty + 1, 0, 0);
InitQTextMsg(QUEST_MUSH4); InitQTextMsg(QUEST_MUSH4);
@ -878,22 +878,22 @@ SKIPANVIL:
Qtalklist[TOWN_HEALER]._qblkm = -1; Qtalklist[TOWN_HEALER]._qblkm = -1;
} }
} }
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_PEPIN1, t); TownerTalk(QUEST_PEPIN1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_HEALER); StartStore(STORE_HEALER);
} }
} }
} else if(t == GetActiveTowner(TOWN_PEGBOY)) { } else if (t == GetActiveTowner(TOWN_PEGBOY)) {
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_WIRT1, t); TownerTalk(QUEST_WIRT1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_BOY); StartStore(STORE_BOY);
} }
} }
} else if(t == GetActiveTowner(TOWN_STORY)) { } else if (t == GetActiveTowner(TOWN_STORY)) {
if(gbMaxPlayers == 1) { if (gbMaxPlayers == 1) {
if(quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, &i) != NULL) { if (quests[QTYPE_VB]._qactive == 1 && PlrHasItem(p, IDI_LAZSTAFF, &i) != NULL) {
RemoveInvItem(p, i); RemoveInvItem(p, i);
quests[QTYPE_VB]._qvar1 = 2; quests[QTYPE_VB]._qvar1 = 2;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
@ -902,7 +902,7 @@ SKIPANVIL:
quests[QTYPE_VB]._qactive = 2; quests[QTYPE_VB]._qactive = 2;
quests[QTYPE_VB]._qlog = TRUE; quests[QTYPE_VB]._qlog = TRUE;
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} else if(quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) {
quests[QTYPE_VB]._qvar1 = 8; quests[QTYPE_VB]._qvar1 = 8;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
@ -911,15 +911,15 @@ SKIPANVIL:
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
} }
} }
if(gbMaxPlayers != 1) { if (gbMaxPlayers != 1) {
if(quests[QTYPE_VB]._qactive == 2 && !quests[QTYPE_VB]._qlog) { if (quests[QTYPE_VB]._qactive == 2 && !quests[QTYPE_VB]._qlog) {
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
InitQTextMsg(QUEST_VILE1); InitQTextMsg(QUEST_VILE1);
towner[t]._tMsgSaid = TRUE; towner[t]._tMsgSaid = TRUE;
quests[QTYPE_VB]._qlog = TRUE; quests[QTYPE_VB]._qlog = TRUE;
NetSendCmdQuest(TRUE, QTYPE_VB); NetSendCmdQuest(TRUE, QTYPE_VB);
} else if(quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) { } else if (quests[QTYPE_VB]._qactive == 3 && quests[QTYPE_VB]._qvar1 == 7) {
quests[QTYPE_VB]._qvar1 = 8; quests[QTYPE_VB]._qvar1 = 8;
towner[t]._tbtcnt = 150; towner[t]._tbtcnt = 150;
towner[t]._tVar1 = p; towner[t]._tVar1 = p;
@ -930,13 +930,13 @@ SKIPANVIL:
NetSendCmdQuest(TRUE, QTYPE_MOD); NetSendCmdQuest(TRUE, QTYPE_MOD);
} }
} }
if(!qtextflag) { if (!qtextflag) {
TownerTalk(QUEST_STORY1, t); TownerTalk(QUEST_STORY1, t);
if(storeflag) { if (storeflag) {
StartStore(STORE_STORY); StartStore(STORE_STORY);
} }
} }
} else if(towner[t]._ttype == TOWN_COW && !qtextflag) { } else if (towner[t]._ttype == TOWN_COW && !qtextflag) {
CowSFX(p); CowSFX(p);
} }
} }

28
Source/trigs.cpp

@ -101,8 +101,8 @@ void InitTownTriggers()
numtrigs = 1; numtrigs = 1;
if(gbMaxPlayers == MAX_PLRS) { if (gbMaxPlayers == MAX_PLRS) {
for(i = 0; i < sizeof(townwarps) / sizeof(townwarps[0]); i++) { for (i = 0; i < sizeof(townwarps) / sizeof(townwarps[0]); i++) {
townwarps[i] = TRUE; townwarps[i] = TRUE;
} }
trigs[1]._tx = 49; trigs[1]._tx = 49;
@ -119,10 +119,10 @@ void InitTownTriggers()
trigs[3]._tlvl = 13; trigs[3]._tlvl = 13;
numtrigs = 4; numtrigs = 4;
} else { } else {
for(i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
townwarps[i] = FALSE; townwarps[i] = FALSE;
} }
if(plr[myplr].pTownWarps & 1) { if (plr[myplr].pTownWarps & 1) {
trigs[1]._tx = 49; trigs[1]._tx = 49;
trigs[1]._ty = 21; trigs[1]._ty = 21;
trigs[1]._tmsg = WM_DIABTOWNWARP; trigs[1]._tmsg = WM_DIABTOWNWARP;
@ -130,7 +130,7 @@ void InitTownTriggers()
numtrigs = 2; numtrigs = 2;
townwarps[0] = TRUE; townwarps[0] = TRUE;
} }
if(plr[myplr].pTownWarps & 2) { if (plr[myplr].pTownWarps & 2) {
townwarps[1] = TRUE; townwarps[1] = TRUE;
trigs[numtrigs]._tx = 17; trigs[numtrigs]._tx = 17;
trigs[numtrigs]._ty = 69; trigs[numtrigs]._ty = 69;
@ -138,7 +138,7 @@ void InitTownTriggers()
trigs[numtrigs]._tlvl = 9; trigs[numtrigs]._tlvl = 9;
numtrigs++; numtrigs++;
} }
if(plr[myplr].pTownWarps & 4) { if (plr[myplr].pTownWarps & 4) {
townwarps[2] = TRUE; townwarps[2] = TRUE;
trigs[numtrigs]._tx = 41; trigs[numtrigs]._tx = 41;
trigs[numtrigs]._ty = 80; trigs[numtrigs]._ty = 80;
@ -204,7 +204,6 @@ void InitL2Triggers()
trigs[numtrigs]._tmsg = WM_DIABNEXTLVL; trigs[numtrigs]._tmsg = WM_DIABNEXTLVL;
numtrigs++; numtrigs++;
} }
} }
} }
trigflag = 0; trigflag = 0;
@ -227,7 +226,7 @@ void InitL3Triggers()
if (dPiece[i][j] == 168) { if (dPiece[i][j] == 168) {
trigs[numtrigs]._tx = i; trigs[numtrigs]._tx = i;
trigs[numtrigs]._ty = j; trigs[numtrigs]._ty = j;
trigs[numtrigs] ._tmsg = WM_DIABNEXTLVL; trigs[numtrigs]._tmsg = WM_DIABNEXTLVL;
numtrigs++; numtrigs++;
} }
@ -238,7 +237,6 @@ void InitL3Triggers()
numtrigs++; numtrigs++;
} }
} }
} }
trigflag = 0; trigflag = 0;
} }
@ -654,12 +652,12 @@ void CheckTrigForce()
{ {
trigflag = FALSE; trigflag = FALSE;
if(MouseY > VIEWPORT_HEIGHT - 1) { if (MouseY > VIEWPORT_HEIGHT - 1) {
return; return;
} }
if(!setlevel) { if (!setlevel) {
switch(leveltype) { switch (leveltype) {
case DTYPE_TOWN: case DTYPE_TOWN:
trigflag = ForceTownTrig(); trigflag = ForceTownTrig();
break; break;
@ -676,11 +674,11 @@ void CheckTrigForce()
trigflag = ForceL4Trig(); trigflag = ForceL4Trig();
break; break;
} }
if(leveltype != DTYPE_TOWN && !trigflag) { if (leveltype != DTYPE_TOWN && !trigflag) {
trigflag = ForceQuests(); trigflag = ForceQuests();
} }
} else { } else {
switch(setlvlnum) { switch (setlvlnum) {
case SL_SKELKING: case SL_SKELKING:
trigflag = ForceSKingTrig(); trigflag = ForceSKingTrig();
break; break;
@ -693,7 +691,7 @@ void CheckTrigForce()
} }
} }
if(trigflag) { if (trigflag) {
ClearPanel(); ClearPanel();
} }
} }

19
format.sh

@ -1,19 +0,0 @@
#!/bin/bash
ROOT=`pwd`
CPP_DONE="doom.cpp movie.cpp pfile.cpp player.cpp plrmsg.cpp sound.cpp spells.cpp tmsg.cpp"
cd ${ROOT}/Source
for f in $CPP_DONE; do
echo "Formatting $f"
clang-format -style=file -i $f
done
H_DONE="enums.h structs.h"
cd ${ROOT}
for f in $H_DONE; do
echo "Formatting $f"
clang-format -style=file -i $f
done
Loading…
Cancel
Save