Use the same weapon drop function in CS:GO as in CS:S

This commit is contained in:
Ruben Gonzalez
2017-06-12 08:39:27 -04:00
parent a984e23bf6
commit 2f0272f864
4 changed files with 14 additions and 40 deletions
+5
View File
@@ -62,6 +62,11 @@ int CallPriceForward(int client, const char *weapon_name, int price);
#define WEAPON_NIGHTVISION 33
#endif
#if SOURCE_ENGINE == SE_CSGO
#define WEAPONDROP_GAMEDATA_NAME "CSWeaponDropBB"
#else
#define WEAPONDROP_GAMEDATA_NAME "CSWeaponDrop"
#endif
/**
* @brief Sample implementation of the SDK Extension.
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
+1 -13
View File
@@ -158,20 +158,12 @@ DETOUR_DECL_MEMBER1(DetourTerminateRound, void, int, reason)
#endif
}
#if SOURCE_ENGINE == SE_CSGO
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, Vector, vec, bool, unknown)
#else
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bDropShield, bool, bThrowForward)
#endif
{
if (g_pIgnoreCSWeaponDropDetour)
{
g_pIgnoreCSWeaponDropDetour = false;
#if SOURCE_ENGINE == SE_CSGO
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, vec, unknown);
#else
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
#endif
return;
}
@@ -186,11 +178,7 @@ DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bDrop
if (result == Pl_Continue)
{
#if SOURCE_ENGINE == SE_CSGO
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, vec, unknown);
#else
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
#endif
}
return;
@@ -269,7 +257,7 @@ bool CreateHandleBuyDetour()
bool CreateCSWeaponDropDetour()
{
DCSWeaponDrop = DETOUR_CREATE_MEMBER(DetourCSWeaponDrop, "CSWeaponDrop");
DCSWeaponDrop = DETOUR_CREATE_MEMBER(DetourCSWeaponDrop, WEAPONDROP_GAMEDATA_NAME);
if (DCSWeaponDrop != NULL)
{
+1 -26
View File
@@ -226,21 +226,7 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
static ICallWrapper *pWrapper = NULL;
if (!pWrapper)
{
#if SOURCE_ENGINE == SE_CSGO
REGISTER_NATIVE_ADDR("CSWeaponDrop",
PassInfo pass[3]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
pass[0].size = sizeof(CBaseEntity *); \
pass[1].flags = PASSFLAG_BYVAL; \
pass[1].type = PassType_Basic; \
pass[1].size = sizeof(Vector); \
pass[2].flags = PASSFLAG_BYVAL; \
pass[2].type = PassType_Basic; \
pass[2].size = sizeof(bool); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
#else
REGISTER_NATIVE_ADDR("CSWeaponDrop",
REGISTER_NATIVE_ADDR(WEAPONDROP_GAMEDATA_NAME,
PassInfo pass[3]; \
pass[0].flags = PASSFLAG_BYVAL; \
pass[0].type = PassType_Basic; \
@@ -252,7 +238,6 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
pass[2].type = PassType_Basic; \
pass[2].size = sizeof(bool); \
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
#endif
}
CBaseEntity *pEntity;
@@ -285,11 +270,7 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
if (params[4] == 1 && g_pCSWeaponDropDetoured)
g_pIgnoreCSWeaponDropDetour = true;
#if SOURCE_ENGINE == SE_CSGO
unsigned char vstk[sizeof(CBaseEntity *) * 2 + sizeof(bool) + sizeof(Vector)];
#else
unsigned char vstk[sizeof(CBaseEntity *) * 2 + sizeof(bool) * 2];
#endif
unsigned char *vptr = vstk;
// <psychonic> first one is always false. second is true to toss, false to just drop
@@ -297,15 +278,9 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
vptr += sizeof(CBaseEntity *);
*(CBaseEntity **)vptr = pWeapon;
vptr += sizeof(CBaseEntity *);
#if SOURCE_ENGINE == SE_CSGO
*(Vector *)vptr = vec3_origin;
vptr += sizeof(Vector);
*(bool *)vptr = false;
#else
*(bool *)vptr = false;
vptr += sizeof(bool);
*(bool *)vptr = (params[3]) ? true : false;
#endif
pWrapper->Execute(vstk, NULL);