diff options
author | Filippos Karapetis | 2009-10-20 10:08:28 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-20 10:08:28 +0000 |
commit | a88aa2f45f651f61b7c2ff851eff13cfe15a37c0 (patch) | |
tree | e5a7a428133a4d2c9e1db3980982159efdea4391 /engines | |
parent | c0f6657797d1d7bfeb64acf6cb3f2b1c0748e7ef (diff) | |
download | scummvm-rg350-a88aa2f45f651f61b7c2ff851eff13cfe15a37c0.tar.gz scummvm-rg350-a88aa2f45f651f61b7c2ff851eff13cfe15a37c0.tar.bz2 scummvm-rg350-a88aa2f45f651f61b7c2ff851eff13cfe15a37c0.zip |
- Fixed the pathfinding issue for LSL5 room 640, where Patti walks off-screen (we still need a proper way of detecting this, though...)
- Made warnings where invalid pointers are dereferenced more precise
svn-id: r45257
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 30 | ||||
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/segment.cpp | 4 |
3 files changed, 23 insertions, 18 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 569311e099..a72064dbf0 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -261,7 +261,7 @@ struct PathfindingState { static Common::Point read_point(SegManager *segMan, reg_t list, int offset) { SegmentRef list_r = segMan->dereference(list); if (!list_r.isValid()) { - warning("Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(list)); + warning("read_point(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(list)); } Common::Point point; @@ -854,7 +854,6 @@ static VertexList *visible_vertices(PathfindingState *s, Vertex *vertex_cur) { return visVerts; } -#if 0 static bool point_on_screen_border(const Common::Point &p) { // Determines if a point lies on the screen border // Parameters: (const Common::Point &) p: The point @@ -862,7 +861,6 @@ static bool point_on_screen_border(const Common::Point &p) { // FIXME get dimensions from somewhere? return (p.x == 0) || (p.x == 319) || (p.y == 0) || (p.y == 189); } -#endif static bool edge_on_screen_border(const Common::Point &p, const Common::Point &q) { // Determines if an edge lies on the screen border @@ -1498,7 +1496,7 @@ static int intersecting_polygons(PathfindingState *s) { return 0; } -static void dijkstra(PathfindingState *s) { +static void dijkstra(PathfindingState *s, bool avoidScreenEdge) { // Computes a shortest path from vertex_start to vertex_end. The caller can // construct the resulting path by following the path_prev links from // vertex_end back to vertex_start. If no path exists vertex_end->path_prev @@ -1558,13 +1556,12 @@ static void dijkstra(PathfindingState *s) { uint32 new_dist; Vertex *vertex = *it; - // Early pathfinding-enabled games exclude edges on screen borders. -// FIXME: Enable this selectively for those games that need it. -#if 0 - // Avoid plotting path along screen edge - if ((vertex != s->vertex_end) && point_on_screen_border(vertex->v)) - continue; -#endif + if (avoidScreenEdge) { + // Avoid plotting path along screen edge + if ((vertex != s->vertex_end) && point_on_screen_border(vertex->v)) + continue; + } + new_dist = vertex_min->dist + (uint32)sqrt((float)vertex_min->v.sqrDist(vertex->v)); if (new_dist < vertex->dist) { vertex->dist = new_dist; @@ -1715,7 +1712,16 @@ reg_t kAvoidPath(EngineState *s, int argc, reg_t *argv) { return output; } - dijkstra(p); + // Early pathfinding-enabled games exclude edges on screen borders. + // FIXME: Enable this selectively for those games that need it. + bool avoidScreenEdge = false; + + // This is certainly needed for LSL5 room 640, otherwise Patti walks off-screen + // and reenters through the wall + if (s->_gameName == "lsl5" && s->currentRoomNumber() == 640) + avoidScreenEdge = true; + + dijkstra(p, avoidScreenEdge); output = output_path(p, s); delete p; diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 3cb4a5d0f1..2af038185b 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -877,7 +877,7 @@ SegmentRef SegManager::dereference(reg_t pointer) { if (!pointer.segment || (pointer.segment >= _heap.size()) || !_heap[pointer.segment]) { // This occurs in KQ5CD when interacting with certain objects - warning("Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); + warning("SegManager::dereference(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); return ret; /* Invalid */ } @@ -1158,12 +1158,11 @@ size_t SegManager::strlen(reg_t str) { } -Common::String SegManager::getString(reg_t pointer, int entries) -{ +Common::String SegManager::getString(reg_t pointer, int entries) { Common::String ret; SegmentRef src_r = dereference(pointer); if (!src_r.isValid()) { - warning("Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); + warning("SegManager::getString(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); return ret; } if (entries > src_r.maxSize) { diff --git a/engines/sci/engine/segment.cpp b/engines/sci/engine/segment.cpp index b683fd4d8b..fee8a9f4a7 100644 --- a/engines/sci/engine/segment.cpp +++ b/engines/sci/engine/segment.cpp @@ -222,7 +222,7 @@ bool Script::isValidOffset(uint16 offset) const { SegmentRef Script::dereference(reg_t pointer) { if (pointer.offset > _bufSize) { - warning("Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)", + warning("Script::dereference(): Attempt to dereference invalid pointer %04x:%04x into script segment (script size=%d)", PRINT_REG(pointer), (uint)_bufSize); return SegmentRef(); } @@ -299,7 +299,7 @@ SegmentRef SystemStrings::dereference(reg_t pointer) { ret.raw = (byte *)(_strings[pointer.offset]._value); else { // This occurs in KQ5CD when interacting with certain objects - warning("Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); + warning("SystemStrings::dereference(): Attempt to dereference invalid pointer %04x:%04x", PRINT_REG(pointer)); } return ret; |