From 8940f362a2a08a3318a9ccd80d5f97eb9984406c Mon Sep 17 00:00:00 2001 From: a/ Date: Wed, 23 Jun 2021 21:57:38 +0900 Subject: [PATCH] SAGA2: Add debug output to path.cpp --- engines/saga2/detection.cpp | 1 + engines/saga2/path.cpp | 10 +++++++++- engines/saga2/saga2.h | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/engines/saga2/detection.cpp b/engines/saga2/detection.cpp index 9cfa174cc5e..cc02059aef5 100644 --- a/engines/saga2/detection.cpp +++ b/engines/saga2/detection.cpp @@ -36,6 +36,7 @@ static const DebugChannelDef debugFlagList[] = { {Saga2::kDebugPalettes, "palettes", "Debug the palettes"}, {Saga2::kDebugLoading, "loading", "Debug the loading"}, {Saga2::kDebugTimers, "timers", "Debug the timers"}, + {Saga2::kDebugPath, "path", "Debug the pathfinding"}, DEBUG_CHANNEL_END }; diff --git a/engines/saga2/path.cpp b/engines/saga2/path.cpp index f0bf3fb91cc..ddaa26de537 100644 --- a/engines/saga2/path.cpp +++ b/engines/saga2/path.cpp @@ -1602,6 +1602,8 @@ void PathRequest::finish(void) { static TilePoint tempResult[32]; + debugC(2, kDebugPath, "Finishing Path Request: %p", (void *)this); + if (bestLoc != Nowhere) { cell = cellArray->getCell(bestPlatform, bestLoc.u, bestLoc.v); assert(cell != nullptr); @@ -1672,6 +1674,8 @@ void PathRequest::finish(void) { } void PathRequest::abortReq(void) { + debugC(4, kDebugPath, "Aborting Path Request: %p", (void *)this); + if (mTask->pathFindTask == this) mTask->pathFindTask = nullptr; } @@ -1680,12 +1684,14 @@ void PathRequest::abortReq(void) { PathResult PathRequest::findPath(void) { assert(cellArray != nullptr); - static const uint8 costTable[] = { 4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0 }; + static const uint8 costTable[] = {4, 10, 12, 16, 12, 10, 4, 0, 4, 10, 12, 16, 12, 10, 4, 0}; ProtoObj *proto = actor->proto(); QueueItem qi; uint8 pCross = proto->crossSection; + debugC(4, kDebugPath, "Finding Path for %p: pCross = %d", (void *)this, pCross); + if (flags & aborted) return pathAborted; int32 lastTick_ = gameTime; @@ -2062,6 +2068,8 @@ DestinationPathRequest::DestinationPathRequest(Actor *a, int16 howSmart) : // Initialize the static data members void DestinationPathRequest::initialize(void) { + debugC(2, kDebugPath, "Initializing Path Request: %p", (void *)this); + PathRequest::initialize(); // Initialize bestDist to the highest possible value. diff --git a/engines/saga2/saga2.h b/engines/saga2/saga2.h index b347d820dfe..0449ab401d4 100644 --- a/engines/saga2/saga2.h +++ b/engines/saga2/saga2.h @@ -51,7 +51,8 @@ enum { kDebugTiles = 1 << 5, kDebugPalettes = 1 << 6, kDebugLoading = 1 << 7, - kDebugTimers = 1 << 8 + kDebugTimers = 1 << 8, + kDebugPath = 1 << 9 }; #define TICKSPERSECOND (728L/10L)