Files
GabsPuNs-Project_Zenith_Main/Minecraft.Client/GuiParticles.cpp
Zero 5ccc8db088 Fix multiple memory leaks and stale pooled allocations
* Fix Vec3/AABB pool reset logic

  * resetPool()/clearPool() now reset poolPointer to 0
  * Prevents endless pool growth, invalid temporary references,
    and increasing memory usage
  * Resolves the leaderboard-related crash mentioned in
    Windows64_Minecraft.cpp

* Properly free old screens in Minecraft::setScreen()

  * Added virtual destructor to Screen
  * Screen destructor now cleans up GuiParticles and Buttons
  * Previous screen is now deleted after screen transitions
  * Screen::init() now clears old buttons/particles before re-init

* Fix GuiParticles memory leak

  * Removed GuiParticle instances are now deleted in tick()
  * Added GuiParticles destructor to free remaining particles
2026-05-26 16:08:09 +02:00

65 lines
1.3 KiB
C++

#include "stdafx.h"
#include "GuiParticles.h"
#include "GuiParticle.h"
#include "Textures.h"
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++)
{
GuiParticle *gp = particles[i];
gp->preTick();
gp->tick(this);
if (gp->removed)
{
delete gp;
particles.erase(particles.begin()+i);
i--;
}
}
}
void GuiParticles::add(GuiParticle *guiParticle)
{
particles.push_back(guiParticle);
guiParticle->preTick();
}
void GuiParticles::render(float a)
{
// 4J Stu - Never used
#if 0
mc->textures->bindTexture(L"/gui/particles.png");
for ( GuiParticle *gp : particles )
{
int xx = (int) (gp->xo + (gp->x - gp->xo) * a - 4);
int yy = (int) (gp->yo + (gp->y - gp->yo) * a - 4);
float alpha = ((float) (gp->oA + (gp->a - gp->oA) * a));
float r = ((float) (gp->oR + (gp->r - gp->oR) * a));
float g = ((float) (gp->oG + (gp->g - gp->oG) * a));
float b = ((float) (gp->oB + (gp->b - gp->oB) * a));
glColor4f(r, g, b, alpha);
blit(xx, yy, 8 * 5, 0, 8, 8);
}
#endif
}