From 1538074b4d9a6486386ed4d564a533a83f83c1cf Mon Sep 17 00:00:00 2001 From: orng Date: Wed, 25 Mar 2026 02:47:51 -0500 Subject: [PATCH] refactor: remove integer caching --- Minecraft.Client/Minecraft.cpp | 18 +- Minecraft.Client/MinecraftServer.cpp | 10 +- .../Common/Network/GameNetworkManager.cpp | 5 - .../Common/UI/UIScene_CreateWorldMenu.cpp | 2 - .../Platform/Common/UI/UIScene_LoadMenu.cpp | 3 +- .../Common/XUI/XUI_MultiGameCreate.cpp | 20 +- .../Platform/Durango/Durango_Minecraft.cpp | 1463 +++++----- .../Platform/Linux/Linux_Minecraft.cpp | 3 - .../Platform/Orbis/Orbis_Minecraft.cpp | 2378 +++++++++------- .../Platform/PS3/PS3_Minecraft.cpp | 2430 +++++++++-------- .../Platform/PS3/Xbox_Minecraft.cpp | 784 +++--- .../Platform/PSVita/PSVita_Minecraft.cpp | 1630 ++++++----- .../Windows64/Windows64_Minecraft.cpp | 1606 ++++++----- .../Platform/Xbox/Xbox_Minecraft.cpp | 1780 ++++++------ Minecraft.Client/Rendering/GameRenderer.cpp | 31 +- Minecraft.Client/Rendering/LevelRenderer.cpp | 22 +- ...net.minecraft.world.level.newbiome.layer.h | 3 +- Minecraft.World/Util/IntCache.cpp | 140 - Minecraft.World/Util/IntCache.h | 30 - .../WorldGen/Biomes/BiomeSource.cpp | 12 +- .../WorldGen/Layers/AddIslandLayer.cpp | 4 +- .../Layers/AddMushroomIslandLayer.cpp | 4 +- .../WorldGen/Layers/AddSnowLayer.cpp | 4 +- .../WorldGen/Layers/BiomeInitLayer.cpp | 4 +- .../WorldGen/Layers/BiomeOverrideLayer.cpp | 4 +- .../WorldGen/Layers/DownfallLayer.cpp | 4 +- .../WorldGen/Layers/DownfallMixerLayer.cpp | 4 +- Minecraft.World/WorldGen/Layers/FlatLayer.cpp | 4 +- .../WorldGen/Layers/FuzzyZoomLayer.cpp | 4 +- .../Layers/GrowMushroomIslandLayer.cpp | 4 +- .../WorldGen/Layers/IslandLayer.cpp | 4 +- .../WorldGen/Layers/RegionHillsLayer.cpp | 5 +- .../WorldGen/Layers/RiverInitLayer.cpp | 4 +- .../WorldGen/Layers/RiverLayer.cpp | 4 +- .../WorldGen/Layers/RiverMixerLayer.cpp | 4 +- .../WorldGen/Layers/ShoreLayer.cpp | 4 +- .../WorldGen/Layers/SmoothLayer.cpp | 4 +- .../WorldGen/Layers/SmoothZoomLayer.cpp | 6 +- .../WorldGen/Layers/SwampRiversLayer.cpp | 5 +- .../WorldGen/Layers/TemperatureLayer.cpp | 4 +- .../WorldGen/Layers/TemperatureMixerLayer.cpp | 4 +- .../WorldGen/Layers/VoronoiZoom.cpp | 4 +- Minecraft.World/WorldGen/Layers/ZoomLayer.cpp | 4 +- 43 files changed, 6622 insertions(+), 5844 deletions(-) delete mode 100644 Minecraft.World/Util/IntCache.cpp delete mode 100644 Minecraft.World/Util/IntCache.h diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 140703f53..1e9a1c954 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -61,7 +61,6 @@ #include "../Minecraft.World/Headers/net.minecraft.world.entity.animal.h" #include "../Minecraft.World/Headers/net.minecraft.world.entity.monster.h" #include "../Minecraft.World/WorldGen/Features/StrongholdFeature.h" -#include "../Minecraft.World/Util/IntCache.h" #include "../Minecraft.World/Entities/Mobs/Villager.h" #include "../Minecraft.World/Level/Storage/SparseLightStorage.h" #include "../Minecraft.World/Level/Storage/SparseDataStorage.h" @@ -2078,9 +2077,11 @@ void Minecraft::run_middle() { // If there's an unoccupied quadrant, then clear that to black if (unoccupiedQuadrant > -1) { // render a logo - RenderManager.StateSetViewport((C4JRender::eViewportType)( - C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT + - unoccupiedQuadrant)); + RenderManager.StateSetViewport(( + C4JRender:: + eViewportType)(C4JRender:: + VIEWPORT_TYPE_QUADRANT_TOP_LEFT + + unoccupiedQuadrant)); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); @@ -2400,7 +2401,6 @@ void Minecraft::levelTickUpdateFunc(void* pParam) { void Minecraft::levelTickThreadInitFunc() { AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); } @@ -2596,8 +2596,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (player->isRiding()) { std::shared_ptr mount = player->riding; - if (mount->instanceof (eTYPE_MINECART) || mount->instanceof - (eTYPE_BOAT)) { + if (mount->instanceof(eTYPE_MINECART) || + mount->instanceof(eTYPE_BOAT)) { *piAlt = IDS_TOOLTIPS_EXIT; } else { *piAlt = IDS_TOOLTIPS_DISMOUNT; @@ -3623,7 +3623,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { break; default: - if (hitResult->entity->instanceof (eTYPE_MOB)) { + if (hitResult->entity->instanceof(eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast( hitResult->entity); @@ -4914,7 +4914,7 @@ void Minecraft::main() { } app.DebugPrintf("\n\n\n\n\n"); - + for(unsigned int i = 0; i < 256; ++i) { if(Tile::tiles[i] != NULL) diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index 96fffb80f..a08f48ac9 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -37,7 +37,6 @@ #include "Player/ServerPlayer.h" #include "Rendering/GameRenderer.h" #include "../Minecraft.World/Util/ThreadName.h" -#include "../Minecraft.World/Util/IntCache.h" #include "../Minecraft.World/Level/Storage/CompressedTileStorage.h" #include "../Minecraft.World/Level/Storage/SparseLightStorage.h" #include "../Minecraft.World/Level/Storage/SparseDataStorage.h" @@ -315,7 +314,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) { MinecraftServer* server = (MinecraftServer*)lpParam; Entity::useSmallIds(); // This thread can end up spawning entities as // resources - IntCache::CreateNewThreadStorage(); AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); @@ -366,7 +364,6 @@ int MinecraftServer::runPostUpdate(void* lpParam) { LeaveCriticalSection(&server->m_postProcessCS); // #endif //__PS3__ Tile::ReleaseThreadStorage(); - IntCache::ReleaseThreadStorage(); AABB::ReleaseThreadStorage(); Vec3::ReleaseThreadStorage(); Level::destroyLightingCache(); @@ -889,8 +886,7 @@ void MinecraftServer::overwriteHellBordersForNewWorldSize(ServerLevel* level, #endif -void MinecraftServer::setProgress(const std::wstring& status, - int progress) { +void MinecraftServer::setProgress(const std::wstring& status, int progress) { progressStatus = status; this->progress = progress; // logger.info(status + ": " + progress + "%"); @@ -1817,9 +1813,7 @@ void MinecraftServer::info(const std::wstring& string) {} void MinecraftServer::warn(const std::wstring& string) {} -std::wstring MinecraftServer::getConsoleName() { - return L"CONSOLE"; -} +std::wstring MinecraftServer::getConsoleName() { return L"CONSOLE"; } ServerLevel* MinecraftServer::getLevel(int dimension) { if (dimension == -1) diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp index 625b526e7..a26addc80 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp @@ -25,7 +25,6 @@ #include "../../Minecraft.Client/UI/Gui.h" #include "../../Minecraft.Client/Rendering/LevelRenderer.h" -#include "../../Minecraft.World/Util/IntCache.h" #include "../GameRules/ConsoleGameRules.h" #include "GameNetworkManager.h" @@ -952,7 +951,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) { Vec3::UseDefaultThreadStorage(); Compression::UseDefaultThreadStorage(); Tile::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); g_NetworkManager.m_bNetworkThreadRunning = true; bool success = g_NetworkManager._RunNetworkGame(lpParameter); @@ -984,7 +982,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) { #endif Tile::ReleaseThreadStorage(); - IntCache::ReleaseThreadStorage(); return 0; } @@ -1012,7 +1009,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { SetThreadName(-1, "Minecraft Server thread"); AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); Compression::UseDefaultThreadStorage(); OldChunkStorage::UseDefaultThreadStorage(); Entity::useSmallIds(); @@ -1027,7 +1023,6 @@ int CGameNetworkManager::ServerThreadProc(void* lpParameter) { Tile::ReleaseThreadStorage(); AABB::ReleaseThreadStorage(); Vec3::ReleaseThreadStorage(); - IntCache::ReleaseThreadStorage(); Level::destroyLightingCache(); if (lpParameter != NULL) delete (NetworkGameInitData*)lpParameter; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp index 24dc60826..43dbade82 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp @@ -9,7 +9,6 @@ #include "../../Minecraft.World/Level/Storage/LevelSettings.h" #include "../../Minecraft.World/Util/StringHelpers.h" #include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h" -#include "../../Minecraft.World/Util/IntCache.h" #include "../../Minecraft.World/Level/Storage/LevelType.h" #include "../../Minecraft.Client/Textures/Packs/DLCTexturePack.h" @@ -1373,7 +1372,6 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam, } else { // This is NOT called from a storage manager thread, and is in // fact called from the main thread in the Profile library tick. - // Therefore we use the main threads IntCache. CreateGame(pClass, localUsersMask); } } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp index d84330c84..1425a32bb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp @@ -1873,7 +1873,6 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void* pParam, bool bContinue, #endif // This is NOT called from a storage manager thread, and is in // fact called from the main thread in the Profile library tick. - // Therefore we use the main threads IntCache. StartGameFromSave(pClass, localUsersMask); } } @@ -1935,4 +1934,4 @@ int UIScene_LoadMenu::MustSignInReturnedPSN(void* pParam, int iPad, // pClass->m_bIgnoreInput=false; // return 0; // } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp index 819264d17..8dcd1e834 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp @@ -9,7 +9,6 @@ #include "../../Minecraft.World/Level/Storage/LevelSettings.h" #include "XUI_MultiGameLaunchMoreOptions.h" #include "../../Minecraft.World/WorldGen/Biomes/BiomeSource.h" -#include "../../Minecraft.World/Util/IntCache.h" #include "../../Minecraft.World/Level/Storage/LevelType.h" #include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h" #include "../../Minecraft.Client/Textures/Packs/TexturePack.h" @@ -614,12 +613,14 @@ int CScene_MultiGameCreate::WarningTrialTexturePackReturned( ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); } else { - // This is called from a storage manager thread... need to set up - // thread storage for IntCache as CreateGame requires this to search - // for a suitable seed if we haven't set a seed. - IntCache::CreateNewThreadStorage(); + // 4J - This is called from a storage manager thread... need to set + // up thread storage for IntCache as CreateGame requires this to + // search for a suitable seed if we haven't set a seed. + // + // 4jcraft - removed reliance on int caching, old 4J comment is + // moot, and we can search for suitable seeds without said cache + // initialization. CreateGame(pScene, 0); - IntCache::ReleaseThreadStorage(); } } @@ -825,9 +826,11 @@ int CScene_MultiGameCreate::ConfirmCreateReturned( // This is called from a storage manager thread... need to set // up thread storage for IntCache as CreateGame requires this to // search for a suitable seed if we haven't set a seed. - IntCache::CreateNewThreadStorage(); + // + // 4jcraft - removed reliance on int caching, old 4J comment is + // moot, and we can search for suitable seeds without said cache + // initialization. CreateGame(pClass, 0); - IntCache::ReleaseThreadStorage(); } } } else { @@ -895,7 +898,6 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void* pParam, } else { // This is NOT called from a storage manager thread, and is in // fact called from the main thread in the Profile library tick. - // Therefore we use the main threads IntCache. CreateGame(pClass, dwLocalUsersMask); } } diff --git a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp index ef41add7c..dff64785d 100644 --- a/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp +++ b/Minecraft.Client/Platform/Durango/Durango_Minecraft.cpp @@ -28,214 +28,371 @@ #include "../../Rendering/Tesselator.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "Resource.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" #include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h" #include -//using namespace Windows::Xbox::Input; +// using namespace Windows::Xbox::Input; using namespace Windows::Foundation::Collections; -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 -//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) -//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) -//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) +// #define THREE_MB 3145728 // minimum save size (checking for this on a +// selected device) #define FIVE_MB 5242880 // minimum save size (checking for +// this on a selected device) #define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR +// space required for a save (checking for this on a selected device) +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) -//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +// #define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 -DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= -{ +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES] = { #ifdef _XBOX - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, #else - 0,0,0,0,0 + 0, 0, 0, 0, 0 #endif }; //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- - BOOL g_bWidescreen = TRUE; +void DefineActions(void) { + // The app needs to define the actions required, and the possible mappings + // for these -void DefineActions(void) -{ - // The app needs to define the actions required, and the possible mappings for these + // Split into Menu actions, and in-game actions - // Split into Menu actions, and in-game actions + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_GTC_PAUSE, + _360_GTC_PAUSE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_GTC_RESUME, + _360_GTC_PLAY); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_GTC_PAUSE, _360_GTC_PAUSE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_GTC_RESUME, _360_GTC_PLAY); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK | _360_GTC_VIEW); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK | _360_GTC_VIEW); - - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_GTC_PAUSE, _360_GTC_PAUSE); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_GTC_RESUME, _360_GTC_PLAY); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_GTC_PAUSE, + _360_GTC_PAUSE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_GTC_RESUME, + _360_GTC_PLAY); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK | _360_GTC_VIEW); - - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); - - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B | _360_GTC_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK | _360_GTC_VIEW); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_GTC_PAUSE, _360_GTC_PAUSE); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_GTC_RESUME, _360_GTC_PLAY); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START | _360_GTC_MENU); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK | _360_GTC_VIEW); - - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B | _360_GTC_BACK); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_GTC_PAUSE, + _360_GTC_PAUSE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_GTC_RESUME, + _360_GTC_PLAY); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START | _360_GTC_MENU); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK | _360_GTC_VIEW); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); } #if 0 -HRESULT InitD3D( IDirect3DDevice9 **ppDevice, +HRESULT InitD3D( IDirect3DDevice9 **ppDevice, D3DPRESENT_PARAMETERS *pd3dPP ) { IDirect3D9 *pD3D; @@ -262,14 +419,14 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, //pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; //ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled // in the launcher/dashboard. - if(g_bWidescreen) + if(g_bWidescreen) pd3dPP->Flags=0; - else + else pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; // Create the device. return pD3D->CreateDevice( - 0, + 0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, @@ -277,38 +434,34 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, ppDevice ); } #endif -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif - -HINSTANCE g_hInst = NULL; +HINSTANCE g_hInst = NULL; Platform::Agile g_window; -Windows::Foundation::Rect g_windowBounds; +Windows::Foundation::Rect g_windowBounds; -D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; -D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; +D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; +D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; Microsoft::WRL::ComPtr g_d3dDevice; -Microsoft::WRL::ComPtr g_d3dContext; -Microsoft::WRL::ComPtr g_swapChain; -Microsoft::WRL::ComPtr g_renderTargetView; -Microsoft::WRL::ComPtr g_depthStencilView; -Microsoft::WRL::ComPtr g_depthStencil; +Microsoft::WRL::ComPtr g_d3dContext; +Microsoft::WRL::ComPtr g_swapChain; +Microsoft::WRL::ComPtr g_renderTargetView; +Microsoft::WRL::ComPtr g_depthStencilView; +Microsoft::WRL::ComPtr g_depthStencil; void CreateDevice(); void CreateResources(); -void InitializeDurango(Windows::UI::Core::CoreWindow^ window) -{ - SetThreadAffinityMask(GetCurrentThread(),1); +void InitializeDurango(Windows::UI::Core::CoreWindow ^ window) { + SetThreadAffinityMask(GetCurrentThread(), 1); g_window = window; @@ -318,58 +471,51 @@ void InitializeDurango(Windows::UI::Core::CoreWindow^ window) // TODO: Begin asynchronous loading of game assets. - C4JThread::StaticInit(); + C4JThread::StaticInit(); } -namespace DX -{ - inline void ThrowIfFailed(HRESULT hr) - { - if (FAILED(hr)) - { - // Set a breakpoint on this line to catch DirectX API errors - throw Platform::Exception::CreateException(hr); - } +namespace DX { +inline void ThrowIfFailed(HRESULT hr) { + if (FAILED(hr)) { + // Set a breakpoint on this line to catch DirectX API errors + throw Platform::Exception::CreateException(hr); } } +} // namespace DX -void CreateDevice() -{ - // This flag adds support for surfaces with a different color channel ordering than the API default. - // It is recommended usage, and is required for compatibility with Direct2D. +void CreateDevice() { + // This flag adds support for surfaces with a different color channel + // ordering than the API default. It is recommended usage, and is required + // for compatibility with Direct2D. UINT creationFlags = D3D11_CREATE_DEVICE_FAST_KICKOFFS; #ifndef _CONTENT_PACKAGE - creationFlags |= D3D11_CREATE_DEVICE_VALIDATED; - creationFlags |= D3D11_CREATE_DEVICE_INSTRUMENTED; + creationFlags |= D3D11_CREATE_DEVICE_VALIDATED; + creationFlags |= D3D11_CREATE_DEVICE_INSTRUMENTED; #endif - // This array defines the set of DirectX hardware feature levels this app will support. - // Note the ordering should be preserved. - // Don't forget to declare your application's minimum required feature level in its - // description. All applications are assumed to support 9.1 unless otherwise stated. - D3D_FEATURE_LEVEL featureLevels[] = - { - D3D_FEATURE_LEVEL_11_0 - }; + // This array defines the set of DirectX hardware feature levels this app + // will support. Note the ordering should be preserved. Don't forget to + // declare your application's minimum required feature level in its + // description. All applications are assumed to support 9.1 unless + // otherwise stated. + D3D_FEATURE_LEVEL featureLevels[] = {D3D_FEATURE_LEVEL_11_0}; // Create the DX11 API device object, and get a corresponding context. Microsoft::WRL::ComPtr device; Microsoft::WRL::ComPtr context; - DX::ThrowIfFailed( - D3D11CreateDevice( - nullptr, // specify null to use the default adapter - D3D_DRIVER_TYPE_HARDWARE, - nullptr, // leave as nullptr unless software device - creationFlags, // optionally set debug and Direct2D compatibility flags - featureLevels, // list of feature levels this app can support - ARRAYSIZE(featureLevels), // number of entries in above list - D3D11_SDK_VERSION, // always set this to D3D11_SDK_VERSION - &device, // returns the Direct3D device created - &g_featureLevel, // returns feature level of device created - &context // returns the device immediate context - ) - ); + DX::ThrowIfFailed(D3D11CreateDevice( + nullptr, // specify null to use the default adapter + D3D_DRIVER_TYPE_HARDWARE, + nullptr, // leave as nullptr unless software device + creationFlags, // optionally set debug and Direct2D compatibility flags + featureLevels, // list of feature levels this app can support + ARRAYSIZE(featureLevels), // number of entries in above list + D3D11_SDK_VERSION, // always set this to D3D11_SDK_VERSION + &device, // returns the Direct3D device created + &g_featureLevel, // returns feature level of device created + &context // returns the device immediate context + )); // Get the DirectX11.1 device by QI off the DirectX11 one. DX::ThrowIfFailed(device.As(&g_d3dDevice)); @@ -379,31 +525,30 @@ void CreateDevice() } // Allocate all memory resources that change on a window SizeChanged event. -void CreateResources() -{ - // Store the window bounds so the next time we get a SizeChanged event we can - // avoid rebuilding everything if the size is identical. +void CreateResources() { + // Store the window bounds so the next time we get a SizeChanged event we + // can avoid rebuilding everything if the size is identical. g_windowBounds = g_window.Get()->Bounds; // If the swap chain already exists, resize it, // otherwise create one. - if(g_swapChain != nullptr) - { - DX::ThrowIfFailed(g_swapChain->ResizeBuffers(2, 0, 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0)); - } - else - { - // First, retrieve the underlying DXGI Device from the D3D Device - Microsoft::WRL::ComPtr dxgiDevice; + if (g_swapChain != nullptr) { + DX::ThrowIfFailed( + g_swapChain->ResizeBuffers(2, 0, 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0)); + } else { + // First, retrieve the underlying DXGI Device from the D3D Device + Microsoft::WRL::ComPtr dxgiDevice; DX::ThrowIfFailed(g_d3dDevice.As(&dxgiDevice)); - // Identify the physical adapter (GPU or card) this device is running on. + // Identify the physical adapter (GPU or card) this device is running + // on. Microsoft::WRL::ComPtr dxgiAdapter; DX::ThrowIfFailed(dxgiDevice->GetAdapter(&dxgiAdapter)); // And obtain the factory object that created it. Microsoft::WRL::ComPtr dxgiFactory; - DX::ThrowIfFailed(dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory)); + DX::ThrowIfFailed( + dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory)); // Create a descriptor for the swap chain. DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {0}; @@ -411,7 +556,8 @@ void CreateResources() swapChainDesc.Width = 1920; swapChainDesc.Height = 1080; swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; + swapChainDesc.BufferUsage = + DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_SHADER_INPUT; swapChainDesc.BufferCount = 2; swapChainDesc.Stereo = false; swapChainDesc.SampleDesc.Count = 1; @@ -421,15 +567,20 @@ void CreateResources() swapChainDesc.Flags = 0; // Create a SwapChain from a CoreWindow. - DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow(g_d3dDevice.Get(), reinterpret_cast(g_window.Get()), &swapChainDesc, nullptr, &g_swapChain)); + DX::ThrowIfFailed(dxgiFactory->CreateSwapChainForCoreWindow( + g_d3dDevice.Get(), reinterpret_cast(g_window.Get()), + &swapChainDesc, nullptr, &g_swapChain)); } - // Obtain the backbuffer for this window which will be the final 3D rendertarget. + // Obtain the backbuffer for this window which will be the final 3D + // rendertarget. Microsoft::WRL::ComPtr backBuffer; - DX::ThrowIfFailed(g_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &backBuffer)); + DX::ThrowIfFailed( + g_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &backBuffer)); // Create a view interface on the rendertarget to use on bind. - DX::ThrowIfFailed(g_d3dDevice->CreateRenderTargetView(backBuffer.Get(), nullptr, &g_renderTargetView)); + DX::ThrowIfFailed(g_d3dDevice->CreateRenderTargetView( + backBuffer.Get(), nullptr, &g_renderTargetView)); // Cache the rendertarget dimensions in our helper class for convenient use. D3D11_TEXTURE2D_DESC backBufferDesc = {0}; @@ -437,37 +588,42 @@ void CreateResources() // Allocate a 2-D surface as the depth/stencil buffer and // create a DepthStencil view on this surface to use on bind. - CD3D11_TEXTURE2D_DESC depthStencilDesc(DXGI_FORMAT_D24_UNORM_S8_UINT, backBufferDesc.Width, backBufferDesc.Height, 1, 1, D3D11_BIND_DEPTH_STENCIL); + CD3D11_TEXTURE2D_DESC depthStencilDesc( + DXGI_FORMAT_D24_UNORM_S8_UINT, backBufferDesc.Width, + backBufferDesc.Height, 1, 1, D3D11_BIND_DEPTH_STENCIL); Microsoft::WRL::ComPtr depthStencil; - DX::ThrowIfFailed(g_d3dDevice->CreateTexture2D(&depthStencilDesc, nullptr, &depthStencil)); + DX::ThrowIfFailed(g_d3dDevice->CreateTexture2D(&depthStencilDesc, nullptr, + &depthStencil)); - CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(D3D11_DSV_DIMENSION_TEXTURE2D); - DX::ThrowIfFailed(g_d3dDevice->CreateDepthStencilView(depthStencil.Get(), &depthStencilViewDesc, &g_depthStencilView)); + CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc( + D3D11_DSV_DIMENSION_TEXTURE2D); + DX::ThrowIfFailed(g_d3dDevice->CreateDepthStencilView( + depthStencil.Get(), &depthStencilViewDesc, &g_depthStencilView)); // Create a viewport descriptor of the full window size. - CD3D11_VIEWPORT viewPort(0.0f, 0.0f, static_cast(backBufferDesc.Width), static_cast(backBufferDesc.Height)); + CD3D11_VIEWPORT viewPort(0.0f, 0.0f, + static_cast(backBufferDesc.Width), + static_cast(backBufferDesc.Height)); // Set the current viewport using the descriptor. g_d3dContext->RSSetViewports(1, &viewPort); - g_d3dContext->OMSetRenderTargets( 1, g_renderTargetView.GetAddressOf(), g_depthStencilView.Get() ); + g_d3dContext->OMSetRenderTargets(1, g_renderTargetView.GetAddressOf(), + g_depthStencilView.Get()); } //-------------------------------------------------------------------------------------- // Render the frame //-------------------------------------------------------------------------------------- -void Render() -{ +void Render() { // Just clear the backbuffer - float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha + float ClearColor[4] = {0.0f, 0.125f, 0.3f, 1.0f}; // red,green,blue,alpha - g_d3dContext->ClearRenderTargetView( g_renderTargetView.Get(), ClearColor ); - g_swapChain->Present( 0, 0 ); + g_d3dContext->ClearRenderTargetView(g_renderTargetView.Get(), ClearColor); + g_swapChain->Present(0, 0); } - -void oldWinMainInit() -{ +void oldWinMainInit() { #if 0 // Main message loop MSG msg = {0}; @@ -487,12 +643,12 @@ void oldWinMainInit() return (int) msg.wParam; #endif - #ifdef MEMORY_TRACKING - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); #endif #if 0 @@ -507,31 +663,31 @@ void oldWinMainInit() } // Initialize the application, assuming sharing of the d3d interface. - hr = app.InitShared( pDevice, &d3dpp, + hr = app.InitShared( pDevice, &d3dpp, XuiPNGTextureLoader ); if ( FAILED(hr) ) { app.DebugPrintf ( "Failed initializing application.\n" ); - + return -1; } - - + #endif - app.loadMediaArchive(); + app.loadMediaArchive(); - RenderManager.Initialise(g_d3dDevice.Get(), g_swapChain.Get()); + RenderManager.Initialise(g_d3dDevice.Get(), g_swapChain.Get()); - app.loadStringTable(); + app.loadStringTable(); - ui.init(g_d3dDevice,g_d3dContext,g_renderTargetView,g_depthStencilView,1920,1080); + ui.init(g_d3dDevice, g_d3dContext, g_renderTargetView, g_depthStencilView, + 1920, 1080); - //////////////// - // Initialise // - //////////////// + //////////////// + // Initialise // + //////////////// #if 0 // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params @@ -552,103 +708,123 @@ void oldWinMainInit() app.FatalLoadError(); } #endif - app.InitTime(); + app.InitTime(); - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions + InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); - // looks like the Durango controller is a good bit more sensitive than XBOX360/PS3. Defaults in the lib are 10000 for deadzone and 32767 for movement range - InputManager.SetDeadzoneAndMovementRange(10000,20000,32767); + // looks like the Durango controller is a good bit more sensitive than + // XBOX360/PS3. Defaults in the lib are 10000 for deadzone and 32767 for + // movement range + InputManager.SetDeadzoneAndMovementRange(10000, 20000, 32767); - // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings - ProfileManager.Initialise(SERVICE_CONFIG_ID, TITLE_PRODUCT_ID); + // Initialise the profile manager with the game Title ID, Offer ID, a + // profile version number, and the number of profile values and settings + ProfileManager.Initialise(SERVICE_CONFIG_ID, TITLE_PRODUCT_ID); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_IDLE,L"Idle"); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MENUS,L"InMenus"); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER,L"PlayingMultiplayer"); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,L"PlayingMultiplayerOffline"); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER_1P,L"PlayingAlone"); - ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,L"PlayingAloneOffline"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_IDLE, L"Idle"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MENUS, L"InMenus"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER, + L"PlayingMultiplayer"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, + L"PlayingMultiplayerOffline"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER_1P, + L"PlayingAlone"); + ProfileManager.RegisterPresence(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, + L"PlayingAloneOffline"); - // Fix for XboxOne #165025 - XR-049: Compliance: Title does not display Rich Presence strings for profiles in main menu. - ProfileManager.SetGameActivityForAllActiveUsers(CONTEXT_PRESENCE_IDLE); + // Fix for XboxOne #165025 - XR-049: Compliance: Title does not display Rich + // Presence strings for profiles in main menu. + ProfileManager.SetGameActivityForAllActiveUsers(CONTEXT_PRESENCE_IDLE); - Compression::CreateNewThreadStorage(); - app.ReadLocalDLCList(); + Compression::CreateNewThreadStorage(); + app.ReadLocalDLCList(); - // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app, app.UpdateProductId,SERVICE_CONFIG_ID,TITLE_PRODUCT_ID); + // initialise the storage manager with a default save display name, a + // Minimum save size, and a callback for displaying the saving message + StorageManager.Init( + 0, app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, + &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, + app.UpdateProductId, SERVICE_CONFIG_ID, TITLE_PRODUCT_ID); - StorageManager.SetMaxSaves(99); + StorageManager.SetMaxSaves(99); - byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); + byteArray baSaveThumbnail = + app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); - StorageManager.InitialiseProfileData(PROFILE_VERSION_BUILD_JUNE14, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + StorageManager.InitialiseProfileData( + PROFILE_VERSION_BUILD_JUNE14, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - StorageManager.SetDefaultImages((PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + StorageManager.SetDefaultImages((PBYTE)baSaveThumbnail.data, + baSaveThumbnail.length); - // Set function to be called if a save game operation can't complete due to running out of storage space etc. - StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + // Set function to be called if a save game operation can't complete due to + // running out of storage space etc. + StorageManager.SetIncompleteSaveCallback( + CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); - // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out - ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + // set a function to be called when there's a sign in change, so we can exit + // a level if the primary player signs out + ProfileManager.SetSignInChangeCallback( + &CConsoleMinecraftApp::SignInChangeCallback, (LPVOID)&app); - // Set a callback for the default player options to be set - when there is no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + // Set a callback for the default player options to be set - when there is + // no profile data for the player + StorageManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); + StorageManager.SetOptionsDataCallback( + &CConsoleMinecraftApp::OptionsDataCallback, (LPVOID)&app); + // Set a callback to deal with old profile versions needing updated to new + // versions + StorageManager.SetOldProfileVersionCallback( + &CConsoleMinecraftApp::OldProfileVersionCallback, (LPVOID)&app); - // Set a callback to deal with old profile versions needing updated to new versions - StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + g_NetworkManager.Initialise(); - g_NetworkManager.Initialise(); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); + // 4J-PB - after the init, which will have read all the local DLC, update + // the product ids by reading the local dlc file + StorageManager.UpdateDLCProductIDs(); - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); + app.InitGameSettings(); - //4J-PB - after the init, which will have read all the local DLC, update the product ids by reading the local dlc file - StorageManager.UpdateDLCProductIDs(); + // read the options here for controller 0 + // 4J-PB - we have no valid user to read a profile for on Xbox One, and + // there's no EULA anyway + // StorageManager.ReadFromProfile(0); - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); - app.InitGameSettings(); + app.InitialiseDLCDetails(); + StorageManager.SetLicenseChangeFn(&app.HandleDLCLicenseChange); - // read the options here for controller 0 - // 4J-PB - we have no valid user to read a profile for on Xbox One, and there's no EULA anyway - //StorageManager.ReadFromProfile(0); - - app.InitialiseDLCDetails(); - StorageManager.SetLicenseChangeFn(&app.HandleDLCLicenseChange); - - - // debug switch to trial version - ProfileManager.SetDebugFullOverride(true); - - // set default values for controllers -// for(int i=0;i<4;i++) -// { -// //app.SetDefaultOptions(app.GetGameDefinedProfileData(i),i); -// app.SetDefaultOptions(ProfileManager.GetGameDefinedProfileData(i),i); -// } + // debug switch to trial version + ProfileManager.SetDebugFullOverride(true); + // set default values for controllers + // for(int i=0;i<4;i++) + // { + // //app.SetDefaultOptions(app.GetGameDefinedProfileData(i),i); + // app.SetDefaultOptions(ProfileManager.GetGameDefinedProfileData(i),i); + // } #if 0 //bool bDisplayPauseMenu=false; @@ -679,16 +855,14 @@ void oldWinMainInit() // Update the base scene quick selects now that the minecraft class exists //CXuiSceneBase::UpdateScreenSettings(0); #endif - app.InitialiseTips(); + app.InitialiseTips(); #if 0 DWORD initData=0; - - #ifndef _FINAL_BUILD #ifndef _DEBUG - #pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission") #endif #endif @@ -699,11 +873,9 @@ void oldWinMainInit() app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); #endif + // app.TemporaryCreateGameStart(); - - //app.TemporaryCreateGameStart(); - - //Sleep(10000); + // Sleep(10000); #if 0 // Intro loop ? while(app.IntroRunning()) @@ -727,12 +899,11 @@ void oldWinMainInit() } #endif } -void oldWinMainTick() -{ - static bool bTrialTimerDisplayed=true; +void oldWinMainTick() { + static bool bTrialTimerDisplayed = true; - Minecraft *pMinecraft=Minecraft::GetInstance(); - RenderManager.StartFrame(); + Minecraft* pMinecraft = Minecraft::GetInstance(); + RenderManager.StartFrame(); #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -742,85 +913,84 @@ void oldWinMainTick() pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); } #endif - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); -// CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); - - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); -// SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - GameProgress::Tick(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); - PIXBeginNamedEvent(PIX_COLOR_INDEX(2),"Network manager do work #1"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + GameProgress::Tick(); - LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } + PIXBeginNamedEvent(PIX_COLOR_INDEX(2), "Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); - pMinecraft->soundEngine->playMusicTick(); + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft->tickAllConnections(); // Added to stop timing out when + // we are waiting after + // converting to an offline game + } + } + pMinecraft->soundEngine->playMusicTick(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -830,8 +1000,8 @@ void oldWinMainTick() bDumpTextureUsage = false; } #endif - ui.tick(); - ui.render(); + ui.tick(); + ui.render(); #if 0 app.HandleButtonPresses(); @@ -854,7 +1024,7 @@ void oldWinMainTick() for(int i=0;i<8;i++) { - if(RenderStateA2[i]!=RenderStateA[i]) + if(RenderStateA2[i]!=RenderStateA[i]) { //printf("Reseting RenderStateA[%d] after a XUI render\n",i); pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); @@ -862,7 +1032,7 @@ void oldWinMainTick() } for(int i=0;i<5;i++) { - if(SamplerStateA2[i]!=SamplerStateA[i]) + if(SamplerStateA2[i]!=SamplerStateA[i]) { //printf("Reseting SamplerStateA[%d] after a XUI render\n",i); pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); @@ -872,119 +1042,116 @@ void oldWinMainTick() RenderManager.Set_matrixDirty(); #endif -#if 0 // ndef _CONTENT_PACKAGE - if( InputManager.ButtonPressed(0,MINECRAFT_ACTION_DPAD_LEFT) || +#if 0 // ndef _CONTENT_PACKAGE + if( InputManager.ButtonPressed(0,MINECRAFT_ACTION_DPAD_LEFT) || InputManager.ButtonPressed(0,ACTION_MENU_STICK_PRESS)) { RenderManager.DoScreenGrabOnNextPresent(); } #endif - // Present the frame. - RenderManager.Present(); + // Present the frame. + RenderManager.Present(); - ui.CheckMenuDisplayed(); + ui.CheckMenuDisplayed(); - PIXBeginNamedEvent(0,"Profile load check"); - // has the game defined profile data been changed (by a profile load) - if(app.uiGameDefinedDataChangedBitmask!=0) - { - void *pData; - for(int i=0;istats[ i ]->clear(); - pMinecraft->stats[i]->parse(pData); - } - } + // clear the stats first - there could have beena signout and + // sign back in in the menus need to clear the player stats - + // can't assume it'll be done in setlevel - we may not be in the + // game + pMinecraft->stats[i]->clear(); + pMinecraft->stats[i]->parse(pData); + } + } #if 0 // Check to see if we can post to social networks. CSocialManager::Instance()->RefreshPostingCapability(); #endif - // clear the flag - app.uiGameDefinedDataChangedBitmask=0; + // clear the flag + app.uiGameDefinedDataChangedBitmask = 0; - // Check if any profile write are needed - app.CheckGameSettingsChanged(); + // Check if any profile write are needed + app.CheckGameSettingsChanged(); + } + PIXEndNamedEvent(); + app.TickTMSPPFilesRetrieved(); - } - PIXEndNamedEvent(); - app.TickTMSPPFilesRetrieved(); + app.TickDLCOffersRetrieved(); - app.TickDLCOffersRetrieved(); - - PIXBeginNamedEvent(0,"Network manager do work #2"); - // 4J Stu - Added this back as it was causing horrendous lag (and eventually a crash on a client) when playing with multiple clients - g_NetworkManager.DoWork(); // TODO - consider putting this back in. Removed because we are having trouble with how long the tick is taking on Durango - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Network manager do work #2"); + // 4J Stu - Added this back as it was causing horrendous lag (and eventually + // a crash on a client) when playing with multiple clients + g_NetworkManager.DoWork(); // TODO - consider putting this back in. Removed + // because we are having trouble with how long + // the tick is taking on Durango + PIXEndNamedEvent(); #if 0 PIXBeginNamedEvent(0,"Misc extra xui"); // Update XUI Timers hr = XuiTimersRun(); #endif - // Any threading type things to deal with from the xui side? - app.HandleXuiActions(); + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); #if 0 PIXEndNamedEvent(); #endif - // 4J-PB - Update the trial timer display if we are in the trial version - if(!ProfileManager.IsFullVersion()) - { - // display the trial timer - if(app.GetGameStarted()) - { - // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down - if(app.IsAppPaused()) - { - app.UpdateTrialPausedTimer(); - } - ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); - } - } - else - { - // need to turn off the trial timer if it was on , and we've unlocked the full version - if(bTrialTimerDisplayed) - { - ui.ShowTrialTimer(false); - bTrialTimerDisplayed=false; - } - } + // 4J-PB - Update the trial timer display if we are in the trial version + if (!ProfileManager.IsFullVersion()) { + // display the trial timer + if (app.GetGameStarted()) { + // 4J-PB - if the game is paused, add the elapsed time to the trial + // timer count so it doesn't tick down + if (app.IsAppPaused()) { + app.UpdateTrialPausedTimer(); + } + ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } else { + // need to turn off the trial timer if it was on , and we've unlocked + // the full version + if (bTrialTimerDisplayed) { + ui.ShowTrialTimer(false); + bTrialTimerDisplayed = false; + } + } - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); + // Fix for #7318 - Title crashes after short soak in the leaderboards menu + // A memory leak was caused because the icon renderer kept creating new + // Vec3's because the pool wasn't reset + Vec3::resetPool(); } #ifdef MEMORY_TRACKING int totalAllocGen = 0; -std::unordered_map allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -993,181 +1160,159 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } - - LeaveCriticalSection(&memCS); + trackEnable = true; + } + } - return p; + LeaveCriticalSection(&memCS); + + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes -) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } - -void DumpMem() -{ - int totalLeak = 0; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 46; +void MemPixStuff() { + const int MAX_SECT = 46; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } #endif diff --git a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp index 41a2188e6..852dbb58c 100644 --- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp @@ -65,7 +65,6 @@ static void sigsegv_handler(int sig) { #include "../../Rendering/Tesselator.h" #include "../../GameState/Options.h" #include "../Linux/Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" #include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h" @@ -870,7 +869,6 @@ return -1; // Initialise TLS for AABB and Vec3 pools, for this main thread AABB::CreateNewThreadStorage(); Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); Compression::CreateNewThreadStorage(); OldChunkStorage::CreateNewThreadStorage(); Level::enableLightingCache(); @@ -940,7 +938,6 @@ return -1; pMinecraft->soundEngine->tick(NULL, 0.0f); MemSect(0); pMinecraft->textures->tick(true, false); - IntCache::Reset(); if (app.GetReallyChangingSessionType()) { pMinecraft ->tickAllConnections(); // Added to stop timing out when we diff --git a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp index 07ca0bdc3..7dfd2c385 100644 --- a/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp +++ b/Minecraft.Client/Platform/Orbis/Orbis_Minecraft.cpp @@ -26,14 +26,13 @@ #include "../../../Minecraft.World/Util/ThreadName.h" #include "../../GameState/StatsCounter.h" #include "../../UI/Screens/ConnectScreen.h" -//#include "Social/SocialManager.h" -//#include "../Common/Leaderboards/LeaderboardManager.h" -//#include "../Common/XUI/XUI_Scene_Container.h" -//#include "NetworkManager.h" +// #include "Social/SocialManager.h" +// #include "../Common/Leaderboards/LeaderboardManager.h" +// #include "../Common/XUI/XUI_Scene_Container.h" +// #include "NetworkManager.h" #include "../../Rendering/Tesselator.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" #include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h" @@ -42,291 +41,499 @@ #include "Network/Orbis_NPToolkit.h" #include "Network/SonyVoiceChat_Orbis.h" -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 -//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) -//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) -//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) +// #define THREE_MB 3145728 // minimum save size (checking for this on a +// selected device) #define FIVE_MB 5242880 // minimum save size (checking for +// this on a selected device) #define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR +// space required for a save (checking for this on a selected device) +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) -//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +// #define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 -DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= -{ +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES] = { #ifdef _XBOX - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, #else - 0,0,0,0,0 + 0, 0, 0, 0, 0 #endif }; //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- // functions for storing and converting rich presence strings from wchar to utf8 -uint8_t * AddRichPresenceString(int iID); +uint8_t* AddRichPresenceString(int iID); void FreeRichPresenceStrings(); BOOL g_bWidescreen = TRUE; +void DefineActions(void) { + // The app needs to define the actions required, and the possible mappings + // for these -void DefineActions(void) -{ - // The app needs to define the actions required, and the possible mappings for these + // Split into Menu actions, and in-game actions - // Split into Menu actions, and in-game actions - - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L2); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_X); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_X, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_Y, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_UP, + _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEUP, + _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEDOWN, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_LEFT_SCROLL, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_STICK_PRESS, + _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_PRESS, + _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_L2); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_JUMP, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_FORWARD, + _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_BACKWARD, + _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT, + _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT, + _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_USE, + _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_ACTION, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT_SCROLL, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_INVENTORY, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DROP, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_SNEAK_TOGGLE, + _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_CRAFTING, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_GAME_INFO, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_UP, + _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN); - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); - } + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_X); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_O); + } - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_X, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_Y, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_UP, + _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEUP, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEDOWN, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_LEFT_SCROLL, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAUSEMENU, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_STICK_PRESS, + _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_PRESS, + _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_L2); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_JUMP, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_FORWARD, + _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_BACKWARD, + _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT, + _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT, + _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_USE, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_ACTION, + _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT_SCROLL, + _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT_SCROLL, + _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_INVENTORY, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DROP, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_SNEAK_TOGGLE, + _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_CRAFTING, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_GAME_INFO, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_UP, + _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN); - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_X); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_X, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_Y, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_UP, + _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_PAGEUP, + _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAGEDOWN, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_LEFT_SCROLL, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_STICK_PRESS, + _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_PRESS, + _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_L2); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _PS4_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_JUMP, + _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_FORWARD, + _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_BACKWARD, + _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT, + _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT, + _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_USE, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_ACTION, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT_SCROLL, + _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT_SCROLL, + _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_INVENTORY, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DROP, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_SNEAK_TOGGLE, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_CRAFTING, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_GAME_INFO, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_UP, + _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN); - // Vita remote play map - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_A, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OK, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_B, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_X); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_A, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OK, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_B, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_CANCEL, _PS4_JOY_BUTTON_O); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_X, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_Y, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_UP, _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_DOWN, _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_LEFT, _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_RIGHT, _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); + // Vita remote play map + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_A, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OK, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_B, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_X); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_A, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OK, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_B, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_CANCEL, + _PS4_JOY_BUTTON_O); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_X, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_Y, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, ACTION_MENU_UP, + _PS4_JOY_BUTTON_DPAD_UP | _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, ACTION_MENU_DOWN, + _PS4_JOY_BUTTON_DPAD_DOWN | _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, ACTION_MENU_LEFT, + _PS4_JOY_BUTTON_DPAD_LEFT | _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, ACTION_MENU_RIGHT, + _PS4_JOY_BUTTON_DPAD_RIGHT | _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OTHER_STICK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OTHER_STICK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OTHER_STICK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OTHER_STICK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAGEUP, _PS4_JOY_BUTTON_L2); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_PAGEDOWN, _PS4_JOY_BUTTON_R2); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_RIGHT_SCROLL, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_LEFT_SCROLL, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_STICK_PRESS, _PS4_JOY_BUTTON_L3); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_OTHER_STICK_PRESS, _PS4_JOY_BUTTON_R3); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_PAGEUP, + _PS4_JOY_BUTTON_L2); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_PAGEDOWN, + _PS4_JOY_BUTTON_R2); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_LEFT_SCROLL, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_STICK_PRESS, + _PS4_JOY_BUTTON_L3); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_OTHER_STICK_PRESS, + _PS4_JOY_BUTTON_R3); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_JUMP, _PS4_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_FORWARD, _PS4_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_BACKWARD, _PS4_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LEFT, _PS4_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RIGHT, _PS4_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_LEFT, _PS4_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_RIGHT, _PS4_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_UP, _PS4_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LOOK_DOWN, _PS4_JOY_BUTTON_RSTICK_DOWN); - - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_INVENTORY, _PS4_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_PAUSEMENU, _PS4_JOY_BUTTON_OPTIONS); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_DROP, _PS4_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_CRAFTING, _PS4_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_JUMP, + _PS4_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_FORWARD, + _PS4_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_BACKWARD, + _PS4_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_LEFT, + _PS4_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_RIGHT, + _PS4_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_LOOK_LEFT, + _PS4_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_LOOK_RIGHT, + _PS4_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_LOOK_UP, + _PS4_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_LOOK_DOWN, + _PS4_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_USE, _PS4_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_ACTION, _PS4_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RIGHT_SCROLL, _PS4_JOY_BUTTON_R2 | _PS4_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_LEFT_SCROLL, _PS4_JOY_BUTTON_L2 | _PS4_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PS4_JOY_BUTTON_L3 | _PS4_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,MINECRAFT_ACTION_SNEAK_TOGGLE, _PS4_JOY_BUTTON_R3 | _PS4_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_INVENTORY, + _PS4_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_PAUSEMENU, + _PS4_JOY_BUTTON_OPTIONS); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_DROP, + _PS4_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_CRAFTING, + _PS4_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_GAME_INFO, + _PS4_JOY_BUTTON_TOUCHPAD); - // Touchpad mapping - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(MAP_STYLE_3,ACTION_MENU_TOUCHPAD_PRESS, _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_USE, + _PS4_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, MINECRAFT_ACTION_ACTION, + _PS4_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, MINECRAFT_ACTION_RIGHT_SCROLL, + _PS4_JOY_BUTTON_R2 | _PS4_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, MINECRAFT_ACTION_LEFT_SCROLL, + _PS4_JOY_BUTTON_L2 | _PS4_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _PS4_JOY_BUTTON_L3 | _PS4_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_3, MINECRAFT_ACTION_SNEAK_TOGGLE, + _PS4_JOY_BUTTON_R3 | _PS4_JOY_BUTTON_DPAD_DOWN); - // Partial mapping for Vita TV (applied over other mappings) + // Touchpad mapping + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_TOUCHPAD_PRESS, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_TOUCHPAD_PRESS, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_TOUCHPAD_PRESS, + _PS4_JOY_BUTTON_TOUCHPAD); + InputManager.SetGameJoypadMaps(MAP_STYLE_3, ACTION_MENU_TOUCHPAD_PRESS, + _PS4_JOY_BUTTON_TOUCHPAD); - InputManager.SetGameJoypadMaps(PARTIAL_MAP_1, MINECRAFT_ACTION_GAME_INFO, _PS4_JOY_BUTTON_DPAD_UP); + // Partial mapping for Vita TV (applied over other mappings) + + InputManager.SetGameJoypadMaps(PARTIAL_MAP_1, MINECRAFT_ACTION_GAME_INFO, + _PS4_JOY_BUTTON_DPAD_UP); } #if 0 -HRESULT InitD3D( IDirect3DDevice9 **ppDevice, +HRESULT InitD3D( IDirect3DDevice9 **ppDevice, D3DPRESENT_PARAMETERS *pd3dPP ) { IDirect3D9 *pD3D; @@ -353,14 +560,14 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, //pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; //ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled // in the launcher/dashboard. - if(g_bWidescreen) + if(g_bWidescreen) pd3dPP->Flags=0; - else + else pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; // Create the device. return pD3D->CreateDevice( - 0, + 0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, @@ -368,29 +575,27 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, ppDevice ); } #endif -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif #ifndef __ORBIS__ -HINSTANCE g_hInst = NULL; -HWND g_hWnd = NULL; -D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; -D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; +D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; +D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; +ID3D11Device* g_pd3dDevice = NULL; +ID3D11DeviceContext* g_pImmediateContext = NULL; +IDXGISwapChain* g_pSwapChain = NULL; ID3D11RenderTargetView* g_pRenderTargetView = NULL; ID3D11DepthStencilView* g_pDepthStencilView = NULL; -ID3D11Texture2D* g_pDepthStencilBuffer = NULL; +ID3D11Texture2D* g_pDepthStencilBuffer = NULL; // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) @@ -402,66 +607,62 @@ ID3D11Texture2D* g_pDepthStencilBuffer = NULL; // WM_DESTROY - post a quit message and return // // -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; - switch (message) - { - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - // Parse the menu selections: - switch (wmId) - { - case IDM_EXIT: - DestroyWindow(hWnd); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - // TODO: Add any drawing code here... - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; + switch (message) { + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + // Parse the menu selections: + switch (wmId) { + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + // TODO: Add any drawing code here... + EndPaint(hWnd, &ps); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; } - // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // -ATOM MyRegisterClass(HINSTANCE hInstance) -{ - WNDCLASSEX wcex; +ATOM MyRegisterClass(HINSTANCE hInstance) { + WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); + wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, "Minecraft"); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = "Minecraft"; - wcex.lpszClassName = "MinecraftClass"; - wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, "Minecraft"); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = "Minecraft"; + wcex.lpszClassName = "MinecraftClass"; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); - return RegisterClassEx(&wcex); + return RegisterClassEx(&wcex); } // @@ -474,34 +675,31 @@ ATOM MyRegisterClass(HINSTANCE hInstance) // In this function, we save the instance handle in a global variable and // create and display the main program window. // -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - g_hInst = hInstance; // Store instance handle in our global variable +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { + g_hInst = hInstance; // Store instance handle in our global variable - g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, + hInstance, NULL); - if (!g_hWnd) - { - return FALSE; - } + if (!g_hWnd) { + return FALSE; + } - ShowWindow(g_hWnd, nCmdShow); - UpdateWindow(g_hWnd); + ShowWindow(g_hWnd, nCmdShow); + UpdateWindow(g_hWnd); - return TRUE; + return TRUE; } - //-------------------------------------------------------------------------------------- // Create Direct3D device and swap chain //-------------------------------------------------------------------------------------- -HRESULT InitDevice() -{ +HRESULT InitDevice() { HRESULT hr = S_OK; RECT rc; - GetClientRect( g_hWnd, &rc ); + GetClientRect(g_hWnd, &rc); UINT width = rc.right - rc.left; UINT height = rc.bottom - rc.top; @@ -510,24 +708,22 @@ HRESULT InitDevice() createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif - D3D_DRIVER_TYPE driverTypes[] = - { + D3D_DRIVER_TYPE driverTypes[] = { D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP, D3D_DRIVER_TYPE_REFERENCE, }; - UINT numDriverTypes = ARRAYSIZE( driverTypes ); + UINT numDriverTypes = ARRAYSIZE(driverTypes); - D3D_FEATURE_LEVEL featureLevels[] = - { + D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, }; - UINT numFeatureLevels = ARRAYSIZE( featureLevels ); + UINT numFeatureLevels = ARRAYSIZE(featureLevels); DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory( &sd, sizeof( sd ) ); + ZeroMemory(&sd, sizeof(sd)); sd.BufferCount = 1; sd.BufferDesc.Width = width; sd.BufferDesc.Height = height; @@ -540,26 +736,26 @@ HRESULT InitDevice() sd.SampleDesc.Quality = 0; sd.Windowed = TRUE; - for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) - { + for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; + driverTypeIndex++) { g_driverType = driverTypes[driverTypeIndex]; - hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, - D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); - if( HRESULT_SUCCEEDED( hr ) ) - break; + hr = D3D11CreateDeviceAndSwapChain( + NULL, g_driverType, NULL, createDeviceFlags, featureLevels, + numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, + &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); + if (HRESULT_SUCCEEDED(hr)) break; } - if( FAILED( hr ) ) - return hr; + if (FAILED(hr)) return hr; // Create a render target view ID3D11Texture2D* pBackBuffer = NULL; - hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); - if( FAILED( hr ) ) - return hr; + hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), + (LPVOID*)&pBackBuffer); + if (FAILED(hr)) return hr; - // Create a depth stencil buffer + // Create a depth stencil buffer D3D11_TEXTURE2D_DESC descDepth; - + descDepth.Width = width; descDepth.Height = height; descDepth.MipLevels = 1; @@ -571,21 +767,24 @@ HRESULT InitDevice() descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; descDepth.CPUAccessFlags = 0; descDepth.MiscFlags = 0; - hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + hr = + g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; descDSView.Texture2D.MipSlice = 0; - hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); + hr = g_pd3dDevice->CreateDepthStencilView( + g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); + hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, + &g_pRenderTargetView); pBackBuffer->Release(); - if( FAILED( hr ) ) - return hr; + if (FAILED(hr)) return hr; - g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView ); + g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, + g_pDepthStencilView); // Setup the viewport D3D11_VIEWPORT vp; @@ -595,98 +794,142 @@ HRESULT InitDevice() vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; - g_pImmediateContext->RSSetViewports( 1, &vp ); + g_pImmediateContext->RSSetViewports(1, &vp); - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); return S_OK; } - //-------------------------------------------------------------------------------------- // Render the frame //-------------------------------------------------------------------------------------- -void Render() -{ +void Render() { // Just clear the backbuffer - float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha + float ClearColor[4] = {0.0f, 0.125f, 0.3f, 1.0f}; // red,green,blue,alpha - g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor ); - g_pSwapChain->Present( 0, 0 ); + g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor); + g_pSwapChain->Present(0, 0); } - //-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- -void CleanupDevice() -{ - if( g_pImmediateContext ) g_pImmediateContext->ClearState(); +void CleanupDevice() { + if (g_pImmediateContext) g_pImmediateContext->ClearState(); - if( g_pRenderTargetView ) g_pRenderTargetView->Release(); - if( g_pSwapChain ) g_pSwapChain->Release(); - if( g_pImmediateContext ) g_pImmediateContext->Release(); - if( g_pd3dDevice ) g_pd3dDevice->Release(); + if (g_pRenderTargetView) g_pRenderTargetView->Release(); + if (g_pSwapChain) g_pSwapChain->Release(); + if (g_pImmediateContext) g_pImmediateContext->Release(); + if (g_pd3dDevice) g_pd3dDevice->Release(); } #endif +void RegisterAwardsWithProfileManager() { + // register the awards + ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, + eAwardType_Achievement); -void RegisterAwardsWithProfileManager() -{ - // register the awards - ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); - - ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel' - ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!' - ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender' - ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire' - ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery' - ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?' - ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.' - ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter' + ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, + eAwardType_Achievement); // 'Sniper Duel' + ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, + eAwardType_Achievement); // 'DIAMONDS!' + ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, + eAwardType_Achievement); // 'Return To Sender' + ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, + eAwardType_Achievement); // 'Into Fire' + ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, + eAwardType_Achievement); // 'Local Brewery' + ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, + eAwardType_Achievement); // 'The End?' + ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, + eAwardType_Achievement); // 'The End.' + ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, + eAwardType_Achievement); // 'Enchanter' #ifdef _EXTENDED_ACHIEVEMENTS - ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, + eAwardType_Achievement); #endif #if 0 @@ -699,74 +942,116 @@ void RegisterAwardsWithProfileManager() ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); #endif - // Rich Presence init - number of presences, number of contexts - //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n"); - ProfileManager.RichPresenceInit(4,1); - ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Orbis::SetRichPresence); - char *pchRichPresenceString; + // Rich Presence init - number of presences, number of contexts + // printf("Rich presence strings are hard coded on PS3 for now, must change + // this!\n"); + ProfileManager.RichPresenceInit(4, 1); + ProfileManager.SetRichPresenceSettingFn( + SQRNetworkManager_Orbis::SetRichPresence); + char* pchRichPresenceString; - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); - ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); - - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); + ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, + pchRichPresenceString); + pchRichPresenceString = (char*)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); } -int StartMinecraftThreadProc( void* lpParameter ) -{ - Vec3::UseDefaultThreadStorage(); - AABB::UseDefaultThreadStorage(); - Tesselator::CreateNewThreadStorage(1024*1024); - RenderManager.InitialiseContext(); - Minecraft::start(std::wstring(),std::wstring()); - delete Tesselator::getInstance(); - return 0; +int StartMinecraftThreadProc(void* lpParameter) { + Vec3::UseDefaultThreadStorage(); + AABB::UseDefaultThreadStorage(); + Tesselator::CreateNewThreadStorage(1024 * 1024); + RenderManager.InitialiseContext(); + Minecraft::start(std::wstring(), std::wstring()); + delete Tesselator::getInstance(); + return 0; } -int main(int argc, const char *argv[] ) -{ - app.DebugPrintf("---main()\n"); - OrbisInit(); - +int main(int argc, const char* argv[]) { + app.DebugPrintf("---main()\n"); + OrbisInit(); #if 0 // Main message loop @@ -787,13 +1072,14 @@ int main(int argc, const char *argv[] ) return (int) msg.wParam; #endif - static bool bTrialTimerDisplayed=true; + static bool bTrialTimerDisplayed = true; #ifdef MEMORY_TRACKING - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); #endif #if 0 @@ -808,124 +1094,121 @@ int main(int argc, const char *argv[] ) } // Initialize the application, assuming sharing of the d3d interface. - hr = app.InitShared( pDevice, &d3dpp, + hr = app.InitShared( pDevice, &d3dpp, XuiPNGTextureLoader ); if ( FAILED(hr) ) { app.DebugPrintf ( "Failed initializing application.\n" ); - + return -1; } #endif + char* usrdirPath = getUsrDirPath(); + strcpy(usrdirPath, "/app0"); + RenderManager.Initialise(); + // Read the file containing the product codes + app.DebugPrintf("---ReadProductCodes()\n"); + if (app.ReadProductCodes() == FALSE) { + // can't continue + app.FatalLoadError(); + } - char *usrdirPath= getUsrDirPath(); + // StorageManager.SetDLCProductCode(app.GetProductCode()); + // StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); + // ProfileManager.SetServiceID(app.GetCommerceCategory()); - strcpy(usrdirPath,"/app0"); + SceNpContentRestriction param; + memset(¶m, 0x0, sizeof(param)); + param.size = sizeof(param); - RenderManager.Initialise(); + SceNpAgeRestriction ageRestriction[5]; + memset(ageRestriction, 0x0, sizeof(ageRestriction)); - // Read the file containing the product codes - app.DebugPrintf("---ReadProductCodes()\n"); - if(app.ReadProductCodes()==FALSE) - { - // can't continue - app.FatalLoadError(); - } + bool bCircleCrossSwapped = false; + switch (app.GetProductSKU()) { + case e_sku_SCEA: + // ESRB EVERYONE 10+ + param.defaultAgeRestriction = 10; + break; + case e_sku_SCEJ: + bCircleCrossSwapped = true; + // 4J Stu - Intentional fall-through + case e_sku_SCEE: + // PEGI 7+ + param.defaultAgeRestriction = 7; -// StorageManager.SetDLCProductCode(app.GetProductCode()); -// StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); - // ProfileManager.SetServiceID(app.GetCommerceCategory()); + // USK 6+ + strncpy(ageRestriction[0].countryCode.data, "de", 2); + ageRestriction[0].age = 6; - SceNpContentRestriction param; - memset(¶m, 0x0, sizeof(param)); - param.size = sizeof(param); + // PG rating has no age, but for some reason the testers are saying + // it's 8 + strncpy(ageRestriction[1].countryCode.data, "au", 2); + ageRestriction[1].age = 8; - SceNpAgeRestriction ageRestriction[5]; - memset(ageRestriction, 0x0, sizeof(ageRestriction)); + strncpy(ageRestriction[2].countryCode.data, "ru", 2); + ageRestriction[2].age = 6; - bool bCircleCrossSwapped = false; - switch(app.GetProductSKU()) - { - case e_sku_SCEA: - // ESRB EVERYONE 10+ - param.defaultAgeRestriction = 10; - break; - case e_sku_SCEJ: - bCircleCrossSwapped = true; - // 4J Stu - Intentional fall-through - case e_sku_SCEE: - // PEGI 7+ - param.defaultAgeRestriction = 7; + strncpy(ageRestriction[3].countryCode.data, "jp", 2); + ageRestriction[3].age = 0; + strncpy(ageRestriction[4].countryCode.data, "kr", 2); + ageRestriction[4].age = 0; + param.ageRestrictionCount = 5; + param.ageRestriction = ageRestriction; + break; + } - // USK 6+ - strncpy(ageRestriction[0].countryCode.data, "de" , 2); - ageRestriction[0].age = 6; + InputManager.SetCircleCrossSwapped(bCircleCrossSwapped); - // PG rating has no age, but for some reason the testers are saying it's 8 - strncpy(ageRestriction[1].countryCode.data, "au" , 2); - ageRestriction[1].age = 8; + int err = sceNpSetContentRestriction(¶m); + if (err < 0) { + /* Error handling */ + app.DebugPrintf("sceNpSetContentRestriction failed with error %08x\n", + err); + } - strncpy(ageRestriction[2].countryCode.data, "ru" , 2); - ageRestriction[2].age = 6; + err = sceGameLiveStreamingInitialize(SCE_GAME_LIVE_STREAMING_HEAP_SIZE); - strncpy(ageRestriction[3].countryCode.data, "jp" , 2); - ageRestriction[3].age = 0; + if (err < 0) { + app.DebugPrintf("Failed to init sceGameLiveStreamingInitialize. %08x\n", + err); + } - strncpy(ageRestriction[4].countryCode.data, "kr" , 2); - ageRestriction[4].age = 0; + err = sceGameLiveStreamingSetStandbyScreenResource("standy_screen"); - param.ageRestrictionCount = 5; - param.ageRestriction = ageRestriction; - break; - } + if (err < 0) { + app.DebugPrintf("Failed to set special standby screen resource. %08x\n", + err); + } - InputManager.SetCircleCrossSwapped(bCircleCrossSwapped); + app.loadMediaArchive(); + app.loadStringTable(); + ui.init(1920, 1080); - int err = sceNpSetContentRestriction(¶m); - if (err < 0){ - /* Error handling */ - app.DebugPrintf("sceNpSetContentRestriction failed with error %08x\n", err); - } + // storage manager is needed for the trial key check + StorageManager.Init( + 0, app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, + &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, ""); + StorageManager.SetSaveTitleExtraFileSuffix( + app.GetString(IDS_SAVE_SUBTITLE_SUFFIX)); + StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + // 4J-PB - Kick of the check for trial or full version - requires ui to be + // initialised + app.GetCommerce()->CheckForTrialUpgradeKey(); - err = sceGameLiveStreamingInitialize(SCE_GAME_LIVE_STREAMING_HEAP_SIZE); - - if(err < 0) - { - app.DebugPrintf("Failed to init sceGameLiveStreamingInitialize. %08x\n", err); - } - - err = sceGameLiveStreamingSetStandbyScreenResource("standy_screen"); - - if(err < 0) - { - app.DebugPrintf("Failed to set special standby screen resource. %08x\n", err); - } - - - app.loadMediaArchive(); - app.loadStringTable(); - ui.init(1920,1080); - - // storage manager is needed for the trial key check - StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,""); - StorageManager.SetSaveTitleExtraFileSuffix(app.GetString(IDS_SAVE_SUBTITLE_SUFFIX)); - StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL - // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised - app.GetCommerce()->CheckForTrialUpgradeKey(); - - //////////////// - // Initialise // - //////////////// + //////////////// + // Initialise // + //////////////// #if 0 // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params @@ -946,82 +1229,94 @@ int main(int argc, const char *argv[] ) app.FatalLoadError(); } - #endif - app.InitTime(); - NPToolkit.init(); + app.InitTime(); + NPToolkit.init(); - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - InputManager.Initialise(1,5,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions + InputManager.Initialise(1, 5, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); - // looks like the PS4 controller is a good bit more sensitive than PS3. Defaults in the lib are 10000 for deadzone and 32767 for movement range - InputManager.SetDeadzoneAndMovementRange(10000,20000,32767); + // looks like the PS4 controller is a good bit more sensitive than PS3. + // Defaults in the lib are 10000 for deadzone and 32767 for movement range + InputManager.SetDeadzoneAndMovementRange(10000, 20000, 32767); - // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings + // Initialise the profile manager with the game Title ID, Offer ID, a + // profile version number, and the number of profile values and settings - SceNpCommunicationId commsId; - SceNpCommunicationSignature commsSig; + SceNpCommunicationId commsId; + SceNpCommunicationSignature commsSig; - ProfileManager.Initialise( &commsId, //SQRNetworkManager::GetSceNpCommsId(), - &commsSig, //SQRNetworkManager::GetSceNpCommsSig(), - PROFILE_VERSION_BUILD_JUNE14, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + ProfileManager.Initialise( + &commsId, // SQRNetworkManager::GetSceNpCommsId(), + &commsSig, // SQRNetworkManager::GetSceNpCommsSig(), + PROFILE_VERSION_BUILD_JUNE14, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - // register the awards - RegisterAwardsWithProfileManager(); + // register the awards + RegisterAwardsWithProfileManager(); - // register the get string function with the profile lib, so it can be called within the lib + // register the get string function with the profile lib, so it can be + // called within the lib - ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); - ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); + ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); + ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); - - - - StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME)); - StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE)); - StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE)); - StorageManager.SetCorruptSaveName((WCHAR *)app.GetString(IDS_CORRUPTSAVE_TITLE)); + StorageManager.SetGameSaveFolderTitle((WCHAR*)app.GetString(IDS_GAMENAME)); + StorageManager.SetSaveCacheFolderTitle( + (WCHAR*)app.GetString(IDS_SAVECACHEFILE)); + StorageManager.SetOptionsFolderTitle( + (WCHAR*)app.GetString(IDS_OPTIONSFILE)); + StorageManager.SetCorruptSaveName( + (WCHAR*)app.GetString(IDS_CORRUPTSAVE_TITLE)); #if (defined _FINAL_BUILD) || (defined _ART_BUILD) - StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); + StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); #else - // Use debug directory to prevent debug saves being loaded/edited in package build (since debug can't edit package save games this causes various problems) - StorageManager.SetGameSaveFolderPrefix("DEBUG01899"); + // Use debug directory to prevent debug saves being loaded/edited in package + // build (since debug can't edit package save games this causes various + // problems) + StorageManager.SetGameSaveFolderPrefix("DEBUG01899"); #endif - StorageManager.SetMaxSaves(99); + StorageManager.SetMaxSaves(99); - byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage228x128.png"); - byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); - byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage228x128.png"); + byteArray baOptionsIcon = + app.getArchiveFile(L"DefaultOptionsImage228x128.png"); + byteArray baSaveThumbnail = + app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); + byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage228x128.png"); - StorageManager.InitialiseProfileData(PROFILE_VERSION_BUILD_JUNE14, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + StorageManager.InitialiseProfileData( + PROFILE_VERSION_BUILD_JUNE14, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + StorageManager.SetDefaultImages( + (PBYTE)baOptionsIcon.data, baOptionsIcon.length, + (PBYTE)baSaveImage.data, baSaveImage.length, + (PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - // Set function to be called if a save game operation can't complete due to running out of storage space etc. - StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + // Set function to be called if a save game operation can't complete due to + // running out of storage space etc. + StorageManager.SetIncompleteSaveCallback( + CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); - // Temporary - set a single user for quadrant 0 for the storage manager. Will need to do more to link this aspect of the storage manager is once we have proper profile management. + // Temporary - set a single user for quadrant 0 for the storage manager. + // Will need to do more to link this aspect of the storage manager is once + // we have proper profile management. - SceUserServiceUserId aUserIds[4]; - memset(aUserIds, 0, sizeof(aUserIds)); - int ret = sceUserServiceGetInitialUser(&aUserIds[0]); - assert(ret == SCE_OK); - StorageManager.SetQuadrantUserIds(aUserIds); + SceUserServiceUserId aUserIds[4]; + memset(aUserIds, 0, sizeof(aUserIds)); + int ret = sceUserServiceGetInitialUser(&aUserIds[0]); + assert(ret == SCE_OK); + StorageManager.SetQuadrantUserIds(aUserIds); #if 0 // Set up the global title storage path @@ -1030,31 +1325,37 @@ int main(int argc, const char *argv[] ) // set a function to be called when the ethernet is disconnected, so we can back out if required ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); - + #endif - // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out - ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + // set a function to be called when there's a sign in change, so we can exit + // a level if the primary player signs out + ProfileManager.SetSignInChangeCallback( + &CConsoleMinecraftApp::SignInChangeCallback, (LPVOID)&app); + // Set a callback for the default player options to be set - when there is + // no profile data for the player + StorageManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); + StorageManager.SetOptionsDataCallback( + &CConsoleMinecraftApp::OptionsDataCallback, (LPVOID)&app); - // Set a callback for the default player options to be set - when there is no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + // Set a callback to deal with old profile versions needing updated to new + // versions + StorageManager.SetOldProfileVersionCallback( + &CConsoleMinecraftApp::OldProfileVersionCallback, (LPVOID)&app); - // Set a callback to deal with old profile versions needing updated to new versions - StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + // Set a callback for when there is a read error on profile data + // StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); - // Set a callback for when there is a read error on profile data - //StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); + // QNet needs to be setup after profile manager, as we do not want its + // Notify listener to handle XN_SYS_SIGNINCHANGED notifications. This does + // mean that we need to have a callback in the ProfileManager for + // XN_LIVE_INVITE_ACCEPTED for QNet. + g_NetworkManager.Initialise(); - // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle - // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the - // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. - - g_NetworkManager.Initialise(); - - // debug switch to trial version - ProfileManager.SetDebugFullOverride(true); + // debug switch to trial version + ProfileManager.SetDebugFullOverride(true); #if 0 //ProfileManager.AddDLC(2); @@ -1064,50 +1365,49 @@ int main(int argc, const char *argv[] ) if(XNuiGetHardwareStatus()!=0) { - // If the Kinect Sensor is not physically connected, this function returns 0. - NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | + // If the Kinect Sensor is not physically connected, this function returns 0. + NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED | NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD ); } // Sentient ! - hr = TelemetryManager->Init(); - + hr = TelemetryManager->Init(); #endif - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - Compression::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + Compression::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); - Minecraft::main(); + Minecraft::main(); - // Minecraft::main () used to call Minecraft::Start, but this takes ~2.5 seconds, so now running this in another thread - // so we can do some basic renderer calls whilst it is happening. This is at attempt to stop getting TRC failure on SubmitDone taking > 5 seconds on boot - C4JThread *minecraftThread = new C4JThread(&StartMinecraftThreadProc, NULL, "Running minecraft start"); - minecraftThread->Run(); - do - { - RenderManager.StartFrame(); - Sleep(20); - RenderManager.Present(); - } while (minecraftThread->isRunning()); - delete minecraftThread; + // Minecraft::main () used to call Minecraft::Start, but this takes ~2.5 + // seconds, so now running this in another thread so we can do some basic + // renderer calls whilst it is happening. This is at attempt to stop getting + // TRC failure on SubmitDone taking > 5 seconds on boot + C4JThread* minecraftThread = new C4JThread(&StartMinecraftThreadProc, NULL, + "Running minecraft start"); + minecraftThread->Run(); + do { + RenderManager.StartFrame(); + Sleep(20); + RenderManager.Present(); + } while (minecraftThread->isRunning()); + delete minecraftThread; - Minecraft *pMinecraft=Minecraft::GetInstance(); + Minecraft* pMinecraft = Minecraft::GetInstance(); - app.InitGameSettings(); - // read the options here for controller 0 - StorageManager.ReadFromProfile(0); - - // 4J-PB - have to hide the auto splashscreen, or we never see our game - sceSystemServiceHideSplashScreen(); + app.InitGameSettings(); + // read the options here for controller 0 + StorageManager.ReadFromProfile(0); + // 4J-PB - have to hide the auto splashscreen, or we never see our game + sceSystemServiceHideSplashScreen(); #if 0 //bool bDisplayPauseMenu=false; @@ -1119,11 +1419,10 @@ int main(int argc, const char *argv[] ) // load any skins //app.AddSkinsToMemoryTextureFiles(); #endif - // set the default profile values - for(int i=0;isoundEngine->init(NULL); + pMinecraft->soundEngine->init(NULL); - while (TRUE) - { - SonyVoiceChat_Orbis::tick(); - RenderManager.StartFrame(); + while (TRUE) { + SonyVoiceChat_Orbis::tick(); + RenderManager.StartFrame(); #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -1209,88 +1505,88 @@ int main(int argc, const char *argv[] ) pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); } #endif - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); -// CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); - - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); -// SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #1"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); - LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } - pMinecraft->soundEngine->playMusicTick(); + PIXBeginNamedEvent(0, "Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); - static bool bInitnet=false; + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft + ->tickAllConnections(); // Added to stop timing out when we + // are waiting after converting to + // an offline game + } + } + pMinecraft->soundEngine->playMusicTick(); - if(bInitnet) - { - g_NetworkManager.Initialise(); - } + static bool bInitnet = false; + + if (bInitnet) { + g_NetworkManager.Initialise(); + } #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -1300,8 +1596,8 @@ int main(int argc, const char *argv[] ) bDumpTextureUsage = false; } #endif - ui.tick(); - ui.render(); + ui.tick(); + ui.render(); #if 0 app.HandleButtonPresses(); @@ -1324,7 +1620,7 @@ int main(int argc, const char *argv[] ) for(int i=0;i<8;i++) { - if(RenderStateA2[i]!=RenderStateA[i]) + if(RenderStateA2[i]!=RenderStateA[i]) { //printf("Reseting RenderStateA[%d] after a XUI render\n",i); pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); @@ -1332,7 +1628,7 @@ int main(int argc, const char *argv[] ) } for(int i=0;i<5;i++) { - if(SamplerStateA2[i]!=SamplerStateA[i]) + if(SamplerStateA2[i]!=SamplerStateA[i]) { //printf("Reseting SamplerStateA[%d] after a XUI render\n",i); pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); @@ -1341,70 +1637,65 @@ int main(int argc, const char *argv[] ) RenderManager.Set_matrixDirty(); #endif - // Present the frame. - RenderManager.Present(); + // Present the frame. + RenderManager.Present(); - ui.CheckMenuDisplayed(); - PIXBeginNamedEvent(0,"Profile load check"); - // has the game defined profile data been changed (by a profile load) - if(app.uiGameDefinedDataChangedBitmask!=0) - { - void *pData; - for(int i=0;istats[ i ]->clear(); - pMinecraft->stats[i]->parse(pData); - } + // clear the stats first - there could have beena signout + // and sign back in in the menus need to clear the player + // stats - can't assume it'll be done in setlevel - we may + // not be in the game + pMinecraft->stats[i]->clear(); + pMinecraft->stats[i]->parse(pData); + } + } - } + // clear the flag + app.uiGameDefinedDataChangedBitmask = 0; + } + PIXEndNamedEvent(); - // clear the flag - app.uiGameDefinedDataChangedBitmask=0; - } - PIXEndNamedEvent(); + // 4J-PB - Monitor the options save for a space issue + bool bOptionsNoSpace = false; + for (int i = 0; i < XUSER_MAX_COUNT; i++) { + if (bOptionsNoSpace == false) { + if (app.GetOptionsCallbackStatus(i) == + C4JStorage::eOptions_Callback_Write_Fail_NoSpace) { + // get the game to bring up the save space handling + bOptionsNoSpace = true; + app.SetOptionsCallbackStatus( + i, C4JStorage::eOptions_Callback_Idle); + app.SetAction(i, eAppAction_OptionsSaveNoSpace); + } + } + } - // 4J-PB - Monitor the options save for a space issue - bool bOptionsNoSpace=false; - for(int i=0;iRelease(); + // Free resources, unregister custom classes, and exit. + // app.Uninit(); + // g_pd3dDevice->Release(); } - -std::vector vRichPresenceStrings; +std::vector vRichPresenceStrings; // convert std::wstring to UTF-8 string -std::string std::wstring_to_utf8 (const std::wstring& str) -{ - std::wstring_convert> myconv; - return myconv.to_bytes(str); +std::string std::wstring_to_utf8(const std::wstring& str) { + std::wstring_convert> myconv; + return myconv.to_bytes(str); } -uint8_t *mallocAndCreateUTF8ArrayFromString(int iID) -{ - int result; - LPCWSTR wchString=app.GetString(iID); +uint8_t* mallocAndCreateUTF8ArrayFromString(int iID) { + int result; + LPCWSTR wchString = app.GetString(iID); - std::wstring srcString = wchString; - std::string dstString = std::wstring_to_utf8(srcString); + std::wstring srcString = wchString; + std::string dstString = std::wstring_to_utf8(srcString); - int dst_len = dstString.size()+1; - uint8_t *strUtf8=(uint8_t *)malloc(dst_len); - memcpy(strUtf8, dstString.c_str(), dst_len); + int dst_len = dstString.size() + 1; + uint8_t* strUtf8 = (uint8_t*)malloc(dst_len); + memcpy(strUtf8, dstString.c_str(), dst_len); - return strUtf8; + return strUtf8; } -uint8_t * AddRichPresenceString(int iID) -{ - uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) - { - vRichPresenceStrings.push_back(strUtf8); - } - return strUtf8; +uint8_t* AddRichPresenceString(int iID) { + uint8_t* strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); + if (strUtf8 != NULL) { + vRichPresenceStrings.push_back(strUtf8); + } + return strUtf8; } -void FreeRichPresenceStrings() -{ - uint8_t *strUtf8; - for(int i=0;i allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -1518,181 +1798,159 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } - - LeaveCriticalSection(&memCS); + trackEnable = true; + } + } - return p; + LeaveCriticalSection(&memCS); + + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes -) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } - -void DumpMem() -{ - int totalLeak = 0; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 46; +void MemPixStuff() { + const int MAX_SECT = 46; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } #endif diff --git a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp index 9a80f25a5..2582fd0cc 100644 --- a/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp +++ b/Minecraft.Client/Platform/PS3/PS3_Minecraft.cpp @@ -15,7 +15,7 @@ SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size #include #include #include -//#include +// #include #include "Leaderboards/PS3LeaderboardManager.h" #include "PS3Extras/PS3Strings.h" @@ -36,22 +36,18 @@ SYS_PROCESS_PARAM(1001, 0x10000); // thread priority, and stack size #endif /* Encrypted ID for protected data file (*) You must edit these binaries!! */ -char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = -{ - 0xEE, 0xA9, 0x37, 0xCC, - 0x5B, 0xD4, 0xD9, 0x0D, - 0x55, 0xED, 0x25, 0x31, - 0xFA, 0x33, 0xBD, 0xC4 -}; +char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = { + 0xEE, 0xA9, 0x37, 0xCC, 0x5B, 0xD4, 0xD9, 0x0D, + 0x55, 0xED, 0x25, 0x31, 0xFA, 0x33, 0xBD, 0xC4}; #define MILES_SPEAKERS 8 // default to 7.1 (can be 2, 6, 7, or 8) -//#define DISABLE_MILES_SOUND +// #define DISABLE_MILES_SOUND - -//#define HEAPINSPECTOR_PS3 1 -// when defining HEAPINSPECTOR_PS3, add this line to the linker settings -// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc --wrap reallocalign --wrap _malloc_init +// #define HEAPINSPECTOR_PS3 1 +// when defining HEAPINSPECTOR_PS3, add this line to the linker settings +// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc +// --wrap reallocalign --wrap _malloc_init #if HEAPINSPECTOR_PS3 #include "PS3Extras/HeapInspector/Server/HeapInspectorServer.h" @@ -79,15 +75,14 @@ char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = #include "../../../Minecraft.World/Util/ThreadName.h" #include "../../GameState/StatsCounter.h" #include "../../UI/Screens/ConnectScreen.h" -//#include "Social/SocialManager.h" -//#include "../Common/Leaderboards/LeaderboardManager.h" -//#include "../Common/XUI/XUI_Scene_Container.h" -//#include "NetworkManager.h" +// #include "Social/SocialManager.h" +// #include "../Common/Leaderboards/LeaderboardManager.h" +// #include "../Common/XUI/XUI_Scene_Container.h" +// #include "NetworkManager.h" #include "../../Rendering/Tesselator.h" #include "../Common/Console_Awards_enum.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "Resource.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" @@ -99,391 +94,551 @@ char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = #include -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) - -//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +// #define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 -DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= -{ +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES] = { #ifdef _XBOX - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, #else - 0,0,0,0,0 + 0, 0, 0, 0, 0 #endif }; // functions for storing and converting rich presence strings from wchar to utf8 -uint8_t * AddRichPresenceString(int iID); +uint8_t* AddRichPresenceString(int iID); void FreeRichPresenceStrings(); #if HEAPINSPECTOR_PS3 -std::vector GetHeapInfo() -{ - std::vector result = HeapInspectorServer::GetDefaultHeapInfo(); - HeapInspectorServer::HeapInfo localHeapInfo; - localHeapInfo.m_Description = "VRAM"; - localHeapInfo.m_Range.m_Min = 0xc0000000; - localHeapInfo.m_Range.m_Max = localHeapInfo.m_Range.m_Min + (249*1024*1024); - result.push_back(localHeapInfo); - return result; +std::vector GetHeapInfo() { + std::vector result = + HeapInspectorServer::GetDefaultHeapInfo(); + HeapInspectorServer::HeapInfo localHeapInfo; + localHeapInfo.m_Description = "VRAM"; + localHeapInfo.m_Range.m_Min = 0xc0000000; + localHeapInfo.m_Range.m_Max = + localHeapInfo.m_Range.m_Min + (249 * 1024 * 1024); + result.push_back(localHeapInfo); + return result; } extern "C" void* __real__malloc_init(size_t a_Boundary, size_t a_Size); -extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size) -{ - void* result = __real__malloc_init(a_Boundary, a_Size); - HeapInspectorServer::Initialise(GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); - return result; +extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size) { + void* result = __real__malloc_init(a_Boundary, a_Size); + HeapInspectorServer::Initialise( + GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); + return result; } -#endif // HEAPINSPECTOR_PS3 +#endif // HEAPINSPECTOR_PS3 //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- BOOL g_bWidescreen = TRUE; -//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware +// int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, +// this is setup from init_audio_hardware -void DefineActions(void) -{ - // The app needs to define the actions required, and the possible mappings for these +void DefineActions(void) { + // The app needs to define the actions required, and the possible mappings + // for these - // Split into Menu actions, and in-game actions - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + // Split into Menu actions, and in-game actions + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_A); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); - - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); - - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - } - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_A); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); + + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); + + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_A); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + } + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); } - -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif - -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; -bool g_bBootedFromInvite = false; +ID3D11Device* g_pd3dDevice = NULL; +ID3D11DeviceContext* g_pImmediateContext = NULL; +IDXGISwapChain* g_pSwapChain = NULL; +bool g_bBootedFromInvite = false; //-------------------------------------------------------------------------------------- // Create Direct3D device and swap chain //-------------------------------------------------------------------------------------- -HRESULT InitDevice() -{ - - - return S_OK; -} +HRESULT InitDevice() { return S_OK; } //-------------------------------------------------------------------------------------- // Render the frame //-------------------------------------------------------------------------------------- -void Render() -{ - -} +void Render() {} //-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- -void CleanupDevice() -{ - -} +void CleanupDevice() {} // simple function to load a file completely into memory -static void * load_file( char const * name ) -{ - void * ret; - int f; - unsigned int size; +static void* load_file(char const* name) { + void* ret; + int f; + unsigned int size; - f = open( name, O_RDONLY ); - if ( f == -1 ) return 0; + f = open(name, O_RDONLY); + if (f == -1) return 0; - size = lseek( f, 0, SEEK_END ); + size = lseek(f, 0, SEEK_END); - ret = malloc( size + 127 ); - if ( ret == 0 ) - { - close( f ); - return 0; - } + ret = malloc(size + 127); + if (ret == 0) { + close(f); + return 0; + } - ret = (void*) ( ( ( (unsigned int) ret ) + 127 ) & ~127 ); + ret = (void*)((((unsigned int)ret) + 127) & ~127); - lseek( f, 0, SEEK_SET ); - read( f, ret, size ); - close( f ); + lseek(f, 0, SEEK_SET); + read(f, ret, size); + close(f); - return ret; + return ret; } - - -void debugSaveGameDirect() -{ - - C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect"); - thread->Run(); - thread->WaitForCompletion(1000); +void debugSaveGameDirect() { + C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, + NULL, "debugSaveGameDirect"); + thread->Run(); + thread->WaitForCompletion(1000); } -void LoadSysModule(uint16_t module, const char* moduleName) -{ - int ret = cellSysmoduleLoadModule(module); - if(ret != CELL_OK) - { +void LoadSysModule(uint16_t module, const char* moduleName) { + int ret = cellSysmoduleLoadModule(module); + if (ret != CELL_OK) { #ifndef _CONTENT_PACKAGE - printf("Error cellSysmoduleLoadModule %s failed (%d) \n", moduleName, ret ); + printf("Error cellSysmoduleLoadModule %s failed (%d) \n", moduleName, + ret); #endif - assert(0); - } + assert(0); + } } #define LOAD_PS3_MODULE(m) LoadSysModule(m, #m) -int simpleMessageBoxCallback( UINT uiTitle, UINT uiText, - UINT *uiOptionA, UINT uiOptionC, DWORD dwPad, - int(*Func) (LPVOID,int,const C4JStorage::EMessageResult), - LPVOID lpParam ) -{ - ui.RequestMessageBox( uiTitle, uiText, - uiOptionA, uiOptionC, dwPad, - Func, lpParam, app.GetStringTable(), - NULL, 0 - ); +int simpleMessageBoxCallback(UINT uiTitle, UINT uiText, UINT* uiOptionA, + UINT uiOptionC, DWORD dwPad, + int (*Func)(LPVOID, int, + const C4JStorage::EMessageResult), + LPVOID lpParam) { + ui.RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, + lpParam, app.GetStringTable(), NULL, 0); - return 0; + return 0; } -void RegisterAwardsWithProfileManager() -{ - // register the awards - ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); +void RegisterAwardsWithProfileManager() { + // register the awards + ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, + eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel' - ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!' - ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender' - ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire' - ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery' - ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?' - ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.' - ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter' + ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, + eAwardType_Achievement); // 'Sniper Duel' + ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, + eAwardType_Achievement); // 'DIAMONDS!' + ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, + eAwardType_Achievement); // 'Return To Sender' + ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, + eAwardType_Achievement); // 'Into Fire' + ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, + eAwardType_Achievement); // 'Local Brewery' + ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, + eAwardType_Achievement); // 'The End?' + ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, + eAwardType_Achievement); // 'The End.' + ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, + eAwardType_Achievement); // 'Enchanter' #if 0 ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK); @@ -495,359 +650,391 @@ void RegisterAwardsWithProfileManager() ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); #endif - // Rich Presence init - number of presences, number of contexts - //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n"); - ProfileManager.RichPresenceInit(-1,-1); // 4J-JEV - Presence and Context count not used. - ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_PS3::SetRichPresence); - char *pchRichPresenceString; + // Rich Presence init - number of presences, number of contexts + // printf("Rich presence strings are hard coded on PS3 for now, must change + // this!\n"); + ProfileManager.RichPresenceInit( + -1, -1); // 4J-JEV - Presence and Context count not used. + ProfileManager.SetRichPresenceSettingFn( + SQRNetworkManager_PS3::SetRichPresence); + char* pchRichPresenceString; - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); - ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); + ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, + pchRichPresenceString); + pchRichPresenceString = (char*)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); - - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); } -int LoadSysModules() -{ - cellSysmoduleInitialize(); +int LoadSysModules() { + cellSysmoduleInitialize(); - LOAD_PS3_MODULE(CELL_SYSMODULE_FS ); - // 4J Stu - For Iggy - LOAD_PS3_MODULE(CELL_SYSMODULE_RTC); - // string conversions - LOAD_PS3_MODULE(CELL_SYSMODULE_L10N ); - // on-screen keyboard - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_OSK_EXT ); - // Networking - //First load the Network module PRX - LOAD_PS3_MODULE(CELL_SYSMODULE_NET); - //Load the libnetctl network connection information module PRX - LOAD_PS3_MODULE(CELL_SYSMODULE_NETCTL); - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP2 ); - LOAD_PS3_MODULE(CELL_SYSMODULE_RUDP ); - LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP); - LOAD_PS3_MODULE(CELL_SYSMODULE_HTTPS); - LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP_UTIL); - LOAD_PS3_MODULE(CELL_SYSMODULE_SSL); - LOAD_PS3_MODULE(CELL_SYSMODULE_JPGDEC); - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_AVCHAT2); + LOAD_PS3_MODULE(CELL_SYSMODULE_FS); + // 4J Stu - For Iggy + LOAD_PS3_MODULE(CELL_SYSMODULE_RTC); + // string conversions + LOAD_PS3_MODULE(CELL_SYSMODULE_L10N); + // on-screen keyboard + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_OSK_EXT); + // Networking + // First load the Network module PRX + LOAD_PS3_MODULE(CELL_SYSMODULE_NET); + // Load the libnetctl network connection information module PRX + LOAD_PS3_MODULE(CELL_SYSMODULE_NETCTL); + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP2); + LOAD_PS3_MODULE(CELL_SYSMODULE_RUDP); + LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP); + LOAD_PS3_MODULE(CELL_SYSMODULE_HTTPS); + LOAD_PS3_MODULE(CELL_SYSMODULE_HTTP_UTIL); + LOAD_PS3_MODULE(CELL_SYSMODULE_SSL); + LOAD_PS3_MODULE(CELL_SYSMODULE_JPGDEC); + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_AVCHAT2); - // 4J-PB - Get launch parameters - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_GAME); - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP_COMMERCE2); + // 4J-PB - Get launch parameters + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_GAME); + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_NP_COMMERCE2); - LOAD_PS3_MODULE(CELL_SYSMODULE_AVCONF_EXT); + LOAD_PS3_MODULE(CELL_SYSMODULE_AVCONF_EXT); - LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_SAVEDATA); - - unsigned int uiType ; - unsigned int uiAttributes ; - CellGameContentSize size,sizeBD; - char *dirName=getDirName(); - char *contentInfoPath = getConsoleHomePath(); - char *usrdirPath= getUsrDirPath(); - char *contentInfoPathBDPatch = getConsoleHomePathBDPatch(); - char *usrdirPathBDPatch= getUsrDirPathBDPatch(); - int ret; - bool bBootedFromBDPatch=false; + LOAD_PS3_MODULE(CELL_SYSMODULE_SYSUTIL_SAVEDATA); - memset(&size, 0x00, sizeof(CellGameContentSize)); + unsigned int uiType; + unsigned int uiAttributes; + CellGameContentSize size, sizeBD; + char* dirName = getDirName(); + char* contentInfoPath = getConsoleHomePath(); + char* usrdirPath = getUsrDirPath(); + char* contentInfoPathBDPatch = getConsoleHomePathBDPatch(); + char* usrdirPathBDPatch = getUsrDirPathBDPatch(); + int ret; + bool bBootedFromBDPatch = false; - ret = cellGameBootCheck( &uiType, &uiAttributes, &size, dirName ) ; - if(ret < 0) - { - DEBUG_PRINTF("cellGameBootCheck() Error: 0x%x\n", ret); - } - else - { - DEBUG_PRINTF("cellGameBootCheck() OK\n"); - DEBUG_PRINTF(" get_type = [%d] get_attributes = [0x%08x] dirName = [%s]\n", uiType, uiAttributes, dirName); - DEBUG_PRINTF(" hddFreeSizeKB = [%d] sizeKB = [%d] sysSizeKB = [%d]\n", size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB); - } + memset(&size, 0x00, sizeof(CellGameContentSize)); - if (uiAttributes & CELL_GAME_ATTRIBUTE_INVITE_MESSAGE) - { - g_bBootedFromInvite = true; - DEBUG_PRINTF("Booted from invite\n"); - } - if (uiAttributes & CELL_GAME_ATTRIBUTE_CUSTOM_DATA_MESSAGE) - { - DEBUG_PRINTF("Booted from custom data\n"); - //bootedFromCustomData = true; - } - if(uiAttributes&CELL_GAME_ATTRIBUTE_PATCH) - { - // Booted from a patch (only for a disc boot game) - // To access patch game data, obtain its path by separately using cellGamePatchCheck(). - bBootedFromBDPatch=true; - app.SetBootedFromDiscPatch(); - } - // true if booting from disc, false if booting from HDD - StorageManager.SetBootTypeDisc(uiType == CELL_GAME_GAMETYPE_DISC); + ret = cellGameBootCheck(&uiType, &uiAttributes, &size, dirName); + if (ret < 0) { + DEBUG_PRINTF("cellGameBootCheck() Error: 0x%x\n", ret); + } else { + DEBUG_PRINTF("cellGameBootCheck() OK\n"); + DEBUG_PRINTF( + " get_type = [%d] get_attributes = [0x%08x] dirName = [%s]\n", + uiType, uiAttributes, dirName); + DEBUG_PRINTF(" hddFreeSizeKB = [%d] sizeKB = [%d] sysSizeKB = [%d]\n", + size.hddFreeSizeKB, size.sizeKB, size.sysSizeKB); + } - StorageManager.SetMessageBoxCallback(&simpleMessageBoxCallback); + if (uiAttributes & CELL_GAME_ATTRIBUTE_INVITE_MESSAGE) { + g_bBootedFromInvite = true; + DEBUG_PRINTF("Booted from invite\n"); + } + if (uiAttributes & CELL_GAME_ATTRIBUTE_CUSTOM_DATA_MESSAGE) { + DEBUG_PRINTF("Booted from custom data\n"); + // bootedFromCustomData = true; + } + if (uiAttributes & CELL_GAME_ATTRIBUTE_PATCH) { + // Booted from a patch (only for a disc boot game) + // To access patch game data, obtain its path by separately using + // cellGamePatchCheck(). + bBootedFromBDPatch = true; + app.SetBootedFromDiscPatch(); + } + // true if booting from disc, false if booting from HDD + StorageManager.SetBootTypeDisc(uiType == CELL_GAME_GAMETYPE_DISC); - cellGameContentPermit(contentInfoPath,usrdirPath); - DEBUG_PRINTF("contentInfoPath - %s\n",contentInfoPath); - DEBUG_PRINTF("usrdirPath - %s\n",usrdirPath); + StorageManager.SetMessageBoxCallback(&simpleMessageBoxCallback); - ret=cellGamePatchCheck(&sizeBD,NULL); - if(ret < 0) - { - DEBUG_PRINTF("cellGamePatchCheck() Error: 0x%x\n", ret); - } - else - { - DEBUG_PRINTF("cellGamePatchCheck() OK - we were booted from a disc patch!\n"); + cellGameContentPermit(contentInfoPath, usrdirPath); + DEBUG_PRINTF("contentInfoPath - %s\n", contentInfoPath); + DEBUG_PRINTF("usrdirPath - %s\n", usrdirPath); - cellGameContentPermit(contentInfoPathBDPatch,usrdirPathBDPatch); - DEBUG_PRINTF("contentInfoPath - %s\n",contentInfoPathBDPatch); - DEBUG_PRINTF("usrdirPath - %s\n",usrdirPathBDPatch); + ret = cellGamePatchCheck(&sizeBD, NULL); + if (ret < 0) { + DEBUG_PRINTF("cellGamePatchCheck() Error: 0x%x\n", ret); + } else { + DEBUG_PRINTF( + "cellGamePatchCheck() OK - we were booted from a disc patch!\n"); - app.SetDiscPatchUsrDir(usrdirPathBDPatch); - } + cellGameContentPermit(contentInfoPathBDPatch, usrdirPathBDPatch); + DEBUG_PRINTF("contentInfoPath - %s\n", contentInfoPathBDPatch); + DEBUG_PRINTF("usrdirPath - %s\n", usrdirPathBDPatch); - if(uiAttributes&CELL_GAME_ATTRIBUTE_DEBUG) - { - DEBUG_PRINTF("Booted from debugger\n"); + app.SetDiscPatchUsrDir(usrdirPathBDPatch); + } + + if (uiAttributes & CELL_GAME_ATTRIBUTE_DEBUG) { + DEBUG_PRINTF("Booted from debugger\n"); #ifndef _RELEASE_FOR_ART - strcat(contentInfoPath,"/Minecraft.Client"); - strcpy(usrdirPath,contentInfoPath); + strcat(contentInfoPath, "/Minecraft.Client"); + strcpy(usrdirPath, contentInfoPath); #endif - } - else - { - //strcat(contentInfoPath,"/"); - //strcat(usrdirPath,"/"); - } + } else { + // strcat(contentInfoPath,"/"); + // strcat(usrdirPath,"/"); + } - return size.hddFreeSizeKB; + return size.hddFreeSizeKB; } +int main() { + ShutdownManager::Initialise(); - - -int main() -{ - ShutdownManager::Initialise(); - - sys_memory_info_t mem_info; - sys_memory_get_user_memory_size(&mem_info); + sys_memory_info_t mem_info; + sys_memory_get_user_memory_size(&mem_info); #ifndef _CONTENT_PACKAGE - printf("------------------------------------------------------\n"); - printf("------------------------------------------------------\n"); - printf("total_user_memory : %.02f\n", mem_info.total_user_memory / (1024.0f*1024.0f)); - printf("available_user_memory : %.02f", mem_info.available_user_memory / (1024.0f*1024.0f)); - printf("------------------------------------------------------\n"); - printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); + printf("total_user_memory : %.02f\n", + mem_info.total_user_memory / (1024.0f * 1024.0f)); + printf("available_user_memory : %.02f", + mem_info.available_user_memory / (1024.0f * 1024.0f)); + printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); #endif - // - // initialize the ps3 - // + // + // initialize the ps3 + // - int ihddFreeSizeKB=LoadSysModules(); - ProfileManager.SetHDDFreeKB(ihddFreeSizeKB); - // Sony request that we have enough space for a save game, so people don't get hit with this when they first save. Going to make the space 20MB - ProfileManager.SetMinSaveKB(20000); + int ihddFreeSizeKB = LoadSysModules(); + ProfileManager.SetHDDFreeKB(ihddFreeSizeKB); + // Sony request that we have enough space for a save game, so people don't + // get hit with this when they first save. Going to make the space 20MB + ProfileManager.SetMinSaveKB(20000); - cellSysutilEnableBgmPlayback(); + cellSysutilEnableBgmPlayback(); - C4JThread_SPU::initSPURS(); + C4JThread_SPU::initSPURS(); #ifndef DISABLE_MILES_SOUND -#ifdef USE_SPURS - void * spurs_info[ 2 ]; - spurs_info[ 0 ] = C4JThread_SPU::getSpurs2(); - extern const CellSpursTaskBinInfo _binary_task_mssspurs_elf_taskbininfo; - spurs_info[1] = (void*)_binary_task_mssspurs_elf_taskbininfo.eaElf; +#ifdef USE_SPURS + void* spurs_info[2]; + spurs_info[0] = C4JThread_SPU::getSpurs2(); + extern const CellSpursTaskBinInfo _binary_task_mssspurs_elf_taskbininfo; + spurs_info[1] = (void*)_binary_task_mssspurs_elf_taskbininfo.eaElf; - // - // load it on an SPU - // + // + // load it on an SPU + // - if ( !MilesStartAsyncThread( 0, spurs_info ) ) - { + if (!MilesStartAsyncThread(0, spurs_info)) { #ifndef _CONTENT_PACKAGE - printf( "Error loading SPU image.\n" ); + printf("Error loading SPU image.\n"); #endif - return( 5 ); - } + return (5); + } #else - // - // Start an SPU thread on SPU threads or RAW - // + // + // Start an SPU thread on SPU threads or RAW + // - { - sys_spu_image_t spu_image; - char selfPath[256]; - sprintf(selfPath,"%s%s%s", getUsrDirPath(), SPU_SELF_PATH, "mssraw.elf" ); + { + sys_spu_image_t spu_image; + char selfPath[256]; + sprintf(selfPath, "%s%s%s", getUsrDirPath(), SPU_SELF_PATH, + "mssraw.elf"); - if ( sys_spu_image_open( &spu_image, selfPath ) != CELL_OK ) - { - printf( "Error loading SPU image.\n" ); - return( 4 ); - } + if (sys_spu_image_open(&spu_image, selfPath) != CELL_OK) { + printf("Error loading SPU image.\n"); + return (4); + } - if ( !MilesStartAsyncThread( 0, &spu_image ) ) - { - printf( "Error loading SPU image.\n" ); - return( 5); - } + if (!MilesStartAsyncThread(0, &spu_image)) { + printf("Error loading SPU image.\n"); + return (5); + } - // - // now close the image, since the system caches it for us - // + // + // now close the image, since the system caches it for us + // - sys_spu_image_close( &spu_image ); - } + sys_spu_image_close(&spu_image); + } #endif + // + // now initialize libAudio + // - // - // now initialize libAudio - // - - cellAudioInit(); + cellAudioInit(); -#endif // DISABLE_MILES_SOUND +#endif // DISABLE_MILES_SOUND - // 4J-JEV: Moved this here in case some archived files are compressed. - Compression::CreateNewThreadStorage(); + // 4J-JEV: Moved this here in case some archived files are compressed. + Compression::CreateNewThreadStorage(); - EdgeZLib::Init(C4JThread_SPU::getSpurs2()); + EdgeZLib::Init(C4JThread_SPU::getSpurs2()); - RenderManager.Initialise(); + RenderManager.Initialise(); - // Read the file containing the product codes - if(app.ReadProductCodes()==FALSE) - { - // can't continue - app.FatalLoadError(); - } + // Read the file containing the product codes + if (app.ReadProductCodes() == FALSE) { + // can't continue + app.FatalLoadError(); + } - StorageManager.SetDLCProductCode(app.GetProductCode(),app.GetDiscProductCode()); - if(StorageManager.GetBootTypeDisc()) - { - StorageManager.SetBDPatchUsrDir(app.GetDiscPatchUsrDir()); - } - StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); - ProfileManager.SetServiceID(app.GetCommerceCategory()); + StorageManager.SetDLCProductCode(app.GetProductCode(), + app.GetDiscProductCode()); + if (StorageManager.GetBootTypeDisc()) { + StorageManager.SetBDPatchUsrDir(app.GetDiscPatchUsrDir()); + } + StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); + ProfileManager.SetServiceID(app.GetCommerceCategory()); - switch(app.GetProductSKU()) - { - case e_sku_SCEE: - // 4J-PB - need to be online to do this check, so let's stick with the 7+, and move this - - if(StorageManager.GetBootTypeDisc()) - { - // set Europe age, then hone down specific countries - ProfileManager.SetMinimumAge(7,0); // PEGI 7+ - ProfileManager.SetGermanyMinimumAge(6); // USK 6+ - ProfileManager.SetAustraliaMinimumAge(8); // PG rating has no age, but for some reason the testers are saying it's 8 - ProfileManager.SetRussiaMinimumAge(6); - } - else - { - // PEGI 7+ - ProfileManager.SetMinimumAge(7,0); - } - break; - case e_sku_SCEA: - // ESRB EVERYONE 10+ - ProfileManager.SetMinimumAge(10,1); - break; - case e_sku_SCEJ: - // CERO A - ProfileManager.SetMinimumAge(0,2); - break; - } + switch (app.GetProductSKU()) { + case e_sku_SCEE: + // 4J-PB - need to be online to do this check, so let's stick with + // the 7+, and move this - // Initialise NpBasic - this used to be in the network manager but other things need this so moved out on its own - void *np_pool = memalign( 8, SQRNetworkManager::NP_POOL_SIZE ); - int ret = sceNp2Init( SQRNetworkManager::NP_POOL_SIZE, np_pool ); - if( ret < 0 ) - { - assert(0); - } + if (StorageManager.GetBootTypeDisc()) { + // set Europe age, then hone down specific countries + ProfileManager.SetMinimumAge(7, 0); // PEGI 7+ + ProfileManager.SetGermanyMinimumAge(6); // USK 6+ + ProfileManager.SetAustraliaMinimumAge( + 8); // PG rating has no age, but for some reason the + // testers are saying it's 8 + ProfileManager.SetRussiaMinimumAge(6); + } else { + // PEGI 7+ + ProfileManager.SetMinimumAge(7, 0); + } + break; + case e_sku_SCEA: + // ESRB EVERYONE 10+ + ProfileManager.SetMinimumAge(10, 1); + break; + case e_sku_SCEJ: + // CERO A + ProfileManager.SetMinimumAge(0, 2); + break; + } + // Initialise NpBasic - this used to be in the network manager but other + // things need this so moved out on its own + void* np_pool = memalign(8, SQRNetworkManager::NP_POOL_SIZE); + int ret = sceNp2Init(SQRNetworkManager::NP_POOL_SIZE, np_pool); + if (ret < 0) { + assert(0); + } - app.loadMediaArchive(); + app.loadMediaArchive(); - app.DebugPrintf("+++Main - after app.loadMediaArchive\n"); + app.DebugPrintf("+++Main - after app.loadMediaArchive\n"); - app.loadStringTable(); + app.loadStringTable(); - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - // Need to init Input before UI so we know what the Circle/Cross state is - InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions Need to init Input before UI so we + // know what the Circle/Cross state is + InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); - if(RenderManager.IsWidescreen()) - ui.init(1280,720); - else - ui.init(1280,480); + if (RenderManager.IsWidescreen()) + ui.init(1280, 720); + else + ui.init(1280, 480); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL - // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised - app.GetCommerce()->CheckForTrialUpgradeKey(); + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + // 4J-PB - Kick of the check for trial or full version - requires ui to be + // initialised + app.GetCommerce()->CheckForTrialUpgradeKey(); - static bool bTrialTimerDisplayed=true; + static bool bTrialTimerDisplayed = true; - - //////////////// - // Initialise // - //////////////// + //////////////// + // Initialise // + //////////////// #if 0 // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params @@ -869,32 +1056,34 @@ int main() } #endif - app.InitTime(); + app.InitTime(); + // Initialise the profile manager with the game Title ID, Offer ID, a + // profile version number, and the number of profile values and settings + ProfileManager.Initialise( + SQRNetworkManager_PS3::GetSceNpCommsId(), + SQRNetworkManager_PS3::GetSceNpCommsSig(), PROFILE_VERSION_10, + NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings - ProfileManager.Initialise(SQRNetworkManager_PS3::GetSceNpCommsId(), - SQRNetworkManager_PS3::GetSceNpCommsSig(), - PROFILE_VERSION_10, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + app.DebugPrintf("+++Main - after ProfileManager.Initialise\n"); - app.DebugPrintf("+++Main - after ProfileManager.Initialise\n"); + // register the awards + RegisterAwardsWithProfileManager(); - // register the awards - RegisterAwardsWithProfileManager(); + // register the get string function with the profile lib, so it can be + // called within the lib - // register the get string function with the profile lib, so it can be called within the lib + ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); + ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); + ProfileManager.SetSignInQuestionID(IDS_SIGNIN_PSN); - ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); - ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); - ProfileManager.SetSignInQuestionID(IDS_SIGNIN_PSN); - - // initialise the storage manager with a callback for displaying the saving message - StorageManager.Init(0,app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,""); + // initialise the storage manager with a callback for displaying the saving + // message + StorageManager.Init( + 0, app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, + &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, ""); #if 0 @@ -902,24 +1091,30 @@ int main() StorageManager.StoreTMSPathName(); #endif - // MGH - I've had to rearrange some of the ordering here, as I was getting conflicts with the sysutils for trophies and the upgrade key + // MGH - I've had to rearrange some of the ordering here, as I was getting + // conflicts with the sysutils for trophies and the upgrade key - //app.FatalLoadError(); + // app.FatalLoadError(); - - // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out - ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + // set a function to be called when there's a sign in change, so we can exit + // a level if the primary player signs out + ProfileManager.SetSignInChangeCallback( + &CConsoleMinecraftApp::SignInChangeCallback, (LPVOID)&app); #if 0 // set a function to be called when the ethernet is disconnected, so we can back out if required ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); #endif - // Set a callback for the default player options to be set - when there is no profile data for the player + // Set a callback for the default player options to be set - when there is + // no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + StorageManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); + StorageManager.SetOptionsDataCallback( + &CConsoleMinecraftApp::OptionsDataCallback, (LPVOID)&app); - // Set a callback to deal with old profile versions needing updated to new versions + // Set a callback to deal with old profile versions needing updated to new + // versions #if 0 ProfileManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); @@ -929,140 +1124,146 @@ int main() // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. -#endif // 0 +#endif // 0 - SonyRemoteStorage_PS3* pRemote = (SonyRemoteStorage_PS3*)app.getRemoteStorage(); - pRemote->SetSecureID(secureFileId); - pRemote->SetServiceID(app.GetCommerceCategory()); + SonyRemoteStorage_PS3* pRemote = + (SonyRemoteStorage_PS3*)app.getRemoteStorage(); + pRemote->SetSecureID(secureFileId); + pRemote->SetServiceID(app.GetCommerceCategory()); - // Before using any save/load on PS3, we need a secure id set - StorageManager.InitialiseProfileData(PROFILE_VERSION_10, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + // Before using any save/load on PS3, we need a secure id set + StorageManager.InitialiseProfileData( + PROFILE_VERSION_10, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - app.DebugPrintf("+++Main - after InitialiseProfileData\n"); + app.DebugPrintf("+++Main - after InitialiseProfileData\n"); + StorageManager.SetSecureID(secureFileId); + // set the name of the folder on the XMB that the saves are grouped in + // 4J-PB - TRC that we need to be able to see the BD in a different titled + // save from the digital game + if (StorageManager.GetBootTypeDisc()) { + std::wstring wsTemp = app.GetString(IDS_GAMENAME); + WCHAR wchTemp[64]; + wsTemp.append(L" ("); + mbstowcs(wchTemp, app.GetDiscProductCode(), 64); + wsTemp.append(wchTemp); + wsTemp.append(L")"); + StorageManager.SetGameSaveFolderTitle((WCHAR*)(wsTemp.c_str())); + } else { + StorageManager.SetGameSaveFolderTitle((WCHAR*)app.GetString( + IDS_GAMENAME)); //"Minecraft: PlayStation®3 Edition");//GAMENAME); + } + StorageManager.SetSaveCacheFolderTitle((WCHAR*)app.GetString( + IDS_SAVECACHEFILE)); //"Minecraft: PlayStation®3 Edition");//GAMENAME); + StorageManager.SetOptionsFolderTitle((WCHAR*)app.GetString( + IDS_OPTIONSFILE)); //"Minecraft: PlayStation®3 Edition");//GAMENAME); + StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); + StorageManager.SetMaxSaves(99); + byteArray baOptionsIcon = + app.getArchiveFile(L"DefaultOptionsImage320x176.png"); + byteArray baSaveThumbnail = + app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); + byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png"); - StorageManager.SetSecureID(secureFileId); - // set the name of the folder on the XMB that the saves are grouped in - // 4J-PB - TRC that we need to be able to see the BD in a different titled save from the digital game - if(StorageManager.GetBootTypeDisc()) - { - std::wstring wsTemp = app.GetString(IDS_GAMENAME); - WCHAR wchTemp[64]; - wsTemp.append(L" ("); - mbstowcs(wchTemp,app.GetDiscProductCode(),64); - wsTemp.append(wchTemp); - wsTemp.append(L")"); - StorageManager.SetGameSaveFolderTitle((WCHAR *)(wsTemp.c_str())); - } - else - { - StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME));//"Minecraft: PlayStation®3 Edition");//GAMENAME); - } - StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE));//"Minecraft: PlayStation®3 Edition");//GAMENAME); - StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE));//"Minecraft: PlayStation®3 Edition");//GAMENAME); - StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); - StorageManager.SetMaxSaves(99); - byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage320x176.png"); - byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); - byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png"); + uint8_t* szTemp = mallocAndCreateUTF8ArrayFromString(IDS_NODEVICE_DECLINE); + StorageManager.SetContinueWithoutSavingMessage((char*)szTemp); + free(szTemp); + StorageManager.SetDefaultImages( + (PBYTE)baOptionsIcon.data, baOptionsIcon.length, + (PBYTE)baSaveImage.data, baSaveImage.length, + (PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - uint8_t *szTemp = mallocAndCreateUTF8ArrayFromString(IDS_NODEVICE_DECLINE); - StorageManager.SetContinueWithoutSavingMessage((char *)szTemp); - free(szTemp); - StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); + if (baOptionsIcon.data != NULL) { + delete[] baOptionsIcon.data; + } - if(baOptionsIcon.data!=NULL) - { - delete [] baOptionsIcon.data; - } + if (baSaveThumbnail.data != NULL) { + delete[] baSaveThumbnail.data; + } - if(baSaveThumbnail.data!=NULL) - { - delete [] baSaveThumbnail.data; - } + if (baSaveImage.data != NULL) { + delete[] baSaveImage.data; + } - if(baSaveImage.data!=NULL) - { - delete [] baSaveImage.data; - } + std::wstring wsName = L"Graphics\\SaveChest.png"; + byteArray baSaveLoadIcon = app.getArchiveFile(wsName); + if (baSaveLoadIcon.data != NULL) { + StorageManager.SetSaveLoadIcon((PBYTE)baSaveLoadIcon.data, + baSaveLoadIcon.length); + delete[] baSaveLoadIcon.data; + } - std::wstring wsName=L"Graphics\\SaveChest.png"; - byteArray baSaveLoadIcon = app.getArchiveFile(wsName); - if(baSaveLoadIcon.data!=NULL) - { - StorageManager.SetSaveLoadIcon((PBYTE)baSaveLoadIcon.data, baSaveLoadIcon.length); - delete [] baSaveLoadIcon.data; - } + // defaults + StorageManager.SetSaveTitle(L"Default Save"); - // defaults - StorageManager.SetSaveTitle(L"Default Save"); + // debug switch to trial version + // ProfileManager.SetDebugFullOverride(true); - // debug switch to trial version -// ProfileManager.SetDebugFullOverride(true); + // ProfileManager.AddDLC(2); + StorageManager.SetDLCPackageRoot("DLCDrive"); + StorageManager.RegisterMarketplaceCountsCallback( + &CConsoleMinecraftApp::MarketplaceCountsCallback, (LPVOID)&app); - //ProfileManager.AddDLC(2); - StorageManager.SetDLCPackageRoot("DLCDrive"); - StorageManager.RegisterMarketplaceCountsCallback(&CConsoleMinecraftApp::MarketplaceCountsCallback,(LPVOID)&app); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); + app.InitGameSettings(); // - allocates the memory for the game settings + // read the options here for controller 0 - this won't actually be actioned + // until a storagemanager tick later + StorageManager.ReadFromProfile(0); - app.InitGameSettings(); // - allocates the memory for the game settings - // read the options here for controller 0 - this won't actually be actioned until a storagemanager tick later - StorageManager.ReadFromProfile(0); - - // set the default profile values - // 4J-PB - InitGameSettings already does this - /*for(int i=0;iOpenSession(); + // LeaderboardManager::Instance()->ReadStats_TopRank(DebugReadListener::m_instance, + // 0, LeaderboardManager::eStatsType_Travelling, 1, 1); + // 4J-PB - we really need to know at this point if we are playing the trial + // or full game, so sleep until we know + while (app.GetCommerce()->LicenseChecked() == false) { + cellSysutilCheckCallback(); + Sleep(50); + } + // wait for the trophy init to complete - nonblocking semaphore + while ((ProfileManager.tryWaitTrophyInitComplete() < 0) && + ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) { + // keep looping + RenderManager.Tick(); + RenderManager.Present(); + cellSysutilCheckCallback(); + Sleep(50); + } - LeaderboardManager::Instance()->OpenSession(); - //LeaderboardManager::Instance()->ReadStats_TopRank(DebugReadListener::m_instance, 0, LeaderboardManager::eStatsType_Travelling, 1, 1); + app.DebugPrintf("+++Main - after tryWaitTrophyInitComplete\n"); - // 4J-PB - we really need to know at this point if we are playing the trial or full game, so sleep until we know - while(app.GetCommerce()->LicenseChecked()==false) - { - cellSysutilCheckCallback(); - Sleep(50); - } - // wait for the trophy init to complete - nonblocking semaphore - while((ProfileManager.tryWaitTrophyInitComplete()<0)&&ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) - { - // keep looping - RenderManager.Tick(); - RenderManager.Present(); - cellSysutilCheckCallback(); - Sleep(50); - } + if (ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) { + g_NetworkManager.Initialise(); + g_NetworkManager.SetLocalGame(true); + } - app.DebugPrintf("+++Main - after tryWaitTrophyInitComplete\n"); + // ProfileManager.WaitTrophyInitComplete(); - if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) - { - g_NetworkManager.Initialise(); - g_NetworkManager.SetLocalGame(true); - } + // 4J-PB - get the chat/UGC restriction flag here so we can stop online + // games, and content rating and restriction It's ok to do this for the + // primary PSN player here - it has this data locally. All other players + // need to do it on PSN sign in. - //ProfileManager.WaitTrophyInitComplete(); + // bool bChatRestricted=false; + // ProfileManager.GetChatAndContentRestrictions(0,&bChatRestricted,NULL,NULL); - // 4J-PB - get the chat/UGC restriction flag here so we can stop online games, and content rating and restriction - // It's ok to do this for the primary PSN player here - it has this data locally. All other players need to do it on PSN sign in. + // 4J-PB - really want to wait until we've read the options, so we can set + // the right language if they've chosen one other than the default + // bool bOptionsRead=false; + // + // while((bOptionsRead==false) && + // ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) + // { + // switch(app.GetOptionsCallbackStatus(0)) + // { + // case C4JStorage::eOptions_Callback_Idle: + // break; + // default: + // bOptionsRead=true; + // break; + // } + // StorageManager.Tick(); + // } + // + // if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) + // { + // app.loadStringTable(); + // ui.SetupFont(); + // //handleReload(); + // } -// bool bChatRestricted=false; -// ProfileManager.GetChatAndContentRestrictions(0,&bChatRestricted,NULL,NULL); - - // 4J-PB - really want to wait until we've read the options, so we can set the right language if they've chosen one other than the default -// bool bOptionsRead=false; -// -// while((bOptionsRead==false) && ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) -// { -// switch(app.GetOptionsCallbackStatus(0)) -// { -// case C4JStorage::eOptions_Callback_Idle: -// break; -// default: -// bOptionsRead=true; -// break; -// } -// StorageManager.Tick(); -// } -// -// if(ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) -// { -// app.loadStringTable(); -// ui.SetupFont(); -// //handleReload(); -// } - - while( ShutdownManager::ShouldRun(ShutdownManager::eMainThread) ) - { + while (ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) { #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -1144,95 +1346,96 @@ int main() pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); } #endif - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); -// CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); - - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); -// SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #1"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); - // 4J-PB - these get set every tick causing the write profile flag to be true all the time - -// app.SetGameSettingsDebugMask(0,eDebugSetting_LoadSavesFromDisk); -// app.SetGameSettingsDebugMask(0,eDebugSetting_WriteSavesToDisk); -// app.SetLoadSavesFromFolderEnabled(true); -// app.SetWriteSavesToFolderEnabled(true); - - LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { + PIXBeginNamedEvent(0, "Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); + // 4J-PB - these get set every tick causing the write profile flag to be + // true all the time - + // app.SetGameSettingsDebugMask(0,eDebugSetting_LoadSavesFromDisk); + // app.SetGameSettingsDebugMask(0,eDebugSetting_WriteSavesToDisk); + // app.SetLoadSavesFromFolderEnabled(true); + // app.SetWriteSavesToFolderEnabled(true); -// if(InputManager.ButtonPressed(0, MINECRAFT_ACTION_SNEAK_TOGGLE)) -// { -// app.DebugPrintf("saving game...\n"); -// debugSaveGameDirect(); -// -// } - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + // if(InputManager.ButtonPressed(0, + // MINECRAFT_ACTION_SNEAK_TOGGLE)) + // { + // app.DebugPrintf("saving game...\n"); + // debugSaveGameDirect(); + // + // } + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft + ->tickAllConnections(); // Added to stop timing out when we + // are waiting after converting to + // an offline game + } + } - pMinecraft->soundEngine->playMusicTick(); + pMinecraft->soundEngine->playMusicTick(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -1242,153 +1445,144 @@ int main() bDumpTextureUsage = false; } #endif - ui.tick(); - ui.render(); + ui.tick(); + ui.render(); - // Present the frame. - PIXBeginNamedEvent(0,"Frame present"); - RenderManager.Present(); - PIXEndNamedEvent(); + // Present the frame. + PIXBeginNamedEvent(0, "Frame present"); + RenderManager.Present(); + PIXEndNamedEvent(); - RenderManager.Set_matrixDirty(); + RenderManager.Set_matrixDirty(); - ui.CheckMenuDisplayed(); - PIXBeginNamedEvent(0,"Profile load check"); - // has the game defined profile data been changed (by a profile load) - if(app.uiGameDefinedDataChangedBitmask!=0) - { - void *pData; - for(int i=0;istats[ i ]->clear(); - pMinecraft->stats[i]->parse(pData); - } - } + // clear the stats first - there could have beena signout + // and sign back in in the menus need to clear the player + // stats - can't assume it'll be done in setlevel - we may + // not be in the game + pMinecraft->stats[i]->clear(); + pMinecraft->stats[i]->parse(pData); + } + } - // Check to see if we can post to social networks. - // PS3 TO DO - CSocialManager::Instance()->RefreshPostingCapability(); + // Check to see if we can post to social networks. + // PS3 TO DO - + // CSocialManager::Instance()->RefreshPostingCapability(); - // clear the flag - app.uiGameDefinedDataChangedBitmask=0; + // clear the flag + app.uiGameDefinedDataChangedBitmask = 0; - // Check if any profile write are needed - //app.CheckGameSettingsChanged(); - } - PIXEndNamedEvent(); + // Check if any profile write are needed + // app.CheckGameSettingsChanged(); + } + PIXEndNamedEvent(); #if 0 app.TickDLCOffersRetrieved(); app.TickTMSPPFilesRetrieved(); #endif - PIXBeginNamedEvent(0,"Network manager do work #2"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Network manager do work #2"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); #if 0 PIXBeginNamedEvent(0,"Misc extra xui"); // Update XUI Timers hr = XuiTimersRun(); #endif - // Any threading type things to deal with from the xui side? - app.HandleXuiActions(); + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); #if 0 PIXEndNamedEvent(); #endif - // 4J-PB - Update the trial timer display if we are in the trial version - if(!ProfileManager.IsFullVersion()) - { - // display the trial timer - if(app.GetGameStarted()) - { - // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down - if(app.IsAppPaused()) - { - app.UpdateTrialPausedTimer(); - } - ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); - } - } - else - { - // need to turn off the trial timer if it was on , and we've unlocked the full version - if(bTrialTimerDisplayed) - { - ui.ShowTrialTimer(false); - bTrialTimerDisplayed=false; - } - } + // 4J-PB - Update the trial timer display if we are in the trial version + if (!ProfileManager.IsFullVersion()) { + // display the trial timer + if (app.GetGameStarted()) { + // 4J-PB - if the game is paused, add the elapsed time to the + // trial timer count so it doesn't tick down + if (app.IsAppPaused()) { + app.UpdateTrialPausedTimer(); + } + ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } else { + // need to turn off the trial timer if it was on , and we've + // unlocked the full version + if (bTrialTimerDisplayed) { + ui.ShowTrialTimer(false); + bTrialTimerDisplayed = false; + } + } - // PS3 DLC - app.CommerceTick(); + // PS3 DLC + app.CommerceTick(); - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); - } + // Fix for #7318 - Title crashes after short soak in the leaderboards + // menu A memory leak was caused because the icon renderer kept creating + // new Vec3's because the pool wasn't reset + Vec3::resetPool(); + } - // Free resources, unregister custom classes, and exit. -// app.Uninit(); -// g_pd3dDevice->Release(); + // Free resources, unregister custom classes, and exit. + // app.Uninit(); + // g_pd3dDevice->Release(); #if HEAPINSPECTOR_PS3 - HeapInspectorServer::Shutdown(); -#endif // HEAPINSPECTOR_PS3 + HeapInspectorServer::Shutdown(); +#endif // HEAPINSPECTOR_PS3 - ShutdownManager::MainThreadHandleShutdown(); + ShutdownManager::MainThreadHandleShutdown(); } -std::vector vRichPresenceStrings; -uint8_t * AddRichPresenceString(int iID) -{ - uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) - { - vRichPresenceStrings.push_back(strUtf8); - } - return strUtf8; +std::vector vRichPresenceStrings; +uint8_t* AddRichPresenceString(int iID) { + uint8_t* strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); + if (strUtf8 != NULL) { + vRichPresenceStrings.push_back(strUtf8); + } + return strUtf8; } -void FreeRichPresenceStrings() -{ - uint8_t *strUtf8; - for(int i=0;i allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -1397,181 +1591,161 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } - - LeaveCriticalSection(&memCS); + trackEnable = true; + } + } - return p; + LeaveCriticalSection(&memCS); + + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes -) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } -void DumpMem() -{ - int totalLeak = 0; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 46; +void MemPixStuff() { + const int MAX_SECT = 46; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } #endif -#endif // __PS3__ \ No newline at end of file +#endif // __PS3__ diff --git a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp index 749111847..fb8e88016 100644 --- a/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp +++ b/Minecraft.Client/Platform/PS3/Xbox_Minecraft.cpp @@ -26,30 +26,31 @@ #include "../../../Minecraft.World/Util/ThreadName.h" #include "../../GameState/StatsCounter.h" #include "../../UI/Screens/ConnectScreen.h" -//#include "Social/SocialManager.h" -//#include "../Common/Leaderboards/LeaderboardManager.h" -//#include "../Common/XUI/XUI_Scene_Container.h" -//#include "QNetManager.h" +// #include "Social/SocialManager.h" +// #include "../Common/Leaderboards/LeaderboardManager.h" +// #include "../Common/XUI/XUI_Scene_Container.h" +// #include "QNetManager.h" #include "../../Rendering/Tesselator.h" #include "Xbox_Awards_enum.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "Resource.h" +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 - -//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) -//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) -//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) +// #define THREE_MB 3145728 // minimum save size (checking for this on a +// selected device) #define FIVE_MB 5242880 // minimum save size (checking for +// this on a selected device) #define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR +// space required for a save (checking for this on a selected device) +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) #if 0 //#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= { @@ -62,17 +63,15 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= #endif //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- - BOOL g_bWidescreen = TRUE; - -void DefineActions(void) -{ +void DefineActions(void) { #if 0 // The app needs to define the actions required, and the possible mappings for these @@ -113,11 +112,11 @@ void DefineActions(void) InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B); @@ -194,7 +193,7 @@ void DefineActions(void) } #if 0 -HRESULT InitD3D( IDirect3DDevice9 **ppDevice, +HRESULT InitD3D( IDirect3DDevice9 **ppDevice, D3DPRESENT_PARAMETERS *pd3dPP ) { IDirect3D9 *pD3D; @@ -221,14 +220,14 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, //pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; //ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled // in the launcher/dashboard. - if(g_bWidescreen) + if(g_bWidescreen) pd3dPP->Flags=0; - else + else pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; // Create the device. return pD3D->CreateDevice( - 0, + 0, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, @@ -236,25 +235,23 @@ HRESULT InitD3D( IDirect3DDevice9 **ppDevice, ppDevice ); } #endif -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif -HINSTANCE g_hInst = NULL; -HWND g_hWnd = NULL; -D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; -D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; -ID3D11Device* g_pd3dDevice = NULL; -ID3D11DeviceContext* g_pImmediateContext = NULL; -IDXGISwapChain* g_pSwapChain = NULL; +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; +D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; +D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; +ID3D11Device* g_pd3dDevice = NULL; +ID3D11DeviceContext* g_pImmediateContext = NULL; +IDXGISwapChain* g_pSwapChain = NULL; ID3D11RenderTargetView* g_pRenderTargetView = NULL; // @@ -267,66 +264,62 @@ ID3D11RenderTargetView* g_pRenderTargetView = NULL; // WM_DESTROY - post a quit message and return // // -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, + LPARAM lParam) { + int wmId, wmEvent; + PAINTSTRUCT ps; + HDC hdc; - switch (message) - { - case WM_COMMAND: - wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); - // Parse the menu selections: - switch (wmId) - { - case IDM_EXIT: - DestroyWindow(hWnd); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - break; - case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); - // TODO: Add any drawing code here... - EndPaint(hWnd, &ps); - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - return 0; + switch (message) { + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + // Parse the menu selections: + switch (wmId) { + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + // TODO: Add any drawing code here... + EndPaint(hWnd, &ps); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; } - // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // -ATOM MyRegisterClass(HINSTANCE hInstance) -{ - WNDCLASSEX wcex; +ATOM MyRegisterClass(HINSTANCE hInstance) { + WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); + wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIcon(hInstance, "Minecraft"); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wcex.lpszMenuName = "Minecraft"; - wcex.lpszClassName = "MinecraftClass"; - wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, "Minecraft"); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wcex.lpszMenuName = "Minecraft"; + wcex.lpszClassName = "MinecraftClass"; + wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); - return RegisterClassEx(&wcex); + return RegisterClassEx(&wcex); } // @@ -339,34 +332,31 @@ ATOM MyRegisterClass(HINSTANCE hInstance) // In this function, we save the instance handle in a global variable and // create and display the main program window. // -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) -{ - g_hInst = hInstance; // Store instance handle in our global variable +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { + g_hInst = hInstance; // Store instance handle in our global variable - g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + g_hWnd = CreateWindow("MinecraftClass", "Minecraft", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, + hInstance, NULL); - if (!g_hWnd) - { - return FALSE; - } + if (!g_hWnd) { + return FALSE; + } - ShowWindow(g_hWnd, nCmdShow); - UpdateWindow(g_hWnd); + ShowWindow(g_hWnd, nCmdShow); + UpdateWindow(g_hWnd); - return TRUE; + return TRUE; } - //-------------------------------------------------------------------------------------- // Create Direct3D device and swap chain //-------------------------------------------------------------------------------------- -HRESULT InitDevice() -{ +HRESULT InitDevice() { HRESULT hr = S_OK; RECT rc; - GetClientRect( g_hWnd, &rc ); + GetClientRect(g_hWnd, &rc); UINT width = rc.right - rc.left; UINT height = rc.bottom - rc.top; @@ -375,24 +365,22 @@ HRESULT InitDevice() createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif - D3D_DRIVER_TYPE driverTypes[] = - { + D3D_DRIVER_TYPE driverTypes[] = { D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP, D3D_DRIVER_TYPE_REFERENCE, }; - UINT numDriverTypes = ARRAYSIZE( driverTypes ); + UINT numDriverTypes = ARRAYSIZE(driverTypes); - D3D_FEATURE_LEVEL featureLevels[] = - { + D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0, }; - UINT numFeatureLevels = ARRAYSIZE( featureLevels ); + UINT numFeatureLevels = ARRAYSIZE(featureLevels); DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory( &sd, sizeof( sd ) ); + ZeroMemory(&sd, sizeof(sd)); sd.BufferCount = 1; sd.BufferDesc.Width = width; sd.BufferDesc.Height = height; @@ -405,29 +393,29 @@ HRESULT InitDevice() sd.SampleDesc.Quality = 0; sd.Windowed = TRUE; - for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) - { + for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; + driverTypeIndex++) { g_driverType = driverTypes[driverTypeIndex]; - hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, - D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); - if( SUCCEEDED( hr ) ) - break; + hr = D3D11CreateDeviceAndSwapChain( + NULL, g_driverType, NULL, createDeviceFlags, featureLevels, + numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, + &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); + if (SUCCEEDED(hr)) break; } - if( FAILED( hr ) ) - return hr; + if (FAILED(hr)) return hr; // Create a render target view ID3D11Texture2D* pBackBuffer = NULL; - hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); - if( FAILED( hr ) ) - return hr; + hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), + (LPVOID*)&pBackBuffer); + if (FAILED(hr)) return hr; - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); + hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, + &g_pRenderTargetView); pBackBuffer->Release(); - if( FAILED( hr ) ) - return hr; + if (FAILED(hr)) return hr; - g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL ); + g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, NULL); // Setup the viewport D3D11_VIEWPORT vp; @@ -437,59 +425,51 @@ HRESULT InitDevice() vp.MaxDepth = 1.0f; vp.TopLeftX = 0; vp.TopLeftY = 0; - g_pImmediateContext->RSSetViewports( 1, &vp ); + g_pImmediateContext->RSSetViewports(1, &vp); - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); return S_OK; } - //-------------------------------------------------------------------------------------- // Render the frame //-------------------------------------------------------------------------------------- -void Render() -{ +void Render() { // Just clear the backbuffer - float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha + float ClearColor[4] = {0.0f, 0.125f, 0.3f, 1.0f}; // red,green,blue,alpha - g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor ); - g_pSwapChain->Present( 0, 0 ); + g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor); + g_pSwapChain->Present(0, 0); } - //-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- -void CleanupDevice() -{ - if( g_pImmediateContext ) g_pImmediateContext->ClearState(); +void CleanupDevice() { + if (g_pImmediateContext) g_pImmediateContext->ClearState(); - if( g_pRenderTargetView ) g_pRenderTargetView->Release(); - if( g_pSwapChain ) g_pSwapChain->Release(); - if( g_pImmediateContext ) g_pImmediateContext->Release(); - if( g_pd3dDevice ) g_pd3dDevice->Release(); + if (g_pRenderTargetView) g_pRenderTargetView->Release(); + if (g_pSwapChain) g_pSwapChain->Release(); + if (g_pImmediateContext) g_pImmediateContext->Release(); + if (g_pd3dDevice) g_pd3dDevice->Release(); } int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPTSTR lpCmdLine, - _In_ int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); + _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, + _In_ int nCmdShow) { + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); - // Initialize global strings - MyRegisterClass(hInstance); + // Initialize global strings + MyRegisterClass(hInstance); - // Perform application initialization: - if (!InitInstance (hInstance, nCmdShow)) - { - return FALSE; - } + // Perform application initialization: + if (!InitInstance(hInstance, nCmdShow)) { + return FALSE; + } - if( FAILED( InitDevice() ) ) - { + if (FAILED(InitDevice())) { CleanupDevice(); return 0; } @@ -513,13 +493,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, return (int) msg.wParam; #endif - static bool bTrialTimerDisplayed=true; + static bool bTrialTimerDisplayed = true; #ifdef MEMORY_TRACKING - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); #endif #if 0 @@ -534,24 +515,23 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } // Initialize the application, assuming sharing of the d3d interface. - hr = app.InitShared( pDevice, &d3dpp, + hr = app.InitShared( pDevice, &d3dpp, XuiPNGTextureLoader ); if ( FAILED(hr) ) { app.DebugPrintf ( "Failed initializing application.\n" ); - + return -1; } - - -#endif - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); - //////////////// - // Initialise // - //////////////// +#endif + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + + //////////////// + // Initialise // + //////////////// #if 0 // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params @@ -641,7 +621,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // set a function to be called when the ethernet is disconnected, so we can back out if required ProfileManager.SetNotificationsCallback(&CXboxMinecraftApp::NotificationsCallback,(LPVOID)&app); - + // Set a callback for the default player options to be set - when there is no profile data for the player ProfileManager.SetDefaultOptionsCallback(&CXboxMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); // Set a callback to deal with old profile versions needing updated to new versions @@ -668,27 +648,24 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, if(XNuiGetHardwareStatus()!=0) { - // If the Kinect Sensor is not physically connected, this function returns 0. - NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | + // If the Kinect Sensor is not physically connected, this function returns 0. + NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED | NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD ); } // Sentient ! - hr = SentientManager.Init(); - + hr = SentientManager.Init(); #endif - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - Level::enableLightingCache(); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + Level::enableLightingCache(); - - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); #if 0 //bool bDisplayPauseMenu=false; @@ -722,11 +699,9 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, DWORD initData=0; - - #ifndef _FINAL_BUILD #ifndef _DEBUG - #pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission") #endif #endif @@ -738,7 +713,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, app.NavigateToScene(XUSER_INDEX_ANY,CXboxMinecraftApp::e_xuiScene_Intro,&initData); #endif - //Sleep(10000); + // Sleep(10000); #if 0 // Intro loop ? while(app.IntroRunning()) @@ -762,8 +737,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } #endif - while( TRUE ) - { + while (TRUE) { #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -773,81 +747,79 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); } #endif - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); -// InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); -// ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); -// StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + // InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + // ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + // StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); -// CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); - - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); -// SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Qnet do work #1"); -// g_qNetManager.DoWork(); - PIXEndNamedEvent(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); -// LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_qNetManager.IsLocalGame() && g_qNetManager.GetPlayerCount() == 1 && app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->update(NULL, 0.0f); - MemSect(0); - pMinecraft->soundEngine->playMusicTick(); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - app.SetGameStarted(true); - } + PIXBeginNamedEvent(0, "Qnet do work #1"); + // g_qNetManager.DoWork(); + PIXEndNamedEvent(); - app.ToggleDimensionIfRequested(); + // LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_qNetManager.IsLocalGame() && + g_qNetManager.GetPlayerCount() == 1 && + app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->update(NULL, 0.0f); + MemSect(0); + pMinecraft->soundEngine->playMusicTick(); + pMinecraft->textures->tick(true, false); + app.SetGameStarted(true); + } + app.ToggleDimensionIfRequested(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -880,7 +852,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, for(int i=0;i<8;i++) { - if(RenderStateA2[i]!=RenderStateA[i]) + if(RenderStateA2[i]!=RenderStateA[i]) { //printf("Reseting RenderStateA[%d] after a XUI render\n",i); pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); @@ -888,7 +860,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } for(int i=0;i<5;i++) { - if(SamplerStateA2[i]!=SamplerStateA[i]) + if(SamplerStateA2[i]!=SamplerStateA[i]) { //printf("Reseting SamplerStateA[%d] after a XUI render\n",i); pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); @@ -897,10 +869,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, RenderManager.Set_matrixDirty(); #endif - // Present the frame. - PIXBeginNamedEvent(0,"Frame present"); - RenderManager.Present(); - PIXEndNamedEvent(); + // Present the frame. + PIXBeginNamedEvent(0, "Frame present"); + RenderManager.Present(); + PIXEndNamedEvent(); #if 0 app.CheckMenuDisplayed(); PIXBeginNamedEvent(0,"Profile load check"); @@ -922,7 +894,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, #ifdef _DEBUG_MENUS_ENABLED if(app.DebugSettingsOn()) { - app.ActionDebugMask(i); + app.ActionDebugMask(i); } else { @@ -967,7 +939,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, if(!ProfileManager.IsFullVersion()) { // display the trial timer - if(app.GetGameStarted()) + if(app.GetGameStarted()) { // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down if(app.IsAppPaused()) @@ -988,21 +960,21 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } #endif - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); - } + // Fix for #7318 - Title crashes after short soak in the leaderboards + // menu A memory leak was caused because the icon renderer kept creating + // new Vec3's because the pool wasn't reset + Vec3::resetPool(); + } - // Free resources, unregister custom classes, and exit. -// app.Uninit(); - g_pd3dDevice->Release(); + // Free resources, unregister custom classes, and exit. + // app.Uninit(); + g_pd3dDevice->Release(); } - #ifdef MEMORY_TRACKING int totalAllocGen = 0; -std::unordered_map allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -1011,181 +983,159 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } - - LeaveCriticalSection(&memCS); + trackEnable = true; + } + } - return p; + LeaveCriticalSection(&memCS); + + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes -) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } - -void DumpMem() -{ - int totalLeak = 0; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 46; +void MemPixStuff() { + const int MAX_SECT = 46; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } #endif diff --git a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp index 56db1f465..1ee98dd99 100644 --- a/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp +++ b/Minecraft.Client/Platform/PSVita/PSVita_Minecraft.cpp @@ -6,16 +6,17 @@ #include "Leaderboards/PSVitaLeaderboardManager.h" #include "PSVitaExtras/ShutdownManager.h" -//#define HEAPINSPECTOR_PS3 1 -// when defining HEAPINSPECTOR_PS3, add this line to the linker settings -// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc --wrap reallocalign --wrap _malloc_init +// #define HEAPINSPECTOR_PS3 1 +// when defining HEAPINSPECTOR_PS3, add this line to the linker settings +// --wrap malloc --wrap free --wrap memalign --wrap calloc --wrap realloc +// --wrap reallocalign --wrap _malloc_init #if HEAPINSPECTOR_PS3 #include "../PS3/PS3Extras/HeapInspector/Server/HeapInspectorServer.h" #include "../PS3/PS3Extras/HeapInspector/Server/PS3/HeapHooks.hpp" #endif -//#define DISABLE_MILES_SOUND +// #define DISABLE_MILES_SOUND #include "PSVita_App.h" #include "PSVitaExtras/PSVitaStrings.h" @@ -39,20 +40,19 @@ #include "../../../Minecraft.World/Util/ThreadName.h" #include "../../GameState/StatsCounter.h" #include "../../UI/Screens/ConnectScreen.h" -//#include "Social/SocialManager.h" -//#include "../Common/Leaderboards/LeaderboardManager.h" -//#include "../Common/XUI/XUI_Scene_Container.h" -//#include "NetworkManager.h" +// #include "Social/SocialManager.h" +// #include "../Common/Leaderboards/LeaderboardManager.h" +// #include "../Common/XUI/XUI_Scene_Container.h" +// #include "NetworkManager.h" #include "../../Rendering/Tesselator.h" #include "../Common/Console_Awards_enum.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" -//#include "../Durango/Resource.h" +// #include "../Durango/Resource.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" #include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h" -//#include "../PS3/PS3Extras/EdgeZLib.h" +// #include "../PS3/PS3Extras/EdgeZLib.h" #include "../../../Minecraft.World/Util/C4JThread.h" #include "../Common/Network/Sony/SQRNetworkManager.h" #include "../Common/UI/IUIScene_PauseMenu.h" @@ -65,11 +65,11 @@ #include #include -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 /* Encrypted ID for protected data file (*) You must edit these binaries!! */ -/*char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = +/*char secureFileId[CELL_SAVEDATA_SECUREFILEID_SIZE] = { 0xEE, 0xA9, 0x37, 0xCC, 0x5B, 0xD4, 0xD9, 0x0D, @@ -77,291 +77,437 @@ 0xFA, 0x33, 0xBD, 0xC4 };*/ +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) - -//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +// #define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 -DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= -{ +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES] = { #ifdef _XBOX - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, #else - 0,0,0,0,0 + 0, 0, 0, 0, 0 #endif }; // functions for storing and converting rich presence strings from wchar to utf8 -uint8_t * AddRichPresenceString(int iID); +uint8_t* AddRichPresenceString(int iID); void FreeRichPresenceStrings(); #if HEAPINSPECTOR_PS3 -std::vector GetHeapInfo() -{ - std::vector result = HeapInspectorServer::GetDefaultHeapInfo(); - HeapInspectorServer::HeapInfo localHeapInfo; - localHeapInfo.m_Description = "VRAM"; - localHeapInfo.m_Range.m_Min = 0xc0000000; - localHeapInfo.m_Range.m_Max = localHeapInfo.m_Range.m_Min + (249*1024*1024); - result.push_back(localHeapInfo); - return result; +std::vector GetHeapInfo() { + std::vector result = + HeapInspectorServer::GetDefaultHeapInfo(); + HeapInspectorServer::HeapInfo localHeapInfo; + localHeapInfo.m_Description = "VRAM"; + localHeapInfo.m_Range.m_Min = 0xc0000000; + localHeapInfo.m_Range.m_Max = + localHeapInfo.m_Range.m_Min + (249 * 1024 * 1024); + result.push_back(localHeapInfo); + return result; } extern "C" void* __real__malloc_init(size_t a_Boundary, size_t a_Size); -extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size) -{ - void* result = __real__malloc_init(a_Boundary, a_Size); - HeapInspectorServer::Initialise(GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); - return result; +extern "C" void* __wrap__malloc_init(size_t a_Boundary, size_t a_Size) { + void* result = __real__malloc_init(a_Boundary, a_Size); + HeapInspectorServer::Initialise( + GetHeapInfo(), 3000, HeapInspectorServer::WaitForConnection_Enabled); + return result; } -#endif // HEAPINSPECTOR_PS3 +#endif // HEAPINSPECTOR_PS3 //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- BOOL g_bWidescreen = TRUE; -//int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, this is setup from init_audio_hardware +// int g_numberOfSpeakersForMiles = 2; // number of speakers to pass to Miles, +// this is setup from init_audio_hardware -void DefineActions(void) -{ - // The app needs to define the actions required, and the possible mappings for these +void DefineActions(void) { + // The app needs to define the actions required, and the possible mappings + // for these - ///////////////////////////////////// - // VITA - ///////////////////////////////////// + ///////////////////////////////////// + // VITA + ///////////////////////////////////// - // Split into Menu actions, and in-game actions - if(InputManager.IsCircleCrossSwapped()) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PSV_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PSV_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PSV_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PSV_JOY_BUTTON_X); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _PSV_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _PSV_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _PSV_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _PSV_JOY_BUTTON_O); - } + // Split into Menu actions, and in-game actions + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _PSV_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _PSV_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _PSV_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _PSV_JOY_BUTTON_X); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _PSV_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _PSV_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _PSV_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _PSV_JOY_BUTTON_O); + } - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _PSV_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _PSV_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _PSV_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _PSV_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _PSV_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _PSV_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _PSV_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _PSV_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _PSV_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_X, + _PSV_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_Y, + _PSV_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_UP, + _PSV_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_DOWN, + _PSV_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_LEFT, + _PSV_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_RIGHT, + _PSV_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_RIGHT_SCROLL, + _PSV_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_LEFT_SCROLL, + _PSV_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAUSEMENU, + _PSV_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _PSV_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_STICK_PRESS, + _PSV_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _PSV_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_JUMP, + _PSV_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _PSV_JOY_BUTTON_L1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _PSV_JOY_BUTTON_R1); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _PSV_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _PSV_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _PSV_JOY_BUTTON_TRIANGLE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _PSV_JOY_BUTTON_O); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _PSV_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _PSV_JOY_BUTTON_SQUARE); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _PSV_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_USE, + _PSV_JOY_BUTTON_L1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_ACTION, + _PSV_JOY_BUTTON_R1); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT_SCROLL, + _PSV_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT_SCROLL, + _PSV_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_INVENTORY, + _PSV_JOY_BUTTON_TRIANGLE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DROP, + _PSV_JOY_BUTTON_O); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_SNEAK_TOGGLE, + _PSV_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_CRAFTING, + _PSV_JOY_BUTTON_SQUARE); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _PSV_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _PSV_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _PSV_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _PSV_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _PSV_JOY_BUTTON_DPAD_DOWN); - ///////////////////////////////////// - // VITA TV (Dualshock 3/4 mapping) - ///////////////////////////////////// + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_LEFT, + _PSV_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_RIGHT, + _PSV_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_UP, + _PSV_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_DOWN, + _PSV_JOY_BUTTON_DPAD_DOWN); + ///////////////////////////////////// + // VITA TV (Dualshock 3/4 mapping) + ///////////////////////////////////// - // Note: this is mapping 0 from the PS3 version + // Note: this is mapping 0 from the PS3 version - // Split into Menu actions, and in-game actions - if(InputManager.IsCircleCrossSwapped() ) - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_A); - } - else - { - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - } + // Split into Menu actions, and in-game actions + if (InputManager.IsCircleCrossSwapped()) { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_A); + } else { + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + } - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); + + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); } - -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif - -void debugSaveGameDirect() -{ - - C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, NULL, "debugSaveGameDirect"); - thread->Run(); - thread->WaitForCompletion(1000); +void debugSaveGameDirect() { + C4JThread* thread = new C4JThread(&IUIScene_PauseMenu::SaveWorldThreadProc, + NULL, "debugSaveGameDirect"); + thread->Run(); + thread->WaitForCompletion(1000); } -int simpleMessageBoxCallback( UINT uiTitle, UINT uiText, - UINT *uiOptionA, UINT uiOptionC, DWORD dwPad, - int(*Func) (LPVOID,int,const C4JStorage::EMessageResult), - LPVOID lpParam ) -{ - ui.RequestMessageBox( uiTitle, uiText, - uiOptionA, uiOptionC, dwPad, - Func, lpParam, app.GetStringTable(), - NULL, 0 - ); +int simpleMessageBoxCallback(UINT uiTitle, UINT uiText, UINT* uiOptionA, + UINT uiOptionC, DWORD dwPad, + int (*Func)(LPVOID, int, + const C4JStorage::EMessageResult), + LPVOID lpParam) { + ui.RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, + lpParam, app.GetStringTable(), NULL, 0); - return 0; + return 0; } -void RegisterAwardsWithProfileManager() -{ - // register the awards - ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); +void RegisterAwardsWithProfileManager() { + // register the awards + ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, + eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, eAwardType_Achievement); // 'Sniper Duel' - ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, eAwardType_Achievement); // 'DIAMONDS!' - ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, eAwardType_Achievement); // 'Return To Sender' - ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, eAwardType_Achievement); // 'Into Fire' - ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, eAwardType_Achievement); // 'Local Brewery' - ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, eAwardType_Achievement); // 'The End?' - ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, eAwardType_Achievement); // 'The End.' - ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, eAwardType_Achievement); // 'Enchanter' + ProfileManager.RegisterAward(eAward_snipeSkeleton, ACHIEVEMENT_21, + eAwardType_Achievement); // 'Sniper Duel' + ProfileManager.RegisterAward(eAward_diamonds, ACHIEVEMENT_22, + eAwardType_Achievement); // 'DIAMONDS!' + ProfileManager.RegisterAward(eAward_ghast, ACHIEVEMENT_23, + eAwardType_Achievement); // 'Return To Sender' + ProfileManager.RegisterAward(eAward_blazeRod, ACHIEVEMENT_24, + eAwardType_Achievement); // 'Into Fire' + ProfileManager.RegisterAward(eAward_potion, ACHIEVEMENT_25, + eAwardType_Achievement); // 'Local Brewery' + ProfileManager.RegisterAward(eAward_theEnd, ACHIEVEMENT_26, + eAwardType_Achievement); // 'The End?' + ProfileManager.RegisterAward(eAward_winGame, ACHIEVEMENT_27, + eAwardType_Achievement); // 'The End.' + ProfileManager.RegisterAward(eAward_enchantments, ACHIEVEMENT_28, + eAwardType_Achievement); // 'Enchanter' #ifdef _EXTENDED_ACHIEVEMENTS - ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_overkill, ACHIEVEMENT_29, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bookcase, ACHIEVEMENT_30, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_adventuringTime, ACHIEVEMENT_31, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_repopulation, ACHIEVEMENT_32, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_diamondsToYou, ACHIEVEMENT_33, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_eatPorkChop, ACHIEVEMENT_34, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_play100Days, ACHIEVEMENT_35, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_arrowKillCreeper, ACHIEVEMENT_36, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_theHaggler, ACHIEVEMENT_37, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_potPlanter, ACHIEVEMENT_38, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_itsASign, ACHIEVEMENT_39, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironBelly, ACHIEVEMENT_40, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_haveAShearfulDay, ACHIEVEMENT_41, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_rainbowCollection, ACHIEVEMENT_42, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_stayinFrosty, ACHIEVEMENT_43, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_chestfulOfCobblestone, ACHIEVEMENT_44, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_renewableEnergy, ACHIEVEMENT_45, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_musicToMyEars, ACHIEVEMENT_46, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_bodyGuard, ACHIEVEMENT_47, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_ironMan, ACHIEVEMENT_48, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_zombieDoctor, ACHIEVEMENT_49, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_lionTamer, ACHIEVEMENT_50, + eAwardType_Achievement); #endif #if 0 @@ -374,298 +520,360 @@ void RegisterAwardsWithProfileManager() ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); #endif - // Rich Presence init - number of presences, number of contexts - //printf("Rich presence strings are hard coded on PS3 for now, must change this!\n"); - ProfileManager.RichPresenceInit(4,1); + // Rich Presence init - number of presences, number of contexts + // printf("Rich presence strings are hard coded on PS3 for now, must change + // this!\n"); + ProfileManager.RichPresenceInit(4, 1); - //Chris TODO - ProfileManager.SetRichPresenceSettingFn(SQRNetworkManager_Vita::SetRichPresence); - char *pchRichPresenceString; + // Chris TODO + ProfileManager.SetRichPresenceSettingFn( + SQRNetworkManager_Vita::SetRichPresence); + char* pchRichPresenceString; - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); - ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); - ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_GAMESTATE); + ProfileManager.RichPresenceRegisterContext(CONTEXT_GAME_STATE, + pchRichPresenceString); + pchRichPresenceString = (char*)AddRichPresenceString(IDS_RICHPRESENCE_IDLE); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_IDLE, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MENUS); + ProfileManager.RichPresenceRegisterPresenceString(CONTEXT_PRESENCE_MENUS, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYEROFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYEROFFLINE, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1P); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1P, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCE_MULTIPLAYER_1POFFLINE); + ProfileManager.RichPresenceRegisterPresenceString( + CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); - - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); - pchRichPresenceString=(char *)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); - ProfileManager.RichPresenceRegisterContextString(CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BLANK); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BLANK, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_PIG); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_PIG, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_RIDING_MINECART); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_RIDING_MINECART, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BOATING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BOATING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FISHING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FISHING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CRAFTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CRAFTING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_FORGING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_FORGING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_NETHER); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_NETHER, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_CD); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_CD, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_MAP); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_MAP, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ENCHANTING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ENCHANTING, + pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_BREWING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_BREWING, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_ANVIL); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_ANVIL, pchRichPresenceString); + pchRichPresenceString = + (char*)AddRichPresenceString(IDS_RICHPRESENCESTATE_TRADING); + ProfileManager.RichPresenceRegisterContextString( + CONTEXT_GAME_STATE, CONTEXT_GAME_STATE_TRADING, pchRichPresenceString); } - - -void LoadSysModule(uint16_t module, const char* moduleName) -{ - int ret = sceSysmoduleLoadModule(module); - if(ret != SCE_OK) - { +void LoadSysModule(uint16_t module, const char* moduleName) { + int ret = sceSysmoduleLoadModule(module); + if (ret != SCE_OK) { #ifndef _CONTENT_PACKAGE - printf("Error sceSysmoduleLoadModule %s failed (%d) \n", moduleName, ret ); + printf("Error sceSysmoduleLoadModule %s failed (%d) \n", moduleName, + ret); #endif - assert(0); - } + assert(0); + } } #define LOAD_PSVITA_MODULE(m) LoadSysModule(m, #m) +int LoadSysModules() { + // LOAD_PSVITA_MODULE(SCE_SYSMODULE_PERF); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_ULT); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_RUDP); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_MATCHING2); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_PSPNET_ADHOC); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET_ADHOC_MATCHING); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTP); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTPS); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_COMMERCE2); + LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_SCORE_RANKING); -int LoadSysModules() -{ - // LOAD_PSVITA_MODULE(SCE_SYSMODULE_PERF); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_ULT); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_RUDP); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_MATCHING2); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_PSPNET_ADHOC); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_NET_ADHOC_MATCHING); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTP); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_HTTPS); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_COMMERCE2); - LOAD_PSVITA_MODULE(SCE_SYSMODULE_NP_SCORE_RANKING); - - return 0; + return 0; } +int main() { + // int* a = new int(5); -int main() -{ - //int* a = new int(5); + PSVitaInit(); - PSVitaInit(); + ShutdownManager::Initialise(); - ShutdownManager::Initialise(); - - SceKernelFreeMemorySizeInfo mem_info; - mem_info.size = sizeof(SceKernelFreeMemorySizeInfo); - int Err = sceKernelGetFreeMemorySize(&mem_info); + SceKernelFreeMemorySizeInfo mem_info; + mem_info.size = sizeof(SceKernelFreeMemorySizeInfo); + int Err = sceKernelGetFreeMemorySize(&mem_info); #ifndef _CONTENT_PACKAGE - printf("------------------------------------------------------\n"); - printf("------------------------------------------------------\n"); - // printf("total_user_memory : %.02f\n", mem_info.total_user_memory / (1024.0f*1024.0f)); - printf("available_user_memory : %.02f\n", mem_info.sizeMain / (1024.0f*1024.0f)); - printf("available_video_memory : %.02f\n", mem_info.sizeCdram / (1024.0f*1024.0f)); - printf("------------------------------------------------------\n"); - printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); + // printf("total_user_memory : %.02f\n", mem_info.total_user_memory / + //(1024.0f*1024.0f)); + printf("available_user_memory : %.02f\n", + mem_info.sizeMain / (1024.0f * 1024.0f)); + printf("available_video_memory : %.02f\n", + mem_info.sizeCdram / (1024.0f * 1024.0f)); + printf("------------------------------------------------------\n"); + printf("------------------------------------------------------\n"); #endif - // - // initialize the Vita - // + // + // initialize the Vita + // - int ihddFreeSizeKB=LoadSysModules(); + int ihddFreeSizeKB = LoadSysModules(); - /* Set the parameters to be passed to initialization function sceAppUtilInit() */ - SceAppUtilInitParam initParam; - SceAppUtilBootParam bootParam; - memset(&initParam, 0, sizeof(SceAppUtilInitParam)); - memset(&bootParam, 0, sizeof(SceAppUtilBootParam)); + /* Set the parameters to be passed to initialization function + * sceAppUtilInit() */ + SceAppUtilInitParam initParam; + SceAppUtilBootParam bootParam; + memset(&initParam, 0, sizeof(SceAppUtilInitParam)); + memset(&bootParam, 0, sizeof(SceAppUtilBootParam)); - /* Initialize the library */ - SceInt32 ret = sceAppUtilInit( &initParam, &bootParam ); + /* Initialize the library */ + SceInt32 ret = sceAppUtilInit(&initParam, &bootParam); + static bool bTrialTimerDisplayed = true; + // 4J-JEV: Moved this here in case some archived files are compressed. + // Compression::CreateNewThreadStorage(); - static bool bTrialTimerDisplayed=true; + app.loadMediaArchive(); + RenderManager.Initialise(NULL, NULL); - // 4J-JEV: Moved this here in case some archived files are compressed. - // Compression::CreateNewThreadStorage(); + // Read the file containing the product codes + if (app.ReadProductCodes() == FALSE) { + // can't continue + app.FatalLoadError(); + } - app.loadMediaArchive(); - RenderManager.Initialise(NULL, NULL); + app.InitTime(); + PSVitaNPToolkit::init(); - // Read the file containing the product codes - if(app.ReadProductCodes()==FALSE) - { - // can't continue - app.FatalLoadError(); - } + // initialise the storage manager with a default save display name, a + // Minimum save size, and a callback for displaying the saving message + StorageManager.Init(0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, + &CConsoleMinecraftApp::DisplaySavingMessage, + (LPVOID)&app, NULL); + StorageManager.SetDLCProductCode(app.GetProductCode()); + StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); + ProfileManager.SetServiceID(app.GetCommerceCategory()); - app.InitTime(); - PSVitaNPToolkit::init(); + bool bCircleCrossSwapped = false; + switch (app.GetProductSKU()) { + case e_sku_SCEE: + // 4J-PB - need to be online to do this check, so let's stick with + // the 7+, and move this + /*if(StorageManager.GetBootTypeDisc()) + {*/ + // set Europe age, then hone down specific countries + ProfileManager.SetMinimumAge(7, 0); // PEGI 7+ + ProfileManager.SetGermanyMinimumAge(6); // USK 6+ + ProfileManager.SetAustraliaMinimumAge( + 8); // PG rating has no age, but for some reason the testers + // are saying it's 8 + ProfileManager.SetRussiaMinimumAge(6); + ProfileManager.SetKoreaMinimumAge(0); + ProfileManager.SetJapanMinimumAge(0); + /*} + else + { + // PEGI 7+ + ProfileManager.SetMinimumAge(7,0); + }*/ + break; + case e_sku_SCEA: + // ESRB EVERYONE 10+ + ProfileManager.SetMinimumAge(10, 1); + break; + case e_sku_SCEJ: + // CERO A + ProfileManager.SetMinimumAge(0, 2); + bCircleCrossSwapped = true; + break; + } - // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init( 0, L"savegame.dat", "savePackName", FIFTY_ONE_MB, &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, NULL); - StorageManager.SetDLCProductCode(app.GetProductCode()); - StorageManager.SetProductUpgradeKey(app.GetUpgradeKey()); - ProfileManager.SetServiceID(app.GetCommerceCategory()); + InputManager.SetCircleCrossSwapped(bCircleCrossSwapped); - bool bCircleCrossSwapped = false; - switch(app.GetProductSKU()) - { - case e_sku_SCEE: - // 4J-PB - need to be online to do this check, so let's stick with the 7+, and move this - /*if(StorageManager.GetBootTypeDisc()) - {*/ - // set Europe age, then hone down specific countries - ProfileManager.SetMinimumAge(7,0); // PEGI 7+ - ProfileManager.SetGermanyMinimumAge(6); // USK 6+ - ProfileManager.SetAustraliaMinimumAge(8); // PG rating has no age, but for some reason the testers are saying it's 8 - ProfileManager.SetRussiaMinimumAge(6); - ProfileManager.SetKoreaMinimumAge(0); - ProfileManager.SetJapanMinimumAge(0); - /*} - else - { - // PEGI 7+ - ProfileManager.SetMinimumAge(7,0); - }*/ - break; - case e_sku_SCEA: - // ESRB EVERYONE 10+ - ProfileManager.SetMinimumAge(10,1); - break; - case e_sku_SCEJ: - // CERO A - ProfileManager.SetMinimumAge(0,2); - bCircleCrossSwapped = true; - break; - } + app.loadStringTable(); - InputManager.SetCircleCrossSwapped(bCircleCrossSwapped); + // Vita + // g_iScreenWidth = 720; + // g_iScreenHeight = 408; - app.loadStringTable(); + // Vita native + // g_iScreenWidth = 960; + // g_iScreenHeight = 544; + ui.init(720, 408); - // Vita - //g_iScreenWidth = 720; - //g_iScreenHeight = 408; + //////////////// + // Initialise // + //////////////// - // Vita native - //g_iScreenWidth = 960; - //g_iScreenHeight = 544; - ui.init(720, 408); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions + InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - //////////////// - // Initialise // - //////////////// + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + // Minimum age must be set prior to profile init - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + ProfileManager.Initialise( + s_npCommunicationConfig, + app.GetCommerceCategory(), // s_serviceId, + PROFILE_VERSION_BUILD_JUNE14, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - //Minimum age must be set prior to profile init + // register the awards + RegisterAwardsWithProfileManager(); - ProfileManager.Initialise( - s_npCommunicationConfig, - app.GetCommerceCategory(),// s_serviceId, - PROFILE_VERSION_BUILD_JUNE14, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); + // register the get string function with the profile lib, so it can be + // called within the lib + ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); + ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); + // defaults + StorageManager.ResetSaveData(); + StorageManager.SetSaveTitle(L"Default Save"); + StorageManager.SetGameSaveFolderTitle((WCHAR*)app.GetString(IDS_GAMENAME)); + StorageManager.SetSaveCacheFolderTitle( + (WCHAR*)app.GetString(IDS_SAVECACHEFILE)); + StorageManager.SetOptionsFolderTitle( + (WCHAR*)app.GetString(IDS_OPTIONSFILE)); + StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); + StorageManager.SetMaxSaves(99); - // register the awards - RegisterAwardsWithProfileManager(); + byteArray baOptionsIcon = + app.getArchiveFile(L"DefaultOptionsImage320x176.png"); + byteArray baSaveThumbnail = + app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); + byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png"); - // register the get string function with the profile lib, so it can be called within the lib - ProfileManager.SetGetStringFunc(&CConsoleMinecraftApp::GetString); - ProfileManager.SetPlayerListTitleID(IDS_PLAYER_LIST_TITLE); + StorageManager.InitialiseProfileData( + PROFILE_VERSION_BUILD_JUNE14, NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, + dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - // defaults - StorageManager.ResetSaveData(); - StorageManager.SetSaveTitle(L"Default Save"); - StorageManager.SetGameSaveFolderTitle((WCHAR *)app.GetString(IDS_GAMENAME)); - StorageManager.SetSaveCacheFolderTitle((WCHAR *)app.GetString(IDS_SAVECACHEFILE)); - StorageManager.SetOptionsFolderTitle((WCHAR *)app.GetString(IDS_OPTIONSFILE)); - StorageManager.SetGameSaveFolderPrefix(app.GetSaveFolderPrefix()); - StorageManager.SetMaxSaves(99); + StorageManager.SetDefaultImages( + (PBYTE)baOptionsIcon.data, baOptionsIcon.length, + (PBYTE)baSaveImage.data, baSaveImage.length, + (PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - byteArray baOptionsIcon = app.getArchiveFile(L"DefaultOptionsImage320x176.png"); - byteArray baSaveThumbnail = app.getArchiveFile(L"DefaultSaveThumbnail64x64.png"); - byteArray baSaveImage = app.getArchiveFile(L"DefaultSaveImage320x176.png"); + if (baOptionsIcon.data != NULL) { + delete[] baOptionsIcon.data; + } + if (baSaveThumbnail.data != NULL) { + delete[] baSaveThumbnail.data; + } + if (baSaveImage.data != NULL) { + delete[] baSaveImage.data; + } - StorageManager.InitialiseProfileData(PROFILE_VERSION_BUILD_JUNE14, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask); - - StorageManager.SetDefaultImages((PBYTE)baOptionsIcon.data, baOptionsIcon.length,(PBYTE)baSaveImage.data, baSaveImage.length,(PBYTE)baSaveThumbnail.data, baSaveThumbnail.length); - - if(baOptionsIcon.data!=NULL){ delete [] baOptionsIcon.data; } - if(baSaveThumbnail.data!=NULL){ delete [] baSaveThumbnail.data; } - if(baSaveImage.data!=NULL){ delete [] baSaveImage.data; } - - StorageManager.SetIncompleteSaveCallback(CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); + StorageManager.SetIncompleteSaveCallback( + CConsoleMinecraftApp::Callback_SaveGameIncomplete, (LPVOID)&app); #if 0 // Set up the global title storage path StorageManager.StoreTMSPathName(); #endif - // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out - ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + // set a function to be called when there's a sign in change, so we can exit + // a level if the primary player signs out + ProfileManager.SetSignInChangeCallback( + &CConsoleMinecraftApp::SignInChangeCallback, (LPVOID)&app); #if 0 // set a function to be called when the ethernet is disconnected, so we can back out if required ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); #endif - // Set a callback for the default player options to be set - when there is no profile data for the player - StorageManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - StorageManager.SetOptionsDataCallback(&CConsoleMinecraftApp::OptionsDataCallback,(LPVOID)&app); + // Set a callback for the default player options to be set - when there is + // no profile data for the player + StorageManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); + StorageManager.SetOptionsDataCallback( + &CConsoleMinecraftApp::OptionsDataCallback, (LPVOID)&app); - // Set a callback to deal with old profile versions needing updated to new versions - StorageManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + // Set a callback to deal with old profile versions needing updated to new + // versions + StorageManager.SetOldProfileVersionCallback( + &CConsoleMinecraftApp::OldProfileVersionCallback, (LPVOID)&app); #if 0 // Set a callback for when there is a read error on profile data //StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); #endif - StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); - app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL + StorageManager.SetDLCInfoMap(app.GetSonyDLCMap()); + app.CommerceInit(); // MGH - moved this here so GetCommerce isn't NULL - // 4J-PB - Kick of the check for trial or full version - requires ui to be initialised - app.GetCommerce()->CheckForTrialUpgradeKey(); + // 4J-PB - Kick of the check for trial or full version - requires ui to be + // initialised + app.GetCommerce()->CheckForTrialUpgradeKey(); - - - // debug switch to trial version - //ProfileManager.SetDebugFullOverride(false); + // debug switch to trial version + // ProfileManager.SetDebugFullOverride(false); #if 0 //ProfileManager.AddDLC(2); @@ -684,59 +892,62 @@ int main() hr = SentientManager.Init(); #endif - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - Compression::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + Compression::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); - //#if 0 - //bool bDisplayPauseMenu=false; + // #if 0 + // bool bDisplayPauseMenu=false; - // set the default gamma level - float fVal=50.0f*327.68f; - RenderManager.UpdateGamma((unsigned short)fVal); + // set the default gamma level + float fVal = 50.0f * 327.68f; + RenderManager.UpdateGamma((unsigned short)fVal); - // load any skins - //app.AddSkinsToMemoryTextureFiles(); + // load any skins + // app.AddSkinsToMemoryTextureFiles(); - // set the achievement text for a trial achievement, now we have the string table loaded - //Chris TODO - //ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); - ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT); - //ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); - //ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT); - ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT); - ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app); + // set the achievement text for a trial achievement, now we have the string + // table loaded + // Chris TODO + // ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, + // IDS_CONFIRM_CANCEL); + ProfileManager.SetTrialAwardText(eAwardType_Achievement, IDS_UNLOCK_TITLE, + IDS_UNLOCK_ACHIEVEMENT_TEXT); + // ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); + // ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_Theme, IDS_UNLOCK_TITLE, + IDS_UNLOCK_THEME_TEXT); + ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback, &app); - // Set up a debug character press sequence + // Set up a debug character press sequence #ifndef _FINAL_BUILD - app.SetDebugSequence("LRLRYYY"); + app.SetDebugSequence("LRLRYYY"); #endif - // Initialise the social networking manager. - //Chris TODO - //CSocialManager::Instance()->Initialise(); + // Initialise the social networking manager. + // Chris TODO + // CSocialManager::Instance()->Initialise(); - // Update the base scene quick selects now that the minecraft class exists - //CXuiSceneBase::UpdateScreenSettings(0); - //#endif - app.InitialiseTips(); + // Update the base scene quick selects now that the minecraft class exists + // CXuiSceneBase::UpdateScreenSettings(0); + // #endif + app.InitialiseTips(); #if 0 DWORD initData=0; #ifndef _FINAL_BUILD #ifndef _DEBUG -#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission") #endif #endif @@ -747,32 +958,34 @@ int main() app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); #endif - // wait for the trophy init to complete - nonblocking semaphore - while(( !ProfileManager.AreTrophiesInstalled() ) && ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) - { - RenderManager.StartFrame(); - ProfileManager.Tick(); - RenderManager.Tick(); - RenderManager.Present(); - } + // wait for the trophy init to complete - nonblocking semaphore + while ((!ProfileManager.AreTrophiesInstalled()) && + ShutdownManager::ShouldRun(ShutdownManager::eMainThread)) { + RenderManager.StartFrame(); + ProfileManager.Tick(); + RenderManager.Tick(); + RenderManager.Present(); + } - // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle - // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the - // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. - g_NetworkManager.Initialise(); - g_NetworkManager.SetLocalGame(true); + // QNet needs to be setup after profile manager, as we do not want its + // Notify listener to handle XN_SYS_SIGNINCHANGED notifications. This does + // mean that we need to have a callback in the ProfileManager for + // XN_LIVE_INVITE_ACCEPTED for QNet. + g_NetworkManager.Initialise(); + g_NetworkManager.SetLocalGame(true); - // Set the default sound levels - pMinecraft->options->set(Options::Option::MUSIC,1.0f); - pMinecraft->options->set(Options::Option::SOUND,1.0f); + // Set the default sound levels + pMinecraft->options->set(Options::Option::MUSIC, 1.0f); + pMinecraft->options->set(Options::Option::SOUND, 1.0f); - app.InitGameSettings(); - // read the options here for controller 0 - this won't actually be actioned until a storagemanager tick later - StorageManager.ReadFromProfile(0); + app.InitGameSettings(); + // read the options here for controller 0 - this won't actually be actioned + // until a storagemanager tick later + StorageManager.ReadFromProfile(0); - //app.TemporaryCreateGameStart(); + // app.TemporaryCreateGameStart(); - //Sleep(10000); + // Sleep(10000); #if 0 // Intro loop ? while(app.IntroRunning()) @@ -795,11 +1008,10 @@ int main() hr = XuiTimersRun(); } #endif - while( true ) - { - SonyVoiceChat_Vita::tick(); + while (true) { + SonyVoiceChat_Vita::tick(); - RenderManager.StartFrame(); + RenderManager.StartFrame(); #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -810,90 +1022,90 @@ int main() } #endif - // static bool bPlay=false; - // if(bPlay) - // { - // bPlay=false; - // app.audio.PlaySound(); - // } + // static bool bPlay=false; + // if(bPlay) + // { + // bPlay=false; + // app.audio.PlaySound(); + // } - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); - // CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); - // SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #1"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); - LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft + ->tickAllConnections(); // Added to stop timing out when we + // are waiting after converting to + // an offline game + } + } - pMinecraft->soundEngine->playMusicTick(); + pMinecraft->soundEngine->playMusicTick(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; + MemPixStuff(); - MemPixStuff(); + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } - - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -903,8 +1115,8 @@ int main() bDumpTextureUsage = false; } #endif - ui.tick(); - ui.render(); + ui.tick(); + ui.render(); #if 0 app.HandleButtonPresses(); @@ -944,141 +1156,133 @@ int main() RenderManager.Set_matrixDirty(); #endif - // Present the frame. - RenderManager.Present(); + // Present the frame. + RenderManager.Present(); - ui.CheckMenuDisplayed(); + ui.CheckMenuDisplayed(); - PIXBeginNamedEvent(0,"Profile load check"); - // has the game defined profile data been changed (by a profile load) - if(app.uiGameDefinedDataChangedBitmask!=0) - { - void *pData; - for(int i=0;istats[ i ]->clear(); - pMinecraft->stats[i]->parse(pData); - } - } + // clear the stats first - there could have beena signout + // and sign back in in the menus need to clear the player + // stats - can't assume it'll be done in setlevel - we may + // not be in the game + pMinecraft->stats[i]->clear(); + pMinecraft->stats[i]->parse(pData); + } + } - //Check to see if we can post to social networks. - //CD - Removing this until support exists - //CSocialManager::Instance()->RefreshPostingCapability(); + // Check to see if we can post to social networks. + // CD - Removing this until support exists + // CSocialManager::Instance()->RefreshPostingCapability(); - // clear the flag - app.uiGameDefinedDataChangedBitmask=0; + // clear the flag + app.uiGameDefinedDataChangedBitmask = 0; - // Check if any profile write are needed - app.CheckGameSettingsChanged(); - } - PIXEndNamedEvent(); - app.TickDLCOffersRetrieved(); - app.TickTMSPPFilesRetrieved(); + // Check if any profile write are needed + app.CheckGameSettingsChanged(); + } + PIXEndNamedEvent(); + app.TickDLCOffersRetrieved(); + app.TickTMSPPFilesRetrieved(); - PIXBeginNamedEvent(0,"Network manager do work #2"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); -#if 0 + PIXBeginNamedEvent(0, "Network manager do work #2"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); +#if 0 PIXBeginNamedEvent(0,"Misc extra xui"); // Update XUI Timers hr = XuiTimersRun(); -#endif // #if 0 - // Any threading type things to deal with from the xui side? - app.HandleXuiActions(); +#endif // #if 0 + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); #if 0 PIXEndNamedEvent(); #endif - // 4J-PB - Update the trial timer display if we are in the trial version - if(!ProfileManager.IsFullVersion()) - { - // display the trial timer - if(app.GetGameStarted()) - { - // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down - if(app.IsAppPaused()) - { - app.UpdateTrialPausedTimer(); - } - ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); - } - } - else - { - // need to turn off the trial timer if it was on , and we've unlocked the full version - if(bTrialTimerDisplayed) - { - ui.ShowTrialTimer(false); - bTrialTimerDisplayed=false; - } - } + // 4J-PB - Update the trial timer display if we are in the trial version + if (!ProfileManager.IsFullVersion()) { + // display the trial timer + if (app.GetGameStarted()) { + // 4J-PB - if the game is paused, add the elapsed time to the + // trial timer count so it doesn't tick down + if (app.IsAppPaused()) { + app.UpdateTrialPausedTimer(); + } + ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } else { + // need to turn off the trial timer if it was on , and we've + // unlocked the full version + if (bTrialTimerDisplayed) { + ui.ShowTrialTimer(false); + bTrialTimerDisplayed = false; + } + } - // PS4 DLC - app.CommerceTick(); - app.AppEventTick(); + // PS4 DLC + app.CommerceTick(); + app.AppEventTick(); - app.SaveDataTick(); + app.SaveDataTick(); - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); + // Fix for #7318 - Title crashes after short soak in the leaderboards + // menu A memory leak was caused because the icon renderer kept creating + // new Vec3's because the pool wasn't reset + Vec3::resetPool(); - // sceRazorCpuSync(); + // sceRazorCpuSync(); #ifndef _CONTENT_PACKAGE - if( InputManager.ButtonDown(0, MINECRAFT_ACTION_DPAD_LEFT) ) - { - malloc_managed_size mmsize; - malloc_stats(&mmsize); - app.DebugPrintf("Free mem = %d\n", (mmsize.current_system_size - mmsize.current_inuse_size) / (1024*1024)); - } + if (InputManager.ButtonDown(0, MINECRAFT_ACTION_DPAD_LEFT)) { + malloc_managed_size mmsize; + malloc_stats(&mmsize); + app.DebugPrintf("Free mem = %d\n", (mmsize.current_system_size - + mmsize.current_inuse_size) / + (1024 * 1024)); + } #endif - } + } - ShutdownManager::MainThreadHandleShutdown(); + ShutdownManager::MainThreadHandleShutdown(); } -std::vector vRichPresenceStrings; -uint8_t * AddRichPresenceString(int iID) -{ - uint8_t *strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); - if( strUtf8 != NULL ) - { - vRichPresenceStrings.push_back(strUtf8); - } - return strUtf8; +std::vector vRichPresenceStrings; +uint8_t* AddRichPresenceString(int iID) { + uint8_t* strUtf8 = mallocAndCreateUTF8ArrayFromString(iID); + if (strUtf8 != NULL) { + vRichPresenceStrings.push_back(strUtf8); + } + return strUtf8; } -void FreeRichPresenceStrings() -{ - uint8_t *strUtf8; - for(int i=0;i(DlgProc)); +void SeedEditBox() { + DialogBox(hMyInst, MAKEINTRESOURCE(IDD_SEED), g_hWnd, + reinterpret_cast(DlgProc)); } - //--------------------------------------------------------------------------- -LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - switch(Msg) - { - case WM_INITDIALOG: - return TRUE; +LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { + switch (Msg) { + case WM_INITDIALOG: + return TRUE; - case WM_COMMAND: - switch(wParam) - { - case IDOK: - // Set the text - GetDlgItemText(hWndDlg,IDC_EDIT,chGlobalText,256); - EndDialog(hWndDlg, 0); - return TRUE; - } - break; - } + case WM_COMMAND: + switch (wParam) { + case IDOK: + // Set the text + GetDlgItemText(hWndDlg, IDC_EDIT, chGlobalText, 256); + EndDialog(hWndDlg, 0); + return TRUE; + } + break; + } - return FALSE; + return FALSE; } //-------------------------------------------------------------------------------------- // Create Direct3D device and swap chain //-------------------------------------------------------------------------------------- -HRESULT InitDevice() -{ - HRESULT hr = S_OK; +HRESULT InitDevice() { + HRESULT hr = S_OK; - RECT rc; - GetClientRect( g_hWnd, &rc ); - UINT width = rc.right - rc.left; - UINT height = rc.bottom - rc.top; -//app.DebugPrintf("width: %d, height: %d\n", width, height); - width = g_iScreenWidth; - height = g_iScreenHeight; -app.DebugPrintf("width: %d, height: %d\n", width, height); + RECT rc; + GetClientRect(g_hWnd, &rc); + UINT width = rc.right - rc.left; + UINT height = rc.bottom - rc.top; + // app.DebugPrintf("width: %d, height: %d\n", width, height); + width = g_iScreenWidth; + height = g_iScreenHeight; + app.DebugPrintf("width: %d, height: %d\n", width, height); - UINT createDeviceFlags = 0; + UINT createDeviceFlags = 0; #ifdef _DEBUG - createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; + createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif - D3D_DRIVER_TYPE driverTypes[] = - { - D3D_DRIVER_TYPE_HARDWARE, - D3D_DRIVER_TYPE_WARP, - D3D_DRIVER_TYPE_REFERENCE, - }; - UINT numDriverTypes = ARRAYSIZE( driverTypes ); + D3D_DRIVER_TYPE driverTypes[] = { + D3D_DRIVER_TYPE_HARDWARE, + D3D_DRIVER_TYPE_WARP, + D3D_DRIVER_TYPE_REFERENCE, + }; + UINT numDriverTypes = ARRAYSIZE(driverTypes); - D3D_FEATURE_LEVEL featureLevels[] = - { - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - }; - UINT numFeatureLevels = ARRAYSIZE( featureLevels ); + D3D_FEATURE_LEVEL featureLevels[] = { + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + }; + UINT numFeatureLevels = ARRAYSIZE(featureLevels); - DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory( &sd, sizeof( sd ) ); - sd.BufferCount = 1; - sd.BufferDesc.Width = width; - sd.BufferDesc.Height = height; - sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.OutputWindow = g_hWnd; - sd.SampleDesc.Count = 1; - sd.SampleDesc.Quality = 0; - sd.Windowed = TRUE; + DXGI_SWAP_CHAIN_DESC sd; + ZeroMemory(&sd, sizeof(sd)); + sd.BufferCount = 1; + sd.BufferDesc.Width = width; + sd.BufferDesc.Height = height; + sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + sd.BufferDesc.RefreshRate.Numerator = 60; + sd.BufferDesc.RefreshRate.Denominator = 1; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.OutputWindow = g_hWnd; + sd.SampleDesc.Count = 1; + sd.SampleDesc.Quality = 0; + sd.Windowed = TRUE; - for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ ) - { - g_driverType = driverTypes[driverTypeIndex]; - hr = D3D11CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels, - D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext ); - if( HRESULT_SUCCEEDED( hr ) ) - break; - } - if( FAILED( hr ) ) - return hr; + for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; + driverTypeIndex++) { + g_driverType = driverTypes[driverTypeIndex]; + hr = D3D11CreateDeviceAndSwapChain( + NULL, g_driverType, NULL, createDeviceFlags, featureLevels, + numFeatureLevels, D3D11_SDK_VERSION, &sd, &g_pSwapChain, + &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); + if (HRESULT_SUCCEEDED(hr)) break; + } + if (FAILED(hr)) return hr; - // Create a render target view - ID3D11Texture2D* pBackBuffer = NULL; - hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer ); - if( FAILED( hr ) ) - return hr; + // Create a render target view + ID3D11Texture2D* pBackBuffer = NULL; + hr = g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), + (LPVOID*)&pBackBuffer); + if (FAILED(hr)) return hr; - // Create a depth stencil buffer - D3D11_TEXTURE2D_DESC descDepth; + // Create a depth stencil buffer + D3D11_TEXTURE2D_DESC descDepth; - descDepth.Width = width; - descDepth.Height = height; - descDepth.MipLevels = 1; - descDepth.ArraySize = 1; - descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; - descDepth.SampleDesc.Count = 1; - descDepth.SampleDesc.Quality = 0; - descDepth.Usage = D3D11_USAGE_DEFAULT; - descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; - descDepth.CPUAccessFlags = 0; - descDepth.MiscFlags = 0; - hr = g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); + descDepth.Width = width; + descDepth.Height = height; + descDepth.MipLevels = 1; + descDepth.ArraySize = 1; + descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + descDepth.SampleDesc.Count = 1; + descDepth.SampleDesc.Quality = 0; + descDepth.Usage = D3D11_USAGE_DEFAULT; + descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; + descDepth.CPUAccessFlags = 0; + descDepth.MiscFlags = 0; + hr = + g_pd3dDevice->CreateTexture2D(&descDepth, NULL, &g_pDepthStencilBuffer); - D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; - descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; - descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; - descDSView.Texture2D.MipSlice = 0; + D3D11_DEPTH_STENCIL_VIEW_DESC descDSView; + descDSView.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; + descDSView.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; + descDSView.Texture2D.MipSlice = 0; - hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); + hr = g_pd3dDevice->CreateDepthStencilView( + g_pDepthStencilBuffer, &descDSView, &g_pDepthStencilView); - hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView ); - pBackBuffer->Release(); - if( FAILED( hr ) ) - return hr; + hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, + &g_pRenderTargetView); + pBackBuffer->Release(); + if (FAILED(hr)) return hr; - g_pImmediateContext->OMSetRenderTargets( 1, &g_pRenderTargetView, g_pDepthStencilView ); + g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, + g_pDepthStencilView); - // Setup the viewport - D3D11_VIEWPORT vp; - vp.Width = (FLOAT)width; - vp.Height = (FLOAT)height; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - vp.TopLeftX = 0; - vp.TopLeftY = 0; - g_pImmediateContext->RSSetViewports( 1, &vp ); + // Setup the viewport + D3D11_VIEWPORT vp; + vp.Width = (FLOAT)width; + vp.Height = (FLOAT)height; + vp.MinDepth = 0.0f; + vp.MaxDepth = 1.0f; + vp.TopLeftX = 0; + vp.TopLeftY = 0; + g_pImmediateContext->RSSetViewports(1, &vp); - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); - return S_OK; + return S_OK; } //-------------------------------------------------------------------------------------- // Render the frame //-------------------------------------------------------------------------------------- -void Render() -{ - // Just clear the backbuffer - float ClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; //red,green,blue,alpha +void Render() { + // Just clear the backbuffer + float ClearColor[4] = {0.0f, 0.125f, 0.3f, 1.0f}; // red,green,blue,alpha - g_pImmediateContext->ClearRenderTargetView( g_pRenderTargetView, ClearColor ); - g_pSwapChain->Present( 0, 0 ); + g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor); + g_pSwapChain->Present(0, 0); } //-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- -void CleanupDevice() -{ - if( g_pImmediateContext ) g_pImmediateContext->ClearState(); +void CleanupDevice() { + if (g_pImmediateContext) g_pImmediateContext->ClearState(); - if( g_pRenderTargetView ) g_pRenderTargetView->Release(); - if( g_pSwapChain ) g_pSwapChain->Release(); - if( g_pImmediateContext ) g_pImmediateContext->Release(); - if( g_pd3dDevice ) g_pd3dDevice->Release(); + if (g_pRenderTargetView) g_pRenderTargetView->Release(); + if (g_pSwapChain) g_pSwapChain->Release(); + if (g_pImmediateContext) g_pImmediateContext->Release(); + if (g_pd3dDevice) g_pd3dDevice->Release(); } - - int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPTSTR lpCmdLine, - _In_ int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); + _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, + _In_ int nCmdShow) { + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); - if(lpCmdLine) - { - if(lpCmdLine[0] == '1') - { - g_iScreenWidth = 1280; - g_iScreenHeight = 720; - } - else if(lpCmdLine[0] == '2') - { - g_iScreenWidth = 640; - g_iScreenHeight = 480; - } - else if(lpCmdLine[0] == '3') - { - // Vita - g_iScreenWidth = 720; - g_iScreenHeight = 408; + if (lpCmdLine) { + if (lpCmdLine[0] == '1') { + g_iScreenWidth = 1280; + g_iScreenHeight = 720; + } else if (lpCmdLine[0] == '2') { + g_iScreenWidth = 640; + g_iScreenHeight = 480; + } else if (lpCmdLine[0] == '3') { + // Vita + g_iScreenWidth = 720; + g_iScreenHeight = 408; - // Vita native - //g_iScreenWidth = 960; - //g_iScreenHeight = 544; - } - } + // Vita native + // g_iScreenWidth = 960; + // g_iScreenHeight = 544; + } + } + // Initialize global strings + MyRegisterClass(hInstance); - // Initialize global strings - MyRegisterClass(hInstance); + // Perform application initialization: + if (!InitInstance(hInstance, nCmdShow)) { + return FALSE; + } - // Perform application initialization: - if (!InitInstance (hInstance, nCmdShow)) - { - return FALSE; - } + hMyInst = hInstance; - hMyInst=hInstance; - - if( FAILED( InitDevice() ) ) - { - CleanupDevice(); - return 0; - } + if (FAILED(InitDevice())) { + CleanupDevice(); + return 0; + } #if 0 // Main message loop @@ -668,13 +786,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, return (int) msg.wParam; #endif - static bool bTrialTimerDisplayed=true; + static bool bTrialTimerDisplayed = true; #ifdef MEMORY_TRACKING - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); #endif #if 0 @@ -701,35 +820,34 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } #endif - app.loadMediaArchive(); + app.loadMediaArchive(); - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); - - app.loadStringTable(); - ui.init(g_pd3dDevice,g_pImmediateContext,g_pRenderTargetView,g_pDepthStencilView,g_iScreenWidth,g_iScreenHeight); + RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); - //////////////// - // Initialise // - //////////////// + app.loadStringTable(); + ui.init(g_pd3dDevice, g_pImmediateContext, g_pRenderTargetView, + g_pDepthStencilView, g_iScreenWidth, g_iScreenHeight); - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + //////////////// + // Initialise // + //////////////// - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions + InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings - ProfileManager.Initialise(TITLEID_MINECRAFT, - app.m_dwOfferID, - PROFILE_VERSION_10, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask - ); + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); + + // Initialise the profile manager with the game Title ID, Offer ID, a + // profile version number, and the number of profile values and settings + ProfileManager.Initialise( + TITLEID_MINECRAFT, app.m_dwOfferID, PROFILE_VERSION_10, + NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); #if 0 // register the awards ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); @@ -778,8 +896,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); #endif - // Set a callback for the default player options to be set - when there is no profile data for the player - ProfileManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); + // Set a callback for the default player options to be set - when there is + // no profile data for the player + ProfileManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); #if 0 // Set a callback to deal with old profile versions needing updated to new versions ProfileManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); @@ -788,18 +908,17 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, ProfileManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); #endif - // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle - // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the - // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. - g_NetworkManager.Initialise(); + // QNet needs to be setup after profile manager, as we do not want its + // Notify listener to handle XN_SYS_SIGNINCHANGED notifications. This does + // mean that we need to have a callback in the ProfileManager for + // XN_LIVE_INVITE_ACCEPTED for QNet. + g_NetworkManager.Initialise(); + // 4J-PB moved further down + // app.InitGameSettings(); - - // 4J-PB moved further down - //app.InitGameSettings(); - - // debug switch to trial version - ProfileManager.SetDebugFullOverride(true); + // debug switch to trial version + ProfileManager.SetDebugFullOverride(true); #if 0 //ProfileManager.AddDLC(2); @@ -818,21 +937,20 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, hr = TelemetryManager->Init(); #endif - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - Compression::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + Compression::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); - app.InitGameSettings(); + app.InitGameSettings(); #if 0 //bool bDisplayPauseMenu=false; @@ -863,14 +981,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // Update the base scene quick selects now that the minecraft class exists //CXuiSceneBase::UpdateScreenSettings(0); #endif - app.InitialiseTips(); + app.InitialiseTips(); #if 0 DWORD initData=0; #ifndef _FINAL_BUILD #ifndef _DEBUG -#pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission") #endif #endif @@ -881,13 +999,13 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); #endif - // Set the default sound levels - pMinecraft->options->set(Options::Option::MUSIC,1.0f); - pMinecraft->options->set(Options::Option::SOUND,1.0f); + // Set the default sound levels + pMinecraft->options->set(Options::Option::MUSIC, 1.0f); + pMinecraft->options->set(Options::Option::SOUND, 1.0f); - //app.TemporaryCreateGameStart(); + // app.TemporaryCreateGameStart(); - //Sleep(10000); + // Sleep(10000); #if 0 // Intro loop ? while(app.IntroRunning()) @@ -910,16 +1028,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, hr = XuiTimersRun(); } #endif - MSG msg = {0}; - while( WM_QUIT != msg.message ) - { - if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - continue; - } - RenderManager.StartFrame(); + MSG msg = {0}; + while (WM_QUIT != msg.message) { + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + continue; + } + RenderManager.StartFrame(); #if 0 if(pMinecraft->soundEngine->isStreamingWavebankReady() && !pMinecraft->soundEngine->isPlayingStreamingGameMusic() && @@ -930,89 +1046,90 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } #endif - // static bool bPlay=false; - // if(bPlay) - // { - // bPlay=false; - // app.audio.PlaySound(); - // } + // static bool bPlay=false; + // if(bPlay) + // { + // bPlay=false; + // app.audio.PlaySound(); + // } - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - // ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + // ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); - // CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + // CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); - // SentientManager.Tick(); - MemSect(0); - PIXEndNamedEvent(); + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + // SentientManager.Tick(); + MemSect(0); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #1"); - // g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Network manager do work #1"); + // g_NetworkManager.DoWork(); + PIXEndNamedEvent(); - // LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } + // LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + ui.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft + ->tickAllConnections(); // Added to stop timing out when we + // are waiting after converting to + // an offline game + } + } - pMinecraft->soundEngine->playMusicTick(); + pMinecraft->soundEngine->playMusicTick(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -1022,8 +1139,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, bDumpTextureUsage = false; } #endif - ui.tick(); - ui.render(); + ui.tick(); + ui.render(); #if 0 app.HandleButtonPresses(); @@ -1063,10 +1180,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, RenderManager.Set_matrixDirty(); #endif - // Present the frame. - RenderManager.Present(); + // Present the frame. + RenderManager.Present(); - ui.CheckMenuDisplayed(); + ui.CheckMenuDisplayed(); #if 0 PIXBeginNamedEvent(0,"Profile load check"); // has the game defined profile data been changed (by a profile load) @@ -1124,51 +1241,48 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, hr = XuiTimersRun(); #endif - // Any threading type things to deal with from the xui side? - app.HandleXuiActions(); + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); #if 0 PIXEndNamedEvent(); #endif - // 4J-PB - Update the trial timer display if we are in the trial version - if(!ProfileManager.IsFullVersion()) - { - // display the trial timer - if(app.GetGameStarted()) - { - // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down - if(app.IsAppPaused()) - { - app.UpdateTrialPausedTimer(); - } - ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); - } - } - else - { - // need to turn off the trial timer if it was on , and we've unlocked the full version - if(bTrialTimerDisplayed) - { - ui.ShowTrialTimer(false); - bTrialTimerDisplayed=false; - } - } + // 4J-PB - Update the trial timer display if we are in the trial version + if (!ProfileManager.IsFullVersion()) { + // display the trial timer + if (app.GetGameStarted()) { + // 4J-PB - if the game is paused, add the elapsed time to the + // trial timer count so it doesn't tick down + if (app.IsAppPaused()) { + app.UpdateTrialPausedTimer(); + } + ui.UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } else { + // need to turn off the trial timer if it was on , and we've + // unlocked the full version + if (bTrialTimerDisplayed) { + ui.ShowTrialTimer(false); + bTrialTimerDisplayed = false; + } + } - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); - } + // Fix for #7318 - Title crashes after short soak in the leaderboards + // menu A memory leak was caused because the icon renderer kept creating + // new Vec3's because the pool wasn't reset + Vec3::resetPool(); + } - // Free resources, unregister custom classes, and exit. - // app.Uninit(); - g_pd3dDevice->Release(); + // Free resources, unregister custom classes, and exit. + // app.Uninit(); + g_pd3dDevice->Release(); } #ifdef MEMORY_TRACKING int totalAllocGen = 0; -std::unordered_map allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -1177,179 +1291,159 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } + trackEnable = true; + } + } - LeaveCriticalSection(&memCS); + LeaveCriticalSection(&memCS); - return p; + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes - ) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } -void DumpMem() -{ - int totalLeak = 0; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 46; +void MemPixStuff() { + const int MAX_SECT = 46; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (AUTO_VAR(it, allocCounts.begin()); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp index bb63d51ce..822fd717c 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp +++ b/Minecraft.Client/Platform/Xbox/Xbox_Minecraft.cpp @@ -29,685 +29,873 @@ #include "../../Rendering/Tesselator.h" #include "../../GameState/Options.h" #include "Sentient/SentientManager.h" -#include "../../../Minecraft.World/Util/IntCache.h" #include "../../Textures/Textures.h" #include "../../../Minecraft.World/IO/Streams/Compression.h" #include "../../../Minecraft.World/Level/Storage/OldChunkStorage.h" -//#include "../../Minecraft.Client/SoundEngine.h" +// #include "../../Minecraft.Client/SoundEngine.h" #include -void GetRenderAndSamplerStates(IDirect3DDevice9 *pDevice,DWORD *RenderStateA,DWORD *SamplerStateA); -void SetRenderAndSamplerStates(IDirect3DDevice9 *pDevice,DWORD *RenderStateA,DWORD *SamplerStateA); +void GetRenderAndSamplerStates(IDirect3DDevice9* pDevice, DWORD* RenderStateA, + DWORD* SamplerStateA); +void SetRenderAndSamplerStates(IDirect3DDevice9* pDevice, DWORD* RenderStateA, + DWORD* SamplerStateA); -// 4J-PB - Done - #pragma message(__LOC__"Theme should be GREEN SIGNED before _FINAL_BUILD") +// 4J-PB - Done - #pragma message(__LOC__"Theme should be GREEN SIGNED before +// _FINAL_BUILD") -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 -//#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) -//#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) -//#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) -#define FIFTY_ONE_MB (1000000*51) // Maximum TCR space required for a save is 52MB (checking for this on a selected device) +#define THEME_NAME "584111F70AAAAAAA" +#define THEME_FILESIZE 2797568 +// #define THREE_MB 3145728 // minimum save size (checking for this on a +// selected device) #define FIVE_MB 5242880 // minimum save size (checking for +// this on a selected device) #define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR +// space required for a save (checking for this on a selected device) +#define FIFTY_ONE_MB \ + (1000000 * 51) // Maximum TCR space required for a save is 52MB (checking + // for this on a selected device) -//#define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU -#define NUM_PROFILE_VALUES 5 +// #define PROFILE_VERSION 3 // new version for the interim bug fix 166 TU +#define NUM_PROFILE_VALUES 5 #define NUM_PROFILE_SETTINGS 4 -DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= -{ - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, +DWORD dwProfileSettingsA[NUM_PROFILE_VALUES] = { + XPROFILE_OPTION_CONTROLLER_VIBRATION, + XPROFILE_GAMER_YAXIS_INVERSION, + XPROFILE_GAMER_CONTROL_SENSITIVITY, + XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, + XPROFILE_TITLE_SPECIFIC1, }; -D3DRENDERSTATETYPE RenderStateModes[]= -{ - D3DRS_FILLMODE, - D3DRS_CULLMODE, - D3DRS_ALPHABLENDENABLE, - D3DRS_VIEWPORTENABLE, - D3DRS_BLENDOP, - D3DRS_SRCBLEND, - D3DRS_DESTBLEND, - D3DRS_COLORWRITEENABLE -}; +D3DRENDERSTATETYPE RenderStateModes[] = { + D3DRS_FILLMODE, D3DRS_CULLMODE, D3DRS_ALPHABLENDENABLE, + D3DRS_VIEWPORTENABLE, D3DRS_BLENDOP, D3DRS_SRCBLEND, + D3DRS_DESTBLEND, D3DRS_COLORWRITEENABLE}; -D3DSAMPLERSTATETYPE SamplerStateModes[]= -{ - D3DSAMP_MINFILTER, - D3DSAMP_MAGFILTER, - D3DSAMP_MIPFILTER, - D3DSAMP_ADDRESSU, - D3DSAMP_ADDRESSV -}; +D3DSAMPLERSTATETYPE SamplerStateModes[] = {D3DSAMP_MINFILTER, D3DSAMP_MAGFILTER, + D3DSAMP_MIPFILTER, D3DSAMP_ADDRESSU, + D3DSAMP_ADDRESSV}; //------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. +// Time Since fAppTime is a float, we need to keep the quadword app +// time +// as a LARGE_INTEGER so that we don't lose precision after +// running for a long time. //------------------------------------------------------------------------------------- - BOOL g_bWidescreen = TRUE; +void DefineActions(void) { + // The app needs to define the actions required, and the possible mappings + // for these -void DefineActions(void) -{ - // The app needs to define the actions required, and the possible mappings for these + // Split into Menu actions, and in-game actions - // Split into Menu actions, and in-game actions + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_0, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_0,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_0, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_1, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_1,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_A, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_B, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_X, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_Y, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OK, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_CANCEL, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_UP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_DOWN, _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT, _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEUP, _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAGEDOWN, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_RIGHT_SCROLL, _360_JOY_BUTTON_RB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_LEFT_SCROLL, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_PAUSEMENU, _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_1, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_STICK_PRESS, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_PRESS, _360_JOY_BUTTON_RTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,ACTION_MENU_OTHER_STICK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_A, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_B, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_X, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_Y, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OK, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_CANCEL, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_UP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_DOWN, + _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_LEFT, + _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT | _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps( + MAP_STYLE_2, ACTION_MENU_PAGEUP, + _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAGEDOWN, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_RIGHT_SCROLL, + _360_JOY_BUTTON_RB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_LEFT_SCROLL, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_PAUSEMENU, + _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_JUMP, _360_JOY_BUTTON_LT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_FORWARD, _360_JOY_BUTTON_LSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_BACKWARD, _360_JOY_BUTTON_LSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT, _360_JOY_BUTTON_LSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT, _360_JOY_BUTTON_LSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_LEFT, _360_JOY_BUTTON_RSTICK_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_RIGHT, _360_JOY_BUTTON_RSTICK_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_UP, _360_JOY_BUTTON_RSTICK_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LOOK_DOWN, _360_JOY_BUTTON_RSTICK_DOWN); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_USE, _360_JOY_BUTTON_RT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_ACTION, _360_JOY_BUTTON_A); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RIGHT_SCROLL, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_LEFT_SCROLL, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_INVENTORY, _360_JOY_BUTTON_Y); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_PAUSEMENU, _360_JOY_BUTTON_START); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DROP, _360_JOY_BUTTON_B); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_SNEAK_TOGGLE, _360_JOY_BUTTON_LB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_CRAFTING, _360_JOY_BUTTON_X); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_RENDER_THIRD_PERSON, _360_JOY_BUTTON_LTHUMB); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_GAME_INFO, _360_JOY_BUTTON_BACK); - - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_LEFT, _360_JOY_BUTTON_DPAD_LEFT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_RIGHT, _360_JOY_BUTTON_DPAD_RIGHT); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_UP, _360_JOY_BUTTON_DPAD_UP); - InputManager.SetGameJoypadMaps(MAP_STYLE_2,MINECRAFT_ACTION_DPAD_DOWN, _360_JOY_BUTTON_DPAD_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_STICK_PRESS, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_PRESS, + _360_JOY_BUTTON_RTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, ACTION_MENU_OTHER_STICK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_JUMP, + _360_JOY_BUTTON_LT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_FORWARD, + _360_JOY_BUTTON_LSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_BACKWARD, + _360_JOY_BUTTON_LSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT, + _360_JOY_BUTTON_LSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT, + _360_JOY_BUTTON_LSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_LEFT, + _360_JOY_BUTTON_RSTICK_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_RIGHT, + _360_JOY_BUTTON_RSTICK_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_UP, + _360_JOY_BUTTON_RSTICK_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LOOK_DOWN, + _360_JOY_BUTTON_RSTICK_DOWN); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_USE, + _360_JOY_BUTTON_RT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_ACTION, + _360_JOY_BUTTON_A); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_RIGHT_SCROLL, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_LEFT_SCROLL, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_INVENTORY, + _360_JOY_BUTTON_Y); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_PAUSEMENU, + _360_JOY_BUTTON_START); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DROP, + _360_JOY_BUTTON_B); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_SNEAK_TOGGLE, + _360_JOY_BUTTON_LB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_CRAFTING, + _360_JOY_BUTTON_X); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, + MINECRAFT_ACTION_RENDER_THIRD_PERSON, + _360_JOY_BUTTON_LTHUMB); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_GAME_INFO, + _360_JOY_BUTTON_BACK); + + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_LEFT, + _360_JOY_BUTTON_DPAD_LEFT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_RIGHT, + _360_JOY_BUTTON_DPAD_RIGHT); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_UP, + _360_JOY_BUTTON_DPAD_UP); + InputManager.SetGameJoypadMaps(MAP_STYLE_2, MINECRAFT_ACTION_DPAD_DOWN, + _360_JOY_BUTTON_DPAD_DOWN); } +HRESULT InitD3D(IDirect3DDevice9** ppDevice, D3DPRESENT_PARAMETERS* pd3dPP) { + IDirect3D9* pD3D; + pD3D = Direct3DCreate9(D3D_SDK_VERSION); + // Set up the structure used to create the D3DDevice + // Using a permanent 1280x720 backbuffer now no matter what the actual video + // resolution.right Have also disabled letterboxing, which would letterbox a + // 1280x720 output if it detected a 4:3 video source - we're doing an + // anamorphic squash in this mode so don't need this functionality. -HRESULT InitD3D( IDirect3DDevice9 **ppDevice, - D3DPRESENT_PARAMETERS *pd3dPP ) -{ - IDirect3D9 *pD3D; + ZeroMemory(pd3dPP, sizeof(D3DPRESENT_PARAMETERS)); + XVIDEO_MODE VideoMode; + XGetVideoMode(&VideoMode); + g_bWidescreen = VideoMode.fIsWideScreen; + pd3dPP->BackBufferWidth = 1280; + pd3dPP->BackBufferHeight = 720; + pd3dPP->BackBufferFormat = D3DFMT_A8R8G8B8; + pd3dPP->BackBufferCount = 1; + pd3dPP->EnableAutoDepthStencil = TRUE; + pd3dPP->AutoDepthStencilFormat = D3DFMT_D24S8; + pd3dPP->SwapEffect = D3DSWAPEFFECT_DISCARD; + pd3dPP->PresentationInterval = D3DPRESENT_INTERVAL_ONE; + // pd3dPP->Flags = + // D3DPRESENTFLAG_NO_LETTERBOX; ERR[D3D]: Can't set + // D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled in the + // launcher/dashboard. + if (g_bWidescreen) + pd3dPP->Flags = 0; + else + pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; - pD3D = Direct3DCreate9( D3D_SDK_VERSION ); - - // Set up the structure used to create the D3DDevice - // Using a permanent 1280x720 backbuffer now no matter what the actual video resolution.right Have also disabled letterboxing, - // which would letterbox a 1280x720 output if it detected a 4:3 video source - we're doing an anamorphic squash in this - // mode so don't need this functionality. - - ZeroMemory( pd3dPP, sizeof(D3DPRESENT_PARAMETERS) ); - XVIDEO_MODE VideoMode; - XGetVideoMode( &VideoMode ); - g_bWidescreen = VideoMode.fIsWideScreen; - pd3dPP->BackBufferWidth = 1280; - pd3dPP->BackBufferHeight = 720; - pd3dPP->BackBufferFormat = D3DFMT_A8R8G8B8; - pd3dPP->BackBufferCount = 1; - pd3dPP->EnableAutoDepthStencil = TRUE; - pd3dPP->AutoDepthStencilFormat = D3DFMT_D24S8; - pd3dPP->SwapEffect = D3DSWAPEFFECT_DISCARD; - pd3dPP->PresentationInterval = D3DPRESENT_INTERVAL_ONE; - //pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; - //ERR[D3D]: Can't set D3DPRESENTFLAG_NO_LETTERBOX when wide-screen is enabled - // in the launcher/dashboard. - if(g_bWidescreen) - pd3dPP->Flags=0; - else - pd3dPP->Flags = D3DPRESENTFLAG_NO_LETTERBOX; - - // Create the device. - return pD3D->CreateDevice( - 0, - D3DDEVTYPE_HAL, - NULL, - D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES, - pd3dPP, - ppDevice ); + // Create the device. + return pD3D->CreateDevice( + 0, D3DDEVTYPE_HAL, NULL, + D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_BUFFER_2_FRAMES, pd3dPP, + ppDevice); } -//#define MEMORY_TRACKING +// #define MEMORY_TRACKING #ifdef MEMORY_TRACKING void ResetMem(); void DumpMem(); void MemPixStuff(); #else -void MemSect(int sect) -{ -} +void MemSect(int sect) {} #endif -IDirect3DDevice9 *g_pD3DDevice; +IDirect3DDevice9* g_pD3DDevice; //------------------------------------------------------------------------------------- // Name: main() // Desc: The application's entry point //------------------------------------------------------------------------------------- -int __cdecl main() -{ - IDirect3DDevice9 *pDevice; - D3DPRESENT_PARAMETERS d3dpp; - HRESULT hr; - static bool bTrialTimerDisplayed=true; +int __cdecl main() { + IDirect3DDevice9* pDevice; + D3DPRESENT_PARAMETERS d3dpp; + HRESULT hr; + static bool bTrialTimerDisplayed = true; - //__debugbreak(); + //__debugbreak(); #ifdef MEMORY_TRACKING - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM start: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM start: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); #endif - // capture the launch data if there is any - app.StoreLaunchData(); + // capture the launch data if there is any + app.StoreLaunchData(); #ifdef _DEBUG - // Output more verbose errors for sessions - XDebugSetSystemOutputLevel( HXAMAPP_XGI, 3 ); + // Output more verbose errors for sessions + XDebugSetSystemOutputLevel(HXAMAPP_XGI, 3); #endif -// DumpMem(); + // DumpMem(); - // Declare an instance of the XUI framework. - - // XUI render can change the following renderstates, so store then before and re-set them after the xui render - /* The following D3DRENDERSTATETYPE D3D render states. + // Declare an instance of the XUI framework. - D3DRS_FILLMODE + // XUI render can change the following renderstates, so store then before + // and re-set them after the xui render + /* The following D3DRENDERSTATETYPE D3D render states. - D3DRS_CULLMODE + D3DRS_FILLMODE - D3DRS_ALPHABLENDENABLE + D3DRS_CULLMODE - D3DRS_VIEWPORTENABLE + D3DRS_ALPHABLENDENABLE - D3DRS_BLENDOP + D3DRS_VIEWPORTENABLE - D3DRS_SRCBLEND + D3DRS_BLENDOP - D3DRS_DESTBLEND + D3DRS_SRCBLEND - D3DRS_COLORWRITEENABLE - */ + D3DRS_DESTBLEND - DWORD RenderStateA[8]; - DWORD SamplerStateA[5]; - DWORD RenderStateA2[8]; - DWORD SamplerStateA2[5]; + D3DRS_COLORWRITEENABLE + */ - // Initialize D3D - hr = InitD3D( &pDevice, &d3dpp ); - g_pD3DDevice = pDevice; - if( FAILED(hr) ) - { - app.DebugPrintf - ( "Failed initializing D3D.\n" ); - return -1; - } + DWORD RenderStateA[8]; + DWORD SamplerStateA[5]; + DWORD RenderStateA2[8]; + DWORD SamplerStateA2[5]; - // Initialize the application, assuming sharing of the d3d interface. - hr = app.InitShared( pDevice, &d3dpp, - XuiPNGTextureLoader ); + // Initialize D3D + hr = InitD3D(&pDevice, &d3dpp); + g_pD3DDevice = pDevice; + if (FAILED(hr)) { + app.DebugPrintf("Failed initializing D3D.\n"); + return -1; + } - if ( FAILED(hr) ) - { - app.DebugPrintf - ( "Failed initializing application.\n" ); - - return -1; - } - - RenderManager.Initialise(pDevice); + // Initialize the application, assuming sharing of the d3d interface. + hr = app.InitShared(pDevice, &d3dpp, XuiPNGTextureLoader); - //////////////// - // Initialise // - //////////////// + if (FAILED(hr)) { + app.DebugPrintf("Failed initializing application.\n"); - // 4J Stu - XACT was creating these automatically, but we need them for QNet. The setup params - // are just copied from a sample app and may need changed for our purposes - // Start XAudio2 - hr = XAudio2Create( &g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR ); - if( FAILED( hr ) ) - { - app.DebugPrintf( "Initializing XAudio2 failed (err = 0x%08x)!\n", hr ); - app.FatalLoadError(); - } + return -1; + } - // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is mixed to main speakers) - hr = g_pXAudio2->CreateMasteringVoice(&g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); - if ( FAILED( hr ) ) - { - app.DebugPrintf( "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr ); - app.FatalLoadError(); - } + RenderManager.Initialise(pDevice); - app.InitTime(); + //////////////// + // Initialise // + //////////////// - // Set the number of possible joypad layouts that the user can switch between, and the number of actions - InputManager.Initialise(1,3,MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); + // 4J Stu - XACT was creating these automatically, but we need them for + // QNet. The setup params are just copied from a sample app and may need + // changed for our purposes Start XAudio2 + hr = XAudio2Create(&g_pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR); + if (FAILED(hr)) { + app.DebugPrintf("Initializing XAudio2 failed (err = 0x%08x)!\n", hr); + app.FatalLoadError(); + } - // Set the default joypad action mappings for Minecraft - DefineActions(); - InputManager.SetJoypadMapVal(0,0); - InputManager.SetKeyRepeatRate(0.3f,0.2f); + // Create an XAudio2 mastering voice (utilized by XHV2 when voice data is + // mixed to main speakers) + hr = g_pXAudio2->CreateMasteringVoice( + &g_pXAudio2MasteringVoice, XAUDIO2_DEFAULT_CHANNELS, + XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, NULL); + if (FAILED(hr)) { + app.DebugPrintf( + "Creating XAudio2 mastering voice failed (err = 0x%08x)!\n", hr); + app.FatalLoadError(); + } + app.InitTime(); - // Initialise the profile manager with the game Title ID, Offer ID, a profile version number, and the number of profile values and settings - ProfileManager.Initialise(TITLEID_MINECRAFT, - app.m_dwOfferID, - PROFILE_VERSION_10, - NUM_PROFILE_VALUES, - NUM_PROFILE_SETTINGS, - dwProfileSettingsA, - app.GAME_DEFINED_PROFILE_DATA_BYTES*XUSER_MAX_COUNT, - &app.uiGameDefinedDataChangedBitmask - ); + // Set the number of possible joypad layouts that the user can switch + // between, and the number of actions + InputManager.Initialise(1, 3, MINECRAFT_ACTION_MAX, ACTION_MAX_MENU); - // register the awards - ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, eAwardType_Achievement); + // Set the default joypad action mappings for Minecraft + DefineActions(); + InputManager.SetJoypadMapVal(0, 0); + InputManager.SetKeyRepeatRate(0.3f, 0.2f); - ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC1,IDS_CONFIRM_OK); - ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, eAwardType_GamerPic,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_GAMERPIC2,IDS_CONFIRM_OK); + // Initialise the profile manager with the game Title ID, Offer ID, a + // profile version number, and the number of profile values and settings + ProfileManager.Initialise( + TITLEID_MINECRAFT, app.m_dwOfferID, PROFILE_VERSION_10, + NUM_PROFILE_VALUES, NUM_PROFILE_SETTINGS, dwProfileSettingsA, + app.GAME_DEFINED_PROFILE_DATA_BYTES * XUSER_MAX_COUNT, + &app.uiGameDefinedDataChangedBitmask); - ProfileManager.RegisterAward(eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR1,IDS_CONFIRM_OK); - ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR2,IDS_CONFIRM_OK); - ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, eAwardType_AvatarItem,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_AVATAR3,IDS_CONFIRM_OK); + // register the awards + ProfileManager.RegisterAward(eAward_TakingInventory, ACHIEVEMENT_01, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingWood, ACHIEVEMENT_02, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_Benchmarking, ACHIEVEMENT_03, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToMine, ACHIEVEMENT_04, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_HotTopic, ACHIEVEMENT_05, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_AquireHardware, ACHIEVEMENT_06, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToFarm, ACHIEVEMENT_07, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_BakeBread, ACHIEVEMENT_08, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TheLie, ACHIEVEMENT_09, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_GettingAnUpgrade, ACHIEVEMENT_10, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DeliciousFish, ACHIEVEMENT_11, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_OnARail, ACHIEVEMENT_12, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_TimeToStrike, ACHIEVEMENT_13, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MonsterHunter, ACHIEVEMENT_14, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_CowTipper, ACHIEVEMENT_15, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_WhenPigsFly, ACHIEVEMENT_16, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_LeaderOfThePack, ACHIEVEMENT_17, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_MOARTools, ACHIEVEMENT_18, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_DispenseWithThis, ACHIEVEMENT_19, + eAwardType_Achievement); + ProfileManager.RegisterAward(eAward_InToTheNether, ACHIEVEMENT_20, + eAwardType_Achievement); - ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme,false,app.GetStringTable(),IDS_AWARD_TITLE,IDS_AWARD_THEME,IDS_CONFIRM_OK,THEME_NAME,THEME_FILESIZE); + ProfileManager.RegisterAward(eAward_mine100Blocks, GAMER_PICTURE_GAMERPIC1, + eAwardType_GamerPic, false, + app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_GAMERPIC1, IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_kill10Creepers, GAMER_PICTURE_GAMERPIC2, + eAwardType_GamerPic, false, + app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_GAMERPIC2, IDS_CONFIRM_OK); - // Rich Presence init - number of presences, number of contexts - ProfileManager.RichPresenceInit(4,1); - ProfileManager.RegisterRichPresenceContext(CONTEXT_GAME_STATE); + ProfileManager.RegisterAward( + eAward_eatPorkChop, AVATARASSETAWARD_PORKCHOP_TSHIRT, + eAwardType_AvatarItem, false, app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_AVATAR1, IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_play100Days, AVATARASSETAWARD_WATCH, + eAwardType_AvatarItem, false, + app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_AVATAR2, IDS_CONFIRM_OK); + ProfileManager.RegisterAward(eAward_arrowKillCreeper, AVATARASSETAWARD_CAP, + eAwardType_AvatarItem, false, + app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_AVATAR3, IDS_CONFIRM_OK); - app.LoadXuiResources(); + ProfileManager.RegisterAward(eAward_socialPost, 0, eAwardType_Theme, false, + app.GetStringTable(), IDS_AWARD_TITLE, + IDS_AWARD_THEME, IDS_CONFIRM_OK, THEME_NAME, + THEME_FILESIZE); - // initialise the storage manager with a default save display name, a Minimum save size, and a callback for displaying the saving message - StorageManager.Init(app.GetString(IDS_DEFAULT_SAVENAME),"savegame.dat",FIFTY_ONE_MB,&CConsoleMinecraftApp::DisplaySavingMessage,(LPVOID)&app,GROUP_ID); - // Set up the global title storage path - StorageManager.StoreTMSPathName(); + // Rich Presence init - number of presences, number of contexts + ProfileManager.RichPresenceInit(4, 1); + ProfileManager.RegisterRichPresenceContext(CONTEXT_GAME_STATE); - // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out - ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); + app.LoadXuiResources(); - // set a function to be called when the ethernet is disconnected, so we can back out if required - ProfileManager.SetNotificationsCallback(&CConsoleMinecraftApp::NotificationsCallback,(LPVOID)&app); - - // Set a callback for the default player options to be set - when there is no profile data for the player - ProfileManager.SetDefaultOptionsCallback(&CConsoleMinecraftApp::DefaultOptionsCallback,(LPVOID)&app); - // Set a callback to deal with old profile versions needing updated to new versions - ProfileManager.SetOldProfileVersionCallback(&CConsoleMinecraftApp::OldProfileVersionCallback,(LPVOID)&app); + // initialise the storage manager with a default save display name, a + // Minimum save size, and a callback for displaying the saving message + StorageManager.Init( + app.GetString(IDS_DEFAULT_SAVENAME), "savegame.dat", FIFTY_ONE_MB, + &CConsoleMinecraftApp::DisplaySavingMessage, (LPVOID)&app, GROUP_ID); + // Set up the global title storage path + StorageManager.StoreTMSPathName(); - // Set a callback for when there is a read error on profile data - ProfileManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); + // set a function to be called when there's a sign in change, so we can exit + // a level if the primary player signs out + ProfileManager.SetSignInChangeCallback( + &CConsoleMinecraftApp::SignInChangeCallback, (LPVOID)&app); + // set a function to be called when the ethernet is disconnected, so we can + // back out if required + ProfileManager.SetNotificationsCallback( + &CConsoleMinecraftApp::NotificationsCallback, (LPVOID)&app); - // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle - // XN_SYS_SIGNINCHANGED notifications. This does mean that we need to have a callback in the - // ProfileManager for XN_LIVE_INVITE_ACCEPTED for QNet. - g_NetworkManager.Initialise(); + // Set a callback for the default player options to be set - when there is + // no profile data for the player + ProfileManager.SetDefaultOptionsCallback( + &CConsoleMinecraftApp::DefaultOptionsCallback, (LPVOID)&app); + // Set a callback to deal with old profile versions needing updated to new + // versions + ProfileManager.SetOldProfileVersionCallback( + &CConsoleMinecraftApp::OldProfileVersionCallback, (LPVOID)&app); - app.InitGameSettings(); + // Set a callback for when there is a read error on profile data + ProfileManager.SetProfileReadErrorCallback( + &CConsoleMinecraftApp::ProfileReadErrorCallback, (LPVOID)&app); - // debug switch to trial version - ProfileManager.SetDebugFullOverride(true); + // QNet needs to be setup after profile manager, as we do not want its + // Notify listener to handle XN_SYS_SIGNINCHANGED notifications. This does + // mean that we need to have a callback in the ProfileManager for + // XN_LIVE_INVITE_ACCEPTED for QNet. + g_NetworkManager.Initialise(); - //ProfileManager.AddDLC(2); - StorageManager.SetDLCPackageRoot("DLCDrive"); - StorageManager.RegisterMarketplaceCountsCallback(&CConsoleMinecraftApp::MarketplaceCountsCallback,(LPVOID)&app); - // Kinect ! + app.InitGameSettings(); -// if(XNuiGetHardwareStatus()!=0) -// { -// // If the Kinect Sensor is not physically connected, this function returns 0. -// NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | NUI_INITIALIZE_FLAG_USES_DEPTH | -// NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED | NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD ); -// } + // debug switch to trial version + ProfileManager.SetDebugFullOverride(true); - // Sentient ! - hr = TelemetryManager->Init(); + // ProfileManager.AddDLC(2); + StorageManager.SetDLCPackageRoot("DLCDrive"); + StorageManager.RegisterMarketplaceCountsCallback( + &CConsoleMinecraftApp::MarketplaceCountsCallback, (LPVOID)&app); + // Kinect ! - // Initialise TLS for tesselator, for this main thread - Tesselator::CreateNewThreadStorage(1024*1024); - // Initialise TLS for AABB and Vec3 pools, for this main thread - AABB::CreateNewThreadStorage(); - Vec3::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); - Compression::CreateNewThreadStorage(); - OldChunkStorage::CreateNewThreadStorage(); - Level::enableLightingCache(); - Tile::CreateNewThreadStorage(); + // if(XNuiGetHardwareStatus()!=0) + // { + // // If the Kinect Sensor is not physically connected, this + // function returns 0. + // NuiInitialize(NUI_INITIALIZE_FLAG_USES_HIGH_QUALITY_COLOR | + // NUI_INITIALIZE_FLAG_USES_DEPTH | + // NUI_INITIALIZE_FLAG_EXTRAPOLATE_FLOOR_PLANE | + // NUI_INITIALIZE_FLAG_USES_FITNESS | NUI_INITIALIZE_FLAG_NUI_GUIDE_DISABLED + // | + // NUI_INITIALIZE_FLAG_SUPPRESS_AUTOMATIC_UI,NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD + // ); + // } - Minecraft::main(); - Minecraft *pMinecraft=Minecraft::GetInstance(); - //bool bDisplayPauseMenu=false; + // Sentient ! + hr = TelemetryManager->Init(); - // set the default gamma level - float fVal=50.0f*327.68f; - RenderManager.UpdateGamma((unsigned short)fVal); + // Initialise TLS for tesselator, for this main thread + Tesselator::CreateNewThreadStorage(1024 * 1024); + // Initialise TLS for AABB and Vec3 pools, for this main thread + AABB::CreateNewThreadStorage(); + Vec3::CreateNewThreadStorage(); + Compression::CreateNewThreadStorage(); + OldChunkStorage::CreateNewThreadStorage(); + Level::enableLightingCache(); + Tile::CreateNewThreadStorage(); - // load any skins - //app.AddSkinsToMemoryTextureFiles(); + Minecraft::main(); + Minecraft* pMinecraft = Minecraft::GetInstance(); + // bool bDisplayPauseMenu=false; - // set the achievement text for a trial achievement, now we have the string table loaded - ProfileManager.SetTrialTextStringTable(app.GetStringTable(),IDS_CONFIRM_OK, IDS_CONFIRM_CANCEL); - ProfileManager.SetTrialAwardText(eAwardType_Achievement,IDS_UNLOCK_TITLE,IDS_UNLOCK_ACHIEVEMENT_TEXT); - ProfileManager.SetTrialAwardText(eAwardType_GamerPic,IDS_UNLOCK_TITLE,IDS_UNLOCK_GAMERPIC_TEXT); - ProfileManager.SetTrialAwardText(eAwardType_AvatarItem,IDS_UNLOCK_TITLE,IDS_UNLOCK_AVATAR_TEXT); - ProfileManager.SetTrialAwardText(eAwardType_Theme,IDS_UNLOCK_TITLE,IDS_UNLOCK_THEME_TEXT); - ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback,&app); + // set the default gamma level + float fVal = 50.0f * 327.68f; + RenderManager.UpdateGamma((unsigned short)fVal); - // Set up a debug character press sequence + // load any skins + // app.AddSkinsToMemoryTextureFiles(); + + // set the achievement text for a trial achievement, now we have the string + // table loaded + ProfileManager.SetTrialTextStringTable(app.GetStringTable(), IDS_CONFIRM_OK, + IDS_CONFIRM_CANCEL); + ProfileManager.SetTrialAwardText(eAwardType_Achievement, IDS_UNLOCK_TITLE, + IDS_UNLOCK_ACHIEVEMENT_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_GamerPic, IDS_UNLOCK_TITLE, + IDS_UNLOCK_GAMERPIC_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_AvatarItem, IDS_UNLOCK_TITLE, + IDS_UNLOCK_AVATAR_TEXT); + ProfileManager.SetTrialAwardText(eAwardType_Theme, IDS_UNLOCK_TITLE, + IDS_UNLOCK_THEME_TEXT); + ProfileManager.SetUpsellCallback(&app.UpsellReturnedCallback, &app); + + // Set up a debug character press sequence #ifndef _FINAL_BUILD - app.SetDebugSequence("LRLRYYY"); + app.SetDebugSequence("LRLRYYY"); #endif - // Initialise the social networking manager. - CSocialManager::Instance()->Initialise(); + // Initialise the social networking manager. + CSocialManager::Instance()->Initialise(); - // Update the base scene quick selects now that the minecraft class exists - //CXuiSceneBase::UpdateScreenSettings(0); - - app.InitialiseTips(); - - DWORD initData=0; + // Update the base scene quick selects now that the minecraft class exists + // CXuiSceneBase::UpdateScreenSettings(0); + app.InitialiseTips(); + DWORD initData = 0; #ifndef _FINAL_BUILD #ifndef _DEBUG - #pragma message(__LOC__"Need to define the _FINAL_BUILD before submission") +#pragma message(__LOC__ "Need to define the _FINAL_BUILD before submission") #endif #endif - // 4J-PB - Having to add in code to stop people being able to play a build from Partnernet unless they know the code + // 4J-PB - Having to add in code to stop people being able to play a build + // from Partnernet unless they know the code #ifdef _CONTENT_PACKAGE #ifndef _FINAL_BUILD // app.SetPartnernetPasswordRunning(true); -// +// // app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_PartnernetPassword,&initData); -// +// // while(app.PartnernetPasswordRunning()) // { // ProfileManager.Tick(); // InputManager.Tick(); // need to ruin this for the edit box -// +// // // Tick XUI // app.RunFrame(); -// -// // 4J : WESTY : Added to ensure we always have clear background for intro. -// RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255)); +// +// // 4J : WESTY : Added to ensure we always have clear background +// for intro. RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255)); // RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -// +// // // Render XUI // hr = app.Render(); -// +// // // Present the frame. // RenderManager.Present(); -// +// // // Update XUI Timers // hr = XuiTimersRun(); // } #endif #endif - // Set the default sound levels - pMinecraft->options->set(Options::Option::MUSIC,1.0f); - pMinecraft->options->set(Options::Option::SOUND,1.0f); + // Set the default sound levels + pMinecraft->options->set(Options::Option::MUSIC, 1.0f); + pMinecraft->options->set(Options::Option::SOUND, 1.0f); - app.NavigateToScene(XUSER_INDEX_ANY,eUIScene_Intro,&initData); + app.NavigateToScene(XUSER_INDEX_ANY, eUIScene_Intro, &initData); - //Sleep(10000); - - // Intro loop ? - while(app.IntroRunning()) - { - ProfileManager.Tick(); - // Tick XUI - app.RunFrame(); + // Sleep(10000); - // 4J : WESTY : Added to ensure we always have clear background for intro. - RenderManager.SetClearColour(D3DCOLOR_RGBA(0,0,0,255)); - RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + // Intro loop ? + while (app.IntroRunning()) { + ProfileManager.Tick(); + // Tick XUI + app.RunFrame(); - // Render XUI - hr = app.Render(); + // 4J : WESTY : Added to ensure we always have clear background for + // intro. + RenderManager.SetClearColour(D3DCOLOR_RGBA(0, 0, 0, 255)); + RenderManager.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - // Present the frame. - RenderManager.Present(); + // Render XUI + hr = app.Render(); - // Update XUI Timers - hr = XuiTimersRun(); - } + // Present the frame. + RenderManager.Present(); - while( TRUE ) - { - if(pMinecraft->soundEngine->isStreamingWavebankReady() && - !pMinecraft->soundEngine->GetIsPlayingStreamingGameMusic() && - !pMinecraft->soundEngine->GetIsPlayingStreamingCDMusic() ) - { - // play some music in the menus - pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); - } - app.UpdateTime(); - PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Profile manager tick"); - ProfileManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Storage manager tick"); - StorageManager.Tick(); - PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Render manager tick"); - RenderManager.Tick(); - PIXEndNamedEvent(); + // Update XUI Timers + hr = XuiTimersRun(); + } - // Tick the social networking manager. - PIXBeginNamedEvent(0,"Social network manager tick"); - CSocialManager::Instance()->Tick(); - PIXEndNamedEvent(); - - // Tick sentient. - PIXBeginNamedEvent(0,"Sentient tick"); - MemSect(37); - TelemetryManager->Tick(); - MemSect(0); - PIXEndNamedEvent(); + while (TRUE) { + if (pMinecraft->soundEngine->isStreamingWavebankReady() && + !pMinecraft->soundEngine->GetIsPlayingStreamingGameMusic() && + !pMinecraft->soundEngine->GetIsPlayingStreamingCDMusic()) { + // play some music in the menus + pMinecraft->soundEngine->playStreaming(L"", 0, 0, 0, 0, 0, false); + } + app.UpdateTime(); + PIXBeginNamedEvent(0, "Input manager tick"); + InputManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Profile manager tick"); + ProfileManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Storage manager tick"); + StorageManager.Tick(); + PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Render manager tick"); + RenderManager.Tick(); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #1"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + // Tick the social networking manager. + PIXBeginNamedEvent(0, "Social network manager tick"); + CSocialManager::Instance()->Tick(); + PIXEndNamedEvent(); - LeaderboardManager::Instance()->Tick(); - // Render game graphics. - if(app.GetGameStarted()) - { - pMinecraft->run_middle(); - app.SetAppPaused( g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1 && app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad()) ); - } - else - { - MemSect(28); - pMinecraft->soundEngine->tick(NULL, 0.0f); - MemSect(0); - pMinecraft->textures->tick(true,false); - IntCache::Reset(); - if( app.GetReallyChangingSessionType() ) - { - pMinecraft->tickAllConnections(); // Added to stop timing out when we are waiting after converting to an offline game - } - } + // Tick sentient. + PIXBeginNamedEvent(0, "Sentient tick"); + MemSect(37); + TelemetryManager->Tick(); + MemSect(0); + PIXEndNamedEvent(); - pMinecraft->soundEngine->playMusicTick(); + PIXBeginNamedEvent(0, "Network manager do work #1"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); + LeaderboardManager::Instance()->Tick(); + // Render game graphics. + if (app.GetGameStarted()) { + pMinecraft->run_middle(); + app.SetAppPaused( + g_NetworkManager.IsLocalGame() && + g_NetworkManager.GetPlayerCount() == 1 && + app.IsPauseMenuDisplayed(ProfileManager.GetPrimaryPad())); + } else { + MemSect(28); + pMinecraft->soundEngine->tick(NULL, 0.0f); + MemSect(0); + pMinecraft->textures->tick(true, false); + if (app.GetReallyChangingSessionType()) { + pMinecraft + ->tickAllConnections(); // Added to stop timing out when we + // are waiting after converting to + // an offline game + } + } + + pMinecraft->soundEngine->playMusicTick(); #ifdef MEMORY_TRACKING - static bool bResetMemTrack = false; - static bool bDumpMemTrack = false; + static bool bResetMemTrack = false; + static bool bDumpMemTrack = false; - MemPixStuff(); + MemPixStuff(); - if( bResetMemTrack ) - { - ResetMem(); - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("RESETMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - bResetMemTrack = false; - } + if (bResetMemTrack) { + ResetMem(); + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("RESETMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + bResetMemTrack = false; + } - if( bDumpMemTrack ) - { - DumpMem(); - bDumpMemTrack = false; - MEMORYSTATUS memStat; - GlobalMemoryStatus(&memStat); - printf("DUMPMEM: Avail. phys %d\n",memStat.dwAvailPhys/(1024*1024)); - printf("Renderer used: %d\n",RenderManager.CBuffSize(-1)); - } + if (bDumpMemTrack) { + DumpMem(); + bDumpMemTrack = false; + MEMORYSTATUS memStat; + GlobalMemoryStatus(&memStat); + printf("DUMPMEM: Avail. phys %d\n", + memStat.dwAvailPhys / (1024 * 1024)); + printf("Renderer used: %d\n", RenderManager.CBuffSize(-1)); + } #endif #if 0 static bool bDumpTextureUsage = false; @@ -718,177 +906,165 @@ int __cdecl main() } #endif - app.HandleButtonPresses(); + app.HandleButtonPresses(); - // store the minecraft renderstates, and re-set them after the xui render - GetRenderAndSamplerStates(pDevice,RenderStateA,SamplerStateA); + // store the minecraft renderstates, and re-set them after the xui + // render + GetRenderAndSamplerStates(pDevice, RenderStateA, SamplerStateA); - // Tick XUI - PIXBeginNamedEvent(0,"Xui running"); - app.RunFrame(); - PIXEndNamedEvent(); + // Tick XUI + PIXBeginNamedEvent(0, "Xui running"); + app.RunFrame(); + PIXEndNamedEvent(); - // Render XUI + // Render XUI - PIXBeginNamedEvent(0,"XUI render"); - MemSect(7); - hr = app.Render(); - MemSect(0); - GetRenderAndSamplerStates(pDevice,RenderStateA2,SamplerStateA2); - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "XUI render"); + MemSect(7); + hr = app.Render(); + MemSect(0); + GetRenderAndSamplerStates(pDevice, RenderStateA2, SamplerStateA2); + PIXEndNamedEvent(); - for(int i=0;i<8;i++) - { - if(RenderStateA2[i]!=RenderStateA[i]) - { - //printf("Reseting RenderStateA[%d] after a XUI render\n",i); - pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); - } - } - for(int i=0;i<5;i++) - { - if(SamplerStateA2[i]!=SamplerStateA[i]) - { - //printf("Reseting SamplerStateA[%d] after a XUI render\n",i); - pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); - } - } + for (int i = 0; i < 8; i++) { + if (RenderStateA2[i] != RenderStateA[i]) { + // printf("Reseting RenderStateA[%d] after a XUI render\n",i); + pDevice->SetRenderState(RenderStateModes[i], RenderStateA[i]); + } + } + for (int i = 0; i < 5; i++) { + if (SamplerStateA2[i] != SamplerStateA[i]) { + // printf("Reseting SamplerStateA[%d] after a XUI render\n",i); + pDevice->SetSamplerState(0, SamplerStateModes[i], + SamplerStateA[i]); + } + } - RenderManager.Set_matrixDirty(); - // Present the frame. - PIXBeginNamedEvent(0,"Frame present"); - RenderManager.Present(); - PIXEndNamedEvent(); + RenderManager.Set_matrixDirty(); + // Present the frame. + PIXBeginNamedEvent(0, "Frame present"); + RenderManager.Present(); + PIXEndNamedEvent(); - app.CheckMenuDisplayed(); - PIXBeginNamedEvent(0,"Profile load check"); - // has the game defined profile data been changed (by a profile load) - if(app.uiGameDefinedDataChangedBitmask!=0) - { - void *pData; - for(int i=0;istats[ i ]->clear(); - pMinecraft->stats[i]->parse(pData); + // clear the stats first - there could have beena signout + // and sign back in in the menus need to clear the player + // stats - can't assume it'll be done in setlevel - we may + // not be in the game + pMinecraft->stats[i]->clear(); + pMinecraft->stats[i]->parse(pData); - // Update the selected item position based on the user's UI setting - CXuiSceneBase::UpdateSelectedItemPos(i); - } - } + // Update the selected item position based on the user's UI + // setting + CXuiSceneBase::UpdateSelectedItemPos(i); + } + } - // Check to see if we can post to social networks. - CSocialManager::Instance()->RefreshPostingCapability(); + // Check to see if we can post to social networks. + CSocialManager::Instance()->RefreshPostingCapability(); - // clear the flag - app.uiGameDefinedDataChangedBitmask=0; + // clear the flag + app.uiGameDefinedDataChangedBitmask = 0; - // Check if any profile write are needed - app.CheckGameSettingsChanged(); + // Check if any profile write are needed + app.CheckGameSettingsChanged(); + } + PIXEndNamedEvent(); + app.TickDLCOffersRetrieved(); + app.TickTMSPPFilesRetrieved(); - } - PIXEndNamedEvent(); - app.TickDLCOffersRetrieved(); - app.TickTMSPPFilesRetrieved(); + PIXBeginNamedEvent(0, "Network manager do work #2"); + g_NetworkManager.DoWork(); + PIXEndNamedEvent(); - PIXBeginNamedEvent(0,"Network manager do work #2"); - g_NetworkManager.DoWork(); - PIXEndNamedEvent(); + PIXBeginNamedEvent(0, "Misc extra xui"); + // Update XUI Timers + hr = XuiTimersRun(); - PIXBeginNamedEvent(0,"Misc extra xui"); - // Update XUI Timers - hr = XuiTimersRun(); + // Any threading type things to deal with from the xui side? + app.HandleXuiActions(); + PIXEndNamedEvent(); - // Any threading type things to deal with from the xui side? - app.HandleXuiActions(); - PIXEndNamedEvent(); + // 4J-PB - Update the trial timer display if we are in the trial version + if (!ProfileManager.IsFullVersion()) { + // display the trial timer + if (app.GetGameStarted()) { + // 4J-PB - if the game is paused, add the elapsed time to the + // trial timer count so it doesn't tick down + if (app.IsAppPaused()) { + app.UpdateTrialPausedTimer(); + } + CXuiSceneBase::UpdateTrialTimer(ProfileManager.GetPrimaryPad()); + } + } else { + // need to turn off the trial timer if it was on , and we've + // unlocked the full version + if (bTrialTimerDisplayed) { + CXuiSceneBase::ShowTrialTimer(FALSE); + bTrialTimerDisplayed = false; + } + } - // 4J-PB - Update the trial timer display if we are in the trial version - if(!ProfileManager.IsFullVersion()) - { - // display the trial timer - if(app.GetGameStarted()) - { - // 4J-PB - if the game is paused, add the elapsed time to the trial timer count so it doesn't tick down - if(app.IsAppPaused()) - { - app.UpdateTrialPausedTimer(); - } - CXuiSceneBase::UpdateTrialTimer(ProfileManager.GetPrimaryPad()); - } - } - else - { - // need to turn off the trial timer if it was on , and we've unlocked the full version - if(bTrialTimerDisplayed) - { - CXuiSceneBase::ShowTrialTimer(FALSE); - bTrialTimerDisplayed=false; - } - } + // Fix for #7318 - Title crashes after short soak in the leaderboards + // menu A memory leak was caused because the icon renderer kept creating + // new Vec3's because the pool wasn't reset + Vec3::resetPool(); + } - // Fix for #7318 - Title crashes after short soak in the leaderboards menu - // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset - Vec3::resetPool(); - } - - // Free resources, unregister custom classes, and exit. - app.Uninit(); - pDevice->Release(); + // Free resources, unregister custom classes, and exit. + app.Uninit(); + pDevice->Release(); } +void GetRenderAndSamplerStates(IDirect3DDevice9* pDevice, DWORD* RenderStateA, + DWORD* SamplerStateA) { + for (int i = 0; i < 8; i++) { + pDevice->GetRenderState(RenderStateModes[i], &RenderStateA[i]); + } -void GetRenderAndSamplerStates(IDirect3DDevice9 *pDevice,DWORD *RenderStateA,DWORD *SamplerStateA) -{ - for(int i=0;i<8;i++) - { - pDevice->GetRenderState(RenderStateModes[i],&RenderStateA[i]); - } - - for(int i=0;i<5;i++) - { - pDevice->GetSamplerState(0,SamplerStateModes[i],&SamplerStateA[i]); - } + for (int i = 0; i < 5; i++) { + pDevice->GetSamplerState(0, SamplerStateModes[i], &SamplerStateA[i]); + } } -void SetRenderAndSamplerStates(IDirect3DDevice9 *pDevice,DWORD *RenderStateA,DWORD *SamplerStateA) -{ - for(int i=0;i<8;i++) - { - pDevice->SetRenderState(RenderStateModes[i],RenderStateA[i]); - } +void SetRenderAndSamplerStates(IDirect3DDevice9* pDevice, DWORD* RenderStateA, + DWORD* SamplerStateA) { + for (int i = 0; i < 8; i++) { + pDevice->SetRenderState(RenderStateModes[i], RenderStateA[i]); + } - for(int i=0;i<5;i++) - { - pDevice->SetSamplerState(0,SamplerStateModes[i],SamplerStateA[i]); - } + for (int i = 0; i < 5; i++) { + pDevice->SetSamplerState(0, SamplerStateModes[i], SamplerStateA[i]); + } } #ifdef MEMORY_TRACKING int totalAllocGen = 0; -std::unordered_map allocCounts; +std::unordered_map allocCounts; bool trackEnable = false; bool trackStarted = false; volatile size_t sizeCheckMin = 1160; @@ -897,181 +1073,159 @@ volatile int sectCheck = 48; CRITICAL_SECTION memCS; DWORD tlsIdx; -LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) -{ - if( !trackStarted ) - { - void *p = XMemAllocDefault(dwSize,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p, dwAllocAttributes); - totalAllocGen += realSize; - return p; - } +LPVOID XMemAlloc(SIZE_T dwSize, DWORD dwAllocAttributes) { + if (!trackStarted) { + void* p = XMemAllocDefault(dwSize, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes); + totalAllocGen += realSize; + return p; + } - EnterCriticalSection(&memCS); + EnterCriticalSection(&memCS); - void *p=XMemAllocDefault(dwSize + 16,dwAllocAttributes); - size_t realSize = XMemSizeDefault(p,dwAllocAttributes) - 16; + void* p = XMemAllocDefault(dwSize + 16, dwAllocAttributes); + size_t realSize = XMemSizeDefault(p, dwAllocAttributes) - 16; - if( trackEnable ) - { + if (trackEnable) { #if 1 - int sect = ((int) TlsGetValue(tlsIdx)) & 0x3f; - *(((unsigned char *)p)+realSize) = sect; + int sect = ((int)TlsGetValue(tlsIdx)) & 0x3f; + *(((unsigned char*)p) + realSize) = sect; - if( ( realSize >= sizeCheckMin ) && ( realSize <= sizeCheckMax ) && ( ( sect == sectCheck ) || ( sectCheck == -1 ) ) ) - { - app.DebugPrintf("Found one\n"); - } + if ((realSize >= sizeCheckMin) && (realSize <= sizeCheckMax) && + ((sect == sectCheck) || (sectCheck == -1))) { + app.DebugPrintf("Found one\n"); + } #endif - if( p ) - { - totalAllocGen += realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount + 1; + if (p) { + totalAllocGen += realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount + 1; - trackEnable = true; - } - } - - LeaveCriticalSection(&memCS); + trackEnable = true; + } + } - return p; + LeaveCriticalSection(&memCS); + + return p; } -void* operator new (size_t size) -{ - return (unsigned char *)XMemAlloc(size,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void* operator new(size_t size) { + return (unsigned char*)XMemAlloc( + size, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void operator delete (void *p) -{ - XMemFree(p,MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP)); +void operator delete(void* p) { + XMemFree(p, MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP)); } -void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) -{ - bool special = false; - if( dwAllocAttributes == 0 ) - { - dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES(0,FALSE,TRUE,FALSE,0,XALLOC_PHYSICAL_ALIGNMENT_DEFAULT,XALLOC_MEMPROTECT_READWRITE,FALSE,XALLOC_MEMTYPE_HEAP); - special = true; - } - if(!trackStarted ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); - XMemFreeDefault(pAddress, dwAllocAttributes); - totalAllocGen -= realSize; - return; - } - EnterCriticalSection(&memCS); - if( pAddress ) - { - size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - - if(trackEnable) - { - int sect = *(((unsigned char *)pAddress)+realSize); - totalAllocGen -= realSize; - trackEnable = false; - int key = ( sect << 26 ) | realSize; - int oldCount = allocCounts[key]; - allocCounts[key] = oldCount - 1; - trackEnable = true; +void WINAPI XMemFree(PVOID pAddress, DWORD dwAllocAttributes) { + bool special = false; + if (dwAllocAttributes == 0) { + dwAllocAttributes = MAKE_XALLOC_ATTRIBUTES( + 0, FALSE, TRUE, FALSE, 0, XALLOC_PHYSICAL_ALIGNMENT_DEFAULT, + XALLOC_MEMPROTECT_READWRITE, FALSE, XALLOC_MEMTYPE_HEAP); + special = true; + } + if (!trackStarted) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes); + XMemFreeDefault(pAddress, dwAllocAttributes); + totalAllocGen -= realSize; + return; + } + EnterCriticalSection(&memCS); + if (pAddress) { + size_t realSize = XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - XMemFreeDefault(pAddress, dwAllocAttributes); - } - LeaveCriticalSection(&memCS); + if (trackEnable) { + int sect = *(((unsigned char*)pAddress) + realSize); + totalAllocGen -= realSize; + trackEnable = false; + int key = (sect << 26) | realSize; + int oldCount = allocCounts[key]; + allocCounts[key] = oldCount - 1; + trackEnable = true; + } + XMemFreeDefault(pAddress, dwAllocAttributes); + } + LeaveCriticalSection(&memCS); } -SIZE_T WINAPI XMemSize( - PVOID pAddress, - DWORD dwAllocAttributes -) -{ - if( trackStarted ) - { - return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; - } - else - { - return XMemSizeDefault(pAddress, dwAllocAttributes); - } +SIZE_T WINAPI XMemSize(PVOID pAddress, DWORD dwAllocAttributes) { + if (trackStarted) { + return XMemSizeDefault(pAddress, dwAllocAttributes) - 16; + } else { + return XMemSizeDefault(pAddress, dwAllocAttributes); + } } - -void DumpMem() -{ - int totalLeak = 0; - for(auto it = allocCounts.begin(); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - app.DebugPrintf("%d %d %d %d\n",( it->first >> 26 ) & 0x3f,it->first & 0x03ffffff, it->second, (it->first & 0x03ffffff) * it->second); - totalLeak += ( it->first & 0x03ffffff ) * it->second; - } - } - app.DebugPrintf("Total %d\n",totalLeak); +void DumpMem() { + int totalLeak = 0; + for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) { + if (it->second > 0) { + app.DebugPrintf("%d %d %d %d\n", (it->first >> 26) & 0x3f, + it->first & 0x03ffffff, it->second, + (it->first & 0x03ffffff) * it->second); + totalLeak += (it->first & 0x03ffffff) * it->second; + } + } + app.DebugPrintf("Total %d\n", totalLeak); } -void ResetMem() -{ - if( !trackStarted ) - { - trackEnable = true; - trackStarted = true; - totalAllocGen = 0; - InitializeCriticalSection(&memCS); - tlsIdx = TlsAlloc(); - } - EnterCriticalSection(&memCS); - trackEnable = false; - allocCounts.clear(); - trackEnable = true; - LeaveCriticalSection(&memCS); +void ResetMem() { + if (!trackStarted) { + trackEnable = true; + trackStarted = true; + totalAllocGen = 0; + InitializeCriticalSection(&memCS); + tlsIdx = TlsAlloc(); + } + EnterCriticalSection(&memCS); + trackEnable = false; + allocCounts.clear(); + trackEnable = true; + LeaveCriticalSection(&memCS); } -void MemSect(int section) -{ - unsigned int value = (unsigned int)TlsGetValue(tlsIdx); - if( section == 0 ) // pop - { - value = (value >> 6) & 0x03ffffff; - } - else - { - value = (value << 6) | section; - } - TlsSetValue(tlsIdx, (LPVOID)value); +void MemSect(int section) { + unsigned int value = (unsigned int)TlsGetValue(tlsIdx); + if (section == 0) // pop + { + value = (value >> 6) & 0x03ffffff; + } else { + value = (value << 6) | section; + } + TlsSetValue(tlsIdx, (LPVOID)value); } -void MemPixStuff() -{ - const int MAX_SECT = 56; +void MemPixStuff() { + const int MAX_SECT = 56; - int totals[MAX_SECT] = {0}; + int totals[MAX_SECT] = {0}; - for(auto it = allocCounts.begin(); it != allocCounts.end(); it++ ) - { - if(it->second > 0 ) - { - int sect = ( it->first >> 26 ) & 0x3f; - int bytes = it->first & 0x03ffffff; - totals[sect] += bytes * it->second; - } - } + for (auto it = allocCounts.begin(); it != allocCounts.end(); it++) { + if (it->second > 0) { + int sect = (it->first >> 26) & 0x3f; + int bytes = it->first & 0x03ffffff; + totals[sect] += bytes * it->second; + } + } - unsigned int allSectsTotal = 0; - for( int i = 0; i < MAX_SECT; i++ ) - { - allSectsTotal += totals[i]; - PIXAddNamedCounter(((float)totals[i])/1024.0f,"MemSect%d",i); - } + unsigned int allSectsTotal = 0; + for (int i = 0; i < MAX_SECT; i++) { + allSectsTotal += totals[i]; + PIXAddNamedCounter(((float)totals[i]) / 1024.0f, "MemSect%d", i); + } - PIXAddNamedCounter(((float)allSectsTotal)/(4096.0f),"MemSect total pages"); + PIXAddNamedCounter(((float)allSectsTotal) / (4096.0f), + "MemSect total pages"); } #endif diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 682f02d33..9455cc252 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -36,7 +36,6 @@ #include "../../Minecraft.World/Util/JavaMath.h" #include "../../Minecraft.World/Util/Facing.h" #include "../../Minecraft.World/Entities/MobEffect.h" -#include "../../Minecraft.World/Util/IntCache.h" #include "../../Minecraft.World/Util/SmoothFloat.h" #include "../../Minecraft.World/Entities/MobEffectInstance.h" #include "../../Minecraft.World/Items/Item.h" @@ -351,7 +350,7 @@ void GameRenderer::pick(float a) { if (nearest < dist || (mc->hitResult == NULL)) { if (mc->hitResult != NULL) delete mc->hitResult; mc->hitResult = new HitResult(hovered); - if (hovered->instanceof (eTYPE_LIVINGENTITY)) { + if (hovered->instanceof(eTYPE_LIVINGENTITY)) { mc->crosshairPickMob = std::dynamic_pointer_cast(hovered); } @@ -424,7 +423,7 @@ void GameRenderer::bobHurt(float a) { } void GameRenderer::bobView(float a) { - if (!mc->cameraTargetPlayer->instanceof (eTYPE_LIVINGENTITY)) return; + if (!mc->cameraTargetPlayer->instanceof(eTYPE_LIVINGENTITY)) return; std::shared_ptr player = std::dynamic_pointer_cast(mc->cameraTargetPlayer); @@ -673,8 +672,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { // 4J-JEV: I'm fairly confident this method would crash if the cameratarget // isnt a local player anyway, but oh well. std::shared_ptr localplayer = - mc->cameraTargetPlayer->instanceof - (eTYPE_LOCALPLAYER) + mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER) ? std::dynamic_pointer_cast(mc->cameraTargetPlayer) : nullptr; @@ -807,9 +805,8 @@ void GameRenderer::turnOnLightLayer( static int logCount = 0; if (logCount < 16) { ++logCount; - app.DebugPrintf( - "[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n", textureId, - scaleLight ? 1 : 0); + app.DebugPrintf("[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n", + textureId, scaleLight ? 1 : 0); } RenderManager.TextureBindVertex(textureId, scaleLight); @@ -1118,7 +1115,6 @@ int GameRenderer::runUpdate(void* lpParam) { Minecraft* minecraft = Minecraft::GetInstance(); Vec3::CreateNewThreadStorage(); AABB::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); Tesselator::CreateNewThreadStorage(1024 * 1024); Compression::UseDefaultThreadStorage(); RenderManager.InitialiseContext(); @@ -1199,7 +1195,6 @@ int GameRenderer::runUpdate(void* lpParam) { AABB::resetPool(); Vec3::resetPool(); - IntCache::Reset(); m_updateEvents->Set(eUpdateEventIsFinished); } @@ -1254,7 +1249,9 @@ void GameRenderer::renderLevel(float a, int64_t until) { // if (mc->cameraTargetPlayer == NULL) // 4J - removed condition as we // want to update this is mc->player changes for different local players - { mc->cameraTargetPlayer = mc->player; } + { + mc->cameraTargetPlayer = mc->player; + } pick(a); std::shared_ptr cameraEntity = mc->cameraTargetPlayer; @@ -1394,9 +1391,9 @@ void GameRenderer::renderLevel(float a, int64_t until) { turnOffLightLayer(a); // 4J - brought forward from 1.8.2 if ((mc->hitResult != NULL) && - cameraEntity->isUnderLiquid(Material::water) && - cameraEntity->instanceof - (eTYPE_PLAYER)) //&& !mc->options.hideGui) + cameraEntity->isUnderLiquid(Material::water) && + cameraEntity->instanceof( + eTYPE_PLAYER)) //&& !mc->options.hideGui) { std::shared_ptr player = std::dynamic_pointer_cast(cameraEntity); @@ -1472,8 +1469,8 @@ void GameRenderer::renderLevel(float a, int64_t until) { glEnable(GL_CULL_FACE); glDisable(GL_BLEND); - if ((zoom == 1) && cameraEntity->instanceof - (eTYPE_PLAYER)) //&& !mc->options.hideGui) + if ((zoom == 1) && + cameraEntity->instanceof(eTYPE_PLAYER)) //&& !mc->options.hideGui) { if (mc->hitResult != NULL && !cameraEntity->isUnderLiquid(Material::water)) { @@ -2008,7 +2005,7 @@ void GameRenderer::setupFog(int i, float alpha) { // 4J - check for creative mode brought forward from 1.2.3 bool creative = false; - if (player->instanceof (eTYPE_PLAYER)) { + if (player->instanceof(eTYPE_PLAYER)) { creative = (std::dynamic_pointer_cast(player))->abilities.instabuild; } diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 8954abb32..313922573 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -42,7 +42,6 @@ #include "../GameState/Options.h" #include "../Network/MultiPlayerChunkCache.h" #include "../../Minecraft.World/Util/ParticleTypes.h" -#include "../../Minecraft.World/Util/IntCache.h" #include "../../Minecraft.World/IO/Streams/IntBuffer.h" #include "../../Minecraft.World/Util/JavaMath.h" #include "../../Minecraft.World/Headers/net.minecraft.world.level.h" @@ -586,7 +585,7 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { (entity->noCulling || culler->isVisible(entity->bb))); // Render the mob if the mob's leash holder is within the culler - if (!shouldRender && entity->instanceof (eTYPE_MOB)) { + if (!shouldRender && entity->instanceof(eTYPE_MOB)) { std::shared_ptr mob = std::dynamic_pointer_cast(entity); if (mob->isLeashed() && (mob->getLeashHolder() != NULL)) { std::shared_ptr leashHolder = mob->getLeashHolder(); @@ -600,10 +599,10 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { // !mc->options->thirdPersonView && // !mc->cameraTargetPlayer->isSleeping()) continue; std::shared_ptr localplayer = - mc->cameraTargetPlayer->instanceof - (eTYPE_LOCALPLAYER) ? std::dynamic_pointer_cast( - mc->cameraTargetPlayer) - : nullptr; + mc->cameraTargetPlayer->instanceof(eTYPE_LOCALPLAYER) + ? std::dynamic_pointer_cast( + mc->cameraTargetPlayer) + : nullptr; if (localplayer && entity == mc->cameraTargetPlayer && !localplayer->ThirdPersonView() && @@ -1198,7 +1197,7 @@ void LevelRenderer::renderSky(float alpha) { // 4J - can't work out what this big black box is for. Taking it out // until someone misses it... it causes a big black box to visible // appear in 3rd person mode whilst under the ground. -#if 0 +#if 0 float ss = 1; float yo = -(float) (yy + 65); float y0 = -ss; @@ -2748,7 +2747,9 @@ void LevelRenderer::cull_SPU(int playerIndex, Culler* culler, float a) { m_jobPort_CullSPU->submitSync(); // static int doSort = false; // if(doSort) - { m_jobPort_CullSPU->submitJob(&sortJob); } + { + m_jobPort_CullSPU->submitJob(&sortJob); + } // doSort ^= 1; m_bSPUCullStarted[playerIndex] = true; } @@ -3221,7 +3222,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( } void LevelRenderer::entityAdded(std::shared_ptr entity) { - if (entity->instanceof (eTYPE_PLAYER)) { + if (entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(entity); player->prepareCustomTextures(); @@ -3239,7 +3240,7 @@ void LevelRenderer::entityAdded(std::shared_ptr entity) { } void LevelRenderer::entityRemoved(std::shared_ptr entity) { - if (entity->instanceof (eTYPE_PLAYER)) { + if (entity->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(entity); if (player->customTextureUrl != L"") { @@ -4040,7 +4041,6 @@ void LevelRenderer::staticCtor() { int LevelRenderer::rebuildChunkThreadProc(void* lpParam) { Vec3::CreateNewThreadStorage(); AABB::CreateNewThreadStorage(); - IntCache::CreateNewThreadStorage(); Tesselator::CreateNewThreadStorage(1024 * 1024); RenderManager.InitialiseContext(); Chunk::CreateNewThreadStorage(); diff --git a/Minecraft.World/Headers/net.minecraft.world.level.newbiome.layer.h b/Minecraft.World/Headers/net.minecraft.world.level.newbiome.layer.h index 67dc6da9e..c77578b3d 100644 --- a/Minecraft.World/Headers/net.minecraft.world.level.newbiome.layer.h +++ b/Minecraft.World/Headers/net.minecraft.world.level.newbiome.layer.h @@ -8,7 +8,6 @@ #include "../WorldGen/Layers/DownfallMixerLayer.h" #include "../WorldGen/Layers/FlatLayer.h" #include "../WorldGen/Layers/FuzzyZoomLayer.h" -#include "../Util/IntCache.h" #include "../WorldGen/Layers/IslandLayer.h" #include "../WorldGen/Layers/Layer.h" #include "../WorldGen/Layers/RiverInitLayer.h" @@ -25,4 +24,4 @@ // 1.1. #include "../WorldGen/Layers/RegionHillsLayer.h" -#include "../WorldGen/Layers/SwampRiversLayer.h" \ No newline at end of file +#include "../WorldGen/Layers/SwampRiversLayer.h" diff --git a/Minecraft.World/Util/IntCache.cpp b/Minecraft.World/Util/IntCache.cpp deleted file mode 100644 index 439dccecc..000000000 --- a/Minecraft.World/Util/IntCache.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "../Platform/stdafx.h" -#include "IntCache.h" - -unsigned int IntCache::tlsIdx = TlsAlloc(); - -void IntCache::CreateNewThreadStorage() { - ThreadStorage* tls = new ThreadStorage(); - TlsSetValue(tlsIdx, (void*)tls); - tls->maxSize = TINY_CUTOFF; -} - -IntCache::ThreadStorage::~ThreadStorage() { - for (unsigned int i = 0; i < tcache.size(); i++) { - delete[] tcache[i].data; - } - for (unsigned int i = 0; i < tallocated.size(); i++) { - delete[] tallocated[i].data; - } - for (unsigned int i = 0; i < cache.size(); i++) { - delete[] cache[i].data; - } - for (unsigned int i = 0; i < allocated.size(); i++) { - delete[] allocated[i].data; - } - for (int i = 0; i < toosmall.size(); i++) { - delete[] toosmall[i].data; - } -} - -void IntCache::ReleaseThreadStorage() { - ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx); - - delete tls; -} - -intArray IntCache::allocate(int size) { - ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx); - - if (size <= TINY_CUTOFF) { - if (tls->tcache.empty()) { - intArray result = intArray(TINY_CUTOFF, true); - tls->tallocated.push_back(result); - return result; - } else { - intArray result = tls->tcache.back(); - tls->tcache.pop_back(); - tls->tallocated.push_back(result); - return result; - } - } - - if (size > tls->maxSize) { - // app.DebugPrintf("IntCache: New max size: %d\n" , size); - tls->maxSize = size; - - // 4J - added - all the vectors in cache & allocated are smaller than - // maxSize so should be discarded. However, we can't delete them until - // the next releaseAll so copy into another vector until then - tls->toosmall.insert(tls->toosmall.end(), tls->cache.begin(), - tls->cache.end()); - tls->toosmall.insert(tls->toosmall.end(), tls->allocated.begin(), - tls->allocated.end()); - - tls->cache.clear(); - tls->allocated.clear(); - - intArray result = intArray(tls->maxSize, true); - tls->allocated.push_back(result); - return result; - } else { - if (tls->cache.empty()) { - intArray result = intArray(tls->maxSize, true); - tls->allocated.push_back(result); - return result; - } else { - intArray result = tls->cache.back(); - tls->cache.pop_back(); - tls->allocated.push_back(result); - return result; - } - } -} - -void IntCache::releaseAll() { - ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx); - - // 4J - added - we can now remove the vectors that were deemed as too small - // (see comment in IntCache::allocate) - for (int i = 0; i < tls->toosmall.size(); i++) { - delete[] tls->toosmall[i].data; - } - tls->toosmall.clear(); - - if (!tls->cache.empty()) { - delete[] tls->cache.back().data; - tls->cache.pop_back(); - } - if (!tls->tcache.empty()) { - delete[] tls->tcache.back().data; - tls->tcache.pop_back(); - } - - tls->cache.insert(tls->cache.end(), tls->allocated.begin(), - tls->allocated.end()); - tls->tcache.insert(tls->tcache.end(), tls->tallocated.begin(), - tls->tallocated.end()); - - tls->allocated.clear(); - tls->tallocated.clear(); -} - -// 4J added so that we can fully reset between levels -void IntCache::Reset() { - ThreadStorage* tls = (ThreadStorage*)TlsGetValue(tlsIdx); - tls->maxSize = TINY_CUTOFF; - for (int i = 0; i < tls->allocated.size(); i++) { - delete[] tls->allocated[i].data; - } - tls->allocated.clear(); - - for (int i = 0; i < tls->cache.size(); i++) { - delete[] tls->cache[i].data; - } - tls->cache.clear(); - - for (int i = 0; i < tls->tallocated.size(); i++) { - delete[] tls->tallocated[i].data; - } - tls->tallocated.clear(); - - for (int i = 0; i < tls->tcache.size(); i++) { - delete[] tls->tcache[i].data; - } - tls->tcache.clear(); - - for (int i = 0; i < tls->toosmall.size(); i++) { - delete[] tls->toosmall[i].data; - } - tls->toosmall.clear(); -} diff --git a/Minecraft.World/Util/IntCache.h b/Minecraft.World/Util/IntCache.h deleted file mode 100644 index 4654d4f3c..000000000 --- a/Minecraft.World/Util/IntCache.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include "ArrayWithLength.h" - -class IntCache { -private: - class ThreadStorage { - public: - int maxSize; - - std::vector tcache; - std::vector tallocated; - - std::vector cache; - std::vector allocated; - std::vector toosmall; // 4J added - ~ThreadStorage(); - }; - static unsigned int tlsIdx; - - static const int TINY_CUTOFF = 256; - -public: - static intArray allocate(int size); - static void releaseAll(); - - static void CreateNewThreadStorage(); - static void ReleaseThreadStorage(); - static void Reset(); // 4J added -}; diff --git a/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp b/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp index 0cffcecec..8d05b2cad 100644 --- a/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp +++ b/Minecraft.World/WorldGen/Biomes/BiomeSource.cpp @@ -75,7 +75,6 @@ floatArray BiomeSource::getDownfallBlock(int x, int z, int w, int h) const { // downfall layers brought forward from 1.2.3 void BiomeSource::getDownfallBlock(floatArray& downfalls, int x, int z, int w, int h) const { - IntCache::releaseAll(); // if (downfalls == NULL || downfalls->length < w * h) if (downfalls.data == NULL || downfalls.length < w * h) { if (downfalls.data != NULL) delete[] downfalls.data; @@ -112,7 +111,6 @@ floatArray BiomeSource::getTemperatureBlock(int x, int z, int w, int h) const { // downfall layers brought forward from 1.2.3 void BiomeSource::getTemperatureBlock(floatArray& temperatures, int x, int z, int w, int h) const { - IntCache::releaseAll(); // if (temperatures == null || temperatures.length < w * h) { if (temperatures.data == NULL || temperatures.length < w * h) { if (temperatures.data != NULL) delete[] temperatures.data; @@ -137,7 +135,6 @@ BiomeArray BiomeSource::getRawBiomeBlock(int x, int z, int w, int h) const { // 4J added void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w, int h) const { - IntCache::releaseAll(); intArray result = layer->getArea(x, z, w, h); for (int i = 0; i < w * h; i++) { @@ -147,7 +144,6 @@ void BiomeSource::getRawBiomeIndices(intArray& biomes, int x, int z, int w, void BiomeSource::getRawBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h) const { - IntCache::releaseAll(); // if (biomes == null || biomes.length < w * h) if (biomes.data == NULL || biomes.length < w * h) { if (biomes.data != NULL) delete[] biomes.data; @@ -178,7 +174,6 @@ BiomeArray BiomeSource::getBiomeBlock(int x, int z, int w, int h) const { // 4J - caller is responsible for deleting biomes array void BiomeSource::getBiomeBlock(BiomeArray& biomes, int x, int z, int w, int h, bool useCache) const { - IntCache::releaseAll(); // if (biomes == null || biomes.length < w * h) if (biomes.data == NULL || biomes.length < w * h) { if (biomes.data != NULL) delete[] biomes.data; @@ -211,7 +206,6 @@ byteArray BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) const { // 4J - caller is responsible for deleting biomes array void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, int w, int h, bool useCache) const { - IntCache::releaseAll(); // if (biomes == null || biomes.length < w * h) if (biomeIndices.data == NULL || biomeIndices.length < w * h) { if (biomeIndices.data != NULL) delete[] biomeIndices.data; @@ -239,7 +233,6 @@ void BiomeSource::getBiomeIndexBlock(byteArray& biomeIndices, int x, int z, */ bool BiomeSource::containsOnly(int x, int z, int r, std::vector allowed) { - IntCache::releaseAll(); int x0 = ((x - r) >> 2); int z0 = ((z - r) >> 2); int x1 = ((x + r) >> 2); @@ -266,7 +259,6 @@ bool BiomeSource::containsOnly(int x, int z, int r, * NO other biomes, add a margin of at least four blocks to the radius */ bool BiomeSource::containsOnly(int x, int z, int r, Biome* allowed) { - IntCache::releaseAll(); int x0 = ((x - r) >> 2); int z0 = ((z - r) >> 2); int x1 = ((x + r) >> 2); @@ -292,7 +284,6 @@ bool BiomeSource::containsOnly(int x, int z, int r, Biome* allowed) { */ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind, Random* random) { - IntCache::releaseAll(); int x0 = ((x - r) >> 2); int z0 = ((z - r) >> 2); int x1 = ((x + r) >> 2); @@ -327,7 +318,6 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind, */ TilePos* BiomeSource::findBiome(int x, int z, int r, std::vector allowed, Random* random) { - IntCache::releaseAll(); int x0 = ((x - r) >> 2); int z0 = ((z - r) >> 2); int x1 = ((x + r) >> 2); @@ -593,4 +583,4 @@ bool BiomeSource::getIsMatch(float* frac) { // or more - currently there's 8 critical so this just forces at least 1 // more others return (typeCount >= 9); -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/AddIslandLayer.cpp b/Minecraft.World/WorldGen/Layers/AddIslandLayer.cpp index d5d4afc32..deee6c325 100644 --- a/Minecraft.World/WorldGen/Layers/AddIslandLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/AddIslandLayer.cpp @@ -14,7 +14,7 @@ intArray AddIslandLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int n1 = p[(x + 0) + (y + 0) * pw]; @@ -53,4 +53,4 @@ intArray AddIslandLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/AddMushroomIslandLayer.cpp b/Minecraft.World/WorldGen/Layers/AddMushroomIslandLayer.cpp index c963cc76e..f1cf6cafb 100644 --- a/Minecraft.World/WorldGen/Layers/AddMushroomIslandLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/AddMushroomIslandLayer.cpp @@ -15,7 +15,7 @@ intArray AddMushroomIslandLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int n1 = p[(x + 0) + (y + 0) * pw]; @@ -33,4 +33,4 @@ intArray AddMushroomIslandLayer::getArea(int xo, int yo, int w, int h) { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/AddSnowLayer.cpp b/Minecraft.World/WorldGen/Layers/AddSnowLayer.cpp index e31ed5f1b..d8491787b 100644 --- a/Minecraft.World/WorldGen/Layers/AddSnowLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/AddSnowLayer.cpp @@ -14,7 +14,7 @@ intArray AddSnowLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int c = p[(x + 1) + (y + 1) * pw]; @@ -32,4 +32,4 @@ intArray AddSnowLayer::getArea(int xo, int yo, int w, int h) { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/BiomeInitLayer.cpp b/Minecraft.World/WorldGen/Layers/BiomeInitLayer.cpp index 102da9644..005a9b25b 100644 --- a/Minecraft.World/WorldGen/Layers/BiomeInitLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/BiomeInitLayer.cpp @@ -34,7 +34,7 @@ BiomeInitLayer::~BiomeInitLayer() { delete[] startBiomes.data; } intArray BiomeInitLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(x + xo, y + yo); @@ -58,4 +58,4 @@ intArray BiomeInitLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp index 8bbc2bf60..ea2e3e3b6 100644 --- a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp @@ -49,7 +49,7 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { } intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h) { - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; int xOrigin = xo + width / 2; int yOrigin = yo + height / 2; @@ -70,4 +70,4 @@ intArray BiomeOverrideLayer::getArea(int xo, int yo, int w, int h) { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/DownfallLayer.cpp b/Minecraft.World/WorldGen/Layers/DownfallLayer.cpp index d83cb0ed8..b89d2491c 100644 --- a/Minecraft.World/WorldGen/Layers/DownfallLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/DownfallLayer.cpp @@ -9,10 +9,10 @@ DownfallLayer::DownfallLayer(std::shared_ptr parent) : Layer(0) { intArray DownfallLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int i = 0; i < w * h; i++) { result[i] = Biome::biomes[b[i]]->getDownfallInt(); } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/DownfallMixerLayer.cpp b/Minecraft.World/WorldGen/Layers/DownfallMixerLayer.cpp index 88b45ea10..af2734425 100644 --- a/Minecraft.World/WorldGen/Layers/DownfallMixerLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/DownfallMixerLayer.cpp @@ -14,11 +14,11 @@ intArray DownfallMixerLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); intArray d = downfall->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int i = 0; i < w * h; i++) { result[i] = d[i] + (Biome::biomes[b[i]]->getDownfallInt() - d[i]) / (layer + 1); } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/FlatLayer.cpp b/Minecraft.World/WorldGen/Layers/FlatLayer.cpp index 6cc234087..6685eb518 100644 --- a/Minecraft.World/WorldGen/Layers/FlatLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/FlatLayer.cpp @@ -4,11 +4,11 @@ FlatLayer::FlatLayer(int val) : Layer(0) { this->val = val; } intArray FlatLayer::getArea(int xo, int yo, int w, int h) { - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { result[x + y * w] = val; } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/FuzzyZoomLayer.cpp b/Minecraft.World/WorldGen/Layers/FuzzyZoomLayer.cpp index 6a348cbed..005c77408 100644 --- a/Minecraft.World/WorldGen/Layers/FuzzyZoomLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/FuzzyZoomLayer.cpp @@ -15,7 +15,7 @@ intArray FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) { intArray p = parent->getArea(px, py, pw, ph); // 4jcraft added casts to unsigned to prevent shift of neg value - intArray tmp = IntCache::allocate((pw * 2) * (ph * 2)); + intArray tmp{static_cast(pw * ph * 4)}; int ww = ((unsigned int)pw << 1); for (int y = 0; y < ph - 1; y++) { int ry = (unsigned int)y << 1; @@ -37,7 +37,7 @@ intArray FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) { dl = dr; } } - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { System::arraycopy(tmp, (y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1), diff --git a/Minecraft.World/WorldGen/Layers/GrowMushroomIslandLayer.cpp b/Minecraft.World/WorldGen/Layers/GrowMushroomIslandLayer.cpp index b4f150103..0b45d2785 100644 --- a/Minecraft.World/WorldGen/Layers/GrowMushroomIslandLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/GrowMushroomIslandLayer.cpp @@ -15,7 +15,7 @@ intArray GrowMushroomIslandLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int n1 = p[(x + 0) + (y + 0) * pw]; @@ -36,4 +36,4 @@ intArray GrowMushroomIslandLayer::getArea(int xo, int yo, int w, int h) { } } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/IslandLayer.cpp b/Minecraft.World/WorldGen/Layers/IslandLayer.cpp index 11dbe7409..fea672e79 100644 --- a/Minecraft.World/WorldGen/Layers/IslandLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/IslandLayer.cpp @@ -4,7 +4,7 @@ IslandLayer::IslandLayer(int64_t seedMixup) : Layer(seedMixup) {} intArray IslandLayer::getArea(int xo, int yo, int w, int h) { - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(xo + x, yo + y); @@ -16,4 +16,4 @@ intArray IslandLayer::getArea(int xo, int yo, int w, int h) { result[-xo + -yo * w] = 1; } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/RegionHillsLayer.cpp b/Minecraft.World/WorldGen/Layers/RegionHillsLayer.cpp index a691c5523..e1d922325 100644 --- a/Minecraft.World/WorldGen/Layers/RegionHillsLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/RegionHillsLayer.cpp @@ -1,6 +1,5 @@ #include "../../Platform/stdafx.h" #include "../../Headers/net.minecraft.world.level.biome.h" -#include "../../Util/IntCache.h" #include "RegionHillsLayer.h" RegionHillsLayer::RegionHillsLayer(int64_t seed, std::shared_ptr parent) @@ -11,7 +10,7 @@ RegionHillsLayer::RegionHillsLayer(int64_t seed, std::shared_ptr parent) intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(x + xo, y + yo); @@ -51,4 +50,4 @@ intArray RegionHillsLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/RiverInitLayer.cpp b/Minecraft.World/WorldGen/Layers/RiverInitLayer.cpp index 5982e25bc..7ccf2cc4a 100644 --- a/Minecraft.World/WorldGen/Layers/RiverInitLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/RiverInitLayer.cpp @@ -9,7 +9,7 @@ RiverInitLayer::RiverInitLayer(int64_t seed, std::shared_ptr parent) intArray RiverInitLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(x + xo, y + yo); @@ -18,4 +18,4 @@ intArray RiverInitLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/RiverLayer.cpp b/Minecraft.World/WorldGen/Layers/RiverLayer.cpp index 9dbe227f5..fcd93e3af 100644 --- a/Minecraft.World/WorldGen/Layers/RiverLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/RiverLayer.cpp @@ -14,7 +14,7 @@ intArray RiverLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int l = p[(x + 0) + (y + 1) * pw]; @@ -32,4 +32,4 @@ intArray RiverLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/RiverMixerLayer.cpp b/Minecraft.World/WorldGen/Layers/RiverMixerLayer.cpp index 12d5be60a..c2dc12e10 100644 --- a/Minecraft.World/WorldGen/Layers/RiverMixerLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/RiverMixerLayer.cpp @@ -19,7 +19,7 @@ intArray RiverMixerLayer::getArea(int xo, int yo, int w, int h) { intArray b = biomes->getArea(xo, yo, w, h); intArray r = rivers->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int i = 0; i < w * h; i++) { if (b[i] == Biome::ocean->id) { result[i] = b[i]; @@ -45,4 +45,4 @@ intArray RiverMixerLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/ShoreLayer.cpp b/Minecraft.World/WorldGen/Layers/ShoreLayer.cpp index 54469a11e..a4bfc420c 100644 --- a/Minecraft.World/WorldGen/Layers/ShoreLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/ShoreLayer.cpp @@ -10,7 +10,7 @@ ShoreLayer::ShoreLayer(int64_t seed, std::shared_ptr parent) intArray ShoreLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(x + xo, y + yo); @@ -59,4 +59,4 @@ intArray ShoreLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/SmoothLayer.cpp b/Minecraft.World/WorldGen/Layers/SmoothLayer.cpp index ad1b43072..b76dd3bce 100644 --- a/Minecraft.World/WorldGen/Layers/SmoothLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/SmoothLayer.cpp @@ -13,7 +13,7 @@ intArray SmoothLayer::getArea(int xo, int yo, int w, int h) { int ph = h + 2; intArray p = parent->getArea(px, py, pw, ph); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { int l = p[(x + 0) + (y + 1) * pw]; @@ -37,4 +37,4 @@ intArray SmoothLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/SmoothZoomLayer.cpp b/Minecraft.World/WorldGen/Layers/SmoothZoomLayer.cpp index 1452af530..e8b2d0f09 100644 --- a/Minecraft.World/WorldGen/Layers/SmoothZoomLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/SmoothZoomLayer.cpp @@ -15,7 +15,7 @@ intArray SmoothZoomLayer::getArea(int xo, int yo, int w, int h) { int ph = (h >> 1) + 3; intArray p = parent->getArea(px, py, pw, ph); - intArray tmp = IntCache::allocate((pw * 2) * (ph * 2)); + intArray tmp{static_cast(pw * ph * 4)}; int ww = (pw << 1); for (int y = 0; y < ph - 1; y++) { int ry = y << 1; @@ -40,7 +40,7 @@ intArray SmoothZoomLayer::getArea(int xo, int yo, int w, int h) { dl = dr; } } - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { System::arraycopy(tmp, (y + (yo & 1)) * (pw << 1) + (xo & 1), &result, y * w, w); @@ -56,4 +56,4 @@ std::shared_ptr SmoothZoomLayer::zoom(int64_t seed, result = std::shared_ptr(new SmoothZoomLayer(seed + i, result)); } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/SwampRiversLayer.cpp b/Minecraft.World/WorldGen/Layers/SwampRiversLayer.cpp index 4b722dfd2..f886716df 100644 --- a/Minecraft.World/WorldGen/Layers/SwampRiversLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/SwampRiversLayer.cpp @@ -1,6 +1,5 @@ #include "../../Platform/stdafx.h" #include "../../Headers/net.minecraft.world.level.biome.h" -#include "../../Util/IntCache.h" #include "SwampRiversLayer.h" SwampRiversLayer::SwampRiversLayer(int64_t seed, std::shared_ptr parent) @@ -11,7 +10,7 @@ SwampRiversLayer::SwampRiversLayer(int64_t seed, std::shared_ptr parent) intArray SwampRiversLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo - 1, yo - 1, w + 2, h + 2); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { initRandom(x + xo, y + yo); @@ -27,4 +26,4 @@ intArray SwampRiversLayer::getArea(int xo, int yo, int w, int h) { } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/TemperatureLayer.cpp b/Minecraft.World/WorldGen/Layers/TemperatureLayer.cpp index 3cb51d756..cc5a05c23 100644 --- a/Minecraft.World/WorldGen/Layers/TemperatureLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/TemperatureLayer.cpp @@ -9,9 +9,9 @@ TemperatureLayer::TemperatureLayer(std::shared_ptr parent) : Layer(0) { intArray TemperatureLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int i = 0; i < w * h; i++) { result[i] = Biome::biomes[b[i]]->getTemperatureInt(); } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/TemperatureMixerLayer.cpp b/Minecraft.World/WorldGen/Layers/TemperatureMixerLayer.cpp index d86159608..f8350b6fd 100644 --- a/Minecraft.World/WorldGen/Layers/TemperatureMixerLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/TemperatureMixerLayer.cpp @@ -15,11 +15,11 @@ intArray TemperatureMixerLayer::getArea(int xo, int yo, int w, int h) { intArray b = parent->getArea(xo, yo, w, h); intArray t = temp->getArea(xo, yo, w, h); - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int i = 0; i < w * h; i++) { result[i] = t[i] + (Biome::biomes[b[i]]->getTemperatureInt() - t[i]) / (layer * 2 + 1); } return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/VoronoiZoom.cpp b/Minecraft.World/WorldGen/Layers/VoronoiZoom.cpp index a9c773e35..0dafbd6d9 100644 --- a/Minecraft.World/WorldGen/Layers/VoronoiZoom.cpp +++ b/Minecraft.World/WorldGen/Layers/VoronoiZoom.cpp @@ -21,7 +21,7 @@ intArray VoronoiZoom::getArea(int xo, int yo, int w, int h) { // 4jcraft added all those casts to unsigned int ww = (unsigned)pw << bits; int hh = (unsigned)ph << bits; - intArray tmp = IntCache::allocate(ww * hh); + intArray tmp{static_cast(ww * hh)}; for (int y = 0; y < ph - 1; y++) { int ul = p[(0 + 0) + (y + 0) * pw]; int dl = p[(0 + 0) + (y + 1) * pw]; @@ -71,7 +71,7 @@ intArray VoronoiZoom::getArea(int xo, int yo, int w, int h) { dl = dr; } } - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { System::arraycopy( tmp, diff --git a/Minecraft.World/WorldGen/Layers/ZoomLayer.cpp b/Minecraft.World/WorldGen/Layers/ZoomLayer.cpp index 15a8dba8c..673cec962 100644 --- a/Minecraft.World/WorldGen/Layers/ZoomLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/ZoomLayer.cpp @@ -14,7 +14,7 @@ intArray ZoomLayer::getArea(int xo, int yo, int w, int h) { int ph = (h >> 1) + 3; intArray p = parent->getArea(px, py, pw, ph); - intArray tmp = IntCache::allocate((pw * 2) * (ph * 2)); + intArray tmp{static_cast(pw * ph * 4)}; // 4jcraft added casts to unsigned int ww = ((unsigned int)pw << 1); for (int y = 0; y < ph - 1; y++) { @@ -37,7 +37,7 @@ intArray ZoomLayer::getArea(int xo, int yo, int w, int h) { dl = dr; } } - intArray result = IntCache::allocate(w * h); + intArray result{static_cast(w * h)}; for (int y = 0; y < h; y++) { System::arraycopy(tmp, (y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1),