From b06f7f5b6db540a546f5677c1c8933e168df5e4c Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Tue, 14 Aug 2012 16:29:07 +0100 Subject: [PATCH] Air and heat tool limits, fixes #112 --- src/simulation/tools/Air.cpp | 4 ++++ src/simulation/tools/Cool.cpp | 4 ++++ src/simulation/tools/Heat.cpp | 4 ++++ src/simulation/tools/Vac.cpp | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/simulation/tools/Air.cpp b/src/simulation/tools/Air.cpp index b7b135132..9fd7f7967 100644 --- a/src/simulation/tools/Air.cpp +++ b/src/simulation/tools/Air.cpp @@ -12,6 +12,10 @@ Tool_Air::Tool_Air() int Tool_Air::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { sim->air->pv[y/CELL][x/CELL] += 0.03f*strength; + if(sim->air->pv[y/CELL][x/CELL] > 256.0f) + sim->air->pv[y/CELL][x/CELL] = 256.0f; + if(sim->air->pv[y/CELL][x/CELL] < -256.0f) + sim->air->pv[y/CELL][x/CELL] = -256.0f; return 1; } diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp index 12a6b2800..b1b57b170 100644 --- a/src/simulation/tools/Cool.cpp +++ b/src/simulation/tools/Cool.cpp @@ -13,6 +13,10 @@ int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, float s if(!cpart) return 0; cpart->temp -= strength; + if(cpart->temp > MAX_TEMP) + cpart->temp = MAX_TEMP; + if(cpart->temp < 0) + cpart->temp = 0; return 1; } diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp index a2c500c9c..f28274cad 100644 --- a/src/simulation/tools/Heat.cpp +++ b/src/simulation/tools/Heat.cpp @@ -13,6 +13,10 @@ int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, float s if(!cpart) return 0; cpart->temp += strength; + if(cpart->temp > MAX_TEMP) + cpart->temp = MAX_TEMP; + if(cpart->temp < 0) + cpart->temp = 0; return 1; } diff --git a/src/simulation/tools/Vac.cpp b/src/simulation/tools/Vac.cpp index 2777f7501..aa319e2c6 100644 --- a/src/simulation/tools/Vac.cpp +++ b/src/simulation/tools/Vac.cpp @@ -12,6 +12,10 @@ Tool_Vac::Tool_Vac() int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { sim->air->pv[y/CELL][x/CELL] -= 0.03f*strength; + if(sim->air->pv[y/CELL][x/CELL] > 256.0f) + sim->air->pv[y/CELL][x/CELL] = 256.0f; + if(sim->air->pv[y/CELL][x/CELL] < -256.0f) + sim->air->pv[y/CELL][x/CELL] = -256.0f; return 1; }