Implemented a lazy load pattern for the deck stats - when the DeckMenu is displaying decks, it calls LoadStats() for only the ones visible in the list. This helps reduces the lag that occurs each time we attempt to load all the AI decks during match selection.
This still could be improved - DeckMetaData's constructor loads an MTGDeck object to parse out the name of a deck from its file. This means that we crack open 106 files on the first attempt to show the list of opponent decks. I started optimizing this, but reverted, as the list itself is sorted alphabetically. Currently, with these mods, it's still taking 4 1/2 seconds on my psp to load the opponent list on the first go around. While at it, did some cleanup - removed the need for passing around a player pointer in some of the DeckStat functions, etc.
This commit is contained in:
@@ -34,11 +34,9 @@ public:
|
||||
static DeckStats * GetInstance();
|
||||
static void EndInstance();
|
||||
void saveStats(Player * player, Player * opponent, GameObserver * game);
|
||||
void save(const char * filename);
|
||||
void save(Player * player);
|
||||
void load(const char * filename);
|
||||
void load(Player * player);
|
||||
void cleanStats();
|
||||
void save(const std::string& filename);
|
||||
void load(const std::string& filename);
|
||||
|
||||
~DeckStats();
|
||||
int percentVictories(string opponentsDeckFile);
|
||||
int percentVictories();
|
||||
|
||||
Reference in New Issue
Block a user