mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- SW: move User into DSWActor.
This commit is contained in:
parent
fe83487c77
commit
f6db4a8e51
6 changed files with 44 additions and 56 deletions
|
@ -571,7 +571,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
|
|||
int SpriteNum = tsprite[tSpriteNum].owner;
|
||||
auto tActor = &swActors[SpriteNum];
|
||||
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
||||
tu = tActor->u();
|
||||
tu = tActor->hasU()? tActor->u() : nullptr;
|
||||
|
||||
#if 0
|
||||
// Brighten up the sprite if set somewhere else to do so
|
||||
|
|
|
@ -1096,7 +1096,6 @@ struct USER
|
|||
DSWActor* attachActor; // attach to sprite if needed - electro snake
|
||||
DSWActor* flagOwnerActor;
|
||||
DSWActor* WpnGoalActor;
|
||||
short SpriteNum; // only needed for writing out to savegames that can be loaded by older builds.
|
||||
|
||||
int Flags;
|
||||
int Flags2;
|
||||
|
@ -1124,9 +1123,9 @@ struct USER
|
|||
short lo_step;
|
||||
int hiz,loz;
|
||||
int zclip; // z height to move up for clipmove
|
||||
int active_range;
|
||||
SECTORp hi_sectp, lo_sectp;
|
||||
|
||||
int active_range;
|
||||
|
||||
// if a player's sprite points to player structure
|
||||
PLAYERp PlayerP;
|
||||
|
@ -1388,7 +1387,6 @@ enum
|
|||
SPR2_FLAMEDIE = BIT(25), // was previously 'flame == -2'
|
||||
};
|
||||
|
||||
extern TPointer<USER> User[MAXSPRITES];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -574,9 +574,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
|
|||
("keypressbits", w.KeyPressBits)
|
||||
("chops", w.Chops);
|
||||
|
||||
if (arc.isWriting()) // we need this for loading saves in older builds for debugging.
|
||||
arc("SpriteP", w.actor);
|
||||
|
||||
|
||||
SerializeCodePtr(arc, "DoPlayerAction", (void**)&w.DoPlayerAction);
|
||||
arc.EndObject();
|
||||
|
@ -922,14 +919,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
|||
("rotator", w.rotator)
|
||||
("oz", w.oz, def->oz);
|
||||
|
||||
if (arc.isWriting()) // we need this for loading saves in older builds for debugging.
|
||||
{
|
||||
arc("SpriteP", w.SpriteNum, def->SpriteNum)
|
||||
("SpriteNum", w.SpriteNum, def->SpriteNum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
SerializeCodePtr(arc, "ActorActionFunc", (void**)&w.ActorActionFunc);
|
||||
arc.EndObject();
|
||||
|
||||
|
@ -942,35 +931,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
|||
return arc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void SerializeUser(FSerializer& arc)
|
||||
{
|
||||
FixedBitArray<MAXSPRITES> hitlist;
|
||||
|
||||
if (arc.isWriting())
|
||||
{
|
||||
for (int i = 0; i < MAXSPRITES; i++)
|
||||
{
|
||||
hitlist.Set(i, swActors[i].hasU());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < MAXSPRITES; i++)
|
||||
{
|
||||
swActors[i].clearUser();
|
||||
}
|
||||
}
|
||||
arc("usermap", hitlist);
|
||||
arc.SparseArray("user", User, MAXSPRITES, hitlist);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -1173,6 +1133,13 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK_POINT& w, TR
|
|||
return arc;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* def)
|
||||
{
|
||||
static int nul;
|
||||
|
@ -1204,6 +1171,27 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* d
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, DSWActor& w, DSWActor* def)
|
||||
{
|
||||
if (arc.isReading())
|
||||
{
|
||||
w.Clear();
|
||||
}
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
arc("hasuser", w.hasUser);
|
||||
if (w.hasUser) arc("user", w.user); // only write if defined.
|
||||
arc.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||
{
|
||||
pspAsArray.Clear();
|
||||
|
@ -1212,10 +1200,10 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
if (arc.BeginObject("state"))
|
||||
{
|
||||
preSerializePanelSprites(arc);
|
||||
SerializeUser(arc);
|
||||
SerializeSectUser(arc);
|
||||
so_serializeinterpolations(arc);
|
||||
arc("numplayers", numplayers)
|
||||
arc .SparseArray("actors", swActors, MAXSPRITES, activeSprites)
|
||||
("numplayers", numplayers)
|
||||
.Array("players", Player, numplayers)
|
||||
("skill", Skill)
|
||||
("screenpeek", screenpeek)
|
||||
|
|
|
@ -82,7 +82,6 @@ int DoTrapMatch(short match);
|
|||
PLAYERp GlobPlayerP;
|
||||
|
||||
TPointer<SECT_USER> SectUser[MAXSECTORS];
|
||||
TPointer<USER> User[MAXSPRITES];
|
||||
|
||||
ANIM Anim[MAXANIM];
|
||||
short AnimCnt = 0;
|
||||
|
|
|
@ -789,10 +789,12 @@ void KillActor(DSWActor* actor)
|
|||
sp->sectnum = sectnum;
|
||||
|
||||
// Kill references in all users - slow but unavoidable if we don't want the game to crash on stale pointers.
|
||||
for (auto& u : User)
|
||||
SWSpriteIterator it;
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
if (u.Data())
|
||||
if (actor->hasU())
|
||||
{
|
||||
auto u = actor->u();
|
||||
if (u->highActor == actor) u->highActor = nullptr;
|
||||
if (u->lowActor == actor) u->lowActor = nullptr;
|
||||
if (u->targetActor == actor) u->targetActor = nullptr;
|
||||
|
@ -885,7 +887,6 @@ USERp SpawnUser(DSWActor* actor, short id, STATEp state)
|
|||
u->targetActor = Player[0].Actor();
|
||||
u->Radius = 220;
|
||||
u->Sibling = -1;
|
||||
u->SpriteNum = actor->GetSpriteIndex();
|
||||
u->WaitTics = 0;
|
||||
u->OverlapZ = Z(4);
|
||||
u->bounce = 0;
|
||||
|
|
|
@ -9,10 +9,12 @@ class DSWActor
|
|||
{
|
||||
int index;
|
||||
DSWActor* base();
|
||||
auto& up() { return User[index]; }
|
||||
|
||||
public:
|
||||
|
||||
bool hasUser;
|
||||
USER user;
|
||||
|
||||
DSWActor() :index(int(this - base())) { /*assert(index >= 0 && index < kMaxSprites);*/ }
|
||||
DSWActor& operator=(const DSWActor& other) = default;
|
||||
|
||||
|
@ -20,21 +22,21 @@ public:
|
|||
{
|
||||
clearUser();
|
||||
}
|
||||
bool hasU() { return u() != nullptr; }
|
||||
bool hasU() { return hasUser; }
|
||||
|
||||
|
||||
spritetype& s() { return sprite[index]; }
|
||||
USER* u() { return up().Data(); }
|
||||
USER* u() { return &user; }
|
||||
USER* allocUser()
|
||||
{
|
||||
up().Alloc();
|
||||
u()->SpriteNum = GetSpriteIndex();
|
||||
hasUser = true;
|
||||
return u();
|
||||
}
|
||||
|
||||
void clearUser()
|
||||
{
|
||||
up().Clear();
|
||||
hasUser = false;
|
||||
user.Clear();
|
||||
}
|
||||
|
||||
int GetIndex()
|
||||
|
|
Loading…
Reference in a new issue