Merge branch 'main' into TU43

This commit is contained in:
/home/neo 2026-05-26 15:48:53 +03:00 committed by GitHub
commit e11fcb5274
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 85 additions and 38 deletions

View file

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

2
BUMP
View file

@ -1 +1 @@
1.0.6b
1.0.7b

View file

@ -56,8 +56,7 @@ enum EGameHostOptionWorldSize
e_worldSize_Classic,
e_worldSize_Small,
e_worldSize_Medium,
e_worldSize_Large,
e_worldSize_Expanded
e_worldSize_Large
};

View file

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

View file

@ -13,6 +13,7 @@ private:
public:
GuiParticles(Minecraft *mc);
~GuiParticles();
void tick();
void add(GuiParticle *guiParticle);
void render(float a);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -54,10 +54,16 @@ AABB *AABB::newPermanent(double x0, double y0, double z0, double x1, double y1,
void AABB::clearPool()
{
ThreadStorage *tls = static_cast<ThreadStorage *>(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)

View file

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

View file

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

View file

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

View file

@ -49,10 +49,16 @@ Vec3 *Vec3::newPermanent(double x, double y, double z)
void Vec3::clearPool()
{
ThreadStorage *tls = static_cast<ThreadStorage *>(TlsGetValue(tlsIdx));
if (tls != nullptr)
{
tls->poolPointer = 0;
}
}
void Vec3::resetPool()
{
clearPool();
}
Vec3 *Vec3::newTemp(double x, double y, double z)

View file

@ -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.
<img width="784" height="410" alt="roadmap" src="https://github.com/user-attachments/assets/134856ae-b151-4003-aa97-7ecf19ccd278" />