Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
character_base.cc
Go to the documentation of this file.
1
/*
2
$Id: character_base.cc,v 1.11 2002/08/25 14:16:18 gnurou Exp $
3
4
Copyright (C) 2000/2001 Kai Sterker <kaisterker@linuxgames.com>
5
Part of the Adonthell Project http://adonthell.linuxgames.com
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.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
16
/**
17
* @file character_base.cc
18
* @author Kai Sterker <kaisterker@linuxgames.com>
19
*
20
* @brief Defines the character_base class.
21
*
22
*
23
*/
24
25
26
#include "
character_base.h
"
27
#include <iostream>
28
29
using namespace
std;
30
31
32
character_base::character_base
()
33
{
34
color = 1;
35
name =
""
;
36
dialogue =
""
;
37
38
// characters are NPC's by default
39
set_val (
"type"
, NPC);
40
}
41
42
character_base::~character_base
()
43
{
44
}
45
46
void
character_base::set_name
(
string
newname)
47
{
48
name = newname;
49
}
50
51
void
character_base::set_dialogue
(
string
newdlg)
52
{
53
dialogue = newdlg;
54
}
55
56
void
character_base::put_state
(
ogzstream
& out)
57
{
58
storage::iterator
i;
59
60
u_int32
j;
61
62
// Save name
63
name >> out;
64
65
// save color
66
color >> out;
67
68
// Save all attributes and flags
69
j = size ();
70
j >> out;
71
72
for
(i = begin (); i != end (); i++)
73
{
74
string
s = (*i).first;
75
s >> out;
76
(*i).second >> out;
77
}
78
79
dialogue >> out;
80
portrait >> out;
81
}
82
83
void
character_base::get_state
(
igzstream
& in)
84
{
85
u_int32
i, size;
86
s_int32
value;
87
88
// load name
89
name << in;
90
91
// load color
92
color << in;
93
94
// load all attributes and flags
95
size << in;
96
for
(i = 0; i < size; i++)
97
{
98
string
key;
99
key << in;
100
101
/// @bug : We should be able to pass a string to objects
102
/// instead of a char *, which memory isn't freed at exit.
103
value << in;
104
set_val (key.c_str (), value);
105
}
106
107
dialogue << in;
108
portrait << in;
109
}
src
character_base.cc
Generated by
1.8.1.2