[Scummvm-git-logs] scummvm master -> 10be96afd6647c17668a7c40356ad03468e16e85

dreammaster paulfgilbert at gmail.com
Sun Feb 23 18:33:46 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
10be96afd6 ULTIMA8: Fix debugger support methods to display text in the debugger


Commit: 10be96afd6647c17668a7c40356ad03468e16e85
    https://github.com/scummvm/scummvm/commit/10be96afd6647c17668a7c40356ad03468e16e85
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-23T10:33:16-08:00

Commit Message:
ULTIMA8: Fix debugger support methods to display text in the debugger

Changed paths:
    engines/ultima/ultima8/kernel/hid_manager.cpp
    engines/ultima/ultima8/kernel/kernel.cpp
    engines/ultima/ultima8/kernel/object.cpp
    engines/ultima/ultima8/kernel/object_manager.cpp
    engines/ultima/ultima8/kernel/process.cpp
    engines/ultima/ultima8/misc/debugger.cpp
    engines/ultima/ultima8/usecode/uc_machine.cpp
    engines/ultima/ultima8/world/world.cpp


diff --git a/engines/ultima/ultima8/kernel/hid_manager.cpp b/engines/ultima/ultima8/kernel/hid_manager.cpp
index 52e1985..4860d67 100644
--- a/engines/ultima/ultima8/kernel/hid_manager.cpp
+++ b/engines/ultima/ultima8/kernel/hid_manager.cpp
@@ -103,8 +103,6 @@ void HIDManager::loadBindings() {
 		bind(i->_key, args);
 		++i;
 	}
-
-	listBindings();
 }
 
 void HIDManager::saveBindings() {
@@ -196,10 +194,10 @@ void HIDManager::listBindings() {
 		ArgvToString(*(it->_value), command);
 
 		if (event == HID_EVENT_DEPRESS) {
-			pout << HID_GetKeyName((HID_Key)key) << " = " << command << Std::endl;
+			g_debugger->debugPrintf("%s = %s\n", HID_GetKeyName((HID_Key)key), command.c_str());
 		} else {
-			pout << HID_GetEventsName((HID_Events)event);
-			pout << ' ' << HID_GetKeyName((HID_Key) key) << " = " << command << Std::endl;
+			g_debugger->debugPrintf("%s", HID_GetEventsName((HID_Events)event));
+			g_debugger->debugPrintf(" %s = %s\n", HID_GetKeyName((HID_Key)key), command.c_str());
 		}
 	}
 }
