- GC support in SW.

- SW GC WIP
This commit is contained in:
Christoph Oelckers 2021-12-06 00:35:12 +01:00
parent 6cb260d916
commit db240ea2b0
8 changed files with 104 additions and 38 deletions

View file

@ -32,6 +32,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "names2.h"
#include "panel.h"
#include "game.h"
#include "swactor.h"
#include "interpso.h"
#include "tags.h"
#include "sector.h"
@ -102,6 +103,48 @@ IMPLEMENT_POINTER(user.attachActor)
IMPLEMENT_POINTER(user.WpnGoalActor)
IMPLEMENT_POINTERS_END
void MarkSOInterp();
void markgcroots()
{
MarkSOInterp();
GC::MarkArray(StarQueue, MAX_STAR_QUEUE);
GC::MarkArray(HoleQueue, MAX_HOLE_QUEUE);
GC::MarkArray(WallBloodQueue, MAX_WALLBLOOD_QUEUE);
GC::MarkArray(FloorBloodQueue, MAX_FLOORBLOOD_QUEUE);
GC::MarkArray(GenericQueue, MAX_GENERIC_QUEUE);
GC::MarkArray(LoWangsQueue, MAX_LOWANGS_QUEUE);
GC::MarkArray(BossSpriteNum, 3);
for (auto& pl : Player)
{
GC::Mark(pl.actor);
GC::Mark(pl.lowActor);
GC::Mark(pl.highActor);
GC::Mark(pl.remoteActor);
GC::Mark(pl.PlayerUnderActor);
GC::Mark(pl.KillerActor);
GC::Mark(pl.HitBy);
GC::Mark(pl.last_camera_act);
}
for (auto& so : SectorObject)
{
GC::Mark(so.controller);
GC::Mark(so.sp_child);
GC::MarkArray(so.so_actors, MAX_SO_SPRITE);
GC::Mark(so.match_event_actor);
}
for (int i = 0; i < AnimCnt; i++)
{
GC::Mark(Anim[i].animactor);
}
for (auto& mir : mirror)
{
GC::Mark(mir.cameraActor);
GC::Mark(mir.camspriteActor);
}
}
void pClearSpriteList(PLAYERp pp);
extern int sw_snd_scratch;
@ -191,6 +234,7 @@ void GameInterface::LoadGameTextures()
void GameInterface::app_init()
{
SetupActors(RUNTIME_CLASS(DSWActor));
GC::AddMarkerFunc(markgcroots);
GameTicRate = TICS_PER_SEC / synctics;
InitCheats();

View file

@ -51,6 +51,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "gamestruct.h"
#include "packet.h"
#include "gameinput.h"
#include "serialize_obj.h"
EXTERN_CVAR(Bool, sw_ninjahack)
EXTERN_CVAR(Bool, sw_darts)
@ -731,14 +732,15 @@ struct PLAYERstruct
vec3_t pos;
};
DSWActor* actor;
DSWActor* lowActor, * highActor;
DSWActor* remoteActor;
DSWActor* PlayerUnderActor;
DSWActor* KillerActor; //who killed me
DSWActor* HitBy; // Sprite num of whatever player was last hit by
TObjPtr<DSWActor*> actor;
TObjPtr<DSWActor*> lowActor, highActor;
TObjPtr<DSWActor*> remoteActor;
TObjPtr<DSWActor*> PlayerUnderActor;
TObjPtr<DSWActor*> KillerActor; //who killed me
TObjPtr<DSWActor*> HitBy; // Sprite num of whatever player was last hit by
TObjPtr<DSWActor*> last_camera_act;
DSWActor* Actor() const
DSWActor* Actor()
{
return actor;
}
@ -761,7 +763,6 @@ struct PLAYERstruct
int ceiling_dist,floor_dist;
SECTORp hi_sectp, lo_sectp;
DSWActor* last_camera_act;
int circle_camera_dist;
int six,siy,siz; // save player interp position for PlayerSprite
int16_t siang;
@ -1093,12 +1094,12 @@ struct USER
// sector object - contains info for the SO
// referenced actors
DSWActor* lowActor, * highActor;
DSWActor* targetActor; // target player for the enemy - can only handle one player at at time
DSWActor* flameActor;
DSWActor* attachActor; // attach to sprite if needed - electro snake
DSWActor* flagOwnerActor;
DSWActor* WpnGoalActor;
TObjPtr<DSWActor*> lowActor, highActor;
TObjPtr<DSWActor*> targetActor; // target player for the enemy - can only handle one player at at time
TObjPtr<DSWActor*> flameActor;
TObjPtr<DSWActor*> attachActor; // attach to sprite if needed - electro snake
TObjPtr<DSWActor*> flagOwnerActor;
TObjPtr<DSWActor*> WpnGoalActor;
int Flags;
int Flags2;
@ -1625,9 +1626,9 @@ struct SECTOR_OBJECTstruct
soANIMATORp PreMoveAnimator;
soANIMATORp PostMoveAnimator;
soANIMATORp Animator;
DSWActor* controller;
TObjPtr<DSWActor*> controller;
DSWActor* sp_child; // child sprite that holds info for the sector object
TObjPtr<DSWActor*> sp_child; // child sprite that holds info for the sector object
union
{
@ -1635,8 +1636,8 @@ struct SECTOR_OBJECTstruct
vec3_t pmid;
};
DSWActor* so_actors[MAX_SO_SPRITE]; // hold the actors of the object
DSWActor* match_event_actor; // spritenum of the match event sprite
TObjPtr<DSWActor*> so_actors[MAX_SO_SPRITE]; // hold the actors of the object
TObjPtr<DSWActor*> match_event_actor; // spritenum of the match event sprite
sectortype
*sectp[MAX_SO_SECTOR],
@ -2240,12 +2241,13 @@ struct ANIMstruct
int goal;
int vel;
short vel_adj;
DSWActor* animactor;
TObjPtr<DSWActor*> animactor;
ANIM_CALLBACKp callback;
SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier.
int& Addr()
{
static int scratch;
switch (animtype)
{
case ANIM_Floorz:
@ -2253,9 +2255,11 @@ struct ANIMstruct
case ANIM_SopZ:
return SectorObject[animindex].zmid;
case ANIM_Spritez:
if (animactor == nullptr) return scratch;
return animactor->s().z;
case ANIM_Userz:
return animactor->u()->sz;
if (animactor == nullptr) return scratch;
return animactor->u()->sz;
case ANIM_SUdepth:
return sector[animindex].depth_fixed;
default:

View file

@ -61,7 +61,7 @@ static struct so_interp
int32_t lastipos;
int32_t lastoldipos;
int32_t lastangdiff;
DSWActor* actorofang;
TObjPtr<DSWActor*> actorofang;
} data[SO_MAXINTERPOLATIONS];
int32_t numinterpolations;
@ -69,6 +69,25 @@ static struct so_interp
bool hasvator;
} so_interpdata[MAX_SECTOR_OBJECTS];
void MarkSOInterp()
{
int32_t i;
SECTOR_OBJECTp sop;
so_interp* interp;
so_interp::interp_data* data;
for (sop = SectorObject, interp = so_interpdata;
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
{
if (SO_EMPTY(sop))
continue;
for (i = 0, data = interp->data; i < interp->numinterpolations; i++, data++)
{
GC::Mark(data->actorofang);
}
}
}
static int &getvalue(so_interp::interp_data& element, bool write)
{
static int scratch;

View file

@ -40,8 +40,8 @@ typedef enum
typedef struct
{
DSWActor* cameraActor; // Contains number of ST1 sprite used as a camera
DSWActor* camspriteActor; // sprite pointing to campic
TObjPtr<DSWActor*> cameraActor; // Contains number of ST1 sprite used as a camera
TObjPtr<DSWActor*> camspriteActor; // sprite pointing to campic
walltype* mirrorWall; // Wall number containing the mirror tile
sectortype* mirrorSector; // used internally to draw mirror rooms
short campic; // Editart tile number to draw a screen to

View file

@ -591,7 +591,7 @@ void SetOwner(DSWActor* ownr, DSWActor* child, bool flag)
DSWActor* GetOwner(DSWActor* child)
{
return child ? child->ownerActor : nullptr;
return child ? child->ownerActor.Get() : nullptr;
}
void ClearOwner(DSWActor* child)

View file

@ -15,7 +15,7 @@ public:
bool hasUser;
USER user;
walltype* tempwall; // transient, to replace a hack using a 16 bit sprite field.
DSWActor* ownerActor;
TObjPtr<DSWActor*> ownerActor;
DSWActor() = default;
DSWActor& operator=(const DSWActor& other) = default;
@ -43,7 +43,6 @@ public:
}
void Serialize(FSerializer& arc) override;
};

View file

@ -72,17 +72,17 @@ int ShellCount = 0;
//int Zombies = 0;
int StarQueueHead=0;
DSWActor* StarQueue[MAX_STAR_QUEUE];
TObjPtr<DSWActor*> StarQueue[MAX_STAR_QUEUE];
int HoleQueueHead=0;
DSWActor* HoleQueue[MAX_HOLE_QUEUE];
TObjPtr<DSWActor*> HoleQueue[MAX_HOLE_QUEUE];
int WallBloodQueueHead=0;
DSWActor* WallBloodQueue[MAX_WALLBLOOD_QUEUE];
TObjPtr<DSWActor*> WallBloodQueue[MAX_WALLBLOOD_QUEUE];
int FloorBloodQueueHead=0;
DSWActor* FloorBloodQueue[MAX_FLOORBLOOD_QUEUE];
TObjPtr<DSWActor*> FloorBloodQueue[MAX_FLOORBLOOD_QUEUE];
int GenericQueueHead=0;
DSWActor* GenericQueue[MAX_GENERIC_QUEUE];
TObjPtr<DSWActor*> GenericQueue[MAX_GENERIC_QUEUE];
int LoWangsQueueHead=0;
DSWActor* LoWangsQueue[MAX_LOWANGS_QUEUE];
TObjPtr<DSWActor*> LoWangsQueue[MAX_LOWANGS_QUEUE];
void SpawnBreakStaticFlames(DSWActor* actor);
bool GlobalSkipZrange = false;

View file

@ -59,17 +59,17 @@ enum
extern int StarQueueHead;
extern DSWActor* StarQueue[MAX_STAR_QUEUE];
extern TObjPtr<DSWActor*> StarQueue[MAX_STAR_QUEUE];
extern int HoleQueueHead;
extern DSWActor* HoleQueue[MAX_HOLE_QUEUE];
extern TObjPtr<DSWActor*> HoleQueue[MAX_HOLE_QUEUE];
extern int WallBloodQueueHead;
extern DSWActor* WallBloodQueue[MAX_WALLBLOOD_QUEUE];
extern TObjPtr<DSWActor*> WallBloodQueue[MAX_WALLBLOOD_QUEUE];
extern int FloorBloodQueueHead;
extern DSWActor* FloorBloodQueue[MAX_FLOORBLOOD_QUEUE];
extern TObjPtr<DSWActor*> FloorBloodQueue[MAX_FLOORBLOOD_QUEUE];
extern int GenericQueueHead;
extern DSWActor* GenericQueue[MAX_GENERIC_QUEUE];
extern TObjPtr<DSWActor*> GenericQueue[MAX_GENERIC_QUEUE];
extern int LoWangsQueueHead;
extern DSWActor* LoWangsQueue[MAX_LOWANGS_QUEUE];
extern TObjPtr<DSWActor*> LoWangsQueue[MAX_LOWANGS_QUEUE];
void ChangeState(DSWActor* actor, STATEp statep);
void DoPlayerBeginRecoil(PLAYERp pp, short pix_amt);