aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/room_flags.h
blob: e2fb91015a4ec9189ca08fd6ca63985ae761f865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef TITANIC_ROOM_FLAGS_H
#define TITANIC_ROOM_FLAGS_H

#include "titanic/support/string.h"
#include "titanic/game_location.h"

namespace Titanic {

class CRoomFlags {
private:
	uint _data;
private:
	int getConditionally() const;

	/**
	 * Returns true if the current flags appear in the
	 * list of transport rooms
	 */
	bool isTransportRoom() const;

	int getRoomCategory() const;

	int getRoomArea() const;

	/**
	 * Set the bits for the elevator number
	 */
	void setElevatorBits(uint val);

	/**
	 * Set the bits for the floor number
	 */
	void setFloorBits(uint val);

	/**
	 * Translates bits for floor into a floor number
	 */
	uint decodeFloorBits(uint bits) const;

	static bool is2To19(uint v) { return v >= 2 && v <= 19; }
	static bool is20To27(uint v) { return v >= 20 && v <= 27; }
	static bool is28To38(uint v) { return v >= 28 && v <= 38; }
public:
	/**
	 * Compares the current flags against the specified flags
	 * for a matching elevator, floor, and room
	 */
	static bool compareLocation(uint flags1, uint flags2);

	/**
	 * Compares two room flags together
	 */
	static bool compareClassElevator(uint flags1, uint flags2);

	/**
	 * Returns true if the current flags is for Titania's room
	 */
	static bool isTitania(uint flags1, uint flags2);
public:
	CRoomFlags() : _data(0) {}
	CRoomFlags(uint data) : _data(data) {}
	operator uint() { return _data; }

	/**
	 * Set the flags value
	 */
	void set(uint data) { _data = data; }

	/**
	 * Get the flags value
	 */
	uint get() const { return _data; }

	/**
	 * Gets the special flags for a transport or succubus room
	 */
	static uint getSpecialRoomFlags(const CString &roomName);

	/**
	 * Returns true if the current flags are in the succubus list
	 */
	bool isSuccUBusRoomFlags() const;

	/**
	 * Get a description for the room
	 */
	CString getRoomDesc() const;

	/**
	 * Get the bits for the elevator number
	 */
	uint getElevatorBits() const;

	/**
	 * Set the elevator number
	 */
	void setElevatorNum(uint val) { setElevatorBits(val - 1); }

	/**
	 * Get the elevator number
	 */
	uint getElevatorNum() const { return getElevatorBits() + 1; }

	/**
	 * Get a description for the elevator number
	 */
	CString getElevatorDesc() const {
		return CString::format("Elevator %d", getElevatorNum());
	}

	/**
	 * Gets the bits for the passenger class
	 */
	uint getPassengerClassBits() const;

	/**
	 * Set the bits for the passenger class
	 */
	void setPassengerClassBits(uint val);

	/**
	 * Gets the passenger class number
	 */
	PassengerClass getPassengerClassNum() const {
		return (PassengerClass)getPassengerClassBits();
	}

	/**
	 * Get a description for the passenger class
	 */
	CString getPassengerClassDesc() const;

	/**
	 * Gets the bits for the floor number
	 */
	uint getFloorBits() const;

	/**
	 * Sets the floor number
	 */
	void setFloorNum(uint floorNum);

	/**
	 * Gets the floor number
	 */
	uint getFloorNum() const;

	/**
	 * Get a description for the floor number
	 */
	CString getFloorDesc() const {
		return CString::format("Floor %d", getFloorNum());
	}

	/**
	 * Sets the bits for the room number
	 */
	void setRoomBits(uint roomBits);

	/**
	 * Gets the bits for the room number
	 */
	uint getRoomBits() const;

	/**
	 * Gets the room number
	 */
	uint getRoomNum() const { return getRoomBits(); }

	/**
	 * Gets a string for the room number
	 */
	CString getRoomNumDesc() const {
		return CString::format("Room %d", getRoomNum());
	}

	bool getBit0() const;

	/**
	 * Change the passenger class
	 */
	void changeClass(PassengerClass newClassNum);

	/**
	 * Sets a random destination in the flags
	 */
	void setRandomLocation(PassengerClass classNum, bool flag);

	/**
	 * Gets the passenger class for a succubus associated with a given room
	 */
	PassengerClass getSuccUBusClass(const CString &roomName) const;

	/**
	 * Gets the succubus room name associated with the current room flags
	 */
	CString getSuccUBusRoomName() const;

	/**
	 * Returns what passenger class a particular floor number belongs to
	 */
	static PassengerClass whatPassengerClass(int floorNum);

	bool not5() const { return getConditionally() != 5; }

	bool is59706() const { return _data == 0x59706; }
};

} // End of namespace Titanic

#endif /* TITANIC_ROOM_FLAGS_H */