- SW: made ANIM value type independent.

This commit is contained in:
Christoph Oelckers 2022-02-03 00:12:15 +01:00
parent fa53fcd085
commit 9407fa549d
2 changed files with 35 additions and 11 deletions

View file

@ -2101,34 +2101,58 @@ inline void PlaySound(int num, DSWActor* actor, int flags, int channel = 8, ECha
struct ANIM struct ANIM
{ {
int animtype, animindex; int animtype, animindex;
int goal; double goal;
int vel; int vel;
short vel_adj; short vel_adj;
TObjPtr<DSWActor*> animactor; TObjPtr<DSWActor*> animactor;
ANIM_CALLBACKp callback; ANIM_CALLBACKp callback;
SECTOR_OBJECT* callbackdata; // only gets used in one place for this so having a proper type makes serialization easier. 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) switch (animtype)
{ {
case ANIM_Floorz: case ANIM_Floorz:
return *sector[animindex].floorzptr(!write); return sector[animindex].floorz;
case ANIM_SopZ: case ANIM_SopZ:
return SectorObject[animindex].pmid.Z; return SectorObject[animindex].pmid.Z;
case ANIM_Spritez: case ANIM_Spritez:
if (animactor == nullptr) return scratch; if (animactor == nullptr) return 0;
return animactor->spr.__int_pos.Z; return animactor->spr.int_pos().Z;
case ANIM_Userz: case ANIM_Userz:
if (animactor == nullptr) return scratch; if (animactor == nullptr) return 0;
return animactor->user.pos.Z; return animactor->user.pos.Z;
case ANIM_SUdepth: case ANIM_SUdepth:
return sector[animindex].depth_fixed; return sector[animindex].depth_fixed;
default: 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]; extern ANIM Anim[MAXANIM];

View file

@ -2425,11 +2425,11 @@ void DoSineWaveWall(void)
void DoAnim(int numtics) void DoAnim(int numtics)
{ {
int i, animval; int i;
for (i = AnimCnt - 1; i >= 0; i--) for (i = AnimCnt - 1; i >= 0; i--)
{ {
animval = Anim[i].Addr(true); double animval = Anim[i].getValue();
// if LESS THAN goal // if LESS THAN goal
if (animval < Anim[i].goal) if (animval < Anim[i].goal)
@ -2455,7 +2455,7 @@ void DoAnim(int numtics)
animval = Anim[i].goal; animval = Anim[i].goal;
} }
Anim[i].Addr(true) =animval; Anim[i].setValue(animval);
// EQUAL this entry has finished // EQUAL this entry has finished
if (animval == Anim[i].goal) if (animval == Anim[i].goal)