Improved Object handling while predicting
Added a warning if a networked Object or non-client-side Thinker was erroneously destroyed manually while predicting. This only applies to ZScript since this is the only place it's relevant. Added a warning if a non-client-side Thinker was spawned while predicting. Sweep objects before backing up while predicting to ensure invalid pointers aren't captured.
This commit is contained in:
parent
346f4c0e87
commit
1fd267a96a
4 changed files with 24 additions and 2 deletions
|
|
@ -333,10 +333,22 @@ void DObject::Destroy ()
|
|||
GC::WriteBarrier(this);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DObject, Destroy)
|
||||
// This will be here until prediction can be reworked.
|
||||
// TODO: Fix prediction by serializing instead of using this terrible memcpy method.
|
||||
bool bPredictionGuard = false;
|
||||
|
||||
static void NativeDestroy(DObject* self)
|
||||
{
|
||||
if (bPredictionGuard && !(self->ObjectFlags & OF_ClientSide) && ((self->ObjectFlags & OF_Networked) || self->IsKindOf(NAME_Thinker)))
|
||||
DPrintf(DMSG_WARNING, TEXTCOLOR_RED "Destroyed non-client-side Object %s while predicting\n", self->GetClass()->TypeName.GetChars());
|
||||
if (!(self->ObjectFlags & OF_EuthanizeMe))
|
||||
self->Destroy();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DObject, Destroy, NativeDestroy)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DObject);
|
||||
self->Destroy();
|
||||
NativeDestroy(self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -369,6 +369,8 @@ public:
|
|||
virtual void EnableNetworking(const bool enable);
|
||||
};
|
||||
|
||||
extern bool bPredictionGuard;
|
||||
|
||||
// This is the only method aside from calling CreateNew that should be used for creating DObjects
|
||||
// to ensure that the Class pointer is always set.
|
||||
template<typename T, typename... Args>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue