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 ULTIMA4_CORE_DEBUGGER_H
24 #define ULTIMA4_CORE_DEBUGGER_H
25 
26 #include "ultima/ultima4/core/coords.h"
27 #include "ultima/ultima4/core/types.h"
28 #include "ultima/ultima4/core/debugger_actions.h"
29 #include "ultima/shared/engine/debugger.h"
30 
31 namespace Ultima {
32 namespace Ultima4 {
33 
34 /**
35  * Debugger base class
36  */
37 class Debugger : public Shared::Debugger, public DebuggerActions {
38 private:
39 	MapTile _horse, _ship, _balloon;
40 	bool _dontEndTurn;
41 protected:
42 	/**
43 	 * Returns true if the debugger is active
44 	 */
isDebuggerActive()45 	bool isDebuggerActive() const override {
46 		return isActive();
47 	}
48 
49 	/**
50 	 * Process the given command line.
51 	 * Returns true if and only if argv[0] is a known command and was
52 	 * handled, false otherwise.
53 	 */
54 	bool handleCommand(int argc, const char **argv, bool &keepRunning) override;
55 
56 	/**
57 	 * Prints a message to the console if it's active, or to the
58 	 * game screen if not
59 	 */
60 	void print(const char *fmt, ...) override;
61 
62 	/**
63 	 * Prints a message to the console if it's active, or to the
64 	 * game screen if not, with no newline
65 	 */
66 	void printN(const char *fmt, ...) override;
67 
68 	/**
69 	 * Prompts for input, but only if debugger isn't running
70 	 */
71 	void prompt() override;
72 
73 	/**
74 	 * Gets the direction for an action
75 	 */
76 	Direction getDirection(int argc, const char **argv);
77 
78 	/**
79 	 * Used by methods so that when they're triggered by a keybinding
80 	 * action, stops the turn from being finished when they're done
81 	 */
dontEndTurn()82 	void dontEndTurn() {
83 		_dontEndTurn = true;
84 	}
85 private:
86 	/**
87 	 * Move the avatar in a given direction
88 	 */
89 	bool cmdMove(int argc, const char **argv);
90 
91 	/**
92 	 * Attack
93 	 */
94 	bool cmdAttack(int argc, const char **argv);
95 
96 	/**
97 	 * Board transport
98 	 */
99 	bool cmdBoard(int argc, const char **argv);
100 
101 	/**
102 	 * Cast spell
103 	 */
104 	bool cmdCastSpell(int argc, const char **argv);
105 
106 	/**
107 	 * Climb
108 	 */
109 	bool cmdClimb(int argc, const char **argv);
110 
111 	/**
112 	 * Descend
113 	 */
114 	bool cmdDescend(int argc, const char **argv);
115 
116 	/**
117 	 * Enter location
118 	 */
119 	bool cmdEnter(int argc, const char **argv);
120 
121 	/**
122 	 * Exit
123 	 */
124 	bool cmdExit(int argc, const char **argv);
125 
126 	/**
127 	 * Fire
128 	 */
129 	bool cmdFire(int argc, const char **argv);
130 
131 	/**
132 	 * Get chest
133 	 */
134 	bool cmdGetChest(int argc, const char **argv);
135 
136 	/**
137 	 * Hole Up & Camp
138 	 */
139 	bool cmdCamp(int argc, const char **argv);
140 
141 	/**
142 	 * Ignite Torch
143 	 */
144 	bool cmdIgnite(int argc, const char **argv);
145 
146 	/**
147 	 * Generic interaction
148 	 */
149 	bool cmdInteract(int argc, const char **argv);
150 
151 	/**
152 	 * Jimmy lock
153 	 */
154 	bool cmdJimmy(int argc, const char **argv);
155 
156 	/**
157 	 * Locate position
158 	 */
159 	bool cmdLocate(int argc, const char **argv);
160 
161 	/**
162 	 * Mix reagents
163 	 */
164 	bool cmdMixReagents(int argc, const char **argv);
165 
166 	/**
167 	 * Exchanges the position of two players in the party.  Prompts the
168 	 * user for the player numbers.
169 	 */
170 	bool cmdNewOrder(int argc, const char **argv);
171 
172 	/**
173 	 * Open door
174 	 */
175 	bool cmdOpenDoor(int argc, const char **argv);
176 
177 	/**
178 	 * Specifies a particular party number
179 	 */
180 	bool cmdParty(int argc, const char **argv);
181 
182 	/**
183 	 * Pass turn
184 	 */
185 	bool cmdPass(int argc, const char **argv);
186 
187 	/**
188 	 * Peer
189 	 */
190 	bool cmdPeer(int argc, const char **argv);
191 
192 	/**
193 	 * Save and quit
194 	 */
195 	bool cmdQuitAndSave(int argc, const char **argv);
196 
197 	/**
198 	 * Readies a weapon for a player.  Prompts for the player and/or the
199 	 * weapon if not provided.
200 	 */
201 	bool cmdReadyWeapon(int argc, const char **argv);
202 
203 	/**
204 	 * Search
205 	 */
206 	bool cmdSearch(int argc, const char **argv);
207 
208 	/**
209 	 * Speed up, down, or normal
210 	 */
211 	bool cmdSpeed(int argc, const char **argv);
212 
213 	/**
214 	 * Combat speed up, down, or normal
215 	 */
216 	bool cmdCombatSpeed(int argc, const char **argv);
217 
218 
219 	/**
220 	 * Show character stats
221 	 */
222 	bool cmdStats(int argc, const char **argv);
223 
224 	/**
225 	 * Talk
226 	 */
227 	bool cmdTalk(int argc, const char **argv);
228 
229 	/**
230 	 * Use
231 	 */
232 	bool cmdUse(int argc, const char **argv);
233 
234 	/**
235 	 * Changes a player's armor
236 	 */
237 	bool cmdWearArmor(int argc, const char **argv);
238 
239 	/**
240 	 * Yell
241 	 */
242 	bool cmdYell(int argc, const char **argv);
243 private:
244 	/**
245 	 * Collision detection on/off
246 	 */
247 	bool cmd3d(int argc, const char **argv);
248 
249 	/**
250 	 * Teleports to the Abyss final altar
251 	 */
252 	bool cmdAbyss(int argc, const char **argv);
253 
254 	/**
255 	 * Collision detection on/off
256 	 */
257 	bool cmdCollisions(int argc, const char **argv);
258 
259 	/**
260 	 * Have all the companions join the party
261 	 */
262 	bool cmdCompanions(int argc, const char **argv);
263 
264 	/**
265 	 * Toggle whether combat occurs
266 	 */
267 	bool cmdCombat(int argc, const char **argv);
268 
269 	/**
270 	 * Destroy an object
271 	 */
272 	bool cmdDestroy(int argc, const char **argv);
273 
274 	/**
275 	 * Destroy all creatures
276 	 */
277 	bool cmdDestroyCreatures(int argc, const char **argv);
278 
279 	/**
280 	 * Jumps to a given dungeon
281 	 */
282 	bool cmdDungeon(int argc, const char **argv);
283 
284 	/**
285 	 * Flee from combat
286 	 */
287 	bool cmdFlee(int argc, const char **argv);
288 
289 	/**
290 	 * All equipement
291 	 */
292 	bool cmdEquipment(int argc, const char **argv);
293 
294 	/**
295 	 * Full stats
296 	 */
297 	bool cmdFullStats(int argc, const char **argv);
298 
299 	/**
300 	 * Toggle hunger on or off
301 	 */
302 	bool cmdHunger(int argc, const char **argv);
303 
304 	/**
305 	 * Moongate teleportation
306 	 */
307 	bool cmdGate(int argc, const char **argv);
308 
309 	/**
310 	 * Go to any specified location by name
311 	 */
312 	bool cmdGoto(int argc, const char **argv);
313 
314 	/**
315 	 * Help.. sends the party to Lord British
316 	 */
317 	bool cmdLorddBritish(int argc, const char **argv);
318 
319 	/**
320 	 * Grant karma
321 	 */
322 	bool cmdKarma(int argc, const char **argv);
323 
324 	/**
325 	 * Give all the items
326 	 */
327 	bool cmdItems(int argc, const char **argv);
328 
329 	/**
330 	 * Leave the current location
331 	 */
332 	bool cmdLeave(int argc, const char **argv);
333 
334 	/**
335 	 * Displays the current location
336 	 */
337 	bool cmdLocation(int argc, const char **argv);
338 
339 	/**
340 	 * Give all the mixtures
341 	 */
342 	bool cmdMixtures(int argc, const char **argv);
343 
344 	/**
345 	 * Moon phase
346 	 */
347 	bool cmdMoon(int argc, const char **argv);
348 
349 	/**
350 	 * Toggle opacity
351 	 */
352 	bool cmdOpacity(int argc, const char **argv);
353 
354 	/**
355 	 * Toggle overhead view
356 	 */
357 	bool cmdOverhead(int argc, const char **argv);
358 
359 	/**
360 	 * Give all the reagents
361 	 */
362 	bool cmdReagents(int argc, const char **argv);
363 
364 	/**
365 	 * Summons a creature to fight
366 	 */
367 	bool cmdSummon(int argc, const char **argv);
368 
369 	/**
370 	 * Returns the torch duration
371 	 */
372 	bool cmdTorch(int argc, const char **argv);
373 
374 	/**
375 	 * Creates a given transport
376 	 */
377 	bool cmdTransport(int argc, const char **argv);
378 
379 	/**
380 	 * Move up a floor
381 	 */
382 	bool cmdUp(int argc, const char **argv);
383 
384 	/**
385 	 * Move down a floor
386 	 */
387 	bool cmdDown(int argc, const char **argv);
388 
389 	/**
390 	 * Gives full virtue, or increments a specific virtue
391 	 */
392 	bool cmdVirtue(int argc, const char **argv);
393 
394 	/**
395 	 * Set wind direction or locks the direction
396 	 */
397 	bool cmdWind(int argc, const char **argv);
398 
399 	/**
400 	 * Lists the triggers in a dungeon room
401 	 */
402 	bool cmdListTriggers(int argc, const char **argv);
403 public:
404 	bool _collisionOverride;
405 	bool _disableHunger;
406 	bool _disableCombat;
407 public:
408 	Debugger();
409 	~Debugger() override;
410 
411 	/**
412 	 * Gets a chest.
413 	 * If the default -2 is used, it bypasses prompting for a
414 	 * user. Otherwise, a non-negative player number is expected
415 	 */
416 	void getChest(int player = -2);
417 };
418 
419 extern Debugger *g_debugger;
420 
421 } // End of namespace Ultima4
422 } // End of namespace Ultima
423 
424 #endif
425