Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Player struct variables: AnimationData #7264

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/engine/animationinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void AnimationInfo::setNewAnimation(OptionalClxSpriteList celSprite, int8_t numb
}
}

void AnimationInfo::changeAnimationData(OptionalClxSpriteList celSprite, int8_t numberOfFrames, int8_t ticksPerFrame)
void AnimationInfo::changeanimationData(OptionalClxSpriteList celSprite, int8_t numberOfFrames, int8_t ticksPerFrame)
{
if (numberOfFrames != this->numberOfFrames || ticksPerFrame != this->ticksPerFrame) {
// Ensure that the currentFrame is still valid and that we disable ADL cause the calculcated values (for example tickModifier_) could be wrong
Expand Down
2 changes: 1 addition & 1 deletion Source/engine/animationinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AnimationInfo {
* @param numberOfFrames Number of Frames in Animation
* @param ticksPerFrame How many game ticks are needed to advance one Animation Frame
*/
void changeAnimationData(OptionalClxSpriteList sprites, int8_t numberOfFrames, int8_t ticksPerFrame);
void changeanimationData(OptionalClxSpriteList sprites, int8_t numberOfFrames, int8_t ticksPerFrame);

/**
* @brief Process the Animation for a game tick (for example advances the frame)
Expand Down
4 changes: 2 additions & 2 deletions Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2811,8 +2811,8 @@ void CalcPlrGraphics(Player &player, PlayerWeaponGraphic animWeaponId, PlayerArm
LoadPlrGFX(player, graphic);
OptionalClxSpriteList sprites;
if (!HeadlessMode)
sprites = player.AnimationData[static_cast<size_t>(graphic)].spritesForDirection(player._pdir);
player.AnimInfo.changeAnimationData(sprites, numberOfFrames, ticksPerFrame);
sprites = player.animationData[static_cast<size_t>(graphic)].spritesForDirection(player._pdir);
player.AnimInfo.changeanimationData(sprites, numberOfFrames, ticksPerFrame);
} else {
player._pgfxnum = gfxNum;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/loadsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ void LoadGame(bool firstflag)
}
}

SetUpMissileAnimationData();
SetUpMissileanimationData();
RedoMissileFlags();
NewCursor(CURSOR_HAND);
gbProcessPlayers = IsDiabloAlive(!firstflag);
Expand Down
2 changes: 1 addition & 1 deletion Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4175,7 +4175,7 @@ void ProcessMissiles()
DeleteMissiles();
}

void SetUpMissileAnimationData()
void SetUpMissileanimationData()
{
for (auto &missile : Missiles) {
if (missile._miAnimType == MissileGraphicID::None)
Expand Down
2 changes: 1 addition & 1 deletion Source/missiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void ProcessBoneSpirit(Missile &missile);
void ProcessResurrectBeam(Missile &missile);
void ProcessRedPortal(Missile &missile);
void ProcessMissiles();
void SetUpMissileAnimationData();
void SetUpMissileanimationData();
void RedoMissileFlags();

#ifdef BUILD_TESTING
Expand Down
22 changes: 11 additions & 11 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void InitMonster(Monster &monster, Direction rd, size_t typeIndex, Point positio
monster.levelType = static_cast<uint8_t>(typeIndex);
monster.mode = MonsterMode::Stand;
monster.animInfo = {};
monster.changeAnimationData(MonsterGraphic::Stand);
monster.changeanimationData(MonsterGraphic::Stand);
monster.animInfo.tickCounterOfCurrentFrame = GenerateRnd(monster.animInfo.ticksPerFrame - 1);
monster.animInfo.currentFrame = GenerateRnd(monster.animInfo.numberOfFrames - 1);

Expand Down Expand Up @@ -187,7 +187,7 @@ void InitMonster(Monster &monster, Direction rd, size_t typeIndex, Point positio
monster.talkMsg = TEXT_NONE;

if (monster.ai == MonsterAIID::Gargoyle) {
monster.changeAnimationData(MonsterGraphic::Special);
monster.changeanimationData(MonsterGraphic::Special);
monster.animInfo.currentFrame = 0;
monster.flags |= MFLAG_ALLOW_SPECIAL;
monster.mode = MonsterMode::SpecialMeleeAttack;
Expand Down Expand Up @@ -302,7 +302,7 @@ void PlaceGroup(size_t typeIndex, size_t num, Monster *leader = nullptr, bool le
}

if (minion.ai != MonsterAIID::Gargoyle) {
minion.changeAnimationData(MonsterGraphic::Stand);
minion.changeanimationData(MonsterGraphic::Stand);
minion.animInfo.currentFrame = GenerateRnd(minion.animInfo.numberOfFrames - 1);
minion.flags &= ~MFLAG_ALLOW_SPECIAL;
minion.mode = MonsterMode::Stand;
Expand Down Expand Up @@ -983,7 +983,7 @@ void StartFadeout(Monster &monster, Direction md, bool backwards)
*/
void StartHeal(Monster &monster)
{
monster.changeAnimationData(MonsterGraphic::Special);
monster.changeanimationData(MonsterGraphic::Special);
monster.animInfo.currentFrame = monster.type().getAnimData(MonsterGraphic::Special).frames - 1;
monster.flags |= MFLAG_LOCK_ANIMATION;
monster.mode = MonsterMode::Heal;
Expand All @@ -1002,9 +1002,9 @@ void SyncLightPosition(Monster &monster)
void MonsterIdle(Monster &monster)
{
if (monster.type().type == MT_GOLEM)
monster.changeAnimationData(MonsterGraphic::Walk);
monster.changeanimationData(MonsterGraphic::Walk);
else
monster.changeAnimationData(MonsterGraphic::Stand);
monster.changeanimationData(MonsterGraphic::Stand);

if (monster.animInfo.isLastFrame())
UpdateEnemy(monster);
Expand Down Expand Up @@ -1484,7 +1484,7 @@ bool MonsterSpecialStand(Monster &monster)

bool MonsterDelay(Monster &monster)
{
monster.changeAnimationData(MonsterGraphic::Stand, GetMonsterDirection(monster));
monster.changeanimationData(MonsterGraphic::Stand, GetMonsterDirection(monster));
if (monster.ai == MonsterAIID::Lazarus) {
if (monster.var2 > 8 || monster.var2 < 0)
monster.var2 = 8;
Expand Down Expand Up @@ -2432,7 +2432,7 @@ void SneakAi(Monster &monster)
}
if (monster.mode == MonsterMode::Stand) {
if (distanceToEnemy >= 2 || v >= 4 * monster.intelligence + 10)
monster.changeAnimationData(MonsterGraphic::Stand);
monster.changeanimationData(MonsterGraphic::Stand);
else
StartAttack(monster);
}
Expand Down Expand Up @@ -3239,7 +3239,7 @@ void PrepareUniqueMonst(Monster &monster, UniqueMonsterType monsterType, size_t
}

if (monster.ai != MonsterAIID::Gargoyle) {
monster.changeAnimationData(MonsterGraphic::Stand);
monster.changeanimationData(MonsterGraphic::Stand);
monster.animInfo.currentFrame = GenerateRnd(monster.animInfo.numberOfFrames - 1);
monster.flags &= ~MFLAG_ALLOW_SPECIAL;
monster.mode = MonsterMode::Stand;
Expand Down Expand Up @@ -4285,7 +4285,7 @@ void SyncMonsterAnim(Monster &monster)
break;
}

monster.changeAnimationData(graphic);
monster.changeanimationData(graphic);
}

void M_FallenFear(Point position)
Expand Down Expand Up @@ -4721,7 +4721,7 @@ void Monster::checkStandAnimationIsLoaded(Direction mdir)
{
if (IsAnyOf(mode, MonsterMode::Stand, MonsterMode::Talk)) {
direction = mdir;
changeAnimationData(MonsterGraphic::Stand);
changeanimationData(MonsterGraphic::Stand);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Source/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,21 +288,21 @@ struct Monster { // note: missing field _mAFNum
* @param graphic Animation sequence of interest
* @param desiredDirection Desired desiredDirection the monster should be visually facing
*/
void changeAnimationData(MonsterGraphic graphic, Direction desiredDirection)
void changeanimationData(MonsterGraphic graphic, Direction desiredDirection)
{
const AnimStruct &animationData = type().getAnimData(graphic);

// Passing the frames and rate properties here is only relevant when initialising a monster, but doesn't cause any harm when switching animations.
this->animInfo.changeAnimationData(animationData.spritesForDirection(desiredDirection), animationData.frames, animationData.rate);
this->animInfo.changeanimationData(animationData.spritesForDirection(desiredDirection), animationData.frames, animationData.rate);
}

/**
* @brief Sets the current cell sprite to match the desired animation sequence using the direction the monster is currently facing
* @param graphic Animation sequence of interest
*/
void changeAnimationData(MonsterGraphic graphic)
void changeanimationData(MonsterGraphic graphic)
{
this->changeAnimationData(graphic, this->direction);
this->changeanimationData(graphic, this->direction);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ void Player::UpdatePreviewCelSprite(_cmd_id cmdId, Point point, uint16_t wParam1
return;

LoadPlrGFX(*this, *graphic);
ClxSpriteList sprites = AnimationData[static_cast<size_t>(*graphic)].spritesForDirection(dir);
ClxSpriteList sprites = animationData[static_cast<size_t>(*graphic)].spritesForDirection(dir);
if (!previewCelSprite || *previewCelSprite != sprites[0]) {
previewCelSprite = sprites[0];
progressToNextGameTickWhenPreviewWasSet = ProgressToNextGameTick;
Expand Down Expand Up @@ -2075,7 +2075,7 @@ void LoadPlrGFX(Player &player, player_graphic graphic)
if (HeadlessMode)
return;

auto &animationData = player.AnimationData[static_cast<size_t>(graphic)];
auto &animationData = player.animationData[static_cast<size_t>(graphic)];
if (animationData.sprites)
return;

Expand Down Expand Up @@ -2170,7 +2170,7 @@ void InitPlayerGFX(Player &player)
void ResetPlayerGFX(Player &player)
{
player.AnimInfo.sprites = std::nullopt;
for (PlayerAnimationData &animData : player.AnimationData) {
for (PlayeranimationData &animData : player.animationData) {
animData.sprites = std::nullopt;
}
}
Expand All @@ -2182,7 +2182,7 @@ void NewPlrAnim(Player &player, player_graphic graphic, Direction dir, Animation
OptionalClxSpriteList sprites;
int previewShownGameTickFragments = 0;
if (!HeadlessMode) {
sprites = player.AnimationData[static_cast<size_t>(graphic)].spritesForDirection(dir);
sprites = player.animationData[static_cast<size_t>(graphic)].spritesForDirection(dir);
if (player.previewCelSprite && (*sprites)[0] == *player.previewCelSprite && !player.isWalking()) {
previewShownGameTickFragments = std::clamp<int>(AnimationInfo::baseValueFraction - player.progressToNextGameTickWhenPreviewWasSet, 0, AnimationInfo::baseValueFraction);
}
Expand Down Expand Up @@ -3207,7 +3207,7 @@ void SyncPlrAnim(Player &player)
{
const player_graphic graphic = player.getGraphic();
if (!HeadlessMode)
player.AnimInfo.sprites = player.AnimationData[static_cast<size_t>(graphic)].spritesForDirection(player._pdir);
player.AnimInfo.sprites = player.animationData[static_cast<size_t>(graphic)].spritesForDirection(player._pdir);
}

void SyncInitPlrPos(Player &player)
Expand Down
6 changes: 3 additions & 3 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ constexpr std::array<char, 6> CharChar = {
/**
* @brief Contains Data (CelSprites) for a player graphic (player_graphic)
*/
struct PlayerAnimationData {
struct PlayeranimationData {
/**
* @brief Sprite lists for each of the 8 directions.
*/
Expand Down Expand Up @@ -285,9 +285,9 @@ struct Player {
/** @brief Bitmask using item_special_effect */
ItemSpecialEffect _pIFlags;
/**
* @brief Contains Data (Sprites) for the different Animations
* @brief Contains Data (Sprites) for the different Animations (AnimationData)
*/
std::array<PlayerAnimationData, enum_size<player_graphic>::value> AnimationData;
std::array<PlayeranimationData, enum_size<player_graphic>::value> animationData;
int8_t _pNFrames;
int8_t _pWFrames;
int8_t _pAFrames;
Expand Down
24 changes: 12 additions & 12 deletions test/animationinfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ struct TestData {
/**
* @brief Represents a call to setNewAnimation
*/
struct SetNewAnimationData : public TestData {
SetNewAnimationData(int numberOfFrames, int delayLen, AnimationDistributionFlags params = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0)
struct SetNewanimationData : public TestData {
SetNewanimationData(int numberOfFrames, int delayLen, AnimationDistributionFlags params = AnimationDistributionFlags::None, int numSkippedFrames = 0, int distributeFramesBeforeFrame = 0)
{
_NumberOfFrames = numberOfFrames;
_DelayLen = delayLen;
Expand Down Expand Up @@ -98,8 +98,8 @@ void RunAnimationTest(const std::vector<TestData *> &vecTestData)
for (TestData *x : vecTestData) {
switch (x->type()) {
case TestDataType::SetNewAnimation: {
auto setNewAnimationData = static_cast<SetNewAnimationData *>(x);
animInfo.setNewAnimation(std::nullopt, setNewAnimationData->_NumberOfFrames, setNewAnimationData->_DelayLen, setNewAnimationData->_Params, setNewAnimationData->_NumSkippedFrames, setNewAnimationData->_DistributeFramesBeforeFrame);
auto setNewanimationData = static_cast<SetNewanimationData *>(x);
animInfo.setNewAnimation(std::nullopt, setNewanimationData->_NumberOfFrames, setNewanimationData->_DelayLen, setNewanimationData->_Params, setNewanimationData->_NumSkippedFrames, setNewanimationData->_DistributeFramesBeforeFrame);
} break;
case TestDataType::GameTick: {
auto gameTickData = static_cast<GameTickData *>(x);
Expand Down Expand Up @@ -129,7 +129,7 @@ TEST(AnimationInfo, AttackSwordWarrior) // ProcessAnimationPending should be con
{
RunAnimationTest(
{
new SetNewAnimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 0, 9),
new SetNewanimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 0, 9),
// processAnimation directly after StartAttack (in same GameTick). So we don't see any rendering before.
new GameTickData(1, 0),
new RenderingData(0.0f, 0),
Expand Down Expand Up @@ -192,7 +192,7 @@ TEST(AnimationInfo, AttackSwordWarriorWithFastestAttack) // Skipped frames and P
{
RunAnimationTest(
{
new SetNewAnimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 2, 9),
new SetNewanimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 2, 9),
// processAnimation directly after StartAttack (in same GameTick). So we don't see any rendering before.
new GameTickData(3, 0),
new RenderingData(0.0f, 0),
Expand Down Expand Up @@ -248,7 +248,7 @@ TEST(AnimationInfo, AttackSwordWarriorRepeated)
{
RunAnimationTest(
{
new SetNewAnimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 0, 9),
new SetNewanimationData(16, 1, AnimationDistributionFlags::ProcessAnimationPending, 0, 9),
// processAnimation directly after StartAttack (in same GameTick). So we don't see any rendering before.
new GameTickData(1, 0),
new RenderingData(0.0f, 0),
Expand Down Expand Up @@ -293,7 +293,7 @@ TEST(AnimationInfo, AttackSwordWarriorRepeated)
new RenderingData(0.3f, 9),

// Start of repeated attack, cause plr[pnum].AnimInfo.currentFrame > plr[myplr]._pAFNum
new SetNewAnimationData(16, 1, static_cast<AnimationDistributionFlags>(AnimationDistributionFlags::ProcessAnimationPending | AnimationDistributionFlags::RepeatedAction), 0, 9),
new SetNewanimationData(16, 1, static_cast<AnimationDistributionFlags>(AnimationDistributionFlags::ProcessAnimationPending | AnimationDistributionFlags::RepeatedAction), 0, 9),
// processAnimation directly after StartAttack (in same GameTick). So we don't see any rendering before.
new GameTickData(1, 0),
new RenderingData(0.0f, 10),
Expand Down Expand Up @@ -356,7 +356,7 @@ TEST(AnimationInfo, BlockingWarriorNormal) // Ignored delay for last Frame shoul
{
RunAnimationTest(
{
new SetNewAnimationData(2, 3, AnimationDistributionFlags::SkipsDelayOfLastFrame),
new SetNewanimationData(2, 3, AnimationDistributionFlags::SkipsDelayOfLastFrame),
new RenderingData(0.0f, 0),
new RenderingData(0.3f, 0),
new RenderingData(0.6f, 0),
Expand Down Expand Up @@ -384,7 +384,7 @@ TEST(AnimationInfo, BlockingSorcererWithFastBlock) // Skipped frames and ignored
{
RunAnimationTest(
{
new SetNewAnimationData(6, 3, AnimationDistributionFlags::SkipsDelayOfLastFrame, 4),
new SetNewanimationData(6, 3, AnimationDistributionFlags::SkipsDelayOfLastFrame, 4),
new RenderingData(0.0f, 0),
new RenderingData(0.3f, 0),
new RenderingData(0.6f, 0),
Expand Down Expand Up @@ -412,7 +412,7 @@ TEST(AnimationInfo, HitRecoverySorcererHarmony) // Skipped frames and ignored de
{
RunAnimationTest(
{
new SetNewAnimationData(8, 1, AnimationDistributionFlags::None, 3),
new SetNewanimationData(8, 1, AnimationDistributionFlags::None, 3),
new RenderingData(0.0f, 0),
new RenderingData(0.3f, 0),
new RenderingData(0.6f, 0),
Expand Down Expand Up @@ -444,7 +444,7 @@ TEST(AnimationInfo, Stand) // Distribution Logic shouldn't change anything here
{
RunAnimationTest(
{
new SetNewAnimationData(10, 4),
new SetNewanimationData(10, 4),
new RenderingData(0.1f, 0),
new GameTickData(0, 1),
new RenderingData(0.6f, 0),
Expand Down
Loading