[Scummvm-cvs-logs] SF.net SVN: scummvm:[55085] scummvm/trunk/engines/sci/engine/klists.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sat Jan 1 13:43:09 CET 2011
Revision: 55085
http://scummvm.svn.sourceforge.net/scummvm/?rev=55085&view=rev
Author: thebluegr
Date: 2011-01-01 12:43:09 +0000 (Sat, 01 Jan 2011)
Log Message:
-----------
SCI: Disable continuous list checking by default
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/klists.cpp
Modified: scummvm/trunk/engines/sci/engine/klists.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/klists.cpp 2011-01-01 10:51:57 UTC (rev 55084)
+++ scummvm/trunk/engines/sci/engine/klists.cpp 2011-01-01 12:43:09 UTC (rev 55085)
@@ -29,7 +29,10 @@
#include "sci/engine/kernel.h"
namespace Sci {
+//#define CHECK_LISTS // adds sanity checking for lists and errors out when problems are found
+#ifdef CHECK_LISTS
+
static bool isSaneNodePointer(SegManager *segMan, reg_t addr) {
bool havePrev = false;
reg_t prev = addr;
@@ -122,6 +125,8 @@
}
}
+#endif
+
reg_t kNewList(EngineState *s, int argc, reg_t *argv) {
reg_t listRef;
List *list = s->_segMan->allocateList(&listRef);
@@ -157,7 +162,9 @@
List *list = s->_segMan->lookupList(argv[0]);
if (list) {
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, argv[0]);
+#endif
return list->first;
} else {
return NULL_REG;
@@ -171,7 +178,9 @@
List *list = s->_segMan->lookupList(argv[0]);
if (list) {
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, argv[0]);
+#endif
return list->last;
} else {
return NULL_REG;
@@ -183,8 +192,9 @@
return NULL_REG;
List *list = s->_segMan->lookupList(argv[0]);
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, argv[0]);
-
+#endif
return make_reg(0, ((list) ? list->first.isNull() : 0));
}
@@ -196,7 +206,10 @@
if (!newNode)
error("Attempt to add non-node (%04x:%04x) to list at %04x:%04x", PRINT_REG(nodeRef), PRINT_REG(listRef));
+
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, listRef);
+#endif
newNode->pred = NULL_REG;
newNode->succ = list->first;
@@ -219,7 +232,10 @@
if (!newNode)
error("Attempt to add non-node (%04x:%04x) to list at %04x:%04x", PRINT_REG(nodeRef), PRINT_REG(listRef));
+
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, listRef);
+#endif
newNode->pred = list->last;
newNode->succ = NULL_REG;
@@ -236,26 +252,37 @@
reg_t kNextNode(EngineState *s, int argc, reg_t *argv) {
Node *n = s->_segMan->lookupNode(argv[0]);
+
+#ifdef CHECK_LISTS
if (!isSaneNodePointer(s->_segMan, argv[0]))
return NULL_REG;
+#endif
return n->succ;
}
reg_t kPrevNode(EngineState *s, int argc, reg_t *argv) {
Node *n = s->_segMan->lookupNode(argv[0]);
+
+#ifdef CHECK_LISTS
if (!isSaneNodePointer(s->_segMan, argv[0]))
return NULL_REG;
+#endif
return n->pred;
}
reg_t kNodeValue(EngineState *s, int argc, reg_t *argv) {
Node *n = s->_segMan->lookupNode(argv[0]);
+
+#ifdef CHECK_LISTS
if (!isSaneNodePointer(s->_segMan, argv[0]))
return NULL_REG;
+#endif
- return n->value;
+ // ICEMAN: when plotting a course in room 40, unDrawLast is called by
+ // startPlot::changeState, but there is no previous entry, so we get 0 here
+ return n ? n->value : NULL_REG;
}
reg_t kAddToFront(EngineState *s, int argc, reg_t *argv) {
@@ -281,7 +308,9 @@
Node *firstnode = argv[1].isNull() ? NULL : s->_segMan->lookupNode(argv[1]);
Node *newnode = s->_segMan->lookupNode(argv[2]);
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, argv[0]);
+#endif
if (!newnode) {
error("New 'node' %04x:%04x is not a node", PRINT_REG(argv[2]));
@@ -323,7 +352,9 @@
debugC(2, kDebugLevelNodes, "Looking for key %04x:%04x in list %04x:%04x", PRINT_REG(key), PRINT_REG(list_pos));
+#ifdef CHECK_LISTS
checkListPointer(s->_segMan, argv[0]);
+#endif
node_pos = s->_segMan->lookupList(list_pos)->first;
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