LandscapeInclude.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <landscapedef/LandscapeInclude.h>
00022 #include <landscapedef/LandscapeEvents.h>
00023 #include <landscapedef/LandscapeMovement.h>
00024 #include <landscapedef/LandscapeSound.h>
00025 #include <landscapedef/LandscapeMusic.h>
00026 #include <landscapedef/LandscapeOptions.h>
00027 
00028 LandscapeInclude::LandscapeInclude()
00029 {
00030 }
00031 
00032 LandscapeInclude::~LandscapeInclude()
00033 {
00034         {
00035                 while (!events.empty())
00036                 {
00037                         delete events.back();
00038                         events.pop_back();
00039                 }
00040         }
00041         {
00042                 while (!movements.empty())
00043                 {
00044                         delete movements.back();
00045                         movements.pop_back();
00046                 }
00047         }
00048         {
00049                 while (!placements.empty())
00050                 {
00051                         delete placements.back();
00052                         placements.pop_back();
00053                 }
00054         }
00055         {
00056                 while (!sounds.empty())
00057                 {
00058                         delete sounds.back();
00059                         sounds.pop_back();
00060                 }
00061         }
00062         {
00063                 while (!musics.empty())
00064                 {
00065                         delete musics.back();
00066                         musics.pop_back();
00067                 }
00068         }
00069         {
00070                 while (!options.empty())
00071                 {
00072                         delete options.back();
00073                         options.pop_back();
00074                 }
00075         }
00076 }
00077 
00078 bool LandscapeInclude::readXML(LandscapeDefinitions *definitions, XMLNode *node)
00079 {
00080         {
00081                 XMLNode *eventNode;
00082                 while (node->getNamedChild("event", eventNode, false))
00083                 {
00084                         LandscapeEvent *event = new LandscapeEvent;
00085                         if (!event->readXML(eventNode)) return false;
00086                         events.push_back(event);
00087                 }
00088         }
00089         {
00090                 XMLNode *soundNode;
00091                 while (node->getNamedChild("sound", soundNode, false))
00092                 {
00093                         LandscapeSoundType *sound = new LandscapeSoundType;
00094                         if (!sound->readXML(soundNode)) return false;
00095                         sounds.push_back(sound);
00096                 }
00097         }
00098         {
00099                 XMLNode *musicNode;
00100                 while (node->getNamedChild("music", musicNode, false))
00101                 {
00102                         LandscapeMusicType *music = new LandscapeMusicType;
00103                         if (!music->readXML(musicNode)) return false;
00104                         musics.push_back(music);
00105                 }
00106         }
00107         {
00108                 XMLNode *optionsNode;
00109                 while (node->getNamedChild("options", optionsNode, false))
00110                 {
00111                         LandscapeOptionsType *option = new LandscapeOptionsType;
00112                         if (!option->readXML(optionsNode)) return false;
00113                         options.push_back(option);
00114                 }
00115         }
00116         {
00117                 XMLNode *placementNode;
00118                 while (node->getNamedChild("placement", placementNode, false))
00119                 {
00120                         std::string placementtype;
00121                         PlacementType *placement = 0;
00122                         if (!placementNode->getNamedParameter("type", placementtype)) return false;
00123                         if (!(placement = PlacementType::create(placementtype.c_str()))) return false;
00124                         if (!placement->readXML(placementNode)) return false;
00125                         placements.push_back(placement);
00126                 }
00127         }
00128         {
00129                 XMLNode *movement;
00130                 while (node->getNamedChild("movement", movement, false))
00131                 {
00132                         std::string type;
00133                         if (!movement->getNamedParameter("type", type)) return false;
00134                         LandscapeMovementType *object = LandscapeMovementType::create(type.c_str());
00135                         if (!object) return false;
00136                         if (!object->readXML(movement)) return false;
00137                         movements.push_back(object);
00138                 }
00139         }
00140         return node->failChildren();
00141 }

Generated on Mon Feb 16 15:14:50 2009 for Scorched3D by  doxygen 1.5.3