zoomedit:
* Added DTD validation of level files.
This commit is contained in:
parent
b27a517af7
commit
0c6471da93
1 changed files with 13 additions and 3 deletions
|
@ -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,7 +120,12 @@ bool Instance::loadLevel(const Glib::ustring &file) {
|
|||
levelXml = new xmlpp::DomParser(file);
|
||||
xmlpp::Document *doc = levelXml->get_document();
|
||||
|
||||
if(doc && 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);
|
||||
|
|
Reference in a new issue