[Scummvm-cvs-logs] SF.net SVN: scummvm:[45257] scummvm/trunk/engines/sci/engine
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Tue Oct 20 12:08:32 CEST 2009
Revision: 45257
http://scummvm.svn.sourceforge.net/scummvm/?rev=45257&view=rev
Author: thebluegr
Date: 2009-10-20 10:08:28 +0000 (Tue, 20 Oct 2009)
Log Message:
-----------
- 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
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kpathing.cpp
scummvm/trunk/engines/sci/engine/seg_manager.cpp
scummvm/trunk/engines/sci/engine/segment.cpp
Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp 2009-10-19 22:52:01 UTC (rev 45256)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp 2009-10-20 10:08:28 UTC (rev 45257)
@@ -261,7 +261,7 @@
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 @@
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 @@
// 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 @@
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 @@
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,8 +1712,17 @@
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;
Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-10-19 22:52:01 UTC (rev 45256)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp 2009-10-20 10:08:28 UTC (rev 45257)
@@ -877,7 +877,7 @@
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 @@
}
-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) {
Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp 2009-10-19 22:52:01 UTC (rev 45256)
+++ scummvm/trunk/engines/sci/engine/segment.cpp 2009-10-20 10:08:28 UTC (rev 45257)
@@ -222,7 +222,7 @@
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 @@
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;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list