From c6f6c99adda9ea581fbc322bd6b1591d132db6fe Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 13 Jun 2021 04:59:43 +0200 Subject: [PATCH] Fix GCC warning --- Source/msg.cpp | 36 ++++++++++++++++++------------------ Source/multi.cpp | 2 +- Source/player.cpp | 4 ++-- test/animationinfo_test.cpp | 3 +-- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Source/msg.cpp b/Source/msg.cpp index 9bc57386b..ab3ce627e 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -2221,32 +2221,32 @@ static DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum) if (gbBufferMsgs == 1) msg_send_packet(pnum, p, sizeof(*p)); else { - plr[pnum]._pLvlChanging = false; - if (plr[pnum]._pName[0] != 0 && !plr[pnum].plractive) { - ResetPlayerGFX(plr[pnum]); - plr[pnum].plractive = true; + player._pLvlChanging = false; + if (player._pName[0] != 0 && !player.plractive) { + ResetPlayerGFX(player); + player.plractive = true; gbActivePlayers++; - EventPlrMsg(fmt::format(_("Player '{:s}' (level {:d}) just joined the game"), plr[pnum]._pName, plr[pnum]._pLevel).c_str()); + EventPlrMsg(fmt::format(_("Player '{:s}' (level {:d}) just joined the game"), player._pName, player._pLevel).c_str()); } - if (plr[pnum].plractive && myplr != pnum) { - plr[pnum].position.tile = { p->x, p->y }; - plr[pnum].plrlevel = p->wParam1; - ResetPlayerGFX(plr[pnum]); - if (currlevel == plr[pnum].plrlevel) { + if (player.plractive && myplr != pnum) { + player.position.tile = { p->x, p->y }; + player.plrlevel = p->wParam1; + ResetPlayerGFX(player); + if (currlevel == player.plrlevel) { SyncInitPlr(pnum); - if ((plr[pnum]._pHitPoints >> 6) > 0) + if ((player._pHitPoints >> 6) > 0) StartStand(pnum, DIR_S); else { - plr[pnum]._pgfxnum = 0; - plr[pnum]._pmode = PM_DEATH; - NewPlrAnim(plr[pnum], player_graphic::Death, DIR_S, plr[pnum]._pDFrames, 1); - plr[pnum].AnimInfo.CurrentFrame = plr[pnum].AnimInfo.NumberOfFrames - 1; - dFlags[plr[pnum].position.tile.x][plr[pnum].position.tile.y] |= BFLAG_DEAD_PLAYER; + player._pgfxnum = 0; + player._pmode = PM_DEATH; + NewPlrAnim(player, player_graphic::Death, DIR_S, player._pDFrames, 1); + player.AnimInfo.CurrentFrame = player.AnimInfo.NumberOfFrames - 1; + dFlags[player.position.tile.x][player.position.tile.y] |= BFLAG_DEAD_PLAYER; } - plr[pnum]._pvid = AddVision(plr[pnum].position.tile, plr[pnum]._pLightRad, pnum == myplr); - plr[pnum]._plid = NO_LIGHT; + player._pvid = AddVision(player.position.tile, player._pLightRad, pnum == myplr); + player._plid = NO_LIGHT; } } } diff --git a/Source/multi.cpp b/Source/multi.cpp index 794af9205..0dc8aab5c 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -720,7 +720,7 @@ bool NetInit(bool bSinglePlayer) memset(sgbPlayerLeftGameTbl, 0, sizeof(sgbPlayerLeftGameTbl)); memset(sgdwPlayerLeftReasonTbl, 0, sizeof(sgdwPlayerLeftReasonTbl)); memset(sgbSendDeltaTbl, 0, sizeof(sgbSendDeltaTbl)); - memset(plr, 0, sizeof(plr)); + plr[0].Reset(); memset(sgwPackPlrOffsetTbl, 0, sizeof(sgwPackPlrOffsetTbl)); SNetSetBasePlayer(0); if (bSinglePlayer) { diff --git a/Source/player.cpp b/Source/player.cpp index 9040437e6..99913d00b 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -515,7 +515,7 @@ void InitPlayerGFX(int pnum) player._pgfxnum = 0; LoadPlrGFX(player, player_graphic::Death); } else { - for (int i = 0; i < enum_size::value; i++) { + for (size_t i = 0; i < enum_size::value; i++) { auto graphic = static_cast(i); if (graphic == player_graphic::Death) continue; @@ -3657,7 +3657,7 @@ void CheckPlrSpell() void SyncPlrAnim(int pnum) { - int dir, sType; + int sType; if ((DWORD)pnum >= MAX_PLRS) { app_fatal("SyncPlrAnim: illegal player %i", pnum); diff --git a/test/animationinfo_test.cpp b/test/animationinfo_test.cpp index 32eae1b54..074426b7f 100644 --- a/test/animationinfo_test.cpp +++ b/test/animationinfo_test.cpp @@ -69,7 +69,6 @@ struct RenderingData : TestData { */ void RunAnimationTest(const std::vector &vecTestData) { - const int pnum = 0; AnimationInfo animInfo = {}; int currentGameTick = 0; @@ -220,7 +219,7 @@ TEST(AnimationInfo, AttackSwordWarriorWithFastestAttack) // Skipped frames and P } /* -* @brief The Warrior make two attacks. The second queued attack cancels the first after the Hit Frame. +* @brief The Warrior make two attacks. The second queued attack cancels the first after the Hit Frame. */ TEST(AnimationInfo, AttackSwordWarriorRepeated) {