mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-04 11:11:04 +00:00
- added GC handling for all backend pointers in the map data.
GC is not active yet!
This commit is contained in:
parent
db240ea2b0
commit
0dd756fa32
13 changed files with 45 additions and 28 deletions
|
@ -97,12 +97,12 @@ struct sectortype
|
||||||
{
|
{
|
||||||
uint8_t keyinfo;
|
uint8_t keyinfo;
|
||||||
uint8_t shadedsector;
|
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
|
struct // Blood
|
||||||
{
|
{
|
||||||
BLD_NS::XSECTOR* _xs;
|
BLD_NS::XSECTOR* _xs;
|
||||||
DCoreActor* upperLink, *lowerLink;
|
TObjPtr<DCoreActor*> upperLink, lowerLink;
|
||||||
int baseFloor, baseCeil;
|
int baseFloor, baseCeil;
|
||||||
int velFloor, velCeil;
|
int velFloor, velCeil;
|
||||||
uint8_t slopewallofs;
|
uint8_t slopewallofs;
|
||||||
|
|
|
@ -186,8 +186,6 @@ class TObjPtr
|
||||||
public:
|
public:
|
||||||
TObjPtr() = default;
|
TObjPtr() = default;
|
||||||
|
|
||||||
TObjPtr(const TObjPtr<T> &q) = delete;
|
|
||||||
|
|
||||||
TObjPtr(T q) noexcept
|
TObjPtr(T q) noexcept
|
||||||
: pp(q)
|
: pp(q)
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,6 +145,7 @@ bool PreBindTexture(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flag
|
||||||
void highTileSetup();
|
void highTileSetup();
|
||||||
void FontCharCreated(FGameTexture* base, FGameTexture* untranslated);
|
void FontCharCreated(FGameTexture* base, FGameTexture* untranslated);
|
||||||
void LoadVoxelModels();
|
void LoadVoxelModels();
|
||||||
|
void MarkMap();
|
||||||
|
|
||||||
DStatusBarCore* StatusBar;
|
DStatusBarCore* StatusBar;
|
||||||
|
|
||||||
|
@ -1054,6 +1055,7 @@ int RunGame()
|
||||||
StartScreen->Progress();
|
StartScreen->Progress();
|
||||||
|
|
||||||
engineInit();
|
engineInit();
|
||||||
|
GC::AddMarkerFunc(MarkMap);
|
||||||
gi->app_init();
|
gi->app_init();
|
||||||
StartScreen->Progress();
|
StartScreen->Progress();
|
||||||
G_ParseMapInfo();
|
G_ParseMapInfo();
|
||||||
|
@ -1382,6 +1384,7 @@ void GameInterface::FreeLevelData()
|
||||||
sector.Reset();
|
sector.Reset();
|
||||||
wall.Reset();
|
wall.Reset();
|
||||||
currentLevel = nullptr;
|
currentLevel = nullptr;
|
||||||
|
GC::FullGC();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
#include "sectorgeometry.h"
|
#include "sectorgeometry.h"
|
||||||
#include "d_net.h"
|
#include "d_net.h"
|
||||||
#include "ns.h"
|
#include "ns.h"
|
||||||
|
#include "serialize_obj.h"
|
||||||
#include "games/blood/src/mapstructs.h"
|
#include "games/blood/src/mapstructs.h"
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
|
@ -4950,8 +4950,8 @@ void MoveDude(DBloodActor* actor)
|
||||||
if (pXSector->Underwater) bUnderwater = 1;
|
if (pXSector->Underwater) bUnderwater = 1;
|
||||||
if (pXSector->Depth) bDepth = 1;
|
if (pXSector->Depth) bDepth = 1;
|
||||||
}
|
}
|
||||||
auto pUpperLink = pSector->upperLink;
|
DCoreActor* pUpperLink = pSector->upperLink;
|
||||||
auto pLowerLink = pSector->lowerLink;
|
DCoreActor* pLowerLink = pSector->lowerLink;
|
||||||
if (pUpperLink && (pUpperLink->s().type == kMarkerUpWater || pUpperLink->s().type == kMarkerUpGoo)) bDepth = 1;
|
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 (pLowerLink && (pLowerLink->s().type == kMarkerLowWater || pLowerLink->s().type == kMarkerLowGoo)) bDepth = 1;
|
||||||
if (pPlayer) wd += 16;
|
if (pPlayer) wd += 16;
|
||||||
|
@ -5076,7 +5076,7 @@ void MoveDude(DBloodActor* actor)
|
||||||
if (gModernMap)
|
if (gModernMap)
|
||||||
{
|
{
|
||||||
pPlayer->nWaterPal = 0;
|
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;
|
if (pUpper && pUpper->hasX()) pPlayer->nWaterPal = pUpper->x().data2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -523,7 +523,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
|
||||||
{
|
{
|
||||||
if (dz > 0)
|
if (dz > 0)
|
||||||
{
|
{
|
||||||
auto actor = static_cast<DBloodActor*>(gHitInfo.hitSector->upperLink);
|
auto actor = barrier_cast<DBloodActor*>(gHitInfo.hitSector->upperLink);
|
||||||
if (!actor) return 2;
|
if (!actor) return 2;
|
||||||
auto link = actor->GetOwner();
|
auto link = actor->GetOwner();
|
||||||
gHitInfo.clearObj();
|
gHitInfo.clearObj();
|
||||||
|
@ -537,7 +537,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto actor = static_cast<DBloodActor*>(gHitInfo.hitSector->lowerLink);
|
auto actor = barrier_cast<DBloodActor*>(gHitInfo.hitSector->lowerLink);
|
||||||
if (!actor) return 1;
|
if (!actor) return 1;
|
||||||
auto link = actor->GetOwner();
|
auto link = actor->GetOwner();
|
||||||
gHitInfo.clearObj();
|
gHitInfo.clearObj();
|
||||||
|
@ -574,7 +574,7 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
|
||||||
XSECTOR *pXSector = &pSector->xs();
|
XSECTOR *pXSector = &pSector->xs();
|
||||||
*floorZ += pXSector->Depth << 10;
|
*floorZ += pXSector->Depth << 10;
|
||||||
}
|
}
|
||||||
auto actor = static_cast<DBloodActor*>(pSector->upperLink);
|
auto actor = barrier_cast<DBloodActor*>(pSector->upperLink);
|
||||||
if (actor)
|
if (actor)
|
||||||
{
|
{
|
||||||
auto link = actor->GetOwner();
|
auto link = actor->GetOwner();
|
||||||
|
@ -588,7 +588,7 @@ void GetZRange(DBloodActor *actor, int *ceilZ, Collision *ceilColl, int *floorZ,
|
||||||
auto pSector = ceilColl->hitSector;
|
auto pSector = ceilColl->hitSector;
|
||||||
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
|
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
|
||||||
*ceilZ = 0x80000000;
|
*ceilZ = 0x80000000;
|
||||||
auto actor = static_cast<DBloodActor*>(pSector->lowerLink);
|
auto actor = barrier_cast<DBloodActor*>(pSector->lowerLink);
|
||||||
if (actor)
|
if (actor)
|
||||||
{
|
{
|
||||||
auto link = actor->GetOwner();
|
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();
|
XSECTOR* pXSector = &pSector->xs();
|
||||||
*floorZ += pXSector->Depth << 10;
|
*floorZ += pXSector->Depth << 10;
|
||||||
}
|
}
|
||||||
auto actor = static_cast<DBloodActor*>(pSector->upperLink);
|
auto actor = barrier_cast<DBloodActor*>(pSector->upperLink);
|
||||||
if (actor)
|
if (actor)
|
||||||
{
|
{
|
||||||
auto link = actor->GetOwner();
|
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;
|
auto pSector = ceilColl->hitSector;
|
||||||
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
|
if ((nClipParallax & PARALLAXCLIP_CEILING) == 0 && (pSector->ceilingstat & 1))
|
||||||
*ceilZ = 0x80000000;
|
*ceilZ = 0x80000000;
|
||||||
auto actor = static_cast<DBloodActor*>(pSector->lowerLink);
|
auto actor = barrier_cast<DBloodActor*>(pSector->lowerLink);
|
||||||
if (actor)
|
if (actor)
|
||||||
{
|
{
|
||||||
auto link = actor->GetOwner();
|
auto link = actor->GetOwner();
|
||||||
|
|
|
@ -113,7 +113,7 @@ void InitMirrors(void)
|
||||||
auto secti = §or[i];
|
auto secti = §or[i];
|
||||||
if (secti->floorpicnum == 504)
|
if (secti->floorpicnum == 504)
|
||||||
{
|
{
|
||||||
auto link = static_cast<DBloodActor*>(secti->upperLink);
|
auto link = barrier_cast<DBloodActor*>(secti->upperLink);
|
||||||
if (link == nullptr)
|
if (link == nullptr)
|
||||||
continue;
|
continue;
|
||||||
auto link2 = link->GetOwner();
|
auto link2 = link->GetOwner();
|
||||||
|
|
|
@ -2840,7 +2840,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
|
||||||
|
|
||||||
spritetype* pUpper = NULL; XSPRITE* pXUpper = NULL;
|
spritetype* pUpper = NULL; XSPRITE* pXUpper = NULL;
|
||||||
|
|
||||||
auto aLower = static_cast<DBloodActor*>(pSector->lowerLink);
|
auto aLower = barrier_cast<DBloodActor*>(pSector->lowerLink);
|
||||||
spritetype* pLower = nullptr;
|
spritetype* pLower = nullptr;
|
||||||
XSPRITE* pXLower = nullptr;
|
XSPRITE* pXLower = nullptr;
|
||||||
if (aLower)
|
if (aLower)
|
||||||
|
@ -2851,7 +2851,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
|
||||||
// must be sure we found exact same upper link
|
// must be sure we found exact same upper link
|
||||||
for (auto& sec : sectors())
|
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;
|
if (aUpper == nullptr || aUpper->x().data1 != pXLower->data1) continue;
|
||||||
pUpper = &aUpper->s();
|
pUpper = &aUpper->s();
|
||||||
pXUpper = &aUpper->x();
|
pXUpper = &aUpper->x();
|
||||||
|
@ -3016,14 +3016,14 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
|
||||||
|
|
||||||
if (pXSector->Underwater)
|
if (pXSector->Underwater)
|
||||||
{
|
{
|
||||||
auto aLink = static_cast<DBloodActor*>(pSource->sector()->lowerLink);
|
auto aLink = barrier_cast<DBloodActor*>(pSource->sector()->lowerLink);
|
||||||
spritetype* pLink = nullptr;
|
spritetype* pLink = nullptr;
|
||||||
if (aLink)
|
if (aLink)
|
||||||
{
|
{
|
||||||
// must be sure we found exact same upper link
|
// must be sure we found exact same upper link
|
||||||
for(auto& sec : sectors())
|
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;
|
if (aUpper == nullptr || aUpper->x().data1 != aLink->x().data1) continue;
|
||||||
pLink = &aLink->s();
|
pLink = &aLink->s();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -163,7 +163,7 @@ void warpInit(TArray<DBloodActor*>& actors)
|
||||||
|
|
||||||
for(auto& sect : sectors())
|
for(auto& sect : sectors())
|
||||||
{
|
{
|
||||||
auto actor = static_cast<DBloodActor*>(sect.upperLink);
|
auto actor = barrier_cast<DBloodActor*>(sect.upperLink);
|
||||||
if (actor && actor->hasX())
|
if (actor && actor->hasX())
|
||||||
{
|
{
|
||||||
spritetype *pSprite = &actor->s();
|
spritetype *pSprite = &actor->s();
|
||||||
|
@ -171,7 +171,7 @@ void warpInit(TArray<DBloodActor*>& actors)
|
||||||
int nLink = pXSprite->data1;
|
int nLink = pXSprite->data1;
|
||||||
for(auto& sect : sectors())
|
for(auto& sect : sectors())
|
||||||
{
|
{
|
||||||
auto actor2 = static_cast<DBloodActor*>(sect.lowerLink);
|
auto actor2 = barrier_cast<DBloodActor*>(sect.lowerLink);
|
||||||
if (actor2 && actor2->hasX())
|
if (actor2 && actor2->hasX())
|
||||||
{
|
{
|
||||||
spritetype *pSprite2 = &actor2->s();
|
spritetype *pSprite2 = &actor2->s();
|
||||||
|
@ -192,8 +192,8 @@ int CheckLink(DBloodActor *actor)
|
||||||
{
|
{
|
||||||
auto pSprite = &actor->s();
|
auto pSprite = &actor->s();
|
||||||
auto pSector = pSprite->sector();
|
auto pSector = pSprite->sector();
|
||||||
auto aUpper = static_cast<DBloodActor*>(pSector->upperLink);
|
auto aUpper = barrier_cast<DBloodActor*>(pSector->upperLink);
|
||||||
auto aLower = static_cast<DBloodActor*>(pSector->lowerLink);
|
auto aLower = barrier_cast<DBloodActor*>(pSector->lowerLink);
|
||||||
if (aUpper)
|
if (aUpper)
|
||||||
{
|
{
|
||||||
spritetype* pUpper = &aUpper->s();
|
spritetype* pUpper = &aUpper->s();
|
||||||
|
@ -253,8 +253,8 @@ int CheckLink(DBloodActor *actor)
|
||||||
|
|
||||||
int CheckLink(int *x, int *y, int *z, sectortype** pSector)
|
int CheckLink(int *x, int *y, int *z, sectortype** pSector)
|
||||||
{
|
{
|
||||||
auto upper = static_cast<DBloodActor*>((*pSector)->upperLink);
|
auto upper = barrier_cast<DBloodActor*>((*pSector)->upperLink);
|
||||||
auto lower = static_cast<DBloodActor*>((*pSector)->lowerLink);
|
auto lower = barrier_cast<DBloodActor*>((*pSector)->lowerLink);
|
||||||
if (upper)
|
if (upper)
|
||||||
{
|
{
|
||||||
spritetype *pUpper = &upper->s();
|
spritetype *pUpper = &upper->s();
|
||||||
|
|
|
@ -3072,7 +3072,7 @@ HORIZONLY:
|
||||||
psectp = s->sector();
|
psectp = s->sector();
|
||||||
if (ud.clipping == 0 && psectp->lotag == 31)
|
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)
|
if (secact && secact->s->xvel && secact->temp_data[0] == 0)
|
||||||
{
|
{
|
||||||
quickkill(p);
|
quickkill(p);
|
||||||
|
|
|
@ -3909,7 +3909,7 @@ HORIZONLY:
|
||||||
psectp = s->sector();
|
psectp = s->sector();
|
||||||
if (ud.clipping == 0 && psectp->lotag == ST_31_TWO_WAY_TRAIN)
|
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)
|
if (act && act->s->xvel && act->temp_data[0] == 0)
|
||||||
{
|
{
|
||||||
quickkill(p);
|
quickkill(p);
|
||||||
|
|
|
@ -980,7 +980,7 @@ void operatesectors(sectortype* sptr, DDukeActor *actor)
|
||||||
|
|
||||||
case ST_30_ROTATE_RISE_BRIDGE:
|
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) break;
|
||||||
if (act->tempang == 0 || act->tempang == 256) callsound(sptr, actor);
|
if (act->tempang == 0 || act->tempang == 256) callsound(sptr, actor);
|
||||||
if (act->s->extra == 1) act->s->extra = 3;
|
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:
|
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) break;
|
||||||
if (act->temp_data[4] == 0)
|
if (act->temp_data[4] == 0)
|
||||||
act->temp_data[4] = 1;
|
act->temp_data[4] = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue