- added GC handling for all backend pointers in the map data.

GC is not active yet!
This commit is contained in:
Christoph Oelckers 2021-12-06 00:50:33 +01:00
parent db240ea2b0
commit 0dd756fa32
13 changed files with 45 additions and 28 deletions

View file

@ -97,12 +97,12 @@ struct sectortype
{
uint8_t keyinfo;
uint8_t shadedsector;
DCoreActor* hitagactor; // we need this because Duke stores an actor in the hitag field. Is really a DDukeActor, but cannot be declared here safely.
TObjPtr<DCoreActor*> hitagactor; // we need this because Duke stores an actor in the hitag field. Is really a DDukeActor, but cannot be declared here safely.
};
struct // Blood
{
BLD_NS::XSECTOR* _xs;
DCoreActor* upperLink, *lowerLink;
TObjPtr<DCoreActor*> upperLink, lowerLink;
int baseFloor, baseCeil;
int velFloor, velCeil;
uint8_t slopewallofs;

View file

@ -186,8 +186,6 @@ class TObjPtr
public:
TObjPtr() = default;
TObjPtr(const TObjPtr<T> &q) = delete;
TObjPtr(T q) noexcept
: pp(q)
{

View file

@ -145,6 +145,7 @@ bool PreBindTexture(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flag
void highTileSetup();
void FontCharCreated(FGameTexture* base, FGameTexture* untranslated);
void LoadVoxelModels();
void MarkMap();
DStatusBarCore* StatusBar;
@ -1054,6 +1055,7 @@ int RunGame()
StartScreen->Progress();
engineInit();
GC::AddMarkerFunc(MarkMap);
gi->app_init();
StartScreen->Progress();
G_ParseMapInfo();
@ -1382,6 +1384,7 @@ void GameInterface::FreeLevelData()
sector.Reset();
wall.Reset();
currentLevel = nullptr;
GC::FullGC();
}
//---------------------------------------------------------------------------

View file

@ -526,3 +526,18 @@ void setWallSectors()
}
}
void MarkMap()
{
for (auto& sect : sectors())
{
GC::Mark(sect.firstEntry);
GC::Mark(sect.lastEntry);
if (isDukeLike()) GC::Mark(sect.hitagactor);
else if (isBlood())
{
GC::Mark(sect.upperLink);
GC::Mark(sect.lowerLink);
}
}
}

View file

@ -61,6 +61,7 @@
#include "sectorgeometry.h"
#include "d_net.h"
#include "ns.h"
#include "serialize_obj.h"
#include "games/blood/src/mapstructs.h"
#include <zlib.h>

View file

@ -4950,8 +4950,8 @@ void MoveDude(DBloodActor* actor)
if (pXSector->Underwater) bUnderwater = 1;
if (pXSector->Depth) bDepth = 1;
}
auto pUpperLink = pSector->upperLink;
auto pLowerLink = pSector->lowerLink;
DCoreActor* pUpperLink = pSector->upperLink;
DCoreActor* pLowerLink = pSector->lowerLink;
if (pUpperLink && (pUpperLink->s().type == kMarkerUpWater || pUpperLink->s().type == kMarkerUpGoo)) bDepth = 1;
if (pLowerLink && (pLowerLink->s().type == kMarkerLowWater || pLowerLink->s().type == kMarkerLowGoo)) bDepth = 1;
if (pPlayer) wd += 16;
@ -5076,7 +5076,7 @@ void MoveDude(DBloodActor* actor)
if (gModernMap)
{
pPlayer->nWaterPal = 0;
auto pUpper = static_cast<DBloodActor*>(pSector->upperLink);
auto pUpper = barrier_cast<DBloodActor*>(pSector->upperLink);
if (pUpper && pUpper->hasX()) pPlayer->nWaterPal = pUpper->x().data2;
}
#endif

View file

