refactor: eliminate app. calls from minecraft via Log, Strings, GameHostOptions, and service wiring

This commit is contained in:
MatthewBeshay 2026-04-04 14:47:39 +11:00 committed by Tropical
parent f28c722da4
commit 5f64818302
190 changed files with 2987 additions and 1165 deletions

View file

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

View file

@ -0,0 +1,58 @@
#include "app/common/GameMenuService.h"
#include "app/common/Game.h"
bool GameMenuService::openInventory(int iPad, std::shared_ptr<LocalPlayer> player, bool navigateBack) {
return game_.LoadInventoryMenu(iPad, player, navigateBack);
}
bool GameMenuService::openCreative(int iPad, std::shared_ptr<LocalPlayer> player, bool navigateBack) {
return game_.LoadCreativeMenu(iPad, player, navigateBack);
}
bool GameMenuService::openCrafting2x2(int iPad, std::shared_ptr<LocalPlayer> player) {
return game_.LoadCrafting2x2Menu(iPad, player);
}
bool GameMenuService::openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x, int y, int z) {
return game_.LoadCrafting3x3Menu(iPad, player, x, y, z);
}
bool GameMenuService::openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x, int y, int z, Level* level, const std::wstring& name) {
return game_.LoadEnchantingMenu(iPad, inventory, x, y, z, level, name);
}
bool GameMenuService::openFurnace(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<FurnaceTileEntity> furnace) {
return game_.LoadFurnaceMenu(iPad, inventory, furnace);
}
bool GameMenuService::openBrewingStand(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<BrewingStandTileEntity> brewingStand) {
return game_.LoadBrewingStandMenu(iPad, inventory, brewingStand);
}
bool GameMenuService::openContainer(int iPad, std::shared_ptr<Container> inventory, std::shared_ptr<Container> container) {
return game_.LoadContainerMenu(iPad, inventory, container);
}
bool GameMenuService::openTrap(int iPad, std::shared_ptr<Container> inventory, std::shared_ptr<DispenserTileEntity> trap) {
return game_.LoadTrapMenu(iPad, inventory, trap);
}
bool GameMenuService::openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x, int y, int z) {
return game_.LoadFireworksMenu(iPad, player, x, y, z);
}
bool GameMenuService::openSign(int iPad, std::shared_ptr<SignTileEntity> sign) {
return game_.LoadSignEntryMenu(iPad, sign);
}
bool GameMenuService::openRepairing(int iPad, std::shared_ptr<Inventory> inventory, Level* level, int x, int y, int z) {
return game_.LoadRepairingMenu(iPad, inventory, level, x, y, z);
}
bool GameMenuService::openTrading(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<Merchant> trader, Level* level, const std::wstring& name) {
return game_.LoadTradingMenu(iPad, inventory, trader, level, name);
}
bool GameMenuService::openCommandBlock(int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) {
return game_.LoadCommandBlockMenu(iPad, commandBlock);
}
bool GameMenuService::openHopper(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<HopperTileEntity> hopper) {
return game_.LoadHopperMenu(iPad, inventory, hopper);
}
bool GameMenuService::openHopperMinecart(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<MinecartHopper> hopper) {
return game_.LoadHopperMenu(iPad, inventory, hopper);
}
bool GameMenuService::openHorse(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<Container> container, std::shared_ptr<EntityHorse> horse) {
return game_.LoadHorseMenu(iPad, inventory, container, horse);
}
bool GameMenuService::openBeacon(int iPad, std::shared_ptr<Inventory> inventory, std::shared_ptr<BeaconTileEntity> beacon) {
return game_.LoadBeaconMenu(iPad, inventory, beacon);
}

View file

