From 9407fa549d88901c93d3e6850525c899ba0c795c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Feb 2022 00:12:15 +0100 Subject: [PATCH] - SW: made ANIM value type independent. --- source/games/sw/src/game.h | 40 +++++++++++++++++++++++++++------- source/games/sw/src/sector.cpp | 6 ++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 4bb88f3a9..365ff6220 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2101,34 +2101,58 @@ inline void PlaySound(int num, DSWActor* actor, int flags, int channel = 8, ECha struct ANIM { int animtype, animindex; - int goal; + double goal; int vel; short vel_adj; TObjPtr animactor; ANIM_CALLBACKp callback; SECTOR_OBJECT* callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. - int& Addr(bool write) + double getValue() { - static int scratch; switch (animtype) { case ANIM_Floorz: - return *sector[animindex].floorzptr(!write); + return sector[animindex].floorz; case ANIM_SopZ: return SectorObject[animindex].pmid.Z; case ANIM_Spritez: - if (animactor == nullptr) return scratch; - return animactor->spr.__int_pos.Z; + if (animactor == nullptr) return 0; + return animactor->spr.int_pos().Z; case ANIM_Userz: - if (animactor == nullptr) return scratch; + if (animactor == nullptr) return 0; return animactor->user.pos.Z; case ANIM_SUdepth: return sector[animindex].depth_fixed; default: - return animindex; + return 0; } } + + void setValue(double value) + { + switch (animtype) + { + case ANIM_Floorz: + sector[animindex].setfloorz(value); + break; + case ANIM_SopZ: + SectorObject[animindex].pmid.Z = value; + break; + case ANIM_Spritez: + if (animactor == nullptr) return; + animactor->set_int_z(value); + break; + case ANIM_Userz: + if (animactor == nullptr) return; + animactor->user.pos.Z = value; + break; + case ANIM_SUdepth: + sector[animindex].depth_fixed = value; + default: + return; + } + } }; extern ANIM Anim[MAXANIM]; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 954e387d2..80128a63d 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -2425,11 +2425,11 @@ void DoSineWaveWall(void) void DoAnim(int numtics) { - int i, animval; + int i; for (i = AnimCnt - 1; i >= 0; i--) { - animval = Anim[i].Addr(true); + double animval = Anim[i].getValue(); // if LESS THAN goal if (animval < Anim[i].goal) @@ -2455,7 +2455,7 @@ void DoAnim(int numtics) animval = Anim[i].goal; } - Anim[i].Addr(true) =animval; + Anim[i].setValue(animval); // EQUAL this entry has finished if (animval == Anim[i].goal)