Added a new ValveCallType that allows for arbitrary |this| parameters, as well as associated features in gamedata and for reading/writing memory (bug 3520, r=dvander, sr=fyren).

This commit is contained in:
Downtown1
2010-01-11 22:46:44 -08:00
parent ead6ca73e5
commit 18865c44c8
9 changed files with 330 additions and 2 deletions
+20 -1
View File
@@ -250,7 +250,7 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
unsigned char *ptr = vc->stk_get();
unsigned int numparams = (unsigned)params[0];
const unsigned int numparams = (unsigned)params[0];
unsigned int startparam = 2;
/* Do we need to write a thispointer? */
@@ -308,6 +308,25 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
*(void **)ptr = g_EntList;
}
break;
case ValveCall_Raw:
{
//params[startparam] is an address to a pointer to THIS
//params following this are params to the method we will invoke later
if (startparam > numparams)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Expected a ThisPtr address, it wasn't found");
}
//note: varargs pawn args are passed by-ref
cell_t *cell;
pContext->LocalToPhysAddr(params[startparam], &cell);
void *thisptr = reinterpret_cast<void*>(*cell);
*(void **)ptr = thisptr;
startparam++;
}
break;
}
}
+1
View File
@@ -80,6 +80,7 @@ enum ValveCallType
ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
ValveCall_GameRules, /**< Thiscall (CGameRules implicit first paramater) */
ValveCall_EntityList, /**< Thiscall (CGlobalEntityList implicit first paramater) */
ValveCall_Raw, /**< Thiscall (address explicit first parameter) */
};
/**