From 7c46d891c6acc414e69c5cf624f45b7b297fe584 Mon Sep 17 00:00:00 2001 From: Eric Fry Date: Fri, 11 May 2018 21:27:52 +1000 Subject: ILLUSIONS: Print walk rectangle point on background to aid in debugging Comment and rename some code in pathfinder to aid in understanding --- engines/illusions/actor.cpp | 2 +- engines/illusions/duckman/scriptopcodes_duckman.cpp | 1 + engines/illusions/pathfinder.cpp | 11 ++++++++--- engines/illusions/pathfinder.h | 2 +- engines/illusions/resources/backgroundresource.cpp | 10 ++++++++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/engines/illusions/actor.cpp b/engines/illusions/actor.cpp index 4ebce4160e..e9aad26ce8 100644 --- a/engines/illusions/actor.cpp +++ b/engines/illusions/actor.cpp @@ -1063,7 +1063,7 @@ void Controls::placeActor(uint32 actorTypeId, Common::Point placePt, uint32 sequ actor->_facing = 64; actor->_scale = actorType->_scale; actor->_namedPoints = &actorType->_namedPoints; - + BackgroundResource *bgRes = _vm->_backgroundInstances->getActiveBgResource(); if (actorType->_pathWalkPointsIndex) { actor->_pathWalkPoints = bgRes->getPathWalkPoints(actorType->_pathWalkPointsIndex - 1); diff --git a/engines/illusions/duckman/scriptopcodes_duckman.cpp b/engines/illusions/duckman/scriptopcodes_duckman.cpp index a2303b0887..10efceae24 100644 --- a/engines/illusions/duckman/scriptopcodes_duckman.cpp +++ b/engines/illusions/duckman/scriptopcodes_duckman.cpp @@ -274,6 +274,7 @@ void ScriptOpcodes_Duckman::opUnloadResourcesBySceneId(ScriptThread *scriptThrea //static uint dsceneId = 0x0001005B, dthreadId = 0x00020341; //static uint dsceneId = 0x00010010, dthreadId = 0x0002008A; //static uint dsceneId = 0x10002, dthreadId = 0x20001;//Debug menu, not supported +//static uint dsceneId = 0x10035, dthreadId = 0x000201B4; // Starship Enterprise (outside) //static uint dsceneId = 0x10044, dthreadId = 0x000202B8; // Starship Enterprise //static uint dsceneId = 0x00010039, dthreadId = 0x00020089; // Map //static uint dsceneId = 0x00010052, dthreadId = 0x00020347; // Credits diff --git a/engines/illusions/pathfinder.cpp b/engines/illusions/pathfinder.cpp index ac4f53df45..1e781e64ea 100644 --- a/engines/illusions/pathfinder.cpp +++ b/engines/illusions/pathfinder.cpp @@ -261,12 +261,17 @@ void PathFinder::findDeltaPt(Common::Point pt, Common::Point &outDeltaPt) { } } } - -bool PathFinder::testRect(PathLine &line, PathLine &rect) { +/** + * returns true if line is contained within rect. + */ +bool PathFinder::isLineWithinRectangle(PathLine &line, PathLine &rect) { return line.p0.x <= rect.p1.x && line.p1.x >= rect.p0.x && line.p0.y <= rect.p1.y && line.p1.y >= rect.p0.y; } +/** + * flip line coordinates so it starts top left and finishes bottom right + */ void PathFinder::swapLine(PathLine &line, PathLine &outLine) { if (line.p1.x <= line.p0.x) { outLine.p1.x = line.p0.x; @@ -289,7 +294,7 @@ int PathFinder::calcLineStatus(PathLine &sourceLine, PathLine &destRect, Common: swapLine(sourceLine, sourceLine1); swapLine(destRect, destRect1); - if (!testRect(sourceLine1, destRect1)) + if (!isLineWithinRectangle(sourceLine1, destRect1)) return 3; int sourceDeltaX = sourceLine.p1.x - sourceLine.p0.x; diff --git a/engines/illusions/pathfinder.h b/engines/illusions/pathfinder.h index ca402bb95d..f337a25fc0 100644 --- a/engines/illusions/pathfinder.h +++ b/engines/illusions/pathfinder.h @@ -57,7 +57,7 @@ protected: void swapDimensions(WidthHeight &dimensions); void clipLineToBg(Common::Point &destPt, WidthHeight &rectDimensions, PathLine &outDestLine); void findDeltaPt(Common::Point pt, Common::Point &outDeltaPt); - bool testRect(PathLine &line, PathLine &rect); + bool isLineWithinRectangle(PathLine &line, PathLine &rect); void swapLine(PathLine &line, PathLine &outLine); int calcLineStatus(PathLine &sourceLine, PathLine &destRect, Common::Point *outPoint); }; diff --git a/engines/illusions/resources/backgroundresource.cpp b/engines/illusions/resources/backgroundresource.cpp index ec2a08ae43..fc1332649a 100644 --- a/engines/illusions/resources/backgroundresource.cpp +++ b/engines/illusions/resources/backgroundresource.cpp @@ -466,6 +466,16 @@ void BackgroundInstance::initSurface() { _panPoints[i] = bgInfo->_panPoint; _surfaces[i] = _vm->_screen->allocSurface(bgInfo->_surfInfo); drawTiles(_surfaces[i], bgInfo->_tileMap, bgInfo->_tilePixels); +#if 0 + if(_bgRes->_pathWalkRectsCount > 0) { + PathLines *pl = _bgRes->_pathWalkRects->_rects; + for(int j=0;j < pl->size(); j++) { + PathLine pathLine = (*pl)[j]; + debug(0, "walk path rect line[%d]. (%d,%d)->(%d,%d)", j, pathLine.p0.x, pathLine.p0.y, pathLine.p1.x, pathLine.p1.y); + _surfaces[i]->drawLine(pathLine.p0.x, pathLine.p0.y, pathLine.p1.x, pathLine.p1.y, 5); + } + } +#endif } } -- cgit v1.2.3