-Added support for CGameRules calls to SDKTools
-Changed some game names in sdktools.games.txt to descriptions

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401071
This commit is contained in:
Scott Ehlert
2007-07-08 09:46:27 +00:00
parent da8399c870
commit c0a869106f
8 changed files with 235 additions and 116 deletions
+3
View File
@@ -25,6 +25,7 @@
#include "vcallbuilder.h"
#include "vnatives.h"
#include "tempents.h"
#include "gamerules.h"
/**
* @file extension.cpp
@@ -102,7 +103,9 @@ bool SDKTools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
void SDKTools::SDK_OnAllLoaded()
{
SM_GET_LATE_IFACE(BINTOOLS, g_pBinTools);
g_TEManager.Initialize();
InitializeGameRules();
}
bool SDKTools::QueryRunning(char *error, size_t maxlength)
@@ -187,6 +187,10 @@
RelativePath="..\extension.cpp"
>
</File>
<File
RelativePath="..\gamerules.cpp"
>
</File>
<File
RelativePath="..\tempents.cpp"
>
@@ -229,6 +233,10 @@
RelativePath="..\extension.h"
>
</File>
<File
RelativePath="..\gamerules.h"
>
</File>
<File
RelativePath="..\tempents.h"
>
+27 -6
View File
@@ -80,6 +80,8 @@ ValveCall *CreateValveCall(void *addr,
ValveCall *vc = new ValveCall;
vc->type = vcalltype;
size_t size = 0;
vc->stackSize = 0;
@@ -109,16 +111,24 @@ ValveCall *CreateValveCall(void *addr,
{
thisinfo = &thisbuf;
thisinfo->type = PassType_Basic;
if (vcalltype == ValveCall_Entity)
switch (vcalltype)
{
case ValveCall_Entity:
thisinfo->vtype = Valve_CBaseEntity;
thisinfo->flags = PASSFLAG_BYVAL;
thisinfo->decflags |= VDECODE_FLAG_ALLOWWORLD;
} else if (vcalltype == ValveCall_Player) {
break;
case ValveCall_Player:
thisinfo->vtype = Valve_CBasePlayer;
thisinfo->flags = PASSFLAG_BYVAL;
thisinfo->decflags = 0;
break;
case ValveCall_GameRules:
thisinfo->vtype = Valve_POD;
thisinfo->flags = PASSFLAG_ASPOINTER;
thisinfo->decflags = 0;
}
thisinfo->encflags = 0;
thisinfo->flags = PASSFLAG_BYVAL;
thisinfo->offset = 0;
vc->stackSize += sizeof(void *);
cv = CallConv_ThisCall;
@@ -227,6 +237,8 @@ ValveCall *CreateValveVCall(unsigned int vtableIdx,
ValveCall *vc = new ValveCall;
vc->type = vcalltype;
size_t size = 0;
vc->stackSize = 0;
@@ -314,16 +326,25 @@ ValveCall *CreateValveVCall(unsigned int vtableIdx,
/* Save the this info for the dynamic decoder */
vc->thisinfo = &(vc->vparams[numParams + 1]);
vc->thisinfo->type = PassType_Basic;
if (vcalltype == ValveCall_Entity)
switch (vcalltype)
{
case ValveCall_Entity:
vc->thisinfo->vtype = Valve_CBaseEntity;
vc->thisinfo->flags = PASSFLAG_BYVAL;
vc->thisinfo->decflags = VDECODE_FLAG_ALLOWWORLD;
} else if (vcalltype == ValveCall_Player) {
break;
case ValveCall_Player:
vc->thisinfo->vtype = Valve_CBasePlayer;
vc->thisinfo->flags = PASSFLAG_BYVAL;
vc->thisinfo->decflags = 0;
break;
case ValveCall_GameRules:
vc->thisinfo->vtype = Valve_POD;
vc->thisinfo->flags = PASSFLAG_ASPOINTER;
vc->thisinfo->decflags = 0;
break;
}
vc->thisinfo->encflags = 0;
vc->thisinfo->flags = PASSFLAG_BYVAL;
vc->thisinfo->offset = 0;
vc->thisinfo->obj_offset = 0;
normSize += sizeof(void *);
+1
View File
@@ -37,6 +37,7 @@ using namespace SourceHook;
struct ValveCall
{
ICallWrapper *call; /**< From IBinTools */
ValveCallType type; /**< Call type */
ValvePassInfo *vparams; /**< Valve parameter info */
ValvePassInfo *retinfo; /**< Return buffer info */
ValvePassInfo *thisinfo; /**< Thiscall info */
+42 -16
View File
@@ -23,6 +23,7 @@
#include "extension.h"
#include "vcallbuilder.h"
#include "gamerules.h"
enum SDKLibrary
{
@@ -245,25 +246,50 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
unsigned int startparam = 2;
/* Do we need to write a thispointer? */
if (vc->thisinfo &&
(vc->thisinfo->vtype == Valve_CBaseEntity
|| vc->thisinfo->vtype == Valve_CBasePlayer))
if (vc->thisinfo)
{
if (startparam > numparams)
switch (vc->type)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Expected 1 parameter for entity pointer; found none");
case ValveCall_Entity:
case ValveCall_Player:
{
if (startparam > numparams)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("Expected 1 parameter for entity pointer; found none");
}
if (DecodeValveParam(pContext,
params[startparam],
vc,
vc->thisinfo,
ptr) == Data_Fail)
{
vc->stk_put(ptr);
return 0;
}
startparam++;
}
break;
case ValveCall_GameRules:
{
if (g_pGameRules == NULL)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("GameRules unsupported or not available; file a bug report");
}
void *gamerules = *g_pGameRules;
if (gamerules == NULL)
{
vc->stk_put(ptr);
return pContext->ThrowNativeError("GameRules not available before map is loaded");
}
*(void **)ptr = gamerules;
}
break;
}
if (DecodeValveParam(pContext,
params[startparam],
vc,
vc->thisinfo,
ptr) == Data_Fail)
{
vc->stk_put(ptr);
return 0;
}
startparam++;
}
/* See if we need to skip any more parameters */
+4 -3
View File
@@ -67,9 +67,10 @@ enum DataStatus
*/
enum ValveCallType
{
ValveCall_Static, /**< Static call */
ValveCall_Entity, /**< Thiscall (CBaseEntity implicit first parameter) */
ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
ValveCall_Static, /**< Static call */
ValveCall_Entity, /**< Thiscall (CBaseEntity implicit first parameter) */
ValveCall_Player, /**< Thiscall (CBasePlayer implicit first parameter) */
ValveCall_GameRules, /**< Thiscall (CGameRules implicit first paramater) */
};
/**