diff --git a/Minecraft.Client/StatsCounter.cpp b/Minecraft.Client/StatsCounter.cpp index 050f533e..aae8d0c1 100644 --- a/Minecraft.Client/StatsCounter.cpp +++ b/Minecraft.Client/StatsCounter.cpp @@ -67,7 +67,9 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, unsigned int count unordered_map::iterator leaderboardEntry = statBoards.find(stat); if( leaderboardEntry != statBoards.end() ) { +#ifdef _DEBUG app.DebugPrintf("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty); +#endif modifiedBoards |= (leaderboardEntry->second << difficulty); if( flushCounter == 0 ) flushCounter = FLUSH_DELAY; diff --git a/Minecraft.Client/Windows64/Windows64_App.cpp b/Minecraft.Client/Windows64/Windows64_App.cpp index ad8aa6e7..24f729e2 100644 --- a/Minecraft.Client/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Windows64/Windows64_App.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "Windows64_Minecraft.h" #include "..\Common\Consoles_App.h" #include "..\User.h" #include "..\..\Minecraft.Client\Minecraft.h" @@ -26,6 +27,14 @@ void CConsoleMinecraftApp::StoreLaunchData() } void CConsoleMinecraftApp::ExitGame() { + if (g_pd3dDevice != NULL) + { + g_pd3dDevice->Release(); + g_pd3dDevice = NULL; + } + + CleanupDevice(); + ExitProcess(0); } void CConsoleMinecraftApp::FatalLoadError() @@ -57,74 +66,6 @@ void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) { } -void CConsoleMinecraftApp::TemporaryCreateGameStart() -{ - ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit - - app.setLevelGenerationOptions(NULL); - - // From CScene_Main::RunPlayGame - Minecraft *pMinecraft=Minecraft::GetInstance(); - app.ReleaseSaveThumbnail(); - ProfileManager.SetLockedProfile(0); - pMinecraft->user->name = L"Windows"; - app.ApplyGameSettingsChanged(0); - - ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit - MinecraftServer::resetFlags(); - - // From CScene_MultiGameJoinLoad::OnNotifyPressEx - app.SetTutorialMode( false ); - app.SetCorruptSaveDeleted(false); - - ////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame - - app.ClearTerrainFeaturePosition(); - wstring wWorldName = L"TestWorld"; - - StorageManager.ResetSaveData(); - StorageManager.SetSaveTitle(wWorldName.c_str()); - - bool isFlat = false; - __int64 seedValue = 0; // BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements - - NetworkGameInitData *param = new NetworkGameInitData(); - param->seed = seedValue; - param->saveData = NULL; - - app.SetGameHostOption(eGameHostOption_Difficulty,0); - app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0); - app.SetGameHostOption(eGameHostOption_Gamertags,1); - app.SetGameHostOption(eGameHostOption_BedrockFog,1); - - app.SetGameHostOption(eGameHostOption_GameType,GameType::CREATIVE->getId() ); // LevelSettings::GAMETYPE_SURVIVAL - app.SetGameHostOption(eGameHostOption_LevelType, 0 ); - app.SetGameHostOption(eGameHostOption_Structures, 1 ); - app.SetGameHostOption(eGameHostOption_BonusChest, 0 ); - - app.SetGameHostOption(eGameHostOption_PvP, 1); - app.SetGameHostOption(eGameHostOption_TrustPlayers, 1 ); - app.SetGameHostOption(eGameHostOption_FireSpreads, 1 ); - app.SetGameHostOption(eGameHostOption_TNT, 1 ); - app.SetGameHostOption(eGameHostOption_HostCanFly, 1); - app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, 1); - app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, 1 ); - - param->settings = app.GetGameHostOption( eGameHostOption_All ); - - g_NetworkManager.FakeLocalPlayerJoined(); - - LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; - - // Reset the autosave time - app.SetAutosaveTimerTime(); - - C4JThread* thread = new C4JThread(loadingParams->func, loadingParams->lpParam, "RunNetworkGame"); - thread->Run(); -} - int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT) { return -1; diff --git a/Minecraft.Client/Windows64/Windows64_App.h b/Minecraft.Client/Windows64/Windows64_App.h index cebdde3a..6302e7f2 100644 --- a/Minecraft.Client/Windows64/Windows64_App.h +++ b/Minecraft.Client/Windows64/Windows64_App.h @@ -27,10 +27,7 @@ public: // BANNED LEVEL LIST virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} - C4JStringTable *GetStringTable() { return NULL;} - - // original code - virtual void TemporaryCreateGameStart(); + C4JStringTable *GetStringTable() { return NULL;} // str1k3r - UTF8 to wchar std::wstring UTF8ToWide(const char* utf8); diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 6d80256a..b0ace9a5 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -76,7 +76,6 @@ DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= //------------------------------------------------------------------------------------- BOOL g_bWidescreen = TRUE; - int g_iScreenWidth = 1920; int g_iScreenHeight = 1080; @@ -313,8 +312,6 @@ ID3D11Texture2D* g_pDepthStencilBuffer = NULL; LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; - PAINTSTRUCT ps; - HDC hdc; switch (message) { @@ -332,11 +329,35 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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_ENTERSIZEMOVE: + SetTimer(hWnd, 1, USER_TIMER_MINIMUM, NULL); + break; + case WM_EXITSIZEMOVE: + KillTimer(hWnd, 1); + break; + case WM_ERASEBKGND: + return 1; + case WM_TIMER: + if (wParam == 1) + { + // Tick UI + ui.tick(); + ui.render(); + RenderManager.Present(); + ui.CheckMenuDisplayed(); + + // Tick Managers + app.UpdateTime(); + InputManager.Tick(); + StorageManager.Tick(); + RenderManager.Tick(); + + // Tick Music + Minecraft *pMinecraft=Minecraft::GetInstance(); + pMinecraft->soundEngine->tick(NULL, 0.0f); + pMinecraft->soundEngine->playMusicTick(); + } + break; case WM_DESTROY: PostQuitMessage(0); break; @@ -467,17 +488,31 @@ HRESULT InitDevice() { HRESULT hr = S_OK; - //str1k3r - use screen size instead of window size - g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); - g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN); - - //str1k3r - stop hardcoding size and just use the screens actual size - UINT width = g_iScreenWidth; + //str1k3r - use screen size instead of window size & detect if its widescreen or not +#ifndef _DEBUG + HMONITOR hMonitor = MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTONEAREST); + MONITORINFO monitorInfo = { sizeof(MONITORINFO) }; + if (GetMonitorInfo(hMonitor, &monitorInfo)) + { + g_iScreenWidth = monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left; + g_iScreenHeight = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top; + } + else + { + g_iScreenWidth = GetSystemMetrics(SM_CXSCREEN); + g_iScreenHeight = GetSystemMetrics(SM_CYSCREEN); + } + + g_bWidescreen = (g_iScreenHeight > 0 && ((double)g_iScreenWidth / g_iScreenHeight) >= 1.59) ? TRUE : FALSE; +#endif + + //str1k3r - stop hardcoding size and just use the screens actual size + UINT width = g_iScreenWidth; UINT height = g_iScreenHeight; UINT createDeviceFlags = 0; #ifdef _DEBUG - app.DebugPrintf("Screen Width: %d, Screen Height: %d\n", width, height); + app.DebugPrintf("Screen Width: %d, Screen Height: %d, Widescreen: %s\n", width, height, g_bWidescreen ? "TRUE" : "FALSE"); createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif @@ -1177,10 +1212,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // A memory leak was caused because the icon renderer kept creating new Vec3's because the pool wasn't reset Vec3::resetPool(); } + + //str1k3r - Safely exit the game + app.ExitGame(); - // Free resources, unregister custom classes, and exit. - // app.Uninit(); - g_pd3dDevice->Release(); + return (int)msg.wParam; } #ifdef MEMORY_TRACKING diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.h b/Minecraft.Client/Windows64/Windows64_Minecraft.h index 1e62aedf..d5208a3c 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.h +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.h @@ -1,4 +1,12 @@ #pragma once +#include + +extern BOOL g_bWidescreen; + extern int g_iScreenWidth; -extern int g_iScreenHeight; \ No newline at end of file +extern int g_iScreenHeight; + +extern ID3D11Device* g_pd3dDevice; + +void CleanupDevice(); \ No newline at end of file