From 4eabc6024b953662325e94e8135a417b75a870e9 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 4 Jul 2021 03:04:01 +0200 Subject: [PATCH] Apply various cleanups via Android Studio --- Source/DiabloUI/credits.cpp | 2 +- Source/DiabloUI/diabloui.cpp | 2 +- Source/capture.cpp | 3 ++- Source/codec.cpp | 30 +++++++++++++++--------------- Source/control.cpp | 22 +++++++++++----------- Source/controls/plrctrls.cpp | 2 +- Source/controls/touch.cpp | 4 ++-- Source/dead.cpp | 24 ++++++++++++------------ Source/dead.h | 6 +++--- Source/debug.cpp | 36 ++++++++++++++++++------------------ Source/diablo.cpp | 14 +++++++------- Source/dthread.cpp | 2 +- Source/dthread.h | 2 +- Source/dx.cpp | 10 +++++----- Source/gendung.cpp | 4 ---- Source/gendung.h | 4 ---- Source/help.cpp | 6 +++--- Source/help.h | 2 +- Source/hwcursor.cpp | 2 +- Source/init.cpp | 1 - Source/inv.cpp | 26 ++++++++++++-------------- Source/inv.h | 2 -- Source/multi.cpp | 2 +- Source/palette.cpp | 4 ++-- Source/scrollrt.cpp | 12 ++++++------ Source/utils/display.h | 2 +- 26 files changed, 107 insertions(+), 119 deletions(-) diff --git a/Source/DiabloUI/credits.cpp b/Source/DiabloUI/credits.cpp index e5c4a1613..295ea4e0d 100644 --- a/Source/DiabloUI/credits.cpp +++ b/Source/DiabloUI/credits.cpp @@ -79,7 +79,7 @@ CachedLine PrepareLine(std::size_t index) // Set up the target surface to have 3 colors: mask, text, and shadow. surface = SDLSurfaceUniquePtr { SDL_CreateRGBSurfaceWithFormat(0, text->w + ShadowOffsetX, text->h + ShadowOffsetY, 8, SDL_PIXELFORMAT_INDEX8) }; const SDL_Color maskColor = { 0, 255, 0, 0 }; // Any color different from both shadow and text - const SDL_Color &textColor = palette->colors[224]; + const SDL_Color &textColor = Palette->colors[224]; SDL_Color colors[3] = { maskColor, textColor, shadowColor }; if (SDLC_SetSurfaceColors(surface.get(), colors, 0, 3) <= -1) Log("{}", SDL_GetError()); diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 7c7ba6606..629f73587 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -609,7 +609,7 @@ void LoadBackgroundArt(const char *pszFile, int frames) if (IsHardwareCursorEnabled() && ArtCursor.surface != nullptr && GetCurrentCursorInfo().type() != CursorType::UserInterface) { #if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_SetSurfacePalette(ArtCursor.surface.get(), palette); + SDL_SetSurfacePalette(ArtCursor.surface.get(), Palette); SDL_SetColorKey(ArtCursor.surface.get(), 1, 0); #endif SetHardwareCursor(CursorInfo::UserInterfaceCursor()); diff --git a/Source/capture.cpp b/Source/capture.cpp index fac4143df..e94ffa5e2 100644 --- a/Source/capture.cpp +++ b/Source/capture.cpp @@ -3,6 +3,7 @@ * * Implementation of the screenshot function. */ +#include #include #include "DiabloUI/diabloui.h" @@ -23,7 +24,7 @@ namespace devilution { * @param out File stream to write to * @return True on success */ -static bool CaptureHdr(short width, short height, std::ofstream *out) +static bool CaptureHdr(int16_t width, int16_t height, std::ofstream *out) { PCXHeader buffer; diff --git a/Source/codec.cpp b/Source/codec.cpp index ad0a573d7..12b97198d 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -20,7 +20,7 @@ struct CodecSignature { uint16_t unused; }; -#define BLOCKSIZE 64 +#define BlockSize 64 static void CodecInitKey(const char *pszPassword) { @@ -65,17 +65,17 @@ std::size_t codec_decode(byte *pbSrcDst, std::size_t size, const char *pszPasswo if (size <= sizeof(CodecSignature)) return 0; size -= sizeof(CodecSignature); - if (size % BLOCKSIZE != 0) + if (size % BlockSize != 0) return 0; - for (i = size; i != 0; pbSrcDst += BLOCKSIZE, i -= BLOCKSIZE) { - memcpy(buf, pbSrcDst, BLOCKSIZE); + for (i = size; i != 0; pbSrcDst += BlockSize, i -= BlockSize) { + memcpy(buf, pbSrcDst, BlockSize); SHA1Result(0, dst); - for (int j = 0; j < BLOCKSIZE; j++) { + for (int j = 0; j < BlockSize; j++) { buf[j] ^= dst[j % SHA1HashSize]; } SHA1Calculate(0, buf, nullptr); memset(dst, 0, sizeof(dst)); - memcpy(pbSrcDst, buf, BLOCKSIZE); + memcpy(pbSrcDst, buf, BlockSize); } memset(buf, 0, sizeof(buf)); @@ -90,7 +90,7 @@ std::size_t codec_decode(byte *pbSrcDst, std::size_t size, const char *pszPasswo goto error; } - size += sig->lastChunkSize - BLOCKSIZE; + size += sig->lastChunkSize - BlockSize; SHA1Clear(); return size; error: @@ -100,8 +100,8 @@ error: std::size_t codec_get_encoded_len(std::size_t dwSrcBytes) { - if (dwSrcBytes % BLOCKSIZE != 0) - dwSrcBytes += BLOCKSIZE - (dwSrcBytes % BLOCKSIZE); + if (dwSrcBytes % BlockSize != 0) + dwSrcBytes += BlockSize - (dwSrcBytes % BlockSize); return dwSrcBytes + sizeof(CodecSignature); } @@ -117,19 +117,19 @@ void codec_encode(byte *pbSrcDst, std::size_t size, std::size_t size64, const ch uint16_t lastChunk = 0; while (size != 0) { - uint16_t chunk = size < BLOCKSIZE ? size : BLOCKSIZE; + uint16_t chunk = size < BlockSize ? size : BlockSize; memcpy(buf, pbSrcDst, chunk); - if (chunk < BLOCKSIZE) - memset(buf + chunk, 0, BLOCKSIZE - chunk); + if (chunk < BlockSize) + memset(buf + chunk, 0, BlockSize - chunk); SHA1Result(0, dst); SHA1Calculate(0, buf, nullptr); - for (int j = 0; j < BLOCKSIZE; j++) { + for (int j = 0; j < BlockSize; j++) { buf[j] ^= dst[j % SHA1HashSize]; } memset(dst, 0, sizeof(dst)); - memcpy(pbSrcDst, buf, BLOCKSIZE); + memcpy(pbSrcDst, buf, BlockSize); lastChunk = chunk; - pbSrcDst += BLOCKSIZE; + pbSrcDst += BlockSize; size -= chunk; } memset(buf, 0, sizeof(buf)); diff --git a/Source/control.cpp b/Source/control.cpp index 38b116a54..a26e4339c 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -36,10 +36,10 @@ namespace { Surface pBtmBuff; Surface pLifeBuff; Surface pManaBuff; -std::optional pTalkBtns; +std::optional talkButtons; std::optional pDurIcons; std::optional pChrButtons; -std::optional pMultiBtns; +std::optional multiButtons; std::optional pPanelButtons; std::optional pChrPanel; std::optional pGBoxBuff; @@ -674,8 +674,8 @@ void InitControlPan() talkflag = false; if (gbIsMultiplayer) { CelDrawUnsafeTo(pBtmBuff, { 0, (PANEL_HEIGHT + 16) * 2 - 1 }, LoadCel("CtrlPan\\TalkPanl.CEL", PANEL_WIDTH), 1); - pMultiBtns = LoadCel("CtrlPan\\P8But2.CEL", 33); - pTalkBtns = LoadCel("CtrlPan\\TalkButt.CEL", 61); + multiButtons = LoadCel("CtrlPan\\P8But2.CEL", 33); + talkButtons = LoadCel("CtrlPan\\TalkButt.CEL", 61); sgbPlrTalkTbl = 0; sgszTalkMsg[0] = '\0'; for (bool &whisper : whisperList) @@ -754,11 +754,11 @@ void DrawCtrlBtns(const Surface &out) CelDrawTo(out, { PanBtnPos[i].x + PANEL_X, PanBtnPos[i].y + PANEL_Y + 18 }, *pPanelButtons, i + 1); } if (numpanbtns == 8) { - CelDrawTo(out, { 87 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[6] ? 2 : 1); + CelDrawTo(out, { 87 + PANEL_X, 122 + PANEL_Y }, *multiButtons, panbtns[6] ? 2 : 1); if (gbFriendlyMode) - CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[7] ? 4 : 3); + CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *multiButtons, panbtns[7] ? 4 : 3); else - CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *pMultiBtns, panbtns[7] ? 6 : 5); + CelDrawTo(out, { 527 + PANEL_X, 122 + PANEL_Y }, *multiButtons, panbtns[7] ? 6 : 5); } } @@ -1069,8 +1069,8 @@ void FreeControlPan() pChrPanel = std::nullopt; pSpellCels = std::nullopt; pPanelButtons = std::nullopt; - pMultiBtns = std::nullopt; - pTalkBtns = std::nullopt; + multiButtons = std::nullopt; + talkButtons = std::nullopt; pChrButtons = std::nullopt; pDurIcons = std::nullopt; pQLogCel = std::nullopt; @@ -1806,13 +1806,13 @@ void DrawTalkPan(const Surface &out) color = UIS_GOLD; if (talkButtonsDown[talkBtn]) { int nCel = talkBtn != 0 ? 4 : 3; - CelDrawTo(out, talkPanPosition, *pTalkBtns, nCel); + CelDrawTo(out, talkPanPosition, *talkButtons, nCel); } } else { int nCel = talkBtn != 0 ? 2 : 1; if (talkButtonsDown[talkBtn]) nCel += 4; - CelDrawTo(out, talkPanPosition, *pTalkBtns, nCel); + CelDrawTo(out, talkPanPosition, *talkButtons, nCel); } auto &player = plr[i]; if (player.plractive) { diff --git a/Source/controls/plrctrls.cpp b/Source/controls/plrctrls.cpp index 03a29bb14..64a80f04c 100644 --- a/Source/controls/plrctrls.cpp +++ b/Source/controls/plrctrls.cpp @@ -35,7 +35,7 @@ int speedspellcount = 0; bool InGameMenu() { return stextflag != STORE_NONE - || helpflag + || HelpFlag || talkflag || qtextflag || gmenu_is_active() diff --git a/Source/controls/touch.cpp b/Source/controls/touch.cpp index 7f3b81c25..fba56f682 100644 --- a/Source/controls/touch.cpp +++ b/Source/controls/touch.cpp @@ -55,8 +55,8 @@ enum { struct Touch { int id; // -1: not touching uint32_t timeLastDown; - int lastX; // last known screen coordinates - int lastY; // last known screen coordinates + int lastX; // last known screen coordinates + int lastY; // last known screen coordinates float lastDownX; // SDL touch coordinates when last pressed down float lastDownY; // SDL touch coordinates when last pressed down }; diff --git a/Source/dead.cpp b/Source/dead.cpp index cddf28399..06f06fb7c 100644 --- a/Source/dead.cpp +++ b/Source/dead.cpp @@ -16,13 +16,13 @@ DeadStruct dead[MaxDead]; int8_t stonendx; namespace { -void InitDeadAnimationFromMonster(DeadStruct &d, const CMonster &mon) +void InitDeadAnimationFromMonster(DeadStruct &dead, const CMonster &mon) { int i = 0; for (const auto &celSprite : mon.Anims[MA_DEATH].CelSpritesForDirections) - d._deadData[i++] = celSprite->Data(); - d._deadFrame = mon.Anims[MA_DEATH].Frames; - d._deadWidth = mon.Anims[MA_DEATH].CelSpritesForDirections[0]->Width(); + dead.data[i++] = celSprite->Data(); + dead.frame = mon.Anims[MA_DEATH].Frames; + dead.width = mon.Anims[MA_DEATH].CelSpritesForDirections[0]->Width(); } } // namespace @@ -44,18 +44,18 @@ void InitDead() mtypes[Monsters[i].mtype] = nd; } - for (auto &d : dead[nd]._deadData) - d = misfiledata[MFILE_BLODBUR].mAnimData[0]; - dead[nd]._deadFrame = 8; - dead[nd]._deadWidth = 128; + for (auto &dead : dead[nd].data) + dead = misfiledata[MFILE_BLODBUR].mAnimData[0]; + dead[nd].frame = 8; + dead[nd].width = 128; dead[nd]._deadtrans = 0; nd++; - for (auto &d : dead[nd]._deadData) - d = misfiledata[MFILE_SHATTER1].mAnimData[0]; + for (auto &dead : dead[nd].data) + dead = misfiledata[MFILE_SHATTER1].mAnimData[0]; - dead[nd]._deadFrame = 12; - dead[nd]._deadWidth = 128; + dead[nd].frame = 12; + dead[nd].width = 128; dead[nd]._deadtrans = 0; nd++; diff --git a/Source/dead.h b/Source/dead.h index e9684e918..8f7b7a946 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -16,9 +16,9 @@ namespace devilution { static constexpr unsigned MaxDead = 31; struct DeadStruct { - std::array _deadData; - int _deadFrame; - int _deadWidth; + std::array data; + int frame; + int width; uint8_t _deadtrans; }; diff --git a/Source/debug.cpp b/Source/debug.cpp index 7e7c0859e..97e072649 100644 --- a/Source/debug.cpp +++ b/Source/debug.cpp @@ -16,10 +16,10 @@ namespace devilution { #ifdef _DEBUG -#define DEBUGSEEDS 4096 +#define DebugSeeds 4096 int seed_index; int level_seeds[NUMLEVELS + 1]; -int seed_table[DEBUGSEEDS]; +int seed_table[DebugSeeds]; std::optional pSquareCel; char dMonsDbg[NUMLEVELS][MAXDUNX][MAXDUNY]; @@ -133,22 +133,22 @@ void SetAllSpellsCheat() SetSpellLevelCheat(SPL_BONESPIRIT, 1); } -int dbgplr; +int DebugPlayerId; void PrintDebugPlayer(bool bNextPlayer) { char dstr[128]; if (bNextPlayer) - dbgplr = ((BYTE)dbgplr + 1) & 3; + DebugPlayerId = ((BYTE)DebugPlayerId + 1) & 3; - auto &player = plr[dbgplr]; + auto &player = plr[DebugPlayerId]; - sprintf(dstr, "Plr %i : Active = %i", dbgplr, player.plractive ? 1 : 0); + sprintf(dstr, "Plr %i : Active = %i", DebugPlayerId, player.plractive ? 1 : 0); NetSendCmdString(1 << myplr, dstr); if (player.plractive) { - sprintf(dstr, " Plr %i is %s", dbgplr, player._pName); + sprintf(dstr, " Plr %i is %s", DebugPlayerId, player._pName); NetSendCmdString(1 << myplr, dstr); sprintf(dstr, " Lvl = %i : Change = %i", player.plrlevel, player._pLvlChanging ? 1 : 0); NetSendCmdString(1 << myplr, dstr); @@ -162,18 +162,18 @@ void PrintDebugPlayer(bool bNextPlayer) } } -int dbgqst; +int DebugQuestId; void PrintDebugQuest() { char dstr[128]; - sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", dbgqst, quests[dbgqst]._qactive, quests[dbgqst]._qvar1); + sprintf(dstr, "Quest %i : Active = %i, Var1 = %i", DebugQuestId, quests[DebugQuestId]._qactive, quests[DebugQuestId]._qvar1); NetSendCmdString(1 << myplr, dstr); - dbgqst++; - if (dbgqst == MAXQUESTS) - dbgqst = 0; + DebugQuestId++; + if (DebugQuestId == MAXQUESTS) + DebugQuestId = 0; } void PrintDebugMonster(int m) @@ -202,7 +202,7 @@ void PrintDebugMonster(int m) NetSendCmdString(1 << myplr, dstr); } -int dbgmon; +int DebugMonsterId; void GetDebugMonster() { @@ -214,7 +214,7 @@ void GetDebugMonster() if (mi2 <= 0) mi1 = -(mi2 + 1); } else { - mi1 = dbgmon; + mi1 = DebugMonsterId; } } PrintDebugMonster(mi1); @@ -224,11 +224,11 @@ void NextDebugMonster() { char dstr[128]; - dbgmon++; - if (dbgmon == MAXMONSTERS) - dbgmon = 0; + DebugMonsterId++; + if (DebugMonsterId == MAXMONSTERS) + DebugMonsterId = 0; - sprintf(dstr, "Current debug monster = %i", dbgmon); + sprintf(dstr, "Current debug monster = %i", DebugMonsterId); NetSendCmdString(1 << myplr, dstr); } diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 48190e25e..bf030936e 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -916,8 +916,8 @@ bool PressEscKey() rv = true; } - if (helpflag) { - helpflag = false; + if (HelpFlag) { + HelpFlag = false; rv = true; } @@ -1022,7 +1022,7 @@ static void PressKey(int vkey) StoreUp(); } else if (questlog) { QuestlogUp(); - } else if (helpflag) { + } else if (HelpFlag) { HelpScrollUp(); } else if (AutomapActive) { AutomapUp(); @@ -1032,7 +1032,7 @@ static void PressKey(int vkey) StoreDown(); } else if (questlog) { QuestlogDown(); - } else if (helpflag) { + } else if (HelpFlag) { HelpScrollDown(); } else if (AutomapActive) { AutomapDown(); @@ -1057,7 +1057,7 @@ static void PressKey(int vkey) DoAutoMap(); } else if (vkey == DVL_VK_SPACE) { ClosePanels(); - helpflag = false; + HelpFlag = false; spselflag = false; if (qtextflag && leveltype == DTYPE_TOWN) { qtextflag = false; @@ -1814,8 +1814,8 @@ void diablo_color_cyc_logic() void helpKeyPressed() { - if (helpflag) { - helpflag = false; + if (HelpFlag) { + HelpFlag = false; } else if (stextflag != STORE_NONE) { ClearPanel(); AddPanelString(_("No help available")); /// BUGFIX: message isn't displayed diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 6d4393d83..feb0b2c1a 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -118,7 +118,7 @@ void dthread_start() } } -void dthread_cleanup() +void DThreadCleanup() { TMegaPkt *tmp; diff --git a/Source/dthread.h b/Source/dthread.h index a78c057a3..d6a5f573d 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -10,6 +10,6 @@ namespace devilution { void dthread_remove_player(uint8_t pnum); void dthread_send_delta(int pnum, _cmd_id cmd, byte *pbSrc, int dwLen); void dthread_start(); -void dthread_cleanup(); +void DThreadCleanup(); } // namespace devilution diff --git a/Source/dx.cpp b/Source/dx.cpp index 658f27393..eac781862 100644 --- a/Source/dx.cpp +++ b/Source/dx.cpp @@ -30,7 +30,7 @@ SDL_Renderer *renderer; SDL_Texture *texture; /** Currently active palette */ -SDL_Palette *palette; +SDL_Palette *Palette; unsigned int pal_surface_palette_version = 0; /** 24-bit renderer texture surface */ @@ -82,7 +82,7 @@ static void CreateBackBuffer() #ifndef USE_SDL1 // In SDL2, `pal_surface` points to the global `palette`. - if (SDL_SetSurfacePalette(pal_surface, palette) < 0) + if (SDL_SetSurfacePalette(pal_surface, Palette) < 0) ErrSdl(); #else // In SDL1, `pal_surface` owns its palette and we must update it every @@ -184,7 +184,7 @@ void dx_cleanup() return; SDL_FreeSurface(pal_surface); pal_surface = nullptr; - SDL_FreePalette(palette); + SDL_FreePalette(Palette); SDL_FreeSurface(renderer_texture_surface); #ifndef USE_SDL1 SDL_DestroyTexture(texture); @@ -218,8 +218,8 @@ void dx_reinit() void InitPalette() { - palette = SDL_AllocPalette(256); - if (palette == nullptr) { + Palette = SDL_AllocPalette(256); + if (Palette == nullptr) { ErrSdl(); } } diff --git a/Source/gendung.cpp b/Source/gendung.cpp index ff38232af..12d15b860 100644 --- a/Source/gendung.cpp +++ b/Source/gendung.cpp @@ -61,10 +61,6 @@ dungeon_type setlvltype; int ViewX; /** Specifies the player viewpoint Y-coordinate of the map. */ int ViewY; -int ViewBX; -int ViewBY; -int ViewDX; -int ViewDY; ScrollStruct ScrollInfo; /** Specifies the level viewpoint X-coordinate of the map. */ int LvlViewX; diff --git a/Source/gendung.h b/Source/gendung.h index ea71383e0..88f346840 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -167,10 +167,6 @@ extern _setlevels setlvlnum; extern dungeon_type setlvltype; extern int ViewX; extern int ViewY; -extern int ViewBX; -extern int ViewBY; -extern int ViewDX; -extern int ViewDY; extern ScrollStruct ScrollInfo; extern int LvlViewX; extern int LvlViewY; diff --git a/Source/help.cpp b/Source/help.cpp index 2855e88c7..e440fb289 100644 --- a/Source/help.cpp +++ b/Source/help.cpp @@ -17,7 +17,7 @@ namespace devilution { unsigned int SkipLines; -bool helpflag; +bool HelpFlag; const char *const HelpText[] = { N_("$Keyboard Shortcuts:"), @@ -95,7 +95,7 @@ std::vector HelpTextLines; void InitHelp() { - helpflag = false; + HelpFlag = false; char tempstr[512]; for (const auto *text : HelpText) { @@ -154,7 +154,7 @@ void DrawHelp(const Surface &out) void DisplayHelp() { SkipLines = 0; - helpflag = true; + HelpFlag = true; } void HelpScrollUp() diff --git a/Source/help.h b/Source/help.h index 524e28fc5..3bd57860d 100644 --- a/Source/help.h +++ b/Source/help.h @@ -9,7 +9,7 @@ namespace devilution { -extern bool helpflag; +extern bool HelpFlag; void InitHelp(); void DrawHelp(const Surface &out); diff --git a/Source/hwcursor.cpp b/Source/hwcursor.cpp index 50b0ec85e..1e68c6d03 100644 --- a/Source/hwcursor.cpp +++ b/Source/hwcursor.cpp @@ -80,7 +80,7 @@ bool SetHardwareCursorFromSprite(int pcurs) size.height += 2 * outlineWidth; auto out = Surface::Alloc(size.width, size.height); - SDL_SetSurfacePalette(out.surface, palette); + SDL_SetSurfacePalette(out.surface, Palette); // Transparent color must not be used in the sprite itself. // Colors 1-127 are outside of the UI palette so are safe to use. diff --git a/Source/init.cpp b/Source/init.cpp index 23f067a4f..783c343a0 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -236,7 +236,6 @@ void MainWndProc(uint32_t msg) break; case DVL_WM_QUERYENDSESSION: diablo_quit(0); - break; } } diff --git a/Source/inv.cpp b/Source/inv.cpp index 238ba351e..d384352f5 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -141,23 +141,21 @@ void FreeInvGFX() void InitInv() { - auto &myPlayer = plr[myplr]; - - if (myPlayer._pClass == HeroClass::Warrior) { + switch (plr[myplr]._pClass) { + case HeroClass::Warrior: + case HeroClass::Barbarian: pInvCels = LoadCel("Data\\Inv\\Inv.CEL", SPANEL_WIDTH); - } else if (myPlayer._pClass == HeroClass::Rogue) { + break; + case HeroClass::Rogue: + case HeroClass::Bard: pInvCels = LoadCel("Data\\Inv\\Inv_rog.CEL", SPANEL_WIDTH); - } else if (myPlayer._pClass == HeroClass::Sorcerer) { + break; + case HeroClass::Sorcerer: pInvCels = LoadCel("Data\\Inv\\Inv_Sor.CEL", SPANEL_WIDTH); - } else if (myPlayer._pClass == HeroClass::Monk) { - if (!gbIsSpawn) - pInvCels = LoadCel("Data\\Inv\\Inv_Sor.CEL", SPANEL_WIDTH); - else - pInvCels = LoadCel("Data\\Inv\\Inv.CEL", SPANEL_WIDTH); - } else if (myPlayer._pClass == HeroClass::Bard) { - pInvCels = LoadCel("Data\\Inv\\Inv_rog.CEL", SPANEL_WIDTH); - } else if (myPlayer._pClass == HeroClass::Barbarian) { - pInvCels = LoadCel("Data\\Inv\\Inv.CEL", SPANEL_WIDTH); + break; + case HeroClass::Monk: + pInvCels = LoadCel(!gbIsSpawn ? "Data\\Inv\\Inv_Sor.CEL" : "Data\\Inv\\Inv.CEL", SPANEL_WIDTH); + break; } invflag = false; diff --git a/Source/inv.h b/Source/inv.h index 434ac1c82..854d244c0 100644 --- a/Source/inv.h +++ b/Source/inv.h @@ -33,8 +33,6 @@ enum inv_item : int8_t { INVITEM_BELT_FIRST = 47, INVITEM_BELT_LAST = 54, // clang-format on - NUM_INVELEM, - INVITEM_INVALID = -1, }; // identifiers for each of the inventory squares diff --git a/Source/multi.cpp b/Source/multi.cpp index a5ad9dc0a..000ed18ac 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -689,7 +689,7 @@ void NetClose() sgbNetInited = false; nthread_cleanup(); - dthread_cleanup(); + DThreadCleanup(); tmsg_cleanup(); EventHandler(false); SNetLeaveGame(3); diff --git a/Source/palette.cpp b/Source/palette.cpp index 7fe886167..36cf67c12 100644 --- a/Source/palette.cpp +++ b/Source/palette.cpp @@ -26,8 +26,8 @@ bool sgbFadedIn = true; void palette_update() { - assert(palette); - if (SDLC_SetSurfaceAndPaletteColors(pal_surface, palette, system_palette, 0, 256) < 0) { + assert(Palette); + if (SDLC_SetSurfaceAndPaletteColors(pal_surface, Palette, system_palette, 0, 256) < 0) { ErrSdl(); } pal_surface_palette_version++; diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index f0b0a019c..6031c3991 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -780,20 +780,20 @@ static void DrawDungeon(const Surface &out, int sx, int sy, int dx, int dy) do { DeadStruct *pDeadGuy = &dead[(bDead & 0x1F) - 1]; auto dd = static_cast((bDead >> 5) & 7); - int px = dx - CalculateWidth2(pDeadGuy->_deadWidth); - const byte *pCelBuff = pDeadGuy->_deadData[dd]; + int px = dx - CalculateWidth2(pDeadGuy->width); + const byte *pCelBuff = pDeadGuy->data[dd]; assert(pCelBuff != nullptr); const auto *frameTable = reinterpret_cast(pCelBuff); int frames = SDL_SwapLE32(frameTable[0]); - int nCel = pDeadGuy->_deadFrame; + int nCel = pDeadGuy->frame; if (nCel < 1 || frames > 50 || nCel > frames) { Log("Unclipped dead: frame {} of {}, deadnum=={}", nCel, frames, (bDead & 0x1F) - 1); break; } if (pDeadGuy->_deadtrans != 0) { - Cl2DrawLightTbl(out, px, dy, CelSprite(pCelBuff, pDeadGuy->_deadWidth), nCel, pDeadGuy->_deadtrans); + Cl2DrawLightTbl(out, px, dy, CelSprite(pCelBuff, pDeadGuy->width), nCel, pDeadGuy->_deadtrans); } else { - Cl2DrawLight(out, px, dy, CelSprite(pCelBuff, pDeadGuy->_deadWidth), nCel); + Cl2DrawLight(out, px, dy, CelSprite(pCelBuff, pDeadGuy->width), nCel); } } while (false); } @@ -1297,7 +1297,7 @@ void DrawView(const Surface &out, int startX, int startY) if (dropGoldFlag) { DrawGoldSplit(out, dropGoldValue); } - if (helpflag) { + if (HelpFlag) { DrawHelp(out); } if (msgflag != EMSG_NONE) { diff --git a/Source/utils/display.h b/Source/utils/display.h index 4eaa8e765..0057c3c1b 100644 --- a/Source/utils/display.h +++ b/Source/utils/display.h @@ -20,7 +20,7 @@ extern SDL_Window *window; extern SDL_Renderer *renderer; extern SDL_Texture *texture; -extern SDL_Palette *palette; +extern SDL_Palette *Palette; extern SDL_Surface *pal_surface; extern unsigned int pal_surface_palette_version;