Still getting the same error.
Also, if I uncomment your line:
g_pDetour->Address()
It tells me that "CDetour has no member Address", so I'm guessing I'm doing something wrong here. Do you think my includes are screwed up?
PHP Code:
#include "extension.h"
/**
* @file extension.cpp
* @brief Implement extension code here.
*/
Sample g_Sample; /**< Global singleton for extension's main interface */
SMEXT_LINK(&g_Sample);
IGameConfig *g_pGameConf = NULL;
CDetour *g_pDetour = NULL;
IForward *g_pFireBullet = NULL;
DETOUR_DECL_STATIC10(Detour_FXFireBullets, void, Vector const&, vOrigin, QAngle const&, vAngles, int, weaponId, int, mode, int, seed, float, flSpread, float, a9, float, a10, float, a11, int, a12)
{
int iPlayerId;
__asm mov iPlayerId, ecx
int definitionIndex;
__asm mov definitionIndex, edx
// Trick the compiler into thinking that we're using ESI(to preserve it - just to be sure).
__asm mov esi, esi;
/*cell_t result = Pl_Continue;
g_pFireBullet->PushCell(iPlayerId);
g_pFireBullet->Execute(&result);
printf("playerID: %d\n", iPlayerId);
printf("definitionIndex: %d\n", definitionIndex);
printf("wpnId: %d\n", weaponId);
printf("mode: %d\n", mode);
printf("seed: %d\n", seed);
printf("spread: %f\n", flSpread);*/
/*Vector *ptr3;
ptr3 = (Vector*)( &vOrigin );
*ptr3 = Vector(vOrigin.x, vOrigin.y, vOrigin.z);
QAngle *ptr4;
ptr4 = (QAngle*)( &vAngles );
*ptr4 = QAngle(vAngles.x, vAngles.y, vAngles.z);*/
/* Call original function.
* I had to manually 'construct' this call because the compiler was destroying register content while pushing the args. */
void *addr = DETOUR_STATIC_CALL(Detour_FXFireBullets);
__asm {
push a12
push a11
push a10
push a9
push flSpread
push seed
push mode
push weaponId
push vAngles
push vOrigin
mov edx, definitionIndex
mov ecx, iPlayerId
call addr
add esp, 0x28
}
}
bool Sample::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
char conf_error[255];
if (!gameconfs->LoadGameConfigFile("sample.games", &g_pGameConf, conf_error, sizeof(conf_error)))
{
if (error)
{
snprintf(error, maxlength, "Could not read sample.games.txt: %s", conf_error);
}
return false;
}
sharesys->RegisterLibrary(myself, "sample");
//plsys->AddPluginsListener(this);
CDetourManager::Init(g_pSM->GetScriptingEngine(), g_pGameConf);
g_pDetour = DETOUR_CREATE_STATIC(Detour_FXFireBullets, "FX_FireBullets");
if(!g_pDetour)
{
g_pSM->Format(error, maxlength, "Couldn't create detour");
return false;
}
//printf("Detouring: %x\n", g_pDetour->Address());
g_pDetour->EnableDetour();
g_pFireBullet = forwards->CreateForward("OnFireBullet", ET_Event, 1, NULL, Param_Cell);
return true;
}
void Sample::SDK_OnUnload()
{
if(g_pDetour)
{
g_pDetour->Destroy();
}
gameconfs->CloseGameConfigFile(g_pGameConf);
//plsys->RemovePluginsListener(this);
forwards->ReleaseForward(g_pFireBullet);
}