Browse Source

🚨 Fix remaning warnings for clang and gcc

pull/1602/head
Anders Jenbo 5 years ago
parent
commit
c89bd9c001
  1. 4
      Source/codec.cpp
  2. 6
      Source/codec.h
  3. 22
      Source/control.cpp
  4. 10
      Source/cursor.cpp
  5. 8
      Source/cursor.h
  6. 2
      Source/debug.cpp
  7. 4
      Source/diablo.cpp
  8. 2
      Source/dthread.cpp
  9. 2
      Source/dthread.h
  10. 22
      Source/encrypt.cpp
  11. 2
      Source/encrypt.h
  12. 2
      Source/engine.cpp
  13. 6
      Source/error.cpp
  14. 40
      Source/gamemenu.cpp
  15. 10
      Source/gendung.cpp
  16. 11
      Source/gendung.h
  17. 7
      Source/inv.cpp
  18. 34
      Source/items.cpp
  19. 22
      Source/loadsave.cpp
  20. 2
      Source/loadsave.h
  21. 11
      Source/monster.cpp
  22. 10
      Source/mpqapi.cpp
  23. 6
      Source/mpqapi.h
  24. 21
      Source/msg.cpp
  25. 6
      Source/multi.cpp
  26. 90
      Source/objects.cpp
  27. 2
      Source/palette.cpp
  28. 6
      Source/pfile.cpp
  29. 2
      Source/pfile.h
  30. 15
      Source/player.cpp
  31. 2
      Source/player.h
  32. 5
      Source/quests.h
  33. 10
      Source/render.cpp
  34. 32
      Source/scrollrt.cpp
  35. 1
      Source/stores.cpp
  36. 10
      Source/themes.cpp
  37. 4
      Source/trigs.cpp

4
Source/codec.cpp

@ -98,14 +98,14 @@ error:
return 0; return 0;
} }
DWORD codec_get_encoded_len(DWORD dwSrcBytes) std::size_t codec_get_encoded_len(std::size_t dwSrcBytes)
{ {
if (dwSrcBytes % BLOCKSIZE != 0) if (dwSrcBytes % BLOCKSIZE != 0)
dwSrcBytes += BLOCKSIZE - (dwSrcBytes % BLOCKSIZE); dwSrcBytes += BLOCKSIZE - (dwSrcBytes % BLOCKSIZE);
return dwSrcBytes + sizeof(CodecSignature); return dwSrcBytes + sizeof(CodecSignature);
} }
void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, const char *pszPassword) void codec_encode(BYTE *pbSrcDst, std::size_t size, std::size_t size_64, const char *pszPassword)
{ {
char buf[128]; char buf[128];
char tmp[SHA1HashSize]; char tmp[SHA1HashSize];

6
Source/codec.h

@ -5,12 +5,14 @@
*/ */
#pragma once #pragma once
#include <cstddef>
#include "miniwin/miniwin.h" #include "miniwin/miniwin.h"
namespace devilution { namespace devilution {
int codec_decode(BYTE *pbSrcDst, DWORD size, const char *pszPassword); int codec_decode(BYTE *pbSrcDst, DWORD size, const char *pszPassword);
DWORD codec_get_encoded_len(DWORD dwSrcBytes); std::size_t codec_get_encoded_len(std::size_t dwSrcBytes);
void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, const char *pszPassword); void codec_encode(BYTE *pbSrcDst, std::size_t size, std::size_t size_64, const char *pszPassword);
} // namespace devilution } // namespace devilution

22
Source/control.cpp

@ -786,7 +786,6 @@ void UpdateManaFlask(CelOutputBuffer out)
void InitControlPan() void InitControlPan()
{ {
int i;
pBtmBuff = CelOutputBuffer::Alloc(PANEL_WIDTH, (PANEL_HEIGHT + 16) * (gbIsMultiplayer ? 2 : 1)); pBtmBuff = CelOutputBuffer::Alloc(PANEL_WIDTH, (PANEL_HEIGHT + 16) * (gbIsMultiplayer ? 2 : 1));
pManaBuff = CelOutputBuffer::Alloc(88, 88); pManaBuff = CelOutputBuffer::Alloc(88, 88);
pLifeBuff = CelOutputBuffer::Alloc(88, 88); pLifeBuff = CelOutputBuffer::Alloc(88, 88);
@ -814,15 +813,15 @@ void InitControlPan()
pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", NULL); pTalkBtns = LoadFileInMem("CtrlPan\\TalkButt.CEL", NULL);
sgbPlrTalkTbl = 0; sgbPlrTalkTbl = 0;
sgszTalkMsg[0] = '\0'; sgszTalkMsg[0] = '\0';
for (i = 0; i < MAX_PLRS; i++) for (unsigned i = 0; i < MAX_PLRS; i++)
whisper[i] = true; whisper[i] = true;
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++) for (unsigned i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++)
talkbtndown[i] = false; talkbtndown[i] = false;
} }
panelflag = false; panelflag = false;
lvlbtndown = false; lvlbtndown = false;
pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", NULL); pPanelButtons = LoadFileInMem("CtrlPan\\Panel8bu.CEL", NULL);
for (i = 0; i < sizeof(panbtn) / sizeof(panbtn[0]); i++) for (unsigned i = 0; i < sizeof(panbtn) / sizeof(panbtn[0]); i++)
panbtn[i] = false; panbtn[i] = false;
panbtndown = false; panbtndown = false;
if (!gbIsMultiplayer) if (!gbIsMultiplayer)
@ -830,7 +829,7 @@ void InitControlPan()
else else
numpanbtns = 8; numpanbtns = 8;
pChrButtons = LoadFileInMem("Data\\CharBut.CEL", NULL); pChrButtons = LoadFileInMem("Data\\CharBut.CEL", NULL);
for (i = 0; i < sizeof(chrbtn) / sizeof(chrbtn[0]); i++) for (unsigned i = 0; i < sizeof(chrbtn) / sizeof(chrbtn[0]); i++)
chrbtn[i] = false; chrbtn[i] = false;
chrbtnactive = false; chrbtnactive = false;
pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", NULL); pDurIcons = LoadFileInMem("Items\\DurIcons.CEL", NULL);
@ -2152,8 +2151,6 @@ void DrawTalkPan(CelOutputBuffer out)
bool control_check_talk_btn() bool control_check_talk_btn()
{ {
int i;
if (!talkflag) if (!talkflag)
return false; return false;
@ -2166,7 +2163,7 @@ bool control_check_talk_btn()
if (MouseY > 123 + PANEL_TOP) if (MouseY > 123 + PANEL_TOP)
return false; return false;
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++) { for (unsigned i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++) {
talkbtndown[i] = false; talkbtndown[i] = false;
} }
@ -2177,15 +2174,14 @@ bool control_check_talk_btn()
void control_release_talk_btn() void control_release_talk_btn()
{ {
int i, p, off;
if (talkflag) { if (talkflag) {
for (i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++) for (unsigned i = 0; i < sizeof(talkbtndown) / sizeof(talkbtndown[0]); i++)
talkbtndown[i] = false; talkbtndown[i] = false;
if (MouseX >= 172 + PANEL_LEFT && MouseY >= 69 + PANEL_TOP && MouseX <= 233 + PANEL_LEFT && MouseY <= 123 + PANEL_TOP) { if (MouseX >= 172 + PANEL_LEFT && MouseY >= 69 + PANEL_TOP && MouseX <= 233 + PANEL_LEFT && MouseY <= 123 + PANEL_TOP) {
off = (MouseY - (69 + PANEL_TOP)) / 18; int off = (MouseY - (69 + PANEL_TOP)) / 18;
for (p = 0; p < MAX_PLRS && off != -1; p++) { int p = 0;
for (; p < MAX_PLRS && off != -1; p++) {
if (p != myplr) if (p != myplr)
off--; off--;
} }

10
Source/cursor.cpp

@ -31,17 +31,17 @@ BYTE *pCursCels;
BYTE *pCursCels2; BYTE *pCursCels2;
/** inv_item value */ /** inv_item value */
char pcursinvitem; int8_t pcursinvitem;
/** Pixel width of the current cursor image */ /** Pixel width of the current cursor image */
int icursW; int icursW;
/** Pixel height of the current cursor image */ /** Pixel height of the current cursor image */
int icursH; int icursH;
/** Current highlighted item */ /** Current highlighted item */
char pcursitem; int8_t pcursitem;
/** Current highlighted object */ /** Current highlighted object */
char pcursobj; int8_t pcursobj;
/** Current highlighted player */ /** Current highlighted player */
char pcursplr; int8_t pcursplr;
/** Current highlighted tile row */ /** Current highlighted tile row */
int cursmx; int cursmx;
/** Current highlighted tile column */ /** Current highlighted tile column */
@ -219,7 +219,7 @@ void CheckRportal()
void CheckCursMove() void CheckCursMove()
{ {
int i, sx, sy, fx, fy, mx, my, tx, ty, px, py, xx, yy, mi, columns, rows, xo, yo; int i, sx, sy, fx, fy, mx, my, tx, ty, px, py, xx, yy, mi, columns, rows, xo, yo;
char bv; int8_t bv;
bool flipflag, flipx, flipy; bool flipflag, flipx, flipy;
sx = MouseX; sx = MouseX;

8
Source/cursor.h

@ -35,11 +35,11 @@ extern int icursH28;
extern BYTE *pCursCels; extern BYTE *pCursCels;
extern BYTE *pCursCels2; extern BYTE *pCursCels2;
extern int icursH; extern int icursH;
extern char pcursinvitem; extern int8_t pcursinvitem;
extern int icursW; extern int icursW;
extern char pcursitem; extern int8_t pcursitem;
extern char pcursobj; extern int8_t pcursobj;
extern char pcursplr; extern int8_t pcursplr;
extern int cursmx; extern int cursmx;
extern int cursmy; extern int cursmy;
extern int pcurs; extern int pcurs;

2
Source/debug.cpp

@ -96,7 +96,7 @@ void MaxSpellsCheat()
} }
} }
void SetSpellLevelCheat(char spl, int spllvl) void SetSpellLevelCheat(spell_id spl, int spllvl)
{ {
plr[myplr]._pMemSpells |= GetSpellBitmask(spl); plr[myplr]._pMemSpells |= GetSpellBitmask(spl);
plr[myplr]._pSplLvl[spl] = spllvl; plr[myplr]._pSplLvl[spl] = spllvl;

4
Source/diablo.cpp

@ -506,7 +506,7 @@ static void SaveOptions()
setIniInt("Network", "Port", sgOptions.Network.nPort); setIniInt("Network", "Port", sgOptions.Network.nPort);
setIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost); setIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost);
for (int i = 0; i < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]); i++) for (size_t i = 0; i < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]); i++)
setIniValue("NetMsg", spszMsgHotKeyTbl[i], sgOptions.Chat.szHotKeyMsgs[i]); setIniValue("NetMsg", spszMsgHotKeyTbl[i], sgOptions.Chat.szHotKeyMsgs[i]);
setIniValue("Controller", "Mapping", sgOptions.Controller.szMapping); setIniValue("Controller", "Mapping", sgOptions.Controller.szMapping);
@ -580,7 +580,7 @@ static void LoadOptions()
sgOptions.Network.nPort = getIniInt("Network", "Port", 6112); sgOptions.Network.nPort = getIniInt("Network", "Port", 6112);
getIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost, sizeof(sgOptions.Network.szPreviousHost), ""); getIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost, sizeof(sgOptions.Network.szPreviousHost), "");
for (int i = 0; i < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]); i++) for (size_t i = 0; i < sizeof(spszMsgTbl) / sizeof(spszMsgTbl[0]); i++)
getIniValue("NetMsg", spszMsgHotKeyTbl[i], sgOptions.Chat.szHotKeyMsgs[i], MAX_SEND_STR_LEN, spszMsgTbl[i]); getIniValue("NetMsg", spszMsgHotKeyTbl[i], sgOptions.Chat.szHotKeyMsgs[i], MAX_SEND_STR_LEN, spszMsgTbl[i]);
getIniValue("Controller", "Mapping", sgOptions.Controller.szMapping, sizeof(sgOptions.Controller.szMapping), ""); getIniValue("Controller", "Mapping", sgOptions.Controller.szMapping, sizeof(sgOptions.Controller.szMapping), "");

