ULTIMA8: Fix Kernel::listProcesses command output

A mix of logging methods caused data to be skipped on the debug console. Building a string in Process::dumpInfo instead of logging allows for flexible use.
This commit is contained in:
Matthew Jimenez 2022-12-30 20:49:56 -06:00
parent d713003db0
commit 9fc0c74b57
19 changed files with 41 additions and 43 deletions

View File

@ -65,9 +65,9 @@ void GumpNotifyProcess::terminate() {
void GumpNotifyProcess::run() {
}
void GumpNotifyProcess::dumpInfo() const {
Process::dumpInfo();
pout << " gump: " << _gump << Std::endl;
Common::String GumpNotifyProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", gump: %u", _gump);
}
void GumpNotifyProcess::saveData(Common::WriteStream *ws) {

View File

@ -51,7 +51,7 @@ public:
void run() override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;

View File

@ -39,9 +39,9 @@ void DelayProcess::run() {
terminate();
}
void DelayProcess::dumpInfo() const {
Process::dumpInfo();
pout << "Frames left: " << _count << Std::endl;
Common::String DelayProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", frames left: %d", _count);
}

View File

@ -39,7 +39,7 @@ public:
void run() override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;

View File

@ -104,7 +104,7 @@ void Process::suspend() {
_flags |= PROC_SUSPENDED;
}
void Process::dumpInfo() const {
Common::String Process::dumpInfo() const {
Common::String info = Common::String::format(
"Process %d class %s, item %d, type %x, status ",
getPid(), GetClassType()._className, _itemNum, _type);
@ -125,7 +125,7 @@ void Process::dumpInfo() const {
}
}
g_debugger->debugPrintf("%s\n", info.c_str());
return info;
}
void Process::saveData(Common::WriteStream *ws) {

View File

@ -110,8 +110,8 @@ public:
return _ticksPerRun;
}
//! dump some info about this process to pout
virtual void dumpInfo() const;
//! dump some info about this process to a string
virtual Common::String dumpInfo() const;
//! load Process data
bool loadData(Common::ReadStream *rs, uint32 version);

View File

@ -876,8 +876,9 @@ bool Debugger::cmdListProcesses(int argc, const char **argv) {
for (ProcessIterator it = kern->_processes.begin();
it != kern->_processes.end(); ++it) {
Process *p = *it;
if (argc == 1 || p->_itemNum == item)
p->dumpInfo();
if (argc == 1 || p->_itemNum == item) {
debugPrintf("%s\n", p->dumpInfo().c_str());
}
}
}
@ -896,7 +897,7 @@ bool Debugger::cmdProcessInfo(int argc, const char **argv) {
if (p == 0) {
debugPrintf("No such process: %d\n", procid);
} else {
p->dumpInfo();
debugPrintf("%s\n", p->dumpInfo().c_str());
}
}

View File

@ -140,16 +140,17 @@ void UCProcess::terminate() {
Process::terminate();
}
void UCProcess::dumpInfo() const {
Process::dumpInfo();
Common::String UCProcess::dumpInfo() const {
Common::String info = Process::dumpInfo();
if (_classId == 0xFFFF) {
pout.Print("IP undefined\n");
info += ", IP undefined";
} else {
const char *classname = GameData::get_instance()->getMainUsecode()->
get_class_name(_classId);
pout.Print("classname: %s, IP: %04X:%04X\n", classname, _classId, _ip);
info += Common::String::format(", classname: %s, IP: %04X:%04X", classname, _classId, _ip);
}
return info;
}
void UCProcess::saveData(Common::WriteStream *ws) {

View File

@ -52,8 +52,7 @@ public:
_temp32 = retval;
}
//! dump some info about this process to pout
void dumpInfo() const override;
Common::String dumpInfo() const override;
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;

View File

@ -699,9 +699,9 @@ void ActorAnimProcess::terminate() {
Process::terminate();
}
void ActorAnimProcess::dumpInfo() const {
Process::dumpInfo();
pout << "_action: " << _action << ", _dir: " << _dir << Std::endl;
Common::String ActorAnimProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", _action: %d, _dir: %d", _action, _dir);
}
void ActorAnimProcess::saveData(Common::WriteStream *ws) {

View File

@ -49,7 +49,7 @@ public:
void terminate() override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
Animation::Sequence getAction() const {
return _action;

View File

@ -1111,9 +1111,8 @@ uint16 AttackProcess::readNextWordRaw() {
return _tacticDatReadStream->readUint16LE();
}
void AttackProcess::dumpInfo() const {
Process::dumpInfo();
Common::String AttackProcess::dumpInfo() const {
return Process::dumpInfo();
}
void AttackProcess::saveData(Common::WriteStream *ws) {

View File

@ -51,7 +51,7 @@ public:
void terminate() override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
void setIsActivityAOrB() {
_isActivityAorB = true;

View File

@ -300,9 +300,9 @@ void CombatProcess::waitForTarget() {
}
}
void CombatProcess::dumpInfo() const {
Process::dumpInfo();
pout << "Target: " << _target << Std::endl;
Common::String CombatProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", target: %u", _target);
}
void CombatProcess::saveData(Common::WriteStream *ws) {

View File

@ -45,7 +45,7 @@ public:
void setTarget(ObjId target);
ObjId seekTarget();
void dumpInfo() const override;
Common::String dumpInfo() const override;
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;

View File

@ -116,9 +116,9 @@ void LoiterProcess::run() {
}
}
void LoiterProcess::dumpInfo() const {
Process::dumpInfo();
pout << "Frames left: " << _count;
Common::String LoiterProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", frames left: %d", _count);
}
void LoiterProcess::saveData(Common::WriteStream *ws) {

View File

@ -41,7 +41,7 @@ public:
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
protected:
int32 _count;
};

View File

@ -374,11 +374,9 @@ void GravityProcess::actorFallStoppedCru(Actor *actor, int height) {
}
}
void GravityProcess::dumpInfo() const {
Process::dumpInfo();
pout << "_gravity: " << _gravity << ", speed: (" << _xSpeed << ","
<< _ySpeed << "," << _zSpeed << ")" << Std::endl;
Common::String GravityProcess::dumpInfo() const {
return Process::dumpInfo() +
Common::String::format(", _gravity: %d, speed: (%d, %d, %d)", _gravity, _xSpeed, _ySpeed, _zSpeed);
}

View File

@ -46,7 +46,7 @@ public:
void run() override;
void terminate() override;
void dumpInfo() const override;
Common::String dumpInfo() const override;
bool loadData(Common::ReadStream *rs, uint32 version);
void saveData(Common::WriteStream *ws) override;