diff --git a/projects/mtg/include/AIPlayer.h b/projects/mtg/include/AIPlayer.h index 79b1062d1..487781e42 100644 --- a/projects/mtg/include/AIPlayer.h +++ b/projects/mtg/include/AIPlayer.h @@ -40,12 +40,8 @@ public: id = currentId++; }; - AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL) - : efficiency(-1), ability(NULL), player(NULL), click(c), target(t) - { - id = currentId++; - }; - + AIAction(MTGCardInstance * c, MTGCardInstance * t = NULL); + AIAction(Player * p) : efficiency(-1), ability(NULL), player(p), click(NULL), target(NULL) { diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index a0bc6e183..39c6790a0 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -2,6 +2,7 @@ #include "AIPlayer.h" #include "CardDescriptor.h" +#include "CardSelectorSingleton.h" #include "AIStats.h" #include "AllAbilities.h" #include "ExtraCost.h" @@ -9,10 +10,35 @@ #include "GameStateDuel.h" #include "DeckManager.h" + const char * const MTG_LAND_TEXTS[] = { "artifact", "forest", "island", "mountain", "swamp", "plains", "other lands" }; int AIAction::currentId = 0; +AIAction::AIAction(MTGCardInstance * c, MTGCardInstance * t) + : efficiency(-1), ability(NULL), player(NULL), click(c), target(t) +{ + id = currentId++; + + // useability tweak - assume that the user is probably going to want to see the full res card, + // so prefetch it. The idea is that we do it here as we want to start the prefetch before it's time to render, + // and waiting for it to actually go into play is too late, as we start drawing the card during the interrupt window. + // This is a good intercept point, as the AI has committed to using this card. + + // if we're not in text mode, always get the thumb + if (CardSelectorSingleton::Instance()->GetDrawMode() != DrawMode::kText) + { + DebugTrace("Prefetching AI card going into play: " << c->getImageName()); + WResourceManager::Instance()->RetrieveCard(c, RETRIEVE_THUMB); + + // also cache the large image if we're using kNormal mode + if (CardSelectorSingleton::Instance()->GetDrawMode() == DrawMode::kNormal) + { + WResourceManager::Instance()->RetrieveCard(c); + } + } +} + int AIAction::Act() { GameObserver * g = GameObserver::GetInstance(); diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index f2ab0f900..8680f26c8 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -1,5 +1,6 @@ #include "PrecompiledHeader.h" +#include "CardSelectorSingleton.h" #include "MTGGameZones.h" #include "Player.h" #include "WEvent.h" @@ -237,6 +238,23 @@ void MTGPlayerCards::drawFromLibrary() } MTGCardInstance * toMove = library->cards[library->nb_cards - 1]; library->lastCardDrawn = toMove; + + // useability tweak - assume that the user is probably going to want to see the new card, + // so prefetch it. + + // if we're not in text mode, always get the thumb + if (CardSelectorSingleton::Instance()->GetDrawMode() != DrawMode::kText) + { + DebugTrace("Prefetching AI card going into play: " << toMove->getImageName()); + WResourceManager::Instance()->RetrieveCard(toMove, RETRIEVE_THUMB); + + // also cache the large image if we're using kNormal mode + if (CardSelectorSingleton::Instance()->GetDrawMode() == DrawMode::kNormal) + { + WResourceManager::Instance()->RetrieveCard(toMove); + } + } + putInZone(toMove, library, hand); } diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index bec6b618f..5212b1710 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -936,8 +936,6 @@ void ResourceManagerImpl::ResetCacheLimits() DebugTrace( "Error, Not enough RAM for Cache: " << myNewSize << " - total Ram: " << ram); } textureWCache.Resize(MIN(myNewSize, HUGE_CACHE_LIMIT), MAX_CACHE_OBJECTS); - - DebugTrace("Texture cache resized to " << myNewSize); #endif return; } @@ -1020,6 +1018,7 @@ template void WCache::Resize(unsigned long size, int items) { maxCacheSize = size; + DebugTrace(typeid(cacheActual).name() << " cache resized to " << size << " bytes"); #ifdef DEBUG_CACHE std::ostringstream stream; @@ -1463,7 +1462,7 @@ bool WCache::Delete(cacheItem * item) cacheItems--; - DebugTrace("Deleting cache item " << ToHex(item)); + DebugTrace("Deleting cache item " << ToHex(item) << ", cache reduced by " << isize << " bytes"); SAFE_DELETE(item); return true; }