1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #include <landscapedef/LandscapeInclude.h>
22 #include <landscapedef/LandscapeEvents.h>
23 #include <landscapedef/LandscapeMovement.h>
24 #include <landscapedef/LandscapeSound.h>
25 #include <landscapedef/LandscapeMusic.h>
26 #include <landscapedef/LandscapeOptions.h>
28 LandscapeInclude::LandscapeInclude()
32 LandscapeInclude::~LandscapeInclude()
35 while (!events
.empty())
42 while (!movements
.empty())
44 delete movements
.back();
49 while (!placements
.empty())
51 delete placements
.back();
52 placements
.pop_back();
56 while (!sounds
.empty())
63 while (!musics
.empty())
70 while (!options
.empty())
72 delete options
.back();
78 bool LandscapeInclude::readXML(LandscapeDefinitions
*definitions
, XMLNode
*node
)
82 while (node
->getNamedChild("event", eventNode
, false))
84 LandscapeEvent
*event
= new LandscapeEvent
;
85 if (!event
->readXML(eventNode
)) return false;
86 events
.push_back(event
);
91 while (node
->getNamedChild("sound", soundNode
, false))
93 LandscapeSoundType
*sound
= new LandscapeSoundType
;
94 if (!sound
->readXML(soundNode
)) return false;
95 sounds
.push_back(sound
);
100 while (node
->getNamedChild("music", musicNode
, false))
102 LandscapeMusicType
*music
= new LandscapeMusicType
;
103 if (!music
->readXML(musicNode
)) return false;
104 musics
.push_back(music
);
108 XMLNode
*optionsNode
;
109 while (node
->getNamedChild("options", optionsNode
, false))
111 LandscapeOptionsType
*option
= new LandscapeOptionsType
;
112 if (!option
->readXML(optionsNode
)) return false;
113 options
.push_back(option
);
117 XMLNode
*placementNode
;
118 while (node
->getNamedChild("placement", placementNode
, false))
120 std::string placementtype
;
121 PlacementType
*placement
= 0;
122 if (!placementNode
->getNamedParameter("type", placementtype
)) return false;
123 if (!(placement
= PlacementType::create(placementtype
.c_str()))) return false;
124 if (!placement
->readXML(placementNode
)) return false;
125 placements
.push_back(placement
);
130 while (node
->getNamedChild("movement", movement
, false))
133 if (!movement
->getNamedParameter("type", type
)) return false;
134 LandscapeMovementType
*object
= LandscapeMovementType::create(type
.c_str());
135 if (!object
) return false;
136 if (!object
->readXML(movement
)) return false;
137 movements
.push_back(object
);
140 return node
->failChildren();