Skip to content

Commit

Permalink
Rename native for consistency
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nosoop committed Mar 18, 2019
1 parent 706d54c commit 112f7d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
11 changes: 10 additions & 1 deletion scripting/include/tf_econ_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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",
Expand Down
9 changes: 6 additions & 3 deletions scripting/tf_econ_data.sp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <stocksoup/handles>
#include <stocksoup/memory>

#define PLUGIN_VERSION "0.5.1"
#define PLUGIN_VERSION "0.6.0"
public Plugin myinfo = {
name = "[TF2] Econ Data",
author = "nosoop",
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 112f7d5

Please sign in to comment.