summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Instance.cpp16
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);
}