diff --git a/4J.Input/4J_Input.cpp b/4J.Input/4J_Input.cpp index 012d385e5..2d8486e2b 100644 --- a/4J.Input/4J_Input.cpp +++ b/4J.Input/4J_Input.cpp @@ -326,16 +326,16 @@ void C_4JInput::SetJoypadSensitivity(int, float){} void C_4JInput::SetJoypadStickAxisMap(int, unsigned int, unsigned int){} void C_4JInput::SetJoypadStickTriggerMap(int, unsigned int, unsigned int){} void C_4JInput::SetKeyRepeatRate(float, float){} -void C_4JInput::SetDebugSequence(const char*, int(*)(LPVOID), LPVOID){} +void C_4JInput::SetDebugSequence(const char*, int(*)(void *), void *){} FLOAT C_4JInput::GetIdleSeconds(int){ return 0.f; } bool C_4JInput::IsPadConnected(int iPad){ return iPad == 0; } // Silly check, we check if we have a keyboard. -EKeyboardResult C_4JInput::RequestKeyboard(LPCWSTR, LPCWSTR, DWORD, UINT, - int(*)(LPVOID, const bool), LPVOID, C_4JInput::EKeyboardMode) +EKeyboardResult C_4JInput::RequestKeyboard(const wchar_t *, const wchar_t *, int, unsigned int, + int(*)(void *, const bool), void *, C_4JInput::EKeyboardMode) { return EKeyboard_Cancelled; } void C_4JInput::GetText(uint16_t *s){ if (s) s[0] = 0; } -bool C_4JInput::VerifyStrings(WCHAR**, int, int(*)(LPVOID, STRING_VERIFY_RESPONSE*), LPVOID){ return true; } -void C_4JInput::CancelQueuedVerifyStrings(int(*)(LPVOID, STRING_VERIFY_RESPONSE*), LPVOID){} -void C_4JInput::CancelAllVerifyInProgress(){} \ No newline at end of file +bool C_4JInput::VerifyStrings(wchar_t **, int, int(*)(void *, STRING_VERIFY_RESPONSE *), void *){ return true; } +void C_4JInput::CancelQueuedVerifyStrings(int(*)(void *, STRING_VERIFY_RESPONSE *), void *){} +void C_4JInput::CancelAllVerifyInProgress(){} diff --git a/4J.Input/4J_Input.h b/4J.Input/4J_Input.h index 59a44f60b..511a92ee6 100644 --- a/4J.Input/4J_Input.h +++ b/4J.Input/4J_Input.h @@ -93,7 +93,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); @@ -111,7 +111,7 @@ public: // 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); + EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); // Online check strings against offensive list - TCR 92 @@ -128,8 +128,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/4J.Profile/4J_Profile.cpp b/4J.Profile/4J_Profile.cpp index 33b88d143..5a7cf8baf 100644 --- a/4J.Profile/4J_Profile.cpp +++ b/4J.Profile/4J_Profile.cpp @@ -22,14 +22,14 @@ 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; } +UINT C_4JProfile::RequestSignInUI(bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, bool bMultiplayerSignIn, bool bAddUser, int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; } +UINT C_4JProfile::DisplayOfflineProfile(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; } +UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; } void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {} bool C_4JProfile::QuerySigninStatus(void) { return true; } void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid, bool bOnlineXuid) { 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::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; @@ -38,13 +38,13 @@ bool C_4JProfile::GetChatAndContentRestrictions(int iPad, bool *pbChatRestricted 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; +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; } +bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount) { 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; } +bool C_4JProfile::GetProfileAvatar(int iPad, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *lpParam) { return false; } void C_4JProfile::CancelProfileAvatarRequest() {} int C_4JProfile::GetPrimaryPad() { return 0; } void C_4JProfile::SetPrimaryPad(int iPad) {} @@ -53,15 +53,15 @@ static char s_gamertag[64] = "Player"; char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; } std::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) {} +void C_4JProfile::SetSignInChangeCallback(void(*Func)(void *, bool, unsigned int), void *lpParam) {} +void C_4JProfile::SetNotificationsCallback(void(*Func)(void *, std::uint32_t, unsigned int), void *lpParam) {} bool C_4JProfile::RegionIsNorthAmerica(void) { return 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; } +void C_4JProfile::SetProfileReadErrorCallback(void(*Func)(void *), void *lpParam) {} +int C_4JProfile::SetDefaultOptionsCallback(int(*Func)(void *, PROFILESETTINGS *, const int iPad), void *lpParam) { return 0; } +int C_4JProfile::SetOldProfileVersionCallback(int(*Func)(void *, unsigned char *, const unsigned short, const int), void *lpParam) { return 0; } static C_4JProfile::PROFILESETTINGS s_defaultSettings = {}; C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(int iPad) { return &s_defaultSettings; } @@ -82,5 +82,5 @@ 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::SetUpsellCallback(void(*Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData), void *lpParam) {} void C_4JProfile::SetDebugFullOverride(bool bVal) {} diff --git a/4J.Profile/4J_Profile.h b/4J.Profile/4J_Profile.h index 4e6fc606c..881480b03 100644 --- a/4J.Profile/4J_Profile.h +++ b/4J.Profile/4J_Profile.h @@ -1,5 +1,7 @@ #pragma once +#include + enum eAwardType { eAwardType_Achievement = 0, @@ -54,21 +56,21 @@ public: 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); + UINT RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT DisplayOfflineProfile(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY); + UINT RequestConvertOfflineToGuestUI(int( *Func)(void *,const bool, const int iPad),void *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 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 AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed); + bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount); void ShowProfileCard(int iPad, PlayerUID targetUid); - bool GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam); + bool GetProfileAvatar(int iPad,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam); void CancelProfileAvatarRequest(); @@ -78,18 +80,18 @@ public: char* GetGamertag(int iPad); std::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); + void SetSignInChangeCallback(void ( *Func)(void *, bool, unsigned int),void *lpParam); + void SetNotificationsCallback(void ( *Func)(void *, std::uint32_t, unsigned int),void *lpParam); bool RegionIsNorthAmerica(void); bool LocaleIsUSorCanada(void); HRESULT GetLiveConnectionStatus(); bool IsSystemUIDisplayed(); - void SetProfileReadErrorCallback(void ( *Func)(LPVOID), LPVOID lpParam); + void SetProfileReadErrorCallback(void ( *Func)(void *), void *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); + int SetDefaultOptionsCallback(int( *Func)(void *,PROFILESETTINGS *, const int iPad),void *lpParam); + int SetOldProfileVersionCallback(int( *Func)(void *,unsigned char *, const unsigned short,const int),void *lpParam); PROFILESETTINGS * GetDashboardProfileSettings(int iPad); void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged=false, bool bOverride5MinuteLimitOnProfileWrites=false); void ForceQueuedProfileWrites(int iPad=XUSER_INDEX_ANY); @@ -116,7 +118,7 @@ public: // PURCHASE void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam = -1); - void SetUpsellCallback(void ( *Func)(LPVOID lpParam, eUpsellType type, eUpsellResponse response, int iUserData),LPVOID lpParam); + void SetUpsellCallback(void ( *Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData),void *lpParam); // Debug void SetDebugFullOverride(bool bVal); // To override the license version (trail/full). Only in debug/release, not ContentPackage diff --git a/4J.Storage/4J_Storage.cpp b/4J.Storage/4J_Storage.cpp index afdfd22af..50c11bbb8 100644 --- a/4J.Storage/4J_Storage.cpp +++ b/4J.Storage/4J_Storage.cpp @@ -13,64 +13,64 @@ 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) { + int(*Func)(void *, int, const C4JStorage::EMessageResult), void *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; } +bool C4JStorage::SetSaveDevice(int(*Func)(void *, const bool), void *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::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize, int(*Func)(void *, const ESavingMessage, int), void *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::SetState(ESaveGameControlState eControlState, int(*Func)(void *, const bool), void *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) {} +C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int(*Func)(void *, const bool), void *lpParam) { return ESaveGame_Idle; } +void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int(*Func)(void *lpParam, bool), void *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; } +C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int(*Func)(void *lpParam, SAVE_DETAILS *pSaveDetails, const bool), void *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; } +C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *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) {} +C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool, const bool), void *lpParam) { return ESaveGame_Idle; } +C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool), void *lpParam) { return ESaveGame_Idle; } +void C4JStorage::RegisterMarketplaceCountsCallback(int(*Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *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; } +C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int(*Func)(void *, int, std::uint32_t, int), void *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::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int(*Func)(void *, int, int), void *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; } +C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int(*Func)(void *, int, int), void *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; } +std::uint32_t C4JStorage::MountInstalledDLC(int iPad, std::uint32_t dwDLC, int(*Func)(void *, int, std::uint32_t, std::uint32_t), void *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; } + WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize, int(*Func)(void *, WCHAR *, int, bool, int), void *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; } +C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(void *, int, int, PTMSPP_FILEDATA, LPCSTR), void *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++) { diff --git a/4J.Storage/4J_Storage.h b/4J.Storage/4J_Storage.h index aa1d74522..973352e6b 100644 --- a/4J.Storage/4J_Storage.h +++ b/4J.Storage/4J_Storage.h @@ -1,6 +1,7 @@ #pragma once +#include #include //#include @@ -242,31 +243,31 @@ public: // 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); + int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL,void *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); + bool SetSaveDevice(int( *Func)(void *,const bool),void *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 Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize,int( *Func)(void *, const ESavingMessage, int),void *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 SetState(ESaveGameControlState eControlState,int( *Func)(void *,const bool),void *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); + C4JStorage::ESaveGameState SaveSaveData(int( *Func)(void * ,const bool),void *lpParam); + void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(void *lpParam, bool), void *lpParam); void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected); bool GetSaveDeviceSelected(unsigned int iPad); C4JStorage::ESaveGameState DoesSaveExist(bool *pbExists); @@ -274,39 +275,39 @@ public: 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); + C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(void *lpParam,SAVE_DETAILS *pSaveDetails,const bool),void *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 + C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *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); + C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool, const bool), void *lpParam); + C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool), void *lpParam); // DLC - void RegisterMarketplaceCountsCallback(int ( *Func)(LPVOID lpParam, C4JStorage::DLC_TMS_DETAILS *, int), LPVOID lpParam ); + void RegisterMarketplaceCountsCallback(int ( *Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *lpParam ); void SetDLCPackageRoot(char *pszDLCRoot); - C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(LPVOID, int, DWORD, int),LPVOID lpParam, DWORD dwOfferTypesBitmask=XMARKETPLACE_OFFERING_TYPE_CONTENT); + C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(void *, int, std::uint32_t, int),void *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 InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA,int( *Func)(void *, int, int),void *lpParam, bool bTrial=false); DWORD GetAvailableDLCCount( int iPad); - C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam); + C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(void *, int, int),void *lpParam); XCONTENT_DATA& GetDLC(DWORD dw); - DWORD MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive=NULL); + std::uint32_t MountInstalledDLC(int iPad,std::uint32_t dwDLC,int( *Func)(void *, int, std::uint32_t, std::uint32_t),void *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); + WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(void *, WCHAR *,int, bool, int)=NULL,void *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); @@ -319,7 +320,7 @@ public: // 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_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(void *,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,void *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 std::wstring &Filename); diff --git a/Minecraft.Client/GameState/StatsCounter.cpp b/Minecraft.Client/GameState/StatsCounter.cpp index ab4895a2b..b63e909f7 100644 --- a/Minecraft.Client/GameState/StatsCounter.cpp +++ b/Minecraft.Client/GameState/StatsCounter.cpp @@ -10,6 +10,7 @@ #include "../../Minecraft.World/Headers/net.minecraft.world.item.h" #include "../Platform/Common/Leaderboards/LeaderboardManager.h" +#include Stat** StatsCounter::LARGE_STATS[] = { &Stats::walkOneM, @@ -142,9 +143,9 @@ void StatsCounter::parse(void* data) assert( stats.size() == 0 ); //Pointer to current position in stat array - PBYTE pbData=(PBYTE)data; - pbData+=sizeof(GAME_SETTINGS); - unsigned short* statData = (unsigned short*)pbData;//data + (STAT_DATA_OFFSET/sizeof(unsigned short)); + std::uint8_t* pbData = reinterpret_cast(data); + pbData += sizeof(GAME_SETTINGS); + std::uint8_t* statData = pbData; //Value being read StatContainer newVal; @@ -157,19 +158,22 @@ void StatsCounter::parse(void* data) { if( !isLargeStat(*iter) ) { - if( statData[0] != 0 || statData[1] != 0 || statData[2] != 0 || statData[3] != 0 ) + std::uint16_t difficultyStats[eDifficulty_Max] = {}; + std::memcpy(difficultyStats, statData, sizeof(difficultyStats)); + if( difficultyStats[0] != 0 || difficultyStats[1] != 0 || difficultyStats[2] != 0 || difficultyStats[3] != 0 ) { - newVal.stats[0] = statData[0]; - newVal.stats[1] = statData[1]; - newVal.stats[2] = statData[2]; - newVal.stats[3] = statData[3]; + newVal.stats[0] = difficultyStats[0]; + newVal.stats[1] = difficultyStats[1]; + newVal.stats[2] = difficultyStats[2]; + newVal.stats[3] = difficultyStats[3]; stats.insert( std::make_pair(*iter, newVal) ); } - statData += 4; + statData += sizeof(difficultyStats); } else { - unsigned int* largeStatData = (unsigned int*)statData; + std::uint32_t largeStatData[eDifficulty_Max] = {}; + std::memcpy(largeStatData, statData, sizeof(largeStatData)); if( largeStatData[0] != 0 || largeStatData[1] != 0 || largeStatData[2] != 0 || largeStatData[3] != 0 ) { newVal.stats[0] = largeStatData[0]; @@ -178,21 +182,22 @@ void StatsCounter::parse(void* data) newVal.stats[3] = largeStatData[3]; stats.insert( std::make_pair(*iter, newVal) ); } - largeStatData += 4; - statData = (unsigned short*)largeStatData; + statData += sizeof(largeStatData); } } else { - if( statData[0] != 0 ) + std::uint16_t achievementValue = 0; + std::memcpy(&achievementValue, statData, sizeof(achievementValue)); + if( achievementValue != 0 ) { - newVal.stats[0] = statData[0]; + newVal.stats[0] = achievementValue; newVal.stats[1] = 0; newVal.stats[2] = 0; newVal.stats[3] = 0; stats.insert( std::make_pair(*iter, newVal) ); } - ++statData; + statData += sizeof(achievementValue); } } @@ -215,15 +220,14 @@ void StatsCounter::save(int player, bool force) //Retrieve the data pointer from the profile #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) - PBYTE pbData = (PBYTE)StorageManager.GetGameDefinedProfileData(player); + std::uint8_t* pbData = reinterpret_cast(StorageManager.GetGameDefinedProfileData(player)); #else - PBYTE pbData = (PBYTE)ProfileManager.GetGameDefinedProfileData(player); + std::uint8_t* pbData = reinterpret_cast(ProfileManager.GetGameDefinedProfileData(player)); #endif - pbData+=sizeof(GAME_SETTINGS); + pbData += sizeof(GAME_SETTINGS); //Pointer to current position in stat array - //unsigned short* statData = (unsigned short*)data + (STAT_DATA_OFFSET/sizeof(unsigned short)); - unsigned short* statData = (unsigned short*)pbData; + std::uint8_t* statData = pbData; //Reset all the data to 0 (we're going to replace it with the map data) memset(statData, 0, CConsoleMinecraftApp::GAME_DEFINED_PROFILE_DATA_BYTES-sizeof(GAME_SETTINGS)); @@ -239,18 +243,20 @@ void StatsCounter::save(int player, bool force) { if( !isLargeStat(*iter) ) { + std::uint16_t difficultyStats[eDifficulty_Max] = {}; if( val != stats.end() ) { - statData[0] = val->second.stats[0]; - statData[1] = val->second.stats[1]; - statData[2] = val->second.stats[2]; - statData[3] = val->second.stats[3]; + difficultyStats[0] = static_cast(val->second.stats[0]); + difficultyStats[1] = static_cast(val->second.stats[1]); + difficultyStats[2] = static_cast(val->second.stats[2]); + difficultyStats[3] = static_cast(val->second.stats[3]); } - statData += 4; + std::memcpy(statData, difficultyStats, sizeof(difficultyStats)); + statData += sizeof(difficultyStats); } else { - unsigned int* largeStatData = (unsigned int*)statData; + std::uint32_t largeStatData[eDifficulty_Max] = {}; if( val != stats.end() ) { largeStatData[0] = val->second.stats[0]; @@ -258,17 +264,19 @@ void StatsCounter::save(int player, bool force) largeStatData[2] = val->second.stats[2]; largeStatData[3] = val->second.stats[3]; } - largeStatData += 4; - statData = (unsigned short*)largeStatData; + std::memcpy(statData, largeStatData, sizeof(largeStatData)); + statData += sizeof(largeStatData); } } else { + std::uint16_t achievementValue = 0; if( val != stats.end() ) { - statData[0] = val->second.stats[0]; + achievementValue = static_cast(val->second.stats[0]); } - ++statData; + std::memcpy(statData, &achievementValue, sizeof(achievementValue)); + statData += sizeof(achievementValue); } } @@ -283,7 +291,7 @@ void StatsCounter::save(int player, bool force) } #ifdef _XBOX -void StatsCounter::setLeaderboardProperty(XUSER_PROPERTY* prop, DWORD id, unsigned int value) +void StatsCounter::setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, unsigned int value) { app.DebugPrintf("Setting property id: %d to value %d\n", id, value); prop->dwPropertyId = id; diff --git a/Minecraft.Client/GameState/StatsCounter.h b/Minecraft.Client/GameState/StatsCounter.h index 4963d3ab8..55298ae01 100644 --- a/Minecraft.Client/GameState/StatsCounter.h +++ b/Minecraft.Client/GameState/StatsCounter.h @@ -1,4 +1,5 @@ #pragma once +#include class Stat; class Achievement; class StatsSyncher; @@ -95,7 +96,7 @@ private: void dumpStatsToTTY(); #ifdef _XBOX - static void setLeaderboardProperty(XUSER_PROPERTY* prop, DWORD id, unsigned int value); + static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, unsigned int value); static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value); #endif diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index fe9c48fc1..1c86fa5ef 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -1415,7 +1415,7 @@ void Minecraft::run_middle() } else { - UINT uiIDA[1] = { IDS_OK }; + unsigned int uiIDA[1] = { IDS_OK }; ui.RequestMessageBox( IDS_CANTJOIN_TITLE, IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, i, NULL, NULL, app.GetStringTable() ); } } @@ -1610,14 +1610,14 @@ void Minecraft::run_middle() // Check if PSN is unavailable because of age restriction if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, i, NULL, NULL, app.GetStringTable()); } else if (ProfileManager.IsSignedIn(i) && !ProfileManager.IsSignedInLive(i)) { // You're not signed in to PSN! - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1] = IDS_CANCEL; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, i,&Minecraft::MustSignInReturnedPSN, this, app.GetStringTable(), NULL, 0, false); @@ -1625,7 +1625,7 @@ void Minecraft::run_middle() else #endif { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA, 1, i, NULL, NULL, app.GetStringTable()); } @@ -3894,7 +3894,7 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, std::shar // The level renderer needs to have it's stored level set to NULL so that it doesn't break next time we set one if (levelRenderer != NULL) { - for(DWORD p = 0; p < XUSER_MAX_COUNT; ++p) + for(unsigned int p = 0; p < XUSER_MAX_COUNT; ++p) { levelRenderer->setLevel(p, NULL); } @@ -4225,7 +4225,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) } // Set the animation override if the skin has one - DWORD dwSkinID=app.getSkinIdFromPath(player->customTextureUrl); + std::uint32_t dwSkinID = app.getSkinIdFromPath(player->customTextureUrl); if(GET_IS_DLC_SKIN_FROM_BITMASK(dwSkinID)) { player->setAnimOverrideBitmask(player->getSkinAnimOverrideBitmask(dwSkinID)); @@ -4703,7 +4703,7 @@ void Minecraft::playerLeftTutorial(int iPad) // 4J Stu -This telemetry event means something different on XboxOne, so we don't call it for simple state changes like this #ifndef _XBOX_ONE - for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) + for(unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(localplayers[idx] != NULL) { @@ -4715,7 +4715,7 @@ void Minecraft::playerLeftTutorial(int iPad) } #ifdef _DURANGO -void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasPrivileges, int iPad) +void Minecraft::inGameSignInCheckAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad) { Minecraft* pClass = (Minecraft*)lpParam; @@ -4727,7 +4727,7 @@ void Minecraft::inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasP { if( !g_NetworkManager.SessionHasSpace() ) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_OK; ui.RequestMessageBox(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); ProfileManager.RemoveGamepadFromGame(iPad); @@ -4784,7 +4784,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) #endif if( !g_NetworkManager.SessionHasSpace() ) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_OK; ui.RequestMessageBox(IDS_MULTIPLAYER_FULL_TITLE, IDS_MULTIPLAYER_FULL_TEXT, uiIDA, 1); #ifdef _DURANGO @@ -4828,7 +4828,7 @@ int Minecraft::InGame_SignInReturned(void *pParam,bool bContinue, int iPad) // 4J Stu - Don't allow converting to guests as we don't allow any guest sign-in while in the game // Fix for #66516 - TCR #124: MPS Guest Support ; #001: BAS Game Stability: TU8: The game crashes when second Guest signs-in on console which takes part in Xbox LIVE multiplayer session. //ProfileManager.RequestConvertOfflineToGuestUI( &Minecraft::InGame_SignInReturned, pMinecraftClass,iPad); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,iPad,NULL,NULL, app.GetStringTable()); #ifdef _DURANGO diff --git a/Minecraft.Client/Minecraft.h b/Minecraft.Client/Minecraft.h index 0d071fa3f..c4208406f 100644 --- a/Minecraft.Client/Minecraft.h +++ b/Minecraft.Client/Minecraft.h @@ -305,7 +305,7 @@ public: static __int64 currentTimeMillis(); #ifdef _DURANGO - static void inGameSignInCheckAllPrivilegesCallback(LPVOID lpParam, bool hasPrivileges, int iPad); + static void inGameSignInCheckAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad); #endif static int InGame_SignInReturned(void *pParam,bool bContinue, int iPad); // 4J-PB @@ -317,7 +317,7 @@ public: CRITICAL_SECTION m_setLevelCS; private: // A bit field that store whether a particular quadrant is in the full tutorial or not - BYTE m_inFullTutorialBits; + std::uint8_t m_inFullTutorialBits; public: bool isTutorial(); void playerStartedTutorial(int iPad); diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index c20b35a10..a666de551 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -99,7 +99,7 @@ MinecraftServer::~MinecraftServer() { } -bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DWORD initSettings, bool findSeed) +bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, std::uint32_t initSettings, bool findSeed) { // 4J - removed #if 0 @@ -262,7 +262,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW // 4J delete passed in save data now - this is only required for the tutorial which is loaded by passing data directly in rather than using the storage manager if( initData->saveData ) { - delete[] (BYTE*)initData->saveData->data; + delete[] reinterpret_cast(initData->saveData->data); initData->saveData->data = 0; initData->saveData->fileSize = 0; } @@ -349,7 +349,7 @@ void MinecraftServer::addPostProcessRequest(ChunkSource *chunkSource, int x, int void MinecraftServer::postProcessTerminate(ProgressRenderer *mcprogress) { - DWORD status = 0; + std::uint32_t status = 0; EnterCriticalSection(&server->m_postProcessCS); size_t postProcessItemCount = server->m_postProcessRequests.size(); @@ -426,8 +426,8 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const std::ws LevelGenerationOptions *levelGen = app.getLevelGenerationOptions(); if( levelGen != NULL && levelGen->requiresBaseSave()) { - DWORD fileSize = 0; - LPVOID pvSaveData = levelGen->getBaseSaveData(fileSize); + unsigned int fileSize = 0; + std::uint8_t *pvSaveData = levelGen->getBaseSaveData(fileSize); if(pvSaveData && fileSize != 0) bLevelGenBaseSave = true; } ConsoleSaveFileSplit *newFormatSave = NULL; @@ -535,15 +535,15 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const std::ws ConsoleSaveFile *csf = getLevel(0)->getLevelStorage()->getSaveFile(); if( csf->doesFileExist(filepath) ) { - DWORD numberOfBytesRead; + unsigned int numberOfBytesRead; byteArray ba_gameRules; FileEntry *fe = csf->createFile(filepath); ba_gameRules.length = fe->getFileSize(); - ba_gameRules.data = new BYTE[ ba_gameRules.length ]; + ba_gameRules.data = new std::uint8_t[ ba_gameRules.length ]; - csf->setFilePointer(fe,0,NULL,FILE_BEGIN); + csf->setFilePointer(fe, 0, SaveFileSeekOrigin::Begin); csf->readFile(fe, ba_gameRules.data, ba_gameRules.length, &numberOfBytesRead); assert(numberOfBytesRead == ba_gameRules.length); @@ -809,8 +809,8 @@ void MinecraftServer::saveGameRules() { ConsoleSaveFile *csf = getLevel(0)->getLevelStorage()->getSaveFile(); FileEntry *fe = csf->createFile(ConsoleSavePath(GAME_RULE_SAVENAME)); - csf->setFilePointer(fe, 0, NULL, FILE_BEGIN); - DWORD length; + csf->setFilePointer(fe, 0, SaveFileSeekOrigin::Begin); + unsigned int length; csf->writeFile(fe, ba.data, ba.length, &length ); delete [] ba.data; @@ -1060,7 +1060,7 @@ extern int c0a, c0b, c1a, c1b, c1c, c2a, c2b; void MinecraftServer::run(__int64 seed, void *lpParameter) { NetworkGameInitData *initData = NULL; - DWORD initSettings = 0; + std::uint32_t initSettings = 0; bool findSeed = false; if(lpParameter != NULL) { @@ -1194,7 +1194,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter) // Process delayed actions eXuiServerAction eAction; - LPVOID param; + void *param; for(int i=0;i + #include "Input/ConsoleInputSource.h" #include "../Minecraft.World/Util/ArrayWithLength.h" #include "../Minecraft.World/Util/SharedConstants.h" @@ -22,19 +24,19 @@ class CommandDispatcher; typedef struct _LoadSaveDataThreadParam { - LPVOID data; + void *data; __int64 fileSize; const std::wstring saveName; - _LoadSaveDataThreadParam(LPVOID data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {} + _LoadSaveDataThreadParam(void *data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {} } LoadSaveDataThreadParam; typedef struct _NetworkGameInitData { __int64 seed; LoadSaveDataThreadParam *saveData; - DWORD settings; + std::uint32_t settings; LevelGenerationOptions *levelGen; - DWORD texturePackId; + std::uint32_t texturePackId; bool findSeed; unsigned int xzSize; unsigned char hellScale; @@ -115,17 +117,17 @@ private: public: // 4J Stu - This value should be incremented every time the list of players with friends-only UGC settings changes // It is sent with PreLoginPacket and compared when it comes back in the LoginPacket - DWORD m_ugcPlayersVersion; + std::uint32_t m_ugcPlayersVersion; // This value is used to store the texture pack id for the currently loaded world - DWORD m_texturePackId; + std::uint32_t m_texturePackId; public: MinecraftServer(); ~MinecraftServer(); private: // 4J Added - LoadSaveDataThreadParam - bool initServer(__int64 seed, NetworkGameInitData *initData, DWORD initSettings, bool findSeed); + bool initServer(__int64 seed, NetworkGameInitData *initData, std::uint32_t initSettings, bool findSeed); void postProcessTerminate(ProgressRenderer *mcprogress); bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData); void setProgress(const std::wstring& status, int progress); diff --git a/Minecraft.Client/Network/ClientConnection.cpp b/Minecraft.Client/Network/ClientConnection.cpp index a671cc0d8..6c5040452 100644 --- a/Minecraft.Client/Network/ClientConnection.cpp +++ b/Minecraft.Client/Network/ClientConnection.cpp @@ -197,8 +197,8 @@ void ClientConnection::handleLogin(std::shared_ptr packet) if(iUserID!=-1) { - BYTE *pBuffer=NULL; - DWORD dwSize=0; + std::uint8_t *pBuffer = NULL; + unsigned int dwSize = 0; bool bRes; // if there's a special skin or cloak for this player, add it in @@ -305,7 +305,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) //minecraft->setScreen(new ReceivingLevelScreen(this)); minecraft->player->entityId = packet->clientVersion; - BYTE networkSmallId = getSocket()->getSmallId(); + std::uint8_t networkSmallId = getSocket()->getSmallId(); app.UpdatePlayerInfo(networkSmallId, packet->m_playerIndex, packet->m_uiGamePrivileges); minecraft->player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); @@ -375,7 +375,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) player->setCustomCape( app.GetPlayerCapeId(m_userIndex) ); - BYTE networkSmallId = getSocket()->getSmallId(); + std::uint8_t networkSmallId = getSocket()->getSmallId(); app.UpdatePlayerInfo(networkSmallId, packet->m_playerIndex, packet->m_uiGamePrivileges); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); @@ -1172,7 +1172,7 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, m_userIndex == ProfileManager.GetPrimaryPad() && !MinecraftServer::saveOnExitAnswered() ) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ProfileManager.GetPrimaryPad(),&ClientConnection::HostDisconnectReturned,NULL, app.GetStringTable()); } @@ -1619,11 +1619,11 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) fprintf(stderr, "[LOGIN-CLI] handlePreLogin entered, isHost=%d, userIdx=%d\n", (int)g_NetworkManager.IsHost(), m_userIndex); #if 1 // 4J - Check that we can play with all the players already in the game who have Friends-Only UGC set - BOOL canPlay = TRUE; - BOOL canPlayLocal = TRUE; - BOOL isAtLeastOneFriend = g_NetworkManager.IsHost(); - BOOL isFriendsWithHost = TRUE; - BOOL cantPlayContentRestricted = FALSE; + bool canPlay = true; + bool canPlayLocal = true; + bool isAtLeastOneFriend = g_NetworkManager.IsHost(); + bool isFriendsWithHost = true; + bool cantPlayContentRestricted = false; if(!g_NetworkManager.IsHost()) { @@ -1642,12 +1642,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { if(m_userIndex == ProfileManager.GetPrimaryPad() ) { - for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) + for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(ProfileManager.IsSignedIn(m_userIndex) && ProfileManager.IsGuest(idx)) { - canPlay = FALSE; - isFriendsWithHost = FALSE; + canPlay = false; + isFriendsWithHost = false; } else { @@ -1659,13 +1659,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) if( playerXuid != INVALID_XUID ) { // Is this user friends with the host player? - BOOL result; - DWORD error; - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); - if(error == ERROR_SUCCESS && result != TRUE) + int result = 0; + const unsigned int error = XUserAreUsersFriends(idx,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); + if(error == ERROR_SUCCESS && result == 0) { - canPlay = FALSE; - isFriendsWithHost = FALSE; + canPlay = false; + isFriendsWithHost = false; } } } @@ -1676,8 +1675,8 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { if(ProfileManager.IsSignedIn(m_userIndex) && ProfileManager.IsGuest(m_userIndex)) { - canPlay = FALSE; - isFriendsWithHost = FALSE; + canPlay = false; + isFriendsWithHost = false; } else { @@ -1689,13 +1688,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) if( playerXuid != INVALID_XUID ) { // Is this user friends with the host player? - BOOL result; - DWORD error; - error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); - if(error == ERROR_SUCCESS && result != TRUE) + int result = 0; + const unsigned int error = XUserAreUsersFriends(m_userIndex,&packet->m_playerXuids[packet->m_hostIndex],1,&result,NULL); + if(error == ERROR_SUCCESS && result == 0) { - canPlay = FALSE; - isFriendsWithHost = FALSE; + canPlay = false; + isFriendsWithHost = false; } } } @@ -1704,10 +1702,10 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) if( canPlay ) { - for(DWORD i = 0; i < packet->m_dwPlayerCount; ++i) + for(std::uint8_t i = 0; i < packet->m_dwPlayerCount; ++i) { bool localPlayer = false; - for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) + for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if( ProfileManager.IsSignedInLive(idx) ) { @@ -1735,16 +1733,15 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) // 4J Stu - Everyone joining needs to have at least one friend in the game // Local players are implied friends - if( isAtLeastOneFriend != TRUE ) + if(!isAtLeastOneFriend) { - BOOL result; - DWORD error; - for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) + int result = 0; + for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if( ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); - if(error == ERROR_SUCCESS && result == TRUE) isAtLeastOneFriend = TRUE; + const unsigned int error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); + if(error == ERROR_SUCCESS && result != 0) isAtLeastOneFriend = true; } } } @@ -1765,14 +1762,13 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) bool thisQuadrantOnly = true; if( m_userIndex == ProfileManager.GetPrimaryPad() ) thisQuadrantOnly = false; - BOOL result; - DWORD error; - for(DWORD idx = 0; idx < XUSER_MAX_COUNT; ++idx) + int result = 0; + for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if( (!thisQuadrantOnly || m_userIndex == idx) && ProfileManager.IsSignedIn(idx) && !ProfileManager.IsGuest(idx) ) { - error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); - if(error == ERROR_SUCCESS) canPlay &= result; + const unsigned int error = XUserAreUsersFriends(idx,&packet->m_playerXuids[i],1,&result,NULL); + if(error == ERROR_SUCCESS) canPlay &= (result != 0); } if(!canPlay) break; } @@ -1783,10 +1779,10 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) } #else // TODO - handle this kind of things for non-360 platforms - canPlay = TRUE; - canPlayLocal = TRUE; - isAtLeastOneFriend = TRUE; - cantPlayContentRestricted= FALSE; + canPlay = true; + canPlayLocal = true; + isAtLeastOneFriend = true; + cantPlayContentRestricted= false; #if ( defined __PS3__ || defined __ORBIS__ || defined __PSVITA__) @@ -1987,7 +1983,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) else if(cantPlayContentRestricted) reason = DisconnectPacket::eDisconnect_ContentRestricted_Single_Local; app.DebugPrintf("Exiting player %d on handling Pre-Login packet due UGC privileges: %d\n", m_userIndex, reason); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; if(!isFriendsWithHost) ui.RequestMessageBox( IDS_CANTJOIN_TITLE, IDS_NOTALLOWED_FRIENDSOFFRIENDS, uiIDA,1,m_userIndex,NULL,NULL, app.GetStringTable()); else ui.RequestMessageBox( IDS_CANTJOIN_TITLE, IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL, uiIDA,1,m_userIndex,NULL,NULL, app.GetStringTable()); @@ -2056,11 +2052,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) // All other players we use their offline XUID so that they can play the game offline ProfileManager.GetXUID(m_userIndex,&offlineXUID,false); } - BOOL allAllowed, friendsAllowed; + bool allAllowed = false; + bool friendsAllowed = false; ProfileManager.AllowedPlayerCreatedContent(m_userIndex,true,&allAllowed,&friendsAllowed); fprintf(stderr, "[LOGIN] Sending LoginPacket: user=%ls netVer=%d userIdx=%d isHost=%d\n", minecraft->user->name.c_str(), SharedConstants::NETWORK_PROTOCOL_VERSION, m_userIndex, (int)g_NetworkManager.IsHost()); - send( std::shared_ptr( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (allAllowed!=TRUE && friendsAllowed==TRUE), + send( std::shared_ptr( new LoginPacket(minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (!allAllowed && friendsAllowed), packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), app.GetPlayerCapeId(m_userIndex), ProfileManager.IsGuest( m_userIndex )))); fprintf(stderr, "[LOGIN] LoginPacket sent successfully\n"); @@ -2235,14 +2232,14 @@ void ClientConnection::handleTexture(std::shared_ptr packet) // Server side also needs to store a list of those clients waiting to get a texture the server doesn't have yet // so that it can send it out to them when it comes in - if(packet->dwBytes==0) + if(packet->dataBytes==0) { // Request for texture #ifndef _CONTENT_PACKAGE wprintf(L"Client received request for custom texture %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=NULL; - DWORD dwBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); if(dwBytes!=0) @@ -2256,7 +2253,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) #ifndef _CONTENT_PACKAGE wprintf(L"Client received custom texture %ls\n",packet->textureName.c_str()); #endif - app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dwBytes); + app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dataBytes); Minecraft::GetInstance()->handleClientTextureReceived(packet->textureName); } } @@ -2273,8 +2270,8 @@ void ClientConnection::handleTextureAndGeometry(std::shared_ptrtextureName.c_str()); #endif - PBYTE pbData=NULL; - DWORD dwBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(packet->textureName); @@ -2883,7 +2880,7 @@ void ClientConnection::handleGameEvent(std::shared_ptr gameEven } else if (event == GameEventPacket::WIN_GAME) { - ui.SetWinUserIndex( (BYTE)gameEventPacket->param ); + ui.SetWinUserIndex(static_cast(gameEventPacket->param)); #ifdef _XBOX @@ -3243,7 +3240,7 @@ void ClientConnection::handleUpdateProgress(std::shared_ptr packet) { - LPCWSTR string = app.GetGameRulesString(packet->m_messageId); + const wchar_t *string = app.GetGameRulesString(packet->m_messageId); if(string != NULL) { std::wstring message(string); @@ -3291,7 +3288,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E // we need to ask if they are sure they want to overwrite the existing game if(bSaveExists && StorageManager.GetSaveDisabled()) { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL, app.GetStringTable()); @@ -3306,7 +3303,7 @@ int ClientConnection::HostDisconnectReturned(void *pParam,int iPad,C4JStorage::E // we need to ask if they are sure they want to overwrite the existing game if(bSaveExists) { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&ClientConnection::ExitGameAndSaveReturned,NULL, app.GetStringTable()); diff --git a/Minecraft.Client/Network/ClientConnection.h b/Minecraft.Client/Network/ClientConnection.h index 1f0aae762..f901e98fa 100644 --- a/Minecraft.Client/Network/ClientConnection.h +++ b/Minecraft.Client/Network/ClientConnection.h @@ -41,7 +41,7 @@ public: Socket *getSocket() { return connection->getSocket(); } // 4J Added private: - DWORD m_userIndex; // 4J Added + int m_userIndex; // 4J Added public: SavedDataStorage *savedDataStorage; ClientConnection(Minecraft *minecraft, const std::wstring& ip, int port); @@ -137,4 +137,4 @@ public: virtual void handleXZ(std::shared_ptr packet); void displayPrivilegeChanges(std::shared_ptr player, unsigned int oldPrivileges); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Network/PendingConnection.cpp b/Minecraft.Client/Network/PendingConnection.cpp index dec6b1f15..80bc0f043 100644 --- a/Minecraft.Client/Network/PendingConnection.cpp +++ b/Minecraft.Client/Network/PendingConnection.cpp @@ -1,4 +1,5 @@ #include "../Platform/stdafx.h" +#include #include "PendingConnection.h" #include "PlayerConnection.h" #include "ServerConnection.h" @@ -94,9 +95,9 @@ void PendingConnection::sendPreLoginResponse() { // 4J Stu - Calculate the players with UGC privileges set PlayerUID *ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS]; - DWORD ugcXuidCount = 0; - DWORD hostIndex = 0; - BYTE ugcFriendsOnlyBits = 0; + std::uint8_t ugcXuidCount = 0; + std::uint8_t hostIndex = 0; + std::uint8_t ugcFriendsOnlyBits = 0; char szUniqueMapName[14]; StorageManager.GetSaveUniqueFilename(szUniqueMapName); @@ -267,4 +268,4 @@ std::wstring PendingConnection::getName() bool PendingConnection::isServerPacketListener() { return true; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Network/PlayerConnection.cpp b/Minecraft.Client/Network/PlayerConnection.cpp index 76c71433c..b5b494e81 100644 --- a/Minecraft.Client/Network/PlayerConnection.cpp +++ b/Minecraft.Client/Network/PlayerConnection.cpp @@ -796,14 +796,14 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { // Both PlayerConnection and ClientConnection should handle this mostly the same way - if(packet->dwBytes==0) + if(packet->dataBytes==0) { // Request for texture #ifndef _CONTENT_PACKAGE wprintf(L"Server received request for custom texture %ls\n",packet->textureName.c_str()); #endif - PBYTE pbData=NULL; - DWORD dwBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwBytes); if(dwBytes!=0) @@ -821,7 +821,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) #ifndef _CONTENT_PACKAGE wprintf(L"Server received custom texture %ls\n",packet->textureName.c_str()); #endif - app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dwBytes); + app.AddMemoryTextureFile(packet->textureName,packet->pbData,packet->dataBytes); server->connection->handleTextureReceived(packet->textureName); } } @@ -836,8 +836,8 @@ void PlayerConnection::handleTextureAndGeometry(std::shared_ptrtextureName.c_str()); #endif - PBYTE pbData=NULL; - DWORD dwTextureBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwTextureBytes=0; app.GetMemFileDetails(packet->textureName,&pbData,&dwTextureBytes); DLCSkinFile *pDLCSkinFile = app.m_dlcManager.getSkinFile(packet->textureName); @@ -900,8 +900,8 @@ void PlayerConnection::handleTextureReceived(const std::wstring &textureName) AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName )); if( it != m_texturesRequested.end() ) { - PBYTE pbData=NULL; - DWORD dwBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwBytes=0; app.GetMemFileDetails(textureName,&pbData,&dwBytes); if(dwBytes!=0) @@ -918,8 +918,8 @@ void PlayerConnection::handleTextureAndGeometryReceived(const std::wstring &text AUTO_VAR(it, find( m_texturesRequested.begin(), m_texturesRequested.end(), textureName )); if( it != m_texturesRequested.end() ) { - PBYTE pbData=NULL; - DWORD dwTextureBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwTextureBytes=0; app.GetMemFileDetails(textureName,&pbData,&dwTextureBytes); DLCSkinFile *pDLCSkinFile=app.m_dlcManager.getSkinFile(textureName); @@ -932,7 +932,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(const std::wstring &text else { // get the data from the app - DWORD dwSkinID = app.getSkinIdFromPath(textureName); + std::uint32_t dwSkinID = app.getSkinIdFromPath(textureName); std::vector *pvSkinBoxes = app.GetAdditionalSkinBoxes(dwSkinID); unsigned int uiAnimOverrideBitmask= app.GetAnimOverrideBitmask(dwSkinID); @@ -1205,7 +1205,7 @@ void PlayerConnection::handleSetCreativeModeSlot(std::shared_ptrx = centreXC; data->z = centreZC; - data->dimension = (uint8_t) player->level->dimension->id; + data->dimension = (std::uint8_t) player->level->dimension->id; data->setDirty(); } @@ -1714,4 +1714,4 @@ bool PlayerConnection::isGuest() } return isGuest; } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Network/PlayerList.cpp b/Minecraft.Client/Network/PlayerList.cpp index 7299f00a3..1f48183c8 100644 --- a/Minecraft.Client/Network/PlayerList.cpp +++ b/Minecraft.Client/Network/PlayerList.cpp @@ -1,4 +1,5 @@ #include "../Platform/stdafx.h" +#include #include "PlayerList.h" #include "PlayerChunkMap.h" #include "../MinecraftServer.h" @@ -105,7 +106,7 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptrgetLevel(player->dimension); - DWORD playerIndex = 0; + std::uint8_t playerIndex = 0; { bool usedIndexes[MINECRAFT_NET_MAX_PLAYERS]; ZeroMemory( &usedIndexes, MINECRAFT_NET_MAX_PLAYERS * sizeof(bool) ); @@ -210,8 +211,8 @@ void PlayerList::placeNewPlayer(Connection *connection, std::shared_ptrsend( std::shared_ptr( new LoginPacket(L"", player->entityId, level->getLevelData()->getGenerator(), level->getSeed(), player->gameMode->getGameModeForPlayer()->getId(), - (uint8_t) level->dimension->id, (uint8_t) level->getMaxBuildHeight(), (uint8_t) getMaxPlayers(), - level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), (BYTE)playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), + (std::uint8_t) level->dimension->id, (std::uint8_t) level->getMaxBuildHeight(), (std::uint8_t) getMaxPlayers(), + level->difficulty, TelemetryManager->GetMultiplayerInstanceID(), playerIndex, level->useNewSeaLevel(), player->getAllPlayerGamePrivileges(), level->getLevelData()->getXZSize(), level->getLevelData()->getHellScale() ) ) ); playerConnection->send( std::shared_ptr( new SetSpawnPositionPacket(spawnPos->x, spawnPos->y, spawnPos->z) ) ); playerConnection->send( std::shared_ptr( new PlayerAbilitiesPacket(&player->abilities)) ); @@ -535,7 +536,7 @@ std::shared_ptr PlayerList::respawn(std::shared_ptr serverPlayer->dimension = targetDimension; EDefaultSkins skin = serverPlayer->getPlayerDefaultSkin(); - DWORD playerIndex = serverPlayer->getPlayerIndex(); + std::uint8_t playerIndex = serverPlayer->getPlayerIndex(); PlayerUID playerXuid = serverPlayer->getXuid(); PlayerUID playerOnlineXuid = serverPlayer->getOnlineXuid(); @@ -846,7 +847,7 @@ void PlayerList::tick() EnterCriticalSection(&m_closePlayersCS); while(!m_smallIdsToClose.empty()) { - BYTE smallId = m_smallIdsToClose.front(); + std::uint8_t smallId = m_smallIdsToClose.front(); m_smallIdsToClose.pop_front(); std::shared_ptr player = nullptr; @@ -872,7 +873,7 @@ void PlayerList::tick() EnterCriticalSection(&m_kickPlayersCS); while(!m_smallIdsToKick.empty()) { - BYTE smallId = m_smallIdsToKick.front(); + std::uint8_t smallId = m_smallIdsToKick.front(); m_smallIdsToKick.pop_front(); INetworkPlayer *selectedPlayer = g_NetworkManager.GetPlayerBySmallId(smallId); if( selectedPlayer != NULL ) @@ -1415,14 +1416,14 @@ bool PlayerList::canReceiveAllPackets(std::shared_ptr player) return false; } -void PlayerList::kickPlayerByShortId(BYTE networkSmallId) +void PlayerList::kickPlayerByShortId(std::uint8_t networkSmallId) { EnterCriticalSection(&m_kickPlayersCS); m_smallIdsToKick.push_back(networkSmallId); LeaveCriticalSection(&m_kickPlayersCS); } -void PlayerList::closePlayerConnectionBySmallId(BYTE networkSmallId) +void PlayerList::closePlayerConnectionBySmallId(std::uint8_t networkSmallId) { EnterCriticalSection(&m_closePlayersCS); m_smallIdsToClose.push_back(networkSmallId); diff --git a/Minecraft.Client/Network/PlayerList.h b/Minecraft.Client/Network/PlayerList.h index 1c5bebfc5..50a00ea91 100644 --- a/Minecraft.Client/Network/PlayerList.h +++ b/Minecraft.Client/Network/PlayerList.h @@ -1,4 +1,5 @@ #pragma once +#include #include #include "../../Minecraft.World/Util/ArrayWithLength.h" @@ -30,9 +31,9 @@ private: // 4J Added std::vector m_bannedXuids; - std::deque m_smallIdsToKick; + std::deque m_smallIdsToKick; CRITICAL_SECTION m_kickPlayersCS; - std::deque m_smallIdsToClose; + std::deque m_smallIdsToClose; CRITICAL_SECTION m_closePlayersCS; /* 4J - removed Set bans = new HashSet(); @@ -119,8 +120,8 @@ public: void setAllowCheatsForAllPlayers(bool allowCommands); // 4J Added - void kickPlayerByShortId(BYTE networkSmallId); - void closePlayerConnectionBySmallId(BYTE networkSmallId); + void kickPlayerByShortId(std::uint8_t networkSmallId); + void closePlayerConnectionBySmallId(std::uint8_t networkSmallId); bool isXuidBanned(PlayerUID xuid); // AP added for Vita so the range can be increased once the level starts void setViewDistance(int newViewDistance); diff --git a/Minecraft.Client/Network/ServerChunkCache.cpp b/Minecraft.Client/Network/ServerChunkCache.cpp index c82e26a81..e05c890b1 100644 --- a/Minecraft.Client/Network/ServerChunkCache.cpp +++ b/Minecraft.Client/Network/ServerChunkCache.cpp @@ -664,7 +664,6 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) C4JThread::Event *wakeEvent[3]; // This sets off the threads that are waiting to continue C4JThread::Event *notificationEvent[3]; // These are signalled by the threads to let us know they are complete C4JThread *saveThreads[3]; - DWORD threadId[3]; SaveThreadData threadData[3]; ZeroMemory(&threadData[0], sizeof(SaveThreadData)); ZeroMemory(&threadData[1], sizeof(SaveThreadData)); @@ -687,7 +686,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) } LevelChunk *chunk = NULL; - uint8_t workingThreads; + std::uint8_t workingThreads; bool chunkSet = false; // Created a roughly sorted list to match the order that the files were created in McRegionChunkStorage::McRegionChunkStorage. @@ -739,7 +738,7 @@ bool ServerChunkCache::save(bool force, ProgressListener *progressListener) { char threadName[256]; sprintf(threadName,"Save thread %d\n",j); - SetThreadName(threadId[j], threadName); + SetThreadName(0, threadName); //saveThreads[j] = CreateThread(NULL,0,runSaveThreadProc,&threadData[j],CREATE_SUSPENDED,&threadId[j]); saveThreads[j] = new C4JThread(runSaveThreadProc,(void *)&threadData[j],threadName); @@ -912,9 +911,9 @@ TilePos *ServerChunkCache::findNearestMapFeature(Level *level, const std::wstrin return source->findNearestMapFeature(level, featureName, x, y, z); } -int ServerChunkCache::runSaveThreadProc(LPVOID lpParam) +int ServerChunkCache::runSaveThreadProc(void *lpParam) { - SaveThreadData *params = (SaveThreadData *)lpParam; + SaveThreadData *params = static_cast(lpParam); if(params->useSharedThreadStorage) { diff --git a/Minecraft.Client/Network/ServerChunkCache.h b/Minecraft.Client/Network/ServerChunkCache.h index e5350771b..e127ccd71 100644 --- a/Minecraft.Client/Network/ServerChunkCache.h +++ b/Minecraft.Client/Network/ServerChunkCache.h @@ -97,5 +97,5 @@ private: } SaveThreadData; public: - static int runSaveThreadProc(LPVOID lpParam); + static int runSaveThreadProc(void *lpParam); }; diff --git a/Minecraft.Client/Platform/Common/App_structs.h b/Minecraft.Client/Platform/Common/App_structs.h index 47cc5167c..e73248d9e 100644 --- a/Minecraft.Client/Platform/Common/App_structs.h +++ b/Minecraft.Client/Platform/Common/App_structs.h @@ -1,28 +1,30 @@ #pragma once +#include + typedef struct { wchar_t *wchFilename; eFileExtensionType eEXT; eTMSFileType eTMSType; - PBYTE pbData; - UINT uiSize; + std::uint8_t *pbData; + unsigned int uiSize; int iConfig; // used for texture pack data files } TMS_FILE; typedef struct { - PBYTE pbData; - DWORD dwBytes; - BYTE ucRefCount; + std::uint8_t *pbData; + unsigned int dwBytes; + std::uint8_t ucRefCount; } MEMDATA,*PMEMDATA; typedef struct { - DWORD dwNotification; - UINT uiParam; + unsigned int dwNotification; + unsigned int uiParam; } NOTIFICATION,*PNOTIFICATION; @@ -60,7 +62,7 @@ typedef struct // adding new flags for interim TU to 1.6.6 // A value that encodes the skin that the player has set as their default - DWORD dwSelectedSkin; + std::uint32_t dwSelectedSkin; // In-Menu sensitivity unsigned char ucMenuSensitivity; @@ -90,7 +92,7 @@ typedef struct unsigned int uiSpecialTutorialBitmask; // A value that encodes the cape that the player has set - DWORD dwSelectedCape; + std::uint32_t dwSelectedCape; unsigned int uiFavoriteSkinA[MAX_FAVORITE_SKINS]; unsigned char ucCurrentFavoriteSkinPos; @@ -142,7 +144,7 @@ XuiActionParam; typedef struct { int iSortValue; - UINT uiStringID; + int uiStringID; } TIPSTRUCT; @@ -168,8 +170,8 @@ typedef struct std::wstring wsDisplayName; // add a store for the local DLC image - PBYTE pbImageData; - DWORD dwImageBytes; + std::uint8_t *pbImageData; + unsigned int dwImageBytes; #else ULONGLONG ullOfferID_Full; ULONGLONG ullOfferID_Trial; @@ -194,14 +196,14 @@ FEATURE_DATA; // banned list typedef struct { - BYTE *pBannedList; - DWORD dwBytes; + std::uint8_t *pBannedList; + unsigned int dwBytes; } BANNEDLIST; typedef struct _DLCRequest { - DWORD dwType; + std::uint32_t dwType; eDLCContentState eState; } DLCRequest; @@ -214,13 +216,13 @@ typedef struct _TMSPPRequest C4JStorage::eTMS_FILETYPEVAL eFileTypeVal; //char szFilename[MAX_TMSFILENAME_SIZE]; #ifdef _XBOX_ONE - int( *CallbackFunc)(LPVOID,int,int,LPVOID, WCHAR *); + int( *CallbackFunc)(void *,int,int,void *, WCHAR *); #else - int( *CallbackFunc)(LPVOID,int,int,C4JStorage::PTMSPP_FILEDATA, LPCSTR szFilename); + int( *CallbackFunc)(void *,int,int,C4JStorage::PTMSPP_FILEDATA, LPCSTR szFilename); #endif WCHAR wchFilename[MAX_TMSFILENAME_SIZE]; - LPVOID lpCallbackParam; + void *lpCallbackParam; } TMSPPRequest; diff --git a/Minecraft.Client/Platform/Common/Audio/SoundEngine.h b/Minecraft.Client/Platform/Common/Audio/SoundEngine.h index be31c662c..e45572461 100644 --- a/Minecraft.Client/Platform/Common/Audio/SoundEngine.h +++ b/Minecraft.Client/Platform/Common/Audio/SoundEngine.h @@ -146,7 +146,7 @@ private: int m_MusicType; AUDIO_INFO m_StreamingAudioInfo; std::wstring m_CDMusic; - BOOL m_bSystemMusicPlaying; + bool m_bSystemMusicPlaying; float m_MasterMusicVolume; float m_MasterEffectsVolume; diff --git a/Minecraft.Client/Platform/Common/Colours/ColourTable.cpp b/Minecraft.Client/Platform/Common/Colours/ColourTable.cpp index 18f959d44..294c3f5fd 100644 --- a/Minecraft.Client/Platform/Common/Colours/ColourTable.cpp +++ b/Minecraft.Client/Platform/Common/Colours/ColourTable.cpp @@ -314,20 +314,20 @@ void ColourTable::staticCtor() } } -ColourTable::ColourTable(PBYTE pbData, DWORD dwLength) +ColourTable::ColourTable(std::uint8_t *pbData, std::uint32_t dataLength) { - loadColoursFromData(pbData, dwLength); + loadColoursFromData(pbData, dataLength); } -ColourTable::ColourTable(ColourTable *defaultColours, PBYTE pbData, DWORD dwLength) +ColourTable::ColourTable(ColourTable *defaultColours, std::uint8_t *pbData, std::uint32_t dataLength) { // 4J Stu - Default the colours that of the table passed in XMemCpy( (void *)m_colourValues, (void *)defaultColours->m_colourValues, sizeof(int) * eMinecraftColour_COUNT); - loadColoursFromData(pbData, dwLength); + loadColoursFromData(pbData, dataLength); } -void ColourTable::loadColoursFromData(PBYTE pbData, DWORD dwLength) +void ColourTable::loadColoursFromData(std::uint8_t *pbData, std::uint32_t dataLength) { - byteArray src(pbData, dwLength); + byteArray src(pbData, dataLength); ByteArrayInputStream bais(src); DataInputStream dis(&bais); diff --git a/Minecraft.Client/Platform/Common/Colours/ColourTable.h b/Minecraft.Client/Platform/Common/Colours/ColourTable.h index 5b3e6ee03..8a467e6cd 100644 --- a/Minecraft.Client/Platform/Common/Colours/ColourTable.h +++ b/Minecraft.Client/Platform/Common/Colours/ColourTable.h @@ -1,4 +1,5 @@ #pragma once +#include class ColourTable { @@ -11,13 +12,13 @@ private: public: static void staticCtor(); - ColourTable(PBYTE pbData, DWORD dwLength); - ColourTable(ColourTable *defaultColours, PBYTE pbData, DWORD dwLength); + ColourTable(std::uint8_t *pbData, std::uint32_t dataLength); + ColourTable(ColourTable *defaultColours, std::uint8_t *pbData, std::uint32_t dataLength); unsigned int getColour(eMinecraftColour id); unsigned int getColor(eMinecraftColour id) { return getColour(id); } - void loadColoursFromData(PBYTE pbData, DWORD dwLength); + void loadColoursFromData(std::uint8_t *pbData, std::uint32_t dataLength); void setColour(const std::wstring &colourName, int value); void setColour(const std::wstring &colourName, const std::wstring &value); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/Consoles_App.cpp b/Minecraft.Client/Platform/Common/Consoles_App.cpp index a89d59f90..304e1aa0a 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.cpp +++ b/Minecraft.Client/Platform/Common/Consoles_App.cpp @@ -38,6 +38,7 @@ #include "../Minecraft.World/IO/Streams/InputOutputStream.h" #include "../Minecraft.World/Level/Storage/LevelSettings.h" #include "../Minecraft.Client/Player/User.h" +#include #include "../Minecraft.World/Level/LevelData.h" #include "../Minecraft.World/Headers/net.minecraft.world.entity.player.h" #include "../Minecraft.Client/Rendering/EntityRenderers/EntityRenderDispatcher.h" @@ -101,7 +102,7 @@ CMinecraftApp::CMinecraftApp() { m_eTMSAction[i]=eTMSAction_Idle; m_eXuiAction[i]=eAppAction_Idle; - m_eXuiActionParam[i] = NULL; + m_eXuiActionParam[i] = nullptr; //m_dwAdditionalModelParts[i] = 0; DebugPrintf("Player at index %d has guest number %d\n", i,m_currentSigninInfo[i].dwGuestNumber ); @@ -250,14 +251,14 @@ void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...) va_end(ap); } -LPCWSTR CMinecraftApp::GetString(int iID) +const wchar_t *CMinecraftApp::GetString(int iID) { //return L"DeÄŸiÅŸiklikler ve Yenilikler"; //return L"ÕÕÕÕÖÖÖÖ"; return app.m_stringTable->getString(iID); } -void CMinecraftApp::SetAction(int iPad, eXuiAction action, LPVOID param) +void CMinecraftApp::SetAction(int iPad, eXuiAction action, void *param) { if(m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail && action != eAppAction_Idle) { @@ -723,9 +724,9 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con } #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) -int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad) +int CMinecraftApp::DefaultOptionsCallback(void *pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad) #else -int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad) +int CMinecraftApp::DefaultOptionsCallback(void *pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad) #endif { CMinecraftApp *pApp=(CMinecraftApp *)pParam; @@ -733,7 +734,7 @@ int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETT // flag the default options to be set pApp->DebugPrintf("Setting default options for player %d", iPad); - pApp->SetAction(iPad,eAppAction_SetDefaultOptions, (LPVOID)pSettings); + pApp->SetAction(iPad,eAppAction_SetDefaultOptions, pSettings); //pApp->SetDefaultOptions(pSettings,iPad); // if the profile data has been changed, then force a profile write @@ -746,7 +747,7 @@ int CMinecraftApp::DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETT #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) #ifdef __ORBIS__ -int CMinecraftApp::OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired) +int CMinecraftApp::OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired) { CMinecraftApp *pApp=(CMinecraftApp *)pParam; pApp->m_eOptionsStatusA[iPad]=eStatus; @@ -760,7 +761,7 @@ int CMinecraftApp::GetOptionsBlocksRequired(int iPad) } #else -int CMinecraftApp::OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus) +int CMinecraftApp::OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus) { CMinecraftApp *pApp=(CMinecraftApp *)pParam; pApp->m_eOptionsStatusA[iPad]=eStatus; @@ -779,7 +780,7 @@ void CMinecraftApp::SetOptionsCallbackStatus(int iPad, C4JStorage::eOptionsCallb } #endif -int CMinecraftApp::OldProfileVersionCallback(LPVOID pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad) +int CMinecraftApp::OldProfileVersionCallback(void *pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad) { // check what needs to be done with this version to update to the current one @@ -1243,7 +1244,7 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) break; case eGameSetting_DisplaySplitscreenGamertags: - for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) + for(std::uint8_t idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(pMinecraft->localplayers[idx] != NULL) { @@ -1270,11 +1271,11 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_Tooltips: if((GameSettingsA[iPad]->usBitmaskValues&0x8000)!=0) { - ui.SetEnableTooltips(iPad,TRUE); + ui.SetEnableTooltips(iPad, true); } else { - ui.SetEnableTooltips(iPad,FALSE); + ui.SetEnableTooltips(iPad, false); } break; case eGameSetting_Clouds: @@ -1334,12 +1335,12 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) void CMinecraftApp::SetPlayerSkin(int iPad,const std::wstring &name) { - DWORD skinId = app.getSkinIdFromPath(name); + std::uint32_t skinId = app.getSkinIdFromPath(name); SetPlayerSkin(iPad,skinId); } -void CMinecraftApp::SetPlayerSkin(int iPad,DWORD dwSkinId) +void CMinecraftApp::SetPlayerSkin(int iPad,std::uint32_t dwSkinId) { DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId); @@ -1357,12 +1358,12 @@ std::wstring CMinecraftApp::GetPlayerSkinName(int iPad) return app.getSkinPathFromId(GameSettingsA[iPad]->dwSelectedSkin); } -DWORD CMinecraftApp::GetPlayerSkinId(int iPad) +std::uint32_t CMinecraftApp::GetPlayerSkinId(int iPad) { // 4J-PB -check the user has rights to use this skin - they may have had at some point but the entitlement has been removed. DLCPack *Pack=NULL; DLCSkinFile *skinFile=NULL; - DWORD dwSkin=GameSettingsA[iPad]->dwSelectedSkin; + std::uint32_t dwSkin=GameSettingsA[iPad]->dwSelectedSkin; wchar_t chars[256]; if( GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin) ) @@ -1394,7 +1395,7 @@ DWORD CMinecraftApp::GetPlayerSkinId(int iPad) return dwSkin; } - DWORD CMinecraftApp::GetAdditionalModelParts(int iPad) + std::uint32_t CMinecraftApp::GetAdditionalModelParts(int iPad) { return m_dwAdditionalModelParts[iPad]; } @@ -1402,12 +1403,12 @@ DWORD CMinecraftApp::GetPlayerSkinId(int iPad) void CMinecraftApp::SetPlayerCape(int iPad,const std::wstring &name) { - DWORD capeId = Player::getCapeIdFromPath(name); + std::uint32_t capeId = Player::getCapeIdFromPath(name); SetPlayerCape(iPad,capeId); } -void CMinecraftApp::SetPlayerCape(int iPad,DWORD dwCapeId) +void CMinecraftApp::SetPlayerCape(int iPad,std::uint32_t dwCapeId) { DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId); @@ -1424,7 +1425,7 @@ std::wstring CMinecraftApp::GetPlayerCapeName(int iPad) return Player::getCapePathFromId(GameSettingsA[iPad]->dwSelectedCape); } -DWORD CMinecraftApp::GetPlayerCapeId(int iPad) +std::uint32_t CMinecraftApp::GetPlayerCapeId(int iPad) { return GameSettingsA[iPad]->dwSelectedCape; } @@ -2369,7 +2370,7 @@ int CMinecraftApp::DisplaySavingMessage(void *pParam, C4JStorage::ESavingMessage return 0; } -void CMinecraftApp::SetActionConfirmed(LPVOID param) +void CMinecraftApp::SetActionConfirmed(void *param) { XuiActionParam *actionInfo = (XuiActionParam *)param; app.SetAction(actionInfo->iPad, actionInfo->action); @@ -2380,7 +2381,7 @@ void CMinecraftApp::HandleXuiActions(void) { eXuiAction eAction; eTMSAction eTMS; - LPVOID param; + void *param; Minecraft *pMinecraft=Minecraft::GetInstance(); std::shared_ptr player; @@ -2393,7 +2394,7 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_DisplayLavaMessage: // Display a warning about placing lava in the spawn area { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_CANT_PLACE_NEAR_SPAWN_TITLE, IDS_CANT_PLACE_NEAR_SPAWN_TEXT, uiIDA,1,XUSER_INDEX_ANY,NULL,NULL, app.GetStringTable()); if(result != C4JStorage::EMessage_Busy) SetGlobalXuiAction(eAppAction_Idle); @@ -2479,7 +2480,7 @@ void CMinecraftApp::HandleXuiActions(void) { // ask the player if they would like to upgrade, or they'll lose the level - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2,i,&CMinecraftApp::UnlockFullSaveReturned,this,app.GetStringTable()); @@ -2888,7 +2889,7 @@ void CMinecraftApp::HandleXuiActions(void) else { // ask the player if they would like to upgrade, or they'll lose the level - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; ui.RequestMessageBox(IDS_UNLOCK_TITLE, IDS_UNLOCK_TOSAVE_TEXT, uiIDA, 2, i,&CMinecraftApp::UnlockFullExitReturned,this,app.GetStringTable()); @@ -3191,7 +3192,7 @@ void CMinecraftApp::HandleXuiActions(void) // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game StatsCounter* pStats = Minecraft::GetInstance()->stats[ i ]; pStats->clear(); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST), g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE), uiIDA, 1, i,&CMinecraftApp::EthernetDisconnectReturned,this, app.GetStringTable()); @@ -3209,7 +3210,7 @@ void CMinecraftApp::HandleXuiActions(void) // need to clear the player stats - can't assume it'll be done in setlevel - we may not be in the game StatsCounter* pStats = Minecraft::GetInstance()->stats[ i ]; pStats->clear(); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST), g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE), uiIDA, 1, i,&CMinecraftApp::EthernetDisconnectReturned,this, app.GetStringTable()); @@ -3303,7 +3304,7 @@ void CMinecraftApp::HandleXuiActions(void) case eAppAction_TrialOver: { SetAction(i,eAppAction_Idle); - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_UNLOCK_TITLE; uiIDA[1]=IDS_EXIT_GAME; @@ -3317,7 +3318,7 @@ void CMinecraftApp::HandleXuiActions(void) TelemetryManager->RecordUpsellPresented(i, eSen_UpsellID_Full_Version_Of_Game, app.m_dwOfferID); SetAction(i,eAppAction_Idle); - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; @@ -3326,7 +3327,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_ExitAndJoinFromInvite: { - UINT uiIDA[3]; + unsigned int uiIDA[3]; SetAction(i,eAppAction_Idle); // Check the player really wants to do this @@ -3437,9 +3438,9 @@ void CMinecraftApp::HandleXuiActions(void) } #endif #ifdef _DURANGO - DWORD result = StorageManager.UnmountInstalledDLC(L"TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC(L"TPACK"); #else - DWORD result = StorageManager.UnmountInstalledDLC("TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); #endif app.DebugPrintf("Unmount result is %d\n",result); } @@ -3520,7 +3521,7 @@ void CMinecraftApp::HandleXuiActions(void) //return hr; // 4J Stu - Copied this from XUI_FullScreenProgress to properly handle the fail case, as the thread will no longer be failing - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_CONNECTION_FAILED, IDS_CONNECTION_LOST_SERVER, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); @@ -3669,7 +3670,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_FailedToJoinNoPrivileges: { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); if(result != C4JStorage::EMessage_Busy) SetAction(i,eAppAction_Idle); @@ -3721,7 +3722,7 @@ void CMinecraftApp::HandleXuiActions(void) break; case eAppAction_LevelInBanLevelList: { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_BUTTON_REMOVE_FROM_BAN_LIST; uiIDA[1]=IDS_EXIT_GAME; @@ -3799,7 +3800,7 @@ void CMinecraftApp::HandleXuiActions(void) TelemetryManager->RecordUpsellPresented(ProfileManager.GetPrimaryPad(), eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); #endif - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_TEXTUREPACK_FULLVERSION; uiIDA[1]=IDS_TEXTURE_PACK_TRIALVERSION; @@ -4317,7 +4318,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); if(bContentRestricted) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); } @@ -4331,7 +4332,7 @@ int CMinecraftApp::UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EM else { // you're not signed in to PSN! - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); @@ -4362,7 +4363,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); if(bContentRestricted) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); } @@ -4376,7 +4377,7 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes else { // you're not signed in to PSN! - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); @@ -4390,14 +4391,14 @@ int CMinecraftApp::UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMes // Signed in to PSN but not connected (no internet access) assert(!ProfileManager.isConnectedToPSN(iPad)); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; 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]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable(), NULL, 0, false); } @@ -4427,7 +4428,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); if(bContentRestricted) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); } @@ -4445,7 +4446,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes else { // you're not signed in to PSN! - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial,&app, app.GetStringTable()); @@ -4459,7 +4460,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes // Signed in to PSN but not connected (no internet access) assert(!ProfileManager.isConnectedToPSN(iPad)); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); // still need to exit the trial or we'll be in the Pause menu with input ignored @@ -4468,7 +4469,7 @@ int CMinecraftApp::UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMes else { // Not signed in to PSN - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPad, &CMinecraftApp::MustSignInFullVersionPurchaseReturnedExitTrial,&app, app.GetStringTable(), NULL, 0, false); } @@ -4500,7 +4501,7 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); if(bContentRestricted) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,&app, app.GetStringTable()); } @@ -4515,7 +4516,7 @@ int CMinecraftApp::TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageR #if defined(__PS3__) // you're not signed in to PSN! - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::MustSignInFullVersionPurchaseReturned,&app, app.GetStringTable()); @@ -4569,7 +4570,7 @@ void CMinecraftApp::ClearSignInChangeUsersMask() } } } -void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChanged,unsigned int uiSignInData) +void CMinecraftApp::SignInChangeCallback(void *pParam,bool bPrimaryPlayerChanged,unsigned int uiSignInData) { #ifdef __PS3__ // this is normally set in the main menu, but we can go online in the create world screens, and the primary player name isn't updated @@ -4604,7 +4605,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange bool hasGuestIdChanged = false; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { - DWORD guestNumber = 0; + unsigned int guestNumber = 0; if(ProfileManager.IsSignedIn(i)) { XUSER_SIGNIN_INFO info; @@ -4620,7 +4621,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange if( hasGuestIdChanged ) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_GUEST_ORDER_CHANGED_TITLE, IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,NULL,app.GetStringTable()); } @@ -4744,7 +4745,7 @@ void CMinecraftApp::SignInChangeCallback(LPVOID pParam,bool bPrimaryPlayerChange } } -void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, unsigned int uiParam) +void CMinecraftApp::NotificationsCallback(void *pParam,std::uint32_t dwNotification, unsigned int uiParam) { CMinecraftApp* pClass = (CMinecraftApp*)pParam; @@ -4813,7 +4814,7 @@ void CMinecraftApp::NotificationsCallback(LPVOID pParam,DWORD dwNotification, un { pDLCTexPack->m_pSoundBank->Destroy(); } - DWORD result = StorageManager.UnmountInstalledDLC("TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); app.DebugPrintf("Unmount result is %d\n",result); } } @@ -4869,12 +4870,12 @@ int CMinecraftApp::NowDisplayFullVersionPurchase(void *pParam, bool bContinue, i return 0; } #endif -void CMinecraftApp::UpsellReturnedCallback(LPVOID pParam, eUpsellType type, eUpsellResponse result, int iUserData) +void CMinecraftApp::UpsellReturnedCallback(void *pParam, eUpsellType type, eUpsellResponse result, int iUserData) { ESen_UpsellID senType; ESen_UpsellOutcome senResponse; #ifdef __PS3__ - UINT uiIDA[2]; + unsigned int uiIDA[2]; #endif // Map the eUpsellResponse to the enum we use for sentient @@ -4926,7 +4927,7 @@ void CMinecraftApp::SetDebugSequence(const char *pchSeq) { InputManager.SetDebugSequence(pchSeq,&CMinecraftApp::DebugInputCallback,this); } -int CMinecraftApp::DebugInputCallback(LPVOID pParam) +int CMinecraftApp::DebugInputCallback(void *pParam) { CMinecraftApp* pClass = (CMinecraftApp*)pParam; //printf("sequence matched\n"); @@ -4963,7 +4964,7 @@ int CMinecraftApp::GetLocalPlayerCount(void) return iPlayerC; } -int CMinecraftApp::MarketplaceCountsCallback(LPVOID pParam,C4JStorage::DLC_TMS_DETAILS *pTMSDetails, int iPad) +int CMinecraftApp::MarketplaceCountsCallback(void *pParam,C4JStorage::DLC_TMS_DETAILS *pTMSDetails, int iPad) { app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",pTMSDetails->dwNewOffers,pTMSDetails->dwTotalOffers); @@ -5008,7 +5009,7 @@ bool CMinecraftApp::StartInstallDLCProcess(int iPad) } // Installed DLC callback -int CMinecraftApp::DLCInstalledCallback(LPVOID pParam,int iInstalledC,int iPad) +int CMinecraftApp::DLCInstalledCallback(void *pParam,int iInstalledC,int iPad) { app.DebugPrintf("--- CMinecraftApp::DLCInstalledCallback: totalDLC=%i, pad=%i.\n", iInstalledC, iPad); app.m_iTotalDLC = iInstalledC; @@ -5077,7 +5078,7 @@ void CMinecraftApp::MountNextDLC(int iPad) #define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName) #endif -int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask) +int CMinecraftApp::DLCMountedCallback(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask) { #if defined(_XBOX) || defined(_DURANGO) || defined(__PS3__) || defined(__ORBIS__) || defined(_WINDOWS64) || defined (__PSVITA__) //Chris TODO app.DebugPrintf("--- CMinecraftApp::DLCMountedCallback\n"); @@ -5085,7 +5086,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d if(dwErr!=ERROR_SUCCESS) { // corrupt DLC - app.DebugPrintf("Failed to mount DLC for pad %d: %d\n",iPad,dwErr); + app.DebugPrintf("Failed to mount DLC for pad %d: %u\n",iPad,dwErr); app.m_dlcManager.incrementUnnamedCorruptCount(); } else @@ -5126,7 +5127,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d } else { - app.DebugPrintf("Pack \"%ls\" is already installed. Updating license to %d\n", CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask); + app.DebugPrintf("Pack \"%ls\" is already installed. Updating license to %u\n", CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask); pack->SetDLCMountIndex(app.m_iTotalDLCInstalled); pack->SetDLCDeviceID(ContentData.DeviceID); @@ -5172,7 +5173,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d void CMinecraftApp::HandleDLC(DLCPack *pack) { - DWORD dwFilesProcessed = 0; + unsigned int dwFilesProcessed = 0; #ifndef _XBOX #if defined(__PS3__) || defined(__ORBIS__) || defined(_WINDOWS64) || defined (__PSVITA__) || defined(__linux__) std::vector dlcFilenames; @@ -5211,7 +5212,7 @@ int CMinecraftApp::DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD d if(( GetFileAttributes( szFullFilename ) & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) { #ifdef _XBOX - DWORD dwPackID=m_dlcManager.retrievePackIDFromDLCDataFile(szFullFilename,pack); + std::uint32_t dwPackID=m_dlcManager.retrievePackIDFromDLCDataFile(szFullFilename,pack); // Do we need to override the TexturePack.pck with an updated version in a TU? std::wstring wsTemp=getFilePath(dwPackID, std::wstring(L"TexturePack.pck"),false ); @@ -5298,7 +5299,7 @@ bool CMinecraftApp::isXuidNotch(PlayerUID xuid) { if(m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) { - return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch) == TRUE; + return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch); } return false; } @@ -5318,7 +5319,7 @@ bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) return false; } -void CMinecraftApp::AddMemoryTextureFile(const std::wstring &wName,PBYTE pbData,DWORD dwBytes) +void CMinecraftApp::AddMemoryTextureFile(const std::wstring &wName, std::uint8_t *pbData, unsigned int dwBytes) { EnterCriticalSection(&csMemFilesLock); // check it's not already in @@ -5413,7 +5414,7 @@ bool CMinecraftApp::IsFileInMemoryTextures(const std::wstring &wName) return val; } -void CMinecraftApp::GetMemFileDetails(const std::wstring &wName,PBYTE *ppbData,DWORD *pdwBytes) +void CMinecraftApp::GetMemFileDetails(const std::wstring &wName, std::uint8_t **ppbData, unsigned int *pdwBytes) { EnterCriticalSection(&csMemFilesLock); AUTO_VAR(it, m_MEM_Files.find(wName)); @@ -5426,7 +5427,7 @@ void CMinecraftApp::GetMemFileDetails(const std::wstring &wName,PBYTE *ppbData,D LeaveCriticalSection(&csMemFilesLock); } -void CMinecraftApp::AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes) +void CMinecraftApp::AddMemoryTPDFile(int iConfig, std::uint8_t *pbData, unsigned int dwBytes) { EnterCriticalSection(&csMemTPDLock); // check it's not already in @@ -5515,7 +5516,7 @@ bool CMinecraftApp::IsFileInTPD(int iConfig) return val; } -void CMinecraftApp::GetTPD(int iConfig,PBYTE *ppbData,DWORD *pdwBytes) +void CMinecraftApp::GetTPD(int iConfig, std::uint8_t **ppbData, unsigned int *pdwBytes) { EnterCriticalSection(&csMemTPDLock); AUTO_VAR(it, m_MEM_TPD.find(iConfig)); @@ -5568,7 +5569,7 @@ void CMinecraftApp::ExitGame() // Invites -void CMinecraftApp::ProcessInvite(DWORD dwUserIndex, DWORD dwLocalUsersMask, const INVITE_INFO * pInviteInfo) +void CMinecraftApp::ProcessInvite(std::uint32_t dwUserIndex, std::uint32_t dwLocalUsersMask, const INVITE_INFO * pInviteInfo) { m_InviteData.dwUserIndex=dwUserIndex; m_InviteData.dwLocalUsersMask=dwLocalUsersMask; @@ -5621,7 +5622,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); #endif - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; @@ -5639,7 +5640,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad // we need to ask if they are sure they want to overwrite the existing game if(bSaveExists) { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned,pClass, app.GetStringTable()); @@ -5657,7 +5658,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad else { // been a few requests for a confirm on exit without saving - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CMinecraftApp::ExitAndJoinFromInviteDeclineSaveReturned,pClass, app.GetStringTable()); @@ -5731,7 +5732,7 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4 TelemetryManager->RecordUpsellPresented(iPad, eSet_UpsellID_Texture_DLC, ullOfferID_Full & 0xFFFFFFFF); #endif - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; @@ -5882,7 +5883,7 @@ void CMinecraftApp::InitialiseTips() { // We'll randomise the tips at start up based on their priority - ZeroMemory(m_TipIDA,sizeof(UINT)*MAX_TIPS_GAMETIP+MAX_TIPS_TRIVIATIP); + ZeroMemory(m_TipIDA, sizeof(m_TipIDA)); // Make the first tip tell you that you can play splitscreen in HD modes if you are in SD if(!RenderManager.IsHiDef()) @@ -5946,7 +5947,7 @@ void CMinecraftApp::InitialiseTips() m_uiCurrentTip=0; } -UINT CMinecraftApp::GetNextTip() +int CMinecraftApp::GetNextTip() { static bool bShowSkinDLCTip=true; // don't display the DLC tip in the trial game @@ -7044,11 +7045,11 @@ int CMinecraftApp::RemoteSaveThreadProc( void* lpParameter ) return 0; } -void CMinecraftApp::ExitGameFromRemoteSave( LPVOID lpParameter ) +void CMinecraftApp::ExitGameFromRemoteSave( void *lpParameter ) { int primaryPad = ProfileManager.GetPrimaryPad(); - UINT uiIDA[3]; + unsigned int uiIDA[3]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; @@ -7146,8 +7147,9 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps if(bWriteToTMS) { - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); - PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new CHAR [dwDataBytes]); + const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); + const unsigned int dataBytes = static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); + PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; int iCount=0; for(AUTO_VAR(it, m_vBannedListA[iPad]->begin()); it != m_vBannedListA[iPad]->end(); ++it) { @@ -7157,12 +7159,13 @@ void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, char *ps // 4J-PB - write to TMS++ now - //bool bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dwDataBytes); + //bool bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dataBytes); #ifdef _XBOX - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,C4JStorage::TMS_UGCTYPE_NONE,"BannedList",(PCHAR) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,C4JStorage::TMS_UGCTYPE_NONE,"BannedList",(PCHAR) pBannedList, dataBytes,NULL,NULL, 0); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dataBytes,NULL,NULL, 0); #endif + delete[] pBannedList; } // update telemetry too } @@ -7221,8 +7224,9 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha } } - DWORD dwDataBytes=(DWORD)(sizeof(BANNEDLISTDATA)*m_vBannedListA[iPad]->size()); - if(dwDataBytes==0) + const std::size_t bannedListCount = m_vBannedListA[iPad]->size(); + const unsigned int dataBytes = static_cast(sizeof(BANNEDLISTDATA) * bannedListCount); + if(dataBytes==0) { // wipe the file #ifdef _XBOX @@ -7233,19 +7237,18 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha } else { - PBANNEDLISTDATA pBannedList = (BANNEDLISTDATA *)(new BYTE [dwDataBytes]); + PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount]; - int iSize=(int)m_vBannedListA[iPad]->size(); - for(int i=0;iat(i); memcpy(&pBannedList[i],pBannedListData,sizeof(BANNEDLISTDATA)); } #ifdef _XBOX - StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dwDataBytes); + StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(PBYTE)pBannedList, dataBytes); #elif defined _XBOX_ONE - StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dwDataBytes,NULL,NULL, 0); + StorageManager.TMSPP_WriteFile(iPad,C4JStorage::eGlobalStorage_TitleUser,C4JStorage::TMS_FILETYPE_BINARY,L"BannedList",(PBYTE) pBannedList, dataBytes,NULL,NULL, 0); #endif delete [] pBannedList; } @@ -7254,7 +7257,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, cha } // function to add credits for the DLC packs -void CMinecraftApp::AddCreditText(LPCWSTR lpStr) +void CMinecraftApp::AddCreditText(const wchar_t *lpStr) { DebugPrintf("ADDING CREDIT - %ls\n",lpStr); // add a string from the DLC to a credits vector @@ -7619,7 +7622,7 @@ void CMinecraftApp::setLevelGenerationOptions(LevelGenerationOptions *levelGen) m_gameRules.setLevelGenerationOptions(levelGen); } -LPCWSTR CMinecraftApp::GetGameRulesString(const std::wstring &key) +const wchar_t *CMinecraftApp::GetGameRulesString(const std::wstring &key) { return m_gameRules.GetGameRulesString(key); } @@ -7645,9 +7648,16 @@ unsigned int CMinecraftApp::FromBigEndian(unsigned int uiValue) #endif } -void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsigned char *pszSeed,unsigned int &uiHostOptions,bool &bHostOptionsRead,DWORD &uiTexturePack) +void CMinecraftApp::GetImageTextData(std::uint8_t *imageData, unsigned int imageBytes, unsigned char *seedText, unsigned int &uiHostOptions, bool &bHostOptionsRead, std::uint32_t &uiTexturePack) { - unsigned char *ucPtr=pbImageData; + auto readPngUInt32 = [](const std::uint8_t *data) -> unsigned int + { + unsigned int value = 0; + std::memcpy(&value, data, sizeof(value)); + return value; + }; + + std::uint8_t *ucPtr = imageData; unsigned int uiCount=0; unsigned int uiChunkLen; unsigned int uiChunkType; @@ -7662,13 +7672,11 @@ void CMinecraftApp::GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsig uiCount+=8; - while(uiCountdwSize]; + std::uint8_t *pbData = new std::uint8_t[pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); pClass->m_vTMSPPData.push_back(pbData); @@ -8342,7 +8349,7 @@ int CMinecraftApp::TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JSto 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]; + std::uint8_t *pbData = new std::uint8_t[pFileData->dwSize]; memcpy(pbData,pFileData->pbData,pFileData->dwSize); pClass->m_vTMSPPData.push_back(pbData); @@ -8559,7 +8566,7 @@ void CMinecraftApp::ClearTMSPPFilesRetrieved() LeaveCriticalSection(&csTMSPPDownloadQueue); } -int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, int iPad) +int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, std::uint32_t dwType, int iPad) { CMinecraftApp* pClass = (CMinecraftApp *) pParam; @@ -8570,10 +8577,10 @@ int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, in DLCRequest *pCurrent = *it; // avatar items are coming back as type Content, so we can't trust the type setting - if(pCurrent->dwType==dwType) + if(pCurrent->dwType == static_cast(dwType)) { pClass->m_iDLCOfferC = iOfferC; - app.DebugPrintf("DLCOffersReturned - type %d, count %d - setting to retrieved\n",dwType,iOfferC); + app.DebugPrintf("DLCOffersReturned - type %u, count %d - setting to retrieved\n",dwType,iOfferC); pCurrent->eState=e_DLC_ContentState_Retrieved; break; } @@ -8582,7 +8589,7 @@ int CMinecraftApp::DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, in return 0; } -eDLCContentType CMinecraftApp::Find_eDLCContentType(DWORD dwType) +eDLCContentType CMinecraftApp::Find_eDLCContentType(std::uint32_t dwType) { for(int i=0;igetRenderer(eTYPE_PLAYER); Model *pModel = renderer->getModel(); @@ -8636,15 +8643,15 @@ void CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, D } - m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); - m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxes) ); + m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); + m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxes) ); LeaveCriticalSection( &csAdditionalSkinBoxes ); LeaveCriticalSection( &csAdditionalModelParts ); } -std::vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, std::vector *pvSkinBoxA) +std::vector * CMinecraftApp::SetAdditionalSkinBoxes(std::uint32_t dwSkinID, std::vector *pvSkinBoxA) { EntityRenderer *renderer = EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER); Model *pModel = renderer->getModel(); @@ -8664,8 +8671,8 @@ std::vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, } } - m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); - m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxA) ); + m_AdditionalModelParts.insert( std::pair *>(dwSkinID, pvModelPart) ); + m_AdditionalSkinBoxes.insert( std::pair *>(dwSkinID, pvSkinBoxA) ); LeaveCriticalSection( &csAdditionalSkinBoxes ); LeaveCriticalSection( &csAdditionalModelParts ); @@ -8673,7 +8680,7 @@ std::vector * CMinecraftApp::SetAdditionalSkinBoxes(DWORD dwSkinID, } -std::vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) +std::vector *CMinecraftApp::GetAdditionalModelParts(std::uint32_t dwSkinID) { EnterCriticalSection( &csAdditionalModelParts ); std::vector *pvModelParts=NULL; @@ -8690,7 +8697,7 @@ std::vector *CMinecraftApp::GetAdditionalModelParts(DWORD dwSkinID) return pvModelParts; } -std::vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) +std::vector *CMinecraftApp::GetAdditionalSkinBoxes(std::uint32_t dwSkinID) { EnterCriticalSection( &csAdditionalSkinBoxes ); std::vector *pvSkinBoxes=NULL; @@ -8707,7 +8714,7 @@ std::vector *CMinecraftApp::GetAdditionalSkinBoxes(DWORD dwSkinID) return pvSkinBoxes; } -unsigned int CMinecraftApp::GetAnimOverrideBitmask(DWORD dwSkinID) +unsigned int CMinecraftApp::GetAnimOverrideBitmask(std::uint32_t dwSkinID) { EnterCriticalSection( &csAnimOverrideBitmask ); unsigned int uiAnimOverrideBitmask=0L; @@ -8725,7 +8732,7 @@ unsigned int CMinecraftApp::GetAnimOverrideBitmask(DWORD dwSkinID) return uiAnimOverrideBitmask; } -void CMinecraftApp::SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOverrideBitmask) +void CMinecraftApp::SetAnimOverrideBitmask(std::uint32_t dwSkinID,unsigned int uiAnimOverrideBitmask) { // Make thread safe EnterCriticalSection( &csAnimOverrideBitmask ); @@ -8739,11 +8746,11 @@ void CMinecraftApp::SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOve return; // already in here } } - m_AnimOverrides.insert( std::pair(dwSkinID, uiAnimOverrideBitmask) ); + m_AnimOverrides.insert( std::pair(dwSkinID, uiAnimOverrideBitmask) ); LeaveCriticalSection( &csAnimOverrideBitmask ); } -DWORD CMinecraftApp::getSkinIdFromPath(const std::wstring &skin) +std::uint32_t CMinecraftApp::getSkinIdFromPath(const std::wstring &skin) { bool dlcSkin = false; unsigned int skinId = 0; @@ -8769,7 +8776,7 @@ DWORD CMinecraftApp::getSkinIdFromPath(const std::wstring &skin) return skinId; } -std::wstring CMinecraftApp::getSkinPathFromId(DWORD skinId) +std::wstring CMinecraftApp::getSkinPathFromId(std::uint32_t skinId) { // 4J Stu - This function maps the encoded DWORD we store in the player profile // to a filename that is stored as a memory texture and shared between systems in game @@ -8782,8 +8789,8 @@ std::wstring CMinecraftApp::getSkinPathFromId(DWORD skinId) } else { - DWORD ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); - DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); + std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); + std::uint32_t defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); if( ugcSkinIndex == 0 ) { swprintf(chars, 256, L"defskin%08X.png",defaultSkinIndex); @@ -8927,7 +8934,7 @@ float CMinecraftApp::getTrialTimer(void) bool CMinecraftApp::IsLocalMultiplayerAvailable() { - DWORD connectedControllers = 0; + unsigned int connectedControllers = 0; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; @@ -8967,12 +8974,12 @@ void CMinecraftApp::getLocale(std::vector &vecWstrLocales) { std::vector locales; - DWORD dwSystemLanguage = XGetLanguage( ); + const unsigned int systemLanguage = XGetLanguage( ); // 4J-PB - restrict the 360 language until we're ready to have them in #ifdef _XBOX - switch(dwSystemLanguage) + switch(systemLanguage) { case XC_LANGUAGE_FRENCH : locales.push_back(eMCLang_frFR); @@ -9004,7 +9011,7 @@ void CMinecraftApp::getLocale(std::vector &vecWstrLocales) break; } #else - switch(dwSystemLanguage) + switch(systemLanguage) { case XC_LANGUAGE_ENGLISH: @@ -9197,13 +9204,13 @@ void CMinecraftApp::getLocale(std::vector &vecWstrLocales) } } -DWORD CMinecraftApp::get_eMCLang(WCHAR *pwchLocale) +int CMinecraftApp::get_eMCLang(WCHAR *pwchLocale) { return m_eMCLangA[pwchLocale]; } -DWORD CMinecraftApp::get_xcLang(WCHAR *pwchLocale) +int CMinecraftApp::get_xcLang(WCHAR *pwchLocale) { return m_xcLangA[pwchLocale]; } @@ -9409,7 +9416,7 @@ void CMinecraftApp::SetTickTMSDLCFiles(bool bVal) m_bTickTMSDLCFiles=bVal; } -std::wstring CMinecraftApp::getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder) +std::wstring CMinecraftApp::getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder) { #ifdef _XBOX std::wstring path = getRootPath(packId, true, bAddDataFolder) + filename; @@ -9445,7 +9452,7 @@ std::wstring titleUpdateTexturePackRoot = L"GAME:\\res\\TitleUpdate\\DLC\\"; #endif #endif -std::wstring CMinecraftApp::getRootPath(DWORD packId, bool allowOverride, bool bAddDataFolder) +std::wstring CMinecraftApp::getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder) { std::wstring path = L"TPACK:"; #ifdef _XBOX diff --git a/Minecraft.Client/Platform/Common/Consoles_App.h b/Minecraft.Client/Platform/Common/Consoles_App.h index d0f2d1700..4b8807399 100644 --- a/Minecraft.Client/Platform/Common/Consoles_App.h +++ b/Minecraft.Client/Platform/Common/Consoles_App.h @@ -1,5 +1,7 @@ #pragma once +#include + //using namespace std; #include "Audio/Consoles_SoundEngine.h" @@ -28,8 +30,8 @@ typedef struct _JoinFromInviteData { - DWORD dwUserIndex; // dwUserIndex - DWORD dwLocalUsersMask; // dwUserMask + std::uint32_t dwUserIndex; // dwUserIndex + std::uint32_t dwLocalUsersMask; // dwUserMask const INVITE_INFO *pInviteInfo; // pInviteInfo } JoinFromInviteData; @@ -124,7 +126,7 @@ public: bool IsAppPaused(); void SetAppPaused(bool val); - static int DisplaySavingMessage(LPVOID pParam,const C4JStorage::ESavingMessage eMsg, int iPad); + static int DisplaySavingMessage(void *pParam,const C4JStorage::ESavingMessage eMsg, int iPad); bool GetGameStarted() {return m_bGameStarted;} void SetGameStarted(bool bVal) { if(bVal) DebugPrintf("SetGameStarted - true\n"); else DebugPrintf("SetGameStarted - false\n"); m_bGameStarted = bVal; m_bIsAppPaused = !bVal;} int GetLocalPlayerCount(void); @@ -146,7 +148,7 @@ public: void SetSpecialTutorialCompletionFlag(int iPad, int index); - static LPCWSTR GetString(int iID); + static const wchar_t * GetString(int iID); eGameMode GetGameMode() { return m_eGameMode;} void SetGameMode(eGameMode eMode) { m_eGameMode=eMode;} @@ -154,12 +156,12 @@ public: eXuiAction GetGlobalXuiAction() {return m_eGlobalXuiAction;} void SetGlobalXuiAction(eXuiAction action) {m_eGlobalXuiAction=action;} eXuiAction GetXuiAction(int iPad) {return m_eXuiAction[iPad];} - void SetAction(int iPad, eXuiAction action, LPVOID param = NULL); + void SetAction(int iPad, eXuiAction action, void *param = nullptr); void SetTMSAction(int iPad, eTMSAction action) {m_eTMSAction[iPad]=action; } eTMSAction GetTMSAction(int iPad) {return m_eTMSAction[iPad];} eXuiServerAction GetXuiServerAction(int iPad) {return m_eXuiServerAction[iPad];} - LPVOID GetXuiServerActionParam(int iPad) {return m_eXuiServerActionParam[iPad];} - void SetXuiServerAction(int iPad, eXuiServerAction action, LPVOID param = NULL) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;} + void * GetXuiServerActionParam(int iPad) {return m_eXuiServerActionParam[iPad];} + void SetXuiServerAction(int iPad, eXuiServerAction action, void *param = nullptr) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;} eXuiServerAction GetGlobalXuiServerAction() {return m_eGlobalXuiServerAction;} void SetGlobalXuiServerAction(eXuiServerAction action) {m_eGlobalXuiServerAction=action;} @@ -174,7 +176,7 @@ public: // 4J Stu - Added so that we can call this when a confirmation box is selected - static void SetActionConfirmed(LPVOID param); + static void SetActionConfirmed(void *param); void HandleXuiActions(void); // 4J Stu - Functions used for Minecon and other promo work @@ -206,23 +208,23 @@ public: //void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE *preview); void InitGameSettings(); - static int OldProfileVersionCallback(LPVOID pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad); + static int OldProfileVersionCallback(void *pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad); #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ ) - static int DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad); + static int DefaultOptionsCallback(void *pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad); int SetDefaultOptions(C4JStorage::PROFILESETTINGS *pSettings,const int iPad,bool bWriteProfile=true); #ifdef __ORBIS__ - static int OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired); + static int OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired); int GetOptionsBlocksRequired(int iPad); #else - static int OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus); + static int OptionsDataCallback(void *pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus); #endif C4JStorage::eOptionsCallback GetOptionsCallbackStatus(int iPad); void SetOptionsCallbackStatus(int iPad, C4JStorage::eOptionsCallback eStatus); #else - static int DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad); + static int DefaultOptionsCallback(void *pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad); int SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,const int iPad); #endif virtual void SetRichPresenceContext(int iPad, int contextId) = 0; @@ -232,9 +234,9 @@ public: unsigned char GetGameSettings(int iPad,eGameSetting eVal); unsigned char GetGameSettings(eGameSetting eVal); // for the primary pad void SetPlayerSkin(int iPad,const std::wstring &name); - void SetPlayerSkin(int iPad,DWORD dwSkinId); + void SetPlayerSkin(int iPad,std::uint32_t dwSkinId); void SetPlayerCape(int iPad,const std::wstring &name); - void SetPlayerCape(int iPad,DWORD dwCapeId); + void SetPlayerCape(int iPad,std::uint32_t dwCapeId); void SetPlayerFavoriteSkin(int iPad, int iIndex,unsigned int uiSkinID); unsigned int GetPlayerFavoriteSkin(int iPad,int iIndex); unsigned char GetPlayerFavoriteSkinsPos(int iPad); @@ -259,10 +261,10 @@ public: public: std::wstring GetPlayerSkinName(int iPad); - DWORD GetPlayerSkinId(int iPad); + std::uint32_t GetPlayerSkinId(int iPad); std::wstring GetPlayerCapeName(int iPad); - DWORD GetPlayerCapeId(int iPad); - DWORD GetAdditionalModelParts(int iPad); + std::uint32_t GetPlayerCapeId(int iPad); + std::uint32_t GetAdditionalModelParts(int iPad); void CheckGameSettingsChanged(bool bOverride5MinuteTimer=false, int iPad=XUSER_INDEX_ANY); void ApplyGameSettingsChanged(int iPad); void ClearGameSettingsChangedFlag(int iPad); @@ -275,7 +277,7 @@ public: bool IsLocalMultiplayerAvailable(); // for sign in change monitoring - static void SignInChangeCallback(LPVOID pParam, bool bVal, unsigned int uiSignInData); + static void SignInChangeCallback(void *pParam, bool bVal, unsigned int uiSignInData); static void ClearSignInChangeUsersMask(); static int SignoutExitWorldThreadProc( void* lpParameter ); static int PrimaryPlayerSignedOutReturned(void *pParam, int iPad, const C4JStorage::EMessageResult); @@ -286,14 +288,14 @@ public: virtual void FatalLoadError(); // Notifications from the game listener to be passed to the qnet listener - static void NotificationsCallback(LPVOID pParam,DWORD dwNotification, unsigned int uiParam); + static void NotificationsCallback(void *pParam,std::uint32_t dwNotification, unsigned int uiParam); // for the ethernet being disconnected - static void LiveLinkChangeCallback(LPVOID pParam,BOOL bConnected); + static void LiveLinkChangeCallback(void *pParam,BOOL bConnected); bool GetLiveLinkRequired() {return m_bLiveLinkRequired;} void SetLiveLinkRequired(bool required) {m_bLiveLinkRequired=required;} - static void UpsellReturnedCallback(LPVOID pParam, eUpsellType type, eUpsellResponse result, int iUserData); + static void UpsellReturnedCallback(void *pParam, eUpsellType type, eUpsellResponse result, int iUserData); #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ static int NowDisplayFullVersionPurchase(void *pParam, bool bContinue, int iPad); @@ -309,21 +311,21 @@ public: bool DebugSettingsOn() { return false;} #endif void SetDebugSequence(const char *pchSeq); - static int DebugInputCallback(LPVOID pParam); + static int DebugInputCallback(void *pParam); //bool UploadFileToGlobalStorage(int iQuadrant, C4JStorage::eGlobalStorage eStorageFacility, std::wstring *wsFile ); // Installed DLC bool StartInstallDLCProcess(int iPad); - static int DLCInstalledCallback(LPVOID pParam,int iOfferC,int iPad); + static int DLCInstalledCallback(void *pParam,int iOfferC,int iPad); void HandleDLCLicenseChange(); - static int DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask); + static int DLCMountedCallback(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask); void MountNextDLC(int iPad); //static int DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS *pDLCData); void HandleDLC(DLCPack *pack); bool DLCInstallPending() {return m_bDLCInstallPending;} bool DLCInstallProcessCompleted() {return m_bDLCInstallProcessCompleted;} void ClearDLCInstalled() { m_bDLCInstallProcessCompleted=false;} - static int MarketplaceCountsCallback(LPVOID pParam,C4JStorage::DLC_TMS_DETAILS *,int iPad); + static int MarketplaceCountsCallback(void *pParam,C4JStorage::DLC_TMS_DETAILS *,int iPad); bool AlreadySeenCreditText(const std::wstring &wstemp); @@ -339,16 +341,16 @@ public: bool isXuidNotch(PlayerUID xuid); bool isXuidDeadmau5(PlayerUID xuid); - void AddMemoryTextureFile(const std::wstring &wName, PBYTE pbData, DWORD dwBytes); + void AddMemoryTextureFile(const std::wstring &wName, std::uint8_t *pbData, unsigned int dwBytes); void RemoveMemoryTextureFile(const std::wstring &wName); - void GetMemFileDetails(const std::wstring &wName,PBYTE *ppbData,DWORD *pdwBytes); + void GetMemFileDetails(const std::wstring &wName, std::uint8_t **ppbData, unsigned int *pdwBytes); bool IsFileInMemoryTextures(const std::wstring &wName); // Texture Pack Data files (icon, banner, comparison shot & text) - void AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes); + void AddMemoryTPDFile(int iConfig, std::uint8_t *pbData, unsigned int dwBytes); void RemoveMemoryTPDFile(int iConfig); bool IsFileInTPD(int iConfig); - void GetTPD(int iConfig,PBYTE *ppbData,DWORD *pdwBytes); + void GetTPD(int iConfig, std::uint8_t **ppbData, unsigned int *pdwBytes); int GetTPDSize() {return m_MEM_TPD.size();} #ifndef __PS3__ int GetTPConfigVal(WCHAR *pwchDataFile); @@ -359,17 +361,17 @@ public: // invites //void ProcessInvite(JoinFromInviteData *pJoinData); - void ProcessInvite(DWORD dwUserIndex, DWORD dwLocalUsersMask, const INVITE_INFO * pInviteInfo); + void ProcessInvite(std::uint32_t dwUserIndex, std::uint32_t dwLocalUsersMask, const INVITE_INFO * pInviteInfo); // Add credits for DLC installed - void AddCreditText(LPCWSTR lpStr); + void AddCreditText(const wchar_t *lpStr); private: PlayerUID m_xuidNotch; #ifdef _DURANGO - std::unordered_map m_GTS_Files; + std::unordered_map m_GTS_Files; #else - std::unordered_map m_GTS_Files; + std::unordered_map m_GTS_Files; #endif // for storing memory textures - player skin @@ -383,8 +385,8 @@ private: public: // launch data - BYTE* m_pLaunchData; - DWORD m_dwLaunchDataSize; + std::uint8_t *m_pLaunchData; + unsigned int m_dwLaunchDataSize; public: // BAN LIST @@ -503,10 +505,10 @@ private: // we'll action these at the end of the game loop eXuiAction m_eXuiAction[XUSER_MAX_COUNT]; eTMSAction m_eTMSAction[XUSER_MAX_COUNT]; - LPVOID m_eXuiActionParam[XUSER_MAX_COUNT]; + void *m_eXuiActionParam[XUSER_MAX_COUNT]; eXuiAction m_eGlobalXuiAction; eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT]; - LPVOID m_eXuiServerActionParam[XUSER_MAX_COUNT]; + void *m_eXuiServerActionParam[XUSER_MAX_COUNT]; eXuiServerAction m_eGlobalXuiServerAction; bool m_bLiveLinkRequired; @@ -547,7 +549,7 @@ protected: static Random *TipRandom; public: void InitialiseTips(); - UINT GetNextTip(); + int GetNextTip(); int GetHTMLColour(eMinecraftColour colour); int GetHTMLColor(eMinecraftColour colour) { return GetHTMLColour(colour); } int GetHTMLFontSize(EHTMLFontSize size); @@ -560,11 +562,11 @@ public: void UpdateTrialPausedTimer() { mfTrialPausedTime+= m_Time.fElapsedTime;} static int RemoteSaveThreadProc( void* lpParameter ); - static void ExitGameFromRemoteSave( LPVOID lpParameter ); + static void ExitGameFromRemoteSave( void *lpParameter ); static int ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); private: - UINT m_TipIDA[MAX_TIPS_GAMETIP+MAX_TIPS_TRIVIATIP]; - UINT m_uiCurrentTip; + int m_TipIDA[MAX_TIPS_GAMETIP+MAX_TIPS_TRIVIATIP]; + unsigned int m_uiCurrentTip; static int TipsSortFunction(const void* a, const void* b); // XML @@ -608,9 +610,9 @@ public: // images for save thumbnail/social post virtual void CaptureSaveThumbnail() =0; - virtual void GetSaveThumbnail(PBYTE*,DWORD*)=0; + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize)=0; virtual void ReleaseSaveThumbnail()=0; - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize)=0; + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize)=0; virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false)=0; @@ -703,8 +705,8 @@ public: bool CanRecordStatsAndAchievements(); // World seed from png image - void GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsigned char *pszSeed,unsigned int &uiHostOptions,bool &bHostOptionsRead,DWORD &uiTexturePack); - unsigned int CreateImageTextData(PBYTE bTextMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId); + void GetImageTextData(std::uint8_t *imageData, unsigned int imageBytes, unsigned char *seedText, unsigned int &uiHostOptions, bool &bHostOptionsRead, std::uint32_t &uiTexturePack); + unsigned int CreateImageTextData(std::uint8_t *textMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId); // Game rules GameRuleManager m_gameRules; @@ -717,16 +719,16 @@ public: void setLevelGenerationOptions(LevelGenerationOptions *levelGen); LevelRuleset *getGameRuleDefinitions() { return m_gameRules.getGameRuleDefinitions(); } LevelGenerationOptions *getLevelGenerationOptions() { return m_gameRules.getLevelGenerationOptions(); } - LPCWSTR GetGameRulesString(const std::wstring &key); + const wchar_t *GetGameRulesString(const std::wstring &key); private: - BYTE m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's + std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS]; public: - void UpdatePlayerInfo(BYTE networkSmallId, SHORT playerColourIndex, unsigned int playerGamePrivileges); - short GetPlayerColour(BYTE networkSmallId); - unsigned int GetPlayerPrivileges(BYTE networkSmallId); + void UpdatePlayerInfo(std::uint8_t networkSmallId, SHORT playerColourIndex, unsigned int playerGamePrivileges); + short GetPlayerColour(std::uint8_t networkSmallId); + unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId); std::wstring getEntityName(eINSTANCEOF type); @@ -735,9 +737,9 @@ public: unsigned int AddDLCRequest(eDLCMarketplaceType eContentType, bool bPromote=false); bool RetrieveNextDLCContent(); bool CheckTMSDLCCanStop(); - static int DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, int iPad); - DWORD GetDLCContentType(eDLCContentType eType) { return m_dwContentTypeA[eType];} - eDLCContentType Find_eDLCContentType(DWORD dwType); + static int DLCOffersReturned(void *pParam, int iOfferC, std::uint32_t dwType, int iPad); + std::uint32_t GetDLCContentType(eDLCContentType eType) { return m_dwContentTypeA[eType];} + eDLCContentType Find_eDLCContentType(std::uint32_t dwType); int GetDLCOffersCount() { return m_iDLCOfferC;} bool DLCContentRetrieved(eDLCMarketplaceType eType); void TickDLCOffersRetrieved(); @@ -757,10 +759,10 @@ public: #else #ifdef _XBOX_ONE - static int TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,LPVOID, WCHAR *wchFilename); + static int TMSPPFileReturned(void *pParam,int iPad,int iUserData,void *, WCHAR *wchFilename); std::unordered_map *GetDLCInfo(); #else - static int TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename); + static int TMSPPFileReturned(void *pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename); #endif DLC_INFO *GetDLCInfoTrialOffer(int iIndex); DLC_INFO *GetDLCInfoFullOffer(int iIndex); @@ -790,7 +792,7 @@ private: //Request current_download; std::vector m_DLCDownloadQueue; std::vector m_TMSPPDownloadQueue; - static DWORD m_dwContentTypeA[e_Marketplace_MAX]; + static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX]; int m_iDLCOfferC; bool m_bAllDLCContentRetrieved; bool m_bAllTMSContentRetrieved; @@ -802,29 +804,29 @@ private: CRITICAL_SECTION csAnimOverrideBitmask; bool m_bCorruptSaveDeleted; - DWORD m_dwAdditionalModelParts[XUSER_MAX_COUNT]; + std::uint32_t m_dwAdditionalModelParts[XUSER_MAX_COUNT]; - BYTE *m_pBannedListFileBuffer; - DWORD m_dwBannedListFileSize; + std::uint8_t *m_pBannedListFileBuffer; + unsigned int m_dwBannedListFileSize; public: - DWORD m_dwDLCFileSize; - BYTE *m_pDLCFileBuffer; + unsigned int m_dwDLCFileSize; + std::uint8_t *m_pDLCFileBuffer; // static int CallbackReadXuidsFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); // static int CallbackDLCFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); // static int CallbackBannedListFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction); // Storing additional model parts per skin texture - void SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC); - std::vector * SetAdditionalSkinBoxes(DWORD dwSkinID, std::vector *pvSkinBoxA); - std::vector *GetAdditionalModelParts(DWORD dwSkinID); - std::vector *GetAdditionalSkinBoxes(DWORD dwSkinID); - void SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOverrideBitmask); - unsigned int GetAnimOverrideBitmask(DWORD dwSkinID); + void SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX *SkinBoxA, unsigned int dwSkinBoxC); + std::vector * SetAdditionalSkinBoxes(std::uint32_t dwSkinID, std::vector *pvSkinBoxA); + std::vector *GetAdditionalModelParts(std::uint32_t dwSkinID); + std::vector *GetAdditionalSkinBoxes(std::uint32_t dwSkinID); + void SetAnimOverrideBitmask(std::uint32_t dwSkinID,unsigned int uiAnimOverrideBitmask); + unsigned int GetAnimOverrideBitmask(std::uint32_t dwSkinID); - static DWORD getSkinIdFromPath(const std::wstring &skin); - static std::wstring getSkinPathFromId(DWORD skinId); + static std::uint32_t getSkinIdFromPath(const std::wstring &skin); + static std::wstring getSkinPathFromId(std::uint32_t skinId); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile)=0; virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt)=0; @@ -839,24 +841,24 @@ public: void SetBanListRead(int iPad,bool bVal) { m_bRead_BannedListA[iPad]=bVal;} void ClearBanList(int iPad) { BannedListA[iPad].pBannedList=NULL;BannedListA[iPad].dwBytes=0;} - DWORD GetRequiredTexturePackID() {return m_dwRequiredTexturePackID;} - void SetRequiredTexturePackID(DWORD dwID) {m_dwRequiredTexturePackID=dwID;} + std::uint32_t GetRequiredTexturePackID() { return m_dwRequiredTexturePackID; } + void SetRequiredTexturePackID(std::uint32_t texturePackId) { m_dwRequiredTexturePackID = texturePackId; } - virtual void GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ) {*ppbData = NULL; *pdwBytes = 0;} + virtual void GetFileFromTPD(eTPDFileType eType, std::uint8_t *pbData, unsigned int dwBytes, std::uint8_t **ppbData, unsigned int *pdwBytes ) {*ppbData = NULL; *pdwBytes = 0;} //XTITLE_DEPLOYMENT_TYPE getDeploymentType() { return m_titleDeploymentType; } private: // vector of additional skin model parts, indexed by the skin texture id - std::unordered_map *> m_AdditionalModelParts; - std::unordered_map *> m_AdditionalSkinBoxes; - std::unordered_map m_AnimOverrides; + std::unordered_map *> m_AdditionalModelParts; + std::unordered_map *> m_AdditionalSkinBoxes; + std::unordered_map m_AnimOverrides; bool m_bResetNether; - DWORD m_dwRequiredTexturePackID; + std::uint32_t m_dwRequiredTexturePackID; #ifdef _XBOX_ONE - std::vector m_vTMSPPData; + std::vector m_vTMSPPData; #endif #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__) @@ -873,18 +875,18 @@ public: void LocaleAndLanguageInit(); void getLocale(std::vector &vecWstrLocales); - DWORD get_eMCLang(WCHAR *pwchLocale); - DWORD get_xcLang(WCHAR *pwchLocale); + int get_eMCLang(WCHAR *pwchLocale); + int get_xcLang(WCHAR *pwchLocale); void SetTickTMSDLCFiles(bool bVal); - std::wstring getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder); + std::wstring getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder); private: std::unordered_mapm_localeA; std::unordered_mapm_eMCLangA; std::unordered_mapm_xcLangA; - std::wstring getRootPath(DWORD packId, bool allowOverride, bool bAddDataFolder); + std::wstring getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder); public: #ifdef _XBOX diff --git a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp index 0caf3f5de..730976f59 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.cpp @@ -1,4 +1,7 @@ #include "../../Minecraft.World/Platform/stdafx.h" +#include +#include +#include #include "DLCManager.h" #include "DLCAudioFile.h" #if defined _XBOX || defined _WINDOWS64 @@ -6,23 +9,81 @@ #include "../../Minecraft.Client/Platform/Xbox/XML/xmlFilesCallback.h" #endif +namespace +{ + constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2; + +#if WCHAR_MAX > 0xFFFF + static std::wstring ReadAudioDlcWString(const void *data) + { + const std::uint16_t *chars = static_cast(data); + const std::uint16_t *end = chars; + while(*end != 0) + { + ++end; + } + + std::wstring out(static_cast(end - chars), 0); + for(std::size_t i = 0; i < out.size(); ++i) + { + out[i] = static_cast(chars[i]); + } + return out; + } +#else + static std::wstring ReadAudioDlcWString(const void *data) + { + return std::wstring(static_cast(data)); + } +#endif + + template + T ReadAudioDlcValue(const std::uint8_t *data, unsigned int offset = 0) + { + T value; + std::memcpy(&value, data + offset, sizeof(value)); + return value; + } + + template + void ReadAudioDlcStruct(T *out, const std::uint8_t *data, unsigned int offset = 0) + { + std::memcpy(out, data + offset, sizeof(*out)); + } + + inline unsigned int AudioParamAdvance(unsigned int wcharCount) + { + return static_cast(sizeof(C4JStorage::DLC_FILE_PARAM) + wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE); + } + + inline unsigned int AudioDetailAdvance(unsigned int wcharCount) + { + return static_cast(sizeof(C4JStorage::DLC_FILE_DETAILS) + wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE); + } + + inline std::wstring ReadAudioParamString(const std::uint8_t *data, unsigned int offset) + { + return ReadAudioDlcWString(data + offset + offsetof(C4JStorage::DLC_FILE_PARAM, wchData)); + } +} + DLCAudioFile::DLCAudioFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_Audio,path) { m_pbData = NULL; - m_dwBytes = 0; + m_dataBytes = 0; } -void DLCAudioFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCAudioFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { m_pbData = pbData; - m_dwBytes = dwBytes; + m_dataBytes = dataBytes; - processDLCDataFile(pbData,dwBytes); + processDLCDataFile(pbData,dataBytes); } -PBYTE DLCAudioFile::getData(DWORD &dwBytes) +std::uint8_t *DLCAudioFile::getData(std::uint32_t &dataBytes) { - dwBytes = m_dwBytes; + dataBytes = m_dataBytes; return m_pbData; } @@ -36,7 +97,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(const std::wstr { EAudioParameterType type = e_AudioParamType_Invalid; - for(DWORD i = 0; i < e_AudioParamType_Max; ++i) + for(int i = 0; i < e_AudioParamType_Max; ++i) { if(paramName.compare(wchTypeNamesA[i]) == 0) { @@ -120,7 +181,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, cons } } -bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) +bool DLCAudioFile::processDLCDataFile(std::uint8_t *pbData, std::uint32_t dataLength) { std::unordered_map parameterMapping; unsigned int uiCurrentByte=0; @@ -128,7 +189,7 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) // File format defined in the AudioPacker // File format: Version 1 - unsigned int uiVersion=*(unsigned int *)pbData; + unsigned int uiVersion = ReadAudioDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); if(uiVersion < CURRENT_AUDIO_VERSION_NUM) @@ -138,60 +199,62 @@ bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength) return false; } - unsigned int uiParameterTypeCount=*(unsigned int *)&pbData[uiCurrentByte]; + unsigned int uiParameterTypeCount = ReadAudioDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); - C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; + C4JStorage::DLC_FILE_PARAM paramBuf; + ReadAudioDlcStruct(¶mBuf, pbData, uiCurrentByte); for(unsigned int i=0;iwchData); + std::wstring parameterName = ReadAudioParamString(pbData, uiCurrentByte); EAudioParameterType type = getParameterType(parameterName); if( type != e_AudioParamType_Invalid ) { - parameterMapping[pParams->dwType] = type; + parameterMapping[paramBuf.dwType] = type; } - uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR)); - pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; + uiCurrentByte += AudioParamAdvance(paramBuf.dwWchCount); + ReadAudioDlcStruct(¶mBuf, pbData, uiCurrentByte); } - unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte]; + unsigned int uiFileCount = ReadAudioDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); - C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + C4JStorage::DLC_FILE_DETAILS fileBuf; + ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte); - DWORD dwTemp=uiCurrentByte; + unsigned int tempByteOffset = uiCurrentByte; for(unsigned int i=0;idwWchCount*sizeof(WCHAR); - pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; + tempByteOffset += AudioDetailAdvance(fileBuf.dwWchCount); + ReadAudioDlcStruct(&fileBuf, pbData, tempByteOffset); } - PBYTE pbTemp=((PBYTE )pFile); - pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + std::uint8_t *pbTemp = &pbData[tempByteOffset]; + ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte); for(unsigned int i=0;idwType; + EAudioType type = (EAudioType)fileBuf.dwType; // Params - unsigned int uiParameterCount=*(unsigned int *)pbTemp; + unsigned int uiParameterCount = ReadAudioDlcValue(pbTemp); pbTemp+=sizeof(int); - pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; + ReadAudioDlcStruct(¶mBuf, pbTemp); for(unsigned int j=0;jdwType )); + AUTO_VAR(it, parameterMapping.find(paramBuf.dwType)); if(it != parameterMapping.end() ) { - addParameter(type,(EAudioParameterType)pParams->dwType,(WCHAR *)pParams->wchData); + addParameter(type, (EAudioParameterType)paramBuf.dwType, ReadAudioParamString(pbTemp, 0)); } - pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount); - pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; + pbTemp += AudioParamAdvance(paramBuf.dwWchCount); + ReadAudioDlcStruct(¶mBuf, pbTemp); } // Move the pointer to the start of the next files data; - pbTemp+=pFile->uiFileSize; - uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR); + pbTemp += fileBuf.uiFileSize; + uiCurrentByte += AudioDetailAdvance(fileBuf.dwWchCount); - pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte); } @@ -213,4 +276,4 @@ std::wstring &DLCAudioFile::GetSoundName(int iIndex) iWorldType++; } return m_parameters[iWorldType].at(iIndex); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.h b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.h index f71f89130..dc6804e30 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCAudioFile.h @@ -32,18 +32,18 @@ public: DLCAudioFile(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); + virtual std::uint8_t *getData(std::uint32_t &dataBytes); - bool processDLCDataFile(PBYTE pbData, DWORD dwLength); + bool processDLCDataFile(std::uint8_t *pbData, std::uint32_t dataLength); int GetCountofType(DLCAudioFile::EAudioType ptype); std::wstring &GetSoundName(int iIndex); private: using DLCFile::addParameter; - PBYTE m_pbData; - DWORD m_dwBytes; + std::uint8_t *m_pbData; + std::uint32_t m_dataBytes; static const int CURRENT_AUDIO_VERSION_NUM=1; //std::unordered_map m_parameters; std::vector m_parameters[e_AudioType_Max]; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.cpp index 6ef5c97f4..a9edb92e8 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.cpp @@ -6,7 +6,7 @@ DLCCapeFile::DLCCapeFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCTy { } -void DLCCapeFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCCapeFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { - app.AddMemoryTextureFile(m_path,pbData,dwBytes); -} \ No newline at end of file + app.AddMemoryTextureFile(m_path,pbData,dataBytes); +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.h b/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.h index 6626387a8..406ac3dc4 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCCapeFile.h @@ -6,5 +6,5 @@ class DLCCapeFile : public DLCFile public: DLCCapeFile(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); -}; \ No newline at end of file + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp index beab8161e..fed962a75 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.cpp @@ -19,8 +19,8 @@ DLCColourTableFile::~DLCColourTableFile() } } -void DLCColourTableFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCColourTableFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { ColourTable *defaultColourTable = Minecraft::GetInstance()->skins->getDefault()->getColourTable(); - m_colourTable = new ColourTable(defaultColourTable, pbData, dwBytes); -} \ No newline at end of file + m_colourTable = new ColourTable(defaultColourTable, pbData, dataBytes); +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.h b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.h index cb7a8cf5a..d75fec458 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCColourTableFile.h @@ -12,7 +12,7 @@ public: DLCColourTableFile(const std::wstring &path); ~DLCColourTableFile(); - virtual void addData(PBYTE pbData, DWORD dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); ColourTable *getColourTable() { return m_colourTable; } -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCFile.cpp index 56bfc4fb1..5ae3551bc 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCFile.cpp @@ -23,4 +23,4 @@ DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring &path) { m_dwSkinId=0; } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCFile.h b/Minecraft.Client/Platform/Common/DLC/DLCFile.h index 0f652f849..cb472a77c 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCFile.h @@ -1,4 +1,5 @@ #pragma once +#include #include "DLCManager.h" class DLCFile @@ -6,7 +7,7 @@ class DLCFile protected: DLCManager::EDLCType m_type; std::wstring m_path; - DWORD m_dwSkinId; + std::uint32_t m_dwSkinId; public: DLCFile(DLCManager::EDLCType type, const std::wstring &path); @@ -14,12 +15,12 @@ public: DLCManager::EDLCType getType() { return m_type; } std::wstring getPath() { return m_path; } - DWORD getSkinID() { return m_dwSkinId; } + std::uint32_t getSkinID() { return m_dwSkinId; } - virtual void addData(PBYTE pbData, DWORD dwBytes) {} - virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return NULL; } + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes) {} + virtual std::uint8_t *getData(std::uint32_t &dataBytes) { dataBytes = 0; return NULL; } virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value) {} virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type) { return L""; } virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) { return false;} -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp index b383bd70d..1c91a39e3 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.cpp @@ -5,17 +5,17 @@ DLCGameRulesFile::DLCGameRulesFile(const std::wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRules,path) { m_pbData = NULL; - m_dwBytes = 0; + m_dataBytes = 0; } -void DLCGameRulesFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCGameRulesFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { m_pbData = pbData; - m_dwBytes = dwBytes; + m_dataBytes = dataBytes; } -PBYTE DLCGameRulesFile::getData(DWORD &dwBytes) +std::uint8_t *DLCGameRulesFile::getData(std::uint32_t &dataBytes) { - dwBytes = m_dwBytes; + dataBytes = m_dataBytes; return m_pbData; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.h b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.h index 9924ca849..56af6cd8c 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesFile.h @@ -4,12 +4,12 @@ class DLCGameRulesFile : public DLCGameRules { private: - PBYTE m_pbData; - DWORD m_dwBytes; + std::uint8_t *m_pbData; + std::uint32_t m_dataBytes; public: DLCGameRulesFile(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); -}; \ No newline at end of file + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); + virtual std::uint8_t *getData(std::uint32_t &dataBytes); +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp index 5b2d705f0..09afd4783 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.cpp @@ -12,7 +12,7 @@ DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path) { m_pbData = NULL; - m_dwBytes = 0; + m_dataBytes = 0; m_hasData = false; @@ -21,14 +21,14 @@ DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring &path) : DLCGameRules( lgo = NULL; } -void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes) +void DLCGameRulesHeader::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { m_pbData = pbData; - m_dwBytes = dwBytes; + m_dataBytes = dataBytes; #if 0 - byteArray data(m_pbData, m_dwBytes); + byteArray data(m_pbData, m_dataBytes); ByteArrayInputStream bais(data); DataInputStream dis(&bais); @@ -73,13 +73,13 @@ void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes) #endif } -PBYTE DLCGameRulesHeader::getData(DWORD &dwBytes) +std::uint8_t *DLCGameRulesHeader::getData(std::uint32_t &dataBytes) { - dwBytes = m_dwBytes; + dataBytes = m_dataBytes; return m_pbData; } -void DLCGameRulesHeader::setGrfData(PBYTE fData, DWORD fSize, StringTable *st) +void DLCGameRulesHeader::setGrfData(std::uint8_t *fData, std::uint32_t dataSize, StringTable *st) { if (!m_hasData) { @@ -87,6 +87,6 @@ void DLCGameRulesHeader::setGrfData(PBYTE fData, DWORD fSize, StringTable *st) //app.m_gameRules.loadGameRules(lgo, fData, fSize); - app.m_gameRules.readRuleFile(lgo, fData, fSize, st); + app.m_gameRules.readRuleFile(lgo, fData, dataSize, st); } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.h b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.h index fddc7318c..a947ece81 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCGameRulesHeader.h @@ -8,21 +8,21 @@ class DLCGameRulesHeader : public DLCGameRules, public JustGrSource private: // GR-Header - PBYTE m_pbData; - DWORD m_dwBytes; + std::uint8_t *m_pbData; + std::uint32_t m_dataBytes; bool m_hasData; public: virtual bool requiresTexturePack() {return m_bRequiresTexturePack;} - virtual UINT getRequiredTexturePackId() {return m_requiredTexturePackId;} + virtual std::uint32_t getRequiredTexturePackId() {return m_requiredTexturePackId;} virtual std::wstring getDefaultSaveName() {return m_defaultSaveName;} - virtual LPCWSTR getWorldName() {return m_worldName.c_str();} - virtual LPCWSTR getDisplayName() {return m_displayName.c_str();} + virtual const wchar_t *getWorldName() {return m_worldName.c_str();} + virtual const wchar_t *getDisplayName() {return m_displayName.c_str();} virtual std::wstring getGrfPath() {return L"GameRules.grf";} virtual void setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;} - virtual void setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;} + virtual void setRequiredTexturePackId(std::uint32_t x) {m_requiredTexturePackId = x;} virtual void setDefaultSaveName(const std::wstring &x) {m_defaultSaveName = x;} virtual void setWorldName(const std::wstring & x) {m_worldName = x;} virtual void setDisplayName(const std::wstring & x) {m_displayName = x;} @@ -33,10 +33,10 @@ public: public: DLCGameRulesHeader(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); + virtual std::uint8_t *getData(std::uint32_t &dataBytes); - void setGrfData(PBYTE fData, DWORD fSize, StringTable *); + void setGrfData(std::uint8_t *fData, std::uint32_t dataSize, StringTable *); virtual bool ready() { return m_hasData; } -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp index 67e6639a6..c1f9c9e30 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.cpp @@ -8,7 +8,7 @@ DLCLocalisationFile::DLCLocalisationFile(const std::wstring &path) : DLCFile(DLC m_strings = NULL; } -void DLCLocalisationFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCLocalisationFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { - m_strings = new StringTable(pbData, dwBytes); -} \ No newline at end of file + m_strings = new StringTable(pbData, dataBytes); +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.h b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.h index db4211667..46f5782d4 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCLocalisationFile.h @@ -10,9 +10,9 @@ private: public: DLCLocalisationFile(const std::wstring &path); - DLCLocalisationFile(PBYTE pbData, DWORD dwBytes); // when we load in a texture pack details file from TMS++ + DLCLocalisationFile(std::uint8_t *pbData, std::uint32_t dataBytes); // when we load in a texture pack details file from TMS++ - virtual void addData(PBYTE pbData, DWORD dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); StringTable *getStringTable() { return m_strings; } -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp b/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp index 7eaaffb51..d633e7223 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCManager.cpp @@ -4,12 +4,17 @@ #include "DLCPack.h" #include "DLCFile.h" #include "../../Minecraft.World/Util/StringHelpers.h" +#include "../../Minecraft.World/Util/PortableFileIO.h" #include "../../Minecraft.Client/Minecraft.h" #include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h" +#include +#include +#include +#include // 4jcraft, this is the size of wchar_t on disk // the DLC was created on windows, with wchar_t beeing 2 bytes and UTF-16 -static const size_t DLC_WCHAR_BIN_SIZE = 2; +static const std::size_t DLC_WCHAR_BIN_SIZE = 2; #if WCHAR_MAX > 0xFFFF // than sizeof(WCHAR) != DLC_WCHAR_BIN_SIZE @@ -18,22 +23,22 @@ static_assert( sizeof(wchar_t) == 4, "wchar_t is not 4bytes but larger than 2byt static inline std::wstring dlc_read_wstring(const void *data) { - const uint16_t* p = (const uint16_t *)data; + const std::uint16_t* p = static_cast(data); // find the end (nullterminated) - const uint16_t* end = p; + const std::uint16_t* end = p; while(*end) { - ++end; + ++end; } - size_t len = end - p; + std::size_t len = static_cast(end - p); // allocate wstring with length len // it will be nullterminated internally, do not worry. std::wstring out(len, 0); // and copy them into thje string - for(size_t i = 0; i < len; ++i) { - out[i] = (wchar_t) p[i]; + for(std::size_t i = 0; i < len; ++i) { + out[i] = static_cast(p[i]); } return out; @@ -51,6 +56,91 @@ static_assert( sizeof(wchar_t) == 2, "How did we get here? wide char smaller tha #define DLC_PARAM_ADV(n) (sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE) #define DLC_DETAIL_ADV(n) (sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE) +namespace +{ + template + T ReadDlcValue(const std::uint8_t *data, unsigned int offset = 0) + { + T value; + std::memcpy(&value, data + offset, sizeof(value)); + return value; + } + + template + void ReadDlcStruct(T *out, const std::uint8_t *data, unsigned int offset = 0) + { + std::memcpy(out, data + offset, sizeof(*out)); + } + + std::wstring getMountedDlcReadPath(const std::string &path) + { + std::wstring readPath = convStringToWstring(path); + +#ifdef _WINDOWS64 + const std::string mountedPath = StorageManager.GetMountedPath(path.c_str()); + if(!mountedPath.empty()) + { + readPath = convStringToWstring(mountedPath); + } +#elif defined(_DURANGO) + const std::wstring mountedPath = StorageManager.GetMountedPath(readPath.c_str()); + if(!mountedPath.empty()) + { + readPath = mountedPath; + } +#endif + + return readPath; + } + + bool readOwnedDlcFile(const std::string &path, std::uint8_t **ppData, unsigned int *pBytesRead) + { + *ppData = NULL; + *pBytesRead = 0; + + const std::wstring readPath = getMountedDlcReadPath(path); + std::FILE *file = PortableFileIO::OpenBinaryFileForRead(readPath); + if(file == NULL) + { + return false; + } + + if(!PortableFileIO::Seek(file, 0, SEEK_END)) + { + std::fclose(file); + return false; + } + + const __int64 endPosition = PortableFileIO::Tell(file); + if(endPosition <= 0 || endPosition > std::numeric_limits::max()) + { + std::fclose(file); + return false; + } + + const unsigned int fileSize = static_cast(endPosition); + if(!PortableFileIO::Seek(file, 0, SEEK_SET)) + { + std::fclose(file); + return false; + } + + std::uint8_t *data = new std::uint8_t[fileSize]; + const std::size_t bytesRead = std::fread(data, 1, fileSize, file); + const bool failed = std::ferror(file) != 0 || bytesRead != fileSize; + std::fclose(file); + if(failed) + { + delete[] data; + return false; + } + + *ppData = data; + *pBytesRead = static_cast(bytesRead); + return true; + } +} + const WCHAR *DLCManager::wchTypeNamesA[]= { L"DISPLAYNAME", @@ -87,7 +177,7 @@ DLCManager::EDLCParameterType DLCManager::getParameterType(const std::wstring &p { EDLCParameterType type = e_DLCParamType_Invalid; - for(DWORD i = 0; i < e_DLCParamType_Max; ++i) + for(unsigned int i = 0; i < e_DLCParamType_Max; ++i) { if(paramName.compare(wchTypeNamesA[i]) == 0) { @@ -99,9 +189,9 @@ DLCManager::EDLCParameterType DLCManager::getParameterType(const std::wstring &p return type; } -DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) +unsigned int DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) { - DWORD packCount = 0; + unsigned int packCount = 0; if( type != e_DLCType_All ) { for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) @@ -115,7 +205,7 @@ DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/) } else { - packCount = (DWORD)m_packs.size(); + packCount = static_cast(m_packs.size()); } return packCount; } @@ -175,12 +265,12 @@ DLCPack *DLCManager::getPackFromProductID(const std::wstring &productID) } #endif -DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/) +DLCPack *DLCManager::getPack(unsigned int index, EDLCType type /*= e_DLCType_All*/) { DLCPack *pack = NULL; if( type != e_DLCType_All ) { - DWORD currentIndex = 0; + unsigned int currentIndex = 0; DLCPack *currentPack = NULL; for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { @@ -209,9 +299,9 @@ DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/) return pack; } -DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_DLCType_All*/) +unsigned int DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_DLCType_All*/) { - DWORD foundIndex = 0; + unsigned int foundIndex = 0; found = false; if(pack == NULL) { @@ -221,7 +311,7 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D } if( type != e_DLCType_All ) { - DWORD index = 0; + unsigned int index = 0; for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { DLCPack *thisPack = *it; @@ -239,7 +329,7 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D } else { - DWORD index = 0; + unsigned int index = 0; for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { DLCPack *thisPack = *it; @@ -255,11 +345,11 @@ DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_D return foundIndex; } -DWORD DLCManager::getPackIndexContainingSkin(const std::wstring &path, bool &found) +unsigned int DLCManager::getPackIndexContainingSkin(const std::wstring &path, bool &found) { - DWORD foundIndex = 0; + unsigned int foundIndex = 0; found = false; - DWORD index = 0; + unsigned int index = 0; for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it) { DLCPack *pack = *it; @@ -310,9 +400,9 @@ DLCSkinFile *DLCManager::getSkinFile(const std::wstring &path) return foundSkinfile; } -DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) +unsigned int DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) { - DWORD corruptDLCCount = m_dwUnnamedCorruptDLCCount; + unsigned int corruptDLCCount = m_dwUnnamedCorruptDLCCount; DLCPack *pack = NULL; DLCPack *firstCorruptPack = NULL; @@ -329,7 +419,7 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) // gotta fix this someday if(corruptDLCCount > 0 && showMessage) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; if(corruptDLCCount == 1 && firstCorruptPack != NULL) { @@ -351,13 +441,13 @@ DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/) return corruptDLCCount; } -bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::wstring &path, DLCPack *pack, bool fromArchive) +bool DLCManager::readDLCDataFile(unsigned int &dwFilesProcessed, const std::wstring &path, DLCPack *pack, bool fromArchive) { return readDLCDataFile( dwFilesProcessed, wstringtofilename(path), pack, fromArchive); } -bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::string &path, DLCPack *pack, bool fromArchive) +bool DLCManager::readDLCDataFile(unsigned int &dwFilesProcessed, const std::string &path, DLCPack *pack, bool fromArchive) { std::wstring wPath = convStringToWstring(path); if (fromArchive && app.getArchiveFileSize(wPath) >= 0) @@ -367,49 +457,19 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::string &pat } else if (fromArchive) return false; -#ifdef _WINDOWS64 - std::string finalPath = StorageManager.GetMountedPath(path.c_str()); - if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#elif defined(_DURANGO) - std::wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); - if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#endif - if( file == INVALID_HANDLE_VALUE ) + unsigned int bytesRead = 0; + std::uint8_t *pbData = NULL; + if(!readOwnedDlcFile(path, &pbData, &bytesRead)) { - DWORD error = GetLastError(); - app.DebugPrintf("Failed to open DLC data file with error code %d (%x)\n", error, error); - if( dwFilesProcessed == 0 ) removePack(pack); - assert(false); - return false; - } - - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); - PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); - if(bSuccess==FALSE) - { - // need to treat the file as corrupt, and flag it, so can't call fatal error - //app.FatalLoadError(); - } - else - { - CloseHandle(file); - } - if(bSuccess==FALSE) - { - // Corrupt or some other error. In any case treat as corrupt - app.DebugPrintf("Failed to read %s from DLC content package\n", path.c_str()); - pack->SetIsCorrupt( true ); + app.DebugPrintf("Failed to open DLC data file %s\n", path.c_str()); + pack->SetIsCorrupt(true); SetNeedsCorruptCheck(true); return false; } return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack); } +bool DLCManager::processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack) // a bunch of makros to reduce memcpy and offset boilerplate #define DLC_READ_UINT(out, buf, off) memcpy((out), (buf) + (off), sizeof(unsigned int)) @@ -421,8 +481,6 @@ bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const std::string &pat #define DLC_PARAM_WSTR(buf, off) DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_PARAM, wchData)) #define DLC_DETAIL_WSTR(buf, off) DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_DETAILS, wchFile)) - -bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack) { std::unordered_map parameterMapping; unsigned int uiCurrentByte=0; @@ -438,16 +496,16 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD // // unsigned long, p = number of parameters // // p * DLC_FILE_PARAM describing each parameter for this file // // ulFileSize bytes of data blob of the file added - + // 4jcraft, some parts of this code changed, specifically: // instead of casting a goddamn raw byte pointer and dereferencing it - // use memcpy, and access WSTRING with propper offset - // (scince bufferoffset after advancing by variable string length is not + // use memcpy, and access WSTRING with propper offset + // (scince bufferoffset after advancing by variable string length is not // guaranteed to be properly aligned, so casting to a scalar/struct is UB) - + // those casts coult be dangerous on e.g. ARM, because it doesnt handle // missaligned loads, like x86/x64, so it would crash - + // WHO TF USES HUNGARIAN NOTATION unsigned int uiVersion; @@ -490,13 +548,13 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD C4JStorage::DLC_FILE_DETAILS fileBuf; DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte); - DWORD dwTemp=uiCurrentByte; + unsigned int dwTemp=uiCurrentByte; for(unsigned int i=0;iSetDataPointer(NULL); // If it's a child pack, it doesn't own the data if(!validPack || texturePackFilesProcessed == 0) { @@ -603,56 +661,25 @@ bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD return true; } -DWORD DLCManager::retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack) +std::uint32_t DLCManager::retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack) { - DWORD packId = 0; - std::wstring wPath = convStringToWstring(path); + std::uint32_t packId = 0; -#ifdef _WINDOWS64 - std::string finalPath = StorageManager.GetMountedPath(path.c_str()); - if(finalPath.size() == 0) finalPath = path; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#elif defined(_DURANGO) - std::wstring finalPath = StorageManager.GetMountedPath(wPath.c_str()); - if(finalPath.size() == 0) finalPath = wPath; - HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#endif - if( file == INVALID_HANDLE_VALUE ) + unsigned int bytesRead = 0; + std::uint8_t *pbData = NULL; + if(!readOwnedDlcFile(path, &pbData, &bytesRead)) { return 0; } - - DWORD bytesRead; - DWORD dwFileSize = GetFileSize(file,NULL); - PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); - if(bSuccess==FALSE) - { - // need to treat the file as corrupt, and flag it, so can't call fatal error - //app.FatalLoadError(); - } - else - { - CloseHandle(file); - } - if(bSuccess==FALSE) - { - // Corrupt or some other error. In any case treat as corrupt - app.DebugPrintf("Failed to read %s from DLC content package\n", path.c_str()); - delete [] pbData; - return 0; - } packId=retrievePackID(pbData, bytesRead, pack); delete [] pbData; return packId; } -DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) +std::uint32_t DLCManager::retrievePackID(std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack) { - DWORD packId=0; + std::uint32_t packId=0; bool bPackIDSet=false; std::unordered_map parameterMapping; unsigned int uiCurrentByte=0; @@ -668,7 +695,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) // // unsigned long, p = number of parameters // // p * DLC_FILE_PARAM describing each parameter for this file // // ulFileSize bytes of data blob of the file added - unsigned int uiVersion=*(unsigned int *)pbData; + unsigned int uiVersion = ReadDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); if(uiVersion < CURRENT_DLC_VERSION_NUM) @@ -677,46 +704,48 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) return 0; } pack->SetDataPointer(pbData); - unsigned int uiParameterCount=*(unsigned int *)&pbData[uiCurrentByte]; + unsigned int uiParameterCount = ReadDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); - C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; + C4JStorage::DLC_FILE_PARAM paramBuf; + ReadDlcStruct(¶mBuf, pbData, uiCurrentByte); for(unsigned int i=0;iwchData); + std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte); DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName); if( type != DLCManager::e_DLCParamType_Invalid ) { - parameterMapping[pParams->dwType] = type; + parameterMapping[paramBuf.dwType] = type; } - uiCurrentByte+= DLC_PARAM_ADV(pParams->dwWchCount); - pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte]; + uiCurrentByte += DLC_PARAM_ADV(paramBuf.dwWchCount); + ReadDlcStruct(¶mBuf, pbData, uiCurrentByte); } - unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte]; + unsigned int uiFileCount = ReadDlcValue(pbData, uiCurrentByte); uiCurrentByte+=sizeof(int); - C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + C4JStorage::DLC_FILE_DETAILS fileBuf; + ReadDlcStruct(&fileBuf, pbData, uiCurrentByte); - DWORD dwTemp=uiCurrentByte; + unsigned int dwTemp=uiCurrentByte; for(unsigned int i=0;idwWchCount); - pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp]; + dwTemp += DLC_DETAIL_ADV(fileBuf.dwWchCount); + ReadDlcStruct(&fileBuf, pbData, dwTemp); } - PBYTE pbTemp=((PBYTE )pFile); - pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + std::uint8_t *pbTemp = &pbData[dwTemp]; + ReadDlcStruct(&fileBuf, pbData, uiCurrentByte); for(unsigned int i=0;idwType; + DLCManager::EDLCType type = (DLCManager::EDLCType)fileBuf.dwType; // Params - uiParameterCount=*(unsigned int *)pbTemp; + uiParameterCount = ReadDlcValue(pbTemp); pbTemp+=sizeof(int); - pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; + ReadDlcStruct(¶mBuf, pbTemp); for(unsigned int j=0;jdwType )); + AUTO_VAR(it, parameterMapping.find(paramBuf.dwType)); if(it != parameterMapping.end() ) { @@ -724,7 +753,7 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) { if(it->second==e_DLCParamType_PackId) { - std::wstring wsTemp = DLC_WSTRING(pParams->wchData); + std::wstring wsTemp = DLC_PARAM_WSTR(pbTemp, 0); std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually ss << std::dec << wsTemp.c_str(); @@ -734,16 +763,16 @@ DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack) } } } - pbTemp+=DLC_PARAM_ADV(pParams->dwWchCount); - pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp; + pbTemp += DLC_PARAM_ADV(paramBuf.dwWchCount); + ReadDlcStruct(¶mBuf, pbTemp); } if(bPackIDSet) break; // Move the pointer to the start of the next files data; - pbTemp+=pFile->uiFileSize; - uiCurrentByte+=DLC_DETAIL_ADV(pFile->dwWchCount); + pbTemp += fileBuf.uiFileSize; + uiCurrentByte += DLC_DETAIL_ADV(fileBuf.dwWchCount); - pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte]; + ReadDlcStruct(&fileBuf, pbData, uiCurrentByte); } parameterMapping.clear(); diff --git a/Minecraft.Client/Platform/Common/DLC/DLCManager.h b/Minecraft.Client/Platform/Common/DLC/DLCManager.h index 41ffb3646..8f4e46e39 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCManager.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCManager.h @@ -1,5 +1,6 @@ #pragma once //using namespace std; +#include #include class DLCPack; class DLCSkinFile; @@ -54,14 +55,14 @@ private: std::vector m_packs; //bool m_bNeedsUpdated; bool m_bNeedsCorruptCheck; - DWORD m_dwUnnamedCorruptDLCCount; + unsigned int m_dwUnnamedCorruptDLCCount; public: DLCManager(); ~DLCManager(); static EDLCParameterType getParameterType(const std::wstring ¶mName); - DWORD getPackCount(EDLCType type = e_DLCType_All); + unsigned int getPackCount(EDLCType type = e_DLCType_All); //bool NeedsUpdated() { return m_bNeedsUpdated; } //void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; } @@ -79,21 +80,21 @@ public: #ifdef _XBOX_ONE DLCPack *DLCManager::getPackFromProductID(const std::wstring &productID); #endif - DLCPack *getPack(DWORD index, EDLCType type = e_DLCType_All); - DWORD getPackIndex(DLCPack *pack, bool &found, EDLCType type = e_DLCType_All); + DLCPack *getPack(unsigned int index, EDLCType type = e_DLCType_All); + unsigned int getPackIndex(DLCPack *pack, bool &found, EDLCType type = e_DLCType_All); DLCSkinFile *getSkinFile(const std::wstring &path); // Will hunt all packs of type skin to find the right skinfile DLCPack *getPackContainingSkin(const std::wstring &path); - DWORD getPackIndexContainingSkin(const std::wstring &path, bool &found); + unsigned int getPackIndexContainingSkin(const std::wstring &path, bool &found); - DWORD checkForCorruptDLCAndAlert(bool showMessage = true); + unsigned int checkForCorruptDLCAndAlert(bool showMessage = true); - bool readDLCDataFile(DWORD &dwFilesProcessed, const std::wstring &path, DLCPack *pack, bool fromArchive = false); - bool readDLCDataFile(DWORD &dwFilesProcessed, const std::string &path, DLCPack *pack, bool fromArchive = false); - DWORD retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack); + bool readDLCDataFile(unsigned int &dwFilesProcessed, const std::wstring &path, DLCPack *pack, bool fromArchive = false); + bool readDLCDataFile(unsigned int &dwFilesProcessed, const std::string &path, DLCPack *pack, bool fromArchive = false); + std::uint32_t retrievePackIDFromDLCDataFile(const std::string &path, DLCPack *pack); private: - bool processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack); + bool processDLCDataFile(unsigned int &dwFilesProcessed, std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack); - DWORD retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack); + std::uint32_t retrievePackID(std::uint8_t *pbData, unsigned int dwLength, DLCPack *pack); }; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp index f02434e91..55ddbbd44 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCPack.cpp @@ -11,7 +11,7 @@ #include "DLCColourTableFile.h" #include "../../Minecraft.World/Util/StringHelpers.h" -DLCPack::DLCPack(const std::wstring &name,DWORD dwLicenseMask) +DLCPack::DLCPack(const std::wstring &name,std::uint32_t dwLicenseMask) { m_dataPath = L""; m_packName = name; @@ -35,7 +35,7 @@ DLCPack::DLCPack(const std::wstring &name,DWORD dwLicenseMask) } #ifdef _XBOX_ONE -DLCPack::DLCPack(const std::wstring &name,const std::wstring &productID,DWORD dwLicenseMask) +DLCPack::DLCPack(const std::wstring &name,const std::wstring &productID,std::uint32_t dwLicenseMask) { m_dataPath = L""; m_packName = name; @@ -81,7 +81,7 @@ DLCPack::~DLCPack() } } -DWORD DLCPack::GetDLCMountIndex() +int DLCPack::GetDLCMountIndex() { if(m_parentPack != NULL) { @@ -101,9 +101,9 @@ XCONTENTDEVICEID DLCPack::GetDLCDeviceID() void DLCPack::addChildPack(DLCPack *childPack) { - int packId = childPack->GetPackId(); + const std::uint32_t packId = childPack->GetPackId(); #ifndef _CONTENT_PACKAGE - if(packId < 0 || packId > 15) + if(packId > 15) { __debugbreak(); } @@ -125,7 +125,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type, const std::wstrin { case DLCManager::e_DLCParamType_PackId: { - DWORD packId = 0; + std::uint32_t packId = 0; std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually @@ -137,7 +137,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type, const std::wstrin break; case DLCManager::e_DLCParamType_PackVersion: { - DWORD version = 0; + std::uint32_t version = 0; std::wstringstream ss; // 4J Stu - numbered using decimal to make it easier for artists/people to number manually @@ -278,7 +278,7 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const std::wstring return hasFile; } -DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index) +DLCFile *DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) { DLCFile *file = NULL; if(type == DLCManager::e_DLCType_All) @@ -333,9 +333,9 @@ DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const std::wstring &path) return file; } -DWORD DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCType_All*/) +unsigned int DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCType_All*/) { - DWORD count = 0; + unsigned int count = 0; switch(type) { @@ -346,13 +346,13 @@ DWORD DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCT } break; default: - count = (DWORD)m_files[(int)type].size(); + count = static_cast(m_files[(int)type].size()); break; }; return count; }; -DWORD DLCPack::getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found) +unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found) { if(type == DLCManager::e_DLCType_All) { @@ -363,9 +363,9 @@ DWORD DLCPack::getFileIndexAt(DLCManager::EDLCType type, const std::wstring &pat return 0; } - DWORD foundIndex = 0; + unsigned int foundIndex = 0; found = false; - DWORD index = 0; + unsigned int index = 0; for(AUTO_VAR(it, m_files[type].begin()); it != m_files[type].end(); ++it) { if(path.compare((*it)->getPath()) == 0) diff --git a/Minecraft.Client/Platform/Common/DLC/DLCPack.h b/Minecraft.Client/Platform/Common/DLC/DLCPack.h index 7a0ba2bac..3fdd16973 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCPack.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCPack.h @@ -1,5 +1,6 @@ #pragma once //using namespace std; +#include #include "DLCManager.h" class DLCFile; @@ -16,7 +17,7 @@ private: std::wstring m_packName; std::wstring m_dataPath; - DWORD m_dwLicenseMask; + std::uint32_t m_dwLicenseMask; int m_dlcMountIndex; XCONTENTDEVICEID m_dlcDeviceID; #ifdef _XBOX_ONE @@ -25,36 +26,36 @@ private: ULONGLONG m_ullFullOfferId; #endif bool m_isCorrupt; - DWORD m_packId; - DWORD m_packVersion; + std::uint32_t m_packId; + std::uint32_t m_packVersion; - PBYTE m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. + std::uint8_t *m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children. public: - DLCPack(const std::wstring &name,DWORD dwLicenseMask); + DLCPack(const std::wstring &name,std::uint32_t dwLicenseMask); #ifdef _XBOX_ONE - DLCPack(const std::wstring &name,const std::wstring &productID,DWORD dwLicenseMask); + DLCPack(const std::wstring &name,const std::wstring &productID,std::uint32_t dwLicenseMask); #endif ~DLCPack(); std::wstring getFullDataPath() { return m_dataPath; } - void SetDataPointer(PBYTE pbData) { m_data = pbData; } + void SetDataPointer(std::uint8_t *pbData) { m_data = pbData; } bool IsCorrupt() { return m_isCorrupt; } void SetIsCorrupt(bool val) { m_isCorrupt = val; } - void SetPackId(DWORD id) { m_packId = id; } - DWORD GetPackId() { return m_packId; } + void SetPackId(std::uint32_t id) { m_packId = id; } + std::uint32_t GetPackId() { return m_packId; } - void SetPackVersion(DWORD version) { m_packVersion = version; } - DWORD GetPackVersion() { return m_packVersion; } + void SetPackVersion(std::uint32_t version) { m_packVersion = version; } + std::uint32_t GetPackVersion() { return m_packVersion; } DLCPack * GetParentPack() { return m_parentPack; } - DWORD GetParentPackId() { return m_parentPack->m_packId; } + std::uint32_t GetParentPackId() { return m_parentPack->m_packId; } - void SetDLCMountIndex(DWORD id) { m_dlcMountIndex = id; } - DWORD GetDLCMountIndex(); + void SetDLCMountIndex(int id) { m_dlcMountIndex = id; } + int GetDLCMountIndex(); void SetDLCDeviceID(XCONTENTDEVICEID deviceId) { m_dlcDeviceID = deviceId; } XCONTENTDEVICEID GetDLCDeviceID(); @@ -64,8 +65,8 @@ public: void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value); bool getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int ¶m); - void updateLicenseMask( DWORD dwLicenseMask ) { m_dwLicenseMask = dwLicenseMask; } - DWORD getLicenseMask( ) { return m_dwLicenseMask; } + void updateLicenseMask(std::uint32_t dwLicenseMask) { m_dwLicenseMask = dwLicenseMask; } + std::uint32_t getLicenseMask() { return m_dwLicenseMask; } std::wstring getName() { return m_packName; } #ifdef _XBOX_ONE @@ -75,18 +76,18 @@ public: #endif DLCFile *addFile(DLCManager::EDLCType type, const std::wstring &path); - DLCFile *getFile(DLCManager::EDLCType type, DWORD index); + DLCFile *getFile(DLCManager::EDLCType type, unsigned int index); DLCFile *getFile(DLCManager::EDLCType type, const std::wstring &path); - DWORD getDLCItemsCount(DLCManager::EDLCType type = DLCManager::e_DLCType_All); - DWORD getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found); + unsigned int getDLCItemsCount(DLCManager::EDLCType type = DLCManager::e_DLCType_All); + unsigned int getFileIndexAt(DLCManager::EDLCType type, const std::wstring &path, bool &found); bool doesPackContainFile(DLCManager::EDLCType type, const std::wstring &path); - DWORD GetPackID() {return m_packId;} + std::uint32_t GetPackID() {return m_packId;} - DWORD getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); } - DWORD getSkinIndexAt(const std::wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); } + unsigned int getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); } + unsigned int getSkinIndexAt(const std::wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); } DLCSkinFile *getSkinFile(const std::wstring &path) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, path); } - DLCSkinFile *getSkinFile(DWORD index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); } + DLCSkinFile *getSkinFile(unsigned int index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); } bool doesPackContainSkin(const std::wstring &path) { return doesPackContainFile(DLCManager::e_DLCType_Skin, path); } bool hasPurchasedFile(DLCManager::EDLCType type, const std::wstring &path); diff --git a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp index 2a4df2cc6..e15fd55a4 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.cpp @@ -16,9 +16,9 @@ DLCSkinFile::DLCSkinFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCTy m_uiAnimOverrideBitmask=0L; } -void DLCSkinFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCSkinFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { - app.AddMemoryTextureFile(m_path,pbData,dwBytes); + app.AddMemoryTextureFile(m_path,pbData,dataBytes); } void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const std::wstring &value) @@ -157,7 +157,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const std::ws case DLCManager::e_DLCParamType_Anim: // 4J Stu - The Xbox version used swscanf_s which isn't available in GCC. swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask); - DWORD skinId = app.getSkinIdFromPath(m_path); + std::uint32_t skinId = app.getSkinIdFromPath(m_path); app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask); break; } diff --git a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.h b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.h index 08ceb6920..9a41b7d44 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCSkinFile.h @@ -17,7 +17,7 @@ public: DLCSkinFile(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value); virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type); diff --git a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp index 10085c834..b21443776 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.cpp @@ -8,19 +8,19 @@ DLCTextureFile::DLCTextureFile(const std::wstring &path) : DLCFile(DLCManager::e m_animString = L""; m_pbData = NULL; - m_dwBytes = 0; + m_dataBytes = 0; } -void DLCTextureFile::addData(PBYTE pbData, DWORD dwBytes) +void DLCTextureFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes) { //app.AddMemoryTextureFile(m_path,pbData,dwBytes); m_pbData = pbData; - m_dwBytes = dwBytes; + m_dataBytes = dataBytes; } -PBYTE DLCTextureFile::getData(DWORD &dwBytes) +std::uint8_t *DLCTextureFile::getData(std::uint32_t &dataBytes) { - dwBytes = m_dwBytes; + dataBytes = m_dataBytes; return m_pbData; } @@ -56,4 +56,4 @@ bool DLCTextureFile::getParameterAsBool(DLCManager::EDLCParameterType type) default: return false; } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.h b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.h index 831740601..baec5e951 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCTextureFile.h @@ -8,17 +8,17 @@ private: bool m_bIsAnim; std::wstring m_animString; - PBYTE m_pbData; - DWORD m_dwBytes; + std::uint8_t *m_pbData; + std::uint32_t m_dataBytes; public: DLCTextureFile(const std::wstring &path); - virtual void addData(PBYTE pbData, DWORD dwBytes); - virtual PBYTE getData(DWORD &dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes); + virtual std::uint8_t *getData(std::uint32_t &dataBytes); virtual void addParameter(DLCManager::EDLCParameterType type, const std::wstring &value); virtual std::wstring getParameterAsString(DLCManager::EDLCParameterType type); virtual bool getParameterAsBool(DLCManager::EDLCParameterType type); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp index 9ba227607..eb6d28220 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp +++ b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.cpp @@ -5,7 +5,7 @@ DLCUIDataFile::DLCUIDataFile(const std::wstring &path) : DLCFile(DLCManager::e_DLCType_UIData,path) { m_pbData = NULL; - m_dwBytes = 0; + m_dataBytes = 0; m_canDeleteData = false; } @@ -18,15 +18,15 @@ DLCUIDataFile::~DLCUIDataFile() } } -void DLCUIDataFile::addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData) +void DLCUIDataFile::addData(std::uint8_t *pbData, std::uint32_t dataBytes,bool canDeleteData) { m_pbData = pbData; - m_dwBytes = dwBytes; + m_dataBytes = dataBytes; m_canDeleteData = canDeleteData; } -PBYTE DLCUIDataFile::getData(DWORD &dwBytes) +std::uint8_t *DLCUIDataFile::getData(std::uint32_t &dataBytes) { - dwBytes = m_dwBytes; + dataBytes = m_dataBytes; return m_pbData; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.h b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.h index a9ffa6c1f..a1ee86308 100644 --- a/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.h +++ b/Minecraft.Client/Platform/Common/DLC/DLCUIDataFile.h @@ -4,8 +4,8 @@ class DLCUIDataFile : public DLCFile { private: - PBYTE m_pbData; - DWORD m_dwBytes; + std::uint8_t *m_pbData; + std::uint32_t m_dataBytes; bool m_canDeleteData; public: @@ -15,6 +15,6 @@ public: using DLCFile::addData; using DLCFile::addParameter; - virtual void addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData = false); - virtual PBYTE getData(DWORD &dwBytes); + virtual void addData(std::uint8_t *pbData, std::uint32_t dataBytes,bool canDeleteData = false); + virtual std::uint8_t *getData(std::uint32_t &dataBytes); }; diff --git a/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp index 90cdcf816..4bd79aa8e 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.cpp @@ -9,7 +9,7 @@ AddEnchantmentRuleDefinition::AddEnchantmentRuleDefinition() m_enchantmentId = m_enchantmentLevel = 0; } -void AddEnchantmentRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void AddEnchantmentRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { GameRuleDefinition::writeAttributes(dos, numAttributes + 2); diff --git a/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.h index bb6f48ae3..d939c0f96 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/AddEnchantmentRuleDefinition.h @@ -15,7 +15,7 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_AddEnchantment; } - virtual void writeAttributes(DataOutputStream *, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); diff --git a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp index f26580add..7ae0aecf9 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.cpp @@ -12,7 +12,7 @@ AddItemRuleDefinition::AddItemRuleDefinition() m_slot = -1; } -void AddItemRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void AddItemRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 5); diff --git a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.h index 01ac84eef..d4863ec9b 100644 --- a/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/AddItemRuleDefinition.h @@ -18,7 +18,7 @@ private: public: AddItemRuleDefinition(); - virtual void writeAttributes(DataOutputStream *, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *, unsigned int numAttributes); virtual void getChildren(std::vector *children); virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_AddItem; } diff --git a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp index cd235b9e9..02e8ecc63 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.cpp @@ -30,7 +30,7 @@ ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition() delete m_location; } -void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 5); diff --git a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h index 7cf307ae1..a7495c841 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/ApplySchematicRuleDefinition.h @@ -30,7 +30,7 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_ApplySchematic; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); void processSchematic(AABB *chunkBox, LevelChunk *chunk); diff --git a/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.cpp b/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.cpp index 9140ed526..eb8809555 100644 --- a/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.cpp @@ -9,7 +9,7 @@ BiomeOverride::BiomeOverride() m_biomeId = 0; } -void BiomeOverride::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void BiomeOverride::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 3); @@ -52,8 +52,8 @@ bool BiomeOverride::isBiome(int id) return m_biomeId == id; } -void BiomeOverride::getTileValues(BYTE &tile, BYTE &topTile) +void BiomeOverride::getTileValues(std::uint8_t &tile, std::uint8_t &topTile) { - if(m_tile != 0) tile = (BYTE)m_tile; - if(m_topTile != 0) topTile = (BYTE)m_topTile; -} \ No newline at end of file + if(m_tile != 0) tile = m_tile; + if(m_topTile != 0) topTile = m_topTile; +} diff --git a/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.h b/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.h index 6ce91bbd1..29cd64f5b 100644 --- a/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.h +++ b/Minecraft.Client/Platform/Common/GameRules/BiomeOverride.h @@ -6,8 +6,8 @@ class BiomeOverride : public GameRuleDefinition { private: - BYTE m_topTile; - BYTE m_tile; + std::uint8_t m_topTile; + std::uint8_t m_tile; int m_biomeId; public: @@ -15,9 +15,9 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_BiomeOverride; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); bool isBiome(int id); - void getTileValues(BYTE &tile, BYTE &topTile); -}; \ No newline at end of file + void getTileValues(std::uint8_t &tile, std::uint8_t &topTile); +}; diff --git a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp index 4e6a757cc..a97b585e0 100644 --- a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.cpp @@ -17,7 +17,7 @@ CollectItemRuleDefinition::~CollectItemRuleDefinition() { } -void CollectItemRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void CollectItemRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { GameRuleDefinition::writeAttributes(dos, numAttributes + 3); diff --git a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.h index 3a6b981c9..d9bc6b7e3 100644 --- a/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/CollectItemRuleDefinition.h @@ -20,7 +20,7 @@ public: ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_CollectItemRule; } - virtual void writeAttributes(DataOutputStream *, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *, unsigned int numAttributes); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); virtual int getGoal(); diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp index 8c78623ef..ad9238a70 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.cpp @@ -55,7 +55,7 @@ GameRuleDefinition *ConsoleGenerateStructure::addChild(ConsoleGameRules::EGameRu return rule; } -void ConsoleGenerateStructure::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void ConsoleGenerateStructure::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 5); diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.h b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.h index 6ad055949..e9aaaface 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.h +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleGenerateStructure.h @@ -23,7 +23,7 @@ public: virtual void getChildren(std::vector *children); virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); // StructurePiece diff --git a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp index 0a7987b1b..1253db9e8 100644 --- a/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/ConsoleSchematicFile.cpp @@ -37,7 +37,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos) dos->writeInt(m_ySize); dos->writeInt(m_zSize); - byteArray ba(new BYTE[ m_data.length ], m_data.length); + byteArray ba(new std::uint8_t[ m_data.length ], m_data.length); Compression::getCompression()->CompressLZXRLE( ba.data, &ba.length, m_data.data, m_data.length); diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp index f94f5c573..0aaabb754 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.cpp @@ -29,7 +29,7 @@ void GameRuleDefinition::write(DataOutputStream *dos) (*it)->write(dos); } -void GameRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void GameRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { dos->writeInt(numAttributes + 3); diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h index 289734428..ae917556f 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleDefinition.h @@ -35,7 +35,7 @@ public: virtual void write(DataOutputStream *); - virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual void getChildren(std::vector *); virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp index aaa5b40d3..bb64f0c1f 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.cpp @@ -103,7 +103,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack) for(int i = 0; i < gameRulesCount; ++i) { DLCGameRulesHeader *dlcHeader = (DLCGameRulesHeader *)pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i); - DWORD dSize; + std::uint32_t dSize; uint8_t *dData = dlcHeader->getData(dSize); LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions(); @@ -125,7 +125,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack) { DLCGameRulesFile *dlcFile = (DLCGameRulesFile *)pack->getFile(DLCManager::e_DLCType_GameRules, i); - DWORD dSize; + std::uint32_t dSize; uint8_t *dData = dlcFile->getData(dSize); LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions(); @@ -142,7 +142,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack) } } -LevelGenerationOptions *GameRuleManager::loadGameRules(uint8_t *dIn, UINT dSize) +LevelGenerationOptions *GameRuleManager::loadGameRules(uint8_t *dIn, unsigned int dSize) { LevelGenerationOptions *lgo = new LevelGenerationOptions(); lgo->setGrSource( new JustGrSource() ); @@ -153,7 +153,7 @@ LevelGenerationOptions *GameRuleManager::loadGameRules(uint8_t *dIn, UINT dSize) } // 4J-JEV: Reverse of saveGameRules. -void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize) +void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, unsigned int dSize) { app.DebugPrintf("GameRuleManager::LoadingGameRules:\n"); @@ -170,11 +170,11 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, U for (int i = 0; i < 8; i++) dis.readByte(); - BYTE compression_type = dis.readByte(); + std::uint8_t compression_type = dis.readByte(); app.DebugPrintf("\tcompressionType=%d.\n", compression_type); - UINT compr_len, decomp_len; + unsigned int compr_len, decomp_len; compr_len = dis.readInt(); decomp_len = dis.readInt(); @@ -183,8 +183,8 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, U // Decompress File Body - byteArray content(new BYTE[decomp_len], decomp_len), - compr_content(new BYTE[compr_len], compr_len); + byteArray content(new std::uint8_t[decomp_len], decomp_len), + compr_content(new std::uint8_t[compr_len], compr_len); dis.read(compr_content); Compression::getCompression()->SetDecompressionType( (Compression::ECompressionTypes)compression_type ); @@ -203,14 +203,14 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, U // Read StringTable. byteArray bStringTable; bStringTable.length = dis2.readInt(); - bStringTable.data = new BYTE[ bStringTable.length ]; + bStringTable.data = new std::uint8_t[ bStringTable.length ]; dis2.read(bStringTable); StringTable *strings = new StringTable(bStringTable.data, bStringTable.length); // Read RuleFile. byteArray bRuleFile; bRuleFile.length = content.length - bStringTable.length; - bRuleFile.data = new BYTE[ bRuleFile.length ]; + bRuleFile.data = new std::uint8_t[ bRuleFile.length ]; dis2.read(bRuleFile); // 4J-JEV: I don't believe that the path-name is ever used. @@ -240,7 +240,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, U } // 4J-JEV: Reverse of loadGameRules. -void GameRuleManager::saveGameRules(uint8_t **dOut, UINT *dSize) +void GameRuleManager::saveGameRules(uint8_t **dOut, unsigned int *dSize) { if (m_currentGameRuleDefinitions == NULL && m_currentLevelGenerationOptions == NULL) @@ -264,7 +264,7 @@ void GameRuleManager::saveGameRules(uint8_t **dOut, UINT *dSize) // Write 8 bytes of empty space in case we need them later. // Mainly useful for the ones we save embedded in game saves. - for (UINT i = 0; i < 8; i++) + for (unsigned int i = 0; i < 8; i++) dos.writeByte(0x0); dos.writeByte(APPROPRIATE_COMPRESSION_TYPE); // m_compressionType @@ -306,7 +306,7 @@ void GameRuleManager::saveGameRules(uint8_t **dOut, UINT *dSize) } // Compress compr_dos and write to dos. - byteArray compr_ba(new BYTE[ compr_baos.buf.length ], compr_baos.buf.length); + byteArray compr_ba(new std::uint8_t[ compr_baos.buf.length ], compr_baos.buf.length); Compression::getCompression()->CompressLZXRLE( compr_ba.data, &compr_ba.length, compr_baos.buf.data, compr_baos.buf.length ); @@ -373,15 +373,15 @@ void GameRuleManager::writeRuleFile(DataOutputStream *dos) m_currentGameRuleDefinitions->write(dos); } -bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize, StringTable *strings) //(DLCGameRulesFile *dlcFile, StringTable *strings) +bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, unsigned int dSize, StringTable *strings) //(DLCGameRulesFile *dlcFile, StringTable *strings) { bool levelGenAdded = false; bool gameRulesAdded = false; LevelGenerationOptions *levelGenerator = lgo;//new LevelGenerationOptions(); LevelRuleset *gameRules = new LevelRuleset(); - //DWORD dwLen = 0; - //PBYTE pbData = dlcFile->getData(dwLen); + //std::uint32_t dataLength = 0; + //std::uint8_t *data = dlcFile->getData(dataLength); //byteArray data(pbData,dwLen); byteArray data(dIn, dSize); @@ -469,15 +469,15 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UI } // string lookup. - UINT numStrings = contentDis->readInt(); + unsigned int numStrings = contentDis->readInt(); std::vector tagsAndAtts; - for (UINT i = 0; i < numStrings; i++) + for (unsigned int i = 0; i < numStrings; i++) tagsAndAtts.push_back( contentDis->readUTF() ); std::unordered_map tagIdMap; for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < (int)ConsoleGameRules::eGameRuleType_Count; ++type) { - for(UINT i = 0; i < numStrings; ++i) + for(unsigned int i = 0; i < numStrings; ++i) { if(tagsAndAtts[i].compare(wchTagNameA[type]) == 0) { @@ -492,7 +492,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UI std::unordered_map attrIdMap; for(int attr = (int)ConsoleGameRules::eGameRuleAttr_descriptionName; attr < (int)ConsoleGameRules::eGameRuleAttr_Count; ++attr) { - for (UINT i = 0; i < numStrings; i++) + for (unsigned int i = 0; i < numStrings; i++) { if (tagsAndAtts[i].compare(wchAttrNameA[attr]) == 0) { @@ -503,8 +503,8 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UI }*/ // subfile - UINT numFiles = contentDis->readInt(); - for (UINT i = 0; i < numFiles; i++) + unsigned int numFiles = contentDis->readInt(); + for (unsigned int i = 0; i < numFiles; i++) { std::wstring sFilename = contentDis->readUTF(); int length = contentDis->readInt(); @@ -519,8 +519,8 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UI LEVEL_GEN_ID lgoID = LEVEL_GEN_ID_NULL; // xml objects - UINT numObjects = contentDis->readInt(); - for(UINT i = 0; i < numObjects; ++i) + unsigned int numObjects = contentDis->readInt(); + for(unsigned int i = 0; i < numObjects; ++i) { int tagId = contentDis->readInt(); ConsoleGameRules::EGameRuleType tagVal = ConsoleGameRules::eGameRuleType_Invalid; @@ -584,7 +584,7 @@ LevelGenerationOptions *GameRuleManager::readHeader(DLCGameRulesHeader *grh) void GameRuleManager::readAttributes(DataInputStream *dis, std::vector *tagsAndAtts, GameRuleDefinition *rule) { int numAttrs = dis->readInt(); - for (UINT att = 0; att < numAttrs; ++att) + for (unsigned int att = 0; att < static_cast(numAttrs); ++att) { int attID = dis->readInt(); std::wstring value = dis->readUTF(); @@ -596,7 +596,7 @@ void GameRuleManager::readAttributes(DataInputStream *dis, std::vector *tagsAndAtts, std::unordered_map *tagIdMap, GameRuleDefinition *rule) { int numChildren = dis->readInt(); - for(UINT child = 0; child < numChildren; ++child) + for(unsigned int child = 0; child < static_cast(numChildren); ++child) { int tagId = dis->readInt(); ConsoleGameRules::EGameRuleType tagVal = ConsoleGameRules::eGameRuleType_Invalid; @@ -663,7 +663,7 @@ void GameRuleManager::loadDefaultGameRules() if(app.getArchiveFileSize(fpTutorial) >= 0) { DLCPack *pack = new DLCPack(L"",0xffffffff); - DWORD dwFilesProcessed = 0; + unsigned int dwFilesProcessed = 0; if ( app.m_dlcManager.readDLCDataFile(dwFilesProcessed,fpTutorial,pack,true) ) { app.m_dlcManager.addPack(pack); @@ -720,7 +720,7 @@ bool GameRuleManager::loadGameRulesPack(File *path) if(path->exists()) { DLCPack *pack = new DLCPack(L"",0xffffffff); - DWORD dwFilesProcessed = 0; + unsigned int dwFilesProcessed = 0; if( app.m_dlcManager.readDLCDataFile(dwFilesProcessed, path->getPath(),pack)) { app.m_dlcManager.addPack(pack); @@ -749,7 +749,7 @@ void GameRuleManager::setLevelGenerationOptions(LevelGenerationOptions *levelGen m_currentLevelGenerationOptions->reset_start(); } -LPCWSTR GameRuleManager::GetGameRulesString(const std::wstring &key) +const wchar_t *GameRuleManager::GetGameRulesString(const std::wstring &key) { if(m_currentGameRuleDefinitions != NULL && !key.empty() ) { diff --git a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.h b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.h index 8d55510af..95a0dbf4d 100644 --- a/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.h +++ b/Minecraft.Client/Platform/Common/GameRules/GameRuleManager.h @@ -40,10 +40,10 @@ public: void loadGameRules(DLCPack *); - LevelGenerationOptions *loadGameRules(uint8_t *dIn, UINT dSize); - void loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize); + LevelGenerationOptions *loadGameRules(uint8_t *dIn, unsigned int dSize); + void loadGameRules(LevelGenerationOptions *lgo, uint8_t *dIn, unsigned int dSize); - void saveGameRules(uint8_t **dOut, UINT *dSize); + void saveGameRules(uint8_t **dOut, unsigned int *dSize); private: LevelGenerationOptions *readHeader(DLCGameRulesHeader *grh); @@ -51,7 +51,7 @@ private: void writeRuleFile(DataOutputStream *dos); public: - bool readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, UINT dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings); + bool readRuleFile(LevelGenerationOptions *lgo, uint8_t *dIn, unsigned int dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings); private: void readAttributes(DataInputStream *dis, std::vector *tagsAndAtts, GameRuleDefinition *rule); @@ -72,7 +72,7 @@ public: void setLevelGenerationOptions(LevelGenerationOptions *levelGen); LevelRuleset *getGameRuleDefinitions() { return m_currentGameRuleDefinitions; } LevelGenerationOptions *getLevelGenerationOptions() { return m_currentLevelGenerationOptions; } - LPCWSTR GetGameRulesString(const std::wstring &key); + const wchar_t *GetGameRulesString(const std::wstring &key); // 4J-JEV: // Properly cleans-up and unloads the current set of gameRules. diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp index 17e861420..c3875f134 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.cpp @@ -23,16 +23,16 @@ JustGrSource::JustGrSource() } bool JustGrSource::requiresTexturePack() {return m_bRequiresTexturePack;} -UINT JustGrSource::getRequiredTexturePackId() {return m_requiredTexturePackId;} +std::uint32_t JustGrSource::getRequiredTexturePackId() {return m_requiredTexturePackId;} std::wstring JustGrSource::getDefaultSaveName() {return m_defaultSaveName;} -LPCWSTR JustGrSource::getWorldName() {return m_worldName.c_str();} -LPCWSTR JustGrSource::getDisplayName() {return m_displayName.c_str();} +const wchar_t *JustGrSource::getWorldName() {return m_worldName.c_str();} +const wchar_t *JustGrSource::getDisplayName() {return m_displayName.c_str();} std::wstring JustGrSource::getGrfPath() {return m_grfPath;} bool JustGrSource::requiresBaseSave() { return m_bRequiresBaseSave; }; std::wstring JustGrSource::getBaseSavePath() { return m_baseSavePath; }; void JustGrSource::setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;} -void JustGrSource::setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;} +void JustGrSource::setRequiredTexturePackId(std::uint32_t x) {m_requiredTexturePackId = x;} void JustGrSource::setDefaultSaveName(const std::wstring &x) {m_defaultSaveName = x;} void JustGrSource::setWorldName(const std::wstring &x) {m_worldName = x;} void JustGrSource::setDisplayName(const std::wstring &x) {m_displayName = x;} @@ -55,7 +55,7 @@ LevelGenerationOptions::LevelGenerationOptions() m_bRequiresGameRules = false; m_pbBaseSaveData = NULL; - m_dwBaseSaveSize = 0; + m_baseSaveSize = 0; } LevelGenerationOptions::~LevelGenerationOptions() @@ -90,7 +90,7 @@ LevelGenerationOptions::~LevelGenerationOptions() ConsoleGameRules::EGameRuleType LevelGenerationOptions::getActionType() { return ConsoleGameRules::eGameRuleType_LevelGenerationOptions; } -void LevelGenerationOptions::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void LevelGenerationOptions::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 5); @@ -332,7 +332,7 @@ void LevelGenerationOptions::clearSchematics() m_schematics.clear(); } -ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstring &filename, PBYTE pbData, DWORD dwLen) +ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstring &filename, std::uint8_t *pbData, unsigned int dataLength) { // If we have already loaded this, just return AUTO_VAR(it, m_schematics.find(filename)); @@ -346,7 +346,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const std::wstri } ConsoleSchematicFile *schematic = NULL; - byteArray data(pbData,dwLen); + byteArray data(pbData, dataLength); ByteArrayInputStream bais(data); DataInputStream dis(&bais); schematic = new ConsoleSchematicFile(); @@ -389,7 +389,7 @@ void LevelGenerationOptions::loadStringTable(StringTable *table) m_stringTable = table; } -LPCWSTR LevelGenerationOptions::getString(const std::wstring &key) +const wchar_t *LevelGenerationOptions::getString(const std::wstring &key) { if(m_stringTable == NULL) { @@ -401,7 +401,7 @@ LPCWSTR LevelGenerationOptions::getString(const std::wstring &key) } } -void LevelGenerationOptions::getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile) +void LevelGenerationOptions::getBiomeOverride(int biomeId, std::uint8_t &tile, std::uint8_t &topTile) { for(AUTO_VAR(it, m_biomeOverrides.begin()); it != m_biomeOverrides.end(); ++it) { @@ -478,10 +478,10 @@ bool LevelGenerationOptions::isFromSave() { return getSrc() == eSrc_fromSave; } bool LevelGenerationOptions::isFromDLC() { return getSrc() == eSrc_fromDLC; } bool LevelGenerationOptions::requiresTexturePack() { return info()->requiresTexturePack(); } -UINT LevelGenerationOptions::getRequiredTexturePackId() { return info()->getRequiredTexturePackId(); } +std::uint32_t LevelGenerationOptions::getRequiredTexturePackId() { return info()->getRequiredTexturePackId(); } std::wstring LevelGenerationOptions::getDefaultSaveName() { return info()->getDefaultSaveName(); } -LPCWSTR LevelGenerationOptions::getWorldName() { return info()->getWorldName(); } -LPCWSTR LevelGenerationOptions::getDisplayName() { return info()->getDisplayName(); } +const wchar_t *LevelGenerationOptions::getWorldName() { return info()->getWorldName(); } +const wchar_t *LevelGenerationOptions::getDisplayName() { return info()->getDisplayName(); } std::wstring LevelGenerationOptions::getGrfPath() { return info()->getGrfPath(); } bool LevelGenerationOptions::requiresBaseSave() { return info()->requiresBaseSave(); } std::wstring LevelGenerationOptions::getBaseSavePath() { return info()->getBaseSavePath(); } @@ -489,7 +489,7 @@ std::wstring LevelGenerationOptions::getBaseSavePath() { return info()->getBaseS void LevelGenerationOptions::setGrSource(GrSource *grs) { m_pSrc = grs; } void LevelGenerationOptions::setRequiresTexturePack(bool x) { info()->setRequiresTexturePack(x); } -void LevelGenerationOptions::setRequiredTexturePackId(UINT x) { info()->setRequiredTexturePackId(x); } +void LevelGenerationOptions::setRequiredTexturePackId(std::uint32_t x) { info()->setRequiredTexturePackId(x); } void LevelGenerationOptions::setDefaultSaveName(const std::wstring &x) { info()->setDefaultSaveName(x); } void LevelGenerationOptions::setWorldName(const std::wstring &x) { info()->setWorldName(x); } void LevelGenerationOptions::setDisplayName(const std::wstring &x) { info()->setDisplayName(x); } @@ -498,10 +498,10 @@ void LevelGenerationOptions::setBaseSavePath(const std::wstring &x) { info()->se bool LevelGenerationOptions::ready() { return info()->ready(); } -void LevelGenerationOptions::setBaseSaveData(PBYTE pbData, DWORD dwSize) { m_pbBaseSaveData = pbData; m_dwBaseSaveSize = dwSize; } -PBYTE LevelGenerationOptions::getBaseSaveData(DWORD &size) { size = m_dwBaseSaveSize; return m_pbBaseSaveData; } -bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != NULL; } -void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_dwBaseSaveSize = 0; } +void LevelGenerationOptions::setBaseSaveData(std::uint8_t *pbData, unsigned int dataSize) { m_pbBaseSaveData = pbData; m_baseSaveSize = dataSize; } +std::uint8_t *LevelGenerationOptions::getBaseSaveData(unsigned int &size) { size = m_baseSaveSize; return m_pbBaseSaveData; } +bool LevelGenerationOptions::hasBaseSaveData() { return m_baseSaveSize > 0 && m_pbBaseSaveData != NULL; } +void LevelGenerationOptions::deleteBaseSaveData() { delete[] m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_baseSaveSize = 0; } bool LevelGenerationOptions::hasLoadedData() { return m_hasLoadedData; } void LevelGenerationOptions::setLoadedData() { m_hasLoadedData = true; } diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h index 11970a555..1ba465405 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h +++ b/Minecraft.Client/Platform/Common/GameRules/LevelGenerationOptions.h @@ -3,6 +3,8 @@ // #pragma message("LevelGenerationOptions.h ") +#include + #include "GameRuleDefinition.h" #include "../../Minecraft.World/WorldGen/Features/StructureFeature.h" @@ -24,16 +26,16 @@ public: virtual ~GrSource(){} virtual bool requiresTexturePack()=0; - virtual UINT getRequiredTexturePackId()=0; + virtual std::uint32_t getRequiredTexturePackId()=0; virtual std::wstring getDefaultSaveName()=0; - virtual LPCWSTR getWorldName()=0; - virtual LPCWSTR getDisplayName()=0; + virtual const wchar_t *getWorldName()=0; + virtual const wchar_t *getDisplayName()=0; virtual std::wstring getGrfPath()=0; virtual bool requiresBaseSave() = 0; virtual std::wstring getBaseSavePath() = 0; virtual void setRequiresTexturePack(bool)=0; - virtual void setRequiredTexturePackId(UINT)=0; + virtual void setRequiredTexturePackId(std::uint32_t)=0; virtual void setDefaultSaveName(const std::wstring &)=0; virtual void setWorldName(const std::wstring &)=0; virtual void setDisplayName(const std::wstring &)=0; @@ -42,7 +44,7 @@ public: virtual bool ready()=0; - //virtual void getGrfData(PBYTE &pData, DWORD &pSize)=0; + //virtual void getGrfData(std::uint8_t *&pData, unsigned int &pSize)=0; }; class JustGrSource : public GrSource @@ -52,23 +54,23 @@ protected: std::wstring m_displayName; std::wstring m_defaultSaveName; bool m_bRequiresTexturePack; - int m_requiredTexturePackId; + std::uint32_t m_requiredTexturePackId; std::wstring m_grfPath; std::wstring m_baseSavePath; bool m_bRequiresBaseSave; public: virtual bool requiresTexturePack(); - virtual UINT getRequiredTexturePackId(); + virtual std::uint32_t getRequiredTexturePackId(); virtual std::wstring getDefaultSaveName(); - virtual LPCWSTR getWorldName(); - virtual LPCWSTR getDisplayName(); + virtual const wchar_t *getWorldName(); + virtual const wchar_t *getDisplayName(); virtual std::wstring getGrfPath(); virtual bool requiresBaseSave(); virtual std::wstring getBaseSavePath(); virtual void setRequiresTexturePack(bool x); - virtual void setRequiredTexturePackId(UINT x); + virtual void setRequiredTexturePackId(std::uint32_t x); virtual void setDefaultSaveName(const std::wstring &x); virtual void setWorldName(const std::wstring &x); virtual void setDisplayName(const std::wstring &x); @@ -104,8 +106,8 @@ private: bool m_hasLoadedData; - PBYTE m_pbBaseSaveData; - DWORD m_dwBaseSaveSize; + std::uint8_t *m_pbBaseSaveData; + unsigned int m_baseSaveSize; public: @@ -117,10 +119,10 @@ public: bool isFromDLC(); bool requiresTexturePack(); - UINT getRequiredTexturePackId(); + std::uint32_t getRequiredTexturePackId(); std::wstring getDefaultSaveName(); - LPCWSTR getWorldName(); - LPCWSTR getDisplayName(); + const wchar_t *getWorldName(); + const wchar_t *getDisplayName(); std::wstring getGrfPath(); bool requiresBaseSave(); std::wstring getBaseSavePath(); @@ -128,7 +130,7 @@ public: void setGrSource(GrSource *grs); void setRequiresTexturePack(bool x); - void setRequiredTexturePackId(UINT x); + void setRequiredTexturePackId(std::uint32_t x); void setDefaultSaveName(const std::wstring &x); void setWorldName(const std::wstring &x); void setDisplayName(const std::wstring &x); @@ -137,8 +139,8 @@ public: bool ready(); - void setBaseSaveData(PBYTE pbData, DWORD dwSize); - PBYTE getBaseSaveData(DWORD &size); + void setBaseSaveData(std::uint8_t *pbData, unsigned int dataSize); + std::uint8_t *getBaseSaveData(unsigned int &size); bool hasBaseSaveData(); void deleteBaseSaveData(); @@ -169,7 +171,7 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType(); - virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual void getChildren(std::vector *children); virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); @@ -187,7 +189,7 @@ private: void clearSchematics(); public: - ConsoleSchematicFile *loadSchematicFile(const std::wstring &filename, PBYTE pbData, DWORD dwLen); + ConsoleSchematicFile *loadSchematicFile(const std::wstring &filename, std::uint8_t *pbData, unsigned int dataLength); public: ConsoleSchematicFile *getSchematicFile(const std::wstring &filename); @@ -197,11 +199,11 @@ public: void setRequiredGameRules(LevelRuleset *rules); LevelRuleset *getRequiredGameRules(); - void getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile); + void getBiomeOverride(int biomeId, std::uint8_t &tile, std::uint8_t &topTile); bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature); void loadStringTable(StringTable *table); - LPCWSTR getString(const std::wstring &key); + const wchar_t *getString(const std::wstring &key); std::unordered_map *getUnfinishedSchematicFiles(); diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelRules.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelRules.cpp index a15749b34..94d2d55f7 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelRules.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelRules.cpp @@ -6,7 +6,7 @@ LevelRules::LevelRules() { } -void LevelRules::addLevelRule(const std::wstring &displayName, PBYTE pbData, DWORD dwLen) +void LevelRules::addLevelRule(const std::wstring &displayName, std::uint8_t *pbData, unsigned int dataLength) { } @@ -17,4 +17,4 @@ void LevelRules::addLevelRule(const std::wstring &displayName, LevelRuleset *roo void LevelRules::removeLevelRule(LevelRuleset *removing) { // TODO ? -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelRules.h b/Minecraft.Client/Platform/Common/GameRules/LevelRules.h index e88cd5dac..d32577eef 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelRules.h +++ b/Minecraft.Client/Platform/Common/GameRules/LevelRules.h @@ -7,8 +7,8 @@ class LevelRules public: LevelRules(); - void addLevelRule(const std::wstring &displayName, PBYTE pbData, DWORD dwLen); + void addLevelRule(const std::wstring &displayName, std::uint8_t *pbData, unsigned int dataLength); void addLevelRule(const std::wstring &displayName, LevelRuleset *rootRule); void removeLevelRule(LevelRuleset *removing); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp index 7137e7ac7..0c0e2cb08 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.cpp @@ -44,7 +44,7 @@ void LevelRuleset::loadStringTable(StringTable *table) m_stringTable = table; } -LPCWSTR LevelRuleset::getString(const std::wstring &key) +const wchar_t *LevelRuleset::getString(const std::wstring &key) { if(m_stringTable == NULL) { diff --git a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.h b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.h index 93802450c..1b7810659 100644 --- a/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.h +++ b/Minecraft.Client/Platform/Common/GameRules/LevelRuleset.h @@ -19,9 +19,9 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_LevelRules; } void loadStringTable(StringTable *table); - LPCWSTR getString(const std::wstring &key); + const wchar_t *getString(const std::wstring &key); AABB *getNamedArea(const std::wstring &areaName); StringTable *getStringTable() { return m_stringTable; } -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.cpp index 9e6480016..bf79d1c14 100644 --- a/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.cpp @@ -14,7 +14,7 @@ NamedAreaRuleDefinition::~NamedAreaRuleDefinition() delete m_area; } -void NamedAreaRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void NamedAreaRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { GameRuleDefinition::writeAttributes(dos, numAttributes + 7); diff --git a/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.h index 8386b3fd4..ff3eb3cb9 100644 --- a/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/NamedAreaRuleDefinition.h @@ -12,7 +12,7 @@ public: NamedAreaRuleDefinition(); ~NamedAreaRuleDefinition(); - virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_NamedArea; } diff --git a/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp b/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp index 5ab776b68..be44ca2b4 100644 --- a/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/StartFeature.cpp @@ -9,7 +9,7 @@ StartFeature::StartFeature() m_feature = StructureFeature::eFeature_Temples; } -void StartFeature::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void StartFeature::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 3); diff --git a/Minecraft.Client/Platform/Common/GameRules/StartFeature.h b/Minecraft.Client/Platform/Common/GameRules/StartFeature.h index b725fccc4..6a153bfcd 100644 --- a/Minecraft.Client/Platform/Common/GameRules/StartFeature.h +++ b/Minecraft.Client/Platform/Common/GameRules/StartFeature.h @@ -15,7 +15,7 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_StartFeature; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature); diff --git a/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp index 741773782..38ffc2768 100644 --- a/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.cpp @@ -24,7 +24,7 @@ UpdatePlayerRuleDefinition::~UpdatePlayerRuleDefinition() } } -void UpdatePlayerRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void UpdatePlayerRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { int attrCount = 3; if(m_bUpdateHealth) ++attrCount; diff --git a/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.h index 2b14dd508..0ac062dd7 100644 --- a/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/UpdatePlayerRuleDefinition.h @@ -26,7 +26,7 @@ public: virtual void getChildren(std::vector *children); virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); - virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); virtual void postProcessPlayer(std::shared_ptr player); diff --git a/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.cpp b/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.cpp index cb2284a25..5b775ea81 100644 --- a/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.cpp @@ -8,7 +8,7 @@ UseTileRuleDefinition::UseTileRuleDefinition() m_useCoords = false; } -void UseTileRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes) +void UseTileRuleDefinition::writeAttributes(DataOutputStream *dos, unsigned int numAttributes) { GameRuleDefinition::writeAttributes(dos, numAttributes + 5); diff --git a/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.h b/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.h index df3a584ac..ee047d96b 100644 --- a/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.h +++ b/Minecraft.Client/Platform/Common/GameRules/UseTileRuleDefinition.h @@ -17,7 +17,7 @@ public: ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_UseTileRule; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.cpp index 60d64a113..a16822fe9 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.cpp @@ -9,7 +9,7 @@ XboxStructureActionGenerateBox::XboxStructureActionGenerateBox() m_skipAir = false; } -void XboxStructureActionGenerateBox::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void XboxStructureActionGenerateBox::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 9); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.h b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.h index 3570b5a3f..44ff199c9 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.h +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionGenerateBox.h @@ -19,7 +19,7 @@ public: virtual int getEndY() { return m_y1; } virtual int getEndZ() { return m_z1; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); bool generateBoxInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.cpp index c9250561b..dcc5d59ed 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.cpp @@ -8,7 +8,7 @@ XboxStructureActionPlaceBlock::XboxStructureActionPlaceBlock() m_x = m_y = m_z = m_tile = m_data = 0; } -void XboxStructureActionPlaceBlock::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void XboxStructureActionPlaceBlock::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 5); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.h b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.h index 75648965c..4101028a0 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.h +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceBlock.h @@ -18,7 +18,7 @@ public: virtual int getEndY() { return m_y; } virtual int getEndZ() { return m_z; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); bool placeBlockInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp index f4819e329..04606e7ca 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.cpp @@ -21,7 +21,7 @@ XboxStructureActionPlaceContainer::~XboxStructureActionPlaceContainer() } // 4J-JEV: Super class handles attr-facing fine. -//void XboxStructureActionPlaceContainer::writeAttributes(DataOutputStream *dos, UINT numAttrs) +//void XboxStructureActionPlaceContainer::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) void XboxStructureActionPlaceContainer::getChildren(std::vector *children) diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.h b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.h index bef68bbb9..f9950e1ba 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.h +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceContainer.h @@ -21,7 +21,7 @@ public: virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); // 4J-JEV: Super class handles attr-facing fine. - //virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); + //virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttributes); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp index 936e7bc8d..af33a418d 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.cpp @@ -15,7 +15,7 @@ XboxStructureActionPlaceSpawner::~XboxStructureActionPlaceSpawner() { } -void XboxStructureActionPlaceSpawner::writeAttributes(DataOutputStream *dos, UINT numAttrs) +void XboxStructureActionPlaceSpawner::writeAttributes(DataOutputStream *dos, unsigned int numAttrs) { XboxStructureActionPlaceBlock::writeAttributes(dos, numAttrs + 1); diff --git a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.h b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.h index 92899b93e..933a467c4 100644 --- a/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.h +++ b/Minecraft.Client/Platform/Common/GameRules/XboxStructureActionPlaceSpawner.h @@ -17,7 +17,7 @@ public: virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_PlaceSpawner; } - virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); + virtual void writeAttributes(DataOutputStream *dos, unsigned int numAttrs); virtual void addAttribute(const std::wstring &attributeName, const std::wstring &attributeValue); bool placeSpawnerInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB); diff --git a/Minecraft.Client/Platform/Common/Minecraft_Macros.h b/Minecraft.Client/Platform/Common/Minecraft_Macros.h index 4f1f096a4..1c5b83e76 100644 --- a/Minecraft.Client/Platform/Common/Minecraft_Macros.h +++ b/Minecraft.Client/Platform/Common/Minecraft_Macros.h @@ -1,6 +1,8 @@ #pragma once +#include + // 3 bit user index // 5 bits alpha // 1 bit decoration @@ -35,8 +37,8 @@ #define MAKE_SKIN_BITMASK(bDlcSkin, dwSkinId) ( (bDlcSkin?0x80000000:0) | (dwSkinId & 0x7FFFFFFF) ) #define IS_SKIN_ID_IN_RANGE(dwSkinId) (dwSkinId <= 0x7FFFFFFF) -#define GET_DLC_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x7FFFFFFF) -#define GET_UGC_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x7FFFFFE0) -#define GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiBitmask) (((DWORD)uiBitmask)&0x0000001F) -#define GET_IS_DLC_SKIN_FROM_BITMASK(uiBitmask) ((((DWORD)uiBitmask)&0x80000000)?true:false) +#define GET_DLC_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast(uiBitmask) & 0x7FFFFFFF) +#define GET_UGC_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast(uiBitmask) & 0x7FFFFFE0) +#define GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast(uiBitmask) & 0x0000001F) +#define GET_IS_DLC_SKIN_FROM_BITMASK(uiBitmask) ((static_cast(uiBitmask) & 0x80000000) ? true : false) diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp index a62be6143..84cdf7740 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.cpp @@ -146,7 +146,7 @@ void CGameNetworkManager::DoWork() #endif } -bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter) +bool CGameNetworkManager::_RunNetworkGame(void *lpParameter) { bool success = true; @@ -184,7 +184,7 @@ bool CGameNetworkManager::_RunNetworkGame(LPVOID lpParameter) return success; } -bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParameter) +bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, void *lpParameter) { #ifdef _DURANGO ProfileManager.SetDeferredSignoutEnabled(true); @@ -645,7 +645,7 @@ bool CGameNetworkManager::GetGameSessionInfo(int iPad, SessionID sessionId,Frien return s_pPlatformNetworkManager->GetGameSessionInfo( iPad, sessionId, foundSession ); } -void CGameNetworkManager::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ) +void CGameNetworkManager::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ) { s_pPlatformNetworkManager->SetSessionsUpdatedCallback( SessionsUpdatedCallback, pSearchParam ); } @@ -681,7 +681,7 @@ CGameNetworkManager::eJoinGameResult CGameNetworkManager::JoinGame(FriendSession return (eJoinGameResult)(s_pPlatformNetworkManager->JoinGame( searchResult, localUsersMask, primaryUserIndex )); } -void CGameNetworkManager::CancelJoinGame(LPVOID lpParam) +void CGameNetworkManager::CancelJoinGame(void *lpParam) { #ifdef _XBOX_ONE s_pPlatformNetworkManager->CancelJoinGame(); @@ -705,7 +705,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin int npAvailability = ProfileManager.getNPAvailability(iPad); if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); @@ -749,7 +749,7 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin } else if(noPrivileges) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); } @@ -924,7 +924,7 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc( void* lpParam ) } else { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CGameNetworkManager::MustSignInReturned_0,lpParam, app.GetStringTable()); @@ -1060,7 +1060,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) MinecraftServer *pServer = MinecraftServer::getInstance(); #if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; if( g_NetworkManager.m_bLastDisconnectWasLostRoomOnly ) { @@ -1084,7 +1084,7 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc( void* lpParam ) #elif defined(_XBOX_ONE) if( g_NetworkManager.m_bFullSessionMessageOnNextSessionChange ) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME, IDS_IN_PARTY_SESSION_FULL, uiIDA,1,ProfileManager.GetPrimaryPad()); pMinecraft->progressRenderer->progressStartNoAbort( IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME ); @@ -1583,7 +1583,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * if (npAvailability == SCE_NP_ERROR_AGE_RESTRICTION) { // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive if the npAvailability isn't SCE_OK - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); } @@ -1592,14 +1592,14 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * // Signed in to PSN but not connected (no internet access) assert(!ProfileManager.isConnectedToPSN(iPadNotSignedInLive)); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, iPadNotSignedInLive, NULL, NULL, app.GetStringTable()); } else { // Not signed in to PSN - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, iPadNotSignedInLive, &CGameNetworkManager::MustSignInReturned_1, (void *)pInviteInfo, app.GetStringTable(), NULL, 0, false); } @@ -1633,14 +1633,14 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * // if (ProfileManager.IsSignedInPSN(ProfileManager.GetPrimaryPad())) // { // // Signed in to PSN but not connected (no internet access) -// UINT uiIDA[1]; +// unsigned int uiIDA[1]; // uiIDA[0] = IDS_OK; // ui.RequestMessageBox( IDS_ERROR_NETWORK_TITLE, IDS_ERROR_NETWORK, uiIDA, 1, ProfileManager.GetPrimaryPad(), NULL, NULL, app.GetStringTable()); // } // else { // Not signed in to PSN - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0] = IDS_PRO_NOTONLINE_ACCEPT; ui.RequestMessageBox( IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad(), &CGameNetworkManager::MustSignInReturned_1, (void *)pInviteInfo, app.GetStringTable(), NULL, 0, false); } @@ -1672,8 +1672,8 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; bool bContentRestricted=false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; #if defined(__PS3__) || defined(__PSVITA__) ProfileManager.GetChatAndContentRestrictions(userIndex,false,&noUGC,&bContentRestricted,NULL); #else @@ -1684,7 +1684,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * #if defined(_XBOX) || defined(__PS3__) if(joiningUsers > 1 && !RenderManager.IsHiDef() && userIndex != ProfileManager.GetPrimaryPad()) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; // 4J-PB - it's possible there is no primary pad here, when accepting an invite from the dashboard @@ -1711,7 +1711,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * #endif else if(noPrivileges) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; // 4J-PB - it's possible there is no primary pad here, when accepting an invite from the dashboard @@ -1740,7 +1740,7 @@ void CGameNetworkManager::GameInviteReceived( int userIndex, const INVITE_INFO * } else { - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_PRO_NOTONLINE_ACCEPT; uiIDA[1]=IDS_PRO_NOTONLINE_DECLINE; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, uiIDA, 2, ProfileManager.GetPrimaryPad(),&CGameNetworkManager::MustSignInReturned_1,(void *)pInviteInfo, app.GetStringTable()); @@ -1806,7 +1806,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I if(noPrivileges) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_NO_MULTIPLAYER_PRIVILEGE_TITLE, IDS_NO_MULTIPLAYER_PRIVILEGE_JOIN_TEXT, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); } @@ -1840,11 +1840,11 @@ void CGameNetworkManager::HandleInviteWhenInMenus( int userIndex, const INVITE_I { // the FromInvite will make the lib decide how many panes to display based on connected pads/signed in players #ifdef _XBOX - ProfileManager.RequestSignInUI(true, false, false, false, false,&CGameNetworkManager::JoinFromInvite_SignInReturned, (LPVOID)pInviteInfo,userIndex); + ProfileManager.RequestSignInUI(true, false, false, false, false,&CGameNetworkManager::JoinFromInvite_SignInReturned, (void *)pInviteInfo,userIndex); #else SignInInfo info; info.Func = &CGameNetworkManager::JoinFromInvite_SignInReturned; - info.lpParam = (LPVOID)pInviteInfo; + info.lpParam = (void *)pInviteInfo; info.requireOnline = true; app.DebugPrintf("Using fullscreen layer\n"); ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_QuadrantSignin,&info,eUILayer_Alert,eUIGroup_Fullscreen); diff --git a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h index 3d4cbc3d5..7110b50ad 100644 --- a/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h +++ b/Minecraft.Client/Platform/Common/Network/GameNetworkManager.h @@ -54,8 +54,8 @@ public: void Initialise(); void Terminate(); void DoWork(); - bool _RunNetworkGame(LPVOID lpParameter); - bool StartNetworkGame(Minecraft *minecraft, LPVOID lpParameter); + bool _RunNetworkGame(void *lpParameter); + bool StartNetworkGame(Minecraft *minecraft, void *lpParameter); int CorrectErrorIDS(int IDS); // Player management @@ -98,7 +98,7 @@ public: bool SessionHasSpace(unsigned int spaceRequired = 1); std::vector *GetSessionList(int iPad, int localPlayers, bool partyOnly); bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession); - void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ); + void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ); void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ); void ForceFriendsSessionRefresh(); @@ -106,7 +106,7 @@ public: bool JoinGameFromInviteInfo( int userIndex, int userMask, const INVITE_INFO *pInviteInfo); eJoinGameResult JoinGame(FriendSessionInfo *searchResult, int localUsersMask); - static void CancelJoinGame(LPVOID lpParam); // Not part of the shared interface + static void CancelJoinGame(void *lpParam); // Not part of the shared interface bool LeaveGame(bool bMigrateHost); static int JoinFromInvite_SignInReturned(void *pParam,bool bContinue, int iPad); void UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving = NULL); diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h index 1ecf14e83..e5987b525 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerInterface.h @@ -114,7 +114,7 @@ private: public: virtual std::vector *GetSessionList(int iPad, int localPlayers, bool partyOnly) = 0; virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession) = 0; - virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ) = 0; + virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ) = 0; virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ) = 0; virtual void ForceFriendsSessionRefresh() = 0; diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp index 5e366e190..f50d09559 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.cpp @@ -134,8 +134,8 @@ bool CPlatformNetworkManagerStub::Initialise(CGameNetworkManager *pGameNetworkMa m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { @@ -534,7 +534,7 @@ bool CPlatformNetworkManagerStub::GetGameSessionInfo(int iPad, SessionID session return false; } -void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ) +void CPlatformNetworkManagerStub::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ) { m_SessionsUpdatedCallback = SessionsUpdatedCallback; m_pSearchParam = pSearchParam; } diff --git a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h index 1fb9c7e54..19a5a938c 100644 --- a/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h +++ b/Minecraft.Client/Platform/Common/Network/PlatformNetworkManagerStub.h @@ -134,8 +134,8 @@ private: int m_lastSearchPad; bool m_bSearchResultsReady; bool m_bSearchPending; - LPVOID m_pSearchParam; - void (*m_SessionsUpdatedCallback)(LPVOID pParam); + void *m_pSearchParam; + void (*m_SessionsUpdatedCallback)(void *pParam); C4JThread* m_SearchingThread; @@ -157,7 +157,7 @@ private: public: virtual std::vector *GetSessionList(int iPad, int localPlayers, bool partyOnly); virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession); - virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ); + virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ); virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ); virtual void ForceFriendsSessionRefresh(); diff --git a/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.cpp b/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.cpp index 8cec4cdcc..27ef1cf7e 100644 --- a/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.cpp +++ b/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.cpp @@ -416,8 +416,8 @@ bool CPlatformNetworkManagerSony::Initialise(CGameNetworkManager *pGameNetworkMa m_bSearchPending = false; m_bIsOfflineGame = false; - m_pSearchParam = NULL; - m_SessionsUpdatedCallback = NULL; + m_pSearchParam = nullptr; + m_SessionsUpdatedCallback = nullptr; m_searchResultsCount = 0; m_pSearchResults = NULL; @@ -1254,7 +1254,7 @@ bool CPlatformNetworkManagerSony::GetGameSessionInfo(int iPad, SessionID session #endif } -void CPlatformNetworkManagerSony::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ) +void CPlatformNetworkManagerSony::SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ) { m_SessionsUpdatedCallback = SessionsUpdatedCallback; m_pSearchParam = pSearchParam; } diff --git a/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.h b/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.h index e39a86621..a244c3190 100644 --- a/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.h +++ b/Minecraft.Client/Platform/Common/Network/Sony/PlatformNetworkManagerSony.h @@ -149,8 +149,8 @@ private: int m_lastSearchPad; bool m_bSearchPending; - LPVOID m_pSearchParam; - void (*m_SessionsUpdatedCallback)(LPVOID pParam); + void *m_pSearchParam; + void (*m_SessionsUpdatedCallback)(void *pParam); C4JThread* m_SearchingThread; @@ -168,7 +168,7 @@ private: public: virtual std::vector *GetSessionList(int iPad, int localPlayers, bool partyOnly); virtual bool GetGameSessionInfo(int iPad, SessionID sessionId,FriendSessionInfo *foundSession); - virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(LPVOID pParam), LPVOID pSearchParam ); + virtual void SetSessionsUpdatedCallback( void (*SessionsUpdatedCallback)(void *pParam), void *pSearchParam ); virtual void GetFullFriendSessionInfo( FriendSessionInfo *foundSession, void (* FriendSessionUpdatedFn)(bool success, void *pParam), void *pParam ); virtual void ForceFriendsSessionRefresh(); diff --git a/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.cpp b/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.cpp index ba34c8e5f..a1e6d3e1d 100644 --- a/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.cpp +++ b/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.cpp @@ -238,7 +238,7 @@ bool SonyRemoteStorage::setData( PSAVE_INFO info, CallbackFunc cb, LPVOID lpPara return true; } -int SonyRemoteStorage::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) +int SonyRemoteStorage::LoadSaveDataThumbnailReturned(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes) { SonyRemoteStorage *pClass= (SonyRemoteStorage *)lpParam; @@ -250,10 +250,10 @@ int SonyRemoteStorage::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThum app.DebugPrintf("Received data for a thumbnail\n"); - if(pbThumbnail && dwThumbnailBytes) + if(thumbnailData && thumbnailBytes) { - pClass->m_thumbnailData = pbThumbnail; - pClass->m_thumbnailDataSize = dwThumbnailBytes; + pClass->m_thumbnailData = thumbnailData; + pClass->m_thumbnailDataSize = thumbnailBytes; } else { diff --git a/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.h b/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.h index 6e0a4b105..087b4d484 100644 --- a/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.h +++ b/Minecraft.Client/Platform/Common/Network/Sony/SonyRemoteStorage.h @@ -3,6 +3,8 @@ #include "sceRemoteStorage/header/sceRemoteStorage.h" +#include + class SonyRemoteStorage { public: @@ -94,7 +96,7 @@ public: bool setData( PSAVE_INFO info, CallbackFunc cb, LPVOID lpParam ); - static int LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); + static int LoadSaveDataThumbnailReturned(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes); static int setDataThread(void* lpParam); SonyRemoteStorage() : m_memPoolBuffer(NULL), m_bInitialised(false),m_getInfoStatus(e_noInfoFound) {} @@ -107,7 +109,7 @@ protected: int m_dataProgress; char *m_pchServiceID; - PBYTE m_thumbnailData; + std::uint8_t *m_thumbnailData; unsigned int m_thumbnailDataSize; C4JThread* m_SetDataThread; PSAVE_INFO m_setDataSaveInfo; diff --git a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp index 9d44b000d..bd2cee98f 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/Tutorial.cpp @@ -1637,7 +1637,7 @@ bool Tutorial::setMessage(TutorialHint *hint, PopupMessageDetails *message) bool hintsOn = m_isFullTutorial || (app.GetGameSettings(m_iPad,eGameSetting_Hints) && app.GetGameSettings(m_iPad,eGameSetting_DisplayHUD)); bool messageShown = false; - DWORD time = GetTickCount(); + std::uint32_t time = GetTickCount(); if(message != NULL && (message->m_forceDisplay || hintsOn) && (!message->m_delay || ( diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.cpp b/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.cpp index 1e4233f28..dfae8b21c 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.cpp +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.cpp @@ -11,7 +11,7 @@ bool TutorialMessage::canDisplay() return !limitRepeats || (timesShown < numRepeats); } -LPCWSTR TutorialMessage::getMessageForDisplay() +const wchar_t *TutorialMessage::getMessageForDisplay() { if(!canDisplay()) return L""; @@ -20,4 +20,4 @@ LPCWSTR TutorialMessage::getMessageForDisplay() ++timesShown; return app.GetString( messageId ); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.h b/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.h index 6a0b4d460..dbc399819 100644 --- a/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.h +++ b/Minecraft.Client/Platform/Common/Tutorial/TutorialMessage.h @@ -10,11 +10,10 @@ private: bool limitRepeats; unsigned char numRepeats; unsigned char timesShown; - DWORD lastDisplayed; public: TutorialMessage(int messageId, bool limitRepeats = false, unsigned char numRepeats = TUTORIAL_MESSAGE_DEFAULT_SHOW); bool canDisplay(); - LPCWSTR getMessageForDisplay(); -}; \ No newline at end of file + const wchar_t *getMessageForDisplay(); +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIController.h b/Minecraft.Client/Platform/Common/UI/IUIController.h index b6ecc91f2..0dc12cb99 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIController.h +++ b/Minecraft.Client/Platform/Common/UI/IUIController.h @@ -27,7 +27,7 @@ public: virtual void CheckMenuDisplayed() = 0; virtual void SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ) = 0; - virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal ) = 0; + virtual void SetEnableTooltips( unsigned int iPad, bool bVal ) = 0; virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) = 0; virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, bool forceUpdate = false) = 0; virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ) = 0; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp index 503848f5c..9cecd88bc 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.cpp @@ -204,7 +204,7 @@ void IUIScene_AbstractContainerMenu::SetToolTip( EToolTipButton eButton, EToolTi void IUIScene_AbstractContainerMenu::UpdateTooltips() { // Table gives us text id for tooltip. - static const DWORD kaToolTipextIds[ eNumToolTips ] = + static const int kaToolTipextIds[ eNumToolTips ] = { IDS_TOOLTIPS_PICKUPPLACE, //eToolTipPickupPlace_OLD IDS_TOOLTIPS_EXIT, // eToolTipExit @@ -231,18 +231,18 @@ void IUIScene_AbstractContainerMenu::UpdateTooltips() IDS_TOOLTIPS_REPAIR, // eToolTipRepair }; - BYTE focusUser = getPad(); + int focusUser = getPad(); for ( int i = 0; i < eToolTipNumButtons; ++i ) { if ( m_aeToolTipSettings[ i ] == eToolTipNone ) { - ui.ShowTooltip( focusUser, i, FALSE ); + ui.ShowTooltip( focusUser, i, false ); } else { ui.SetTooltipText( focusUser, i, kaToolTipextIds[ m_aeToolTipSettings[ i ] ] ); - ui.ShowTooltip( focusUser, i, TRUE ); + ui.ShowTooltip( focusUser, i, true ); } } } @@ -1274,9 +1274,9 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b #endif int buttonNum=0; // 0 = LeftMouse, 1 = RightMouse - BOOL quickKeyHeld=FALSE; // Represents shift key on PC + bool quickKeyHeld = false; // Represents shift key on PC - BOOL validKeyPress = FALSE; + bool validKeyPress = false; //BOOL itemEditorKeyPress = FALSE; // Ignore input from other players @@ -1297,22 +1297,22 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b #endif if(!bRepeat) { - validKeyPress = TRUE; + validKeyPress = true; // Standard left click buttonNum = 0; - quickKeyHeld = FALSE; + quickKeyHeld = false; ui.PlayUISFX(eSFX_Press); } break; case ACTION_MENU_X: if(!bRepeat) { - validKeyPress = TRUE; + validKeyPress = true; // Standard right click buttonNum = 1; - quickKeyHeld = FALSE; + quickKeyHeld = false; ui.PlayUISFX(eSFX_Press); } break; @@ -1327,11 +1327,11 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b // No quick move tooltip is shown if something is carried, so disable the action as well //if(!bIsItemCarried) { - validKeyPress = TRUE; + validKeyPress = true; // Shift and left click buttonNum = 0; - quickKeyHeld = TRUE; + quickKeyHeld = true; ui.PlayUISFX(eSFX_Press); } } @@ -1428,12 +1428,12 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b } } } - bHandled = TRUE; + bHandled = true; } break; }; - if( validKeyPress == TRUE ) + if(validKeyPress) { if(handleValidKeyPress(iPad,buttonNum,quickKeyHeld)) { @@ -1482,7 +1482,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b if( XuiIsInstanceOf( hFocusObjectParent, hClassCXuiCtrlSlotList ) ) { CXuiCtrlSlotList* slotList; - VOID *pObj; + void *pObj; XuiObjectFromHandle( hFocusObjectParent, &pObj ); slotList = (CXuiCtrlSlotList *)pObj; @@ -1517,12 +1517,12 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b return bHandled; } -bool IUIScene_AbstractContainerMenu::handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld) +bool IUIScene_AbstractContainerMenu::handleValidKeyPress(int iUserIndex, int buttonNum, bool quickKeyHeld) { return false; } -void IUIScene_AbstractContainerMenu::handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld) +void IUIScene_AbstractContainerMenu::handleOutsideClicked(int iPad, int buttonNum, bool quickKeyHeld) { // Drop items. @@ -1540,7 +1540,7 @@ void IUIScene_AbstractContainerMenu::handleAdditionalKeyPress(int iAction) // Do nothing } -void IUIScene_AbstractContainerMenu::handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld) +void IUIScene_AbstractContainerMenu::handleSlotListClicked(ESceneSection eSection, int buttonNum, bool quickKeyHeld) { int currentIndex = getCurrentIndex(eSection); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h index 33c49f689..43e8dbe9a 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AbstractContainerMenu.h @@ -181,17 +181,17 @@ protected: // 4J - WESTY - Added for pointer prototype. void SetPointerOutsideMenu( bool bOutside ) { m_bPointerOutsideMenu = bOutside; } - void Initialize(int m_iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack=FALSE); + void Initialize(int m_iPad, AbstractContainerMenu* menu, bool autoDeleteMenu, int startIndex,ESceneSection firstSection,ESceneSection maxSection, bool bNavigateBack=false); virtual void PlatformInitialize(int iPad, int startIndex) = 0; virtual void InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex = 0) = 0; void onMouseTick(); bool handleKeyDown(int iPad, int iAction, bool bRepeat); - virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld); - virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld); + virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, bool quickKeyHeld); + virtual void handleOutsideClicked(int iPad, int buttonNum, bool quickKeyHeld); virtual void handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey); virtual void handleAdditionalKeyPress(int iAction); - virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld); + virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, bool quickKeyHeld); virtual void handleSectionClick(ESceneSection eSection) = 0; void slotClicked(int slotId, int buttonNum, bool quickKey); int getCurrentIndex(ESceneSection eSection); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp index d1170900b..45a6aa072 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_AnvilMenu.cpp @@ -212,7 +212,7 @@ void IUIScene_AnvilMenu::handleTick() } else { - LPCWSTR costString = app.GetString(IDS_REPAIR_COST); + const wchar_t *costString = app.GetString(IDS_REPAIR_COST); wchar_t temp[256]; swprintf(temp, 256, costString, m_repairMenu->cost); m_costString = temp; @@ -269,4 +269,4 @@ void IUIScene_AnvilMenu::slotChanged(AbstractContainerMenu *container, int slotI void IUIScene_AnvilMenu::setContainerData(AbstractContainerMenu *container, int id, int value) { -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp index 261882ad6..60d62372c 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.cpp @@ -28,7 +28,7 @@ Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping9GridA[IUIScene_Cra }; -LPCWSTR IUIScene_CraftingMenu::m_GroupIconNameA[m_iMaxGroup3x3]= +const wchar_t *IUIScene_CraftingMenu::m_GroupIconNameA[m_iMaxGroup3x3]= { L"Structures",//Recipy::eGroupType_Structure, L"Tools",//Recipy::eGroupType_Tool, @@ -118,7 +118,7 @@ IUIScene_CraftingMenu::IUIScene_CraftingMenu() m_iIngredientsC=0; } -LPCWSTR IUIScene_CraftingMenu::GetGroupNameText(int iGroupType) +const wchar_t *IUIScene_CraftingMenu::GetGroupNameText(int iGroupType) { switch(iGroupType) { @@ -907,7 +907,7 @@ void IUIScene_CraftingMenu::UpdateHighlight() // special case for the torch coal/charcoal int id=pTempItemInstAdditional->getDescriptionId(); - LPCWSTR itemstring; + const wchar_t *itemstring; switch(id) { diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h index c794c9e39..5d088de9a 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CraftingMenu.h @@ -54,12 +54,12 @@ protected: int iVSlotIndexA[3]; // index of the v slots currently displayed - static LPCWSTR m_GroupIconNameA[m_iMaxGroup3x3]; + static const wchar_t *m_GroupIconNameA[m_iMaxGroup3x3]; static Recipy::_eGroupType m_GroupTypeMapping4GridA[m_iMaxGroup2x2]; static Recipy::_eGroupType m_GroupTypeMapping9GridA[m_iMaxGroup3x3]; Recipy::_eGroupType *m_pGroupA; - static LPCWSTR m_GroupTabNameA[3]; + static const wchar_t *m_GroupTabNameA[3]; static _eGroupTab m_GroupTabBkgMapping2x2A[m_iMaxGroup2x2]; static _eGroupTab m_GroupTabBkgMapping3x3A[m_iMaxGroup3x3]; _eGroupTab *m_pGroupTabA; @@ -78,7 +78,7 @@ public: IUIScene_CraftingMenu(); protected: - LPCWSTR GetGroupNameText(int iGroupType); + const wchar_t *GetGroupNameText(int iGroupType); void CheckRecipesAvailable(); void UpdateHighlight(); @@ -104,16 +104,16 @@ protected: virtual void setIngredientSlotRedBox(int index, bool show) = 0; virtual void setIngredientDescriptionItem(int iPad, int index, std::shared_ptr item) = 0; virtual void setIngredientDescriptionRedBox(int index, bool show) = 0; - virtual void setIngredientDescriptionText(int index, LPCWSTR text) = 0; + virtual void setIngredientDescriptionText(int index, const wchar_t *text) = 0; virtual void setShowCraftHSlot(int iIndex, bool show) = 0; virtual void showTabHighlight(int iIndex, bool show) = 0; - virtual void setGroupText(LPCWSTR text) = 0; - virtual void setDescriptionText(LPCWSTR text) = 0; - virtual void setItemText(LPCWSTR text) = 0; + virtual void setGroupText(const wchar_t *text) = 0; + virtual void setDescriptionText(const wchar_t *text) = 0; + virtual void setItemText(const wchar_t *text) = 0; virtual void scrollDescriptionUp() = 0; virtual void scrollDescriptionDown() = 0; virtual void updateHighlightAndScrollPositions() = 0; virtual void updateVSlotPositions(int iSlots, int i) = 0; virtual void UpdateMultiPanel() = 0; -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp index de3c3d74e..302f22720 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.cpp @@ -602,7 +602,7 @@ void IUIScene_CreativeMenu::switchTab(ECreativeInventoryTabs tab) // 4J JEV - Tab Spec Struct -IUIScene_CreativeMenu::TabSpec::TabSpec(LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups) +IUIScene_CreativeMenu::TabSpec::TabSpec(const wchar_t *icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups) : m_icon(icon), m_descriptionId(descriptionId), m_staticGroupsCount(staticGroupsCount), m_dynamicGroupsCount(dynamicGroupsCount) { @@ -786,7 +786,7 @@ IUIScene_AbstractContainerMenu::ESceneSection IUIScene_CreativeMenu::GetSectionA return newSection; } -bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, BOOL quickKeyHeld) +bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, bool quickKeyHeld) { // 4J Added - Make pressing the X button clear the hotbar if(buttonNum == 1) @@ -808,7 +808,7 @@ bool IUIScene_CreativeMenu::handleValidKeyPress(int iPad, int buttonNum, BOOL qu return false; } -void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld) +void IUIScene_CreativeMenu::handleOutsideClicked(int iPad, int buttonNum, bool quickKeyHeld) { // Drop items. Minecraft *pMinecraft = Minecraft::GetInstance(); @@ -882,7 +882,7 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction) } } -void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld) +void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int buttonNum, bool quickKeyHeld) { int currentIndex = getCurrentIndex(eSection); @@ -901,7 +901,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu { playerInventory->setCarried(ItemInstance::clone(clicked)); carried = playerInventory->getCarried(); - if (quickKeyHeld == TRUE) + if(quickKeyHeld) { carried->count = carried->getMaxStackSize(); } @@ -925,7 +925,7 @@ void IUIScene_CreativeMenu::handleSlotListClicked(ESceneSection eSection, int bu setSectionSelectedSlot(eSectionInventoryCreativeUsing,m_iCurrSlotX,m_iCurrSlotY); currentIndex = getCurrentIndex(eSectionInventoryCreativeUsing); buttonNum = 0; - quickKeyHeld = FALSE; + quickKeyHeld = false; } m_menu->clicked(currentIndex, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, pMinecraft->localplayers[getPad()]); std::shared_ptr newItem = m_menu->getSlot(currentIndex)->getItem(); diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h index 4320e3a17..ac4f3d454 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_CreativeMenu.h @@ -51,7 +51,7 @@ public: static const int MAX_SIZE = rows * columns; // 4J JEV - Images - const LPCWSTR m_icon; + const wchar_t *m_icon; const int m_descriptionId; const int m_staticGroupsCount; ECreative_Inventory_Groups *m_staticGroupsA; @@ -64,7 +64,7 @@ public: unsigned int m_staticItems; public: - TabSpec( LPCWSTR icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups ); + TabSpec( const wchar_t *icon, int descriptionId, int staticGroupsCount, ECreative_Inventory_Groups *staticGroups, int dynamicGroupsCount, ECreative_Inventory_Groups *dynamicGroups ); ~TabSpec(); void populateMenu(AbstractContainerMenu *menu, int dynamicIndex, unsigned int page); @@ -108,10 +108,10 @@ protected: virtual void updateTabHighlightAndText(ECreativeInventoryTabs tab) = 0; virtual void updateScrollCurrentPage(int currentPage, int pageCount) = 0; virtual ESceneSection GetSectionAndSlotInDirection( ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY ); - virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, BOOL quickKeyHeld); - virtual void handleOutsideClicked(int iPad, int buttonNum, BOOL quickKeyHeld); + virtual bool handleValidKeyPress(int iUserIndex, int buttonNum, bool quickKeyHeld); + virtual void handleOutsideClicked(int iPad, int buttonNum, bool quickKeyHeld); virtual void handleAdditionalKeyPress(int iAction); - virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, BOOL quickKeyHeld); + virtual void handleSlotListClicked(ESceneSection eSection, int buttonNum, bool quickKeyHeld); bool getEmptyInventorySlot(std::shared_ptr item, int &slotX); int getSectionStartOffset(ESceneSection eSection); virtual bool IsSectionSlotList( ESceneSection eSection ); @@ -119,4 +119,4 @@ protected: virtual bool overrideTooltips(ESceneSection sectionUnderPointer, std::shared_ptr itemUnderPointer, bool bIsItemCarried, bool bSlotHasItem, bool bCarriedIsSameAsSlot, int iSlotStackSizeRemaining, EToolTipItem &buttonA, EToolTipItem &buttonX, EToolTipItem &buttonY, EToolTipItem &buttonRT); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp index dc3701f7f..bfb77504a 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.cpp @@ -278,9 +278,9 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 DLCPack *pDLCPack=pDLCTexPack->getDLCInfoParentPack(); - DLC_INFO *pDLCInfo=app.GetDLCInfoForProductName((WCHAR *)pDLCPack->getName().c_str()); + DLC_INFO *pDLCInfo = app.GetDLCInfoForProductName(const_cast(pDLCPack->getName().c_str())); - StorageManager.InstallOffer(1,(WCHAR *)pDLCInfo->wsProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1, const_cast(pDLCInfo->wsProductId.c_str()), NULL, NULL); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -330,7 +330,7 @@ int IUIScene_PauseMenu::WarningTrialTexturePackReturned(void *pParam,int iPad,C4 } -int IUIScene_PauseMenu::SaveWorldThreadProc( LPVOID lpParameter ) +int IUIScene_PauseMenu::SaveWorldThreadProc(void *lpParameter) { bool bAutosave=(bool)lpParameter; if(bAutosave) @@ -391,7 +391,7 @@ int IUIScene_PauseMenu::ExitWorldThreadProc( void* lpParameter ) } // This function performs the meat of exiting from a level. It should be called from a thread other than the main thread. -void IUIScene_PauseMenu::_ExitWorld(LPVOID lpParameter) +void IUIScene_PauseMenu::_ExitWorld(void *lpParameter) { Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -688,4 +688,4 @@ int IUIScene_PauseMenu::DisableAutosaveDialogReturned(void *pParam,int iPad,C4JS app.SetAction(iPad,eAppAction_SaveGame); } return 0; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.h b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.h index 7233df3a7..d12e5c140 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.h +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_PauseMenu.h @@ -17,9 +17,9 @@ public: static int SaveWorldThreadProc( void* lpParameter ); static int ExitWorldThreadProc( void* lpParameter ); - static void _ExitWorld(LPVOID lpParameter); // Call only from a thread + static void _ExitWorld(void *lpParameter); // Call only from a thread protected: virtual void ShowScene(bool show) = 0; virtual void SetIgnoreInput(bool ignoreInput) = 0; -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp index 175e96362..18eeccd99 100644 --- a/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp +++ b/Minecraft.Client/Platform/Common/UI/IUIScene_StartGame.cpp @@ -29,14 +29,14 @@ void IUIScene_StartGame::HandleDLCMountingComplete() { TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { wchar_t imageName[64]; swprintf(imageName,64,L"tpack%08x",tp->getId()); - registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); + registerSubstitutionTexture(imageName, imageData, imageBytes); m_texturePackList.addPack(i,imageName); } } @@ -58,7 +58,7 @@ void IUIScene_StartGame::HandleDLCMountingComplete() char *pchName=app.GetDLCInfoTextures(i); pDLCInfo=app.GetDLCInfo(pchName); #elif defined _XBOX_ONE - pDLCInfo=app.GetDLCInfoForFullOfferID((WCHAR *)app.GetDLCInfoTexturesFullOffer(i).c_str()); + pDLCInfo=app.GetDLCInfoForFullOfferID(const_cast(app.GetDLCInfoTexturesFullOffer(i).c_str())); #else ULONGLONG ull=app.GetDLCInfoTexturesFullOffer(i); pDLCInfo=app.GetDLCInfoForFullOfferID(ull); @@ -140,8 +140,10 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) #if TO_BE_IMPLEMENTED // this is probably a texture pack icon added from TMS - DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + unsigned int dwBytes=0; + unsigned int dwFileBytes=0; + std::uint8_t *pbData=NULL; + std::uint8_t *pbFileData=NULL; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -158,13 +160,13 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) } app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush); m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); } app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); @@ -180,12 +182,12 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) m_labelTexturePackName.setLabel(tp->getName()); m_labelTexturePackDescription.setLabel(tp->getDesc1()); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - //if(dwImageBytes > 0 && pbImageData) + //if(imageBytes > 0 && imageData) //{ - // registerSubstitutionTexture(L"texturePackIcon", pbImageData, dwImageBytes); + // registerSubstitutionTexture(L"texturePackIcon", imageData, imageBytes); // m_bitmapTexturePackIcon.setTextureName(L"texturePackIcon"); //} @@ -193,12 +195,12 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) swprintf(imageName,64,L"tpack%08x",tp->getId()); m_bitmapTexturePackIcon.setTextureName(imageName); - pbImageData = tp->getPackComparison(dwImageBytes); + imageData = tp->getPackComparison(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { swprintf(imageName,64,L"texturePackComparison%08x",tp->getId()); - registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); + registerSubstitutionTexture(imageName, imageData, imageBytes); m_bitmapComparison.setTextureName(imageName); } else @@ -360,7 +362,7 @@ int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStora app.GetDLCFullOfferIDForPackID(pClass->m_MoreOptionsParams.dwTexturePack,ProductId); - StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1, const_cast(ProductId.c_str()), NULL, NULL); // the license change coming in when the offer has been installed will cause this scene to refresh } @@ -376,4 +378,4 @@ int IUIScene_StartGame::TexturePackDialogReturned(void *pParam,int iPad,C4JStora #endif pClass->m_bIgnoreInput=false; return 0; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp index dceb0f831..3d0378346 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.cpp @@ -205,7 +205,7 @@ void UIComponent_TutorialPopup::_SetDescription(UIScene *interactScene, const st } } -std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc) +std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal, bool isFoil, const wchar_t *desc) { std::wstring temp(desc); @@ -340,7 +340,7 @@ std::wstring UIComponent_TutorialPopup::_SetImage(std::wstring &desc) { // 4J Stu - Unused #if 0 - BOOL imageShowAtStart = m_image.IsShown(); + bool imageShowAtStart = m_image.IsShown(); std::wstring openTag(L"{*IMAGE*}"); std::wstring closeTag(L"{*/IMAGE*}"); @@ -354,7 +354,7 @@ std::wstring UIComponent_TutorialPopup::_SetImage(std::wstring &desc) { std::wstring id = desc.substr(imageStartPos, imageEndPos - imageStartPos); m_image.SetImagePath( id.c_str() ); - m_image.SetShow( TRUE ); + m_image.SetShow( true ); desc.replace(imageTagStartPos, imageEndPos - imageTagStartPos + closeTag.length(), L""); } @@ -362,10 +362,10 @@ std::wstring UIComponent_TutorialPopup::_SetImage(std::wstring &desc) else { // hide the icon slot - m_image.SetShow( FALSE ); + m_image.SetShow( false ); } - BOOL imageShowAtEnd = m_image.IsShown(); + bool imageShowAtEnd = m_image.IsShown(); if(imageShowAtStart != imageShowAtEnd) { float fHeight, fWidth, fIconHeight, fDescHeight, fDescWidth; diff --git a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h index 59d038278..904efe745 100644 --- a/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h +++ b/Minecraft.Client/Platform/Common/UI/UIComponent_TutorialPopup.h @@ -92,7 +92,7 @@ protected: private: void _SetDescription(UIScene *interactScene, const std::wstring &desc, const std::wstring &title, bool allowFade, bool isReminder); - std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil, LPCWSTR desc); + std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil, const wchar_t *desc); std::wstring _SetImage(std::wstring &desc); std::wstring ParseDescription(int iPad, std::wstring &text); void UpdateInteractScenePosition(bool visible); diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp index 280250286..9d0808393 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.cpp @@ -16,7 +16,7 @@ UIControl_PlayerSkinPreview::UIControl_PlayerSkinPreview() { UIControl::setControlType(UIControl::ePlayerSkinPreview); - m_bDirty = FALSE; + m_bDirty = false; m_fScale = 1.0f; m_fAlpha = 1.0f; diff --git a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.h b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.h index 2ee0729a9..64616f18d 100644 --- a/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.h +++ b/Minecraft.Client/Platform/Common/UI/UIControl_PlayerSkinPreview.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIControl.h" #include "../../Minecraft.Client/Textures/Textures.h" @@ -23,7 +25,7 @@ private: e_SkinPreviewAnimation_Count, }; - BOOL m_bDirty; + bool m_bDirty; float m_fScale,m_fAlpha; std::wstring m_customTextureUrl; @@ -43,7 +45,7 @@ private: float m_walkAnimPos; bool m_bAutoRotate, m_bRotatingLeft; - BYTE m_rotateTick; + std::uint8_t m_rotateTick; float m_fTargetRotation, m_fOriginalRotation; int m_framesAnimatingRotation; bool m_bAnimatingToFacing; @@ -87,4 +89,4 @@ private: void render(EntityRenderer *renderer, double x, double y, double z, float rot, float a); bool bindTexture(const std::wstring& urlTexture, int backupTexture); bool bindTexture(const std::wstring& urlTexture, const std::wstring& backupTexture); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIController.cpp b/Minecraft.Client/Platform/Common/UI/UIController.cpp index e697b6369..e52429731 100644 --- a/Minecraft.Client/Platform/Common/UI/UIController.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIController.cpp @@ -50,7 +50,7 @@ CRITICAL_SECTION UIController::ms_reloadSkinCS; bool UIController::ms_bReloadSkinCSInitialised = false; -DWORD UIController::m_dwTrialTimerLimitSecs=DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; +std::uint32_t UIController::m_dwTrialTimerLimitSecs = DYNAMIC_CONFIG_DEFAULT_TRIAL_TIME; static void RADLINK WarningCallback(void *user_callback_data, Iggy *player, IggyResult code, const char *message) { @@ -235,7 +235,7 @@ void UIController::SetSysUIShowing(bool bVal) m_bSystemUIShowing=bVal; } -void UIController::SetSystemUIShowing(LPVOID lpParam,bool bVal) +void UIController::SetSystemUIShowing(void *lpParam,bool bVal) { UIController *pClass=(UIController *)lpParam; pClass->SetSysUIShowing(bVal); @@ -633,9 +633,9 @@ void UIController::CleanUpSkinReload() if(!Minecraft::GetInstance()->skins->getSelected()->hasAudio()) { #ifdef _DURANGO - DWORD result = StorageManager.UnmountInstalledDLC(L"TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC(L"TPACK"); #else - DWORD result = StorageManager.UnmountInstalledDLC("TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); #endif } } @@ -898,7 +898,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) else if (down) { // Check is enough time has elapsed to be a repeat key - DWORD currentTime = GetTickCount(); + std::uint32_t currentTime = GetTickCount(); if(m_actionRepeatTimer[iPad][key] > 0 && currentTime > m_actionRepeatTimer[iPad][key]) { repeat = true; @@ -935,7 +935,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key) else if (down) { // Check is enough time has elapsed to be a repeat key - DWORD currentTime = GetTickCount(); + std::uint32_t currentTime = GetTickCount(); if(m_actionRepeatTimer[iPad][key] > 0 && currentTime > m_actionRepeatTimer[iPad][key]) { repeat = true; @@ -1383,7 +1383,7 @@ void RADLINK UIController::TextureSubstitutionDestroyCallback ( void * user_call t->releaseTexture( id ); } -void UIController::registerSubstitutionTexture(const std::wstring &textureName, PBYTE pbData, DWORD dwLength) +void UIController::registerSubstitutionTexture(const std::wstring &textureName, std::uint8_t *pbData, unsigned int dwLength) { // Remove it if it already exists unregisterSubstitutionTexture(textureName,false); @@ -1568,9 +1568,9 @@ void UIController::NavigateToHomeMenu() // pDLCTexPack->m_pSoundBank->Destroy(); // } #ifdef _XBOX_ONE - DWORD result = StorageManager.UnmountInstalledDLC(L"TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC(L"TPACK"); #else - DWORD result = StorageManager.UnmountInstalledDLC("TPACK"); + const unsigned int result = StorageManager.UnmountInstalledDLC("TPACK"); #endif app.DebugPrintf("Unmount result is %d\n",result); @@ -1883,7 +1883,7 @@ void UIController::SetTooltipText( unsigned int iPad, unsigned int tooltip, int if(m_groups[(int)group]->getTooltips()) m_groups[(int)group]->getTooltips()->SetTooltipText(tooltip, iTextID); } -void UIController::SetEnableTooltips( unsigned int iPad, BOOL bVal ) +void UIController::SetEnableTooltips( unsigned int iPad, bool bVal ) { EUIGroup group; if( app.GetGameStarted() ) @@ -2199,7 +2199,7 @@ void UIController::UpdatePlayerBasePositions() { Minecraft *pMinecraft = Minecraft::GetInstance(); - for( BYTE idx = 0; idx < XUSER_MAX_COUNT; ++idx) + for(int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { if(pMinecraft->localplayers[idx] != NULL) { @@ -2254,26 +2254,26 @@ void UIController::SetTrialTimerLimitSecs(unsigned int uiSeconds) void UIController::UpdateTrialTimer(unsigned int iPad) { - WCHAR wcTime[20]; + wchar_t wcTime[20]; - DWORD dwTimeTicks=(DWORD)app.getTrialTimer(); + std::uint32_t timeTicks = (std::uint32_t)app.getTrialTimer(); - if(dwTimeTicks>m_dwTrialTimerLimitSecs) + if(timeTicks > m_dwTrialTimerLimitSecs) { - dwTimeTicks=m_dwTrialTimerLimitSecs; + timeTicks = m_dwTrialTimerLimitSecs; } - dwTimeTicks=m_dwTrialTimerLimitSecs-dwTimeTicks; + timeTicks = m_dwTrialTimerLimitSecs - timeTicks; #ifndef _CONTENT_PACKAGE if(true) #else // display the time - only if there's less than 3 minutes - if(dwTimeTicks<180) + if(timeTicks < 180) #endif { - int iMins=dwTimeTicks/60; - int iSeconds=dwTimeTicks%60; + int iMins = timeTicks / 60; + int iSeconds = timeTicks % 60; swprintf( wcTime, 20, L"%d:%02d",iMins,iSeconds); if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcTime); } @@ -2283,7 +2283,7 @@ void UIController::UpdateTrialTimer(unsigned int iPad) } // are we out of time? - if((dwTimeTicks==0)) + if(timeTicks == 0) { // Trial over // bring up the pause menu to stop the trial over message box being called again? @@ -2298,14 +2298,14 @@ void UIController::UpdateTrialTimer(unsigned int iPad) void UIController::ReduceTrialTimerValue() { - DWORD dwTimeTicks=(int)app.getTrialTimer(); + std::uint32_t timeTicks = (std::uint32_t)app.getTrialTimer(); - if(dwTimeTicks>m_dwTrialTimerLimitSecs) + if(timeTicks > m_dwTrialTimerLimitSecs) { - dwTimeTicks=m_dwTrialTimerLimitSecs; + timeTicks = m_dwTrialTimerLimitSecs; } - m_dwTrialTimerLimitSecs-=dwTimeTicks; + m_dwTrialTimerLimitSecs -= timeTicks; } void UIController::ShowAutosaveCountdownTimer(bool show) @@ -2316,7 +2316,7 @@ void UIController::ShowAutosaveCountdownTimer(bool show) void UIController::UpdateAutosaveCountdownTimer(unsigned int uiSeconds) { #if !(defined(_XBOX_ONE) || defined(__ORBIS__)) - WCHAR wcAutosaveCountdown[100]; + wchar_t wcAutosaveCountdown[100]; swprintf( wcAutosaveCountdown, 100, app.GetString(IDS_AUTOSAVE_COUNTDOWN),uiSeconds); if(m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()) m_groups[(int)eUIGroup_Fullscreen]->getPressStartToPlay()->setTrialTimer(wcAutosaveCountdown); #endif @@ -2414,11 +2414,11 @@ void UIController::ClearPressStart() // 4J Stu - For the different StringTable classes. Should really fix the libraries. #ifndef __PS3__ -C4JStorage::EMessageResult UIController::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, bool bIsError) +C4JStorage::EMessageResult UIController::RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad, + int( *Func)(void *,int,const C4JStorage::EMessageResult), void *lpParam, C4JStringTable *pStringTable, wchar_t *pwchFormatString, unsigned int dwFocusButton, bool bIsError) #else -C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, StringTable *pStringTable, WCHAR *pwchFormatString,DWORD dwFocusButton, bool bIsError) +C4JStorage::EMessageResult UIController::RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad, + int( *Func)(void *,int,const C4JStorage::EMessageResult), void *lpParam, StringTable *pStringTable, wchar_t *pwchFormatString, unsigned int dwFocusButton, bool bIsError) #endif { MessageBoxInfo param; @@ -2440,8 +2440,8 @@ C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT ui // Queue this message box QueuedMessageBoxData *queuedData = new QueuedMessageBoxData(); queuedData->info = param; - queuedData->info.uiOptionA = new UINT[param.uiOptionC]; - memcpy(queuedData->info.uiOptionA, param.uiOptionA, param.uiOptionC * sizeof(UINT)); + queuedData->info.uiOptionA = new unsigned int[param.uiOptionC]; + memcpy(queuedData->info.uiOptionA, param.uiOptionA, param.uiOptionC * sizeof(unsigned int)); queuedData->iPad = dwPad; queuedData->layer = eUILayer_Error; // Ensures that these don't get wiped out by a CloseAllScenes call m_queuedMessageBoxData.push_back(queuedData); @@ -2462,7 +2462,7 @@ C4JStorage::EMessageResult UIController::RequestMessageBox(UINT uiTitle, UINT ui } } -C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult UIController::RequestUGCMessageBox(int title/* = -1 */, int message/* = -1 */, int iPad/* = -1*/, int( *Func)(void *,int,const C4JStorage::EMessageResult)/* = NULL*/, void *lpParam/* = NULL*/) { // Default title / messages if (title == -1) @@ -2484,17 +2484,17 @@ C4JStorage::EMessageResult UIController::RequestUGCMessageBox(UINT title/* = -1 return C4JStorage::EMessage_ResultAccept; #elif defined(__PSVITA__) ProfileManager.ShowSystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, iPad ); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; return ui.RequestMessageBox( title, IDS_CHAT_RESTRICTION_UGC, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), NULL, 0, false); #else - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; return ui.RequestMessageBox( title, message, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), NULL, 0, false); #endif } -C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(int title/* = -1 */, int message/* = -1 */, int iPad/* = -1*/, int( *Func)(void *,int,const C4JStorage::EMessageResult)/* = NULL*/, void *lpParam/* = NULL*/) { // Default title / messages if (title == -1) @@ -2522,7 +2522,7 @@ C4JStorage::EMessageResult UIController::RequestContentRestrictedMessageBox(UINT ProfileManager.ShowSystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_AGE_RESTRICTION, iPad ); return C4JStorage::EMessage_ResultAccept; #else - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; return ui.RequestMessageBox( title, message, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), NULL, 0, false); #endif diff --git a/Minecraft.Client/Platform/Common/UI/UIController.h b/Minecraft.Client/Platform/Common/UI/UIController.h index 4ba7eaefd..707e7de1a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIController.h +++ b/Minecraft.Client/Platform/Common/UI/UIController.h @@ -1,5 +1,7 @@ #pragma once //using namespace std; +#include + #include "IUIController.h" #include "UIEnums.h" #include "UIGroup.h" @@ -30,7 +32,7 @@ private: static const int UI_REPEAT_KEY_DELAY_MS = 300; // How long from press until the first repeat static const int UI_REPEAT_KEY_REPEAT_RATE_MS = 100; // How long in between repeats - DWORD m_actionRepeatTimer[XUSER_MAX_COUNT][ACTION_MAX_MENU+1]; + std::uint32_t m_actionRepeatTimer[XUSER_MAX_COUNT][ACTION_MAX_MENU+1]; float m_fScreenWidth; float m_fScreenHeight; @@ -111,7 +113,7 @@ private: C4JRender::eViewportType m_currentRenderViewport; bool m_bCustomRenderPosition; - static DWORD m_dwTrialTimerLimitSecs; + static std::uint32_t m_dwTrialTimerLimitSecs; std::unordered_map m_substitutionTextures; @@ -223,7 +225,7 @@ public: void setupRenderPosition(S32 xOrigin, S32 yOrigin); void SetSysUIShowing(bool bVal); - static void SetSystemUIShowing(LPVOID lpParam,bool bVal); + static void SetSystemUIShowing(void *lpParam,bool bVal); protected: virtual void setTileOrigin(S32 xPos, S32 yPos) = 0; @@ -256,7 +258,7 @@ protected: virtual void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) {} public: - void registerSubstitutionTexture(const std::wstring &textureName, PBYTE pbData, DWORD dwLength); + void registerSubstitutionTexture(const std::wstring &textureName, std::uint8_t *pbData, unsigned int dwLength); void unregisterSubstitutionTexture(const std::wstring &textureName, bool deleteData); public: @@ -293,7 +295,7 @@ public: // TOOLTIPS virtual void SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ); - virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal ); + virtual void SetEnableTooltips( unsigned int iPad, bool bVal ); virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ); virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, bool forceUpdate = false); virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ); @@ -343,15 +345,15 @@ public: // 4J Stu - Only because of the different StringTable type, should really fix the libraries #ifndef __PS3__ - virtual 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, bool bIsError = true); + virtual C4JStorage::EMessageResult RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad = XUSER_INDEX_ANY, + int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL, void *lpParam=NULL, C4JStringTable *pStringTable=NULL, wchar_t *pwchFormatString=NULL, unsigned int dwFocusButton=0, bool bIsError = true); #else - virtual 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, StringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0, bool bIsError = true); + virtual C4JStorage::EMessageResult RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad = XUSER_INDEX_ANY, + int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL, void *lpParam=NULL, StringTable *pStringTable=NULL, wchar_t *pwchFormatString=NULL, unsigned int dwFocusButton=0, bool bIsError = true); #endif - C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); - C4JStorage::EMessageResult RequestContentRestrictedMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); + C4JStorage::EMessageResult RequestUGCMessageBox(int title = -1, int message = -1, int iPad = -1, int( *Func)(void *,int,const C4JStorage::EMessageResult) = NULL, void *lpParam = NULL); + C4JStorage::EMessageResult RequestContentRestrictedMessageBox(int title = -1, int message = -1, int iPad = -1, int( *Func)(void *,int,const C4JStorage::EMessageResult) = NULL, void *lpParam = NULL); virtual void SetWinUserIndex(unsigned int iPad); unsigned int GetWinUserIndex(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.cpp b/Minecraft.Client/Platform/Common/UI/UIScene.cpp index 338e5eee1..e7c35404e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene.cpp @@ -1161,7 +1161,7 @@ void UIScene::externalCallback(IggyExternalFunctionCallUTF16 * call) } } -void UIScene::registerSubstitutionTexture(const std::wstring &textureName, PBYTE pbData, DWORD dwLength, bool deleteData) +void UIScene::registerSubstitutionTexture(const std::wstring &textureName, std::uint8_t *pbData, unsigned int dwLength, bool deleteData) { m_registeredTextures[textureName] = deleteData;; ui.registerSubstitutionTexture(textureName, pbData, dwLength); @@ -1245,4 +1245,4 @@ size_t UIScene::GetCallbackUniqueId() bool UIScene::isReadyToDelete() { return true; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene.h b/Minecraft.Client/Platform/Common/UI/UIScene.h index 54b2675fc..5647d5981 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene.h @@ -4,6 +4,8 @@ //using namespace std; // A scene map directly to an Iggy movie (or more accurately a collection of different sized movies) +#include + #include "UIEnums.h" #include "UIControl_Base.h" @@ -251,7 +253,7 @@ public: #ifdef _XBOX_ONE virtual void HandleDLCLicenseChange() {} #endif - void registerSubstitutionTexture(const std::wstring &textureName, PBYTE pbData, DWORD dwLength, bool deleteData = false); + void registerSubstitutionTexture(const std::wstring &textureName, std::uint8_t *pbData, unsigned int dwLength, bool deleteData = false); bool hasRegisteredSubstitutionTexture(const std::wstring &textureName); virtual void handleUnlockFullVersion() {} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp index f3000b74e..1df13f057 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.cpp @@ -52,7 +52,7 @@ UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void *_initData, UILayer *parentL } else { - LPCWSTR costString = app.GetString(IDS_REPAIR_COST); + const wchar_t *costString = app.GetString(IDS_REPAIR_COST); wchar_t temp[256]; swprintf(temp, 256, costString, m_repairMenu->cost); m_costString = temp; @@ -306,7 +306,7 @@ UIControl *UIScene_AnvilMenu::getSection(ESceneSection eSection) return control; } -int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) +int UIScene_AnvilMenu::KeyboardCompleteCallback(void *lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled UIScene_AnvilMenu *pClass=(UIScene_AnvilMenu *)lpParam; @@ -334,15 +334,15 @@ void UIScene_AnvilMenu::handleEditNamePressed() case XC_LANGUAGE_JAPANESE: case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_TCHINESE: - InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),(DWORD)m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); break; default: // 4J Stu - Use a different keyboard for non-asian languages so we don't have prediction on - InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),(DWORD)m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); + InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),(DWORD)m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_TITLE_RENAME),m_textInputAnvil.getLabel(),m_iPad,30,&UIScene_AnvilMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); #endif } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.h index 53ce46871..829264155 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_AnvilMenu.h @@ -55,7 +55,7 @@ protected: virtual UIControl *getSection(ESceneSection eSection); - static int KeyboardCompleteCallback(LPVOID lpParam,bool bRes); + static int KeyboardCompleteCallback(void *lpParam,bool bRes); virtual void handleEditNamePressed(); virtual void setEditNameValue(const std::wstring &name); virtual void setEditNameEditable(bool enabled); @@ -63,4 +63,4 @@ protected: void setCostLabel(const std::wstring &label, bool canAfford); void showCross(bool show); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp index e01b99f9b..a09011fb8 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.cpp @@ -186,7 +186,7 @@ void UIScene_ConnectingProgress::handleTimerComplete(int id) } else { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( IDS_CONNECTION_FAILED, exitReasonStringId, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable()); exitReasonStringId = -1; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.h b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.h index 19a5eedd8..4691b6434 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ConnectingProgress.h @@ -10,8 +10,8 @@ private: bool m_showTooltips; bool m_removeLocalPlayer; bool m_showingButton; - void (*m_cancelFunc)(LPVOID param); - LPVOID m_cancelFuncParam; + void (*m_cancelFunc)(void *param); + void *m_cancelFuncParam; enum EControls { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp index 6bc03ecf8..7ae0f4bff 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_ControlsMenu.cpp @@ -329,8 +329,8 @@ void UIScene_ControlsMenu::PositionText(int iPad,int iTextID, unsigned char ucAc void UIScene_ControlsMenu::PositionTextDirect(int iPad,int iTextID, int iControlDetailsIndex, bool bShow) { - LPCWSTR text = app.GetString(iTextID); + const wchar_t *text = app.GetString(iTextID); m_labelsPad[iControlDetailsIndex].setLabel(text); m_controlLines[iControlDetailsIndex].setVisible(bShow); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp index ba5673bbf..f2aa4b6d6 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.cpp @@ -666,7 +666,7 @@ void UIScene_CraftingMenu::setIngredientDescriptionRedBox(int index, bool show) m_slotListIngredients[index].showSlotRedBox(0,show); } -void UIScene_CraftingMenu::setIngredientDescriptionText(int index, LPCWSTR text) +void UIScene_CraftingMenu::setIngredientDescriptionText(int index, const wchar_t *text) { m_labelIngredientsDesc[index].setLabel(text); } @@ -690,17 +690,17 @@ void UIScene_CraftingMenu::showTabHighlight(int iIndex, bool show) } } -void UIScene_CraftingMenu::setGroupText(LPCWSTR text) +void UIScene_CraftingMenu::setGroupText(const wchar_t *text) { m_labelGroupName.setLabel(text); } -void UIScene_CraftingMenu::setDescriptionText(LPCWSTR text) +void UIScene_CraftingMenu::setDescriptionText(const wchar_t *text) { m_labelDescription.setLabel(text); } -void UIScene_CraftingMenu::setItemText(LPCWSTR text) +void UIScene_CraftingMenu::setItemText(const wchar_t *text) { m_labelItemName.setLabel(text); } diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h index 04318c582..87df8d1ce 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CraftingMenu.h @@ -190,12 +190,12 @@ protected: virtual void setIngredientSlotRedBox(int index, bool show); virtual void setIngredientDescriptionItem(int iPad, int index, std::shared_ptr item); virtual void setIngredientDescriptionRedBox(int index, bool show); - virtual void setIngredientDescriptionText(int index, LPCWSTR text); + virtual void setIngredientDescriptionText(int index, const wchar_t *text); virtual void setShowCraftHSlot(int iIndex, bool show); virtual void showTabHighlight(int iIndex, bool show); - virtual void setGroupText(LPCWSTR text); - virtual void setDescriptionText(LPCWSTR text); - virtual void setItemText(LPCWSTR text); + virtual void setGroupText(const wchar_t *text); + virtual void setDescriptionText(const wchar_t *text); + virtual void setItemText(const wchar_t *text); virtual void scrollDescriptionUp(); virtual void scrollDescriptionDown(); virtual void updateHighlightAndScrollPositions(); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp index 32c1f8065..59dd6e35c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.cpp @@ -60,19 +60,19 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay m_labelTexturePackName.init(L""); m_labelTexturePackDescription.init(L""); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); + wchar_t TempString[256]; + swprintf(TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); m_sliderDifficulty.init(TempString,eControl_Difficulty,0,3,app.GetGameSettings(m_iPad,eGameSetting_Difficulty)); - m_MoreOptionsParams.bGenerateOptions=TRUE; - m_MoreOptionsParams.bStructures=TRUE; - m_MoreOptionsParams.bFlatWorld=FALSE; - m_MoreOptionsParams.bBonusChest=FALSE; - m_MoreOptionsParams.bPVP = TRUE; - m_MoreOptionsParams.bTrust = TRUE; - m_MoreOptionsParams.bFireSpreads = TRUE; - m_MoreOptionsParams.bHostPrivileges = FALSE; - m_MoreOptionsParams.bTNT = TRUE; + m_MoreOptionsParams.bGenerateOptions = true; + m_MoreOptionsParams.bStructures = true; + m_MoreOptionsParams.bFlatWorld = false; + m_MoreOptionsParams.bBonusChest = false; + m_MoreOptionsParams.bPVP = true; + m_MoreOptionsParams.bTrust = true; + m_MoreOptionsParams.bFireSpreads = true; + m_MoreOptionsParams.bHostPrivileges = false; + m_MoreOptionsParams.bTNT = true; m_MoreOptionsParams.iPad = iPad; m_bGameModeSurvival=true; @@ -97,23 +97,23 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay // Set the text for friends of friends, and default to on if( m_bMultiplayerAllowed ) { - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; if(bGameSetting_Online) { // The profile settings say Online, but either the player is offline, or they are not allowed to play online @@ -167,14 +167,14 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay { TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { wchar_t imageName[64]; swprintf(imageName,64,L"tpack%08x",tp->getId()); - registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); + registerSubstitutionTexture(imageName, imageData, imageBytes); m_texturePackList.addPack(i,imageName); } } @@ -420,7 +420,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) case eControl_EditWorldName: { m_bIgnoreInput=true; - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),(DWORD)0,25,&UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),0,25,&UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default); } break; case eControl_EditSeed: @@ -433,15 +433,15 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) case XC_LANGUAGE_JAPANESE: case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_TCHINESE: - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); break; default: // 4J Stu - Use a different keyboard for non-asian languages so we don't have prediction on - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); #endif } break; @@ -484,7 +484,7 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) } #ifdef _DURANGO -void UIScene_CreateWorldMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) +void UIScene_CreateWorldMenu::checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad) { UIScene_CreateWorldMenu* pClass = (UIScene_CreateWorldMenu*)lpParam; @@ -628,7 +628,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() void UIScene_CreateWorldMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { @@ -636,7 +636,7 @@ void UIScene_CreateWorldMenu::handleSliderMove(F64 sliderId, F64 currentValue) m_sliderDifficulty.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); + swprintf(TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); m_sliderDifficulty.setLabel(TempString); break; } @@ -665,23 +665,23 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) if( bMultiplayerAllowed ) { bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } #if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 @@ -708,8 +708,8 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) { if(m_iConfigA[i]!=-1) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -717,8 +717,8 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); if(dwBytes > 0 && pbData) { - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + unsigned int dwImageBytes=0; + std::uint8_t *pbImageData=NULL; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -752,15 +752,15 @@ void UIScene_CreateWorldMenu::handleGainFocus(bool navBack) } } -int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) +int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(void *lpParam,bool bRes) { UIScene_CreateWorldMenu *pClass=(UIScene_CreateWorldMenu *)lpParam; pClass->m_bIgnoreInput=false; // 4J HEG - No reason to set value if keyboard was cancelled if (bRes) { - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); + std::uint16_t pchText[128]; + ZeroMemory(pchText, 128 * sizeof(std::uint16_t) ); InputManager.GetText(pchText); if(pchText[0]!=0) @@ -774,7 +774,7 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bo return 0; } -int UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,bool bRes) +int UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback(void *lpParam,bool bRes) { UIScene_CreateWorldMenu *pClass=(UIScene_CreateWorldMenu *)lpParam; pClass->m_bIgnoreInput=false; @@ -783,11 +783,11 @@ int UIScene_CreateWorldMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,bool bR { #ifdef __PSVITA__ //CD - Changed to 2048 [SCE_IME_MAX_TEXT_LENGTH] - uint16_t pchText[2048]; - ZeroMemory(pchText, 2048 * sizeof(uint16_t) ); + std::uint16_t pchText[2048]; + ZeroMemory(pchText, 2048 * sizeof(std::uint16_t) ); #else - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); + std::uint16_t pchText[128]; + ZeroMemory(pchText, 128 * sizeof(std::uint16_t) ); #endif InputManager.GetText(pchText); pClass->m_editSeed.setLabel((wchar_t *)pchText); @@ -896,7 +896,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -915,7 +915,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() } #endif - if(m_bGameModeSurvival != true || m_MoreOptionsParams.bHostPrivileges == TRUE) + if(m_bGameModeSurvival != true || m_MoreOptionsParams.bHostPrivileges) { UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; @@ -932,7 +932,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() else { // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again - DWORD connectedControllers = 0; + int connectedControllers = 0; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; @@ -941,8 +941,8 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // Check if user-created content is allowed, as we cannot play multiplayer if it's not //bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && m_MoreOptionsParams.bOnlineGame; bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; bool bContentRestricted = false; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); @@ -975,7 +975,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1023,7 +1023,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1061,7 +1061,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() } // 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not -void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD dwLocalUsersMask) +void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, int localUsersMask) { #if TO_BE_IMPLEMENTED // stop the timer running that causes a check for new texture packs in TMS but not installed, since this will run all through the create game, and will crash if it tries to create an hbrush @@ -1101,7 +1101,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD } // start the game - bool isFlat = (pClass->m_MoreOptionsParams.bFlatWorld==TRUE); + bool isFlat = pClass->m_MoreOptionsParams.bFlatWorld; __int64 seedValue = 0; NetworkGameInitData *param = new NetworkGameInitData(); @@ -1172,7 +1172,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD app.SetGameHostOption(eGameHostOption_HostCanChangeHunger,pClass->m_MoreOptionsParams.bHostPrivileges); app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges ); - g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); + g_NetworkManager.HostGame(localUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); param->settings = app.GetGameHostOption( eGameHostOption_All ); @@ -1214,7 +1214,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1243,7 +1243,7 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinu // bool isOnlineGame = pClass->m_MoreOptionsParams.bOnlineGame; int primaryPad = ProfileManager.GetPrimaryPad(); bool noPrivileges = false; - DWORD dwLocalUsersMask = 0; + int localUsersMask = 0; bool isSignedInLive = ProfileManager.IsSignedInLive(primaryPad); int iPadNotSignedInLive = -1; bool isLocalMultiplayerAvailable = app.IsLocalMultiplayerAvailable(); @@ -1259,7 +1259,7 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinu } if( !ProfileManager.AllowedToPlayMultiplayer(i) ) noPrivileges = true; - dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); + localUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); } } @@ -1300,8 +1300,8 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinu // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1326,7 +1326,7 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void *pParam,bool bContinu else { // This is NOT called from a storage manager thread, and is in fact called from the main thread in the Profile library tick. Therefore we use the main threads IntCache. - CreateGame(pClass, dwLocalUsersMask); + CreateGame(pClass, localUsersMask); } } } @@ -1347,7 +1347,7 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again - DWORD connectedControllers = 0; + int connectedControllers = 0; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; @@ -1367,8 +1367,8 @@ int UIScene_CreateWorldMenu::ConfirmCreateReturned(void *pParam,int iPad,C4JStor // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1421,14 +1421,14 @@ int UIScene_CreateWorldMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStor // int UIScene_CreateWorldMenu::PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) // { -// int32_t iResult; +// std::int32_t iResult; // UIScene_CreateWorldMenu *pClass = (UIScene_CreateWorldMenu *)pParam; // // // continue offline, or upsell PS Plus? // if(result==C4JStorage::EMessage_ResultDecline) // { // // upsell psplus -// int32_t iResult=sceNpCommerceDialogInitialize(); +// std::int32_t iResult=sceNpCommerceDialogInitialize(); // // SceNpCommerceDialogParam param; // sceNpCommerceDialogParamInitialize(¶m); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h index be1f60dd4..4058d6f1a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_CreateWorldMenu.h @@ -92,16 +92,16 @@ private: bool IsLocalMultiplayerAvailable(); #ifdef _DURANGO - static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); + static void checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad); #endif protected: - static int KeyboardCompleteWorldNameCallback(LPVOID lpParam,const bool bRes); - static int KeyboardCompleteSeedCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteWorldNameCallback(void *lpParam,const bool bRes); + static int KeyboardCompleteSeedCallback(void *lpParam,const bool bRes); void handlePress(F64 controlId, F64 childId); void handleSliderMove(F64 sliderId, F64 currentValue); - static void CreateGame(UIScene_CreateWorldMenu* pClass, DWORD dwLocalUsersMask); + static void CreateGame(UIScene_CreateWorldMenu* pClass, int localUsersMask); static int ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int StartGame_SignInReturned(void *pParam,bool bContinue, int iPad); static int MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result); @@ -112,4 +112,4 @@ protected: #endif virtual void checkStateAndStartGame(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp index 5f9d3c78e..ebbbe505a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DLCOffersMenu.cpp @@ -438,7 +438,7 @@ void UIScene_DLCOffersMenu::tick() if(hasRegisteredSubstitutionTexture(textureName)==false) { - PBYTE pbImageData; + std::uint8_t *pbImageData = NULL; int iImageDataBytes=0; bool bDeleteData; #ifdef __ORBIS__ @@ -570,7 +570,7 @@ void UIScene_DLCOffersMenu::tick() if(hasRegisteredSubstitutionTexture(textureName)==false) { - PBYTE pbImageData; + std::uint8_t *pbImageData = NULL; int iImageDataBytes=0; bool bDeleteData; #ifdef __ORBIS__ @@ -738,8 +738,7 @@ void UIScene_DLCOffersMenu::GetDLCInfo( int iOfferC, bool bUpdateOnly ) if(wcsncmp(L"Minecraft ",wstrTemp.c_str(),10)==0) { app.DebugPrintf("Removing Minecraft from name\n"); - WCHAR *pwchNewName=(WCHAR *)wstrTemp.c_str(); - wstrTemp=&pwchNewName[10]; + wstrTemp = wstrTemp.substr(10); } #ifdef _XBOX_ONE @@ -822,7 +821,7 @@ bool UIScene_DLCOffersMenu::UpdateDisplay(MARKETPLACE_CONTENTOFFER_INFO& xOffer) if (dlc != NULL) { - WCHAR *cString = dlc->wchBanner; + wchar_t *cString = dlc->wchBanner; // is the file in the local DLC images? @@ -855,8 +854,8 @@ bool UIScene_DLCOffersMenu::UpdateDisplay(MARKETPLACE_CONTENTOFFER_INFO& xOffer) { if(hasRegisteredSubstitutionTexture(cString)==false) { - BYTE *pData=NULL; - DWORD dwSize=0; + std::uint8_t *pData=NULL; + unsigned int dwSize=0; app.GetMemFileDetails(cString,&pData,&dwSize); // set the image #ifdef _XBOX_ONE @@ -920,4 +919,4 @@ void UIScene_DLCOffersMenu::HandleDLCInstalled() //} -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.cpp index 897cebb73..67436505f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.cpp @@ -113,7 +113,7 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) case eControl_EndY: case eControl_EndZ: m_keyboardCallbackControl = (eControls)((int)controlId); - InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(L"Enter something",L"",0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); break; }; } @@ -134,7 +134,7 @@ void UIScene_DebugCreateSchematic::handleCheckboxToggled(F64 controlId, bool sel } } -int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) +int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void *lpParam,bool bRes) { UIScene_DebugCreateSchematic *pClass=(UIScene_DebugCreateSchematic *)lpParam; @@ -213,4 +213,4 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool b return 0; } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.h b/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.h index 80ec8d057..763803919 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugCreateSchematic.h @@ -68,6 +68,6 @@ protected: virtual void handleCheckboxToggled(F64 controlId, bool selected); private: - static int KeyboardCompleteCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteCallback(void *lpParam,const bool bRes); }; -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp index 30ec55b4d..79731d8c5 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.cpp @@ -2,7 +2,7 @@ #include "UI.h" #include "UIScene_DebugOptions.h" -LPCWSTR UIScene_DebugOptionsMenu::m_DebugCheckboxTextA[eDebugSetting_Max+1]= +const wchar_t *UIScene_DebugOptionsMenu::m_DebugCheckboxTextA[eDebugSetting_Max+1]= { L"Load Saves From Local Folder Mode", L"Write Saves To Local Folder Mode", diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.h b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.h index 6eaa4ed02..51571fa9a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOptions.h @@ -6,7 +6,7 @@ class UIScene_DebugOptionsMenu : public UIScene { private: - static LPCWSTR m_DebugCheckboxTextA[eDebugSetting_Max+1]; + static const wchar_t *m_DebugCheckboxTextA[eDebugSetting_Max+1]; int m_iTotalCheckboxElements; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp index e9fabdfac..af475e573 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugOverlay.cpp @@ -22,12 +22,12 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa initialiseMovie(); Minecraft *pMinecraft = Minecraft::GetInstance(); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)pMinecraft->gameRenderer->GetFovVal()); + wchar_t TempString[256]; + swprintf(TempString, 256, L"Set fov (%d)", (int)pMinecraft->gameRenderer->GetFovVal()); m_sliderFov.init(TempString,eControl_FOV,0,100,(int)pMinecraft->gameRenderer->GetFovVal()); float currentTime = pMinecraft->level->getLevelData()->getTime() % 24000; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); + swprintf(TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); m_sliderTime.init(TempString,eControl_Time,0,240,currentTime/100); m_buttonRain.init(L"Toggle Rain",eControl_Rain); @@ -244,9 +244,9 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) MinecraftServer::SetTime(currentValue * 100); pMinecraft->level->getLevelData()->setTime(currentValue * 100); - WCHAR TempString[256]; + wchar_t TempString[256]; float currentTime = currentValue * 100; - swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); + swprintf(TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime); m_sliderTime.setLabel(TempString); } break; @@ -255,8 +255,8 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) Minecraft *pMinecraft = Minecraft::GetInstance(); pMinecraft->gameRenderer->SetFovVal((float)currentValue); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)currentValue); + wchar_t TempString[256]; + swprintf(TempString, 256, L"Set fov (%d)", (int)currentValue); m_sliderFov.setLabel(TempString); } break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp index 46d2460c8..e8f065dfb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.cpp @@ -29,21 +29,21 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void *initData, UILayer currentPosition->m_elev = pMinecraft->localplayers[playerNo]->xRot; } - WCHAR TempString[256]; + wchar_t TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camX); + swprintf(TempString, 256, L"%f", currentPosition->m_camX); m_textInputX.init(TempString, eControl_CamX); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camY); + swprintf(TempString, 256, L"%f", currentPosition->m_camY); m_textInputY.init(TempString, eControl_CamY); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camZ); + swprintf(TempString, 256, L"%f", currentPosition->m_camZ); m_textInputZ.init(TempString, eControl_CamZ); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_yRot); + swprintf(TempString, 256, L"%f", currentPosition->m_yRot); m_textInputYRot.init(TempString, eControl_YRot); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_elev); + swprintf(TempString, 256, L"%f", currentPosition->m_elev); m_textInputElevation.init(TempString, eControl_Elevation); m_checkboxLockPlayer.init(L"Lock Player", eControl_LockPlayer, app.GetFreezePlayers()); @@ -101,7 +101,7 @@ void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) case eControl_YRot: case eControl_Elevation: m_keyboardCallbackControl = (eControls)((int)controlId); - InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugSetCamera::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(L"Enter something",L"",0,25,&UIScene_DebugSetCamera::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); break; }; } @@ -116,7 +116,7 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) } } -int UIScene_DebugSetCamera::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) +int UIScene_DebugSetCamera::KeyboardCompleteCallback(void *lpParam,bool bRes) { UIScene_DebugSetCamera *pClass=(UIScene_DebugSetCamera *)lpParam; uint16_t pchText[2048];//[128]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.h b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.h index 926a54040..6a99cdaf8 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_DebugSetCamera.h @@ -64,6 +64,6 @@ protected: virtual void handleCheckboxToggled(F64 controlId, bool selected); private: - static int KeyboardCompleteCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteCallback(void *lpParam,const bool bRes); }; -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp index 29190223a..3f4cc5d6e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.cpp @@ -99,7 +99,7 @@ void UIScene_FullscreenProgress::updateTooltips() void UIScene_FullscreenProgress::handleDestroy() { int code = thread->GetExitCode(); - DWORD exitcode = *((DWORD *)&code); + const unsigned int exitcode = static_cast(code); // If we're active, have a cancel func, and haven't already cancelled, call cancel func if( exitcode == STILL_ACTIVE && m_cancelFunc != NULL && !m_bWasCancelled) @@ -152,10 +152,10 @@ void UIScene_FullscreenProgress::tick() int code = thread->GetExitCode(); - DWORD exitcode = *((DWORD *)&code); + const unsigned int exitcode = static_cast(code); static int s_FPTickCount = 0; - if(s_FPTickCount % 60 == 0) app.DebugPrintf("[FP] tick #%d exitcode=%u STILL_ACTIVE=%u\n", s_FPTickCount, exitcode, (DWORD)STILL_ACTIVE); + if(s_FPTickCount % 60 == 0) app.DebugPrintf("[FP] tick #%d exitcode=%u STILL_ACTIVE=%u\n", s_FPTickCount, exitcode, static_cast(STILL_ACTIVE)); s_FPTickCount++; //app.DebugPrintf("CScene_FullscreenProgress Timer %d\n",pTimer->nId); @@ -189,7 +189,7 @@ void UIScene_FullscreenProgress::tick() pMinecraft->progressRenderer->progressStartNoAbort( exitReasonStringId );*/ //app.NavigateBack(m_CompletionData->iPad); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox( g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_FAILED), g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_SERVER), uiIDA,1, XUSER_INDEX_ANY,NULL,NULL, app.GetStringTable()); @@ -375,4 +375,4 @@ bool UIScene_FullscreenProgress::isReadyToDelete() { return true; } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.h b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.h index 2ecb71ea2..f5a6553d0 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_FullscreenProgress.h @@ -18,10 +18,10 @@ private: UIFullscreenProgressCompletionData *m_CompletionData; bool m_threadCompleted; int m_iPad; - void (*m_cancelFunc)(LPVOID param); - void (*m_completeFunc)(LPVOID param); - LPVOID m_cancelFuncParam; - LPVOID m_completeFuncParam; + void (*m_cancelFunc)(void *param); + void (*m_completeFunc)(void *param); + void *m_cancelFuncParam; + void *m_completeFuncParam; bool m_bWaitForThreadToDelete; std::wstring m_titleText, m_statusText; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp index 48e860289..32df02920 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.cpp @@ -20,10 +20,10 @@ UIScene_InGameInfoMenu::UIScene_InGameInfoMenu(int iPad, void *initData, UILayer m_playerNames[i] = L""; } - DWORD playerCount = g_NetworkManager.GetPlayerCount(); + int playerCount = g_NetworkManager.GetPlayerCount(); m_playersCount = 0; - for(DWORD i = 0; i < playerCount; ++i) + for(int i = 0; i < playerCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); @@ -196,10 +196,10 @@ void UIScene_InGameInfoMenu::handleGainFocus(bool navBack) void UIScene_InGameInfoMenu::handleReload() { - DWORD playerCount = g_NetworkManager.GetPlayerCount(); + int playerCount = g_NetworkManager.GetPlayerCount(); m_playersCount = 0; - for(DWORD i = 0; i < playerCount; ++i) + for(int i = 0; i < playerCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); @@ -270,7 +270,7 @@ void UIScene_InGameInfoMenu::tick() { UIScene::tick(); - for(DWORD i = 0; i < m_playersCount; ++i) + for(int i = 0; i < m_playersCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); @@ -455,7 +455,7 @@ void UIScene_InGameInfoMenu::handlePress(F64 controlId, F64 childId) else if(selectedPlayer->IsLocal() != TRUE && selectedPlayer->IsSameSystem(g_NetworkManager.GetHostPlayer()) != TRUE) { // Only ops will hit this, can kick anyone not local and not local to the host - BYTE *smallId = new BYTE(); + std::uint8_t *smallId = new std::uint8_t(); *smallId = m_players[currentSelection]; UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; @@ -550,8 +550,8 @@ void UIScene_InGameInfoMenu::OnPlayerChanged(void *callbackParam, INetworkPlayer int UIScene_InGameInfoMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; - delete (BYTE*)pParam; + std::uint8_t smallId = *(std::uint8_t *)pParam; + delete (std::uint8_t *)pParam; if(result==C4JStorage::EMessage_ResultAccept) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h index 9bed08c6b..74ef27025 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameInfoMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class UIScene_InGameInfoMenu : public UIScene @@ -13,7 +15,7 @@ private: bool m_isHostPlayer; int m_playersCount; - BYTE m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's + std::uint8_t m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's char m_playersVoiceState[MINECRAFT_NET_MAX_PLAYERS]; short m_playersColourState[MINECRAFT_NET_MAX_PLAYERS]; std::wstring m_playerNames[MINECRAFT_NET_MAX_PLAYERS]; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp index 6559e6c53..b13dda69f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.cpp @@ -346,9 +346,9 @@ void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) { case eControl_Kick: { - BYTE *smallId = new BYTE(); + std::uint8_t *smallId = new std::uint8_t(); *smallId = m_networkSmallId; - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; uiIDA[1]=IDS_CONFIRM_CANCEL; @@ -360,8 +360,8 @@ void UIScene_InGamePlayerOptionsMenu::handlePress(F64 controlId, F64 childId) int UIScene_InGamePlayerOptionsMenu::KickPlayerReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) { - BYTE smallId = *(BYTE *)pParam; - delete (BYTE*)pParam; + std::uint8_t smallId = *(std::uint8_t *)pParam; + delete (std::uint8_t *)pParam; if(result==C4JStorage::EMessage_ResultAccept) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h index 670da1d4e..a4eeaa87c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGamePlayerOptionsMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class UIScene_InGamePlayerOptionsMenu : public UIScene @@ -27,7 +29,7 @@ private: bool m_bShouldNavBack; bool m_editingSelf; - BYTE m_networkSmallId; + std::uint8_t m_networkSmallId; unsigned int m_playerPrivileges; UIControl_Label m_labelGamertag; @@ -87,4 +89,4 @@ private: used after changing the moderator checkbox. */ void resetCheatCheckboxes(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp index 5ca70ddbf..6ffc1903c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.cpp @@ -6,7 +6,15 @@ #include #endif -int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) +namespace +{ +int InGameSaveManagementThumbnailReturnedThunk(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes) +{ + return UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(lpParam, thumbnailData, thumbnailBytes); +} +} + +int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int dwThumbnailBytes) { UIScene_InGameSaveManagementMenu *pClass= (UIScene_InGameSaveManagementMenu *)lpParam; @@ -14,7 +22,7 @@ int UIScene_InGameSaveManagementMenu::LoadSaveDataThumbnailReturned(LPVOID lpPar if(pbThumbnail && dwThumbnailBytes) { - pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = new BYTE[dwThumbnailBytes]; + pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = new std::uint8_t[dwThumbnailBytes]; memcpy(pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData, pbThumbnail, dwThumbnailBytes); pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].dwThumbnailSize = dwThumbnailBytes; } @@ -258,7 +266,7 @@ void UIScene_InGameSaveManagementMenu::tick() app.DebugPrintf("Requesting the first thumbnail\n"); // set the save to load PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadSaveDataThumbnailReturned,this); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&InGameSaveManagementThumbnailReturnedThunk,this); if(eLoadStatus!=C4JStorage::ESaveGame_GetSaveThumbnail) { @@ -276,7 +284,7 @@ void UIScene_InGameSaveManagementMenu::tick() if(!m_bExitScene) { // convert to utf16 - uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; + std::uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; #ifdef _DURANGO // Already utf16 on durango memcpy(u16Message, m_saveDetails[m_iRequestingThumbnailId].UTF16SaveFilename, MAX_SAVEFILENAME_LENGTH); @@ -296,19 +304,19 @@ void UIScene_InGameSaveManagementMenu::tick() #ifdef __PS3 size_t srcmax,dstmax; #else - uint32_t srcmax,dstmax; - uint32_t srclen,dstlen; + std::uint32_t srcmax,dstmax; + std::uint32_t srclen,dstlen; #endif srcmax=MAX_SAVEFILENAME_LENGTH; dstmax=MAX_SAVEFILENAME_LENGTH; #if defined(__PS3__) - L10nResult lres= UTF8stoUTF16s((uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,&srcmax,u16Message,&dstmax); + L10nResult lres= UTF8stoUTF16s((std::uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,&srcmax,u16Message,&dstmax); #else SceCesUcsContext context; sceCesUcsContextInit(&context); - sceCesUtf8StrToUtf16Str(&context, (uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,srcmax,&srclen,u16Message,dstmax,&dstlen); + sceCesUtf8StrToUtf16Str(&context, (std::uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,srcmax,&srclen,u16Message,dstmax,&dstlen); #endif #endif if( m_saveDetails[m_iRequestingThumbnailId].pbThumbnailData ) @@ -323,7 +331,7 @@ void UIScene_InGameSaveManagementMenu::tick() app.DebugPrintf("Requesting another thumbnail\n"); // set the save to load PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadSaveDataThumbnailReturned,this); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&InGameSaveManagementThumbnailReturnedThunk,this); if(eLoadStatus!=C4JStorage::ESaveGame_GetSaveThumbnail) { // something went wrong @@ -481,7 +489,7 @@ int UIScene_InGameSaveManagementMenu::DeleteSaveDialogReturned(void *pParam,int return 0; } -int UIScene_InGameSaveManagementMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) +int UIScene_InGameSaveManagementMenu::DeleteSaveDataReturned(void *lpParam,bool bRes) { UIScene_InGameSaveManagementMenu* pClass = (UIScene_InGameSaveManagementMenu*)lpParam; @@ -500,4 +508,4 @@ int UIScene_InGameSaveManagementMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bool UIScene_InGameSaveManagementMenu::hasFocus(int iPad) { return bHasFocus && (iPad == m_iPad || m_iPad == XUSER_INDEX_ANY); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.h index 904eee00c..d012e149a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_InGameSaveManagementMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class UIScene_InGameSaveManagementMenu : public UIScene @@ -96,9 +98,9 @@ protected: public: - static int LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); + static int LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int thumbnailBytes); static int DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int DeleteSaveDataReturned(LPVOID lpParam,bool bRes); + static int DeleteSaveDataReturned(void *lpParam,bool bRes); protected: void handlePress(F64 controlId, F64 childId); }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp index 0c212dae6..7b3d42c61 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.cpp @@ -329,7 +329,7 @@ void UIScene_JoinMenu::handleFocusChange(F64 controlId, F64 childId) } #ifdef _DURANGO -void UIScene_JoinMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) +void UIScene_JoinMenu::checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad) { UIScene_JoinMenu* pClass = (UIScene_JoinMenu*)lpParam; @@ -387,9 +387,9 @@ int UIScene_JoinMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int // Shared function to join the game that is the same whether we used the sign-in UI or not void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { - DWORD dwSignedInUsers = 0; bool noPrivileges = false; - DWORD dwLocalUsersMask = 0; + int signedInUsers = 0; + int localUsersMask = 0; bool isSignedInLive = true; int iPadNotSignedInLive = -1; @@ -402,6 +402,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { if(ProfileManager.IsSignedIn(index)) { + ++signedInUsers; if (isSignedInLive && !ProfileManager.IsSignedInLive(index)) { // Record the first non signed in live pad @@ -409,7 +410,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) } if( !ProfileManager.AllowedToPlayMultiplayer(index) ) noPrivileges = true; - dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index); + localUsersMask |= CGameNetworkManager::GetLocalPlayerMask(index); isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(index); } } @@ -418,8 +419,9 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) { if(ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) { + ++signedInUsers; if( !ProfileManager.AllowedToPlayMultiplayer(ProfileManager.GetPrimaryPad()) ) noPrivileges = true; - dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); + localUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); isSignedInLive = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()); #ifdef __PSVITA__ @@ -457,8 +459,8 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; #if defined(__PS3__) || defined(__PSVITA__) if(isSignedInLive) @@ -485,7 +487,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) pClass->m_bIgnoreInput=false; int messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; - if(dwSignedInUsers > 1) messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; + if(signedInUsers > 1) messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; ui.RequestUGCMessageBox(IDS_CONNECTION_FAILED, messageText); } @@ -507,7 +509,7 @@ void UIScene_JoinMenu::JoinGame(UIScene_JoinMenu* pClass) ProfileManager.DisplaySystemMessage( SCE_MSG_DIALOG_SYSMSG_TYPE_TRC_PSN_CHAT_RESTRICTION, ProfileManager.GetPrimaryPad() ); } #endif - CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( pClass->m_selectedSession, dwLocalUsersMask ); + CGameNetworkManager::eJoinGameResult result = g_NetworkManager.JoinGame( pClass->m_selectedSession, localUsersMask ); // Alert the app the we no longer want to be informed of ethernet connections app.SetLiveLinkRequired( false ); @@ -583,4 +585,4 @@ void UIScene_JoinMenu::handleTimerComplete(int id) } break; }; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.h index a97ee5a3e..056415e11 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_JoinMenu.h @@ -90,7 +90,7 @@ protected: void StartSharedLaunchFlow(); #ifdef _DURANGO - static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); + static void checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad); #endif static int StartGame_SignInReturned(void *pParam, bool, int); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index eb959991d..2961fccdd 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -226,7 +226,7 @@ void UIScene_LaunchMoreOptionsMenu::handleInput(int iPad, int key, bool repeat, UIControl_CheckBox *checkboxOnline = &m_checkboxes[eLaunchCheckbox_Online]; if ( pressed && controlHasFocus( checkboxOnline->getId()) && !checkboxOnline->IsEnabled() ) { - UINT uiIDA[1] = { IDS_CONFIRM_OK }; + unsigned int uiIDA[1] = { IDS_CONFIRM_OK }; ui.RequestMessageBox(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad, NULL, NULL, app.GetStringTable()); } } @@ -398,7 +398,7 @@ void UIScene_LaunchMoreOptionsMenu::handleTimerComplete(int id) };*/ } -int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(LPVOID lpParam,bool bRes) +int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void *lpParam,bool bRes) { UIScene_LaunchMoreOptionsMenu *pClass=(UIScene_LaunchMoreOptionsMenu *)lpParam; pClass->m_bIgnoreInput=false; @@ -430,15 +430,15 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) case XC_LANGUAGE_JAPANESE: case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_TCHINESE: - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); break; default: // 4J Stu - Use a different keyboard for non-asian languages so we don't have prediction on - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Alphabet_Extended); break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),(DWORD)0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD_SEED),m_editSeed.getLabel(),0,60,&UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback,this,C_4JInput::EKeyboardMode_Default); #endif } break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h index ef4fe9e93..e939d770e 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LaunchMoreOptionsMenu.h @@ -116,7 +116,7 @@ public: virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); virtual void handleFocusChange(F64 controlId, F64 childId); virtual void handleTimerComplete(int id); - static int KeyboardCompleteSeedCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteSeedCallback(void *lpParam,const bool bRes); virtual void handlePress(F64 controlId, F64 childId); virtual void handleSliderMove(F64 sliderId, F64 currentValue); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp index 8bc4ab11b..789e5f487 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.cpp @@ -702,7 +702,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor // Copy the rank leaderboardEntry->m_rank = statsRow->m_rank; - DWORD displayRank = leaderboardEntry->m_rank; + unsigned int displayRank = leaderboardEntry->m_rank; if(displayRank > 9999999) displayRank = 9999999; swprintf(leaderboardEntry->m_wcRank, 12, L"%u", displayRank); @@ -741,10 +741,10 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(LeaderboardManager::ReadScor for( unsigned int i=0 ; im_statsSize ; i++ ) { leaderboardEntry->m_columns[i] = statsRow->m_statsData[i]; - ZeroMemory(leaderboardEntry->m_wcColumns[i],12*sizeof(WCHAR)); + ZeroMemory(leaderboardEntry->m_wcColumns[i], 12 * sizeof(wchar_t)); if( !isDistanceLeaderboard ) { - DWORD displayValue = leaderboardEntry->m_columns[i]; + unsigned int displayValue = leaderboardEntry->m_columns[i]; if(displayValue > 99999) displayValue = 99999; swprintf(leaderboardEntry->m_wcColumns[i], 12, L"%u",displayValue); #ifdef _DEBUG @@ -869,7 +869,7 @@ void UIScene_LeaderboardsMenu::PopulateLeaderboard(LeaderboardManager::eStatsRet int startIndex = m_newEntryIndex; int entryCount = m_newEntriesCount; - for(DWORD i = startIndex; i < (startIndex + entryCount); ++i) + for(unsigned int i = startIndex; i < (startIndex + entryCount); ++i) { bool isLast = i == ((startIndex + entryCount) - 1); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h index 4d92cef00..b9f44b6e8 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LeaderboardsMenu.h @@ -35,12 +35,12 @@ private: struct LeaderboardEntry { PlayerUID m_xuid; unsigned int m_row; // Row identifier for passing to Iggy as a unique identifier - DWORD m_rank; - WCHAR m_wcRank[12]; - WCHAR m_gamerTag[XUSER_NAME_SIZE+1]; + unsigned int m_rank; + wchar_t m_wcRank[12]; + wchar_t m_gamerTag[XUSER_NAME_SIZE+1]; //int m_locale; unsigned int m_columns[7]; - WCHAR m_wcColumns[7][12]; + wchar_t m_wcColumns[7][12]; bool m_bPlayer; //Is the player bool m_bOnline; //Is online bool m_bFriend; //Is friend @@ -49,9 +49,9 @@ private: }; struct Leaderboard { - DWORD m_totalEntryCount; //Either total number of entries in leaderboard, or total number of results for a friends query + unsigned int m_totalEntryCount; //Either total number of entries in leaderboard, or total number of results for a friends query std::vector m_entries; - DWORD m_numColumns; + unsigned int m_numColumns; }; Leaderboard m_leaderboard; //All leaderboard data for the currently selected filter diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp index 2382f5a5c..c231e047c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.cpp @@ -23,6 +23,14 @@ #define CHECKFORAVAILABLETEXTUREPACKS_TIMER_TIME 50 #endif +namespace +{ +int LoadMenuThumbnailReturnedThunk(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes) +{ + return UIScene_LoadMenu::LoadSaveDataThumbnailReturned(lpParam, thumbnailData, thumbnailBytes); +} +} + int UIScene_LoadMenu::m_iDifficultyTitleSettingA[4]= { IDS_DIFFICULTY_TITLE_PEACEFUL, @@ -31,7 +39,7 @@ int UIScene_LoadMenu::m_iDifficultyTitleSettingA[4]= IDS_DIFFICULTY_TITLE_HARD }; -int UIScene_LoadMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) +int UIScene_LoadMenu::LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int dwThumbnailBytes) { UIScene_LoadMenu *pClass= (UIScene_LoadMenu *)lpParam; @@ -75,16 +83,16 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye m_labelTexturePackDescription.init(L""); m_CurrentDifficulty=app.GetGameSettings(m_iPad,eGameSetting_Difficulty); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); + wchar_t TempString[256]; + swprintf(TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)])); m_sliderDifficulty.init(TempString,eControl_Difficulty,0,3,app.GetGameSettings(m_iPad,eGameSetting_Difficulty)); - m_MoreOptionsParams.bGenerateOptions=FALSE; - m_MoreOptionsParams.bPVP = TRUE; - m_MoreOptionsParams.bTrust = TRUE; - m_MoreOptionsParams.bFireSpreads = TRUE; - m_MoreOptionsParams.bHostPrivileges = FALSE; - m_MoreOptionsParams.bTNT = TRUE; + m_MoreOptionsParams.bGenerateOptions = false; + m_MoreOptionsParams.bPVP = true; + m_MoreOptionsParams.bTrust = true; + m_MoreOptionsParams.bFireSpreads = true; + m_MoreOptionsParams.bHostPrivileges = false; + m_MoreOptionsParams.bTNT = true; m_MoreOptionsParams.iPad = iPad; m_iSaveGameInfoIndex=params->iSaveGameInfoIndex; @@ -112,23 +120,23 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye // Set the text for friends of friends, and default to on if( m_bMultiplayerAllowed) { - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; if(bGameSetting_Online) { // The profile settings say Online, but either the player is offline, or they are not allowed to play online @@ -173,14 +181,14 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye // retrieve the save icon from the texture pack, if there is one TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { wchar_t textureName[64]; swprintf(textureName,64,L"loadsave"); - registerSubstitutionTexture(textureName,pbImageData,dwImageBytes); + registerSubstitutionTexture(textureName,imageData,imageBytes); m_bitmapIcon.setTextureName( textureName ); } } @@ -193,12 +201,12 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye #if defined(__PS3__) || defined(__ORBIS__)|| defined(_DURANGO) || defined (__PSVITA__) // convert to utf16 - uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; + std::uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; size_t srclen,dstlen; srclen=MAX_SAVEFILENAME_LENGTH; dstlen=MAX_SAVEFILENAME_LENGTH; #ifdef __PS3__ - L10nResult lres= UTF8stoUTF16s((uint8_t *)params->saveDetails->UTF8SaveFilename,&srclen,u16Message,&dstlen); + L10nResult lres= UTF8stoUTF16s((std::uint8_t *)params->saveDetails->UTF8SaveFilename,&srclen,u16Message,&dstlen); #elif defined(_DURANGO) // Already utf16 on durango memcpy(u16Message,params->saveDetails->UTF16SaveFilename, MAX_SAVEFILENAME_LENGTH); @@ -206,8 +214,8 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye { SceCesUcsContext Context; sceCesUcsContextInit( &Context ); - uint32_t utf8Len, utf16Len; - sceCesUtf8StrToUtf16Str(&Context, (uint8_t *)params->saveDetails->UTF8SaveFilename, srclen, &utf8Len, u16Message, dstlen, &utf16Len); + std::uint32_t utf8Len, utf16Len; + sceCesUtf8StrToUtf16Str(&Context, (std::uint8_t *)params->saveDetails->UTF8SaveFilename, srclen, &utf8Len, u16Message, dstlen, &utf16Len); } #endif m_thumbnailName = (wchar_t *)u16Message; @@ -225,9 +233,9 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye #ifdef _DURANGO // On Durango, we have an extra flag possible with LoadSaveDataThumbnail, which if true will force the loading of this thumbnail even if the save data isn't sync'd from // the cloud at this stage. This could mean that there could be a pretty large delay before the callback happens, in this case. - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataThumbnailReturned,this,true); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadMenuThumbnailReturnedThunk,this,true); #else - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadSaveDataThumbnailReturned,this); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iSaveGameInfoIndex],&LoadMenuThumbnailReturnedThunk,this); #endif m_bShowTimer = true; } @@ -259,14 +267,14 @@ UIScene_LoadMenu::UIScene_LoadMenu(int iPad, void *initData, UILayer *parentLaye { TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { wchar_t imageName[64]; swprintf(imageName,64,L"tpack%08x",tp->getId()); - registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); + registerSubstitutionTexture(imageName, imageData, imageBytes); m_texturePackList.addPack(i,imageName); } } @@ -439,8 +447,8 @@ void UIScene_LoadMenu::tick() if(szSeed[0]!=0) { - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %hs", app.GetString( IDS_SEED ),szSeed); + wchar_t TempString[256]; + swprintf(TempString, 256, L"%ls: %hs", app.GetString( IDS_SEED ),szSeed); m_labelSeed.setLabel(TempString); } else @@ -451,12 +459,12 @@ void UIScene_LoadMenu::tick() // Setup all the text and checkboxes to match what the game was saved with on if(bHostOptionsRead) { - m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions,eGameHostOption_PvP)>0?TRUE:FALSE; - m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions,eGameHostOption_TrustPlayers)>0?TRUE:FALSE; - m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions,eGameHostOption_FireSpreads)>0?TRUE:FALSE; - m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions,eGameHostOption_TNT)>0?TRUE:FALSE; - m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions,eGameHostOption_CheatsEnabled)>0?TRUE:FALSE; - m_MoreOptionsParams.bDisableSaving = app.GetGameHostOption(uiHostOptions,eGameHostOption_DisableSaving)>0?TRUE:FALSE; + m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions, eGameHostOption_PvP) > 0; + m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions, eGameHostOption_TrustPlayers) > 0; + m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions, eGameHostOption_FireSpreads) > 0; + m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions, eGameHostOption_TNT) > 0; + m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions, eGameHostOption_CheatsEnabled) > 0; + m_MoreOptionsParams.bDisableSaving = app.GetGameHostOption(uiHostOptions, eGameHostOption_DisableSaving) > 0; // turn off creative mode on the save // #ifdef _DEBUG @@ -483,7 +491,7 @@ void UIScene_LoadMenu::tick() bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); if(app.GetGameHostOption(uiHostOptions,eGameHostOption_FriendsOfFriends) && !(m_bMultiplayerAllowed && bGameSetting_Online)) { - m_MoreOptionsParams.bAllowFriendsOfFriends = TRUE; + m_MoreOptionsParams.bAllowFriendsOfFriends = true; } } @@ -680,7 +688,7 @@ void UIScene_LoadMenu::handlePress(F64 controlId, F64 childId) } #ifdef _DURANGO -void UIScene_LoadMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) +void UIScene_LoadMenu::checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad) { UIScene_LoadMenu* pClass = (UIScene_LoadMenu*)lpParam; @@ -828,7 +836,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() #endif // Check if they have the Reset Nether flag set, and confirm they want to do this - if(m_MoreOptionsParams.bResetNether==TRUE) + if(m_MoreOptionsParams.bResetNether) { UINT uiIDA[2]; uiIDA[0]=IDS_DONT_RESET_NETHER; @@ -844,7 +852,7 @@ void UIScene_LoadMenu::StartSharedLaunchFlow() void UIScene_LoadMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { @@ -852,7 +860,7 @@ void UIScene_LoadMenu::handleSliderMove(F64 sliderId, F64 currentValue) m_sliderDifficulty.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); + swprintf(TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); m_sliderDifficulty.setLabel(TempString); break; } @@ -887,23 +895,23 @@ void UIScene_LoadMenu::handleTimerComplete(int id) if( bMultiplayerAllowed ) { bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } #if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 if(getSceneResolution() == eSceneResolution_1080) @@ -936,7 +944,7 @@ void UIScene_LoadMenu::handleTimerComplete(int id) if(hasRegisteredSubstitutionTexture(textureName)==false) { - PBYTE pbImageData; + std::uint8_t *pbImageData = NULL; int iImageDataBytes=0; SonyHttp::getDataFromURL(pDLCInfo->chImageURL,(void **)&pbImageData,&iImageDataBytes); @@ -988,7 +996,7 @@ void UIScene_LoadMenu::LaunchGame(void) killTimer(CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); #endif - if( (m_bGameModeSurvival != true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges == TRUE) + if( (m_bGameModeSurvival != true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges) { UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; @@ -1205,8 +1213,8 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; bool bContentRestricted = false; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); #if defined(__PS3__) || defined(__PSVITA__) @@ -1259,7 +1267,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1290,10 +1298,10 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) } } #endif - DWORD dwLocalUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); + int localUsersMask = CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); // No guest problems so we don't need to force a sign-in of players here - StartGameFromSave(pClass, dwLocalUsersMask); + StartGameFromSave(pClass, localUsersMask); } } else @@ -1319,7 +1327,7 @@ int UIScene_LoadMenu::LoadDataComplete(void *pParam) // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1418,7 +1426,7 @@ int UIScene_LoadMenu::DeleteSaveDataReturned(void *pParam,bool bSuccess) } // 4J Stu - Shared functionality that is the same whether we needed a quadrant sign-in or not -void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocalUsersMask) +void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, int localUsersMask) { INT saveOrCheckpointId = 0; bool validSave = StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId); @@ -1461,13 +1469,13 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges ); // flag if the user wants to reset the Nether to force a Fortress with netherwart etc. - app.SetResetNether((pClass->m_MoreOptionsParams.bResetNether==TRUE)?true:false); + app.SetResetNether(pClass->m_MoreOptionsParams.bResetNether); // clear out the app's terrain features list app.ClearTerrainFeaturePosition(); app.SetGameHostOption(eGameHostOption_GameType,pClass->m_bGameModeSurvival?GameType::SURVIVAL->getId():GameType::CREATIVE->getId() ); - g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); + g_NetworkManager.HostGame(localUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); param->settings = app.GetGameHostOption( eGameHostOption_All ); @@ -1477,7 +1485,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1495,7 +1503,7 @@ void UIScene_LoadMenu::StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocal void UIScene_LoadMenu::checkStateAndStartGame() { // Check if they have the Reset Nether flag set, and confirm they want to do this - if(m_MoreOptionsParams.bResetNether==TRUE) + if(m_MoreOptionsParams.bResetNether) { UINT uiIDA[2]; uiIDA[0]=IDS_DONT_RESET_NETHER; @@ -1514,7 +1522,7 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && m_MoreOptionsParams.bOnlineGame; // 4J Stu - If we only have one controller connected, then don't show the sign-in UI again - DWORD connectedControllers = 0; + int connectedControllers = 0; for(unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) { if( InputManager.IsPadConnected(i) || ProfileManager.IsSignedIn(i) ) ++connectedControllers; @@ -1525,8 +1533,8 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1542,9 +1550,9 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) } - DWORD dwLocalUsersMask = 0; + int localUsersMask = 0; - dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); + localUsersMask |= CGameNetworkManager::GetLocalPlayerMask(ProfileManager.GetPrimaryPad()); // Load data from disc //File saveFile( L"Tutorial\\Tutorial" ); //LoadSaveFromDisk(&saveFile); @@ -1555,7 +1563,7 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) bool isPrivate = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)>0)?true:false; - g_NetworkManager.HostGame(dwLocalUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); + g_NetworkManager.HostGame(localUsersMask,isClientSide,isPrivate,MINECRAFT_NET_MAX_PLAYERS,0); NetworkGameInitData *param = new NetworkGameInitData(); param->seed = 0; @@ -1587,7 +1595,7 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,m_MoreOptionsParams.bHostPrivileges ); // flag if the user wants to reset the Nether to force a Fortress with netherwart etc. - app.SetResetNether((m_MoreOptionsParams.bResetNether==TRUE)?true:false); + app.SetResetNether(m_MoreOptionsParams.bResetNether); // clear out the app's terrain features list app.ClearTerrainFeaturePosition(); @@ -1601,7 +1609,7 @@ void UIScene_LoadMenu::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; // Reset the autosave time app.SetAutosaveTimerTime(); @@ -1627,7 +1635,7 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int { int primaryPad = ProfileManager.GetPrimaryPad(); bool noPrivileges = false; - DWORD dwLocalUsersMask = 0; + int localUsersMask = 0; bool isSignedInLive = ProfileManager.IsSignedInLive(primaryPad); bool isOnlineGame = pClass->m_MoreOptionsParams.bOnlineGame; int iPadNotSignedInLive = -1; @@ -1644,7 +1652,7 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int } if( !ProfileManager.AllowedToPlayMultiplayer(i) ) noPrivileges = true; - dwLocalUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); + localUsersMask |= CGameNetworkManager::GetLocalPlayerMask(i); isSignedInLive = isSignedInLive && ProfileManager.IsSignedInLive(i); } } @@ -1685,8 +1693,8 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1731,7 +1739,7 @@ int UIScene_LoadMenu::StartGame_SignInReturned(void *pParam,bool bContinue, int } #endif // This is NOT called from a storage manager thread, and is in fact called from the main thread in the Profile library tick. Therefore we use the main threads IntCache. - StartGameFromSave(pClass, dwLocalUsersMask); + StartGameFromSave(pClass, localUsersMask); } } } @@ -1751,7 +1759,7 @@ void UIScene_LoadMenu::handleGainFocus(bool navBack) #if defined _XBOX_ONE || defined __ORBIS__ || defined _WINDOWS64 if(getSceneResolution() == eSceneResolution_1080) { - m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame == TRUE); + m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); } #endif } @@ -1773,7 +1781,7 @@ int UIScene_LoadMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EM // int UIScene_LoadMenu::PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) // { -// int32_t iResult; +// std::int32_t iResult; // UIScene_LoadMenu *pClass = (UIScene_LoadMenu *)pParam; // // // continue offline, or upsell PS Plus? @@ -1801,4 +1809,4 @@ int UIScene_LoadMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EM // pClass->m_bIgnoreInput=false; // return 0; // } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h index 11ace0c2b..7c33bb516 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "IUIScene_StartGame.h" class UIScene_LoadMenu : public IUIScene_StartGame @@ -68,7 +70,7 @@ private: #endif //int *m_iConfigA; // track the texture packs that we don't have installed - PBYTE m_pbThumbnailData; + std::uint8_t *m_pbThumbnailData; unsigned int m_uiThumbnailSize; std::wstring m_thumbnailName; @@ -108,15 +110,14 @@ private: void LaunchGame(void); #ifdef _DURANGO - static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); + static void checkPrivilegeCallback(void *lpParam, bool hasPrivilege, int iPad); #endif static int ConfirmLoadReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static void StartGameFromSave(UIScene_LoadMenu* pClass, DWORD dwLocalUsersMask); + static void StartGameFromSave(UIScene_LoadMenu* pClass, int localUsersMask); static int LoadSaveDataReturned(void *pParam,bool bIsCorrupt, bool bIsOwner); static int TrophyDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int LoadDataComplete(void *pParam); - static int LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); static int CheckResetNetherReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int DeleteSaveDataReturned(void *pParam,bool bSuccess); @@ -127,5 +128,6 @@ private: #endif public: - static int StartGame_SignInReturned(LPVOID pParam, bool, int); -}; \ No newline at end of file + static int LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int thumbnailBytes); + static int StartGame_SignInReturned(void *pParam, bool, int); +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp index 034d55a4e..a5cea82fb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.cpp @@ -9,6 +9,7 @@ #include "../../Minecraft.World/IO/Files/ConsoleSaveFile.h" #include "../../Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h" #include "../../Minecraft.World/IO/Files/ConsoleSaveFileSplit.h" +#include "../../Minecraft.World/Util/PortableFileIO.h" #include "../../Minecraft.Client/Rendering/EntityRenderers/ProgressRenderer.h" #include "../../Minecraft.Client/MinecraftServer.h" #include "../../Minecraft.Client/Textures/Packs/TexturePackRepository.h" @@ -51,7 +52,15 @@ C4JStorage::SAVETRANSFER_FILE_DETAILS UIScene_LoadOrJoinMenu::m_debugTransferDet #endif #endif -int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) +namespace +{ +int LoadOrJoinThumbnailReturnedThunk(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes) +{ + return UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(lpParam, thumbnailData, thumbnailBytes); +} +} + +int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int dwThumbnailBytes) { UIScene_LoadOrJoinMenu *pClass= (UIScene_LoadOrJoinMenu *)lpParam; @@ -59,7 +68,7 @@ int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE p if(pbThumbnail && dwThumbnailBytes) { - pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = new BYTE[dwThumbnailBytes]; + pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData = new std::uint8_t[dwThumbnailBytes]; memcpy(pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].pbThumbnailData, pbThumbnail, dwThumbnailBytes); pClass->m_saveDetails[pClass->m_iRequestingThumbnailId].dwThumbnailSize = dwThumbnailBytes; } @@ -74,7 +83,7 @@ int UIScene_LoadOrJoinMenu::LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE p return 0; } -int UIScene_LoadOrJoinMenu::LoadSaveCallback(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::LoadSaveCallback(void *lpParam,bool bRes) { //UIScene_LoadOrJoinMenu *pClass= (UIScene_LoadOrJoinMenu *)lpParam; // Get the save data now @@ -639,7 +648,7 @@ void UIScene_LoadOrJoinMenu::tick() app.DebugPrintf("Requesting the first thumbnail\n"); // set the save to load PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadSaveDataThumbnailReturned,this); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadOrJoinThumbnailReturnedThunk,this); if(eLoadStatus!=C4JStorage::ESaveGame_GetSaveThumbnail) { @@ -657,7 +666,7 @@ void UIScene_LoadOrJoinMenu::tick() if(!m_bExitScene) { // convert to utf16 - uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; + std::uint16_t u16Message[MAX_SAVEFILENAME_LENGTH]; #ifdef _DURANGO // Already utf16 on durango memcpy(u16Message, m_saveDetails[m_iRequestingThumbnailId].UTF16SaveFilename, MAX_SAVEFILENAME_LENGTH); @@ -675,19 +684,19 @@ void UIScene_LoadOrJoinMenu::tick() #ifdef __PS3 size_t srcmax,dstmax; #else - uint32_t srcmax,dstmax; - uint32_t srclen,dstlen; + std::uint32_t srcmax,dstmax; + std::uint32_t srclen,dstlen; #endif srcmax=MAX_SAVEFILENAME_LENGTH; dstmax=MAX_SAVEFILENAME_LENGTH; #if defined(__PS3__) - L10nResult lres= UTF8stoUTF16s((uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,&srcmax,u16Message,&dstmax); + L10nResult lres= UTF8stoUTF16s((std::uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,&srcmax,u16Message,&dstmax); #else SceCesUcsContext context; sceCesUcsContextInit(&context); - sceCesUtf8StrToUtf16Str(&context, (uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,srcmax,&srclen,u16Message,dstmax,&dstlen); + sceCesUtf8StrToUtf16Str(&context, (std::uint8_t *)m_saveDetails[m_iRequestingThumbnailId].UTF8SaveFilename,srcmax,&srclen,u16Message,dstmax,&dstlen); #endif #endif if( m_saveDetails[m_iRequestingThumbnailId].pbThumbnailData ) @@ -702,7 +711,7 @@ void UIScene_LoadOrJoinMenu::tick() app.DebugPrintf("Requesting another thumbnail\n"); // set the save to load PSAVE_DETAILS pSaveDetails=StorageManager.ReturnSavesInfo(); - C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadSaveDataThumbnailReturned,this); + C4JStorage::ESaveGameState eLoadStatus=StorageManager.LoadSaveDataThumbnail(&pSaveDetails->SaveInfoA[(int)m_iRequestingThumbnailId],&LoadOrJoinThumbnailReturnedThunk,this); if(eLoadStatus!=C4JStorage::ESaveGame_GetSaveThumbnail) { // something went wrong @@ -927,14 +936,14 @@ void UIScene_LoadOrJoinMenu::AddDefaultButtons() // increment the count of the mash-up pack worlds in the save list m_iMashUpButtonsC++; TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(levelGen->getRequiredTexturePackId()); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { wchar_t imageName[64]; swprintf(imageName,64,L"tpack%08x",tp->getId()); - registerSubstitutionTexture(imageName, pbImageData, dwImageBytes); + registerSubstitutionTexture(imageName, imageData, imageBytes); m_buttonListSaves.setTextureName( m_buttonListSaves.getItemCount() - 1, imageName ); } } @@ -1035,7 +1044,7 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, bool pr #elif defined(_DURANGO) if(getControlFocus() == eControl_GamesList && m_buttonListGames.getItemCount() > 0) { - DWORD nIndex = m_buttonListGames.getCurrentSelection(); + const int nIndex = m_buttonListGames.getCurrentSelection(); FriendSessionInfo *pSelectedSession = m_currentSessions->at( nIndex ); PlayerUID uid = pSelectedSession->searchResult.m_playerXuids[0]; @@ -1165,15 +1174,15 @@ void UIScene_LoadOrJoinMenu::handleInput(int iPad, int key, bool repeat, bool pr } } -int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(void *lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled UIScene_LoadOrJoinMenu *pClass=(UIScene_LoadOrJoinMenu *)lpParam; pClass->m_bIgnoreInput=false; if (bRes) { - uint16_t ui16Text[128]; - ZeroMemory(ui16Text, 128 * sizeof(uint16_t) ); + std::uint16_t ui16Text[128]; + ZeroMemory(ui16Text, 128 * sizeof(std::uint16_t) ); InputManager.GetText(ui16Text); // check the name is valid @@ -1224,7 +1233,7 @@ void UIScene_LoadOrJoinMenu::handleFocusChange(F64 controlId, F64 childId) #ifdef SONY_REMOTE_STORAGE_DOWNLOAD -void UIScene_LoadOrJoinMenu::remoteStorageGetSaveCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) +void UIScene_LoadOrJoinMenu::remoteStorageGetSaveCallback(void *lpParam, SonyRemoteStorage::Status s, int error_code) { app.DebugPrintf("remoteStorageGetCallback err : 0x%08x\n", error_code); assert(error_code == 0); @@ -1453,7 +1462,7 @@ void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex) // PS Plus upsell // 4J-PB - we're not allowed to show the text Playstation Plus - have to call the upsell all the time! // upsell psplus - int32_t iResult=sceNpCommerceDialogInitialize(); + std::int32_t iResult=sceNpCommerceDialogInitialize(); SceNpCommerceDialogParam param; sceNpCommerceDialogParamInitialize(¶m); @@ -1578,7 +1587,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1590,7 +1599,7 @@ void UIScene_LoadOrJoinMenu::LoadLevelGen(LevelGenerationOptions *levelGen) ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_FullscreenProgress, loadingParams); } -void UIScene_LoadOrJoinMenu::UpdateGamesListCallback(LPVOID pParam) +void UIScene_LoadOrJoinMenu::UpdateGamesListCallback(void *pParam) { if(pParam != NULL) { @@ -1617,7 +1626,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() FriendSessionInfo *pSelectedSession = NULL; if(DoesGamesListHaveFocus() && m_buttonListGames.getItemCount() > 0) { - unsigned int nIndex = m_buttonListGames.getCurrentSelection(); + const int nIndex = m_buttonListGames.getCurrentSelection(); pSelectedSession = m_currentSessions->at( nIndex ); } @@ -1641,7 +1650,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() unsigned int xuiListSize = m_buttonListGames.getItemCount(); unsigned int filteredListSize = (unsigned int)m_currentSessions->size(); - BOOL gamesListHasFocus = DoesGamesListHaveFocus(); + const bool gamesListHasFocus = DoesGamesListHaveFocus(); if(filteredListSize > 0) { @@ -1691,30 +1700,32 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() TexturePack *tp = pMinecraft->skins->getTexturePackById(sessionInfo->data.texturePackParentId); HRESULT hr; - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = NULL; if(tp==NULL) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes); // is it in the tpd data ? - app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); - if(dwImageBytes > 0 && pbImageData) + unsigned int tpdImageBytes = 0; + app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&imageData,&tpdImageBytes ); + imageBytes = static_cast(tpdImageBytes); + if(imageBytes > 0 && imageData) { swprintf(textureName,64,L"%ls",sessionInfo->displayLabel); - registerSubstitutionTexture(textureName,pbImageData,dwImageBytes); + registerSubstitutionTexture(textureName,imageData,imageBytes); } } else { - pbImageData = tp->getPackIcon(dwImageBytes); - if(dwImageBytes > 0 && pbImageData) + imageData = tp->getPackIcon(imageBytes); + if(imageBytes > 0 && imageData) { swprintf(textureName,64,L"%ls",sessionInfo->displayLabel); - registerSubstitutionTexture(textureName,pbImageData,dwImageBytes); + registerSubstitutionTexture(textureName,imageData,imageBytes); } } } @@ -1724,13 +1735,13 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() Minecraft *pMinecraft = Minecraft::GetInstance(); TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(0); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { swprintf(textureName,64,L"%ls",sessionInfo->displayLabel); - registerSubstitutionTexture(textureName,pbImageData,dwImageBytes); + registerSubstitutionTexture(textureName,imageData,imageBytes); } } @@ -1848,7 +1859,7 @@ void UIScene_LoadOrJoinMenu::handleTimerComplete(int id) if(hasRegisteredSubstitutionTexture(textureName)==false) { - PBYTE pbImageData; + std::uint8_t *pbImageData = NULL; int iImageDataBytes=0; SonyHttp::getDataFromURL(pDLCInfo->chImageURL,(void **)&pbImageData,&iImageDataBytes); @@ -1932,7 +1943,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromDisk(File *saveFile, ESavePlatform save LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -1997,7 +2008,7 @@ void UIScene_LoadOrJoinMenu::LoadSaveFromCloud() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2027,7 +2038,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JSt } else { - StorageManager.DeleteSaveData(&pClass->m_pSaveDetails->SaveInfoA[pClass->m_iSaveListIndex - pClass->m_iDefaultButtonsC], UIScene_LoadOrJoinMenu::DeleteSaveDataReturned, (LPVOID)pClass->GetCallbackUniqueId()); + StorageManager.DeleteSaveData(&pClass->m_pSaveDetails->SaveInfoA[pClass->m_iSaveListIndex - pClass->m_iDefaultButtonsC], UIScene_LoadOrJoinMenu::DeleteSaveDataReturned, reinterpret_cast(pClass->GetCallbackUniqueId())); pClass->m_controlSavesTimer.setVisible( true ); } } @@ -2039,7 +2050,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDialogReturned(void *pParam,int iPad,C4JSt return 0; } -int UIScene_LoadOrJoinMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::DeleteSaveDataReturned(void *lpParam,bool bRes) { ui.EnterCallbackIdCriticalSection(); UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)ui.GetSceneFromCallbackId((size_t)lpParam); @@ -2060,7 +2071,7 @@ int UIScene_LoadOrJoinMenu::DeleteSaveDataReturned(LPVOID lpParam,bool bRes) } -int UIScene_LoadOrJoinMenu::RenameSaveDataReturned(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::RenameSaveDataReturned(void *lpParam,bool bRes) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam; @@ -2105,7 +2116,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(void *pParam,int iPad,C4JS pClass->m_bIgnoreInput=true; #ifdef _DURANGO // bring up a keyboard - InputManager.RequestKeyboard(app.GetString(IDS_RENAME_WORLD_TITLE), (pClass->m_saveDetails[pClass->m_iSaveListIndex-pClass->m_iDefaultButtonsC]).UTF16SaveName,(DWORD)0,25,&UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback,pClass,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_RENAME_WORLD_TITLE), (pClass->m_saveDetails[pClass->m_iSaveListIndex-pClass->m_iDefaultButtonsC]).UTF16SaveName,0,25,&UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback,pClass,C_4JInput::EKeyboardMode_Default); #else // bring up a keyboard wchar_t wSaveName[128]; @@ -2113,7 +2124,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(void *pParam,int iPad,C4JS ZeroMemory(wSaveName, 128 * sizeof(wchar_t) ); mbstowcs(wSaveName, pClass->m_saveDetails[pClass->m_iSaveListIndex - pClass->m_iDefaultButtonsC].UTF8SaveName, strlen(pClass->m_saveDetails->UTF8SaveName)+1); // plus null LPWSTR ptr = wSaveName; - InputManager.RequestKeyboard(app.GetString(IDS_RENAME_WORLD_TITLE),wSaveName,(DWORD)0,25,&UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback,pClass,C_4JInput::EKeyboardMode_Default); + InputManager.RequestKeyboard(app.GetString(IDS_RENAME_WORLD_TITLE),wSaveName,0,25,&UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback,pClass,C_4JInput::EKeyboardMode_Default); #endif } break; @@ -2202,7 +2213,7 @@ int UIScene_LoadOrJoinMenu::TexturePackDialogReturned(void *pParam,int iPad,C4JS std::wstring ProductId; app.GetDLCFullOfferIDForPackID(pClass->m_initData->selectedSession->data.texturePackParentId,ProductId); - StorageManager.InstallOffer(1,(WCHAR *)ProductId.c_str(),NULL,NULL); + StorageManager.InstallOffer(1, const_cast(ProductId.c_str()), NULL, NULL); } else { @@ -2282,7 +2293,7 @@ void UIScene_LoadOrJoinMenu::LaunchSaveTransfer() { LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc; - loadingParams->lpParam = (LPVOID)this; + loadingParams->lpParam = this; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2301,7 +2312,7 @@ void UIScene_LoadOrJoinMenu::LaunchSaveTransfer() -int UIScene_LoadOrJoinMenu::CreateDummySaveDataCallback(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::CreateDummySaveDataCallback(void *lpParam, bool bRes) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; if(bRes) @@ -2317,7 +2328,7 @@ int UIScene_LoadOrJoinMenu::CreateDummySaveDataCallback(LPVOID lpParam,bool bRes return 0; } -int UIScene_LoadOrJoinMenu::CrossSaveGetSavesInfoCallback(LPVOID lpParam, SAVE_DETAILS *pSaveDetails, bool bRes) +int UIScene_LoadOrJoinMenu::CrossSaveGetSavesInfoCallback(void *lpParam, SAVE_DETAILS *pSaveDetails, bool bRes) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; if(bRes) @@ -2356,7 +2367,7 @@ int UIScene_LoadOrJoinMenu::CrossSaveFinishedCallback(void *pParam,int iPad,C4JS } -int UIScene_LoadOrJoinMenu::CrossSaveDeleteOnErrorReturned(LPVOID lpParam,bool bRes) +int UIScene_LoadOrJoinMenu::CrossSaveDeleteOnErrorReturned(void *lpParam, bool bRes) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; pClass->m_eSaveTransferState = eSaveTransfer_ErrorMesssage; @@ -2375,7 +2386,7 @@ int UIScene_LoadOrJoinMenu::RemoteSaveNotFoundCallback(void *pParam,int iPad,C4J bool g_bForceVitaSaveWipe = false; -int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter ) +int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void *lpParameter) { Compression::UseDefaultThreadStorage(); UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParameter; @@ -2435,16 +2446,16 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter const char* pNameUTF8 = app.getRemoteStorage()->getSaveNameUTF8(); mbstowcs(wSaveName, pNameUTF8, strlen(pNameUTF8)+1); // plus null StorageManager.SetSaveTitle(wSaveName); - PBYTE pbThumbnailData=NULL; - DWORD dwThumbnailDataSize=0; + std::uint8_t *pbThumbnailData = NULL; + unsigned int dwThumbnailDataSize = 0; - PBYTE pbDataSaveImage=NULL; - DWORD dwDataSizeSaveImage=0; + std::uint8_t *pbDataSaveImage = NULL; + unsigned int dwDataSizeSaveImage = 0; StorageManager.GetDefaultSaveImage(&pbDataSaveImage, &dwDataSizeSaveImage); // Get the default save thumbnail (as set by SetDefaultImages) for use on saving games t StorageManager.GetDefaultSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); // Get the default save image (as set by SetDefaultImages) for use on saving games that - BYTE bTextMetadata[88]; + std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata,88); int iTextMetadataBytes = app.CreateImageTextData(bTextMetadata, app.getRemoteStorage()->getSaveSeed(), true, app.getRemoteStorage()->getSaveHostOptions(), app.getRemoteStorage()->getSaveTexturePack() ); @@ -2471,7 +2482,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter // we can't cancel here, we need the saves info so we can delete the file if(pClass->m_saveTransferDownloadCancelled) { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; swprintf(wcTemp,256, app.GetString(IDS_CANCEL)); // MGH - should change this string to "cancelling download" m_wstrStageText=wcTemp; pMinecraft->progressRenderer->progressStage( m_wstrStageText ); @@ -2486,7 +2497,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter case eSaveTransfer_GettingSavesInfo: if(pClass->m_saveTransferDownloadCancelled) { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; swprintf(wcTemp,256, app.GetString(IDS_CANCEL)); // MGH - should change this string to "cancelling download" m_wstrStageText=wcTemp; pMinecraft->progressRenderer->progressStage( m_wstrStageText ); @@ -2521,7 +2532,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter case eSaveTransfer_GettingFileData: { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; int dataProgress = app.getRemoteStorage()->getDataProgress(); pMinecraft->progressRenderer->progressStagePercentage(dataProgress); @@ -2595,16 +2606,16 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter StorageManager.ResetSaveData(); { - PBYTE pbThumbnailData=NULL; - DWORD dwThumbnailDataSize=0; + std::uint8_t *pbThumbnailData = NULL; + unsigned int dwThumbnailDataSize = 0; - PBYTE pbDataSaveImage=NULL; - DWORD dwDataSizeSaveImage=0; + std::uint8_t *pbDataSaveImage = NULL; + unsigned int dwDataSizeSaveImage = 0; StorageManager.GetDefaultSaveImage(&pbDataSaveImage, &dwDataSizeSaveImage); // Get the default save thumbnail (as set by SetDefaultImages) for use on saving games t StorageManager.GetDefaultSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); // Get the default save image (as set by SetDefaultImages) for use on saving games that - BYTE bTextMetadata[88]; + std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata,88); int iTextMetadataBytes = app.CreateImageTextData(bTextMetadata, app.getRemoteStorage()->getSaveSeed(), true, app.getRemoteStorage()->getSaveHostOptions(), app.getRemoteStorage()->getSaveTexturePack() ); @@ -2684,7 +2695,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter { if(pClass->m_saveTransferDownloadCancelled) { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; swprintf(wcTemp,256, app.GetString(IDS_CANCEL)); // MGH - should change this string to "cancelling download" m_wstrStageText=wcTemp; pMinecraft->progressRenderer->progressStage( m_wstrStageText ); @@ -2767,7 +2778,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc( LPVOID lpParameter } -void UIScene_LoadOrJoinMenu::SaveTransferReturned(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) +void UIScene_LoadOrJoinMenu::SaveTransferReturned(void *lpParam, SonyRemoteStorage::Status s, int error_code) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; @@ -2787,7 +2798,7 @@ ConsoleSaveFile* UIScene_LoadOrJoinMenu::SonyCrossSaveConvert() return NULL; } -void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(LPVOID lpParam) +void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(void *lpParam) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; pClass->m_saveTransferDownloadCancelled = true; @@ -2804,7 +2815,7 @@ void UIScene_LoadOrJoinMenu::LaunchSaveUpload() { LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc; - loadingParams->lpParam = (LPVOID)this; + loadingParams->lpParam = this; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -2831,7 +2842,7 @@ int UIScene_LoadOrJoinMenu::CrossSaveUploadFinishedCallback(void *pParam,int iPa } -int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc( LPVOID lpParameter ) +int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc(void *lpParameter) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParameter; pClass->m_saveTransferUploadCancelled = false; @@ -2865,7 +2876,7 @@ int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc( LPVOID lpParameter ) break; case eSaveUpload_UploadingFileData: { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; int dataProgress = app.getRemoteStorage()->getDataProgress(); pMinecraft->progressRenderer->progressStagePercentage(dataProgress); @@ -2920,7 +2931,7 @@ int UIScene_LoadOrJoinMenu::UploadSonyCrossSaveThreadProc( LPVOID lpParameter ) } -void UIScene_LoadOrJoinMenu::SaveUploadReturned(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code) +void UIScene_LoadOrJoinMenu::SaveUploadReturned(void *lpParam, SonyRemoteStorage::Status s, int error_code) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; @@ -2939,7 +2950,7 @@ void UIScene_LoadOrJoinMenu::SaveUploadReturned(LPVOID lpParam, SonyRemoteStorag } } -void UIScene_LoadOrJoinMenu::CancelSaveUploadCallback(LPVOID lpParam) +void UIScene_LoadOrJoinMenu::CancelSaveUploadCallback(void *lpParam) { UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu *) lpParam; pClass->m_saveTransferUploadCancelled = true; @@ -2982,7 +2993,7 @@ void UIScene_LoadOrJoinMenu::LaunchSaveTransfer() LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc; - loadingParams->lpParam = (LPVOID)stateContainer; + loadingParams->lpParam = stateContainer; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; @@ -3001,7 +3012,7 @@ void UIScene_LoadOrJoinMenu::LaunchSaveTransfer() -int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc( LPVOID lpParameter ) +int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc(void *lpParameter) { Compression::UseDefaultThreadStorage(); @@ -3174,7 +3185,7 @@ int UIScene_LoadOrJoinMenu::DownloadXbox360SaveThreadProc( LPVOID lpParameter ) if(pStateContainer->m_bSaveTransferCancelled) { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; pStateContainer->m_bSaveTransferCancelled=false; swprintf(wcTemp,app.GetString(IDS_SAVE_TRANSFER_DOWNLOAD_CANCELLED)); @@ -3226,7 +3237,7 @@ void UIScene_LoadOrJoinMenu::RequestFileSize( SaveTransferStateContainer *pClass void UIScene_LoadOrJoinMenu::RequestFileData( SaveTransferStateContainer *pClass, wchar_t *filename ) { Minecraft *pMinecraft=Minecraft::GetInstance(); - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; pMinecraft->progressRenderer->progressStagePercentage(0); @@ -3241,17 +3252,24 @@ void UIScene_LoadOrJoinMenu::RequestFileData( SaveTransferStateContainer *pClass File targetFile( std::wstring(L"FakeTMSPP\\").append(filename) ); if(targetFile.exists()) { - HANDLE hSaveFile = CreateFile( targetFile.getPath().c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS, NULL); + const std::size_t fileLength = static_cast(m_debugTransferDetails.ulFileLen); + m_debugTransferDetails.pbData = new std::uint8_t[fileLength]; - m_debugTransferDetails.pbData = new BYTE[m_debugTransferDetails.ulFileLen]; + const PortableFileIO::BinaryReadResult readResult = + PortableFileIO::ReadBinaryFile(targetFile.getPath(), m_debugTransferDetails.pbData, fileLength); - DWORD numberOfBytesRead = 0; - ReadFile( hSaveFile,m_debugTransferDetails.pbData,m_debugTransferDetails.ulFileLen,&numberOfBytesRead,NULL); - assert(numberOfBytesRead == m_debugTransferDetails.ulFileLen); + assert(readResult.status == PortableFileIO::BinaryReadStatus::ok); + assert(readResult.bytesRead == fileLength); - CloseHandle(hSaveFile); - - SaveTransferReturned(pClass,&m_debugTransferDetails); + if ((readResult.status == PortableFileIO::BinaryReadStatus::ok) && (readResult.bytesRead == fileLength)) + { + SaveTransferReturned(pClass,&m_debugTransferDetails); + } + else + { + delete[] m_debugTransferDetails.pbData; + m_debugTransferDetails.pbData = NULL; + } } } else @@ -3268,7 +3286,7 @@ void UIScene_LoadOrJoinMenu::RequestFileData( SaveTransferStateContainer *pClass } } -int UIScene_LoadOrJoinMenu::SaveTransferReturned(LPVOID lpParam,C4JStorage::SAVETRANSFER_FILE_DETAILS *pSaveTransferDetails) +int UIScene_LoadOrJoinMenu::SaveTransferReturned(void *lpParam, C4JStorage::SAVETRANSFER_FILE_DETAILS *pSaveTransferDetails) { SaveTransferStateContainer* pClass = (SaveTransferStateContainer *) lpParam; app.DebugPrintf("Save Transfer - size is %d\n",pSaveTransferDetails->ulFileLen); @@ -3289,9 +3307,9 @@ int UIScene_LoadOrJoinMenu::SaveTransferReturned(LPVOID lpParam,C4JStorage::SAVE return 0; } -int UIScene_LoadOrJoinMenu::SaveTransferUpdateProgress(LPVOID lpParam,unsigned long ulBytesReceived) +int UIScene_LoadOrJoinMenu::SaveTransferUpdateProgress(void *lpParam, unsigned long ulBytesReceived) { - WCHAR wcTemp[256]; + wchar_t wcTemp[256]; SaveTransferStateContainer* pClass = (SaveTransferStateContainer *) lpParam; Minecraft *pMinecraft=Minecraft::GetInstance(); @@ -3316,7 +3334,7 @@ int UIScene_LoadOrJoinMenu::SaveTransferUpdateProgress(LPVOID lpParam,unsigned l return 0; } -void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(LPVOID lpParam) +void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(void *lpParam) { SaveTransferStateContainer* pClass = (SaveTransferStateContainer *) lpParam; @@ -3329,7 +3347,7 @@ void UIScene_LoadOrJoinMenu::CancelSaveTransferCallback(LPVOID lpParam) //pClass->m_bSaveTransferInProgress=false; } -int UIScene_LoadOrJoinMenu::CancelSaveTransferCompleteCallback(LPVOID lpParam) +int UIScene_LoadOrJoinMenu::CancelSaveTransferCompleteCallback(void *lpParam) { SaveTransferStateContainer* pClass = (SaveTransferStateContainer *) lpParam; // change the state to idle to get the download thread to terminate @@ -3377,7 +3395,7 @@ int UIScene_LoadOrJoinMenu::CopySaveDialogReturned(void *pParam,int iPad,C4JStor { LoadingInputParams *loadingParams = new LoadingInputParams(); - void *uniqueId = (LPVOID)pClass->GetCallbackUniqueId(); + void *uniqueId = reinterpret_cast(pClass->GetCallbackUniqueId()); loadingParams->func = &UIScene_LoadOrJoinMenu::CopySaveThreadProc; loadingParams->lpParam = uniqueId; loadingParams->waitForThreadToDelete = true; @@ -3403,7 +3421,7 @@ int UIScene_LoadOrJoinMenu::CopySaveDialogReturned(void *pParam,int iPad,C4JStor return 0; } -int UIScene_LoadOrJoinMenu::CopySaveThreadProc( LPVOID lpParameter ) +int UIScene_LoadOrJoinMenu::CopySaveThreadProc(void *lpParameter) { Minecraft *pMinecraft=Minecraft::GetInstance(); pMinecraft->progressRenderer->progressStart(IDS_PROGRESS_COPYING_SAVE); @@ -3444,7 +3462,7 @@ int UIScene_LoadOrJoinMenu::CopySaveThreadProc( LPVOID lpParameter ) return 0; } -int UIScene_LoadOrJoinMenu::CopySaveDataReturned(LPVOID lpParam, bool success, C4JStorage::ESaveGameState stat) +int UIScene_LoadOrJoinMenu::CopySaveDataReturned(void *lpParam, bool success, C4JStorage::ESaveGameState stat) { ui.EnterCallbackIdCriticalSection(); UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)ui.GetSceneFromCallbackId((size_t)lpParam); @@ -3493,7 +3511,7 @@ int UIScene_LoadOrJoinMenu::CopySaveDataReturned(LPVOID lpParam, bool success, C return 0; } -bool UIScene_LoadOrJoinMenu::CopySaveDataProgress(LPVOID lpParam, int percent) +bool UIScene_LoadOrJoinMenu::CopySaveDataProgress(void *lpParam, int percent) { bool bContinue = false; ui.EnterCallbackIdCriticalSection(); @@ -3509,7 +3527,7 @@ bool UIScene_LoadOrJoinMenu::CopySaveDataProgress(LPVOID lpParam, int percent) return bContinue; } -void UIScene_LoadOrJoinMenu::CancelCopySaveCallback(LPVOID lpParam) +void UIScene_LoadOrJoinMenu::CancelCopySaveCallback(void *lpParam) { ui.EnterCallbackIdCriticalSection(); UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)ui.GetSceneFromCallbackId((size_t)lpParam); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h index 02f850978..7837308d2 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_LoadOrJoinMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class LevelGenerationOptions; @@ -124,7 +126,7 @@ public: virtual EUIScene getSceneType() { return eUIScene_LoadOrJoinMenu;} - static void UpdateGamesListCallback(LPVOID pParam); + static void UpdateGamesListCallback(void *pParam); #ifdef _XBOX_ONE void HandleDLCLicenseChange(); #endif @@ -145,14 +147,14 @@ protected: public: - static int LoadSaveDataThumbnailReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); - static int LoadSaveCallback(LPVOID lpParam,bool bRes); + static int LoadSaveDataThumbnailReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int thumbnailBytes); + static int LoadSaveCallback(void *lpParam,bool bRes); static int DeleteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int SaveOptionsDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int DeleteSaveDataReturned(LPVOID lpParam,bool bRes); - static int RenameSaveDataReturned(LPVOID lpParam,bool bRes); - static int KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes); + static int DeleteSaveDataReturned(void *lpParam,bool bRes); + static int RenameSaveDataReturned(void *lpParam,bool bRes); + static int KeyboardCompleteWorldNameCallback(void *lpParam,bool bRes); protected: void handlePress(F64 controlId, F64 childId); void LoadLevelGen(LevelGenerationOptions *levelGen); @@ -172,7 +174,7 @@ private: #if defined(__PS3__) || defined(__PSVITA__) || defined(__ORBIS__) static int MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result); static int PSN_SignInReturned(void *pParam,bool bContinue, int iPad); - static void remoteStorageGetSaveCallback(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code); + static void remoteStorageGetSaveCallback(void *lpParam, SonyRemoteStorage::Status s, int error_code); #endif #ifdef __ORBIS__ @@ -205,14 +207,14 @@ private: #endif void LaunchSaveTransfer(); - static int DownloadXbox360SaveThreadProc( LPVOID lpParameter ); + static int DownloadXbox360SaveThreadProc(void *lpParameter); static void RequestFileSize( SaveTransferStateContainer *pClass, wchar_t *filename ); static void RequestFileData( SaveTransferStateContainer *pClass, wchar_t *filename ); - static int SaveTransferReturned(LPVOID lpParam,C4JStorage::SAVETRANSFER_FILE_DETAILS *pSaveTransferDetails); - static int SaveTransferUpdateProgress(LPVOID lpParam,unsigned long ulBytesReceived); - static void CancelSaveTransferCallback(LPVOID lpParam); + static int SaveTransferReturned(void *lpParam, C4JStorage::SAVETRANSFER_FILE_DETAILS *pSaveTransferDetails); + static int SaveTransferUpdateProgress(void *lpParam, unsigned long ulBytesReceived); + static void CancelSaveTransferCallback(void *lpParam); static int NeedSyncMessageReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int CancelSaveTransferCompleteCallback(LPVOID lpParam); + static int CancelSaveTransferCompleteCallback(void *lpParam); #endif @@ -254,17 +256,17 @@ private: char m_downloadedUniqueFilename[64];//SCE_SAVE_DATA_DIRNAME_DATA_MAXSIZE]; bool m_saveTransferDownloadCancelled; void LaunchSaveTransfer(); - static int CreateDummySaveDataCallback(LPVOID lpParam,bool bRes); - static int CrossSaveGetSavesInfoCallback(LPVOID lpParam, SAVE_DETAILS *pSaveDetails,bool bRes); + static int CreateDummySaveDataCallback(void *lpParam, bool bRes); + static int CrossSaveGetSavesInfoCallback(void *lpParam, SAVE_DETAILS *pSaveDetails, bool bRes); static int LoadCrossSaveDataCallback(void *pParam,bool bIsCorrupt, bool bIsOwner); static int CrossSaveFinishedCallback(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int CrossSaveDeleteOnErrorReturned(LPVOID lpParam,bool bRes); + static int CrossSaveDeleteOnErrorReturned(void *lpParam, bool bRes); static int RemoteSaveNotFoundCallback(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int DownloadSonyCrossSaveThreadProc( LPVOID lpParameter ); - static void SaveTransferReturned(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code); + static int DownloadSonyCrossSaveThreadProc(void *lpParameter); + static void SaveTransferReturned(void *lpParam, SonyRemoteStorage::Status s, int error_code); static ConsoleSaveFile* SonyCrossSaveConvert(); - static void CancelSaveTransferCallback(LPVOID lpParam); + static void CancelSaveTransferCallback(void *lpParam); #endif #ifdef SONY_REMOTE_STORAGE_UPLOAD @@ -282,19 +284,19 @@ private: bool m_saveTransferUploadCancelled; void LaunchSaveUpload(); - static int UploadSonyCrossSaveThreadProc( LPVOID lpParameter ); - static void SaveUploadReturned(LPVOID lpParam, SonyRemoteStorage::Status s, int error_code); - static void CancelSaveUploadCallback(LPVOID lpParam); + static int UploadSonyCrossSaveThreadProc(void *lpParameter); + static void SaveUploadReturned(void *lpParam, SonyRemoteStorage::Status s, int error_code); + static void CancelSaveUploadCallback(void *lpParam); static int SaveTransferDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); static int CrossSaveUploadFinishedCallback(void *pParam,int iPad,C4JStorage::EMessageResult result); #endif #if defined _XBOX_ONE || defined __ORBIS__ static int CopySaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int CopySaveThreadProc( LPVOID lpParameter ); - static int CopySaveDataReturned( LPVOID lpParameter, bool success, C4JStorage::ESaveGameState state ); - static bool CopySaveDataProgress(LPVOID lpParam, int percent); - static void CancelCopySaveCallback(LPVOID lpParam); + static int CopySaveThreadProc(void *lpParameter); + static int CopySaveDataReturned(void *lpParameter, bool success, C4JStorage::ESaveGameState state); + static bool CopySaveDataProgress(void *lpParam, int percent); + static void CancelCopySaveCallback(void *lpParam); static int CopySaveErrorDialogFinishedCallback(void *pParam,int iPad,C4JStorage::EMessageResult result); #endif }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp index 207dc28a5..bcd7764fb 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MainMenu.cpp @@ -281,7 +281,7 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { int primaryPad = ProfileManager.GetPrimaryPad(); - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (void *,const bool, const int iPad) = NULL; switch((int)controlId) { @@ -1042,7 +1042,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_PlayGame(void * UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (void *,const bool, const int iPad) = NULL; // 4J-PB - Check if there is a patch for the game pClass->m_errorCode = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad()); @@ -1131,7 +1131,7 @@ void UIScene_MainMenu::RefreshChatAndContentRestrictionsReturned_Leaderboards(vo UIScene_MainMenu* pClass = (UIScene_MainMenu*)pParam; - int (*signInReturnedFunc) (LPVOID,const bool, const int iPad) = NULL; + int (*signInReturnedFunc) (void *,const bool, const int iPad) = NULL; // 4J-PB - Check if there is a patch for the game pClass->m_errorCode = ProfileManager.getNPAvailability(ProfileManager.GetPrimaryPad()); @@ -2019,7 +2019,7 @@ void UIScene_MainMenu::LoadTrial(void) LoadingInputParams *loadingParams = new LoadingInputParams(); loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; - loadingParams->lpParam = (LPVOID)param; + loadingParams->lpParam = param; UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); completionData->bShowBackground=TRUE; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h index 38d850d03..fd3813684 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_MessageBox.h @@ -15,8 +15,8 @@ private: eControl_COUNT }; - int( *m_Func)(LPVOID,int,const C4JStorage::EMessageResult); - LPVOID m_lpParam; + int( *m_Func)(void *,int,const C4JStorage::EMessageResult); + void *m_lpParam; int m_buttonCount; UIControl_Button m_buttonButtons[eControl_COUNT]; @@ -56,4 +56,4 @@ public: protected: void handlePress(F64 controlId, F64 childId); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp index a035d074d..476aa49db 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.cpp @@ -6,6 +6,11 @@ #include "../Network/Sony/SonyHttp.h" #endif +namespace +{ +int AvatarReturnedThunk(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes); +} + UIScene_QuadrantSignin::UIScene_QuadrantSignin(int iPad, void *_initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene @@ -198,7 +203,7 @@ int UIScene_QuadrantSignin::SignInReturned(void *pParam,bool bContinue, int iPad } #ifdef _DURANGO -void UIScene_QuadrantSignin::checkAllPrivilegesCallback(LPVOID lpParam, bool hasPrivileges, int iPad) +void UIScene_QuadrantSignin::checkAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad) { UIScene_QuadrantSignin* pClass = (UIScene_QuadrantSignin*)lpParam; @@ -226,7 +231,7 @@ void UIScene_QuadrantSignin::updateState() if(!m_iconRequested[i]) { app.DebugPrintf(app.USER_SR, "Requesting avatar for %d\n", i); - if(ProfileManager.GetProfileAvatar(i, &UIScene_QuadrantSignin::AvatarReturned, this)) + if(ProfileManager.GetProfileAvatar(i, &AvatarReturnedThunk, this)) { m_iconRequested[i] = true; m_lastRequestedAvatar = i; @@ -251,6 +256,14 @@ void UIScene_QuadrantSignin::updateState() } } +namespace +{ +int AvatarReturnedThunk(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes) +{ + return UIScene_QuadrantSignin::AvatarReturned(lpParam, thumbnailData, thumbnailBytes); +} +} + void UIScene_QuadrantSignin::setControllerState(int iPad, EControllerStatus state) { if(m_controllerStatus[iPad] != state) @@ -269,7 +282,7 @@ void UIScene_QuadrantSignin::setControllerState(int iPad, EControllerStatus stat } } -int UIScene_QuadrantSignin::AvatarReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes) +int UIScene_QuadrantSignin::AvatarReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int dwThumbnailBytes) { UIScene_QuadrantSignin *pClass = (UIScene_QuadrantSignin *)lpParam; app.DebugPrintf(app.USER_SR,"AvatarReturned callback\n"); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h index bc9bb4325..f85be56fc 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_QuadrantSignin.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class UIScene_QuadrantSignin : public UIScene @@ -99,12 +101,14 @@ public: private: static int SignInReturned(void *pParam,bool bContinue, int iPad); - static int AvatarReturned(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes); void updateState(); void setControllerState(int iPad, EControllerStatus state); #ifdef _DURANGO - static void checkAllPrivilegesCallback(LPVOID lpParam, bool hasPrivileges, int iPad); + static void checkAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad); #endif + +public: + static int AvatarReturned(void *lpParam, std::uint8_t *pbThumbnail, unsigned int thumbnailBytes); }; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp index 6974e1eae..b60e3288b 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SaveMessage.cpp @@ -156,7 +156,7 @@ void UIScene_SaveMessage::handleTimerComplete(int id) app.SetOptionsCallbackStatus(0,C4JStorage::eOptions_Callback_Read_CorruptDeletePending); m_bIgnoreInput=false; // give the option to delete the save - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_CORRUPT_FILE, IDS_CORRUPT_OPTIONS, uiIDA, 1, 0,&UIScene_SaveMessage::DeleteOptionsDialogReturned,this, app.GetStringTable()); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp index 3e3efb9b5..e4d741a69 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsAudioMenu.cpp @@ -7,11 +7,11 @@ UIScene_SettingsAudioMenu::UIScene_SettingsAudioMenu(int iPad, void *initData, U // Setup all the Iggy references we need for this scene initialiseMovie(); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),app.GetGameSettings(m_iPad,eGameSetting_MusicVolume)); + wchar_t TempString[256]; + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),app.GetGameSettings(m_iPad,eGameSetting_MusicVolume)); m_sliderMusic.init(TempString,eControl_Music,0,100,app.GetGameSettings(m_iPad,eGameSetting_MusicVolume)); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),app.GetGameSettings(m_iPad,eGameSetting_SoundFXVolume)); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),app.GetGameSettings(m_iPad,eGameSetting_SoundFXVolume)); m_sliderSound.init(TempString,eControl_Sound,0,100,app.GetGameSettings(m_iPad,eGameSetting_SoundFXVolume)); doHorizontalResizeCheck(); @@ -92,7 +92,7 @@ void UIScene_SettingsAudioMenu::handleInput(int iPad, int key, bool repeat, bool void UIScene_SettingsAudioMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { @@ -100,7 +100,7 @@ void UIScene_SettingsAudioMenu::handleSliderMove(F64 sliderId, F64 currentValue) m_sliderMusic.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_MusicVolume,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_MUSIC ),value); m_sliderMusic.setLabel(TempString); break; @@ -108,7 +108,7 @@ void UIScene_SettingsAudioMenu::handleSliderMove(F64 sliderId, F64 currentValue) m_sliderSound.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_SoundFXVolume,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SOUND ),value); m_sliderSound.setLabel(TempString); break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp index d34586891..361d8f626 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsControlMenu.cpp @@ -7,11 +7,11 @@ UIScene_SettingsControlMenu::UIScene_SettingsControlMenu(int iPad, void *initDat // Setup all the Iggy references we need for this scene initialiseMovie(); - WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame)); + wchar_t TempString[256]; + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame)); m_sliderSensitivityInGame.init(TempString,eControl_SensitivityInGame,0,200,app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame)); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InMenu)); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InMenu)); m_sliderSensitivityInMenu.init(TempString,eControl_SensitivityInMenu,0,200,app.GetGameSettings(m_iPad,eGameSetting_Sensitivity_InMenu)); doHorizontalResizeCheck(); @@ -92,7 +92,7 @@ void UIScene_SettingsControlMenu::handleInput(int iPad, int key, bool repeat, bo void UIScene_SettingsControlMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { @@ -100,7 +100,7 @@ void UIScene_SettingsControlMenu::handleSliderMove(F64 sliderId, F64 currentValu m_sliderSensitivityInGame.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_Sensitivity_InGame,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INGAME ),value); m_sliderSensitivityInGame.setLabel(TempString); break; @@ -108,7 +108,7 @@ void UIScene_SettingsControlMenu::handleSliderMove(F64 sliderId, F64 currentValu m_sliderSensitivityInMenu.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_Sensitivity_InMenu,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_SENSITIVITY_INMENU ),value); m_sliderSensitivityInMenu.setLabel(TempString); break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp index 3e60fb506..7b1813edc 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -14,12 +14,12 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD m_checkboxCustomSkinAnim.init(app.GetString(IDS_CHECKBOX_CUSTOM_SKIN_ANIM),eControl_CustomSkinAnim,(app.GetGameSettings(m_iPad,eGameSetting_CustomSkinAnim)!=0)); - WCHAR TempString[256]; + wchar_t TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma)); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma)); m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma)); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); doHorizontalResizeCheck(); @@ -129,7 +129,7 @@ void UIScene_SettingsGraphicsMenu::handleInput(int iPad, int key, bool repeat, b void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { @@ -137,7 +137,7 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal m_sliderGamma.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_Gamma,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),value); m_sliderGamma.setLabel(TempString); break; @@ -145,7 +145,7 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal m_sliderInterfaceOpacity.handleSliderMove(value); app.SetGameSettings(m_iPad,eGameSetting_InterfaceOpacity,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),value); + swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),value); m_sliderInterfaceOpacity.setLabel(TempString); break; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp index edd011d96..64ac27c5c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsMenu.cpp @@ -138,7 +138,7 @@ void UIScene_SettingsMenu::handlePress(F64 controlId, F64 childId) case BUTTON_ALL_RESETTODEFAULTS: { // check they really want to do this - UINT uiIDA[2]; + unsigned int uiIDA[2]; uiIDA[0]=IDS_CONFIRM_CANCEL; uiIDA[1]=IDS_CONFIRM_OK; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp index 87870dfd7..96df5d076 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsOptionsMenu.cpp @@ -221,7 +221,6 @@ void UIScene_SettingsOptionsMenu::handleInput(int iPad, int key, bool repeat, bo void UIScene_SettingsOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; int value = (int)currentValue; switch((int)sliderId) { diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp index 100e746ad..837ef000a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SettingsUIMenu.cpp @@ -16,12 +16,12 @@ UIScene_SettingsUIMenu::UIScene_SettingsUIMenu(int iPad, void *initData, UILayer m_checkboxSplitscreen.init(app.GetString(IDS_CHECKBOX_VERTICAL_SPLIT_SCREEN),eControl_Splitscreen,(app.GetGameSettings(m_iPad,eGameSetting_SplitScreenVertical)!=0)); m_checkboxShowSplitscreenGamertags.init(app.GetString(IDS_CHECKBOX_DISPLAY_SPLITSCREENGAMERTAGS),eControl_ShowSplitscreenGamertags,(app.GetGameSettings(m_iPad,eGameSetting_DisplaySplitscreenGamertags)!=0)); - WCHAR TempString[256]; + wchar_t TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),app.GetGameSettings(m_iPad,eGameSetting_UISize)+1); + swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),app.GetGameSettings(m_iPad,eGameSetting_UISize)+1); m_sliderUISize.init(TempString,eControl_UISize,1,3,app.GetGameSettings(m_iPad,eGameSetting_UISize)+1); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen)+1); + swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen)+1); m_sliderUISizeSplitscreen.init(TempString,eControl_UISizeSplitscreen,1,3,app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen)+1); doHorizontalResizeCheck(); @@ -145,14 +145,14 @@ void UIScene_SettingsUIMenu::handleInput(int iPad, int key, bool repeat, bool pr void UIScene_SettingsUIMenu::handleSliderMove(F64 sliderId, F64 currentValue) { - WCHAR TempString[256]; + wchar_t TempString[256]; int value = (int)currentValue; switch((int)sliderId) { case eControl_UISize: m_sliderUISize.handleSliderMove(value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),value); + swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZE ),value); m_sliderUISize.setLabel(TempString); // is this different from the current value? @@ -167,7 +167,7 @@ void UIScene_SettingsUIMenu::handleSliderMove(F64 sliderId, F64 currentValue) case eControl_UISizeSplitscreen: m_sliderUISizeSplitscreen.handleSliderMove(value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),value); + swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_UISIZESPLITSCREEN ),value); m_sliderUISizeSplitscreen.setLabel(TempString); if(value != app.GetGameSettings(m_iPad,eGameSetting_UISizeSplitscreen)+1) diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp index fb85bd56b..62604696a 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.cpp @@ -140,7 +140,7 @@ void UIScene_SignEntryMenu::handleInput(int iPad, int key, bool repeat, bool pre } } -int UIScene_SignEntryMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) +int UIScene_SignEntryMenu::KeyboardCompleteCallback(void *lpParam,bool bRes) { // 4J HEG - No reason to set value if keyboard was cancelled UIScene_SignEntryMenu *pClass=(UIScene_SignEntryMenu *)lpParam; @@ -179,14 +179,14 @@ void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) case XC_LANGUAGE_JAPANESE: case XC_LANGUAGE_KOREAN: case XC_LANGUAGE_TCHINESE: - InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),(DWORD)m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Email); + InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Email); break; default: - InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),(DWORD)m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); + InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); break; } #else - InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),(DWORD)m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); + InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),m_textInputLines[m_iEditingLine].getLabel(),m_iPad,15,&UIScene_SignEntryMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Alphabet); #endif } break; @@ -203,4 +203,4 @@ void UIScene_SignEntryMenu::handleDestroy() #if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO) InputManager.DestroyKeyboard(); #endif -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.h index d2535ce78..62ac378d0 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SignEntryMenu.h @@ -53,6 +53,6 @@ public: protected: void handlePress(F64 controlId, F64 childId); - static int KeyboardCompleteCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteCallback(void *lpParam,const bool bRes); virtual void handleDestroy(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp index 87ec61804..f1a9f929c 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.cpp @@ -13,7 +13,7 @@ //#define SKIN_SELECT_PACK_PLAYER_CUSTOM 1 #define SKIN_SELECT_MAX_DEFAULTS 2 -const WCHAR *UIScene_SkinSelectMenu::wchDefaultNamesA[]= +const wchar_t *UIScene_SkinSelectMenu::wchDefaultNamesA[]= { L"USE LOCALISED VERSION", // Server selected L"Steve", @@ -442,7 +442,7 @@ void UIScene_SkinSelectMenu::handleInput(int iPad, int key, bool repeat, bool pr { ui.AnimateKeyPress(iPad, key, repeat, pressed, released); ui.PlayUISFX(eSFX_Scroll); - DWORD startingIndex = m_packIndex; + int startingIndex = m_packIndex; m_packIndex = getPreviousPackIndex(m_packIndex); if(startingIndex != m_packIndex) { @@ -477,7 +477,7 @@ void UIScene_SkinSelectMenu::handleInput(int iPad, int key, bool repeat, bool pr { ui.AnimateKeyPress(iPad, key, repeat, pressed, released); ui.PlayUISFX(eSFX_Scroll); - DWORD startingIndex = m_packIndex; + int startingIndex = m_packIndex; m_packIndex = getNextPackIndex(m_packIndex); if(startingIndex != m_packIndex) { @@ -744,15 +744,15 @@ void UIScene_SkinSelectMenu::customDraw(IggyCustomDrawCallbackRegion *region) void UIScene_SkinSelectMenu::handleSkinIndexChanged() { - BOOL showPrevious = FALSE, showNext = FALSE; - DWORD previousIndex = 0, nextIndex = 0; + bool showPrevious = false, showNext = false; + int previousIndex = 0, nextIndex = 0; std::wstring skinName = L""; std::wstring skinOrigin = L""; bool bSkinIsFree=false; bool bLicensed=false; DLCSkinFile *skinFile=NULL; DLCPack *Pack=NULL; - BYTE sidePreviewControlsL,sidePreviewControlsR; + int sidePreviewControlsL, sidePreviewControlsR; m_bNoSkinsToShow=false; TEXTURE_NAME backupTexture = TN_MOB_CHAR; @@ -887,8 +887,8 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() m_characters[eCharacter_Current].SetTexture(m_selectedSkinPath, backupTexture); m_characters[eCharacter_Current].SetCapeTexture(m_selectedCapePath); - showNext = TRUE; - showPrevious = TRUE; + showNext = true; + showPrevious = true; nextIndex = getNextSkinIndex(m_skinIndex); previousIndex = getPreviousSkinIndex(m_skinIndex); @@ -935,7 +935,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() sidePreviewControlsL=sidePreviewControlsR=sidePreviewControls; } - for(BYTE i = 0; i < sidePreviewControlsR; ++i) + for(int i = 0; i < sidePreviewControlsR; ++i) { if(showNext) { @@ -1006,7 +1006,7 @@ void UIScene_SkinSelectMenu::handleSkinIndexChanged() - for(BYTE i = 0; i < sidePreviewControlsL; ++i) + for(int i = 0; i < sidePreviewControlsL; ++i) { if(showPrevious) { @@ -1113,7 +1113,7 @@ TEXTURE_NAME UIScene_SkinSelectMenu::getTextureId(int skinIndex) return texture; } -int UIScene_SkinSelectMenu::getNextSkinIndex(DWORD sourceIndex) +int UIScene_SkinSelectMenu::getNextSkinIndex(int sourceIndex) { int nextSkin = sourceIndex; @@ -1147,7 +1147,7 @@ int UIScene_SkinSelectMenu::getNextSkinIndex(DWORD sourceIndex) return nextSkin; } -int UIScene_SkinSelectMenu::getPreviousSkinIndex(DWORD sourceIndex) +int UIScene_SkinSelectMenu::getPreviousSkinIndex(int sourceIndex) { int previousSkin = sourceIndex; switch(m_packIndex) @@ -1200,7 +1200,7 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() if(m_currentPack != NULL) { bool found; - DWORD currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); + int currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); if(found) m_skinIndex = currentSkinIndex; } else @@ -1210,8 +1210,8 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() case SKIN_SELECT_PACK_DEFAULT: if( !GET_IS_DLC_SKIN_FROM_BITMASK(m_originalSkinId) ) { - DWORD ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(m_originalSkinId); - DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId); + std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(m_originalSkinId); + std::uint32_t defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(m_originalSkinId); if( ugcSkinIndex == 0 ) { m_skinIndex = (EDefaultSkins) defaultSkinIndex; @@ -1229,7 +1229,7 @@ void UIScene_SkinSelectMenu::handlePackIndexChanged() DLCPack *Pack=app.m_dlcManager.getPackContainingSkin(chars); if(Pack) { - DWORD currentSkinIndex = Pack->getSkinIndexAt(m_currentSkinPath, found); + int currentSkinIndex = Pack->getSkinIndexAt(m_currentSkinPath, found); if(found) m_skinIndex = app.GetPlayerFavoriteSkinsPos(m_iPad); } } @@ -1304,7 +1304,7 @@ void UIScene_SkinSelectMenu::updatePackDisplay() } -int UIScene_SkinSelectMenu::getNextPackIndex(DWORD sourceIndex) +int UIScene_SkinSelectMenu::getNextPackIndex(int sourceIndex) { int nextPack = sourceIndex; ++nextPack; @@ -1316,12 +1316,12 @@ int UIScene_SkinSelectMenu::getNextPackIndex(DWORD sourceIndex) return nextPack; } -int UIScene_SkinSelectMenu::getPreviousPackIndex(DWORD sourceIndex) +int UIScene_SkinSelectMenu::getPreviousPackIndex(int sourceIndex) { int previousPack = sourceIndex; if (previousPack == SKIN_SELECT_PACK_DEFAULT) { - DWORD packCount = app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin); + int packCount = app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin); if (packCount > 0) { @@ -1523,7 +1523,7 @@ void UIScene_SkinSelectMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, i if( m_currentNavigation == eSkinNavigation_Pack ) { ui.PlayUISFX(eSFX_Scroll); - DWORD startingIndex = m_packIndex; + int startingIndex = m_packIndex; m_packIndex = getPreviousPackIndex(m_packIndex); if(startingIndex != m_packIndex) { @@ -1535,7 +1535,7 @@ void UIScene_SkinSelectMenu::handleTouchInput(unsigned int iPad, S32 x, S32 y, i if( m_currentNavigation == eSkinNavigation_Pack ) { ui.PlayUISFX(eSFX_Scroll); - DWORD startingIndex = m_packIndex; + int startingIndex = m_packIndex; m_packIndex = getNextPackIndex(m_packIndex); if(startingIndex != m_packIndex) { @@ -1712,7 +1712,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: pScene->m_bIgnoreInput = false; } #elif defined _XBOX_ONE - StorageManager.InstallOffer(1,(WCHAR *)(pScene->m_currentPack->getPurchaseOfferId().c_str()), &RenableInput, pScene, NULL); + StorageManager.InstallOffer(1, const_cast(pScene->m_currentPack->getPurchaseOfferId().c_str()), &RenableInput, pScene, NULL); #endif } else // Is signed in, but not live. @@ -1729,7 +1729,7 @@ int UIScene_SkinSelectMenu::UnlockSkinReturned(void *pParam,int iPad,C4JStorage: return 0; } -int UIScene_SkinSelectMenu::RenableInput(LPVOID lpVoid, int, int) +int UIScene_SkinSelectMenu::RenableInput(void *lpVoid, int, int) { ((UIScene_SkinSelectMenu*) lpVoid)->m_bIgnoreInput = false; return 0; @@ -1795,4 +1795,4 @@ void UIScene_SkinSelectMenu::HandleDLCLicenseChange() // update the lock flag handleSkinIndexChanged(); } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h index 6333451b1..247314d4f 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_SkinSelectMenu.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "../../Minecraft.World/Util/Definitions.h" #include "UIScene.h" #include "UIControl_PlayerSkinPreview.h" @@ -6,10 +8,10 @@ class UIScene_SkinSelectMenu : public UIScene { private: - static const WCHAR *wchDefaultNamesA[eDefaultSkins_Count]; + static const wchar_t *wchDefaultNamesA[eDefaultSkins_Count]; // 4J Stu - How many to show on each side of the main control - static const BYTE sidePreviewControls = 4; + static const int sidePreviewControls = 4; #ifdef __PSVITA__ enum ETouchInput @@ -100,8 +102,8 @@ private: UI_END_MAP_ELEMENTS_AND_NAMES() DLCPack *m_currentPack; - DWORD m_packIndex, m_skinIndex; - DWORD m_originalSkinId; + int m_packIndex, m_skinIndex; + std::uint32_t m_originalSkinId; std::wstring m_currentSkinPath, m_selectedSkinPath, m_selectedCapePath; std::vector *m_vAdditionalSkinBoxes; @@ -109,7 +111,7 @@ private: ESkinSelectNavigation m_currentNavigation; bool m_bNoSkinsToShow; - DWORD m_currentPackCount; + int m_currentPackCount; bool m_bIgnoreInput; bool m_bSkinIndexChanged; std::wstring m_leftLabel, m_centreLabel, m_rightLabel; @@ -144,15 +146,15 @@ public: private: void handleSkinIndexChanged(); - int getNextSkinIndex(DWORD sourceIndex); - int getPreviousSkinIndex(DWORD sourceIndex); + int getNextSkinIndex(int sourceIndex); + int getPreviousSkinIndex(int sourceIndex); TEXTURE_NAME getTextureId(int skinIndex); void handlePackIndexChanged(); void updatePackDisplay(); - int getNextPackIndex(DWORD sourceIndex); - int getPreviousPackIndex(DWORD sourceIndex); + int getNextPackIndex(int sourceIndex); + int getPreviousPackIndex(int sourceIndex); void setCharacterSelected(bool selected); void setCharacterLocked(bool locked); @@ -170,7 +172,7 @@ private: void showNotOnlineDialog(int iPad); static int UnlockSkinReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int RenableInput(LPVOID lpVoid, int, int); + static int RenableInput(void *lpVoid, int, int); void AddFavoriteSkin(int iPad,int iSkinID); void InputActionOK(unsigned int iPad); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp index 4a5999a1b..6e0620771 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.cpp @@ -34,10 +34,10 @@ UIScene_TeleportMenu::UIScene_TeleportMenu(int iPad, void *initData, UILayer *pa m_playerNames[i] = L""; } - DWORD playerCount = g_NetworkManager.GetPlayerCount(); + int playerCount = g_NetworkManager.GetPlayerCount(); m_playersCount = 0; - for(DWORD i = 0; i < playerCount; ++i) + for(int i = 0; i < playerCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); @@ -124,10 +124,10 @@ void UIScene_TeleportMenu::handleGainFocus(bool navBack) void UIScene_TeleportMenu::handleReload() { - DWORD playerCount = g_NetworkManager.GetPlayerCount(); + int playerCount = g_NetworkManager.GetPlayerCount(); m_playersCount = 0; - for(DWORD i = 0; i < playerCount; ++i) + for(int i = 0; i < playerCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerByIndex( i ); @@ -185,7 +185,7 @@ void UIScene_TeleportMenu::tick() { UIScene::tick(); - for(DWORD i = 0; i < m_playersCount; ++i) + for(int i = 0; i < m_playersCount; ++i) { INetworkPlayer *player = g_NetworkManager.GetPlayerBySmallId( m_players[i] ); diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.h b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.h index a608d8248..9cd3cb760 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.h +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TeleportMenu.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "UIScene.h" class UIScene_TeleportMenu : public UIScene @@ -12,7 +14,7 @@ private: bool m_teleportToPlayer; int m_playersCount; - BYTE m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's + std::uint8_t m_players[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's char m_playersVoiceState[MINECRAFT_NET_MAX_PLAYERS]; short m_playersColourState[MINECRAFT_NET_MAX_PLAYERS]; std::wstring m_playerNames[MINECRAFT_NET_MAX_PLAYERS]; @@ -48,4 +50,4 @@ protected: public: static void OnPlayerChanged(void *callbackParam, INetworkPlayer *pPlayer, bool leaving); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp b/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp index 12ff9020c..272933921 100644 --- a/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp +++ b/Minecraft.Client/Platform/Common/UI/UIScene_TrialExitUpsell.cpp @@ -53,7 +53,7 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat, bool p ProfileManager.GetChatAndContentRestrictions(ProfileManager.GetPrimaryPad(),true,NULL,&bContentRestricted,NULL); if(bContentRestricted) { - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; ui.RequestMessageBox(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, ProfileManager.GetPrimaryPad(),NULL,this, app.GetStringTable()); } diff --git a/Minecraft.Client/Platform/Common/UI/UIStructs.h b/Minecraft.Client/Platform/Common/UI/UIStructs.h index d59a666fa..018be49be 100644 --- a/Minecraft.Client/Platform/Common/UI/UIStructs.h +++ b/Minecraft.Client/Platform/Common/UI/UIStructs.h @@ -2,6 +2,8 @@ // #pragma message("UIStructs.h") +#include + #include "UIEnums.h" class Container; @@ -137,8 +139,8 @@ typedef struct _ConnectionProgressParams bool showTooltips; bool setFailTimer; int timerTime; - void (*cancelFunc)(LPVOID param); - LPVOID cancelFuncParam; + void (*cancelFunc)(void *param); + void *cancelFuncParam; _ConnectionProgressParams() { @@ -155,20 +157,20 @@ typedef struct _ConnectionProgressParams // Fullscreen progress typedef struct _UIFullscreenProgressCompletionData { - BOOL bRequiresUserAction; - BOOL bShowBackground; - BOOL bShowLogo; - BOOL bShowTips; + bool bRequiresUserAction; + bool bShowBackground; + bool bShowLogo; + bool bShowTips; ProgressionCompletionType type; int iPad; EUIScene scene; _UIFullscreenProgressCompletionData() { - bRequiresUserAction = FALSE; - bShowBackground = TRUE; - bShowLogo = TRUE; - bShowTips = TRUE; + bRequiresUserAction = false; + bShowBackground = true; + bShowLogo = true; + bShowTips = true; type = e_ProgressCompletion_NoAction; } } UIFullscreenProgressCompletionData; @@ -176,8 +178,8 @@ typedef struct _UIFullscreenProgressCompletionData // Create world typedef struct _CreateWorldMenuInitData { - BOOL bOnline; - BOOL bIsPrivate; + bool bOnline; + bool bIsPrivate; int iPad; } CreateWorldMenuInitData; @@ -186,8 +188,8 @@ CreateWorldMenuInitData; typedef struct _SaveListDetails { int saveId; - PBYTE pbThumbnailData; - DWORD dwThumbnailSize; + std::uint8_t *pbThumbnailData; + unsigned int dwThumbnailSize; #ifdef _DURANGO wchar_t UTF16SaveName[128]; wchar_t UTF16SaveFilename[MAX_SAVEFILENAME_LENGTH]; @@ -236,28 +238,28 @@ typedef struct _JoinMenuInitData // More Options typedef struct _LaunchMoreOptionsMenuInitData { - BOOL bOnlineGame; - BOOL bInviteOnly; - BOOL bAllowFriendsOfFriends; + bool bOnlineGame; + bool bInviteOnly; + bool bAllowFriendsOfFriends; - BOOL bGenerateOptions; - BOOL bStructures; - BOOL bFlatWorld; - BOOL bBonusChest; + bool bGenerateOptions; + bool bStructures; + bool bFlatWorld; + bool bBonusChest; - BOOL bPVP; - BOOL bTrust; - BOOL bFireSpreads; - BOOL bTNT; + bool bPVP; + bool bTrust; + bool bFireSpreads; + bool bTNT; - BOOL bHostPrivileges; - BOOL bResetNether; + bool bHostPrivileges; + bool bResetNether; - BOOL bOnlineSettingChangedBySystem; + bool bOnlineSettingChangedBySystem; int iPad; - DWORD dwTexturePack; + std::uint32_t dwTexturePack; std::wstring seed; int worldSize; @@ -266,11 +268,11 @@ typedef struct _LaunchMoreOptionsMenuInitData _LaunchMoreOptionsMenuInitData() { memset((void*)this,0,sizeof(_LaunchMoreOptionsMenuInitData)); - bOnlineGame = TRUE; - bAllowFriendsOfFriends = TRUE; - bPVP = TRUE; - bFireSpreads = TRUE; - bTNT = TRUE; + bOnlineGame = true; + bAllowFriendsOfFriends = true; + bPVP = true; + bFireSpreads = true; + bTNT = true; iPad = -1; worldSize = 3; seed = L""; @@ -282,14 +284,14 @@ LaunchMoreOptionsMenuInitData; typedef struct _LoadingInputParams { C4JThreadStartFunc* func; - LPVOID lpParam; + void *lpParam; UIFullscreenProgressCompletionData *completionData; int cancelText; - void (*cancelFunc)(LPVOID param); - void (*completeFunc)(LPVOID param); - LPVOID m_cancelFuncParam; - LPVOID m_completeFuncParam; + void (*cancelFunc)(void *param); + void (*completeFunc)(void *param); + void *m_cancelFuncParam; + void *m_completeFuncParam; bool waitForThreadToDelete; _LoadingInputParams() @@ -319,8 +321,8 @@ typedef struct _TutorialPopupInfo #else UIScene *interactScene; #endif - LPCWSTR desc; - LPCWSTR title; + const wchar_t *desc; + const wchar_t *title; int icon; int iAuxVal /* = 0 */; bool isFoil /* = false */; @@ -346,15 +348,15 @@ typedef struct _TutorialPopupInfo // Quadrant sign in typedef struct _SignInInfo { - int( *Func)(LPVOID,const bool, const int iPad); - LPVOID lpParam; + int( *Func)(void *,const bool, const int iPad); + void *lpParam; bool requireOnline; } SignInInfo; // Credits typedef struct { - LPCWSTR m_Text; // Should contain string, optionally with %s to add in translated string ... e.g. "Andy West - %s" + const wchar_t * m_Text; // Should contain string, optionally with %s to add in translated string ... e.g. "Andy West - %s" int m_iStringID[2]; // May be NO_TRANSLATED_STRING if we do not require to add any translated string. ECreditTextTypes m_eType; } @@ -363,16 +365,16 @@ SCreditTextItemDef; // Message box typedef struct _MessageBoxInfo { - UINT uiTitle; - UINT uiText; - UINT *uiOptionA; - UINT uiOptionC; - DWORD dwPad; - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult); - LPVOID lpParam; + unsigned int uiTitle; + unsigned int uiText; + unsigned int *uiOptionA; + unsigned int uiOptionC; + unsigned int dwPad; + int( *Func)(void *,int,const C4JStorage::EMessageResult); + void *lpParam; //C4JStringTable *pStringTable; // 4J Stu - We don't need this for our internal message boxes - WCHAR *pwchFormatString; - DWORD dwFocusButton; + wchar_t *pwchFormatString; + unsigned int dwFocusButton; } MessageBoxInfo; typedef struct _DLCOffersParam @@ -386,7 +388,7 @@ DLCOffersParam; typedef struct _InGamePlayerOptionsInitData { int iPad; - BYTE networkSmallId; + std::uint8_t networkSmallId; unsigned int playerPrivileges; } InGamePlayerOptionsInitData; diff --git a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp index 8f1ad34af..81ff9b33b 100644 --- a/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp +++ b/Minecraft.Client/Platform/Common/UI/UITTFFont.cpp @@ -1,40 +1,51 @@ #include "../../Minecraft.World/Platform/stdafx.h" #include "UI.h" -#include "../../Minecraft.World/Util/StringHelpers.h" -#include "../../Minecraft.World/IO/Files/File.h" +#include "../../Minecraft.World/Util/PortableFileIO.h" #include "UITTFFont.h" UITTFFont::UITTFFont(const std::string &path, S32 fallbackCharacter) { app.DebugPrintf("UITTFFont opening %s\n",path.c_str()); + pbData = NULL; -#if defined(_UNICODE) && !defined(__linux__) std::wstring wPath = convStringToWstring(path); - HANDLE file = CreateFile(wPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#else - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#endif - if( file == INVALID_HANDLE_VALUE ) + std::FILE *file = PortableFileIO::OpenBinaryFileForRead(wPath); + if( file == NULL ) { - DWORD error = GetLastError(); - app.DebugPrintf("Failed to open TTF file with error code %d (%x)\n", error, error); + app.DebugPrintf("Failed to open TTF file\n"); assert(false); } - DWORD dwHigh=0; - DWORD dwFileSize = GetFileSize(file,&dwHigh); - - if(dwFileSize!=0) + if(!PortableFileIO::Seek(file, 0, SEEK_END)) { - DWORD bytesRead; + std::fclose(file); + app.FatalLoadError(); + } - pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL); - if(bSuccess==FALSE) + const __int64 endPosition = PortableFileIO::Tell(file); + if(endPosition < 0) + { + std::fclose(file); + app.FatalLoadError(); + } + + const std::size_t fileSize = static_cast(endPosition); + if(fileSize != 0) + { + if(!PortableFileIO::Seek(file, 0, SEEK_SET)) + { + std::fclose(file); + app.FatalLoadError(); + } + + pbData = new std::uint8_t[fileSize]; + const std::size_t bytesRead = std::fread(pbData, 1, fileSize, file); + const bool failed = std::ferror(file) != 0 || bytesRead != fileSize; + std::fclose(file); + if(failed) { app.FatalLoadError(); } - CloseHandle(file); IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, "Mojangles_TTF", -1, IGGY_FONTFLAG_none ); @@ -44,8 +55,12 @@ UITTFFont::UITTFFont(const std::string &path, S32 fallbackCharacter) IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, "Times New Roman", -1, IGGY_FONTFLAG_none ); IggyFontInstallTruetypeUTF8 ( (void *)pbData, IGGY_TTC_INDEX_none, "Arial", -1, IGGY_FONTFLAG_none ); } + else + { + std::fclose(file); + } } UITTFFont::~UITTFFont() { -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/UI/UITTFFont.h b/Minecraft.Client/Platform/Common/UI/UITTFFont.h index e489e1e69..6053f9b49 100644 --- a/Minecraft.Client/Platform/Common/UI/UITTFFont.h +++ b/Minecraft.Client/Platform/Common/UI/UITTFFont.h @@ -1,9 +1,11 @@ #pragma once +#include + class UITTFFont { private: - PBYTE pbData; + std::uint8_t *pbData; //DWORD dwDataSize; public: diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_DLCOffers.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_DLCOffers.cpp index 1db284ac4..b41d5835f 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_DLCOffers.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_DLCOffers.cpp @@ -449,9 +449,9 @@ HRESULT CScene_DLCOffers::GetDLCInfo( int iOfferC, bool bUpdateOnly ) DLC_INFO *dlc = app.GetDLCInfoForFullOfferID(xOffer.qwOfferID); if (dlc != NULL) { - BYTE *pData=NULL; + std::uint8_t *pData=NULL; UINT uiSize=0; - DWORD dwSize=0; + unsigned int dwSize=0; WCHAR *cString = dlc->wchBanner; // is the file in the TMS XZP? @@ -702,9 +702,9 @@ HRESULT CScene_DLCOffers::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelCha if (dlc != NULL) { - BYTE *pImage=NULL; + std::uint8_t *pImage=NULL; UINT uiSize=0; - DWORD dwSize=0; + unsigned int dwSize=0; WCHAR *cString = dlc->wchBanner; @@ -811,8 +811,8 @@ HRESULT CScene_DLCOffers::OnTimer(XUIMessageTimer *pData,BOOL& rfHandled) if(bPresent) { - BYTE *pImage=NULL; - DWORD dwSize=0; + std::uint8_t *pImage=NULL; + unsigned int dwSize=0; if(m_hXuiBrush!=NULL) { diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_DebugOverlay.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_DebugOverlay.cpp index 088a47402..6764fb23f 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_DebugOverlay.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_DebugOverlay.cpp @@ -307,8 +307,8 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) //SetSpawnToPlayerPos(); FileEntry *origFileEntry = currentSave->createFile( std::wstring( L"level.dat" ) ); byteArray levelData( origFileEntry->getFileSize() ); - DWORD bytesRead; - currentSave->setFilePointer(origFileEntry,0,NULL,FILE_BEGIN); + unsigned int bytesRead; + currentSave->setFilePointer(origFileEntry, 0, SaveFileSeekOrigin::Begin); currentSave->readFile( origFileEntry, levelData.data, // data buffer @@ -317,7 +317,7 @@ void CScene_DebugOverlay::SaveLimitedFile(int chunkRadius) ); FileEntry *newFileEntry = newSave.createFile( std::wstring( L"level.dat" ) ); - DWORD bytesWritten; + unsigned int bytesWritten; newSave.writeFile( newFileEntry, levelData.data, // data buffer origFileEntry->getFileSize(), // number of bytes to write @@ -388,4 +388,4 @@ DataOutputStream *CScene_DebugOverlay::getChunkDataOutputStream(std::unordered_m RegionFile *r = getRegionFile(newFileCache, saveFile, prefix, chunkX, chunkZ); return r->getChunkDataOutputStream(chunkX & 31, chunkZ & 31); } -#endif \ No newline at end of file +#endif diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_InGamePlayerOptions.h b/Minecraft.Client/Platform/Common/XUI/XUI_InGamePlayerOptions.h index 487be5afc..cbd137a2f 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_InGamePlayerOptions.h +++ b/Minecraft.Client/Platform/Common/XUI/XUI_InGamePlayerOptions.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "../Media/xuiscene_ingame_player_options.h" class CScene_InGamePlayerOptions : public CXuiSceneImpl @@ -79,7 +81,7 @@ public: private: bool m_editingSelf; int m_iPad; - BYTE m_networkSmallId; + std::uint8_t m_networkSmallId; unsigned int m_playerPrivileges; D3DXVECTOR3 m_OriginalPosition; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp index 987997a87..a55bef5eb 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_LoadSettings.cpp @@ -51,20 +51,20 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl m_params = (LoadMenuInitData *)pInitData->pvInitData; - m_MoreOptionsParams.bGenerateOptions=FALSE; - m_MoreOptionsParams.bPVP = TRUE; - m_MoreOptionsParams.bTrust = TRUE; - m_MoreOptionsParams.bFireSpreads = TRUE; - m_MoreOptionsParams.bTNT = TRUE; - m_MoreOptionsParams.bHostPrivileges = FALSE; - m_MoreOptionsParams.bResetNether = FALSE; + m_MoreOptionsParams.bGenerateOptions = false; + m_MoreOptionsParams.bPVP = true; + m_MoreOptionsParams.bTrust = true; + m_MoreOptionsParams.bFireSpreads = true; + m_MoreOptionsParams.bTNT = true; + m_MoreOptionsParams.bHostPrivileges = false; + m_MoreOptionsParams.bResetNether = false; m_MoreOptionsParams.iPad = m_params->iPad; // 4J-JEV: Fix for: // TU12: Content: Gameplay: New "Mass Effect World" remembers and uses the settings of another - lately created - World. - m_MoreOptionsParams.bBonusChest = FALSE; - m_MoreOptionsParams.bFlatWorld = FALSE; - m_MoreOptionsParams.bStructures = TRUE; + m_MoreOptionsParams.bBonusChest = false; + m_MoreOptionsParams.bFlatWorld = false; + m_MoreOptionsParams.bStructures = true; m_iPad=m_params->iPad; m_iSaveGameInfoIndex=m_params->iSaveGameInfoIndex; @@ -84,23 +84,23 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // Set the text for friends of friends, and default to on if( m_bMultiplayerAllowed) { - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; if(bGameSetting_Online) { // The profile settings say Online, but either the player is offline, or they are not allowed to play online @@ -130,12 +130,12 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // retrieve the save icon from the texture pack, if there is one TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(m_MoreOptionsParams.dwTexturePack); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hXuiBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&m_hXuiBrush); } // Set this level as created in creative mode, so that people can't use the themed worlds as an easy way to get achievements @@ -195,11 +195,11 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl // Setup all the text and checkboxes to match what the game was saved with on if(bHostOptionsRead) { - m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions,eGameHostOption_PvP)>0?TRUE:FALSE; - m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions,eGameHostOption_TrustPlayers)>0?TRUE:FALSE; - m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions,eGameHostOption_FireSpreads)>0?TRUE:FALSE; - m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions,eGameHostOption_TNT)>0?TRUE:FALSE; - m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions,eGameHostOption_CheatsEnabled)>0?TRUE:FALSE; + m_MoreOptionsParams.bPVP = app.GetGameHostOption(uiHostOptions, eGameHostOption_PvP) > 0; + m_MoreOptionsParams.bTrust = app.GetGameHostOption(uiHostOptions, eGameHostOption_TrustPlayers) > 0; + m_MoreOptionsParams.bFireSpreads = app.GetGameHostOption(uiHostOptions, eGameHostOption_FireSpreads) > 0; + m_MoreOptionsParams.bTNT = app.GetGameHostOption(uiHostOptions, eGameHostOption_TNT) > 0; + m_MoreOptionsParams.bHostPrivileges = app.GetGameHostOption(uiHostOptions, eGameHostOption_CheatsEnabled) > 0; m_bHasBeenInCreative = app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0; if(app.GetGameHostOption(uiHostOptions,eGameHostOption_HasBeenInCreative)>0) @@ -219,7 +219,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl if(app.GetGameHostOption(uiHostOptions,eGameHostOption_FriendsOfFriends) && !(m_bMultiplayerAllowed && bGameSetting_Online)) { - m_MoreOptionsParams.bAllowFriendsOfFriends = TRUE; + m_MoreOptionsParams.bAllowFriendsOfFriends = true; } } @@ -270,10 +270,10 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { ListInfo.fEnabled = TRUE; DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; @@ -297,7 +297,7 @@ HRESULT CScene_LoadGameSettings::OnInit( XUIMessageInit* pInitData, BOOL& bHandl OutputDebugStringW(tp->getName().c_str()); app.DebugPrintf(", sort index - %d\n",ListInfo.iSortIndex); #endif - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&ListInfo.hXuiBrush); m_pTexturePacksList->AddData(ListInfo,0,CXuiCtrl4JList::eSortList_Index); } @@ -389,7 +389,7 @@ HRESULT CScene_LoadGameSettings::LaunchGame(void) // stop the timer running that causes a check for new texture packs in TMS but not installed, since this will run all through the load game, and will crash if it tries to create an hbrush XuiKillTimer(m_hObj,CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID); - if( (m_bGameModeSurvival != true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges == TRUE) + if( (m_bGameModeSurvival != true || m_bHasBeenInCreative) || m_MoreOptionsParams.bHostPrivileges) { UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; @@ -628,7 +628,7 @@ HRESULT CScene_LoadGameSettings::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyP XBackgroundDownloadSetMode(XBACKGROUND_DOWNLOAD_MODE_AUTO); // Check if they have the Reset Nether flag set, and confirm they want to do this - if(m_MoreOptionsParams.bResetNether==TRUE) + if(m_MoreOptionsParams.bResetNether) { UINT uiIDA[2]; uiIDA[0]=IDS_DONT_RESET_NETHER; @@ -748,23 +748,23 @@ HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandle if( bMultiplayerAllowed ) { bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } m_bMultiplayerAllowed = bMultiplayerAllowed; @@ -783,15 +783,15 @@ HRESULT CScene_LoadGameSettings::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandle { if(m_iConfigA[i]!=-1) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); if(dwBytes > 0 && pbData) { - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + unsigned int dwImageBytes=0; + std::uint8_t *pbImageData=NULL; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -857,8 +857,8 @@ int CScene_LoadGameSettings::LoadSaveDataReturned(void *pParam,bool bContinue) { // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -973,7 +973,7 @@ void CScene_LoadGameSettings::StartGameFromSave(CScene_LoadGameSettings* pClass, app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,pClass->m_MoreOptionsParams.bHostPrivileges ); // flag if the user wants to reset the Nether to force a Fortress with netherwart etc. - app.SetResetNether((pClass->m_MoreOptionsParams.bResetNether==TRUE)?true:false); + app.SetResetNether(pClass->m_MoreOptionsParams.bResetNether); // clear out the app's terrain features list app.ClearTerrainFeaturePosition(); @@ -1022,8 +1022,8 @@ int CScene_LoadGameSettings::StartGame_SignInReturned(void *pParam,bool bContinu // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(), false, &pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1241,8 +1241,10 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) if(tp==NULL) { // this is probably a texture pack icon added from TMS - DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + unsigned int dwBytes=0; + unsigned int dwFileBytes=0; + std::uint8_t *pbData=NULL; + std::uint8_t *pbFileData=NULL; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -1259,13 +1261,13 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) } app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush); m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); } app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); @@ -1280,12 +1282,12 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) m_texturePackTitle.SetText(tp->getName().c_str()); m_texturePackDescription.SetText(tp->getDesc1().c_str()); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackIconBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&m_hTexturePackIconBrush); m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); } else @@ -1293,11 +1295,11 @@ void CScene_LoadGameSettings::UpdateTexturePackDescription(int index) m_texturePackIcon->UseBrush(NULL); } - pbImageData = tp->getPackComparison(dwImageBytes); + imageData = tp->getPackComparison(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackComparisonBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); } else @@ -1405,8 +1407,8 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) { // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -1472,7 +1474,7 @@ void CScene_LoadGameSettings::LoadLevelGen(LevelGenerationOptions *levelGen) app.SetGameHostOption(eGameHostOption_HostCanBeInvisible,m_MoreOptionsParams.bHostPrivileges ); // flag if the user wants to reset the Nether to force a Fortress with netherwart etc. - app.SetResetNether((m_MoreOptionsParams.bResetNether==TRUE)?true:false); + app.SetResetNether(m_MoreOptionsParams.bResetNether); // clear out the app's terrain features list app.ClearTerrainFeaturePosition(); @@ -1532,13 +1534,13 @@ HRESULT CScene_LoadGameSettings::OnCustomMessage_DLCMountingComplete() TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { ListInfo.fEnabled = TRUE; - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&ListInfo.hXuiBrush); DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; if(pDLCTexPack) @@ -1683,4 +1685,4 @@ HRESULT CScene_LoadGameSettings::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) #endif CXuiSceneBase::SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK, -1, -1,-1,-1,-1,iRB); return S_OK; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp index 3aeb139cd..bf17a2978 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameCreate.cpp @@ -54,15 +54,15 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle CreateWorldMenuInitData *params = (CreateWorldMenuInitData *)pInitData->pvInitData; - m_MoreOptionsParams.bGenerateOptions=TRUE; - m_MoreOptionsParams.bStructures=TRUE; - m_MoreOptionsParams.bFlatWorld=FALSE; - m_MoreOptionsParams.bBonusChest=FALSE; - m_MoreOptionsParams.bPVP = TRUE; - m_MoreOptionsParams.bTrust = TRUE; - m_MoreOptionsParams.bFireSpreads = TRUE; - m_MoreOptionsParams.bHostPrivileges = FALSE; - m_MoreOptionsParams.bTNT = TRUE; + m_MoreOptionsParams.bGenerateOptions = true; + m_MoreOptionsParams.bStructures = true; + m_MoreOptionsParams.bFlatWorld = false; + m_MoreOptionsParams.bBonusChest = false; + m_MoreOptionsParams.bPVP = true; + m_MoreOptionsParams.bTrust = true; + m_MoreOptionsParams.bFireSpreads = true; + m_MoreOptionsParams.bHostPrivileges = false; + m_MoreOptionsParams.bTNT = true; m_MoreOptionsParams.iPad = params->iPad; m_iPad=params->iPad; delete params; @@ -75,23 +75,23 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle // Set the text for friends of friends, and default to on if( m_bMultiplayerAllowed) { - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; if(bGameSetting_Online) { // The profile settings say Online, but either the player is offline, or they are not allowed to play online @@ -184,10 +184,10 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { ListInfo.fEnabled = TRUE; DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; @@ -213,7 +213,7 @@ HRESULT CScene_MultiGameCreate::OnInit( XUIMessageInit* pInitData, BOOL& bHandle app.DebugPrintf(", sort index - %d\n",ListInfo.iSortIndex); #endif - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&ListInfo.hXuiBrush); m_pTexturePacksList->AddData(ListInfo,0,CXuiCtrl4JList::eSortList_Index); } @@ -442,7 +442,7 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr } } - if(m_bGameModeSurvival != true || m_MoreOptionsParams.bHostPrivileges == TRUE) + if(m_bGameModeSurvival != true || m_MoreOptionsParams.bHostPrivileges) { UINT uiIDA[2]; uiIDA[0]=IDS_CONFIRM_OK; @@ -474,8 +474,8 @@ HRESULT CScene_MultiGameCreate::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPr // Check if user-created content is allowed, as we cannot play multiplayer if it's not //bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && m_MoreOptionsParams.bOnlineGame; bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -579,8 +579,8 @@ int CScene_MultiGameCreate::WarningTrialTexturePackReturned(void *pParam,int iPa { // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -670,23 +670,23 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled if( bMultiplayerAllowed ) { bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; + m_MoreOptionsParams.bOnlineGame = bGameSetting_Online; if(bGameSetting_Online) { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; + m_MoreOptionsParams.bInviteOnly = app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0; + m_MoreOptionsParams.bAllowFriendsOfFriends = app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0; } else { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } } else { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; + m_MoreOptionsParams.bOnlineGame = false; + m_MoreOptionsParams.bInviteOnly = false; + m_MoreOptionsParams.bAllowFriendsOfFriends = false; } m_bMultiplayerAllowed = bMultiplayerAllowed; @@ -705,8 +705,8 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled { if(m_iConfigA[i]!=-1) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -714,8 +714,8 @@ HRESULT CScene_MultiGameCreate::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandled ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); if(dwBytes > 0 && pbData) { - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + unsigned int dwImageBytes=0; + std::uint8_t *pbImageData=NULL; app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); ListInfo.fEnabled = TRUE; @@ -776,8 +776,8 @@ int CScene_MultiGameCreate::ConfirmCreateReturned(void *pParam,int iPad,C4JStora // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool isClientSide = ProfileManager.IsSignedInLive(ProfileManager.GetPrimaryPad()) && pClass->m_MoreOptionsParams.bOnlineGame; bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -831,8 +831,8 @@ int CScene_MultiGameCreate::StartGame_SignInReturned(void *pParam,bool bContinue // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; @@ -903,7 +903,7 @@ void CScene_MultiGameCreate::CreateGame(CScene_MultiGameCreate* pClass, DWORD dw } // start the game - bool isFlat = (pClass->m_MoreOptionsParams.bFlatWorld==TRUE); + bool isFlat = pClass->m_MoreOptionsParams.bFlatWorld; __int64 seedValue = 0; //BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements if (wSeed.length() != 0) @@ -1099,8 +1099,10 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) { // this is probably a texture pack icon added from TMS - DWORD dwBytes=0,dwFileBytes=0; - PBYTE pbData=NULL,pbFileData=NULL; + unsigned int dwBytes=0; + unsigned int dwFileBytes=0; + std::uint8_t *pbData=NULL; + std::uint8_t *pbFileData=NULL; CXuiCtrl4JList::LIST_ITEM_INFO ListItem; // get the current index of the list, and then get the data @@ -1117,13 +1119,13 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) } app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackIconBrush); m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); } app.GetFileFromTPD(eTPDFileType_Comparison,pbData,dwBytes,&pbFileData,&dwFileBytes ); - if(dwFileBytes >= 0 && pbFileData) + if(dwFileBytes > 0 && pbFileData) { XuiCreateTextureBrushFromMemory(pbFileData,dwFileBytes,&m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); @@ -1138,20 +1140,20 @@ void CScene_MultiGameCreate::UpdateTexturePackDescription(int index) m_texturePackTitle.SetText(tp->getName().c_str()); m_texturePackDescription.SetText(tp->getDesc1().c_str()); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackIconBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&m_hTexturePackIconBrush); m_texturePackIcon->UseBrush(m_hTexturePackIconBrush); } - pbImageData = tp->getPackComparison(dwImageBytes); + imageData = tp->getPackComparison(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&m_hTexturePackComparisonBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&m_hTexturePackComparisonBrush); m_texturePackComparison->UseBrush(m_hTexturePackComparisonBrush); } else @@ -1287,13 +1289,13 @@ HRESULT CScene_MultiGameCreate::OnCustomMessage_DLCMountingComplete() TexturePack *tp = pMinecraft->skins->getTexturePackByIndex(i); ZeroMemory(&ListInfo,sizeof(CXuiCtrl4JList::LIST_ITEM_INFO)); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { ListInfo.fEnabled = TRUE; - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&ListInfo.hXuiBrush); DLCTexturePack *pDLCTexPack=(DLCTexturePack *)tp; if(pDLCTexPack) @@ -1394,4 +1396,4 @@ void CScene_MultiGameCreate::ClearTexturePackDescription() m_texturePackDescription.SetText(L" "); m_texturePackComparison->UseBrush(NULL); m_texturePackIcon->UseBrush(NULL); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameInfo.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameInfo.cpp index 20e1f4cac..5e5f662a6 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameInfo.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameInfo.cpp @@ -287,8 +287,8 @@ void CScene_MultiGameInfo::JoinGame(CScene_MultiGameInfo* pClass) // Check if user-created content is allowed, as we cannot play multiplayer if it's not bool noUGC = false; - BOOL pccAllowed = TRUE; - BOOL pccFriendsAllowed = TRUE; + bool pccAllowed = true; + bool pccFriendsAllowed = true; ProfileManager.AllowedPlayerCreatedContent(ProfileManager.GetPrimaryPad(),false,&pccAllowed,&pccFriendsAllowed); if(!pccAllowed && !pccFriendsAllowed) noUGC = true; diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp index b431a4f71..9e11420a4 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_MultiGameJoinLoad.cpp @@ -295,13 +295,13 @@ void CScene_MultiGameJoinLoad::AddDefaultButtons() // increment the count of the mash-up pack worlds in the save list m_iMashUpButtonsC++; TexturePack *tp = Minecraft::GetInstance()->skins->getTexturePackById(levelGen->getRequiredTexturePackId()); - DWORD dwImageBytes; - PBYTE pbImageData = tp->getPackIcon(dwImageBytes); + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = tp->getPackIcon(imageBytes); HXUIBRUSH hXuiBrush; - if(dwImageBytes > 0 && pbImageData) + if(imageBytes > 0 && imageData) { - XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush); + XuiCreateTextureBrushFromMemory(imageData,imageBytes,&hXuiBrush); // the index inside the list item for this will be i+1 because they start at m_vListData.size(), so the first etry (tutorial) is 1 m_pSavesList->UpdateGraphic(iSavesListIndex+1,hXuiBrush); } @@ -1270,29 +1270,31 @@ void CScene_MultiGameJoinLoad::UpdateGamesList() TexturePack *tp = pMinecraft->skins->getTexturePackById(sessionInfo->data.texturePackParentId); HRESULT hr; - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; + std::uint32_t imageBytes = 0; + std::uint8_t *imageData = NULL; if(tp==NULL) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; app.GetTPD(sessionInfo->data.texturePackParentId,&pbData,&dwBytes); // is it in the tpd data ? - app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); - if(dwImageBytes > 0 && pbImageData) + unsigned int tpdImageBytes = 0; + app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&imageData,&tpdImageBytes ); + imageBytes = static_cast(tpdImageBytes); + if(imageBytes > 0 && imageData) { - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&hXuiBrush); m_pGamesList->UpdateGraphic(sessionIndex,hXuiBrush); } } else { - pbImageData = tp->getPackIcon(dwImageBytes); - if(dwImageBytes > 0 && pbImageData) + imageData = tp->getPackIcon(imageBytes); + if(imageBytes > 0 && imageData) { - hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&hXuiBrush); + hr=XuiCreateTextureBrushFromMemory(imageData,imageBytes,&hXuiBrush); m_pGamesList->UpdateGraphic(sessionIndex,hXuiBrush); } } @@ -1742,8 +1744,8 @@ HRESULT CScene_MultiGameJoinLoad::OnTimer( XUIMessageTimer *pTimer, BOOL& bHandl { if(m_iConfigA[i]!=-1) { - DWORD dwBytes=0; - PBYTE pbData=NULL; + unsigned int dwBytes=0; + std::uint8_t *pbData=NULL; //app.DebugPrintf("Retrieving iConfig %d from TPD\n",m_iConfigA[i]); app.GetTPD(m_iConfigA[i],&pbData,&dwBytes); @@ -2764,4 +2766,4 @@ void CScene_MultiGameJoinLoad::SaveUploadCompleteCallback(LPVOID lpParam) app.TMSPP_SetTitleGroupID(GROUP_ID); // app.getRemoteStorage()->abort(); // pClass->m_eSaveUploadState = eSaveUpload_Idle; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Common/XUI/XUI_SkinSelect.cpp b/Minecraft.Client/Platform/Common/XUI/XUI_SkinSelect.cpp index 71f9c9336..189b3bb89 100644 --- a/Minecraft.Client/Platform/Common/XUI/XUI_SkinSelect.cpp +++ b/Minecraft.Client/Platform/Common/XUI/XUI_SkinSelect.cpp @@ -1007,7 +1007,7 @@ void CScene_SkinSelect::handlePackIndexChanged() if(m_currentPack != NULL) { bool found; - DWORD currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); + unsigned int currentSkinIndex = m_currentPack->getSkinIndexAt(m_currentSkinPath, found); if(found) m_skinIndex = currentSkinIndex; } else @@ -1036,7 +1036,7 @@ void CScene_SkinSelect::handlePackIndexChanged() DLCPack *Pack=app.m_dlcManager.getPackContainingSkin(chars); if(Pack) { - DWORD currentSkinIndex = Pack->getSkinIndexAt(m_currentSkinPath, found); + unsigned int currentSkinIndex = Pack->getSkinIndexAt(m_currentSkinPath, found); if(found) m_skinIndex = app.GetPlayerFavoriteSkinsPos(m_iPad); } } @@ -1441,4 +1441,4 @@ void CScene_SkinSelect::AddFavoriteSkin(int iPad,int iSkinID) app.SetPlayerFavoriteSkin(iPad,(int)ucPos,iSkinID); app.SetPlayerFavoriteSkinsPos(m_iPad,ucPos); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Durango/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/Durango/4JLibs/inc/4J_Input.h index 884f281e1..96038740c 100644 --- a/Minecraft.Client/Platform/Durango/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/Durango/4JLibs/inc/4J_Input.h @@ -110,7 +110,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); unsigned int GetConnectedGamepadCount(); bool IsPadConnected(int iPad); @@ -128,7 +128,7 @@ public: // 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, int iMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); + EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, int iMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); bool IsCircleCrossSwapped(); @@ -147,8 +147,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/Minecraft.Client/Platform/Durango/Durango_App.cpp b/Minecraft.Client/Platform/Durango/Durango_App.cpp index d5dfed695..5a4c95e8f 100644 --- a/Minecraft.Client/Platform/Durango/Durango_App.cpp +++ b/Minecraft.Client/Platform/Durango/Durango_App.cpp @@ -114,25 +114,30 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() { RenderManager.CaptureThumbnail(&m_ThumbnailBuffer); } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ThumbnailBuffer.Allocated()) { - if( pbData ) + if( thumbnailData ) { - *pbData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; - *pdwSize=m_ThumbnailBuffer.GetBufferSize(); - memcpy(*pbData,m_ThumbnailBuffer.GetBufferPointer(),*pdwSize); + *thumbnailData = new std::uint8_t[m_ThumbnailBuffer.GetBufferSize()]; + *thumbnailSize = static_cast(m_ThumbnailBuffer.GetBufferSize()); + memcpy(*thumbnailData, m_ThumbnailBuffer.GetBufferPointer(), *thumbnailSize); } m_ThumbnailBuffer.Release(); } else { - if( pbData ) + if( thumbnailData ) { // use the default image - StorageManager.GetDefaultSaveThumbnail(pbData,pdwSize); + DWORD defaultSize = 0; + StorageManager.GetDefaultSaveThumbnail(thumbnailData, &defaultSize); + if (thumbnailSize) + { + *thumbnailSize = static_cast(defaultSize); + } } } } @@ -141,7 +146,7 @@ void CConsoleMinecraftApp::ReleaseSaveThumbnail() } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } @@ -796,4 +801,4 @@ void CConsoleMinecraftApp::ReadLocalDLCList(void) delete pDecompressedData; } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Durango/Durango_App.h b/Minecraft.Client/Platform/Durango/Durango_App.h index 6e0212329..cd775c70e 100644 --- a/Minecraft.Client/Platform/Durango/Durango_App.h +++ b/Minecraft.Client/Platform/Durango/Durango_App.h @@ -23,9 +23,9 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt); diff --git a/Minecraft.Client/Platform/Extrax64Stubs.cpp b/Minecraft.Client/Platform/Extrax64Stubs.cpp index 0d7476e9f..683ef6f94 100644 --- a/Minecraft.Client/Platform/Extrax64Stubs.cpp +++ b/Minecraft.Client/Platform/Extrax64Stubs.cpp @@ -467,14 +467,14 @@ void C_4JProfile::SetLockedProfile(int iProf) {} bool C_4JProfile::IsSignedIn(int iQuadrant) { return ( iQuadrant == 0); } bool C_4JProfile::IsSignedInLive(int iProf) { return true; } 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; } +UINT C_4JProfile::RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant) { return 0; } +UINT C_4JProfile::DisplayOfflineProfile(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant) { return 0; } +UINT C_4JProfile::RequestConvertOfflineToGuestUI(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant) { return 0; } void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {} bool C_4JProfile::QuerySigninStatus(void) { return true; } void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid) {*pXuid = 0xe000d45248242f2e; } -BOOL C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return false; } -BOOL C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; } +bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2) { return false; } +bool C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; } bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; } #if defined(__ORBIS__) @@ -488,9 +488,9 @@ bool C_4JProfile::GetChatAndContentRestrictions(int iPad, bool thisQuadrantOn #endif void C_4JProfile::StartTrialGame() {} -void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, BOOL *allAllowed, BOOL *friendsAllowed) {} -BOOL C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, DWORD dwXuidCount ) { return true; } -bool C_4JProfile::GetProfileAvatar(int iPad,int( *Func)(LPVOID lpParam,PBYTE pbThumbnail,DWORD dwThumbnailBytes), LPVOID lpParam) { return false; } +void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed) {} +bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount) { return true; } +bool C_4JProfile::GetProfileAvatar(int iPad,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam) { return false; } void C_4JProfile::CancelProfileAvatarRequest() {} int C_4JProfile::GetPrimaryPad() { return 0; } void C_4JProfile::SetPrimaryPad(int iPad) {} @@ -503,22 +503,22 @@ char* C_4JProfile::GetGamertag(int iPad){ return "PlayerName"; } std::wstring C_4JProfile::GetDisplayName(int iPad){ return L"PlayerName"; } #endif bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; } -void C_4JProfile::SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam) {} -void C_4JProfile::SetNotificationsCallback(void ( *Func)(LPVOID, DWORD, unsigned int),LPVOID lpParam) {} +void C_4JProfile::SetSignInChangeCallback(void ( *Func)(void *, bool, unsigned int),void *lpParam) {} +void C_4JProfile::SetNotificationsCallback(void ( *Func)(void *, std::uint32_t, unsigned int),void *lpParam) {} bool C_4JProfile::RegionIsNorthAmerica(void) { return false; } bool C_4JProfile::LocaleIsUSorCanada(void) { return false; } HRESULT C_4JProfile::GetLiveConnectionStatus() { return S_OK; } bool C_4JProfile::IsSystemUIDisplayed() { return false; } -void C_4JProfile::SetProfileReadErrorCallback(void ( *Func)(LPVOID), LPVOID lpParam) {} -int( *defaultOptionsCallback)(LPVOID,C_4JProfile::PROFILESETTINGS *, const int iPad) = NULL; -LPVOID lpProfileParam = NULL; -int C_4JProfile::SetDefaultOptionsCallback(int( *Func)(LPVOID,PROFILESETTINGS *, const int iPad),LPVOID lpParam) +void C_4JProfile::SetProfileReadErrorCallback(void ( *Func)(void *), void *lpParam) {} +int( *defaultOptionsCallback)(void *,C_4JProfile::PROFILESETTINGS *, const int iPad) = NULL; +void *lpProfileParam = NULL; +int C_4JProfile::SetDefaultOptionsCallback(int( *Func)(void *,PROFILESETTINGS *, const int iPad),void *lpParam) { defaultOptionsCallback = Func; lpProfileParam = lpParam; return 0; } -int C_4JProfile::SetOldProfileVersionCallback(int( *Func)(LPVOID,unsigned char *, const unsigned short,const int),LPVOID lpParam) { return 0; } +int C_4JProfile::SetOldProfileVersionCallback(int( *Func)(void *,unsigned char *, const unsigned short,const int),void *lpParam) { return 0; } // To store the dashboard preferences for controller flipped, etc. C_4JProfile::PROFILESETTINGS ProfileSettingsA[XUSER_MAX_COUNT]; @@ -548,7 +548,7 @@ 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::SetUpsellCallback(void ( *Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData),void *lpParam) {} void C_4JProfile::SetDebugFullOverride(bool bVal) {s_bProfileIsFullVersion = bVal;} void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {} @@ -593,7 +593,7 @@ PSAVE_DETAILS C4JStorage::ReturnSavesInfo() {return NULL;} 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 dwOfferTypesBitmaskT) { return C4JStorage::EDLC_Idle; } +C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad,int( *Func)(void *, int, std::uint32_t, int),void *lpParam, DWORD dwOfferTypesBitmaskT) { return C4JStorage::EDLC_Idle; } DWORD C4JStorage::CancelGetDLCOffers() { return 0; } void C4JStorage::ClearDLCOffers() {} XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw) { static XMARKETPLACE_CONTENTOFFER_INFO retval = {0}; return retval; } @@ -602,7 +602,7 @@ DWORD C4JStorage::InstallOffer(int iOfferIDC,ULONGLONG *ullOfferIDA,int( DWORD C4JStorage::GetAvailableDLCCount( int iPad) { return 0; } XCONTENT_DATA& C4JStorage::GetDLC(DWORD dw) { static XCONTENT_DATA retval = {0}; return retval; } C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,int( *Func)(LPVOID, int, int),LPVOID lpParam) { return C4JStorage::EDLC_Idle; } -DWORD C4JStorage::MountInstalledDLC(int iPad,DWORD dwDLC,int( *Func)(LPVOID, int, DWORD,DWORD),LPVOID lpParam,LPCSTR szMountDrive) { return 0; } +std::uint32_t C4JStorage::MountInstalledDLC(int iPad,std::uint32_t dwDLC,int( *Func)(void *, int, std::uint32_t, std::uint32_t),void *lpParam,LPCSTR szMountDrive) { return 0; } DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) { return 0; } 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 C4JStorage::ETMSStatus_Idle; } bool C4JStorage::WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize) { return true; } diff --git a/Minecraft.Client/Platform/Linux/Linux_App.cpp b/Minecraft.Client/Platform/Linux/Linux_App.cpp index a9520f211..332537d07 100644 --- a/Minecraft.Client/Platform/Linux/Linux_App.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_App.cpp @@ -39,14 +39,14 @@ void CConsoleMinecraftApp::FatalLoadError() void CConsoleMinecraftApp::CaptureSaveThumbnail() { } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) { } void CConsoleMinecraftApp::ReleaseSaveThumbnail() { } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } diff --git a/Minecraft.Client/Platform/Linux/Linux_App.h b/Minecraft.Client/Platform/Linux/Linux_App.h index 39351d55b..f15afd928 100644 --- a/Minecraft.Client/Platform/Linux/Linux_App.h +++ b/Minecraft.Client/Platform/Linux/Linux_App.h @@ -12,9 +12,9 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt); diff --git a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp index 38717792f..14729679c 100644 --- a/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_Minecraft.cpp @@ -700,10 +700,10 @@ ProfileManager.Initialise(TITLEID_MINECRAFT, ); // set a function to be called when there's a sign in change, so we can exit a level if the primary player signs out -ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback,(LPVOID)&app); +ProfileManager.SetSignInChangeCallback(&CConsoleMinecraftApp::SignInChangeCallback, &app); // Set a callback for when there is a read error on profile data -//StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback,(LPVOID)&app); +//StorageManager.SetProfileReadErrorCallback(&CConsoleMinecraftApp::ProfileReadErrorCallback, &app); // QNet needs to be setup after profile manager, as we do not want its Notify listener to handle diff --git a/Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Input.h index 75960c5ab..71c32ebbc 100644 --- a/Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/Orbis/4JLibs/inc/4J_Input.h @@ -173,7 +173,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); void SetCircleCrossSwapped(bool swapped); @@ -191,7 +191,7 @@ public: void SetMenuDisplayed(int iPad, bool bVal); - C_4JInput::EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad, UINT uiMaxChars, int( *Func)(LPVOID,const bool),LPVOID lpParam,C_4JInput::EKeyboardMode eMode); + C_4JInput::EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); void GetText(uint16_t *UTF16String); @@ -214,8 +214,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/Minecraft.Client/Platform/Orbis/Orbis_App.cpp b/Minecraft.Client/Platform/Orbis/Orbis_App.cpp index fa0c48c84..16cd30972 100644 --- a/Minecraft.Client/Platform/Orbis/Orbis_App.cpp +++ b/Minecraft.Client/Platform/Orbis/Orbis_App.cpp @@ -227,44 +227,54 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() { RenderManager.CaptureThumbnail(&m_ThumbnailBuffer,&m_SaveImageBuffer); } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ThumbnailBuffer.Allocated()) { - if( ppbThumbnailData ) + if( thumbnailData ) { - *ppbThumbnailData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; - *pdwThumbnailSize=m_ThumbnailBuffer.GetBufferSize(); - memcpy(*ppbThumbnailData,m_ThumbnailBuffer.GetBufferPointer(),*pdwThumbnailSize); + *thumbnailData = new std::uint8_t[m_ThumbnailBuffer.GetBufferSize()]; + *thumbnailSize = static_cast(m_ThumbnailBuffer.GetBufferSize()); + memcpy(*thumbnailData, m_ThumbnailBuffer.GetBufferPointer(), *thumbnailSize); } m_ThumbnailBuffer.Release(); } else { - if( ppbThumbnailData ) + if( thumbnailData ) { // use the default image - StorageManager.GetDefaultSaveThumbnail(ppbThumbnailData,pdwThumbnailSize); + DWORD defaultThumbnailSize = 0; + StorageManager.GetDefaultSaveThumbnail(thumbnailData, &defaultThumbnailSize); + if (thumbnailSize) + { + *thumbnailSize = static_cast(defaultThumbnailSize); + } } } if(m_SaveImageBuffer.Allocated()) { - if( ppbDataImage ) + if( saveImageData ) { - *ppbDataImage= new BYTE [m_SaveImageBuffer.GetBufferSize()]; - *pdwSizeImage=m_SaveImageBuffer.GetBufferSize(); - memcpy(*ppbDataImage,m_SaveImageBuffer.GetBufferPointer(),*pdwSizeImage); + *saveImageData = new std::uint8_t[m_SaveImageBuffer.GetBufferSize()]; + *saveImageSize = static_cast(m_SaveImageBuffer.GetBufferSize()); + memcpy(*saveImageData, m_SaveImageBuffer.GetBufferPointer(), *saveImageSize); } m_SaveImageBuffer.Release(); } else { - if( ppbDataImage ) + if( saveImageData ) { // use the default image - StorageManager.GetDefaultSaveImage(ppbDataImage,pdwSizeImage); + DWORD defaultSaveImageSize = 0; + StorageManager.GetDefaultSaveImage(saveImageData, &defaultSaveImageSize); + if (saveImageSize) + { + *saveImageSize = static_cast(defaultSaveImageSize); + } } } } @@ -274,7 +284,7 @@ void CConsoleMinecraftApp::ReleaseSaveThumbnail() } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } @@ -1278,4 +1288,4 @@ void CConsoleMinecraftApp::PatchAvailableDialogTick() m_bPatchAvailableDialogRunning=false; } } -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Orbis/Orbis_App.h b/Minecraft.Client/Platform/Orbis/Orbis_App.h index 68be9be45..ef55633a9 100644 --- a/Minecraft.Client/Platform/Orbis/Orbis_App.h +++ b/Minecraft.Client/Platform/Orbis/Orbis_App.h @@ -68,10 +68,10 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*) {}; // NOT USED - virtual void GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) {}; // NOT USED + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); int LoadLocalTMSFile(char *chTMSFile); int LoadLocalDLCImage(SONYDLC *pDLCInfo); diff --git a/Minecraft.Client/Platform/PS3/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/PS3/4JLibs/inc/4J_Input.h index 6f51bba51..09e97b0ea 100644 --- a/Minecraft.Client/Platform/PS3/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/PS3/4JLibs/inc/4J_Input.h @@ -115,7 +115,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); bool IsCircleCrossSwapped(); @@ -132,7 +132,7 @@ public: // 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); + EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void DestroyKeyboard(); void GetText(uint16_t *UTF16String); @@ -153,8 +153,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/Minecraft.Client/Platform/PS3/Network/SonyRemoteStorage_PS3.cpp b/Minecraft.Client/Platform/PS3/Network/SonyRemoteStorage_PS3.cpp index 4dbd9f224..ab16c7b71 100644 --- a/Minecraft.Client/Platform/PS3/Network/SonyRemoteStorage_PS3.cpp +++ b/Minecraft.Client/Platform/PS3/Network/SonyRemoteStorage_PS3.cpp @@ -1,6 +1,7 @@ #include "../../../../Minecraft.World/Platform/stdafx.h" #include "SonyRemoteStorage_PS3.h" +#include #include #include #include @@ -84,12 +85,12 @@ int SonyRemoteStorage_PS3::initPreconditions() return 0; } -void SonyRemoteStorage_PS3::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) +void SonyRemoteStorage_PS3::staticInternalCallback(const SceRemoteStorageEvent event, std::int32_t retCode, void * userData) { ((SonyRemoteStorage_PS3*)userData)->internalCallback(event, retCode); } -void SonyRemoteStorage_PS3::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) +void SonyRemoteStorage_PS3::internalCallback(const SceRemoteStorageEvent event, std::int32_t retCode) { m_lastErrorCode = retCode; @@ -341,7 +342,7 @@ bool SonyRemoteStorage_PS3::setDataInternal() { unsigned int uiHostOptions; bool bHostOptionsRead; - DWORD uiTexturePack; + std::uint32_t uiTexturePack = 0; char seed[22]; app.GetImageTextData(m_thumbnailData, m_thumbnailDataSize,(unsigned char *)seed, uiHostOptions, bHostOptionsRead, uiTexturePack); @@ -451,7 +452,7 @@ int SonyRemoteStorage_PS3::LoadCompressCallback(void *pParam,bool bIsCorrupt, bo // We add 4 bytes to the start so that we can signal compressed data // And another 4 bytes to store the decompressed data size unsigned int compLength = origFilesize+8; - uint8_t *compData = (uint8_t *)malloc( compLength ); + std::uint8_t *compData = (std::uint8_t *)malloc( compLength ); Compression::UseDefaultThreadStorage(); Compression::getCompression()->Compress(compData+8,&compLength,pOrigSaveData,origFilesize); ZeroMemory(compData,8); diff --git a/Minecraft.Client/Platform/PS3/PS3_App.cpp b/Minecraft.Client/Platform/PS3/PS3_App.cpp index 1b9537220..b2f8d0646 100644 --- a/Minecraft.Client/Platform/PS3/PS3_App.cpp +++ b/Minecraft.Client/Platform/PS3/PS3_App.cpp @@ -391,44 +391,54 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() MemSect(0); } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ThumbnailBuffer.Allocated()) { - if( ppbThumbnailData ) + if( thumbnailData ) { - *ppbThumbnailData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; - *pdwThumbnailSize=m_ThumbnailBuffer.GetBufferSize(); - memcpy(*ppbThumbnailData,m_ThumbnailBuffer.GetBufferPointer(),*pdwThumbnailSize); + *thumbnailData = new std::uint8_t[m_ThumbnailBuffer.GetBufferSize()]; + *thumbnailSize = static_cast(m_ThumbnailBuffer.GetBufferSize()); + memcpy(*thumbnailData, m_ThumbnailBuffer.GetBufferPointer(), *thumbnailSize); } m_ThumbnailBuffer.Release(); } else { - if( ppbThumbnailData ) + if( thumbnailData ) { // use the default image - StorageManager.GetDefaultSaveThumbnail(ppbThumbnailData,pdwThumbnailSize); + DWORD defaultThumbnailSize = 0; + StorageManager.GetDefaultSaveThumbnail(thumbnailData, &defaultThumbnailSize); + if (thumbnailSize) + { + *thumbnailSize = static_cast(defaultThumbnailSize); + } } } if(m_SaveImageBuffer.Allocated()) { - if( ppbDataImage ) + if( saveImageData ) { - *ppbDataImage= new BYTE [m_SaveImageBuffer.GetBufferSize()]; - *pdwSizeImage=m_SaveImageBuffer.GetBufferSize(); - memcpy(*ppbDataImage,m_SaveImageBuffer.GetBufferPointer(),*pdwSizeImage); + *saveImageData = new std::uint8_t[m_SaveImageBuffer.GetBufferSize()]; + *saveImageSize = static_cast(m_SaveImageBuffer.GetBufferSize()); + memcpy(*saveImageData, m_SaveImageBuffer.GetBufferPointer(), *saveImageSize); } m_SaveImageBuffer.Release(); } else { - if( ppbDataImage ) + if( saveImageData ) { // use the default image - StorageManager.GetDefaultSaveImage(ppbDataImage,pdwSizeImage); + DWORD defaultSaveImageSize = 0; + StorageManager.GetDefaultSaveImage(saveImageData, &defaultSaveImageSize); + if (saveImageSize) + { + *saveImageSize = static_cast(defaultSaveImageSize); + } } } } @@ -440,7 +450,7 @@ void CConsoleMinecraftApp::ReleaseSaveThumbnail() } } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } diff --git a/Minecraft.Client/Platform/PS3/PS3_App.h b/Minecraft.Client/Platform/PS3/PS3_App.h index 305a5f2b5..a643280e9 100644 --- a/Minecraft.Client/Platform/PS3/PS3_App.h +++ b/Minecraft.Client/Platform/PS3/PS3_App.h @@ -68,10 +68,10 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*) {}; // NOT USED - virtual void GetSaveThumbnail(PBYTE*,DWORD*,PBYTE*,DWORD*); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) {}; // NOT USED + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); // BANNED LEVEL LIST virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {} diff --git a/Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Input.h index c0209eb66..aec2c5c07 100644 --- a/Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/PSVita/4JLibs/inc/4J_Input.h @@ -124,7 +124,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); void SetCircleCrossSwapped(bool swapped); @@ -147,7 +147,7 @@ public: // 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); + EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); // Online check strings against offensive list - TCR 92 @@ -164,8 +164,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); bool IsVitaTV(); diff --git a/Minecraft.Client/Platform/PSVita/Network/SonyRemoteStorage_Vita.cpp b/Minecraft.Client/Platform/PSVita/Network/SonyRemoteStorage_Vita.cpp index 1b7d0844b..70117ffce 100644 --- a/Minecraft.Client/Platform/PSVita/Network/SonyRemoteStorage_Vita.cpp +++ b/Minecraft.Client/Platform/PSVita/Network/SonyRemoteStorage_Vita.cpp @@ -2,6 +2,7 @@ #include "SonyRemoteStorage_Vita.h" #include "SonyHttp_Vita.h" +#include #include #include #include @@ -24,12 +25,12 @@ static SceRemoteStorageData s_getDataOutput; -void SonyRemoteStorage_Vita::staticInternalCallback(const SceRemoteStorageEvent event, int32_t retCode, void * userData) +void SonyRemoteStorage_Vita::staticInternalCallback(const SceRemoteStorageEvent event, std::int32_t retCode, void * userData) { ((SonyRemoteStorage_Vita*)userData)->internalCallback(event, retCode); } -void SonyRemoteStorage_Vita::internalCallback(const SceRemoteStorageEvent event, int32_t retCode) +void SonyRemoteStorage_Vita::internalCallback(const SceRemoteStorageEvent event, std::int32_t retCode) { m_lastErrorCode = retCode; @@ -313,7 +314,7 @@ bool SonyRemoteStorage_Vita::setDataInternal() { unsigned int uiHostOptions; bool bHostOptionsRead; - DWORD uiTexturePack; + std::uint32_t uiTexturePack = 0; char seed[22]; app.GetImageTextData(m_thumbnailData, m_thumbnailDataSize,(unsigned char *)seed, uiHostOptions, bHostOptionsRead, uiTexturePack); diff --git a/Minecraft.Client/Platform/PSVita/PSVita_App.cpp b/Minecraft.Client/Platform/PSVita/PSVita_App.cpp index ed23f0f15..888e4c854 100644 --- a/Minecraft.Client/Platform/PSVita/PSVita_App.cpp +++ b/Minecraft.Client/Platform/PSVita/PSVita_App.cpp @@ -208,44 +208,54 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() { RenderManager.CaptureThumbnail(&m_ThumbnailBuffer); } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ThumbnailBuffer.Allocated()) { - if( ppbThumbnailData ) + if( thumbnailData ) { - *ppbThumbnailData= new BYTE [m_ThumbnailBuffer.GetBufferSize()]; - *pdwThumbnailSize=m_ThumbnailBuffer.GetBufferSize(); - memcpy(*ppbThumbnailData,m_ThumbnailBuffer.GetBufferPointer(),*pdwThumbnailSize); + *thumbnailData = new std::uint8_t[m_ThumbnailBuffer.GetBufferSize()]; + *thumbnailSize = static_cast(m_ThumbnailBuffer.GetBufferSize()); + memcpy(*thumbnailData, m_ThumbnailBuffer.GetBufferPointer(), *thumbnailSize); } m_ThumbnailBuffer.Release(); } else { - if( ppbThumbnailData ) + if( thumbnailData ) { // use the default image - StorageManager.GetDefaultSaveThumbnail(ppbThumbnailData,pdwThumbnailSize); + DWORD defaultThumbnailSize = 0; + StorageManager.GetDefaultSaveThumbnail(thumbnailData, &defaultThumbnailSize); + if (thumbnailSize) + { + *thumbnailSize = static_cast(defaultThumbnailSize); + } } } if(m_SaveImageBuffer.Allocated()) { - if( ppbDataImage ) + if( saveImageData ) { - *ppbDataImage= new BYTE [m_SaveImageBuffer.GetBufferSize()]; - *pdwSizeImage=m_SaveImageBuffer.GetBufferSize(); - memcpy(*ppbDataImage,m_SaveImageBuffer.GetBufferPointer(),*pdwSizeImage); + *saveImageData = new std::uint8_t[m_SaveImageBuffer.GetBufferSize()]; + *saveImageSize = static_cast(m_SaveImageBuffer.GetBufferSize()); + memcpy(*saveImageData, m_SaveImageBuffer.GetBufferPointer(), *saveImageSize); } m_SaveImageBuffer.Release(); } else { - if( ppbDataImage ) + if( saveImageData ) { // use the default image - StorageManager.GetDefaultSaveImage(ppbDataImage,pdwSizeImage); + DWORD defaultSaveImageSize = 0; + StorageManager.GetDefaultSaveImage(saveImageData, &defaultSaveImageSize); + if (saveImageSize) + { + *saveImageSize = static_cast(defaultSaveImageSize); + } } } } @@ -255,7 +265,7 @@ void CConsoleMinecraftApp::ReleaseSaveThumbnail() } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } @@ -1669,4 +1679,4 @@ void CConsoleMinecraftApp::finishedDeletingSaves(bool bContinue) if (bContinue) m_bSaveDataDeleteDialogState = eSaveDataDeleteState_continue; else m_bSaveDataDeleteDialogState = eSaveDataDeleteState_abort; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/PSVita/PSVita_App.h b/Minecraft.Client/Platform/PSVita/PSVita_App.h index 24100436b..9c262dac3 100644 --- a/Minecraft.Client/Platform/PSVita/PSVita_App.h +++ b/Minecraft.Client/Platform/PSVita/PSVita_App.h @@ -70,10 +70,10 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*) {}; // NOT USED - virtual void GetSaveThumbnail(PBYTE *ppbThumbnailData,DWORD *pdwThumbnailSize,PBYTE *ppbDataImage,DWORD *pdwSizeImage); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) {}; // NOT USED + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize, std::uint8_t **saveImageData, unsigned int *saveImageSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt); diff --git a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h index 9ac5c55d1..51e79b098 100644 --- a/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h @@ -93,7 +93,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); @@ -109,7 +109,7 @@ public: // 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); + EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode); void GetText(uint16_t *UTF16String); // Online check strings against offensive list - TCR 92 @@ -126,8 +126,8 @@ public: // 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); + bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp index 2193aedc1..bc60aa486 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_App.cpp +++ b/Minecraft.Client/Platform/Windows64/Windows64_App.cpp @@ -37,14 +37,14 @@ void CConsoleMinecraftApp::FatalLoadError() void CConsoleMinecraftApp::CaptureSaveThumbnail() { } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) { } void CConsoleMinecraftApp::ReleaseSaveThumbnail() { } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { } diff --git a/Minecraft.Client/Platform/Windows64/Windows64_App.h b/Minecraft.Client/Platform/Windows64/Windows64_App.h index 39351d55b..f15afd928 100644 --- a/Minecraft.Client/Platform/Windows64/Windows64_App.h +++ b/Minecraft.Client/Platform/Windows64/Windows64_App.h @@ -12,9 +12,9 @@ public: virtual void FatalLoadError(); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile); virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt); diff --git a/Minecraft.Client/Platform/Xbox/4JLibs/inc/4J_Input.h b/Minecraft.Client/Platform/Xbox/4JLibs/inc/4J_Input.h index 120e9c7b5..e618d683d 100644 --- a/Minecraft.Client/Platform/Xbox/4JLibs/inc/4J_Input.h +++ b/Minecraft.Client/Platform/Xbox/4JLibs/inc/4J_Input.h @@ -84,7 +84,7 @@ public: 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 ); + void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam ); FLOAT GetIdleSeconds(int iPad); bool IsPadConnected(int iPad); @@ -116,8 +116,8 @@ public: // // 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); +bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); + void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam); void CancelAllVerifyInProgress(void); */ //bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput); diff --git a/Minecraft.Client/Platform/Xbox/Network/extra.h b/Minecraft.Client/Platform/Xbox/Network/extra.h index d09b18b7f..5965b9736 100644 --- a/Minecraft.Client/Platform/Xbox/Network/extra.h +++ b/Minecraft.Client/Platform/Xbox/Network/extra.h @@ -1,4 +1,8 @@ - #pragma once +#include +#include -const int MINECRAFT_NET_MAX_PLAYERS = 8; +constexpr int MINECRAFT_NET_MAX_PLAYERS = 8; + +static_assert(MINECRAFT_NET_MAX_PLAYERS <= std::numeric_limits::max(), + "MINECRAFT_NET_MAX_PLAYERS must fit in the 8-bit network protocol"); diff --git a/Minecraft.Client/Platform/Xbox/Social/SocialManager.cpp b/Minecraft.Client/Platform/Xbox/Social/SocialManager.cpp index f61292648..bbcfc7f11 100644 --- a/Minecraft.Client/Platform/Xbox/Social/SocialManager.cpp +++ b/Minecraft.Client/Platform/Xbox/Social/SocialManager.cpp @@ -459,8 +459,8 @@ bool CSocialManager::PostImageToSocialNetwork( ESocialNetwork eSocialNetwork, DW bool bResult = false; - PBYTE pbData=NULL; - DWORD dwDataSize; + std::uint8_t *pbData = NULL; + unsigned int dwDataSize = 0; app.GetScreenshot(dwUserIndex,&pbData,&dwDataSize); app.GetPreviewImage(dwUserIndex,&m_PostPreviewImage); diff --git a/Minecraft.Client/Platform/Xbox/Xbox_App.cpp b/Minecraft.Client/Platform/Xbox/Xbox_App.cpp index c55ef4806..86bb69123 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_App.cpp +++ b/Minecraft.Client/Platform/Xbox/Xbox_App.cpp @@ -1448,16 +1448,16 @@ void CConsoleMinecraftApp::CaptureSaveThumbnail() RenderManager.CaptureThumbnail(&m_ThumbnailBuffer); MemSect(0); } -void CConsoleMinecraftApp::GetSaveThumbnail(PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ThumbnailBuffer!=NULL) { - if( pbData ) + if( thumbnailData ) { - *pbData= new BYTE [m_ThumbnailBuffer->GetBufferSize()]; - *pdwSize=m_ThumbnailBuffer->GetBufferSize(); - memcpy(*pbData,m_ThumbnailBuffer->GetBufferPointer(),*pdwSize); + *thumbnailData = new std::uint8_t[m_ThumbnailBuffer->GetBufferSize()]; + *thumbnailSize = static_cast(m_ThumbnailBuffer->GetBufferSize()); + memcpy(*thumbnailData, m_ThumbnailBuffer->GetBufferPointer(), *thumbnailSize); } m_ThumbnailBuffer->Release(); m_ThumbnailBuffer=NULL; @@ -1472,14 +1472,14 @@ void CConsoleMinecraftApp::ReleaseSaveThumbnail() } } -void CConsoleMinecraftApp::GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize) +void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize) { // on a save caused by a create world, the thumbnail capture won't have happened if(m_ScreenshotBuffer[iPad]!=NULL) { - *pbData= new BYTE [m_ScreenshotBuffer[iPad]->GetBufferSize()]; - *pdwSize=m_ScreenshotBuffer[iPad]->GetBufferSize(); - memcpy(*pbData,m_ScreenshotBuffer[iPad]->GetBufferPointer(),*pdwSize); + *screenshotData = new std::uint8_t[m_ScreenshotBuffer[iPad]->GetBufferSize()]; + *screenshotSize = static_cast(m_ScreenshotBuffer[iPad]->GetBufferSize()); + memcpy(*screenshotData, m_ScreenshotBuffer[iPad]->GetBufferPointer(), *screenshotSize); m_ScreenshotBuffer[iPad]->Release(); m_ScreenshotBuffer[iPad]=NULL; } @@ -2959,9 +2959,9 @@ WCHAR CConsoleMinecraftApp::m_wchTMSXZP[] = L"file://UPDATE:/res/TMS/TMSFiles.xz #endif -void CConsoleMinecraftApp::GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ) +void CConsoleMinecraftApp::GetFileFromTPD(eTPDFileType eType, std::uint8_t *pbData, unsigned int dwBytes, std::uint8_t **ppbData, unsigned int *pdwBytes ) { - PBYTE pbPos=pbData; + std::uint8_t *pbPos=pbData; // icon is the second thing in the file if(pbData && dwBytes>0) { @@ -2973,15 +2973,15 @@ void CConsoleMinecraftApp::GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD if(eType==eTPDFileType_Loc) { *pdwBytes= uiDecompSize; - *ppbData = new BYTE [uiDecompSize]; + *ppbData = new std::uint8_t[uiDecompSize]; - Compression::getCompression()->Decompress(*ppbData,(UINT *)pdwBytes,&((unsigned int *)pbPos)[2],uiCompSize); + Compression::getCompression()->Decompress(*ppbData, pdwBytes, &((unsigned int *)pbPos)[2], uiCompSize); return; } else { // skip over the data - pbPos=(PBYTE)&((unsigned int *)pbPos)[2]; + pbPos=(std::uint8_t *)&((unsigned int *)pbPos)[2]; pbPos+=uiCompSize; } @@ -2992,15 +2992,15 @@ void CConsoleMinecraftApp::GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD if(eType==eTPDFileType_Icon) { *pdwBytes= uiDecompSize; - *ppbData = new BYTE [uiDecompSize]; + *ppbData = new std::uint8_t[uiDecompSize]; - Compression::getCompression()->Decompress(*ppbData,(UINT *)pdwBytes,&((unsigned int *)pbPos)[2],uiCompSize); + Compression::getCompression()->Decompress(*ppbData, pdwBytes, &((unsigned int *)pbPos)[2], uiCompSize); return; } else { // skip over the data - pbPos=(PBYTE)&((unsigned int *)pbPos)[2]; + pbPos=(std::uint8_t *)&((unsigned int *)pbPos)[2]; pbPos+=uiCompSize; } @@ -3011,9 +3011,9 @@ void CConsoleMinecraftApp::GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD if(eType==eTPDFileType_Comparison) { *pdwBytes= uiDecompSize; - *ppbData = new BYTE [uiDecompSize]; + *ppbData = new std::uint8_t[uiDecompSize]; - Compression::getCompression()->Decompress(*ppbData,(UINT *)pdwBytes,&((unsigned int *)pbPos)[2],uiCompSize); + Compression::getCompression()->Decompress(*ppbData, pdwBytes, &((unsigned int *)pbPos)[2], uiCompSize); return; } } diff --git a/Minecraft.Client/Platform/Xbox/Xbox_App.h b/Minecraft.Client/Platform/Xbox/Xbox_App.h index f64e71423..2884b9c5d 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_App.h +++ b/Minecraft.Client/Platform/Xbox/Xbox_App.h @@ -50,9 +50,9 @@ public: virtual void CaptureScreenshot(int iPad); virtual void CaptureSaveThumbnail(); - virtual void GetSaveThumbnail(PBYTE*,DWORD*); + virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize); virtual void ReleaseSaveThumbnail(); - virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize); + virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize); virtual void RunFrame(); @@ -185,7 +185,7 @@ public: static TMS_FILE TMSFileA[TMS_COUNT]; - virtual void GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ); + virtual void GetFileFromTPD(eTPDFileType eType, std::uint8_t *pbData, unsigned int dwBytes, std::uint8_t **ppbData, unsigned int *pdwBytes ); private: static WCHAR m_wchTMSXZP[]; @@ -194,4 +194,4 @@ private: }; -extern CConsoleMinecraftApp app; \ No newline at end of file +extern CConsoleMinecraftApp app; diff --git a/Minecraft.Client/Platform/Xbox/Xbox_UIController.cpp b/Minecraft.Client/Platform/Xbox/Xbox_UIController.cpp index 495dac0e0..ac15e4580 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_UIController.cpp +++ b/Minecraft.Client/Platform/Xbox/Xbox_UIController.cpp @@ -106,9 +106,9 @@ void ConsoleUIController::SetTooltipText( unsigned int iPad, unsigned int toolti CXuiSceneBase::SetTooltipText(iPad,tooltip,iTextID); } -void ConsoleUIController::SetEnableTooltips( unsigned int iPad, BOOL bVal ) +void ConsoleUIController::SetEnableTooltips( unsigned int iPad, bool bVal ) { - CXuiSceneBase::SetEnableTooltips(iPad,bVal); + CXuiSceneBase::SetEnableTooltips(iPad, bVal ? TRUE : FALSE); } void ConsoleUIController::ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ) @@ -313,13 +313,13 @@ void ConsoleUIController::SetWinUserIndex(unsigned int iPad) CScene_Win::setWinUserIndex( iPad ); } -C4JStorage::EMessageResult ConsoleUIController::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad, - int( *Func)(LPVOID,int,const C4JStorage::EMessageResult),LPVOID lpParam, CXuiStringTable *pStringTable, WCHAR *pwchFormatString,DWORD dwFocusButton,bool bIsError) +C4JStorage::EMessageResult ConsoleUIController::RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad, + int( *Func)(void *,int,const C4JStorage::EMessageResult), void *lpParam, CXuiStringTable *pStringTable, wchar_t *pwchFormatString, unsigned int dwFocusButton, bool bIsError) { return StorageManager.RequestMessageBox(uiTitle, uiText, uiOptionA, uiOptionC, dwPad, Func, lpParam, pStringTable, pwchFormatString, dwFocusButton); } -C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(UINT title/* = -1 */, UINT message/* = -1 */, int iPad/* = -1*/, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult)/* = NULL*/, LPVOID lpParam/* = NULL*/) +C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(int title/* = -1 */, int message/* = -1 */, int iPad/* = -1*/, int( *Func)(void *,int,const C4JStorage::EMessageResult)/* = NULL*/, void *lpParam/* = NULL*/) { // Default title / messages if (title == -1) @@ -335,7 +335,7 @@ C4JStorage::EMessageResult ConsoleUIController::RequestUGCMessageBox(UINT title/ // Default pad to primary player if (iPad == -1) iPad = ProfileManager.GetPrimaryPad(); - UINT uiIDA[1]; + unsigned int uiIDA[1]; uiIDA[0]=IDS_CONFIRM_OK; return ui.RequestMessageBox(title, message, uiIDA, 1, iPad, Func, lpParam, app.GetStringTable(), NULL, 0, false); -} \ No newline at end of file +} diff --git a/Minecraft.Client/Platform/Xbox/Xbox_UIController.h b/Minecraft.Client/Platform/Xbox/Xbox_UIController.h index 041306a75..3f7503513 100644 --- a/Minecraft.Client/Platform/Xbox/Xbox_UIController.h +++ b/Minecraft.Client/Platform/Xbox/Xbox_UIController.h @@ -28,7 +28,7 @@ public: virtual void AnimateKeyPress(int iPad, int dwKeyCode); virtual void SetTooltipText( unsigned int iPad, unsigned int tooltip, int iTextID ); - virtual void SetEnableTooltips( unsigned int iPad, BOOL bVal ); + virtual void SetEnableTooltips( unsigned int iPad, bool bVal ); virtual void ShowTooltip( unsigned int iPad, unsigned int tooltip, bool show ); virtual void SetTooltips( unsigned int iPad, int iA, int iB=-1, int iX=-1, int iY=-1 , int iLT=-1, int iRT=-1, int iLB=-1, int iRB=-1, int iLS=-1, bool forceUpdate = false); virtual void EnableTooltip( unsigned int iPad, unsigned int tooltip, bool enable ); @@ -70,10 +70,10 @@ public: virtual void SetWinUserIndex(unsigned int iPad); - virtual 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, CXuiStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0, bool bIsError = true); + virtual C4JStorage::EMessageResult RequestMessageBox(unsigned int uiTitle, unsigned int uiText, unsigned int *uiOptionA, unsigned int uiOptionC, unsigned int dwPad = XUSER_INDEX_ANY, + int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL, void *lpParam=NULL, CXuiStringTable *pStringTable=NULL, wchar_t *pwchFormatString=NULL, unsigned int dwFocusButton=0, bool bIsError = true); - C4JStorage::EMessageResult RequestUGCMessageBox(UINT title = -1, UINT message = -1, int iPad = -1, int( *Func)(LPVOID,int,const C4JStorage::EMessageResult) = NULL, LPVOID lpParam = NULL); + C4JStorage::EMessageResult RequestUGCMessageBox(int title = -1, int message = -1, int iPad = -1, int( *Func)(void *,int,const C4JStorage::EMessageResult) = NULL, void *lpParam = NULL); }; -extern ConsoleUIController ui; \ No newline at end of file +extern ConsoleUIController ui; diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index 91adb3300..3d8a38895 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -1143,12 +1143,12 @@ void LocalPlayer::onCrafted(std::shared_ptr item) } } -void LocalPlayer::setAndBroadcastCustomSkin(DWORD skinId) +void LocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { setCustomSkin(skinId); } -void LocalPlayer::setAndBroadcastCustomCape(DWORD capeId) +void LocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { setCustomCape(capeId); } @@ -1617,4 +1617,3 @@ void LocalPlayer::SetPlayerAdditionalModelParts(std::vectorpAdditio { m_pAdditionalModelParts=pAdditionalModelParts; } - diff --git a/Minecraft.Client/Player/LocalPlayer.h b/Minecraft.Client/Player/LocalPlayer.h index 3a70bd4b6..cb8b5dfa1 100644 --- a/Minecraft.Client/Player/LocalPlayer.h +++ b/Minecraft.Client/Player/LocalPlayer.h @@ -1,4 +1,5 @@ #pragma once +#include #include "../../Minecraft.World/Util/SmoothFloat.h" #include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h" #include "../../Minecraft.World/Util/Pos.h" @@ -161,8 +162,8 @@ public: // 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client virtual void onCrafted(std::shared_ptr item); - virtual void setAndBroadcastCustomSkin(DWORD skinId); - virtual void setAndBroadcastCustomCape(DWORD capeId); + virtual void setAndBroadcastCustomSkin(std::uint32_t skinId); + virtual void setAndBroadcastCustomCape(std::uint32_t capeId); private: bool isSolidBlock(int x, int y, int z); diff --git a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp index 2f6fae0e1..47ae79e61 100644 --- a/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp +++ b/Minecraft.Client/Player/MultiPlayerLocalPlayer.cpp @@ -348,9 +348,9 @@ void MultiplayerLocalPlayer::StopSleeping() } // 4J Added -void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(DWORD skinId) +void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { - DWORD oldSkinIndex = getCustomSkin(); + std::uint32_t oldSkinIndex = getCustomSkin(); LocalPlayer::setCustomSkin(skinId); #ifndef _CONTENT_PACKAGE wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() ); @@ -358,9 +358,9 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(DWORD skinId) if(getCustomSkin() != oldSkinIndex) connection->send( std::shared_ptr( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) ); } -void MultiplayerLocalPlayer::setAndBroadcastCustomCape(DWORD capeId) +void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { - DWORD oldCapeIndex = getCustomCape(); + std::uint32_t oldCapeIndex = getCustomCape(); LocalPlayer::setCustomCape(capeId); #ifndef _CONTENT_PACKAGE wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str()); diff --git a/Minecraft.Client/Player/MultiPlayerLocalPlayer.h b/Minecraft.Client/Player/MultiPlayerLocalPlayer.h index 54c6001da..ea66686c0 100644 --- a/Minecraft.Client/Player/MultiPlayerLocalPlayer.h +++ b/Minecraft.Client/Player/MultiPlayerLocalPlayer.h @@ -1,4 +1,5 @@ #pragma once +#include #include "LocalPlayer.h" #include "../../Minecraft.World/Util/SharedConstants.h" @@ -68,6 +69,6 @@ public: virtual void StopSleeping(); // 4J Added - virtual void setAndBroadcastCustomSkin(DWORD skinId); - virtual void setAndBroadcastCustomCape(DWORD capeId); + virtual void setAndBroadcastCustomSkin(std::uint32_t skinId); + virtual void setAndBroadcastCustomCape(std::uint32_t capeId); }; diff --git a/Minecraft.Client/Player/ServerPlayer.cpp b/Minecraft.Client/Player/ServerPlayer.cpp index 9f7081106..5de88dafe 100644 --- a/Minecraft.Client/Player/ServerPlayer.cpp +++ b/Minecraft.Client/Player/ServerPlayer.cpp @@ -1494,7 +1494,7 @@ int ServerPlayer::getPlayerViewDistanceModifier() if( player != NULL ) { - DWORD rtt = player->GetCurrentRtt(); + int rtt = player->GetCurrentRtt(); value = rtt >> 6; diff --git a/Minecraft.Client/Rendering/Chunk.cpp b/Minecraft.Client/Rendering/Chunk.cpp index a91477615..cbf5bb4a3 100644 --- a/Minecraft.Client/Rendering/Chunk.cpp +++ b/Minecraft.Client/Rendering/Chunk.cpp @@ -20,7 +20,7 @@ int Chunk::updates = 0; #ifdef _LARGE_WORLDS -DWORD Chunk::tlsIdx = TlsAlloc(); +unsigned int Chunk::tlsIdx = TlsAlloc(); void Chunk::CreateNewThreadStorage() { diff --git a/Minecraft.Client/Rendering/Chunk.h b/Minecraft.Client/Rendering/Chunk.h index 787fae4de..efcdfc914 100644 --- a/Minecraft.Client/Rendering/Chunk.h +++ b/Minecraft.Client/Rendering/Chunk.h @@ -32,7 +32,7 @@ private: #ifndef _LARGE_WORLDS static Tesselator *t; #else - static DWORD tlsIdx; + static unsigned int tlsIdx; public: static void CreateNewThreadStorage(); static void ReleaseThreadStorage(); diff --git a/Minecraft.Client/Rendering/EntityRenderers/SignRenderer.cpp b/Minecraft.Client/Rendering/EntityRenderers/SignRenderer.cpp index 9b8d5aa80..d49f23f17 100644 --- a/Minecraft.Client/Rendering/EntityRenderers/SignRenderer.cpp +++ b/Minecraft.Client/Rendering/EntityRenderers/SignRenderer.cpp @@ -63,7 +63,7 @@ void SignRenderer::render(std::shared_ptr _sign, double x, double y, std::wstring msg; // need to send the new data // Get the current language setting from the console - DWORD dwLanguage = XGetLanguage( ); + std::uint32_t dwLanguage = XGetLanguage( ); for (int i = 0; i < MAX_SIGN_LINES; i++) // 4J - was sign.messages.length { diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index b96c626e2..9f45d145c 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -57,7 +57,7 @@ C4JThread* GameRenderer::m_updateThread; C4JThread::EventArray* GameRenderer::m_updateEvents; bool GameRenderer::nearThingsToDo = false; bool GameRenderer::updateRunning = false; -std::vector GameRenderer::m_deleteStackByte; +std::vector GameRenderer::m_deleteStackByte; std::vector GameRenderer::m_deleteStackSparseLightStorage; std::vector GameRenderer::m_deleteStackCompressedTileStorage; std::vector GameRenderer::m_deleteStackSparseDataStorage; @@ -1134,7 +1134,7 @@ void GameRenderer::renderLevel(float a) #ifdef MULTITHREAD_ENABLE // Request that an item be deleted, when it is safe to do so -void GameRenderer::AddForDelete(uint8_t *deleteThis) +void GameRenderer::AddForDelete(std::uint8_t *deleteThis) { EnterCriticalSection(&m_csDeleteStack); m_deleteStackByte.push_back(deleteThis); @@ -1163,7 +1163,7 @@ void GameRenderer::FinishedReassigning() LeaveCriticalSection(&m_csDeleteStack); } -int GameRenderer::runUpdate(LPVOID lpParam) +int GameRenderer::runUpdate(void *lpParam) { Minecraft *minecraft = Minecraft::GetInstance(); Vec3::CreateNewThreadStorage(); @@ -1902,9 +1902,9 @@ void GameRenderer::setupClearColor(float a) { unsigned int colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Under_Water_Clear_Colour ); - uint8_t redComponent = ((colour>>16)&0xFF); - uint8_t greenComponent = ((colour>>8)&0xFF); - uint8_t blueComponent = ((colour)&0xFF); + std::uint8_t redComponent = ((colour>>16)&0xFF); + std::uint8_t greenComponent = ((colour>>8)&0xFF); + std::uint8_t blueComponent = ((colour)&0xFF); fr = (float)redComponent/256;//0.02f; fg = (float)greenComponent/256;//0.02f; @@ -1914,9 +1914,9 @@ void GameRenderer::setupClearColor(float a) { unsigned int colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Under_Lava_Clear_Colour ); - uint8_t redComponent = ((colour>>16)&0xFF); - uint8_t greenComponent = ((colour>>8)&0xFF); - uint8_t blueComponent = ((colour)&0xFF); + std::uint8_t redComponent = ((colour>>16)&0xFF); + std::uint8_t greenComponent = ((colour>>8)&0xFF); + std::uint8_t blueComponent = ((colour)&0xFF); fr = (float)redComponent/256;//0.6f; fg = (float)greenComponent/256;//0.1f; @@ -2058,9 +2058,9 @@ void GameRenderer::setupFog(int i, float alpha) glFogf(GL_FOG_DENSITY, 0.1f); // was 0.06 unsigned int colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_In_Cloud_Fog_Colour ); - uint8_t redComponent = ((colour>>16)&0xFF); - uint8_t greenComponent = ((colour>>8)&0xFF); - uint8_t blueComponent = ((colour)&0xFF); + std::uint8_t redComponent = ((colour>>16)&0xFF); + std::uint8_t greenComponent = ((colour>>8)&0xFF); + std::uint8_t blueComponent = ((colour)&0xFF); float rr = (float)redComponent/256;//1.0f; float gg = (float)greenComponent/256;//1.0f; @@ -2090,9 +2090,9 @@ void GameRenderer::setupFog(int i, float alpha) } unsigned int colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Under_Water_Fog_Colour ); - uint8_t redComponent = ((colour>>16)&0xFF); - uint8_t greenComponent = ((colour>>8)&0xFF); - uint8_t blueComponent = ((colour)&0xFF); + std::uint8_t redComponent = ((colour>>16)&0xFF); + std::uint8_t greenComponent = ((colour>>8)&0xFF); + std::uint8_t blueComponent = ((colour)&0xFF); float rr = (float)redComponent/256;//0.4f; float gg = (float)greenComponent/256;//0.4f; @@ -2115,9 +2115,9 @@ void GameRenderer::setupFog(int i, float alpha) glFogf(GL_FOG_DENSITY, 2.0f); // was 0.06 unsigned int colour = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Under_Lava_Fog_Colour ); - uint8_t redComponent = ((colour>>16)&0xFF); - uint8_t greenComponent = ((colour>>8)&0xFF); - uint8_t blueComponent = ((colour)&0xFF); + std::uint8_t redComponent = ((colour>>16)&0xFF); + std::uint8_t greenComponent = ((colour>>8)&0xFF); + std::uint8_t blueComponent = ((colour)&0xFF); float rr = (float)redComponent/256;//0.4f; float gg = (float)greenComponent/256;//0.3f; diff --git a/Minecraft.Client/Rendering/GameRenderer.h b/Minecraft.Client/Rendering/GameRenderer.h index f5cdedecc..eec06278e 100644 --- a/Minecraft.Client/Rendering/GameRenderer.h +++ b/Minecraft.Client/Rendering/GameRenderer.h @@ -145,7 +145,7 @@ public: #ifdef MULTITHREAD_ENABLE static C4JThread* m_updateThread; - static int runUpdate(LPVOID lpParam); + static int runUpdate(void *lpParam); static C4JThread::EventArray* m_updateEvents; enum EUpdateEvents { @@ -156,12 +156,12 @@ public: static bool nearThingsToDo; static bool updateRunning; #endif - static std::vector m_deleteStackByte; + static std::vector m_deleteStackByte; static std::vector m_deleteStackSparseLightStorage; static std::vector m_deleteStackCompressedTileStorage; static std::vector m_deleteStackSparseDataStorage; static CRITICAL_SECTION m_csDeleteStack; - static void AddForDelete(uint8_t *deleteThis); + static void AddForDelete(std::uint8_t *deleteThis); static void AddForDelete(SparseLightStorage *deleteThis); static void AddForDelete(CompressedTileStorage *deleteThis); static void AddForDelete(SparseDataStorage *deleteThis); diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index a3ab7aba3..5ddc7b60a 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -3629,7 +3629,7 @@ void LevelRenderer::staticCtor() } } -int LevelRenderer::rebuildChunkThreadProc(LPVOID lpParam) +int LevelRenderer::rebuildChunkThreadProc(void *lpParam) { Vec3::CreateNewThreadStorage(); AABB::CreateNewThreadStorage(); diff --git a/Minecraft.Client/Rendering/LevelRenderer.h b/Minecraft.Client/Rendering/LevelRenderer.h index 32941711d..65a82d4be 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.h +++ b/Minecraft.Client/Rendering/LevelRenderer.h @@ -271,7 +271,7 @@ public: static C4JThread::EventArray *s_rebuildCompleteEvents; static C4JThread::Event *s_activationEventA[MAX_CHUNK_REBUILD_THREADS]; static void staticCtor(); - static int rebuildChunkThreadProc(LPVOID lpParam); + static int rebuildChunkThreadProc(void *lpParam); CRITICAL_SECTION m_csChunkFlags; #endif diff --git a/Minecraft.Client/Rendering/Tesselator.cpp b/Minecraft.Client/Rendering/Tesselator.cpp index fafea37ef..517c8a61d 100644 --- a/Minecraft.Client/Rendering/Tesselator.cpp +++ b/Minecraft.Client/Rendering/Tesselator.cpp @@ -24,7 +24,7 @@ int normal; */ -DWORD Tesselator::tlsIdx = TlsAlloc(); +unsigned int Tesselator::tlsIdx = TlsAlloc(); Tesselator *Tesselator::getInstance() { @@ -329,7 +329,7 @@ void Tesselator::color(int r, int g, int b, int a) col = (r << 24) | (g << 16) | (b << 8) | (a); } -void Tesselator::color(uint8_t r, uint8_t g, uint8_t b) +void Tesselator::color(std::uint8_t r, std::uint8_t g, std::uint8_t b) { color(r & 0xff, g & 0xff, b & 0xff); } @@ -510,16 +510,16 @@ void Tesselator::tileQuad(float x1, float y1, float z1, float u1, float v1, floa count+=4; // AP - alpha cut out is expensive on vita. This will choose the correct data buffer depending on cut out enabled - int16_t* pShortData; + std::int16_t* pShortData; if( !alphaCutOutEnabled ) { - pShortData = (int16_t*)&_array->data[p]; + pShortData = (std::int16_t*)&_array->data[p]; p += 16; vertices+=4; } else { - pShortData = (int16_t*)&_array2->data[p2]; + pShortData = (std::int16_t*)&_array2->data[p2]; p2 += 16; vertices2+=4; } @@ -784,25 +784,25 @@ void Tesselator::vertex(float x, float y, float z) #ifdef __PSVITA__ // AP - alpha cut out is expensive on vita. This will choose the correct data buffer depending on cut out enabled - int16_t* pShortData; + std::int16_t* pShortData; if( !alphaCutOutEnabled ) { - pShortData = (int16_t*)&_array->data[p]; + pShortData = (std::int16_t*)&_array->data[p]; } else { - pShortData = (int16_t*)&_array2->data[p2]; + pShortData = (std::int16_t*)&_array2->data[p2]; } #else - int16_t* pShortData = (int16_t*)&_array->data[p]; + std::int16_t* pShortData = (std::int16_t*)&_array->data[p]; #endif #ifdef __PS3__ - float tex2U = ((int16_t*)&_tex2)[1] + 8; - float tex2V = ((int16_t*)&_tex2)[0] + 8; + float tex2U = ((std::int16_t*)&_tex2)[1] + 8; + float tex2V = ((std::int16_t*)&_tex2)[0] + 8; float colVal1 = ((col&0xff000000)>>24)/256.0f; float colVal2 = ((col&0x00ff0000)>>16)/256.0f; float colVal3 = ((col&0x0000ff00)>>8)/256.0f; @@ -833,8 +833,8 @@ void Tesselator::vertex(float x, float y, float z) pShortData[3] = ipackedcol; pShortData[4] = (((int)(uu * 8192.0f))&0xffff); pShortData[5] = (((int)(v * 8192.0f))&0xffff); - int16_t u2 = ((int16_t*)&_tex2)[0]; - int16_t v2 = ((int16_t*)&_tex2)[1]; + std::int16_t u2 = ((std::int16_t*)&_tex2)[0]; + std::int16_t v2 = ((std::int16_t*)&_tex2)[1]; #if defined _XBOX_ONE || defined __ORBIS__ // Optimisation - pack the second UVs into a single short (they could actually go in a byte), which frees up a short to store the x offset for this chunk in the vertex itself. // This means that when rendering chunks, we don't need to update the vertex constants that specify the location for a chunk, when only the x offset has changed. @@ -945,13 +945,13 @@ void Tesselator::vertex(float x, float y, float z) // 4jcraft: we will be lighting the blocks right in here #if defined(__PS3__) || defined (__linux__) #ifdef __PS3__ - int16_t tex2U = ((int16_t*)&_tex2)[1] + 8; - int16_t tex2V = ((int16_t*)&_tex2)[0] + 8; + std::int16_t tex2U = ((std::int16_t*)&_tex2)[1] + 8; + std::int16_t tex2V = ((std::int16_t*)&_tex2)[0] + 8; #else - int16_t tex2U = ((int16_t*)&_tex2)[0] + 8; - int16_t tex2V = ((int16_t*)&_tex2)[1] + 8; + std::int16_t tex2U = ((std::int16_t*)&_tex2)[0] + 8; + std::int16_t tex2V = ((std::int16_t*)&_tex2)[1] + 8; #endif - int16_t* pShortArray = (int16_t*)&_array->data[p + 7]; + std::int16_t* pShortArray = (std::int16_t*)&_array->data[p + 7]; pShortArray[0] = tex2U; pShortArray[1] = tex2V; #else @@ -1003,7 +1003,7 @@ void Tesselator::noColor() } #ifdef __PS3__ -uint32_t _ConvertF32toX11Y11Z10N(float x, float y, float z) +std::uint32_t _ConvertF32toX11Y11Z10N(float x, float y, float z) { // 11111111111 X 0x000007FF // 1111111111100000000000 Y 0x003FF800 @@ -1028,10 +1028,10 @@ uint32_t _ConvertF32toX11Y11Z10N(float x, float y, float z) if (z<-1.0f || z>1.0f) { printf("Value (%5.3f) should be in range [-1..1]. Conversion will clamp to X11Y11Z10N.\n", z); } #endif - const uint32_t uX = ((int32_t(std::max(std::min(((x)*2047.f - 1.f)*0.5f, 1023.f), -1024.f)) & (X11Y11Z10N_X_MASK >> X11Y11Z10N_X_SHIFT)) << X11Y11Z10N_X_SHIFT); - const uint32_t uY = ((int32_t(std::max(std::min(((y)*2047.f - 1.f)*0.5f, 1023.f), -1024.f)) & (X11Y11Z10N_Y_MASK >> X11Y11Z10N_Y_SHIFT)) << X11Y11Z10N_Y_SHIFT); - const uint32_t uZ = ((int32_t(std::max(std::min(((z)*1023.f - 1.f)*0.5f, 511.f), -512.f )) & (X11Y11Z10N_Z_MASK >> X11Y11Z10N_Z_SHIFT)) << X11Y11Z10N_Z_SHIFT); - const uint32_t xyz = uX | uY | uZ; + const std::uint32_t uX = ((std::int32_t(std::max(std::min(((x)*2047.f - 1.f)*0.5f, 1023.f), -1024.f)) & (X11Y11Z10N_X_MASK >> X11Y11Z10N_X_SHIFT)) << X11Y11Z10N_X_SHIFT); + const std::uint32_t uY = ((std::int32_t(std::max(std::min(((y)*2047.f - 1.f)*0.5f, 1023.f), -1024.f)) & (X11Y11Z10N_Y_MASK >> X11Y11Z10N_Y_SHIFT)) << X11Y11Z10N_Y_SHIFT); + const std::uint32_t uZ = ((std::int32_t(std::max(std::min(((z)*1023.f - 1.f)*0.5f, 511.f), -512.f )) & (X11Y11Z10N_Z_MASK >> X11Y11Z10N_Z_SHIFT)) << X11Y11Z10N_Z_SHIFT); + const std::uint32_t xyz = uX | uY | uZ; return xyz; } #endif // __PS3__ @@ -1044,15 +1044,15 @@ void Tesselator::normal(float x, float y, float z) _normal = _ConvertF32toX11Y11Z10N(x,y,z); #elif __PSVITA__ // AP - casting a negative value to 'byte' on Vita results in zero. changed to a signed 8 value - int8_t xx = (int8_t) (x * 127); - int8_t yy = (int8_t) (y * 127); - int8_t zz = (int8_t) (z * 127); + std::int8_t xx = (std::int8_t) (x * 127); + std::int8_t yy = (std::int8_t) (y * 127); + std::int8_t zz = (std::int8_t) (z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #else // 4jcraft copied the PSVITA branch, read comment above - int8_t xx = (int8_t) (x * 127); - int8_t yy = (int8_t) (y * 127); - int8_t zz = (int8_t) (z * 127); + std::int8_t xx = (std::int8_t) (x * 127); + std::int8_t yy = (std::int8_t) (y * 127); + std::int8_t zz = (std::int8_t) (z * 127); _normal = (xx & 0xff) | ((yy & 0xff) << 8) | ((zz & 0xff) << 16); #endif } diff --git a/Minecraft.Client/Rendering/Tesselator.h b/Minecraft.Client/Rendering/Tesselator.h index 6c0f30a23..eefeaa73a 100644 --- a/Minecraft.Client/Rendering/Tesselator.h +++ b/Minecraft.Client/Rendering/Tesselator.h @@ -38,7 +38,7 @@ private: public: static void CreateNewThreadStorage(int bytes); private: - static DWORD tlsIdx; + static unsigned int tlsIdx; public: static Tesselator *getInstance(); @@ -138,7 +138,7 @@ public: void color(float r, float g, float b, float a); void color(int r, int g, int b); void color(int r, int g, int b, int a); - void color(uint8_t r, uint8_t g, uint8_t b); + void color(std::uint8_t r, std::uint8_t g, std::uint8_t b); void vertexUV(float x, float y, float z, float u, float v); void vertex(float x, float y, float z); void color(int c); diff --git a/Minecraft.Client/Textures/BufferedImage.cpp b/Minecraft.Client/Textures/BufferedImage.cpp index cf64c2e3f..d8065851f 100644 --- a/Minecraft.Client/Textures/BufferedImage.cpp +++ b/Minecraft.Client/Textures/BufferedImage.cpp @@ -193,8 +193,8 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const std::wstring& File, bool fi { HRESULT hr; std::wstring filePath = File; - BYTE *pbData = NULL; - DWORD dwBytes = 0; + std::uint8_t *pbData = NULL; + std::uint32_t dataBytes = 0; for( int l = 0 ; l < 10; l++ ) { @@ -229,8 +229,8 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const std::wstring& File, bool fi } DLCFile *dlcFile = dlcPack->getFile(DLCManager::e_DLCType_All, name); - pbData = dlcFile->getData(dwBytes); - if(pbData == NULL || dwBytes == 0) + pbData = dlcFile->getData(dataBytes); + if(pbData == NULL || dataBytes == 0) { // 4J - If we haven't loaded the non-mipmap version then exit the game if( l == 0 ) @@ -242,7 +242,7 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const std::wstring& File, bool fi D3DXIMAGE_INFO ImageInfo; ZeroMemory(&ImageInfo,sizeof(D3DXIMAGE_INFO)); - hr=RenderManager.LoadTextureData(pbData,dwBytes,&ImageInfo,&data[l]); + hr=RenderManager.LoadTextureData(pbData,dataBytes,&ImageInfo,&data[l]); if(hr!=ERROR_SUCCESS) @@ -264,7 +264,7 @@ BufferedImage::BufferedImage(DLCPack *dlcPack, const std::wstring& File, bool fi } -BufferedImage::BufferedImage(BYTE *pbData, DWORD dwBytes) +BufferedImage::BufferedImage(std::uint8_t *pbData, std::uint32_t dataBytes) { int iCurrentByte=0; for( int l = 0 ; l < 10; l++ ) @@ -274,7 +274,7 @@ BufferedImage::BufferedImage(BYTE *pbData, DWORD dwBytes) D3DXIMAGE_INFO ImageInfo; ZeroMemory(&ImageInfo,sizeof(D3DXIMAGE_INFO)); - HRESULT hr=RenderManager.LoadTextureData(pbData,dwBytes,&ImageInfo,&data[0]); + HRESULT hr=RenderManager.LoadTextureData(pbData,dataBytes,&ImageInfo,&data[0]); if(hr==ERROR_SUCCESS) { diff --git a/Minecraft.Client/Textures/BufferedImage.h b/Minecraft.Client/Textures/BufferedImage.h index 026c457a7..94ffe0576 100644 --- a/Minecraft.Client/Textures/BufferedImage.h +++ b/Minecraft.Client/Textures/BufferedImage.h @@ -1,4 +1,5 @@ #pragma once +#include class Graphics; @@ -17,7 +18,7 @@ public: BufferedImage(int width,int height,int type); BufferedImage(const std::wstring& File, bool filenameHasExtension = false, bool bTitleUpdateTexture=false, const std::wstring &drive =L""); // 4J added BufferedImage(DLCPack *dlcPack, const std::wstring& File, bool filenameHasExtension = false ); // 4J Added - BufferedImage(BYTE *pbData, DWORD dwBytes); // 4J added + BufferedImage(std::uint8_t *pbData, std::uint32_t dataBytes); // 4J added ~BufferedImage(); int getWidth(); @@ -30,4 +31,4 @@ public: BufferedImage *getSubimage(int x, int y, int w, int h); void preMultiplyAlpha(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Textures/MemTexture.cpp b/Minecraft.Client/Textures/MemTexture.cpp index 343aa48a3..e243a94ce 100644 --- a/Minecraft.Client/Textures/MemTexture.cpp +++ b/Minecraft.Client/Textures/MemTexture.cpp @@ -1,7 +1,7 @@ #include "../Platform/stdafx.h" #include "MemTexture.h" -MemTexture::MemTexture(const std::wstring& _url, PBYTE pbData,DWORD dwBytes, MemTextureProcessor *processor) +MemTexture::MemTexture(const std::wstring& _url, std::uint8_t *pbData, std::uint32_t dataBytes, MemTextureProcessor *processor) { // 4J - added count = 1; @@ -14,7 +14,7 @@ MemTexture::MemTexture(const std::wstring& _url, PBYTE pbData,DWORD dwBytes, Mem // load the texture, and process it //loadedImage=Textures::getTexture() // 4J - remember to add deletes in here for any created BufferedImages when implemented - loadedImage = new BufferedImage(pbData,dwBytes); + loadedImage = new BufferedImage(pbData,dataBytes); if(processor==NULL) { @@ -30,4 +30,4 @@ MemTexture::MemTexture(const std::wstring& _url, PBYTE pbData,DWORD dwBytes, Mem MemTexture::~MemTexture() { delete loadedImage; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/MemTexture.h b/Minecraft.Client/Textures/MemTexture.h index e3f6b6bf7..d8c9c4d1a 100644 --- a/Minecraft.Client/Textures/MemTexture.h +++ b/Minecraft.Client/Textures/MemTexture.h @@ -1,4 +1,5 @@ #pragma once +#include class BufferedImage; class MemTextureProcessor; @@ -12,6 +13,6 @@ public: int ticksSinceLastUse; static const int UNUSED_TICKS_TO_FREE = 20; - MemTexture(const std::wstring& _name, PBYTE pbData, DWORD dwBytes, MemTextureProcessor *processor); + MemTexture(const std::wstring& _name, std::uint8_t *pbData, std::uint32_t dataBytes, MemTextureProcessor *processor); ~MemTexture(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp index 56739429d..8821e6068 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.cpp @@ -4,7 +4,9 @@ #include "../../../Minecraft.World/IO/Streams/InputOutputStream.h" #include "../../../Minecraft.World/Util/StringHelpers.h" -AbstractTexturePack::AbstractTexturePack(DWORD id, File *file, const std::wstring &name, TexturePack *fallback) : id(id), name(name) +#include + +AbstractTexturePack::AbstractTexturePack(std::uint32_t id, File *file, const std::wstring &name, TexturePack *fallback) : id(id), name(name) { // 4J init textureId = -1; @@ -38,15 +40,15 @@ void AbstractTexturePack::loadIcon() { #ifdef _XBOX // 4J Stu - Temporary only - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png"); - UINT size = 0; + unsigned int size = 0; HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_iconData, &size); - m_iconSize = size; + m_iconSize = static_cast(size); #endif } @@ -54,15 +56,15 @@ void AbstractTexturePack::loadComparison() { #ifdef _XBOX // 4J Stu - Temporary only - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/DefaultPack_Comparison.png"); - UINT size = 0; + unsigned int size = 0; HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_comparisonData, &size); - m_comparisonSize = size; + m_comparisonSize = static_cast(size); #endif } @@ -152,7 +154,7 @@ bool AbstractTexturePack::hasFile(const std::wstring &name, bool allowFallback) return !hasFile && (allowFallback && fallback != NULL) ? fallback->hasFile(name, allowFallback) : hasFile; } -DWORD AbstractTexturePack::getId() +std::uint32_t AbstractTexturePack::getId() { return id; } @@ -230,7 +232,7 @@ void AbstractTexturePack::loadDefaultUI() const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); // Load new skin - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/skin_Minecraft.xur"); @@ -257,14 +259,22 @@ void AbstractTexturePack::loadDefaultColourTable() if(coloursFile.exists()) { - DWORD dwLength = coloursFile.length(); - byteArray data(dwLength); + const __int64 colourTableLength = coloursFile.length(); + if(colourTableLength < 0 || colourTableLength > static_cast<__int64>(std::numeric_limits::max())) + { + app.DebugPrintf("Failed to load the default colours table\n"); + app.FatalLoadError(); + return; + } + + const unsigned int dataLength = static_cast(colourTableLength); + byteArray data(dataLength); FileInputStream fis(coloursFile); - fis.read(data,0,dwLength); + fis.read(data,0,dataLength); fis.close(); if(m_colourTable != NULL) delete m_colourTable; - m_colourTable = new ColourTable(data.data, dwLength); + m_colourTable = new ColourTable(data.data, dataLength); delete [] data.data; } @@ -281,13 +291,13 @@ void AbstractTexturePack::loadDefaultHTMLColourTable() // load from the .xzp file const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; // Try and load the HTMLColours.col based off the common XML first, before the deprecated xuiscene_colourtable wsprintfW(szResourceLocator,L"section://%X,%s#%s",c_ModuleHandle,L"media", L"media/HTMLColours.col"); - BYTE *data; - UINT dataLength; + std::uint8_t *data; + unsigned int dataLength; if(XuiResourceLoadAll(szResourceLocator, &data, &dataLength) == S_OK) { m_colourTable->loadColoursFromData(data,dataLength); @@ -366,25 +376,25 @@ std::wstring AbstractTexturePack::getXuiRootPath() const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); // Load new skin - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/"); return szResourceLocator; } -PBYTE AbstractTexturePack::getPackIcon(DWORD &dwImageBytes) +std::uint8_t *AbstractTexturePack::getPackIcon(std::uint32_t &imageBytes) { if(m_iconSize == 0 || m_iconData == NULL) loadIcon(); - dwImageBytes = m_iconSize; + imageBytes = m_iconSize; return m_iconData; } -PBYTE AbstractTexturePack::getPackComparison(DWORD &dwImageBytes) +std::uint8_t *AbstractTexturePack::getPackComparison(std::uint32_t &imageBytes) { if(m_comparisonSize == 0 || m_comparisonData == NULL) loadComparison(); - dwImageBytes = m_comparisonSize; + imageBytes = m_comparisonSize; return m_comparisonData; } @@ -396,4 +406,4 @@ unsigned int AbstractTexturePack::getDLCParentPackId() unsigned char AbstractTexturePack::getDLCSubPackId() { return 0; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h index c861a88c0..d9cbd8222 100644 --- a/Minecraft.Client/Textures/Packs/AbstractTexturePack.h +++ b/Minecraft.Client/Textures/Packs/AbstractTexturePack.h @@ -8,7 +8,7 @@ class BufferedImage; class AbstractTexturePack : public TexturePack { private: - const DWORD id; + const std::uint32_t id; const std::wstring name; protected: @@ -19,11 +19,11 @@ protected: std::wstring desc1; std::wstring desc2; - PBYTE m_iconData; - DWORD m_iconSize; + std::uint8_t *m_iconData; + std::uint32_t m_iconSize; - PBYTE m_comparisonData; - DWORD m_comparisonSize; + std::uint8_t *m_comparisonData; + std::uint32_t m_comparisonSize; TexturePack *fallback; @@ -36,7 +36,7 @@ private: int textureId; protected: - AbstractTexturePack(DWORD id, File *file, const std::wstring &name, TexturePack *fallback); + AbstractTexturePack(std::uint32_t id, File *file, const std::wstring &name, TexturePack *fallback); private: static std::wstring trim(std::wstring line); @@ -61,7 +61,7 @@ public: virtual void load(Textures *textures); virtual bool hasFile(const std::wstring &name, bool allowFallback); virtual bool hasFile(const std::wstring &name) = 0; - virtual DWORD getId(); + virtual std::uint32_t getId(); virtual std::wstring getName(); virtual std::wstring getDesc1(); virtual std::wstring getDesc2(); @@ -84,8 +84,8 @@ public: virtual void loadUI(); virtual void unloadUI(); virtual std::wstring getXuiRootPath(); - virtual PBYTE getPackIcon(DWORD &dwImageBytes); - virtual PBYTE getPackComparison(DWORD &dwImageBytes); + virtual std::uint8_t *getPackIcon(std::uint32_t &imageBytes); + virtual std::uint8_t *getPackComparison(std::uint32_t &imageBytes); virtual unsigned int getDLCParentPackId(); virtual unsigned char getDLCSubPackId(); virtual ColourTable *getColourTable() { return m_colourTable; } diff --git a/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp index 3519b038c..4d56cf46e 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.cpp @@ -8,15 +8,49 @@ #include "../../Platform/Common/DLC/DLCTextureFile.h" #include "../../Platform/Common/DLC/DLCLocalisationFile.h" #include "../../../Minecraft.World/Util/StringHelpers.h" +#include "../../../Minecraft.World/Util/PortableFileIO.h" #include "../../Utils/StringTable.h" #include "../../Platform/Common/DLC/DLCAudioFile.h" +#include +#include + #if defined _XBOX || defined _WINDOWS64 #include "../../Platform/Xbox/XML/ATGXmlParser.h" #include "../../Platform/Xbox/XML/xmlFilesCallback.h" #endif -DLCTexturePack::DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, NULL, pack->getName(), fallback) +namespace +{ + bool ReadPortableBinaryFile(File &file, std::uint8_t *&data, unsigned int &size) + { + const __int64 fileLength = file.length(); + if (fileLength < 0 || fileLength > static_cast<__int64>(std::numeric_limits::max())) + { + data = NULL; + size = 0; + return false; + } + + const std::size_t capacity = static_cast(fileLength); + std::uint8_t *buffer = new std::uint8_t[capacity == 0 ? 1 : capacity]; + const PortableFileIO::BinaryReadResult readResult = PortableFileIO::ReadBinaryFile(file.getPath(), buffer, capacity); + if (readResult.status != PortableFileIO::BinaryReadStatus::ok + || readResult.fileSize > std::numeric_limits::max()) + { + delete [] buffer; + data = NULL; + size = 0; + return false; + } + + data = buffer; + size = static_cast(readResult.fileSize); + return true; + } +} + +DLCTexturePack::DLCTexturePack(std::uint32_t id, DLCPack *pack, TexturePack *fallback) : AbstractTexturePack(id, NULL, pack->getName(), fallback) { m_dlcInfoPack = pack; m_dlcDataPack = NULL; @@ -52,7 +86,9 @@ void DLCTexturePack::loadIcon() if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_Texture, L"icon.png")) { DLCTextureFile *textureFile = (DLCTextureFile *)m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"icon.png"); - m_iconData = textureFile->getData(m_iconSize); + std::uint32_t iconSize = 0; + m_iconData = textureFile->getData(iconSize); + m_iconSize = iconSize; } else { @@ -65,7 +101,9 @@ void DLCTexturePack::loadComparison() if(m_dlcInfoPack->doesPackContainFile(DLCManager::e_DLCType_Texture, L"comparison.png")) { DLCTextureFile *textureFile = (DLCTextureFile *)m_dlcInfoPack->getFile(DLCManager::e_DLCType_Texture, L"comparison.png"); - m_comparisonData = textureFile->getData(m_comparisonSize); + std::uint32_t comparisonSize = 0; + m_comparisonData = textureFile->getData(comparisonSize); + m_comparisonSize = comparisonSize; } } @@ -184,16 +222,16 @@ void DLCTexturePack::loadColourTable() { DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); - DWORD dwSize = 0; - PBYTE pbData = dataFile->getData(dwSize); + std::uint32_t dwSize = 0; + std::uint8_t *pbData = dataFile->getData(dwSize); - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; // Try and load the HTMLColours.col based off the common XML first, before the deprecated xuiscene_colourtable swprintf(szResourceLocator, LOCATOR_SIZE,L"memory://%08X,%04X#HTMLColours.col",pbData, dwSize); - BYTE *data; - UINT dataLength; + std::uint8_t *data; + unsigned int dataLength; if(XuiResourceLoadAll(szResourceLocator, &data, &dataLength) == S_OK) { m_colourTable->loadColoursFromData(data,dataLength); @@ -267,26 +305,26 @@ void DLCTexturePack::loadData() -std::wstring DLCTexturePack::getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder) +std::wstring DLCTexturePack::getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder) { return app.getFilePath(packId,filename,bAddDataFolder); } -int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask) +int DLCTexturePack::packMounted(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask) { - DLCTexturePack *texturePack = (DLCTexturePack *)pParam; + DLCTexturePack *texturePack = static_cast(pParam); texturePack->m_bLoadingData = false; if(dwErr!=ERROR_SUCCESS) { // corrupt DLC - app.DebugPrintf("Failed to mount DLC for pad %d: %d\n",iPad,dwErr); + app.DebugPrintf("Failed to mount DLC for pad %d: %u\n",iPad,dwErr); } else { app.DebugPrintf("Mounted DLC for texture pack, attempting to load data\n"); texturePack->m_dlcDataPack = new DLCPack(texturePack->m_dlcInfoPack->getName(), dwLicenceMask); texturePack->setHasAudio(false); - DWORD dwFilesProcessed = 0; + unsigned int dwFilesProcessed = 0; // Load the DLC textures std::wstring dataFilePath = texturePack->m_dlcInfoPack->getFullDataPath(); if(!dataFilePath.empty()) @@ -305,30 +343,12 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen if(xzpPath.exists()) { - const char *pchFilename=wstringtofilename(xzpPath.getPath()); - HANDLE fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); - - if( fileHandle != INVALID_HANDLE_VALUE ) + std::uint8_t *pbData = NULL; + unsigned int bytesRead = 0; + if( ReadPortableBinaryFile(xzpPath, pbData, bytesRead) ) { - DWORD dwFileSize = xzpPath.length(); - DWORD bytesRead; - PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL success = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); - CloseHandle(fileHandle); - if(success) - { - DLCUIDataFile *uiDLCFile = (DLCUIDataFile *)texturePack->m_dlcDataPack->addFile(DLCManager::e_DLCType_UIData,L"TexturePack.xzp"); - uiDLCFile->addData(pbData,bytesRead,true); - - } + DLCUIDataFile *uiDLCFile = (DLCUIDataFile *)texturePack->m_dlcDataPack->addFile(DLCManager::e_DLCType_UIData,L"TexturePack.xzp"); + uiDLCFile->addData(pbData,bytesRead,true); } } #else @@ -354,50 +374,21 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen File grf( getFilePath(texturePack->m_dlcInfoPack->GetPackID(), dlcFile->getGrfPath() ) ); if (grf.exists()) { -#if defined(_UNICODE) && !defined(__linux__) - std::wstring path = grf.getPath(); - const WCHAR *pchFilename=path.c_str(); - HANDLE fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); -#else - const char *pchFilename=wstringtofilename(grf.getPath()); - HANDLE fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); -#endif - - if( fileHandle != INVALID_HANDLE_VALUE ) + std::uint8_t *pbData = NULL; + unsigned int fileSize = 0; + if( ReadPortableBinaryFile(grf, pbData, fileSize) ) { - DWORD dwFileSize = grf.length(); - DWORD bytesRead; - PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - CloseHandle(fileHandle); - // 4J-PB - is it possible that we can get here after a read fail and it's not an error? - dlcFile->setGrfData(pbData, dwFileSize, texturePack->m_stringTable); + dlcFile->setGrfData(pbData, fileSize, texturePack->m_stringTable); delete [] pbData; app.m_gameRules.setLevelGenerationOptions( dlcFile->lgo ); } + else + { + app.FatalLoadError(); + } } } } @@ -406,44 +397,16 @@ int DLCTexturePack::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicen File grf(getFilePath(texturePack->m_dlcInfoPack->GetPackID(), levelGen->getBaseSavePath() )); if (grf.exists()) { -#if defined(_UNICODE) && !defined(__linux__) - std::wstring path = grf.getPath(); - const WCHAR *pchFilename=path.c_str(); - HANDLE fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); -#else - const char *pchFilename=wstringtofilename(grf.getPath()); - HANDLE fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); -#endif - - if( fileHandle != INVALID_HANDLE_VALUE ) + std::uint8_t *pbData = NULL; + unsigned int fileSize = 0; + if( ReadPortableBinaryFile(grf, pbData, fileSize) ) { - DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,NULL); - PBYTE pbData = (PBYTE) new BYTE[dwFileSize]; - BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL); - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - CloseHandle(fileHandle); - // 4J-PB - is it possible that we can get here after a read fail and it's not an error? - levelGen->setBaseSaveData(pbData, dwFileSize); + levelGen->setBaseSaveData(pbData, fileSize); + } + else + { + app.FatalLoadError(); } } } @@ -517,10 +480,10 @@ void DLCTexturePack::loadUI() { DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); - DWORD dwSize = 0; - PBYTE pbData = dataFile->getData(dwSize); + std::uint32_t dwSize = 0; + std::uint8_t *pbData = dataFile->getData(dwSize); - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE,L"memory://%08X,%04X#skin_Minecraft.xur",pbData, dwSize); @@ -591,10 +554,10 @@ std::wstring DLCTexturePack::getXuiRootPath() { DLCUIDataFile *dataFile = (DLCUIDataFile *)m_dlcDataPack->getFile(DLCManager::e_DLCType_UIData, L"TexturePack.xzp"); - DWORD dwSize = 0; - PBYTE pbData = dataFile->getData(dwSize); + std::uint32_t dwSize = 0; + std::uint8_t *pbData = dataFile->getData(dwSize); - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE,L"memory://%08X,%04X#",pbData, dwSize); path = szResourceLocator; diff --git a/Minecraft.Client/Textures/Packs/DLCTexturePack.h b/Minecraft.Client/Textures/Packs/DLCTexturePack.h index f69eb0258..39ca39e27 100644 --- a/Minecraft.Client/Textures/Packs/DLCTexturePack.h +++ b/Minecraft.Client/Textures/Packs/DLCTexturePack.h @@ -22,7 +22,7 @@ private: public: using AbstractTexturePack::getResource; - DLCTexturePack(DWORD id, DLCPack *pack, TexturePack *fallback); + DLCTexturePack(std::uint32_t id, DLCPack *pack, TexturePack *fallback); ~DLCTexturePack(){}; virtual std::wstring getResource(const std::wstring& name); @@ -54,11 +54,11 @@ public: virtual bool isLoadingData() { return m_bLoadingData; } private: - static std::wstring getRootPath(DWORD packId, bool allowOverride, bool bAddDataFolder); - static std::wstring getFilePath(DWORD packId, std::wstring filename, bool bAddDataFolder=true); + static std::wstring getRootPath(std::uint32_t packId, bool allowOverride, bool bAddDataFolder); + static std::wstring getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder=true); public: - static int packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask); + static int packMounted(void *pParam,int iPad,std::uint32_t dwErr,std::uint32_t dwLicenceMask); virtual void loadData(); virtual void loadUI(); virtual void unloadUI(); diff --git a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp index 62418287b..a6e59d471 100644 --- a/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/DefaultTexturePack.cpp @@ -17,13 +17,13 @@ void DefaultTexturePack::loadIcon() { #ifdef _XBOX // 4J Stu - Temporary only - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; const ULONG_PTR c_ModuleHandle = (ULONG_PTR)GetModuleHandle(NULL); swprintf(szResourceLocator, LOCATOR_SIZE ,L"section://%X,%ls#%ls",c_ModuleHandle,L"media", L"media/Graphics/TexturePackIcon.png"); - UINT size = 0; + unsigned int size = 0; HRESULT hr = XuiResourceLoadAllNoLoc(szResourceLocator, &m_iconData, &size); m_iconSize = size; #else @@ -31,7 +31,7 @@ void DefaultTexturePack::loadIcon() { byteArray ba = app.getArchiveFile(L"Graphics\\TexturePackIcon.png"); m_iconData = ba.data; - m_iconSize = ba.length; + m_iconSize = static_cast(ba.length); } #endif } diff --git a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp index 4cbf392ed..c70b462d6 100644 --- a/Minecraft.Client/Textures/Packs/FileTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FileTexturePack.cpp @@ -1,7 +1,7 @@ #include "../../Platform/stdafx.h" #include "FileTexturePack.h" -FileTexturePack::FileTexturePack(DWORD id, File *file, TexturePack *fallback) : AbstractTexturePack(id, file, file->getName(), fallback) +FileTexturePack::FileTexturePack(std::uint32_t id, File *file, TexturePack *fallback) : AbstractTexturePack(id, file, file->getName(), fallback) { // 4J Stu - These calls need to be in the most derived version of the class loadIcon(); @@ -83,4 +83,4 @@ bool FileTexturePack::isTerrainUpdateCompatible() return !hasOldFiles; #endif return false; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/Packs/FileTexturePack.h b/Minecraft.Client/Textures/Packs/FileTexturePack.h index 6a7be75fe..3643d6f74 100644 --- a/Minecraft.Client/Textures/Packs/FileTexturePack.h +++ b/Minecraft.Client/Textures/Packs/FileTexturePack.h @@ -12,7 +12,7 @@ private: //ZipFile *zipFile; public: - FileTexturePack(DWORD id, File *file, TexturePack *fallback); + FileTexturePack(std::uint32_t id, File *file, TexturePack *fallback); //@Override void unload(Textures *textures); diff --git a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp index 51e5a669c..2365d08cb 100644 --- a/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp +++ b/Minecraft.Client/Textures/Packs/FolderTexturePack.cpp @@ -1,7 +1,7 @@ #include "../../Platform/stdafx.h" #include "FolderTexturePack.h" -FolderTexturePack::FolderTexturePack(DWORD id, const std::wstring &name, File *folder, TexturePack *fallback) : AbstractTexturePack(id, folder, name, fallback) +FolderTexturePack::FolderTexturePack(std::uint32_t id, const std::wstring &name, File *folder, TexturePack *fallback) : AbstractTexturePack(id, folder, name, fallback) { // 4J Stu - These calls need to be in the most derived version of the class loadIcon(); @@ -79,7 +79,7 @@ void FolderTexturePack::loadUI() // Load new skin if(hasFile(L"TexturePack.xzp")) { - const DWORD LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string + constexpr int LOCATOR_SIZE = 256; // Use this to allocate space to hold a ResourceLocator string WCHAR szResourceLocator[ LOCATOR_SIZE ]; swprintf(szResourceLocator, LOCATOR_SIZE,L"file://%lsTexturePack.xzp#skin_Minecraft.xur",getPath().c_str()); @@ -107,4 +107,4 @@ void FolderTexturePack::unloadUI() } AbstractTexturePack::unloadUI(); #endif -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/Packs/FolderTexturePack.h b/Minecraft.Client/Textures/Packs/FolderTexturePack.h index c57d2576e..3cd30859e 100644 --- a/Minecraft.Client/Textures/Packs/FolderTexturePack.h +++ b/Minecraft.Client/Textures/Packs/FolderTexturePack.h @@ -8,7 +8,7 @@ private: bool bUILoaded; public: - FolderTexturePack(DWORD id, const std::wstring &name, File *folder, TexturePack *fallback); + FolderTexturePack(std::uint32_t id, const std::wstring &name, File *folder, TexturePack *fallback); protected: //@Override @@ -23,4 +23,4 @@ public: virtual std::wstring getPath(bool bTitleUpdateTexture = false); virtual void loadUI(); virtual void unloadUI(); -}; \ No newline at end of file +}; diff --git a/Minecraft.Client/Textures/Packs/TexturePack.h b/Minecraft.Client/Textures/Packs/TexturePack.h index 781fbe474..621c3d458 100644 --- a/Minecraft.Client/Textures/Packs/TexturePack.h +++ b/Minecraft.Client/Textures/Packs/TexturePack.h @@ -1,5 +1,6 @@ #pragma once +#include #include "../../Platform/Common/App_enums.h" @@ -22,7 +23,7 @@ public: virtual void load(Textures *textures) = 0; virtual InputStream *getResource(const std::wstring &name, bool allowFallback) = 0;// throws IOException; //virtual InputStream *getResource(const std::wstring &name) = 0;// throws IOException; - virtual DWORD getId() = 0; + virtual std::uint32_t getId() = 0; virtual std::wstring getName() = 0; virtual std::wstring getDesc1() = 0; virtual std::wstring getDesc2() = 0; @@ -47,8 +48,8 @@ public: virtual void loadUI() = 0; virtual void unloadUI() = 0; virtual std::wstring getXuiRootPath() = 0; - virtual PBYTE getPackIcon(DWORD &dwImageBytes) = 0; - virtual PBYTE getPackComparison(DWORD &dwImageBytes) = 0; + virtual std::uint8_t *getPackIcon(std::uint32_t &imageBytes) = 0; + virtual std::uint8_t *getPackComparison(std::uint32_t &imageBytes) = 0; virtual unsigned int getDLCParentPackId() = 0; virtual unsigned char getDLCSubPackId() = 0; virtual ColourTable *getColourTable() = 0; diff --git a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp index 2b10c3a4a..9eccc3ff6 100644 --- a/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp +++ b/Minecraft.Client/Textures/Packs/TexturePackRepository.cpp @@ -59,7 +59,7 @@ void TexturePackRepository::addDebugPacks() { wprintf(L"Pack \"%ls\" is not installed, so adding it\n", L"DLCTestPack"); pack = new DLCPack(L"DLCTestPack",0xffffffff); - DWORD dwFilesProcessed = 0; + unsigned int dwFilesProcessed = 0; if( app.m_dlcManager.readDLCDataFile(dwFilesProcessed, "GAME:\\DummyTexturePack\\TexturePack.pck",pack)) { // 4J Stu - Don't need to do this, as the readDLCDataFile now adds texture packs @@ -291,19 +291,19 @@ bool TexturePackRepository::canUseWebSkin() return false; } -std::vector< std::pair > *TexturePackRepository::getTexturePackIdNames() +std::vector< std::pair > *TexturePackRepository::getTexturePackIdNames() { - std::vector< std::pair > *packList = new std::vector< std::pair >(); + std::vector< std::pair > *packList = new std::vector< std::pair >(); for(AUTO_VAR(it,texturePacks->begin()); it != texturePacks->end(); ++it) { TexturePack *pack = *it; - packList->push_back( std::pair(pack->getId(),pack->getName()) ); + packList->push_back( std::pair(pack->getId(),pack->getName()) ); } return packList; } -bool TexturePackRepository::selectTexturePackById(DWORD id) +bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { bool bDidSelect = false; @@ -352,7 +352,7 @@ bool TexturePackRepository::selectTexturePackById(DWORD id) return bDidSelect; } -TexturePack *TexturePackRepository::getTexturePackById(DWORD id) +TexturePack *TexturePackRepository::getTexturePackById(std::uint32_t id) { AUTO_VAR(it, cacheById.find(id)); if(it != cacheById.end()) @@ -363,27 +363,27 @@ TexturePack *TexturePackRepository::getTexturePackById(DWORD id) return NULL; } -TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, DWORD id) +TexturePack *TexturePackRepository::addTexturePackFromDLC(DLCPack *dlcPack, std::uint32_t id) { TexturePack *newPack = NULL; // 4J-PB - The City texture pack went out with a child id for the texture pack of 1 instead of zero // we need to mask off the child id here to deal with this - DWORD dwParentID=id&0xFFFFFF; // child id is <<24 and Or'd with parent + const std::uint32_t parentId = id & 0xFFFFFFu; // child id is <<24 and Or'd with parent if(dlcPack != NULL) { - newPack = new DLCTexturePack(dwParentID, dlcPack, DEFAULT_TEXTURE_PACK); + newPack = new DLCTexturePack(parentId, dlcPack, DEFAULT_TEXTURE_PACK); texturePacks->push_back(newPack); - cacheById[dwParentID] = newPack; + cacheById[parentId] = newPack; #ifndef _CONTENT_PACKAGE if(dlcPack->hasPurchasedFile(DLCManager::e_DLCType_TexturePack,L"")) { - wprintf(L"Added new FULL DLCTexturePack: %ls - id=%d\n", dlcPack->getName().c_str(),dwParentID ); + wprintf(L"Added new FULL DLCTexturePack: %ls - id=%u\n", dlcPack->getName().c_str(), parentId ); } else { - wprintf(L"Added new TRIAL DLCTexturePack: %ls - id=%d\n", dlcPack->getName().c_str(),dwParentID ); + wprintf(L"Added new TRIAL DLCTexturePack: %ls - id=%u\n", dlcPack->getName().c_str(), parentId ); } #endif } @@ -398,7 +398,7 @@ void TexturePackRepository::clearInvalidTexturePacks() } } -void TexturePackRepository::removeTexturePackById(DWORD id) +void TexturePackRepository::removeTexturePackById(std::uint32_t id) { AUTO_VAR(it, cacheById.find(id)); if(it != cacheById.end()) @@ -450,7 +450,7 @@ TexturePack *TexturePackRepository::getTexturePackByIndex(unsigned int index) return pack; } -unsigned int TexturePackRepository::getTexturePackIndex(unsigned int id) +unsigned int TexturePackRepository::getTexturePackIndex(std::uint32_t id) { int currentIndex = 0; for(AUTO_VAR(it,texturePacks->begin()); it != texturePacks->end(); ++it) @@ -461,4 +461,4 @@ unsigned int TexturePackRepository::getTexturePackIndex(unsigned int id) } if(currentIndex >= texturePacks->size()) currentIndex = 0; return currentIndex; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Textures/Packs/TexturePackRepository.h b/Minecraft.Client/Textures/Packs/TexturePackRepository.h index 1f8e66b8c..a93e1f7c6 100644 --- a/Minecraft.Client/Textures/Packs/TexturePackRepository.h +++ b/Minecraft.Client/Textures/Packs/TexturePackRepository.h @@ -7,9 +7,9 @@ class Minecraft; class TexturePackRepository { public: - static const DWORD DEFAULT_TEXTURE_PACK_ID = 0; - static const DWORD FOLDER_TEST_TEXTURE_PACK_ID = 1; - static const DWORD DLC_TEST_TEXTURE_PACK_ID = 2; + static constexpr std::uint32_t DEFAULT_TEXTURE_PACK_ID = 0; + static constexpr std::uint32_t FOLDER_TEST_TEXTURE_PACK_ID = 1; + static constexpr std::uint32_t DLC_TEST_TEXTURE_PACK_ID = 2; private: static TexturePack *DEFAULT_TEXTURE_PACK; TexturePack *m_dummyTexturePack; @@ -21,7 +21,7 @@ private: std::vector *texturePacks; std::vector m_texturePacksToDelete; - std::unordered_map cacheById; + std::unordered_map cacheById; TexturePack *selected; TexturePack *lastSelected; @@ -60,18 +60,18 @@ public: bool isUsingDefaultSkin() { return selected == DEFAULT_TEXTURE_PACK; } // 4J Added TexturePack *getDefault() { return DEFAULT_TEXTURE_PACK; } // 4J Added - std::vector< std::pair > *getTexturePackIdNames(); - bool selectTexturePackById(DWORD id); // 4J Added - TexturePack *getTexturePackById(DWORD id); // 4J Added + std::vector< std::pair > *getTexturePackIdNames(); + bool selectTexturePackById(std::uint32_t id); // 4J Added + TexturePack *getTexturePackById(std::uint32_t id); // 4J Added - TexturePack *addTexturePackFromDLC(DLCPack *dlcPack, DWORD id); + TexturePack *addTexturePackFromDLC(DLCPack *dlcPack, std::uint32_t id); void clearInvalidTexturePacks(); void updateUI(); bool needsUIUpdate(); private: - void removeTexturePackById(DWORD id); + void removeTexturePackById(std::uint32_t id); public: unsigned int getTexturePackCount(); TexturePack *getTexturePackByIndex(unsigned int index); - unsigned int getTexturePackIndex(unsigned int id); + unsigned int getTexturePackIndex(std::uint32_t id); }; diff --git a/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp index 9b55f0132..99066524e 100644 --- a/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp +++ b/Minecraft.Client/Textures/Stitching/PreStitchedTextureMap.cpp @@ -18,6 +18,7 @@ #include "../../UI/SimpleIcon.h" #include "../CompassTexture.h" #include "../ClockTexture.h" +#include const std::wstring PreStitchedTextureMap::NAME_MISSING_TEXTURE = L"missingno"; @@ -178,7 +179,7 @@ void PreStitchedTextureMap::stitch() #ifdef __PSVITA__ // AP - alpha cut out is expensive on vita so we mark which icons actually require it - DWORD *data = (DWORD*) this->getStitchedTexture()->getData()->getBuffer(); + const std::uint8_t *data = this->getStitchedTexture()->getData()->getBuffer(); int Width = this->getStitchedTexture()->getWidth(); int Height = this->getStitchedTexture()->getHeight(); for(AUTO_VAR(it, texturesByName.begin()); it != texturesByName.end(); ++it) @@ -196,8 +197,10 @@ void PreStitchedTextureMap::stitch() { for( int u = u0;u < u1; u+= 1 ) { + std::uint32_t pixel = 0; + std::memcpy(&pixel, data + ((v * Width + u) * sizeof(pixel)), sizeof(pixel)); // is this texel alpha value < 0.1 - if( (data[v * Width + u] & 0xff000000) < 0x20000000 ) + if( (pixel & 0xff000000) < 0x20000000 ) { // this texel is transparent. Mark the icon as such and bail preStitched->setFlags(Icon::IS_ALPHA_CUT_OUT); diff --git a/Minecraft.Client/Textures/Texture.cpp b/Minecraft.Client/Textures/Texture.cpp index b5d9625b9..f01691229 100644 --- a/Minecraft.Client/Textures/Texture.cpp +++ b/Minecraft.Client/Textures/Texture.cpp @@ -224,10 +224,10 @@ void Texture::fill(const Rect2i *rect, int color) int line = y * width * 4; for (int x = myRect->getX(); x < (myRect->getX() + myRect->getWidth()); x++) { - data[0]->put(line + x * 4 + 0, (BYTE)((color >> 24) & 0x000000ff)); - data[0]->put(line + x * 4 + 1, (BYTE)((color >> 16) & 0x000000ff)); - data[0]->put(line + x * 4 + 2, (BYTE)((color >> 8) & 0x000000ff)); - data[0]->put(line + x * 4 + 3, (BYTE)((color >> 0) & 0x000000ff)); + data[0]->put(line + x * 4 + 0, static_cast((color >> 24) & 0x000000ff)); + data[0]->put(line + x * 4 + 1, static_cast((color >> 16) & 0x000000ff)); + data[0]->put(line + x * 4 + 2, static_cast((color >> 8) & 0x000000ff)); + data[0]->put(line + x * 4 + 3, static_cast((color >> 0) & 0x000000ff)); } } delete myRect; diff --git a/Minecraft.Client/Textures/Textures.cpp b/Minecraft.Client/Textures/Textures.cpp index 83cb97d44..eecc06df1 100644 --- a/Minecraft.Client/Textures/Textures.cpp +++ b/Minecraft.Client/Textures/Textures.cpp @@ -1015,8 +1015,8 @@ MemTexture *Textures::addMemTexture(const std::wstring& name,MemTextureProcessor if(texture == NULL) { // can we find it in the app mem files? - PBYTE pbData=NULL; - DWORD dwBytes=0; + std::uint8_t *pbData=NULL; + unsigned int dwBytes=0; app.GetMemFileDetails(name,&pbData,&dwBytes); if(dwBytes!=0) diff --git a/Minecraft.Client/UI/Gui.cpp b/Minecraft.Client/UI/Gui.cpp index 87213ba19..fc1f8ea47 100644 --- a/Minecraft.Client/UI/Gui.cpp +++ b/Minecraft.Client/UI/Gui.cpp @@ -1349,7 +1349,7 @@ void Gui::addMessage(const std::wstring& _string,int iPad,bool bIsDeathMessage) } // 4J Added -float Gui::getOpacity(int iPad, DWORD index) +float Gui::getOpacity(int iPad, std::size_t index) { float opacityPercentage = 0; if (guiMessages[iPad].size() > index && guiMessages[iPad][index].ticks < 20 * 10) diff --git a/Minecraft.Client/UI/Gui.h b/Minecraft.Client/UI/Gui.h index 590947f0e..725a3b4c6 100644 --- a/Minecraft.Client/UI/Gui.h +++ b/Minecraft.Client/UI/Gui.h @@ -1,4 +1,5 @@ #pragma once +#include #include "GuiComponent.h" #include "GuiMessage.h" class Random; @@ -55,9 +56,9 @@ public: void displayClientMessage(int messageId, int iPad); // 4J Added - DWORD getMessagesCount(int iPad) { return (int)guiMessages[iPad].size(); } - std::wstring getMessage(int iPad, DWORD index) { return guiMessages[iPad].at(index).string; } - float getOpacity(int iPad, DWORD index); + std::size_t getMessagesCount(int iPad) { return guiMessages[iPad].size(); } + std::wstring getMessage(int iPad, std::size_t index) { return guiMessages[iPad].at(index).string; } + float getOpacity(int iPad, std::size_t index); std::wstring getJukeboxMessage(int iPad) { return overlayMessageString; } float getJukeboxOpacity(int iPad); diff --git a/Minecraft.Client/Utils/ArchiveFile.cpp b/Minecraft.Client/Utils/ArchiveFile.cpp index b2a8b383b..d39e38591 100644 --- a/Minecraft.Client/Utils/ArchiveFile.cpp +++ b/Minecraft.Client/Utils/ArchiveFile.cpp @@ -1,6 +1,7 @@ #include "../Platform/stdafx.h" #include "../../Minecraft.World/Util/StringHelpers.h" +#include "../../Minecraft.World/Util/PortableFileIO.h" #include "../../Minecraft.World/IO/Streams/Compression.h" #include "ArchiveFile.h" @@ -120,66 +121,18 @@ byteArray ArchiveFile::getFile(const std::wstring &filename) memcpy( out.data, m_cachedData + data->ptr, data->filesize ); #else + const unsigned int fileSize = static_cast(data->filesize); + std::uint8_t *pbData = new std::uint8_t[fileSize == 0 ? 1 : fileSize]; + out = byteArray(pbData, fileSize); + const PortableFileIO::BinaryReadResult readResult = PortableFileIO::ReadBinaryFileSegment( + m_sourcefile.getPath(), + static_cast(data->ptr), + out.data, + static_cast(data->filesize)); -#if defined(_UNICODE) && !defined(__linux__) - HANDLE hfile = CreateFile( m_sourcefile.getPath().c_str(), - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL - ); -#else - app.DebugPrintf("Createfile archive\n"); - HANDLE hfile = CreateFile( wstringtofilename(m_sourcefile.getPath()), - GENERIC_READ, - 0, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL - ); -#endif - - if (hfile != INVALID_HANDLE_VALUE) + if (readResult.status != PortableFileIO::BinaryReadStatus::ok) { - app.DebugPrintf("hfile ok\n"); - DWORD ok = SetFilePointer( hfile, - data->ptr, - NULL, - FILE_BEGIN - ); - - if (ok != INVALID_SET_FILE_POINTER) - { - PBYTE pbData = new BYTE[ data->filesize ]; - - DWORD bytesRead = -1; - BOOL bSuccess = ReadFile( hfile, - (LPVOID) pbData, - data->filesize, - &bytesRead, - NULL - ); - - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - assert(bytesRead == data->filesize); - out = byteArray(pbData, data->filesize); - } - else - { - app.FatalLoadError(); - } - - CloseHandle(hfile); - } - else - { - app.DebugPrintf("bad hfile\n"); + app.DebugPrintf("Failed to read archive file segment\n"); app.FatalLoadError(); } #endif @@ -198,7 +151,7 @@ byteArray ArchiveFile::getFile(const std::wstring &filename) unsigned int decompressedSize = dis.readInt(); dis.close(); - PBYTE uncompressedBuffer = new BYTE[decompressedSize]; + std::uint8_t *uncompressedBuffer = new std::uint8_t[decompressedSize]; Compression::getCompression()->Decompress(uncompressedBuffer, &decompressedSize, out.data+4, out.length-4); delete [] out.data; diff --git a/Minecraft.Client/Utils/ArchiveFile.h b/Minecraft.Client/Utils/ArchiveFile.h index 83ca6b160..d3f34e8be 100644 --- a/Minecraft.Client/Utils/ArchiveFile.h +++ b/Minecraft.Client/Utils/ArchiveFile.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -12,7 +13,7 @@ class ArchiveFile { protected: File m_sourcefile; - BYTE *m_cachedData; + std::uint8_t *m_cachedData; typedef struct _MetaData { diff --git a/Minecraft.Client/Utils/StringTable.cpp b/Minecraft.Client/Utils/StringTable.cpp index ac324a2d4..2a675e707 100644 --- a/Minecraft.Client/Utils/StringTable.cpp +++ b/Minecraft.Client/Utils/StringTable.cpp @@ -7,9 +7,9 @@ StringTable::StringTable(void) } // Load string table from a binary blob, filling out with the current localisation data only -StringTable::StringTable(PBYTE pbData, DWORD dwSize) +StringTable::StringTable(std::uint8_t *pbData, unsigned int dataSize) { - src = byteArray(pbData, dwSize); + src = byteArray(pbData, dataSize); ByteArrayInputStream bais(src); DataInputStream dis(&bais); @@ -31,7 +31,7 @@ StringTable::StringTable(PBYTE pbData, DWORD dwSize) bool foundLang = false; __int64 bytesToSkip = 0; - int dataSize = 0; + int selectedDataSize = 0; // for( AUTO_VAR(it_locales, locales.begin()); @@ -46,7 +46,7 @@ StringTable::StringTable(PBYTE pbData, DWORD dwSize) if(it->first.compare(*it_locales) == 0) { app.DebugPrintf("StringTable:: Found language '%ls'.\n", it_locales->c_str()); - dataSize = it->second; + selectedDataSize = it->second; foundLang = true; break; } @@ -62,7 +62,7 @@ StringTable::StringTable(PBYTE pbData, DWORD dwSize) { dis.skip(bytesToSkip); - byteArray langData(dataSize); + byteArray langData(selectedDataSize); dis.read(langData); dis.close(); @@ -119,13 +119,13 @@ StringTable::~StringTable(void) // delete src.data; TODO 4J-JEV: ? } -void StringTable::getData(PBYTE *ppData, UINT *pSize) +void StringTable::getData(std::uint8_t **ppData, unsigned int *pSize) { *ppData = src.data; *pSize = src.length; } -LPCWSTR StringTable::getString(const std::wstring &id) +const wchar_t *StringTable::getString(const std::wstring &id) { #ifndef _CONTENT_PACKAGE if (isStatic) @@ -147,7 +147,7 @@ LPCWSTR StringTable::getString(const std::wstring &id) } } -LPCWSTR StringTable::getString(int id) +const wchar_t *StringTable::getString(int id) { #ifndef _CONTENT_PACKAGE if (!isStatic) @@ -159,7 +159,7 @@ LPCWSTR StringTable::getString(int id) if (id < m_stringsVec.size()) { - LPCWSTR pwchString=m_stringsVec.at(id).c_str(); + const wchar_t *pwchString = m_stringsVec.at(id).c_str(); return pwchString; } else diff --git a/Minecraft.Client/Utils/StringTable.h b/Minecraft.Client/Utils/StringTable.h index 4e55afe76..c3ce4bccb 100644 --- a/Minecraft.Client/Utils/StringTable.h +++ b/Minecraft.Client/Utils/StringTable.h @@ -1,5 +1,7 @@ #pragma once +#include + #if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ @@ -59,13 +61,13 @@ public: // }; StringTable(void); - StringTable(PBYTE pbData, DWORD dwSize); + StringTable(std::uint8_t *pbData, unsigned int dataSize); ~StringTable(void); - void getData(PBYTE *ppbData, UINT *pdwSize); + void getData(std::uint8_t **ppData, unsigned int *pSize); - LPCWSTR getString(const std::wstring &id); - LPCWSTR getString(int id); + const wchar_t *getString(const std::wstring &id); + const wchar_t *getString(int id); //static LPCWSTR m_wchLocaleCode[LOCALE_COUNT]; diff --git a/Minecraft.Client/Utils/WstringLookup.cpp b/Minecraft.Client/Utils/WstringLookup.cpp index dfd3de37c..7f8fdaa70 100644 --- a/Minecraft.Client/Utils/WstringLookup.cpp +++ b/Minecraft.Client/Utils/WstringLookup.cpp @@ -8,7 +8,7 @@ WstringLookup::WstringLookup() numIDs = 0; } -std::wstring WstringLookup::lookup(UINT id) +std::wstring WstringLookup::lookup(unsigned int id) { // TODO //if (id > currentMaxID) @@ -17,12 +17,12 @@ std::wstring WstringLookup::lookup(UINT id) return int2str.at(id); } -UINT WstringLookup::lookup(std::wstring str) +unsigned int WstringLookup::lookup(std::wstring str) { if (str2int.find(str) == str2int.end()) { - std::pair p = - std::pair(str, numIDs); + std::pair p = + std::pair(str, numIDs); str2int.insert( p ); int2str.push_back( str ); @@ -35,14 +35,15 @@ UINT WstringLookup::lookup(std::wstring str) } } -VOID WstringLookup::getTable(std::wstring **lookup, UINT *len) +void WstringLookup::getTable(std::wstring **lookup, unsigned int *len) { // Outputs - std::wstring *out_lookup; UINT out_len; + std::wstring *out_lookup; + unsigned int out_len; // Fill lookup. out_lookup = new std::wstring[int2str.size()]; - for (UINT i = 0; i < numIDs; i++) + for (unsigned int i = 0; i < numIDs; i++) out_lookup[i] = int2str.at(i); out_len = numIDs; @@ -51,4 +52,4 @@ VOID WstringLookup::getTable(std::wstring **lookup, UINT *len) *lookup = out_lookup; *len = out_len; return; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Utils/WstringLookup.h b/Minecraft.Client/Utils/WstringLookup.h index a5247bc3f..8c531845b 100644 --- a/Minecraft.Client/Utils/WstringLookup.h +++ b/Minecraft.Client/Utils/WstringLookup.h @@ -5,16 +5,16 @@ class WstringLookup { private: - UINT numIDs; - std::unordered_map str2int; + unsigned int numIDs; + std::unordered_map str2int; std::vector int2str; public: WstringLookup(); - std::wstring lookup(UINT id); + std::wstring lookup(unsigned int id); - UINT lookup(std::wstring); + unsigned int lookup(std::wstring); - VOID getTable(std::wstring **lookup, UINT *len); -}; \ No newline at end of file + void getTable(std::wstring **lookup, unsigned int *len); +}; diff --git a/Minecraft.World/Blocks/PistonBaseTile.cpp b/Minecraft.World/Blocks/PistonBaseTile.cpp index 5d75a398d..1aa424c43 100644 --- a/Minecraft.World/Blocks/PistonBaseTile.cpp +++ b/Minecraft.World/Blocks/PistonBaseTile.cpp @@ -1,4 +1,5 @@ #include "../Platform/stdafx.h" +#include #include "PistonBaseTile.h" #include "PistonMovingTileEntity.h" #include "TileEntities/PistonPieceTileEntity.h" @@ -19,7 +20,43 @@ const std::wstring PistonBaseTile::INSIDE_TEX = L"piston_inner_top"; const float PistonBaseTile::PLATFORM_THICKNESS = 4.0f; +namespace +{ +#if defined(_WIN32) + inline void *PistonTlsGetValue(DWORD key) + { + return TlsGetValue(key); + } + + inline void PistonTlsSetValue(DWORD key, void *value) + { + TlsSetValue(key, value); + } +#else + pthread_key_t CreatePistonTlsKey() + { + pthread_key_t key; + pthread_key_create(&key, NULL); + return key; + } + + inline void *PistonTlsGetValue(pthread_key_t key) + { + return pthread_getspecific(key); + } + + inline void PistonTlsSetValue(pthread_key_t key, void *value) + { + pthread_setspecific(key, value); + } +#endif +} + +#if defined(_WIN32) DWORD PistonBaseTile::tlsIdx = TlsAlloc(); +#else +pthread_key_t PistonBaseTile::tlsIdx = CreatePistonTlsKey(); +#endif // 4J - NOTE - this ignoreUpdate stuff has been removed from the java version, but I'm not currently sure how the java version does without it... there must be // some other mechanism that we don't have that stops the event from one piston being processed, from causing neighbours to have extra events created for them. @@ -28,12 +65,12 @@ DWORD PistonBaseTile::tlsIdx = TlsAlloc(); // 4J - ignoreUpdate is a static in java, implementing as TLS here to make thread safe bool PistonBaseTile::ignoreUpdate() { - return (TlsGetValue(tlsIdx) != NULL); + return PistonTlsGetValue(tlsIdx) != NULL; } void PistonBaseTile::ignoreUpdate(bool set) { - TlsSetValue(tlsIdx,(LPVOID)(intptr_t)(set?1:0)); + PistonTlsSetValue(tlsIdx, reinterpret_cast(static_cast(set ? 1 : 0))); } PistonBaseTile::PistonBaseTile(int id, bool isSticky) : Tile(id, Material::piston, false) diff --git a/Minecraft.World/Blocks/PistonBaseTile.h b/Minecraft.World/Blocks/PistonBaseTile.h index 9e5ca11e1..4e844a7e2 100644 --- a/Minecraft.World/Blocks/PistonBaseTile.h +++ b/Minecraft.World/Blocks/PistonBaseTile.h @@ -1,6 +1,10 @@ #pragma once #include "Tile.h" +#if !defined(_WIN32) +#include +#endif + class PistonBaseTile : public Tile { public: @@ -25,7 +29,11 @@ private: Icon *iconBack; Icon *iconPlatform; +#if defined(_WIN32) static DWORD tlsIdx; +#else + static pthread_key_t tlsIdx; +#endif // 4J - was just a static but implemented with TLS for our version static bool ignoreUpdate(); static void ignoreUpdate(bool set); @@ -68,4 +76,4 @@ private: static void stopSharingIfServer(Level *level, int x, int y, int z); // 4J added bool createPush(Level *level, int sx, int sy, int sz, int facing); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Blocks/TheEndPortalTile.cpp b/Minecraft.World/Blocks/TheEndPortalTile.cpp index 3d94380eb..a2fbaf308 100644 --- a/Minecraft.World/Blocks/TheEndPortalTile.cpp +++ b/Minecraft.World/Blocks/TheEndPortalTile.cpp @@ -7,18 +7,55 @@ #include "../Headers/net.minecraft.world.entity.h" #include "../Headers/net.minecraft.world.entity.player.h" #include "../Headers/net.minecraft.world.h" +#include +namespace +{ +#if defined(_WIN32) + inline void *TheEndPortalTlsGetValue(DWORD key) + { + return TlsGetValue(key); + } + + inline void TheEndPortalTlsSetValue(DWORD key, void *value) + { + TlsSetValue(key, value); + } +#else + pthread_key_t CreateTheEndPortalTlsKey() + { + pthread_key_t key; + pthread_key_create(&key, NULL); + return key; + } + + inline void *TheEndPortalTlsGetValue(pthread_key_t key) + { + return pthread_getspecific(key); + } + + inline void TheEndPortalTlsSetValue(pthread_key_t key, void *value) + { + pthread_setspecific(key, value); + } +#endif +} + +#if defined(_WIN32) DWORD TheEndPortal::tlsIdx = TlsAlloc(); +#else +pthread_key_t TheEndPortal::tlsIdx = CreateTheEndPortalTlsKey(); +#endif // 4J - allowAnywhere is a static in java, implementing as TLS here to make thread safe bool TheEndPortal::allowAnywhere() { - return (TlsGetValue(tlsIdx) != NULL); + return TheEndPortalTlsGetValue(tlsIdx) != NULL; } void TheEndPortal::allowAnywhere(bool set) { - TlsSetValue(tlsIdx,(LPVOID)(intptr_t)(set?1:0)); + TheEndPortalTlsSetValue(tlsIdx, reinterpret_cast(static_cast(set ? 1 : 0))); } TheEndPortal::TheEndPortal(int id, Material *material) : EntityTile(id, material, false) diff --git a/Minecraft.World/Blocks/TheEndPortalTile.h b/Minecraft.World/Blocks/TheEndPortalTile.h index b344ce796..130a4232b 100644 --- a/Minecraft.World/Blocks/TheEndPortalTile.h +++ b/Minecraft.World/Blocks/TheEndPortalTile.h @@ -1,10 +1,18 @@ #pragma once #include "TileEntities/EntityTile.h" +#if !defined(_WIN32) +#include +#endif + class TheEndPortal : public EntityTile { public: +#if defined(_WIN32) static DWORD tlsIdx; +#else + static pthread_key_t tlsIdx; +#endif // 4J - was just a static but implemented with TLS for our version static bool allowAnywhere(); static void allowAnywhere(bool set); @@ -24,4 +32,4 @@ public: virtual void onPlace(Level *level, int x, int y, int z); virtual int cloneTileId(Level *level, int x, int y, int z); void registerIcons(IconRegister *iconRegister); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Blocks/Tile.cpp b/Minecraft.World/Blocks/Tile.cpp index adc7cb714..209b76272 100644 --- a/Minecraft.World/Blocks/Tile.cpp +++ b/Minecraft.World/Blocks/Tile.cpp @@ -16,6 +16,39 @@ #include "../Headers/net.minecraft.h" #include "Tile.h" +namespace +{ +#if defined(_WIN32) + inline void *TileTlsGetValue(DWORD key) + { + return TlsGetValue(key); + } + + inline void TileTlsSetValue(DWORD key, void *value) + { + TlsSetValue(key, value); + } +#else + pthread_key_t CreateTileTlsKey() + { + pthread_key_t key; + const int result = pthread_key_create(&key, nullptr); + assert(result == 0); + return key; + } + + inline void *TileTlsGetValue(pthread_key_t key) + { + return pthread_getspecific(key); + } + + inline void TileTlsSetValue(pthread_key_t key, void *value) + { + pthread_setspecific(key, value); + } +#endif +} + std::wstring Tile::TILE_DESCRIPTION_PREFIX = L"Tile."; const float Tile::INDESTRUCTIBLE_DESTROY_TIME = -1.0f; @@ -201,7 +234,11 @@ Tile *Tile::stairs_quartz = NULL; Tile *Tile::woolCarpet = NULL; +#if defined(_WIN32) DWORD Tile::tlsIdxShape = TlsAlloc(); +#else +pthread_key_t Tile::tlsIdxShape = CreateTileTlsKey(); +#endif Tile::ThreadStorage::ThreadStorage() { @@ -212,12 +249,12 @@ Tile::ThreadStorage::ThreadStorage() void Tile::CreateNewThreadStorage() { ThreadStorage *tls = new ThreadStorage(); - TlsSetValue(Tile::tlsIdxShape, tls); + TileTlsSetValue(Tile::tlsIdxShape, tls); } void Tile::ReleaseThreadStorage() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); delete tls; } @@ -650,7 +687,7 @@ Tile *Tile::disableMipmap() void Tile::setShape(float x0, float y0, float z0, float x1, float y1, float z1) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); tls->xx0 = x0; tls->yy0 = y0; tls->zz0 = z0; @@ -700,7 +737,7 @@ bool Tile::isFaceVisible(Level *level, int x, int y, int z, int f) bool Tile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); if (face == 0 && tls->yy0 > 0) return true; @@ -717,7 +754,7 @@ int Tile::getFaceFlags(LevelSource *level, int x, int y, int z) { int faceFlags = 0; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); @@ -792,7 +829,7 @@ Icon *Tile::getTexture(int face) AABB *Tile::getTileAABB(Level *level, int x, int y, int z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); @@ -806,7 +843,7 @@ void Tile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxe AABB *Tile::getAABB(Level *level, int x, int y, int z) { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + tls->yy1, z + tls->zz1); @@ -941,7 +978,7 @@ HitResult *Tile::clip(Level *level, int xt, int yt, int zt, Vec3 *a, Vec3 *b) a = a->add(-xt, -yt, -zt); b = b->add(-xt, -yt, -zt); - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); Vec3 *xh0 = a->clipX(b, tls->xx0); Vec3 *xh1 = a->clipX(b, tls->xx1); @@ -978,7 +1015,7 @@ bool Tile::containsX(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->y >= tls->yy0 && v->y <= tls->yy1 && v->z >= tls->zz0 && v->z <= tls->zz1; @@ -988,7 +1025,7 @@ bool Tile::containsY(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->x >= tls->xx0 && v->x <= tls->xx1 && v->z >= tls->zz0 && v->z <= tls->zz1; @@ -998,7 +1035,7 @@ bool Tile::containsZ(Vec3 *v) { if( v == NULL) return false; - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return v->x >= tls->xx0 && v->x <= tls->xx1 && v->y >= tls->yy0 && v->y <= tls->yy1; @@ -1063,14 +1100,14 @@ void Tile::handleEntityInside(Level *level, int x, int y, int z, std::shared_ptr void Tile::updateShape(LevelSource *level, int x, int y, int z, int forceData, std::shared_ptr forceEntity) // 4J added forceData, forceEntity param { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); } double Tile::getShapeX0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->xx0; @@ -1078,7 +1115,7 @@ double Tile::getShapeX0() double Tile::getShapeX1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->xx1; @@ -1086,7 +1123,7 @@ double Tile::getShapeX1() double Tile::getShapeY0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->yy0; @@ -1094,7 +1131,7 @@ double Tile::getShapeY0() double Tile::getShapeY1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->yy1; @@ -1102,7 +1139,7 @@ double Tile::getShapeY1() double Tile::getShapeZ0() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->zz0; @@ -1110,7 +1147,7 @@ double Tile::getShapeZ0() double Tile::getShapeZ1() { - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); + ThreadStorage *tls = static_cast(TileTlsGetValue(Tile::tlsIdxShape)); // 4J Stu - Added this so that the TLS shape is correct for this tile if(tls->tileId != this->id) updateDefaultShape(); return tls->zz1; @@ -1630,3 +1667,4 @@ const int Tile::quartzBlock_Id; const int Tile::stairs_quartz_Id; const int Tile::woolCarpet_Id; #endif + diff --git a/Minecraft.World/Blocks/Tile.h b/Minecraft.World/Blocks/Tile.h index de71490c4..ea4421fc0 100644 --- a/Minecraft.World/Blocks/Tile.h +++ b/Minecraft.World/Blocks/Tile.h @@ -3,6 +3,9 @@ #include "../Util/Vec3.h" #include "../Util/Definitions.h" #include "../Util/SoundTypes.h" +#if !defined(_WIN32) +#include +#endif class GrassTile; @@ -55,7 +58,11 @@ protected: int tileId; ThreadStorage(); }; +#if defined(_WIN32) static DWORD tlsIdxShape; +#else + static pthread_key_t tlsIdxShape; +#endif public: // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own // local storage, or share the default storage already allocated by the main thread diff --git a/Minecraft.World/Blocks/TileEntities/SignTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/SignTileEntity.cpp index 3cc0dc95c..71971e540 100644 --- a/Minecraft.World/Blocks/TileEntities/SignTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/SignTileEntity.cpp @@ -36,7 +36,7 @@ SignTileEntity::~SignTileEntity() { // TODO ORBIS_STUBBED; #ifndef __ORBIS__ - // 4J-PB - we don't need to verify strings anymore - InputManager.CancelQueuedVerifyStrings(&SignTileEntity::StringVerifyCallback,(LPVOID)this); + // 4J-PB - we don't need to verify strings anymore - InputManager.CancelQueuedVerifyStrings(&SignTileEntity::StringVerifyCallback, this); #endif } @@ -129,7 +129,7 @@ void SignTileEntity::setChanged() m_bVerified=true; #else - if(!InputManager.VerifyStrings((WCHAR**)&wcMessages,MAX_SIGN_LINES,&SignTileEntity::StringVerifyCallback,(LPVOID)this)) + if(!InputManager.VerifyStrings((WCHAR**)&wcMessages,MAX_SIGN_LINES,&SignTileEntity::StringVerifyCallback, this)) { // Nothing to verify m_bVerified=true; @@ -156,7 +156,7 @@ void SignTileEntity::SetMessage(int iIndex,std::wstring &wsText) } // 4J-PB - added for string verification -int SignTileEntity::StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *pResults) +int SignTileEntity::StringVerifyCallback(void *lpParam,STRING_VERIFY_RESPONSE *pResults) { // results will be in m_pStringVerifyResponse SignTileEntity *pClass=(SignTileEntity *)lpParam; @@ -195,4 +195,4 @@ std::shared_ptr SignTileEntity::clone() result->m_bVerified = m_bVerified; result->m_bCensored = m_bCensored; return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/TileEntities/SignTileEntity.h b/Minecraft.World/Blocks/TileEntities/SignTileEntity.h index 6325180b6..b19d413d6 100644 --- a/Minecraft.World/Blocks/TileEntities/SignTileEntity.h +++ b/Minecraft.World/Blocks/TileEntities/SignTileEntity.h @@ -42,8 +42,8 @@ public: bool isEditable(); void setEditable(bool isEditable); virtual void setChanged(); - static int StringVerifyCallback(LPVOID lpParam,STRING_VERIFY_RESPONSE *pResults); + static int StringVerifyCallback(void *lpParam,STRING_VERIFY_RESPONSE *pResults); // 4J Added virtual std::shared_ptr clone(); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp b/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp index c28e1a903..68b589787 100644 --- a/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp +++ b/Minecraft.World/Blocks/TileEntities/SkullTileEntity.cpp @@ -13,8 +13,8 @@ SkullTileEntity::SkullTileEntity() void SkullTileEntity::save(CompoundTag *tag) { TileEntity::save(tag); - tag->putByte(L"SkullType", (BYTE) (skullType & 0xff)); - tag->putByte(L"Rot", (BYTE) (rotation & 0xff)); + tag->putByte(L"SkullType", static_cast(skullType & 0xff)); + tag->putByte(L"Rot", static_cast(rotation & 0xff)); tag->putString(L"ExtraType", extraType); } @@ -69,4 +69,4 @@ std::shared_ptr SkullTileEntity::clone() result->rotation = rotation; result->extraType = extraType; return result; -} \ No newline at end of file +} diff --git a/Minecraft.World/Entities/Entity.cpp b/Minecraft.World/Entities/Entity.cpp index 28e55b7c4..1a9a927da 100644 --- a/Minecraft.World/Entities/Entity.cpp +++ b/Minecraft.World/Entities/Entity.cpp @@ -21,10 +21,48 @@ #include "../../Minecraft.Client/MinecraftServer.h" #include "../../Minecraft.Client/Level/MultiPlayerLevel.h" #include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h" +#include + +namespace +{ +#if defined(_WIN32) + inline void *EntityTlsGetValue(DWORD key) + { + return TlsGetValue(key); + } + + inline void EntityTlsSetValue(DWORD key, void *value) + { + TlsSetValue(key, value); + } +#else + pthread_key_t CreateEntityTlsKey() + { + pthread_key_t key; + const int result = pthread_key_create(&key, nullptr); + assert(result == 0); + return key; + } + + inline void *EntityTlsGetValue(pthread_key_t key) + { + return pthread_getspecific(key); + } + + inline void EntityTlsSetValue(pthread_key_t key, void *value) + { + pthread_setspecific(key, value); + } +#endif +} int Entity::entityCounter = 2048; // 4J - changed initialiser to 2048, as we are using range 0 - 2047 as special unique smaller ids for things that need network tracked +#if defined(_WIN32) DWORD Entity::tlsIdx = TlsAlloc(); +#else +pthread_key_t Entity::tlsIdx = CreateEntityTlsKey(); +#endif // 4J - added getSmallId & freeSmallId methods unsigned int Entity::entityIdUsedFlags[2048/32] = {0}; @@ -44,9 +82,7 @@ int Entity::getSmallId() // for final notification to the client that the entities are removed. We can't go re-using these small Ids yet, as otherwise we will // potentially end up telling the client that the entity has been removed After we have already re-used its Id and created a new entity. // This ends up with newly created client-side entities being removed by accident, causing invisible mobs. - - //4jcraft - i have no idea what 4j was cooking here ngl - if ( ((size_t)pthread_getspecific(tlsIdx) != 0) ) + if( reinterpret_cast(EntityTlsGetValue(tlsIdx)) != 0 ) { MinecraftServer *server = MinecraftServer::getInstance(); if( server ) @@ -127,7 +163,7 @@ void Entity::countFlagsForPIX() void Entity::resetSmallId() { freeSmallId(entityId); - if( ((size_t)pthread_getspecific(tlsIdx) != 0 ) ) + if( reinterpret_cast(EntityTlsGetValue(tlsIdx)) != 0 ) { entityId = getSmallId(); } @@ -135,7 +171,7 @@ void Entity::resetSmallId() void Entity::freeSmallId(int index) { - if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread + if( reinterpret_cast(EntityTlsGetValue(tlsIdx)) == 0 ) return; // Don't do anything with small ids if this isn't the server thread if( index >= 2048 ) return; // Don't do anything if this isn't a short id unsigned int i = index / 32; @@ -148,7 +184,7 @@ void Entity::freeSmallId(int index) void Entity::useSmallIds() { - pthread_setspecific(tlsIdx,(LPVOID)1); + EntityTlsSetValue(tlsIdx, reinterpret_cast(static_cast(1))); } // Things also added here to be able to manage the concept of a number of extra "wandering" entities - normally path finding entities aren't allowed to @@ -158,7 +194,7 @@ void Entity::useSmallIds() // Let the management system here know whether or not to consider this particular entity for some extra wandering void Entity::considerForExtraWandering(bool enable) { - if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return; // Don't do anything with small ids if this isn't the server thread + if( reinterpret_cast(EntityTlsGetValue(tlsIdx)) == 0 ) return; // Don't do anything with small ids if this isn't the server thread if( entityId >= 2048 ) return; // Don't do anything if this isn't a short id unsigned int i = entityId / 32; @@ -178,7 +214,7 @@ void Entity::considerForExtraWandering(bool enable) // Should this entity do wandering in addition to what the java code would have done? bool Entity::isExtraWanderingEnabled() { - if( ( (size_t)pthread_getspecific(tlsIdx) ) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread + if( reinterpret_cast(EntityTlsGetValue(tlsIdx)) == 0 ) return false; // Don't do anything with small ids if this isn't the server thread if( entityId >= 2048 ) return false; // Don't do anything if this isn't a short id for( int i = 0; i < extraWanderCount; i++ ) @@ -241,7 +277,7 @@ void Entity::_init(bool useSmallId) // 4J - changed to assign two different types of ids. A range from 0-2047 is used for things that we'll be wanting to identify over the network, // so we should only need 11 bits rather than 32 to uniquely identify them. The rest of the range is used for anything we don't need to track like this, // currently particles. We only ever want to allocate this type of id from the server thread, so using thread local storage to isolate this. - if( useSmallId && ((size_t)pthread_getspecific(tlsIdx) != 0 ) ) + if( useSmallId && reinterpret_cast(EntityTlsGetValue(tlsIdx)) != 0 ) { entityId = getSmallId(); } diff --git a/Minecraft.World/Entities/Entity.h b/Minecraft.World/Entities/Entity.h index bb64e3b79..10cc1553c 100644 --- a/Minecraft.World/Entities/Entity.h +++ b/Minecraft.World/Entities/Entity.h @@ -5,7 +5,9 @@ #include "../IO/NBT/FloatTag.h" #include "../Util/Vec3.h" #include "../Util/Definitions.h" +#if !defined(_WIN32) #include +#endif class Mob; class LightningBolt; diff --git a/Minecraft.World/Entities/EntityEvent.h b/Minecraft.World/Entities/EntityEvent.h index 4d2064aba..8e94bac1c 100644 --- a/Minecraft.World/Entities/EntityEvent.h +++ b/Minecraft.World/Entities/EntityEvent.h @@ -1,29 +1,30 @@ #pragma once +#include class EntityEvent { public: - static const BYTE JUMP = 1; - static const BYTE HURT = 2; - static const BYTE DEATH = 3; - static const BYTE START_ATTACKING = 4; - static const BYTE STOP_ATTACKING = 5; + static const std::uint8_t JUMP = 1; + static const std::uint8_t HURT = 2; + static const std::uint8_t DEATH = 3; + static const std::uint8_t START_ATTACKING = 4; + static const std::uint8_t STOP_ATTACKING = 5; - static const BYTE TAMING_FAILED = 6; - static const BYTE TAMING_SUCCEEDED = 7; - static const BYTE SHAKE_WETNESS = 8; + static const std::uint8_t TAMING_FAILED = 6; + static const std::uint8_t TAMING_SUCCEEDED = 7; + static const std::uint8_t SHAKE_WETNESS = 8; - static const BYTE USE_ITEM_COMPLETE = 9; + static const std::uint8_t USE_ITEM_COMPLETE = 9; - static const BYTE EAT_GRASS = 10; - static const BYTE OFFER_FLOWER = 11; - static const BYTE LOVE_HEARTS = 12; - static const BYTE VILLAGER_ANGRY = 13; - static const BYTE VILLAGER_HAPPY = 14; - static const BYTE WITCH_HAT_MAGIC = 15; - static const BYTE ZOMBIE_CONVERTING = 16; + static const std::uint8_t EAT_GRASS = 10; + static const std::uint8_t OFFER_FLOWER = 11; + static const std::uint8_t LOVE_HEARTS = 12; + static const std::uint8_t VILLAGER_ANGRY = 13; + static const std::uint8_t VILLAGER_HAPPY = 14; + static const std::uint8_t WITCH_HAT_MAGIC = 15; + static const std::uint8_t ZOMBIE_CONVERTING = 16; - static const BYTE FIREWORKS_EXPLODE = 17; + static const std::uint8_t FIREWORKS_EXPLODE = 17; - static const BYTE IN_LOVE_HEARTS = 18; -}; \ No newline at end of file + static const std::uint8_t IN_LOVE_HEARTS = 18; +}; diff --git a/Minecraft.World/Entities/Mob.cpp b/Minecraft.World/Entities/Mob.cpp index 4b64f0363..44e733151 100644 --- a/Minecraft.World/Entities/Mob.cpp +++ b/Minecraft.World/Entities/Mob.cpp @@ -1097,7 +1097,7 @@ void Mob::addAdditonalSaveData(CompoundTag *entityTag) MobEffectInstance *effect = it->second; CompoundTag *tag = new CompoundTag(); - tag->putByte(L"Id", (BYTE) effect->getId()); + tag->putByte(L"Id", static_cast(effect->getId())); tag->putByte(L"Amplifier", (char) effect->getAmplifier()); tag->putInt(L"Duration", effect->getDuration()); listTag->add(tag); diff --git a/Minecraft.World/IO/Files/ConsoleSaveFile.h b/Minecraft.World/IO/Files/ConsoleSaveFile.h index 818964175..63679bfac 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFile.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFile.h @@ -3,6 +3,13 @@ #include "FileHeader.h" #include "ConsoleSavePath.h" +enum class SaveFileSeekOrigin +{ + Begin, + Current, + End +}; + class ConsoleSaveFile { public: @@ -10,11 +17,11 @@ public: virtual FileEntry *createFile( const ConsoleSavePath &fileName ) = 0; virtual void deleteFile( FileEntry *file ) = 0; - virtual void setFilePointer( FileEntry *file,LONG lDistanceToMove, PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod) = 0; - virtual BOOL writeFile( FileEntry *file, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) = 0; - virtual BOOL zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) = 0; - virtual BOOL readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead ) = 0; - virtual BOOL closeHandle( FileEntry *file ) = 0; + virtual void setFilePointer( FileEntry *file, unsigned int distanceToMove, SaveFileSeekOrigin seekOrigin ) = 0; + virtual bool writeFile( FileEntry *file, const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) = 0; + virtual bool zeroFile(FileEntry *file, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) = 0; + virtual bool readFile( FileEntry *file, void *lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead ) = 0; + virtual bool closeHandle( FileEntry *file ) = 0; virtual void finalizeWrite() = 0; virtual void tick() {}; diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp index 439c819fb..819156385 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileConverter.cpp @@ -7,10 +7,10 @@ void ConsoleSaveFileConverter::ProcessSimpleFile(ConsoleSaveFile *sourceSave, FileEntry *sourceFileEntry, ConsoleSaveFile *targetSave, FileEntry *targetFileEntry) { - DWORD numberOfBytesRead = 0; - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; - uint8_t *data = new uint8_t[sourceFileEntry->getFileSize()]; + std::uint8_t *data = new std::uint8_t[sourceFileEntry->getFileSize()]; // Read from source sourceSave->readFile(sourceFileEntry, data, sourceFileEntry->getFileSize(), &numberOfBytesRead); @@ -23,8 +23,8 @@ void ConsoleSaveFileConverter::ProcessSimpleFile(ConsoleSaveFile *sourceSave, Fi void ConsoleSaveFileConverter::ProcessStandardRegionFile(ConsoleSaveFile *sourceSave, File sourceFile, ConsoleSaveFile *targetSave, File targetFile) { - DWORD numberOfBytesWritten = 0; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; RegionFile sourceRegionFile(sourceSave, &sourceFile); RegionFile targetRegionFile(targetSave, &targetFile); diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp index 35cd702c7..7f60b210e 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileInputStream.cpp @@ -9,7 +9,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile m_saveFile = saveFile; m_file = m_saveFile->createFile( file ); - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, SaveFileSeekOrigin::Begin ); } ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile, FileEntry *file) @@ -17,7 +17,7 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile m_saveFile = saveFile; m_file = file; - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, SaveFileSeekOrigin::Begin ); } //Reads a byte of data from this input stream. This method blocks if no input is yet available. @@ -25,17 +25,17 @@ ConsoleSaveFileInputStream::ConsoleSaveFileInputStream(ConsoleSaveFile *saveFile //the next byte of data, or -1 if the end of the file is reached. int ConsoleSaveFileInputStream::read() { - uint8_t byteRead = static_cast(0); - DWORD numberOfBytesRead; + std::uint8_t byteRead = static_cast(0); + unsigned int numberOfBytesRead; - BOOL result = m_saveFile->readFile( + bool result = m_saveFile->readFile( m_file, &byteRead, // data buffer 1, // number of bytes to read &numberOfBytesRead // number of bytes read ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling return -1; @@ -56,16 +56,16 @@ int ConsoleSaveFileInputStream::read() //the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached. int ConsoleSaveFileInputStream::read(byteArray b) { - DWORD numberOfBytesRead; + unsigned int numberOfBytesRead; - BOOL result = m_saveFile->readFile( + bool result = m_saveFile->readFile( m_file, &b.data, // data buffer b.length, // number of bytes to read &numberOfBytesRead // number of bytes read ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling return -1; @@ -92,16 +92,16 @@ int ConsoleSaveFileInputStream::read(byteArray b, unsigned int offset, unsigned // 4J Stu - We don't want to read any more than the array buffer can hold assert( length <= ( b.length - offset ) ); - DWORD numberOfBytesRead; + unsigned int numberOfBytesRead; - BOOL result = m_saveFile->readFile( + bool result = m_saveFile->readFile( m_file, &b[offset], // data buffer length, // number of bytes to read &numberOfBytesRead // number of bytes read ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling return -1; @@ -121,9 +121,9 @@ void ConsoleSaveFileInputStream::close() { if( m_saveFile != NULL ) { - BOOL result = m_saveFile->closeHandle( m_file ); + bool result = m_saveFile->closeHandle( m_file ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling } diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp index a5bce2de1..d3030fdd4 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.cpp @@ -1,5 +1,6 @@ #include "../../Platform/stdafx.h" #include "../../Util/StringHelpers.h" +#include "../../Util/PortableFileIO.h" #include "ConsoleSaveFileOriginal.h" #include "File.h" #include @@ -23,7 +24,7 @@ unsigned int ConsoleSaveFileOriginal::pagesCommitted = 0; void *ConsoleSaveFileOriginal::pvHeap = NULL; -ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, LPVOID pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) +ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData /*= NULL*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { InitializeCriticalSectionAndSpinCount(&m_lock,5120); @@ -43,7 +44,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, L pvSaveMem = pvHeap; m_fileName = fileName; - DWORD fileSize = dFileSize; + unsigned int fileSize = initialFileSize; // Load a save from the game rules bool bLevelGenBaseSave = false; @@ -60,7 +61,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, L if( forceCleanSave ) fileSize = 0; - DWORD heapSize = std::max( fileSize, (DWORD)(1024 * 1024 * 2)); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with + unsigned int heapSize = std::max(fileSize, 1024u * 1024u * 2u); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with // Initially committ enough room to store headSize bytes (using CSF_PAGE_SIZE pages, so rounding up here). We should only ever have one save file at a time, // and the pages should be decommitted in the dtor, so pages committed should always be zero at this point. @@ -172,9 +173,9 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(const std::wstring &fileName, L } // Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries - DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; + unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; - DWORD desiredSize = decompSize; + unsigned int desiredSize = decompSize; if( desiredSize > currentHeapSize ) { @@ -238,13 +239,13 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file ) LockSaveAccess(); - DWORD numberOfBytesRead = 0; - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; const int bufferSize = 4096; int amountToRead = bufferSize; - uint8_t buffer[bufferSize]; - DWORD bufferDataSize = 0; + std::uint8_t buffer[bufferSize]; + unsigned int bufferDataSize = 0; char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize(); @@ -298,22 +299,29 @@ void ConsoleSaveFileOriginal::deleteFile( FileEntry *file ) ReleaseSaveAccess(); } -void ConsoleSaveFileOriginal::setFilePointer(FileEntry *file,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod) +void ConsoleSaveFileOriginal::setFilePointer(FileEntry *file, unsigned int distanceToMove, SaveFileSeekOrigin seekOrigin) { LockSaveAccess(); - file->currentFilePointer = file->data.startOffset + lDistanceToMove; - - if( dwMoveMethod == FILE_END) + switch( seekOrigin ) { - file->currentFilePointer += file->getFileSize(); + case SaveFileSeekOrigin::Current: + file->currentFilePointer += distanceToMove; + break; + case SaveFileSeekOrigin::End: + file->currentFilePointer = file->data.startOffset + file->getFileSize() + distanceToMove; + break; + case SaveFileSeekOrigin::Begin: + default: + file->currentFilePointer = file->data.startOffset + distanceToMove; + break; } ReleaseSaveAccess(); } // If this file needs to grow, move the data after along -void ConsoleSaveFileOriginal::PrepareForWrite( FileEntry *file, DWORD nNumberOfBytesToWrite ) +void ConsoleSaveFileOriginal::PrepareForWrite( FileEntry *file, unsigned int nNumberOfBytesToWrite ) { int bytesToGrowBy = ( (file->currentFilePointer - file->data.startOffset) + nNumberOfBytesToWrite) - file->getFileSize(); if( bytesToGrowBy <= 0 ) @@ -336,12 +344,12 @@ void ConsoleSaveFileOriginal::PrepareForWrite( FileEntry *file, DWORD nNumberOfB finalizeWrite(); } -BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) +bool ConsoleSaveFileOriginal::writeFile(FileEntry *file,const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) { assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } LockSaveAccess(); @@ -370,15 +378,15 @@ BOOL ConsoleSaveFileOriginal::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) +bool ConsoleSaveFileOriginal::zeroFile(FileEntry *file, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) { assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } LockSaveAccess(); @@ -407,16 +415,16 @@ BOOL ConsoleSaveFileOriginal::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWr ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileOriginal::readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead) +bool ConsoleSaveFileOriginal::readFile( FileEntry *file, void *lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead) { - DWORD actualBytesToRead; + unsigned int actualBytesToRead; assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } LockSaveAccess(); @@ -447,16 +455,16 @@ BOOL ConsoleSaveFileOriginal::readFile( FileEntry *file, LPVOID lpBuffer, DWORD ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileOriginal::closeHandle( FileEntry *file ) +bool ConsoleSaveFileOriginal::closeHandle( FileEntry *file ) { LockSaveAccess(); finalizeWrite(); ReleaseSaveAccess(); - return TRUE; + return true; } void ConsoleSaveFileOriginal::finalizeWrite() @@ -466,23 +474,23 @@ void ConsoleSaveFileOriginal::finalizeWrite() ReleaseSaveAccess(); } -void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesToWrite) +void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, unsigned int nNumberOfBytesToWrite) { - DWORD numberOfBytesRead = 0; - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; - const DWORD bufferSize = 4096; - DWORD amountToRead = bufferSize; + const unsigned int bufferSize = 4096; + unsigned int amountToRead = bufferSize; //assert( nNumberOfBytesToWrite <= bufferSize ); - static uint8_t buffer1[bufferSize]; - static uint8_t buffer2[bufferSize]; - DWORD buffer1Size = 0; - DWORD buffer2Size = 0; + static std::uint8_t buffer1[bufferSize]; + static std::uint8_t buffer2[bufferSize]; + unsigned int buffer1Size = 0; + unsigned int buffer2Size = 0; // Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries - DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; + unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; - DWORD desiredSize = header.GetFileSize() + nNumberOfBytesToWrite; + unsigned int desiredSize = header.GetFileSize() + nNumberOfBytesToWrite; if( desiredSize > currentHeapSize ) { @@ -569,7 +577,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond(FileEntry *file, DWORD nNumberOfByt // Fill buffer 1 from file if( (readStartOffset - bufferSize) < spaceStartOffset ) { - amountToRead = (DWORD)(readStartOffset - spaceStartOffset); + amountToRead = static_cast(readStartOffset - spaceStartOffset); } else { @@ -666,11 +674,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) // On PS3, don't compress the data as we can't really afford the extra memory this requires for the output buffer. Instead we'll be writing // directly from the save data. StorageManager.SetSaveData(pvSaveMem,fileSize); - uint8_t *compData = (uint8_t *)pvSaveMem; + std::uint8_t *compData = (std::uint8_t *)pvSaveMem; #else // Attempt to allocate the required memory // We do not own this, it belongs to the StorageManager - uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength ); + std::uint8_t *compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength ); #ifdef __PSVITA__ // AP - make sure we always allocate just what is needed so it will only SAVE what is needed. @@ -708,7 +716,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) compLength = compLength+8; // Attempt to allocate the required memory - compData = (uint8_t *)StorageManager.AllocateSaveData( compLength ); + compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength ); } #endif @@ -742,11 +750,11 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, compLength); #endif - PBYTE pbThumbnailData=NULL; - DWORD dwThumbnailDataSize=0; + std::uint8_t *pbThumbnailData = NULL; + unsigned int dwThumbnailDataSize = 0; - PBYTE pbDataSaveImage=NULL; - DWORD dwDataSizeSaveImage=0; + std::uint8_t *pbDataSaveImage = NULL; + unsigned int dwDataSizeSaveImage = 0; #if ( defined _XBOX || defined _DURANGO ) app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); @@ -754,7 +762,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage); #endif - BYTE bTextMetadata[88]; + std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata,88); __int64 seed = 0; @@ -816,7 +824,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail ) #if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64) -int ConsoleSaveFileOriginal::SaveSaveDataCallback(LPVOID lpParam,bool bRes) +int ConsoleSaveFileOriginal::SaveSaveDataCallback(void *lpParam, bool bRes) { ConsoleSaveFile *pClass=(ConsoleSaveFile *)lpParam; @@ -834,7 +842,7 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, unsigned int fileSize = header.GetFileSize(); - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; #ifdef _XBOX File targetFileDir(L"GAME:\\Saves"); #else @@ -859,23 +867,19 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, } swprintf(fileName, XCONTENT_MAX_FILENAME_LENGTH+1, L"\\v%04d-%ls%02d.%02d.%02d.%02d.%02d.mcs",VER_PRODUCTBUILD,cutFileName.c_str(), t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); -#ifdef _UNICODE - std::wstring wtemp = targetFileDir.getPath() + std::wstring(fileName); - LPCWSTR lpFileName = wtemp.c_str(); -#else - LPCSTR lpFileName = wstringtofilename( targetFileDir.getPath() + std::wstring(fileName) ); -#endif + const std::wstring outputPath = targetFileDir.getPath() + std::wstring(fileName); #ifndef __PSVITA__ - HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + bool writeSucceeded = false; #endif if(compressedData != NULL && compressedDataSize > 0) { #ifdef __PSVITA__ // AP - Use the access function to save - VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); + VirtualWriteFile( outputPath.c_str(), compressedData, compressedDataSize, &numberOfBytesWritten, NULL); #else - WriteFile( hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); + writeSucceeded = PortableFileIO::WriteBinaryFile(outputPath, compressedData, compressedDataSize); + numberOfBytesWritten = writeSucceeded ? compressedDataSize : 0; #endif assert(numberOfBytesWritten == compressedDataSize); } @@ -883,15 +887,13 @@ void ConsoleSaveFileOriginal::DebugFlushToFile(void *compressedData /*= NULL*/, { #ifdef __PSVITA__ // AP - Use the access function to save - VirtualWriteFile( lpFileName, compressedData, compressedDataSize, &numberOfBytesWritten, NULL); + VirtualWriteFile( outputPath.c_str(), compressedData, compressedDataSize, &numberOfBytesWritten, NULL); #else - WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); + writeSucceeded = PortableFileIO::WriteBinaryFile(outputPath, pvSaveMem, fileSize); + numberOfBytesWritten = writeSucceeded ? fileSize : 0; #endif assert(numberOfBytesWritten == fileSize); } -#ifndef __PSVITA__ - CloseHandle( hSaveFile ); -#endif delete[] fileName; @@ -997,8 +999,8 @@ bool ConsoleSaveFileOriginal::isLocalEndianDifferent( ESavePlatform plat ) void ConsoleSaveFileOriginal::ConvertRegionFile(File sourceFile) { - DWORD numberOfBytesWritten = 0; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; RegionFile sourceRegionFile(this, &sourceFile); @@ -1064,4 +1066,4 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform() void *ConsoleSaveFileOriginal::getWritePointer(FileEntry *file) { return (char *)pvSaveMem + file->currentFilePointer;; -} \ No newline at end of file +} diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h index 123d4828a..6cbf2ce4b 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOriginal.h @@ -24,18 +24,18 @@ private: static const unsigned int CSF_PAGE_SIZE = 64 * 1024; static const unsigned int MAX_PAGE_COUNT = 1024; #endif - LPVOID pvSaveMem; + void *pvSaveMem; CRITICAL_SECTION m_lock; - void PrepareForWrite( FileEntry *file, DWORD nNumberOfBytesToWrite ); - void MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesToWrite); + void PrepareForWrite( FileEntry *file, unsigned int nNumberOfBytesToWrite ); + void MoveDataBeyond(FileEntry *file, unsigned int nNumberOfBytesToWrite); public: #if (defined __PS3__ || defined __ORBIS__ || defined __PSVITA__ || defined _DURANGO || defined _WINDOWS64) - static int SaveSaveDataCallback(LPVOID lpParam,bool bRes); + static int SaveSaveDataCallback(void *lpParam, bool bRes); #endif - ConsoleSaveFileOriginal(const std::wstring &fileName, LPVOID pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); + ConsoleSaveFileOriginal(const std::wstring &fileName, void *pvSaveData = NULL, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); virtual ~ConsoleSaveFileOriginal(); // 4J Stu - Initial implementation is intended to have a similar interface to the standard Xbox file access functions @@ -43,11 +43,11 @@ public: virtual FileEntry *createFile( const ConsoleSavePath &fileName ); virtual void deleteFile( FileEntry *file ); - virtual void setFilePointer(FileEntry *file,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod); - virtual BOOL writeFile( FileEntry *file, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten ); - virtual BOOL zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten); - virtual BOOL readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead ); - virtual BOOL closeHandle( FileEntry *file ); + virtual void setFilePointer(FileEntry *file, unsigned int distanceToMove, SaveFileSeekOrigin seekOrigin); + virtual bool writeFile( FileEntry *file, const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten ); + virtual bool zeroFile(FileEntry *file, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten); + virtual bool readFile( FileEntry *file, void *lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead ); + virtual bool closeHandle( FileEntry *file ); virtual void finalizeWrite(); @@ -91,4 +91,4 @@ public: protected: virtual void *getWritePointer(FileEntry *file); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp index 2193991e8..93a42efb7 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileOutputStream.cpp @@ -19,7 +19,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi m_file = m_saveFile->createFile(file); - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, SaveFileSeekOrigin::Begin ); } ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFile, FileEntry *file) @@ -28,7 +28,7 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi m_file = file; - m_saveFile->setFilePointer( m_file, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( m_file, 0, SaveFileSeekOrigin::Begin ); } //Writes the specified byte to this file output stream. Implements the write method of OutputStream. @@ -36,18 +36,18 @@ ConsoleSaveFileOutputStream::ConsoleSaveFileOutputStream(ConsoleSaveFile *saveFi //b - the byte to be written. void ConsoleSaveFileOutputStream::write(unsigned int b) { - DWORD numberOfBytesWritten; + unsigned int numberOfBytesWritten; - uint8_t value = (uint8_t) b; + std::uint8_t value = (std::uint8_t) b; - BOOL result = m_saveFile->writeFile( + bool result = m_saveFile->writeFile( m_file, &value, // data buffer 1, // number of bytes to write &numberOfBytesWritten // number of bytes written ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling } @@ -62,16 +62,16 @@ void ConsoleSaveFileOutputStream::write(unsigned int b) //b - the data. void ConsoleSaveFileOutputStream::write(byteArray b) { - DWORD numberOfBytesWritten; + unsigned int numberOfBytesWritten; - BOOL result = m_saveFile->writeFile( + bool result = m_saveFile->writeFile( m_file, &b.data, // data buffer b.length, // number of bytes to write &numberOfBytesWritten // number of bytes written ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling } @@ -91,16 +91,16 @@ void ConsoleSaveFileOutputStream::write(byteArray b, unsigned int offset, unsign // 4J Stu - We don't want to write any more than the array buffer holds assert( length <= ( b.length - offset ) ); - DWORD numberOfBytesWritten; + unsigned int numberOfBytesWritten; - BOOL result = m_saveFile->writeFile( + bool result = m_saveFile->writeFile( m_file, &b[offset], // data buffer length, // number of bytes to write &numberOfBytesWritten // number of bytes written ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling } @@ -117,9 +117,9 @@ void ConsoleSaveFileOutputStream::close() { if( m_saveFile != NULL ) { - BOOL result = m_saveFile->closeHandle( m_file ); + bool result = m_saveFile->closeHandle( m_file ); - if( result == 0 ) + if( !result ) { // TODO 4J Stu - Some kind of error handling } diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp index 90778f02c..1c363bb48 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp +++ b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.cpp @@ -1,5 +1,6 @@ #include "../../Platform/stdafx.h" #include "../../Util/StringHelpers.h" +#include "../../Util/PortableFileIO.h" #include "ConsoleSaveFileSplit.h" #include "ConsoleSaveFileConverter.h" #include "File.h" @@ -53,7 +54,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Compress() unsigned char *dataIn = data; unsigned char *dataInLast = data + fileEntry->data.length; -// int64_t startTime = System::currentTimeMillis(); +// std::int64_t startTime = System::currentTimeMillis(); // One pass through to work out storage space required for compressed data unsigned int outputSize = 4; // 4 bytes required to store the uncompressed size for faster decompression @@ -188,14 +189,14 @@ void ConsoleSaveFileSplit::RegionFileReference::Compress() } assert(( dataOut - dataCompressed ) == outputSize ); dataCompressedSize = outputSize; -// int64_t endTime = System::currentTimeMillis(); +// std::int64_t endTime = System::currentTimeMillis(); // app.DebugPrintf("Compressing region file 0x%.8x from %d to %d bytes - %dms\n", fileEntry->data.regionIndex, fileEntry->data.length, dataCompressedSize, endTime - startTime); } // Decompress from dataCompressed -> data. See comment in Compress method for format void ConsoleSaveFileSplit::RegionFileReference::Decompress() { -// int64_t startTime = System::currentTimeMillis(); +// std::int64_t startTime = System::currentTimeMillis(); fileEntry->data.length = *((unsigned int *)dataCompressed); // If this is unusually large, then test how big it would be when expanded before trying to allocate. Matching the expanded size @@ -284,7 +285,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Decompress() data = NULL; assert(0); } -// int64_t endTime = System::currentTimeMillis(); +// std::int64_t endTime = System::currentTimeMillis(); // app.DebugPrintf("Decompressing region file from 0x%.8x %d to %d bytes - %dms\n", fileEntry->data.regionIndex, dataCompressedSize, fileEntry->data.length, endTime - startTime);// } @@ -379,9 +380,9 @@ FileEntry *ConsoleSaveFileSplit::GetRegionFileEntry(unsigned int regionIndex) return newRef->fileEntry; } -ConsoleSaveFileSplit::ConsoleSaveFileSplit(const std::wstring &fileName, LPVOID pvSaveData /*= NULL*/, DWORD dFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) +ConsoleSaveFileSplit::ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData /*= NULL*/, unsigned int initialFileSize /*= 0*/, bool forceCleanSave /*= false*/, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL*/) { - DWORD fileSize = dFileSize; + unsigned int fileSize = initialFileSize; // Load a save from the game rules bool bLevelGenBaseSave = false; @@ -418,11 +419,11 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alr std::vector *sourceFiles = sourceSave->getFilesWithPrefix(L""); - DWORD bytesWritten; + unsigned int bytesWritten = 0; for(AUTO_VAR(it, sourceFiles->begin()); it != sourceFiles->end(); ++it) { FileEntry *sourceEntry = *it; - sourceSave->setFilePointer(sourceEntry,0,NULL,FILE_BEGIN); + sourceSave->setFilePointer(sourceEntry, 0, SaveFileSeekOrigin::Begin); FileEntry *targetEntry = createFile(ConsoleSavePath(sourceEntry->data.filename)); @@ -437,7 +438,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alr } } -void ConsoleSaveFileSplit::_init(const std::wstring &fileName, LPVOID pvSaveData, DWORD fileSize, ESavePlatform plat) +void ConsoleSaveFileSplit::_init(const std::wstring &fileName, void *pvSaveData, unsigned int fileSize, ESavePlatform plat) { InitializeCriticalSectionAndSpinCount(&m_lock,5120); @@ -478,7 +479,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring &fileName, LPVOID pvSaveData regionFiles[regionIndex] = regionFileRef; } - DWORD heapSize = std::max( fileSize, (DWORD)(1024 * 1024 * 2)); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with + unsigned int heapSize = std::max(fileSize, 1024u * 1024u * 2u); // 4J Stu - Our files are going to be bigger than 2MB so allocate high to start with // Initially committ enough room to store headSize bytes (using CSF_PAGE_SIZE pages, so rounding up here). We should only ever have one save file at a time, // and the pages should be decommitted in the dtor, so pages committed should always be zero at this point. @@ -537,9 +538,9 @@ void ConsoleSaveFileSplit::_init(const std::wstring &fileName, LPVOID pvSaveData { // Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries - DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; + unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; - DWORD desiredSize = decompSize; + unsigned int desiredSize = decompSize; if( desiredSize > currentHeapSize ) { @@ -636,13 +637,13 @@ void ConsoleSaveFileSplit::deleteFile( FileEntry *file ) LockSaveAccess(); - DWORD numberOfBytesRead = 0; - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; const int bufferSize = 4096; int amountToRead = bufferSize; - uint8_t buffer[bufferSize]; - DWORD bufferDataSize = 0; + std::uint8_t buffer[bufferSize]; + unsigned int bufferDataSize = 0; char *readStartOffset = (char *)pvSaveMem + file->data.startOffset + file->getFileSize(); @@ -686,29 +687,36 @@ void ConsoleSaveFileSplit::deleteFile( FileEntry *file ) ReleaseSaveAccess(); } -void ConsoleSaveFileSplit::setFilePointer(FileEntry *file,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod) +void ConsoleSaveFileSplit::setFilePointer(FileEntry *file, unsigned int distanceToMove, SaveFileSeekOrigin seekOrigin) { LockSaveAccess(); - if( file->isRegionFile() ) + if( seekOrigin == SaveFileSeekOrigin::Current ) { - file->currentFilePointer = lDistanceToMove; + file->currentFilePointer += distanceToMove; } else { - file->currentFilePointer = file->data.startOffset + lDistanceToMove; - } + if( file->isRegionFile() ) + { + file->currentFilePointer = distanceToMove; + } + else + { + file->currentFilePointer = file->data.startOffset + distanceToMove; + } - if( dwMoveMethod == FILE_END) - { - file->currentFilePointer += file->getFileSize(); + if( seekOrigin == SaveFileSeekOrigin::End ) + { + file->currentFilePointer += file->getFileSize(); + } } ReleaseSaveAccess(); } // If this file needs to grow, move the data after along -void ConsoleSaveFileSplit::PrepareForWrite( FileEntry *file, DWORD nNumberOfBytesToWrite ) +void ConsoleSaveFileSplit::PrepareForWrite( FileEntry *file, unsigned int nNumberOfBytesToWrite ) { int bytesToGrowBy = ( (file->currentFilePointer - file->data.startOffset) + nNumberOfBytesToWrite) - file->getFileSize(); if( bytesToGrowBy <= 0 ) @@ -733,12 +741,12 @@ void ConsoleSaveFileSplit::PrepareForWrite( FileEntry *file, DWORD nNumberOfByte finalizeWrite(); } -BOOL ConsoleSaveFileSplit::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) +bool ConsoleSaveFileSplit::writeFile(FileEntry *file,const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) { assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } LockSaveAccess(); @@ -783,15 +791,15 @@ BOOL ConsoleSaveFileSplit::writeFile(FileEntry *file,LPCVOID lpBuffer, DWORD nNu ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileSplit::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten) +bool ConsoleSaveFileSplit::zeroFile(FileEntry *file, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten) { assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } // 4jcraft added: memset(NULL + 0, 0, 0); was called @@ -845,16 +853,16 @@ BOOL ConsoleSaveFileSplit::zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileSplit::readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead) +bool ConsoleSaveFileSplit::readFile( FileEntry *file, void *lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead) { - DWORD actualBytesToRead; + unsigned int actualBytesToRead; assert( pvSaveMem != NULL ); if( pvSaveMem == NULL ) { - return 0; + return false; } LockSaveAccess(); @@ -897,22 +905,22 @@ BOOL ConsoleSaveFileSplit::readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNu ReleaseSaveAccess(); - return 1; + return true; } -BOOL ConsoleSaveFileSplit::closeHandle( FileEntry *file ) +bool ConsoleSaveFileSplit::closeHandle( FileEntry *file ) { LockSaveAccess(); finalizeWrite(); ReleaseSaveAccess(); - return TRUE; + return true; } // In this method, attempt to write any dirty region files, subject to maintaining a maximum write output rate. Writing is prioritised by time since the region was last written. void ConsoleSaveFileSplit::tick() { - int64_t currentTime = System::currentTimeMillis(); + std::int64_t currentTime = System::currentTimeMillis(); // Don't do anything if the save system is up to something... if( StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle ) @@ -1045,23 +1053,23 @@ void ConsoleSaveFileSplit::finalizeWrite() ReleaseSaveAccess(); } -void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesToWrite) +void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, unsigned int nNumberOfBytesToWrite) { - DWORD numberOfBytesRead = 0; - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; - const DWORD bufferSize = 4096; - DWORD amountToRead = bufferSize; + const unsigned int bufferSize = 4096; + unsigned int amountToRead = bufferSize; //assert( nNumberOfBytesToWrite <= bufferSize ); - static uint8_t buffer1[bufferSize]; - static uint8_t buffer2[bufferSize]; - DWORD buffer1Size = 0; - DWORD buffer2Size = 0; + static std::uint8_t buffer1[bufferSize]; + static std::uint8_t buffer2[bufferSize]; + unsigned int buffer1Size = 0; + unsigned int buffer2Size = 0; // Only ReAlloc if we need to (we might already have enough) and align to 512 byte boundaries - DWORD currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; + unsigned int currentHeapSize = pagesCommitted * CSF_PAGE_SIZE; - DWORD desiredSize = header.GetFileSize() + nNumberOfBytesToWrite; + unsigned int desiredSize = header.GetFileSize() + nNumberOfBytesToWrite; if( desiredSize > currentHeapSize ) { @@ -1143,7 +1151,7 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesT // Fill buffer 1 from file if( (readStartOffset - bufferSize) < spaceStartOffset ) { - amountToRead = (DWORD)(readStartOffset - spaceStartOffset); + amountToRead = static_cast(readStartOffset - spaceStartOffset); } else { @@ -1362,7 +1370,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) // Attempt to allocate the required memory // We do not own this, it belongs to the StorageManager - uint8_t *compData = (uint8_t *)StorageManager.AllocateSaveData( compLength ); + std::uint8_t *compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength ); // If we failed to allocate then compData will be NULL // Pre-calculate the compressed data size so that we can attempt to allocate a smaller buffer @@ -1389,7 +1397,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) compLength = compLength+8; // Attempt to allocate the required memory - compData = (uint8_t *)StorageManager.AllocateSaveData( compLength ); + compData = (std::uint8_t *)StorageManager.AllocateSaveData( compLength ); } if(compData != NULL) @@ -1416,11 +1424,11 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) if(updateThumbnail) { - PBYTE pbThumbnailData=NULL; - DWORD dwThumbnailDataSize=0; + std::uint8_t *pbThumbnailData = NULL; + unsigned int dwThumbnailDataSize = 0; - PBYTE pbDataSaveImage=NULL; - DWORD dwDataSizeSaveImage=0; + std::uint8_t *pbDataSaveImage = NULL; + unsigned int dwDataSizeSaveImage = 0; #if ( defined _XBOX || defined _DURANGO ) app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize); @@ -1428,7 +1436,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) app.GetSaveThumbnail(&pbThumbnailData,&dwThumbnailDataSize,&pbDataSaveImage,&dwDataSizeSaveImage); #endif - BYTE bTextMetadata[88]; + std::uint8_t bTextMetadata[88]; ZeroMemory(bTextMetadata,88); __int64 seed = 0; @@ -1466,7 +1474,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) } } -int ConsoleSaveFileSplit::SaveSaveDataCallback(LPVOID lpParam,bool bRes) +int ConsoleSaveFileSplit::SaveSaveDataCallback(void *lpParam, bool bRes) { ConsoleSaveFileSplit *pClass=(ConsoleSaveFileSplit *)lpParam; @@ -1479,7 +1487,7 @@ int ConsoleSaveFileSplit::SaveSaveDataCallback(LPVOID lpParam,bool bRes) return 0; } -int ConsoleSaveFileSplit::SaveRegionFilesCallback(LPVOID lpParam,bool bRes) +int ConsoleSaveFileSplit::SaveRegionFilesCallback(void *lpParam, bool bRes) { ConsoleSaveFileSplit *pClass=(ConsoleSaveFileSplit *)lpParam; @@ -1498,7 +1506,7 @@ void ConsoleSaveFileSplit::DebugFlushToFile(void *compressedData /*= NULL*/, uns unsigned int fileSize = header.GetFileSize(); - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; File targetFileDir(L"Saves"); @@ -1520,26 +1528,21 @@ void ConsoleSaveFileSplit::DebugFlushToFile(void *compressedData /*= NULL*/, uns } swprintf(fileName, XCONTENT_MAX_FILENAME_LENGTH+1, L"\\v%04d-%ls%02d.%02d.%02d.%02d.%02d.mcs",VER_PRODUCTBUILD,cutFileName.c_str(), t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond); -#ifdef _UNICODE - std::wstring wtemp = targetFileDir.getPath() + std::wstring(fileName); - LPCWSTR lpFileName = wtemp.c_str(); -#else - LPCSTR lpFileName = wstringtofilename( targetFileDir.getPath() + std::wstring(fileName) ); -#endif - - HANDLE hSaveFile = CreateFile( lpFileName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_FLAG_RANDOM_ACCESS, NULL); + const std::wstring outputPath = targetFileDir.getPath() + std::wstring(fileName); + bool writeSucceeded = false; if(compressedData != NULL && compressedDataSize > 0) { - WriteFile(hSaveFile,compressedData,compressedDataSize,&numberOfBytesWritten,NULL); + writeSucceeded = PortableFileIO::WriteBinaryFile(outputPath, compressedData, compressedDataSize); + numberOfBytesWritten = writeSucceeded ? compressedDataSize : 0; assert(numberOfBytesWritten == compressedDataSize); } else { - WriteFile(hSaveFile,pvSaveMem,fileSize,&numberOfBytesWritten,NULL); + writeSucceeded = PortableFileIO::WriteBinaryFile(outputPath, pvSaveMem, fileSize); + numberOfBytesWritten = writeSucceeded ? fileSize : 0; assert(numberOfBytesWritten == fileSize); } - CloseHandle( hSaveFile ); delete[] fileName; @@ -1656,8 +1659,8 @@ void ConsoleSaveFileSplit::setEndian(ByteOrder endian) void ConsoleSaveFileSplit::ConvertRegionFile(File sourceFile) { - DWORD numberOfBytesWritten = 0; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesWritten = 0; + unsigned int numberOfBytesRead = 0; RegionFile sourceRegionFile(this, &sourceFile); diff --git a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h index afb9eecad..e0f1eeef9 100644 --- a/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h +++ b/Minecraft.World/IO/Files/ConsoleSaveFileSplit.h @@ -19,14 +19,14 @@ private: class WriteHistory { public: - int64_t writeTime; + std::int64_t writeTime; unsigned int writeSize; } ; class DirtyRegionFile { public: - int64_t lastWritten; + std::int64_t lastWritten; unsigned int fileRef; bool operator<(const DirtyRegionFile& rhs) const { return lastWritten < rhs.lastWritten; } }; @@ -46,11 +46,11 @@ private: unsigned int dataCompressedSize; int index; bool dirty; - int64_t lastWritten; + std::int64_t lastWritten; }; std::unordered_map regionFiles; std::vector writeHistory; - int64_t m_lastTickTime; + std::int64_t m_lastTickTime; FileEntry *GetRegionFileEntry(unsigned int regionIndex); @@ -67,26 +67,26 @@ private: static const unsigned int CSF_PAGE_SIZE = 64 * 1024; static const unsigned int MAX_PAGE_COUNT = 1024; #endif - LPVOID pvSaveMem; + void *pvSaveMem; CRITICAL_SECTION m_lock; - void PrepareForWrite( FileEntry *file, DWORD nNumberOfBytesToWrite ); - void MoveDataBeyond(FileEntry *file, DWORD nNumberOfBytesToWrite); + void PrepareForWrite( FileEntry *file, unsigned int nNumberOfBytesToWrite ); + void MoveDataBeyond(FileEntry *file, unsigned int nNumberOfBytesToWrite); bool GetNumericIdentifierFromName(const std::wstring &fileName, unsigned int *idOut); std::wstring GetNameFromNumericIdentifier(unsigned int idIn); void processSubfilesForWrite(); void processSubfilesAfterWrite(); public: - static int SaveSaveDataCallback(LPVOID lpParam,bool bRes); - static int SaveRegionFilesCallback(LPVOID lpParam,bool bRes); + static int SaveSaveDataCallback(void *lpParam, bool bRes); + static int SaveRegionFilesCallback(void *lpParam, bool bRes); private: - void _init(const std::wstring &fileName, LPVOID pvSaveData, DWORD fileSize, ESavePlatform plat); + void _init(const std::wstring &fileName, void *pvSaveData, unsigned int fileSize, ESavePlatform plat); public: - ConsoleSaveFileSplit(const std::wstring &fileName, LPVOID pvSaveData = NULL, DWORD fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); + ConsoleSaveFileSplit(const std::wstring &fileName, void *pvSaveData = NULL, unsigned int fileSize = 0, bool forceCleanSave = false, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); ConsoleSaveFileSplit(ConsoleSaveFile *sourceSave, bool alreadySmallRegions = true, ProgressListener *progress = NULL); virtual ~ConsoleSaveFileSplit(); @@ -95,11 +95,11 @@ public: virtual FileEntry *createFile( const ConsoleSavePath &fileName ); virtual void deleteFile( FileEntry *file ); - virtual void setFilePointer(FileEntry *file,LONG lDistanceToMove,PLONG lpDistanceToMoveHigh,DWORD dwMoveMethod); - virtual BOOL writeFile( FileEntry *file, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten ); - virtual BOOL zeroFile(FileEntry *file, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten); - virtual BOOL readFile( FileEntry *file, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead ); - virtual BOOL closeHandle( FileEntry *file ); + virtual void setFilePointer(FileEntry *file, unsigned int distanceToMove, SaveFileSeekOrigin seekOrigin); + virtual bool writeFile( FileEntry *file, const void *lpBuffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten ); + virtual bool zeroFile(FileEntry *file, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten); + virtual bool readFile( FileEntry *file, void *lpBuffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead ); + virtual bool closeHandle( FileEntry *file ); virtual void finalizeWrite(); virtual void tick(); diff --git a/Minecraft.World/IO/Files/File.cpp b/Minecraft.World/IO/Files/File.cpp index e2326d25e..1056cf0f0 100644 --- a/Minecraft.World/IO/Files/File.cpp +++ b/Minecraft.World/IO/Files/File.cpp @@ -3,6 +3,11 @@ #include "../../Level/Storage/McRegionLevelStorageSource.h" #include "File.h" +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) +#include +#include +#endif + #ifdef __PS3__ #include #endif @@ -17,6 +22,34 @@ const std::wstring File::pathRoot = L"GAME:"; // Path root after pathSeparator h const std::wstring File::pathRoot = L""; // Path root after pathSeparator has been removed #endif +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) +namespace +{ + namespace fs = std::filesystem; + + fs::path ToFilesystemPath(const std::wstring& path) + { + const std::string nativePath = wstringtofilename(path); + return fs::u8path(nativePath); + } + + std::wstring ToFilename(const fs::path& path) + { + const std::string filename = path.filename().u8string(); + return filenametowstring(filename.c_str()); + } + + __int64 ToEpochMilliseconds(const fs::file_time_type& fileTime) + { + using namespace std::chrono; + + const auto systemTime = time_point_cast( + fileTime - fs::file_time_type::clock::now() + system_clock::now()); + return static_cast<__int64>(systemTime.time_since_epoch().count()); + } +} +#endif + //Creates a new File instance from a parent abstract pathname and a child pathname string. File::File( const File &parent, const std::wstring& child ) { @@ -97,18 +130,47 @@ this->parent = NULL; //true if and only if the file or directory is successfully deleted; false otherwise bool File::_delete() { +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + const bool result = fs::remove(ToFilesystemPath(getPath()), error); #if defined _UNICODE - BOOL result = DeleteFile( getPath().c_str() ); + if( !result || error ) + { +#ifndef _CONTENT_PACKAGE + printf( "File::_delete - Error code %d (%#0.8X)\n", error.value(), error.value() ); +#endif + return false; + } + return true; +#elif defined(__linux__) + if( !result || error ) + { + printf("Unable to delete file :("); + return false; + } + return true; +#else + if( !result || error ) + { +#ifndef _CONTENT_PACKAGE + printf( "File::_delete - Error code %d (%#0.8X)\n", error.value(), error.value() ); +#endif + return false; + } + return true; +#endif +#elif defined _UNICODE + const bool result = DeleteFile( getPath().c_str() ) != 0; #elif defined(__linux__) // FIXME - BOOL result = 0; + const bool result = false; #else - BOOL result = DeleteFile( wstringtofilename(getPath()) ); + const bool result = DeleteFile( wstringtofilename(getPath()) ) != 0; #endif - if( result == 0 ) + if( !result ) { #if !defined(__linux__) - DWORD error = GetLastError(); + const unsigned int error = GetLastError(); #ifndef _CONTENT_PACKAGE printf( "File::_delete - Error code %d (%#0.8X)\n", error, error ); #endif @@ -126,7 +188,10 @@ bool File::_delete() //true if and only if the directory was created; false otherwise bool File::mkdir() const { -#if defined (_UNICODE) +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + return fs::create_directory(ToFilesystemPath(getPath()), error); +#elif defined (_UNICODE) return CreateDirectory( getPath().c_str(), NULL) != 0; #elif defined(__linux__) return ::mkdir(wstringtofilename(getPath()), 0777) == 0; @@ -157,6 +222,22 @@ bool File::mkdir() const // bool File::mkdirs() const { +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + const fs::path path = ToFilesystemPath(getPath()); + + if( fs::exists(path, error) ) + { + return fs::is_directory(path, error); + } + + if( error ) + { + return false; + } + + return fs::create_directories(path, error); +#else std::vector path = stringSplit( m_abstractPathName, pathSeparator ); std::wstring pathToHere = L""; @@ -176,8 +257,8 @@ bool File::mkdirs() const #ifdef _UNICODE if( GetFileAttributes( pathToHere.c_str() ) == -1 ) { - DWORD result = CreateDirectory( pathToHere.c_str(), NULL); - if( result == 0 ) + const bool result = CreateDirectory( pathToHere.c_str(), NULL) != 0; + if( !result ) { // Failed to create return false; @@ -194,8 +275,8 @@ bool File::mkdirs() const #else if( GetFileAttributes( wstringtofilename(pathToHere) ) == -1 ) { - DWORD result = CreateDirectory( wstringtofilename(pathToHere), NULL); - if( result == 0 ) + const bool result = CreateDirectory( wstringtofilename(pathToHere), NULL) != 0; + if( !result ) { // Failed to create return false; @@ -208,6 +289,7 @@ bool File::mkdirs() const assert( exists() ); return true; +#endif } /* @@ -223,7 +305,10 @@ return (File *) parent; bool File::exists() const { // TODO 4J Stu - Possible we could get an error result from something other than the file not existing? -#if defined(_UNICODE) +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + return fs::exists(ToFilesystemPath(getPath()), error); +#elif defined(_UNICODE) return GetFileAttributes( getPath().c_str() ) != -1; #elif defined(__linux__) // BAD DOBBY BAD DOBBY @@ -252,6 +337,16 @@ bool File::isFile() const //true if and only if the renaming succeeded; false otherwise bool File::renameTo(File dest) { +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + fs::rename(ToFilesystemPath(getPath()), ToFilesystemPath(dest.getPath()), error); + if(error) + { + perror("File::renameTo - Error renaming file"); + return false; + } + return true; +#else std::string sourcePath = wstringtofilename(getPath()); std::string destPath = wstringtofilename(dest.getPath()); @@ -266,37 +361,9 @@ bool File::renameTo(File dest) { return true; } +#endif } -#if defined(__linux__) -// DecalOverdose: Stolen from my other project -void listFiles(const char *directory) { - DIR *dp; - struct dirent *entry; - struct stat fileStat; - - dp = opendir(directory); - if (dp == NULL) { - perror("opendir"); - return; - } - - while ((entry = readdir(dp)) != NULL) { - char fullPath[1024]; - snprintf(fullPath, sizeof(fullPath), "%s/%s", directory, entry->d_name); - - if (stat(fullPath, &fileStat) == 0) { - if (S_ISREG(fileStat.st_mode)) { - printf("File: %s\n", entry->d_name); - } - } else { - perror("stat"); - } - } - closedir(dp); -} -#endif // __linux__ - //Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. //If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, //one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory @@ -319,6 +386,13 @@ std::vector *File::listFiles() const if( !isDirectory() ) return vOutput; +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + for( fs::directory_iterator it(ToFilesystemPath(getPath()), error); !error && it != fs::directory_iterator(); it.increment(error) ) + { + vOutput->push_back( new File( *this, ToFilename(it->path()) ) ); + } +#else #ifdef __PS3__ const char *lpFileName=wstringtofilename(getPath()); char filePath[256]; @@ -336,7 +410,7 @@ std::vector *File::listFiles() const CellFsErrno err = cellFsOpendir(filePath , &fd); CellFsDirectoryEntry de; - uint32_t count = 0; + std::uint32_t count = 0; err = cellFsGetDirectoryEntries(fd, &de, sizeof(CellFsDirectoryEntry), &count); if(count != 0) { @@ -422,7 +496,6 @@ std::vector *File::listFiles() const int count = 0; do { - //if( !(wfd.dwFileAttributes & dwAttr) ) vOutput->push_back( new File( *this, wfd.cFileName ) ); } while( FindNextFile( hFind, &wfd) ); @@ -440,13 +513,13 @@ std::vector *File::listFiles() const //int count = 0; do { - //if( !(wfd.dwFileAttributes & dwAttr) ) vOutput->push_back( new File( *this, filenametowstring( wfd.cFileName ) ) ); } while( FindNextFile( hFind, &wfd) ); FindClose( hFind); } #endif +#endif #endif return vOutput; } @@ -469,6 +542,17 @@ std::vector *File::listFiles(FileFilter *filter) const std::vector *vOutput = new std::vector(); +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + for( fs::directory_iterator it(ToFilesystemPath(getPath()), error); !error && it != fs::directory_iterator(); it.increment(error) ) + { + File thisFile = File( *this, ToFilename(it->path()) ); + if( filter->accept( &thisFile ) ) + { + vOutput->push_back( new File( thisFile ) ); + } + } +#else #ifdef __PS3__ const char *lpFileName=wstringtofilename(getPath()); char filePath[256]; @@ -486,7 +570,7 @@ std::vector *File::listFiles(FileFilter *filter) const CellFsErrno err = cellFsOpendir(filePath, &fd); CellFsDirectoryEntry de; - uint32_t count = 0; + std::uint32_t count = 0; err = cellFsGetDirectoryEntries(fd, &de, sizeof(CellFsDirectoryEntry), &count); if(count != 0) { @@ -508,7 +592,6 @@ std::vector *File::listFiles(FileFilter *filter) const WCHAR path[MAX_PATH]; WIN32_FIND_DATA wfd; - DWORD dwAttr = FILE_ATTRIBUTE_DIRECTORY; swprintf( path, L"%ls\\*", getPath().c_str() ); HANDLE hFind = FindFirstFile( path, &wfd); @@ -532,7 +615,6 @@ std::vector *File::listFiles(FileFilter *filter) const #else char path[MAX_PATH]; WIN32_FIND_DATA wfd; - //DWORD dwAttr = FILE_ATTRIBUTE_DIRECTORY; sprintf( path, "%s\\*", wstringtofilename( getPath() ) ); HANDLE hFind = FindFirstFile( path, &wfd); @@ -551,6 +633,7 @@ std::vector *File::listFiles(FileFilter *filter) const FindClose( hFind); } #endif +#endif #endif return vOutput; } @@ -560,7 +643,10 @@ std::vector *File::listFiles(FileFilter *filter) const //true if and only if the file denoted by this abstract pathname exists and is a directory; false otherwise bool File::isDirectory() const { -#if defined(_UNICODE) +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + return fs::is_directory(ToFilesystemPath(getPath()), error); +#elif defined(_UNICODE) return exists() && ( GetFileAttributes( getPath().c_str() ) & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; #elif defined(__linux__) const char *dirpath = wstringtofilename(getPath()); @@ -639,34 +725,37 @@ __int64 File::length() return 0; } return statData.fileSize; -#elif defined(__linux__) - struct stat fileInfoBuffer; - const char *path = wstringtofilename(getPath()); +#elif !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + const fs::path path = ToFilesystemPath(getPath()); - int result = stat(path, &fileInfoBuffer); - - if(result == 0) { - return fileInfoBuffer.st_size; - } else { - return 0; + if( fs::is_regular_file(path, error) ) + { + const auto size = fs::file_size(path, error); + if( !error ) + { + return static_cast<__int64>(size); + } } + + return 0; #else WIN32_FILE_ATTRIBUTE_DATA fileInfoBuffer; #ifdef _UNICODE - BOOL result = GetFileAttributesEx( + const bool result = GetFileAttributesEx( getPath().c_str(), // file or directory name GetFileExInfoStandard, // attribute &fileInfoBuffer // attribute information - ); + ) != 0; #else - BOOL result = GetFileAttributesEx( + const bool result = GetFileAttributesEx( wstringtofilename(getPath()), // file or directory name GetFileExInfoStandard, // attribute &fileInfoBuffer // attribute information - ); + ) != 0; #endif - if( result != 0 && !( (fileInfoBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) ) + if( result && !( (fileInfoBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) ) { // Success LARGE_INTEGER liFileSize; @@ -689,23 +778,37 @@ __int64 File::length() //or 0L if the file does not exist or if an I/O error occurs __int64 File::lastModified() { -#if !defined(__linux__) +#if !defined(__PS3__) && !defined(__ORBIS__) && !defined(__PSVITA__) + std::error_code error; + const fs::path path = ToFilesystemPath(getPath()); + + if( fs::is_regular_file(path, error) ) + { + const fs::file_time_type lastWriteTime = fs::last_write_time(path, error); + if( !error ) + { + return ToEpochMilliseconds(lastWriteTime); + } + } + + return 0l; +#elif !defined(__linux__) WIN32_FILE_ATTRIBUTE_DATA fileInfoBuffer; #ifdef _UNICODE - BOOL result = GetFileAttributesEx( + const bool result = GetFileAttributesEx( getPath().c_str(), // file or directory name GetFileExInfoStandard, // attribute &fileInfoBuffer // attribute information - ); + ) != 0; #else - BOOL result = GetFileAttributesEx( + const bool result = GetFileAttributesEx( wstringtofilename(getPath()), // file or directory name GetFileExInfoStandard, // attribute &fileInfoBuffer // attribute information - ); + ) != 0; #endif - if( result != 0 && !( (fileInfoBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) ) + if( result && !( (fileInfoBuffer.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) ) { // Success LARGE_INTEGER liLastModified; diff --git a/Minecraft.World/IO/Files/FileHeader.cpp b/Minecraft.World/IO/Files/FileHeader.cpp index fd9e16e26..056345a1c 100644 --- a/Minecraft.World/IO/Files/FileHeader.cpp +++ b/Minecraft.World/IO/Files/FileHeader.cpp @@ -69,7 +69,7 @@ void FileHeader::RemoveFile( FileEntry *file ) delete file; } -void FileHeader::WriteHeader( LPVOID saveMem ) +void FileHeader::WriteHeader(void *saveMem) { unsigned int headerOffset = GetStartOfNextData(); @@ -137,7 +137,7 @@ void FileHeader::WriteHeader( LPVOID saveMem ) } } -void FileHeader::ReadHeader( LPVOID saveMem, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL */ ) +void FileHeader::ReadHeader(void *saveMem, ESavePlatform plat /*= SAVE_FILE_PLATFORM_LOCAL */ ) { unsigned int headerOffset; unsigned int headerSize; @@ -325,7 +325,7 @@ unsigned int FileHeader::GetFileSize() return GetStartOfNextData() + ( sizeof(FileEntrySaveData) * (unsigned int)fileTable.size() ); } -void FileHeader::AdjustStartOffsets(FileEntry *file, DWORD nNumberOfBytesToWrite, bool subtract /*= false*/) +void FileHeader::AdjustStartOffsets(FileEntry *file, unsigned int nNumberOfBytesToWrite, bool subtract /*= false*/) { bool found = false; for( unsigned int i = 0; i < fileTable.size(); ++i ) diff --git a/Minecraft.World/IO/Files/FileHeader.h b/Minecraft.World/IO/Files/FileHeader.h index 5367a2924..e7e8c1e4d 100644 --- a/Minecraft.World/IO/Files/FileHeader.h +++ b/Minecraft.World/IO/Files/FileHeader.h @@ -166,14 +166,14 @@ public: protected: FileEntry *AddFile( const std::wstring &name, unsigned int length = 0 ); void RemoveFile( FileEntry * ); - void WriteHeader( LPVOID saveMem ); - void ReadHeader( LPVOID saveMem, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL ); + void WriteHeader(void *saveMem); + void ReadHeader(void *saveMem, ESavePlatform plat = SAVE_FILE_PLATFORM_LOCAL); unsigned int GetStartOfNextData(); unsigned int GetFileSize(); - void AdjustStartOffsets(FileEntry *file, DWORD nNumberOfBytesToWrite, bool subtract = false); + void AdjustStartOffsets(FileEntry *file, unsigned int nNumberOfBytesToWrite, bool subtract = false); bool fileExists( const std::wstring &name ); diff --git a/Minecraft.World/IO/Files/FileInputStream.cpp b/Minecraft.World/IO/Files/FileInputStream.cpp index c5586a781..f3abe198c 100644 --- a/Minecraft.World/IO/Files/FileInputStream.cpp +++ b/Minecraft.World/IO/Files/FileInputStream.cpp @@ -2,11 +2,31 @@ #include "File.h" #include "FileInputStream.h" -#include -#include // for close() +#include extern CConsoleMinecraftApp app; +namespace +{ + __int64 FileTell(std::FILE *file) + { +#if defined(_WIN32) + return _ftelli64(file); +#else + return static_cast<__int64>(ftello(file)); +#endif + } + + bool FileSeek(std::FILE *file, __int64 offset, int origin) + { +#if defined(_WIN32) + return _fseeki64(file, offset, origin) == 0; +#else + return fseeko(file, static_cast(offset), origin) == 0; +#endif + } +} + //Creates a FileInputStream by opening a connection to an actual file, the file named by the File object file in the file system. //A new FileDescriptor object is created to represent this file connection. //First, if there is a security manager, its checkRead method is called with the path represented by the file argument as its argument. @@ -20,34 +40,16 @@ extern CConsoleMinecraftApp app; //FileNotFoundException - if the file does not exist, is a directory rather than a regular file, or for some other reason cannot be //opened for reading. //SecurityException - if a security manager exists and its checkRead method denies read access to the file. -FileInputStream::FileInputStream(const File &file) +FileInputStream::FileInputStream(const File &file) : m_fileHandle(NULL) { - const char *pchFilename=wstringtofilename(file.getPath()); -#ifdef _UNICODE - m_fileHandle = CreateFile( - file.getPath().c_str(), // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); -#elif defined(__linux__) - m_fileHandle = (HANDLE)(intptr_t)open(pchFilename, O_RDONLY); +#if defined(_WIN32) + m_fileHandle = _wfopen(file.getPath().c_str(), L"rb"); #else - m_fileHandle = CreateFile( - pchFilename, // file name - GENERIC_READ, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it - FILE_FLAG_SEQUENTIAL_SCAN, // file attributes - NULL // Unsupported - ); + const std::string nativePath = wstringtofilename(file.getPath()); + m_fileHandle = std::fopen(nativePath.c_str(), "rb"); #endif - if( m_fileHandle == INVALID_HANDLE_VALUE ) + if( m_fileHandle == NULL ) { // TODO 4J Stu - Any form of error/exception handling //__debugbreak(); @@ -57,45 +59,26 @@ FileInputStream::FileInputStream(const File &file) FileInputStream::~FileInputStream() { - if( m_fileHandle != INVALID_HANDLE_VALUE ) -#ifndef __linux__ - CloseHandle( m_fileHandle ); -#else - ::close( (int)(intptr_t)m_fileHandle ); -#endif -} - -#if defined(__linux__) -ssize_t ReadFile(int fd, void* buffer, size_t byteRead, DWORD* numberOfBytesRead, int JustAddANULL) { - ssize_t result = read(fd, buffer, byteRead); - - if (result == -1) { - perror("read failed"); - return -1; - } else { - *numberOfBytesRead = result; - return 0; + if( m_fileHandle != NULL ) + { + std::fclose( m_fileHandle ); } } -#endif // __linux__ //Reads a byte of data from this input stream. This method blocks if no input is yet available. //Returns: //the next byte of data, or -1 if the end of the file is reached. int FileInputStream::read() { - uint8_t byteRead = static_cast(0); - DWORD numberOfBytesRead; + if( m_fileHandle == NULL ) + { + return -1; + } - BOOL bSuccess = ReadFile( - m_fileHandle, // handle to file - &byteRead, // data buffer - 1, // number of bytes to read - &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer - ); + std::uint8_t byteRead = static_cast(0); + const size_t numberOfBytesRead = std::fread(&byteRead, 1, 1, m_fileHandle); - if( bSuccess==FALSE ) + if( std::ferror(m_fileHandle) != 0 ) { // TODO 4J Stu - Some kind of error handling app.FatalLoadError(); @@ -117,17 +100,14 @@ int FileInputStream::read() //the total number of bytes read into the buffer, or -1 if there is no more data because the end of the file has been reached. int FileInputStream::read(byteArray b) { - DWORD numberOfBytesRead; + if( m_fileHandle == NULL ) + { + return -1; + } - BOOL bSuccess = ReadFile( - m_fileHandle, // handle to file - b.data, // data buffer - b.length, // number of bytes to read - &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer - ); + const size_t numberOfBytesRead = std::fread(b.data, 1, b.length, m_fileHandle); - if( bSuccess==FALSE ) + if( std::ferror(m_fileHandle) != 0 ) { // TODO 4J Stu - Some kind of error handling app.FatalLoadError(); @@ -155,17 +135,14 @@ int FileInputStream::read(byteArray b, unsigned int offset, unsigned int length) // 4J Stu - We don't want to read any more than the array buffer can hold assert( length <= ( b.length - offset ) ); - DWORD numberOfBytesRead; + if( m_fileHandle == NULL ) + { + return -1; + } - BOOL bSuccess = ReadFile( - m_fileHandle, // handle to file - &b[offset], // data buffer - length, // number of bytes to read - &numberOfBytesRead, // number of bytes read - NULL // overlapped buffer - ); + const size_t numberOfBytesRead = std::fread(&b[offset], 1, length, m_fileHandle); - if( bSuccess==FALSE ) + if( std::ferror(m_fileHandle) != 0 ) { // TODO 4J Stu - Some kind of error handling app.FatalLoadError(); @@ -184,21 +161,21 @@ int FileInputStream::read(byteArray b, unsigned int offset, unsigned int length) //If this stream has an associated channel then the channel is closed as well. void FileInputStream::close() { - if(m_fileHandle==INVALID_HANDLE_VALUE) + if(m_fileHandle==NULL) { //printf("\n\nFileInputStream::close - TRYING TO CLOSE AN INVALID FILE HANDLE\n\n"); return; } - int result = ::close( (int)(intptr_t)m_fileHandle ); + int result = std::fclose( m_fileHandle ); - if( result == 0 ) + if( result != 0 ) { // TODO 4J Stu - Some kind of error handling } // Stop the dtor from trying to close it again - m_fileHandle = INVALID_HANDLE_VALUE; + m_fileHandle = NULL; } @@ -211,18 +188,34 @@ void FileInputStream::close() //the actual number of bytes skipped. __int64 FileInputStream::skip(__int64 n) { -#ifdef _XBOX - LARGE_INTEGER li; - li.QuadPart = n; - li.LowPart = SetFilePointer(m_fileHandle, li.LowPart, &li.HighPart, FILE_CURRENT); - - if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) + if( m_fileHandle == NULL || n <= 0 ) { - li.QuadPart = 0; + return 0; } - return li.QuadPart; -#else - return 0; -#endif + const __int64 start = FileTell(m_fileHandle); + if( start < 0 ) + { + return 0; + } + + if( !FileSeek(m_fileHandle, 0, SEEK_END) ) + { + return 0; + } + + const __int64 end = FileTell(m_fileHandle); + if( end < 0 ) + { + return 0; + } + + const __int64 offset = std::min(n, std::max<__int64>(0, end - start)); + const __int64 target = start + offset; + if( !FileSeek(m_fileHandle, target, SEEK_SET) ) + { + return 0; + } + + return offset; } diff --git a/Minecraft.World/IO/Files/FileInputStream.h b/Minecraft.World/IO/Files/FileInputStream.h index ecf3ff599..7afda60a2 100644 --- a/Minecraft.World/IO/Files/FileInputStream.h +++ b/Minecraft.World/IO/Files/FileInputStream.h @@ -1,8 +1,12 @@ #pragma once // 4J Stu - Represents Java standard library class +#include + #include "../Streams/InputStream.h" +class File; + class FileInputStream : public InputStream { public: @@ -15,6 +19,6 @@ public: virtual __int64 skip(__int64 n); private: - HANDLE m_fileHandle; + std::FILE *m_fileHandle; -}; \ No newline at end of file +}; diff --git a/Minecraft.World/IO/Files/FileOutputStream.cpp b/Minecraft.World/IO/Files/FileOutputStream.cpp index 8b0ff4213..699f75101 100644 --- a/Minecraft.World/IO/Files/FileOutputStream.cpp +++ b/Minecraft.World/IO/Files/FileOutputStream.cpp @@ -1,14 +1,6 @@ #include "../../Platform/stdafx.h" #include "File.h" #include "FileOutputStream.h" -#include -#include -#include -#include -#include -#include -#include -#include //Creates a file output stream to write to the file represented by the specified File object. A new FileDescriptor object is //created to represent this file connection. @@ -19,7 +11,7 @@ // //Parameters: //file - the file to be opened for writing. -FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HANDLE_VALUE ) +FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( NULL ) { if( file.exists() && file.isDirectory()) { @@ -27,46 +19,26 @@ FileOutputStream::FileOutputStream(const File &file) : m_fileHandle( INVALID_HAN return; } -#ifdef _DURANGO - m_fileHandle = CreateFile( - file.getPath().c_str() , // file name - GENERIC_WRITE, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_ALWAYS , // how to create - FILE_ATTRIBUTE_NORMAL , // file attributes - NULL // Unsupported - ); -#elif defined(__linux__) - std::wstring path = file.getPath(); - char* convertedPath = new char[path.size() + 1]; - std::wcstombs(convertedPath, path.c_str(), path.size() + 1); - - m_fileHandle = (HANDLE)(intptr_t)open(convertedPath, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); - delete[] convertedPath; +#if defined(_WIN32) + m_fileHandle = _wfopen(file.getPath().c_str(), L"wb"); #else - m_fileHandle = CreateFile( - wstringtofilename(file.getPath()) , // file name - GENERIC_WRITE, // access mode - 0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but... - NULL, // Unused - OPEN_ALWAYS , // how to create - FILE_ATTRIBUTE_NORMAL , // file attributes - NULL // Unsupported - ); + const std::string nativePath = wstringtofilename(file.getPath()); + m_fileHandle = std::fopen(nativePath.c_str(), "wb"); #endif - if( m_fileHandle == INVALID_HANDLE_VALUE ) + if( m_fileHandle == NULL ) { // TODO 4J Stu - Any form of error/exception handling - DWORD error = GetLastError(); + perror("FileOutputStream::FileOutputStream"); } } FileOutputStream::~FileOutputStream() { - if( m_fileHandle != INVALID_HANDLE_VALUE ) - ::close( (int)(intptr_t)m_fileHandle ); + if( m_fileHandle != NULL ) + { + std::fclose( m_fileHandle ); + } } //Writes the specified byte to this file output stream. Implements the write method of OutputStream. @@ -74,23 +46,16 @@ FileOutputStream::~FileOutputStream() //b - the byte to be written. void FileOutputStream::write(unsigned int b) { - uint8_t value = (uint8_t) b; + if( m_fileHandle == NULL ) + { + return; + } -#if defined(_WIN32) - BOOL result = WriteFile( - m_fileHandle, // handle to file - &value, // data buffer - 1, // number of bytes to write - &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer - ); -#else // LINUX - int fileDescriptor = (int)(intptr_t)(m_fileHandle); - ssize_t numberOfBytesWritten = ::write(fileDescriptor, &value, 1); - int result = static_cast(numberOfBytesWritten); -#endif // _WIN32 + std::uint8_t value = (std::uint8_t) b; + const size_t numberOfBytesWritten = std::fwrite(&value, 1, 1, m_fileHandle); + const int result = std::ferror(m_fileHandle); - if( result == 0 ) + if( result != 0 ) { // TODO 4J Stu - Some kind of error handling } @@ -105,21 +70,15 @@ void FileOutputStream::write(unsigned int b) //b - the data. void FileOutputStream::write(byteArray b) { -#if defined(_WIN32) - BOOL result = WriteFile( - m_fileHandle, // handle to file - &b.data, // data buffer - b.length, // number of bytes to write - &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer - ); -#else // Linux - int fileDescriptor = (int)(intptr_t)(m_fileHandle); - ssize_t numberOfBytesWritten = ::write(fileDescriptor, static_cast(b.data), b.length); - int result = static_cast(numberOfBytesWritten); -#endif // _WIN32 + if( m_fileHandle == NULL ) + { + return; + } - if( result == 0 ) + const size_t numberOfBytesWritten = std::fwrite(b.data, 1, b.length, m_fileHandle); + const int result = std::ferror(m_fileHandle); + + if( result != 0 ) { // TODO 4J Stu - Some kind of error handling } @@ -139,23 +98,15 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng // 4J Stu - We don't want to write any more than the array buffer holds assert( length <= ( b.length - offset ) ); -#if defined(_WIN32) - DWORD numberOfBytesWritten; + if( m_fileHandle == NULL ) + { + return; + } - BOOL result = WriteFile( - m_fileHandle, // handle to file - &b[offset], // data buffer - length, // number of bytes to write - &numberOfBytesWritten, // number of bytes written - NULL // overlapped buffer - ); -#else - int fileDescriptor = (int)(intptr_t)(m_fileHandle); - ssize_t numberOfBytesWritten = ::write(fileDescriptor, static_cast(&b[offset]), length); - int result = static_cast(numberOfBytesWritten); -#endif // _WIN32 + const size_t numberOfBytesWritten = std::fwrite(&b[offset], 1, length, m_fileHandle); + const int result = std::ferror(m_fileHandle); - if( result == 0 ) + if( result != 0 ) { // TODO 4J Stu - Some kind of error handling } @@ -170,16 +121,25 @@ void FileOutputStream::write(byteArray b, unsigned int offset, unsigned int leng //If this stream has an associated channel then the channel is closed as well. void FileOutputStream::close() { -#ifdef _WIN32 - BOOL result = CloseHandle( m_fileHandle ); -#else // __linux__ - int result = ::close( (int)(intptr_t)m_fileHandle ); -#endif // _WIN32 - if( result == 0 ) + if( m_fileHandle == NULL ) + { + return; + } + + int result = std::fclose( m_fileHandle ); + if( result != 0 ) { // TODO 4J Stu - Some kind of error handling } // Stop the dtor from trying to close it again - m_fileHandle = INVALID_HANDLE_VALUE; + m_fileHandle = NULL; +} + +void FileOutputStream::flush() +{ + if( m_fileHandle != NULL ) + { + std::fflush( m_fileHandle ); + } } diff --git a/Minecraft.World/IO/Files/FileOutputStream.h b/Minecraft.World/IO/Files/FileOutputStream.h index 577994303..03734802c 100644 --- a/Minecraft.World/IO/Files/FileOutputStream.h +++ b/Minecraft.World/IO/Files/FileOutputStream.h @@ -1,8 +1,12 @@ #pragma once // 4J Stu - Represents Java standard lib abstract +#include + #include "../Streams/OutputStream.h" +class File; + class FileOutputStream : public OutputStream { public: @@ -12,8 +16,8 @@ public: virtual void write(byteArray b); virtual void write(byteArray b, unsigned int offset, unsigned int length); virtual void close(); - virtual void flush() {} + virtual void flush(); private: - HANDLE m_fileHandle; -}; \ No newline at end of file + std::FILE *m_fileHandle; +}; diff --git a/Minecraft.World/IO/NBT/NbtSlotFile.cpp b/Minecraft.World/IO/NBT/NbtSlotFile.cpp index 3a7cceacf..a373667fe 100644 --- a/Minecraft.World/IO/NBT/NbtSlotFile.cpp +++ b/Minecraft.World/IO/NBT/NbtSlotFile.cpp @@ -2,6 +2,47 @@ #include "../Files/File.h" #include "NbtSlotFile.h" +namespace +{ + std::FILE *OpenBinaryFileForReadWrite(const File &file) + { +#if defined(_WIN32) + std::FILE *stream = _wfopen(file.getPath().c_str(), L"r+b"); + if (stream == NULL) + { + stream = _wfopen(file.getPath().c_str(), L"w+b"); + } +#else + const std::string nativePath = wstringtofilename(file.getPath()); + std::FILE *stream = std::fopen(nativePath.c_str(), "r+b"); + if (stream == NULL) + { + stream = std::fopen(nativePath.c_str(), "w+b"); + } +#endif + return stream; + } + + bool SeekFile(std::FILE *file, __int64 offset) + { +#if defined(_WIN32) + return _fseeki64(file, offset, SEEK_SET) == 0; +#else + return fseeko(file, static_cast(offset), SEEK_SET) == 0; +#endif + } + + bool ReadExact(std::FILE *file, void *buffer, std::size_t size) + { + return std::fread(buffer, 1, size, file) == size; + } + + bool WriteExact(std::FILE *file, const void *buffer, std::size_t size) + { + return std::fwrite(buffer, 1, size, file) == size; + } +} + byteArray NbtSlotFile::READ_BUFFER(1024*1024); __int64 NbtSlotFile::largest = 0; @@ -14,12 +55,12 @@ NbtSlotFile::NbtSlotFile(File file) if ( !file.exists() || file.length() ) { - raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + raf = OpenBinaryFileForReadWrite(file); writeHeader(); } else { - raf = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + raf = OpenBinaryFileForReadWrite(file); } readHeader(); @@ -29,12 +70,11 @@ NbtSlotFile::NbtSlotFile(File file) fileSlotMap[i] = new std::vector; } - DWORD numberofBytesRead; for (int fileSlot = 0; fileSlot < totalFileSlots; fileSlot++) { seekSlotHeader(fileSlot); short slot; - ReadFile(raf,&slot,2,&numberofBytesRead,NULL); + ReadExact(raf, &slot, sizeof(slot)); if (slot == 0) { freeFileSlots.push_back(fileSlot); @@ -49,42 +89,39 @@ NbtSlotFile::NbtSlotFile(File file) void NbtSlotFile::readHeader() { - DWORD numberOfBytesRead; - SetFilePointer(raf,0,0,FILE_BEGIN); + SeekFile(raf, 0); int magic; - ReadFile(raf,&magic,4,&numberOfBytesRead,NULL); + ReadExact(raf, &magic, sizeof(magic)); // if (magic != MAGIC_NUMBER) throw new IOException("Bad magic number: " + magic); // 4J - TODO short version; - ReadFile(raf,&version,2,&numberOfBytesRead,NULL); + ReadExact(raf, &version, sizeof(version)); // if (version != 0) throw new IOException("Bad version number: " + version); // 4J - TODO - ReadFile(raf,&totalFileSlots,4,&numberOfBytesRead,NULL); + ReadExact(raf, &totalFileSlots, sizeof(totalFileSlots)); } void NbtSlotFile::writeHeader() { - DWORD numberOfBytesWritten; short version = 0; - SetFilePointer(raf,0,0,FILE_BEGIN); - WriteFile(raf,&MAGIC_NUMBER,4,&numberOfBytesWritten,NULL); - WriteFile(raf,&version,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&totalFileSlots,4,&numberOfBytesWritten,NULL); + SeekFile(raf, 0); + WriteExact(raf, &MAGIC_NUMBER, sizeof(MAGIC_NUMBER)); + WriteExact(raf, &version, sizeof(version)); + WriteExact(raf, &totalFileSlots, sizeof(totalFileSlots)); } void NbtSlotFile::seekSlotHeader(int fileSlot) { int target = FILE_HEADER_SIZE + fileSlot * (FILE_SLOT_SIZE + FILE_SLOT_HEADER_SIZE); - SetFilePointer(raf,target,0,FILE_BEGIN); + SeekFile(raf, target); } void NbtSlotFile::seekSlot(int fileSlot) { int target = FILE_HEADER_SIZE + fileSlot * (FILE_SLOT_SIZE + FILE_SLOT_HEADER_SIZE); - SetFilePointer(raf,target+FILE_SLOT_HEADER_SIZE,0,FILE_BEGIN); + SeekFile(raf, target + FILE_SLOT_HEADER_SIZE); } std::vector *NbtSlotFile::readAll(int slot) { - DWORD numberOfBytesRead; std::vector *tags = new std::vector; std::vector *fileSlots = fileSlotMap[slot]; int skipped = 0; @@ -101,12 +138,12 @@ std::vector *NbtSlotFile::readAll(int slot) { seekSlotHeader(c); short oldSlot; - ReadFile(raf,&oldSlot,2,&numberOfBytesRead,NULL); + ReadExact(raf, &oldSlot, sizeof(oldSlot)); short size; - ReadFile(raf,&size,2,&numberOfBytesRead,NULL); - ReadFile(raf,&continuesAt,4,&numberOfBytesRead,NULL); + ReadExact(raf, &size, sizeof(size)); + ReadExact(raf, &continuesAt, sizeof(continuesAt)); int lastSlot; - ReadFile(raf,&lastSlot,4,&numberOfBytesRead,NULL); + ReadExact(raf, &lastSlot, sizeof(lastSlot)); seekSlot(c); if (expectedSlot > 0 && oldSlot == -expectedSlot) @@ -117,7 +154,7 @@ std::vector *NbtSlotFile::readAll(int slot) // if (oldSlot != expectedSlot) throw new IOException("Wrong slot! Got " + oldSlot + ", expected " + expectedSlot); // 4J - TODO - ReadFile(raf,READ_BUFFER.data + pos,size,&numberOfBytesRead,NULL); + ReadExact(raf, READ_BUFFER.data + pos, size); if (continuesAt >= 0) { @@ -161,7 +198,6 @@ int NbtSlotFile::getFreeSlot() } void NbtSlotFile::replaceSlot(int slot, std::vector *tags) { - DWORD numberOfBytesWritten; toReplace = fileSlotMap[slot]; fileSlotMap[slot] = new std::vector(); @@ -210,13 +246,13 @@ void NbtSlotFile::replaceSlot(int slot, std::vector *tags) } seekSlotHeader(fileSlot); - WriteFile(raf,¤tSlot,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&toWrite,2,&numberOfBytesWritten,NULL); - WriteFile(raf,&nextFileSlot,4,&numberOfBytesWritten,NULL); - WriteFile(raf,&lastFileSlot,4,&numberOfBytesWritten,NULL); + WriteExact(raf, ¤tSlot, sizeof(currentSlot)); + WriteExact(raf, &toWrite, sizeof(toWrite)); + WriteExact(raf, &nextFileSlot, sizeof(nextFileSlot)); + WriteExact(raf, &lastFileSlot, sizeof(lastFileSlot)); seekSlot(fileSlot); - WriteFile(raf,compressed.data+pos,toWrite,&numberOfBytesWritten,NULL); + WriteExact(raf, compressed.data + pos, toWrite); if (remaining > 0) { @@ -237,7 +273,7 @@ void NbtSlotFile::replaceSlot(int slot, std::vector *tags) seekSlotHeader(c); short zero = 0; - WriteFile(raf,&zero,2,&numberOfBytesWritten,NULL); + WriteExact(raf, &zero, sizeof(zero)); } toReplace->clear(); @@ -246,5 +282,9 @@ void NbtSlotFile::replaceSlot(int slot, std::vector *tags) void NbtSlotFile::close() { - CloseHandle(raf); + if (raf != NULL) + { + std::fclose(raf); + raf = NULL; + } } diff --git a/Minecraft.World/IO/NBT/NbtSlotFile.h b/Minecraft.World/IO/NBT/NbtSlotFile.h index 4c1f40b8e..0a613cab2 100644 --- a/Minecraft.World/IO/NBT/NbtSlotFile.h +++ b/Minecraft.World/IO/NBT/NbtSlotFile.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "CompoundTag.h" #include "../../Level/Storage/ZonedChunkStorage.h" #include "../../Headers/com.mojang.nbt.h" @@ -14,7 +16,7 @@ private: static const int FILE_SLOT_HEADER_SIZE = 12; static const int FILE_SLOT_SIZE = 500; - HANDLE raf; + std::FILE *raf; std::vector **fileSlotMap; int fileSlotMapLength; std::vector freeFileSlots; diff --git a/Minecraft.World/IO/Streams/Compression.cpp b/Minecraft.World/IO/Streams/Compression.cpp index c7f2e463a..899aae280 100644 --- a/Minecraft.World/IO/Streams/Compression.cpp +++ b/Minecraft.World/IO/Streams/Compression.cpp @@ -16,7 +16,7 @@ #include "../../../Minecraft.Client/Platform/PS3/PS3Extras/EdgeZLib.h" #endif //__PS3__ -DWORD Compression::tlsIdx = 0; +unsigned int Compression::tlsIdx = 0; Compression::ThreadStorage *Compression::tlsDefault = NULL; Compression::ThreadStorage::ThreadStorage() @@ -312,7 +312,7 @@ HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void *pDestSize = (unsigned int)destSize; return ( ( res == Z_OK ) ? S_OK : -1 ); #elif defined __PS3__ - uint32_t destSize = (uint32_t)(*pDestSize); + std::uint32_t destSize = (std::uint32_t)(*pDestSize); bool res = EdgeZLib::Compress(pDestination, &destSize, pSource, SrcSize); *pDestSize = (unsigned int)destSize; return ( ( res ) ? S_OK : -1 ); @@ -340,7 +340,7 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi *pDestSize = (unsigned int)destSize; return ( ( res == Z_OK ) ? S_OK : -1 ); #elif defined __PS3__ - uint32_t destSize = (uint32_t)(*pDestSize); + std::uint32_t destSize = (std::uint32_t)(*pDestSize); bool res = EdgeZLib::Decompress(pDestination, &destSize, pSource, SrcSize); *pDestSize = (unsigned int)destSize; return ( ( res ) ? S_OK : -1 ); @@ -354,13 +354,13 @@ HRESULT Compression::Decompress(void *pDestination, unsigned int *pDestSize, voi // MGH - same as VirtualDecompress in PSVitaStubs, but for use on other platforms (so no virtual mem stuff) #ifndef _XBOX -VOID Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) // (LPVOID buf, SIZE_T dwSize, LPVOID dst) +void Compression::VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize) // (LPVOID buf, SIZE_T dwSize, LPVOID dst) { - uint8_t *pSrc = (uint8_t *)pSource; + std::uint8_t *pSrc = (std::uint8_t *)pSource; int Offset = 0; int Page = 0; int Index = 0; - uint8_t* Data = (uint8_t*)pDestination; + std::uint8_t* Data = (std::uint8_t*)pDestination; while( Index != SrcSize ) { // is this a normal value @@ -426,8 +426,8 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS if (pDestination != NULL) { // Read big-endian srcize from array - PBYTE pbDestSize = (PBYTE) pDestSize; - PBYTE pbSource = (PBYTE) pSource; + std::uint8_t* pbDestSize = reinterpret_cast(pDestSize); + std::uint8_t* pbSource = reinterpret_cast(pSource); for (int i = 3; i >= 0; i--) { pbDestSize[3-i] = pbSource[i]; } @@ -442,7 +442,7 @@ HRESULT Compression::DecompressWithType(void *pDestination, unsigned int *pDestS strm.next_out = uncompr.data; strm.avail_out = uncompr.length; // Skip those first 4 bytes - strm.next_in = (PBYTE) pSource + 4; + strm.next_in = reinterpret_cast(pSource) + 4; strm.avail_in = SrcSize - 4; int hr = inflateInit2(&strm, -15); @@ -549,4 +549,3 @@ void Compression::SetDecompressionType(ESavePlatform platform) /*Compression gCompression;*/ - diff --git a/Minecraft.World/IO/Streams/Compression.h b/Minecraft.World/IO/Streams/Compression.h index 4f81cc784..080e2b349 100644 --- a/Minecraft.World/IO/Streams/Compression.h +++ b/Minecraft.World/IO/Streams/Compression.h @@ -27,7 +27,7 @@ private: ThreadStorage(); ~ThreadStorage(); }; - static DWORD tlsIdx; + static unsigned int tlsIdx; static ThreadStorage *tlsDefault; public: // Each new thread that needs to use Compression will need to call one of the following 2 functions, to either create its own @@ -46,7 +46,7 @@ public: HRESULT CompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize); HRESULT DecompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize); #ifndef _XBOX - static VOID VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize); + static void VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize); #endif void SetDecompressionType(ECompressionTypes type) { m_decompressType = type; } // for loading a save from a different platform (Sony cloud storage cross play) diff --git a/Minecraft.World/Items/Item.cpp b/Minecraft.World/Items/Item.cpp index 3eb9a063b..f77644996 100644 --- a/Minecraft.World/Items/Item.cpp +++ b/Minecraft.World/Items/Item.cpp @@ -747,13 +747,13 @@ Item *Item::setDescriptionId(unsigned int id) return this; } -LPCWSTR Item::getDescription() +const wchar_t *Item::getDescription() { return app.GetString(getDescriptionId()); //return I18n::get(getDescriptionId()); } -LPCWSTR Item::getDescription(std::shared_ptr instance) +const wchar_t *Item::getDescription(std::shared_ptr instance) { return app.GetString(getDescriptionId(instance)); //return I18n::get(getDescriptionId(instance)); diff --git a/Minecraft.World/Items/Item.h b/Minecraft.World/Items/Item.h index eb041fed0..4a20b7602 100644 --- a/Minecraft.World/Items/Item.h +++ b/Minecraft.World/Items/Item.h @@ -672,8 +672,8 @@ public: virtual bool isHandEquipped(); virtual bool isMirroredArt(); Item *setDescriptionId(unsigned int id); - LPCWSTR getDescription(); - LPCWSTR getDescription(std::shared_ptr instance); + const wchar_t *getDescription(); + const wchar_t *getDescription(std::shared_ptr instance); virtual unsigned int getDescriptionId(int iData = -1); virtual unsigned int getDescriptionId(std::shared_ptr instance); Item *setUseDescriptionId(unsigned int id); diff --git a/Minecraft.World/Level/BlockGenMethods.cpp b/Minecraft.World/Level/BlockGenMethods.cpp index bf00c5511..e5799f50a 100644 --- a/Minecraft.World/Level/BlockGenMethods.cpp +++ b/Minecraft.World/Level/BlockGenMethods.cpp @@ -3,7 +3,7 @@ #include "../Headers/net.minecraft.world.level.h" #include "BlockGenMethods.h" -void BlockGenMethods::generateBox(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, BYTE edge, BYTE filling) +void BlockGenMethods::generateBox(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t edge, std::uint8_t filling) { sx = Mth::clamp(sx, 0, 15); @@ -34,7 +34,7 @@ void BlockGenMethods::generateBox(Level *level, byteArray blocks, int sx, int sy } } -void BlockGenMethods::generateFrame(Level *level, byteArray blocks, int sx, int sy, int ex, int ey, int flatZ, int direction, BYTE edge, BYTE filling) +void BlockGenMethods::generateFrame(Level *level, byteArray blocks, int sx, int sy, int ex, int ey, int flatZ, int direction, std::uint8_t edge, std::uint8_t filling) { sx = Mth::clamp(sx, 0, 15); @@ -100,7 +100,7 @@ void BlockGenMethods::generateFrame(Level *level, byteArray blocks, int sx, int } } -void BlockGenMethods::generateDirectionLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, int startDirection, int endDirection, BYTE block) +void BlockGenMethods::generateDirectionLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, int startDirection, int endDirection, std::uint8_t block) { sx = Mth::clamp(sx, 0, 15); @@ -218,7 +218,7 @@ void BlockGenMethods::generateDirectionLine(Level *level, byteArray blocks, int } } -void BlockGenMethods::generateLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, BYTE block) +void BlockGenMethods::generateLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t block) { generateDirectionLine(level, blocks, sx, sy, sz, ex, ey, ez, 0, 0, block); -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/BlockGenMethods.h b/Minecraft.World/Level/BlockGenMethods.h index 602a994b7..f0e6027c6 100644 --- a/Minecraft.World/Level/BlockGenMethods.h +++ b/Minecraft.World/Level/BlockGenMethods.h @@ -1,12 +1,13 @@ #pragma once +#include #include "../Util/ArrayWithLength.h" class BlockGenMethods { public: - static void generateBox(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, BYTE edge, BYTE filling); - static void generateFrame(Level *level, byteArray blocks, int sx, int sy, int ex, int ey, int flatZ, int direction, BYTE edge, BYTE filling); - static void generateDirectionLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, int startDirection, int endDirection, BYTE block); - static void generateLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, BYTE block); -}; \ No newline at end of file + static void generateBox(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t edge, std::uint8_t filling); + static void generateFrame(Level *level, byteArray blocks, int sx, int sy, int ex, int ey, int flatZ, int direction, std::uint8_t edge, std::uint8_t filling); + static void generateDirectionLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, int startDirection, int endDirection, std::uint8_t block); + static void generateLine(Level *level, byteArray blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t block); +}; diff --git a/Minecraft.World/Level/CustomLevelSource.cpp b/Minecraft.World/Level/CustomLevelSource.cpp index 5753d6092..a0d4fd057 100644 --- a/Minecraft.World/Level/CustomLevelSource.cpp +++ b/Minecraft.World/Level/CustomLevelSource.cpp @@ -1,4 +1,5 @@ #include "../Platform/stdafx.h" +#include "../Util/PortableFileIO.h" #include "../Headers/net.minecraft.world.level.h" #include "../Headers/net.minecraft.world.level.biome.h" #include "../Headers/net.minecraft.world.level.levelgen.h" @@ -19,86 +20,47 @@ CustomLevelSource::CustomLevelSource(Level *level, __int64 seed, bool generateSt m_heightmapOverride = byteArray( (m_XZSize*16) * (m_XZSize*16) ); -#ifdef _UNICODE - std::wstring path = L"GAME:\\GameRules\\heightmap.bin"; - -#else #ifdef _WINDOWS64 - std::string path = "GameRules\\heightmap.bin"; + const std::wstring path = L"GameRules\\heightmap.bin"; #else - std::string path = "GAME:\\GameRules\\heightmap.bin"; + const std::wstring path = L"GAME:\\GameRules\\heightmap.bin"; #endif -#endif - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if( file == INVALID_HANDLE_VALUE ) + const PortableFileIO::BinaryReadResult heightmapReadResult = PortableFileIO::ReadBinaryFile(path, m_heightmapOverride.data, m_heightmapOverride.length); + if(heightmapReadResult.status == PortableFileIO::BinaryReadStatus::not_found) { app.FatalLoadError(); - DWORD error = GetLastError(); assert(false); } - else + else if(heightmapReadResult.status == PortableFileIO::BinaryReadStatus::too_large) { - -#ifdef _DURANGO - __debugbreak(); // TODO - DWORD bytesRead,dwFileSize = 0; -#else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); -#endif - if(dwFileSize > m_heightmapOverride.length) - { - app.DebugPrintf("Heightmap binary is too large!!\n"); - __debugbreak(); - } - BOOL bSuccess = ReadFile(file,m_heightmapOverride.data,dwFileSize,&bytesRead,NULL); - - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - CloseHandle(file); + app.DebugPrintf("Heightmap binary is too large!!\n"); + __debugbreak(); + } + else if(heightmapReadResult.status != PortableFileIO::BinaryReadStatus::ok) + { + app.FatalLoadError(); } m_waterheightOverride = byteArray( (m_XZSize*16) * (m_XZSize*16) ); -#ifdef _UNICODE - std::wstring waterHeightPath = L"GAME:\\GameRules\\waterheight.bin"; - -#else #ifdef _WINDOWS64 - std::string waterHeightPath = "GameRules\\waterheight.bin"; + const std::wstring waterHeightPath = L"GameRules\\waterheight.bin"; #else - std::string waterHeightPath = "GAME:\\GameRules\\waterheight.bin"; + const std::wstring waterHeightPath = L"GAME:\\GameRules\\waterheight.bin"; #endif -#endif - file = CreateFile(waterHeightPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if( file == INVALID_HANDLE_VALUE ) + const PortableFileIO::BinaryReadResult waterHeightReadResult = PortableFileIO::ReadBinaryFile(waterHeightPath, m_waterheightOverride.data, m_waterheightOverride.length); + if(waterHeightReadResult.status == PortableFileIO::BinaryReadStatus::not_found) { - DWORD error = GetLastError(); - //assert(false); memset(m_waterheightOverride.data, level->seaLevel, m_waterheightOverride.length); } - else + else if(waterHeightReadResult.status == PortableFileIO::BinaryReadStatus::too_large) { - -#ifdef _DURANGO - __debugbreak(); // TODO - DWORD bytesRead,dwFileSize = 0; -#else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); -#endif - if(dwFileSize > m_waterheightOverride.length) - { - app.DebugPrintf("waterheight binary is too large!!\n"); - __debugbreak(); - } - BOOL bSuccess = ReadFile(file,m_waterheightOverride.data,dwFileSize,&bytesRead,NULL); - - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - CloseHandle(file); + app.DebugPrintf("waterheight binary is too large!!\n"); + __debugbreak(); + } + else if(waterHeightReadResult.status != PortableFileIO::BinaryReadStatus::ok) + { + app.FatalLoadError(); } caveFeature = new LargeCaveFeature(); @@ -202,11 +164,11 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, byteArray blocks) // 4J - this comparison used to just be with 0.0f but is now varied by block above if (yc * CHUNK_HEIGHT + y < mapHeight) { - tileId = (uint8_t) Tile::rock_Id; + tileId = (std::uint8_t) Tile::rock_Id; } else if (yc * CHUNK_HEIGHT + y < waterHeight) { - tileId = (uint8_t) Tile::calmWater_Id; + tileId = (std::uint8_t) Tile::calmWater_Id; } // 4J - more extra code to make sure that the column at the edge of the world is just water & rock, to match the infinite sea that @@ -264,8 +226,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi int run = -1; - uint8_t top = b->topMaterial; - uint8_t material = b->material; + std::uint8_t top = b->topMaterial; + std::uint8_t material = b->material; LevelGenerationOptions *lgo = app.getLevelGenerationOptions(); if(lgo != NULL) @@ -288,7 +250,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y <= 1 + random->nextInt(2)) // 4J - changed to make the bedrock not have bits you can get stuck in // if (y <= 0 + random->nextInt(5)) { - blocks[offs] = (uint8_t) Tile::unbreakable_Id; + blocks[offs] = (std::uint8_t) Tile::unbreakable_Id; } else { @@ -305,7 +267,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (runDepth <= 0) { top = 0; - material = (uint8_t) Tile::rock_Id; + material = (std::uint8_t) Tile::rock_Id; } else if (y >= waterHeight - 4 && y <= waterHeight + 1) { @@ -319,8 +281,8 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (y < waterHeight && top == 0) { - if (temp < 0.15f) top = (uint8_t) Tile::ice_Id; - else top = (uint8_t) Tile::calmWater_Id; + if (temp < 0.15f) top = (std::uint8_t) Tile::ice_Id; + else top = (std::uint8_t) Tile::calmWater_Id; } run = runDepth; @@ -337,7 +299,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, byteArray blocks, Bi if (run == 0 && material == Tile::sand_Id) { run = random->nextInt(4); - material = (uint8_t) Tile::sandStone_Id; + material = (std::uint8_t) Tile::sandStone_Id; } } } @@ -366,7 +328,7 @@ LevelChunk *CustomLevelSource::getChunk(int xOffs, int zOffs) // 4J - now allocating this with a physical alloc & bypassing general memory management so that it will get cleanly freed int blocksSize = Level::maxBuildHeight * 16 * 16; - uint8_t *tileData = (uint8_t *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + std::uint8_t *tileData = (std::uint8_t *)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, PAGE_READWRITE); XMemSet128(tileData,0,blocksSize); byteArray blocks = byteArray(tileData,blocksSize); // byteArray blocks = byteArray(16 * level->depth * 16); diff --git a/Minecraft.World/Level/Level.cpp b/Minecraft.World/Level/Level.cpp index 536703187..b4026d890 100644 --- a/Minecraft.World/Level/Level.cpp +++ b/Minecraft.World/Level/Level.cpp @@ -41,10 +41,48 @@ #include "../../Minecraft.Client/Textures/Packs/DLCTexturePack.h" #include "../../Minecraft.Client/Platform/Common/DLC/DLCPack.h" #include "../../Minecraft.Client/Platform/PS3/PS3Extras/ShutdownManager.h" +#include +namespace +{ +#if defined(_WIN32) + inline void *LevelTlsGetValue(DWORD key) + { + return TlsGetValue(key); + } + + inline void LevelTlsSetValue(DWORD key, void *value) + { + TlsSetValue(key, value); + } +#else + pthread_key_t CreateLevelTlsKey() + { + pthread_key_t key; + pthread_key_create(&key, NULL); + return key; + } + + inline void *LevelTlsGetValue(pthread_key_t key) + { + return pthread_getspecific(key); + } + + inline void LevelTlsSetValue(pthread_key_t key, void *value) + { + pthread_setspecific(key, value); + } +#endif +} + +#if defined(_WIN32) DWORD Level::tlsIdx = TlsAlloc(); DWORD Level::tlsIdxLightCache = TlsAlloc(); +#else +pthread_key_t Level::tlsIdx = CreateLevelTlsKey(); +pthread_key_t Level::tlsIdxLightCache = CreateLevelTlsKey(); +#endif // 4J : WESTY : Added for time played stats. #include "../Headers/net.minecraft.stats.h" @@ -94,12 +132,12 @@ void Level::enableLightingCache() { // Allocate 16K (needs 32K for large worlds) for a 16x16x16x4 byte cache of results, plus 128K required for toCheck array. Rounding up to 256 to keep as multiple of alignement - aligning to 128K boundary for possible cache locking. void *cache = (unsigned char *)XPhysicalAlloc(256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES); - TlsSetValue(tlsIdxLightCache,cache); + LevelTlsSetValue(tlsIdxLightCache, cache); } void Level::destroyLightingCache() { - lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache); + lightCache_t *cache = static_cast(LevelTlsGetValue(tlsIdxLightCache)); XPhysicalFree(cache); } @@ -458,14 +496,14 @@ void Level::flushCache(lightCache_t *cache, __uint64 cacheUse, LightLayer::varie // 4J - added following 2 functions to move instaBuild flag from being a class member, to TLS bool Level::getInstaTick() { - return ((size_t)TlsGetValue(tlsIdx)) != 0; + return reinterpret_cast(LevelTlsGetValue(tlsIdx)) != 0; } void Level::setInstaTick(bool enable) { void *value = 0; if( enable ) value = (void *)1; - TlsSetValue(tlsIdx,value); + LevelTlsSetValue(tlsIdx, value); } // 4J - added @@ -3386,7 +3424,7 @@ inline int GetIndex(int x, int y, int z) // 4J - Made changes here so that lighting goes through a cache, if enabled for this thread void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, bool force, bool rootOnlyEmissive) { - lightCache_t *cache = (lightCache_t *)TlsGetValue(tlsIdxLightCache); + lightCache_t *cache = static_cast(LevelTlsGetValue(tlsIdxLightCache)); __uint64 cacheUse = 0; if( force ) diff --git a/Minecraft.World/Level/Level.h b/Minecraft.World/Level/Level.h index 945341bfa..f6b60ec6f 100644 --- a/Minecraft.World/Level/Level.h +++ b/Minecraft.World/Level/Level.h @@ -9,6 +9,9 @@ #include "../Util/ParticleTypes.h" #include "../WorldGen/Biomes/Biome.h" #include "../Util/C4JThread.h" +#if !defined(_WIN32) +#include +#endif #ifdef __PSVITA__ #include "../../Minecraft.Client/Platform/PSVita/PSVitaExtras/CustomSet.h" @@ -77,8 +80,13 @@ public: int seaLevel; // 4J - added, making instaTick flag use TLS so we can set it in the chunk rebuilding thread without upsetting the main game thread +#if defined(_WIN32) static DWORD tlsIdx; static DWORD tlsIdxLightCache; +#else + static pthread_key_t tlsIdx; + static pthread_key_t tlsIdxLightCache; +#endif static void enableLightingCache(); static void destroyLightingCache(); static bool getCacheTestEnabled(); diff --git a/Minecraft.World/Level/Storage/CompressedTileStorage.cpp b/Minecraft.World/Level/Storage/CompressedTileStorage.cpp index 5c41f9114..473316e7a 100644 --- a/Minecraft.World/Level/Storage/CompressedTileStorage.cpp +++ b/Minecraft.World/Level/Storage/CompressedTileStorage.cpp @@ -1051,7 +1051,6 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc ); if( newIndicesAndData == NULL ) { - DWORD lastError = GetLastError(); #ifndef _DURANGO MEMORYSTATUS memStatus; GlobalMemoryStatus(&memStatus); @@ -1358,4 +1357,4 @@ void CompressedTileStorage::reverseIndices(unsigned char *indices) { System::ReverseUSHORT(&blockIndices[i]); } -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp index ab1381644..eee1b4068 100644 --- a/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/DirectoryLevelStorage.cpp @@ -19,7 +19,7 @@ _MapDataMappings::_MapDataMappings() #ifndef _DURANGO ZeroMemory(xuids,sizeof(PlayerUID)*MAXIMUM_MAP_SAVE_DATA); #endif - ZeroMemory(dimensions,sizeof(uint8_t)*(MAXIMUM_MAP_SAVE_DATA/4)); + ZeroMemory(dimensions,sizeof(std::uint8_t)*(MAXIMUM_MAP_SAVE_DATA/4)); } int _MapDataMappings::getDimension(int id) @@ -84,7 +84,7 @@ _MapDataMappings_old::_MapDataMappings_old() #ifndef _DURANGO ZeroMemory(xuids,sizeof(PlayerUID)*MAXIMUM_MAP_SAVE_DATA); #endif - ZeroMemory(dimensions,sizeof(uint8_t)*(MAXIMUM_MAP_SAVE_DATA/8)); + ZeroMemory(dimensions,sizeof(std::uint8_t)*(MAXIMUM_MAP_SAVE_DATA/8)); } int _MapDataMappings_old::getDimension(int id) @@ -243,7 +243,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() #endif if (!m_bHasLoadedMapDataMappings && !mapFile.getName().empty() && getSaveFile()->doesFileExist( mapFile )) { - DWORD NumberOfBytesRead; + unsigned int NumberOfBytesRead; FileEntry *fileEntry = getSaveFile()->createFile(mapFile); #ifdef __PS3__ @@ -270,7 +270,7 @@ LevelData *DirectoryLevelStorage::prepareLevel() else #endif { - getSaveFile()->setFilePointer(fileEntry,0,NULL, FILE_BEGIN); + getSaveFile()->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin); #ifdef _LARGE_WORLDS byteArray data(fileEntry->getFileSize()); @@ -681,9 +681,9 @@ void DirectoryLevelStorage::saveMapIdLookup() if (!file.getName().empty()) { - DWORD NumberOfBytesWritten; + unsigned int NumberOfBytesWritten; FileEntry *fileEntry = m_saveFile->createFile(file); - m_saveFile->setFilePointer(fileEntry,0,NULL, FILE_BEGIN); + m_saveFile->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin); #ifdef _LARGE_WORLDS ByteArrayOutputStream baos; diff --git a/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp b/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp index a0c8c2d75..5c6d4489f 100644 --- a/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp +++ b/Minecraft.World/Level/Storage/McRegionChunkStorage.cpp @@ -348,7 +348,7 @@ void McRegionChunkStorage::staticCtor() } } -int McRegionChunkStorage::runSaveThreadProc(LPVOID lpParam) +int McRegionChunkStorage::runSaveThreadProc(void *lpParam) { Compression::CreateNewThreadStorage(); diff --git a/Minecraft.World/Level/Storage/McRegionChunkStorage.h b/Minecraft.World/Level/Storage/McRegionChunkStorage.h index bcca14c8a..56fa2800c 100644 --- a/Minecraft.World/Level/Storage/McRegionChunkStorage.h +++ b/Minecraft.World/Level/Storage/McRegionChunkStorage.h @@ -39,5 +39,5 @@ public: private: static void WaitForAllSaves(); static void WaitForSaves(); - static int runSaveThreadProc(LPVOID lpParam); + static int runSaveThreadProc(void *lpParam); }; diff --git a/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp b/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp index 5dcea66cc..336b2f372 100644 --- a/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp +++ b/Minecraft.World/Level/Storage/McRegionLevelStorage.cpp @@ -33,7 +33,7 @@ ChunkStorage *McRegionLevelStorage::createChunkStorage(Dimension *dimension) std::vector *netherFiles = m_saveFile->getRegionFilesByDimension(1); if(netherFiles!=NULL) { - DWORD bytesWritten = 0; + unsigned int bytesWritten = 0; for(AUTO_VAR(it, netherFiles->begin()); it != netherFiles->end(); ++it) { m_saveFile->zeroFile(*it, (*it)->getFileSize(), &bytesWritten); @@ -100,4 +100,4 @@ void McRegionLevelStorage::saveLevelData(LevelData *levelData, std::vector(OldChunkStorageTlsGetValue(tlsIdx)); if( tls == tlsDefault ) return; delete tls; @@ -321,7 +358,7 @@ void OldChunkStorage::save(LevelChunk *lc, Level *level, CompoundTag *tag) // Will be fine so long as we only actually create tags for once chunk at a time. // 4J Stu - As we now save on multiple threads, the static data has been moved to TLS - ThreadStorage *tls = (ThreadStorage *)TlsGetValue(tlsIdx); + ThreadStorage *tls = static_cast(OldChunkStorageTlsGetValue(tlsIdx)); PIXBeginNamedEvent(0,"Getting block data"); //static byteArray blockData = byteArray(32768); diff --git a/Minecraft.World/Level/Storage/OldChunkStorage.h b/Minecraft.World/Level/Storage/OldChunkStorage.h index 2d09498c6..34d100720 100644 --- a/Minecraft.World/Level/Storage/OldChunkStorage.h +++ b/Minecraft.World/Level/Storage/OldChunkStorage.h @@ -4,6 +4,9 @@ #include "../../IO/Files/File.h" #include "../../IO/NBT/CompoundTag.h" #include "../../Headers/com.mojang.nbt.h" +#if !defined(_WIN32) +#include +#endif class Level; @@ -22,7 +25,11 @@ private: ThreadStorage(); ~ThreadStorage(); }; +#if defined(_WIN32) static DWORD tlsIdx; +#else + static pthread_key_t tlsIdx; +#endif static ThreadStorage *tlsDefault; public: // Each new thread that needs to use Compression will need to call one of the following 2 functions, to either create its own diff --git a/Minecraft.World/Level/Storage/RegionFile.cpp b/Minecraft.World/Level/Storage/RegionFile.cpp index b4bd43a43..d47a0eddf 100644 --- a/Minecraft.World/Level/Storage/RegionFile.cpp +++ b/Minecraft.World/Level/Storage/RegionFile.cpp @@ -39,7 +39,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) */ fileEntry = m_saveFile->createFile( fileName->getName() ); - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); + m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::End ); if ( fileEntry->getFileSize() < SECTOR_BYTES) { @@ -57,10 +57,10 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) //if ((GetFileSize(file,NULL) & 0xfff) != 0) if ((fileEntry->getFileSize() & 0xfff) != 0) { - //uint8_t zero = 0; - DWORD numberOfBytesWritten = 0; - DWORD bytesToWrite = 0x1000 - (fileEntry->getFileSize() & 0xfff); - uint8_t *zeroBytes = new uint8_t[ bytesToWrite ]; + //std::uint8_t zero = 0; + unsigned int numberOfBytesWritten = 0; + unsigned int bytesToWrite = 0x1000 - (fileEntry->getFileSize() & 0xfff); + std::uint8_t *zeroBytes = new std::uint8_t[ bytesToWrite ]; ZeroMemory(zeroBytes, bytesToWrite); /* the file size is not a multiple of 4KB, grow it */ @@ -91,11 +91,11 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) sectorFree->at(0) = false; // chunk offset table sectorFree->at(1) = false; // for the last modified info - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::Begin ); for (int i = 0; i < SECTOR_INTS; ++i) { unsigned int offset = 0; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesRead = 0; if( !m_bIsEmpty ) // 4J added condition, don't read back if we've just created an empty file as we don't immediately write this anymore { m_saveFile->readFile(fileEntry, &offset, 4, &numberOfBytesRead); @@ -115,7 +115,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) for (int i = 0; i < SECTOR_INTS; ++i) { int lastModValue = 0; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesRead = 0; if( !m_bIsEmpty ) // 4J added condition, don't read back if we've just created an empty file as we don't immediately write this anymore { m_saveFile->readFile(fileEntry, &lastModValue, 4, &numberOfBytesRead); @@ -138,12 +138,12 @@ void RegionFile::writeAllOffsets() // used for the file ConsoleSaveFile conversi // save all the offsets and timestamps m_saveFile->LockSaveAccess(); - DWORD numberOfBytesWritten = 0; - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); + unsigned int numberOfBytesWritten = 0; + m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::Begin ); m_saveFile->writeFile(fileEntry,offsets, SECTOR_BYTES ,&numberOfBytesWritten); numberOfBytesWritten = 0; - m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES, SaveFileSeekOrigin::Begin ); m_saveFile->writeFile(fileEntry, chunkTimestamps, SECTOR_BYTES, &numberOfBytesWritten); m_saveFile->ReleaseSaveAccess(); @@ -199,13 +199,13 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was m_saveFile->LockSaveAccess(); //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, SaveFileSeekOrigin::Begin); unsigned int length; unsigned int decompLength; unsigned int readDecompLength; - DWORD numberOfBytesRead = 0; + unsigned int numberOfBytesRead = 0; // 4J - this differs a bit from the java file format. Java has length stored as an int, then a type as a byte, then length-1 bytes of data // We store length and decompression length as ints, then length bytes of xbox LZX compressed data @@ -233,8 +233,8 @@ DataInputStream *RegionFile::getChunkDataInputStream(int x, int z) // TODO - was } MemSect(50); - uint8_t *data = new uint8_t[length]; - uint8_t *decomp = new uint8_t[decompLength]; + std::uint8_t *data = new std::uint8_t[length]; + std::uint8_t *decomp = new std::uint8_t[decompLength]; MemSect(0); readDecompLength = decompLength; m_saveFile->readFile(fileEntry,data,length,&numberOfBytesRead); @@ -273,10 +273,10 @@ DataOutputStream *RegionFile::getChunkDataOutputStream(int x, int z) } /* write a chunk at (x,z) with length bytes of data to disk */ -void RegionFile::write(int x, int z, uint8_t *data, int length) // TODO - was synchronized +void RegionFile::write(int x, int z, std::uint8_t *data, int length) // TODO - was synchronized { // 4J Stu - Do the compression here so that we know how much space we need to store the compressed data - uint8_t *compData = new uint8_t[length + 2048]; // presuming compression is going to make this smaller... UPDATE - for some really small things this isn't the case. Added 2K on here to cover those. + std::uint8_t *compData = new std::uint8_t[length + 2048]; // presuming compression is going to make this smaller... UPDATE - for some really small things this isn't the case. Added 2K on here to cover those. unsigned int compLength = length; Compression::getCompression()->CompressLZXRLE(compData,&compLength,data,length); @@ -373,13 +373,13 @@ void RegionFile::write(int x, int z, uint8_t *data, int length) // TODO - was s */ // debug("SAVE", x, z, length, "grow"); //SetFilePointer(file,0,0,FILE_END); - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); + m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::End ); sectorNumber = (int)sectorFree->size(); #ifndef _CONTENT_PACAKGE //wprintf(L"Writing chunk (%d,%d) in %ls from new sector %d to %d\n", x,z, fileEntry->data.filename, sectorNumber, sectorNumber + sectorsNeeded - 1); #endif - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; for (int i = 0; i < sectorsNeeded; ++i) { //WriteFile(file,emptySector.data,SECTOR_BYTES,&numberOfBytesWritten,NULL); @@ -403,11 +403,11 @@ void RegionFile::write(int x, int z, uint8_t *data, int length) // TODO - was s } /* write a chunk data to the region file at specified sector number */ -void RegionFile::write(int sectorNumber, uint8_t *data, int length, unsigned int compLength) +void RegionFile::write(int sectorNumber, std::uint8_t *data, int length, unsigned int compLength) { - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, SaveFileSeekOrigin::Begin ); // 4J - this differs a bit from the java file format. Java has length stored as an int, then a type as a byte, then length-1 bytes of data // We store length and decompression length as ints, then length bytes of xbox LZX compressed data @@ -424,9 +424,9 @@ void RegionFile::write(int sectorNumber, uint8_t *data, int length, unsigned int void RegionFile::zero(int sectorNumber, int length) { - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; //SetFilePointer(file,sectorNumber * SECTOR_BYTES,0,FILE_BEGIN); - m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, sectorNumber * SECTOR_BYTES, SaveFileSeekOrigin::Begin ); m_saveFile->zeroFile( fileEntry, length, &numberOfBytesWritten ); } @@ -449,9 +449,9 @@ bool RegionFile::hasChunk(int x, int z) // 4J added - write the initial two sectors that used to be written in the ctor when the file was empty void RegionFile::insertInitialSectors() { - m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_BEGIN ); - DWORD numberOfBytesWritten = 0; - uint8_t zeroBytes[ SECTOR_BYTES ]; + m_saveFile->setFilePointer( fileEntry, 0, SaveFileSeekOrigin::Begin ); + unsigned int numberOfBytesWritten = 0; + std::uint8_t zeroBytes[ SECTOR_BYTES ]; ZeroMemory(zeroBytes, SECTOR_BYTES); /* we need to write the chunk offset table */ @@ -470,9 +470,9 @@ void RegionFile::setOffset(int x, int z, int offset) insertInitialSectors(); // 4J added } - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; offsets[x + z * 32] = offset; - m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, (x + z * 32) * 4, SaveFileSeekOrigin::Begin ); m_saveFile->writeFile(fileEntry,&offset,4,&numberOfBytesWritten); } @@ -484,9 +484,9 @@ void RegionFile::setTimestamp(int x, int z, int value) insertInitialSectors(); // 4J added } - DWORD numberOfBytesWritten = 0; + unsigned int numberOfBytesWritten = 0; chunkTimestamps[x + z * 32] = value; - m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, NULL, FILE_BEGIN ); + m_saveFile->setFilePointer( fileEntry, SECTOR_BYTES + (x + z * 32) * 4, SaveFileSeekOrigin::Begin ); m_saveFile->writeFile(fileEntry,&value,4,&numberOfBytesWritten); } diff --git a/Minecraft.World/Level/Storage/ZoneFile.cpp b/Minecraft.World/Level/Storage/ZoneFile.cpp index f90290683..fc60cc54c 100644 --- a/Minecraft.World/Level/Storage/ZoneFile.cpp +++ b/Minecraft.World/Level/Storage/ZoneFile.cpp @@ -3,6 +3,28 @@ #include "../../IO/Files/File.h" #include "ZoneFile.h" +namespace +{ + std::FILE *OpenBinaryFileForReadWrite(const File &file) + { +#if defined(_WIN32) + std::FILE *stream = _wfopen(file.getPath().c_str(), L"r+b"); + if (stream == NULL) + { + stream = _wfopen(file.getPath().c_str(), L"w+b"); + } +#else + const std::string nativePath = wstringtofilename(file.getPath()); + std::FILE *stream = std::fopen(nativePath.c_str(), "r+b"); + if (stream == NULL) + { + stream = std::fopen(nativePath.c_str(), "w+b"); + } +#endif + return stream; + } +} + const int ZoneFile::slotsLength = ZonedChunkStorage::CHUNKS_PER_ZONE * ZonedChunkStorage::CHUNKS_PER_ZONE; @@ -23,7 +45,7 @@ ZoneFile::ZoneFile(__int64 key, File file, File entityFile) : slots(slotsLength) // this.entityFile = new NbtSlotFile(entityFile); // } - channel = CreateFile(wstringtofilename(file.getPath()), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + channel = OpenBinaryFileForReadWrite(file); // 4J - try/catch removed // try { readHeader(); @@ -71,7 +93,11 @@ void ZoneFile::writeHeader() void ZoneFile::close() { - CloseHandle(channel); + if (channel != NULL) + { + std::fclose(channel); + channel = NULL; + } entityFile->close(); } @@ -89,4 +115,4 @@ ZoneIo *ZoneFile::getZoneIo(int slot) bool ZoneFile::containsSlot(int slot) { return slots[slot] > 0; -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/Storage/ZoneFile.h b/Minecraft.World/Level/Storage/ZoneFile.h index bc055f25f..75e402918 100644 --- a/Minecraft.World/Level/Storage/ZoneFile.h +++ b/Minecraft.World/Level/Storage/ZoneFile.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "ZonedChunkStorage.h" #include "../../IO/NBT/NbtSlotFile.h" #include "ZoneIO.h" @@ -20,7 +22,7 @@ public: __int64 lastUse; private: - HANDLE channel; + std::FILE *channel; public: __int64 key; diff --git a/Minecraft.World/Level/Storage/ZoneIO.cpp b/Minecraft.World/Level/Storage/ZoneIO.cpp index 8899fa76c..9789fae2b 100644 --- a/Minecraft.World/Level/Storage/ZoneIO.cpp +++ b/Minecraft.World/Level/Storage/ZoneIO.cpp @@ -2,7 +2,19 @@ #include "../../IO/Streams/ByteBuffer.h" #include "ZoneIO.h" -ZoneIo::ZoneIo(HANDLE channel, __int64 pos) +namespace +{ + bool SeekFile(std::FILE *file, __int64 offset) + { +#if defined(_WIN32) + return _fseeki64(file, offset, SEEK_SET) == 0; +#else + return fseeko(file, static_cast(offset), SEEK_SET) == 0; +#endif + } +} + +ZoneIo::ZoneIo(std::FILE *channel, __int64 pos) { this->channel = channel; this->pos = pos; @@ -21,23 +33,21 @@ void ZoneIo::write(byteArray bb, int size) void ZoneIo::write(ByteBuffer *bb, int size) { - DWORD numberOfBytesWritten; - SetFilePointer(channel,(int)pos,NULL,NULL); - WriteFile(channel,bb->getBuffer(), bb->getSize(),&numberOfBytesWritten,NULL); + SeekFile(channel, pos); + std::fwrite(bb->getBuffer(), 1, bb->getSize(), channel); pos += size; } ByteBuffer *ZoneIo::read(int size) { - DWORD numberOfBytesRead; byteArray bb = byteArray(size); - SetFilePointer(channel,(int)pos,NULL,NULL); + SeekFile(channel, pos); ByteBuffer *buff = ByteBuffer::wrap(bb); // 4J - to investigate - why is this buffer flipped before anything goes in it? buff->order(ZonedChunkStorage::BYTEORDER); buff->position(size); buff->flip(); - ReadFile(channel, buff->getBuffer(), buff->getSize(), &numberOfBytesRead, NULL); + std::fread(buff->getBuffer(), 1, buff->getSize(), channel); pos += size; return buff; } @@ -45,4 +55,4 @@ ByteBuffer *ZoneIo::read(int size) void ZoneIo::flush() { // 4J - was channel.force(false); -} \ No newline at end of file +} diff --git a/Minecraft.World/Level/Storage/ZoneIO.h b/Minecraft.World/Level/Storage/ZoneIO.h index 22473583a..6bf1dbd04 100644 --- a/Minecraft.World/Level/Storage/ZoneIO.h +++ b/Minecraft.World/Level/Storage/ZoneIO.h @@ -1,4 +1,6 @@ #pragma once +#include + #include "ZonedChunkStorage.h" class ByteBuffer; @@ -6,11 +8,11 @@ class ByteBuffer; class ZoneIo { private: - HANDLE channel; + std::FILE *channel; __int64 pos; public: - ZoneIo(HANDLE channel, __int64 pos); + ZoneIo(std::FILE *channel, __int64 pos); void write(byteArray bb, int size); void write(ByteBuffer *bb, int size); ByteBuffer *read(int size); diff --git a/Minecraft.World/Network/Connection.cpp b/Minecraft.World/Network/Connection.cpp index aec8254be..a67ee7623 100644 --- a/Minecraft.World/Network/Connection.cpp +++ b/Minecraft.World/Network/Connection.cpp @@ -33,9 +33,6 @@ void Connection::_init() fakeLag = 0; slowWriteDelay = 50; - saqThreadID = 0; - closeThreadID = 0; - tickCount = 0; } @@ -380,7 +377,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...) // return( sum ? (sum / count) : 0 ); -// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID); +// CreateThread(NULL, 0, runClose, this, 0, NULL); running = false; @@ -525,7 +522,7 @@ void Connection::sendAndQuit() close(DisconnectPacket::eDisconnect_Closed); } #else - CreateThread(NULL, 0, runSendAndQuit, this, 0, &saqThreadID); + CreateThread(NULL, 0, runSendAndQuit, this, 0, NULL); #endif } @@ -606,7 +603,7 @@ int Connection::runWrite(void* lpParam) // 4J Stu - Adding this to force us to run through the writeTick at least once after the event is fired // Otherwise there is a race between the calling thread setting the running flag and this loop checking the condition - DWORD waitResult = WAIT_TIMEOUT; + unsigned int waitResult = WAIT_TIMEOUT; while ((con->running || waitResult == 0 ) && ShutdownManager::ShouldRun(ShutdownManager::eConnectionWriteThreads)) { diff --git a/Minecraft.World/Network/Connection.h b/Minecraft.World/Network/Connection.h index 420f82358..c29bf9e71 100644 --- a/Minecraft.World/Network/Connection.h +++ b/Minecraft.World/Network/Connection.h @@ -19,11 +19,6 @@ class ByteArrayOutputStream; class Connection { - friend DWORD WINAPI runRead(LPVOID lpParam); - friend DWORD WINAPI runWrite(LPVOID lpParam); - friend DWORD WINAPI runSendAndQuit(LPVOID lpParam); - friend DWORD WINAPI runClose(LPVOID lpParam); - private: static const int SEND_BUFFER_SIZE = 1024 * 5; @@ -68,8 +63,6 @@ private: C4JThread::Event* m_hWakeReadThread; C4JThread::Event* m_hWakeWriteThread; - DWORD saqThreadID, closeThreadID; - bool disconnected; DisconnectPacket::eDisconnectReason disconnectReason; void **disconnectReasonObjects; // 4J a pointer to an array. diff --git a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp index 64ff58608..57c3a5214 100644 --- a/Minecraft.World/Network/Packets/AddPlayerPacket.cpp +++ b/Minecraft.World/Network/Packets/AddPlayerPacket.cpp @@ -1,4 +1,5 @@ #include "../../Platform/stdafx.h" +#include #include #include "../../IO/Streams/InputOutputStream.h" #include "../../Headers/net.minecraft.world.entity.player.h" @@ -44,9 +45,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, // 4J - changed - send current "previously sent" value of rotations to put this in sync with other clients yRot = yRotp; xRot = xRotp; - yHeadRot = static_cast(yHeadRotp); // 4J Added - // yRot = (uint8_t) (player->yRot * 256 / 360); - // xRot = (uint8_t) (player->xRot * 256 / 360); + yHeadRot = static_cast(yHeadRotp); // 4J Added + // yRot = (std::uint8_t) (player->yRot * 256 / 360); + // xRot = (std::uint8_t) (player->xRot * 256 / 360); //printf("%d: New add player (%f,%f,%f) : (%d,%d,%d) : xRot %d, yRot %d\n",id,player->x,player->y,player->z,x,y,z,xRot,yRot); @@ -55,7 +56,7 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, this->xuid = xuid; this->OnlineXuid = OnlineXuid; - m_playerIndex = (BYTE)player->getPlayerIndex(); + m_playerIndex = static_cast(player->getPlayerIndex()); m_skinId = player->getCustomSkin(); m_capeId = player->getCustomCape(); m_uiGamePrivileges = player->getAllPlayerGamePrivileges(); @@ -77,13 +78,11 @@ void AddPlayerPacket::read(DataInputStream *dis) //throws IOException carriedItem = dis->readShort(); xuid = dis->readPlayerUID(); OnlineXuid = dis->readPlayerUID(); - m_playerIndex = static_cast(dis->readByte()); - INT skinId = dis->readInt(); - m_skinId = *(DWORD *)&skinId; - INT capeId = dis->readInt(); - m_capeId = *(DWORD *)&capeId; + m_playerIndex = dis->readByte(); + m_skinId = static_cast(dis->readInt()); + m_capeId = static_cast(dis->readInt()); INT privileges = dis->readInt(); - m_uiGamePrivileges = *(unsigned int *)&privileges; + m_uiGamePrivileges = static_cast(privileges); MemSect(1); unpack = SynchedEntityData::unpack(dis); MemSect(0); @@ -96,15 +95,15 @@ void AddPlayerPacket::write(DataOutputStream *dos) //throws IOException dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); - dos->writeByte(static_cast(yRot)); - dos->writeByte(static_cast(xRot)); - dos->writeByte(static_cast(m_playerIndex)); // 4J Added + dos->writeByte(static_cast(yRot)); + dos->writeByte(static_cast(xRot)); + dos->writeByte(static_cast(m_playerIndex)); // 4J Added dos->writeShort(carriedItem); dos->writePlayerUID(xuid); dos->writePlayerUID(OnlineXuid); - dos->writeByte(static_cast(m_playerIndex)); // 4J Added - dos->writeInt(m_skinId); - dos->writeInt(m_capeId); + dos->writeByte(static_cast(m_playerIndex)); // 4J Added + dos->writeInt(static_cast(m_skinId)); + dos->writeInt(static_cast(m_capeId)); dos->writeInt(m_uiGamePrivileges); entityData->packAll(dos); @@ -117,7 +116,7 @@ void AddPlayerPacket::handle(PacketListener *listener) int AddPlayerPacket::getEstimatedSize() { - int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(BYTE) + sizeof(BYTE) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(BYTE) + sizeof(unsigned int) + sizeof(uint8_t); + int iSize= sizeof(int) + Player::MAX_NAME_LENGTH + sizeof(int) + sizeof(int) + sizeof(int) + sizeof(std::uint8_t) + sizeof(std::uint8_t) +sizeof(short) + sizeof(PlayerUID) + sizeof(PlayerUID) + sizeof(int) + sizeof(std::uint8_t) + sizeof(unsigned int) + sizeof(std::uint8_t); if( entityData != NULL ) { diff --git a/Minecraft.World/Network/Packets/AddPlayerPacket.h b/Minecraft.World/Network/Packets/AddPlayerPacket.h index 80a5c3dfb..1cef92752 100644 --- a/Minecraft.World/Network/Packets/AddPlayerPacket.h +++ b/Minecraft.World/Network/Packets/AddPlayerPacket.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Packet.h" #include "../../Entities/SyncedEntityData.h" @@ -18,14 +19,14 @@ public: std::wstring name; int x, y, z; char yRot, xRot; - int carriedItem; + int carriedItem; PlayerUID xuid; // 4J Added PlayerUID OnlineXuid; // 4J Added - BYTE m_playerIndex; // 4J Added - DWORD m_skinId; // 4J Added - DWORD m_capeId; // 4J Added + std::uint8_t m_playerIndex; // 4J Added + std::uint32_t m_skinId; // 4J Added + std::uint32_t m_capeId; // 4J Added unsigned int m_uiGamePrivileges; // 4J Added - uint8_t yHeadRot; // 4J Added + std::uint8_t yHeadRot; // 4J Added AddPlayerPacket(); ~AddPlayerPacket(); diff --git a/Minecraft.World/Network/Packets/KickPlayerPacket.cpp b/Minecraft.World/Network/Packets/KickPlayerPacket.cpp index 502fd6b86..fde36a1b8 100644 --- a/Minecraft.World/Network/Packets/KickPlayerPacket.cpp +++ b/Minecraft.World/Network/Packets/KickPlayerPacket.cpp @@ -11,7 +11,7 @@ KickPlayerPacket::KickPlayerPacket() m_networkSmallId = 0; } -KickPlayerPacket::KickPlayerPacket(BYTE networkSmallId) +KickPlayerPacket::KickPlayerPacket(std::uint8_t networkSmallId) { m_networkSmallId = networkSmallId; } @@ -23,12 +23,12 @@ void KickPlayerPacket::handle(PacketListener *listener) void KickPlayerPacket::read(DataInputStream *dis) //throws IOException { - m_networkSmallId = (int)dis->readByte(); + m_networkSmallId = dis->readByte(); } void KickPlayerPacket::write(DataOutputStream *dos) //throws IOException { - dos->writeByte((uint8_t)m_networkSmallId); + dos->writeByte((std::uint8_t)m_networkSmallId); } int KickPlayerPacket::getEstimatedSize() diff --git a/Minecraft.World/Network/Packets/KickPlayerPacket.h b/Minecraft.World/Network/Packets/KickPlayerPacket.h index 37e4655c5..30c04b4c6 100644 --- a/Minecraft.World/Network/Packets/KickPlayerPacket.h +++ b/Minecraft.World/Network/Packets/KickPlayerPacket.h @@ -1,15 +1,16 @@ #pragma once +#include #include "Packet.h" class KickPlayerPacket : public Packet, public std::enable_shared_from_this { public: - BYTE m_networkSmallId; + std::uint8_t m_networkSmallId; KickPlayerPacket(); - KickPlayerPacket(BYTE networkSmallId); + KickPlayerPacket(std::uint8_t networkSmallId); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis); @@ -19,4 +20,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new KickPlayerPacket()); } virtual int getId() { return 159; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/LoginPacket.cpp b/Minecraft.World/Network/Packets/LoginPacket.cpp index e13d26ab9..9d2d3364d 100644 --- a/Minecraft.World/Network/Packets/LoginPacket.cpp +++ b/Minecraft.World/Network/Packets/LoginPacket.cpp @@ -1,4 +1,5 @@ #include "../../Platform/stdafx.h" +#include #include #include "../../IO/Streams/InputOutputStream.h" #include "../../Headers/net.minecraft.world.entity.player.h" @@ -36,7 +37,7 @@ LoginPacket::LoginPacket() } // Client -> Server -LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, PlayerUID offlineXuid, PlayerUID onlineXuid, bool friendsOnlyUGC, DWORD ugcPlayersVersion, DWORD skinId, DWORD capeId, bool isGuest) +LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, PlayerUID offlineXuid, PlayerUID onlineXuid, bool friendsOnlyUGC, std::uint32_t ugcPlayersVersion, std::uint32_t skinId, std::uint32_t capeId, bool isGuest) { this->userName = userName; this->clientVersion = clientVersion; @@ -65,7 +66,7 @@ LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, Player } // Server -> Client -LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, LevelType *pLevelType, __int64 seed, int gameType, char dimension, BYTE mapHeight, BYTE maxPlayers, char difficulty, INT multiplayerInstanceId, BYTE playerIndex, bool newSeaLevel, unsigned int uiGamePrivileges, int xzSize, int hellScale) +LoginPacket::LoginPacket(const std::wstring& userName, int clientVersion, LevelType *pLevelType, __int64 seed, int gameType, char dimension, std::uint8_t mapHeight, std::uint8_t maxPlayers, char difficulty, int multiplayerInstanceId, std::uint8_t playerIndex, bool newSeaLevel, unsigned int uiGamePrivileges, int xzSize, int hellScale) { this->userName = userName; this->clientVersion = clientVersion; @@ -106,19 +107,17 @@ void LoginPacket::read(DataInputStream *dis) //throws IOException seed = dis->readLong(); gameType = dis->readInt(); dimension = (int)dis->readByte(); - mapHeight = (int)dis->readByte(); - maxPlayers = (int)dis->readByte(); + mapHeight = dis->readByte(); + maxPlayers = dis->readByte(); m_offlineXuid = dis->readPlayerUID(); m_onlineXuid = dis->readPlayerUID(); m_friendsOnlyUGC = dis->readBoolean(); - m_ugcPlayersVersion = dis->readInt(); + m_ugcPlayersVersion = static_cast(dis->readInt()); difficulty = (int)dis->readByte(); m_multiplayerInstanceId = dis->readInt(); - m_playerIndex = (int)dis->readByte(); - INT skinId = dis->readInt(); - m_playerSkinId = *(DWORD *)&skinId; - INT capeId = dis->readInt(); - m_playerCapeId = *(DWORD *)&capeId; + m_playerIndex = dis->readByte(); + m_playerSkinId = static_cast(dis->readInt()); + m_playerCapeId = static_cast(dis->readInt()); m_isGuest = dis->readBoolean(); m_newSeaLevel = dis->readBoolean(); m_uiGamePrivileges = dis->readInt(); @@ -144,18 +143,18 @@ void LoginPacket::write(DataOutputStream *dos) //throws IOException } dos->writeLong(seed); dos->writeInt(gameType); - dos->writeByte((uint8_t)dimension); - dos->writeByte((uint8_t)mapHeight); - dos->writeByte((uint8_t)maxPlayers); + dos->writeByte((std::uint8_t)dimension); + dos->writeByte((std::uint8_t)mapHeight); + dos->writeByte((std::uint8_t)maxPlayers); dos->writePlayerUID(m_offlineXuid); dos->writePlayerUID(m_onlineXuid); dos->writeBoolean(m_friendsOnlyUGC); - dos->writeInt(m_ugcPlayersVersion); - dos->writeByte((uint8_t)difficulty); + dos->writeInt(static_cast(m_ugcPlayersVersion)); + dos->writeByte((std::uint8_t)difficulty); dos->writeInt(m_multiplayerInstanceId); - dos->writeByte((uint8_t)m_playerIndex); - dos->writeInt(m_playerSkinId); - dos->writeInt(m_playerCapeId); + dos->writeByte((std::uint8_t)m_playerIndex); + dos->writeInt(static_cast(m_playerSkinId)); + dos->writeInt(static_cast(m_playerCapeId)); dos->writeBoolean(m_isGuest); dos->writeBoolean(m_newSeaLevel); dos->writeInt(m_uiGamePrivileges); @@ -178,5 +177,5 @@ int LoginPacket::getEstimatedSize() length = (int)m_pLevelType->getGeneratorName().length(); } - return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(__int64) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) +1 + sizeof(char) + sizeof(BYTE) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); + return (int)(sizeof(int) + userName.length() + 4 + 6 + sizeof(__int64) + sizeof(char) + sizeof(int) + (2*sizeof(PlayerUID)) + 1 + sizeof(char) + sizeof(std::uint8_t) + sizeof(bool) + sizeof(bool) + length + sizeof(unsigned int)); } diff --git a/Minecraft.World/Network/Packets/LoginPacket.h b/Minecraft.World/Network/Packets/LoginPacket.h index d0bfb030a..b6f14816a 100644 --- a/Minecraft.World/Network/Packets/LoginPacket.h +++ b/Minecraft.World/Network/Packets/LoginPacket.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Packet.h" class LevelType; @@ -14,10 +15,10 @@ public: PlayerUID m_offlineXuid, m_onlineXuid; // 4J Added char difficulty; // 4J Added bool m_friendsOnlyUGC; // 4J Added - DWORD m_ugcPlayersVersion; // 4J Added - INT m_multiplayerInstanceId; //4J Added for sentient - BYTE m_playerIndex; // 4J Added - DWORD m_playerSkinId, m_playerCapeId; // 4J Added + std::uint32_t m_ugcPlayersVersion; // 4J Added + int m_multiplayerInstanceId; //4J Added for sentient + std::uint8_t m_playerIndex; // 4J Added + std::uint32_t m_playerSkinId, m_playerCapeId; // 4J Added bool m_isGuest; // 4J Added bool m_newSeaLevel; // 4J Added LevelType *m_pLevelType; @@ -27,12 +28,12 @@ public: // 1.8.2 int gameType; - BYTE mapHeight; - BYTE maxPlayers; + std::uint8_t mapHeight; + std::uint8_t maxPlayers; LoginPacket(); - LoginPacket(const std::wstring& userName, int clientVersion, LevelType *pLevelType, __int64 seed, int gameType, char dimension, BYTE mapHeight, BYTE maxPlayers, char difficulty, INT m_multiplayerInstanceId, BYTE playerIndex, bool newSeaLevel, unsigned int uiGamePrivileges, int xzSize, int hellScale); // Server -> Client - LoginPacket(const std::wstring& userName, int clientVersion, PlayerUID offlineXuid, PlayerUID onlineXuid, bool friendsOnlyUGC, DWORD ugcPlayersVersion, DWORD skinId, DWORD capeId, bool isGuest); // Client -> Server + LoginPacket(const std::wstring& userName, int clientVersion, LevelType *pLevelType, __int64 seed, int gameType, char dimension, std::uint8_t mapHeight, std::uint8_t maxPlayers, char difficulty, int m_multiplayerInstanceId, std::uint8_t playerIndex, bool newSeaLevel, unsigned int uiGamePrivileges, int xzSize, int hellScale); // Server -> Client + LoginPacket(const std::wstring& userName, int clientVersion, PlayerUID offlineXuid, PlayerUID onlineXuid, bool friendsOnlyUGC, std::uint32_t ugcPlayersVersion, std::uint32_t skinId, std::uint32_t capeId, bool isGuest); // Client -> Server virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); diff --git a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp index 4b9056386..786d2734d 100644 --- a/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp +++ b/Minecraft.World/Network/Packets/PlayerInfoPacket.cpp @@ -19,7 +19,7 @@ PlayerInfoPacket::PlayerInfoPacket() m_entityId = -1; } -PlayerInfoPacket::PlayerInfoPacket(BYTE networkSmallId, short playerColourIndex, unsigned int playerPrivileges) +PlayerInfoPacket::PlayerInfoPacket(std::uint8_t networkSmallId, short playerColourIndex, unsigned int playerPrivileges) { m_networkSmallId = networkSmallId; m_playerColourIndex = playerColourIndex; diff --git a/Minecraft.World/Network/Packets/PlayerInfoPacket.h b/Minecraft.World/Network/Packets/PlayerInfoPacket.h index fd4c83451..0c98036df 100644 --- a/Minecraft.World/Network/Packets/PlayerInfoPacket.h +++ b/Minecraft.World/Network/Packets/PlayerInfoPacket.h @@ -1,4 +1,5 @@ #pragma once +#include #include "Packet.h" @@ -11,14 +12,14 @@ class PlayerInfoPacket : public Packet, public std::enable_shared_from_this player); virtual void read(DataInputStream *dis); @@ -29,4 +30,4 @@ class PlayerInfoPacket : public Packet, public std::enable_shared_from_this create() { return std::shared_ptr(new PlayerInfoPacket()); } virtual int getId() { return 201; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/PreLoginPacket.cpp b/Minecraft.World/Network/Packets/PreLoginPacket.cpp index 2cc287ec0..9bb385884 100644 --- a/Minecraft.World/Network/Packets/PreLoginPacket.cpp +++ b/Minecraft.World/Network/Packets/PreLoginPacket.cpp @@ -1,4 +1,6 @@ #include "../../Platform/stdafx.h" +#include +#include #include #include "PacketListener.h" #include "PreLoginPacket.h" @@ -32,7 +34,7 @@ PreLoginPacket::PreLoginPacket(std::wstring userName) m_netcodeVersion = 0; } -PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, DWORD texturePackId) +PreLoginPacket::PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, std::uint8_t playerCount, std::uint8_t friendsOnlyBits, std::uint32_t ugcPlayersVersion, const char *pszUniqueSaveName, std::uint32_t serverSettings, std::uint8_t hostIndex, std::uint32_t texturePackId) { this->loginKey = userName; m_playerXuids = playerXuids; @@ -58,25 +60,24 @@ void PreLoginPacket::read(DataInputStream *dis) //throws IOException loginKey = readUtf(dis, 32); m_friendsOnlyBits = dis->readByte(); - m_ugcPlayersVersion = dis->readInt(); + m_ugcPlayersVersion = static_cast(dis->readInt()); m_dwPlayerCount = dis->readByte(); if( m_dwPlayerCount > 0 ) { m_playerXuids = new PlayerUID[m_dwPlayerCount]; - for(DWORD i = 0; i < m_dwPlayerCount; ++i) + for(std::uint32_t i = 0; i < m_dwPlayerCount; ++i) { m_playerXuids[i] = dis->readPlayerUID(); } } - for(DWORD i = 0; i < m_iSaveNameLen; ++i) + for(int i = 0; i < m_iSaveNameLen; ++i) { - m_szUniqueSaveName[i]=dis->readByte(); + m_szUniqueSaveName[i] = static_cast(dis->readByte()); } - m_serverSettings = dis->readInt(); + m_serverSettings = static_cast(dis->readInt()); m_hostIndex = dis->readByte(); - INT texturePackId = dis->readInt(); - m_texturePackId = *(DWORD *)&texturePackId; + m_texturePackId = static_cast(dis->readInt()); // Set the name of the map so we can check it for players banned lists app.SetUniqueMapName((char *)m_szUniqueSaveName); @@ -89,21 +90,21 @@ void PreLoginPacket::write(DataOutputStream *dos) //throws IOException writeUtf(loginKey, dos); dos->writeByte(m_friendsOnlyBits); - dos->writeInt(m_ugcPlayersVersion); - dos->writeByte((uint8_t)m_dwPlayerCount); - for(DWORD i = 0; i < m_dwPlayerCount; ++i) + dos->writeInt(static_cast(m_ugcPlayersVersion)); + dos->writeByte((std::uint8_t)m_dwPlayerCount); + for(std::uint32_t i = 0; i < m_dwPlayerCount; ++i) { dos->writePlayerUID( m_playerXuids[i] ); } app.DebugPrintf("*** PreLoginPacket::write - %s\n",m_szUniqueSaveName); - for(DWORD i = 0; i < m_iSaveNameLen; ++i) + for(int i = 0; i < m_iSaveNameLen; ++i) { - dos->writeByte(m_szUniqueSaveName[i]); + dos->writeByte(static_cast(m_szUniqueSaveName[i])); } - dos->writeInt(m_serverSettings); + dos->writeInt(static_cast(m_serverSettings)); dos->writeByte(m_hostIndex); - dos->writeInt(m_texturePackId); + dos->writeInt(static_cast(m_texturePackId)); } void PreLoginPacket::handle(PacketListener *listener) diff --git a/Minecraft.World/Network/Packets/PreLoginPacket.h b/Minecraft.World/Network/Packets/PreLoginPacket.h index c6839b2b6..637cb34dd 100644 --- a/Minecraft.World/Network/Packets/PreLoginPacket.h +++ b/Minecraft.World/Network/Packets/PreLoginPacket.h @@ -1,5 +1,6 @@ #pragma once +#include #include "Packet.h" @@ -12,20 +13,20 @@ public: // join, and so that we can inform the server if we have that privilege set. Anyone with UGC turned off completely // can't play the game online at all, so we only need to specify players with friends only set PlayerUID *m_playerXuids; - DWORD m_dwPlayerCount; - BYTE m_friendsOnlyBits; - DWORD m_ugcPlayersVersion; - BYTE m_szUniqueSaveName[m_iSaveNameLen]; // added for checking if the level is in the ban list - DWORD m_serverSettings; // A bitfield of server settings constructed with the MAKE_SERVER_SETTINGS macro - BYTE m_hostIndex; // Rather than sending the xuid of the host again, send an index into the m_playerXuids array - DWORD m_texturePackId; - SHORT m_netcodeVersion; + std::uint8_t m_dwPlayerCount; + std::uint8_t m_friendsOnlyBits; + std::uint32_t m_ugcPlayersVersion; + char m_szUniqueSaveName[m_iSaveNameLen]; // added for checking if the level is in the ban list + std::uint32_t m_serverSettings; // A bitfield of server settings constructed with the MAKE_SERVER_SETTINGS macro + std::uint8_t m_hostIndex; // Rather than sending the xuid of the host again, send an index into the m_playerXuids array + std::uint32_t m_texturePackId; + std::int16_t m_netcodeVersion; std::wstring loginKey; PreLoginPacket(); PreLoginPacket(std::wstring userName); - PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, DWORD playerCount, BYTE friendsOnlyBits, DWORD ugcPlayersVersion,char *pszUniqueSaveName, DWORD serverSettings, BYTE hostIndex, DWORD texturePackId); + PreLoginPacket(std::wstring userName, PlayerUID *playerXuids, std::uint8_t playerCount, std::uint8_t friendsOnlyBits, std::uint32_t ugcPlayersVersion, const char *pszUniqueSaveName, std::uint32_t serverSettings, std::uint8_t hostIndex, std::uint32_t texturePackId); ~PreLoginPacket(); virtual void read(DataInputStream *dis); @@ -36,4 +37,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new PreLoginPacket()); } virtual int getId() { return 2; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.cpp b/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.cpp index 0115c2bd4..aed41853e 100644 --- a/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.cpp +++ b/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.cpp @@ -31,14 +31,14 @@ TextureAndGeometryChangePacket::TextureAndGeometryChangePacket(std::shared_ptrreadInt(); - dwSkinID = dis->readInt(); + dwSkinID = static_cast(dis->readInt()); path = dis->readUTF(); } void TextureAndGeometryChangePacket::write(DataOutputStream *dos) //throws IOException { dos->writeInt(id); - dos->writeInt(dwSkinID); + dos->writeInt(static_cast(dwSkinID)); dos->writeUTF(path); } diff --git a/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.h b/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.h index 00001d8f3..7584b3c3e 100644 --- a/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.h +++ b/Minecraft.World/Network/Packets/TextureAndGeometryChangePacket.h @@ -1,5 +1,5 @@ #pragma once - +#include #include "Packet.h" @@ -9,7 +9,7 @@ public: int id; std::wstring path; - DWORD dwSkinID; + std::uint32_t dwSkinID; TextureAndGeometryChangePacket(); TextureAndGeometryChangePacket(std::shared_ptr e, const std::wstring &path); @@ -22,4 +22,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new TextureAndGeometryChangePacket()); } virtual int getId() { return 161; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp index 029daa1a6..fa479a143 100644 --- a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp +++ b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.cpp @@ -30,7 +30,7 @@ TextureAndGeometryPacket::~TextureAndGeometryPacket() // } } -TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes) +TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes) { this->textureName = textureName; @@ -41,13 +41,13 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureNa ss >> this->dwSkinID; this->dwSkinID = MAKE_SKIN_BITMASK(true, this->dwSkinID); this->pbData = pbData; - this->dwTextureBytes = dwBytes; + this->dwTextureBytes = dataBytes; this->dwBoxC = 0; this->BoxDataA=NULL; this->uiAnimOverrideBitmask=0; } -TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile) +TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes, DLCSkinFile *pDLCSkinFile) { this->textureName = textureName; @@ -59,7 +59,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureNa this->dwSkinID = MAKE_SKIN_BITMASK(true, this->dwSkinID); this->pbData = pbData; - this->dwTextureBytes = dwBytes; + this->dwTextureBytes = dataBytes; this->uiAnimOverrideBitmask = pDLCSkinFile->getAnimOverrideBitmask(); this->dwBoxC = pDLCSkinFile->getAdditionalBoxesCount(); if(this->dwBoxC!=0) @@ -80,7 +80,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureNa } } -TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes,std::vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask) +TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes,std::vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask) { this->textureName = textureName; @@ -92,7 +92,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureNa this->dwSkinID = MAKE_SKIN_BITMASK(true, this->dwSkinID); this->pbData = pbData; - this->dwTextureBytes = dwBytes; + this->dwTextureBytes = dataBytes; this->uiAnimOverrideBitmask = uiAnimOverrideBitmask; if(pvSkinBoxes==NULL) { @@ -101,7 +101,7 @@ TextureAndGeometryPacket::TextureAndGeometryPacket(const std::wstring &textureNa } else { - this->dwBoxC = (DWORD)pvSkinBoxes->size(); + this->dwBoxC = (std::uint32_t)pvSkinBoxes->size(); this->BoxDataA= new SKIN_BOX [this->dwBoxC]; int iCount=0; @@ -122,28 +122,28 @@ void TextureAndGeometryPacket::handle(PacketListener *listener) void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException { textureName = dis->readUTF(); - dwSkinID = (DWORD)dis->readInt(); - dwTextureBytes = (DWORD)dis->readShort(); + dwSkinID = static_cast(dis->readInt()); + dwTextureBytes = (std::uint32_t)dis->readShort(); if(dwTextureBytes>0) { - this->pbData= new BYTE [dwTextureBytes]; + this->pbData= new std::uint8_t [dwTextureBytes]; - for(DWORD i=0;ipbData[i] = dis->readByte(); } } uiAnimOverrideBitmask = dis->readInt(); - dwBoxC = (DWORD)dis->readShort(); + dwBoxC = (std::uint32_t)dis->readShort(); if(dwBoxC>0) { this->BoxDataA= new SKIN_BOX [dwBoxC]; } - for(DWORD i=0;iBoxDataA[i].ePart = (eBodyPart) dis->readShort(); this->BoxDataA[i].fX = dis->readFloat(); @@ -160,16 +160,16 @@ void TextureAndGeometryPacket::read(DataInputStream *dis) //throws IOException void TextureAndGeometryPacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); - dos->writeInt(dwSkinID); + dos->writeInt(static_cast(dwSkinID)); dos->writeShort((short)dwTextureBytes); - for(DWORD i=0;iwriteByte(this->pbData[i]); } dos->writeInt(uiAnimOverrideBitmask); dos->writeShort((short)dwBoxC); - for(DWORD i=0;iwriteShort((short)this->BoxDataA[i].ePart); dos->writeFloat(this->BoxDataA[i].fX); diff --git a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.h b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.h index f1ca1f7cb..c6470895d 100644 --- a/Minecraft.World/Network/Packets/TextureAndGeometryPacket.h +++ b/Minecraft.World/Network/Packets/TextureAndGeometryPacket.h @@ -1,5 +1,5 @@ #pragma once - +#include #include "Packet.h" #include "../../../Minecraft.Client/Rendering/Models/Model.h" @@ -11,18 +11,18 @@ class TextureAndGeometryPacket : public Packet, public std::enable_shared_from_t { public: std::wstring textureName; - DWORD dwSkinID; - PBYTE pbData; - DWORD dwTextureBytes; + std::uint32_t dwSkinID; + std::uint8_t *pbData; + std::uint32_t dwTextureBytes; SKIN_BOX *BoxDataA; - DWORD dwBoxC; + std::uint32_t dwBoxC; unsigned int uiAnimOverrideBitmask; TextureAndGeometryPacket(); ~TextureAndGeometryPacket(); - TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes); - TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes, DLCSkinFile *pDLCSkinFile); - TextureAndGeometryPacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes, std::vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask); + TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes); + TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes, DLCSkinFile *pDLCSkinFile); + TextureAndGeometryPacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes, std::vector *pvSkinBoxes, unsigned int uiAnimOverrideBitmask); virtual void handle(PacketListener *listener); virtual void read(DataInputStream *dis); diff --git a/Minecraft.World/Network/Packets/TexturePacket.cpp b/Minecraft.World/Network/Packets/TexturePacket.cpp index 09b2bd9cf..bb179a8e5 100644 --- a/Minecraft.World/Network/Packets/TexturePacket.cpp +++ b/Minecraft.World/Network/Packets/TexturePacket.cpp @@ -9,7 +9,7 @@ TexturePacket::TexturePacket() { this->textureName = L""; - this->dwBytes = 0; + this->dataBytes = 0; this->pbData = NULL; } @@ -22,11 +22,11 @@ TexturePacket::~TexturePacket() // } } -TexturePacket::TexturePacket(const std::wstring &textureName, PBYTE pbData, DWORD dwBytes) +TexturePacket::TexturePacket(const std::wstring &textureName, std::uint8_t *pbData, std::uint32_t dataBytes) { this->textureName = textureName; this->pbData = pbData; - this->dwBytes = dwBytes; + this->dataBytes = dataBytes; } void TexturePacket::handle(PacketListener *listener) @@ -37,13 +37,13 @@ void TexturePacket::handle(PacketListener *listener) void TexturePacket::read(DataInputStream *dis) //throws IOException { textureName = dis->readUTF(); - dwBytes = (DWORD)dis->readShort(); + dataBytes = (std::uint32_t)dis->readShort(); - if(dwBytes>0) + if(dataBytes>0) { - this->pbData= new BYTE [dwBytes]; + this->pbData= new std::uint8_t [dataBytes]; - for(DWORD i=0;ipbData[i] = dis->readByte(); } @@ -53,8 +53,8 @@ void TexturePacket::read(DataInputStream *dis) //throws IOException void TexturePacket::write(DataOutputStream *dos) //throws IOException { dos->writeUTF(textureName); - dos->writeShort((short)dwBytes); - for(DWORD i=0;iwriteShort((short)dataBytes); + for(std::uint32_t i=0;iwriteByte(this->pbData[i]); } diff --git a/Minecraft.World/Network/Packets/TexturePacket.h b/Minecraft.World/Network/Packets/TexturePacket.h index d4e199019..dfa5bd70f 100644 --- a/Minecraft.World/Network/Packets/TexturePacket.h +++ b/Minecraft.World/Network/Packets/TexturePacket.h @@ -1,5 +1,5 @@ #pragma once - +#include #include "Packet.h" @@ -7,12 +7,12 @@ class TexturePacket : public Packet, public std::enable_shared_from_this create() { return std::shared_ptr(new TexturePacket()); } virtual int getId() { return 154; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Packets/TileUpdatePacket.cpp b/Minecraft.World/Network/Packets/TileUpdatePacket.cpp index 6c94d0e2b..563461500 100644 --- a/Minecraft.World/Network/Packets/TileUpdatePacket.cpp +++ b/Minecraft.World/Network/Packets/TileUpdatePacket.cpp @@ -33,7 +33,7 @@ void TileUpdatePacket::read(DataInputStream *dis) //throws IOException block = (int)dis->readShort() & 0xffff; - BYTE dataLevel = dis->readByte(); + std::uint8_t dataLevel = dis->readByte(); data = dataLevel & 0xf; levelIdx = (dataLevel>>4) & 0xf; #else @@ -61,7 +61,7 @@ void TileUpdatePacket::write(DataOutputStream *dos) //throws IOException dos->writeInt(z); dos->writeShort(block); - BYTE dataLevel = ((levelIdx & 0xf ) << 4) | (data & 0xf); + std::uint8_t dataLevel = ((levelIdx & 0xf ) << 4) | (data & 0xf); dos->writeByte(dataLevel); #else // 4J - for our fixed size map, we can pack x & z into 10 bits each (-512 -> 511), y into 8 bits (0 to 255) diff --git a/Minecraft.World/Network/Packets/UpdateMobEffectPacket.cpp b/Minecraft.World/Network/Packets/UpdateMobEffectPacket.cpp index 56873ac80..443c24c56 100644 --- a/Minecraft.World/Network/Packets/UpdateMobEffectPacket.cpp +++ b/Minecraft.World/Network/Packets/UpdateMobEffectPacket.cpp @@ -17,7 +17,7 @@ UpdateMobEffectPacket::UpdateMobEffectPacket() UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId, MobEffectInstance *effect) { this->entityId = entityId; - this->effectId = (BYTE) (effect->getId() & 0xff); + this->effectId = static_cast(effect->getId() & 0xff); this->effectAmplifier = (char) (effect->getAmplifier() & 0xff); this->effectDurationTicks = (short) effect->getDuration(); } @@ -57,4 +57,4 @@ bool UpdateMobEffectPacket::isInvalidatedBy(std::shared_ptr packet) { std::shared_ptr target = std::dynamic_pointer_cast(packet); return target->entityId == entityId && target->effectId == effectId; -} \ No newline at end of file +} diff --git a/Minecraft.World/Network/Packets/UpdateMobEffectPacket.h b/Minecraft.World/Network/Packets/UpdateMobEffectPacket.h index 0eeed4dc1..d8d6c879e 100644 --- a/Minecraft.World/Network/Packets/UpdateMobEffectPacket.h +++ b/Minecraft.World/Network/Packets/UpdateMobEffectPacket.h @@ -1,4 +1,5 @@ #pragma once +#include #include "Packet.h" @@ -8,7 +9,7 @@ class UpdateMobEffectPacket : public Packet, public std::enable_shared_from_this { public: int entityId; - BYTE effectId; + std::uint8_t effectId; char effectAmplifier; short effectDurationTicks; @@ -25,4 +26,4 @@ public: public: static std::shared_ptr create() { return std::shared_ptr(new UpdateMobEffectPacket()); } virtual int getId() { return 41; } -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Network/Socket.cpp b/Minecraft.World/Network/Socket.cpp index 4f1025b2a..010b29dfe 100644 --- a/Minecraft.World/Network/Socket.cpp +++ b/Minecraft.World/Network/Socket.cpp @@ -11,7 +11,7 @@ // link, the end (0 or 1) is passed as a parameter to the ctor. CRITICAL_SECTION Socket::s_hostQueueLock[2]; -std::queue Socket::s_hostQueue[2]; +std::queue Socket::s_hostQueue[2]; Socket::SocketOutputStreamLocal *Socket::s_hostOutStream[2]; Socket::SocketInputStreamLocal *Socket::s_hostInStream[2]; ServerConnection *Socket::s_serverConnection = NULL; @@ -49,7 +49,7 @@ void Socket::Initialise(ServerConnection *serverConnection) if(TryEnterCriticalSection(&s_hostQueueLock[i])) { // Clear the queue - std::queue empty; + std::queue empty; std::swap( s_hostQueue[i], empty ); LeaveCriticalSection(&s_hostQueueLock[i]); } @@ -147,7 +147,7 @@ void Socket::setPlayer(INetworkPlayer *player) } } -void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHost /*= true*/) +void Socket::pushDataToQueue(const std::uint8_t *pbData, std::size_t dataSize, bool fromHost /*= true*/) { int queueIdx = SOCKET_CLIENT_END; if(!fromHost) @@ -160,7 +160,7 @@ void Socket::pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHos } EnterCriticalSection(&m_queueLockNetwork[queueIdx]); - for( unsigned int i = 0; i < dwDataSize; i++ ) + for(std::size_t i = 0; i < dataSize; ++i) { m_queueNetwork[queueIdx].push(*pbData++); } @@ -298,7 +298,7 @@ int Socket::SocketInputStreamLocal::read() { if( s_hostQueue[m_queueIdx].size() ) { - uint8_t retval = s_hostQueue[m_queueIdx].front(); + std::uint8_t retval = s_hostQueue[m_queueIdx].front(); s_hostQueue[m_queueIdx].pop(); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); return retval; @@ -344,7 +344,7 @@ void Socket::SocketInputStreamLocal::close() { m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - std::queue().swap(s_hostQueue[m_queueIdx]); + std::queue().swap(s_hostQueue[m_queueIdx]); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); } @@ -363,7 +363,7 @@ void Socket::SocketOutputStreamLocal::write(unsigned int b) return; } EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - s_hostQueue[m_queueIdx].push((uint8_t)b); + s_hostQueue[m_queueIdx].push((std::uint8_t)b); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); } @@ -392,7 +392,7 @@ void Socket::SocketOutputStreamLocal::close() { m_streamOpen = false; EnterCriticalSection(&s_hostQueueLock[m_queueIdx]); - std::queue().swap(s_hostQueue[m_queueIdx]); + std::queue().swap(s_hostQueue[m_queueIdx]); LeaveCriticalSection(&s_hostQueueLock[m_queueIdx]); } @@ -414,7 +414,7 @@ int Socket::SocketInputStreamNetwork::read() { if( m_socket->m_queueNetwork[m_queueIdx].size() ) { - uint8_t retval = m_socket->m_queueNetwork[m_queueIdx].front(); + std::uint8_t retval = m_socket->m_queueNetwork[m_queueIdx].front(); m_socket->m_queueNetwork[m_queueIdx].pop(); LeaveCriticalSection(&m_socket->m_queueLockNetwork[m_queueIdx]); return retval; @@ -474,8 +474,8 @@ void Socket::SocketOutputStreamNetwork::write(unsigned int b) { if( m_streamOpen != true ) return; byteArray barray; - uint8_t bb; - bb = (uint8_t)b; + std::uint8_t bb; + bb = (std::uint8_t)b; barray.data = &bb; barray.length = 1; write(barray, 0, 1); @@ -564,4 +564,4 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(byteArray b, unsigned int void Socket::SocketOutputStreamNetwork::close() { m_streamOpen = false; -} \ No newline at end of file +} diff --git a/Minecraft.World/Network/Socket.h b/Minecraft.World/Network/Socket.h index 659967e1a..293f9dd4a 100644 --- a/Minecraft.World/Network/Socket.h +++ b/Minecraft.World/Network/Socket.h @@ -1,4 +1,6 @@ #pragma once +#include +#include #ifndef __linux__ #include #include @@ -95,12 +97,12 @@ private: // For local connections between the host player and the server static CRITICAL_SECTION s_hostQueueLock[2]; - static std::queue s_hostQueue[2]; + static std::queue s_hostQueue[2]; static SocketOutputStreamLocal *s_hostOutStream[2]; static SocketInputStreamLocal *s_hostInStream[2]; // For network connections - std::queue m_queueNetwork[2]; // For input data + std::queue m_queueNetwork[2]; // For input data CRITICAL_SECTION m_queueLockNetwork[2]; // For input data SocketInputStreamNetwork *m_inputStream[2]; SocketOutputStreamNetwork *m_outputStream[2]; @@ -109,7 +111,7 @@ private: // Host only connection class static ServerConnection *s_serverConnection; - BYTE networkPlayerSmallId; + std::uint8_t networkPlayerSmallId; public: C4JThread::Event* m_socketClosedEvent; @@ -122,7 +124,7 @@ public: Socket(bool response = false); // 4J - Create a local socket, for end 0 or 1 of a connection Socket(INetworkPlayer *player, bool response = false, bool hostLocal = false); // 4J - Create a socket for an INetworkPlayer SocketAddress *getRemoteSocketAddress(); - void pushDataToQueue(const BYTE * pbData, DWORD dwDataSize, bool fromHost = true); + void pushDataToQueue(const std::uint8_t *pbData, std::size_t dataSize, bool fromHost = true); static void addIncomingSocket(Socket *socket); InputStream *getInputStream(bool isServerConnection); void setSoTimeout(int a ); @@ -133,5 +135,5 @@ public: bool isLocal() { return m_hostLocal; } bool isClosing() { return m_endClosed[SOCKET_CLIENT_END] || m_endClosed[SOCKET_SERVER_END]; } - BYTE getSmallId() { return networkPlayerSmallId; } + std::uint8_t getSmallId() { return networkPlayerSmallId; } }; diff --git a/Minecraft.World/Platform/x64headers/extraX64.h b/Minecraft.World/Platform/x64headers/extraX64.h index 0dac12ca6..51a7b5275 100644 --- a/Minecraft.World/Platform/x64headers/extraX64.h +++ b/Minecraft.World/Platform/x64headers/extraX64.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "../../../Minecraft.Client/Rendering/Models/SkinBox.h" @@ -17,12 +19,15 @@ const int XUSER_INDEX_FOCUS = 254; #ifdef __PSVITA__ const int XUSER_MAX_COUNT = 1; -const int MINECRAFT_NET_MAX_PLAYERS = 4; +constexpr int MINECRAFT_NET_MAX_PLAYERS = 4; #else const int XUSER_MAX_COUNT = 4; -const int MINECRAFT_NET_MAX_PLAYERS = 8; +constexpr int MINECRAFT_NET_MAX_PLAYERS = 8; #endif +static_assert(MINECRAFT_NET_MAX_PLAYERS <= std::numeric_limits::max(), + "MINECRAFT_NET_MAX_PLAYERS must fit in the 8-bit network protocol"); + #ifdef __ORBIS__ #include #include diff --git a/Minecraft.World/Player/Player.cpp b/Minecraft.World/Player/Player.cpp index 0c8005ad4..82f706430 100644 --- a/Minecraft.World/Player/Player.cpp +++ b/Minecraft.World/Player/Player.cpp @@ -183,8 +183,8 @@ void Player::defineSynchedData() { this->Mob::defineSynchedData(); - entityData->define(DATA_PLAYER_FLAGS_ID, (uint8_t) 0); - entityData->define(DATA_PLAYER_RUNNING_ID, (uint8_t) 0); + entityData->define(DATA_PLAYER_FLAGS_ID, (std::uint8_t) 0); + entityData->define(DATA_PLAYER_RUNNING_ID, (std::uint8_t) 0); } std::shared_ptr Player::getUseItem() @@ -572,7 +572,7 @@ void Player::completeUsingItem() } } -void Player::handleEntityEvent(uint8_t id) +void Player::handleEntityEvent(std::uint8_t id) { if (id == EntityEvent::USE_ITEM_COMPLETE) { @@ -620,7 +620,7 @@ void Player::setPlayerDefaultSkin(EDefaultSkins skin) m_skinIndex = skin; } -void Player::setCustomSkin(DWORD skinId) +void Player::setCustomSkin(std::uint32_t skinId) { #ifndef _CONTENT_PACKAGE wprintf(L"Attempting to set skin to %08X for player %ls\n", skinId, name.c_str() ); @@ -634,8 +634,8 @@ void Player::setCustomSkin(DWORD skinId) if( !GET_IS_DLC_SKIN_FROM_BITMASK(skinId) ) { // GET_UGC_SKIN_ID_FROM_BITMASK will always be zero - this was for a possible custom skin editor skin - DWORD ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); - DWORD defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); + std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId); + std::uint32_t defaultSkinIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId); if( ugcSkinIndex == 0 && defaultSkinIndex > 0 ) { playerSkin = (EDefaultSkins) defaultSkinIndex; @@ -666,8 +666,8 @@ void Player::setCustomSkin(DWORD skinId) if(pDLCSkinFile!=NULL) { - DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount(); - if(dwBoxC!=0) + const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); + if(additionalBoxCount != 0) { app.DebugPrintf("Got model parts from DLCskin for skin %X\n",m_dwSkinId); pvModelParts=app.SetAdditionalSkinBoxes(m_dwSkinId,pDLCSkinFile->getAdditionalBoxes()); @@ -699,7 +699,7 @@ void Player::setCustomSkin(DWORD skinId) } -unsigned int Player::getSkinAnimOverrideBitmask(DWORD skinId) +unsigned int Player::getSkinAnimOverrideBitmask(std::uint32_t skinId) { unsigned long bitmask = 0L; if( GET_IS_DLC_SKIN_FROM_BITMASK(skinId) ) @@ -751,7 +751,7 @@ void Player::setXuid(PlayerUID xuid) #endif } -void Player::setCustomCape(DWORD capeId) +void Player::setCustomCape(std::uint32_t capeId) { #ifndef _CONTENT_PACKAGE wprintf(L"Attempting to set cape to %08X for player %s\n", capeId, name.c_str() ); @@ -801,10 +801,10 @@ void Player::setCustomCape(DWORD capeId) } } -DWORD Player::getCapeIdFromPath(const std::wstring &cape) +std::uint32_t Player::getCapeIdFromPath(const std::wstring &cape) { bool dlcCape = false; - unsigned int capeId = 0; + std::uint32_t capeId = 0; if(cape.size() >= 14) { @@ -827,7 +827,7 @@ DWORD Player::getCapeIdFromPath(const std::wstring &cape) return capeId; } -std::wstring Player::getCapePathFromId(DWORD capeId) +std::wstring Player::getCapePathFromId(std::uint32_t capeId) { // 4J Stu - This function maps the encoded DWORD we store in the player profile // to a filename that is stored as a memory texture and shared between systems in game @@ -840,8 +840,8 @@ std::wstring Player::getCapePathFromId(DWORD capeId) } else { - DWORD ugcCapeIndex = GET_UGC_SKIN_ID_FROM_BITMASK(capeId); - DWORD defaultCapeIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(capeId); + std::uint32_t ugcCapeIndex = GET_UGC_SKIN_ID_FROM_BITMASK(capeId); + std::uint32_t defaultCapeIndex = GET_DEFAULT_SKIN_ID_FROM_BITMASK(capeId); if( ugcCapeIndex == 0 ) { swprintf(chars,256,L"defcape%08X.png",defaultCapeIndex); @@ -1979,14 +1979,14 @@ bool Player::getPlayerFlag(int flag) void Player::setPlayerFlag(int flag, bool value) { - uint8_t currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID); + std::uint8_t currentValue = entityData->getByte(DATA_PLAYER_FLAGS_ID); if (value) { - entityData->set(DATA_PLAYER_FLAGS_ID, (uint8_t) (currentValue | (1 << flag))); + entityData->set(DATA_PLAYER_FLAGS_ID, (std::uint8_t) (currentValue | (1 << flag))); } else { - entityData->set(DATA_PLAYER_FLAGS_ID, (uint8_t) (currentValue & ~(1 << flag))); + entityData->set(DATA_PLAYER_FLAGS_ID, (std::uint8_t) (currentValue & ~(1 << flag))); } } @@ -2958,8 +2958,8 @@ std::vector *Player::GetAdditionalModelParts() if(pDLCSkinFile!=NULL) { - DWORD dwBoxC=pDLCSkinFile->getAdditionalBoxesCount(); - if(dwBoxC!=0) + const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); + if(additionalBoxCount != 0) { app.DebugPrintf("m_bCheckedForModelParts Got model parts from DLCskin for skin %X\n",m_dwSkinId); m_ppAdditionalModelParts=app.SetAdditionalSkinBoxes(m_dwSkinId,pDLCSkinFile->getAdditionalBoxes()); diff --git a/Minecraft.World/Player/Player.h b/Minecraft.World/Player/Player.h index 55159386c..62f0a018d 100644 --- a/Minecraft.World/Player/Player.h +++ b/Minecraft.World/Player/Player.h @@ -1,5 +1,6 @@ #pragma once +#include #include "../Entities/Mob.h" #include "../Util/Definitions.h" @@ -64,7 +65,7 @@ protected: int jumpTriggerTime; public: - BYTE userType; + std::uint8_t userType; int score; float oBob, bob; bool swinging; @@ -160,7 +161,7 @@ protected: virtual void completeUsingItem(); public: - virtual void handleEntityEvent(uint8_t id); + virtual void handleEntityEvent(std::uint8_t id); protected: bool isImmobile(); @@ -396,14 +397,14 @@ public: virtual int getTexture(); // 4J changed from std::wstring to int void setPlayerDefaultSkin(EDefaultSkins skin); EDefaultSkins getPlayerDefaultSkin() { return m_skinIndex; } - virtual void setCustomSkin(DWORD skinId); - DWORD getCustomSkin() {return m_dwSkinId; } - virtual void setCustomCape(DWORD capeId); - DWORD getCustomCape() {return m_dwCapeId; } + virtual void setCustomSkin(std::uint32_t skinId); + std::uint32_t getCustomSkin() {return m_dwSkinId; } + virtual void setCustomCape(std::uint32_t capeId); + std::uint32_t getCustomCape() {return m_dwCapeId; } - static DWORD getCapeIdFromPath(const std::wstring &cape); - static std::wstring getCapePathFromId(DWORD capeId); - static unsigned int getSkinAnimOverrideBitmask(DWORD skinId); + static std::uint32_t getCapeIdFromPath(const std::wstring &cape); + static std::wstring getCapePathFromId(std::uint32_t capeId); + static unsigned int getSkinAnimOverrideBitmask(std::uint32_t skinId); // 4J Added void setXuid(PlayerUID xuid); @@ -413,8 +414,8 @@ public: void setUUID(const std::wstring &UUID) { m_UUID = UUID; } std::wstring getUUID() { return m_UUID; } - void setPlayerIndex(DWORD dwIndex) { m_playerIndex = dwIndex; } - DWORD getPlayerIndex() { return m_playerIndex; } + void setPlayerIndex(std::uint8_t index) { m_playerIndex = index; } + std::uint8_t getPlayerIndex() { return m_playerIndex; } void setIsGuest(bool bVal) { m_bIsGuest = bVal; } bool isGuest() { return m_bIsGuest; } @@ -436,10 +437,10 @@ protected: private: EDefaultSkins m_skinIndex; - DWORD m_dwSkinId,m_dwCapeId; + std::uint32_t m_dwSkinId,m_dwCapeId; // 4J Added - Used to show which colour the player is on the map/behind their name - DWORD m_playerIndex; + std::uint8_t m_playerIndex; // 4J-PB - to track debug options from the server player unsigned int m_uiDebugOptions; diff --git a/Minecraft.World/Util/AABB.cpp b/Minecraft.World/Util/AABB.cpp index 3dc459497..2d40fcaee 100644 --- a/Minecraft.World/Util/AABB.cpp +++ b/Minecraft.World/Util/AABB.cpp @@ -7,7 +7,7 @@ #include "AABB.h" #include "HitResult.h" -DWORD AABB::tlsIdx = 0; +unsigned int AABB::tlsIdx = 0; AABB::ThreadStorage *AABB::tlsDefault = NULL; AABB::ThreadStorage::ThreadStorage() diff --git a/Minecraft.World/Util/AABB.h b/Minecraft.World/Util/AABB.h index 5341e6eba..28f55d1f8 100644 --- a/Minecraft.World/Util/AABB.h +++ b/Minecraft.World/Util/AABB.h @@ -18,7 +18,7 @@ class AABB ThreadStorage(); ~ThreadStorage(); }; - static DWORD tlsIdx; + static unsigned int tlsIdx; static ThreadStorage *tlsDefault; public: // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own diff --git a/Minecraft.World/Util/IntCache.cpp b/Minecraft.World/Util/IntCache.cpp index 39755e63f..241c541f9 100644 --- a/Minecraft.World/Util/IntCache.cpp +++ b/Minecraft.World/Util/IntCache.cpp @@ -1,7 +1,7 @@ #include "../Platform/stdafx.h" #include "IntCache.h" -DWORD IntCache::tlsIdx = TlsAlloc(); +unsigned int IntCache::tlsIdx = TlsAlloc(); void IntCache::CreateNewThreadStorage() { @@ -161,4 +161,4 @@ void IntCache::Reset() delete [] tls->toosmall[i].data; } tls->toosmall.clear(); -} \ No newline at end of file +} diff --git a/Minecraft.World/Util/IntCache.h b/Minecraft.World/Util/IntCache.h index 6097d6844..c83b1eba8 100644 --- a/Minecraft.World/Util/IntCache.h +++ b/Minecraft.World/Util/IntCache.h @@ -20,7 +20,7 @@ private: std::vector toosmall; // 4J added ~ThreadStorage(); }; - static DWORD tlsIdx; + static unsigned int tlsIdx; static const int TINY_CUTOFF = 256; @@ -31,4 +31,4 @@ public: static void CreateNewThreadStorage(); static void ReleaseThreadStorage(); static void Reset(); // 4J added -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Util/PerformanceTimer.cpp b/Minecraft.World/Util/PerformanceTimer.cpp index 96ce372ef..42b00a2a7 100644 --- a/Minecraft.World/Util/PerformanceTimer.cpp +++ b/Minecraft.World/Util/PerformanceTimer.cpp @@ -3,33 +3,17 @@ PerformanceTimer::PerformanceTimer() { -#if !defined (__linux__) - // Get the frequency of the timer - LARGE_INTEGER qwTicksPerSec; - QueryPerformanceFrequency( &qwTicksPerSec ); - m_fSecsPerTick = 1.0f / (float)qwTicksPerSec.QuadPart; - Reset(); -#endif } void PerformanceTimer::Reset() { -#if !defined (__linux__) - QueryPerformanceCounter( &m_qwStartTime ); -#endif + m_startTime = std::chrono::steady_clock::now(); } void PerformanceTimer::PrintElapsedTime(const std::wstring &description) { -#if !defined (__linux__) - LARGE_INTEGER qwNewTime, qwDeltaTime; + const std::chrono::duration elapsedTime = std::chrono::steady_clock::now() - m_startTime; - QueryPerformanceCounter( &qwNewTime ); - - qwDeltaTime.QuadPart = qwNewTime.QuadPart - m_qwStartTime.QuadPart; - float fElapsedTime = m_fSecsPerTick * ((FLOAT)(qwDeltaTime.QuadPart)); - - app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), fElapsedTime); -#endif + app.DebugPrintf("TIMER: %ls: Elapsed time %f\n", description.c_str(), elapsedTime.count()); } diff --git a/Minecraft.World/Util/PerformanceTimer.h b/Minecraft.World/Util/PerformanceTimer.h index 5ceaa2480..7fca90507 100644 --- a/Minecraft.World/Util/PerformanceTimer.h +++ b/Minecraft.World/Util/PerformanceTimer.h @@ -1,13 +1,24 @@ #pragma once +#ifdef __valid +#pragma push_macro("__valid") +#undef __valid +#define PERFORMANCE_TIMER_RESTORE_VALID_MACRO +#endif +#include +#ifdef PERFORMANCE_TIMER_RESTORE_VALID_MACRO +#pragma pop_macro("__valid") +#undef PERFORMANCE_TIMER_RESTORE_VALID_MACRO +#endif +#include + class PerformanceTimer { private: - LARGE_INTEGER m_qwStartTime; - float m_fSecsPerTick; + std::chrono::steady_clock::time_point m_startTime; public: PerformanceTimer(); void Reset(); void PrintElapsedTime(const std::wstring &description); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/Util/PortableFileIO.h b/Minecraft.World/Util/PortableFileIO.h new file mode 100644 index 000000000..aed99aa31 --- /dev/null +++ b/Minecraft.World/Util/PortableFileIO.h @@ -0,0 +1,162 @@ +#pragma once + +#include +#include +#include + +#include "StringHelpers.h" + +namespace PortableFileIO +{ + enum class BinaryReadStatus + { + ok, + not_found, + too_large, + read_error, + }; + + struct BinaryReadResult + { + BinaryReadStatus status; + std::size_t bytesRead; + std::size_t fileSize; + }; + + inline std::FILE *OpenBinaryFileForRead(const std::wstring &path) + { +#if defined(_WIN32) + return _wfopen(path.c_str(), L"rb"); +#else + const std::string nativePath = wstringtofilename(path); + return std::fopen(nativePath.c_str(), "rb"); +#endif + } + + inline bool Seek(std::FILE *file, std::size_t offset, int origin) + { +#if defined(_WIN32) + return _fseeki64(file, static_cast<__int64>(offset), origin) == 0; +#else + return fseeko(file, static_cast(offset), origin) == 0; +#endif + } + + inline __int64 Tell(std::FILE *file) + { +#if defined(_WIN32) + return _ftelli64(file); +#else + return static_cast<__int64>(ftello(file)); +#endif + } + + inline BinaryReadResult ReadBinaryFile(const std::wstring &path, void *buffer, std::size_t capacity) + { + std::FILE *stream = OpenBinaryFileForRead(path); + if (stream == NULL) + { + return { BinaryReadStatus::not_found, 0, 0 }; + } + + if (!Seek(stream, 0, SEEK_END)) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, 0 }; + } + + const __int64 endPosition = Tell(stream); + if (endPosition < 0) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, 0 }; + } + + const std::size_t fileSize = static_cast(endPosition); + if (fileSize > capacity) + { + std::fclose(stream); + return { BinaryReadStatus::too_large, 0, fileSize }; + } + + if (!Seek(stream, 0, SEEK_SET)) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, fileSize }; + } + + const std::size_t bytesRead = std::fread(buffer, 1, fileSize, stream); + const bool failed = std::ferror(stream) != 0; + std::fclose(stream); + if (failed || bytesRead != fileSize) + { + return { BinaryReadStatus::read_error, bytesRead, fileSize }; + } + + return { BinaryReadStatus::ok, bytesRead, fileSize }; + } + + inline BinaryReadResult ReadBinaryFileSegment(const std::wstring &path, std::size_t offset, void *buffer, std::size_t bytesToRead) + { + std::FILE *stream = OpenBinaryFileForRead(path); + if (stream == NULL) + { + return { BinaryReadStatus::not_found, 0, 0 }; + } + + if (!Seek(stream, 0, SEEK_END)) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, 0 }; + } + + const __int64 endPosition = Tell(stream); + if (endPosition < 0) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, 0 }; + } + + const std::size_t fileSize = static_cast(endPosition); + if ((offset > fileSize) || (bytesToRead > (fileSize - offset))) + { + std::fclose(stream); + return { BinaryReadStatus::too_large, 0, fileSize }; + } + + if (!Seek(stream, offset, SEEK_SET)) + { + std::fclose(stream); + return { BinaryReadStatus::read_error, 0, fileSize }; + } + + const std::size_t bytesRead = std::fread(buffer, 1, bytesToRead, stream); + const bool failed = std::ferror(stream) != 0; + std::fclose(stream); + if (failed || bytesRead != bytesToRead) + { + return { BinaryReadStatus::read_error, bytesRead, fileSize }; + } + + return { BinaryReadStatus::ok, bytesRead, fileSize }; + } + + inline bool WriteBinaryFile(const std::wstring &path, const void *buffer, std::size_t bytesToWrite) + { +#if defined(_WIN32) + std::FILE *stream = _wfopen(path.c_str(), L"wb"); +#else + const std::string nativePath = wstringtofilename(path); + std::FILE *stream = std::fopen(nativePath.c_str(), "wb"); +#endif + if (stream == NULL) + { + return false; + } + + const std::size_t bytesWritten = std::fwrite(buffer, 1, bytesToWrite, stream); + const bool failed = std::ferror(stream) != 0 || bytesWritten != bytesToWrite; + const bool closeFailed = std::fclose(stream) != 0; + return !failed && !closeFailed; + } +} diff --git a/Minecraft.World/Util/Vec3.cpp b/Minecraft.World/Util/Vec3.cpp index 8c4671960..24132d839 100644 --- a/Minecraft.World/Util/Vec3.cpp +++ b/Minecraft.World/Util/Vec3.cpp @@ -2,7 +2,7 @@ #include "Vec3.h" #include "AABB.h" -DWORD Vec3::tlsIdx = 0; +unsigned int Vec3::tlsIdx = 0; Vec3::ThreadStorage *Vec3::tlsDefault = NULL; Vec3::ThreadStorage::ThreadStorage() @@ -262,4 +262,4 @@ double Vec3::distanceTo(AABB *box) else if( z > box->z1) zd = z - box->z1; return sqrt(xd * xd + yd * yd + zd * zd); -} \ No newline at end of file +} diff --git a/Minecraft.World/Util/Vec3.h b/Minecraft.World/Util/Vec3.h index 0d1fd247d..826bf9a0a 100644 --- a/Minecraft.World/Util/Vec3.h +++ b/Minecraft.World/Util/Vec3.h @@ -15,7 +15,7 @@ class Vec3 ThreadStorage(); ~ThreadStorage(); }; - static DWORD tlsIdx; + static unsigned int tlsIdx; static ThreadStorage *tlsDefault; public: // Each new thread that needs to use Vec3 pools will need to call one of the following 2 functions, to either create its own @@ -56,4 +56,4 @@ public: // 4J Added double distanceTo(AABB *box); -}; \ No newline at end of file +}; diff --git a/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp b/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp index 09947db05..198d44406 100644 --- a/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp +++ b/Minecraft.World/WorldGen/Biomes/DesertBiome.cpp @@ -10,8 +10,8 @@ DesertBiome::DesertBiome(int id) : Biome(id) friendlies.clear(); friendlies_chicken.clear(); // 4J added friendlies_wolf.clear(); // 4J added - this->topMaterial = (BYTE) Tile::sand_Id; - this->material = (BYTE) Tile::sand_Id; + this->topMaterial = static_cast(Tile::sand_Id); + this->material = static_cast(Tile::sand_Id); decorator->treeCount = -999; decorator->deadBushCount = 2; @@ -30,4 +30,4 @@ void DesertBiome::decorate(Level *level, Random *random, int xo, int zo) Feature *well = new DesertWellFeature(); well->place(level, random, x, level->getHeightmap(x, z) + 1, z); } -} \ No newline at end of file +} diff --git a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp index eefe26b4d..9f6c90585 100644 --- a/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp +++ b/Minecraft.World/WorldGen/Layers/BiomeOverrideLayer.cpp @@ -1,4 +1,5 @@ #include "../../Platform/stdafx.h" +#include "../../Util/PortableFileIO.h" #include "../../Headers/net.minecraft.world.level.biome.h" #include "../../Headers/net.minecraft.world.level.newbiome.layer.h" #include "../../Headers/net.minecraft.world.level.h" @@ -9,47 +10,25 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { m_biomeOverride = byteArray( width * height ); -#ifdef _UNICODE - std::wstring path = L"GAME:\\GameRules\\biomemap.bin"; - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#else #ifdef _WINDOWS64 - std::string path = "GameRules\\biomemap.bin"; + const std::wstring path = L"GameRules\\biomemap.bin"; #else - std::string path = "GAME:\\GameRules\\biomemap.bin"; + const std::wstring path = L"GAME:\\GameRules\\biomemap.bin"; #endif - HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#endif - if( file == INVALID_HANDLE_VALUE ) + const PortableFileIO::BinaryReadResult readResult = PortableFileIO::ReadBinaryFile(path, m_biomeOverride.data, m_biomeOverride.length); + if(readResult.status == PortableFileIO::BinaryReadStatus::not_found) { - // DWORD error = GetLastError(); - //assert(false); app.DebugPrintf("Biome override not found, using plains as default\n"); - memset(m_biomeOverride.data,Biome::plains->id,m_biomeOverride.length); } - else + else if(readResult.status == PortableFileIO::BinaryReadStatus::too_large) { - -#ifdef _DURANGO - __debugbreak(); // TODO - DWORD bytesRead,dwFileSize = 0; -#else - DWORD bytesRead,dwFileSize = GetFileSize(file,NULL); -#endif - if(dwFileSize > m_biomeOverride.length) - { - app.DebugPrintf("Biomemap binary is too large!!\n"); - __debugbreak(); - } - BOOL bSuccess = ReadFile(file,m_biomeOverride.data,dwFileSize,&bytesRead,NULL); - - if(bSuccess==FALSE) - { - app.FatalLoadError(); - } - - CloseHandle(file); + app.DebugPrintf("Biomemap binary is too large!!\n"); + __debugbreak(); + } + else if(readResult.status != PortableFileIO::BinaryReadStatus::ok) + { + app.FatalLoadError(); } }