2
Source/dthread.cpp

@ -57,7 +57,7 @@ static unsigned int dthread_handler(void *data)
return 0; return 0;
} }
void dthread_remove_player(int pnum) void dthread_remove_player(uint8_t pnum)
{ {
TMegaPkt *pkt; TMegaPkt *pkt;

2
Source/dthread.h

@ -7,7 +7,7 @@
namespace devilution { namespace devilution {
void dthread_remove_player(int pnum); void dthread_remove_player(uint8_t pnum);
void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen); void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen);
void dthread_start(); void dthread_start();
void dthread_cleanup(); void dthread_cleanup();

22
Source/encrypt.cpp

@ -30,29 +30,25 @@ void Decrypt(DWORD *castBlock, DWORD size, DWORD key)
void Encrypt(DWORD *castBlock, DWORD size, DWORD key) void Encrypt(DWORD *castBlock, DWORD size, DWORD key)
{ {
DWORD seed, i, ch; uint32_t seed = 0xEEEEEEEE;
for (unsigned i = 0; i < (size >> 2); i++) {
seed = 0xEEEEEEEE; uint32_t ch = *castBlock;
for (i = 0; i < (size >> 2); i++) { uint32_t t = ch;
DWORD t = ch = *castBlock;
seed += hashtable[4][(key & 0xFF)]; seed += hashtable[4][(key & 0xFF)];
t ^= seed + key; t ^= seed + key;
*castBlock = SDL_SwapLE32(t); *castBlock = SDL_SwapLE32(t);
castBlock++; castBlock++;
seed += ch + (seed << 5) + 3; seed += ch + (seed << 5) + 3;
key = ((key << 0x15) ^ 0xFFE00000) + 0x11111111 | (key >> 0x0B); key = (((key << 0x15) ^ 0xFFE00000) + 0x11111111) | (key >> 0x0B);
} }
} }
DWORD Hash(const char *s, int type) uint32_t Hash(const char *s, int type)
{ {
char ch; uint32_t seed1 = 0x7FED7FED;
DWORD seed1, seed2; uint32_t seed2 = 0xEEEEEEEE;
seed1 = 0x7FED7FED;
seed2 = 0xEEEEEEEE;
while (s != NULL && *s) { while (s != NULL && *s) {
ch = *s++; int8_t ch = *s++;
ch = toupper(ch); ch = toupper(ch);
seed1 = hashtable[type][ch] ^ (seed1 + seed2); seed1 = hashtable[type][ch] ^ (seed1 + seed2);
seed2 += ch + seed1 + (seed2 << 5) + 3; seed2 += ch + seed1 + (seed2 << 5) + 3;

2
Source/encrypt.h

@ -21,7 +21,7 @@ struct TDataInfo {
void Decrypt(DWORD *castBlock, DWORD size, DWORD key); void Decrypt(DWORD *castBlock, DWORD size, DWORD key);
void Encrypt(DWORD *castBlock, DWORD size, DWORD key); void Encrypt(DWORD *castBlock, DWORD size, DWORD key);
DWORD Hash(const char *s, int type); uint32_t Hash(const char *s, int type);
void InitHash(); void InitHash();
DWORD PkwareCompress(BYTE *srcData, DWORD size); DWORD PkwareCompress(BYTE *srcData, DWORD size);
void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes); void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes);

2
Source/engine.cpp

@ -853,7 +853,7 @@ static void Cl2BlitSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEBytes, in
static void Cl2BlitOutlineSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE col) static void Cl2BlitOutlineSafe(CelOutputBuffer out, int sx, int sy, BYTE *pRLEBytes, int nDataSize, int nWidth, BYTE col)
{ {
int w; int w;
char width; int8_t width;
BYTE *src, *dst; BYTE *src, *dst;
src = pRLEBytes; src = pRLEBytes;

6
Source/error.cpp

@ -13,7 +13,7 @@ namespace devilution {
diablo_message msgtable[MAX_SEND_STR_LEN]; diablo_message msgtable[MAX_SEND_STR_LEN];
DWORD msgdelay; DWORD msgdelay;
diablo_message msgflag; diablo_message msgflag;
char msgcnt; uint8_t msgcnt;
/** Maps from error_id to error message. */ /** Maps from error_id to error message. */
const char *const MsgStrings[] = { const char *const MsgStrings[] = {
@ -95,9 +95,7 @@ void InitDiabloMsg(diablo_message e)
void ClrDiabloMsg() void ClrDiabloMsg()
{ {
int i; for (unsigned i = 0; i < sizeof(msgtable); i++)
for (i = 0; i < sizeof(msgtable); i++)
msgtable[i] = EMSG_NONE; msgtable[i] = EMSG_NONE;
msgflag = EMSG_NONE; msgflag = EMSG_NONE;

40
Source/gamemenu.cpp

@ -27,10 +27,8 @@ void gamemenu_restart_town(bool bActivate);
void gamemenu_options(bool bActivate); void gamemenu_options(bool bActivate);
void gamemenu_music_volume(bool bActivate); void gamemenu_music_volume(bool bActivate);
void gamemenu_sound_volume(bool bActivate); void gamemenu_sound_volume(bool bActivate);
void gamemenu_loadjog(bool bActivate);
void gamemenu_gamma(bool bActivate); void gamemenu_gamma(bool bActivate);
void gamemenu_speed(bool bActivate); void gamemenu_speed(bool bActivate);
void gamemenu_color_cycling(bool bActivate);
/** Contains the game menu items of the single player menu. */ /** Contains the game menu items of the single player menu. */
TMenuItem sgSingleMenu[] = { TMenuItem sgSingleMenu[] = {
@ -61,9 +59,7 @@ TMenuItem sgOptionsMenu[] = {
{ GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_music_volume }, { GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_music_volume },
{ GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_sound_volume }, { GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_sound_volume },
{ GMENU_ENABLED | GMENU_SLIDER, "Gamma", &gamemenu_gamma }, { GMENU_ENABLED | GMENU_SLIDER, "Gamma", &gamemenu_gamma },
// { GMENU_ENABLED , NULL, &gamemenu_color_cycling },
{ GMENU_ENABLED | GMENU_SLIDER, "Speed", &gamemenu_speed }, { GMENU_ENABLED | GMENU_SLIDER, "Speed", &gamemenu_speed },
// { GMENU_ENABLED | GMENU_SLIDER, NULL, &gamemenu_loadjog },
{ GMENU_ENABLED , "Previous Menu", &gamemenu_previous }, { GMENU_ENABLED , "Previous Menu", &gamemenu_previous },
{ GMENU_ENABLED , NULL, NULL }, { GMENU_ENABLED , NULL, NULL },
// clang-format on // clang-format on
@ -78,12 +74,6 @@ const char *const sound_toggle_names[] = {
"Sound", "Sound",
"Sound Disabled", "Sound Disabled",
}; };
const char *jogging_toggle_names[] = {
"Jog",
"Walk",
};
/** Specifies the menu names for color cycling disabled and enabled. */
const char *const color_cycling_toggle_names[] = { "Color Cycling Off", "Color Cycling On" };
void gamemenu_update_single(TMenuItem *pMenuItems) void gamemenu_update_single(TMenuItem *pMenuItems)
{ {
@ -215,13 +205,6 @@ void gamemenu_get_sound()
gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionsMenu[1], sound_get_or_set_sound_volume(1)); gamemenu_sound_music_toggle(sound_toggle_names, &sgOptionsMenu[1], sound_get_or_set_sound_volume(1));
} }
void gamemenu_jogging()
{
gmenu_slider_steps(&sgOptionsMenu[3], 2);
gmenu_slider_set(&sgOptionsMenu[3], 0, 1, sgOptions.Gameplay.bRunInTown);
sgOptionsMenu[3].pszStr = jogging_toggle_names[!sgOptions.Gameplay.bRunInTown ? 1 : 0];
}
void gamemenu_get_gamma() void gamemenu_get_gamma()
{ {
gmenu_slider_steps(&sgOptionsMenu[2], 15); gmenu_slider_steps(&sgOptionsMenu[2], 15);
@ -250,11 +233,6 @@ void gamemenu_get_speed()
gmenu_slider_set(&sgOptionsMenu[3], 20, 50, sgGameInitInfo.nTickRate); gmenu_slider_set(&sgOptionsMenu[3], 20, 50, sgGameInitInfo.nTickRate);
} }
void gamemenu_get_color_cycling()
{
sgOptionsMenu[3].pszStr = color_cycling_toggle_names[sgOptions.Graphics.bColorCycling ? 1 : 0];
}
static int gamemenu_slider_gamma() static int gamemenu_slider_gamma()
{ {
return gmenu_slider_get(&sgOptionsMenu[2], 30, 100); return gmenu_slider_get(&sgOptionsMenu[2], 30, 100);
@ -264,10 +242,8 @@ void gamemenu_options(bool bActivate)
{ {
gamemenu_get_music(); gamemenu_get_music();
gamemenu_get_sound(); gamemenu_get_sound();
//gamemenu_jogging();
gamemenu_get_gamma(); gamemenu_get_gamma();
gamemenu_get_speed(); gamemenu_get_speed();
//gamemenu_get_color_cycling();
gmenu_set_items(sgOptionsMenu, NULL); gmenu_set_items(sgOptionsMenu, NULL);
} }
@ -345,16 +321,6 @@ void gamemenu_sound_volume(bool bActivate)
gamemenu_get_sound(); gamemenu_get_sound();
} }
void gamemenu_loadjog(bool bActivate)
{
if (!gbIsMultiplayer) {
sgOptions.Gameplay.bRunInTown = !sgOptions.Gameplay.bRunInTown;
sgGameInitInfo.bRunInTown = sgOptions.Gameplay.bRunInTown;
PlaySFX(IS_TITLEMOV);
gamemenu_jogging();
}
}
void gamemenu_gamma(bool bActivate) void gamemenu_gamma(bool bActivate)
{ {
int gamma; int gamma;
@ -388,12 +354,6 @@ void gamemenu_speed(bool bActivate)
gnTickDelay = 1000 / sgGameInitInfo.nTickRate; gnTickDelay = 1000 / sgGameInitInfo.nTickRate;
} }
void gamemenu_color_cycling(bool bActivate)
{
sgOptions.Graphics.bColorCycling = !sgOptions.Graphics.bColorCycling;
sgOptionsMenu[3].pszStr = color_cycling_toggle_names[sgOptions.Graphics.bColorCycling ? 1 : 0];
}
} // namespace } // namespace
void gamemenu_on() void gamemenu_on()

10
Source/gendung.cpp

@ -91,12 +91,12 @@ int dPiece[MAXDUNX][MAXDUNY];
/** Specifies the dungeon piece information for a given coordinate and block number. */ /** Specifies the dungeon piece information for a given coordinate and block number. */
MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY]; MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY];
/** Specifies the transparency at each coordinate of the map. */ /** Specifies the transparency at each coordinate of the map. */
char dTransVal[MAXDUNX][MAXDUNY]; int8_t dTransVal[MAXDUNX][MAXDUNY];
char dLight[MAXDUNX][MAXDUNY]; char dLight[MAXDUNX][MAXDUNY];
char dPreLight[MAXDUNX][MAXDUNY]; char dPreLight[MAXDUNX][MAXDUNY];
char dFlags[MAXDUNX][MAXDUNY]; int8_t dFlags[MAXDUNX][MAXDUNY];
/** Contains the player numbers (players array indices) of the map. */ /** Contains the player numbers (players array indices) of the map. */
char dPlayer[MAXDUNX][MAXDUNY]; int8_t dPlayer[MAXDUNX][MAXDUNY];
/** /**
* Contains the NPC numbers of the map. The NPC number represents a * Contains the NPC numbers of the map. The NPC number represents a
* towner number (towners array index) in Tristram and a monster number * towner number (towners array index) in Tristram and a monster number
@ -109,11 +109,11 @@ int16_t dMonster[MAXDUNX][MAXDUNY];
* dDead[x][y] & 0x1F - index of dead * dDead[x][y] & 0x1F - index of dead
* dDead[x][y] >> 0x5 - direction * dDead[x][y] >> 0x5 - direction
*/ */
char dDead[MAXDUNX][MAXDUNY]; int8_t dDead[MAXDUNX][MAXDUNY];
/** Contains the object numbers (objects array indices) of the map. */ /** Contains the object numbers (objects array indices) of the map. */
char dObject[MAXDUNX][MAXDUNY]; char dObject[MAXDUNX][MAXDUNY];
/** Contains the item numbers (items array indices) of the map. */ /** Contains the item numbers (items array indices) of the map. */
char dItem[MAXDUNX][MAXDUNY]; int8_t dItem[MAXDUNX][MAXDUNY];
/** Contains the missile numbers (missiles array indices) of the map. */ /** Contains the missile numbers (missiles array indices) of the map. */
char dMissile[MAXDUNX][MAXDUNY]; char dMissile[MAXDUNX][MAXDUNY];
/** /**

11
Source/gendung.h

@ -77,7 +77,6 @@ enum _difficulty : uint8_t {
DIFF_NORMAL, DIFF_NORMAL,
DIFF_NIGHTMARE, DIFF_NIGHTMARE,
DIFF_HELL, DIFF_HELL,
NUM_DIFFICULTIES,
}; };
struct ScrollStruct { struct ScrollStruct {
@ -154,15 +153,15 @@ extern char TransVal;
extern bool TransList[256]; extern bool TransList[256];
extern int dPiece[MAXDUNX][MAXDUNY]; extern int dPiece[MAXDUNX][MAXDUNY];
extern MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY]; extern MICROS dpiece_defs_map_2[MAXDUNX][MAXDUNY];
extern char dTransVal[MAXDUNX][MAXDUNY]; extern int8_t dTransVal[MAXDUNX][MAXDUNY];
extern char dLight[MAXDUNX][MAXDUNY]; extern char dLight[MAXDUNX][MAXDUNY];
extern char dPreLight[MAXDUNX][MAXDUNY]; extern char dPreLight[MAXDUNX][MAXDUNY];
extern char dFlags[MAXDUNX][MAXDUNY]; extern int8_t dFlags[MAXDUNX][MAXDUNY];
extern char dPlayer[MAXDUNX][MAXDUNY]; extern int8_t dPlayer[MAXDUNX][MAXDUNY];
extern int16_t dMonster[MAXDUNX][MAXDUNY]; extern int16_t dMonster[MAXDUNX][MAXDUNY];
extern char dDead[MAXDUNX][MAXDUNY]; extern int8_t dDead[MAXDUNX][MAXDUNY];
extern char dObject[MAXDUNX][MAXDUNY]; extern char dObject[MAXDUNX][MAXDUNY];
extern char dItem[MAXDUNX][MAXDUNY]; extern int8_t dItem[MAXDUNX][MAXDUNY];
extern char dMissile[MAXDUNX][MAXDUNY]; extern char dMissile[MAXDUNX][MAXDUNY];
extern char dSpecial[MAXDUNX][MAXDUNY]; extern char dSpecial[MAXDUNX][MAXDUNY];
extern int themeCount; extern int themeCount;

7
Source/inv.cpp

@ -363,7 +363,7 @@ static void AddItemToInvGrid(int playerNumber, int invGridIndex, int invListInde
const int pitch = 10; const int pitch = 10;
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
if (x == 0 & y == sizeY - 1) if (x == 0 && y == sizeY - 1)
plr[playerNumber].InvGrid[invGridIndex + x] = invListIndex; plr[playerNumber].InvGrid[invGridIndex + x] = invListIndex;
else else
plr[playerNumber].InvGrid[invGridIndex + x] = -invListIndex; plr[playerNumber].InvGrid[invGridIndex + x] = -invListIndex;
@ -1815,7 +1815,7 @@ void CleanupItems(ItemStruct *item, int ii)
{ {
dItem[item->_ix][item->_iy] = 0; dItem[item->_ix][item->_iy] = 0;
if (currlevel == 21 & item->_ix == CornerStone.x && item->_iy == CornerStone.y) { if (currlevel == 21 && item->_ix == CornerStone.x && item->_iy == CornerStone.y) {
CornerStone.item._itype = ITYPE_NONE; CornerStone.item._itype = ITYPE_NONE;
CornerStone.item._iSelFlag = 0; CornerStone.item._iSelFlag = 0;
CornerStone.item._ix = 0; CornerStone.item._ix = 0;
@ -2226,7 +2226,6 @@ char CheckInvHLight()
int r, ii, nGold; int r, ii, nGold;
ItemStruct *pi; ItemStruct *pi;
PlayerStruct *p; PlayerStruct *p;
char rv;
for (r = 0; (DWORD)r < NUM_XY_SLOTS; r++) { for (r = 0; (DWORD)r < NUM_XY_SLOTS; r++) {
int xo = RIGHT_PANEL; int xo = RIGHT_PANEL;
@ -2247,7 +2246,7 @@ char CheckInvHLight()
if ((DWORD)r >= NUM_XY_SLOTS) if ((DWORD)r >= NUM_XY_SLOTS)
return -1; return -1;
rv = -1; int8_t rv = -1;
infoclr = COL_WHITE; infoclr = COL_WHITE;
pi = NULL; pi = NULL;
p = &plr[myplr]; p = &plr[myplr];

34
Source/items.cpp

@ -545,7 +545,6 @@ void CalcPlrItemVals(int p, bool Loadgfx)
int g; int g;
int i; int i;
int mi;
int bdam = 0; // bonus damage int bdam = 0; // bonus damage
int btohit = 0; // bonus chance to hit int btohit = 0; // bonus chance to hit
@ -1377,7 +1376,7 @@ bool ItemSpaceOk(int i, int j)
return !nSolidTable[dPiece[i][j]]; return !nSolidTable[dPiece[i][j]];
} }
static bool GetItemSpace(int x, int y, char inum) static bool GetItemSpace(int x, int y, int8_t inum)
{ {
int i, j, rs; int i, j, rs;
int xx, yy; int xx, yy;
@ -1443,7 +1442,7 @@ int AllocateItem()
return inum; return inum;
} }
static void GetSuperItemSpace(int x, int y, char inum) static void GetSuperItemSpace(int x, int y, int8_t inum)
{ {
if (!GetItemSpace(x, y, inum)) { if (!GetItemSpace(x, y, inum)) {
for (int k = 2; k < 50; k++) { for (int k = 2; k < 50; k++) {
@ -1724,12 +1723,17 @@ void GetItemAttrs(int i, int idata, int lvl)
int rndv; int rndv;
int itemlevel = items_get_currlevel(); int itemlevel = items_get_currlevel();
if (sgGameInitInfo.nDifficulty == DIFF_NORMAL) switch (sgGameInitInfo.nDifficulty) {
case DIFF_NORMAL:
rndv = 5 * itemlevel + random_(21, 10 * itemlevel); rndv = 5 * itemlevel + random_(21, 10 * itemlevel);
else if (sgGameInitInfo.nDifficulty == DIFF_NIGHTMARE) break;
case DIFF_NIGHTMARE:
rndv = 5 * (itemlevel + 16) + random_(21, 10 * (itemlevel + 16)); rndv = 5 * (itemlevel + 16) + random_(21, 10 * (itemlevel + 16));
else if (sgGameInitInfo.nDifficulty == DIFF_HELL) break;
case DIFF_HELL:
rndv = 5 * (itemlevel + 32) + random_(21, 10 * (itemlevel + 32)); rndv = 5 * (itemlevel + 32) + random_(21, 10 * (itemlevel + 32));
break;
}
if (leveltype == DTYPE_HELL) if (leveltype == DTYPE_HELL)
rndv += rndv >> 3; rndv += rndv >> 3;
if (rndv > GOLD_MAX_LIMIT) if (rndv > GOLD_MAX_LIMIT)
@ -1773,7 +1777,7 @@ void SaveItemPower(int i, item_effect_type power, int param1, int param2, int mi
break; break;
case IPL_DOPPELGANGER: case IPL_DOPPELGANGER:
items[i]._iDamAcFlags |= 16; items[i]._iDamAcFlags |= 16;
// no break [[fallthrough]];
case IPL_TOHIT_DAMP: case IPL_TOHIT_DAMP:
r = RndPL(param1, param2); r = RndPL(param1, param2);
items[i]._iPLDam += r; items[i]._iPLDam += r;
@ -1928,7 +1932,7 @@ void SaveItemPower(int i, item_effect_type power, int param1, int param2, int mi
break; break;
case IPL_CRYSTALLINE: case IPL_CRYSTALLINE:
items[i]._iPLDam += 140 + r * 2; items[i]._iPLDam += 140 + r * 2;
// no break [[fallthrough]];
case IPL_DUR_CURSE: case IPL_DUR_CURSE:
items[i]._iMaxDur -= r * items[i]._iMaxDur / 100; items[i]._iMaxDur -= r * items[i]._iMaxDur / 100;
if (items[i]._iMaxDur < 1) if (items[i]._iMaxDur < 1)
@ -2842,7 +2846,7 @@ void items_427A72()
if (!CornerStone.item.isEmpty()) { if (!CornerStone.item.isEmpty()) {
PackItem(&id, &CornerStone.item); PackItem(&id, &CornerStone.item);
buffer = (BYTE *)&id; buffer = (BYTE *)&id;
for (int i = 0; i < sizeof(PkItemStruct); i++) { for (size_t i = 0; i < sizeof(PkItemStruct); i++) {
sprintf(&sgOptions.Hellfire.szItem[i * 2], "%02X", buffer[i]); sprintf(&sgOptions.Hellfire.szItem[i * 2], "%02X", buffer[i]);
} }
} else { } else {
@ -4530,12 +4534,12 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
count++; count++;
} while (keepgoing } while (keepgoing
|| (( || ((
items[0]._iIvalue > 200000 items[0]._iIvalue > 200000
|| items[0]._iMinStr > strength || items[0]._iMinStr > strength
|| items[0]._iMinMag > magic || items[0]._iMinMag > magic
|| items[0]._iMinDex > dexterity || items[0]._iMinDex > dexterity
|| items[0]._iIvalue < ivalue)) || items[0]._iIvalue < ivalue)
&& count < 150); && count < 150));
premiumitem[i] = items[0]; premiumitem[i] = items[0];
premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM; premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM;
premiumitem[i]._iIdentified = true; premiumitem[i]._iIdentified = true;

22
Source/loadsave.cpp

@ -24,9 +24,9 @@
namespace devilution { namespace devilution {
bool gbIsHellfireSaveGame; bool gbIsHellfireSaveGame;
int giNumberOfLevels; uint8_t giNumberOfLevels;
int giNumberQuests; uint8_t giNumberQuests;
int giNumberOfSmithPremiumItems; uint8_t giNumberOfSmithPremiumItems;
namespace { namespace {
@ -429,9 +429,9 @@ static void LoadPlayer(LoadHelper *file, int p)
pPlayer->_pVar6 = file->nextLE<Sint32>(); pPlayer->_pVar6 = file->nextLE<Sint32>();
pPlayer->_pVar7 = file->nextLE<Sint32>(); pPlayer->_pVar7 = file->nextLE<Sint32>();
pPlayer->_pVar8 = file->nextLE<Sint32>(); pPlayer->_pVar8 = file->nextLE<Sint32>();
for (int i = 0; i < giNumberOfLevels; i++) for (uint8_t i = 0; i < giNumberOfLevels; i++)
pPlayer->_pLvlVisited[i] = file->nextBool8(); pPlayer->_pLvlVisited[i] = file->nextBool8();
for (int i = 0; i < giNumberOfLevels; i++) for (uint8_t i = 0; i < giNumberOfLevels; i++)
pPlayer->_pSLvlVisited[i] = file->nextBool8(); pPlayer->_pSLvlVisited[i] = file->nextBool8();
file->skip(2); // Alignment file->skip(2); // Alignment
@ -752,9 +752,9 @@ static void LoadQuest(LoadHelper *file, int i)
pQuest->_qidx = file->nextLE<Uint8>(); pQuest->_qidx = file->nextLE<Uint8>();
if (gbIsHellfireSaveGame) { if (gbIsHellfireSaveGame) {
file->skip(2); // Alignment file->skip(2); // Alignment
pQuest->_qmsg = file->nextLE<Sint32>(); pQuest->_qmsg = static_cast<_speech_id>(file->nextLE<Sint32>());
} else { } else {
pQuest->_qmsg = file->nextLE<Uint8>(); pQuest->_qmsg = static_cast<_speech_id>(file->nextLE<Uint8>());
} }
pQuest->_qvar1 = file->nextLE<Uint8>(); pQuest->_qvar1 = file->nextLE<Uint8>();
pQuest->_qvar2 = file->nextLE<Uint8>(); pQuest->_qvar2 = file->nextLE<Uint8>();
@ -1034,7 +1034,7 @@ void LoadGame(bool firstflag)
if (!gbIsHellfire && currlevel > 17) if (!gbIsHellfire && currlevel > 17)
app_fatal("Player is on a Hellfire only level"); app_fatal("Player is on a Hellfire only level");
for (int i = 0; i < giNumberOfLevels; i++) { for (uint8_t i = 0; i < giNumberOfLevels; i++) {
glSeedTbl[i] = file.nextBE<Uint32>(); glSeedTbl[i] = file.nextBE<Uint32>();
file.skip(4); // Skip loading gnLevelTypeTbl file.skip(4); // Skip loading gnLevelTypeTbl
} }
@ -1407,9 +1407,9 @@ static void SavePlayer(SaveHelper *file, int p)
file->writeLE<Sint32>(pPlayer->_pVar6); file->writeLE<Sint32>(pPlayer->_pVar6);
file->writeLE<Sint32>(pPlayer->_pVar7); file->writeLE<Sint32>(pPlayer->_pVar7);
file->writeLE<Sint32>(pPlayer->_pVar8); file->writeLE<Sint32>(pPlayer->_pVar8);
for (int i = 0; i < giNumberOfLevels; i++) for (uint8_t i = 0; i < giNumberOfLevels; i++)
file->writeLE<Uint8>(pPlayer->_pLvlVisited[i]); file->writeLE<Uint8>(pPlayer->_pLvlVisited[i]);
for (int i = 0; i < giNumberOfLevels; i++) for (uint8_t i = 0; i < giNumberOfLevels; i++)
file->writeLE<Uint8>(pPlayer->_pSLvlVisited[i]); // only 10 used file->writeLE<Uint8>(pPlayer->_pSLvlVisited[i]); // only 10 used
file->skip(2); // Alignment file->skip(2); // Alignment
@ -1807,7 +1807,7 @@ void SaveGameData()
file.writeBE<Sint32>(nummissiles); file.writeBE<Sint32>(nummissiles);
file.writeBE<Sint32>(nobjects); file.writeBE<Sint32>(nobjects);
for (int i = 0; i < giNumberOfLevels; i++) { for (uint8_t i = 0; i < giNumberOfLevels; i++) {
file.writeBE<Uint32>(glSeedTbl[i]); file.writeBE<Uint32>(glSeedTbl[i]);
file.writeBE<Sint32>(gnLevelTypeTbl[i]); file.writeBE<Sint32>(gnLevelTypeTbl[i]);
} }

2
Source/loadsave.h

@ -10,7 +10,7 @@
namespace devilution { namespace devilution {
extern bool gbIsHellfireSaveGame; extern bool gbIsHellfireSaveGame;
extern int giNumberOfLevels; extern uint8_t giNumberOfLevels;
void RemoveInvalidItem(ItemStruct *pItem); void RemoveInvalidItem(ItemStruct *pItem);
int RemapItemIdxFromDiablo(int i); int RemapItemIdxFromDiablo(int i);

11
Source/monster.cpp

@ -2665,21 +2665,18 @@ void DoEnding()
void PrepDoEnding() void PrepDoEnding()
{ {
int newKillLevel, i;
DWORD *killLevel;
gbSoundOn = sgbSaveSoundOn; gbSoundOn = sgbSaveSoundOn;
gbRunGame = false; gbRunGame = false;
deathflag = false; deathflag = false;
cineflag = true; cineflag = true;
killLevel = &plr[myplr].pDiabloKillLevel; uint32_t *killLevel = &plr[myplr].pDiabloKillLevel;
newKillLevel = sgGameInitInfo.nDifficulty + 1; uint32_t newKillLevel = sgGameInitInfo.nDifficulty + 1;
if (*killLevel > newKillLevel) if (*killLevel > newKillLevel)
newKillLevel = *killLevel; newKillLevel = *killLevel;
plr[myplr].pDiabloKillLevel = newKillLevel; plr[myplr].pDiabloKillLevel = newKillLevel;
for (i = 0; i < MAX_PLRS; i++) { for (int i = 0; i < MAX_PLRS; i++) {
plr[i]._pmode = PM_QUIT; plr[i]._pmode = PM_QUIT;
plr[i]._pInvincible = true; plr[i]._pInvincible = true;
if (gbIsMultiplayer) { if (gbIsMultiplayer) {
@ -2812,6 +2809,8 @@ void M_WalkDir(int i, direction md)
case DIR_NW: case DIR_NW:
M_StartWalk(i, -MWVel[mwi][1], -MWVel[mwi][0], -1, 0, DIR_NW); M_StartWalk(i, -MWVel[mwi][1], -MWVel[mwi][0], -1, 0, DIR_NW);
break; break;
case DIR_OMNI:
break;
} }
} }

10
Source/mpqapi.cpp

@ -446,7 +446,7 @@ int mpqapi_find_free_block(uint32_t size, uint32_t *block_size)
return result; return result;
} }
static int mpqapi_get_hash_index(int index, int hash_a, int hash_b, int locale) static int mpqapi_get_hash_index(int index, uint32_t hash_a, uint32_t hash_b)
{ {
DWORD idx, i; DWORD idx, i;
@ -458,8 +458,6 @@ static int mpqapi_get_hash_index(int index, int hash_a, int hash_b, int locale)
continue; continue;
if (cur_archive.sgpHashTbl[idx].hashcheck[1] != hash_b) if (cur_archive.sgpHashTbl[idx].hashcheck[1] != hash_b)
continue; continue;
if (cur_archive.sgpHashTbl[idx].lcid != locale)
continue;
if (cur_archive.sgpHashTbl[idx].block == -2) if (cur_archive.sgpHashTbl[idx].block == -2)
continue; continue;
@ -471,7 +469,7 @@ static int mpqapi_get_hash_index(int index, int hash_a, int hash_b, int locale)
static int FetchHandle(const char *pszName) static int FetchHandle(const char *pszName)
{ {
return mpqapi_get_hash_index(Hash(pszName, 0), Hash(pszName, 1), Hash(pszName, 2), 0); return mpqapi_get_hash_index(Hash(pszName, 0), Hash(pszName, 1), Hash(pszName, 2));
} }
void mpqapi_remove_hash_entry(const char *pszName) void mpqapi_remove_hash_entry(const char *pszName)
@ -493,7 +491,7 @@ void mpqapi_remove_hash_entry(const char *pszName)
} }
} }
void mpqapi_remove_hash_entries(bool (*fnGetName)(DWORD, char *)) void mpqapi_remove_hash_entries(bool (*fnGetName)(uint8_t, char *))
{ {
DWORD dwIndex, i; DWORD dwIndex, i;
char pszFileName[MAX_PATH]; char pszFileName[MAX_PATH];
@ -512,7 +510,7 @@ static _BLOCKENTRY *mpqapi_add_file(const char *pszName, _BLOCKENTRY *pBlk, int
h1 = Hash(pszName, 0); h1 = Hash(pszName, 0);
h2 = Hash(pszName, 1); h2 = Hash(pszName, 1);
h3 = Hash(pszName, 2); h3 = Hash(pszName, 2);
if (mpqapi_get_hash_index(h1, h2, h3, 0) != -1) if (mpqapi_get_hash_index(h1, h2, h3) != -1)
app_fatal("Hash collision between \"%s\" and existing file\n", pszName); app_fatal("Hash collision between \"%s\" and existing file\n", pszName);
hIdx = h1 & 0x7FF; hIdx = h1 & 0x7FF;
i = INDEX_ENTRIES; i = INDEX_ENTRIES;

6
Source/mpqapi.h

@ -15,7 +15,7 @@ namespace devilution {
struct _FILEHEADER { struct _FILEHEADER {
int signature; int signature;
int headersize; int headersize;
int filesize; uint32_t filesize;
Uint16 version; Uint16 version;
Sint16 sectorsizeid; Sint16 sectorsizeid;
int hashoffset; int hashoffset;
@ -28,7 +28,7 @@ struct _FILEHEADER {
struct _HASHENTRY { struct _HASHENTRY {
Uint32 hashcheck[2]; Uint32 hashcheck[2];
Uint32 lcid; Uint32 lcid;
Uint32 block; int32_t block;
}; };
struct _BLOCKENTRY { struct _BLOCKENTRY {
@ -39,7 +39,7 @@ struct _BLOCKENTRY {
}; };
void mpqapi_remove_hash_entry(const char *pszName); void mpqapi_remove_hash_entry(const char *pszName);
void mpqapi_remove_hash_entries(bool (*fnGetName)(DWORD, char *)); void mpqapi_remove_hash_entries(bool (*fnGetName)(uint8_t, char *));
bool mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen); bool mpqapi_write_file(const char *pszName, const BYTE *pbData, DWORD dwLen);
void mpqapi_rename(char *pszOld, char *pszNew); void mpqapi_rename(char *pszOld, char *pszNew);
bool mpqapi_has_file(const char *pszName); bool mpqapi_has_file(const char *pszName);

21
Source/msg.cpp

@ -73,12 +73,10 @@ static void msg_free_packets()
static void msg_pre_packet() static void msg_pre_packet()
{ {
int i; int i = -1;
i = -1;
for (TMegaPkt *pkt = sgpMegaPkt; pkt != NULL; pkt = pkt->pNext) { for (TMegaPkt *pkt = sgpMegaPkt; pkt != NULL; pkt = pkt->pNext) {
BYTE *data = pkt->data; BYTE *data = pkt->data;
int spaceLeft = sizeof(pkt->data); size_t spaceLeft = sizeof(pkt->data);
while (spaceLeft != pkt->dwSpaceLeft) { while (spaceLeft != pkt->dwSpaceLeft) {
if (*data == FAKE_CMD_SETID) { if (*data == FAKE_CMD_SETID) {
TFakeCmdPlr *cmd = (TFakeCmdPlr *)data; TFakeCmdPlr *cmd = (TFakeCmdPlr *)data;
@ -2385,21 +2383,6 @@ static DWORD On_SYNCQUEST(TCmd *pCmd, int pnum)
return sizeof(*p); return sizeof(*p);
} }
static DWORD On_ENDREFLECT(TCmd *pCmd, int pnum)
{
if (gbBufferMsgs != 1 && pnum != myplr && currlevel == plr[pnum].plrlevel) {
for (int i = 0; i < nummissiles; i++) {
int mi = missileactive[i];
if (missile[mi]._mitype == MIS_REFLECT && missile[mi]._misource == pnum) {
ClearMissileSpot(mi);
DeleteMissile(mi, i);
}
}
}
return sizeof(*pCmd);
}
static DWORD On_ENDSHIELD(TCmd *pCmd, int pnum) static DWORD On_ENDSHIELD(TCmd *pCmd, int pnum)
{ {
if (gbBufferMsgs != 1 && pnum != myplr && currlevel == plr[pnum].plrlevel) { if (gbBufferMsgs != 1 && pnum != myplr && currlevel == plr[pnum].plrlevel) {

6
Source/multi.cpp

@ -453,19 +453,19 @@ void multi_process_network_packets()
int dx, dy; int dx, dy;
TPktHdr *pkt; TPktHdr *pkt;
DWORD dwMsgSize; DWORD dwMsgSize;
DWORD dwID; int dwID;
bool cond; bool cond;
char *data; char *data;
multi_clear_left_tbl(); multi_clear_left_tbl();
multi_process_tmsgs(); multi_process_tmsgs();
while (SNetReceiveMessage((int *)&dwID, &data, (int *)&dwMsgSize)) { while (SNetReceiveMessage(&dwID, &data, (int *)&dwMsgSize)) {
dwRecCount++; dwRecCount++;
multi_clear_left_tbl(); multi_clear_left_tbl();
pkt = (TPktHdr *)data; pkt = (TPktHdr *)data;
if (dwMsgSize < sizeof(TPktHdr)) if (dwMsgSize < sizeof(TPktHdr))
continue; continue;
if (dwID >= MAX_PLRS) if (dwID < 0 || dwID >= MAX_PLRS)
continue; continue;
if (pkt->wCheck != LOAD_BE32("\0\0ip")) if (pkt->wCheck != LOAD_BE32("\0\0ip"))
continue; continue;

90
Source/objects.cpp

@ -671,7 +671,7 @@ void AddL2Torches()
void AddObjTraps() void AddObjTraps()
{ {
char oi_trap, oi; int8_t oi_trap, oi;
int i, j; int i, j;
int xp, yp; int xp, yp;
int rndv; int rndv;
@ -727,7 +727,7 @@ void AddObjTraps()
void AddChestTraps() void AddChestTraps()
{ {
int i, j; int i, j;
char oi; int8_t oi;
for (j = 0; j < MAXDUNY; j++) { for (j = 0; j < MAXDUNY; j++) {
for (i = 0; i < MAXDUNX; i++) { for (i = 0; i < MAXDUNX; i++) {
@ -1042,7 +1042,6 @@ void AddLazStand()
void InitObjects() void InitObjects()
{ {
_speech_id sp_id;
BYTE *mem; BYTE *mem;
ClrAllObjects(); ClrAllObjects();
@ -1093,18 +1092,26 @@ void InitObjects()
AddL2Objs(0, 0, MAXDUNX, MAXDUNY); AddL2Objs(0, 0, MAXDUNX, MAXDUNY);
AddL2Torches(); AddL2Torches();
if (QuestStatus(Q_BLIND)) { if (QuestStatus(Q_BLIND)) {
if (plr[myplr]._pClass == HeroClass::Warrior) { _speech_id sp_id;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLINDING; sp_id = TEXT_BLINDING;
} else if (plr[myplr]._pClass == HeroClass::Rogue) { break;
case HeroClass::Rogue:
sp_id = TEXT_RBLINDING; sp_id = TEXT_RBLINDING;
} else if (plr[myplr]._pClass == HeroClass::Sorcerer) { break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLINDING; sp_id = TEXT_MBLINDING;
} else if (plr[myplr]._pClass == HeroClass::Monk) { break;
case HeroClass::Monk:
sp_id = TEXT_HBLINDING; sp_id = TEXT_HBLINDING;
} else if (plr[myplr]._pClass == HeroClass::Bard) { break;
case HeroClass::Bard:
sp_id = TEXT_BBLINDING; sp_id = TEXT_BBLINDING;
} else if (plr[myplr]._pClass == HeroClass::Barbarian) { break;
case HeroClass::Barbarian:
sp_id = TEXT_BLINDING; sp_id = TEXT_BLINDING;
break;
} }
quests[Q_BLIND]._qmsg = sp_id; quests[Q_BLIND]._qmsg = sp_id;
AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, sp_id); AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_w + setpc_x + 1, setpc_h + setpc_y + 1, sp_id);
@ -1113,18 +1120,26 @@ void InitObjects()
mem_free_dbg(mem); mem_free_dbg(mem);
} }
if (QuestStatus(Q_BLOOD)) { if (QuestStatus(Q_BLOOD)) {
if (plr[myplr]._pClass == HeroClass::Warrior) { _speech_id sp_id;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLOODY; sp_id = TEXT_BLOODY;
} else if (plr[myplr]._pClass == HeroClass::Rogue) { break;
case HeroClass::Rogue:
sp_id = TEXT_RBLOODY; sp_id = TEXT_RBLOODY;
} else if (plr[myplr]._pClass == HeroClass::Sorcerer) { break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLOODY; sp_id = TEXT_MBLOODY;
} else if (plr[myplr]._pClass == HeroClass::Monk) { break;
case HeroClass::Monk:
sp_id = TEXT_HBLOODY; sp_id = TEXT_HBLOODY;
} else if (plr[myplr]._pClass == HeroClass::Bard) { break;
case HeroClass::Bard:
sp_id = TEXT_BBLOODY; sp_id = TEXT_BBLOODY;
} else if (plr[myplr]._pClass == HeroClass::Barbarian) { break;
case HeroClass::Barbarian:
sp_id = TEXT_BLOODY; sp_id = TEXT_BLOODY;
break;
} }
quests[Q_BLOOD]._qmsg = sp_id; quests[Q_BLOOD]._qmsg = sp_id;
AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, sp_id); AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7, sp_id);
@ -1138,18 +1153,26 @@ void InitObjects()
} }
if (leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
if (QuestStatus(Q_WARLORD)) { if (QuestStatus(Q_WARLORD)) {
if (plr[myplr]._pClass == HeroClass::Warrior) { _speech_id sp_id;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
sp_id = TEXT_BLOODWAR; sp_id = TEXT_BLOODWAR;
} else if (plr[myplr]._pClass == HeroClass::Rogue) { break;
case HeroClass::Rogue:
sp_id = TEXT_RBLOODWAR; sp_id = TEXT_RBLOODWAR;
} else if (plr[myplr]._pClass == HeroClass::Sorcerer) { break;
case HeroClass::Sorcerer:
sp_id = TEXT_MBLOODWAR; sp_id = TEXT_MBLOODWAR;
} else if (plr[myplr]._pClass == HeroClass::Monk) { break;
case HeroClass::Monk:
sp_id = TEXT_HBLOODWAR; sp_id = TEXT_HBLOODWAR;
} else if (plr[myplr]._pClass == HeroClass::Bard) { break;
case HeroClass::Bard:
sp_id = TEXT_BBLOODWAR; sp_id = TEXT_BBLOODWAR;
} else if (plr[myplr]._pClass == HeroClass::Barbarian) { break;
case HeroClass::Barbarian:
sp_id = TEXT_BLOODWAR; sp_id = TEXT_BLOODWAR;
break;
} }
quests[Q_WARLORD]._qmsg = sp_id; quests[Q_WARLORD]._qmsg = sp_id;
AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, sp_id); AddBookLever(0, 0, MAXDUNX, MAXDUNY, setpc_x, setpc_y, setpc_x + setpc_w, setpc_y + setpc_h, sp_id);
@ -3056,7 +3079,7 @@ void OperateBookLever(int pnum, int i)
void OperateSChambBk(int pnum, int i) void OperateSChambBk(int pnum, int i)
{ {
int j, textdef; int j;
if (object[i]._oSelFlag != 0 && !qtextflag) { if (object[i]._oSelFlag != 0 && !qtextflag) {
if (object[i]._oAnimFrame != object[i]._oVar6) { if (object[i]._oAnimFrame != object[i]._oVar6) {
@ -3069,18 +3092,27 @@ void OperateSChambBk(int pnum, int i)
quests[Q_SCHAMB]._qactive = QUEST_ACTIVE; quests[Q_SCHAMB]._qactive = QUEST_ACTIVE;
quests[Q_SCHAMB]._qlog = true; quests[Q_SCHAMB]._qlog = true;
} }
if (plr[myplr]._pClass == HeroClass::Warrior) {
_speech_id textdef;
switch (plr[myplr]._pClass) {
case HeroClass::Warrior:
textdef = TEXT_BONER; textdef = TEXT_BONER;
} else if (plr[myplr]._pClass == HeroClass::Rogue) { break;
case HeroClass::Rogue:
textdef = TEXT_RBONER; textdef = TEXT_RBONER;
} else if (plr[myplr]._pClass == HeroClass::Sorcerer) { break;
case HeroClass::Sorcerer:
textdef = TEXT_MBONER; textdef = TEXT_MBONER;
} else if (plr[myplr]._pClass == HeroClass::Monk) { break;
case HeroClass::Monk:
textdef = TEXT_HBONER; textdef = TEXT_HBONER;
} else if (plr[myplr]._pClass == HeroClass::Bard) { break;
case HeroClass::Bard:
textdef = TEXT_BBONER; textdef = TEXT_BBONER;
} else if (plr[myplr]._pClass == HeroClass::Barbarian) { break;
case HeroClass::Barbarian:
textdef = TEXT_BONER; textdef = TEXT_BONER;
break;
} }
quests[Q_SCHAMB]._qmsg = textdef; quests[Q_SCHAMB]._qmsg = textdef;
InitQTextMsg(textdef); InitQTextMsg(textdef);
@ -4829,7 +4861,7 @@ void OperateStoryBook(int pnum, int i)
} else if (currlevel >= 21) { } else if (currlevel >= 21) {
quests[Q_NAKRUL]._qactive = QUEST_ACTIVE; quests[Q_NAKRUL]._qactive = QUEST_ACTIVE;
quests[Q_NAKRUL]._qlog = 1; quests[Q_NAKRUL]._qlog = 1;
quests[Q_NAKRUL]._qmsg = object[i]._oVar2; quests[Q_NAKRUL]._qmsg = static_cast<_speech_id>(object[i]._oVar2);
} }
InitQTextMsg(object[i]._oVar2); InitQTextMsg(object[i]._oVar2);
NetSendCmdParam1(false, CMD_OPERATEOBJ, i); NetSendCmdParam1(false, CMD_OPERATEOBJ, i);

2
Source/palette.cpp

@ -106,7 +106,7 @@ static void GenerateBlendedLookupTable(SDL_Color *palette, int skipFrom, int ski
int diffr = palette[k].r - r; int diffr = palette[k].r - r;
int diffg = palette[k].g - g; int diffg = palette[k].g - g;
int diffb = palette[k].b - b; int diffb = palette[k].b - b;
int diff = diffr * diffr + diffg * diffg + diffb * diffb; Uint32 diff = diffr * diffr + diffg * diffg + diffb * diffb;
if (bestDiff > diff) { if (bestDiff > diff) {
best = k; best = k;

6
Source/pfile.cpp

@ -54,7 +54,7 @@ std::string GetSavePath(DWORD save_num)
return path; return path;
} }
bool GetPermSaveNames(DWORD dwIndex, char *szPerm) bool GetPermSaveNames(uint8_t dwIndex, char *szPerm)
{ {
const char *fmt; const char *fmt;
@ -70,7 +70,7 @@ bool GetPermSaveNames(DWORD dwIndex, char *szPerm)
return true; return true;
} }
bool GetTempSaveNames(DWORD dwIndex, char *szTemp) bool GetTempSaveNames(uint8_t dwIndex, char *szTemp)
{ {
const char *fmt; const char *fmt;
@ -365,7 +365,7 @@ bool pfile_ui_save_create(_uiheroinfo *heroinfo)
return true; return true;
} }
bool pfile_get_file_name(DWORD lvl, char *dst) bool pfile_get_file_name(uint8_t lvl, char *dst)
{ {
const char *fmt; const char *fmt;

2
Source/pfile.h

@ -34,7 +34,7 @@ bool pfile_ui_set_hero_infos(bool (*ui_add_hero_info)(_uiheroinfo *));
bool pfile_archive_contains_game(HANDLE hsArchive, DWORD save_num); bool pfile_archive_contains_game(HANDLE hsArchive, DWORD save_num);
void pfile_ui_set_class_stats(unsigned int player_class_nr, _uidefaultstats *class_stats); void pfile_ui_set_class_stats(unsigned int player_class_nr, _uidefaultstats *class_stats);
bool pfile_ui_save_create(_uiheroinfo *heroinfo); bool pfile_ui_save_create(_uiheroinfo *heroinfo);
bool pfile_get_file_name(DWORD lvl, char *dst); bool pfile_get_file_name(uint8_t lvl, char *dst);
bool pfile_delete_save(_uiheroinfo *hero_info); bool pfile_delete_save(_uiheroinfo *hero_info);
void pfile_read_player_from_save(); void pfile_read_player_from_save();
bool LevelFileExists(); bool LevelFileExists();

15
Source/player.cpp

@ -645,7 +645,6 @@ void SetPlrAnims(int pnum)
void CreatePlayer(int pnum, HeroClass c) void CreatePlayer(int pnum, HeroClass c)
{ {
char val; char val;
int i;
memset(&plr[pnum], 0, sizeof(PlayerStruct)); memset(&plr[pnum], 0, sizeof(PlayerStruct));
SetRndSeed(SDL_GetTicks()); SetRndSeed(SDL_GetTicks());
@ -761,7 +760,7 @@ void CreatePlayer(int pnum, HeroClass c)
plr[pnum]._pMemSpells = 0; plr[pnum]._pMemSpells = 0;
} }
for (i = 0; i < sizeof(plr[pnum]._pSplLvl) / sizeof(plr[pnum]._pSplLvl[0]); i++) { for (size_t i = 0; i < sizeof(plr[pnum]._pSplLvl) / sizeof(plr[pnum]._pSplLvl[0]); i++) {
plr[pnum]._pSplLvl[i] = 0; plr[pnum]._pSplLvl[i] = 0;
} }
@ -773,7 +772,7 @@ void CreatePlayer(int pnum, HeroClass c)
// interestingly, only the first three hotkeys are reset // interestingly, only the first three hotkeys are reset
// TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover) // TODO: BUGFIX: clear all 4 hotkeys instead of 3 (demo leftover)
for (i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
plr[pnum]._pSplHotKey[i] = SPL_INVALID; plr[pnum]._pSplHotKey[i] = SPL_INVALID;
} }
@ -791,11 +790,11 @@ void CreatePlayer(int pnum, HeroClass c)
plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD; plr[pnum]._pgfxnum = ANIM_ID_SWORD_SHIELD;
} }
for (i = 0; i < NUMLEVELS; i++) { for (int i = 0; i < NUMLEVELS; i++) {
plr[pnum]._pLvlVisited[i] = false; plr[pnum]._pLvlVisited[i] = false;
} }
for (i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
plr[pnum]._pSLvlVisited[i] = false; plr[pnum]._pSLvlVisited[i] = false;
} }
@ -2639,7 +2638,7 @@ bool PlrHitMonst(int pnum, int m)
return rv; return rv;
} }
bool PlrHitPlr(int pnum, char p) bool PlrHitPlr(int pnum, int8_t p)
{ {
bool rv; bool rv;
int hit, hper, blk, blkper, mind, maxd, dam, lvl, skdam, tac; int hit, hper, blk, blkper, mind, maxd, dam, lvl, skdam, tac;
@ -3750,8 +3749,7 @@ void ClrPlrPath(int pnum)
bool PosOkPlayer(int pnum, int x, int y) bool PosOkPlayer(int pnum, int x, int y)
{ {
DWORD p; int8_t p, bv;
char bv;
if (x < 0 || x >= MAXDUNX || y < 0 || y >= MAXDUNY) if (x < 0 || x >= MAXDUNX || y < 0 || y >= MAXDUNY)
return false; return false;
@ -3766,6 +3764,7 @@ bool PosOkPlayer(int pnum, int x, int y)
p = -(dPlayer[x][y] + 1); p = -(dPlayer[x][y] + 1);
} }
if (p != pnum if (p != pnum
&& p >= 0
&& p < MAX_PLRS && p < MAX_PLRS
&& plr[p]._pHitPoints != 0) { && plr[p]._pHitPoints != 0) {
return false; return false;

2
Source/player.h

@ -311,7 +311,7 @@ struct PlayerStruct {
Uint8 pDungMsgs2; Uint8 pDungMsgs2;
bool pOriginalCathedral; bool pOriginalCathedral;
Uint16 wReflections; Uint16 wReflections;
Uint32 pDiabloKillLevel; uint32_t pDiabloKillLevel;
_difficulty pDifficulty; _difficulty pDifficulty;
Uint32 pDamAcFlags; Uint32 pDamAcFlags;
Uint8 *_pNData; Uint8 *_pNData;

5
Source/quests.h

@ -9,6 +9,7 @@
#include "engine.h" #include "engine.h"
#include "gendung.h" #include "gendung.h"
#include "textdat.h"
namespace devilution { namespace devilution {
@ -47,7 +48,7 @@ struct QuestStruct {
Sint32 _qty; Sint32 _qty;
_setlevels _qslvl; _setlevels _qslvl;
Uint8 _qidx; Uint8 _qidx;
Sint32 _qmsg; _speech_id _qmsg;
Uint8 _qvar1; Uint8 _qvar1;
Uint8 _qvar2; Uint8 _qvar2;
bool _qlog; bool _qlog;
@ -61,7 +62,7 @@ struct QuestData {
Uint8 _qdrnd; Uint8 _qdrnd;
_setlevels _qslvl; _setlevels _qslvl;
bool isSinglePlayerOnly; bool isSinglePlayerOnly;
Sint32 _qdmsg; _speech_id _qdmsg;
const char *_qlstr; const char *_qlstr;
}; };

10
Source/render.cpp

@ -379,7 +379,7 @@ void foreach_set_bit(DWORD mask, const F &f)
} }
} }
inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask) inline void DoRenderLine(BYTE *dst, BYTE *src, size_t n, BYTE *tbl, DWORD mask)
{ {
if (mask == 0xFFFFFFFF) { // Opaque line if (mask == 0xFFFFFFFF) { // Opaque line
if (light_table_index == lightmax) { // Complete darkness if (light_table_index == lightmax) { // Complete darkness
@ -387,7 +387,7 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask)
} else if (light_table_index == 0) { // Fully lit } else if (light_table_index == 0) { // Fully lit
memcpy(dst, src, n); memcpy(dst, src, n);
} else { // Partially lit } else { // Partially lit
for (int i = 0; i < n; i++) { for (size_t i = 0; i < n; i++) {
dst[i] = tbl[src[i]]; dst[i] = tbl[src[i]];
} }
} }
@ -401,21 +401,21 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask)
if (sgOptions.Graphics.bBlendedTransparancy) { // Blended transparancy if (sgOptions.Graphics.bBlendedTransparancy) { // Blended transparancy
if (light_table_index == lightmax) { // Complete darkness if (light_table_index == lightmax) { // Complete darkness
for (int i = 0; i < n; i++, mask <<= 1) { for (size_t i = 0; i < n; i++, mask <<= 1) {
if (mask & 0x80000000) if (mask & 0x80000000)
dst[i] = 0; dst[i] = 0;
else else
dst[i] = paletteTransparencyLookup[0][dst[i]]; dst[i] = paletteTransparencyLookup[0][dst[i]];
} }
} else if (light_table_index == 0) { // Fully lit } else if (light_table_index == 0) { // Fully lit
for (int i = 0; i < n; i++, mask <<= 1) { for (size_t i = 0; i < n; i++, mask <<= 1) {
if (mask & 0x80000000) if (mask & 0x80000000)
dst[i] = src[i]; dst[i] = src[i];
else else
dst[i] = paletteTransparencyLookup[dst[i]][src[i]]; dst[i] = paletteTransparencyLookup[dst[i]][src[i]];
} }
} else { // Partially lit } else { // Partially lit
for (int i = 0; i < n; i++, mask <<= 1) { for (size_t i = 0; i < n; i++, mask <<= 1) {
if (mask & 0x80000000) if (mask & 0x80000000)
dst[i] = tbl[src[i]]; dst[i] = tbl[src[i]];
else else

32
Source/scrollrt.cpp

@ -40,7 +40,7 @@ int sgdwCursY;
/** /**
* Lower bound of back buffer. * Lower bound of back buffer.
*/ */
DWORD sgdwCursHgt; uint32_t sgdwCursHgt;
/** /**
* Specifies the current MIN block of the level CEL file, as used during rendering of the level tiles. * Specifies the current MIN block of the level CEL file, as used during rendering of the level tiles.
@ -68,10 +68,10 @@ int cel_foliage_active = false;
* Specifies the current dungeon piece ID of the level, as used during rendering of the level tiles. * Specifies the current dungeon piece ID of the level, as used during rendering of the level tiles.
*/ */
int level_piece_id; int level_piece_id;
DWORD sgdwCursWdt; uint32_t sgdwCursWdt;
void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int); void (*DrawPlrProc)(int, int, int, int, int, BYTE *, int, int, int, int);
BYTE sgSaveBack[8192]; BYTE sgSaveBack[8192];
DWORD sgdwCursHgtOld; uint32_t sgdwCursHgtOld;
bool dRendered[MAXDUNX][MAXDUNY]; bool dRendered[MAXDUNX][MAXDUNY];
@ -130,7 +130,7 @@ void ClearCursor() // CODE_FIX: this was supposed to be in cursor.cpp
static void BlitCursor(BYTE *dst, int dst_pitch, BYTE *src, int src_pitch) static void BlitCursor(BYTE *dst, int dst_pitch, BYTE *src, int src_pitch)
{ {
for (int i = 0; i < sgdwCursHgt; ++i, src += src_pitch, dst += dst_pitch) { for (uint32_t i = 0; i < sgdwCursHgt; ++i, src += src_pitch, dst += dst_pitch) {
memcpy(dst, src, sgdwCursWdt); memcpy(dst, src, sgdwCursWdt);
} }
} }
@ -185,20 +185,14 @@ static void scrollrt_draw_cursor_item(CelOutputBuffer out)
} }
sgdwCursX = mx; sgdwCursX = mx;
sgdwCursWdt = sgdwCursX + cursW + 1; sgdwCursWdt = std::min(sgdwCursX + cursW + 1, gnScreenWidth - 1);
if (sgdwCursWdt > gnScreenWidth - 1) {
sgdwCursWdt = gnScreenWidth - 1;
}
sgdwCursX &= ~3; sgdwCursX &= ~3;
sgdwCursWdt |= 3; sgdwCursWdt |= 3;
sgdwCursWdt -= sgdwCursX; sgdwCursWdt -= sgdwCursX;
sgdwCursWdt++; sgdwCursWdt++;
sgdwCursY = my; sgdwCursY = my;
sgdwCursHgt = sgdwCursY + cursH + 1; sgdwCursHgt = std::min(sgdwCursY + cursH + 1, gnScreenHeight - 1);
if (sgdwCursHgt > gnScreenHeight - 1) {
sgdwCursHgt = gnScreenHeight - 1;
}
sgdwCursHgt -= sgdwCursY; sgdwCursHgt -= sgdwCursY;
sgdwCursHgt++; sgdwCursHgt++;
@ -511,7 +505,7 @@ static void DrawObject(CelOutputBuffer out, int x, int y, int ox, int oy, bool p
return; return;
int sx, sy; int sx, sy;
char bv; int8_t bv;
if (dObject[x][y] > 0) { if (dObject[x][y] > 0) {
bv = dObject[x][y] - 1; bv = dObject[x][y] - 1;
if (object[bv]._oPreFlag != pre) if (object[bv]._oPreFlag != pre)
@ -620,11 +614,9 @@ static void drawFloor(CelOutputBuffer out, int x, int y, int sx, int sy)
*/ */
static void DrawItem(CelOutputBuffer out, int x, int y, int sx, int sy, bool pre) static void DrawItem(CelOutputBuffer out, int x, int y, int sx, int sy, bool pre)
{ {
char bItem = dItem[x][y]; int8_t bItem = dItem[x][y];
assert((unsigned char)bItem <= MAXITEMS);
if (bItem > MAXITEMS || bItem <= 0) if (bItem <= 0)
return; return;
ItemStruct *pItem = &items[bItem - 1]; ItemStruct *pItem = &items[bItem - 1];
@ -750,9 +742,9 @@ static void scrollrt_draw_dungeon(CelOutputBuffer out, int sx, int sy, int dx, i
drawCell(out, sx, sy, dx, dy); drawCell(out, sx, sy, dx, dy);
char bFlag = dFlags[sx][sy]; int8_t bFlag = dFlags[sx][sy];
char bDead = dDead[sx][sy]; int8_t bDead = dDead[sx][sy];
char bMap = dTransVal[sx][sy]; int8_t bMap = dTransVal[sx][sy];
int negMon = 0; int negMon = 0;
if (sy > 0) // check for OOB if (sy > 0) // check for OOB

1
Source/stores.cpp

@ -2559,7 +2559,6 @@ void STextPrior()
if (stextsel == stextup) { if (stextsel == stextup) {
if (stextsval) if (stextsval)
stextsval -= 4; stextsval -= 4;
stextsval = stextsval;
if (stextsval < 0) if (stextsval < 0)
stextsval = 0; stextsval = 0;
} else { } else {

10
Source/themes.cpp

@ -407,8 +407,6 @@ bool CheckThemeRoom(int tv)
void InitThemes() void InitThemes()
{ {
int i;
zharlib = -1; zharlib = -1;
numthemes = 0; numthemes = 0;
armorFlag = true; armorFlag = true;
@ -425,10 +423,10 @@ void InitThemes()
return; return;
if (leveltype == DTYPE_CATHEDRAL) { if (leveltype == DTYPE_CATHEDRAL) {
for (i = 0; i < sizeof(ThemeGoodIn) / sizeof(ThemeGoodIn[0]); i++) for (size_t i = 0; i < sizeof(ThemeGoodIn) / sizeof(ThemeGoodIn[0]); i++)
ThemeGoodIn[i] = false; ThemeGoodIn[i] = false;
for (i = 0; i < 256 && numthemes < MAXTHEMES; i++) { for (size_t i = 0; i < 256 && numthemes < MAXTHEMES; i++) {
if (CheckThemeRoom(i)) { if (CheckThemeRoom(i)) {
themes[numthemes].ttval = i; themes[numthemes].ttval = i;
theme_id j = ThemeGood[random_(0, 4)]; theme_id j = ThemeGood[random_(0, 4)];
@ -441,7 +439,7 @@ void InitThemes()
} }
} }
if (leveltype == DTYPE_CATACOMBS || leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) { if (leveltype == DTYPE_CATACOMBS || leveltype == DTYPE_CAVES || leveltype == DTYPE_HELL) {
for (i = 0; i < themeCount; i++) for (int i = 0; i < themeCount; i++)
themes[i].ttype = THEME_NONE; themes[i].ttype = THEME_NONE;
if (QuestStatus(Q_ZHAR)) { if (QuestStatus(Q_ZHAR)) {
for (int j = 0; j < themeCount; j++) { for (int j = 0; j < themeCount; j++) {
@ -453,7 +451,7 @@ void InitThemes()
} }
} }
} }
for (i = 0; i < themeCount; i++) { for (int i = 0; i < themeCount; i++) {
if (themes[i].ttype == THEME_NONE) { if (themes[i].ttype == THEME_NONE) {
themes[i].ttval = themeLoc[i].ttval; themes[i].ttval = themeLoc[i].ttval;
theme_id j = ThemeGood[random_(0, 4)]; theme_id j = ThemeGood[random_(0, 4)];

4
Source/trigs.cpp

@ -63,8 +63,6 @@ void InitNoTriggers()
void InitTownTriggers() void InitTownTriggers()
{ {
int i;
numtrigs = 0; numtrigs = 0;
trigs[numtrigs]._tx = 25; trigs[numtrigs]._tx = 25;
@ -72,7 +70,7 @@ void InitTownTriggers()
trigs[numtrigs]._tmsg = WM_DIABNEXTLVL; trigs[numtrigs]._tmsg = WM_DIABNEXTLVL;
numtrigs++; numtrigs++;
for (i = 0; i < sizeof(townwarps) / sizeof(townwarps[0]); i++) { for (size_t i = 0; i < sizeof(townwarps) / sizeof(townwarps[0]); i++) {
townwarps[i] = gbIsMultiplayer && !gbIsSpawn; townwarps[i] = gbIsMultiplayer && !gbIsSpawn;
} }
if (!gbIsSpawn) { if (!gbIsSpawn) {

Loading…
Cancel
Save