if ( path.empty() )
return NULL;
- std::cout << "File path: " << path << std::endl;
-- currentXML = std::string(xmlFolder + path);
- std::cout << "Full file path: " << currentXML << std::endl;
-
- xml.LoadFile(currentXML.c_str());
- wxml = xml.FirstChildElement("World");
++ currentXML = std::string(xmlFolder + path);
+ xml.LoadFile( currentXML.c_str() );
- if(wxml){
+ // attempt to load a <World> tag
+ if ( (wxml = xml.FirstChildElement("World")) ) {
wxml = wxml->FirstChildElement();
vil = xml.FirstChildElement("World")->FirstChildElement("village");
- Indoor = false;
tmp = new World();
- }else if((wxml = xml.FirstChildElement("IndoorWorld"))){
+ Indoor = false;
+ }
+
+ // attempt to load an <IndoorWorld> tag
+ else if( (wxml = xml.FirstChildElement("IndoorWorld")) ) {
wxml = wxml->FirstChildElement();
vil = NULL;
- Indoor = true;
tmp = new IndoorWorld();
+ Indoor = true;
}
- while(wxml){
+ // error: can't load a world...
+ else
+ UserError("XML Error: Cannot find a <World> or <IndoorWorld> tag in " + currentXML + "!");
+
+ // iterate through world tags
+ while ( wxml ) {
name = wxml->Name();
+ // world linkage
if ( name == "link" ) {
- if ((ptr = wxml->Attribute("left"))) {
- tmp->setToLeft(ptr);
+
+ // links world to the left
+ if ( (ptr = wxml->Attribute("left")) ) {
+ tmp->setToLeft( ptr );
+
+ // load the left world if it isn't
if ( !loadedLeft ) {
loadedLeft = true;
currentWorldToLeft = loadWorldFromXMLNoSave( ptr );