summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2013-09-08 08:21:08 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2013-09-08 08:26:31 (GMT)
commit79edfe9589c4b82ce320e0ae88d043b66b14f570 (patch)
tree476541f19227f01da686f9462d9f5b3fda685a35 /src/gui
parent8d96f3f6b6a872956cac4217c4a8f56d6316738b (diff)
downloadpowder-79edfe9589c4b82ce320e0ae88d043b66b14f570.zip
powder-79edfe9589c4b82ce320e0ae88d043b66b14f570.tar.gz
Include elements[].Enabled in check for invalid lava ctype
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/game/GameController.cpp10
-rw-r--r--src/gui/game/GameController.h1
-rw-r--r--src/gui/game/GameView.cpp4
3 files changed, 13 insertions, 2 deletions
diff --git a/src/gui/game/GameController.cpp b/src/gui/game/GameController.cpp
index 1235848..a114b82 100644
--- a/src/gui/game/GameController.cpp
+++ b/src/gui/game/GameController.cpp
@@ -1389,6 +1389,16 @@ std::string GameController::ElementResolve(int type, int ctype)
return "";
}
+bool GameController::IsValidElement(int type)
+{
+ if(gameModel && gameModel->GetSimulation())
+ {
+ return (type > 0 && type < PT_NUM && gameModel->GetSimulation()->elements[type].Enabled);
+ }
+ else
+ return false;
+}
+
std::string GameController::WallName(int type)
{
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
diff --git a/src/gui/game/GameController.h b/src/gui/game/GameController.h
index d723ccb..b2a7d99 100644
--- a/src/gui/game/GameController.h
+++ b/src/gui/game/GameController.h
@@ -137,6 +137,7 @@ public:
ui::Point PointTranslate(ui::Point point);
ui::Point NormaliseBlockCoord(ui::Point point);
std::string ElementResolve(int type, int ctype);
+ bool IsValidElement(int type);
std::string WallName(int type);
void ResetAir();
diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp
index 65f341a..5d0cc34 100644
--- a/src/gui/game/GameView.cpp
+++ b/src/gui/game/GameView.cpp
@@ -2069,7 +2069,7 @@ void GameView::OnDraw()
ctype = sample.particle.tmp&0xFF;
if(showDebug)
{
- if (sample.particle.type == PT_LAVA && ctype > 0 && ctype < PT_NUM)
+ if (sample.particle.type == PT_LAVA && c->IsValidElement(ctype))
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
@@ -2087,7 +2087,7 @@ void GameView::OnDraw()
else
{
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
- if(ctype > 0 && ctype < PT_NUM)
+ if (c->IsValidElement(ctype))
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
else
sampleInfo << " ()";