aboutsummaryrefslogtreecommitdiff
path: root/engines/cruise/debugger.cpp
blob: d4e706a094764c5e282e7b504bc6c6dcc9167ca4 (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
/* 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.
 *
 */

#include "cruise/debugger.h"
#include "cruise/cell.h"
#include "cruise/cruise_main.h"
#include "cruise/object.h"
#include "cruise/overlay.h"

namespace Cruise {

Debugger::Debugger(): GUI::Debugger() {
	registerCmd("continue",			WRAP_METHOD(Debugger, cmdExit));
	registerCmd("hotspots",				WRAP_METHOD(Debugger, cmd_hotspots));
	registerCmd("items",				WRAP_METHOD(Debugger, cmd_items));
}

/**
 * Preliminary command to list the currently loaded hotspots
 */
bool Debugger::cmd_hotspots(int argc, const char **argv) {
	const char *pObjType;
	objectParamsQuery params;

	cellStruct *currentObject = cellHead.prev;

	while (currentObject) {
		if (currentObject->overlay > 0 && overlayTable[currentObject->overlay].alreadyLoaded &&
			(currentObject->type == OBJ_TYPE_SPRITE || currentObject->type == OBJ_TYPE_MASK ||
			currentObject->type == OBJ_TYPE_EXIT || currentObject->type == OBJ_TYPE_VIRTUAL)) {
			const char *pObjectName = getObjectName(currentObject->idx, overlayTable[currentObject->overlay].ovlData->arrayNameObj);

			switch (currentObject->type) {
			case OBJ_TYPE_SPRITE:
				pObjType = "SPRITE";
				break;
			case OBJ_TYPE_MASK:
				pObjType = "MASK";
				break;
			case OBJ_TYPE_EXIT:
				pObjType = "EXIT";
				break;
			case OBJ_TYPE_VIRTUAL:
				pObjType = "VIRTUAL";
				break;
			default:
				pObjType = "UNKNOWN";
				break;
			}

			if (*pObjectName) {
				getMultipleObjectParam(currentObject->overlay, currentObject->idx, &params);

				debugPrintf("%s %s - %d,%d\n", pObjectName, pObjType, params.X, params.Y);
			}
		}

		currentObject = currentObject->prev;
	}

	return true;
}

/**
 * Preliminary command to list the current items in the player's inventory
 */
bool Debugger::cmd_items(int argc, const char **argv) {
	for (int i = 1; i < numOfLoadedOverlay; i++) {
		ovlDataStruct *pOvlData = overlayTable[i].ovlData;

		if (overlayTable[i].alreadyLoaded) {
			if (overlayTable[i].ovlData->arrayObject) {
				for (int j = 0; j < pOvlData->numObj; j++) {
					if (getObjectClass(i, j) != 3) {
						int16 returnVar;

						getSingleObjectParam(i, j, 5, &returnVar);

						if (returnVar < -1)
							debugPrintf("%s\n", getObjectName(j, pOvlData->arrayNameObj));
					}
				}
			}
		}
	}

	return true;
}

} // End of namespace Cruise