diff --git a/.gitignore b/.gitignore index 2a5f4588f..6472c8443 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,24 @@ build/ .cache/ .idea/ -cmake-build-debug/cd \ No newline at end of file +cmake-build-debug/ + +# CMake generated +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +Makefile +compile_commands.json + +# IDE / editor +*.swp +*.swo +*~ +.vscode/ +*.code-workspace + +# Compiled objects / binaries +*.o +*.a +*.so +*.out diff --git a/4J.Input/4J_Input.cpp b/4J.Input/4J_Input.cpp new file mode 100644 index 000000000..b378b5c2e --- /dev/null +++ b/4J.Input/4J_Input.cpp @@ -0,0 +1,34 @@ +#include "4J_Input.h" + +C_4JInput InputManager; + +void C_4JInput::Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC) {} +void C_4JInput::Tick(void) {} +void C_4JInput::SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax) {} +void C_4JInput::SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, unsigned int uiActionVal) {} +unsigned int C_4JInput::GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction) { return 0; } +void C_4JInput::SetJoypadMapVal(int iPad, unsigned char ucMap) {} +unsigned char C_4JInput::GetJoypadMapVal(int iPad) { return 0; } +void C_4JInput::SetJoypadSensitivity(int iPad, float fSensitivity) {} +unsigned int C_4JInput::GetValue(int iPad, unsigned char ucAction, bool bRepeat) { return 0; } +bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction) { return false; } +bool C_4JInput::ButtonReleased(int iPad, unsigned char ucAction) { return false; } +bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) { return false; } +void C_4JInput::SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo) {} +void C_4JInput::SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo) {} +void C_4JInput::SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs) {} +void C_4JInput::SetDebugSequence(const char *chSequenceA, int(*Func)(LPVOID), LPVOID lpParam) {} +FLOAT C_4JInput::GetIdleSeconds(int iPad) { return 0.0f; } +bool C_4JInput::IsPadConnected(int iPad) { return iPad == 0; } +float C_4JInput::GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay) { return 0.0f; } +float C_4JInput::GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay) { return 0.0f; } +float C_4JInput::GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay) { return 0.0f; } +float C_4JInput::GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay) { return 0.0f; } +unsigned char C_4JInput::GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay) { return 0; } +unsigned char C_4JInput::GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay) { return 0; } +void C_4JInput::SetMenuDisplayed(int iPad, bool bVal) {} +EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int(*Func)(LPVOID, const bool), LPVOID lpParam, C_4JInput::EKeyboardMode eMode) { return EKeyboard_Cancelled; } +void C_4JInput::GetText(uint16_t *UTF16String) { if (UTF16String) UTF16String[0] = 0; } +bool C_4JInput::VerifyStrings(WCHAR **pwStringA, int iStringC, int(*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam) { return true; } +void C_4JInput::CancelQueuedVerifyStrings(int(*Func)(LPVOID, STRING_VERIFY_RESPONSE *), LPVOID lpParam) {} +void C_4JInput::CancelAllVerifyInProgress(void) {} diff --git a/4J.Input/4J_Input.h b/4J.Input/4J_Input.h new file mode 100644 index 000000000..9ac5c55d1 --- /dev/null +++ b/4J.Input/4J_Input.h @@ -0,0 +1,137 @@ +#pragma once + +#define MAP_STYLE_0 0 +#define MAP_STYLE_1 1 +#define MAP_STYLE_2 2 + +#define _360_JOY_BUTTON_A 0x00000001 +#define _360_JOY_BUTTON_B 0x00000002 +#define _360_JOY_BUTTON_X 0x00000004 +#define _360_JOY_BUTTON_Y 0x00000008 + +#define _360_JOY_BUTTON_START 0x00000010 +#define _360_JOY_BUTTON_BACK 0x00000020 +#define _360_JOY_BUTTON_RB 0x00000040 +#define _360_JOY_BUTTON_LB 0x00000080 + +#define _360_JOY_BUTTON_RTHUMB 0x00000100 +#define _360_JOY_BUTTON_LTHUMB 0x00000200 +#define _360_JOY_BUTTON_DPAD_UP 0x00000400 +#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800 + +#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000 +#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000 +// fake digital versions of analog values +#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000 +#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000 + +#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000 +#define _360_JOY_BUTTON_RSTICK_UP 0x00020000 +#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000 +#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000 + +#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000 +#define _360_JOY_BUTTON_LSTICK_UP 0x00200000 +#define _360_JOY_BUTTON_RT 0x00400000 +#define _360_JOY_BUTTON_LT 0x00800000 + +// Stick axis maps - to allow changes for SouthPaw in-game axis mapping +#define AXIS_MAP_LX 0 +#define AXIS_MAP_LY 1 +#define AXIS_MAP_RX 2 +#define AXIS_MAP_RY 3 + +// Trigger map - to allow for swap triggers in-game +#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 +{ + WORD wNumStrings; + HRESULT *pStringResult; +} +STRING_VERIFY_RESPONSE; + +class C_4JInput +{ +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 ); + void Tick(void); + void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax ); + void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal); + unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction); + void SetJoypadMapVal(int iPad,unsigned char ucMap); + unsigned char GetJoypadMapVal(int iPad); + void SetJoypadSensitivity(int iPad, float fSensitivity); + unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false); + bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled + bool ButtonReleased(int iPad,unsigned char ucAction); //toggled + bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down + // Functions to remap the axis and triggers for in-game (not menus) - SouthPaw, etc + void SetJoypadStickAxisMap(int iPad,unsigned int uiFrom, unsigned int uiTo); + void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo); + void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs); + void SetDebugSequence( const char *chSequenceA,int( *Func)(LPVOID),LPVOID lpParam ); + FLOAT GetIdleSeconds(int iPad); + bool IsPadConnected(int iPad); + + // In-Game values which may have been remapped due to Southpaw, swap triggers, etc + float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay=true); + float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay=true); + unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay=true); + unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay=true); + + void SetMenuDisplayed(int iPad, bool bVal); + +// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); +// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL); + EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); + void GetText(uint16_t *UTF16String); + + // Online check strings against offensive list - TCR 92 + // TCR # 092 CMTV Player Text String Verification + // Requirement Any player-entered text visible to another player on Xbox LIVE must be verified using the Xbox LIVE service before being transmitted. Text that is rejected by the Xbox LIVE service must not be displayed. + // + // Remarks + // This requirement applies to any player-entered string that can be exposed to other players on Xbox LIVE. It includes session names, content descriptions, text messages, tags, team names, mottos, comments, and so on. + // + // Games may decide to not send the text, blank it out, or use generic text if the text was rejected by the Xbox LIVE service. + // + // Games verify the text by calling the XStringVerify function. + // + // Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat. + // + // Intent Protect players from inappropriate language. + bool VerifyStrings(WCHAR **pwStringA,int iStringC,int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam); + void CancelQueuedVerifyStrings(int( *Func)(LPVOID,STRING_VERIFY_RESPONSE *),LPVOID lpParam); + void CancelAllVerifyInProgress(void); + + //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); +}; + +// Singleton +extern C_4JInput InputManager; diff --git a/4J.Input/CMakeLists.txt b/4J.Input/CMakeLists.txt new file mode 100644 index 000000000..b23afb284 --- /dev/null +++ b/4J.Input/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +project(4J_Input CXX) + +add_library(${PROJECT_NAME}) +target_sources(${PROJECT_NAME} + PRIVATE + 4J_Input.cpp + INP_ForceFeedback.cpp + INP_Keyboard.cpp + INP_Main.cpp + INP_StringCheck.cpp + stdafx.cpp + ../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h +) +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# Mimic cmake converter behaviour +target_precompile_headers(${PROJECT_NAME} PRIVATE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>" +) diff --git a/4J.Input/INP_ForceFeedback.cpp b/4J.Input/INP_ForceFeedback.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Input/INP_Keyboard.cpp b/4J.Input/INP_Keyboard.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Input/INP_Main.cpp b/4J.Input/INP_Main.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Input/INP_StringCheck.cpp b/4J.Input/INP_StringCheck.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Input/stdafx.cpp b/4J.Input/stdafx.cpp new file mode 100644 index 000000000..fd4f341c7 --- /dev/null +++ b/4J.Input/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/4J.Input/stdafx.h b/4J.Input/stdafx.h new file mode 100644 index 000000000..c5d7fda89 --- /dev/null +++ b/4J.Input/stdafx.h @@ -0,0 +1,8 @@ +#ifndef _4J_INPUT_STADAFX_H +#define _4J_INPUT_STADAFX_H + +#ifdef __linux__ +#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h" +#endif + +#endif //_4J_INPUT_STADAFX_H \ No newline at end of file diff --git a/4J.Profile/4J_Profile.cpp b/4J.Profile/4J_Profile.cpp new file mode 100644 index 000000000..3776dec6d --- /dev/null +++ b/4J.Profile/4J_Profile.cpp @@ -0,0 +1,86 @@ +#include "4J_Profile.h" +#include + +C_4JProfile ProfileManager; + +static void *s_profileData[4] = {}; + +void C_4JProfile::Initialise(DWORD dwTitleID, DWORD dwOfferID, unsigned short usProfileVersion, + UINT uiProfileValuesC, UINT uiProfileSettingsC, DWORD *pdwProfileSettingsA, + int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask) +{ + for (int i = 0; i < 4; i++) + { + s_profileData[i] = new unsigned char[iGameDefinedDataSizeX4 / 4]; + memset(s_profileData[i], 0, iGameDefinedDataSizeX4 / 4); + } +} +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 -1; } +void C_4JProfile::SetLockedProfile(int iProf) {} +bool C_4JProfile::IsSignedIn(int iQuadrant) { return iQuadrant == 0; } +bool C_4JProfile::IsSignedInLive(int iProf) { return false; } +bool C_4JProfile::IsGuest(int iQuadrant) { return false; } +UINT C_4JProfile::RequestSignInUI(bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, bool bMultiplayerSignIn, bool bAddUser, int(*Func)(LPVOID, const bool, const int iPad), LPVOID lpParam, int iQuadrant) { return 0; } +UINT C_4JProfile::DisplayOfflineProfile(int(*Func)(LPVOID, const bool, const int iPad), LPVOID lpParam, int iQuadrant) { return 0; } +UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(LPVOID, const bool, const int iPad), LPVOID 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) { if (pXuid) *pXuid = 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 *pbContentRestricted, int *piAge) { + if (pbChatRestricted) *pbChatRestricted = false; + if (pbContentRestricted) *pbContentRestricted = false; + 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, PPlayerUID pXuids, DWORD dwXuidCount) { return TRUE; } +void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {} +bool C_4JProfile::GetProfileAvatar(int iPad, int(*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam) { return false; } +void C_4JProfile::CancelProfileAvatarRequest() {} +int C_4JProfile::GetPrimaryPad() { return 0; } +void C_4JProfile::SetPrimaryPad(int iPad) {} + +static char s_gamertag[64] = "Player"; +char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; } +wstring C_4JProfile::GetDisplayName(int iPad) { return L"Player"; } +bool C_4JProfile::IsFullVersion() { return true; } +void C_4JProfile::SetSignInChangeCallback(void(*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {} +void C_4JProfile::SetNotificationsCallback(void(*Func)(LPVOID, DWORD, unsigned int), LPVOID lpParam) {} +bool C_4JProfile::RegionIsNorthAmerica(void) { return true; } +bool C_4JProfile::LocaleIsUSorCanada(void) { return true; } +HRESULT C_4JProfile::GetLiveConnectionStatus() { return S_OK; } +bool C_4JProfile::IsSystemUIDisplayed() { return false; } +void C_4JProfile::SetProfileReadErrorCallback(void(*Func)(LPVOID), LPVOID lpParam) {} +int C_4JProfile::SetDefaultOptionsCallback(int(*Func)(LPVOID, PROFILESETTINGS *, const int iPad), LPVOID lpParam) { return 0; } +int C_4JProfile::SetOldProfileVersionCallback(int(*Func)(LPVOID, unsigned char *, const unsigned short, const int), LPVOID lpParam) { return 0; } + +static C_4JProfile::PROFILESETTINGS s_defaultSettings = {}; +C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(int iPad) { return &s_defaultSettings; } +void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, bool bOverride5MinuteLimitOnProfileWrites) {} +void C_4JProfile::ForceQueuedProfileWrites(int iPad) {} +void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return s_profileData[iQuadrant]; } +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; } +bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; } +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)(LPVOID lpParam, eUpsellType type, eUpsellResponse response, int iUserData), LPVOID lpParam) {} +void C_4JProfile::SetDebugFullOverride(bool bVal) {} diff --git a/4J.Profile/4J_Profile.h b/4J.Profile/4J_Profile.h new file mode 100644 index 000000000..f1bd85bbe --- /dev/null +++ b/4J.Profile/4J_Profile.h @@ -0,0 +1,128 @@ +#pragma once + +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, +}; + + + +class C_4JProfile +{ +public: + struct PROFILESETTINGS + { + int iYAxisInversion; + int iControllerSensitivity; + int iVibration; + bool bSwapSticks; + }; + + + // 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( DWORD dwTitleID, + DWORD dwOfferID, + unsigned short usProfileVersion, + UINT uiProfileValuesC, + UINT uiProfileSettingsC, + DWORD *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); + UINT RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT DisplayOfflineProfile(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT RequestConvertOfflineToGuestUI(int( *Func)(LPVOID,const bool, const int iPad),LPVOID lpParam,int iQuadrant=XUSER_INDEX_ANY); + void SetPrimaryPlayerChanged(bool bVal); + bool QuerySigninStatus(void); + 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 + void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, BOOL *allAllowed, BOOL *friendsAllowed); + BOOL CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, DWORD dwXuidCount ); + void ShowProfileCard(int iPad, PlayerUID targetUid); + bool GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); + void CancelProfileAvatarRequest(); + + + // SYS + int GetPrimaryPad(); + void SetPrimaryPad(int iPad); + char* GetGamertag(int iPad); + wstring GetDisplayName(int iPad); + bool IsFullVersion(); + void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam); + void SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam); + bool RegionIsNorthAmerica(void); + bool LocaleIsUSorCanada(void); + HRESULT GetLiveConnectionStatus(); + bool IsSystemUIDisplayed(); + void SetProfileReadErrorCallback(void ( *Func)(LPVOID), LPVOID lpParam); + + + // PROFILE DATA + int SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam); + int SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned char *, const unsigned short,const int),LPVOID 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=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, 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)(LPVOID lpParam, eUpsellType type, eUpsellResponse response, int iUserData),LPVOID lpParam); + + // Debug + void SetDebugFullOverride(bool bVal); // To override the license version (trail/full). Only in debug/release, not ContentPackage + +}; + +// Singleton +extern C_4JProfile ProfileManager; + diff --git a/4J.Profile/CMakeLists.txt b/4J.Profile/CMakeLists.txt new file mode 100644 index 000000000..4f297166a --- /dev/null +++ b/4J.Profile/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +project(4J_Profile CXX) + +add_library(${PROJECT_NAME}) +target_sources(${PROJECT_NAME} + PRIVATE + 4J_Profile.cpp + PRO_AwardManager.cpp + PRO_Data.cpp + PRO_Main.cpp + PRO_RichPresence.cpp + PRO_Sys.cpp + stdafx.cpp +) +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# Mimic cmake converter behaviour +target_precompile_headers(${PROJECT_NAME} PRIVATE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>" +) diff --git a/4J.Profile/PRO_AwardManager.cpp b/4J.Profile/PRO_AwardManager.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Profile/PRO_Data.cpp b/4J.Profile/PRO_Data.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Profile/PRO_Main.cpp b/4J.Profile/PRO_Main.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Profile/PRO_RichPresence.cpp b/4J.Profile/PRO_RichPresence.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Profile/PRO_Sys.cpp b/4J.Profile/PRO_Sys.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Profile/stdafx.cpp b/4J.Profile/stdafx.cpp new file mode 100644 index 000000000..fd4f341c7 --- /dev/null +++ b/4J.Profile/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/4J.Profile/stdafx.h b/4J.Profile/stdafx.h new file mode 100644 index 000000000..ebe87b316 --- /dev/null +++ b/4J.Profile/stdafx.h @@ -0,0 +1,11 @@ +#ifndef _4J_PROFILE_STADAFX_H +#define _4J_PROFILE_STADAFX_H + + +#ifdef __linux__ +#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h" +#endif + +#include "../Minecraft.World/Build/x64headers/extraX64.h" + +#endif //_4J_PROFILE_STADAFX_H \ No newline at end of file diff --git a/4J.Render/4J_Render.cpp b/4J.Render/4J_Render.cpp new file mode 100644 index 000000000..74727f007 --- /dev/null +++ b/4J.Render/4J_Render.cpp @@ -0,0 +1,199 @@ +#include "4J_Render.h" +#include + +C4JRender RenderManager; + +static float s_identityMatrix[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1}; + +void C4JRender::Tick() {} +void C4JRender::UpdateGamma(unsigned short usGamma) {} +void C4JRender::MatrixMode(int type) {} +void C4JRender::MatrixSetIdentity() {} +void C4JRender::MatrixTranslate(float x, float y, float z) {} +void C4JRender::MatrixRotate(float angle, float x, float y, float z) {} +void C4JRender::MatrixScale(float x, float y, float z) {} +void C4JRender::MatrixPerspective(float fovy, float aspect, float zNear, float zFar) {} +void C4JRender::MatrixOrthogonal(float left, float right, float bottom, float top, float zNear, float zFar) {} +void C4JRender::MatrixPop() {} +void C4JRender::MatrixPush() {} +void C4JRender::MatrixMult(float *mat) {} +const float* C4JRender::MatrixGet(int type) { return s_identityMatrix; } +void C4JRender::Set_matrixDirty() {} +void C4JRender::Initialise() {} +void C4JRender::InitialiseContext() {} +void C4JRender::StartFrame() {} +void C4JRender::DoScreenGrabOnNextPresent() {} +void C4JRender::Present() {} +void C4JRender::Clear(int flags) {} +void C4JRender::SetClearColour(const float colourRGBA[4]) {} +bool C4JRender::IsWidescreen() { return true; } +bool C4JRender::IsHiDef() { return true; } +void C4JRender::CaptureThumbnail(ImageFileBuffer *pngOut) {} +void C4JRender::CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut) {} +void C4JRender::BeginConditionalSurvey(int identifier) {} +void C4JRender::EndConditionalSurvey() {} +void C4JRender::BeginConditionalRendering(int identifier) {} +void C4JRender::EndConditionalRendering() {} +void C4JRender::DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn, eVertexType vType, C4JRender::ePixelShaderType psType) {} +void C4JRender::CBuffLockStaticCreations() {} +int C4JRender::CBuffCreate(int count) { return 0; } +void C4JRender::CBuffDelete(int first, int count) {} +void C4JRender::CBuffStart(int index, bool full) {} +void C4JRender::CBuffClear(int index) {} +int C4JRender::CBuffSize(int index) { return 0; } +void C4JRender::CBuffEnd() {} +bool C4JRender::CBuffCall(int index, bool full) { return false; } +void C4JRender::CBuffTick() {} +void C4JRender::CBuffDeferredModeStart() {} +void C4JRender::CBuffDeferredModeEnd() {} +int C4JRender::TextureCreate() { return 0; } +void C4JRender::TextureFree(int idx) {} +void C4JRender::TextureBind(int idx) {} +void C4JRender::TextureBindVertex(int idx) {} +void C4JRender::TextureSetTextureLevels(int levels) {} +int C4JRender::TextureGetTextureLevels() { return 1; } +void C4JRender::TextureData(int width, int height, void *data, int level, eTextureFormat format) {} +void C4JRender::TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level) {} +void C4JRender::TextureSetParam(int param, int value) {} +void C4JRender::TextureDynamicUpdateStart() {} +void C4JRender::TextureDynamicUpdateEnd() {} +// really don't know if this is nessesary but didn't find any other functions to load images properly as a png.. +// im sorry. +#ifdef __linux__ +#include +#include +#include + +static HRESULT LoadPNGFromRows(png_structp png, png_infop info, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) +{ + int width = png_get_image_width(png, info); + int height = png_get_image_height(png, info); + png_byte color_type = png_get_color_type(png, info); + png_byte bit_depth = png_get_bit_depth(png, info); + + if (bit_depth == 16) png_set_strip_16(png); + if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png); + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png); + if (png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png); + if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE) + png_set_filler(png, 0xFF, PNG_FILLER_AFTER); + if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png); + + png_read_update_info(png, info); + + unsigned char *buf = new unsigned char[width * height * 4]; + png_bytep *rows = new png_bytep[height]; + for (int y = 0; y < height; y++) + rows[y] = buf + y * width * 4; + png_read_image(png, rows); + delete[] rows; + // considering i worked on previous projects with raw pngs,,,,, + int *pixels = new int[width * height]; + for (int i = 0; i < width * height; i++) + { + unsigned char r = buf[i * 4 + 0]; + unsigned char g = buf[i * 4 + 1]; + unsigned char b = buf[i * 4 + 2]; + unsigned char a = buf[i * 4 + 3]; + pixels[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + delete[] buf; + + pSrcInfo->Width = width; + pSrcInfo->Height = height; + *ppDataOut = pixels; + return S_OK; +} + +HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) +{ + FILE *fp = fopen(szFilename, "rb"); + if (!fp) return E_FAIL; + + png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png) { fclose(fp); return E_FAIL; } + png_infop info = png_create_info_struct(png); + if (!info) { png_destroy_read_struct(&png, NULL, NULL); fclose(fp); return E_FAIL; } + if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); fclose(fp); return E_FAIL; } + + png_init_io(png, fp); + png_read_info(png, info); + + HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut); + png_destroy_read_struct(&png, &info, NULL); + fclose(fp); + return hr; +} + +struct PNGMemReader { const unsigned char *data; png_size_t pos; png_size_t size; }; + +static void png_mem_read(png_structp png, png_bytep out, png_size_t len) +{ + PNGMemReader *r = (PNGMemReader *)png_get_io_ptr(png); + if (r->pos + len > r->size) len = r->size - r->pos; + memcpy(out, r->data + r->pos, len); + r->pos += len; +} + +HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) +{ + png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png) return E_FAIL; + png_infop info = png_create_info_struct(png); + if (!info) { png_destroy_read_struct(&png, NULL, NULL); return E_FAIL; } + if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); return E_FAIL; } + + PNGMemReader reader = { pbData, 0, dwBytes }; + png_set_read_fn(png, &reader, png_mem_read); + png_read_info(png, info); + + HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut); + png_destroy_read_struct(&png, &info, NULL); + return hr; +} + +#else +HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; } +HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; } +#endif +HRESULT C4JRender::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) { return S_OK; } +HRESULT C4JRender::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn) { return S_OK; } +void C4JRender::TextureGetStats() {} +void* C4JRender::TextureGetTexture(int idx) { return nullptr; } +void C4JRender::StateSetColour(float r, float g, float b, float a) {} +void C4JRender::StateSetDepthMask(bool enable) {} +void C4JRender::StateSetBlendEnable(bool enable) {} +void C4JRender::StateSetBlendFunc(int src, int dst) {} +void C4JRender::StateSetBlendFactor(unsigned int colour) {} +void C4JRender::StateSetAlphaFunc(int func, float param) {} +void C4JRender::StateSetDepthFunc(int func) {} +void C4JRender::StateSetFaceCull(bool enable) {} +void C4JRender::StateSetFaceCullCW(bool enable) {} +void C4JRender::StateSetLineWidth(float width) {} +void C4JRender::StateSetWriteEnable(bool red, bool green, bool blue, bool alpha) {} +void C4JRender::StateSetDepthTestEnable(bool enable) {} +void C4JRender::StateSetAlphaTestEnable(bool enable) {} +void C4JRender::StateSetDepthSlopeAndBias(float slope, float bias) {} +void C4JRender::StateSetFogEnable(bool enable) {} +void C4JRender::StateSetFogMode(int mode) {} +void C4JRender::StateSetFogNearDistance(float dist) {} +void C4JRender::StateSetFogFarDistance(float dist) {} +void C4JRender::StateSetFogDensity(float density) {} +void C4JRender::StateSetFogColour(float red, float green, float blue) {} +void C4JRender::StateSetLightingEnable(bool enable) {} +void C4JRender::StateSetVertexTextureUV(float u, float v) {} +void C4JRender::StateSetLightColour(int light, float red, float green, float blue) {} +void C4JRender::StateSetLightAmbientColour(float red, float green, float blue) {} +void C4JRender::StateSetLightDirection(int light, float x, float y, float z) {} +void C4JRender::StateSetLightEnable(int light, bool enable) {} +void C4JRender::StateSetViewport(eViewportType viewportType) {} +void C4JRender::StateSetEnableViewportClipPlanes(bool enable) {} +void C4JRender::StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace) {} +void C4JRender::StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask) {} +void C4JRender::StateSetForceLOD(int LOD) {} +void C4JRender::BeginEvent(LPCWSTR eventName) {} +void C4JRender::EndEvent() {} +void C4JRender::Suspend() {} +bool C4JRender::Suspended() { return false; } +void C4JRender::Resume() {} diff --git a/4J.Render/4J_Render.h b/4J.Render/4J_Render.h new file mode 100644 index 000000000..406702eba --- /dev/null +++ b/4J.Render/4J_Render.h @@ -0,0 +1,307 @@ +#pragma once + +#ifdef __linux__ +#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h" +#endif + +#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() { free(m_pBuffer); m_pBuffer = NULL; } + bool Allocated() { return m_pBuffer != NULL; } +}; + +typedef struct +{ + int Width; + int Height; +}D3DXIMAGE_INFO; + +typedef struct _XSOCIAL_PREVIEWIMAGE { + BYTE *pBytes; + DWORD Pitch; + DWORD Width; + DWORD Height; +// D3DFORMAT Format; +} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE; + +class C4JRender +{ +public: + void Tick(); + void UpdateGamma(unsigned short usGamma); + + // Matrix stack + void MatrixMode(int type); + void MatrixSetIdentity(); + void MatrixTranslate(float x,float y,float z); + void MatrixRotate(float angle, float x, float y, float z); + void MatrixScale(float x, float y, float z); + void MatrixPerspective(float fovy, float aspect, float zNear, float zFar); + void MatrixOrthogonal(float left,float right,float bottom,float top,float zNear,float zFar); + void MatrixPop(); + void MatrixPush(); + void MatrixMult(float *mat); + const float *MatrixGet(int type); + void Set_matrixDirty(); + + // Core + void Initialise(); + void InitialiseContext(); + void StartFrame(); + void DoScreenGrabOnNextPresent(); + void Present(); + void Clear(int flags); + void SetClearColour(const float colourRGBA[4]); + bool IsWidescreen(); + bool IsHiDef(); + void CaptureThumbnail(ImageFileBuffer *pngOut); + void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut); + void BeginConditionalSurvey(int identifier); + void EndConditionalSurvey(); + 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 DWORD + 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); + + // Command buffers + void CBuffLockStaticCreations(); + int CBuffCreate(int count); + void CBuffDelete(int first, int count); + void CBuffStart(int index, bool full = false); + void CBuffClear(int index); + int CBuffSize(int index); + void CBuffEnd(); + bool CBuffCall(int index, bool full = true); + void CBuffTick(); + 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); + void TextureBind(int idx); + void TextureBindVertex(int idx); + void TextureSetTextureLevels(int levels); + int TextureGetTextureLevels(); + void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw); + void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level); + void TextureSetParam(int param, int value); + void TextureDynamicUpdateStart(); + void TextureDynamicUpdateEnd(); + HRESULT LoadTextureData(const char *szFilename,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut); + HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut); + HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut); + HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn); + void TextureGetStats(); + void *TextureGetTexture(int idx); + + // State control + void StateSetColour(float r, float g, float b, float a); + void StateSetDepthMask(bool enable); + void StateSetBlendEnable(bool enable); + void StateSetBlendFunc(int src, int dst); + void StateSetBlendFactor(unsigned int colour); + void StateSetAlphaFunc(int func, float param); + void StateSetDepthFunc(int func); + void StateSetFaceCull(bool enable); + void StateSetFaceCullCW(bool enable); + void StateSetLineWidth(float width); + void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha); + void StateSetDepthTestEnable(bool enable); + void StateSetAlphaTestEnable(bool enable); + void StateSetDepthSlopeAndBias(float slope, float bias); + void StateSetFogEnable(bool enable); + void StateSetFogMode(int mode); + void StateSetFogNearDistance(float dist); + void StateSetFogFarDistance(float dist); + void StateSetFogDensity(float density); + void StateSetFogColour(float red, float green, float blue); + void StateSetLightingEnable(bool enable); + void StateSetVertexTextureUV( float u, float v); + void StateSetLightColour(int light, float red, float green, float blue); + void StateSetLightAmbientColour(float red, float green, float blue); + void StateSetLightDirection(int light, float x, float y, float z); + void StateSetLightEnable(int light, bool enable); + void StateSetViewport(eViewportType viewportType); + void StateSetEnableViewportClipPlanes(bool enable); + void StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace); + void StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask); + void StateSetForceLOD(int LOD); + + // Event tracking + void BeginEvent(LPCWSTR eventName); + void EndEvent(); + + // PLM event handling + void Suspend(); + bool Suspended(); + void Resume(); +}; + + +const int GL_MODELVIEW_MATRIX = 0; +const int GL_PROJECTION_MATRIX = 1; +const int GL_MODELVIEW = 0; +const int GL_PROJECTION = 1; +const int GL_TEXTURE = 2; + +// These things required for tex gen + +const int GL_S = 0; +const int GL_T = 1; +const int GL_R = 2; +const int GL_Q = 3; + +const int GL_TEXTURE_GEN_S = 0; +const int GL_TEXTURE_GEN_T = 1; +const int GL_TEXTURE_GEN_Q = 2; +const int GL_TEXTURE_GEN_R = 3; + +const int GL_TEXTURE_GEN_MODE = 0; +const int GL_OBJECT_LINEAR = 0; +const int GL_EYE_LINEAR = 1; +const int GL_OBJECT_PLANE = 0; +const int GL_EYE_PLANE = 1; + + +// These things are used by glEnable/glDisable so must be different and non-zero (zero is used by things we haven't assigned yet) +const int GL_TEXTURE_2D = 1; +const int GL_BLEND = 2; +const int GL_CULL_FACE = 3; +const int GL_ALPHA_TEST = 4; +const int GL_DEPTH_TEST = 5; +const int GL_FOG = 6; +const int GL_LIGHTING = 7; +const int GL_LIGHT0 = 8; +const int GL_LIGHT1 = 9; + +const int CLEAR_DEPTH_FLAG = 1; +const int CLEAR_COLOUR_FLAG = 2; + +const int GL_DEPTH_BUFFER_BIT = CLEAR_DEPTH_FLAG; +const int GL_COLOR_BUFFER_BIT = CLEAR_COLOUR_FLAG; + +const int GL_SRC_ALPHA = D3D11_BLEND_SRC_ALPHA; +const int GL_ONE_MINUS_SRC_ALPHA = D3D11_BLEND_INV_SRC_ALPHA; +const int GL_ONE = D3D11_BLEND_ONE; +const int GL_ZERO = D3D11_BLEND_ZERO; +const int GL_DST_ALPHA = D3D11_BLEND_DEST_ALPHA; +const int GL_SRC_COLOR = D3D11_BLEND_SRC_COLOR; +const int GL_DST_COLOR = D3D11_BLEND_DEST_COLOR; +const int GL_ONE_MINUS_DST_COLOR = D3D11_BLEND_INV_DEST_COLOR; +const int GL_ONE_MINUS_SRC_COLOR = D3D11_BLEND_INV_SRC_COLOR; +const int GL_CONSTANT_ALPHA = D3D11_BLEND_BLEND_FACTOR; +const int GL_ONE_MINUS_CONSTANT_ALPHA = D3D11_BLEND_INV_BLEND_FACTOR; + +const int GL_GREATER = D3D11_COMPARISON_GREATER; +const int GL_EQUAL = D3D11_COMPARISON_EQUAL; +const int GL_LEQUAL = D3D11_COMPARISON_LESS_EQUAL; +const int GL_GEQUAL = D3D11_COMPARISON_GREATER_EQUAL; +const int GL_ALWAYS = D3D11_COMPARISON_ALWAYS; + +const int GL_TEXTURE_MIN_FILTER = 1; +const int GL_TEXTURE_MAG_FILTER = 2; +const int GL_TEXTURE_WRAP_S = 3; +const int GL_TEXTURE_WRAP_T = 4; + +const int GL_NEAREST = 0; +const int GL_LINEAR = 1; +const int GL_EXP = 2; +const int GL_NEAREST_MIPMAP_LINEAR = 0; // TODO - mipmapping bit of this + +const int GL_CLAMP = 0; +const int GL_REPEAT = 1; + +const int GL_FOG_START = 1; +const int GL_FOG_END = 2; +const int GL_FOG_MODE = 3; +const int GL_FOG_DENSITY = 4; +const int GL_FOG_COLOR = 5; + +const int GL_POSITION = 1; +const int GL_AMBIENT = 2; +const int GL_DIFFUSE = 3; +const int GL_SPECULAR = 4; + +const int GL_LIGHT_MODEL_AMBIENT = 1; + +const int GL_LINES = C4JRender::PRIMITIVE_TYPE_LINE_LIST; +const int GL_LINE_STRIP = C4JRender::PRIMITIVE_TYPE_LINE_STRIP; +const int GL_QUADS = C4JRender::PRIMITIVE_TYPE_QUAD_LIST; +const int GL_TRIANGLE_FAN = C4JRender::PRIMITIVE_TYPE_TRIANGLE_FAN; +const int GL_TRIANGLE_STRIP = C4JRender::PRIMITIVE_TYPE_TRIANGLE_STRIP; + +// Singleton +extern C4JRender RenderManager; + + diff --git a/4J.Render/CMakeLists.txt b/4J.Render/CMakeLists.txt new file mode 100644 index 000000000..4aae8d1b6 --- /dev/null +++ b/4J.Render/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +project(4J_Render CXX) + +add_library(${PROJECT_NAME}) +target_sources(${PROJECT_NAME} + PRIVATE + 4J_Render.cpp + RendererCbuff.cpp + RendererCore.cpp + RendererMatrix.cpp + RendererState.cpp + RendererTexture.cpp + RendererVertex.cpp + stdafx.cpp +) +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) +# giving a boost on the next macos implmentation + +if(UNIX AND NOT APPLE) + find_package(PNG REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE PNG::PNG) +endif() + +# Mimic cmake converter behaviour +target_precompile_headers(${PROJECT_NAME} PRIVATE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>" +) diff --git a/4J.Render/RendererCbuff.cpp b/4J.Render/RendererCbuff.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/RendererCore.cpp b/4J.Render/RendererCore.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/RendererMatrix.cpp b/4J.Render/RendererMatrix.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/RendererState.cpp b/4J.Render/RendererState.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/RendererTexture.cpp b/4J.Render/RendererTexture.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/RendererVertex.cpp b/4J.Render/RendererVertex.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Render/stdafx.cpp b/4J.Render/stdafx.cpp new file mode 100644 index 000000000..fd4f341c7 --- /dev/null +++ b/4J.Render/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/4J.Render/stdafx.h b/4J.Render/stdafx.h new file mode 100644 index 000000000..0aa0f4359 --- /dev/null +++ b/4J.Render/stdafx.h @@ -0,0 +1,8 @@ +#ifndef _4J_RENDER_STADAFX_H +#define _4J_RENDER_STADAFX_H + +#ifdef __linux__ +#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h" +#endif + +#endif //_4J_RENDER_STADAFX_H \ No newline at end of file diff --git a/4J.Storage/4J_Storage.cpp b/4J.Storage/4J_Storage.cpp new file mode 100644 index 000000000..afdfd22af --- /dev/null +++ b/4J.Storage/4J_Storage.cpp @@ -0,0 +1,92 @@ +#include "4J_Storage.h" +#include +#include +#include + +C4JStorage StorageManager; + +static XMARKETPLACE_CONTENTOFFER_INFO s_dummyOffer = {}; +static XCONTENT_DATA s_dummyContentData = {}; + +C4JStorage::C4JStorage() : m_pStringTable(nullptr) {} + +void C4JStorage::Tick(void) {} + +C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA, UINT uiOptionC, DWORD dwPad, + int(*Func)(LPVOID, int, const C4JStorage::EMessageResult), LPVOID lpParam, C4JStringTable *pStringTable, WCHAR *pwchFormatString, DWORD dwFocusButton) { + return EMessage_ResultAccept; +} + +C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() { return EMessage_Undefined; } + +bool C4JStorage::SetSaveDevice(int(*Func)(LPVOID, const bool), LPVOID lpParam, bool bForceResetOfSaveDevice) { return true; } + +void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize, int(*Func)(LPVOID, const ESavingMessage, int), LPVOID lpParam, LPCSTR szGroupID) {} +void C4JStorage::ResetSaveData() {} +void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName) {} +void C4JStorage::SetSaveTitle(LPCWSTR pwchDefaultSaveName) {} +bool C4JStorage::GetSaveUniqueNumber(INT *piVal) { if (piVal) *piVal = 0; return true; } +bool C4JStorage::GetSaveUniqueFilename(char *pszName) { if (pszName) pszName[0] = '\0'; return true; } +void C4JStorage::SetSaveUniqueFilename(char *szFilename) {} +void C4JStorage::SetState(ESaveGameControlState eControlState, int(*Func)(LPVOID, const bool), LPVOID lpParam) {} +void C4JStorage::SetSaveDisabled(bool bDisable) {} +bool C4JStorage::GetSaveDisabled(void) { return false; } +unsigned int C4JStorage::GetSaveSize() { return 0; } +void C4JStorage::GetSaveData(void *pvData, unsigned int *puiBytes) { if (puiBytes) *puiBytes = 0; } +PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) { return malloc(uiBytes); } +void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) {} +C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int(*Func)(LPVOID, const bool), LPVOID lpParam) { return ESaveGame_Idle; } +void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int(*Func)(LPVOID lpParam, bool), LPVOID lpParam) {} +void C4JStorage::SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) {} +bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad) { return true; } +C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool *pbExists) { if (pbExists) *pbExists = false; return ESaveGame_Idle; } +bool C4JStorage::EnoughSpaceForAMinSaveGame() { return true; } +void C4JStorage::SetSaveMessageVPosition(float fY) {} +C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int(*Func)(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, const bool), LPVOID lpParam, char *pszSavePackName) { return ESaveGame_Idle; } +PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return nullptr; } +void C4JStorage::ClearSavesInfo() {} +C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, PBYTE pbThumbnail, DWORD dwThumbnailBytes), LPVOID lpParam) { return ESaveGame_Idle; } +void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA &xContentData) { memset(&xContentData, 0, sizeof(xContentData)); } +void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes) { if (ppbImageData) *ppbImageData = nullptr; if (pdwImageBytes) *pdwImageBytes = 0; } +C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool, const bool), LPVOID lpParam) { return ESaveGame_Idle; } +C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(LPVOID lpParam, const bool), LPVOID lpParam) { return ESaveGame_Idle; } +void C4JStorage::RegisterMarketplaceCountsCallback(int(*Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam) {} +void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot) {} +C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int(*Func)(LPVOID, int, DWORD, int), LPVOID lpParam, DWORD dwOfferTypesBitmask) { return EDLC_NoOffers; } +DWORD C4JStorage::CancelGetDLCOffers() { return 0; } +void C4JStorage::ClearDLCOffers() {} +XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw) { return s_dummyOffer; } +int C4JStorage::GetOfferCount() { return 0; } +DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int(*Func)(LPVOID, int, int), LPVOID lpParam, bool bTrial) { return 0; } +DWORD C4JStorage::GetAvailableDLCCount(int iPad) { return 0; } +C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int(*Func)(LPVOID, int, int), LPVOID lpParam) { return EDLC_NoInstalledDLC; } +XCONTENT_DATA& C4JStorage::GetDLC(DWORD dw) { return s_dummyContentData; } +DWORD C4JStorage::MountInstalledDLC(int iPad, DWORD dwDLC, int(*Func)(LPVOID, int, DWORD, DWORD), LPVOID lpParam, LPCSTR szMountDrive) { return 0; } +DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) { return 0; } +void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector &fileList) { fileList.clear(); } +std::string C4JStorage::GetMountedPath(std::string szMount) { return ""; } +C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType, + WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize, int(*Func)(LPVOID, WCHAR *, int, bool, int), LPVOID lpParam, int iAction) { return ETMSStatus_Fail; } +bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename, BYTE *pBuffer, DWORD dwBufferSize) { return false; } +bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename) { return false; } +void C4JStorage::StoreTMSPathName(WCHAR *pwchName) {} +C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(LPVOID, int, int, PTMSPP_FILEDATA, LPCSTR), LPVOID lpParam, int iUserData) { return ETMSStatus_Fail; } +unsigned int C4JStorage::CRC(unsigned char *buf, int len) { + unsigned int crc = 0xFFFFFFFF; + for (int i = 0; i < len; i++) { + crc ^= buf[i]; + for (int j = 0; j < 8; j++) { + crc = (crc >> 1) ^ (0xEDB88320 & (-(crc & 1))); + } + } + return ~crc; +} + +int C4JStorage::AddSubfile(int regionIndex) { (void)regionIndex; return 0; } +unsigned int C4JStorage::GetSubfileCount() { return 0; } +void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size) { (void)i; if(regionIndex) *regionIndex=0; if(data) *data=0; if(size) *size=0; } +void C4JStorage::ResetSubfiles() {} +void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) { (void)index; (void)data; (void)size; } +void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) { if(Func) Func(param, true); } +C4JStorage::ESaveGameState C4JStorage::GetSaveState() { return ESaveGame_Idle; } +void C4JStorage::ContinueIncompleteOperation() {} diff --git a/4J.Storage/4J_Storage.h b/4J.Storage/4J_Storage.h new file mode 100644 index 000000000..7fa3f0745 --- /dev/null +++ b/4J.Storage/4J_Storage.h @@ -0,0 +1,353 @@ +#pragma once + + +#include +//#include + +class C4JStringTable; + +#define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3 +#define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3 +#define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE + +typedef struct +{ + time_t modifiedTime; + unsigned int dataSize; + unsigned int thumbnailSize; +} +CONTAINER_METADATA; + +typedef struct +{ + char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH]; + char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH]; + CONTAINER_METADATA metaData; + PBYTE thumbnailData; +} +SAVE_INFO,*PSAVE_INFO; + +typedef struct +{ + int iSaveC; + PSAVE_INFO SaveInfoA; +} +SAVE_DETAILS,*PSAVE_DETAILS; + +typedef std::vector OfferDataArray; +typedef std::vector XContentDataArray; +//typedef std::vector SaveDetailsArray; + +// Current version of the dlc data creator +#define CURRENT_DLC_VERSION_NUM 3 + +class C4JStorage +{ + +public: + // Structs defined in the DLC_Creator, but added here to be used in the app + typedef struct + { + unsigned int uiFileSize; + DWORD dwType; + DWORD dwWchCount; // count of WCHAR in next array + WCHAR wchFile[1]; + } + DLC_FILE_DETAILS, *PDLC_FILE_DETAILS; + + typedef struct + { + DWORD dwType; + DWORD dwWchCount; // count of WCHAR in next array; + WCHAR wchData[1]; // will be an array of size dwBytes + } + DLC_FILE_PARAM, *PDLC_FILE_PARAM; + // End of DLC_Creator structs + + typedef struct + { + WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH]; + CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH]; + DWORD dwImageOffset; + DWORD dwImageBytes; + } + CACHEINFOSTRUCT; + + // structure to hold DLC info in TMS + typedef struct + { + DWORD dwVersion; + DWORD dwNewOffers; + DWORD dwTotalOffers; + DWORD dwInstalledTotalOffers; + BYTE bPadding[1024-sizeof(DWORD)*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, + ELoadGame_NoSaves, + ELoadGame_ChangedDevice, + ELoadGame_DeviceRemoved + }; + + enum EDeleteGameStatus + { + EDeleteGame_Idle=0, + EDeleteGame_InProgress, + }; + + + enum ESGIStatus + { + ESGIStatus_Error=0, + ESGIStatus_Idle, + ESGIStatus_ReadInProgress, + 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 + { + CHAR szFilename[256]; + int iFileSize; + eTMS_FILETYPEVAL eFileTypeVal; + } + TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS; + + typedef struct + { + int iCount; + PTMSPP_FILE_DETAILS FileDetailsA; + } + TMSPP_FILE_LIST, *PTMSPP_FILE_LIST; + + typedef struct + { + DWORD dwSize; + PBYTE pbData; + } + TMSPP_FILEDATA, *PTMSPP_FILEDATA; + + + C4JStorage(); + + void Tick(void); + + // Messages + C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY, + int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)=NULL,LPVOID lpParam=NULL, C4JStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0); + + + C4JStorage::EMessageResult GetMessageBoxResult(); + + // save device + bool SetSaveDevice(int( *Func)(LPVOID,const bool),LPVOID lpParam, bool bForceResetOfSaveDevice=false); + + // savegame + void Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize,int( *Func)(LPVOID, const ESavingMessage, int),LPVOID lpParam,LPCSTR szGroupID); + void ResetSaveData(); // Call before a new save to clear out stored save file name + void SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName); + void SetSaveTitle(LPCWSTR pwchDefaultSaveName); + bool GetSaveUniqueNumber(INT *piVal); + bool GetSaveUniqueFilename(char *pszName); + void SetSaveUniqueFilename(char *szFilename); + void SetState(ESaveGameControlState eControlState,int( *Func)(LPVOID,const bool),LPVOID lpParam); + void SetSaveDisabled(bool bDisable); + bool GetSaveDisabled(void); + unsigned int GetSaveSize(); + void GetSaveData(void *pvData,unsigned int *puiBytes); + PVOID AllocateSaveData(unsigned int uiBytes); + void SetSaveImages( PBYTE pbThumbnail,DWORD dwThumbnailBytes,PBYTE pbImage,DWORD dwImageBytes, PBYTE pbTextData ,DWORD dwTextDataBytes); // Sets the thumbnail & image for the save, optionally setting the metadata in the png + C4JStorage::ESaveGameState SaveSaveData(int( *Func)(LPVOID ,const bool),LPVOID lpParam); + void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(LPVOID lpParam, bool), LPVOID lpParam); + void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected); + bool GetSaveDeviceSelected(unsigned int iPad); + C4JStorage::ESaveGameState DoesSaveExist(bool *pbExists); + bool EnoughSpaceForAMinSaveGame(); + + void SetSaveMessageVPosition(float fY); // The 'Saving' message will display at a default position unless changed + // Get the info for the saves + C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(LPVOID lpParam,SAVE_DETAILS *pSaveDetails,const bool),LPVOID lpParam,char *pszSavePackName); + PSAVE_DETAILS ReturnSavesInfo(); + void ClearSavesInfo(); // Clears results + C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo + + void GetSaveCacheFileInfo(DWORD dwFile,XCONTENT_DATA &xContentData); + void GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes); + + // Load the save. Need to call GetSaveData once the callback is called + C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool, const bool), LPVOID lpParam); + C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(LPVOID lpParam,const bool), LPVOID lpParam); + + // DLC + void RegisterMarketplaceCountsCallback(int ( *Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam ); + void SetDLCPackageRoot(char *pszDLCRoot); + C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(LPVOID, int, DWORD, int),LPVOID lpParam, DWORD dwOfferTypesBitmask=XMARKETPLACE_OFFERING_TYPE_CONTENT); + DWORD CancelGetDLCOffers(); + void ClearDLCOffers(); + XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(DWORD dw); + int GetOfferCount(); + DWORD InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA,int( *Func)(LPVOID, int, int),LPVOID lpParam, bool bTrial=false); + DWORD GetAvailableDLCCount( int iPad); + + C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); + XCONTENT_DATA& GetDLC(DWORD dw); + DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=NULL); + DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL); + void GetMountedDLCFileList(const char* szMountDrive, std::vector& fileList); + std::string GetMountedPath(std::string szMount); + + // Global title storage + C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType, + WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(LPVOID, WCHAR *,int, bool, int)=NULL,LPVOID lpParam=NULL, int iAction=0); + bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize); + bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename); + void StoreTMSPathName(WCHAR *pwchName=NULL); + + // TMS++ +#ifdef _XBOX + C4JStorage::ETMSStatus WriteTMSFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,TMSCLIENT_CALLBACK Func,LPVOID lpParam); + HRESULT GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam); +#endif + + // C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0); + C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(LPVOID,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,LPVOID lpParam=NULL, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0); + // C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0); + // bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const wstring &Filename); + // unsigned int CRC(unsigned char *buf, int len); + +// enum eXBLWS +// { +// eXBLWS_GET, +// eXBLWS_POST, +// eXBLWS_PUT, +// eXBLWS_DELETE, +// }; + //bool XBLWS_Command(eXBLWS eCommand); + + + unsigned int CRC(unsigned char *buf, int len); + + int AddSubfile(int regionIndex); + unsigned int GetSubfileCount(); + void GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size); + void ResetSubfiles(); + void UpdateSubfile(int index, void* data, unsigned int size); + void SaveSubfiles(int (*Func)(void*, const bool), void* param); + ESaveGameState GetSaveState(); + + void ContinueIncompleteOperation(); + + C4JStringTable *m_pStringTable; +}; + +extern C4JStorage StorageManager; diff --git a/4J.Storage/CMakeLists.txt b/4J.Storage/CMakeLists.txt new file mode 100644 index 000000000..0c10107e5 --- /dev/null +++ b/4J.Storage/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +project(4J_Storage CXX) + +add_library(${PROJECT_NAME}) +target_sources(${PROJECT_NAME} + PRIVATE + 4J_Storage.cpp + STO_DLC.cpp + STO_Main.cpp + STO_SaveGame.cpp + stdafx.cpp +) +target_include_directories(${PROJECT_NAME} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# Mimic cmake converter behaviour +target_precompile_headers(${PROJECT_NAME} PRIVATE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>" +) diff --git a/4J.Storage/STO_DLC.cpp b/4J.Storage/STO_DLC.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Storage/STO_Main.cpp b/4J.Storage/STO_Main.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Storage/STO_SaveGame.cpp b/4J.Storage/STO_SaveGame.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/4J.Storage/stdafx.cpp b/4J.Storage/stdafx.cpp new file mode 100644 index 000000000..fd4f341c7 --- /dev/null +++ b/4J.Storage/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" diff --git a/4J.Storage/stdafx.h b/4J.Storage/stdafx.h new file mode 100644 index 000000000..e3bb783d6 --- /dev/null +++ b/4J.Storage/stdafx.h @@ -0,0 +1,10 @@ +#ifndef _4J_STORAGE_STADAFX_H +#define _4J_STORAGE_STADAFX_H + +#ifdef __linux__ +#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h" +#endif + +#include "../Minecraft.World/Build/x64headers/extraX64.h" + +#endif //_4J_STORAGE_STADAFX_H \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e8bb5a04..21313c606 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) ################################################################################ # Sub-projects ################################################################################ +add_subdirectory(4J.Input) +add_subdirectory(4J.Profile) +add_subdirectory(4J.Render) +add_subdirectory(4J.Storage) add_subdirectory(Minecraft.Client/Build Minecraft.Client) add_subdirectory(Minecraft.World/Build Minecraft.World) diff --git a/Minecraft.Client/Build/CMakeLists.txt b/Minecraft.Client/Build/CMakeLists.txt index 8b1d9646c..f1824aeac 100644 --- a/Minecraft.Client/Build/CMakeLists.txt +++ b/Minecraft.Client/Build/CMakeLists.txt @@ -34,7 +34,7 @@ source_group("Common\\Source Files" FILES ${Common__Source_Files}) set(Common__Source_Files__Audio "Common/Audio/Consoles_SoundEngine.cpp" "Common/Audio/Consoles_SoundEngine.h" -# "Common/Audio/SoundEngine.cpp" + "Common/Audio/SoundEngine.cpp" "Common/Audio/SoundEngine.h" "Common/Audio/SoundNames.cpp" ) @@ -175,8 +175,8 @@ set(Common__Source_Files__Network "Common/Network/GameNetworkManager.h" "Common/Network/NetworkPlayerInterface.h" "Common/Network/PlatformNetworkManagerInterface.h" -# "Common/Network/PlatformNetworkManagerStub.cpp" -# "Common/Network/PlatformNetworkManagerStub.h" + "Common/Network/PlatformNetworkManagerStub.cpp" + "Common/Network/PlatformNetworkManagerStub.h" "Common/Network/SessionInfo.h" "../Network Implementation Notes.txt" ) @@ -418,8 +418,8 @@ set(Common__Source_Files__UI__Controls "Common/UI/UIControl_TextInput.h" "Common/UI/UIControl_TexturePackList.cpp" "Common/UI/UIControl_TexturePackList.h" -# "Common/UI/UIControl_Touch.cpp" -# "Common/UI/UIControl_Touch.h" + "Common/UI/UIControl_Touch.cpp" + "Common/UI/UIControl_Touch.h" ) source_group("Common\\Source Files\\UI\\Controls" FILES ${Common__Source_Files__UI__Controls}) @@ -526,8 +526,8 @@ set(Common__Source_Files__UI__Scenes__In-Game_Menu_Screens "Common/UI/UIScene_InGameInfoMenu.h" "Common/UI/UIScene_InGamePlayerOptionsMenu.cpp" "Common/UI/UIScene_InGamePlayerOptionsMenu.h" -# "Common/UI/UIScene_InGameSaveManagementMenu.cpp" -# "Common/UI/UIScene_InGameSaveManagementMenu.h" + "Common/UI/UIScene_InGameSaveManagementMenu.cpp" + "Common/UI/UIScene_InGameSaveManagementMenu.h" "Common/UI/UIScene_PauseMenu.cpp" "Common/UI/UIScene_PauseMenu.h" "Common/UI/UIScene_SignEntryMenu.cpp" @@ -1104,6 +1104,8 @@ set(Linux "../Platform/Linux/Linux_UIController.cpp" "../Platform/Linux/Linux_Minecraft.cpp" "../Platform/Linux/Linux_App.cpp" + "../Platform/Linux/LinuxGL.cpp" + "../Platform/Linux/linux_game_stubs.cpp" ) source_group("Linux" FILES ${Linux}) @@ -5216,3 +5218,32 @@ endif() add_compile_options(-fpermissive -Wtemplate-body) target_link_libraries(${PROJECT_NAME} PRIVATE "${ADDITIONAL_LIBRARY_DEPENDENCIES}") target_link_libraries(${PROJECT_NAME} PRIVATE Minecraft.World) + +if(UNIX AND NOT APPLE) + find_package(OpenGL REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(GLFW3 REQUIRED glfw3) + + target_include_directories(${PROJECT_NAME} PRIVATE + ${GLFW3_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/4J.Input + ${CMAKE_SOURCE_DIR}/4J.Profile + ${CMAKE_SOURCE_DIR}/4J.Render + ${CMAKE_SOURCE_DIR}/4J.Storage + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE + Minecraft.World + OpenGL::GL + GLU + ${GLFW3_LIBRARIES} + 4J_Input + 4J_Profile + 4J_Render + 4J_Storage + pthread + dl + ) + + target_compile_definitions(${PROJECT_NAME} PRIVATE __linux__) +endif() diff --git a/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp b/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp index 5dead08fb..f5707cdef 100644 --- a/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp +++ b/Minecraft.Client/Build/Common/Audio/SoundEngine.cpp @@ -25,7 +25,7 @@ #endif // take out Orbis until they are done -#if defined _XBOX +#if defined _XBOX || defined(__linux__) SoundEngine::SoundEngine() {} void SoundEngine::init(Options *pOptions) @@ -52,6 +52,13 @@ void SoundEngine::addStreaming(const wstring& name, File *file) {} char *SoundEngine::ConvertSoundPathToName(const wstring& name, bool bConvertSpaces) { return NULL; } bool SoundEngine::isStreamingWavebankReady() { return true; } void SoundEngine::playMusicTick() {}; +void SoundEngine::SetStreamingSounds(int, int, int, int, int, int, int) {} +void SoundEngine::updateSystemMusicPlaying(bool) {} +#ifdef __linux__ +char SoundEngine::m_szSoundPath[]={"Sound/"}; +char SoundEngine::m_szMusicPath[]={"music/"}; +char SoundEngine::m_szRedistName[]={"redist64"}; +#endif #else @@ -95,6 +102,8 @@ char SoundEngine::m_szRedistName[]={"redist"}; #endif +#ifndef __linux__ + F32 AILCALLBACK custom_falloff_function (HSAMPLE S, F32 distance, F32 rolloff_factor, @@ -1666,3 +1675,5 @@ F32 AILCALLBACK custom_falloff_function (HSAMPLE S, return result; } + +#endif \ No newline at end of file diff --git a/Minecraft.Client/Build/Common/Consoles_App.cpp b/Minecraft.Client/Build/Common/Consoles_App.cpp index 679367683..a79ab5e61 100644 --- a/Minecraft.Client/Build/Common/Consoles_App.cpp +++ b/Minecraft.Client/Build/Common/Consoles_App.cpp @@ -192,11 +192,11 @@ CMinecraftApp::CMinecraftApp() m_dwRequiredTexturePackID=0; m_bResetNether=false; - + #ifdef _XBOX // m_bTransferSavesToXboxOne=false; // m_uiTransferSlotC=5; -#endif +#endif #if (defined _CONTENT_PACAKGE) || (defined _XBOX) m_bUseDPadForDebug = false; @@ -213,7 +213,7 @@ CMinecraftApp::CMinecraftApp() for(int i=0;i; + m_vBannedListA[i] = new vector; } LocaleAndLanguageInit(); @@ -241,7 +241,6 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...) void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...) { -#ifndef _FINAL_BUILD if(user == USER_NONE) return; char buf[1024]; @@ -249,48 +248,6 @@ void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...) va_start(ap, szFormat); vsnprintf(buf, sizeof(buf), szFormat, ap); va_end(ap); -#ifdef __PS3__ - unsigned int writelen; - sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen ); -#elif defined __PSVITA__ - switch(user) - { - case 0: - { - SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0); - if(tty2>=0) - { - std::string string1(buf); - sceIoWrite(tty2, string1.c_str(), string1.length()); - sceIoClose(tty2); - } - } - break; - case 1: - { - SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0); - if(tty3>=0) - { - std::string string1(buf); - sceIoWrite(tty3, string1.c_str(), string1.length()); - sceIoClose(tty3); - } - } - break; - default: - OutputDebugStringA(buf); - break; - } -#else - OutputDebugStringA(buf); -#endif -#ifndef _XBOX - if(user == USER_UI) - { - ui.logDebugString(buf); - } -#endif -#endif } LPCWSTR CMinecraftApp::GetString(int iID) @@ -312,7 +269,7 @@ void CMinecraftApp::SetAction(int iPad, eXuiAction action, LPVOID param) m_eXuiAction[iPad]=action; m_eXuiActionParam[iPad] = param; } -} +} bool CMinecraftApp::IsAppPaused() { @@ -348,7 +305,7 @@ void CMinecraftApp::HandleButtonPresses(int iPad) // // test an update of the profile data // void *pData=ProfileManager.GetGameDefinedProfileData(iPad); -// +// // unsigned char *pchData= (unsigned char *)pData; // int iCount=0; // for(int i=0;i player, CraftingPanelScreenInput* initData = new CraftingPanelScreenInput(); initData->player = player; - initData->iContainerType=RECIPE_TYPE_3x3; + initData->iContainerType=RECIPE_TYPE_3x3; initData->iPad = iPad; initData->x = x; initData->y = y; @@ -544,7 +501,7 @@ bool CMinecraftApp::LoadContainerMenu(int iPad,shared_ptr inventory, initData->container = container; initData->iPad = iPad; - // Load the scene. + // Load the scene. if(app.GetLocalPlayerCount()>1) { initData->bSplitscreen=true; @@ -774,7 +731,7 @@ int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETT pApp->DebugPrintf("Setting default options for player %d", iPad); pApp->SetAction(iPad,eAppAction_SetDefaultOptions, (LPVOID)pSettings); //pApp->SetDefaultOptions(pSettings,iPad); - + // if the profile data has been changed, then force a profile write // It seems we're allowed to break the 5 minute rule if it's the result of a user action //pApp->CheckGameSettingsChanged(); @@ -828,7 +785,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat case PROFILE_VERSION_1: case PROFILE_VERSION_2: // need to fill in values for the new profile data. No need to save the profile - that'll happen if they get changed, or if the auto save for the profile kicks in - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->ucMenuSensitivity=100; //eGameSetting_Sensitivity_InMenu pGameSettings->ucInterfaceOpacity=80; //eGameSetting_Sensitivity_InMenu @@ -874,7 +831,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_3: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->uiBitmaskValues=0L; // reset pGameSettings->uiBitmaskValues|=GAMESETTING_CLOUDS; //eGameSetting_Clouds - on @@ -911,7 +868,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat case PROFILE_VERSION_4: { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; - + pGameSettings->uiBitmaskValues&=~GAMESETTING_BEDROCKFOG; //eGameSetting_BedrockFog - off pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHUD; //eGameSetting_DisplayHUD - on pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYHAND; //eGameSetting_DisplayHand - on @@ -1008,7 +965,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_7: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; // reset the display new message counter pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) @@ -1031,7 +988,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; #endif case PROFILE_VERSION_8: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; // reset the display new message counter //pGameSettings->uiBitmaskValues|=GAMESETTING_DISPLAYUPDATEMSG; //eGameSetting_DisplayUpdateMessage (counter) @@ -1049,17 +1006,17 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; case PROFILE_VERSION_9: // PS3DEC13 - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->uiBitmaskValues&=~GAMESETTING_PS3EULAREAD; //eGameSetting_PS3_EULA_Read - off - + // PS3 1.05 - added Greek pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language } break; case PROFILE_VERSION_10: - { + { GAME_SETTINGS *pGameSettings=(GAME_SETTINGS *)pucData; pGameSettings->ucLanguage = MINECRAFT_LANGUAGE_DEFAULT; // use the system language @@ -1067,7 +1024,7 @@ int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucDat break; default: - { + { // This might be from a version during testing of new profile updates app.DebugPrintf("Don't know what to do with this profile version!\n"); #ifndef _CONTENT_PACKAGE @@ -1169,7 +1126,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) if(iPad==ProfileManager.GetPrimaryPad()) { pMinecraft->options->set(Options::Option::SOUND,((float)GameSettingsA[iPad]->ucSoundFXVolume)/100.0f); - } + } break; case eGameSetting_Gamma: if(iPad==ProfileManager.GetPrimaryPad()) @@ -1177,10 +1134,10 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) // ucGamma range is 0-100, UpdateGamma is 0 - 32768 float fVal=((float)GameSettingsA[iPad]->ucGamma)*327.68f; RenderManager.UpdateGamma((unsigned short)fVal); - } + } break; - case eGameSetting_Difficulty: + case eGameSetting_Difficulty: if(iPad==ProfileManager.GetPrimaryPad()) { pMinecraft->options->toggle(Options::Option::DIFFICULTY,GameSettingsA[iPad]->usBitmaskValues&0x03); @@ -1202,7 +1159,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) { app.DebugPrintf("NOT ACTIONING DIFFICULTY - Primary pad is %d, This pad is %d\n",ProfileManager.GetPrimaryPad(),iPad); } - + break; case eGameSetting_Sensitivity_InGame: // 4J-PB - we don't use the options value @@ -1329,7 +1286,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) //nothing to do here break; case eGameSetting_BedrockFog: - { + { bool bInGame=pMinecraft->level!=NULL; // Game Host only @@ -1408,8 +1365,8 @@ DWORD CMinecraftApp::GetPlayerSkinId(int iPad) { // 4J Stu - DLC skins are numbered using decimal rather than hex to make it easier to number manually swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(dwSkin)); - - Pack=app.m_dlcManager.getPackContainingSkin(chars); + + Pack=app.m_dlcManager.getPackContainingSkin(chars); if(Pack) { @@ -1512,7 +1469,7 @@ unsigned int CMinecraftApp::GetPlayerFavoriteSkinsCount(int iPad) void CMinecraftApp::ValidateFavoriteSkins(int iPad) { unsigned int uiCount=GetPlayerFavoriteSkinsCount(iPad); - + // remove invalid skins unsigned int uiValidSkin=0; wchar_t chars[256]; @@ -1533,7 +1490,7 @@ void CMinecraftApp::ValidateFavoriteSkins(int iPad) if( pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") || (pSkinFile && pSkinFile->isFree())) { - GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; + GameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++]=GameSettingsA[iPad]->uiFavoriteSkinA[i]; } } } @@ -1554,7 +1511,7 @@ void CMinecraftApp::HideMashupPackWorld(int iPad, unsigned int iMashupPackID) void CMinecraftApp::SetMinecraftLanguage(int iPad, unsigned char ucLanguage) { - GameSettingsA[iPad]->ucLanguage = ucLanguage; + GameSettingsA[iPad]->ucLanguage = ucLanguage; GameSettingsA[iPad]->bSettingsChanged = true; } @@ -1606,7 +1563,7 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV if(iPad==ProfileManager.GetPrimaryPad()) { ActionGameSettings(iPad,eVal); - } + } GameSettingsA[iPad]->bSettingsChanged=true; } break; @@ -1621,7 +1578,7 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; - case eGameSetting_Difficulty: + case eGameSetting_Difficulty: if((GameSettingsA[iPad]->usBitmaskValues&0x03)!=(ucVal&0x03)) { GameSettingsA[iPad]->usBitmaskValues&=~0x03; @@ -1966,9 +1923,9 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; - case eGameSetting_UISize: + } + break; + case eGameSetting_UISize: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE)!=((ucVal&0x03)<<11)) { GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE; @@ -1980,7 +1937,7 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV GameSettingsA[iPad]->bSettingsChanged=true; } break; - case eGameSetting_UISizeSplitscreen: + case eGameSetting_UISizeSplitscreen: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_UISIZE_SPLITSCREEN)!=((ucVal&0x03)<<13)) { GameSettingsA[iPad]->uiBitmaskValues&=~GAMESETTING_UISIZE_SPLITSCREEN; @@ -2005,8 +1962,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; case eGameSetting_PS3_EULA_Read: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PS3EULAREAD)!=(ucVal&0x01)<<16) { @@ -2020,8 +1977,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; case eGameSetting_PSVita_NetworkModeAdhoc: if((GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_PSVITANETWORKMODEADHOC)!=(ucVal&0x01)<<17) { @@ -2035,8 +1992,8 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV } ActionGameSettings(iPad,eVal); GameSettingsA[iPad]->bSettingsChanged=true; - } - break; + } + break; } } @@ -2061,7 +2018,7 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) case eGameSetting_Gamma: return GameSettingsA[iPad]->ucGamma; break; - case eGameSetting_Difficulty: + case eGameSetting_Difficulty: return GameSettingsA[iPad]->usBitmaskValues&0x0003; break; case eGameSetting_Sensitivity_InGame: @@ -2110,7 +2067,7 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) case eGameSetting_InterfaceOpacity: return GameSettingsA[iPad]->ucInterfaceOpacity; break; - + case eGameSetting_Clouds: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_CLOUDS); break; @@ -2125,7 +2082,7 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_DisplayUpdateMessage: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_DISPLAYUPDATEMSG)>>4; - break; + break; case eGameSetting_BedrockFog: return (GameSettingsA[iPad]->uiBitmaskValues&GAMESETTING_BEDROCKFOG)>>6; break; @@ -2451,13 +2408,13 @@ void CMinecraftApp::HandleXuiActions(void) param = m_eXuiActionParam[i]; if(eAction!=eAppAction_Idle) - { + { switch(eAction) { // the renderer will capture a screenshot case eAppAction_SocialPost: if(ProfileManager.IsFullVersion()) - { + { // Facebook Share if( CSocialManager::Instance()->IsTitleAllowedToPostImages() && CSocialManager::Instance()->AreAllUsersAllowedToPostImages() ) { @@ -2517,7 +2474,7 @@ void CMinecraftApp::HandleXuiActions(void) else { // ask the player if they would like to upgrade, or they'll lose the level - + UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; @@ -2527,7 +2484,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_AutosaveSaveGame: - { + { // Need to run a check to see if the save exists in order to stop the dialog asking if we want to overwrite it coming up on an autosave bool bSaveExists; StorageManager.DoesSaveExist(&bSaveExists); @@ -2537,7 +2494,7 @@ void CMinecraftApp::HandleXuiActions(void) { // flag the render to capture the screenshot for the save - SetAction(i,eAppAction_AutosaveSaveGameCapturedThumbnail); + SetAction(i,eAppAction_AutosaveSaveGameCapturedThumbnail); } } @@ -2563,7 +2520,7 @@ void CMinecraftApp::HandleXuiActions(void) //INT saveOrCheckpointId = 0; //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); - + LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; loadingParams->lpParam = (LPVOID)false; @@ -2587,7 +2544,7 @@ void CMinecraftApp::HandleXuiActions(void) } loadingParams->completionData = completionData; - + // 4J Stu - Xbox only #ifdef _XBOX // Temporarily make this scene fullscreen @@ -2600,7 +2557,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_AutosaveSaveGameCapturedThumbnail: - { + { app.SetAutosaveTimerTime(); SetAction(i,eAppAction_Idle); @@ -2618,12 +2575,12 @@ void CMinecraftApp::HandleXuiActions(void) // This just allows it to be shown if(pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()] != NULL) pMinecraft->localgameModes[ProfileManager.GetPrimaryPad()]->getTutorial()->showTutorialPopup(false); - + //INT saveOrCheckpointId = 0; //bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); //SentientManager.RecordLevelSaveOrCheckpoint(ProfileManager.GetPrimaryPad(), saveOrCheckpointId); - + LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::SaveWorldThreadProc; @@ -2636,7 +2593,7 @@ void CMinecraftApp::HandleXuiActions(void) completionData->iPad = ProfileManager.GetPrimaryPad(); //completionData->bAutosaveWasMenuDisplayed=ui.GetMenuDisplayed(ProfileManager.GetPrimaryPad()); loadingParams->completionData = completionData; - + // 4J Stu - Xbox only #ifdef _XBOX // Temporarily make this scene fullscreen @@ -2650,7 +2607,7 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_ExitPlayer: // a secondary player has chosen to quit { - int iPlayerC=g_NetworkManager.GetPlayerCount(); + int iPlayerC=g_NetworkManager.GetPlayerCount(); // Since the player is exiting, let's flush any profile writes for them, and hope we're not breaking TCR 136... #if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) @@ -2671,7 +2628,7 @@ void CMinecraftApp::HandleXuiActions(void) // not required - it's done within the removeLocalPlayerIdx // if(pMinecraft->level->isClientSide) - // { + // { // // we need to remove the qnetplayer, or this player won't be able to get back into the game until qnet times out and removes them // g_NetworkManager.NotifyPlayerLeaving(g_NetworkManager.GetLocalPlayerByUserIndex(i)); // } @@ -2710,9 +2667,9 @@ void CMinecraftApp::HandleXuiActions(void) if(iPlayerC>2) // one player is about to leave here - they'll be set to idle in the qnet manager player leave { for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { + { if(g_NetworkManager.IsLocalGame()) { ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); @@ -2727,9 +2684,9 @@ void CMinecraftApp::HandleXuiActions(void) else { for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { + { if(g_NetworkManager.IsLocalGame()) { ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); @@ -2741,11 +2698,11 @@ void CMinecraftApp::HandleXuiActions(void) } } } - + #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(i); -#endif - +#endif + SetAction(i,eAppAction_Idle); } break; @@ -2757,7 +2714,7 @@ void CMinecraftApp::HandleXuiActions(void) StorageManager.ForceQueuedProfileWrites(i); #else ProfileManager.ForceQueuedProfileWrites(i); -#endif +#endif // if there are any tips showing, we need to close them pMinecraft->gui->clearMessages(i); @@ -2792,9 +2749,9 @@ void CMinecraftApp::HandleXuiActions(void) if(iPlayerC>2) // one player is about to leave here - they'll be set to idle in the qnet manager player leave { for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { + { if(g_NetworkManager.IsLocalGame()) { ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYEROFFLINE,false); @@ -2809,9 +2766,9 @@ void CMinecraftApp::HandleXuiActions(void) else { for(int iPlayer=0;iPlayerlocalplayers[iPlayer]) - { + { if(g_NetworkManager.IsLocalGame()) { ProfileManager.SetCurrentGameActivity(iPlayer,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); @@ -2866,7 +2823,7 @@ void CMinecraftApp::HandleXuiActions(void) SetAction(i,eAppAction_Idle); // If we're already leaving don't exit - if (g_NetworkManager.IsLeavingGame()) + if (g_NetworkManager.IsLeavingGame()) { break; } @@ -2897,7 +2854,7 @@ void CMinecraftApp::HandleXuiActions(void) Minecraft::GetInstance()->forceStatsSave(j); } } - LeaderboardManager::Instance()->CloseSession(); + LeaderboardManager::Instance()->CloseSession(); #elif (defined _XBOX) ProfileManager.ForceQueuedProfileWrites(); #endif @@ -2917,7 +2874,7 @@ void CMinecraftApp::HandleXuiActions(void) #ifdef _DURANGO ProfileManager.RemoveGamepadFromGame(i); -#endif +#endif SetAction(i,eAppAction_Idle); return; } @@ -2935,13 +2892,13 @@ void CMinecraftApp::HandleXuiActions(void) // Change the presence info // Are we offline or online, and how many players are there - + if(g_NetworkManager.GetPlayerCount()>1) { for(int j=0;jlocalplayers[j]) - { + { if(g_NetworkManager.IsLocalGame()) { app.SetRichPresenceContext(j,CONTEXT_GAME_STATE_BLANK); @@ -2960,7 +2917,7 @@ void CMinecraftApp::HandleXuiActions(void) { app.SetRichPresenceContext(i,CONTEXT_GAME_STATE_BLANK); if(g_NetworkManager.IsLocalGame()) - { + { ProfileManager.SetCurrentGameActivity(i,CONTEXT_PRESENCE_MULTIPLAYER_1POFFLINE,false); } else @@ -2981,14 +2938,14 @@ void CMinecraftApp::HandleXuiActions(void) // turn off the gamertags in splitscreen for the primary player, since they are about to be made fullscreen ui.HideAllGameUIElements(); - + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX app.TutorialSceneNavigateBack(idx,true); #endif - + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial // It doesn't matter if they were in the tutorial already pMinecraft->playerLeftTutorial( idx ); @@ -2996,7 +2953,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); // If param is non-null then this is a forced exit by the server, so make sure the player knows why @@ -3009,11 +2966,11 @@ void CMinecraftApp::HandleXuiActions(void) completionData->iPad = DEFAULT_XUI_MENU_USER; loadingParams->completionData = completionData; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } break; case eAppAction_ExitWorldTrial: - { + { SetAction(i,eAppAction_Idle); pMinecraft->gui->clearMessages(); @@ -3025,14 +2982,14 @@ void CMinecraftApp::HandleXuiActions(void) SetGameStarted(false); ui.CloseAllPlayersScenes(); - + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX app.TutorialSceneNavigateBack(idx,true); #endif - + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial // It doesn't matter if they were in the tutorial already pMinecraft->playerLeftTutorial( idx ); @@ -3040,7 +2997,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_PauseMenu::ExitWorldThreadProc; - loadingParams->lpParam = param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3048,7 +3005,7 @@ void CMinecraftApp::HandleXuiActions(void) completionData->type = e_ProgressCompletion_NavigateToHomeMenu; completionData->iPad = DEFAULT_XUI_MENU_USER; loadingParams->completionData = completionData; - + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } @@ -3066,7 +3023,7 @@ void CMinecraftApp::HandleXuiActions(void) param->showTooltips = false; param->setFailTimer = false; ui.NavigateToScene(i,eUIScene_ConnectingProgress, param); - + // Need to reset this incase the player has already died and respawned pMinecraft->localplayers[i]->SetPlayerRespawned(false); @@ -3094,7 +3051,7 @@ void CMinecraftApp::HandleXuiActions(void) // Disable game & update thread whilst we do any of this //app.SetGameStarted(false); pMinecraft->gameRenderer->DisableUpdateThread(); - + // 4J Stu - We don't need this on a thread in multiplayer as respawning is asynchronous. pMinecraft->localplayers[i]->respawn(); @@ -3110,7 +3067,7 @@ void CMinecraftApp::HandleXuiActions(void) //app.NavigateToScene(i,eUIScene_FullscreenProgress, loadingParams, true); } - } + } break; case eAppAction_WaitForRespawnComplete: player = pMinecraft->localplayers[i]; @@ -3150,8 +3107,8 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_PrimaryPlayerSignedOut: - { - //SetAction(i,eAppAction_Idle); + { + //SetAction(i,eAppAction_Idle); // clear the autosavetimer that might be displayed ui.ShowAutosaveCountdownTimer(false); @@ -3169,10 +3126,10 @@ void CMinecraftApp::HandleXuiActions(void) // 4J-PB - the libs will display the Returned to Title screen // UINT uiIDA[1]; // uiIDA[0]=IDS_CONFIRM_OK; -// +// // ui.RequestMessageBox(IDS_RETURNEDTOMENU_TITLE, IDS_RETURNEDTOTITLESCREEN_TEXT, uiIDA, 1, i,&CMinecraftApp::PrimaryPlayerSignedOutReturned,this,app.GetStringTable()); if( g_NetworkManager.IsInSession() ) - { + { app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned); } else @@ -3220,7 +3177,7 @@ void CMinecraftApp::HandleXuiActions(void) if (!gameStarted) { - // 1. Exit + // 1. Exit MinecraftServer::HaltServer(); // Fix for #12530 - TCR 001 BAS Game Stability: Title will crash if the player disconnects while starting a new world and then opts to play the tutorial once they have been returned to the Main Menu. @@ -3288,21 +3245,21 @@ void CMinecraftApp::HandleXuiActions(void) ui.HideAllGameUIElements(); ui.CloseAllPlayersScenes(); - + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX app.TutorialSceneNavigateBack(idx,true); #endif - + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial // It doesn't matter if they were in the tutorial already pMinecraft->playerLeftTutorial( idx ); } LoadingInputParams *loadingParams = new LoadingInputParams(); - loadingParams->func = &CMinecraftApp::SignoutExitWorldThreadProc; + loadingParams->func = &CMinecraftApp::SignoutExitWorldThreadProc; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3340,7 +3297,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_TrialOver: - { + { SetAction(i,eAppAction_Idle); UINT uiIDA[2]; uiIDA[0]=IDS_UNLOCK_TITLE; @@ -3352,7 +3309,7 @@ void CMinecraftApp::HandleXuiActions(void) // INVITES case eAppAction_DashboardTrialJoinFromInvite: - { + { TelemetryManager->RecordUpsellPresented(i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); SetAction(i,eAppAction_Idle); @@ -3364,7 +3321,7 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_ExitAndJoinFromInvite: - { + { UINT uiIDA[3]; SetAction(i,eAppAction_Idle); @@ -3373,7 +3330,7 @@ void CMinecraftApp::HandleXuiActions(void) #if defined(_XBOX_ONE) || defined(__ORBIS__) // Show save option is saves ARE disabled if(ProfileManager.IsFullVersion() && StorageManager.GetSaveDisabled() && i==ProfileManager.GetPrimaryPad() && g_NetworkManager.IsHost() && GetGameStarted() ) - { + { uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_EXIT_GAME_SAVE; uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; @@ -3383,7 +3340,7 @@ void CMinecraftApp::HandleXuiActions(void) else #else if(ProfileManager.IsFullVersion() && !StorageManager.GetSaveDisabled() && i==ProfileManager.GetPrimaryPad() && g_NetworkManager.IsHost() && GetGameStarted() ) - { + { uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_EXIT_GAME_SAVE; uiIDA[2]=IDS_EXIT_GAME_NO_SAVE; @@ -3403,7 +3360,7 @@ void CMinecraftApp::HandleXuiActions(void) ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_ACCEPT_INVITE, uiIDA, 2, i,&CMinecraftApp::UnlockFullInviteReturned,this,app.GetStringTable()); } else - { + { uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, 2,i,&CMinecraftApp::ExitAndJoinFromInvite,this,app.GetStringTable(), 0, 0, false); @@ -3424,14 +3381,14 @@ void CMinecraftApp::HandleXuiActions(void) SetGameStarted(false); ui.CloseAllPlayersScenes(); - + // 4J Stu - Fix for #12368 - Crash: Game crashes when saving then exiting and selecting to save for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { #ifdef _XBOX app.TutorialSceneNavigateBack(idx,true); #endif - + // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after exiting the tutorial // It doesn't matter if they were in the tutorial already pMinecraft->playerLeftTutorial( idx ); @@ -3491,7 +3448,7 @@ void CMinecraftApp::HandleXuiActions(void) if(ProfileManager.IsSignedIn(index) ) { if(index==i || pMinecraft->localplayers[index]!=NULL ) - { + { m_InviteData.dwLocalUsersMask |= g_NetworkManager.GetLocalPlayerMask( index ); } } @@ -3500,7 +3457,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::ExitAndJoinFromInviteThreadProc; - loadingParams->lpParam = (LPVOID)&m_InviteData; + loadingParams->lpParam = (LPVOID)&m_InviteData; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3538,7 +3495,7 @@ void CMinecraftApp::HandleXuiActions(void) if( index != inviteData->dwUserIndex && ProfileManager.IsSignedIn(index) ) { if( (m_InviteData.dwLocalUsersMask & g_NetworkManager.GetLocalPlayerMask( index ) ) == 0 ) - { + { ProfileManager.RemoveGamepadFromGame(index); } } @@ -3562,7 +3519,7 @@ void CMinecraftApp::HandleXuiActions(void) UINT uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); - + ui.NavigateToHomeMenu(); ui.UpdatePlayerBasePositions(); } @@ -3574,12 +3531,12 @@ void CMinecraftApp::HandleXuiActions(void) if( g_NetworkManager.IsInGameplay() ) { // This kicks off a thread that waits for the server to end, then closes the current session, starts a new one and joins the local players into it - + SetAction(i,eAppAction_Idle); if( !GetChangingSessionType() && !g_NetworkManager.IsLocalGame() ) { - SetGameStarted(false); + SetGameStarted(false); SetChangingSessionType(true); SetReallyChangingSessionType(true); @@ -3591,14 +3548,14 @@ void CMinecraftApp::HandleXuiActions(void) ui.CloseAllPlayersScenes(); } ui.ShowOtherPlayersBaseScene(ProfileManager.GetPrimaryPad(), true); - + // Remove this line to fix: // #49084 - TU5: Code: Gameplay: The title crashes every time client navigates to 'Play game' menu and loads/creates new game after a "Connection to Xbox LIVE was lost" message has appeared. //app.NavigateToScene(0,eUIScene_Main); - + LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::ChangeSessionTypeThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = NULL; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); #ifdef __PS3__ @@ -3620,7 +3577,7 @@ void CMinecraftApp::HandleXuiActions(void) } loadingParams->completionData = completionData; - ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); + ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } } else if( g_NetworkManager.IsLeavingGame() ) @@ -3647,9 +3604,9 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_SetDefaultOptions: SetAction(i,eAppAction_Idle); #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) - SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); + SetDefaultOptions((C4JStorage::PROFILESETTINGS *)param,i); #else - SetDefaultOptions((C_4JProfile::PROFILESETTINGS *)param,i); + SetDefaultOptions((C_4JProfile::PROFILESETTINGS *)param,i); #endif // if the profile data has been changed, then force a profile write @@ -3657,7 +3614,7 @@ void CMinecraftApp::HandleXuiActions(void) CheckGameSettingsChanged(true,i); break; - + case eAppAction_RemoteServerSave: { // If the remote server save has already finished, don't complete the action @@ -3668,7 +3625,7 @@ void CMinecraftApp::HandleXuiActions(void) } SetAction(i,eAppAction_WaitRemoteServerSaveComplete); - + for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { ui.CloseUIScenes(i, true); @@ -3679,7 +3636,7 @@ void CMinecraftApp::HandleXuiActions(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CMinecraftApp::RemoteSaveThreadProc; - loadingParams->lpParam = NULL; + loadingParams->lpParam = NULL; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bRequiresUserAction=FALSE; @@ -3721,7 +3678,7 @@ void CMinecraftApp::HandleXuiActions(void) if(!app.GetGameStarted()) MinecraftServer::HaltServer(true); if( g_NetworkManager.IsInSession() ) - { + { app.SetAction(i,eAppAction_PrimaryPlayerSignedOutReturned); } else @@ -3730,7 +3687,7 @@ void CMinecraftApp::HandleXuiActions(void) MinecraftServer::resetFlags(); } break; - + case eAppAction_BanLevel: { // It's possible that this state can get set after the game has been exited (e.g. by network disconnection) so we can't ban the level at that point @@ -3738,12 +3695,12 @@ void CMinecraftApp::HandleXuiActions(void) { TelemetryManager->RecordBanLevel(i); -#if defined _XBOX - INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); +#if defined _XBOX + INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); // write the level to the banned level list, and exit the world AddLevelToBannedLevelList(i,((NetworkPlayerXbox *)pHost)->GetUID(),GetUniqueMapName(),true); #elif defined _XBOX_ONE - INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); + INetworkPlayer *pHost=g_NetworkManager.GetHostPlayer(); AddLevelToBannedLevelList(i,pHost->GetUID(),GetUniqueMapName(),true); #endif // primary player would exit the world, secondary would exit the player @@ -3759,7 +3716,7 @@ void CMinecraftApp::HandleXuiActions(void) } break; case eAppAction_LevelInBanLevelList: - { + { UINT uiIDA[2]; uiIDA[0]=IDS_BUTTON_REMOVE_FROM_BAN_LIST; uiIDA[1]=IDS_EXIT_GAME; @@ -3798,15 +3755,15 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_ReloadTexturePack: - { + { SetAction(i,eAppAction_Idle); Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->textures->reloadAll(); pMinecraft->skins->updateUI(); - + if(!pMinecraft->skins->isUsingDefaultSkin()) { - TexturePack *pTexturePack = pMinecraft->skins->getSelected(); + TexturePack *pTexturePack = pMinecraft->skins->getSelected(); DLCPack *pDLCPack=pTexturePack->getDLCPack(); @@ -3824,7 +3781,7 @@ void CMinecraftApp::HandleXuiActions(void) // 4J-PB - If the texture pack has audio, we need to switch to this if(pMinecraft->skins->getSelected()->hasAudio()) { - Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); + Minecraft::GetInstance()->soundEngine->playStreaming(L"", 0, 0, 0, 1, 1); } } @@ -3857,7 +3814,7 @@ void CMinecraftApp::HandleXuiActions(void) eTMS = app.GetTMSAction(i); if(eTMS!=eTMSAction_Idle) - { + { switch(eTMS) { // TMS++ actions @@ -3882,7 +3839,7 @@ void CMinecraftApp::HandleXuiActions(void) #endif case eTMSAction_TMSPP_UserFileList: // retrieve the file list first -#if defined _XBOX +#if defined _XBOX SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); #elif defined _XBOX_ONE @@ -3901,7 +3858,7 @@ void CMinecraftApp::HandleXuiActions(void) SetTMSAction(i,eTMSAction_TMSPP_DLCFile); #endif - break; + break; case eTMSAction_TMSPP_DLCFile: #if defined _XBOX || defined _XBOX_ONE SetTMSAction(i,eTMSAction_TMSPP_DLCFile_Waiting); @@ -3935,7 +3892,7 @@ void CMinecraftApp::HandleXuiActions(void) case eTMSAction_TMSPP_RetrieveFiles_HelpAndOptions: case eTMSAction_TMSPP_RetrieveFiles_DLCMain: // retrieve the file list first -#if defined _XBOX +#if defined _XBOX // pass in the next app action on the call or callback completing SetTMSAction(i,eTMSAction_TMSPP_XUIDSFile_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_Title,"\\",eTMSAction_TMSPP_DLCFileOnly); @@ -3947,7 +3904,7 @@ void CMinecraftApp::HandleXuiActions(void) #endif break; case eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly: -#if defined _XBOX +#if defined _XBOX SetTMSAction(i,eTMSAction_TMSPP_UserFileList_Waiting); app.TMSPP_RetrieveFileList(i,C4JStorage::eGlobalStorage_TitleUser,"\\",eTMSAction_TMSPP_XUIDSFile); #elif defined _XBOX_ONE @@ -4091,7 +4048,7 @@ void CMinecraftApp::loadMediaArchive() mediapath = L"Common\\Media\\MediaPSVita.arc"; #endif - if (!mediapath.empty()) + if (!mediapath.empty()) { m_mediaArchive = new ArchiveFile( File(mediapath) ); } @@ -4172,7 +4129,7 @@ int CMinecraftApp::PrimaryPlayerSignedOutReturned(void *pParam,int iPad,const C4 // We always create a session before kicking of any of the game code, so even though we may still be joining/creating a game // at this point we want to handle it differently from just being in a menu if( g_NetworkManager.IsInSession() ) - { + { app.SetAction(iPad,eAppAction_PrimaryPlayerSignedOutReturned); } else @@ -4189,7 +4146,7 @@ int CMinecraftApp::EthernetDisconnectReturned(void *pParam,int iPad,const C4JSto // if the player is null, we're in the menus if(Minecraft::GetInstance()->player!=NULL) - { + { app.SetAction(pMinecraft->player->GetXboxPad(),eAppAction_EthernetDisconnectedReturned); } else @@ -4319,10 +4276,10 @@ int CMinecraftApp::SignoutExitWorldThreadProc( void* lpParameter ) // 4J-JEV: Fix for #106402 - TCR #014 BAS Debug Output: // TU12: Mass Effect Mash-UP: Save file "Default_DisplayName" is created on all storage devices after signing out from a re-launched pre-generated world - app.m_gameRules.unloadCurrentGameRules(); // + app.m_gameRules.unloadCurrentGameRules(); // MinecraftServer::resetFlags(); - + // We can't start/join a new game until the session is destroyed, so wait for it to be idle again while( g_NetworkManager.IsInSession() ) { @@ -4422,7 +4379,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes } #elif defined(__ORBIS__) else - { + { // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -4434,7 +4391,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); } else - { + { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; @@ -4491,7 +4448,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes } #elif defined(__ORBIS__) else - { + { // Determine why they're not "signed in live" if (ProfileManager.isSignedInPSN(iPad)) { @@ -4505,7 +4462,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes pApp->SetAction(pMinecraft->player->GetXboxPad(),eAppAction_ExitWorldTrial); } else - { + { // Not signed in to PSN UINT uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; @@ -4590,7 +4547,7 @@ void CMinecraftApp::ProfileReadErrorCallback(void *pParam) void CMinecraftApp::ClearSignInChangeUsersMask() { - // 4J-PB - When in the main menu, the user is on pad 0, and any change they make to their profile will be to pad 0 data + // 4J-PB - When in the main menu, the user is on pad 0, and any change they make to their profile will be to pad 0 data // If they then go in as a secondary player to a splitscreen game, their profile will not be read again on pad 1 if they were previously in a splitscreen game // This is because m_uiLastSignInData remembers they were in previously, and doesn't read the profile data for them again // Fix this by resetting the m_uiLastSignInData on pressing play game for secondary users. The Primary user does a read profile on play game anyway @@ -4625,7 +4582,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange { // Primary Player gone or there's been a sign out and sign in of the primary player, so kick them out pApp->SetAction(iPrimaryPlayer,eAppAction_PrimaryPlayerSignedOut); - + // 4J-PB - invalidate their banned level list pApp->InvalidateBannedList(iPrimaryPlayer); @@ -4696,7 +4653,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange bool bPlayerChanged=(uiChangedPlayers&(1<m_currentSigninInfo[i].xuid, info.xuid) ) )) + if( bPlayerChanged && (!bPlayerSignedIn || (bPlayerSignedIn && !ProfileManager.AreXUIDSEqual(pApp->m_currentSigninInfo[i].xuid, info.xuid) ) )) { // 4J-PB - invalidate their banned level list pApp->DebugPrintf("Player at index %d Left - invalidating their banned list\n",i); @@ -4731,7 +4688,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange pApp->SetAction(iPrimaryPlayer,eAppAction_EthernetDisconnected); } - + g_NetworkManager.HandleSignInChange(); } // Some menus require the player to be signed in to live, so if this callback happens and the primary player is @@ -4745,7 +4702,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange // 4J-JEV: Need to kick of loading of profile data for sub-sign in players. for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - if( i != iPrimaryPlayer + if( i != iPrimaryPlayer && ( uiChangedPlayers & (1<RecordUpsellResponded(ProfileManager.GetPrimaryPad(), eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID, senResponse); } @@ -4975,7 +4932,7 @@ int CMinecraftApp::DebugInputCallback(LPVOID pParam) { if(app.DebugSettingsOn()) { - app.ActionDebugMask(i); + app.ActionDebugMask(i); } else { @@ -5067,7 +5024,7 @@ void CMinecraftApp::MountNextDLC(int iPad) if(StorageManager.MountInstalledDLC(iPad,m_iTotalDLCInstalled,&CMinecraftApp::DLCMountedCallback,this)!=ERROR_IO_PENDING ) { // corrupt DLC - app.DebugPrintf("Failed to mount DLC %d for pad %d\n",m_iTotalDLCInstalled,iPad); + app.DebugPrintf("Failed to mount DLC %d for pad %d\n",m_iTotalDLCInstalled,iPad); ++m_iTotalDLCInstalled; app.MountNextDLC(iPad); } @@ -5140,7 +5097,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d app.m_dlcManager.removePack(pack); pack = NULL; } - + if(pack == NULL) { app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n", CONTENT_DATA_DISPLAY_NAME(ContentData)); @@ -5185,15 +5142,15 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // void CMinecraftApp::InstallDefaultCape() // { // if(!m_bDefaultCapeInstallAttempted) -// { +// { // // we only attempt to install the cape once per launch of the game // m_bDefaultCapeInstallAttempted=true; -// +// // wstring wTemp=L"Default_Cape.png"; // bool bRes=app.IsFileInMemoryTextures(wTemp); // // if the file is not already in the memory textures, then read it from TMS // if(!bRes) -// { +// { // BYTE *pBuffer=NULL; // DWORD dwSize=0; // // 4J-PB - out for now for DaveK so he doesn't get the birthday cape @@ -5203,13 +5160,13 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // if(eTMSStatus==C4JStorage::ETMSStatus_Idle) // { // app.AddMemoryTextureFile(wTemp,pBuffer,dwSize); -// } +// } // #endif // } // } // } - void CMinecraftApp::HandleDLC(DLCPack *pack) + void CMinecraftApp::HandleDLC(DLCPack *pack) { DWORD dwFilesProcessed = 0; #ifndef _XBOX @@ -5246,7 +5203,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d { strcpy(szFullFilename,szPath); strcat(szFullFilename,wfd.cFileName); - + if(( GetFileAttributes( szFullFilename ) & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { #ifdef _XBOX @@ -5257,9 +5214,9 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d File texturePCKPath(wsTemp ); if(texturePCKPath.exists()) { - app.DebugPrintf("Found a replacement .pck\n"); + app.DebugPrintf("Found a replacement .pck\n"); m_dlcManager.readDLCDataFile(dwFilesProcessed, wsTemp,pack); - } + } else { m_dlcManager.readDLCDataFile(dwFilesProcessed, szFullFilename,pack); @@ -5269,7 +5226,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d #endif } - } + } while( FindNextFile( hFind, &wfd ) ); // Close the find handle. @@ -5282,8 +5239,8 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // int CMinecraftApp::DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS *pDLCData) // { -// -// +// +// // return 0; // } @@ -5292,7 +5249,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // Desc: Initializes the timer variables //------------------------------------------------------------------------------------- void CMinecraftApp::InitTime() - { + { // Get the frequency of the timer LARGE_INTEGER qwTicksPerSec; @@ -5304,8 +5261,8 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d // Zero out the elapsed and total time m_Time.qwAppTime.QuadPart = 0; - m_Time.fAppTime = 0.0f; - m_Time.fElapsedTime = 0.0f; + m_Time.fAppTime = 0.0f; + m_Time.fElapsedTime = 0.0f; } //------------------------------------------------------------------------------------- @@ -5317,14 +5274,14 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d LARGE_INTEGER qwNewTime; LARGE_INTEGER qwDeltaTime; - QueryPerformanceCounter( &qwNewTime ); + QueryPerformanceCounter( &qwNewTime ); qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_Time.qwTime.QuadPart; - m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; + m_Time.qwAppTime.QuadPart += qwDeltaTime.QuadPart; m_Time.qwTime.QuadPart = qwNewTime.QuadPart; m_Time.fElapsedTime = m_Time.fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - m_Time.fAppTime = m_Time.fSecsPerTick * ((FLOAT)(m_Time.qwAppTime.QuadPart)); + m_Time.fAppTime = m_Time.fSecsPerTick * ((FLOAT)(m_Time.qwAppTime.QuadPart)); } @@ -5357,8 +5314,8 @@ bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) return false; } -void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD dwBytes) -{ +void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD dwBytes) +{ EnterCriticalSection(&csMemFilesLock); // check it's not already in PMEMDATA pData=NULL; @@ -5406,7 +5363,7 @@ void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD void CMinecraftApp::RemoveMemoryTextureFile(const wstring &wName) { EnterCriticalSection(&csMemFilesLock); - + AUTO_VAR(it, m_MEM_Files.find(wName)); if(it != m_MEM_Files.end()) { @@ -5434,7 +5391,7 @@ bool CMinecraftApp::DefaultCapeExists() EnterCriticalSection(&csMemFilesLock); AUTO_VAR(it, m_MEM_Files.find(wTex)); - if(it != m_MEM_Files.end()) val = true; + if(it != m_MEM_Files.end()) val = true; LeaveCriticalSection(&csMemFilesLock); return val; @@ -5446,7 +5403,7 @@ bool CMinecraftApp::IsFileInMemoryTextures(const wstring &wName) EnterCriticalSection(&csMemFilesLock); AUTO_VAR(it, m_MEM_Files.find(wName)); - if(it != m_MEM_Files.end()) val = true; + if(it != m_MEM_Files.end()) val = true; LeaveCriticalSection(&csMemFilesLock); return val; @@ -5465,14 +5422,14 @@ void CMinecraftApp::GetMemFileDetails(const wstring &wName,PBYTE *ppbData,DWORD LeaveCriticalSection(&csMemFilesLock); } -void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) -{ +void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) +{ EnterCriticalSection(&csMemTPDLock); // check it's not already in PMEMDATA pData=NULL; AUTO_VAR(it, m_MEM_TPD.find(iConfig)); if(it == m_MEM_TPD.end()) - { + { pData = (PMEMDATA)new BYTE[sizeof(MEMDATA)]; ZeroMemory( pData, sizeof(MEMDATA) ); pData->pbData=pbData; @@ -5485,8 +5442,8 @@ void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) LeaveCriticalSection(&csMemTPDLock); } -void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) -{ +void CMinecraftApp::RemoveMemoryTPDFile(int iConfig) +{ EnterCriticalSection(&csMemTPDLock); // check it's not already in PMEMDATA pData=NULL; @@ -5548,7 +5505,7 @@ bool CMinecraftApp::IsFileInTPD(int iConfig) EnterCriticalSection(&csMemTPDLock); AUTO_VAR(it, m_MEM_TPD.find(iConfig)); - if(it != m_MEM_TPD.end()) val = true; + if(it != m_MEM_TPD.end()) val = true; LeaveCriticalSection(&csMemTPDLock); return val; @@ -5574,18 +5531,18 @@ void CMinecraftApp::GetTPD(int iConfig,PBYTE *ppbData,DWORD *pdwBytes) // #ifndef _CONTENT_PACKAGE // // read the local file // File gtsFile( wsFile->c_str() ); -// +// // __int64 fileSize = gtsFile.length(); -// +// // if(fileSize!=0) // { // FileInputStream fis(gtsFile); // byteArray ba((int)fileSize); // fis.read(ba); // fis.close(); -// +// // bRes=StorageManager.WriteTMSFile(iQuadrant,eStorageFacility,(WCHAR *)wsFile->c_str(),ba.data, ba.length); -// +// // } // #endif // return bRes; @@ -5635,7 +5592,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad CMinecraftApp *pClass = (CMinecraftApp *)pParam; // Exit with or without saving // Decline means save in this dialog - if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) + if(result==C4JStorage::EMessage_ResultDecline || result==C4JStorage::EMessage_ResultThirdOption) { if( result==C4JStorage::EMessage_ResultDecline ) // Save { @@ -5647,7 +5604,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad DLCPack * pDLCPack=tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { + { // upsell // get the dlc texture pack @@ -5725,7 +5682,7 @@ int CMinecraftApp::WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStor if(result==C4JStorage::EMessage_ResultAccept) { if(ProfileManager.IsSignedIn(iPad)) - { + { // need to allow downloads here, or the player would need to quit the game to let the download of a texture pack happen. This might affect the network traffic, since the download could take all the bandwidth... XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); @@ -5745,7 +5702,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 //CMinecraftApp* pClass = (CMinecraftApp*)pParam; // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { INT saveOrCheckpointId = 0; @@ -5757,7 +5714,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 DLCPack * pDLCPack=tPack->getDLCPack(); if(!pDLCPack->hasPurchasedFile( DLCManager::e_DLCType_Texture, L"" )) - { + { // upsell // get the dlc texture pack @@ -5792,7 +5749,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 int CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { #if defined(_XBOX_ONE) || defined(__ORBIS__) StorageManager.SetSaveDisabled(false); @@ -5919,7 +5876,7 @@ void CMinecraftApp::InitialiseTips() // Only randomise the content package build #ifdef _CONTENT_PACKAGE - + for(int i=1;inextInt(); @@ -5981,7 +5938,7 @@ UINT CMinecraftApp::GetNextTip() } else { - if(bShowSkinDLCTip && ProfileManager.IsFullVersion()) + if(bShowSkinDLCTip && ProfileManager.IsFullVersion()) { bShowSkinDLCTip=false; if( app.DLCInstallProcessCompleted() ) @@ -6017,7 +5974,7 @@ int CMinecraftApp::GetHTMLFontSize(EHTMLFontSize size) wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shadowColour /*= 0xFFFFFFFF*/) { wstring text(desc); - + wchar_t replacements[64]; // We will also insert line breaks here as couldn't figure out how to get them to come through from strings.resx ! text = replaceAll(text, L"{*B*}", L"
" ); @@ -6106,7 +6063,7 @@ wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shado text = replaceAll(text, L"{*ICON_SHANK_03*}", GetIconReplacement(XZP_ICON_SHANK_03) ); text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_UP*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_UP ) ); text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_DOWN*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_DOWN ) ); - text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_RIGHT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_RIGHT ) ); + text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_RIGHT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_RIGHT ) ); text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}", GetActionReplacement(iPad,MINECRAFT_ACTION_DPAD_LEFT ) ); #if defined _XBOX_ONE || defined __PSVITA__ text = replaceAll(text, L"{*CONTROLLER_VK_START*}", GetVKReplacement(VK_PAD_START ) ); @@ -6122,13 +6079,13 @@ wstring CMinecraftApp::FormatHTMLString(int iPad, const wstring &desc, int shado text = replaceAll(text, L"{*IMAGEROOT*}", imageRoot); #endif // _XBOX - // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered with padding space, which looks no good + // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered with padding space, which looks no good DWORD dwLanguage = XGetLanguage( ); switch(dwLanguage) { - case XC_LANGUAGE_KOREAN: + case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_JAPANESE: - case XC_LANGUAGE_TCHINESE: + case XC_LANGUAGE_TCHINESE: text = replaceAll(text, L" ", L"" ); break; } @@ -6271,7 +6228,7 @@ wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) case VK_PAD_LTHUMB_UPLEFT : case VK_PAD_LTHUMB_UPRIGHT : case VK_PAD_LTHUMB_DOWNRIGHT: - case VK_PAD_LTHUMB_DOWNLEFT : + case VK_PAD_LTHUMB_DOWNLEFT : return app.GetString( IDS_CONTROLLER_LEFT_STICK ); case VK_PAD_RTHUMB_UP : case VK_PAD_RTHUMB_DOWN : @@ -6280,7 +6237,7 @@ wstring CMinecraftApp::GetVKReplacement(unsigned int uiVKey) case VK_PAD_RTHUMB_UPLEFT : case VK_PAD_RTHUMB_UPRIGHT : case VK_PAD_RTHUMB_DOWNRIGHT: - case VK_PAD_RTHUMB_DOWNLEFT : + case VK_PAD_RTHUMB_DOWNLEFT : return app.GetString( IDS_CONTROLLER_RIGHT_STICK ); default: break; @@ -6443,7 +6400,7 @@ HRESULT CMinecraftApp::RegisterMojangData(WCHAR *pXuidName, PlayerUID xuid, WCHA // ignore the names if we don't recognize them if(pXuidName!=NULL) - { + { if( wcscmp( pXuidName, L"XUID_NOTCH" ) == 0 ) { eTempXuid = eXUID_Notch; // might be needed for the apple at some point @@ -6463,7 +6420,7 @@ HRESULT CMinecraftApp::RegisterMojangData(WCHAR *pXuidName, PlayerUID xuid, WCHA pMojangData = new MOJANG_DATA; ZeroMemory(pMojangData,sizeof(MOJANG_DATA)); pMojangData->eXuid=eTempXuid; - + wcsncpy( pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE); wcsncpy( pMojangData->wchCape, pCape, MAX_CAPENAME_SIZE); MojangData[xuid]=pMojangData; @@ -6483,7 +6440,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) // #ifdef _XBOX // if(pType!=NULL) -// { +// { // if(wcscmp(pType,L"XboxOneTransfer")==0) // { // if(iValue>0) @@ -6499,7 +6456,7 @@ HRESULT CMinecraftApp::RegisterConfigValues(WCHAR *pType, int iValue) // { // app.m_uiTransferSlotC=iValue; // } -// +// // } // #endif @@ -6523,18 +6480,18 @@ HRESULT CMinecraftApp::RegisterDLCData(WCHAR *pType, WCHAR *pBannerName, int iGe #ifndef __ORBIS__ // ignore the names if we don't recognize them if(pBannerName!=L"") - { + { wcsncpy_s( pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE); } if(pDataFile[0]!=0) - { + { wcsncpy_s( pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE); } #endif if(pType!=NULL) - { + { if(wcscmp(pType,L"Skin")==0) { pDLCData->eDLCType=e_DLC_SkinPack; @@ -6613,12 +6570,12 @@ HRESULT CMinecraftApp::RegisterDLCData(eDLCContentType eType, WCHAR *pwchBannerN // ignore the names if we don't recognize them if(pwchBannerName!=L"") - { + { wcsncpy_s( pDLCData->wchBanner, pwchBannerName, MAX_BANNERNAME_SIZE); } if(pwchProductName[0]!=0) - { + { pDLCData->wsDisplayName=pwchProductName; } @@ -6665,7 +6622,7 @@ HRESULT CMinecraftApp::RegisterDLCData(char *pchDLCName, unsigned int uiSortInde pDLCData->iConfig = app.GetiConfigFromName(pchDLCName); pDLCData->uiSortIndex=uiSortIndex; - pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); + pDLCData->eDLCType = app.GetDLCTypeFromName(pchDLCName); strcpy(pDLCData->chImageURL,pchImageURL); //bool bIsTrialDLC = app.GetTrialFromName(pchDLCName); @@ -6737,7 +6694,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfo(char *pchDLCName) string tempString=pchDLCName; if(DLCInfo.size()>0) - { + { AUTO_VAR(it, DLCInfo.find(tempString)); if( it == DLCInfo.end() ) @@ -6810,7 +6767,7 @@ bool CMinecraftApp::GetDLCFullOfferIDForPackID(const int iPackID,wstring &Produc { AUTO_VAR(it, DLCTextures_PackID.find(iPackID)); if( it == DLCTextures_PackID.end() ) - { + { return false; } else @@ -6882,7 +6839,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial) { //DLC_INFO *pDLCInfo=NULL; if(DLCInfo_Trial.size()>0) - { + { AUTO_VAR(it, DLCInfo_Trial.find(ullOfferID_Trial)); if( it == DLCInfo_Trial.end() ) @@ -6939,7 +6896,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(WCHAR *pwchProductID) { wstring wsTemp = pwchProductID; if(DLCInfo_Full.size()>0) - { + { AUTO_VAR(it, DLCInfo_Full.find(wsTemp)); if( it == DLCInfo_Full.end() ) @@ -6968,7 +6925,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForProductName(WCHAR *pwchProductName) } ++it; } - + return NULL; } @@ -6979,7 +6936,7 @@ DLC_INFO *CMinecraftApp::GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full) { if(DLCInfo_Full.size()>0) - { + { AUTO_VAR(it, DLCInfo_Full.find(ullOfferID_Full)); if( it == DLCInfo_Full.end() ) @@ -7072,7 +7029,7 @@ int CMinecraftApp::RemoteSaveThreadProc( void* lpParameter ) void CMinecraftApp::ExitGameFromRemoteSave( LPVOID lpParameter ) { int primaryPad = ProfileManager.GetPrimaryPad(); - + UINT uiIDA[3]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; @@ -7085,11 +7042,11 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4 //CScene_Pause* pClass = (CScene_Pause*)pParam; // results switched for this dialog - if(result==C4JStorage::EMessage_ResultDecline) + if(result==C4JStorage::EMessage_ResultDecline) { app.SetAction(iPad,eAppAction_ExitWorld); } - else + else { #ifndef _XBOX // Inform fullscreen progress scene that it's not being cancelled after all @@ -7170,7 +7127,7 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps m_vBannedListA[iPad]->push_back(pBannedListData); if(bWriteToTMS) - { + { DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new CHAR [dwDataBytes]); int iCount=0; @@ -7200,7 +7157,7 @@ bool CMinecraftApp::IsInBannedLevelList(int iPad, PlayerUID xuid, char *pszLevel #ifdef _XBOX_ONE PlayerUID bannedPlayerUID = pData->wchPlayerUID; if(IsEqualXUID (bannedPlayerUID,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) -#else +#else if(IsEqualXUID (pData->xuid,xuid) && (strcmp(pData->pszLevelName,pszLevelName)==0)) #endif { @@ -7215,12 +7172,12 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha { //bool bFound=false; //bool bRes; - + // we will have retrieved the banned level list from TMS, so remove this one from it and write it back to TMS for(AUTO_VAR(it, m_vBannedListA[iPad]->begin()); it != m_vBannedListA[iPad]->end(); ) { PBANNEDLISTDATA pBannedListData = *it; - + if(pBannedListData!=NULL) { #ifdef _XBOX_ONE @@ -7301,7 +7258,7 @@ bool CMinecraftApp::AlreadySeenCreditText(const wstring &wstemp) wstring temp=m_vCreditText.at(i); // if they are the same, break out of the case - if(temp.compare(wstemp)==0) + if(temp.compare(wstemp)==0) { return true; } @@ -7591,7 +7548,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame break; case eGameHostOption_FireSpreads: return (uiHostSettings&GAME_HOST_OPTION_BITMASK_FIRESPREADS); - break; + break; case eGameHostOption_CheatsEnabled: return (uiHostSettings&(GAME_HOST_OPTION_BITMASK_HOSTFLY|GAME_HOST_OPTION_BITMASK_HOSTHUNGER|GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE)); break; @@ -7609,7 +7566,7 @@ unsigned int CMinecraftApp::GetGameHostOption(unsigned int uiHostSettings, eGame break; case eGameHostOption_DisableSaving: return (uiHostSettings&GAME_HOST_OPTION_BITMASK_DISABLESAVE); - break; + break; } return false; @@ -7662,7 +7619,7 @@ unsigned int CMinecraftApp::FromBigEndian(unsigned int uiValue) // Keep it in big endian return uiValue; #else - unsigned int uiReturn = ( ( uiValue >> 24 ) & 0x000000ff ) | + unsigned int uiReturn = ( ( uiValue >> 24 ) & 0x000000ff ) | ( ( uiValue >> 8 ) & 0x0000ff00 ) | ( ( uiValue << 8 ) & 0x00ff0000 ) | ( ( uiValue << 24 ) & 0xff000000 ); @@ -7688,7 +7645,7 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig uiCount+=8; while(uiCounteTerrainFeature==eType) { *pX=pFeatureData->x; *pZ=pFeatureData->z; return true; - } + } } return false; @@ -7978,7 +7935,7 @@ unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, bool bPromo { // promote if(bPromote) - { + { m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin()+iPosition); m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),pCurrent); } @@ -7990,10 +7947,10 @@ unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType, bool bPromo } DLCRequest *pDLCreq = new DLCRequest; - pDLCreq->dwType=m_dwContentTypeA[eType]; + pDLCreq->dwType=m_dwContentTypeA[eType]; pDLCreq->eState=e_DLC_ContentState_Idle; - m_DLCDownloadQueue.push_back(pDLCreq); + m_DLCDownloadQueue.push_back(pDLCreq); m_bAllDLCContentRetrieved=false; LeaveCriticalSection(&csDLCDownloadQueue); @@ -8025,7 +7982,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool { // promote if(bPromote) - { + { m_TMSPPDownloadQueue.erase(m_TMSPPDownloadQueue.begin()+iPosition); m_TMSPPDownloadQueue.insert(m_TMSPPDownloadQueue.begin(),pCurrent); bPromoted=true; @@ -8059,17 +8016,17 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool { // first check if the image is already in the memory textures, since we might be loading some from the Title Update partition if(pDLC->wchDataFile[0]!=0) - { + { //WCHAR *cString = pDLC->wchDataFile; // 4J-PB - shouldn't check this here - let the TMS files override it, so if they are on TMS, we'll take them first //int iIndex = app.GetLocalTMSFileIndex(pDLC->wchDataFile,true); //if(iIndex!=-1) - { + { bool bPresent = app.IsFileInTPD(pDLC->iConfig); if(!bPresent) - { + { // this may already be present in the vector because of a previous trial/full offer bool bAlreadyInQueue=false; @@ -8085,7 +8042,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { TMSPPRequest *pTMSPPreq = new TMSPPRequest; pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; @@ -8097,7 +8054,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool pTMSPPreq->eState=e_TMS_ContentState_Queued; m_bAllTMSContentRetrieved=false; m_TMSPPDownloadQueue.push_back(pTMSPPreq); - } + } } else { @@ -8121,20 +8078,20 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool // is this the right type? if(pDLC->eDLCType==eType) - { + { WCHAR *cString = pDLC->wchBanner; // 4J-PB - shouldn't check this here - let the TMS files override it, so if they are on TMS, we'll take them first - // is the file in the TMS XZP? + // is the file in the TMS XZP? //int iIndex = app.GetLocalTMSFileIndex(cString,true); //if(iIndex!=-1) - { - bool bPresent = app.IsFileInMemoryTextures(cString); + { + bool bPresent = app.IsFileInMemoryTextures(cString); if(!bPresent) // retrieve it from TMSPP - { + { bool bAlreadyInQueue=false; for(AUTO_VAR(it, m_TMSPPDownloadQueue.begin()); it != m_TMSPPDownloadQueue.end(); ++it) { @@ -8148,7 +8105,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { TMSPPRequest *pTMSPPreq = new TMSPPRequest; pTMSPPreq->CallbackFunc=&CMinecraftApp::TMSPPFileReturned; @@ -8161,7 +8118,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool pTMSPPreq->eState=e_TMS_ContentState_Queued; m_bAllTMSContentRetrieved=false; - m_TMSPPDownloadQueue.push_back(pTMSPPreq); + m_TMSPPDownloadQueue.push_back(pTMSPPreq); app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); } } @@ -8185,11 +8142,11 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool //int iIndex = app.GetLocalTMSFileIndex(cString,true); //if(iIndex!=-1) - { + { bool bPresent = app.IsFileInMemoryTextures(cString); - + if(!bPresent) - { + { // this may already be present in the vector because of a previous trial/full offer bool bAlreadyInQueue=false; @@ -8205,7 +8162,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool } if(!bAlreadyInQueue) - { + { //app.DebugPrintf("Adding a request to the TMSPP download queue - %ls\n",pDLC->wchBanner); TMSPPRequest *pTMSPPreq = new TMSPPRequest; ZeroMemory(pTMSPPreq,sizeof(TMSPPRequest)); @@ -8224,7 +8181,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, bool m_bAllTMSContentRetrieved=false; m_TMSPPDownloadQueue.push_back(pTMSPPreq); app.DebugPrintf("===m_TMSPPDownloadQueue Adding %ls, q size is %d\n",pTMSPPreq->wchFilename,m_TMSPPDownloadQueue.size()); - } + } } } } @@ -8331,7 +8288,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto #if defined(_XBOX) || defined(_WINDOWS64) char szFile[MAX_TMSFILENAME_SIZE]; wcstombs(szFile,pCurrent->wchFilename,MAX_TMSFILENAME_SIZE); - + if(strcmp(szFilename,szFile)==0) #elif _XBOX_ONE @@ -8342,15 +8299,15 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto pCurrent->eState=e_TMS_ContentState_Retrieved; if(pFileData!=NULL) - { + { #ifdef _XBOX_ONE - + switch(pCurrent->eType) { case e_DLC_TexturePackData: - { + { // 4J-PB - we need to allocate memory for the file data and copy into it, since the current data is a reference into the blob download memory PBYTE pbData = new BYTE [pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); @@ -8359,17 +8316,17 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto app.DebugPrintf("Got texturepack data\n"); // get the config value for the texture pack int iConfig=app.GetTPConfigVal(pCurrent->wchFilename); - app.AddMemoryTPDFile(iConfig, pbData, pFileData->dwSize); + app.AddMemoryTPDFile(iConfig, pbData, pFileData->dwSize); } break; default: // 4J-PB - check the data is an image if(pFileData->pbData[0]==0x89) - { + { // 4J-PB - we need to allocate memory for the file data and copy into it, since the current data is a reference into the blob download memory PBYTE pbData = new BYTE [pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); - + pClass->m_vTMSPPData.push_back(pbData); app.DebugPrintf("Got image data - %ls\n",pCurrent->wchFilename); app.AddMemoryTextureFile(pCurrent->wchFilename, pbData, pFileData->dwSize); @@ -8385,11 +8342,11 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto switch(pCurrent->eType) { case e_DLC_TexturePackData: - { + { app.DebugPrintf("--- Got texturepack data %ls\n",pCurrent->wchFilename); // get the config value for the texture pack int iConfig=app.GetTPConfigVal(pCurrent->wchFilename); - app.AddMemoryTPDFile(iConfig, pFileData->pbData, pFileData->dwSize); + app.AddMemoryTPDFile(iConfig, pFileData->pbData, pFileData->dwSize); } break; default: @@ -8409,7 +8366,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto } break; } - + } LeaveCriticalSection(&pClass->csTMSPPDownloadQueue); @@ -8653,7 +8610,7 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D for(unsigned int i=0;iAddOrRetrievePart(&SkinBoxA[i]); pvModelPart->push_back(pModelPart); pvSkinBoxes->push_back(&SkinBoxA[i]); @@ -8663,7 +8620,7 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxes) ); - + LeaveCriticalSection( &csAdditionalSkinBoxes ); LeaveCriticalSection( &csAdditionalModelParts ); @@ -8683,7 +8640,7 @@ vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, vect for(AUTO_VAR(it, pvSkinBoxA->begin());it != pvSkinBoxA->end(); ++it) { if(pModel) - { + { ModelPart *pModelPart=pModel->AddOrRetrievePart(*it); pvModelPart->push_back(pModelPart); } @@ -8727,7 +8684,7 @@ vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) pvSkinBoxes = (*it).second; } } - + LeaveCriticalSection( &csAdditionalSkinBoxes ); return pvSkinBoxes; } @@ -8770,16 +8727,16 @@ void CMinecraftApp::SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOve DWORD CMinecraftApp::getSkinIdFromPath(const wstring &skin) { - bool dlcSkin = false; + bool dlcSkin = false; unsigned int skinId = 0; - + if(skin.size() >= 14) { dlcSkin = skin.substr(0,3).compare(L"dlc") == 0; wstring skinValue = skin.substr(7,skin.size()); skinValue = skinValue.substr(0,skinValue.find_first_of(L'.')); - + std::wstringstream ss; // 4J Stu - dlc skins are numbered using decimal to make it easier for artists/people to number manually // Everything else is numbered using hex @@ -8803,7 +8760,7 @@ wstring CMinecraftApp::getSkinPathFromId(DWORD skinId) { // 4J Stu - DLC skins are numbered using decimal rather than hex to make it easier to number manually swprintf(chars, 256, L"dlcskin%08d.png", GET_DLC_SKIN_ID_FROM_BITMASK(skinId)); - + } else { @@ -8828,7 +8785,7 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E if(result!=C4JStorage::EMessage_Cancelled) { if(app.GetRequiredTexturePackID()!=0) - { + { // we need to enable background downloading for the DLC XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_ALWAYS_ALLOW); @@ -8846,7 +8803,7 @@ int CMinecraftApp::TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::E DLC_INFO *pDLCInfo=app.GetDLCInfoForFullOfferID(ullOfferID_Full); ullIndexA[0]=pDLCInfo->ullOfferID_Trial; StorageManager.InstallOffer(1,ullIndexA,NULL,NULL); - } + } } } #endif @@ -8889,39 +8846,39 @@ byteArray CMinecraftApp::getArchiveFile(const wstring &filename) // DLC #if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__) -int CMinecraftApp::GetDLCInfoCount() -{ +int CMinecraftApp::GetDLCInfoCount() +{ return (int)DLCInfo.size(); } #elif defined _XBOX_ONE -int CMinecraftApp::GetDLCInfoTrialOffersCount() -{ +int CMinecraftApp::GetDLCInfoTrialOffersCount() +{ return 0; } -int CMinecraftApp::GetDLCInfoFullOffersCount() -{ +int CMinecraftApp::GetDLCInfoFullOffersCount() +{ return (int)DLCInfo_Full.size(); } #else -int CMinecraftApp::GetDLCInfoTrialOffersCount() -{ +int CMinecraftApp::GetDLCInfoTrialOffersCount() +{ return (int)DLCInfo_Trial.size(); } -int CMinecraftApp::GetDLCInfoFullOffersCount() -{ +int CMinecraftApp::GetDLCInfoFullOffersCount() +{ return (int)DLCInfo_Full.size(); } #endif -int CMinecraftApp::GetDLCInfoTexturesOffersCount() -{ +int CMinecraftApp::GetDLCInfoTexturesOffersCount() +{ return (int)DLCTextures_PackID.size(); } // AUTOSAVE -void CMinecraftApp::SetAutosaveTimerTime(void) +void CMinecraftApp::SetAutosaveTimerTime(void) { #if defined(_XBOX_ONE) || defined(__ORBIS__) m_uiAutosaveTimer= GetTickCount()+1000*60; @@ -8930,23 +8887,23 @@ void CMinecraftApp::SetAutosaveTimerTime(void) #endif }// value x 15 to get mins, x60 for secs -bool CMinecraftApp::AutosaveDue(void) -{ +bool CMinecraftApp::AutosaveDue(void) +{ return (GetTickCount()>m_uiAutosaveTimer); } -unsigned int CMinecraftApp::SecondsToAutosave() -{ - return (m_uiAutosaveTimer - GetTickCount() ) / 1000; +unsigned int CMinecraftApp::SecondsToAutosave() +{ + return (m_uiAutosaveTimer - GetTickCount() ) / 1000; } -void CMinecraftApp::SetTrialTimerStart(void) +void CMinecraftApp::SetTrialTimerStart(void) { m_fTrialTimerStart=m_Time.fAppTime; mfTrialPausedTime=0.0f; } -float CMinecraftApp::getTrialTimer(void) -{ +float CMinecraftApp::getTrialTimer(void) +{ return m_Time.fAppTime-m_fTrialTimerStart-mfTrialPausedTime; } @@ -8977,7 +8934,7 @@ bool CMinecraftApp::IsLocalMultiplayerAvailable() //#else // for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) // { - // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) + // if( (i!=userIndex) && (InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i)) ) // { // iOtherConnectedControllers++; // } @@ -8991,7 +8948,7 @@ bool CMinecraftApp::IsLocalMultiplayerAvailable() void CMinecraftApp::getLocale(vector &vecWstrLocales) { vector locales; - + DWORD dwSystemLanguage = XGetLanguage( ); // 4J-PB - restrict the 360 language until we're ready to have them in @@ -9052,7 +9009,7 @@ void CMinecraftApp::getLocale(vector &vecWstrLocales) case XC_LOCALE_UNITED_ARAB_EMIRATES: case XC_LOCALE_GREAT_BRITAIN: locales.push_back(eMCLang_enGB); - break; + break; default: //XC_LOCALE_UNITED_STATES break; } @@ -9149,7 +9106,7 @@ void CMinecraftApp::getLocale(vector &vecWstrLocales) break; case XC_LANGUAGE_BNORWEGIAN : locales.push_back(eMCLang_nbNO); - locales.push_back(eMCLang_noNO); + locales.push_back(eMCLang_noNO); locales.push_back(eMCLang_nnNO); break; case XC_LANGUAGE_DUTCH : @@ -9292,7 +9249,7 @@ void CMinecraftApp::LocaleAndLanguageInit() m_localeA[eMCLang_esCO] =L"es-CO"; m_localeA[eMCLang_esUS] =L"es-US"; m_localeA[eMCLang_svSE] =L"sv-SE"; - + m_localeA[eMCLang_csCZ] =L"cs-CZ"; m_localeA[eMCLang_elGR] =L"el-GR"; m_localeA[eMCLang_nnNO] =L"nn-NO"; diff --git a/Minecraft.Client/Build/Common/DLC/DLCManager.cpp b/Minecraft.Client/Build/Common/DLC/DLCManager.cpp index fe77821df..c30eab3ca 100644 --- a/Minecraft.Client/Build/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Build/Common/DLC/DLCManager.cpp @@ -7,6 +7,25 @@ #include "../../../Minecraft.h" #include "../../../Textures/Packs/TexturePackRepository.h" +#ifdef __linux__ +#include +static const size_t DLC_WCHAR_BINARY = 2; +static wstring dlc_read_wstring(const void *data) +{ + const uint16_t *p = (const uint16_t *)data; + wstring s; + while (*p) s += (wchar_t)*p++; + return s; +} +#define DLC_WSTRING(ptr) dlc_read_wstring(ptr) +#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BINARY) +#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BINARY) +#else +#define DLC_WSTRING(ptr) wstring((WCHAR *)(ptr)) +#define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + sizeof(WCHAR) * (n)) +#define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + sizeof(WCHAR) * (n)) +#endif + const WCHAR *DLCManager::wchTypeNamesA[]= { L"DISPLAYNAME", @@ -282,6 +301,7 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) } } + // gotta fix this someday if(corruptDLCCount > 0 && showMessage) { UINT uiIDA[1]; @@ -398,13 +418,13 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD for(unsigned int i=0;iwchData); + wstring parameterName = DLC_WSTRING(pParams->wchData); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); if( type != DLCManager::e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } - uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR)); + uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; } //ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); @@ -416,7 +436,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD DWORD dwTemp=uiCurrentByte; for(unsigned int i=0;idwWchCount*sizeof(WCHAR); + dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount); pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; } PBYTE pbTemp=((PBYTE )pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount; @@ -435,7 +455,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD } else if(type != e_DLCType_PackConfig) { - dlcFile = pack->addFile(type,(WCHAR *)pFile->wchFile); + dlcFile = pack->addFile(type, DLC_WSTRING(pFile->wchFile)); } // Params @@ -452,15 +472,15 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD { if(type == e_DLCType_PackConfig) { - pack->addParameter(it->second,(WCHAR *)pParams->wchData); + pack->addParameter(it->second, DLC_WSTRING(pParams->wchData)); } else { - if(dlcFile != NULL) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData); - else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData); + if(dlcFile != NULL) dlcFile->addParameter(it->second, DLC_WSTRING(pParams->wchData)); + else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, DLC_WSTRING(pParams->wchData)); } } - pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); + pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; } //pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM); @@ -495,7 +515,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD switch(pFile->dwType) { case DLCManager::e_DLCType_Skin: - app.vSkinNames.push_back((WCHAR *)pFile->wchFile); + app.vSkinNames.push_back(DLC_WSTRING(pFile->wchFile)); break; } @@ -504,7 +524,7 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD // Move the pointer to the start of the next files data; pbTemp+=pFile->uiFileSize; - uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR); + uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount); pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; } @@ -603,13 +623,13 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) for(unsigned int i=0;iwchData); + wstring parameterName = DLC_WSTRING(pParams->wchData); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); if( type != DLCManager::e_DLCParamType_Invalid ) { parameterMapping[pParams->dwType] = type; } - uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR)); + uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; } @@ -620,7 +640,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) DWORD dwTemp=uiCurrentByte; for(unsigned int i=0;idwWchCount*sizeof(WCHAR); + dwTemp+=DLC_DETAIL_ADV(pFile->dwWchCount); pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; } PBYTE pbTemp=((PBYTE )pFile); @@ -644,7 +664,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { if(it->second==e_DLCParamType_PackId) { - wstring wsTemp=(WCHAR *)pParams->wchData; + wstring wsTemp = DLC_WSTRING(pParams->wchData); std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually ss << std::dec << wsTemp.c_str(); @@ -654,14 +674,14 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) } } } - pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); + pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount); pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; } if(bPackIDSet) break; // Move the pointer to the start of the next files data; pbTemp+=pFile->uiFileSize; - uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR); + uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount); pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; } diff --git a/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp b/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp index c8a365c94..955d0d718 100644 --- a/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp +++ b/Minecraft.Client/Build/Common/UI/UIControl_EnchantmentButton.cpp @@ -1,4 +1,6 @@ #include "../../../../Minecraft.World/Build/stdafx.h" +#include +#include #include "UI.h" #include "UIControl_EnchantmentButton.h" #include "../../../../Minecraft.World/Headers/net.minecraft.world.inventory.h" diff --git a/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp b/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp index 07419543e..3abdea101 100644 --- a/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp +++ b/Minecraft.Client/Build/Common/UI/UIControl_Touch.cpp @@ -18,7 +18,7 @@ void UIControl_Touch::init(int iId) { m_id = iId; - // 4J-TomK - add this touch control to the vita touch box list +#if !defined(__linux__) switch(m_parentScene->GetParentLayer()->m_iLayer) { case eUILayer_Error: @@ -28,6 +28,7 @@ void UIControl_Touch::init(int iId) ui.TouchBoxAdd(this,m_parentScene); break; } +#endif } void UIControl_Touch::ReInit() diff --git a/Minecraft.Client/Build/Common/UI/UIController.cpp b/Minecraft.Client/Build/Common/UI/UIController.cpp index df8d64680..f5ed2c407 100644 --- a/Minecraft.Client/Build/Common/UI/UIController.cpp +++ b/Minecraft.Client/Build/Common/UI/UIController.cpp @@ -1285,7 +1285,6 @@ void UIController::setupCustomDrawGameStateAndMatrices(UIScene *scene, CustomDra void UIController::endCustomDrawGameState() { #if defined(__ORBIS__) || defined(__linux__) - // TO BE IMPLEMENTED RenderManager.Clear(GL_DEPTH_BUFFER_BIT); #else RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &m_customRenderingClearRect); @@ -2506,7 +2505,6 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT if (message == -1) { #if defined(_XBOX_ONE) || defined(_WINDOWS64) || defined(__linux__) - // IDS_CONTENT_RESTRICTION doesn't exist on XB1 message = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_CREATE; #else message = IDS_CONTENT_RESTRICTION; diff --git a/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp index e4c10af20..e6d544918 100644 --- a/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Build/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -190,7 +190,9 @@ void UIScene_InGameSaveManagementMenu::tick() { if(m_bUpdateSaveSize) { +#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.selectSave(m_iSaveListIndex); +#endif m_bUpdateSaveSize = false; } @@ -200,7 +202,9 @@ void UIScene_InGameSaveManagementMenu::tick() m_pSaveDetails=StorageManager.ReturnSavesInfo(); if(m_pSaveDetails!=NULL) { +#if defined(_XBOX_ONE) || defined(__ORBIS__) m_spaceIndicatorSaves.reset(); +#endif m_bSavesDisplayed=true; @@ -286,6 +290,8 @@ void UIScene_InGameSaveManagementMenu::tick() (wchar_t *)u16Message, // destination buffer MAX_SAVEFILENAME_LENGTH // size of destination buffer, in WCHAR's ); +#elif defined(__linux__) + mbstowcs((wchar_t *)u16Message, m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename, MAX_SAVEFILENAME_LENGTH); #else #ifdef __PS3 size_t srcmax,dstmax; diff --git a/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp b/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp index 857426f18..a16729007 100644 --- a/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp +++ b/Minecraft.Client/Build/Common/UI/UIScene_Intro.cpp @@ -30,6 +30,8 @@ UIScene_Intro::UIScene_Intro(int iPad, void *initData, UILayer *parentLayer) : U int platformIdx = 4; #elif defined(__PSVITA__) int platformIdx = 5; +#elif defined(__linux__) + int platformIdx = 0; #endif IggyDataValue result; diff --git a/Minecraft.Client/Build/Extrax64Stubs.cpp b/Minecraft.Client/Build/Extrax64Stubs.cpp index e17b2f615..ea7c6394e 100644 --- a/Minecraft.Client/Build/Extrax64Stubs.cpp +++ b/Minecraft.Client/Build/Extrax64Stubs.cpp @@ -256,7 +256,7 @@ HRESULT XMemDecompress( XMEMDECOMPRESSION_CONTEXT Context, VOID *pDestination, SIZE_T *pDestSize, - CONST VOID *pSource, + VOID *pSource, SIZE_T SrcSize ) { @@ -287,7 +287,7 @@ HRESULT XMemCompress( XMEMCOMPRESSION_CONTEXT Context, VOID *pDestination, SIZE_T *pDestSize, - CONST VOID *pSource, + VOID *pSource, SIZE_T SrcSize ) { diff --git a/Minecraft.Client/Build/stdafx.h b/Minecraft.Client/Build/stdafx.h index f7ccf3faa..41f8edbdd 100644 --- a/Minecraft.Client/Build/stdafx.h +++ b/Minecraft.Client/Build/stdafx.h @@ -188,11 +188,10 @@ typedef XUID GameSessionUID; #include "../Platform/Windows64/4JLibs/inc/4J_Render.h" #include "../Platform/Windows64/4JLibs/inc/4J_Storage.h" #elif defined __linux__ - // draw the rest of the owl - #include "../Platform/Windows64/4JLibs/inc/4J_Input.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Profile.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Render.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Storage.h" + #include "../../4J.Input/4J_Input.h" + #include "../../4J.Profile/4J_Profile.h" + #include "../../4J.Render/4J_Render.h" + #include "../../4J.Storage/4J_Storage.h" #elif defined __PSVITA__ #include "../Platform/PSVita/4JLibs/inc/4J_Input.h" #include "../Platform/PSVita/4JLibs/inc/4J_Profile.h" diff --git a/Minecraft.Client/Build/stubs.cpp b/Minecraft.Client/Build/stubs.cpp index 0c7e680a3..ad16cc431 100644 --- a/Minecraft.Client/Build/stubs.cpp +++ b/Minecraft.Client/Build/stubs.cpp @@ -1,5 +1,7 @@ #include "stdafx.h" +#ifndef __linux__ + void glReadPixels(int,int, int, int, int, int, ByteBuffer *) { } @@ -116,4 +118,6 @@ DWORD XCamSetView( ) { return 0; } XCAMDEVICESTATE XCamGetStatus() { return XCAMDEVICESTATE_DISCONNECTED; } +#endif + #endif \ No newline at end of file diff --git a/Minecraft.Client/Build/stubs.h b/Minecraft.Client/Build/stubs.h index f9196e206..dcb411079 100644 --- a/Minecraft.Client/Build/stubs.h +++ b/Minecraft.Client/Build/stubs.h @@ -1,6 +1,41 @@ #pragma once +#ifdef __linux__ +#include +#include +#undef GL_SMOOTH +#undef GL_FLAT +static const int GL_SMOOTH = 0x1D01; +static const int GL_FLAT = 0x1D00; + +class FloatBuffer; +class IntBuffer; +class ByteBuffer; + +void glGenTextures(IntBuffer *); +int glGenTextures(); +void glDeleteTextures(IntBuffer *); +void glDeleteTextures(int); +void glLight(int, int, FloatBuffer *); +void glLightModel(int, FloatBuffer *); +void glGetFloat(int, FloatBuffer *); +void glTexGen(int, int, FloatBuffer *); +void glFog(int, FloatBuffer *); +void glTexCoordPointer(int, int, FloatBuffer *); +void glNormalPointer(int, ByteBuffer *); +void glColorPointer(int, bool, int, ByteBuffer *); +void glVertexPointer(int, int, FloatBuffer *); +void glEndList(int); +void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer *); +void glCallLists(IntBuffer *); +void glGenQueriesARB(IntBuffer *); +void glBeginQueryARB(int, int); +void glEndQueryARB(int); +void glGetQueryObjectuARB(int, int, IntBuffer *); +void glReadPixels(int, int, int, int, int, int, ByteBuffer *); + +#else const int GL_BYTE = 0; const int GL_FLOAT = 0; @@ -115,10 +150,32 @@ void glFog(int,FloatBuffer *); void glColorMaterial(int,int); void glMultiTexCoord2f(int, float, float); -//1.8.2 void glClientActiveTexture(int); void glActiveTexture(int); +#endif + +#ifdef __linux__ +class GL11 +{ +public: + static const int GL_SMOOTH = 0x1D01; + static const int GL_FLAT = 0x1D00; + static void glShadeModel(int mode) { ::glShadeModel(mode); } +}; + +#undef GL_ARRAY_BUFFER_ARB +#undef GL_STREAM_DRAW_ARB +class ARBVertexBufferObject +{ +public: + static const int GL_ARRAY_BUFFER_ARB = 0x8892; + static const int GL_STREAM_DRAW_ARB = 0x88E0; + static void glBindBufferARB(int, int) {} + static void glBufferDataARB(int, ByteBuffer *, int) {} + static void glGenBuffersARB(IntBuffer *) {} +}; +#else class GL11 { public: @@ -136,6 +193,7 @@ public: static void glBufferDataARB(int, ByteBuffer *, int) {} static void glGenBuffersARB(IntBuffer *) {} }; +#endif class Level; diff --git a/Minecraft.Client/Platform/DurangoMedia/loc/strings.h b/Minecraft.Client/Platform/DurangoMedia/loc/strings.h index 65759e893..0cce344bd 100644 --- a/Minecraft.Client/Platform/DurangoMedia/loc/strings.h +++ b/Minecraft.Client/Platform/DurangoMedia/loc/strings.h @@ -1955,3 +1955,4 @@ #define IDS_YOU_DIED 1953 #define IDS_YOU_HAVE 1954 #define IDS_ZOMBIE 1955 +// gone cuz previous implementation is better diff --git a/Minecraft.Client/Platform/Linux/LinuxGL.cpp b/Minecraft.Client/Platform/Linux/LinuxGL.cpp new file mode 100644 index 000000000..d24f71947 --- /dev/null +++ b/Minecraft.Client/Platform/Linux/LinuxGL.cpp @@ -0,0 +1,159 @@ +#ifdef __linux__ + +#include +#include +#include +#include +#include "../../Minecraft.World/IntBuffer.h" +#include "../../Minecraft.World/FloatBuffer.h" +#include "../../Minecraft.World/ByteBuffer.h" + +int glGenTextures() +{ + GLuint id = 0; + ::glGenTextures(1, &id); + return (int)id; +} + +void glGenTextures(IntBuffer *buf) +{ + GLuint id = 0; + ::glGenTextures(1, &id); + buf->put((int)id); + buf->flip(); +} + +void glDeleteTextures(int id) +{ + GLuint uid = (GLuint)id; + ::glDeleteTextures(1, &uid); +} + +void glDeleteTextures(IntBuffer *buf) +{ + int id = buf->get(0); + GLuint uid = (GLuint)id; + ::glDeleteTextures(1, &uid); +} + +void glLight(int light, int pname, FloatBuffer *params) +{ + ::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer()); +} + +void glLightModel(int pname, FloatBuffer *params) +{ + ::glLightModelfv((GLenum)pname, params->_getDataPointer()); +} + +void glGetFloat(int pname, FloatBuffer *params) +{ + ::glGetFloatv((GLenum)pname, params->_getDataPointer()); +} + +void glTexGen(int coord, int pname, FloatBuffer *params) +{ + ::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer()); +} + +void glFog(int pname, FloatBuffer *params) +{ + ::glFogfv((GLenum)pname, params->_getDataPointer()); +} + +void glTexCoordPointer(int size, int type, FloatBuffer *pointer) +{ + ::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer()); +} + +void glNormalPointer(int type, ByteBuffer *pointer) +{ + ::glNormalPointer((GLenum)type, 0, pointer->getBuffer()); +} + +void glColorPointer(int size, bool normalized, int stride, ByteBuffer *pointer) +{ + (void)normalized; + ::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer()); +} + +void glVertexPointer(int size, int type, FloatBuffer *pointer) +{ + ::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer()); +} + +void glEndList(int) +{ + ::glEndList(); +} + +void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer *pixels) +{ + void *data = pixels ? pixels->getBuffer() : nullptr; + ::glTexImage2D((GLenum)target, level, internalformat, width, height, border, (GLenum)format, (GLenum)type, data); +} + +void glCallLists(IntBuffer *lists) +{ + int count = lists->limit() - lists->position(); + ::glCallLists(count, GL_INT, lists->getBuffer()); +} + +static PFNGLGENQUERIESARBPROC _glGenQueriesARB = nullptr; +static PFNGLBEGINQUERYARBPROC _glBeginQueryARB = nullptr; +static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr; +static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr; +static bool _queriesInitialized = false; + +static void initQueryFuncs() +{ + if (_queriesInitialized) return; + _queriesInitialized = true; + _glGenQueriesARB = (PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB"); + _glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB"); + _glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB"); + _glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(RTLD_DEFAULT, "glGetQueryObjectuivARB"); +} + +void glGenQueriesARB(IntBuffer *buf) +{ + initQueryFuncs(); + if (_glGenQueriesARB) + { + GLuint id = 0; + _glGenQueriesARB(1, &id); + buf->put((int)id); + buf->flip(); + } +} + +void glBeginQueryARB(int target, int id) +{ + initQueryFuncs(); + if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id); +} + +void glEndQueryARB(int target) +{ + initQueryFuncs(); + if (_glEndQueryARB) _glEndQueryARB((GLenum)target); +} + +void glGetQueryObjectuARB(int id, int pname, IntBuffer *params) +{ + initQueryFuncs(); + if (_glGetQueryObjectuivARB) + { + GLuint val = 0; + _glGetQueryObjectuivARB((GLuint)id, (GLenum)pname, &val); + params->put((int)val); + params->flip(); + } +} + +void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer *pixels) +{ + ::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type, pixels->getBuffer()); +} + +#endif diff --git a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h index 0d5c41486..998c7b394 100644 --- a/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h +++ b/Minecraft.Client/Platform/Linux/Stubs/winapi_stubs.h @@ -4,6 +4,7 @@ #pragma once #include +#include #define TRUE true #define FALSE false @@ -413,12 +414,27 @@ static inline HANDLE CreateFileA(const char *lpFileName, DWORD dwDesiredAccess, return fd == -1 ? INVALID_HANDLE_VALUE : (HANDLE)(intptr_t)fd; } +static inline HANDLE CreateFileW(const wchar_t *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + char narrowBuf[1024]; + wcstombs(narrowBuf, lpFileName, sizeof(narrowBuf)); + narrowBuf[sizeof(narrowBuf) - 1] = '\0'; + return CreateFileA(narrowBuf, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); +} + static inline HANDLE CreateFile(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } +static inline HANDLE CreateFile(const wchar_t *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, + void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) +{ + return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); +} + static inline BOOL CloseHandle(HANDLE hObject) { if (hObject == INVALID_HANDLE_VALUE) return FALSE; @@ -766,6 +782,198 @@ static inline HANDLE CreateEvent(int manual_reset, int initial_state) { return (HANDLE)ev; } +static inline HANDLE CreateEvent(void*, BOOL manual_reset, BOOL initial_state, void*) { + return CreateEvent(manual_reset, initial_state); +} + +static inline BOOL SetEvent(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return FALSE; + pthread_mutex_lock(&ev->mutex); + ev->signaled = 1; + if (ev->manual_reset) pthread_cond_broadcast(&ev->cond); + else pthread_cond_signal(&ev->cond); + pthread_mutex_unlock(&ev->mutex); + return TRUE; +} + +static inline BOOL ResetEvent(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return FALSE; + pthread_mutex_lock(&ev->mutex); + ev->signaled = 0; + pthread_mutex_unlock(&ev->mutex); + return TRUE; +} + +#define WAIT_OBJECT_0 0 +#define WAIT_TIMEOUT 258 +#define WAIT_FAILED ((DWORD)0xFFFFFFFF) +#define INFINITE 0xFFFFFFFF + +static inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) { + Event* ev = (Event*)hHandle; + if (!ev) return WAIT_FAILED; + pthread_mutex_lock(&ev->mutex); + if (dwMilliseconds == INFINITE) { + while (!ev->signaled) pthread_cond_wait(&ev->cond, &ev->mutex); + } else if (dwMilliseconds > 0) { + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += dwMilliseconds / 1000; + ts.tv_nsec += (dwMilliseconds % 1000) * 1000000; + if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; } + while (!ev->signaled) { + if (pthread_cond_timedwait(&ev->cond, &ev->mutex, &ts) != 0) { + pthread_mutex_unlock(&ev->mutex); + return WAIT_TIMEOUT; + } + } + } else { + if (!ev->signaled) { pthread_mutex_unlock(&ev->mutex); return WAIT_TIMEOUT; } + } + if (!ev->manual_reset) ev->signaled = 0; + pthread_mutex_unlock(&ev->mutex); + return WAIT_OBJECT_0; +} + +static inline DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) { + if (bWaitAll) { + for (DWORD i = 0; i < nCount; i++) WaitForSingleObject(lpHandles[i], dwMilliseconds); + return WAIT_OBJECT_0; + } + for (int pass = 0; pass < 1000; pass++) { + for (DWORD i = 0; i < nCount; i++) { + if (WaitForSingleObject(lpHandles[i], 0) == WAIT_OBJECT_0) return WAIT_OBJECT_0 + i; + } + usleep(1000); + } + return WAIT_TIMEOUT; +} + +static inline void CloseHandle_Event(HANDLE hEvent) { + Event* ev = (Event*)hEvent; + if (!ev) return; + pthread_mutex_destroy(&ev->mutex); + pthread_cond_destroy(&ev->cond); + free(ev); +} + +#define STILL_ACTIVE 259 +#define CREATE_SUSPENDED 0x00000004 +#define THREAD_PRIORITY_LOWEST (-2) +#define THREAD_PRIORITY_BELOW_NORMAL (-1) +#define THREAD_PRIORITY_NORMAL 0 +#define THREAD_PRIORITY_ABOVE_NORMAL 1 +#define THREAD_PRIORITY_HIGHEST 2 +#define THREAD_PRIORITY_TIME_CRITICAL 15 + +typedef DWORD (*LPTHREAD_START_ROUTINE)(void*); + +struct LinuxThread { + pthread_t thread; + LPTHREAD_START_ROUTINE func; + void* param; + DWORD threadId; + DWORD exitCode; + int suspended; + pthread_mutex_t suspendMutex; + pthread_cond_t suspendCond; +}; + +static inline void* _linux_thread_entry(void* arg) { + LinuxThread* lt = (LinuxThread*)arg; + pthread_mutex_lock(<->suspendMutex); + while (lt->suspended) pthread_cond_wait(<->suspendCond, <->suspendMutex); + pthread_mutex_unlock(<->suspendMutex); + lt->exitCode = lt->func(lt->param); + return NULL; +} + +static DWORD g_nextThreadId = 1000; + +static inline HANDLE CreateThread(void*, SIZE_T stackSize, LPTHREAD_START_ROUTINE lpStartAddress, void* lpParameter, DWORD dwCreationFlags, DWORD* lpThreadId) { + LinuxThread* lt = (LinuxThread*)calloc(1, sizeof(LinuxThread)); + lt->func = lpStartAddress; + lt->param = lpParameter; + lt->exitCode = STILL_ACTIVE; + lt->suspended = (dwCreationFlags & CREATE_SUSPENDED) ? 1 : 0; + lt->threadId = __sync_fetch_and_add(&g_nextThreadId, 1); + pthread_mutex_init(<->suspendMutex, NULL); + pthread_cond_init(<->suspendCond, NULL); + if (lpThreadId) *lpThreadId = lt->threadId; + pthread_attr_t attr; + pthread_attr_init(&attr); + if (stackSize > 0) pthread_attr_setstacksize(&attr, stackSize); + pthread_create(<->thread, &attr, _linux_thread_entry, lt); + pthread_attr_destroy(&attr); + return (HANDLE)lt; +} + +static inline DWORD ResumeThread(HANDLE hThread) { + LinuxThread* lt = (LinuxThread*)hThread; + if (!lt) return (DWORD)-1; + pthread_mutex_lock(<->suspendMutex); + lt->suspended = 0; + pthread_cond_signal(<->suspendCond); + pthread_mutex_unlock(<->suspendMutex); + return 0; +} + +static inline BOOL SetThreadPriority(HANDLE hThread, int nPriority) { + (void)hThread; (void)nPriority; + return TRUE; +} + +static inline BOOL GetExitCodeThread(HANDLE hThread, DWORD* lpExitCode) { + LinuxThread* lt = (LinuxThread*)hThread; + if (!lt || !lpExitCode) return FALSE; + *lpExitCode = lt->exitCode; + return TRUE; +} + +static inline DWORD GetCurrentThreadId() { + return (DWORD)(unsigned long)pthread_self(); +} + +static inline HANDLE GetCurrentThread() { + return (HANDLE)(unsigned long)pthread_self(); +} + +template +static inline int sprintf_s(char (&buf)[N], const char* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vsnprintf(buf, N, fmt, args); + va_end(args); + return ret; +} + +static inline int sprintf_s(char* buf, size_t sz, const char* fmt, ...) { + va_list args; + va_start(args, fmt); // fucking horrid + int ret = vsnprintf(buf, sz, fmt, args); + va_end(args); + return ret; +} + +template +static inline int swprintf_s(wchar_t (&buf)[N], const wchar_t* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vswprintf(buf, N, fmt, args); + va_end(args); + return ret; +} + +static inline int swprintf_s(wchar_t* buf, size_t sz, const wchar_t* fmt, ...) { + va_list args; + va_start(args, fmt); + int ret = vswprintf(buf, sz, fmt, args); + va_end(args); + return ret; +} + static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; } static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { @@ -776,5 +984,11 @@ static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType assert(0 && "FIXME: implement VirtualFree"); } +#define swscanf_s swscanf +#define sscanf_s sscanf +#define _wcsicmp wcscasecmp +#define _stricmp strcasecmp +#define _strnicmp strncasecmp +#define _wcsnicmp wcsncasecmp #endif // WINAPISTUBS_H diff --git a/Minecraft.Client/Platform/Linux/Stubs/xbox_stubs.h b/Minecraft.Client/Platform/Linux/Stubs/xbox_stubs.h index f245d9b50..a5bfca2b9 100644 --- a/Minecraft.Client/Platform/Linux/Stubs/xbox_stubs.h +++ b/Minecraft.Client/Platform/Linux/Stubs/xbox_stubs.h @@ -157,9 +157,6 @@ FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {} FORCEINLINE const char *XBX_GetLanguageString() { return ""; } FORCEINLINE bool XBX_IsLocalized() { return false; } -// #define XCONTENT_MAX_DISPLAYNAME_LENGTH 128 -// #define XCONTENT_MAX_FILENAME_LENGTH 42 - #define XBX_INVALID_STORAGE_ID ((DWORD) -1) #define XBX_STORAGE_DECLINED ((DWORD) -2) diff --git a/Minecraft.Client/Platform/Linux/linux_game_stubs.cpp b/Minecraft.Client/Platform/Linux/linux_game_stubs.cpp new file mode 100644 index 000000000..3844e1deb --- /dev/null +++ b/Minecraft.Client/Platform/Linux/linux_game_stubs.cpp @@ -0,0 +1,44 @@ +#ifdef __linux__ + +#include +#include +#include +#include + +#include "../stubs.h" +#include "../Common/Consoles_App.h" + +void Display::update() {} + +int CMinecraftApp::GetTPConfigVal(WCHAR* pwchDataFile) { return 0; } + +#include "../../Minecraft.World/x64headers/extraX64.h" + +void PIXSetMarkerDeprecated(int a, const char* b, ...) {} + +#include "../Xbox/Network/NetworkPlayerXbox.h" + +NetworkPlayerXbox::NetworkPlayerXbox(IQNetPlayer* p) : m_qnetPlayer(p), m_pSocket(nullptr) {} +IQNetPlayer* NetworkPlayerXbox::GetQNetPlayer() { return m_qnetPlayer; } +unsigned char NetworkPlayerXbox::GetSmallId() { return 0; } +void NetworkPlayerXbox::SendData(INetworkPlayer*, const void*, int, bool) {} +bool NetworkPlayerXbox::IsSameSystem(INetworkPlayer*) { return false; } +int NetworkPlayerXbox::GetSendQueueSizeBytes(INetworkPlayer*, bool) { return 0; } +int NetworkPlayerXbox::GetSendQueueSizeMessages(INetworkPlayer*, bool) { return 0; } +int NetworkPlayerXbox::GetCurrentRtt() { return 0; } +bool NetworkPlayerXbox::IsHost() { return false; } +bool NetworkPlayerXbox::IsGuest() { return false; } +bool NetworkPlayerXbox::IsLocal() { return true; } +int NetworkPlayerXbox::GetSessionIndex() { return 0; } +bool NetworkPlayerXbox::IsTalking() { return false; } +bool NetworkPlayerXbox::IsMutedByLocalUser(int) { return false; } +bool NetworkPlayerXbox::HasVoice() { return false; } +bool NetworkPlayerXbox::HasCamera() { return false; } +int NetworkPlayerXbox::GetUserIndex() { return 0; } +void NetworkPlayerXbox::SetSocket(Socket* s) { m_pSocket = s; } +Socket* NetworkPlayerXbox::GetSocket() { return m_pSocket; } +const wchar_t* NetworkPlayerXbox::GetOnlineName() { return L"Player"; } +std::wstring NetworkPlayerXbox::GetDisplayName() { return L"Player"; } +PlayerUID NetworkPlayerXbox::GetUID() { return PlayerUID(); } + +#endif diff --git a/Minecraft.Client/Rendering/glWrapper.cpp b/Minecraft.Client/Rendering/glWrapper.cpp index d38274911..6134b7d45 100644 --- a/Minecraft.Client/Rendering/glWrapper.cpp +++ b/Minecraft.Client/Rendering/glWrapper.cpp @@ -1,4 +1,7 @@ #include "../Build/stdafx.h" + +#ifndef __linux__ + #include "../../Minecraft.World/IO/Streams/FloatBuffer.h" #include "../../Minecraft.World/IO/Streams/IntBuffer.h" #include "../../Minecraft.World/IO/Streams/ByteBuffer.h" @@ -386,4 +389,7 @@ void glTexGen(int coord, int mode, FloatBuffer *vec) void glCullFace(int dir) { RenderManager.StateSetFaceCullCW( dir == GL_BACK); -} \ No newline at end of file +} + +#endif +#endif \ No newline at end of file diff --git a/Minecraft.Client/Textures/Texture.cpp b/Minecraft.Client/Textures/Texture.cpp index c8dd00936..ce1a85b74 100644 --- a/Minecraft.Client/Textures/Texture.cpp +++ b/Minecraft.Client/Textures/Texture.cpp @@ -133,7 +133,7 @@ void Texture::_init(const wstring &name, int mode, int width, int height, int de for(unsigned int level = 1; level < m_iMipLevels; ++level) { int ww = width >> level; - int hh = height >> height; + int hh = height >> level; byteArray tempBytes = byteArray(ww * hh * depth * 4); for (int index = 0; index < tempBytes.length; index++) diff --git a/Minecraft.Client/UI/Screens/ChatScreen.cpp b/Minecraft.Client/UI/Screens/ChatScreen.cpp index 481e4758a..d7c944fbe 100644 --- a/Minecraft.Client/UI/Screens/ChatScreen.cpp +++ b/Minecraft.Client/UI/Screens/ChatScreen.cpp @@ -4,7 +4,7 @@ #include "../../../Minecraft.World/Util/SharedConstants.h" #include "../../../Minecraft.World/Util/StringHelpers.h" -const wstring ChatScreen::allowedChars = SharedConstants::acceptableLetters; +const wstring ChatScreen::allowedChars = SharedConstants::readAcceptableChars(); ChatScreen::ChatScreen() { diff --git a/Minecraft.Client/UI/Screens/TextEditScreen.cpp b/Minecraft.Client/UI/Screens/TextEditScreen.cpp index 235f56df4..917ec9678 100644 --- a/Minecraft.Client/UI/Screens/TextEditScreen.cpp +++ b/Minecraft.Client/UI/Screens/TextEditScreen.cpp @@ -11,7 +11,7 @@ #include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.h" -const wstring TextEditScreen::allowedChars = SharedConstants::acceptableLetters;; +const wstring TextEditScreen::allowedChars = SharedConstants::readAcceptableChars(); TextEditScreen::TextEditScreen(shared_ptr sign) { diff --git a/Minecraft.World/Build/CMakeLists.txt b/Minecraft.World/Build/CMakeLists.txt index 7f3ec8b04..a1e93b28e 100644 --- a/Minecraft.World/Build/CMakeLists.txt +++ b/Minecraft.World/Build/CMakeLists.txt @@ -5,8 +5,8 @@ set(PROJECT_NAME Minecraft.World) ################################################################################ set(ConsoleHelpers "../Util/ArrayWithLength.h" -# "C4JThread.cpp" -# "C4JThread.h" + "../Util/C4JThread.cpp" + "../Util/C4JThread.h" "../Util/Definitions.h" "../Util/HashExtension.h" "../Util/PerformanceTimer.cpp" @@ -29,8 +29,8 @@ set(ConsoleHelpers__ConsoleSaveFileIO "../IO/Files/ConsoleSaveFileOriginal.h" "../IO/Files/ConsoleSaveFileOutputStream.cpp" "../IO/Files/ConsoleSaveFileOutputStream.h" -# "ConsoleSaveFileSplit.cpp" -# "ConsoleSaveFileSplit.h" + "../IO/Files/ConsoleSaveFileSplit.cpp" + "../IO/Files/ConsoleSaveFileSplit.h" "../IO/Files/ConsoleSavePath.h" "../IO/Files/FileHeader.cpp" "../IO/Files/FileHeader.h" @@ -1906,6 +1906,7 @@ endif() ################################################################################ # Target name ################################################################################ +if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES TARGET_NAME_CONTENTPACKAGE_NO_TU "${OUTPUT_DIRECTORY}${PROJECT_NAME}" TARGET_NAME_CONTENTPACKAGE_SYMBOLS "${OUTPUT_DIRECTORY}${PROJECT_NAME}" @@ -1913,6 +1914,15 @@ set_target_properties(${PROJECT_NAME} PROPERTIES TARGET_NAME_DEBUG "${OUTPUT_DIRECTORY}${PROJECT_NAME}" TARGET_NAME_RELEASE "${OUTPUT_DIRECTORY}${PROJECT_NAME}" TARGET_NAME_RELEASEFORART "${OUTPUT_DIRECTORY}${PROJECT_NAME}") +else() +set_target_properties(${PROJECT_NAME} PROPERTIES + TARGET_NAME_CONTENTPACKAGE_NO_TU "${PROJECT_NAME}" + TARGET_NAME_CONTENTPACKAGE_SYMBOLS "${PROJECT_NAME}" + TARGET_NAME_CONTENTPACKAGE "${PROJECT_NAME}" + TARGET_NAME_DEBUG "${PROJECT_NAME}" + TARGET_NAME_RELEASE "${PROJECT_NAME}" + TARGET_NAME_RELEASEFORART "${PROJECT_NAME}") +endif() ################################################################################ # Output directory diff --git a/Minecraft.World/Build/stdafx.h b/Minecraft.World/Build/stdafx.h index b915a651e..421f7e1cf 100644 --- a/Minecraft.World/Build/stdafx.h +++ b/Minecraft.World/Build/stdafx.h @@ -176,11 +176,10 @@ void MemSect(int sect); #include "../../Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Storage.h" #include "../../Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Input.h" #elif defined __linux__ -// FIXME: Port 4JLibs to POSIX -#include "../../Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h" -#include "../../Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Render.h" -#include "../../Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h" -#include "../../Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h" +#include "../../4J.Profile/4J_Profile.h" +#include "../../4J.Render/4J_Render.h" +#include "../../4J.Storage/4J_Storage.h" +#include "../../4J.Input/4J_Input.h" #else #include "../../Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Profile.h" #include "../../Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Render.h" diff --git a/Minecraft.World/IO/Files/File.cpp b/Minecraft.World/IO/Files/File.cpp index 900acba91..67adfe805 100644 --- a/Minecraft.World/IO/Files/File.cpp +++ b/Minecraft.World/IO/Files/File.cpp @@ -129,9 +129,7 @@ bool File::mkdir() const #if defined (_UNICODE) return CreateDirectory( getPath().c_str(), NULL) != 0; #elif defined(__linux__) - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); - return ::mkdir(path.c_str(), 0777) == 0; // rwxrwxrwx + return ::mkdir(wstringtofilename(getPath()), 0777) == 0; #else return CreateDirectory( wstringtofilename(getPath()), NULL) != 0; #endif @@ -186,11 +184,10 @@ bool File::mkdirs() const } } #elif defined(__linux__) - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); + const char *mkpath = wstringtofilename(getPath()); struct stat info; - if (stat(path.c_str(), &info) != 0 || !(info.st_mode & S_IFDIR)) { - if (::mkdir(path.c_str(), 0777) != 0) { + if (stat(mkpath, &info) != 0 || !(info.st_mode & S_IFDIR)) { + if (::mkdir(mkpath, 0777) != 0) { return false; } } @@ -229,9 +226,8 @@ bool File::exists() const #if defined(_UNICODE) return GetFileAttributes( getPath().c_str() ) != -1; #elif defined(__linux__) - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); - return access(path.c_str(), F_OK) != -1; + // BAD DOBBY BAD DOBBY + return access(wstringtofilename(getPath()), F_OK) != -1; #else return GetFileAttributes( wstringtofilename(getPath()) ) != -1; #endif @@ -567,9 +563,9 @@ bool File::isDirectory() const #if defined(_UNICODE) return exists() && ( GetFileAttributes( getPath().c_str() ) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; #elif defined(__linux__) - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); - return access(path.c_str(), F_OK) != -1; + const char *dirpath = wstringtofilename(getPath()); + struct stat st; + return stat(dirpath, &st) == 0 && S_ISDIR(st.st_mode); #else return exists() && ( GetFileAttributes( wstringtofilename(getPath()) ) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; #endif @@ -645,10 +641,9 @@ __int64 File::length() return statData.fileSize; #elif defined(__linux__) struct stat fileInfoBuffer; - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); + const char *path = wstringtofilename(getPath()); - int result = stat(path.c_str(), &fileInfoBuffer); + int result = stat(path, &fileInfoBuffer); if(result == 0) { return fileInfoBuffer.st_size; @@ -726,10 +721,7 @@ __int64 File::lastModified() } #else struct stat fileStat; - struct stat fileInfoBuffer; - std::wstring wpath = getPath(); - std::string path(wpath.begin(), wpath.end()); - if (stat(path.c_str(), &fileStat) == 0 && !S_ISDIR(fileStat.st_mode)) { + if (stat(wstringtofilename(getPath()), &fileStat) == 0 && !S_ISDIR(fileStat.st_mode)) { return static_cast<__int64>(fileStat.st_mtime); } else { return 0l; diff --git a/Minecraft.World/IO/Streams/Compression.cpp b/Minecraft.World/IO/Streams/Compression.cpp index d73e6e506..d8dc7222f 100644 --- a/Minecraft.World/IO/Streams/Compression.cpp +++ b/Minecraft.World/IO/Streams/Compression.cpp @@ -300,7 +300,7 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize, HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) { // Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this -#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ +#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__ SIZE_T destSize = (SIZE_T)(*pDestSize); int res = ::compress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize); *pDestSize = (unsigned int)destSize; @@ -328,7 +328,7 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi } // Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this -#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ +#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__ SIZE_T destSize = (SIZE_T)(*pDestSize); int res = ::uncompress((Bytef *)pDestination, (uLongf *)&destSize, (Bytef *)pSource, SrcSize); *pDestSize = (unsigned int)destSize; @@ -405,7 +405,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS } break; case eCompressionType_ZLIBRLE: -#if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64) +#if (defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64 || defined __linux__) if (pDestination != NULL) return ::uncompress((PBYTE)pDestination, (unsigned long *) pDestSize, (PBYTE) pSource, SrcSize); // Decompress else break; // Cannot decompress when destination is NULL diff --git a/Minecraft.World/IO/Streams/Compression.h b/Minecraft.World/IO/Streams/Compression.h index 3d5fceca1..4f81cc784 100644 --- a/Minecraft.World/IO/Streams/Compression.h +++ b/Minecraft.World/IO/Streams/Compression.h @@ -77,7 +77,7 @@ private: //extern Compression gCompression; -#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ +#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__ || defined __linux__ #define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_ZLIBRLE #elif defined __PS3__ #define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_PS3ZLIB diff --git a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp index 12eab3c37..f974f0c03 100644 --- a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp @@ -284,7 +284,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() for(unsigned int i = 0; i < count; ++i) { PlayerUID playerUid = dis.readPlayerUID(); -#ifdef _WINDOWS64 +#if defined(_WINDOWS64) || defined(__linux__) app.DebugPrintf(" -- %d\n", playerUid); #else #ifdef __linux__ @@ -692,7 +692,7 @@ void DirectoryLevelStorage::saveMapIdLookup() app.DebugPrintf("Saving %d mappings\n", m_playerMappings.size()); for(AUTO_VAR(it,m_playerMappings.begin()); it != m_playerMappings.end(); ++it) { -#ifdef _WINDOWS64 +#if defined(_WINDOWS64) || defined(__linux__) app.DebugPrintf(" -- %d\n", it->first); #else #ifdef __linux__ diff --git a/Minecraft.World/Network/Packets/RemoveEntitiesPacket.cpp b/Minecraft.World/Network/Packets/RemoveEntitiesPacket.cpp index a338490dd..56ab5ba05 100644 --- a/Minecraft.World/Network/Packets/RemoveEntitiesPacket.cpp +++ b/Minecraft.World/Network/Packets/RemoveEntitiesPacket.cpp @@ -51,6 +51,6 @@ int RemoveEntitiesPacket::getEstimatedSize() 4J: These are necesary on the PS3. (and 4). */ -#if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__) +#if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined __linux__) const int RemoveEntitiesPacket::MAX_PER_PACKET; #endif diff --git a/Minecraft.World/Util/SharedConstants.cpp b/Minecraft.World/Util/SharedConstants.cpp index 1d26932a2..66cbfec2b 100644 --- a/Minecraft.World/Util/SharedConstants.cpp +++ b/Minecraft.World/Util/SharedConstants.cpp @@ -37,7 +37,7 @@ bool SharedConstants::isAllowedChatCharacter(char ch) return true; } -wstring SharedConstants::acceptableLetters; +wstring SharedConstants::acceptableLetters = SharedConstants::readAcceptableChars(); void SharedConstants::staticCtor() { diff --git a/Minecraft.World/Util/SharedConstants.h b/Minecraft.World/Util/SharedConstants.h index bd6dae895..80751d6d8 100644 --- a/Minecraft.World/Util/SharedConstants.h +++ b/Minecraft.World/Util/SharedConstants.h @@ -14,8 +14,7 @@ class SharedConstants static const int WORLD_RESOLUTION = 16; static bool isAllowedChatCharacter(char ch); - - private: + // why private?????????? static wstring readAcceptableChars(); public: diff --git a/Minecraft.World/Util/StringHelpers.cpp b/Minecraft.World/Util/StringHelpers.cpp index b9ae5d8eb..30512764e 100644 --- a/Minecraft.World/Util/StringHelpers.cpp +++ b/Minecraft.World/Util/StringHelpers.cpp @@ -56,7 +56,7 @@ const char *wstringtofilename(const wstring& name) for(unsigned int i = 0; i < name.length(); i++ ) { wchar_t c = name[i]; -#if defined __PS3__ || defined __ORBIS__ +#if defined __PS3__ || defined __ORBIS__ || defined __linux__ if(c=='\\') c='/'; #else if(c=='/') c='\\'; diff --git a/README.md b/README.md index f332f1cc7..4ecccdb7f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Join our community: * Steam: https://steamcommunity.com/groups/4JCraft ## Planned platforms to be supported: -- Linux (~90%) +- Linux (~95%) - Emscripten (not started) - PS3 - macOS (not started)