File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ class ServerEntityExt
62
62
};
63
63
64
64
65
+ // -----------------------------------------------------------------------------
66
+ // CEdictWrapper.
67
+ // -----------------------------------------------------------------------------
68
+ struct CEdictWrapper : public edict_t
69
+ {
70
+ void SetUnknown (IServerUnknown *pUnk) {
71
+ m_pUnk = pUnk;
72
+ }
73
+ };
74
+
75
+
65
76
// -----------------------------------------------------------------------------
66
77
// CBaseEdict extension class.
67
78
// -----------------------------------------------------------------------------
Original file line number Diff line number Diff line change 59
59
60
60
#include " modules/listeners/listeners_manager.h"
61
61
#include " utilities/conversions.h"
62
+ #include " modules/entities/entities.h"
62
63
#include " modules/entities/entities_entity.h"
63
64
#include " modules/core/core.h"
64
65
@@ -571,6 +572,14 @@ void CSourcePython::OnEntitySpawned( CBaseEntity *pEntity )
571
572
572
573
void CSourcePython::OnEntityDeleted ( CBaseEntity *pEntity )
573
574
{
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
+
574
583
CALL_LISTENERS (OnEntityDeleted, ptr ((CBaseEntityWrapper*) pEntity));
575
584
576
585
unsigned int uiIndex;
@@ -587,6 +596,10 @@ void CSourcePython::OnEntityDeleted( CBaseEntity *pEntity )
587
596
// Invalidate the internal entity cache once all callbacks have been called.
588
597
static object _on_networked_entity_deleted = import (" entities" ).attr (" _base" ).attr (" _on_networked_entity_deleted" );
589
598
_on_networked_entity_deleted (uiIndex);
599
+
600
+ if (bRebound) {
601
+ reinterpret_cast <CEdictWrapper *>(pEdict)->SetUnknown (NULL );
602
+ }
590
603
}
591
604
592
605
void CSourcePython::OnDataLoaded ( MDLCacheDataType_t type, MDLHandle_t handle )
You can’t perform that action at this time.
0 commit comments