@ -523,7 +523,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
{
if (dz > 0)
{
auto actor = static_cast<DBloodActor*>(gHitInfo.hitSector->upperLink);
auto actor = barrier_cast<DBloodActor*>(gHitInfo.hitSector->upperLink);
if (!actor) return 2;
auto link = actor->GetOwner();
gHitInfo.clearObj();
@ -537,7 +537,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
}
else
{
auto actor = static_cast<DBloodActor*>(gHitInfo.hitSector->lowerLink);
auto actor = barrier_cast<DBloodActor*>(gHitInfo.hitSector->lowerLink);
if (!actor) return 1;
auto link = actor->GetOwner();
gHitInfo.clearObj();
@ -574,7 +574,7 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
XSECTOR *pXSector = &pSector->xs();
*floorZ += pXSector->Depth << 10;
}
auto actor = static_cast<DBloodActor*>(pSector->upperLink);
auto actor = barrier_cast<DBloodActor*>(pSector->upperLink);
if (actor)
{
auto link = actor->GetOwner();
@ -588,7 +588,7 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
auto pSector = ceilColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
*ceilZ = 0x80000000;
auto actor = static_cast<DBloodActor*>(pSector->lowerLink);
auto actor = barrier_cast<DBloodActor*>(pSector->lowerLink);
if (actor)
{
auto link = actor->GetOwner();
@ -616,7 +616,7 @@ void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collis
XSECTOR* pXSector = &pSector->xs();
*floorZ += pXSector->Depth << 10;
}
auto actor = static_cast<DBloodActor*>(pSector->upperLink);
auto actor = barrier_cast<DBloodActor*>(pSector->upperLink);
if (actor)
{
auto link = actor->GetOwner();
@ -630,7 +630,7 @@ void GetZRangeAtXYZ(int x, int y, int z, sectortype* pSector, int *ceilZ, Collis
auto pSector = ceilColl->hitSector;
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
*ceilZ = 0x80000000;
auto actor = static_cast<DBloodActor*>(pSector->lowerLink);
auto actor = barrier_cast<DBloodActor*>(pSector->lowerLink);
if (actor)
{
auto link = actor->GetOwner();

View file

@ -113,7 +113,7 @@ void InitMirrors(void)
auto secti = &sector[i];
if (secti->floorpicnum == 504)
{
auto link = static_cast<DBloodActor*>(secti->upperLink);
auto link = barrier_cast<DBloodActor*>(secti->upperLink);
if (link == nullptr)
continue;
auto link2 = link->GetOwner();

View file

@ -2840,7 +2840,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
spritetype* pUpper = NULL; XSPRITE* pXUpper = NULL;
auto aLower = static_cast<DBloodActor*>(pSector->lowerLink);
auto aLower = barrier_cast<DBloodActor*>(pSector->lowerLink);
spritetype* pLower = nullptr;
XSPRITE* pXLower = nullptr;
if (aLower)
@ -2851,7 +2851,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
// must be sure we found exact same upper link
for (auto& sec : sectors())
{
auto aUpper = static_cast<DBloodActor*>(sec.upperLink);
auto aUpper = barrier_cast<DBloodActor*>(sec.upperLink);
if (aUpper == nullptr || aUpper->x().data1 != pXLower->data1) continue;
pUpper = &aUpper->s();
pXUpper = &aUpper->x();
@ -3016,14 +3016,14 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
if (pXSector->Underwater)
{
auto aLink = static_cast<DBloodActor*>(pSource->sector()->lowerLink);
auto aLink = barrier_cast<DBloodActor*>(pSource->sector()->lowerLink);
spritetype* pLink = nullptr;
if (aLink)
{
// must be sure we found exact same upper link
for(auto& sec : sectors())
{
auto aUpper = static_cast<DBloodActor*>(sec.upperLink);
auto aUpper = barrier_cast<DBloodActor*>(sec.upperLink);
if (aUpper == nullptr || aUpper->x().data1 != aLink->x().data1) continue;
pLink = &aLink->s();
break;

View file

@ -163,7 +163,7 @@ void warpInit(TArray<DBloodActor*>& actors)
for(auto& sect : sectors())
{
auto actor = static_cast<DBloodActor*>(sect.upperLink);
auto actor = barrier_cast<DBloodActor*>(sect.upperLink);
if (actor && actor->hasX())
{
spritetype *pSprite = &actor->s();
@ -171,7 +171,7 @@ void warpInit(TArray<DBloodActor*>& actors)
int nLink = pXSprite->data1;
for(auto& sect : sectors())
{
auto actor2 = static_cast<DBloodActor*>(sect.lowerLink);
auto actor2 = barrier_cast<DBloodActor*>(sect.lowerLink);
if (actor2 && actor2->hasX())
{
spritetype *pSprite2 = &actor2->s();
@ -192,8 +192,8 @@ int CheckLink(DBloodActor *actor)
{
auto pSprite = &actor->s();
auto pSector = pSprite->sector();
auto aUpper = static_cast<DBloodActor*>(pSector->upperLink);
auto aLower = static_cast<DBloodActor*>(pSector->lowerLink);
auto aUpper = barrier_cast<DBloodActor*>(pSector->upperLink);
auto aLower = barrier_cast<DBloodActor*>(pSector->lowerLink);
if (aUpper)
{
spritetype* pUpper = &aUpper->s();
@ -253,8 +253,8 @@ int CheckLink(DBloodActor *actor)
int CheckLink(int *x, int *y, int *z, sectortype** pSector)
{
auto upper = static_cast<DBloodActor*>((*pSector)->upperLink);
auto lower = static_cast<DBloodActor*>((*pSector)->lowerLink);
auto upper = barrier_cast<DBloodActor*>((*pSector)->upperLink);
auto lower = barrier_cast<DBloodActor*>((*pSector)->lowerLink);
if (upper)
{
spritetype *pUpper = &upper->s();

View file

@ -3072,7 +3072,7 @@ HORIZONLY:
psectp = s->sector();
if (ud.clipping == 0 && psectp->lotag == 31)
{
auto secact = static_cast<DDukeActor*>(psectp->hitagactor);
auto secact = barrier_cast<DDukeActor*>(psectp->hitagactor);
if (secact && secact->s->xvel && secact->temp_data[0] == 0)
{
quickkill(p);

View file

@ -3909,7 +3909,7 @@ HORIZONLY:
psectp = s->sector();
if (ud.clipping == 0 && psectp->lotag == ST_31_TWO_WAY_TRAIN)
{
auto act = static_cast<DDukeActor*>(psectp->hitagactor);
auto act = barrier_cast<DDukeActor*>(psectp->hitagactor);
if (act && act->s->xvel && act->temp_data[0] == 0)
{
quickkill(p);

View file

@ -980,7 +980,7 @@ void operatesectors(sectortype* sptr, DDukeActor *actor)
case ST_30_ROTATE_RISE_BRIDGE:
{
auto act = static_cast<DDukeActor*>(sptr->hitagactor);
auto act = barrier_cast<DDukeActor*>(sptr->hitagactor);
if (!act) break;
if (act->tempang == 0 || act->tempang == 256) callsound(sptr, actor);
if (act->s->extra == 1) act->s->extra = 3;
@ -990,7 +990,7 @@ void operatesectors(sectortype* sptr, DDukeActor *actor)
case ST_31_TWO_WAY_TRAIN:
{
auto act = static_cast<DDukeActor*>(sptr->hitagactor);
auto act = barrier_cast<DDukeActor*>(sptr->hitagactor);
if (!act) break;
if (act->temp_data[4] == 0)
act->temp_data[4] = 1;