initial commit, lordsawar source, slightly modified
[lordsawar] / src / armyprotobase.cpp
1 // Copyright (C) 2000, 2001, 2003 Michael Bartl
2 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Ulf Lorenz
3 // Copyright (C) 2004, 2005 Andrea Paternesi
4 // Copyright (C) 2007, 2008 Ben Asselstine
5 // Copyright (C) 2007, 2008 Ole Laursen
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License as published by
9 //  the Free Software Foundation; either version 3 of the License, or
10 //  (at your option) any later version.
11 //
12 //  This program is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //  GNU Library General Public License for more details.
16 //
17 //  You should have received a copy of the GNU General Public License
18 //  along with this program; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
20 //  02110-1301, USA.
21
22 #include <iostream>
23 #include <sstream>
24 #include <algorithm>
25 #include "armyprotobase.h"
26 #include "xmlhelper.h"
27 #include "defs.h"
28
29 //#define debug(x) {std::cerr<<__FILE__<<": "<<__LINE__<<": "<<x<<std::endl<<std::flush;}
30 #define debug(x)
31
32 ArmyProtoBase::ArmyProtoBase(const ArmyProtoBase& a)
33     :ArmyBase(a), d_name(a.d_name), 
34     d_type_id(a.d_type_id),
35      d_description(a.d_description), d_production_cost(a.d_production_cost),
36      d_new_production_cost(a.d_new_production_cost),
37      d_production(a.d_production), d_armyset(a.d_armyset)
38 {
39 }
40
41 ArmyProtoBase::ArmyProtoBase()
42   :ArmyBase(), d_name(_("Untitled")), d_type_id(0),
43     d_description(""), d_production_cost(0), d_new_production_cost(0),
44     d_production(0), d_armyset(0)
45 {
46 }
47
48 ArmyProtoBase::ArmyProtoBase(XML_Helper* helper)
49   :ArmyBase(helper), d_name(""), d_type_id(0), 
50     d_description(""), d_production_cost(0), d_new_production_cost(0),
51     d_production(0), d_armyset(0)
52 {
53
54   helper->getData(d_name, "name");
55   helper->getData(d_production_cost, "production_cost");
56   helper->getData(d_new_production_cost, "new_production_cost");
57   helper->getData(d_production, "production");
58   helper->getData(d_description, "description");
59 }
60
61 ArmyProtoBase::~ArmyProtoBase()
62 {
63 }
64
65 bool ArmyProtoBase::saveData(XML_Helper* helper) const
66 {
67   bool retval = true;
68
69   retval &= helper->saveData("name", d_name);
70   retval &= helper->saveData("description", d_description);
71   retval &= helper->saveData("production_cost", d_production_cost);
72   retval &= helper->saveData("new_production_cost", d_new_production_cost);
73   retval &= helper->saveData("production", d_production);
74   retval &= ArmyBase::saveData(helper);
75   return retval;
76 }