Merge pull request #52 from alliedmodders/bug-6137
Update TF2_IsHolidayActive native to virtually call gamerules IsHolidayActive (bug 6137, r=VoiDeD).
This commit is contained in:
commit
c5e2d49b8f
@ -34,6 +34,8 @@
|
||||
#include "time.h"
|
||||
#include "RegNatives.h"
|
||||
|
||||
#include <ISDKTools.h>
|
||||
|
||||
// native TF2_MakeBleed(client, attacker, Float:duration)
|
||||
cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
@ -553,25 +555,41 @@ cell_t TF2_IsPlayerInDuel(IPluginContext *pContext, const cell_t *params)
|
||||
// native bool:TF2_IsHolidayActive(TFHoliday:holiday);
|
||||
cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
static ICallWrapper *pWrapper = NULL;
|
||||
|
||||
// UTIL_IsHolidayActive(int)
|
||||
if (!pWrapper)
|
||||
void *pGameRules;
|
||||
if (!g_pSDKTools || !(pGameRules = g_pSDKTools->GetGameRules()))
|
||||
{
|
||||
REGISTER_NATIVE_ADDR("IsHolidayActive",
|
||||
PassInfo pass[1]; \
|
||||
pass[0].flags = PASSFLAG_BYVAL; \
|
||||
pass[0].size = sizeof(int); \
|
||||
pass[0].type = PassType_Basic; \
|
||||
PassInfo ret; \
|
||||
ret.flags = PASSFLAG_BYVAL; \
|
||||
ret.size = sizeof(bool); \
|
||||
ret.type = PassType_Basic; \
|
||||
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &ret, pass, 1))
|
||||
return pContext->ThrowNativeError("Failed to find GameRules");
|
||||
}
|
||||
|
||||
unsigned char vstk[sizeof(int)];
|
||||
static ICallWrapper *pWrapper = NULL;
|
||||
|
||||
// CTFGameRules::IsHolidayActive(int)
|
||||
if (!pWrapper)
|
||||
{
|
||||
int offset;
|
||||
if (!g_pGameConf->GetOffset("IsHolidayActive", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Failed to locate function");
|
||||
}
|
||||
|
||||
PassInfo pass[1];
|
||||
pass[0].flags = PASSFLAG_BYVAL;
|
||||
pass[0].size = sizeof(int);
|
||||
pass[0].type = PassType_Basic;
|
||||
PassInfo ret;
|
||||
ret.flags = PASSFLAG_BYVAL;
|
||||
ret.size = sizeof(bool);
|
||||
ret.type = PassType_Basic;
|
||||
|
||||
pWrapper = g_pBinTools->CreateVCall(offset, 0, 0, &ret, pass, 1);
|
||||
|
||||
g_RegNatives.Register(pWrapper);
|
||||
}
|
||||
|
||||
unsigned char vstk[sizeof(void *) + sizeof(int)];
|
||||
unsigned char *vptr = vstk;
|
||||
*(void **)vptr = pGameRules;
|
||||
vptr += sizeof(void *);
|
||||
*(int *)vptr = params[1];
|
||||
|
||||
bool retValue;
|
||||
|
Loading…
Reference in New Issue
Block a user