diff options
author | neoraider <devnull@localhost> | 2008-04-11 12:28:03 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2008-04-11 12:28:03 +0200 |
commit | 0c6471da931839b4e934d87df27ef208c74355c3 (patch) | |
tree | a9c42971c28f1cc9da8e68278d4f52646b88426c /src | |
parent | b27a517af7b8b99733622193a380bb3ef6674bcc (diff) | |
download | zoomedit-0c6471da931839b4e934d87df27ef208c74355c3.tar zoomedit-0c6471da931839b4e934d87df27ef208c74355c3.zip |
zoomedit:
* Added DTD validation of level files.
Diffstat (limited to 'src')
-rw-r--r-- | src/Instance.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Instance.cpp b/src/Instance.cpp index eb4d9dd..fe4b761 100644 --- a/src/Instance.cpp +++ b/src/Instance.cpp @@ -18,6 +18,7 @@ */ #include <iostream> +#include <libxml++/validators/dtdvalidator.h> #include "Instance.h" #include "Gui/Window.h" #include "Data/Level.h" @@ -103,11 +104,15 @@ void Instance::createLevel() { root->add_child("rooms"); root->add_child("gates"); root->add_child("textures"); + + level = new Data::Level(root); } bool Instance::loadLevel(const Glib::ustring &file) { - if(level) + if(level) { delete level; + level = NULL; + } if(levelXml) delete levelXml; @@ -115,8 +120,13 @@ bool Instance::loadLevel(const Glib::ustring &file) { levelXml = new xmlpp::DomParser(file); xmlpp::Document *doc = levelXml->get_document(); - if(doc && doc->get_root_node()) - level = new Data::Level(doc->get_root_node()); + if(!doc || !doc->get_root_node()) + return false; + + if(!xmlpp::DtdValidator("level.dtd").validate(doc)) + return false; + + level = new Data::Level(doc->get_root_node()); return (level != NULL); } |