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
|
#define WEAPON_NIGHTVISION 33
|
||||||
#endif
|
#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.
|
* @brief Sample implementation of the SDK Extension.
|
||||||
* Note: Uncomment one of the pre-defined virtual functions in order to use it.
|
* 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
|
#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)
|
DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bDropShield, bool, bThrowForward)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (g_pIgnoreCSWeaponDropDetour)
|
if (g_pIgnoreCSWeaponDropDetour)
|
||||||
{
|
{
|
||||||
g_pIgnoreCSWeaponDropDetour = false;
|
g_pIgnoreCSWeaponDropDetour = false;
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, vec, unknown);
|
|
||||||
#else
|
|
||||||
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
|
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,11 +178,7 @@ DETOUR_DECL_MEMBER3(DetourCSWeaponDrop, void, CBaseEntity *, weapon, bool, bDrop
|
|||||||
|
|
||||||
if (result == Pl_Continue)
|
if (result == Pl_Continue)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, vec, unknown);
|
|
||||||
#else
|
|
||||||
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
|
DETOUR_MEMBER_CALL(DetourCSWeaponDrop)(weapon, bDropShield, bThrowForward);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -269,7 +257,7 @@ bool CreateHandleBuyDetour()
|
|||||||
|
|
||||||
bool CreateCSWeaponDropDetour()
|
bool CreateCSWeaponDropDetour()
|
||||||
{
|
{
|
||||||
DCSWeaponDrop = DETOUR_CREATE_MEMBER(DetourCSWeaponDrop, "CSWeaponDrop");
|
DCSWeaponDrop = DETOUR_CREATE_MEMBER(DetourCSWeaponDrop, WEAPONDROP_GAMEDATA_NAME);
|
||||||
|
|
||||||
if (DCSWeaponDrop != NULL)
|
if (DCSWeaponDrop != NULL)
|
||||||
{
|
{
|
||||||
|
@ -226,21 +226,7 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
|||||||
static ICallWrapper *pWrapper = NULL;
|
static ICallWrapper *pWrapper = NULL;
|
||||||
if (!pWrapper)
|
if (!pWrapper)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
REGISTER_NATIVE_ADDR(WEAPONDROP_GAMEDATA_NAME,
|
||||||
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",
|
|
||||||
PassInfo pass[3]; \
|
PassInfo pass[3]; \
|
||||||
pass[0].flags = PASSFLAG_BYVAL; \
|
pass[0].flags = PASSFLAG_BYVAL; \
|
||||||
pass[0].type = PassType_Basic; \
|
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].type = PassType_Basic; \
|
||||||
pass[2].size = sizeof(bool); \
|
pass[2].size = sizeof(bool); \
|
||||||
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
|
pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, NULL, pass, 3))
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBaseEntity *pEntity;
|
CBaseEntity *pEntity;
|
||||||
@ -285,11 +270,7 @@ static cell_t CS_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
|||||||
if (params[4] == 1 && g_pCSWeaponDropDetoured)
|
if (params[4] == 1 && g_pCSWeaponDropDetoured)
|
||||||
g_pIgnoreCSWeaponDropDetour = true;
|
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];
|
unsigned char vstk[sizeof(CBaseEntity *) * 2 + sizeof(bool) * 2];
|
||||||
#endif
|
|
||||||
unsigned char *vptr = vstk;
|
unsigned char *vptr = vstk;
|
||||||
|
|
||||||
// <psychonic> first one is always false. second is true to toss, false to just drop
|
// <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 *);
|
vptr += sizeof(CBaseEntity *);
|
||||||
*(CBaseEntity **)vptr = pWeapon;
|
*(CBaseEntity **)vptr = pWeapon;
|
||||||
vptr += sizeof(CBaseEntity *);
|
vptr += sizeof(CBaseEntity *);
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
*(Vector *)vptr = vec3_origin;
|
|
||||||
vptr += sizeof(Vector);
|
|
||||||
*(bool *)vptr = false;
|
|
||||||
#else
|
|
||||||
*(bool *)vptr = false;
|
*(bool *)vptr = false;
|
||||||
vptr += sizeof(bool);
|
vptr += sizeof(bool);
|
||||||
*(bool *)vptr = (params[3]) ? true : false;
|
*(bool *)vptr = (params[3]) ? true : false;
|
||||||
#endif
|
|
||||||
|
|
||||||
pWrapper->Execute(vstk, NULL);
|
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"
|
"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"
|
"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"
|
"library" "server"
|
||||||
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x81\xEC\x2A\x2A\x2A\x2A\x53\x8B\x5D\x08\x56\x57\x6A\x00\x68"
|
"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"
|
"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"
|
"TerminateRound"
|
||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
|
Loading…
Reference in New Issue
Block a user