Merge pull request #363 from 4jcraft/chore/fmt2
Some checks are pending
Publish Documentation / build (push) Waiting to run
Build (Linux, x86-64) / build-linux (push) Waiting to run
Format Check / clang-format (push) Waiting to run

chore: format everything
This commit is contained in:
Tropical 2026-03-30 02:33:42 -05:00 committed by GitHub
commit 8a83ea0879
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
463 changed files with 12634 additions and 11237 deletions

View file

@ -87,8 +87,7 @@ using PXMARKETPLACE_CONTENTOFFER_INFO = XMARKETPLACE_CONTENTOFFER_INFO*;
#endif #endif
#ifndef XMARKETPLACE_OFFERING_TYPE_CONTENT #ifndef XMARKETPLACE_OFFERING_TYPE_CONTENT
inline constexpr std::uint32_t XMARKETPLACE_OFFERING_TYPE_CONTENT = inline constexpr std::uint32_t XMARKETPLACE_OFFERING_TYPE_CONTENT = 0x00000002;
0x00000002;
#endif #endif
#ifndef XMARKETPLACE_OFFERING_TYPE_GAME_DEMO #ifndef XMARKETPLACE_OFFERING_TYPE_GAME_DEMO

View file

@ -264,7 +264,6 @@ static void utf8_pop_back(std::string& str) {
str.erase(i); str.erase(i);
} }
// Each tick we update the input state by polling SDL, this is where we get the // Each tick we update the input state by polling SDL, this is where we get the
// kbd and mouse state. // kbd and mouse state.
void C_4JInput::Tick() { void C_4JInput::Tick() {
@ -650,9 +649,7 @@ bool C_4JInput::GetMenuDisplayed(int iPad) {
if (iPad >= 0 && iPad < 4) return s_menuDisplayed[iPad]; if (iPad >= 0 && iPad < 4) return s_menuDisplayed[iPad];
return false; return false;
} }
const char* C_4JInput::GetText() { const char* C_4JInput::GetText() { return s_textInputBuf.c_str(); }
return s_textInputBuf.c_str();
}
bool C_4JInput::VerifyStrings(wchar_t**, int, bool C_4JInput::VerifyStrings(wchar_t**, int,
int (*)(void*, STRING_VERIFY_RESPONSE*), void*) { int (*)(void*, STRING_VERIFY_RESPONSE*), void*) {
return true; return true;

View file

@ -102,8 +102,7 @@ void initialiseDefaultGameSettings(ProfileGameSettings* gameSettings) {
} }
} // namespace } // namespace
void C_4JProfile::Initialise(std::uint32_t dwTitleID, void C_4JProfile::Initialise(std::uint32_t dwTitleID, std::uint32_t dwOfferID,
std::uint32_t dwOfferID,
unsigned short usProfileVersion, unsigned short usProfileVersion,
unsigned int uiProfileValuesC, unsigned int uiProfileValuesC,
unsigned int uiProfileSettingsC, unsigned int uiProfileSettingsC,
@ -139,9 +138,9 @@ unsigned int C_4JProfile::RequestSignInUI(
int iQuadrant) { int iQuadrant) {
return 0; return 0;
} }
unsigned int C_4JProfile::DisplayOfflineProfile( unsigned int C_4JProfile::DisplayOfflineProfile(int (*Func)(void*, const bool,
int (*Func)(void*, const bool, const int iPad), void* lpParam, const int iPad),
int iQuadrant) { void* lpParam, int iQuadrant) {
return 0; return 0;
} }
unsigned int C_4JProfile::RequestConvertOfflineToGuestUI( unsigned int C_4JProfile::RequestConvertOfflineToGuestUI(
@ -152,7 +151,9 @@ unsigned int C_4JProfile::RequestConvertOfflineToGuestUI(
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {} void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
bool C_4JProfile::QuerySigninStatus(void) { return true; } bool C_4JProfile::QuerySigninStatus(void) { return true; }
void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) { void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) {
if (pXuid) *pXuid = kFakeXuidBase + static_cast<PlayerUID>(isValidPad(iPad) ? iPad : 0); if (pXuid)
*pXuid =
kFakeXuidBase + static_cast<PlayerUID>(isValidPad(iPad) ? iPad : 0);
} }
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) { bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) {
return xuid1 == xuid2; return xuid1 == xuid2;
@ -267,4 +268,6 @@ void C_4JProfile::SetUpsellCallback(void (*Func)(void* lpParam,
eUpsellResponse response, eUpsellResponse response,
int iUserData), int iUserData),
void* lpParam) {} void* lpParam) {}
void C_4JProfile::SetDebugFullOverride(bool bVal) { s_profileIsFullVersion = bVal; } void C_4JProfile::SetDebugFullOverride(bool bVal) {
s_profileIsFullVersion = bVal;
}

View file

@ -56,14 +56,15 @@ public:
bool IsSignedInLive(int iProf); bool IsSignedInLive(int iProf);
bool IsGuest(int iQuadrant); bool IsGuest(int iQuadrant);
unsigned int RequestSignInUI(bool bFromInvite, bool bLocalGame, unsigned int RequestSignInUI(bool bFromInvite, bool bLocalGame,
bool bNoGuestsAllowed, bool bNoGuestsAllowed, bool bMultiplayerSignIn,
bool bMultiplayerSignIn, bool bAddUser, bool bAddUser,
int (*Func)(void*, const bool, const int iPad), int (*Func)(void*, const bool, const int iPad),
void* lpParam, void* lpParam,
int iQuadrant = XUSER_INDEX_ANY); int iQuadrant = XUSER_INDEX_ANY);
unsigned int DisplayOfflineProfile( unsigned int DisplayOfflineProfile(int (*Func)(void*, const bool,
int (*Func)(void*, const bool, const int iPad), void* lpParam, const int iPad),
int iQuadrant = XUSER_INDEX_ANY); void* lpParam,
int iQuadrant = XUSER_INDEX_ANY);
unsigned int RequestConvertOfflineToGuestUI( unsigned int RequestConvertOfflineToGuestUI(
int (*Func)(void*, const bool, const int iPad), void* lpParam, int (*Func)(void*, const bool, const int iPad), void* lpParam,
int iQuadrant = XUSER_INDEX_ANY); int iQuadrant = XUSER_INDEX_ANY);
@ -80,8 +81,7 @@ public:
void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
bool* allAllowed, bool* friendsAllowed); bool* allAllowed, bool* friendsAllowed);
bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
PlayerUID* pXuids, PlayerUID* pXuids, unsigned int xuidCount);
unsigned int xuidCount);
void ShowProfileCard(int iPad, PlayerUID targetUid); void ShowProfileCard(int iPad, PlayerUID targetUid);
bool GetProfileAvatar(int iPad, bool GetProfileAvatar(int iPad,
int (*Func)(void* lpParam, int (*Func)(void* lpParam,
@ -129,9 +129,8 @@ public:
void RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, void RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType,
bool bLeaderboardAffected = false, bool bLeaderboardAffected = false,
CXuiStringTable* pStringTable = nullptr, CXuiStringTable* pStringTable = nullptr,
int iTitleStr = -1, int iTitleStr = -1, int iTextStr = -1,
int iTextStr = -1, int iAcceptStr = -1, int iAcceptStr = -1, char* pszThemeName = nullptr,
char* pszThemeName = nullptr,
unsigned int uiThemeSize = 0L); unsigned int uiThemeSize = 0L);
int GetAwardId(int iAwardNumber); int GetAwardId(int iAwardNumber);
eAwardType GetAwardType(int iAwardNumber); eAwardType GetAwardType(int iAwardNumber);

View file

@ -1,28 +1,28 @@
#pragma once #pragma once
#ifndef GL_GLEXT_PROTOTYPES #ifndef GL_GLEXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES 1 #define GL_GLEXT_PROTOTYPES 1
#endif #endif
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glext.h> #include <GL/glext.h>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <cstdio> #include <cstdio>
#ifndef GL_ARRAY_BUFFER #ifndef GL_ARRAY_BUFFER
# define GL_ARRAY_BUFFER 0x8892 #define GL_ARRAY_BUFFER 0x8892
#endif #endif
#ifndef GL_ELEMENT_ARRAY_BUFFER #ifndef GL_ELEMENT_ARRAY_BUFFER
# define GL_ELEMENT_ARRAY_BUFFER 0x8893 #define GL_ELEMENT_ARRAY_BUFFER 0x8893
#endif #endif
#ifndef GL_STATIC_DRAW #ifndef GL_STATIC_DRAW
# define GL_STATIC_DRAW 0x88B4 #define GL_STATIC_DRAW 0x88B4
#endif #endif
#ifndef GL_VERTEX_SHADER #ifndef GL_VERTEX_SHADER
# define GL_VERTEX_SHADER 0x8B31 #define GL_VERTEX_SHADER 0x8B31
#endif #endif
#ifndef GL_FRAGMENT_SHADER #ifndef GL_FRAGMENT_SHADER
# define GL_FRAGMENT_SHADER 0x8B30 #define GL_FRAGMENT_SHADER 0x8B30
#endif #endif
#ifndef GL_QUADS #ifndef GL_QUADS
# define GL_QUADS 0x0007 #define GL_QUADS 0x0007
#endif #endif
static inline bool gl3_load() { static inline bool gl3_load() {
const char* ver = (const char*)glGetString(GL_VERSION); const char* ver = (const char*)glGetString(GL_VERSION);
@ -33,10 +33,15 @@ static inline bool gl3_load() {
int major = 0, minor = 0; int major = 0, minor = 0;
if (sscanf(ver, "%d.%d", &major, &minor) >= 2) { if (sscanf(ver, "%d.%d", &major, &minor) >= 2) {
if (major < 3 || (major == 3 && minor < 3)) { if (major < 3 || (major == 3 && minor < 3)) {
fprintf(stderr, "[gl3_loader] ERROR: Need GL 3.3, but system provides %s\n", ver); fprintf(stderr,
"[gl3_loader] ERROR: Need GL 3.3, but system provides %s\n",
ver);
return false; return false;
} }
} }
fprintf(stderr, "[gl3_loader] GL Version: %s, it's all okay!! until android support.\n", ver); fprintf(
stderr,
"[gl3_loader] GL Version: %s, it's all okay!! until android support.\n",
ver);
return true; return true;
} }

View file

@ -31,8 +31,8 @@ bool C4JStorage::SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
} }
void C4JStorage::Init(unsigned int uiSaveVersion, void C4JStorage::Init(unsigned int uiSaveVersion,
const wchar_t* pwchDefaultSaveName, const wchar_t* pwchDefaultSaveName, char* pszSavePackName,
char* pszSavePackName, int iMinimumSaveSize, int iMinimumSaveSize,
int (*Func)(void*, const ESavingMessage, int), int (*Func)(void*, const ESavingMessage, int),
void* lpParam, const char* szGroupID) {} void* lpParam, const char* szGroupID) {}
void C4JStorage::ResetSaveData() {} void C4JStorage::ResetSaveData() {}
@ -61,8 +61,7 @@ void* C4JStorage::AllocateSaveData(unsigned int uiBytes) {
} }
void C4JStorage::SetSaveImages(std::uint8_t* pbThumbnail, void C4JStorage::SetSaveImages(std::uint8_t* pbThumbnail,
unsigned int thumbnailBytes, unsigned int thumbnailBytes,
std::uint8_t* pbImage, std::uint8_t* pbImage, unsigned int imageBytes,
unsigned int imageBytes,
std::uint8_t* pbTextData, std::uint8_t* pbTextData,
unsigned int textDataBytes) {} unsigned int textDataBytes) {}
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(void*, C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(void*,
@ -130,7 +129,9 @@ C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(
} }
unsigned int C4JStorage::CancelGetDLCOffers() { return 0; } unsigned int C4JStorage::CancelGetDLCOffers() { return 0; }
void C4JStorage::ClearDLCOffers() {} void C4JStorage::ClearDLCOffers() {}
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(unsigned int dw) { return s_dummyOffer; } XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(unsigned int dw) {
return s_dummyOffer;
}
int C4JStorage::GetOfferCount() { return 0; } int C4JStorage::GetOfferCount() { return 0; }
unsigned int C4JStorage::InstallOffer(int iOfferIDC, std::uint64_t* ullOfferIDA, unsigned int C4JStorage::InstallOffer(int iOfferIDC, std::uint64_t* ullOfferIDA,
int (*Func)(void*, int, int), int (*Func)(void*, int, int),
@ -146,7 +147,9 @@ C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,
} }
return EDLC_NoInstalledDLC; return EDLC_NoInstalledDLC;
} }
XCONTENT_DATA& C4JStorage::GetDLC(unsigned int dw) { return s_dummyContentData; } XCONTENT_DATA& C4JStorage::GetDLC(unsigned int dw) {
return s_dummyContentData;
}
std::uint32_t C4JStorage::MountInstalledDLC( std::uint32_t C4JStorage::MountInstalledDLC(
int iPad, std::uint32_t dwDLC, int iPad, std::uint32_t dwDLC,
int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam, int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam,
@ -165,8 +168,7 @@ C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(
int iQuadrant, eGlobalStorage eStorageFacility, int iQuadrant, eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FileType eFileType, wchar_t* pwchFilename, C4JStorage::eTMS_FileType eFileType, wchar_t* pwchFilename,
std::uint8_t** ppBuffer, unsigned int* pBufferSize, std::uint8_t** ppBuffer, unsigned int* pBufferSize,
int (*Func)(void*, wchar_t*, int, bool, int), void* lpParam, int (*Func)(void*, wchar_t*, int, bool, int), void* lpParam, int iAction) {
int iAction) {
return ETMSStatus_Fail; return ETMSStatus_Fail;
} }
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,

View file

@ -42,18 +42,18 @@ typedef std::vector<PXCONTENT_DATA> XContentDataArray;
class C4JStorage { class C4JStorage {
public: public:
// Structs defined in the DLC_Creator, but added here to be used in the app // Structs defined in the DLC_Creator, but added here to be used in the app
typedef struct { typedef struct {
unsigned int uiFileSize; unsigned int uiFileSize;
std::uint32_t dwType; std::uint32_t dwType;
std::uint32_t dwWchCount; // count of wchar_t in next array std::uint32_t dwWchCount; // count of wchar_t in next array
wchar_t wchFile[1]; wchar_t wchFile[1];
} DLC_FILE_DETAILS, *PDLC_FILE_DETAILS; } DLC_FILE_DETAILS, *PDLC_FILE_DETAILS;
typedef struct { typedef struct {
std::uint32_t dwType; std::uint32_t dwType;
std::uint32_t dwWchCount; // count of wchar_t in next array; std::uint32_t dwWchCount; // count of wchar_t in next array;
wchar_t wchData[1]; // will be an array of size dwBytes wchar_t wchData[1]; // will be an array of size dwBytes
} DLC_FILE_PARAM, *PDLC_FILE_PARAM; } DLC_FILE_PARAM, *PDLC_FILE_PARAM;
// End of DLC_Creator structs // End of DLC_Creator structs
typedef struct { typedef struct {
@ -240,8 +240,8 @@ typedef struct {
std::uint8_t* pbImage, unsigned int imageBytes, std::uint8_t* pbImage, unsigned int imageBytes,
std::uint8_t* pbTextData, std::uint8_t* pbTextData,
unsigned int textDataBytes); // Sets the thumbnail & image for the unsigned int textDataBytes); // Sets the thumbnail & image for the
// save, optionally setting the // save, optionally setting the
// metadata in the png // metadata in the png
C4JStorage::ESaveGameState SaveSaveData(int (*Func)(void*, const bool), C4JStorage::ESaveGameState SaveSaveData(int (*Func)(void*, const bool),
void* lpParam); void* lpParam);
void CopySaveDataToNewSave(std::uint8_t* pbThumbnail, void CopySaveDataToNewSave(std::uint8_t* pbThumbnail,
@ -269,7 +269,8 @@ typedef struct {
void* lpParam); // Get the thumbnail for an individual save referenced void* lpParam); // Get the thumbnail for an individual save referenced
// by pSaveInfo // by pSaveInfo
void GetSaveCacheFileInfo(unsigned int fileIndex, XCONTENT_DATA& xContentData); void GetSaveCacheFileInfo(unsigned int fileIndex,
XCONTENT_DATA& xContentData);
void GetSaveCacheFileInfo(unsigned int fileIndex, void GetSaveCacheFileInfo(unsigned int fileIndex,
std::uint8_t** ppbImageData, std::uint8_t** ppbImageData,
unsigned int* pImageBytes); unsigned int* pImageBytes);
@ -291,8 +292,7 @@ typedef struct {
void SetDLCPackageRoot(char* pszDLCRoot); void SetDLCPackageRoot(char* pszDLCRoot);
C4JStorage::EDLCStatus GetDLCOffers( C4JStorage::EDLCStatus GetDLCOffers(
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam, int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
std::uint32_t dwOfferTypesBitmask = std::uint32_t dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT);
XMARKETPLACE_OFFERING_TYPE_CONTENT);
unsigned int CancelGetDLCOffers(); unsigned int CancelGetDLCOffers();
void ClearDLCOffers(); void ClearDLCOffers();
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(unsigned int dw); XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(unsigned int dw);
@ -334,9 +334,8 @@ typedef struct {
#ifdef _XBOX #ifdef _XBOX
C4JStorage::ETMSStatus WriteTMSFile( C4JStorage::ETMSStatus WriteTMSFile(
int iPad, C4JStorage::eGlobalStorage eStorageFacility, int iPad, C4JStorage::eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FileType eFileType, char* pchFilePath, C4JStorage::eTMS_FileType eFileType, char* pchFilePath, char* pchBuffer,
char* pchBuffer, unsigned int bufferSize, TMSCLIENT_CALLBACK Func, unsigned int bufferSize, TMSCLIENT_CALLBACK Func, void* lpParam);
void* lpParam);
int GetUserQuotaInfo(int iPad, TMSCLIENT_CALLBACK Func, void* lpParam); int GetUserQuotaInfo(int iPad, TMSCLIENT_CALLBACK Func, void* lpParam);
#endif #endif

View file

@ -65,22 +65,23 @@ void TeleportCommand::execute(std::shared_ptr<CommandSender> source,
// int pos = args.length - 3; // int pos = args.length - 3;
// int maxPos = Level.MAX_LEVEL_SIZE; // int maxPos = Level.MAX_LEVEL_SIZE;
// int x = convertArgToInt(source, args[pos++], -maxPos, // int x = convertArgToInt(source, args[pos++], -maxPos,
//maxPos); int y = convertArgToInt(source, args[pos++], // maxPos); int y = convertArgToInt(source,
//Level.minBuildHeight, Level.maxBuildHeight); int z = // args[pos++], Level.minBuildHeight, Level.maxBuildHeight);
//convertArgToInt(source, args[pos++], -maxPos, maxPos); // int z = convertArgToInt(source, args[pos++], -maxPos, maxPos);
// victim.teleportTo(x + 0.5f, y, z + 0.5f); // victim.teleportTo(x + 0.5f, y, z + 0.5f);
// logAdminAction(source, "commands.tp.coordinates", // logAdminAction(source, "commands.tp.coordinates",
//victim.getAName(), x, y, z); // victim.getAName(), x, y, z);
// } // }
// } else if (args.length == 1 || args.length == 2) { // } else if (args.length == 1 || args.length == 2) {
// ServerPlayer destination = // ServerPlayer destination =
//server.getPlayers().getPlayer(args[args.length - 1]); if (destination == // server.getPlayers().getPlayer(args[args.length - 1]); if
//null) throw new PlayerNotFoundException(); // (destination == null) throw new PlayerNotFoundException();
// victim.connection.teleport(destination.x, destination.y, // victim.connection.teleport(destination.x, destination.y,
//destination.z, destination.yRot, destination.xRot); logAdminAction(source, // destination.z, destination.yRot, destination.xRot);
//"commands.tp.success", victim.getAName(), destination.getAName()); // logAdminAction(source, "commands.tp.success", victim.getAName(),
// destination.getAName());
// } // }
//} //}
} }

View file

@ -254,7 +254,6 @@ void StatsCounter::save(int player, bool force) {
saveCounter = SAVE_DELAY; saveCounter = SAVE_DELAY;
} }
void StatsCounter::flushLeaderboards() { void StatsCounter::flushLeaderboards() {
if (LeaderboardManager::Instance()->OpenSession()) { if (LeaderboardManager::Instance()->OpenSession()) {
writeStats(); writeStats();
@ -301,7 +300,6 @@ void StatsCounter::writeStats() {
int viewCount = 0; int viewCount = 0;
int iPad = ProfileManager.GetLockedProfile(); int iPad = ProfileManager.GetLockedProfile();
} }
void StatsCounter::setupStatBoards() { void StatsCounter::setupStatBoards() {
@ -390,6 +388,5 @@ void StatsCounter::dumpStatsToTTY() {
#define DEBUG_CLEAR_LEADERBOARDS (0xFFFFFFFF) #define DEBUG_CLEAR_LEADERBOARDS (0xFFFFFFFF)
#define DEBUG_ENABLE_CLEAR_LEADERBOARDS #define DEBUG_ENABLE_CLEAR_LEADERBOARDS
void StatsCounter::WipeLeaderboards() { void StatsCounter::WipeLeaderboards() {}
}
#endif #endif

View file

@ -90,6 +90,5 @@ private:
bool isLargeStat(Stat* stat); bool isLargeStat(Stat* stat);
void dumpStatsToTTY(); void dumpStatsToTTY();
void writeStats(); void writeStats();
}; };

View file

@ -626,8 +626,8 @@ void MultiPlayerLevel::disconnect(bool sendDisconnect /*= true*/) {
Tickable* MultiPlayerLevel::makeSoundUpdater( Tickable* MultiPlayerLevel::makeSoundUpdater(
std::shared_ptr<Minecart> minecart) { std::shared_ptr<Minecart> minecart) {
return nullptr; // new MinecartSoundUpdater(minecraft->soundEngine, minecart, return nullptr; // new MinecartSoundUpdater(minecraft->soundEngine,
// minecraft->player); // minecart, minecraft->player);
} }
void MultiPlayerLevel::tickWeather() { void MultiPlayerLevel::tickWeather() {
@ -811,8 +811,8 @@ void MultiPlayerLevel::removeAllPendingEntityRemovals() {
EnterCriticalSection(&m_entitiesCS); EnterCriticalSection(&m_entitiesCS);
for (auto it = entities.begin(); it != entities.end();) { for (auto it = entities.begin(); it != entities.end();) {
bool found = false; bool found = false;
for (auto it2 = entitiesToRemove.begin(); for (auto it2 = entitiesToRemove.begin(); it2 != entitiesToRemove.end();
it2 != entitiesToRemove.end(); it2++) { it2++) {
if ((*it) == (*it2)) { if ((*it) == (*it2)) {
found = true; found = true;
break; break;

View file

@ -1384,8 +1384,7 @@ void ServerLevel::entityRemovedExtra(std::shared_ptr<Entity> e) {
EnterCriticalSection(&m_limiterCS); EnterCriticalSection(&m_limiterCS);
// printf("entity removed: item entity count // printf("entity removed: item entity count
//%d\n",m_itemEntities.size()); //%d\n",m_itemEntities.size());
auto it = auto it = find(m_hangingEntities.begin(), m_hangingEntities.end(), e);
find(m_hangingEntities.begin(), m_hangingEntities.end(), e);
if (it != m_hangingEntities.end()) { if (it != m_hangingEntities.end()) {
// printf("Item to remove found\n"); // printf("Item to remove found\n");
m_hangingEntities.erase(it); m_hangingEntities.erase(it);
@ -1410,7 +1409,7 @@ void ServerLevel::entityRemovedExtra(std::shared_ptr<Entity> e) {
// printf("entity removed: experience orb entity count // printf("entity removed: experience orb entity count
//%d\n",m_arrowEntities.size()); //%d\n",m_arrowEntities.size());
auto it = find(m_experienceOrbEntities.begin(), auto it = find(m_experienceOrbEntities.begin(),
m_experienceOrbEntities.end(), e); m_experienceOrbEntities.end(), e);
if (it != m_experienceOrbEntities.end()) { if (it != m_experienceOrbEntities.end()) {
// printf("Item to remove found\n"); // printf("Item to remove found\n");
m_experienceOrbEntities.erase(it); m_experienceOrbEntities.erase(it);

View file

@ -91,7 +91,6 @@ int Minecraft::frameTimePos = 0;
int64_t Minecraft::warezTime = 0; int64_t Minecraft::warezTime = 0;
File Minecraft::workDir = File(L""); File Minecraft::workDir = File(L"");
ResourceLocation Minecraft::DEFAULT_FONT_LOCATION = ResourceLocation Minecraft::DEFAULT_FONT_LOCATION =
ResourceLocation(TN_DEFAULT_FONT); ResourceLocation(TN_DEFAULT_FONT);
ResourceLocation Minecraft::ALT_FONT_LOCATION = ResourceLocation(TN_ALT_FONT); ResourceLocation Minecraft::ALT_FONT_LOCATION = ResourceLocation(TN_ALT_FONT);
@ -198,8 +197,8 @@ Minecraft::Minecraft(Component* mouseComponent, Canvas* parent,
localgameModes[i] = nullptr; localgameModes[i] = nullptr;
} }
animateTickLevel = nullptr; // 4J added animateTickLevel = nullptr; // 4J added
m_inFullTutorialBits = 0; // 4J Added m_inFullTutorialBits = 0; // 4J Added
reloadTextures = false; reloadTextures = false;
// initialise the audio before any textures are loaded - to avoid the // initialise the audio before any textures are loaded - to avoid the
@ -233,7 +232,6 @@ void Minecraft::connectTo(const std::wstring& server, int port) {
} }
void Minecraft::init() { void Minecraft::init() {
// glClearColor(0.2f, 0.2f, 0.2f, 1); // glClearColor(0.2f, 0.2f, 0.2f, 1);
workingDirectory = getWorkingDirectory(); workingDirectory = getWorkingDirectory();
@ -468,7 +466,8 @@ void Minecraft::setScreen(Screen* screen) {
this->screen = screen; this->screen = screen;
if (screen == nullptr && level == nullptr) { if (screen == nullptr && level == nullptr) {
screen = new TitleScreen(); screen = new TitleScreen();
} else if (player != nullptr && !ui.GetMenuDisplayed(player->GetXboxPad()) && } else if (player != nullptr &&
!ui.GetMenuDisplayed(player->GetXboxPad()) &&
player->getHealth() <= 0) { player->getHealth() <= 0) {
#if defined(ENABLE_JAVA_GUIS) #if defined(ENABLE_JAVA_GUIS)
screen = new DeathScreen(); screen = new DeathScreen();
@ -480,7 +479,8 @@ void Minecraft::setScreen(Screen* screen) {
if (ticks == 0) { if (ticks == 0) {
player->respawn(); player->respawn();
} else { } else {
ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, nullptr); ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu,
nullptr);
} }
#endif #endif
} }
@ -541,7 +541,8 @@ void Minecraft::destroy() {
if (screen == nullptr && level == nullptr) { if (screen == nullptr && level == nullptr) {
screen = new TitleScreen(); screen = new TitleScreen();
} else if (player != nullptr && !ui.GetMenuDisplayed(player->GetXboxPad()) && } else if (player != nullptr &&
!ui.GetMenuDisplayed(player->GetXboxPad()) &&
player->getHealth() <= 0) { player->getHealth() <= 0) {
#if defined(ENABLE_JAVA_GUIS) #if defined(ENABLE_JAVA_GUIS)
screen = new DeathScreen(); screen = new DeathScreen();
@ -553,7 +554,8 @@ void Minecraft::destroy() {
if (ticks == 0) { if (ticks == 0) {
player->respawn(); player->respawn();
} else { } else {
ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu, nullptr); ui.NavigateToScene(player->GetXboxPad(), eUIScene_DeathMenu,
nullptr);
} }
#endif #endif
} }
@ -605,7 +607,6 @@ void Minecraft::destroy() {
// 4J-PB - splitting this function into 3 parts, so we can call the middle part // 4J-PB - splitting this function into 3 parts, so we can call the middle part
// from our xbox game loop // from our xbox game loop
void Minecraft::run() { void Minecraft::run() {
running = true; running = true;
// try { // 4J - removed try/catch // try { // 4J - removed try/catch
@ -624,7 +625,8 @@ bool Minecraft::setLocalPlayerIdx(int idx) {
localPlayerIdx = idx; localPlayerIdx = idx;
// If the player is not null, but the game mode is then this is just a temp // If the player is not null, but the game mode is then this is just a temp
// player whose only real purpose is to hold the viewport position // player whose only real purpose is to hold the viewport position
if (localplayers[idx] == nullptr || localgameModes[idx] == nullptr) return false; if (localplayers[idx] == nullptr || localgameModes[idx] == nullptr)
return false;
gameMode = localgameModes[idx]; gameMode = localgameModes[idx];
player = localplayers[idx]; player = localplayers[idx];
@ -854,7 +856,8 @@ std::shared_ptr<MultiplayerLocalPlayer> Minecraft::createExtraLocalPlayer(
localplayers[idx]->SetXboxPad(iPad); localplayers[idx]->SetXboxPad(iPad);
if (localplayers[idx]->input != nullptr) delete localplayers[idx]->input; if (localplayers[idx]->input != nullptr)
delete localplayers[idx]->input;
localplayers[idx]->input = new Input(); localplayers[idx]->input = new Input();
localplayers[idx]->resetPos(); localplayers[idx]->resetPos();
@ -907,7 +910,6 @@ void Minecraft::removeLocalPlayerIdx(int idx) {
} }
getLevel(localplayers[idx]->dimension)->removeEntity(localplayers[idx]); getLevel(localplayers[idx]->dimension)->removeEntity(localplayers[idx]);
// 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title crashed after
// exiting the tutorial It doesn't matter if they were in the tutorial // exiting the tutorial It doesn't matter if they were in the tutorial
// already // already
@ -1322,8 +1324,7 @@ void Minecraft::run_middle() {
// did we just get input from a player who doesn't // did we just get input from a player who doesn't
// exist? They'll be wanting to join the game then // exist? They'll be wanting to join the game then
if (InputManager.ButtonPressed( if (InputManager.ButtonPressed(
i, MINECRAFT_ACTION_PAUSEMENU)) i, MINECRAFT_ACTION_PAUSEMENU)) {
{
// Let them join // Let them join
// are they signed in? // are they signed in?
@ -1430,7 +1431,6 @@ void Minecraft::run_middle() {
} }
} }
if (pause && level != nullptr) { if (pause && level != nullptr) {
float lastA = timer->a; float lastA = timer->a;
timer->advanceTime(); timer->advanceTime();
@ -2349,8 +2349,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
case Tile::chest_Id: case Tile::chest_Id:
*piAction = IDS_TOOLTIPS_MINE; *piAction = IDS_TOOLTIPS_MINE;
*piUse = (Tile::chest->getContainer(level, x, y, *piUse = (Tile::chest->getContainer(
z) != nullptr) level, x, y, z) != nullptr)
? IDS_TOOLTIPS_OPEN ? IDS_TOOLTIPS_OPEN
: -1; : -1;
break; break;
@ -3402,14 +3402,14 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
#endif #endif
} }
if ((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_PAUSEMENU)) if ((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_PAUSEMENU))) {
) {
app.DebugPrintf( app.DebugPrintf(
"PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n", "PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n",
player->GetXboxPad()); player->GetXboxPad());
ui.PlayUISFX(eSFX_Press); ui.PlayUISFX(eSFX_Press);
#if !defined(ENABLE_JAVA_GUIS) #if !defined(ENABLE_JAVA_GUIS)
ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr, eUILayer_Scene); ui.NavigateToScene(iPad, eUIScene_PauseMenu, nullptr,
eUILayer_Scene);
#endif #endif
} }
@ -3439,8 +3439,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
if (selectedItem != nullptr) iCount = selectedItem->GetCount(); if (selectedItem != nullptr) iCount = selectedItem->GetCount();
if (selectedItem != nullptr && !((player->ullButtonsPressed & if (selectedItem != nullptr && !((player->ullButtonsPressed &
(1LL << MINECRAFT_ACTION_DROP)) && (1LL << MINECRAFT_ACTION_DROP)) &&
selectedItem->GetCount() == 1)) { selectedItem->GetCount() == 1)) {
itemName = selectedItem->getHoverName(); itemName = selectedItem->getHoverName();
} }
if (!(player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_DROP)) || if (!(player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_DROP)) ||
@ -3473,7 +3473,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// } // }
// #endif // #endif
if (level != nullptr) { if (level != nullptr) {
if (player != nullptr) { if (player != nullptr) {
recheckPlayerIn++; recheckPlayerIn++;
@ -3598,7 +3597,9 @@ void Minecraft::reloadSound() {
bgLoader->forceReload(); bgLoader->forceReload();
} }
bool Minecraft::isClientSide() { return level != nullptr && level->isClientSide; } bool Minecraft::isClientSide() {
return level != nullptr && level->isClientSide;
}
void Minecraft::selectLevel(ConsoleSaveFile* saveFile, void Minecraft::selectLevel(ConsoleSaveFile* saveFile,
const std::wstring& levelId, const std::wstring& levelId,
@ -3698,9 +3699,9 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/,
forceStatsSave(player->GetXboxPad()); forceStatsSave(player->GetXboxPad());
// 4J Stu - Added these for the case when we exit a level so we are // 4J Stu - Added these for the case when we exit a level so we are
// setting the level to nullptr The level renderer needs to have it's // setting the level to nullptr The level renderer needs to have
// stored level set to nullptr so that it doesn't break next time we // it's stored level set to nullptr so that it doesn't break next
// set one // time we set one
if (levelRenderer != nullptr) { if (levelRenderer != nullptr) {
for (unsigned int p = 0; p < XUSER_MAX_COUNT; ++p) { for (unsigned int p = 0; p < XUSER_MAX_COUNT; ++p) {
levelRenderer->setLevel(p, nullptr); levelRenderer->setLevel(p, nullptr);
@ -3709,8 +3710,8 @@ void Minecraft::setLevel(MultiPlayerLevel* level, int message /*=-1*/,
if (particleEngine != nullptr) particleEngine->setLevel(nullptr); if (particleEngine != nullptr) particleEngine->setLevel(nullptr);
} }
} }
// 4J If we are setting the level to nullptr then we are exiting, so delete the // 4J If we are setting the level to nullptr then we are exiting, so delete
// levels // the levels
if (level == nullptr) { if (level == nullptr) {
if (levels[0] != nullptr) { if (levels[0] != nullptr) {
delete levels[0]; delete levels[0];
@ -3863,7 +3864,6 @@ void Minecraft::prepareLevel(int title) {
spawnPos->z = (int)player->z; spawnPos->z = (int)player->z;
} }
for (int x = -r; x <= r; x += 16) { for (int x = -r; x <= r; x += 16) {
for (int z = -r; z <= r; z += 16) { for (int z = -r; z <= r; z += 16) {
if (progressRenderer != nullptr) if (progressRenderer != nullptr)
@ -4078,8 +4078,8 @@ void Minecraft::startAndConnectTo(const std::wstring& name,
// if (ProfileManager.IsFullVersion()) // if (ProfileManager.IsFullVersion())
{ {
if (userName != L"" && if (userName != L"" &&
sid != L"") // 4J - username & side were compared with nullptr rather sid != L"") // 4J - username & side were compared with nullptr
// than empty strings // rather than empty strings
{ {
minecraft->user = new User(userName, sid); minecraft->user = new User(userName, sid);
} else { } else {
@ -4226,8 +4226,8 @@ if (gameMode->instaBuild) return;
if (!down) missTime = 0; if (!down) missTime = 0;
if (button == 0 && missTime > 0) return; if (button == 0 && missTime > 0) return;
if (down && hitResult != nullptr && hitResult->type == HitResult::TILE && button == if (down && hitResult != nullptr && hitResult->type == HitResult::TILE && button
0) == 0)
{ {
int x = hitResult->x; int x = hitResult->x;
int y = hitResult->y; int y = hitResult->y;
@ -4260,7 +4260,8 @@ bool mayUse = true;
// 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer // 4J-PB - Adding a special case in here for sleeping in a bed in a multiplayer
game - we need to wake up, and we don't have the inbedchatscreen with a button game - we need to wake up, and we don't have the inbedchatscreen with a button
if(button==1 && (player->isSleeping() && level != nullptr && level->isClientSide)) if(button==1 && (player->isSleeping() && level != nullptr &&
level->isClientSide))
{ {
shared_ptr<MultiplayerLocalPlayer> mplp = shared_ptr<MultiplayerLocalPlayer> mplp =
std::dynamic_pointer_cast<MultiplayerLocalPlayer>( player ); std::dynamic_pointer_cast<MultiplayerLocalPlayer>( player );
@ -4279,8 +4280,8 @@ PlayerCommandPacket.STOP_SLEEPING));
if (hitResult == nullptr) if (hitResult == nullptr)
{ {
if (button == 0 && !(dynamic_cast<CreativeMode *>(gameMode) != nullptr)) missTime = if (button == 0 && !(dynamic_cast<CreativeMode *>(gameMode) != nullptr))
10; missTime = 10;
} }
else if (hitResult->type == HitResult::ENTITY) else if (hitResult->type == HitResult::ENTITY)
{ {
@ -4402,9 +4403,7 @@ void Minecraft::playerLeftTutorial(int iPad) {
} }
} }
int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) {
int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad)
{
Minecraft* pMinecraftClass = (Minecraft*)pParam; Minecraft* pMinecraftClass = (Minecraft*)pParam;
if (g_NetworkManager.IsInSession()) { if (g_NetworkManager.IsInSession()) {
@ -4424,7 +4423,7 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad)
// It's possible that the player has not signed in - they can back out // It's possible that the player has not signed in - they can back out
// or choose no for the converttoguest // or choose no for the converttoguest
if (ProfileManager.IsSignedIn(iPad)) { if (ProfileManager.IsSignedIn(iPad)) {
if (!g_NetworkManager.SessionHasSpace()) { if (!g_NetworkManager.SessionHasSpace()) {
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_OK; uiIDA[0] = IDS_OK;
ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE, ui.RequestErrorMessage(IDS_MULTIPLAYER_FULL_TITLE,
@ -4485,7 +4484,7 @@ void Minecraft::tickAllConnections() {
bool Minecraft::addPendingClientTextureRequest( bool Minecraft::addPendingClientTextureRequest(
const std::wstring& textureName) { const std::wstring& textureName) {
auto it = find(m_pendingTextureRequests.begin(), auto it = find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName); m_pendingTextureRequests.end(), textureName);
if (it == m_pendingTextureRequests.end()) { if (it == m_pendingTextureRequests.end()) {
m_pendingTextureRequests.push_back(textureName); m_pendingTextureRequests.push_back(textureName);
return true; return true;
@ -4495,7 +4494,7 @@ bool Minecraft::addPendingClientTextureRequest(
void Minecraft::handleClientTextureReceived(const std::wstring& textureName) { void Minecraft::handleClientTextureReceived(const std::wstring& textureName) {
auto it = find(m_pendingTextureRequests.begin(), auto it = find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName); m_pendingTextureRequests.end(), textureName);
if (it != m_pendingTextureRequests.end()) { if (it != m_pendingTextureRequests.end()) {
m_pendingTextureRequests.erase(it); m_pendingTextureRequests.erase(it);
} }
@ -4516,4 +4515,3 @@ ColourTable* Minecraft::getColourTable() {
return colours; return colours;
} }

View file

@ -277,7 +277,7 @@ public:
// bool isRaining ; // bool isRaining ;
// 4J - Moved to per player // 4J - Moved to per player
//int64_t lastTickTime; // int64_t lastTickTime;
private: private:
// 4J- per player? // 4J- per player?
@ -386,5 +386,4 @@ public:
unsigned int getCurrentTexturePackId(); unsigned int getCurrentTexturePackId();
ColourTable* getColourTable(); ColourTable* getColourTable();
}; };

View file

@ -889,8 +889,7 @@ void MinecraftServer::stopServer(bool didInit) {
// also need to check for a profile switch here - primary player signs out, // also need to check for a profile switch here - primary player signs out,
// and another player signs in before dismissing the dash // and another player signs in before dismissing the dash
if ((m_bPrimaryPlayerSignedOut == false) && if ((m_bPrimaryPlayerSignedOut == false) &&
ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) {
{
// if trial version or saving is disabled, then don't save anything. // if trial version or saving is disabled, then don't save anything.
// Also don't save anything if we didn't actually get through the server // Also don't save anything if we didn't actually get through the server
// initialisation. // initialisation.
@ -916,7 +915,7 @@ void MinecraftServer::stopServer(bool didInit) {
saveGameRules(); saveGameRules();
app.m_gameRules.unloadCurrentGameRules(); app.m_gameRules.unloadCurrentGameRules();
if (levels[0] != nullptr) // This can be null if stopServer happens if (levels[0] != nullptr) // This can be null if stopServer happens
// very quickly due to network error // very quickly due to network error
{ {
levels[0]->saveToDisc( levels[0]->saveToDisc(
Minecraft::GetInstance()->progressRenderer, false); Minecraft::GetInstance()->progressRenderer, false);
@ -942,7 +941,6 @@ void MinecraftServer::stopServer(bool didInit) {
} }
} }
delete connection; delete connection;
connection = nullptr; connection = nullptr;
delete players; delete players;
@ -1613,8 +1611,7 @@ void MinecraftServer::chunkPacketManagement_PreTick() {
do { do {
int longestTime = 0; int longestTime = 0;
auto playerConnectionBest = playersOrig.begin(); auto playerConnectionBest = playersOrig.begin();
for (auto it = playersOrig.begin(); it != playersOrig.end(); for (auto it = playersOrig.begin(); it != playersOrig.end(); it++) {
it++) {
int thisTime = 0; int thisTime = 0;
INetworkPlayer* np = (*it)->getNetworkPlayer(); INetworkPlayer* np = (*it)->getNetworkPlayer();
if (np) { if (np) {
@ -1700,8 +1697,8 @@ void MinecraftServer::cycleSlowQueueIndex() {
s_slowQueuePlayerIndex = 0; s_slowQueuePlayerIndex = 0;
} }
} while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 && } while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 &&
s_slowQueuePlayerIndex != startingIndex && currentPlayer != nullptr && s_slowQueuePlayerIndex != startingIndex &&
currentPlayer->IsLocal()); currentPlayer != nullptr && currentPlayer->IsLocal());
// app.DebugPrintf("Cycled slow queue index to %d\n", // app.DebugPrintf("Cycled slow queue index to %d\n",
// s_slowQueuePlayerIndex); // s_slowQueuePlayerIndex);
} }

View file

@ -22,7 +22,6 @@ class CommandDispatcher;
#define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250 #define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250
typedef struct _LoadSaveDataThreadParam { typedef struct _LoadSaveDataThreadParam {
void* data; void* data;
int64_t fileSize; int64_t fileSize;

View file

@ -50,7 +50,6 @@
#include "../Platform/Common/UI/UI.h" #include "../Platform/Common/UI/UI.h"
#include "../Textures/Packs/DLCTexturePack.h" #include "../Textures/Packs/DLCTexturePack.h"
ClientConnection::ClientConnection(Minecraft* minecraft, const std::wstring& ip, ClientConnection::ClientConnection(Minecraft* minecraft, const std::wstring& ip,
int port) { int port) {
// 4J Stu - No longer used as we use the socket version below. // 4J Stu - No longer used as we use the socket version below.
@ -1256,7 +1255,8 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1, ui.RequestErrorMessage(IDS_EXITING_GAME, IDS_GENERIC_ERROR, uiIDA, 1,
ProfileManager.GetPrimaryPad(), ProfileManager.GetPrimaryPad(),
&ClientConnection::HostDisconnectReturned, nullptr); &ClientConnection::HostDisconnectReturned,
nullptr);
} else { } else {
app.SetAction(m_userIndex, eAppAction_ExitWorld, (void*)true); app.SetAction(m_userIndex, eAppAction_ExitWorld, (void*)true);
} }
@ -1839,9 +1839,6 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
isAtLeastOneFriend = true; isAtLeastOneFriend = true;
cantPlayContentRestricted = false; cantPlayContentRestricted = false;
if (!canPlay || !canPlayLocal || !isAtLeastOneFriend || if (!canPlay || !canPlayLocal || !isAtLeastOneFriend ||
cantPlayContentRestricted) { cantPlayContentRestricted) {
DisconnectPacket::eDisconnectReason reason = DisconnectPacket::eDisconnectReason reason =
@ -1943,8 +1940,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
// On PS3, all non-signed in players (even guests) can get a useful // On PS3, all non-signed in players (even guests) can get a useful
// offlineXUID // offlineXUID
if (!ProfileManager.IsGuest(m_userIndex)) if (!ProfileManager.IsGuest(m_userIndex)) {
{
// All other players we use their offline XUID so that they can play // All other players we use their offline XUID so that they can play
// the game offline // the game offline
ProfileManager.GetXUID(m_userIndex, &offlineXUID, false); ProfileManager.GetXUID(m_userIndex, &offlineXUID, false);
@ -2003,8 +1999,7 @@ void ClientConnection::handleAddMob(std::shared_ptr<AddMobPacket> packet) {
if (subEntities != nullptr) { if (subEntities != nullptr) {
int offs = packet->id - mob->entityId; int offs = packet->id - mob->entityId;
// for (int i = 0; i < subEntities.length; i++) // for (int i = 0; i < subEntities.length; i++)
for (auto it = subEntities->begin(); it != subEntities->end(); for (auto it = subEntities->begin(); it != subEntities->end(); ++it) {
++it) {
// subEntities[i].entityId += offs; // subEntities[i].entityId += offs;
(*it)->entityId += offs; (*it)->entityId += offs;
} }
@ -2078,7 +2073,8 @@ void ClientConnection::handleEntityLinkPacket(
displayMountMessage = displayMountMessage =
(sourceEntity->riding == nullptr && destEntity != nullptr); (sourceEntity->riding == nullptr && destEntity != nullptr);
} else if (destEntity != nullptr && destEntity->instanceof(eTYPE_BOAT)) { } else if (destEntity != nullptr &&
destEntity->instanceof(eTYPE_BOAT)) {
(std::dynamic_pointer_cast<Boat>(destEntity))->setDoLerp(true); (std::dynamic_pointer_cast<Boat>(destEntity))->setDoLerp(true);
} }
@ -2416,7 +2412,6 @@ void ClientConnection::handleRespawn(std::shared_ptr<RespawnPacket> packet) {
minecraft->setScreen(new ReceivingLevelScreen(this)); minecraft->setScreen(new ReceivingLevelScreen(this));
// minecraft->addPendingLocalConnection(m_userIndex, this); // minecraft->addPendingLocalConnection(m_userIndex, this);
if (minecraft->localgameModes[m_userIndex] != nullptr) { if (minecraft->localgameModes[m_userIndex] != nullptr) {
TutorialMode* gameMode = TutorialMode* gameMode =
(TutorialMode*)minecraft->localgameModes[m_userIndex]; (TutorialMode*)minecraft->localgameModes[m_userIndex];
@ -2816,7 +2811,8 @@ void ClientConnection::handleTileEntityData(
if (te != nullptr) { if (te != nullptr) {
if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER && if (packet->type == TileEntityDataPacket::TYPE_MOB_SPAWNER &&
std::dynamic_pointer_cast<MobSpawnerTileEntity>(te) != nullptr) { std::dynamic_pointer_cast<MobSpawnerTileEntity>(te) !=
nullptr) {
std::dynamic_pointer_cast<MobSpawnerTileEntity>(te)->load( std::dynamic_pointer_cast<MobSpawnerTileEntity>(te)->load(
packet->tag); packet->tag);
} else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND && } else if (packet->type == TileEntityDataPacket::TYPE_ADV_COMMAND &&
@ -2830,7 +2826,8 @@ void ClientConnection::handleTileEntityData(
std::dynamic_pointer_cast<BeaconTileEntity>(te)->load( std::dynamic_pointer_cast<BeaconTileEntity>(te)->load(
packet->tag); packet->tag);
} else if (packet->type == TileEntityDataPacket::TYPE_SKULL && } else if (packet->type == TileEntityDataPacket::TYPE_SKULL &&
std::dynamic_pointer_cast<SkullTileEntity>(te) != nullptr) { std::dynamic_pointer_cast<SkullTileEntity>(te) !=
nullptr) {
std::dynamic_pointer_cast<SkullTileEntity>(te)->load( std::dynamic_pointer_cast<SkullTileEntity>(te)->load(
packet->tag); packet->tag);
} }
@ -2912,7 +2909,8 @@ void ClientConnection::handleGameEvent(
app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n",
m_userIndex); m_userIndex);
// This just allows it to be shown // This just allows it to be shown
if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] != nullptr) if (minecraft->localgameModes[ProfileManager.GetPrimaryPad()] !=
nullptr)
minecraft->localgameModes[ProfileManager.GetPrimaryPad()] minecraft->localgameModes[ProfileManager.GetPrimaryPad()]
->getTutorial() ->getTutorial()
->showTutorialPopup(false); ->showTutorialPopup(false);
@ -3362,8 +3360,7 @@ int ClientConnection::HostDisconnectReturned(
uiIDA, 2, ProfileManager.GetPrimaryPad(), uiIDA, 2, ProfileManager.GetPrimaryPad(),
&ClientConnection::ExitGameAndSaveReturned, &ClientConnection::ExitGameAndSaveReturned,
nullptr); nullptr);
} else } else {
{
MinecraftServer::getInstance()->setSaveOnExit(true); MinecraftServer::getInstance()->setSaveOnExit(true);
// flag a app action of exit game // flag a app action of exit game
app.SetAction(iPad, eAppAction_ExitWorld); app.SetAction(iPad, eAppAction_ExitWorld);
@ -3396,19 +3393,15 @@ std::wstring ClientConnection::GetDisplayNameByGamertag(std::wstring gamertag) {
} }
void ClientConnection::handleAddObjective( void ClientConnection::handleAddObjective(
std::shared_ptr<SetObjectivePacket> packet) { std::shared_ptr<SetObjectivePacket> packet) {}
}
void ClientConnection::handleSetScore(std::shared_ptr<SetScorePacket> packet) { void ClientConnection::handleSetScore(std::shared_ptr<SetScorePacket> packet) {}
}
void ClientConnection::handleSetDisplayObjective( void ClientConnection::handleSetDisplayObjective(
std::shared_ptr<SetDisplayObjectivePacket> packet) { std::shared_ptr<SetDisplayObjectivePacket> packet) {}
}
void ClientConnection::handleSetPlayerTeamPacket( void ClientConnection::handleSetPlayerTeamPacket(
std::shared_ptr<SetPlayerTeamPacket> packet) { std::shared_ptr<SetPlayerTeamPacket> packet) {}
}
void ClientConnection::handleParticleEvent( void ClientConnection::handleParticleEvent(
std::shared_ptr<LevelParticlesPacket> packet) { std::shared_ptr<LevelParticlesPacket> packet) {
@ -3444,8 +3437,8 @@ void ClientConnection::handleUpdateAttributes(
(std::dynamic_pointer_cast<LivingEntity>(entity))->getAttributes(); (std::dynamic_pointer_cast<LivingEntity>(entity))->getAttributes();
std::unordered_set<UpdateAttributesPacket::AttributeSnapshot*> std::unordered_set<UpdateAttributesPacket::AttributeSnapshot*>
attributeSnapshots = packet->getValues(); attributeSnapshots = packet->getValues();
for (auto it = attributeSnapshots.begin(); for (auto it = attributeSnapshots.begin(); it != attributeSnapshots.end();
it != attributeSnapshots.end(); ++it) { ++it) {
UpdateAttributesPacket::AttributeSnapshot* attribute = *it; UpdateAttributesPacket::AttributeSnapshot* attribute = *it;
AttributeInstance* instance = AttributeInstance* instance =
attributes->getInstance(attribute->getId()); attributes->getInstance(attribute->getId());
@ -3465,8 +3458,7 @@ void ClientConnection::handleUpdateAttributes(
std::unordered_set<AttributeModifier*>* modifiers = std::unordered_set<AttributeModifier*>* modifiers =
attribute->getModifiers(); attribute->getModifiers();
for (auto it2 = modifiers->begin(); it2 != modifiers->end(); for (auto it2 = modifiers->begin(); it2 != modifiers->end(); ++it2) {
++it2) {
AttributeModifier* modifier = *it2; AttributeModifier* modifier = *it2;
instance->addModifier( instance->addModifier(
new AttributeModifier(modifier->getId(), modifier->getAmount(), new AttributeModifier(modifier->getId(), modifier->getAmount(),

View file

@ -207,8 +207,8 @@ LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
(int64_t*)&cache[idx], (int64_t)chunk, (int64_t)lastChunk) == (int64_t*)&cache[idx], (int64_t)chunk, (int64_t)lastChunk) ==
(int64_t)lastChunk) (int64_t)lastChunk)
#else #else
if (InterlockedCompareExchangeRelease((int32_t*)&cache[idx], (int32_t)chunk, if (InterlockedCompareExchangeRelease(
(int32_t)lastChunk) == (int32_t*)&cache[idx], (int32_t)chunk, (int32_t)lastChunk) ==
(int32_t)lastChunk) (int32_t)lastChunk)
#endif // 0 #endif // 0
{ {

View file

@ -93,8 +93,8 @@ void PendingConnection::sendPreLoginResponse() {
StorageManager.GetSaveUniqueFilename(szUniqueMapName); StorageManager.GetSaveUniqueFilename(szUniqueMapName);
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers(); PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
for (auto it = playerList->players.begin(); for (auto it = playerList->players.begin(); it != playerList->players.end();
it != playerList->players.end(); ++it) { ++it) {
std::shared_ptr<ServerPlayer> player = *it; std::shared_ptr<ServerPlayer> player = *it;
// If the offline Xuid is invalid but the online one is not then that's // If the offline Xuid is invalid but the online one is not then that's
// guest which we should ignore If the online Xuid is invalid but the // guest which we should ignore If the online Xuid is invalid but the
@ -180,9 +180,9 @@ void PendingConnection::handleAcceptedLogin(
packet->m_onlineXuid); packet->m_onlineXuid);
if (playerEntity != nullptr) { if (playerEntity != nullptr) {
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet); server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
connection = nullptr; // We've moved responsibility for this over to the connection = nullptr; // We've moved responsibility for this over to
// new PlayerConnection, nullptr so we don't delete our // the new PlayerConnection, nullptr so we don't
// reference to it here in our dtor // delete our reference to it here in our dtor
} }
done = true; done = true;
} }

View file

@ -105,7 +105,7 @@ void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player) {
LevelChunk* chunk = parent->level->getChunk(pos.x, pos.z); LevelChunk* chunk = parent->level->getChunk(pos.x, pos.z);
updateInhabitedTime(chunk); updateInhabitedTime(chunk);
auto it = find(parent->knownChunks.begin(), auto it = find(parent->knownChunks.begin(),
parent->knownChunks.end(), this); parent->knownChunks.end(), this);
if (it != parent->knownChunks.end()) parent->knownChunks.erase(it); if (it != parent->knownChunks.end()) parent->knownChunks.erase(it);
} }
int64_t id = (pos.x + 0x7fffffffLL) | ((pos.z + 0x7fffffffLL) << 32); int64_t id = (pos.x + 0x7fffffffLL) | ((pos.z + 0x7fffffffLL) << 32);
@ -117,7 +117,7 @@ void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player) {
} }
if (changes > 0) { if (changes > 0) {
auto it = find(parent->changedChunks.begin(), auto it = find(parent->changedChunks.begin(),
parent->changedChunks.end(), this); parent->changedChunks.end(), this);
parent->changedChunks.erase(it); parent->changedChunks.erase(it);
} }
parent->getLevel()->cache->drop(pos.x, pos.z); parent->getLevel()->cache->drop(pos.x, pos.z);
@ -764,10 +764,9 @@ bool PlayerChunkMap::isPlayerIn(std::shared_ptr<ServerPlayer> player,
if (chunk == nullptr) { if (chunk == nullptr) {
return false; return false;
} else { } else {
auto it1 = auto it1 = find(chunk->players.begin(), chunk->players.end(), player);
find(chunk->players.begin(), chunk->players.end(), player);
auto it2 = find(player->chunksToSend.begin(), auto it2 = find(player->chunksToSend.begin(),
player->chunksToSend.end(), chunk->pos); player->chunksToSend.end(), chunk->pos);
return it1 != chunk->players.end() && it2 == player->chunksToSend.end(); return it1 != chunk->players.end() && it2 == player->chunksToSend.end();
} }

View file

@ -273,9 +273,7 @@ void PlayerConnection::handleMovePlayer(
float r = 1 / 16.0f; float r = 1 / 16.0f;
AABB shrunk = player->bb.shrink(r, r, r); AABB shrunk = player->bb.shrink(r, r, r);
bool oldOk = bool oldOk = level->getCubes(player, &shrunk)->empty();
level->getCubes(player, &shrunk)
->empty();
if (player->onGround && !packet->onGround && yDist > 0) { if (player->onGround && !packet->onGround && yDist > 0) {
// assume the player made a jump // assume the player made a jump
@ -327,9 +325,7 @@ void PlayerConnection::handleMovePlayer(
// TODO: check if this can be elided // TODO: check if this can be elided
shrunk = player->bb.shrink(r, r, r); shrunk = player->bb.shrink(r, r, r);
bool newOk = bool newOk = level->getCubes(player, &shrunk)->empty();
level->getCubes(player, &shrunk)
->empty();
if (oldOk && (fail || !newOk) && !player->isSleeping()) { if (oldOk && (fail || !newOk) && !player->isSleeping()) {
teleport(xLastOk, yLastOk, zLastOk, yRotT, xRotT); teleport(xLastOk, yLastOk, zLastOk, yRotT, xRotT);
return; return;
@ -712,7 +708,7 @@ void PlayerConnection::handleInteract(std::shared_ptr<InteractPacket> packet) {
// a ray from head->head, but we may actually be looking at a different part // a ray from head->head, but we may actually be looking at a different part
// of the entity that can be seen even though the ray is blocked. // of the entity that can be seen even though the ray is blocked.
if (target != nullptr) // && player->canSee(target) && if (target != nullptr) // && player->canSee(target) &&
// player->distanceToSqr(target) < 6 * 6) // player->distanceToSqr(target) < 6 * 6)
{ {
// boole canSee = player->canSee(target); // boole canSee = player->canSee(target);
// double maxDist = 6 * 6; // double maxDist = 6 * 6;
@ -852,7 +848,7 @@ void PlayerConnection::handleTextureReceived(const std::wstring& textureName) {
// This sends the server received texture out to any other players waiting // This sends the server received texture out to any other players waiting
// for the data // for the data
auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(), auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(),
textureName); textureName);
if (it != m_texturesRequested.end()) { if (it != m_texturesRequested.end()) {
std::uint8_t* pbData = nullptr; std::uint8_t* pbData = nullptr;
unsigned int dwBytes = 0; unsigned int dwBytes = 0;
@ -871,7 +867,7 @@ void PlayerConnection::handleTextureAndGeometryReceived(
// This sends the server received texture out to any other players waiting // This sends the server received texture out to any other players waiting
// for the data // for the data
auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(), auto it = find(m_texturesRequested.begin(), m_texturesRequested.end(),
textureName); textureName);
if (it != m_texturesRequested.end()) { if (it != m_texturesRequested.end()) {
std::uint8_t* pbData = nullptr; std::uint8_t* pbData = nullptr;
unsigned int dwTextureBytes = 0; unsigned int dwTextureBytes = 0;
@ -1112,7 +1108,8 @@ void PlayerConnection::handleContainerSetSlot(
std::shared_ptr<ItemInstance> lastItem = std::shared_ptr<ItemInstance> lastItem =
player->inventoryMenu->getSlot(packet->slot)->getItem(); player->inventoryMenu->getSlot(packet->slot)->getItem();
if (packet->item != nullptr) { if (packet->item != nullptr) {
if (lastItem == nullptr || lastItem->count < packet->item->count) { if (lastItem == nullptr ||
lastItem->count < packet->item->count) {
packet->item->popTime = Inventory::POP_TIME_DURATION; packet->item->popTime = Inventory::POP_TIME_DURATION;
} }
} }
@ -1226,11 +1223,12 @@ void PlayerConnection::handleSetCreativeModeSlot(
bool validSlot = (packet->slotNum >= InventoryMenu::CRAFT_SLOT_START && bool validSlot = (packet->slotNum >= InventoryMenu::CRAFT_SLOT_START &&
packet->slotNum < (InventoryMenu::USE_ROW_SLOT_START + packet->slotNum < (InventoryMenu::USE_ROW_SLOT_START +
Inventory::getSelectionSize())); Inventory::getSelectionSize()));
bool validItem = bool validItem = item == nullptr ||
item == nullptr || (item->id < Item::items.length && item->id >= 0 && (item->id < Item::items.length && item->id >= 0 &&
Item::items[item->id] != nullptr); Item::items[item->id] != nullptr);
bool validData = item == nullptr || (item->getAuxValue() >= 0 && bool validData =
item->count > 0 && item->count <= 64); item == nullptr ||
(item->getAuxValue() >= 0 && item->count > 0 && item->count <= 64);
if (validSlot && validItem && validData) { if (validSlot && validItem && validData) {
if (item == nullptr) { if (item == nullptr) {
@ -1795,8 +1793,10 @@ void PlayerConnection::handleTradeItem(
int buyAMatches = player->inventory->countMatches(buyAItem); int buyAMatches = player->inventory->countMatches(buyAItem);
int buyBMatches = player->inventory->countMatches(buyBItem); int buyBMatches = player->inventory->countMatches(buyBItem);
if ((buyAItem != nullptr && buyAMatches >= buyAItem->count) && if ((buyAItem != nullptr &&
(buyBItem == nullptr || buyBMatches >= buyBItem->count)) { buyAMatches >= buyAItem->count) &&
(buyBItem == nullptr ||
buyBMatches >= buyBItem->count)) {
menu->getMerchant()->notifyTrade(activeRecipe); menu->getMerchant()->notifyTrade(activeRecipe);
// Remove the items we are purchasing with // Remove the items we are purchasing with

View file

@ -83,7 +83,6 @@ void PlayerList::placeNewPlayer(Connection* connection,
player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST, 1); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_HOST, 1);
} }
// 4J Stu - TU-1 hotfix // 4J Stu - TU-1 hotfix
// Fix for #13150 - When a player loads/joins a game after saving/leaving in // Fix for #13150 - When a player loads/joins a game after saving/leaving in
// the nether, sometimes they are spawned on top of the nether and cannot // the nether, sometimes they are spawned on top of the nether and cannot
@ -268,8 +267,7 @@ void PlayerList::placeNewPlayer(Connection* connection,
level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)))); level->getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT))));
auto activeEffects = player->getActiveEffects(); auto activeEffects = player->getActiveEffects();
for (auto it = activeEffects->begin(); it != activeEffects->end(); for (auto it = activeEffects->begin(); it != activeEffects->end(); ++it) {
++it) {
MobEffectInstance* effect = *it; MobEffectInstance* effect = *it;
playerConnection->send(std::shared_ptr<UpdateMobEffectPacket>( playerConnection->send(std::shared_ptr<UpdateMobEffectPacket>(
new UpdateMobEffectPacket(player->entityId, effect))); new UpdateMobEffectPacket(player->entityId, effect)));
@ -602,7 +600,8 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(
if (ep->dimension != oldDimension) continue; if (ep->dimension != oldDimension) continue;
INetworkPlayer* otherPlayer = ep->connection->getNetworkPlayer(); INetworkPlayer* otherPlayer = ep->connection->getNetworkPlayer();
if (otherPlayer != nullptr && thisPlayer->IsSameSystem(otherPlayer)) { if (otherPlayer != nullptr &&
thisPlayer->IsSameSystem(otherPlayer)) {
// There's another player here in the same dimension - we're not // There's another player here in the same dimension - we're not
// the last one out // the last one out
isEmptying = false; isEmptying = false;
@ -614,9 +613,9 @@ std::shared_ptr<ServerPlayer> PlayerList::respawn(
// (1) if this isn't the primary player, then we just need to remove it from // (1) if this isn't the primary player, then we just need to remove it from
// the entity tracker (2) if this Is the primary player then: // the entity tracker (2) if this Is the primary player then:
// (a) if isEmptying is true, then remove the player from the // (a) if isEmptying is true, then remove the player from the
//tracker, and send "remove entity" packets for anything seen (this is the // tracker, and send "remove entity" packets for anything seen (this is the
//original behaviour of the code) (b) if isEmptying is false, then we'll be // original behaviour of the code) (b) if isEmptying is false, then
//transferring control of entity tracking to another player // we'll be transferring control of entity tracking to another player
if (isPrimary) { if (isPrimary) {
if (isEmptying) { if (isEmptying) {
@ -893,8 +892,7 @@ void PlayerList::toggleDimension(std::shared_ptr<ServerPlayer> player,
// 4J Stu - Fix for #64683 - Customer Encountered: TU7: Content: Gameplay: // 4J Stu - Fix for #64683 - Customer Encountered: TU7: Content: Gameplay:
// Potion effects are removed after using the Nether Portal // Potion effects are removed after using the Nether Portal
std::vector<MobEffectInstance*>* activeEffects = player->getActiveEffects(); std::vector<MobEffectInstance*>* activeEffects = player->getActiveEffects();
for (auto it = activeEffects->begin(); it != activeEffects->end(); for (auto it = activeEffects->begin(); it != activeEffects->end(); ++it) {
++it) {
MobEffectInstance* effect = *it; MobEffectInstance* effect = *it;
player->connection->send(std::shared_ptr<UpdateMobEffectPacket>( player->connection->send(std::shared_ptr<UpdateMobEffectPacket>(
@ -1130,9 +1128,9 @@ bool PlayerList::isOp(std::shared_ptr<ServerPlayer> player) {
cheatsEnabled = cheatsEnabled || app.GetUseDPadForDebug(); cheatsEnabled = cheatsEnabled || app.GetUseDPadForDebug();
#endif #endif
INetworkPlayer* networkPlayer = player->connection->getNetworkPlayer(); INetworkPlayer* networkPlayer = player->connection->getNetworkPlayer();
bool isOp = bool isOp = cheatsEnabled &&
cheatsEnabled && (player->isModerator() || (player->isModerator() ||
(networkPlayer != nullptr && networkPlayer->IsHost())); (networkPlayer != nullptr && networkPlayer->IsHost()));
return isOp; return isOp;
} }
@ -1345,8 +1343,8 @@ void PlayerList::saveAll(ProgressListener* progressListener,
bool bDeleteGuestMaps /*= false*/) { bool bDeleteGuestMaps /*= false*/) {
if (progressListener != nullptr) if (progressListener != nullptr)
progressListener->progressStart(IDS_PROGRESS_SAVING_PLAYERS); progressListener->progressStart(IDS_PROGRESS_SAVING_PLAYERS);
// 4J - playerIo can be nullptr if we have have to exit a game really early on // 4J - playerIo can be nullptr if we have have to exit a game really early
// due to network failure // on due to network failure
if (playerIo) { if (playerIo) {
playerIo->saveAllCachedData(); playerIo->saveAllCachedData();
for (unsigned int i = 0; i < players.size(); i++) { for (unsigned int i = 0; i < players.size(); i++) {
@ -1489,7 +1487,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
bool playerRemoved = false; bool playerRemoved = false;
auto it = find(receiveAllPlayers[dimIndex].begin(), auto it = find(receiveAllPlayers[dimIndex].begin(),
receiveAllPlayers[dimIndex].end(), player); receiveAllPlayers[dimIndex].end(), player);
if (it != receiveAllPlayers[dimIndex].end()) { if (it != receiveAllPlayers[dimIndex].end()) {
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
app.DebugPrintf( app.DebugPrintf(
@ -1509,7 +1507,8 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
newPlayer->connection->getNetworkPlayer(); newPlayer->connection->getNetworkPlayer();
if (newPlayer != player && newPlayer->dimension == playerDim && if (newPlayer != player && newPlayer->dimension == playerDim &&
otherPlayer != nullptr && otherPlayer->IsSameSystem(thisPlayer)) { otherPlayer != nullptr &&
otherPlayer->IsSameSystem(thisPlayer)) {
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
app.DebugPrintf( app.DebugPrintf(
"Remove: Adding player %ls as primary in dimension %d\n", "Remove: Adding player %ls as primary in dimension %d\n",
@ -1522,7 +1521,8 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
} else if (thisPlayer == nullptr) { } else if (thisPlayer == nullptr) {
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
app.DebugPrintf( app.DebugPrintf(
"Remove: Qnet player for %ls was nullptr so re-checking all players\n", "Remove: Qnet player for %ls was nullptr so re-checking all "
"players\n",
player->name.c_str()); player->name.c_str());
#endif #endif
// 4J Stu - Something went wrong, or possibly the QNet player left // 4J Stu - Something went wrong, or possibly the QNet player left

View file

@ -46,7 +46,7 @@ ServerChunkCache::ServerChunkCache(ServerLevel* level, ChunkStorage* storage,
ServerChunkCache::~ServerChunkCache() { ServerChunkCache::~ServerChunkCache() {
storage->WaitForAll(); // MGH - added to fix crash bug 175183 storage->WaitForAll(); // MGH - added to fix crash bug 175183
delete emptyChunk; delete emptyChunk;
delete[] cache; // 4jcraft changed to delete[] delete[] cache; // 4jcraft changed to delete[]
delete source; delete source;
#if defined(_LARGE_WORLDS) #if defined(_LARGE_WORLDS)
@ -166,8 +166,8 @@ LevelChunk* ServerChunkCache::create(
(int64_t*)&cache[idx], (int64_t)chunk, (int64_t)lastChunk) == (int64_t*)&cache[idx], (int64_t)chunk, (int64_t)lastChunk) ==
(int64_t)lastChunk) (int64_t)lastChunk)
#else #else
if (InterlockedCompareExchangeRelease((int32_t*)&cache[idx], (int32_t)chunk, if (InterlockedCompareExchangeRelease(
(int32_t)lastChunk) == (int32_t*)&cache[idx], (int32_t)chunk, (int32_t)lastChunk) ==
(int32_t)lastChunk) (int32_t)lastChunk)
#endif #endif
{ {
@ -715,8 +715,8 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) {
} }
} }
} else { } else {
// 4J Stu - We have multiple for threads for all saving as part of the // 4J Stu - We have multiple for threads for all saving as part of the
// storage, so use that rather than new threads here // storage, so use that rather than new threads here
// Created a roughly sorted list to match the order that the files were // Created a roughly sorted list to match the order that the files were
// created in McRegionChunkStorage::McRegionChunkStorage. This is to // created in McRegionChunkStorage::McRegionChunkStorage. This is to
@ -814,7 +814,7 @@ bool ServerChunkCache::tick() {
// loadedChunks.remove(cp); // loadedChunks.remove(cp);
// loadedChunkList.remove(chunk); // loadedChunkList.remove(chunk);
auto it = find(m_loadedChunkList.begin(), auto it = find(m_loadedChunkList.begin(),
m_loadedChunkList.end(), chunk); m_loadedChunkList.end(), chunk);
if (it != m_loadedChunkList.end()) if (it != m_loadedChunkList.end())
m_loadedChunkList.erase(it); m_loadedChunkList.erase(it);

View file

@ -57,8 +57,8 @@ void ServerCommandDispatcher::logAdminCommand(
int customData, const std::wstring& additionalMessage) { int customData, const std::wstring& additionalMessage) {
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers(); PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
// for (Player player : MinecraftServer.getInstance().getPlayers().players) // for (Player player : MinecraftServer.getInstance().getPlayers().players)
for (auto it = playerList->players.begin(); for (auto it = playerList->players.begin(); it != playerList->players.end();
it != playerList->players.end(); ++it) { ++it) {
std::shared_ptr<ServerPlayer> player = *it; std::shared_ptr<ServerPlayer> player = *it;
if (player != source && playerList->isOp(player)) { if (player != source && playerList->isOp(player)) {
// TODO: Change chat packet to be able to send more bits of data // TODO: Change chat packet to be able to send more bits of data

View file

@ -103,7 +103,7 @@ void ServerConnection::tick() {
bool ServerConnection::addPendingTextureRequest( bool ServerConnection::addPendingTextureRequest(
const std::wstring& textureName) { const std::wstring& textureName) {
auto it = find(m_pendingTextureRequests.begin(), auto it = find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName); m_pendingTextureRequests.end(), textureName);
if (it == m_pendingTextureRequests.end()) { if (it == m_pendingTextureRequests.end()) {
m_pendingTextureRequests.push_back(textureName); m_pendingTextureRequests.push_back(textureName);
return true; return true;
@ -120,7 +120,7 @@ bool ServerConnection::addPendingTextureRequest(
void ServerConnection::handleTextureReceived(const std::wstring& textureName) { void ServerConnection::handleTextureReceived(const std::wstring& textureName) {
auto it = find(m_pendingTextureRequests.begin(), auto it = find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName); m_pendingTextureRequests.end(), textureName);
if (it != m_pendingTextureRequests.end()) { if (it != m_pendingTextureRequests.end()) {
m_pendingTextureRequests.erase(it); m_pendingTextureRequests.erase(it);
} }
@ -135,7 +135,7 @@ void ServerConnection::handleTextureReceived(const std::wstring& textureName) {
void ServerConnection::handleTextureAndGeometryReceived( void ServerConnection::handleTextureAndGeometryReceived(
const std::wstring& textureName) { const std::wstring& textureName) {
auto it = find(m_pendingTextureRequests.begin(), auto it = find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName); m_pendingTextureRequests.end(), textureName);
if (it != m_pendingTextureRequests.end()) { if (it != m_pendingTextureRequests.end()) {
m_pendingTextureRequests.erase(it); m_pendingTextureRequests.erase(it);
} }

View file

@ -658,8 +658,6 @@ enum EControllerActions {
ACTION_MENU_OTHER_STICK_RIGHT, ACTION_MENU_OTHER_STICK_RIGHT,
ACTION_MENU_PAUSEMENU, ACTION_MENU_PAUSEMENU,
ACTION_MENU_OK, ACTION_MENU_OK,
ACTION_MENU_CANCEL, ACTION_MENU_CANCEL,
// 4jcraft added, off by one // 4jcraft added, off by one

View file

@ -87,5 +87,3 @@ private:
bool m_bIsPlayingEndMusic; bool m_bIsPlayingEndMusic;
bool m_bIsPlayingNetherMusic; bool m_bIsPlayingNetherMusic;
}; };

View file

@ -794,7 +794,6 @@ void SoundEngine::init(Options* pOptions) {
} }
app.DebugPrintf("---SoundEngine::init - driver opened\n"); app.DebugPrintf("---SoundEngine::init - driver opened\n");
AIL_set_event_error_callback(ErrorCallback); AIL_set_event_error_callback(ErrorCallback);
AIL_set_3D_rolloff_factor(m_hDriver, 1.0); AIL_set_3D_rolloff_factor(m_hDriver, 1.0);
@ -853,14 +852,11 @@ void SoundEngine::init(Options* pOptions) {
m_bSystemMusicPlaying = false; m_bSystemMusicPlaying = false;
m_openStreamThread = nullptr; m_openStreamThread = nullptr;
} }
// AP - moved to a separate function so it can be called from the mixer callback // AP - moved to a separate function so it can be called from the mixer callback
// on Vita // on Vita
void SoundEngine::updateMiles() { void SoundEngine::updateMiles() {
if (m_validListenerCount == 1) { if (m_validListenerCount == 1) {
for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) { for (int i = 0; i < MAX_LOCAL_PLAYERS; i++) {
// set the listener as the first player we find // set the listener as the first player we find
@ -1093,13 +1089,11 @@ static float fVal = 0.0f;
// //
///////////////////////////////////////////// /////////////////////////////////////////////
void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) { void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
#if defined(__DISABLE_MILES__) #if defined(__DISABLE_MILES__)
return; return;
#endif #endif
// update the listener positions // update the listener positions
int listenerCount = 0; int listenerCount = 0;
#if defined(DISTORTION_TEST) #if defined(DISTORTION_TEST)
@ -1175,7 +1169,6 @@ SoundEngine::SoundEngine() {
memset(CurrentSoundsPlaying, 0, sizeof(int) * (eSoundType_MAX + eSFX_MAX)); memset(CurrentSoundsPlaying, 0, sizeof(int) * (eSoundType_MAX + eSFX_MAX));
memset(m_ListenerA, 0, sizeof(AUDIO_LISTENER) * XUSER_MAX_COUNT); memset(m_ListenerA, 0, sizeof(AUDIO_LISTENER) * XUSER_MAX_COUNT);
} }
void SoundEngine::destroy() {} void SoundEngine::destroy() {}
@ -1389,7 +1382,7 @@ int SoundEngine::OpenStreamThreadProc(void* lpParameter) {
// //
///////////////////////////////////////////// /////////////////////////////////////////////
void SoundEngine::playMusicTick() { void SoundEngine::playMusicTick() {
// AP - vita will update the music during the mixer callback // AP - vita will update the music during the mixer callback
playMusicUpdate(); playMusicUpdate();
} }
@ -1487,7 +1480,6 @@ void SoundEngine::playMusicUpdate() {
} }
strcat((char*)m_szStreamName, m_szStreamFileA[m_musicID]); strcat((char*)m_szStreamName, m_szStreamFileA[m_musicID]);
strcat((char*)m_szStreamName, ".binka"); strcat((char*)m_szStreamName, ".binka");
} }
// std::wstring name = // std::wstring name =

View file

@ -170,5 +170,4 @@ private:
int m_iStream_End_Min, m_iStream_End_Max; int m_iStream_End_Min, m_iStream_End_Max;
int m_iStream_CD_1; int m_iStream_CD_1;
bool* m_bHeardTrackA; bool* m_bHeardTrackA;
}; };

View file

@ -3,64 +3,64 @@
#include "Consoles_SoundEngine.h" #include "Consoles_SoundEngine.h"
const wchar_t* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = { const wchar_t* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
L"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT L"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
L"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT L"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
L"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP L"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
L"mob/cow/say", // eSoundType_MOB_COW_AMBIENT L"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
L"mob/cow/hurt", // eSoundType_MOB_COW_HURT L"mob/cow/hurt", // eSoundType_MOB_COW_HURT
L"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT L"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
L"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH L"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
L"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT L"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
L"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL L"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
L"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE L"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
L"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING L"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
L"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK L"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
L"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT L"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
L"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH L"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
L"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE L"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
L"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE L"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
L"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT L"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
L"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH L"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
L"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN L"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
L"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM L"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
L"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH L"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
L"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL L"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
L"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE L"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
L"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE L"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
L"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT L"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
L"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH L"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
L"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL L"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
L"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT L"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
L"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT L"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
L"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH L"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
L"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY L"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
L"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT, L"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
L"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT L"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
L"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH, L"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
L"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP, L"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
L"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT, L"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
L"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT, L"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
L"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT, L"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
L"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH, L"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
L"mob/slime/slime", // eSoundType_MOB_SLIME, L"mob/slime/slime", // eSoundType_MOB_SLIME,
L"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK, L"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
L"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT, L"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
L"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH, L"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
L"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT, L"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
L"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT, L"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
L"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH, L"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
L"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD, L"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
L"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK, L"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
L"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL, L"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
L"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG, L"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
L"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL, L"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
L"mob/cat/purr", // eSoundType_MOB_CAT_PURR L"mob/cat/purr", // eSoundType_MOB_CAT_PURR
L"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW L"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
L"mob/cat/meow", // eSoundType_MOB_CAT_MEOW L"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
// 4J-PB - correct the name of the event for hitting ocelots // 4J-PB - correct the name of the event for hitting ocelots
L"mob/cat/hitt", // eSoundType_MOB_CAT_HITT L"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
// L"mob.irongolem.throw", // // L"mob.irongolem.throw", //
//eSoundType_MOB_IRONGOLEM_THROW L"mob.irongolem.hit", // eSoundType_MOB_IRONGOLEM_THROW L"mob.irongolem.hit",
//// eSoundType_MOB_IRONGOLEM_HIT L"mob.irongolem.death", //// eSoundType_MOB_IRONGOLEM_HIT L"mob.irongolem.death",
//// eSoundType_MOB_IRONGOLEM_DEATH L"mob.irongolem.walk", //// eSoundType_MOB_IRONGOLEM_DEATH L"mob.irongolem.walk",
//// eSoundType_MOB_IRONGOLEM_WALK //// eSoundType_MOB_IRONGOLEM_WALK
@ -85,14 +85,14 @@ const wchar_t* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
L"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN, L"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
L"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER, L"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
L"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!! L"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
L"portal/portal", // eSoundType_PORTAL_PORTAL, L"portal/portal", // eSoundType_PORTAL_PORTAL,
// 4J-PB - added a couple that were still using std::wstring // 4J-PB - added a couple that were still using std::wstring
L"portal/trigger", // eSoundType_PORTAL_TRIGGER L"portal/trigger", // eSoundType_PORTAL_TRIGGER
L"portal/travel", // eSoundType_PORTAL_TRAVEL L"portal/travel", // eSoundType_PORTAL_TRAVEL
L"fire/ignite", // eSoundType_FIRE_IGNITE, L"fire/ignite", // eSoundType_FIRE_IGNITE,
L"fire/fire", // eSoundType_FIRE_FIRE, L"fire/fire", // eSoundType_FIRE_FIRE,
L"damage/hit", // eSoundType_DAMAGE_HURT, L"damage/hit", // eSoundType_DAMAGE_HURT,
L"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL, L"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
L"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG, L"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
L"note/harp", // eSoundType_NOTE_HARP, L"note/harp", // eSoundType_NOTE_HARP,

View file

@ -1,34 +1,38 @@
#pragma once #pragma once
#define VER_PRODUCTMAJORVERSION 0
#define VER_PRODUCTMAJORVERSION 0 #define VER_PRODUCTMINORVERSION 0
#define VER_PRODUCTMINORVERSION 0
// This goes up with each build // This goes up with each build
// 4J-JEV: This value is extracted with a regex so it can be placed as the version in the AppX manifest on Durango. // 4J-JEV: This value is extracted with a regex so it can be placed as the
#define VER_PRODUCTBUILD 560 // version in the AppX manifest on Durango.
#define VER_PRODUCTBUILD 560
// This goes up if there is any change to network traffic or code in a build // This goes up if there is any change to network traffic or code in a build
#define VER_NETWORK 560 #define VER_NETWORK 560
#define VER_PRODUCTBUILD_QFE 0 #define VER_PRODUCTBUILD_QFE 0
#define VER_FILEVERSION_STRING "1.6" #define VER_FILEVERSION_STRING "1.6"
#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING #define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING
#define VER_FILEVERSION_STRING_W L"1.6" #define VER_FILEVERSION_STRING_W L"1.6"
#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W #define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W
#define VER_FILEBETA_STR "" #define VER_FILEBETA_STR ""
#undef VER_FILEVERSION #undef VER_FILEVERSION
#define VER_FILEVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE #define VER_FILEVERSION \
#define VER_PRODUCTVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, \
VER_PRODUCTBUILD_QFE
#define VER_PRODUCTVERSION \
VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, \
VER_PRODUCTBUILD_QFE
#if (VER_PRODUCTBUILD < 10) #if (VER_PRODUCTBUILD < 10)
#define VER_FILEBPAD "000" #define VER_FILEBPAD "000"
#define VER_FILEBPAD_W L"000" #define VER_FILEBPAD_W L"000"
#elif (VER_PRODUCTBUILD < 100) #elif (VER_PRODUCTBUILD < 100)
#define VER_FILEBPAD "00" #define VER_FILEBPAD "00"
#define VER_FILEBPAD_W L"00" #define VER_FILEBPAD_W L"00"
#elif (VER_PRODUCTBUILD < 1000) #elif (VER_PRODUCTBUILD < 1000)
#define VER_FILEBPAD "0" #define VER_FILEBPAD "0"
#define VER_FILEBPAD_W L"0" #define VER_FILEBPAD_W L"0"
#else #else
#define VER_FILEBPAD #define VER_FILEBPAD
@ -37,21 +41,25 @@
#define VER_WIDE_PREFIX(x) L##x #define VER_WIDE_PREFIX(x) L##x
#define VER_FILEVERSION_STR2(x,y) VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y #define VER_FILEVERSION_STR2(x, y) \
#define VER_FILEVERSION_STR2_W(x,y) VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX(#x) L"." VER_WIDE_PREFIX(#y) VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y
#define VER_FILEVERSION_STR1(x,y) VER_FILEVERSION_STR2(x, y) #define VER_FILEVERSION_STR2_W(x, y) \
#define VER_FILEVERSION_STR1_W(x,y) VER_FILEVERSION_STR2_W(x, y) VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX( \
#x) L"." VER_WIDE_PREFIX(#y)
#define VER_FILEVERSION_STR1(x, y) VER_FILEVERSION_STR2(x, y)
#define VER_FILEVERSION_STR1_W(x, y) VER_FILEVERSION_STR2_W(x, y)
#undef VER_FILEVERSION_STR #undef VER_FILEVERSION_STR
#define VER_FILEVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) #define VER_FILEVERSION_STR \
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_PRODUCTVERSION_STR \
VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_FILEVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) #define VER_FILEVERSION_STR_W \
#define VER_PRODUCTVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE) VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_PRODUCTVERSION_STR_W \
VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#if (VER_PRODUCTBUILD_QFE >= 256) #if (VER_PRODUCTBUILD_QFE >= 256)
#error "QFE number cannot exceed 255" #error "QFE number cannot exceed 255"
#endif #endif

View file

@ -1,176 +1,147 @@
#pragma once #pragma once
#include <stdlib.h> #include <stdlib.h>
class C4JMemoryPool class C4JMemoryPool {
{
public: public:
unsigned int Align(unsigned int val, unsigned int align) { return int((val+(align-1))/align) * align; } unsigned int Align(unsigned int val, unsigned int align) {
virtual void* Alloc(size_t size) = 0; return int((val + (align - 1)) / align) * align;
virtual void Free(void* ptr) = 0; }
virtual void* Alloc(size_t size) = 0;
virtual void Free(void* ptr) = 0;
}; };
// Fast Efficient Fixed-Size Memory Pool : No Loops and No Overhead // Fast Efficient Fixed-Size Memory Pool : No Loops and No Overhead
// http://www.alogicalmind.com/memory_pools/index.htm // http://www.alogicalmind.com/memory_pools/index.htm
class C4JMemoryPoolFixed : public C4JMemoryPool class C4JMemoryPoolFixed : public C4JMemoryPool {
{ // Basic type define
// Basic type define typedef unsigned int uint;
typedef unsigned int uint; typedef unsigned char uchar;
typedef unsigned char uchar; uint m_numOfBlocks; // Num of blocks
uint m_numOfBlocks; // Num of blocks uint m_sizeOfEachBlock; // Size of each block
uint m_sizeOfEachBlock; // Size of each block uint m_numFreeBlocks; // Num of remaining blocks
uint m_numFreeBlocks; // Num of remaining blocks uint m_numInitialized; // Num of initialized blocks
uint m_numInitialized; // Num of initialized blocks uchar* m_memStart; // Beginning of memory pool
uchar* m_memStart; // Beginning of memory pool uchar* m_memEnd; // End of memory pool
uchar* m_memEnd; // End of memory pool uchar* m_next; // Num of next free block
uchar* m_next; // Num of next free block // CRITICAL_SECTION m_CS;
// CRITICAL_SECTION m_CS;
public: public:
C4JMemoryPoolFixed() C4JMemoryPoolFixed() {
{ m_numOfBlocks = 0;
m_numOfBlocks = 0; m_sizeOfEachBlock = 0;
m_sizeOfEachBlock = 0; m_numFreeBlocks = 0;
m_numFreeBlocks = 0; m_numInitialized = 0;
m_numInitialized = 0; m_memStart = nullptr;
m_memStart = nullptr; m_memEnd = nullptr;
m_memEnd = nullptr; m_next = 0;
m_next = 0; }
}
C4JMemoryPoolFixed(uint sizeOfEachBlock, uint numOfBlocks) C4JMemoryPoolFixed(uint sizeOfEachBlock, uint numOfBlocks) {
{ CreatePool(sizeOfEachBlock, numOfBlocks);
CreatePool(sizeOfEachBlock, numOfBlocks); }
}
~C4JMemoryPoolFixed() { DestroyPool(); } ~C4JMemoryPoolFixed() { DestroyPool(); }
void CreatePool(uint sizeOfEachBlock, uint numOfBlocks) void CreatePool(uint sizeOfEachBlock, uint numOfBlocks) {
{ assert(sizeOfEachBlock >=
assert(sizeOfEachBlock >= 4); // has to be at least the size of an int, for book keeping 4); // has to be at least the size of an int, for book keeping
m_numOfBlocks = numOfBlocks; m_numOfBlocks = numOfBlocks;
m_sizeOfEachBlock = sizeOfEachBlock; m_sizeOfEachBlock = sizeOfEachBlock;
m_numFreeBlocks = numOfBlocks; m_numFreeBlocks = numOfBlocks;
m_numInitialized = 0; m_numInitialized = 0;
m_memStart = new uchar[ m_sizeOfEachBlock * m_memStart = new uchar[m_sizeOfEachBlock * m_numOfBlocks];
m_numOfBlocks ]; m_memEnd = m_memStart + (m_sizeOfEachBlock * m_numOfBlocks);
m_memEnd = m_memStart + (m_sizeOfEachBlock * m_numOfBlocks); m_next = m_memStart;
m_next = m_memStart; // InitializeCriticalSection(&m_CS);
// InitializeCriticalSection(&m_CS); }
}
void DestroyPool() void DestroyPool() {
{ delete[] m_memStart;
delete[] m_memStart; m_memStart = nullptr;
m_memStart = nullptr; }
}
uchar* AddrFromIndex(uint i) const uchar* AddrFromIndex(uint i) const {
{ return m_memStart + (i * m_sizeOfEachBlock);
return m_memStart + ( i * m_sizeOfEachBlock ); }
}
uint IndexFromAddr(const uchar* p) const uint IndexFromAddr(const uchar* p) const {
{ return (((uint)(p - m_memStart)) / m_sizeOfEachBlock);
return (((uint)(p - m_memStart)) / m_sizeOfEachBlock); }
}
virtual void* Alloc(size_t size) virtual void* Alloc(size_t size) {
{ if (size > m_sizeOfEachBlock) return ::malloc(size);
if(size > m_sizeOfEachBlock) // EnterCriticalSection(&m_CS);
return ::malloc(size); if (m_numInitialized < m_numOfBlocks) {
// EnterCriticalSection(&m_CS); uint* p = (uint*)AddrFromIndex(m_numInitialized);
if (m_numInitialized < m_numOfBlocks ) *p = m_numInitialized + 1;
{ m_numInitialized++;
uint* p = (uint*)AddrFromIndex( m_numInitialized ); }
*p = m_numInitialized + 1; void* ret = nullptr;
m_numInitialized++; if (m_numFreeBlocks > 0) {
} ret = (void*)m_next;
void* ret = nullptr; --m_numFreeBlocks;
if ( m_numFreeBlocks > 0 ) if (m_numFreeBlocks != 0) {
{ m_next = AddrFromIndex(*((uint*)m_next));
ret = (void*)m_next; } else {
--m_numFreeBlocks; m_next = nullptr;
if (m_numFreeBlocks!=0) }
{ }
m_next = AddrFromIndex( *((uint*)m_next) ); // LeaveCriticalSection(&m_CS);
} return ret;
else }
{
m_next = nullptr;
}
}
// LeaveCriticalSection(&m_CS);
return ret;
}
virtual void Free(void* ptr) virtual void Free(void* ptr) {
{ if (ptr < m_memStart || ptr > m_memEnd) {
if(ptr < m_memStart || ptr > m_memEnd) ::free(ptr);
{ return;
::free(ptr); }
return; // EnterCriticalSection(&m_CS);
} if (m_next != nullptr) {
// EnterCriticalSection(&m_CS); (*(uint*)ptr) = IndexFromAddr(m_next);
if (m_next != nullptr) m_next = (uchar*)ptr;
{ } else {
(*(uint*)ptr) = IndexFromAddr( m_next ); *((uint*)ptr) = m_numOfBlocks;
m_next = (uchar*)ptr; m_next = (uchar*)ptr;
} }
else ++m_numFreeBlocks;
{ // LeaveCriticalSection(&m_CS);
*((uint*)ptr) = m_numOfBlocks; }
m_next = (uchar*)ptr; }; // End pool class
}
++m_numFreeBlocks;
// LeaveCriticalSection(&m_CS);
}
}; // End pool class
// this pool will constantly grow until it is reset (automatically when all
// this pool will constantly grow until it is reset (automatically when all allocs have been "freed") // allocs have been "freed")
class C4JMemoryPoolGrow : public C4JMemoryPool class C4JMemoryPoolGrow : public C4JMemoryPool {
{ uint32_t m_totalSize;
uint32_t m_totalSize; uint32_t m_memUsed;
uint32_t m_memUsed; uint32_t m_numAllocations;
uint32_t m_numAllocations; uint8_t* m_pMemory;
uint8_t* m_pMemory; uint32_t m_currentOffset;
uint32_t m_currentOffset;
public: public:
C4JMemoryPoolGrow(uint32_t size = 64*1024) C4JMemoryPoolGrow(uint32_t size = 64 * 1024) {
{ size = Align(size, 4);
size = Align(size, 4); m_totalSize = size;
m_totalSize = size; m_pMemory = new uint8_t[size];
m_pMemory = new uint8_t[size]; m_currentOffset = 0;
m_currentOffset = 0; m_memUsed = 0;
m_memUsed = 0; m_numAllocations = 0;
m_numAllocations = 0; }
}
virtual void* Alloc(size_t size) virtual void* Alloc(size_t size) {
{ size = Align(size, 4); // 4 byte align the memory
size = Align(size, 4); // 4 byte align the memory assert((m_currentOffset + size) <
assert((m_currentOffset + size) < m_totalSize); // make sure we haven't ran out of space m_totalSize); // make sure we haven't ran out of space
void* returnMem = &m_pMemory[m_currentOffset]; // grab the return memory void* returnMem =
m_currentOffset += size; &m_pMemory[m_currentOffset]; // grab the return memory
m_numAllocations++; m_currentOffset += size;
return returnMem; m_numAllocations++;
} return returnMem;
virtual void Free(void* ptr) }
{ virtual void Free(void* ptr) {
m_numAllocations--; m_numAllocations--;
if(m_numAllocations == 0) if (m_numAllocations == 0)
m_currentOffset = 0; // reset the pool when we reach zero allocations m_currentOffset =
} 0; // reset the pool when we reach zero allocations
}
}; };

View file

@ -3,111 +3,85 @@
#pragma once #pragma once
#include "C4JMemoryPool.h" #include "C4JMemoryPool.h"
// Custom allocator, takes a C4JMemoryPool class, which can be one of a number of pool implementations. // Custom allocator, takes a C4JMemoryPool class, which can be one of a number
// of pool implementations.
template <class T> template <class T>
class C4JPoolAllocator class C4JPoolAllocator {
{
public: public:
typedef T value_type; typedef T value_type;
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
typedef T* pointer; typedef T* pointer;
typedef const T* const_pointer; typedef const T* const_pointer;
typedef T& reference; typedef T& reference;
typedef const T& const_reference; typedef const T& const_reference;
//! A struct to construct an allocator for a different type. //! A struct to construct an allocator for a different type.
template<typename U> template <typename U>
struct rebind { typedef C4JPoolAllocator<U> other; }; struct rebind {
typedef C4JPoolAllocator<U> other;
};
C4JMemoryPool* m_pPool;
bool m_selfAllocated;
C4JMemoryPool* m_pPool; C4JPoolAllocator(C4JMemoryPool* pool = new C4JMemoryPoolFixed(32, 4096))
bool m_selfAllocated; : m_pPool(pool), m_selfAllocated(true) {
printf("allocated mempool\n");
C4JPoolAllocator( C4JMemoryPool* pool = new C4JMemoryPoolFixed(32, 4096 )) : m_pPool( pool ), m_selfAllocated(true)
{
printf("allocated mempool\n");
}
template<typename U>
C4JPoolAllocator(C4JPoolAllocator<U> const& obj) : m_pPool( obj.m_pPool ), m_selfAllocated(false) // copy constructor
{
printf("C4JPoolAllocator constructed from 0x%08x\n", &obj);
assert(obj.m_pPool);
} }
template <typename U>
C4JPoolAllocator(C4JPoolAllocator<U> const& obj)
: m_pPool(obj.m_pPool),
m_selfAllocated(false) // copy constructor
{
printf("C4JPoolAllocator constructed from 0x%08x\n", &obj);
assert(obj.m_pPool);
}
private: private:
public: public:
~C4JPoolAllocator() {
~C4JPoolAllocator() if (m_selfAllocated) delete m_pPool;
{
if(m_selfAllocated)
delete m_pPool;
} }
pointer address( reference r ) const { return &r; } pointer address(reference r) const { return &r; }
const_pointer address( const_reference r ) const { return &r; } const_pointer address(const_reference r) const { return &r; }
pointer allocate( size_type n, const void* /*hint*/=0 ) pointer allocate(size_type n, const void* /*hint*/ = 0) {
{ assert(m_pPool);
assert(m_pPool);
return (pointer)m_pPool->Alloc(n * sizeof(T)); return (pointer)m_pPool->Alloc(n * sizeof(T));
} }
void deallocate( pointer p, size_type /*n*/ ) void deallocate(pointer p, size_type /*n*/) {
{ assert(m_pPool);
assert(m_pPool); m_pPool->Free(p);
m_pPool->Free(p);
} }
void construct( pointer p, const T& val ) void construct(pointer p, const T& val) { new (p) T(val); }
{
new (p) T(val);
}
void destroy( pointer p ) void destroy(pointer p) { p->~T(); }
{
p->~T();
}
size_type max_size() const
{
return ULONG_MAX / sizeof(T);
}
size_type max_size() const { return ULONG_MAX / sizeof(T); }
}; };
template <class T> template <class T>
bool bool operator==(const C4JPoolAllocator<T>& left,
operator==( const C4JPoolAllocator<T>& left, const C4JPoolAllocator<T>& right ) const C4JPoolAllocator<T>& right) {
{ if (left.m_pPool == right.m_pPool) {
if (left.m_pPool == right.m_pPool)
{
return true; return true;
} }
return false;
}
template <class T>
bool
operator!=( const C4JPoolAllocator<T>& left, const C4JPoolAllocator<T>& right)
{
if (left.m_pPool != right.m_pPool)
{
return true;
}
return false; return false;
} }
template <class T>
bool operator!=(const C4JPoolAllocator<T>& left,
const C4JPoolAllocator<T>& right) {
if (left.m_pPool != right.m_pPool) {
return true;
}
return false;
}

View file

@ -1,24 +1,24 @@
#pragma once #pragma once
#include <cstdint> #include <cstdint>
class ColourTable class ColourTable {
{
private: private:
unsigned int m_colourValues[eMinecraftColour_COUNT]; unsigned int m_colourValues[eMinecraftColour_COUNT];
static const wchar_t *ColourTableElements[eMinecraftColour_COUNT]; static const wchar_t* ColourTableElements[eMinecraftColour_COUNT];
static std::unordered_map<std::wstring,eMinecraftColour> s_colourNamesMap; static std::unordered_map<std::wstring, eMinecraftColour> s_colourNamesMap;
public: public:
static void staticCtor(); static void staticCtor();
ColourTable(std::uint8_t *pbData, std::uint32_t dataLength); ColourTable(std::uint8_t* pbData, std::uint32_t dataLength);
ColourTable(ColourTable *defaultColours, 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 getColour(eMinecraftColour id);
unsigned int getColor(eMinecraftColour id) { return getColour(id); } unsigned int getColor(eMinecraftColour id) { return getColour(id); }
void loadColoursFromData(std::uint8_t *pbData, std::uint32_t dataLength); void loadColoursFromData(std::uint8_t* pbData, std::uint32_t dataLength);
void setColour(const std::wstring &colourName, int value); void setColour(const std::wstring& colourName, int value);
void setColour(const std::wstring &colourName, const std::wstring &value); void setColour(const std::wstring& colourName, const std::wstring& value);
}; };

View file

@ -2,8 +2,8 @@
#include "ConsoleGameMode.h" #include "ConsoleGameMode.h"
#include "Tutorial/Tutorial.h" #include "Tutorial/Tutorial.h"
ConsoleGameMode::ConsoleGameMode(int iPad, Minecraft *minecraft, ClientConnection *connection) ConsoleGameMode::ConsoleGameMode(int iPad, Minecraft* minecraft,
: TutorialMode(iPad, minecraft, connection) ClientConnection* connection)
{ : TutorialMode(iPad, minecraft, connection) {
tutorial = new Tutorial(iPad); tutorial = new Tutorial(iPad);
} }

View file

@ -1,10 +1,10 @@
#pragma once #pragma once
#include "Tutorial/TutorialMode.h" #include "Tutorial/TutorialMode.h"
class ConsoleGameMode : public TutorialMode class ConsoleGameMode : public TutorialMode {
{
public: public:
ConsoleGameMode(int iPad, Minecraft *minecraft, ClientConnection *connection); ConsoleGameMode(int iPad, Minecraft* minecraft,
ClientConnection* connection);
virtual bool isImplemented() { return true; } virtual bool isImplemented() { return true; }
}; };

View file

@ -1,70 +1,69 @@
#pragma once #pragma once
enum eAward enum eAward {
{ eAward_TakingInventory = 0,
eAward_TakingInventory=0, eAward_GettingWood,
eAward_GettingWood, eAward_Benchmarking,
eAward_Benchmarking, eAward_TimeToMine,
eAward_TimeToMine, eAward_HotTopic,
eAward_HotTopic, eAward_AquireHardware,
eAward_AquireHardware, eAward_TimeToFarm,
eAward_TimeToFarm, eAward_BakeBread,
eAward_BakeBread, eAward_TheLie,
eAward_TheLie, eAward_GettingAnUpgrade,
eAward_GettingAnUpgrade, eAward_DeliciousFish,
eAward_DeliciousFish, eAward_OnARail,
eAward_OnARail, eAward_TimeToStrike,
eAward_TimeToStrike, eAward_MonsterHunter,
eAward_MonsterHunter, eAward_CowTipper,
eAward_CowTipper, eAward_WhenPigsFly,
eAward_WhenPigsFly, eAward_LeaderOfThePack,
eAward_LeaderOfThePack, eAward_MOARTools,
eAward_MOARTools, eAward_DispenseWithThis,
eAward_DispenseWithThis, eAward_InToTheNether,
eAward_InToTheNether,
eAward_mine100Blocks, eAward_mine100Blocks,
eAward_kill10Creepers, eAward_kill10Creepers,
eAward_eatPorkChop, eAward_eatPorkChop,
eAward_play100Days, eAward_play100Days,
eAward_arrowKillCreeper, eAward_arrowKillCreeper,
eAward_socialPost, eAward_socialPost,
// 4J Stu - Does not map to any Xbox achievements // 4J Stu - Does not map to any Xbox achievements
eAward_snipeSkeleton, eAward_snipeSkeleton,
eAward_diamonds, eAward_diamonds,
eAward_portal, eAward_portal,
eAward_ghast, eAward_ghast,
eAward_blazeRod, eAward_blazeRod,
eAward_potion, eAward_potion,
eAward_theEnd, eAward_theEnd,
eAward_winGame, eAward_winGame,
eAward_enchantments, eAward_enchantments,
eAward_overkill, eAward_overkill,
eAward_bookcase, eAward_bookcase,
#if defined(_EXTENDED_ACHIEVEMENTS) #if defined(_EXTENDED_ACHIEVEMENTS)
eAward_adventuringTime, eAward_adventuringTime,
eAward_repopulation, eAward_repopulation,
//eAward_porkChop, // eAward_porkChop,
eAward_diamondsToYou, eAward_diamondsToYou,
//eAward_passingTheTime, // eAward_passingTheTime,
//eAward_archer, // eAward_archer,
eAward_theHaggler, eAward_theHaggler,
eAward_potPlanter, eAward_potPlanter,
eAward_itsASign, eAward_itsASign,
eAward_ironBelly, eAward_ironBelly,
eAward_haveAShearfulDay, eAward_haveAShearfulDay,
eAward_rainbowCollection, eAward_rainbowCollection,
eAward_stayinFrosty, eAward_stayinFrosty,
eAward_chestfulOfCobblestone, eAward_chestfulOfCobblestone,
eAward_renewableEnergy, eAward_renewableEnergy,
eAward_musicToMyEars, eAward_musicToMyEars,
eAward_bodyGuard, eAward_bodyGuard,
eAward_ironMan, eAward_ironMan,
eAward_zombieDoctor, eAward_zombieDoctor,
eAward_lionTamer, eAward_lionTamer,
#endif #endif
eAward_Max, eAward_Max,
}; };

View file

@ -7,17 +7,16 @@
// Desc: Internal helper function // Desc: Internal helper function
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
static void DebugSpewV(const char* strFormat, va_list pArgList) static void DebugSpewV(const char* strFormat, va_list pArgList) {
{
#if defined(__linux__) #if defined(__linux__)
assert(0); assert(0);
#else #else
char str[2048]; char str[2048];
// Use the secure CRT to avoid buffer overruns. Specify a count of // Use the secure CRT to avoid buffer overruns. Specify a count of
// _TRUNCATE so that too long strings will be silently truncated // _TRUNCATE so that too long strings will be silently truncated
// rather than triggering an error. // rather than triggering an error.
_vsnprintf_s( str, _TRUNCATE, strFormat, pArgList ); _vsnprintf_s(str, _TRUNCATE, strFormat, pArgList);
OutputDebugStringA( str ); OutputDebugStringA(str);
#endif #endif
} }
#endif #endif
@ -26,12 +25,11 @@ static void DebugSpewV(const char* strFormat, va_list pArgList)
// Name: DebugPrintf() // Name: DebugPrintf()
// Desc: Prints formatted debug spew // Desc: Prints formatted debug spew
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
void CDECL DebugPrintf(const char* strFormat, ...) void CDECL DebugPrintf(const char* strFormat, ...) {
{
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
va_list pArgList; va_list pArgList;
va_start( pArgList, strFormat ); va_start(pArgList, strFormat);
DebugSpewV( strFormat, pArgList ); DebugSpewV(strFormat, pArgList);
va_end( pArgList ); va_end(pArgList);
#endif #endif
} }

View file

@ -71,8 +71,7 @@ const float CMinecraftApp::fSafeZoneY = 36.0f; // 5% of 720
int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] = { int CMinecraftApp::s_iHTMLFontSizesA[eHTMLSize_COUNT] = {
// 20,15,20,24 // 20,15,20,24
20, 13, 20, 26 20, 13, 20, 26};
};
CMinecraftApp::CMinecraftApp() { CMinecraftApp::CMinecraftApp() {
if (GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) { if (GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) {
@ -195,20 +194,17 @@ CMinecraftApp::CMinecraftApp() {
m_bResetNether = false; m_bResetNether = false;
#if defined(_CONTENT_PACAKGE) #if defined(_CONTENT_PACAKGE)
m_bUseDPadForDebug = false; m_bUseDPadForDebug = false;
#else #else
m_bUseDPadForDebug = true; m_bUseDPadForDebug = true;
#endif #endif
for (int i = 0; i < XUSER_MAX_COUNT; i++) { for (int i = 0; i < XUSER_MAX_COUNT; i++) {
m_vBannedListA[i] = new std::vector<PBANNEDLISTDATA>; m_vBannedListA[i] = new std::vector<PBANNEDLISTDATA>;
} }
LocaleAndLanguageInit(); LocaleAndLanguageInit();
} }
void CMinecraftApp::DebugPrintf(const char* szFormat, ...) { void CMinecraftApp::DebugPrintf(const char* szFormat, ...) {
@ -267,9 +263,7 @@ void CMinecraftApp::SetAction(int iPad, eXuiAction action, void* param) {
} }
} }
bool CMinecraftApp::IsAppPaused() { bool CMinecraftApp::IsAppPaused() { return m_bIsAppPaused; }
return m_bIsAppPaused;
}
void CMinecraftApp::SetAppPaused(bool val) { m_bIsAppPaused = val; } void CMinecraftApp::SetAppPaused(bool val) { m_bIsAppPaused = val; }
@ -701,8 +695,7 @@ void CMinecraftApp::InitGameSettings() {
} }
int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings, int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings,
const int iPad) const int iPad) {
{
SetGameSettings(iPad, eGameSetting_MusicVolume, DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad, eGameSetting_MusicVolume, DEFAULT_VOLUME_LEVEL);
SetGameSettings(iPad, eGameSetting_SoundFXVolume, DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad, eGameSetting_SoundFXVolume, DEFAULT_VOLUME_LEVEL);
SetGameSettings(iPad, eGameSetting_Gamma, 50); SetGameSettings(iPad, eGameSetting_Gamma, 50);
@ -796,13 +789,11 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings,
// #endif // #endif
return 0; return 0;
} }
int CMinecraftApp::DefaultOptionsCallback( int CMinecraftApp::DefaultOptionsCallback(
void* pParam, C_4JProfile::PROFILESETTINGS* pSettings, const int iPad) void* pParam, C_4JProfile::PROFILESETTINGS* pSettings, const int iPad) {
{
CMinecraftApp* pApp = (CMinecraftApp*)pParam; CMinecraftApp* pApp = (CMinecraftApp*)pParam;
// flag the default options to be set // flag the default options to be set
@ -819,7 +810,6 @@ int CMinecraftApp::DefaultOptionsCallback(
return 0; return 0;
} }
int CMinecraftApp::OldProfileVersionCallback(void* pParam, int CMinecraftApp::OldProfileVersionCallback(void* pParam,
unsigned char* pucData, unsigned char* pucData,
const unsigned short usVersion, const unsigned short usVersion,
@ -2452,7 +2442,6 @@ void CMinecraftApp::HandleXuiActions(void) {
ProfileManager.GetPrimaryPad()); ProfileManager.GetPrimaryPad());
pMinecraft->removeLocalPlayerIdx(i); pMinecraft->removeLocalPlayerIdx(i);
// Wipe out the tooltips // Wipe out the tooltips
ui.SetTooltips(i, -1); ui.SetTooltips(i, -1);
@ -2500,7 +2489,6 @@ void CMinecraftApp::HandleXuiActions(void) {
} }
} }
SetAction(i, eAppAction_Idle); SetAction(i, eAppAction_Idle);
} }
break; break;
@ -2519,7 +2507,6 @@ void CMinecraftApp::HandleXuiActions(void) {
ProfileManager.GetPrimaryPad()); ProfileManager.GetPrimaryPad());
pMinecraft->removeLocalPlayerIdx(i); pMinecraft->removeLocalPlayerIdx(i);
// Wipe out the tooltips // Wipe out the tooltips
ui.SetTooltips(i, -1); ui.SetTooltips(i, -1);
@ -2566,7 +2553,6 @@ void CMinecraftApp::HandleXuiActions(void) {
SetAction(i, eAppAction_Idle); SetAction(i, eAppAction_Idle);
} break; } break;
case eAppAction_ExitWorld: case eAppAction_ExitWorld:
pMinecraft->exitingWorldRightNow = true; pMinecraft->exitingWorldRightNow = true;
@ -2679,7 +2665,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// 4J Stu - Fix for #12368 - Crash: Game crashes when saving // 4J Stu - Fix for #12368 - Crash: Game crashes when saving
// then exiting and selecting to save // then exiting and selecting to save
for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) {
// 4J Stu - Fix for #13257 - CRASH: Gameplay: Title // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title
// crashed after exiting the tutorial It doesn't matter // crashed after exiting the tutorial It doesn't matter
// if they were in the tutorial already // if they were in the tutorial already
@ -2700,7 +2685,8 @@ void CMinecraftApp::HandleXuiActions(void) {
// action, use a dialog instead // action, use a dialog instead
completionData->bRequiresUserAction = completionData->bRequiresUserAction =
false; //(param != nullptr) ? true : false; false; //(param != nullptr) ? true : false;
completionData->bShowTips = (param != nullptr) ? false : true; completionData->bShowTips =
(param != nullptr) ? false : true;
completionData->bShowBackground = true; completionData->bShowBackground = true;
completionData->bShowLogo = true; completionData->bShowLogo = true;
completionData->type = completionData->type =
@ -2729,7 +2715,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// 4J Stu - Fix for #12368 - Crash: Game crashes when saving // 4J Stu - Fix for #12368 - Crash: Game crashes when saving
// then exiting and selecting to save // then exiting and selecting to save
for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) {
// 4J Stu - Fix for #13257 - CRASH: Gameplay: Title // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title
// crashed after exiting the tutorial It doesn't matter // crashed after exiting the tutorial It doesn't matter
// if they were in the tutorial already // if they were in the tutorial already
@ -3034,7 +3019,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// saving then exiting and selecting to save // saving then exiting and selecting to save
for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; for (unsigned int idx = 0; idx < XUSER_MAX_COUNT;
++idx) { ++idx) {
// 4J Stu - Fix for #13257 - CRASH: Gameplay: Title // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title
// crashed after exiting the tutorial It doesn't // crashed after exiting the tutorial It doesn't
// matter if they were in the tutorial already // matter if they were in the tutorial already
@ -3131,8 +3115,7 @@ void CMinecraftApp::HandleXuiActions(void) {
&CMinecraftApp:: &CMinecraftApp::
ExitAndJoinFromInviteSaveDialogReturned, ExitAndJoinFromInviteSaveDialogReturned,
this); this);
} else } else {
{
if (!ProfileManager.IsFullVersion()) { if (!ProfileManager.IsFullVersion()) {
TelemetryManager->RecordUpsellPresented( TelemetryManager->RecordUpsellPresented(
i, eSen_UpsellID_Full_Version_Of_Game, i, eSen_UpsellID_Full_Version_Of_Game,
@ -3172,7 +3155,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// 4J Stu - Fix for #12368 - Crash: Game crashes when saving // 4J Stu - Fix for #12368 - Crash: Game crashes when saving
// then exiting and selecting to save // then exiting and selecting to save
for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) { for (unsigned int idx = 0; idx < XUSER_MAX_COUNT; ++idx) {
// 4J Stu - Fix for #13257 - CRASH: Gameplay: Title // 4J Stu - Fix for #13257 - CRASH: Gameplay: Title
// crashed after exiting the tutorial It doesn't matter // crashed after exiting the tutorial It doesn't matter
// if they were in the tutorial already // if they were in the tutorial already
@ -3214,7 +3196,6 @@ void CMinecraftApp::HandleXuiActions(void) {
app.DebugPrintf("Unmount result is %d\n", result); app.DebugPrintf("Unmount result is %d\n", result);
} }
LoadingInputParams* loadingParams = LoadingInputParams* loadingParams =
new LoadingInputParams(); new LoadingInputParams();
loadingParams->func = loadingParams->func =
@ -3259,7 +3240,6 @@ void CMinecraftApp::HandleXuiActions(void) {
ProfileManager.SetLockedProfile(inviteData->dwUserIndex); ProfileManager.SetLockedProfile(inviteData->dwUserIndex);
ProfileManager.SetPrimaryPad(inviteData->dwUserIndex); ProfileManager.SetPrimaryPad(inviteData->dwUserIndex);
// change the minecraft player name // change the minecraft player name
Minecraft::GetInstance()->user->name = Minecraft::GetInstance()->user->name =
convStringToWstring(ProfileManager.GetGamertag( convStringToWstring(ProfileManager.GetGamertag(
@ -3706,7 +3686,6 @@ void CMinecraftApp::loadMediaArchive() {
} }
void CMinecraftApp::loadStringTable() { void CMinecraftApp::loadStringTable() {
if (m_stringTable != nullptr) { if (m_stringTable != nullptr) {
// we need to unload the current std::string table, this is a reload // we need to unload the current std::string table, this is a reload
delete m_stringTable; delete m_stringTable;
@ -4008,7 +3987,6 @@ void CMinecraftApp::ClearSignInChangeUsersMask() {
void CMinecraftApp::SignInChangeCallback(void* pParam, void CMinecraftApp::SignInChangeCallback(void* pParam,
bool bPrimaryPlayerChanged, bool bPrimaryPlayerChanged,
unsigned int uiSignInData) { unsigned int uiSignInData) {
CMinecraftApp* pApp = (CMinecraftApp*)pParam; CMinecraftApp* pApp = (CMinecraftApp*)pParam;
// check if the primary player signed out // check if the primary player signed out
int iPrimaryPlayer = ProfileManager.GetPrimaryPad(); int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
@ -4083,7 +4061,8 @@ void CMinecraftApp::SignInChangeCallback(void* pParam,
// invalidates all the guest players we have in the game // invalidates all the guest players we have in the game
if (hasGuestIdChanged && if (hasGuestIdChanged &&
pApp->m_currentSigninInfo[i].dwGuestNumber != 0 && pApp->m_currentSigninInfo[i].dwGuestNumber != 0 &&
g_NetworkManager.GetLocalPlayerByUserIndex(i) != nullptr) { g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
nullptr) {
pApp->DebugPrintf( pApp->DebugPrintf(
"Recommending removal of player at index %d " "Recommending removal of player at index %d "
"because their guest id changed\n", "because their guest id changed\n",
@ -4153,7 +4132,6 @@ void CMinecraftApp::SignInChangeCallback(void* pParam,
eAppAction_EthernetDisconnected); eAppAction_EthernetDisconnected);
} }
} }
} }
m_uiLastSignInData = uiSignInData; m_uiLastSignInData = uiSignInData;
} else if (iPrimaryPlayer != -1) { } else if (iPrimaryPlayer != -1) {
@ -4392,7 +4370,6 @@ void CMinecraftApp::MountNextDLC(int iPad) {
m_bDLCInstallProcessCompleted = true; m_bDLCInstallProcessCompleted = true;
ui.HandleDLCMountingComplete(); ui.HandleDLCMountingComplete();
} }
} }
@ -4565,7 +4542,7 @@ bool CMinecraftApp::isXuidNotch(PlayerUID xuid) {
bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) { bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid) {
auto it = MojangData.find(xuid); // 4J Stu - The .at and [] accessors auto it = MojangData.find(xuid); // 4J Stu - The .at and [] accessors
// insert elements if they don't exist // insert elements if they don't exist
if (it != MojangData.end()) { if (it != MojangData.end()) {
MOJANG_DATA* pMojangData = MojangData[xuid]; MOJANG_DATA* pMojangData = MojangData[xuid];
if (pMojangData && pMojangData->eXuid == eXUID_Deadmau5) { if (pMojangData && pMojangData->eXuid == eXUID_Deadmau5) {
@ -4815,7 +4792,6 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(
// upsell // upsell
// get the dlc texture pack // get the dlc texture pack
unsigned int uiIDA[2]; unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_CANCEL;
@ -4847,8 +4823,7 @@ int CMinecraftApp::ExitAndJoinFromInviteSaveDialogReturned(
&CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned, &CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned,
pClass); pClass);
return 0; return 0;
} else } else {
{
MinecraftServer::getInstance()->setSaveOnExit(true); MinecraftServer::getInstance()->setSaveOnExit(true);
} }
} else { } else {
@ -4898,7 +4873,6 @@ int CMinecraftApp::ExitAndJoinFromInviteAndSaveReturned(
// upsell // upsell
// get the dlc texture pack // get the dlc texture pack
unsigned int uiIDA[2]; unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_CANCEL;
@ -5251,7 +5225,6 @@ std::wstring CMinecraftApp::FormatHTMLString(
text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}", text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}",
GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_LEFT)); GetActionReplacement(iPad, MINECRAFT_ACTION_DPAD_LEFT));
// Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered // Fix for #8903 - UI: Localization: KOR/JPN/CHT: Button Icons are rendered
// with padding space, which looks no good // with padding space, which looks no good
std::uint32_t dwLanguage = XGetLanguage(); std::uint32_t dwLanguage = XGetLanguage();
@ -5655,8 +5628,7 @@ DLC_INFO* CMinecraftApp::GetDLCInfoTrialOffer(int iIndex) {
return it->second; return it->second;
} }
DLC_INFO* CMinecraftApp::GetDLCInfoFullOffer(int iIndex) { DLC_INFO* CMinecraftApp::GetDLCInfoFullOffer(int iIndex) {
std::unordered_map<uint64_t, DLC_INFO*>::iterator it = std::unordered_map<uint64_t, DLC_INFO*>::iterator it = DLCInfo_Full.begin();
DLCInfo_Full.begin();
for (int i = 0; i < iIndex; i++) { for (int i = 0; i < iIndex; i++) {
++it; ++it;
@ -5665,8 +5637,7 @@ DLC_INFO* CMinecraftApp::GetDLCInfoFullOffer(int iIndex) {
return it->second; return it->second;
} }
uint64_t CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) { uint64_t CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) {
std::unordered_map<int, uint64_t>::iterator it = std::unordered_map<int, uint64_t>::iterator it = DLCTextures_PackID.begin();
DLCTextures_PackID.begin();
for (int i = 0; i < iIndex; i++) { for (int i = 0; i < iIndex; i++) {
++it; ++it;
@ -5675,7 +5646,6 @@ uint64_t CMinecraftApp::GetDLCInfoTexturesFullOffer(int iIndex) {
return it->second; return it->second;
} }
DLC_INFO* CMinecraftApp::GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full) { DLC_INFO* CMinecraftApp::GetDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
if (DLCInfo_Full.size() > 0) { if (DLCInfo_Full.size() > 0) {
auto it = DLCInfo_Full.find(ullOfferID_Full); auto it = DLCInfo_Full.find(ullOfferID_Full);
@ -5802,8 +5772,7 @@ int CMinecraftApp::ExitGameFromRemoteSaveDialogReturned(
UIScene_FullscreenProgress* pScene = UIScene_FullscreenProgress* pScene =
(UIScene_FullscreenProgress*)ui.FindScene( (UIScene_FullscreenProgress*)ui.FindScene(
eUIScene_FullscreenProgress); eUIScene_FullscreenProgress);
if (pScene != nullptr) if (pScene != nullptr) {
{
pScene->SetWasCancelled(false); pScene->SetWasCancelled(false);
} }
} }
@ -5837,7 +5806,6 @@ void CMinecraftApp::InvalidateBannedList(int iPad) {
} }
} }
void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid, void CMinecraftApp::AddLevelToBannedLevelList(int iPad, PlayerUID xuid,
char* pszLevelName, char* pszLevelName,
bool bWriteToTMS) { bool bWriteToTMS) {
@ -5880,8 +5848,7 @@ bool CMinecraftApp::IsInBannedLevelList(int iPad, PlayerUID xuid,
it != m_vBannedListA[iPad]->end(); ++it) { it != m_vBannedListA[iPad]->end(); ++it) {
PBANNEDLISTDATA pData = *it; PBANNEDLISTDATA pData = *it;
if (IsEqualXUID(pData->xuid, xuid) && if (IsEqualXUID(pData->xuid, xuid) &&
(strcmp(pData->pszLevelName, pszLevelName) == 0)) (strcmp(pData->pszLevelName, pszLevelName) == 0)) {
{
return true; return true;
} }
} }
@ -5902,8 +5869,7 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid,
if (pBannedListData != nullptr) { if (pBannedListData != nullptr) {
if (IsEqualXUID(pBannedListData->xuid, xuid) && if (IsEqualXUID(pBannedListData->xuid, xuid) &&
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
{
TelemetryManager->RecordUnBanLevel(iPad); TelemetryManager->RecordUnBanLevel(iPad);
// match found, so remove this entry // match found, so remove this entry
@ -6507,8 +6473,8 @@ unsigned int CMinecraftApp::CreateImageTextData(std::uint8_t* textMetadata,
void CMinecraftApp::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType, void CMinecraftApp::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType,
int x, int z) { int x, int z) {
// check we don't already have this in // check we don't already have this in
for (auto it = m_vTerrainFeatures.begin(); for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
it < m_vTerrainFeatures.end(); ++it) { ++it) {
FEATURE_DATA* pFeatureData = *it; FEATURE_DATA* pFeatureData = *it;
if ((pFeatureData->eTerrainFeature == eFeatureType) && if ((pFeatureData->eTerrainFeature == eFeatureType) &&
@ -6525,8 +6491,8 @@ void CMinecraftApp::AddTerrainFeaturePosition(_eTerrainFeatureType eFeatureType,
} }
_eTerrainFeatureType CMinecraftApp::IsTerrainFeature(int x, int z) { _eTerrainFeatureType CMinecraftApp::IsTerrainFeature(int x, int z) {
for (auto it = m_vTerrainFeatures.begin(); for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
it < m_vTerrainFeatures.end(); ++it) { ++it) {
FEATURE_DATA* pFeatureData = *it; FEATURE_DATA* pFeatureData = *it;
if ((pFeatureData->x == x) && (pFeatureData->z == z)) if ((pFeatureData->x == x) && (pFeatureData->z == z))
@ -6538,8 +6504,8 @@ _eTerrainFeatureType CMinecraftApp::IsTerrainFeature(int x, int z) {
bool CMinecraftApp::GetTerrainFeaturePosition(_eTerrainFeatureType eType, bool CMinecraftApp::GetTerrainFeaturePosition(_eTerrainFeatureType eType,
int* pX, int* pZ) { int* pX, int* pZ) {
for (auto it = m_vTerrainFeatures.begin(); for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
it < m_vTerrainFeatures.end(); ++it) { ++it) {
FEATURE_DATA* pFeatureData = *it; FEATURE_DATA* pFeatureData = *it;
if (pFeatureData->eTerrainFeature == eType) { if (pFeatureData->eTerrainFeature == eType) {
@ -6654,7 +6620,7 @@ std::wstring CMinecraftApp::getEntityName(eINSTANCEOF type) {
std::uint32_t CMinecraftApp::m_dwContentTypeA[e_Marketplace_MAX] = { std::uint32_t CMinecraftApp::m_dwContentTypeA[e_Marketplace_MAX] = {
XMARKETPLACE_OFFERING_TYPE_CONTENT, // e_DLC_SkinPack, e_DLC_TexturePacks, XMARKETPLACE_OFFERING_TYPE_CONTENT, // e_DLC_SkinPack, e_DLC_TexturePacks,
// e_DLC_MashupPacks // e_DLC_MashupPacks
XMARKETPLACE_OFFERING_TYPE_THEME, // e_DLC_Themes XMARKETPLACE_OFFERING_TYPE_THEME, // e_DLC_Themes
XMARKETPLACE_OFFERING_TYPE_AVATARITEM, // e_DLC_AvatarItems XMARKETPLACE_OFFERING_TYPE_AVATARITEM, // e_DLC_AvatarItems
XMARKETPLACE_OFFERING_TYPE_TILE, // e_DLC_Gamerpics XMARKETPLACE_OFFERING_TYPE_TILE, // e_DLC_Gamerpics
}; };
@ -6666,8 +6632,8 @@ unsigned int CMinecraftApp::AddDLCRequest(eDLCMarketplaceType eType,
// If it's already in there, promote it to the top of the list // If it's already in there, promote it to the top of the list
int iPosition = 0; int iPosition = 0;
for (auto it = m_DLCDownloadQueue.begin(); for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
it != m_DLCDownloadQueue.end(); ++it) { ++it) {
DLCRequest* pCurrent = *it; DLCRequest* pCurrent = *it;
if (pCurrent->dwType == m_dwContentTypeA[eType]) { if (pCurrent->dwType == m_dwContentTypeA[eType]) {
@ -6921,8 +6887,8 @@ bool CMinecraftApp::RetrieveNextDLCContent() {
} }
EnterCriticalSection(&csDLCDownloadQueue); EnterCriticalSection(&csDLCDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin(); for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
it != m_DLCDownloadQueue.end(); ++it) { ++it) {
DLCRequest* pCurrent = *it; DLCRequest* pCurrent = *it;
if (pCurrent->eState == e_DLC_ContentState_Retrieving) { if (pCurrent->eState == e_DLC_ContentState_Retrieving) {
@ -6932,8 +6898,8 @@ bool CMinecraftApp::RetrieveNextDLCContent() {
} }
// Now look for the next retrieval // Now look for the next retrieval
for (auto it = m_DLCDownloadQueue.begin(); for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
it != m_DLCDownloadQueue.end(); ++it) { ++it) {
DLCRequest* pCurrent = *it; DLCRequest* pCurrent = *it;
if (pCurrent->eState == e_DLC_ContentState_Idle) { if (pCurrent->eState == e_DLC_ContentState_Idle) {
@ -6965,7 +6931,6 @@ bool CMinecraftApp::RetrieveNextDLCContent() {
int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData, int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData,
C4JStorage::PTMSPP_FILEDATA pFileData, C4JStorage::PTMSPP_FILEDATA pFileData,
const char* szFilename) { const char* szFilename) {
CMinecraftApp* pClass = (CMinecraftApp*)pParam; CMinecraftApp* pClass = (CMinecraftApp*)pParam;
// find the right one in the vector // find the right one in the vector
@ -7013,9 +6978,7 @@ int CMinecraftApp::TMSPPFileReturned(void* pParam, int iPad, int iUserData,
return 0; return 0;
} }
bool CMinecraftApp::RetrieveNextTMSPPContent() { bool CMinecraftApp::RetrieveNextTMSPPContent() { return false; }
return false;
}
void CMinecraftApp::TickDLCOffersRetrieved() { void CMinecraftApp::TickDLCOffersRetrieved() {
if (!m_bAllDLCContentRetrieved) { if (!m_bAllDLCContentRetrieved) {
@ -7030,8 +6993,8 @@ void CMinecraftApp::ClearAndResetDLCDownloadQueue() {
int iPosition = 0; int iPosition = 0;
EnterCriticalSection(&csTMSPPDownloadQueue); EnterCriticalSection(&csTMSPPDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin(); for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
it != m_DLCDownloadQueue.end(); ++it) { ++it) {
DLCRequest* pCurrent = *it; DLCRequest* pCurrent = *it;
delete pCurrent; delete pCurrent;
@ -7102,8 +7065,8 @@ bool CMinecraftApp::DLCContentRetrieved(eDLCMarketplaceType eType) {
// If there's already a retrieve in progress, quit // If there's already a retrieve in progress, quit
// we may have re-ordered the list, so need to check every item // we may have re-ordered the list, so need to check every item
EnterCriticalSection(&csDLCDownloadQueue); EnterCriticalSection(&csDLCDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin(); for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
it != m_DLCDownloadQueue.end(); ++it) { ++it) {
DLCRequest* pCurrent = *it; DLCRequest* pCurrent = *it;
if ((pCurrent->dwType == m_dwContentTypeA[eType]) && if ((pCurrent->dwType == m_dwContentTypeA[eType]) &&
@ -7300,7 +7263,6 @@ std::wstring CMinecraftApp::getSkinPathFromId(std::uint32_t skinId) {
int CMinecraftApp::TexturePackDialogReturned( int CMinecraftApp::TexturePackDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) { void* pParam, int iPad, C4JStorage::EMessageResult result) {
return 0; return 0;
} }
@ -7388,7 +7350,6 @@ bool CMinecraftApp::IsLocalMultiplayerAvailable() {
bool available = RenderManager.IsHiDef() && connectedControllers > 1; bool available = RenderManager.IsHiDef() && connectedControllers > 1;
return available; return available;
// Found this in GameNetworkManager? // Found this in GameNetworkManager?
@ -7561,7 +7522,6 @@ void CMinecraftApp::getLocale(std::vector<std::wstring>& vecWstrLocales) {
locales.push_back(eMCLang_csCS); locales.push_back(eMCLang_csCS);
locales.push_back(eMCLang_zhCN); locales.push_back(eMCLang_zhCN);
break; break;
} }
locales.push_back(eMCLang_enUS); locales.push_back(eMCLang_enUS);
@ -7824,7 +7784,6 @@ std::wstring titleUpdateTexturePackRoot = L"Windows64\\DLC\\";
std::wstring titleUpdateTexturePackRoot = L"CU\\DLC\\"; std::wstring titleUpdateTexturePackRoot = L"CU\\DLC\\";
#endif #endif
std::wstring CMinecraftApp::getRootPath(std::uint32_t packId, std::wstring CMinecraftApp::getRootPath(std::uint32_t packId,
bool allowOverride, bool bAddDataFolder, bool allowOverride, bool bAddDataFolder,
std::wstring mountPoint) { std::wstring mountPoint) {
@ -7847,4 +7806,3 @@ std::wstring CMinecraftApp::getRootPath(std::uint32_t packId,
return path + L"\\"; return path + L"\\";
} }
} }

View file

@ -25,7 +25,6 @@
#include "../Minecraft.Client/Utils/ArchiveFile.h" #include "../Minecraft.Client/Utils/ArchiveFile.h"
#include "../Minecraft.World/Entities/MinecartHopper.h" #include "../Minecraft.World/Entities/MinecartHopper.h"
typedef struct _JoinFromInviteData { typedef struct _JoinFromInviteData {
std::uint32_t dwUserIndex; // dwUserIndex std::uint32_t dwUserIndex; // dwUserIndex
std::uint32_t dwLocalUsersMask; // dwUserMask std::uint32_t dwLocalUsersMask; // dwUserMask
@ -56,8 +55,7 @@ class Merchant;
class CMinecraftAudio; class CMinecraftAudio;
class CMinecraftApp class CMinecraftApp {
{
private: private:
static int s_iHTMLFontSizesA[eHTMLSize_COUNT]; static int s_iHTMLFontSizesA[eHTMLSize_COUNT];
@ -268,8 +266,7 @@ public:
void SetFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; } void SetFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; }
// debug -0 show safe area // debug -0 show safe area
void ShowSafeArea(bool show) { void ShowSafeArea(bool show) {}
}
// 4J-PB - to capture the social post screenshot // 4J-PB - to capture the social post screenshot
virtual void CaptureScreenshot(int iPad) {}; virtual void CaptureScreenshot(int iPad) {};
// void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE // void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE
@ -371,7 +368,6 @@ public:
static void UpsellReturnedCallback(void* pParam, eUpsellType type, static void UpsellReturnedCallback(void* pParam, eUpsellType type,
eUpsellResponse result, int iUserData); eUpsellResponse result, int iUserData);
#if defined(_DEBUG_MENUS_ENABLED) #if defined(_DEBUG_MENUS_ENABLED)
bool DebugSettingsOn() { return m_bDebugOptions; } bool DebugSettingsOn() { return m_bDebugOptions; }
bool DebugArtToolsOn(); bool DebugArtToolsOn();
@ -677,7 +673,8 @@ public:
static int32_t RegisterConfigValues(wchar_t* pType, int iValue); static int32_t RegisterConfigValues(wchar_t* pType, int iValue);
static int32_t RegisterDLCData(wchar_t*, wchar_t*, int, uint64_t, uint64_t, static int32_t RegisterDLCData(wchar_t*, wchar_t*, int, uint64_t, uint64_t,
wchar_t*, unsigned int, int, wchar_t* pDataFile); wchar_t*, unsigned int, int,
wchar_t* pDataFile);
bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin, bool GetDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
uint64_t* pullVal); uint64_t* pullVal);
DLC_INFO* GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial); DLC_INFO* GetDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
@ -839,7 +836,8 @@ private:
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS]; unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
public: public:
void UpdatePlayerInfo(std::uint8_t networkSmallId, int16_t playerColourIndex, void UpdatePlayerInfo(std::uint8_t networkSmallId,
int16_t playerColourIndex,
unsigned int playerGamePrivileges); unsigned int playerGamePrivileges);
short GetPlayerColour(std::uint8_t networkSmallId); short GetPlayerColour(std::uint8_t networkSmallId);
unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId); unsigned int GetPlayerPrivileges(std::uint8_t networkSmallId);
@ -915,9 +913,10 @@ public:
// static int CallbackReadXuidsFileFromTMS(void* lpParam, wchar_t // static int CallbackReadXuidsFileFromTMS(void* lpParam, wchar_t
// *wchFilename, int iPad, bool bResult, int iAction); static int // *wchFilename, int iPad, bool bResult, int iAction); static int
// CallbackDLCFileFromTMS(void* lpParam, wchar_t *wchFilename, int iPad, bool // CallbackDLCFileFromTMS(void* lpParam, wchar_t *wchFilename, int iPad,
// bResult, int iAction); static int CallbackBannedListFileFromTMS(void* // bool bResult, int iAction); static int
// lpParam, wchar_t *wchFilename, int iPad, bool bResult, int iAction); // CallbackBannedListFileFromTMS(void* lpParam, wchar_t *wchFilename, int
// iPad, bool bResult, int iAction);
// Storing additional model parts per skin texture // Storing additional model parts per skin texture
void SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA, void SetAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA,
@ -982,7 +981,6 @@ private:
bool m_bResetNether; bool m_bResetNether;
std::uint32_t m_dwRequiredTexturePackID; std::uint32_t m_dwRequiredTexturePackID;
// 4J-PB - language and locale functions // 4J-PB - language and locale functions
public: public:
void LocaleAndLanguageInit(); void LocaleAndLanguageInit();
@ -1009,7 +1007,6 @@ public:
#else #else
#endif #endif
}; };
// singleton // singleton

View file

@ -25,7 +25,6 @@ void DLCGameRulesHeader::addData(std::uint8_t* pbData,
std::uint32_t dataBytes) { std::uint32_t dataBytes) {
m_pbData = pbData; m_pbData = pbData;
m_dataBytes = dataBytes; m_dataBytes = dataBytes;
} }
std::uint8_t* DLCGameRulesHeader::getData(std::uint32_t& dataBytes) { std::uint8_t* DLCGameRulesHeader::getData(std::uint32_t& dataBytes) {

View file

@ -229,7 +229,6 @@ DLCPack* DLCManager::getPack(const std::wstring& name) {
return pack; return pack;
} }
DLCPack* DLCManager::getPack(unsigned int index, DLCPack* DLCManager::getPack(unsigned int index,
EDLCType type /*= e_DLCType_All*/) { EDLCType type /*= e_DLCType_All*/) {
DLCPack* pack = nullptr; DLCPack* pack = nullptr;

View file

@ -27,7 +27,6 @@ DLCPack::DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask) {
m_data = nullptr; m_data = nullptr;
} }
DLCPack::~DLCPack() { DLCPack::~DLCPack() {
for (auto it = m_childPacks.begin(); it != m_childPacks.end(); ++it) { for (auto it = m_childPacks.begin(); it != m_childPacks.end(); ++it) {
delete *it; delete *it;
@ -213,8 +212,8 @@ bool DLCPack::doesPackContainFile(DLCManager::EDLCType type,
} }
} else { } else {
g_pathCmpString = &path; g_pathCmpString = &path;
auto it = std::find_if(m_files[type].begin(), m_files[type].end(), auto it =
pathCmp); std::find_if(m_files[type].begin(), m_files[type].end(), pathCmp);
hasFile = it != m_files[type].end(); hasFile = it != m_files[type].end();
if (!hasFile && m_parentPack) { if (!hasFile && m_parentPack) {
hasFile = m_parentPack->doesPackContainFile(type, path); hasFile = m_parentPack->doesPackContainFile(type, path);
@ -252,7 +251,8 @@ DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) {
} }
} else { } else {
g_pathCmpString = &path; g_pathCmpString = &path;
auto it = std::find_if(m_files[type].begin(), m_files[type].end(), pathCmp); auto it =
std::find_if(m_files[type].begin(), m_files[type].end(), pathCmp);
if (it == m_files[type].end()) { if (it == m_files[type].end()) {
// Not found // Not found

View file

@ -107,10 +107,10 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
SKIN_BOX* pSkinBox = new SKIN_BOX; SKIN_BOX* pSkinBox = new SKIN_BOX;
ZeroMemory(pSkinBox, sizeof(SKIN_BOX)); ZeroMemory(pSkinBox, sizeof(SKIN_BOX));
swscanf_s( swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10, &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ,
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW, &pSkinBox->fW, &pSkinBox->fH, &pSkinBox->fD,
&pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV); &pSkinBox->fU, &pSkinBox->fV);
if (wcscmp(wchBodyPart, L"HEAD") == 0) { if (wcscmp(wchBodyPart, L"HEAD") == 0) {
pSkinBox->ePart = eBodyPart_Head; pSkinBox->ePart = eBodyPart_Head;

View file

@ -88,8 +88,8 @@ bool CollectItemRuleDefinition::onCollectItem(
std::shared_ptr<UpdateGameRuleProgressPacket>( std::shared_ptr<UpdateGameRuleProgressPacket>(
new UpdateGameRuleProgressPacket( new UpdateGameRuleProgressPacket(
getActionType(), this->m_descriptionId, getActionType(), this->m_descriptionId,
m_itemId, m_auxValue, this->m_4JDataValue, nullptr, m_itemId, m_auxValue, this->m_4JDataValue,
0))); nullptr, 0)));
} }
} }
} }

View file

@ -28,8 +28,8 @@ bool CompleteAllRuleDefinition::onCollectItem(
void CompleteAllRuleDefinition::updateStatus(GameRule* rule) { void CompleteAllRuleDefinition::updateStatus(GameRule* rule) {
int goal = 0; int goal = 0;
int progress = 0; int progress = 0;
for (auto it = rule->m_parameters.begin(); for (auto it = rule->m_parameters.begin(); it != rule->m_parameters.end();
it != rule->m_parameters.end(); ++it) { ++it) {
if (it->second.isPointer) { if (it->second.isPointer) {
goal += it->second.gr->getGameRuleDefinition()->getGoal(); goal += it->second.gr->getGameRuleDefinition()->getGoal();
progress += it->second.gr->getGameRuleDefinition()->getProgress( progress += it->second.gr->getGameRuleDefinition()->getProgress(

View file

@ -66,8 +66,8 @@ void CompoundGameRuleDefinition::populateGameRule(
bool CompoundGameRuleDefinition::onUseTile(GameRule* rule, int tileId, int x, bool CompoundGameRuleDefinition::onUseTile(GameRule* rule, int tileId, int x,
int y, int z) { int y, int z) {
bool statusChanged = false; bool statusChanged = false;
for (auto it = rule->m_parameters.begin(); for (auto it = rule->m_parameters.begin(); it != rule->m_parameters.end();
it != rule->m_parameters.end(); ++it) { ++it) {
if (it->second.isPointer) { if (it->second.isPointer) {
bool changed = it->second.gr->getGameRuleDefinition()->onUseTile( bool changed = it->second.gr->getGameRuleDefinition()->onUseTile(
it->second.gr, tileId, x, y, z); it->second.gr, tileId, x, y, z);
@ -84,8 +84,8 @@ bool CompoundGameRuleDefinition::onUseTile(GameRule* rule, int tileId, int x,
bool CompoundGameRuleDefinition::onCollectItem( bool CompoundGameRuleDefinition::onCollectItem(
GameRule* rule, std::shared_ptr<ItemInstance> item) { GameRule* rule, std::shared_ptr<ItemInstance> item) {
bool statusChanged = false; bool statusChanged = false;
for (auto it = rule->m_parameters.begin(); for (auto it = rule->m_parameters.begin(); it != rule->m_parameters.end();
it != rule->m_parameters.end(); ++it) { ++it) {
if (it->second.isPointer) { if (it->second.isPointer) {
bool changed = bool changed =
it->second.gr->getGameRuleDefinition()->onCollectItem( it->second.gr->getGameRuleDefinition()->onCollectItem(

View file

@ -122,7 +122,8 @@ void ConsoleSchematicFile::load(DataInputStream* dis) {
if (te == nullptr) { if (te == nullptr) {
#ifndef _CONTENT_PACKAGE #ifndef _CONTENT_PACKAGE
app.DebugPrintf( app.DebugPrintf(
"ConsoleSchematicFile has read a nullptr tile entity\n"); "ConsoleSchematicFile has read a nullptr tile "
"entity\n");
__debugbreak(); __debugbreak();
#endif #endif
} else { } else {
@ -169,8 +170,7 @@ void ConsoleSchematicFile::save_tags(DataOutputStream* dos) {
ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>(); ListTag<CompoundTag>* tileEntityTags = new ListTag<CompoundTag>();
tag->put(L"TileEntities", tileEntityTags); tag->put(L"TileEntities", tileEntityTags);
for (auto it = m_tileEntities.begin(); it != m_tileEntities.end(); for (auto it = m_tileEntities.begin(); it != m_tileEntities.end(); it++) {
it++) {
CompoundTag* cTag = new CompoundTag(); CompoundTag* cTag = new CompoundTag();
(*it)->save(cTag); (*it)->save(cTag);
tileEntityTags->add(cTag); tileEntityTags->add(cTag);
@ -452,8 +452,7 @@ void ConsoleSchematicFile::schematicCoordToChunkCoord(
void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox, void ConsoleSchematicFile::applyTileEntities(LevelChunk* chunk, AABB* chunkBox,
AABB* destinationBox, AABB* destinationBox,
ESchematicRotation rot) { ESchematicRotation rot) {
for (auto it = m_tileEntities.begin(); it != m_tileEntities.end(); for (auto it = m_tileEntities.begin(); it != m_tileEntities.end(); ++it) {
++it) {
std::shared_ptr<TileEntity> te = *it; std::shared_ptr<TileEntity> te = *it;
double targetX = te->x; double targetX = te->x;
@ -1070,8 +1069,8 @@ ConsoleSchematicFile::getTileEntitiesInRegion(LevelChunk* chunk, int x0, int y0,
int z0, int x1, int y1, int z1) { int z0, int x1, int y1, int z1) {
std::vector<std::shared_ptr<TileEntity> >* result = std::vector<std::shared_ptr<TileEntity> >* result =
new std::vector<std::shared_ptr<TileEntity> >; new std::vector<std::shared_ptr<TileEntity> >;
for (auto it = chunk->tileEntities.begin(); for (auto it = chunk->tileEntities.begin(); it != chunk->tileEntities.end();
it != chunk->tileEntities.end(); ++it) { ++it) {
std::shared_ptr<TileEntity> te = it->second; std::shared_ptr<TileEntity> te = it->second;
if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 && if (te->x >= x0 && te->y >= y0 && te->z >= z0 && te->x < x1 &&
te->y < y1 && te->z < z1) { te->y < y1 && te->z < z1) {

View file

@ -77,5 +77,6 @@ public:
Connection* connection); Connection* connection);
static std::wstring generateDescriptionString( static std::wstring generateDescriptionString(
ConsoleGameRules::EGameRuleType defType, ConsoleGameRules::EGameRuleType defType,
const std::wstring& description, void* data = nullptr, int dataLength = 0); const std::wstring& description, void* data = nullptr,
int dataLength = 0);
}; };

View file

@ -627,7 +627,6 @@ void GameRuleManager::processSchematicsLighting(LevelChunk* levelChunk) {
} }
void GameRuleManager::loadDefaultGameRules() { void GameRuleManager::loadDefaultGameRules() {
#if !defined(__linux__) #if !defined(__linux__)
#if defined(_WINDOWS64) #if defined(_WINDOWS64)
File packedTutorialFile(L"Windows64Media\\Tutorial\\Tutorial.pck"); File packedTutorialFile(L"Windows64Media\\Tutorial\\Tutorial.pck");
@ -644,19 +643,20 @@ void GameRuleManager::loadDefaultGameRules() {
app.GetString(IDS_TUTORIALSAVENAME)); app.GetString(IDS_TUTORIALSAVENAME));
} }
#else #else
std::wstring fpTutorial = L"Tutorial.pck"; std::wstring fpTutorial = L"Tutorial.pck";
if(app.getArchiveFileSize(fpTutorial) >= 0) if (app.getArchiveFileSize(fpTutorial) >= 0) {
{ DLCPack* pack = new DLCPack(L"", 0xffffffff);
DLCPack *pack = new DLCPack(L"",0xffffffff); uint32_t dwFilesProcessed = 0;
uint32_t dwFilesProcessed = 0; if (app.m_dlcManager.readDLCDataFile(dwFilesProcessed, fpTutorial, pack,
if ( app.m_dlcManager.readDLCDataFile(dwFilesProcessed,fpTutorial,pack,true) ) true)) {
{ app.m_dlcManager.addPack(pack);
app.m_dlcManager.addPack(pack); m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(
m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(app.GetString(IDS_PLAY_TUTORIAL)); app.GetString(IDS_PLAY_TUTORIAL));
m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(app.GetString(IDS_TUTORIALSAVENAME)); m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(
} app.GetString(IDS_TUTORIALSAVENAME));
else delete pack; } else
} delete pack;
}
#endif #endif
} }

View file

@ -56,7 +56,7 @@ public:
bool readRuleFile(LevelGenerationOptions* lgo, uint8_t* dIn, bool readRuleFile(LevelGenerationOptions* lgo, uint8_t* dIn,
unsigned int dSize, unsigned int dSize,
StringTable* strings); //(DLCGameRulesFile *dlcFile, StringTable* strings); //(DLCGameRulesFile *dlcFile,
//StringTable *strings); // StringTable *strings);
private: private:
void readAttributes(DataInputStream* dis, void readAttributes(DataInputStream* dis,

View file

@ -124,18 +124,14 @@ void LevelGenerationOptions::getChildren(
GameRuleDefinition::getChildren(children); GameRuleDefinition::getChildren(children);
std::vector<ApplySchematicRuleDefinition*> used_schematics; std::vector<ApplySchematicRuleDefinition*> used_schematics;
for (auto it = m_schematicRules.begin(); it != m_schematicRules.end(); for (auto it = m_schematicRules.begin(); it != m_schematicRules.end(); it++)
it++)
if (!(*it)->isComplete()) used_schematics.push_back(*it); if (!(*it)->isComplete()) used_schematics.push_back(*it);
for (auto it = m_structureRules.begin(); it != m_structureRules.end(); for (auto it = m_structureRules.begin(); it != m_structureRules.end(); it++)
it++)
children->push_back(*it); children->push_back(*it);
for (auto it = used_schematics.begin(); it != used_schematics.end(); for (auto it = used_schematics.begin(); it != used_schematics.end(); it++)
it++)
children->push_back(*it); children->push_back(*it);
for (auto it = m_biomeOverrides.begin(); it != m_biomeOverrides.end(); for (auto it = m_biomeOverrides.begin(); it != m_biomeOverrides.end(); ++it)
++it)
children->push_back(*it); children->push_back(*it);
for (auto it = m_features.begin(); it != m_features.end(); ++it) for (auto it = m_features.begin(); it != m_features.end(); ++it)
children->push_back(*it); children->push_back(*it);
@ -300,15 +296,15 @@ bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1,
// ground/sea level and b) tutorial world additions generally being above // ground/sea level and b) tutorial world additions generally being above
// ground/sea level // ground/sea level
if (!m_bHaveMinY) { if (!m_bHaveMinY) {
for (auto it = m_schematicRules.begin(); for (auto it = m_schematicRules.begin(); it != m_schematicRules.end();
it != m_schematicRules.end(); ++it) { ++it) {
ApplySchematicRuleDefinition* rule = *it; ApplySchematicRuleDefinition* rule = *it;
int minY = rule->getMinY(); int minY = rule->getMinY();
if (minY < m_minY) m_minY = minY; if (minY < m_minY) m_minY = minY;
} }
for (auto it = m_structureRules.begin(); for (auto it = m_structureRules.begin(); it != m_structureRules.end();
it != m_structureRules.end(); it++) { it++) {
ConsoleGenerateStructure* structureStart = *it; ConsoleGenerateStructure* structureStart = *it;
int minY = structureStart->getMinY(); int minY = structureStart->getMinY();
if (minY < m_minY) m_minY = minY; if (minY < m_minY) m_minY = minY;
@ -330,8 +326,8 @@ bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1,
} }
if (!intersects) { if (!intersects) {
for (auto it = m_structureRules.begin(); for (auto it = m_structureRules.begin(); it != m_structureRules.end();
it != m_structureRules.end(); it++) { it++) {
ConsoleGenerateStructure* structureStart = *it; ConsoleGenerateStructure* structureStart = *it;
intersects = intersects =
structureStart->checkIntersects(x0, y0, z0, x1, y1, z1); structureStart->checkIntersects(x0, y0, z0, x1, y1, z1);
@ -446,8 +442,7 @@ LevelGenerationOptions::getUnfinishedSchematicFiles() {
// Clean schematic rules. // Clean schematic rules.
std::unordered_set<std::wstring> usedFiles = std::unordered_set<std::wstring> usedFiles =
std::unordered_set<std::wstring>(); std::unordered_set<std::wstring>();
for (auto it = m_schematicRules.begin(); it != m_schematicRules.end(); for (auto it = m_schematicRules.begin(); it != m_schematicRules.end(); it++)
it++)
if (!(*it)->isComplete()) usedFiles.insert((*it)->getSchematicName()); if (!(*it)->isComplete()) usedFiles.insert((*it)->getSchematicName());
// Clean schematic files. // Clean schematic files.
@ -469,8 +464,7 @@ void LevelGenerationOptions::loadBaseSaveData() {
if (StorageManager.MountInstalledDLC( if (StorageManager.MountInstalledDLC(
ProfileManager.GetPrimaryPad(), mountIndex, ProfileManager.GetPrimaryPad(), mountIndex,
&LevelGenerationOptions::packMounted, this, &LevelGenerationOptions::packMounted, this,
"WPACK") != ERROR_IO_PENDING) "WPACK") != ERROR_IO_PENDING) {
{
// corrupt DLC // corrupt DLC
setLoadedData(); setLoadedData();
app.DebugPrintf("Failed to mount LGO DLC %d for pad %d\n", app.DebugPrintf("Failed to mount LGO DLC %d for pad %d\n",
@ -518,12 +512,12 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share 0, // share mode // TODO 4J Stu - Will we need to share
// file? Probably not but... // file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu - OPEN_EXISTING, // how to create // TODO 4J Stu -
// Assuming that the file already exists // Assuming that the file already exists
// if we are opening to read from it // if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#else #else
const char* pchFilename = wstringtofilename(grf.getPath()); const char* pchFilename = wstringtofilename(grf.getPath());
@ -532,19 +526,19 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share 0, // share mode // TODO 4J Stu - Will we need to share
// file? Probably not but... // file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu - OPEN_EXISTING, // how to create // TODO 4J Stu -
// Assuming that the file already exists // Assuming that the file already exists
// if we are opening to read from it // if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#endif #endif
if (fileHandle != INVALID_HANDLE_VALUE) { if (fileHandle != INVALID_HANDLE_VALUE) {
uint32_t dwFileSize = grf.length(); uint32_t dwFileSize = grf.length();
uint32_t bytesRead; uint32_t bytesRead;
uint8_t* pbData = (uint8_t*) new uint8_t[dwFileSize]; uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
bool bSuccess = ReadFile(fileHandle, pbData, dwFileSize, bool bSuccess = ReadFile(fileHandle, pbData, dwFileSize,
&bytesRead, nullptr); &bytesRead, nullptr);
if (bSuccess == false) { if (bSuccess == false) {
@ -574,34 +568,35 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
void* fileHandle = CreateFile( void* fileHandle = CreateFile(
pchFilename, // file name pchFilename, // file name
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share 0, // share mode // TODO 4J Stu - Will we need to share
// file? Probably not but... // file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu - Assuming OPEN_EXISTING, // how to create // TODO 4J Stu - Assuming
// that the file already exists if we are // that the file already exists if we are
// opening to read from it // opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#else #else
const char* pchFilename = wstringtofilename(save.getPath()); const char* pchFilename = wstringtofilename(save.getPath());
void* fileHandle = CreateFile( void* fileHandle = CreateFile(
pchFilename, // file name pchFilename, // file name
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share 0, // share mode // TODO 4J Stu - Will we need to share
// file? Probably not but... // file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu - Assuming OPEN_EXISTING, // how to create // TODO 4J Stu - Assuming
// that the file already exists if we are // that the file already exists if we are
// opening to read from it // opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#endif #endif
if (fileHandle != INVALID_HANDLE_VALUE) { if (fileHandle != INVALID_HANDLE_VALUE) {
uint32_t bytesRead, dwFileSize = GetFileSize(fileHandle, nullptr); uint32_t bytesRead,
uint8_t* pbData = (uint8_t*) new uint8_t[dwFileSize]; dwFileSize = GetFileSize(fileHandle, nullptr);
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
bool bSuccess = ReadFile(fileHandle, pbData, dwFileSize, bool bSuccess = ReadFile(fileHandle, pbData, dwFileSize,
&bytesRead, nullptr); &bytesRead, nullptr);
if (bSuccess == false) { if (bSuccess == false) {

View file

@ -24,7 +24,8 @@ public:
ConsoleGameRules::EGameRuleType ruleType); ConsoleGameRules::EGameRuleType ruleType);
// 4J-JEV: Super class handles attr-facing fine. // 4J-JEV: Super class handles attr-facing fine.
// virtual void writeAttributes(DataOutputStream *dos, uint32_t numAttributes); // virtual void writeAttributes(DataOutputStream *dos, uint32_t
// numAttributes);
virtual void addAttribute(const std::wstring& attributeName, virtual void addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue); const std::wstring& attributeValue);

View file

@ -4,101 +4,105 @@
#include "LeaderboardManager.h" #include "LeaderboardManager.h"
const std::wstring LeaderboardManager::filterNames[eNumFilterModes] = const std::wstring LeaderboardManager::filterNames[eNumFilterModes] = {
{ L"Friends", L"MyScore", L"TopRank"};
L"Friends", L"MyScore", L"TopRank"
};
void LeaderboardManager::DeleteInstance() void LeaderboardManager::DeleteInstance() {
{ delete m_instance;
delete m_instance; m_instance = nullptr;
m_instance = nullptr;
} }
LeaderboardManager::LeaderboardManager() LeaderboardManager::LeaderboardManager() {
{ zeroReadParameters();
zeroReadParameters();
m_myXUID = INVALID_XUID; m_myXUID = INVALID_XUID;
} }
void LeaderboardManager::zeroReadParameters() void LeaderboardManager::zeroReadParameters() {
{ m_difficulty = -1;
m_difficulty = -1; m_statsType = eStatsType_UNDEFINED;
m_statsType = eStatsType_UNDEFINED; m_readListener = nullptr;
m_readListener = nullptr; m_startIndex = 0;
m_startIndex = 0; m_readCount = 0;
m_readCount = 0; m_eFilterMode = eFM_UNDEFINED;
m_eFilterMode = eFM_UNDEFINED;
} }
bool LeaderboardManager::ReadStats_Friends(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount) bool LeaderboardManager::ReadStats_Friends(LeaderboardReadListener* listener,
{ int difficulty, EStatsType type,
zeroReadParameters(); PlayerUID myUID,
unsigned int startIndex,
unsigned int readCount) {
zeroReadParameters();
m_readListener = listener; m_readListener = listener;
m_difficulty = difficulty; m_difficulty = difficulty;
m_statsType = type; m_statsType = type;
m_eFilterMode = eFM_Friends; m_eFilterMode = eFM_Friends;
return true; return true;
} }
bool LeaderboardManager::ReadStats_MyScore(LeaderboardReadListener *listener, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount) bool LeaderboardManager::ReadStats_MyScore(LeaderboardReadListener* listener,
{ int difficulty, EStatsType type,
zeroReadParameters(); PlayerUID myUID,
unsigned int readCount) {
zeroReadParameters();
m_readListener = listener; m_readListener = listener;
m_difficulty = difficulty; m_difficulty = difficulty;
m_statsType = type; m_statsType = type;
m_readCount = readCount; m_readCount = readCount;
m_eFilterMode = eFM_MyScore; m_eFilterMode = eFM_MyScore;
return true; return true;
} }
bool LeaderboardManager::ReadStats_TopRank(LeaderboardReadListener *listener, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount) bool LeaderboardManager::ReadStats_TopRank(LeaderboardReadListener* listener,
{ int difficulty, EStatsType type,
zeroReadParameters(); unsigned int startIndex,
unsigned int readCount) {
zeroReadParameters();
m_readListener = listener; m_readListener = listener;
m_difficulty = difficulty; m_difficulty = difficulty;
m_statsType = type; m_statsType = type;
m_startIndex = startIndex; m_startIndex = startIndex;
m_readCount = readCount; m_readCount = readCount;
m_eFilterMode = eFM_TopRank; m_eFilterMode = eFM_TopRank;
return true; return true;
} }
void LeaderboardManager::printStats(ReadView &view) void LeaderboardManager::printStats(ReadView& view) {
{ app.DebugPrintf(
app.DebugPrintf("[LeaderboardManager] Printing stats:\n" "[LeaderboardManager] Printing stats:\n"
"\tnumQueries=%i\n", view.m_numQueries); "\tnumQueries=%i\n",
view.m_numQueries);
for (int i=0; i<view.m_numQueries; i++) for (int i = 0; i < view.m_numQueries; i++) {
{ ReadScore score = view.m_queries[i];
ReadScore score = view.m_queries[i];
app.DebugPrintf( "\tname='%s'\n", wstringtofilename(std::wstring(score.m_name)) ); app.DebugPrintf("\tname='%s'\n",
app.DebugPrintf( "\trank='%i'\n", score.m_rank ); wstringtofilename(std::wstring(score.m_name)));
app.DebugPrintf("\trank='%i'\n", score.m_rank);
app.DebugPrintf( "\tstatsData=[" ); app.DebugPrintf("\tstatsData=[");
for (int j=0; j<score.m_statsSize; j++) for (int j = 0; j < score.m_statsSize; j++)
app.DebugPrintf( " %i", score.m_statsData[j] ); app.DebugPrintf(" %i", score.m_statsData[j]);
app.DebugPrintf( "]\n" ); app.DebugPrintf("]\n");
} }
} }
bool DebugReadListener::OnStatsReadComplete(
LeaderboardManager::eStatsReturn success, int numResults,
LeaderboardManager::ViewOut results) {
app.DebugPrintf("[DebugReadListener] OnStatsReadComplete, %s:\n",
(success ? "success" : "FAILED"));
LeaderboardManager::printStats(results);
bool DebugReadListener::OnStatsReadComplete(LeaderboardManager::eStatsReturn success, int numResults, LeaderboardManager::ViewOut results) return true;
{
app.DebugPrintf("[DebugReadListener] OnStatsReadComplete, %s:\n", (success ? "success" : "FAILED") );
LeaderboardManager::printStats(results);
return true;
} }
DebugReadListener *DebugReadListener::m_instance = new DebugReadListener(); DebugReadListener* DebugReadListener::m_instance = new DebugReadListener();

View file

@ -7,249 +7,246 @@ class LeaderboardManager;
class LeaderboardReadListener; class LeaderboardReadListener;
// ABSTRACT CLASS // // ABSTRACT CLASS //
class LeaderboardManager class LeaderboardManager {
{
public: public:
enum eStatsReturn enum eStatsReturn {
{ eStatsReturn_Success = 0,
eStatsReturn_Success=0, eStatsReturn_NoResults,
eStatsReturn_NoResults, eStatsReturn_NetworkError
eStatsReturn_NetworkError };
};
enum eProperty_Kills enum eProperty_Kills {
{ eProperty_Kills_Zombie = 0,
eProperty_Kills_Zombie=0, eProperty_Kills_Skeleton,
eProperty_Kills_Skeleton, eProperty_Kills_Creeper,
eProperty_Kills_Creeper, eProperty_Kills_Spider,
eProperty_Kills_Spider, eProperty_Kills_SpiderJockey,
eProperty_Kills_SpiderJockey, eProperty_Kills_ZombiePigman,
eProperty_Kills_ZombiePigman, eProperty_Kills_Slime,
eProperty_Kills_Slime, eProperty_Kills_Rating,
eProperty_Kills_Rating, eProperty_Kills_Max,
eProperty_Kills_Max, };
};
enum eProperty_Mining enum eProperty_Mining {
{ eProperty_Mining_Dirt = 0,
eProperty_Mining_Dirt=0, eProperty_Mining_Stone,
eProperty_Mining_Stone, eProperty_Mining_Sand,
eProperty_Mining_Sand, eProperty_Mining_Cobblestone,
eProperty_Mining_Cobblestone, eProperty_Mining_Gravel,
eProperty_Mining_Gravel, eProperty_Mining_Clay,
eProperty_Mining_Clay, eProperty_Mining_Obsidian,
eProperty_Mining_Obsidian, eProperty_Mining_Rating,
eProperty_Mining_Rating, eProperty_Mining_Max,
eProperty_Mining_Max, };
};
enum eProperty_Farming enum eProperty_Farming {
{ eProperty_Farming_Egg = 0,
eProperty_Farming_Egg=0, eProperty_Farming_Wheat,
eProperty_Farming_Wheat, eProperty_Farming_Mushroom,
eProperty_Farming_Mushroom, eProperty_Farming_Sugarcane,
eProperty_Farming_Sugarcane, eProperty_Farming_Milk,
eProperty_Farming_Milk, eProperty_Farming_Pumpkin,
eProperty_Farming_Pumpkin, eProperty_Farming_Rating,
eProperty_Farming_Rating, eProperty_Farming_Max,
eProperty_Farming_Max, };
};
enum eProperty_Travelling enum eProperty_Travelling {
{ eProperty_Travelling_Walked = 0,
eProperty_Travelling_Walked=0, eProperty_Travelling_Fallen,
eProperty_Travelling_Fallen, eProperty_Travelling_Minecart,
eProperty_Travelling_Minecart, eProperty_Travelling_Boat,
eProperty_Travelling_Boat, eProperty_Travelling_Rating,
eProperty_Travelling_Rating, eProperty_Travelling_Max,
eProperty_Travelling_Max, };
};
enum EStatsType enum EStatsType {
{ eStatsType_Travelling = 0,
eStatsType_Travelling=0, eStatsType_Mining,
eStatsType_Mining, eStatsType_Farming,
eStatsType_Farming, eStatsType_Kills,
eStatsType_Kills, eStatsType_MAX,
eStatsType_MAX, eStatsType_UNDEFINED
eStatsType_UNDEFINED };
};
enum EFilterMode enum EFilterMode {
{ eFM_Friends = 0, // Stats belonging to current user's friends
eFM_Friends=0, //Stats belonging to current user's friends eFM_MyScore, // Stats around the current user's rank
eFM_MyScore, //Stats around the current user's rank eFM_TopRank, // Stats at the top of the leaderboard
eFM_TopRank, //Stats at the top of the leaderboard eNumFilterModes,
eNumFilterModes, eFM_UNDEFINED
eFM_UNDEFINED };
};
static const std::wstring filterNames[eNumFilterModes]; static const std::wstring filterNames[eNumFilterModes];
typedef struct KillsRecord typedef struct KillsRecord {
{ public:
public: unsigned short m_zombie;
unsigned short m_zombie; unsigned short m_skeleton;
unsigned short m_skeleton; unsigned short m_creeper;
unsigned short m_creeper; unsigned short m_spider;
unsigned short m_spider; unsigned short m_spiderJockey;
unsigned short m_spiderJockey; unsigned short m_zombiePigman;
unsigned short m_zombiePigman; unsigned short m_slime;
unsigned short m_slime; } KillsRecord;
} KillsRecord;
typedef struct MiningRecord typedef struct MiningRecord {
{ public:
public: unsigned short m_dirt;
unsigned short m_dirt; unsigned short m_stone;
unsigned short m_stone; unsigned short m_sand;
unsigned short m_sand; unsigned short m_cobblestone;
unsigned short m_cobblestone; unsigned short m_gravel;
unsigned short m_gravel; unsigned short m_clay;
unsigned short m_clay; unsigned short m_obsidian;
unsigned short m_obsidian; } MiningRecord;
} MiningRecord;
typedef struct FarmingRecord
{
public:
unsigned short m_eggs;
unsigned short m_wheat;
unsigned short m_mushroom;
unsigned short m_sugarcane;
unsigned short m_milk;
unsigned short m_pumpkin;
} FarmingRecord;
typedef struct TravellingRecord
{
public:
unsigned int m_walked;
unsigned int m_fallen;
unsigned int m_minecart;
unsigned int m_boat;
} TravellingRecord;
typedef struct FarmingRecord {
public:
unsigned short m_eggs;
unsigned short m_wheat;
unsigned short m_mushroom;
unsigned short m_sugarcane;
unsigned short m_milk;
unsigned short m_pumpkin;
} FarmingRecord;
typedef struct TravellingRecord {
public:
unsigned int m_walked;
unsigned int m_fallen;
unsigned int m_minecart;
unsigned int m_boat;
} TravellingRecord;
public: public:
static const int RECORD_SIZE = 40; //base32 static const int RECORD_SIZE = 40; // base32
typedef struct StatsData typedef struct StatsData {
{ EStatsType m_statsType;
EStatsType m_statsType; union {
union LeaderboardManager::KillsRecord m_kills;
{ LeaderboardManager::MiningRecord m_mining;
LeaderboardManager::KillsRecord m_kills; LeaderboardManager::FarmingRecord m_farming;
LeaderboardManager::MiningRecord m_mining; LeaderboardManager::TravellingRecord m_travelling;
LeaderboardManager::FarmingRecord m_farming; unsigned char m_padding[RECORD_SIZE];
LeaderboardManager::TravellingRecord m_travelling; };
unsigned char m_padding[RECORD_SIZE]; } StatsData;
};
} StatsData;
typedef struct RegisterScore typedef struct RegisterScore {
{ int m_iPad;
int m_iPad; int m_score;
int m_score; int m_difficulty;
int m_difficulty; StatsData m_commentData;
StatsData m_commentData; } RegisterScore;
} RegisterScore;
typedef struct ReadScore typedef struct ReadScore {
{ // Maximum number of columns in a scoreboard.
// Maximum number of columns in a scoreboard. static const unsigned int STATSDATA_MAX = 8;
static const unsigned int STATSDATA_MAX = 8;
PlayerUID m_uid; // Player's unique identifier. PlayerUID m_uid; // Player's unique identifier.
unsigned long m_rank; // Rank of the player on this scoreboard. unsigned long m_rank; // Rank of the player on this scoreboard.
std::wstring m_name; // Player's display name. std::wstring m_name; // Player's display name.
unsigned long m_totalScore; // Sum of all the player's scores on this leaderboard. unsigned long m_totalScore; // Sum of all the player's scores on this
// leaderboard.
unsigned short m_statsSize; // Iff (m_hasResults): Number of columns on this leaderboard. unsigned short m_statsSize; // Iff (m_hasResults): Number of columns on
unsigned long m_statsData[STATSDATA_MAX]; // Iff (m_hasResults): Player's score for each appropriate column. // this leaderboard.
unsigned long
m_statsData[STATSDATA_MAX]; // Iff (m_hasResults): Player's score
// for each appropriate column.
int m_idsErrorMessage; // Iff (not m_hasResults): error message explaining what went wrong. int m_idsErrorMessage; // Iff (not m_hasResults): error message
// explaining what went wrong.
} ReadScore; } ReadScore;
typedef struct ReadView typedef struct ReadView {
{ unsigned int m_numQueries;
unsigned int m_numQueries; ReadScore* m_queries;
ReadScore *m_queries;
} ReadView; } ReadView;
typedef ReadView ViewOut;
typedef RegisterScore *ViewIn;
typedef ReadView ViewOut;
typedef RegisterScore* ViewIn;
public: public:
LeaderboardManager(); LeaderboardManager();
virtual ~LeaderboardManager() {} virtual ~LeaderboardManager() {}
protected: protected:
virtual void zeroReadParameters(); virtual void zeroReadParameters();
EFilterMode m_eFilterMode; EFilterMode m_eFilterMode;
// Parameters for reading. // Parameters for reading.
int m_difficulty; int m_difficulty;
EStatsType m_statsType; EStatsType m_statsType;
LeaderboardReadListener *m_readListener; LeaderboardReadListener* m_readListener;
PlayerUID m_myXUID; PlayerUID m_myXUID;
unsigned int m_startIndex, m_readCount; unsigned int m_startIndex, m_readCount;
private: private:
static LeaderboardManager *m_instance; //Singleton instance of the LeaderboardManager static LeaderboardManager*
m_instance; // Singleton instance of the LeaderboardManager
public: public:
static LeaderboardManager *Instance() { return m_instance; } static LeaderboardManager* Instance() { return m_instance; }
static void DeleteInstance(); static void DeleteInstance();
virtual void Tick() = 0; virtual void Tick() = 0;
//Open a session // Open a session
virtual bool OpenSession() = 0; virtual bool OpenSession() = 0;
//Close a session // Close a session
virtual void CloseSession() = 0; virtual void CloseSession() = 0;
//Delete a session // Delete a session
virtual void DeleteSession() = 0; virtual void DeleteSession() = 0;
//Write the given stats // Write the given stats
//This is called synchronously and will not free any memory allocated for views when it is done // This is called synchronously and will not free any memory allocated for
// views when it is done
virtual bool WriteStats(unsigned int viewCount, ViewIn views) = 0; virtual bool WriteStats(unsigned int viewCount, ViewIn views) = 0;
virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int startIndex, unsigned int readCount); virtual bool ReadStats_Friends(LeaderboardReadListener* callback,
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount); int difficulty, EStatsType type,
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount); PlayerUID myUID, unsigned int startIndex,
unsigned int readCount);
virtual bool ReadStats_MyScore(LeaderboardReadListener* callback,
int difficulty, EStatsType type,
PlayerUID myUID, unsigned int readCount);
virtual bool ReadStats_TopRank(LeaderboardReadListener* callback,
int difficulty, EStatsType type,
unsigned int startIndex,
unsigned int readCount);
//Perform a flush of the stats // Perform a flush of the stats
virtual void FlushStats() = 0; virtual void FlushStats() = 0;
//Cancel the current operation // Cancel the current operation
virtual void CancelOperation() = 0; virtual void CancelOperation() = 0;
//Is the leaderboard manager idle. // Is the leaderboard manager idle.
virtual bool isIdle() = 0; virtual bool isIdle() = 0;
public: public:
static void printStats(ReadView &view); static void printStats(ReadView& view);
}; };
class LeaderboardReadListener class LeaderboardReadListener {
{
public: public:
virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret, int numResults, LeaderboardManager::ViewOut results) = 0; virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret,
int numResults,
LeaderboardManager::ViewOut results) = 0;
}; };
class DebugReadListener : public LeaderboardReadListener class DebugReadListener : public LeaderboardReadListener {
{
public: public:
virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret, int numResults, LeaderboardManager::ViewOut results); virtual bool OnStatsReadComplete(LeaderboardManager::eStatsReturn ret,
static DebugReadListener *m_instance; int numResults,
LeaderboardManager::ViewOut results);
static DebugReadListener* m_instance;
}; };

View file

@ -236,88 +236,86 @@ bool SonyLeaderboardManager::getScoreByIds() {
/* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t /* app.DebugPrintf("sceNpScoreGetRankingByNpId(\n\t transaction=%i,\n\t
boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\ boardID=0,\n\t npId=%i,\n\t friendCount*sizeof(SceNpId)=%i*%i=%i,\
rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t nullptr, rankData=%i,\n\t friendCount*sizeof(SceNpScorePlayerRankData)=%i,\n\t
0, nullptr, 0,\n\t friendCount=%i,\n...\n", transaction, npId, friendCount, nullptr, 0, nullptr, 0,\n\t friendCount=%i,\n...\n", transaction, npId,
sizeof(SceNpId), friendCount*sizeof(SceNpId), rankData, friendCount, sizeof(SceNpId), friendCount*sizeof(SceNpId), rankData,
friendCount*sizeof(SceNpScorePlayerRankData), friendCount friendCount*sizeof(SceNpScorePlayerRankData), friendCount
); */ ); */
int boardId = getBoardId(m_difficulty, m_statsType); int boardId = getBoardId(m_difficulty, m_statsType);
// 4J-JEV: Orbis can only do with 100 ids max, so we use batches. // 4J-JEV: Orbis can only do with 100 ids max, so we use batches.
ret = createTransactionContext(m_titleContext); ret = createTransactionContext(m_titleContext);
if (m_eStatsState == eStatsState_Canceled) { if (m_eStatsState == eStatsState_Canceled) {
// Cancel operation has been called, abort. // Cancel operation has been called, abort.
app.DebugPrintf( app.DebugPrintf(
"[SonyLeaderboardManager]\tgetScoreByIds() - m_eStatsState == " "[SonyLeaderboardManager]\tgetScoreByIds() - m_eStatsState == "
"eStatsState_Canceled.\n"); "eStatsState_Canceled.\n");
destroyTransactionContext(ret); destroyTransactionContext(ret);
if (npIds != nullptr) delete[] npIds; if (npIds != nullptr) delete[] npIds;
if (ptr != nullptr) delete[] ptr; if (ptr != nullptr) delete[] ptr;
if (comments != nullptr) delete[] comments; if (comments != nullptr) delete[] comments;
return false; return false;
} else if (ret < 0) { } else if (ret < 0) {
// Error occurred creating a transacion, abort. // Error occurred creating a transacion, abort.
app.DebugPrintf( app.DebugPrintf(
"[SonyLeaderboardManager]\tgetScoreByIds() - createTransaction " "[SonyLeaderboardManager]\tgetScoreByIds() - createTransaction "
"failed, ret=0x%X\n", "failed, ret=0x%X\n",
ret); ret);
m_eStatsState = eStatsState_Failed; m_eStatsState = eStatsState_Failed;
if (npIds != nullptr) delete[] npIds; if (npIds != nullptr) delete[] npIds;
if (ptr != nullptr) delete[] ptr; if (ptr != nullptr) delete[] ptr;
if (comments != nullptr) delete[] comments; if (comments != nullptr) delete[] comments;
return false; return false;
} else { } else {
// Transaction created successfully, continue. // Transaction created successfully, continue.
m_requestId = ret; m_requestId = ret;
} }
int tmpNum = num; int tmpNum = num;
ret = sceNpScoreGetRankingByNpId( ret = sceNpScoreGetRankingByNpId(
m_requestId, m_requestId,
boardId, // BoardId boardId, // BoardId
npIds, sizeof(SceNpId) * tmpNum, // IN: Player IDs npIds, sizeof(SceNpId) * tmpNum, // IN: Player IDs
ptr, sizeof(SceNpScorePlayerRankData) * tmpNum, // OUT: Rank Data ptr, sizeof(SceNpScorePlayerRankData) * tmpNum, // OUT: Rank Data
comments, sizeof(SceNpScoreComment) * tmpNum, // OUT: Comments comments, sizeof(SceNpScoreComment) * tmpNum, // OUT: Comments
nullptr, 0, // GameData. (unused) nullptr, 0, // GameData. (unused)
tmpNum, tmpNum,
&last_sort_date, &mTotalRecord, &last_sort_date, &mTotalRecord,
nullptr // Reserved, specify null. nullptr // Reserved, specify null.
); );
if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) { if (ret == SCE_NP_COMMUNITY_ERROR_ABORTED) {
ret = destroyTransactionContext(m_requestId); ret = destroyTransactionContext(m_requestId);
app.DebugPrintf( app.DebugPrintf(
"[SonyLeaderboardManager] getScoreByIds(): " "[SonyLeaderboardManager] getScoreByIds(): "
"'sceNpScoreGetRankingByRange' aborted (0x%X).\n", "'sceNpScoreGetRankingByRange' aborted (0x%X).\n",
ret); ret);
delete[] ptr; delete[] ptr;
delete[] comments; delete[] comments;
delete[] npIds; delete[] npIds;
return false; return false;
} else if (ret == } else if (ret == SCE_NP_COMMUNITY_SERVER_ERROR_GAME_RANKING_NOT_FOUND) {
SCE_NP_COMMUNITY_SERVER_ERROR_GAME_RANKING_NOT_FOUND) { // 4J-JEV: Keep going, other batches might have scores.
// 4J-JEV: Keep going, other batches might have scores. } else if (ret < 0)
} else if (ret < 0) goto error3;
goto error3;
// Return.
destroyTransactionContext(m_requestId);
m_requestId = 0;
// Return.
destroyTransactionContext(m_requestId);
m_requestId = 0;
m_readCount = num; m_readCount = num;
@ -544,7 +542,7 @@ bool SonyLeaderboardManager::setScore() {
rscore.m_score, // IN: new score, rscore.m_score, // IN: new score,
&comment, // Comments &comment, // Comments
nullptr, // GameInfo nullptr, // GameInfo
&tmp, // OUT: current rank, &tmp, // OUT: current rank,

View file

@ -131,6 +131,5 @@ protected:
virtual int32_t fillByIdsQuery(const SceNpId& myNpId, SceNpId*& npIds, virtual int32_t fillByIdsQuery(const SceNpId& myNpId, SceNpId*& npIds,
uint32_t& len); uint32_t& len);
virtual char* getComment(SceNpScoreComment* comment) = 0; virtual char* getComment(SceNpScoreComment* comment) = 0;
}; };

View file

@ -37,44 +37,50 @@
#include <algorithm> #include <algorithm>
#include <stdexcept> #include <stdexcept>
// //
// Depending on the url parameter in base64_chars, one of // Depending on the url parameter in base64_chars, one of
// two sets of base64 characters needs to be chosen. // two sets of base64 characters needs to be chosen.
// They differ in their last two characters. // They differ in their last two characters.
// //
static const char* base64_chars[2] = { static const char* base64_chars[2] = {
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789" "0123456789"
"+/", "+/",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789" "0123456789"
"-_"}; "-_"};
static unsigned int pos_of_char(const unsigned char chr) { static unsigned int pos_of_char(const unsigned char chr) {
// //
// Return the position of chr within base64_encode() // Return the position of chr within base64_encode()
// //
if (chr >= 'A' && chr <= 'Z') return chr - 'A'; if (chr >= 'A' && chr <= 'Z')
else if (chr >= 'a' && chr <= 'z') return chr - 'a' + ('Z' - 'A') + 1; return chr - 'A';
else if (chr >= '0' && chr <= '9') return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2; else if (chr >= 'a' && chr <= 'z')
else if (chr == '+' || chr == '-') return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters ( return chr - 'a' + ('Z' - 'A') + 1;
else if (chr == '/' || chr == '_') return 63; // Ditto for '/' and '_' else if (chr >= '0' && chr <= '9')
return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2;
else if (chr == '+' || chr == '-')
return 62; // Be liberal with input and accept both url ('-') and
// non-url ('+') base 64 characters (
else if (chr == '/' || chr == '_')
return 63; // Ditto for '/' and '_'
else else
// //
// 2020-10-23: Throw std::exception rather than const char* // 2020-10-23: Throw std::exception rather than const char*
//(Pablo Martin-Gomez, https://github.com/Bouska) //(Pablo Martin-Gomez, https://github.com/Bouska)
// //
throw std::runtime_error("Input is not valid base64-encoded data."); throw std::runtime_error("Input is not valid base64-encoded data.");
} }
static std::string insert_linebreaks(std::string str, size_t distance) { static std::string insert_linebreaks(std::string str, size_t distance) {
// //
// Provided by https://github.com/JomaCorpFX, adapted by me. // Provided by https://github.com/JomaCorpFX, adapted by me.
// //
if (!str.length()) { if (!str.length()) {
return ""; return "";
} }
@ -91,39 +97,40 @@ static std::string insert_linebreaks(std::string str, size_t distance) {
template <typename String, unsigned int line_length> template <typename String, unsigned int line_length>
static std::string encode_with_line_breaks(String s) { static std::string encode_with_line_breaks(String s) {
return insert_linebreaks(base64_encode(s, false), line_length); return insert_linebreaks(base64_encode(s, false), line_length);
} }
template <typename String> template <typename String>
static std::string encode_pem(String s) { static std::string encode_pem(String s) {
return encode_with_line_breaks<String, 64>(s); return encode_with_line_breaks<String, 64>(s);
} }
template <typename String> template <typename String>
static std::string encode_mime(String s) { static std::string encode_mime(String s) {
return encode_with_line_breaks<String, 76>(s); return encode_with_line_breaks<String, 76>(s);
} }
template <typename String> template <typename String>
static std::string encode(String s, bool url) { static std::string encode(String s, bool url) {
return base64_encode(reinterpret_cast<const unsigned char*>(s.data()), s.length(), url); return base64_encode(reinterpret_cast<const unsigned char*>(s.data()),
s.length(), url);
} }
std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, bool url) { std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len,
bool url) {
size_t len_encoded = (in_len +2) / 3 * 4; size_t len_encoded = (in_len + 2) / 3 * 4;
unsigned char trailing_char = url ? '.' : '='; unsigned char trailing_char = url ? '.' : '=';
// //
// Choose set of base64 characters. They differ // Choose set of base64 characters. They differ
// for the last two positions, depending on the url // for the last two positions, depending on the url
// parameter. // parameter.
// A bool (as is the parameter url) is guaranteed // A bool (as is the parameter url) is guaranteed
// to evaluate to either 0 or 1 in C++ therefore, // to evaluate to either 0 or 1 in C++ therefore,
// the correct character set is chosen by subscripting // the correct character set is chosen by subscripting
// base64_chars with url. // base64_chars with url.
// //
const char* base64_chars_ = base64_chars[url]; const char* base64_chars_ = base64_chars[url];
std::string ret; std::string ret;
@ -134,21 +141,24 @@ std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, b
while (pos < in_len) { while (pos < in_len) {
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]); ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]);
if (pos+1 < in_len) { if (pos + 1 < in_len) {
ret.push_back(base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) + ((bytes_to_encode[pos + 1] & 0xf0) >> 4)]); ret.push_back(
base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) +
((bytes_to_encode[pos + 1] & 0xf0) >> 4)]);
if (pos+2 < in_len) { if (pos + 2 < in_len) {
ret.push_back(base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) + ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]); ret.push_back(
ret.push_back(base64_chars_[ bytes_to_encode[pos + 2] & 0x3f]); base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) +
} ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]);
else { ret.push_back(base64_chars_[bytes_to_encode[pos + 2] & 0x3f]);
ret.push_back(base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]); } else {
ret.push_back(trailing_char); ret.push_back(
} base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]);
} ret.push_back(trailing_char);
else { }
} else {
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]); ret.push_back(
base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]);
ret.push_back(trailing_char); ret.push_back(trailing_char);
ret.push_back(trailing_char); ret.push_back(trailing_char);
} }
@ -156,106 +166,110 @@ std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, b
pos += 3; pos += 3;
} }
return ret; return ret;
} }
template <typename String> template <typename String>
static std::string decode(String const& encoded_string, bool remove_linebreaks) { static std::string decode(String const& encoded_string,
// bool remove_linebreaks) {
// decode(…) is templated so that it can be used with String = const std::string& //
// or std::string_view (requires at least C++17) // decode(…) is templated so that it can be used with String = const
// // std::string& or std::string_view (requires at least C++17)
//
if (encoded_string.empty()) return std::string(); if (encoded_string.empty()) return std::string();
if (remove_linebreaks) { if (remove_linebreaks) {
std::string copy(encoded_string);
std::string copy(encoded_string); copy.erase(std::remove(copy.begin(), copy.end(), '\n'), copy.end());
copy.erase(std::remove(copy.begin(), copy.end(), '\n'), copy.end()); return base64_decode(copy, false);
return base64_decode(copy, false);
} }
size_t length_of_string = encoded_string.length(); size_t length_of_string = encoded_string.length();
size_t pos = 0; size_t pos = 0;
// //
// The approximate length (bytes) of the decoded string might be one or // The approximate length (bytes) of the decoded string might be one or
// two bytes smaller, depending on the amount of trailing equal signs // two bytes smaller, depending on the amount of trailing equal signs
// in the encoded string. This approximation is needed to reserve // in the encoded string. This approximation is needed to reserve
// enough space in the string to be returned. // enough space in the string to be returned.
// //
size_t approx_length_of_decoded_string = length_of_string / 4 * 3; size_t approx_length_of_decoded_string = length_of_string / 4 * 3;
std::string ret; std::string ret;
ret.reserve(approx_length_of_decoded_string); ret.reserve(approx_length_of_decoded_string);
while (pos < length_of_string) { while (pos < length_of_string) {
// //
// Iterate over encoded input string in chunks. The size of all // Iterate over encoded input string in chunks. The size of all
// chunks except the last one is 4 bytes. // chunks except the last one is 4 bytes.
// //
// The last chunk might be padded with equal signs or dots // The last chunk might be padded with equal signs or dots
// in order to make it 4 bytes in size as well, but this // in order to make it 4 bytes in size as well, but this
// is not required as per RFC 2045. // is not required as per RFC 2045.
// //
// All chunks except the last one produce three output bytes. // All chunks except the last one produce three output bytes.
// //
// The last chunk produces at least one and up to three bytes. // The last chunk produces at least one and up to three bytes.
// //
size_t pos_of_char_1 = pos_of_char(encoded_string.at(pos+1) ); size_t pos_of_char_1 = pos_of_char(encoded_string.at(pos + 1));
// //
// Emit the first output byte that is produced in each chunk: // Emit the first output byte that is produced in each chunk:
// //
ret.push_back(static_cast<std::string::value_type>( ( (pos_of_char(encoded_string.at(pos+0)) ) << 2 ) + ( (pos_of_char_1 & 0x30 ) >> 4))); ret.push_back(static_cast<std::string::value_type>(
((pos_of_char(encoded_string.at(pos + 0))) << 2) +
((pos_of_char_1 & 0x30) >> 4)));
if ( ( pos + 2 < length_of_string ) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045) if ((pos + 2 <
encoded_string.at(pos+2) != '=' && length_of_string) && // Check for data that is not padded with
encoded_string.at(pos+2) != '.' // accept URL-safe base 64 strings, too, so check for '.' also. // equal signs (which is allowed by RFC 2045)
) encoded_string.at(pos + 2) != '=' &&
{ encoded_string.at(pos + 2) !=
// '.' // accept URL-safe base 64 strings, too, so check for '.'
// Emit a chunk's second byte (which might not be produced in the last chunk). // also.
// ) {
unsigned int pos_of_char_2 = pos_of_char(encoded_string.at(pos+2) ); //
ret.push_back(static_cast<std::string::value_type>( (( pos_of_char_1 & 0x0f) << 4) + (( pos_of_char_2 & 0x3c) >> 2))); // Emit a chunk's second byte (which might not be produced in the
// last chunk).
//
unsigned int pos_of_char_2 =
pos_of_char(encoded_string.at(pos + 2));
ret.push_back(static_cast<std::string::value_type>(
((pos_of_char_1 & 0x0f) << 4) + ((pos_of_char_2 & 0x3c) >> 2)));
if ( ( pos + 3 < length_of_string ) && if ((pos + 3 < length_of_string) &&
encoded_string.at(pos+3) != '=' && encoded_string.at(pos + 3) != '=' &&
encoded_string.at(pos+3) != '.' encoded_string.at(pos + 3) != '.') {
) //
{ // Emit a chunk's third byte (which might not be produced in the
// // last chunk).
// Emit a chunk's third byte (which might not be produced in the last chunk). //
// ret.push_back(static_cast<std::string::value_type>(
ret.push_back(static_cast<std::string::value_type>( ( (pos_of_char_2 & 0x03 ) << 6 ) + pos_of_char(encoded_string.at(pos+3)) )); ((pos_of_char_2 & 0x03) << 6) +
} pos_of_char(encoded_string.at(pos + 3))));
} }
}
pos += 4; pos += 4;
} }
return ret; return ret;
} }
std::string base64_decode(std::string const& s, bool remove_linebreaks) { std::string base64_decode(std::string const& s, bool remove_linebreaks) {
return decode(s, remove_linebreaks); return decode(s, remove_linebreaks);
} }
std::string base64_encode(std::string const& s, bool url) { std::string base64_encode(std::string const& s, bool url) {
return encode(s, url); return encode(s, url);
} }
std::string base64_encode_pem (std::string const& s) { std::string base64_encode_pem(std::string const& s) { return encode_pem(s); }
return encode_pem(s);
}
std::string base64_encode_mime(std::string const& s) { std::string base64_encode_mime(std::string const& s) { return encode_mime(s); }
return encode_mime(s);
}
#if __cplusplus >= 201703L #if __cplusplus >= 201703L
// //
@ -265,19 +279,15 @@ std::string base64_encode_mime(std::string const& s) {
// //
std::string base64_encode(std::string_view s, bool url) { std::string base64_encode(std::string_view s, bool url) {
return encode(s, url); return encode(s, url);
} }
std::string base64_encode_pem(std::string_view s) { std::string base64_encode_pem(std::string_view s) { return encode_pem(s); }
return encode_pem(s);
}
std::string base64_encode_mime(std::string_view s) { std::string base64_encode_mime(std::string_view s) { return encode_mime(s); }
return encode_mime(s);
}
std::string base64_decode(std::string_view s, bool remove_linebreaks) { std::string base64_decode(std::string_view s, bool remove_linebreaks) {
return decode(s, remove_linebreaks); return decode(s, remove_linebreaks);
} }
#endif // __cplusplus >= 201703L #endif // __cplusplus >= 201703L

View file

@ -12,8 +12,8 @@
#include <string_view> #include <string_view>
#endif // __cplusplus >= 201703L #endif // __cplusplus >= 201703L
std::string base64_encode (std::string const& s, bool url = false); std::string base64_encode(std::string const& s, bool url = false);
std::string base64_encode_pem (std::string const& s); std::string base64_encode_pem(std::string const& s);
std::string base64_encode_mime(std::string const& s); std::string base64_encode_mime(std::string const& s);
std::string base64_decode(std::string const& s, bool remove_linebreaks = false); std::string base64_decode(std::string const& s, bool remove_linebreaks = false);
@ -25,8 +25,8 @@ std::string base64_encode(unsigned char const*, size_t len, bool url = false);
// Requires C++17 // Requires C++17
// Provided by Yannic Bonenberger (https://github.com/Yannic) // Provided by Yannic Bonenberger (https://github.com/Yannic)
// //
std::string base64_encode (std::string_view s, bool url = false); std::string base64_encode(std::string_view s, bool url = false);
std::string base64_encode_pem (std::string_view s); std::string base64_encode_pem(std::string_view s);
std::string base64_encode_mime(std::string_view s); std::string base64_encode_mime(std::string_view s);
std::string base64_decode(std::string_view s, bool remove_linebreaks = false); std::string base64_decode(std::string_view s, bool remove_linebreaks = false);

View file

@ -7,38 +7,56 @@
// 5 bits alpha // 5 bits alpha
// 1 bit decoration // 1 bit decoration
// 3 bits poptime // 3 bits poptime
// 8 bits unused // was 11 bits aux val but needed 15 bits for potions so moved to item bitmask // 8 bits unused // was 11 bits aux val but needed 15 bits for potions so moved
// 6 bits count // to item bitmask 6 bits count 6 bits scale
// 6 bits scale
// uiCount is up to 64, but can't ever be 0, so to make it 6 bits, subtract one from the packing, and add one on the unpacking // uiCount is up to 64, but can't ever be 0, so to make it 6 bits, subtract one
#define MAKE_SLOTDISPLAY_DATA_BITMASK(uiUserIndex,uiAlpha,bDecorations,uiCount,uiScale,uiPopTime) ((((uiUserIndex&0x7)<<29) | (uiAlpha&0x1F)<<24) | (bDecorations?0x800000:0) | ((uiPopTime&0x7)<<20) | ((uiCount-1)<<6) | (uiScale&0x3F)) // from the packing, and add one on the unpacking
#define MAKE_SLOTDISPLAY_DATA_BITMASK(uiUserIndex, uiAlpha, bDecorations, \
uiCount, uiScale, uiPopTime) \
((((uiUserIndex & 0x7) << 29) | (uiAlpha & 0x1F) << 24) | \
(bDecorations ? 0x800000 : 0) | ((uiPopTime & 0x7) << 20) | \
((uiCount - 1) << 6) | (uiScale & 0x3F))
#define GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>29)&0x7) #define GET_SLOTDISPLAY_USERINDEX_FROM_DATA_BITMASK(uiBitmask) \
#define GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>24)&0x1F) ((((unsigned int)uiBitmask) >> 29) & 0x7)
#define GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)&0x800000)?true:false) #define GET_SLOTDISPLAY_ALPHA_FROM_DATA_BITMASK(uiBitmask) \
//#define GET_SLOTDISPLAY_AUXVAL_FROM_DATA_BITMASK(uiBitmask) ((((unsigned long)uiBitmask)>>12)&0x7FF) ((((unsigned int)uiBitmask) >> 24) & 0x1F)
#define GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(uiBitmask) (((((unsigned int)uiBitmask)>>6)&0x3F)+1) #define GET_SLOTDISPLAY_DECORATIONS_FROM_DATA_BITMASK(uiBitmask) \
#define GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(uiBitmask) (((unsigned int)uiBitmask)&0x3F) ((((unsigned int)uiBitmask) & 0x800000) ? true : false)
#define GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>20)&0x7) // #define GET_SLOTDISPLAY_AUXVAL_FROM_DATA_BITMASK(uiBitmask)
// ((((unsigned long)uiBitmask)>>12)&0x7FF)
#define GET_SLOTDISPLAY_COUNT_FROM_DATA_BITMASK(uiBitmask) \
(((((unsigned int)uiBitmask) >> 6) & 0x3F) + 1)
#define GET_SLOTDISPLAY_SCALE_FROM_DATA_BITMASK(uiBitmask) \
(((unsigned int)uiBitmask) & 0x3F)
#define GET_SLOTDISPLAY_POPTIME_FROM_DATA_BITMASK(uiBitmask) \
((((unsigned int)uiBitmask) >> 20) & 0x7)
// 16 bits for id (either item id or xzp icon id) // 16 bits for id (either item id or xzp icon id)
// 15 bits for aux value // 15 bits for aux value
// 1 bit for foil // 1 bit for foil
#define MAKE_SLOTDISPLAY_ITEM_BITMASK(uiId,uiAuxValue,bFoil) ( (uiId & 0xFFFF) | ((uiAuxValue & 0x7FFF) << 16) | (bFoil?0x80000000:0) ) #define MAKE_SLOTDISPLAY_ITEM_BITMASK(uiId, uiAuxValue, bFoil) \
((uiId & 0xFFFF) | ((uiAuxValue & 0x7FFF) << 16) | (bFoil ? 0x80000000 : 0))
#define GET_SLOTDISPLAY_ID_FROM_ITEM_BITMASK(uiBitmask) (((unsigned int)uiBitmask)&0xFFFF)
#define GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)>>16) & 0x7FFF)
#define GET_SLOTDISPLAY_FOIL_FROM_ITEM_BITMASK(uiBitmask) ((((unsigned int)uiBitmask)&0x80000000)?true:false)
#define GET_SLOTDISPLAY_ID_FROM_ITEM_BITMASK(uiBitmask) \
(((unsigned int)uiBitmask) & 0xFFFF)
#define GET_SLOTDISPLAY_AUXVAL_FROM_ITEM_BITMASK(uiBitmask) \
((((unsigned int)uiBitmask) >> 16) & 0x7FFF)
#define GET_SLOTDISPLAY_FOIL_FROM_ITEM_BITMASK(uiBitmask) \
((((unsigned int)uiBitmask) & 0x80000000) ? true : false)
// For encoding the players skin selection in their profile // For encoding the players skin selection in their profile
// bDlcSkin = false is a players skin, bDlcSkin = true is a DLC skin // bDlcSkin = false is a players skin, bDlcSkin = true is a DLC skin
#define MAKE_SKIN_BITMASK(bDlcSkin, dwSkinId) ( (bDlcSkin?0x80000000:0) | (dwSkinId & 0x7FFFFFFF) ) #define MAKE_SKIN_BITMASK(bDlcSkin, dwSkinId) \
((bDlcSkin ? 0x80000000 : 0) | (dwSkinId & 0x7FFFFFFF))
#define IS_SKIN_ID_IN_RANGE(dwSkinId) (dwSkinId <= 0x7FFFFFFF) #define IS_SKIN_ID_IN_RANGE(dwSkinId) (dwSkinId <= 0x7FFFFFFF)
#define GET_DLC_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast<std::uint32_t>(uiBitmask) & 0x7FFFFFFF) #define GET_DLC_SKIN_ID_FROM_BITMASK(uiBitmask) \
#define GET_UGC_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast<std::uint32_t>(uiBitmask) & 0x7FFFFFE0) (static_cast<std::uint32_t>(uiBitmask) & 0x7FFFFFFF)
#define GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiBitmask) (static_cast<std::uint32_t>(uiBitmask) & 0x0000001F) #define GET_UGC_SKIN_ID_FROM_BITMASK(uiBitmask) \
#define GET_IS_DLC_SKIN_FROM_BITMASK(uiBitmask) ((static_cast<std::uint32_t>(uiBitmask) & 0x80000000) ? true : false) (static_cast<std::uint32_t>(uiBitmask) & 0x7FFFFFE0)
#define GET_DEFAULT_SKIN_ID_FROM_BITMASK(uiBitmask) \
(static_cast<std::uint32_t>(uiBitmask) & 0x0000001F)
#define GET_IS_DLC_SKIN_FROM_BITMASK(uiBitmask) \
((static_cast<std::uint32_t>(uiBitmask) & 0x80000000) ? true : false)

View file

@ -34,7 +34,6 @@
#include "../UI/UI.h" #include "../UI/UI.h"
#include "../UI/UIScene_PauseMenu.h" #include "../UI/UIScene_PauseMenu.h"
// Global instance // Global instance
CGameNetworkManager g_NetworkManager; CGameNetworkManager g_NetworkManager;
CPlatformNetworkManager* CGameNetworkManager::s_pPlatformNetworkManager; CPlatformNetworkManager* CGameNetworkManager::s_pPlatformNetworkManager;
@ -47,7 +46,6 @@ CGameNetworkManager::CGameNetworkManager() {
m_bInitialised = false; m_bInitialised = false;
m_bLastDisconnectWasLostRoomOnly = false; m_bLastDisconnectWasLostRoomOnly = false;
m_bFullSessionMessageOnNextSessionChange = false; m_bFullSessionMessageOnNextSessionChange = false;
} }
void CGameNetworkManager::Initialise() { void CGameNetworkManager::Initialise() {
@ -69,10 +67,7 @@ void CGameNetworkManager::Terminate() {
} }
} }
void CGameNetworkManager::DoWork() { void CGameNetworkManager::DoWork() { s_pPlatformNetworkManager->DoWork(); }
s_pPlatformNetworkManager->DoWork();
}
bool CGameNetworkManager::_RunNetworkGame(void* lpParameter) { bool CGameNetworkManager::_RunNetworkGame(void* lpParameter) {
bool success = true; bool success = true;
@ -113,7 +108,6 @@ bool CGameNetworkManager::_RunNetworkGame(void* lpParameter) {
bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
void* lpParameter) { void* lpParameter) {
int64_t seed = 0; int64_t seed = 0;
if (lpParameter != nullptr) { if (lpParameter != nullptr) {
NetworkGameInitData* param = (NetworkGameInitData*)lpParameter; NetworkGameInitData* param = (NetworkGameInitData*)lpParameter;
@ -156,13 +150,13 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need 0, // share mode // TODO 4J Stu - Will we need
// to share file? Probably not but... // to share file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu OPEN_EXISTING, // how to create // TODO 4J Stu
// - Assuming that the file // - Assuming that the file
// already exists if we are // already exists if we are
// opening to read from it // opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#else #else
const char* pchFilename = const char* pchFilename =
@ -172,20 +166,21 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
GENERIC_READ, // access mode GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need 0, // share mode // TODO 4J Stu - Will we need
// to share file? Probably not but... // to share file? Probably not but...
nullptr, // Unused nullptr, // Unused
OPEN_EXISTING, // how to create // TODO 4J Stu OPEN_EXISTING, // how to create // TODO 4J Stu
// - Assuming that the file // - Assuming that the file
// already exists if we are // already exists if we are
// opening to read from it // opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
nullptr // Unsupported nullptr // Unsupported
); );
#endif #endif
if (fileHandle != INVALID_HANDLE_VALUE) { if (fileHandle != INVALID_HANDLE_VALUE) {
uint32_t bytesRead, uint32_t bytesRead, dwFileSize = GetFileSize(
dwFileSize = GetFileSize(fileHandle, nullptr); fileHandle, nullptr);
uint8_t* pbData = (uint8_t*) new uint8_t[dwFileSize]; uint8_t* pbData =
(uint8_t*)new uint8_t[dwFileSize];
bool bSuccess = bool bSuccess =
ReadFile(fileHandle, pbData, dwFileSize, ReadFile(fileHandle, pbData, dwFileSize,
&bytesRead, nullptr); &bytesRead, nullptr);
@ -483,7 +478,7 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
} else { } else {
connection->close(); connection->close();
auto it = find(createdConnections.begin(), auto it = find(createdConnections.begin(),
createdConnections.end(), connection); createdConnections.end(), connection);
if (it != createdConnections.end()) if (it != createdConnections.end())
createdConnections.erase(it); createdConnections.erase(it);
} }
@ -552,7 +547,6 @@ INetworkPlayer* CGameNetworkManager::GetPlayerBySmallId(unsigned char smallId) {
return s_pPlatformNetworkManager->GetPlayerBySmallId(smallId); return s_pPlatformNetworkManager->GetPlayerBySmallId(smallId);
} }
INetworkPlayer* CGameNetworkManager::GetHostPlayer() { INetworkPlayer* CGameNetworkManager::GetHostPlayer() {
return s_pPlatformNetworkManager->GetHostPlayer(); return s_pPlatformNetworkManager->GetHostPlayer();
} }
@ -689,8 +683,7 @@ CGameNetworkManager::eJoinGameResult CGameNetworkManager::JoinGame(
searchResult, localUsersMask, primaryUserIndex)); searchResult, localUsersMask, primaryUserIndex));
} }
void CGameNetworkManager::CancelJoinGame(void* lpParam) { void CGameNetworkManager::CancelJoinGame(void* lpParam) {}
}
bool CGameNetworkManager::LeaveGame(bool bMigrateHost) { bool CGameNetworkManager::LeaveGame(bool bMigrateHost) {
Minecraft::GetInstance()->gui->clearMessages(); Minecraft::GetInstance()->gui->clearMessages();
@ -703,7 +696,6 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void* pParam,
INVITE_INFO* pInviteInfo = (INVITE_INFO*)pParam; INVITE_INFO* pInviteInfo = (INVITE_INFO*)pParam;
if (bContinue == true) { if (bContinue == true) {
app.DebugPrintf("JoinFromInvite_SignInReturned, iPad %d\n", iPad); app.DebugPrintf("JoinFromInvite_SignInReturned, iPad %d\n", iPad);
// It's possible that the player has not signed in - they can back out // It's possible that the player has not signed in - they can back out
if (ProfileManager.IsSignedIn(iPad) && if (ProfileManager.IsSignedIn(iPad) &&
@ -833,7 +825,6 @@ int CGameNetworkManager::RunNetworkGameThreadProc(void* lpParameter) {
return -1; return -1;
} }
Tile::ReleaseThreadStorage(); Tile::ReleaseThreadStorage();
return 0; return 0;
} }
@ -899,7 +890,6 @@ int CGameNetworkManager::ExitAndJoinFromInviteThreadProc(void* lpParam) {
return S_OK; return S_OK;
} }
void CGameNetworkManager::_LeaveGame() { void CGameNetworkManager::_LeaveGame() {
s_pPlatformNetworkManager->_LeaveGame(false, true); s_pPlatformNetworkManager->_LeaveGame(false, true);
} }
@ -912,10 +902,10 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) {
Minecraft* pMinecraft = Minecraft::GetInstance(); Minecraft* pMinecraft = Minecraft::GetInstance();
MinecraftServer* pServer = MinecraftServer::getInstance(); MinecraftServer* pServer = MinecraftServer::getInstance();
pMinecraft->progressRenderer->progressStartNoAbort( pMinecraft->progressRenderer->progressStartNoAbort(
g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT)); g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT));
pMinecraft->progressRenderer->progressStage( pMinecraft->progressRenderer->progressStage(
IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME); IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME);
while (app.GetXuiServerAction(ProfileManager.GetPrimaryPad()) != while (app.GetXuiServerAction(ProfileManager.GetPrimaryPad()) !=
eXuiServerAction_Idle && eXuiServerAction_Idle &&
@ -928,20 +918,19 @@ int CGameNetworkManager::ChangeSessionTypeThreadProc(void* lpParam) {
// wait for the server to be in a non-ticking state // wait for the server to be in a non-ticking state
pServer->m_serverPausedEvent->WaitForSignal(INFINITE); pServer->m_serverPausedEvent->WaitForSignal(INFINITE);
pMinecraft->progressRenderer->progressStartNoAbort( pMinecraft->progressRenderer->progressStartNoAbort(
g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT)); g_NetworkManager.CorrectErrorIDS(IDS_CONNECTION_LOST_LIVE_NO_EXIT));
pMinecraft->progressRenderer->progressStage( pMinecraft->progressRenderer->progressStage(
IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME); IDS_PROGRESS_CONVERTING_TO_OFFLINE_GAME);
pMinecraft->progressRenderer->progressStagePercentage(25); pMinecraft->progressRenderer->progressStagePercentage(25);
// Null the network player of all the server players that are local, to stop // Null the network player of all the server players that are local, to stop
// them being removed from the server when removed from the session // them being removed from the server when removed from the session
if (pServer != nullptr) { if (pServer != nullptr) {
PlayerList* players = pServer->getPlayers(); PlayerList* players = pServer->getPlayers();
for (auto it = players->players.begin(); for (auto it = players->players.begin(); it < players->players.end();
it < players->players.end(); ++it) { ++it) {
std::shared_ptr<ServerPlayer> servPlayer = *it; std::shared_ptr<ServerPlayer> servPlayer = *it;
if (servPlayer->connection->isLocal() && if (servPlayer->connection->isLocal() &&
!servPlayer->connection->isGuest()) { !servPlayer->connection->isGuest()) {
@ -1073,8 +1062,7 @@ std::wstring CGameNetworkManager::GatherStats() {
return s_pPlatformNetworkManager->GatherStats(); return s_pPlatformNetworkManager->GatherStats();
} }
void CGameNetworkManager::renderQueueMeter() { void CGameNetworkManager::renderQueueMeter() {}
}
std::wstring CGameNetworkManager::GatherRTTStats() { std::wstring CGameNetworkManager::GatherRTTStats() {
return s_pPlatformNetworkManager->GatherRTTStats(); return s_pPlatformNetworkManager->GatherRTTStats();
@ -1125,7 +1113,6 @@ void CGameNetworkManager::StateChange_JoiningToIdle(
} }
void CGameNetworkManager::StateChange_AnyToStarting() { void CGameNetworkManager::StateChange_AnyToStarting() {
if (!g_NetworkManager.IsHost()) { if (!g_NetworkManager.IsHost()) {
LoadingInputParams* loadingParams = new LoadingInputParams(); LoadingInputParams* loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
@ -1321,7 +1308,8 @@ void CGameNetworkManager::GameInviteReceived(int userIndex,
// except for the invited player (who may be an inactive player) 4J // except for the invited player (who may be an inactive player) 4J
// Stu - If we are not in a game, then bring in all players signed // Stu - If we are not in a game, then bring in all players signed
// in // in
if (index == userIndex || pMinecraft->localplayers[index] != nullptr) { if (index == userIndex ||
pMinecraft->localplayers[index] != nullptr) {
++joiningUsers; ++joiningUsers;
if (!ProfileManager.AllowedToPlayMultiplayer(index)) if (!ProfileManager.AllowedToPlayMultiplayer(index))
noPrivileges = true; noPrivileges = true;
@ -1340,16 +1328,14 @@ void CGameNetworkManager::GameInviteReceived(int userIndex,
ProfileManager.GetPrimaryPad(), false, &pccAllowed, &pccFriendsAllowed); ProfileManager.GetPrimaryPad(), false, &pccAllowed, &pccFriendsAllowed);
if (!pccAllowed && !pccFriendsAllowed) noUGC = true; if (!pccAllowed && !pccFriendsAllowed) noUGC = true;
if (noUGC) {
if (noUGC) {
int messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL; int messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
if (joiningUsers > 1) if (joiningUsers > 1)
messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL; messageText = IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
ui.RequestUGCMessageBox(IDS_CONNECTION_FAILED, messageText, ui.RequestUGCMessageBox(IDS_CONNECTION_FAILED, messageText,
XUSER_INDEX_ANY); XUSER_INDEX_ANY);
} } else if (noPrivileges) {
else if (noPrivileges) {
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
@ -1389,7 +1375,6 @@ void CGameNetworkManager::HandleInviteWhenInMenus(
int userIndex, const INVITE_INFO* pInviteInfo) { int userIndex, const INVITE_INFO* pInviteInfo) {
// We are in the root menus somewhere // We are in the root menus somewhere
// if this is the trial game, then we need the user to unlock the full game // if this is the trial game, then we need the user to unlock the full game
if (!ProfileManager.IsFullVersion()) { if (!ProfileManager.IsFullVersion()) {
// The marketplace will fail with the primary player set to -1 // The marketplace will fail with the primary player set to -1
@ -1411,8 +1396,7 @@ void CGameNetworkManager::HandleInviteWhenInMenus(
// as the main player might sign out in the sign-in ui // as the main player might sign out in the sign-in ui
// ProfileManager.SetLockedProfile(-1); // ProfileManager.SetLockedProfile(-1);
if (!app.IsLocalMultiplayerAvailable()) if (!app.IsLocalMultiplayerAvailable()) {
{
bool noPrivileges = bool noPrivileges =
!ProfileManager.AllowedToPlayMultiplayer(userIndex); !ProfileManager.AllowedToPlayMultiplayer(userIndex);
@ -1473,8 +1457,7 @@ void CGameNetworkManager::AddLocalPlayerFailed(int idx,
: DisconnectPacket::eDisconnect_ConnectionCreationFailed); : DisconnectPacket::eDisconnect_ConnectionCreationFailed);
} }
void CGameNetworkManager::HandleDisconnect(bool bLostRoomOnly) void CGameNetworkManager::HandleDisconnect(bool bLostRoomOnly) {
{
int iPrimaryPlayer = g_NetworkManager.GetPrimaryPad(); int iPrimaryPlayer = g_NetworkManager.GetPrimaryPad();
if ((g_NetworkManager.GetLockedProfile() != -1) && iPrimaryPlayer != -1 && if ((g_NetworkManager.GetLockedProfile() != -1) && iPrimaryPlayer != -1 &&
@ -1600,4 +1583,3 @@ int CGameNetworkManager::GetJoiningReadyPercentage() {
void CGameNetworkManager::FakeLocalPlayerJoined() { void CGameNetworkManager::FakeLocalPlayerJoined() {
s_pPlatformNetworkManager->FakeLocalPlayerJoined(); s_pPlatformNetworkManager->FakeLocalPlayerJoined();
} }

View file

@ -22,6 +22,7 @@ const int NON_QNET_SENDDATA_ACK_REQUIRED = 1;
class CGameNetworkManager { class CGameNetworkManager {
friend class CPlatformNetworkManagerStub; friend class CPlatformNetworkManagerStub;
public: public:
CGameNetworkManager(); CGameNetworkManager();
// Misc high level flow // Misc high level flow
@ -122,7 +123,6 @@ public:
static int ServerThreadProc(void* lpParameter); static int ServerThreadProc(void* lpParameter);
static int ExitAndJoinFromInviteThreadProc(void* lpParam); static int ExitAndJoinFromInviteThreadProc(void* lpParam);
static void _LeaveGame(); static void _LeaveGame();
static int ChangeSessionTypeThreadProc(void* lpParam); static int ChangeSessionTypeThreadProc(void* lpParam);
@ -133,11 +133,12 @@ public:
// Events // Events
void ServerReadyCreate(bool create); // Create the signal (or set to nullptr) void ServerReadyCreate(
void ServerReady(); // Signal that we are ready bool create); // Create the signal (or set to nullptr)
void ServerReadyWait(); // Wait for the signal void ServerReady(); // Signal that we are ready
void ServerReadyDestroy(); // Destroy signal void ServerReadyWait(); // Wait for the signal
bool ServerReadyValid(); // Is non-nullptr void ServerReadyDestroy(); // Destroy signal
bool ServerReadyValid(); // Is non-nullptr
void ServerStoppedCreate(bool create); // Create the signal void ServerStoppedCreate(bool create); // Create the signal
void ServerStopped(); // Signal that we are ready void ServerStopped(); // Signal that we are ready
@ -204,4 +205,3 @@ public:
}; };
extern CGameNetworkManager g_NetworkManager; extern CGameNetworkManager g_NetworkManager;

View file

@ -141,5 +141,4 @@ public:
virtual void FakeLocalPlayerJoined() { virtual void FakeLocalPlayerJoined() {
}; // Temporary method whilst we don't have real networking to make this }; // Temporary method whilst we don't have real networking to make this
// happen // happen
}; };

View file

@ -292,8 +292,8 @@ void CPlatformNetworkManagerStub::UpdateAndSetGameSessionData(
// INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i); // INetworkPlayer *pNetworkPlayer = GetPlayerByIndex(i);
// //
// // We can call this from NotifyPlayerLeaving but at that // // We can call this from NotifyPlayerLeaving but at that
// point the player is still considered in the session if( pNetworkPlayer != // point the player is still considered in the session
// pNetworkPlayerLeaving ) // if( pNetworkPlayer != pNetworkPlayerLeaving )
// { // {
// m_hostGameSessionData.players[i] = // m_hostGameSessionData.players[i] =
// ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID(); // ((NetworkPlayerXbox *)pNetworkPlayer)->GetUID();

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
// A struct that we store in the QoS data when we are hosting the session. Max // A struct that we store in the QoS data when we are hosting the session. Max
// size 1020 bytes. // size 1020 bytes.
typedef struct _GameSessionData { typedef struct _GameSessionData {

View file

@ -3,52 +3,59 @@
// 4J-JEV: // 4J-JEV:
// All functional potions need bit-13 set. // All functional potions need bit-13 set.
#define MASK_REGENERATION 0x2001 #define MASK_REGENERATION 0x2001
#define MASK_SPEED 0x2002 #define MASK_SPEED 0x2002
#define MASK_FIRE_RESISTANCE 0x2003 #define MASK_FIRE_RESISTANCE 0x2003
#define MASK_POISON 0x2004 #define MASK_POISON 0x2004
#define MASK_INSTANTHEALTH 0x2005 #define MASK_INSTANTHEALTH 0x2005
#define MASK_NIGHTVISION 0x2006 #define MASK_NIGHTVISION 0x2006
#define MASK_INVISIBILITY 0x200E #define MASK_INVISIBILITY 0x200E
#define MASK_WEAKNESS 0x2008 #define MASK_WEAKNESS 0x2008
#define MASK_STRENGTH 0x2009 #define MASK_STRENGTH 0x2009
#define MASK_SLOWNESS 0x200A #define MASK_SLOWNESS 0x200A
#define MASK_INSTANTDAMAGE 0x200C #define MASK_INSTANTDAMAGE 0x200C
#define MASK_TYPE_AWKWARD 0x0010 #define MASK_TYPE_AWKWARD 0x0010
#define MASK_SPLASH 0x4000 #define MASK_SPLASH 0x4000
#define MASK_BIT13 0x2000 #define MASK_BIT13 0x2000
#define MASK_LEVEL2 0x0020 #define MASK_LEVEL2 0x0020
#define MASK_EXTENDED 0x0040 #define MASK_EXTENDED 0x0040
#define MASK_LEVEL2EXTENDED 0x0060 #define MASK_LEVEL2EXTENDED 0x0060
#define MACRO_POTION_IS_REGENERATION(aux) ((aux & 0x200F) == MASK_REGENERATION) #define MACRO_POTION_IS_REGENERATION(aux) ((aux & 0x200F) == MASK_REGENERATION)
#define MACRO_POTION_IS_SPEED(aux) ((aux & 0x200F) == MASK_SPEED) #define MACRO_POTION_IS_SPEED(aux) ((aux & 0x200F) == MASK_SPEED)
#define MACRO_POTION_IS_FIRE_RESISTANCE(aux) ((aux & 0x200F) == MASK_FIRE_RESISTANCE) #define MACRO_POTION_IS_FIRE_RESISTANCE(aux) \
#define MACRO_POTION_IS_INSTANTHEALTH(aux) ((aux & 0x200F) == MASK_INSTANTHEALTH) ((aux & 0x200F) == MASK_FIRE_RESISTANCE)
#define MACRO_POTION_IS_NIGHTVISION(aux) ((aux & 0x200F) == MASK_NIGHTVISION) #define MACRO_POTION_IS_INSTANTHEALTH(aux) \
#define MACRO_POTION_IS_INVISIBILITY(aux) ((aux & 0x200F) == MASK_INVISIBILITY) ((aux & 0x200F) == MASK_INSTANTHEALTH)
#define MACRO_POTION_IS_WEAKNESS(aux) ((aux & 0x200F) == MASK_WEAKNESS) #define MACRO_POTION_IS_NIGHTVISION(aux) ((aux & 0x200F) == MASK_NIGHTVISION)
#define MACRO_POTION_IS_STRENGTH(aux) ((aux & 0x200F) == MASK_STRENGTH) #define MACRO_POTION_IS_INVISIBILITY(aux) ((aux & 0x200F) == MASK_INVISIBILITY)
#define MACRO_POTION_IS_SLOWNESS(aux) ((aux & 0x200F) == MASK_SLOWNESS) #define MACRO_POTION_IS_WEAKNESS(aux) ((aux & 0x200F) == MASK_WEAKNESS)
#define MACRO_POTION_IS_POISON(aux) ((aux & 0x200F) == MASK_POISON) #define MACRO_POTION_IS_STRENGTH(aux) ((aux & 0x200F) == MASK_STRENGTH)
#define MACRO_POTION_IS_INSTANTDAMAGE(aux) ((aux & 0x200F) == MASK_INSTANTDAMAGE) #define MACRO_POTION_IS_SLOWNESS(aux) ((aux & 0x200F) == MASK_SLOWNESS)
#define MACRO_POTION_IS_POISON(aux) ((aux & 0x200F) == MASK_POISON)
#define MACRO_POTION_IS_INSTANTDAMAGE(aux) \
((aux & 0x200F) == MASK_INSTANTDAMAGE)
#define MACRO_POTION_IS_SPLASH(aux) ((aux & MASK_SPLASH) == MASK_SPLASH) #define MACRO_POTION_IS_SPLASH(aux) ((aux & MASK_SPLASH) == MASK_SPLASH)
#define MACRO_POTION_IS_BOTTLE(aux) ((aux & MASK_SPLASH) == 0) #define MACRO_POTION_IS_BOTTLE(aux) ((aux & MASK_SPLASH) == 0)
#define MACRO_POTION_IS_AKWARD(aux) ((aux & MASK_TYPE_AWKWARD) == MASK_TYPE_AWKWARD) #define MACRO_POTION_IS_AKWARD(aux) \
((aux & MASK_TYPE_AWKWARD) == MASK_TYPE_AWKWARD)
#define MACRO_POTION_IS_REGULAR(aux) ((aux & (MASK_LEVEL2EXTENDED)) == 0) #define MACRO_POTION_IS_REGULAR(aux) ((aux & (MASK_LEVEL2EXTENDED)) == 0)
#define MACRO_POTION_IS_LEVEL2(aux) ((aux & (MASK_LEVEL2 )) == MASK_LEVEL2) #define MACRO_POTION_IS_LEVEL2(aux) ((aux & (MASK_LEVEL2)) == MASK_LEVEL2)
#define MACRO_POTION_IS_EXTENDED(aux) ((aux & (MASK_EXTENDED)) == (MASK_EXTENDED)) #define MACRO_POTION_IS_EXTENDED(aux) \
#define MACRO_POTION_IS_LEVEL2EXTENDED(aux) ((aux & (MASK_LEVEL2EXTENDED)) == (MASK_LEVEL2EXTENDED)) ((aux & (MASK_EXTENDED)) == (MASK_EXTENDED))
#define MACRO_POTION_IS_LEVEL2EXTENDED(aux) \
((aux & (MASK_LEVEL2EXTENDED)) == (MASK_LEVEL2EXTENDED))
#define MACRO_MAKEPOTION_AUXVAL(potion_type, potion_strength, potion_effect) \
(potion_type | potion_strength | potion_effect)
#define MACRO_MAKEPOTION_AUXVAL(potion_type, potion_strength, potion_effect) (potion_type | potion_strength | potion_effect) // The potion brewing creates high aux values with redundant high bits, so use
// this to bring the aux val into ranges that match our macros 4J-JEV: 0x2000 ==
// The potion brewing creates high aux values with redundant high bits, so use this to bring the aux val into ranges that match our macros // bit-13; Used to stop netherwart "resetting" functional potions.
// 4J-JEV: 0x2000 == bit-13; Used to stop netherwart "resetting" functional potions.
#define NORMALISE_POTION_AUXVAL(aux) (aux & (MASK_BIT13 | MASK_SPLASH | 0xFF)) #define NORMALISE_POTION_AUXVAL(aux) (aux & (MASK_BIT13 | MASK_SPLASH | 0xFF))

View file

@ -9,7 +9,7 @@
#include "../../../Minecraft.World/Util/C4JThread.h" #include "../../../Minecraft.World/Util/C4JThread.h"
class ShutdownManager { class ShutdownManager {
public: public:
enum EThreadId { enum EThreadId {
eMainThread, eMainThread,
eLeaderboardThread, eLeaderboardThread,
@ -36,7 +36,7 @@ class ShutdownManager {
static bool ShouldRun(EThreadId threadId); static bool ShouldRun(EThreadId threadId);
static void HasFinished(EThreadId threadId); static void HasFinished(EThreadId threadId);
private: private:
struct GroupState { struct GroupState {
std::size_t started = 0; std::size_t started = 0;
std::size_t running = 0; std::size_t running = 0;

View file

@ -8,435 +8,396 @@
#include "TelemetryManager.h" #include "TelemetryManager.h"
CTelemetryManager* TelemetryManager = new CTelemetryManager();
CTelemetryManager *TelemetryManager = new CTelemetryManager(); int32_t CTelemetryManager::Init() { return 0; }
int32_t CTelemetryManager::Tick() { return 0; }
int32_t CTelemetryManager::Init() int32_t CTelemetryManager::Flush() { return 0; }
{
return 0; bool CTelemetryManager::RecordPlayerSessionStart(int iPad) { return true; }
bool CTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus) {
return true;
} }
int32_t CTelemetryManager::Tick() bool CTelemetryManager::RecordHeartBeat(int iPad) { return true; }
{
return 0; bool CTelemetryManager::RecordLevelStart(int iPad,
ESen_FriendOrMatch friendsOrMatch,
ESen_CompeteOrCoop competeOrCoop,
int difficulty,
int numberOfLocalPlayers,
int numberOfOnlinePlayers) {
if (iPad == ProfileManager.GetPrimaryPad()) m_bFirstFlush = true;
++m_levelInstanceID;
m_fLevelStartTime[iPad] = app.getAppTime();
return true;
} }
int32_t CTelemetryManager::Flush() bool CTelemetryManager::RecordLevelExit(int iPad,
{ ESen_LevelExitStatus levelExitStatus) {
return 0; return true;
} }
bool CTelemetryManager::RecordPlayerSessionStart(int iPad) bool CTelemetryManager::RecordLevelSaveOrCheckpoint(int iPad,
{ int saveOrCheckPointID,
return true; int saveSizeInBytes) {
return true;
} }
bool CTelemetryManager::RecordPlayerSessionExit(int iPad, int exitStatus) bool CTelemetryManager::RecordLevelResume(
{ int iPad, ESen_FriendOrMatch friendsOrMatch,
return true; ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers,
int numberOfOnlinePlayers, int saveOrCheckPointID) {
return true;
} }
bool CTelemetryManager::RecordHeartBeat(int iPad) bool CTelemetryManager::RecordPauseOrInactive(int iPad) { return true; }
{
return true; bool CTelemetryManager::RecordUnpauseOrActive(int iPad) { return true; }
bool CTelemetryManager::RecordMenuShown(int iPad, EUIScene menuID,
int optionalMenuSubID) {
return true;
} }
bool CTelemetryManager::RecordLevelStart(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers) bool CTelemetryManager::RecordAchievementUnlocked(int iPad, int achievementID,
{ int achievementGamerscore) {
if(iPad == ProfileManager.GetPrimaryPad() ) m_bFirstFlush = true; return true;
++m_levelInstanceID;
m_fLevelStartTime[iPad] = app.getAppTime();
return true;
} }
bool CTelemetryManager::RecordLevelExit(int iPad, ESen_LevelExitStatus levelExitStatus) bool CTelemetryManager::RecordMediaShareUpload(
{ int iPad, ESen_MediaDestination mediaDestination,
return true; ESen_MediaType mediaType) {
return true;
} }
bool CTelemetryManager::RecordLevelSaveOrCheckpoint(int iPad, int saveOrCheckPointID, int saveSizeInBytes) bool CTelemetryManager::RecordUpsellPresented(int iPad, ESen_UpsellID upsellId,
{ int marketplaceOfferID) {
return true; return true;
} }
bool CTelemetryManager::RecordLevelResume(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers, int saveOrCheckPointID) bool CTelemetryManager::RecordUpsellResponded(
{ int iPad, ESen_UpsellID upsellId, int marketplaceOfferID,
return true; ESen_UpsellOutcome upsellOutcome) {
return true;
} }
bool CTelemetryManager::RecordPauseOrInactive(int iPad) bool CTelemetryManager::RecordPlayerDiedOrFailed(
{ int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID,
return true; int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID) {
return true;
} }
bool CTelemetryManager::RecordUnpauseOrActive(int iPad) bool CTelemetryManager::RecordEnemyKilledOrOvercome(
{ int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID,
return true; int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID) {
return true;
} }
bool CTelemetryManager::RecordMenuShown(int iPad, EUIScene menuID, int optionalMenuSubID) bool CTelemetryManager::RecordTexturePackLoaded(int iPad, int texturePackId,
{ bool purchased) {
return true; return true;
} }
bool CTelemetryManager::RecordAchievementUnlocked(int iPad, int achievementID, int achievementGamerscore) bool CTelemetryManager::RecordSkinChanged(int iPad, int dwSkinId) {
{ return true;
return true;
} }
bool CTelemetryManager::RecordMediaShareUpload(int iPad, ESen_MediaDestination mediaDestination, ESen_MediaType mediaType) bool CTelemetryManager::RecordBanLevel(int iPad) { return true; }
{
return true;
}
bool CTelemetryManager::RecordUpsellPresented(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID) bool CTelemetryManager::RecordUnBanLevel(int iPad) { return true; }
{
return true;
}
bool CTelemetryManager::RecordUpsellResponded(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID, ESen_UpsellOutcome upsellOutcome)
{
return true;
}
bool CTelemetryManager::RecordPlayerDiedOrFailed(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID)
{
return true;
}
bool CTelemetryManager::RecordEnemyKilledOrOvercome(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID)
{
return true;
}
bool CTelemetryManager::RecordTexturePackLoaded(int iPad, int texturePackId, bool purchased)
{
return true;
}
bool CTelemetryManager::RecordSkinChanged(int iPad, int dwSkinId)
{
return true;
}
bool CTelemetryManager::RecordBanLevel(int iPad)
{
return true;
}
bool CTelemetryManager::RecordUnBanLevel(int iPad)
{
return true;
}
///////////////////////////////////////////////////////////////////
// 4J-JEV: FOLLOWING LOGIC TAKEN FROM XBOX 'SentientManager.cpp' //
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// 4J-JEV: FOLLOWING LOGIC TAKEN FROM XBOX 'SentientManager.cpp' //
///////////////////////////////////////////////////////////////////
/* /*
Number of seconds elapsed since Sentient initialize. Number of seconds elapsed since Sentient initialize.
Title needs to track this and report it as a property. Title needs to track this and report it as a property.
These times will be used to create timelines and understand durations. These times will be used to create timelines and understand durations.
This should be tracked independently of saved games (restoring a save should not reset the seconds since initialize) This should be tracked independently of saved games (restoring a save should not
reset the seconds since initialize)
*/ */
int CTelemetryManager::GetSecondsSinceInitialize() int CTelemetryManager::GetSecondsSinceInitialize() {
{ return static_cast<int>(app.getAppTime() - m_initialiseTime);
return static_cast<int>(app.getAppTime() - m_initialiseTime);
} }
/* /*
An in-game setting that significantly differentiates the play style of the game. An in-game setting that significantly differentiates the play style of the game.
(This should be captured as an integer and correspond to mode specific to the game.) (This should be captured as an integer and correspond to mode specific to the
Teams will have to provide the game mappings that correspond to the integers. game.) Teams will have to provide the game mappings that correspond to the
The intent is to allow teams to capture data on the highest level categories of gameplay in their game. integers. The intent is to allow teams to capture data on the highest level
For example, a game mode could be the name of the specific mini game (eg: golf vs darts) or a specific multiplayer mode (eg: hoard vs beast.) ModeID = 0 means undefined or unknown. categories of gameplay in their game. For example, a game mode could be the name
The intent is to answer the question "How are players playing your game?" of the specific mini game (eg: golf vs darts) or a specific multiplayer mode
(eg: hoard vs beast.) ModeID = 0 means undefined or unknown. The intent is to
answer the question "How are players playing your game?"
*/ */
int CTelemetryManager::GetMode(int userId) int CTelemetryManager::GetMode(int userId) {
{ int mode = static_cast<int>(eTelem_ModeId_Undefined);
int mode = static_cast<int>(eTelem_ModeId_Undefined);
Minecraft *pMinecraft = Minecraft::GetInstance(); Minecraft* pMinecraft = Minecraft::GetInstance();
if( pMinecraft->localplayers[userId] != nullptr && pMinecraft->localplayers[userId]->level != nullptr && pMinecraft->localplayers[userId]->level->getLevelData() != nullptr ) if (pMinecraft->localplayers[userId] != nullptr &&
{ pMinecraft->localplayers[userId]->level != nullptr &&
GameType *gameType = pMinecraft->localplayers[userId]->level->getLevelData()->getGameType(); pMinecraft->localplayers[userId]->level->getLevelData() != nullptr) {
GameType* gameType = pMinecraft->localplayers[userId]
->level->getLevelData()
->getGameType();
if (gameType->isSurvival()) if (gameType->isSurvival()) {
{ mode = static_cast<int>(eTelem_ModeId_Survival);
mode = static_cast<int>(eTelem_ModeId_Survival); } else if (gameType->isCreative()) {
} mode = static_cast<int>(eTelem_ModeId_Creative);
else if (gameType->isCreative()) } else {
{ mode = static_cast<int>(eTelem_ModeId_Undefined);
mode = static_cast<int>(eTelem_ModeId_Creative); }
} }
else return mode;
{
mode = static_cast<int>(eTelem_ModeId_Undefined);
}
}
return mode;
} }
/* /*
Used when a title has more heirarchy required. Used when a title has more heirarchy required.
OptionalSubMode ID = 0 means undefined or unknown. OptionalSubMode ID = 0 means undefined or unknown.
For titles that have sub-modes (Sports/Football). For titles that have sub-modes (Sports/Football).
Mode is always an indicator of "How is the player choosing to play my game?" so these do not have to be consecutive. Mode is always an indicator of "How is the player choosing to play my game?" so
LevelIDs and SubLevelIDs can be reused as they will always be paired with a Mode/SubModeID, Mode should be unique - SubMode can be shared between modes. these do not have to be consecutive. LevelIDs and SubLevelIDs can be reused as
they will always be paired with a Mode/SubModeID, Mode should be unique -
SubMode can be shared between modes.
*/ */
int CTelemetryManager::GetSubMode(int userId) int CTelemetryManager::GetSubMode(int userId) {
{ int subMode = static_cast<int>(eTelem_SubModeId_Undefined);
int subMode = static_cast<int>(eTelem_SubModeId_Undefined);
if(Minecraft::GetInstance()->isTutorial()) if (Minecraft::GetInstance()->isTutorial()) {
{ subMode = static_cast<int>(eTelem_SubModeId_Tutorial);
subMode = static_cast<int>(eTelem_SubModeId_Tutorial); } else {
} subMode = static_cast<int>(eTelem_SubModeId_Normal);
else }
{
subMode = static_cast<int>(eTelem_SubModeId_Normal);
}
return subMode; return subMode;
} }
/* /*
This is a more granular view of mode, allowing teams to get a sense of the levels or maps players are playing and providing some insight into how players progress through a game. This is a more granular view of mode, allowing teams to get a sense of the
Teams will have to provide the game mappings that correspond to the integers. levels or maps players are playing and providing some insight into how players
The intent is that a level is highest level at which modes can be dissected and provides an indication of player progression in a game. progress through a game. Teams will have to provide the game mappings that
The intent is that level start and ends do not occur more than every 2 minutes or so, otherwise the data reported will be difficult to understand. correspond to the integers. The intent is that a level is highest level at which
Levels are unique only within a given modeID - so you can have a ModeID =1, LevelID =1 and a different ModeID=2, LevelID = 1 indicate two completely different levels. modes can be dissected and provides an indication of player progression in a
LevelID = 0 means undefined or unknown. game. The intent is that level start and ends do not occur more than every 2
minutes or so, otherwise the data reported will be difficult to understand.
Levels are unique only within a given modeID - so you can have a ModeID =1,
LevelID =1 and a different ModeID=2, LevelID = 1 indicate two completely
different levels. LevelID = 0 means undefined or unknown.
*/ */
int CTelemetryManager::GetLevelId(int userId) int CTelemetryManager::GetLevelId(int userId) {
{ int levelId = static_cast<int>(eTelem_LevelId_Undefined);
int levelId = static_cast<int>(eTelem_LevelId_Undefined);
levelId = static_cast<int>(eTelem_LevelId_PlayerGeneratedLevel); levelId = static_cast<int>(eTelem_LevelId_PlayerGeneratedLevel);
return levelId; return levelId;
} }
/* /*
Used when a title has more heirarchy required. OptionalSubLevel ID = 0 means undefined or unknown. Used when a title has more heirarchy required. OptionalSubLevel ID = 0 means
For titles that have sub-levels. undefined or unknown. For titles that have sub-levels. Level is always an
Level is always an indicator of "How far has the player progressed." so when possible these should be consecutive or at least monotonically increasing. indicator of "How far has the player progressed." so when possible these should
LevelIDs and SubLevelIDs can be reused as they will always be paired with a Mode/SubModeID be consecutive or at least monotonically increasing. LevelIDs and SubLevelIDs
can be reused as they will always be paired with a Mode/SubModeID
*/ */
int CTelemetryManager::GetSubLevelId(int userId) int CTelemetryManager::GetSubLevelId(int userId) {
{ int subLevelId = static_cast<int>(eTelem_SubLevelId_Undefined);
int subLevelId = static_cast<int>(eTelem_SubLevelId_Undefined);
Minecraft *pMinecraft = Minecraft::GetInstance(); Minecraft* pMinecraft = Minecraft::GetInstance();
if(pMinecraft->localplayers[userId] != nullptr) if (pMinecraft->localplayers[userId] != nullptr) {
{ switch (pMinecraft->localplayers[userId]->dimension) {
switch(pMinecraft->localplayers[userId]->dimension) case 0:
{ subLevelId = static_cast<int>(eTelem_SubLevelId_Overworld);
case 0: break;
subLevelId = static_cast<int>(eTelem_SubLevelId_Overworld); case -1:
break; subLevelId = static_cast<int>(eTelem_SubLevelId_Nether);
case -1: break;
subLevelId = static_cast<int>(eTelem_SubLevelId_Nether); case 1:
break; subLevelId = static_cast<int>(eTelem_SubLevelId_End);
case 1: break;
subLevelId = static_cast<int>(eTelem_SubLevelId_End); };
break; }
};
}
return subLevelId; return subLevelId;
} }
/* /*
Build version of the title, used to track changes in development as well as patches/title updates Build version of the title, used to track changes in development as well as
Allows developer to separate out stats from different builds patches/title updates Allows developer to separate out stats from different
builds
*/ */
int CTelemetryManager::GetTitleBuildId() int CTelemetryManager::GetTitleBuildId() {
{ return static_cast<int>(VER_PRODUCTBUILD);
return static_cast<int>(VER_PRODUCTBUILD);
} }
/* /*
Generated by the game every time LevelStart or LevelResume is called. Generated by the game every time LevelStart or LevelResume is called.
This should be a unique ID (can be sequential) within a session. This should be a unique ID (can be sequential) within a session.
Helps differentiate level attempts when a play plays the same mode/level - especially with aggregated stats Helps differentiate level attempts when a play plays the same mode/level -
especially with aggregated stats
*/ */
int CTelemetryManager::GetLevelInstanceID() int CTelemetryManager::GetLevelInstanceID() { return m_levelInstanceID; }
{
return m_levelInstanceID; /*
MultiplayerinstanceID is a title-generated value that is the same for all
players in the same multiplayer session. Link up players into a single
multiplayer session ID.
*/
int CTelemetryManager::GetMultiplayerInstanceID() {
return m_multiplayerInstanceID;
}
int CTelemetryManager::GenerateMultiplayerInstanceId() { return 0; }
void CTelemetryManager::SetMultiplayerInstanceId(int value) {
m_multiplayerInstanceID = value;
} }
/* /*
MultiplayerinstanceID is a title-generated value that is the same for all players in the same multiplayer session. Indicates whether the game is being played in single or multiplayer mode and
Link up players into a single multiplayer session ID. whether multiplayer is being played locally or over live. How social is your
game? How do people play it?
*/ */
int CTelemetryManager::GetMultiplayerInstanceID() int CTelemetryManager::GetSingleOrMultiplayer() {
{ int singleOrMultiplayer =
return m_multiplayerInstanceID; static_cast<int>(eSen_SingleOrMultiplayer_Undefined);
}
int CTelemetryManager::GenerateMultiplayerInstanceId() // Unused
{ // eSen_SingleOrMultiplayer_Single_Player
return 0; // eSen_SingleOrMultiplayer_Multiplayer_Live
}
void CTelemetryManager::SetMultiplayerInstanceId(int value) if (app.GetLocalPlayerCount() == 1 &&
{ g_NetworkManager.GetOnlinePlayerCount() == 0) {
m_multiplayerInstanceID = value; singleOrMultiplayer =
} static_cast<int>(eSen_SingleOrMultiplayer_Single_Player);
} else if (app.GetLocalPlayerCount() > 1 &&
g_NetworkManager.GetOnlinePlayerCount() == 0) {
singleOrMultiplayer =
static_cast<int>(eSen_SingleOrMultiplayer_Multiplayer_Local);
} else if (app.GetLocalPlayerCount() == 1 &&
g_NetworkManager.GetOnlinePlayerCount() > 0) {
singleOrMultiplayer =
static_cast<int>(eSen_SingleOrMultiplayer_Multiplayer_Live);
} else if (app.GetLocalPlayerCount() > 1 &&
g_NetworkManager.GetOnlinePlayerCount() > 0) {
singleOrMultiplayer = static_cast<int>(
eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live);
}
/* return singleOrMultiplayer;
Indicates whether the game is being played in single or multiplayer mode and whether multiplayer is being played locally or over live.
How social is your game? How do people play it?
*/
int CTelemetryManager::GetSingleOrMultiplayer()
{
int singleOrMultiplayer = static_cast<int>(eSen_SingleOrMultiplayer_Undefined);
// Unused
//eSen_SingleOrMultiplayer_Single_Player
//eSen_SingleOrMultiplayer_Multiplayer_Live
if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() == 0)
{
singleOrMultiplayer = static_cast<int>(eSen_SingleOrMultiplayer_Single_Player);
}
else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() == 0)
{
singleOrMultiplayer = static_cast<int>(eSen_SingleOrMultiplayer_Multiplayer_Local);
}
else if(app.GetLocalPlayerCount() == 1 && g_NetworkManager.GetOnlinePlayerCount() > 0)
{
singleOrMultiplayer = static_cast<int>(eSen_SingleOrMultiplayer_Multiplayer_Live);
}
else if(app.GetLocalPlayerCount() > 1 && g_NetworkManager.GetOnlinePlayerCount() > 0)
{
singleOrMultiplayer = static_cast<int>(eSen_SingleOrMultiplayer_Multiplayer_Both_Local_and_Live);
}
return singleOrMultiplayer;
} }
/* /*
An in-game setting that differentiates the challenge imposed on the user. An in-game setting that differentiates the challenge imposed on the user.
Normalized to a standard 5-point scale. Are players changing the difficulty? Normalized to a standard 5-point scale. Are players changing the difficulty?
*/ */
int CTelemetryManager::GetDifficultyLevel(int diff) int CTelemetryManager::GetDifficultyLevel(int diff) {
{ int difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Undefined);
int difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Undefined);
switch(diff) switch (diff) {
{ case 0:
case 0: difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Easiest);
difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Easiest); break;
break; case 1:
case 1: difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Easier);
difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Easier); break;
break; case 2:
case 2: difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Normal);
difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Normal); break;
break; case 3:
case 3: difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Harder);
difficultyLevel = static_cast<int>(eSen_DifficultyLevel_Harder); break;
break; }
}
// Unused // Unused
//eSen_DifficultyLevel_Hardest = 5, // eSen_DifficultyLevel_Hardest = 5,
return difficultyLevel; return difficultyLevel;
} }
/* /*
Differentiates trial/demo from full purchased titles Differentiates trial/demo from full purchased titles
Is this a full title or demo? Is this a full title or demo?
*/ */
int CTelemetryManager::GetLicense() int CTelemetryManager::GetLicense() {
{ int license = eSen_License_Undefined;
int license = eSen_License_Undefined;
if(ProfileManager.IsFullVersion()) if (ProfileManager.IsFullVersion()) {
{ license = static_cast<int>(eSen_License_Full_Purchased_Title);
license = static_cast<int>(eSen_License_Full_Purchased_Title); } else {
} license = static_cast<int>(eSen_License_Trial_or_Demo);
else }
{ return license;
license = static_cast<int>(eSen_License_Trial_or_Demo);
}
return license;
} }
/* /*
This is intended to capture whether players played using default control scheme or customized the control scheme. This is intended to capture whether players played using default control scheme
Are players customizing your controls? or customized the control scheme. Are players customizing your controls?
*/ */
int CTelemetryManager::GetDefaultGameControls() int CTelemetryManager::GetDefaultGameControls() {
{ int defaultGameControls = eSen_DefaultGameControls_Undefined;
int defaultGameControls = eSen_DefaultGameControls_Undefined;
// Unused // Unused
//eSen_DefaultGameControls_Custom_controls // eSen_DefaultGameControls_Custom_controls
defaultGameControls = eSen_DefaultGameControls_Default_controls; defaultGameControls = eSen_DefaultGameControls_Default_controls;
return defaultGameControls; return defaultGameControls;
} }
/* /*
Are players changing default audio settings? Are players changing default audio settings?
This is intended to capture whether players are playing with or without volume and whether they make changes from the default audio settings. This is intended to capture whether players are playing with or without volume
and whether they make changes from the default audio settings.
*/ */
int CTelemetryManager::GetAudioSettings(int userId) int CTelemetryManager::GetAudioSettings(int userId) {
{ int audioSettings = static_cast<int>(eSen_AudioSettings_Undefined);
int audioSettings = static_cast<int>(eSen_AudioSettings_Undefined);
if(userId == ProfileManager.GetPrimaryPad()) if (userId == ProfileManager.GetPrimaryPad()) {
{ unsigned char volume =
unsigned char volume = app.GetGameSettings(userId, eGameSetting_SoundFXVolume); app.GetGameSettings(userId, eGameSetting_SoundFXVolume);
if(volume == 0) if (volume == 0) {
{ audioSettings = static_cast<int>(eSen_AudioSettings_Off);
audioSettings = static_cast<int>(eSen_AudioSettings_Off); } else if (volume == DEFAULT_VOLUME_LEVEL) {
} audioSettings = static_cast<int>(eSen_AudioSettings_On_Default);
else if(volume == DEFAULT_VOLUME_LEVEL) } else {
{ audioSettings =
audioSettings = static_cast<int>(eSen_AudioSettings_On_Default); static_cast<int>(eSen_AudioSettings_On_CustomSetting);
} }
else }
{ return audioSettings;
audioSettings = static_cast<int>(eSen_AudioSettings_On_CustomSetting);
}
}
return audioSettings;
} }
/* /*
Refers to the highest level performance metric for your game. Refers to the highest level performance metric for your game.
For example, a performance metric could points earned, race time, total kills, etc. For example, a performance metric could points earned, race time, total kills,
This is entirely up to you and will help us understand how well the player performed, or how far the player progressed  in the level before exiting. etc. This is entirely up to you and will help us understand how well the player
How far did users progress before failing/exiting the level? performed, or how far the player progressed  in the level before exiting. How
far did users progress before failing/exiting the level?
*/ */
int CTelemetryManager::GetLevelExitProgressStat1() int CTelemetryManager::GetLevelExitProgressStat1() {
{ // 4J Stu - Unused
// 4J Stu - Unused return 0;
return 0;
} }
/* /*
Refers to the highest level performance metric for your game. Refers to the highest level performance metric for your game.
For example, a performance metric could points earned, race time, total kills, etc. For example, a performance metric could points earned, race time, total kills,
This is entirely up to you and will help us understand how well the player performed, or how far the player progressed  in the level before exiting. etc. This is entirely up to you and will help us understand how well the player
How far did users progress before failing/exiting the level? performed, or how far the player progressed  in the level before exiting. How
far did users progress before failing/exiting the level?
*/ */
int CTelemetryManager::GetLevelExitProgressStat2() int CTelemetryManager::GetLevelExitProgressStat2() {
{ // 4J Stu - Unused
// 4J Stu - Unused return 0;
return 0;
} }

View file

@ -10,64 +10,88 @@
#endif #endif
#include "../UI/UIEnums.h" #include "../UI/UIEnums.h"
class CTelemetryManager class CTelemetryManager {
{
public: public:
virtual int32_t Init(); virtual int32_t Init();
virtual int32_t Tick(); virtual int32_t Tick();
virtual int32_t Flush(); virtual int32_t Flush();
virtual bool RecordPlayerSessionStart(int iPad); virtual bool RecordPlayerSessionStart(int iPad);
virtual bool RecordPlayerSessionExit(int iPad, int exitStatus); virtual bool RecordPlayerSessionExit(int iPad, int exitStatus);
virtual bool RecordHeartBeat(int iPad); virtual bool RecordHeartBeat(int iPad);
virtual bool RecordLevelStart(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers); virtual bool RecordLevelStart(int iPad, ESen_FriendOrMatch friendsOrMatch,
virtual bool RecordLevelExit(int iPad, ESen_LevelExitStatus levelExitStatus); ESen_CompeteOrCoop competeOrCoop,
virtual bool RecordLevelSaveOrCheckpoint(int iPad, int saveOrCheckPointID, int saveSizeInBytes); int difficulty, int numberOfLocalPlayers,
virtual bool RecordLevelResume(int iPad, ESen_FriendOrMatch friendsOrMatch, ESen_CompeteOrCoop competeOrCoop, int difficulty, int numberOfLocalPlayers, int numberOfOnlinePlayers, int saveOrCheckPointID); int numberOfOnlinePlayers);
virtual bool RecordPauseOrInactive(int iPad); virtual bool RecordLevelExit(int iPad,
virtual bool RecordUnpauseOrActive(int iPad); ESen_LevelExitStatus levelExitStatus);
virtual bool RecordMenuShown(int iPad, EUIScene menuID, int optionalMenuSubID); virtual bool RecordLevelSaveOrCheckpoint(int iPad, int saveOrCheckPointID,
virtual bool RecordAchievementUnlocked(int iPad, int achievementID, int achievementGamerscore); int saveSizeInBytes);
virtual bool RecordMediaShareUpload(int iPad, ESen_MediaDestination mediaDestination, ESen_MediaType mediaType); virtual bool RecordLevelResume(int iPad, ESen_FriendOrMatch friendsOrMatch,
virtual bool RecordUpsellPresented(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID); ESen_CompeteOrCoop competeOrCoop,
virtual bool RecordUpsellResponded(int iPad, ESen_UpsellID upsellId, int marketplaceOfferID, ESen_UpsellOutcome upsellOutcome); int difficulty, int numberOfLocalPlayers,
virtual bool RecordPlayerDiedOrFailed(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID); int numberOfOnlinePlayers,
virtual bool RecordEnemyKilledOrOvercome(int iPad, int lowResMapX, int lowResMapY, int lowResMapZ, int mapID, int playerWeaponID, int enemyWeaponID, ETelemetryChallenges enemyTypeID); int saveOrCheckPointID);
virtual bool RecordTexturePackLoaded(int iPad, int texturePackId, bool purchased); virtual bool RecordPauseOrInactive(int iPad);
virtual bool RecordUnpauseOrActive(int iPad);
virtual bool RecordMenuShown(int iPad, EUIScene menuID,
int optionalMenuSubID);
virtual bool RecordAchievementUnlocked(int iPad, int achievementID,
int achievementGamerscore);
virtual bool RecordMediaShareUpload(int iPad,
ESen_MediaDestination mediaDestination,
ESen_MediaType mediaType);
virtual bool RecordUpsellPresented(int iPad, ESen_UpsellID upsellId,
int marketplaceOfferID);
virtual bool RecordUpsellResponded(int iPad, ESen_UpsellID upsellId,
int marketplaceOfferID,
ESen_UpsellOutcome upsellOutcome);
virtual bool RecordPlayerDiedOrFailed(int iPad, int lowResMapX,
int lowResMapY, int lowResMapZ,
int mapID, int playerWeaponID,
int enemyWeaponID,
ETelemetryChallenges enemyTypeID);
virtual bool RecordEnemyKilledOrOvercome(int iPad, int lowResMapX,
int lowResMapY, int lowResMapZ,
int mapID, int playerWeaponID,
int enemyWeaponID,
ETelemetryChallenges enemyTypeID);
virtual bool RecordTexturePackLoaded(int iPad, int texturePackId,
bool purchased);
virtual bool RecordSkinChanged(int iPad, int dwSkinId); virtual bool RecordSkinChanged(int iPad, int dwSkinId);
virtual bool RecordBanLevel(int iPad); virtual bool RecordBanLevel(int iPad);
virtual bool RecordUnBanLevel(int iPad); virtual bool RecordUnBanLevel(int iPad);
virtual int GetMultiplayerInstanceID(); virtual int GetMultiplayerInstanceID();
virtual int GenerateMultiplayerInstanceId(); virtual int GenerateMultiplayerInstanceId();
virtual void SetMultiplayerInstanceId(int value); virtual void SetMultiplayerInstanceId(int value);
protected: protected:
float m_initialiseTime; float m_initialiseTime;
float m_lastHeartbeat; float m_lastHeartbeat;
bool m_bFirstFlush; bool m_bFirstFlush;
float m_fLevelStartTime[XUSER_MAX_COUNT]; float m_fLevelStartTime[XUSER_MAX_COUNT];
int m_multiplayerInstanceID; int m_multiplayerInstanceID;
int m_levelInstanceID; int m_levelInstanceID;
// Helper functions to get the various common settings // Helper functions to get the various common settings
int GetSecondsSinceInitialize(); int GetSecondsSinceInitialize();
int GetMode(int userId); int GetMode(int userId);
int GetSubMode(int userId); int GetSubMode(int userId);
int GetLevelId(int userId); int GetLevelId(int userId);
int GetSubLevelId(int userId); int GetSubLevelId(int userId);
int GetTitleBuildId(); int GetTitleBuildId();
int GetLevelInstanceID(); int GetLevelInstanceID();
int GetSingleOrMultiplayer(); int GetSingleOrMultiplayer();
int GetDifficultyLevel(int diff); int GetDifficultyLevel(int diff);
int GetLicense(); int GetLicense();
int GetDefaultGameControls(); int GetDefaultGameControls();
int GetAudioSettings(int userId); int GetAudioSettings(int userId);
int GetLevelExitProgressStat1(); int GetLevelExitProgressStat1();
int GetLevelExitProgressStat2(); int GetLevelExitProgressStat2();
}; };
extern CTelemetryManager *TelemetryManager; extern CTelemetryManager* TelemetryManager;

View file

@ -2,8 +2,8 @@
#include "TrialMode.h" #include "TrialMode.h"
#include "../Tutorial/FullTutorial.h" #include "../Tutorial/FullTutorial.h"
TrialMode::TrialMode(int iPad, Minecraft *minecraft, ClientConnection *connection) TrialMode::TrialMode(int iPad, Minecraft* minecraft,
: FullTutorialMode(iPad, minecraft, connection) ClientConnection* connection)
{ : FullTutorialMode(iPad, minecraft, connection) {
tutorial = new FullTutorial(iPad, true); tutorial = new FullTutorial(iPad, true);
} }

View file

@ -1,10 +1,9 @@
#pragma once #pragma once
#include "../Tutorial/FullTutorialMode.h" #include "../Tutorial/FullTutorialMode.h"
class TrialMode : public FullTutorialMode class TrialMode : public FullTutorialMode {
{
public: public:
TrialMode(int iPad, Minecraft *minecraft, ClientConnection *connection); TrialMode(int iPad, Minecraft* minecraft, ClientConnection* connection);
virtual bool isImplemented() { return true; } virtual bool isImplemented() { return true; }
}; };

View file

@ -21,8 +21,7 @@ bool AreaTask::isCompleted() {
switch (m_completionState) { switch (m_completionState) {
case eAreaTaskCompletion_CompleteOnConstraintsSatisfied: { case eAreaTaskCompletion_CompleteOnConstraintsSatisfied: {
bool allSatisfied = true; bool allSatisfied = true;
for (auto it = constraints.begin(); it != constraints.end(); for (auto it = constraints.begin(); it != constraints.end(); ++it) {
++it) {
TutorialConstraint* constraint = *it; TutorialConstraint* constraint = *it;
if (!constraint->isConstraintSatisfied(tutorial->getPad())) { if (!constraint->isConstraintSatisfied(tutorial->getPad())) {
allSatisfied = false; allSatisfied = false;

View file

@ -14,7 +14,8 @@ ChoiceTask::ChoiceTask(
int iCancelMapping /*= 0*/, int iCancelMapping /*= 0*/,
eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/, eTutorial_CompletionAction cancelAction /*= e_Tutorial_Completion_None*/,
ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false, false) { : TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
false) {
if (requiresUserInput == true) { if (requiresUserInput == true) {
constraints.push_back(new InputConstraint(iConfirmMapping)); constraints.push_back(new InputConstraint(iConfirmMapping));
constraints.push_back(new InputConstraint(iCancelMapping)); constraints.push_back(new InputConstraint(iCancelMapping));

View file

@ -23,7 +23,8 @@ public:
ControllerTask(Tutorial* tutorial, int descriptionId, ControllerTask(Tutorial* tutorial, int descriptionId,
bool enablePreCompletion, bool showMinimumTime, bool enablePreCompletion, bool showMinimumTime,
int mappings[], unsigned int mappingsLength, int mappings[], unsigned int mappingsLength,
int iCompletionMaskA[] = nullptr, int iCompletionMaskACount = 0, int iCompletionMaskA[] = nullptr,
int iCompletionMaskACount = 0,
int iSouthpawMappings[] = nullptr, int iSouthpawMappings[] = nullptr,
unsigned int uiSouthpawMappingsCount = 0); unsigned int uiSouthpawMappingsCount = 0);
~ControllerTask(); ~ControllerTask();

View file

@ -2,11 +2,12 @@
#include "CraftTask.h" #include "CraftTask.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h" #include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
CraftTask::CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial, CraftTask::CraftTask(
int descriptionId, bool enablePreCompletion /*= true*/, int itemId, int auxValue, int quantity, Tutorial* tutorial,
std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/, int descriptionId, bool enablePreCompletion /*= true*/,
bool bShowMinimumTime /*=false*/, std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/,
bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/) bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/,
bool m_bTaskReminders /*=true*/)
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
bShowMinimumTime, bAllowFade, m_bTaskReminders), bShowMinimumTime, bAllowFade, m_bTaskReminders),
m_quantity(quantity), m_quantity(quantity),
@ -18,12 +19,12 @@ CraftTask::CraftTask(int itemId, int auxValue, int quantity, Tutorial* tutorial,
m_auxValues[0] = auxValue; m_auxValues[0] = auxValue;
} }
CraftTask::CraftTask(int* items, int* auxValues, int numItems, int quantity, CraftTask::CraftTask(
Tutorial* tutorial, int descriptionId, int* items, int* auxValues, int numItems, int quantity, Tutorial* tutorial,
bool enablePreCompletion /*= true*/, int descriptionId, bool enablePreCompletion /*= true*/,
std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/, std::vector<TutorialConstraint*>* inConstraints /*= nullptr*/,
bool bShowMinimumTime /*=false*/, bool bShowMinimumTime /*=false*/, bool bAllowFade /*=true*/,
bool bAllowFade /*=true*/, bool m_bTaskReminders /*=true*/) bool m_bTaskReminders /*=true*/)
: TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints, : TutorialTask(tutorial, descriptionId, enablePreCompletion, inConstraints,
bShowMinimumTime, bAllowFade, m_bTaskReminders), bShowMinimumTime, bAllowFade, m_bTaskReminders),
m_quantity(quantity), m_quantity(quantity),

View file

@ -12,7 +12,8 @@ InfoTask::InfoTask(
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/, Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
bool requiresUserInput /*= false*/, int iMapping /*= 0*/, bool requiresUserInput /*= false*/, int iMapping /*= 0*/,
ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/) ETelemetryChallenges telemetryEvent /*= eTelemetryTutorial_NoEvent*/)
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false, false) { : TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
false) {
if (requiresUserInput == true) { if (requiresUserInput == true) {
constraints.push_back(new InputConstraint(iMapping)); constraints.push_back(new InputConstraint(iMapping));
} }
@ -45,8 +46,8 @@ bool InfoTask::isCompleted() {
// If a menu is displayed, then we use the handleUIInput to complete the // If a menu is displayed, then we use the handleUIInput to complete the
// task // task
bAllComplete = true; bAllComplete = true;
for (auto it = completedMappings.begin(); for (auto it = completedMappings.begin(); it != completedMappings.end();
it != completedMappings.end(); ++it) { ++it) {
bool current = (*it).second; bool current = (*it).second;
if (!current) { if (!current) {
bAllComplete = false; bAllComplete = false;
@ -56,8 +57,8 @@ bool InfoTask::isCompleted() {
} else { } else {
int iCurrent = 0; int iCurrent = 0;
for (auto it = completedMappings.begin(); for (auto it = completedMappings.begin(); it != completedMappings.end();
it != completedMappings.end(); ++it) { ++it) {
bool current = (*it).second; bool current = (*it).second;
if (!current) { if (!current) {
if (InputManager.GetValue(pMinecraft->player->GetXboxPad(), if (InputManager.GetValue(pMinecraft->player->GetXboxPad(),
@ -94,8 +95,8 @@ void InfoTask::setAsCurrentTask(bool active /*= true*/) {
void InfoTask::handleUIInput(int iAction) { void InfoTask::handleUIInput(int iAction) {
if (bHasBeenActivated) { if (bHasBeenActivated) {
for (auto it = completedMappings.begin(); for (auto it = completedMappings.begin(); it != completedMappings.end();
it != completedMappings.end(); ++it) { ++it) {
if (iAction == (*it).first) { if (iAction == (*it).first) {
(*it).second = true; (*it).second = true;
} }

View file

@ -2,8 +2,7 @@
#include "ProcedureCompoundTask.h" #include "ProcedureCompoundTask.h"
ProcedureCompoundTask::~ProcedureCompoundTask() { ProcedureCompoundTask::~ProcedureCompoundTask() {
for (auto it = m_taskSequence.begin(); it < m_taskSequence.end(); for (auto it = m_taskSequence.begin(); it < m_taskSequence.end(); ++it) {
++it) {
delete (*it); delete (*it);
} }
} }

View file

@ -1683,8 +1683,8 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad(iPad) {
if (isFullTutorial) if (isFullTutorial)
addTask(e_Tutorial_State_Horse, addTask(e_Tutorial_State_Horse,
new RideEntityTask(eTYPE_HORSE, this, new RideEntityTask(eTYPE_HORSE, this,
IDS_TUTORIAL_TASK_HORSE_RIDE, true, nullptr, IDS_TUTORIAL_TASK_HORSE_RIDE, true,
false, false, false)); nullptr, false, false, false));
else else
addTask(e_Tutorial_State_Horse, addTask(e_Tutorial_State_Horse,
new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_RIDE, new InfoTask(this, IDS_TUTORIAL_TASK_HORSE_RIDE,
@ -1929,8 +1929,8 @@ Tutorial::Tutorial(int iPad, bool isFullTutorial /*= false*/) : m_iPad(iPad) {
} }
Tutorial::~Tutorial() { Tutorial::~Tutorial() {
for (auto it = m_globalConstraints.begin(); for (auto it = m_globalConstraints.begin(); it != m_globalConstraints.end();
it != m_globalConstraints.end(); ++it) { ++it) {
delete (*it); delete (*it);
} }
for (std::unordered_map<int, TutorialMessage*>::iterator it = for (std::unordered_map<int, TutorialMessage*>::iterator it =
@ -1968,8 +1968,8 @@ void Tutorial::setCompleted(int completableId) {
// } // }
int completableIndex = -1; int completableIndex = -1;
for (auto it = s_completableTasks.begin(); for (auto it = s_completableTasks.begin(); it < s_completableTasks.end();
it < s_completableTasks.end(); ++it) { ++it) {
++completableIndex; ++completableIndex;
if (*it == completableId) { if (*it == completableId) {
break; break;
@ -1996,8 +1996,8 @@ bool Tutorial::getCompleted(int completableId) {
// } // }
int completableIndex = -1; int completableIndex = -1;
for (auto it = s_completableTasks.begin(); for (auto it = s_completableTasks.begin(); it < s_completableTasks.end();
it < s_completableTasks.end(); ++it) { ++it) {
++completableIndex; ++completableIndex;
if (*it == completableId) { if (*it == completableId) {
break; break;
@ -2152,8 +2152,8 @@ void Tutorial::tick() {
} }
// Check constraints // Check constraints
for (auto it = m_globalConstraints.begin(); for (auto it = m_globalConstraints.begin(); it < m_globalConstraints.end();
it < m_globalConstraints.end(); ++it) { ++it) {
TutorialConstraint* constraint = *it; TutorialConstraint* constraint = *it;
constraint->tick(m_iPad); constraint->tick(m_iPad);
} }
@ -2234,8 +2234,7 @@ void Tutorial::tick() {
// gameplay state so that they are in effect for // gameplay state so that they are in effect for
// a bit longer // a bit longer
auto itCon = auto itCon =
constraintsToRemove[m_CurrentState] constraintsToRemove[m_CurrentState].begin();
.begin();
while ( while (
itCon != itCon !=
constraintsToRemove[m_CurrentState].end()) { constraintsToRemove[m_CurrentState].end()) {
@ -2259,8 +2258,7 @@ void Tutorial::tick() {
} }
// Fall through the the normal complete state // Fall through the the normal complete state
case e_Tutorial_Completion_Complete_State: case e_Tutorial_Completion_Complete_State:
for (auto for (auto itRem =
itRem =
activeTasks[m_CurrentState].begin(); activeTasks[m_CurrentState].begin();
itRem < activeTasks[m_CurrentState].end(); itRem < activeTasks[m_CurrentState].end();
++itRem) { ++itRem) {
@ -2273,8 +2271,7 @@ void Tutorial::tick() {
activeTasks[m_CurrentState].at( activeTasks[m_CurrentState].at(
activeTasks[m_CurrentState].size() - 1); activeTasks[m_CurrentState].size() - 1);
activeTasks[m_CurrentState].pop_back(); activeTasks[m_CurrentState].pop_back();
for (auto for (auto itRem =
itRem =
activeTasks[m_CurrentState].begin(); activeTasks[m_CurrentState].begin();
itRem < activeTasks[m_CurrentState].end(); itRem < activeTasks[m_CurrentState].end();
++itRem) { ++itRem) {
@ -2773,8 +2770,8 @@ void Tutorial::onLookAtEntity(std::shared_ptr<Entity> entity) {
} }
} }
if ((m_CurrentState == e_Tutorial_State_Gameplay) && entity->instanceof if ((m_CurrentState == e_Tutorial_State_Gameplay) &&
(eTYPE_HORSE)) { entity->instanceof(eTYPE_HORSE)) {
changeTutorialState(e_Tutorial_State_Horse); changeTutorialState(e_Tutorial_State_Horse);
} }
@ -2898,7 +2895,7 @@ void Tutorial::RemoveConstraint(TutorialConstraint* c,
} }
auto it = find(constraints[m_CurrentState].begin(), auto it = find(constraints[m_CurrentState].begin(),
constraints[m_CurrentState].end(), c); constraints[m_CurrentState].end(), c);
if (it != constraints[m_CurrentState].end()) if (it != constraints[m_CurrentState].end())
constraints[m_CurrentState].erase( constraints[m_CurrentState].erase(
find(constraints[m_CurrentState].begin(), find(constraints[m_CurrentState].begin(),
@ -2934,8 +2931,7 @@ void Tutorial::addMessage(
} }
void Tutorial::changeTutorialState(eTutorial_State newState, void Tutorial::changeTutorialState(eTutorial_State newState,
UIScene* scene /*= nullptr*/) UIScene* scene /*= nullptr*/) {
{
if (newState == m_CurrentState) { if (newState == m_CurrentState) {
// If clearing the scene, make sure that the tutorial popup has its // If clearing the scene, make sure that the tutorial popup has its
// reference to this scene removed // reference to this scene removed

View file

@ -135,7 +135,8 @@ public:
void setCompleted(int completableId); void setCompleted(int completableId);
bool getCompleted(int completableId); bool getCompleted(int completableId);
void changeTutorialState(eTutorial_State newState, UIScene* scene = nullptr); void changeTutorialState(eTutorial_State newState,
UIScene* scene = nullptr);
bool isSelectedItemState(); bool isSelectedItemState();
bool setMessage(PopupMessageDetails* message); bool setMessage(PopupMessageDetails* message);

View file

@ -22,7 +22,8 @@ public:
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level, virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y, std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, Vec3* hit, int z, int face, Vec3* hit,
bool bTestUseOnly = false, bool* pbUsedItem = nullptr); bool bTestUseOnly = false,
bool* pbUsedItem = nullptr);
virtual void attack(std::shared_ptr<Player> player, virtual void attack(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity); std::shared_ptr<Entity> entity);

View file

@ -13,11 +13,11 @@ class MobEffect;
// enablePreCompletion - If this is true, then the player can complete this // enablePreCompletion - If this is true, then the player can complete this
// task out of sequence. // task out of sequence.
// This stops us asking them to do // This stops us asking them to do
//things they have already done // things they have already done
// constraints - A list of constraints which can be activated // constraints - A list of constraints which can be activated
// (as a whole). // (as a whole).
// If they are active, then the // If they are active, then the
//constraints are removed when the task is completed // constraints are removed when the task is completed
// areConstraintsEnabled- A flag which records whether or not we have added the // areConstraintsEnabled- A flag which records whether or not we have added the
// constraints to the tutorial // constraints to the tutorial
class TutorialTask { class TutorialTask {

View file

@ -9,7 +9,6 @@
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h" #include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
#include "../../Minecraft.Client/Minecraft.h" #include "../../Minecraft.Client/Minecraft.h"
IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() { IUIScene_AbstractContainerMenu::IUIScene_AbstractContainerMenu() {
m_menu = nullptr; m_menu = nullptr;
m_autoDeleteMenu = false; m_autoDeleteMenu = false;
@ -68,12 +67,11 @@ void IUIScene_AbstractContainerMenu::Initialize(
m_iCurrSlotX = 0; m_iCurrSlotX = 0;
m_iCurrSlotY = 0; m_iCurrSlotY = 0;
#endif #endif
// //
// for(int i=0;i<XUSER_MAX_COUNT;i++) // for(int i=0;i<XUSER_MAX_COUNT;i++)
// { // {
// m_bFirstTouchStored[i]=false; // m_bFirstTouchStored[i]=false;
// } // }
PlatformInitialize(iPad, startIndex); PlatformInitialize(iPad, startIndex);
} }
@ -247,123 +245,117 @@ void IUIScene_AbstractContainerMenu::onMouseTick() {
((float)app.GetGameSettings(iPad, eGameSetting_Sensitivity_InMenu) / ((float)app.GetGameSettings(iPad, eGameSetting_Sensitivity_InMenu) /
100.0f); // apply the sensitivity 100.0f); // apply the sensitivity
// If there is any input on sticks, move the pointer.
// If there is any input on sticks, move the pointer. if ((fabs(fInputX) >= 0.01f) || (fabs(fInputY) >= 0.01f)) {
if ((fabs(fInputX) >= 0.01f) || (fabs(fInputY) >= 0.01f)) { fInputDirX = (fInputX > 0.0f) ? 1.0f : (fInputX < 0.0f) ? -1.0f : 0.0f;
fInputDirX = (fInputX > 0.0f) ? 1.0f fInputDirY = (fInputY > 0.0f) ? 1.0f : (fInputY < 0.0f) ? -1.0f : 0.0f;
: (fInputX < 0.0f) ? -1.0f
: 0.0f;
fInputDirY = (fInputY > 0.0f) ? 1.0f
: (fInputY < 0.0f) ? -1.0f
: 0.0f;
#if defined(TAP_DETECTION) #if defined(TAP_DETECTION)
// Check for potential tap input to jump slot. // Check for potential tap input to jump slot.
ETapState eNewTapInput = GetTapInputType(fInputX, fInputY); ETapState eNewTapInput = GetTapInputType(fInputX, fInputY);
switch (m_eCurrTapState) { switch (m_eCurrTapState) {
case eTapStateNoInput: case eTapStateNoInput:
m_eCurrTapState = eNewTapInput; m_eCurrTapState = eNewTapInput;
break; break;
case eTapStateUp: case eTapStateUp:
case eTapStateDown: case eTapStateDown:
case eTapStateLeft: case eTapStateLeft:
case eTapStateRight: case eTapStateRight:
if ((eNewTapInput != m_eCurrTapState) && if ((eNewTapInput != m_eCurrTapState) &&
(eNewTapInput != eTapStateNoInput)) { (eNewTapInput != eTapStateNoInput)) {
// Input is no longer suitable for tap. // Input is no longer suitable for tap.
m_eCurrTapState = eTapNone; m_eCurrTapState = eTapNone;
} }
break; break;
case eTapNone: case eTapNone:
/// Nothing to do, input is not a tap. /// Nothing to do, input is not a tap.
break; break;
default: default:
break; break;
} }
#endif #endif
// Square it so we get more precision for small inputs. // Square it so we get more precision for small inputs.
fInputX = fInputX * fInputX * fInputDirX * POINTER_SPEED_FACTOR; fInputX = fInputX * fInputX * fInputDirX * POINTER_SPEED_FACTOR;
fInputY = fInputY * fInputY * fInputDirY * POINTER_SPEED_FACTOR; fInputY = fInputY * fInputY * fInputDirY * POINTER_SPEED_FACTOR;
// fInputX = fInputX * POINTER_SPEED_FACTOR; // fInputX = fInputX * POINTER_SPEED_FACTOR;
// fInputY = fInputY * POINTER_SPEED_FACTOR; // fInputY = fInputY * POINTER_SPEED_FACTOR;
float fInputScale = 1.0f; float fInputScale = 1.0f;
// Ramp up input from zero when new input is recieved over // Ramp up input from zero when new input is recieved over
// INPUT_TICKS_FOR_SCALING ticks. This is to try to improve tapping // INPUT_TICKS_FOR_SCALING ticks. This is to try to improve tapping
// stick to move 1 box. // stick to move 1 box.
if (m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_SCALING) { if (m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_SCALING) {
++m_iConsectiveInputTicks; ++m_iConsectiveInputTicks;
fInputScale = ((float)(m_iConsectiveInputTicks) / fInputScale = ((float)(m_iConsectiveInputTicks) /
(float)(MAX_INPUT_TICKS_FOR_SCALING)); (float)(MAX_INPUT_TICKS_FOR_SCALING));
} }
#if defined(TAP_DETECTION) #if defined(TAP_DETECTION)
else if (m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_TAPPING) { else if (m_iConsectiveInputTicks < MAX_INPUT_TICKS_FOR_TAPPING) {
++m_iConsectiveInputTicks; ++m_iConsectiveInputTicks;
} else { } else {
m_eCurrTapState = eTapNone; m_eCurrTapState = eTapNone;
} }
#endif #endif
// 4J Stu - The cursor moves too fast in SD mode // 4J Stu - The cursor moves too fast in SD mode
// The SD/splitscreen scenes are approximately 0.6 times the size of // The SD/splitscreen scenes are approximately 0.6 times the size of
// the fullscreen on // the fullscreen on
if (!RenderManager.IsHiDef() || app.GetLocalPlayerCount() > 1) if (!RenderManager.IsHiDef() || app.GetLocalPlayerCount() > 1)
fInputScale *= 0.6f; fInputScale *= 0.6f;
fInputX *= fInputScale; fInputX *= fInputScale;
fInputY *= fInputScale; fInputY *= fInputScale;
#if defined(USE_POINTER_ACCEL) #if defined(USE_POINTER_ACCEL)
m_fPointerAccelX += fInputX / 50.0f; m_fPointerAccelX += fInputX / 50.0f;
m_fPointerAccelY += fInputY / 50.0f; m_fPointerAccelY += fInputY / 50.0f;
if (fabsf(fInputX) > fabsf(m_fPointerVelX + m_fPointerAccelX)) { if (fabsf(fInputX) > fabsf(m_fPointerVelX + m_fPointerAccelX)) {
m_fPointerVelX += m_fPointerAccelX; m_fPointerVelX += m_fPointerAccelX;
} else { } else {
m_fPointerAccelX = fInputX - m_fPointerVelX; m_fPointerAccelX = fInputX - m_fPointerVelX;
m_fPointerVelX = fInputX; m_fPointerVelX = fInputX;
} }
if (fabsf(fInputY) > fabsf(m_fPointerVelY + m_fPointerAccelY)) { if (fabsf(fInputY) > fabsf(m_fPointerVelY + m_fPointerAccelY)) {
m_fPointerVelY += m_fPointerAccelY; m_fPointerVelY += m_fPointerAccelY;
} else { } else {
m_fPointerAccelY = fInputY - m_fPointerVelY; m_fPointerAccelY = fInputY - m_fPointerVelY;
m_fPointerVelY = fInputY; m_fPointerVelY = fInputY;
} }
// printf( "IN %.2f VEL %.2f ACC %.2f\n", fInputY, m_fPointerVelY, // printf( "IN %.2f VEL %.2f ACC %.2f\n", fInputY, m_fPointerVelY,
// m_fPointerAccelY ); // m_fPointerAccelY );
vPointerPos.x += m_fPointerVelX; vPointerPos.x += m_fPointerVelX;
vPointerPos.y -= m_fPointerVelY; vPointerPos.y -= m_fPointerVelY;
#else #else
// Add input to pointer position. // Add input to pointer position.
vPointerPos.x += fInputX; vPointerPos.x += fInputX;
vPointerPos.y -= fInputY; vPointerPos.y -= fInputY;
#endif #endif
// Clamp to pointer extents. // Clamp to pointer extents.
if (vPointerPos.x < m_fPointerMinX) if (vPointerPos.x < m_fPointerMinX)
vPointerPos.x = m_fPointerMinX; vPointerPos.x = m_fPointerMinX;
else if (vPointerPos.x > m_fPointerMaxX) else if (vPointerPos.x > m_fPointerMaxX)
vPointerPos.x = m_fPointerMaxX; vPointerPos.x = m_fPointerMaxX;
if (vPointerPos.y < m_fPointerMinY) if (vPointerPos.y < m_fPointerMinY)
vPointerPos.y = m_fPointerMinY; vPointerPos.y = m_fPointerMinY;
else if (vPointerPos.y > m_fPointerMaxY) else if (vPointerPos.y > m_fPointerMaxY)
vPointerPos.y = m_fPointerMaxY; vPointerPos.y = m_fPointerMaxY;
bStickInput = true; bStickInput = true;
} else { } else {
m_iConsectiveInputTicks = 0; m_iConsectiveInputTicks = 0;
#if defined(USE_POINTER_ACCEL) #if defined(USE_POINTER_ACCEL)
m_fPointerVelX = 0.0f; m_fPointerVelX = 0.0f;
m_fPointerVelY = 0.0f; m_fPointerVelY = 0.0f;
m_fPointerAccelX = 0.0f; m_fPointerAccelX = 0.0f;
m_fPointerAccelY = 0.0f; m_fPointerAccelY = 0.0f;
#endif #endif
} }
// Determine which slot the pointer is currently over. // Determine which slot the pointer is currently over.
ESceneSection eSectionUnderPointer = eSectionNone; ESceneSection eSectionUnderPointer = eSectionNone;
@ -480,8 +472,8 @@ void IUIScene_AbstractContainerMenu::onMouseTick() {
m_iCurrSlotX = iNewSlotX; m_iCurrSlotX = iNewSlotX;
m_iCurrSlotY = iNewSlotY; m_iCurrSlotY = iNewSlotY;
#endif #endif
// No need to check any further slots, the pointer can only ever be over // No need to check any further slots, the pointer can
// one. // only ever be over one.
break; break;
} }
} }

View file

@ -164,7 +164,6 @@ protected:
int m_iCurrSlotX; int m_iCurrSlotX;
int m_iCurrSlotY; int m_iCurrSlotY;
// ENum indexes of the first section for this scene, and 1+the last section // ENum indexes of the first section for this scene, and 1+the last section
ESceneSection m_eFirstSection, m_eMaxSection; ESceneSection m_eFirstSection, m_eMaxSection;

View file

@ -271,7 +271,8 @@ void IUIScene_BeaconMenu::handleTick() {
int totalWidth = count * 22 + (count - 1) * 2; int totalWidth = count * 22 + (count - 1) * 2;
for (int c = 0; c < count; c++) { for (int c = 0; c < count; c++) {
if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr) continue; if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr)
continue;
int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id;
int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon();
@ -298,7 +299,8 @@ void IUIScene_BeaconMenu::handleTick() {
int totalWidth = count * 22 + (count - 1) * 2; int totalWidth = count * 22 + (count - 1) * 2;
for (int c = 0; c < count - 1; c++) { for (int c = 0; c < count - 1; c++) {
if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr) continue; if (BeaconTileEntity::BEACON_EFFECTS[tier][c] == nullptr)
continue;
int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id; int effectId = BeaconTileEntity::BEACON_EFFECTS[tier][c]->id;
int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon(); int icon = BeaconTileEntity::BEACON_EFFECTS[tier][c]->getIcon();

View file

@ -651,8 +651,9 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
// if(pTempItemInst->id<256) // if(pTempItemInst->id<256)
// { // {
// Tile // Tile
// *pTile=Tile::tiles[pTempItemInst->id]; printf("[TILE] ID\t%d\tAux // *pTile=Tile::tiles[pTempItemInst->id];
// val\t%d\tBase type\t%d\tMaterial\t%d\t Count=%d\n",pTempItemInst->id, // printf("[TILE] ID\t%d\tAux val\t%d\tBase type\t%d\tMaterial\t%d\t
// Count=%d\n",pTempItemInst->id,
// pTempItemInst->getAuxValue(),pTile->getBaseItemType(),pTile->getMaterial(),pTempItemInst->GetCount()); // pTempItemInst->getAuxValue(),pTile->getBaseItemType(),pTile->getMaterial(),pTempItemInst->GetCount());
// } // }
// else // else

View file

@ -211,7 +211,6 @@ void IUIScene_CreativeMenu::staticCtor() {
ITEM_AUX(Tile::woolCarpet_Id, 13) // Green ITEM_AUX(Tile::woolCarpet_Id, 13) // Green
ITEM_AUX(Tile::woolCarpet_Id, 12) // Brown ITEM_AUX(Tile::woolCarpet_Id, 12) // Brown
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
DEF(eCreativeInventory_ArtToolsDecorations) DEF(eCreativeInventory_ArtToolsDecorations)
if (app.DebugSettingsOn()) { if (app.DebugSettingsOn()) {
@ -508,7 +507,8 @@ void IUIScene_CreativeMenu::staticCtor() {
for (unsigned int i = 0; i < Enchantment::enchantments.length; ++i) { for (unsigned int i = 0; i < Enchantment::enchantments.length; ++i) {
Enchantment* enchantment = Enchantment::enchantments[i]; Enchantment* enchantment = Enchantment::enchantments[i];
if (enchantment == nullptr || enchantment->category == nullptr) continue; if (enchantment == nullptr || enchantment->category == nullptr)
continue;
list->push_back(Item::enchantedBook->createForEnchantment( list->push_back(Item::enchantedBook->createForEnchantment(
new EnchantmentInstance(enchantment, enchantment->getMaxLevel()))); new EnchantmentInstance(enchantment, enchantment->getMaxLevel())));
} }
@ -862,8 +862,8 @@ void IUIScene_CreativeMenu::staticCtor() {
ECreative_Inventory_Groups debugMiscGroup[] = { ECreative_Inventory_Groups debugMiscGroup[] = {
eCreativeInventory_ArtToolsMisc}; eCreativeInventory_ArtToolsMisc};
specs[eCreativeInventoryTab_Misc] = specs[eCreativeInventoryTab_Misc] =
new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0, nullptr, new TabSpec(L"Misc", IDS_GROUPNAME_MISCELLANEOUS, 1, miscGroup, 0,
1, debugMiscGroup); nullptr, 1, debugMiscGroup);
#else #else
ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc}; ECreative_Inventory_Groups miscGroup[] = {eCreativeInventory_Misc};
specs[eCreativeInventoryTab_Misc] = specs[eCreativeInventoryTab_Misc] =
@ -982,8 +982,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu* menu,
// Fill the dynamic group // Fill the dynamic group
if (m_dynamicGroupsCount > 0 && m_dynamicGroupsA != nullptr) { if (m_dynamicGroupsCount > 0 && m_dynamicGroupsA != nullptr) {
for (auto it= for (auto it = categoryGroups[m_dynamicGroupsA[dynamicIndex]].rbegin();
categoryGroups[m_dynamicGroupsA[dynamicIndex]].rbegin();
it != categoryGroups[m_dynamicGroupsA[dynamicIndex]].rend() && it != categoryGroups[m_dynamicGroupsA[dynamicIndex]].rend() &&
lastSlotIndex < MAX_SIZE; lastSlotIndex < MAX_SIZE;
++it) { ++it) {

View file

@ -205,7 +205,8 @@ void IUIScene_HUD::renderPlayerHealth() {
std::shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding; std::shared_ptr<Entity> riding = pMinecraft->localplayers[iPad]->riding;
if (riding == nullptr || riding && !riding->instanceof(eTYPE_LIVINGENTITY)) { if (riding == nullptr ||
riding && !riding->instanceof(eTYPE_LIVINGENTITY)) {
SetRidingHorse(false, false, 0); SetRidingHorse(false, false, 0);
ShowFood(true); ShowFood(true);

View file

@ -51,7 +51,6 @@ int IUIScene_PauseMenu::ExitGameSaveDialogReturned(
->getDLCInfoParentPack(); // tPack->getDLCPack(); ->getDLCInfoParentPack(); // tPack->getDLCPack();
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture, if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
L"")) { L"")) {
unsigned int uiIDA[2]; unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_CANCEL;
@ -192,9 +191,6 @@ int IUIScene_PauseMenu::ExitGameDeclineSaveReturned(
int IUIScene_PauseMenu::WarningTrialTexturePackReturned( int IUIScene_PauseMenu::WarningTrialTexturePackReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) { void* pParam, int iPad, C4JStorage::EMessageResult result) {
return 0; return 0;
} }
@ -227,7 +223,6 @@ int IUIScene_PauseMenu::SaveWorldThreadProc(void* lpParameter) {
if (!MinecraftServer::serverHalted() && !app.GetChangingSessionType()) if (!MinecraftServer::serverHalted() && !app.GetChangingSessionType())
app.SetGameStarted(true); app.SetGameStarted(true);
} }
int32_t hr = S_OK; int32_t hr = S_OK;
@ -443,7 +438,6 @@ void IUIScene_PauseMenu::_ExitWorld(void* lpParameter) {
app.SetChangingSessionType(false); app.SetChangingSessionType(false);
app.SetReallyChangingSessionType(false); app.SetReallyChangingSessionType(false);
pMinecraft->exitingWorldRightNow = false; pMinecraft->exitingWorldRightNow = false;
} }
int IUIScene_PauseMenu::SaveGameDialogReturned( int IUIScene_PauseMenu::SaveGameDialogReturned(

View file

@ -166,7 +166,7 @@ void IUIScene_StartGame::UpdateTexturePackDescription(int index) {
// if(imageBytes > 0 && imageData) // if(imageBytes > 0 && imageData)
//{ //{
// registerSubstitutionTexture(L"texturePackIcon", imageData, // registerSubstitutionTexture(L"texturePackIcon", imageData,
//imageBytes); // imageBytes);
// m_bitmapTexturePackIcon.setTextureName(L"texturePackIcon"); // m_bitmapTexturePackIcon.setTextureName(L"texturePackIcon");
// } // }
@ -249,7 +249,6 @@ int IUIScene_StartGame::UnlockTexturePackReturned(
if (result == C4JStorage::EMessage_ResultAccept) { if (result == C4JStorage::EMessage_ResultAccept) {
if (ProfileManager.IsSignedIn(iPad)) { if (ProfileManager.IsSignedIn(iPad)) {
// the license change coming in when the offer has been installed // the license change coming in when the offer has been installed
// will cause this scene to refresh // will cause this scene to refresh
} }

View file

@ -180,8 +180,8 @@ void IUIScene_TradingMenu::updateDisplay() {
m_activeOffers.clear(); m_activeOffers.clear();
int unfilteredIndex = 0; int unfilteredIndex = 0;
int firstValidTrade = INT_MAX; int firstValidTrade = INT_MAX;
for (auto it = unfilteredOffers->begin(); for (auto it = unfilteredOffers->begin(); it != unfilteredOffers->end();
it != unfilteredOffers->end(); ++it) { ++it) {
MerchantRecipe* recipe = *it; MerchantRecipe* recipe = *it;
if (!recipe->isDeprecated()) { if (!recipe->isDeprecated()) {
m_activeOffers.push_back( m_activeOffers.push_back(

View file

@ -38,7 +38,6 @@
#include "UIControl_SpaceIndicatorBar.h" #include "UIControl_SpaceIndicatorBar.h"
#include "UIControl_BeaconEffectButton.h" #include "UIControl_BeaconEffectButton.h"
#include "UIScene_HUD.h" #include "UIScene_HUD.h"
#include "UIComponent_Panorama.h" #include "UIComponent_Panorama.h"
#include "UIComponent_Logo.h" #include "UIComponent_Logo.h"

View file

@ -240,8 +240,8 @@ rrbool UIBitmapFont::CanProvideBitmap(S32 glyph, F32 pixel_scale) {
// Parameters // Parameters
// glyph The glyph to compute/get the bitmap for // glyph The glyph to compute/get the bitmap for
// pixel_scale The scale factor (pseudo point size) requested by the // pixel_scale The scale factor (pseudo point size) requested by the
//textfield,adjusted for display resolution bitmap The structure to store the // textfield,adjusted for display resolution bitmap The structure to store
//bitmap into // the bitmap into
rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph, F32 pixel_scale, rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph, F32 pixel_scale,
IggyBitmapCharacter* bitmap) { IggyBitmapCharacter* bitmap) {
// Description // Description
@ -326,8 +326,9 @@ rrbool UIBitmapFont::GetGlyphBitmap(S32 glyph, F32 pixel_scale,
#endif #endif
// app.DebugPrintf("Request glyph_%d (U+%.4X) at %f, converted to %f // app.DebugPrintf("Request glyph_%d (U+%.4X) at %f, converted to %f
// (%f)\n", glyph, GetUnicode(glyph), pixel_scale, targetPixelScale, // (%f)\n", glyph, GetUnicode(glyph),
//glyphScale); // pixel_scale, targetPixelScale,
// glyphScale);
// It is not necessary to shrink the glyph width here // It is not necessary to shrink the glyph width here
// as its already been done in 'GetGlyphMetrics' by: // as its already been done in 'GetGlyphMetrics' by:

View file

@ -7,8 +7,12 @@ class CFontData;
// const int BITMAP_FONT_LANGUAGES = XC_LANGUAGE_ENGLISH // const int BITMAP_FONT_LANGUAGES = XC_LANGUAGE_ENGLISH
// | // |
// XC_LANGUAGE_GERMAN | XC_LANGUAGE_FRENCH | XC_LANGUAGE_SPANISH | // XC_LANGUAGE_GERMAN
// XC_LANGUAGE_ITALIAN | XC_LANGUAGE_PORTUGUESE | XC_LANGUAGE_BRAZILIAN; // | XC_LANGUAGE_FRENCH
// | XC_LANGUAGE_SPANISH
// | XC_LANGUAGE_ITALIAN
// | XC_LANGUAGE_PORTUGUESE
// | XC_LANGUAGE_BRAZILIAN;
// using namespace std; // using namespace std;

View file

@ -12,8 +12,6 @@ UIComponent_Tooltips::UIComponent_Tooltips(int iPad, void* initData,
} }
// Setup all the Iggy references we need for this scene // Setup all the Iggy references we need for this scene
initialiseMovie(); initialiseMovie();
} }
std::wstring UIComponent_Tooltips::getMoviePath() { std::wstring UIComponent_Tooltips::getMoviePath() {
@ -311,14 +309,11 @@ void UIComponent_Tooltips::_Relayout() {
IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result, IggyResult out = IggyPlayerCallMethodRS(getMovie(), &result,
IggyPlayerRootPath(getMovie()), IggyPlayerRootPath(getMovie()),
m_funcUpdateLayout, 0, nullptr); m_funcUpdateLayout, 0, nullptr);
} }
void UIComponent_Tooltips::handleReload() { void UIComponent_Tooltips::handleReload() {
app.DebugPrintf("UIComponent_Tooltips::handleReload\n"); app.DebugPrintf("UIComponent_Tooltips::handleReload\n");
for (unsigned int i = 0; i < eToolTipNumButtons; ++i) { for (unsigned int i = 0; i < eToolTipNumButtons; ++i) {
_SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show, _SetTooltip(i, m_tooltipValues[i].iString, m_tooltipValues[i].show,
true); true);

View file

@ -24,7 +24,6 @@ protected:
IggyName m_funcSetTooltip, m_funcSetOpacity, m_funcSetABSwap, IggyName m_funcSetTooltip, m_funcSetOpacity, m_funcSetABSwap,
m_funcUpdateLayout; m_funcUpdateLayout;
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
UI_MAP_NAME(m_funcSetTooltip, L"SetToolTip") UI_MAP_NAME(m_funcSetTooltip, L"SetToolTip")
UI_MAP_NAME(m_funcSetOpacity, L"SetOpacity") UI_MAP_NAME(m_funcSetOpacity, L"SetOpacity")
@ -81,5 +80,4 @@ private:
void _Relayout(); void _Relayout();
bool m_overrideSFX[XUSER_MAX_COUNT][ACTION_MAX_MENU]; bool m_overrideSFX[XUSER_MAX_COUNT][ACTION_MAX_MENU];
}; };

View file

@ -335,7 +335,8 @@ std::wstring UIComponent_TutorialPopup::_SetIcon(int icon, int iAuxVal,
m_iconItem = nullptr; m_iconItem = nullptr;
} }
} }
if (!isFixedIcon && m_iconItem != nullptr) setupIconHolder(e_ICON_TYPE_IGGY); if (!isFixedIcon && m_iconItem != nullptr)
setupIconHolder(e_ICON_TYPE_IGGY);
m_controlIconHolder.setVisible(isFixedIcon || m_iconItem != nullptr); m_controlIconHolder.setVisible(isFixedIcon || m_iconItem != nullptr);
return temp; return temp;

View file

@ -98,7 +98,8 @@ private:
void _SetDescription(UIScene* interactScene, const std::wstring& desc, void _SetDescription(UIScene* interactScene, const std::wstring& desc,
const std::wstring& title, bool allowFade, const std::wstring& title, bool allowFade,
bool isReminder); bool isReminder);
std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil, const wchar_t* desc); std::wstring _SetIcon(int icon, int iAuxVal, bool isFoil,
const wchar_t* desc);
std::wstring _SetImage(std::wstring& desc); std::wstring _SetImage(std::wstring& desc);
std::wstring ParseDescription(int iPad, std::wstring& text); std::wstring ParseDescription(int iPad, std::wstring& text);
void UpdateInteractScenePosition(bool visible); void UpdateInteractScenePosition(bool visible);

View file

@ -64,7 +64,6 @@ bool UIControl::setupControl(UIScene* scene, IggyValuePath* parent,
return res; return res;
} }
void UIControl::ReInit() { void UIControl::ReInit() {
if (!m_isValid) return; if (!m_isValid) return;
@ -86,7 +85,8 @@ void UIControl::ReInit() {
m_funcSetAlpha, 2, value); m_funcSetAlpha, 2, value);
} }
IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, nullptr, m_isVisible); IggyValueSetBooleanRS(getIggyValuePath(), m_nameVisible, nullptr,
m_isVisible);
} }
IggyValuePath* UIControl::getIggyValuePath() { return &m_iggyPath; } IggyValuePath* UIControl::getIggyValuePath() { return &m_iggyPath; }

View file

@ -35,7 +35,6 @@ void UIControl_Button::init(UIString label, int id) {
IggyResult out = IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 2, value); getIggyValuePath(), m_initFunc, 2, value);
} }
void UIControl_Button::ReInit() { void UIControl_Button::ReInit() {

View file

@ -34,7 +34,6 @@ void UIControl_ButtonList::init(int id) {
IggyResult out = IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result, IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_initFunc, 1, value); getIggyValuePath(), m_initFunc, 1, value);
} }
void UIControl_ButtonList::ReInit() { void UIControl_ButtonList::ReInit() {
@ -151,7 +150,6 @@ void UIControl_ButtonList::setButtonLabel(int iButtonId,
m_funcSetButtonLabel, 2, value); m_funcSetButtonLabel, 2, value);
} }
void UIControl_DynamicButtonList::tick() { void UIControl_DynamicButtonList::tick() {
UIControl_ButtonList::tick(); UIControl_ButtonList::tick();

Some files were not shown because too many files have changed in this diff Show more