~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/ExitData.cc

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Goulais
  • Date: 2004-08-09 10:26:00 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040809102600-lg2q9lfars0q1p42
Tags: 0.6.0-8
Applied patch from Andreas Jochens (Closes: #263992)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: ExitData.cc,v 1.6 2002/01/15 10:48:49 grumbel Exp $
2
 
//
3
 
//  Pingus - A free Lemmings clone
4
 
//  Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
5
 
//
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.
10
 
//
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.
15
 
//
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.
19
 
 
20
 
#include "Exit.hh"
21
 
#include "editor/PLFObj.hh"
22
 
#include "ExitData.hh"
23
 
 
24
 
void 
25
 
ExitData::write_xml(std::ofstream* xml)
26
 
{
27
 
  (*xml) << "<exit use-old-pos-handling=\"" << use_old_pos_handling << "\">\n";
28
 
 
29
 
  // FIXME: Repair me
30
 
  //pos.x += surf.get_width ()/2;
31
 
  //pos.y += surf.get_height ();
32
 
  XMLhelper::write_position_xml(xml, pos);
33
 
  
34
 
  XMLhelper::write_desc_xml(xml, desc);
35
 
  (*xml) << "  <owner-id>" << owner_id << "</owner-id>"
36
 
         << "</exit>\n"
37
 
         << std::endl;
38
 
}
39
 
 
40
 
boost::shared_ptr<WorldObjData> 
41
 
ExitData::create(xmlDocPtr doc, xmlNodePtr cur)
42
 
{
43
 
  ExitData* exit  = new ExitData ();
44
 
 
45
 
  char* pos_handling = (char*)xmlGetProp(cur, (xmlChar*)"use-old-pos-handling");
46
 
  if (pos_handling)
47
 
    {
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));
50
 
      free (pos_handling);
51
 
    }
52
 
  else
53
 
    {
54
 
      exit->use_old_pos_handling = true;
55
 
    }
56
 
 
57
 
  cur = cur->children;
58
 
  while (cur != NULL)
59
 
    {
60
 
      if (xmlIsBlankNode(cur)) 
61
 
        {
62
 
          cur = cur->next;
63
 
          continue;
64
 
        }
65
 
      
66
 
      if (strcmp((char*)cur->name, "position") == 0)
67
 
        {
68
 
          exit->pos = XMLhelper::parse_vector(doc, cur);
69
 
        }
70
 
      else if (strcmp((char*)cur->name, "surface") == 0)
71
 
        {
72
 
          exit->desc = XMLhelper::parse_surface(doc, cur);
73
 
        }
74
 
      else if (strcmp((char*)cur->name, "owner-id") == 0)
75
 
        {
76
 
          exit->owner_id = XMLhelper::parse_int(doc, cur);
77
 
        }
78
 
      else
79
 
        {
80
 
          std::cout << "XMLPLF: Unhandled exit tag: " << (char*)cur->name << std::endl;
81
 
        }
82
 
      cur = cur->next;  
83
 
    }
84
 
 
85
 
  return boost::shared_ptr<WorldObjData> (exit);
86
 
}
87
 
 
88
 
boost::shared_ptr<WorldObj> 
89
 
ExitData::create_WorldObj()
90
 
{
91
 
  return boost::shared_ptr<WorldObj> (new Exit (*this));
92
 
}
93
 
 
94
 
EditorObjLst 
95
 
ExitData::create_EditorObj()
96
 
{
97
 
  EditorObjLst lst;
98
 
  lst.push_back (boost::shared_ptr<EditorObj> (new ExitObj (*this)));
99
 
  return lst;
100
 
}
101
 
 
102
 
/* EOF */