From 112f7d56d5936d3e576d92af47837b30c576714a Mon Sep 17 00:00:00 2001 From: nosoop Date: Mon, 18 Mar 2019 09:04:33 -0700 Subject: [PATCH] Rename native for consistency TF2Econ_IsValidDefinitionIndex doesn't indicate that it's used specifically for items, so I've decided to rename it. The old function is present for backcompat, though. --- scripting/include/tf_econ_data.inc | 11 ++++++++++- scripting/tf_econ_data.sp | 9 ++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/scripting/include/tf_econ_data.inc b/scripting/include/tf_econ_data.inc index 940e25e..34c9c8e 100644 --- a/scripting/include/tf_econ_data.inc +++ b/scripting/include/tf_econ_data.inc @@ -16,7 +16,7 @@ typedef ItemFilterCriteria = function bool(int defindex, any data); /** * Returns true if there is an item corresponding to the given definition index. */ -native bool TF2Econ_IsValidDefinitionIndex(int defindex); +native bool TF2Econ_IsValidItemDefinition(int defindex); /** * Returns the item's name (corresponds to the "name" key). @@ -78,6 +78,15 @@ native bool TF2Econ_TranslateWeaponEntForClass(char[] className, int maxlen, */ native Address TF2Econ_GetItemDefinitionAddress(int defindex); +/** + * @deprecated Renamed native to TF2Econ_IsValidItemDefinition so there is a better distinction + * between item and attribute definitions. + * + * This native will still be present for backwards compatibility. + */ +#pragma deprecated Use TF2Econ_IsValidItemDefinition instead +native bool TF2Econ_IsValidDefinitionIndex(int defindex); + public SharedPlugin __pl_tf_econ_data = { name = "tf_econ_data", file = "tf_econ_data.smx", diff --git a/scripting/tf_econ_data.sp b/scripting/tf_econ_data.sp index ce7b4bd..5f919b3 100644 --- a/scripting/tf_econ_data.sp +++ b/scripting/tf_econ_data.sp @@ -13,7 +13,7 @@ #include #include -#define PLUGIN_VERSION "0.5.1" +#define PLUGIN_VERSION "0.6.0" public Plugin myinfo = { name = "[TF2] Econ Data", author = "nosoop", @@ -41,7 +41,7 @@ Address offs_CEconItemDefinition_pKeyValues, public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) { RegPluginLibrary("tf_econ_data"); - CreateNative("TF2Econ_IsValidDefinitionIndex", Native_IsValidDefIndex); + CreateNative("TF2Econ_IsValidItemDefinition", Native_IsValidItemDefinition); // defindex getters CreateNative("TF2Econ_GetItemName", Native_GetItemName); @@ -60,6 +60,9 @@ public APLRes AskPluginLoad2(Handle self, bool late, char[] error, int maxlen) { // low-level stuff CreateNative("TF2Econ_GetItemDefinitionAddress", Native_GetItemDefinitionAddress); + // backwards-compatibile + CreateNative("TF2Econ_IsValidDefinitionIndex", Native_IsValidItemDefinition); + return APLRes_Success; } @@ -238,7 +241,7 @@ public int Native_GetItemDefinitionString(Handle hPlugin, int nParams) { SetNativeString(3, buffer, maxlen, true); } -public int Native_IsValidDefIndex(Handle hPlugin, int nParams) { +public int Native_IsValidItemDefinition(Handle hPlugin, int nParams) { int defindex = GetNativeCell(1); return ValidItemDefIndex(defindex); }