@ -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<LocalPlayer> player,
bool navigateBack) override;
bool openCreative(int iPad, std::shared_ptr<LocalPlayer> player,
bool navigateBack) override;
bool openCrafting2x2(int iPad,
std::shared_ptr<LocalPlayer> player) override;
bool openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player, int x,
int y, int z) override;
bool openEnchanting(int iPad, std::shared_ptr<Inventory> inventory, int x,
int y, int z, Level* level,
const std::wstring& name) override;
bool openFurnace(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<FurnaceTileEntity> furnace) override;
bool openBrewingStand(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BrewingStandTileEntity> brewingStand) override;
bool openContainer(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<Container> container) override;
bool openTrap(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<DispenserTileEntity> trap) override;
bool openFireworks(int iPad, std::shared_ptr<LocalPlayer> player, int x,
int y, int z) override;
bool openSign(int iPad, std::shared_ptr<SignTileEntity> sign) override;
bool openRepairing(int iPad, std::shared_ptr<Inventory> inventory,
Level* level, int x, int y, int z) override;
bool openTrading(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Merchant> trader, Level* level,
const std::wstring& name) override;
bool openCommandBlock(
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) override;
bool openHopper(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<HopperTileEntity> hopper) override;
bool openHopperMinecart(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<MinecartHopper> hopper) override;
bool openHorse(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Container> container,
std::shared_ptr<EntityHorse> horse) override;
bool openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BeaconTileEntity> beacon) override;
private:
Game& game_;
};

View file

