extensions/cstrike/natives.cpp
changeset 4016 ecd3735e908b
parent 3965 86dedf4462d8
child 4019 7daf4ae6f80e
     1.1 --- a/extensions/cstrike/natives.cpp	Thu Aug 15 10:18:27 2013 -0400
     1.2 +++ b/extensions/cstrike/natives.cpp	Thu Aug 15 14:40:30 2013 -0400
     1.3 @@ -353,6 +353,45 @@
     1.4  		return 400;
     1.5  #endif
     1.6  
     1.7 +	void *info = GetWeaponInfo(id);
     1.8 +		
     1.9 +	if (!info)
    1.10 +	{
    1.11 +		return pContext->ThrowNativeError("Failed to get weaponinfo");
    1.12 +	}
    1.13 +
    1.14 +#if SOURCE_ENGINE == SE_CSGO
    1.15 +	static ICallWrapper *pWrapper = NULL;
    1.16 +
    1.17 +	if (!pWrapper)
    1.18 +	{
    1.19 +		REGISTER_NATIVE_ADDR("GetAttributeInt",
    1.20 +		PassInfo pass[2]; \
    1.21 +		PassInfo ret; \
    1.22 +		pass[0].flags = PASSFLAG_BYVAL; \
    1.23 +		pass[0].type = PassType_Basic; \
    1.24 +		pass[0].size = sizeof(char *); \
    1.25 +		pass[1].flags = PASSFLAG_BYVAL; \
    1.26 +		pass[1].type = PassType_Basic; \
    1.27 +		pass[1].size = sizeof(CEconItemView *); \
    1.28 +		ret.flags = PASSFLAG_BYVAL; \
    1.29 +		ret.type = PassType_Basic; \
    1.30 +		ret.size = sizeof(int); \
    1.31 +		pWrapper = g_pBinTools->CreateCall(addr, CallConv_ThisCall, &ret, pass, 2))
    1.32 +	}
    1.33 +
    1.34 +	unsigned char vstk[sizeof(void *) * 2 + sizeof(char *)];
    1.35 +	unsigned char *vptr = vstk;
    1.36 +
    1.37 +	*(void **)vptr = info;
    1.38 +	vptr += sizeof(void *);
    1.39 +	*(char **)vptr = "in_game_price";
    1.40 +	vptr += sizeof(char **);
    1.41 +	*(CEconItemView **)vptr = NULL;
    1.42 +
    1.43 +	int price = 0;
    1.44 + 	pWrapper->Execute(vstk, &price);
    1.45 +#else
    1.46  	if (g_iPriceOffset == -1)
    1.47  	{
    1.48  		if (!g_pGameConf->GetOffset("WeaponPrice", &g_iPriceOffset))
    1.49 @@ -362,28 +401,21 @@
    1.50  		}
    1.51  	}
    1.52  
    1.53 +	int price = *(int *)((intptr_t)info + g_iPriceOffset);
    1.54 +#endif
    1.55 +
    1.56  	CBaseEntity *pEntity;
    1.57  	if (!(pEntity = GetCBaseEntity(params[1], true)))
    1.58  	{
    1.59  		return pContext->ThrowNativeError("Client index %d is not valid", params[1]);
    1.60  	}
    1.61  
    1.62 -	void *info = GetWeaponInfo(id);
    1.63 -	if (!info)
    1.64 -		return pContext->ThrowNativeError("Failed to get weaponinfo");
    1.65 -
    1.66 -	int price = *(int *)((intptr_t)info + g_iPriceOffset);
    1.67 -
    1.68  	if (params[3] || weaponNameOffset == -1)
    1.69  		return price;
    1.70  
    1.71  	const char *weapon_name = (const char *)((intptr_t)info + weaponNameOffset);
    1.72  
    1.73 -#if SOURCE_ENGINE == SE_CSGO
    1.74 -	return CallPriceForwardCSGO(params[1], weapon_name, price);
    1.75 -#else
    1.76  	return CallPriceForward(params[1], weapon_name, price);
    1.77 -#endif
    1.78  }
    1.79  
    1.80  static cell_t CS_GetClientClanTag(IPluginContext *pContext, const cell_t *params)
    1.81 @@ -469,6 +501,13 @@
    1.82  
    1.83  	pContext->LocalToString(params[1], &weapon);
    1.84  
    1.85 +#if SOURCE_ENGINE == SE_CSGO
    1.86 +	if (strstr(weapon, "usp_silencer") != NULL)
    1.87 +	{
    1.88 +		return SMCSWeapon_HKP2000;
    1.89 +	}
    1.90 +#endif
    1.91 +
    1.92  	int id = GetFakeWeaponID(AliasToWeaponID(weapon));
    1.93  
    1.94  	if (!IsValidWeaponID(id))