1
// $Id: ExitData.cc,v 1.6 2002/01/15 10:48:49 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
11
// This program 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 this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include "editor/PLFObj.hh"
22
#include "ExitData.hh"
25
ExitData::write_xml(std::ofstream* xml)
27
(*xml) << "<exit use-old-pos-handling=\"" << use_old_pos_handling << "\">\n";
30
//pos.x += surf.get_width ()/2;
31
//pos.y += surf.get_height ();
32
XMLhelper::write_position_xml(xml, pos);
34
XMLhelper::write_desc_xml(xml, desc);
35
(*xml) << " <owner-id>" << owner_id << "</owner-id>"
40
boost::shared_ptr<WorldObjData>
41
ExitData::create(xmlDocPtr doc, xmlNodePtr cur)
43
ExitData* exit = new ExitData ();
45
char* pos_handling = (char*)xmlGetProp(cur, (xmlChar*)"use-old-pos-handling");
48
std::cout << "XMLPLF: Use Old Pos Handling: " << pos_handling << std::endl;
49
exit->use_old_pos_handling = static_cast<bool>(StringConverter::to_int (pos_handling));
54
exit->use_old_pos_handling = true;
60
if (xmlIsBlankNode(cur))
66
if (strcmp((char*)cur->name, "position") == 0)
68
exit->pos = XMLhelper::parse_vector(doc, cur);
70
else if (strcmp((char*)cur->name, "surface") == 0)
72
exit->desc = XMLhelper::parse_surface(doc, cur);
74
else if (strcmp((char*)cur->name, "owner-id") == 0)
76
exit->owner_id = XMLhelper::parse_int(doc, cur);
80
std::cout << "XMLPLF: Unhandled exit tag: " << (char*)cur->name << std::endl;
85
return boost::shared_ptr<WorldObjData> (exit);
88
boost::shared_ptr<WorldObj>
89
ExitData::create_WorldObj()
91
return boost::shared_ptr<WorldObj> (new Exit (*this));
95
ExitData::create_EditorObj()
98
lst.push_back (boost::shared_ptr<EditorObj> (new ExitObj (*this)));