@ -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<eGameSetting>(s));
},
[](int s) {
return app.GetGameSettings(static_cast<eGameSetting>(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<SKIN_BOX*>* 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<eINSTANCEOF>(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(

View file

@ -0,0 +1,185 @@
#include "minecraft/GameHostOptions.h"
#include <cassert>
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

View file

@ -0,0 +1,18 @@
#pragma once
#include <cstdint>
#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

View file

@ -0,0 +1,654 @@
#include "minecraft/GameServices.h"
#include <cassert>
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<SKIN_BOX*>* (*s_getAdditionalSkinBoxes)(std::uint32_t) = nullptr;
static std::vector<ModelPart*>* (*s_getAdditionalModelParts)(std::uint32_t) = nullptr;
static std::vector<ModelPart*>* (*s_setAdditionalSkinBoxesFromVec)(
std::uint32_t, std::vector<SKIN_BOX*>*) = 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<SKIN_BOX*>* (*getAdditionalSkinBoxesFn)(std::uint32_t),
std::vector<ModelPart*>* (*getAdditionalModelPartsFn)(std::uint32_t),
std::vector<ModelPart*>* (*setAdditionalSkinBoxesFromVecFn)(
std::uint32_t, std::vector<SKIN_BOX*>*),
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<SKIN_BOX*>* getAdditionalSkinBoxes(std::uint32_t dwSkinID) {
return s_getAdditionalSkinBoxes ? s_getAdditionalSkinBoxes(dwSkinID) : nullptr;
}
std::vector<ModelPart*>* getAdditionalModelParts(std::uint32_t dwSkinID) {
return s_getAdditionalModelParts ? s_getAdditionalModelParts(dwSkinID) : nullptr;
}
std::vector<ModelPart*>* setAdditionalSkinBoxesFromVec(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* 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<std::uint8_t> (*s_getArchiveFile)(const std::wstring&) = nullptr;
void initArchive(
bool (*hasArchiveFileFn)(const std::wstring&),
std::vector<std::uint8_t> (*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<std::uint8_t> getArchiveFile(const std::wstring& filename) {
return s_getArchiveFile ? s_getArchiveFile(filename) : std::vector<std::uint8_t>{};
}
// 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<std::wstring>* s_skinNames = nullptr;
static std::vector<FEATURE_DATA*>* s_terrainFeatures = nullptr;
void initMemberAccess(
DLCManager* dlcManager,
GameRuleManager* gameRules,
std::vector<std::wstring>* skinNames,
std::vector<FEATURE_DATA*>* 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<std::wstring>& getSkinNames() {
assert(s_skinNames);
return *s_skinNames;
}
std::vector<FEATURE_DATA*>& 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

View file

@ -0,0 +1,305 @@
#pragma once
#include <cstdint>
#include <string>
#include <vector>
// 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<SKIN_BOX*>* (*getAdditionalSkinBoxes)(std::uint32_t dwSkinID),
std::vector<ModelPart*>* (*getAdditionalModelParts)(std::uint32_t dwSkinID),
std::vector<ModelPart*>* (*setAdditionalSkinBoxesFromVec)(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* 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<SKIN_BOX*>* getAdditionalSkinBoxes(
std::uint32_t dwSkinID);
[[nodiscard]] std::vector<ModelPart*>* getAdditionalModelParts(
std::uint32_t dwSkinID);
std::vector<ModelPart*>* setAdditionalSkinBoxesFromVec(
std::uint32_t dwSkinID, std::vector<SKIN_BOX*>* 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<std::uint8_t> (*getArchiveFile)(const std::wstring&)
);
[[nodiscard]] bool hasArchiveFile(const std::wstring& filename);
[[nodiscard]] std::vector<std::uint8_t> 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<std::wstring>* skinNames,
std::vector<FEATURE_DATA*>* terrainFeatures
);
[[nodiscard]] DLCManager& getDLCManager();
[[nodiscard]] GameRuleManager& getGameRules();
[[nodiscard]] std::vector<std::wstring>& getSkinNames();
[[nodiscard]] std::vector<FEATURE_DATA*>& getTerrainFeatures();
void initMenuService(IMenuService* service);
[[nodiscard]] IMenuService& menus();
} // namespace GameServices

View file

@ -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<uint8_t> ba = app.getArchiveFile(archiveKey);
if (GameServices::hasArchiveFile(archiveKey)) {
std::vector<uint8_t> 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();
}
}

View file

@ -0,0 +1,66 @@
#pragma once
#include <memory>
#include <string>
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<LocalPlayer> player,
bool navigateBack = false) = 0;
virtual bool openCreative(int iPad, std::shared_ptr<LocalPlayer> player,
bool navigateBack = false) = 0;
virtual bool openCrafting2x2(int iPad,
std::shared_ptr<LocalPlayer> player) = 0;
virtual bool openCrafting3x3(int iPad, std::shared_ptr<LocalPlayer> player,
int x, int y, int z) = 0;
virtual bool openEnchanting(int iPad, std::shared_ptr<Inventory> inventory,
int x, int y, int z, Level* level,
const std::wstring& name) = 0;
virtual bool openFurnace(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<FurnaceTileEntity> furnace) = 0;
virtual bool openBrewingStand(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BrewingStandTileEntity> brewingStand) = 0;
virtual bool openContainer(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<Container> container) = 0;
virtual bool openTrap(int iPad, std::shared_ptr<Container> inventory,
std::shared_ptr<DispenserTileEntity> trap) = 0;
virtual bool openFireworks(int iPad, std::shared_ptr<LocalPlayer> player,
int x, int y, int z) = 0;
virtual bool openSign(int iPad,
std::shared_ptr<SignTileEntity> sign) = 0;
virtual bool openRepairing(int iPad, std::shared_ptr<Inventory> inventory,
Level* level, int x, int y, int z) = 0;
virtual bool openTrading(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Merchant> trader, Level* level,
const std::wstring& name) = 0;
virtual bool openCommandBlock(
int iPad, std::shared_ptr<CommandBlockEntity> commandBlock) = 0;
virtual bool openHopper(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<HopperTileEntity> hopper) = 0;
virtual bool openHopperMinecart(
int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<MinecartHopper> hopper) = 0;
virtual bool openHorse(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<Container> container,
std::shared_ptr<EntityHorse> horse) = 0;
virtual bool openBeacon(int iPad, std::shared_ptr<Inventory> inventory,
std::shared_ptr<BeaconTileEntity> beacon) = 0;
};

View file

@ -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 <assert.h>
@ -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<MultiplayerLocalPlayer>(
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<MultiplayerLocalPlayer> 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<MultiplayerLocalPlayer> 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> mob =
// std::dynamic_pointer_cast<Mob>(Creeper::_class->newInstance(
// level )); shared_ptr<Mob> 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<LocalPlayer>(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<LocalPlayer>(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<LocalPlayer>(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<int64_t>(app.SecondsToAutosave()) + L"s";
toWString<int64_t>(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);
}

View file

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

View file

@ -1,3 +1,6 @@
#include "minecraft/GameServices.h"
#include "minecraft/GameHostOptions.h"
#include "minecraft/util/Log.h"
#include "CreateWorldScreen.h"
#include <stddef.h>
@ -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();

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/locale/Strings.h"
#include "Gui.h"
#include <cmath>
@ -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<int>(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);
}

View file

@ -1,3 +1,4 @@
#include "minecraft/GameServices.h"
#include "PauseScreen.h"
#include <math.h>
@ -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

View file

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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "SelectWorldScreen.h"
#include <stdint.h>
@ -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));

View file

@ -1,3 +1,4 @@
#include "minecraft/GameServices.h"
#include "AbstractContainerScreen.h"
#include <wchar.h>
@ -248,7 +249,7 @@ void AbstractContainerScreen::renderTooltip(std::shared_ptr<ItemInstance> item,
}
if (!cleanedLines.empty()) {
lineColors[0] = app.GetHTMLColour(item->getRarity()->color);
lineColors[0] = GameServices::getHTMLColour(item->getRarity()->color);
}
renderTooltipInternal(cleanedLines, lineColors, xm, ym);

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "BeaconPowerButton.h"
#include <string>
@ -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";
}

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "CreativeInventoryScreen.h"
#include <GL/gl.h>
@ -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);

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "HumanoidModel.h"
#include <cmath>
@ -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);

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "MultiPlayerGameMode.h"
#include <vector>
@ -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<<eDebugSetting_InstantDestroy))
// ||(DebugSettings::isOn() &&
// DebugSettings::getMask(InputManager.GetPrimaryPad())&(1L<<eDebugSetting_InstantDestroy))
)) {
destroyBlock(x, y, z, face);
} else {

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "MultiPlayerLevel.h"
#include <float.h>
@ -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

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "MultiPlayerLocalPlayer.h"
#include <wchar.h>
@ -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<PlayerCommandPacket>( new
PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) )
); else connection->send( std::shared_ptr<PlayerCommandPacket>( new
@ -377,7 +379,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) {
if (getCustomSkin() != oldSkinIndex)
connection->send(std::shared_ptr<TextureAndGeometryChangePacket>(
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<TextureChangePacket>(
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;
}
*/

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/DebugSettings.h"
#include "Input.h"
#include <cmath>
@ -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");

View file

@ -1,3 +1,6 @@
#include "minecraft/client/IMenuService.h"
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "LocalPlayer.h"
#include <stdio.h>
@ -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> tileEntity) {
bool success;
if (tileEntity->GetType() == eTYPE_SIGNTILEENTITY) {
success = app.LoadSignEntryMenu(
success = GameServices::menus().openSign(
GetXboxPad(),
std::dynamic_pointer_cast<SignTileEntity>(tileEntity));
} else if (tileEntity->GetType() == eTYPE_COMMANDBLOCKTILEENTITY) {
success = app.LoadCommandBlockMenu(
success = GameServices::menus().openCommandBlock(
GetXboxPad(),
std::dynamic_pointer_cast<CommandBlockEntity>(tileEntity));
}
@ -608,7 +610,7 @@ bool LocalPlayer::openContainer(std::shared_ptr<Container> 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<HopperTileEntity> 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<MinecartHopper> 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<EntityHorse> 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<LocalPlayer>(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<LocalPlayer>(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<FurnaceTileEntity> 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<BeaconTileEntity> 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<DispenserTileEntity> 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<Merchant> 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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<ItemInstance> 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;

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "RemotePlayer.h"
#include <cmath>
@ -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;

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "GameRenderer.h"
#include <float.h>
@ -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<ItemInstance> 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);

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "ItemInHandRenderer.h"
#include <GL/gl.h>
@ -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();
}

View file

@ -1,3 +1,6 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/DebugSettings.h"
#include "minecraft/util/Log.h"
#include "LevelRenderer.h"
#include <GL/gl.h>
@ -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> 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();

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "Tesselator.h"
#include <GL/gl.h>
@ -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);
}

View file

@ -1,3 +1,4 @@
#include "minecraft/GameServices.h"
#include "Textures.h"
#include <assert.h>
@ -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);

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "EntityRenderDispatcher.h"
#include <assert.h>
@ -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);

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/GameHostOptions.h"
#include "LivingEntityRenderer.h"
#include <cmath>
@ -388,12 +390,12 @@ void LivingEntityRenderer::renderName(std::shared_ptr<LivingEntity> 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<LivingEntity> 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<LivingEntity> 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<LivingEntity> mob,
if (mob->instanceof(eTYPE_PLAYER)) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(mob);
if (app.isXuidDeadmau5(player->getXuid())) offs = -10;
if (GameServices::isXuidDeadmau5(player->getXuid())) offs = -10;
playerName = name;
} else {

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/GameHostOptions.h"
#include "PlayerRenderer.h"
#include <cmath>
@ -301,7 +303,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<LivingEntity> _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<LivingEntity> _mob,
// 4J Added override to stop rendering shadow if player is invisible
void PlayerRenderer::renderShadow(std::shared_ptr<Entity> 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> player = std::dynamic_pointer_cast<Player>(e);
if (player != nullptr && player->hasInvisiblePrivilege()) return;
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "PreStitchedTextureMap.h"
#include <format>
@ -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;

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "Stitcher.h"
#include <algorithm>
@ -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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "Texture.h"
#include <string.h>
@ -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);

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "TextureManager.h"
#include <wchar.h>
@ -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;

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "TextureMap.h"
#include <wchar.h>
@ -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

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "SignRenderer.h"
#include <cstdint>
@ -89,7 +90,7 @@ void SignRenderer::render(std::shared_ptr<TileEntity> _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<TileEntity> _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;
}
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "AbstractTexturePack.h"
#include <GL/gl.h>
@ -6,7 +7,7 @@
#include <vector>
#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<uint8_t> textColours =
app.getArchiveFile(L"HTMLColours.col");
GameServices::getArchiveFile(L"HTMLColours.col");
m_colourTable->loadColoursFromData(textColours.data(),
textColours.size());
}

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "DLCTexturePack.h"
#include <cstdint>
@ -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<uint8_t> 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;

View file

@ -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<uint8_t> ba =
app.getArchiveFile(L"Graphics\\TexturePackIcon.png");
GameServices::getArchiveFile(L"Graphics\\TexturePackIcon.png");
m_iconData = ba.data();
m_iconSize = static_cast<std::uint32_t>(ba.size());
}

View file

@ -2,8 +2,8 @@
#include <string>
#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

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "TexturePackRepository.h"
#include <wchar.h>
@ -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<File> TexturePackRepository::getWorkDirContents() {
app.DebugPrintf(
Log::info(
"TexturePackRepository::getWorkDirContents is not implemented\n");
return std::vector<File>();
}
@ -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);
}
}

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "TitleScreen.h"
#include <stdint.h>
@ -41,8 +43,8 @@ TitleScreen::TitleScreen() {
int splashIndex;
std::wstring filename = L"splashes.txt";
if (app.hasArchiveFile(filename)) {
std::vector<uint8_t> splashesArray = app.getArchiveFile(filename);
if (GameServices::hasArchiveFile(filename)) {
std::vector<uint8_t> 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();
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "CommandDispatcher.h"
#include <string>
@ -24,7 +25,7 @@ int CommandDispatcher::performCommand(std::shared_ptr<CommandSender> sender,
#endif
}
} else {
app.DebugPrintf("Command %d not found!\n", command);
Log::info("Command %d not found!\n", command);
}
return 0;

View file

@ -1,3 +1,4 @@
#include "minecraft/GameHostOptions.h"
#include "ItemDispenseBehaviors.h"
#include <memory>
@ -448,7 +449,7 @@ std::shared_ptr<ItemInstance> 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();

View file

@ -0,0 +1,16 @@
#include "minecraft/locale/Strings.h"
#include <cassert>
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

View file

@ -0,0 +1,12 @@
#pragma once
#include <cstdint>
namespace Strings {
using LookupFn = const wchar_t* (*)(int);
void init(LookupFn fn);
[[nodiscard]] const wchar_t* get(int id);
} // namespace Strings

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "BlockRegionUpdatePacket.h"
#include <assert.h>
@ -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");
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "CustomPayloadPacket.h"
#include <limits>
@ -30,7 +31,7 @@ CustomPayloadPacket::CustomPayloadPacket(const std::wstring& identifier,
length = data.size();
if (length > std::numeric_limits<short>::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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "GameCommandPacket.h"
#include <limits>
@ -23,7 +24,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command,
length = data.size();
if (length > std::numeric_limits<short>::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

View file

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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "Packet.h"
#include <assert.h>
@ -465,7 +466,7 @@ void Packet::writeBytes(DataOutputStream* dataoutputstream,
std::vector<uint8_t> 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> 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> Packet::readPacket(
assert(false); // throw new IOException(wstring(L"Bad packet id ") +
// toWString<int>(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);
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "PreLoginPacket.h"
#include <cstdint>
@ -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<std::uint8_t>(m_szUniqueSaveName[i]));
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "RespawnPacket.h"
#include <string>
@ -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

View file

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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "SetPlayerTeamPacket.h"
#include <unordered_set>
@ -40,13 +41,13 @@ SetPlayerTeamPacket::SetPlayerTeamPacket(PlayerTeam* team,
std::vector<std::wstring>* 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

View file

@ -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 <assert.h>
@ -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<uint8_t> 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<float>(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<ServerSettingsChangedPacket>(
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<UpdateProgressPacket>( 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

View file

@ -1,3 +1,6 @@
#include "minecraft/GameServices.h"
#include "minecraft/GameHostOptions.h"
#include "minecraft/util/Log.h"
#include "PlayerList.h"
#include <string.h>
@ -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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer>* PlayerList::getPlayers(
std::unordered_map<std::wstring, int>* 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<ServerPlayer>* PlayerList::getPlayers(
bool PlayerList::meetsScoreRequirements(
std::shared_ptr<Player> player,
std::unordered_map<std::wstring, int> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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<ServerPlayer> 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);

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "PlayerChunkMap.h"
#include <assert.h>
@ -64,12 +65,12 @@ void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int* flags,
void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> 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<ServerPlayer> player,
void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> 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<ServerPlayer> player) {
new ChunkVisibilityPacket(pos.x, pos.z, false)));
}
} else {
// app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer
// Log::info("PlayerChunkMap::PlayerChunk::remove - QNetPlayer
// is nullptr\n");
}
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "ServerChunkCache.h"
#include <assert.h>
@ -6,7 +7,7 @@
#include <algorithm>
#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();

View file

@ -1,3 +1,5 @@
#include "minecraft/util/DebugSettings.h"
#include "minecraft/util/Log.h"
#include "ServerLevel.h"
#include <assert.h>
@ -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<TickNextTickData>* 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<Explosion> ServerLevel::explode(std::shared_ptr<Entity> 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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "ServerLevelListener.h"
#include <memory>
@ -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> player,
float pitch,
float fSoundClipDist) {
if (iSound < 0) {
app.DebugPrintf(
Log::info(
"ServerLevelListener received request for sound less than 0, so "
"ignoring\n");
} else {

View file

@ -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 <assert.h>
@ -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(" - <NOT
// Log::info(" - <NOT
// OK>\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<BlockRegionUpdatePacket> 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<<eDebugSetting_GoToNether))
// if(DebugSettings::getMask(InputManager.GetPrimaryPad())&(1L<<eDebugSetting_GoToNether))
//{
// if(level->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<<eDebugSetting_GoToNether));
// uiVal=DebugSettings::getMask(InputManager.GetPrimaryPad());
// GameServices::setGameSettingsDebugMask(InputManager.GetPrimaryPad(),uiVal&~(1L<<eDebugSetting_GoToNether));
//}
// else if
// (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad())&(1L<<eDebugSetting_GoToEnd))
// (DebugSettings::getMask(InputManager.GetPrimaryPad())&(1L<<eDebugSetting_GoToEnd))
// {
// if(level->dimension->id == 0 )
// {
@ -603,19 +607,19 @@ void ServerPlayer::doTickB() {
// std::dynamic_pointer_cast<ServerPlayer>( shared_from_this() ), 1 );
// }
// unsigned int
// uiVal=app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad());
// app.SetGameSettingsDebugMask(InputManager.GetPrimaryPad(),uiVal&~(1L<<eDebugSetting_GoToEnd));
// uiVal=DebugSettings::getMask(InputManager.GetPrimaryPad());
// GameServices::setGameSettingsDebugMask(InputManager.GetPrimaryPad(),uiVal&~(1L<<eDebugSetting_GoToEnd));
// }
// else
if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
if (DebugSettings::getMask(InputManager.GetPrimaryPad()) &
(1L << eDebugSetting_GoToOverworld)) {
if (level->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>(
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<GameEventPacket>(
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> 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<HopperTileEntity> 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<MinecartHopper> 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<FurnaceTileEntity> 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<DispenserTileEntity> 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<BeaconTileEntity> 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<Merchant> 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<ChatPacket>( new ChatPacket(L"",
// messageType) ) );
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "ServerPlayerGameMode.h"
#include <vector>
@ -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<<eDebugSetting_InstantDestroy)
//) )))
{

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "TrackedEntity.h"
#include <assert.h>
@ -440,7 +441,7 @@ void TrackedEntity::broadcast(std::shared_ptr<Packet> 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<Player> plr = std::dynamic_pointer_cast<Player>(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<Packet> 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<Packet> 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<AddEntityPacket> packet =

View file

@ -1,3 +1,5 @@
#include "minecraft/GameHostOptions.h"
#include "minecraft/util/Log.h"
#include "PendingConnection.h"
#include <stdio.h>
@ -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<DisconnectPacket>(reason));
connection->sendAndQuit();
done = true;
@ -77,7 +79,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) {
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> 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<PreLoginPacket>(
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<LoginPacket> 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) {

View file

@ -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 <wchar.h>
@ -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<TexturePacket> 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<TexturePacket>(
@ -825,7 +829,7 @@ void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> 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<SKIN_BOX*>* pvSkinBoxes =
app.GetAdditionalSkinBoxes(packet->dwSkinID);
GameServices::getAdditionalSkinBoxes(packet->dwSkinID);
unsigned int uiAnimOverrideBitmask =
app.GetAnimOverrideBitmask(packet->dwSkinID);
GameServices::getAnimOverrideBitmask(packet->dwSkinID);
send(std::shared_ptr<TextureAndGeometryPacket>(
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<TexturePacket>(
@ -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<SKIN_BOX*>* pvSkinBoxes =
app.GetAdditionalSkinBoxes(dwSkinID);
GameServices::getAdditionalSkinBoxes(dwSkinID);
unsigned int uiAnimOverrideBitmask =
app.GetAnimOverrideBitmask(dwSkinID);
GameServices::getAnimOverrideBitmask(dwSkinID);
send(std::shared_ptr<TextureAndGeometryPacket>(
new TextureAndGeometryPacket(textureName, pbData,
@ -963,7 +967,7 @@ void PlayerConnection::handleTextureChange(
std::shared_ptr<TextureChangePacket> 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<TextureChangePacket>(
@ -1005,7 +1009,7 @@ void PlayerConnection::handleTextureChange(
void PlayerConnection::handleTextureAndGeometryChange(
std::shared_ptr<TextureAndGeometryChangePacket> 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<ServerSettingsChangedPacket>(
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<SignUpdatePacket> 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<ItemInstance> pTempItemInst =
pRecipeIngredientsRequired[iRecipe].pRecipy->assemble(nullptr);
if (app.DebugSettingsOn() &&
if (DebugSettings::isOn() &&
(player->GetDebugOptions() & (1L << eDebugSetting_CraftAnything))) {
pTempItemInst->onCraftedBy(
player->level,

View file

@ -1,3 +1,5 @@
#include "minecraft/GameHostOptions.h"
#include "minecraft/util/Log.h"
#include "ServerConnection.h"
#include <algorithm>
@ -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
// {

View file

@ -8,6 +8,7 @@
#include <vector>
#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<LocalPlayer> plr,
std::vector<uint8_t>& param) {
app.DebugPrintf("'Stat.h', Unhandled AwardStat blob.\n");
GameServices::debugPrintf("'Stat.h', Unhandled AwardStat blob.\n");
return;
}
};

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "StatsCounter.h"
#include <assert.h>
@ -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<Stat*, int>::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<Stat*>::iterator statsEnd = Stats::all->end();
for (std::vector<Stat*>::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));
}

View file

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

View file

@ -0,0 +1,33 @@
#include "minecraft/util/DebugSettings.h"
#include <cassert>
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

View file

@ -0,0 +1,20 @@
#pragma once
#include <cstdint>
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

View file

@ -4,7 +4,7 @@
#include <sstream>
#include <vector>
#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"<font color=\"#" << std::setfill(L'0') << std::setw(6) << std::hex
<< app.GetHTMLColor(color) << L"\">" << text << "</font>";
<< GameServices::getHTMLColor(color) << L"\">" << text << "</font>";
if (italics) {
ss << "</i>";

View file

@ -0,0 +1,15 @@
#pragma once
#include <cstdarg>
#include <cstdio>
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

View file

@ -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<Container> 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() {

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "SimpleContainer.h"
#include <vector>
@ -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() {

View file

@ -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) {

View file

@ -1,3 +1,5 @@
#include "minecraft/GameServices.h"
#include "minecraft/util/Log.h"
#include "Entity.h"
#include <stdarg.h>
@ -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 =

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "EntityIO.h"
#include <utility>
@ -330,7 +331,7 @@ std::shared_ptr<Entity> 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
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "LivingEntity.h"
#include <stdint.h>
@ -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);
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "Painting.h"
#include <memory>
@ -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

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "SyncedEntityData.h"
#include <assert.h>
@ -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;

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "AttributeModifier.h"
#include <assert.h>
@ -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);
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "EntityHorse.h"
#include <math.h>
@ -840,7 +841,7 @@ bool EntityHorse::mobInteract(std::shared_ptr<Player> player) {
}
doPlayerRide(player);
app.DebugPrintf(
Log::info(
"<EntityHorse::mobInteract> 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("<EntityHorse::generateRandomSpeed> Speed: %f\n", speed);
Log::info("<EntityHorse::generateRandomSpeed> Speed: %f\n", speed);
return speed;
}

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "Ocelot.h"
#include <stdint.h>
@ -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()

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "EnderDragon.h"
#include <algorithm>
@ -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<LivingEntity> e =
std::dynamic_pointer_cast<LivingEntity>(*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> 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> 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> 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<Player>(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;
}

View file

@ -5,7 +5,7 @@
#include <string>
#include <vector>
#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<double>& 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(); };
};

View file

@ -3,7 +3,7 @@
#include <memory>
#include <string>
#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); };
};

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "ItemEntity.h"
#include <stdint.h>
@ -280,7 +281,7 @@ std::shared_ptr<ItemInstance> 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?!");
}

View file

@ -1,3 +1,4 @@
#include "minecraft/locale/Strings.h"
#include "MinecartContainer.h"
#include <stdint.h>
@ -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() {

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "EnderMan.h"
#include <math.h>
@ -106,7 +107,7 @@ void EnderMan::readAdditionalSaveData(CompoundTag* tag) {
std::shared_ptr<Entity> EnderMan::findAttackTarget() {
#ifndef _FINAL_BUILD
if (app.GetMobsDontAttackEnabled()) {
if (DebugSettings::mobsDontAttack()) {
return std::shared_ptr<Player>();
}
#endif

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "Monster.h"
#include <math.h>
@ -48,7 +49,7 @@ void Monster::tick() {
std::shared_ptr<Entity> Monster::findAttackTarget() {
#ifndef _FINAL_BUILD
if (app.GetMobsDontAttackEnabled()) {
if (DebugSettings::mobsDontAttack()) {
return std::shared_ptr<Player>();
}
#endif

View file

@ -1,3 +1,4 @@
#include "minecraft/util/DebugSettings.h"
#include "PigZombie.h"
#include <string>
@ -93,7 +94,7 @@ void PigZombie::readAdditionalSaveData(CompoundTag* tag) {
std::shared_ptr<Entity> PigZombie::findAttackTarget() {
#ifndef _FINAL_BUILD
#ifdef _DEBUG_MENUS_ENABLED
if (app.GetMobsDontAttackEnabled()) {
if (DebugSettings::mobsDontAttack()) {
return std::shared_ptr<Player>();
}
#endif

View file

@ -1,3 +1,4 @@
#include "minecraft/util/Log.h"
#include "SharedMonsterAttributes.h"
#include <limits>
@ -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"));
}
}

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