Question on method saving() in playerdata

If you have a question about the git repository and the code, or if you have code to propose then please post in this forum.
Do not post request here.
Locked
User avatar
ph34rbot
Posts: 280
Joined: Thu Jan 07, 2010 6:33 am

Question on method saving() in playerdata

Post by ph34rbot »

Why does the game saves your colection after every game and every time you save your deck? doing so really slows the game (using psp the memory stick takes a long time to save and rewrite? )

I have made some modifications to the code, playing with the method save() in class playerdata and it really speeds up the process of writing data after games and deck saves, I haven't experienced any loss of information or any other bugs.
wololo
Site Admin
Posts: 3728
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Question on method saving() in playerdata

Post by wololo »

I think the calls to the save method have been done by several devs, who not always knew what they were actually saving. (including myself)
For example, at the end of a game, we want to save a player's statistics (win/lose), and its credits and options (because unlocked decks are saved in the options).
But you're right, the collection should be saved in the shop, and that's pretty much it...

I'd be interested to see your patch :)
User avatar
ph34rbot
Posts: 280
Joined: Thu Jan 07, 2010 6:33 am

Re: Question on method saving() in playerdata

Post by ph34rbot »

Hi wololo, thanks for this wonderful game.

At the moment the method PlayerData::save() writes information about the credits, "Story Saves" (would like to know more about this) and then a condition if (collection)
then collection->save();

In what case the condition doesn't meet? What would make collection==0?

The collection shouldn't be saved after every duel, (it's really slow in the psp having a entire colletion), and save only after deck edit because you can sell your cards in that mode and thus modifying the cards you have, and while exiting the shop.

I think that separate the code of save() to make a exclusive saveCollection() method could be a solution.

Code: Select all

int PlayerData::save(){
    std::ofstream file(options.profileFile(PLAYER_SAVEFILE).c_str());
    char writer[512];
    if (file){
      sprintf(writer, "%i\n", credits);
      file << writer;
      //Story Saves
      for (map<string,string>::iterator it = storySaves.begin(); it != storySaves.end(); ++it){
      sprintf(writer, "s %s=%s\n", it->first.c_str(), it->second.c_str());
      file << writer;
    }
    file.close();
  }
  taskList->save();
  return 1;
}
With the neccesary references:

Code: Select all

int PlayerData::savecollection(){
  if (collection) collection->save();
  return 1;
}
Locked