mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-03 04:52:35 +02:00
Include elements[].Enabled in check for invalid lava ctype
This commit is contained in:
@@ -1389,6 +1389,16 @@ std::string GameController::ElementResolve(int type, int ctype)
|
|||||||
return "";
|
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)
|
std::string GameController::WallName(int type)
|
||||||
{
|
{
|
||||||
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
|
if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->wtypes && type >= 0 && type < UI_WALLCOUNT)
|
||||||
|
@@ -137,6 +137,7 @@ public:
|
|||||||
ui::Point PointTranslate(ui::Point point);
|
ui::Point PointTranslate(ui::Point point);
|
||||||
ui::Point NormaliseBlockCoord(ui::Point point);
|
ui::Point NormaliseBlockCoord(ui::Point point);
|
||||||
std::string ElementResolve(int type, int ctype);
|
std::string ElementResolve(int type, int ctype);
|
||||||
|
bool IsValidElement(int type);
|
||||||
std::string WallName(int type);
|
std::string WallName(int type);
|
||||||
|
|
||||||
void ResetAir();
|
void ResetAir();
|
||||||
|
@@ -2069,7 +2069,7 @@ void GameView::OnDraw()
|
|||||||
ctype = sample.particle.tmp&0xFF;
|
ctype = sample.particle.tmp&0xFF;
|
||||||
if(showDebug)
|
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);
|
sampleInfo << "Molten " << c->ElementResolve(ctype, -1);
|
||||||
else if ((sample.particle.type == PT_PIPE || sample.particle.type == PT_PPIP) && ctype > 0 && ctype < PT_NUM)
|
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]);
|
sampleInfo << c->ElementResolve(sample.particle.type, -1) << " with " << c->ElementResolve(ctype, (int)sample.particle.pavg[1]);
|
||||||
@@ -2087,7 +2087,7 @@ void GameView::OnDraw()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
sampleInfo << c->ElementResolve(sample.particle.type, sample.particle.ctype);
|
||||||
if(ctype > 0 && ctype < PT_NUM)
|
if (c->IsValidElement(ctype))
|
||||||
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
|
sampleInfo << " (" << c->ElementResolve(ctype, -1) << ")";
|
||||||
else
|
else
|
||||||
sampleInfo << " ()";
|
sampleInfo << " ()";
|
||||||
|
@@ -3811,7 +3811,7 @@ void Simulation::update_particles_i(int start, int inc)
|
|||||||
s = 1;
|
s = 1;
|
||||||
|
|
||||||
//A fix for ice with ctype = 0
|
//A fix for ice with ctype = 0
|
||||||
if ((t==PT_ICEI || t==PT_SNOW) && (parts[i].ctype==0 || parts[i].ctype>=PT_NUM || parts[i].ctype==PT_ICEI || parts[i].ctype==PT_SNOW))
|
if ((t==PT_ICEI || t==PT_SNOW) && (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || parts[i].ctype==PT_ICEI || parts[i].ctype==PT_SNOW || !elements[parts[i].ctype].Enabled))
|
||||||
parts[i].ctype = PT_WATR;
|
parts[i].ctype = PT_WATR;
|
||||||
|
|
||||||
if (ctemph>elements[t].HighTemperature && elements[t].HighTemperatureTransition>-1)
|
if (ctemph>elements[t].HighTemperature && elements[t].HighTemperatureTransition>-1)
|
||||||
@@ -3838,7 +3838,7 @@ void Simulation::update_particles_i(int start, int inc)
|
|||||||
#endif
|
#endif
|
||||||
else if (t == PT_ICEI || t == PT_SNOW)
|
else if (t == PT_ICEI || t == PT_SNOW)
|
||||||
{
|
{
|
||||||
if (parts[i].ctype < PT_NUM && parts[i].ctype != t)
|
if (parts[i].ctype > 0 && parts[i].ctype < PT_NUM && parts[i].ctype != t)
|
||||||
{
|
{
|
||||||
if (elements[parts[i].ctype].LowTemperatureTransition==t && pt<=elements[parts[i].ctype].LowTemperature)
|
if (elements[parts[i].ctype].LowTemperatureTransition==t && pt<=elements[parts[i].ctype].LowTemperature)
|
||||||
s = 0;
|
s = 0;
|
||||||
@@ -3941,7 +3941,7 @@ void Simulation::update_particles_i(int start, int inc)
|
|||||||
}
|
}
|
||||||
else if (t == PT_LAVA)
|
else if (t == PT_LAVA)
|
||||||
{
|
{
|
||||||
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_LAVA)
|
if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_LAVA && parts[i].ctype!=PT_LAVA && elements[parts[i].ctype].Enabled)
|
||||||
{
|
{
|
||||||
if (parts[i].ctype==PT_THRM&&pt>=elements[PT_BMTL].HighTemperature)
|
if (parts[i].ctype==PT_THRM&&pt>=elements[PT_BMTL].HighTemperature)
|
||||||
s = 0;
|
s = 0;
|
||||||
|
Reference in New Issue
Block a user