diff --git a/extensions/sdktools/output.cpp b/extensions/sdktools/output.cpp index 10cc26a5..24bb8434 100644 --- a/extensions/sdktools/output.cpp +++ b/extensions/sdktools/output.cpp @@ -37,16 +37,13 @@ EntityOutputManager g_OutputManager; bool EntityOutputManager::CreateFireEventDetour() { - g_pGameConf->GetMemSig("FireOutput", &info_address); - g_pGameConf->GetOffset("FireOutputBackup", (int *)&(info_restore.bytes)); - - if (!info_address) + if (!g_pGameConf->GetMemSig("FireOutput", &info_address) || !info_address) { g_pSM->LogError(myself, "Could not locate FireOutput - Disabling Entity Outputs"); return false; } - if (!info_restore.bytes) + if (!g_pGameConf->GetOffset("FireOutputBackup", (int *)&(info_restore.bytes))) { g_pSM->LogError(myself, "Could not locate FireOutputBackup - Disabling Entity Outputs"); return false; @@ -56,7 +53,6 @@ bool EntityOutputManager::CreateFireEventDetour() for (size_t i=0; iLogMessage(myself, "Backing up: %x", info_restore.patch[i]); } info_callback = spengine->ExecAlloc(100); @@ -65,9 +61,6 @@ bool EntityOutputManager::CreateFireEventDetour() wr.outbase = (jitcode_t)info_callback; wr.outptr = wr.outbase; - g_pSM->LogMessage(myself, "info_callback : %x", info_callback); - g_pSM->LogMessage(myself, "info_address : %x", info_address); - /* Function we are detouring into is * * void FireEventDetour(CBaseEntityOutput(void *) *pOutput, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay = 0 ) @@ -120,7 +113,6 @@ bool EntityOutputManager::CreateFireEventDetour() for (size_t i=0; iwrite_ubyte(info_restore.patch[i]); - g_pSM->LogMessage(myself, "Writing: %x", info_restore.patch[i]); } /* Return to the original function */ @@ -179,6 +171,12 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator edict_t *pEdict = gameents->BaseEntityToEdict(pCaller); + /* TODO: Add support for entities without an edict */ + if (pEdict == NULL) + { + return; + } + bool fastLookup = false; // Fast lookup failed - check the slow way for hooks that havn't fired yet @@ -247,7 +245,16 @@ void EntityOutputManager::FireEventDetour(void *pOutput, CBaseEntity *pActivator //fire the forward to hook->pf hook->pf->PushString(pOutputName->Name); hook->pf->PushCell(engine->IndexOfEdict(pEdict)); - hook->pf->PushCell(engine->IndexOfEdict(gameents->BaseEntityToEdict(pActivator))); + + edict_t *pEdictActivator = gameents->BaseEntityToEdict(pActivator); + if (!pEdictActivator) + { + hook->pf->PushCell(-1); + } + else + { + hook->pf->PushCell(engine->IndexOfEdict(pEdictActivator)); + } //hook->pf->PushCell(handle); hook->pf->PushFloat(fDelay); hook->pf->Execute(NULL); diff --git a/gamedata/sdktools.games.txt b/gamedata/sdktools.games.txt index cc5f454b..7a5e99de 100644 --- a/gamedata/sdktools.games.txt +++ b/gamedata/sdktools.games.txt @@ -1704,6 +1704,7 @@ "#supported" { "game" "cstrike" + "game" "hl2mp" } "Signatures" {