From 59e834fdad50d93baa0a45789bd0ccad262983ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Jan 2022 18:31:08 +0100 Subject: [PATCH] - Duke: changed animation storage to be independent of the animated values' types. --- source/games/duke/src/funct.h | 2 - source/games/duke/src/sectors.cpp | 61 +++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 2e78aff81..f6626a753 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -239,6 +239,4 @@ void loadcons(); void recordoldspritepos(); void DrawStatusBar(); -int* animateptr(int i, bool write = true); - END_DUKE_NS diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 8a6c6e917..eeb501920 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -277,30 +277,62 @@ int findotherplayer(int p, int* d) // //--------------------------------------------------------------------------- -int* animateptr(int type, int index, bool write) +double getanimatevalue(int type, int index) +{ + switch (type) + { + case anim_floorz: + return sector[index].floorz; + case anim_ceilingz: + return sector[index].ceilingz; + case anim_vertexx: + return wall[index].wall_int_pos().X; + case anim_vertexy: + return wall[index].wall_int_pos().Y; + default: + assert(false); + return 0; + } +} + +double getanimatevalue(int i) +{ + return getanimatevalue(animatetype[i], animatetarget[i]); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void setanimatevalue(int type, int index, double value) { static int scratch; switch (type) { case anim_floorz: - return sector[index].floorzptr(!write); + sector[index].setfloorz((int)value); + break; case anim_ceilingz: - return sector[index].ceilingzptr(!write); + sector[index].setceilingz((int)value); + break; case anim_vertexx: - if (write) wall[index].moved(); - return &wall[index].__wall_int_pos.X; + wall[index].moved(); + wall[index].__wall_int_pos.X = (int)value; + break; case anim_vertexy: - if (write) wall[index].moved(); - return &wall[index].__wall_int_pos.Y; + wall[index].moved(); + wall[index].__wall_int_pos.Y = (int)value; + break; default: assert(false); - return &scratch; } } -int* animateptr(int i, bool write) +void setanimatevalue(int i, double value) { - return animateptr(animatetype[i], animatetarget[i], write); + return setanimatevalue(animatetype[i], animatetarget[i], value); } //--------------------------------------------------------------------------- @@ -315,7 +347,7 @@ void doanimations(void) for (i = animatecnt - 1; i >= 0; i--) { - a = *animateptr(i, false); + a = (int)getanimatevalue(i); v = animatevel[i] * TICSPERFRAME; auto dasectp = animatesect[i]; @@ -365,8 +397,7 @@ void doanimations(void) } } } - - *animateptr(i, true) = a; + setanimatevalue(i, a); } } @@ -412,12 +443,12 @@ static int dosetanimation(sectortype* animsect, int animtype, int animtarget, in break; } - auto animptr = animateptr(animtype, animtarget, false); + auto animval = (int)getanimatevalue(animtype, animtarget); animatesect[j] = animsect; animatetype[j] = animtype; animatetarget[j] = animtarget; animategoal[j] = thegoal; - if (thegoal >= *animptr) + if (thegoal >= animval) animatevel[j] = thevel; else animatevel[j] = -thevel;