diff --git a/Source/player.cpp b/Source/player.cpp index fd63b7b43..e2662e6d3 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -545,7 +545,7 @@ void FreePlayerGFX(int pnum) plr[pnum]._pGFXLoad = 0; } -void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, AnimationFlags flags /*= AnimationFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/) +void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, AnimationDistributionFlags flags /*= AnimationDistributionFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/) { if ((DWORD)pnum >= MAX_PLRS) { app_fatal("NewPlrAnim: illegal player %d", pnum); @@ -562,7 +562,7 @@ void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, Animat plr[pnum]._pAnimRelevantAnimationFramesForDistributing = 0; plr[pnum]._pAnimGameTickModifier = 0.0f; - if (numSkippedFrames != 0 || flags != AnimationFlags::None) { + if (numSkippedFrames != 0 || flags != AnimationDistributionFlags::None) { int relevantAnimationFramesForDistributing = numFrames; // Animation Frames that will be adjusted for the skipped Frames/GameTicks if (distributeFramesBeforeFrame != 0) { // After an attack hits (_pAFNum or _pSFNum) it can be canceled or another attack can be queued and this means the animation is canceled. @@ -576,7 +576,7 @@ void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, Animat int relevantAnimationGameTicksForDistribution = relevantAnimationFramesForDistributing * gameTicksPerFrame; // GameTicks that will be adjusted for the skipped Frames/GameTicks int relevantAnimationGameTicksWithSkipping = relevantAnimationGameTicksForDistribution - (numSkippedFrames * gameTicksPerFrame); // How many GameTicks will the Animation be really shown (skipped Frames and GameTicks removed) - if ((flags & AnimationFlags::ProcessAnimationPending) == AnimationFlags::ProcessAnimationPending) { + if ((flags & AnimationDistributionFlags::ProcessAnimationPending) == AnimationDistributionFlags::ProcessAnimationPending) { // If ProcessAnimation will be called after NewPlrAnim (in same GameTick as NewPlrAnim), we increment the Animation-Counter. // If no delay is specified, this will result in complete skipped frame (see ProcessPlayerAnimation). // But if we have a delay specified, this would only result in a reduced time the first frame is shown (one skipped delay). @@ -588,7 +588,7 @@ void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, Animat plr[pnum]._pAnimGameTicksSinceSequenceStarted = -1; } - if ((flags & AnimationFlags::SkipsDelayOfLastFrame) == AnimationFlags::SkipsDelayOfLastFrame) { + if ((flags & AnimationDistributionFlags::SkipsDelayOfLastFrame) == AnimationDistributionFlags::SkipsDelayOfLastFrame) { // The logic for player/monster/... (not ProcessAnimation) only checks the frame not the delay. // That means if a delay is specified, the last-frame is shown less then the other frames // Example: @@ -1537,7 +1537,7 @@ void StartWalk(int pnum, int xvel, int yvel, int xoff, int yoff, int xadd, int y //Start walk animation int numSkippedFrames = (currlevel == 0 && sgGameInitInfo.bRunInTown) ? (plr[pnum]._pWFrames / 2) : 0; - NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth, AnimationFlags::None, numSkippedFrames); + NewPlrAnim(pnum, plr[pnum]._pWAnim[EndDir], plr[pnum]._pWFrames, 0, plr[pnum]._pWWidth, AnimationDistributionFlags::None, numSkippedFrames); plr[pnum]._pdir = EndDir; plr[pnum]._pVar8 = 0; @@ -1585,7 +1585,7 @@ void StartAttack(int pnum, direction d) skippedAnimationFrames += 2; } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth, AnimationFlags::ProcessAnimationPending, skippedAnimationFrames, plr[pnum]._pAFNum); + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth, AnimationDistributionFlags::ProcessAnimationPending, skippedAnimationFrames, plr[pnum]._pAFNum); plr[pnum]._pmode = PM_ATTACK; FixPlayerLocation(pnum, d); SetPlayerOld(pnum); @@ -1613,7 +1613,7 @@ void StartRangeAttack(int pnum, direction d, int cx, int cy) } } - NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth, AnimationFlags::ProcessAnimationPending, skippedAnimationFrames, plr[pnum]._pAFNum); + NewPlrAnim(pnum, plr[pnum]._pAAnim[d], plr[pnum]._pAFrames, 0, plr[pnum]._pAWidth, AnimationDistributionFlags::ProcessAnimationPending, skippedAnimationFrames, plr[pnum]._pAFNum); plr[pnum]._pmode = PM_RATTACK; FixPlayerLocation(pnum, d); @@ -1644,7 +1644,7 @@ void StartPlrBlock(int pnum, direction dir) skippedAnimationFrames = (plr[pnum]._pBFrames - 2); // ISPL_FASTBLOCK means we cancel the animation if frame 2 was shown } - NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth, AnimationFlags::SkipsDelayOfLastFrame, skippedAnimationFrames); + NewPlrAnim(pnum, plr[pnum]._pBAnim[dir], plr[pnum]._pBFrames, 2, plr[pnum]._pBWidth, AnimationDistributionFlags::SkipsDelayOfLastFrame, skippedAnimationFrames); plr[pnum]._pmode = PM_BLOCK; FixPlayerLocation(pnum, dir); @@ -1667,19 +1667,19 @@ void StartSpell(int pnum, direction d, int cx, int cy) if ((plr[pnum]._pGFXLoad & PFILE_FIRE) == 0) { LoadPlrGFX(pnum, PFILE_FIRE); } - NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationFlags::ProcessAnimationPending); + NewPlrAnim(pnum, plr[pnum]._pFAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationDistributionFlags::ProcessAnimationPending); break; case STYPE_LIGHTNING: if ((plr[pnum]._pGFXLoad & PFILE_LIGHTNING) == 0) { LoadPlrGFX(pnum, PFILE_LIGHTNING); } - NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationFlags::ProcessAnimationPending); + NewPlrAnim(pnum, plr[pnum]._pLAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationDistributionFlags::ProcessAnimationPending); break; case STYPE_MAGIC: if ((plr[pnum]._pGFXLoad & PFILE_MAGIC) == 0) { LoadPlrGFX(pnum, PFILE_MAGIC); } - NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationFlags::ProcessAnimationPending); + NewPlrAnim(pnum, plr[pnum]._pTAnim[d], plr[pnum]._pSFrames, 0, plr[pnum]._pSWidth, AnimationDistributionFlags::ProcessAnimationPending); break; } } @@ -1791,7 +1791,7 @@ void StartPlrHit(int pnum, int dam, bool forcehit) skippedAnimationFrames = 0; } - NewPlrAnim(pnum, plr[pnum]._pHAnim[pd], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth, AnimationFlags::None, skippedAnimationFrames); + NewPlrAnim(pnum, plr[pnum]._pHAnim[pd], plr[pnum]._pHFrames, 0, plr[pnum]._pHWidth, AnimationDistributionFlags::None, skippedAnimationFrames); plr[pnum]._pmode = PM_GOTHIT; FixPlayerLocation(pnum, pd); diff --git a/Source/player.h b/Source/player.h index 5824736cb..d90770424 100644 --- a/Source/player.h +++ b/Source/player.h @@ -419,7 +419,7 @@ void FreePlayerGFX(int pnum); /** * @brief Specifies what special logics are applied for a Animation */ -enum AnimationFlags : uint8_t { +enum AnimationDistributionFlags : uint8_t { None = 0, /* * @brief ProcessAnimation will be called after NewPlrAnim (in same GameTick as NewPlrAnim) @@ -443,7 +443,7 @@ enum AnimationFlags : uint8_t { * @param numSkippedFrames Number of Frames that will be skipped (for example with modifier "faster attack") * @param distributeFramesBeforeFrame Distribute the numSkippedFrames only before this frame */ -void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, AnimationFlags flags = AnimationFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0); +void NewPlrAnim(int pnum, BYTE *Peq, int numFrames, int Delay, int width, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0); void SetPlrAnims(int pnum); void ProcessPlayerAnimation(int pnum); /** diff --git a/test/animationinformation_test.cpp b/test/animationinformation_test.cpp index 6bbae0d55..5ddfda5cc 100644 --- a/test/animationinformation_test.cpp +++ b/test/animationinformation_test.cpp @@ -50,7 +50,7 @@ struct RenderingData : TestData { * Rendering can happen more often then GameTicks and at any time between two GameTicks. * The Animation Distribution Logic must adjust to the Rendering that happens at any give point in time. */ -void RunAnimationTest(int numFrames, int delay, AnimationFlags flags, int numSkippedFrames, int distributeFramesBeforeFrame, const std::vector &vecTestData) +void RunAnimationTest(int numFrames, int delay, AnimationDistributionFlags flags, int numSkippedFrames, int distributeFramesBeforeFrame, const std::vector &vecTestData) { const int pnum = 0; PlayerStruct *pPlayer = &plr[pnum]; @@ -86,7 +86,7 @@ void RunAnimationTest(int numFrames, int delay, AnimationFlags flags, int numSki TEST(AnimationInformation, AttackSwordWarrior) // ProcessAnimationPending should be considered by distribution logic { - RunAnimationTest(16, 0, AnimationFlags::ProcessAnimationPending, 0, 9, + RunAnimationTest(16, 0, AnimationDistributionFlags::ProcessAnimationPending, 0, 9, { new GameTickData(2, 0), // ProcessPlayer directly after StartAttack (in same GameTick). So we don't see any rendering before. new RenderingData(0.0f, 1), @@ -146,7 +146,7 @@ TEST(AnimationInformation, AttackSwordWarrior) // ProcessAnimationPending should TEST(AnimationInformation, AttackSwordWarriorWithFastestAttack) // Skipped frames and ProcessAnimationPending should be considered by distribution logic { - RunAnimationTest(16, 0, AnimationFlags::ProcessAnimationPending, 2, 9, + RunAnimationTest(16, 0, AnimationDistributionFlags::ProcessAnimationPending, 2, 9, { new GameTickData(2, 0), // ProcessPlayer directly after StartAttack (in same GameTick). So we don't see any rendering before. new RenderingData(0.0f, 1), @@ -196,7 +196,7 @@ TEST(AnimationInformation, AttackSwordWarriorWithFastestAttack) // Skipped frame TEST(AnimationInformation, BlockingWarriorNormal) // Ignored delay for last Frame should be considered by distribution logic { - RunAnimationTest(2, 2, AnimationFlags::SkipsDelayOfLastFrame, 0, 0, + RunAnimationTest(2, 2, AnimationDistributionFlags::SkipsDelayOfLastFrame, 0, 0, { new RenderingData(0.0f, 1), new RenderingData(0.3f, 1), @@ -223,7 +223,7 @@ TEST(AnimationInformation, BlockingWarriorNormal) // Ignored delay for last Fram TEST(AnimationInformation, BlockingSorcererWithFastBlock) // Skipped frames and ignored delay for last Frame should be considered by distribution logic { - RunAnimationTest(6, 2, AnimationFlags::SkipsDelayOfLastFrame, 4, 0, + RunAnimationTest(6, 2, AnimationDistributionFlags::SkipsDelayOfLastFrame, 4, 0, { new RenderingData(0.0f, 1), new RenderingData(0.3f, 1), @@ -250,7 +250,7 @@ TEST(AnimationInformation, BlockingSorcererWithFastBlock) // Skipped frames and TEST(AnimationInformation, HitRecoverySorcererZenMode) // Skipped frames and ignored delay for last Frame should be considered by distribution logic { - RunAnimationTest(8, 0, AnimationFlags::None, 4, 0, + RunAnimationTest(8, 0, AnimationDistributionFlags::None, 4, 0, { new RenderingData(0.0f, 1), new RenderingData(0.3f, 1), @@ -276,7 +276,7 @@ TEST(AnimationInformation, HitRecoverySorcererZenMode) // Skipped frames and ign } TEST(AnimationInformation, Stand) // Distribution Logic shouldn't change anything here { - RunAnimationTest(10, 3, AnimationFlags::None, 0, 0, + RunAnimationTest(10, 3, AnimationDistributionFlags::None, 0, 0, { new RenderingData(0.1f, 1), new GameTickData(1, 1),