diff --git a/minecraft/Minecraft.Client/Common/App_structs.h b/minecraft/Minecraft.Client/Common/App_structs.h index b8999074a..edbb71635 100644 --- a/minecraft/Minecraft.Client/Common/App_structs.h +++ b/minecraft/Minecraft.Client/Common/App_structs.h @@ -2,6 +2,8 @@ #include +#include "4J.Storage/4J_Storage.h" + typedef struct { wchar_t* wchFilename; eFileExtensionType eEXT; diff --git a/minecraft/Minecraft.Client/Common/Consoles_App.h b/minecraft/Minecraft.Client/Common/Consoles_App.h index b29e85540..106056cdb 100644 --- a/minecraft/Minecraft.Client/Common/Consoles_App.h +++ b/minecraft/Minecraft.Client/Common/Consoles_App.h @@ -3,6 +3,9 @@ #include #include +#include "4J.Storage/4J_Storage.h" +#include "4J.Profile/4J_Profile.h" + // using namespace std; #include "Source Files/Audio/Consoles_SoundEngine.h" diff --git a/minecraft/Minecraft.Client/Common/Source Files/UI/All Platforms/UIStructs.h b/minecraft/Minecraft.Client/Common/Source Files/UI/All Platforms/UIStructs.h index afdccb7fc..3f60a3526 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/UI/All Platforms/UIStructs.h +++ b/minecraft/Minecraft.Client/Common/Source Files/UI/All Platforms/UIStructs.h @@ -6,6 +6,7 @@ #include "UIEnums.h" #include "../../../App_Defines.h" +#include "4J.Storage/4J_Storage.h" class Container; class Inventory; diff --git a/minecraft/Minecraft.Client/meson.build b/minecraft/Minecraft.Client/meson.build index ab04627f0..972757c4c 100644 --- a/minecraft/Minecraft.Client/meson.build +++ b/minecraft/Minecraft.Client/meson.build @@ -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 diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/Textures.h b/minecraft/Minecraft.Client/net/minecraft/client/renderer/Textures.h index 458a83f03..ad8b6a9a0 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/Textures.h +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/Textures.h @@ -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); diff --git a/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp b/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp index 18cfdac2e..0041049cd 100644 --- a/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp +++ b/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp @@ -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()) { diff --git a/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp b/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp index 5476291ff..1a2a0b477 100644 --- a/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp +++ b/minecraft/Minecraft.World/ConsoleHelpers/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp @@ -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*)®ionIndex, + PlatformStorage.GetSubfileDetails(i, (int*)®ionIndex, (void**)®ionDataCompressed, ®ionSizeCompressed); @@ -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(); diff --git a/minecraft/Minecraft.World/Header Files/stdafx.h b/minecraft/Minecraft.World/Header Files/stdafx.h index 36fd77438..9ba4fb483 100644 --- a/minecraft/Minecraft.World/Header Files/stdafx.h +++ b/minecraft/Minecraft.World/Header Files/stdafx.h @@ -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" diff --git a/minecraft/Minecraft.World/meson.build b/minecraft/Minecraft.World/meson.build index 804a1fd12..a6d9553b2 100644 --- a/minecraft/Minecraft.World/meson.build +++ b/minecraft/Minecraft.World/meson.build @@ -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', '..'), diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp index d09778ceb..26ad65f2d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp @@ -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 diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp index a50603b32..8e90dd178 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/EnderEyeItem.cpp @@ -167,7 +167,7 @@ bool EnderEyeItem::TestUse(std::shared_ptr itemInstance, // app.DebugPrintf("=== FOUND stronghold in // terrain features list\n"); // - // app.SetXuiServerAction(InputManager.GetPrimaryPad(),eXuiServerAction_StrongholdPosition); + // app.SetXuiServerAction(PlatformInput.GetPrimaryPad(),eXuiServerAction_StrongholdPosition); // } // else { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp index 3395c0aac..855d68b3b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp @@ -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) + diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp index a0b718bfd..2a6b36b64 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/biome/BiomeSource.cpp @@ -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; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp index fd19157b6..432271684 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp @@ -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(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp index 858dd98a7..37cf2148e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/storage/OldChunkStorage.cpp @@ -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 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 diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp index 052daea88..112ae923e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp @@ -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(), diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp index fa5b519f5..fc767e2b8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/HellDimension.cpp @@ -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 diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp index 2f1cc48fb..68e4b9de8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/newbiome/layer/Layer.cpp @@ -3,7 +3,6 @@ #include #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> 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(new BiomeOverrideLayer(1)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp index d5e61dce7..192915b45 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/storage/DirectoryLevelStorage.cpp @@ -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) { 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* 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(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.cpp index 4c2772e65..700f69e10 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.cpp @@ -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; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.h b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.h index 23374fda2..6cc894f9c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.h +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/SignTileEntity.h @@ -4,7 +4,7 @@ #include #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" diff --git a/minecraft/platform/PlatformServices.cpp b/minecraft/platform/PlatformServices.cpp new file mode 100644 index 000000000..497bb805f --- /dev/null +++ b/minecraft/platform/PlatformServices.cpp @@ -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; diff --git a/minecraft/platform/PlatformServices.h b/minecraft/platform/PlatformServices.h new file mode 100644 index 000000000..0cab17cc0 --- /dev/null +++ b/minecraft/platform/PlatformServices.h @@ -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;