UpdateParticles takes a range that is inclusive on both ends

This commit is contained in:
Tamás Bálint Misius 2022-12-22 17:29:10 +01:00
parent 888e0f2065
commit ca93e69b19
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
4 changed files with 5 additions and 5 deletions

View File

@ -34,7 +34,7 @@ void ParticleDebug::Debug(int mode, int x, int y)
{ {
if (x < 0 || x >= XRES || y < 0 || y >= YRES || !sim->pmap[y][x] || (i = ID(sim->pmap[y][x])) < debug_currentParticle) if (x < 0 || x >= XRES || y < 0 || y >= YRES || !sim->pmap[y][x] || (i = ID(sim->pmap[y][x])) < debug_currentParticle)
{ {
i = NPART; i = NPART - 1;
logmessage = String::Build("Updated particles from #", debug_currentParticle, " to end, updated sim"); logmessage = String::Build("Updated particles from #", debug_currentParticle, " to end, updated sim");
} }
else else
@ -88,7 +88,7 @@ bool ParticleDebug::KeyPress(int key, int scan, bool shift, bool ctrl, bool alt,
return true; return true;
if (sim->debug_currentParticle > 0) if (sim->debug_currentParticle > 0)
{ {
sim->UpdateParticles(sim->debug_currentParticle, NPART); sim->UpdateParticles(sim->debug_currentParticle, NPART - 1);
sim->AfterSim(); sim->AfterSim();
String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end, updated sim"); String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end, updated sim");
model->Log(logmessage, false); model->Log(logmessage, false);

View File

@ -891,7 +891,7 @@ void GameController::Update()
sim->BeforeSim(); sim->BeforeSim();
if (!sim->sys_pause || sim->framerender) if (!sim->sys_pause || sim->framerender)
{ {
sim->UpdateParticles(0, NPART); sim->UpdateParticles(0, NPART - 1);
sim->AfterSim(); sim->AfterSim();
} }

View File

@ -1236,7 +1236,7 @@ void GameModel::SetPaused(bool pauseState)
if (!pauseState && sim->debug_currentParticle > 0) if (!pauseState && sim->debug_currentParticle > 0)
{ {
String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end due to unpause"); String logmessage = String::Build("Updated particles from #", sim->debug_currentParticle, " to end due to unpause");
sim->UpdateParticles(sim->debug_currentParticle, NPART); sim->UpdateParticles(sim->debug_currentParticle, NPART - 1);
sim->AfterSim(); sim->AfterSim();
sim->debug_currentParticle = 0; sim->debug_currentParticle = 0;
Log(logmessage, false); Log(logmessage, false);

View File

@ -162,7 +162,7 @@ public:
void set_emap(int x, int y); void set_emap(int x, int y);
int parts_avg(int ci, int ni, int t); int parts_avg(int ci, int ni, int t);
void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags); void create_arc(int sx, int sy, int dx, int dy, int midpoints, int variance, int type, int flags);
void UpdateParticles(int start, int end); void UpdateParticles(int start, int end); // range inclusive on both ends
void SimulateGoL(); void SimulateGoL();
void RecalcFreeParticles(bool do_life_dec); void RecalcFreeParticles(bool do_life_dec);
void CheckStacking(); void CheckStacking();