@@ -95,6 +95,7 @@ SH_DECL_MANUALHOOK1_void(GoToIntermission, 0, 0, 0, bool);
9595SH_DECL_MANUALHOOK2_void (PhysicsTouchShuffle, 0 , 0 , 0 , CUtlVector<TouchLinked_t>*, bool );
9696SH_DECL_MANUALHOOK3_void (DropWeapon, 0 , 0 , 0 , CBasePlayerWeapon*, Vector*, Vector*);
9797SH_DECL_HOOK1_void (IServer, SetGameSpawnGroupMgr, SH_NOATTRIB, 0 , IGameSpawnGroupMgr*);
98+ SH_DECL_HOOK2_void (CEntitySystem, Spawn, SH_NOATTRIB, 0 , int , const EntitySpawnInfo_t*);
9899
99100CS2Fixes g_CS2Fixes;
100101IGameEventSystem* g_gameEventSystem = nullptr ;
@@ -118,6 +119,7 @@ int g_iGoToIntermissionId = -1;
118119int g_iPhysicsTouchShuffle = -1 ;
119120int g_iWeaponServiceDropWeaponId = -1 ;
120121int g_iSetGameSpawnGroupMgrId = -1 ;
122+ int g_iSpawnId = -1 ;
121123
122124double g_flUniversalTime = 0.0 ;
123125float g_flLastTickedTime = 0 .0f ;
@@ -317,9 +319,11 @@ bool CS2Fixes::Load(PluginId id, ISmmAPI* ismm, char* error, size_t maxlen, bool
317319 g_iWeaponServiceDropWeaponId = SH_ADD_MANUALDVPHOOK (DropWeapon, pCCSPlayer_WeaponServicesVTable, SH_MEMBER (this , &CS2Fixes::Hook_DropWeaponPost), true );
318320
319321 auto pCGameEventManagerVTable = (IGameEventManager2*)modules::server->FindVirtualTable (" CGameEventManager" );
320-
321322 g_iLoadEventsFromFileId = SH_ADD_DVPHOOK (IGameEventManager2, LoadEventsFromFile, pCGameEventManagerVTable, SH_MEMBER (this , &CS2Fixes::Hook_LoadEventsFromFile), false );
322323
324+ auto pCEntitySystemVTable = (CEntitySystem*)modules::server->FindVirtualTable (" CGameEntitySystem" );
325+ g_iSpawnId = SH_ADD_DVPHOOK (CEntitySystem, Spawn, pCEntitySystemVTable, SH_MEMBER (this , &CS2Fixes::Hook_SpawnPost), true );
326+
323327 if (!bRequiredInitLoaded)
324328 {
325329 snprintf (error, maxlen, " One or more address lookups, patches or detours failed, please refer to startup logs for more information" );
@@ -441,6 +445,7 @@ bool CS2Fixes::Unload(char* error, size_t maxlen)
441445 SH_REMOVE_HOOK_ID (g_iCGamePlayerEquipPrecacheId);
442446 SH_REMOVE_HOOK_ID (g_iCTriggerGravityPrecacheId);
443447 SH_REMOVE_HOOK_ID (g_iCTriggerGravityEndTouchId);
448+ SH_REMOVE_HOOK_ID (g_iSpawnId);
444449
445450 if (g_iSetGameSpawnGroupMgrId != -1 )
446451 SH_REMOVE_HOOK_ID (g_iSetGameSpawnGroupMgrId);
@@ -1214,6 +1219,12 @@ void CS2Fixes::Hook_SetGameSpawnGroupMgr(IGameSpawnGroupMgr* pSpawnGroupMgr)
12141219 g_pSpawnGroupMgr = (CSpawnGroupMgrGameSystem*)pSpawnGroupMgr;
12151220}
12161221
1222+ void CS2Fixes::Hook_SpawnPost (int nCount, const EntitySpawnInfo_t* pInfo)
1223+ {
1224+ for (int i = 0 ; i < nCount; i++)
1225+ g_pMapMigrations->OnEntitySpawned (pInfo[i].m_pEntity ->m_pInstance , pInfo[i].m_pKeyValues );
1226+ }
1227+
12171228void * CS2Fixes::OnMetamodQuery (const char * iface, int * ret)
12181229{
12191230 if (V_strcmp (iface, CS2FIXES_INTERFACE))
0 commit comments