diff --git a/engines/ultima/ultima8/kernel/kernel.cpp b/engines/ultima/ultima8/kernel/kernel.cpp
index dc5ecd4..4d3fe78 100644
--- a/engines/ultima/ultima8/kernel/kernel.cpp
+++ b/engines/ultima/ultima8/kernel/kernel.cpp
@@ -238,12 +238,12 @@ Process *Kernel::getProcess(ProcId pid) {
 }
 
 void Kernel::kernelStats() {
-	pout << "Kernel memory stats:" << Std::endl;
-	pout << "Processes  : " << processes.size() << "/32765" << Std::endl;
+	g_debugger->debugPrintf("Kernel memory stats:\n");
+	g_debugger->debugPrintf("Processes  : %u/32765\n", processes.size());
 }
 
 void Kernel::processTypes() {
-	pout << "Current process types:" << Std::endl;
+	g_debugger->debugPrintf("Current process types:\n");
 	Std::map<Common::String, unsigned int> processtypes;
 	for (ProcessIterator it = processes.begin(); it != processes.end(); ++it) {
 		Process *p = *it;
@@ -251,7 +251,7 @@ void Kernel::processTypes() {
 	}
 	Std::map<Common::String, unsigned int>::iterator iter;
 	for (iter = processtypes.begin(); iter != processtypes.end(); ++iter) {
-		pout << (*iter)._key << ": " << (*iter)._value << Std::endl;
+		g_debugger->debugPrintf("%s: %u\n", (*iter)._key.c_str(), (*iter)._value);
 	}
 }
 
diff --git a/engines/ultima/ultima8/kernel/object.cpp b/engines/ultima/ultima8/kernel/object.cpp
index b6d4aa1..13e3caf 100644
--- a/engines/ultima/ultima8/kernel/object.cpp
+++ b/engines/ultima/ultima8/kernel/object.cpp
@@ -60,8 +60,7 @@ void Object::clearObjId() {
 }
 
 void Object::dumpInfo() {
-	pout << "Object " << getObjId() << " (class "
-	     << GetClassType()._className << ")" << Std::endl;
+	g_debugger->debugPrintf("Object %d (class %s)\n", getObjId(), GetClassType()._className);
 }
 
 ProcId Object::callUsecode(uint16 classid, uint16 offset,
diff --git a/engines/ultima/ultima8/kernel/object_manager.cpp b/engines/ultima/ultima8/kernel/object_manager.cpp
index 41ebb58..c9cdf0d 100644
--- a/engines/ultima/ultima8/kernel/object_manager.cpp
+++ b/engines/ultima/ultima8/kernel/object_manager.cpp
@@ -136,13 +136,13 @@ void ObjectManager::objectStats() {
 			objcount++;
 	}
 
-	pout << "Object memory stats:" << Std::endl;
-	pout << "NPCs       : " << npccount << "/255" << Std::endl;
-	pout << "Objects    : " << objcount << "/32511" << Std::endl;
+	g_debugger->debugPrintf("Object memory stats:\n");
+	g_debugger->debugPrintf("NPCs       : %u/255\n", npccount);
+	g_debugger->debugPrintf("Objects    : %u/32511\n", objcount);
 }
 
 void ObjectManager::objectTypes() {
-	pout << "Current object types:" << Std::endl;
+	g_debugger->debugPrintf("Current object types:\n");
 	Std::map<Common::String, unsigned int> objecttypes;
 	for (unsigned int i = 1; i < _objects.size(); ++i) {
 		Object *o = _objects[i];
@@ -152,7 +152,7 @@ void ObjectManager::objectTypes() {
 
 	Std::map<Common::String, unsigned int>::iterator iter;
 	for (iter = objecttypes.begin(); iter != objecttypes.end(); ++iter) {
-		pout << (*iter)._key << ": " << (*iter)._value << Std::endl;
+		g_debugger->debugPrintf("%s: %u\n", (*iter)._key.c_str(), (*iter)._value);
 	}
 }
 
diff --git a/engines/ultima/ultima8/kernel/process.cpp b/engines/ultima/ultima8/kernel/process.cpp
index 6138148..a1a7541 100644
--- a/engines/ultima/ultima8/kernel/process.cpp
+++ b/engines/ultima/ultima8/kernel/process.cpp
@@ -97,25 +97,24 @@ void Process::suspend() {
 
 void Process::dumpInfo() {
 	Common::String info = Common::String::format(
-		"Process %d class %s, item %d, _type %x, status ",
+		"Process %d class %s, item %d, type %x, status ",
 		getPid(), GetClassType()._className, _itemNum, _type);
 
-	pout << info.c_str();
-	if (_flags & PROC_ACTIVE) pout << "A";
-	if (_flags & PROC_SUSPENDED) pout << "S";
-	if (_flags & PROC_TERMINATED) pout << "T";
-	if (_flags & PROC_TERM_DEFERRED) pout << "t";
-	if (_flags & PROC_FAILED) pout << "F";
-	if (_flags & PROC_RUNPAUSED) pout << "R";
+	if (_flags & PROC_ACTIVE) info += "A";
+	if (_flags & PROC_SUSPENDED) info += "S";
+	if (_flags & PROC_TERMINATED) info += "T";
+	if (_flags & PROC_TERM_DEFERRED) info += "t";
+	if (_flags & PROC_FAILED) info += "F";
+	if (_flags & PROC_RUNPAUSED) info += "R";
 	if (!waiting.empty()) {
-		pout << ", notify: ";
-		for (Std::vector<ProcId>::iterator i = waiting.begin();
-		        i != waiting.end(); ++i) {
-			if (i != waiting.begin()) pout << ", ";
-			pout << *i;
+		info += ", notify: ";
+		for (Std::vector<ProcId>::iterator i = waiting.begin(); i != waiting.end(); ++i) {
+			if (i != waiting.begin()) info += ", ";
+			info += *i;
 		}
 	}
-	pout << Std::endl;
+
+	g_debugger->debugPrintf("%s\n", info.c_str());
 }
 
 void Process::save(ODataSource *ods) {
diff --git a/engines/ultima/ultima8/misc/debugger.cpp b/engines/ultima/ultima8/misc/debugger.cpp
index 0f6ed9a..585ce3b 100644
--- a/engines/ultima/ultima8/misc/debugger.cpp
+++ b/engines/ultima/ultima8/misc/debugger.cpp
@@ -241,7 +241,7 @@ bool Debugger::cmdNewGame(int argc, const char **argv) {
 
 bool Debugger::cmdQuit(int argc, const char **argv) {
 	Ultima8Engine::get_instance()->_isRunning = false;
-	return true;
+	return false;
 }
 
 bool Debugger::cmdEngineStats(int argc, const char **argv) {
@@ -297,14 +297,14 @@ bool Debugger::cmdSetVideoMode(int argc, const char **argv) {
 bool Debugger::cmdToggleAvatarInStasis(int argc, const char **argv) {
 	Ultima8Engine *g = Ultima8Engine::get_instance();
 	g->toggleAvatarInStasis();
-	debugPrintf("_avatarInStasis = %s\n", strBool(g->isAvatarInStasis()));
+	debugPrintf("avatarInStasis = %s\n", strBool(g->isAvatarInStasis()));
 	return true;
 }
 
 bool Debugger::cmdTogglePaintEditorItems(int argc, const char **argv) {
 	Ultima8Engine *g = Ultima8Engine::get_instance();
 	g->togglePaintEditorItems();
-	debugPrintf("_paintEditorItems = %s\n", strBool(g->isPaintEditorItems()));
+	debugPrintf("paintEditorItems = %s\n", strBool(g->isPaintEditorItems()));
 	return true;
 }
 
@@ -318,7 +318,7 @@ bool Debugger::cmdToggleShowTouchingItems(int argc, const char **argv) {
 bool Debugger::cmdCloseItemGumps(int argc, const char **argv) {
 	Ultima8Engine *g = Ultima8Engine::get_instance();
 	g->getDesktopGump()->CloseItemDependents();
-	return true;
+	return false;
 }
 
 bool Debugger::cmdMemberVar(int argc, const char **argv) {
@@ -628,9 +628,9 @@ bool Debugger::cmdCheatEquip(int argc, const char **argv) {
 		return true;
 	}
 	MainActor *av = getMainActor();
-	if (!av) return true;
+	if (!av) return false;
 	Container *backpack = getContainer(av->getEquip(7)); // CONSTANT!
-	if (!backpack) return true;
+	if (!backpack) return false;
 
 	Item *item;
 
@@ -932,10 +932,9 @@ bool Debugger::cmdSave(int argc, const char **argv) {
 }
 
 
-
 bool Debugger::cmdProcessTypes(int argc, const char **argv) {
 	Kernel::get_instance()->processTypes();
-	return false;
+	return true;
 }
 
 bool Debugger::cmdListProcesses(int argc, const char **argv) {
@@ -984,7 +983,7 @@ bool Debugger::cmdToggleFrameByFrame(int argc, const char **argv) {
 	Kernel *kern = Kernel::get_instance();
 	bool fbf = !kern->isFrameByFrame();
 	kern->setFrameByFrame(fbf);
-	debugPrintf("FrameByFrame = %s\n", fbf ? "true" : "false");
+	debugPrintf("FrameByFrame = %s\n", strBool(fbf));
 
 	if (fbf)
 		kern->pause();
@@ -1165,6 +1164,7 @@ bool Debugger::cmdToggleCombat(int argc, const char **argv) {
 		debugPrintf("Can't: avatarInStasis\n");
 		return true;
 	}
+
 	MainActor *av = getMainActor();
 	av->toggleInCombat();
 	return false;
@@ -1325,7 +1325,7 @@ bool Debugger::cmdToggleClipping(int argc, const char **argv) {
 	if (Ultima8Engine::get_instance()->areCheatsEnabled()) {
 		QuickAvatarMoverProcess::toggleClipping();
 		debugPrintf("QuickAvatarMoverProcess::_clipping = %s\n",
-			QuickAvatarMoverProcess::isClipping() ? "true" : "false");
+			strBool(QuickAvatarMoverProcess::isClipping()));
 	} else {
 		debugPrintf("Cheats aren't enabled\n");
 	}
@@ -1343,9 +1343,7 @@ bool Debugger::cmdGetGlobal(int argc, const char **argv) {
 	unsigned int offset = strtol(argv[1], 0, 0);
 	unsigned int size = strtol(argv[2], 0, 0);
 
-	pout.Print("[%04X %02X] = %d\n", offset, size,
-		uc->_globals->getBits(offset, size));
-
+	debugPrintf("[%04X %02X] = %d\n", offset, size, uc->_globals->getBits(offset, size));
 	return true;
 }
 
@@ -1534,7 +1532,7 @@ bool Debugger::cmdToggleMinimap(int argc, const char **argv) {
 		mmg->Close();
 	}
 
-	return true;
+	return false;
 }
 
 bool Debugger::cmdGenerateWholeMap(int argc, const char **argv) {
diff --git a/engines/ultima/ultima8/usecode/uc_machine.cpp b/engines/ultima/ultima8/usecode/uc_machine.cpp
index 4e6be62..c51fb5d 100644
--- a/engines/ultima/ultima8/usecode/uc_machine.cpp
+++ b/engines/ultima/ultima8/usecode/uc_machine.cpp
@@ -2195,32 +2195,32 @@ uint16 UCMachine::ptrToObject(uint32 ptr) {
 }
 
 void UCMachine::usecodeStats() {
-	pout << "Usecode Machine memory stats:" << Std::endl;
-	pout << "Strings    : " << _stringHeap.size() << "/65534" << Std::endl;
+	g_debugger->debugPrintf("Usecode Machine memory stats:\n");
+	g_debugger->debugPrintf("Strings    : %u/65534\n", _stringHeap.size());
 #ifdef DUMPHEAP
 	Std::map<uint16, Std::string>::iterator iter;
 	for (iter = _stringHeap.begin(); iter != _stringHeap.end(); ++iter)
-		pout << iter->first << ":" << iter->_value << Std::endl;
+		g_debugger->debugPrintf("%d:%s\n", iter->_key << ":" << iter->_value.c_str());
 #endif
-	pout << "Lists      : " << _listHeap.size() << "/65534" << Std::endl;
+	g_debugger->debugPrintf("Lists      : %u/65534\n", _listHeap.size());
 #ifdef DUMPHEAP
 	Std::map<uint16, UCList *>::iterator iterl;
 	for (iterl = _listHeap.begin(); iterl != _listHeap.end(); ++iterl) {
 		if (!iterl->_value) {
-			pout << iterl->first << ": <null>" << Std::endl;
+			g_debugger->debugPrintf("%d: <null>\n", iterl->_key);
 			continue;
 		}
 		if (iterl->_value->getElementSize() == 2) {
-			pout << iterl->first << ":";
+			g_debugger->debugPrintf("%d:", iterl->_key);
+
 			for (unsigned int i = 0; i < iterl->_value->getSize(); ++i) {
-				if (i > 0) pout << ",";
-				pout << iterl->_value->getuint16(i);
+				if (i > 0) g_debugger->debugPrintf(",");
+				g_debugger->debugPrintf("%d", iterl->_value->getuint16(i));
 			}
-			pout << Std::endl;
+			g_debugger->debugPrintf("\n");
 		} else {
-			pout << iterl->first << ": " << iterl->_value->getSize()
-			     << " elements of size " << iterl->_value->getElementSize()
-			     << Std::endl;
+			g_debugger->debugPrintf("%d: %u elements of size %u\n",
+				iterl->_key, iterl->_value->getSize(), iterl->_value->getElementSize());
 		}
 	}
 #endif
diff --git a/engines/ultima/ultima8/world/world.cpp b/engines/ultima/ultima8/world/world.cpp
index 590b870..5e77130 100644
--- a/engines/ultima/ultima8/world/world.cpp
+++ b/engines/ultima/ultima8/world/world.cpp
@@ -321,17 +321,18 @@ void World::worldStats() {
 			mapcount++;
 	}
 
-	pout << "World memory stats:" << Std::endl;
-	pout << "Maps       : " << mapcount << "/256" << Std::endl;
+	g_debugger->debugPrintf("World memory stats:\n");
+	g_debugger->debugPrintf("Maps       : %u/256\n", mapcount);
+
 	Actor *av = getMainActor();
-	pout << "Avatar pos.: ";
+	g_debugger->debugPrintf("Avatar pos.: ");
 	if (av) {
-		pout << "map " << av->getMapNum() << ", (";
+		g_debugger->debugPrintf("map %d, (", av->getMapNum());
 		int32 x, y, z;
 		av->getLocation(x, y, z);
-		pout << x << "," << y << "," << z << ")" << Std::endl;
+		g_debugger->debugPrintf("%d,%d,%d)\n", x, y, z);
 	} else {
-		pout << "missing (null)" << Std::endl;
+		g_debugger->debugPrintf("missing (null)\n");
 	}
 }
 




More information about the Scummvm-git-logs mailing list