- drafted a DBloodActor to wrap the multitude of arrays (12 overall!) in which an actor is split up.

This commit is contained in:
Christoph Oelckers 2020-12-02 12:46:44 +01:00
parent bc1adc9c51
commit 0ac41e0b5a
3 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,43 @@
#pragma once
#include "build.h"
#include "common_game.h"
#include "db.h"
#include "ai.h"
#include "nnexts.h"
#include "seq.h"
#include "aiunicult.h"
BEGIN_BLD_NS
// Due to the messed up array storage of all the game data we cannot do any direct referenced here yet. We have to access everything via wrapper functions for now.
// Note that the indexing is very inconsistent - partially by sprite index, partially by xsprite index.
class DBloodActor
{
const int index;
DBloodActor* base();
public:
DBloodActor() :index(int(this - base())) { assert(index >= 0 && index < kMaxSprites); }
bool hasX() { return sprite[index].extra > 0; }
spritetype& s() { return sprite[index]; }
XSPRITE& x() { return xsprite[sprite[index].extra]; } // calling this does not validate the xsprite!
SPRITEHIT& hit() { return gSpriteHit[sprite[index].extra]; }
int& xvel() { return Blood::xvel[index]; }
int& yvel() { return Blood::yvel[index]; }
int& zvel() { return Blood::zvel[index]; }
int& cumulDamage() { return Blood::cumulDamage[sprite[index].extra]; }
int& dudeSlope() { return Blood::gDudeSlope[sprite[index].extra]; }
DUDEEXTRA& dudeExtra() { return gDudeExtra[sprite[index].extra]; }
SPRITEMASS& spriteMass() { return gSpriteMass[sprite[index].extra]; }
GENDUDEEXTRA& genDudeExtra() { return Blood::gGenDudeExtra[index]; }
POINT3D& basePoint() { return Blood::baseSprite[index]; }
};
extern DBloodActor bloodActors[kMaxSprites];
inline DBloodActor* DBloodActor::base() { return bloodActors; }
END_BLD_NS

View file

@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h" // Must come before everything else!
#include "bloodactor.h"
#include "build.h"
#include "compat.h"
#include "mmulti.h"

View file

@ -37,9 +37,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "db.h"
#include "eventq.h"
#include "nnexts.h"
#include "bloodactor.h"
BEGIN_BLD_NS
DBloodActor bloodActors[kMaxSprites];
bool gModernMap = false;
unsigned short gStatCount[kMaxStatus + 1];