From a1af662b8fad2cc654fdcfda2aeedec24659c908 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 14 Dec 2012 23:01:54 +0000 Subject: [PATCH] More accurate elementCount --- src/simulation/Simulation.cpp | 8 +++++--- src/simulation/Simulation.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 9c8bffded..f016112e0 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1951,6 +1951,7 @@ void Simulation::clear_sim(void) memset(portalp, 0, sizeof(portalp)); memset(fighters, 0, sizeof(fighters)); std::fill(elementCount, elementCount+PT_NUM, 0); + elementRecount = true; fighcount = 0; player.spwn = 0; player2.spwn = 0; @@ -3550,7 +3551,7 @@ void Simulation::update_particles_i(int start, int inc) ISWIRE--; } - bool elementRecount = !(currentTick%180); + elementRecount |= !(currentTick%180); if(elementRecount) { std::fill(elementCount, elementCount+PT_NUM, 0); @@ -3566,8 +3567,8 @@ void Simulation::update_particles_i(int start, int inc) continue; } - - elementCount[t]++; + if(elementRecount) + elementCount[t]++; elem_properties = elements[t].Properties; if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC)) @@ -4768,6 +4769,7 @@ Simulation::Simulation(): currentTick = 0; std::fill(elementCount, elementCount+PT_NUM, 0); + elementRecount = true; //Create and attach gravity simulation grav = new Gravity(); diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 9cdd3a7e8..d0accad67 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -74,6 +74,7 @@ public: int parts_lastActiveIndex;// = NPART-1; int pfree; int NUM_PARTS; + bool elementRecount; int elementCount[PT_NUM]; int ISWIRE; int force_stacking_check;