Skip to content

Commit

Permalink
Drop caching from internal schema accessors
Browse files Browse the repository at this point in the history
Closes #14.
  • Loading branch information
nosoop committed Feb 23, 2022
1 parent a8e2248 commit 80b15be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
8 changes: 2 additions & 6 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.18.1"
#define PLUGIN_VERSION "0.18.2"
public Plugin myinfo = {
name = "[TF2] Econ Data",
author = "nosoop",
Expand Down Expand Up @@ -394,11 +394,7 @@ Address GetEconItemDefinition(int defindex) {
}

static Address GetEconDefaultItemDefinition() {
static Address s_pDefaultItemDefinition;
if (!s_pDefaultItemDefinition) {
s_pDefaultItemDefinition = GetEconItemDefinition(TF_ITEMDEF_DEFAULT);
}
return s_pDefaultItemDefinition;
return GetEconItemDefinition(TF_ITEMDEF_DEFAULT);
}

public int Native_GetAttributeDefinitionAddress(Handle hPlugin, int nParams) {
Expand Down
9 changes: 3 additions & 6 deletions scripting/tf_econ_data/attached_particle_systems.sp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,9 @@ static bool IsParticleSystemRightChild(int index) {

// get address of attachedparticlesystem_t in CUtlRBTree by index
static Address GetAttachedParticleSystemEntry(int index) {
static Address s_pParticleData;
if (!s_pParticleData) {
Address pParticleSystemTree = GetParticleSystemTree();
s_pParticleData = DereferencePointer(pParticleSystemTree + view_as<Address>(0x08));
}
return s_pParticleData + view_as<Address>(index * ATTACHED_PARTICLE_SYSTEM_STRUCT_SIZE);
Address pParticleSystemTree = GetParticleSystemTree();
Address pParticleData = DereferencePointer(pParticleSystemTree + view_as<Address>(0x08));
return pParticleData + view_as<Address>(index * ATTACHED_PARTICLE_SYSTEM_STRUCT_SIZE);
}

static Address GetParticleSystemTree() {
Expand Down
9 changes: 1 addition & 8 deletions scripting/tf_econ_data/quality_definition.sp
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,9 @@ static int GetEconQualityDefinitionCount() {
}

static Address GetEconQualityDefinitionTree() {
static Address s_pItemQualityTree;
if (s_pItemQualityTree) {
return s_pItemQualityTree;
}

Address pSchema = GetEconItemSchema();
if (!pSchema) {
return Address_Null;
}

s_pItemQualityTree = pSchema + offs_CEconItemSchema_ItemQualities;
return s_pItemQualityTree;
return pSchema + offs_CEconItemSchema_ItemQualities;
}
9 changes: 1 addition & 8 deletions scripting/tf_econ_data/rarity_definition.sp
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,9 @@ static int GetEconRarityDefinitionCount() {
}

static Address GetEconRarityDefinitionTree() {
static Address s_pItemRarityTree;
if (s_pItemRarityTree) {
return s_pItemRarityTree;
}

Address pSchema = GetEconItemSchema();
if (!pSchema) {
return Address_Null;
}

s_pItemRarityTree = pSchema + offs_CEconItemSchema_ItemRarities;
return s_pItemRarityTree;
return pSchema + offs_CEconItemSchema_ItemRarities;
}

0 comments on commit 80b15be

Please sign in to comment.