From 6fe33a99a8c7c580d470b814f6c9aecd4618ea91 Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Sat, 10 Dec 2016 17:48:35 +0200 Subject: [PATCH] Fixed bug causing SIGSEGV at startup. --- src/storage/Parsers.cpp | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/storage/Parsers.cpp b/src/storage/Parsers.cpp index dcece69..344c937 100644 --- a/src/storage/Parsers.cpp +++ b/src/storage/Parsers.cpp @@ -54,7 +54,7 @@ template <> components::Map* parse (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 (boost::property_tree::ptree& root) template <> components::basic::Camera* parse (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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