Compare commits

..

No commits in common. "dev" and "nightly" have entirely different histories.
dev ... nightly

1685 changed files with 38046 additions and 38709 deletions

View file

@ -1,62 +1,36 @@
FROM ubuntu:24.04 as clang
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
ENV DEBIAN_FRONTEND=noninteractive
ARG LLVM_VERSION=20
RUN apt-get update \
&& apt-get install -y \
wget \
lsb-release \
software-properties-common \
gnupg
RUN wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh ${LLVM_VERSION} \
&& rm llvm.sh
RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 \
--slave /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION}
RUN update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${LLVM_VERSION} 100
RUN apt-get install -y \
libc++-${LLVM_VERSION}-dev \
libc++abi-${LLVM_VERSION}-dev \
&& rm -rf /var/lib/apt/lists/*
ENV CC="clang" \
CXX="clang++" \
CC_LD="lld" \
CXX_LD="lld"
FROM clang AS ivjcraft
ARG MESON_VERSION=1.10.2
# Dependencies
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository ppa:ubuntu-toolchain-r/test \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
build-essential \
gcc-14 g++-14 \
python3 \
ninja-build \
libsdl2-dev \
libgl-dev \
libglm-dev \
libglu1-mesa-dev \
libpthread-stubs0-dev \
libssl-dev \
gcc-15 g++-15 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
# Set GCC 14 as the default compiler
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 \
# Clean up lol
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
# Use the latest version of Meson -> $(curl -s "https://api.github.com/repos/mesonbuild/meson/releases/latest" | grep -Po '"tag_name": "\K[0-9.]+')
RUN MESON_VERSION=1.10.2 \
&& wget -qO meson.tar.gz https://github.com/mesonbuild/meson/releases/latest/download/meson-${MESON_VERSION}.tar.gz \
&& mkdir /opt/meson \
&& tar xf meson.tar.gz --strip-components=1 -C /opt/meson \
&& mv /opt/meson/meson.py /opt/meson/meson \
&& ln -s /opt/meson/meson /usr/bin/meson \
&& rm -rf meson.tar.gz
ENV DEBIAN_FRONTEND=dialog

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
.github-assets/ieget-an.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
.github-assets/opengl.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
.github-assets/progress.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

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

View file

@ -1,5 +1,7 @@
# <img src=".github-assets/logo.jpg" alt="Logo" width="50" height="50" style="vertical-align: middle;"> 4JCraft
![](.github-assets/transrights.png) ![](.github-assets/progress.png) ![](.github-assets/internetarchive.gif) ![](.github-assets//ieget-an.gif) ![](.github-assets/minecraft.gif) ![](.github-assets/powered-llvm.gif)
![](.github-assets/opengl.gif) ![](.github-assets/adobe_getflash2.gif) ![](.github-assets/flash_get_20010813.gif) ![](.github-assets/SiliconValley_7479_English_imagens_get_flashplayer.gif)
---
4JCraft is a modified version of the Minecraft Console Legacy Edition, aimed at porting old Minecraft to different platforms (such as Linux, Android, Emscripten, etc.) and refactoring the codebase to improve organization and use modern C++ features.

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": 1775423009,
"narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=",
"lastModified": 1774386573,
"narHash": "sha256-4hAV26quOxdC6iyG7kYaZcM3VOskcPUrdCQd/nx8obc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9",
"rev": "46db2e09e1d3f113a13c0d7b81e2f221c63b8ce9",
"type": "github"
},
"original": {
@ -108,11 +108,11 @@
"simdutf": {
"flake": false,
"locked": {
"lastModified": 1775422815,
"narHash": "sha256-ybQGXx7ULmlaiNUEEAGJurblG3sA1HzLTuXE8t/LFnM=",
"lastModified": 1773677002,
"narHash": "sha256-kq53Jz9zm2bfs8x/74FQbzYrUc+VD7JlnBoYHnEHuSY=",
"owner": "simdutf",
"repo": "simdutf",
"rev": "06258b2c046d233fa53957cced61bc279fadfb41",
"rev": "04a9b596de943ea9e4d4c833e39740edf3c11e88",
"type": "github"
},
"original": {

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 \

View file

@ -76,10 +76,7 @@ glm_dep = dependency('glm')
stb = subproject('stb').get_variable('stb_inc')
stb_dep = declare_dependency(include_directories: stb)
simdutf_dep = dependency('simdutf',
fallback: ['simdutf', 'simdutf_dep'],
default_options: ['utf8=true', 'utf16=true', 'utf32=true']
)
miniaudio_dep = dependency('miniaudio')
subdir('targets/util')

View file

@ -55,7 +55,7 @@ simdutf_lib = static_library(
)
simdutf_dep = declare_dependency(
include_directories: include_directories('.'),
sources: simdutf_amalgamate,
link_with: simdutf_lib,
)

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 char* 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::string& name,
std::uint8_t* data,
unsigned int size) {
game_.AddMemoryTextureFile(name, data, size);
}
void AppGameServices::removeMemoryTextureFile(const std::string& name) {
game_.RemoveMemoryTextureFile(name);
}
void AppGameServices::getMemFileDetails(const std::string& name,
std::uint8_t** data,
unsigned int* size) {
game_.GetMemFileDetails(name, data, size);
}
bool AppGameServices::isFileInMemoryTextures(const std::string& 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::string AppGameServices::getPlayerSkinName(int iPad) {
return game_.GetPlayerSkinName(iPad);
}
std::uint32_t AppGameServices::getPlayerSkinId(int iPad) {
return game_.GetPlayerSkinId(iPad);
}
std::string 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::string& skin) {
return Game::getSkinIdFromPath(skin);
}
std::string 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::string& filename) {
return game_.hasArchiveFile(filename);
}
std::vector<std::uint8_t> AppGameServices::getArchiveFile(
const std::string& filename) {
return game_.getArchiveFile(filename);
}
// -- Strings / formatting / misc queries --
int AppGameServices::getHTMLColour(eMinecraftColour colour) {
return game_.GetHTMLColour(colour);
}
std::string AppGameServices::getEntityName(EntityTypeId type) {
return game_.getEntityName(static_cast<eINSTANCEOF>(type));
}
const char* AppGameServices::getGameRulesString(const std::string& 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::string AppGameServices::getFilePath(std::uint32_t packId,
std::string filename,
bool bAddDataFolder,
std::string 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::string& 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::string& 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::string>& AppGameServices::getSkinNames() {
return game_.vSkinNames;
}
std::vector<FEATURE_DATA*>& AppGameServices::getTerrainFeatures() {
return *game_.m_terrainFeatureManager.features();
}
// -- Menu service --
IMenuService& AppGameServices::menus() { return menus_; }

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 char* 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::string& name, std::uint8_t* data,
unsigned int size) override;
void removeMemoryTextureFile(const std::string& name) override;
void getMemFileDetails(const std::string& name, std::uint8_t** data,
unsigned int* size) override;
bool isFileInMemoryTextures(const std::string& 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::string getPlayerSkinName(int iPad) override;
std::uint32_t getPlayerSkinId(int iPad) override;
std::string 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::string& skin) override;
std::string 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::string& filename) override;
std::vector<std::uint8_t> getArchiveFile(
const std::string& filename) override;
// -- Strings / formatting / misc queries --
int getHTMLColour(eMinecraftColour colour) override;
std::string getEntityName(EntityTypeId type) override;
const char* getGameRulesString(const std::string& key) override;
unsigned int createImageTextData(std::uint8_t* textMetadata,
int64_t seed, bool hasSeed,
unsigned int uiHostOptions,
unsigned int uiTexturePackId) override;
std::string getFilePath(std::uint32_t packId, std::string filename,
bool bAddDataFolder,
std::string 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::string& name) override;
bool dlcNeedsCorruptCheck() override;
unsigned int dlcCheckForCorrupt(bool showMessage) override;
bool dlcReadDataFile(unsigned int& filesProcessed,
const std::string& 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::string>& getSkinNames() override;
std::vector<FEATURE_DATA*>& getTerrainFeatures() override;
// -- Menu service --
IMenuService& menus() override;
private:
Game& game_;
IMenuService& menus_;
};

View file

@ -2,18 +2,17 @@
#include <cstdint>
#include "platform/storage/storage.h"
#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 {
char* wchFilename;
wchar_t* wchFilename;
eFileExtensionType eEXT;
eTMSFileType eTMSType;
std::uint8_t* pbData;
@ -145,18 +144,29 @@ 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;
uint64_t ullOfferID_Full;
uint64_t ullOfferID_Trial;
char wchBanner[MAX_BANNERNAME_SIZE];
char wchDataFile[MAX_BANNERNAME_SIZE];
wchar_t wchBanner[MAX_BANNERNAME_SIZE];
wchar_t wchDataFile[MAX_BANNERNAME_SIZE];
int iGender;
int iConfig;
unsigned int uiSortIndex;
} DLC_INFO;
typedef struct {
int x, z;
_eTerrainFeatureType eTerrainFeature;
} FEATURE_DATA;
// banned list
typedef struct {
std::uint8_t* pBannedList;
@ -171,12 +181,12 @@ typedef struct _DLCRequest {
typedef struct _TMSPPRequest {
eTMSContentState eState;
eDLCContentType eType;
IPlatformStorage::eGlobalStorage eStorageFacility;
IPlatformStorage::eTMS_FILETYPEVAL eFileTypeVal;
C4JStorage::eGlobalStorage eStorageFacility;
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal;
// char szFilename[MAX_TMSFILENAME_SIZE];
int (*CallbackFunc)(void*, int, int, IPlatformStorage::PTMSPP_FILEDATA,
int (*CallbackFunc)(void*, int, int, C4JStorage::PTMSPP_FILEDATA,
const char* szFilename);
char wchFilename[MAX_TMSFILENAME_SIZE];
wchar_t wchFilename[MAX_TMSFILENAME_SIZE];
void* lpCallbackParam;
} TMSPPRequest;

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/fs/fs.h"
#include "platform/PlatformTypes.h"
ArchiveManager::ArchiveManager()
: m_mediaArchive(nullptr), m_dwRequiredTexturePackID(0) {}
void ArchiveManager::loadMediaArchive() {
std::string mediapath = "";
#if _WINDOWS64
mediapath = "Common\\Media\\MediaWindows64.arc";
#elif __linux__
mediapath = "app/common/Media/MediaLinux.arc";
#endif
if (!mediapath.empty()) {
#if defined(__linux__)
std::string exeDirW = PlatformFilesystem.getBasePath().string();
std::string 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::string& 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::string& 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::string& 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(char* 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;
}
}

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::string& filename);
bool hasArchiveFile(const std::string& filename);
std::vector<uint8_t> getArchiveFile(const std::string& 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(char* 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;
};

View file

@ -1,228 +0,0 @@
#include "Consoles_SoundEngine.h"
#include "minecraft/sounds/SoundTypes.h"
const char* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
"mob/cow/hurt", // eSoundType_MOB_COW_HURT
"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
"mob/slime/slime", // eSoundType_MOB_SLIME,
"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
"mob/cat/purr", // eSoundType_MOB_CAT_PURR
"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
// 4J-PB - correct the name of the event for hitting ocelots
"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
// "mob.irongolem.throw", //
// eSoundType_MOB_IRONGOLEM_THROW "mob.irongolem.hit",
//// eSoundType_MOB_IRONGOLEM_HIT "mob.irongolem.death",
//// eSoundType_MOB_IRONGOLEM_DEATH "mob.irongolem.walk",
//// eSoundType_MOB_IRONGOLEM_WALK
"random/bow", // eSoundType_RANDOM_BOW,
"random/bowhit", // eSoundType_RANDOM_BOW_HIT,
"random/explode", // eSoundType_RANDOM_EXPLODE,
"random/fizz", // eSoundType_RANDOM_FIZZ,
"random/pop", // eSoundType_RANDOM_POP,
"random/fuse", // eSoundType_RANDOM_FUSE,
"random/drink", // eSoundType_RANDOM_DRINK,
"random/eat", // eSoundType_RANDOM_EAT,
"random/burp", // eSoundType_RANDOM_BURP,
"random/splash", // eSoundType_RANDOM_SPLASH,
"random/click", // eSoundType_RANDOM_CLICK,
"random/glass", // eSoundType_RANDOM_GLASS,
"random/orb", // eSoundType_RANDOM_ORB,
"random/break", // eSoundType_RANDOM_BREAK,
"random/chestopen", // eSoundType_RANDOM_CHEST_OPEN,
"random/chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
"random/door_open", // eSoundType_RANDOM_DOOR_OPEN,
"random/door_close", // eSoundType_RANDOM_DOOR_CLOSE,
"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
"portal/portal", // eSoundType_PORTAL_PORTAL,
// 4J-PB - added a couple that were still using std::string
"portal/trigger", // eSoundType_PORTAL_TRIGGER
"portal/travel", // eSoundType_PORTAL_TRAVEL
"fire/ignite", // eSoundType_FIRE_IGNITE,
"fire/fire", // eSoundType_FIRE_FIRE,
"damage/hit", // eSoundType_DAMAGE_HURT,
"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
"note/harp", // eSoundType_NOTE_HARP,
"note/bd", // eSoundType_NOTE_BD,
"note/snare", // eSoundType_NOTE_SNARE,
"note/hat", // eSoundType_NOTE_HAT,
"note/bassattack", // eSoundType_NOTE_BASSATTACK,
"tile/piston.in", // eSoundType_TILE_PISTON_IN,
"tile/piston.out", // eSoundType_TILE_PISTON_OUT,
"liquid/water", // eSoundType_LIQUID_WATER,
"liquid/lavapop", // eSoundType_LIQUID_LAVA_POP,
"liquid/lava", // eSoundType_LIQUID_LAVA,
"step/stone", // eSoundType_STEP_STONE,
"step/wood", // eSoundType_STEP_WOOD,
"step/gravel", // eSoundType_STEP_GRAVEL,
"step/grass", // eSoundType_STEP_GRASS,
"step/metal", // eSoundType_STEP_METAL,
"step/cloth", // eSoundType_STEP_CLOTH,
"step/sand", // eSoundType_STEP_SAND,
// below this are the additional sounds from the second soundbank
"mob/enderdragon/end", // eSoundType_MOB_ENDERDRAGON_END
"mob/enderdragon/growl", // eSoundType_MOB_ENDERDRAGON_GROWL
"mob/enderdragon/hit", // eSoundType_MOB_ENDERDRAGON_HIT
"mob/enderdragon/wings", // eSoundType_MOB_ENDERDRAGON_MOVE
"mob/irongolem/throw", // eSoundType_MOB_IRONGOLEM_THROW
"mob/irongolem/hit", // eSoundType_MOB_IRONGOLEM_HIT
"mob/irongolem/death", // eSoundType_MOB_IRONGOLEM_DEATH
"mob/irongolem/walk", // eSoundType_MOB_IRONGOLEM_WALK
// TU14
"damage/thorns", // eSoundType_DAMAGE_THORNS
"random/anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
"random/anvil_land", // eSoundType_RANDOM_ANVIL_LAND
"random/anvil_use", // eSoundType_RANDOM_ANVIL_USE
"mob/villager/haggle", // eSoundType_MOB_VILLAGER_HAGGLE
"mob/villager/idle", // eSoundType_MOB_VILLAGER_IDLE
"mob/villager/hit", // eSoundType_MOB_VILLAGER_HIT
"mob/villager/death", // eSoundType_MOB_VILLAGER_DEATH
"mob/villager/yes", // eSoundType_MOB_VILLAGER_YES
"mob/villager/no", // eSoundType_MOB_VILLAGER_NO
"mob/zombie/infect", // eSoundType_MOB_ZOMBIE_INFECT
"mob/zombie/unfect", // eSoundType_MOB_ZOMBIE_UNFECT
"mob/zombie/remedy", // eSoundType_MOB_ZOMBIE_REMEDY
"step/snow", // eSoundType_STEP_SNOW
"step/ladder", // eSoundType_STEP_LADDER
"dig/cloth", // eSoundType_DIG_CLOTH
"dig/grass", // eSoundType_DIG_GRASS
"dig/gravel", // eSoundType_DIG_GRAVEL
"dig/sand", // eSoundType_DIG_SAND
"dig/snow", // eSoundType_DIG_SNOW
"dig/stone", // eSoundType_DIG_STONE
"dig/wood", // eSoundType_DIG_WOOD
// 1.6.4
"fireworks/launch", // eSoundType_FIREWORKS_LAUNCH,
"fireworks/blast", // eSoundType_FIREWORKS_BLAST,
"fireworks/blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
"fireworks/large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
"fireworks/large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
"fireworks/twinkle", // eSoundType_FIREWORKS_TWINKLE,
"fireworks/twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
"mob/bat/idle", // eSoundType_MOB_BAT_IDLE,
"mob/bat/hurt", // eSoundType_MOB_BAT_HURT,
"mob/bat/death", // eSoundType_MOB_BAT_DEATH,
"mob/bat/takeoff", // eSoundType_MOB_BAT_TAKEOFF,
"mob/wither/spawn", // eSoundType_MOB_WITHER_SPAWN,
"mob/wither/idle", // eSoundType_MOB_WITHER_IDLE,
"mob/wither/hurt", // eSoundType_MOB_WITHER_HURT,
"mob/wither/death", // eSoundType_MOB_WITHER_DEATH,
"mob/wither/shoot", // eSoundType_MOB_WITHER_SHOOT,
"mob/cow/step", // eSoundType_MOB_COW_STEP,
"mob/chicken/step", // eSoundType_MOB_CHICKEN_STEP,
"mob/pig/step", // eSoundType_MOB_PIG_STEP,
"mob/enderman/stare", // eSoundType_MOB_ENDERMAN_STARE,
"mob/enderman/scream", // eSoundType_MOB_ENDERMAN_SCREAM,
"mob/sheep/shear", // eSoundType_MOB_SHEEP_SHEAR,
"mob/sheep/step", // eSoundType_MOB_SHEEP_STEP,
"mob/skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
"mob/skeleton/step", // eSoundType_MOB_SKELETON_STEP,
"mob/spider/step", // eSoundType_MOB_SPIDER_STEP,
"mob/wolf/step", // eSoundType_MOB_WOLF_STEP,
"mob/zombie/step", // eSoundType_MOB_ZOMBIE_STEP,
"liquid/swim", // eSoundType_LIQUID_SWIM,
"mob/horse/land", // eSoundType_MOB_HORSE_LAND,
"mob/horse/armor", // eSoundType_MOB_HORSE_ARMOR,
"mob/horse/leather", // eSoundType_MOB_HORSE_LEATHER,
"mob/horse/zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
"mob/horse/skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
"mob/horse/donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
"mob/horse/death", // eSoundType_MOB_HORSE_DEATH,
"mob/horse/zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
"mob/horse/skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
"mob/horse/donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
"mob/horse/hit", // eSoundType_MOB_HORSE_HIT,
"mob/horse/zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
"mob/horse/skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
"mob/horse/donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
"mob/horse/idle", // eSoundType_MOB_HORSE_IDLE,
"mob/horse/donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
"mob/horse/angry", // eSoundType_MOB_HORSE_ANGRY,
"mob/horse/gallop", // eSoundType_MOB_HORSE_GALLOP,
"mob/horse/breathe", // eSoundType_MOB_HORSE_BREATHE,
"mob/horse/wood", // eSoundType_MOB_HORSE_WOOD,
"mob/horse/soft", // eSoundType_MOB_HORSE_SOFT,
"mob/horse/jump", // eSoundType_MOB_HORSE_JUMP,
"mob/witch/idle", // eSoundType_MOB_WITCH_IDLE, <---
// missing
"mob/witch/hurt", // eSoundType_MOB_WITCH_HURT, <---
// missing
"mob/witch/death", // eSoundType_MOB_WITCH_DEATH, <---
// missing
"mob/slime/big", // eSoundType_MOB_SLIME_BIG,
"mob/slime/small", // eSoundType_MOB_SLIME_SMALL,
"eating", // eSoundType_EATING <--- missing
"random/levelup", // eSoundType_RANDOM_LEVELUP
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
// have to do a new sound bank instead, we'll add the sounds as new ones and
// change the code to reference them
"fire/new_ignite",
};
const char* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
"back", "craft", "craftfail", "focus", "press", "scroll",
};

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=PlatformStorage.WriteTMSFile(iPad,IPlatformStorage::eGlobalStorage_TitleUser,"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;
}

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];
};

View file

@ -1,385 +0,0 @@
#include "ColourTable.h"
#include <cstring>
#include <utility>
#include <vector>
#include "minecraft/GameEnums.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
#include "java/InputOutputStream/DataInputStream.h"
std::unordered_map<std::string, eMinecraftColour>
ColourTable::s_colourNamesMap;
const char* ColourTable::ColourTableElements[eMinecraftColour_COUNT] = {
"NOTSET",
"Foliage_Evergreen",
"Foliage_Birch",
"Foliage_Default",
"Foliage_Common",
"Foliage_Ocean",
"Foliage_Plains",
"Foliage_Desert",
"Foliage_ExtremeHills",
"Foliage_Forest",
"Foliage_Taiga",
"Foliage_Swampland",
"Foliage_River",
"Foliage_Hell",
"Foliage_Sky",
"Foliage_FrozenOcean",
"Foliage_FrozenRiver",
"Foliage_IcePlains",
"Foliage_IceMountains",
"Foliage_MushroomIsland",
"Foliage_MushroomIslandShore",
"Foliage_Beach",
"Foliage_DesertHills",
"Foliage_ForestHills",
"Foliage_TaigaHills",
"Foliage_ExtremeHillsEdge",
"Foliage_Jungle",
"Foliage_JungleHills",
"Grass_Common",
"Grass_Ocean",
"Grass_Plains",
"Grass_Desert",
"Grass_ExtremeHills",
"Grass_Forest",
"Grass_Taiga",
"Grass_Swampland",
"Grass_River",
"Grass_Hell",
"Grass_Sky",
"Grass_FrozenOcean",
"Grass_FrozenRiver",
"Grass_IcePlains",
"Grass_IceMountains",
"Grass_MushroomIsland",
"Grass_MushroomIslandShore",
"Grass_Beach",
"Grass_DesertHills",
"Grass_ForestHills",
"Grass_TaigaHills",
"Grass_ExtremeHillsEdge",
"Grass_Jungle",
"Grass_JungleHills",
"Water_Ocean",
"Water_Plains",
"Water_Desert",
"Water_ExtremeHills",
"Water_Forest",
"Water_Taiga",
"Water_Swampland",
"Water_River",
"Water_Hell",
"Water_Sky",
"Water_FrozenOcean",
"Water_FrozenRiver",
"Water_IcePlains",
"Water_IceMountains",
"Water_MushroomIsland",
"Water_MushroomIslandShore",
"Water_Beach",
"Water_DesertHills",
"Water_ForestHills",
"Water_TaigaHills",
"Water_ExtremeHillsEdge",
"Water_Jungle",
"Water_JungleHills",
"Sky_Ocean",
"Sky_Plains",
"Sky_Desert",
"Sky_ExtremeHills",
"Sky_Forest",
"Sky_Taiga",
"Sky_Swampland",
"Sky_River",
"Sky_Hell",
"Sky_Sky",
"Sky_FrozenOcean",
"Sky_FrozenRiver",
"Sky_IcePlains",
"Sky_IceMountains",
"Sky_MushroomIsland",
"Sky_MushroomIslandShore",
"Sky_Beach",
"Sky_DesertHills",
"Sky_ForestHills",
"Sky_TaigaHills",
"Sky_ExtremeHillsEdge",
"Sky_Jungle",
"Sky_JungleHills",
"Tile_RedstoneDust",
"Tile_RedstoneDustUnlit",
"Tile_RedstoneDustLitMin",
"Tile_RedstoneDustLitMax",
"Tile_StemMin",
"Tile_StemMax",
"Tile_WaterLily",
"Sky_Dawn_Dark",
"Sky_Dawn_Bright",
"Material_None",
"Material_Grass",
"Material_Sand",
"Material_Cloth",
"Material_Fire",
"Material_Ice",
"Material_Metal",
"Material_Plant",
"Material_Snow",
"Material_Clay",
"Material_Dirt",
"Material_Stone",
"Material_Water",
"Material_Wood",
"Material_Emerald",
"Particle_Note_00",
"Particle_Note_01",
"Particle_Note_02",
"Particle_Note_03",
"Particle_Note_04",
"Particle_Note_05",
"Particle_Note_06",
"Particle_Note_07",
"Particle_Note_08",
"Particle_Note_09",
"Particle_Note_10",
"Particle_Note_11",
"Particle_Note_12",
"Particle_Note_13",
"Particle_Note_14",
"Particle_Note_15",
"Particle_Note_16",
"Particle_Note_17",
"Particle_Note_18",
"Particle_Note_19",
"Particle_Note_20",
"Particle_Note_21",
"Particle_Note_22",
"Particle_Note_23",
"Particle_Note_24",
"Particle_NetherPortal",
"Particle_EnderPortal",
"Particle_Smoke",
"Particle_Ender",
"Particle_Explode",
"Particle_HugeExplosion",
"Particle_DripWater",
"Particle_DripLavaStart",
"Particle_DripLavaEnd",
"Particle_EnchantmentTable",
"Particle_DragonBreathMin",
"Particle_DragonBreathMax",
"Particle_Suspend",
"Particle_CritStart", // arrow in air
"Particle_CritEnd", // arrow in air
"Effect_MovementSpeed",
"Effect_MovementSlowDown",
"Effect_DigSpeed",
"Effect_DigSlowdown",
"Effect_DamageBoost",
"Effect_Heal",
"Effect_Harm",
"Effect_Jump",
"Effect_Confusion",
"Effect_Regeneration",
"Effect_DamageResistance",
"Effect_FireResistance",
"Effect_WaterBreathing",
"Effect_Invisiblity",
"Effect_Blindness",
"Effect_NightVision",
"Effect_Hunger",
"Effect_Weakness",
"Effect_Poison",
"Effect_Wither",
"Effect_HealthBoost",
"Effect_Absorption",
"Effect_Saturation",
"Potion_BaseColour",
"Mob_Creeper_Colour1",
"Mob_Creeper_Colour2",
"Mob_Skeleton_Colour1",
"Mob_Skeleton_Colour2",
"Mob_Spider_Colour1",
"Mob_Spider_Colour2",
"Mob_Zombie_Colour1",
"Mob_Zombie_Colour2",
"Mob_Slime_Colour1",
"Mob_Slime_Colour2",
"Mob_Ghast_Colour1",
"Mob_Ghast_Colour2",
"Mob_PigZombie_Colour1",
"Mob_PigZombie_Colour2",
"Mob_Enderman_Colour1",
"Mob_Enderman_Colour2",
"Mob_CaveSpider_Colour1",
"Mob_CaveSpider_Colour2",
"Mob_Silverfish_Colour1",
"Mob_Silverfish_Colour2",
"Mob_Blaze_Colour1",
"Mob_Blaze_Colour2",
"Mob_LavaSlime_Colour1",
"Mob_LavaSlime_Colour2",
"Mob_Pig_Colour1",
"Mob_Pig_Colour2",
"Mob_Sheep_Colour1",
"Mob_Sheep_Colour2",
"Mob_Cow_Colour1",
"Mob_Cow_Colour2",
"Mob_Chicken_Colour1",
"Mob_Chicken_Colour2",
"Mob_Squid_Colour1",
"Mob_Squid_Colour2",
"Mob_Wolf_Colour1",
"Mob_Wolf_Colour2",
"Mob_MushroomCow_Colour1",
"Mob_MushroomCow_Colour2",
"Mob_Ocelot_Colour1",
"Mob_Ocelot_Colour2",
"Mob_Villager_Colour1",
"Mob_Villager_Colour2",
"Mob_Bat_Colour1",
"Mob_Bat_Colour2",
"Mob_Witch_Colour1",
"Mob_Witch_Colour2",
"Mob_Horse_Colour1",
"Mob_Horse_Colour2",
"Armour_Default_Leather_Colour",
"Under_Water_Clear_Colour",
"Under_Lava_Clear_Colour",
"In_Cloud_Base_Colour",
"Under_Water_Fog_Colour",
"Under_Lava_Fog_Colour",
"In_Cloud_Fog_Colour",
"Default_Fog_Colour",
"Nether_Fog_Colour",
"End_Fog_Colour",
"Sign_Text",
"Map_Text",
"Leash_Light_Colour",
"Leash_Dark_Colour",
"Fire_Overlay",
"HTMLColor_0",
"HTMLColor_1",
"HTMLColor_2",
"HTMLColor_3",
"HTMLColor_4",
"HTMLColor_5",
"HTMLColor_6",
"HTMLColor_7",
"HTMLColor_8",
"HTMLColor_9",
"HTMLColor_a",
"HTMLColor_b",
"HTMLColor_c",
"HTMLColor_d",
"HTMLColor_e",
"HTMLColor_f",
"HTMLColor_dark_0",
"HTMLColor_dark_1",
"HTMLColor_dark_2",
"HTMLColor_dark_3",
"HTMLColor_dark_4",
"HTMLColor_dark_5",
"HTMLColor_dark_6",
"HTMLColor_dark_7",
"HTMLColor_dark_8",
"HTMLColor_dark_9",
"HTMLColor_dark_a",
"HTMLColor_dark_b",
"HTMLColor_dark_c",
"HTMLColor_dark_d",
"HTMLColor_dark_e",
"HTMLColor_dark_f",
"HTMLColor_T1",
"HTMLColor_T2",
"HTMLColor_T3",
"HTMLColor_Black",
"HTMLColor_White",
"Color_EnchantText",
"Color_EnchantTextFocus",
"Color_EnchantTextDisabled",
"Color_RenamedItemTitle",
};
void ColourTable::staticCtor() {
for (unsigned int i = eMinecraftColour_NOT_SET; i < eMinecraftColour_COUNT;
++i) {
s_colourNamesMap.insert(
std::unordered_map<std::string, eMinecraftColour>::value_type(
ColourTableElements[i], (eMinecraftColour)i));
}
}
ColourTable::ColourTable(std::uint8_t* pbData, std::uint32_t dataLength) {
loadColoursFromData(pbData, dataLength);
}
ColourTable::ColourTable(ColourTable* defaultColours, std::uint8_t* pbData,
std::uint32_t dataLength) {
// 4J Stu - Default the colours that of the table passed in
memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues,
sizeof(int) * eMinecraftColour_COUNT);
loadColoursFromData(pbData, dataLength);
}
void ColourTable::loadColoursFromData(std::uint8_t* pbData,
std::uint32_t dataLength) {
std::vector<uint8_t> src(pbData, pbData + dataLength);
ByteArrayInputStream bais(src);
DataInputStream dis(&bais);
int versionNumber = dis.readInt();
int coloursCount = dis.readInt();
for (int i = 0; i < coloursCount; ++i) {
std::string colourId = dis.readUTF();
int colourValue = dis.readInt();
setColour(colourId, colourValue);
auto it = s_colourNamesMap.find(colourId);
}
bais.reset();
}
void ColourTable::setColour(const std::string& colourName, int value) {
auto it = s_colourNamesMap.find(colourName);
if (it != s_colourNamesMap.end()) {
m_colourValues[(int)it->second] = value;
}
}
void ColourTable::setColour(const std::string& colourName,
const std::string& value) {
setColour(colourName, fromHexWString<int>(value));
}
unsigned int ColourTable::getColour(eMinecraftColour id) {
return m_colourValues[(int)id];
}

View file

@ -1,10 +0,0 @@
#pragma once
#include "DLCFile.h"
#include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h"
class DLCGameRules : public DLCFile {
public:
DLCGameRules(DLCManager::EDLCType type, const std::string& path)
: DLCFile(type, path) {}
};

View file

@ -1,720 +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 "app/linux/Stubs/winapi_stubs.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePack.h"
#include "minecraft/client/skins/TexturePackRepository.h"
#include "platform/storage/storage.h"
#include "platform/profile/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::string, 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, IPlatformStorage::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 - "
"PlatformStorage.GetInstalledDLC\n");
PlatformStorage.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 (PlatformStorage.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("PlatformStorage.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 =
PlatformStorage.GetDLC(m_iTotalDLCInstalled);
DLCPack* pack =
app.m_dlcManager.getPack(CONTENT_DATA_DISPLAY_NAME(ContentData));
if (pack != nullptr && pack->IsCorrupt()) {
app.DebugPrintf(
"Pack '%s' 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 \"%s\" 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 \"%s\" 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);
}
PlatformStorage.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
PlatformStorage.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 char* lpStr) {
app.DebugPrintf("ADDING CREDIT - %s\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 char[strlen(lpStr) + 1];
strcpy((char*)pCreditStruct->m_Text, lpStr);
vDLCCredits.push_back(pCreditStruct);
}
bool DLCController::alreadySeenCreditText(const std::string& wstemp) {
for (unsigned int i = 0; i < m_vCreditText.size(); i++) {
std::string temp = m_vCreditText.at(i);
if (temp.compare(wstemp) == 0) {
return true;
}
}
m_vCreditText.push_back((char*)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(char* pType, char* pBannerName,
int iGender, uint64_t ullOfferID_Full,
uint64_t ullOfferID_Trial,
char* pFirstSkin,
unsigned int uiSortIndex, int iConfig,
char* 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 != "") {
wcsncpy_s(pDLCData->wchBanner, pBannerName, MAX_BANNERNAME_SIZE);
}
if (pDataFile[0] != 0) {
wcsncpy_s(pDLCData->wchDataFile, pDataFile, MAX_BANNERNAME_SIZE);
}
if (pType != nullptr) {
if (strcmp(pType, "Skin") == 0) {
pDLCData->eDLCType = e_DLC_SkinPack;
} else if (strcmp(pType, "Gamerpic") == 0) {
pDLCData->eDLCType = e_DLC_Gamerpics;
} else if (strcmp(pType, "Theme") == 0) {
pDLCData->eDLCType = e_DLC_Themes;
} else if (strcmp(pType, "Avatar") == 0) {
pDLCData->eDLCType = e_DLC_AvatarItems;
} else if (strcmp(pType, "MashUpPack") == 0) {
pDLCData->eDLCType = e_DLC_MashupPacks;
DLCTextures_PackID[pDLCData->iConfig] = ullOfferID_Full;
} else if (strcmp(pType, "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(char* pType, char* pBannerName,
int iGender, uint64_t ullOfferID_Full,
uint64_t ullOfferID_Trial,
char* pFirstSkin,
unsigned int uiSortIndex, int iConfig,
char* pDataFile) {
fprintf(stderr,
"warning: DLCController::registerDLCData unimplemented for "
"platform `__linux__`\n");
return 0;
}
#endif
bool DLCController::getDLCFullOfferIDForSkinID(const std::string& 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 = PlatformProfile.GetPrimaryPad();
if (primPad == -1 || !PlatformProfile.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
IPlatformStorage::EDLCStatus status = PlatformStorage.GetDLCOffers(
PlatformProfile.GetPrimaryPad(),
[this](int iOfferC, std::uint32_t dwType, int pad) {
return dlcOffersReturned(iOfferC, dwType, pad);
},
pCurrent->dwType);
if (status == IPlatformStorage::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 (strcmp(pDLC->wchDataFile,
pCurrent->wchFilename) == 0) {
bAlreadyInQueue = true;
break;
}
}
if (!bAlreadyInQueue) {
TMSPPRequest* pTMSPPreq = new TMSPPRequest;
pTMSPPreq->CallbackFunc =
&DLCController::tmsPPFileReturned;
pTMSPPreq->lpCallbackParam = this;
pTMSPPreq->eStorageFacility =
IPlatformStorage::eGlobalStorage_Title;
pTMSPPreq->eFileTypeVal =
IPlatformStorage::TMS_FILETYPE_BINARY;
memcpy(pTMSPPreq->wchFilename,
pDLC->wchDataFile,
sizeof(char) * 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) {
char* 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 (strcmp(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 =
IPlatformStorage::eGlobalStorage_Title;
pTMSPPreq->eFileTypeVal =
IPlatformStorage::TMS_FILETYPE_BINARY;
memcpy(pTMSPPreq->wchFilename, pDLC->wchBanner,
sizeof(char) * 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 %s, q size is "
"%d\n",
pTMSPPreq->wchFilename,
m_TMSPPDownloadQueue.size());
}
}
}
}
}
}
return 1;
}
int DLCController::tmsPPFileReturned(void* pParam, int iPad, int iUserData,
IPlatformStorage::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];
strncpy(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 %s\n",
pCurrent->wchFilename);
int iConfig =
app.GetTPConfigVal(pCurrent->wchFilename);
app.AddMemoryTPDFile(iConfig, pFileData->pbData,
pFileData->size);
} break;
default:
app.DebugPrintf("--- Got image data - %s\n",
pCurrent->wchFilename);
app.AddMemoryTextureFile(pCurrent->wchFilename,
pFileData->pbData,
pFileData->size);
break;
}
} else {
app.DebugPrintf("TMSImageReturned failed (%s)...\n",
szFilename);
}
break;
}
}
}
return 0;
}

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/storage/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,
IPlatformStorage::DLC_TMS_DETAILS*,
int iPad);
// DLC info registration
static int32_t registerDLCData(char*, char*, int, uint64_t, uint64_t,
char*, unsigned int, int,
char* pDataFile);
bool getDLCFullOfferIDForSkinID(const std::string& 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,
IPlatformStorage::PTMSPP_FILEDATA pFileData,
const char* szFilename);
// Credit text
void addCreditText(const char* lpStr);
bool alreadySeenCreditText(const std::string& 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::string> 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::string, 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;
};

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

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;
};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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::string& 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::string& 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);
}

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::string& 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::string& 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_;
};

View file

@ -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"

View file

@ -1,21 +0,0 @@
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
class WstringLookup {
private:
unsigned int numIDs;
std::unordered_map<std::string, unsigned int> str2int;
std::vector<std::string> int2str;
public:
WstringLookup();
std::string lookup(unsigned int id);
unsigned int lookup(std::string);
void getTable(std::string** lookup, unsigned int* len);
};

File diff suppressed because it is too large Load diff

View file

@ -1,77 +0,0 @@
#pragma once
#include <cstdint>
#include "app/common/App_structs.h"
#include "platform/profile/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,
IPlatformProfile::PROFILESETTINGS* pSettings,
const int iPad);
int setDefaultOptions(IPlatformProfile::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 IPlatformStorage::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

View file

@ -2,7 +2,7 @@
#include <cstdint>
#include "minecraft/GameEnums.h"
#include "app/common/App_enums.h"
class IPlatformGame {
public:
@ -20,11 +20,11 @@ public:
virtual void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0,
bool bCallback = false) = 0;
virtual int LoadLocalTMSFile(char* wchTMSFile) = 0;
virtual int LoadLocalTMSFile(char* wchTMSFile,
virtual int LoadLocalTMSFile(wchar_t* wchTMSFile) = 0;
virtual int LoadLocalTMSFile(wchar_t* wchTMSFile,
eFileExtensionType eExt) = 0;
virtual void FreeLocalTMSFiles(eTMSFileType eType) = 0;
virtual int GetLocalTMSFileIndex(char* wchTMSFile,
virtual int GetLocalTMSFileIndex(wchar_t* wchTMSFile,
bool bFilenameIncludesExtension,
eFileExtensionType eEXT) = 0;
};

View file

@ -1,862 +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/input/input.h"
#include "platform/renderer/renderer.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::string localisationFile = "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 char* 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 (!PlatformRenderer.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::string LocalizationManager::formatHTMLString(
int iPad, const std::string& desc, int shadowColour /*= 0xFFFFFFFF*/) {
std::string text(desc);
char replacements[64];
text = replaceAll(text, "{*B*}", "<br />");
snprintf(replacements, 64, "<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T1));
text = replaceAll(text, "{*T1*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T2));
text = replaceAll(text, "{*T2*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_T3));
text = replaceAll(text, "{*T3*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_Black));
text = replaceAll(text, "{*ETB*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\">",
getHTMLColour(eHTMLColor_White));
text = replaceAll(text, "{*ETW*}", replacements);
text = replaceAll(text, "{*EF*}", "</font>");
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_0), shadowColour);
text = replaceAll(text, "{*C0*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_1), shadowColour);
text = replaceAll(text, "{*C1*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_2), shadowColour);
text = replaceAll(text, "{*C2*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_3), shadowColour);
text = replaceAll(text, "{*C3*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_4), shadowColour);
text = replaceAll(text, "{*C4*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_5), shadowColour);
text = replaceAll(text, "{*C5*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_6), shadowColour);
text = replaceAll(text, "{*C6*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_7), shadowColour);
text = replaceAll(text, "{*C7*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_8), shadowColour);
text = replaceAll(text, "{*C8*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_9), shadowColour);
text = replaceAll(text, "{*C9*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_a), shadowColour);
text = replaceAll(text, "{*CA*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_b), shadowColour);
text = replaceAll(text, "{*CB*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_c), shadowColour);
text = replaceAll(text, "{*CC*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_d), shadowColour);
text = replaceAll(text, "{*CD*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_e), shadowColour);
text = replaceAll(text, "{*CE*}", replacements);
snprintf(replacements, 64, "<font color=\"#%08x\" shadowcolor=\"#%08x\">",
getHTMLColour(eHTMLColor_f), shadowColour);
text = replaceAll(text, "{*CF*}", replacements);
// Swap for southpaw.
if (app.GetGameSettings(iPad, eGameSetting_ControlSouthPaw)) {
text =
replaceAll(text, "{*CONTROLLER_ACTION_MOVE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
text = replaceAll(text, "{*CONTROLLER_ACTION_LOOK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
text = replaceAll(text, "{*CONTROLLER_MENU_NAVIGATE*}",
getVKReplacement(VK_PAD_RTHUMB_LEFT));
} else {
text = replaceAll(text, "{*CONTROLLER_ACTION_MOVE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT));
text =
replaceAll(text, "{*CONTROLLER_ACTION_LOOK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LOOK_RIGHT));
text = replaceAll(text, "{*CONTROLLER_MENU_NAVIGATE*}",
getVKReplacement(VK_PAD_LTHUMB_LEFT));
}
text = replaceAll(text, "{*CONTROLLER_ACTION_JUMP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_JUMP));
text =
replaceAll(text, "{*CONTROLLER_ACTION_SNEAK*}",
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
text = replaceAll(text, "{*CONTROLLER_ACTION_USE*}",
getActionReplacement(iPad, MINECRAFT_ACTION_USE));
text = replaceAll(text, "{*CONTROLLER_ACTION_ACTION*}",
getActionReplacement(iPad, MINECRAFT_ACTION_ACTION));
text = replaceAll(text, "{*CONTROLLER_ACTION_LEFT_SCROLL*}",
getActionReplacement(iPad, MINECRAFT_ACTION_LEFT_SCROLL));
text =
replaceAll(text, "{*CONTROLLER_ACTION_RIGHT_SCROLL*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RIGHT_SCROLL));
text = replaceAll(text, "{*CONTROLLER_ACTION_INVENTORY*}",
getActionReplacement(iPad, MINECRAFT_ACTION_INVENTORY));
text = replaceAll(text, "{*CONTROLLER_ACTION_CRAFTING*}",
getActionReplacement(iPad, MINECRAFT_ACTION_CRAFTING));
text = replaceAll(text, "{*CONTROLLER_ACTION_DROP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DROP));
text = replaceAll(
text, "{*CONTROLLER_ACTION_CAMERA*}",
getActionReplacement(iPad, MINECRAFT_ACTION_RENDER_THIRD_PERSON));
text = replaceAll(text, "{*CONTROLLER_ACTION_MENU_PAGEDOWN*}",
getActionReplacement(iPad, ACTION_MENU_PAGEDOWN));
text =
replaceAll(text, "{*CONTROLLER_ACTION_DISMOUNT*}",
getActionReplacement(iPad, MINECRAFT_ACTION_SNEAK_TOGGLE));
text = replaceAll(text, "{*CONTROLLER_VK_A*}", getVKReplacement(VK_PAD_A));
text = replaceAll(text, "{*CONTROLLER_VK_B*}", getVKReplacement(VK_PAD_B));
text = replaceAll(text, "{*CONTROLLER_VK_X*}", getVKReplacement(VK_PAD_X));
text = replaceAll(text, "{*CONTROLLER_VK_Y*}", getVKReplacement(VK_PAD_Y));
text = replaceAll(text, "{*CONTROLLER_VK_LB*}",
getVKReplacement(VK_PAD_LSHOULDER));
text = replaceAll(text, "{*CONTROLLER_VK_RB*}",
getVKReplacement(VK_PAD_RSHOULDER));
text = replaceAll(text, "{*CONTROLLER_VK_LS*}",
getVKReplacement(VK_PAD_LTHUMB_UP));
text = replaceAll(text, "{*CONTROLLER_VK_RS*}",
getVKReplacement(VK_PAD_RTHUMB_UP));
text = replaceAll(text, "{*CONTROLLER_VK_LT*}",
getVKReplacement(VK_PAD_LTRIGGER));
text = replaceAll(text, "{*CONTROLLER_VK_RT*}",
getVKReplacement(VK_PAD_RTRIGGER));
text = replaceAll(text, "{*ICON_SHANK_01*}",
getIconReplacement(XZP_ICON_SHANK_01));
text = replaceAll(text, "{*ICON_SHANK_03*}",
getIconReplacement(XZP_ICON_SHANK_03));
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_UP*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_UP));
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_DOWN*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_DOWN));
text = replaceAll(text, "{*CONTROLLER_ACTION_DPAD_RIGHT*}",
getActionReplacement(iPad, MINECRAFT_ACTION_DPAD_RIGHT));
text = replaceAll(text, "{*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, "&nbsp;", "");
break;
}
return text;
}
std::string LocalizationManager::getActionReplacement(
int iPad, unsigned char ucAction) {
unsigned int input = PlatformInput.GetGameJoypadMaps(
PlatformInput.GetJoypadMapVal(iPad), ucAction);
std::string replacement = "";
if (input & _360_JOY_BUTTON_A)
replacement = "ButtonA";
else if (input & _360_JOY_BUTTON_B)
replacement = "ButtonB";
else if (input & _360_JOY_BUTTON_X)
replacement = "ButtonX";
else if (input & _360_JOY_BUTTON_Y)
replacement = "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 = "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 = "ButtonRightStick";
} else if (input & _360_JOY_BUTTON_DPAD_LEFT)
replacement = "ButtonDpadL";
else if (input & _360_JOY_BUTTON_DPAD_RIGHT)
replacement = "ButtonDpadR";
else if (input & _360_JOY_BUTTON_DPAD_UP)
replacement = "ButtonDpadU";
else if (input & _360_JOY_BUTTON_DPAD_DOWN)
replacement = "ButtonDpadD";
else if (input & _360_JOY_BUTTON_LT)
replacement = "ButtonLeftTrigger";
else if (input & _360_JOY_BUTTON_RT)
replacement = "ButtonRightTrigger";
else if (input & _360_JOY_BUTTON_RB)
replacement = "ButtonRightBumper";
else if (input & _360_JOY_BUTTON_LB)
replacement = "ButtonLeftBumper";
else if (input & _360_JOY_BUTTON_BACK)
replacement = "ButtonBack";
else if (input & _360_JOY_BUTTON_START)
replacement = "ButtonStart";
else if (input & _360_JOY_BUTTON_RTHUMB)
replacement = "ButtonRS";
else if (input & _360_JOY_BUTTON_LTHUMB)
replacement = "ButtonLS";
char string[128];
#if defined(_WIN64)
int size = 45;
if (ui.getScreenWidth() < 1920) size = 30;
#else
int size = 45;
#endif
snprintf(string, 128,
"<img src=\"%s\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
replacement.c_str(), size, size);
return string;
}
std::string LocalizationManager::getVKReplacement(unsigned int uiVKey) {
std::string replacement = "";
switch (uiVKey) {
case VK_PAD_A:
replacement = "ButtonA";
break;
case VK_PAD_B:
replacement = "ButtonB";
break;
case VK_PAD_X:
replacement = "ButtonX";
break;
case VK_PAD_Y:
replacement = "ButtonY";
break;
case VK_PAD_LSHOULDER:
replacement = "ButtonLeftBumper";
break;
case VK_PAD_RSHOULDER:
replacement = "ButtonRightBumper";
break;
case VK_PAD_LTRIGGER:
replacement = "ButtonLeftTrigger";
break;
case VK_PAD_RTRIGGER:
replacement = "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 = "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 = "ButtonRightStick";
break;
default:
break;
}
char string[128];
#if defined(_WIN64)
int size = 45;
if (ui.getScreenWidth() < 1920) size = 30;
#else
int size = 45;
#endif
snprintf(string, 128,
"<img src=\"%s\" align=\"middle\" height=\"%d\" width=\"%d\"/>",
replacement.c_str(), size, size);
return string;
}
std::string LocalizationManager::getIconReplacement(unsigned int uiIcon) {
char string[128];
#if defined(_WIN64)
int size = 33;
if (ui.getScreenWidth() < 1920) size = 22;
#else
int size = 33;
#endif
snprintf(string, 128,
"<img src=\"Icon_Shank\" align=\"middle\" height=\"%d\" "
"width=\"%d\"/>",
size, size);
std::string result = "";
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::string>& 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(char* pwchLocale) {
return m_eMCLangA[pwchLocale];
}
int LocalizationManager::get_xcLang(char* pwchLocale) {
return m_xcLangA[pwchLocale];
}
void LocalizationManager::localeAndLanguageInit() {
m_localeA[eMCLang_zhCHT] = "zh-CHT";
m_localeA[eMCLang_csCS] = "cs-CS";
m_localeA[eMCLang_laLAS] = "la-LAS";
m_localeA[eMCLang_null] = "en-EN";
m_localeA[eMCLang_enUS] = "en-US";
m_localeA[eMCLang_enGB] = "en-GB";
m_localeA[eMCLang_enIE] = "en-IE";
m_localeA[eMCLang_enAU] = "en-AU";
m_localeA[eMCLang_enNZ] = "en-NZ";
m_localeA[eMCLang_enCA] = "en-CA";
m_localeA[eMCLang_jaJP] = "ja-JP";
m_localeA[eMCLang_deDE] = "de-DE";
m_localeA[eMCLang_deAT] = "de-AT";
m_localeA[eMCLang_frFR] = "fr-FR";
m_localeA[eMCLang_frCA] = "fr-CA";
m_localeA[eMCLang_esES] = "es-ES";
m_localeA[eMCLang_esMX] = "es-MX";
m_localeA[eMCLang_itIT] = "it-IT";
m_localeA[eMCLang_koKR] = "ko-KR";
m_localeA[eMCLang_ptPT] = "pt-PT";
m_localeA[eMCLang_ptBR] = "pt-BR";
m_localeA[eMCLang_ruRU] = "ru-RU";
m_localeA[eMCLang_nlNL] = "nl-NL";
m_localeA[eMCLang_fiFI] = "fi-FI";
m_localeA[eMCLang_svSV] = "sv-SV";
m_localeA[eMCLang_daDA] = "da-DA";
m_localeA[eMCLang_noNO] = "no-NO";
m_localeA[eMCLang_plPL] = "pl-PL";
m_localeA[eMCLang_trTR] = "tr-TR";
m_localeA[eMCLang_elEL] = "el-EL";
m_localeA[eMCLang_zhSG] = "zh-SG";
m_localeA[eMCLang_zhCN] = "zh-CN";
m_localeA[eMCLang_zhHK] = "zh-HK";
m_localeA[eMCLang_zhTW] = "zh-TW";
m_localeA[eMCLang_nlBE] = "nl-BE";
m_localeA[eMCLang_daDK] = "da-DK";
m_localeA[eMCLang_frBE] = "fr-BE";
m_localeA[eMCLang_frCH] = "fr-CH";
m_localeA[eMCLang_deCH] = "de-CH";
m_localeA[eMCLang_nbNO] = "nb-NO";
m_localeA[eMCLang_enGR] = "en-GR";
m_localeA[eMCLang_enHK] = "en-HK";
m_localeA[eMCLang_enSA] = "en-SA";
m_localeA[eMCLang_enHU] = "en-HU";
m_localeA[eMCLang_enIN] = "en-IN";
m_localeA[eMCLang_enIL] = "en-IL";
m_localeA[eMCLang_enSG] = "en-SG";
m_localeA[eMCLang_enSK] = "en-SK";
m_localeA[eMCLang_enZA] = "en-ZA";
m_localeA[eMCLang_enCZ] = "en-CZ";
m_localeA[eMCLang_enAE] = "en-AE";
m_localeA[eMCLang_esAR] = "es-AR";
m_localeA[eMCLang_esCL] = "es-CL";
m_localeA[eMCLang_esCO] = "es-CO";
m_localeA[eMCLang_esUS] = "es-US";
m_localeA[eMCLang_svSE] = "sv-SE";
m_localeA[eMCLang_csCZ] = "cs-CZ";
m_localeA[eMCLang_elGR] = "el-GR";
m_localeA[eMCLang_nnNO] = "nn-NO";
m_localeA[eMCLang_skSK] = "sk-SK";
m_localeA[eMCLang_hans] = "zh-HANS";
m_localeA[eMCLang_hant] = "zh-HANT";
m_eMCLangA["zh-CHT"] = eMCLang_zhCHT;
m_eMCLangA["cs-CS"] = eMCLang_csCS;
m_eMCLangA["la-LAS"] = eMCLang_laLAS;
m_eMCLangA["en-EN"] = eMCLang_null;
m_eMCLangA["en-US"] = eMCLang_enUS;
m_eMCLangA["en-GB"] = eMCLang_enGB;
m_eMCLangA["en-IE"] = eMCLang_enIE;
m_eMCLangA["en-AU"] = eMCLang_enAU;
m_eMCLangA["en-NZ"] = eMCLang_enNZ;
m_eMCLangA["en-CA"] = eMCLang_enCA;
m_eMCLangA["ja-JP"] = eMCLang_jaJP;
m_eMCLangA["de-DE"] = eMCLang_deDE;
m_eMCLangA["de-AT"] = eMCLang_deAT;
m_eMCLangA["fr-FR"] = eMCLang_frFR;
m_eMCLangA["fr-CA"] = eMCLang_frCA;
m_eMCLangA["es-ES"] = eMCLang_esES;
m_eMCLangA["es-MX"] = eMCLang_esMX;
m_eMCLangA["it-IT"] = eMCLang_itIT;
m_eMCLangA["ko-KR"] = eMCLang_koKR;
m_eMCLangA["pt-PT"] = eMCLang_ptPT;
m_eMCLangA["pt-BR"] = eMCLang_ptBR;
m_eMCLangA["ru-RU"] = eMCLang_ruRU;
m_eMCLangA["nl-NL"] = eMCLang_nlNL;
m_eMCLangA["fi-FI"] = eMCLang_fiFI;
m_eMCLangA["sv-SV"] = eMCLang_svSV;
m_eMCLangA["da-DA"] = eMCLang_daDA;
m_eMCLangA["no-NO"] = eMCLang_noNO;
m_eMCLangA["pl-PL"] = eMCLang_plPL;
m_eMCLangA["tr-TR"] = eMCLang_trTR;
m_eMCLangA["el-EL"] = eMCLang_elEL;
m_eMCLangA["zh-SG"] = eMCLang_zhSG;
m_eMCLangA["zh-CN"] = eMCLang_zhCN;
m_eMCLangA["zh-HK"] = eMCLang_zhHK;
m_eMCLangA["zh-TW"] = eMCLang_zhTW;
m_eMCLangA["nl-BE"] = eMCLang_nlBE;
m_eMCLangA["da-DK"] = eMCLang_daDK;
m_eMCLangA["fr-BE"] = eMCLang_frBE;
m_eMCLangA["fr-CH"] = eMCLang_frCH;
m_eMCLangA["de-CH"] = eMCLang_deCH;
m_eMCLangA["nb-NO"] = eMCLang_nbNO;
m_eMCLangA["en-GR"] = eMCLang_enGR;
m_eMCLangA["en-HK"] = eMCLang_enHK;
m_eMCLangA["en-SA"] = eMCLang_enSA;
m_eMCLangA["en-HU"] = eMCLang_enHU;
m_eMCLangA["en-IN"] = eMCLang_enIN;
m_eMCLangA["en-IL"] = eMCLang_enIL;
m_eMCLangA["en-SG"] = eMCLang_enSG;
m_eMCLangA["en-SK"] = eMCLang_enSK;
m_eMCLangA["en-ZA"] = eMCLang_enZA;
m_eMCLangA["en-CZ"] = eMCLang_enCZ;
m_eMCLangA["en-AE"] = eMCLang_enAE;
m_eMCLangA["es-AR"] = eMCLang_esAR;
m_eMCLangA["es-CL"] = eMCLang_esCL;
m_eMCLangA["es-CO"] = eMCLang_esCO;
m_eMCLangA["es-US"] = eMCLang_esUS;
m_eMCLangA["sv-SE"] = eMCLang_svSE;
m_eMCLangA["cs-CZ"] = eMCLang_csCZ;
m_eMCLangA["el-GR"] = eMCLang_elGR;
m_eMCLangA["nn-NO"] = eMCLang_nnNO;
m_eMCLangA["sk-SK"] = eMCLang_skSK;
m_eMCLangA["zh-HANS"] = eMCLang_hans;
m_eMCLangA["zh-HANT"] = eMCLang_hant;
m_xcLangA["zh-CHT"] = XC_LOCALE_CHINA;
m_xcLangA["cs-CS"] = XC_LOCALE_CHINA;
m_xcLangA["en-EN"] = XC_LOCALE_UNITED_STATES;
m_xcLangA["en-US"] = XC_LOCALE_UNITED_STATES;
m_xcLangA["en-GB"] = XC_LOCALE_GREAT_BRITAIN;
m_xcLangA["en-IE"] = XC_LOCALE_IRELAND;
m_xcLangA["en-AU"] = XC_LOCALE_AUSTRALIA;
m_xcLangA["en-NZ"] = XC_LOCALE_NEW_ZEALAND;
m_xcLangA["en-CA"] = XC_LOCALE_CANADA;
m_xcLangA["ja-JP"] = XC_LOCALE_JAPAN;
m_xcLangA["de-DE"] = XC_LOCALE_GERMANY;
m_xcLangA["de-AT"] = XC_LOCALE_AUSTRIA;
m_xcLangA["fr-FR"] = XC_LOCALE_FRANCE;
m_xcLangA["fr-CA"] = XC_LOCALE_CANADA;
m_xcLangA["es-ES"] = XC_LOCALE_SPAIN;
m_xcLangA["es-MX"] = XC_LOCALE_MEXICO;
m_xcLangA["it-IT"] = XC_LOCALE_ITALY;
m_xcLangA["ko-KR"] = XC_LOCALE_KOREA;
m_xcLangA["pt-PT"] = XC_LOCALE_PORTUGAL;
m_xcLangA["pt-BR"] = XC_LOCALE_BRAZIL;
m_xcLangA["ru-RU"] = XC_LOCALE_RUSSIAN_FEDERATION;
m_xcLangA["nl-NL"] = XC_LOCALE_NETHERLANDS;
m_xcLangA["fi-FI"] = XC_LOCALE_FINLAND;
m_xcLangA["sv-SV"] = XC_LOCALE_SWEDEN;
m_xcLangA["da-DA"] = XC_LOCALE_DENMARK;
m_xcLangA["no-NO"] = XC_LOCALE_NORWAY;
m_xcLangA["pl-PL"] = XC_LOCALE_POLAND;
m_xcLangA["tr-TR"] = XC_LOCALE_TURKEY;
m_xcLangA["el-EL"] = XC_LOCALE_GREECE;
m_xcLangA["la-LAS"] = XC_LOCALE_LATIN_AMERICA;
m_xcLangA["zh-SG"] = XC_LOCALE_SINGAPORE;
m_xcLangA["Zh-CN"] = XC_LOCALE_CHINA;
m_xcLangA["zh-HK"] = XC_LOCALE_HONG_KONG;
m_xcLangA["zh-TW"] = XC_LOCALE_TAIWAN;
m_xcLangA["nl-BE"] = XC_LOCALE_BELGIUM;
m_xcLangA["da-DK"] = XC_LOCALE_DENMARK;
m_xcLangA["fr-BE"] = XC_LOCALE_BELGIUM;
m_xcLangA["fr-CH"] = XC_LOCALE_SWITZERLAND;
m_xcLangA["de-CH"] = XC_LOCALE_SWITZERLAND;
m_xcLangA["nb-NO"] = XC_LOCALE_NORWAY;
m_xcLangA["en-GR"] = XC_LOCALE_GREECE;
m_xcLangA["en-HK"] = XC_LOCALE_HONG_KONG;
m_xcLangA["en-SA"] = XC_LOCALE_SAUDI_ARABIA;
m_xcLangA["en-HU"] = XC_LOCALE_HUNGARY;
m_xcLangA["en-IN"] = XC_LOCALE_INDIA;
m_xcLangA["en-IL"] = XC_LOCALE_ISRAEL;
m_xcLangA["en-SG"] = XC_LOCALE_SINGAPORE;
m_xcLangA["en-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
m_xcLangA["en-ZA"] = XC_LOCALE_SOUTH_AFRICA;
m_xcLangA["en-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
m_xcLangA["en-AE"] = XC_LOCALE_UNITED_ARAB_EMIRATES;
m_xcLangA["ja-IP"] = XC_LOCALE_JAPAN;
m_xcLangA["es-AR"] = XC_LOCALE_ARGENTINA;
m_xcLangA["es-CL"] = XC_LOCALE_CHILE;
m_xcLangA["es-CO"] = XC_LOCALE_COLOMBIA;
m_xcLangA["es-US"] = XC_LOCALE_UNITED_STATES;
m_xcLangA["sv-SE"] = XC_LOCALE_SWEDEN;
m_xcLangA["cs-CZ"] = XC_LOCALE_CZECH_REPUBLIC;
m_xcLangA["el-GR"] = XC_LOCALE_GREECE;
m_xcLangA["sk-SK"] = XC_LOCALE_SLOVAK_REPUBLIC;
m_xcLangA["zh-HANS"] = XC_LOCALE_CHINA;
m_xcLangA["zh-HANT"] = XC_LOCALE_CHINA;
}

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 char* getString(int iID) const;
std::string formatHTMLString(int iPad, const std::string& desc,
int shadowColour = 0xFFFFFFFF);
std::string getActionReplacement(int iPad, unsigned char ucAction);
std::string getVKReplacement(unsigned int uiVKey);
std::string 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::string>& vecWstrLocales);
int get_eMCLang(char* pwchLocale);
int get_xcLang(char* pwchLocale);
StringTable* getStringTable() const { return m_stringTable; }
private:
static int s_iHTMLFontSizesA[eHTMLSize_COUNT];
StringTable* m_stringTable;
std::unordered_map<int, std::string> m_localeA;
std::unordered_map<std::string, int> m_eMCLangA;
std::unordered_map<std::string, 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);
};

View file

@ -1,666 +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 "app/linux/Stubs/winapi_stubs.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/profile/profile.h"
#include "platform/storage/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::string& 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::string& 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, IPlatformStorage::EMessageResult result) {
return 0;
}
int MenuController::unlockFullInviteReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
Minecraft* pMinecraft = Minecraft::GetInstance();
bool bNoPlayer;
if (pMinecraft->player == nullptr) {
bNoPlayer = true;
}
return 0;
}
int MenuController::unlockFullSaveReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
return 0;
}
int MenuController::unlockFullExitReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (result != IPlatformStorage::EMessage_ResultAccept) {
pApp->SetAction(pMinecraft->player->GetXboxPad(),
eAppAction_ExitWorldTrial);
}
return 0;
}
int MenuController::trialOverReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
Minecraft* pMinecraft = Minecraft::GetInstance();
if (result != IPlatformStorage::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(PlatformProfile.GetPrimaryPad()) ==
eAppAction_WaitRemoteServerSaveComplete) {
pMinecraft->tickAllConnections();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
if (app.GetXuiAction(PlatformProfile.GetPrimaryPad()) !=
eAppAction_WaitRemoteServerSaveComplete) {
return ERROR_CANCELLED;
}
app.SetAction(PlatformProfile.GetPrimaryPad(), eAppAction_Idle);
ui.UpdatePlayerBasePositions();
Tile::ReleaseThreadStorage();
return 0;
}
void MenuController::exitGameFromRemoteSave(void* lpParameter) {
int primaryPad = PlatformProfile.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, IPlatformStorage::EMessageResult result) {
if (result == IPlatformStorage::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;
}

View file

@ -1,151 +0,0 @@
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include "app/common/App_structs.h"
#include "platform/storage/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::string& 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::string& 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,
IPlatformStorage::EMessageResult result);
static int fatalErrorDialogReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result);
static int trialOverReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result);
static int unlockFullExitReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result);
static int unlockFullSaveReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result);
static int unlockFullInviteReturned(void* pParam, int iPad,
IPlatformStorage::EMessageResult result);
// Remote save
static int remoteSaveThreadProc(void* lpParameter);
static void exitGameFromRemoteSave(void* lpParameter);
static int exitGameFromRemoteSaveDialogReturned(
void* pParam, int iPad, IPlatformStorage::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);
};

View file

@ -1,512 +0,0 @@
#include "app/common/NetworkController.h"
#include <chrono>
#include <cstring>
#include <thread>
#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/world/level/storage/ConsoleSaveFileIO/compression.h"
#include "platform/input/input.h"
#include "platform/profile/profile.h"
#include "platform/storage/storage.h"
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 (XUserGetSigninInfo(i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
&m_currentSigninInfo[i]) < 0) {
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 IPlatformStorage::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 IPlatformStorage::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 = PlatformProfile.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 = PlatformProfile.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 = PlatformProfile.GetPrimaryPad();
if ((PlatformProfile.GetLockedProfile() != -1) && iPrimaryPlayer != -1) {
if (((uiSignInData & (1 << iPrimaryPlayer)) == 0) ||
bPrimaryPlayerChanged) {
pApp->SetAction(iPrimaryPlayer, eAppAction_PrimaryPlayerSignedOut);
pApp->InvalidateBannedList(iPrimaryPlayer);
PlatformStorage.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 (PlatformProfile.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, PlatformProfile.GetPrimaryPad());
}
bool switchToOffline = false;
if (!PlatformProfile.IsSignedInLive(
PlatformProfile.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 && !PlatformProfile.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() &&
!PlatformProfile.IsSignedInLive(
PlatformProfile.GetLockedProfile())) {
{
pApp->SetAction(iPrimaryPlayer,
eAppAction_EthernetDisconnected);
}
}
}
m_uiLastSignInData = uiSignInData;
} else if (iPrimaryPlayer != -1) {
pApp->InvalidateBannedList(iPrimaryPlayer);
PlatformStorage.ClearDLCOffers();
pApp->ClearAndResetDLCDownloadQueue();
pApp->ClearDLCInstalled();
}
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
if (XUserGetSigninInfo(
i, XUSER_GET_SIGNIN_INFO_OFFLINE_XUID_ONLY,
&pApp->m_networkController.m_currentSigninInfo[i]) < 0) {
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 (!PlatformInput.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(PlatformProfile.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, IPlatformStorage::EMessageResult result) {
Game* pApp = (Game*)pParam;
if (result == IPlatformStorage::EMessage_ResultDecline) {
pApp->SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
int NetworkController::exitAndJoinFromInviteSaveDialogReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
Game* pClass = (Game*)pParam;
if (result == IPlatformStorage::EMessage_ResultDecline ||
result == IPlatformStorage::EMessage_ResultThirdOption) {
if (result == IPlatformStorage::EMessage_ResultDecline) {
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
TexturePack* tPack =
Minecraft::GetInstance()->skins->getSelected();
DLCPack* pDLCPack = tPack->getDLCPack();
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
"")) {
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;
PlatformStorage.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,
PlatformProfile.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, PlatformProfile.GetPrimaryPad(),
&NetworkController::exitAndJoinFromInviteDeclineSaveReturned,
pClass);
return 0;
}
app.SetAction(PlatformProfile.GetPrimaryPad(),
eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}
int NetworkController::warningTrialTexturePackReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
return 0;
}
int NetworkController::exitAndJoinFromInviteAndSaveReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result) {
if (result == IPlatformStorage::EMessage_ResultDecline) {
if (!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) {
TexturePack* tPack = Minecraft::GetInstance()->skins->getSelected();
DLCPack* pDLCPack = tPack->getDLCPack();
if (!pDLCPack->hasPurchasedFile(DLCManager::e_DLCType_Texture,
"")) {
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, IPlatformStorage::EMessageResult result) {
if (result == IPlatformStorage::EMessage_ResultDecline) {
MinecraftServer::getInstance()->setSaveOnExit(false);
app.SetAction(iPad, eAppAction_ExitAndJoinFromInviteConfirmed);
}
return 0;
}

View file

@ -1,106 +0,0 @@
#pragma once
#include <cstdint>
#include "app/common/App_structs.h"
#include "platform/NetTypes.h"
#include "platform/storage/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 IPlatformStorage::EMessageResult);
static int ethernetDisconnectReturned(void* pParam, int iPad,
const IPlatformStorage::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,
IPlatformStorage::EMessageResult result);
static int exitAndJoinFromInviteSaveDialogReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
static int exitAndJoinFromInviteAndSaveReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
static int exitAndJoinFromInviteDeclineSaveReturned(
void* pParam, int iPad, IPlatformStorage::EMessageResult result);
static int warningTrialTexturePackReturned(
void* pParam, int iPad, IPlatformStorage::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;
};

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/profile/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(PlatformProfile.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(PlatformProfile.GetPrimaryPad(),
eXuiServerAction_PauseServer,
(void*)false);
}
}
}
}

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;
};

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/profile/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::string& 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::string 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;
char chars[256];
if (GET_IS_DLC_SKIN_FROM_BITMASK(dwSkin)) {
snprintf(chars, 256, "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::string& 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::string 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;
char chars[256];
for (unsigned int i = 0; i < uiCount; i++) {
snprintf(chars, 256, "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, "") ||
(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 PlatformProfile.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::string& 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)
printf("Incrementing the memory texture file count for %s\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::string& 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)
printf("Decrementing the memory texture file count for %s\n",
wName.c_str());
#endif
PMEMDATA pData = (*it).second;
--pData->ucRefCount;
if (pData->ucRefCount <= 0) {
#if !defined(_CONTENT_PACKAGE)
printf("Erasing the memory texture file data for %s\n",
wName.c_str());
#endif
delete pData;
m_MEM_Files.erase(wName);
}
}
}
bool SkinManager::defaultCapeExists() {
std::string wTex = "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::string& 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::string& 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::string& skin) {
bool dlcSkin = false;
unsigned int skinId = 0;
if (skin.size() >= 14) {
dlcSkin = skin.substr(0, 3).compare("dlc") == 0;
std::string skinValue = skin.substr(7, skin.size());
skinValue = skinValue.substr(0, skinValue.find_first_of('.'));
std::stringstream 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::string SkinManager::getSkinPathFromId(std::uint32_t skinId) {
char chars[256];
if (GET_IS_DLC_SKIN_FROM_BITMASK(skinId)) {
snprintf(chars, 256, "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) {
snprintf(chars, 256, "defskin%08X.png", defaultSkinIndex);
} else {
snprintf(chars, 256, "ugcskin%08X.png", ugcSkinIndex);
}
}
return chars;
}

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::string& name,
GAME_SETTINGS** gameSettingsA);
void setPlayerSkin(int iPad, std::uint32_t dwSkinId,
GAME_SETTINGS** gameSettingsA);
std::string 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::string& name,
GAME_SETTINGS** gameSettingsA);
void setPlayerCape(int iPad, std::uint32_t dwCapeId,
GAME_SETTINGS** gameSettingsA);
std::string 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::string& skin);
static std::string 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::string& wName, std::uint8_t* pbData,
unsigned int byteCount);
void removeMemoryTextureFile(const std::string& wName);
void getMemFileDetails(const std::string& wName, std::uint8_t** ppbData,
unsigned int* pByteCount);
bool isFileInMemoryTextures(const std::string& wName);
// storing skin files
std::vector<std::string> 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::string, 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;
};

View file

@ -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;
}
}

View file

@ -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;
};

View file

@ -1,31 +0,0 @@
#include "UIComponent_Logo.h"
#include "platform/renderer/renderer.h"
#include "app/common/UI/UILayer.h"
#include "app/common/UI/UIScene.h"
UIComponent_Logo::UIComponent_Logo(int iPad, void* initData,
UILayer* parentLayer)
: UIScene(iPad, parentLayer) {
// Setup all the Iggy references we need for this scene
initialiseMovie();
}
std::string UIComponent_Logo::getMoviePath() {
switch (m_parentLayer->getViewport()) {
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_TOP:
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_BOTTOM:
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_LEFT:
case IPlatformRenderer::VIEWPORT_TYPE_SPLIT_RIGHT:
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
case IPlatformRenderer::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
return "ComponentLogoSplit";
break;
case IPlatformRenderer::VIEWPORT_TYPE_FULLSCREEN:
default:
return "ComponentLogo";
break;
}
}

View file

@ -1,78 +0,0 @@
#include "UIControl_SaveList.h"
#include "app/common/UI/Controls/UIControl.h"
#include "app/common/UI/Controls/UIControl_ButtonList.h"
#include "app/common/UI/UIScene.h"
#include "app/linux/Iggy/include/iggy.h"
#ifndef _ENABLEIGGY
#include "app/linux/Stubs/iggy_stubs.h"
#endif
#include "app/linux/Iggy/include/rrCore.h"
#include "util/StringHelpers.h"
bool UIControl_SaveList::setupControl(UIScene* scene, IggyValuePath* parent,
const std::string& controlName) {
UIControl::setControlType(UIControl::eSaveList);
bool success =
UIControl_ButtonList::setupControl(scene, parent, controlName);
// SlotList specific initialisers
m_funcSetTextureName = registerFastName("SetTextureName");
return success;
}
void UIControl_SaveList::addItem(const std::string& label) {
addItem(label, "");
}
void UIControl_SaveList::addItem(const std::string& label, int data) {
addItem(label, "", data);
}
void UIControl_SaveList::addItem(const std::string& label,
const std::string& iconName) {
addItem(label, iconName, m_itemCount);
++m_itemCount;
}
void UIControl_SaveList::addItem(const std::string& label,
const std::string& iconName, int data) {
IggyDataValue result;
IggyDataValue value[3];
IggyStringUTF8 stringVal;
stringVal.string = const_cast<char*>((char*)label.c_str());
stringVal.length = (S32)label.length();
value[0].type = IGGY_DATATYPE_string_UTF8;
value[0].string8 = stringVal;
value[1].type = IGGY_DATATYPE_number;
value[1].number = m_itemCount;
IggyStringUTF8 stringVal2;
stringVal2.string = const_cast<char*>(iconName.c_str());
stringVal2.length = iconName.length();
value[2].type = IGGY_DATATYPE_string_UTF8;
value[2].string8 = stringVal2;
IggyResult out =
IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(), m_addNewItemFunc, 3, value);
}
void UIControl_SaveList::setTextureName(int iId, const std::string& iconName) {
IggyDataValue result;
IggyDataValue value[2];
value[0].type = IGGY_DATATYPE_number;
value[0].number = iId;
IggyStringUTF8 stringVal;
stringVal.string = const_cast<char*>(iconName.c_str());
stringVal.length = iconName.length();
value[1].type = IGGY_DATATYPE_string_UTF8;
value[1].string8 = stringVal;
IggyResult out = IggyPlayerCallMethodRS(m_parentScene->getMovie(), &result,
getIggyValuePath(),
m_funcSetTextureName, 2, value);
}

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 char* CXuiStringTable::Lookup(const char* szId) { return szId; }
const char* CXuiStringTable::Lookup(uint32_t nIndex) { return "String"; }
void CXuiStringTable::Clear() {}
int32_t CXuiStringTable::Load(const char* szId) { return 0; }
uint32_t XGetLanguage() { return 1; }
uint32_t XGetLocale() { return 0; }
uint32_t XEnableGuestSignin(bool fEnable) { return 0; }

View file

@ -33,7 +33,7 @@ public:
virtual void destroy() = 0;
virtual void play(int iSound, float x, float y, float z, float volume,
float pitch) = 0;
virtual void playStreaming(const std::string& name, float x, float y,
virtual void playStreaming(const std::wstring& name, float x, float y,
float z, float volume, float pitch,
bool bMusicDelay = true) = 0;
virtual void playUI(int iSound, float volume, float pitch) = 0;
@ -41,10 +41,10 @@ public:
virtual void updateSystemMusicPlaying(bool isPlaying) = 0;
virtual void updateSoundEffectVolume(float fVal) = 0;
virtual void init(Options*) = 0;
virtual void add(const std::string& name, File* file) = 0;
virtual void addMusic(const std::string& name, File* file) = 0;
virtual void addStreaming(const std::string& name, File* file) = 0;
virtual char* ConvertSoundPathToName(const std::string& name,
virtual void add(const std::wstring& name, File* file) = 0;
virtual void addMusic(const std::wstring& name, File* file) = 0;
virtual void addStreaming(const std::wstring& name, File* file) = 0;
virtual char* ConvertSoundPathToName(const std::wstring& name,
bool bConvertSpaces) = 0;
virtual void playMusicTick() = 0;
@ -57,8 +57,8 @@ public:
virtual void SetIsPlayingEndMusic(bool bVal);
virtual void SetIsPlayingNetherMusic(bool bVal);
static const char* wchSoundNames[eSoundType_MAX];
static const char* wchUISoundNames[eSFX_MAX];
static const wchar_t* wchSoundNames[eSoundType_MAX];
static const wchar_t* wchUISoundNames[eSFX_MAX];
public:
void tick();

View file

@ -12,11 +12,11 @@
#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"
#include "platform/fs/fs.h"
#include "platform/PlatformServices.h"
#include "java/Random.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
@ -117,6 +117,13 @@ char SoundEngine::m_szRedistName[] = {"redist64"};
// Linux specific functions
#if defined(__linux__)
std::wstring stws(const char* utf8) {
size_t len = std::mbstowcs(nullptr, utf8, 0);
if (len == static_cast<size_t>(-1)) return L"";
std::wstring result(len, L'\0');
std::mbstowcs(&result[0], utf8, len);
return result;
}
SoundEngine::SoundEngine() {}
std::vector<MiniAudioSound*> m_activeSounds;
void SoundEngine::init(Options* pOptions) {
@ -172,11 +179,11 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
float pitch) {
if (iSound == -1) return;
char szId[256];
strncpy(szId, wchSoundNames[iSound], 255);
wcstombs(szId, wchSoundNames[iSound], 255);
for (int i = 0; szId[i]; i++)
if (szId[i] == '.') szId[i] = '/';
std::string base = PlatformFilesystem.getBasePath().string() + "/";
std::string base = PlatformFileIO.getBasePath().string() + "/";
const char* roots[] = {
"Sound/Minecraft/", "app/common/Sound/Minecraft/",
"app/common/res/TitleUpdate/res/Sound/Minecraft/"};
@ -190,7 +197,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
for (int i = 1; i <= 16; i++) {
char tryP[512];
snprintf(tryP, 512, "%s%s%d%s", fullRoot.c_str(), szId, i, ext);
if (PlatformFilesystem.exists(tryP))
if (PlatformFileIO.exists(tryP))
count = i;
else
break;
@ -203,7 +210,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
}
char tryP[512];
snprintf(tryP, 512, "%s%s%s", fullRoot.c_str(), szId, ext);
if (PlatformFilesystem.exists(tryP)) {
if (PlatformFileIO.exists(tryP)) {
strncpy(finalPath, tryP, 511);
found = true;
break;
@ -238,12 +245,12 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
void SoundEngine::playUI(int iSound, float volume, float pitch) {
char szIdentifier[256];
if (iSound >= eSFX_MAX)
strncpy(szIdentifier, wchSoundNames[iSound], 255);
wcstombs(szIdentifier, wchSoundNames[iSound], 255);
else
strncpy(szIdentifier, wchUISoundNames[iSound], 255);
wcstombs(szIdentifier, wchUISoundNames[iSound], 255);
for (int i = 0; szIdentifier[i]; i++)
if (szIdentifier[i] == '.') szIdentifier[i] = '/';
std::string base = PlatformFilesystem.getBasePath().string() + "/";
std::string base = PlatformFileIO.getBasePath().string() + "/";
const char* roots[] = {
"Sound/Minecraft/UI/",
"Sound/Minecraft/",
@ -258,7 +265,7 @@ void SoundEngine::playUI(int iSound, float volume, float pitch) {
char tryP[512];
snprintf(tryP, 512, "%s%s%s%s", base.c_str(), root, szIdentifier,
ext);
if (PlatformFilesystem.exists(tryP)) {
if (PlatformFileIO.exists(tryP)) {
strncpy(finalPath, tryP, 511);
found = true;
break;
@ -334,12 +341,12 @@ int SoundEngine::getMusicID(int iDomain) {
}
}
int SoundEngine::getMusicID(const std::string& name) {
int SoundEngine::getMusicID(const std::wstring& name) {
int iCD = 0;
for (size_t i = 0; i < 12; i++) {
std::string fileName = m_szStreamFileA[i + eStream_CD_1];
std::wstring fileNameW = stws(m_szStreamFileA[i + eStream_CD_1]);
if (name == fileName) {
if (name == fileNameW) {
iCD = static_cast<int>(i);
break;
}
@ -347,7 +354,7 @@ int SoundEngine::getMusicID(const std::string& name) {
return iCD + m_iStream_CD_1;
}
void SoundEngine::playStreaming(const std::string& name, float x, float y,
void SoundEngine::playStreaming(const std::wstring& name, float x, float y,
float z, float volume, float pitch,
bool bMusicDelay) {
m_StreamingAudioInfo.x = x;
@ -445,7 +452,7 @@ void SoundEngine::playMusicTick() {
return;
}
if (m_musicID != -1) {
std::string base = PlatformFilesystem.getBasePath().string() + "/";
std::string base = PlatformFileIO.getBasePath().string() + "/";
bool isCD = (m_musicID >= m_iStream_CD_1);
const char* folder = isCD ? "cds/" : "music/";
const char* track = m_szStreamFileA[m_musicID];
@ -460,13 +467,13 @@ void SoundEngine::playMusicTick() {
// try with folder prefix (music/ or cds/)
snprintf(m_szStreamName, sizeof(m_szStreamName), "%s%s%s%s%s", base.c_str(), r, folder,
track, e);
if (PlatformFilesystem.exists(m_szStreamName)) {
if (PlatformFileIO.exists(m_szStreamName)) {
found = true;
break;
}
// try without folder prefix
snprintf(m_szStreamName, sizeof(m_szStreamName), "%s%s%s%s", base.c_str(), r, track, e);
if (PlatformFilesystem.exists(m_szStreamName)) {
if (PlatformFileIO.exists(m_szStreamName)) {
found = true;
break;
}
@ -1194,7 +1201,7 @@ void SoundEngine::destroy() {}
#if defined(_DEBUG)
void SoundEngine::GetSoundName(char* szSoundName, int iSound) {
strcpy((char*)szSoundName, "Minecraft/");
std::string name = wchSoundNames[iSound];
std::wstring name = wchSoundNames[iSound];
char* SoundName = (char*)ConvertSoundPathToName(name);
strcat((char*)szSoundName, SoundName);
}
@ -1217,7 +1224,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
/* // if we are already playing loads of this sounds ignore this one
if(CurrentSoundsPlaying[iSound+eSFX_MAX]>MAX_SAME_SOUNDS_PLAYING)
{
// std::string name = wchSoundNames[iSound];
// std::wstring name = wchSoundNames[iSound];
// char *SoundName = (char *)ConvertSoundPathToName(name);
// app.DebugPrintf("Too many %s sounds playing!\n",SoundName);
return;
@ -1229,9 +1236,9 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
strcpy((char*)szSoundName, "Minecraft/");
#if defined(DISTORTION_TEST)
std::string name = wchSoundNames[eSoundType_MOB_ENDERDRAGON_GROWL];
std::wstring name = wchSoundNames[eSoundType_MOB_ENDERDRAGON_GROWL];
#else
std::string name = wchSoundNames[iSound];
std::wstring name = wchSoundNames[iSound];
#endif
char* SoundName = (char*)ConvertSoundPathToName(name);
@ -1265,7 +1272,7 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
/////////////////////////////////////////////
void SoundEngine::playUI(int iSound, float volume, float pitch) {
U8 szSoundName[256];
std::string name;
std::wstring name;
// we have some game sounds played as UI sounds...
// Not the best way to do this, but it seems to only be the portal sounds
@ -1324,7 +1331,7 @@ void SoundEngine::playUI(int iSound, float volume, float pitch) {
// playStreaming
//
/////////////////////////////////////////////
void SoundEngine::playStreaming(const std::string& name, float x, float y,
void SoundEngine::playStreaming(const std::wstring& name, float x, float y,
float z, float volume, float pitch,
bool bMusicDelay) {
// This function doesn't actually play a streaming sound, just sets states
@ -1455,15 +1462,15 @@ void SoundEngine::playMusicUpdate() {
m_MusicType = eMusicType_Game;
m_StreamingAudioInfo.bIs3D = false;
std::string& wstrSoundName =
std::wstring& wstrSoundName =
dlcAudioFile->GetSoundName(m_musicID);
char szName[255];
strncpy(szName, wstrSoundName.c_str(), 255);
wcstombs(szName, wstrSoundName.c_str(), 255);
std::string strFile =
"TPACK:\\Data\\" + string(szName) + ".binka";
std::string mountedPath =
PlatformStorage.GetMountedPath(strFile);
StorageManager.GetMountedPath(strFile);
strcpy(m_szStreamName, mountedPath.c_str());
} else {
SetIsPlayingStreamingGameMusic(false);
@ -1501,7 +1508,7 @@ void SoundEngine::playMusicUpdate() {
strcat((char*)m_szStreamName, ".binka");
}
// std::string name =
// std::wstring name =
// m_szStreamFileA[m_musicID];char*SoundName=(char
// *)ConvertSoundPathToName(name);strcat((char
// *)szStreamName,SoundName);
@ -1903,14 +1910,14 @@ float SoundEngine::getMasterMusicVolume() {
return m_MasterMusicVolume;
}
}
void SoundEngine::add(const std::string& name, File* file) {}
void SoundEngine::add(const std::wstring& name, File* file) {}
void SoundEngine::addMusic(const std::string& name, File* file) {}
void SoundEngine::addStreaming(const std::string& name, File* file) {}
void SoundEngine::addMusic(const std::wstring& name, File* file) {}
void SoundEngine::addStreaming(const std::wstring& name, File* file) {}
bool SoundEngine::isStreamingWavebankReady() { return true; }
// This is unused by the linux version, it'll need to be changed
char* SoundEngine::ConvertSoundPathToName(const std::string& name,
char* SoundEngine::ConvertSoundPathToName(const std::wstring& name,
bool bConvertSpaces) {
return nullptr;
}

View file

@ -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"
@ -105,7 +105,7 @@ public:
#endif
virtual void play(int iSound, float x, float y, float z, float volume,
float pitch);
virtual void playStreaming(const std::string& name, float x, float y,
virtual void playStreaming(const std::wstring& name, float x, float y,
float z, float volume, float pitch,
bool bMusicDelay = true);
virtual void playUI(int iSound, float volume, float pitch);
@ -117,14 +117,14 @@ public:
virtual void tick(std::shared_ptr<Mob>* players,
float a); // 4J - updated to take array of local players
// rather than single one
virtual void add(const std::string& name, File* file);
virtual void addMusic(const std::string& name, File* file);
virtual void addStreaming(const std::string& name, File* file);
virtual char* ConvertSoundPathToName(const std::string& name,
virtual void add(const std::wstring& name, File* file);
virtual void addMusic(const std::wstring& name, File* file);
virtual void addStreaming(const std::wstring& name, File* file);
virtual char* ConvertSoundPathToName(const std::wstring& name,
bool bConvertSpaces = false);
bool isStreamingWavebankReady(); // 4J Added
int getMusicID(int iDomain);
int getMusicID(const std::string& name);
int getMusicID(const std::wstring& name);
void SetStreamingSounds(int iOverworldMin, int iOverWorldMax,
int iNetherMin, int iNetherMax, int iEndMin,
int iEndMax, int iCD1);
@ -161,7 +161,7 @@ private:
int m_StreamState;
int m_MusicType;
AUDIO_INFO m_StreamingAudioInfo;
std::string m_CDMusic;
std::wstring m_CDMusic;
bool m_bSystemMusicPlaying;
float m_MasterMusicVolume;
float m_MasterEffectsVolume;

View file

@ -0,0 +1,228 @@
#include "Consoles_SoundEngine.h"
#include "minecraft/sounds/SoundTypes.h"
const wchar_t* ConsoleSoundEngine::wchSoundNames[eSoundType_MAX] = {
L"mob/chicken/chicken", // eSoundType_MOB_CHICKEN_AMBIENT
L"mob/chicken/chickenhurt", // eSoundType_MOB_CHICKEN_HURT
L"mob/chicken/chickenplop", // eSoundType_MOB_CHICKENPLOP
L"mob/cow/say", // eSoundType_MOB_COW_AMBIENT
L"mob/cow/hurt", // eSoundType_MOB_COW_HURT
L"mob/pig/pig", // eSoundType_MOB_PIG_AMBIENT
L"mob/pig/pigdeath", // eSoundType_MOB_PIG_DEATH
L"mob/sheep/sheep", // eSoundType_MOB_SHEEP_AMBIENT
L"mob/wolf/growl", // eSoundType_MOB_WOLF_GROWL
L"mob/wolf/whine", // eSoundType_MOB_WOLF_WHINE
L"mob/wolf/panting", // eSoundType_MOB_WOLF_PANTING
L"mob/wolf/bark", // eSoundType_MOB_WOLF_BARK
L"mob/wolf/hurt", // eSoundType_MOB_WOLF_HURT
L"mob/wolf/death", // eSoundType_MOB_WOLF_DEATH
L"mob/wolf/shake", // eSoundType_MOB_WOLF_SHAKE
L"mob/blaze/breathe", // eSoundType_MOB_BLAZE_BREATHE
L"mob/blaze/hit", // eSoundType_MOB_BLAZE_HURT
L"mob/blaze/death", // eSoundType_MOB_BLAZE_DEATH
L"mob/ghast/moan", // eSoundType_MOB_GHAST_MOAN
L"mob/ghast/scream", // eSoundType_MOB_GHAST_SCREAM
L"mob/ghast/death", // eSoundType_MOB_GHAST_DEATH
L"mob/ghast/fireball", // eSoundType_MOB_GHAST_FIREBALL
L"mob/ghast/charge", // eSoundType_MOB_GHAST_CHARGE
L"mob/endermen/idle", // eSoundType_MOB_ENDERMEN_IDLE
L"mob/endermen/hit", // eSoundType_MOB_ENDERMEN_HIT
L"mob/endermen/death", // eSoundType_MOB_ENDERMEN_DEATH
L"mob/endermen/portal", // eSoundType_MOB_ENDERMEN_PORTAL
L"mob/zombiepig/zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
L"mob/zombiepig/zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
L"mob/zombiepig/zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
L"mob/zombiepig/zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
L"mob/silverfish/say", // eSoundType_MOB_SILVERFISH_AMBIENT,
L"mob/silverfish/hit", // eSoundType_MOB_SILVERFISH_HURT
L"mob/silverfish/kill", // eSoundType_MOB_SILVERFISH_DEATH,
L"mob/silverfish/step", // eSoundType_MOB_SILVERFISH_STEP,
L"mob/skeleton/skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
L"mob/skeleton/skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
L"mob/spider/spider", // eSoundType_MOB_SPIDER_AMBIENT,
L"mob/spider/spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
L"mob/slime/slime", // eSoundType_MOB_SLIME,
L"mob/slime/slimeattack", // eSoundType_MOB_SLIME_ATTACK,
L"mob/creeper/creeper", // eSoundType_MOB_CREEPER_HURT,
L"mob/creeper/creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
L"mob/zombie/zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
L"mob/zombie/zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
L"mob/zombie/zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
L"mob/zombie/wood", // eSoundType_MOB_ZOMBIE_WOOD,
L"mob/zombie/woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
L"mob/zombie/metal", // eSoundType_MOB_ZOMBIE_METAL,
L"mob/magmacube/big", // eSoundType_MOB_MAGMACUBE_BIG,
L"mob/magmacube/small", // eSoundType_MOB_MAGMACUBE_SMALL,
L"mob/cat/purr", // eSoundType_MOB_CAT_PURR
L"mob/cat/purreow", // eSoundType_MOB_CAT_PURREOW
L"mob/cat/meow", // eSoundType_MOB_CAT_MEOW
// 4J-PB - correct the name of the event for hitting ocelots
L"mob/cat/hitt", // eSoundType_MOB_CAT_HITT
// L"mob.irongolem.throw", //
// eSoundType_MOB_IRONGOLEM_THROW L"mob.irongolem.hit",
//// eSoundType_MOB_IRONGOLEM_HIT L"mob.irongolem.death",
//// eSoundType_MOB_IRONGOLEM_DEATH L"mob.irongolem.walk",
//// eSoundType_MOB_IRONGOLEM_WALK
L"random/bow", // eSoundType_RANDOM_BOW,
L"random/bowhit", // eSoundType_RANDOM_BOW_HIT,
L"random/explode", // eSoundType_RANDOM_EXPLODE,
L"random/fizz", // eSoundType_RANDOM_FIZZ,
L"random/pop", // eSoundType_RANDOM_POP,
L"random/fuse", // eSoundType_RANDOM_FUSE,
L"random/drink", // eSoundType_RANDOM_DRINK,
L"random/eat", // eSoundType_RANDOM_EAT,
L"random/burp", // eSoundType_RANDOM_BURP,
L"random/splash", // eSoundType_RANDOM_SPLASH,
L"random/click", // eSoundType_RANDOM_CLICK,
L"random/glass", // eSoundType_RANDOM_GLASS,
L"random/orb", // eSoundType_RANDOM_ORB,
L"random/break", // eSoundType_RANDOM_BREAK,
L"random/chestopen", // eSoundType_RANDOM_CHEST_OPEN,
L"random/chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
L"random/door_open", // eSoundType_RANDOM_DOOR_OPEN,
L"random/door_close", // eSoundType_RANDOM_DOOR_CLOSE,
L"ambient/weather/rain", // eSoundType_AMBIENT_WEATHER_RAIN,
L"ambient/weather/thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
L"ambient/cave/cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
L"portal/portal", // eSoundType_PORTAL_PORTAL,
// 4J-PB - added a couple that were still using std::wstring
L"portal/trigger", // eSoundType_PORTAL_TRIGGER
L"portal/travel", // eSoundType_PORTAL_TRAVEL
L"fire/ignite", // eSoundType_FIRE_IGNITE,
L"fire/fire", // eSoundType_FIRE_FIRE,
L"damage/hit", // eSoundType_DAMAGE_HURT,
L"damage/fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
L"damage/fallbig", // eSoundType_DAMAGE_FALL_BIG,
L"note/harp", // eSoundType_NOTE_HARP,
L"note/bd", // eSoundType_NOTE_BD,
L"note/snare", // eSoundType_NOTE_SNARE,
L"note/hat", // eSoundType_NOTE_HAT,
L"note/bassattack", // eSoundType_NOTE_BASSATTACK,
L"tile/piston.in", // eSoundType_TILE_PISTON_IN,
L"tile/piston.out", // eSoundType_TILE_PISTON_OUT,
L"liquid/water", // eSoundType_LIQUID_WATER,
L"liquid/lavapop", // eSoundType_LIQUID_LAVA_POP,
L"liquid/lava", // eSoundType_LIQUID_LAVA,
L"step/stone", // eSoundType_STEP_STONE,
L"step/wood", // eSoundType_STEP_WOOD,
L"step/gravel", // eSoundType_STEP_GRAVEL,
L"step/grass", // eSoundType_STEP_GRASS,
L"step/metal", // eSoundType_STEP_METAL,
L"step/cloth", // eSoundType_STEP_CLOTH,
L"step/sand", // eSoundType_STEP_SAND,
// below this are the additional sounds from the second soundbank
L"mob/enderdragon/end", // eSoundType_MOB_ENDERDRAGON_END
L"mob/enderdragon/growl", // eSoundType_MOB_ENDERDRAGON_GROWL
L"mob/enderdragon/hit", // eSoundType_MOB_ENDERDRAGON_HIT
L"mob/enderdragon/wings", // eSoundType_MOB_ENDERDRAGON_MOVE
L"mob/irongolem/throw", // eSoundType_MOB_IRONGOLEM_THROW
L"mob/irongolem/hit", // eSoundType_MOB_IRONGOLEM_HIT
L"mob/irongolem/death", // eSoundType_MOB_IRONGOLEM_DEATH
L"mob/irongolem/walk", // eSoundType_MOB_IRONGOLEM_WALK
// TU14
L"damage/thorns", // eSoundType_DAMAGE_THORNS
L"random/anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
L"random/anvil_land", // eSoundType_RANDOM_ANVIL_LAND
L"random/anvil_use", // eSoundType_RANDOM_ANVIL_USE
L"mob/villager/haggle", // eSoundType_MOB_VILLAGER_HAGGLE
L"mob/villager/idle", // eSoundType_MOB_VILLAGER_IDLE
L"mob/villager/hit", // eSoundType_MOB_VILLAGER_HIT
L"mob/villager/death", // eSoundType_MOB_VILLAGER_DEATH
L"mob/villager/yes", // eSoundType_MOB_VILLAGER_YES
L"mob/villager/no", // eSoundType_MOB_VILLAGER_NO
L"mob/zombie/infect", // eSoundType_MOB_ZOMBIE_INFECT
L"mob/zombie/unfect", // eSoundType_MOB_ZOMBIE_UNFECT
L"mob/zombie/remedy", // eSoundType_MOB_ZOMBIE_REMEDY
L"step/snow", // eSoundType_STEP_SNOW
L"step/ladder", // eSoundType_STEP_LADDER
L"dig/cloth", // eSoundType_DIG_CLOTH
L"dig/grass", // eSoundType_DIG_GRASS
L"dig/gravel", // eSoundType_DIG_GRAVEL
L"dig/sand", // eSoundType_DIG_SAND
L"dig/snow", // eSoundType_DIG_SNOW
L"dig/stone", // eSoundType_DIG_STONE
L"dig/wood", // eSoundType_DIG_WOOD
// 1.6.4
L"fireworks/launch", // eSoundType_FIREWORKS_LAUNCH,
L"fireworks/blast", // eSoundType_FIREWORKS_BLAST,
L"fireworks/blast_far", // eSoundType_FIREWORKS_BLAST_FAR,
L"fireworks/large_blast", // eSoundType_FIREWORKS_LARGE_BLAST,
L"fireworks/large_blast_far", // eSoundType_FIREWORKS_LARGE_BLAST_FAR,
L"fireworks/twinkle", // eSoundType_FIREWORKS_TWINKLE,
L"fireworks/twinkle_far", // eSoundType_FIREWORKS_TWINKLE_FAR,
L"mob/bat/idle", // eSoundType_MOB_BAT_IDLE,
L"mob/bat/hurt", // eSoundType_MOB_BAT_HURT,
L"mob/bat/death", // eSoundType_MOB_BAT_DEATH,
L"mob/bat/takeoff", // eSoundType_MOB_BAT_TAKEOFF,
L"mob/wither/spawn", // eSoundType_MOB_WITHER_SPAWN,
L"mob/wither/idle", // eSoundType_MOB_WITHER_IDLE,
L"mob/wither/hurt", // eSoundType_MOB_WITHER_HURT,
L"mob/wither/death", // eSoundType_MOB_WITHER_DEATH,
L"mob/wither/shoot", // eSoundType_MOB_WITHER_SHOOT,
L"mob/cow/step", // eSoundType_MOB_COW_STEP,
L"mob/chicken/step", // eSoundType_MOB_CHICKEN_STEP,
L"mob/pig/step", // eSoundType_MOB_PIG_STEP,
L"mob/enderman/stare", // eSoundType_MOB_ENDERMAN_STARE,
L"mob/enderman/scream", // eSoundType_MOB_ENDERMAN_SCREAM,
L"mob/sheep/shear", // eSoundType_MOB_SHEEP_SHEAR,
L"mob/sheep/step", // eSoundType_MOB_SHEEP_STEP,
L"mob/skeleton.death", // eSoundType_MOB_SKELETON_DEATH,
L"mob/skeleton/step", // eSoundType_MOB_SKELETON_STEP,
L"mob/spider/step", // eSoundType_MOB_SPIDER_STEP,
L"mob/wolf/step", // eSoundType_MOB_WOLF_STEP,
L"mob/zombie/step", // eSoundType_MOB_ZOMBIE_STEP,
L"liquid/swim", // eSoundType_LIQUID_SWIM,
L"mob/horse/land", // eSoundType_MOB_HORSE_LAND,
L"mob/horse/armor", // eSoundType_MOB_HORSE_ARMOR,
L"mob/horse/leather", // eSoundType_MOB_HORSE_LEATHER,
L"mob/horse/zombie.death", // eSoundType_MOB_HORSE_ZOMBIE_DEATH,
L"mob/horse/skeleton.death", // eSoundType_MOB_HORSE_SKELETON_DEATH,
L"mob/horse/donkey.death", // eSoundType_MOB_HORSE_DONKEY_DEATH,
L"mob/horse/death", // eSoundType_MOB_HORSE_DEATH,
L"mob/horse/zombie.hit", // eSoundType_MOB_HORSE_ZOMBIE_HIT,
L"mob/horse/skeleton.hit", // eSoundType_MOB_HORSE_SKELETON_HIT,
L"mob/horse/donkey.hit", // eSoundType_MOB_HORSE_DONKEY_HIT,
L"mob/horse/hit", // eSoundType_MOB_HORSE_HIT,
L"mob/horse/zombie.idle", // eSoundType_MOB_HORSE_ZOMBIE_IDLE,
L"mob/horse/skeleton.idle", // eSoundType_MOB_HORSE_SKELETON_IDLE,
L"mob/horse/donkey.idle", // eSoundType_MOB_HORSE_DONKEY_IDLE,
L"mob/horse/idle", // eSoundType_MOB_HORSE_IDLE,
L"mob/horse/donkey.angry", // eSoundType_MOB_HORSE_DONKEY_ANGRY,
L"mob/horse/angry", // eSoundType_MOB_HORSE_ANGRY,
L"mob/horse/gallop", // eSoundType_MOB_HORSE_GALLOP,
L"mob/horse/breathe", // eSoundType_MOB_HORSE_BREATHE,
L"mob/horse/wood", // eSoundType_MOB_HORSE_WOOD,
L"mob/horse/soft", // eSoundType_MOB_HORSE_SOFT,
L"mob/horse/jump", // eSoundType_MOB_HORSE_JUMP,
L"mob/witch/idle", // eSoundType_MOB_WITCH_IDLE, <---
// missing
L"mob/witch/hurt", // eSoundType_MOB_WITCH_HURT, <---
// missing
L"mob/witch/death", // eSoundType_MOB_WITCH_DEATH, <---
// missing
L"mob/slime/big", // eSoundType_MOB_SLIME_BIG,
L"mob/slime/small", // eSoundType_MOB_SLIME_SMALL,
L"eating", // eSoundType_EATING <--- missing
L"random/levelup", // eSoundType_RANDOM_LEVELUP
// 4J-PB - Some sounds were updated, but we can't do that for the 360 or we
// have to do a new sound bank instead, we'll add the sounds as new ones and
// change the code to reference them
L"fire/new_ignite",
};
const wchar_t* ConsoleSoundEngine::wchUISoundNames[eSFX_MAX] = {
L"back", L"craft", L"craftfail", L"focus", L"press", L"scroll",
};

View file

@ -14,7 +14,7 @@
#define VER_FILEVERSION_STRING "1.6"
#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING
#define VER_FILEVERSION_STRING_W "1.6"
#define VER_FILEVERSION_STRING_W L"1.6"
#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W
#define VER_FILEBETA_STR ""
#undef VER_FILEVERSION
@ -27,25 +27,25 @@
#if (VER_PRODUCTBUILD < 10)
#define VER_FILEBPAD "000"
#define VER_FILEBPAD_W "000"
#define VER_FILEBPAD_W L"000"
#elif (VER_PRODUCTBUILD < 100)
#define VER_FILEBPAD "00"
#define VER_FILEBPAD_W "00"
#define VER_FILEBPAD_W L"00"
#elif (VER_PRODUCTBUILD < 1000)
#define VER_FILEBPAD "0"
#define VER_FILEBPAD_W "0"
#define VER_FILEBPAD_W L"0"
#else
#define VER_FILEBPAD
#define VER_FILEBPAD_W
#endif
#define VER_WIDE_PREFIX(x) x
#define VER_WIDE_PREFIX(x) L##x
#define VER_FILEVERSION_STR2(x, y) \
VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y
#define VER_FILEVERSION_STR2_W(x, y) \
VER_FILEVERSION_STRING_W "." VER_FILEBPAD_W VER_WIDE_PREFIX( \
#x) "." VER_WIDE_PREFIX(#y)
VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX( \
#x) L"." VER_WIDE_PREFIX(#y)
#define VER_FILEVERSION_STR1(x, y) VER_FILEVERSION_STR2(x, y)
#define VER_FILEVERSION_STR1_W(x, y) VER_FILEVERSION_STR2_W(x, y)

View file

@ -0,0 +1,385 @@
#include "ColourTable.h"
#include <cstring>
#include <utility>
#include <vector>
#include "app/common/App_enums.h"
#include "util/StringHelpers.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
#include "java/InputOutputStream/DataInputStream.h"
std::unordered_map<std::wstring, eMinecraftColour>
ColourTable::s_colourNamesMap;
const wchar_t* ColourTable::ColourTableElements[eMinecraftColour_COUNT] = {
L"NOTSET",
L"Foliage_Evergreen",
L"Foliage_Birch",
L"Foliage_Default",
L"Foliage_Common",
L"Foliage_Ocean",
L"Foliage_Plains",
L"Foliage_Desert",
L"Foliage_ExtremeHills",
L"Foliage_Forest",
L"Foliage_Taiga",
L"Foliage_Swampland",
L"Foliage_River",
L"Foliage_Hell",
L"Foliage_Sky",
L"Foliage_FrozenOcean",
L"Foliage_FrozenRiver",
L"Foliage_IcePlains",
L"Foliage_IceMountains",
L"Foliage_MushroomIsland",
L"Foliage_MushroomIslandShore",
L"Foliage_Beach",
L"Foliage_DesertHills",
L"Foliage_ForestHills",
L"Foliage_TaigaHills",
L"Foliage_ExtremeHillsEdge",
L"Foliage_Jungle",
L"Foliage_JungleHills",
L"Grass_Common",
L"Grass_Ocean",
L"Grass_Plains",
L"Grass_Desert",
L"Grass_ExtremeHills",
L"Grass_Forest",
L"Grass_Taiga",
L"Grass_Swampland",
L"Grass_River",
L"Grass_Hell",
L"Grass_Sky",
L"Grass_FrozenOcean",
L"Grass_FrozenRiver",
L"Grass_IcePlains",
L"Grass_IceMountains",
L"Grass_MushroomIsland",
L"Grass_MushroomIslandShore",
L"Grass_Beach",
L"Grass_DesertHills",
L"Grass_ForestHills",
L"Grass_TaigaHills",
L"Grass_ExtremeHillsEdge",
L"Grass_Jungle",
L"Grass_JungleHills",
L"Water_Ocean",
L"Water_Plains",
L"Water_Desert",
L"Water_ExtremeHills",
L"Water_Forest",
L"Water_Taiga",
L"Water_Swampland",
L"Water_River",
L"Water_Hell",
L"Water_Sky",
L"Water_FrozenOcean",
L"Water_FrozenRiver",
L"Water_IcePlains",
L"Water_IceMountains",
L"Water_MushroomIsland",
L"Water_MushroomIslandShore",
L"Water_Beach",
L"Water_DesertHills",
L"Water_ForestHills",
L"Water_TaigaHills",
L"Water_ExtremeHillsEdge",
L"Water_Jungle",
L"Water_JungleHills",
L"Sky_Ocean",
L"Sky_Plains",
L"Sky_Desert",
L"Sky_ExtremeHills",
L"Sky_Forest",
L"Sky_Taiga",
L"Sky_Swampland",
L"Sky_River",
L"Sky_Hell",
L"Sky_Sky",
L"Sky_FrozenOcean",
L"Sky_FrozenRiver",
L"Sky_IcePlains",
L"Sky_IceMountains",
L"Sky_MushroomIsland",
L"Sky_MushroomIslandShore",
L"Sky_Beach",
L"Sky_DesertHills",
L"Sky_ForestHills",
L"Sky_TaigaHills",
L"Sky_ExtremeHillsEdge",
L"Sky_Jungle",
L"Sky_JungleHills",
L"Tile_RedstoneDust",
L"Tile_RedstoneDustUnlit",
L"Tile_RedstoneDustLitMin",
L"Tile_RedstoneDustLitMax",
L"Tile_StemMin",
L"Tile_StemMax",
L"Tile_WaterLily",
L"Sky_Dawn_Dark",
L"Sky_Dawn_Bright",
L"Material_None",
L"Material_Grass",
L"Material_Sand",
L"Material_Cloth",
L"Material_Fire",
L"Material_Ice",
L"Material_Metal",
L"Material_Plant",
L"Material_Snow",
L"Material_Clay",
L"Material_Dirt",
L"Material_Stone",
L"Material_Water",
L"Material_Wood",
L"Material_Emerald",
L"Particle_Note_00",
L"Particle_Note_01",
L"Particle_Note_02",
L"Particle_Note_03",
L"Particle_Note_04",
L"Particle_Note_05",
L"Particle_Note_06",
L"Particle_Note_07",
L"Particle_Note_08",
L"Particle_Note_09",
L"Particle_Note_10",
L"Particle_Note_11",
L"Particle_Note_12",
L"Particle_Note_13",
L"Particle_Note_14",
L"Particle_Note_15",
L"Particle_Note_16",
L"Particle_Note_17",
L"Particle_Note_18",
L"Particle_Note_19",
L"Particle_Note_20",
L"Particle_Note_21",
L"Particle_Note_22",
L"Particle_Note_23",
L"Particle_Note_24",
L"Particle_NetherPortal",
L"Particle_EnderPortal",
L"Particle_Smoke",
L"Particle_Ender",
L"Particle_Explode",
L"Particle_HugeExplosion",
L"Particle_DripWater",
L"Particle_DripLavaStart",
L"Particle_DripLavaEnd",
L"Particle_EnchantmentTable",
L"Particle_DragonBreathMin",
L"Particle_DragonBreathMax",
L"Particle_Suspend",
L"Particle_CritStart", // arrow in air
L"Particle_CritEnd", // arrow in air
L"Effect_MovementSpeed",
L"Effect_MovementSlowDown",
L"Effect_DigSpeed",
L"Effect_DigSlowdown",
L"Effect_DamageBoost",
L"Effect_Heal",
L"Effect_Harm",
L"Effect_Jump",
L"Effect_Confusion",
L"Effect_Regeneration",
L"Effect_DamageResistance",
L"Effect_FireResistance",
L"Effect_WaterBreathing",
L"Effect_Invisiblity",
L"Effect_Blindness",
L"Effect_NightVision",
L"Effect_Hunger",
L"Effect_Weakness",
L"Effect_Poison",
L"Effect_Wither",
L"Effect_HealthBoost",
L"Effect_Absorption",
L"Effect_Saturation",
L"Potion_BaseColour",
L"Mob_Creeper_Colour1",
L"Mob_Creeper_Colour2",
L"Mob_Skeleton_Colour1",
L"Mob_Skeleton_Colour2",
L"Mob_Spider_Colour1",
L"Mob_Spider_Colour2",
L"Mob_Zombie_Colour1",
L"Mob_Zombie_Colour2",
L"Mob_Slime_Colour1",
L"Mob_Slime_Colour2",
L"Mob_Ghast_Colour1",
L"Mob_Ghast_Colour2",
L"Mob_PigZombie_Colour1",
L"Mob_PigZombie_Colour2",
L"Mob_Enderman_Colour1",
L"Mob_Enderman_Colour2",
L"Mob_CaveSpider_Colour1",
L"Mob_CaveSpider_Colour2",
L"Mob_Silverfish_Colour1",
L"Mob_Silverfish_Colour2",
L"Mob_Blaze_Colour1",
L"Mob_Blaze_Colour2",
L"Mob_LavaSlime_Colour1",
L"Mob_LavaSlime_Colour2",
L"Mob_Pig_Colour1",
L"Mob_Pig_Colour2",
L"Mob_Sheep_Colour1",
L"Mob_Sheep_Colour2",
L"Mob_Cow_Colour1",
L"Mob_Cow_Colour2",
L"Mob_Chicken_Colour1",
L"Mob_Chicken_Colour2",
L"Mob_Squid_Colour1",
L"Mob_Squid_Colour2",
L"Mob_Wolf_Colour1",
L"Mob_Wolf_Colour2",
L"Mob_MushroomCow_Colour1",
L"Mob_MushroomCow_Colour2",
L"Mob_Ocelot_Colour1",
L"Mob_Ocelot_Colour2",
L"Mob_Villager_Colour1",
L"Mob_Villager_Colour2",
L"Mob_Bat_Colour1",
L"Mob_Bat_Colour2",
L"Mob_Witch_Colour1",
L"Mob_Witch_Colour2",
L"Mob_Horse_Colour1",
L"Mob_Horse_Colour2",
L"Armour_Default_Leather_Colour",
L"Under_Water_Clear_Colour",
L"Under_Lava_Clear_Colour",
L"In_Cloud_Base_Colour",
L"Under_Water_Fog_Colour",
L"Under_Lava_Fog_Colour",
L"In_Cloud_Fog_Colour",
L"Default_Fog_Colour",
L"Nether_Fog_Colour",
L"End_Fog_Colour",
L"Sign_Text",
L"Map_Text",
L"Leash_Light_Colour",
L"Leash_Dark_Colour",
L"Fire_Overlay",
L"HTMLColor_0",
L"HTMLColor_1",
L"HTMLColor_2",
L"HTMLColor_3",
L"HTMLColor_4",
L"HTMLColor_5",
L"HTMLColor_6",
L"HTMLColor_7",
L"HTMLColor_8",
L"HTMLColor_9",
L"HTMLColor_a",
L"HTMLColor_b",
L"HTMLColor_c",
L"HTMLColor_d",
L"HTMLColor_e",
L"HTMLColor_f",
L"HTMLColor_dark_0",
L"HTMLColor_dark_1",
L"HTMLColor_dark_2",
L"HTMLColor_dark_3",
L"HTMLColor_dark_4",
L"HTMLColor_dark_5",
L"HTMLColor_dark_6",
L"HTMLColor_dark_7",
L"HTMLColor_dark_8",
L"HTMLColor_dark_9",
L"HTMLColor_dark_a",
L"HTMLColor_dark_b",
L"HTMLColor_dark_c",
L"HTMLColor_dark_d",
L"HTMLColor_dark_e",
L"HTMLColor_dark_f",
L"HTMLColor_T1",
L"HTMLColor_T2",
L"HTMLColor_T3",
L"HTMLColor_Black",
L"HTMLColor_White",
L"Color_EnchantText",
L"Color_EnchantTextFocus",
L"Color_EnchantTextDisabled",
L"Color_RenamedItemTitle",
};
void ColourTable::staticCtor() {
for (unsigned int i = eMinecraftColour_NOT_SET; i < eMinecraftColour_COUNT;
++i) {
s_colourNamesMap.insert(
std::unordered_map<std::wstring, eMinecraftColour>::value_type(
ColourTableElements[i], (eMinecraftColour)i));
}
}
ColourTable::ColourTable(std::uint8_t* pbData, std::uint32_t dataLength) {
loadColoursFromData(pbData, dataLength);
}
ColourTable::ColourTable(ColourTable* defaultColours, std::uint8_t* pbData,
std::uint32_t dataLength) {
// 4J Stu - Default the colours that of the table passed in
memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues,
sizeof(int) * eMinecraftColour_COUNT);
loadColoursFromData(pbData, dataLength);
}
void ColourTable::loadColoursFromData(std::uint8_t* pbData,
std::uint32_t dataLength) {
std::vector<uint8_t> src(pbData, pbData + dataLength);
ByteArrayInputStream bais(src);
DataInputStream dis(&bais);
int versionNumber = dis.readInt();
int coloursCount = dis.readInt();
for (int i = 0; i < coloursCount; ++i) {
std::wstring colourId = dis.readUTF();
int colourValue = dis.readInt();
setColour(colourId, colourValue);
auto it = s_colourNamesMap.find(colourId);
}
bais.reset();
}
void ColourTable::setColour(const std::wstring& colourName, int value) {
auto it = s_colourNamesMap.find(colourName);
if (it != s_colourNamesMap.end()) {
m_colourValues[(int)it->second] = value;
}
}
void ColourTable::setColour(const std::wstring& colourName,
const std::wstring& value) {
setColour(colourName, fromHexWString<int>(value));
}
unsigned int ColourTable::getColour(eMinecraftColour id) {
return m_colourValues[(int)id];
}

View file

@ -3,14 +3,14 @@
#include <string>
#include <unordered_map>
#include "minecraft/GameEnums.h"
#include "app/common/App_enums.h"
class ColourTable {
private:
unsigned int m_colourValues[eMinecraftColour_COUNT];
static const char* ColourTableElements[eMinecraftColour_COUNT];
static std::unordered_map<std::string, eMinecraftColour> s_colourNamesMap;
static const wchar_t* ColourTableElements[eMinecraftColour_COUNT];
static std::unordered_map<std::wstring, eMinecraftColour> s_colourNamesMap;
public:
static void staticCtor();
@ -23,6 +23,6 @@ public:
unsigned int getColor(eMinecraftColour id) { return getColour(id); }
void loadColoursFromData(std::uint8_t* pbData, std::uint32_t dataLength);
void setColour(const std::string& colourName, int value);
void setColour(const std::string& colourName, const std::string& value);
void setColour(const std::wstring& colourName, int value);
void setColour(const std::wstring& colourName, const std::wstring& value);
};

View file

@ -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;

View file

@ -1,5 +1,5 @@
#pragma once
#include "app/common/Tutorial/TutorialMode.h"
#include "app/common/src/Tutorial/TutorialMode.h"
class ClientConnection;
class Minecraft;

View file

@ -5,14 +5,12 @@
#include <cstring>
#include <unordered_map>
#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 "platform/renderer/renderer.h"
#include "platform/storage/storage.h"
#include "util/StringHelpers.h"
#include "app/include/XboxStubs.h"
#if defined(_WINDOWS64)
#include "app/windows/XML/ATGXmlParser.h"
#include "app/windows/XML/xmlFilesCallback.h"
@ -21,6 +19,26 @@
namespace {
constexpr std::size_t AUDIO_DLC_WCHAR_BIN_SIZE = 2;
#if WCHAR_MAX > 0xFFFF
static std::wstring ReadAudioDlcWString(const void* data) {
const std::uint16_t* chars = static_cast<const std::uint16_t*>(data);
const std::uint16_t* end = chars;
while (*end != 0) {
++end;
}
std::wstring out(static_cast<std::size_t>(end - chars), 0);
for (std::size_t i = 0; i < out.size(); ++i) {
out[i] = static_cast<wchar_t>(chars[i]);
}
return out;
}
#else
static std::wstring ReadAudioDlcWString(const void* data) {
return std::wstring(static_cast<const wchar_t*>(data));
}
#endif
template <typename T>
T ReadAudioDlcValue(const std::uint8_t* data, unsigned int offset = 0) {
T value;
@ -35,24 +53,23 @@ void ReadAudioDlcStruct(T* out, const std::uint8_t* data,
}
inline unsigned int AudioParamAdvance(unsigned int wcharCount) {
return static_cast<unsigned int>(sizeof(IPlatformStorage::DLC_FILE_PARAM) +
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_PARAM) +
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
inline unsigned int AudioDetailAdvance(unsigned int wcharCount) {
return static_cast<unsigned int>(
sizeof(IPlatformStorage::DLC_FILE_DETAILS) +
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
return static_cast<unsigned int>(sizeof(C4JStorage::DLC_FILE_DETAILS) +
wcharCount * AUDIO_DLC_WCHAR_BIN_SIZE);
}
inline std::string ReadAudioParamString(const std::uint8_t* data,
unsigned int offset) {
return dlc_read_wstring(
data + offset + offsetof(IPlatformStorage::DLC_FILE_PARAM, wchData));
inline std::wstring ReadAudioParamString(const std::uint8_t* data,
unsigned int offset) {
return ReadAudioDlcWString(data + offset +
offsetof(C4JStorage::DLC_FILE_PARAM, wchData));
}
} // namespace
DLCAudioFile::DLCAudioFile(const std::string& path)
DLCAudioFile::DLCAudioFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Audio, path) {
m_pbData = nullptr;
m_dataBytes = 0;
@ -70,13 +87,13 @@ std::uint8_t* DLCAudioFile::getData(std::uint32_t& dataBytes) {
return m_pbData;
}
const char* DLCAudioFile::wchTypeNamesA[] = {
"CUENAME",
"CREDIT",
const wchar_t* DLCAudioFile::wchTypeNamesA[] = {
L"CUENAME",
L"CREDIT",
};
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
const std::string& paramName) {
const std::wstring& paramName) {
EAudioParameterType type = e_AudioParamType_Invalid;
for (int i = 0; i < e_AudioParamType_Max; ++i) {
@ -90,7 +107,7 @@ DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(
}
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
const std::string& value) {
const std::wstring& value) {
switch (ptype) {
case e_AudioParamType_Credit: // If this parameter exists, then mark
// this as free
@ -105,8 +122,8 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
int maximumChars = 55;
bool bIsSDMode = !PlatformRenderer.IsHiDef() &&
!PlatformRenderer.IsWidescreen();
bool bIsSDMode =
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if (bIsSDMode) {
maximumChars = 45;
@ -119,14 +136,14 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
maximumChars = 35;
break;
}
std::string creditValue = value;
std::wstring creditValue = value;
while (creditValue.length() > maximumChars) {
unsigned int i = 1;
while (i < creditValue.length() &&
(i + 1) <= maximumChars) {
i++;
}
int iLast = (int)creditValue.find_last_of(" ", i);
int iLast = (int)creditValue.find_last_of(L" ", i);
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
@ -134,7 +151,7 @@ void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype,
iLast = maximumChars;
break;
default:
iLast = (int)creditValue.find_last_of(" ", i);
iLast = (int)creditValue.find_last_of(L" ", i);
break;
}
@ -179,13 +196,14 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
unsigned int uiParameterTypeCount =
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_PARAM paramBuf;
C4JStorage::DLC_FILE_PARAM paramBuf;
ReadAudioDlcStruct(&paramBuf, pbData, uiCurrentByte);
for (unsigned int i = 0; i < uiParameterTypeCount; i++) {
// Map DLC strings to application strings, then store the DLC index
// mapping to application index
std::string parameterName = ReadAudioParamString(pbData, uiCurrentByte);
std::wstring parameterName =
ReadAudioParamString(pbData, uiCurrentByte);
EAudioParameterType type = getParameterType(parameterName);
if (type != e_AudioParamType_Invalid) {
parameterMapping[paramBuf.dwType] = type;
@ -196,7 +214,7 @@ bool DLCAudioFile::processDLCDataFile(std::uint8_t* pbData,
unsigned int uiFileCount =
ReadAudioDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
C4JStorage::DLC_FILE_DETAILS fileBuf;
ReadAudioDlcStruct(&fileBuf, pbData, uiCurrentByte);
unsigned int tempByteOffset = uiCurrentByte;
@ -239,7 +257,7 @@ int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType) {
return m_parameters[eType].size();
}
std::string& DLCAudioFile::GetSoundName(int iIndex) {
std::wstring& DLCAudioFile::GetSoundName(int iIndex) {
int iWorldType = e_AudioType_Overworld;
while (iIndex >= m_parameters[iWorldType].size()) {
iIndex -= m_parameters[iWorldType].size();

View file

@ -27,16 +27,16 @@ public:
e_AudioParamType_Max,
};
static const char* wchTypeNamesA[e_AudioParamType_Max];
static const wchar_t* wchTypeNamesA[e_AudioParamType_Max];
DLCAudioFile(const std::string& path);
DLCAudioFile(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
bool processDLCDataFile(std::uint8_t* pbData, std::uint32_t dataLength);
int GetCountofType(DLCAudioFile::EAudioType ptype);
std::string& GetSoundName(int iIndex);
std::wstring& GetSoundName(int iIndex);
private:
using DLCFile::addParameter;
@ -44,13 +44,13 @@ private:
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
static const int CURRENT_AUDIO_VERSION_NUM = 1;
// std::unordered_map<int, std::string> m_parameters;
std::vector<std::string> m_parameters[e_AudioType_Max];
// std::unordered_map<int, std::wstring> m_parameters;
std::vector<std::wstring> m_parameters[e_AudioType_Max];
// use the EAudioType to order these
void addParameter(DLCAudioFile::EAudioType type,
DLCAudioFile::EAudioParameterType ptype,
const std::string& value);
const std::wstring& value);
DLCAudioFile::EAudioParameterType getParameterType(
const std::string& paramName);
const std::wstring& paramName);
};

View file

@ -1,10 +1,10 @@
#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::string& path)
DLCCapeFile::DLCCapeFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Cape, path) {}
void DLCCapeFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {

View file

@ -6,7 +6,7 @@
class DLCCapeFile : public DLCFile {
public:
DLCCapeFile(const std::string& path);
DLCCapeFile(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
};

View file

@ -1,14 +1,14 @@
#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"
#include "minecraft/client/skins/TexturePackRepository.h"
DLCColourTableFile::DLCColourTableFile(const std::string& path)
DLCColourTableFile::DLCColourTableFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_ColourTable, path) {
m_colourTable = nullptr;
}

View file

@ -11,7 +11,7 @@ private:
ColourTable* m_colourTable;
public:
DLCColourTableFile(const std::string& path);
DLCColourTableFile(const std::wstring& path);
~DLCColourTableFile();
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);

View file

@ -3,19 +3,19 @@
#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::string& path) {
DLCFile::DLCFile(DLCManager::EDLCType type, const std::wstring& path) {
m_type = type;
m_path = path;
// store the id
bool dlcSkin = path.substr(0, 3).compare("dlc") == 0;
bool dlcSkin = path.substr(0, 3).compare(L"dlc") == 0;
if (dlcSkin) {
std::string skinValue = path.substr(7, path.size());
skinValue = skinValue.substr(0, skinValue.find_first_of('.'));
std::stringstream ss;
std::wstring skinValue = path.substr(7, path.size());
skinValue = skinValue.substr(0, skinValue.find_first_of(L'.'));
std::wstringstream ss;
ss << std::dec << skinValue.c_str();
ss >> m_dwSkinId;
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);

View file

@ -7,15 +7,15 @@
class DLCFile {
protected:
DLCManager::EDLCType m_type;
std::string m_path;
std::wstring m_path;
std::uint32_t m_dwSkinId;
public:
DLCFile(DLCManager::EDLCType type, const std::string& path);
DLCFile(DLCManager::EDLCType type, const std::wstring& path);
virtual ~DLCFile() {}
DLCManager::EDLCType getType() { return m_type; }
std::string getPath() { return m_path; }
std::wstring getPath() { return m_path; }
std::uint32_t getSkinID() { return m_dwSkinId; }
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes) {}
@ -24,11 +24,11 @@ public:
return nullptr;
}
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::string& value) {}
const std::wstring& value) {}
virtual std::string getParameterAsString(
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type) {
return "";
return L"";
}
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) {
return false;

View file

@ -0,0 +1,10 @@
#pragma once
#include "DLCFile.h"
#include "app/common/src/GameRules/LevelGeneration/LevelGenerationOptions.h"
class DLCGameRules : public DLCFile {
public:
DLCGameRules(DLCManager::EDLCType type, const std::wstring& path)
: DLCFile(type, path) {}
};

View file

@ -1,9 +1,9 @@
#include "DLCGameRulesFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCGameRules.h"
#include "app/common/src/DLC/DLCGameRules.h"
DLCGameRulesFile::DLCGameRulesFile(const std::string& path)
DLCGameRulesFile::DLCGameRulesFile(const std::wstring& path)
: DLCGameRules(DLCManager::e_DLCType_GameRules, path) {
m_pbData = nullptr;
m_dataBytes = 0;

View file

@ -10,7 +10,7 @@ private:
std::uint32_t m_dataBytes;
public:
DLCGameRulesFile(const std::string& path);
DLCGameRulesFile(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);

View file

@ -3,20 +3,20 @@
#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;
DLCGameRulesHeader::DLCGameRulesHeader(const std::string& path)
DLCGameRulesHeader::DLCGameRulesHeader(const std::wstring& path)
: DLCGameRules(DLCManager::e_DLCType_GameRulesHeader, path) {
m_pbData = nullptr;
m_dataBytes = 0;
m_hasData = false;
m_grfPath = path.substr(0, path.length() - 4) + ".grf";
m_grfPath = path.substr(0, path.length() - 4) + L".grf";
lgo = nullptr;
}

View file

@ -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;
@ -21,26 +21,26 @@ public:
virtual std::uint32_t getRequiredTexturePackId() {
return m_requiredTexturePackId;
}
virtual std::string getDefaultSaveName() { return m_defaultSaveName; }
virtual const char* getWorldName() { return m_worldName.c_str(); }
virtual const char* getDisplayName() { return m_displayName.c_str(); }
virtual std::string getGrfPath() { return "GameRules.grf"; }
virtual std::wstring getDefaultSaveName() { return m_defaultSaveName; }
virtual const wchar_t* getWorldName() { return m_worldName.c_str(); }
virtual const wchar_t* getDisplayName() { return m_displayName.c_str(); }
virtual std::wstring getGrfPath() { return L"GameRules.grf"; }
virtual void setRequiresTexturePack(bool x) { m_bRequiresTexturePack = x; }
virtual void setRequiredTexturePackId(std::uint32_t x) {
m_requiredTexturePackId = x;
}
virtual void setDefaultSaveName(const std::string& x) {
virtual void setDefaultSaveName(const std::wstring& x) {
m_defaultSaveName = x;
}
virtual void setWorldName(const std::string& x) { m_worldName = x; }
virtual void setDisplayName(const std::string& x) { m_displayName = x; }
virtual void setGrfPath(const std::string& x) { m_grfPath = x; }
virtual void setWorldName(const std::wstring& x) { m_worldName = x; }
virtual void setDisplayName(const std::wstring& x) { m_displayName = x; }
virtual void setGrfPath(const std::wstring& x) { m_grfPath = x; }
LevelGenerationOptions* lgo;
public:
DLCGameRulesHeader(const std::string& path);
DLCGameRulesHeader(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);

View file

@ -1,10 +1,10 @@
#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::string& path)
DLCLocalisationFile::DLCLocalisationFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_LocalisationData, path) {
m_strings = nullptr;
}

View file

@ -11,7 +11,7 @@ private:
StringTable* m_strings;
public:
DLCLocalisationFile(const std::string& path);
DLCLocalisationFile(const std::wstring& path);
DLCLocalisationFile(
std::uint8_t* pbData,
std::uint32_t dataBytes); // when we load in a texture pack details

View file

@ -13,16 +13,14 @@
#include <unordered_map>
#include <utility>
#include "simdutf.h"
#include "platform/profile/profile.h"
#include "platform/storage/storage.h"
#include "platform/sdl2/Profile.h"
#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/fs/fs.h"
#include "platform/PlatformServices.h"
#include "util/StringHelpers.h"
#include "minecraft/client/Minecraft.h"
#include "minecraft/client/skins/TexturePackRepository.h"
@ -32,27 +30,48 @@
// the DLC was created on windows, with wchar_t beeing 2 bytes and UTF-16
static const std::size_t DLC_WCHAR_BIN_SIZE = 2;
std::string dlc_read_wstring(const void* data) {
const char16_t* chars = static_cast<const char16_t*>(data);
const char16_t* end = chars;
while (*end != 0) {
#if WCHAR_MAX > 0xFFFF
// than sizeof(wchar_t) != DLC_WCHAR_BIN_SIZE
// e.g. Linux and all Posix/Unix systems with wchar_t beeing 4B/32bit
static_assert(sizeof(wchar_t) == 4,
"wchar_t is not 4bytes but larger than 2bytes ???");
static inline std::wstring dlc_read_wstring(const void* data) {
const std::uint16_t* p = static_cast<const std::uint16_t*>(data);
// find the end (nullterminated)
const std::uint16_t* end = p;
while (*end) {
++end;
}
const std::size_t len16 = static_cast<std::size_t>(end - chars);
std::string result(simdutf::utf8_length_from_utf16le(chars, len16), '\0');
auto len = simdutf::convert_utf16le_to_utf8(chars, len16, result.data());
result.resize(len);
std::size_t len = static_cast<std::size_t>(end - p);
return result;
// allocate wstring with length len
// it will be nullterminated internally, do not worry.
std::wstring out(len, 0);
// and copy them into thje string
for (std::size_t i = 0; i < len; ++i) {
out[i] = static_cast<wchar_t>(p[i]);
}
return out;
}
#define DLC_WSTRING(ptr) dlc_read_wstring(ptr)
#else
// just in case.
static_assert(sizeof(wchar_t) == 2,
"How did we get here? wide char smaller than 2 bytes");
// perfectly fine scince wchar_t will be 2 bytes (UCS-2/UTF-16)
#define DLC_WSTRING(ptr) std::wstring((wchar_t*)(ptr))
#endif
#define DLC_PARAM_ADV(n) \
(sizeof(IPlatformStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE)
(sizeof(C4JStorage::DLC_FILE_PARAM) + (n) * DLC_WCHAR_BIN_SIZE)
#define DLC_DETAIL_ADV(n) \
(sizeof(IPlatformStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE)
(sizeof(C4JStorage::DLC_FILE_DETAILS) + (n) * DLC_WCHAR_BIN_SIZE)
namespace {
template <typename T>
@ -67,13 +86,13 @@ void ReadDlcStruct(T* out, const std::uint8_t* data, unsigned int offset = 0) {
std::memcpy(out, data + offset, sizeof(*out));
}
std::string getMountedDlcReadPath(const std::string& path) {
std::string readPath = path;
std::wstring getMountedDlcReadPath(const std::string& path) {
std::wstring readPath = convStringToWstring(path);
#if defined(_WINDOWS64)
const std::string mountedPath = PlatformStorage.GetMountedPath(path.c_str());
const std::string mountedPath = StorageManager.GetMountedPath(path.c_str());
if (!mountedPath.empty()) {
readPath = mountedPath;
readPath = convStringToWstring(mountedPath);
}
#endif
@ -85,15 +104,15 @@ bool readOwnedDlcFile(const std::string& path, std::uint8_t** ppData,
*ppData = nullptr;
*pBytesRead = 0;
const std::string readPath = getMountedDlcReadPath(path);
const std::size_t fSize = PlatformFilesystem.fileSize(readPath);
const std::wstring readPath = getMountedDlcReadPath(path);
const std::size_t fSize = PlatformFileIO.fileSize(readPath);
if (fSize == 0 || fSize > std::numeric_limits<unsigned int>::max()) {
return false;
}
std::uint8_t* data = new std::uint8_t[fSize];
auto result = PlatformFilesystem.readFile(readPath, data, fSize);
if (result.status != IPlatformFilesystem::ReadStatus::Ok) {
auto result = PlatformFileIO.readFile(readPath, data, fSize);
if (result.status != IPlatformFileIO::ReadStatus::Ok) {
delete[] data;
return false;
}
@ -104,20 +123,20 @@ bool readOwnedDlcFile(const std::string& path, std::uint8_t** ppData,
}
} // namespace
const char* DLCManager::wchTypeNamesA[] = {
"DISPLAYNAME",
"THEMENAME",
"FREE",
"CREDIT",
"CAPEPATH",
"BOX",
"ANIM",
"PACKID",
"NETHERPARTICLECOLOUR",
"ENCHANTTEXTCOLOUR",
"ENCHANTTEXTFOCUSCOLOUR",
"DATAPATH",
"PACKVERSION",
const wchar_t* DLCManager::wchTypeNamesA[] = {
L"DISPLAYNAME",
L"THEMENAME",
L"FREE",
L"CREDIT",
L"CAPEPATH",
L"BOX",
L"ANIM",
L"PACKID",
L"NETHERPARTICLECOLOUR",
L"ENCHANTTEXTCOLOUR",
L"ENCHANTTEXTFOCUSCOLOUR",
L"DATAPATH",
L"PACKVERSION",
};
DLCManager::DLCManager() {
@ -133,7 +152,7 @@ DLCManager::~DLCManager() {
}
DLCManager::EDLCParameterType DLCManager::getParameterType(
const std::string& paramName) {
const std::wstring& paramName) {
EDLCParameterType type = e_DLCParamType_Invalid;
for (unsigned int i = 0; i < e_DLCParamType_Max; ++i) {
@ -188,13 +207,13 @@ void DLCManager::LanguageChanged(void) {
}
}
DLCPack* DLCManager::getPack(const std::string& name) {
DLCPack* DLCManager::getPack(const std::wstring& name) {
DLCPack* pack = nullptr;
// uint32_t currentIndex = 0;
DLCPack* currentPack = nullptr;
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
currentPack = *it;
std::string wsName = currentPack->getName();
std::wstring wsName = currentPack->getName();
if (wsName.compare(name) == 0) {
pack = currentPack;
@ -240,7 +259,7 @@ unsigned int DLCManager::getPackIndex(DLCPack* pack, bool& found,
if (pack == nullptr) {
app.DebugPrintf(
"DLCManager: Attempting to find the index for a nullptr pack\n");
//assert(0);
//__debugbreak();
return foundIndex;
}
if (type != e_DLCType_All) {
@ -271,7 +290,7 @@ unsigned int DLCManager::getPackIndex(DLCPack* pack, bool& found,
return foundIndex;
}
unsigned int DLCManager::getPackIndexContainingSkin(const std::string& path,
unsigned int DLCManager::getPackIndexContainingSkin(const std::wstring& path,
bool& found) {
unsigned int foundIndex = 0;
found = false;
@ -290,7 +309,7 @@ unsigned int DLCManager::getPackIndexContainingSkin(const std::string& path,
return foundIndex;
}
DLCPack* DLCManager::getPackContainingSkin(const std::string& path) {
DLCPack* DLCManager::getPackContainingSkin(const std::wstring& path) {
DLCPack* foundPack = nullptr;
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
DLCPack* pack = *it;
@ -304,7 +323,7 @@ DLCPack* DLCManager::getPackContainingSkin(const std::string& path) {
return foundPack;
}
DLCSkinFile* DLCManager::getSkinFile(const std::string& path) {
DLCSkinFile* DLCManager::getSkinFile(const std::wstring& path) {
DLCSkinFile* foundSkinfile = nullptr;
for (auto it = m_packs.begin(); it != m_packs.end(); ++it) {
DLCPack* pack = *it;
@ -336,18 +355,18 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert(
uiIDA[0] = IDS_CONFIRM_OK;
if (corruptDLCCount == 1 && firstCorruptPack != nullptr) {
// pass in the pack format string
char wchFormat[132];
snprintf(wchFormat, 132, "%s\n\n%%s",
wchar_t wchFormat[132];
swprintf(wchFormat, 132, L"%ls\n\n%%ls",
firstCorruptPack->getName().c_str());
IPlatformStorage::EMessageResult result = ui.RequestErrorMessage(
C4JStorage::EMessageResult result = ui.RequestErrorMessage(
IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA, 1,
PlatformProfile.GetPrimaryPad(), nullptr, nullptr, wchFormat);
ProfileManager.GetPrimaryPad(), nullptr, nullptr, wchFormat);
} else {
IPlatformStorage::EMessageResult result = ui.RequestErrorMessage(
C4JStorage::EMessageResult result = ui.RequestErrorMessage(
IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC_MULTIPLE, uiIDA, 1,
PlatformProfile.GetPrimaryPad());
ProfileManager.GetPrimaryPad());
}
}
@ -356,18 +375,18 @@ unsigned int DLCManager::checkForCorruptDLCAndAlert(
return corruptDLCCount;
}
// bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
// const std::string& path, DLCPack* pack,
// bool fromArchive) {
// return readDLCDataFile(dwFilesProcessed,
// std::filesystem::path(path).string(), pack,
// fromArchive);
// }
bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
const std::wstring& path, DLCPack* pack,
bool fromArchive) {
return readDLCDataFile(dwFilesProcessed,
std::filesystem::path(path).string(), pack,
fromArchive);
}
bool DLCManager::readDLCDataFile(unsigned int& dwFilesProcessed,
const std::string& path, DLCPack* pack,
bool fromArchive) {
std::string wPath = path;
std::wstring wPath = convStringToWstring(path);
if (fromArchive && app.getArchiveFileSize(wPath) >= 0) {
std::vector<uint8_t> bytes = app.getArchiveFile(wPath);
return processDLCDataFile(dwFilesProcessed, bytes.data(), bytes.size(),
@ -394,17 +413,17 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
memcpy((out), (buf) + (off), sizeof(unsigned int))
#define DLC_READ_PARAM(out, buf, off) \
memcpy((out), (buf) + (off), sizeof(IPlatformStorage::DLC_FILE_PARAM))
memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_PARAM))
#define DLC_READ_DETAIL(out, buf, off) \
memcpy((out), (buf) + (off), sizeof(IPlatformStorage::DLC_FILE_DETAILS))
memcpy((out), (buf) + (off), sizeof(C4JStorage::DLC_FILE_DETAILS))
// for details, read in the function below
#define DLC_PARAM_WSTR(buf, off) \
DLC_WSTRING((buf) + (off) + offsetof(IPlatformStorage::DLC_FILE_PARAM, wchData))
DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_PARAM, wchData))
#define DLC_DETAIL_WSTR(buf, off) \
DLC_WSTRING((buf) + (off) + offsetof(IPlatformStorage::DLC_FILE_DETAILS, wchFile))
DLC_WSTRING((buf) + (off) + offsetof(C4JStorage::DLC_FILE_DETAILS, wchFile))
{
std::unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
unsigned int uiCurrentByte = 0;
@ -447,13 +466,13 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
DLC_READ_UINT(&uiParameterCount, pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_PARAM parBuf;
C4JStorage::DLC_FILE_PARAM parBuf;
DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
// uint32_t dwwchCount=0;
for (unsigned int i = 0; i < uiParameterCount; i++) {
// Map DLC strings to application strings, then store the DLC index
// mapping to application index
std::string parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
DLCManager::EDLCParameterType type =
DLCManager::getParameterType(parameterName);
if (type != DLCManager::e_DLCParamType_Invalid) {
@ -462,13 +481,13 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
uiCurrentByte += DLC_PARAM_ADV(parBuf.dwWchCount);
DLC_READ_PARAM(&parBuf, pbData, uiCurrentByte);
}
// ulCurrentByte+=ulParameterCount * sizeof(IPlatformStorage::DLC_FILE_PARAM);
// ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
unsigned int uiFileCount;
DLC_READ_UINT(&uiFileCount, pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
C4JStorage::DLC_FILE_DETAILS fileBuf;
DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
unsigned int dwTemp = uiCurrentByte;
@ -477,7 +496,7 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
DLC_READ_DETAIL(&fileBuf, pbData, dwTemp);
}
std::uint8_t* pbTemp =
&pbData[dwTemp]; //+ sizeof(IPlatformStorage::DLC_FILE_DETAILS)*ulFileCount;
&pbData[dwTemp]; //+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
DLC_READ_DETAIL(&fileBuf, pbData, uiCurrentByte);
for (unsigned int i = 0; i < uiFileCount; i++) {
@ -521,7 +540,7 @@ bool DLCManager::processDLCDataFile(unsigned int& dwFilesProcessed,
pbTemp += DLC_PARAM_ADV(parBuf.dwWchCount);
DLC_READ_PARAM(&parBuf, pbTemp, 0);
}
// pbTemp+=ulParameterCount * sizeof(IPlatformStorage::DLC_FILE_PARAM);
// pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
if (dlcTexturePack != nullptr) {
unsigned int texturePackFilesProcessed = 0;
@ -624,12 +643,12 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
unsigned int uiParameterCount =
ReadDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_PARAM paramBuf;
C4JStorage::DLC_FILE_PARAM paramBuf;
ReadDlcStruct(&paramBuf, pbData, uiCurrentByte);
for (unsigned int i = 0; i < uiParameterCount; i++) {
// Map DLC strings to application strings, then store the DLC index
// mapping to application index
std::string parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
std::wstring parameterName = DLC_PARAM_WSTR(pbData, uiCurrentByte);
DLCManager::EDLCParameterType type =
DLCManager::getParameterType(parameterName);
if (type != DLCManager::e_DLCParamType_Invalid) {
@ -642,7 +661,7 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
unsigned int uiFileCount =
ReadDlcValue<unsigned int>(pbData, uiCurrentByte);
uiCurrentByte += sizeof(int);
IPlatformStorage::DLC_FILE_DETAILS fileBuf;
C4JStorage::DLC_FILE_DETAILS fileBuf;
ReadDlcStruct(&fileBuf, pbData, uiCurrentByte);
unsigned int dwTemp = uiCurrentByte;
@ -666,8 +685,8 @@ std::uint32_t DLCManager::retrievePackID(std::uint8_t* pbData,
if (it != parameterMapping.end()) {
if (type == e_DLCType_PackConfig) {
if (it->second == e_DLCParamType_PackId) {
std::string wsTemp = DLC_PARAM_WSTR(pbTemp, 0);
std::stringstream ss;
std::wstring wsTemp = DLC_PARAM_WSTR(pbTemp, 0);
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for
// artists/people to number manually
ss << std::dec << wsTemp.c_str();

View file

@ -47,7 +47,7 @@ public:
e_DLCParamType_Max,
};
const static char* wchTypeNamesA[e_DLCParamType_Max];
const static wchar_t* wchTypeNamesA[e_DLCParamType_Max];
private:
std::vector<DLCPack*> m_packs;
@ -59,7 +59,7 @@ public:
DLCManager();
~DLCManager();
static EDLCParameterType getParameterType(const std::string& paramName);
static EDLCParameterType getParameterType(const std::wstring& paramName);
unsigned int getPackCount(EDLCType type = e_DLCType_All);
@ -77,23 +77,23 @@ public:
void removeAllPacks(void);
void LanguageChanged(void);
DLCPack* getPack(const std::string& name);
DLCPack* getPack(const std::wstring& name);
DLCPack* getPack(unsigned int index, EDLCType type = e_DLCType_All);
unsigned int getPackIndex(DLCPack* pack, bool& found,
EDLCType type = e_DLCType_All);
DLCSkinFile* getSkinFile(
const std::string& path); // Will hunt all packs of type skin to find
const std::wstring& path); // Will hunt all packs of type skin to find
// the right skinfile
DLCPack* getPackContainingSkin(const std::string& path);
unsigned int getPackIndexContainingSkin(const std::string& path,
DLCPack* getPackContainingSkin(const std::wstring& path);
unsigned int getPackIndexContainingSkin(const std::wstring& path,
bool& found);
unsigned int checkForCorruptDLCAndAlert(bool showMessage = true);
// bool readDLCDataFile(unsigned int& dwFilesProcessed,
// const std::wstring& path, DLCPack* pack,
// bool fromArchive = false);
bool readDLCDataFile(unsigned int& dwFilesProcessed,
const std::wstring& path, DLCPack* pack,
bool fromArchive = false);
bool readDLCDataFile(unsigned int& dwFilesProcessed,
const std::string& path, DLCPack* pack,
bool fromArchive = false);
@ -108,5 +108,3 @@ private:
std::uint32_t retrievePackID(std::uint8_t* pbData, unsigned int dwLength,
DLCPack* pack);
};
std::string dlc_read_wstring(const void* data);

View file

@ -6,7 +6,7 @@
#include <sstream>
#include <utility>
#include "platform/profile/profile.h"
#include "platform/sdl2/Profile.h"
#include "DLCAudioFile.h"
#include "DLCCapeFile.h"
#include "DLCColourTableFile.h"
@ -15,17 +15,17 @@
#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"
DLCPack::DLCPack(const std::string& name, std::uint32_t dwLicenseMask) {
m_dataPath = "";
DLCPack::DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask) {
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask = dwLicenseMask;
m_ullFullOfferId = 0LL;
@ -55,7 +55,7 @@ DLCPack::~DLCPack() {
// invalidates ALL of it's children.
if (m_data) {
#if !defined(_CONTENT_PACKAGE)
printf("Deleting data for DLC pack %s\n", m_packName.c_str());
wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str());
#endif
// For the same reason, don't delete data pointer for any child pack as
// it just points to a region within the parent pack that has already
@ -84,7 +84,7 @@ void DLCPack::addChildPack(DLCPack* childPack) {
const std::uint32_t packId = childPack->GetPackId();
#if !defined(_CONTENT_PACKAGE)
if (packId < 0 || packId > 15) {
assert(0);
__debugbreak();
}
#endif
childPack->SetPackId((packId << 24) | m_packId);
@ -96,12 +96,12 @@ void DLCPack::addChildPack(DLCPack* childPack) {
void DLCPack::setParentPack(DLCPack* parentPack) { m_parentPack = parentPack; }
void DLCPack::addParameter(DLCManager::EDLCParameterType type,
const std::string& value) {
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_PackId: {
std::uint32_t packId = 0;
std::stringstream ss;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for
// artists/people to number manually
ss << std::dec << value.c_str();
@ -112,7 +112,7 @@ void DLCPack::addParameter(DLCManager::EDLCParameterType type,
case DLCManager::e_DLCParamType_PackVersion: {
std::uint32_t version = 0;
std::stringstream ss;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for
// artists/people to number manually
ss << std::dec << value.c_str();
@ -140,7 +140,7 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
case DLCManager::e_DLCParamType_NetherParticleColour:
case DLCManager::e_DLCParamType_EnchantmentTextColour:
case DLCManager::e_DLCParamType_EnchantmentTextFocusColour: {
std::stringstream ss;
std::wstringstream ss;
ss << std::hex << it->second.c_str();
ss >> param;
} break;
@ -152,13 +152,13 @@ bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type,
return false;
}
DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::string& path) {
DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::wstring& path) {
DLCFile* newFile = nullptr;
switch (type) {
case DLCManager::e_DLCType_Skin: {
std::vector<std::string> splitPath = stringSplit(path, '/');
std::string strippedPath = splitPath.back();
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
std::wstring strippedPath = splitPath.back();
newFile = new DLCSkinFile(strippedPath);
@ -170,8 +170,8 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::string& path) {
}
} break;
case DLCManager::e_DLCType_Cape: {
std::vector<std::string> splitPath = stringSplit(path, '/');
std::string strippedPath = splitPath.back();
std::vector<std::wstring> splitPath = stringSplit(path, L'/');
std::wstring strippedPath = splitPath.back();
newFile = new DLCCapeFile(strippedPath);
} break;
case DLCManager::e_DLCType_Texture:
@ -208,13 +208,13 @@ DLCFile* DLCPack::addFile(DLCManager::EDLCType type, const std::string& path) {
// MGH - added this comp func, as the embedded func in find_if was confusing the
// PS3 compiler
static const std::string* g_pathCmpString = nullptr;
static const std::wstring* g_pathCmpString = nullptr;
static bool pathCmp(DLCFile* val) {
return (g_pathCmpString->compare(val->getPath()) == 0);
}
bool DLCPack::doesPackContainFile(DLCManager::EDLCType type,
const std::string& path) {
const std::wstring& path) {
bool hasFile = false;
if (type == DLCManager::e_DLCType_All) {
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
@ -253,7 +253,7 @@ DLCFile* DLCPack::getFile(DLCManager::EDLCType type, unsigned int index) {
return file;
}
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::string& path) {
DLCFile* DLCPack::getFile(DLCManager::EDLCType type, const std::wstring& path) {
DLCFile* file = nullptr;
if (type == DLCManager::e_DLCType_All) {
for (DLCManager::EDLCType currentType = (DLCManager::EDLCType)0;
@ -298,11 +298,11 @@ unsigned int DLCPack::getDLCItemsCount(
};
unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type,
const std::string& path, bool& found) {
const std::wstring& path, bool& found) {
if (type == DLCManager::e_DLCType_All) {
app.DebugPrintf("Unimplemented\n");
#if !defined(__CONTENT_PACKAGE)
assert(0);
__debugbreak();
#endif
return 0;
}
@ -323,16 +323,16 @@ unsigned int DLCPack::getFileIndexAt(DLCManager::EDLCType type,
}
bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type,
const std::string& path) {
const std::wstring& path) {
if (type == DLCManager::e_DLCType_All) {
app.DebugPrintf("Unimplemented\n");
#if !defined(_CONTENT_PACKAGE)
assert(0);
__debugbreak();
#endif
return false;
}
#if !defined(_CONTENT_PACKAGE)
if (app.GetGameSettingsDebugMask(PlatformProfile.GetPrimaryPad()) &
if (app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) &
(1L << eDebugSetting_UnlockAllDLC)) {
return true;
} else
@ -350,7 +350,7 @@ void DLCPack::UpdateLanguage() {
// find the language file
if (m_files[DLCManager::e_DLCType_LocalisationData].size() > 0) {
DLCLocalisationFile* localisationFile = (DLCLocalisationFile*)getFile(
DLCManager::e_DLCType_LocalisationData, "languages.loc");
DLCManager::e_DLCType_LocalisationData, L"languages.loc");
StringTable* strTable = localisationFile->getStringTable();
strTable->ReloadStringTable();
}

View file

@ -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;
@ -18,10 +18,10 @@ private:
std::vector<DLCPack*> m_childPacks;
DLCPack* m_parentPack;
std::unordered_map<int, std::string> m_parameters;
std::unordered_map<int, std::wstring> m_parameters;
std::string m_packName;
std::string m_dataPath;
std::wstring m_packName;
std::wstring m_dataPath;
std::uint32_t m_dwLicenseMask;
int m_dlcMountIndex;
XCONTENTDEVICEID m_dlcDeviceID;
@ -34,10 +34,10 @@ private:
m_data; // This pointer is for all the data used for this pack, so
// deleting it invalidates ALL of it's children.
public:
DLCPack(const std::string& name, std::uint32_t dwLicenseMask);
DLCPack(const std::wstring& name, std::uint32_t dwLicenseMask);
~DLCPack();
std::string getFullDataPath() { return m_dataPath; }
std::wstring getFullDataPath() { return m_dataPath; }
void SetDataPointer(std::uint8_t* pbData) { m_data = pbData; }
@ -62,7 +62,7 @@ public:
void setParentPack(DLCPack* parentPack);
void addParameter(DLCManager::EDLCParameterType type,
const std::string& value);
const std::wstring& value);
bool getParameterAsUInt(DLCManager::EDLCParameterType type,
unsigned int& param);
@ -71,38 +71,38 @@ public:
}
std::uint32_t getLicenseMask() { return m_dwLicenseMask; }
std::string getName() { return m_packName; }
std::wstring getName() { return m_packName; }
void UpdateLanguage();
uint64_t getPurchaseOfferId() { return m_ullFullOfferId; }
DLCFile* addFile(DLCManager::EDLCType type, const std::string& path);
DLCFile* addFile(DLCManager::EDLCType type, const std::wstring& path);
DLCFile* getFile(DLCManager::EDLCType type, unsigned int index);
DLCFile* getFile(DLCManager::EDLCType type, const std::string& path);
DLCFile* getFile(DLCManager::EDLCType type, const std::wstring& path);
unsigned int getDLCItemsCount(
DLCManager::EDLCType type = DLCManager::e_DLCType_All);
unsigned int getFileIndexAt(DLCManager::EDLCType type,
const std::string& path, bool& found);
const std::wstring& path, bool& found);
bool doesPackContainFile(DLCManager::EDLCType type,
const std::string& path);
const std::wstring& path);
std::uint32_t GetPackID() { return m_packId; }
unsigned int getSkinCount() {
return getDLCItemsCount(DLCManager::e_DLCType_Skin);
}
unsigned int getSkinIndexAt(const std::string& path, bool& found) {
unsigned int getSkinIndexAt(const std::wstring& path, bool& found) {
return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found);
}
DLCSkinFile* getSkinFile(const std::string& path) {
DLCSkinFile* getSkinFile(const std::wstring& path) {
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, path);
}
DLCSkinFile* getSkinFile(unsigned int index) {
return (DLCSkinFile*)getFile(DLCManager::e_DLCType_Skin, index);
}
bool doesPackContainSkin(const std::string& path) {
bool doesPackContainSkin(const std::wstring& path) {
return doesPackContainFile(DLCManager::e_DLCType_Skin, path);
}
bool hasPurchasedFile(DLCManager::EDLCType type, const std::string& path);
bool hasPurchasedFile(DLCManager::EDLCType type, const std::wstring& path);
};

View file

@ -3,18 +3,18 @@
#include <string.h>
#include <wchar.h>
#include "platform/renderer/renderer.h"
#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::string& path)
DLCSkinFile::DLCSkinFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Skin, path) {
m_displayName = "";
m_themeName = "";
m_cape = "";
m_displayName = L"";
m_themeName = L"";
m_cape = L"";
m_bIsFree = false;
m_uiAnimOverrideBitmask = 0L;
}
@ -24,13 +24,13 @@ void DLCSkinFile::addData(std::uint8_t* pbData, std::uint32_t dataBytes) {
}
void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
const std::string& value) {
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_DisplayName: {
// 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two
// p's as Zapp dlcskin00000109.png
if (m_path.compare("dlcskin00000109.png") == 0) {
m_displayName = "Zap";
if (m_path.compare(L"dlcskin00000109.png") == 0) {
m_displayName = L"Zap";
} else {
m_displayName = value;
}
@ -52,12 +52,12 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
{
if (app.AlreadySeenCreditText(value)) break;
// first add a blank string for spacing
app.AddCreditText("");
app.AddCreditText(L"");
int maximumChars = 55;
bool bIsSDMode =
!PlatformRenderer.IsHiDef() && !PlatformRenderer.IsWidescreen();
!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if (bIsSDMode) {
maximumChars = 45;
@ -72,14 +72,14 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
default:
break;
}
std::string creditValue = value;
std::wstring creditValue = value;
while (creditValue.length() > maximumChars) {
unsigned int i = 1;
while (i < creditValue.length() &&
(i + 1) <= maximumChars) {
i++;
}
int iLast = (int)creditValue.find_last_of(" ", i);
int iLast = (int)creditValue.find_last_of(L" ", i);
switch (XGetLanguage()) {
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
@ -87,7 +87,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
iLast = maximumChars;
break;
default:
iLast = (int)creditValue.find_last_of(" ", i);
iLast = (int)creditValue.find_last_of(L" ", i);
break;
}
@ -106,25 +106,25 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
m_cape = value;
break;
case DLCManager::e_DLCParamType_Box: {
char wchBodyPart[10];
wchar_t wchBodyPart[10];
SKIN_BOX* pSkinBox = new SKIN_BOX;
memset(pSkinBox, 0, sizeof(SKIN_BOX));
sscanf(value.c_str(), "%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
&pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
if (strcmp(wchBodyPart, "HEAD") == 0) {
if (wcscmp(wchBodyPart, L"HEAD") == 0) {
pSkinBox->ePart = eBodyPart_Head;
} else if (strcmp(wchBodyPart, "BODY") == 0) {
} else if (wcscmp(wchBodyPart, L"BODY") == 0) {
pSkinBox->ePart = eBodyPart_Body;
} else if (strcmp(wchBodyPart, "ARM0") == 0) {
} else if (wcscmp(wchBodyPart, L"ARM0") == 0) {
pSkinBox->ePart = eBodyPart_Arm0;
} else if (strcmp(wchBodyPart, "ARM1") == 0) {
} else if (wcscmp(wchBodyPart, L"ARM1") == 0) {
pSkinBox->ePart = eBodyPart_Arm1;
} else if (strcmp(wchBodyPart, "LEG0") == 0) {
} else if (wcscmp(wchBodyPart, L"LEG0") == 0) {
pSkinBox->ePart = eBodyPart_Leg0;
} else if (strcmp(wchBodyPart, "LEG1") == 0) {
} else if (wcscmp(wchBodyPart, L"LEG1") == 0) {
pSkinBox->ePart = eBodyPart_Leg1;
}
@ -132,7 +132,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
m_AdditionalBoxes.push_back(pSkinBox);
} break;
case DLCManager::e_DLCParamType_Anim: {
sscanf(value.c_str(), "%X", &m_uiAnimOverrideBitmask,
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask,
sizeof(unsigned int));
uint32_t skinId = app.getSkinIdFromPath(m_path);
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
@ -155,7 +155,7 @@ std::vector<SKIN_BOX*>* DLCSkinFile::getAdditionalBoxes() {
return &m_AdditionalBoxes;
}
std::string DLCSkinFile::getParameterAsString(
std::wstring DLCSkinFile::getParameterAsString(
DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_DisplayName:
@ -165,7 +165,7 @@ std::string DLCSkinFile::getParameterAsString(
case DLCManager::e_DLCParamType_Cape:
return m_cape;
default:
return "";
return L"";
}
}

View file

@ -5,27 +5,27 @@
#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 {
private:
std::string m_displayName;
std::string m_themeName;
std::string m_cape;
std::wstring m_displayName;
std::wstring m_themeName;
std::wstring m_cape;
unsigned int m_uiAnimOverrideBitmask;
bool m_bIsFree;
std::vector<SKIN_BOX*> m_AdditionalBoxes;
public:
DLCSkinFile(const std::string& path);
DLCSkinFile(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::string& value);
const std::wstring& value);
virtual std::string getParameterAsString(
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
std::vector<SKIN_BOX*>* getAdditionalBoxes();

View file

@ -1,12 +1,12 @@
#include "DLCTextureFile.h"
#include "DLCManager.h"
#include "app/common/DLC/DLCFile.h"
#include "app/common/src/DLC/DLCFile.h"
DLCTextureFile::DLCTextureFile(const std::string& path)
DLCTextureFile::DLCTextureFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_Texture, path) {
m_bIsAnim = false;
m_animString = "";
m_animString = L"";
m_pbData = nullptr;
m_dataBytes = 0;
@ -24,7 +24,7 @@ std::uint8_t* DLCTextureFile::getData(std::uint32_t& dataBytes) {
}
void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type,
const std::string& value) {
const std::wstring& value) {
switch (type) {
case DLCManager::e_DLCParamType_Anim:
m_animString = value;
@ -36,13 +36,13 @@ void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type,
}
}
std::string DLCTextureFile::getParameterAsString(
std::wstring DLCTextureFile::getParameterAsString(
DLCManager::EDLCParameterType type) {
switch (type) {
case DLCManager::e_DLCParamType_Anim:
return m_animString;
default:
return "";
return L"";
}
}

View file

@ -3,26 +3,26 @@
#include <string>
#include "DLCFile.h"
#include "app/common/DLC/DLCManager.h"
#include "app/common/src/DLC/DLCManager.h"
class DLCTextureFile : public DLCFile {
private:
bool m_bIsAnim;
std::string m_animString;
std::wstring m_animString;
std::uint8_t* m_pbData;
std::uint32_t m_dataBytes;
public:
DLCTextureFile(const std::string& path);
DLCTextureFile(const std::wstring& path);
virtual void addData(std::uint8_t* pbData, std::uint32_t dataBytes);
virtual std::uint8_t* getData(std::uint32_t& dataBytes);
virtual void addParameter(DLCManager::EDLCParameterType type,
const std::string& value);
const std::wstring& value);
virtual std::string getParameterAsString(
virtual std::wstring getParameterAsString(
DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
};

View file

@ -1,10 +1,10 @@
#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::string& path)
DLCUIDataFile::DLCUIDataFile(const std::wstring& path)
: DLCFile(DLCManager::e_DLCType_UIData, path) {
m_pbData = nullptr;
m_dataBytes = 0;

View file

@ -11,7 +11,7 @@ private:
bool m_canDeleteData;
public:
DLCUIDataFile(const std::string& path);
DLCUIDataFile(const std::wstring& path);
~DLCUIDataFile();
using DLCFile::addData;

View file

@ -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"

View file

@ -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"
@ -29,73 +29,73 @@
#include "minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h"
#include "strings.h"
const char* GameRuleManager::wchTagNameA[] = {
"", // eGameRuleType_Root
"MapOptions", // eGameRuleType_LevelGenerationOptions
"ApplySchematic", // eGameRuleType_ApplySchematic
"GenerateStructure", // eGameRuleType_GenerateStructure
"GenerateBox", // eGameRuleType_GenerateBox
"PlaceBlock", // eGameRuleType_PlaceBlock
"PlaceContainer", // eGameRuleType_PlaceContainer
"PlaceSpawner", // eGameRuleType_PlaceSpawner
"BiomeOverride", // eGameRuleType_BiomeOverride
"StartFeature", // eGameRuleType_StartFeature
"AddItem", // eGameRuleType_AddItem
"AddEnchantment", // eGameRuleType_AddEnchantment
"LevelRules", // eGameRuleType_LevelRules
"NamedArea", // eGameRuleType_NamedArea
"UseTile", // eGameRuleType_UseTileRule
"CollectItem", // eGameRuleType_CollectItemRule
"CompleteAll", // eGameRuleType_CompleteAllRule
"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
const wchar_t* GameRuleManager::wchTagNameA[] = {
L"", // eGameRuleType_Root
L"MapOptions", // eGameRuleType_LevelGenerationOptions
L"ApplySchematic", // eGameRuleType_ApplySchematic
L"GenerateStructure", // eGameRuleType_GenerateStructure
L"GenerateBox", // eGameRuleType_GenerateBox
L"PlaceBlock", // eGameRuleType_PlaceBlock
L"PlaceContainer", // eGameRuleType_PlaceContainer
L"PlaceSpawner", // eGameRuleType_PlaceSpawner
L"BiomeOverride", // eGameRuleType_BiomeOverride
L"StartFeature", // eGameRuleType_StartFeature
L"AddItem", // eGameRuleType_AddItem
L"AddEnchantment", // eGameRuleType_AddEnchantment
L"LevelRules", // eGameRuleType_LevelRules
L"NamedArea", // eGameRuleType_NamedArea
L"UseTile", // eGameRuleType_UseTileRule
L"CollectItem", // eGameRuleType_CollectItemRule
L"CompleteAll", // eGameRuleType_CompleteAllRule
L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
};
const char* GameRuleManager::wchAttrNameA[] = {
"descriptionName", // eGameRuleAttr_descriptionName
"promptName", // eGameRuleAttr_promptName
"dataTag", // eGameRuleAttr_dataTag
"enchantmentId", // eGameRuleAttr_enchantmentId
"enchantmentLevel", // eGameRuleAttr_enchantmentLevel
"itemId", // eGameRuleAttr_itemId
"quantity", // eGameRuleAttr_quantity
"auxValue", // eGameRuleAttr_auxValue
"slot", // eGameRuleAttr_slot
"name", // eGameRuleAttr_name
"food", // eGameRuleAttr_food
"health", // eGameRuleAttr_health
"tileId", // eGameRuleAttr_tileId
"useCoords", // eGameRuleAttr_useCoords
"seed", // eGameRuleAttr_seed
"flatworld", // eGameRuleAttr_flatworld
"filename", // eGameRuleAttr_filename
"rot", // eGameRuleAttr_rot
"data", // eGameRuleAttr_data
"block", // eGameRuleAttr_block
"entity", // eGameRuleAttr_entity
"facing", // eGameRuleAttr_facing
"edgeTile", // eGameRuleAttr_edgeTile
"fillTile", // eGameRuleAttr_fillTile
"skipAir", // eGameRuleAttr_skipAir
"x", // eGameRuleAttr_x
"x0", // eGameRuleAttr_x0
"x1", // eGameRuleAttr_x1
"y", // eGameRuleAttr_y
"y0", // eGameRuleAttr_y0
"y1", // eGameRuleAttr_y1
"z", // eGameRuleAttr_z
"z0", // eGameRuleAttr_z0
"z1", // eGameRuleAttr_z1
"chunkX", // eGameRuleAttr_chunkX
"chunkZ", // eGameRuleAttr_chunkZ
"yRot", // eGameRuleAttr_yRot
"spawnX", // eGameRuleAttr_spawnX
"spawnY", // eGameRuleAttr_spawnY
"spawnZ", // eGameRuleAttr_spawnZ
"orientation",
"dimension",
"topTileId", // eGameRuleAttr_topTileId
"biomeId", // eGameRuleAttr_biomeId
"feature", // eGameRuleAttr_feature
const wchar_t* GameRuleManager::wchAttrNameA[] = {
L"descriptionName", // eGameRuleAttr_descriptionName
L"promptName", // eGameRuleAttr_promptName
L"dataTag", // eGameRuleAttr_dataTag
L"enchantmentId", // eGameRuleAttr_enchantmentId
L"enchantmentLevel", // eGameRuleAttr_enchantmentLevel
L"itemId", // eGameRuleAttr_itemId
L"quantity", // eGameRuleAttr_quantity
L"auxValue", // eGameRuleAttr_auxValue
L"slot", // eGameRuleAttr_slot
L"name", // eGameRuleAttr_name
L"food", // eGameRuleAttr_food
L"health", // eGameRuleAttr_health
L"tileId", // eGameRuleAttr_tileId
L"useCoords", // eGameRuleAttr_useCoords
L"seed", // eGameRuleAttr_seed
L"flatworld", // eGameRuleAttr_flatworld
L"filename", // eGameRuleAttr_filename
L"rot", // eGameRuleAttr_rot
L"data", // eGameRuleAttr_data
L"block", // eGameRuleAttr_block
L"entity", // eGameRuleAttr_entity
L"facing", // eGameRuleAttr_facing
L"edgeTile", // eGameRuleAttr_edgeTile
L"fillTile", // eGameRuleAttr_fillTile
L"skipAir", // eGameRuleAttr_skipAir
L"x", // eGameRuleAttr_x
L"x0", // eGameRuleAttr_x0
L"x1", // eGameRuleAttr_x1
L"y", // eGameRuleAttr_y
L"y0", // eGameRuleAttr_y0
L"y1", // eGameRuleAttr_y1
L"z", // eGameRuleAttr_z
L"z0", // eGameRuleAttr_z0
L"z1", // eGameRuleAttr_z1
L"chunkX", // eGameRuleAttr_chunkX
L"chunkZ", // eGameRuleAttr_chunkZ
L"yRot", // eGameRuleAttr_yRot
L"spawnX", // eGameRuleAttr_spawnX
L"spawnY", // eGameRuleAttr_spawnY
L"spawnZ", // eGameRuleAttr_spawnZ
L"orientation",
L"dimension",
L"topTileId", // eGameRuleAttr_topTileId
L"biomeId", // eGameRuleAttr_biomeId
L"feature", // eGameRuleAttr_feature
};
GameRuleManager::GameRuleManager() {
@ -107,10 +107,10 @@ void GameRuleManager::loadGameRules(DLCPack* pack) {
StringTable* strings = nullptr;
if (pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,
"languages.loc")) {
L"languages.loc")) {
DLCLocalisationFile* localisationFile =
(DLCLocalisationFile*)pack->getFile(
DLCManager::e_DLCType_LocalisationData, "languages.loc");
DLCManager::e_DLCType_LocalisationData, L"languages.loc");
strings = localisationFile->getStringTable();
}
@ -231,7 +231,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
dis2.read(bRuleFile);
// 4J-JEV: I don't believe that the path-name is ever used.
// DLCGameRulesFile *dlcgr = new DLCGameRulesFile("__PLACEHOLDER__");
// DLCGameRulesFile *dlcgr = new DLCGameRulesFile(L"__PLACEHOLDER__");
// dlcgr->addData(bRuleFile.data(),bRuleFile.size());
if (readRuleFile(lgo, bRuleFile.data(), bRuleFile.size(), strings)) {
@ -358,11 +358,11 @@ void GameRuleManager::writeRuleFile(DataOutputStream* dos) {
dos->writeUTF(wchAttrNameA[i]);
// Write schematic files.
std::unordered_map<std::string, ConsoleSchematicFile*>* files;
std::unordered_map<std::wstring, ConsoleSchematicFile*>* files;
files = getLevelGenerationOptions()->getUnfinishedSchematicFiles();
dos->writeInt(files->size());
for (auto it = files->begin(); it != files->end(); it++) {
std::string filename = it->first;
std::wstring filename = it->first;
ConsoleSchematicFile* file = it->second;
ByteArrayOutputStream fileBaos;
@ -473,7 +473,7 @@ bool GameRuleManager::readRuleFile(
compressedBuffer.data(), compressedSize); break; default:
app.DebugPrintf("Invalid compression
type %d found\n", compressionType);
assert(0);
__debugbreak();
[] decompressedBuffer.data(); dis.close(); bais.reset();
@ -488,7 +488,7 @@ bool GameRuleManager::readRuleFile(
// string lookup.
unsigned int numStrings = contentDis->readInt();
std::vector<std::string> tagsAndAtts;
std::vector<std::wstring> tagsAndAtts;
for (unsigned int i = 0; i < numStrings; i++)
tagsAndAtts.push_back(contentDis->readUTF());
@ -525,7 +525,7 @@ bool GameRuleManager::readRuleFile(
// subfile
unsigned int numFiles = contentDis->readInt();
for (unsigned int i = 0; i < numFiles; i++) {
std::string sFilename = contentDis->readUTF();
std::wstring sFilename = contentDis->readUTF();
int length = contentDis->readInt();
std::vector<uint8_t> ba(length);
@ -550,13 +550,13 @@ bool GameRuleManager::readRuleFile(
if (tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions) {
rule = levelGenerator;
levelGenAdded = true;
// m_levelGenerators.addLevelGenerator("",levelGenerator);
// m_levelGenerators.addLevelGenerator(L"",levelGenerator);
lgoID = addLevelGenerationOptions(levelGenerator);
levelGenerator->loadStringTable(strings);
} else if (tagVal == ConsoleGameRules::eGameRuleType_LevelRules) {
rule = gameRules;
gameRulesAdded = true;
m_levelRules.addLevelRule("", gameRules);
m_levelRules.addLevelRule(L"", gameRules);
levelGenerator->setRequiredGameRules(gameRules);
gameRules->loadStringTable(strings);
}
@ -593,20 +593,20 @@ LevelGenerationOptions* GameRuleManager::readHeader(DLCGameRulesHeader* grh) {
}
void GameRuleManager::readAttributes(DataInputStream* dis,
std::vector<std::string>* tagsAndAtts,
std::vector<std::wstring>* tagsAndAtts,
GameRuleDefinition* rule) {
int numAttrs = dis->readInt();
for (unsigned int att = 0; att < static_cast<unsigned int>(numAttrs);
++att) {
int attID = dis->readInt();
std::string value = dis->readUTF();
std::wstring value = dis->readUTF();
if (rule != nullptr) rule->addAttribute(tagsAndAtts->at(attID), value);
}
}
void GameRuleManager::readChildren(
DataInputStream* dis, std::vector<std::string>* tagsAndAtts,
DataInputStream* dis, std::vector<std::wstring>* tagsAndAtts,
std::unordered_map<int, ConsoleGameRules::EGameRuleType>* tagIdMap,
GameRuleDefinition* rule) {
int numChildren = dis->readInt();
@ -643,23 +643,23 @@ void GameRuleManager::processSchematicsLighting(LevelChunk* levelChunk) {
void GameRuleManager::loadDefaultGameRules() {
#if !defined(__linux__)
#if defined(_WINDOWS64)
File packedTutorialFile("Windows64Media\\Tutorial\\Tutorial.pck");
File packedTutorialFile(L"Windows64Media\\Tutorial\\Tutorial.pck");
if (!packedTutorialFile.exists())
packedTutorialFile = File("Windows64\\Tutorial\\Tutorial.pck");
packedTutorialFile = File(L"Windows64\\Tutorial\\Tutorial.pck");
#else
File packedTutorialFile("Tutorial\\Tutorial.pck");
File packedTutorialFile(L"Tutorial\\Tutorial.pck");
#endif
if (loadGameRulesPack(&packedTutorialFile)) {
m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(
app.GetString(IDS_PLAY_TUTORIAL));
// m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName("Tutorial");
// m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(L"Tutorial");
m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(
app.GetString(IDS_TUTORIALSAVENAME));
}
#else
std::string fpTutorial = "Tutorial.pck";
std::wstring fpTutorial = L"Tutorial.pck";
if (app.getArchiveFileSize(fpTutorial) >= 0) {
DLCPack* pack = new DLCPack("", 0xffffffff);
DLCPack* pack = new DLCPack(L"", 0xffffffff);
uint32_t dwFilesProcessed = 0;
if (app.m_dlcManager.readDLCDataFile(dwFilesProcessed, fpTutorial, pack,
true)) {
@ -677,7 +677,7 @@ void GameRuleManager::loadDefaultGameRules() {
bool GameRuleManager::loadGameRulesPack(File* path) {
bool success = false;
if (path->exists()) {
DLCPack* pack = new DLCPack("", 0xffffffff);
DLCPack* pack = new DLCPack(L"", 0xffffffff);
unsigned int dwFilesProcessed = 0;
if (app.m_dlcManager.readDLCDataFile(dwFilesProcessed, path->getPath(),
pack)) {
@ -707,11 +707,11 @@ void GameRuleManager::setLevelGenerationOptions(
m_currentLevelGenerationOptions->reset_start();
}
const char* GameRuleManager::GetGameRulesString(const std::string& key) {
const wchar_t* GameRuleManager::GetGameRulesString(const std::wstring& key) {
if (m_currentGameRuleDefinitions != nullptr && !key.empty()) {
return m_currentGameRuleDefinitions->getString(key);
} else {
return "";
return L"";
}
}

View file

@ -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;
@ -27,7 +27,7 @@ class DLCGameRulesHeader;
class File;
class LevelRuleset;
#define GAME_RULE_SAVENAME "requiredGameRules.grf"
#define GAME_RULE_SAVENAME L"requiredGameRules.grf"
// 4J-JEV:
#define LEVEL_GEN_ID int
@ -35,8 +35,8 @@ class LevelRuleset;
class GameRuleManager {
public:
static const char* wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
static const char* wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
static const wchar_t* wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
static const wchar_t* wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
static const short version_number = 2;
@ -70,10 +70,10 @@ public:
private:
void readAttributes(DataInputStream* dis,
std::vector<std::string>* tagsAndAtts,
std::vector<std::wstring>* tagsAndAtts,
GameRuleDefinition* rule);
void readChildren(
DataInputStream* dis, std::vector<std::string>* tagsAndAtts,
DataInputStream* dis, std::vector<std::wstring>* tagsAndAtts,
std::unordered_map<int, ConsoleGameRules::EGameRuleType>* tagIdMap,
GameRuleDefinition* rule);
@ -98,7 +98,7 @@ public:
LevelGenerationOptions* getLevelGenerationOptions() {
return m_currentLevelGenerationOptions;
}
const char* GetGameRulesString(const std::string& key);
const wchar_t* GetGameRulesString(const std::wstring& key);
// 4J-JEV:
// Properly cleans-up and unloads the current set of gameRules.

View file

@ -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"
@ -65,8 +65,8 @@ void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream* dos,
}
void ApplySchematicRuleDefinition::addAttribute(
const std::string& attributeName, const std::string& attributeValue) {
if (attributeName.compare("filename") == 0) {
const std::wstring& attributeName, const std::wstring& attributeValue) {
if (attributeName.compare(L"filename") == 0) {
m_schematicName = attributeValue;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// filename=%s\n",m_schematicName.c_str());
@ -75,28 +75,28 @@ void ApplySchematicRuleDefinition::addAttribute(
if (m_schematicName
.substr(m_schematicName.length() - 4,
m_schematicName.length())
.compare(".sch") != 0) {
m_schematicName.append(".sch");
.compare(L".sch") != 0) {
m_schematicName.append(L".sch");
}
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
}
} else if (attributeName.compare("x") == 0) {
} else if (attributeName.compare(L"x") == 0) {
m_location.x = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.x)) % 2 != 0) m_location.x -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// x=%f\n",m_location->x);
} else if (attributeName.compare("y") == 0) {
} else if (attributeName.compare(L"y") == 0) {
m_location.y = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.y)) % 2 != 0) m_location.y -= 1;
if (m_location.y < 0) m_location.y = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// y=%f\n",m_location->y);
} else if (attributeName.compare("z") == 0) {
} else if (attributeName.compare(L"z") == 0) {
m_location.z = fromWString<int>(attributeValue);
if (((int)std::abs(m_location.z)) % 2 != 0) m_location.z -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// z=%f\n",m_location->z);
} else if (attributeName.compare("rot") == 0) {
} else if (attributeName.compare(L"rot") == 0) {
int degrees = fromWString<int>(attributeValue);
while (degrees < 0) degrees += 360;
@ -122,7 +122,7 @@ void ApplySchematicRuleDefinition::addAttribute(
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// rot=%d\n",m_rotation);
} else if (attributeName.compare("dim") == 0) {
} else if (attributeName.compare(L"dim") == 0) {
m_dimension = fromWString<int>(attributeValue);
if (m_dimension > 1 || m_dimension < -1) m_dimension = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
@ -173,7 +173,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
#ifdef _DEBUG
app.DebugPrintf("Applying schematic %s to chunk (%d,%d)\n",
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
m_schematicName.c_str(), chunk->x, chunk->z);
#endif
m_totalBlocksChanged += m_schematic->applyBlocksAndData(
@ -211,7 +211,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
std::min((double)Level::maxBuildHeight, m_locationBox->y1);
#ifdef _DEBUG
app.DebugPrintf("Applying schematic %s to chunk (%d,%d)\n",
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
m_schematicName.c_str(), chunk->x, chunk->z);
#endif
m_totalBlocksChangedLighting += m_schematic->applyLighting(

View file

@ -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"
@ -19,7 +19,7 @@ class GRFObject;
class ApplySchematicRuleDefinition : public GameRuleDefinition {
private:
LevelGenerationOptions* m_levelGenOptions;
std::string m_schematicName;
std::wstring m_schematicName;
ConsoleSchematicFile* m_schematic;
Vec3 m_location;
std::optional<AABB> m_locationBox;
@ -41,8 +41,8 @@ public:
}
virtual void writeAttributes(DataOutputStream* dos, unsigned int numAttrs);
virtual void addAttribute(const std::string& attributeName,
const std::string& attributeValue);
virtual void addAttribute(const std::wstring& attributeName,
const std::wstring& attributeValue);
void processSchematic(AABB* chunkBox, LevelChunk* chunk);
void processSchematicLighting(AABB* chunkBox, LevelChunk* chunk);
@ -52,7 +52,7 @@ public:
bool isComplete() { return m_completed; }
std::string getSchematicName() { return m_schematicName; }
std::wstring getSchematicName() { return m_schematicName; }
/** 4J-JEV:
* This GameRuleDefinition contains limited game state.

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