From 5f6481830263a056e66a9bb27ca1203675763708 Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Sat, 4 Apr 2026 14:47:39 +1100 Subject: [PATCH] refactor: eliminate app. calls from minecraft via Log, Strings, GameHostOptions, and service wiring --- targets/app/common/Game.cpp | 7 +- targets/app/common/GameMenuService.cpp | 58 ++ targets/app/common/GameMenuService.h | 54 ++ targets/app/linux/Linux_Minecraft.cpp | 152 +++- targets/minecraft/GameHostOptions.cpp | 185 +++++ targets/minecraft/GameHostOptions.h | 18 + targets/minecraft/GameServices.cpp | 654 ++++++++++++++++++ targets/minecraft/GameServices.h | 305 ++++++++ targets/minecraft/client/BufferedImage.cpp | 12 +- targets/minecraft/client/IMenuService.h | 66 ++ targets/minecraft/client/Minecraft.cpp | 138 ++-- targets/minecraft/client/Options.cpp | 3 +- .../client/gui/CreateWorldScreen.cpp | 43 +- targets/minecraft/client/gui/Gui.cpp | 30 +- targets/minecraft/client/gui/PauseScreen.cpp | 7 +- targets/minecraft/client/gui/Screen.cpp | 3 +- .../client/gui/SelectWorldScreen.cpp | 9 +- .../gui/inventory/AbstractContainerScreen.cpp | 3 +- .../gui/inventory/BeaconPowerButton.cpp | 3 +- .../gui/inventory/CreativeInventoryScreen.cpp | 5 +- .../minecraft/client/model/HumanoidModel.cpp | 5 +- .../client/multiplayer/ClientConnection.cpp | 407 +++++------ .../multiplayer/MultiPlayerGameMode.cpp | 5 +- .../client/multiplayer/MultiPlayerLevel.cpp | 5 +- .../multiplayer/MultiPlayerLocalPlayer.cpp | 12 +- targets/minecraft/client/player/Input.cpp | 14 +- .../minecraft/client/player/LocalPlayer.cpp | 74 +- .../minecraft/client/player/RemotePlayer.cpp | 3 +- .../client/renderer/GameRenderer.cpp | 16 +- .../client/renderer/ItemInHandRenderer.cpp | 8 +- .../client/renderer/LevelRenderer.cpp | 39 +- .../minecraft/client/renderer/Tesselator.cpp | 3 +- .../minecraft/client/renderer/Textures.cpp | 7 +- .../entity/EntityRenderDispatcher.cpp | 3 +- .../renderer/entity/LivingEntityRenderer.cpp | 14 +- .../client/renderer/entity/PlayerRenderer.cpp | 6 +- .../texture/PreStitchedTextureMap.cpp | 9 +- .../client/renderer/texture/Stitcher.cpp | 3 +- .../client/renderer/texture/Texture.cpp | 3 +- .../renderer/texture/TextureManager.cpp | 3 +- .../client/renderer/texture/TextureMap.cpp | 3 +- .../renderer/tileentity/SignRenderer.cpp | 5 +- .../client/skins/AbstractTexturePack.cpp | 17 +- .../minecraft/client/skins/DLCTexturePack.cpp | 48 +- .../client/skins/DefaultTexturePack.cpp | 5 +- .../client/skins/DefaultTexturePack.h | 4 +- .../client/skins/TexturePackRepository.cpp | 24 +- .../minecraft/client/title/TitleScreen.cpp | 18 +- .../minecraft/commands/CommandDispatcher.cpp | 3 +- .../minecraft/core/ItemDispenseBehaviors.cpp | 3 +- targets/minecraft/locale/Strings.cpp | 16 + targets/minecraft/locale/Strings.h | 12 + .../packet/BlockRegionUpdatePacket.cpp | 5 +- .../network/packet/CustomPayloadPacket.cpp | 3 +- .../network/packet/GameCommandPacket.cpp | 3 +- .../minecraft/network/packet/LoginPacket.cpp | 3 +- targets/minecraft/network/packet/Packet.cpp | 9 +- .../network/packet/PreLoginPacket.cpp | 3 +- .../network/packet/RespawnPacket.cpp | 5 +- .../packet/ServerSettingsChangedPacket.cpp | 3 +- .../network/packet/SetPlayerTeamPacket.cpp | 5 +- targets/minecraft/server/MinecraftServer.cpp | 148 ++-- targets/minecraft/server/PlayerList.cpp | 75 +- .../minecraft/server/level/PlayerChunkMap.cpp | 11 +- .../server/level/ServerChunkCache.cpp | 15 +- .../minecraft/server/level/ServerLevel.cpp | 16 +- .../server/level/ServerLevelListener.cpp | 5 +- .../minecraft/server/level/ServerPlayer.cpp | 70 +- .../server/level/ServerPlayerGameMode.cpp | 3 +- .../minecraft/server/level/TrackedEntity.cpp | 9 +- .../server/network/PendingConnection.cpp | 10 +- .../server/network/PlayerConnection.cpp | 108 +-- .../server/network/ServerConnection.cpp | 6 +- targets/minecraft/stats/Stat.h | 3 +- targets/minecraft/stats/StatsCounter.cpp | 11 +- targets/minecraft/stdafx.h | 10 - targets/minecraft/util/DebugSettings.cpp | 33 + targets/minecraft/util/DebugSettings.h | 20 + targets/minecraft/util/HtmlString.cpp | 4 +- targets/minecraft/util/Log.h | 15 + targets/minecraft/world/CompoundContainer.cpp | 3 +- targets/minecraft/world/SimpleContainer.cpp | 3 +- .../world/effect/MobEffectInstance.cpp | 3 +- targets/minecraft/world/entity/Entity.cpp | 12 +- targets/minecraft/world/entity/EntityIO.cpp | 3 +- .../minecraft/world/entity/LivingEntity.cpp | 3 +- targets/minecraft/world/entity/Painting.cpp | 3 +- .../world/entity/SyncedEntityData.cpp | 3 +- .../ai/attributes/AttributeModifier.cpp | 3 +- .../world/entity/animal/EntityHorse.cpp | 5 +- .../minecraft/world/entity/animal/Ocelot.cpp | 3 +- .../entity/boss/enderdragon/EnderDragon.cpp | 91 +-- .../entity/boss/enderdragon/EnderDragon.h | 4 +- .../world/entity/boss/wither/WitherBoss.h | 4 +- .../world/entity/item/ItemEntity.cpp | 3 +- .../world/entity/item/MinecartContainer.cpp | 3 +- .../world/entity/monster/EnderMan.cpp | 3 +- .../world/entity/monster/Monster.cpp | 3 +- .../world/entity/monster/PigZombie.cpp | 3 +- .../monster/SharedMonsterAttributes.cpp | 3 +- .../world/entity/monster/Silverfish.cpp | 3 +- .../minecraft/world/entity/monster/Spider.cpp | 3 +- .../minecraft/world/entity/npc/Villager.cpp | 3 +- .../world/entity/player/Inventory.cpp | 10 +- .../minecraft/world/entity/player/Player.cpp | 79 ++- .../world/entity/projectile/Arrow.cpp | 3 +- .../world/entity/projectile/Fireball.cpp | 11 +- .../minecraft/world/inventory/AnvilMenu.cpp | 31 +- targets/minecraft/world/item/BucketItem.cpp | 5 +- targets/minecraft/world/item/EnderEyeItem.cpp | 5 +- .../world/item/FireworksChargeItem.cpp | 19 +- .../minecraft/world/item/FireworksItem.cpp | 3 +- .../world/item/HangingEntityItem.cpp | 5 +- targets/minecraft/world/item/Item.cpp | 10 +- .../minecraft/world/item/PlanterTileItem.cpp | 5 +- targets/minecraft/world/item/PotionItem.cpp | 23 +- targets/minecraft/world/item/SpawnEggItem.cpp | 8 +- targets/minecraft/world/item/TileItem.cpp | 10 +- .../minecraft/world/item/crafting/Recipes.cpp | 3 +- .../world/item/crafting/ShapedRecipy.cpp | 3 +- .../world/item/enchantment/Enchantment.cpp | 15 +- targets/minecraft/world/level/Explosion.cpp | 5 +- targets/minecraft/world/level/GameRules.cpp | 17 +- targets/minecraft/world/level/Level.cpp | 12 +- .../minecraft/world/level/PortalForcer.cpp | 13 +- .../world/level/biome/BiomeCache.cpp | 5 +- .../world/level/biome/BiomeDecorator.cpp | 3 +- .../world/level/biome/BiomeSource.cpp | 10 +- .../world/level/chunk/LevelChunk.cpp | 13 +- .../storage/ChunkStorageProfileDecorator.cpp | 5 +- .../chunk/storage/McRegionChunkStorage.cpp | 14 +- .../level/chunk/storage/OldChunkStorage.cpp | 16 +- .../world/level/chunk/storage/RegionFile.cpp | 3 +- .../level/chunk/storage/ZonedChunkStorage.cpp | 3 +- .../world/level/dimension/Dimension.cpp | 12 +- .../world/level/dimension/HellDimension.cpp | 5 +- .../world/level/levelgen/CanyonFeature.cpp | 3 +- .../level/levelgen/CustomLevelSource.cpp | 16 +- .../world/level/levelgen/FlatLevelSource.cpp | 3 +- .../level/levelgen/HellFlatLevelSource.cpp | 3 +- .../level/levelgen/HellRandomLevelSource.cpp | 3 +- .../level/levelgen/RandomLevelSource.cpp | 5 +- .../levelgen/TheEndLevelRandomLevelSource.cpp | 3 +- .../levelgen/feature/BasicTreeFeature.cpp | 8 +- .../level/levelgen/feature/BirchFeature.cpp | 8 +- .../level/levelgen/feature/CaveFeature.cpp | 8 +- .../level/levelgen/feature/FlowerFeature.cpp | 8 +- .../level/levelgen/feature/LakeFeature.cpp | 8 +- .../levelgen/feature/MegaTreeFeature.cpp | 8 +- .../level/levelgen/feature/OreFeature.cpp | 8 +- .../level/levelgen/feature/PineFeature.cpp | 8 +- .../level/levelgen/feature/ReedsFeature.cpp | 8 +- .../level/levelgen/feature/SandFeature.cpp | 8 +- .../level/levelgen/feature/SpikeFeature.cpp | 7 +- .../level/levelgen/feature/SpringFeature.cpp | 8 +- .../level/levelgen/feature/SpruceFeature.cpp | 8 +- .../levelgen/feature/SwampTreeFeature.cpp | 8 +- .../level/levelgen/feature/TreeFeature.cpp | 8 +- .../levelgen/structure/MineShaftFeature.cpp | 5 +- .../structure/NetherBridgeFeature.cpp | 3 +- .../structure/RandomScatteredLargeFeature.cpp | 3 +- .../structure/ScatteredFeaturePieces.cpp | 3 +- .../levelgen/structure/StrongholdFeature.cpp | 10 +- .../levelgen/structure/StrongholdPieces.cpp | 3 +- .../levelgen/structure/StructureFeatureIO.cpp | 5 +- .../levelgen/structure/VillageFeature.cpp | 8 +- .../newbiome/layer/BiomeOverrideLayer.cpp | 9 +- .../world/level/newbiome/layer/Layer.cpp | 5 +- .../ConsoleSaveFileOriginal.cpp | 32 +- .../ConsoleSaveFileSplit.cpp | 46 +- .../storage/ConsoleSaveFileIO/FileHeader.cpp | 15 +- .../level/storage/DirectoryLevelStorage.cpp | 49 +- .../world/level/storage/LevelData.cpp | 12 +- .../level/storage/McRegionLevelStorage.cpp | 6 +- .../minecraft/world/level/tile/FireTile.cpp | 5 +- .../world/level/tile/NotGateTile.cpp | 5 +- .../world/level/tile/NoteBlockTile.cpp | 7 +- .../world/level/tile/StoneMonsterTile.cpp | 3 +- targets/minecraft/world/level/tile/Tile.cpp | 5 +- .../minecraft/world/level/tile/TntTile.cpp | 9 +- .../level/tile/entity/BeaconTileEntity.cpp | 3 +- .../tile/entity/BrewingStandTileEntity.cpp | 3 +- .../level/tile/entity/ChestTileEntity.cpp | 3 +- .../level/tile/entity/DispenserTileEntity.cpp | 3 +- .../level/tile/entity/DropperTileEntity.cpp | 3 +- .../entity/EnchantmentTableTileEntity.cpp | 3 +- .../level/tile/entity/FurnaceTileEntity.cpp | 3 +- .../level/tile/entity/HopperTileEntity.cpp | 3 +- .../level/tile/entity/TheEndPortalTile.cpp | 5 +- .../world/level/tile/entity/TileEntity.cpp | 3 +- 190 files changed, 2987 insertions(+), 1165 deletions(-) create mode 100644 targets/app/common/GameMenuService.cpp create mode 100644 targets/app/common/GameMenuService.h create mode 100644 targets/minecraft/GameHostOptions.cpp create mode 100644 targets/minecraft/GameHostOptions.h create mode 100644 targets/minecraft/GameServices.cpp create mode 100644 targets/minecraft/GameServices.h create mode 100644 targets/minecraft/client/IMenuService.h create mode 100644 targets/minecraft/locale/Strings.cpp create mode 100644 targets/minecraft/locale/Strings.h create mode 100644 targets/minecraft/util/DebugSettings.cpp create mode 100644 targets/minecraft/util/DebugSettings.h create mode 100644 targets/minecraft/util/Log.h diff --git a/targets/app/common/Game.cpp b/targets/app/common/Game.cpp index 490cdfed7..e479d3944 100644 --- a/targets/app/common/Game.cpp +++ b/targets/app/common/Game.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameHostOptions.h" #include "app/common/Game.h" #include "platform/PlatformTypes.h" @@ -118,6 +119,8 @@ int Game::s_iHTMLFontSizesA[eHTMLSize_COUNT] = { 20, 13, 20, 26}; Game::Game() { + GameHostOptions::init(&m_uiGameHostSettings); + if (GAME_SETTINGS_PROFILE_DATA_BYTES != sizeof(GAME_SETTINGS)) { // 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES in // Xbox_App.h @@ -5797,7 +5800,7 @@ SCreditTextItemDef* Game::GetDLCCredits(int iIndex) { void Game::SetGameHostOption(eGameHostOption eVal, unsigned int uiVal) { - SetGameHostOption(m_uiGameHostSettings, eVal, uiVal); + GameHostOptions::set(eVal, uiVal); } void Game::SetGameHostOption(unsigned int& uiHostSettings, @@ -6036,7 +6039,7 @@ void Game::SetGameHostOption(unsigned int& uiHostSettings, } unsigned int Game::GetGameHostOption(eGameHostOption eVal) { - return GetGameHostOption(m_uiGameHostSettings, eVal); + return GameHostOptions::get(eVal); } unsigned int Game::GetGameHostOption(unsigned int uiHostSettings, diff --git a/targets/app/common/GameMenuService.cpp b/targets/app/common/GameMenuService.cpp new file mode 100644 index 000000000..3b4305841 --- /dev/null +++ b/targets/app/common/GameMenuService.cpp @@ -0,0 +1,58 @@ +#include "app/common/GameMenuService.h" + +#include "app/common/Game.h" + +bool GameMenuService::openInventory(int iPad, std::shared_ptr player, bool navigateBack) { + return game_.LoadInventoryMenu(iPad, player, navigateBack); +} +bool GameMenuService::openCreative(int iPad, std::shared_ptr player, bool navigateBack) { + return game_.LoadCreativeMenu(iPad, player, navigateBack); +} +bool GameMenuService::openCrafting2x2(int iPad, std::shared_ptr player) { + return game_.LoadCrafting2x2Menu(iPad, player); +} +bool GameMenuService::openCrafting3x3(int iPad, std::shared_ptr player, int x, int y, int z) { + return game_.LoadCrafting3x3Menu(iPad, player, x, y, z); +} +bool GameMenuService::openEnchanting(int iPad, std::shared_ptr inventory, int x, int y, int z, Level* level, const std::wstring& name) { + return game_.LoadEnchantingMenu(iPad, inventory, x, y, z, level, name); +} +bool GameMenuService::openFurnace(int iPad, std::shared_ptr inventory, std::shared_ptr furnace) { + return game_.LoadFurnaceMenu(iPad, inventory, furnace); +} +bool GameMenuService::openBrewingStand(int iPad, std::shared_ptr inventory, std::shared_ptr brewingStand) { + return game_.LoadBrewingStandMenu(iPad, inventory, brewingStand); +} +bool GameMenuService::openContainer(int iPad, std::shared_ptr inventory, std::shared_ptr container) { + return game_.LoadContainerMenu(iPad, inventory, container); +} +bool GameMenuService::openTrap(int iPad, std::shared_ptr inventory, std::shared_ptr trap) { + return game_.LoadTrapMenu(iPad, inventory, trap); +} +bool GameMenuService::openFireworks(int iPad, std::shared_ptr player, int x, int y, int z) { + return game_.LoadFireworksMenu(iPad, player, x, y, z); +} +bool GameMenuService::openSign(int iPad, std::shared_ptr sign) { + return game_.LoadSignEntryMenu(iPad, sign); +} +bool GameMenuService::openRepairing(int iPad, std::shared_ptr 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, std::shared_ptr trader, Level* level, const std::wstring& name) { + return game_.LoadTradingMenu(iPad, inventory, trader, level, name); +} +bool GameMenuService::openCommandBlock(int iPad, std::shared_ptr commandBlock) { + return game_.LoadCommandBlockMenu(iPad, commandBlock); +} +bool GameMenuService::openHopper(int iPad, std::shared_ptr inventory, std::shared_ptr hopper) { + return game_.LoadHopperMenu(iPad, inventory, hopper); +} +bool GameMenuService::openHopperMinecart(int iPad, std::shared_ptr inventory, std::shared_ptr hopper) { + return game_.LoadHopperMenu(iPad, inventory, hopper); +} +bool GameMenuService::openHorse(int iPad, std::shared_ptr inventory, std::shared_ptr container, std::shared_ptr horse) { + return game_.LoadHorseMenu(iPad, inventory, container, horse); +} +bool GameMenuService::openBeacon(int iPad, std::shared_ptr inventory, std::shared_ptr beacon) { + return game_.LoadBeaconMenu(iPad, inventory, beacon); +} diff --git a/targets/app/common/GameMenuService.h b/targets/app/common/GameMenuService.h new file mode 100644 index 000000000..cb056da7e --- /dev/null +++ b/targets/app/common/GameMenuService.h @@ -0,0 +1,54 @@ +#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 player, + bool navigateBack) override; + bool openCreative(int iPad, std::shared_ptr player, + bool navigateBack) override; + bool openCrafting2x2(int iPad, + std::shared_ptr player) override; + bool openCrafting3x3(int iPad, std::shared_ptr player, int x, + int y, int z) override; + bool openEnchanting(int iPad, std::shared_ptr inventory, int x, + int y, int z, Level* level, + const std::wstring& name) override; + bool openFurnace(int iPad, std::shared_ptr inventory, + std::shared_ptr furnace) override; + bool openBrewingStand( + int iPad, std::shared_ptr inventory, + std::shared_ptr brewingStand) override; + bool openContainer(int iPad, std::shared_ptr inventory, + std::shared_ptr container) override; + bool openTrap(int iPad, std::shared_ptr inventory, + std::shared_ptr trap) override; + bool openFireworks(int iPad, std::shared_ptr player, int x, + int y, int z) override; + bool openSign(int iPad, std::shared_ptr sign) override; + bool openRepairing(int iPad, std::shared_ptr inventory, + Level* level, int x, int y, int z) override; + bool openTrading(int iPad, std::shared_ptr inventory, + std::shared_ptr trader, Level* level, + const std::wstring& name) override; + bool openCommandBlock( + int iPad, std::shared_ptr commandBlock) override; + bool openHopper(int iPad, std::shared_ptr inventory, + std::shared_ptr hopper) override; + bool openHopperMinecart( + int iPad, std::shared_ptr inventory, + std::shared_ptr hopper) override; + bool openHorse(int iPad, std::shared_ptr inventory, + std::shared_ptr container, + std::shared_ptr horse) override; + bool openBeacon(int iPad, std::shared_ptr inventory, + std::shared_ptr beacon) override; + +private: + Game& game_; +}; diff --git a/targets/app/linux/Linux_Minecraft.cpp b/targets/app/linux/Linux_Minecraft.cpp index 01b1b4c1c..d04f53533 100644 --- a/targets/app/linux/Linux_Minecraft.cpp +++ b/targets/app/linux/Linux_Minecraft.cpp @@ -1,3 +1,7 @@ +#include "app/common/GameMenuService.h" +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/locale/Strings.h" // Minecraft.cpp : Defines the entry point for the application. // @@ -451,7 +455,153 @@ int main(int argc, const char* argv[]) { app.loadMediaArchive(); app.loadStringTable(); - // fuck you + Strings::init([](int id) { return app.GetString(id); }); + DebugSettings::init( + [] { return app.DebugSettingsOn(); }, + [] { return app.DebugArtToolsOn(); }, + [](int iPad, bool overridePlayer) { + return app.GetGameSettingsDebugMask(iPad, overridePlayer); + }, + [] { return app.GetMobsDontAttackEnabled(); }, + [] { return app.GetMobsDontTickEnabled(); }, + [] { return app.GetFreezePlayers(); }); + GameServices::initLevelGen( + [] { return app.getLevelGenerationOptions(); }, + [] { return app.getGameRuleDefinitions(); }); + GameServices::initTextureCache( + [](const std::wstring& n, std::uint8_t* d, unsigned int s) { + app.AddMemoryTextureFile(n, d, s); + }, + [](const std::wstring& n) { app.RemoveMemoryTextureFile(n); }, + [](const std::wstring& n, std::uint8_t** d, unsigned int* s) { + app.GetMemFileDetails(n, d, s); + }, + [](const std::wstring& n) { return app.IsFileInMemoryTextures(n); }); + GameServices::initPlayerSettings( + [](int iPad, int s) { + return app.GetGameSettings(iPad, static_cast(s)); + }, + [](int s) { + return app.GetGameSettings(static_cast(s)); + }); + GameServices::initAppTime([] { return app.getAppTime(); }); + GameServices::initGameState( + [] { return app.GetGameStarted(); }, + [](bool v) { app.SetGameStarted(v); }, + [] { return app.GetTutorialMode(); }, + [](bool v) { app.SetTutorialMode(v); }, + [] { return app.IsAppPaused(); }, + [] { return app.GetLocalPlayerCount(); }, + [] { return app.AutosaveDue(); }, + [] { app.SetAutosaveTimerTime(); }, + [] { return app.SecondsToAutosave(); }, + [](DisconnectPacket::eDisconnectReason r) { app.SetDisconnectReason(r); }, + [] { app.lockSaveNotification(); }, + [] { app.unlockSaveNotification(); }, + [] { return app.GetResetNether(); }, + [] { return app.GetUseDPadForDebug(); }, + [] { return app.GetWriteSavesToFolderEnabled(); }, + [] { return app.IsLocalMultiplayerAvailable(); }, + [] { return app.DLCInstallPending(); }, + [] { return app.DLCInstallProcessCompleted(); }, + [] { return app.CanRecordStatsAndAchievements(); }, + [] { return app.GetTMSGlobalFileListRead(); }, + [](std::uint32_t id) { app.SetRequiredTexturePackID(id); }, + [](int iPad, int idx) { app.SetSpecialTutorialCompletionFlag(iPad, idx); }, + [](int iPad, bool v) { app.SetBanListCheck(iPad, v); }, + [](int iPad) { return app.GetBanListCheck(iPad); }, + [] { return app.GetGameNewWorldSize(); }, + [] { return app.GetGameNewWorldSizeUseMoat(); }, + [] { return app.GetGameNewHellScale(); } + ); + GameServices::initUIDispatch( + [](int iPad, eXuiAction a, void* p) { app.SetAction(iPad, a, p); }, + [](int iPad, eXuiServerAction a, void* p) { app.SetXuiServerAction(iPad, a, p); }, + [](int iPad) { return app.GetXuiAction(iPad); }, + [](int iPad) { return app.GetXuiServerAction(iPad); }, + [](int iPad) { return app.GetXuiServerActionParam(iPad); }, + [](eXuiAction a) { app.SetGlobalXuiAction(a); }, + [] { app.HandleButtonPresses(); }, + [](int iPad, eTMSAction a) { app.SetTMSAction(iPad, a); } + ); + GameServices::initSkinCape( + [](int iPad) { return app.GetPlayerSkinName(iPad); }, + [](int iPad) { return app.GetPlayerSkinId(iPad); }, + [](int iPad) { return app.GetPlayerCapeName(iPad); }, + [](int iPad) { return app.GetPlayerCapeId(iPad); }, + [](int iPad) { return app.GetAdditionalModelParts(iPad); }, + [](std::uint32_t id, SKIN_BOX* a, unsigned int c) { + app.SetAdditionalSkinBoxes(id, a, c); + }, + [](std::uint32_t id) { return app.GetAdditionalSkinBoxes(id); }, + [](std::uint32_t id) { return app.GetAdditionalModelParts(id); }, + [](std::uint32_t id, std::vector* v) { + return app.SetAdditionalSkinBoxes(id, v); + }, + [](std::uint32_t id, unsigned int m) { app.SetAnimOverrideBitmask(id, m); }, + [](std::uint32_t id) { return app.GetAnimOverrideBitmask(id); }, + [](const std::wstring& s) { return Game::getSkinIdFromPath(s); }, + [](std::uint32_t id) { return Game::getSkinPathFromId(id); }, + [] { return app.DefaultCapeExists(); }, + [](PlayerUID x) { return app.isXuidNotch(x); }, + [](PlayerUID x) { return app.isXuidDeadmau5(x); } + ); + GameServices::initPlatformFeatures( + [] { app.FatalLoadError(); }, + [](int iPad, int ctx) { app.SetRichPresenceContext(iPad, ctx); }, + [] { app.CaptureSaveThumbnail(); }, + [](std::uint8_t** d, unsigned int* s) { app.GetSaveThumbnail(d, s); }, + [](int iPad, eTMSAction a, bool cb) { app.ReadBannedList(iPad, a, cb); }, + [](std::uint8_t id, int16_t col, unsigned int priv) { + app.UpdatePlayerInfo(id, col, priv); + }, + [](std::uint8_t id) { return app.GetPlayerPrivileges(id); }, + [](int iPad, unsigned int v) { app.SetGameSettingsDebugMask(iPad, v); } + ); + GameServices::initSchematics( + [](LevelChunk* c) { app.processSchematics(c); }, + [](LevelChunk* c) { app.processSchematicsLighting(c); }, + [](_eTerrainFeatureType t, int x, int z) { + app.AddTerrainFeaturePosition(t, x, z); + }, + [](_eTerrainFeatureType t, int* x, int* z) { + return app.GetTerrainFeaturePosition(t, x, z); + }, + [] { app.loadDefaultGameRules(); } + ); + GameServices::initArchive( + [](const std::wstring& f) { return app.hasArchiveFile(f); }, + [](const std::wstring& f) { return app.getArchiveFile(f); } + ); + GameServices::initStringsAndMisc( + [](eMinecraftColour c) { return app.GetHTMLColour(c); }, + [](int type) { return app.getEntityName(static_cast(type)); }, + [](const std::wstring& k) { return app.GetGameRulesString(k); }, + [](std::uint8_t* m, int64_t s, bool h, unsigned int ho, unsigned int tp) { + return app.CreateImageTextData(m, s, h, ho, tp); + }, + [](std::uint32_t p, std::wstring f, bool a, std::wstring mp) { + return app.getFilePath(p, f, a, mp); + }, + [] { return app.GetUniqueMapName(); }, + [](char* n) { app.SetUniqueMapName(n); }, + [](int iPad) { return app.GetOpacityTimer(iPad); }, + [](int iPad) { app.SetOpacityTimer(iPad); }, + [](int iPad) { app.TickOpacityTimer(iPad); }, + [](int iPad, PlayerUID x, char* n) { + return app.IsInBannedLevelList(iPad, x, n); + }, + [](PlayerUID x) { return app.GetMojangDataForXuid(x); }, + [](const char* msg) { app.DebugPrintf("%s", msg); } + ); + GameServices::initMemberAccess( + &app.m_dlcManager, + &app.m_gameRules, + &app.vSkinNames, + &app.m_vTerrainFeatures + ); + static GameMenuService menuService(app); + GameServices::initMenuService(&menuService); ui.init(1920, 1080); // storage manager is needed for the trial key check StorageManager.Init( diff --git a/targets/minecraft/GameHostOptions.cpp b/targets/minecraft/GameHostOptions.cpp new file mode 100644 index 000000000..74c9fcd01 --- /dev/null +++ b/targets/minecraft/GameHostOptions.cpp @@ -0,0 +1,185 @@ +#include "minecraft/GameHostOptions.h" + +#include + +namespace GameHostOptions { + +static unsigned int* s_settings = nullptr; + +void init(unsigned int* settingsPtr) { + s_settings = settingsPtr; +} + +unsigned int get(eGameHostOption option) { + assert(s_settings); + return get(*s_settings, option); +} + +void set(eGameHostOption option, unsigned int value) { + assert(s_settings); + set(*s_settings, option, value); +} + +unsigned int get(unsigned int settings, eGameHostOption option) { + switch (option) { + case eGameHostOption_FriendsOfFriends: + return (settings & GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS); + case eGameHostOption_Difficulty: + return (settings & GAME_HOST_OPTION_BITMASK_DIFFICULTY); + case eGameHostOption_Gamertags: + return (settings & GAME_HOST_OPTION_BITMASK_GAMERTAGS); + case eGameHostOption_GameType: + return (settings & GAME_HOST_OPTION_BITMASK_GAMETYPE) >> 4; + case eGameHostOption_All: + return (settings & GAME_HOST_OPTION_BITMASK_ALL); + case eGameHostOption_Tutorial: + return ((settings & GAME_HOST_OPTION_BITMASK_GAMERTAGS) | + GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS | + GAME_HOST_OPTION_BITMASK_FIRESPREADS | + GAME_HOST_OPTION_BITMASK_TNT | + GAME_HOST_OPTION_BITMASK_PVP | + GAME_HOST_OPTION_BITMASK_STRUCTURES | 1); + case eGameHostOption_LevelType: + return (settings & GAME_HOST_OPTION_BITMASK_LEVELTYPE); + case eGameHostOption_Structures: + return (settings & GAME_HOST_OPTION_BITMASK_STRUCTURES); + case eGameHostOption_BonusChest: + return (settings & GAME_HOST_OPTION_BITMASK_BONUSCHEST); + case eGameHostOption_HasBeenInCreative: + return (settings & GAME_HOST_OPTION_BITMASK_BEENINCREATIVE); + case eGameHostOption_PvP: + return (settings & GAME_HOST_OPTION_BITMASK_PVP); + case eGameHostOption_TrustPlayers: + return (settings & GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS); + case eGameHostOption_TNT: + return (settings & GAME_HOST_OPTION_BITMASK_TNT); + case eGameHostOption_FireSpreads: + return (settings & GAME_HOST_OPTION_BITMASK_FIRESPREADS); + case eGameHostOption_CheatsEnabled: + return (settings & (GAME_HOST_OPTION_BITMASK_HOSTFLY | + GAME_HOST_OPTION_BITMASK_HOSTHUNGER | + GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE)); + case eGameHostOption_HostCanFly: + return (settings & GAME_HOST_OPTION_BITMASK_HOSTFLY); + case eGameHostOption_HostCanChangeHunger: + return (settings & GAME_HOST_OPTION_BITMASK_HOSTHUNGER); + case eGameHostOption_HostCanBeInvisible: + return (settings & GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE); + case eGameHostOption_BedrockFog: + return (settings & GAME_HOST_OPTION_BITMASK_BEDROCKFOG); + case eGameHostOption_DisableSaving: + return (settings & GAME_HOST_OPTION_BITMASK_DISABLESAVE); + case eGameHostOption_WasntSaveOwner: + return (settings & GAME_HOST_OPTION_BITMASK_NOTOWNER); + case eGameHostOption_WorldSize: + return (settings & GAME_HOST_OPTION_BITMASK_WORLDSIZE) >> + GAME_HOST_OPTION_BITMASK_WORLDSIZE_BITSHIFT; + case eGameHostOption_MobGriefing: + return !(settings & GAME_HOST_OPTION_BITMASK_MOBGRIEFING); + case eGameHostOption_KeepInventory: + return (settings & GAME_HOST_OPTION_BITMASK_KEEPINVENTORY); + case eGameHostOption_DoMobSpawning: + return !(settings & GAME_HOST_OPTION_BITMASK_DOMOBSPAWNING); + case eGameHostOption_DoMobLoot: + return !(settings & GAME_HOST_OPTION_BITMASK_DOMOBLOOT); + case eGameHostOption_DoTileDrops: + return !(settings & GAME_HOST_OPTION_BITMASK_DOTILEDROPS); + case eGameHostOption_NaturalRegeneration: + return !(settings & GAME_HOST_OPTION_BITMASK_NATURALREGEN); + case eGameHostOption_DoDaylightCycle: + return !(settings & GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE); + default: + return 0; + } +} + +void set(unsigned int& settings, eGameHostOption option, unsigned int value) { + auto setBit = [&](unsigned int mask) { + if (value != 0) + settings |= mask; + else + settings &= ~mask; + }; + auto setInvertedBit = [&](unsigned int mask) { + if (value != 1) + settings |= mask; + else + settings &= ~mask; + }; + + switch (option) { + case eGameHostOption_FriendsOfFriends: + setBit(GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS); break; + case eGameHostOption_Difficulty: + settings &= ~GAME_HOST_OPTION_BITMASK_DIFFICULTY; + settings |= (GAME_HOST_OPTION_BITMASK_DIFFICULTY & value); break; + case eGameHostOption_Gamertags: + setBit(GAME_HOST_OPTION_BITMASK_GAMERTAGS); break; + case eGameHostOption_GameType: + settings &= ~GAME_HOST_OPTION_BITMASK_GAMETYPE; + settings |= (GAME_HOST_OPTION_BITMASK_GAMETYPE & (value << 4)); break; + case eGameHostOption_LevelType: + setBit(GAME_HOST_OPTION_BITMASK_LEVELTYPE); break; + case eGameHostOption_Structures: + setBit(GAME_HOST_OPTION_BITMASK_STRUCTURES); break; + case eGameHostOption_BonusChest: + setBit(GAME_HOST_OPTION_BITMASK_BONUSCHEST); break; + case eGameHostOption_HasBeenInCreative: + setBit(GAME_HOST_OPTION_BITMASK_BEENINCREATIVE); break; + case eGameHostOption_PvP: + setBit(GAME_HOST_OPTION_BITMASK_PVP); break; + case eGameHostOption_TrustPlayers: + setBit(GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS); break; + case eGameHostOption_TNT: + setBit(GAME_HOST_OPTION_BITMASK_TNT); break; + case eGameHostOption_FireSpreads: + setBit(GAME_HOST_OPTION_BITMASK_FIRESPREADS); break; + case eGameHostOption_CheatsEnabled: + if (value != 0) { + settings |= GAME_HOST_OPTION_BITMASK_HOSTFLY; + settings |= GAME_HOST_OPTION_BITMASK_HOSTHUNGER; + settings |= GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE; + } else { + settings &= ~GAME_HOST_OPTION_BITMASK_HOSTFLY; + settings &= ~GAME_HOST_OPTION_BITMASK_HOSTHUNGER; + settings &= ~GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE; + } break; + case eGameHostOption_HostCanFly: + setBit(GAME_HOST_OPTION_BITMASK_HOSTFLY); break; + case eGameHostOption_HostCanChangeHunger: + setBit(GAME_HOST_OPTION_BITMASK_HOSTHUNGER); break; + case eGameHostOption_HostCanBeInvisible: + setBit(GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE); break; + case eGameHostOption_BedrockFog: + setBit(GAME_HOST_OPTION_BITMASK_BEDROCKFOG); break; + case eGameHostOption_DisableSaving: + setBit(GAME_HOST_OPTION_BITMASK_DISABLESAVE); break; + case eGameHostOption_WasntSaveOwner: + setBit(GAME_HOST_OPTION_BITMASK_NOTOWNER); break; + case eGameHostOption_MobGriefing: + setInvertedBit(GAME_HOST_OPTION_BITMASK_MOBGRIEFING); break; + case eGameHostOption_KeepInventory: + setBit(GAME_HOST_OPTION_BITMASK_KEEPINVENTORY); break; + case eGameHostOption_DoMobSpawning: + setInvertedBit(GAME_HOST_OPTION_BITMASK_DOMOBSPAWNING); break; + case eGameHostOption_DoMobLoot: + setInvertedBit(GAME_HOST_OPTION_BITMASK_DOMOBLOOT); break; + case eGameHostOption_DoTileDrops: + setInvertedBit(GAME_HOST_OPTION_BITMASK_DOTILEDROPS); break; + case eGameHostOption_NaturalRegeneration: + setInvertedBit(GAME_HOST_OPTION_BITMASK_NATURALREGEN); break; + case eGameHostOption_DoDaylightCycle: + setInvertedBit(GAME_HOST_OPTION_BITMASK_DODAYLIGHTCYCLE); break; + case eGameHostOption_WorldSize: + settings &= ~GAME_HOST_OPTION_BITMASK_WORLDSIZE; + settings |= (GAME_HOST_OPTION_BITMASK_WORLDSIZE & + (value << GAME_HOST_OPTION_BITMASK_WORLDSIZE_BITSHIFT)); + break; + case eGameHostOption_All: + settings = value; break; + default: + break; + } +} + +} // namespace GameHostOptions diff --git a/targets/minecraft/GameHostOptions.h b/targets/minecraft/GameHostOptions.h new file mode 100644 index 000000000..6aca553b8 --- /dev/null +++ b/targets/minecraft/GameHostOptions.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include "app/common/App_Defines.h" +#include "app/common/App_enums.h" + +namespace GameHostOptions { + +unsigned int get(unsigned int settings, eGameHostOption option); +void set(unsigned int& settings, eGameHostOption option, unsigned int value); + +// Global game settings - initialized by app layer at startup +void init(unsigned int* settingsPtr); +unsigned int get(eGameHostOption option); +void set(eGameHostOption option, unsigned int value); + +} // namespace GameHostOptions diff --git a/targets/minecraft/GameServices.cpp b/targets/minecraft/GameServices.cpp new file mode 100644 index 000000000..4ec90720b --- /dev/null +++ b/targets/minecraft/GameServices.cpp @@ -0,0 +1,654 @@ +#include "minecraft/GameServices.h" + +#include + +namespace GameServices { + +// Level generation + +static LevelGenOptsFn s_levelGenOpts = nullptr; +static GameRuleDefsFn s_gameRuleDefs = nullptr; + +void initLevelGen(LevelGenOptsFn levelGenOpts, GameRuleDefsFn gameRuleDefs) { + s_levelGenOpts = levelGenOpts; + s_gameRuleDefs = gameRuleDefs; +} + +LevelGenerationOptions* getLevelGenerationOptions() { + assert(s_levelGenOpts); + return s_levelGenOpts(); +} + +LevelRuleset* getGameRuleDefinitions() { + assert(s_gameRuleDefs); + return s_gameRuleDefs(); +} + +// Texture cache + +static AddTexFn s_addTex = nullptr; +static RemoveTexFn s_removeTex = nullptr; +static GetTexDetailsFn s_getTexDetails = nullptr; +static HasTexFn s_hasTex = nullptr; + +void initTextureCache(AddTexFn add, RemoveTexFn remove, + GetTexDetailsFn getDetails, HasTexFn has) { + s_addTex = add; + s_removeTex = remove; + s_getTexDetails = getDetails; + s_hasTex = has; +} + +void addMemoryTextureFile(const std::wstring& name, std::uint8_t* data, + unsigned int size) { + if (s_addTex) s_addTex(name, data, size); +} + +void removeMemoryTextureFile(const std::wstring& name) { + if (s_removeTex) s_removeTex(name); +} + +void getMemFileDetails(const std::wstring& name, std::uint8_t** data, + unsigned int* size) { + if (s_getTexDetails) s_getTexDetails(name, data, size); +} + +bool isFileInMemoryTextures(const std::wstring& name) { + return s_hasTex ? s_hasTex(name) : false; +} + +// Per-player settings + +static GetSettingsFn s_getSettings = nullptr; +static GetSettingsNoArgFn s_getSettingsNoArg = nullptr; + +void initPlayerSettings(GetSettingsFn getSettings, + GetSettingsNoArgFn getSettingsNoArg) { + s_getSettings = getSettings; + s_getSettingsNoArg = getSettingsNoArg; +} + +unsigned char getGameSettings(int iPad, int setting) { + return s_getSettings ? s_getSettings(iPad, setting) : 0; +} + +unsigned char getGameSettings(int setting) { + return s_getSettingsNoArg ? s_getSettingsNoArg(setting) : 0; +} + +// App time + +static AppTimeFn s_appTime = nullptr; + +void initAppTime(AppTimeFn fn) { s_appTime = fn; } + +float getAppTime() { return s_appTime ? s_appTime() : 0.0f; } + +// Game state + +static bool (*s_getGameStarted)() = nullptr; +static void (*s_setGameStarted)(bool) = nullptr; +static bool (*s_getTutorialMode)() = nullptr; +static void (*s_setTutorialMode)(bool) = nullptr; +static bool (*s_isAppPaused)() = nullptr; +static int (*s_getLocalPlayerCount)() = nullptr; +static bool (*s_autosaveDue)() = nullptr; +static void (*s_setAutosaveTimerTime)() = nullptr; +static int64_t (*s_secondsToAutosave)() = nullptr; +static void (*s_setDisconnectReason)(DisconnectPacket::eDisconnectReason) = nullptr; +static void (*s_lockSaveNotify)() = nullptr; +static void (*s_unlockSaveNotify)() = nullptr; +static bool (*s_getResetNether)() = nullptr; +static bool (*s_getUseDPadForDebug)() = nullptr; +static bool (*s_getWriteSavesToFolderEnabled)() = nullptr; +static bool (*s_isLocalMultiplayerAvailable)() = nullptr; +static bool (*s_dlcInstallPending)() = nullptr; +static bool (*s_dlcInstallProcessCompleted)() = nullptr; +static bool (*s_canRecordStatsAndAchievements)() = nullptr; +static bool (*s_getTMSGlobalFileListRead)() = nullptr; +static void (*s_setRequiredTexturePackID)(std::uint32_t) = nullptr; +static void (*s_setSpecialTutorialCompletionFlag)(int, int) = nullptr; +static void (*s_setBanListCheck)(int, bool) = nullptr; +static bool (*s_getBanListCheck)(int) = nullptr; +static unsigned int (*s_getGameNewWorldSize)() = nullptr; +static unsigned int (*s_getGameNewWorldSizeUseMoat)() = nullptr; +static unsigned int (*s_getGameNewHellScale)() = nullptr; + +void initGameState( + bool (*getGameStartedFn)(), + void (*setGameStartedFn)(bool), + bool (*getTutorialModeFn)(), + void (*setTutorialModeFn)(bool), + bool (*isAppPausedFn)(), + int (*getLocalPlayerCountFn)(), + bool (*autosaveDueFn)(), + void (*setAutosaveTimerTimeFn)(), + int64_t (*secondsToAutosaveFn)(), + void (*setDisconnectReasonFn)(DisconnectPacket::eDisconnectReason), + void (*lockSaveNotifyFn)(), + void (*unlockSaveNotifyFn)(), + bool (*getResetNetherFn)(), + bool (*getUseDPadForDebugFn)(), + bool (*getWriteSavesToFolderEnabledFn)(), + bool (*isLocalMultiplayerAvailableFn)(), + bool (*dlcInstallPendingFn)(), + bool (*dlcInstallProcessCompletedFn)(), + bool (*canRecordStatsAndAchievementsFn)(), + bool (*getTMSGlobalFileListReadFn)(), + void (*setRequiredTexturePackIDFn)(std::uint32_t), + void (*setSpecialTutorialCompletionFlagFn)(int, int), + void (*setBanListCheckFn)(int, bool), + bool (*getBanListCheckFn)(int), + unsigned int (*getGameNewWorldSizeFn)(), + unsigned int (*getGameNewWorldSizeUseMoatFn)(), + unsigned int (*getGameNewHellScaleFn)() +) { + s_getGameStarted = getGameStartedFn; + s_setGameStarted = setGameStartedFn; + s_getTutorialMode = getTutorialModeFn; + s_setTutorialMode = setTutorialModeFn; + s_isAppPaused = isAppPausedFn; + s_getLocalPlayerCount = getLocalPlayerCountFn; + s_autosaveDue = autosaveDueFn; + s_setAutosaveTimerTime = setAutosaveTimerTimeFn; + s_secondsToAutosave = secondsToAutosaveFn; + s_setDisconnectReason = setDisconnectReasonFn; + s_lockSaveNotify = lockSaveNotifyFn; + s_unlockSaveNotify = unlockSaveNotifyFn; + s_getResetNether = getResetNetherFn; + s_getUseDPadForDebug = getUseDPadForDebugFn; + s_getWriteSavesToFolderEnabled = getWriteSavesToFolderEnabledFn; + s_isLocalMultiplayerAvailable = isLocalMultiplayerAvailableFn; + s_dlcInstallPending = dlcInstallPendingFn; + s_dlcInstallProcessCompleted = dlcInstallProcessCompletedFn; + s_canRecordStatsAndAchievements = canRecordStatsAndAchievementsFn; + s_getTMSGlobalFileListRead = getTMSGlobalFileListReadFn; + s_setRequiredTexturePackID = setRequiredTexturePackIDFn; + s_setSpecialTutorialCompletionFlag = setSpecialTutorialCompletionFlagFn; + s_setBanListCheck = setBanListCheckFn; + s_getBanListCheck = getBanListCheckFn; + s_getGameNewWorldSize = getGameNewWorldSizeFn; + s_getGameNewWorldSizeUseMoat = getGameNewWorldSizeUseMoatFn; + s_getGameNewHellScale = getGameNewHellScaleFn; +} + +bool getGameStarted() { return s_getGameStarted ? s_getGameStarted() : false; } +void setGameStarted(bool val) { if (s_setGameStarted) s_setGameStarted(val); } +bool getTutorialMode() { return s_getTutorialMode ? s_getTutorialMode() : false; } +void setTutorialMode(bool val) { if (s_setTutorialMode) s_setTutorialMode(val); } +bool isAppPaused() { return s_isAppPaused ? s_isAppPaused() : false; } +int getLocalPlayerCount() { return s_getLocalPlayerCount ? s_getLocalPlayerCount() : 0; } +bool autosaveDue() { return s_autosaveDue ? s_autosaveDue() : false; } +void setAutosaveTimerTime() { if (s_setAutosaveTimerTime) s_setAutosaveTimerTime(); } +int64_t secondsToAutosave() { return s_secondsToAutosave ? s_secondsToAutosave() : 0; } +void setDisconnectReason(DisconnectPacket::eDisconnectReason reason) { + if (s_setDisconnectReason) s_setDisconnectReason(reason); +} +void lockSaveNotification() { if (s_lockSaveNotify) s_lockSaveNotify(); } +void unlockSaveNotification() { if (s_unlockSaveNotify) s_unlockSaveNotify(); } +bool getResetNether() { return s_getResetNether ? s_getResetNether() : false; } +bool getUseDPadForDebug() { return s_getUseDPadForDebug ? s_getUseDPadForDebug() : false; } +bool getWriteSavesToFolderEnabled() { + return s_getWriteSavesToFolderEnabled ? s_getWriteSavesToFolderEnabled() : false; +} +bool isLocalMultiplayerAvailable() { + return s_isLocalMultiplayerAvailable ? s_isLocalMultiplayerAvailable() : false; +} +bool dlcInstallPending() { return s_dlcInstallPending ? s_dlcInstallPending() : false; } +bool dlcInstallProcessCompleted() { + return s_dlcInstallProcessCompleted ? s_dlcInstallProcessCompleted() : false; +} +bool canRecordStatsAndAchievements() { + return s_canRecordStatsAndAchievements ? s_canRecordStatsAndAchievements() : false; +} +bool getTMSGlobalFileListRead() { + return s_getTMSGlobalFileListRead ? s_getTMSGlobalFileListRead() : true; +} +void setRequiredTexturePackID(std::uint32_t id) { + if (s_setRequiredTexturePackID) s_setRequiredTexturePackID(id); +} +void setSpecialTutorialCompletionFlag(int iPad, int index) { + if (s_setSpecialTutorialCompletionFlag) s_setSpecialTutorialCompletionFlag(iPad, index); +} +void setBanListCheck(int iPad, bool val) { + if (s_setBanListCheck) s_setBanListCheck(iPad, val); +} +bool getBanListCheck(int iPad) { + return s_getBanListCheck ? s_getBanListCheck(iPad) : false; +} +unsigned int getGameNewWorldSize() { + return s_getGameNewWorldSize ? s_getGameNewWorldSize() : 0; +} +unsigned int getGameNewWorldSizeUseMoat() { + return s_getGameNewWorldSizeUseMoat ? s_getGameNewWorldSizeUseMoat() : 0; +} +unsigned int getGameNewHellScale() { + return s_getGameNewHellScale ? s_getGameNewHellScale() : 0; +} + +// UI dispatch + +static void (*s_setAction)(int, eXuiAction, void*) = nullptr; +static void (*s_setXuiServerAction)(int, eXuiServerAction, void*) = nullptr; +static eXuiAction (*s_getXuiAction)(int) = nullptr; +static eXuiServerAction (*s_getXuiServerAction)(int) = nullptr; +static void* (*s_getXuiServerActionParam)(int) = nullptr; +static void (*s_setGlobalXuiAction)(eXuiAction) = nullptr; +static void (*s_handleButtonPresses)() = nullptr; +static void (*s_setTMSAction)(int, eTMSAction) = nullptr; + +void initUIDispatch( + void (*setActionFn)(int, eXuiAction, void*), + void (*setXuiServerActionFn)(int, eXuiServerAction, void*), + eXuiAction (*getXuiActionFn)(int), + eXuiServerAction (*getXuiServerActionFn)(int), + void* (*getXuiServerActionParamFn)(int), + void (*setGlobalXuiActionFn)(eXuiAction), + void (*handleButtonPressesFn)(), + void (*setTMSActionFn)(int, eTMSAction) +) { + s_setAction = setActionFn; + s_setXuiServerAction = setXuiServerActionFn; + s_getXuiAction = getXuiActionFn; + s_getXuiServerAction = getXuiServerActionFn; + s_getXuiServerActionParam = getXuiServerActionParamFn; + s_setGlobalXuiAction = setGlobalXuiActionFn; + s_handleButtonPresses = handleButtonPressesFn; + s_setTMSAction = setTMSActionFn; +} + +void setAction(int iPad, eXuiAction action, void* param) { + if (s_setAction) s_setAction(iPad, action, param); +} +void setXuiServerAction(int iPad, eXuiServerAction action, void* param) { + if (s_setXuiServerAction) s_setXuiServerAction(iPad, action, param); +} +eXuiAction getXuiAction(int iPad) { + return s_getXuiAction ? s_getXuiAction(iPad) : eAppAction_Idle; +} +eXuiServerAction getXuiServerAction(int iPad) { + return s_getXuiServerAction ? s_getXuiServerAction(iPad) : eXuiServerAction_Idle; +} +void* getXuiServerActionParam(int iPad) { + return s_getXuiServerActionParam ? s_getXuiServerActionParam(iPad) : nullptr; +} +void setGlobalXuiAction(eXuiAction action) { + if (s_setGlobalXuiAction) s_setGlobalXuiAction(action); +} +void handleButtonPresses() { + if (s_handleButtonPresses) s_handleButtonPresses(); +} +void setTMSAction(int iPad, eTMSAction action) { + if (s_setTMSAction) s_setTMSAction(iPad, action); +} + +// Skin / cape / animation + +static std::wstring (*s_getPlayerSkinName)(int) = nullptr; +static std::uint32_t (*s_getPlayerSkinId)(int) = nullptr; +static std::wstring (*s_getPlayerCapeName)(int) = nullptr; +static std::uint32_t (*s_getPlayerCapeId)(int) = nullptr; +static std::uint32_t (*s_getAdditionalModelPartsForPad)(int) = nullptr; +static void (*s_setAdditionalSkinBoxes)(std::uint32_t, SKIN_BOX*, unsigned int) = nullptr; +static std::vector* (*s_getAdditionalSkinBoxes)(std::uint32_t) = nullptr; +static std::vector* (*s_getAdditionalModelParts)(std::uint32_t) = nullptr; +static std::vector* (*s_setAdditionalSkinBoxesFromVec)( + std::uint32_t, std::vector*) = nullptr; +static void (*s_setAnimOverrideBitmask)(std::uint32_t, unsigned int) = nullptr; +static unsigned int (*s_getAnimOverrideBitmask)(std::uint32_t) = nullptr; +static std::uint32_t (*s_skinIdFromPath)(const std::wstring&) = nullptr; +static std::wstring (*s_skinPathFromId)(std::uint32_t) = nullptr; +static bool (*s_defaultCapeExists)() = nullptr; +static bool (*s_isXuidNotch)(PlayerUID) = nullptr; +static bool (*s_isXuidDeadmau5)(PlayerUID) = nullptr; + +void initSkinCape( + std::wstring (*getPlayerSkinNameFn)(int), + std::uint32_t (*getPlayerSkinIdFn)(int), + std::wstring (*getPlayerCapeNameFn)(int), + std::uint32_t (*getPlayerCapeIdFn)(int), + std::uint32_t (*getAdditionalModelPartsForPadFn)(int), + void (*setAdditionalSkinBoxesFn)(std::uint32_t, SKIN_BOX*, unsigned int), + std::vector* (*getAdditionalSkinBoxesFn)(std::uint32_t), + std::vector* (*getAdditionalModelPartsFn)(std::uint32_t), + std::vector* (*setAdditionalSkinBoxesFromVecFn)( + std::uint32_t, std::vector*), + void (*setAnimOverrideBitmaskFn)(std::uint32_t, unsigned int), + unsigned int (*getAnimOverrideBitmaskFn)(std::uint32_t), + std::uint32_t (*skinIdFromPathFn)(const std::wstring&), + std::wstring (*skinPathFromIdFn)(std::uint32_t), + bool (*defaultCapeExistsFn)(), + bool (*isXuidNotchFn)(PlayerUID), + bool (*isXuidDeadmau5Fn)(PlayerUID) +) { + s_getPlayerSkinName = getPlayerSkinNameFn; + s_getPlayerSkinId = getPlayerSkinIdFn; + s_getPlayerCapeName = getPlayerCapeNameFn; + s_getPlayerCapeId = getPlayerCapeIdFn; + s_getAdditionalModelPartsForPad = getAdditionalModelPartsForPadFn; + s_setAdditionalSkinBoxes = setAdditionalSkinBoxesFn; + s_getAdditionalSkinBoxes = getAdditionalSkinBoxesFn; + s_getAdditionalModelParts = getAdditionalModelPartsFn; + s_setAdditionalSkinBoxesFromVec = setAdditionalSkinBoxesFromVecFn; + s_setAnimOverrideBitmask = setAnimOverrideBitmaskFn; + s_getAnimOverrideBitmask = getAnimOverrideBitmaskFn; + s_skinIdFromPath = skinIdFromPathFn; + s_skinPathFromId = skinPathFromIdFn; + s_defaultCapeExists = defaultCapeExistsFn; + s_isXuidNotch = isXuidNotchFn; + s_isXuidDeadmau5 = isXuidDeadmau5Fn; +} + +std::wstring getPlayerSkinName(int iPad) { + return s_getPlayerSkinName ? s_getPlayerSkinName(iPad) : L""; +} +std::uint32_t getPlayerSkinId(int iPad) { + return s_getPlayerSkinId ? s_getPlayerSkinId(iPad) : 0; +} +std::wstring getPlayerCapeName(int iPad) { + return s_getPlayerCapeName ? s_getPlayerCapeName(iPad) : L""; +} +std::uint32_t getPlayerCapeId(int iPad) { + return s_getPlayerCapeId ? s_getPlayerCapeId(iPad) : 0; +} +std::uint32_t getAdditionalModelPartsForPad(int iPad) { + return s_getAdditionalModelPartsForPad ? s_getAdditionalModelPartsForPad(iPad) : 0; +} +void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* boxA, + unsigned int boxC) { + if (s_setAdditionalSkinBoxes) s_setAdditionalSkinBoxes(dwSkinID, boxA, boxC); +} +std::vector* getAdditionalSkinBoxes(std::uint32_t dwSkinID) { + return s_getAdditionalSkinBoxes ? s_getAdditionalSkinBoxes(dwSkinID) : nullptr; +} +std::vector* getAdditionalModelParts(std::uint32_t dwSkinID) { + return s_getAdditionalModelParts ? s_getAdditionalModelParts(dwSkinID) : nullptr; +} +std::vector* setAdditionalSkinBoxesFromVec( + std::uint32_t dwSkinID, std::vector* pvSkinBoxA) { + return s_setAdditionalSkinBoxesFromVec + ? s_setAdditionalSkinBoxesFromVec(dwSkinID, pvSkinBoxA) + : nullptr; +} +void setAnimOverrideBitmask(std::uint32_t dwSkinID, unsigned int bitmask) { + if (s_setAnimOverrideBitmask) s_setAnimOverrideBitmask(dwSkinID, bitmask); +} +unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID) { + return s_getAnimOverrideBitmask ? s_getAnimOverrideBitmask(dwSkinID) : 0; +} +std::uint32_t getSkinIdFromPath(const std::wstring& skin) { + return s_skinIdFromPath ? s_skinIdFromPath(skin) : 0; +} +std::wstring getSkinPathFromId(std::uint32_t skinId) { + return s_skinPathFromId ? s_skinPathFromId(skinId) : L""; +} +bool defaultCapeExists() { + return s_defaultCapeExists ? s_defaultCapeExists() : false; +} +bool isXuidNotch(PlayerUID xuid) { + return s_isXuidNotch ? s_isXuidNotch(xuid) : false; +} +bool isXuidDeadmau5(PlayerUID xuid) { + return s_isXuidDeadmau5 ? s_isXuidDeadmau5(xuid) : false; +} + +// Platform features + +static void (*s_fatalLoadError)() = nullptr; +static void (*s_setRichPresenceContext)(int, int) = nullptr; +static void (*s_captureSaveThumbnail)() = nullptr; +static void (*s_getSaveThumbnail)(std::uint8_t**, unsigned int*) = nullptr; +static void (*s_readBannedList)(int, eTMSAction, bool) = nullptr; +static void (*s_updatePlayerInfo)(std::uint8_t, int16_t, unsigned int) = nullptr; +static unsigned int (*s_getPlayerPrivileges)(std::uint8_t) = nullptr; +static void (*s_setGameSettingsDebugMask)(int, unsigned int) = nullptr; + +void initPlatformFeatures( + void (*fatalLoadErrorFn)(), + void (*setRichPresenceContextFn)(int, int), + void (*captureSaveThumbnailFn)(), + void (*getSaveThumbnailFn)(std::uint8_t**, unsigned int*), + void (*readBannedListFn)(int, eTMSAction, bool), + void (*updatePlayerInfoFn)(std::uint8_t, int16_t, unsigned int), + unsigned int (*getPlayerPrivilegesFn)(std::uint8_t), + void (*setGameSettingsDebugMaskFn)(int, unsigned int) +) { + s_fatalLoadError = fatalLoadErrorFn; + s_setRichPresenceContext = setRichPresenceContextFn; + s_captureSaveThumbnail = captureSaveThumbnailFn; + s_getSaveThumbnail = getSaveThumbnailFn; + s_readBannedList = readBannedListFn; + s_updatePlayerInfo = updatePlayerInfoFn; + s_getPlayerPrivileges = getPlayerPrivilegesFn; + s_setGameSettingsDebugMask = setGameSettingsDebugMaskFn; +} + +void fatalLoadError() { + if (s_fatalLoadError) s_fatalLoadError(); +} +void setRichPresenceContext(int iPad, int contextId) { + if (s_setRichPresenceContext) s_setRichPresenceContext(iPad, contextId); +} +void captureSaveThumbnail() { + if (s_captureSaveThumbnail) s_captureSaveThumbnail(); +} +void getSaveThumbnail(std::uint8_t** data, unsigned int* size) { + if (s_getSaveThumbnail) s_getSaveThumbnail(data, size); +} +void readBannedList(int iPad, eTMSAction action, bool bCallback) { + if (s_readBannedList) s_readBannedList(iPad, action, bCallback); +} +void updatePlayerInfo(std::uint8_t networkSmallId, int16_t playerColourIndex, + unsigned int playerPrivileges) { + if (s_updatePlayerInfo) s_updatePlayerInfo(networkSmallId, playerColourIndex, playerPrivileges); +} +unsigned int getPlayerPrivileges(std::uint8_t networkSmallId) { + return s_getPlayerPrivileges ? s_getPlayerPrivileges(networkSmallId) : 0; +} +void setGameSettingsDebugMask(int iPad, unsigned int uiVal) { + if (s_setGameSettingsDebugMask) s_setGameSettingsDebugMask(iPad, uiVal); +} + +// Schematics / terrain + +static void (*s_processSchematics)(LevelChunk*) = nullptr; +static void (*s_processSchematicsLighting)(LevelChunk*) = nullptr; +static void (*s_addTerrainFeaturePosition)(_eTerrainFeatureType, int, int) = nullptr; +static bool (*s_getTerrainFeaturePosition)(_eTerrainFeatureType, int*, int*) = nullptr; +static void (*s_loadDefaultGameRules)() = nullptr; + +void initSchematics( + void (*processSchematicsFn)(LevelChunk*), + void (*processSchematicsLightingFn)(LevelChunk*), + void (*addTerrainFeaturePositionFn)(_eTerrainFeatureType, int, int), + bool (*getTerrainFeaturePositionFn)(_eTerrainFeatureType, int*, int*), + void (*loadDefaultGameRulesFn)() +) { + s_processSchematics = processSchematicsFn; + s_processSchematicsLighting = processSchematicsLightingFn; + s_addTerrainFeaturePosition = addTerrainFeaturePositionFn; + s_getTerrainFeaturePosition = getTerrainFeaturePositionFn; + s_loadDefaultGameRules = loadDefaultGameRulesFn; +} + +void processSchematics(LevelChunk* chunk) { + if (s_processSchematics) s_processSchematics(chunk); +} +void processSchematicsLighting(LevelChunk* chunk) { + if (s_processSchematicsLighting) s_processSchematicsLighting(chunk); +} +void addTerrainFeaturePosition(_eTerrainFeatureType type, int x, int z) { + if (s_addTerrainFeaturePosition) s_addTerrainFeaturePosition(type, x, z); +} +bool getTerrainFeaturePosition(_eTerrainFeatureType type, int* pX, int* pZ) { + return s_getTerrainFeaturePosition ? s_getTerrainFeaturePosition(type, pX, pZ) : false; +} +void loadDefaultGameRules() { + if (s_loadDefaultGameRules) s_loadDefaultGameRules(); +} + +// Archive / resources + +static bool (*s_hasArchiveFile)(const std::wstring&) = nullptr; +static std::vector (*s_getArchiveFile)(const std::wstring&) = nullptr; + +void initArchive( + bool (*hasArchiveFileFn)(const std::wstring&), + std::vector (*getArchiveFileFn)(const std::wstring&) +) { + s_hasArchiveFile = hasArchiveFileFn; + s_getArchiveFile = getArchiveFileFn; +} + +bool hasArchiveFile(const std::wstring& filename) { + return s_hasArchiveFile ? s_hasArchiveFile(filename) : false; +} +std::vector getArchiveFile(const std::wstring& filename) { + return s_getArchiveFile ? s_getArchiveFile(filename) : std::vector{}; +} + +// Strings / formatting / misc queries + +static int (*s_getHTMLColour)(eMinecraftColour) = nullptr; +static std::wstring (*s_getEntityName)(EntityTypeId) = nullptr; +static const wchar_t* (*s_getGameRulesString)(const std::wstring&) = nullptr; +static unsigned int (*s_createImageTextData)(std::uint8_t*, int64_t, bool, + unsigned int, unsigned int) = nullptr; +static std::wstring (*s_getFilePath)(std::uint32_t, std::wstring, bool, + std::wstring) = nullptr; +static char* (*s_getUniqueMapName)() = nullptr; +static void (*s_setUniqueMapName)(char*) = nullptr; +static unsigned int (*s_getOpacityTimer)(int) = nullptr; +static void (*s_setOpacityTimer)(int) = nullptr; +static void (*s_tickOpacityTimer)(int) = nullptr; +static bool (*s_isInBannedLevelList)(int, PlayerUID, char*) = nullptr; +static MOJANG_DATA* (*s_getMojangDataForXuid)(PlayerUID) = nullptr; +static void (*s_debugPrintf)(const char*) = nullptr; + +void initStringsAndMisc( + int (*getHTMLColourFn)(eMinecraftColour), + std::wstring (*getEntityNameFn)(EntityTypeId), + const wchar_t* (*getGameRulesStringFn)(const std::wstring&), + unsigned int (*createImageTextDataFn)(std::uint8_t*, int64_t, bool, + unsigned int, unsigned int), + std::wstring (*getFilePathFn)(std::uint32_t, std::wstring, bool, + std::wstring), + char* (*getUniqueMapNameFn)(), + void (*setUniqueMapNameFn)(char*), + unsigned int (*getOpacityTimerFn)(int), + void (*setOpacityTimerFn)(int), + void (*tickOpacityTimerFn)(int), + bool (*isInBannedLevelListFn)(int, PlayerUID, char*), + MOJANG_DATA* (*getMojangDataForXuidFn)(PlayerUID), + void (*debugPrintfFn)(const char*) +) { + s_getHTMLColour = getHTMLColourFn; + s_getEntityName = getEntityNameFn; + s_getGameRulesString = getGameRulesStringFn; + s_createImageTextData = createImageTextDataFn; + s_getFilePath = getFilePathFn; + s_getUniqueMapName = getUniqueMapNameFn; + s_setUniqueMapName = setUniqueMapNameFn; + s_getOpacityTimer = getOpacityTimerFn; + s_setOpacityTimer = setOpacityTimerFn; + s_tickOpacityTimer = tickOpacityTimerFn; + s_isInBannedLevelList = isInBannedLevelListFn; + s_getMojangDataForXuid = getMojangDataForXuidFn; + s_debugPrintf = debugPrintfFn; +} + +int getHTMLColour(eMinecraftColour colour) { + return s_getHTMLColour ? s_getHTMLColour(colour) : 0; +} +int getHTMLColor(eMinecraftColour colour) { return getHTMLColour(colour); } +std::wstring getEntityName(EntityTypeId type) { + return s_getEntityName ? s_getEntityName(type) : L""; +} +const wchar_t* getGameRulesString(const std::wstring& key) { + return s_getGameRulesString ? s_getGameRulesString(key) : L""; +} +unsigned int createImageTextData(std::uint8_t* textMetadata, int64_t seed, + bool hasSeed, unsigned int uiHostOptions, + unsigned int uiTexturePackId) { + return s_createImageTextData + ? s_createImageTextData(textMetadata, seed, hasSeed, + uiHostOptions, uiTexturePackId) + : 0; +} +std::wstring getFilePath(std::uint32_t packId, std::wstring filename, + bool bAddDataFolder, std::wstring mountPoint) { + return s_getFilePath ? s_getFilePath(packId, filename, bAddDataFolder, mountPoint) : L""; +} +char* getUniqueMapName() { + return s_getUniqueMapName ? s_getUniqueMapName() : nullptr; +} +void setUniqueMapName(char* name) { + if (s_setUniqueMapName) s_setUniqueMapName(name); +} +unsigned int getOpacityTimer(int iPad) { + return s_getOpacityTimer ? s_getOpacityTimer(iPad) : 0; +} +void setOpacityTimer(int iPad) { + if (s_setOpacityTimer) s_setOpacityTimer(iPad); +} +void tickOpacityTimer(int iPad) { + if (s_tickOpacityTimer) s_tickOpacityTimer(iPad); +} +bool isInBannedLevelList(int iPad, PlayerUID xuid, char* levelName) { + return s_isInBannedLevelList ? s_isInBannedLevelList(iPad, xuid, levelName) : false; +} +MOJANG_DATA* getMojangDataForXuid(PlayerUID xuid) { + return s_getMojangDataForXuid ? s_getMojangDataForXuid(xuid) : nullptr; +} +void debugPrintf(const char* msg) { + if (s_debugPrintf) s_debugPrintf(msg); +} + +// Member variable access + +static DLCManager* s_dlcManager = nullptr; +static GameRuleManager* s_gameRules = nullptr; +static std::vector* s_skinNames = nullptr; +static std::vector* s_terrainFeatures = nullptr; + +void initMemberAccess( + DLCManager* dlcManager, + GameRuleManager* gameRules, + std::vector* skinNames, + std::vector* terrainFeatures +) { + s_dlcManager = dlcManager; + s_gameRules = gameRules; + s_skinNames = skinNames; + s_terrainFeatures = terrainFeatures; +} + +DLCManager& getDLCManager() { + assert(s_dlcManager); + return *s_dlcManager; +} +GameRuleManager& getGameRules() { + assert(s_gameRules); + return *s_gameRules; +} +std::vector& getSkinNames() { + assert(s_skinNames); + return *s_skinNames; +} +std::vector& getTerrainFeatures() { + assert(s_terrainFeatures); + return *s_terrainFeatures; +} + +// Menu service + +static IMenuService* s_menuService = nullptr; + +void initMenuService(IMenuService* service) { s_menuService = service; } + +IMenuService& menus() { + assert(s_menuService); + return *s_menuService; +} + +} // namespace GameServices diff --git a/targets/minecraft/GameServices.h b/targets/minecraft/GameServices.h new file mode 100644 index 000000000..f1f9abd1f --- /dev/null +++ b/targets/minecraft/GameServices.h @@ -0,0 +1,305 @@ +#pragma once + +#include +#include +#include + +// Forward declarations - minecraft types +class LevelGenerationOptions; +class LevelRuleset; +class LevelChunk; +class ModelPart; + +// Forward declarations - app types (opaque pointers only) +class DLCManager; +class GameRuleManager; + +// SKIN_BOX, FEATURE_DATA, MOJANG_DATA are C-style typedef'd structs +// that cannot be forward-declared. Include the lightweight headers. +#include "minecraft/world/entity/player/SkinBox.h" +#include "app/common/App_structs.h" + +// Enums needed by callers - pulled from app layer. +// These are small POD enums safe to include transitively. +#include "app/common/App_enums.h" +#include "platform/PlatformTypes.h" // PlayerUID +#include "protocol/DisconnectPacket.h" // eDisconnectReason +#include "minecraft/client/IMenuService.h" + +// eINSTANCEOF lives in java/Class.h which is heavyweight. +// We use int here and cast at init/call sites. +using EntityTypeId = int; + +namespace GameServices { +using LevelGenOptsFn = LevelGenerationOptions* (*)(); +using GameRuleDefsFn = LevelRuleset* (*)(); + +void initLevelGen(LevelGenOptsFn levelGenOpts, GameRuleDefsFn gameRuleDefs); +[[nodiscard]] LevelGenerationOptions* getLevelGenerationOptions(); +[[nodiscard]] LevelRuleset* getGameRuleDefinitions(); +using AddTexFn = void (*)(const std::wstring&, std::uint8_t*, unsigned int); +using RemoveTexFn = void (*)(const std::wstring&); +using GetTexDetailsFn = void (*)(const std::wstring&, std::uint8_t**, + unsigned int*); +using HasTexFn = bool (*)(const std::wstring&); + +void initTextureCache(AddTexFn add, RemoveTexFn remove, + GetTexDetailsFn getDetails, HasTexFn has); +void addMemoryTextureFile(const std::wstring& name, std::uint8_t* data, + unsigned int size); +void removeMemoryTextureFile(const std::wstring& name); +void getMemFileDetails(const std::wstring& name, std::uint8_t** data, + unsigned int* size); +[[nodiscard]] bool isFileInMemoryTextures(const std::wstring& name); +using GetSettingsFn = unsigned char (*)(int iPad, int setting); +using GetSettingsNoArgFn = unsigned char (*)(int setting); + +void initPlayerSettings(GetSettingsFn getSettings, + GetSettingsNoArgFn getSettingsNoArg); +[[nodiscard]] unsigned char getGameSettings(int iPad, int setting); +[[nodiscard]] unsigned char getGameSettings(int setting); +using AppTimeFn = float (*)(); + +void initAppTime(AppTimeFn fn); +[[nodiscard]] float getAppTime(); + +// Game state + +void initGameState( + bool (*getGameStarted)(), + void (*setGameStarted)(bool), + bool (*getTutorialMode)(), + void (*setTutorialMode)(bool), + bool (*isAppPaused)(), + int (*getLocalPlayerCount)(), + bool (*autosaveDue)(), + void (*setAutosaveTimerTime)(), + int64_t (*secondsToAutosave)(), + void (*setDisconnectReason)(DisconnectPacket::eDisconnectReason), + void (*lockSaveNotify)(), + void (*unlockSaveNotify)(), + bool (*getResetNether)(), + bool (*getUseDPadForDebug)(), + bool (*getWriteSavesToFolderEnabled)(), + bool (*isLocalMultiplayerAvailable)(), + bool (*dlcInstallPending)(), + bool (*dlcInstallProcessCompleted)(), + bool (*canRecordStatsAndAchievements)(), + bool (*getTMSGlobalFileListRead)(), + void (*setRequiredTexturePackID)(std::uint32_t), + void (*setSpecialTutorialCompletionFlag)(int iPad, int index), + void (*setBanListCheck)(int iPad, bool), + bool (*getBanListCheck)(int iPad), + unsigned int (*getGameNewWorldSize)(), + unsigned int (*getGameNewWorldSizeUseMoat)(), + unsigned int (*getGameNewHellScale)() +); + +[[nodiscard]] bool getGameStarted(); +void setGameStarted(bool val); +[[nodiscard]] bool getTutorialMode(); +void setTutorialMode(bool val); +[[nodiscard]] bool isAppPaused(); +[[nodiscard]] int getLocalPlayerCount(); +[[nodiscard]] bool autosaveDue(); +void setAutosaveTimerTime(); +[[nodiscard]] int64_t secondsToAutosave(); +void setDisconnectReason(DisconnectPacket::eDisconnectReason reason); +void lockSaveNotification(); +void unlockSaveNotification(); +[[nodiscard]] bool getResetNether(); +[[nodiscard]] bool getUseDPadForDebug(); +[[nodiscard]] bool getWriteSavesToFolderEnabled(); +[[nodiscard]] bool isLocalMultiplayerAvailable(); +[[nodiscard]] bool dlcInstallPending(); +[[nodiscard]] bool dlcInstallProcessCompleted(); +[[nodiscard]] bool canRecordStatsAndAchievements(); +[[nodiscard]] bool getTMSGlobalFileListRead(); +void setRequiredTexturePackID(std::uint32_t id); +void setSpecialTutorialCompletionFlag(int iPad, int index); +void setBanListCheck(int iPad, bool val); +[[nodiscard]] bool getBanListCheck(int iPad); +[[nodiscard]] unsigned int getGameNewWorldSize(); +[[nodiscard]] unsigned int getGameNewWorldSizeUseMoat(); +[[nodiscard]] unsigned int getGameNewHellScale(); + +// UI dispatch + +void initUIDispatch( + void (*setAction)(int iPad, eXuiAction action, void* param), + void (*setXuiServerAction)(int iPad, eXuiServerAction action, void* param), + eXuiAction (*getXuiAction)(int iPad), + eXuiServerAction (*getXuiServerAction)(int iPad), + void* (*getXuiServerActionParam)(int iPad), + void (*setGlobalXuiAction)(eXuiAction action), + void (*handleButtonPresses)(), + void (*setTMSAction)(int iPad, eTMSAction action) +); + +void setAction(int iPad, eXuiAction action, void* param = nullptr); +void setXuiServerAction(int iPad, eXuiServerAction action, + void* param = nullptr); +[[nodiscard]] eXuiAction getXuiAction(int iPad); +[[nodiscard]] eXuiServerAction getXuiServerAction(int iPad); +[[nodiscard]] void* getXuiServerActionParam(int iPad); +void setGlobalXuiAction(eXuiAction action); +void handleButtonPresses(); +void setTMSAction(int iPad, eTMSAction action); + +// Skin / cape / animation + +void initSkinCape( + std::wstring (*getPlayerSkinName)(int iPad), + std::uint32_t (*getPlayerSkinId)(int iPad), + std::wstring (*getPlayerCapeName)(int iPad), + std::uint32_t (*getPlayerCapeId)(int iPad), + std::uint32_t (*getAdditionalModelPartsForPad)(int iPad), + void (*setAdditionalSkinBoxes)(std::uint32_t dwSkinID, SKIN_BOX* boxA, + unsigned int boxC), + std::vector* (*getAdditionalSkinBoxes)(std::uint32_t dwSkinID), + std::vector* (*getAdditionalModelParts)(std::uint32_t dwSkinID), + std::vector* (*setAdditionalSkinBoxesFromVec)( + std::uint32_t dwSkinID, std::vector* pvSkinBoxA), + void (*setAnimOverrideBitmask)(std::uint32_t dwSkinID, unsigned int bitmask), + unsigned int (*getAnimOverrideBitmask)(std::uint32_t dwSkinID), + std::uint32_t (*skinIdFromPath)(const std::wstring& skin), + std::wstring (*skinPathFromId)(std::uint32_t skinId), + bool (*defaultCapeExists)(), + bool (*isXuidNotch)(PlayerUID xuid), + bool (*isXuidDeadmau5)(PlayerUID xuid) +); + +[[nodiscard]] std::wstring getPlayerSkinName(int iPad); +[[nodiscard]] std::uint32_t getPlayerSkinId(int iPad); +[[nodiscard]] std::wstring getPlayerCapeName(int iPad); +[[nodiscard]] std::uint32_t getPlayerCapeId(int iPad); +[[nodiscard]] std::uint32_t getAdditionalModelPartsForPad(int iPad); +void setAdditionalSkinBoxes(std::uint32_t dwSkinID, SKIN_BOX* boxA, + unsigned int boxC); +[[nodiscard]] std::vector* getAdditionalSkinBoxes( + std::uint32_t dwSkinID); +[[nodiscard]] std::vector* getAdditionalModelParts( + std::uint32_t dwSkinID); +std::vector* setAdditionalSkinBoxesFromVec( + std::uint32_t dwSkinID, std::vector* pvSkinBoxA); +void setAnimOverrideBitmask(std::uint32_t dwSkinID, unsigned int bitmask); +[[nodiscard]] unsigned int getAnimOverrideBitmask(std::uint32_t dwSkinID); +[[nodiscard]] std::uint32_t getSkinIdFromPath(const std::wstring& skin); +[[nodiscard]] std::wstring getSkinPathFromId(std::uint32_t skinId); +[[nodiscard]] bool defaultCapeExists(); +[[nodiscard]] bool isXuidNotch(PlayerUID xuid); +[[nodiscard]] bool isXuidDeadmau5(PlayerUID xuid); + +// Platform features + +void initPlatformFeatures( + void (*fatalLoadError)(), + void (*setRichPresenceContext)(int iPad, int contextId), + void (*captureSaveThumbnail)(), + void (*getSaveThumbnail)(std::uint8_t**, unsigned int*), + void (*readBannedList)(int iPad, eTMSAction action, bool bCallback), + void (*updatePlayerInfo)(std::uint8_t networkSmallId, + int16_t playerColourIndex, + unsigned int playerPrivileges), + unsigned int (*getPlayerPrivileges)(std::uint8_t networkSmallId), + void (*setGameSettingsDebugMask)(int iPad, unsigned int uiVal) +); + +void fatalLoadError(); +void setRichPresenceContext(int iPad, int contextId); +void captureSaveThumbnail(); +void getSaveThumbnail(std::uint8_t** data, unsigned int* size); +void readBannedList(int iPad, eTMSAction action = (eTMSAction)0, + bool bCallback = false); +void updatePlayerInfo(std::uint8_t networkSmallId, int16_t playerColourIndex, + unsigned int playerPrivileges); +[[nodiscard]] unsigned int getPlayerPrivileges(std::uint8_t networkSmallId); +void setGameSettingsDebugMask(int iPad, unsigned int uiVal); + +// Schematics / terrain + +void initSchematics( + void (*processSchematics)(LevelChunk* chunk), + void (*processSchematicsLighting)(LevelChunk* chunk), + void (*addTerrainFeaturePosition)(_eTerrainFeatureType, int, int), + bool (*getTerrainFeaturePosition)(_eTerrainFeatureType, int*, int*), + void (*loadDefaultGameRules)() +); + +void processSchematics(LevelChunk* chunk); +void processSchematicsLighting(LevelChunk* chunk); +void addTerrainFeaturePosition(_eTerrainFeatureType type, int x, int z); +[[nodiscard]] bool getTerrainFeaturePosition(_eTerrainFeatureType type, + int* pX, int* pZ); +void loadDefaultGameRules(); + +// Archive / resources + +void initArchive( + bool (*hasArchiveFile)(const std::wstring&), + std::vector (*getArchiveFile)(const std::wstring&) +); + +[[nodiscard]] bool hasArchiveFile(const std::wstring& filename); +[[nodiscard]] std::vector getArchiveFile( + const std::wstring& filename); + +// Strings / formatting / misc queries + +void initStringsAndMisc( + int (*getHTMLColour)(eMinecraftColour), + std::wstring (*getEntityName)(EntityTypeId), + const wchar_t* (*getGameRulesString)(const std::wstring&), + unsigned int (*createImageTextData)(std::uint8_t*, int64_t, bool, + unsigned int, unsigned int), + std::wstring (*getFilePath)(std::uint32_t, std::wstring, bool, + std::wstring), + char* (*getUniqueMapName)(), + void (*setUniqueMapName)(char*), + unsigned int (*getOpacityTimer)(int iPad), + void (*setOpacityTimer)(int iPad), + void (*tickOpacityTimer)(int iPad), + bool (*isInBannedLevelList)(int iPad, PlayerUID xuid, char* levelName), + MOJANG_DATA* (*getMojangDataForXuid)(PlayerUID xuid), + void (*debugPrintf)(const char*) +); + +[[nodiscard]] int getHTMLColour(eMinecraftColour colour); +[[nodiscard]] int getHTMLColor(eMinecraftColour colour); +[[nodiscard]] std::wstring getEntityName(EntityTypeId type); +[[nodiscard]] const wchar_t* getGameRulesString(const std::wstring& key); +[[nodiscard]] unsigned int createImageTextData(std::uint8_t* textMetadata, + int64_t seed, bool hasSeed, + unsigned int uiHostOptions, + unsigned int uiTexturePackId); +[[nodiscard]] std::wstring getFilePath(std::uint32_t packId, + std::wstring filename, + bool bAddDataFolder, + std::wstring mountPoint = L"TPACK:"); +[[nodiscard]] char* getUniqueMapName(); +void setUniqueMapName(char* name); +[[nodiscard]] unsigned int getOpacityTimer(int iPad); +void setOpacityTimer(int iPad); +void tickOpacityTimer(int iPad); +[[nodiscard]] bool isInBannedLevelList(int iPad, PlayerUID xuid, + char* levelName); +[[nodiscard]] MOJANG_DATA* getMojangDataForXuid(PlayerUID xuid); +void debugPrintf(const char* msg); + +// Member variable access (opaque pointers) + +void initMemberAccess( + DLCManager* dlcManager, + GameRuleManager* gameRules, + std::vector* skinNames, + std::vector* terrainFeatures +); + +[[nodiscard]] DLCManager& getDLCManager(); +[[nodiscard]] GameRuleManager& getGameRules(); +[[nodiscard]] std::vector& getSkinNames(); +[[nodiscard]] std::vector& getTerrainFeatures(); +void initMenuService(IMenuService* service); +[[nodiscard]] IMenuService& menus(); + +} // namespace GameServices diff --git a/targets/minecraft/client/BufferedImage.cpp b/targets/minecraft/client/BufferedImage.cpp index 150c4a75e..d3080a7b4 100644 --- a/targets/minecraft/client/BufferedImage.cpp +++ b/targets/minecraft/client/BufferedImage.cpp @@ -10,7 +10,7 @@ #include "app/common/DLC/DLCFile.h" #include "app/common/DLC/DLCManager.h" #include "app/common/DLC/DLCPack.h" -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "app/linux/Stubs/winapi_stubs.h" #include "PlatformTypes.h" #include "util/StringHelpers.h" @@ -98,8 +98,8 @@ BufferedImage::BufferedImage(const std::wstring& File, &ImageInfo, &data[l]); } else { std::wstring archiveKey = L"res/" + fileName; - if (app.hasArchiveFile(archiveKey)) { - std::vector ba = app.getArchiveFile(archiveKey); + if (GameServices::hasArchiveFile(archiveKey)) { + std::vector ba = GameServices::getArchiveFile(archiveKey); hr = RenderManager.LoadTextureData(ba.data(), ba.size(), &ImageInfo, &data[l]); } @@ -140,14 +140,14 @@ BufferedImage::BufferedImage(DLCPack* dlcPack, const std::wstring& File, mipMapPath + L".png"); if (!dlcPack->doesPackContainFile(DLCManager::e_DLCType_All, name)) { - if (l == 0) app.FatalLoadError(); + if (l == 0) GameServices::fatalLoadError(); return; } DLCFile* dlcFile = dlcPack->getFile(DLCManager::e_DLCType_All, name); pbData = dlcFile->getData(dataBytes); if (pbData == nullptr || dataBytes == 0) { - if (l == 0) app.FatalLoadError(); + if (l == 0) GameServices::fatalLoadError(); return; } @@ -175,7 +175,7 @@ BufferedImage::BufferedImage(std::uint8_t* pbData, std::uint32_t dataBytes) { width = ImageInfo.Width; height = ImageInfo.Height; } else { - app.FatalLoadError(); + GameServices::fatalLoadError(); } } diff --git a/targets/minecraft/client/IMenuService.h b/targets/minecraft/client/IMenuService.h new file mode 100644 index 000000000..93c71e929 --- /dev/null +++ b/targets/minecraft/client/IMenuService.h @@ -0,0 +1,66 @@ +#pragma once + +#include +#include + +class LocalPlayer; +class Inventory; +class Container; +class Level; +class FurnaceTileEntity; +class BrewingStandTileEntity; +class DispenserTileEntity; +class SignTileEntity; +class CommandBlockEntity; +class HopperTileEntity; +class MinecartHopper; +class EntityHorse; +class BeaconTileEntity; +class Merchant; + +class IMenuService { +public: + virtual ~IMenuService() = default; + + virtual bool openInventory(int iPad, std::shared_ptr player, + bool navigateBack = false) = 0; + virtual bool openCreative(int iPad, std::shared_ptr player, + bool navigateBack = false) = 0; + virtual bool openCrafting2x2(int iPad, + std::shared_ptr player) = 0; + virtual bool openCrafting3x3(int iPad, std::shared_ptr player, + int x, int y, int z) = 0; + virtual bool openEnchanting(int iPad, std::shared_ptr inventory, + int x, int y, int z, Level* level, + const std::wstring& name) = 0; + virtual bool openFurnace(int iPad, std::shared_ptr inventory, + std::shared_ptr furnace) = 0; + virtual bool openBrewingStand( + int iPad, std::shared_ptr inventory, + std::shared_ptr brewingStand) = 0; + virtual bool openContainer(int iPad, std::shared_ptr inventory, + std::shared_ptr container) = 0; + virtual bool openTrap(int iPad, std::shared_ptr inventory, + std::shared_ptr trap) = 0; + virtual bool openFireworks(int iPad, std::shared_ptr player, + int x, int y, int z) = 0; + virtual bool openSign(int iPad, + std::shared_ptr sign) = 0; + virtual bool openRepairing(int iPad, std::shared_ptr inventory, + Level* level, int x, int y, int z) = 0; + virtual bool openTrading(int iPad, std::shared_ptr inventory, + std::shared_ptr trader, Level* level, + const std::wstring& name) = 0; + virtual bool openCommandBlock( + int iPad, std::shared_ptr commandBlock) = 0; + virtual bool openHopper(int iPad, std::shared_ptr inventory, + std::shared_ptr hopper) = 0; + virtual bool openHopperMinecart( + int iPad, std::shared_ptr inventory, + std::shared_ptr hopper) = 0; + virtual bool openHorse(int iPad, std::shared_ptr inventory, + std::shared_ptr container, + std::shared_ptr horse) = 0; + virtual bool openBeacon(int iPad, std::shared_ptr inventory, + std::shared_ptr beacon) = 0; +}; diff --git a/targets/minecraft/client/Minecraft.cpp b/targets/minecraft/client/Minecraft.cpp index 59c664bca..290fbf64b 100644 --- a/targets/minecraft/client/Minecraft.cpp +++ b/targets/minecraft/client/Minecraft.cpp @@ -1,3 +1,8 @@ +#include "minecraft/GameServices.h" +#include "minecraft/client/IMenuService.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "Minecraft.h" #include @@ -22,7 +27,6 @@ #include "app/common/Tutorial/Tutorial.h" #include "app/common/UI/All Platforms/UIEnums.h" #include "app/common/UI/All Platforms/UIStructs.h" -#include "app/linux/LinuxGame.h" #include "app/linux/Linux_UIController.h" #include "app/linux/Stubs/winapi_stubs.h" #include "platform/XboxStubs.h" @@ -280,7 +284,7 @@ void Minecraft::clearConnectionFailed() { m_connectionFailed[i] = false; m_connectionFailedReason[i] = DisconnectPacket::eDisconnect_None; } - app.SetDisconnectReason(DisconnectPacket::eDisconnect_None); + GameServices::setDisconnectReason(DisconnectPacket::eDisconnect_None); } void Minecraft::connectTo(const std::wstring& server, int port) { @@ -489,7 +493,7 @@ File Minecraft::getWorkingDirectory(const std::wstring& applicationName) { #endif if (!workingDirectory->exists()) { if (!workingDirectory->mkdirs()) { - app.DebugPrintf("The working directory could not be created"); + Log::info("The working directory could not be created"); assert(0); // throw new RuntimeException(L"The working directory could not be // created: " + workingDirectory); @@ -714,7 +718,7 @@ void Minecraft::updatePlayerViewportAssignments() { for (int i = 0; i < XUSER_MAX_COUNT; i++) { if (localplayers[i] != nullptr) { // Primary player settings decide what the mode is - if (app.GetGameSettings(InputManager.GetPrimaryPad(), + if (GameServices::getGameSettings(InputManager.GetPrimaryPad(), eGameSetting_SplitScreenVertical)) { localplayers[i]->m_iScreenSection = C4JRender::VIEWPORT_TYPE_SPLIT_LEFT + found; @@ -737,7 +741,7 @@ void Minecraft::updatePlayerViewportAssignments() { // allocations (as the players won't have seen them) This fixes // an issue with the primary player being the 4th controller // quadrant, but ending up in the 3rd viewport. - if (app.GetGameStarted()) { + if (GameServices::getGameStarted()) { if ((localplayers[i]->m_iScreenSection >= C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT) && (localplayers[i]->m_iScreenSection <= @@ -786,7 +790,7 @@ void Minecraft::updatePlayerViewportAssignments() { // 4J Stu - If the game is not running we do not want to do this yet, and // should wait until the task that caused the app to not be running is // finished - if (app.GetGameStarted()) ui.UpdatePlayerBasePositions(); + if (GameServices::getGameStarted()) ui.UpdatePlayerBasePositions(); } // Add a temporary player so that the viewports get re-arranged, and add the @@ -804,7 +808,7 @@ bool Minecraft::addLocalPlayer(int idx) { bool success = g_NetworkManager.AddLocalPlayerByUserIndex(idx); if (success) { - app.DebugPrintf("Adding temp local player on pad %d\n", idx); + Log::info("Adding temp local player on pad %d\n", idx); localplayers[idx] = std::shared_ptr( new MultiplayerLocalPlayer(this, level, user, nullptr)); localgameModes[idx] = nullptr; @@ -822,7 +826,7 @@ bool Minecraft::addLocalPlayer(int idx) { ui.NavigateToScene(idx, eUIScene_ConnectingProgress, param); } else { - app.DebugPrintf("g_NetworkManager.AddLocalPlayerByUserIndex failed\n"); + Log::info("g_NetworkManager.AddLocalPlayerByUserIndex failed\n"); } return success; @@ -868,7 +872,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( mpLevel->addClientConnection(clientConnection); } - if (app.GetTutorialMode()) { + if (GameServices::getTutorialMode()) { localgameModes[idx] = new FullTutorialMode(idx, this, clientConnection); } else { @@ -922,7 +926,7 @@ std::shared_ptr Minecraft::createExtraLocalPlayer( // ClientConnection::handleMovePlayer // // 4J-PB - can't call this when this function is called // from the qnet thread (GetGameStarted will be false) - // if(app.GetGameStarted()) + // if(GameServices::getGameStarted()) // { // ui.CloseUIScenes(idx); // } @@ -1065,7 +1069,7 @@ void Minecraft::run_middle() { // set the timer bAutosaveTimerSet=true; - app.SetAutosaveTimerTime(); + GameServices::setAutosaveTimerTime(); } else*/ { @@ -1074,7 +1078,7 @@ void Minecraft::run_middle() { // player has a app action running , or has any crafting // or containers open, don't autosave if (!StorageManager.GetSaveDisabled() && - (app.GetXuiAction(InputManager.GetPrimaryPad()) == + (GameServices::getXuiAction(InputManager.GetPrimaryPad()) == eAppAction_Idle)) { if (!ui.IsPauseMenuDisplayed( InputManager.GetPrimaryPad()) && @@ -1083,7 +1087,7 @@ void Minecraft::run_middle() { // check if the autotimer countdown has reached // zero unsigned char ucAutosaveVal = - app.GetGameSettings( + GameServices::getGameSettings( InputManager.GetPrimaryPad(), eGameSetting_Autosave); bool bTrialTexturepack = false; @@ -1112,18 +1116,18 @@ void Minecraft::run_middle() { // check whether we need to save this tick if ((ucAutosaveVal != 0) && !bTrialTexturepack) { - if (app.AutosaveDue()) { + if (GameServices::autosaveDue()) { // disable the autosave countdown ui.ShowAutosaveCountdownTimer(false); // Need to save now - app.DebugPrintf("+++++++++++\n"); - app.DebugPrintf("+++Autosave\n"); - app.DebugPrintf("+++++++++++\n"); - app.SetAction( + Log::info("+++++++++++\n"); + Log::info("+++Autosave\n"); + Log::info("+++++++++++\n"); + GameServices::setAction( InputManager.GetPrimaryPad(), eAppAction_AutosaveSaveGame); - // app.SetAutosaveTimerTime(); + // GameServices::setAutosaveTimerTime(); #if !defined(_CONTENT_PACKAGE) { // print the time @@ -1138,7 +1142,7 @@ void Minecraft::run_middle() { gmtime_r(&now_tt, &utcTime); #endif - app.DebugPrintf("%02d:%02d:%02d\n", + Log::info("%02d:%02d:%02d\n", utcTime.tm_hour, utcTime.tm_min, utcTime.tm_sec); @@ -1146,7 +1150,7 @@ void Minecraft::run_middle() { #endif } else { int64_t uiTimeToAutosave = - app.SecondsToAutosave(); + GameServices::secondsToAutosave(); if (uiTimeToAutosave < 6) { ui.ShowAutosaveCountdownTimer(true); @@ -1167,14 +1171,14 @@ void Minecraft::run_middle() { // the level in their banned list and ask if they want to play // it for (int i = 0; i < XUSER_MAX_COUNT; i++) { - if (localplayers[i] && (app.GetBanListCheck(i) == false) && + if (localplayers[i] && (GameServices::getBanListCheck(i) == false) && !Minecraft::GetInstance()->isTutorial() && ProfileManager.IsSignedInLive(i) && !ProfileManager.IsGuest(i)) { // If there is a sys ui displayed, we can't display the // message box here, so ignore until we can if (!ProfileManager.IsSystemUIDisplayed()) { - app.SetBanListCheck(i, true); + GameServices::setBanListCheck(i, true); // 4J-PB - check if the level is in the banned level // list get the unique save name and xuid from // whoever is the host @@ -1182,15 +1186,15 @@ void Minecraft::run_middle() { g_NetworkManager.GetHostPlayer(); PlayerUID xuid = pHostPlayer->GetUID(); - if (app.IsInBannedLevelList( - i, xuid, app.GetUniqueMapName())) { + if (GameServices::isInBannedLevelList( + i, xuid, GameServices::getUniqueMapName())) { // put up a message box asking if the player // would like to unban this level - app.DebugPrintf("This level is banned\n"); + Log::info("This level is banned\n"); // set the app action to bring up the message // box to give them the option to remove from // the ban list or exit the level - app.SetAction(i, eAppAction_LevelInBanLevelList, + GameServices::setAction(i, eAppAction_LevelInBanLevelList, (void*)true); } } @@ -1198,10 +1202,10 @@ void Minecraft::run_middle() { } if (!ProfileManager.IsSystemUIDisplayed() && - app.DLCInstallProcessCompleted() && - !app.DLCInstallPending() && - app.m_dlcManager.NeedsCorruptCheck()) { - app.m_dlcManager.checkForCorruptDLCAndAlert(); + GameServices::dlcInstallProcessCompleted() && + !GameServices::dlcInstallPending() && + GameServices::getDLCManager().NeedsCorruptCheck()) { + GameServices::getDLCManager().checkForCorruptDLCAndAlert(); } // When we go into the first loaded level, check if the console @@ -1214,7 +1218,7 @@ void Minecraft::run_middle() { if (iFirstTimeCountdown == 0) { bFirstTimeIntoGame = false; - if (app.IsLocalMultiplayerAvailable()) { + if (GameServices::isLocalMultiplayerAvailable()) { for (int i = 0; i < XUSER_MAX_COUNT; i++) { if ((localplayers[i] == nullptr) && InputManager.IsPadConnected(i)) { @@ -1258,7 +1262,7 @@ void Minecraft::run_middle() { i, MINECRAFT_ACTION_PAUSEMENU)) { localplayers[i]->ullButtonsPressed |= 1LL << MINECRAFT_ACTION_PAUSEMENU; - app.DebugPrintf( + Log::info( "PAUSE PRESSED - ipad = %d, Storing press\n", i); #if defined(ENABLE_JAVA_GUIS) @@ -1293,7 +1297,7 @@ void Minecraft::run_middle() { 1LL << MINECRAFT_ACTION_GAME_INFO; #if !defined(_FINAL_BUILD) - if (app.DebugSettingsOn() && app.GetUseDPadForDebug()) { + if (DebugSettings::isOn() && GameServices::getUseDPadForDebug()) { localplayers[i]->ullDpad_last = 0; localplayers[i]->ullDpad_this = 0; localplayers[i]->ullDpad_filtered = 0; @@ -1371,7 +1375,7 @@ void Minecraft::run_middle() { // || InputManager.ButtonPressed(i, // MINECRAFT_ACTION_ACTION)) { - app.SetOpacityTimer(i); + GameServices::setOpacityTimer(i); } } else { // 4J Stu - This doesn't make any sense with the way we @@ -1409,7 +1413,7 @@ void Minecraft::run_middle() { addLocalPlayer(i); if (!success) { - app.DebugPrintf( + Log::info( "Bringing up the sign " "in " "ui\n"); @@ -1486,7 +1490,7 @@ void Minecraft::run_middle() { { // player not signed in to live // bring up the sign in dialog - app.DebugPrintf( + Log::info( "Bringing up the sign in " "ui\n"); ProfileManager.RequestSignInUI( @@ -1503,7 +1507,7 @@ void Minecraft::run_middle() { } } else { // bring up the sign in dialog - app.DebugPrintf( + Log::info( "Bringing up the sign in ui\n"); ProfileManager.RequestSignInUI( false, @@ -1538,7 +1542,7 @@ void Minecraft::run_middle() { // again if (i != 0) { InputManager.Tick(); - app.HandleButtonPresses(); + GameServices::handleButtonPresses(); } ticks++; @@ -1658,12 +1662,12 @@ void Minecraft::run_middle() { if (i == iPrimaryPad) { // check to see if we need to capture a // screenshot for the save game thumbnail - switch (app.GetXuiAction(i)) { + switch (GameServices::getXuiAction(i)) { case eAppAction_ExitWorldCapturedThumbnail: case eAppAction_SaveGameCapturedThumbnail: case eAppAction_AutosaveSaveGameCapturedThumbnail: // capture the save thumbnail - app.CaptureSaveThumbnail(); + GameServices::captureSaveThumbnail(); break; default: break; @@ -1776,7 +1780,7 @@ void Minecraft::run_middle() { g_NetworkManager.GetPlayerCount() == 1 && screen != nullptr && screen->isPauseScreen(); #else - pause = app.IsAppPaused(); + pause = GameServices::isAppPaused(); #endif #if !defined(_CONTENT_PACKAGE) @@ -2011,7 +2015,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // Tick the opacity timer (to display the interface at default opacity for a // certain time if the user has been navigating it) - app.TickOpacityTimer(iPad); + GameServices::tickOpacityTimer(iPad); // 4J added if (bFirst) levelRenderer->destroyedTileManager->tick(); @@ -3036,7 +3040,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // have the // privilege { - if (app.GetGameHostOption( + if (GameHostOptions::get( eGameHostOption_PvP) && player->isAllowedToAttackPlayers()) { *piAction = IDS_TOOLTIPS_HIT; @@ -3362,7 +3366,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { } } - if (app.DebugSettingsOn()) { + if (DebugSettings::isOn()) { if (player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_CHANGE_SKIN)) { player->ChangePlayerSkin(); @@ -3372,7 +3376,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (player->missTime > 0) player->missTime--; #if defined(_DEBUG_MENUS_ENABLED) - if (app.DebugSettingsOn()) { + if (DebugSettings::isOn()) { // 4J-PB - debugoverlay for primary player only if (iPad == InputManager.GetPrimaryPad()) { if ((player->ullButtonsPressed & @@ -3389,7 +3393,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if ((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_SPAWN_CREEPER)) && - app.GetMobsDontAttackEnabled()) { + DebugSettings::mobsDontAttack()) { // shared_ptr mob = // std::dynamic_pointer_cast(Creeper::_class->newInstance( // level )); shared_ptr mob = @@ -3433,7 +3437,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { #if defined(ENABLE_JAVA_GUIS) setScreen(new InventoryScreen(player)); #else - app.LoadInventoryMenu(iPad, player); + GameServices::menus().openInventory(iPad, std::static_pointer_cast(player)); #endif } @@ -3454,7 +3458,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { setScreen(new CreativeInventoryScreen(player)); } #else - app.LoadCreativeMenu(iPad, player); + GameServices::menus().openCreative(iPad, std::static_pointer_cast(player)); } // 4J-PB - Microsoft request that we use the 3x3 crafting if someone // presses X while at the workbench @@ -3471,13 +3475,13 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { &hitResult->pos, false, &usedItem); } else { ui.PlayUISFX(eSFX_Press); - app.LoadCrafting2x2Menu(iPad, player); + GameServices::menus().openCrafting2x2(iPad, std::static_pointer_cast(player)); } #endif } if ((player->ullButtonsPressed & (1LL << MINECRAFT_ACTION_PAUSEMENU))) { - app.DebugPrintf( + Log::info( "PAUSE PRESS PROCESSING - ipad = %d, NavigateToScene\n", player->GetXboxPad()); ui.PlayUISFX(eSFX_Press); @@ -3539,9 +3543,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // printf("Input Detected!\n"); // // // see if we can react to this - // if(app.GetXuiAction(iPad)==eAppAction_Idle) + // if(GameServices::getXuiAction(iPad)==eAppAction_Idle) // { - // app.SetAction(iPad,eAppAction_DebugText,(void*)wchInput); + // GameServices::setAction(iPad,eAppAction_DebugText,(void*)wchInput); // } // } // } @@ -3560,7 +3564,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // level->difficulty = options->difficulty; // if (level->isClientSide) level->difficulty = Difficulty::HARD; if (!level->isClientSide) { - // app.DebugPrintf("Minecraft::tick - Difficulty = + // Log::info("Minecraft::tick - Difficulty = // %d",options->difficulty); level->difficulty = options->difficulty; } @@ -3624,7 +3628,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // 4J Stu - We are always online, but still could be paused if (!pause) // || isClientSide()) { - // app.DebugPrintf("Minecraft::tick spawn settings - + // Log::info("Minecraft::tick spawn settings - // Difficulty = %d",options->difficulty); levels[i]->setSpawnSettings(level->difficulty > 0, true); #if defined(DISABLE_LEVELTICK_THREAD) @@ -3968,7 +3972,7 @@ void Minecraft::fileDownloaded(const std::wstring& name, File* file) { std::wstring Minecraft::gatherStats1() { // return levelRenderer->gatherStats1(); return L"Time to autosave: " + - toWString(app.SecondsToAutosave()) + L"s"; + toWString(GameServices::secondsToAutosave()) + L"s"; } std::wstring Minecraft::gatherStats2() { @@ -4041,7 +4045,7 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { } // Set the animation override if the skin has one - std::uint32_t dwSkinID = app.getSkinIdFromPath(player->customTextureUrl); + std::uint32_t dwSkinID = GameServices::getSkinIdFromPath(player->customTextureUrl); if (GET_IS_DLC_SKIN_FROM_BITMASK(dwSkinID)) { player->setAnimOverrideBitmask( player->getSkinAnimOverrideBitmask(dwSkinID)); @@ -4055,14 +4059,14 @@ void Minecraft::respawnPlayer(int iPad, int dimension, int newEntityId) { createPrimaryLocalPlayer(iPad); // update the debugoptions - app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(), - app.GetGameSettingsDebugMask(-1, true)); + GameServices::setGameSettingsDebugMask(InputManager.GetPrimaryPad(), + DebugSettings::getMask(-1, true)); } else { storeExtraLocalPlayer(iPad); } player->setShowOnMaps( - app.GetGameHostOption(eGameHostOption_Gamertags) != 0 ? true : false); + GameHostOptions::get(eGameHostOption_Gamertags) != 0 ? true : false); player->resetPos(); level->addEntity(player); @@ -4204,7 +4208,7 @@ void Minecraft::main() { User::staticCtor(); Tutorial::staticCtor(); ColourTable::staticCtor(); - app.loadDefaultGameRules(); + GameServices::loadDefaultGameRules(); #if defined(_LARGE_WORLDS) LevelRenderer::staticCtor(); @@ -4305,7 +4309,7 @@ void Minecraft::handleMouseClick(int button) if (button == 0 && missTime > 0) return; if (button == 0) { -app.DebugPrintf("handleMouseClick - Player %d is +Log::info("handleMouseClick - Player %d is swinging\n",player->GetXboxPad()); player->swing(); } @@ -4380,7 +4384,7 @@ int oldCount = item != nullptr ? item->count : 0; if (gameMode->useItemOn(player, level, item, x, y, z, face)) { mayUse = false; -app.DebugPrintf("Player %d is swinging\n",player->GetXboxPad()); +Log::info("Player %d is swinging\n",player->GetXboxPad()); player->swing(); } if (item == nullptr) @@ -4432,7 +4436,7 @@ bool Minecraft::isTutorial() { void Minecraft::playerStartedTutorial(int iPad) { // If the app doesn't think we are in a tutorial mode then just ignore this // add - if (app.GetTutorialMode()) + if (GameServices::getTutorialMode()) m_inFullTutorialBits = m_inFullTutorialBits | (1 << iPad); } @@ -4440,13 +4444,13 @@ void Minecraft::playerLeftTutorial(int iPad) { // 4J Stu - Fix for bug that was flooding Sentient with LevelStart events // If the tutorial bits are already 0 then don't need to update anything if (m_inFullTutorialBits == 0) { - app.SetTutorialMode(false); + GameServices::setTutorialMode(false); return; } m_inFullTutorialBits = m_inFullTutorialBits & ~(1 << iPad); if (m_inFullTutorialBits == 0) { - app.SetTutorialMode(false); + GameServices::setTutorialMode(false); } } @@ -4459,7 +4463,7 @@ int Minecraft::InGame_SignInReturned(void* pParam, bool bContinue, int iPad) { // it's disabled Fix for #66516 - TCR #124: MPS Guest Support ; #001: // BAS Game Stability: TU8: The game crashes when second Guest signs-in // on console which takes part in Xbox LIVE multiplayer session. - app.DebugPrintf("Disabling Guest Signin\n"); + Log::info("Disabling Guest Signin\n"); XEnableGuestSignin(false); } diff --git a/targets/minecraft/client/Options.cpp b/targets/minecraft/client/Options.cpp index ecfe1f509..a9428d697 100644 --- a/targets/minecraft/client/Options.cpp +++ b/targets/minecraft/client/Options.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Options.h" #include "KeyMapping.h" @@ -256,7 +257,7 @@ void Options::toggle(const Options::Option* option, int dir) { // if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3; if (option == Option::DIFFICULTY) difficulty = (dir) & 3; - app.DebugPrintf("Option::DIFFICULTY = %d", difficulty); + Log::info("Option::DIFFICULTY = %d", difficulty); if (option == Option::GRAPHICS) { fancyGraphics = !fancyGraphics; diff --git a/targets/minecraft/client/gui/CreateWorldScreen.cpp b/targets/minecraft/client/gui/CreateWorldScreen.cpp index 5dde8ca00..61e16b7ff 100644 --- a/targets/minecraft/client/gui/CreateWorldScreen.cpp +++ b/targets/minecraft/client/gui/CreateWorldScreen.cpp @@ -1,3 +1,6 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "CreateWorldScreen.h" #include @@ -160,10 +163,10 @@ std::wstring CreateWorldScreen::findAvailableFolderName( void CreateWorldScreen::removed() { Keyboard::enableRepeatEvents(false); } void CreateWorldScreen::buttonClicked(Button* button) { - app.DebugPrintf("CreateWorldScreen::buttonClicked START\n"); + Log::info("CreateWorldScreen::buttonClicked START\n"); if (!button->active) return; if (button->id == 1) { - app.DebugPrintf( + Log::info( "CreateWorldScreen::buttonClicked 'Cancel' " "minecraft->setScreen(lastScreen)\n"); minecraft->setScreen(lastScreen); @@ -250,38 +253,38 @@ void CreateWorldScreen::buttonClicked(Button* button) { param->texturePackId = 0; param->settings = 0; - app.SetGameHostOption(eGameHostOption_Difficulty, + GameHostOptions::set(eGameHostOption_Difficulty, minecraft->options->difficulty); - app.SetGameHostOption(eGameHostOption_FriendsOfFriends, + GameHostOptions::set(eGameHostOption_FriendsOfFriends, moreOptionsParams->bAllowFriendsOfFriends); - app.SetGameHostOption(eGameHostOption_Gamertags, 1); - app.SetGameHostOption(eGameHostOption_BedrockFog, 0); - app.SetGameHostOption(eGameHostOption_GameType, + GameHostOptions::set(eGameHostOption_Gamertags, 1); + GameHostOptions::set(eGameHostOption_BedrockFog, 0); + GameHostOptions::set(eGameHostOption_GameType, (gameMode == L"survival") ? GameType::SURVIVAL->getId() : GameType::CREATIVE->getId()); - app.SetGameHostOption(eGameHostOption_LevelType, + GameHostOptions::set(eGameHostOption_LevelType, moreOptionsParams->bFlatWorld); - app.SetGameHostOption(eGameHostOption_Structures, + GameHostOptions::set(eGameHostOption_Structures, moreOptionsParams->bStructures); - app.SetGameHostOption(eGameHostOption_BonusChest, + GameHostOptions::set(eGameHostOption_BonusChest, moreOptionsParams->bBonusChest); - app.SetGameHostOption(eGameHostOption_PvP, moreOptionsParams->bPVP); - app.SetGameHostOption(eGameHostOption_TrustPlayers, + GameHostOptions::set(eGameHostOption_PvP, moreOptionsParams->bPVP); + GameHostOptions::set(eGameHostOption_TrustPlayers, moreOptionsParams->bTrust); - app.SetGameHostOption(eGameHostOption_FireSpreads, + GameHostOptions::set(eGameHostOption_FireSpreads, moreOptionsParams->bFireSpreads); - app.SetGameHostOption(eGameHostOption_TNT, moreOptionsParams->bTNT); - app.SetGameHostOption(eGameHostOption_HostCanFly, + GameHostOptions::set(eGameHostOption_TNT, moreOptionsParams->bTNT); + GameHostOptions::set(eGameHostOption_HostCanFly, moreOptionsParams->bHostPrivileges); - app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, + GameHostOptions::set(eGameHostOption_HostCanChangeHunger, moreOptionsParams->bHostPrivileges); - app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, + GameHostOptions::set(eGameHostOption_HostCanBeInvisible, moreOptionsParams->bHostPrivileges); - app.SetGameHostOption(eGameHostOption_CheatsEnabled, + GameHostOptions::set(eGameHostOption_CheatsEnabled, moreOptionsParams->bHostPrivileges); - param->settings = app.GetGameHostOption(eGameHostOption_All); + param->settings = GameHostOptions::get(eGameHostOption_All); param->xzSize = LEVEL_MAX_WIDTH; param->hellScale = HELL_LEVEL_MAX_SCALE; @@ -294,7 +297,7 @@ void CreateWorldScreen::buttonClicked(Button* button) { loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; loadingParams->lpParam = param; - app.SetAutosaveTimerTime(); + GameServices::setAutosaveTimerTime(); UIFullscreenProgressCompletionData* completionData = new UIFullscreenProgressCompletionData(); diff --git a/targets/minecraft/client/gui/Gui.cpp b/targets/minecraft/client/gui/Gui.cpp index c1520f0cf..891b438c1 100644 --- a/targets/minecraft/client/gui/Gui.cpp +++ b/targets/minecraft/client/gui/Gui.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/locale/Strings.h" #include "Gui.h" #include @@ -112,10 +114,10 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 4J-PB - selected the gui scale based on the slider settings if (minecraft->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_FULLSCREEN) { - guiScale = app.GetGameSettings(iPad, eGameSetting_UISize) + 2; + guiScale = GameServices::getGameSettings(iPad, eGameSetting_UISize) + 2; } else { guiScale = - app.GetGameSettings(iPad, eGameSetting_UISizeSplitscreen) + 2; + GameServices::getGameSettings(iPad, eGameSetting_UISizeSplitscreen) + 2; } ScreenSizeCalculator ssc(minecraft->options, minecraft->width, @@ -246,11 +248,11 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 4J-PB - turn off the slot display if a xui menu is up, or if we're // autosaving bool bDisplayGui = !ui.GetMenuDisplayed(iPad) && - !(app.GetXuiAction(iPad) == + !(GameServices::getXuiAction(iPad) == eAppAction_AutosaveSaveGameCapturedThumbnail); // if tooltips are off, set the y offset to zero - if (app.GetGameSettings(iPad, eGameSetting_Tooltips) == 0 && bDisplayGui) { + if (GameServices::getGameSettings(iPad, eGameSetting_Tooltips) == 0 && bDisplayGui) { switch (minecraft->player->m_iScreenSection) { case C4JRender::VIEWPORT_TYPE_FULLSCREEN: iTooltipsYOffset = screenHeight / 10; @@ -274,7 +276,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 4J-PB - Turn off interface if eGameSetting_DisplayHUD is off - for screen // shots/videos. - if (app.GetGameSettings(iPad, eGameSetting_DisplayHUD) == 0) { + if (GameServices::getGameSettings(iPad, eGameSetting_DisplayHUD) == 0) { bDisplayGui = false; } @@ -333,7 +335,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // 4J - this is where to set the blend factor for gui things // use the primary player's settings - unsigned char ucAlpha = app.GetGameSettings( + unsigned char ucAlpha = GameServices::getGameSettings( InputManager.GetPrimaryPad(), eGameSetting_InterfaceOpacity); // If the user has started to navigate their quickselect bar, ignore the @@ -341,7 +343,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { float fVal = fAlphaIncrementPerCent * (float)ucAlpha; if (ucAlpha < 80) { // check if we have the timer running for the opacity - unsigned int uiOpacityTimer = app.GetOpacityTimer(iPad); + unsigned int uiOpacityTimer = GameServices::getOpacityTimer(iPad); if (uiOpacityTimer != 0) { if (uiOpacityTimer < 10) { float fStep = (80.0f - (float)ucAlpha) / 10.0f; @@ -728,7 +730,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { // positions worked out by hand from the xui implementation of the // crouch icon - if (app.GetGameSettings(iPad, eGameSetting_AnimatedCharacter)) { + if (GameServices::getGameSettings(iPad, eGameSetting_AnimatedCharacter)) { // int playerIdx = minecraft->player->GetXboxPad(); static int characterDisplayTimer[4] = {0}; @@ -977,8 +979,8 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { wfeature[eTerrainFeature_Village] = L"Village: "; wfeature[eTerrainFeature_Ravine] = L"Ravine: "; - for (int i = 0; i < app.m_vTerrainFeatures.size(); i++) { - FEATURE_DATA* pFeatureData = app.m_vTerrainFeatures[i]; + for (int i = 0; i < GameServices::getTerrainFeatures().size(); i++) { + FEATURE_DATA* pFeatureData = GameServices::getTerrainFeatures()[i]; std::wstring itemInfo = L"[" + toWString(pFeatureData->x * 16) + L", " + @@ -1465,7 +1467,7 @@ void Gui::addMessage(const std::wstring& _string, int iPad, for (int i = 0; i < XUSER_MAX_COUNT; i++) { if (minecraft->localplayers[i] && !(bIsDeathMessage && - app.GetGameSettings(i, eGameSetting_DeathMessages) == 0)) { + GameServices::getGameSettings(i, eGameSetting_DeathMessages) == 0)) { guiMessages[i].insert(guiMessages[i].begin(), GuiMessage(string)); while (guiMessages[i].size() > 50) { @@ -1474,7 +1476,7 @@ void Gui::addMessage(const std::wstring& _string, int iPad, } } } else if (!(bIsDeathMessage && - app.GetGameSettings(iPad, eGameSetting_DeathMessages) == 0)) { + GameServices::getGameSettings(iPad, eGameSetting_DeathMessages) == 0)) { guiMessages[iPad].insert(guiMessages[iPad].begin(), GuiMessage(string)); while (guiMessages[iPad].size() > 50) { guiMessages[iPad].pop_back(); @@ -1509,7 +1511,7 @@ float Gui::getJukeboxOpacity(int iPad) { void Gui::setNowPlaying(const std::wstring& string) { // overlayMessageString = L"Now playing: " + string; - overlayMessageString = app.GetString(IDS_NOWPLAYING) + string; + overlayMessageString = Strings::get(IDS_NOWPLAYING) + string; overlayMessageTime = 20 * 3; animateOverlayMessageColor = true; } @@ -1517,7 +1519,7 @@ void Gui::setNowPlaying(const std::wstring& string) { void Gui::displayClientMessage(int messageId, int iPad) { // Language *language = Language::getInstance(); std::wstring languageString = - app.GetString(messageId); // language->getElement(messageId); + Strings::get(messageId); // language->getElement(messageId); addMessage(languageString, iPad); } diff --git a/targets/minecraft/client/gui/PauseScreen.cpp b/targets/minecraft/client/gui/PauseScreen.cpp index 32c3ae68a..038c26c04 100644 --- a/targets/minecraft/client/gui/PauseScreen.cpp +++ b/targets/minecraft/client/gui/PauseScreen.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "PauseScreen.h" #include @@ -32,7 +33,7 @@ void PauseScreen::init() { // 4jcraft: solves the issue of client-side only pausing in the java gui if (g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1) - app.SetXuiServerAction(InputManager.GetPrimaryPad(), + GameServices::setXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)true); buttons.push_back(new Button(1, width / 2 - 100, height / 4 + 24 * 5 + yo, I18n::get(L"menu.returnToMenu"))); @@ -70,7 +71,7 @@ void PauseScreen::exitWorld(Minecraft* minecraft, bool save) { if (g_NetworkManager.IsHost()) { server->setSaveOnExit(save); } - app.SetAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld); + GameServices::setAction(minecraft->player->GetXboxPad(), eAppAction_ExitWorld); } void PauseScreen::buttonClicked(Button* button) { @@ -90,7 +91,7 @@ void PauseScreen::buttonClicked(Button* button) { exitWorld(minecraft, true); } if (button->id == 4) { - app.SetXuiServerAction(InputManager.GetPrimaryPad(), + GameServices::setXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)false); minecraft->setScreen(nullptr); // minecraft->grabMouse(); // 4J - removed diff --git a/targets/minecraft/client/gui/Screen.cpp b/targets/minecraft/client/gui/Screen.cpp index 8e7f94a23..1f1fa4fc3 100644 --- a/targets/minecraft/client/gui/Screen.cpp +++ b/targets/minecraft/client/gui/Screen.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "Screen.h" #include "platform/InputActions.h" @@ -43,7 +44,7 @@ void Screen::keyPressed(wchar_t eventCharacter, int eventKey) { // unpausing is done in all scenarios if (g_NetworkManager.IsLocalGame() && g_NetworkManager.GetPlayerCount() == 1) - app.SetXuiServerAction(InputManager.GetPrimaryPad(), + GameServices::setXuiServerAction(InputManager.GetPrimaryPad(), eXuiServerAction_PauseServer, (void*)false); } } diff --git a/targets/minecraft/client/gui/SelectWorldScreen.cpp b/targets/minecraft/client/gui/SelectWorldScreen.cpp index 101e19cdd..3d121c03f 100644 --- a/targets/minecraft/client/gui/SelectWorldScreen.cpp +++ b/targets/minecraft/client/gui/SelectWorldScreen.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "SelectWorldScreen.h" #include @@ -34,7 +35,7 @@ SelectWorldScreen::SelectWorldScreen(Screen* lastScreen) { } void SelectWorldScreen::init() { - app.DebugPrintf("SelectWorldScreen::init() START\n"); + Log::info("SelectWorldScreen::init() START\n"); Language* language = Language::getInstance(); title = language->getElement(L"selectWorld.title"); @@ -95,7 +96,7 @@ void SelectWorldScreen::postInit() { } void SelectWorldScreen::buttonClicked(Button* button) { - app.DebugPrintf("SelectWorldScreen::buttonClicked START\n"); + Log::info("SelectWorldScreen::buttonClicked START\n"); if (!button->active) return; if (button->id == BUTTON_DELETE_ID) { std::wstring worldName = getWorldName(selectedWorld); @@ -124,7 +125,7 @@ void SelectWorldScreen::buttonClicked(Button* button) { minecraft->setScreen( new RenameWorldScreen(this, getWorldId(selectedWorld))); } else if (button->id == BUTTON_CANCEL_ID) { - app.DebugPrintf( + Log::info( "SelectWorldScreen::buttonClicked 'Cancel' " "minecraft->setScreen(lastScreen)\n"); minecraft->setScreen(lastScreen); @@ -200,7 +201,7 @@ void SelectWorldScreen::render(int xm, int ym, float a) { count = 0; } } else { - app.DebugPrintf( + Log::info( "SelectWorldScreen::render minecraft->setScreen(new " "CreateWorldScreen(this))\n"); minecraft->setScreen(new CreateWorldScreen(this)); diff --git a/targets/minecraft/client/gui/inventory/AbstractContainerScreen.cpp b/targets/minecraft/client/gui/inventory/AbstractContainerScreen.cpp index 9456dfd3e..909890eab 100644 --- a/targets/minecraft/client/gui/inventory/AbstractContainerScreen.cpp +++ b/targets/minecraft/client/gui/inventory/AbstractContainerScreen.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "AbstractContainerScreen.h" #include @@ -248,7 +249,7 @@ void AbstractContainerScreen::renderTooltip(std::shared_ptr item, } if (!cleanedLines.empty()) { - lineColors[0] = app.GetHTMLColour(item->getRarity()->color); + lineColors[0] = GameServices::getHTMLColour(item->getRarity()->color); } renderTooltipInternal(cleanedLines, lineColors, xm, ym); diff --git a/targets/minecraft/client/gui/inventory/BeaconPowerButton.cpp b/targets/minecraft/client/gui/inventory/BeaconPowerButton.cpp index ae1bd13a0..b0810ae5d 100644 --- a/targets/minecraft/client/gui/inventory/BeaconPowerButton.cpp +++ b/targets/minecraft/client/gui/inventory/BeaconPowerButton.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "BeaconPowerButton.h" #include @@ -34,7 +35,7 @@ void BeaconPowerButton::renderTooltip(int xm, int ym) { MobEffect* effect = MobEffect::effects[effectId]; if (!effect) return; - std::wstring name = app.GetString(effect->getDescriptionId()); + std::wstring name = Strings::get(effect->getDescriptionId()); if (tier >= 3 && effect->id != MobEffect::regeneration->id) { name += L" II"; } diff --git a/targets/minecraft/client/gui/inventory/CreativeInventoryScreen.cpp b/targets/minecraft/client/gui/inventory/CreativeInventoryScreen.cpp index ac5edd501..624674746 100644 --- a/targets/minecraft/client/gui/inventory/CreativeInventoryScreen.cpp +++ b/targets/minecraft/client/gui/inventory/CreativeInventoryScreen.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "CreativeInventoryScreen.h" #include @@ -411,7 +412,7 @@ void CreativeInventoryScreen::renderLabels() { IUIScene_CreativeMenu::TabSpec* spec = IUIScene_CreativeMenu::specs[selectedTabIndex]; if (spec) { - std::wstring tabName = app.GetString(spec->m_descriptionId); + std::wstring tabName = Strings::get(spec->m_descriptionId); font->draw(tabName, 8, 6, 0x404040); } } @@ -589,7 +590,7 @@ bool CreativeInventoryScreen::renderIconTooltip(int tab, int mouseX, glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); renderTooltip( - app.GetString(IUIScene_CreativeMenu::specs[tab]->m_descriptionId), + Strings::get(IUIScene_CreativeMenu::specs[tab]->m_descriptionId), mouseX, mouseY); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); diff --git a/targets/minecraft/client/model/HumanoidModel.cpp b/targets/minecraft/client/model/HumanoidModel.cpp index 7801c5f6f..630a0eabf 100644 --- a/targets/minecraft/client/model/HumanoidModel.cpp +++ b/targets/minecraft/client/model/HumanoidModel.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "HumanoidModel.h" #include @@ -44,14 +45,14 @@ ModelPart* HumanoidModel::AddOrRetrievePart(SKIN_BOX* pBox) { if (pNewBox) { if ((pNewBox->getfU() != (int)pBox->fU) || (pNewBox->getfV() != (int)pBox->fV)) { - app.DebugPrintf( + Log::info( "HumanoidModel::AddOrRetrievePart - Box geometry was found, " "but with different uvs\n"); pNewBox = nullptr; } } if (pNewBox == nullptr) { - // app.DebugPrintf("HumanoidModel::AddOrRetrievePart - Adding box to + // Log::info("HumanoidModel::AddOrRetrievePart - Adding box to // model part\n"); pNewBox = new ModelPart(this, (int)pBox->fU, (int)pBox->fV); diff --git a/targets/minecraft/client/multiplayer/ClientConnection.cpp b/targets/minecraft/client/multiplayer/ClientConnection.cpp index 481f056b2..e687e9877 100644 --- a/targets/minecraft/client/multiplayer/ClientConnection.cpp +++ b/targets/minecraft/client/multiplayer/ClientConnection.cpp @@ -1,3 +1,8 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/locale/Strings.h" +#include "minecraft/util/Log.h" #include "ClientConnection.h" #include @@ -274,7 +279,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { MOJANG_DATA* pMojangData = nullptr; if (!g_NetworkManager.IsLocalGame()) { - pMojangData = app.GetMojangDataForXuid(OnlineXuid); + pMojangData = GameServices::getMojangDataForXuid(OnlineXuid); } if (!g_NetworkManager.IsHost()) { @@ -314,12 +319,12 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { if (pMojangData->wchSkin[0] != 0L) { std::wstring wstr = pMojangData->wchSkin; // check the file is not already in - bRes = app.IsFileInMemoryTextures(wstr); + bRes = GameServices::isFileInMemoryTextures(wstr); if (!bRes) { } if (bRes) { - app.AddMemoryTextureFile(wstr, pBuffer, dwSize); + GameServices::addMemoryTextureFile(wstr, pBuffer, dwSize); } } @@ -327,25 +332,25 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { if (pMojangData->wchCape[0] != 0L) { std::wstring wstr = pMojangData->wchCape; // check the file is not already in - bRes = app.IsFileInMemoryTextures(wstr); + bRes = GameServices::isFileInMemoryTextures(wstr); if (!bRes) { } if (bRes) { - app.AddMemoryTextureFile(wstr, pBuffer, dwSize); + GameServices::addMemoryTextureFile(wstr, pBuffer, dwSize); } } } // If we're online, read the banned game list - app.ReadBannedList(iUserID); + GameServices::readBannedList(iUserID); // mark the level as not checked against banned levels - it'll be // checked once the level starts - app.SetBanListCheck(iUserID, false); + GameServices::setBanListCheck(iUserID, false); } if (m_userIndex == InputManager.GetPrimaryPad()) { - if (app.GetTutorialMode()) { + if (GameServices::getTutorialMode()) { minecraft->gameMode = new FullTutorialMode( InputManager.GetPrimaryPad(), minecraft, this); } else { @@ -374,7 +379,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { level->savedDataStorage = activeLevel->savedDataStorage; } - app.DebugPrintf("ClientConnection - DIFFICULTY --- %d\n", + Log::info("ClientConnection - DIFFICULTY --- %d\n", packet->difficulty); level->difficulty = packet->difficulty; // 4J Added level->isClientSide = true; @@ -382,8 +387,8 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { } minecraft->player->setPlayerIndex(packet->m_playerIndex); - minecraft->player->setCustomSkin(app.GetPlayerSkinId(m_userIndex)); - minecraft->player->setCustomCape(app.GetPlayerCapeId(m_userIndex)); + minecraft->player->setCustomSkin(GameServices::getPlayerSkinId(m_userIndex)); + minecraft->player->setCustomCape(GameServices::getPlayerCapeId(m_userIndex)); minecraft->createPrimaryLocalPlayer(InputManager.GetPrimaryPad()); @@ -392,7 +397,7 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { minecraft->player->entityId = packet->clientVersion; std::uint8_t networkSmallId = getSocket()->getSmallId(); - app.UpdatePlayerInfo(networkSmallId, packet->m_playerIndex, + GameServices::updatePlayerInfo(networkSmallId, packet->m_playerIndex, packet->m_uiGamePrivileges); minecraft->player->setPlayerGamePrivilege( Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); @@ -410,8 +415,8 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { displayPrivilegeChanges(minecraft->player, startingPrivileges); // update the debugoptions - app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(), - app.GetGameSettingsDebugMask(-1, true)); + GameServices::setGameSettingsDebugMask(InputManager.GetPrimaryPad(), + DebugSettings::getMask(-1, true)); } else { // 4J-PB - this isn't the level we want // level = (MultiPlayerLevel *)minecraft->level; @@ -469,11 +474,11 @@ void ClientConnection::handleLogin(std::shared_ptr packet) { player->entityId = packet->clientVersion; player->setPlayerIndex(packet->m_playerIndex); - player->setCustomSkin(app.GetPlayerSkinId(m_userIndex)); - player->setCustomCape(app.GetPlayerCapeId(m_userIndex)); + player->setCustomSkin(GameServices::getPlayerSkinId(m_userIndex)); + player->setCustomCape(GameServices::getPlayerCapeId(m_userIndex)); std::uint8_t networkSmallId = getSocket()->getSmallId(); - app.UpdatePlayerInfo(networkSmallId, packet->m_playerIndex, + GameServices::updatePlayerInfo(networkSmallId, packet->m_playerIndex, packet->m_uiGamePrivileges); player->setPlayerGamePrivilege(Player::ePlayerGamePrivilege_All, packet->m_uiGamePrivileges); @@ -556,7 +561,7 @@ void ClientConnection::handleAddEntity( int ix = (int)x; int iy = (int)y; int iz = (int)z; - app.DebugPrintf("ClientConnection ITEM_FRAME xyz %d,%d,%d\n", ix, + Log::info("ClientConnection ITEM_FRAME xyz %d,%d,%d\n", ix, iy, iz); } e = std::shared_ptr( @@ -873,7 +878,7 @@ void ClientConnection::handleAddPlayer( ProfileManager.AreXUIDSEqual(playerXUIDOnline, packet->xuid)) || (playerXUIDOffline != INVALID_XUID && ProfileManager.AreXUIDSEqual(playerXUIDOffline, packet->xuid))) { - app.DebugPrintf( + Log::info( "AddPlayerPacket received with XUID of local player\n"); return; } @@ -918,10 +923,10 @@ void ClientConnection::handleAddPlayer( if (!player->customTextureUrl.empty() && player->customTextureUrl.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(player->customTextureUrl)) { + !GameServices::isFileInMemoryTextures(player->customTextureUrl)) { if (minecraft->addPendingClientTextureRequest( player->customTextureUrl)) { - app.DebugPrintf( + Log::info( "Client sending TextureAndGeometryPacket to get custom skin " "%ls for player %ls\n", player->customTextureUrl.c_str(), player->name.c_str()); @@ -931,20 +936,20 @@ void ClientConnection::handleAddPlayer( 0))); } } else if (!player->customTextureUrl.empty() && - app.IsFileInMemoryTextures(player->customTextureUrl)) { + GameServices::isFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl, nullptr, 0); + GameServices::addMemoryTextureFile(player->customTextureUrl, nullptr, 0); } - app.DebugPrintf("Custom skin for player %ls is %ls\n", player->name.c_str(), + Log::info("Custom skin for player %ls is %ls\n", player->name.c_str(), player->customTextureUrl.c_str()); if (!player->customTextureUrl2.empty() && player->customTextureUrl2.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(player->customTextureUrl2)) { + !GameServices::isFileInMemoryTextures(player->customTextureUrl2)) { if (minecraft->addPendingClientTextureRequest( player->customTextureUrl2)) { - app.DebugPrintf( + Log::info( "Client sending texture packet to get custom cape %ls for " "player %ls\n", player->customTextureUrl2.c_str(), player->name.c_str()); @@ -952,12 +957,12 @@ void ClientConnection::handleAddPlayer( new TexturePacket(player->customTextureUrl2, nullptr, 0))); } } else if (!player->customTextureUrl2.empty() && - app.IsFileInMemoryTextures(player->customTextureUrl2)) { + GameServices::isFileInMemoryTextures(player->customTextureUrl2)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl2, nullptr, 0); + GameServices::addMemoryTextureFile(player->customTextureUrl2, nullptr, 0); } - app.DebugPrintf("Custom cape for player %ls is %ls\n", player->name.c_str(), + Log::info("Custom cape for player %ls is %ls\n", player->name.c_str(), player->customTextureUrl2.c_str()); level->putEntity(packet->id, player); @@ -1114,7 +1119,7 @@ void ClientConnection::handleMovePlayer( // Minecraft::createExtraLocalPlayer 4J-PB - can't call this when this // function is called from the qnet thread (GetGameStarted will be // false) - if (app.GetGameStarted()) { + if (GameServices::getGameStarted()) { ui.CloseUIScenes(m_userIndex); } } @@ -1337,9 +1342,9 @@ void ClientConnection::handleDisconnect( Minecraft* pMinecraft = Minecraft::GetInstance(); pMinecraft->connectionDisconnected(m_userIndex, packet->reason); - app.SetDisconnectReason(packet->reason); + GameServices::setDisconnectReason(packet->reason); - app.SetAction(m_userIndex, eAppAction_ExitWorld, (void*)true); + GameServices::setAction(m_userIndex, eAppAction_ExitWorld, (void*)true); // minecraft->setLevel(nullptr); // minecraft->setScreen(new DisconnectedScreen(L"disconnect.disconnected", // L"disconnect.genericReason", &packet->reason)); @@ -1369,7 +1374,7 @@ void ClientConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, &ClientConnection::HostDisconnectReturned, nullptr); } else { - app.SetAction(m_userIndex, eAppAction_ExitWorld, (void*)true); + GameServices::setAction(m_userIndex, eAppAction_ExitWorld, (void*)true); } // minecraft->setLevel(nullptr); @@ -1439,7 +1444,7 @@ void ClientConnection::handleTakeItemEntity( ((random->nextFloat() - random->nextFloat()) * 0.7f + 1.0f) * 2.0f; - app.DebugPrintf("XP Orb with pitch %f\n", fPitch); + Log::info("XP Orb with pitch %f\n", fPitch); level->playSound(from, eSoundType_RANDOM_ORB, 0.2f, fPitch); } else { level->playSound( @@ -1494,327 +1499,327 @@ void ClientConnection::handleChat(std::shared_ptr packet) { switch (packet->m_messageType) { case ChatPacket::e_ChatBedOccupied: - message = app.GetString(IDS_TILE_BED_OCCUPIED); + message = Strings::get(IDS_TILE_BED_OCCUPIED); break; case ChatPacket::e_ChatBedNoSleep: - message = app.GetString(IDS_TILE_BED_NO_SLEEP); + message = Strings::get(IDS_TILE_BED_NO_SLEEP); break; case ChatPacket::e_ChatBedNotValid: - message = app.GetString(IDS_TILE_BED_NOT_VALID); + message = Strings::get(IDS_TILE_BED_NOT_VALID); break; case ChatPacket::e_ChatBedNotSafe: - message = app.GetString(IDS_TILE_BED_NOTSAFE); + message = Strings::get(IDS_TILE_BED_NOTSAFE); break; case ChatPacket::e_ChatBedPlayerSleep: - message = app.GetString(IDS_TILE_BED_PLAYERSLEEP); + message = Strings::get(IDS_TILE_BED_PLAYERSLEEP); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatBedMeSleep: - message = app.GetString(IDS_TILE_BED_MESLEEP); + message = Strings::get(IDS_TILE_BED_MESLEEP); break; case ChatPacket::e_ChatPlayerJoinedGame: - message = app.GetString(IDS_PLAYER_JOINED); + message = Strings::get(IDS_PLAYER_JOINED); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatPlayerLeftGame: - message = app.GetString(IDS_PLAYER_LEFT); + message = Strings::get(IDS_PLAYER_LEFT); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatPlayerKickedFromGame: - message = app.GetString(IDS_PLAYER_KICKED); + message = Strings::get(IDS_PLAYER_KICKED); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatCannotPlaceLava: displayOnGui = false; - app.SetGlobalXuiAction(eAppAction_DisplayLavaMessage); + GameServices::setGlobalXuiAction(eAppAction_DisplayLavaMessage); break; case ChatPacket::e_ChatDeathInFire: - message = app.GetString(IDS_DEATH_INFIRE); + message = Strings::get(IDS_DEATH_INFIRE); replacePlayer = true; break; case ChatPacket::e_ChatDeathOnFire: - message = app.GetString(IDS_DEATH_ONFIRE); + message = Strings::get(IDS_DEATH_ONFIRE); replacePlayer = true; break; case ChatPacket::e_ChatDeathLava: - message = app.GetString(IDS_DEATH_LAVA); + message = Strings::get(IDS_DEATH_LAVA); replacePlayer = true; break; case ChatPacket::e_ChatDeathInWall: - message = app.GetString(IDS_DEATH_INWALL); + message = Strings::get(IDS_DEATH_INWALL); replacePlayer = true; break; case ChatPacket::e_ChatDeathDrown: - message = app.GetString(IDS_DEATH_DROWN); + message = Strings::get(IDS_DEATH_DROWN); replacePlayer = true; break; case ChatPacket::e_ChatDeathStarve: - message = app.GetString(IDS_DEATH_STARVE); + message = Strings::get(IDS_DEATH_STARVE); replacePlayer = true; break; case ChatPacket::e_ChatDeathCactus: - message = app.GetString(IDS_DEATH_CACTUS); + message = Strings::get(IDS_DEATH_CACTUS); replacePlayer = true; break; case ChatPacket::e_ChatDeathFall: - message = app.GetString(IDS_DEATH_FALL); + message = Strings::get(IDS_DEATH_FALL); replacePlayer = true; break; case ChatPacket::e_ChatDeathOutOfWorld: - message = app.GetString(IDS_DEATH_OUTOFWORLD); + message = Strings::get(IDS_DEATH_OUTOFWORLD); replacePlayer = true; break; case ChatPacket::e_ChatDeathGeneric: - message = app.GetString(IDS_DEATH_GENERIC); + message = Strings::get(IDS_DEATH_GENERIC); replacePlayer = true; break; case ChatPacket::e_ChatDeathExplosion: - message = app.GetString(IDS_DEATH_EXPLOSION); + message = Strings::get(IDS_DEATH_EXPLOSION); replacePlayer = true; break; case ChatPacket::e_ChatDeathMagic: - message = app.GetString(IDS_DEATH_MAGIC); + message = Strings::get(IDS_DEATH_MAGIC); replacePlayer = true; break; case ChatPacket::e_ChatDeathAnvil: - message = app.GetString(IDS_DEATH_FALLING_ANVIL); + message = Strings::get(IDS_DEATH_FALLING_ANVIL); replacePlayer = true; break; case ChatPacket::e_ChatDeathFallingBlock: - message = app.GetString(IDS_DEATH_FALLING_TILE); + message = Strings::get(IDS_DEATH_FALLING_TILE); replacePlayer = true; break; case ChatPacket::e_ChatDeathDragonBreath: - message = app.GetString(IDS_DEATH_DRAGON_BREATH); + message = Strings::get(IDS_DEATH_DRAGON_BREATH); replacePlayer = true; break; case ChatPacket::e_ChatDeathMob: - message = app.GetString(IDS_DEATH_MOB); + message = Strings::get(IDS_DEATH_MOB); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathPlayer: - message = app.GetString(IDS_DEATH_PLAYER); + message = Strings::get(IDS_DEATH_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathArrow: - message = app.GetString(IDS_DEATH_ARROW); + message = Strings::get(IDS_DEATH_ARROW); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathFireball: - message = app.GetString(IDS_DEATH_FIREBALL); + message = Strings::get(IDS_DEATH_FIREBALL); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathThrown: - message = app.GetString(IDS_DEATH_THROWN); + message = Strings::get(IDS_DEATH_THROWN); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathIndirectMagic: - message = app.GetString(IDS_DEATH_INDIRECT_MAGIC); + message = Strings::get(IDS_DEATH_INDIRECT_MAGIC); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathThorns: - message = app.GetString(IDS_DEATH_THORNS); + message = Strings::get(IDS_DEATH_THORNS); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathFellAccidentLadder: - message = app.GetString(IDS_DEATH_FELL_ACCIDENT_LADDER); + message = Strings::get(IDS_DEATH_FELL_ACCIDENT_LADDER); replacePlayer = true; break; case ChatPacket::e_ChatDeathFellAccidentVines: - message = app.GetString(IDS_DEATH_FELL_ACCIDENT_VINES); + message = Strings::get(IDS_DEATH_FELL_ACCIDENT_VINES); replacePlayer = true; break; case ChatPacket::e_ChatDeathFellAccidentWater: - message = app.GetString(IDS_DEATH_FELL_ACCIDENT_WATER); + message = Strings::get(IDS_DEATH_FELL_ACCIDENT_WATER); replacePlayer = true; break; case ChatPacket::e_ChatDeathFellAccidentGeneric: - message = app.GetString(IDS_DEATH_FELL_ACCIDENT_GENERIC); + message = Strings::get(IDS_DEATH_FELL_ACCIDENT_GENERIC); replacePlayer = true; break; case ChatPacket::e_ChatDeathFellKiller: - // message=app.GetString(IDS_DEATH_FELL_KILLER); + // message=Strings::get(IDS_DEATH_FELL_KILLER); // replacePlayer = true; // replaceEntitySource = true; // 4J Stu - The correct string for here, IDS_DEATH_FELL_KILLER is // incorrect. We can't change localisation, so use a different // string for now - message = app.GetString(IDS_DEATH_FALL); + message = Strings::get(IDS_DEATH_FALL); replacePlayer = true; break; case ChatPacket::e_ChatDeathFellAssist: - message = app.GetString(IDS_DEATH_FELL_ASSIST); + message = Strings::get(IDS_DEATH_FELL_ASSIST); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathFellAssistItem: - message = app.GetString(IDS_DEATH_FELL_ASSIST_ITEM); + message = Strings::get(IDS_DEATH_FELL_ASSIST_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathFellFinish: - message = app.GetString(IDS_DEATH_FELL_FINISH); + message = Strings::get(IDS_DEATH_FELL_FINISH); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathFellFinishItem: - message = app.GetString(IDS_DEATH_FELL_FINISH_ITEM); + message = Strings::get(IDS_DEATH_FELL_FINISH_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathInFirePlayer: - message = app.GetString(IDS_DEATH_INFIRE_PLAYER); + message = Strings::get(IDS_DEATH_INFIRE_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathOnFirePlayer: - message = app.GetString(IDS_DEATH_ONFIRE_PLAYER); + message = Strings::get(IDS_DEATH_ONFIRE_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathLavaPlayer: - message = app.GetString(IDS_DEATH_LAVA_PLAYER); + message = Strings::get(IDS_DEATH_LAVA_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathDrownPlayer: - message = app.GetString(IDS_DEATH_DROWN_PLAYER); + message = Strings::get(IDS_DEATH_DROWN_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathCactusPlayer: - message = app.GetString(IDS_DEATH_CACTUS_PLAYER); + message = Strings::get(IDS_DEATH_CACTUS_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathExplosionPlayer: - message = app.GetString(IDS_DEATH_EXPLOSION_PLAYER); + message = Strings::get(IDS_DEATH_EXPLOSION_PLAYER); replacePlayer = true; replaceEntitySource = true; break; case ChatPacket::e_ChatDeathWither: - message = app.GetString(IDS_DEATH_WITHER); + message = Strings::get(IDS_DEATH_WITHER); replacePlayer = true; break; case ChatPacket::e_ChatDeathPlayerItem: - message = app.GetString(IDS_DEATH_PLAYER_ITEM); + message = Strings::get(IDS_DEATH_PLAYER_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathArrowItem: - message = app.GetString(IDS_DEATH_ARROW_ITEM); + message = Strings::get(IDS_DEATH_ARROW_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathFireballItem: - message = app.GetString(IDS_DEATH_FIREBALL_ITEM); + message = Strings::get(IDS_DEATH_FIREBALL_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathThrownItem: - message = app.GetString(IDS_DEATH_THROWN_ITEM); + message = Strings::get(IDS_DEATH_THROWN_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatDeathIndirectMagicItem: - message = app.GetString(IDS_DEATH_INDIRECT_MAGIC_ITEM); + message = Strings::get(IDS_DEATH_INDIRECT_MAGIC_ITEM); replacePlayer = true; replaceEntitySource = true; replaceItem = true; break; case ChatPacket::e_ChatPlayerEnteredEnd: - message = app.GetString(IDS_PLAYER_ENTERED_END); + message = Strings::get(IDS_PLAYER_ENTERED_END); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatPlayerLeftEnd: - message = app.GetString(IDS_PLAYER_LEFT_END); + message = Strings::get(IDS_PLAYER_LEFT_END); iPos = message.find(L"%s"); message.replace(iPos, 2, playerDisplayName); break; case ChatPacket::e_ChatPlayerMaxEnemies: - message = app.GetString(IDS_MAX_ENEMIES_SPAWNED); + message = Strings::get(IDS_MAX_ENEMIES_SPAWNED); break; // Spawn eggs case ChatPacket::e_ChatPlayerMaxVillagers: - message = app.GetString(IDS_MAX_VILLAGERS_SPAWNED); + message = Strings::get(IDS_MAX_VILLAGERS_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxPigsSheepCows: - message = app.GetString(IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED); + message = Strings::get(IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxChickens: - message = app.GetString(IDS_MAX_CHICKENS_SPAWNED); + message = Strings::get(IDS_MAX_CHICKENS_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxSquid: - message = app.GetString(IDS_MAX_SQUID_SPAWNED); + message = Strings::get(IDS_MAX_SQUID_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxMooshrooms: - message = app.GetString(IDS_MAX_MOOSHROOMS_SPAWNED); + message = Strings::get(IDS_MAX_MOOSHROOMS_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxWolves: - message = app.GetString(IDS_MAX_WOLVES_SPAWNED); + message = Strings::get(IDS_MAX_WOLVES_SPAWNED); break; case ChatPacket::e_ChatPlayerMaxBats: - message = app.GetString(IDS_MAX_BATS_SPAWNED); + message = Strings::get(IDS_MAX_BATS_SPAWNED); break; // Breeding case ChatPacket::e_ChatPlayerMaxBredPigsSheepCows: - message = app.GetString(IDS_MAX_PIGS_SHEEP_COWS_CATS_BRED); + message = Strings::get(IDS_MAX_PIGS_SHEEP_COWS_CATS_BRED); break; case ChatPacket::e_ChatPlayerMaxBredChickens: - message = app.GetString(IDS_MAX_CHICKENS_BRED); + message = Strings::get(IDS_MAX_CHICKENS_BRED); break; case ChatPacket::e_ChatPlayerMaxBredMooshrooms: - message = app.GetString(IDS_MAX_MUSHROOMCOWS_BRED); + message = Strings::get(IDS_MAX_MUSHROOMCOWS_BRED); break; case ChatPacket::e_ChatPlayerMaxBredWolves: - message = app.GetString(IDS_MAX_WOLVES_BRED); + message = Strings::get(IDS_MAX_WOLVES_BRED); break; // can't shear the mooshroom case ChatPacket::e_ChatPlayerCantShearMooshroom: - message = app.GetString(IDS_CANT_SHEAR_MOOSHROOM); + message = Strings::get(IDS_CANT_SHEAR_MOOSHROOM); break; // Paintings/Item Frames case ChatPacket::e_ChatPlayerMaxHangingEntities: - message = app.GetString(IDS_MAX_HANGINGENTITIES); + message = Strings::get(IDS_MAX_HANGINGENTITIES); break; // Enemy spawn eggs in peaceful case ChatPacket::e_ChatPlayerCantSpawnInPeaceful: - message = app.GetString(IDS_CANT_SPAWN_IN_PEACEFUL); + message = Strings::get(IDS_CANT_SPAWN_IN_PEACEFUL); break; // Enemy spawn eggs in peaceful case ChatPacket::e_ChatPlayerMaxBoats: - message = app.GetString(IDS_MAX_BOATS); + message = Strings::get(IDS_MAX_BOATS); break; case ChatPacket::e_ChatCommandTeleportSuccess: - message = app.GetString(IDS_COMMAND_TELEPORT_SUCCESS); + message = Strings::get(IDS_COMMAND_TELEPORT_SUCCESS); replacePlayer = true; if (packet->m_intArgs[0] == eTYPE_SERVERPLAYER) { message = @@ -1822,15 +1827,15 @@ void ClientConnection::handleChat(std::shared_ptr packet) { } else { message = replaceAll( message, L"{*DESTINATION*}", - app.getEntityName((eINSTANCEOF)packet->m_intArgs[0])); + GameServices::getEntityName((EntityTypeId)packet->m_intArgs[0])); } break; case ChatPacket::e_ChatCommandTeleportMe: - message = app.GetString(IDS_COMMAND_TELEPORT_ME); + message = Strings::get(IDS_COMMAND_TELEPORT_ME); replacePlayer = true; break; case ChatPacket::e_ChatCommandTeleportToMe: - message = app.GetString(IDS_COMMAND_TELEPORT_TO_ME); + message = Strings::get(IDS_COMMAND_TELEPORT_TO_ME); replacePlayer = true; break; @@ -1855,7 +1860,7 @@ void ClientConnection::handleChat(std::shared_ptr packet) { entityName = packet->m_stringArgs[1]; } else { entityName = - app.getEntityName((eINSTANCEOF)packet->m_intArgs[0]); + GameServices::getEntityName((EntityTypeId)packet->m_intArgs[0]); } message = replaceAll(message, L"{*SOURCE*}", entityName); @@ -1929,12 +1934,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { if (!g_NetworkManager.IsHost()) { // set the game host settings - app.SetGameHostOption(eGameHostOption_All, packet->m_serverSettings); + GameHostOptions::set(eGameHostOption_All, packet->m_serverSettings); // 4J-PB - if we go straight in from the menus via an invite, we won't // have the DLC info - if (app.GetTMSGlobalFileListRead() == false) { - app.SetTMSAction(InputManager.GetPrimaryPad(), + if (GameServices::getTMSGlobalFileListRead() == false) { + GameServices::setTMSAction(InputManager.GetPrimaryPad(), eTMSAction_TMSPP_RetrieveFiles_RunPlayGame); } } @@ -1960,12 +1965,12 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { reason = DisconnectPacket::eDisconnect_ContentRestricted_AllLocal; - app.DebugPrintf( + Log::info( "Exiting world on handling Pre-Login packet due UGC " "privileges: %d\n", reason); - app.SetDisconnectReason(reason); - app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ExitWorld, + GameServices::setDisconnectReason(reason); + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_ExitWorld, (void*)true); } else { if (!isFriendsWithHost) @@ -1976,7 +1981,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { reason = DisconnectPacket:: eDisconnect_ContentRestricted_Single_Local; - app.DebugPrintf( + Log::info( "Exiting player %d on handling Pre-Login packet due UGC " "privileges: %d\n", m_userIndex, reason); @@ -1992,7 +1997,7 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { IDS_NO_USER_CREATED_CONTENT_PRIVILEGE_SINGLE_LOCAL, uiIDA, 1, m_userIndex); - app.SetDisconnectReason(reason); + GameServices::setDisconnectReason(reason); // 4J-PB - this locks up on the read and write threads not closing // down, because they are trying to lock the incoming critsec when @@ -2000,10 +2005,10 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { // Minecraft::GetInstance()->connectionDisconnected( // m_userIndex , reason ); done = true; // connection->flush(); connection->close(reason); - // app.SetAction(m_userIndex,eAppAction_ExitPlayer); + // GameServices::setAction(m_userIndex,eAppAction_ExitPlayer); // 4J-PB - doing this instead - app.SetAction(m_userIndex, eAppAction_ExitPlayerPreLogin); + GameServices::setAction(m_userIndex, eAppAction_ExitPlayerPreLogin); } } else { // Texture pack handling @@ -2016,11 +2021,11 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft->skins->selectTexturePackById( packet->m_texturePackId)) { - app.DebugPrintf( + Log::info( "Selected texture pack %d from Pre-Login packet\n", packet->m_texturePackId); } else { - app.DebugPrintf( + Log::info( "Could not select texture pack %d from Pre-Login packet, " "requesting from host\n", packet->m_texturePackId); @@ -2064,8 +2069,8 @@ void ClientConnection::handlePreLogin(std::shared_ptr packet) { send(std::make_shared( minecraft->user->name, SharedConstants::NETWORK_PROTOCOL_VERSION, offlineXUID, onlineXUID, (!allAllowed && friendsAllowed), - packet->m_ugcPlayersVersion, app.GetPlayerSkinId(m_userIndex), - app.GetPlayerCapeId(m_userIndex), + packet->m_ugcPlayersVersion, GameServices::getPlayerSkinId(m_userIndex), + GameServices::getPlayerCapeId(m_userIndex), ProfileManager.IsGuest(m_userIndex))); fprintf(stderr, "[LOGIN] LoginPacket sent successfully\n"); @@ -2266,7 +2271,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) { #endif std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; - app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); + GameServices::getMemFileDetails(packet->textureName, &pbData, &dwBytes); if (dwBytes != 0) { send(std::shared_ptr( @@ -2278,7 +2283,7 @@ void ClientConnection::handleTexture(std::shared_ptr packet) { wprintf(L"Client received custom texture %ls\n", packet->textureName.c_str()); #endif - app.AddMemoryTextureFile(packet->textureName, packet->pbData, + GameServices::addMemoryTextureFile(packet->textureName, packet->pbData, packet->dataBytes); Minecraft::GetInstance()->handleClientTextureReceived( packet->textureName); @@ -2301,9 +2306,9 @@ void ClientConnection::handleTextureAndGeometry( #endif std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; - app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); + GameServices::getMemFileDetails(packet->textureName, &pbData, &dwBytes); DLCSkinFile* pDLCSkinFile = - app.m_dlcManager.getSkinFile(packet->textureName); + GameServices::getDLCManager().getSkinFile(packet->textureName); if (dwBytes != 0) { if (pDLCSkinFile) { @@ -2319,12 +2324,12 @@ void ClientConnection::handleTextureAndGeometry( } } else { unsigned int uiAnimOverrideBitmask = - app.GetAnimOverrideBitmask(packet->dwSkinID); + GameServices::getAnimOverrideBitmask(packet->dwSkinID); send(std::shared_ptr( new TextureAndGeometryPacket( packet->textureName, pbData, dwBytes, - app.GetAdditionalSkinBoxes(packet->dwSkinID), + GameServices::getAdditionalSkinBoxes(packet->dwSkinID), uiAnimOverrideBitmask))); } } @@ -2335,15 +2340,15 @@ void ClientConnection::handleTextureAndGeometry( packet->textureName.c_str()); #endif // Add the texture data - app.AddMemoryTextureFile(packet->textureName, packet->pbData, + GameServices::addMemoryTextureFile(packet->textureName, packet->pbData, packet->dwTextureBytes); // Add the geometry data if (packet->dwBoxC != 0) { - app.SetAdditionalSkinBoxes(packet->dwSkinID, packet->BoxDataA, + GameServices::setAdditionalSkinBoxes(packet->dwSkinID, packet->BoxDataA, packet->dwBoxC); } // Add the anim override - app.SetAnimOverrideBitmask(packet->dwSkinID, + GameServices::setAnimOverrideBitmask(packet->dwSkinID, packet->uiAnimOverrideBitmask); // clear out the pending texture request @@ -2371,7 +2376,7 @@ void ClientConnection::handleTextureChange( switch (packet->action) { case TextureChangePacket::e_TextureChange_Skin: - player->setCustomSkin(app.getSkinIdFromPath(packet->path)); + player->setCustomSkin(GameServices::getSkinIdFromPath(packet->path)); #if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for remote player %ls has changed to %ls (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), @@ -2390,7 +2395,7 @@ void ClientConnection::handleTextureChange( if (!packet->path.empty() && packet->path.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(packet->path)) { + !GameServices::isFileInMemoryTextures(packet->path)) { if (minecraft->addPendingClientTextureRequest(packet->path)) { #if !defined(_CONTENT_PACKAGE) wprintf( @@ -2402,9 +2407,9 @@ void ClientConnection::handleTextureChange( new TexturePacket(packet->path, nullptr, 0))); } } else if (!packet->path.empty() && - app.IsFileInMemoryTextures(packet->path)) { + GameServices::isFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path, nullptr, 0); + GameServices::addMemoryTextureFile(packet->path, nullptr, 0); } } @@ -2426,7 +2431,7 @@ void ClientConnection::handleTextureAndGeometryChange( } if (isLocalPlayer) return; - player->setCustomSkin(app.getSkinIdFromPath(packet->path)); + player->setCustomSkin(GameServices::getSkinIdFromPath(packet->path)); #if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for remote player %ls has changed to %ls (%d)\n", @@ -2436,7 +2441,7 @@ void ClientConnection::handleTextureAndGeometryChange( if (!packet->path.empty() && packet->path.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(packet->path)) { + !GameServices::isFileInMemoryTextures(packet->path)) { if (minecraft->addPendingClientTextureRequest(packet->path)) { #if !defined(_CONTENT_PACKAGE) wprintf( @@ -2449,9 +2454,9 @@ void ClientConnection::handleTextureAndGeometryChange( new TextureAndGeometryPacket(packet->path, nullptr, 0))); } } else if (!packet->path.empty() && - app.IsFileInMemoryTextures(packet->path)) { + GameServices::isFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path, nullptr, 0); + GameServices::addMemoryTextureFile(packet->path, nullptr, 0); } } @@ -2489,7 +2494,7 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { dimensionLevel->savedDataStorage = level->savedDataStorage; dimensionLevel->difficulty = packet->difficulty; // 4J Added - app.DebugPrintf("dimensionLevel->difficulty - Difficulty = %d\n", + Log::info("dimensionLevel->difficulty - Difficulty = %d\n", packet->difficulty); dimensionLevel->isClientSide = true; @@ -2543,13 +2548,13 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { // with the inventory menu open ui.CloseUIScenes(m_userIndex); - if (app.GetLocalPlayerCount() > 1) { + if (GameServices::getLocalPlayerCount() > 1) { ui.NavigateToScene(m_userIndex, eUIScene_ConnectingProgress, param); } else { ui.NavigateToScene(m_userIndex, eUIScene_ConnectingProgress, param); } - app.SetAction(m_userIndex, eAppAction_WaitForDimensionChangeComplete); + GameServices::setAction(m_userIndex, eAppAction_WaitForDimensionChangeComplete); } // minecraft->respawnPlayer(minecraft->player->GetXboxPad(),true, @@ -2569,7 +2574,7 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { void ClientConnection::handleExplosion(std::shared_ptr packet) { if (!packet->m_bKnockbackOnly) { - // app.DebugPrintf("Received ExplodePacket with explosion data\n"); + // Log::info("Received ExplodePacket with explosion data\n"); Explosion* e = new Explosion(minecraft->level, nullptr, packet->x, packet->y, packet->z, packet->r); @@ -2588,10 +2593,10 @@ void ClientConnection::handleExplosion(std::shared_ptr packet) { delete e; } else { - // app.DebugPrintf("Received ExplodePacket with knockback only data\n"); + // Log::info("Received ExplodePacket with knockback only data\n"); } - // app.DebugPrintf("Adding knockback (%f,%f,%f) for player %d\n", + // Log::info("Adding knockback (%f,%f,%f) for player %d\n", // packet->getKnockbackX(), packet->getKnockbackY(), // packet->getKnockbackZ(), m_userIndex); minecraft->localplayers[m_userIndex]->xd += packet->getKnockbackX(); @@ -2875,7 +2880,7 @@ void ClientConnection::handleTileEditorOpen( void ClientConnection::handleSignUpdate( std::shared_ptr packet) { - app.DebugPrintf("ClientConnection::handleSignUpdate - "); + Log::info("ClientConnection::handleSignUpdate - "); if (minecraft->level->hasChunkAt(packet->x, packet->y, packet->z)) { std::shared_ptr te = minecraft->level->getTileEntity(packet->x, packet->y, packet->z); @@ -2888,18 +2893,18 @@ void ClientConnection::handleSignUpdate( ste->SetMessage(i, packet->lines[i]); } - app.DebugPrintf("verified = %d\tCensored = %d\n", + Log::info("verified = %d\tCensored = %d\n", packet->m_bVerified, packet->m_bCensored); ste->SetVerified(packet->m_bVerified); ste->SetCensored(packet->m_bCensored); ste->setChanged(); } else { - app.DebugPrintf( + Log::info( "std::dynamic_pointer_cast(te) == nullptr\n"); } } else { - app.DebugPrintf("hasChunkAt failed\n"); + Log::info("hasChunkAt failed\n"); } } @@ -3004,7 +3009,7 @@ void ClientConnection::handleGameEvent( } else if (event == GameEventPacket::WIN_GAME) { ui.SetWinUserIndex(static_cast(gameEventPacket->param)); - app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", + Log::info("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr) @@ -3018,12 +3023,12 @@ void ClientConnection::handleGameEvent( // Move app started to here so that it happens immediately otherwise // back-to-back START/STOP packets leave the client stuck in the // loading screen - app.SetGameStarted(false); - app.SetAction(InputManager.GetPrimaryPad(), + GameServices::setGameStarted(false); + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_RemoteServerSave); } } else if (event == GameEventPacket::STOP_SAVING) { - if (!g_NetworkManager.IsHost()) app.SetGameStarted(true); + if (!g_NetworkManager.IsHost()) GameServices::setGameStarted(true); } else if (event == GameEventPacket::SUCCESSFUL_BOW_HIT) { std::shared_ptr player = minecraft->localplayers[m_userIndex]; @@ -3106,7 +3111,7 @@ bool ClientConnection::isServerPacketListener() { return false; } void ClientConnection::handlePlayerInfo( std::shared_ptr packet) { unsigned int startingPrivileges = - app.GetPlayerPrivileges(packet->m_networkSmallId); + GameServices::getPlayerPrivileges(packet->m_networkSmallId); INetworkPlayer* networkPlayer = g_NetworkManager.GetPlayerBySmallId(packet->m_networkSmallId); @@ -3119,7 +3124,7 @@ void ClientConnection::handlePlayerInfo( } // 4J Stu - Repurposed this packet for player info that we want - app.UpdatePlayerInfo(packet->m_networkSmallId, packet->m_playerColourIndex, + GameServices::updatePlayerInfo(packet->m_networkSmallId, packet->m_playerColourIndex, packet->m_playerPrivileges); std::shared_ptr entity = getEntity(packet->m_entityId); @@ -3161,58 +3166,58 @@ void ClientConnection::displayPrivilegeChanges( Player::getPlayerGamePrivilege(oldPrivileges, priv)) { privOn = Player::getPlayerGamePrivilege(newPrivileges, priv); std::wstring message = L""; - if (app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { + if (GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) { switch (priv) { case Player::ePlayerGamePrivilege_CannotMine: if (privOn) - message = app.GetString(IDS_PRIV_MINE_TOGGLE_ON); + message = Strings::get(IDS_PRIV_MINE_TOGGLE_ON); else - message = app.GetString(IDS_PRIV_MINE_TOGGLE_OFF); + message = Strings::get(IDS_PRIV_MINE_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CannotBuild: if (privOn) - message = app.GetString(IDS_PRIV_BUILD_TOGGLE_ON); + message = Strings::get(IDS_PRIV_BUILD_TOGGLE_ON); else - message = app.GetString(IDS_PRIV_BUILD_TOGGLE_OFF); + message = Strings::get(IDS_PRIV_BUILD_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanUseDoorsAndSwitches: if (privOn) message = - app.GetString(IDS_PRIV_USE_DOORS_TOGGLE_ON); + Strings::get(IDS_PRIV_USE_DOORS_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_USE_DOORS_TOGGLE_OFF); + Strings::get(IDS_PRIV_USE_DOORS_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanUseContainers: if (privOn) - message = app.GetString( + message = Strings::get( IDS_PRIV_USE_CONTAINERS_TOGGLE_ON); else - message = app.GetString( + message = Strings::get( IDS_PRIV_USE_CONTAINERS_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CannotAttackAnimals: if (privOn) message = - app.GetString(IDS_PRIV_ATTACK_ANIMAL_TOGGLE_ON); + Strings::get(IDS_PRIV_ATTACK_ANIMAL_TOGGLE_ON); else - message = app.GetString( + message = Strings::get( IDS_PRIV_ATTACK_ANIMAL_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CannotAttackMobs: if (privOn) message = - app.GetString(IDS_PRIV_ATTACK_MOB_TOGGLE_ON); + Strings::get(IDS_PRIV_ATTACK_MOB_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_ATTACK_MOB_TOGGLE_OFF); + Strings::get(IDS_PRIV_ATTACK_MOB_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CannotAttackPlayers: if (privOn) message = - app.GetString(IDS_PRIV_ATTACK_PLAYER_TOGGLE_ON); + Strings::get(IDS_PRIV_ATTACK_PLAYER_TOGGLE_ON); else - message = app.GetString( + message = Strings::get( IDS_PRIV_ATTACK_PLAYER_TOGGLE_OFF); break; default: @@ -3222,75 +3227,75 @@ void ClientConnection::displayPrivilegeChanges( switch (priv) { case Player::ePlayerGamePrivilege_Op: if (privOn) - message = app.GetString(IDS_PRIV_MODERATOR_TOGGLE_ON); + message = Strings::get(IDS_PRIV_MODERATOR_TOGGLE_ON); else - message = app.GetString(IDS_PRIV_MODERATOR_TOGGLE_OFF); + message = Strings::get(IDS_PRIV_MODERATOR_TOGGLE_OFF); break; default: break; }; - if (app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0) { + if (GameHostOptions::get(eGameHostOption_CheatsEnabled) != 0) { switch (priv) { case Player::ePlayerGamePrivilege_CanFly: if (privOn) - message = app.GetString(IDS_PRIV_FLY_TOGGLE_ON); + message = Strings::get(IDS_PRIV_FLY_TOGGLE_ON); else - message = app.GetString(IDS_PRIV_FLY_TOGGLE_OFF); + message = Strings::get(IDS_PRIV_FLY_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_ClassicHunger: if (privOn) message = - app.GetString(IDS_PRIV_EXHAUSTION_TOGGLE_ON); + Strings::get(IDS_PRIV_EXHAUSTION_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_EXHAUSTION_TOGGLE_OFF); + Strings::get(IDS_PRIV_EXHAUSTION_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_Invisible: if (privOn) message = - app.GetString(IDS_PRIV_INVISIBLE_TOGGLE_ON); + Strings::get(IDS_PRIV_INVISIBLE_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_INVISIBLE_TOGGLE_OFF); + Strings::get(IDS_PRIV_INVISIBLE_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_Invulnerable: if (privOn) message = - app.GetString(IDS_PRIV_INVULNERABLE_TOGGLE_ON); + Strings::get(IDS_PRIV_INVULNERABLE_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_INVULNERABLE_TOGGLE_OFF); + Strings::get(IDS_PRIV_INVULNERABLE_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanToggleInvisible: if (privOn) message = - app.GetString(IDS_PRIV_CAN_INVISIBLE_TOGGLE_ON); + Strings::get(IDS_PRIV_CAN_INVISIBLE_TOGGLE_ON); else - message = app.GetString( + message = Strings::get( IDS_PRIV_CAN_INVISIBLE_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanToggleFly: if (privOn) - message = app.GetString(IDS_PRIV_CAN_FLY_TOGGLE_ON); + message = Strings::get(IDS_PRIV_CAN_FLY_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_CAN_FLY_TOGGLE_OFF); + Strings::get(IDS_PRIV_CAN_FLY_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanToggleClassicHunger: if (privOn) - message = app.GetString( + message = Strings::get( IDS_PRIV_CAN_EXHAUSTION_TOGGLE_ON); else - message = app.GetString( + message = Strings::get( IDS_PRIV_CAN_EXHAUSTION_TOGGLE_OFF); break; case Player::ePlayerGamePrivilege_CanTeleport: if (privOn) message = - app.GetString(IDS_PRIV_CAN_TELEPORT_TOGGLE_ON); + Strings::get(IDS_PRIV_CAN_TELEPORT_TOGGLE_ON); else message = - app.GetString(IDS_PRIV_CAN_TELEPORT_TOGGLE_OFF); + Strings::get(IDS_PRIV_CAN_TELEPORT_TOGGLE_OFF); break; default: break; @@ -3365,11 +3370,11 @@ Connection* ClientConnection::getConnection() { return connection; } void ClientConnection::handleServerSettingsChanged( std::shared_ptr packet) { if (packet->action == ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS) { - app.SetGameHostOption(eGameHostOption_All, packet->data); + GameHostOptions::set(eGameHostOption_All, packet->data); } else if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) { for (unsigned int i = 0; i < minecraft->levels.size(); ++i) { if (minecraft->levels[i] != nullptr) { - app.DebugPrintf( + Log::info( "ClientConnection::handleServerSettingsChanged - " "Difficulty = %d", packet->data); @@ -3379,7 +3384,7 @@ void ClientConnection::handleServerSettingsChanged( } else { // options // minecraft->options->SetGamertagSetting((packet->data==0)?false:true); - app.SetGameHostOption(eGameHostOption_Gamertags, packet->data); + GameHostOptions::set(eGameHostOption_Gamertags, packet->data); } } @@ -3400,7 +3405,7 @@ void ClientConnection::handleUpdateProgress( void ClientConnection::handleUpdateGameRuleProgressPacket( std::shared_ptr packet) { - const wchar_t* string = app.GetGameRulesString(packet->m_messageId); + const wchar_t* string = GameServices::getGameRulesString(packet->m_messageId); if (string != nullptr) { std::wstring message(string); message = GameRuleDefinition::generateDescriptionString( @@ -3414,10 +3419,10 @@ void ClientConnection::handleUpdateGameRuleProgressPacket( // If this rule has a data tag associated with it, then we save that in user // profile data if (packet->m_dataTag > 0 && packet->m_dataTag <= 32) { - app.DebugPrintf( + Log::info( "handleUpdateGameRuleProgressPacket: Data tag is in range, so " "updating profile data\n"); - app.SetSpecialTutorialCompletionFlag(m_userIndex, + GameServices::setSpecialTutorialCompletionFlag(m_userIndex, packet->m_dataTag - 1); } } @@ -3439,7 +3444,7 @@ int ClientConnection::HostDisconnectReturned( // no upsell, we're about to quit MinecraftServer::getInstance()->setSaveOnExit(false); // flag a app action of exit game - app.SetAction(iPad, eAppAction_ExitWorld); + GameServices::setAction(iPad, eAppAction_ExitWorld); } } @@ -3460,7 +3465,7 @@ int ClientConnection::HostDisconnectReturned( } else { MinecraftServer::getInstance()->setSaveOnExit(true); // flag a app action of exit game - app.SetAction(iPad, eAppAction_ExitWorld); + GameServices::setAction(iPad, eAppAction_ExitWorld); } return 0; @@ -3480,7 +3485,7 @@ int ClientConnection::ExitGameAndSaveReturned( MinecraftServer::getInstance()->setSaveOnExit(false); } // flag a app action of exit game - app.SetAction(iPad, eAppAction_ExitWorld); + GameServices::setAction(iPad, eAppAction_ExitWorld); return 0; } diff --git a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp index 21869e797..4f076b37b 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "MultiPlayerGameMode.h" #include @@ -149,8 +150,8 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { if (t > 0 && (Tile::tiles[t]->getDestroyProgress( minecraft->player, minecraft->player->level, x, y, z) >= 1 - // ||(app.DebugSettingsOn() && - // app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad())&(1L< @@ -121,8 +122,8 @@ void MultiPlayerLevel::tick() { // 4J: Debug setting added to keep it at day time #if !defined(_FINAL_BUILD) bool freezeTime = - app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + DebugSettings::isOn() && + DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime); if (!freezeTime) #endif diff --git a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp index 7cc772879..4ed8d21b4 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "MultiPlayerLocalPlayer.h" #include @@ -72,11 +74,11 @@ void MultiplayerLocalPlayer::tick() { // bool bIsisPrimaryHost=g_NetworkManager.IsHost() && // (InputManager.GetPrimaryPad()==m_iPad); - /*if((app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) != + /*if((GameServices::getGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) != m_bShownOnMaps) { m_bShownOnMaps = - (app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0); if + (GameServices::getGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0); if (m_bShownOnMaps) connection->send( std::shared_ptr( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) ) ); else connection->send( std::shared_ptr( new @@ -377,7 +379,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) { if (getCustomSkin() != oldSkinIndex) connection->send(std::shared_ptr( new TextureAndGeometryChangePacket( - shared_from_this(), app.GetPlayerSkinName(GetXboxPad())))); + shared_from_this(), GameServices::getPlayerSkinName(GetXboxPad())))); } void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { @@ -390,7 +392,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { if (getCustomCape() != oldCapeIndex) connection->send(std::make_shared( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, - app.GetPlayerCapeName(GetXboxPad()))); + GameServices::getPlayerCapeName(GetXboxPad()))); } // 4J added for testing. This moves the player in a repeated sequence of 2 @@ -419,7 +421,7 @@ void MultiplayerLocalPlayer::StressTestMove(double* tempX, double* tempY, /* if( faultFound ) { - app.DebugPrintf("Fault found\n"); + Log::info("Fault found\n"); stressTestEnabled = false; } */ diff --git a/targets/minecraft/client/player/Input.cpp b/targets/minecraft/client/player/Input.cpp index fd231d699..3de25df4e 100644 --- a/targets/minecraft/client/player/Input.cpp +++ b/targets/minecraft/client/player/Input.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" #include "Input.h" #include @@ -50,7 +52,7 @@ void Input::tick(LocalPlayer* player) { ya = 0.0f; #ifndef _CONTENT_PACKAGE - if (app.GetFreezePlayers()) { + if (DebugSettings::freezePlayers()) { xa = ya = 0.0f; player->abilities.flying = true; } @@ -87,7 +89,7 @@ void Input::tick(LocalPlayer* player) { pMinecraft->localgameModes[iPad]->isInputAllowed( MINECRAFT_ACTION_LOOK_RIGHT)) tx = InputManager.GetJoypadStick_RX(iPad) * - (((float)app.GetGameSettings(iPad, + (((float)GameServices::getGameSettings(iPad, eGameSetting_Sensitivity_InGame)) / 100.0f); // apply sensitivity to look if (pMinecraft->localgameModes[iPad]->isInputAllowed( @@ -95,16 +97,16 @@ void Input::tick(LocalPlayer* player) { pMinecraft->localgameModes[iPad]->isInputAllowed( MINECRAFT_ACTION_LOOK_DOWN)) ty = InputManager.GetJoypadStick_RY(iPad) * - (((float)app.GetGameSettings(iPad, + (((float)GameServices::getGameSettings(iPad, eGameSetting_Sensitivity_InGame)) / 100.0f); // apply sensitivity to look #ifndef _CONTENT_PACKAGE - if (app.GetFreezePlayers()) tx = ty = 0.0f; + if (DebugSettings::freezePlayers()) tx = ty = 0.0f; #endif // 4J: WESTY : Invert look Y if required. - if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) { + if (GameServices::getGameSettings(iPad, eGameSetting_ControlInvertLook)) { ty = -ty; } @@ -127,7 +129,7 @@ void Input::tick(LocalPlayer* player) { pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP); #ifndef _CONTENT_PACKAGE - if (app.GetFreezePlayers()) jumping = false; + if (DebugSettings::freezePlayers()) jumping = false; #endif // OutputDebugString("INPUT: End input tick\n"); diff --git a/targets/minecraft/client/player/LocalPlayer.cpp b/targets/minecraft/client/player/LocalPlayer.cpp index ae53c24f1..c0792812c 100644 --- a/targets/minecraft/client/player/LocalPlayer.cpp +++ b/targets/minecraft/client/player/LocalPlayer.cpp @@ -1,3 +1,6 @@ +#include "minecraft/client/IMenuService.h" +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "LocalPlayer.h" #include @@ -35,7 +38,6 @@ #include "app/common/Tutorial/Tutorial.h" #include "app/common/Tutorial/TutorialMode.h" #include "app/common/UI/All Platforms/UIEnums.h" -#include "app/linux/LinuxGame.h" #include "app/linux/Linux_UIController.h" #include "app/linux/Stubs/winapi_stubs.h" #include "PlatformTypes.h" @@ -115,7 +117,7 @@ LocalPlayer::LocalPlayer(Minecraft* minecraft, Level* level, User* user, this->name = user->name; // wprintf(L"Created LocalPlayer with name %ls\n", name.c_str() ); // check to see if this player's xuid is in the list of special players - MOJANG_DATA* pMojangData = app.GetMojangDataForXuid(getOnlineXuid()); + MOJANG_DATA* pMojangData = GameServices::getMojangDataForXuid(getOnlineXuid()); if (pMojangData) { customTextureUrl = pMojangData->wchSkin; } @@ -519,7 +521,7 @@ void LocalPlayer::changeDimension(int i) { awardStat(GenericStats::winGame(), GenericStats::param_noArgs()); // minecraft.setScreen(new WinScreen()); #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "LocalPlayer::changeDimension from 1 to 1 but WinScreen has " "not been implemented.\n"); __debugbreak(); @@ -590,11 +592,11 @@ void LocalPlayer::openTextEdit(std::shared_ptr tileEntity) { bool success; if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) { - success = app.LoadSignEntryMenu( + success = GameServices::menus().openSign( GetXboxPad(), std::dynamic_pointer_cast(tileEntity)); } else if (tileEntity->GetType() == eTYPE_COMMANDBLOCKTILEENTITY) { - success = app.LoadCommandBlockMenu( + success = GameServices::menus().openCommandBlock( GetXboxPad(), std::dynamic_pointer_cast(tileEntity)); } @@ -608,7 +610,7 @@ bool LocalPlayer::openContainer(std::shared_ptr container) { minecraft->setScreen(new ContainerScreen(inventory, container)); bool success = true; #else - bool success = app.LoadContainerMenu(GetXboxPad(), inventory, container); + bool success = GameServices::menus().openContainer(GetXboxPad(), inventory, container); if (success) ui.PlayUISFX(eSFX_Press); #endif // minecraft->setScreen(new ContainerScreen(inventory, container)); @@ -620,7 +622,7 @@ bool LocalPlayer::openHopper(std::shared_ptr container) { minecraft->setScreen(new HopperScreen(inventory, container)); bool success = true; #else - bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container); + bool success = GameServices::menus().openHopper(GetXboxPad(), inventory, container); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -631,7 +633,7 @@ bool LocalPlayer::openHopper(std::shared_ptr container) { minecraft->setScreen(new HopperScreen(inventory, container)); bool success = true; #else - bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container); + bool success = GameServices::menus().openHopperMinecart(GetXboxPad(), inventory, container); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -643,7 +645,7 @@ bool LocalPlayer::openHorseInventory(std::shared_ptr horse, minecraft->setScreen(new HorseInventoryScreen(inventory, container, horse)); bool success = true; #else - bool success = app.LoadHorseMenu(GetXboxPad(), inventory, container, horse); + bool success = GameServices::menus().openHorse(GetXboxPad(), inventory, container, horse); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -654,7 +656,7 @@ bool LocalPlayer::startCrafting(int x, int y, int z) { minecraft->setScreen(new CraftingScreen(inventory, level, x, y, z)); bool success = true; #else - bool success = app.LoadCrafting3x3Menu( + bool success = GameServices::menus().openCrafting3x3( GetXboxPad(), std::dynamic_pointer_cast(shared_from_this()), x, y, z); if (success) ui.PlayUISFX(eSFX_Press); @@ -665,7 +667,7 @@ bool LocalPlayer::startCrafting(int x, int y, int z) { } bool LocalPlayer::openFireworks(int x, int y, int z) { - bool success = app.LoadFireworksMenu( + bool success = GameServices::menus().openFireworks( GetXboxPad(), std::dynamic_pointer_cast(shared_from_this()), x, y, z); if (success) ui.PlayUISFX(eSFX_Press); @@ -679,7 +681,7 @@ bool LocalPlayer::startEnchanting(int x, int y, int z, bool success = true; #else bool success = - app.LoadEnchantingMenu(GetXboxPad(), inventory, x, y, z, level, name); + GameServices::menus().openEnchanting(GetXboxPad(), inventory, x, y, z, level, name); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -691,7 +693,7 @@ bool LocalPlayer::startRepairing(int x, int y, int z) { bool success = true; #else bool success = - app.LoadRepairingMenu(GetXboxPad(), inventory, level, x, y, z); + GameServices::menus().openRepairing(GetXboxPad(), inventory, level, x, y, z); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -702,7 +704,7 @@ bool LocalPlayer::openFurnace(std::shared_ptr furnace) { minecraft->setScreen(new FurnaceScreen(inventory, furnace)); bool success = true; #else - bool success = app.LoadFurnaceMenu(GetXboxPad(), inventory, furnace); + bool success = GameServices::menus().openFurnace(GetXboxPad(), inventory, furnace); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -715,7 +717,7 @@ bool LocalPlayer::openBrewingStand( bool success = true; #else bool success = - app.LoadBrewingStandMenu(GetXboxPad(), inventory, brewingStand); + GameServices::menus().openBrewingStand(GetXboxPad(), inventory, brewingStand); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -726,7 +728,7 @@ bool LocalPlayer::openBeacon(std::shared_ptr beacon) { minecraft->setScreen(new BeaconScreen(inventory, beacon)); bool success = true; #else - bool success = app.LoadBeaconMenu(GetXboxPad(), inventory, beacon); + bool success = GameServices::menus().openBeacon(GetXboxPad(), inventory, beacon); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -737,7 +739,7 @@ bool LocalPlayer::openTrap(std::shared_ptr trap) { minecraft->setScreen(new TrapScreen(inventory, trap)); bool success = true; #else - bool success = app.LoadTrapMenu(GetXboxPad(), inventory, trap); + bool success = GameServices::menus().openTrap(GetXboxPad(), inventory, trap); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -750,7 +752,7 @@ bool LocalPlayer::openTrading(std::shared_ptr traderTarget, bool success = true; #else bool success = - app.LoadTradingMenu(GetXboxPad(), inventory, traderTarget, level, name); + GameServices::menus().openTrading(GetXboxPad(), inventory, traderTarget, level, name); if (success) ui.PlayUISFX(eSFX_Press); #endif return success; @@ -824,7 +826,7 @@ void LocalPlayer::displayClientMessage(int messageId) { void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { int count = CommonStats::readParam(param); - if (!app.CanRecordStatsAndAchievements()) return; + if (!GameServices::canRecordStatsAndAchievements()) return; if (stat == nullptr) return; if (stat->isAchievement()) { @@ -965,7 +967,7 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { numCookPorkchop = pStats->getTotalValue(cookPorkchop); numEatPorkchop = pStats->getTotalValue(eatPorkchop); - app.DebugPrintf( + Log::info( "[AwardStat] Check unlock 'Porkchop': " "pork_cooked=%i, pork_eaten=%i.\n", numCookPorkchop, numEatPorkchop); @@ -986,7 +988,7 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { iPlayedTicks = pStats->getTotalValue(timePlayed); iRequiredTicks = Level::TICKS_PER_DAY * 100; - /* app.DebugPrintf( + /* Log::info( "[AwardStat] Check unlock 'Passing the Time': " "total_ticks=%i, req=%i.\n", iPlayedTicks, iRequiredTicks @@ -1011,7 +1013,7 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { numEmeraldBought = pStats->getTotalValue(emeraldBought); totalSum = numEmeraldMined + numEmeraldBought; - app.DebugPrintf( + Log::info( "[AwardStat] Check unlock 'The Haggler': " "emerald_mined=%i, emerald_bought=%i, sum=%i.\n", numEmeraldMined, numEmeraldBought, totalSum); @@ -1051,7 +1053,7 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { numPlacedWallSign = pStats->getTotalValue(placeWallsign); numPlacedSignpost = pStats->getTotalValue(placeSignpost); - app.DebugPrintf( + Log::info( "[AwardStat] Check unlock 'It's a Sign': " "crafted=%i, placedWallSigns=%i, placedSignposts=%i.\n", numCraftedSigns, numPlacedWallSign, numPlacedSignpost); @@ -1454,7 +1456,7 @@ bool LocalPlayer::handleMouseClick(int button) { if (button == 0 && missTime > 0) return false; if (button == 0) { - // app.DebugPrintf("handleMouseClick - Player %d is + // Log::info("handleMouseClick - Player %d is // swinging\n",GetXboxPad()); swing(); } @@ -1540,7 +1542,7 @@ bool LocalPlayer::handleMouseClick(int button) { returnItemPlaced = true; } mayUse = false; - // app.DebugPrintf("Player %d is swinging\n",GetXboxPad()); + // Log::info("Player %d is swinging\n",GetXboxPad()); swing(); } if (item == nullptr) { @@ -1574,39 +1576,39 @@ void LocalPlayer::updateRichPresence() { std::shared_ptr selectedItem = inventory->getSelected(); if (selectedItem != nullptr && selectedItem->id == Item::fishingRod_Id) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_FISHING); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_FISHING); } else if (selectedItem != nullptr && selectedItem->id == Item::map_Id) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_MAP); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_MAP); } else if ((riding != nullptr) && riding->instanceof(eTYPE_MINECART)) { - app.SetRichPresenceContext(m_iPad, + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_RIDING_MINECART); } else if ((riding != nullptr) && riding->instanceof(eTYPE_BOAT)) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BOATING); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BOATING); } else if ((riding != nullptr) && riding->instanceof(eTYPE_PIG)) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_RIDING_PIG); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_RIDING_PIG); } else if (this->dimension == -1) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_NETHER); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_NETHER); } else if (minecraft->soundEngine->GetIsPlayingStreamingCDMusic()) { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_CD); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_CD); } else { - app.SetRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BLANK); + GameServices::setRichPresenceContext(m_iPad, CONTEXT_GAME_STATE_BLANK); } } } // 4J Stu - Added for telemetry void LocalPlayer::SetSessionTimerStart(void) { - m_sessionTimeStart = app.getAppTime(); + m_sessionTimeStart = GameServices::getAppTime(); m_dimensionTimeStart = m_sessionTimeStart; } float LocalPlayer::getSessionTimer(void) { - return app.getAppTime() - m_sessionTimeStart; + return GameServices::getAppTime() - m_sessionTimeStart; } float LocalPlayer::getAndResetChangeDimensionTimer() { - float appTime = app.getAppTime(); + float appTime = GameServices::getAppTime(); float returnVal = appTime - m_dimensionTimeStart; m_dimensionTimeStart = appTime; return returnVal; diff --git a/targets/minecraft/client/player/RemotePlayer.cpp b/targets/minecraft/client/player/RemotePlayer.cpp index a48fa4e40..39adc9838 100644 --- a/targets/minecraft/client/player/RemotePlayer.cpp +++ b/targets/minecraft/client/player/RemotePlayer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "RemotePlayer.h" #include @@ -21,7 +22,7 @@ RemotePlayer::RemotePlayer(Level* level, const std::wstring& name) lx = ly = lz = lyr = lxr = 0.0; fallTime = 0.0f; - app.DebugPrintf("Created RemotePlayer with name %ls\n", name.c_str()); + Log::info("Created RemotePlayer with name %ls\n", name.c_str()); heightOffset = 0; footSize = 0; diff --git a/targets/minecraft/client/renderer/GameRenderer.cpp b/targets/minecraft/client/renderer/GameRenderer.cpp index 138c654f3..3fac3bd98 100644 --- a/targets/minecraft/client/renderer/GameRenderer.cpp +++ b/targets/minecraft/client/renderer/GameRenderer.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "GameRenderer.h" #include @@ -663,7 +665,7 @@ void GameRenderer::setupCamera(float a, int eye) { bool bNoBobbingAnim = (mc->player->getAnimOverrideBitmask() & (1 << HumanoidModel::eAnim_NoBobbing)) != 0; - if (app.GetGameSettings(mc->player->GetXboxPad(), eGameSetting_ViewBob) && + if (GameServices::getGameSettings(mc->player->GetXboxPad(), eGameSetting_ViewBob) && !mc->player->abilities.flying && !bNoLegAnim && !bNoBobbingAnim) bobView(a); @@ -717,7 +719,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { std::shared_ptr item = localplayer->inventory->getSelected(); if (!(item && item->getItem()->id == Item::map_Id) && - app.GetGameSettings(localplayer->GetXboxPad(), + GameServices::getGameSettings(localplayer->GetXboxPad(), eGameSetting_DisplayHand) == 0) renderHand = false; } @@ -758,7 +760,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { bool bNoLegAnim = (localplayer->getAnimOverrideBitmask() & ((1 << HumanoidModel::eAnim_NoLegAnim) | (1 << HumanoidModel::eAnim_NoBobbing))) != 0; - if (app.GetGameSettings(localplayer->GetXboxPad(), eGameSetting_ViewBob) && + if (GameServices::getGameSettings(localplayer->GetXboxPad(), eGameSetting_ViewBob) && !localplayer->abilities.flying && !bNoLegAnim) bobView(a); @@ -790,7 +792,7 @@ void GameRenderer::renderItemInHand(float a, int eye) { // 4J-PB - changing this to be per player // if (mc->options->bobView) bobView(a); - if (app.GetGameSettings(localplayer->GetXboxPad(), eGameSetting_ViewBob) && + if (GameServices::getGameSettings(localplayer->GetXboxPad(), eGameSetting_ViewBob) && !localplayer->abilities.flying && !bNoLegAnim) bobView(a); } @@ -835,7 +837,7 @@ void GameRenderer::turnOnLightLayer( static int logCount = 0; if (logCount < 16) { ++logCount; - app.DebugPrintf("[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n", + Log::info("[linux-lightmap] turnOnLightLayer tex=%d scale=%d\n", textureId, scaleLight ? 1 : 0); } @@ -1201,7 +1203,7 @@ void GameRenderer::EnableUpdateThread() { // #endif #if defined(MULTITHREAD_ENABLE) if (updateRunning) return; - app.DebugPrintf( + Log::info( "------------------EnableUpdateThread--------------------\n"); updateRunning = true; m_updateEvents->set(eUpdateCanRun); @@ -1215,7 +1217,7 @@ void GameRenderer::DisableUpdateThread() { // #endif #if defined(MULTITHREAD_ENABLE) if (!updateRunning) return; - app.DebugPrintf( + Log::info( "------------------DisableUpdateThread--------------------\n"); updateRunning = false; m_updateEvents->clear(eUpdateCanRun); diff --git a/targets/minecraft/client/renderer/ItemInHandRenderer.cpp b/targets/minecraft/client/renderer/ItemInHandRenderer.cpp index 4334f2fc7..7505637c6 100644 --- a/targets/minecraft/client/renderer/ItemInHandRenderer.cpp +++ b/targets/minecraft/client/renderer/ItemInHandRenderer.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "ItemInHandRenderer.h" #include @@ -464,7 +466,7 @@ void ItemInHandRenderer::render(float a) { static int lightmapLogCount = 0; if (lightmapLogCount < 8) { ++lightmapLogCount; - app.DebugPrintf( + Log::info( "[linux-lightmap] item-hand raw=0x%08x uv=(%d,%d)\n", col, u, v); } @@ -547,7 +549,7 @@ void ItemInHandRenderer::render(float a) { player->inventory->getSelected(); if ((itemInstance && (itemInstance->getItem()->id == Item::map_Id)) || - app.GetGameSettings(localPlayer->GetXboxPad(), + GameServices::getGameSettings(localPlayer->GetXboxPad(), eGameSetting_DisplayHand) != 0) { playerRenderer->renderHand(); } @@ -764,7 +766,7 @@ void ItemInHandRenderer::render(float a) { player->inventory->getSelected(); if ((itemInstance && (itemInstance->getItem()->id == Item::map_Id)) || - app.GetGameSettings(localPlayer->GetXboxPad(), + GameServices::getGameSettings(localPlayer->GetXboxPad(), eGameSetting_DisplayHand) != 0) { playerRenderer->renderHand(); } diff --git a/targets/minecraft/client/renderer/LevelRenderer.cpp b/targets/minecraft/client/renderer/LevelRenderer.cpp index 6faeae699..f0e596964 100644 --- a/targets/minecraft/client/renderer/LevelRenderer.cpp +++ b/targets/minecraft/client/renderer/LevelRenderer.cpp @@ -1,3 +1,6 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "LevelRenderer.h" #include @@ -445,8 +448,8 @@ void LevelRenderer::setLevel(int playerIndex, MultiPlayerLevel* level) { } void LevelRenderer::AddDLCSkinsToMemTextures() { - for (int i = 0; i < app.vSkinNames.size(); i++) { - textures->addMemTexture(app.vSkinNames[i], + for (int i = 0; i < GameServices::getSkinNames().size(); i++) { + textures->addMemTexture(GameServices::getSkinNames()[i], new MobSkinMemTextureProcessor()); } } @@ -1127,7 +1130,7 @@ void LevelRenderer::renderHaloRing(float alpha) { // Rough lumninance calculation float Y = (sr + sr + sb + sg + sg + sg) / 6; float br = 0.6f + (Y * 0.4f); - // app.DebugPrintf("Luminance = %f, brightness = %f\n", Y, br); + // Log::info("Luminance = %f, brightness = %f\n", Y, br); glColor3f(br, br, br); // Fog at the base near the world @@ -1162,7 +1165,7 @@ void LevelRenderer::renderClouds(float alpha) { int playerIndex = mc->player->GetXboxPad(); // if the primary player has clouds off, so do all players on this machine - if (app.GetGameSettings(InputManager.GetPrimaryPad(), + if (GameServices::getGameSettings(InputManager.GetPrimaryPad(), eGameSetting_Clouds) == 0) { return; } @@ -1175,8 +1178,8 @@ void LevelRenderer::renderClouds(float alpha) { return; } - if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + if (DebugSettings::isOn()) { + if (DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime)) { iTicks = m_freezeticks; } @@ -1253,8 +1256,8 @@ void LevelRenderer::renderClouds(float alpha) { glDisable(GL_BLEND); glEnable(GL_CULL_FACE); - if (app.DebugSettingsOn()) { - if (!(app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + if (DebugSettings::isOn()) { + if (!(DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime))) { m_freezeticks = iTicks; } @@ -1439,8 +1442,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { int iTicks = ticks; - if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + if (DebugSettings::isOn()) { + if (DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime)) { iTicks = m_freezeticks; } @@ -1686,8 +1689,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { glDisable(GL_BLEND); glEnable(GL_CULL_FACE); - if (app.DebugSettingsOn()) { - if (!(app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + if (DebugSettings::isOn()) { + if (!(DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime))) { m_freezeticks = iTicks; } @@ -1748,7 +1751,7 @@ bool LevelRenderer::updateDirtyChunks() { static int throttle = 0; if( ( throttle % 100 ) == 0 ) { - app.DebugPrintf("CBuffSize: %d\n",memAlloc/(1024*1024)); + Log::info("CBuffSize: %d\n",memAlloc/(1024*1024)); } throttle++; */ @@ -1818,7 +1821,7 @@ bool LevelRenderer::updateDirtyChunks() { int py = (int)player->y; int pz = (int)player->z; - // app.DebugPrintf("!! %d %d %d, %d %d %d + // Log::info("!! %d %d %d, %d %d %d //{%d,%d} //",px,py,pz,stackChunkDirty,nonStackChunkDirty,onlyRebuild, // xChunks, zChunks); @@ -1935,7 +1938,7 @@ bool LevelRenderer::updateDirtyChunks() { } } } - // app.DebugPrintf("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty); + // Log::info("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty); } } } @@ -1999,7 +2002,7 @@ bool LevelRenderer::updateDirtyChunks() { // 0; static int64_t countTime = 0; // int64_t startTime = System::currentTimeMillis(); - // app.DebugPrintf("Rebuilding permaChunk %d\n", index); + // Log::info("Rebuilding permaChunk %d\n", index); { FRAME_PROFILE_SCOPE(ChunkRebuildBody); @@ -2218,7 +2221,7 @@ void LevelRenderer::renderHitOutline(std::shared_ptr player, const float ss = 0.002f; // 4J-PB - If Display HUD is false, don't render the hit outline - if (app.GetGameSettings(iPad, eGameSetting_DisplayHUD) == 0) return; + if (GameServices::getGameSettings(iPad, eGameSetting_DisplayHUD) == 0) return; RenderManager.StateSetLightingEnable(false); glDisable(GL_TEXTURE_2D); @@ -4047,7 +4050,7 @@ int LevelRenderer::rebuildChunkThreadProc(void* lpParam) { while (true) { s_activationEventA[index]->waitForSignal(C4JThread::kInfiniteTimeout); - // app.DebugPrintf("Rebuilding permaChunk %d\n", index + 1); + // Log::info("Rebuilding permaChunk %d\n", index + 1); { FRAME_PROFILE_SCOPE(ChunkRebuildBody); permaChunk[index + 1].rebuild(); diff --git a/targets/minecraft/client/renderer/Tesselator.cpp b/targets/minecraft/client/renderer/Tesselator.cpp index b9ea4caf3..c243c9499 100644 --- a/targets/minecraft/client/renderer/Tesselator.cpp +++ b/targets/minecraft/client/renderer/Tesselator.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Tesselator.h" #include @@ -432,7 +433,7 @@ void logLinuxPackedLightmapCoords(const char* path, int tex2, std::int16_t u, if (logCount >= 16) return; ++logCount; - app.DebugPrintf( + Log::info( "[linux-lightmap] %s raw=0x%08x packed=(%d,%d) sampled=(%.4f,%.4f)\n", path, tex2, (int)u, (int)v, u / 256.0f, v / 256.0f); } diff --git a/targets/minecraft/client/renderer/Textures.cpp b/targets/minecraft/client/renderer/Textures.cpp index ea184c456..73cf2ddd4 100644 --- a/targets/minecraft/client/renderer/Textures.cpp +++ b/targets/minecraft/client/renderer/Textures.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "Textures.h" #include @@ -1003,7 +1004,7 @@ int Textures::loadMemTexture(const std::wstring& url, if (it != memTextures.end()) { texture = (*it).second; } - if (texture == nullptr && app.IsFileInMemoryTextures(url)) { + if (texture == nullptr && GameServices::isFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor()); } @@ -1040,7 +1041,7 @@ int Textures::loadMemTexture(const std::wstring& url, int backup) { if (it != memTextures.end()) { texture = (*it).second; } - if (texture == nullptr && app.IsFileInMemoryTextures(url)) { + if (texture == nullptr && GameServices::isFileInMemoryTextures(url)) { // If we haven't loaded it yet, but we have the data for it then add it texture = addMemTexture(url, new MobSkinMemTextureProcessor()); } @@ -1081,7 +1082,7 @@ MemTexture* Textures::addMemTexture(const std::wstring& name, // can we find it in the app mem files? std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; - app.GetMemFileDetails(name, &pbData, &dwBytes); + GameServices::getMemFileDetails(name, &pbData, &dwBytes); if (dwBytes != 0) { texture = new MemTexture(name, pbData, dwBytes, processor); diff --git a/targets/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp b/targets/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp index bd0a73d89..33794e6d8 100644 --- a/targets/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/targets/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "EntityRenderDispatcher.h" #include @@ -195,7 +196,7 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(eINSTANCEOF e) { // insert elements if they don't exist if (it == renderers.end()) { - app.DebugPrintf("Couldn't find renderer for entity of type %d\n", e); + Log::info("Couldn't find renderer for entity of type %d\n", e); // New renderer mapping required in above table // __debugbreak(); assert(0); diff --git a/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp b/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp index 30e469227..ca7a436a3 100644 --- a/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" #include "LivingEntityRenderer.h" #include @@ -388,12 +390,12 @@ void LivingEntityRenderer::renderName(std::shared_ptr mob, if (!msg.empty()) { if (mob->isSneaking()) { - if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) { + if (GameServices::getGameSettings(eGameSetting_DisplayHUD) == 0) { // 4J-PB - turn off gamertag render return; } - if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) { + if (GameHostOptions::get(eGameHostOption_Gamertags) == 0) { // turn off gamertags if the host has set them off return; } @@ -463,12 +465,12 @@ void LivingEntityRenderer::renderNameTag(std::shared_ptr mob, const std::wstring& name, double x, double y, double z, int maxDist, int color /*= 0xff000000*/) { - if (app.GetGameSettings(eGameSetting_DisplayHUD) == 0) { + if (GameServices::getGameSettings(eGameSetting_DisplayHUD) == 0) { // 4J-PB - turn off gamertag render return; } - if (app.GetGameHostOption(eGameHostOption_Gamertags) == 0) { + if (GameHostOptions::get(eGameHostOption_Gamertags) == 0) { // turn off gamertags if the host has set them off return; } @@ -499,7 +501,7 @@ void LivingEntityRenderer::renderNameTag(std::shared_ptr mob, int readableDist = PLAYER_NAME_READABLE_FULLSCREEN; if (!RenderManager.IsHiDef()) { readableDist = PLAYER_NAME_READABLE_DISTANCE_SD; - } else if (app.GetLocalPlayerCount() > 2) { + } else if (GameServices::getLocalPlayerCount() > 2) { readableDist = PLAYER_NAME_READABLE_DISTANCE_SPLITSCREEN; } @@ -527,7 +529,7 @@ void LivingEntityRenderer::renderNameTag(std::shared_ptr mob, if (mob->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(mob); - if (app.isXuidDeadmau5(player->getXuid())) offs = -10; + if (GameServices::isXuidDeadmau5(player->getXuid())) offs = -10; playerName = name; } else { diff --git a/targets/minecraft/client/renderer/entity/PlayerRenderer.cpp b/targets/minecraft/client/renderer/entity/PlayerRenderer.cpp index 9c4acb77f..07b5041a3 100644 --- a/targets/minecraft/client/renderer/entity/PlayerRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/PlayerRenderer.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" #include "PlayerRenderer.h" #include @@ -301,7 +303,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr _mob, } // need to add a custom texture for deadmau5 - if (mob != nullptr && app.isXuidDeadmau5(mob->getXuid()) && + if (mob != nullptr && GameServices::isXuidDeadmau5(mob->getXuid()) && bindTexture(mob->customTextureUrl, L"")) { for (int i = 0; i < 2; i++) { float yr = (mob->yRotO + (mob->yRot - mob->yRotO) * a) - @@ -522,7 +524,7 @@ void PlayerRenderer::setupRotations(std::shared_ptr _mob, // 4J Added override to stop rendering shadow if player is invisible void PlayerRenderer::renderShadow(std::shared_ptr e, double x, double y, double z, float pow, float a) { - if (app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) > 0) { + if (GameHostOptions::get(eGameHostOption_HostCanBeInvisible) > 0) { std::shared_ptr player = std::dynamic_pointer_cast(e); if (player != nullptr && player->hasInvisiblePrivilege()) return; } diff --git a/targets/minecraft/client/renderer/texture/PreStitchedTextureMap.cpp b/targets/minecraft/client/renderer/texture/PreStitchedTextureMap.cpp index 65d3a574f..03ea642c1 100644 --- a/targets/minecraft/client/renderer/texture/PreStitchedTextureMap.cpp +++ b/targets/minecraft/client/renderer/texture/PreStitchedTextureMap.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "PreStitchedTextureMap.h" #include @@ -173,7 +174,7 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, #if !defined(_CONTENT_PACKAGE) if (first->getWidth() != tex->getWidth() || first->getHeight() != tex->getHeight()) { - app.DebugPrintf("%ls - first w - %d, h - %d, tex w - %d, h - %d\n", + Log::info("%ls - first w - %d, h - %d, tex w - %d, h - %d\n", textureFileName.c_str(), first->getWidth(), tex->getWidth(), first->getHeight(), tex->getHeight()); @@ -194,7 +195,7 @@ void PreStitchedTextureMap::makeTextureAnimated(TexturePack* texturePack, StitchedTexture* PreStitchedTextureMap::getTexture(const std::wstring& name) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Not implemented!\n"); + Log::info("Not implemented!\n"); __debugbreak(); #endif return nullptr; @@ -215,7 +216,7 @@ Texture* PreStitchedTextureMap::getStitchedTexture() { return stitchResult; } Icon* PreStitchedTextureMap::registerIcon(const std::wstring& name) { Icon* result = nullptr; if (name.empty()) { - app.DebugPrintf("Don't register nullptr\n"); + Log::info("Don't register nullptr\n"); #if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif @@ -228,7 +229,7 @@ Icon* PreStitchedTextureMap::registerIcon(const std::wstring& name) { if (result == nullptr) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Could not find uv data for icon %ls\n", name.c_str()); + Log::info("Could not find uv data for icon %ls\n", name.c_str()); __debugbreak(); #endif result = missingPosition; diff --git a/targets/minecraft/client/renderer/texture/Stitcher.cpp b/targets/minecraft/client/renderer/texture/Stitcher.cpp index 5a9498de0..30f656257 100644 --- a/targets/minecraft/client/renderer/texture/Stitcher.cpp +++ b/targets/minecraft/client/renderer/texture/Stitcher.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Stitcher.h" #include @@ -81,7 +82,7 @@ void Stitcher::stitch() { TextureHolder* textureHolder = *it; // textureHolders[i]; if (!addToStorage(textureHolder)) { - app.DebugPrintf("Stitcher exception!\n"); + Log::info("Stitcher exception!\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/targets/minecraft/client/renderer/texture/Texture.cpp b/targets/minecraft/client/renderer/texture/Texture.cpp index ecf188999..c16c818e1 100644 --- a/targets/minecraft/client/renderer/texture/Texture.cpp +++ b/targets/minecraft/client/renderer/texture/Texture.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Texture.h" #include @@ -344,7 +345,7 @@ void Texture::transferFromImage(BufferedImage* image) { // + // imgHeight + ") larger than the Texture dimensions (" + width + // ", " + height + "). Ignoring."); - app.DebugPrintf( + Log::info( "transferFromImage called with a BufferedImage with dimensions " "(%d, %d) larger than the Texture dimensions (%d, %d). Ignoring.\n", imgWidth, imgHeight, width, height); diff --git a/targets/minecraft/client/renderer/texture/TextureManager.cpp b/targets/minecraft/client/renderer/texture/TextureManager.cpp index aed33c94c..79eed49ef 100644 --- a/targets/minecraft/client/renderer/texture/TextureManager.cpp +++ b/targets/minecraft/client/renderer/texture/TextureManager.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "TextureManager.h" #include @@ -48,7 +49,7 @@ void TextureManager::registerTexture(Texture* texture) { // Minecraft.getInstance().getLogger().warning("TextureManager.registerTexture // called, but this texture has " + "already been registered. // ignoring."); - app.DebugPrintf( + Log::info( "TextureManager.registerTexture called, but this texture has " "already been registered. ignoring."); return; diff --git a/targets/minecraft/client/renderer/texture/TextureMap.cpp b/targets/minecraft/client/renderer/texture/TextureMap.cpp index bf973d163..8421fa863 100644 --- a/targets/minecraft/client/renderer/texture/TextureMap.cpp +++ b/targets/minecraft/client/renderer/texture/TextureMap.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "TextureMap.h" #include @@ -234,7 +235,7 @@ Texture* TextureMap::getStitchedTexture() { return stitchResult; } // 4J Stu - register is a reserved keyword in C++ Icon* TextureMap::registerIcon(const std::wstring& name) { if (name.empty()) { - app.DebugPrintf("Don't register nullptr\n"); + Log::info("Don't register nullptr\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/targets/minecraft/client/renderer/tileentity/SignRenderer.cpp b/targets/minecraft/client/renderer/tileentity/SignRenderer.cpp index afaa763e9..5c9b0d935 100644 --- a/targets/minecraft/client/renderer/tileentity/SignRenderer.cpp +++ b/targets/minecraft/client/renderer/tileentity/SignRenderer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "SignRenderer.h" #include @@ -89,7 +90,7 @@ void SignRenderer::render(std::shared_ptr _sign, double x, double y, msg = L"Censored"; // In-game font, so English only break; default: - msg = app.GetString(IDS_STRINGVERIFY_CENSORED); + msg = Strings::get(IDS_STRINGVERIFY_CENSORED); break; } } else { @@ -104,7 +105,7 @@ void SignRenderer::render(std::shared_ptr _sign, double x, double y, L"Awaiting Approval"; // In-game font, so English only break; default: - msg = app.GetString(IDS_STRINGVERIFY_AWAITING_APPROVAL); + msg = Strings::get(IDS_STRINGVERIFY_AWAITING_APPROVAL); break; } } diff --git a/targets/minecraft/client/skins/AbstractTexturePack.cpp b/targets/minecraft/client/skins/AbstractTexturePack.cpp index 5c3d36eb6..04951d109 100644 --- a/targets/minecraft/client/skins/AbstractTexturePack.cpp +++ b/targets/minecraft/client/skins/AbstractTexturePack.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "AbstractTexturePack.h" #include @@ -6,7 +7,7 @@ #include #include "app/common/Colours/ColourTable.h" -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "app/linux/Linux_UIController.h" #include "app/linux/Stubs/winapi_stubs.h" #include "minecraft/client/BufferedImage.h" @@ -61,7 +62,7 @@ void AbstractTexturePack::loadName() {} InputStream* AbstractTexturePack::getResource( const std::wstring& name, bool allowFallback) // throws IOException { - app.DebugPrintf("texture - %ls\n", name.c_str()); + Log::info("texture - %ls\n", name.c_str()); InputStream* is = getResourceImplementation(name); if (is == nullptr && fallback != nullptr && allowFallback) { is = fallback->getResource(name, true); @@ -136,7 +137,7 @@ std::wstring AbstractTexturePack::getAnimationString( // Minecraft::getInstance()->getLogger().info("Found animation info for: // " + animationDefinitionFile); #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Found animation info for: %ls\n", + Log::info("Found animation info for: %ls\n", animationDefinitionFile.c_str()); #endif InputStreamReader isr(fileStream); @@ -162,7 +163,7 @@ BufferedImage* AbstractTexturePack::getImageResource( bool bTitleUpdateTexture /*=false*/, const std::wstring& drive /*=L""*/) { std::string pchTexture = wstringtofilename(File); std::string pchDrive = wstringtofilename(drive); - app.DebugPrintf("AbstractTexturePack::getImageResource - %s, drive is %s\n", + Log::info("AbstractTexturePack::getImageResource - %s, drive is %s\n", pchTexture.c_str(), pchDrive.c_str()); return new BufferedImage(TexturePack::getResource(L"/" + File), @@ -192,15 +193,15 @@ void AbstractTexturePack::loadDefaultColourTable() { m_colourTable = new ColourTable(data.data(), dataLength); } else { - app.DebugPrintf("Failed to load the default colours table\n"); - app.FatalLoadError(); + Log::info("Failed to load the default colours table\n"); + GameServices::fatalLoadError(); } } void AbstractTexturePack::loadDefaultHTMLColourTable() { - if (app.hasArchiveFile(L"HTMLColours.col")) { + if (GameServices::hasArchiveFile(L"HTMLColours.col")) { std::vector textColours = - app.getArchiveFile(L"HTMLColours.col"); + GameServices::getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data(), textColours.size()); } diff --git a/targets/minecraft/client/skins/DLCTexturePack.cpp b/targets/minecraft/client/skins/DLCTexturePack.cpp index 022d2cad8..f6ced500d 100644 --- a/targets/minecraft/client/skins/DLCTexturePack.cpp +++ b/targets/minecraft/client/skins/DLCTexturePack.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "DLCTexturePack.h" #include @@ -77,8 +79,8 @@ DLCTexturePack::DLCTexturePack(std::uint32_t id, DLCPack* pack, m_bLoadingData = false; m_bHasLoadedData = false; m_archiveFile = nullptr; - if (app.getLevelGenerationOptions()) - app.getLevelGenerationOptions()->setLoadedData(); + if (GameServices::getLevelGenerationOptions()) + GameServices::getLevelGenerationOptions()->setLoadedData(); m_bUsingDefaultColourTable = true; m_stringTable = nullptr; @@ -224,9 +226,9 @@ void DLCTexturePack::loadColourTable() { } // Load the text colours - if (app.hasArchiveFile(L"HTMLColours.col")) { + if (GameServices::hasArchiveFile(L"HTMLColours.col")) { std::vector textColours = - app.getArchiveFile(L"HTMLColours.col"); + GameServices::getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data(), textColours.size()); } @@ -244,20 +246,20 @@ void DLCTexturePack::loadData() { "TPACK") != ERROR_IO_PENDING) { // corrupt DLC m_bHasLoadedData = true; - if (app.getLevelGenerationOptions()) - app.getLevelGenerationOptions()->setLoadedData(); - app.DebugPrintf("Failed to mount texture pack DLC %d for pad %d\n", + if (GameServices::getLevelGenerationOptions()) + GameServices::getLevelGenerationOptions()->setLoadedData(); + Log::info("Failed to mount texture pack DLC %d for pad %d\n", mountIndex, InputManager.GetPrimaryPad()); } else { m_bLoadingData = true; - app.DebugPrintf("Attempted to mount DLC data for texture pack %d\n", + Log::info("Attempted to mount DLC data for texture pack %d\n", mountIndex); } } else { m_bHasLoadedData = true; - if (app.getLevelGenerationOptions()) - app.getLevelGenerationOptions()->setLoadedData(); - app.SetAction(InputManager.GetPrimaryPad(), + if (GameServices::getLevelGenerationOptions()) + GameServices::getLevelGenerationOptions()->setLoadedData(); + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } } @@ -265,7 +267,7 @@ void DLCTexturePack::loadData() { std::wstring DLCTexturePack::getFilePath(std::uint32_t packId, std::wstring filename, bool bAddDataFolder) { - return app.getFilePath(packId, filename, bAddDataFolder); + return GameServices::getFilePath(packId, filename, bAddDataFolder); } int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, @@ -274,9 +276,9 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, texturePack->m_bLoadingData = false; if (dwErr != ERROR_SUCCESS) { // corrupt DLC - app.DebugPrintf("Failed to mount DLC for pad %d: %u\n", iPad, dwErr); + Log::info("Failed to mount DLC for pad %d: %u\n", iPad, dwErr); } else { - app.DebugPrintf( + Log::info( "Mounted DLC for texture pack, attempting to load data\n"); texturePack->m_dlcDataPack = new DLCPack(texturePack->m_dlcInfoPack->getName(), dwLicenceMask); @@ -286,7 +288,7 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, std::wstring dataFilePath = texturePack->m_dlcInfoPack->getFullDataPath(); if (!dataFilePath.empty()) { - if (!app.m_dlcManager.readDLCDataFile( + if (!GameServices::getDLCManager().readDLCDataFile( dwFilesProcessed, getFilePath(texturePack->m_dlcInfoPack->GetPackID(), dataFilePath), @@ -309,7 +311,7 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, */ DLCPack* pack = texturePack->m_dlcInfoPack->GetParentPack(); LevelGenerationOptions* levelGen = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); if (levelGen != nullptr && !levelGen->hasLoadedData()) { int gameRulesCount = pack->getDLCItemsCount( DLCManager::e_DLCType_GameRulesHeader); @@ -336,10 +338,10 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, delete[] pbData; - app.m_gameRules.setLevelGenerationOptions( + GameServices::getGameRules().setLevelGenerationOptions( dlcFile->lgo); } else { - app.FatalLoadError(); + GameServices::fatalLoadError(); } } } @@ -357,7 +359,7 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, // after a read fail and it's not an error? levelGen->setBaseSaveData(pbData, fileSize); } else { - app.FatalLoadError(); + GameServices::fatalLoadError(); } } } @@ -400,9 +402,9 @@ int DLCTexturePack::onPackMounted(int iPad, std::uint32_t dwErr, } texturePack->m_bHasLoadedData = true; - if (app.getLevelGenerationOptions()) - app.getLevelGenerationOptions()->setLoadedData(); - app.SetAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); + if (GameServices::getLevelGenerationOptions()) + GameServices::getLevelGenerationOptions()->setLoadedData(); + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); return 0; } @@ -429,7 +431,7 @@ void DLCTexturePack::unloadUI() { } AbstractTexturePack::unloadUI(); - app.m_dlcManager.removePack(m_dlcDataPack); + GameServices::getDLCManager().removePack(m_dlcDataPack); m_dlcDataPack = nullptr; delete m_archiveFile; m_bHasLoadedData = false; diff --git a/targets/minecraft/client/skins/DefaultTexturePack.cpp b/targets/minecraft/client/skins/DefaultTexturePack.cpp index 4b86b2b19..9c1543771 100644 --- a/targets/minecraft/client/skins/DefaultTexturePack.cpp +++ b/targets/minecraft/client/skins/DefaultTexturePack.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "DefaultTexturePack.h" @@ -17,9 +18,9 @@ DefaultTexturePack::DefaultTexturePack() } void DefaultTexturePack::loadIcon() { - if (app.hasArchiveFile(L"Graphics\\TexturePackIcon.png")) { + if (GameServices::hasArchiveFile(L"Graphics\\TexturePackIcon.png")) { std::vector ba = - app.getArchiveFile(L"Graphics\\TexturePackIcon.png"); + GameServices::getArchiveFile(L"Graphics\\TexturePackIcon.png"); m_iconData = ba.data(); m_iconSize = static_cast(ba.size()); } diff --git a/targets/minecraft/client/skins/DefaultTexturePack.h b/targets/minecraft/client/skins/DefaultTexturePack.h index b7fd41292..8f33b5b71 100644 --- a/targets/minecraft/client/skins/DefaultTexturePack.h +++ b/targets/minecraft/client/skins/DefaultTexturePack.h @@ -2,8 +2,8 @@ #include #include "AbstractTexturePack.h" -#include "app/linux/LinuxGame.h" #include "java/InputOutputStream/InputStream.h" +#include "minecraft/locale/Strings.h" #include "strings.h" class DefaultTexturePack : public AbstractTexturePack { @@ -22,7 +22,7 @@ public: bool hasFile(const std::wstring& name); bool isTerrainUpdateCompatible(); - std::wstring getDesc1() { return app.GetString(IDS_DEFAULT_TEXTUREPACK); } + std::wstring getDesc1() { return Strings::get(IDS_DEFAULT_TEXTUREPACK); } protected: //@Override diff --git a/targets/minecraft/client/skins/TexturePackRepository.cpp b/targets/minecraft/client/skins/TexturePackRepository.cpp index 2f6b2215a..53cdf640f 100644 --- a/targets/minecraft/client/skins/TexturePackRepository.cpp +++ b/targets/minecraft/client/skins/TexturePackRepository.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "TexturePackRepository.h" #include @@ -62,13 +64,13 @@ bool TexturePackRepository::selectSkin(TexturePack* skin) { } void TexturePackRepository::selectWebSkin(const std::wstring& url) { - app.DebugPrintf( + Log::info( "TexturePackRepository::selectWebSkin is not implemented\n"); } void TexturePackRepository::downloadWebSkin(const std::wstring& url, File file) { - app.DebugPrintf( + Log::info( "TexturePackRepository::selectWebSkin is not implemented\n"); } @@ -86,12 +88,12 @@ void TexturePackRepository::updateList() { } std::wstring TexturePackRepository::getIdOrNull(File file) { - app.DebugPrintf("TexturePackRepository::getIdOrNull is not implemented\n"); + Log::info("TexturePackRepository::getIdOrNull is not implemented\n"); return L""; } std::vector TexturePackRepository::getWorkDirContents() { - app.DebugPrintf( + Log::info( "TexturePackRepository::getWorkDirContents is not implemented\n"); return std::vector(); } @@ -109,13 +111,13 @@ TexturePack* TexturePackRepository::getSelected() { } bool TexturePackRepository::shouldPromptForWebSkin() { - app.DebugPrintf( + Log::info( "TexturePackRepository::shouldPromptForWebSkin is not implemented\n"); return false; } bool TexturePackRepository::canUseWebSkin() { - app.DebugPrintf( + Log::info( "TexturePackRepository::canUseWebSkin is not implemented\n"); return false; } @@ -140,7 +142,7 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { // invite games // (where they don't have the texture pack) can check this when the texture // pack is installed - app.SetRequiredTexturePackID(id); + GameServices::setRequiredTexturePackID(id); auto it = cacheById.find(id); if (it != cacheById.end()) { @@ -149,7 +151,7 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { selectSkin(newPack); if (newPack->hasData()) { - app.SetAction(InputManager.GetPrimaryPad(), + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } else { newPack->loadData(); @@ -157,15 +159,15 @@ bool TexturePackRepository::selectTexturePackById(std::uint32_t id) { // Minecraft *pMinecraft = Minecraft::GetInstance(); // pMinecraft->textures->reloadAll(); } else { - app.DebugPrintf("TexturePack with id %d is already selected\n", id); + Log::info("TexturePack with id %d is already selected\n", id); } bDidSelect = true; } else { - app.DebugPrintf( + Log::info( "Failed to select texture pack %d as it is not in the list\n", id); // Fail safely if (selectSkin(DEFAULT_TEXTURE_PACK)) { - app.SetAction(InputManager.GetPrimaryPad(), + GameServices::setAction(InputManager.GetPrimaryPad(), eAppAction_ReloadTexturePack); } } diff --git a/targets/minecraft/client/title/TitleScreen.cpp b/targets/minecraft/client/title/TitleScreen.cpp index 7faa2c244..04c657856 100644 --- a/targets/minecraft/client/title/TitleScreen.cpp +++ b/targets/minecraft/client/title/TitleScreen.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "TitleScreen.h" #include @@ -41,8 +43,8 @@ TitleScreen::TitleScreen() { int splashIndex; std::wstring filename = L"splashes.txt"; - if (app.hasArchiveFile(filename)) { - std::vector splashesArray = app.getArchiveFile(filename); + if (GameServices::hasArchiveFile(filename)) { + std::vector splashesArray = GameServices::getArchiveFile(filename); ByteArrayInputStream bais(splashesArray); InputStreamReader isr(&bais); BufferedReader br(&isr); @@ -90,7 +92,7 @@ void TitleScreen::tick() { void TitleScreen::keyPressed(wchar_t eventCharacter, int eventKey) {} void TitleScreen::init() { - app.DebugPrintf("TitleScreen::init() START\n"); + Log::info("TitleScreen::init() START\n"); // 4jcraft: this is for the blured panorama background viewportTexture = @@ -141,31 +143,31 @@ if (c.get(Calendar.MONTH) + 1 == 11 && c.get(Calendar.DAY_OF_MONTH) == 9) { void TitleScreen::buttonClicked(Button* button) { if (button->id == 0) { - app.DebugPrintf( + Log::info( "TitleScreen::buttonClicked() 'Options...' if (button->id == 0)\n"); minecraft->setScreen(new OptionsScreen(this, minecraft->options)); } if (button->id == 1) { - app.DebugPrintf( + Log::info( "TitleScreen::buttonClicked() 'Singleplayer' if (button->id == " "1)\n"); minecraft->setScreen(new SelectWorldScreen(this)); } if (button->id == 2) { - app.DebugPrintf( + Log::info( "TitleScreen::buttonClicked() 'Multiplayer' if (button->id == " "2)\n"); minecraft->setScreen(new JoinMultiplayerScreen(this)); } if (button->id == 3) { - app.DebugPrintf( + Log::info( "TitleScreen::buttonClicked() 'Texture Pack' if (button->id == " "3)\n"); // minecraft->setScreen(new TexturePackSelectScreen(this)); // // 4J - TODO put back in } if (button->id == 4) { - app.DebugPrintf( + Log::info( "TitleScreen::buttonClicked() Exit Game if (button->id == 4)\n"); RenderManager.Close(); // minecraft->stop(); } diff --git a/targets/minecraft/commands/CommandDispatcher.cpp b/targets/minecraft/commands/CommandDispatcher.cpp index 634d6d371..87037c66f 100644 --- a/targets/minecraft/commands/CommandDispatcher.cpp +++ b/targets/minecraft/commands/CommandDispatcher.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "CommandDispatcher.h" #include @@ -24,7 +25,7 @@ int CommandDispatcher::performCommand(std::shared_ptr sender, #endif } } else { - app.DebugPrintf("Command %d not found!\n", command); + Log::info("Command %d not found!\n", command); } return 0; diff --git a/targets/minecraft/core/ItemDispenseBehaviors.cpp b/targets/minecraft/core/ItemDispenseBehaviors.cpp index e9b6aaac9..7be8e1053 100644 --- a/targets/minecraft/core/ItemDispenseBehaviors.cpp +++ b/targets/minecraft/core/ItemDispenseBehaviors.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameHostOptions.h" #include "ItemDispenseBehaviors.h" #include @@ -448,7 +449,7 @@ std::shared_ptr TntDispenseBehavior::execute( Level* world = source->getWorld(); if (world->newPrimedTntAllowed() && - app.GetGameHostOption(eGameHostOption_TNT)) { + GameHostOptions::get(eGameHostOption_TNT)) { int targetX = source->getBlockX() + facing->getStepX(); int targetY = source->getBlockY() + facing->getStepY(); int targetZ = source->getBlockZ() + facing->getStepZ(); diff --git a/targets/minecraft/locale/Strings.cpp b/targets/minecraft/locale/Strings.cpp new file mode 100644 index 000000000..3c30d9a0b --- /dev/null +++ b/targets/minecraft/locale/Strings.cpp @@ -0,0 +1,16 @@ +#include "minecraft/locale/Strings.h" + +#include + +namespace Strings { + +static LookupFn s_lookup = nullptr; + +void init(LookupFn fn) { s_lookup = fn; } + +const wchar_t* get(int id) { + assert(s_lookup && "Strings::init() must be called before Strings::get()"); + return s_lookup(id); +} + +} // namespace Strings diff --git a/targets/minecraft/locale/Strings.h b/targets/minecraft/locale/Strings.h new file mode 100644 index 000000000..73f7db0b9 --- /dev/null +++ b/targets/minecraft/locale/Strings.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace Strings { + +using LookupFn = const wchar_t* (*)(int); + +void init(LookupFn fn); +[[nodiscard]] const wchar_t* get(int id); + +} // namespace Strings diff --git a/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp b/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp index 3872f8c1b..035cfdb9a 100644 --- a/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp +++ b/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "BlockRegionUpdatePacket.h" #include @@ -74,7 +75,7 @@ BlockRegionUpdatePacket::BlockRegionUpdatePacket(int x, int y, int z, int xs, Compression::getCompression()->CompressLZXRLE( ucTemp, &inputSize, rawBuffer.data(), (unsigned int)rawBuffer.size()); - // app.DebugPrintf("Chunk (%d,%d) compressed from %d to size %d\n", + // Log::info("Chunk (%d,%d) compressed from %d to size %d\n", // x>>4, z>>4, rawBuffer.size(), inputSize); unsigned char* ucTemp2 = new unsigned char[inputSize]; memcpy(ucTemp2, ucTemp, inputSize); @@ -118,7 +119,7 @@ void BlockRegionUpdatePacket::read(DataInputStream* dis) // throws IOException Compression::getCompression()->DecompressLZXRLE( buffer.data(), &outputSize, compressedBuffer.data(), size); } else { - app.DebugPrintf( + Log::info( "Not decompressing packet that wasn't fully read\n"); } diff --git a/targets/minecraft/network/packet/CustomPayloadPacket.cpp b/targets/minecraft/network/packet/CustomPayloadPacket.cpp index 72ccc7bb3..66f373aec 100644 --- a/targets/minecraft/network/packet/CustomPayloadPacket.cpp +++ b/targets/minecraft/network/packet/CustomPayloadPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "CustomPayloadPacket.h" #include @@ -30,7 +31,7 @@ CustomPayloadPacket::CustomPayloadPacket(const std::wstring& identifier, length = data.size(); if (length > std::numeric_limits::max()) { - app.DebugPrintf("Payload may not be larger than 32K\n"); + Log::info("Payload may not be larger than 32K\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/targets/minecraft/network/packet/GameCommandPacket.cpp b/targets/minecraft/network/packet/GameCommandPacket.cpp index 13fadd380..71944da60 100644 --- a/targets/minecraft/network/packet/GameCommandPacket.cpp +++ b/targets/minecraft/network/packet/GameCommandPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "GameCommandPacket.h" #include @@ -23,7 +24,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, length = data.size(); if (length > std::numeric_limits::max()) { - app.DebugPrintf("Payload may not be larger than 32K\n"); + Log::info("Payload may not be larger than 32K\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/targets/minecraft/network/packet/LoginPacket.cpp b/targets/minecraft/network/packet/LoginPacket.cpp index 58e5bd641..6823437ad 100644 --- a/targets/minecraft/network/packet/LoginPacket.cpp +++ b/targets/minecraft/network/packet/LoginPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "LoginPacket.h" #include "app/linux/LinuxGame.h" @@ -131,7 +132,7 @@ void LoginPacket::read(DataInputStream* dis) // throws IOException m_xzSize = dis->readShort(); m_hellScale = dis->read(); #endif - app.DebugPrintf("LoginPacket::read - Difficulty = %d\n", difficulty); + Log::info("LoginPacket::read - Difficulty = %d\n", difficulty); } void LoginPacket::write(DataOutputStream* dos) // throws IOException diff --git a/targets/minecraft/network/packet/Packet.cpp b/targets/minecraft/network/packet/Packet.cpp index bd77f0cd7..d2eb450c2 100644 --- a/targets/minecraft/network/packet/Packet.cpp +++ b/targets/minecraft/network/packet/Packet.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Packet.h" #include @@ -465,7 +466,7 @@ void Packet::writeBytes(DataOutputStream* dataoutputstream, std::vector Packet::readBytes(DataInputStream* datainputstream) { int size = datainputstream->readShort(); if (size < 0) { - app.DebugPrintf("Key was smaller than nothing! Weird key!"); + Log::info("Key was smaller than nothing! Weird key!"); #if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif @@ -515,7 +516,7 @@ std::shared_ptr Packet::readPacket( serverReceivedPackets.find(id) == serverReceivedPackets.end()) || (!isServer && clientReceivedPackets.find(id) == clientReceivedPackets.end())) { - // app.DebugPrintf("Bad packet id %d\n", id); + // Log::info("Bad packet id %d\n", id); __debugbreak(); assert(false); // throw new IOException(wstring(L"Bad packet id ") + @@ -527,7 +528,7 @@ std::shared_ptr Packet::readPacket( assert(false); // throw new IOException(wstring(L"Bad packet id ") + // toWString(id)); - // app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", + // Log::info("%s reading packet %d\n", isServer ? "Server" : "Client", // packet->getId()); packet->read(dis); // } @@ -563,7 +564,7 @@ void Packet::writePacket( DataOutputStream* dos) // throws IOException TODO 4J JEV, should this declare a throws? { - // app.DebugPrintf("Writing packet %d\n", packet->getId()); + // Log::info("Writing packet %d\n", packet->getId()); dos->write(packet->getId()); packet->write(dos); } diff --git a/targets/minecraft/network/packet/PreLoginPacket.cpp b/targets/minecraft/network/packet/PreLoginPacket.cpp index 41978ed7b..5de0a2d42 100644 --- a/targets/minecraft/network/packet/PreLoginPacket.cpp +++ b/targets/minecraft/network/packet/PreLoginPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "PreLoginPacket.h" #include @@ -98,7 +99,7 @@ void PreLoginPacket::write(DataOutputStream* dos) // throws IOException dos->writePlayerUID(m_playerXuids[i]); } - app.DebugPrintf("*** PreLoginPacket::write - %s\n", m_szUniqueSaveName); + Log::info("*** PreLoginPacket::write - %s\n", m_szUniqueSaveName); for (int i = 0; i < m_iSaveNameLen; ++i) { dos->writeByte(static_cast(m_szUniqueSaveName[i])); } diff --git a/targets/minecraft/network/packet/RespawnPacket.cpp b/targets/minecraft/network/packet/RespawnPacket.cpp index 25b9bcc83..91e7cb3df 100644 --- a/targets/minecraft/network/packet/RespawnPacket.cpp +++ b/targets/minecraft/network/packet/RespawnPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "RespawnPacket.h" #include @@ -37,7 +38,7 @@ RespawnPacket::RespawnPacket(char dimension, int64_t mapSeed, int mapHeight, this->m_newEntityId = newEntityId; m_xzSize = xzSize; m_hellScale = hellScale; - app.DebugPrintf("RespawnPacket - Difficulty = %d\n", difficulty); + Log::info("RespawnPacket - Difficulty = %d\n", difficulty); } void RespawnPacket::handle(PacketListener* listener) { @@ -62,7 +63,7 @@ void RespawnPacket::read(DataInputStream* dis) // throws IOException m_xzSize = dis->readShort(); m_hellScale = dis->read(); #endif - app.DebugPrintf("RespawnPacket::read - Difficulty = %d\n", difficulty); + Log::info("RespawnPacket::read - Difficulty = %d\n", difficulty); } void RespawnPacket::write(DataOutputStream* dos) // throws IOException diff --git a/targets/minecraft/network/packet/ServerSettingsChangedPacket.cpp b/targets/minecraft/network/packet/ServerSettingsChangedPacket.cpp index 9f8ac9a13..80bc466de 100644 --- a/targets/minecraft/network/packet/ServerSettingsChangedPacket.cpp +++ b/targets/minecraft/network/packet/ServerSettingsChangedPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ServerSettingsChangedPacket.h" #include "PacketListener.h" @@ -20,7 +21,7 @@ ServerSettingsChangedPacket::ServerSettingsChangedPacket(char action, this->action = action; this->data = data; - // app.DebugPrintf("ServerSettingsChangedPacket - Difficulty = + // Log::info("ServerSettingsChangedPacket - Difficulty = // %d",difficulty); } diff --git a/targets/minecraft/network/packet/SetPlayerTeamPacket.cpp b/targets/minecraft/network/packet/SetPlayerTeamPacket.cpp index 8d79d076d..cd5448d2e 100644 --- a/targets/minecraft/network/packet/SetPlayerTeamPacket.cpp +++ b/targets/minecraft/network/packet/SetPlayerTeamPacket.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "SetPlayerTeamPacket.h" #include @@ -40,13 +41,13 @@ SetPlayerTeamPacket::SetPlayerTeamPacket(PlayerTeam* team, std::vector* playerNames, int method) { if (method != METHOD_JOIN && method != METHOD_LEAVE) { - app.DebugPrintf("Method must be join or leave for player constructor"); + Log::info("Method must be join or leave for player constructor"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif } if (playerNames == nullptr || playerNames->empty()) { - app.DebugPrintf("Players cannot be null/empty"); + Log::info("Players cannot be null/empty"); #ifndef _CONTENT_PACKAGE __debugbreak(); #endif diff --git a/targets/minecraft/server/MinecraftServer.cpp b/targets/minecraft/server/MinecraftServer.cpp index 0d9307758..49bc094d8 100644 --- a/targets/minecraft/server/MinecraftServer.cpp +++ b/targets/minecraft/server/MinecraftServer.cpp @@ -1,3 +1,7 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "MinecraftServer.h" #include @@ -147,30 +151,30 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, // 4J - removed settings = new Settings(new File(L"server.properties")); - app.DebugPrintf("\n*** SERVER SETTINGS ***\n"); - app.DebugPrintf( + Log::info("\n*** SERVER SETTINGS ***\n"); + Log::info( "ServerSettings: host-friends-only is %s\n", - (app.GetGameHostOption(eGameHostOption_FriendsOfFriends) > 0) ? "on" + (GameHostOptions::get(eGameHostOption_FriendsOfFriends) > 0) ? "on" : "off"); - app.DebugPrintf("ServerSettings: game-type is %s\n", - (app.GetGameHostOption(eGameHostOption_GameType) == 0) + Log::info("ServerSettings: game-type is %s\n", + (GameHostOptions::get(eGameHostOption_GameType) == 0) ? "Survival Mode" : "Creative Mode"); - app.DebugPrintf( + Log::info( "ServerSettings: pvp is %s\n", - (app.GetGameHostOption(eGameHostOption_PvP) > 0) ? "on" : "off"); - app.DebugPrintf("ServerSettings: fire spreads is %s\n", - (app.GetGameHostOption(eGameHostOption_FireSpreads) > 0) + (GameHostOptions::get(eGameHostOption_PvP) > 0) ? "on" : "off"); + Log::info("ServerSettings: fire spreads is %s\n", + (GameHostOptions::get(eGameHostOption_FireSpreads) > 0) ? "on" : "off"); - app.DebugPrintf( + Log::info( "ServerSettings: tnt explodes is %s\n", - (app.GetGameHostOption(eGameHostOption_TNT) > 0) ? "on" : "off"); - app.DebugPrintf("\n"); + (GameHostOptions::get(eGameHostOption_TNT) > 0) ? "on" : "off"); + Log::info("\n"); // TODO 4J Stu - Init a load of settings based on data passed as params // settings->setBooleanAndSave( L"host-friends-only", - // (app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0) ); + // (GameHostOptions::get(eGameHostOption_FriendsOfFriends)>0) ); // 4J - Unused // localIp = settings->getString(L"server-ip", L""); @@ -180,7 +184,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, setAnimals(settings->getBoolean(L"spawn-animals", true)); setNpcsEnabled(settings->getBoolean(L"spawn-npcs", true)); - setPvpAllowed(app.GetGameHostOption(eGameHostOption_PvP) > 0 + setPvpAllowed(GameHostOptions::get(eGameHostOption_PvP) > 0 ? true : false); // settings->getBoolean(L"pvp", true); @@ -200,12 +204,12 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, setPlayers(new PlayerList(this)); // 4J-JEV: Need to wait for levelGenerationOptions to load. - while (app.getLevelGenerationOptions() != nullptr && - !app.getLevelGenerationOptions()->hasLoadedData()) + while (GameServices::getLevelGenerationOptions() != nullptr && + !GameServices::getLevelGenerationOptions()->hasLoadedData()) std::this_thread::sleep_for(std::chrono::milliseconds(1)); - if (app.getLevelGenerationOptions() != nullptr && - !app.getLevelGenerationOptions()->ready()) { + if (GameServices::getLevelGenerationOptions() != nullptr && + !GameServices::getLevelGenerationOptions()->ready()) { // TODO: Stop loading, add error message. } @@ -215,12 +219,12 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, std::wstring levelTypeString; bool gameRuleUseFlatWorld = false; - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { gameRuleUseFlatWorld = - app.getLevelGenerationOptions()->getuseFlatWorld(); + GameServices::getLevelGenerationOptions()->getuseFlatWorld(); } if (gameRuleUseFlatWorld || - app.GetGameHostOption(eGameHostOption_LevelType) > 0) { + GameHostOptions::get(eGameHostOption_LevelType) > 0) { levelTypeString = settings->getString(L"level-type", L"flat"); } else { levelTypeString = settings->getString(L"level-type", L"default"); @@ -376,16 +380,16 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, int gameTypeId = settings->getInt( L"gamemode", - app.GetGameHostOption( + GameHostOptions::get( eGameHostOption_GameType)); // LevelSettings::GAMETYPE_SURVIVAL); GameType* gameType = LevelSettings::validateGameType(gameTypeId); - app.DebugPrintf("Default game type: %d\n", gameTypeId); + Log::info("Default game type: %d\n", gameTypeId); LevelSettings* levelSettings = new LevelSettings( levelSeed, gameType, - app.GetGameHostOption(eGameHostOption_Structures) > 0 ? true : false, + GameHostOptions::get(eGameHostOption_Structures) > 0 ? true : false, isHardcore(), true, pLevelType, initData->xzSize, initData->hellScale); - if (app.GetGameHostOption(eGameHostOption_BonusChest)) + if (GameHostOptions::get(eGameHostOption_BonusChest)) levelSettings->enableStartingBonusItems(); // 4J - temp - load existing level @@ -418,7 +422,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, // We are loading a save from the storage manager #if defined(SPLIT_SAVES) bool bLevelGenBaseSave = false; - LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGen = GameServices::getLevelGenerationOptions(); if (levelGen != nullptr && levelGen->requiresBaseSave()) { unsigned int fileSize = 0; std::uint8_t* pvSaveData = levelGen->getBaseSaveData(fileSize); @@ -457,9 +461,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, if (i == 0) { levels[i] = new ServerLevel(this, storage, name, dimension, levelSettings); - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* mapOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); Pos* spawnPos = mapOptions->getSpawnPos(); if (spawnPos != nullptr) { levels[i]->setSpawnPos(spawnPos); @@ -481,9 +485,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, // ? Difficulty::EASY : Difficulty::PEACEFUL; Minecraft* pMinecraft = Minecraft::GetInstance(); // m_lastSentDifficulty = pMinecraft->options->difficulty; - levels[i]->difficulty = app.GetGameHostOption( + levels[i]->difficulty = GameHostOptions::get( eGameHostOption_Difficulty); // pMinecraft->options->difficulty; - app.DebugPrintf("MinecraftServer::loadLevel - Difficulty = %d\n", + Log::info("MinecraftServer::loadLevel - Difficulty = %d\n", levels[i]->difficulty); #if DEBUG_SERVER_DONT_SPAWN_MOBS @@ -494,9 +498,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, #endif levels[i]->getLevelData()->setGameType(gameType); - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* mapOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); levels[i]->getLevelData()->setHasBeenInCreative( mapOptions->getLevelHasBeenInCreative()); } @@ -509,10 +513,10 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, } else { mcprogress->progressStage(IDS_PROGRESS_LOADING_SPAWN_AREA); } - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_HasBeenInCreative, gameType == GameType::CREATIVE || levels[0]->getHasBeenInCreative()); - app.SetGameHostOption(eGameHostOption_Structures, + GameHostOptions::set(eGameHostOption_Structures, levels[0]->isGenerateMapFeatures()); if (s_bServerHalted || !g_NetworkManager.IsInSession()) return false; @@ -552,14 +556,14 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, &numberOfBytesRead); assert(numberOfBytesRead == ba_gameRules.size()); - app.m_gameRules.loadGameRules(ba_gameRules.data(), ba_gameRules.size()); + GameServices::getGameRules().loadGameRules(ba_gameRules.data(), ba_gameRules.size()); csf->closeHandle(fe); } int64_t lastTime = System::currentTimeMillis(); #if defined(_LARGE_WORLDS) - if (app.GetGameNewWorldSize() > levels[0]->getLevelData()->getXZSizeOld()) { - if (!app.GetGameNewWorldSizeUseMoat()) // check the moat settings to + if (GameServices::getGameNewWorldSize() > levels[0]->getLevelData()->getXZSizeOld()) { + if (!GameServices::getGameNewWorldSizeUseMoat()) // check the moat settings to // see if we should be // overwriting the edge tiles { @@ -646,29 +650,29 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, // stronghold position? if (levels[0]->dimension->id == 0) { - app.DebugPrintf("===================================\n"); + Log::info("===================================\n"); if (!levels[0]->getLevelData()->getHasStronghold()) { int x, z; - if (app.GetTerrainFeaturePosition(eTerrainFeature_Stronghold, &x, + if (GameServices::getTerrainFeaturePosition(eTerrainFeature_Stronghold, &x, &z)) { levels[0]->getLevelData()->setXStronghold(x); levels[0]->getLevelData()->setZStronghold(z); levels[0]->getLevelData()->setHasStronghold(); - app.DebugPrintf( + Log::info( "=== FOUND stronghold in terrain features list\n"); } else { // can't find the stronghold position in the terrain feature // list. Do we have to run a post-process? - app.DebugPrintf( + Log::info( "=== Can't find stronghold in terrain features list\n"); } } else { - app.DebugPrintf("=== Leveldata has stronghold position\n"); + Log::info("=== Leveldata has stronghold position\n"); } - app.DebugPrintf("===================================\n"); + Log::info("===================================\n"); } // printf("Post processing complete at %dms\n",System::currentTimeMillis() @@ -724,7 +728,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, void MinecraftServer::overwriteBordersForNewWorldSize(ServerLevel* level) { // recreate the chunks round the border (2 chunks or 32 blocks deep), // deleting any player data from them - app.DebugPrintf("Expanding level size\n"); + Log::info("Expanding level size\n"); int oldSize = level->getLevelData()->getXZSizeOld(); // top int minVal = -oldSize / 2; @@ -758,7 +762,7 @@ void MinecraftServer::overwriteHellBordersForNewWorldSize(ServerLevel* level, int oldHellSize) { // recreate the chunks round the border (1 chunk or 16 blocks deep), // deleting any player data from them - app.DebugPrintf("Expanding level size\n"); + Log::info("Expanding level size\n"); // top int minVal = -oldHellSize / 2; int maxVal = (oldHellSize / 2) - 1; @@ -829,8 +833,8 @@ void MinecraftServer::saveAllChunks() { // 4J-JEV: Added void MinecraftServer::saveGameRules() { #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { // Do nothing } else @@ -838,7 +842,7 @@ void MinecraftServer::saveGameRules() { { uint8_t* baPtr = nullptr; unsigned int baSize = 0; - app.m_gameRules.saveGameRules(&baPtr, &baSize); + GameServices::getGameRules().saveGameRules(&baPtr, &baSize); if (baPtr != nullptr) { std::vector ba(baPtr, baPtr + baSize); @@ -878,7 +882,7 @@ void MinecraftServer::Suspend() { } m_suspending = false; - app.DebugPrintf("Suspend server: Elapsed time %f\n", + Log::info("Suspend server: Elapsed time %f\n", static_cast(timer.elapsed_seconds())); } @@ -893,7 +897,7 @@ void MinecraftServer::stopServer(bool didInit) { connection->stop(); - app.DebugPrintf("Stopping server\n"); + Log::info("Stopping server\n"); // logger.info("Stopping server"); // 4J-PB - If the primary player has signed out, then don't attempt to save // anything @@ -924,7 +928,7 @@ void MinecraftServer::stopServer(bool didInit) { //} saveGameRules(); - app.m_gameRules.unloadCurrentGameRules(); + GameServices::getGameRules().unloadCurrentGameRules(); if (levels[0] != nullptr) // This can be null if stopServer happens // very quickly due to network error { @@ -1061,7 +1065,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { bool findSeed = false; if (lpParameter != nullptr) { initData = (NetworkGameInitData*)lpParameter; - initSettings = app.GetGameHostOption(eGameHostOption_All); + initSettings = GameHostOptions::get(eGameHostOption_All); findSeed = initData->findSeed; m_texturePackId = initData->texturePackId; } @@ -1077,7 +1081,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { if (pLevelData && pLevelData->getHasStronghold() == false) { int x, z; - if (app.GetTerrainFeaturePosition(eTerrainFeature_Stronghold, &x, + if (GameServices::getTerrainFeaturePosition(eTerrainFeature_Stronghold, &x, &z)) { pLevelData->setXStronghold(x); pLevelData->setZStronghold(z); @@ -1180,13 +1184,13 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { eXuiServerAction eAction; void* param; for (int i = 0; i < XUSER_MAX_COUNT; i++) { - eAction = app.GetXuiServerAction(i); - param = app.GetXuiServerActionParam(i); + eAction = GameServices::getXuiServerAction(i); + param = GameServices::getXuiServerActionParam(i); switch (eAction) { case eXuiServerAction_AutoSaveGame: case eXuiServerAction_SaveGame: - app.lockSaveNotification(); + GameServices::lockSaveNotification(); if (players != nullptr) { players->saveAll( Minecraft::GetInstance()->progressRenderer); @@ -1221,7 +1225,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { Minecraft::GetInstance()->progressRenderer, (eAction == eXuiServerAction_AutoSaveGame)); } - app.unlockSaveNotification(); + GameServices::unlockSaveNotification(); break; case eXuiServerAction_DropItem: // Find the player, and drop the id at their feet @@ -1279,7 +1283,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { std::shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_OPTIONS, - app.GetGameHostOption( + GameHostOptions::get( eGameHostOption_Gamertags)))); break; case eXuiServerAction_ServerSettingChanged_BedrockFog: @@ -1288,7 +1292,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { new ServerSettingsChangedPacket( ServerSettingsChangedPacket:: HOST_IN_GAME_SETTINGS, - app.GetGameHostOption( + GameHostOptions::get( eGameHostOption_All)))); break; @@ -1302,7 +1306,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { break; case eXuiServerAction_ExportSchematic: #if !defined(_CONTENT_PACKAGE) - app.lockSaveNotification(); + GameServices::lockSaveNotification(); // players->broadcastAll( // shared_ptr( new @@ -1336,7 +1340,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { delete initData; } - app.unlockSaveNotification(); + GameServices::unlockSaveNotification(); #endif break; case eXuiServerAction_SetCameraLocation: @@ -1345,8 +1349,8 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { DebugSetCameraPosition* pos = (DebugSetCameraPosition*)param; - app.DebugPrintf("DEBUG: Player=%i\n", pos->player); - app.DebugPrintf( + Log::info("DEBUG: Player=%i\n", pos->player); + Log::info( "DEBUG: Teleporting to pos=(%f.2, %f.2, %f.2), " "looking at=(%f.2,%f.2)\n", pos->m_camX, pos->m_camY, pos->m_camZ, pos->m_yRot, @@ -1369,7 +1373,7 @@ void MinecraftServer::run(int64_t seed, void* lpParameter) { break; } - app.SetXuiServerAction(i, eXuiServerAction_Idle); + GameServices::setXuiServerAction(i, eXuiServerAction_Idle); } std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -1438,7 +1442,7 @@ void MinecraftServer::tick() { // 4J Stu - We set the levels difficulty based on the minecraft // options - level->difficulty = app.GetGameHostOption( + level->difficulty = GameHostOptions::get( eGameHostOption_Difficulty); // pMinecraft->options->difficulty; #if DEBUG_SERVER_DONT_SPAWN_MOBS @@ -1584,10 +1588,10 @@ void MinecraftServer::chunkPacketManagement_DidSendTo(INetworkPlayer* player) { if ((currentTime - s_tickStartTime) >= MAX_TICK_TIME_FOR_PACKET_SENDS) { s_hasSentEnoughPackets = true; - // app.DebugPrintf("Sending, setting enough packet flag: + // Log::info("Sending, setting enough packet flag: //%dms\n",currentTime - s_tickStartTime); } else { - // app.DebugPrintf("Sending, more time: %dms\n",currentTime + // Log::info("Sending, more time: %dms\n",currentTime //- s_tickStartTime); } @@ -1597,7 +1601,7 @@ void MinecraftServer::chunkPacketManagement_DidSendTo(INetworkPlayer* player) { } void MinecraftServer::chunkPacketManagement_PreTick() { - // app.DebugPrintf("*************************************************************************************************************************************************************************\n"); + // Log::info("*************************************************************************************************************************************************************************\n"); s_hasSentEnoughPackets = false; s_tickStartTime = System::currentTimeMillis(); s_sentTo.clear(); @@ -1640,7 +1644,7 @@ bool MinecraftServer::chunkPacketManagement_CanSendTo(INetworkPlayer* player) { auto now = time_util::clock::now(); if (player->GetSessionIndex() == s_slowQueuePlayerIndex && (now - s_slowQueueLastTime) > std::chrono::milliseconds(MINECRAFT_SERVER_SLOW_QUEUE_DELAY)) { - // app.DebugPrintf("Slow queue OK for player #%d\n", + // Log::info("Slow queue OK for player #%d\n", // player->GetSessionIndex()); return true; } @@ -1660,7 +1664,7 @@ void MinecraftServer::chunkPacketManagement_PostTick() { auto now = time_util::clock::now(); if ((s_slowQueuePacketSent) || ((now - s_slowQueueLastTime) > std::chrono::milliseconds(2 * MINECRAFT_SERVER_SLOW_QUEUE_DELAY))) { - // app.DebugPrintf("Considering cycling: (%d) %d - %d -> %d + // Log::info("Considering cycling: (%d) %d - %d -> %d //> %d\n",s_slowQueuePacketSent, time, s_slowQueueLastTime, (time - // s_slowQueueLastTime), (2*MINECRAFT_SERVER_SLOW_QUEUE_DELAY)); MinecraftServer::cycleSlowQueueIndex(); @@ -1669,7 +1673,7 @@ void MinecraftServer::chunkPacketManagement_PostTick() { } // else // { - // app.DebugPrintf("Not considering cycling: %d - %d -> %d > + // Log::info("Not considering cycling: %d - %d -> %d > //%d\n",time, s_slowQueueLastTime, (time - s_slowQueueLastTime), //(2*MINECRAFT_SERVER_SLOW_QUEUE_DELAY)); // } @@ -1700,7 +1704,7 @@ void MinecraftServer::cycleSlowQueueIndex() { } while (g_NetworkManager.IsInSession() && currentPlayerCount > 0 && s_slowQueuePlayerIndex != startingIndex && currentPlayer != nullptr && currentPlayer->IsLocal()); - // app.DebugPrintf("Cycled slow queue index to %d\n", + // Log::info("Cycled slow queue index to %d\n", // s_slowQueuePlayerIndex); } #endif diff --git a/targets/minecraft/server/PlayerList.cpp b/targets/minecraft/server/PlayerList.cpp index 169604f5f..e627815ca 100644 --- a/targets/minecraft/server/PlayerList.cpp +++ b/targets/minecraft/server/PlayerList.cpp @@ -1,3 +1,6 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "PlayerList.h" #include @@ -185,14 +188,14 @@ void PlayerList::placeNewPlayer(Connection* connection, Item::map_Id, 1, level->getAuxValueForMap(player->getXuid(), 0, centreXC, centreZC, mapScale))); - if (app.getGameRuleDefinitions() != nullptr) { - app.getGameRuleDefinitions()->postProcessPlayer(player); + if (GameServices::getGameRuleDefinitions() != nullptr) { + GameServices::getGameRuleDefinitions()->postProcessPlayer(player); } } if (!player->customTextureUrl.empty() && player->customTextureUrl.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(player->customTextureUrl)) { + !GameServices::isFileInMemoryTextures(player->customTextureUrl)) { if (server->getConnection()->addPendingTextureRequest( player->customTextureUrl)) { #if !defined(_CONTENT_PACKAGE) @@ -206,14 +209,14 @@ void PlayerList::placeNewPlayer(Connection* connection, 0))); } } else if (!player->customTextureUrl.empty() && - app.IsFileInMemoryTextures(player->customTextureUrl)) { + GameServices::isFileInMemoryTextures(player->customTextureUrl)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl, nullptr, 0); + GameServices::addMemoryTextureFile(player->customTextureUrl, nullptr, 0); } if (!player->customTextureUrl2.empty() && player->customTextureUrl2.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(player->customTextureUrl2)) { + !GameServices::isFileInMemoryTextures(player->customTextureUrl2)) { if (server->getConnection()->addPendingTextureRequest( player->customTextureUrl2)) { #if !defined(_CONTENT_PACKAGE) @@ -226,9 +229,9 @@ void PlayerList::placeNewPlayer(Connection* connection, new TexturePacket(player->customTextureUrl2, nullptr, 0))); } } else if (!player->customTextureUrl2.empty() && - app.IsFileInMemoryTextures(player->customTextureUrl2)) { + GameServices::isFileInMemoryTextures(player->customTextureUrl2)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(player->customTextureUrl2, nullptr, 0); + GameServices::addMemoryTextureFile(player->customTextureUrl2, nullptr, 0); } player->setIsGuest(packet->m_isGuest); @@ -416,7 +419,7 @@ void PlayerList::validatePlayerSpawnPosition( // 4J Stu - Some adjustments to make sure the current players position is // correct Make sure that the player is on the ground, and in the centre x/z // of the current column - app.DebugPrintf("Original pos is %f, %f, %f in dimension %d\n", player->x, + Log::info("Original pos is %f, %f, %f in dimension %d\n", player->x, player->y, player->z, player->dimension); bool spawnForced = player->isRespawnForced(); @@ -437,14 +440,14 @@ void PlayerList::validatePlayerSpawnPosition( player->setPos(targetX, targetY, targetZ); - app.DebugPrintf("New pos is %f, %f, %f in dimension %d\n", player->x, + Log::info("New pos is %f, %f, %f in dimension %d\n", player->x, player->y, player->z, player->dimension); ServerLevel* level = server->getLevel(player->dimension); while (level->getCubes(player, &player->bb)->size() != 0) { player->setPos(player->x, player->y + 1, player->z); } - app.DebugPrintf("Final pos is %f, %f, %f in dimension %d\n", player->x, + Log::info("Final pos is %f, %f, %f in dimension %d\n", player->x, player->y, player->z, player->dimension); // 4J Stu - If we are in the nether and the above while loop has put us @@ -455,7 +458,7 @@ void PlayerList::validatePlayerSpawnPosition( // use this mechanism to force a spawn point in the overworld for players // who were in the save when the reset nether option was applied if (level->dimension->id == -1 && player->y > 125) { - app.DebugPrintf( + Log::info( "Player in the nether tried to spawn at y = %f, moving to " "overworld\n", player->y); @@ -485,7 +488,7 @@ void PlayerList::validatePlayerSpawnPosition( player->setPos(player->x, player->y + 1, player->z); } - app.DebugPrintf("Updated pos is %f, %f, %f in dimension %d\n", + Log::info("Updated pos is %f, %f, %f in dimension %d\n", player->x, player->y, player->z, player->dimension); } } @@ -557,7 +560,7 @@ void PlayerList::remove(std::shared_ptr player) { // removed, also remove mount because it's saved in the player's // save tag level->removeEntityImmediately(player->riding); - app.DebugPrintf("removing player mount"); + Log::info("removing player mount"); } level->removeEntity(player); level->getChunkMap()->remove(player); @@ -601,11 +604,11 @@ std::shared_ptr PlayerList::getPlayerForLogin( pendingConnection->connection->getSocket()->getPlayer(); if (networkPlayer != nullptr && !networkPlayer->IsHost()) { player->enableAllPlayerPrivileges( - app.GetGameHostOption(eGameHostOption_TrustPlayers) > 0); + GameHostOptions::get(eGameHostOption_TrustPlayers) > 0); } // 4J Added - LevelRuleset* serverRuleDefs = app.getGameRuleDefinitions(); + LevelRuleset* serverRuleDefs = GameServices::getGameRuleDefinitions(); if (serverRuleDefs != nullptr) { player->gameMode->setGameRules( GameRuleDefinition::generateNewGameRulesInstance( @@ -661,14 +664,14 @@ std::shared_ptr PlayerList::respawn( if (isPrimary) { if (isEmptying) { - app.DebugPrintf("Emptying this dimension\n"); + Log::info("Emptying this dimension\n"); serverPlayer->getLevel()->getTracker()->clear(serverPlayer); } else { - app.DebugPrintf("Transferring... storing flags\n"); + Log::info("Transferring... storing flags\n"); serverPlayer->getLevel()->getTracker()->removeEntity(serverPlayer); } } else { - app.DebugPrintf("Not primary player\n"); + Log::info("Not primary player\n"); serverPlayer->getLevel()->getTracker()->removeEntity(serverPlayer); } @@ -816,7 +819,7 @@ std::shared_ptr PlayerList::respawn( if (Minecraft::GetInstance()->isTutorial() && (!Minecraft::GetInstance()->gameMode->getTutorial()->isStateCompleted( e_Tutorial_State_Food_Bar))) { - app.getGameRuleDefinitions()->postProcessPlayer(player); + GameServices::getGameRuleDefinitions()->postProcessPlayer(player); } if (oldDimension == 1 && player->dimension != 1) { @@ -863,14 +866,14 @@ void PlayerList::toggleDimension(std::shared_ptr player, if (isPrimary) { if (isEmptying) { - app.DebugPrintf("Toggle... Emptying this dimension\n"); + Log::info("Toggle... Emptying this dimension\n"); player->getLevel()->getTracker()->clear(player); } else { - app.DebugPrintf("Toggle... transferring\n"); + Log::info("Toggle... transferring\n"); player->getLevel()->getTracker()->removeEntity(player); } } else { - app.DebugPrintf("Toggle... Not primary player\n"); + Log::info("Toggle... Not primary player\n"); player->getLevel()->getTracker()->removeEntity(player); } @@ -1116,7 +1119,7 @@ void PlayerList::tick() { findAlivePlayerOnSystem(currentPlayer); if (newPlayer != nullptr) { receiveAllPlayers[dim][i] = newPlayer; - app.DebugPrintf( + Log::info( "Replacing primary player %ls with %ls in dimension " "%d\n", currentPlayer->name.c_str(), newPlayer->name.c_str(), @@ -1165,9 +1168,9 @@ bool PlayerList::isWhiteListed(const std::wstring& name) { return true; } bool PlayerList::isOp(const std::wstring& name) { return false; } bool PlayerList::isOp(std::shared_ptr player) { - bool cheatsEnabled = app.GetGameHostOption(eGameHostOption_CheatsEnabled); + bool cheatsEnabled = GameHostOptions::get(eGameHostOption_CheatsEnabled); #if defined(_DEBUG_MENUS_ENABLED) - cheatsEnabled = cheatsEnabled || app.GetUseDPadForDebug(); + cheatsEnabled = cheatsEnabled || GameServices::getUseDPadForDebug(); #endif INetworkPlayer* networkPlayer = player->connection->getNetworkPlayer(); bool isOp = cheatsEnabled && @@ -1233,7 +1236,7 @@ std::vector* PlayerList::getPlayers( std::unordered_map* scoreRequirements, const std::wstring& playerName, const std::wstring& teamName, Level* level) { - app.DebugPrintf("getPlayers NOT IMPLEMENTED!"); + Log::info("getPlayers NOT IMPLEMENTED!"); return nullptr; /*if (players.empty()) return nullptr; @@ -1288,7 +1291,7 @@ std::vector* PlayerList::getPlayers( bool PlayerList::meetsScoreRequirements( std::shared_ptr player, std::unordered_map scoreRequirements) { - app.DebugPrintf("meetsScoreRequirements NOT IMPLEMENTED!"); + Log::info("meetsScoreRequirements NOT IMPLEMENTED!"); return false; // if (scoreRequirements == null || scoreRequirements.size() == 0) return @@ -1522,7 +1525,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, dimIndex = 2; #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Requesting remove player %ls as primary in dimension %d\n", + Log::info("Requesting remove player %ls as primary in dimension %d\n", player->name.c_str(), dimIndex); #endif bool playerRemoved = false; @@ -1531,7 +1534,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, receiveAllPlayers[dimIndex].end(), player); if (it != receiveAllPlayers[dimIndex].end()) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "Remove: Removing player %ls as primary in dimension %d\n", player->name.c_str(), dimIndex); #endif @@ -1551,7 +1554,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, otherPlayer != nullptr && otherPlayer->IsSameSystem(thisPlayer)) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "Remove: Adding player %ls as primary in dimension %d\n", newPlayer->name.c_str(), dimIndex); #endif @@ -1561,7 +1564,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, } } else if (thisPlayer == nullptr) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "Remove: Qnet player for %ls was nullptr so re-checking all " "players\n", player->name.c_str()); @@ -1594,7 +1597,7 @@ void PlayerList::removePlayerFromReceiving(std::shared_ptr player, } if (!foundPrimary) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "Remove: Adding player %ls as primary in dimension " "%d\n", newPlayer->name.c_str(), newPlayerDim); @@ -1614,7 +1617,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { playerDim = 2; #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Requesting add player %ls as primary in dimension %d\n", + Log::info("Requesting add player %ls as primary in dimension %d\n", player->name.c_str(), playerDim); #endif @@ -1624,7 +1627,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { if (thisPlayer == nullptr) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf( + Log::info( "Add: Qnet player for player %ls is nullptr so not adding them\n", player->name.c_str()); #endif @@ -1645,7 +1648,7 @@ void PlayerList::addPlayerToReceiving(std::shared_ptr player) { if (shouldAddPlayer) { #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("Add: Adding player %ls as primary in dimension %d\n", + Log::info("Add: Adding player %ls as primary in dimension %d\n", player->name.c_str(), playerDim); #endif receiveAllPlayers[playerDim].push_back(player); diff --git a/targets/minecraft/server/level/PlayerChunkMap.cpp b/targets/minecraft/server/level/PlayerChunkMap.cpp index 61f4eef9e..9e26fdea3 100644 --- a/targets/minecraft/server/level/PlayerChunkMap.cpp +++ b/targets/minecraft/server/level/PlayerChunkMap.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "PlayerChunkMap.h" #include @@ -64,12 +65,12 @@ void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int* flags, void PlayerChunkMap::PlayerChunk::add(std::shared_ptr player, bool sendPacket /*= true*/) { - // app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z); + // Log::info("--- Adding player to chunk x=%d\tz=%d\n",x, z); if (find(players.begin(), players.end(), player) != players.end()) { // 4J-PB - At the start of the game, lots of chunks are added, and we // can then move into an area that is outside the diameter of our // starting area, but is inside the area loaded at the start. - app.DebugPrintf( + Log::info( "--- Adding player to chunk x=%d\t z=%d, but they are already in " "there!\n", pos.x, pos.z); @@ -103,11 +104,11 @@ void PlayerChunkMap::PlayerChunk::add(std::shared_ptr player, void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr player) { PlayerChunkMap::PlayerChunk* toDelete = nullptr; - // app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove + // Log::info("--- PlayerChunkMap::PlayerChunk::remove // x=%d\tz=%d\n",x,z); auto it = find(players.begin(), players.end(), player); if (it == players.end()) { - app.DebugPrintf( + Log::info( "--- INFO - Removing player from chunk x=%d\t z=%d, but they are " "not in that chunk!\n", pos.x, pos.z); @@ -170,7 +171,7 @@ void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr player) { new ChunkVisibilityPacket(pos.x, pos.z, false))); } } else { - // app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer + // Log::info("PlayerChunkMap::PlayerChunk::remove - QNetPlayer // is nullptr\n"); } } diff --git a/targets/minecraft/server/level/ServerChunkCache.cpp b/targets/minecraft/server/level/ServerChunkCache.cpp index 386c2ad9e..82f2c8de1 100644 --- a/targets/minecraft/server/level/ServerChunkCache.cpp +++ b/targets/minecraft/server/level/ServerChunkCache.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ServerChunkCache.h" #include @@ -6,7 +7,7 @@ #include -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "app/linux/Stubs/winapi_stubs.h" #include "ServerLevel.h" #include "minecraft/world/level/storage/ConsoleSaveFileIO/compression.h" @@ -559,7 +560,7 @@ void ServerChunkCache::flagPostProcessComplete(short flag, int x, int z) { // Are all neighbouring chunks And this one now post-processed? if (lc->terrainPopulated == LevelChunk::sTerrainPopulatedAllNeighbours) { // Special lighting patching for schematics first - app.processSchematicsLighting(lc); + GameServices::processSchematicsLighting(lc); // This would be a good time to fix up any lighting for this chunk since // all the geometry that could affect it should now be in place @@ -676,7 +677,7 @@ bool ServerChunkCache::save(bool force, ProgressListener* progressListener) { bool maxSavesReached = false; if (!force) { - // app.DebugPrintf("Unsaved chunks = %d\n", + // Log::info("Unsaved chunks = %d\n", // level->getUnsavedChunkCount() ); // Single threaded implementation for small saves for (unsigned int i = 0; i < m_loadedChunkList.size(); i++) { @@ -854,10 +855,10 @@ int ServerChunkCache::runSaveThreadProc(void* lpParam) { C4JThread:: kInfiniteTimeout); // WaitForSingleObject(params->wakeEvent,INFINITE); - // app.DebugPrintf("Save thread has started\n"); + // Log::info("Save thread has started\n"); while (params->chunkToSave != nullptr) { - // app.DebugPrintf("Save thread has started processing a chunk\n"); + // Log::info("Save thread has started processing a chunk\n"); if (params->saveEntities) params->cache->saveEntities(params->chunkToSave); @@ -868,7 +869,7 @@ int ServerChunkCache::runSaveThreadProc(void* lpParam) { params->notificationEvent ->set(); // SetEvent(params->notificationEvent); - // app.DebugPrintf("Save thread has alerted producer that it is + // Log::info("Save thread has alerted producer that it is // complete\n"); // Wait for the producer thread to tell us to go again @@ -877,7 +878,7 @@ int ServerChunkCache::runSaveThreadProc(void* lpParam) { kInfiniteTimeout); // WaitForSingleObject(params->wakeEvent,INFINITE); } - // app.DebugPrintf("Thread is exiting as it has no chunk to process\n"); + // Log::info("Thread is exiting as it has no chunk to process\n"); if (!params->useSharedThreadStorage) { Compression::ReleaseThreadStorage(); diff --git a/targets/minecraft/server/level/ServerLevel.cpp b/targets/minecraft/server/level/ServerLevel.cpp index 789838738..3520b8de9 100644 --- a/targets/minecraft/server/level/ServerLevel.cpp +++ b/targets/minecraft/server/level/ServerLevel.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "ServerLevel.h" #include @@ -311,7 +313,7 @@ void ServerLevel::tick() { (dimension->id * dimension->id * (saveInterval / 2))) #endif { - // app.DebugPrintf("Incremental save\n"); + // Log::info("Incremental save\n"); save(false, nullptr); } @@ -323,8 +325,8 @@ void ServerLevel::tick() { // 4J: Debug setting added to keep it at day time #if !defined(_FINAL_BUILD) bool freezeTime = - app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) & + DebugSettings::isOn() && + DebugSettings::getMask(InputManager.GetPrimaryPad()) & (1L << eDebugSetting_FreezeTime); if (!freezeTime) #endif @@ -489,7 +491,7 @@ void ServerLevel::tickTiles() { // AP moved this outside of the loop int prob = 100000; - if (app.GetGameSettingsDebugMask() & (1L << eDebugSetting_RegularLightning)) + if (DebugSettings::getMask() & (1L << eDebugSetting_RegularLightning)) prob = 100; auto itEndCtp = chunksToPoll.end(); @@ -734,7 +736,7 @@ std::vector* ServerLevel::fetchTicksInChunk(LevelChunk* chunk, } } else { if (!toBeTicked.empty()) { - app.DebugPrintf("To be ticked size: %d\n", toBeTicked.size()); + Log::info("To be ticked size: %d\n", toBeTicked.size()); } for (auto it = toBeTicked.begin(); it != toBeTicked.end();) { TickNextTickData td = *it; @@ -849,7 +851,7 @@ void ServerLevel::setInitialSpawn(LevelSettings* levelSettings) { zSpawn = findBiome->z; delete findBiome; } else { - app.DebugPrintf( + Log::info( "Level::setInitialSpawn - Unable to find spawn biome\n"); } @@ -1099,7 +1101,7 @@ std::shared_ptr ServerLevel::explode(std::shared_ptr source, if (player->distanceToSqr(x, y, z) < 64 * 64) { Vec3 knockbackVec = explosion->getHitPlayerKnockback(player); - // app.DebugPrintf("Sending %s with knockback (%f,%f,%f)\n", + // Log::info("Sending %s with knockback (%f,%f,%f)\n", // knockbackOnly?"knockbackOnly":"allExplosion",knockbackVec->x,knockbackVec->y,knockbackVec->z); // If the player is not the primary on the system, then we only // want to send info for the knockback diff --git a/targets/minecraft/server/level/ServerLevelListener.cpp b/targets/minecraft/server/level/ServerLevelListener.cpp index b48dbcd92..dd2204c08 100644 --- a/targets/minecraft/server/level/ServerLevelListener.cpp +++ b/targets/minecraft/server/level/ServerLevelListener.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ServerLevelListener.h" #include @@ -57,7 +58,7 @@ void ServerLevelListener::playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist) { if (iSound < 0) { - app.DebugPrintf( + Log::info( "ServerLevelListener received request for sound less than 0, so " "ignoring\n"); } else { @@ -78,7 +79,7 @@ void ServerLevelListener::playSoundExceptPlayer(std::shared_ptr player, float pitch, float fSoundClipDist) { if (iSound < 0) { - app.DebugPrintf( + Log::info( "ServerLevelListener received request for sound less than 0, so " "ignoring\n"); } else { diff --git a/targets/minecraft/server/level/ServerPlayer.cpp b/targets/minecraft/server/level/ServerPlayer.cpp index 2630c28a3..7d358093b 100644 --- a/targets/minecraft/server/level/ServerPlayer.cpp +++ b/targets/minecraft/server/level/ServerPlayer.cpp @@ -1,3 +1,7 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/locale/Strings.h" +#include "minecraft/util/Log.h" #include "ServerPlayer.h" #include @@ -431,11 +435,11 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { MinecraftServer::chunkPacketManagement_CanSendTo( connection->getNetworkPlayer()); - // app.DebugPrintf(">>> %d\n", + // Log::info(">>> %d\n", // canSendToPlayer); if( // connection->getNetworkPlayer() ) // { - // app.DebugPrintf("%d: + // Log::info("%d: // canSendToPlayer %d, countDelayedPackets %d // GetSendQueueSizeBytes %d done: %d\n", // connection->getNetworkPlayer()->GetSmallId(), @@ -465,12 +469,12 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { // System::currentTimeMillis(); // int64_t lastTime = // mapLastTime[connection->getNetworkPlayer()->GetUID().toString()]; - // app.DebugPrintf(" - OK + // Log::info(" - OK // to send (%d ms since last)\n", thisTime - lastTime); // mapLastTime[connection->getNetworkPlayer()->GetUID().toString()] //= thisTime; } else { - // app.DebugPrintf(" - \n"); } } @@ -505,7 +509,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { // finite set of chunks as the player moves if (!g_NetworkManager.SystemFlagGet( connection->getNetworkPlayer(), flagIndex)) { - // app.DebugPrintf("Creating + // Log::info("Creating // BRUP for %d %d\n",nearest.x, nearest.z); int64_t before = System::currentTimeMillis(); std::shared_ptr packet = @@ -514,7 +518,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { nearest.x * 16, 0, nearest.z * 16, 16, Level::maxBuildHeight, 16, level)); int64_t after = System::currentTimeMillis(); - // app.DebugPrintf(">>><<< + // Log::info(">>><<< //%d ms\n",after-before); if (dontDelayChunks) packet->shouldDelay = false; @@ -583,7 +587,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { void ServerPlayer::doTickB() { #if !defined(_CONTENT_PACKAGE) // check if there's a debug dimension change requested - // if(app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad())&(1L<dimension->id == 0 ) // { @@ -591,11 +595,11 @@ void ServerPlayer::doTickB() { // portalTime=1; // } // unsigned int - // uiVal=app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()); - // app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(),uiVal&~(1L<dimension->id == 0 ) // { @@ -603,19 +607,19 @@ void ServerPlayer::doTickB() { // std::dynamic_pointer_cast( shared_from_this() ), 1 ); // } // unsigned int - // uiVal=app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()); - // app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(),uiVal&~(1L<dimension->id != 0) { isInsidePortal = true; portalTime = 1; } unsigned int uiVal = - app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()); - app.SetGameSettingsDebugMask( + DebugSettings::getMask(InputManager.GetPrimaryPad()); + GameServices::setGameSettingsDebugMask( InputManager.GetPrimaryPad(), uiVal & ~(1L << eDebugSetting_GoToOverworld)); } @@ -765,7 +769,7 @@ void ServerPlayer::changeDimension(int i) { if (!connection->hasClientTickedOnce()) return; if (dimension == 1 && i == 1) { - app.DebugPrintf("Start win game\n"); + Log::info("Start win game\n"); awardStat(GenericStats::winGame(), GenericStats::param_winGame()); // All players on the same system as this player should also be removed @@ -779,7 +783,7 @@ void ServerPlayer::changeDimension(int i) { true; // We only flag this for the player in the portal connection->send(std::make_shared( GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); - app.DebugPrintf("Sending packet to %d\n", + Log::info("Sending packet to %d\n", thisPlayer->GetUserIndex()); } if (thisPlayer != nullptr) { @@ -800,12 +804,12 @@ void ServerPlayer::changeDimension(int i) { std::shared_ptr( new GameEventPacket(GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex()))); - app.DebugPrintf("Sending packet to %d\n", + Log::info("Sending packet to %d\n", thisPlayer->GetUserIndex()); } } } - app.DebugPrintf("End win game\n"); + Log::info("End win game\n"); } else { if (dimension == 0 && i == 1) { awardStat(GenericStats::theEnd(), GenericStats::param_theEnd()); @@ -920,7 +924,7 @@ bool ServerPlayer::startCrafting(int x, int y, int z) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open crafting container when one was " "already open\n"); } @@ -946,7 +950,7 @@ bool ServerPlayer::openFireworks(int x, int y, int z) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open crafting container when one was " "already open\n"); } @@ -965,7 +969,7 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open enchanting container when one was " "already open\n"); } @@ -985,7 +989,7 @@ bool ServerPlayer::startRepairing(int x, int y, int z) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open enchanting container when one was " "already open\n"); } @@ -1010,7 +1014,7 @@ bool ServerPlayer::openContainer(std::shared_ptr container) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open container when one was already open\n"); } @@ -1028,7 +1032,7 @@ bool ServerPlayer::openHopper(std::shared_ptr container) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open hopper container when one was already " "open\n"); } @@ -1047,7 +1051,7 @@ bool ServerPlayer::openHopper(std::shared_ptr container) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open minecart hopper container when one was " "already open\n"); } @@ -1066,7 +1070,7 @@ bool ServerPlayer::openFurnace(std::shared_ptr furnace) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open furnace when one was already open\n"); } @@ -1087,7 +1091,7 @@ bool ServerPlayer::openTrap(std::shared_ptr trap) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open dispenser when one was already open\n"); } @@ -1106,7 +1110,7 @@ bool ServerPlayer::openBrewingStand( containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open brewing stand when one was already " "open\n"); } @@ -1125,7 +1129,7 @@ bool ServerPlayer::openBeacon(std::shared_ptr beacon) { containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open beacon when one was already open\n"); } @@ -1162,7 +1166,7 @@ bool ServerPlayer::openTrading(std::shared_ptr traderTarget, rawOutput.toByteArray()))); } } else { - app.DebugPrintf( + Log::info( "ServerPlayer tried to open trading menu when one was already " "open\n"); } @@ -1540,7 +1544,7 @@ void ServerPlayer::displayClientMessage(int messageId) { break; default: - app.DebugPrintf( + Log::info( "Tried to send a chat packet to the player with an unhandled " "messageId\n"); assert(false); @@ -1549,7 +1553,7 @@ void ServerPlayer::displayClientMessage(int messageId) { // Language *language = Language::getInstance(); // wstring languageString = - // app.GetString(messageId);//language->getElement(messageId); + // Strings::get(messageId);//language->getElement(messageId); // connection->send( shared_ptr( new ChatPacket(L"", // messageType) ) ); } diff --git a/targets/minecraft/server/level/ServerPlayerGameMode.cpp b/targets/minecraft/server/level/ServerPlayerGameMode.cpp index 2b96a055d..551879c0d 100644 --- a/targets/minecraft/server/level/ServerPlayerGameMode.cpp +++ b/targets/minecraft/server/level/ServerPlayerGameMode.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "ServerPlayerGameMode.h" #include @@ -151,7 +152,7 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { if (t > 0 && (progress >= - 1)) //|| (app.DebugSettingsOn() && + 1)) //|| (DebugSettings::isOn() && //(player->GetDebugOptions()&(1L< @@ -440,7 +441,7 @@ void TrackedEntity::broadcast(std::shared_ptr packet) { // (packet); // if(emp!=nullptr) // { - // app.DebugPrintf("Not + // Log::info("Not // sending this SetEntityMotionPacket to player - // it's already been sent to a player on their // console\n"); @@ -597,7 +598,7 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, if (e->instanceof(eTYPE_PLAYER)) { std::shared_ptr plr = std::dynamic_pointer_cast(e); - app.DebugPrintf( + Log::info( "TrackedEntity:: Player '%ls' is now visible to player '%ls', " "%s.\n", plr->name.c_str(), sp->name.c_str(), @@ -711,7 +712,7 @@ void TrackedEntity::updatePlayers( std::shared_ptr TrackedEntity::getAddEntityPacket() { if (e->removed) { - app.DebugPrintf("Fetching addPacket for removed entity - %ls\n", + Log::info("Fetching addPacket for removed entity - %ls\n", e->getAName().c_str()); } @@ -841,7 +842,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { int ix = (int)frame->xTile; int iy = (int)frame->yTile; int iz = (int)frame->zTile; - app.DebugPrintf("eTYPE_ITEM_FRAME xyz %d,%d,%d\n", ix, iy, iz); + Log::info("eTYPE_ITEM_FRAME xyz %d,%d,%d\n", ix, iy, iz); } std::shared_ptr packet = diff --git a/targets/minecraft/server/network/PendingConnection.cpp b/targets/minecraft/server/network/PendingConnection.cpp index a7665f366..bda1a5e8f 100644 --- a/targets/minecraft/server/network/PendingConnection.cpp +++ b/targets/minecraft/server/network/PendingConnection.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "PendingConnection.h" #include @@ -66,7 +68,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) { // logger.info("Disconnecting " + getName() + ": " + reason); fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick); - app.DebugPrintf("Pending connection disconnect: %d\n", reason); + Log::info("Pending connection disconnect: %d\n", reason); connection->send(std::make_shared(reason)); connection->sendAndQuit(); done = true; @@ -77,7 +79,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) { void PendingConnection::handlePreLogin(std::shared_ptr packet) { if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) { - app.DebugPrintf("Netcode version is %d not equal to %d\n", + Log::info("Netcode version is %d not equal to %d\n", packet->m_netcodeVersion, MINECRAFT_NET_VERSION); if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION) { disconnect(DisconnectPacket::eDisconnect_OutdatedServer); @@ -137,7 +139,7 @@ void PendingConnection::sendPreLoginResponse() { connection->send(std::shared_ptr( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName, - app.GetGameHostOption(eGameHostOption_All), + GameHostOptions::get(eGameHostOption_All), hostIndex, server->m_texturePackId))); } } @@ -147,7 +149,7 @@ void PendingConnection::handleLogin(std::shared_ptr packet) { packet->clientVersion); // name = packet->userName; if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION) { - app.DebugPrintf("Client version is %d not equal to %d\n", + Log::info("Client version is %d not equal to %d\n", packet->clientVersion, SharedConstants::NETWORK_PROTOCOL_VERSION); if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION) { diff --git a/targets/minecraft/server/network/PlayerConnection.cpp b/targets/minecraft/server/network/PlayerConnection.cpp index 8cd9fe231..57bbf5846 100644 --- a/targets/minecraft/server/network/PlayerConnection.cpp +++ b/targets/minecraft/server/network/PlayerConnection.cpp @@ -1,3 +1,7 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "PlayerConnection.h" #include @@ -137,7 +141,7 @@ PlayerConnection::PlayerConnection(MinecraftServer* server, m_bHasClientTickedOnce = false; setShowOnMaps( - app.GetGameHostOption(eGameHostOption_Gamertags) != 0 ? true : false); + GameHostOptions::get(eGameHostOption_Gamertags) != 0 ? true : false); } PlayerConnection::~PlayerConnection() { delete connection; } @@ -177,7 +181,7 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason) { return; } - app.DebugPrintf("PlayerConnection disconect reason: %d\n", reason); + Log::info("PlayerConnection disconect reason: %d\n", reason); player->disconnect(); // 4J Stu - Need to remove the player from the receiving list before their @@ -380,8 +384,8 @@ void PlayerConnection::handleMovePlayer( // + ", " + player->y + ", " + player->z); #if !defined(_CONTENT_PACKAGE) wprintf(L"%ls moved wrongly!\n", player->name.c_str()); - app.DebugPrintf("Got position %f, %f, %f\n", xt, yt, zt); - app.DebugPrintf("Expected %f, %f, %f\n", player->x, player->y, + Log::info("Got position %f, %f, %f\n", xt, yt, zt); + Log::info("Expected %f, %f, %f\n", player->x, player->y, player->z); #endif } @@ -811,7 +815,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { #endif std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; - app.GetMemFileDetails(packet->textureName, &pbData, &dwBytes); + GameServices::getMemFileDetails(packet->textureName, &pbData, &dwBytes); if (dwBytes != 0) { send(std::shared_ptr( @@ -825,7 +829,7 @@ void PlayerConnection::handleTexture(std::shared_ptr packet) { wprintf(L"Server received custom texture %ls\n", packet->textureName.c_str()); #endif - app.AddMemoryTextureFile(packet->textureName, packet->pbData, + GameServices::addMemoryTextureFile(packet->textureName, packet->pbData, packet->dataBytes); server->connection->handleTextureReceived(packet->textureName); } @@ -844,9 +848,9 @@ void PlayerConnection::handleTextureAndGeometry( #endif std::uint8_t* pbData = nullptr; unsigned int dwTextureBytes = 0; - app.GetMemFileDetails(packet->textureName, &pbData, &dwTextureBytes); + GameServices::getMemFileDetails(packet->textureName, &pbData, &dwTextureBytes); DLCSkinFile* pDLCSkinFile = - app.m_dlcManager.getSkinFile(packet->textureName); + GameServices::getDLCManager().getSkinFile(packet->textureName); if (dwTextureBytes != 0) { if (pDLCSkinFile) { @@ -864,9 +868,9 @@ void PlayerConnection::handleTextureAndGeometry( // we don't have the dlc skin, so retrieve the data from the app // store std::vector* pvSkinBoxes = - app.GetAdditionalSkinBoxes(packet->dwSkinID); + GameServices::getAdditionalSkinBoxes(packet->dwSkinID); unsigned int uiAnimOverrideBitmask = - app.GetAnimOverrideBitmask(packet->dwSkinID); + GameServices::getAnimOverrideBitmask(packet->dwSkinID); send(std::shared_ptr( new TextureAndGeometryPacket(packet->textureName, pbData, @@ -882,7 +886,7 @@ void PlayerConnection::handleTextureAndGeometry( wprintf(L"Server received custom texture %ls and geometry\n", packet->textureName.c_str()); #endif - app.AddMemoryTextureFile(packet->textureName, packet->pbData, + GameServices::addMemoryTextureFile(packet->textureName, packet->pbData, packet->dwTextureBytes); // add the geometry to the app list @@ -891,11 +895,11 @@ void PlayerConnection::handleTextureAndGeometry( wprintf(L"Adding skin boxes for skin id %X, box count %d\n", packet->dwSkinID, packet->dwBoxC); #endif - app.SetAdditionalSkinBoxes(packet->dwSkinID, packet->BoxDataA, + GameServices::setAdditionalSkinBoxes(packet->dwSkinID, packet->BoxDataA, packet->dwBoxC); } // Add the anim override - app.SetAnimOverrideBitmask(packet->dwSkinID, + GameServices::setAnimOverrideBitmask(packet->dwSkinID, packet->uiAnimOverrideBitmask); player->setCustomSkin(packet->dwSkinID); @@ -913,7 +917,7 @@ void PlayerConnection::handleTextureReceived(const std::wstring& textureName) { if (it != m_texturesRequested.end()) { std::uint8_t* pbData = nullptr; unsigned int dwBytes = 0; - app.GetMemFileDetails(textureName, &pbData, &dwBytes); + GameServices::getMemFileDetails(textureName, &pbData, &dwBytes); if (dwBytes != 0) { send(std::shared_ptr( @@ -932,8 +936,8 @@ void PlayerConnection::handleTextureAndGeometryReceived( if (it != m_texturesRequested.end()) { std::uint8_t* pbData = nullptr; unsigned int dwTextureBytes = 0; - app.GetMemFileDetails(textureName, &pbData, &dwTextureBytes); - DLCSkinFile* pDLCSkinFile = app.m_dlcManager.getSkinFile(textureName); + GameServices::getMemFileDetails(textureName, &pbData, &dwTextureBytes); + DLCSkinFile* pDLCSkinFile = GameServices::getDLCManager().getSkinFile(textureName); if (dwTextureBytes != 0) { if (pDLCSkinFile && @@ -943,11 +947,11 @@ void PlayerConnection::handleTextureAndGeometryReceived( textureName, pbData, dwTextureBytes, pDLCSkinFile))); } else { // get the data from the app - std::uint32_t dwSkinID = app.getSkinIdFromPath(textureName); + std::uint32_t dwSkinID = GameServices::getSkinIdFromPath(textureName); std::vector* pvSkinBoxes = - app.GetAdditionalSkinBoxes(dwSkinID); + GameServices::getAdditionalSkinBoxes(dwSkinID); unsigned int uiAnimOverrideBitmask = - app.GetAnimOverrideBitmask(dwSkinID); + GameServices::getAnimOverrideBitmask(dwSkinID); send(std::shared_ptr( new TextureAndGeometryPacket(textureName, pbData, @@ -963,7 +967,7 @@ void PlayerConnection::handleTextureChange( std::shared_ptr packet) { switch (packet->action) { case TextureChangePacket::e_TextureChange_Skin: - player->setCustomSkin(app.getSkinIdFromPath(packet->path)); + player->setCustomSkin(GameServices::getSkinIdFromPath(packet->path)); #if !defined(_CONTENT_PACKAGE) wprintf(L"Skin for server player %ls has changed to %ls (%d)\n", player->name.c_str(), player->customTextureUrl.c_str(), @@ -981,7 +985,7 @@ void PlayerConnection::handleTextureChange( } if (!packet->path.empty() && packet->path.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(packet->path)) { + !GameServices::isFileInMemoryTextures(packet->path)) { if (server->connection->addPendingTextureRequest(packet->path)) { #if !defined(_CONTENT_PACKAGE) wprintf( @@ -993,9 +997,9 @@ void PlayerConnection::handleTextureChange( new TexturePacket(packet->path, nullptr, 0))); } } else if (!packet->path.empty() && - app.IsFileInMemoryTextures(packet->path)) { + GameServices::isFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path, nullptr, 0); + GameServices::addMemoryTextureFile(packet->path, nullptr, 0); } server->getPlayers()->broadcastAll( std::shared_ptr( @@ -1005,7 +1009,7 @@ void PlayerConnection::handleTextureChange( void PlayerConnection::handleTextureAndGeometryChange( std::shared_ptr packet) { - player->setCustomSkin(app.getSkinIdFromPath(packet->path)); + player->setCustomSkin(GameServices::getSkinIdFromPath(packet->path)); #if !defined(_CONTENT_PACKAGE) wprintf( L"PlayerConnection::handleTextureAndGeometryChange - Skin for server " @@ -1016,7 +1020,7 @@ void PlayerConnection::handleTextureAndGeometryChange( if (!packet->path.empty() && packet->path.substr(0, 3).compare(L"def") != 0 && - !app.IsFileInMemoryTextures(packet->path)) { + !GameServices::isFileInMemoryTextures(packet->path)) { if (server->connection->addPendingTextureRequest(packet->path)) { #if !defined(_CONTENT_PACKAGE) wprintf( @@ -1028,15 +1032,15 @@ void PlayerConnection::handleTextureAndGeometryChange( new TextureAndGeometryPacket(packet->path, nullptr, 0))); } } else if (!packet->path.empty() && - app.IsFileInMemoryTextures(packet->path)) { + GameServices::isFileInMemoryTextures(packet->path)) { // Update the ref count on the memory texture data - app.AddMemoryTextureFile(packet->path, nullptr, 0); + GameServices::addMemoryTextureFile(packet->path, nullptr, 0); player->setCustomSkin(packet->dwSkinID); // If we already have the texture, then we already have the model parts // too - // app.SetAdditionalSkinBoxes(packet->dwSkinID,) + // GameServices::setAdditionalSkinBoxes(packet->dwSkinID,) // DebugBreak(); } server->getPlayers()->broadcastAll( @@ -1054,46 +1058,46 @@ void PlayerConnection::handleServerSettingsChanged( INetworkPlayer* networkPlayer = getNetworkPlayer(); if ((networkPlayer != nullptr && networkPlayer->IsHost()) || player->isModerator()) { - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_FireSpreads, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_FireSpreads)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_TNT, - app.GetGameHostOption(packet->data, eGameHostOption_TNT)); - app.SetGameHostOption( + GameHostOptions::get(packet->data, eGameHostOption_TNT)); + GameHostOptions::set( eGameHostOption_MobGriefing, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_MobGriefing)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_KeepInventory, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_KeepInventory)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_DoMobSpawning, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_DoMobSpawning)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_DoMobLoot, - app.GetGameHostOption(packet->data, eGameHostOption_DoMobLoot)); - app.SetGameHostOption( + GameHostOptions::get(packet->data, eGameHostOption_DoMobLoot)); + GameHostOptions::set( eGameHostOption_DoTileDrops, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_DoTileDrops)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_DoDaylightCycle, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_DoDaylightCycle)); - app.SetGameHostOption( + GameHostOptions::set( eGameHostOption_NaturalRegeneration, - app.GetGameHostOption(packet->data, + GameHostOptions::get(packet->data, eGameHostOption_NaturalRegeneration)); server->getPlayers()->broadcastAll( std::shared_ptr( new ServerSettingsChangedPacket( ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS, - app.GetGameHostOption(eGameHostOption_All)))); + GameHostOptions::get(eGameHostOption_All)))); // Update the QoS data g_NetworkManager.UpdateAndSetGameSessionData(); @@ -1338,7 +1342,7 @@ void PlayerConnection::handleContainerAck( void PlayerConnection::handleSignUpdate( std::shared_ptr packet) { player->resetLastActionTime(); - app.DebugPrintf("PlayerConnection::handleSignUpdate\n"); + Log::info("PlayerConnection::handleSignUpdate\n"); ServerLevel* level = server->getLevel(player->dimension); if (level->hasChunkAt(packet->x, packet->y, packet->z)) { @@ -1406,9 +1410,9 @@ void PlayerConnection::handlePlayerInfo( unsigned int origPrivs = serverPlayer->getAllPlayerGamePrivileges(); bool trustPlayers = - app.GetGameHostOption(eGameHostOption_TrustPlayers) != 0; + GameHostOptions::get(eGameHostOption_TrustPlayers) != 0; bool cheats = - app.GetGameHostOption(eGameHostOption_CheatsEnabled) != 0; + GameHostOptions::get(eGameHostOption_CheatsEnabled) != 0; if (serverPlayer == player) { GameType* gameType = Player::getPlayerGamePrivilege( @@ -1605,7 +1609,7 @@ void PlayerConnection::handleCustomPayload( } else if (CustomPayloadPacket::SET_ADVENTURE_COMMAND_PACKET.compare( customPayloadPacket->identifier) == 0) { if (!server->isCommandBlockEnabled()) { - app.DebugPrintf("Command blocks not enabled"); + Log::info("Command blocks not enabled"); // player->sendMessage(ChatMessageComponent.forTranslation("advMode.notEnabled")); } else if (player->hasPermission(eGameCommand_Effect) && player->abilities.instabuild) { @@ -1688,7 +1692,7 @@ void PlayerConnection::handleCraftItem( std::shared_ptr pTempItemInst = pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr); - if (app.DebugSettingsOn() && + if (DebugSettings::isOn() && (player->GetDebugOptions() & (1L << eDebugSetting_CraftAnything))) { pTempItemInst->onCraftedBy( player->level, diff --git a/targets/minecraft/server/network/ServerConnection.cpp b/targets/minecraft/server/network/ServerConnection.cpp index 698827860..9890f39ff 100644 --- a/targets/minecraft/server/network/ServerConnection.cpp +++ b/targets/minecraft/server/network/ServerConnection.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "ServerConnection.h" #include @@ -162,7 +164,7 @@ void ServerConnection::handleServerSettingsChanged( if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) { for (unsigned int i = 0; i < pMinecraft->levels.size(); ++i) { if (pMinecraft->levels[i] != nullptr) { - app.DebugPrintf( + Log::info( "ClientConnection::handleServerSettingsChanged - " "Difficulty = %d", packet->data); @@ -174,7 +176,7 @@ void ServerConnection::handleServerSettingsChanged( // if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)// // options // { - // app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings) + // GameHostOptions::set(eGameHostOption_All,packet->m_serverSettings) // } // else // { diff --git a/targets/minecraft/stats/Stat.h b/targets/minecraft/stats/Stat.h index 94acdc79b..c4103a00d 100644 --- a/targets/minecraft/stats/Stat.h +++ b/targets/minecraft/stats/Stat.h @@ -8,6 +8,7 @@ #include #include "GenericStats.h" +#include "minecraft/GameServices.h" #include "app/linux/LinuxGame.h" #include "StatFormatter.h" @@ -62,7 +63,7 @@ public: // 4J-JEV, for Durango stats virtual void handleParamBlob(std::shared_ptr plr, std::vector& param) { - app.DebugPrintf("'Stat.h', Unhandled AwardStat blob.\n"); + GameServices::debugPrintf("'Stat.h', Unhandled AwardStat blob.\n"); return; } }; diff --git a/targets/minecraft/stats/StatsCounter.cpp b/targets/minecraft/stats/StatsCounter.cpp index db31ad09a..cc353da2e 100644 --- a/targets/minecraft/stats/StatsCounter.cpp +++ b/targets/minecraft/stats/StatsCounter.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "StatsCounter.h" #include @@ -47,7 +48,7 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, } else { val->second.stats[difficulty] += count; - if (stat != GenericStats::timePlayed()) app.DebugPrintf(""); + if (stat != GenericStats::timePlayed()) Log::info(""); // If value has wrapped, cap it to UINT_MAX if (val->second.stats[difficulty] < @@ -67,7 +68,7 @@ void StatsCounter::award(Stat* stat, unsigned int difficulty, std::unordered_map::iterator leaderboardEntry = statBoards.find(stat); if (leaderboardEntry != statBoards.end()) { - app.DebugPrintf("[StatsCounter] award(): %X\n", + Log::info("[StatsCounter] award(): %X\n", leaderboardEntry->second << difficulty); modifiedBoards |= (leaderboardEntry->second << difficulty); if (flushCounter == 0) flushCounter = FLUSH_DELAY; @@ -253,7 +254,7 @@ void StatsCounter::flushLeaderboards() { writeStats(); LeaderboardManager::Instance()->FlushStats(); } else { - app.DebugPrintf( + Log::info( "Failed to open a session in order to write to leaderboard\n"); // 4J-JEV: If user was not signed in it would hit this. @@ -269,7 +270,7 @@ void StatsCounter::saveLeaderboards() { writeStats(); LeaderboardManager::Instance()->CloseSession(); } else { - app.DebugPrintf( + Log::info( "Failed to open a session in order to write to leaderboard\n"); // 4J-JEV: If user was not signed in it would hit this. @@ -355,7 +356,7 @@ void StatsCounter::dumpStatsToTTY() { std::vector::iterator statsEnd = Stats::all->end(); for (std::vector::iterator statsIter = Stats::all->begin(); statsIter != statsEnd; ++statsIter) { - app.DebugPrintf("%ls\t\t%u\t%u\t%u\t%u\n", (*statsIter)->name.c_str(), + Log::info("%ls\t\t%u\t%u\t%u\t%u\n", (*statsIter)->name.c_str(), getValue(*statsIter, 0), getValue(*statsIter, 1), getValue(*statsIter, 2), getValue(*statsIter, 3)); } diff --git a/targets/minecraft/stdafx.h b/targets/minecraft/stdafx.h index 2d8cf8455..6f70f09be 100644 --- a/targets/minecraft/stdafx.h +++ b/targets/minecraft/stdafx.h @@ -1,11 +1 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// #pragma once - -#ifdef _WINDOWS64 -#include "app/windows/WindowsGame.h" -#else -#include "app/linux/LinuxGame.h" -#endif diff --git a/targets/minecraft/util/DebugSettings.cpp b/targets/minecraft/util/DebugSettings.cpp new file mode 100644 index 000000000..59246dd1c --- /dev/null +++ b/targets/minecraft/util/DebugSettings.cpp @@ -0,0 +1,33 @@ +#include "minecraft/util/DebugSettings.h" + +#include + +namespace DebugSettings { + +static BoolFn s_debugOn = nullptr; +static BoolFn s_artToolsOn = nullptr; +static MaskFn s_mask = nullptr; +static BoolFn s_mobsDontAttack = nullptr; +static BoolFn s_mobsDontTick = nullptr; +static BoolFn s_freezePlayers = nullptr; + +void init(BoolFn debugOn, BoolFn artToolsOn, MaskFn mask, + BoolFn mobsDontAttack, BoolFn mobsDontTick, BoolFn freezePlayers) { + s_debugOn = debugOn; + s_artToolsOn = artToolsOn; + s_mask = mask; + s_mobsDontAttack = mobsDontAttack; + s_mobsDontTick = mobsDontTick; + s_freezePlayers = freezePlayers; +} + +bool isOn() { return s_debugOn && s_debugOn(); } +bool artToolsOn() { return s_artToolsOn && s_artToolsOn(); } +unsigned int getMask(int iPad, bool overridePlayer) { + return s_mask ? s_mask(iPad, overridePlayer) : 0; +} +bool mobsDontAttack() { return s_mobsDontAttack && s_mobsDontAttack(); } +bool mobsDontTick() { return s_mobsDontTick && s_mobsDontTick(); } +bool freezePlayers() { return s_freezePlayers && s_freezePlayers(); } + +} // namespace DebugSettings diff --git a/targets/minecraft/util/DebugSettings.h b/targets/minecraft/util/DebugSettings.h new file mode 100644 index 000000000..9f5f86071 --- /dev/null +++ b/targets/minecraft/util/DebugSettings.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +namespace DebugSettings { + +using BoolFn = bool (*)(); +using MaskFn = unsigned int (*)(int, bool); + +void init(BoolFn debugOn, BoolFn artToolsOn, MaskFn mask, + BoolFn mobsDontAttack, BoolFn mobsDontTick, BoolFn freezePlayers); + +[[nodiscard]] bool isOn(); +[[nodiscard]] bool artToolsOn(); +[[nodiscard]] unsigned int getMask(int iPad = -1, bool overridePlayer = false); +[[nodiscard]] bool mobsDontAttack(); +[[nodiscard]] bool mobsDontTick(); +[[nodiscard]] bool freezePlayers(); + +} // namespace DebugSettings diff --git a/targets/minecraft/util/HtmlString.cpp b/targets/minecraft/util/HtmlString.cpp index cabed04bc..5f6f2e36c 100644 --- a/targets/minecraft/util/HtmlString.cpp +++ b/targets/minecraft/util/HtmlString.cpp @@ -4,7 +4,7 @@ #include #include -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "util/StringHelpers.h" HtmlString::HtmlString(std::wstring text, eMinecraftColour hexColor, @@ -30,7 +30,7 @@ std::wstring HtmlString::ToString() { this->color == eMinecraftColour_NOT_SET ? eHTMLColor_7 : this->color; ss << L"" << text << ""; + << GameServices::getHTMLColor(color) << L"\">" << text << ""; if (italics) { ss << ""; diff --git a/targets/minecraft/util/Log.h b/targets/minecraft/util/Log.h new file mode 100644 index 000000000..ee70d553b --- /dev/null +++ b/targets/minecraft/util/Log.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace Log { + +inline void info(const char* fmt, ...) { + va_list args; + va_start(args, fmt); + std::vfprintf(stderr, fmt, args); + va_end(args); +} + +} // namespace Log diff --git a/targets/minecraft/world/CompoundContainer.cpp b/targets/minecraft/world/CompoundContainer.cpp index f30488cf3..44291b516 100644 --- a/targets/minecraft/world/CompoundContainer.cpp +++ b/targets/minecraft/world/CompoundContainer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "CompoundContainer.h" #include "app/linux/LinuxGame.h" @@ -28,7 +29,7 @@ bool CompoundContainer::contains(std::shared_ptr c) { std::wstring CompoundContainer::getName() { if (c1->hasCustomName()) return c1->getName(); if (c2->hasCustomName()) return c2->getName(); - return app.GetString(name); + return Strings::get(name); } std::wstring CompoundContainer::getCustomName() { diff --git a/targets/minecraft/world/SimpleContainer.cpp b/targets/minecraft/world/SimpleContainer.cpp index 022bb38b4..5daf48601 100644 --- a/targets/minecraft/world/SimpleContainer.cpp +++ b/targets/minecraft/world/SimpleContainer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "SimpleContainer.h" #include @@ -81,7 +82,7 @@ void SimpleContainer::setItem(unsigned int slot, unsigned int SimpleContainer::getContainerSize() { return size; } std::wstring SimpleContainer::getName() { - return stringName.empty() ? app.GetString(name) : stringName; + return stringName.empty() ? Strings::get(name) : stringName; } std::wstring SimpleContainer::getCustomName() { diff --git a/targets/minecraft/world/effect/MobEffectInstance.cpp b/targets/minecraft/world/effect/MobEffectInstance.cpp index ad0c7f5f6..fd087cff4 100644 --- a/targets/minecraft/world/effect/MobEffectInstance.cpp +++ b/targets/minecraft/world/effect/MobEffectInstance.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "minecraft/world/effect/MobEffectInstance.h" @@ -49,7 +50,7 @@ MobEffectInstance::MobEffectInstance(MobEffectInstance* copy) { void MobEffectInstance::update(MobEffectInstance* takeOver) { if (id != takeOver->id) { - app.DebugPrintf( + Log::info( "This method should only be called for matching effects!"); } if (takeOver->amplifier > amplifier) { diff --git a/targets/minecraft/world/entity/Entity.cpp b/targets/minecraft/world/entity/Entity.cpp index 3aa5d565a..0325d5581 100644 --- a/targets/minecraft/world/entity/Entity.cpp +++ b/targets/minecraft/world/entity/Entity.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "Entity.h" #include @@ -87,7 +89,7 @@ int Entity::getSmallId() { if (removedFound) { // Has set up the entityIdRemovingFlags vector in this case, so // we should check against this when allocating new ids - // app.DebugPrintf("getSmallId: + // Log::info("getSmallId: // Removed entities found\n"); puiRemovedFlags = entityIdRemovingFlags; } @@ -105,7 +107,7 @@ int Entity::getSmallId() { // should. if (puiRemovedFlags) { if (puiRemovedFlags[i] & uiMask) { - // app.DebugPrintf("Avoiding + // Log::info("Avoiding // using ID %d (0x%x)\n", i * 32 + // j,puiRemovedFlags[i]); uiMask >>= 1; @@ -123,7 +125,7 @@ int Entity::getSmallId() { puiUsedFlags++; } - app.DebugPrintf("Out of small entity Ids... possible leak?\n"); + Log::info("Out of small entity Ids... possible leak?\n"); __debugbreak(); return -1; } @@ -1862,10 +1864,10 @@ std::wstring Entity::getNetworkName() { return getDisplayName(); } void Entity::setAnimOverrideBitmask(unsigned int uiBitmask) { m_uiAnimOverrideBitmask = uiBitmask; - app.DebugPrintf("!!! Setting anim override bitmask to %d\n", uiBitmask); + Log::info("!!! Setting anim override bitmask to %d\n", uiBitmask); } unsigned int Entity::getAnimOverrideBitmask() { - if (app.GetGameSettings(eGameSetting_CustomSkinAnim) == 0) { + if (GameServices::getGameSettings(eGameSetting_CustomSkinAnim) == 0) { // We have a force animation for some skins (claptrap) // 4J-PB - treat all the eAnim_Disable flags as a force anim unsigned int uiIgnoreUserCustomSkinAnimSettingMask = diff --git a/targets/minecraft/world/entity/EntityIO.cpp b/targets/minecraft/world/entity/EntityIO.cpp index ec60be53c..5481afe51 100644 --- a/targets/minecraft/world/entity/EntityIO.cpp +++ b/targets/minecraft/world/entity/EntityIO.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "EntityIO.h" #include @@ -330,7 +331,7 @@ std::shared_ptr EntityIO::loadStatic(CompoundTag* tag, Level* level) { entity->load(tag); } else { #ifdef _DEBUG - app.DebugPrintf("Skipping Entity with id %ls\n", + Log::info("Skipping Entity with id %ls\n", tag->getString(L"id").c_str()); #endif } diff --git a/targets/minecraft/world/entity/LivingEntity.cpp b/targets/minecraft/world/entity/LivingEntity.cpp index bdc1612ab..61b041535 100644 --- a/targets/minecraft/world/entity/LivingEntity.cpp +++ b/targets/minecraft/world/entity/LivingEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "LivingEntity.h" #include @@ -336,7 +337,7 @@ int LivingEntity::decreaseAirSupply(int currentSupply) { } } if (instanceof(eTYPE_PLAYER)) { - app.DebugPrintf("++++++++++ %s: Player decreasing air supply to %d\n", + Log::info("++++++++++ %s: Player decreasing air supply to %d\n", level->isClientSide ? "CLIENT" : "SERVER", currentSupply - 1); } diff --git a/targets/minecraft/world/entity/Painting.cpp b/targets/minecraft/world/entity/Painting.cpp index 5b3eeb6dc..886925747 100644 --- a/targets/minecraft/world/entity/Painting.cpp +++ b/targets/minecraft/world/entity/Painting.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "Painting.h" #include @@ -77,7 +78,7 @@ Painting::Painting(Level* level, int xTile, int yTile, int zTile, int dir) // needed in the ctor 4J Stu - Added motive param for debugging/artists only void Painting::PaintingPostConstructor(int dir, int motive) { #ifndef _CONTENT_PACKAGE - if (app.DebugArtToolsOn() && motive >= 0) { + if (DebugSettings::artToolsOn() && motive >= 0) { this->motive = (Motive*)Motive::values[motive]; setDir(dir); } else diff --git a/targets/minecraft/world/entity/SyncedEntityData.cpp b/targets/minecraft/world/entity/SyncedEntityData.cpp index 110ff13f6..3894f020a 100644 --- a/targets/minecraft/world/entity/SyncedEntityData.cpp +++ b/targets/minecraft/world/entity/SyncedEntityData.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "SyncedEntityData.h" #include @@ -332,7 +333,7 @@ SynchedEntityData::unpack(DataInputStream* input) // throws IOException new DataItem(itemType, itemId, Packet::readItem(input))); } break; default: - app.DebugPrintf( + Log::info( " ------ garbage data, or early end of stream due to an " "incomplete packet\n"); delete result; diff --git a/targets/minecraft/world/entity/ai/attributes/AttributeModifier.cpp b/targets/minecraft/world/entity/ai/attributes/AttributeModifier.cpp index 8850776aa..7d70fd197 100644 --- a/targets/minecraft/world/entity/ai/attributes/AttributeModifier.cpp +++ b/targets/minecraft/world/entity/ai/attributes/AttributeModifier.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "AttributeModifier.h" #include @@ -106,7 +107,7 @@ HtmlString AttributeModifier::getHoverText(eATTRIBUTE_ID attribute) { wchar_t formatted[256]; swprintf(formatted, 256, L"%ls%d%ls %ls", (amount > 0 ? L"+" : L"-"), (int)displayAmount, (percentage ? L"%" : L""), - app.GetString(Attribute::getName(attribute))); + Strings::get(Attribute::getName(attribute))); return HtmlString(formatted, color); } \ No newline at end of file diff --git a/targets/minecraft/world/entity/animal/EntityHorse.cpp b/targets/minecraft/world/entity/animal/EntityHorse.cpp index da40cc2ac..334b7f955 100644 --- a/targets/minecraft/world/entity/animal/EntityHorse.cpp +++ b/targets/minecraft/world/entity/animal/EntityHorse.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "EntityHorse.h" #include @@ -840,7 +841,7 @@ bool EntityHorse::mobInteract(std::shared_ptr player) { } doPlayerRide(player); - app.DebugPrintf( + Log::info( " Horse speed: %f\n", (float)(getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED) ->getValue())); @@ -1530,7 +1531,7 @@ double EntityHorse::generateRandomSpeed() { double speed = (0.45f + random->nextDouble() * .3 + random->nextDouble() * .3 + random->nextDouble() * .3) * 0.25f; - app.DebugPrintf(" Speed: %f\n", speed); + Log::info(" Speed: %f\n", speed); return speed; } diff --git a/targets/minecraft/world/entity/animal/Ocelot.cpp b/targets/minecraft/world/entity/animal/Ocelot.cpp index 4d5a382fb..9696a91f4 100644 --- a/targets/minecraft/world/entity/animal/Ocelot.cpp +++ b/targets/minecraft/world/entity/animal/Ocelot.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "Ocelot.h" #include @@ -306,7 +307,7 @@ MobGroupData* Ocelot::finalizeMobSpawn( groupData = TamableAnimal::finalizeMobSpawn(groupData); #ifndef _CONTENT_PACKAGE - if (app.DebugArtToolsOn() && (extraData != 0)) { + if (DebugSettings::artToolsOn() && (extraData != 0)) { setTame(true); setCatType(extraData - 1); setOwnerUUID(Minecraft::GetInstance() diff --git a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp index fca96218c..38d40462f 100644 --- a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp +++ b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "EnderDragon.h" #include @@ -258,7 +259,7 @@ void EnderDragon::aiStep() { if (getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || getSynchedAction() == e_EnderdragonAction_Sitting_Scanning || getSynchedAction() == e_EnderdragonAction_Sitting_Attacking) { - // app.DebugPrintf("flapSpeed is %f\n", flapSpeed); + // Log::info("flapSpeed is %f\n", flapSpeed); // flapTime += flapSpeed * 2; flapTime += 0.1f; } else if (inWall) { @@ -327,7 +328,7 @@ void EnderDragon::aiStep() { double yP = 0.0; double zP = 0.0; Vec3 v = getHeadLookVector(1); // getViewVector(1); - // app.DebugPrintf("View vector is (%f,%f,%f) - lsteps %d\n", v->x, + // Log::info("View vector is (%f,%f,%f) - lsteps %d\n", v->x, // v->y, v->z, lSteps); unsigned int d = 0; for(unsigned int d = 1; // d < 3; ++d) { @@ -403,7 +404,7 @@ void EnderDragon::aiStep() { if (m_flameAttacks >= SITTING_FLAME_ATTACKS_COUNT) { setSynchedAction(e_EnderdragonAction_Takeoff); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: Takeoff\n"); + Log::info("Dragon action is now: Takeoff\n"); #endif newTarget = true; } else { @@ -412,7 +413,7 @@ void EnderDragon::aiStep() { shared_from_this(), SITTING_ATTACK_VIEW_RANGE, SITTING_ATTACK_Y_VIEW_RANGE); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: SittingScanning\n"); + Log::info("Dragon action is now: SittingScanning\n"); #endif } } @@ -426,7 +427,7 @@ void EnderDragon::aiStep() { if (m_actionTicks > SITTING_SCANNING_IDLE_TICKS / 4) { setSynchedAction(e_EnderdragonAction_Sitting_Attacking); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: SittingAttacking\n"); + Log::info("Dragon action is now: SittingAttacking\n"); #endif m_actionTicks = ATTACK_TICKS; } @@ -434,7 +435,7 @@ void EnderDragon::aiStep() { if (m_actionTicks >= SITTING_SCANNING_IDLE_TICKS) { setSynchedAction(e_EnderdragonAction_Takeoff); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: Takeoff\n"); + Log::info("Dragon action is now: Takeoff\n"); #endif newTarget = true; } @@ -449,7 +450,7 @@ void EnderDragon::aiStep() { shared_from_this(), SITTING_ATTACK_VIEW_RANGE, SITTING_ATTACK_Y_VIEW_RANGE); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: SittingFlaming\n"); + Log::info("Dragon action is now: SittingFlaming\n"); #endif m_actionTicks = FLAME_TICKS; } @@ -462,7 +463,7 @@ void EnderDragon::aiStep() { if (dist > (10.0f * 10.0f)) { setSynchedAction(e_EnderdragonAction_HoldingPattern); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: HoldingPattern\n"); + Log::info("Dragon action is now: HoldingPattern\n"); #endif } } else if (newTarget || @@ -482,7 +483,7 @@ void EnderDragon::aiStep() { for (auto it = targets->begin(); it != targets->end(); ++it) { if ((*it)->instanceof(eTYPE_LIVINGENTITY)) { - // app.DebugPrintf("Attacking entity with acid\n"); + // Log::info("Attacking entity with acid\n"); std::shared_ptr e = std::dynamic_pointer_cast(*it); e->hurt(DamageSource::dragonbreath, 2); @@ -533,7 +534,7 @@ void EnderDragon::aiStep() { } } else { // setSynchedAction(e_EnderdragonAction_Sitting_Flaming); - // app.DebugPrintf("Dragon action is now : SittingFlaming\n"); + // Log::info("Dragon action is now : SittingFlaming\n"); // m_actionTicks = 0; } } else if (getSynchedAction() == @@ -707,16 +708,16 @@ void EnderDragon::aiStep() { m_acidArea = {acidX - 5, acidY - 17, acidZ - 5, acidX + 5, acidY + 4, acidZ + 5}; - // app.DebugPrintf("\nDragon is %s, yRot = %f, yRotA = %f, ss = %f, cc = + // Log::info("\nDragon is %s, yRot = %f, yRotA = %f, ss = %f, cc = // %f, ccTilt = %f\n",level->isClientSide?"client":"server", yRot, - // yRotA, ss, cc, ccTilt); app.DebugPrintf("Body (%f,%f,%f) to + // yRotA, ss, cc, ccTilt); Log::info("Body (%f,%f,%f) to // (%f,%f,%f)\n", body->bb.x0, body->bb.y0, body->bb.z0, - // body->bb.x1, body->bb.y1, body->bb.z1); app.DebugPrintf("Neck + // body->bb.x1, body->bb.y1, body->bb.z1); Log::info("Neck // (%f,%f,%f) to (%f,%f,%f)\n", neck->bb.x0, neck->bb.y0, // neck->bb.z0, neck->bb.x1, neck->bb.y1, neck->bb.z1); - // app.DebugPrintf("Head (%f,%f,%f) to (%f,%f,%f)\n", head->bb.x0, + // Log::info("Head (%f,%f,%f) to (%f,%f,%f)\n", head->bb.x0, // head->bb.y0, head->bb.z0, head->bb.x1, head->bb.y1, - // head->bb.z1); app.DebugPrintf("Acid (%f,%f,%f) to (%f,%f,%f)\n\n", + // head->bb.z1); Log::info("Acid (%f,%f,%f) to (%f,%f,%f)\n\n", // m_acidArea->x0, m_acidArea->y0, m_acidArea->z0, m_acidArea->x1, // m_acidArea->y1, m_acidArea->z1); } @@ -794,7 +795,7 @@ void EnderDragon::aiStep() { level->addEntity(ie); m_fireballCharge = 0; - app.DebugPrintf( + Log::info( "Finding new target due to having fired a fireball\n"); if (m_currentPath != nullptr) { while (!m_currentPath->isDone()) { @@ -928,12 +929,12 @@ void EnderDragon::findNewTarget() { PODIUM_X_POS, eggHeight, PODIUM_Z_POS); dist /= (8 * 8 * 8); } - // app.DebugPrintf("Adjusted dist is %f\n", dist); + // Log::info("Adjusted dist is %f\n", dist); if (random->nextInt(m_remainingCrystalsCount + 3) == 0) { setSynchedAction(e_EnderdragonAction_LandingApproach); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: LandingApproach\n"); + Log::info("Dragon action is now: LandingApproach\n"); #endif } // More likely to strafe a player if they are close to the egg, @@ -943,7 +944,7 @@ void EnderDragon::findNewTarget() { random->nextInt(m_remainingCrystalsCount + 2) == 0)) { setSynchedAction(e_EnderdragonAction_StrafePlayer); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: StrafePlayer\n"); + Log::info("Dragon action is now: StrafePlayer\n"); #endif } } @@ -954,14 +955,14 @@ void EnderDragon::findNewTarget() { (m_currentPath->isDone() && newTarget)) { setSynchedAction(e_EnderdragonAction_HoldingPattern); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: HoldingPattern\n"); + Log::info("Dragon action is now: HoldingPattern\n"); #endif } break; case e_EnderdragonAction_Landing: // setSynchedAction(e_EnderdragonAction_Sitting_Flaming); // #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - // app.DebugPrintf("Dragon action is now: + // Log::info("Dragon action is now: // SittingFlaming\n"); #endif m_actionTicks = // FLAME_TICKS; @@ -971,7 +972,7 @@ void EnderDragon::findNewTarget() { SITTING_ATTACK_VIEW_RANGE, SITTING_ATTACK_Y_VIEW_RANGE); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: SittingScanning\n"); + Log::info("Dragon action is now: SittingScanning\n"); #endif m_actionTicks = 0; break; @@ -1005,7 +1006,7 @@ void EnderDragon::findNewTarget() { Vec3 aim = Vec3(playerNearestToEgg->x, 0, playerNearestToEgg->z) .normalize(); - // app.DebugPrintf("Final marker node near (%f,%d,%f)\n", + // Log::info("Final marker node near (%f,%d,%f)\n", // -aim->x*40,105,-aim->z*40 ); targetNodeIndex = findClosestNode(-aim.x * 40, 105.0, -aim.z * 40); @@ -1029,7 +1030,7 @@ void EnderDragon::findNewTarget() { if (m_currentPath != nullptr && m_currentPath->isDone()) { setSynchedAction(e_EnderdragonAction_Landing); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: Landing\n"); + Log::info("Dragon action is now: Landing\n"); #endif } } else if (getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || @@ -1152,7 +1153,7 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, int healthBefore = getHealth(); reallyHurt(source, damage); - // if(!level->isClientSide) app.DebugPrintf("Health is now %d\n", + // if(!level->isClientSide) Log::info("Health is now %d\n", // health); if (getHealth() <= 0 && !(getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || @@ -1166,9 +1167,9 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, m_currentPath->next(); } } - app.DebugPrintf("Dragon should be dead, so landing.\n"); + Log::info("Dragon should be dead, so landing.\n"); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: LandingApproach\n"); + Log::info("Dragon action is now: LandingApproach\n"); #endif findNewTarget(); } @@ -1185,7 +1186,7 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, setSynchedAction(e_EnderdragonAction_Takeoff); newTarget = true; #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: Takeoff\n"); + Log::info("Dragon action is now: Takeoff\n"); #endif } } @@ -1431,7 +1432,7 @@ bool EnderDragon::setSynchedAction(EEnderdragonAction action, if (force || validTransition) { entityData->set(DATA_ID_SYNCHED_ACTION, action); } else { - app.DebugPrintf("EnderDragon: Invalid state transition from %d to %d\n", + Log::info("EnderDragon: Invalid state transition from %d to %d\n", getSynchedAction(), action); } @@ -1452,7 +1453,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { if (m_remainingCrystalsCount < 0) m_remainingCrystalsCount = 0; delete crystals; - app.DebugPrintf("Crystal count is now %d\n", m_remainingCrystalsCount); + Log::info("Crystal count is now %d\n", m_remainingCrystalsCount); //--m_remainingCrystalsCount; @@ -1465,7 +1466,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { } m_actionTicks = 1; #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: LandingApproach\n"); + Log::info("Dragon action is now: LandingApproach\n"); #endif } } else if (source->getEntity() != nullptr && @@ -1474,7 +1475,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { attackTarget = std::dynamic_pointer_cast(source->getEntity()); #if PRINT_DRAGON_STATE_CHANGE_MESSAGES - app.DebugPrintf("Dragon action is now: StrafePlayer\n"); + Log::info("Dragon action is now: StrafePlayer\n"); #endif strafeAttackTarget(); } @@ -1482,7 +1483,7 @@ void EnderDragon::handleCrystalDestroyed(DamageSource* source) { } void EnderDragon::strafeAttackTarget() { - app.DebugPrintf("Setting path to strafe attack target\n"); + Log::info("Setting path to strafe attack target\n"); int currentNodeIndex = findClosestNode(); int targetNodeIndex = findClosestNode(attackTarget->x, attackTarget->y, attackTarget->z); @@ -1528,9 +1529,9 @@ void EnderDragon::navigateToNextPathNode() { } while (yTarget < (curr.y)); } zTarget = curr.z; - app.DebugPrintf("Path node pos is (%f,%f,%f)\n", curr.x, curr.y, + Log::info("Path node pos is (%f,%f,%f)\n", curr.x, curr.y, curr.z); - app.DebugPrintf("Setting new target to (%f,%f,%f)\n", xTarget, yTarget, + Log::info("Setting new target to (%f,%f,%f)\n", xTarget, yTarget, zTarget); } } @@ -1575,7 +1576,7 @@ int EnderDragon::findClosestNode() { std::max((level->seaLevel + 10), level->getTopSolidBlock(nodeX, nodeZ) + yAdjustment); - app.DebugPrintf("Node %d is at (%d,%d,%d)\n", i, nodeX, nodeY, + Log::info("Node %d is at (%d,%d,%d)\n", i, nodeX, nodeY, nodeZ); (*m_nodes)[i] = new Node(nodeX, nodeY, nodeZ); @@ -1681,7 +1682,7 @@ Path* EnderDragon::findPath(int startIndex, int endIndex, Node* x = openSet->pop(); if (x->equals(to)) { - app.DebugPrintf("Found path from %d to %d\n", startIndex, endIndex); + Log::info("Found path from %d to %d\n", startIndex, endIndex); if (finalNode != nullptr) { finalNode->cameFrom = to; to = finalNode; @@ -1725,7 +1726,7 @@ Path* EnderDragon::findPath(int startIndex, int endIndex, } if (closest == from) return nullptr; - app.DebugPrintf("Failed to find path from %d to %d\n", startIndex, + Log::info("Failed to find path from %d to %d\n", startIndex, endIndex); if (finalNode != nullptr) { finalNode->cameFrom = closest; @@ -1755,7 +1756,7 @@ Path* EnderDragon::reconstruct_path(Node* from, Node* to) { } void EnderDragon::addAdditonalSaveData(CompoundTag* entityTag) { - app.DebugPrintf("Adding EnderDragon additional save data\n"); + Log::info("Adding EnderDragon additional save data\n"); entityTag->putShort(L"RemainingCrystals", m_remainingCrystalsCount); entityTag->putInt(L"DragonState", (int)getSynchedAction()); @@ -1763,7 +1764,7 @@ void EnderDragon::addAdditonalSaveData(CompoundTag* entityTag) { } void EnderDragon::readAdditionalSaveData(CompoundTag* tag) { - app.DebugPrintf("Reading EnderDragon additional save data\n"); + Log::info("Reading EnderDragon additional save data\n"); m_remainingCrystalsCount = tag->getShort(L"RemainingCrystals"); if (!tag->contains(L"RemainingCrystals")) m_remainingCrystalsCount = CRYSTAL_COUNT; @@ -1795,7 +1796,7 @@ float EnderDragon::getTilt(float a) { tilt = (latencyPosA[1] - latencyPosB[1]) * 10; } - // app.DebugPrintf("Tilt is %f\n", tilt); + // Log::info("Tilt is %f\n", tilt); return tilt; } @@ -1819,7 +1820,7 @@ double EnderDragon::getHeadYOffset(float a) { headYOffset = (p0[1] - p1[1]) * 1; } - // app.DebugPrintf("headYOffset is %f\n", headYOffset); + // Log::info("headYOffset is %f\n", headYOffset); return headYOffset; } @@ -1846,7 +1847,7 @@ double EnderDragon::getHeadPartYOffset(int partIndex, sqrt(distanceToSqr(PODIUM_X_POS, eggHeight, PODIUM_Z_POS)) / 4; if (dist < 1.0f) dist = 1.0f; result = partIndex / dist; - // app.DebugPrintf("getHeadPartYOffset - dist = %f, result = %f (%d)\n", + // Log::info("getHeadPartYOffset - dist = %f, result = %f (%d)\n", // dist, result, partIndex); } else if (getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || getSynchedAction() == e_EnderdragonAction_Sitting_Scanning || @@ -1859,7 +1860,7 @@ double EnderDragon::getHeadPartYOffset(int partIndex, result = partPos[1] - bodyPos[1]; } } - // app.DebugPrintf("Part %d is at %f\n", partIndex, result); + // Log::info("Part %d is at %f\n", partIndex, result); return result; } @@ -1877,7 +1878,7 @@ double EnderDragon::getHeadPartYRotDiff(int partIndex, { result = partPos[0] - bodyPos[0]; } - // app.DebugPrintf("Part %d is at %f\n", partIndex, result); + // Log::info("Part %d is at %f\n", partIndex, result); return result; } diff --git a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.h b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.h index 454c74c6a..5ccc23053 100644 --- a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.h +++ b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.h @@ -5,7 +5,7 @@ #include #include -#include "app/linux/LinuxGame.h" +#include "minecraft/locale/Strings.h" #include "java/Class.h" #include "minecraft/stdafx.h" #include "minecraft/world/entity/LivingEntity.h" @@ -207,7 +207,7 @@ public: std::vector& partPos); Vec3 getHeadLookVector(float a); - virtual std::wstring getAName() { return app.GetString(IDS_ENDERDRAGON); }; + virtual std::wstring getAName() { return Strings::get(IDS_ENDERDRAGON); }; virtual float getHealth() { return LivingEntity::getHealth(); }; virtual float getMaxHealth() { return LivingEntity::getMaxHealth(); }; }; diff --git a/targets/minecraft/world/entity/boss/wither/WitherBoss.h b/targets/minecraft/world/entity/boss/wither/WitherBoss.h index 58ae44577..3603ceef4 100644 --- a/targets/minecraft/world/entity/boss/wither/WitherBoss.h +++ b/targets/minecraft/world/entity/boss/wither/WitherBoss.h @@ -3,7 +3,7 @@ #include #include -#include "app/linux/LinuxGame.h" +#include "minecraft/locale/Strings.h" #include "java/Class.h" #include "minecraft/stdafx.h" #include "minecraft/world/entity/EntitySelector.h" @@ -120,5 +120,5 @@ public: // 4J Stu - These are required for the BossMob interface virtual float getMaxHealth() { return Monster::getMaxHealth(); }; virtual float getHealth() { return Monster::getHealth(); }; - virtual std::wstring getAName() { return app.GetString(IDS_WITHER); }; + virtual std::wstring getAName() { return Strings::get(IDS_WITHER); }; }; \ No newline at end of file diff --git a/targets/minecraft/world/entity/item/ItemEntity.cpp b/targets/minecraft/world/entity/item/ItemEntity.cpp index 062bc1247..b0983522c 100644 --- a/targets/minecraft/world/entity/item/ItemEntity.cpp +++ b/targets/minecraft/world/entity/item/ItemEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ItemEntity.h" #include @@ -280,7 +281,7 @@ std::shared_ptr ItemEntity::getItem() { if (result == nullptr) { if (level != nullptr) { - app.DebugPrintf("Item entity %d has no item?!\n", entityId); + Log::info("Item entity %d has no item?!\n", entityId); // level.getLogger().severe("Item entity " + entityId + " has no // item?!"); } diff --git a/targets/minecraft/world/entity/item/MinecartContainer.cpp b/targets/minecraft/world/entity/item/MinecartContainer.cpp index 728e20e8f..2ea706a43 100644 --- a/targets/minecraft/world/entity/item/MinecartContainer.cpp +++ b/targets/minecraft/world/entity/item/MinecartContainer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "MinecartContainer.h" #include @@ -119,7 +120,7 @@ bool MinecartContainer::canPlaceItem(int slot, std::wstring MinecartContainer::getName() { return hasCustomName() ? getCustomName() - : app.GetString(IDS_CONTAINER_MINECART); + : Strings::get(IDS_CONTAINER_MINECART); } int MinecartContainer::getMaxStackSize() { diff --git a/targets/minecraft/world/entity/monster/EnderMan.cpp b/targets/minecraft/world/entity/monster/EnderMan.cpp index b44f8fda6..82924b9a1 100644 --- a/targets/minecraft/world/entity/monster/EnderMan.cpp +++ b/targets/minecraft/world/entity/monster/EnderMan.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "EnderMan.h" #include @@ -106,7 +107,7 @@ void EnderMan::readAdditionalSaveData(CompoundTag* tag) { std::shared_ptr EnderMan::findAttackTarget() { #ifndef _FINAL_BUILD - if (app.GetMobsDontAttackEnabled()) { + if (DebugSettings::mobsDontAttack()) { return std::shared_ptr(); } #endif diff --git a/targets/minecraft/world/entity/monster/Monster.cpp b/targets/minecraft/world/entity/monster/Monster.cpp index 8a3efd90d..fd68cc0bf 100644 --- a/targets/minecraft/world/entity/monster/Monster.cpp +++ b/targets/minecraft/world/entity/monster/Monster.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "Monster.h" #include @@ -48,7 +49,7 @@ void Monster::tick() { std::shared_ptr Monster::findAttackTarget() { #ifndef _FINAL_BUILD - if (app.GetMobsDontAttackEnabled()) { + if (DebugSettings::mobsDontAttack()) { return std::shared_ptr(); } #endif diff --git a/targets/minecraft/world/entity/monster/PigZombie.cpp b/targets/minecraft/world/entity/monster/PigZombie.cpp index 1c7a7544b..5cec18648 100644 --- a/targets/minecraft/world/entity/monster/PigZombie.cpp +++ b/targets/minecraft/world/entity/monster/PigZombie.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "PigZombie.h" #include @@ -93,7 +94,7 @@ void PigZombie::readAdditionalSaveData(CompoundTag* tag) { std::shared_ptr PigZombie::findAttackTarget() { #ifndef _FINAL_BUILD #ifdef _DEBUG_MENUS_ENABLED - if (app.GetMobsDontAttackEnabled()) { + if (DebugSettings::mobsDontAttack()) { return std::shared_ptr(); } #endif diff --git a/targets/minecraft/world/entity/monster/SharedMonsterAttributes.cpp b/targets/minecraft/world/entity/monster/SharedMonsterAttributes.cpp index a3c3e8b1d..14eedd839 100644 --- a/targets/minecraft/world/entity/monster/SharedMonsterAttributes.cpp +++ b/targets/minecraft/world/entity/monster/SharedMonsterAttributes.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "SharedMonsterAttributes.h" #include @@ -93,7 +94,7 @@ void SharedMonsterAttributes::loadAttributes(BaseAttributeMap* attributes, if (instance != nullptr) { loadAttribute(instance, tag); } else { - app.DebugPrintf("Ignoring unknown attribute '%d'", + Log::info("Ignoring unknown attribute '%d'", tag->getInt(L"ID")); } } diff --git a/targets/minecraft/world/entity/monster/Silverfish.cpp b/targets/minecraft/world/entity/monster/Silverfish.cpp index f44581675..316d554c6 100644 --- a/targets/minecraft/world/entity/monster/Silverfish.cpp +++ b/targets/minecraft/world/entity/monster/Silverfish.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "Silverfish.h" #include @@ -43,7 +44,7 @@ bool Silverfish::makeStepSound() { return false; } std::shared_ptr Silverfish::findAttackTarget() { #ifndef _FINAL_BUILD - if (app.GetMobsDontAttackEnabled()) { + if (DebugSettings::mobsDontAttack()) { return std::shared_ptr(); } #endif diff --git a/targets/minecraft/world/entity/monster/Spider.cpp b/targets/minecraft/world/entity/monster/Spider.cpp index 31f1fb95d..576b4ba79 100644 --- a/targets/minecraft/world/entity/monster/Spider.cpp +++ b/targets/minecraft/world/entity/monster/Spider.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "Spider.h" #include @@ -60,7 +61,7 @@ void Spider::registerAttributes() { std::shared_ptr Spider::findAttackTarget() { #ifndef _FINAL_BUILD #ifdef _DEBUG_MENUS_ENABLED - if (app.GetMobsDontAttackEnabled()) { + if (DebugSettings::mobsDontAttack()) { return std::shared_ptr(); } #endif diff --git a/targets/minecraft/world/entity/npc/Villager.cpp b/targets/minecraft/world/entity/npc/Villager.cpp index 07502eb47..5a5728ab1 100644 --- a/targets/minecraft/world/entity/npc/Villager.cpp +++ b/targets/minecraft/world/entity/npc/Villager.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "Villager.h" #include @@ -796,5 +797,5 @@ std::wstring Villager::getDisplayName() { name = IDS_VILLAGER_BUTCHER; break; }; - return app.GetString(name); + return Strings::get(name); } diff --git a/targets/minecraft/world/entity/player/Inventory.cpp b/targets/minecraft/world/entity/player/Inventory.cpp index efc5dfe3e..ce40e3948 100644 --- a/targets/minecraft/world/entity/player/Inventory.cpp +++ b/targets/minecraft/world/entity/player/Inventory.cpp @@ -1,3 +1,5 @@ +#include "minecraft/locale/Strings.h" +#include "minecraft/util/Log.h" #include "Inventory.h" #include @@ -391,14 +393,14 @@ void Inventory::setItem(unsigned int slot, std::shared_ptr item) { #ifdef _DEBUG if (item != nullptr) { std::wstring itemstring = item->toString(); - app.DebugPrintf("Inventory::setItem - slot = %d,\t item = %d ", slot, + Log::info("Inventory::setItem - slot = %d,\t item = %d ", slot, item->id); // OutputDebugStringW(itemstring.c_str()); - app.DebugPrintf("\n"); + Log::info("\n"); } #else if (item != nullptr) { - app.DebugPrintf( + Log::info( "Inventory::setItem - slot = %d,\t item = %d, aux = %d\n", slot, item->id, item->getAuxValue()); } @@ -488,7 +490,7 @@ std::shared_ptr Inventory::getItem(unsigned int slot) { */ } -std::wstring Inventory::getName() { return app.GetString(IDS_INVENTORY); } +std::wstring Inventory::getName() { return Strings::get(IDS_INVENTORY); } std::wstring Inventory::getCustomName() { return L""; } diff --git a/targets/minecraft/world/entity/player/Player.cpp b/targets/minecraft/world/entity/player/Player.cpp index ea5f71bb8..07d784b58 100644 --- a/targets/minecraft/world/entity/player/Player.cpp +++ b/targets/minecraft/world/entity/player/Player.cpp @@ -1,3 +1,6 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" // 4J TODO // All the instanceof s from Java have been converted to dynamic_cast in this @@ -182,7 +185,7 @@ Player::Player(Level* level, const std::wstring& name) : LivingEntity(level) { m_OnlineXuid = INVALID_XUID; // m_bShownOnMaps = true; setShowOnMaps( - app.GetGameHostOption(eGameHostOption_Gamertags) != 0 ? true : false); + GameHostOptions::get(eGameHostOption_Gamertags) != 0 ? true : false); m_bIsGuest = false; // 4J: Set UUID to name on none-XB1 consoles, may change in future but for @@ -569,34 +572,34 @@ void Player::setCustomSkin(std::uint32_t skinId) { setPlayerDefaultSkin(playerSkin); m_dwSkinId = skinId; - this->customTextureUrl = app.getSkinPathFromId(skinId); + this->customTextureUrl = GameServices::getSkinPathFromId(skinId); // set the new player additional boxes - /*vector *pvModelParts=app.GetAdditionalModelParts(m_dwSkinId); + /*vector *pvModelParts=GameServices::getAdditionalModelParts(m_dwSkinId); if(pvModelParts==nullptr) { // we don't have the data from the dlc skin yet - app.DebugPrintf("Couldn't get model parts for skin %X\n",m_dwSkinId); + Log::info("Couldn't get model parts for skin %X\n",m_dwSkinId); // do we have it from the DLC pack? DLCSkinFile *pDLCSkinFile = - app.m_dlcManager.getSkinFile(this->customTextureUrl); + GameServices::getDLCManager().getSkinFile(this->customTextureUrl); if(pDLCSkinFile!=nullptr) { const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); if(additionalBoxCount != 0) { - app.DebugPrintf("Got model parts from DLCskin for skin %X\n",m_dwSkinId); - pvModelParts=app.SetAdditionalSkinBoxes(m_dwSkinId,pDLCSkinFile->getAdditionalBoxes()); + Log::info("Got model parts from DLCskin for skin %X\n",m_dwSkinId); + pvModelParts=GameServices::setAdditionalSkinBoxesFromVec(m_dwSkinId,pDLCSkinFile->getAdditionalBoxes()); this->SetAdditionalModelParts(pvModelParts); } else { this->SetAdditionalModelParts(nullptr); } - app.SetAnimOverrideBitmask(pDLCSkinFile->getSkinID(),pDLCSkinFile->getAnimOverrideBitmask()); + GameServices::setAnimOverrideBitmask(pDLCSkinFile->getSkinID(),pDLCSkinFile->getAnimOverrideBitmask()); } else { @@ -605,7 +608,7 @@ void Player::setCustomSkin(std::uint32_t skinId) { } else { - app.DebugPrintf("Got model parts from app.GetAdditionalModelParts for skin + Log::info("Got model parts from app.GetAdditionalModelParts for skin %X\n",m_dwSkinId); this->SetAdditionalModelParts(pvModelParts); @@ -650,7 +653,7 @@ unsigned int Player::getSkinAnimOverrideBitmask(std::uint32_t skinId) { default: // This is not one of the prefined skins // Does the app have an anim override for this skin? - bitmask = app.GetAnimOverrideBitmask(skinId); + bitmask = GameServices::getAnimOverrideBitmask(skinId); break; } } @@ -670,13 +673,13 @@ void Player::setCustomCape(std::uint32_t capeId) { if (capeId > 0) { this->customTextureUrl2 = Player::getCapePathFromId(capeId); } else { - MOJANG_DATA* pMojangData = app.GetMojangDataForXuid(getOnlineXuid()); + MOJANG_DATA* pMojangData = GameServices::getMojangDataForXuid(getOnlineXuid()); if (pMojangData) { // Cape if (pMojangData->wchCape[0] != 0) { this->customTextureUrl2 = pMojangData->wchCape; } else { - if (app.DefaultCapeExists()) { + if (GameServices::defaultCapeExists()) { this->customTextureUrl2 = std::wstring(L"Special_Cape.png"); } else { this->customTextureUrl2 = std::wstring(L""); @@ -685,7 +688,7 @@ void Player::setCustomCape(std::uint32_t capeId) { } else { // if there is a custom default cloak, then set it here - if (app.DefaultCapeExists()) { + if (GameServices::defaultCapeExists()) { this->customTextureUrl2 = std::wstring(L"Special_Cape.png"); } else { this->customTextureUrl2 = std::wstring(L""); @@ -744,23 +747,23 @@ std::wstring Player::getCapePathFromId(std::uint32_t capeId) { } void Player::ChangePlayerSkin() { - if (app.vSkinNames.size() > 0) { + if (GameServices::getSkinNames().size() > 0) { m_uiPlayerCurrentSkin++; - if (m_uiPlayerCurrentSkin > app.vSkinNames.size()) { + if (m_uiPlayerCurrentSkin > GameServices::getSkinNames().size()) { m_uiPlayerCurrentSkin = 0; this->customTextureUrl = L""; } else { if (m_uiPlayerCurrentSkin > 0) { // change this players custom texture url this->customTextureUrl = - app.vSkinNames[m_uiPlayerCurrentSkin - 1]; + GameServices::getSkinNames()[m_uiPlayerCurrentSkin - 1]; } } } } void Player::prepareCustomTextures() { - MOJANG_DATA* pMojangData = app.GetMojangDataForXuid(getOnlineXuid()); + MOJANG_DATA* pMojangData = GameServices::getMojangDataForXuid(getOnlineXuid()); if (pMojangData) { // Skin @@ -776,7 +779,7 @@ void Player::prepareCustomTextures() { //} // else //{ - // if(app.DefaultCapeExists()) + // if(GameServices::defaultCapeExists()) // { // this->customTextureUrl2= wstring(L"Default_Cape.png"); // } @@ -789,7 +792,7 @@ void Player::prepareCustomTextures() { } else { // 4J Stu - Don't update the cape here, it gets set elsewhere // if there is a custom default cloak, then set it here - // if(app.DefaultCapeExists()) + // if(GameServices::defaultCapeExists()) //{ // this->customTextureUrl2= wstring(L"Default_Cape.png"); //} @@ -933,7 +936,7 @@ void Player::die(DamageSource* source) { yd = 0.1f; // 4J - TODO need to use a xuid - if (app.isXuidNotch(m_xuid)) { + if (GameServices::isXuidNotch(m_xuid)) { drop(std::make_shared(Item::apple, 1), true); } if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) { @@ -2081,7 +2084,7 @@ void Player::causeFoodExhaustion(float amount) { // 4J Stu - Added 1.8.2 bug fix (TU6) - If players cannot eat, then their // food bar should not decrease due to exhaustion - if (app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0 && + if (GameHostOptions::get(eGameHostOption_TrustPlayers) == 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) return; @@ -2387,7 +2390,7 @@ void Player::setPlayerGamePrivilege(unsigned int& uiGamePrivileges, bool Player::isAllowedToUse(Tile* tile) { bool allowed = true; if (tile != nullptr && - app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { + GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) { allowed = false; if (getPlayerGamePrivilege( @@ -2458,7 +2461,7 @@ bool Player::isAllowedToUse(Tile* tile) { bool Player::isAllowedToUse(std::shared_ptr item) { bool allowed = true; if (item != nullptr && - app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { + GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) { if (getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotBuild) != 0) { allowed = false; @@ -2502,7 +2505,7 @@ bool Player::isAllowedToUse(std::shared_ptr item) { bool Player::isAllowedToInteract(std::shared_ptr target) { bool allowed = true; - if (app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { + if (GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) { if (target->instanceof(eTYPE_MINECART)) { if (getPlayerGamePrivilege( Player::ePlayerGamePrivilege_CanUseContainers) == 0) { @@ -2530,7 +2533,7 @@ bool Player::isAllowedToInteract(std::shared_ptr target) { bool Player::isAllowedToMine() { bool allowed = true; - if (app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) { + if (GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) { if (getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CannotMine) != 0) { allowed = false; @@ -2542,7 +2545,7 @@ bool Player::isAllowedToMine() { bool Player::isAllowedToAttackPlayers() { bool allowed = true; if (hasInvisiblePrivilege() || - ((app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) && + ((GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) && getPlayerGamePrivilege( Player::ePlayerGamePrivilege_CannotAttackPlayers))) { allowed = false; @@ -2552,7 +2555,7 @@ bool Player::isAllowedToAttackPlayers() { bool Player::isAllowedToAttackAnimals() { bool allowed = true; - if ((app.GetGameHostOption(eGameHostOption_TrustPlayers) == 0) && + if ((GameHostOptions::get(eGameHostOption_TrustPlayers) == 0) && getPlayerGamePrivilege( Player::ePlayerGamePrivilege_CannotAttackAnimals)) { allowed = false; @@ -2586,7 +2589,7 @@ bool Player::isAllowedToHurtEntity(std::shared_ptr target) { bool Player::isAllowedToFly() { bool allowed = false; - if (app.GetGameHostOption(eGameHostOption_HostCanFly) != 0 && + if (GameHostOptions::get(eGameHostOption_HostCanFly) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_CanFly) != 0) { allowed = true; } @@ -2595,7 +2598,7 @@ bool Player::isAllowedToFly() { bool Player::isAllowedToIgnoreExhaustion() { bool allowed = false; - if ((app.GetGameHostOption(eGameHostOption_HostCanChangeHunger) != 0 && + if ((GameHostOptions::get(eGameHostOption_HostCanChangeHunger) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_ClassicHunger) != 0) || (isAllowedToFly() && abilities.flying)) { @@ -2615,7 +2618,7 @@ bool Player::isAllowedToTeleport() { bool Player::hasInvisiblePrivilege() { bool enabled = false; - if (app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) != 0 && + if (GameHostOptions::get(eGameHostOption_HostCanBeInvisible) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_Invisible) != 0) { enabled = true; } @@ -2624,7 +2627,7 @@ bool Player::hasInvisiblePrivilege() { bool Player::hasInvulnerablePrivilege() { bool enabled = false; - if (app.GetGameHostOption(eGameHostOption_HostCanBeInvisible) != 0 && + if (GameHostOptions::get(eGameHostOption_HostCanBeInvisible) != 0 && getPlayerGamePrivilege(Player::ePlayerGamePrivilege_Invulnerable) != 0) { enabled = true; @@ -2671,14 +2674,14 @@ std::vector* Player::GetAdditionalModelParts() { customTextureUrl.substr(0, 3).compare(L"def") == 0; // see if we can find the parts - m_ppAdditionalModelParts = app.GetAdditionalModelParts(m_dwSkinId); + m_ppAdditionalModelParts = GameServices::getAdditionalModelParts(m_dwSkinId); // If it's a default texture (which has no parts), we have the parts, or // we already have the texture (in which case we should have parts if // there are any) then we are done if (!hasCustomTexture || customTextureIsDefaultSkin || m_ppAdditionalModelParts != nullptr || - app.IsFileInMemoryTextures(customTextureUrl)) { + GameServices::isFileInMemoryTextures(customTextureUrl)) { m_bCheckedForModelParts = true; } if (m_ppAdditionalModelParts == nullptr && @@ -2686,28 +2689,28 @@ std::vector* Player::GetAdditionalModelParts() { m_bCheckedDLCForModelParts = true; // we don't have the data from the dlc skin yet - app.DebugPrintf( + Log::info( "m_bCheckedForModelParts Couldn't get model parts for skin " "%X\n", m_dwSkinId); // do we have it from the DLC pack? DLCSkinFile* pDLCSkinFile = - app.m_dlcManager.getSkinFile(this->customTextureUrl); + GameServices::getDLCManager().getSkinFile(this->customTextureUrl); if (pDLCSkinFile != nullptr) { const int additionalBoxCount = pDLCSkinFile->getAdditionalBoxesCount(); if (additionalBoxCount != 0) { - app.DebugPrintf( + Log::info( "m_bCheckedForModelParts Got model parts from DLCskin " "for skin %X\n", m_dwSkinId); - m_ppAdditionalModelParts = app.SetAdditionalSkinBoxes( + m_ppAdditionalModelParts = GameServices::setAdditionalSkinBoxesFromVec( m_dwSkinId, pDLCSkinFile->getAdditionalBoxes()); } - app.SetAnimOverrideBitmask( + GameServices::setAnimOverrideBitmask( pDLCSkinFile->getSkinID(), pDLCSkinFile->getAnimOverrideBitmask()); diff --git a/targets/minecraft/world/entity/projectile/Arrow.cpp b/targets/minecraft/world/entity/projectile/Arrow.cpp index a2f4cd331..29e72035c 100644 --- a/targets/minecraft/world/entity/projectile/Arrow.cpp +++ b/targets/minecraft/world/entity/projectile/Arrow.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Arrow.h" #include @@ -182,7 +183,7 @@ void Arrow::lerpMotion(double xd, double yd, double zd) { xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); xRotO = xRot; yRotO = yRot; - app.DebugPrintf("%f %f : 0x%x\n", xRot, yRot, &yRot); + Log::info("%f %f : 0x%x\n", xRot, yRot, &yRot); moveTo(x, y, z, yRot, xRot); life = 0; } diff --git a/targets/minecraft/world/entity/projectile/Fireball.cpp b/targets/minecraft/world/entity/projectile/Fireball.cpp index bab78c6f4..05a6b9eb2 100644 --- a/targets/minecraft/world/entity/projectile/Fireball.cpp +++ b/targets/minecraft/world/entity/projectile/Fireball.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Fireball.h" #include @@ -133,7 +134,7 @@ void Fireball::tick() { if (!level->isClientSide) { if ((owner != nullptr && owner->removed) || !level->hasChunkAt((int)x, (int)y, (int)z)) { - app.DebugPrintf( + Log::info( "Fireball removed - owner is null or removed is true for " "owner\n"); remove(); @@ -146,7 +147,7 @@ void Fireball::tick() { if ((x <= minXZ) || (x >= maxXZ) || (z <= minXZ) || (z >= maxXZ)) { remove(); - app.DebugPrintf("Fireball removed - end of world\n"); + Log::info("Fireball removed - end of world\n"); return; } } @@ -154,7 +155,7 @@ void Fireball::tick() { Entity::tick(); - // app.DebugPrintf("Fireball x %d, y %d, z%d\n",(int)x,(int)y,(int)z); + // Log::info("Fireball x %d, y %d, z%d\n",(int)x,(int)y,(int)z); if (shouldBurn()) setOnFire(1); @@ -164,7 +165,7 @@ void Fireball::tick() { life++; if (life == SharedConstants::TICKS_PER_SECOND * 30) { remove(); - app.DebugPrintf("Fireball removed - life is 20*60\n"); + Log::info("Fireball removed - life is 20*60\n"); } return; } else { @@ -264,7 +265,7 @@ void Fireball::tick() { xd = 0.0; zd = 0.0; yd = 0.0; - app.DebugPrintf("Removing a fireball with zero velocity\n"); + Log::info("Removing a fireball with zero velocity\n"); remove(); } } diff --git a/targets/minecraft/world/inventory/AnvilMenu.cpp b/targets/minecraft/world/inventory/AnvilMenu.cpp index 4032dcfb7..5e9fae9de 100644 --- a/targets/minecraft/world/inventory/AnvilMenu.cpp +++ b/targets/minecraft/world/inventory/AnvilMenu.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "AnvilMenu.h" #include @@ -72,7 +73,7 @@ void AnvilMenu::createResult() { int tax = 0; int namingCost = 0; - if (DEBUG_COST) app.DebugPrintf("----"); + if (DEBUG_COST) Log::info("----"); if (input == nullptr) { resultSlots->setItem(0, nullptr); @@ -89,7 +90,7 @@ void AnvilMenu::createResult() { tax += input->getBaseRepairCost() + (addition == nullptr ? 0 : addition->getBaseRepairCost()); if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Starting with base repair tax of %d (%d + %d)\n", tax, input->getBaseRepairCost(), (addition == nullptr ? 0 : addition->getBaseRepairCost())); @@ -146,7 +147,7 @@ void AnvilMenu::createResult() { result->setAuxValue(resultDamage); price += std::max(1, additional / 100); if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Repairing; price is now %d (went up by %d)\n", price, std::max(1, additional / 100)); } @@ -183,7 +184,7 @@ void AnvilMenu::createResult() { price += extra; if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Enchantment incompatibility fee; price is " "now %d (went up by %d)\n", price, extra); @@ -216,7 +217,7 @@ void AnvilMenu::createResult() { price += fee * extra; if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Enchantment increase fee; price is now %d (went " "up by %d)\n", price, fee * extra); @@ -232,7 +233,7 @@ void AnvilMenu::createResult() { price += namingCost; if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Un-naming cost; price is now %d (went up by %d)", price, namingCost); } @@ -245,7 +246,7 @@ void AnvilMenu::createResult() { price += namingCost; if (DEBUG_COST) { - app.DebugPrintf("Naming cost; price is now %d (went up by %d)", + Log::info("Naming cost; price is now %d (went up by %d)", price, namingCost); } @@ -253,7 +254,7 @@ void AnvilMenu::createResult() { tax += namingCost / 2; if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Already-named tax; tax is now %d (went up by %d)", tax, (namingCost / 2)); } @@ -290,7 +291,7 @@ void AnvilMenu::createResult() { tax += count + level * fee; if (DEBUG_COST) { - app.DebugPrintf( + Log::info( "Enchantment tax; tax is now %d (went up by %d)", tax, (count + level * fee)); } @@ -300,18 +301,18 @@ void AnvilMenu::createResult() { cost = tax + price; if (price <= 0) { - if (DEBUG_COST) app.DebugPrintf("No purchase, only tax; aborting"); + if (DEBUG_COST) Log::info("No purchase, only tax; aborting"); result = nullptr; } if (namingCost == price && namingCost > 0 && cost >= 40) { - if (DEBUG_COST) app.DebugPrintf("Cost is too high; aborting"); - app.DebugPrintf( + if (DEBUG_COST) Log::info("Cost is too high; aborting"); + Log::info( "Naming an item only, cost too high; giving discount to cap " "cost to 39 levels"); cost = 39; } if (cost >= 40 && !player->abilities.instabuild) { - if (DEBUG_COST) app.DebugPrintf("Cost is too high; aborting"); + if (DEBUG_COST) Log::info("Cost is too high; aborting"); result = nullptr; } @@ -334,10 +335,10 @@ void AnvilMenu::createResult() { if (DEBUG_COST) { if (level->isClientSide) { - app.DebugPrintf("CLIENT Cost is %d (%d price, %d tax)\n", cost, + Log::info("CLIENT Cost is %d (%d price, %d tax)\n", cost, price, tax); } else { - app.DebugPrintf("SERVER Cost is %d (%d price, %d tax)\n", cost, + Log::info("SERVER Cost is %d (%d price, %d tax)\n", cost, price, tax); } } diff --git a/targets/minecraft/world/item/BucketItem.cpp b/targets/minecraft/world/item/BucketItem.cpp index 412af3e40..7a953f5f4 100644 --- a/targets/minecraft/world/item/BucketItem.cpp +++ b/targets/minecraft/world/item/BucketItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "BucketItem.h" #include @@ -112,11 +113,11 @@ std::shared_ptr BucketItem::use( int zt = hr->z; if (!level->mayInteract(player, xt, yt, zt, content)) { - app.DebugPrintf("!!!!!!!!!!! Can't place that here\n"); + Log::info("!!!!!!!!!!! Can't place that here\n"); std::shared_ptr servPlayer = std::dynamic_pointer_cast(player); if (servPlayer != nullptr) { - app.DebugPrintf( + Log::info( "Sending ChatPacket::e_ChatCannotPlaceLava to player\n"); servPlayer->connection->send(std::shared_ptr( new ChatPacket(L"", ChatPacket::e_ChatCannotPlaceLava))); diff --git a/targets/minecraft/world/item/EnderEyeItem.cpp b/targets/minecraft/world/item/EnderEyeItem.cpp index 185fa0a57..66098b4f7 100644 --- a/targets/minecraft/world/item/EnderEyeItem.cpp +++ b/targets/minecraft/world/item/EnderEyeItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "EnderEyeItem.h" #include @@ -165,7 +166,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, // level->getLevelData()->setZStronghold(z); // level->getLevelData()->setHasStronghold(); // - // app.DebugPrintf("=== FOUND stronghold in + // Log::info("=== FOUND stronghold in // terrain features list\n"); // // app.SetXuiServerAction(PlatformInput.GetPrimaryPad(),eXuiServerAction_StrongholdPosition); @@ -174,7 +175,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, { // can't find the stronghold position in the terrain feature // list. Do we have to run a post-process? - app.DebugPrintf( + Log::info( "=== Can't find stronghold in terrain features list\n"); } } diff --git a/targets/minecraft/world/item/FireworksChargeItem.cpp b/targets/minecraft/world/item/FireworksChargeItem.cpp index 87c8ff857..107cc7291 100644 --- a/targets/minecraft/world/item/FireworksChargeItem.cpp +++ b/targets/minecraft/world/item/FireworksChargeItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "FireworksChargeItem.h" #include @@ -99,9 +100,9 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, uint8_t type = expTag->getByte(FireworksItem::TAG_E_TYPE); if (type >= FireworksItem::TYPE_MIN && type <= FireworksItem::TYPE_MAX) { lines->push_back( - HtmlString(app.GetString(FIREWORKS_CHARGE_TYPE_NAME[type]))); + HtmlString(Strings::get(FIREWORKS_CHARGE_TYPE_NAME[type]))); } else { - lines->push_back(HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_TYPE))); + lines->push_back(HtmlString(Strings::get(IDS_FIREWORKS_CHARGE_TYPE))); } // colors @@ -124,12 +125,12 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, for (int dc = 0; dc < 16; dc++) { if (c == DyePowderItem::COLOR_RGB[dc]) { found = true; - output += app.GetString(FIREWORKS_CHARGE_COLOUR_NAME[dc]); + output += Strings::get(FIREWORKS_CHARGE_COLOUR_NAME[dc]); break; } } if (!found) { - output += app.GetString(IDS_FIREWORKS_CHARGE_CUSTOM); + output += Strings::get(IDS_FIREWORKS_CHARGE_CUSTOM); } } lines->push_back(output); @@ -141,7 +142,7 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, if (fadeList.size() > 0) { bool first = true; std::wstring output = - std::wstring(app.GetString(IDS_FIREWORKS_CHARGE_FADE_TO)) + L" "; + std::wstring(Strings::get(IDS_FIREWORKS_CHARGE_FADE_TO)) + L" "; for (unsigned int i = 0; i < fadeList.size(); ++i) { int c = fadeList[i]; if (!first) { @@ -156,12 +157,12 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, for (int dc = 0; dc < 16; dc++) { if (c == DyePowderItem::COLOR_RGB[dc]) { found = true; - output += app.GetString(FIREWORKS_CHARGE_COLOUR_NAME[dc]); + output += Strings::get(FIREWORKS_CHARGE_COLOUR_NAME[dc]); break; } } if (!found) { - output += app.GetString(IDS_FIREWORKS_CHARGE_CUSTOM); + output += Strings::get(IDS_FIREWORKS_CHARGE_CUSTOM); } } lines->push_back(output); @@ -170,14 +171,14 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, // has trail bool trail = expTag->getBoolean(FireworksItem::TAG_E_TRAIL); if (trail) { - lines->push_back(HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_TRAIL))); + lines->push_back(HtmlString(Strings::get(IDS_FIREWORKS_CHARGE_TRAIL))); } // has flicker bool flicker = expTag->getBoolean(FireworksItem::TAG_E_FLICKER); if (flicker) { lines->push_back( - HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_FLICKER))); + HtmlString(Strings::get(IDS_FIREWORKS_CHARGE_FLICKER))); } } diff --git a/targets/minecraft/world/item/FireworksItem.cpp b/targets/minecraft/world/item/FireworksItem.cpp index 1fccc3fba..81fa87b89 100644 --- a/targets/minecraft/world/item/FireworksItem.cpp +++ b/targets/minecraft/world/item/FireworksItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "FireworksItem.h" #include @@ -65,7 +66,7 @@ void FireworksItem::appendHoverText(std::shared_ptr itemInstance, } if (fireTag->contains(TAG_FLIGHT)) { lines->push_back( - std::wstring(app.GetString(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " + + std::wstring(Strings::get(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " + toWString((fireTag->getByte(TAG_FLIGHT)))); } diff --git a/targets/minecraft/world/item/HangingEntityItem.cpp b/targets/minecraft/world/item/HangingEntityItem.cpp index dfc939a36..1cdc9de53 100644 --- a/targets/minecraft/world/item/HangingEntityItem.cpp +++ b/targets/minecraft/world/item/HangingEntityItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "HangingEntityItem.h" #include @@ -82,7 +83,7 @@ std::shared_ptr HangingEntityItem::createEntity( std::make_shared(level, x, y, z, dir); #ifndef _CONTENT_PACKAGE - if (app.DebugArtToolsOn() && auxValue > 0) { + if (DebugSettings::artToolsOn() && auxValue > 0) { painting->PaintingPostConstructor(dir, auxValue - 1); } else #endif @@ -106,7 +107,7 @@ void HangingEntityItem::appendHoverText( std::shared_ptr itemInstance, std::shared_ptr player, std::vector* lines, bool advanced) { #ifndef _CONTENT_PACKAGE - if (eType == eTYPE_PAINTING && app.DebugArtToolsOn() && + if (eType == eTYPE_PAINTING && DebugSettings::artToolsOn() && itemInstance->getAuxValue() > 0) { int motive = itemInstance->getAuxValue() - 1; diff --git a/targets/minecraft/world/item/Item.cpp b/targets/minecraft/world/item/Item.cpp index 7c0ebdd40..628b3edb4 100644 --- a/targets/minecraft/world/item/Item.cpp +++ b/targets/minecraft/world/item/Item.cpp @@ -1,3 +1,5 @@ +#include "minecraft/locale/Strings.h" +#include "minecraft/util/Log.h" #include "Item.h" @@ -1395,7 +1397,7 @@ Item::Item(int id) : id(256 + id) { // this->id = 256 + id; if (items[256 + id] != nullptr) { - app.DebugPrintf("CONFLICT @ %d", id); + Log::info("CONFLICT @ %d", id); } items[256 + id] = this; @@ -1539,12 +1541,12 @@ Item* Item::setDescriptionId(unsigned int id) { } const wchar_t* Item::getDescription() { - return app.GetString(getDescriptionId()); + return Strings::get(getDescriptionId()); // return I18n::get(getDescriptionId()); } const wchar_t* Item::getDescription(std::shared_ptr instance) { - return app.GetString(getDescriptionId(instance)); + return Strings::get(getDescriptionId(instance)); // return I18n::get(getDescriptionId(instance)); } @@ -1638,7 +1640,7 @@ std::wstring Item::getHoverName(std::shared_ptr itemInstance) { // String elementName = ("" + // Language.getInstance().getElementName(getDescription(itemInstance))).trim(); // return elementName; - return app.GetString(getDescriptionId(itemInstance)); + return Strings::get(getDescriptionId(itemInstance)); } bool Item::isFoil(std::shared_ptr itemInstance) { diff --git a/targets/minecraft/world/item/PlanterTileItem.cpp b/targets/minecraft/world/item/PlanterTileItem.cpp index 649501434..095953675 100644 --- a/targets/minecraft/world/item/PlanterTileItem.cpp +++ b/targets/minecraft/world/item/PlanterTileItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "PlanterTileItem.h" #include @@ -70,8 +71,8 @@ bool TilePlanterItem::useOn(std::shared_ptr instance, // 4J-PB - If we have the debug option on, don't reduce the // number of this item #ifndef _FINAL_BUILD - if (!(app.DebugSettingsOn() && - app.GetGameSettingsDebugMask() & + if (!(DebugSettings::isOn() && + DebugSettings::getMask() & (1L << eDebugSetting_CraftAnything))) #endif { diff --git a/targets/minecraft/world/item/PotionItem.cpp b/targets/minecraft/world/item/PotionItem.cpp index 672015a08..07f6079a6 100644 --- a/targets/minecraft/world/item/PotionItem.cpp +++ b/targets/minecraft/world/item/PotionItem.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "PotionItem.h" #include @@ -205,7 +206,7 @@ bool PotionItem::hasInstantenousEffects(int itemAuxValue) { std::wstring PotionItem::getHoverName( std::shared_ptr itemInstance) { if (itemInstance->getAuxValue() == 0) { - return app.GetString( + return Strings::get( IDS_ITEM_WATER_BOTTLE); // I18n.get("item.emptyPotion.name").trim(); } @@ -214,7 +215,7 @@ std::wstring PotionItem::getHoverName( // elementName = I18n.get("potion.prefix.grenade").trim() + " " + // elementName; elementName = replaceAll(elementName, L"{*splash*}", - app.GetString(IDS_POTION_PREFIX_GRENADE)); + Strings::get(IDS_POTION_PREFIX_GRENADE)); } else { elementName = replaceAll(elementName, L"{*splash*}", L""); } @@ -229,14 +230,14 @@ std::wstring PotionItem::getHoverName( elementName = replaceAll(elementName, L"{*prefix*}", L""); elementName = replaceAll( elementName, L"{*postfix*}", - app.GetString(effects->at(0)->getPostfixDescriptionId())); + Strings::get(effects->at(0)->getPostfixDescriptionId())); } else { // String appearanceName = // PotionBrewing.getAppearanceName(itemInstance.getAuxValue()); return // I18n.get(appearanceName).trim() + " " + elementName; elementName = replaceAll(elementName, L"{*prefix*}", - app.GetString(PotionBrewing::getAppearanceName( + Strings::get(PotionBrewing::getAppearanceName( itemInstance->getAuxValue()))); elementName = replaceAll(elementName, L"{*postfix*}", L""); } @@ -258,7 +259,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, for (auto it = effects->begin(); it != effects->end(); ++it) { MobEffectInstance* effect = *it; std::wstring effectString = - app.GetString(effect->getDescriptionId()); + Strings::get(effect->getDescriptionId()); MobEffect* mobEffect = MobEffect::effects[effect->getId()]; std::unordered_map* @@ -288,18 +289,18 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, switch (effect->getAmplifier()) { case 1: potencyString = L" "; - potencyString += app.GetString(IDS_POTION_POTENCY_1); + potencyString += Strings::get(IDS_POTION_POTENCY_1); break; case 2: potencyString = L" "; - potencyString += app.GetString(IDS_POTION_POTENCY_2); + potencyString += Strings::get(IDS_POTION_POTENCY_2); break; case 3: potencyString = L" "; - potencyString += app.GetString(IDS_POTION_POTENCY_3); + potencyString += Strings::get(IDS_POTION_POTENCY_3); break; default: - potencyString = app.GetString(IDS_POTION_POTENCY_0); + potencyString = Strings::get(IDS_POTION_POTENCY_0); break; } effectString += @@ -322,7 +323,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, lines->push_back(HtmlString(effectString, color)); } } else { - std::wstring effectString = app.GetString( + std::wstring effectString = Strings::get( IDS_POTION_EMPTY); // I18n.get("potion.empty").trim(); lines->push_back(HtmlString(effectString, eHTMLColor_7)); //"�7" @@ -331,7 +332,7 @@ void PotionItem::appendHoverText(std::shared_ptr itemInstance, if (!modifiers.empty()) { // Add new line lines->push_back(HtmlString(L"")); - lines->push_back(HtmlString(app.GetString(IDS_POTION_EFFECTS_WHENDRANK), + lines->push_back(HtmlString(Strings::get(IDS_POTION_EFFECTS_WHENDRANK), eHTMLColor_5)); // Add modifier descriptions diff --git a/targets/minecraft/world/item/SpawnEggItem.cpp b/targets/minecraft/world/item/SpawnEggItem.cpp index fc667bb60..6bb4587d6 100644 --- a/targets/minecraft/world/item/SpawnEggItem.cpp +++ b/targets/minecraft/world/item/SpawnEggItem.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/locale/Strings.h" #include "SpawnEggItem.h" #include @@ -40,7 +42,7 @@ std::wstring SpawnEggItem::getHoverName( int nameId = EntityIO::getNameId(itemInstance->getAuxValue()); if (nameId >= 0) { elementName = - replaceAll(elementName, L"{*CREATURE*}", app.GetString(nameId)); + replaceAll(elementName, L"{*CREATURE*}", Strings::get(nameId)); // elementName += " " + I18n.get("entity." + encodeId + ".name"); } else { elementName = replaceAll(elementName, L"{*CREATURE*}", L""); @@ -153,7 +155,7 @@ std::shared_ptr SpawnEggItem::canSpawn(int iAuxVal, Level* level, } } #ifndef _CONTENT_PACKAGE - else if (app.DebugArtToolsOn()) { + else if (DebugSettings::artToolsOn()) { canSpawn = true; } #endif @@ -179,7 +181,7 @@ bool SpawnEggItem::useOn(std::shared_ptr itemInstance, int tile = level->getTile(x, y, z); #ifndef _CONTENT_PACKAGE - if (app.DebugArtToolsOn() && tile == Tile::mobSpawner_Id) { + if (DebugSettings::artToolsOn() && tile == Tile::mobSpawner_Id) { // 4J Stu - Force adding this as a tile update level->removeTile(x, y, z); level->setTileAndData(x, y, z, Tile::mobSpawner_Id, 0, diff --git a/targets/minecraft/world/item/TileItem.cpp b/targets/minecraft/world/item/TileItem.cpp index 7d374f61c..c9e3c7daf 100644 --- a/targets/minecraft/world/item/TileItem.cpp +++ b/targets/minecraft/world/item/TileItem.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "TileItem.h" @@ -153,9 +155,9 @@ bool TileItem::useOn(std::shared_ptr instance, // pMinecraft->soundEngine->GetSoundName(szStepSoundName,iStepSound); // } - // app.DebugPrintf("Place Sound - %s, Step Sound - + // Log::info("Place Sound - %s, Step Sound - // %s\n",szPlaceSoundName,szStepSoundName); - app.DebugPrintf("Place Sound - %d, Step Sound - %d\n", + Log::info("Place Sound - %d, Step Sound - %d\n", iPlaceSound, iStepSound); #endif level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, @@ -165,8 +167,8 @@ bool TileItem::useOn(std::shared_ptr instance, #ifndef _FINAL_BUILD // 4J-PB - If we have the debug option on, don't reduce the // number of this item - if (!(app.DebugSettingsOn() && - app.GetGameSettingsDebugMask() & + if (!(DebugSettings::isOn() && + DebugSettings::getMask() & (1L << eDebugSetting_CraftAnything))) #endif { diff --git a/targets/minecraft/world/item/crafting/Recipes.cpp b/targets/minecraft/world/item/crafting/Recipes.cpp index e1f6278b7..5adee83b7 100644 --- a/targets/minecraft/world/item/crafting/Recipes.cpp +++ b/targets/minecraft/world/item/crafting/Recipes.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "minecraft/world/item/crafting/Recipes.h" #include @@ -987,7 +988,7 @@ ShapedRecipy* Recipes::addShapedRecipy(ItemInstance* result, ...) { for (int i = 0; wchTypes[i] != L'\0'; ++i) { if (wchTypes[i + 1] == L'\0' && wchTypes[i] != L'g') { - app.DebugPrintf("Missing group type\n"); + Log::info("Missing group type\n"); } switch (wchTypes[i]) { diff --git a/targets/minecraft/world/item/crafting/ShapedRecipy.cpp b/targets/minecraft/world/item/crafting/ShapedRecipy.cpp index f881a6311..70380f05b 100644 --- a/targets/minecraft/world/item/crafting/ShapedRecipy.cpp +++ b/targets/minecraft/world/item/crafting/ShapedRecipy.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" // package net.minecraft.world.item.crafting; // // import net.minecraft.world.inventory.CraftingContainer; @@ -97,7 +98,7 @@ int ShapedRecipy::size() { return width * height; } // 4J-PB bool ShapedRecipy::requiresRecipe(int iRecipe) { - app.DebugPrintf("ShapedRecipy %d\n", iRecipe); + Log::info("ShapedRecipy %d\n", iRecipe); int iCount = 0; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { diff --git a/targets/minecraft/world/item/enchantment/Enchantment.cpp b/targets/minecraft/world/item/enchantment/Enchantment.cpp index 21f176b27..646b480e1 100644 --- a/targets/minecraft/world/item/enchantment/Enchantment.cpp +++ b/targets/minecraft/world/item/enchantment/Enchantment.cpp @@ -1,10 +1,11 @@ +#include "minecraft/locale/Strings.h" +#include "minecraft/util/Log.h" #include "Enchantment.h" #include #include -#include "app/common/App_enums.h" -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "minecraft/util/HtmlString.h" #include "minecraft/world/item/ItemInstance.h" #include "minecraft/world/item/enchantment/ArrowDamageEnchantment.h" @@ -109,7 +110,7 @@ void Enchantment::staticCtor() { void Enchantment::_init(int id) { if (enchantments[id] != nullptr) { - app.DebugPrintf("Duplicate enchantment id!"); + Log::info("Duplicate enchantment id!"); #ifndef _CONTENT_PACKAGE assert(0); #endif @@ -162,17 +163,17 @@ int Enchantment::getDescriptionId() { return descriptionId; } // 4jcraft: re-added old TU18 overload for java gui std::wstring Enchantment::getFullname(int level, std::wstring& unformatted) { wchar_t formatted[256]; - swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()), + swprintf(formatted, 256, L"%ls %ls", Strings::get(getDescriptionId()), getLevelString(level).c_str()); unformatted = formatted; swprintf(formatted, 256, L"%ls", - app.GetHTMLColour(eHTMLColor_f), unformatted.c_str()); + GameServices::getHTMLColour(eHTMLColor_f), unformatted.c_str()); return formatted; } HtmlString Enchantment::getFullname(int level) { wchar_t formatted[256]; - swprintf(formatted, 256, L"%ls %ls", app.GetString(getDescriptionId()), + swprintf(formatted, 256, L"%ls %ls", Strings::get(getDescriptionId()), getLevelString(level).c_str()); return HtmlString(formatted, eHTMLColor_f); @@ -214,5 +215,5 @@ std::wstring Enchantment::getLevelString(int level) { stringId = IDS_ENCHANTMENT_LEVEL_10; break; }; - return app.GetString(stringId); // I18n.get("enchantment.level." + level); + return Strings::get(stringId); // I18n.get("enchantment.level." + level); } \ No newline at end of file diff --git a/targets/minecraft/world/level/Explosion.cpp b/targets/minecraft/world/level/Explosion.cpp index 9b64f9c8d..099c3b33c 100644 --- a/targets/minecraft/world/level/Explosion.cpp +++ b/targets/minecraft/world/level/Explosion.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Explosion.h" #include @@ -173,7 +174,7 @@ void Explosion::explode() { if (e->instanceof(eTYPE_PLAYER)) { std::shared_ptr player = std::dynamic_pointer_cast(e); - // app.DebugPrintf("Adding player knockback (%f,%f,%f)\n", xa * + // Log::info("Adding player knockback (%f,%f,%f)\n", xa * // pow, ya * pow, za * pow); hitPlayers.insert(playerVec3Map::value_type( player, Vec3(xa * pow, ya * pow, za * pow))); @@ -206,7 +207,7 @@ void Explosion::finalizeExplosion( if (destroyBlocks) { // toBlowArray.addAll(toBlow); // TODO 4J Stu - Reverse iterator - app.DebugPrintf("Finalizing explosion size %d\n", toBlow.size()); + Log::info("Finalizing explosion size %d\n", toBlow.size()); static const int MAX_EXPLODE_PARTICLES = 50; // 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES; diff --git a/targets/minecraft/world/level/GameRules.cpp b/targets/minecraft/world/level/GameRules.cpp index 0f5276268..e421a7599 100644 --- a/targets/minecraft/world/level/GameRules.cpp +++ b/targets/minecraft/world/level/GameRules.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameHostOptions.h" #include "GameRules.h" #include @@ -40,21 +41,21 @@ GameRules::~GameRules() { bool GameRules::getBoolean(const int rule) { switch (rule) { case GameRules::RULE_DOFIRETICK: - return app.GetGameHostOption(eGameHostOption_FireSpreads); + return GameHostOptions::get(eGameHostOption_FireSpreads); case GameRules::RULE_MOBGRIEFING: - return app.GetGameHostOption(eGameHostOption_MobGriefing); + return GameHostOptions::get(eGameHostOption_MobGriefing); case GameRules::RULE_KEEPINVENTORY: - return app.GetGameHostOption(eGameHostOption_KeepInventory); + return GameHostOptions::get(eGameHostOption_KeepInventory); case GameRules::RULE_DOMOBSPAWNING: - return app.GetGameHostOption(eGameHostOption_DoMobSpawning); + return GameHostOptions::get(eGameHostOption_DoMobSpawning); case GameRules::RULE_DOMOBLOOT: - return app.GetGameHostOption(eGameHostOption_DoMobLoot); + return GameHostOptions::get(eGameHostOption_DoMobLoot); case GameRules::RULE_DOTILEDROPS: - return app.GetGameHostOption(eGameHostOption_DoTileDrops); + return GameHostOptions::get(eGameHostOption_DoTileDrops); case GameRules::RULE_NATURAL_REGENERATION: - return app.GetGameHostOption(eGameHostOption_NaturalRegeneration); + return GameHostOptions::get(eGameHostOption_NaturalRegeneration); case GameRules::RULE_DAYLIGHT: - return app.GetGameHostOption(eGameHostOption_DoDaylightCycle); + return GameHostOptions::get(eGameHostOption_DoDaylightCycle); default: assert(0); return false; diff --git a/targets/minecraft/world/level/Level.cpp b/targets/minecraft/world/level/Level.cpp index 38cf58b57..48e4ae151 100644 --- a/targets/minecraft/world/level/Level.cpp +++ b/targets/minecraft/world/level/Level.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "Level.h" #include @@ -1492,7 +1494,7 @@ void Level::playEntitySound(std::shared_ptr entity, int iSound, for (auto it = listeners.begin(); it != itEnd; it++) { // 4J-PB - if the entity is a local player, don't play the sound if (entity->GetType() == eTYPE_SERVERPLAYER) { - // app.DebugPrintf("ENTITY is serverplayer\n"); + // Log::info("ENTITY is serverplayer\n"); (*it)->playSound(iSound, entity->x, entity->y - entity->heightOffset, entity->z, @@ -2113,7 +2115,7 @@ void Level::tickEntities() { if (!e->removed) { #if !defined(_FINAL_BUILD) - if (!(app.DebugSettingsOn() && app.GetMobsDontTickEnabled() && + if (!(DebugSettings::isOn() && DebugSettings::mobsDontTick() && e->instanceof(eTYPE_MOB) && !e->instanceof(eTYPE_PLAYER))) #endif { @@ -2812,8 +2814,8 @@ void Level::tickWeather() { #if !defined(_FINAL_BUILD) // debug setting added to disable weather - if (app.DebugSettingsOn()) { - if (app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn()) { + if (DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_DisableWeather)) { levelData->setThundering(false); levelData->setThunderTime(random->nextInt(TICKS_PER_DAY * 7) + @@ -3870,7 +3872,7 @@ void Level::setGameTime(int64_t time) { } else if (timeDiff > 100) { // Time differences of more than ~5 seconds are generally not real // time passing so ignore (moving dimensions does this) - app.DebugPrintf( + Log::info( "Level::setTime: Massive time difference, ignoring for time " "passed stat (%lli)\n", timeDiff); diff --git a/targets/minecraft/world/level/PortalForcer.cpp b/targets/minecraft/world/level/PortalForcer.cpp index 56a3e3fd0..6998269d6 100644 --- a/targets/minecraft/world/level/PortalForcer.cpp +++ b/targets/minecraft/world/level/PortalForcer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "PortalForcer.h" #include @@ -261,20 +262,20 @@ bool PortalForcer::createPortal(std::shared_ptr e) { // Move the positions that we want to check away from the edge of the world if ((xc - r) < -XZOFFSET) { - app.DebugPrintf( + Log::info( "Adjusting portal creation x due to being too close to the edge\n"); xc -= ((xc - r) + XZOFFSET); } else if ((xc + r) >= XZOFFSET) { - app.DebugPrintf( + Log::info( "Adjusting portal creation x due to being too close to the edge\n"); xc -= ((xc + r) - XZOFFSET); } if ((zc - r) < -XZOFFSET) { - app.DebugPrintf( + Log::info( "Adjusting portal creation z due to being too close to the edge\n"); zc -= ((zc - r) + XZOFFSET); } else if ((zc + r) >= XZOFFSET) { - app.DebugPrintf( + Log::info( "Adjusting portal creation z due to being too close to the edge\n"); zc -= ((zc + r) - XZOFFSET); } @@ -321,7 +322,7 @@ bool PortalForcer::createPortal(std::shared_ptr e) { (xt >= XZOFFSET) || (zt < -XZOFFSET) || (zt >= XZOFFSET)) { - app.DebugPrintf( + Log::info( "Skipping possible portal " "location as at least one " "block is too close to the " @@ -383,7 +384,7 @@ bool PortalForcer::createPortal(std::shared_ptr e) { // inside the bedrock if ((xt < -XZOFFSET) || (xt >= XZOFFSET) || (zt < -XZOFFSET) || (zt >= XZOFFSET)) { - app.DebugPrintf( + Log::info( "Skipping possible portal location " "as at least one block is too " "close to the edge\n"); diff --git a/targets/minecraft/world/level/biome/BiomeCache.cpp b/targets/minecraft/world/level/biome/BiomeCache.cpp index 4459b50fd..1d93a3244 100644 --- a/targets/minecraft/world/level/biome/BiomeCache.cpp +++ b/targets/minecraft/world/level/biome/BiomeCache.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "BiomeCache.h" #include @@ -89,7 +90,7 @@ BiomeCache::Block* BiomeCache::getBlockAt(int x, int z) { } else { block = it->second; } - block->lastUse = app.getAppTime(); + block->lastUse = GameServices::getAppTime(); return block; } @@ -107,7 +108,7 @@ float BiomeCache::getDownfall(int x, int z) { void BiomeCache::update() { std::lock_guard lock(m_CS); - int64_t now = app.getAppTime(); + int64_t now = GameServices::getAppTime(); int64_t utime = now - lastUpdateTime; if (utime > DECAY_TIME / 4 || utime < 0) { lastUpdateTime = now; diff --git a/targets/minecraft/world/level/biome/BiomeDecorator.cpp b/targets/minecraft/world/level/biome/BiomeDecorator.cpp index 193f2f6f8..339bd2f23 100644 --- a/targets/minecraft/world/level/biome/BiomeDecorator.cpp +++ b/targets/minecraft/world/level/biome/BiomeDecorator.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "minecraft/world/level/biome/BiomeDecorator.h" @@ -34,7 +35,7 @@ BiomeDecorator::BiomeDecorator(Biome* biome) { void BiomeDecorator::decorate(Level* level, Random* random, int xo, int zo) { if (this->level != nullptr) { - app.DebugPrintf("BiomeDecorator::decorate - Already decorating!!\n"); + Log::info("BiomeDecorator::decorate - Already decorating!!\n"); #ifndef _CONTENT_PACKAGE __debugbreak(); // throw new RuntimeException("Already decorating!!"); diff --git a/targets/minecraft/world/level/biome/BiomeSource.cpp b/targets/minecraft/world/level/biome/BiomeSource.cpp index 85dd09069..06b0fe2fb 100644 --- a/targets/minecraft/world/level/biome/BiomeSource.cpp +++ b/targets/minecraft/world/level/biome/BiomeSource.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "BiomeSource.h" #include @@ -166,7 +168,7 @@ void BiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int z, biomes[i] = Biome::biomes[result[i]]; #if !defined(_CONTENT_PACKAGE) if (biomes[i] == nullptr) { - app.DebugPrintf("Tried to assign null biome %d\n", result[i]); + Log::info("Tried to assign null biome %d\n", result[i]); assert(0); } #endif @@ -367,8 +369,8 @@ int64_t BiomeSource::findSeed(LevelType* generator) { mcprogress->progressStage(IDS_PROGRESS_NEW_WORLD_SEED); #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Do nothing } else @@ -425,7 +427,7 @@ int64_t BiomeSource::findSeed(LevelType* generator) { delete pr; #if defined(DEBUG_SEEDS) - app.DebugPrintf("%d: %d tries taken, seed used is %lld\n", k, + Log::info("%d: %d tries taken, seed used is %lld\n", k, tryCount, bestSeed); BiomeSource* biomeSource = new BiomeSource(bestSeed); diff --git a/targets/minecraft/world/level/chunk/LevelChunk.cpp b/targets/minecraft/world/level/chunk/LevelChunk.cpp index f1bab0fba..765a6888d 100644 --- a/targets/minecraft/world/level/chunk/LevelChunk.cpp +++ b/targets/minecraft/world/level/chunk/LevelChunk.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "LevelChunk.h" #include @@ -962,13 +963,13 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { if (te == nullptr) { te = dynamic_cast(Tile::tiles[_tile]) ->newTileEntity(level); - // app.DebugPrintf("%s: Setting tile id %d, created tileEntity + // Log::info("%s: Setting tile id %d, created tileEntity // type %d\n", level->isClientSide?"Client":"Server", _tile, // te->GetType()); level->setTileEntity(xOffs, y, zOffs, te); } if (te != nullptr) { - // app.DebugPrintf("%s: Setting tile id %d, found tileEntity + // Log::info("%s: Setting tile id %d, found tileEntity // type %d\n", level->isClientSide?"Client":"Server", _tile, // te->GetType()); te->clearCache(); @@ -1151,7 +1152,7 @@ void LevelChunk::addEntity(std::shared_ptr e) { int xc = Mth::floor(e->x / 16); int zc = Mth::floor(e->z / 16); if (xc != this->x || zc != this->z) { - app.DebugPrintf("Wrong location!"); + Log::info("Wrong location!"); // System.out.println("Wrong location! " + e); // Thread.dumpStack(); } @@ -1298,7 +1299,7 @@ void LevelChunk::setTileEntity(int x, int y, int z, ->isEntityTile()) // 4J - was !(Tile.tiles[getTile(x, y, z)] // instanceof EntityTile)) { - app.DebugPrintf( + Log::info( "Attempted to place a tile entity where there was no entity " "tile!\n"); return; @@ -1331,7 +1332,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z) { tileEntities.erase(pos); if (te != nullptr) { if (level->isClientSide) { - app.DebugPrintf("Removing tile entity of type %d\n", + Log::info("Removing tile entity of type %d\n", te->GetType()); } te->setRemoved(); @@ -1430,7 +1431,7 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter level->removeEntities(entityBlocks[i]); } } - // app.DebugPrintf("Unloaded chunk %d, %d\n", x, z); + // Log::info("Unloaded chunk %d, %d\n", x, z); #if defined(_LARGE_WORLDS) if (!m_bUnloaded) // 4J-JEV: If we unload a chunk twice, we delete all the diff --git a/targets/minecraft/world/level/chunk/storage/ChunkStorageProfileDecorator.cpp b/targets/minecraft/world/level/chunk/storage/ChunkStorageProfileDecorator.cpp index 6bf13d9e0..36f89b42e 100644 --- a/targets/minecraft/world/level/chunk/storage/ChunkStorageProfileDecorator.cpp +++ b/targets/minecraft/world/level/chunk/storage/ChunkStorageProfileDecorator.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ChunkStorageProfileDecorator.h" #include @@ -54,7 +55,7 @@ void ChunkStorageProfilerDecorator::tick() { 0.000001 * (double)timeSpentLoading / (double)loadCount, loadCount); #endif - app.DebugPrintf(buf); + Log::info(buf); #endif } if (saveCount > 0) { @@ -68,7 +69,7 @@ void ChunkStorageProfilerDecorator::tick() { 0.000001 * (double)timeSpentSaving / (double)loadCount, loadCount); #endif - app.DebugPrintf(buf); + Log::info(buf); #endif } counter = 0; diff --git a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp index 9fc077222..e83bbc2ec 100644 --- a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "McRegionChunkStorage.h" #include @@ -144,7 +146,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { sprintf(buf, "Chunk file at %d, %d is missing level data, skipping\n", x, z); - app.DebugPrintf(buf); + Log::info(buf); delete chunkData; return nullptr; } @@ -153,7 +155,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { sprintf(buf, "Chunk file at %d, %d is missing block data, skipping\n", x, z); - app.DebugPrintf(buf); + Log::info(buf); delete chunkData; return nullptr; } @@ -165,7 +167,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { "Chunk file at %d, %d is in the wrong location; " "relocating. Expected %d, %d, got %d, %d\n", x, z, x, z, levelChunk->x, levelChunk->z); - app.DebugPrintf(buf); + Log::info(buf); delete levelChunk; delete chunkData; return nullptr; @@ -182,8 +184,8 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) { delete chunkData; } #if !defined(_CONTENT_PACKAGE) - if (levelChunk && app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (levelChunk && DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // 4J Stu - This will force an update of the chunk's biome array levelChunk->reloadBiomes(); @@ -333,7 +335,7 @@ void McRegionChunkStorage::staticCtor() { s_saveThreads[i] = new C4JThread(runSaveThreadProc, nullptr, threadName); - // app.DebugPrintf("Created new thread: %s\n",threadName); + // Log::info("Created new thread: %s\n",threadName); // ResumeThread( saveThreads[j] ); s_saveThreads[i]->run(); diff --git a/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp index 9bc13c8be..9c02c07e5 100644 --- a/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "OldChunkStorage.h" #include @@ -134,7 +136,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { sprintf(buf, "Chunk file at %d, %d is missing level data, skipping\n", x, z); - app.DebugPrintf(buf); + Log::info(buf); return nullptr; } if (!tag->getCompound(L"Level")->contains(L"Blocks")) { @@ -142,7 +144,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { sprintf(buf, "Chunk file at %d, %d is missing block data, skipping\n", x, z); - app.DebugPrintf(buf); + Log::info(buf); return nullptr; } LevelChunk* levelChunk = @@ -153,7 +155,7 @@ LevelChunk* OldChunkStorage::load(Level* level, int x, int z) { "Chunk fileat %d, %d is in the wrong location; relocating. " "Expected %d, %d, got %d, %d\n", x, z, x, z, levelChunk->x, levelChunk->z); - app.DebugPrintf(buf); + Log::info(buf); tag->putInt(L"xPos", x); tag->putInt(L"zPos", z); levelChunk = @@ -445,8 +447,8 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { } #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Read the biome data from the stream, but don't use it std::vector dummyBiomes(levelChunk->biomes.size()); @@ -555,8 +557,8 @@ LevelChunk* OldChunkStorage::load(Level* level, CompoundTag* tag) { // 4J removed - we shouldn't need this any more #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { // Do nothing } else diff --git a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp index 7f778a06f..dd5eb2060 100644 --- a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp +++ b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "RegionFile.h" #include @@ -303,7 +304,7 @@ void RegionFile::write(int x, int z, std::uint8_t* data, int sectorsNeeded = (compLength + CHUNK_HEADER_SIZE) / SECTOR_BYTES + 1; - // app.DebugPrintf(">>>>>>>>>>>>>> writing compressed data for 0x%.8x, %d + // Log::info(">>>>>>>>>>>>>> writing compressed data for 0x%.8x, %d //%d\n",fileEntry->data.regionIndex,x,z); // maximum chunk size is 1MB diff --git a/targets/minecraft/world/level/chunk/storage/ZonedChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/ZonedChunkStorage.cpp index 86421596f..8b351ab29 100644 --- a/targets/minecraft/world/level/chunk/storage/ZonedChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/ZonedChunkStorage.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "ZonedChunkStorage.h" #include @@ -166,7 +167,7 @@ void ZonedChunkStorage::tick() { // try { char buf[256]; sprintf(buf, "Closing zone %I64d\n", key); - app.DebugPrintf(buf); + Log::info(buf); zoneFiles[key]->close(); zoneFiles.erase(zoneFiles.find(key)); // } catch (IOException e) { diff --git a/targets/minecraft/world/level/dimension/Dimension.cpp b/targets/minecraft/world/level/dimension/Dimension.cpp index 848918b44..f16da9554 100644 --- a/targets/minecraft/world/level/dimension/Dimension.cpp +++ b/targets/minecraft/world/level/dimension/Dimension.cpp @@ -1,3 +1,5 @@ +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" #include "Dimension.h" #include @@ -54,8 +56,8 @@ void Dimension::init() { #ifdef _OVERRIDE_HEIGHTMAP // 4J Stu - Added to enable overriding the heightmap from a loaded in data // file - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { biomeSource = new BiomeSource(level); } else @@ -89,8 +91,8 @@ ChunkSource* Dimension::createRandomLevelSource() const { #ifdef _OVERRIDE_HEIGHTMAP // 4J Stu - Added to enable overriding the heightmap from a loaded in data // file - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableHeightWaterOverride)) { return new CustomLevelSource( level, level->getSeed(), @@ -216,7 +218,7 @@ int Dimension::getSpawnYPosition() { bool Dimension::hasBedrockFog() { // 4J-PB - turn off bedrock fog if the host player doesn't want it - if (app.GetGameHostOption(eGameHostOption_BedrockFog) == 0) { + if (GameHostOptions::get(eGameHostOption_BedrockFog) == 0) { return false; } diff --git a/targets/minecraft/world/level/dimension/HellDimension.cpp b/targets/minecraft/world/level/dimension/HellDimension.cpp index 222d7d8f5..d4dfbd919 100644 --- a/targets/minecraft/world/level/dimension/HellDimension.cpp +++ b/targets/minecraft/world/level/dimension/HellDimension.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "HellDimension.h" #include @@ -49,8 +50,8 @@ void HellDimension::updateLightRamp() { ChunkSource* HellDimension::createRandomLevelSource() const { #ifdef _DEBUG_MENUS_ENABLED - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_SuperflatNether)) { return new HellFlatLevelSource(level, level->getSeed()); } else diff --git a/targets/minecraft/world/level/levelgen/CanyonFeature.cpp b/targets/minecraft/world/level/levelgen/CanyonFeature.cpp index 0c2d2b553..5c390abfa 100644 --- a/targets/minecraft/world/level/levelgen/CanyonFeature.cpp +++ b/targets/minecraft/world/level/levelgen/CanyonFeature.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "CanyonFeature.h" #include @@ -182,7 +183,7 @@ void CanyonFeature::addFeature(Level* level, int x, int z, int xOffs, int zOffs, thickness, yRot, xRot, 0, 0, 3.0); // 4J Add to feature list - app.AddTerrainFeaturePosition(eTerrainFeature_Ravine, + GameServices::addTerrainFeaturePosition(eTerrainFeature_Ravine, (int)(xCave / 16.0), (int)(yCave / 16.0)); } } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp b/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp index 6944df755..352cf46b7 100644 --- a/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "CustomLevelSource.h" #include @@ -48,10 +50,10 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, auto result = PlatformFileIO.readFile( path, m_heightmapOverride.data(), m_heightmapOverride.size()); if (result.status == IPlatformFileIO::ReadStatus::TooLarge) { - app.DebugPrintf("Heightmap binary is too large!!\n"); + Log::info("Heightmap binary is too large!!\n"); __debugbreak(); } else if (result.status != IPlatformFileIO::ReadStatus::Ok) { - app.FatalLoadError(); + GameServices::fatalLoadError(); assert(false); } } @@ -68,10 +70,10 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, memset(m_waterheightOverride.data(), level->seaLevel, m_waterheightOverride.size()); } else if (result.status == IPlatformFileIO::ReadStatus::TooLarge) { - app.DebugPrintf("waterheight binary is too large!!\n"); + Log::info("waterheight binary is too large!!\n"); __debugbreak(); } else if (result.status != IPlatformFileIO::ReadStatus::Ok) { - app.FatalLoadError(); + GameServices::fatalLoadError(); } } @@ -130,7 +132,7 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, (xMapStart * 16 + x + (xc * CHUNK_WIDTH)); int mapHeight = m_heightmapOverride[mapIndex]; waterHeight = m_waterheightOverride[mapIndex]; - // app.DebugPrintf("MapHeight = %d, y = %d\n", + // Log::info("MapHeight = %d, y = %d\n", // mapHeight, yc * CHUNK_HEIGHT + y); /////////////////////////////////////////////////////////////////// // 4J - add this chunk of code to make land @@ -260,7 +262,7 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, uint8_t top = b->topMaterial; uint8_t material = b->material; - LevelGenerationOptions* lgo = app.getLevelGenerationOptions(); + LevelGenerationOptions* lgo = GameServices::getLevelGenerationOptions(); if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } @@ -527,7 +529,7 @@ void CustomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { biome->decorate(level, pprandom, xo, zo); - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, pprandom); diff --git a/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp b/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp index 42b58d265..f33ae8c20 100644 --- a/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "FlatLevelSource.h" #include @@ -105,7 +106,7 @@ void FlatLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { villageFeature->postProcess(level, pprandom, xt, zt); } - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); } bool FlatLevelSource::save(bool force, ProgressListener* progressListener) { diff --git a/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp b/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp index 700f66641..196d5b48a 100644 --- a/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "HellFlatLevelSource.h" #include @@ -181,7 +182,7 @@ void HellFlatLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { HeavyTile::instaFall = false; - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); } bool HellFlatLevelSource::save(bool force, ProgressListener* progressListener) { diff --git a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp index 4dd0b186d..9c008da28 100644 --- a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "HellRandomLevelSource.h" #include @@ -528,7 +529,7 @@ void HellRandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { HeavyTile::instaFall = false; - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); } bool HellRandomLevelSource::save(bool force, diff --git a/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp index b6b614504..f6575a32e 100644 --- a/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "RandomLevelSource.h" #include @@ -408,7 +409,7 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, uint8_t top = b->topMaterial; uint8_t material = b->material; - LevelGenerationOptions* lgo = app.getLevelGenerationOptions(); + LevelGenerationOptions* lgo = GameServices::getLevelGenerationOptions(); if (lgo != nullptr) { lgo->getBiomeOverride(b->id, material, top); } @@ -798,7 +799,7 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { biome->decorate(level, pprandom, xo, zo); - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, pprandom); diff --git a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp index a331b7656..854e93cca 100644 --- a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "TheEndLevelRandomLevelSource.h" #include @@ -402,7 +403,7 @@ void TheEndLevelRandomLevelSource::postProcess(ChunkSource* parent, int xt, HeavyTile::instaFall = false; - app.processSchematics(parent->getChunk(xt, zt)); + GameServices::processSchematics(parent->getChunk(xt, zt)); } bool TheEndLevelRandomLevelSource::save(bool force, diff --git a/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp index 193c7a6ec..57d2798f8 100644 --- a/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "BasicTreeFeature.h" #include @@ -450,14 +452,14 @@ bool BasicTree::checkLocation() { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( startPosition[0], startPosition[1], startPosition[2], endPosition[0], endPosition[1], endPosition[2]); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/BirchFeature.cpp b/targets/minecraft/world/level/levelgen/feature/BirchFeature.cpp index 81c78dca7..22c35b1f5 100644 --- a/targets/minecraft/world/level/levelgen/feature/BirchFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/BirchFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "BirchFeature.h" #include @@ -44,15 +46,15 @@ bool BirchFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); int radius = 3; bool intersects = levelGenOptions->checkIntersects( x - radius, y - 1, z - radius, x + radius, y + treeHeight, z + radius); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp b/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp index 177a34e52..14b041d64 100644 --- a/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "CaveFeature.h" #include @@ -46,14 +48,14 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop cave features generating areas previously place // by game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( (xx - r / 2), (yy - hr / 2), (zz - r / 2), (xx + r / 2), (yy + hr / 2), (zz + r / 2)); if (intersects) { - // app.DebugPrintf("Skipping cave feature generation as it + // Log::info("Skipping cave feature generation as it // overlaps a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/FlowerFeature.cpp b/targets/minecraft/world/level/levelgen/feature/FlowerFeature.cpp index 8ea66ab0d..b4be07c41 100644 --- a/targets/minecraft/world/level/levelgen/feature/FlowerFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/FlowerFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "FlowerFeature.h" #include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h" @@ -12,13 +14,13 @@ FlowerFeature::FlowerFeature(int tile) { this->tile = tile; } bool FlowerFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x - 8, y - 4, z - 8, x + 8, y + 4, z + 8); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/LakeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/LakeFeature.cpp index bbb2eeb3b..1a8b4cb64 100644 --- a/targets/minecraft/world/level/levelgen/feature/LakeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/LakeFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "LakeFeature.h" #include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h" @@ -24,8 +26,8 @@ bool LakeFeature::place(Level* level, Random* random, int x, int y, int z) { bool grid[16 * 16 * 8] = {0}; LevelGenerationOptions* levelGenOptions = nullptr; - if (app.getLevelGenerationOptions() != nullptr) { - levelGenOptions = app.getLevelGenerationOptions(); + if (GameServices::getLevelGenerationOptions() != nullptr) { + levelGenOptions = GameServices::getLevelGenerationOptions(); int minX = x; int minY = y; @@ -38,7 +40,7 @@ bool LakeFeature::place(Level* level, Random* random, int x, int y, int z) { bool intersects = levelGenOptions->checkIntersects(minX, minY, minZ, maxX, maxY, maxZ); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp index f84d29d32..ef62e1726 100644 --- a/targets/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "MegaTreeFeature.h" #include @@ -26,14 +28,14 @@ bool MegaTreeFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - 2, y - 1, z - 2, x + 2, y + treeHeight, z + 2); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp b/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp index 0d4bcb0d7..d603b76a6 100644 --- a/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "OreFeature.h" #include @@ -37,8 +39,8 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { bool collisionsExpected = false; LevelGenerationOptions* levelGenOptions = nullptr; - if (app.getLevelGenerationOptions() != nullptr) { - levelGenOptions = app.getLevelGenerationOptions(); + if (GameServices::getLevelGenerationOptions() != nullptr) { + levelGenOptions = GameServices::getLevelGenerationOptions(); // 4J Stu - Optimise schematic intersection checks by first checking the // max possible bounding box of this place call @@ -88,7 +90,7 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { bool intersects = levelGenOptions->checkIntersects(xt0, yt0, zt0, xt1, yt1, zt1); if (intersects) { - // app.DebugPrintf("Skipping ore feature generation as it + // Log::info("Skipping ore feature generation as it // overlaps a game rule structure\n"); continue; } diff --git a/targets/minecraft/world/level/levelgen/feature/PineFeature.cpp b/targets/minecraft/world/level/levelgen/feature/PineFeature.cpp index 7c47d19a6..13b0778bf 100644 --- a/targets/minecraft/world/level/levelgen/feature/PineFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/PineFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "PineFeature.h" #include @@ -25,14 +27,14 @@ bool PineFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - topRadius, y - 1, z - topRadius, x + topRadius, y + treeHeight, z + topRadius); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/ReedsFeature.cpp b/targets/minecraft/world/level/levelgen/feature/ReedsFeature.cpp index 9c18c71ed..992bed873 100644 --- a/targets/minecraft/world/level/levelgen/feature/ReedsFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/ReedsFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "ReedsFeature.h" #include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h" @@ -15,13 +17,13 @@ bool ReedsFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop reed features generating areas previously place // by game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x2, y2, z2, x2, y2, z2); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it + // Log::info("Skipping reeds feature generation as it // overlaps a game rule structure\n"); continue; } diff --git a/targets/minecraft/world/level/levelgen/feature/SandFeature.cpp b/targets/minecraft/world/level/levelgen/feature/SandFeature.cpp index a7dae77d0..0aa467cb4 100644 --- a/targets/minecraft/world/level/levelgen/feature/SandFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/SandFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "SandFeature.h" #include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h" @@ -26,14 +28,14 @@ bool SandFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - r, y - yr, z - r, x + r, y + yr, z + r); if (intersects) { level->setInstaTick(false); - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/SpikeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/SpikeFeature.cpp index b6cb58dbb..f24fbc8fd 100644 --- a/targets/minecraft/world/level/levelgen/feature/SpikeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/SpikeFeature.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "SpikeFeature.h" #include @@ -59,7 +60,7 @@ bool SpikeFeature::place(Level* level, Random* random, int x, int y, int z) { bool SpikeFeature::placeWithIndex(Level* level, Random* random, int x, int y, int z, int iIndex, int iRadius) { - app.DebugPrintf("Spike - %d,%d,%d - index %d\n", x, y, z, iIndex); + Log::info("Spike - %d,%d,%d - index %d\n", x, y, z, iIndex); int hh = 12 + (iIndex * 3); @@ -104,7 +105,7 @@ bool SpikeFeature::placeWithIndex(Level* level, Random* random, int x, int y, } } } else { - app.DebugPrintf("Breaking out of spike feature\n"); + Log::info("Breaking out of spike feature\n"); break; } } @@ -132,7 +133,7 @@ bool SpikeFeature::placeWithIndex(Level* level, Random* random, int x, int y, } } } else { - app.DebugPrintf("Breaking out of spike feature\n"); + Log::info("Breaking out of spike feature\n"); break; } } diff --git a/targets/minecraft/world/level/levelgen/feature/SpringFeature.cpp b/targets/minecraft/world/level/levelgen/feature/SpringFeature.cpp index 633afa53f..f72d07540 100644 --- a/targets/minecraft/world/level/levelgen/feature/SpringFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/SpringFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "SpringFeature.h" #include "app/common/GameRules/LevelGeneration/LevelGenerationOptions.h" @@ -10,12 +12,12 @@ SpringFeature::SpringFeature(int tile) { this->tile = tile; } bool SpringFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop spring features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects(x, y, z, x, y, z); if (intersects) { - // app.DebugPrintf("Skipping spring feature generation as it + // Log::info("Skipping spring feature generation as it // overlaps a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/SpruceFeature.cpp b/targets/minecraft/world/level/levelgen/feature/SpruceFeature.cpp index ca3979440..fe43a42a7 100644 --- a/targets/minecraft/world/level/levelgen/feature/SpruceFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/SpruceFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "SpruceFeature.h" #include @@ -28,14 +30,14 @@ bool SpruceFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - leafRadius, y - 1, z - leafRadius, x + leafRadius, y + treeHeight, z + leafRadius); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/SwampTreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/SwampTreeFeature.cpp index 32f20a82d..bc81aac38 100644 --- a/targets/minecraft/world/level/levelgen/feature/SwampTreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/SwampTreeFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "SwampTreeFeature.h" #include @@ -20,13 +22,13 @@ bool SwampTreeFeature::place(Level* level, Random* random, int x, int y, // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - 3, y - 1, z - 3, x + 3, y + treeHeight, z + 3); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp index 1ef0e6ddf..d9c41eb43 100644 --- a/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "TreeFeature.h" #include @@ -34,14 +36,14 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation - if (app.getLevelGenerationOptions() != nullptr) { + if (GameServices::getLevelGenerationOptions() != nullptr) { LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - 2, y - 1, z - 2, x + 2, y + treeHeight, z + 2); if (intersects) { - // app.DebugPrintf("Skipping reeds feature generation as it overlaps + // Log::info("Skipping reeds feature generation as it overlaps // a game rule structure\n"); return false; } diff --git a/targets/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp b/targets/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp index cd1ab4062..ca9301eef 100644 --- a/targets/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "minecraft/world/level/levelgen/structure/MineShaftFeature.h" @@ -34,7 +35,7 @@ MineShaftFeature::MineShaftFeature( bool MineShaftFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { bool forcePlacement = false; - LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGenOptions = GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_Mineshaft); @@ -46,7 +47,7 @@ bool MineShaftFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { StructureStart* MineShaftFeature::createStructureStart(int x, int z) { // 4J added - app.AddTerrainFeaturePosition(eTerrainFeature_Mineshaft, x, z); + GameServices::addTerrainFeaturePosition(eTerrainFeature_Mineshaft, x, z); return new MineShaftStart(level, random, x, z); } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/structure/NetherBridgeFeature.cpp b/targets/minecraft/world/level/levelgen/structure/NetherBridgeFeature.cpp index 45225b771..fef8d89d5 100644 --- a/targets/minecraft/world/level/levelgen/structure/NetherBridgeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/NetherBridgeFeature.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "NetherBridgeFeature.h" #include @@ -59,7 +60,7 @@ bool NetherBridgeFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { } bool forcePlacement = false; - LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGenOptions = GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_NetherBridge); diff --git a/targets/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp b/targets/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp index 12d7e12bf..0c795f2ed 100644 --- a/targets/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "RandomScatteredLargeFeature.h" #include @@ -67,7 +68,7 @@ bool RandomScatteredLargeFeature::isFeatureChunk(int x, int z, z = zz; bool forcePlacement = false; - LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGenOptions = GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_Temples); diff --git a/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp b/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp index 46dbd99c2..d1d9386c4 100644 --- a/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "ScatteredFeaturePieces.h" #include @@ -60,7 +61,7 @@ ScatteredFeaturePieces::ScatteredFeaturePiece::ScatteredFeaturePiece( orientation = random->nextInt(4); - LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGenOptions = GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { int tempOrientation = 0; if (levelGenOptions->isFeatureChunk(west >> 4, north >> 4, diff --git a/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp b/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp index f4846fe40..1d6d245f9 100644 --- a/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "StrongholdFeature.h" #include @@ -161,12 +163,12 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { } #endif - app.DebugPrintf( + Log::info( "Placed stronghold in valid biome at (%d, %d), (%d, " "%d)\n", selectedX, selectedZ, position->x, position->z); // 4J added - app.AddTerrainFeaturePosition(eTerrainFeature_Stronghold, + GameServices::addTerrainFeaturePosition(eTerrainFeature_Stronghold, selectedX, selectedZ); // 4J Added @@ -196,7 +198,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { // one we tried, so store it in the save so Eye of Ender works Fix // for #81933 - GAMEPLAY: The Eye of Ender occasionally does not // appear when used to try and locate the End Portal. - app.AddTerrainFeaturePosition(eTerrainFeature_Stronghold, + GameServices::addTerrainFeaturePosition(eTerrainFeature_Stronghold, strongholdPos[0]->x, strongholdPos[0]->z); } @@ -207,7 +209,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { for (int i = 0; i < strongholdPos_length; i++) { bool forcePlacement = false; LevelGenerationOptions* levelGenOptions = - app.getLevelGenerationOptions(); + GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_Stronghold); diff --git a/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp b/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp index d473dcf0e..c4b78cf3a 100644 --- a/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameServices.h" #include "StrongholdPieces.h" #include @@ -1970,7 +1971,7 @@ bool StrongholdPieces::PortalRoom::postProcess(Level* level, Random* random, // 4J Stu - The mob spawner location is close enough for the map // icon display, and this ensures that we only need to set the // position once - app.AddTerrainFeaturePosition(eTerrainFeature_StrongholdEndPortal, + GameServices::addTerrainFeaturePosition(eTerrainFeature_StrongholdEndPortal, x, z); level->getLevelData()->setXStrongholdEndPortal(x); level->getLevelData()->setZStrongholdEndPortal(z); diff --git a/targets/minecraft/world/level/levelgen/structure/StructureFeatureIO.cpp b/targets/minecraft/world/level/levelgen/structure/StructureFeatureIO.cpp index 9de107b29..84d15d80c 100644 --- a/targets/minecraft/world/level/levelgen/structure/StructureFeatureIO.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StructureFeatureIO.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "StructureFeatureIO.h" #include @@ -95,7 +96,7 @@ StructureStart* StructureFeatureIO::loadStaticStart(CompoundTag* tag, if (start != nullptr) { start->load(level, tag); } else { - app.DebugPrintf("Skipping Structure with id %ls", + Log::info("Skipping Structure with id %ls", tag->getString(L"id").c_str()); } return start; @@ -113,7 +114,7 @@ StructurePiece* StructureFeatureIO::loadStaticPiece(CompoundTag* tag, if (piece != nullptr) { piece->load(level, tag); } else { - app.DebugPrintf("Skipping Piece with id %ls", + Log::info("Skipping Piece with id %ls", tag->getString(L"id").c_str()); } return piece; diff --git a/targets/minecraft/world/level/levelgen/structure/VillageFeature.cpp b/targets/minecraft/world/level/levelgen/structure/VillageFeature.cpp index ba261b23a..e28b106a4 100644 --- a/targets/minecraft/world/level/levelgen/structure/VillageFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/VillageFeature.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "VillageFeature.h" #include @@ -84,7 +86,7 @@ bool VillageFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { z = zz; bool forcePlacement = false; - LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGenOptions = GameServices::getLevelGenerationOptions(); if (levelGenOptions != nullptr) { forcePlacement = levelGenOptions->isFeatureChunk(x, z, eFeature_Village); @@ -94,7 +96,7 @@ bool VillageFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { bool biomeOk = level->getBiomeSource()->containsOnly( x * 16 + 8, z * 16 + 8, 0, allowedBiomes); if (biomeOk) { - // app.DebugPrintf("Biome ok for Village at %d, %d\n",(x * 16 + + // Log::info("Biome ok for Village at %d, %d\n",(x * 16 + // 8),(z * 16 + 8)); return true; } @@ -105,7 +107,7 @@ bool VillageFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { StructureStart* VillageFeature::createStructureStart(int x, int z) { // 4J added - app.AddTerrainFeaturePosition(eTerrainFeature_Village, x, z); + GameServices::addTerrainFeaturePosition(eTerrainFeature_Village, x, z); return new VillageStart(level, random, x, z, villageSizeModifier, m_iXZSize); diff --git a/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp b/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp index 51a46ae9a..df9eb0334 100644 --- a/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp @@ -1,8 +1,9 @@ +#include "minecraft/util/Log.h" #include "BiomeOverrideLayer.h" #include -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "platform/PlatformServices.h" #include "minecraft/world/level/newbiome/layer/Layer.h" #if defined(__linux__) @@ -18,14 +19,14 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { auto result = PlatformFileIO.readFile( path, m_biomeOverride.data(), m_biomeOverride.size()); if (result.status == IPlatformFileIO::ReadStatus::NotFound) { - app.DebugPrintf("Biome override not found, using plains as default\n"); + Log::info("Biome override not found, using plains as default\n"); memset(m_biomeOverride.data(), Biome::plains->id, m_biomeOverride.size()); } else if (result.status == IPlatformFileIO::ReadStatus::TooLarge) { - app.DebugPrintf("Biomemap binary is too large!!\n"); + Log::info("Biomemap binary is too large!!\n"); __debugbreak(); } else if (result.status != IPlatformFileIO::ReadStatus::Ok) { - app.FatalLoadError(); + GameServices::fatalLoadError(); } } } diff --git a/targets/minecraft/world/level/newbiome/layer/Layer.cpp b/targets/minecraft/world/level/newbiome/layer/Layer.cpp index 755f56352..087b78780 100644 --- a/targets/minecraft/world/level/newbiome/layer/Layer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/Layer.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "minecraft/world/level/newbiome/layer/Layer.h" #include @@ -110,8 +111,8 @@ std::vector> Layer::getDefaultLayers( #if !defined(_CONTENT_PACKAGE) #if defined(_BIOME_OVERRIDE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { biomeLayer = std::make_shared(1); } diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp index cb38fca94..a3c0e2ab1 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp @@ -1,3 +1,7 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.h" #include @@ -66,7 +70,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( // Load a save from the game rules bool bLevelGenBaseSave = false; - LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGen = GameServices::getLevelGenerationOptions(); if (pvSaveData == nullptr && levelGen != nullptr && levelGen->requiresBaseSave()) { pvSaveData = levelGen->getBaseSaveData(fileSize); @@ -115,7 +119,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( } else { unsigned int storageLength; PlatformStorage.GetSaveData(pvSaveMem, &storageLength); - app.DebugPrintf("Filesize - %d, Adjusted size - %d\n", fileSize, + Log::info("Filesize - %d, Adjusted size - %d\n", fileSize, storageLength); fileSize = storageLength; } @@ -129,7 +133,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal( if (decompSize == 0) { // 4J Stu - Saves created between 2/12/2011 and 7/12/2011 // will have this problem - app.DebugPrintf("Invalid save data format\n"); + Log::info("Invalid save data format\n"); std::memset(pvSourceData, 0, fileSize); // Clear the first 8 bytes that reference the header header.WriteHeader(pvSourceData); @@ -606,7 +610,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { std::chrono::steady_clock::now() - startTime) .count(); - app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); + Log::info("Check buffer size: Elapsed time %f\n", fElapsedTime); // We add 4 bytes to the start so that we can signal compressed data // And another 4 bytes to store the decompressed data size @@ -626,14 +630,14 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { std::chrono::steady_clock::now() - startTime) .count(); - app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); + Log::info("Compress: Elapsed time %f\n", fElapsedTime); std::fill_n(compData, 8, std::uint8_t{0}); int saveVer = 0; memcpy(compData, &saveVer, sizeof(int)); memcpy(compData + 4, &fileSize, sizeof(int)); - app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, + Log::info("Save data compressed from %d to %d\n", fileSize, compLength); std::uint8_t* pbThumbnailData = nullptr; @@ -643,7 +647,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { unsigned int dwDataSizeSaveImage = 0; #ifdef _WINDOWS64 - app.GetSaveThumbnail(&pbThumbnailData, &dwThumbnailDataSize, + GameServices::getSaveThumbnail(&pbThumbnailData, &dwThumbnailDataSize, &pbDataSaveImage, &dwDataSizeSaveImage); #endif @@ -660,9 +664,9 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { hasSeed = true; } - int iTextMetadataBytes = app.CreateImageTextData( + int iTextMetadataBytes = GameServices::createImageTextData( bTextMetadata, seed, hasSeed, - app.GetGameHostOption(eGameHostOption_All), + GameHostOptions::get(eGameHostOption_All), Minecraft::GetInstance()->getCurrentTexturePackId()); int32_t saveOrCheckpointId = 0; @@ -673,14 +677,14 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize, pbDataSaveImage, dwDataSizeSaveImage, bTextMetadata, iTextMetadataBytes); - app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize); + Log::info("Save thumbnail size %d\n", dwThumbnailDataSize); // save the data PlatformStorage.SaveSaveData( &ConsoleSaveFileOriginal::SaveSaveDataCallback, this); #ifndef _CONTENT_PACKAGE - if (app.DebugSettingsOn()) { - if (app.GetWriteSavesToFolderEnabled()) { + if (DebugSettings::isOn()) { + if (GameServices::getWriteSavesToFolderEnabled()) { DebugFlushToFile(compData, compLength + 8); } } @@ -867,10 +871,10 @@ void ConsoleSaveFileOriginal::ConvertToLocalPlatform() { std::wstring suffix(L".mcr"); if (fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0) { - app.DebugPrintf("Processing a region file: %ls\n", fName.c_str()); + Log::info("Processing a region file: %ls\n", fName.c_str()); ConvertRegionFile(File(fe->data.filename)); } else { - app.DebugPrintf("%ls is not a region file, ignoring\n", + Log::info("%ls is not a region file, ignoring\n", fName.c_str()); } } diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp index 631ca084a..fb6f632a1 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp @@ -1,3 +1,7 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/GameHostOptions.h" +#include "minecraft/util/Log.h" #include "minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.h" #include @@ -197,7 +201,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Compress() { assert((dataOut - dataCompressed) == outputSize); dataCompressedSize = outputSize; // std::int64_t endTime = System::currentTimeMillis(); - // app.DebugPrintf("Compressing region file 0x%.8x from %d to %d bytes - + // Log::info("Compressing region file 0x%.8x from %d to %d bytes - //%dms\n", fileEntry->data.regionIndex, fileEntry->data.length, // dataCompressedSize, endTime - startTime); } @@ -277,7 +281,7 @@ void ConsoleSaveFileSplit::RegionFileReference::Decompress() { assert(0); } // std::int64_t endTime = System::currentTimeMillis(); - // app.DebugPrintf("Decompressing region file from 0x%.8x %d to %d bytes - + // Log::info("Decompressing region file from 0x%.8x %d to %d bytes - //%dms\n", fileEntry->data.regionIndex, dataCompressedSize, // fileEntry->data.length, endTime - startTime);// } @@ -337,7 +341,7 @@ unsigned int ConsoleSaveFileSplit::RegionFileReference::GetCompressedSize() { // Release dataCompressed void ConsoleSaveFileSplit::RegionFileReference::ReleaseCompressed() { - // app.DebugPrintf("Releasing compressed data for region file from + // Log::info("Releasing compressed data for region file from // 0x%.8x\n", fileEntry->data.regionIndex ); free(dataCompressed); dataCompressed = nullptr; @@ -367,7 +371,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit( // Load a save from the game rules bool bLevelGenBaseSave = false; - LevelGenerationOptions* levelGen = app.getLevelGenerationOptions(); + LevelGenerationOptions* levelGen = GameServices::getLevelGenerationOptions(); if (pvSaveData == nullptr && levelGen != nullptr && levelGen->requiresBaseSave()) { pvSaveData = levelGen->getBaseSaveData(fileSize); @@ -491,7 +495,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, } else { unsigned int storageLength; PlatformStorage.GetSaveData(pvSaveMem, &storageLength); - app.DebugPrintf("Filesize - %d, Adjusted size - %d\n", fileSize, + Log::info("Filesize - %d, Adjusted size - %d\n", fileSize, storageLength); fileSize = storageLength; } @@ -504,7 +508,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, if (decompSize == 0) { // 4J Stu - Saves created between 2/12/2011 and 7/12/2011 will // have this problem - app.DebugPrintf("Invalid save data format\n"); + Log::info("Invalid save data format\n"); memset(pvSaveMem, 0, fileSize); // Clear the first 8 bytes that reference the header header.WriteHeader(pvSaveMem); @@ -538,7 +542,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, } else { // Corrupt save, although most of the terrain should // actually be ok - app.DebugPrintf("Failed to decompress save data!\n"); + Log::info("Failed to decompress save data!\n"); #if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif @@ -721,7 +725,7 @@ bool ConsoleSaveFileSplit::writeFile(FileEntry* file, const void* lpBuffer, memcpy(fileRef->data + file->currentFilePointer, lpBuffer, nNumberOfBytesToWrite); - // app.DebugPrintf(">>>>>>>>>>>>>> writing a region file's + // Log::info(">>>>>>>>>>>>>> writing a region file's // data 0x%.8x, 0x%x offset %d of %d bytes (writing %d // bytes)\n",file->data.regionIndex,fileRef->data,file->currentFilePointer, // file->getFileSize(), nNumberOfBytesToWrite); @@ -788,7 +792,7 @@ bool ConsoleSaveFileSplit::zeroFile(FileEntry* file, memset(fileRef->data + file->currentFilePointer, 0, nNumberOfBytesToWrite); - // app.DebugPrintf(">>>>>>>>>>>>>> writing a region file's + // Log::info(">>>>>>>>>>>>>> writing a region file's // data 0x%.8x, 0x%x offset %d of %d bytes (writing %d // bytes)\n",file->data.regionIndex,fileRef->data,file->currentFilePointer, // file->getFileSize(), nNumberOfBytesToWrite); @@ -966,7 +970,7 @@ void ConsoleSaveFileSplit::tick() { writeHistory.push_back(writeEvent); regionRef->Compress(); - // app.DebugPrintf("Tick: Writing region 0x%.8x, compressed + // Log::info("Tick: Writing region 0x%.8x, compressed // as %d bytes\n",regionRef->fileEntry->getRegionFileIndex(), // regionRef->dataCompressedSize); PlatformStorage.UpdateSubfile(regionRef->index, @@ -1275,7 +1279,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { // The storage manage might potentially be busy doing a sub-file write // initiated from the tick. Wait until this is totally processed. while (PlatformStorage.GetSaveState() != IPlatformStorage::ESaveGame_Idle) { - app.DebugPrintf("Flush wait\n"); + Log::info("Flush wait\n"); std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -1314,7 +1318,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { Compression::getCompression()->Compress(nullptr, &compLength, pvSaveMem, fileSize); - app.DebugPrintf("Check buffer size: Elapsed time %f\n", + Log::info("Check buffer size: Elapsed time %f\n", static_cast(timer.elapsed_seconds())); // We add 4 bytes to the start so that we can signal compressed data @@ -1331,7 +1335,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { Compression::getCompression()->Compress(compData + 8, &compLength, pvSaveMem, fileSize); - app.DebugPrintf("Compress: Elapsed time %f\n", + Log::info("Compress: Elapsed time %f\n", static_cast(timer.elapsed_seconds())); memset(compData, 0, 8); @@ -1339,7 +1343,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { memcpy(compData, &saveVer, sizeof(int)); memcpy(compData + 4, &fileSize, sizeof(int)); - app.DebugPrintf("Save data compressed from %d to %d\n", fileSize, + Log::info("Save data compressed from %d to %d\n", fileSize, compLength); if (updateThumbnail) { @@ -1363,16 +1367,16 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { hasSeed = true; } - int iTextMetadataBytes = app.CreateImageTextData( + int iTextMetadataBytes = GameServices::createImageTextData( bTextMetadata, seed, hasSeed, - app.GetGameHostOption(eGameHostOption_All), + GameHostOptions::get(eGameHostOption_All), Minecraft::GetInstance()->getCurrentTexturePackId()); // set the icon and save image PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize, pbDataSaveImage, dwDataSizeSaveImage, bTextMetadata, iTextMetadataBytes); - app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize); + Log::info("Save thumbnail size %d\n", dwThumbnailDataSize); } int32_t saveOrCheckpointId = 0; @@ -1384,8 +1388,8 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { return SaveSaveDataCallback(this, bRes); }); #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn()) { - if (app.GetWriteSavesToFolderEnabled()) { + if (DebugSettings::isOn()) { + if (GameServices::getWriteSavesToFolderEnabled()) { DebugFlushToFile(compData, compLength + 8); } } @@ -1593,10 +1597,10 @@ void ConsoleSaveFileSplit::ConvertToLocalPlatform() { std::wstring suffix(L".mcr"); if (fName.compare(fName.length() - suffix.length(), suffix.length(), suffix) == 0) { - app.DebugPrintf("Processing a region file: %ls\n", fName.c_str()); + Log::info("Processing a region file: %ls\n", fName.c_str()); ConvertRegionFile(File(fe->data.filename)); } else { - app.DebugPrintf("%ls is not a region file, ignoring\n", + Log::info("%ls is not a region file, ignoring\n", fName.c_str()); } } diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.cpp index 129c81425..8f8521493 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" // #define _DEBUG_FILE_HEADER @@ -106,7 +107,7 @@ void FileHeader::WriteHeader(void* saveMem) { *(versions + 1) = versionNumber; #if defined(_DEBUG_FILE_HEADER) - app.DebugPrintf( + Log::info( "Write save file with original version: %d, and current version %d\n", m_originalSaveVersion, versionNumber); #endif @@ -114,7 +115,7 @@ void FileHeader::WriteHeader(void* saveMem) { char* headerPosition = (char*)saveMem + headerOffset; #if defined(_DEBUG_FILE_HEADER) - app.DebugPrintf("\n\nWrite file Header: Offset = %d, Size = %d\n", + Log::info("\n\nWrite file Header: Offset = %d, Size = %d\n", headerOffset, headerSize); #endif @@ -178,10 +179,10 @@ void FileHeader::ReadHeader( if (isSaveEndianDifferent()) System::ReverseSHORT(&m_saveVersion); #if defined(_DEBUG_FILE_HEADER) - app.DebugPrintf( + Log::info( "Read save file with orignal version: %d, and current version %d\n", m_originalSaveVersion, m_saveVersion); - app.DebugPrintf("\n\nRead file Header: Offset = %d, Size = %d\n", + Log::info("\n\nRead file Header: Offset = %d, Size = %d\n", headerOffset, headerSize); #endif @@ -236,7 +237,7 @@ void FileHeader::ReadHeader( lastFile = entry; fileTable.push_back(entry); #if defined(_DEBUG_FILE_HEADER) - app.DebugPrintf( + Log::info( "File: %ls, Start = %d, Length = %d, End = %d, Timestamp = " "%lld\n", entry->data.filename, entry->data.startOffset, @@ -268,7 +269,7 @@ void FileHeader::ReadHeader( lastFile = entry; fileTable.push_back(entry); #if defined(_DEBUG_FILE_HEADER) - app.DebugPrintf( + Log::info( "File: %ls, Start = %d, Length = %d, End = %d\n", entry->data.filename, entry->data.startOffset, entry->data.length, @@ -281,7 +282,7 @@ void FileHeader::ReadHeader( } break; default: #if !defined(_CONTENT_PACKAGE) - app.DebugPrintf("********** Invalid save version %d\n", + Log::info("********** Invalid save version %d\n", m_saveVersion); __debugbreak(); #endif diff --git a/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp b/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp index 0d41605c6..d3fc3b884 100644 --- a/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp +++ b/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp @@ -1,3 +1,6 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/DebugSettings.h" +#include "minecraft/util/Log.h" #include "DirectoryLevelStorage.h" #include @@ -131,7 +134,7 @@ void DirectoryLevelStorage::PlayerMappings::addMapping(int id, int centreX, (((int64_t)(centreX & 0x1FFFFFFF)) << 5) | ((scale & 0x7) << 2) | (dimension & 0x3); m_mappings[index] = id; - // app.DebugPrintf("Adding mapping: %d - (%d,%d)/%d/%d [%I64d - + // Log::info("Adding mapping: %d - (%d,%d)/%d/%d [%I64d - // 0x%016llx]\n", id, centreX, centreZ, dimension, scale, index, index); } @@ -143,7 +146,7 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int& id, int centreX, // int64_t xMasked = centreX & 0x1FFFFFFF; // int64_t zShifted = zMasked << 34; // int64_t xShifted = xMasked << 5; - // app.DebugPrintf("xShifted = %d (0x%016x), zShifted = %I64d + // Log::info("xShifted = %d (0x%016x), zShifted = %I64d // (0x%016llx)\n", xShifted, xShifted, zShifted, zShifted); int64_t index = (((int64_t)(centreZ & 0x1FFFFFFF)) << 34) | (((int64_t)(centreX & 0x1FFFFFFF)) << 5) | @@ -151,11 +154,11 @@ bool DirectoryLevelStorage::PlayerMappings::getMapping(int& id, int centreX, auto it = m_mappings.find(index); if (it != m_mappings.end()) { id = it->second; - // app.DebugPrintf("Found mapping: %d - (%d,%d)/%d/%d [%I64d - + // Log::info("Found mapping: %d - (%d,%d)/%d/%d [%I64d - // 0x%016llx]\n", id, centreX, centreZ, dimension, scale, index, index); return true; } else { - // app.DebugPrintf("Failed to find mapping: (%d,%d)/%d/%d [%I64d - + // Log::info("Failed to find mapping: (%d,%d)/%d/%d [%I64d - // 0x%016llx]\n", centreX, centreZ, dimension, scale, index, index); return false; } @@ -165,7 +168,7 @@ void DirectoryLevelStorage::PlayerMappings::writeMappings( DataOutputStream* dos) { dos->writeInt(m_mappings.size()); for (auto it = m_mappings.begin(); it != m_mappings.end(); ++it) { - app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", it->first, it->first, + Log::info(" -- %lld (0x%016llx) = %d\n", it->first, it->first, it->second); dos->writeLong(it->first); dos->writeInt(it->second); @@ -178,7 +181,7 @@ void DirectoryLevelStorage::PlayerMappings::readMappings(DataInputStream* dis) { int64_t index = dis->readLong(); int id = dis->readInt(); m_mappings[index] = id; - app.DebugPrintf(" -- %lld (0x%016llx) = %d\n", index, index, id); + Log::info(" -- %lld (0x%016llx) = %d\n", index, index, id); } } #endif @@ -275,16 +278,16 @@ LevelData* DirectoryLevelStorage::prepareLevel() { ByteArrayInputStream bais(data); DataInputStream dis(&bais); int count = dis.readInt(); - app.DebugPrintf("Loading %d mappings\n", count); + Log::info("Loading %d mappings\n", count); for (unsigned int i = 0; i < count; ++i) { PlayerUID playerUid = dis.readPlayerUID(); #if defined(_WINDOWS64) || defined(__linux__) - app.DebugPrintf(" -- %d\n", playerUid); + Log::info(" -- %d\n", playerUid); #else #if defined(__linux__) - app.DebugPrintf(" -- %d\n", playerUid); + Log::info(" -- %d\n", playerUid); #else - app.DebugPrintf(" -- %ls\n", playerUid.toWString().c_str()); + Log::info(" -- %ls\n", playerUid.toWString().c_str()); #endif #endif m_playerMappings[playerUid].readMappings(&dis); @@ -402,7 +405,7 @@ void DirectoryLevelStorage::save(std::shared_ptr player) { delete it->second; } m_cachedSaveData[realFile.getName()] = bos; - app.DebugPrintf( + Log::info( "Cached saving of file %ls due to saves being disabled\n", realFile.getName().c_str()); } else { @@ -412,7 +415,7 @@ void DirectoryLevelStorage::save(std::shared_ptr player) { } delete tag; } else if (playerXuid != INVALID_XUID) { - app.DebugPrintf("Not saving player as their XUID is a guest\n"); + Log::info("Not saving player as their XUID is a guest\n"); dontSaveMapMappingForPlayer(playerXuid); } } @@ -436,7 +439,7 @@ CompoundTag* DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) { ByteArrayInputStream bis(bos->buf, 0, bos->size()); CompoundTag* tag = NbtIo::readCompressed(&bis); bis.reset(); - app.DebugPrintf("Loaded player data from cached file %ls\n", + Log::info("Loaded player data from cached file %ls\n", realFile.getName().c_str()); return tag; } else if (m_saveFile->doesFileExist(realFile)) { @@ -456,8 +459,8 @@ void DirectoryLevelStorage::clearOldPlayerFiles() { if (playerFiles != nullptr) { #if !defined(_FINAL_BUILD) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { for (unsigned int i = 0; i < playerFiles->size(); ++i) { FileEntry* file = playerFiles->at(i); @@ -502,8 +505,8 @@ std::wstring DirectoryLevelStorage::getLevelId() { return levelId; } void DirectoryLevelStorage::flushSaveFile(bool autosave) { #if !defined(_CONTENT_PACKAGE) - if (app.DebugSettingsOn() && - app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & + if (DebugSettings::isOn() && + DebugSettings::getMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_DistributableSave)) { // Delete gamerules files if it exists ConsoleSavePath gameRulesFiles(GAME_RULE_SAVENAME); @@ -518,7 +521,7 @@ void DirectoryLevelStorage::flushSaveFile(bool autosave) { // 4J Added void DirectoryLevelStorage::resetNetherPlayerPositions() { - if (app.GetResetNether()) { + if (GameServices::getResetNether()) { std::vector* playerFiles = m_saveFile->getFilesWithPrefix(playerDir.getName()); @@ -635,16 +638,16 @@ void DirectoryLevelStorage::saveMapIdLookup() { ByteArrayOutputStream baos; DataOutputStream dos(&baos); dos.writeInt(m_playerMappings.size()); - app.DebugPrintf("Saving %d mappings\n", m_playerMappings.size()); + Log::info("Saving %d mappings\n", m_playerMappings.size()); for (auto it = m_playerMappings.begin(); it != m_playerMappings.end(); ++it) { #if defined(_WINDOWS64) || defined(__linux__) - app.DebugPrintf(" -- %d\n", it->first); + Log::info(" -- %d\n", it->first); #else #if defined(__linux__) - app.DebugPrintf(" -- %d\n", it->first); + Log::info(" -- %d\n", it->first); #else - app.DebugPrintf(" -- %ls\n", it->first.toWString().c_str()); + Log::info(" -- %ls\n", it->first.toWString().c_str()); #endif #endif dos.writePlayerUID(it->first); @@ -756,7 +759,7 @@ void DirectoryLevelStorage::saveAllCachedData() { ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream(m_saveFile, realFile); - app.DebugPrintf("Actually writing cached file %ls\n", + Log::info("Actually writing cached file %ls\n", it->first.c_str()); fos.write(bos->buf, 0, bos->size()); delete bos; diff --git a/targets/minecraft/world/level/storage/LevelData.cpp b/targets/minecraft/world/level/storage/LevelData.cpp index 83893ee61..e4cb26caf 100644 --- a/targets/minecraft/world/level/storage/LevelData.cpp +++ b/targets/minecraft/world/level/storage/LevelData.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/GameHostOptions.h" #include "LevelData.h" #include @@ -123,12 +125,12 @@ LevelData::LevelData(CompoundTag* tag) { m_smallEdgeMoat = tag->getInt(L"SmallMoat"); m_mediumEdgeMoat = tag->getInt(L"MediumMoat"); - int newWorldSize = app.GetGameNewWorldSize(); - int newHellScale = app.GetGameNewHellScale(); + int newWorldSize = GameServices::getGameNewWorldSize(); + int newHellScale = GameServices::getGameNewHellScale(); m_hellScaleOld = m_hellScale; m_xzSizeOld = m_xzSize; if (newWorldSize > m_xzSize) { - bool bUseMoat = app.GetGameNewWorldSizeUseMoat(); + bool bUseMoat = GameServices::getGameNewWorldSizeUseMoat(); switch (m_xzSize) { case LEVEL_WIDTH_CLASSIC: m_classicEdgeMoat = bUseMoat; @@ -182,7 +184,7 @@ LevelData::LevelData(CompoundTag* tag) { assert(0); break; } - app.SetGameHostOption(eGameHostOption_WorldSize, hostOptionworldSize); + GameHostOptions::set(eGameHostOption_WorldSize, hostOptionworldSize); #endif /* 4J - we don't store this anymore @@ -516,7 +518,7 @@ void LevelData::setGameType(GameType* gameType) { // 4J Added hasBeenInCreative = hasBeenInCreative || (gameType == GameType::CREATIVE) || - (app.GetGameHostOption(eGameHostOption_CheatsEnabled) > 0); + (GameHostOptions::get(eGameHostOption_CheatsEnabled) > 0); } bool LevelData::useNewSeaLevel() { return newSeaLevel; } diff --git a/targets/minecraft/world/level/storage/McRegionLevelStorage.cpp b/targets/minecraft/world/level/storage/McRegionLevelStorage.cpp index 07ec7b43c..8ce8a768a 100644 --- a/targets/minecraft/world/level/storage/McRegionLevelStorage.cpp +++ b/targets/minecraft/world/level/storage/McRegionLevelStorage.cpp @@ -1,3 +1,5 @@ +#include "minecraft/GameServices.h" +#include "minecraft/util/Log.h" #include "McRegionLevelStorage.h" #include @@ -36,7 +38,7 @@ ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) { // File folder = getFolder(); if (dynamic_cast(dimension) != nullptr) { - if (app.GetResetNether()) { + if (GameServices::getResetNether()) { #ifdef SPLIT_SAVES std::vector* netherFiles = m_saveFile->getRegionFilesByDimension(1); @@ -79,7 +81,7 @@ ChunkStorage* McRegionLevelStorage::createChunkStorage(Dimension* dimension) { // For versions before TU9 (TU7 and 8) we generate a part of The // End, but we want to scrap it if it exists so that it is replaced // with the TU9+ version - app.DebugPrintf( + Log::info( "Loaded save version number is: %d, required to keep The End " "is: %d\n", m_saveFile->getSaveVersion(), SAVE_FILE_VERSION_NEW_END); diff --git a/targets/minecraft/world/level/tile/FireTile.cpp b/targets/minecraft/world/level/tile/FireTile.cpp index 29be2d805..9134d8dc5 100644 --- a/targets/minecraft/world/level/tile/FireTile.cpp +++ b/targets/minecraft/world/level/tile/FireTile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameHostOptions.h" #include "FireTile.h" #include @@ -161,7 +162,7 @@ void FireTile::tick(Level* level, int x, int y, int z, Random* random) { checkBurnOut(level, x, y + 1, z, 250 + extra, random, age); checkBurnOut(level, x, y, z - 1, 300 + extra, random, age); checkBurnOut(level, x, y, z + 1, 300 + extra, random, age); - if (app.GetGameHostOption(eGameHostOption_FireSpreads)) { + if (GameHostOptions::get(eGameHostOption_FireSpreads)) { for (int xx = x - 1; xx <= x + 1; xx++) { for (int zz = z - 1; zz <= z + 1; zz++) { for (int yy = y - 1; yy <= y + 4; yy++) { @@ -207,7 +208,7 @@ void FireTile::checkBurnOut(Level* level, int x, int y, int z, int chance, if (random->nextInt(chance) < odds) { bool wasTnt = level->getTile(x, y, z) == Tile::tnt_Id; if (random->nextInt(age + 10) < 5 && !level->isRainingAt(x, y, z) && - app.GetGameHostOption(eGameHostOption_FireSpreads)) { + GameHostOptions::get(eGameHostOption_FireSpreads)) { int tAge = age + random->nextInt(5) / 4; if (tAge > 15) tAge = 15; level->setTileAndData(x, y, z, id, tAge, Tile::UPDATE_ALL); diff --git a/targets/minecraft/world/level/tile/NotGateTile.cpp b/targets/minecraft/world/level/tile/NotGateTile.cpp index 0d76cd7b1..f813da13e 100644 --- a/targets/minecraft/world/level/tile/NotGateTile.cpp +++ b/targets/minecraft/world/level/tile/NotGateTile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "NotGateTile.h" #include "app/linux/LinuxGame.h" @@ -122,7 +123,7 @@ void NotGateTile::tick(Level* level, int x, int y, int z, Random* random) { level->getData(x, y, z), Tile::UPDATE_ALL); if (isToggledTooFrequently(level, x, y, z, true)) { - app.DebugPrintf( + Log::info( "Torch at (%d,%d,%d) has toggled too many times\n", x, y, z); @@ -148,7 +149,7 @@ void NotGateTile::tick(Level* level, int x, int y, int z, Random* random) { level->getData(x, y, z), Tile::UPDATE_ALL); } else { - app.DebugPrintf( + Log::info( "Torch at (%d,%d,%d) has toggled too many times\n", x, y, z); } diff --git a/targets/minecraft/world/level/tile/NoteBlockTile.cpp b/targets/minecraft/world/level/tile/NoteBlockTile.cpp index dcc937b22..d51fca491 100644 --- a/targets/minecraft/world/level/tile/NoteBlockTile.cpp +++ b/targets/minecraft/world/level/tile/NoteBlockTile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "NoteBlockTile.h" #include @@ -15,12 +16,12 @@ NoteBlockTile::NoteBlockTile(int id) : BaseEntityTile(id, Material::wood) {} void NoteBlockTile::neighborChanged(Level* level, int x, int y, int z, int type) { - app.DebugPrintf("-------- Neighbour changed type %d\n", type); + Log::info("-------- Neighbour changed type %d\n", type); bool signal = level->hasNeighborSignal(x, y, z); std::shared_ptr mte = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)); - app.DebugPrintf("-------- Signal is %s, tile is currently %s\n", + Log::info("-------- Signal is %s, tile is currently %s\n", signal ? "true" : "false", mte->on ? "ON" : "OFF"); if (mte != nullptr && mte->on != signal) { if (signal) { @@ -85,7 +86,7 @@ bool NoteBlockTile::triggerEvent(Level* level, int x, int y, int z, int i, iSound = eSoundType_NOTE_HARP; break; } - app.DebugPrintf("NoteBlockTile::triggerEvent - playSound - pitch = %f\n", + Log::info("NoteBlockTile::triggerEvent - playSound - pitch = %f\n", pitch); level->playSound(x + 0.5, y + 0.5, z + 0.5, iSound, 3, pitch); level->addParticle(eParticleType_note, x + 0.5, y + 1.2, z + 0.5, diff --git a/targets/minecraft/world/level/tile/StoneMonsterTile.cpp b/targets/minecraft/world/level/tile/StoneMonsterTile.cpp index 6fc9a8d2e..1ca2a0920 100644 --- a/targets/minecraft/world/level/tile/StoneMonsterTile.cpp +++ b/targets/minecraft/world/level/tile/StoneMonsterTile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/DebugSettings.h" #include "StoneMonsterTile.h" #include @@ -25,7 +26,7 @@ StoneMonsterTile::StoneMonsterTile(int id) : Tile(id, Material::clay) { Icon* StoneMonsterTile::getTexture(int face, int data) { #ifndef _CONTENT_PACKAGE - if (app.DebugArtToolsOn()) { + if (DebugSettings::artToolsOn()) { return Tile::fire->getTexture(face, 0); } #endif diff --git a/targets/minecraft/world/level/tile/Tile.cpp b/targets/minecraft/world/level/tile/Tile.cpp index 7e2766700..b4cc3c2c8 100644 --- a/targets/minecraft/world/level/tile/Tile.cpp +++ b/targets/minecraft/world/level/tile/Tile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "Tile.h" #include @@ -2672,7 +2673,7 @@ Tile::SoundType::SoundType(eMATERIALSOUND_TYPE eMaterialSound, float volume, this->iBreakSound = eSoundType_DIG_WOOD; break; default: - app.DebugPrintf("NO BREAK SOUND!\n"); + Log::info("NO BREAK SOUND!\n"); this->iBreakSound = -1; break; } @@ -2714,7 +2715,7 @@ Tile::SoundType::SoundType(eMATERIALSOUND_TYPE eMaterialSound, float volume, this->iStepSound = eSoundType_STEP_LADDER; break; default: - app.DebugPrintf("NO STEP SOUND!\n"); + Log::info("NO STEP SOUND!\n"); this->iStepSound = -1; break; diff --git a/targets/minecraft/world/level/tile/TntTile.cpp b/targets/minecraft/world/level/tile/TntTile.cpp index e3bfbf899..1d8b44794 100644 --- a/targets/minecraft/world/level/tile/TntTile.cpp +++ b/targets/minecraft/world/level/tile/TntTile.cpp @@ -1,3 +1,4 @@ +#include "minecraft/GameHostOptions.h" #include "TntTile.h" #include @@ -35,7 +36,7 @@ Icon* TntTile::getTexture(int face, int data) { void TntTile::onPlace(Level* level, int x, int y, int z) { Tile::onPlace(level, x, y, z); if (level->hasNeighborSignal(x, y, z) && - app.GetGameHostOption(eGameHostOption_TNT)) { + GameHostOptions::get(eGameHostOption_TNT)) { destroy(level, x, y, z, EXPLODE_BIT); level->removeTile(x, y, z); } @@ -43,7 +44,7 @@ void TntTile::onPlace(Level* level, int x, int y, int z) { void TntTile::neighborChanged(Level* level, int x, int y, int z, int type) { if (level->hasNeighborSignal(x, y, z) && - app.GetGameHostOption(eGameHostOption_TNT)) { + GameHostOptions::get(eGameHostOption_TNT)) { destroy(level, x, y, z, EXPLODE_BIT); level->removeTile(x, y, z); } @@ -63,7 +64,7 @@ void TntTile::wasExploded(Level* level, int x, int y, int z, // TNT blocks are triggered by explosions even though "TNT explodes" option // is unchecked. if (level->newPrimedTntAllowed() && - app.GetGameHostOption(eGameHostOption_TNT)) { + GameHostOptions::get(eGameHostOption_TNT)) { std::shared_ptr primed = std::shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, explosion->getSourceMob())); @@ -84,7 +85,7 @@ void TntTile::destroy(Level* level, int x, int y, int z, int data, if ((data & EXPLODE_BIT) == 1) { // 4J - added condition to have finite limit of these if (level->newPrimedTntAllowed() && - app.GetGameHostOption(eGameHostOption_TNT)) { + GameHostOptions::get(eGameHostOption_TNT)) { std::shared_ptr tnt = std::shared_ptr( new PrimedTnt(level, x + 0.5f, y + 0.5f, z + 0.5f, source)); level->addEntity(tnt); diff --git a/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp b/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp index c2c85b71e..333d9a272 100644 --- a/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "BeaconTileEntity.h" #include @@ -281,7 +282,7 @@ void BeaconTileEntity::setItem(unsigned int slot, } std::wstring BeaconTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_CONTAINER_BEACON); + return hasCustomName() ? name : Strings::get(IDS_CONTAINER_BEACON); } std::wstring BeaconTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp b/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp index 85e48f505..a42c37b54 100644 --- a/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "BrewingStandTileEntity.h" #include @@ -40,7 +41,7 @@ BrewingStandTileEntity::BrewingStandTileEntity() { BrewingStandTileEntity::~BrewingStandTileEntity() {} std::wstring BrewingStandTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_TILE_BREWINGSTAND); + return hasCustomName() ? name : Strings::get(IDS_TILE_BREWINGSTAND); } std::wstring BrewingStandTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp b/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp index bd03d0e9d..9ef3d2f27 100644 --- a/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "ChestTileEntity.h" #include @@ -109,7 +110,7 @@ void ChestTileEntity::setItem(unsigned int slot, } std::wstring ChestTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_TILE_CHEST); + return hasCustomName() ? name : Strings::get(IDS_TILE_CHEST); } std::wstring ChestTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp b/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp index 492558328..bd6c4b004 100644 --- a/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "DispenserTileEntity.h" #include @@ -124,7 +125,7 @@ int DispenserTileEntity::addItem(std::shared_ptr item) { } std::wstring DispenserTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_TILE_DISPENSER); + return hasCustomName() ? name : Strings::get(IDS_TILE_DISPENSER); } std::wstring DispenserTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/DropperTileEntity.cpp b/targets/minecraft/world/level/tile/entity/DropperTileEntity.cpp index 7e8a9b991..6522ce614 100644 --- a/targets/minecraft/world/level/tile/entity/DropperTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/DropperTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "DropperTileEntity.h" #include @@ -8,7 +9,7 @@ #include "strings.h" std::wstring DropperTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_CONTAINER_DROPPER); + return hasCustomName() ? name : Strings::get(IDS_CONTAINER_DROPPER); } // 4J Added diff --git a/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp b/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp index 11371e655..0c6ede03c 100644 --- a/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "EnchantmentTableTileEntity.h" #include @@ -93,7 +94,7 @@ void EnchantmentTableEntity::tick() { } std::wstring EnchantmentTableEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_ENCHANT); + return hasCustomName() ? name : Strings::get(IDS_ENCHANT); } std::wstring EnchantmentTableEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp b/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp index 519cbd231..feb650deb 100644 --- a/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "FurnaceTileEntity.h" #include @@ -97,7 +98,7 @@ void FurnaceTileEntity::setItem(unsigned int slot, } std::wstring FurnaceTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_TILE_FURNACE); + return hasCustomName() ? name : Strings::get(IDS_TILE_FURNACE); } std::wstring FurnaceTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp b/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp index 39a184427..d90aad5f0 100644 --- a/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/locale/Strings.h" #include "HopperTileEntity.h" #include @@ -109,7 +110,7 @@ void HopperTileEntity::setItem(unsigned int slot, } std::wstring HopperTileEntity::getName() { - return hasCustomName() ? name : app.GetString(IDS_CONTAINER_HOPPER); + return hasCustomName() ? name : Strings::get(IDS_CONTAINER_HOPPER); } std::wstring HopperTileEntity::getCustomName() { diff --git a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp index 0e4824612..6e6187df5 100644 --- a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp +++ b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp @@ -2,8 +2,7 @@ #include -#include "app/common/App_enums.h" -#include "app/linux/LinuxGame.h" +#include "minecraft/GameServices.h" #include "TheEndPortalTileEntity.h" #include "java/Class.h" #include "java/Random.h" @@ -72,7 +71,7 @@ void TheEndPortal::entityInside(Level* level, int x, int y, int z, x = z = 0; if (level->dimension == 0 && !level->getLevelData()->getHasStrongholdEndPortal() && - app.GetTerrainFeaturePosition( + GameServices::getTerrainFeaturePosition( eTerrainFeature_StrongholdEndPortal, &x, &z)) { level->getLevelData()->setXStrongholdEndPortal(x); level->getLevelData()->setZStrongholdEndPortal(z); diff --git a/targets/minecraft/world/level/tile/entity/TileEntity.cpp b/targets/minecraft/world/level/tile/entity/TileEntity.cpp index 908e58d19..6944e7d46 100644 --- a/targets/minecraft/world/level/tile/entity/TileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/TileEntity.cpp @@ -1,3 +1,4 @@ +#include "minecraft/util/Log.h" #include "TileEntity.h" #include @@ -136,7 +137,7 @@ std::shared_ptr TileEntity::loadStatic(CompoundTag* tag) { entity->load(tag); } else { #ifdef _DEBUG - app.DebugPrintf("Skipping TileEntity with id %ls.\n", + Log::info("Skipping TileEntity with id %ls.\n", tag->getString(L"id").c_str()); #endif }