Merge remote-tracking branch 'origin/main' into feat/minigames

This commit is contained in:
github-actions 2026-05-26 16:02:07 +00:00
commit 67ec8f7fb1
8 changed files with 85 additions and 37 deletions

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

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

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

@ -149,47 +149,57 @@ static void CopyWideArgToAnsi(LPCWSTR source, char* dest, size_t destSize)
dest[destSize - 1] = 0;
}
// ---------- Persistent options (options.txt next to exe) ----------
static void GetOptionsFilePath(char *out, size_t outSize)
// ---------- Persistent options (options.dat next to exe) ----------
static void GetOptionsFilePath(char *out, DWORD outSize)
{
GetModuleFileNameA(nullptr, out, static_cast<DWORD>(outSize));
char *p = strrchr(out, '\\');
if (p) *(p + 1) = '\0';
strncat_s(out, outSize, "options.txt", _TRUNCATE);
GetModuleFileNameA(nullptr, out, outSize);
char *p = strrchr(out, '\\');
if (p) *(p + 1) = '\0';
strncat_s(out, outSize, "settings.dat", _TRUNCATE);
}
static void SaveFullscreenOption(bool fullscreen)
{
char path[MAX_PATH];
GetOptionsFilePath(path, sizeof(path));
FILE *f = nullptr;
if (fopen_s(&f, path, "w") == 0 && f)
{
fprintf(f, "fullscreen=%d\n", fullscreen ? 1 : 0);
fclose(f);
}
GAME_SETTINGS settings = {};
char path[MAX_PATH] = {};
GetOptionsFilePath(path, MAX_PATH);
FILE *f = nullptr;
if (fopen_s(&f, path, "rb") == 0 && f)
{
fread(&settings, sizeof(GAME_SETTINGS), 1, f);
fclose(f);
}
if (fullscreen)
settings.uiBitmaskValues |= (1UL << 25);
else
settings.uiBitmaskValues &= ~(1UL << 25);
if (fopen_s(&f, path, "wb") == 0 && f)
{
fwrite(&settings, sizeof(GAME_SETTINGS), 1, f);
fclose(f);
}
}
static bool LoadFullscreenOption()
{
char path[MAX_PATH];
char path[MAX_PATH] = {};
GetOptionsFilePath(path, sizeof(path));
FILE *f = nullptr;
if (fopen_s(&f, path, "r") == 0 && f)
{
char line[256];
while (fgets(line, sizeof(line), f))
{
int val = 0;
if (sscanf_s(line, "fullscreen=%d", &val) == 1)
{
fclose(f);
return val != 0;
}
}
fclose(f);
}
return false;
FILE *f = nullptr;
if (fopen_s(&f, path, "rb") != 0 || !f)
return false;
GAME_SETTINGS current = {};
bool ok = (fread(&current, sizeof(GAME_SETTINGS), 1, f) == 1);
fclose(f);
if (!ok)
return false;
return (current.uiBitmaskValues & (1UL << 25)) != 0;
}
// ------------------------------------------------------------------
@ -824,7 +834,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
return FALSE;
}
return TRUE;
}
@ -1695,11 +1705,12 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
CleanupDevice();
return 0;
}
// Restore fullscreen state from previous session. Route through the
// deferred exclusive fullscreen path so the main loop applies it on the
// first tick (safer than transitioning during init).
if ((LoadFullscreenOption() && !g_isFullscreen) || launchOptions.fullscreen)
bool FullScreenEnabled = LoadFullscreenOption();
if (FullScreenEnabled && !g_isFullscreen)
{
g_bPendingExclusiveFullscreen = true;
g_bPendingExclusiveFullscreenValue = true;
@ -1764,7 +1775,7 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
return 1;
}
g_bResizeReady = true;
//app.TemporaryCreateGameStart();
//Sleep(10000);

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

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