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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef NEVERHOOD_GAMEVARS_H
24 #define NEVERHOOD_GAMEVARS_H
25 
26 #include "common/array.h"
27 #include "common/savefile.h"
28 #include "neverhood/neverhood.h"
29 
30 namespace Neverhood {
31 
32 enum {
33 	// Misc
34 	V_MODULE_NAME				= 0x91080831,			// Currently active module name hash
35 	V_CURRENT_SCENE				= 0x108A4870,			// Current scene in the current module
36 	V_CURRENT_SCENE_WHICH		= 0x82C80875,
37 	V_DEBUG						= 0xA4014072,			// Original debug-flag, can probably be removed
38 	V_SMACKER_CAN_ABORT			= 0x06C02850,			// Not set anywhere (yet), seems like a debug flag
39 	V_KEY3_LOCATION				= 0x13382860,			// Location of the third key
40 	V_TEXT_FLAG1				= 0x8440001F,
41 	V_TEXT_INDEX				= 0x01830201,
42 	V_TEXT_COUNTING_INDEX1		= 0x29408F00,
43 	V_TEXT_COUNTING_INDEX2		= 0x8A140C21,
44 	V_TALK_COUNTING_INDEX		= 0xA0808898,
45 	V_FRUIT_COUNTING_INDEX		= 0x40040831,
46 	V_NOISY_SYMBOL_INDEX		= 0x2414C2F2,
47 	V_COLUMN_BACK_NAME			= 0x4CE79018,
48 	V_COLUMN_TEXT_NAME			= 0xC8C28808,
49 	V_CLICKED_COLUMN_INDEX		= 0x48A68852,
50 	V_CLICKED_COLUMN_ROW		= 0x49C40058,
51 	// Klaymen
52 	V_KLAYMEN_SMALL				= 0x1860C990,			// Is Klaymen small?
53 	V_KLAYMEN_FRAMEINDEX		= 0x18288913,
54 	V_KLAYMEN_IS_DELTA_X		= 0xC0418A02,
55 	V_KLAYMEN_SAVED_X			= 0x00D30138,
56 	V_CAR_DELTA_X				= 0x21E60190,
57 	// Flags
58 	V_CRYSTAL_COLORS_INIT		= 0xDE2EC914,
59 	V_TV_JOKE_TOLD				= 0x92603A79,
60 	V_NOTES_DOOR_UNLOCKED		= 0x0045D021,
61 	V_WATER_RUNNING				= 0x4E0BE910,
62 	V_CREATURE_ANGRY			= 0x0A310817,			// After having played with the music box
63 	V_BEEN_SHRINKING_ROOM		= 0x1C1B8A9A,
64 	V_BEEN_STATUE_ROOM			= 0xCB45DE03,
65 	V_MOUSE_PUZZLE_SOLVED		= 0x70A1189C,
66 	V_NOTES_PUZZLE_SOLVED		= 0x86615030,
67 	V_TILE_PUZZLE_SOLVED		= 0x404290D5,
68 	V_STAIRS_PUZZLE_SOLVED		= 0xA9035F60,
69 	V_CODE_SYMBOLS_SOLVED		= 0x2C531AF8,
70 	V_SPIKES_RETRACTED			= 0x18890C91,
71 	V_LARGE_DOOR_NUMBER			= 0x9A500914,			// Number of the currently "large" door
72 	V_LIGHTS_ON					= 0x4D080E54,
73 	V_SHRINK_LIGHTS_ON			= 0x190A1D18,			// Lights on in the room with the shrinking device
74 	V_STAIRS_DOWN_ONCE			= 0x2050861A,			// Stairs have been down once before
75 	V_STAIRS_DOWN				= 0x09221A62,
76 	V_LADDER_DOWN				= 0x0018CA22,			// Is the ladder in the statue room down?
77 	V_LADDER_DOWN_ACTION		= 0x00188211,
78 	V_WALL_BROKEN				= 0x10938830,
79 	V_BOLT_DOOR_OPEN			= 0x01BA1A52,
80 	V_BOLT_DOOR_UNLOCKED		= 0x00040153,
81 	V_SEEN_SYMBOLS_NO_LIGHT		= 0x81890D14,
82 	V_FELL_DOWN_HOLE			= 0xE7498218,
83 	V_DOOR_PASSED				= 0x2090590C,			// Auto-closing door was passed
84 	V_ENTRANCE_OPEN				= 0xD0A14D10,			// Is the entrance to Module1300 open (after the robot got his teddy)
85 	V_WINDOW_OPEN				= 0x03C698DA,
86 	V_DOOR_STATUS				= 0x52371C95,
87 	V_DOOR_BUSTED				= 0xD217189D,
88 	V_WORLDS_JOINED				= 0x98109F12,			// Are the worlds joined?
89 	V_KEYDOOR_UNLOCKED			= 0x80455A41,			// Is the keyboard-door unlocked?
90 	V_MOUSE_SUCKED_IN			= 0x01023818,			// Are mouse/cheese in Scene1308?
91 	V_BALLOON_POPPED			= 0xAC00C0D0,			// Has the balloon with the key been popped?
92 	V_TNT_DUMMY_BUILT			= 0x000CF819,			// Are all TNT parts on the dummy?
93 	V_TNT_DUMMY_FUSE_LIT		= 0x20A0C516,
94 	V_RADIO_ENABLED				= 0x4DE80AC0,
95 	V_SEEN_CREATURE_EXPLODE_VID	= 0x2A02C07B,
96 	V_CREATURE_EXPLODED			= 0x0A18CA33,
97 	V_UNUSED					= 0x89C669AA,			// Seems to be unused, confirmed by checking the exe for this constant value (still left in atm)
98 	// Radio
99 	V_RADIO_ROOM_LEFT_DOOR		= 0x09880D40,
100 	V_RADIO_ROOM_RIGHT_DOOR		= 0x08180ABC,
101 	V_CURR_RADIO_MUSIC_INDEX	= 0x08CC0828,
102 	V_GOOD_RADIO_MUSIC_INDEX	= 0x88880915,
103 	V_GOOD_RADIO_MUSIC_NAME		= 0x89A82A15,
104 	V_RADIO_MOVE_DISH_VIDEO		= 0x28D8C940,
105 	// Match
106 	V_MATCH_STATUS				= 0x0112090A,
107 	// Venus fly trap
108 	V_FLYTRAP_RING_EATEN		= 0x2B514304,
109 	V_FLYTRAP_RING_DOOR			= 0x8306F218,
110 	V_FLYTRAP_RING_FENCE		= 0x80101B1E,
111 	V_FLYTRAP_RING_BRIDGE		= 0x13206309,
112 	V_FLYTRAP_POSITION_1		= 0x1B144052,
113 	V_FLYTRAP_POSITION_2		= 0x86341E88,
114 	// Navigation
115 	V_NAVIGATION_INDEX			= 0x4200189E,			// Navigation scene: Current navigation index
116 	// Cannon
117 	V_CANNON_RAISED				= 0x000809C2,			// Is the cannon raised?
118 	V_CANNON_TURNED				= 0x9040018A,			// Is the cannon turned?
119 	V_ROBOT_HIT					= 0x0C0288F4,			// Was the robot hit by the cannon?
120 	V_ROBOT_TARGET				= 0x610210B7,			// Is the robot at the cannon target position? (teddy)
121 	V_CANNON_SMACKER_NAME		= 0xF0402B0A,
122 	V_CANNON_TARGET_STATUS		= 0x20580A86,
123 	// Projector
124 	V_PROJECTOR_SLOT			= 0x04A10F33,			// Projector x slot index
125 	V_PROJECTOR_LOCATION		= 0x04A105B3,			// Projector scene location
126 	V_PROJECTOR_ACTIVE			= 0x12A10DB3,			// Is the projecor projecting?
127 	// Teleporter
128 	V_TELEPORTER_CURR_LOCATION	= 0x0152899A,
129 	V_TELEPORTER_WHICH			= 0x60826830,
130 	V_TELEPORTER_DEST_AVAILABLE	= 0x2C145A98,
131 	// Inventory
132 	V_HAS_NEEDLE				= 0x31C63C51,			// Has Klaymen the needle?
133 	V_HAS_FINAL_KEY				= 0xC0780812,			// Has Klaymen the key from the diskplayer?
134 	V_HAS_TEST_TUBE				= 0x45080C38,
135 	// Arrays
136 	// NOTE "GOOD" means the solution, "CURR" is the current setup of the puzzle variables
137 	VA_IS_PUZZLE_INIT			= 0x40050052,
138 	VA_SMACKER_PLAYED			= 0x00800410,
139 	VA_CURR_CRYSTAL_COLORS		= 0xE11A1929,
140 	VA_GOOD_CRYSTAL_COLORS		= 0xD4B2089C,
141 	VA_GOOD_TEST_TUBES_LEVEL_1	= 0x0C601058,
142 	VA_GOOD_TEST_TUBES_LEVEL_2	= 0x40005834,
143 	VA_CURR_CANNON_SYMBOLS		= 0x00000914,
144 	VA_GOOD_CANNON_SYMBOLS_1	= 0x00504B86,
145 	VA_GOOD_CANNON_SYMBOLS_2	= 0x0A4C0A9A,
146 	VA_CURR_WATER_PIPES_LEVEL	= 0x0800547C,
147 	VA_GOOD_WATER_PIPES_LEVEL	= 0x90405038,
148 	VA_CURR_DICE_NUMBERS		= 0x61084036,
149 	VA_GOOD_DICE_NUMBERS		= 0x7500993A,
150 	VA_CURR_KEY_SLOT_NUMBERS	= 0xA010B810,
151 	VA_GOOD_KEY_SLOT_NUMBERS	= 0x0C10A000,
152 	VA_CUBE_POSITIONS			= 0x484498D0,
153 	VA_CODE_SYMBOLS				= 0x04909A50,
154 	VA_TILE_SYMBOLS				= 0x0C65F80B,
155 	VA_IS_TILE_MATCH			= 0xCCE0280F,
156 	VA_TNT_POSITIONS			= 0x10055D14,
157 	VA_DICE_MEMORY_SYMBOLS		= 0x13100631,
158 	VA_HAS_TAPE					= 0x02038314,
159 	VA_IS_TAPE_INSERTED			= 0x02720344,
160 	VA_HAS_KEY					= 0x0090EA95,
161 	VA_IS_KEY_INSERTED			= 0x08D0AB11,
162 	VA_LOCKS_DISABLED			= 0x14800353,
163 	V_END_
164 };
165 
166 struct GameVar {
167 	uint32 nameHash;
168 	uint32 value;
169 	int16 firstIndex, nextIndex;
170 };
171 
172 class Console;
173 
174 class GameVars {
175 public:
176 	GameVars();
177 	void clear();
178 	void loadState(Common::InSaveFile *in);
179 	void saveState(Common::OutSaveFile *out);
180 	uint32 getGlobalVar(uint32 nameHash);
181 	void setGlobalVar(uint32 nameHash, uint32 value);
182 	uint32 getSubVar(uint32 nameHash, uint32 subNameHash);
183 	void setSubVar(uint32 nameHash, uint32 subNameHash, uint32 value);
184 	void dumpVars(Console *con);
185 protected:
186 	Common::Array<GameVar> _vars;
187 	int16 addVar(uint32 nameHash, uint32 value);
188 	int16 findSubVarIndex(int16 varIndex, uint32 subNameHash);
189 	int16 addSubVar(int16 varIndex, uint32 subNameHash, uint32 value);
190 	int16 getSubVarIndex(int16 varIndex, uint32 subNameHash);
191 };
192 
193 } // End of namespace Neverhood
194 
195 #endif /* NEVERHOOD_GAMEVARS_H */
196