mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-21 11:01:01 +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;
|
int SpriteNum = tsprite[tSpriteNum].owner;
|
||||||
auto tActor = &swActors[SpriteNum];
|
auto tActor = &swActors[SpriteNum];
|
||||||
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
tspriteptr_t tsp = &tsprite[tSpriteNum];
|
||||||
tu = tActor->u();
|
tu = tActor->hasU()? tActor->u() : nullptr;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Brighten up the sprite if set somewhere else to do so
|
// 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* attachActor; // attach to sprite if needed - electro snake
|
||||||
DSWActor* flagOwnerActor;
|
DSWActor* flagOwnerActor;
|
||||||
DSWActor* WpnGoalActor;
|
DSWActor* WpnGoalActor;
|
||||||
short SpriteNum; // only needed for writing out to savegames that can be loaded by older builds.
|
|
||||||
|
|
||||||
int Flags;
|
int Flags;
|
||||||
int Flags2;
|
int Flags2;
|
||||||
|
@ -1124,9 +1123,9 @@ struct USER
|
||||||
short lo_step;
|
short lo_step;
|
||||||
int hiz,loz;
|
int hiz,loz;
|
||||||
int zclip; // z height to move up for clipmove
|
int zclip; // z height to move up for clipmove
|
||||||
|
int active_range;
|
||||||
SECTORp hi_sectp, lo_sectp;
|
SECTORp hi_sectp, lo_sectp;
|
||||||
|
|
||||||
int active_range;
|
|
||||||
|
|
||||||
// if a player's sprite points to player structure
|
// if a player's sprite points to player structure
|
||||||
PLAYERp PlayerP;
|
PLAYERp PlayerP;
|
||||||
|
@ -1388,7 +1387,6 @@ enum
|
||||||
SPR2_FLAMEDIE = BIT(25), // was previously 'flame == -2'
|
SPR2_FLAMEDIE = BIT(25), // was previously 'flame == -2'
|
||||||
};
|
};
|
||||||
|
|
||||||
extern TPointer<USER> User[MAXSPRITES];
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -574,9 +574,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
|
||||||
("keypressbits", w.KeyPressBits)
|
("keypressbits", w.KeyPressBits)
|
||||||
("chops", w.Chops);
|
("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);
|
SerializeCodePtr(arc, "DoPlayerAction", (void**)&w.DoPlayerAction);
|
||||||
arc.EndObject();
|
arc.EndObject();
|
||||||
|
@ -922,14 +919,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
||||||
("rotator", w.rotator)
|
("rotator", w.rotator)
|
||||||
("oz", w.oz, def->oz);
|
("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);
|
SerializeCodePtr(arc, "ActorActionFunc", (void**)&w.ActorActionFunc);
|
||||||
arc.EndObject();
|
arc.EndObject();
|
||||||
|
|
||||||
|
@ -942,35 +931,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, USER& w, USER* def
|
||||||
return arc;
|
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;
|
return arc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* def)
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, TRACK& w, TRACK* def)
|
||||||
{
|
{
|
||||||
static int nul;
|
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)
|
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
{
|
{
|
||||||
pspAsArray.Clear();
|
pspAsArray.Clear();
|
||||||
|
@ -1212,10 +1200,10 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
||||||
if (arc.BeginObject("state"))
|
if (arc.BeginObject("state"))
|
||||||
{
|
{
|
||||||
preSerializePanelSprites(arc);
|
preSerializePanelSprites(arc);
|
||||||
SerializeUser(arc);
|
|
||||||
SerializeSectUser(arc);
|
SerializeSectUser(arc);
|
||||||
so_serializeinterpolations(arc);
|
so_serializeinterpolations(arc);
|
||||||
arc("numplayers", numplayers)
|
arc .SparseArray("actors", swActors, MAXSPRITES, activeSprites)
|
||||||
|
("numplayers", numplayers)
|
||||||
.Array("players", Player, numplayers)
|
.Array("players", Player, numplayers)
|
||||||
("skill", Skill)
|
("skill", Skill)
|
||||||
("screenpeek", screenpeek)
|
("screenpeek", screenpeek)
|
||||||
|
|
|
@ -82,7 +82,6 @@ int DoTrapMatch(short match);
|
||||||
PLAYERp GlobPlayerP;
|
PLAYERp GlobPlayerP;
|
||||||
|
|
||||||
TPointer<SECT_USER> SectUser[MAXSECTORS];
|
TPointer<SECT_USER> SectUser[MAXSECTORS];
|
||||||
TPointer<USER> User[MAXSPRITES];
|
|
||||||
|
|
||||||
ANIM Anim[MAXANIM];
|
ANIM Anim[MAXANIM];
|
||||||
short AnimCnt = 0;
|
short AnimCnt = 0;
|
||||||
|
|
|
@ -789,10 +789,12 @@ void KillActor(DSWActor* actor)
|
||||||
sp->sectnum = sectnum;
|
sp->sectnum = sectnum;
|
||||||
|
|
||||||
// Kill references in all users - slow but unavoidable if we don't want the game to crash on stale pointers.
|
// 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->highActor == actor) u->highActor = nullptr;
|
||||||
if (u->lowActor == actor) u->lowActor = nullptr;
|
if (u->lowActor == actor) u->lowActor = nullptr;
|
||||||
if (u->targetActor == actor) u->targetActor = 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->targetActor = Player[0].Actor();
|
||||||
u->Radius = 220;
|
u->Radius = 220;
|
||||||
u->Sibling = -1;
|
u->Sibling = -1;
|
||||||
u->SpriteNum = actor->GetSpriteIndex();
|
|
||||||
u->WaitTics = 0;
|
u->WaitTics = 0;
|
||||||
u->OverlapZ = Z(4);
|
u->OverlapZ = Z(4);
|
||||||
u->bounce = 0;
|
u->bounce = 0;
|
||||||
|
|
|
@ -9,10 +9,12 @@ class DSWActor
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
DSWActor* base();
|
DSWActor* base();
|
||||||
auto& up() { return User[index]; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
bool hasUser;
|
||||||
|
USER user;
|
||||||
|
|
||||||
DSWActor() :index(int(this - base())) { /*assert(index >= 0 && index < kMaxSprites);*/ }
|
DSWActor() :index(int(this - base())) { /*assert(index >= 0 && index < kMaxSprites);*/ }
|
||||||
DSWActor& operator=(const DSWActor& other) = default;
|
DSWActor& operator=(const DSWActor& other) = default;
|
||||||
|
|
||||||
|
@ -20,21 +22,21 @@ public:
|
||||||
{
|
{
|
||||||
clearUser();
|
clearUser();
|
||||||
}
|
}
|
||||||
bool hasU() { return u() != nullptr; }
|
bool hasU() { return hasUser; }
|
||||||
|
|
||||||
|
|
||||||
spritetype& s() { return sprite[index]; }
|
spritetype& s() { return sprite[index]; }
|
||||||
USER* u() { return up().Data(); }
|
USER* u() { return &user; }
|
||||||
USER* allocUser()
|
USER* allocUser()
|
||||||
{
|
{
|
||||||
up().Alloc();
|
hasUser = true;
|
||||||
u()->SpriteNum = GetSpriteIndex();
|
|
||||||
return u();
|
return u();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearUser()
|
void clearUser()
|
||||||
{
|
{
|
||||||
up().Clear();
|
hasUser = false;
|
||||||
|
user.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetIndex()
|
int GetIndex()
|
||||||
|
|
Loading…
Reference in a new issue