From 68cffde7de7202324b3f7136083ca281d4babe44 Mon Sep 17 00:00:00 2001 From: "wrenczes@gmail.com" Date: Sat, 28 May 2011 05:00:40 +0000 Subject: [PATCH] Refix on issue 634. Calling EndInstance() on the DeckManager wasn't the right fix here, as it blows away all the instance data and basically nullifies the advantage of caching all the stats data. From what I could see, the problem was more a case of when a new deck was targetted, if no stats file was already present for the new deck, the old values from the previous player deck would persist. Now we clear these up before attempting to assign new values, so if the stat info doesn't exist, it'll show 0 matches / victories /etc instead of stale data belonging to another player deck. --- projects/mtg/src/DeckMetaData.cpp | 6 ++++++ projects/mtg/src/DeckStats.cpp | 2 ++ projects/mtg/src/GameStateDuel.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/projects/mtg/src/DeckMetaData.cpp b/projects/mtg/src/DeckMetaData.cpp index 216ab374c..6753160dd 100644 --- a/projects/mtg/src/DeckMetaData.cpp +++ b/projects/mtg/src/DeckMetaData.cpp @@ -59,6 +59,12 @@ void DeckMetaData::LoadStats() DeckStats * stats = DeckStats::GetInstance(); if (mIsAI) { + mPercentVictories = 0; + mVictories = 0; + mGamesPlayed = 0; + mColorIndex = ""; + mDifficulty = 0; + stats->load(mPlayerDeck); DeckStat * opponentDeckStats = stats->getDeckStat(mStatsFilename); if (opponentDeckStats) diff --git a/projects/mtg/src/DeckStats.cpp b/projects/mtg/src/DeckStats.cpp index a2cb57312..fb6dff4ac 100644 --- a/projects/mtg/src/DeckStats.cpp +++ b/projects/mtg/src/DeckStats.cpp @@ -193,6 +193,8 @@ void DeckStats::save(const std::string& filename) file << "MANA:" << it->second->manaColorIndex <Invalidate(); } } diff --git a/projects/mtg/src/GameStateDuel.cpp b/projects/mtg/src/GameStateDuel.cpp index 0e0d5a9ef..41e3c94dc 100644 --- a/projects/mtg/src/GameStateDuel.cpp +++ b/projects/mtg/src/GameStateDuel.cpp @@ -115,7 +115,7 @@ void GameStateDuel::Start() { if (mParent->players[i] == PLAYER_TYPE_HUMAN) { - DeckManager::EndInstance(); + //DeckManager::EndInstance(); decksneeded = 1; deckmenu = NEW DeckMenu(DUEL_MENU_CHOOSE_DECK, this, Fonts::OPTION_FONT, "Choose a Deck",