diff --git a/targets/app/common/Game.cpp b/targets/app/common/Game.cpp index 752016d29..a17dccfcb 100644 --- a/targets/app/common/Game.cpp +++ b/targets/app/common/Game.cpp @@ -156,7 +156,7 @@ void Game::DebugPrintf(const char* szFormat, ...) { va_start(ap, szFormat); vsnprintf(buf, sizeof(buf), szFormat, ap); va_end(ap); - OutputDebugStringA(buf); + fputs(buf, stderr); #endif } @@ -168,7 +168,7 @@ void Game::DebugPrintf(int user, const char* szFormat, ...) { va_start(ap, szFormat); vsnprintf(buf, sizeof(buf), szFormat, ap); va_end(ap); - OutputDebugStringA(buf); + fputs(buf, stderr); if (user == USER_UI) { ui.logDebugString(buf); } diff --git a/targets/app/common/NetworkController.cpp b/targets/app/common/NetworkController.cpp index 295079fdb..257bef7da 100644 --- a/targets/app/common/NetworkController.cpp +++ b/targets/app/common/NetworkController.cpp @@ -1,5 +1,9 @@ #include "app/common/NetworkController.h" +#include +#include +#include + #include "app/common/Game.h" #include "app/common/Network/GameNetworkManager.h" #include "app/linux/LinuxGame.h" @@ -13,18 +17,10 @@ #include "minecraft/client/skins/TexturePack.h" #include "minecraft/client/skins/TexturePackRepository.h" #include "minecraft/server/MinecraftServer.h" -#include "minecraft/stats/StatsCounter.h" -#include "minecraft/world/entity/player/Player.h" -#include "minecraft/world/level/tile/Tile.h" #include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h" #include "platform/input/input.h" #include "platform/profile/profile.h" #include "platform/storage/storage.h" -#include "app/common/Audio/SoundEngine.h" - -#include -#include -#include unsigned int NetworkController::m_uiLastSignInData = 0; @@ -39,9 +35,8 @@ NetworkController::NetworkController() { memset(m_playerGamePrivileges, 0, sizeof(m_playerGamePrivileges)); for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (FAILED(XUserGetSigninInfo(i, - XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, - &m_currentSigninInfo[i]))) { + if (XUserGetSigninInfo(i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, + &m_currentSigninInfo[i]) < 0) { m_currentSigninInfo[i].xuid = INVALID_XUID; m_currentSigninInfo[i].dwGuestNumber = 0; } @@ -308,12 +303,11 @@ void NetworkController::signInChangeCallback(void* pParam, if (bPlayerChanged && (!bPlayerSignedIn || - (bPlayerSignedIn && - !PlatformProfile.AreXUIDSEqual( - pApp->m_networkController - .m_currentSigninInfo[i] - .xuid, - info.xuid)))) { + (bPlayerSignedIn && !PlatformProfile.AreXUIDSEqual( + pApp->m_networkController + .m_currentSigninInfo[i] + .xuid, + info.xuid)))) { pApp->DebugPrintf( "Player at index %d Left - invalidating their " "banned list\n", @@ -355,9 +349,9 @@ void NetworkController::signInChangeCallback(void* pParam, } for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if (FAILED(XUserGetSigninInfo( + if (XUserGetSigninInfo( i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, - &pApp->m_networkController.m_currentSigninInfo[i]))) { + &pApp->m_networkController.m_currentSigninInfo[i]) < 0) { pApp->m_networkController.m_currentSigninInfo[i].xuid = INVALID_XUID; pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber = 0; diff --git a/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp b/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp index 0aecabe23..c415b9e8c 100644 --- a/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp +++ b/targets/app/common/UI/All Platforms/IUIScene_CraftingMenu.cpp @@ -7,15 +7,13 @@ #include #include -#include "platform/profile/profile.h" -#include "platform/renderer/renderer.h" -#include "minecraft/GameEnums.h" #include "app/common/Console_Debug_enum.h" #include "app/common/Tutorial/Tutorial.h" #include "app/common/UI/All Platforms/UIEnums.h" #include "app/linux/LinuxGame.h" #include "app/linux/Linux_UIController.h" #include "app/linux/Stubs/winapi_stubs.h" +#include "minecraft/GameEnums.h" #include "minecraft/client/Minecraft.h" #include "minecraft/client/multiplayer/MultiPlayerGameMode.h" #include "minecraft/client/player/LocalPlayer.h" @@ -27,6 +25,8 @@ #include "minecraft/world/item/crafting/Recipes.h" #include "minecraft/world/item/crafting/ShapedRecipy.h" #include "minecraft/world/level/tile/Tile.h" +#include "platform/profile/profile.h" +#include "platform/renderer/renderer.h" #include "strings.h" Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA @@ -875,7 +875,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { } else { app.DebugPrintf("Need more H slots - "); #if !defined(_CONTENT_PACKAGE) - OutputDebugStringW( + fwprintf( + stderr, app.GetString(pTempItemInst->getDescriptionId())); #endif app.DebugPrintf("\n"); @@ -1313,8 +1314,8 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) { // 12 for splitscreen, 14 for normal EHTMLFontSize size = eHTMLSize_Normal; - if (m_bSplitscreen || - (!PlatformRenderer.IsHiDef() && !PlatformRenderer.IsWidescreen())) { + if (m_bSplitscreen || (!PlatformRenderer.IsHiDef() && + !PlatformRenderer.IsWidescreen())) { size = eHTMLSize_Splitscreen; } wchar_t startTags[64]; diff --git a/targets/app/common/UI/Scenes/Debug/UIScene_DebugOptions.cpp b/targets/app/common/UI/Scenes/Debug/UIScene_DebugOptions.cpp index d42483a53..f9efe3f44 100644 --- a/targets/app/common/UI/Scenes/Debug/UIScene_DebugOptions.cpp +++ b/targets/app/common/UI/Scenes/Debug/UIScene_DebugOptions.cpp @@ -1,13 +1,13 @@ #include "UIScene_DebugOptions.h" #include "app/common/Console_Debug_enum.h" -#include "app/common/UI/Controls/UIControl_CheckBox.h" #include "app/common/UI/UIScene.h" #include "app/linux/Iggy/include/iggy.h" #ifndef _ENABLEIGGY #include "app/linux/Stubs/iggy_stubs.h" #endif #include "app/linux/LinuxGame.h" +#include "platform/input/InputConstants.h" class UILayer; diff --git a/targets/app/linux/Stubs/winapi_stubs.h b/targets/app/linux/Stubs/winapi_stubs.h index 49d8e34c9..b06539542 100644 --- a/targets/app/linux/Stubs/winapi_stubs.h +++ b/targets/app/linux/Stubs/winapi_stubs.h @@ -4,16 +4,14 @@ #pragma once #include -#include #include #include #include #include #include -#include -#include #include +#include #include #include #include @@ -22,41 +20,20 @@ #define _vsnprintf_s vsnprintf; typedef unsigned int DWORD; -typedef unsigned char BYTE; -typedef BYTE* PBYTE; -typedef int HRESULT; -typedef unsigned int UINT; -typedef void* HANDLE; -typedef int INT; -typedef unsigned int* LPDWORD; -typedef char CHAR; -typedef uintptr_t ULONG_PTR; -typedef long LONG; -typedef unsigned long long PlayerUID; -typedef DWORD WORD; -typedef DWORD* PDWORD; typedef struct { - DWORD LowPart; - LONG HighPart; - long long QuadPart; + int32_t LowPart; + int32_t HighPart; + int64_t QuadPart; } LARGE_INTEGER; typedef struct { - DWORD LowPart; - LONG HighPart; - long long QuadPart; + uint32_t LowPart; + uint32_t HighPart; + uint64_t QuadPart; } ULARGE_INTEGER; -typedef long long LONGLONG; -typedef wchar_t *LPWSTR, *PWSTR; -typedef unsigned char boolean; // java brainrot #define __debugbreak() -#define CONST const -typedef unsigned long ULONG; -// typedef unsigned char byte; -typedef short SHORT; -typedef float FLOAT; #define ERROR_SUCCESS 0L #define ERROR_IO_PENDING 997L // dderror @@ -73,67 +50,18 @@ typedef struct _FILETIME { DWORD dwHighDateTime; } FILETIME, *PFILETIME, *LPFILETIME; -typedef struct _MEMORYSTATUS { - DWORD dwLength; - DWORD dwMemoryLoad; - size_t dwTotalPhys; - size_t dwAvailPhys; - size_t dwTotalPageFile; - size_t dwAvailPageFile; - size_t dwTotalVirtual; - size_t dwAvailVirtual; -} MEMORYSTATUS, *LPMEMORYSTATUS; - -typedef enum _GET_FILEEX_INFO_LEVELS { - GetFileExInfoStandard, - GetFileExMaxInfoLevel -} GET_FILEEX_INFO_LEVELS; - -typedef void* XMEMCOMPRESSION_CONTEXT; -typedef void* XMEMDECOMPRESSION_CONTEXT; - // https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime typedef struct _SYSTEMTIME { - WORD wYear; - WORD wMonth; - WORD wDayOfWeek; - WORD wDay; - WORD wHour; - WORD wMinute; - WORD wSecond; - WORD wMilliseconds; + int16_t wYear; + int16_t wMonth; + int16_t wDayOfWeek; + int16_t wDay; + int16_t wHour; + int16_t wMinute; + int16_t wSecond; + int16_t wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME, *LPSYSTEMTIME; -#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF) -// https://learn.microsoft.com/en-us/cpp/c-runtime-library/truncate?view=msvc-170 -#define _TRUNCATE ((size_t)-1) - -#define DECLARE_HANDLE(name) typedef HANDLE name -DECLARE_HANDLE(HINSTANCE); - -typedef HINSTANCE HMODULE; - -#define _HRESULT_TYPEDEF_(_sc) _sc - -#define FAILED(Status) ((HRESULT)(Status) < 0) -#define MAKE_HRESULT(sev, fac, code) \ - ((HRESULT)(((unsigned int)(sev) << 31) | ((unsigned int)(fac) << 16) | \ - ((unsigned int)(code)))) -#define MAKE_SCODE(sev, fac, code) \ - ((SCODE)(((unsigned int)(sev) << 31) | ((unsigned int)(fac) << 16) | \ - ((unsigned int)(code)))) -#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L) -#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L) -#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L) - -// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalmemorystatus -static inline void GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) { - // TODO: Parse /proc/meminfo and set lpBuffer based on that. Probably will - // also need another different codepath for macOS too. -} - -static inline DWORD GetLastError(void) { return errno; } - #ifdef __LP64__ static inline int64_t InterlockedCompareExchangeRelease64( int64_t volatile* Destination, int64_t Exchange, int64_t Comperand) { @@ -195,7 +123,7 @@ static inline void _FillSystemTime(const struct tm* tm, long tv_nsec, lpSystemTime->wHour = tm->tm_hour; lpSystemTime->wMinute = tm->tm_min; lpSystemTime->wSecond = tm->tm_sec; - lpSystemTime->wMilliseconds = (WORD)(tv_nsec / 1000000); // ns to ms + lpSystemTime->wMilliseconds = (int16_t)(tv_nsec / 1000000); // ns to ms } // https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime @@ -221,23 +149,7 @@ static inline bool FileTimeToSystemTime(const FILETIME* lpFileTime, return true; } -// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa -static inline void OutputDebugStringA(const char* lpOutputString) { - if (!lpOutputString) return; - fputs(lpOutputString, stderr); -} - -// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw -static inline void OutputDebugStringW(const wchar_t* lpOutputString) { - if (!lpOutputString) return; - fprintf(stderr, "%ls", lpOutputString); -} - -static inline void OutputDebugString(const char* lpOutputString) { - return OutputDebugStringA(lpOutputString); -} - -static inline HMODULE GetModuleHandle(const char* lpModuleName) { return 0; } +static inline void* GetModuleHandle(const char* lpModuleName) { return 0; } static inline void* VirtualAlloc(void* lpAddress, size_t dwSize, DWORD flAllocationType, DWORD flProtect) { diff --git a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp index ffeefde22..067474dee 100644 --- a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp +++ b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp @@ -952,10 +952,11 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { unsigned char* newIndicesAndData = (unsigned char*)malloc( memToAlloc); //(unsigned char *)malloc( memToAlloc ); if (newIndicesAndData == nullptr) { - uint32_t lastError = GetLastError(); - MEMORYSTATUS memStatus; - GlobalMemoryStatus(&memStatus); - __debugbreak(); + assert(0 && "Failed to allocate memory for CompressedTileStorage."); + // uint32_t lastError = GetLastError(); + // MEMORYSTATUS memStatus; + // GlobalMemoryStatus(&memStatus); + // __debugbreak(); } unsigned char* pucData = newIndicesAndData + 1024; unsigned short usDataOffset = 0; diff --git a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp index 8f72c21f3..0ad4eb0db 100644 --- a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp @@ -43,10 +43,10 @@ void SignTileEntity::save(CompoundTag* tag) { tag->putString(L"Text3", m_wsmessages[2]); tag->putString(L"Text4", m_wsmessages[3]); #if !defined(_CONTENT_PACKAGE) - OutputDebugStringW(L"### - Saving a sign with text - \n"); + fwprintf(stderr, L"### - Saving a sign with text - \n"); for (int i = 0; i < 4; i++) { - OutputDebugStringW(m_wsmessages[i].c_str()); - OutputDebugStringW(L"\n"); + fwprintf(stderr, m_wsmessages[i].c_str()); + fwprintf(stderr, L"\n"); } #endif } @@ -62,10 +62,10 @@ void SignTileEntity::load(CompoundTag* tag) { m_wsmessages[i] = m_wsmessages[i].substr(0, MAX_LINE_LENGTH); } #if !defined(_CONTENT_PACKAGE) - OutputDebugStringW(L"### - Loaded a sign with text - \n"); + fwprintf(stderr, L"### - Loaded a sign with text - \n"); for (int i = 0; i < 4; i++) { - OutputDebugStringW(m_wsmessages[i].c_str()); - OutputDebugStringW(L"\n"); + fwprintf(stderr, m_wsmessages[i].c_str()); + fwprintf(stderr, L"\n"); } #endif