diff options
author | Walter van Niftrik | 2010-11-11 11:24:12 +0000 |
---|---|---|
committer | Walter van Niftrik | 2010-11-11 11:24:12 +0000 |
commit | 97067a75db00a29640e797da3f679074343a5526 (patch) | |
tree | b2d3ecf18447f2df94fab57edf80af1cca07c6c5 /engines/sci | |
parent | 84e4c1742a849e2d8087528c3ba4ecce37896512 (diff) | |
download | scummvm-rg350-97067a75db00a29640e797da3f679074343a5526.tar.gz scummvm-rg350-97067a75db00a29640e797da3f679074343a5526.tar.bz2 scummvm-rg350-97067a75db00a29640e797da3f679074343a5526.zip |
SCI: Allow paths along the edge of the screen in kAvoidPath.
Paths along the edge of the screen are now taken as a last resort. Fixes
bugs #3047418 and #3059595.
svn-id: r54199
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index cfd455e7b6..567f9fadfa 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1330,15 +1330,21 @@ static void AStar(PathfindingState *s) { if (closedSet.contains(vertex)) continue; - // Avoid plotting path along screen edge - if ((vertex_min != s->vertex_start) || (vertex != s->vertex_end)) - if (s->pointOnScreenBorder(vertex_min->v) && s->pointOnScreenBorder(vertex->v)) - continue; - if (!openSet.contains(vertex)) openSet.push_front(vertex); new_dist = vertex_min->costG + (uint32)sqrt((float)vertex_min->v.sqrDist(vertex->v)); + + // When travelling to a vertex on the screen edge, we + // add a penalty score to make this path less appealing. + // NOTE: If an obstacle has only one vertex on a screen edge, + // later SSCI pathfinders will treat that vertex like any + // other, while we apply a penalty to paths traversing it. + // This difference might lead to problems, but none are + // known at the time of writing. + if (s->pointOnScreenBorder(vertex->v)) + new_dist += 10000; + if (new_dist < vertex->costG) { vertex->costG = new_dist; vertex->costF = vertex->costG + (uint32)sqrt((float)vertex->v.sqrDist(s->vertex_end->v)); |