From 9e207250cb2bcd7ac2d4d0a8753b71718cdf477b Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:57:48 +1100 Subject: [PATCH] refactor: add platform interfaces, move GetPrimaryPad to Input, gut Profile stubs --- meson.build | 1 + minecraft/4J.Input/4J_Input.cpp | 5 + minecraft/4J.Input/4J_Input.h | 30 +- minecraft/4J.Profile/4J_Profile.cpp | 168 ++++------- minecraft/4J.Profile/4J_Profile.h | 224 +++++---------- minecraft/4J.Profile/meson.build | 5 - minecraft/4J.Render/4J_Render.h | 93 +------ minecraft/4J.Storage/4J_Storage.h | 148 ++-------- .../Minecraft.Client/Linux/Linux_App.cpp | 2 - .../net/minecraft/client/Minecraft.cpp | 34 +-- .../net/minecraft/client/gui/Gui.cpp | 2 +- .../net/minecraft/client/gui/PauseScreen.cpp | 4 +- .../net/minecraft/client/gui/Screen.cpp | 2 +- .../client/multiplayer/ClientConnection.cpp | 40 +-- .../multiplayer/MultiPlayerGameMode.cpp | 2 +- .../client/multiplayer/MultiPlayerLevel.cpp | 2 +- .../multiplayer/MultiPlayerLocalPlayer.cpp | 2 +- .../client/renderer/GameRenderer.cpp | 4 +- .../client/renderer/LevelRenderer.cpp | 12 +- .../minecraft/client/skins/DLCTexturePack.cpp | 8 +- .../client/skins/TexturePackRepository.cpp | 4 +- .../net/minecraft/server/MinecraftServer.cpp | 4 +- .../minecraft/server/level/ServerLevel.cpp | 2 +- .../minecraft/server/level/ServerPlayer.cpp | 18 +- .../net/minecraft/stats/StatsCounter.cpp | 1 - .../minecraft/world/entity/animal/Ocelot.cpp | 2 +- .../net/minecraft/world/item/EnderEyeItem.cpp | 2 +- .../net/minecraft/world/level/Level.cpp | 2 +- .../world/level/biome/BiomeSource.cpp | 2 +- .../chunk/storage/McRegionChunkStorage.cpp | 2 +- .../level/chunk/storage/OldChunkStorage.cpp | 4 +- .../world/level/dimension/Dimension.cpp | 4 +- .../world/level/dimension/HellDimension.cpp | 2 +- .../world/level/newbiome/layer/Layer.cpp | 2 +- .../level/storage/DirectoryLevelStorage.cpp | 4 +- minecraft/platform/IPlatformInput.h | 111 ++++++++ minecraft/platform/IPlatformProfile.h | 167 +++++++++++ minecraft/platform/IPlatformRender.h | 234 ++++++++++++++++ minecraft/platform/IPlatformStorage.h | 260 ++++++++++++++++++ minecraft/platform/Platform.h | 6 + minecraft/platform/meson.build | 5 + 41 files changed, 1026 insertions(+), 600 deletions(-) create mode 100644 minecraft/platform/IPlatformInput.h create mode 100644 minecraft/platform/IPlatformProfile.h create mode 100644 minecraft/platform/IPlatformRender.h create mode 100644 minecraft/platform/IPlatformStorage.h create mode 100644 minecraft/platform/Platform.h create mode 100644 minecraft/platform/meson.build diff --git a/meson.build b/meson.build index 46945ee0b..f208d68d2 100644 --- a/meson.build +++ b/meson.build @@ -65,6 +65,7 @@ miniaudio_dep = dependency('miniaudio') subdir('minecraft/java') subdir('minecraft/nbt') +subdir('minecraft/platform') subdir('minecraft/4J.Render') subdir('minecraft/4J.Input') diff --git a/minecraft/4J.Input/4J_Input.cpp b/minecraft/4J.Input/4J_Input.cpp index ae44f7f38..037554362 100644 --- a/minecraft/4J.Input/4J_Input.cpp +++ b/minecraft/4J.Input/4J_Input.cpp @@ -658,3 +658,8 @@ void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*, STRING_VERIFY_RESPONSE*), void*) {} void C_4JInput::CancelAllVerifyInProgress() {} + +// Primary pad (moved from Profile) +namespace { int s_inputPrimaryPad = 0; } +int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; } +void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; } diff --git a/minecraft/4J.Input/4J_Input.h b/minecraft/4J.Input/4J_Input.h index 8c03e8ab2..a592291ad 100644 --- a/minecraft/4J.Input/4J_Input.h +++ b/minecraft/4J.Input/4J_Input.h @@ -2,6 +2,8 @@ #include +#include "../platform/IPlatformInput.h" + #define MAP_STYLE_0 0 #define MAP_STYLE_1 1 #define MAP_STYLE_2 2 @@ -47,30 +49,8 @@ #define TRIGGER_MAP_0 0 #define TRIGGER_MAP_1 1 -enum EKeyboardResult { - EKeyboard_Pending, - EKeyboard_Cancelled, - EKeyboard_ResultAccept, - EKeyboard_ResultDecline, -}; - -typedef struct _STRING_VERIFY_RESPONSE { - std::uint16_t wNumStrings; - int* pStringResult; -} STRING_VERIFY_RESPONSE; - -class C_4JInput { +class C_4JInput : public IPlatformInput { public: - enum EKeyboardMode { - EKeyboardMode_Default, - EKeyboardMode_Numeric, - EKeyboardMode_Password, - EKeyboardMode_Alphabet, - EKeyboardMode_Full, - EKeyboardMode_Alphabet_Extended, - EKeyboardMode_IP_Address, - EKeyboardMode_Phone - }; void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC); @@ -157,6 +137,10 @@ public: int GetMouseX(); int GetMouseY(); + // Primary pad (moved from Profile) + int GetPrimaryPad(); + void SetPrimaryPad(int iPad); + // bool InputDetected(int userIndex, wchar_t* inputText); }; diff --git a/minecraft/4J.Profile/4J_Profile.cpp b/minecraft/4J.Profile/4J_Profile.cpp index 827f05cde..f2e52bf5f 100644 --- a/minecraft/4J.Profile/4J_Profile.cpp +++ b/minecraft/4J.Profile/4J_Profile.cpp @@ -1,5 +1,6 @@ #include "4J_Profile.h" #include "../4J.Common/4J_ProfileConstants.h" +#include "../4J.Input/4J_Input.h" #include #include @@ -45,7 +46,6 @@ void* s_profileData[XUSER_MAX_COUNT] = {}; C_4JProfile::PROFILESETTINGS s_dashboardSettings[XUSER_MAX_COUNT] = {}; char s_gamertags[XUSER_MAX_COUNT][16] = {}; std::wstring s_displayNames[XUSER_MAX_COUNT]; -int s_primaryPad = 0; int s_lockedProfile = 0; bool s_profileIsFullVersion = true; int (*s_defaultOptionsCallback)(void*, C_4JProfile::PROFILESETTINGS*, @@ -102,14 +102,9 @@ void initialiseDefaultGameSettings(ProfileGameSettings* gameSettings) { } } // namespace -void C_4JProfile::Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID, - unsigned short usProfileVersion, - unsigned int uiProfileValuesC, - unsigned int uiProfileSettingsC, - std::uint32_t* pdwProfileSettingsA, - int iGameDefinedDataSizeX4, - unsigned int* puiGameDefinedDataChangedBitmask) { - s_primaryPad = 0; +void C_4JProfile::Initialise(std::uint32_t, std::uint32_t, unsigned short, + unsigned int, unsigned int, std::uint32_t*, + int iGameDefinedDataSizeX4, unsigned int*) { s_lockedProfile = 0; std::memset(s_dashboardSettings, 0, sizeof(s_dashboardSettings)); @@ -122,46 +117,28 @@ void C_4JProfile::Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID, ensureFakeIdentity(i); } } -void C_4JProfile::SetTrialTextStringTable(CXuiStringTable* pStringTable, - int iAccept, int iReject) {} -void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle, - int iText) {} + int C_4JProfile::GetLockedProfile() { return s_lockedProfile; } void C_4JProfile::SetLockedProfile(int iProf) { s_lockedProfile = iProf; } bool C_4JProfile::IsSignedIn(int iQuadrant) { return iQuadrant == 0; } bool C_4JProfile::IsSignedInLive(int iProf) { return IsSignedIn(iProf); } -bool C_4JProfile::IsGuest(int iQuadrant) { return false; } -unsigned int C_4JProfile::RequestSignInUI( - bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, - bool bMultiplayerSignIn, bool bAddUser, - int (*Func)(void*, const bool, const int iPad), void* lpParam, - int iQuadrant) { - return 0; -} -unsigned int C_4JProfile::DisplayOfflineProfile(int (*Func)(void*, const bool, - const int iPad), - void* lpParam, int iQuadrant) { - return 0; -} -unsigned int C_4JProfile::RequestConvertOfflineToGuestUI( - int (*Func)(void*, const bool, const int iPad), void* lpParam, - int iQuadrant) { - return 0; -} -void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {} -bool C_4JProfile::QuerySigninStatus(void) { return true; } -void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) { +bool C_4JProfile::IsGuest(int) { return false; } +bool C_4JProfile::QuerySigninStatus() { return true; } + +void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool) { if (pXuid) *pXuid = kFakeXuidBase + static_cast(isValidPad(iPad) ? iPad : 0); } + bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) { return xuid1 == xuid2; } -bool C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; } -bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; } -bool C_4JProfile::GetChatAndContentRestrictions(int iPad, - bool* pbChatRestricted, + +bool C_4JProfile::XUIDIsGuest(PlayerUID) { return false; } +bool C_4JProfile::AllowedToPlayMultiplayer(int) { return true; } + +bool C_4JProfile::GetChatAndContentRestrictions(int, bool* pbChatRestricted, bool* pbContentRestricted, int* piAge) { if (pbChatRestricted) *pbChatRestricted = false; @@ -169,105 +146,56 @@ bool C_4JProfile::GetChatAndContentRestrictions(int iPad, if (piAge) *piAge = 18; return true; } -void C_4JProfile::StartTrialGame() {} -void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, - bool* allAllowed, - bool* friendsAllowed) { - if (allAllowed) *allAllowed = true; - if (friendsAllowed) *friendsAllowed = true; -} -bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, - PlayerUID* pXuids, - unsigned int xuidCount) { - return true; -} -void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {} -bool C_4JProfile::GetProfileAvatar(int iPad, - int (*Func)(void* lpParam, - std::uint8_t* thumbnailData, - unsigned int thumbnailBytes), - void* lpParam) { - return false; -} -void C_4JProfile::CancelProfileAvatarRequest() {} -int C_4JProfile::GetPrimaryPad() { return s_primaryPad; } -void C_4JProfile::SetPrimaryPad(int iPad) { s_primaryPad = iPad; } char* C_4JProfile::GetGamertag(int iPad) { - const int resolvedPad = isValidPad(iPad) ? iPad : 0; - ensureFakeIdentity(resolvedPad); - return s_gamertags[resolvedPad]; + const int p = isValidPad(iPad) ? iPad : 0; + ensureFakeIdentity(p); + return s_gamertags[p]; } + std::wstring C_4JProfile::GetDisplayName(int iPad) { - const int resolvedPad = isValidPad(iPad) ? iPad : 0; - ensureFakeIdentity(resolvedPad); - return s_displayNames[resolvedPad]; + const int p = isValidPad(iPad) ? iPad : 0; + ensureFakeIdentity(p); + return s_displayNames[p]; } + bool C_4JProfile::IsFullVersion() { return s_profileIsFullVersion; } -void C_4JProfile::SetSignInChangeCallback(void (*Func)(void*, bool, - unsigned int), - void* lpParam) {} -void C_4JProfile::SetNotificationsCallback(void (*Func)(void*, std::uint32_t, - unsigned int), - void* lpParam) {} -bool C_4JProfile::RegionIsNorthAmerica(void) { return false; } -bool C_4JProfile::LocaleIsUSorCanada(void) { return false; } -int C_4JProfile::GetLiveConnectionStatus() { return 0; } -bool C_4JProfile::IsSystemUIDisplayed() { return false; } -void C_4JProfile::SetProfileReadErrorCallback(void (*Func)(void*), - void* lpParam) {} -int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*, - const int iPad), - void* lpParam) { + +int C_4JProfile::SetDefaultOptionsCallback( + int (*Func)(void*, PROFILESETTINGS*, const int iPad), void* lpParam) { s_defaultOptionsCallback = Func; s_defaultOptionsCallbackParam = lpParam; return 0; } -int C_4JProfile::SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*, - const unsigned short, - const int), - void* lpParam) { - return 0; -} + C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings( int iPad) { return &s_dashboardSettings[isValidPad(iPad) ? iPad : 0]; } -void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, - bool bOverride5MinuteLimitOnProfileWrites) {} -void C_4JProfile::ForceQueuedProfileWrites(int iPad) {} + void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return isValidPad(iQuadrant) ? s_profileData[iQuadrant] : nullptr; } -void C_4JProfile::ResetProfileProcessState() {} -void C_4JProfile::Tick(void) {} -void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, - eAwardType eType, bool bLeaderboardAffected, - CXuiStringTable* pStringTable, int iTitleStr, - int iTextStr, int iAcceptStr, - char* pszThemeName, unsigned int uiThemeSize) {} -int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; } -eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { - return eAwardType_Achievement; + +void C_4JProfile::AllowedPlayerCreatedContent(int, bool, bool* allAllowed, + bool* friendsAllowed) { + if (allAllowed) *allAllowed = true; + if (friendsAllowed) *friendsAllowed = true; } -bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { - return false; + +bool C_4JProfile::CanViewPlayerCreatedContent(int, bool, PlayerUID*, + unsigned int) { + return true; } -void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce) {} -bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward) { return false; } -void C_4JProfile::RichPresenceInit(int iPresenceCount, int iContextCount) {} -void C_4JProfile::RegisterRichPresenceContext(int iGameConfigContextID) {} -void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID, - int iVal) {} -void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence, - bool bSetOthersToIdle) {} -void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant, - int iUpsellParam) {} -void C_4JProfile::SetUpsellCallback(void (*Func)(void* lpParam, - eUpsellType type, - eUpsellResponse response, - int iUserData), - void* lpParam) {} -void C_4JProfile::SetDebugFullOverride(bool bVal) { - s_profileIsFullVersion = bVal; + +// GetPrimaryPad/SetPrimaryPad — delegates to InputManager. +// Kept here temporarily for call sites that still use ProfileManager. +// These forward to the canonical copies in C_4JInput. +int C_4JProfile::GetPrimaryPad() { + extern C_4JInput InputManager; + return InputManager.GetPrimaryPad(); +} +void C_4JProfile::SetPrimaryPad(int iPad) { + extern C_4JInput InputManager; + InputManager.SetPrimaryPad(iPad); } diff --git a/minecraft/4J.Profile/4J_Profile.h b/minecraft/4J.Profile/4J_Profile.h index 52f50ff65..b7e16565b 100644 --- a/minecraft/4J.Profile/4J_Profile.h +++ b/minecraft/4J.Profile/4J_Profile.h @@ -4,51 +4,11 @@ #include #include "../4J.Common/4J_Compat.h" - -enum eAwardType { - eAwardType_Achievement = 0, - eAwardType_GamerPic, - eAwardType_Theme, - eAwardType_AvatarItem, -}; - -enum eUpsellType { - eUpsellType_Custom = 0, // This is the default, and means that the upsell - // dialog was initiated in the app code - eUpsellType_Achievement, - eUpsellType_GamerPic, - eUpsellType_Theme, - eUpsellType_AvatarItem, -}; - -enum eUpsellResponse { - eUpsellResponse_Declined, - eUpsellResponse_Accepted_NoPurchase, - eUpsellResponse_Accepted_Purchase, -}; - -// -// Title info -// +#include "../platform/IPlatformProfile.h" #define TITLEID_MINECRAFT 0x584111F7 -// -// Context ids -// -// These values are passed as the dwContextId to XUserSetContext. -// - #define CONTEXT_GAME_STATE 0 - -// -// Context values -// -// These values are passed as the dwContextValue to XUserSetContext. -// - -// Values for CONTEXT_GAME_STATE - #define CONTEXT_GAME_STATE_BLANK 0 #define CONTEXT_GAME_STATE_RIDING_PIG 1 #define CONTEXT_GAME_STATE_RIDING_MINECART 2 @@ -59,12 +19,10 @@ enum eUpsellResponse { #define CONTEXT_GAME_STATE_NETHER 7 #define CONTEXT_GAME_STATE_CD 8 #define CONTEXT_GAME_STATE_MAP 9 -#define CONTEXT_GAME_STATE_ENCHANTING 5 // TODO 10 -#define CONTEXT_GAME_STATE_BREWING 5 // TODO 11 -#define CONTEXT_GAME_STATE_ANVIL 6 // TODO 12 -#define CONTEXT_GAME_STATE_TRADING 0 // TODO 13 - -// Values for X_CONTEXT_PRESENCE +#define CONTEXT_GAME_STATE_ENCHANTING 5 +#define CONTEXT_GAME_STATE_BREWING 5 +#define CONTEXT_GAME_STATE_ANVIL 6 +#define CONTEXT_GAME_STATE_TRADING 0 #define CONTEXT_PRESENCE_IDLE 0 #define CONTEXT_PRESENCE_MENUS 1 @@ -73,23 +31,10 @@ enum eUpsellResponse { #define CONTEXT_PRESENCE_MULTIPLAYER_1P 4 #define CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE 5 -// Values for X_CONTEXT_GAME_MODE - -#define CONTEXT_GAME_MODE_GAMEMODE 0 -#define CONTEXT_GAME_MODE_MULTIPLAYER 1 - -class C_4JProfile { +class C_4JProfile : public IPlatformProfile { public: - struct PROFILESETTINGS { - int iYAxisInversion; - int iControllerSensitivity; - int iVibration; - bool bSwapSticks; - }; + // --- Methods with real logic (implemented in .cpp) --- - // 4 players have game defined data, puiGameDefinedDataChangedBitmask needs - // to be checked by the game side to see if there's an update needed - it'll - // have the bits set for players to be updated void Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID, unsigned short usProfileVersion, unsigned int uiProfileValuesC, @@ -97,118 +42,85 @@ public: std::uint32_t* pdwProfileSettingsA, int iGameDefinedDataSizeX4, unsigned int* puiGameDefinedDataChangedBitmask); - void SetTrialTextStringTable(CXuiStringTable* pStringTable, int iAccept, - int iReject); - void SetTrialAwardText(eAwardType AwardType, int iTitle, - int iText); // achievement popup in the trial game + int GetLockedProfile(); void SetLockedProfile(int iProf); bool IsSignedIn(int iQuadrant); bool IsSignedInLive(int iProf); bool IsGuest(int iQuadrant); - unsigned int RequestSignInUI(bool bFromInvite, bool bLocalGame, - bool bNoGuestsAllowed, bool bMultiplayerSignIn, - bool bAddUser, - int (*Func)(void*, const bool, const int iPad), - void* lpParam, - int iQuadrant = XUSER_INDEX_ANY); - unsigned int DisplayOfflineProfile(int (*Func)(void*, const bool, - const int iPad), - void* lpParam, - int iQuadrant = XUSER_INDEX_ANY); - unsigned int RequestConvertOfflineToGuestUI( - int (*Func)(void*, const bool, const int iPad), void* lpParam, - int iQuadrant = XUSER_INDEX_ANY); - void SetPrimaryPlayerChanged(bool bVal); - bool QuerySigninStatus(void); + bool QuerySigninStatus(); void GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid); bool AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2); bool XUIDIsGuest(PlayerUID xuid); bool AllowedToPlayMultiplayer(int iProf); bool GetChatAndContentRestrictions(int iPad, bool* pbChatRestricted, bool* pbContentRestricted, int* piAge); - void StartTrialGame(); // disables saves and leaderboard, and change state - // to readyforgame from pregame + char* GetGamertag(int iPad); + std::wstring GetDisplayName(int iPad); + bool IsFullVersion(); + int SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*, + const int iPad), + void* lpParam); + PROFILESETTINGS* GetDashboardProfileSettings(int iPad); + void* GetGameDefinedProfileData(int iQuadrant); void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool* allAllowed, bool* friendsAllowed); bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PlayerUID* pXuids, unsigned int xuidCount); - void ShowProfileCard(int iPad, PlayerUID targetUid); - bool GetProfileAvatar(int iPad, - int (*Func)(void* lpParam, - std::uint8_t* thumbnailData, - unsigned int thumbnailBytes), - void* lpParam); - void CancelProfileAvatarRequest(); - // SYS + // --- Dead stubs (inline no-ops, kept for call-site compat) --- + + void Tick() {} + void SetTrialTextStringTable(CXuiStringTable*, int, int) {} + void SetTrialAwardText(eAwardType, int, int) {} + void StartTrialGame() {} + unsigned int RequestSignInUI(bool, bool, bool, bool, bool, + int (*)(void*, const bool, const int), + void*, int = XUSER_INDEX_ANY) { return 0; } + unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int), + void*, int = XUSER_INDEX_ANY) { return 0; } + unsigned int RequestConvertOfflineToGuestUI( + int (*)(void*, const bool, const int), void*, + int = XUSER_INDEX_ANY) { return 0; } + void SetPrimaryPlayerChanged(bool) {} + void ShowProfileCard(int, PlayerUID) {} + bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int), + void*) { return false; } + void CancelProfileAvatarRequest() {} + void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {} + void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int), + void*) {} + bool RegionIsNorthAmerica() { return false; } + bool LocaleIsUSorCanada() { return false; } + int GetLiveConnectionStatus() { return 0; } + bool IsSystemUIDisplayed() { return false; } + void SetProfileReadErrorCallback(void (*)(void*), void*) {} + int SetOldProfileVersionCallback(int (*)(void*, unsigned char*, + const unsigned short, const int), + void*) { return 0; } + void WriteToProfile(int, bool = false, bool = false) {} + void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {} + void ResetProfileProcessState() {} + void RegisterAward(int, int, eAwardType, bool = false, + CXuiStringTable* = nullptr, int = -1, int = -1, + int = -1, char* = nullptr, unsigned int = 0L) {} + int GetAwardId(int) { return 0; } + eAwardType GetAwardType(int) { return eAwardType_Achievement; } + bool CanBeAwarded(int, int) { return false; } + void Award(int, int, bool = false) {} + bool IsAwardsFlagSet(int, int) { return false; } + void RichPresenceInit(int, int) {} + void RegisterRichPresenceContext(int) {} + void SetRichPresenceContextValue(int, int, int) {} + void SetCurrentGameActivity(int, int, bool = false) {} + void DisplayFullVersionPurchase(bool, int, int = -1) {} + void SetUpsellCallback(void (*)(void*, eUpsellType, eUpsellResponse, int), + void*) {} + void SetDebugFullOverride(bool) {} + + // GetPrimaryPad/SetPrimaryPad moved to InputManager int GetPrimaryPad(); void SetPrimaryPad(int iPad); - char* GetGamertag(int iPad); - std::wstring GetDisplayName(int iPad); - bool IsFullVersion(); - void SetSignInChangeCallback(void (*Func)(void*, bool, unsigned int), - void* lpParam); - void SetNotificationsCallback(void (*Func)(void*, std::uint32_t, - unsigned int), - void* lpParam); - bool RegionIsNorthAmerica(void); - bool LocaleIsUSorCanada(void); - int GetLiveConnectionStatus(); - bool IsSystemUIDisplayed(); - void SetProfileReadErrorCallback(void (*Func)(void*), void* lpParam); - - // PROFILE DATA - int SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*, - const int iPad), - void* lpParam); - int SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*, - const unsigned short, - const int), - void* lpParam); - PROFILESETTINGS* GetDashboardProfileSettings(int iPad); - void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged = false, - bool bOverride5MinuteLimitOnProfileWrites = false); - void ForceQueuedProfileWrites(int iPad = XUSER_INDEX_ANY); - void* GetGameDefinedProfileData(int iQuadrant); - void ResetProfileProcessState(); // after a sign out from the primary - // player, call this - void Tick(void); - - // ACHIEVEMENTS & AWARDS - - void RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, - bool bLeaderboardAffected = false, - CXuiStringTable* pStringTable = nullptr, - int iTitleStr = -1, int iTextStr = -1, - int iAcceptStr = -1, char* pszThemeName = nullptr, - unsigned int uiThemeSize = 0L); - int GetAwardId(int iAwardNumber); - eAwardType GetAwardType(int iAwardNumber); - bool CanBeAwarded(int iQuadrant, int iAwardNumber); - void Award(int iQuadrant, int iAwardNumber, bool bForce = false); - bool IsAwardsFlagSet(int iQuadrant, int iAward); - - // RICH PRESENCE - - void RichPresenceInit(int iPresenceCount, int iContextCount); - void RegisterRichPresenceContext(int iGameConfigContextID); - void SetRichPresenceContextValue(int iPad, int iContextID, int iVal); - void SetCurrentGameActivity(int iPad, int iNewPresence, - bool bSetOthersToIdle = false); - - // PURCHASE - void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, - int iUpsellParam = -1); - void SetUpsellCallback(void (*Func)(void* lpParam, eUpsellType type, - eUpsellResponse response, - int iUserData), - void* lpParam); - - // Debug - void SetDebugFullOverride( - bool bVal); // To override the license version (trail/full). Only in - // debug/release, not ContentPackage }; // Singleton diff --git a/minecraft/4J.Profile/meson.build b/minecraft/4J.Profile/meson.build index fe70cbfbb..987d67212 100644 --- a/minecraft/4J.Profile/meson.build +++ b/minecraft/4J.Profile/meson.build @@ -1,10 +1,5 @@ profile_sources = files( '4J_Profile.cpp', - 'PRO_AwardManager.cpp', - 'PRO_Data.cpp', - 'PRO_Main.cpp', - 'PRO_RichPresence.cpp', - 'PRO_Sys.cpp', 'stdafx.cpp', ) # 4jprofile stink diff --git a/minecraft/4J.Render/4J_Render.h b/minecraft/4J.Render/4J_Render.h index 344c9f9b9..29c5ebdfb 100644 --- a/minecraft/4J.Render/4J_Render.h +++ b/minecraft/4J.Render/4J_Render.h @@ -3,40 +3,14 @@ #include #include +#include "../platform/IPlatformRender.h" + #ifdef __linux__ #include #include #endif -class ImageFileBuffer { -public: - enum EImageType { e_typePNG, e_typeJPG }; - EImageType m_type; - void* m_pBuffer; - int m_bufferSize; - int GetType() { return m_type; } - void* GetBufferPointer() { return m_pBuffer; } - int GetBufferSize() { return m_bufferSize; } - void Release() { - std::free(m_pBuffer); - m_pBuffer = nullptr; - } - bool Allocated() { return m_pBuffer != nullptr; } -}; - -typedef struct { - int Width; - int Height; -} D3DXIMAGE_INFO; - -typedef struct _XSOCIAL_PREVIEWIMAGE { - std::uint8_t* pBytes; - std::uint32_t Pitch; - std::uint32_t Width; - std::uint32_t Height; -} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE; - -class C4JRender { +class C4JRender : public IPlatformRender { public: void Tick(); void UpdateGamma(unsigned short usGamma); @@ -78,55 +52,8 @@ public: void BeginConditionalRendering(int identifier); void EndConditionalRendering(); - // Vertex data handling - typedef enum { - VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x - // float, colour 4 x byte, normal 4 x - // byte, padding 1 32-bit word - VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of - // VS_PS3_TS2_CS1.hlsl for description of - // layout - VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as - // VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 - // with lighting applied, - VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as - // VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 - // with tex gen - VERTEX_TYPE_COUNT - } eVertexType; - - // Pixel shader - typedef enum { - PIXEL_SHADER_TYPE_STANDARD, - PIXEL_SHADER_TYPE_PROJECTION, - PIXEL_SHADER_TYPE_FORCELOD, - PIXEL_SHADER_COUNT - } ePixelShaderType; - - typedef enum { - VIEWPORT_TYPE_FULLSCREEN, - VIEWPORT_TYPE_SPLIT_TOP, - VIEWPORT_TYPE_SPLIT_BOTTOM, - VIEWPORT_TYPE_SPLIT_LEFT, - VIEWPORT_TYPE_SPLIT_RIGHT, - VIEWPORT_TYPE_QUADRANT_TOP_LEFT, - VIEWPORT_TYPE_QUADRANT_TOP_RIGHT, - VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT, - VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT, - } eViewportType; - - typedef enum { - PRIMITIVE_TYPE_TRIANGLE_LIST, - PRIMITIVE_TYPE_TRIANGLE_STRIP, - PRIMITIVE_TYPE_TRIANGLE_FAN, - PRIMITIVE_TYPE_QUAD_LIST, - PRIMITIVE_TYPE_LINE_LIST, - PRIMITIVE_TYPE_LINE_STRIP, - PRIMITIVE_TYPE_COUNT - } ePrimitiveType; - void DrawVertices(ePrimitiveType PrimitiveType, int count, void* dataIn, - eVertexType vType, C4JRender::ePixelShaderType psType); + eVertexType vType, ePixelShaderType psType); // Command buffers void CBuffLockStaticCreations(); @@ -141,18 +68,6 @@ public: void CBuffDeferredModeStart(); void CBuffDeferredModeEnd(); - typedef enum { - TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per - // component - /* Don't think these are all directly available on D3D 11 - leaving for - now TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to - alpha channel, R=G=B=0 TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit - component mapped to alpha channel, R=G=B=1 TEXTURE_FORMAT_RxGxBxAx, - // One 8-bit component mapped to all channels - */ - MAX_TEXTURE_FORMATS - } eTextureFormat; - // Textures int TextureCreate(); void TextureFree(int idx); diff --git a/minecraft/4J.Storage/4J_Storage.h b/minecraft/4J.Storage/4J_Storage.h index ea72d3b01..1531740eb 100644 --- a/minecraft/4J.Storage/4J_Storage.h +++ b/minecraft/4J.Storage/4J_Storage.h @@ -7,6 +7,7 @@ // #include #include "../4J.Common/4J_Compat.h" +#include "../platform/IPlatformStorage.h" class C4JStringTable; @@ -14,23 +15,25 @@ class C4JStringTable; #define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3 #define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE -typedef struct { +struct CONTAINER_METADATA { time_t modifiedTime; unsigned int dataSize; unsigned int thumbnailSize; -} CONTAINER_METADATA; +}; -typedef struct { +struct SAVE_INFO { char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH]; char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH]; CONTAINER_METADATA metaData; std::uint8_t* thumbnailData; -} SAVE_INFO, *PSAVE_INFO; +}; +using PSAVE_INFO = SAVE_INFO*; -typedef struct { +struct SAVE_DETAILS { int iSaveC; PSAVE_INFO SaveInfoA; -} SAVE_DETAILS, *PSAVE_DETAILS; +}; +using PSAVE_DETAILS = SAVE_DETAILS*; typedef std::vector OfferDataArray; typedef std::vector XContentDataArray; @@ -39,89 +42,32 @@ typedef std::vector XContentDataArray; // Current version of the dlc data creator #define CURRENT_DLC_VERSION_NUM 3 -class C4JStorage { +class C4JStorage : public IPlatformStorage { public: - // Structs defined in the DLC_Creator, but added here to be used in the app - typedef struct { + struct DLC_FILE_DETAILS { unsigned int uiFileSize; std::uint32_t dwType; - std::uint32_t dwWchCount; // count of wchar_t in next array + std::uint32_t dwWchCount; wchar_t wchFile[1]; - } DLC_FILE_DETAILS, *PDLC_FILE_DETAILS; + }; + using PDLC_FILE_DETAILS = DLC_FILE_DETAILS*; - typedef struct { + struct DLC_FILE_PARAM { std::uint32_t dwType; - std::uint32_t dwWchCount; // count of wchar_t in next array; - wchar_t wchData[1]; // will be an array of size dwBytes - } DLC_FILE_PARAM, *PDLC_FILE_PARAM; - // End of DLC_Creator structs + std::uint32_t dwWchCount; + wchar_t wchData[1]; + }; + using PDLC_FILE_PARAM = DLC_FILE_PARAM*; - typedef struct { + struct CACHEINFOSTRUCT { wchar_t wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH]; char szFileName[XCONTENT_MAX_FILENAME_LENGTH]; std::uint32_t dwImageOffset; std::uint32_t dwImageBytes; - } CACHEINFOSTRUCT; - - // structure to hold DLC info in TMS - typedef struct { - std::uint32_t dwVersion; - std::uint32_t dwNewOffers; - std::uint32_t dwTotalOffers; - std::uint32_t dwInstalledTotalOffers; - std::uint8_t bPadding[1024 - sizeof(std::uint32_t) * 4]; - // future expansion - } DLC_TMS_DETAILS; + }; enum eGTS_FileTypes { eGTS_Type_Skin = 0, eGTS_Type_Cape, eGTS_Type_MAX }; - enum eGlobalStorage { - // eGlobalStorage_GameClip=0, - eGlobalStorage_Title = 0, - eGlobalStorage_TitleUser, - eGlobalStorage_Max - }; - - enum EMessageResult { - EMessage_Undefined = 0, - EMessage_Busy, - EMessage_Pending, - EMessage_Cancelled, - EMessage_ResultAccept, - EMessage_ResultDecline, - EMessage_ResultThirdOption, - EMessage_ResultFourthOption - }; - - enum ESaveGameControlState { - ESaveGameControl_Idle = 0, - ESaveGameControl_Save, - ESaveGameControl_InternalRequestingDevice, - ESaveGameControl_InternalGetSaveName, - ESaveGameControl_InternalSaving, - ESaveGameControl_CopySave, - ESaveGameControl_CopyingSave, - }; - - enum ESaveGameState { - ESaveGame_Idle = 0, - ESaveGame_Save, - ESaveGame_InternalRequestingDevice, - ESaveGame_InternalGetSaveName, - ESaveGame_InternalSaving, - ESaveGame_CopySave, - ESaveGame_CopyingSave, - ESaveGame_Load, - ESaveGame_GetSavesInfo, - ESaveGame_Rename, - ESaveGame_Delete, - - ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4, - // but the game expects this to be returned - // to indicate success when getting a - // thumbnail - - }; enum ELoadGameStatus { ELoadGame_Idle = 0, ELoadGame_InProgress, @@ -142,60 +88,20 @@ public: ESGIStatus_NoSaves, }; - enum EDLCStatus { - EDLC_Error = 0, - EDLC_Idle, - EDLC_NoOffers, - EDLC_AlreadyEnumeratedAllOffers, - EDLC_NoInstalledDLC, - EDLC_Pending, - EDLC_LoadInProgress, - EDLC_Loaded, - EDLC_ChangedDevice - }; - - enum ESavingMessage { - ESavingMessage_None = 0, - ESavingMessage_Short, - ESavingMessage_Long - }; - - enum ETMSStatus { - ETMSStatus_Idle = 0, - ETMSStatus_Fail, - ETMSStatus_Fail_ReadInProgress, - ETMSStatus_Fail_WriteInProgress, - ETMSStatus_Pending, - }; - - enum eTMS_FileType { - eTMS_FileType_Normal = 0, - eTMS_FileType_Graphic, - }; - - enum eTMS_FILETYPEVAL { - TMS_FILETYPE_BINARY, - TMS_FILETYPE_CONFIG, - TMS_FILETYPE_JSON, - TMS_FILETYPE_MAX - }; enum eTMS_UGCTYPE { TMS_UGCTYPE_NONE, TMS_UGCTYPE_IMAGE, TMS_UGCTYPE_MAX }; - typedef struct { + struct TMSPP_FILE_DETAILS { char szFilename[256]; int iFileSize; eTMS_FILETYPEVAL eFileTypeVal; - } TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS; + }; + using PTMSPP_FILE_DETAILS = TMSPP_FILE_DETAILS*; - typedef struct { + struct TMSPP_FILE_LIST { int iCount; PTMSPP_FILE_DETAILS FileDetailsA; - } TMSPP_FILE_LIST, *PTMSPP_FILE_LIST; - - typedef struct { - unsigned int size; - std::uint8_t* pbData; - } TMSPP_FILEDATA, *PTMSPP_FILEDATA; + }; + using PTMSPP_FILE_LIST = TMSPP_FILE_LIST*; C4JStorage(); diff --git a/minecraft/Minecraft.Client/Linux/Linux_App.cpp b/minecraft/Minecraft.Client/Linux/Linux_App.cpp index be17eeed0..735f1921b 100644 --- a/minecraft/Minecraft.Client/Linux/Linux_App.cpp +++ b/minecraft/Minecraft.Client/Linux/Linux_App.cpp @@ -18,8 +18,6 @@ CConsoleMinecraftApp app; CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {} void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) { - ProfileManager.SetRichPresenceContextValue(iPad, CONTEXT_GAME_STATE, - contextId); } void CConsoleMinecraftApp::StoreLaunchData() {} diff --git a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp index d44621a5e..b36ca8eff 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp @@ -655,7 +655,7 @@ void Minecraft::updatePlayerViewportAssignments() { for (int i = 0; i < XUSER_MAX_COUNT; i++) { if (localplayers[i] != nullptr) { // Primary player settings decide what the mode is - if (app.GetGameSettings(ProfileManager.GetPrimaryPad(), + if (app.GetGameSettings(InputManager.GetPrimaryPad(), eGameSetting_SplitScreenVertical)) { localplayers[i]->m_iScreenSection = C4JRender::VIEWPORT_TYPE_SPLIT_LEFT + found; @@ -926,7 +926,7 @@ void Minecraft::removeLocalPlayerIdx(int idx) { } localplayers[idx] = nullptr; - if (idx == ProfileManager.GetPrimaryPad()) { + if (idx == InputManager.GetPrimaryPad()) { // We should never try to remove the Primary player in this way assert(false); /* @@ -957,9 +957,9 @@ void Minecraft::createPrimaryLocalPlayer(int iPad) { localplayers[iPad] = player; // gameRenderer->itemInHandRenderer = localitemInHandRenderers[iPad]; // Give them the gamertag if they're signed in - if (ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) { + if (ProfileManager.IsSignedIn(InputManager.GetPrimaryPad())) { user->name = convStringToWstring( - ProfileManager.GetGamertag(ProfileManager.GetPrimaryPad())); + ProfileManager.GetGamertag(InputManager.GetPrimaryPad())); } } @@ -1021,17 +1021,17 @@ void Minecraft::run_middle() { // player has a app action running , or has any crafting // or containers open, don't autosave if (!StorageManager.GetSaveDisabled() && - (app.GetXuiAction(ProfileManager.GetPrimaryPad()) == + (app.GetXuiAction(InputManager.GetPrimaryPad()) == eAppAction_Idle)) { if (!ui.IsPauseMenuDisplayed( - ProfileManager.GetPrimaryPad()) && + InputManager.GetPrimaryPad()) && !ui.IsIgnoreAutosaveMenuDisplayed( - ProfileManager.GetPrimaryPad())) { + InputManager.GetPrimaryPad())) { // check if the autotimer countdown has reached // zero unsigned char ucAutosaveVal = app.GetGameSettings( - ProfileManager.GetPrimaryPad(), + InputManager.GetPrimaryPad(), eGameSetting_Autosave); bool bTrialTexturepack = false; if (!Minecraft::GetInstance() @@ -1068,7 +1068,7 @@ void Minecraft::run_middle() { app.DebugPrintf("+++Autosave\n"); app.DebugPrintf("+++++++++++\n"); app.SetAction( - ProfileManager.GetPrimaryPad(), + InputManager.GetPrimaryPad(), eAppAction_AutosaveSaveGame); // app.SetAutosaveTimerTime(); #if !defined(_CONTENT_PACKAGE) @@ -1320,7 +1320,7 @@ void Minecraft::run_middle() { // exist? They'll be wanting to join the game then bool tryJoin = !pause && !ui.IsIgnorePlayerJoinMenuDisplayed( - ProfileManager.GetPrimaryPad()) && + InputManager.GetPrimaryPad()) && g_NetworkManager.SessionHasSpace() && RenderManager.IsHiDef() && InputManager.ButtonPressed(i); @@ -1531,7 +1531,7 @@ void Minecraft::run_middle() { ui.HandleGameTick(); - setLocalPlayerIdx(ProfileManager.GetPrimaryPad()); + setLocalPlayerIdx(InputManager.GetPrimaryPad()); // 4J - added - now do the equivalent of level::animateTick, // but taking into account the positions of all our players @@ -1583,7 +1583,7 @@ void Minecraft::run_middle() { if (!noRender) { bool bFirst = true; - int iPrimaryPad = ProfileManager.GetPrimaryPad(); + int iPrimaryPad = InputManager.GetPrimaryPad(); for (int i = 0; i < XUSER_MAX_COUNT; i++) { if (setLocalPlayerIdx(i)) { PIXBeginNamedEvent(0, "Game render player idx %d", @@ -3320,7 +3320,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { #if defined(_DEBUG_MENUS_ENABLED) if (app.DebugSettingsOn()) { // 4J-PB - debugoverlay for primary player only - if (iPad == ProfileManager.GetPrimaryPad()) { + if (iPad == InputManager.GetPrimaryPad()) { if ((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_RENDER_DEBUG))) { #if !defined(_CONTENT_PACKAGE) @@ -3793,7 +3793,7 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/, // If no player has been set, then this is the first level to be set // this game, so set up a primary player & initialise some other things if (player == nullptr) { - int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); + int iPrimaryPlayer = InputManager.GetPrimaryPad(); player = gameMode->createPlayer(level); @@ -4007,11 +4007,11 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { cameraTargetPlayer = player; // 4J-PB - are we the primary player or a local player? - if (iPad == ProfileManager.GetPrimaryPad()) { + if (iPad == InputManager.GetPrimaryPad()) { createPrimaryLocalPlayer(iPad); // update the debugoptions - app.SetGameSettingsDebugMask(ProfileManager.GetPrimaryPad(), + app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(), app.GetGameSettingsDebugMask(-1, true)); } else { storeExtraLocalPlayer(iPad); @@ -4456,7 +4456,7 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) { } } } else if (ProfileManager.IsSignedInLive( - ProfileManager.GetPrimaryPad()) && + InputManager.GetPrimaryPad()) && !ProfileManager.AllowedToPlayMultiplayer(iPad)) { // 4J Stu - Don't allow converting to guests as we don't allow // any guest sign-in while in the game Fix for #66516 - TCR diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp index 82007a2a6..80ddc7325 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp @@ -306,7 +306,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 4J - this is where to set the blend factor for gui things // use the primary player's settings unsigned char ucAlpha = app.GetGameSettings( - ProfileManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); + InputManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); // If the user has started to navigate their quickselect bar, ignore the // alpha setting, and display at default value diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp index aeccaa1b7..2a1ce89ea 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp @@ -25,7 +25,7 @@ void PauseScreen::init() { // 4jcraft: solves the issue of client-side only pausing in the java gui if (g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1) - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + app.SetXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)true); buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + yo, I18n::get(L"menu.returnToMenu"))); @@ -83,7 +83,7 @@ void PauseScreen::buttonClicked(Button* button) { exitWorld(minecraft, true); } if (button->id == 4) { - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + app.SetXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)false); minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/Screen.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/Screen.cpp index 39be72ea5..a5405d951 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/Screen.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/Screen.cpp @@ -33,7 +33,7 @@ void Screen::keyPressed(wchar_t eventCharacter, int eventKey) { // unpausing is done in all scenarios if (g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1) - app.SetXuiServerAction(ProfileManager.GetPrimaryPad(), + app.SetXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)false); } } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp index f354c7021..abb9d91ee 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp @@ -69,7 +69,7 @@ ClientConnection::ClientConnection(Minecraft* minecraft, Socket* socket, this->minecraft = minecraft; if (iUserIndex < 0) { - m_userIndex = ProfileManager.GetPrimaryPad(); + m_userIndex = InputManager.GetPrimaryPad(); } else { m_userIndex = iUserIndex; } @@ -131,7 +131,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { INetworkPlayer* networkPlayer = connection->getSocket()->getPlayer(); int iUserID = -1; - if (m_userIndex == ProfileManager.GetPrimaryPad()) { + if (m_userIndex == InputManager.GetPrimaryPad()) { iUserID = m_userIndex; } else { if (!networkPlayer->IsGuest() && networkPlayer->IsLocal()) { @@ -187,18 +187,18 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { app.SetBanListCheck(iUserID, false); } - if (m_userIndex == ProfileManager.GetPrimaryPad()) { + if (m_userIndex == InputManager.GetPrimaryPad()) { if (app.GetTutorialMode()) { minecraft->gameMode = new FullTutorialMode( - ProfileManager.GetPrimaryPad(), minecraft, this); + InputManager.GetPrimaryPad(), minecraft, this); } // check if we're in the trial version else if (ProfileManager.IsFullVersion() == false) { minecraft->gameMode = - new TrialMode(ProfileManager.GetPrimaryPad(), minecraft, this); + new TrialMode(InputManager.GetPrimaryPad(), minecraft, this); } else { minecraft->gameMode = new ConsoleGameMode( - ProfileManager.GetPrimaryPad(), minecraft, this); + InputManager.GetPrimaryPad(), minecraft, this); } Level* dimensionLevel = minecraft->getLevel(packet->dimension); @@ -233,7 +233,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { minecraft->player->setCustomSkin(app.GetPlayerSkinId(m_userIndex)); minecraft->player->setCustomCape(app.GetPlayerCapeId(m_userIndex)); - minecraft->createPrimaryLocalPlayer(ProfileManager.GetPrimaryPad()); + minecraft->createPrimaryLocalPlayer(InputManager.GetPrimaryPad()); minecraft->player->dimension = packet->dimension; minecraft->setScreen(new ReceivingLevelScreen(this)); @@ -258,7 +258,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { displayPrivilegeChanges(minecraft->player, startingPrivileges); // update the debugoptions - app.SetGameSettingsDebugMask(ProfileManager.GetPrimaryPad(), + app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(), app.GetGameSettingsDebugMask(-1, true)); } else { // 4J-PB - this isn't the level we want @@ -1238,12 +1238,12 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, if (g_NetworkManager.IsHost() && (reason == DisconnectPacket::eDisconnect_TimeOut || reason == DisconnectPacket::eDisconnect_Overflow) && - m_userIndex == ProfileManager.GetPrimaryPad() && + m_userIndex == InputManager.GetPrimaryPad() && !MinecraftServer::saveOnExitAnswered()) { unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, - ProfileManager.GetPrimaryPad(), + InputManager.GetPrimaryPad(), &ClientConnection::HostDisconnectReturned, nullptr); } else { @@ -1812,7 +1812,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { // 4J-PB - if we go straight in from the menus via an invite, we won't // have the DLC info if (app.GetTMSGlobalFileListRead() == false) { - app.SetTMSAction(ProfileManager.GetPrimaryPad(), + app.SetTMSAction(InputManager.GetPrimaryPad(), eTMSAction_TMSPP_RetrieveFiles_RunPlayGame); } } @@ -1827,7 +1827,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { cantPlayContentRestricted) { DisconnectPacket::eDisconnectReason reason = DisconnectPacket::eDisconnect_NoUGC_Remote; - if (m_userIndex == ProfileManager.GetPrimaryPad()) { + if (m_userIndex == InputManager.GetPrimaryPad()) { if (!isFriendsWithHost) reason = DisconnectPacket::eDisconnect_NotFriendsWithHost; else if (!isAtLeastOneFriend) @@ -1843,7 +1843,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { "privileges: %d\n", reason); app.SetDisconnectReason(reason); - app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ExitWorld, + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ExitWorld, (void*)true); } else { if (!isFriendsWithHost) @@ -1890,7 +1890,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { // send this before the LoginPacket so that it gets handled first, as // once the LoginPacket is received on the client the game is close to // starting - if (m_userIndex == ProfileManager.GetPrimaryPad()) { + if (m_userIndex == InputManager.GetPrimaryPad()) { Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->skins->selectTexturePackById( packet->m_texturePackId)) { @@ -2890,12 +2890,12 @@ void ClientConnection::handleGameEvent( app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown - if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != + if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr) - minecraft->localgameModes[ProfileManager.GetPrimaryPad()] + minecraft->localgameModes[InputManager.GetPrimaryPad()] ->getTutorial() ->showTutorialPopup(false); - ui.NavigateToScene(ProfileManager.GetPrimaryPad(), eUIScene_EndPoem, + ui.NavigateToScene(InputManager.GetPrimaryPad(), eUIScene_EndPoem, nullptr, eUILayer_Scene, eUIGroup_Fullscreen); } else if (event == GameEventPacket::START_SAVING) { if (!g_NetworkManager.IsHost()) { @@ -2903,7 +2903,7 @@ void ClientConnection::handleGameEvent( // back-to-back START/STOP packets leave the client stuck in the // loading screen app.SetGameStarted(false); - app.SetAction(ProfileManager.GetPrimaryPad(), + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_RemoteServerSave); } } else if (event == GameEventPacket::STOP_SAVING) { @@ -3338,7 +3338,7 @@ int ClientConnection::HostDisconnectReturned( uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; ui.RequestErrorMessage(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, - uiIDA, 2, ProfileManager.GetPrimaryPad(), + uiIDA, 2, InputManager.GetPrimaryPad(), &ClientConnection::ExitGameAndSaveReturned, nullptr); } else { @@ -3357,7 +3357,7 @@ int ClientConnection::ExitGameAndSaveReturned( // int32_t saveOrCheckpointId = 0; // bool validSave = // StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); - // SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), + // SentientManager.RecordLevelSaveOrCheckpoint(InputManager.GetPrimaryPad(), // saveOrCheckpointId); MinecraftServer::getInstance()->setSaveOnExit(true); } else { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.cpp index c698a10a3..0b4c585ff 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.cpp @@ -135,7 +135,7 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { (Tile::tiles[t]->getDestroyProgress( minecraft->player, minecraft->player->level, x, y, z) >= 1 // ||(app.DebugSettingsOn() && - // app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<player != mc->localplayers[ProfileManager.GetPrimaryPad()]) + if (mc->player != mc->localplayers[InputManager.GetPrimaryPad()]) return; // 4J added for split screen - only do rest of processing for // once per frame @@ -1192,7 +1192,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { // view whatever they have loaded in - we're sharing render data between // players. bool updateChunks = - (mc->player == mc->localplayers[ProfileManager.GetPrimaryPad()]); + (mc->player == mc->localplayers[InputManager.GetPrimaryPad()]); // if (mc->cameraTargetPlayer == nullptr) // 4J - removed condition as we // want to update this is mc->player changes for different local players diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp index f693ecfa5..290f20c5c 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp @@ -389,7 +389,7 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel* level) { // tile entities in the world dissappear We should only do this when // actually exiting the game, so only when the primary player sets there // level to nullptr - if (playerIndex == ProfileManager.GetPrimaryPad()) { + if (playerIndex == InputManager.GetPrimaryPad()) { { std::lock_guard lock(m_csRenderableTileEntities); renderableTileEntities.clear(); @@ -1117,7 +1117,7 @@ void LevelRenderer::renderClouds(float alpha) { int playerIndex = mc->player->GetXboxPad(); // if the primary player has clouds off, so do all players on this machine - if (app.GetGameSettings(ProfileManager.GetPrimaryPad(), + if (app.GetGameSettings(InputManager.GetPrimaryPad(), eGameSetting_Clouds) == 0) { return; } @@ -1131,7 +1131,7 @@ void LevelRenderer::renderClouds(float alpha) { } if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime)) { iTicks = m_freezeticks; } @@ -1209,7 +1209,7 @@ void LevelRenderer::renderClouds(float alpha) { glEnable(GL_CULL_FACE); if (app.DebugSettingsOn()) { - if (!(app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + if (!(app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime))) { m_freezeticks = iTicks; } @@ -1395,7 +1395,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { int iTicks = ticks; if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime)) { iTicks = m_freezeticks; } @@ -1642,7 +1642,7 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { glEnable(GL_CULL_FACE); if (app.DebugSettingsOn()) { - if (!(app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + if (!(app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime))) { m_freezeticks = iTicks; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/skins/DLCTexturePack.cpp b/minecraft/Minecraft.Client/net/minecraft/client/skins/DLCTexturePack.cpp index 26ecb6cc1..5ecdfb498 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/skins/DLCTexturePack.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/skins/DLCTexturePack.cpp @@ -218,7 +218,7 @@ void DLCTexturePack::loadData() { int mountIndex = m_dlcInfoPack->GetDLCMountIndex(); if (mountIndex > -1) { - if (StorageManager.MountInstalledDLC(ProfileManager.GetPrimaryPad(), + if (StorageManager.MountInstalledDLC(InputManager.GetPrimaryPad(), mountIndex, &DLCTexturePack::packMounted, this, "TPACK") != ERROR_IO_PENDING) { @@ -227,7 +227,7 @@ void DLCTexturePack::loadData() { if (app.getLevelGenerationOptions()) app.getLevelGenerationOptions()->setLoadedData(); app.DebugPrintf("Failed to mount texture pack DLC %d for pad %d\n", - mountIndex, ProfileManager.GetPrimaryPad()); + mountIndex, InputManager.GetPrimaryPad()); } else { m_bLoadingData = true; app.DebugPrintf("Attempted to mount DLC data for texture pack %d\n", @@ -237,7 +237,7 @@ void DLCTexturePack::loadData() { m_bHasLoadedData = true; if (app.getLevelGenerationOptions()) app.getLevelGenerationOptions()->setLoadedData(); - app.SetAction(ProfileManager.GetPrimaryPad(), + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } } @@ -382,7 +382,7 @@ int DLCTexturePack::packMounted(void* pParam, int iPad, std::uint32_t dwErr, texturePack->m_bHasLoadedData = true; if (app.getLevelGenerationOptions()) app.getLevelGenerationOptions()->setLoadedData(); - app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); return 0; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/skins/TexturePackRepository.cpp b/minecraft/Minecraft.Client/net/minecraft/client/skins/TexturePackRepository.cpp index de3c2ab25..7fedade65 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/skins/TexturePackRepository.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/skins/TexturePackRepository.cpp @@ -149,7 +149,7 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { selectSkin(newPack); if (newPack->hasData()) { - app.SetAction(ProfileManager.GetPrimaryPad(), + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } else { newPack->loadData(); @@ -169,7 +169,7 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { #endif // Fail safely if (selectSkin(DEFAULT_TEXTURE_PACK)) { - app.SetAction(ProfileManager.GetPrimaryPad(), + app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } } diff --git a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp index 5c2a6113c..767a348b2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp @@ -799,7 +799,7 @@ void MinecraftServer::saveAllChunks() { void MinecraftServer::saveGameRules() { #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { // Do nothing } else @@ -883,7 +883,7 @@ void MinecraftServer::stopServer(bool didInit) { // also need to check for a profile switch here - primary player signs out, // and another player signs in before dismissing the dash if ((m_bPrimaryPlayerSignedOut == false) && - ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) { + ProfileManager.IsSignedIn(InputManager.GetPrimaryPad())) { // if trial version or saving is disabled, then don't save anything. // Also don't save anything if we didn't actually get through the server // initialisation. diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp index 42b4579f3..80855f645 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp @@ -300,7 +300,7 @@ void ServerLevel::tick() { #if !defined(_FINAL_BUILD) bool freezeTime = app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime); if (!freezeTime) #endif diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp index 46ffb7d08..57d0ae076 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp @@ -507,7 +507,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { void ServerPlayer::doTickB() { #if !defined(_CONTENT_PACKAGE) // check if there's a debug dimension change requested - // if(app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<dimension->id == 0 ) // { @@ -515,11 +515,11 @@ void ServerPlayer::doTickB() { // portalTime=1; // } // unsigned int - // uiVal=app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()); - // app.SetGameSettingsDebugMask(ProfileManager.GetPrimaryPad(),uiVal&~(1L<dimension->id == 0 ) // { @@ -527,20 +527,20 @@ void ServerPlayer::doTickB() { // std::dynamic_pointer_cast( shared_from_this() ), 1 ); // } // unsigned int - // uiVal=app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()); - // app.SetGameSettingsDebugMask(ProfileManager.GetPrimaryPad(),uiVal&~(1L<dimension->id != 0) { isInsidePortal = true; portalTime = 1; } unsigned int uiVal = - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()); + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()); app.SetGameSettingsDebugMask( - ProfileManager.GetPrimaryPad(), + InputManager.GetPrimaryPad(), uiVal & ~(1L << eDebugSetting_GoToOverworld)); } #endif diff --git a/minecraft/Minecraft.Client/net/minecraft/stats/StatsCounter.cpp b/minecraft/Minecraft.Client/net/minecraft/stats/StatsCounter.cpp index 024f71846..685adbf3b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/stats/StatsCounter.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/stats/StatsCounter.cpp @@ -249,7 +249,6 @@ void StatsCounter::save(int player, bool force) { } } - ProfileManager.WriteToProfile(player, true, force); saveCounter = SAVE_DELAY; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp index e54648d70..d09778ceb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp @@ -308,7 +308,7 @@ MobGroupData* Ocelot::finalizeMobSpawn( setTame(true); setCatType(extraData - 1); setOwnerUUID(Minecraft::GetInstance() - ->localplayers[ProfileManager.GetPrimaryPad()] + ->localplayers[InputManager.GetPrimaryPad()] ->getUUID()); } else #endif diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp index 2bc6a821e..a50603b32 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp @@ -167,7 +167,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, // app.DebugPrintf("=== FOUND stronghold in // terrain features list\n"); // - // app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),eXuiServerAction_StrongholdPosition); + // app.SetXuiServerAction(InputManager.GetPrimaryPad(),eXuiServerAction_StrongholdPosition); // } // else { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp index b86de3a80..3395c0aac 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp @@ -2826,7 +2826,7 @@ void Level::tickWeather() { #if !defined(_FINAL_BUILD) // debug setting added to disable weather if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_DisableWeather)) { levelData->setThundering(false); levelData->setThunderTime(random->nextInt(TICKS_PER_DAY * 7) + diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp index 520372473..a0b718bfd 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp @@ -349,7 +349,7 @@ int64_t BiomeSource::findSeed(LevelType* generator) { #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Do nothing } else diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp index d74924c64..fd19157b6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp @@ -180,7 +180,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { } #if !defined(_CONTENT_PACKAGE) if (levelChunk && app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // 4J Stu - This will force an update of the chunk's biome array levelChunk->reloadBiomes(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp index 2fdea8f62..858dd98a7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp @@ -470,7 +470,7 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Read the biome data from the stream, but don't use it std::vector dummyBiomes(levelChunk->biomes.size()); @@ -584,7 +584,7 @@ LevelChunk* OldChunkStorage::load(Level* level, CompoundTag* tag) { #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Do nothing } else diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp index 3ef5dd5f7..052daea88 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp @@ -51,7 +51,7 @@ void Dimension::init() { // 4J Stu - Added to enable overriding the heightmap from a loaded in data // file if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { biomeSource = new BiomeSource(level); } else @@ -86,7 +86,7 @@ ChunkSource* Dimension::createRandomLevelSource() const { // 4J Stu - Added to enable overriding the heightmap from a loaded in data // file if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableHeightWaterOverride)) { return new CustomLevelSource( level, level->getSeed(), diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp index b5c0b7724..fa5b519f5 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp @@ -48,7 +48,7 @@ void HellDimension::updateLightRamp() { ChunkSource* HellDimension::createRandomLevelSource() const { #ifdef _DEBUG_MENUS_ENABLED if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_SuperflatNether)) { return new HellFlatLevelSource(level, level->getSeed()); } else diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp index bc7200e24..2f1cc48fb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp @@ -113,7 +113,7 @@ std::vector> Layer::getDefaultLayers(int64_t seed, LevelT #if !defined(_CONTENT_PACKAGE) #if defined(_BIOME_OVERRIDE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { biomeLayer = std::shared_ptr(new BiomeOverrideLayer(1)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp index e55591dfa..d5e61dce7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp @@ -454,7 +454,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() { if (playerFiles != nullptr) { #if !defined(_FINAL_BUILD) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { for (unsigned int i = 0; i < playerFiles->size(); ++i) { FileEntry* file = playerFiles->at(i); @@ -500,7 +500,7 @@ std::wstring DirectoryLevelStorage::getLevelId() { return levelId; } void DirectoryLevelStorage::flushSaveFile(bool autosave) { #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) & + app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { // Delete gamerules files if it exists ConsoleSavePath gameRulesFiles(GAME_RULE_SAVENAME); diff --git a/minecraft/platform/IPlatformInput.h b/minecraft/platform/IPlatformInput.h new file mode 100644 index 000000000..c94d978b6 --- /dev/null +++ b/minecraft/platform/IPlatformInput.h @@ -0,0 +1,111 @@ +#pragma once + +#include + +enum EKeyboardResult { + EKeyboard_Pending, + EKeyboard_Cancelled, + EKeyboard_ResultAccept, + EKeyboard_ResultDecline, +}; + +typedef struct _STRING_VERIFY_RESPONSE { + std::uint16_t wNumStrings; + int* pStringResult; +} STRING_VERIFY_RESPONSE; + +class IPlatformInput { +public: + enum EKeyboardMode { + EKeyboardMode_Default, + EKeyboardMode_Numeric, + EKeyboardMode_Password, + EKeyboardMode_Alphabet, + EKeyboardMode_Full, + EKeyboardMode_Alphabet_Extended, + EKeyboardMode_IP_Address, + EKeyboardMode_Phone + }; + + virtual ~IPlatformInput() = default; + + virtual void Initialise(int iInputStateC, unsigned char ucMapC, + unsigned char ucActionC, + unsigned char ucMenuActionC) = 0; + virtual void Tick() = 0; + virtual void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, + unsigned int uiMovementRangeMax) = 0; + + // Joypad mapping + virtual void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, + unsigned int uiActionVal) = 0; + virtual unsigned int GetGameJoypadMaps(unsigned char ucMap, + unsigned char ucAction) = 0; + virtual void SetJoypadMapVal(int iPad, unsigned char ucMap) = 0; + virtual unsigned char GetJoypadMapVal(int iPad) = 0; + virtual void SetJoypadSensitivity(int iPad, float fSensitivity) = 0; + + // Input queries + virtual unsigned int GetValue(int iPad, unsigned char ucAction, + bool bRepeat = false) = 0; + virtual bool ButtonPressed(int iPad, unsigned char ucAction = 255) = 0; + virtual bool ButtonReleased(int iPad, unsigned char ucAction) = 0; + virtual bool ButtonDown(int iPad, unsigned char ucAction = 255) = 0; + + // Axis remapping + virtual void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, + unsigned int uiTo) = 0; + virtual void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, + unsigned int uiTo) = 0; + virtual void SetKeyRepeatRate(float fRepeatDelaySecs, + float fRepeatRateSecs) = 0; + virtual void SetDebugSequence(const char* chSequenceA, int (*Func)(void*), + void* lpParam) = 0; + virtual float GetIdleSeconds(int iPad) = 0; + virtual bool IsPadConnected(int iPad) = 0; + + // Analog sticks and triggers (remapped for Southpaw etc.) + virtual float GetJoypadStick_LX(int iPad, + bool bCheckMenuDisplay = true) = 0; + virtual float GetJoypadStick_LY(int iPad, + bool bCheckMenuDisplay = true) = 0; + virtual float GetJoypadStick_RX(int iPad, + bool bCheckMenuDisplay = true) = 0; + virtual float GetJoypadStick_RY(int iPad, + bool bCheckMenuDisplay = true) = 0; + virtual unsigned char GetJoypadLTrigger(int iPad, + bool bCheckMenuDisplay = true) = 0; + virtual unsigned char GetJoypadRTrigger(int iPad, + bool bCheckMenuDisplay = true) = 0; + + // Menu and misc + virtual void SetMenuDisplayed(int iPad, bool bVal) = 0; + virtual bool GetMenuDisplayed(int iPad) = 0; + virtual int GetHotbarSlotPressed(int iPad) = 0; + virtual int GetScrollDelta() = 0; + + // Keyboard + virtual EKeyboardResult RequestKeyboard(const wchar_t* Title, + const wchar_t* Text, int iPad, + unsigned int uiMaxChars, + int (*Func)(void*, const bool), + void* lpParam, + EKeyboardMode eMode) = 0; + virtual const char* GetText() = 0; + + // String verification (TCR 92) + virtual bool VerifyStrings(wchar_t** pwStringA, int iStringC, + int (*Func)(void*, STRING_VERIFY_RESPONSE*), + void* lpParam) = 0; + virtual void CancelQueuedVerifyStrings( + int (*Func)(void*, STRING_VERIFY_RESPONSE*), void* lpParam) = 0; + virtual void CancelAllVerifyInProgress() = 0; + + // Mouse + virtual int GetMouseX() = 0; + virtual int GetMouseY() = 0; + + // Primary pad (which controller is player 1) + virtual int GetPrimaryPad() = 0; + virtual void SetPrimaryPad(int iPad) = 0; +}; diff --git a/minecraft/platform/IPlatformProfile.h b/minecraft/platform/IPlatformProfile.h new file mode 100644 index 000000000..7eb2b26a8 --- /dev/null +++ b/minecraft/platform/IPlatformProfile.h @@ -0,0 +1,167 @@ +#pragma once + +#include +#include + +#include "../4J.Common/4J_Compat.h" + +class CXuiStringTable; + +enum eAwardType { + eAwardType_Achievement = 0, + eAwardType_GamerPic, + eAwardType_Theme, + eAwardType_AvatarItem, +}; + +enum eUpsellType { + eUpsellType_Custom = 0, + eUpsellType_Achievement, + eUpsellType_GamerPic, + eUpsellType_Theme, + eUpsellType_AvatarItem, +}; + +enum eUpsellResponse { + eUpsellResponse_Declined, + eUpsellResponse_Accepted_NoPurchase, + eUpsellResponse_Accepted_Purchase, +}; + +class IPlatformProfile { +public: + struct PROFILESETTINGS { + int iYAxisInversion; + int iControllerSensitivity; + int iVibration; + bool bSwapSticks; + }; + + virtual ~IPlatformProfile() = default; + + // Lifecycle + virtual void Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID, + unsigned short usProfileVersion, + unsigned int uiProfileValuesC, + unsigned int uiProfileSettingsC, + std::uint32_t* pdwProfileSettingsA, + int iGameDefinedDataSizeX4, + unsigned int* puiGameDefinedDataChangedBitmask) = 0; + virtual void Tick() = 0; + + // Sign-in + virtual int GetLockedProfile() = 0; + virtual void SetLockedProfile(int iProf) = 0; + virtual bool IsSignedIn(int iQuadrant) = 0; + virtual bool IsSignedInLive(int iProf) = 0; + virtual bool IsGuest(int iQuadrant) = 0; + virtual unsigned int RequestSignInUI( + bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, + bool bMultiplayerSignIn, bool bAddUser, + int (*Func)(void*, const bool, const int iPad), void* lpParam, + int iQuadrant = XUSER_INDEX_ANY) = 0; + virtual unsigned int DisplayOfflineProfile( + int (*Func)(void*, const bool, const int iPad), void* lpParam, + int iQuadrant = XUSER_INDEX_ANY) = 0; + virtual unsigned int RequestConvertOfflineToGuestUI( + int (*Func)(void*, const bool, const int iPad), void* lpParam, + int iQuadrant = XUSER_INDEX_ANY) = 0; + virtual void SetPrimaryPlayerChanged(bool bVal) = 0; + virtual bool QuerySigninStatus() = 0; + virtual void GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) = 0; + virtual bool AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) = 0; + virtual bool XUIDIsGuest(PlayerUID xuid) = 0; + virtual bool AllowedToPlayMultiplayer(int iProf) = 0; + virtual bool GetChatAndContentRestrictions(int iPad, bool* pbChatRestricted, + bool* pbContentRestricted, + int* piAge) = 0; + + // System + virtual int GetPrimaryPad() = 0; + virtual void SetPrimaryPad(int iPad) = 0; + virtual char* GetGamertag(int iPad) = 0; + virtual std::wstring GetDisplayName(int iPad) = 0; + virtual bool IsFullVersion() = 0; + virtual void SetSignInChangeCallback( + void (*Func)(void*, bool, unsigned int), void* lpParam) = 0; + virtual void SetNotificationsCallback( + void (*Func)(void*, std::uint32_t, unsigned int), void* lpParam) = 0; + virtual bool RegionIsNorthAmerica() = 0; + virtual bool LocaleIsUSorCanada() = 0; + virtual int GetLiveConnectionStatus() = 0; + virtual bool IsSystemUIDisplayed() = 0; + virtual void SetProfileReadErrorCallback(void (*Func)(void*), + void* lpParam) = 0; + + // Profile data + virtual int SetDefaultOptionsCallback( + int (*Func)(void*, PROFILESETTINGS*, const int iPad), + void* lpParam) = 0; + virtual int SetOldProfileVersionCallback( + int (*Func)(void*, unsigned char*, const unsigned short, const int), + void* lpParam) = 0; + virtual PROFILESETTINGS* GetDashboardProfileSettings(int iPad) = 0; + virtual void WriteToProfile(int iQuadrant, + bool bGameDefinedDataChanged = false, + bool bOverrideTimeLimit = false) = 0; + virtual void ForceQueuedProfileWrites(int iPad = XUSER_INDEX_ANY) = 0; + virtual void* GetGameDefinedProfileData(int iQuadrant) = 0; + virtual void ResetProfileProcessState() = 0; + + // Trial + virtual void StartTrialGame() = 0; + virtual void SetTrialTextStringTable(CXuiStringTable* pStringTable, + int iAccept, int iReject) = 0; + virtual void SetTrialAwardText(eAwardType AwardType, int iTitle, + int iText) = 0; + + // Content + virtual void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, + bool* allAllowed, + bool* friendsAllowed) = 0; + virtual bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, + PlayerUID* pXuids, + unsigned int xuidCount) = 0; + virtual void ShowProfileCard(int iPad, PlayerUID targetUid) = 0; + virtual bool GetProfileAvatar( + int iPad, + int (*Func)(void* lpParam, std::uint8_t* thumbnailData, + unsigned int thumbnailBytes), + void* lpParam) = 0; + virtual void CancelProfileAvatarRequest() = 0; + + // Achievements + virtual void RegisterAward(int iAwardNumber, int iGamerconfigID, + eAwardType eType, + bool bLeaderboardAffected = false, + CXuiStringTable* pStringTable = nullptr, + int iTitleStr = -1, int iTextStr = -1, + int iAcceptStr = -1, + char* pszThemeName = nullptr, + unsigned int uiThemeSize = 0L) = 0; + virtual int GetAwardId(int iAwardNumber) = 0; + virtual eAwardType GetAwardType(int iAwardNumber) = 0; + virtual bool CanBeAwarded(int iQuadrant, int iAwardNumber) = 0; + virtual void Award(int iQuadrant, int iAwardNumber, + bool bForce = false) = 0; + virtual bool IsAwardsFlagSet(int iQuadrant, int iAward) = 0; + + // Rich presence + virtual void RichPresenceInit(int iPresenceCount, int iContextCount) = 0; + virtual void RegisterRichPresenceContext(int iGameConfigContextID) = 0; + virtual void SetRichPresenceContextValue(int iPad, int iContextID, + int iVal) = 0; + virtual void SetCurrentGameActivity(int iPad, int iNewPresence, + bool bSetOthersToIdle = false) = 0; + + // Purchase + virtual void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, + int iUpsellParam = -1) = 0; + virtual void SetUpsellCallback(void (*Func)(void* lpParam, eUpsellType type, + eUpsellResponse response, + int iUserData), + void* lpParam) = 0; + + // Debug + virtual void SetDebugFullOverride(bool bVal) = 0; +}; diff --git a/minecraft/platform/IPlatformRender.h b/minecraft/platform/IPlatformRender.h new file mode 100644 index 000000000..da7bd5810 --- /dev/null +++ b/minecraft/platform/IPlatformRender.h @@ -0,0 +1,234 @@ +#pragma once + +#include +#include + +class ImageFileBuffer { +public: + enum EImageType { e_typePNG, e_typeJPG }; + EImageType m_type; + void* m_pBuffer; + int m_bufferSize; + int GetType() { return m_type; } + void* GetBufferPointer() { return m_pBuffer; } + int GetBufferSize() { return m_bufferSize; } + void Release() { + std::free(m_pBuffer); + m_pBuffer = nullptr; + } + bool Allocated() { return m_pBuffer != nullptr; } +}; + +struct D3DXIMAGE_INFO { + int Width; + int Height; +}; + +struct XSOCIAL_PREVIEWIMAGE { + std::uint8_t* pBytes; + std::uint32_t Pitch; + std::uint32_t Width; + std::uint32_t Height; +}; +using PXSOCIAL_PREVIEWIMAGE = XSOCIAL_PREVIEWIMAGE*; + +class IPlatformRender { +public: + enum eVertexType { + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, + VERTEX_TYPE_COMPRESSED, + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, + VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, + VERTEX_TYPE_COUNT + }; + + enum ePixelShaderType { + PIXEL_SHADER_TYPE_STANDARD, + PIXEL_SHADER_TYPE_PROJECTION, + PIXEL_SHADER_TYPE_FORCELOD, + PIXEL_SHADER_COUNT + }; + + enum eViewportType { + VIEWPORT_TYPE_FULLSCREEN, + VIEWPORT_TYPE_SPLIT_TOP, + VIEWPORT_TYPE_SPLIT_BOTTOM, + VIEWPORT_TYPE_SPLIT_LEFT, + VIEWPORT_TYPE_SPLIT_RIGHT, + VIEWPORT_TYPE_QUADRANT_TOP_LEFT, + VIEWPORT_TYPE_QUADRANT_TOP_RIGHT, + VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT, + VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT, + }; + + enum ePrimitiveType { + PRIMITIVE_TYPE_TRIANGLE_LIST, + PRIMITIVE_TYPE_TRIANGLE_STRIP, + PRIMITIVE_TYPE_TRIANGLE_FAN, + PRIMITIVE_TYPE_QUAD_LIST, + PRIMITIVE_TYPE_LINE_LIST, + PRIMITIVE_TYPE_LINE_STRIP, + PRIMITIVE_TYPE_COUNT + }; + + enum eTextureFormat { + TEXTURE_FORMAT_RxGyBzAw, + MAX_TEXTURE_FORMATS + }; + + virtual ~IPlatformRender() = default; + + // Lifecycle + virtual void Initialise() = 0; + virtual void InitialiseContext() = 0; + virtual void Tick() = 0; + virtual void StartFrame() = 0; + virtual void Present() = 0; + virtual void Clear(int flags) = 0; + virtual void SetClearColour(const float colourRGBA[4]) = 0; + virtual void Shutdown() = 0; + virtual void Suspend() = 0; + virtual bool Suspended() = 0; + virtual void Resume() = 0; + + // Window + virtual void SetWindowSize(int w, int h) = 0; + virtual void SetFullscreen(bool fs) = 0; + virtual bool IsWidescreen() = 0; + virtual bool IsHiDef() = 0; + virtual void GetFramebufferSize(int& width, int& height) = 0; + virtual bool ShouldClose() = 0; + virtual void Close() = 0; + virtual void UpdateGamma(unsigned short usGamma) = 0; + + // Matrix stack + virtual void MatrixMode(int type) = 0; + virtual void MatrixSetIdentity() = 0; + virtual void MatrixTranslate(float x, float y, float z) = 0; + virtual void MatrixRotate(float angle, float x, float y, float z) = 0; + virtual void MatrixScale(float x, float y, float z) = 0; + virtual void MatrixPerspective(float fovy, float aspect, float zNear, + float zFar) = 0; + virtual void MatrixOrthogonal(float left, float right, float bottom, + float top, float zNear, float zFar) = 0; + virtual void MatrixPop() = 0; + virtual void MatrixPush() = 0; + virtual void MatrixMult(float* mat) = 0; + virtual const float* MatrixGet(int type) = 0; + virtual void Set_matrixDirty() = 0; + + // Draw calls + virtual void DrawVertices(ePrimitiveType PrimitiveType, int count, + void* dataIn, eVertexType vType, + ePixelShaderType psType) = 0; + + // Command buffers + virtual void CBuffLockStaticCreations() = 0; + virtual int CBuffCreate(int count) = 0; + virtual void CBuffDelete(int first, int count) = 0; + virtual void CBuffStart(int index, bool full = false) = 0; + virtual void CBuffClear(int index) = 0; + virtual int CBuffSize(int index) = 0; + virtual void CBuffEnd() = 0; + virtual bool CBuffCall(int index, bool full = true) = 0; + virtual void CBuffTick() = 0; + virtual void CBuffDeferredModeStart() = 0; + virtual void CBuffDeferredModeEnd() = 0; + + // Textures + virtual int TextureCreate() = 0; + virtual void TextureFree(int idx) = 0; + virtual void TextureBind(int idx) = 0; + virtual void TextureBindVertex(int idx, bool scaleLight = false) = 0; + virtual void TextureSetTextureLevels(int levels) = 0; + virtual int TextureGetTextureLevels() = 0; + virtual void TextureData(int width, int height, void* data, int level, + eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw) = 0; + virtual void TextureDataUpdate(int xoffset, int yoffset, int width, + int height, void* data, int level) = 0; + virtual void TextureSetParam(int param, int value) = 0; + virtual void TextureDynamicUpdateStart() = 0; + virtual void TextureDynamicUpdateEnd() = 0; + virtual int LoadTextureData(const char* szFilename, + D3DXIMAGE_INFO* pSrcInfo, + int** ppDataOut) = 0; + virtual int LoadTextureData(std::uint8_t* pbData, std::uint32_t byteCount, + D3DXIMAGE_INFO* pSrcInfo, + int** ppDataOut) = 0; + virtual int SaveTextureData(const char* szFilename, + D3DXIMAGE_INFO* pSrcInfo, + int* ppDataOut) = 0; + virtual int SaveTextureDataToMemory(void* pOutput, int outputCapacity, + int* outputLength, int width, + int height, int* ppDataIn) = 0; + virtual void ReadPixels(int x, int y, int w, int h, void* buf) = 0; + virtual void TextureGetStats() = 0; + virtual void* TextureGetTexture(int idx) = 0; + + // Render state + virtual void StateSetColour(float r, float g, float b, float a) = 0; + virtual void StateSetDepthMask(bool enable) = 0; + virtual void StateSetBlendEnable(bool enable) = 0; + virtual void StateSetBlendFunc(int src, int dst) = 0; + virtual void StateSetBlendFactor(unsigned int colour) = 0; + virtual void StateSetAlphaFunc(int func, float param) = 0; + virtual void StateSetDepthFunc(int func) = 0; + virtual void StateSetFaceCull(bool enable) = 0; + virtual void StateSetFaceCullCW(bool enable) = 0; + virtual void StateSetLineWidth(float width) = 0; + virtual void StateSetWriteEnable(bool red, bool green, bool blue, + bool alpha) = 0; + virtual void StateSetDepthTestEnable(bool enable) = 0; + virtual void StateSetAlphaTestEnable(bool enable) = 0; + virtual void StateSetDepthSlopeAndBias(float slope, float bias) = 0; + + // Fog + virtual void StateSetFogEnable(bool enable) = 0; + virtual void StateSetFogMode(int mode) = 0; + virtual void StateSetFogNearDistance(float dist) = 0; + virtual void StateSetFogFarDistance(float dist) = 0; + virtual void StateSetFogDensity(float density) = 0; + virtual void StateSetFogColour(float red, float green, float blue) = 0; + + // Lighting + virtual void StateSetLightingEnable(bool enable) = 0; + virtual void StateSetVertexTextureUV(float u, float v) = 0; + virtual void StateSetLightColour(int light, float red, float green, + float blue) = 0; + virtual void StateSetLightAmbientColour(float red, float green, + float blue) = 0; + virtual void StateSetLightDirection(int light, float x, float y, + float z) = 0; + virtual void StateSetLightEnable(int light, bool enable) = 0; + + // Viewport & clipping + virtual void StateSetViewport(eViewportType viewportType) = 0; + virtual void StateSetEnableViewportClipPlanes(bool enable) = 0; + virtual void StateSetTexGenCol(int col, float x, float y, float z, float w, + bool eyeSpace) = 0; + virtual void StateSetStencil(int Function, std::uint8_t stencil_ref, + std::uint8_t stencil_func_mask, + std::uint8_t stencil_write_mask) = 0; + virtual void StateSetForceLOD(int LOD) = 0; + virtual void StateSetTextureEnable(bool enable) = 0; + virtual void StateSetActiveTexture(int tex) = 0; + + // Chunks + virtual void SetChunkOffset(float x, float y, float z) = 0; + + // Occlusion + virtual void BeginConditionalSurvey(int identifier) = 0; + virtual void EndConditionalSurvey() = 0; + virtual void BeginConditionalRendering(int identifier) = 0; + virtual void EndConditionalRendering() = 0; + + // Screenshots + virtual void DoScreenGrabOnNextPresent() = 0; + virtual void CaptureThumbnail(ImageFileBuffer* pngOut) = 0; + virtual void CaptureScreen(ImageFileBuffer* jpgOut, + XSOCIAL_PREVIEWIMAGE* previewOut) = 0; + + // Events + virtual void BeginEvent(const wchar_t* eventName) = 0; + virtual void EndEvent() = 0; +}; diff --git a/minecraft/platform/IPlatformStorage.h b/minecraft/platform/IPlatformStorage.h new file mode 100644 index 000000000..53c518b29 --- /dev/null +++ b/minecraft/platform/IPlatformStorage.h @@ -0,0 +1,260 @@ +#pragma once + +#include +#include +#include +#include + +#include "../4J.Common/4J_Compat.h" + +struct SAVE_INFO; +using PSAVE_INFO = SAVE_INFO*; +struct SAVE_DETAILS; +using PSAVE_DETAILS = SAVE_DETAILS*; +class C4JStringTable; + +class IPlatformStorage { +public: + // Enums live here so both the interface consumer and the concrete + // implementation share the same values without a circular include. + enum EMessageResult { + EMessage_Undefined = 0, + EMessage_Busy, + EMessage_Pending, + EMessage_Cancelled, + EMessage_ResultAccept, + EMessage_ResultDecline, + EMessage_ResultThirdOption, + EMessage_ResultFourthOption + }; + + enum ESaveGameState { + ESaveGame_Idle = 0, + ESaveGame_Save, + ESaveGame_InternalRequestingDevice, + ESaveGame_InternalGetSaveName, + ESaveGame_InternalSaving, + ESaveGame_CopySave, + ESaveGame_CopyingSave, + ESaveGame_Load, + ESaveGame_GetSavesInfo, + ESaveGame_Rename, + ESaveGame_Delete, + ESaveGame_GetSaveThumbnail + }; + + enum ESaveGameControlState { + ESaveGameControl_Idle = 0, + ESaveGameControl_Save, + ESaveGameControl_InternalRequestingDevice, + ESaveGameControl_InternalGetSaveName, + ESaveGameControl_InternalSaving, + ESaveGameControl_CopySave, + ESaveGameControl_CopyingSave, + }; + + enum ESavingMessage { + ESavingMessage_None = 0, + ESavingMessage_Short, + ESavingMessage_Long + }; + + enum EDLCStatus { + EDLC_Error = 0, + EDLC_Idle, + EDLC_NoOffers, + EDLC_AlreadyEnumeratedAllOffers, + EDLC_NoInstalledDLC, + EDLC_Pending, + EDLC_LoadInProgress, + EDLC_Loaded, + EDLC_ChangedDevice + }; + + enum ETMSStatus { + ETMSStatus_Idle = 0, + ETMSStatus_Fail, + ETMSStatus_Fail_ReadInProgress, + ETMSStatus_Fail_WriteInProgress, + ETMSStatus_Pending, + }; + + enum eGlobalStorage { + eGlobalStorage_Title = 0, + eGlobalStorage_TitleUser, + eGlobalStorage_Max + }; + + enum eTMS_FileType { + eTMS_FileType_Normal = 0, + eTMS_FileType_Graphic, + }; + + enum eTMS_FILETYPEVAL { + TMS_FILETYPE_BINARY, + TMS_FILETYPE_CONFIG, + TMS_FILETYPE_JSON, + TMS_FILETYPE_MAX + }; + + struct TMSPP_FILEDATA { + unsigned int size; + std::uint8_t* pbData; + }; + using PTMSPP_FILEDATA = TMSPP_FILEDATA*; + + struct DLC_TMS_DETAILS { + std::uint32_t dwVersion; + std::uint32_t dwNewOffers; + std::uint32_t dwTotalOffers; + std::uint32_t dwInstalledTotalOffers; + std::uint8_t bPadding[1024 - sizeof(std::uint32_t) * 4]; + }; + + virtual ~IPlatformStorage() = default; + + // Lifecycle + virtual void Tick() = 0; + virtual void Init(unsigned int uiSaveVersion, + const wchar_t* pwchDefaultSaveName, + char* pszSavePackName, int iMinimumSaveSize, + int (*Func)(void*, const ESavingMessage, int), + void* lpParam, const char* szGroupID) = 0; + virtual void ResetSaveData() = 0; + + // Messages + virtual EMessageResult RequestMessageBox( + unsigned int uiTitle, unsigned int uiText, unsigned int* uiOptionA, + unsigned int uiOptionC, unsigned int pad = XUSER_INDEX_ANY, + int (*Func)(void*, int, const EMessageResult) = nullptr, + void* lpParam = nullptr, C4JStringTable* pStringTable = nullptr, + wchar_t* pwchFormatString = nullptr, + unsigned int focusButton = 0) = 0; + virtual EMessageResult GetMessageBoxResult() = 0; + + // Save device + virtual bool SetSaveDevice(int (*Func)(void*, const bool), void* lpParam, + bool bForceResetOfSaveDevice = false) = 0; + virtual void SetSaveDeviceSelected(unsigned int uiPad, + bool bSelected) = 0; + virtual bool GetSaveDeviceSelected(unsigned int iPad) = 0; + + // Save game + virtual void SetDefaultSaveNameForKeyboardDisplay( + const wchar_t* pwchDefaultSaveName) = 0; + virtual void SetSaveTitle(const wchar_t* pwchDefaultSaveName) = 0; + virtual bool GetSaveUniqueNumber(int* piVal) = 0; + virtual bool GetSaveUniqueFilename(char* pszName) = 0; + virtual void SetSaveUniqueFilename(char* szFilename) = 0; + virtual void SetState(ESaveGameControlState eControlState, + int (*Func)(void*, const bool), void* lpParam) = 0; + virtual void SetSaveDisabled(bool bDisable) = 0; + virtual bool GetSaveDisabled() = 0; + virtual unsigned int GetSaveSize() = 0; + virtual void GetSaveData(void* pvData, unsigned int* puiBytes) = 0; + virtual void* AllocateSaveData(unsigned int uiBytes) = 0; + virtual void SetSaveImages(std::uint8_t* pbThumbnail, + unsigned int thumbnailBytes, + std::uint8_t* pbImage, unsigned int imageBytes, + std::uint8_t* pbTextData, + unsigned int textDataBytes) = 0; + virtual ESaveGameState SaveSaveData(int (*Func)(void*, const bool), + void* lpParam) = 0; + virtual void CopySaveDataToNewSave(std::uint8_t* pbThumbnail, + unsigned int cbThumbnail, + wchar_t* wchNewName, + int (*Func)(void* lpParam, bool), + void* lpParam) = 0; + virtual ESaveGameState DoesSaveExist(bool* pbExists) = 0; + virtual bool EnoughSpaceForAMinSaveGame() = 0; + virtual void SetSaveMessageVPosition(float fY) = 0; + virtual ESaveGameState GetSavesInfo( + int iPad, + int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool), + void* lpParam, char* pszSavePackName) = 0; + virtual PSAVE_DETAILS ReturnSavesInfo() = 0; + virtual void ClearSavesInfo() = 0; + virtual ESaveGameState LoadSaveDataThumbnail( + PSAVE_INFO pSaveInfo, + int (*Func)(void* lpParam, std::uint8_t* thumbnailData, + unsigned int thumbnailBytes), + void* lpParam) = 0; + virtual void GetSaveCacheFileInfo(unsigned int fileIndex, + XCONTENT_DATA& xContentData) = 0; + virtual void GetSaveCacheFileInfo(unsigned int fileIndex, + std::uint8_t** ppbImageData, + unsigned int* pImageBytes) = 0; + virtual ESaveGameState LoadSaveData( + PSAVE_INFO pSaveInfo, + int (*Func)(void* lpParam, const bool, const bool), + void* lpParam) = 0; + virtual ESaveGameState DeleteSaveData( + PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool), + void* lpParam) = 0; + + // DLC + virtual void RegisterMarketplaceCountsCallback( + int (*Func)(void* lpParam, DLC_TMS_DETAILS*, int), + void* lpParam) = 0; + virtual void SetDLCPackageRoot(char* pszDLCRoot) = 0; + virtual EDLCStatus GetDLCOffers( + int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam, + std::uint32_t dwOfferTypesBitmask = + XMARKETPLACE_OFFERING_TYPE_CONTENT) = 0; + virtual unsigned int CancelGetDLCOffers() = 0; + virtual void ClearDLCOffers() = 0; + virtual XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(unsigned int dw) = 0; + virtual int GetOfferCount() = 0; + virtual unsigned int InstallOffer(int iOfferIDC, + std::uint64_t* ullOfferIDA, + int (*Func)(void*, int, int), + void* lpParam, bool bTrial = false) = 0; + virtual unsigned int GetAvailableDLCCount(int iPad) = 0; + virtual EDLCStatus GetInstalledDLC(int iPad, + int (*Func)(void*, int, int), + void* lpParam) = 0; + virtual XCONTENT_DATA& GetDLC(unsigned int dw) = 0; + virtual std::uint32_t MountInstalledDLC( + int iPad, std::uint32_t dwDLC, + int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam, + const char* szMountDrive = nullptr) = 0; + virtual unsigned int UnmountInstalledDLC( + const char* szMountDrive = nullptr) = 0; + virtual void GetMountedDLCFileList( + const char* szMountDrive, std::vector& fileList) = 0; + virtual std::string GetMountedPath(std::string szMount) = 0; + + // Title storage + virtual ETMSStatus ReadTMSFile( + int iQuadrant, eGlobalStorage eStorageFacility, + eTMS_FileType eFileType, wchar_t* pwchFilename, + std::uint8_t** ppBuffer, unsigned int* pBufferSize, + int (*Func)(void*, wchar_t*, int, bool, int) = nullptr, + void* lpParam = nullptr, int iAction = 0) = 0; + virtual bool WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, + wchar_t* pwchFilename, std::uint8_t* pBuffer, + unsigned int bufferSize) = 0; + virtual bool DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, + wchar_t* pwchFilename) = 0; + virtual void StoreTMSPathName(wchar_t* pwchName = nullptr) = 0; + virtual ETMSStatus TMSPP_ReadFile( + int iPad, eGlobalStorage eStorageFacility, + eTMS_FILETYPEVAL eFileTypeVal, const char* szFilename, + int (*Func)(void*, int, int, PTMSPP_FILEDATA, const char*) = nullptr, + void* lpParam = nullptr, int iUserData = 0) = 0; + + // Subfile management (save splitting) + virtual int AddSubfile(int regionIndex) = 0; + virtual unsigned int GetSubfileCount() = 0; + virtual void GetSubfileDetails(unsigned int i, int* regionIndex, + void** data, unsigned int* size) = 0; + virtual void ResetSubfiles() = 0; + virtual void UpdateSubfile(int index, void* data, unsigned int size) = 0; + virtual void SaveSubfiles(int (*Func)(void*, const bool), + void* param) = 0; + virtual ESaveGameState GetSaveState() = 0; + + // Misc + virtual unsigned int CRC(unsigned char* buf, int len) = 0; + virtual void ContinueIncompleteOperation() = 0; +}; diff --git a/minecraft/platform/Platform.h b/minecraft/platform/Platform.h new file mode 100644 index 000000000..2790f6514 --- /dev/null +++ b/minecraft/platform/Platform.h @@ -0,0 +1,6 @@ +#pragma once + +#include "IPlatformInput.h" +#include "IPlatformProfile.h" +#include "IPlatformRender.h" +#include "IPlatformStorage.h" diff --git a/minecraft/platform/meson.build b/minecraft/platform/meson.build new file mode 100644 index 000000000..8c736a9f5 --- /dev/null +++ b/minecraft/platform/meson.build @@ -0,0 +1,5 @@ +platform_inc = include_directories('.') + +platform_dep = declare_dependency( + include_directories: platform_inc, +)