Are you sure you don't want to use the KeyValues? I'd say it's a good fit for what you're trying to do, provided it's accessible across your plugin (i.e., you read it once into a global handle and just call its getters / setters; if you want to write out user input, figure out what you need to change and write that specific stuff back out). As far as I can see, there's nothing dirty about accessing KeyValues that have already been read from a file (as long as you don't read from disk every time you just need to
KvGetNum()).
Treat it as just another data structure like
adt_* instead of just a (de)serialization format and you'll be fine.
But anyways, as requested, here's an example for nested
adt_trie in 1.7:
Code:
StringMap config = CreateTrie();
// note: I'm not 100% sure of how to even do iterative lookups, just basing this off of the wiki
if (!kv.GotoFirstSubKey()) {
// your config is broked
}
do {
char section[256];
kv.GetSectionName(section, sizeof(section));
StringMap subtrie = new StringMap();
int tloc[3];
tloc[0] = kv.GetNum("tlocx");
/* repeat for all your position values */
subtrie.SetArray("tloc", tloc, sizeof(tloc));
/* same thing with the rest of your values */
config.SetValue(section, subtrie);
} while (kv.GotoNextKey());
// Read TradeRooms / tloc
StringMap tradeRooms;
if (config.GetValue("TradeRooms", tradeRooms)) {
int tloc[3];
tradeRooms.GetArray("tloc", tloc, sizeof(tloc));
}
// I have no idea how to write this stuff back out to KV, but it will involve iterating over the keys again after creating a StringMapSnapshot / calling CreateTrieSnapshot
For
adt_array, I'd expect that you just do
CreateArray(7); and pack the seven values into one array and store the position of that array in a way that you can retrieve it (either using another
adt_array with
arrayList.FindString(section) or an
adt_trie with
trie.GetValue(section)).
__________________