diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 12d5fe38..c4514c62 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -62,7 +62,7 @@ body: - type: input id: itsrevela attributes: - label: Is this reproducable in itsRevela/LCE-Revelations? (https://github.com/itsRevela/LCE-Revelations) + label: Is this reproducable in itsRevela/LCE-Revelations? (https://git.revela.dev/itsRevela/LCE-Revelations) description: If this was a "no idea" or similar, it will be rejected. validations: required: true diff --git a/BUMP b/BUMP index 24a364be..ce96854b 100644 --- a/BUMP +++ b/BUMP @@ -1 +1 @@ -1.0.6b +1.0.7b diff --git a/Minecraft.Client/Common/App_Defines.h b/Minecraft.Client/Common/App_Defines.h index 8d741041..aad6bbcf 100644 --- a/Minecraft.Client/Common/App_Defines.h +++ b/Minecraft.Client/Common/App_Defines.h @@ -56,8 +56,7 @@ enum EGameHostOptionWorldSize e_worldSize_Classic, e_worldSize_Small, e_worldSize_Medium, - e_worldSize_Large, - e_worldSize_Expanded + e_worldSize_Large }; diff --git a/Minecraft.Client/GuiParticles.cpp b/Minecraft.Client/GuiParticles.cpp index 79240288..864ea29e 100644 --- a/Minecraft.Client/GuiParticles.cpp +++ b/Minecraft.Client/GuiParticles.cpp @@ -8,6 +8,15 @@ GuiParticles::GuiParticles(Minecraft *mc) this->mc = mc; } +GuiParticles::~GuiParticles() +{ + for (GuiParticle *gp : particles) + { + delete gp; + } + particles.clear(); +} + void GuiParticles::tick() { for (unsigned int i = 0; i < particles.size(); i++) @@ -19,6 +28,7 @@ void GuiParticles::tick() if (gp->removed) { + delete gp; particles.erase(particles.begin()+i); i--; } diff --git a/Minecraft.Client/GuiParticles.h b/Minecraft.Client/GuiParticles.h index 0fe31811..cbfc089d 100644 --- a/Minecraft.Client/GuiParticles.h +++ b/Minecraft.Client/GuiParticles.h @@ -13,6 +13,7 @@ private: public: GuiParticles(Minecraft *mc); + ~GuiParticles(); void tick(); void add(GuiParticle *guiParticle); void render(float a); diff --git a/Minecraft.Client/MemTexture.h b/Minecraft.Client/MemTexture.h index d11d68b1..4afa799c 100644 --- a/Minecraft.Client/MemTexture.h +++ b/Minecraft.Client/MemTexture.h @@ -10,7 +10,14 @@ public: int id; bool isLoaded; int ticksSinceLastUse; - static const int UNUSED_TICKS_TO_FREE = 20; + // @CDevJoud + // changing the lifetime of the texture from 20 ticks(1 sec) to 200 ticks (10 sec) + // as it helps the texture to have longer lifetime and reducing the usage of loadTexture for every second/frame + // note that we dont remove the code that removes the textures from `tick()` as it is required in memory limited environment such as older Consoles(PS3/XBOX360) + static const int UNUSED_TICKS_TO_FREE = 200; + + //default ctor for int Texture::getHeight(const wstring& url, int backup) + MemTexture() = default; MemTexture(const wstring& _name, PBYTE pbData, DWORD dwBytes, MemTextureProcessor *processor); ~MemTexture(); diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index 8f67b1f4..05194bef 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -526,9 +526,10 @@ LevelStorageSource *Minecraft::getLevelSource() void Minecraft::setScreen(Screen *screen) { - if (this->screen != nullptr) + Screen *oldScreen = this->screen; + if (oldScreen != nullptr) { - this->screen->removed(); + oldScreen->removed(); } #ifdef _WINDOWS64 @@ -4438,6 +4439,8 @@ void Minecraft::setLevel(MultiPlayerLevel *level, int message /*=-1*/, shared_pt // 4J If we are setting the level to nullptr then we are exiting, so delete the levels if( level == nullptr ) { + if (soundEngine) soundEngine->stopElytraSound(); + if(levels[0]!=nullptr) { delete levels[0]; diff --git a/Minecraft.Client/MultiPlayerChunkCache.cpp b/Minecraft.Client/MultiPlayerChunkCache.cpp index a44279f8..19792432 100644 --- a/Minecraft.Client/MultiPlayerChunkCache.cpp +++ b/Minecraft.Client/MultiPlayerChunkCache.cpp @@ -94,7 +94,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level) this->level = level; this->cache = new LevelChunk *[XZSIZE * XZSIZE]; - memset(this->cache, 0, sizeof(LevelChunk*) * XZSIZE * XZSIZE); + memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk *)); InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000); } @@ -132,7 +132,7 @@ bool MultiPlayerChunkCache::reallyHasChunk(int x, int z) int idx = ix * XZSIZE + iz; LevelChunk *chunk = cache[idx]; - if (chunk == nullptr) + if( chunk == nullptr ) { return false; } @@ -145,8 +145,7 @@ void MultiPlayerChunkCache::drop(const int x, const int z) const int iz = z + XZOFFSET; if ((ix < 0) || (ix >= XZSIZE)) return; if ((iz < 0) || (iz >= XZSIZE)) return; - - int idx = ix * XZSIZE + iz; + const int idx = ix * XZSIZE + iz; LevelChunk* chunk = cache[idx]; if (chunk != nullptr && !chunk->isEmpty()) @@ -170,7 +169,6 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z) if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk ); int idx = ix * XZSIZE + iz; - LevelChunk *chunk = cache[idx]; LevelChunk *lastChunk = chunk; diff --git a/Minecraft.Client/Screen.cpp b/Minecraft.Client/Screen.cpp index 071b42cc..38a645bb 100644 --- a/Minecraft.Client/Screen.cpp +++ b/Minecraft.Client/Screen.cpp @@ -23,6 +23,18 @@ Screen::Screen() // 4J added clickedButton = nullptr; } +Screen::~Screen() +{ + delete particles; + particles = nullptr; + + for (Button *button : buttons) + { + delete button; + } + buttons.clear(); +} + void Screen::render(int xm, int ym, float a) { for (Button* button : buttons) diff --git a/Minecraft.Client/Screen.h b/Minecraft.Client/Screen.h index 6b2cb945..04f9296d 100644 --- a/Minecraft.Client/Screen.h +++ b/Minecraft.Client/Screen.h @@ -22,6 +22,7 @@ public: GuiParticles *particles; Screen(); // 4J added + virtual ~Screen(); virtual void render(int xm, int ym, float a); protected: virtual void keyPressed(wchar_t eventCharacter, int eventKey); diff --git a/Minecraft.Client/Textures.cpp b/Minecraft.Client/Textures.cpp index 627255b6..0db18171 100644 --- a/Minecraft.Client/Textures.cpp +++ b/Minecraft.Client/Textures.cpp @@ -1256,8 +1256,14 @@ int Textures::getHeight(const wstring& url, int backup) if (img) { + MemTexture* _texture = new MemTexture(); + _texture->loadedImage = img; + _texture->isLoaded = true; + _texture->id = getTexture(_texture->loadedImage, C4JRender::TEXTURE_FORMAT_RxGyBzAw, MIPMAP); + int h = img->getHeight(); - delete img; + //delete img; // commenting this out and inserting the loaded texture to memTextures unordered_map + this->memTextures[url] = _texture; return h; } diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 133d6092..178bda48 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -824,8 +824,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) return FALSE; } - ShowWindow(g_hWnd, (nCmdShow != SW_HIDE) ? SW_SHOWMAXIMIZED : nCmdShow); - UpdateWindow(g_hWnd); + return TRUE; } @@ -1456,8 +1455,9 @@ void CleanupDevice() static Minecraft* InitialiseMinecraftRuntime() { app.loadMediaArchive(); - - RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); + // @CDevJoud: No need to call this method as it gets called once in `InitDevice()` + // Calling it again and it results of 20MB of memory leak! + //RenderManager.Initialise(g_pd3dDevice, g_pSwapChain); app.loadStringTable(); ui.init(g_pd3dDevice, g_pImmediateContext, g_pRenderTargetView, g_pDepthStencilView, g_rScreenWidth, g_rScreenHeight); @@ -1791,6 +1791,20 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, hr = XuiTimersRun(); } #endif + + // @CDevJoud The window should only be shown after the engine/game + // initialization has fully completed. + // + // Showing the window too early especially on low end devices, + // may cause windows to display a "Not Responding" state while + // initialization is still in progress. + // + // This creates an unprofessional first impression for the player. + // Instead, initialize all engine systems first, then display the + // window once everything is ready. + ShowWindow(g_hWnd, (nCmdShow != SW_HIDE) ? SW_SHOWMAXIMIZED : nCmdShow); + UpdateWindow(g_hWnd); + MSG msg = {0}; while( WM_QUIT != msg.message && !app.m_bShutdown) { diff --git a/Minecraft.Server/ServerProperties.cpp b/Minecraft.Server/ServerProperties.cpp index 525be788..1b6c5c0a 100644 --- a/Minecraft.Server/ServerProperties.cpp +++ b/Minecraft.Server/ServerProperties.cpp @@ -628,8 +628,6 @@ static std::string WorldSizeToPropertyValue(int worldSize) return "medium"; case e_worldSize_Large: return "large"; - case e_worldSize_Expanded: - return "expanded"; case e_worldSize_Classic: default: return "classic"; @@ -646,8 +644,6 @@ static int WorldSizeToXzChunks(int worldSize) return LEVEL_WIDTH_MEDIUM; case e_worldSize_Large: return LEVEL_WIDTH_LARGE; - case e_worldSize_Expanded: - return LEVEL_WIDTH_EXPANDED; case e_worldSize_Classic: default: return LEVEL_WIDTH_CLASSIC; @@ -663,7 +659,6 @@ static int WorldSizeToHellScale(int worldSize) case e_worldSize_Medium: return HELL_LEVEL_SCALE_MEDIUM; case e_worldSize_Large: - case e_worldSize_Expanded: return HELL_LEVEL_SCALE_LARGE; case e_worldSize_Classic: default: @@ -699,12 +694,6 @@ static bool TryParseWorldSize(const std::string &lowered, int *outWorldSize) return true; } - if (lowered == "expanded" || lowered == "344" || lowered == "8") - { - *outWorldSize = e_worldSize_Expanded; - return true; - } - return false; } diff --git a/Minecraft.World/AABB.cpp b/Minecraft.World/AABB.cpp index af0501b4..b6fc1375 100644 --- a/Minecraft.World/AABB.cpp +++ b/Minecraft.World/AABB.cpp @@ -54,10 +54,16 @@ AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1, void AABB::clearPool() { + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + if (tls != nullptr) + { + tls->poolPointer = 0; + } } void AABB::resetPool() { + clearPool(); } AABB *AABB::newTemp(double x0, double y0, double z0, double x1, double y1, double z1) diff --git a/Minecraft.World/ChunkSource.h b/Minecraft.World/ChunkSource.h index 5b510ddb..37b0ecc3 100644 --- a/Minecraft.World/ChunkSource.h +++ b/Minecraft.World/ChunkSource.h @@ -7,14 +7,12 @@ class TilePos; // The maximum number of chunks that we can store #ifdef _LARGE_WORLDS // 4J Stu - Our default map (at zoom level 3) is 1024x1024 blocks (or 64 chunks) +#define LEVEL_MAX_WIDTH (5*64) //(6*54) + #define LEVEL_WIDTH_CLASSIC 54 #define LEVEL_WIDTH_SMALL 64 #define LEVEL_WIDTH_MEDIUM (3*64) #define LEVEL_WIDTH_LARGE (5*64) -#define LEVEL_WIDTH_EXPANDED (5*64) + 24 - - -#define LEVEL_MAX_WIDTH LEVEL_WIDTH_EXPANDED #else #define LEVEL_MAX_WIDTH 54 diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index 335c88ff..7cd3eb88 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -46,7 +46,6 @@ DWORD Level::tlsIdxLightCache = TlsAlloc(); // 4J : WESTY : Added for time played stats. #include "net.minecraft.stats.h" -#include "../Minecraft.Client/MultiPlayerChunkCache.h" // 4J - Caching of lighting data added. This is implemented as a 16x16x16 cache of ints (ie 16K storage in total). The index of the element to be used in the array is determined by the lower // four bits of each x/y/z position, and the upper 7/4/7 bits of the x/y/z positions are stored within the element itself along with the cached values etc. The cache can be enabled per thread by @@ -1338,7 +1337,7 @@ int Level::getBrightness(LightLayer::variety layer, int x, int y, int z) int idx = ix * chunkSourceXZSize + iz; LevelChunk *c = chunkSourceCache[idx]; - if( c == nullptr) return (int)layer; + if( c == nullptr ) return (int)layer; if (y < 0) y = 0; if (y >= maxBuildHeight) y = maxBuildHeight - 1; diff --git a/Minecraft.World/LevelData.cpp b/Minecraft.World/LevelData.cpp index e9f22fdb..0edd2d7e 100644 --- a/Minecraft.World/LevelData.cpp +++ b/Minecraft.World/LevelData.cpp @@ -185,7 +185,6 @@ LevelData::LevelData(CompoundTag *tag) case LEVEL_WIDTH_SMALL: hostOptionworldSize = e_worldSize_Small; break; case LEVEL_WIDTH_MEDIUM: hostOptionworldSize = e_worldSize_Medium; break; case LEVEL_WIDTH_LARGE: hostOptionworldSize = e_worldSize_Large; break; - case LEVEL_WIDTH_EXPANDED: hostOptionworldSize = e_worldSize_Expanded; break; default: assert(0); break; } app.SetGameHostOption(eGameHostOption_WorldSize, hostOptionworldSize ); diff --git a/Minecraft.World/Vec3.cpp b/Minecraft.World/Vec3.cpp index 75619bb0..cc9901a6 100644 --- a/Minecraft.World/Vec3.cpp +++ b/Minecraft.World/Vec3.cpp @@ -49,10 +49,16 @@ Vec3 *Vec3::newPermanent(double x, double y, double z) void Vec3::clearPool() { + ThreadStorage *tls = static_cast(TlsGetValue(tlsIdx)); + if (tls != nullptr) + { + tls->poolPointer = 0; + } } void Vec3::resetPool() { + clearPool(); } Vec3 *Vec3::newTemp(double x, double y, double z) diff --git a/NOTES.md b/NOTES.md index 01c3f9c2..5a3445e9 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,7 +1,6 @@ -# neoLegacy v1.0.5b +# neoLegacy v1.0.7b -### Bug Fixes -- Fixed crashing, lagging, and lighting issues caused by expanded world generation. +- Reverted "Expanded" world size due to it causing crashing and lighting issues. roadmap