Skip to content

Commit

Permalink
Check return value of some lisp.get calls
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Mar 16, 2015
1 parent a178705 commit 96b4e53
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/object/candle.cpp
Expand Up @@ -31,12 +31,26 @@ Candle::Candle(const Reader& lisp)
candle_light_1(SpriteManager::current()->create("images/objects/candle/candle-light-1.sprite")),
candle_light_2(SpriteManager::current()->create("images/objects/candle/candle-light-2.sprite"))
{
lisp.get("name", name);
lisp.get("burning", burning);
lisp.get("flicker", flicker);

if(!lisp.get("name", name))
{
log_warning << "Couldn't get \"name\" property for candle." << std::endl;
}
if(!lisp.get("burning", burning))
{
log_warning << "Couldn't get \"burning\" property for candle." << std::endl;
}
if(!lisp.get("flicker", flicker))
{
log_warning << "Couldn't get \"flicker\" property for candle." << std::endl;
}
//get color from lisp
std::vector<float> vColor;
lisp.get("color", vColor);
if(lisp.get("color", vColor))
{
log_warning << "Couldn't get \"color\" property for candle." << std::endl;
}

//change the light color if defined
if (vColor.size() >= 3) {
lightcolor = Color(vColor);
Expand Down

0 comments on commit 96b4e53

Please sign in to comment.