Browse Source

Move InsertOrReplaceAttribute to manager

nosoop 1 year ago
parent
commit
73160a55f6
3 changed files with 4 additions and 5 deletions
  1. 1 1
      econmanager.cpp
  2. 1 2
      econmanager.h
  3. 2 2
      mmsplugin.cpp

+ 1 - 1
econmanager.cpp

@@ -65,7 +65,7 @@ bool CEconManager::Init(char *error, size_t maxlength) {
  * Initializes a CEconItemAttributeDefinition from a KeyValues definition, then inserts or
  * replaces the appropriate entry in the schema.
  */
-bool InsertOrReplaceAttribute(KeyValues *pAttribKV) {
+bool CEconManager::InsertOrReplaceAttribute(KeyValues *pAttribKV) {
 	const char* attrID = pAttribKV->GetName();
 	const char* attrName = pAttribKV->GetString("name");
 	

+ 1 - 2
econmanager.h

@@ -43,14 +43,13 @@ public:
 class CEconManager {
 	public:
 	bool Init(char *error, size_t maxlength);
+	bool InsertOrReplaceAttribute(KeyValues *pAttribKV);
 };
 
 // binary refers to 0x58 when iterating over the attribute map, so we'll refer to that value
 // we could also do a runtime assertion
 static_assert(sizeof(CEconItemAttributeDefinition) + 0x14 == 0x58, "CEconItemAttributeDefinition size mismatch");
 
-extern bool InsertOrReplaceAttribute(KeyValues *pAttribKV);
-
 extern CEconManager g_EconManager;
 
 #endif // _INCLUDE_DYNATTRIB_ECON_MANAGER_H_

+ 2 - 2
mmsplugin.cpp

@@ -84,7 +84,7 @@ bool DynSchema::Hook_LevelInitPost(const char *pMapName, char const *pMapEntitie
 		KeyValues *pKVAttributes = pKVMainConfig->FindKey( "attributes" );
 		if (pKVAttributes) {
 			FOR_EACH_TRUE_SUBKEY(pKVAttributes, kv) {
-				InsertOrReplaceAttribute(kv);
+				g_EconManager.InsertOrReplaceAttribute(kv);
 			}
 			META_CONPRINTF("Successfully injected custom schema %s\n", buffer);
 		} else {
@@ -106,7 +106,7 @@ bool DynSchema::Hook_LevelInitPost(const char *pMapName, char const *pMapEntitie
 			nativeAttribConfig->LoadFromFile(filesystem, pathbuf);
 			
 			FOR_EACH_TRUE_SUBKEY(nativeAttribConfig, kv) {
-				InsertOrReplaceAttribute(kv);
+				g_EconManager.InsertOrReplaceAttribute(kv);
 			}
 			
 			META_CONPRINTF("Discovered custom schema %s\n", pathbuf);