- avoid double linking to and unlinking from the world for actors.

Some people apparently have to toy around with the engine's innards without fully understanding them. :(
When properly used the saveguards should never be triggered.
This commit is contained in:
Christoph Oelckers 2020-09-26 19:09:00 +02:00
parent 084c2cc7f5
commit 8fc9f1e5ef
3 changed files with 15 additions and 1 deletions

View File

@ -414,6 +414,7 @@ enum ActorFlag8
MF8_STOPRAILS = 0x00000200, // [MC] Prevent rails from going further if an actor has this flag. MF8_STOPRAILS = 0x00000200, // [MC] Prevent rails from going further if an actor has this flag.
MF8_ABSVIEWANGLES = 0x00000400, // [MC] By default view angle/pitch/roll is an offset. This will make it absolute instead. MF8_ABSVIEWANGLES = 0x00000400, // [MC] By default view angle/pitch/roll is an offset. This will make it absolute instead.
MF8_FALLDAMAGE = 0x00000800, // Monster will take fall damage regardless of map settings. MF8_FALLDAMAGE = 0x00000800, // Monster will take fall damage regardless of map settings.
MF8_LINKEDTOWORLD = 0x00010000, // actor is currently linked to the blockmap and sector chain.
}; };

View File

@ -286,6 +286,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co
void AActor::UnlinkFromWorld (FLinkContext *ctx) void AActor::UnlinkFromWorld (FLinkContext *ctx)
{ {
if (ctx != nullptr) ctx->sector_list = nullptr; if (ctx != nullptr) ctx->sector_list = nullptr;
if (!(flags8 & MF8_LINKEDTOWORLD))
{
//assert(false);
return;
}
flags8 &= ~MF8_LINKEDTOWORLD;
if (!(flags & MF_NOSECTOR)) if (!(flags & MF_NOSECTOR))
{ {
// invisible things don't need to be in sector list // invisible things don't need to be in sector list
@ -443,6 +449,12 @@ bool AActor::FixMapthingPos()
void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sector) void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sector)
{ {
if (flags8 & MF8_LINKEDTOWORLD)
{
//assert(false);
return;
}
bool spawning = spawningmapthing; bool spawning = spawningmapthing;
if (spawning) if (spawning)
@ -468,6 +480,7 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec
Sector = sector; Sector = sector;
subsector = Level->PointInRenderSubsector(Pos()); // this is from the rendering nodes, not the gameplay nodes! subsector = Level->PointInRenderSubsector(Pos()); // this is from the rendering nodes, not the gameplay nodes!
section = subsector->section; section = subsector->section;
flags8 |= MF8_LINKEDTOWORLD;
if (!(flags & MF_NOSECTOR)) if (!(flags & MF_NOSECTOR))
{ {

View File

@ -371,7 +371,7 @@ void AActor::Serialize(FSerializer &arc)
SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain); SerializeTerrain(arc, "floorterrain", floorterrain, &def->floorterrain);
SerializeArgs(arc, "args", args, def->args, special); SerializeArgs(arc, "args", args, def->args, special);
if (arc.isReading()) flags8 &= ~MF8_LINKEDTOWORLD;
} }
#undef A #undef A