Merge pull request #623 from alliedmodders/CSWeaponDrop-change
Use the same weapon drop function in CS:GO as in CS:S
This commit is contained in:
commit
f413ea7f4b
@ -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.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -99,12 +99,18 @@
|
||||
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x7C\x01\x00\x00\x53\x56\x57\x6A\x00"
|
||||
"linux" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x9C\x01\x00\x00\x0F\xB6\x55\x14"
|
||||
}
|
||||
"CSWeaponDrop"//Wildcard first 6 bytes for CS:S DM
|
||||
"CSWeaponDrop"//Wildcard first 6 bytes for CS:S DM (kept for backcompat with old SM versions)
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x2A\x2A\x2A\x2A\x53\x8B\x5D\x08\x56\x57\x6A\x00\x68"
|
||||
"linux" "\x2A\x2A\x2A\x2A\x2A\x2A\x56\x53\x81\xEC\x7C\x02\x00\x00\x8B\x5D\x0C\x8B\x75\x08\x85\xDB\x74\x2A\xC7\x44\x24\x2A\x2A\x2A\x2A\x00"
|
||||
}
|
||||
"CSWeaponDropBB" //Revert back to using CSWeaponDrop(weapon, bool, bool)
|
||||
{
|
||||
"library" "server"
|
||||
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x83\xE4\xF8\x83\xC4\x04\x55\x8B\x6B\x04\x89\x6C\x24\x04\x8B\xEC\x83\xEC\x34\x56"
|
||||
"linux" "\x2A\x2A\x2A\x2A\x2A\x2A\x83\xEC\x7C\x8B\x5D\x08\x0F\xB6\x7D\x14"
|
||||
}
|
||||
"TerminateRound"
|
||||
{
|
||||
"library" "server"
|
||||
|
Loading…
Reference in New Issue
Block a user