Adonthell  0.4
quest.cc
1 /*
2  Copyright (C) 2000 Kai Sterker <kai.sterker@gmail.com>
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "quest.h"
20 
21 dictionary <quest *> data::quests;
22 
23 quest::quest ()
24 {
25 }
26 
27 quest::~quest ()
28 {
29 }
30 
31 // Save a quest object
32 void quest::save (ogzstream& out)
33 {
35  u_int32 j;
36 
37  // Save name
38  name >> out;
39 
40  // Save all variables and flags
41  j = size ();
42  j >> out;
43 
44  for (i = begin (); i != end (); i++)
45  {
46  string s = (*i).first;
47  s >> out;
48  (*i).second >> out;
49  }
50 }
51 
52 // Load a quest object and add it to the quest-arrays
53 void quest::load (igzstream& in)
54 {
55  u_int32 i, size;
56  s_int32 value;
57  string key;
58 
59  name << in;
60 
61  size << in;
62  for (i = 0; i < size; i++)
63  {
64  key << in;
65  value << in;
66  set_val (key.c_str (), value);
67  }
68 }
u_int32 size() const
Returns the size (number of elements) of the storage.
Definition: storage.h:148
Class to write data from a Gzip compressed file.
Definition: fileops.h:227
#define s_int32
32 bits long signed integer
Definition: types.h:50
Class to read data from a Gzip compressed file.
Definition: fileops.h:135
#define u_int32
32 bits long unsigned integer
Definition: types.h:41
Stores objects of any kind.
Definition: storage.h:231
void set_val(string key, s_int32 value)
Sets key to value.
Definition: storage.cc:41
iterator end()
Returns an iterator to the end of the storage.
Definition: storage.h:137
hash_map< string, s_int32 >::iterator iterator
Storage iterator, similar to STL iterator.
Definition: storage.h:118
iterator begin()
Returns an iterator to the beginning of the storage.
Definition: storage.h:126