refactor: break World dependency on 4J modules via platform interfaces

This commit is contained in:
MatthewBeshay 2026-03-31 19:27:44 +11:00
parent 5c3668ec3c
commit 42839182cd
23 changed files with 93 additions and 80 deletions

View file

@ -2,6 +2,8 @@
#include <cstdint>
#include "4J.Storage/4J_Storage.h"
typedef struct {
wchar_t* wchFilename;
eFileExtensionType eEXT;

View file

@ -3,6 +3,9 @@
#include <cstdint>
#include <mutex>
#include "4J.Storage/4J_Storage.h"
#include "4J.Profile/4J_Profile.h"
// using namespace std;
#include "Source Files/Audio/Consoles_SoundEngine.h"

View file

@ -6,6 +6,7 @@
#include "UIEnums.h"
#include "../../../App_Defines.h"
#include "4J.Storage/4J_Storage.h"
class Container;
class Inventory;

View file

@ -52,6 +52,7 @@ client_dependencies = [
profile_dep,
storage_dep,
assets_localisation_dep,
platform_dep,
world_dep,
gl_dep,
glu_dep,
@ -99,9 +100,11 @@ elif occlusion_mode == 'hardware'
global_cpp_defs += ['-DOCCLUSION_MODE_HARDWARE', '-DUSE_OCCLUSION_CULLING']
endif
platform_services_src = files('../platform/PlatformServices.cpp')
client = executable(
'Minecraft.Client',
client_sources + platform_sources + localisation[1],
client_sources + platform_sources + platform_services_src + localisation[1],
include_directories: include_directories('Header Files', '..'),
dependencies: client_dependencies,
cpp_args: global_cpp_args

View file

@ -267,7 +267,7 @@ typedef enum _TEXTURE_NAME {
class Textures {
public:
static bool MIPMAP;
static C4JRender::eTextureFormat TEXTURE_FORMAT;
static IPlatformRender::eTextureFormat TEXTURE_FORMAT;
private:
static const wchar_t* preLoaded[TN_COUNT];
@ -328,7 +328,7 @@ public:
int loadTexture(int idx); // 4J added
int getTexture(
BufferedImage* img,
C4JRender::eTextureFormat format = C4JRender::TEXTURE_FORMAT_RxGyBzAw,
IPlatformRender::eTextureFormat format = IPlatformRender::TEXTURE_FORMAT_RxGyBzAw,
bool mipmap = true);
void loadTexture(BufferedImage* img, int id);
void loadTexture(BufferedImage* img, int id, bool blur, bool clamp);

View file

@ -18,7 +18,7 @@
#include "Minecraft.World/net/minecraft/world/level/storage/LevelData.h"
#include "Minecraft.Client/Common/Source Files/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "4J.Common/4J_Compat.h"
#include "4J_Storage.h"
#include "platform/IPlatformStorage.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFile.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSavePath.h"
#include "Minecraft.Client/Common/App_enums.h"
@ -72,7 +72,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(
}
if (pvSaveData == nullptr || fileSize == 0)
fileSize = StorageManager.GetSaveSize();
fileSize = PlatformStorage.GetSaveSize();
if (forceCleanSave) fileSize = 0;
@ -112,7 +112,7 @@ ConsoleSaveFileOriginal::ConsoleSaveFileOriginal(
}
} else {
unsigned int storageLength;
StorageManager.GetSaveData(pvSaveMem, &storageLength);
PlatformStorage.GetSaveData(pvSaveMem, &storageLength);
app.DebugPrintf("Filesize - %d, Adjusted size - %d\n", fileSize,
storageLength);
fileSize = storageLength;
@ -585,7 +585,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) {
// Attempt to allocate the required memory
// We do not own this, it belongs to the StorageManager
std::uint8_t* compData =
(std::uint8_t*)StorageManager.AllocateSaveData(compLength);
(std::uint8_t*)PlatformStorage.AllocateSaveData(compLength);
// If we failed to allocate then compData will be nullptr
// Pre-calculate the compressed data size so that we can attempt to allocate
@ -613,7 +613,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) {
compLength = compLength + 8;
// Attempt to allocate the required memory
compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength);
compData = (std::uint8_t*)PlatformStorage.AllocateSaveData(compLength);
}
if (compData != nullptr) {
@ -669,16 +669,16 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) {
int32_t saveOrCheckpointId = 0;
bool validSave =
StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId);
PlatformStorage.GetSaveUniqueNumber(&saveOrCheckpointId);
#ifdef _WINDOWS64
// set the icon and save image
StorageManager.SetSaveImages(pbThumbnailData, dwThumbnailDataSize,
PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize,
pbDataSaveImage, dwDataSizeSaveImage,
bTextMetadata, iTextMetadataBytes);
app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize);
// save the data
StorageManager.SaveSaveData(
PlatformStorage.SaveSaveData(
&ConsoleSaveFileOriginal::SaveSaveDataCallback, this);
#ifndef _CONTENT_PACKAGE
if (app.DebugSettingsOn()) {

View file

@ -19,7 +19,7 @@
#include "Minecraft.World/net/minecraft/world/level/storage/LevelData.h"
#include "Minecraft.Client/Common/Source Files/GameRules/LevelGeneration/LevelGenerationOptions.h"
#include "4J.Common/4J_Compat.h"
#include "4J_Storage.h"
#include "platform/IPlatformStorage.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFile.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSavePath.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"
@ -348,7 +348,7 @@ FileEntry* ConsoleSaveFileSplit::GetRegionFileEntry(unsigned int regionIndex) {
return it->second->fileEntry;
}
int index = StorageManager.AddSubfile(regionIndex);
int index = PlatformStorage.AddSubfile(regionIndex);
RegionFileReference* newRef = new RegionFileReference(index, regionIndex);
regionFiles[regionIndex] = newRef;
@ -371,7 +371,7 @@ ConsoleSaveFileSplit::ConsoleSaveFileSplit(
}
if (pvSaveData == nullptr || fileSize == 0)
fileSize = StorageManager.GetSaveSize();
fileSize = PlatformStorage.GetSaveSize();
if (forceCleanSave) fileSize = 0;
@ -432,13 +432,13 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData,
// Get details of region files. From this point on we are responsible for
// the memory that the storage manager initially allocated for them
unsigned int regionCount = StorageManager.GetSubfileCount();
unsigned int regionCount = PlatformStorage.GetSubfileCount();
for (unsigned int i = 0; i < regionCount; i++) {
unsigned int regionIndex;
unsigned char* regionDataCompressed;
unsigned int regionSizeCompressed;
StorageManager.GetSubfileDetails(i, (int*)&regionIndex,
PlatformStorage.GetSubfileDetails(i, (int*)&regionIndex,
(void**)&regionDataCompressed,
&regionSizeCompressed);
@ -486,7 +486,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData,
memcpy(pvSaveMem, pvSaveData, fileSize);
} else {
unsigned int storageLength;
StorageManager.GetSaveData(pvSaveMem, &storageLength);
PlatformStorage.GetSaveData(pvSaveMem, &storageLength);
app.DebugPrintf("Filesize - %d, Adjusted size - %d\n", fileSize,
storageLength);
fileSize = storageLength;
@ -565,7 +565,7 @@ ConsoleSaveFileSplit::~ConsoleSaveFileSplit() {
delete it->second;
}
StorageManager.ResetSubfiles();
PlatformStorage.ResetSubfiles();
}
// Add the file to our table of internal files if not already there
@ -888,12 +888,12 @@ void ConsoleSaveFileSplit::tick() {
std::int64_t currentTime = System::currentTimeMillis();
// Don't do anything if the save system is up to something...
if (StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle) {
if (PlatformStorage.GetSaveState() != IPlatformStorage::ESaveGame_Idle) {
return;
}
// ...or we shouldn't be saving...
if (StorageManager.GetSaveDisabled()) {
if (PlatformStorage.GetSaveDisabled()) {
return;
}
@ -967,7 +967,7 @@ void ConsoleSaveFileSplit::tick() {
// app.DebugPrintf("Tick: Writing region 0x%.8x, compressed
// as %d bytes\n",regionRef->fileEntry->getRegionFileIndex(),
// regionRef->dataCompressedSize);
StorageManager.UpdateSubfile(regionRef->index,
PlatformStorage.UpdateSubfile(regionRef->index,
regionRef->dataCompressed,
regionRef->dataCompressedSize);
regionRef->dirty = false;
@ -993,7 +993,7 @@ void ConsoleSaveFileSplit::tick() {
#endif
if (writeRequired) {
StorageManager.SaveSubfiles(SaveRegionFilesCallback, this);
PlatformStorage.SaveSubfiles(SaveRegionFilesCallback, this);
}
ReleaseSaveAccess();
@ -1238,7 +1238,7 @@ void ConsoleSaveFileSplit::processSubfilesForWrite() {
RegionFileReference* region = it->second;
if (region->dirty) {
region->Compress();
StorageManager.UpdateSubfile(region->index, region->dataCompressed,
PlatformStorage.UpdateSubfile(region->index, region->dataCompressed,
region->dataCompressedSize);
region->dirty = false;
region->lastWritten = System::currentTimeMillis();
@ -1249,7 +1249,7 @@ void ConsoleSaveFileSplit::processSubfilesForWrite() {
// Clean up any memory allocated for compressed data when we have finished
// writing
void ConsoleSaveFileSplit::processSubfilesAfterWrite() {
// This is called from the StorageManager.Tick() which should always be on
// This is called from the PlatformStorage.Tick() which should always be on
// the main thread
for (auto it = regionFiles.begin(); it != regionFiles.end(); it++) {
RegionFileReference* region = it->second;
@ -1270,7 +1270,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) {
// The storage manage might potentially be busy doing a sub-file write
// initiated from the tick. Wait until this is totally processed.
while (StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle) {
while (PlatformStorage.GetSaveState() != IPlatformStorage::ESaveGame_Idle) {
app.DebugPrintf("Flush wait\n");
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
@ -1299,7 +1299,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) {
// Attempt to allocate the required memory
// We do not own this, it belongs to the StorageManager
std::uint8_t* compData =
(std::uint8_t*)StorageManager.AllocateSaveData(compLength);
(std::uint8_t*)PlatformStorage.AllocateSaveData(compLength);
// If we failed to allocate then compData will be nullptr
// Pre-calculate the compressed data size so that we can attempt to allocate
@ -1328,7 +1328,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) {
compLength = compLength + 8;
// Attempt to allocate the required memory
compData = (std::uint8_t*)StorageManager.AllocateSaveData(compLength);
compData = (std::uint8_t*)PlatformStorage.AllocateSaveData(compLength);
}
if (compData != nullptr) {
@ -1381,7 +1381,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) {
Minecraft::GetInstance()->getCurrentTexturePackId());
// set the icon and save image
StorageManager.SetSaveImages(pbThumbnailData, dwThumbnailDataSize,
PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize,
pbDataSaveImage, dwDataSizeSaveImage,
bTextMetadata, iTextMetadataBytes);
app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize);
@ -1389,10 +1389,10 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) {
int32_t saveOrCheckpointId = 0;
bool validSave =
StorageManager.GetSaveUniqueNumber(&saveOrCheckpointId);
PlatformStorage.GetSaveUniqueNumber(&saveOrCheckpointId);
// save the data
StorageManager.SaveSaveData(&ConsoleSaveFileSplit::SaveSaveDataCallback,
PlatformStorage.SaveSaveData(&ConsoleSaveFileSplit::SaveSaveDataCallback,
this);
#if !defined(_CONTENT_PACKAGE)
if (app.DebugSettingsOn()) {
@ -1410,9 +1410,9 @@ int ConsoleSaveFileSplit::SaveSaveDataCallback(void* lpParam, bool bRes) {
// Don't save sub files on autosave (their always being saved anyway)
if (!pClass->m_autosave) {
// This is called from the StorageManager.Tick() which should always be
// This is called from the PlatformStorage.Tick() which should always be
// on the main thread
StorageManager.SaveSubfiles(SaveRegionFilesCallback, pClass);
PlatformStorage.SaveSubfiles(SaveRegionFilesCallback, pClass);
}
return 0;
}
@ -1420,7 +1420,7 @@ int ConsoleSaveFileSplit::SaveSaveDataCallback(void* lpParam, bool bRes) {
int ConsoleSaveFileSplit::SaveRegionFilesCallback(void* lpParam, bool bRes) {
ConsoleSaveFileSplit* pClass = (ConsoleSaveFileSplit*)lpParam;
// This is called from the StorageManager.Tick() which should always be on
// This is called from the PlatformStorage.Tick() which should always be on
// the main thread
pClass->processSubfilesAfterWrite();

View file

@ -66,17 +66,7 @@
#endif
#ifdef _WINDOWS64
#include "Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Profile.h"
#include "Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Render.h"
#include "Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Storage.h"
#include "Minecraft.Client/Platform/Windows64/4JLibs/inc/4J_Input.h"
#else
#include "4J_Profile.h"
#include "4J_Render.h"
#include "4J_Storage.h"
#include "4J_Input.h"
#endif
#include "platform/PlatformServices.h"
#include "Minecraft.Client/Common/Source Files/Network/GameNetworkManager.h"

View file

@ -36,10 +36,7 @@ lib_world = static_library('Minecraft.World',
nbt_dep,
java_dep,
assets_localisation_dep,
render_dep,
input_dep,
profile_dep,
storage_dep,
platform_dep,
simdutf_dep,
],
include_directories : include_directories('Header Files', '..'),

View file

@ -7,7 +7,6 @@
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "Minecraft.World/net/minecraft/stats/GenericStats.h"
#include "Ocelot.h"
#include "4J_Profile.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include "Minecraft.Client/Linux/Linux_App.h"
#include "SoundTypes.h"
@ -308,7 +307,7 @@ MobGroupData* Ocelot::finalizeMobSpawn(
setTame(true);
setCatType(extraData - 1);
setOwnerUUID(Minecraft::GetInstance()
->localplayers[InputManager.GetPrimaryPad()]
->localplayers[PlatformInput.GetPrimaryPad()]
->getUUID());
} else
#endif

View file

@ -167,7 +167,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr<ItemInstance> itemInstance,
// app.DebugPrintf("=== FOUND stronghold in
// terrain features list\n");
//
// app.SetXuiServerAction(InputManager.GetPrimaryPad(),eXuiServerAction_StrongholdPosition);
// app.SetXuiServerAction(PlatformInput.GetPrimaryPad(),eXuiServerAction_StrongholdPosition);
// }
// else
{

View file

@ -15,7 +15,6 @@
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.h"
#include "Minecraft.Client/Header Files/FrameProfiler.h"
#include "4J_Profile.h"
#include "Minecraft.Client/Common/App_enums.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
@ -2826,7 +2825,7 @@ void Level::tickWeather() {
#if !defined(_FINAL_BUILD)
// debug setting added to disable weather
if (app.DebugSettingsOn()) {
if (app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
if (app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_DisableWeather)) {
levelData->setThundering(false);
levelData->setThunderTime(random->nextInt(TICKS_PER_DAY * 7) +

View file

@ -349,7 +349,7 @@ int64_t BiomeSource::findSeed(LevelType* generator) {
#if !defined(_CONTENT_PACKAGE)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
// Do nothing
} else
@ -456,7 +456,7 @@ int64_t BiomeSource::findSeed(LevelType* generator) {
char buf[256];
sprintf(buf, "GAME:\\BiomeTest%d.bmp", k);
RenderManager.SaveTextureData(buf, &srcInfo, (int*)pixels);
PlatformRender.SaveTextureData(buf, &srcInfo, (int*)pixels);
delete[] pixels;
delete biomeSource;

View file

@ -8,7 +8,6 @@
#include "Minecraft.World/ConsoleHelpers/ThreadName.h"
#include "Minecraft.World/net/minecraft/world/level/storage/LevelData.h"
#include "McRegionChunkStorage.h"
#include "4J_Profile.h"
#include "Minecraft.World/ConsoleHelpers/C4JThread.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFile.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h"
@ -180,7 +179,7 @@ LevelChunk* McRegionChunkStorage::load(Level* level, int x, int z) {
}
#if !defined(_CONTENT_PACKAGE)
if (levelChunk && app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
// 4J Stu - This will force an update of the chunk's biome array
levelChunk->reloadBiomes();

View file

@ -9,7 +9,6 @@
#include "java/File.h"
#include "OldChunkStorage.h"
#include "4J_Profile.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/FileHeader.h"
#include "Minecraft.World/ConsoleHelpers/Definitions.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
@ -470,7 +469,7 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) {
#if !defined(_CONTENT_PACKAGE)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
// Read the biome data from the stream, but don't use it
std::vector<uint8_t> dummyBiomes(levelChunk->biomes.size());
@ -584,7 +583,7 @@ LevelChunk* OldChunkStorage::load(Level* level, CompoundTag* tag) {
#if !defined(_CONTENT_PACKAGE)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
// Do nothing
} else

View file

@ -10,7 +10,6 @@
#include "TheEndDimension.h"
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
#include "4J_Profile.h"
#include "Minecraft.Client/Common/App_enums.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
#include "Minecraft.Client/Linux/Linux_App.h"
@ -51,7 +50,7 @@ void Dimension::init() {
// 4J Stu - Added to enable overriding the heightmap from a loaded in data
// file
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
biomeSource = new BiomeSource(level);
} else
@ -86,7 +85,7 @@ ChunkSource* Dimension::createRandomLevelSource() const {
// 4J Stu - Added to enable overriding the heightmap from a loaded in data
// file
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableHeightWaterOverride)) {
return new CustomLevelSource(
level, level->getSeed(),

View file

@ -3,7 +3,6 @@
#include "HellDimension.h"
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
#include "4J_Profile.h"
#include "Minecraft.Client/Common/App_enums.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
#include "Minecraft.Client/Linux/Linux_App.h"
@ -48,7 +47,7 @@ void HellDimension::updateLightRamp() {
ChunkSource* HellDimension::createRandomLevelSource() const {
#ifdef _DEBUG_MENUS_ENABLED
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_SuperflatNether)) {
return new HellFlatLevelSource(level, level->getSeed());
} else

View file

@ -3,7 +3,6 @@
#include <vector>
#include "BiomeOverrideLayer.h"
#include "4J_Profile.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
#include "Minecraft.Client/Linux/Linux_App.h"
#include "Minecraft.World/net/minecraft/world/level/LevelType.h"
@ -113,7 +112,7 @@ std::vector<std::shared_ptr<Layer>> Layer::getDefaultLayers(int64_t seed, LevelT
#if !defined(_CONTENT_PACKAGE)
#if defined(_BIOME_OVERRIDE)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_EnableBiomeOverride)) {
biomeLayer =
std::shared_ptr<BiomeOverrideLayer>(new BiomeOverrideLayer(1));

View file

@ -11,8 +11,7 @@
#include "java/InputOutputStream/DataInputStream.h"
#include "LevelData.h"
#include "DirectoryLevelStorage.h"
#include "4J_Profile.h"
#include "4J_Storage.h"
#include "platform/IPlatformStorage.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFile.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h"
#include "Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.h"
@ -390,7 +389,7 @@ void DirectoryLevelStorage::save(std::shared_ptr<Player> player) {
playerDir.getName() + _toString(player->getXuid()) + L".dat");
// If saves are disabled (e.g. because we are writing the save buffer to
// disk) then cache this player data
if (StorageManager.GetSaveDisabled()) {
if (PlatformStorage.GetSaveDisabled()) {
ByteArrayOutputStream* bos = new ByteArrayOutputStream();
NbtIo::writeCompressed(tag, bos);
@ -446,7 +445,7 @@ CompoundTag* DirectoryLevelStorage::loadPlayerDataTag(PlayerUID xuid) {
// 4J Added function
void DirectoryLevelStorage::clearOldPlayerFiles() {
if (StorageManager.GetSaveDisabled()) return;
if (PlatformStorage.GetSaveDisabled()) return;
std::vector<FileEntry*>* playerFiles =
m_saveFile->getFilesWithPrefix(playerDir.getName());
@ -454,7 +453,7 @@ void DirectoryLevelStorage::clearOldPlayerFiles() {
if (playerFiles != nullptr) {
#if !defined(_FINAL_BUILD)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_DistributableSave)) {
for (unsigned int i = 0; i < playerFiles->size(); ++i) {
FileEntry* file = playerFiles->at(i);
@ -500,7 +499,7 @@ std::wstring DirectoryLevelStorage::getLevelId() { return levelId; }
void DirectoryLevelStorage::flushSaveFile(bool autosave) {
#if !defined(_CONTENT_PACKAGE)
if (app.DebugSettingsOn() &&
app.GetGameSettingsDebugMask(InputManager.GetPrimaryPad()) &
app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) &
(1L << eDebugSetting_DistributableSave)) {
// Delete gamerules files if it exists
ConsoleSavePath gameRulesFiles(GAME_RULE_SAVENAME);
@ -615,7 +614,7 @@ int DirectoryLevelStorage::getAuxValueForMap(PlayerUID xuid, int dimension,
}
void DirectoryLevelStorage::saveMapIdLookup() {
if (StorageManager.GetSaveDisabled()) return;
if (PlatformStorage.GetSaveDisabled()) return;
#if defined(_LARGE_WORLDS)
ConsoleSavePath file = getDataFile(L"largeMapDataMappings");
@ -704,7 +703,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) {
if (m_saveFile->doesFileExist(file)) {
// If we can't actually delete this file, store the name so we
// can delete it later
if (StorageManager.GetSaveDisabled())
if (PlatformStorage.GetSaveDisabled())
m_mapFilesToDelete.push_back(itMap->second);
else
m_saveFile->deleteFile(m_saveFile->createFile(file));
@ -728,7 +727,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) {
if (m_saveFile->doesFileExist(file)) {
// If we can't actually delete this file, store the name so we
// can delete it later
if (StorageManager.GetSaveDisabled())
if (PlatformStorage.GetSaveDisabled())
m_mapFilesToDelete.push_back(i);
else
m_saveFile->deleteFile(m_saveFile->createFile(file));
@ -742,7 +741,7 @@ void DirectoryLevelStorage::deleteMapFilesForPlayer(PlayerUID xuid) {
}
void DirectoryLevelStorage::saveAllCachedData() {
if (StorageManager.GetSaveDisabled()) return;
if (PlatformStorage.GetSaveDisabled()) return;
// Save any files that were saved while saving was disabled
for (auto it = m_cachedSaveData.begin(); it != m_cachedSaveData.end();

View file

@ -29,7 +29,7 @@ SignTileEntity::SignTileEntity() : TileEntity() {
SignTileEntity::~SignTileEntity() {
// TODO ORBIS_STUBBED;
// 4J-PB - we don't need to verify strings anymore -
// InputManager.CancelQueuedVerifyStrings(&SignTileEntity::StringVerifyCallback,(void*)this);
// PlatformInput.CancelQueuedVerifyStrings(&SignTileEntity::StringVerifyCallback,(void*)this);
}
void SignTileEntity::save(CompoundTag* tag) {
@ -120,7 +120,7 @@ void SignTileEntity::setChanged() {
// at this point, we can ask the online string verifier if our sign
text is ok #if 0 m_bVerified=true; #else
if(!InputManager.VerifyStrings((wchar_t**)&wcMessages,MAX_SIGN_LINES,&SignTileEntity::StringVerifyCallback,(void*)this))
if(!PlatformInput.VerifyStrings((wchar_t**)&wcMessages,MAX_SIGN_LINES,&SignTileEntity::StringVerifyCallback,(void*)this))
{
// Nothing to verify
m_bVerified=true;

View file

@ -4,7 +4,7 @@
#include <string>
#include "TileEntity.h"
#include "4J_Input.h"
#include "platform/IPlatformInput.h"
#include "java/Class.h"
#include "Minecraft.World/net/minecraft/world/entity/player/Player.h"

View file

@ -0,0 +1,10 @@
#include "PlatformServices.h"
#include "../4J.Input/4J_Input.h"
#include "../4J.Profile/4J_Profile.h"
#include "../4J.Render/4J_Render.h"
#include "../4J.Storage/4J_Storage.h"
IPlatformInput& PlatformInput = InputManager;
IPlatformProfile& PlatformProfile = ProfileManager;
IPlatformRender& PlatformRender = RenderManager;
IPlatformStorage& PlatformStorage = StorageManager;

View file

@ -0,0 +1,15 @@
#pragma once
#include "IPlatformInput.h"
#include "IPlatformProfile.h"
#include "IPlatformRender.h"
#include "IPlatformStorage.h"
// Interface references to platform services. World code uses these
// instead of the concrete 4J globals directly. The bindings are
// established by the app layer at startup.
extern IPlatformInput& PlatformInput;
extern IPlatformProfile& PlatformProfile;
extern IPlatformRender& PlatformRender;
extern IPlatformStorage& PlatformStorage;