PDA

View Full Version : passing vector to perl event


c0ncrete
12-13-2012, 01:04 AM
i'm attempting to implement a custom quest event. the data i would like to export is stored in two sequences of pairs stored in vectors, and the vectors will likely vary in size.

seeing as how EventPlayer() only takes data as a string and extra data is a numeric value, i need to know the best way to convert and pass the data. i have seen a char sequence built and passed to EVENT_LOOT, then broken up via the Seperator class.

i was considering simply building two non-delimited char sequences, then putting them together in a single string, and passing the length of the first sequence as extradata so i could know where one data set ended and the other began. i could then either pass them both directly to perl and parse the data there (unpack), or break the data up in c++ and try my hand at exporting a hash (like qglobals).

i'm trying to avoid having to run additional database queries in perl by handling things in this manner. i'm still learning c++ (mostly by example, trial, and error), and would appreciate any further insight or suggestions as to the best way to handle this.

Tabasco
12-13-2012, 10:32 AM
I don't think I have enough information to suggest a specific course of action here, but there are a lot of possibilities.

Your vectors sound like a sort of linked list, but if that's the case, you would most likely be better off using a std::map. In fact, for the purpose of exporting hashes the prototype for PerlembParser::ExportHash takes a map<string, string>.
If you could store it in mob or client you wouldn't need to pass it at all since you would already have a handle on it.

If it's temporary data that is generated uniquely at event time and then discarded, it has the potential to be a bit more complicated.
Depending on just how large these pairs get, you could send perl a string delineated like a query string and let perl do the work since that's what it's good at.
name=value&name=value&name=value, etc.

c0ncrete
12-13-2012, 11:23 AM
it's trade skill recipe data i'm trying to work with. i'm currently iterating over the vectors and building a stringstream with the information i need, passing that to EventPlayer, breaking up parts of it, exporting those to perl as scalars, and then using split() to build hashes from two of those scalars. it's a bit of a hack job, but it looks like it'll work like i wanted without more source modifications. i'm much more comfortable in perl. i just wanted to keep from having to connect to the database to fetch the recipe information when it was already present in the vectors.