xoreos  0.0.5
creature.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 #include "src/common/error.h"
27 #include "src/common/ustring.h"
28 
29 #include "src/aurora/gff3file.h"
30 
32 
33 namespace Engines {
34 
35 namespace Witcher {
36 
38  _isPC(false) {
39 
40  load(utc);
41 }
42 
44 }
45 
46 bool Creature::isPC() const {
47  return _isPC;
48 }
49 
50 void Creature::load(const Common::UString &utc) {
51  Aurora::GFF3File gff(utc, Aurora::kFileTypeUTC, MKTAG('U', 'T', 'C', ' '));
52 
53  load(gff.getTopLevel());
54 }
55 
57  // Unique ID and tag
58  _uniqueID = utc.getString("UniqueID", _uniqueID);
59  _tag = utc.getString("Tag", _tag);
60 
61  // Name
62  utc.getLocString("FirstName", _name);
63 
64  // Description
65  utc.getLocString("Description", _description);
66 
67  // Static
68  _static = false;
69 
70  // Usable
71  _static = true;
72 
73  // PC
74  _isPC = utc.getBool("IsPC", _isPC);
75 
76  // Scripts
77  readScripts(utc);
78 }
79 
80 } // End of namespace Witcher
81 
82 } // End of namespace Engines
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
bool getBool(const Common::UString &field, bool def=false) const
Definition: gff3file.cpp:510
bool getLocString(const Common::UString &field, LocString &str) const
Definition: gff3file.cpp:614
A class holding an UTF-8 string.
Definition: ustring.h:48
void load(const Common::UString &utc)
Definition: creature.cpp:50
An object within a Witcher area.
Definition: object.h:51
void readScripts(const Aurora::GFF3Struct &gff)
Definition: container.cpp:129
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
Basic exceptions to throw.
A creature in a The Witcher area.
Utility templates and functions.
Aurora::LocString _description
The object&#39;s description.
Definition: object.h:147
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
Common::UString _uniqueID
A globally unique ID.
Definition: object.h:144
bool _static
Is the object static?
Definition: object.h:151
bool _isPC
Is the creature a PC?
Definition: creature.h:49
Unicode string handling.
Creature(const Common::UString &utc)
Load from a creature template.
Definition: creature.cpp:37
A struct within a GFF3.
Definition: gff3file.h:164
Common::UString _tag
Definition: object.h:56
bool isPC() const
Is the creature a player character?
Definition: creature.cpp:46
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
Aurora::LocString _name
The object&#39;s name.
Definition: object.h:146
Creature template (user), GFF.
Definition: types.h:93