Well, I believe it shouldnt be hard to find out if you look at the function I mentioned in the previous post.
Originally Posted by tonka4ok
For the database table for talents..
Do you mean having a custom table that has your custom talent tree models or something else?
As an example the DB table could look like this:
(talentgroup, talentid) VALUES (1, 123), (1, 124), (1, 125), (2, 123), (2, 124), (2, 125);
both columns are keys. A group has many talents, but a talent can be only once in a group.
Then the code logic would be to fetch the rows:
Then later on you can use that as you want.
std::map<uint32, std::vector<uint32> > talentgroups;
talentgroups.clear(); // Erase old rows (reload)
QueryResult res = WorldDatabase.Query("SELECT talentgroup, talentid from mycustomtable"); // Get rows
if(!res) // Check that query didnt fail and isnt empty (null)
do // loop through results as long as there is a new row
// Get the data from the query
uint32 group = res->Fetch().GetUInt32();
uint32 talentid = res->Fetch().GetUInt32();
talentgroups[group].push_back(talentid); // insert the data to our talentgroup map-vector container
} while res->NextRow();
You should extend the above template to your needs like race/class combinations etc. and possibly you want to store more than just the talent ID.
ps. coded while posting, so dont expect it to be flawless and work right away.