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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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) */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user