From 5b9f0f4aaaeafc1fd76cf8afe35cfa9b3cf663cc Mon Sep 17 00:00:00 2001 From: obligaron Date: Sun, 25 Jul 2021 10:32:23 +0200 Subject: [PATCH] Introduce GetPlayerGraphicForSpell --- Source/player.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/player.cpp b/Source/player.cpp index 95b6bbd77..99871e8f0 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -490,6 +490,18 @@ void StartRangeAttack(int pnum, Direction d, int cx, int cy) player.position.temp = { cx, cy }; } +player_graphic GetPlayerGraphicForSpell(spell_id spellId) +{ + switch (spelldata[spellId].sType) { + case STYPE_FIRE: + return player_graphic::Fire; + case STYPE_LIGHTNING: + return player_graphic::Lightning; + default: + return player_graphic::Magic; + } +} + void StartSpell(int pnum, Direction d, int cx, int cy) { if ((DWORD)pnum >= MAX_PLRS) @@ -505,18 +517,7 @@ void StartSpell(int pnum, Direction d, int cx, int cy) auto animationFlags = AnimationDistributionFlags::ProcessAnimationPending; if (player._pmode == PM_SPELL) animationFlags = static_cast(animationFlags | AnimationDistributionFlags::RepeatedAction); - - switch (spelldata[player._pSpell].sType) { - case STYPE_FIRE: - NewPlrAnim(player, player_graphic::Fire, d, player._pSFrames, 1, animationFlags, 0, player._pSFNum); - break; - case STYPE_LIGHTNING: - NewPlrAnim(player, player_graphic::Lightning, d, player._pSFrames, 1, animationFlags, 0, player._pSFNum); - break; - case STYPE_MAGIC: - NewPlrAnim(player, player_graphic::Magic, d, player._pSFrames, 1, animationFlags, 0, player._pSFNum); - break; - } + NewPlrAnim(player, GetPlayerGraphicForSpell(player._pSpell), d, player._pSFrames, 1, animationFlags, 0, player._pSFNum); } else { // Start new stand animation so that currentframe is reset d = player._pdir;