diff options
author | Walter van Niftrik | 2009-05-08 12:39:37 +0000 |
---|---|---|
committer | Walter van Niftrik | 2009-05-08 12:39:37 +0000 |
commit | afa254721d786397d579230463ccdb96dcb9bae5 (patch) | |
tree | 68d1b2b1fb7c01042a0597fbcdf4bbe92bc91e1e /engines/sci | |
parent | c91a6c97ae8f3b10ee33c91225ce2d865c2a268a (diff) | |
download | scummvm-rg350-afa254721d786397d579230463ccdb96dcb9bae5.tar.gz scummvm-rg350-afa254721d786397d579230463ccdb96dcb9bae5.tar.bz2 scummvm-rg350-afa254721d786397d579230463ccdb96dcb9bae5.zip |
SCI: AvoidPath: Fixed a regression caused by previous commit, and added a
workaround for ECO room 300.
svn-id: r40383
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 8956e63852..351bdb89f6 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -927,8 +927,8 @@ static int near_point(const Common::Point &p, Polygon *polygon, Common::Point *r FloatPoint new_point; uint32 new_dist; - // Ignore edges on the screen border - if (edge_on_screen_border(p1, p2)) + // Ignore edges on the screen border, except for contained access polygons + if ((polygon->type != POLY_CONTAINED_ACCESS) && (edge_on_screen_border(p1, p2))) continue; // Compute near point @@ -1142,7 +1142,7 @@ static Common::Point *fixup_end_point(PathfindingState *s, const Common::Point & case POLY_CONTAINED_ACCESS: case POLY_BARRED_ACCESS: case POLY_NEAREST_ACCESS: - if (cont == CONT_INSIDE) { + if (cont != CONT_OUTSIDE) { if (s->_appendPoint != NULL) { // We shouldn't get here twice warning("AvoidPath: end point is contained in multiple polygons"); @@ -1230,15 +1230,24 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) { // WORKAROUND: broken polygon in LSL1VGA, room 350, after opening elevator // Polygon has 17 points but size is set to 19 - if (s->_gameName == "LSL1") { + if ((size == 19) && (s->_gameName == "LSL1")) { // FIXME: implement function to get current room number if ((KP_UINT(s->script_000->locals_block->locals[13]) == 350) - && (size == 19) && (read_point(list, is_reg_t, 18) == Common::Point(108, 137))) { - debug(1, "Applying fix for broken polygon in LSL1, room 350"); + && (read_point(list, is_reg_t, 18) == Common::Point(108, 137))) { + debug(1, "Applying fix for broken polygon in LSL1VGA, room 350"); size = 17; } } + // WORKAROUND: self-intersecting polygon in ECO, room 300, remove last point + if ((size == 11) && (s->_gameName == "eco")) { + if ((KP_UINT(s->script_000->locals_block->locals[13]) == 300) + && (read_point(list, is_reg_t, 10) == Common::Point(221, 0))) { + debug(1, "Applying fix for self-intersecting polygon in ECO, room 300"); + size = 10; + } + } + for (i = 0; i < size; i++) { Vertex *vertex = new Vertex(read_point(list, is_reg_t, i)); poly->vertices.insertHead(vertex); @@ -1662,6 +1671,12 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) { p = convert_polygon_set(s, poly_list, start, end, opt); + if (p && intersecting_polygons(p)) { + sciprintf("[avoidpath] Error: input set contains (self-)intersecting polygons\n"); + delete p; + p = NULL; + } + if (!p) { byte *oref; sciprintf("[avoidpath] Error: pathfinding failed for following input:\n"); @@ -1677,12 +1692,6 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) { return output; } - if (intersecting_polygons(p)) { - sciprintf("[avoidpath] Error: input set contains (self-)intersecting polygons\n"); - delete p; - p = NULL; - } - dijkstra(p); output = output_path(p, s); |