Browse Source

Apply various cleanups via Android Studio

pull/2298/head
Anders Jenbo 5 years ago
parent
commit
4eabc6024b
  1. 2
      Source/DiabloUI/credits.cpp
  2. 2
      Source/DiabloUI/diabloui.cpp
  3. 3
      Source/capture.cpp
  4. 30
      Source/codec.cpp
  5. 22
      Source/control.cpp
  6. 2
      Source/controls/plrctrls.cpp
  7. 4
      Source/controls/touch.cpp
  8. 24
      Source/dead.cpp
  9. 6
      Source/dead.h
  10. 36
      Source/debug.cpp
  11. 14
      Source/diablo.cpp
  12. 2
      Source/dthread.cpp
  13. 2
      Source/dthread.h
  14. 10
      Source/dx.cpp
  15. 4
      Source/gendung.cpp
  16. 4
      Source/gendung.h
  17. 6
      Source/help.cpp
  18. 2
      Source/help.h
  19. 2
      Source/hwcursor.cpp
  20. 1
      Source/init.cpp
  21. 26
      Source/inv.cpp
  22. 2
      Source/inv.h
  23. 2
      Source/multi.cpp
  24. 4
      Source/palette.cpp
  25. 12
      Source/scrollrt.cpp
  26. 2
      Source/utils/display.h

2
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());

2
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());

3
Source/capture.cpp

@ -3,6 +3,7 @@
*
* Implementation of the screenshot function.
*/
#include <cstdint>
#include <fstream>
#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;

30
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));

22
Source/control.cpp

@ -36,10 +36,10 @@ namespace {
Surface pBtmBuff;
Surface pLifeBuff;
Surface pManaBuff;
std::optional<CelSprite> pTalkBtns;
std::optional<CelSprite> talkButtons;
std::optional<CelSprite> pDurIcons;
std::optional<CelSprite> pChrButtons;
std::optional<CelSprite> pMultiBtns;
std::optional<CelSprite> multiButtons;
std::optional<CelSprite> pPanelButtons;
std::optional<CelSprite> pChrPanel;
std::optional<CelSprite> 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) {

2
Source/controls/plrctrls.cpp

@ -35,7 +35,7 @@ int speedspellcount = 0;
bool InGameMenu()
{
return stextflag != STORE_NONE
|| helpflag
|| HelpFlag
|| talkflag
|| qtextflag
|| gmenu_is_active()

4
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
};

24
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++;

6
Source/dead.h

@ -16,9 +16,9 @@ namespace devilution {
static constexpr unsigned MaxDead = 31;
struct DeadStruct {
std::array<const byte *, 8> _deadData;
int _deadFrame;
int _deadWidth;
std::array<const byte *, 8> data;
int frame;
int width;
uint8_t _deadtrans;
};

36
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<CelSprite> 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);
}

14
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

2
Source/dthread.cpp

@ -118,7 +118,7 @@ void dthread_start()
}
}
void dthread_cleanup()
void DThreadCleanup()
{
TMegaPkt *tmp;

2
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

10
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();
}
}

4
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;

4
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;

6
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<std::string> 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()

2
Source/help.h

@ -9,7 +9,7 @@
namespace devilution {
extern bool helpflag;
extern bool HelpFlag;
void InitHelp();
void DrawHelp(const Surface &out);

2
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.

1
Source/init.cpp

@ -236,7 +236,6 @@ void MainWndProc(uint32_t msg)
break;
case DVL_WM_QUERYENDSESSION:
diablo_quit(0);
break;
}
}

26
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;

2
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

2
Source/multi.cpp

@ -689,7 +689,7 @@ void NetClose()
sgbNetInited = false;
nthread_cleanup();
dthread_cleanup();
DThreadCleanup();
tmsg_cleanup();
EventHandler(false);
SNetLeaveGame(3);

4
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++;

12
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<Direction>((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<const uint32_t *>(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) {

2
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;

Loading…
Cancel
Save