bool Account::load(void) {
try
{
char filebuf[200];
// account name is set on Account::new(name) so we have our name here, so we attempt loading
// as the account name is already set!
snprintf(filebuf, 200, "../Libs/Accounts/%c/%s.acc", tolower(mAccountName[0]), mAccountName.c_str());
// declare the document for the phone book
ticpp::Document book(filebuf);
// actually load the information
book.LoadFile();
// retrieve our actual account data first action.
ticpp::Element *bookObj = book.FirstChildElement("Account");
// read in our password
bookObj->GetAttribute("password", &mPassword); // assign password to our account
// saved in the clear until we can find a
// safe way to encrypt it
bookObj->GetAttribute("level", &mAccountLevel); // assign our account level (staff or not)
// staff commands are assigned by account - not by player
// so staff can safely co-exist as regular players if they
// want to play the game.
bookObj->GetAttribute("email", &mEmailAddress); // Email address used for the retrieve password
// option that is slated to come into the mud
// so that players can at-least get a new
// password should they forget.
// our iterated elements (things that have multiple childs to them)
ticpp::Iterator<ticpp::Element>entry(bookObj->FirstChildElement("Player"), "Player");
// add our players!
while ( entry != entry.end() )
{
char *stringData;
int intData = 0;
PlayerData *p = new Player();
entry->GetAttribute("name", &stringData);
p->setName(stringData);
entry->GetAttribute("level", &intData);
p->setLevel(intData);
entry->GetAttribute("x", &intData);
p->setX(intData);
entry->GetAttribute("y", &intData);
p->setY(intData);
entry->GetAttribute("roomname", &stringData);
p->setRoomName(stringData);
// advance to next item
++entry;
mPlayerList.push_back(p);
} // end of our entry loop
return true;
} catch (ticpp:Exception &e) {
// report our exception from ticpp!
Log::instance().exception(e.what());
} catch ( … ) {
Log::instance().exception(UNKNOWN_EXCEPTION);
}
// return false if the account does not exist!
return false;
}
I want to work on revising the area format so I break up the credit string to levels, creator, and name (I need to figure out something besides area name). That would allow me to redo the area command to not use the credit string. I'd also like to add versioning to the files.
What are the perils of doing so? What do I need to look out for? Has anyone done something similar and have any advice?
Best Regards,
Arholly