mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-08 10:51:11 +00:00
ULTIMA8: Fix compilation of DEBUG code
This commit is contained in:
parent
67a5d0d7e3
commit
844a26e34b
@ -113,6 +113,9 @@ inline void u6debug(bool no_header, const DebugLevelType level, const char *form
|
||||
extern void u6debug(bool no_header, const DebugLevelType level, const char *format, ...);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
#define DEBUG u6debug
|
||||
|
||||
#define U6PATH_DELIMITER '/'
|
||||
|
@ -107,7 +107,7 @@ template<class T>
|
||||
class set {
|
||||
struct Comparitor {
|
||||
bool operator()(const T &a, const T &b) const {
|
||||
return a.Compare(b);
|
||||
return a == b;
|
||||
}
|
||||
};
|
||||
|
||||
@ -129,6 +129,13 @@ public:
|
||||
iterator begin() { return _items.begin(); }
|
||||
iterator end() { return _items.end(); }
|
||||
|
||||
/**
|
||||
* Clear the set
|
||||
*/
|
||||
void clear() {
|
||||
_items.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new item
|
||||
*/
|
||||
@ -152,6 +159,15 @@ public:
|
||||
void swap(set<T> &arr) {
|
||||
_items.swap(arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an item
|
||||
*/
|
||||
iterator find(T item) {
|
||||
iterator it = begin();
|
||||
for (; it != end() && *it != item; ++it) {}
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
||||
template<class Key, class Val, class HashFunc = Common::Hash<Key>,
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "ultima/ultima8/world/item_factory.h"
|
||||
#include "ultima/ultima8/world/actors/quick_avatar_mover_process.h"
|
||||
#include "ultima/ultima8/world/actors/main_actor.h"
|
||||
#include "ultima/ultima8/world/actors/pathfinder.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima8 {
|
||||
@ -153,7 +154,7 @@ Debugger::Debugger() : Shared::Debugger() {
|
||||
registerCmd("ShapeViewerGump::U8ShapeViewer", WRAP_METHOD(Debugger, cmdU8ShapeViewer));
|
||||
|
||||
#ifdef DEBUG
|
||||
registerCmd("Pathfinder::visualDebug", Pathfinder::cmdVisualDebugPathfinder);
|
||||
registerCmd("Pathfinder::visualDebug", WRAP_METHOD(Debugger, cmdVisualDebugPathfinder));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1145,7 +1146,7 @@ bool Debugger::cmdMemInfo(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool Debugger::cmdTest(int argc, const char **argv) {
|
||||
bool Debugger::cmdTestMemory(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@ -1331,11 +1332,11 @@ bool Debugger::cmdTracePID(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16 _pid = static_cast<uint16>(strtol(argv[1].c_str(), 0, 0));
|
||||
uint16 pid = static_cast<uint16>(strtol(argv[1], 0, 0));
|
||||
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->tracing_enabled = true;
|
||||
uc->trace_PIDs.insert(_pid);
|
||||
uc->_tracingEnabled = true;
|
||||
uc->_tracePIDs.insert(pid);
|
||||
|
||||
debugPrintf("UCMachine: tracing process %d\n", pid);
|
||||
return true;
|
||||
@ -1347,11 +1348,11 @@ bool Debugger::cmdTraceObjID(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16 objid = static_cast<uint16>(strtol(argv[1].c_str(), 0, 0));
|
||||
uint16 objid = static_cast<uint16>(strtol(argv[1], 0, 0));
|
||||
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->tracing_enabled = true;
|
||||
uc->trace_ObjIDs.insert(objid);
|
||||
uc->_tracingEnabled = true;
|
||||
uc->_traceObjIDs.insert(objid);
|
||||
|
||||
debugPrintf("UCMachine: tracing object %d\n", objid);
|
||||
return true;
|
||||
@ -1363,11 +1364,11 @@ bool Debugger::cmdTraceClass(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16 ucclass = static_cast<uint16>(strtol(argv[1].c_str(), 0, 0));
|
||||
uint16 ucclass = static_cast<uint16>(strtol(argv[1], 0, 0));
|
||||
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->tracing_enabled = true;
|
||||
uc->trace_classes.insert(ucclass);
|
||||
uc->_tracingEnabled = true;
|
||||
uc->_traceClasses.insert(ucclass);
|
||||
|
||||
debugPrintf("UCMachine: tracing class %d\n", ucclass);
|
||||
return true;
|
||||
@ -1375,8 +1376,8 @@ bool Debugger::cmdTraceClass(int argc, const char **argv) {
|
||||
|
||||
bool Debugger::cmdTraceAll(int argc, const char **argv) {
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->tracing_enabled = true;
|
||||
uc->trace_all = true;
|
||||
uc->_tracingEnabled = true;
|
||||
uc->_traceAll = true;
|
||||
|
||||
debugPrintf("UCMachine: tracing all usecode\n");
|
||||
return true;
|
||||
@ -1384,21 +1385,21 @@ bool Debugger::cmdTraceAll(int argc, const char **argv) {
|
||||
|
||||
bool Debugger::cmdTraceEvents(int argc, const char **argv) {
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->tracing_enabled = true;
|
||||
uc->trace_events = true;
|
||||
uc->_tracingEnabled = true;
|
||||
uc->_traceEvents = true;
|
||||
|
||||
debugPrintf("UCMachine: tracing usecode events\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Debugger::cmdStopTrace(const Console::ArgvType &/*argv*/) {
|
||||
bool Debugger::cmdStopTrace(int argc, const char **argv) {
|
||||
UCMachine *uc = UCMachine::get_instance();
|
||||
uc->trace_ObjIDs.clear();
|
||||
uc->trace_PIDs.clear();
|
||||
uc->trace_classes.clear();
|
||||
uc->tracing_enabled = false;
|
||||
uc->trace_all = false;
|
||||
uc->trace_events = false;
|
||||
uc->_traceObjIDs.clear();
|
||||
uc->_tracePIDs.clear();
|
||||
uc->_traceClasses.clear();
|
||||
uc->_tracingEnabled = false;
|
||||
uc->_traceAll = false;
|
||||
uc->_traceEvents = false;
|
||||
|
||||
debugPrintf("Trace stopped\n");
|
||||
return true;
|
||||
@ -1506,16 +1507,18 @@ bool Debugger::cmdVisualDebugPathfinder(int argc, const char **argv) {
|
||||
if (argc != 2) {
|
||||
debugPrintf("Usage: Pathfinder::visualDebug objid\n");
|
||||
debugPrintf("Specify objid -1 to stop tracing.\n");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
int p = strtol(argv[1].c_str(), 0, 0);
|
||||
int p = strtol(argv[1], 0, 0);
|
||||
if (p == -1) {
|
||||
visualdebug_actor = 0xFFFF;
|
||||
Pathfinder::_visualDebugActor = 0xFFFF;
|
||||
debugPrintf("Pathfinder: stopped visual tracing\n");
|
||||
} else {
|
||||
visualdebug_actor = (uint16)p;
|
||||
debugPrintf("Pathfinder: visually tracing _actor " << visualdebug_actor << Std::endl;
|
||||
Pathfinder::_visualDebugActor = (uint16)p;
|
||||
debugPrintf("Pathfinder: visually tracing _actor %d\n", Pathfinder::_visualDebugActor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1337,9 +1337,7 @@ Common::Error Ultima8Engine::loadGameStream(Common::SeekableReadStream *stream)
|
||||
_settingMan->get("ignore_savegame_mismatch", ignore);
|
||||
|
||||
if (!ignore) {
|
||||
Error(message, "Error Loading savegame " + filename);
|
||||
delete sg;
|
||||
return false;
|
||||
error("%s", message.c_str());
|
||||
}
|
||||
perr << message << Std::endl;
|
||||
#else
|
||||
|
@ -97,8 +97,8 @@ UCMachine::UCMachine(Intrinsic *iset, unsigned int icount) {
|
||||
_stringIDs = new idMan(1, 65534, 256);
|
||||
|
||||
#ifdef DEBUG
|
||||
tracing_enabled = false;
|
||||
trace_all = false;
|
||||
_tracingEnabled = false;
|
||||
_traceAll = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ void UCMachine::execProcess(UCProcess *p) {
|
||||
#ifdef DEBUG
|
||||
if (trace_show(p->_pid, p->_itemNum, p->_classId)) {
|
||||
pout << Std::hex << "running process " << p->_pid
|
||||
<< ", item " << p->_itemNum << ", type " << p->type
|
||||
<< ", item " << p->_itemNum << ", type " << p->_type
|
||||
<< ", class " << p->_classId << ", offset " << p->_ip
|
||||
<< Std::dec << Std::endl;
|
||||
}
|
||||
@ -354,7 +354,7 @@ void UCMachine::execProcess(UCProcess *p) {
|
||||
//! TODO
|
||||
uint16 arg_bytes = cs.read1();
|
||||
uint16 func = cs.read2();
|
||||
LOGPF(("calli\t\t%04Xh (%02Xh arg bytes) %s \n", func, arg_bytes, _convUse->_intrinsics()[func]));
|
||||
debug(("calli\t\t%04Xh (%02Xh arg bytes) %s \n", func, arg_bytes, _convUse->intrinsics()[func]));
|
||||
|
||||
// !constants
|
||||
if (func >= _intrinsicCount || _intrinsics[func] == 0) {
|
||||
@ -1337,7 +1337,7 @@ void UCMachine::execProcess(UCProcess *p) {
|
||||
#ifdef DEBUG
|
||||
if (trace_show(p->_pid, p->_itemNum, p->_classId)) {
|
||||
pout << Std::hex << "(still) running process " << p->_pid
|
||||
<< ", item " << p->_itemNum << ", type " << p->type
|
||||
<< ", item " << p->_itemNum << ", type " << p->_type
|
||||
<< ", class " << p->_classId << ", offset " << p->_ip
|
||||
<< Std::dec << Std::endl;
|
||||
}
|
||||
@ -1365,10 +1365,10 @@ void UCMachine::execProcess(UCProcess *p) {
|
||||
uint16 offset = cs.read2();
|
||||
uint16 delta = cs.read2();
|
||||
int this_size = cs.read1();
|
||||
(void)cs.read1(); // ??
|
||||
int unknown = cs.read1(); // ??
|
||||
|
||||
LOGPF(("spawn inline\t%04X:%04X+%04X=%04X %02X %02X\n",
|
||||
classid, offset, delta, offset + delta, this_size, unknown));
|
||||
debug("spawn inline\t%04X:%04X+%04X=%04X %02X %02X\n",
|
||||
classid, offset, delta, offset + delta, this_size, unknown);
|
||||
|
||||
uint32 thisptr = 0;
|
||||
if (this_size > 0)
|
||||
|
@ -23,6 +23,7 @@
|
||||
#ifndef ULTIMA8_USECODE_UCMACHINE_H
|
||||
#define ULTIMA8_USECODE_UCMACHINE_H
|
||||
|
||||
#include "ultima/ultima8/misc/common_types.h"
|
||||
#include "ultima/shared/std/containers.h"
|
||||
#include "ultima/ultima8/usecode/intrinsics.h"
|
||||
|
||||
@ -114,25 +115,25 @@ private:
|
||||
|
||||
#ifdef DEBUG
|
||||
// tracing
|
||||
bool tracing_enabled;
|
||||
bool trace_all;
|
||||
bool trace_events;
|
||||
Std::set<ObjId> trace_ObjIDs;
|
||||
Std::set<ProcId> trace_PIDs;
|
||||
Std::set<uint16> trace_classes;
|
||||
bool _tracingEnabled;
|
||||
bool _traceAll;
|
||||
bool _traceEvents;
|
||||
Std::set<ObjId> _traceObjIDs;
|
||||
Std::set<ProcId> _tracePIDs;
|
||||
Std::set<uint16> _traceClasses;
|
||||
|
||||
inline bool trace_show(ProcId pid, ObjId objid, uint16 ucclass) {
|
||||
if (!tracing_enabled) return false;
|
||||
if (trace_all) return true;
|
||||
if (trace_ObjIDs.find(objid) != trace_ObjIDs.end()) return true;
|
||||
if (trace_PIDs.find(pid) != trace_PIDs.end()) return true;
|
||||
if (trace_classes.find(ucclass) != trace_classes.end()) return true;
|
||||
if (!_tracingEnabled) return false;
|
||||
if (_traceAll) return true;
|
||||
if (_traceObjIDs.find(objid) != _traceObjIDs.end()) return true;
|
||||
if (_tracePIDs.find(pid) != _tracePIDs.end()) return true;
|
||||
if (_traceClasses.find(ucclass) != _traceClasses.end()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
bool trace_event() {
|
||||
return (tracing_enabled && (trace_all || trace_events));
|
||||
return (_tracingEnabled && (_traceAll || _traceEvents));
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
@ -33,7 +33,7 @@ namespace Ultima {
|
||||
namespace Ultima8 {
|
||||
|
||||
#ifdef DEBUG
|
||||
ObjId Pathfinder::visualdebug_actor = 0xFFFF;
|
||||
ObjId Pathfinder::_visualDebugActor = 0xFFFF;
|
||||
#endif
|
||||
|
||||
struct PathNode {
|
||||
@ -403,12 +403,12 @@ void Pathfinder::newNode(PathNode *oldnode, PathfindingState &state,
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_actor->getObjId() == visualdebug_actor) {
|
||||
if (_actor->getObjId() == _visualDebugActor) {
|
||||
RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
|
||||
screen->BeginPainting();
|
||||
drawpath(newnode, 0xFFFFFF00, done);
|
||||
screen->EndPainting();
|
||||
SDL_Delay(250);
|
||||
g_system->delayMillis(250);
|
||||
if (!done) {
|
||||
screen->BeginPainting();
|
||||
drawpath(newnode, 0xFFB0B000, done);
|
||||
@ -513,7 +513,7 @@ bool Pathfinder::pathfind(Std::vector<PathfindingAction> &path) {
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
if (_actor->getObjId() == visualdebug_actor) {
|
||||
if (_actor->getObjId() == _visualDebugActor) {
|
||||
RenderSurface *screen = Ultima8Engine::get_instance()->getRenderScreen();
|
||||
screen->BeginPainting();
|
||||
if (_targetItem)
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
bool pathfind(Std::vector<PathfindingAction> &path);
|
||||
|
||||
#ifdef DEBUG
|
||||
static ObjId visualdebug_actor;
|
||||
static ObjId _visualDebugActor;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -1035,8 +1035,8 @@ uint32 Item::callUsecodeEvent(uint32 event, const uint8 *args, int argsize) {
|
||||
|
||||
#ifdef DEBUG
|
||||
if (UCMachine::get_instance()->trace_event()) {
|
||||
pout.printf("Item: %d calling usecode event %d @ %04X:%04X\n",
|
||||
_objId, event, class_id, offset);
|
||||
pout.Print("Item: %d calling usecode event %d @ %04X:%04X\n",
|
||||
_objId, event, class_id, offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user