Skip to content

Commit

Permalink
Moving conditional branches around
Browse files Browse the repository at this point in the history
  • Loading branch information
LBPHacker authored and jacob1 committed May 7, 2017
1 parent ce054bf commit e15bfac
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/gui/game/PropertyTool.cpp
Expand Up @@ -122,27 +122,14 @@ void PropertyWindow::SetProperty()
}
else
{
if(properties[property->GetOption().second].Type == StructProperty::ParticleType)
int type;
if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (type = sim->GetParticleType(value)) != -1)
{
int type = sim->GetParticleType(value);
if(type != -1)
{
v = type;

#ifdef DEBUG
std::cout << "Got type from particle name" << std::endl;
std::cout << "Got type from particle name" << std::endl;
#endif
v = type;
}
else
{
std::stringstream buffer(value);
buffer.exceptions(std::stringstream::failbit | std::stringstream::badbit);
buffer >> v;
}
if (property->GetOption().first == "type" && (v < 0 || v >= PT_NUM || !sim->elements[v].Enabled))
{
new ErrorMessage("Could not set property", "Invalid particle type");
return;
}
}
else
{
Expand All @@ -151,9 +138,17 @@ void PropertyWindow::SetProperty()
buffer >> v;
}
}

if (properties[property->GetOption().second].Type == StructProperty::ParticleType && (v < 0 || v >= PT_NUM || !sim->elements[v].Enabled))
{
new ErrorMessage("Could not set property", "Invalid particle type");
return;
}

#ifdef DEBUG
std::cout << "Got int value " << v << std::endl;
#endif

tool->propValue.Integer = v;
break;
}
Expand Down

0 comments on commit e15bfac

Please sign in to comment.