- moved around some pieces of code to make sharing with Raze easier.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:22:16 +02:00
commit cf51508ce6
21 changed files with 96 additions and 74 deletions

View file

@ -473,60 +473,6 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld)
return changed;
}
//==========================================================================
//
// This once was the main method for pointer cleanup, but
// nowadays its only use is swapping out PlayerPawns.
// This requires pointer fixing throughout all objects and a few
// global variables, but it only needs to look at pointers that
// can point to a player.
//
//==========================================================================
void DObject::StaticPointerSubstitution (AActor *old, AActor *notOld)
{
DObject *probe;
size_t changed = 0;
int i;
if (old == nullptr) return;
// This is only allowed to replace players. For everything else the results are undefined.
if (!old->IsKindOf(NAME_PlayerPawn) || (notOld != nullptr && !notOld->IsKindOf(NAME_PlayerPawn))) return;
// Go through all objects.
i = 0;DObject *last=0;
for (probe = GC::Root; probe != NULL; probe = probe->ObjNext)
{
i++;
changed += probe->PointerSubstitution(old, notOld);
last = probe;
}
// Go through players.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
{
AActor *replacement = notOld;
auto &p = players[i];
if (p.mo == old) p.mo = replacement, changed++;
if (p.poisoner.pp == old) p.poisoner = replacement, changed++;
if (p.attacker.pp == old) p.attacker = replacement, changed++;
if (p.camera.pp == old) p.camera = replacement, changed++;
if (p.ConversationNPC.pp == old) p.ConversationNPC = replacement, changed++;
if (p.ConversationPC == old) p.ConversationPC = replacement, changed++;
}
}
// Go through sectors. Only the level this actor belongs to is relevant.
for (auto &sec : old->Level->sectors)
{
if (sec.SoundTarget == old) sec.SoundTarget = notOld;
}
}
//==========================================================================
//
//

View file

@ -247,7 +247,6 @@ public:
// This is only needed for swapping out PlayerPawns and absolutely nothing else!
virtual size_t PointerSubstitution (DObject *old, DObject *notOld);
static void StaticPointerSubstitution (AActor *old, AActor *notOld);
PClass *GetClass() const
{

View file

@ -276,8 +276,6 @@ void MarkArray(DObject **obj, size_t count)
static void MarkRoot()
{
int i;
Gray = NULL;
Mark(StatusBar);
M_MarkMenus();
@ -288,7 +286,7 @@ static void MarkRoot()
Level->Mark();
// Mark players.
for (i = 0; i < MAXPLAYERS; i++)
for (int i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
players[i].PropagateMark();

View file

@ -208,6 +208,11 @@ public:
return GC::ReadBarrier(pp);
}
T ForceGet() throw() //for situations where the read barrier needs to be skipped.
{
return pp;
}
operator T() throw()
{
return GC::ReadBarrier(pp);

View file

@ -77,7 +77,7 @@ bool PClass::bVMOperational;
// that does not work anymore. WP_NOCHANGE needs to point to a vaild object to work as intended.
// This Object does not need to be garbage collected, though, but it needs to provide the proper structure so that the
// GC can process it.
AActor *WP_NOCHANGE;
DObject *WP_NOCHANGE;
DEFINE_GLOBAL(WP_NOCHANGE);
@ -231,7 +231,7 @@ void PClass::StaticInit ()
// WP_NOCHANGE must point to a valid object, although it does not need to be a weapon.
// A simple DObject is enough to give the GC the ability to deal with it, if subjected to it.
WP_NOCHANGE = (AActor*)Create<DObject>();
WP_NOCHANGE = Create<DObject>();
WP_NOCHANGE->Release();
}

View file

@ -17,14 +17,14 @@ class VMException : public DObject
// An action function -------------------------------------------------------
struct FState;
struct StateCallData;
class VMFrameStack;
struct VMValue;
struct VMReturn;
class VMFunction;
class PClassType;
struct FNamespaceManager;
class PSymbol;
class PField;
enum
{