Added WeaponIDToAlias native to CStrike extension (bug 5460, r=psychonic).
authorKyle Sanderson <kyle.leet@gmail.com>
Fri Dec 14 15:12:22 2012 -0500 (2012-12-14)
changeset 3702a0256b609078
parent 3701 43ae98b168bb
child 3703 391951cdde71
Added WeaponIDToAlias native to CStrike extension (bug 5460, r=psychonic).
extensions/cstrike/natives.cpp
extensions/cstrike/util_cstrike.cpp
extensions/cstrike/util_cstrike.h
gamedata/sm-cstrike.games/game.csgo.txt
gamedata/sm-cstrike.games/game.css.txt
plugins/include/cstrike.inc
     1.1 --- a/extensions/cstrike/natives.cpp	Fri Dec 14 15:07:47 2012 -0500
     1.2 +++ b/extensions/cstrike/natives.cpp	Fri Dec 14 15:12:22 2012 -0500
     1.3 @@ -294,6 +294,22 @@
     1.4  	return 1;
     1.5  }
     1.6  
     1.7 +static cell_t CS_WeaponIDToAlias(IPluginContext *pContext, const cell_t *params)
     1.8 +{
     1.9 +	char *dest;
    1.10 +
    1.11 +	pContext->LocalToString(params[2], &dest);
    1.12 +
    1.13 +	const char *ret = WeaponIDToAlias(params[1]);
    1.14 +	
    1.15 +	if (ret == NULL)
    1.16 +	{
    1.17 +		return 0;
    1.18 +	}
    1.19 +	
    1.20 +	return strncopy(dest, ret, params[3]);
    1.21 +}
    1.22 +
    1.23  static cell_t CS_GetTranslatedWeaponAlias(IPluginContext *pContext, const cell_t *params)
    1.24  {
    1.25  	char *weapon;
    1.26 @@ -669,6 +685,7 @@
    1.27  	{"CS_SetTeamScore",				CS_SetTeamScore},
    1.28  	{"CS_GetMVPCount",				CS_GetMVPCount},
    1.29  	{"CS_SetMVPCount",				CS_SetMVPCount},
    1.30 +	{"CS_WeaponIDToAlias",			CS_WeaponIDToAlias},
    1.31  	{NULL,							NULL}
    1.32  };
    1.33  
     2.1 --- a/extensions/cstrike/util_cstrike.cpp	Fri Dec 14 15:07:47 2012 -0500
     2.2 +++ b/extensions/cstrike/util_cstrike.cpp	Fri Dec 14 15:12:22 2012 -0500
     2.3 @@ -129,6 +129,35 @@
     2.4  	pWrapper->Execute(vstk, &weaponID);
     2.5  
     2.6  	return weaponID;
     2.7 +}
     2.8 +
     2.9 +const char *WeaponIDToAlias(int weaponID)
    2.10 +{
    2.11 +	static ICallWrapper *pWrapper = NULL;
    2.12 +
    2.13 +	if (!pWrapper)
    2.14 +	{
    2.15 +		REGISTER_ADDR("WeaponIDToAlias", 0,
    2.16 +			PassInfo pass[1]; \
    2.17 +			PassInfo retpass; \
    2.18 +			pass[0].flags = PASSFLAG_BYVAL; \
    2.19 +			pass[0].type = PassType_Basic; \
    2.20 +			pass[0].size = sizeof(int); \
    2.21 +			retpass.flags = PASSFLAG_BYVAL; \
    2.22 +			retpass.type = PassType_Basic; \
    2.23 +			retpass.size = sizeof(const char *); \
    2.24 +			pWrapper = g_pBinTools->CreateCall(addr, CallConv_Cdecl, &retpass, pass, 1))
    2.25 +	}
    2.26 +	const char *ret = NULL;
    2.27 +	
    2.28 +	unsigned char vstk[sizeof(int)];
    2.29 +	unsigned char *vptr = vstk;
    2.30 +
    2.31 +	*(int *)vptr = GetRealWeaponID(weaponID);
    2.32 +
    2.33 +	pWrapper->Execute(vstk, &ret);
    2.34 +
    2.35 +	return ret;
    2.36  }
    2.37  int GetRealWeaponID(int weaponId)
    2.38  {
     3.1 --- a/extensions/cstrike/util_cstrike.h	Fri Dec 14 15:07:47 2012 -0500
     3.2 +++ b/extensions/cstrike/util_cstrike.h	Fri Dec 14 15:12:22 2012 -0500
     3.3 @@ -153,7 +153,9 @@
     3.4  
     3.5  const char *GetTranslatedWeaponAlias(const char *weapon);
     3.6  
     3.7 -int AliasToWeaponID(const char *weapon);
     3.8 +int AliasToWeaponID(const char *weapon);
     3.9 +
    3.10 +const char *WeaponIDToAlias(int weaponID);
    3.11  
    3.12  int GetRealWeaponID(int weaponId);
    3.13  
     4.1 --- a/gamedata/sm-cstrike.games/game.csgo.txt	Fri Dec 14 15:07:47 2012 -0500
     4.2 +++ b/gamedata/sm-cstrike.games/game.csgo.txt	Fri Dec 14 15:12:22 2012 -0500
     4.3 @@ -129,6 +129,13 @@
     4.4  				"linux"		"@_Z15AliasToWeaponIDPKc"
     4.5  				"mac"		"@_Z15AliasToWeaponIDPKc"
     4.6  			}
     4.7 +			"WeaponIDToAlias"
     4.8 +			{
     4.9 +				"library"	"server"
    4.10 +				"windows"	"\x55\x8B\xEC\x8B\x4D\x08\x33\xC0\xEB\x2A\x8D\x9B\x00\x00\x00\x00\x39\x0C\xC5\x2A\x2A\x2A\x2A\x74\x2A\x40\x83\xF8\x37\x72\x2A\x33\xC0\x5D"
    4.11 +				"linux"		"@_Z15WeaponIDToAliasi"
    4.12 +				"mac"		"@_Z15WeaponIDToAliasi"
    4.13 +			}
    4.14  			"SetClanTag"
    4.15  			{
    4.16  				"library"	"server"
     5.1 --- a/gamedata/sm-cstrike.games/game.css.txt	Fri Dec 14 15:07:47 2012 -0500
     5.2 +++ b/gamedata/sm-cstrike.games/game.css.txt	Fri Dec 14 15:12:22 2012 -0500
     5.3 @@ -129,6 +129,13 @@
     5.4  				"linux"		"@_Z15AliasToWeaponIDPKc"
     5.5  				"mac"		"@_Z15AliasToWeaponIDPKc"
     5.6  			}
     5.7 +			"WeaponIDToAlias"
     5.8 +			{
     5.9 +				"library"	"server"
    5.10 +				"windows"	"\x55\x8B\xEC\x8B\x4D\x08\x33\xC0\xEB\x2A\x8D\x9B\x00\x00\x00\x00\x39\x0C\xC5\x2A\x2A\x2A\x2A\x74\x2A\x40\x83\xF8\x26\x72\x2A\x33\xC0\x5D"
    5.11 +				"linux"		"@_Z15WeaponIDToAliasi"
    5.12 +				"mac"		"@_Z15WeaponIDToAliasi"
    5.13 +			}
    5.14  			
    5.15  			//For mac we use think since CheckWinLimit dosnt exist on mac.
    5.16  			"CheckWinLimit"
     6.1 --- a/plugins/include/cstrike.inc	Fri Dec 14 15:07:47 2012 -0500
     6.2 +++ b/plugins/include/cstrike.inc	Fri Dec 14 15:12:22 2012 -0500
     6.3 @@ -312,6 +312,15 @@
     6.4  native CSWeaponID:CS_AliasToWeaponID(const String:alias[]);
     6.5  
     6.6  /**
     6.7 + * Gets a alias from a weaponID
     6.8 + * @param weaponID		WeaponID to get alias for.
     6.9 + * @param destination	Destination string to hold the weapon alias.
    6.10 + * @param len			Length of the destination array.
    6.11 + * @return				Returns number of cells written.
    6.12 + */
    6.13 +native CS_WeaponIDToAlias(weaponID, String:destination[], len);
    6.14 +
    6.15 +/**
    6.16   * Do not edit below this line!
    6.17   */
    6.18  public Extension:__ext_cstrike =