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
LONG __stdcall BreakFilter(PEXCEPTION_POINTERS pExc)
{
if(pExc->ExceptionRecord == NULL) {
if (pExc->ExceptionRecord == NULL) {
return 0;
}
if(pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) {
if (pExc->ExceptionRecord->ExceptionCode != EXCEPTION_BREAKPOINT) {
return 0;
}
if(((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3
if (((BYTE *)pExc->ContextRecord->Eip)[0] == 0xCC) { // int 3
pExc->ContextRecord->Eip++;
}

6
Source/capture.cpp

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

7
Source/codec.cpp

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

2
Source/control.cpp

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

212
Source/cursor.cpp

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

20
Source/debug.cpp

@ -28,20 +28,20 @@ void init_seed_desync()
{
int i;
for(i = 0; i < 4096; i++) {
for (i = 0; i < 4096; i++) {
seed_table[i] = -1;
}
seed_index = 0;
for(i = 0; i < NUMLEVELS; i++) {
for (i = 0; i < NUMLEVELS; i++) {
level_seeds[i] = 0;
}
}
void seed_desync_index_get()
{
if(currlevel == 0) {
if (currlevel == 0) {
return;
}
@ -51,7 +51,7 @@ void seed_desync_index_get()
void seed_desync_index_set()
{
if(currlevel == 0) {
if (currlevel == 0) {
return;
}
@ -61,13 +61,13 @@ void seed_desync_index_set()
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;
}
if(seed_table[seed_index] == -1) {
if (seed_table[seed_index] == -1) {
seed_table[seed_index] = seed;
} else if(seed != seed_table[seed_index]) {
} else if (seed != seed_table[seed_index]) {
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);
NetSendCmdString(1 << myplr, dstr);
dbgqst++;
if (dbgqst == MAXQUESTS)
dbgqst = 0;
@ -229,8 +229,8 @@ void PrintDebugQuest()
void PrintDebugMonster(int m)
{
BOOL bActive;
int i;
char dstr[128];
int i;
char dstr[128];
sprintf(dstr, "Monster %i = %s", m, monster[m].mName);
NetSendCmdString(1 << myplr, dstr);

352
Source/diablo.cpp

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

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;
else
return psfx;
return psfx + random(165, nRand);
return psfx + random(165, nRand);
}
void PlaySfxLoc(int psfx, int x, int y)
@ -1162,7 +1162,6 @@ void effects_update()
}
}
void effects_cleanup_sfx()
{
DWORD i;

18
Source/error.cpp

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

2
Source/fault.cpp

@ -24,7 +24,7 @@ void fault_init_filter()
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()

134
Source/gendung.cpp

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

37
Source/init.cpp

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

20
Source/interfac.cpp

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

36
Source/minitext.cpp

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

135
Source/monster.cpp

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

48
Source/multi.cpp

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

7
Source/objects.cpp

@ -1515,11 +1515,10 @@ void Obj_Circle(int i)
object[i]._oVar6 = 2;
return;
}
}
else {
} else {
if (object[i]._ox == 26 && object[i]._oy == 46) {
object[i]._oVar6 = 1;
return;
object[i]._oVar6 = 1;
return;
}
}
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
* 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;
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
*/
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 i;

30
Source/themes.cpp

@ -600,7 +600,7 @@ void Theme_SkelRoom(int t)
AddObject(OBJ_SKFIRE, xp, yp);
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp - 1);
} else {
@ -610,25 +610,25 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp - 1);
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp - 1);
} else {
AddObject(OBJ_BANNERR, xp + 1, yp - 1);
}
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp);
} else {
AddObject(OBJ_BANNERM, xp - 1, yp);
}
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp);
} else {
AddObject(OBJ_BANNERM, xp + 1, yp);
}
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp - 1, yp + 1);
} else {
@ -638,17 +638,17 @@ void Theme_SkelRoom(int t)
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp, yp + 1);
if(random(0, monstrnd[leveltype - 1]) != 0) {
if (random(0, monstrnd[leveltype - 1]) != 0) {
i = PreSpawnSkeleton();
SpawnSkeleton(i, xp + 1, yp + 1);
} else {
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);
}
if(dObject[xp][yp + 3] == 0) {
if (dObject[xp][yp + 3] == 0) {
AddObject(OBJ_SKELBOOK, xp, yp + 2);
}
}
@ -702,7 +702,7 @@ void Theme_Library(int t)
TFit_Shrine(t);
if(themeVar1 == 1) {
if (themeVar1 == 1) {
AddObject(OBJ_BOOKCANDLE, themex - 1, themey);
AddObject(OBJ_BOOKCASER, themex, themey);
AddObject(OBJ_BOOKCANDLE, themex + 1, themey);
@ -712,11 +712,11 @@ void Theme_Library(int t)
AddObject(OBJ_BOOKCANDLE, themex, themey + 1);
}
for(yp = 1; yp < MAXDUNY - 1; yp++) {
for(xp = 1; xp < MAXDUNX - 1; xp++) {
if(CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random(0, librnd[leveltype - 1]) == 0) {
for (yp = 1; yp < MAXDUNY - 1; yp++) {
for (xp = 1; xp < MAXDUNX - 1; xp++) {
if (CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random(0, librnd[leveltype - 1]) == 0) {
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;
object[oi]._oSelFlag = 0;
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`
} else if(t != zharlib) {
} else if (t != zharlib) {
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) {
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]);
}
}
@ -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) {
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]);
}
}
@ -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) {
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]);
}
}

158
Source/towners.cpp

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

28
Source/trigs.cpp

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