2 Commits

Author SHA1 Message Date
JuiceyDev 6215e1365f fix/saving: Final storage fix. 2026-04-05 02:44:30 +02:00
JuiceyDev d30e18ef4d fix/saving: Storage implementation, gui fix and file.cpp refactor 2026-04-05 02:10:20 +02:00
783 changed files with 11132 additions and 13364 deletions
+2 -2
View File
@@ -66,8 +66,8 @@ jobs:
- name: Package artifact
run: |
cd build/targets/app
zip -r ../../../minecraft-client-linux.zip . --exclude "./Minecraft.Client.p/*"
cd build/targets
zip -r ../minecraft-client-linux.zip app --exclude "app/Minecraft.Client.p/*"
- name: Upload artifact
uses: actions/upload-artifact@v4
-6
View File
@@ -89,12 +89,6 @@ pip install meson ninja
Or follow the [Meson quickstart guide](https://mesonbuild.com/Quick-guide.html).
### Tracy profiler
This project can be built with Tracy profiling support. Tracy is available as a meson subproject (bundled in `subprojects/tracy`) and many distributions provide the Tracy tooling; on Arch/Manjaro you can get the latest build from the AUR as `tracy-git`.
Tracy can be directly enabled if you enable the tracy meson option before compiling.
#### Docker (alternative)
If you don't want to install dependencies, use the included devcontainer. Open the project in VS Code with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension, or build manually:
Generated
+9 -9
View File
@@ -3,11 +3,11 @@
"4jlibs": {
"flake": false,
"locked": {
"lastModified": 1774845485,
"narHash": "sha256-6lZrYkW0hX5jQDUy0lb2Qtsst3+lMfJviYUVfuNlEzk=",
"lastModified": 1774836469,
"narHash": "sha256-ukp6tLThQugPlREYFDDB6IaunjGte08f0Ler/c8cvaY=",
"owner": "4jcraft",
"repo": "4jlibs",
"rev": "db73929667eb0607821e38b57d01e6954a7df36d",
"rev": "ab37891dabba90cf1e568660f750cebf46ba83f6",
"type": "github"
},
"original": {
@@ -62,11 +62,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1775036866,
"narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=",
"lastModified": 1774386573,
"narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6201e203d09599479a3b3450ed24fa81537ebc4e",
"rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9",
"type": "github"
},
"original": {
@@ -108,11 +108,11 @@
"simdutf": {
"flake": false,
"locked": {
"lastModified": 1775095916,
"narHash": "sha256-eKMjANt0fbqemtll6iSiFHwYzGWAsuZoVqOXqXNfodc=",
"lastModified": 1773677002,
"narHash": "sha256-kq53Jz9zm2bfs8x/74FQbzYrUc+VD7JlnBoYHnEHuSY=",
"owner": "simdutf",
"repo": "simdutf",
"rev": "1ac2c2245ce9df6a7d26550e34734882c4a16e9b",
"rev": "04a9b596de943ea9e4d4c833e39740edf3c11e88",
"type": "github"
},
"original": {
+1 -1
View File
@@ -128,7 +128,7 @@
installPhase = ''
mkdir -p $out/share/4jcraft
cp -r targets/app/. $out/share/4jcraft/
cp -r Minecraft.Client/. $out/share/4jcraft/
mkdir -p $out/bin
makeWrapper $out/share/4jcraft/Minecraft.Client $out/bin/4jcraft \
+32 -46
View File
@@ -1,16 +1,16 @@
project(
'4jcraft',
['cpp', 'c'],
version: '0.1.0',
meson_version: '>= 1.3',
default_options: [
'cpp_std=c++23',
'warning_level=0',
'buildtype=debugoptimized', # for now
'unity=on', # merge source files per target
'unity_size=8', # TODO: mess around with this
'b_pch=true', # precompiled headers
],
'4jcraft',
['cpp', 'c'],
version: '0.1.0',
meson_version: '>= 1.3',
default_options: [
'cpp_std=c++23',
'warning_level=0',
'buildtype=debugoptimized', # for now
'unity=on', # merge source files per target
'unity_size=8', # TODO: mess around with this
'b_pch=true', # precompiled headers
],
)
pymod = import('python')
@@ -19,30 +19,30 @@ python = pymod.find_installation('python3', required: true)
cc = meson.get_compiler('cpp')
global_cpp_defs = [
'-DSPLIT_SAVES',
'-D_LARGE_WORLDS',
'-D_EXTENDED_ACHIEVEMENTS',
'-D_DEBUG_MENUS_ENABLED',
'-D_DEBUG',
'-D_FORTIFY_SOURCE=2',
'-DDEBUG',
'-DSPLIT_SAVES',
'-D_LARGE_WORLDS',
'-D_EXTENDED_ACHIEVEMENTS',
'-D_DEBUG_MENUS_ENABLED',
'-D_DEBUG',
'-D_FORTIFY_SOURCE=2',
'-DDEBUG',
]
if host_machine.system() == 'linux'
global_cpp_defs += ['-Dlinux', '-D__linux', '-D__linux__']
global_cpp_defs += ['-Dlinux', '-D__linux', '-D__linux__']
endif
if get_option('renderer') == 'gles'
global_cpp_defs += ['-DGLES']
gl_dep = dependency('glesv2', required: true)
glu_dep = dependency('', required: false)
global_cpp_defs += ['-DGLES']
gl_dep = dependency('glesv2', required: true)
glu_dep = dependency('', required: false)
else
gl_dep = dependency('gl', required: true)
glu_dep = dependency('glu', required: true)
gl_dep = dependency('gl', required: true)
glu_dep = dependency('glu', required: true)
endif
if get_option('enable_vsync')
global_cpp_defs += ['-DENABLE_VSYNC']
global_cpp_defs += ['-DENABLE_VSYNC']
endif
if get_option('classic_panorama')
@@ -50,22 +50,22 @@ if get_option('classic_panorama')
endif
if get_option('enable_frame_profiler')
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
global_cpp_defs += ['-DENABLE_FRAME_PROFILER']
endif
if get_option('ui_backend') == 'shiggy'
global_cpp_defs += ['-D_ENABLEIGGY']
global_cpp_defs += ['-D_ENABLEIGGY']
endif
if get_option('ui_backend') == 'java'
global_cpp_defs += '-DENABLE_JAVA_GUIS'
global_cpp_defs += '-DENABLE_JAVA_GUIS'
endif
add_project_arguments(global_cpp_defs, language: ['cpp', 'c'])
global_cpp_args = [
'-Wshift-count-overflow',
'-pipe',
'-Wshift-count-overflow',
'-pipe',
]
add_project_arguments(global_cpp_args, language: 'cpp')
@@ -79,20 +79,6 @@ stb_dep = declare_dependency(include_directories: stb)
miniaudio_dep = dependency('miniaudio')
tracy_opt = get_option('tracy')
if not tracy_opt.disabled()
tracy_proj = subproject('tracy', required: tracy_opt, default_options: ['tracy_enable=true'])
if tracy_proj.found()
tracy_client_dep = tracy_proj.get_variable('tracy_dep')
add_project_arguments('-DTRACY_ENABLE', language: ['cpp', 'c'])
else
tracy_client_dep = dependency('', required: false)
endif
else
tracy_client_dep = dependency('', required: false)
endif
subdir('targets/util')
subdir('targets/java')
subdir('targets/nbt')
@@ -100,4 +86,4 @@ subdir('targets/platform')
subdir('targets/resources')
subdir('targets/minecraft')
subdir('targets/app')
subdir('targets/app')
+2 -9
View File
@@ -7,8 +7,8 @@ option(
)
option('classic_panorama',
type : 'boolean',
value : false,
type : 'boolean',
value : false,
description : 'Enable classic java edition panorama (ui_backend=java ONLY).')
option(
@@ -40,10 +40,3 @@ option(
value: 'frustum',
description: 'Occlusion culling mode. Off disables ALL CULLING (debug only!), Frustum disables offscreen rendering (default), BFS is experimental connectivity culling, hardware uses GPU queries.',
)
option(
'tracy',
type: 'feature',
value: 'auto',
description: 'Enable Tracy profiler'
)
-4
View File
@@ -1,4 +0,0 @@
[wrap-git]
url = https://github.com/wolfpld/tracy.git
revision = master
depth = 1
-463
View File
@@ -1,463 +0,0 @@
#include "app/common/AppGameServices.h"
#include "app/common/Game.h"
#include "java/Class.h" // eINSTANCEOF
AppGameServices::AppGameServices(Game& game, IMenuService& menus)
: game_(game), menus_(menus) {}
// -- Strings --
const wchar_t* AppGameServices::getString(int id) {
return Game::GetString(id);
}
// -- Debug settings --
bool AppGameServices::debugSettingsOn() {
return game_.DebugSettingsOn();
}
bool AppGameServices::debugArtToolsOn() {
return game_.DebugArtToolsOn();
}
unsigned int AppGameServices::debugGetMask(int iPad, bool overridePlayer) {
return game_.GetGameSettingsDebugMask(iPad, overridePlayer);
}
bool AppGameServices::debugMobsDontAttack() {
return game_.GetMobsDontAttackEnabled();
}
bool AppGameServices::debugMobsDontTick() {
return game_.GetMobsDontTickEnabled();
}
bool AppGameServices::debugFreezePlayers() {
return game_.GetFreezePlayers();
}
// -- Game host options --
unsigned int AppGameServices::getGameHostOption(eGameHostOption option) {
return game_.GetGameHostOption(option);
}
void AppGameServices::setGameHostOption(eGameHostOption option,
unsigned int value) {
game_.SetGameHostOption(option, value);
}
// -- Level generation --
LevelGenerationOptions* AppGameServices::getLevelGenerationOptions() {
return game_.getLevelGenerationOptions();
}
LevelRuleset* AppGameServices::getGameRuleDefinitions() {
return game_.getGameRuleDefinitions();
}
// -- Texture cache --
void AppGameServices::addMemoryTextureFile(const std::wstring& name,
std::uint8_t* data,
unsigned int size) {
game_.AddMemoryTextureFile(name, data, size);
}
void AppGameServices::removeMemoryTextureFile(const std::wstring& name) {
game_.RemoveMemoryTextureFile(name);
}
void AppGameServices::getMemFileDetails(const std::wstring& name,
std::uint8_t** data,
unsigned int* size) {
game_.GetMemFileDetails(name, data, size);
}
bool AppGameServices::isFileInMemoryTextures(const std::wstring& name) {
return game_.IsFileInMemoryTextures(name);
}
// -- Player settings --
unsigned char AppGameServices::getGameSettings(int iPad, int setting) {
return game_.GetGameSettings(iPad, static_cast<eGameSetting>(setting));
}
unsigned char AppGameServices::getGameSettings(int setting) {
return game_.GetGameSettings(static_cast<eGameSetting>(setting));
}
// -- App time --
float AppGameServices::getAppTime() {
return game_.getAppTime();
}
// -- Game state --
bool AppGameServices::getGameStarted() { return game_.GetGameStarted(); }
void AppGameServices::setGameStarted(bool val) { game_.SetGameStarted(val); }
bool AppGameServices::getTutorialMode() { return game_.GetTutorialMode(); }
void AppGameServices::setTutorialMode(bool val) { game_.SetTutorialMode(val); }
bool AppGameServices::isAppPaused() { return game_.IsAppPaused(); }
int AppGameServices::getLocalPlayerCount() { return game_.GetLocalPlayerCount(); }
bool AppGameServices::autosaveDue() { return game_.AutosaveDue(); }
void AppGameServices::setAutosaveTimerTime() { game_.SetAutosaveTimerTime(); }
int64_t AppGameServices::secondsToAutosave() { return game_.SecondsToAutosave(); }
void AppGameServices::setDisconnectReason(
DisconnectPacket::eDisconnectReason reason) {
game_.SetDisconnectReason(reason);
}
void AppGameServices::lockSaveNotification() { game_.lockSaveNotification(); }
void AppGameServices::unlockSaveNotification() { game_.unlockSaveNotification(); }
bool AppGameServices::getResetNether() { return game_.GetResetNether(); }
bool AppGameServices::getUseDPadForDebug() { return game_.GetUseDPadForDebug(); }
bool AppGameServices::getWriteSavesToFolderEnabled() {
return game_.GetWriteSavesToFolderEnabled();
}
bool AppGameServices::isLocalMultiplayerAvailable() {
return game_.IsLocalMultiplayerAvailable();
}
bool AppGameServices::dlcInstallPending() {
return game_.DLCInstallPending();
}
bool AppGameServices::dlcInstallProcessCompleted() {
return game_.DLCInstallProcessCompleted();
}
bool AppGameServices::canRecordStatsAndAchievements() {
return game_.CanRecordStatsAndAchievements();
}
bool AppGameServices::getTMSGlobalFileListRead() {
return game_.GetTMSGlobalFileListRead();
}
void AppGameServices::setRequiredTexturePackID(std::uint32_t id) {
game_.SetRequiredTexturePackID(id);
}
void AppGameServices::setSpecialTutorialCompletionFlag(int iPad, int index) {
game_.SetSpecialTutorialCompletionFlag(iPad, index);
}
void AppGameServices::setBanListCheck(int iPad, bool val) {
game_.SetBanListCheck(iPad, val);
}
bool AppGameServices::getBanListCheck(int iPad) {
return game_.GetBanListCheck(iPad);
}
unsigned int AppGameServices::getGameNewWorldSize() {
return game_.GetGameNewWorldSize();
}
unsigned int AppGameServices::getGameNewWorldSizeUseMoat() {
return game_.GetGameNewWorldSizeUseMoat();
}
unsigned int AppGameServices::getGameNewHellScale() {
return game_.GetGameNewHellScale();
}
// -- UI dispatch --
void AppGameServices::setAction(int iPad, eXuiAction action, void* param) {
game_.SetAction(iPad, action, param);
}
void AppGameServices::setXuiServerAction(int iPad, eXuiServerAction action,
void* param) {
game_.SetXuiServerAction(iPad, action, param);
}
eXuiAction AppGameServices::getXuiAction(int iPad) {
return game_.GetXuiAction(iPad);
}
eXuiServerAction AppGameServices::getXuiServerAction(int iPad) {
return game_.GetXuiServerAction(iPad);
}
void* AppGameServices::getXuiServerActionParam(int iPad) {
return game_.GetXuiServerActionParam(iPad);
}
void AppGameServices::setGlobalXuiAction(eXuiAction action) {
game_.SetGlobalXuiAction(action);
}
void AppGameServices::handleButtonPresses() {
game_.HandleButtonPresses();
}
void AppGameServices::setTMSAction(int iPad, eTMSAction action) {
game_.SetTMSAction(iPad, action);
}
// -- Skin / cape / animation --
std::wstring AppGameServices::getPlayerSkinName(int iPad) {
return game_.GetPlayerSkinName(iPad);
}
std::uint32_t AppGameServices::getPlayerSkinId(int iPad) {
return game_.GetPlayerSkinId(iPad);
}
std::wstring AppGameServices::getPlayerCapeName(int iPad) {
return game_.GetPlayerCapeName(iPad);
}
std::uint32_t AppGameServices::getPlayerCapeId(int iPad) {
return game_.GetPlayerCapeId(iPad);
}
std::uint32_t AppGameServices::getAdditionalModelPartsForPad(int iPad) {
return game_.GetAdditionalModelParts(iPad);
}
void AppGameServices::setAdditionalSkinBoxes(std::uint32_t dwSkinID,
SKIN_BOX* boxA,
unsigned int boxC) {
game_.SetAdditionalSkinBoxes(dwSkinID, boxA, boxC);
}
std::vector<SKIN_BOX*>* AppGameServices::getAdditionalSkinBoxes(
std::uint32_t dwSkinID) {
return game_.GetAdditionalSkinBoxes(dwSkinID);
}
std::vector<ModelPart*>* AppGameServices::getAdditionalModelParts(
std::uint32_t dwSkinID) {
return game_.GetAdditionalModelParts(dwSkinID);
}
std::vector<ModelPart*>* AppGameServices::setAdditionalSkinBoxesFromVec(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) {
return game_.SetAdditionalSkinBoxes(dwSkinID, pvSkinBoxA);
}
void AppGameServices::setAnimOverrideBitmask(std::uint32_t dwSkinID,
unsigned int bitmask) {
game_.SetAnimOverrideBitmask(dwSkinID, bitmask);
}
unsigned int AppGameServices::getAnimOverrideBitmask(
std::uint32_t dwSkinID) {
return game_.GetAnimOverrideBitmask(dwSkinID);
}
std::uint32_t AppGameServices::getSkinIdFromPath(const std::wstring& skin) {
return Game::getSkinIdFromPath(skin);
}
std::wstring AppGameServices::getSkinPathFromId(std::uint32_t skinId) {
return Game::getSkinPathFromId(skinId);
}
bool AppGameServices::defaultCapeExists() {
return game_.DefaultCapeExists();
}
bool AppGameServices::isXuidNotch(PlayerUID xuid) {
return game_.isXuidNotch(xuid);
}
bool AppGameServices::isXuidDeadmau5(PlayerUID xuid) {
return game_.isXuidDeadmau5(xuid);
}
// -- Platform features --
void AppGameServices::fatalLoadError() { game_.FatalLoadError(); }
void AppGameServices::setRichPresenceContext(int iPad, int contextId) {
game_.SetRichPresenceContext(iPad, contextId);
}
void AppGameServices::captureSaveThumbnail() { game_.CaptureSaveThumbnail(); }
void AppGameServices::getSaveThumbnail(std::uint8_t** data,
unsigned int* size) {
game_.GetSaveThumbnail(data, size);
}
void AppGameServices::readBannedList(int iPad, eTMSAction action,
bool bCallback) {
game_.ReadBannedList(iPad, action, bCallback);
}
void AppGameServices::updatePlayerInfo(std::uint8_t networkSmallId,
int16_t playerColourIndex,
unsigned int playerPrivileges) {
game_.UpdatePlayerInfo(networkSmallId, playerColourIndex, playerPrivileges);
}
unsigned int AppGameServices::getPlayerPrivileges(
std::uint8_t networkSmallId) {
return game_.GetPlayerPrivileges(networkSmallId);
}
void AppGameServices::setGameSettingsDebugMask(int iPad, unsigned int uiVal) {
game_.SetGameSettingsDebugMask(iPad, uiVal);
}
// -- Schematics / terrain --
void AppGameServices::processSchematics(LevelChunk* chunk) {
game_.processSchematics(chunk);
}
void AppGameServices::processSchematicsLighting(LevelChunk* chunk) {
game_.processSchematicsLighting(chunk);
}
void AppGameServices::addTerrainFeaturePosition(_eTerrainFeatureType type,
int x, int z) {
game_.AddTerrainFeaturePosition(type, x, z);
}
bool AppGameServices::getTerrainFeaturePosition(_eTerrainFeatureType type,
int* pX, int* pZ) {
return game_.GetTerrainFeaturePosition(type, pX, pZ);
}
void AppGameServices::loadDefaultGameRules() {
game_.loadDefaultGameRules();
}
// -- Archive / resources --
bool AppGameServices::hasArchiveFile(const std::wstring& filename) {
return game_.hasArchiveFile(filename);
}
std::vector<std::uint8_t> AppGameServices::getArchiveFile(
const std::wstring& filename) {
return game_.getArchiveFile(filename);
}
// -- Strings / formatting / misc queries --
int AppGameServices::getHTMLColour(eMinecraftColour colour) {
return game_.GetHTMLColour(colour);
}
std::wstring AppGameServices::getEntityName(EntityTypeId type) {
return game_.getEntityName(static_cast<eINSTANCEOF>(type));
}
const wchar_t* AppGameServices::getGameRulesString(const std::wstring& key) {
return game_.GetGameRulesString(key);
}
unsigned int AppGameServices::createImageTextData(std::uint8_t* textMetadata,
int64_t seed, bool hasSeed,
unsigned int uiHostOptions,
unsigned int uiTexturePackId) {
return game_.CreateImageTextData(textMetadata, seed, hasSeed,
uiHostOptions, uiTexturePackId);
}
std::wstring AppGameServices::getFilePath(std::uint32_t packId,
std::wstring filename,
bool bAddDataFolder,
std::wstring mountPoint) {
return game_.getFilePath(packId, filename, bAddDataFolder, mountPoint);
}
char* AppGameServices::getUniqueMapName() {
return game_.GetUniqueMapName();
}
void AppGameServices::setUniqueMapName(char* name) {
game_.SetUniqueMapName(name);
}
unsigned int AppGameServices::getOpacityTimer(int iPad) {
return game_.GetOpacityTimer(iPad);
}
void AppGameServices::setOpacityTimer(int iPad) {
game_.SetOpacityTimer(iPad);
}
void AppGameServices::tickOpacityTimer(int iPad) {
game_.TickOpacityTimer(iPad);
}
bool AppGameServices::isInBannedLevelList(int iPad, PlayerUID xuid,
char* levelName) {
return game_.IsInBannedLevelList(iPad, xuid, levelName);
}
MOJANG_DATA* AppGameServices::getMojangDataForXuid(PlayerUID xuid) {
return game_.GetMojangDataForXuid(xuid);
}
void AppGameServices::debugPrintf(const char* msg) {
game_.DebugPrintf("%s", msg);
}
// -- DLC --
DLCSkinFile* AppGameServices::getDLCSkinFile(const std::wstring& name) {
return game_.m_dlcManager.getSkinFile(name);
}
bool AppGameServices::dlcNeedsCorruptCheck() {
return game_.m_dlcManager.NeedsCorruptCheck();
}
unsigned int AppGameServices::dlcCheckForCorrupt(bool showMessage) {
return game_.m_dlcManager.checkForCorruptDLCAndAlert(showMessage);
}
bool AppGameServices::dlcReadDataFile(unsigned int& filesProcessed,
const std::wstring& path,
DLCPack* pack, bool fromArchive) {
return game_.m_dlcManager.readDLCDataFile(filesProcessed, path, pack,
fromArchive);
}
void AppGameServices::dlcRemovePack(DLCPack* pack) {
game_.m_dlcManager.removePack(pack);
}
// -- Game rules --
LevelGenerationOptions* AppGameServices::loadGameRules(std::uint8_t* data,
unsigned int size) {
return game_.m_gameRules.loadGameRules(data, size);
}
void AppGameServices::saveGameRules(std::uint8_t** data, unsigned int* size) {
game_.m_gameRules.saveGameRules(data, size);
}
void AppGameServices::unloadCurrentGameRules() {
game_.m_gameRules.unloadCurrentGameRules();
}
void AppGameServices::setLevelGenerationOptions(LevelGenerationOptions* levelGen) {
game_.m_gameRules.setLevelGenerationOptions(levelGen);
}
// -- Shared data --
std::vector<std::wstring>& AppGameServices::getSkinNames() {
return game_.vSkinNames;
}
std::vector<FEATURE_DATA*>& AppGameServices::getTerrainFeatures() {
return *game_.m_terrainFeatureManager.features();
}
// -- Menu service --
IMenuService& AppGameServices::menus() { return menus_; }
-185
View File
@@ -1,185 +0,0 @@
#pragma once
#include "minecraft/IGameServices.h"
class Game;
class IMenuService;
class AppGameServices : public IGameServices {
public:
AppGameServices(Game& game, IMenuService& menus);
// -- Strings --
const wchar_t* getString(int id) override;
// -- Debug settings --
bool debugSettingsOn() override;
bool debugArtToolsOn() override;
unsigned int debugGetMask(int iPad, bool overridePlayer) override;
bool debugMobsDontAttack() override;
bool debugMobsDontTick() override;
bool debugFreezePlayers() override;
// -- Game host options --
unsigned int getGameHostOption(eGameHostOption option) override;
void setGameHostOption(eGameHostOption option,
unsigned int value) override;
// -- Level generation --
LevelGenerationOptions* getLevelGenerationOptions() override;
LevelRuleset* getGameRuleDefinitions() override;
// -- Texture cache --
void addMemoryTextureFile(const std::wstring& name, std::uint8_t* data,
unsigned int size) override;
void removeMemoryTextureFile(const std::wstring& name) override;
void getMemFileDetails(const std::wstring& name, std::uint8_t** data,
unsigned int* size) override;
bool isFileInMemoryTextures(const std::wstring& name) override;
// -- Player settings --
unsigned char getGameSettings(int iPad, int setting) override;
unsigned char getGameSettings(int setting) override;
// -- App time --
float getAppTime() override;
// -- Game state --
bool getGameStarted() override;
void setGameStarted(bool val) override;
bool getTutorialMode() override;
void setTutorialMode(bool val) override;
bool isAppPaused() override;
int getLocalPlayerCount() override;
bool autosaveDue() override;
void setAutosaveTimerTime() override;
int64_t secondsToAutosave() override;
void setDisconnectReason(
DisconnectPacket::eDisconnectReason reason) override;
void lockSaveNotification() override;
void unlockSaveNotification() override;
bool getResetNether() override;
bool getUseDPadForDebug() override;
bool getWriteSavesToFolderEnabled() override;
bool isLocalMultiplayerAvailable() override;
bool dlcInstallPending() override;
bool dlcInstallProcessCompleted() override;
bool canRecordStatsAndAchievements() override;
bool getTMSGlobalFileListRead() override;
void setRequiredTexturePackID(std::uint32_t id) override;
void setSpecialTutorialCompletionFlag(int iPad, int index) override;
void setBanListCheck(int iPad, bool val) override;
bool getBanListCheck(int iPad) override;
unsigned int getGameNewWorldSize() override;
unsigned int getGameNewWorldSizeUseMoat() override;
unsigned int getGameNewHellScale() override;
// -- UI dispatch --
void setAction(int iPad, eXuiAction action, void* param) override;
void setXuiServerAction(int iPad, eXuiServerAction action,
void* param) override;
eXuiAction getXuiAction(int iPad) override;
eXuiServerAction getXuiServerAction(int iPad) override;
void* getXuiServerActionParam(int iPad) override;
void setGlobalXuiAction(eXuiAction action) override;
void handleButtonPresses() override;
void setTMSAction(int iPad, eTMSAction action) override;
// -- Skin / cape / animation --
std::wstring getPlayerSkinName(int iPad) override;
std::uint32_t getPlayerSkinId(int iPad) override;
std::wstring getPlayerCapeName(int iPad) override;
std::uint32_t getPlayerCapeId(int iPad) override;
std::uint32_t getAdditionalModelPartsForPad(int iPad) override;
void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* boxA,
unsigned int boxC) override;
std::vector<SKIN_BOX*>* getAdditionalSkinBoxes(
std::uint32_t dwSkinID) override;
std::vector<ModelPart*>* getAdditionalModelParts(
std::uint32_t dwSkinID) override;
std::vector<ModelPart*>* setAdditionalSkinBoxesFromVec(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) override;
void setAnimOverrideBitmask(std::uint32_t dwSkinID,
unsigned int bitmask) override;
unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID) override;
std::uint32_t getSkinIdFromPath(const std::wstring& skin) override;
std::wstring getSkinPathFromId(std::uint32_t skinId) override;
bool defaultCapeExists() override;
bool isXuidNotch(PlayerUID xuid) override;
bool isXuidDeadmau5(PlayerUID xuid) override;
// -- Platform features --
void fatalLoadError() override;
void setRichPresenceContext(int iPad, int contextId) override;
void captureSaveThumbnail() override;
void getSaveThumbnail(std::uint8_t** data, unsigned int* size) override;
void readBannedList(int iPad, eTMSAction action,
bool bCallback) override;
void updatePlayerInfo(std::uint8_t networkSmallId,
int16_t playerColourIndex,
unsigned int playerPrivileges) override;
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId) override;
void setGameSettingsDebugMask(int iPad, unsigned int uiVal) override;
// -- Schematics / terrain --
void processSchematics(LevelChunk* chunk) override;
void processSchematicsLighting(LevelChunk* chunk) override;
void addTerrainFeaturePosition(_eTerrainFeatureType type, int x,
int z) override;
bool getTerrainFeaturePosition(_eTerrainFeatureType type, int* pX,
int* pZ) override;
void loadDefaultGameRules() override;
// -- Archive / resources --
bool hasArchiveFile(const std::wstring& filename) override;
std::vector<std::uint8_t> getArchiveFile(
const std::wstring& filename) override;
// -- Strings / formatting / misc queries --
int getHTMLColour(eMinecraftColour colour) override;
std::wstring getEntityName(EntityTypeId type) override;
const wchar_t* getGameRulesString(const std::wstring& key) override;
unsigned int createImageTextData(std::uint8_t* textMetadata,
int64_t seed, bool hasSeed,
unsigned int uiHostOptions,
unsigned int uiTexturePackId) override;
std::wstring getFilePath(std::uint32_t packId, std::wstring filename,
bool bAddDataFolder,
std::wstring mountPoint) override;
char* getUniqueMapName() override;
void setUniqueMapName(char* name) override;
unsigned int getOpacityTimer(int iPad) override;
void setOpacityTimer(int iPad) override;
void tickOpacityTimer(int iPad) override;
bool isInBannedLevelList(int iPad, PlayerUID xuid,
char* levelName) override;
MOJANG_DATA* getMojangDataForXuid(PlayerUID xuid) override;
void debugPrintf(const char* msg) override;
// -- DLC --
DLCSkinFile* getDLCSkinFile(const std::wstring& name) override;
bool dlcNeedsCorruptCheck() override;
unsigned int dlcCheckForCorrupt(bool showMessage) override;
bool dlcReadDataFile(unsigned int& filesProcessed,
const std::wstring& path, DLCPack* pack,
bool fromArchive) override;
void dlcRemovePack(DLCPack* pack) override;
// -- Game rules --
LevelGenerationOptions* loadGameRules(std::uint8_t* data,
unsigned int size) override;
void saveGameRules(std::uint8_t** data, unsigned int* size) override;
void unloadCurrentGameRules() override;
void setLevelGenerationOptions(LevelGenerationOptions* levelGen) override;
// -- Shared data --
std::vector<std::wstring>& getSkinNames() override;
std::vector<FEATURE_DATA*>& getTerrainFeatures() override;
// -- Menu service --
IMenuService& menus() override;
private:
Game& game_;
IMenuService& menus_;
};
+17 -7
View File
@@ -4,13 +4,12 @@
#include "platform/sdl2/Storage.h"
#include "app/common/App_Defines.h"
#include "minecraft/GameEnums.h"
#include "minecraft/GameTypes.h"
#include "app/common/Tutorial/TutorialEnum.h"
#include "app/common/UI/All Platforms/UIEnums.h"
#include "platform/NetTypes.h"
#include "minecraft/client/model/SkinBox.h"
#include "platform/XboxStubs.h"
#include "app/common/App_enums.h"
#include "app/common/src/Tutorial/TutorialEnum.h"
#include "app/common/src/UI/All Platforms/UIEnums.h"
#include "app/include/NetTypes.h"
#include "app/include/SkinBox.h"
#include "app/include/XboxStubs.h"
typedef struct {
wchar_t* wchFilename;
@@ -145,6 +144,12 @@ typedef struct {
int uiStringID;
} TIPSTRUCT;
typedef struct {
eXUID eXuid;
wchar_t wchCape[MAX_CAPENAME_SIZE];
wchar_t wchSkin[MAX_CAPENAME_SIZE];
} MOJANG_DATA;
typedef struct {
eDLCContentType eDLCType;
@@ -157,6 +162,11 @@ typedef struct {
unsigned int uiSortIndex;
} DLC_INFO;
typedef struct {
int x, z;
_eTerrainFeatureType eTerrainFeature;
} FEATURE_DATA;
// banned list
typedef struct {
std::uint8_t* pBannedList;
-128
View File
@@ -1,128 +0,0 @@
#include "app/common/ArchiveManager.h"
#include <mutex>
#include <string>
#include "app/common/UI/All Platforms/ArchiveFile.h"
#include "app/linux/LinuxGame.h"
#include "java/File.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePack.h"
#include "minecraft/client/skins/TexturePackRepository.h"
#include "platform/PlatformServices.h"
#include "platform/PlatformTypes.h"
ArchiveManager::ArchiveManager()
: m_mediaArchive(nullptr), m_dwRequiredTexturePackID(0) {}
void ArchiveManager::loadMediaArchive() {
std::wstring mediapath = L"";
#if _WINDOWS64
mediapath = L"Common\\Media\\MediaWindows64.arc";
#elif __linux__
mediapath = L"app/common/Media/MediaLinux.arc";
#endif
if (!mediapath.empty()) {
#if defined(__linux__)
std::wstring exeDirW = PlatformFileIO.getBasePath().wstring();
std::wstring candidate = exeDirW + File::pathSeparator + mediapath;
if (File(candidate).exists()) {
m_mediaArchive = new ArchiveFile(File(candidate));
} else {
m_mediaArchive = new ArchiveFile(File(mediapath));
}
#else
m_mediaArchive = new ArchiveFile(File(mediapath));
#endif
}
}
int ArchiveManager::getArchiveFileSize(const std::wstring& filename) {
TexturePack* tPack = nullptr;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft && pMinecraft->skins)
tPack = pMinecraft->skins->getSelected();
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
tPack->getArchiveFile()->hasFile(filename)) {
return tPack->getArchiveFile()->getFileSize(filename);
} else
return m_mediaArchive->getFileSize(filename);
}
bool ArchiveManager::hasArchiveFile(const std::wstring& filename) {
TexturePack* tPack = nullptr;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft && pMinecraft->skins)
tPack = pMinecraft->skins->getSelected();
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
tPack->getArchiveFile()->hasFile(filename))
return true;
else
return m_mediaArchive->hasFile(filename);
}
std::vector<uint8_t> ArchiveManager::getArchiveFile(
const std::wstring& filename) {
TexturePack* tPack = nullptr;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft && pMinecraft->skins)
tPack = pMinecraft->skins->getSelected();
if (tPack && tPack->hasData() && tPack->getArchiveFile() &&
tPack->getArchiveFile()->hasFile(filename)) {
return tPack->getArchiveFile()->getFile(filename);
} else
return m_mediaArchive->getFile(filename);
}
void ArchiveManager::addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
unsigned int byteCount) {
std::lock_guard<std::mutex> lock(csMemTPDLock);
PMEMDATA pData = nullptr;
auto it = m_MEM_TPD.find(iConfig);
if (it == m_MEM_TPD.end()) {
pData = new MEMDATA();
pData->pbData = pbData;
pData->byteCount = byteCount;
pData->ucRefCount = 1;
m_MEM_TPD[iConfig] = pData;
}
}
void ArchiveManager::removeMemoryTPDFile(int iConfig) {
std::lock_guard<std::mutex> lock(csMemTPDLock);
PMEMDATA pData = nullptr;
auto it = m_MEM_TPD.find(iConfig);
if (it != m_MEM_TPD.end()) {
pData = m_MEM_TPD[iConfig];
delete pData;
m_MEM_TPD.erase(iConfig);
}
}
int ArchiveManager::getTPConfigVal(wchar_t* pwchDataFile) { return -1; }
bool ArchiveManager::isFileInTPD(int iConfig) {
bool val = false;
{
std::lock_guard<std::mutex> lock(csMemTPDLock);
auto it = m_MEM_TPD.find(iConfig);
if (it != m_MEM_TPD.end()) val = true;
}
return val;
}
void ArchiveManager::getTPD(int iConfig, std::uint8_t** ppbData,
unsigned int* pByteCount) {
std::lock_guard<std::mutex> lock(csMemTPDLock);
auto it = m_MEM_TPD.find(iConfig);
if (it != m_MEM_TPD.end()) {
PMEMDATA pData = (*it).second;
*ppbData = pData->pbData;
*pByteCount = pData->byteCount;
}
}
-54
View File
@@ -1,54 +0,0 @@
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "app/common/App_structs.h"
class ArchiveFile;
class ArchiveManager {
public:
ArchiveManager();
void loadMediaArchive();
ArchiveFile* getMediaArchive() const { return m_mediaArchive; }
int getArchiveFileSize(const std::wstring& filename);
bool hasArchiveFile(const std::wstring& filename);
std::vector<uint8_t> getArchiveFile(const std::wstring& filename);
// Texture Pack Data files (icon, banner, comparison shot & text)
void addMemoryTPDFile(int iConfig, std::uint8_t* pbData,
unsigned int byteCount);
void removeMemoryTPDFile(int iConfig);
bool isFileInTPD(int iConfig);
void getTPD(int iConfig, std::uint8_t** ppbData, unsigned int* pByteCount);
int getTPDSize() { return m_MEM_TPD.size(); }
int getTPConfigVal(wchar_t* pwchDataFile);
void setRequiredTexturePackID(std::uint32_t texturePackId) {
m_dwRequiredTexturePackID = texturePackId;
}
std::uint32_t getRequiredTexturePackID() const {
return m_dwRequiredTexturePackID;
}
virtual void getFileFromTPD(eTPDFileType eType, std::uint8_t* pbData,
unsigned int byteCount, std::uint8_t** ppbData,
unsigned int* pByteCount) {
*ppbData = nullptr;
*pByteCount = 0;
}
protected:
ArchiveFile* m_mediaArchive;
private:
std::unordered_map<int, PMEMDATA> m_MEM_TPD;
std::mutex csMemTPDLock;
std::uint32_t m_dwRequiredTexturePackID;
};
-131
View File
@@ -1,131 +0,0 @@
#include "app/common/BannedListManager.h"
#include <cstring>
#include "platform/XboxStubs.h"
BannedListManager::BannedListManager() {
m_pBannedListFileBuffer = nullptr;
m_dwBannedListFileSize = 0;
std::memset(m_pszUniqueMapName, 0, 14);
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
m_bRead_BannedListA[i] = false;
m_BanListCheck[i] = false;
m_vBannedListA[i] = new std::vector<PBANNEDLISTDATA>;
}
}
void BannedListManager::invalidate(int iPad) {
if (m_bRead_BannedListA[iPad] == true) {
m_bRead_BannedListA[iPad] = false;
setBanListCheck(iPad, false);
m_vBannedListA[iPad]->clear();
if (BannedListA[iPad].pBannedList) {
delete[] BannedListA[iPad].pBannedList;
BannedListA[iPad].pBannedList = nullptr;
}
}
}
void BannedListManager::addLevel(int iPad, PlayerUID xuid,
char* pszLevelName, bool bWriteToTMS) {
// we will have retrieved the banned level list from TMS, so add this one to
// it and write it back to TMS
BANNEDLISTDATA* pBannedListData = new BANNEDLISTDATA;
memset(pBannedListData, 0, sizeof(BANNEDLISTDATA));
memcpy(&pBannedListData->xuid, &xuid, sizeof(PlayerUID));
strcpy(pBannedListData->pszLevelName, pszLevelName);
m_vBannedListA[iPad]->push_back(pBannedListData);
if (bWriteToTMS) {
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
const unsigned int dataBytes =
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
PBANNEDLISTDATA pBannedList = new BANNEDLISTDATA[bannedListCount];
int iCount = 0;
for (auto it = m_vBannedListA[iPad]->begin();
it != m_vBannedListA[iPad]->end(); ++it) {
PBANNEDLISTDATA pData = *it;
memcpy(&pBannedList[iCount++], pData, sizeof(BANNEDLISTDATA));
}
// 4J-PB - write to TMS++ now
// bool
// bRes=StorageManager.WriteTMSFile(iPad,C4JStorage::eGlobalStorage_TitleUser,L"BannedList",(std::uint8_t*)pBannedList,
// dwDataBytes);
delete[] pBannedList;
}
// update telemetry too
}
bool BannedListManager::isInList(int iPad, PlayerUID xuid,
char* pszLevelName) {
for (auto it = m_vBannedListA[iPad]->begin();
it != m_vBannedListA[iPad]->end(); ++it) {
PBANNEDLISTDATA pData = *it;
if (IsEqualXUID(pData->xuid, xuid) &&
(strcmp(pData->pszLevelName, pszLevelName) == 0)) {
return true;
}
}
return false;
}
void BannedListManager::removeLevel(int iPad, PlayerUID xuid,
char* pszLevelName) {
// bool bFound=false;
// bool bRes;
// we will have retrieved the banned level list from TMS, so remove this one
// from it and write it back to TMS
for (auto it = m_vBannedListA[iPad]->begin();
it != m_vBannedListA[iPad]->end();) {
PBANNEDLISTDATA pBannedListData = *it;
if (pBannedListData != nullptr) {
if (IsEqualXUID(pBannedListData->xuid, xuid) &&
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
// match found, so remove this entry
it = m_vBannedListA[iPad]->erase(it);
} else {
++it;
}
} else {
++it;
}
}
const std::size_t bannedListCount = m_vBannedListA[iPad]->size();
const unsigned int dataBytes =
static_cast<unsigned int>(sizeof(BANNEDLISTDATA) * bannedListCount);
if (dataBytes == 0) {
// wipe the file
} else {
PBANNEDLISTDATA pBannedList =
(BANNEDLISTDATA*)(new std::uint8_t[dataBytes]);
for (std::size_t i = 0; i < bannedListCount; ++i) {
PBANNEDLISTDATA pBannedListData = m_vBannedListA[iPad]->at(i);
memcpy(&pBannedList[i], pBannedListData, sizeof(BANNEDLISTDATA));
}
delete[] pBannedList;
}
// update telemetry too
}
void BannedListManager::setUniqueMapName(char* pszUniqueMapName) {
memcpy(m_pszUniqueMapName, pszUniqueMapName, 14);
}
char* BannedListManager::getUniqueMapName() {
return m_pszUniqueMapName;
}
-46
View File
@@ -1,46 +0,0 @@
#pragma once
#include <cstdint>
#include <cstring>
#include <vector>
#include "app/common/App_structs.h"
#include "platform/XboxStubs.h"
class BannedListManager {
public:
BannedListManager();
void invalidate(int iPad);
void addLevel(int iPad, PlayerUID xuid, char* pszLevelName,
bool bWriteToTMS);
bool isInList(int iPad, PlayerUID xuid, char* pszLevelName);
void removeLevel(int iPad, PlayerUID xuid, char* pszLevelName);
void setUniqueMapName(char* pszUniqueMapName);
char* getUniqueMapName();
void setBanListCheck(int iPad, bool bVal) { m_BanListCheck[iPad] = bVal; }
bool getBanListCheck(int iPad) const { return m_BanListCheck[iPad]; }
bool getBanListRead(int iPad) const { return m_bRead_BannedListA[iPad]; }
void setBanListRead(int iPad, bool bVal) {
m_bRead_BannedListA[iPad] = bVal;
}
void clearBanList(int iPad) {
BannedListA[iPad].pBannedList = nullptr;
BannedListA[iPad].byteCount = 0;
}
BANNEDLIST BannedListA[XUSER_MAX_COUNT];
std::uint8_t* m_pBannedListFileBuffer;
unsigned int m_dwBannedListFileSize;
private:
VBANNEDLIST* m_vBannedListA[XUSER_MAX_COUNT];
bool m_bRead_BannedListA[XUSER_MAX_COUNT];
char m_pszUniqueMapName[14];
bool m_BanListCheck[XUSER_MAX_COUNT];
};
-719
View File
@@ -1,719 +0,0 @@
#include "app/common/DLCController.h"
#include "app/common/Game.h"
#include "app/common/DLC/DLCPack.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Linux_UIController.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePack.h"
#include "minecraft/client/skins/TexturePackRepository.h"
#include "platform/sdl2/Storage.h"
#include "platform/sdl2/Profile.h"
#include "platform/XboxStubs.h"
#include <cstring>
#include <mutex>
DLCController::DLCController() {
m_pDLCFileBuffer = nullptr;
m_dwDLCFileSize = 0;
m_bDefaultCapeInstallAttempted = false;
m_bDLCInstallProcessCompleted = false;
m_bDLCInstallPending = false;
m_iTotalDLC = 0;
m_iTotalDLCInstalled = 0;
m_bNewDLCAvailable = false;
m_bSeenNewDLCTip = false;
m_iDLCOfferC = 0;
m_bAllDLCContentRetrieved = true;
m_bAllTMSContentRetrieved = true;
m_bTickTMSDLCFiles = true;
}
std::unordered_map<PlayerUID, MOJANG_DATA*> DLCController::MojangData;
std::unordered_map<int, uint64_t> DLCController::DLCTextures_PackID;
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Trial;
std::unordered_map<uint64_t, DLC_INFO*> DLCController::DLCInfo_Full;
std::unordered_map<std::wstring, uint64_t> DLCController::DLCInfo_SkinName;
std::uint32_t DLCController::m_dwContentTypeA[e_Marketplace_MAX] = {
XMARKETPLACE_OFFERING_TYPE_CONTENT,
XMARKETPLACE_OFFERING_TYPE_THEME,
XMARKETPLACE_OFFERING_TYPE_AVATARITEM,
XMARKETPLACE_OFFERING_TYPE_TILE,
};
int DLCController::marketplaceCountsCallback(
void* pParam, C4JStorage::DLC_TMS_DETAILS* pTMSDetails, int iPad) {
app.DebugPrintf("Marketplace Counts= New - %d Total - %d\n",
pTMSDetails->dwNewOffers, pTMSDetails->dwTotalOffers);
if (pTMSDetails->dwNewOffers > 0) {
app.m_dlcController.m_bNewDLCAvailable = true;
app.m_dlcController.m_bSeenNewDLCTip = false;
} else {
app.m_dlcController.m_bNewDLCAvailable = false;
app.m_dlcController.m_bSeenNewDLCTip = true;
}
return 0;
}
bool DLCController::startInstallDLCProcess(int iPad) {
app.DebugPrintf("--- DLCController::startInstallDLCProcess: pad=%i.\n",
iPad);
if ((dlcInstallProcessCompleted() == false) &&
(m_bDLCInstallPending == false)) {
app.m_dlcManager.resetUnnamedCorruptCount();
m_bDLCInstallPending = true;
m_iTotalDLC = 0;
m_iTotalDLCInstalled = 0;
app.DebugPrintf(
"--- DLCController::startInstallDLCProcess - "
"StorageManager.GetInstalledDLC\n");
StorageManager.GetInstalledDLC(
iPad, [this](int iInstalledC, int pad) {
return dlcInstalledCallback(iInstalledC, pad);
});
return true;
} else {
app.DebugPrintf(
"--- DLCController::startInstallDLCProcess - nothing to do\n");
return false;
}
}
int DLCController::dlcInstalledCallback(int iInstalledC, int iPad) {
app.DebugPrintf(
"--- DLCController::dlcInstalledCallback: totalDLC=%i, pad=%i.\n",
iInstalledC, iPad);
m_iTotalDLC = iInstalledC;
mountNextDLC(iPad);
return 0;
}
void DLCController::mountNextDLC(int iPad) {
app.DebugPrintf("--- DLCController::mountNextDLC: pad=%i.\n", iPad);
if (m_iTotalDLCInstalled < m_iTotalDLC) {
if (StorageManager.MountInstalledDLC(
iPad, m_iTotalDLCInstalled,
[this](int pad, std::uint32_t dwErr,
std::uint32_t dwLicenceMask) {
return dlcMountedCallback(pad, dwErr, dwLicenceMask);
}) != ERROR_IO_PENDING) {
app.DebugPrintf("Failed to mount DLC %d for pad %d\n",
m_iTotalDLCInstalled, iPad);
++m_iTotalDLCInstalled;
mountNextDLC(iPad);
} else {
app.DebugPrintf("StorageManager.MountInstalledDLC ok\n");
}
} else {
m_bDLCInstallPending = false;
m_bDLCInstallProcessCompleted = true;
ui.HandleDLCMountingComplete();
}
}
#if defined(_WINDOWS64)
#define CONTENT_DATA_DISPLAY_NAME(a) (a.szDisplayName)
#else
#define CONTENT_DATA_DISPLAY_NAME(a) (a.wszDisplayName)
#endif
int DLCController::dlcMountedCallback(int iPad, std::uint32_t dwErr,
std::uint32_t dwLicenceMask) {
#if defined(_WINDOWS64)
app.DebugPrintf("--- DLCController::dlcMountedCallback\n");
if (dwErr != ERROR_SUCCESS) {
app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr);
app.m_dlcManager.incrementUnnamedCorruptCount();
} else {
XCONTENT_DATA ContentData =
StorageManager.GetDLC(m_iTotalDLCInstalled);
DLCPack* pack =
app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData));
if (pack != nullptr && pack->IsCorrupt()) {
app.DebugPrintf(
"Pack '%ls' is corrupt, removing it from the DLC Manager.\n",
CONTENT_DATA_DISPLAY_NAME(ContentData));
app.m_dlcManager.removePack(pack);
pack = nullptr;
}
if (pack == nullptr) {
app.DebugPrintf("Pack \"%ls\" is not installed, so adding it\n",
CONTENT_DATA_DISPLAY_NAME(ContentData));
#if defined(_WINDOWS64)
pack = new DLCPack(ContentData.szDisplayName, dwLicenceMask);
#else
pack = new DLCPack(ContentData.wszDisplayName, dwLicenceMask);
#endif
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
pack->SetDLCDeviceID(ContentData.DeviceID);
app.m_dlcManager.addPack(pack);
handleDLC(pack);
if (pack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0) {
Minecraft::GetInstance()->skins->addTexturePackFromDLC(
pack, pack->GetPackId());
}
} else {
app.DebugPrintf(
"Pack \"%ls\" is already installed. Updating license to %u\n",
CONTENT_DATA_DISPLAY_NAME(ContentData), dwLicenceMask);
pack->SetDLCMountIndex(m_iTotalDLCInstalled);
pack->SetDLCDeviceID(ContentData.DeviceID);
pack->updateLicenseMask(dwLicenceMask);
}
StorageManager.UnmountInstalledDLC();
}
++m_iTotalDLCInstalled;
mountNextDLC(iPad);
#endif
return 0;
}
#undef CONTENT_DATA_DISPLAY_NAME
void DLCController::handleDLC(DLCPack* pack) {
unsigned int dwFilesProcessed = 0;
#if defined(_WINDOWS64) || defined(__linux__)
std::vector<std::string> dlcFilenames;
#endif
StorageManager.GetMountedDLCFileList("DLCDrive", dlcFilenames);
for (int i = 0; i < dlcFilenames.size(); i++) {
app.m_dlcManager.readDLCDataFile(dwFilesProcessed, dlcFilenames[i],
pack);
}
if (dwFilesProcessed == 0) app.m_dlcManager.removePack(pack);
}
void DLCController::addCreditText(const wchar_t* lpStr) {
app.DebugPrintf("ADDING CREDIT - %ls\n", lpStr);
SCreditTextItemDef* pCreditStruct = new SCreditTextItemDef;
pCreditStruct->m_eType = eSmallText;
pCreditStruct->m_iStringID[0] = NO_TRANSLATED_STRING;
pCreditStruct->m_iStringID[1] = NO_TRANSLATED_STRING;
pCreditStruct->m_Text = new wchar_t[wcslen(lpStr) + 1];
wcscpy((wchar_t*)pCreditStruct->m_Text, lpStr);
vDLCCredits.push_back(pCreditStruct);
}
bool DLCController::alreadySeenCreditText(const std::wstring& wstemp) {
for (unsigned int i = 0; i < m_vCreditText.size(); i++) {
std::wstring temp = m_vCreditText.at(i);
if (temp.compare(wstemp) == 0) {
return true;
}
}
m_vCreditText.push_back((wchar_t*)wstemp.c_str());
return false;
}
unsigned int DLCController::getDLCCreditsCount() {
return (unsigned int)vDLCCredits.size();
}
SCreditTextItemDef* DLCController::getDLCCredits(int iIndex) {
return vDLCCredits.at(iIndex);
}
#if defined(_WINDOWS64)
int32_t DLCController::registerDLCData(wchar_t* pType, wchar_t* pBannerName,
int iGender, uint64_t ullOfferID_Full,
uint64_t ullOfferID_Trial,
wchar_t* pFirstSkin,
unsigned int uiSortIndex, int iConfig,
wchar_t* pDataFile) {
int32_t hr = 0;
DLC_INFO* pDLCData = new DLC_INFO;
memset(pDLCData, 0, sizeof(DLC_INFO));
pDLCData->ullOfferID_Full = ullOfferID_Full;
pDLCData->ullOfferID_Trial = ullOfferID_Trial;
pDLCData->eDLCType = e_DLC_NotDefined;
pDLCData->iGender = iGender;
pDLCData->uiSortIndex = uiSortIndex;
pDLCData->iConfig = iConfig;
if (pBannerName != L"") {
wcsncpy_s(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
}
if (pDataFile[0] != 0) {
wcsncpy_s(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
}
if (pType != nullptr) {
if (wcscmp(pType, L"Skin") == 0) {
pDLCData->eDLCType = e_DLC_SkinPack;
} else if (wcscmp(pType, L"Gamerpic") == 0) {
pDLCData->eDLCType = e_DLC_Gamerpics;
} else if (wcscmp(pType, L"Theme") == 0) {
pDLCData->eDLCType = e_DLC_Themes;
} else if (wcscmp(pType, L"Avatar") == 0) {
pDLCData->eDLCType = e_DLC_AvatarItems;
} else if (wcscmp(pType, L"MashUpPack") == 0) {
pDLCData->eDLCType = e_DLC_MashupPacks;
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
} else if (wcscmp(pType, L"TexturePack") == 0) {
pDLCData->eDLCType = e_DLC_TexturePacks;
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
}
}
if (ullOfferID_Trial != 0ll) DLCInfo_Trial[ullOfferID_Trial] = pDLCData;
if (ullOfferID_Full != 0ll) DLCInfo_Full[ullOfferID_Full] = pDLCData;
if (pFirstSkin[0] != 0) DLCInfo_SkinName[pFirstSkin] = ullOfferID_Full;
return hr;
}
#elif defined(__linux__)
int32_t DLCController::registerDLCData(wchar_t* pType, wchar_t* pBannerName,
int iGender, uint64_t ullOfferID_Full,
uint64_t ullOfferID_Trial,
wchar_t* pFirstSkin,
unsigned int uiSortIndex, int iConfig,
wchar_t* pDataFile) {
fprintf(stderr,
"warning: DLCController::registerDLCData unimplemented for "
"platform `__linux__`\n");
return 0;
}
#endif
bool DLCController::getDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
uint64_t* pullVal) {
auto it = DLCInfo_SkinName.find(FirstSkin);
if (it == DLCInfo_SkinName.end()) {
return false;
} else {
*pullVal = (uint64_t)it->second;
return true;
}
}
bool DLCController::getDLCFullOfferIDForPackID(const int iPackID,
uint64_t* pullVal) {
auto it = DLCTextures_PackID.find(iPackID);
if (it == DLCTextures_PackID.end()) {
*pullVal = (uint64_t)0;
return false;
} else {
*pullVal = (uint64_t)it->second;
return true;
}
}
DLC_INFO* DLCController::getDLCInfoForTrialOfferID(
uint64_t ullOfferID_Trial) {
if (DLCInfo_Trial.size() > 0) {
auto it = DLCInfo_Trial.find(ullOfferID_Trial);
if (it == DLCInfo_Trial.end()) {
return nullptr;
} else {
return it->second;
}
} else
return nullptr;
}
DLC_INFO* DLCController::getDLCInfoForFullOfferID(uint64_t ullOfferID_Full) {
if (DLCInfo_Full.size() > 0) {
auto it = DLCInfo_Full.find(ullOfferID_Full);
if (it == DLCInfo_Full.end()) {
return nullptr;
} else {
return it->second;
}
} else
return nullptr;
}
DLC_INFO* DLCController::getDLCInfoTrialOffer(int iIndex) {
std::unordered_map<uint64_t, DLC_INFO*>::iterator it =
DLCInfo_Trial.begin();
for (int i = 0; i < iIndex; i++) {
++it;
}
return it->second;
}
DLC_INFO* DLCController::getDLCInfoFullOffer(int iIndex) {
std::unordered_map<uint64_t, DLC_INFO*>::iterator it = DLCInfo_Full.begin();
for (int i = 0; i < iIndex; i++) {
++it;
}
return it->second;
}
uint64_t DLCController::getDLCInfoTexturesFullOffer(int iIndex) {
std::unordered_map<int, uint64_t>::iterator it = DLCTextures_PackID.begin();
for (int i = 0; i < iIndex; i++) {
++it;
}
return it->second;
}
int DLCController::getDLCInfoTrialOffersCount() {
return (int)DLCInfo_Trial.size();
}
int DLCController::getDLCInfoFullOffersCount() {
return (int)DLCInfo_Full.size();
}
int DLCController::getDLCInfoTexturesOffersCount() {
return (int)DLCTextures_PackID.size();
}
unsigned int DLCController::addDLCRequest(eDLCMarketplaceType eType,
bool bPromote) {
{
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
int iPosition = 0;
for (auto it = m_DLCDownloadQueue.begin();
it != m_DLCDownloadQueue.end(); ++it) {
DLCRequest* pCurrent = *it;
if (pCurrent->dwType == m_dwContentTypeA[eType]) {
if (pCurrent->eState == e_DLC_ContentState_Retrieving ||
pCurrent->eState == e_DLC_ContentState_Retrieved) {
return 0;
} else {
if (bPromote) {
m_DLCDownloadQueue.erase(m_DLCDownloadQueue.begin() +
iPosition);
m_DLCDownloadQueue.insert(m_DLCDownloadQueue.begin(),
pCurrent);
}
return 0;
}
}
iPosition++;
}
DLCRequest* pDLCreq = new DLCRequest;
pDLCreq->dwType = m_dwContentTypeA[eType];
pDLCreq->eState = e_DLC_ContentState_Idle;
m_DLCDownloadQueue.push_back(pDLCreq);
m_bAllDLCContentRetrieved = false;
}
app.DebugPrintf("[Consoles_App] Added DLC request.\n");
return 1;
}
bool DLCController::retrieveNextDLCContent() {
int primPad = ProfileManager.GetPrimaryPad();
if (primPad == -1 || !ProfileManager.IsSignedInLive(primPad)) {
return true;
}
{
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin();
it != m_DLCDownloadQueue.end(); ++it) {
DLCRequest* pCurrent = *it;
if (pCurrent->eState == e_DLC_ContentState_Retrieving) {
return true;
}
}
for (auto it = m_DLCDownloadQueue.begin();
it != m_DLCDownloadQueue.end(); ++it) {
DLCRequest* pCurrent = *it;
if (pCurrent->eState == e_DLC_ContentState_Idle) {
#if defined(_DEBUG)
app.DebugPrintf("RetrieveNextDLCContent - type = %d\n",
pCurrent->dwType);
#endif
C4JStorage::EDLCStatus status = StorageManager.GetDLCOffers(
ProfileManager.GetPrimaryPad(),
[this](int iOfferC, std::uint32_t dwType, int pad) {
return dlcOffersReturned(iOfferC, dwType, pad);
},
pCurrent->dwType);
if (status == C4JStorage::EDLC_Pending) {
pCurrent->eState = e_DLC_ContentState_Retrieving;
} else {
app.DebugPrintf("RetrieveNextDLCContent - PROBLEM\n");
pCurrent->eState = e_DLC_ContentState_Retrieved;
}
return true;
}
}
}
app.DebugPrintf("[Consoles_App] Finished downloading dlc content.\n");
return false;
}
bool DLCController::checkTMSDLCCanStop() {
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
for (auto it = m_TMSPPDownloadQueue.begin();
it != m_TMSPPDownloadQueue.end(); ++it) {
TMSPPRequest* pCurrent = *it;
if (pCurrent->eState == e_TMS_ContentState_Retrieving) {
return false;
}
}
return true;
}
int DLCController::dlcOffersReturned(int iOfferC, std::uint32_t dwType,
int iPad) {
{
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin();
it != m_DLCDownloadQueue.end(); ++it) {
DLCRequest* pCurrent = *it;
if (pCurrent->dwType == static_cast<std::uint32_t>(dwType)) {
m_iDLCOfferC = iOfferC;
app.DebugPrintf(
"DLCOffersReturned - type %u, count %d - setting to "
"retrieved\n",
dwType, iOfferC);
pCurrent->eState = e_DLC_ContentState_Retrieved;
break;
}
}
}
return 0;
}
eDLCContentType DLCController::find_eDLCContentType(std::uint32_t dwType) {
for (int i = 0; i < e_DLC_MAX; i++) {
if (m_dwContentTypeA[i] == dwType) {
return (eDLCContentType)i;
}
}
return (eDLCContentType)0;
}
bool DLCController::dlcContentRetrieved(eDLCMarketplaceType eType) {
std::lock_guard<std::mutex> lock(csDLCDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin(); it != m_DLCDownloadQueue.end();
++it) {
DLCRequest* pCurrent = *it;
if ((pCurrent->dwType == m_dwContentTypeA[eType]) &&
(pCurrent->eState == e_DLC_ContentState_Retrieved)) {
return true;
}
}
return false;
}
void DLCController::tickDLCOffersRetrieved() {
if (!m_bAllDLCContentRetrieved) {
if (!retrieveNextDLCContent()) {
app.DebugPrintf("[Consoles_App] All content retrieved.\n");
m_bAllDLCContentRetrieved = true;
}
}
}
void DLCController::clearAndResetDLCDownloadQueue() {
app.DebugPrintf("[Consoles_App] Clear and reset download queue.\n");
int iPosition = 0;
{
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
for (auto it = m_DLCDownloadQueue.begin();
it != m_DLCDownloadQueue.end(); ++it) {
DLCRequest* pCurrent = *it;
delete pCurrent;
iPosition++;
}
m_DLCDownloadQueue.clear();
m_bAllDLCContentRetrieved = true;
}
}
bool DLCController::retrieveNextTMSPPContent() { return false; }
void DLCController::tickTMSPPFilesRetrieved() {
if (m_bTickTMSDLCFiles && !m_bAllTMSContentRetrieved) {
if (retrieveNextTMSPPContent() == false) {
m_bAllTMSContentRetrieved = true;
}
}
}
void DLCController::clearTMSPPFilesRetrieved() {
int iPosition = 0;
{
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
for (auto it = m_TMSPPDownloadQueue.begin();
it != m_TMSPPDownloadQueue.end(); ++it) {
TMSPPRequest* pCurrent = *it;
delete pCurrent;
iPosition++;
}
m_TMSPPDownloadQueue.clear();
m_bAllTMSContentRetrieved = true;
}
}
unsigned int DLCController::addTMSPPFileTypeRequest(eDLCContentType eType,
bool bPromote) {
std::lock_guard<std::mutex> lock(csTMSPPDownloadQueue);
if (eType == e_DLC_TexturePackData) {
int iCount = getDLCInfoFullOffersCount();
for (int i = 0; i < iCount; i++) {
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
if ((pDLC->eDLCType == e_DLC_TexturePacks) ||
(pDLC->eDLCType == e_DLC_MashupPacks)) {
if (pDLC->wchDataFile[0] != 0) {
{
bool bPresent = app.IsFileInTPD(pDLC->iConfig);
if (!bPresent) {
bool bAlreadyInQueue = false;
for (auto it = m_TMSPPDownloadQueue.begin();
it != m_TMSPPDownloadQueue.end(); ++it) {
TMSPPRequest* pCurrent = *it;
if (wcscmp(pDLC->wchDataFile,
pCurrent->wchFilename) == 0) {
bAlreadyInQueue = true;
break;
}
}
if (!bAlreadyInQueue) {
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
pTMSPPreq->CallbackFunc =
&DLCController::tmsPPFileReturned;
pTMSPPreq->lpCallbackParam = this;
pTMSPPreq->eStorageFacility =
C4JStorage::eGlobalStorage_Title;
pTMSPPreq->eFileTypeVal =
C4JStorage::TMS_FILETYPE_BINARY;
memcpy(pTMSPPreq->wchFilename,
pDLC->wchDataFile,
sizeof(wchar_t) * MAX_BANNERNAME_SIZE);
pTMSPPreq->eType = e_DLC_TexturePackData;
pTMSPPreq->eState = e_TMS_ContentState_Queued;
m_bAllTMSContentRetrieved = false;
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
}
} else {
app.DebugPrintf(
"Texture data already present in the TPD\n");
}
}
}
}
}
} else {
int iCount;
iCount = getDLCInfoFullOffersCount();
for (int i = 0; i < iCount; i++) {
DLC_INFO* pDLC = getDLCInfoFullOffer(i);
if (pDLC->eDLCType == eType) {
wchar_t* cString = pDLC->wchBanner;
{
bool bPresent = app.IsFileInMemoryTextures(cString);
if (!bPresent) {
bool bAlreadyInQueue = false;
for (auto it = m_TMSPPDownloadQueue.begin();
it != m_TMSPPDownloadQueue.end(); ++it) {
TMSPPRequest* pCurrent = *it;
if (wcscmp(pDLC->wchBanner,
pCurrent->wchFilename) == 0) {
bAlreadyInQueue = true;
break;
}
}
if (!bAlreadyInQueue) {
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
memset(pTMSPPreq, 0, sizeof(TMSPPRequest));
pTMSPPreq->CallbackFunc =
&DLCController::tmsPPFileReturned;
pTMSPPreq->lpCallbackParam = this;
pTMSPPreq->eStorageFacility =
C4JStorage::eGlobalStorage_Title;
pTMSPPreq->eFileTypeVal =
C4JStorage::TMS_FILETYPE_BINARY;
memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner,
sizeof(wchar_t) * MAX_BANNERNAME_SIZE);
pTMSPPreq->eType = eType;
pTMSPPreq->eState = e_TMS_ContentState_Queued;
m_bAllTMSContentRetrieved = false;
m_TMSPPDownloadQueue.push_back(pTMSPPreq);
app.DebugPrintf(
"===m_TMSPPDownloadQueue Adding %ls, q size is "
"%d\n",
pTMSPPreq->wchFilename,
m_TMSPPDownloadQueue.size());
}
}
}
}
}
}
return 1;
}
int DLCController::tmsPPFileReturned(void* pParam, int iPad, int iUserData,
C4JStorage::PTMSPP_FILEDATA pFileData,
const char* szFilename) {
DLCController* pClass = (DLCController*)pParam;
{
std::lock_guard<std::mutex> lock(pClass->csTMSPPDownloadQueue);
for (auto it = pClass->m_TMSPPDownloadQueue.begin();
it != pClass->m_TMSPPDownloadQueue.end(); ++it) {
TMSPPRequest* pCurrent = *it;
#if defined(_WINDOWS64)
char szFile[MAX_TMSFILENAME_SIZE];
wcstombs(szFile, pCurrent->wchFilename, MAX_TMSFILENAME_SIZE);
if (strcmp(szFilename, szFile) == 0)
#endif
{
pCurrent->eState = e_TMS_ContentState_Retrieved;
if (pFileData != nullptr) {
switch (pCurrent->eType) {
case e_DLC_TexturePackData: {
app.DebugPrintf("--- Got texturepack data %ls\n",
pCurrent->wchFilename);
int iConfig =
app.GetTPConfigVal(pCurrent->wchFilename);
app.AddMemoryTPDFile(iConfig, pFileData->pbData,
pFileData->size);
} break;
default:
app.DebugPrintf("--- Got image data - %ls\n",
pCurrent->wchFilename);
app.AddMemoryTextureFile(pCurrent->wchFilename,
pFileData->pbData,
pFileData->size);
break;
}
} else {
app.DebugPrintf("TMSImageReturned failed (%s)...\n",
szFilename);
}
break;
}
}
}
return 0;
}
-137
View File
@@ -1,137 +0,0 @@
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "app/common/App_structs.h"
#include "app/common/DLC/DLCManager.h"
#include "platform/sdl2/Storage.h"
#include "platform/XboxStubs.h"
struct SCreditTextItemDef;
class DLCPack;
class DLCController {
public:
DLCController();
// Install process
bool startInstallDLCProcess(int iPad);
int dlcInstalledCallback(int iInstalledC, int iPad);
void mountNextDLC(int iPad);
int dlcMountedCallback(int iPad, std::uint32_t dwErr,
std::uint32_t dwLicenceMask);
void handleDLC(DLCPack* pack);
bool dlcInstallPending() { return m_bDLCInstallPending; }
bool dlcInstallProcessCompleted() { return m_bDLCInstallProcessCompleted; }
void clearDLCInstalled() { m_bDLCInstallProcessCompleted = false; }
static int marketplaceCountsCallback(void* pParam,
C4JStorage::DLC_TMS_DETAILS*,
int iPad);
// DLC info registration
static int32_t registerDLCData(wchar_t*, wchar_t*, int, uint64_t, uint64_t,
wchar_t*, unsigned int, int,
wchar_t* pDataFile);
bool getDLCFullOfferIDForSkinID(const std::wstring& FirstSkin,
uint64_t* pullVal);
bool getDLCFullOfferIDForPackID(const int iPackID, uint64_t* pullVal);
DLC_INFO* getDLCInfoForTrialOfferID(uint64_t ullOfferID_Trial);
DLC_INFO* getDLCInfoForFullOfferID(uint64_t ullOfferID_Full);
DLC_INFO* getDLCInfoTrialOffer(int iIndex);
DLC_INFO* getDLCInfoFullOffer(int iIndex);
uint64_t getDLCInfoTexturesFullOffer(int iIndex);
int getDLCInfoTrialOffersCount();
int getDLCInfoFullOffersCount();
int getDLCInfoTexturesOffersCount();
// DLC content/offers
unsigned int addDLCRequest(eDLCMarketplaceType eContentType,
bool bPromote = false);
bool retrieveNextDLCContent();
bool checkTMSDLCCanStop();
int dlcOffersReturned(int iOfferC, std::uint32_t dwType, int iPad);
std::uint32_t getDLCContentType(eDLCContentType eType) {
return m_dwContentTypeA[eType];
}
eDLCContentType find_eDLCContentType(std::uint32_t dwType);
int getDLCOffersCount() { return m_iDLCOfferC; }
bool dlcContentRetrieved(eDLCMarketplaceType eType);
void tickDLCOffersRetrieved();
void clearAndResetDLCDownloadQueue();
// TMS/TMSPP
bool retrieveNextTMSPPContent();
void tickTMSPPFilesRetrieved();
void clearTMSPPFilesRetrieved();
unsigned int addTMSPPFileTypeRequest(eDLCContentType eType,
bool bPromote = false);
static int tmsPPFileReturned(void* pParam, int iPad, int iUserData,
C4JStorage::PTMSPP_FILEDATA pFileData,
const char* szFilename);
// Credit text
void addCreditText(const wchar_t* lpStr);
bool alreadySeenCreditText(const std::wstring& wstemp);
unsigned int getDLCCreditsCount();
SCreditTextItemDef* getDLCCredits(int iIndex);
// New DLC available
void clearNewDLCAvailable() {
m_bNewDLCAvailable = false;
m_bSeenNewDLCTip = true;
}
bool getNewDLCAvailable() { return m_bNewDLCAvailable; }
void displayNewDLCTipAgain() { m_bSeenNewDLCTip = false; }
bool displayNewDLCTip() {
if (!m_bSeenNewDLCTip) {
m_bSeenNewDLCTip = true;
return true;
} else
return false;
}
void setTickTMSDLCFiles(bool bVal) { m_bTickTMSDLCFiles = bVal; }
// Public data needed by other parts
std::vector<std::wstring> m_vCreditText;
std::uint8_t* m_pDLCFileBuffer;
unsigned int m_dwDLCFileSize;
// DLC install counters (accessed by dlcMountedCallback)
int m_iTotalDLC;
int m_iTotalDLCInstalled;
// Static maps
static std::unordered_map<PlayerUID, MOJANG_DATA*> MojangData;
static std::unordered_map<int, uint64_t> DLCTextures_PackID;
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Trial;
static std::unordered_map<uint64_t, DLC_INFO*> DLCInfo_Full;
static std::unordered_map<std::wstring, uint64_t> DLCInfo_SkinName;
static std::uint32_t m_dwContentTypeA[e_Marketplace_MAX];
private:
std::vector<SCreditTextItemDef*> vDLCCredits;
std::vector<DLCRequest*> m_DLCDownloadQueue;
std::vector<TMSPPRequest*> m_TMSPPDownloadQueue;
int m_iDLCOfferC;
bool m_bAllDLCContentRetrieved;
bool m_bAllTMSContentRetrieved;
bool m_bTickTMSDLCFiles;
std::mutex csDLCDownloadQueue;
std::mutex csTMSPPDownloadQueue;
bool m_bDLCInstallProcessCompleted;
bool m_bDLCInstallPending;
bool m_bDefaultCapeInstallAttempted;
bool m_bNewDLCAvailable;
bool m_bSeenNewDLCTip;
};
-33
View File
@@ -1,33 +0,0 @@
#include "app/common/DebugOptions.h"
DebugOptions::DebugOptions() {
#if defined(_DEBUG_MENUS_ENABLED)
#if defined(_CONTENT_PACKAGE)
m_bDebugOptions =
false; // make them off by default in a content package build
#else
m_bDebugOptions = true;
#endif
#else
m_bDebugOptions = false;
#endif
m_bLoadSavesFromFolderEnabled = false;
m_bWriteSavesToFolderEnabled = false;
m_bMobsDontAttack = false;
m_bMobsDontTick = false;
m_bFreezePlayers = false;
#if defined(_CONTENT_PACAKGE)
m_bUseDPadForDebug = false;
#else
m_bUseDPadForDebug = true;
#endif
}
#if defined(_DEBUG_MENUS_ENABLED)
bool DebugOptions::debugArtToolsOn(unsigned int debugMask) {
return settingsOn() &&
(debugMask & (1L << eDebugSetting_ArtTools)) != 0;
}
#endif
-52
View File
@@ -1,52 +0,0 @@
#pragma once
#include "app/common/Console_Debug_enum.h"
class DebugOptions {
public:
DebugOptions();
bool settingsOn() const { return m_bDebugOptions; }
void setDebugOptions(bool bVal) { m_bDebugOptions = bVal; }
bool getLoadSavesFromFolderEnabled() const {
return m_bLoadSavesFromFolderEnabled;
}
void setLoadSavesFromFolderEnabled(bool bVal) {
m_bLoadSavesFromFolderEnabled = bVal;
}
bool getWriteSavesToFolderEnabled() const {
return m_bWriteSavesToFolderEnabled;
}
void setWriteSavesToFolderEnabled(bool bVal) {
m_bWriteSavesToFolderEnabled = bVal;
}
bool getMobsDontAttack() const { return m_bMobsDontAttack; }
void setMobsDontAttack(bool bVal) { m_bMobsDontAttack = bVal; }
bool getUseDPadForDebug() const { return m_bUseDPadForDebug; }
void setUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; }
bool getMobsDontTick() const { return m_bMobsDontTick; }
void setMobsDontTick(bool bVal) { m_bMobsDontTick = bVal; }
bool getFreezePlayers() const { return m_bFreezePlayers; }
void setFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; }
#if defined(_DEBUG_MENUS_ENABLED)
bool debugArtToolsOn(unsigned int debugMask);
#else
bool debugArtToolsOn(unsigned int) { return false; }
#endif
private:
bool m_bDebugOptions;
bool m_bLoadSavesFromFolderEnabled;
bool m_bWriteSavesToFolderEnabled;
bool m_bMobsDontAttack;
bool m_bUseDPadForDebug;
bool m_bMobsDontTick;
bool m_bFreezePlayers;
};
+7034 -115
View File
File diff suppressed because it is too large Load Diff
+438 -599
View File
File diff suppressed because it is too large Load Diff
-58
View File
@@ -1,58 +0,0 @@
#include "app/common/GameMenuService.h"
#include "app/common/Game.h"
bool GameMenuService::openInventory(int iPad, std::shared_ptr<LocalPlayer> player, bool navigateBack) {
return game_.LoadInventoryMenu(iPad, player, navigateBack);
}
bool GameMenuService::openCreative(int iPad, std::shared_ptr<LocalPlayer> player, bool navigateBack) {
return game_.LoadCreativeMenu(iPad, player, navigateBack);
}
bool GameMenuService::openCrafting2x2(int iPad, std::shared_ptr<LocalPlayer> player) {
return game_.LoadCrafting2x2Menu(iPad, player);
}
bool GameMenuService::openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x, int y, int z) {
return game_.LoadCrafting3x3Menu(iPad, player, x, y, z);
}
bool GameMenuService::openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x, int y, int z, Level* level, const std::wstring& name) {
return game_.LoadEnchantingMenu(iPad, inventory, x, y, z, level, name);
}
bool GameMenuService::openFurnace(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<FurnaceTileEntity> furnace) {
return game_.LoadFurnaceMenu(iPad, inventory, furnace);
}
bool GameMenuService::openBrewingStand(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<BrewingStandTileEntity> brewingStand) {
return game_.LoadBrewingStandMenu(iPad, inventory, brewingStand);
}
bool GameMenuService::openContainer(int iPad, std::shared_ptr<Container> inventory, std::shared_ptr<Container> container) {
return game_.LoadContainerMenu(iPad, inventory, container);
}
bool GameMenuService::openTrap(int iPad, std::shared_ptr<Container> inventory, std::shared_ptr<DispenserTileEntity> trap) {
return game_.LoadTrapMenu(iPad, inventory, trap);
}
bool GameMenuService::openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x, int y, int z) {
return game_.LoadFireworksMenu(iPad, player, x, y, z);
}
bool GameMenuService::openSign(int iPad, std::shared_ptr<SignTileEntity> sign) {
return game_.LoadSignEntryMenu(iPad, sign);
}
bool GameMenuService::openRepairing(int iPad, std::shared_ptr<Inventory> inventory, Level* level, int x, int y, int z) {
return game_.LoadRepairingMenu(iPad, inventory, level, x, y, z);
}
bool GameMenuService::openTrading(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<Merchant> trader, Level* level, const std::wstring& name) {
return game_.LoadTradingMenu(iPad, inventory, trader, level, name);
}
bool GameMenuService::openCommandBlock(int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) {
return game_.LoadCommandBlockMenu(iPad, commandBlock);
}
bool GameMenuService::openHopper(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<HopperTileEntity> hopper) {
return game_.LoadHopperMenu(iPad, inventory, hopper);
}
bool GameMenuService::openHopperMinecart(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<MinecartHopper> hopper) {
return game_.LoadHopperMenu(iPad, inventory, hopper);
}
bool GameMenuService::openHorse(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<Container> container, std::shared_ptr<EntityHorse> horse) {
return game_.LoadHorseMenu(iPad, inventory, container, horse);
}
bool GameMenuService::openBeacon(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<BeaconTileEntity> beacon) {
return game_.LoadBeaconMenu(iPad, inventory, beacon);
}
-54
View File
@@ -1,54 +0,0 @@
#pragma once
#include "minecraft/client/IMenuService.h"
class Game;
class GameMenuService : public IMenuService {
public:
explicit GameMenuService(Game& game) : game_(game) {}
bool openInventory(int iPad, std::shared_ptr<LocalPlayer> player,
bool navigateBack) override;
bool openCreative(int iPad, std::shared_ptr<LocalPlayer> player,
bool navigateBack) override;
bool openCrafting2x2(int iPad,
std::shared_ptr<LocalPlayer> player) override;
bool openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x,
int y, int z) override;
bool openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x,
int y, int z, Level* level,
const std::wstring& name) override;
bool openFurnace(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<FurnaceTileEntity> furnace) override;
bool openBrewingStand(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BrewingStandTileEntity> brewingStand) override;
bool openContainer(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<Container> container) override;
bool openTrap(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<DispenserTileEntity> trap) override;
bool openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x,
int y, int z) override;
bool openSign(int iPad, std::shared_ptr<SignTileEntity> sign) override;
bool openRepairing(int iPad, std::shared_ptr<Inventory> inventory,
Level* level, int x, int y, int z) override;
bool openTrading(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Merchant> trader, Level* level,
const std::wstring& name) override;
bool openCommandBlock(
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) override;
bool openHopper(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<HopperTileEntity> hopper) override;
bool openHopperMinecart(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<MinecartHopper> hopper) override;
bool openHorse(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Container> container,
std::shared_ptr<EntityHorse> horse) override;
bool openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BeaconTileEntity> beacon) override;
private:
Game& game_;
};
@@ -1,25 +0,0 @@
#pragma once
#include "ConsoleGameRulesConstants.h"
#include "GameRuleManager.h"
#include "app/common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
#include "app/common/GameRules/LevelGeneration/BiomeOverride.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/GameRules/LevelGeneration/StartFeature.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddEnchantmentRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/CollectItemRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompleteAllRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/CompoundGameRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/NamedAreaRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/UpdatePlayerRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.h"
#include "app/common/GameRules/LevelRules/Rules/GameRule.h"
#include "app/common/GameRules/LevelRules/Rules/GameRulesInstance.h"
File diff suppressed because it is too large Load Diff
-77
View File
@@ -1,77 +0,0 @@
#pragma once
#include <cstdint>
#include "app/common/App_structs.h"
#include "platform/sdl2/Profile.h"
#include "platform/XboxStubs.h"
class GameSettingsManager {
public:
GameSettingsManager();
void initGameSettings();
static int oldProfileVersionCallback(void* pParam, unsigned char* pucData,
const unsigned short usVersion,
const int iPad);
static int defaultOptionsCallback(void* pParam,
C_4JProfile::PROFILESETTINGS* pSettings,
const int iPad);
int setDefaultOptions(C_4JProfile::PROFILESETTINGS* pSettings,
const int iPad);
void setGameSettings(int iPad, eGameSetting eVal, unsigned char ucVal);
unsigned char getGameSettings(int iPad, eGameSetting eVal);
unsigned char getGameSettings(eGameSetting eVal);
void checkGameSettingsChanged(bool bOverride5MinuteTimer = false,
int iPad = XUSER_INDEX_ANY);
void applyGameSettingsChanged(int iPad);
void clearGameSettingsChangedFlag(int iPad);
void actionGameSettings(int iPad, eGameSetting eVal);
unsigned int getGameSettingsDebugMask(int iPad = -1,
bool bOverridePlayer = false);
void setGameSettingsDebugMask(int iPad, unsigned int uiVal);
void actionDebugMask(int iPad, bool bSetAllClear = false);
void setSpecialTutorialCompletionFlag(int iPad, int index);
// Mash-up pack worlds
void hideMashupPackWorld(int iPad, unsigned int iMashupPackID);
void enableMashupPackWorlds(int iPad);
unsigned int getMashupPackWorlds(int iPad);
// Language/locale
void setMinecraftLanguage(int iPad, unsigned char ucLanguage);
unsigned char getMinecraftLanguage(int iPad);
void setMinecraftLocale(int iPad, unsigned char ucLocale);
unsigned char getMinecraftLocale(int iPad);
// Game host options (bitfield versions)
void setGameHostOption(unsigned int& uiHostSettings, eGameHostOption eVal,
unsigned int uiVal);
unsigned int getGameHostOption(unsigned int uiHostSettings,
eGameHostOption eVal);
bool canRecordStatsAndAchievements();
// HandleXuiActions and HandleButtonPresses
void handleXuiActions();
void handleButtonPresses();
// Action-related
static void setActionConfirmed(void* param);
// Saving message
int displaySavingMessage(const C4JStorage::ESavingMessage eMsg, int iPad);
// Game settings array - public, referenced by Game via alias
GAME_SETTINGS* GameSettingsA[XUSER_MAX_COUNT];
// Game host settings bitfield
unsigned int m_uiGameHostSettings;
private:
void handleButtonPresses(int iPad);
};
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2,7 +2,7 @@
#include <cstdint>
#include "minecraft/GameEnums.h"
#include "app/common/App_enums.h"
class IPlatformGame {
public:
-863
View File
@@ -1,863 +0,0 @@
#include "app/common/LocalizationManager.h"
#include <assert.h>
#include <stdlib.h>
#include <wchar.h>
#include <string>
#include "minecraft/GameEnums.h"
#include "app/common/App_structs.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/Colours/ColourTable.h"
#include "app/common/UI/All Platforms/ArchiveFile.h"
#include "app/linux/LinuxGame.h"
#include "java/Random.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePack.h"
#include "minecraft/client/skins/TexturePackRepository.h"
#include "platform/InputActions.h"
#include "platform/sdl2/Input.h"
#include "platform/sdl2/Render.h"
#include "platform/XboxStubs.h"
#include "strings.h"
#include "util/StringHelpers.h"
int LocalizationManager::s_iHTMLFontSizesA[eHTMLSize_COUNT] = {
20, 13, 20, 26};
TIPSTRUCT LocalizationManager::m_GameTipA[MAX_TIPS_GAMETIP] = {
{0, IDS_TIPS_GAMETIP_1}, {0, IDS_TIPS_GAMETIP_2},
{0, IDS_TIPS_GAMETIP_3}, {0, IDS_TIPS_GAMETIP_4},
{0, IDS_TIPS_GAMETIP_5}, {0, IDS_TIPS_GAMETIP_6},
{0, IDS_TIPS_GAMETIP_7}, {0, IDS_TIPS_GAMETIP_8},
{0, IDS_TIPS_GAMETIP_9}, {0, IDS_TIPS_GAMETIP_10},
{0, IDS_TIPS_GAMETIP_11}, {0, IDS_TIPS_GAMETIP_12},
{0, IDS_TIPS_GAMETIP_13}, {0, IDS_TIPS_GAMETIP_14},
{0, IDS_TIPS_GAMETIP_15}, {0, IDS_TIPS_GAMETIP_16},
{0, IDS_TIPS_GAMETIP_17}, {0, IDS_TIPS_GAMETIP_18},
{0, IDS_TIPS_GAMETIP_19}, {0, IDS_TIPS_GAMETIP_20},
{0, IDS_TIPS_GAMETIP_21}, {0, IDS_TIPS_GAMETIP_22},
{0, IDS_TIPS_GAMETIP_23}, {0, IDS_TIPS_GAMETIP_24},
{0, IDS_TIPS_GAMETIP_25}, {0, IDS_TIPS_GAMETIP_26},
{0, IDS_TIPS_GAMETIP_27}, {0, IDS_TIPS_GAMETIP_28},
{0, IDS_TIPS_GAMETIP_29}, {0, IDS_TIPS_GAMETIP_30},
{0, IDS_TIPS_GAMETIP_31}, {0, IDS_TIPS_GAMETIP_32},
{0, IDS_TIPS_GAMETIP_33}, {0, IDS_TIPS_GAMETIP_34},
{0, IDS_TIPS_GAMETIP_35}, {0, IDS_TIPS_GAMETIP_36},
{0, IDS_TIPS_GAMETIP_37}, {0, IDS_TIPS_GAMETIP_38},
{0, IDS_TIPS_GAMETIP_39}, {0, IDS_TIPS_GAMETIP_40},
{0, IDS_TIPS_GAMETIP_41}, {0, IDS_TIPS_GAMETIP_42},
{0, IDS_TIPS_GAMETIP_43}, {0, IDS_TIPS_GAMETIP_44},
{0, IDS_TIPS_GAMETIP_45}, {0, IDS_TIPS_GAMETIP_46},
{0, IDS_TIPS_GAMETIP_47}, {0, IDS_TIPS_GAMETIP_48},
{0, IDS_TIPS_GAMETIP_49}, {0, IDS_TIPS_GAMETIP_50},
};
TIPSTRUCT LocalizationManager::m_TriviaTipA[MAX_TIPS_TRIVIATIP] = {
{0, IDS_TIPS_TRIVIA_1}, {0, IDS_TIPS_TRIVIA_2}, {0, IDS_TIPS_TRIVIA_3},
{0, IDS_TIPS_TRIVIA_4}, {0, IDS_TIPS_TRIVIA_5}, {0, IDS_TIPS_TRIVIA_6},
{0, IDS_TIPS_TRIVIA_7}, {0, IDS_TIPS_TRIVIA_8}, {0, IDS_TIPS_TRIVIA_9},
{0, IDS_TIPS_TRIVIA_10}, {0, IDS_TIPS_TRIVIA_11}, {0, IDS_TIPS_TRIVIA_12},
{0, IDS_TIPS_TRIVIA_13}, {0, IDS_TIPS_TRIVIA_14}, {0, IDS_TIPS_TRIVIA_15},
{0, IDS_TIPS_TRIVIA_16}, {0, IDS_TIPS_TRIVIA_17}, {0, IDS_TIPS_TRIVIA_18},
{0, IDS_TIPS_TRIVIA_19}, {0, IDS_TIPS_TRIVIA_20},
};
Random* LocalizationManager::TipRandom = new Random();
LocalizationManager::LocalizationManager()
: m_stringTable(nullptr), m_uiCurrentTip(0) {
memset(m_TipIDA, 0, sizeof(m_TipIDA));
}
void LocalizationManager::loadStringTable(ArchiveFile* mediaArchive) {
if (m_stringTable != nullptr) {
// we need to unload the current std::string table, this is a reload
delete m_stringTable;
}
std::wstring localisationFile = L"languages.loc";
if (mediaArchive->hasFile(localisationFile)) {
std::vector<uint8_t> locFile =
mediaArchive->getFile(localisationFile);
m_stringTable = new StringTable(locFile.data(), locFile.size());
} else {
m_stringTable = nullptr;
assert(false);
// AHHHHHHHHH.
}
}
const wchar_t* LocalizationManager::getString(int iID) const {
return m_stringTable->getString(iID);
}
int LocalizationManager::TipsSortFunction(const void* a, const void* b) {
int s1 = ((TIPSTRUCT*)a)->iSortValue;
int s2 = ((TIPSTRUCT*)b)->iSortValue;
if (s1 > s2) {
return 1;
} else if (s1 == s2) {
return 0;
}
return -1;
}
void LocalizationManager::initialiseTips() {
memset(m_TipIDA, 0, sizeof(m_TipIDA));
if (!RenderManager.IsHiDef()) {
m_GameTipA[0].uiStringID = IDS_TIPS_GAMETIP_0;
}
#if defined(_CONTENT_PACKAGE)
for (int i = 1; i < MAX_TIPS_GAMETIP; i++) {
m_GameTipA[i].iSortValue = TipRandom->nextInt();
}
qsort(&m_GameTipA[1], MAX_TIPS_GAMETIP - 1, sizeof(TIPSTRUCT),
TipsSortFunction);
#endif
for (int i = 0; i < MAX_TIPS_TRIVIATIP; i++) {
m_TriviaTipA[i].iSortValue = TipRandom->nextInt();
}
qsort(m_TriviaTipA, MAX_TIPS_TRIVIATIP, sizeof(TIPSTRUCT),
TipsSortFunction);
int iCurrentGameTip = 0;
int iCurrentTriviaTip = 0;
for (int i = 0; i < MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP; i++) {
if ((i % 3 == 2) && (iCurrentTriviaTip < MAX_TIPS_TRIVIATIP)) {
m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID;
} else {
if (iCurrentGameTip < MAX_TIPS_GAMETIP) {
m_TipIDA[i] = m_GameTipA[iCurrentGameTip++].uiStringID;
} else {
m_TipIDA[i] = m_TriviaTipA[iCurrentTriviaTip++].uiStringID;
}
}
if (m_TipIDA[i] == 0) {
#if !defined(_CONTENT_PACKAGE)
assert(0);
#endif
}
}
m_uiCurrentTip = 0;
}
int LocalizationManager::getNextTip() {
static bool bShowSkinDLCTip = true;
if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) {
return IDS_TIPS_GAMETIP_NEWDLC;
} else {
if (bShowSkinDLCTip) {
bShowSkinDLCTip = false;
if (app.DLCInstallProcessCompleted()) {
if (app.m_dlcManager.getPackCount(DLCManager::e_DLCType_Skin) ==
0) {
return IDS_TIPS_GAMETIP_SKINPACKS;
}
} else {
return IDS_TIPS_GAMETIP_SKINPACKS;
}
}
}
if (m_uiCurrentTip == MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP)
m_uiCurrentTip = 0;
return m_TipIDA[m_uiCurrentTip++];
}
int LocalizationManager::getHTMLColour(eMinecraftColour colour) {
Minecraft* pMinecraft = Minecraft::GetInstance();
return pMinecraft->skins->getSelected()->getColourTable()->getColour(
colour);
}
int LocalizationManager::getHTMLFontSize(EHTMLFontSize size) {
return s_iHTMLFontSizesA[size];
}
std::wstring LocalizationManager::formatHTMLString(
int iPad, const std::wstring& desc, int shadowColour /*= 0xFFFFFFFF*/) {
std::wstring text(desc);
wchar_t replacements[64];
text = replaceAll(text, L"{*B*}", L"<br />");
swprintf(replacements, 64, L"<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T1));
text = replaceAll(text, L"{*T1*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T2));
text = replaceAll(text, L"{*T2*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T3));
text = replaceAll(text, L"{*T3*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_Black));
text = replaceAll(text, L"{*ETB*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_White));
text = replaceAll(text, L"{*ETW*}", replacements);
text = replaceAll(text, L"{*EF*}", L"</font>");
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_0), shadowColour);
text = replaceAll(text, L"{*C0*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_1), shadowColour);
text = replaceAll(text, L"{*C1*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_2), shadowColour);
text = replaceAll(text, L"{*C2*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_3), shadowColour);
text = replaceAll(text, L"{*C3*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_4), shadowColour);
text = replaceAll(text, L"{*C4*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_5), shadowColour);
text = replaceAll(text, L"{*C5*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_6), shadowColour);
text = replaceAll(text, L"{*C6*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_7), shadowColour);
text = replaceAll(text, L"{*C7*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_8), shadowColour);
text = replaceAll(text, L"{*C8*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_9), shadowColour);
text = replaceAll(text, L"{*C9*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_a), shadowColour);
text = replaceAll(text, L"{*CA*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_b), shadowColour);
text = replaceAll(text, L"{*CB*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_c), shadowColour);
text = replaceAll(text, L"{*CC*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_d), shadowColour);
text = replaceAll(text, L"{*CD*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_e), shadowColour);
text = replaceAll(text, L"{*CE*}", replacements);
swprintf(replacements, 64, L"<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_f), shadowColour);
text = replaceAll(text, L"{*CF*}", replacements);
// Swap for southpaw.
if (app.GetGameSettings(iPad, eGameSetting_ControlSouthPaw)) {
text =
replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
text = replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}",
getVKReplacement(VK_PAD_RTHUMB_LEFT));
} else {
text = replaceAll(text, L"{*CONTROLLER_ACTION_MOVE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
text =
replaceAll(text, L"{*CONTROLLER_ACTION_LOOK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
text = replaceAll(text, L"{*CONTROLLER_MENU_NAVIGATE*}",
getVKReplacement(VK_PAD_LTHUMB_LEFT));
}
text = replaceAll(text, L"{*CONTROLLER_ACTION_JUMP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_JUMP));
text =
replaceAll(text, L"{*CONTROLLER_ACTION_SNEAK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
text = replaceAll(text, L"{*CONTROLLER_ACTION_USE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_USE));
text = replaceAll(text, L"{*CONTROLLER_ACTION_ACTION*}",
getActionReplacement(iPad, MINECRAFT_ACTION_ACTION));
text = replaceAll(text, L"{*CONTROLLER_ACTION_LEFT_SCROLL*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LEFT_SCROLL));
text =
replaceAll(text, L"{*CONTROLLER_ACTION_RIGHT_SCROLL*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT_SCROLL));
text = replaceAll(text, L"{*CONTROLLER_ACTION_INVENTORY*}",
getActionReplacement(iPad, MINECRAFT_ACTION_INVENTORY));
text = replaceAll(text, L"{*CONTROLLER_ACTION_CRAFTING*}",
getActionReplacement(iPad, MINECRAFT_ACTION_CRAFTING));
text = replaceAll(text, L"{*CONTROLLER_ACTION_DROP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DROP));
text = replaceAll(
text, L"{*CONTROLLER_ACTION_CAMERA*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RENDER_THIRD_PERSON));
text = replaceAll(text, L"{*CONTROLLER_ACTION_MENU_PAGEDOWN*}",
getActionReplacement(iPad, ACTION_MENU_PAGEDOWN));
text =
replaceAll(text, L"{*CONTROLLER_ACTION_DISMOUNT*}",
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
text = replaceAll(text, L"{*CONTROLLER_VK_A*}", getVKReplacement(VK_PAD_A));
text = replaceAll(text, L"{*CONTROLLER_VK_B*}", getVKReplacement(VK_PAD_B));
text = replaceAll(text, L"{*CONTROLLER_VK_X*}", getVKReplacement(VK_PAD_X));
text = replaceAll(text, L"{*CONTROLLER_VK_Y*}", getVKReplacement(VK_PAD_Y));
text = replaceAll(text, L"{*CONTROLLER_VK_LB*}",
getVKReplacement(VK_PAD_LSHOULDER));
text = replaceAll(text, L"{*CONTROLLER_VK_RB*}",
getVKReplacement(VK_PAD_RSHOULDER));
text = replaceAll(text, L"{*CONTROLLER_VK_LS*}",
getVKReplacement(VK_PAD_LTHUMB_UP));
text = replaceAll(text, L"{*CONTROLLER_VK_RS*}",
getVKReplacement(VK_PAD_RTHUMB_UP));
text = replaceAll(text, L"{*CONTROLLER_VK_LT*}",
getVKReplacement(VK_PAD_LTRIGGER));
text = replaceAll(text, L"{*CONTROLLER_VK_RT*}",
getVKReplacement(VK_PAD_RTRIGGER));
text = replaceAll(text, L"{*ICON_SHANK_01*}",
getIconReplacement(XZP_ICON_SHANK_01));
text = replaceAll(text, L"{*ICON_SHANK_03*}",
getIconReplacement(XZP_ICON_SHANK_03));
text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_UP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_UP));
text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_DOWN*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_DOWN));
text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_RIGHT*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_RIGHT));
text = replaceAll(text, L"{*CONTROLLER_ACTION_DPAD_LEFT*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_LEFT));
std::uint32_t dwLanguage = XGetLanguage();
switch (dwLanguage) {
case XC_LANGUAGE_KOREAN:
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
text = replaceAll(text, L"&nbsp;", L"");
break;
}
return text;
}
std::wstring LocalizationManager::getActionReplacement(
int iPad, unsigned char ucAction) {
unsigned int input = InputManager.GetGameJoypadMaps(
InputManager.GetJoypadMapVal(iPad), ucAction);
std::wstring replacement = L"";
if (input & _360_JOY_BUTTON_A)
replacement = L"ButtonA";
else if (input & _360_JOY_BUTTON_B)
replacement = L"ButtonB";
else if (input & _360_JOY_BUTTON_X)
replacement = L"ButtonX";
else if (input & _360_JOY_BUTTON_Y)
replacement = L"ButtonY";
else if ((input & _360_JOY_BUTTON_LSTICK_UP) ||
(input & _360_JOY_BUTTON_LSTICK_DOWN) ||
(input & _360_JOY_BUTTON_LSTICK_LEFT) ||
(input & _360_JOY_BUTTON_LSTICK_RIGHT)) {
replacement = L"ButtonLeftStick";
} else if ((input & _360_JOY_BUTTON_RSTICK_LEFT) ||
(input & _360_JOY_BUTTON_RSTICK_RIGHT) ||
(input & _360_JOY_BUTTON_RSTICK_UP) ||
(input & _360_JOY_BUTTON_RSTICK_DOWN)) {
replacement = L"ButtonRightStick";
} else if (input & _360_JOY_BUTTON_DPAD_LEFT)
replacement = L"ButtonDpadL";
else if (input & _360_JOY_BUTTON_DPAD_RIGHT)
replacement = L"ButtonDpadR";
else if (input & _360_JOY_BUTTON_DPAD_UP)
replacement = L"ButtonDpadU";
else if (input & _360_JOY_BUTTON_DPAD_DOWN)
replacement = L"ButtonDpadD";
else if (input & _360_JOY_BUTTON_LT)
replacement = L"ButtonLeftTrigger";
else if (input & _360_JOY_BUTTON_RT)
replacement = L"ButtonRightTrigger";
else if (input & _360_JOY_BUTTON_RB)
replacement = L"ButtonRightBumper";
else if (input & _360_JOY_BUTTON_LB)
replacement = L"ButtonLeftBumper";
else if (input & _360_JOY_BUTTON_BACK)
replacement = L"ButtonBack";
else if (input & _360_JOY_BUTTON_START)
replacement = L"ButtonStart";
else if (input & _360_JOY_BUTTON_RTHUMB)
replacement = L"ButtonRS";
else if (input & _360_JOY_BUTTON_LTHUMB)
replacement = L"ButtonLS";
wchar_t string[128];
#if defined(_WIN64)
int size = 45;
if (ui.getScreenWidth() < 1920) size = 30;
#else
int size = 45;
#endif
swprintf(string, 128,
L"<img src=\"%ls\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
replacement.c_str(), size, size);
return string;
}
std::wstring LocalizationManager::getVKReplacement(unsigned int uiVKey) {
std::wstring replacement = L"";
switch (uiVKey) {
case VK_PAD_A:
replacement = L"ButtonA";
break;
case VK_PAD_B:
replacement = L"ButtonB";
break;
case VK_PAD_X:
replacement = L"ButtonX";
break;
case VK_PAD_Y:
replacement = L"ButtonY";
break;
case VK_PAD_LSHOULDER:
replacement = L"ButtonLeftBumper";
break;
case VK_PAD_RSHOULDER:
replacement = L"ButtonRightBumper";
break;
case VK_PAD_LTRIGGER:
replacement = L"ButtonLeftTrigger";
break;
case VK_PAD_RTRIGGER:
replacement = L"ButtonRightTrigger";
break;
case VK_PAD_LTHUMB_UP:
case VK_PAD_LTHUMB_DOWN:
case VK_PAD_LTHUMB_RIGHT:
case VK_PAD_LTHUMB_LEFT:
case VK_PAD_LTHUMB_UPLEFT:
case VK_PAD_LTHUMB_UPRIGHT:
case VK_PAD_LTHUMB_DOWNRIGHT:
case VK_PAD_LTHUMB_DOWNLEFT:
replacement = L"ButtonLeftStick";
break;
case VK_PAD_RTHUMB_UP:
case VK_PAD_RTHUMB_DOWN:
case VK_PAD_RTHUMB_RIGHT:
case VK_PAD_RTHUMB_LEFT:
case VK_PAD_RTHUMB_UPLEFT:
case VK_PAD_RTHUMB_UPRIGHT:
case VK_PAD_RTHUMB_DOWNRIGHT:
case VK_PAD_RTHUMB_DOWNLEFT:
replacement = L"ButtonRightStick";
break;
default:
break;
}
wchar_t string[128];
#if defined(_WIN64)
int size = 45;
if (ui.getScreenWidth() < 1920) size = 30;
#else
int size = 45;
#endif
swprintf(string, 128,
L"<img src=\"%ls\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
replacement.c_str(), size, size);
return string;
}
std::wstring LocalizationManager::getIconReplacement(unsigned int uiIcon) {
wchar_t string[128];
#if defined(_WIN64)
int size = 33;
if (ui.getScreenWidth() < 1920) size = 22;
#else
int size = 33;
#endif
swprintf(string, 128,
L"<img src=\"Icon_Shank\" align=\"middle\" height=\"%d\" "
L"width=\"%d\"/>",
size, size);
std::wstring result = L"";
switch (uiIcon) {
case XZP_ICON_SHANK_01:
result = string;
break;
case XZP_ICON_SHANK_03:
result.append(string).append(string).append(string);
break;
default:
break;
}
return result;
}
void LocalizationManager::getLocale(
std::vector<std::wstring>& vecWstrLocales) {
std::vector<eMCLang> locales;
const unsigned int systemLanguage = XGetLanguage();
switch (systemLanguage) {
case XC_LANGUAGE_ENGLISH:
switch (XGetLocale()) {
case XC_LOCALE_AUSTRALIA:
case XC_LOCALE_CANADA:
case XC_LOCALE_CZECH_REPUBLIC:
case XC_LOCALE_GREECE:
case XC_LOCALE_HONG_KONG:
case XC_LOCALE_HUNGARY:
case XC_LOCALE_INDIA:
case XC_LOCALE_IRELAND:
case XC_LOCALE_ISRAEL:
case XC_LOCALE_NEW_ZEALAND:
case XC_LOCALE_SAUDI_ARABIA:
case XC_LOCALE_SINGAPORE:
case XC_LOCALE_SLOVAK_REPUBLIC:
case XC_LOCALE_SOUTH_AFRICA:
case XC_LOCALE_UNITED_ARAB_EMIRATES:
case XC_LOCALE_GREAT_BRITAIN:
locales.push_back(eMCLang_enGB);
break;
default:
break;
}
break;
case XC_LANGUAGE_JAPANESE:
locales.push_back(eMCLang_jaJP);
break;
case XC_LANGUAGE_GERMAN:
switch (XGetLocale()) {
case XC_LOCALE_AUSTRIA:
locales.push_back(eMCLang_deAT);
break;
case XC_LOCALE_SWITZERLAND:
locales.push_back(eMCLang_deCH);
break;
default:
break;
}
locales.push_back(eMCLang_deDE);
break;
case XC_LANGUAGE_FRENCH:
switch (XGetLocale()) {
case XC_LOCALE_BELGIUM:
locales.push_back(eMCLang_frBE);
break;
case XC_LOCALE_CANADA:
locales.push_back(eMCLang_frCA);
break;
case XC_LOCALE_SWITZERLAND:
locales.push_back(eMCLang_frCH);
break;
default:
break;
}
locales.push_back(eMCLang_frFR);
break;
case XC_LANGUAGE_SPANISH:
switch (XGetLocale()) {
case XC_LOCALE_MEXICO:
case XC_LOCALE_ARGENTINA:
case XC_LOCALE_CHILE:
case XC_LOCALE_COLOMBIA:
case XC_LOCALE_UNITED_STATES:
case XC_LOCALE_LATIN_AMERICA:
locales.push_back(eMCLang_laLAS);
locales.push_back(eMCLang_esMX);
break;
default:
break;
}
locales.push_back(eMCLang_esES);
break;
case XC_LANGUAGE_ITALIAN:
locales.push_back(eMCLang_itIT);
break;
case XC_LANGUAGE_KOREAN:
locales.push_back(eMCLang_koKR);
break;
case XC_LANGUAGE_TCHINESE:
switch (XGetLocale()) {
case XC_LOCALE_HONG_KONG:
locales.push_back(eMCLang_zhHK);
locales.push_back(eMCLang_zhTW);
break;
case XC_LOCALE_TAIWAN:
locales.push_back(eMCLang_zhTW);
locales.push_back(eMCLang_zhHK);
default:
break;
}
locales.push_back(eMCLang_hant);
locales.push_back(eMCLang_zhCHT);
break;
case XC_LANGUAGE_PORTUGUESE:
if (XGetLocale() == XC_LOCALE_BRAZIL) {
locales.push_back(eMCLang_ptBR);
}
locales.push_back(eMCLang_ptPT);
break;
case XC_LANGUAGE_POLISH:
locales.push_back(eMCLang_plPL);
break;
case XC_LANGUAGE_RUSSIAN:
locales.push_back(eMCLang_ruRU);
break;
case XC_LANGUAGE_SWEDISH:
locales.push_back(eMCLang_svSV);
locales.push_back(eMCLang_svSE);
break;
case XC_LANGUAGE_TURKISH:
locales.push_back(eMCLang_trTR);
break;
case XC_LANGUAGE_BNORWEGIAN:
locales.push_back(eMCLang_nbNO);
locales.push_back(eMCLang_noNO);
locales.push_back(eMCLang_nnNO);
break;
case XC_LANGUAGE_DUTCH:
switch (XGetLocale()) {
case XC_LOCALE_BELGIUM:
locales.push_back(eMCLang_nlBE);
break;
default:
break;
}
locales.push_back(eMCLang_nlNL);
break;
case XC_LANGUAGE_SCHINESE:
switch (XGetLocale()) {
case XC_LOCALE_SINGAPORE:
locales.push_back(eMCLang_zhSG);
break;
default:
break;
}
locales.push_back(eMCLang_hans);
locales.push_back(eMCLang_csCS);
locales.push_back(eMCLang_zhCN);
break;
}
locales.push_back(eMCLang_enUS);
locales.push_back(eMCLang_null);
for (int i = 0; i < locales.size(); i++) {
eMCLang lang = locales.at(i);
vecWstrLocales.push_back(m_localeA[lang]);
}
}
int LocalizationManager::get_eMCLang(wchar_t* pwchLocale) {
return m_eMCLangA[pwchLocale];
}
int LocalizationManager::get_xcLang(wchar_t* pwchLocale) {
return m_xcLangA[pwchLocale];
}
void LocalizationManager::localeAndLanguageInit() {
m_localeA[eMCLang_zhCHT] = L"zh-CHT";
m_localeA[eMCLang_csCS] = L"cs-CS";
m_localeA[eMCLang_laLAS] = L"la-LAS";
m_localeA[eMCLang_null] = L"en-EN";
m_localeA[eMCLang_enUS] = L"en-US";
m_localeA[eMCLang_enGB] = L"en-GB";
m_localeA[eMCLang_enIE] = L"en-IE";
m_localeA[eMCLang_enAU] = L"en-AU";
m_localeA[eMCLang_enNZ] = L"en-NZ";
m_localeA[eMCLang_enCA] = L"en-CA";
m_localeA[eMCLang_jaJP] = L"ja-JP";
m_localeA[eMCLang_deDE] = L"de-DE";
m_localeA[eMCLang_deAT] = L"de-AT";
m_localeA[eMCLang_frFR] = L"fr-FR";
m_localeA[eMCLang_frCA] = L"fr-CA";
m_localeA[eMCLang_esES] = L"es-ES";
m_localeA[eMCLang_esMX] = L"es-MX";
m_localeA[eMCLang_itIT] = L"it-IT";
m_localeA[eMCLang_koKR] = L"ko-KR";
m_localeA[eMCLang_ptPT] = L"pt-PT";
m_localeA[eMCLang_ptBR] = L"pt-BR";
m_localeA[eMCLang_ruRU] = L"ru-RU";
m_localeA[eMCLang_nlNL] = L"nl-NL";
m_localeA[eMCLang_fiFI] = L"fi-FI";
m_localeA[eMCLang_svSV] = L"sv-SV";
m_localeA[eMCLang_daDA] = L"da-DA";
m_localeA[eMCLang_noNO] = L"no-NO";
m_localeA[eMCLang_plPL] = L"pl-PL";
m_localeA[eMCLang_trTR] = L"tr-TR";
m_localeA[eMCLang_elEL] = L"el-EL";
m_localeA[eMCLang_zhSG] = L"zh-SG";
m_localeA[eMCLang_zhCN] = L"zh-CN";
m_localeA[eMCLang_zhHK] = L"zh-HK";
m_localeA[eMCLang_zhTW] = L"zh-TW";
m_localeA[eMCLang_nlBE] = L"nl-BE";
m_localeA[eMCLang_daDK] = L"da-DK";
m_localeA[eMCLang_frBE] = L"fr-BE";
m_localeA[eMCLang_frCH] = L"fr-CH";
m_localeA[eMCLang_deCH] = L"de-CH";
m_localeA[eMCLang_nbNO] = L"nb-NO";
m_localeA[eMCLang_enGR] = L"en-GR";
m_localeA[eMCLang_enHK] = L"en-HK";
m_localeA[eMCLang_enSA] = L"en-SA";
m_localeA[eMCLang_enHU] = L"en-HU";
m_localeA[eMCLang_enIN] = L"en-IN";
m_localeA[eMCLang_enIL] = L"en-IL";
m_localeA[eMCLang_enSG] = L"en-SG";
m_localeA[eMCLang_enSK] = L"en-SK";
m_localeA[eMCLang_enZA] = L"en-ZA";
m_localeA[eMCLang_enCZ] = L"en-CZ";
m_localeA[eMCLang_enAE] = L"en-AE";
m_localeA[eMCLang_esAR] = L"es-AR";
m_localeA[eMCLang_esCL] = L"es-CL";
m_localeA[eMCLang_esCO] = L"es-CO";
m_localeA[eMCLang_esUS] = L"es-US";
m_localeA[eMCLang_svSE] = L"sv-SE";
m_localeA[eMCLang_csCZ] = L"cs-CZ";
m_localeA[eMCLang_elGR] = L"el-GR";
m_localeA[eMCLang_nnNO] = L"nn-NO";
m_localeA[eMCLang_skSK] = L"sk-SK";
m_localeA[eMCLang_hans] = L"zh-HANS";
m_localeA[eMCLang_hant] = L"zh-HANT";
m_eMCLangA[L"zh-CHT"] = eMCLang_zhCHT;
m_eMCLangA[L"cs-CS"] = eMCLang_csCS;
m_eMCLangA[L"la-LAS"] = eMCLang_laLAS;
m_eMCLangA[L"en-EN"] = eMCLang_null;
m_eMCLangA[L"en-US"] = eMCLang_enUS;
m_eMCLangA[L"en-GB"] = eMCLang_enGB;
m_eMCLangA[L"en-IE"] = eMCLang_enIE;
m_eMCLangA[L"en-AU"] = eMCLang_enAU;
m_eMCLangA[L"en-NZ"] = eMCLang_enNZ;
m_eMCLangA[L"en-CA"] = eMCLang_enCA;
m_eMCLangA[L"ja-JP"] = eMCLang_jaJP;
m_eMCLangA[L"de-DE"] = eMCLang_deDE;
m_eMCLangA[L"de-AT"] = eMCLang_deAT;
m_eMCLangA[L"fr-FR"] = eMCLang_frFR;
m_eMCLangA[L"fr-CA"] = eMCLang_frCA;
m_eMCLangA[L"es-ES"] = eMCLang_esES;
m_eMCLangA[L"es-MX"] = eMCLang_esMX;
m_eMCLangA[L"it-IT"] = eMCLang_itIT;
m_eMCLangA[L"ko-KR"] = eMCLang_koKR;
m_eMCLangA[L"pt-PT"] = eMCLang_ptPT;
m_eMCLangA[L"pt-BR"] = eMCLang_ptBR;
m_eMCLangA[L"ru-RU"] = eMCLang_ruRU;
m_eMCLangA[L"nl-NL"] = eMCLang_nlNL;
m_eMCLangA[L"fi-FI"] = eMCLang_fiFI;
m_eMCLangA[L"sv-SV"] = eMCLang_svSV;
m_eMCLangA[L"da-DA"] = eMCLang_daDA;
m_eMCLangA[L"no-NO"] = eMCLang_noNO;
m_eMCLangA[L"pl-PL"] = eMCLang_plPL;
m_eMCLangA[L"tr-TR"] = eMCLang_trTR;
m_eMCLangA[L"el-EL"] = eMCLang_elEL;
m_eMCLangA[L"zh-SG"] = eMCLang_zhSG;
m_eMCLangA[L"zh-CN"] = eMCLang_zhCN;
m_eMCLangA[L"zh-HK"] = eMCLang_zhHK;
m_eMCLangA[L"zh-TW"] = eMCLang_zhTW;
m_eMCLangA[L"nl-BE"] = eMCLang_nlBE;
m_eMCLangA[L"da-DK"] = eMCLang_daDK;
m_eMCLangA[L"fr-BE"] = eMCLang_frBE;
m_eMCLangA[L"fr-CH"] = eMCLang_frCH;
m_eMCLangA[L"de-CH"] = eMCLang_deCH;
m_eMCLangA[L"nb-NO"] = eMCLang_nbNO;
m_eMCLangA[L"en-GR"] = eMCLang_enGR;
m_eMCLangA[L"en-HK"] = eMCLang_enHK;
m_eMCLangA[L"en-SA"] = eMCLang_enSA;
m_eMCLangA[L"en-HU"] = eMCLang_enHU;
m_eMCLangA[L"en-IN"] = eMCLang_enIN;
m_eMCLangA[L"en-IL"] = eMCLang_enIL;
m_eMCLangA[L"en-SG"] = eMCLang_enSG;
m_eMCLangA[L"en-SK"] = eMCLang_enSK;
m_eMCLangA[L"en-ZA"] = eMCLang_enZA;
m_eMCLangA[L"en-CZ"] = eMCLang_enCZ;
m_eMCLangA[L"en-AE"] = eMCLang_enAE;
m_eMCLangA[L"es-AR"] = eMCLang_esAR;
m_eMCLangA[L"es-CL"] = eMCLang_esCL;
m_eMCLangA[L"es-CO"] = eMCLang_esCO;
m_eMCLangA[L"es-US"] = eMCLang_esUS;
m_eMCLangA[L"sv-SE"] = eMCLang_svSE;
m_eMCLangA[L"cs-CZ"] = eMCLang_csCZ;
m_eMCLangA[L"el-GR"] = eMCLang_elGR;
m_eMCLangA[L"nn-NO"] = eMCLang_nnNO;
m_eMCLangA[L"sk-SK"] = eMCLang_skSK;
m_eMCLangA[L"zh-HANS"] = eMCLang_hans;
m_eMCLangA[L"zh-HANT"] = eMCLang_hant;
m_xcLangA[L"zh-CHT"] = XC_LOCALE_CHINA;
m_xcLangA[L"cs-CS"] = XC_LOCALE_CHINA;
m_xcLangA[L"en-EN"] = XC_LOCALE_UNITED_STATES;
m_xcLangA[L"en-US"] = XC_LOCALE_UNITED_STATES;
m_xcLangA[L"en-GB"] = XC_LOCALE_GREAT_BRITAIN;
m_xcLangA[L"en-IE"] = XC_LOCALE_IRELAND;
m_xcLangA[L"en-AU"] = XC_LOCALE_AUSTRALIA;
m_xcLangA[L"en-NZ"] = XC_LOCALE_NEW_ZEALAND;
m_xcLangA[L"en-CA"] = XC_LOCALE_CANADA;
m_xcLangA[L"ja-JP"] = XC_LOCALE_JAPAN;
m_xcLangA[L"de-DE"] = XC_LOCALE_GERMANY;
m_xcLangA[L"de-AT"] = XC_LOCALE_AUSTRIA;
m_xcLangA[L"fr-FR"] = XC_LOCALE_FRANCE;
m_xcLangA[L"fr-CA"] = XC_LOCALE_CANADA;
m_xcLangA[L"es-ES"] = XC_LOCALE_SPAIN;
m_xcLangA[L"es-MX"] = XC_LOCALE_MEXICO;
m_xcLangA[L"it-IT"] = XC_LOCALE_ITALY;
m_xcLangA[L"ko-KR"] = XC_LOCALE_KOREA;
m_xcLangA[L"pt-PT"] = XC_LOCALE_PORTUGAL;
m_xcLangA[L"pt-BR"] = XC_LOCALE_BRAZIL;
m_xcLangA[L"ru-RU"] = XC_LOCALE_RUSSIAN_FEDERATION;
m_xcLangA[L"nl-NL"] = XC_LOCALE_NETHERLANDS;
m_xcLangA[L"fi-FI"] = XC_LOCALE_FINLAND;
m_xcLangA[L"sv-SV"] = XC_LOCALE_SWEDEN;
m_xcLangA[L"da-DA"] = XC_LOCALE_DENMARK;
m_xcLangA[L"no-NO"] = XC_LOCALE_NORWAY;
m_xcLangA[L"pl-PL"] = XC_LOCALE_POLAND;
m_xcLangA[L"tr-TR"] = XC_LOCALE_TURKEY;
m_xcLangA[L"el-EL"] = XC_LOCALE_GREECE;
m_xcLangA[L"la-LAS"] = XC_LOCALE_LATIN_AMERICA;
m_xcLangA[L"zh-SG"] = XC_LOCALE_SINGAPORE;
m_xcLangA[L"Zh-CN"] = XC_LOCALE_CHINA;
m_xcLangA[L"zh-HK"] = XC_LOCALE_HONG_KONG;
m_xcLangA[L"zh-TW"] = XC_LOCALE_TAIWAN;
m_xcLangA[L"nl-BE"] = XC_LOCALE_BELGIUM;
m_xcLangA[L"da-DK"] = XC_LOCALE_DENMARK;
m_xcLangA[L"fr-BE"] = XC_LOCALE_BELGIUM;
m_xcLangA[L"fr-CH"] = XC_LOCALE_SWITZERLAND;
m_xcLangA[L"de-CH"] = XC_LOCALE_SWITZERLAND;
m_xcLangA[L"nb-NO"] = XC_LOCALE_NORWAY;
m_xcLangA[L"en-GR"] = XC_LOCALE_GREECE;
m_xcLangA[L"en-HK"] = XC_LOCALE_HONG_KONG;
m_xcLangA[L"en-SA"] = XC_LOCALE_SAUDI_ARABIA;
m_xcLangA[L"en-HU"] = XC_LOCALE_HUNGARY;
m_xcLangA[L"en-IN"] = XC_LOCALE_INDIA;
m_xcLangA[L"en-IL"] = XC_LOCALE_ISRAEL;
m_xcLangA[L"en-SG"] = XC_LOCALE_SINGAPORE;
m_xcLangA[L"en-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
m_xcLangA[L"en-ZA"] = XC_LOCALE_SOUTH_AFRICA;
m_xcLangA[L"en-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
m_xcLangA[L"en-AE"] = XC_LOCALE_UNITED_ARAB_EMIRATES;
m_xcLangA[L"ja-IP"] = XC_LOCALE_JAPAN;
m_xcLangA[L"es-AR"] = XC_LOCALE_ARGENTINA;
m_xcLangA[L"es-CL"] = XC_LOCALE_CHILE;
m_xcLangA[L"es-CO"] = XC_LOCALE_COLOMBIA;
m_xcLangA[L"es-US"] = XC_LOCALE_UNITED_STATES;
m_xcLangA[L"sv-SE"] = XC_LOCALE_SWEDEN;
m_xcLangA[L"cs-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
m_xcLangA[L"el-GR"] = XC_LOCALE_GREECE;
m_xcLangA[L"sk-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
m_xcLangA[L"zh-HANS"] = XC_LOCALE_CHINA;
m_xcLangA[L"zh-HANT"] = XC_LOCALE_CHINA;
}
-61
View File
@@ -1,61 +0,0 @@
#pragma once
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
#include "minecraft/GameEnums.h"
#include "app/common/App_structs.h"
#include "platform/XboxStubs.h"
class ArchiveFile;
class Random;
class StringTable;
class LocalizationManager {
public:
LocalizationManager();
void localeAndLanguageInit();
void loadStringTable(ArchiveFile* mediaArchive);
const wchar_t* getString(int iID) const;
std::wstring formatHTMLString(int iPad, const std::wstring& desc,
int shadowColour = 0xFFFFFFFF);
std::wstring getActionReplacement(int iPad, unsigned char ucAction);
std::wstring getVKReplacement(unsigned int uiVKey);
std::wstring getIconReplacement(unsigned int uiIcon);
int getHTMLColour(eMinecraftColour colour);
int getHTMLColor(eMinecraftColour colour) { return getHTMLColour(colour); }
int getHTMLFontSize(EHTMLFontSize size);
void initialiseTips();
int getNextTip();
void getLocale(std::vector<std::wstring>& vecWstrLocales);
int get_eMCLang(wchar_t* pwchLocale);
int get_xcLang(wchar_t* pwchLocale);
StringTable* getStringTable() const { return m_stringTable; }
private:
static int s_iHTMLFontSizesA[eHTMLSize_COUNT];
StringTable* m_stringTable;
std::unordered_map<int, std::wstring> m_localeA;
std::unordered_map<std::wstring, int> m_eMCLangA;
std::unordered_map<std::wstring, int> m_xcLangA;
static const int MAX_TIPS_GAMETIP = 50;
static const int MAX_TIPS_TRIVIATIP = 20;
static TIPSTRUCT m_GameTipA[MAX_TIPS_GAMETIP];
static TIPSTRUCT m_TriviaTipA[MAX_TIPS_TRIVIATIP];
static Random* TipRandom;
int m_TipIDA[MAX_TIPS_GAMETIP + MAX_TIPS_TRIVIATIP];
unsigned int m_uiCurrentTip;
static int TipsSortFunction(const void* a, const void* b);
};
-665
View File
@@ -1,665 +0,0 @@
#include "app/common/MenuController.h"
#include "app/common/Game.h"
#include "app/common/UI/All Platforms/UIEnums.h"
#include "app/common/UI/All Platforms/UIStructs.h"
#include "app/common/UI/Scenes/UIScene_FullscreenProgress.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Linux_UIController.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/ProgressRenderer.h"
#include "minecraft/client/renderer/GameRenderer.h"
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "minecraft/server/MinecraftServer.h"
#include "minecraft/world/Container.h"
#include "minecraft/world/entity/item/MinecartHopper.h"
#include "minecraft/world/entity/player/Player.h"
#include "minecraft/world/item/crafting/Recipy.h"
#include "minecraft/world/level/tile/Tile.h"
#include "minecraft/world/level/tile/entity/HopperTileEntity.h"
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
#include "platform/sdl2/Profile.h"
#include "platform/sdl2/Storage.h"
#include <cstring>
#include <sstream>
#include <chrono>
#include <thread>
unsigned char MenuController::m_szPNG[8] = {137, 80, 78, 71, 13, 10, 26, 10};
MenuController::MenuController() {
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
m_eTMSAction[i] = eTMSAction_Idle;
m_eXuiAction[i] = eAppAction_Idle;
m_eXuiActionParam[i] = nullptr;
m_uiOpacityCountDown[i] = 0;
}
m_eGlobalXuiAction = eAppAction_Idle;
m_eGlobalXuiServerAction = eXuiServerAction_Idle;
}
void MenuController::setAction(int iPad, eXuiAction action, void* param) {
if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
(action == eAppAction_EthernetDisconnected)) {
app.DebugPrintf(
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
iPad, m_eXuiAction[iPad], action);
} else if ((m_eXuiAction[iPad] == eAppAction_ReloadTexturePack) &&
(action == eAppAction_ExitWorld)) {
app.DebugPrintf(
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
iPad, m_eXuiAction[iPad], action);
} else if (m_eXuiAction[iPad] == eAppAction_ExitWorldCapturedThumbnail &&
action != eAppAction_Idle) {
app.DebugPrintf(
"Invalid change of App action for pad %d from %d to %d, ignoring\n",
iPad, m_eXuiAction[iPad], action);
} else {
app.DebugPrintf("Changing App action for pad %d from %d to %d\n", iPad,
m_eXuiAction[iPad], action);
m_eXuiAction[iPad] = action;
m_eXuiActionParam[iPad] = param;
}
}
bool MenuController::loadInventoryMenu(int iPad,
std::shared_ptr<LocalPlayer> player,
bool bNavigateBack) {
bool success = true;
InventoryScreenInput* initData = new InventoryScreenInput();
initData->player = player;
initData->bNavigateBack = bNavigateBack;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_InventoryMenu, initData);
}
return success;
}
bool MenuController::loadCreativeMenu(int iPad,
std::shared_ptr<LocalPlayer> player,
bool bNavigateBack) {
bool success = true;
InventoryScreenInput* initData = new InventoryScreenInput();
initData->player = player;
initData->bNavigateBack = bNavigateBack;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_CreativeMenu, initData);
}
return success;
}
bool MenuController::loadCrafting2x2Menu(int iPad,
std::shared_ptr<LocalPlayer> player) {
bool success = true;
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
initData->player = player;
initData->iContainerType = RECIPE_TYPE_2x2;
initData->iPad = iPad;
initData->x = 0;
initData->y = 0;
initData->z = 0;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_Crafting2x2Menu, initData);
}
return success;
}
bool MenuController::loadCrafting3x3Menu(int iPad,
std::shared_ptr<LocalPlayer> player,
int x, int y, int z) {
bool success = true;
CraftingPanelScreenInput* initData = new CraftingPanelScreenInput();
initData->player = player;
initData->iContainerType = RECIPE_TYPE_3x3;
initData->iPad = iPad;
initData->x = x;
initData->y = y;
initData->z = z;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_Crafting3x3Menu, initData);
}
return success;
}
bool MenuController::loadFireworksMenu(int iPad,
std::shared_ptr<LocalPlayer> player,
int x, int y, int z) {
bool success = true;
FireworksScreenInput* initData = new FireworksScreenInput();
initData->player = player;
initData->iPad = iPad;
initData->x = x;
initData->y = y;
initData->z = z;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_FireworksMenu, initData);
}
return success;
}
bool MenuController::loadEnchantingMenu(int iPad,
std::shared_ptr<Inventory> inventory,
int x, int y, int z, Level* level,
const std::wstring& name) {
bool success = true;
EnchantingScreenInput* initData = new EnchantingScreenInput();
initData->inventory = inventory;
initData->level = level;
initData->x = x;
initData->y = y;
initData->z = z;
initData->iPad = iPad;
initData->name = name;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_EnchantingMenu, initData);
}
return success;
}
bool MenuController::loadFurnaceMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<FurnaceTileEntity> furnace) {
bool success = true;
FurnaceScreenInput* initData = new FurnaceScreenInput();
initData->furnace = furnace;
initData->inventory = inventory;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_FurnaceMenu, initData);
}
return success;
}
bool MenuController::loadBrewingStandMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
bool success = true;
BrewingScreenInput* initData = new BrewingScreenInput();
initData->brewingStand = brewingStand;
initData->inventory = inventory;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_BrewingStandMenu, initData);
}
return success;
}
bool MenuController::loadContainerMenu(int iPad,
std::shared_ptr<Container> inventory,
std::shared_ptr<Container> container) {
bool success = true;
ContainerScreenInput* initData = new ContainerScreenInput();
initData->inventory = inventory;
initData->container = container;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
bool bLargeChest =
(initData->container->getContainerSize() > 3 * 9) ? true : false;
if (bLargeChest) {
success =
ui.NavigateToScene(iPad, eUIScene_LargeContainerMenu, initData);
} else {
success =
ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
}
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_ContainerMenu, initData);
}
return success;
}
bool MenuController::loadTrapMenu(
int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<DispenserTileEntity> trap) {
bool success = true;
TrapScreenInput* initData = new TrapScreenInput();
initData->inventory = inventory;
initData->trap = trap;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1) {
initData->bSplitscreen = true;
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
} else {
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_DispenserMenu, initData);
}
return success;
}
bool MenuController::loadSignEntryMenu(
int iPad, std::shared_ptr<SignTileEntity> sign) {
bool success = true;
SignEntryScreenInput* initData = new SignEntryScreenInput();
initData->sign = sign;
initData->iPad = iPad;
success = ui.NavigateToScene(iPad, eUIScene_SignEntryMenu, initData);
delete initData;
return success;
}
bool MenuController::loadRepairingMenu(int iPad,
std::shared_ptr<Inventory> inventory,
Level* level, int x, int y, int z) {
bool success = true;
AnvilScreenInput* initData = new AnvilScreenInput();
initData->inventory = inventory;
initData->level = level;
initData->x = x;
initData->y = y;
initData->z = z;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_AnvilMenu, initData);
return success;
}
bool MenuController::loadTradingMenu(int iPad,
std::shared_ptr<Inventory> inventory,
std::shared_ptr<Merchant> trader,
Level* level, const std::wstring& name) {
bool success = true;
TradingScreenInput* initData = new TradingScreenInput();
initData->inventory = inventory;
initData->trader = trader;
initData->level = level;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_TradingMenu, initData);
return success;
}
bool MenuController::loadHopperMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<HopperTileEntity> hopper) {
bool success = true;
HopperScreenInput* initData = new HopperScreenInput();
initData->inventory = inventory;
initData->hopper = hopper;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
return success;
}
bool MenuController::loadHopperMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<MinecartHopper> hopper) {
bool success = true;
HopperScreenInput* initData = new HopperScreenInput();
initData->inventory = inventory;
initData->hopper = std::dynamic_pointer_cast<Container>(hopper);
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_HopperMenu, initData);
return success;
}
bool MenuController::loadHorseMenu(int iPad,
std::shared_ptr<Inventory> inventory,
std::shared_ptr<Container> container,
std::shared_ptr<EntityHorse> horse) {
bool success = true;
HorseScreenInput* initData = new HorseScreenInput();
initData->inventory = inventory;
initData->container = container;
initData->horse = horse;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_HorseMenu, initData);
return success;
}
bool MenuController::loadBeaconMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BeaconTileEntity> beacon) {
bool success = true;
BeaconScreenInput* initData = new BeaconScreenInput();
initData->inventory = inventory;
initData->beacon = beacon;
initData->iPad = iPad;
if (app.GetLocalPlayerCount() > 1)
initData->bSplitscreen = true;
else
initData->bSplitscreen = false;
success = ui.NavigateToScene(iPad, eUIScene_BeaconMenu, initData);
return success;
}
int MenuController::texturePackDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
return 0;
}
int MenuController::unlockFullInviteReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
Minecraft* pMinecraft = Minecraft::GetInstance();
bool bNoPlayer;
if (pMinecraft->player == nullptr) {
bNoPlayer = true;
}
return 0;
}
int MenuController::unlockFullSaveReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
return 0;
}
int MenuController::unlockFullExitReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (result != C4JStorage::EMessage_ResultAccept) {
pApp->SetAction(pMinecraft->player->GetXboxPad(),
eAppAction_ExitWorldTrial);
}
return 0;
}
int MenuController::trialOverReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (result != C4JStorage::EMessage_ResultAccept) {
pApp->SetAction(pMinecraft->player->GetXboxPad(), eAppAction_ExitTrial);
}
return 0;
}
int MenuController::remoteSaveThreadProc(void* lpParameter) {
Compression::UseDefaultThreadStorage();
Tile::CreateNewThreadStorage();
Minecraft* pMinecraft = Minecraft::GetInstance();
pMinecraft->progressRenderer->progressStartNoAbort(
IDS_PROGRESS_HOST_SAVING);
pMinecraft->progressRenderer->progressStage(-1);
pMinecraft->progressRenderer->progressStagePercentage(0);
while (!app.GetGameStarted() &&
app.GetXuiAction(ProfileManager.GetPrimaryPad()) ==
eAppAction_WaitRemoteServerSaveComplete) {
pMinecraft->tickAllConnections();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
if (app.GetXuiAction(ProfileManager.GetPrimaryPad()) !=
eAppAction_WaitRemoteServerSaveComplete) {
return ERROR_CANCELLED;
}
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_Idle);
ui.UpdatePlayerBasePositions();
Tile::ReleaseThreadStorage();
return 0;
}
void MenuController::exitGameFromRemoteSave(void* lpParameter) {
int primaryPad = ProfileManager.GetPrimaryPad();
unsigned int uiIDA[3];
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, primaryPad,
&MenuController::exitGameFromRemoteSaveDialogReturned, nullptr);
}
int MenuController::exitGameFromRemoteSaveDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
if (result == C4JStorage::EMessage_ResultDecline) {
app.SetAction(iPad, eAppAction_ExitWorld);
} else {
UIScene_FullscreenProgress* pScene =
(UIScene_FullscreenProgress*)ui.FindScene(
eUIScene_FullscreenProgress);
if (pScene != nullptr) {
pScene->SetWasCancelled(false);
}
}
return 0;
}
#define PNG_TAG_tEXt 0x74455874
unsigned int MenuController::fromBigEndian(unsigned int uiValue) {
unsigned int uiReturn =
((uiValue >> 24) & 0x000000ff) | ((uiValue >> 8) & 0x0000ff00) |
((uiValue << 8) & 0x00ff0000) | ((uiValue << 24) & 0xff000000);
return uiReturn;
}
void MenuController::getImageTextData(std::uint8_t* imageData,
unsigned int imageBytes,
unsigned char* seedText,
unsigned int& uiHostOptions,
bool& bHostOptionsRead,
std::uint32_t& uiTexturePack) {
auto readPngUInt32 = [](const std::uint8_t* data) -> unsigned int {
unsigned int value = 0;
std::memcpy(&value, data, sizeof(value));
return value;
};
std::uint8_t* ucPtr = imageData;
unsigned int uiCount = 0;
unsigned int uiChunkLen;
unsigned int uiChunkType;
unsigned int uiCRC;
char szKeyword[80];
for (int i = 0; i < 8; i++) {
if (m_szPNG[i] != ucPtr[i]) return;
}
uiCount += 8;
while (uiCount < imageBytes) {
uiChunkLen = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
uiCount += sizeof(int);
uiChunkType = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
uiCount += sizeof(int);
if (uiChunkType == PNG_TAG_tEXt) {
unsigned char* pszKeyword = &ucPtr[uiCount];
while (pszKeyword < ucPtr + uiCount + uiChunkLen) {
memset(szKeyword, 0, 80);
unsigned int uiKeywordC = 0;
while (*pszKeyword != 0) {
szKeyword[uiKeywordC++] = *pszKeyword;
pszKeyword++;
}
pszKeyword++;
if (strcmp(szKeyword, "4J_SEED") == 0) {
unsigned int uiValueC = 0;
while (*pszKeyword != 0 &&
(pszKeyword < ucPtr + uiCount + uiChunkLen)) {
seedText[uiValueC++] = *pszKeyword;
pszKeyword++;
}
} else if (strcmp(szKeyword, "4J_HOSTOPTIONS") == 0) {
bHostOptionsRead = true;
unsigned int uiValueC = 0;
unsigned char pszHostOptions[9];
memset(&pszHostOptions, 0, 9);
while (*pszKeyword != 0 &&
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
uiValueC < 8) {
pszHostOptions[uiValueC++] = *pszKeyword;
pszKeyword++;
}
uiHostOptions = 0;
std::stringstream ss;
ss << pszHostOptions;
ss >> std::hex >> uiHostOptions;
} else if (strcmp(szKeyword, "4J_TEXTUREPACK") == 0) {
unsigned int uiValueC = 0;
unsigned char pszTexturePack[9];
memset(&pszTexturePack, 0, 9);
while (*pszKeyword != 0 &&
(pszKeyword < ucPtr + uiCount + uiChunkLen) &&
uiValueC < 8) {
pszTexturePack[uiValueC++] = *pszKeyword;
pszKeyword++;
}
std::stringstream ss;
ss << pszTexturePack;
ss >> std::hex >> uiTexturePack;
}
}
}
uiCount += uiChunkLen;
uiCRC = fromBigEndian(readPngUInt32(&ucPtr[uiCount]));
uiCount += sizeof(int);
}
return;
}
unsigned int MenuController::createImageTextData(
std::uint8_t* textMetadata, int64_t seed, bool hasSeed,
unsigned int uiHostOptions, unsigned int uiTexturePackId) {
int iTextMetadataBytes = 0;
if (hasSeed) {
strcpy((char*)textMetadata, "4J_SEED");
snprintf((char*)&textMetadata[8], 42, "%lld", (long long)seed);
iTextMetadataBytes += 8;
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
++iTextMetadataBytes;
}
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_HOSTOPTIONS");
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
uiHostOptions);
iTextMetadataBytes += 15;
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
++iTextMetadataBytes;
strcpy((char*)&textMetadata[iTextMetadataBytes], "4J_TEXTUREPACK");
snprintf((char*)&textMetadata[iTextMetadataBytes + 15], 9, "%X",
uiHostOptions);
iTextMetadataBytes += 15;
while (textMetadata[iTextMetadataBytes] != 0) iTextMetadataBytes++;
return iTextMetadataBytes;
}
-151
View File
@@ -1,151 +0,0 @@
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include "app/common/App_structs.h"
#include "platform/sdl2/Storage.h"
#include "platform/XboxStubs.h"
class Player;
class Inventory;
class Level;
class FurnaceTileEntity;
class Container;
class DispenserTileEntity;
class SignTileEntity;
class BrewingStandTileEntity;
class HopperTileEntity;
class MinecartHopper;
class EntityHorse;
class BeaconTileEntity;
class LocalPlayer;
class Merchant;
class CommandBlockEntity;
class MenuController {
public:
MenuController();
// Load menu methods
bool loadInventoryMenu(int iPad, std::shared_ptr<LocalPlayer> player,
bool bNavigateBack = false);
bool loadCreativeMenu(int iPad, std::shared_ptr<LocalPlayer> player,
bool bNavigateBack = false);
bool loadEnchantingMenu(int iPad, std::shared_ptr<Inventory> inventory,
int x, int y, int z, Level* level,
const std::wstring& name);
bool loadFurnaceMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<FurnaceTileEntity> furnace);
bool loadBrewingStandMenu(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BrewingStandTileEntity> brewingStand);
bool loadContainerMenu(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<Container> container);
bool loadTrapMenu(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<DispenserTileEntity> trap);
bool loadCrafting2x2Menu(int iPad, std::shared_ptr<LocalPlayer> player);
bool loadCrafting3x3Menu(int iPad, std::shared_ptr<LocalPlayer> player,
int x, int y, int z);
bool loadFireworksMenu(int iPad, std::shared_ptr<LocalPlayer> player,
int x, int y, int z);
bool loadSignEntryMenu(int iPad, std::shared_ptr<SignTileEntity> sign);
bool loadRepairingMenu(int iPad, std::shared_ptr<Inventory> inventory,
Level* level, int x, int y, int z);
bool loadTradingMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Merchant> trader, Level* level,
const std::wstring& name);
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<HopperTileEntity> hopper);
bool loadHopperMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<MinecartHopper> hopper);
bool loadHorseMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Container> container,
std::shared_ptr<EntityHorse> horse);
bool loadBeaconMenu(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BeaconTileEntity> beacon);
// Action management
void setAction(int iPad, eXuiAction action, void* param = nullptr);
eXuiAction getXuiAction(int iPad) { return m_eXuiAction[iPad]; }
void setXuiServerAction(int iPad, eXuiServerAction action,
void* param = nullptr) {
m_eXuiServerAction[iPad] = action;
m_eXuiServerActionParam[iPad] = param;
}
eXuiServerAction getXuiServerAction(int iPad) {
return m_eXuiServerAction[iPad];
}
void* getXuiServerActionParam(int iPad) {
return m_eXuiServerActionParam[iPad];
}
eXuiAction getGlobalXuiAction() { return m_eGlobalXuiAction; }
void setGlobalXuiAction(eXuiAction action) { m_eGlobalXuiAction = action; }
eXuiServerAction getGlobalXuiServerAction() {
return m_eGlobalXuiServerAction;
}
void setGlobalXuiServerAction(eXuiServerAction action) {
m_eGlobalXuiServerAction = action;
}
// TMS action
void setTMSAction(int iPad, eTMSAction action) {
m_eTMSAction[iPad] = action;
}
eTMSAction getTMSAction(int iPad) { return m_eTMSAction[iPad]; }
// Dialog callbacks
static int texturePackDialogReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int fatalErrorDialogReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int trialOverReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int unlockFullExitReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int unlockFullSaveReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int unlockFullInviteReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
// Remote save
static int remoteSaveThreadProc(void* lpParameter);
static void exitGameFromRemoteSave(void* lpParameter);
static int exitGameFromRemoteSaveDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result);
// Image text data
void getImageTextData(std::uint8_t* imageData, unsigned int imageBytes,
unsigned char* seedText, unsigned int& uiHostOptions,
bool& bHostOptionsRead, std::uint32_t& uiTexturePack);
unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed,
bool hasSeed, unsigned int uiHostOptions,
unsigned int uiTexturePackId);
// Opacity timer
unsigned int getOpacityTimer(int iPad) {
return m_uiOpacityCountDown[iPad];
}
void setOpacityTimer(int iPad) { m_uiOpacityCountDown[iPad] = 120; }
void tickOpacityTimer(int iPad) {
if (m_uiOpacityCountDown[iPad] > 0) m_uiOpacityCountDown[iPad]--;
}
// Action param accessor (needed by HandleXuiActions)
void* getXuiActionParam(int iPad) { return m_eXuiActionParam[iPad]; }
private:
eXuiAction m_eXuiAction[XUSER_MAX_COUNT];
eTMSAction m_eTMSAction[XUSER_MAX_COUNT];
void* m_eXuiActionParam[XUSER_MAX_COUNT];
eXuiAction m_eGlobalXuiAction;
eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT];
void* m_eXuiServerActionParam[XUSER_MAX_COUNT];
eXuiServerAction m_eGlobalXuiServerAction;
unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT];
static unsigned char m_szPNG[8];
unsigned int fromBigEndian(unsigned int uiValue);
};
-518
View File
@@ -1,518 +0,0 @@
#include "app/common/NetworkController.h"
#include "app/common/Game.h"
#include "app/common/Network/GameNetworkManager.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Linux_UIController.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/ProgressRenderer.h"
#include "minecraft/client/multiplayer/MultiPlayerLevel.h"
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "minecraft/client/renderer/GameRenderer.h"
#include "minecraft/client/skins/DLCTexturePack.h"
#include "minecraft/client/skins/TexturePack.h"
#include "minecraft/client/skins/TexturePackRepository.h"
#include "minecraft/server/MinecraftServer.h"
#include "minecraft/stats/StatsCounter.h"
#include "minecraft/world/entity/player/Player.h"
#include "minecraft/world/level/tile/Tile.h"
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
#include "platform/sdl2/Input.h"
#include "platform/sdl2/Profile.h"
#include "platform/sdl2/Storage.h"
#include "app/common/Audio/SoundEngine.h"
#include <cstring>
#include <chrono>
#include <thread>
unsigned int NetworkController::m_uiLastSignInData = 0;
NetworkController::NetworkController() {
m_disconnectReason = DisconnectPacket::eDisconnect_None;
m_bLiveLinkRequired = false;
m_bChangingSessionType = false;
m_bReallyChangingSessionType = false;
memset(&m_InviteData, 0, sizeof(JoinFromInviteData));
memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS);
memset(m_playerGamePrivileges, 0, sizeof(m_playerGamePrivileges));
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
if (FAILED(XUserGetSigninInfo(i,
XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
&m_currentSigninInfo[i]))) {
m_currentSigninInfo[i].xuid = INVALID_XUID;
m_currentSigninInfo[i].dwGuestNumber = 0;
}
}
}
void NetworkController::updatePlayerInfo(std::uint8_t networkSmallId,
int16_t playerColourIndex,
unsigned int playerGamePrivileges) {
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
if (m_playerColours[i] == networkSmallId) {
m_playerColours[i] = 0;
m_playerGamePrivileges[i] = 0;
}
}
if (playerColourIndex >= 0 &&
playerColourIndex < MINECRAFT_NET_MAX_PLAYERS) {
m_playerColours[playerColourIndex] = networkSmallId;
m_playerGamePrivileges[playerColourIndex] = playerGamePrivileges;
}
}
short NetworkController::getPlayerColour(std::uint8_t networkSmallId) {
short index = -1;
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
if (m_playerColours[i] == networkSmallId) {
index = i;
break;
}
}
return index;
}
unsigned int NetworkController::getPlayerPrivileges(
std::uint8_t networkSmallId) {
unsigned int privileges = 0;
for (unsigned int i = 0; i < MINECRAFT_NET_MAX_PLAYERS; ++i) {
if (m_playerColours[i] == networkSmallId) {
privileges = m_playerGamePrivileges[i];
break;
}
}
return privileges;
}
void NetworkController::processInvite(std::uint32_t dwUserIndex,
std::uint32_t dwLocalUsersMask,
const INVITE_INFO* pInviteInfo) {
m_InviteData.dwUserIndex = dwUserIndex;
m_InviteData.dwLocalUsersMask = dwLocalUsersMask;
m_InviteData.pInviteInfo = pInviteInfo;
app.SetAction(dwUserIndex, eAppAction_ExitAndJoinFromInvite);
}
int NetworkController::primaryPlayerSignedOutReturned(
void* pParam, int iPad, const C4JStorage::EMessageResult) {
if (g_NetworkManager.IsInSession()) {
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned);
} else {
app.SetAction(iPad, eAppAction_PrimaryPlayerSignedOutReturned_Menus);
}
return 0;
}
int NetworkController::ethernetDisconnectReturned(
void* pParam, int iPad, const C4JStorage::EMessageResult) {
Minecraft* pMinecraft = Minecraft::GetInstance();
if (Minecraft::GetInstance()->player != nullptr) {
app.SetAction(pMinecraft->player->GetXboxPad(),
eAppAction_EthernetDisconnectedReturned);
} else {
app.SetAction(iPad, eAppAction_EthernetDisconnectedReturned_Menus);
}
return 0;
}
void NetworkController::profileReadErrorCallback(void* pParam) {
Game* pApp = (Game*)pParam;
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
pApp->SetAction(iPrimaryPlayer, eAppAction_ProfileReadError);
}
int NetworkController::signoutExitWorldThreadProc(void* lpParameter) {
Compression::UseDefaultThreadStorage();
Minecraft* pMinecraft = Minecraft::GetInstance();
int exitReasonStringId = -1;
bool saveStats = false;
if (pMinecraft->isClientSide() || g_NetworkManager.IsInSession()) {
if (lpParameter != nullptr) {
switch (app.GetDisconnectReason()) {
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoFlying:
exitReasonStringId = IDS_DISCONNECTED_FLYING;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
break;
default:
exitReasonStringId = IDS_DISCONNECTED;
}
pMinecraft->progressRenderer->progressStartNoAbort(
exitReasonStringId);
if (pMinecraft->levels[0] != nullptr)
pMinecraft->levels[0]->disconnect(false);
if (pMinecraft->levels[1] != nullptr)
pMinecraft->levels[1]->disconnect(false);
} else {
exitReasonStringId = IDS_EXITING_GAME;
pMinecraft->progressRenderer->progressStartNoAbort(
IDS_EXITING_GAME);
if (pMinecraft->levels[0] != nullptr)
pMinecraft->levels[0]->disconnect();
if (pMinecraft->levels[1] != nullptr)
pMinecraft->levels[1]->disconnect();
}
MinecraftServer::HaltServer(true);
saveStats = false;
g_NetworkManager.LeaveGame(false);
} else {
if (lpParameter != nullptr) {
switch (app.GetDisconnectReason()) {
case DisconnectPacket::eDisconnect_Kicked:
exitReasonStringId = IDS_DISCONNECTED_KICKED;
break;
case DisconnectPacket::eDisconnect_NoUGC_AllLocal:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_ALL_LOCAL;
break;
case DisconnectPacket::eDisconnect_NoUGC_Single_Local:
exitReasonStringId =
IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL;
break;
case DisconnectPacket::eDisconnect_OutdatedServer:
exitReasonStringId = IDS_DISCONNECTED_SERVER_OLD;
break;
case DisconnectPacket::eDisconnect_OutdatedClient:
exitReasonStringId = IDS_DISCONNECTED_CLIENT_OLD;
default:
exitReasonStringId = IDS_DISCONNECTED;
}
pMinecraft->progressRenderer->progressStartNoAbort(
exitReasonStringId);
}
}
pMinecraft->setLevel(nullptr, exitReasonStringId, nullptr, saveStats, true);
app.m_gameRules.unloadCurrentGameRules();
MinecraftServer::resetFlags();
while (g_NetworkManager.IsInSession()) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
return 0;
}
void NetworkController::clearSignInChangeUsersMask() {
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
if (m_uiLastSignInData != 0) {
if (iPrimaryPlayer >= 0) {
m_uiLastSignInData = 1 << iPrimaryPlayer;
} else {
m_uiLastSignInData = 0;
}
}
}
void NetworkController::signInChangeCallback(void* pParam,
bool bPrimaryPlayerChanged,
unsigned int uiSignInData) {
Game* pApp = (Game*)pParam;
int iPrimaryPlayer = ProfileManager.GetPrimaryPad();
if ((ProfileManager.GetLockedProfile() != -1) && iPrimaryPlayer != -1) {
if (((uiSignInData & (1 << iPrimaryPlayer)) == 0) ||
bPrimaryPlayerChanged) {
pApp->SetAction(iPrimaryPlayer, eAppAction_PrimaryPlayerSignedOut);
pApp->InvalidateBannedList(iPrimaryPlayer);
StorageManager.ClearDLCOffers();
pApp->ClearAndResetDLCDownloadQueue();
pApp->ClearDLCInstalled();
} else {
unsigned int uiChangedPlayers = uiSignInData ^ m_uiLastSignInData;
if (g_NetworkManager.IsInSession()) {
bool hasGuestIdChanged = false;
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
unsigned int guestNumber = 0;
if (ProfileManager.IsSignedIn(i)) {
XUSER_SIGNIN_INFO info;
XUserGetSigninInfo(
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
pApp->DebugPrintf(
"Player at index %d has guest number %d\n", i,
info.dwGuestNumber);
guestNumber = info.dwGuestNumber;
}
if (pApp->m_networkController.m_currentSigninInfo[i]
.dwGuestNumber != 0 &&
guestNumber != 0 &&
pApp->m_networkController.m_currentSigninInfo[i]
.dwGuestNumber != guestNumber) {
hasGuestIdChanged = true;
}
}
if (hasGuestIdChanged) {
unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK;
ui.RequestErrorMessage(IDS_GUEST_ORDER_CHANGED_TITLE,
IDS_GUEST_ORDER_CHANGED_TEXT, uiIDA,
1, ProfileManager.GetPrimaryPad());
}
bool switchToOffline = false;
if (!ProfileManager.IsSignedInLive(
ProfileManager.GetLockedProfile()) &&
!g_NetworkManager.IsLocalGame()) {
switchToOffline = true;
}
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
if (i == iPrimaryPlayer) continue;
if (hasGuestIdChanged &&
pApp->m_networkController.m_currentSigninInfo[i]
.dwGuestNumber != 0 &&
g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
nullptr) {
pApp->DebugPrintf(
"Recommending removal of player at index %d "
"because their guest id changed\n",
i);
pApp->SetAction(i, eAppAction_ExitPlayer);
} else {
XUSER_SIGNIN_INFO info;
XUserGetSigninInfo(
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY, &info);
bool bPlayerChanged =
(uiChangedPlayers & (1 << i)) == (1 << i);
bool bPlayerSignedIn = ((uiSignInData & (1 << i)) != 0);
if (bPlayerChanged &&
(!bPlayerSignedIn ||
(bPlayerSignedIn &&
!ProfileManager.AreXUIDSEqual(
pApp->m_networkController
.m_currentSigninInfo[i]
.xuid,
info.xuid)))) {
pApp->DebugPrintf(
"Player at index %d Left - invalidating their "
"banned list\n",
i);
pApp->InvalidateBannedList(i);
if (g_NetworkManager.GetLocalPlayerByUserIndex(i) !=
nullptr ||
Minecraft::GetInstance()->localplayers[i] !=
nullptr) {
pApp->DebugPrintf("Player %d signed out\n", i);
pApp->SetAction(i, eAppAction_ExitPlayer);
}
}
}
}
if (switchToOffline) {
pApp->SetAction(iPrimaryPlayer,
eAppAction_EthernetDisconnected);
}
g_NetworkManager.HandleSignInChange();
} else if (pApp->GetLiveLinkRequired() &&
!ProfileManager.IsSignedInLive(
ProfileManager.GetLockedProfile())) {
{
pApp->SetAction(iPrimaryPlayer,
eAppAction_EthernetDisconnected);
}
}
}
m_uiLastSignInData = uiSignInData;
} else if (iPrimaryPlayer != -1) {
pApp->InvalidateBannedList(iPrimaryPlayer);
StorageManager.ClearDLCOffers();
pApp->ClearAndResetDLCDownloadQueue();
pApp->ClearDLCInstalled();
}
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
if (FAILED(XUserGetSigninInfo(
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
&pApp->m_networkController.m_currentSigninInfo[i]))) {
pApp->m_networkController.m_currentSigninInfo[i].xuid =
INVALID_XUID;
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber = 0;
}
app.DebugPrintf(
"Player at index %d has guest number %d\n", i,
pApp->m_networkController.m_currentSigninInfo[i].dwGuestNumber);
}
}
void NetworkController::notificationsCallback(void* pParam,
std::uint32_t dwNotification,
unsigned int uiParam) {
Game* pClass = (Game*)pParam;
PNOTIFICATION pNotification = new NOTIFICATION;
pNotification->dwNotification = dwNotification;
pNotification->uiParam = uiParam;
switch (dwNotification) {
case XN_SYS_SIGNINCHANGED: {
pClass->DebugPrintf("Signing changed - %d\n", uiParam);
} break;
case XN_SYS_INPUTDEVICESCHANGED:
if (app.GetGameStarted() && g_NetworkManager.IsInSession()) {
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
if (!InputManager.IsPadConnected(i) &&
Minecraft::GetInstance()->localplayers[i] != nullptr &&
!ui.IsPauseMenuDisplayed(i) &&
!ui.IsSceneInStack(i, eUIScene_EndPoem)) {
ui.CloseUIScenes(i);
ui.NavigateToScene(i, eUIScene_PauseMenu);
}
}
}
break;
case XN_LIVE_CONTENT_INSTALLED: {
app.ClearDLCInstalled();
ui.HandleDLCInstalled(ProfileManager.GetPrimaryPad());
} break;
case XN_SYS_STORAGEDEVICESCHANGED: {
} break;
}
pClass->m_networkController.m_vNotifications.push_back(pNotification);
}
void NetworkController::liveLinkChangeCallback(void* pParam, bool bConnected) {
// Implementation is platform-specific, stub here
}
int NetworkController::exitAndJoinFromInvite(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
if (result == C4JStorage::EMessage_ResultDecline) {
pApp->SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
int NetworkController::exitAndJoinFromInviteSaveDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
Game* pClass = (Game*)pParam;
if (result == C4JStorage::EMessage_ResultDecline ||
result == C4JStorage::EMessage_ResultThirdOption) {
if (result == C4JStorage::EMessage_ResultDecline) {
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
TexturePack* tPack =
Minecraft::GetInstance()->skins->getSelected();
DLCPack* pDLCPack = tPack->getDLCPack();
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
L"")) {
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL;
ui.RequestErrorMessage(
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
&NetworkController::warningTrialTexturePackReturned,
pClass);
return 0;
}
}
bool bSaveExists;
StorageManager.DoesSaveExist(&bSaveExists);
if (bSaveExists) {
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestErrorMessage(
IDS_TITLE_SAVE_GAME, IDS_CONFIRM_SAVE_GAME, uiIDA, 2,
ProfileManager.GetPrimaryPad(),
&NetworkController::exitAndJoinFromInviteAndSaveReturned,
pClass);
return 0;
} else {
MinecraftServer::getInstance()->setSaveOnExit(true);
}
} else {
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestErrorMessage(
IDS_TITLE_DECLINE_SAVE_GAME, IDS_CONFIRM_DECLINE_SAVE_GAME,
uiIDA, 2, ProfileManager.GetPrimaryPad(),
&NetworkController::exitAndJoinFromInviteDeclineSaveReturned,
pClass);
return 0;
}
app.SetAction(ProfileManager.GetPrimaryPad(),
eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
int NetworkController::warningTrialTexturePackReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
return 0;
}
int NetworkController::exitAndJoinFromInviteAndSaveReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
if (result == C4JStorage::EMessage_ResultDecline) {
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected();
DLCPack* pDLCPack = tPack->getDLCPack();
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
L"")) {
unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_OK;
uiIDA[1] = IDS_CONFIRM_CANCEL;
ui.RequestErrorMessage(
IDS_WARNING_DLC_TRIALTEXTUREPACK_TITLE,
IDS_WARNING_DLC_TRIALTEXTUREPACK_TEXT, uiIDA, 2, iPad,
&NetworkController::warningTrialTexturePackReturned,
nullptr);
return 0;
}
}
MinecraftServer::getInstance()->setSaveOnExit(true);
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
int NetworkController::exitAndJoinFromInviteDeclineSaveReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result) {
if (result == C4JStorage::EMessage_ResultDecline) {
MinecraftServer::getInstance()->setSaveOnExit(false);
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
-106
View File
@@ -1,106 +0,0 @@
#pragma once
#include <cstdint>
#include "app/common/App_structs.h"
#include "platform/NetTypes.h"
#include "platform/sdl2/Storage.h"
#include "platform/XboxStubs.h"
#include "minecraft/network/packet/DisconnectPacket.h"
struct INVITE_INFO;
typedef struct _JoinFromInviteData {
std::uint32_t dwUserIndex;
std::uint32_t dwLocalUsersMask;
const INVITE_INFO* pInviteInfo;
} JoinFromInviteData;
class NetworkController {
public:
NetworkController();
// Player info
void updatePlayerInfo(std::uint8_t networkSmallId,
int16_t playerColourIndex,
unsigned int playerGamePrivileges);
short getPlayerColour(std::uint8_t networkSmallId);
unsigned int getPlayerPrivileges(std::uint8_t networkSmallId);
// Sign-in change
static void signInChangeCallback(void* pParam, bool bVal,
unsigned int uiSignInData);
static void clearSignInChangeUsersMask();
static int signoutExitWorldThreadProc(void* lpParameter);
static int primaryPlayerSignedOutReturned(void* pParam, int iPad,
const C4JStorage::EMessageResult);
static int ethernetDisconnectReturned(void* pParam, int iPad,
const C4JStorage::EMessageResult);
static void profileReadErrorCallback(void* pParam);
// Notifications
static void notificationsCallback(void* pParam,
std::uint32_t dwNotification,
unsigned int uiParam);
// Ethernet/Live link
static void liveLinkChangeCallback(void* pParam, bool bConnected);
// Invites
void processInvite(std::uint32_t dwUserIndex,
std::uint32_t dwLocalUsersMask,
const INVITE_INFO* pInviteInfo);
static int exitAndJoinFromInvite(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int exitAndJoinFromInviteSaveDialogReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result);
static int exitAndJoinFromInviteAndSaveReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result);
static int exitAndJoinFromInviteDeclineSaveReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result);
static int warningTrialTexturePackReturned(
void* pParam, int iPad, C4JStorage::EMessageResult result);
// Disconnect
DisconnectPacket::eDisconnectReason getDisconnectReason() {
return m_disconnectReason;
}
void setDisconnectReason(DisconnectPacket::eDisconnectReason bVal) {
m_disconnectReason = bVal;
}
// Session type flags
bool getChangingSessionType() { return m_bChangingSessionType; }
void setChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; }
bool getReallyChangingSessionType() { return m_bReallyChangingSessionType; }
void setReallyChangingSessionType(bool bVal) {
m_bReallyChangingSessionType = bVal;
}
// Live link
bool getLiveLinkRequired() { return m_bLiveLinkRequired; }
void setLiveLinkRequired(bool required) { m_bLiveLinkRequired = required; }
// Sign-in info
XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT];
// Invite data
JoinFromInviteData m_InviteData;
// Notifications
typedef std::vector<PNOTIFICATION> VNOTIFICATIONS;
VNOTIFICATIONS m_vNotifications;
VNOTIFICATIONS* getNotifications() { return &m_vNotifications; }
// Static sign-in data
static unsigned int m_uiLastSignInData;
private:
std::uint8_t m_playerColours[MINECRAFT_NET_MAX_PLAYERS];
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
DisconnectPacket::eDisconnectReason m_disconnectReason;
bool m_bChangingSessionType;
bool m_bReallyChangingSessionType;
bool m_bLiveLinkRequired;
};
-63
View File
@@ -1,63 +0,0 @@
#include "app/linux/LinuxGame.h"
#include "app/common/SaveManager.h"
#include <chrono>
#include "app/common/Game.h"
#include "app/common/Network/GameNetworkManager.h"
#include "minecraft/server/MinecraftServer.h"
#include "platform/sdl2/Profile.h"
void SaveManager::setAutosaveTimerTime(int settingValue) {
m_uiAutosaveTimer =
time_util::clock::now() +
std::chrono::minutes(settingValue * 15);
}
bool SaveManager::autosaveDue() const {
return (time_util::clock::now() > m_uiAutosaveTimer);
}
int64_t SaveManager::secondsToAutosave() const {
return std::chrono::duration_cast<std::chrono::seconds>(
m_uiAutosaveTimer - time_util::clock::now())
.count();
}
void SaveManager::lock() {
std::lock_guard<std::mutex> lock(m_saveNotificationMutex);
if (m_saveNotificationDepth++ == 0) {
if (g_NetworkManager
.IsInSession()) // this can be triggered from the front end if
// we're downloading a save
{
MinecraftServer::getInstance()->broadcastStartSavingPacket();
if (g_NetworkManager.IsLocalGame() &&
g_NetworkManager.GetPlayerCount() == 1) {
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_PauseServer,
(void*)true);
}
}
}
}
void SaveManager::unlock() {
std::lock_guard<std::mutex> lock(m_saveNotificationMutex);
if (--m_saveNotificationDepth == 0) {
if (g_NetworkManager
.IsInSession()) // this can be triggered from the front end if
// we're downloading a save
{
MinecraftServer::getInstance()->broadcastStopSavingPacket();
if (g_NetworkManager.IsLocalGame() &&
g_NetworkManager.GetPlayerCount() == 1) {
app.SetXuiServerAction(ProfileManager.GetPrimaryPad(),
eXuiServerAction_PauseServer,
(void*)false);
}
}
}
}
-23
View File
@@ -1,23 +0,0 @@
#pragma once
#include <cstdint>
#include <mutex>
#include "util/Timer.h"
class SaveManager {
public:
SaveManager() : m_uiAutosaveTimer{}, m_saveNotificationDepth(0) {}
void setAutosaveTimerTime(int settingValue);
bool autosaveDue() const;
int64_t secondsToAutosave() const;
void lock();
void unlock();
private:
time_util::time_point m_uiAutosaveTimer;
std::mutex m_saveNotificationMutex;
int m_saveNotificationDepth;
};
-451
View File
@@ -1,451 +0,0 @@
#include "app/common/SkinManager.h"
#include <mutex>
#include <sstream>
#include <string>
#include <wchar.h>
#include "app/common/App_structs.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/DLC/DLCPack.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "app/common/Minecraft_Macros.h"
#include "app/linux/LinuxGame.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/model/geom/Model.h"
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "minecraft/client/renderer/entity/EntityRenderer.h"
#include "minecraft/client/renderer/entity/EntityRenderDispatcher.h"
#include "minecraft/world/entity/player/Player.h"
#include "platform/sdl2/Profile.h"
SkinManager::SkinManager() : m_xuidNotch(INVALID_XUID) {
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
m_dwAdditionalModelParts[i] = 0;
}
}
void SkinManager::setPlayerSkin(int iPad, const std::wstring& name,
GAME_SETTINGS** gameSettingsA) {
std::uint32_t skinId = getSkinIdFromPath(name);
setPlayerSkin(iPad, skinId, gameSettingsA);
}
void SkinManager::setPlayerSkin(int iPad, std::uint32_t dwSkinId,
GAME_SETTINGS** gameSettingsA) {
app.DebugPrintf("Setting skin for %d to %08X\n", iPad, dwSkinId);
gameSettingsA[iPad]->dwSelectedSkin = dwSkinId;
gameSettingsA[iPad]->bSettingsChanged = true;
if (Minecraft::GetInstance()->localplayers[iPad] != nullptr)
Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomSkin(
dwSkinId);
}
std::wstring SkinManager::getPlayerSkinName(int iPad,
GAME_SETTINGS** gameSettingsA) {
return getSkinPathFromId(gameSettingsA[iPad]->dwSelectedSkin);
}
std::uint32_t SkinManager::getPlayerSkinId(int iPad,
GAME_SETTINGS** gameSettingsA,
DLCManager& dlcManager) {
DLCPack* Pack = nullptr;
DLCSkinFile* skinFile = nullptr;
std::uint32_t dwSkin = gameSettingsA[iPad]->dwSelectedSkin;
wchar_t chars[256];
if (GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin)) {
swprintf(chars, 256, L"dlcskin%08d.png",
GET_DLC_SKIN_ID_FROM_BITMASK(dwSkin));
Pack = dlcManager.getPackContainingSkin(chars);
if (Pack) {
skinFile = Pack->getSkinFile(chars);
bool bSkinIsFree =
skinFile->getParameterAsBool(DLCManager::e_DLCParamType_Free);
bool bLicensed = Pack->hasPurchasedFile(DLCManager::e_DLCType_Skin,
skinFile->getPath());
if (bSkinIsFree || bLicensed) {
return dwSkin;
} else {
return 0;
}
}
}
return dwSkin;
}
std::uint32_t SkinManager::getAdditionalModelParts(int iPad) {
return m_dwAdditionalModelParts[iPad];
}
void SkinManager::setPlayerCape(int iPad, const std::wstring& name,
GAME_SETTINGS** gameSettingsA) {
std::uint32_t capeId = Player::getCapeIdFromPath(name);
setPlayerCape(iPad, capeId, gameSettingsA);
}
void SkinManager::setPlayerCape(int iPad, std::uint32_t dwCapeId,
GAME_SETTINGS** gameSettingsA) {
app.DebugPrintf("Setting cape for %d to %08X\n", iPad, dwCapeId);
gameSettingsA[iPad]->dwSelectedCape = dwCapeId;
gameSettingsA[iPad]->bSettingsChanged = true;
if (Minecraft::GetInstance()->localplayers[iPad] != nullptr)
Minecraft::GetInstance()->localplayers[iPad]->setAndBroadcastCustomCape(
dwCapeId);
}
std::wstring SkinManager::getPlayerCapeName(int iPad,
GAME_SETTINGS** gameSettingsA) {
return Player::getCapePathFromId(gameSettingsA[iPad]->dwSelectedCape);
}
std::uint32_t SkinManager::getPlayerCapeId(int iPad,
GAME_SETTINGS** gameSettingsA) {
return gameSettingsA[iPad]->dwSelectedCape;
}
void SkinManager::setPlayerFavoriteSkin(int iPad, int iIndex,
unsigned int uiSkinID,
GAME_SETTINGS** gameSettingsA) {
app.DebugPrintf("Setting favorite skin for %d to %08X\n", iPad, uiSkinID);
gameSettingsA[iPad]->uiFavoriteSkinA[iIndex] = uiSkinID;
gameSettingsA[iPad]->bSettingsChanged = true;
}
unsigned int SkinManager::getPlayerFavoriteSkin(
int iPad, int iIndex, GAME_SETTINGS** gameSettingsA) {
return gameSettingsA[iPad]->uiFavoriteSkinA[iIndex];
}
unsigned char SkinManager::getPlayerFavoriteSkinsPos(
int iPad, GAME_SETTINGS** gameSettingsA) {
return gameSettingsA[iPad]->ucCurrentFavoriteSkinPos;
}
void SkinManager::setPlayerFavoriteSkinsPos(int iPad, int iPos,
GAME_SETTINGS** gameSettingsA) {
gameSettingsA[iPad]->ucCurrentFavoriteSkinPos = (unsigned char)iPos;
gameSettingsA[iPad]->bSettingsChanged = true;
}
unsigned int SkinManager::getPlayerFavoriteSkinsCount(
int iPad, GAME_SETTINGS** gameSettingsA) {
unsigned int uiCount = 0;
for (int i = 0; i < MAX_FAVORITE_SKINS; i++) {
if (gameSettingsA[iPad]->uiFavoriteSkinA[i] != 0xFFFFFFFF) {
uiCount++;
} else {
break;
}
}
return uiCount;
}
void SkinManager::validateFavoriteSkins(int iPad,
GAME_SETTINGS** gameSettingsA,
DLCManager& dlcManager) {
unsigned int uiCount = getPlayerFavoriteSkinsCount(iPad, gameSettingsA);
unsigned int uiValidSkin = 0;
wchar_t chars[256];
for (unsigned int i = 0; i < uiCount; i++) {
swprintf(chars, 256, L"dlcskin%08d.png",
getPlayerFavoriteSkin(iPad, i, gameSettingsA));
DLCPack* pDLCPack = dlcManager.getPackContainingSkin(chars);
if (pDLCPack != nullptr) {
DLCSkinFile* pSkinFile = pDLCPack->getSkinFile(chars);
if (pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Skin, L"") ||
(pSkinFile && pSkinFile->isFree())) {
gameSettingsA[iPad]->uiFavoriteSkinA[uiValidSkin++] =
gameSettingsA[iPad]->uiFavoriteSkinA[i];
}
}
}
for (unsigned int i = uiValidSkin; i < MAX_FAVORITE_SKINS; i++) {
gameSettingsA[iPad]->uiFavoriteSkinA[i] = 0xFFFFFFFF;
}
}
bool SkinManager::isXuidNotch(PlayerUID xuid) {
if (m_xuidNotch != INVALID_XUID && xuid != INVALID_XUID) {
return ProfileManager.AreXUIDSEqual(xuid, m_xuidNotch);
}
return false;
}
bool SkinManager::isXuidDeadmau5(PlayerUID xuid) {
// Delegates back to static MojangData on Game - this is a simple forwarding
// wrapper for now; the actual MojangData map stays on Game.
return app.isXuidDeadmau5(xuid);
}
void SkinManager::addMemoryTextureFile(const std::wstring& wName,
std::uint8_t* pbData,
unsigned int byteCount) {
std::lock_guard<std::mutex> lock(csMemFilesLock);
PMEMDATA pData = nullptr;
auto it = m_MEM_Files.find(wName);
if (it != m_MEM_Files.end()) {
#if !defined(_CONTENT_PACKAGE)
wprintf(L"Incrementing the memory texture file count for %ls\n",
wName.c_str());
#endif
pData = (*it).second;
if (pData->byteCount == 0 && byteCount != 0) {
if (pData->pbData != nullptr) delete[] pData->pbData;
pData->pbData = pbData;
pData->byteCount = byteCount;
}
++pData->ucRefCount;
return;
}
pData = new MEMDATA();
pData->pbData = pbData;
pData->byteCount = byteCount;
pData->ucRefCount = 1;
m_MEM_Files[wName] = pData;
}
void SkinManager::removeMemoryTextureFile(const std::wstring& wName) {
std::lock_guard<std::mutex> lock(csMemFilesLock);
auto it = m_MEM_Files.find(wName);
if (it != m_MEM_Files.end()) {
#if !defined(_CONTENT_PACKAGE)
wprintf(L"Decrementing the memory texture file count for %ls\n",
wName.c_str());
#endif
PMEMDATA pData = (*it).second;
--pData->ucRefCount;
if (pData->ucRefCount <= 0) {
#if !defined(_CONTENT_PACKAGE)
wprintf(L"Erasing the memory texture file data for %ls\n",
wName.c_str());
#endif
delete pData;
m_MEM_Files.erase(wName);
}
}
}
bool SkinManager::defaultCapeExists() {
std::wstring wTex = L"Special_Cape.png";
bool val = false;
{
std::lock_guard<std::mutex> lock(csMemFilesLock);
auto it = m_MEM_Files.find(wTex);
if (it != m_MEM_Files.end()) val = true;
}
return val;
}
bool SkinManager::isFileInMemoryTextures(const std::wstring& wName) {
bool val = false;
{
std::lock_guard<std::mutex> lock(csMemFilesLock);
auto it = m_MEM_Files.find(wName);
if (it != m_MEM_Files.end()) val = true;
}
return val;
}
void SkinManager::getMemFileDetails(const std::wstring& wName,
std::uint8_t** ppbData,
unsigned int* pByteCount) {
std::lock_guard<std::mutex> lock(csMemFilesLock);
auto it = m_MEM_Files.find(wName);
if (it != m_MEM_Files.end()) {
PMEMDATA pData = (*it).second;
*ppbData = pData->pbData;
*pByteCount = pData->byteCount;
}
}
void SkinManager::setAdditionalSkinBoxes(std::uint32_t dwSkinID,
SKIN_BOX* SkinBoxA,
unsigned int dwSkinBoxC) {
EntityRenderer* renderer =
EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
Model* pModel = renderer->getModel();
std::vector<ModelPart*>* pvModelPart = new std::vector<ModelPart*>;
std::vector<SKIN_BOX*>* pvSkinBoxes = new std::vector<SKIN_BOX*>;
{
std::lock_guard<std::mutex> lock_mp(csAdditionalModelParts);
std::lock_guard<std::mutex> lock_sb(csAdditionalSkinBoxes);
app.DebugPrintf(
"*** SetAdditionalSkinBoxes - Inserting model parts for skin %d "
"from "
"array of Skin Boxes\n",
dwSkinID & 0x0FFFFFFF);
for (unsigned int i = 0; i < dwSkinBoxC; i++) {
if (pModel) {
ModelPart* pModelPart = pModel->AddOrRetrievePart(&SkinBoxA[i]);
pvModelPart->push_back(pModelPart);
pvSkinBoxes->push_back(&SkinBoxA[i]);
}
}
m_AdditionalModelParts.insert(
std::pair<std::uint32_t, std::vector<ModelPart*>*>(dwSkinID,
pvModelPart));
m_AdditionalSkinBoxes.insert(
std::pair<std::uint32_t, std::vector<SKIN_BOX*>*>(dwSkinID,
pvSkinBoxes));
}
}
std::vector<ModelPart*>* SkinManager::setAdditionalSkinBoxes(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA) {
EntityRenderer* renderer =
EntityRenderDispatcher::instance->getRenderer(eTYPE_PLAYER);
Model* pModel = renderer->getModel();
std::vector<ModelPart*>* pvModelPart = new std::vector<ModelPart*>;
{
std::lock_guard<std::mutex> lock_mp(csAdditionalModelParts);
std::lock_guard<std::mutex> lock_sb(csAdditionalSkinBoxes);
app.DebugPrintf(
"*** SetAdditionalSkinBoxes - Inserting model parts for skin %d "
"from "
"array of Skin Boxes\n",
dwSkinID & 0x0FFFFFFF);
for (auto it = pvSkinBoxA->begin(); it != pvSkinBoxA->end(); ++it) {
if (pModel) {
ModelPart* pModelPart = pModel->AddOrRetrievePart(*it);
pvModelPart->push_back(pModelPart);
}
}
m_AdditionalModelParts.insert(
std::pair<std::uint32_t, std::vector<ModelPart*>*>(dwSkinID,
pvModelPart));
m_AdditionalSkinBoxes.insert(
std::pair<std::uint32_t, std::vector<SKIN_BOX*>*>(dwSkinID,
pvSkinBoxA));
}
return pvModelPart;
}
std::vector<ModelPart*>* SkinManager::getAdditionalModelParts(
std::uint32_t dwSkinID) {
std::lock_guard<std::mutex> lock(csAdditionalModelParts);
std::vector<ModelPart*>* pvModelParts = nullptr;
if (m_AdditionalModelParts.size() > 0) {
auto it = m_AdditionalModelParts.find(dwSkinID);
if (it != m_AdditionalModelParts.end()) {
pvModelParts = (*it).second;
}
}
return pvModelParts;
}
std::vector<SKIN_BOX*>* SkinManager::getAdditionalSkinBoxes(
std::uint32_t dwSkinID) {
std::lock_guard<std::mutex> lock(csAdditionalSkinBoxes);
std::vector<SKIN_BOX*>* pvSkinBoxes = nullptr;
if (m_AdditionalSkinBoxes.size() > 0) {
auto it = m_AdditionalSkinBoxes.find(dwSkinID);
if (it != m_AdditionalSkinBoxes.end()) {
pvSkinBoxes = (*it).second;
}
}
return pvSkinBoxes;
}
unsigned int SkinManager::getAnimOverrideBitmask(std::uint32_t dwSkinID) {
std::lock_guard<std::mutex> lock(csAnimOverrideBitmask);
unsigned int uiAnimOverrideBitmask = 0L;
if (m_AnimOverrides.size() > 0) {
auto it = m_AnimOverrides.find(dwSkinID);
if (it != m_AnimOverrides.end()) {
uiAnimOverrideBitmask = (*it).second;
}
}
return uiAnimOverrideBitmask;
}
void SkinManager::setAnimOverrideBitmask(std::uint32_t dwSkinID,
unsigned int uiAnimOverrideBitmask) {
std::lock_guard<std::mutex> lock(csAnimOverrideBitmask);
if (m_AnimOverrides.size() > 0) {
auto it = m_AnimOverrides.find(dwSkinID);
if (it != m_AnimOverrides.end()) {
return; // already in here
}
}
m_AnimOverrides.insert(std::pair<std::uint32_t, unsigned int>(
dwSkinID, uiAnimOverrideBitmask));
}
std::uint32_t SkinManager::getSkinIdFromPath(const std::wstring& skin) {
bool dlcSkin = false;
unsigned int skinId = 0;
if (skin.size() >= 14) {
dlcSkin = skin.substr(0, 3).compare(L"dlc") == 0;
std::wstring skinValue = skin.substr(7, skin.size());
skinValue = skinValue.substr(0, skinValue.find_first_of(L'.'));
std::wstringstream ss;
if (dlcSkin)
ss << std::dec << skinValue.c_str();
else
ss << std::hex << skinValue.c_str();
ss >> skinId;
skinId = MAKE_SKIN_BITMASK(dlcSkin, skinId);
}
return skinId;
}
std::wstring SkinManager::getSkinPathFromId(std::uint32_t skinId) {
wchar_t chars[256];
if (GET_IS_DLC_SKIN_FROM_BITMASK(skinId)) {
swprintf(chars, 256, L"dlcskin%08d.png",
GET_DLC_SKIN_ID_FROM_BITMASK(skinId));
} else {
std::uint32_t ugcSkinIndex = GET_UGC_SKIN_ID_FROM_BITMASK(skinId);
std::uint32_t defaultSkinIndex =
GET_DEFAULT_SKIN_ID_FROM_BITMASK(skinId);
if (ugcSkinIndex == 0) {
swprintf(chars, 256, L"defskin%08X.png", defaultSkinIndex);
} else {
swprintf(chars, 256, L"ugcskin%08X.png", ugcSkinIndex);
}
}
return chars;
}
-108
View File
@@ -1,108 +0,0 @@
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "app/common/App_structs.h"
#include "minecraft/client/model/SkinBox.h"
#include "platform/XboxStubs.h"
class ModelPart;
class DLCManager;
class SkinManager {
public:
SkinManager();
// Skin get/set (require GameSettingsA pointer from Game)
void setPlayerSkin(int iPad, const std::wstring& name,
GAME_SETTINGS** gameSettingsA);
void setPlayerSkin(int iPad, std::uint32_t dwSkinId,
GAME_SETTINGS** gameSettingsA);
std::wstring getPlayerSkinName(int iPad, GAME_SETTINGS** gameSettingsA);
std::uint32_t getPlayerSkinId(int iPad, GAME_SETTINGS** gameSettingsA,
DLCManager& dlcManager);
// Cape get/set
void setPlayerCape(int iPad, const std::wstring& name,
GAME_SETTINGS** gameSettingsA);
void setPlayerCape(int iPad, std::uint32_t dwCapeId,
GAME_SETTINGS** gameSettingsA);
std::wstring getPlayerCapeName(int iPad, GAME_SETTINGS** gameSettingsA);
std::uint32_t getPlayerCapeId(int iPad, GAME_SETTINGS** gameSettingsA);
// Favorite skins
void setPlayerFavoriteSkin(int iPad, int iIndex, unsigned int uiSkinID,
GAME_SETTINGS** gameSettingsA);
unsigned int getPlayerFavoriteSkin(int iPad, int iIndex,
GAME_SETTINGS** gameSettingsA);
unsigned char getPlayerFavoriteSkinsPos(int iPad,
GAME_SETTINGS** gameSettingsA);
void setPlayerFavoriteSkinsPos(int iPad, int iPos,
GAME_SETTINGS** gameSettingsA);
unsigned int getPlayerFavoriteSkinsCount(int iPad,
GAME_SETTINGS** gameSettingsA);
void validateFavoriteSkins(int iPad, GAME_SETTINGS** gameSettingsA,
DLCManager& dlcManager);
// Additional model parts per player
std::uint32_t getAdditionalModelParts(int iPad);
// Additional model parts per skin texture
void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* SkinBoxA,
unsigned int dwSkinBoxC);
std::vector<ModelPart*>* setAdditionalSkinBoxes(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* pvSkinBoxA);
std::vector<ModelPart*>* getAdditionalModelParts(std::uint32_t dwSkinID);
std::vector<SKIN_BOX*>* getAdditionalSkinBoxes(std::uint32_t dwSkinID);
// Anim overrides
void setAnimOverrideBitmask(std::uint32_t dwSkinID,
unsigned int uiAnimOverrideBitmask);
unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID);
// Skin path <-> id conversion (static)
static std::uint32_t getSkinIdFromPath(const std::wstring& skin);
static std::wstring getSkinPathFromId(std::uint32_t skinId);
// Default cape
bool defaultCapeExists();
// Notch/Deadmau5 xuid checks
bool isXuidNotch(PlayerUID xuid);
bool isXuidDeadmau5(PlayerUID xuid);
// Memory texture files for player skins
void addMemoryTextureFile(const std::wstring& wName, std::uint8_t* pbData,
unsigned int byteCount);
void removeMemoryTextureFile(const std::wstring& wName);
void getMemFileDetails(const std::wstring& wName, std::uint8_t** ppbData,
unsigned int* pByteCount);
bool isFileInMemoryTextures(const std::wstring& wName);
// storing skin files
std::vector<std::wstring> vSkinNames;
// per-player additional model parts
std::uint32_t m_dwAdditionalModelParts[XUSER_MAX_COUNT];
private:
PlayerUID m_xuidNotch;
// Memory texture files
std::unordered_map<std::wstring, PMEMDATA> m_MEM_Files;
std::mutex csMemFilesLock;
// Additional model parts/skin boxes per skin id
std::unordered_map<std::uint32_t, std::vector<ModelPart*>*>
m_AdditionalModelParts;
std::unordered_map<std::uint32_t, std::vector<SKIN_BOX*>*>
m_AdditionalSkinBoxes;
std::unordered_map<std::uint32_t, unsigned int> m_AnimOverrides;
std::mutex csAdditionalModelParts;
std::mutex csAdditionalSkinBoxes;
std::mutex csAnimOverrideBitmask;
};
@@ -1,58 +0,0 @@
#include "app/common/TerrainFeatureManager.h"
void TerrainFeatureManager::add(_eTerrainFeatureType eFeatureType, int x,
int z) {
// check we don't already have this in
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
++it) {
FEATURE_DATA* pFeatureData = *it;
if ((pFeatureData->eTerrainFeature == eFeatureType) &&
(pFeatureData->x == x) && (pFeatureData->z == z))
return;
}
FEATURE_DATA* pFeatureData = new FEATURE_DATA;
pFeatureData->eTerrainFeature = eFeatureType;
pFeatureData->x = x;
pFeatureData->z = z;
m_vTerrainFeatures.push_back(pFeatureData);
}
_eTerrainFeatureType TerrainFeatureManager::isFeature(int x, int z) const {
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
++it) {
FEATURE_DATA* pFeatureData = *it;
if ((pFeatureData->x == x) && (pFeatureData->z == z))
return pFeatureData->eTerrainFeature;
}
return eTerrainFeature_None;
}
bool TerrainFeatureManager::getPosition(_eTerrainFeatureType eType, int* pX,
int* pZ) const {
for (auto it = m_vTerrainFeatures.begin(); it < m_vTerrainFeatures.end();
++it) {
FEATURE_DATA* pFeatureData = *it;
if (pFeatureData->eTerrainFeature == eType) {
*pX = pFeatureData->x;
*pZ = pFeatureData->z;
return true;
}
}
return false;
}
void TerrainFeatureManager::clear() {
FEATURE_DATA* pFeatureData;
while (m_vTerrainFeatures.size() > 0) {
pFeatureData = m_vTerrainFeatures.back();
m_vTerrainFeatures.pop_back();
delete pFeatureData;
}
}
@@ -1,19 +0,0 @@
#pragma once
#include <vector>
#include "minecraft/GameEnums.h"
#include "app/common/App_structs.h"
class TerrainFeatureManager {
public:
void add(_eTerrainFeatureType eFeatureType, int x, int z);
void clear();
_eTerrainFeatureType isFeature(int x, int z) const;
bool getPosition(_eTerrainFeatureType eType, int* pX, int* pZ) const;
std::vector<FEATURE_DATA*>* features() { return &m_vTerrainFeatures; }
private:
std::vector<FEATURE_DATA*> m_vTerrainFeatures;
};
-201
View File
@@ -1,201 +0,0 @@
#include <cstdlib>
#include <new>
#include <mutex>
#include <unordered_set>
#ifdef _WIN32
#include <malloc.h>
#endif
#ifdef TRACY_ENABLE
#include <tracy/Tracy.hpp>
namespace {
template <typename T>
struct TracyMallocAllocator {
using value_type = T;
TracyMallocAllocator() noexcept = default;
template <typename U>
TracyMallocAllocator(const TracyMallocAllocator<U>&) noexcept {}
T* allocate(std::size_t n) {
return static_cast<T*>(std::malloc(n * sizeof(T)));
}
void deallocate(T* p, std::size_t) noexcept { std::free(p); }
};
using PtrSet =
std::unordered_set<void*, std::hash<void*>, std::equal_to<void*>,
TracyMallocAllocator<void*>>;
inline PtrSet* GetAllocSet() {
static PtrSet* set = []() -> PtrSet* {
void* mem = std::malloc(sizeof(PtrSet));
return mem ? new (mem) PtrSet() : nullptr;
}();
return set;
}
inline std::mutex* GetAllocMutex() {
static std::mutex* mtx = []() -> std::mutex* {
void* mem = std::malloc(sizeof(std::mutex));
return mem ? new (mem) std::mutex() : nullptr;
}();
return mtx;
}
inline void* TracyAlignedAlloc(std::size_t size, std::size_t alignment) {
if (alignment < alignof(void*)) alignment = alignof(void*);
#if defined(_WIN32)
return _aligned_malloc(size, alignment);
#else
void* ptr = nullptr;
if (posix_memalign(&ptr, alignment, size) != 0) {
return nullptr;
}
return ptr;
#endif
}
inline void TracyAlignedFree(void* ptr) {
#if defined(_WIN32)
_aligned_free(ptr);
#else
free(ptr);
#endif
}
inline void TracyTrackAlloc(void* ptr, std::size_t size) {
if (!ptr) return;
auto* set = GetAllocSet();
auto* mtx = GetAllocMutex();
if (!set || !mtx) return;
std::lock_guard<std::mutex> lock(*mtx);
set->insert(ptr);
TracyAlloc(ptr, size);
}
inline void TracyTrackFree(void* ptr) {
if (!ptr) return;
auto* set = GetAllocSet();
auto* mtx = GetAllocMutex();
if (!set || !mtx) return;
std::lock_guard<std::mutex> lock(*mtx);
if (set->erase(ptr) != 0) {
TracyFree(ptr);
}
}
} // namespace
void* operator new(std::size_t count) {
void* ptr = std::malloc(count);
if (!ptr) throw std::bad_alloc();
TracyTrackAlloc(ptr, count);
return ptr;
}
void* operator new[](std::size_t count) {
void* ptr = std::malloc(count);
if (!ptr) throw std::bad_alloc();
TracyTrackAlloc(ptr, count);
return ptr;
}
void operator delete(void* ptr) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void operator delete[](void* ptr) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void operator delete(void* ptr, std::size_t) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void operator delete[](void* ptr, std::size_t) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void* operator new(std::size_t count, const std::nothrow_t&) noexcept {
void* ptr = std::malloc(count);
TracyTrackAlloc(ptr, count);
return ptr;
}
void* operator new[](std::size_t count, const std::nothrow_t&) noexcept {
void* ptr = std::malloc(count);
TracyTrackAlloc(ptr, count);
return ptr;
}
void operator delete(void* ptr, const std::nothrow_t&) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void operator delete[](void* ptr, const std::nothrow_t&) noexcept {
TracyTrackFree(ptr);
std::free(ptr);
}
void* operator new(std::size_t count, std::align_val_t align) {
void* ptr = TracyAlignedAlloc(count, (std::size_t)align);
if (!ptr) throw std::bad_alloc();
TracyTrackAlloc(ptr, count);
return ptr;
}
void* operator new[](std::size_t count, std::align_val_t align) {
void* ptr = TracyAlignedAlloc(count, (std::size_t)align);
if (!ptr) throw std::bad_alloc();
TracyTrackAlloc(ptr, count);
return ptr;
}
void* operator new(std::size_t count, std::align_val_t align,
const std::nothrow_t&) noexcept {
void* ptr = TracyAlignedAlloc(count, (std::size_t)align);
TracyTrackAlloc(ptr, count);
return ptr;
}
void* operator new[](std::size_t count, std::align_val_t align,
const std::nothrow_t&) noexcept {
void* ptr = TracyAlignedAlloc(count, (std::size_t)align);
TracyTrackAlloc(ptr, count);
return ptr;
}
void operator delete(void* ptr, std::align_val_t) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
void operator delete[](void* ptr, std::align_val_t) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
void operator delete(void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
void operator delete[](void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
void operator delete(void* ptr, std::size_t, std::align_val_t) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
void operator delete[](void* ptr, std::size_t, std::align_val_t) noexcept {
TracyTrackFree(ptr);
TracyAlignedFree(ptr);
}
#endif
-18
View File
@@ -1,18 +0,0 @@
#include "platform/PlatformTypes.h"
#include "platform/XboxStubs.h"
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return a == b; }
uint32_t XUserGetSigninInfo(uint32_t dwUserIndex, uint32_t dwFlags,
PXUSER_SIGNIN_INFO pSigninInfo) {
return 0;
}
const wchar_t* CXuiStringTable::Lookup(const wchar_t* szId) { return szId; }
const wchar_t* CXuiStringTable::Lookup(uint32_t nIndex) { return L"String"; }
void CXuiStringTable::Clear() {}
int32_t CXuiStringTable::Load(const wchar_t* szId) { return 0; }
uint32_t XGetLanguage() { return 1; }
uint32_t XGetLocale() { return 0; }
uint32_t XEnableGuestSignin(bool fEnable) { return 0; }
@@ -12,7 +12,7 @@
#include "platform/PlatformTypes.h"
#include "app/common/App_Defines.h"
#include "app/common/Audio/Consoles_SoundEngine.h"
#include "app/common/src/Audio/Consoles_SoundEngine.h"
#include "app/linux/Iggy/include/rrCore.h"
#include "app/linux/LinuxGame.h"
#include "platform/C4JThread.h"
@@ -7,7 +7,7 @@ class Random;
#include <string>
#include "app/common/App_Defines.h"
#include "app/common/Audio/Consoles_SoundEngine.h"
#include "app/common/src/Audio/Consoles_SoundEngine.h"
#include "app/linux/Iggy/include/rrCore.h"
#include "minecraft/sounds/SoundTypes.h"
#include "miniaudio.h"
@@ -4,7 +4,7 @@
#include <utility>
#include <vector>
#include "minecraft/GameEnums.h"
#include "app/common/App_enums.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
#include "java/InputOutputStream/DataInputStream.h"
@@ -3,7 +3,7 @@
#include <string>
#include <unordered_map>
#include "minecraft/GameEnums.h"
#include "app/common/App_enums.h"
class ColourTable {
private:
@@ -1,7 +1,7 @@
#include "ConsoleGameMode.h"
#include "app/common/Tutorial/Tutorial.h"
#include "app/common/Tutorial/TutorialMode.h"
#include "app/common/src/Tutorial/Tutorial.h"
#include "app/common/src/Tutorial/TutorialMode.h"
class ClientConnection;
class Minecraft;
@@ -1,5 +1,5 @@
#pragma once
#include "app/common/Tutorial/TutorialMode.h"
#include "app/common/src/Tutorial/TutorialMode.h"
class ClientConnection;
class Minecraft;
@@ -8,9 +8,9 @@
#include "platform/sdl2/Render.h"
#include "platform/sdl2/Storage.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/linux/LinuxGame.h"
#include "platform/XboxStubs.h"
#include "app/include/XboxStubs.h"
#if defined(_WINDOWS64)
#include "app/windows/XML/ATGXmlParser.h"
#include "app/windows/XML/xmlFilesCallback.h"
@@ -1,7 +1,7 @@
#include "DLCCapeFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/linux/LinuxGame.h"
DLCCapeFile::DLCCapeFile(const std::wstring& path)
@@ -1,8 +1,8 @@
#include "DLCColourTableFile.h"
#include "DLCManager.h"
#include "app/common/Colours/ColourTable.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/Colours/ColourTable.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/linux/LinuxGame.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePack.h"
@@ -3,7 +3,7 @@
#include <sstream>
#include "app/common/Minecraft_Macros.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCManager.h"
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring& path) {
m_type = type;
@@ -1,7 +1,7 @@
#pragma once
#include "DLCFile.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
class DLCGameRules : public DLCFile {
public:
@@ -1,7 +1,7 @@
#include "DLCGameRulesFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCGameRules.h"
#include "app/common/src/DLC/DLCGameRules.h"
DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path)
: DLCGameRules(DLCManager::e_DLCType_GameRules, path) {
@@ -3,8 +3,8 @@
#include <string>
#include "DLCManager.h"
#include "app/common/DLC/DLCGameRules.h"
#include "app/common/GameRules/GameRuleManager.h"
#include "app/common/src/DLC/DLCGameRules.h"
#include "app/common/src/GameRules/GameRuleManager.h"
#include "app/linux/LinuxGame.h"
class StringTable;
@@ -4,7 +4,7 @@
#include <string>
#include "DLCGameRules.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
class StringTable;
@@ -1,8 +1,8 @@
#include "DLCLocalisationFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/common/src/Localisation/StringTable.h"
DLCLocalisationFile::DLCLocalisationFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_LocalisationData, path) {
@@ -17,7 +17,7 @@
#include "platform/sdl2/Storage.h"
#include "DLCFile.h"
#include "DLCPack.h"
#include "app/common/GameRules/GameRuleManager.h"
#include "app/common/src/GameRules/GameRuleManager.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Linux_UIController.h"
#include "platform/PlatformServices.h"
@@ -15,11 +15,11 @@
#include "DLCLocalisationFile.h"
#include "DLCTextureFile.h"
#include "DLCUIDataFile.h"
#include "app/common/Console_Debug_enum.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/src/Console_Debug_enum.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCSkinFile.h"
#include "app/common/src/Localisation/StringTable.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Stubs/winapi_stubs.h"
#include "util/StringHelpers.h"
@@ -7,7 +7,7 @@
#include "platform/PlatformTypes.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "app/common/src/DLC/DLCSkinFile.h"
class DLCFile;
class DLCSkinFile;
@@ -5,10 +5,10 @@
#include "platform/sdl2/Render.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/linux/LinuxGame.h"
#include "minecraft/client/model/SkinBox.h"
#include "platform/XboxStubs.h"
#include "app/include/SkinBox.h"
#include "app/include/XboxStubs.h"
DLCSkinFile::DLCSkinFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Skin, path) {
@@ -5,8 +5,8 @@
#include <vector>
#include "DLCFile.h"
#include "app/common/DLC/DLCManager.h"
#include "minecraft/client/model/SkinBox.h"
#include "app/common/src/DLC/DLCManager.h"
#include "app/include/SkinBox.h"
#include "minecraft/client/model/HumanoidModel.h"
class DLCSkinFile : public DLCFile {
@@ -1,7 +1,7 @@
#include "DLCTextureFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
DLCTextureFile::DLCTextureFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Texture, path) {
@@ -3,7 +3,7 @@
#include <string>
#include "DLCFile.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCManager.h"
class DLCTextureFile : public DLCFile {
private:
@@ -1,7 +1,7 @@
#include "DLCUIDataFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
#include "app/linux/LinuxGame.h"
DLCUIDataFile::DLCUIDataFile(const std::wstring& path)
@@ -0,0 +1,25 @@
#pragma once
#include "ConsoleGameRulesConstants.h"
#include "GameRuleManager.h"
#include "app/common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
#include "app/common/src/GameRules/LevelGeneration/BiomeOverride.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/src/GameRules/LevelGeneration/StartFeature.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/AddEnchantmentRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/AddItemRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/CollectItemRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/CompleteAllRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/CompoundGameRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/NamedAreaRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/UpdatePlayerRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/UseTileRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/Rules/GameRule.h"
#include "app/common/src/GameRules/LevelRules/Rules/GameRulesInstance.h"
@@ -7,18 +7,18 @@
#include <utility>
#include <vector>
#include "app/common/DLC/DLCGameRulesFile.h"
#include "app/common/DLC/DLCGameRulesHeader.h"
#include "app/common/DLC/DLCLocalisationFile.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/DLC/DLCPack.h"
#include "app/common/GameRules/LevelGeneration/ConsoleSchematicFile.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerators.h"
#include "app/common/GameRules/LevelRules/LevelRules.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/src/DLC/DLCGameRulesFile.h"
#include "app/common/src/DLC/DLCGameRulesHeader.h"
#include "app/common/src/DLC/DLCLocalisationFile.h"
#include "app/common/src/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCPack.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerators.h"
#include "app/common/src/GameRules/LevelRules/LevelRules.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
#include "app/common/src/Localisation/StringTable.h"
#include "app/linux/LinuxGame.h"
#include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h"
#include "java/File.h"
@@ -7,10 +7,10 @@
#include <string>
#include <unordered_map>
#include "app/common/DLC/DLCGameRulesHeader.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerators.h"
#include "app/common/GameRules/LevelRules/LevelRules.h"
#include "app/common/src/DLC/DLCGameRulesHeader.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerators.h"
#include "app/common/src/GameRules/LevelRules/LevelRules.h"
class LevelGenerationOptions;
class RootGameRulesDefinition;
@@ -5,8 +5,8 @@
#include "ConsoleSchematicFile.h"
#include "LevelGenerationOptions.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/DataOutputStream.h"
@@ -5,8 +5,8 @@
#include <string>
#include "ConsoleSchematicFile.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "minecraft/world/phys/AABB.h"
#include "minecraft/world/phys/Vec3.h"
@@ -1,7 +1,7 @@
#include "BiomeOverride.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/DataOutputStream.h"
@@ -4,8 +4,8 @@
#include <cstdint>
#include <string>
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
class BiomeOverride : public GameRuleDefinition {
private:
@@ -4,13 +4,13 @@
#include <algorithm>
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
#include "app/common/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionGenerateBox.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceBlock.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceContainer.h"
#include "app/common/src/GameRules/LevelGeneration/StructureActions/XboxStructureActionPlaceSpawner.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/DataOutputStream.h"
@@ -2,8 +2,8 @@
#include <string>
#include <vector>
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "minecraft/world/level/levelgen/structure/StructureFeatureIO.h"
#include "minecraft/world/level/levelgen/structure/StructurePiece.h"
@@ -1,6 +1,6 @@
#pragma once
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
class ConsoleGenerateStructureAction : public GameRuleDefinition {
public:
@@ -6,18 +6,18 @@
#include <unordered_set>
#include <utility>
#include "minecraft/GameEnums.h"
#include "app/common/DLC/DLCGameRulesHeader.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/DLC/DLCPack.h"
#include "app/common/GameRules/GameRuleManager.h"
#include "app/common/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
#include "app/common/GameRules/LevelGeneration/BiomeOverride.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
#include "app/common/GameRules/LevelGeneration/ConsoleSchematicFile.h"
#include "app/common/GameRules/LevelGeneration/StartFeature.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/App_enums.h"
#include "app/common/src/DLC/DLCGameRulesHeader.h"
#include "app/common/src/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCPack.h"
#include "app/common/src/GameRules/GameRuleManager.h"
#include "app/common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.h"
#include "app/common/src/GameRules/LevelGeneration/BiomeOverride.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructure.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h"
#include "app/common/src/GameRules/LevelGeneration/StartFeature.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/Localisation/StringTable.h"
#include "app/linux/LinuxGame.h"
#include "app/linux/Stubs/winapi_stubs.h"
#include "java/File.h"
@@ -8,10 +8,10 @@
#include <unordered_map>
#include <vector>
#include "app/common/DLC/DLCPack.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/Localisation/StringTable.h"
#include "app/common/src/DLC/DLCPack.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/Localisation/StringTable.h"
#include "minecraft/world/level/levelgen/structure/StructureFeature.h"
class ApplySchematicRuleDefinition;
@@ -1,7 +1,7 @@
#include "StartFeature.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/DataOutputStream.h"
@@ -3,8 +3,8 @@
#include <string>
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "minecraft/world/level/levelgen/structure/StructureFeature.h"
class StartFeature : public GameRuleDefinition {
@@ -1,8 +1,8 @@
#include "XboxStructureActionGenerateBox.h"
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/src/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "app/linux/LinuxGame.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/DataOutputStream.h"
@@ -1,8 +1,8 @@
#pragma once
#include <string>
#include "app/common/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
#include "app/common/src/GameRules/ConsoleGameRulesConstants.h"
#include "app/common/src/GameRules/LevelGeneration/ConsoleGenerateStructureAction.h"
class StructurePiece;
class Level;

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