Fixed amb1579 bug in entity outputs and added hl2mp to the supported games.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401982
This commit is contained in:
Matt Woodrow 2008-04-03 23:57:54 +00:00
parent 4d3d51b5dd
commit 10bd6c298e
2 changed files with 19 additions and 11 deletions

View File

@ -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; i<info_restore.bytes; i++)
{
info_restore.patch[i] = ((unsigned char *)info_address)[i];
g_pSM->LogMessage(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; i<info_restore.bytes; i++)
{
jit->write_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);

View File

@ -1704,6 +1704,7 @@
"#supported"
{
"game" "cstrike"
"game" "hl2mp"
}
"Signatures"
{