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 "time.h"
|
||||||
#include "RegNatives.h"
|
#include "RegNatives.h"
|
||||||
|
|
||||||
|
#include <ISDKTools.h>
|
||||||
|
|
||||||
// native TF2_MakeBleed(client, attacker, Float:duration)
|
// native TF2_MakeBleed(client, attacker, Float:duration)
|
||||||
cell_t TF2_MakeBleed(IPluginContext *pContext, const cell_t *params)
|
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);
|
// native bool:TF2_IsHolidayActive(TFHoliday:holiday);
|
||||||
cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params)
|
cell_t TF2_IsHolidayActive(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
static ICallWrapper *pWrapper = NULL;
|
void *pGameRules;
|
||||||
|
if (!g_pSDKTools || !(pGameRules = g_pSDKTools->GetGameRules()))
|
||||||
// UTIL_IsHolidayActive(int)
|
|
||||||
if (!pWrapper)
|
|
||||||
{
|
{
|
||||||
REGISTER_NATIVE_ADDR("IsHolidayActive",
|
return pContext->ThrowNativeError("Failed to find GameRules");
|
||||||
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))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
unsigned char *vptr = vstk;
|
||||||
|
*(void **)vptr = pGameRules;
|
||||||
|
vptr += sizeof(void *);
|
||||||
*(int *)vptr = params[1];
|
*(int *)vptr = params[1];
|
||||||
|
|
||||||
bool retValue;
|
bool retValue;
|
||||||
|
Loading…
Reference in New Issue
Block a user