So I was brainstorming on how to do a clansystem, and the structure seemed basic enough. You got a clan datum, setters/getters, New() to set leader/name/whatever, etc.
Now, the problems I am foreseeing have to do with saving.
- members list containing mobs (rollback bugs)
- loading/saving clans AND their properties in seperate files, as well as preferably a clan list
- clans calling New() all over again when being loaded
So what's the idea way to implement saving/loading in a clan system without the above happening?
EDIT: So far I've managed to make everything functional by saving things as text, making the clans on world/New(), and on mob Login(), search if the clan with the name his clan var (which is now text) exists, if so, set that clan as his clan.
Bit messy, but it works.
If player names are exclusive, save a list of names. Otherwise associate character name with ckey and save that.
You haven't told what properties a clan has so I don't understand your question. If you're asking how to associate a 'clan' with its respective 'clan datum': give each clan a unique identifier. Associate that identifier with respective clan savefile (or subdirectory, if you don't have separate savefiles). So for example ID "001" might point to "001.sav", which contains the information of the "Mega Ninjaz" clan.
Preferably, each /mob will have a "myClanID" property, so you only need to load clans whose players are currently online. If you use a clever hash, you can also associate clan id with clan name, so you can load clans directly by name, on demand. Alternatively you can save a table associating clan name => clan id.
Unavoidable, but why is this a problem?