ScummVM API documentation
world.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
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 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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA8_WORLD_WORLD_H
23#define ULTIMA8_WORLD_WORLD_H
24
25// the main world class.
26
27// Current ideas on how to store the game world: (-wjp)
28
29// World contains Map objects. All Map objects are initialized when
30// starting/loading a game.
31
32// Each Map permanently contains the nonfixed objects in that map,
33// ( These objects don't have to be assigned object IDs here, I think )
34
35// When a Map is loaded, it loads the fixed objects from disk.
36// All objects in the active map will also have to be assigned object IDs.
37// NB: This has to happen in such a way that when a game is loaded the IDs can
38// be reproduced exactly. (Since running usecode scripts can contain objIDs)
39// The first N objIDs will probably be reserved from NPCs (and inventories?)
40// After that, for example, the fixed objects could be loaded (in disk-order),
41// followed by assigning IDs to the (already loaded) dynamic items.
42// (in basic depth-first order, I would guess)
43
44// NPCs will also have to be stored somewhere. We could keep them in Map #0
45// like the original.
46// Q: Is the avatar's inventory stored in npcdata?
47// Q: Is the number of objIDs reserved for npcdata fixed?
48
49// World also has to have the necessary save/load functions. (Which will
50// mostly consist of calls to the save/load functions of the Map objects.)
51
52// Fixed objects could be kept cached in for better performance, or
53// swapped out for memory.
54
55// A clear/reset function would also be useful. (All singletons that store
56// game data need this, actually.)
57
58#include "ultima/ultima8/misc/common_types.h"
59#include "ultima/ultima8/usecode/intrinsics.h"
60
61namespace Common {
62class ReadStream;
63}
64
65namespace Ultima {
66namespace Ultima8 {
67
68class Map;
69class CurrentMap;
70class Actor;
71class MainActor;
72class Flex;
73class Item;
74
75class World {
76public:
77 World();
78 ~World();
79
80 static World *get_instance() {
81 return _world;
82 }
83
85 void clear();
86
88 void reset();
89
91 void initMaps();
92
94 void loadNonFixed(Common::SeekableReadStream *rs); // delete ds afterwards
95
98
101 return _currentMap;
102 }
103
107 bool switchMap(uint32 newmap);
108
110 void etherealPush(ObjId objid) {
111 _ethereal.push_front(objid);
112 }
113
115 bool etherealEmpty() const {
116 return _ethereal.empty();
117 }
118
120 ObjId etherealPeek() const {
121 return _ethereal.front();
122 }
123
125 void etherealRemove(ObjId objid) {
126 _ethereal.remove(objid);
127 }
128
130 void worldStats() const;
131
134
136 bool loadMaps(Common::ReadStream *rs, uint32 version);
137
140
142 bool load(Common::ReadStream *rs, uint32 version);
143
144 bool isAlertActive() const {
145 return _alertActive;
146 }
147
148 void setAlertActive(bool active);
149
150 uint8 getGameDifficulty() const {
151 return _difficulty;
152 }
153
154 void setGameDifficulty(uint8 difficulty);
155
156 uint16 getControlledNPCNum() const {
157 return _controlledNPCNum;
158 }
159 void setControlledNPCNum(uint16 num);
160
161 uint32 getVargasShield() const {
162 return _vargasShield;
163 }
164 void setVargasShield(uint32 val) {
165 _vargasShield = val;
166 }
167
168 INTRINSIC(I_getAlertActive); // for Crusader
169 INTRINSIC(I_setAlertActive); // for Crusader
170 INTRINSIC(I_clrAlertActive); // for Crusader
171 INTRINSIC(I_gameDifficulty); // for Crusader
172 INTRINSIC(I_getControlledNPCNum); // for Crusader
173 INTRINSIC(I_setControlledNPCNum); // for Crusader
174 INTRINSIC(I_resetVargasShield); // for Crusader: No Remorse
175
176private:
177
178 void setAlertActiveRemorse(bool active);
179 void setAlertActiveRegret(bool active);
180
181 static World *_world;
182
184 CurrentMap *_currentMap;
185
186 Common::List<ObjId> _ethereal;
187
188 bool _alertActive;
189 uint8 _difficulty;
190 uint16 _controlledNPCNum;
196 uint32 _vargasShield;
197
198};
199
200} // End of namespace Ultima8
201} // End of namespace Ultima
202
203#endif
Definition: array.h:52
t_T & front()
Definition: list.h:196
void push_front(const t_T &element)
Definition: list.h:158
void remove(const t_T &val)
Definition: list.h:142
bool empty() const
Definition: list.h:258
Definition: stream.h:385
Definition: stream.h:745
Definition: stream.h:77
Definition: current_map.h:45
Definition: world.h:75
void reset()
reset the world (clear everything and re-initialize maps)
void loadNonFixed(Common::SeekableReadStream *rs)
load U8's nonfixed.dat into the Maps
bool switchMap(uint32 newmap)
void loadItemCachNPCData(Common::SeekableReadStream *itemcach, Common::SeekableReadStream *npcdata)
load U8's itemcach.dat, npcdata.dat into the world
void etherealPush(ObjId objid)
push an item onto the ethereal void
Definition: world.h:110
ObjId etherealPeek() const
return (but don't remove) the top item from the ethereal void
Definition: world.h:120
bool etherealEmpty() const
check if the ethereal void is empty
Definition: world.h:115
CurrentMap * getCurrentMap() const
get the CurrentMap
Definition: world.h:100
void save(Common::WriteStream *ws)
save the rest of the World data (ethereal items, current map number).
void initMaps()
create (empty) maps, currentmap
void worldStats() const
output some statistics about the world
void etherealRemove(ObjId objid)
remove an item from the ethereal void
Definition: world.h:125
void saveMaps(Common::WriteStream *ws)
save the Maps in World.
bool loadMaps(Common::ReadStream *rs, uint32 version)
load Maps
bool load(Common::ReadStream *rs, uint32 version)
load World data
void clear()
clear the world (maps, currentmap, ethereal items)
Definition: algorithm.h:29