diff --git a/projects/mtg/Android/jni/Android.mk b/projects/mtg/Android/jni/Android.mk index 9c61ec269..6fbc87b16 100644 --- a/projects/mtg/Android/jni/Android.mk +++ b/projects/mtg/Android/jni/Android.mk @@ -133,7 +133,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \ $(MTG_PATH)/src/WFont.cpp \ $(MTG_PATH)/src/WGui.cpp \ $(MTG_PATH)/src/WResourceManager.cpp \ - $(MTG_PATH)/src/NetworkPlayer.cpp \ $(JGE_PATH)/src/SDLmain.cpp \ $(JGE_PATH)/src/Encoding.cpp \ $(JGE_PATH)/src/JAnimator.cpp \ diff --git a/projects/mtg/include/Credits.h b/projects/mtg/include/Credits.h index 066aa5669..5fd9d323d 100644 --- a/projects/mtg/include/Credits.h +++ b/projects/mtg/include/Credits.h @@ -25,7 +25,7 @@ public: bool tryToUnlock(GameObserver * game); static void load(); static map unlockables; - static void Unlockable::Destroy(); + static void Destroy(); }; diff --git a/projects/mtg/include/WResourceManagerImpl.h b/projects/mtg/include/WResourceManagerImpl.h index d06817d81..471afc3ec 100644 --- a/projects/mtg/include/WResourceManagerImpl.h +++ b/projects/mtg/include/WResourceManagerImpl.h @@ -10,7 +10,7 @@ #include "JLogger.h" #include -#define HUGE_CACHE_LIMIT 20000000 // Size of the cache for Windows and Linux +#define HUGE_CACHE_LIMIT 20000000 // Size of the cache for Windows and Linux (in bytes) #define SAMPLES_CACHE_SIZE 1500000 // Size in bytes of the cached samples #define PSI_CACHE_SIZE 500000 // Size in bytes of the cached particles #define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index 14ee18f97..fb0c86a53 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -96,8 +96,6 @@ void GameApp::Create() //_CrtSetBreakAlloc(368); LOG("starting Game"); - WResourceManager::Instance()->ResetCacheLimits(); - string systemFolder = "Res/"; string foldersRoot = ""; @@ -149,6 +147,11 @@ void GameApp::Create() LOG("options.reloadProfile()"); options.reloadProfile(); + + //Setup Cache before calling any gfx/sfx functions + WResourceManager::Instance()->ResetCacheLimits(); + + LOG("Checking for music files"); //Test for Music files presence JFileSystem * jfs = JFileSystem::GetInstance(); diff --git a/projects/mtg/src/WResourceManager.cpp b/projects/mtg/src/WResourceManager.cpp index 2b00baa55..18bd68549 100644 --- a/projects/mtg/src/WResourceManager.cpp +++ b/projects/mtg/src/WResourceManager.cpp @@ -894,13 +894,7 @@ void ResourceManagerImpl::RemoveWFonts() void ResourceManagerImpl::ResetCacheLimits() { -#if defined WIN32 || defined LINUX || defined (IOS) -#ifdef FORCE_LOW_CACHE_MEMORY - textureWCache.Resize(kConstrainedCacheLimit, MAX_CACHE_OBJECTS); -#else - textureWCache.Resize(HUGE_CACHE_LIMIT,MAX_CACHE_OBJECTS); -#endif -#else +#if defined PSP unsigned int ram = ramAvailable(); unsigned int myNewSize = ram - OPERATIONAL_SIZE + textureWCache.totalSize; if (myNewSize < TEXTURES_CACHE_MINSIZE) @@ -908,6 +902,14 @@ void ResourceManagerImpl::ResetCacheLimits() DebugTrace( "Error, Not enough RAM for Cache: " << myNewSize << " - total Ram: " << ram); } textureWCache.Resize(MIN(myNewSize, HUGE_CACHE_LIMIT), MAX_CACHE_OBJECTS); +#else +#ifdef FORCE_LOW_CACHE_MEMORY + textureWCache.Resize(kConstrainedCacheLimit, MAX_CACHE_OBJECTS); +#else + unsigned long cacheSize = options["cachesize"].number ? (unsigned long)(options["cachesize"].number) * 1024 * 1024 : HUGE_CACHE_LIMIT; + textureWCache.Resize(cacheSize,MAX_CACHE_OBJECTS); +#endif + #endif return; }