diff --git a/src/framework/ui/uiskins.cpp b/src/framework/ui/uiskins.cpp index 3dec15c7..d115489e 100644 --- a/src/framework/ui/uiskins.cpp +++ b/src/framework/ui/uiskins.cpp @@ -66,8 +66,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UIButtonSkin(name)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } @@ -79,8 +78,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::Panel)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } @@ -92,8 +90,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UIWindowSkin(name)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } @@ -105,8 +102,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UILabelSkin(name)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } @@ -119,8 +115,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UITextEditSkin(name)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } @@ -133,8 +128,7 @@ void UISkins::load(const std::string& skinsFile) it.first() >> name; UIElementSkinPtr skin = UIElementSkinPtr(new UIElementSkin(name, UI::LineDecoration)); - if(it.second().Type() == YAML::NodeType::Map) - skin->load(it.second()); + skin->load(it.second()); m_elementSkins.push_back(skin); } } diff --git a/src/framework/util/yaml.h b/src/framework/util/yaml.h index 98cf90c6..6b74b875 100644 --- a/src/framework/util/yaml.h +++ b/src/framework/util/yaml.h @@ -75,7 +75,8 @@ template inline T yamlRead(const YAML::Node& node, const char *name) { T value; - node[name] >> value; + if(node.Type() == YAML::NodeType::Map) + node[name] >> value; return value; } @@ -83,14 +84,14 @@ template inline T yamlRead(const YAML::Node& node, const char *name, const T& defaultValue) { T value = defaultValue; - if(node.FindValue(name)) + if(node.Type() == YAML::NodeType::Map && node.FindValue(name)) node[name] >> value; return value; } inline bool yamlHasValue(const YAML::Node& node, const char *name) { - return node.FindValue(name) != NULL; + return (node.Type() == YAML::NodeType::Map && node.FindValue(name) != NULL); } inline std::string yamlErrorDesc(const YAML::Node& node, const std::string& error) @@ -107,13 +108,15 @@ template inline std::map yamlReadMap(const YAML::Node& node, const char *name) { std::map map; - if(const YAML::Node* mapNode = node.FindValue(name)) { - for(auto it = mapNode->begin(); it != mapNode->end(); ++it) { - A a; - B b; - it.first() >> a; - it.second() >> b; - map[a] = b; + if(node.Type() == YAML::NodeType::Map) { + if(const YAML::Node* mapNode = node.FindValue(name)) { + for(auto it = mapNode->begin(); it != mapNode->end(); ++it) { + A a; + B b; + it.first() >> a; + it.second() >> b; + map[a] = b; + } } } return map; diff --git a/src/main.cpp b/src/main.cpp index d38bda02..18beb2c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,7 +115,7 @@ int main(int argc, const char *argv[]) g_engine.enableFpsCounter(); // load ui skins - g_uiSkins.load("skins/lightness.yml"); + g_uiSkins.load("skins/tibiaskin.yml"); // load script modules g_lua.loadAllModules();