Fixed bug causing SIGSEGV at startup.

This commit is contained in:
Tiberiu Chibici 2016-12-10 17:48:35 +02:00
parent bb2ddf1374
commit 6fe33a99a8

View File

@ -54,7 +54,7 @@ template <>
components::Map* parse<components::Map> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Map")
if (root.size() > 0 && root.front().first == "Map")
root = root.front().second;
// This object can be declared in another file
@ -106,7 +106,7 @@ components::Map* parse<components::Map> (boost::property_tree::ptree& root)
template <>
components::basic::Camera* parse<components::basic::Camera> (boost::property_tree::ptree& root)
{
if (root.front().first == "Camera")
if (root.size() > 0 && root.front().first == "Camera")
root = root.front().second;
components::basic::Camera* camera = new components::basic::Camera();
@ -119,7 +119,7 @@ template <>
components::basic::Frame* parse<components::basic::Frame> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Frame")
if (root.size() > 0 && root.front().first == "Frame")
root = root.front().second;
components::basic::Frame* frame = new components::basic::Frame();
@ -142,7 +142,7 @@ template <>
components::basic::Grid* parse<components::basic::Grid> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Grid")
if (root.size() > 0 && root.front().first == "Grid")
root = root.front().second;
components::basic::Grid* grid = new components::basic::Grid();
@ -162,7 +162,7 @@ template <>
components::basic::Sprite* parse<components::basic::Sprite> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Sprite")
if (root.size() > 0 && root.front().first == "Sprite")
root = root.front().second;
// This object can be declared in another file
@ -196,7 +196,7 @@ template <>
components::basic::SpriteState* parse<components::basic::SpriteState> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "SpriteState")
if (root.size() > 0 && root.front().first == "SpriteState")
root = root.front().second;
components::basic::SpriteState* spriteState = new components::basic::SpriteState();
@ -219,7 +219,7 @@ template <>
components::basic::Transform* parse<components::basic::Transform> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Transform")
if (root.size() > 0 && root.front().first == "Transform")
root = root.front().second;
components::basic::Transform* transform = new components::basic::Transform();
@ -235,7 +235,7 @@ template <>
components::DebugController* parse<components::DebugController> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "DebugController")
if (root.size() > 0 && root.front().first == "DebugController")
root = root.front().second;
components::DebugController* controller = new components::DebugController();
@ -246,7 +246,7 @@ template <>
components::environment::GameTime* parse<components::environment::GameTime> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "GameTime")
if (root.size() > 0 && root.front().first == "GameTime")
root = root.front().second;
components::environment::GameTime* gameTime = new components::environment::GameTime();
@ -271,7 +271,7 @@ template <>
components::environment::Weather* parse<components::environment::Weather> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Weather")
if (root.size() > 0 && root.front().first == "Weather")
root = root.front().second;
components::environment::Weather* weather = new components::environment::Weather();
@ -287,7 +287,7 @@ template <>
components::items::Axe* parse<components::items::Axe> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Axe")
if (root.size() > 0 && root.front().first == "Axe")
root = root.front().second;
// Parse
@ -298,7 +298,7 @@ template <>
components::items::Giftable* parse<components::items::Giftable> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Giftable")
if (root.size() > 0 && root.front().first == "Giftable")
root = root.front().second;
// Parse
@ -309,7 +309,7 @@ template <>
components::items::Hoe* parse<components::items::Hoe> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Hoe")
if (root.size() > 0 && root.front().first == "Hoe")
root = root.front().second;
// Parse
@ -320,7 +320,7 @@ template <>
components::items::Item* parse<components::items::Item> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Item")
if (root.size() > 0 && root.front().first == "Item")
root = root.front().second;
// Parse
@ -336,7 +336,7 @@ template <>
components::items::Pickaxe* parse<components::items::Pickaxe> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Pickaxe")
if (root.size() > 0 && root.front().first == "Pickaxe")
root = root.front().second;
// Parse
@ -347,7 +347,7 @@ template <>
components::items::Scythe* parse<components::items::Scythe> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Pickaxe")
if (root.size() > 0 && root.front().first == "Pickaxe")
root = root.front().second;
// Parse
@ -358,7 +358,7 @@ template <>
components::items::WateringCan* parse<components::items::WateringCan> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "WateringCan")
if (root.size() > 0 && root.front().first == "WateringCan")
root = root.front().second;
// Parse
@ -373,7 +373,7 @@ template <>
components::items::Weapon* parse<components::items::Weapon> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Weapon")
if (root.size() > 0 && root.front().first == "Weapon")
root = root.front().second;
// Parse
@ -389,7 +389,7 @@ template <>
components::plants::Plant* parse<components::plants::Plant> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Plant")
if (root.size() > 0 && root.front().first == "Plant")
root = root.front().second;
// Parse
@ -414,7 +414,7 @@ template <>
components::plants::Seed* parse<components::plants::Seed> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Seed")
if (root.size() > 0 && root.front().first == "Seed")
root = root.front().second;
// Parse
@ -427,7 +427,7 @@ template <>
components::player::PlayerInventory* parse<components::player::PlayerInventory> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "PlayerInventory")
if (root.size() > 0 && root.front().first == "PlayerInventory")
root = root.front().second;
components::player::PlayerInventory* controller = new components::player::PlayerInventory();
@ -441,7 +441,7 @@ template <>
components::player::PlayerMovement* parse<components::player::PlayerMovement> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "PlayerMovement")
if (root.size() > 0 && root.front().first == "PlayerMovement")
root = root.front().second;
components::player::PlayerMovement* controller = new components::player::PlayerMovement();
@ -457,7 +457,7 @@ template <>
graphics::MapRenderer* parse<graphics::MapRenderer> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "MapRenderer")
if (root.size() > 0 && root.front().first == "MapRenderer")
root = root.front().second;
graphics::MapRenderer* renderer = new graphics::MapRenderer();
@ -468,7 +468,7 @@ template <>
graphics::SpriteRenderer* parse<graphics::SpriteRenderer> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "SpriteRenderer")
if (root.size() > 0 && root.front().first == "SpriteRenderer")
root = root.front().second;
graphics::SpriteRenderer* renderer = new graphics::SpriteRenderer();
@ -482,7 +482,7 @@ template <>
model::GameObject* parse<model::GameObject> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "GameObject")
if (root.size() > 0 && root.front().first == "GameObject")
root = root.front().second;
model::GameObject* gameObj = new model::GameObject();
@ -579,7 +579,7 @@ template <>
model::Configuration* parse<model::Configuration> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Configuration")
if (root.size() > 0 && root.front().first == "Configuration")
root = root.front().second;
model::Configuration* config = new model::Configuration();
@ -592,7 +592,7 @@ template <>
model::Scene* parse<model::Scene> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "Scene")
if (root.size() > 0 && root.front().first == "Scene")
root = root.front().second;
model::Scene* scene = new model::Scene();
@ -615,7 +615,7 @@ template<>
model::TileSet* parse<model::TileSet> (boost::property_tree::ptree& root)
{
// Ensure we are on the correct node (property tree seems to add root of its own)
if (root.front().first == "TileSet")
if (root.size() > 0 && root.front().first == "TileSet")
root = root.front().second;
// This object can be declared in another file