File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ class ServerEntityExt
6262};
6363
6464
65+ // -----------------------------------------------------------------------------
66+ // CEdictWrapper.
67+ // -----------------------------------------------------------------------------
68+ struct CEdictWrapper : public edict_t
69+ {
70+ void SetUnknown (IServerUnknown *pUnk) {
71+ m_pUnk = pUnk;
72+ }
73+ };
74+
75+
6576// -----------------------------------------------------------------------------
6677// CBaseEdict extension class.
6778// -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change 5959
6060#include " modules/listeners/listeners_manager.h"
6161#include " utilities/conversions.h"
62+ #include " modules/entities/entities.h"
6263#include " modules/entities/entities_entity.h"
6364#include " modules/core/core.h"
6465
@@ -571,6 +572,14 @@ void CSourcePython::OnEntitySpawned( CBaseEntity *pEntity )
571572
572573void CSourcePython::OnEntityDeleted ( CBaseEntity *pEntity )
573574{
575+ // #455 - Temporarily rebind ourself to our edict if needed.
576+ bool bRebound = false ;
577+ edict_t *pEdict;
578+ if (EdictFromBaseEntity (pEntity, pEdict) && !pEdict->GetUnknown ()) {
579+ reinterpret_cast <CEdictWrapper *>(pEdict)->SetUnknown ((IServerUnknown *)pEntity);
580+ bRebound = true ;
581+ }
582+
574583 CALL_LISTENERS (OnEntityDeleted, ptr ((CBaseEntityWrapper*) pEntity));
575584
576585 unsigned int uiIndex;
@@ -587,6 +596,10 @@ void CSourcePython::OnEntityDeleted( CBaseEntity *pEntity )
587596 // Invalidate the internal entity cache once all callbacks have been called.
588597 static object _on_networked_entity_deleted = import (" entities" ).attr (" _base" ).attr (" _on_networked_entity_deleted" );
589598 _on_networked_entity_deleted (uiIndex);
599+
600+ if (bRebound) {
601+ reinterpret_cast <CEdictWrapper *>(pEdict)->SetUnknown (NULL );
602+ }
590603}
591604
592605void CSourcePython::OnDataLoaded ( MDLCacheDataType_t type, MDLHandle_t handle )
You can’t perform that action at this time.
0 commit comments