Browse Source

Change AnimationInfo.pCelSprite to const

pull/2364/head
obligaron 5 years ago committed by Anders Jenbo
parent
commit
54d63e2edd
  1. 2
      Source/dead.cpp
  2. 4
      Source/engine/animationinfo.cpp
  3. 6
      Source/engine/animationinfo.h
  4. 2
      Source/monster.h
  5. 2
      Source/scrollrt.cpp

2
Source/dead.cpp

@ -16,7 +16,7 @@ DeadStruct Dead[MaxDead];
int8_t stonendx;
namespace {
void InitDeadAnimationFromMonster(DeadStruct &dead, CMonster &mon)
void InitDeadAnimationFromMonster(DeadStruct &dead, const CMonster &mon)
{
int i = 0;
auto &animData = mon.GetAnimData(MonsterGraphic::Death);

4
Source/engine/animationinfo.cpp

@ -73,7 +73,7 @@ float AnimationInfo::GetAnimationProgress() const
return fAnimationFraction;
}
void AnimationInfo::SetNewAnimation(CelSprite *celSprite, int numberOfFrames, int ticksPerFrame, AnimationDistributionFlags flags /*= AnimationDistributionFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/)
void AnimationInfo::SetNewAnimation(const CelSprite *celSprite, int numberOfFrames, int ticksPerFrame, AnimationDistributionFlags flags /*= AnimationDistributionFlags::None*/, int numSkippedFrames /*= 0*/, int distributeFramesBeforeFrame /*= 0*/)
{
if ((flags & AnimationDistributionFlags::RepeatedAction) == AnimationDistributionFlags::RepeatedAction && distributeFramesBeforeFrame != 0 && NumberOfFrames == numberOfFrames && CurrentFrame >= distributeFramesBeforeFrame && CurrentFrame != NumberOfFrames) {
// We showed the same Animation (for example a melee attack) before but truncated the Animation.
@ -161,7 +161,7 @@ void AnimationInfo::SetNewAnimation(CelSprite *celSprite, int numberOfFrames, in
}
}
void AnimationInfo::ChangeAnimationData(CelSprite *celSprite, int numberOfFrames, int delayLen)
void AnimationInfo::ChangeAnimationData(const CelSprite *celSprite, int numberOfFrames, int delayLen)
{
if (numberOfFrames != NumberOfFrames || delayLen != TicksPerFrame) {
// Ensure that the CurrentFrame is still valid and that we disable ADL cause the calculcated values (for example TickModifier) could be wrong

6
Source/engine/animationinfo.h

@ -39,7 +39,7 @@ public:
/**
* @brief Pointer to Animation Sprite
*/
CelSprite *pCelSprite;
const CelSprite *pCelSprite;
/**
* @brief How many game ticks are needed to advance one Animation Frame
*/
@ -81,7 +81,7 @@ public:
* @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 SetNewAnimation(CelSprite *celSprite, int numberOfFrames, int ticksPerFrame, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0);
void SetNewAnimation(const CelSprite *celSprite, int numberOfFrames, int ticksPerFrame, AnimationDistributionFlags flags = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0);
/**
* @brief Changes the Animation Data on-the-fly. This is needed if a animation is currently in progress and the player changes his gear.
@ -89,7 +89,7 @@ public:
* @param numberOfFrames Number of Frames in Animation
* @param delayLen Delay after each Animation sequence
*/
void ChangeAnimationData(CelSprite *celSprite, int numberOfFrames, int delayLen);
void ChangeAnimationData(const CelSprite *celSprite, int numberOfFrames, int delayLen);
/**
* @brief Process the Animation for a game tick (for example advances the frame)

2
Source/monster.h

@ -130,7 +130,7 @@ struct CMonster {
/**
* @brief Returns AnimStruct for specified graphic
*/
AnimStruct& GetAnimData(MonsterGraphic graphic)
const AnimStruct& GetAnimData(MonsterGraphic graphic) const
{
return Anims[static_cast<int>(graphic)];
}

2
Source/scrollrt.cpp

@ -443,7 +443,7 @@ static void DrawMonster(const Surface &out, int x, int y, int mx, int my, int m)
return;
}
CelSprite &cel = *Monsters[m].AnimInfo.pCelSprite;
auto &cel = *Monsters[m].AnimInfo.pCelSprite;
if ((dFlags[x][y] & BFLAG_LIT) == 0) {
Cl2DrawLightTbl(out, mx, my, cel, nCel, 1);

Loading…
Cancel
Save