Update CStrike extension and gamedata on windows for latest CS:GO update (irc, r= psychonic)

This commit is contained in:
Ruben Gonzalez
2014-02-08 20:04:12 -05:00
parent 925d514224
commit f351e20de3
4 changed files with 218 additions and 34 deletions
+49 -1
View File
@@ -21,6 +21,13 @@ CDetour *DCSWeaponDrop = NULL;
int weaponNameOffset = -1;
//Windows CS:GO
// int __userpurge HandleCommand_Buy_Internal<eax>(int a1<ecx>, float a2<xmm0>, int a3, int a4, char a5)
// a1 - this
// a2 - CCSGameRules::GetWarmupPeriodEndTime(g_pGameRules)
// a3 - weapon
// a4 - unknown
// a5 - bRebuy
#if SOURCE_ENGINE == SE_CSGO
DETOUR_DECL_MEMBER3(DetourHandleBuy, int, const char *, weapon, int, iUnknown, bool, bRebuy)
#else
@@ -69,7 +76,7 @@ DETOUR_DECL_MEMBER2(DetourWeaponPrice, int, const char *, szAttribute, CEconItem
{
int price = DETOUR_MEMBER_CALL(DetourWeaponPrice)(szAttribute, pEconItem);
if(lastclient == -1 || strcmp(szAttribute, "in_game_price") != 0)
if(lastclient == -1 || strcmp(szAttribute, "in game price") != 0)
return price;
const char *weapon_name = reinterpret_cast<char *>(this+weaponNameOffset);
@@ -78,6 +85,7 @@ DETOUR_DECL_MEMBER2(DetourWeaponPrice, int, const char *, szAttribute, CEconItem
}
#endif
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason)
{
if (g_pIgnoreTerminateDetour)
@@ -86,6 +94,30 @@ DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason)
DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason);
return;
}
#else
//Windows CSGO
//char __userpurge TerminateRound<al>(unsigned int a1<ecx>, signed int a2<edi>, unsigned int a3<xmm1>, int a4)
// a1 - this
// a2 - unknown
// a3 - delay
// a4 - reason
DETOUR_DECL_MEMBER1(DetourTerminateRound, void, int, reason)
{
float delay;
if (g_pIgnoreTerminateDetour)
{
g_pIgnoreTerminateDetour = false;
return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason);
}
//Save the delay
__asm
{
movss delay, xmm1
}
#endif
float orgdelay = delay;
int orgreason = reason;
@@ -98,10 +130,26 @@ DETOUR_DECL_MEMBER2(DetourTerminateRound, void, float, delay, int, reason)
if (result >= Pl_Handled)
return;
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
if (result == Pl_Changed)
return DETOUR_MEMBER_CALL(DetourTerminateRound)(delay, reason);
return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgdelay, orgreason);
#else
if (result == Pl_Changed)
{
__asm
{
movss xmm1, delay
}
return DETOUR_MEMBER_CALL(DetourTerminateRound)(reason);
}
__asm
{
movss xmm1, orgdelay
}
return DETOUR_MEMBER_CALL(DetourTerminateRound)(orgreason);
#endif
}
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, something, bool, toss)
+74 -8
View File
@@ -46,6 +46,12 @@ int g_iPriceOffset = -1;
code; \
g_RegNatives.Register(pWrapper);
#define GET_MEMSIG(name) \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
return pContext->ThrowNativeError("Failed to locate function"); \
}
inline CBaseEntity *GetCBaseEntity(int num, bool isplayer)
{
edict_t *pEdict = gamehelpers->EdictOfIndex(num);
@@ -150,6 +156,7 @@ static cell_t CS_RespawnPlayer(IPluginContext *pContext, const cell_t *params)
static cell_t CS_SwitchTeam(IPluginContext *pContext, const cell_t *params)
{
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
@@ -174,6 +181,41 @@ static cell_t CS_SwitchTeam(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(CBaseEntity *);
*(int *)vptr = params[2];
pWrapper->Execute(vstk, NULL);
#else
if (g_pSDKTools == NULL)
{
return pContext->ThrowNativeError("SDKTools interface not found. TerminateRound native disabled.");
}
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("SwitchTeam");
}
void *gamerules = g_pSDKTools->GetGameRules();
if (gamerules == NULL)
{
return pContext->ThrowNativeError("GameRules not available. SwitchTeam native disabled.");
}
CBaseEntity *pEntity;
if (!(pEntity=GetCBaseEntity(params[1], true)))
{
return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
}
int team = params[2];
__asm
{
push team
mov ecx, pEntity
mov ebx, gamerules
call addr
}
#endif
return 1;
}
@@ -248,7 +290,7 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
{
if (g_pSDKTools == NULL)
{
smutils->LogError(myself, "SDKTools interface not found. TerminateRound native disabled.");
return pContext->ThrowNativeError("SDKTools interface not found. TerminateRound native disabled.");
}
else if (g_pSDKTools->GetInterfaceVersion() < 2)
{
@@ -256,6 +298,13 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
return pContext->ThrowNativeError("SDKTools interface is outdated. TerminateRound native disabled.");
}
void *gamerules = g_pSDKTools->GetGameRules();
if (gamerules == NULL)
{
return pContext->ThrowNativeError("GameRules not available. TerminateRound native disabled.");
}
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
@@ -271,12 +320,6 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 2))
}
void *gamerules = g_pSDKTools->GetGameRules();
if (gamerules == NULL)
{
return pContext->ThrowNativeError("GameRules not available. TerminateRound native disabled.");
}
if (params[3] == 1 && g_pTerminateRoundDetoured)
g_pIgnoreTerminateDetour = true;
@@ -290,7 +333,30 @@ static cell_t CS_TerminateRound(IPluginContext *pContext, const cell_t *params)
*(int*)vptr = params[2];
pWrapper->Execute(vstk, NULL);
#else
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("TerminateRound");
}
if (params[3] == 1 && g_pTerminateRoundDetoured)
g_pIgnoreTerminateDetour = true;
float delay = sp_ctof(params[1]);
int reason = params[2];
signed int unknown = 1;//We might want to find what this is?
__asm
{
push reason
movss xmm1, delay
mov edi, unknown
mov ecx, gamerules
call addr
}
#endif
return 1;
}
@@ -385,7 +451,7 @@ static cell_t CS_GetWeaponPrice(IPluginContext *pContext, const cell_t *params)
*(void **)vptr = info;
vptr += sizeof(void *);
*(const char **)vptr = "in_game_price";
*(const char **)vptr = "in game price";
vptr += sizeof(const char **);
*(CEconItemView **)vptr = NULL;
+80 -10
View File
@@ -44,8 +44,17 @@
code; \
g_RegNatives.Register(pWrapper);
#define GET_MEMSIG(name, defaultret) \
if (!g_pGameConf->GetMemSig(name, &addr) || !addr) \
{ \
g_pSM->LogError(myself, "Failed to locate function."); \
return defaultret;\
}
void *GetWeaponInfo(int weaponID)
{
void *info;
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
@@ -61,8 +70,6 @@ void *GetWeaponInfo(int weaponID)
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
void *info;
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
@@ -70,11 +77,30 @@ void *GetWeaponInfo(int weaponID)
pWrapper->Execute(vstk, &info);
#else
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("GetWeaponInfo", 0);
}
__asm
{
mov ecx, weaponID
call addr
mov info, eax
}
#endif
return info;
}
const char *GetTranslatedWeaponAlias(const char *weapon)
{
const char *alias = NULL;
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
@@ -90,20 +116,35 @@ const char *GetTranslatedWeaponAlias(const char *weapon)
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
const char *ret = NULL;
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
*(const char **)vptr = weapon;
pWrapper->Execute(vstk, &ret);
pWrapper->Execute(vstk, &alias);
#else
static void *addr = NULL;
return ret;
if(!addr)
{
GET_MEMSIG("GetTranslatedWeaponAlias", weapon);
}
__asm
{
mov ecx, weapon
call addr
mov alias, eax
}
#endif
return alias;
}
int AliasToWeaponID(const char *weapon)
{
int weaponID = 0;
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
@@ -119,7 +160,6 @@ int AliasToWeaponID(const char *weapon)
retpass.size = sizeof(int); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
int weaponID = 0;
unsigned char vstk[sizeof(const char *)];
unsigned char *vptr = vstk;
@@ -127,12 +167,28 @@ int AliasToWeaponID(const char *weapon)
*(const char **)vptr = weapon;
pWrapper->Execute(vstk, &weaponID);
#else
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("AliasToWeaponID", 0);
}
__asm
{
mov ecx, weapon
call addr
mov weaponID, eax
}
#endif
return weaponID;
}
const char *WeaponIDToAlias(int weaponID)
{
const char *alias = NULL;
#if SOURCE_ENGINE != SE_CSGO || !defined(WIN32)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
@@ -148,16 +204,30 @@ const char *WeaponIDToAlias(int weaponID)
retpass.size = sizeof(const char *); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
}
const char *ret = NULL;
unsigned char vstk[sizeof(int)];
unsigned char *vptr = vstk;
*(int *)vptr = GetRealWeaponID(weaponID);
pWrapper->Execute(vstk, &ret);
return ret;
pWrapper->Execute(vstk, &alias);
#else
static void *addr = NULL;
if(!addr)
{
GET_MEMSIG("WeaponIDToAlias", 0);
}
int realWeaponID = GetRealWeaponID(weaponID);
__asm
{
mov ecx, realWeaponID
call addr
mov alias, eax
}
#endif
return alias;
}
int GetRealWeaponID(int weaponId)
{