From 90b6cdfbdff3e75a034c748d6d8784a0df7f5db4 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 7 Nov 2010 01:03:03 +0000 Subject: LURE: Remove all uses of (f)printf; cleanup svn-id: r54106 --- engines/lure/debugger.cpp | 6 ++--- engines/lure/hotspots.cpp | 37 ++++++++++---------------- engines/lure/hotspots.h | 3 +-- engines/lure/res_struct.cpp | 65 +++++++++++---------------------------------- engines/lure/res_struct.h | 7 +++-- 5 files changed, 35 insertions(+), 83 deletions(-) (limited to 'engines') diff --git a/engines/lure/debugger.cpp b/engines/lure/debugger.cpp index 9ce6331db9..9b1bb743e4 100644 --- a/engines/lure/debugger.cpp +++ b/engines/lure/debugger.cpp @@ -352,15 +352,13 @@ bool Debugger::cmd_hotspot(int argc, const char **argv) { } else { if (strcmp(argv[2], "schedule") == 0) { // List any current schedule for the character - hs->npcSchedule.list(buffer); - DebugPrintf("%s", buffer); + DebugPrintf("%s", hs->npcSchedule.getDebugInfo().c_str()); } if (!h) DebugPrintf("The specified hotspot is not currently active\n"); else if (strcmp(argv[2], "paths") == 0) { // List any paths for a charcter - h->pathFinder().list(buffer); - DebugPrintf("%s", buffer); + DebugPrintf("%s", h->pathFinder().getDebugInfo().c_str()); } else if (strcmp(argv[2], "pixels") == 0) { // List the pixel data for the hotspot diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 64e5035ee9..bce98b28fd 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -2496,10 +2496,9 @@ void HotspotTickHandlers::standardCharacterAnimHandler(Hotspot &h) { bool bumpedPlayer; if (h.currentActions().action() != WALKING) { - char buffer[MAX_DESC_SIZE]; - h.currentActions().list(buffer); + Common::String buffer = h.currentActions().getDebugInfo(); debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot standard character p=(%d,%d,%d) bs=%d\n%s", - h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer); + h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer.c_str()); } // Handle any active talk dialog @@ -2902,12 +2901,12 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { Action hsAction; uint16 hotspotId; HotspotData *hotspot; - char buffer[MAX_DESC_SIZE]; + Common::String buffer; - h.currentActions().list(buffer); + buffer = h.currentActions().getDebugInfo(); debugC(ERROR_DETAILED, kLureDebugAnimations, "Hotspot player anim handler p=(%d,%d,%d) bs=%d\n%s", - h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer); + h.x(), h.y(), h.roomNumber(), h.blockedState(), buffer.c_str()); h.handleTalkDialog(); @@ -3037,10 +3036,10 @@ void HotspotTickHandlers::playerAnimHandler(Hotspot &h) { if (pfResult == PF_UNFINISHED) break; // Pathfinding is now complete - pathFinder.list(buffer); + buffer = pathFinder.getDebugInfo(); debugC(ERROR_DETAILED, kLureDebugAnimations, "Pathfind processing done; result=%d, walkFlag=%d\n%s", - pfResult, h.walkFlag(), buffer); + pfResult, h.walkFlag(), buffer.c_str()); if ((pfResult != PF_OK) && (h.walkFlag() || (pfResult != PF_DEST_OCCUPIED))) { @@ -4374,25 +4373,17 @@ final_step: return result; } -void PathFinder::list(char *buffer) { - if (buffer) { - sprintf(buffer, "Pathfinder::list\n"); - buffer += strlen(buffer); - } - else { - printf("Pathfinder::list\n"); - } +Common::String PathFinder::getDebugInfo() const { + Common::String buffer; + buffer += "Pathfinder::list(\n"; - WalkingActionList::iterator i; + WalkingActionList::const_iterator i; for (i = _list.begin(); i != _list.end(); ++i) { WalkingActionEntry *e = (*i).get(); - if (buffer) { - sprintf(buffer, "Direction=%d, numSteps=%d\n", e->direction(), e->numSteps()); - buffer += strlen(buffer); - } - else - printf("Direction=%d, numSteps=%d\n", e->direction(), e->numSteps()); + buffer += Common::String::format("Direction=%d, numSteps=%d\n", e->direction(), e->numSteps()); } + + return buffer; } void PathFinder::processCell(uint16 *p) { diff --git a/engines/lure/hotspots.h b/engines/lure/hotspots.h index 5ff0ec563f..2ae2e91ecf 100644 --- a/engines/lure/hotspots.h +++ b/engines/lure/hotspots.h @@ -158,8 +158,7 @@ public: void clear(); void reset(RoomPathsData &src); PathFinderResult process(); - void list(char *buffer); - void list() { list(NULL); } + Common::String getDebugInfo() const; void pop() { _list.erase(_list.begin()); } WalkingActionEntry &top() { return **_list.begin(); } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 9ef595b30f..f6a2092ddc 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -1439,77 +1439,42 @@ CurrentActionEntry *CurrentActionEntry::loadFromStream(Common::ReadStream *strea return result; } -void CurrentActionStack::list(char *buffer) { - ActionsList::iterator i; +Common::String CurrentActionStack::getDebugInfo() const { + Common::String buffer; + ActionsList::const_iterator i; - if (buffer) { - sprintf(buffer, "CurrentActionStack::list num_actions=%d\n", size()); - buffer += strlen(buffer); - } - else - printf("CurrentActionStack::list num_actions=%d\n", size()); + buffer += Common::String::format("CurrentActionStack::list num_actions=%d\n", size()); for (i = _actions.begin(); i != _actions.end(); ++i) { CurrentActionEntry *entry = (*i).get(); - if (buffer) { - sprintf(buffer, "style=%d room#=%d", entry->action(), entry->roomNumber()); - buffer += strlen(buffer); - } - else - printf("style=%d room#=%d", entry->action(), entry->roomNumber()); + buffer += Common::String::format("style=%d room#=%d", entry->action(), entry->roomNumber()); if (entry->hasSupportData()) { CharacterScheduleEntry &rec = entry->supportData(); - if (buffer) { - sprintf(buffer, ", action=%d params=", rec.action()); - buffer += strlen(buffer); - } - else - printf(", action=%d params=", rec.action()); + buffer += Common::String::format(", action=%d params=", rec.action()); if (rec.numParams() == 0) - if (buffer) { - strcat(buffer, "none"); - buffer += strlen(buffer); - } - else - printf("none"); + buffer += "none"; else { - for (int ctr = 0; ctr < rec.numParams(); ++ctr) { - if (ctr != 0) { - if (buffer) { - strcpy(buffer, ", "); - buffer += strlen(buffer); - } - else - printf(", "); - } - - if (buffer) { - sprintf(buffer, "%d", rec.param(ctr)); - buffer += strlen(buffer); - } else - printf("%d", rec.param(ctr)); + buffer += Common::String::format("%d", rec.param(0)); + for (int ctr = 1; ctr < rec.numParams(); ++ctr) { + buffer += Common::String::format(", %d", rec.param(ctr)); } } } - if (buffer) { - sprintf(buffer, "\n"); - buffer += strlen(buffer); - } - else - printf("\n"); + buffer += "\n"; } + + return buffer; } void CurrentActionStack::saveToStream(Common::WriteStream *stream) { ActionsList::iterator i; debugC(ERROR_DETAILED, kLureDebugAnimations, "Saving hotspot action stack"); - char buffer[MAX_DESC_SIZE]; - list(buffer); - debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer); + Common::String buffer = getDebugInfo(); + debugC(ERROR_DETAILED, kLureDebugAnimations, "%s", buffer.c_str()); for (i = _actions.begin(); i != _actions.end(); ++i) { CurrentActionEntry *rec = (*i).get(); diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index afb8ee9153..9b2a4c79f8 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -464,7 +464,7 @@ private: public: CurrentActionStack() { _actions.clear(); } - bool isEmpty() { return _actions.begin() == _actions.end(); } + bool isEmpty() const { return _actions.begin() == _actions.end(); } void clear() { _actions.clear(); } CurrentActionEntry &top() { return **_actions.begin(); } CurrentActionEntry &bottom() { @@ -474,9 +474,8 @@ public: } CurrentAction action() { return isEmpty() ? NO_ACTION : top().action(); } void pop() { _actions.erase(_actions.begin()); } - int size() { return _actions.size(); } - void list(char *buffer); - void list() { list(NULL); } + int size() const { return _actions.size(); } + Common::String getDebugInfo() const; void addBack(CurrentAction newAction, uint16 roomNum) { _actions.push_back(ActionsList::value_type(new CurrentActionEntry(newAction, roomNum))); -- cgit v1.2.3