[Scummvm-cvs-logs] SF.net SVN: scummvm:[54106] scummvm/trunk/engines/lure
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun Nov 7 02:03:03 CET 2010
Revision: 54106
http://scummvm.svn.sourceforge.net/scummvm/?rev=54106&view=rev
Author: fingolfin
Date: 2010-11-07 01:03:03 +0000 (Sun, 07 Nov 2010)
Log Message:
-----------
LURE: Remove all uses of (f)printf; cleanup
Modified Paths:
--------------
scummvm/trunk/engines/lure/debugger.cpp
scummvm/trunk/engines/lure/hotspots.cpp
scummvm/trunk/engines/lure/hotspots.h
scummvm/trunk/engines/lure/res_struct.cpp
scummvm/trunk/engines/lure/res_struct.h
Modified: scummvm/trunk/engines/lure/debugger.cpp
===================================================================
--- scummvm/trunk/engines/lure/debugger.cpp 2010-11-07 01:01:18 UTC (rev 54105)
+++ scummvm/trunk/engines/lure/debugger.cpp 2010-11-07 01:03:03 UTC (rev 54106)
@@ -352,15 +352,13 @@
} 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
Modified: scummvm/trunk/engines/lure/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/lure/hotspots.cpp 2010-11-07 01:01:18 UTC (rev 54105)
+++ scummvm/trunk/engines/lure/hotspots.cpp 2010-11-07 01:03:03 UTC (rev 54106)
@@ -2496,10 +2496,9 @@
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 @@
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 @@
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 @@
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) {
Modified: scummvm/trunk/engines/lure/hotspots.h
===================================================================
--- scummvm/trunk/engines/lure/hotspots.h 2010-11-07 01:01:18 UTC (rev 54105)
+++ scummvm/trunk/engines/lure/hotspots.h 2010-11-07 01:03:03 UTC (rev 54106)
@@ -158,8 +158,7 @@
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(); }
Modified: scummvm/trunk/engines/lure/res_struct.cpp
===================================================================
--- scummvm/trunk/engines/lure/res_struct.cpp 2010-11-07 01:01:18 UTC (rev 54105)
+++ scummvm/trunk/engines/lure/res_struct.cpp 2010-11-07 01:03:03 UTC (rev 54106)
@@ -1439,77 +1439,42 @@
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();
Modified: scummvm/trunk/engines/lure/res_struct.h
===================================================================
--- scummvm/trunk/engines/lure/res_struct.h 2010-11-07 01:01:18 UTC (rev 54105)
+++ scummvm/trunk/engines/lure/res_struct.h 2010-11-07 01:03:03 UTC (rev 54106)
@@ -464,7 +464,7 @@
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 @@
}
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)));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list