Skip to content

Commit

Permalink
flattening vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ASpoonPlaysGames committed Jul 30, 2023
1 parent f925936 commit 87724ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
38 changes: 34 additions & 4 deletions NorthstarDLL/mods/compiled/ns_persistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,31 +684,61 @@ void NSPersistenceDefinitionManager::HandleVarArray(std::string context, std::st
{
for (auto& it : m_enumDefs[def.arraySize])
{
HandleStructChildren(context, std::format("{}[{}]", def.identifier, it.value), def);
HandleStructChildren(context, std::format("{}[{}]", identifier, it.value), def);
}
}
else
{
int size = std::atoi(def.arraySize.c_str());
for (int i = 0; i < size; ++i)
{
HandleStructChildren(context, std::format("{}[{}]", def.identifier, i), def);
HandleStructChildren(context, std::format("{}[{}]", identifier, i), def);
}
}
}
else
{
HandleStructChildren(context, identifier, def);
}
}

void NSPersistenceDefinitionManager::HandleStructChildren(std::string context, std::string prefix, PersistentVarDef& def)
{
spdlog::info("({}) Adding var children: {} {} {} Prefix: {}", context, def.type, def.identifier, def.arraySize, prefix);
//spdlog::info("({}) Adding var children: {} {} {} Prefix: {}", context, def.type, def.identifier, def.arraySize, prefix);
if (!StructExists(context, def.type))
{
AddVar(context, def.type, prefix);
return;
}

PersistentStructDef* structDef = nullptr;
for (auto& it : m_contexts[context].structDefs)
{
if (it.name == def.type)
{
structDef = &it;
break;
}
}

for (auto& it : structDef->vars)
{
HandleVarArray(context, prefix, it);
}

}

void NSPersistenceDefinitionManager::AddVar(std::string context, std::string type, std::string identifier)
{
spdlog::info("{} {} ({}) ", type, identifier, context);
}

void ConCommand_load_pdiff(const CCommand& args)
{
spdlog::info("Loading pdiffs from files...");
g_persistenceDefinitionManager->LoadPdiff("C:\\Users\\Jack\\Desktop\\Persistence Stuff\\Version 1\\cool.pdiff", "Test.Pdiff");
g_persistenceDefinitionManager->LoadPdiff("C:\\Users\\Jack\\Desktop\\Persistence Stuff\\Version 1\\awesome.pdiff", "Second.Pdiff");
g_persistenceDefinitionManager->PrintPdiffs();
//g_persistenceDefinitionManager->PrintPdiffs();
g_persistenceDefinitionManager->SetupVars();
}

Expand Down
1 change: 1 addition & 0 deletions NorthstarDLL/mods/compiled/ns_persistence.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class NSPersistenceDefinitionManager

void HandleVarArray(std::string context, std::string prefix, PersistentVarDef& def);
void HandleStructChildren(std::string context, std::string prefix, PersistentVarDef& def);
void AddVar(std::string context, std::string type, std::string identifier);
//void AddVar(std::string type, std::string identifier);

static constexpr const char* m_whitespaceChars = " \n\r\t\f\v";
Expand Down

0 comments on commit 87724ff

Please sign in to comment.