View Single Post
nosoop
Veteran Member
Join Date: Aug 2014
Old 12-20-2015 , 20:33   Re: Need a good array for this...
Reply With Quote #2

Your declaration of CreateArray wouldn't work since the declaration's first argument determines the number of values it can hold in one array entry (and functions don't allow for arguments after the closing parenthesis). The size of the adt_array is dynamic and the initial size is the second argument. I wouldn't recommend using it for your particular use case.

You could do nested adt_trie so you could just read keys out, but you'd still have to deal with iterating through the KeyValues to put them into each trie.

Out of curiosity, why not just use the KeyValues directly? Since you know exactly what keys you're working with, you can use forward slashes to read a value from a subkey.

Assuming transitional syntax:
Code:
KeyValues kv = new KeyValues("Locations");
kv.ImportFromString(keyvalue_data_from_post);

// Read tlocx from Surf section
int tlocX = kv.GetNum("Surf/tlocx");
(Also, assuming the configuration file uses your own schema, you can also use kv.GetVector to read a float[3] instead of storing the individual (x, y, z) values.)
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 12-20-2015 at 20:47. Reason: updated reasoning for CreateArray
nosoop is offline