[Scummvm-cvs-logs] SF.net SVN: scummvm: [26763] scummvm/trunk/engines/agi
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sun May 6 12:35:48 CEST 2007
Revision: 26763
http://scummvm.svn.sourceforge.net/scummvm/?rev=26763&view=rev
Author: thebluegr
Date: 2007-05-06 03:35:47 -0700 (Sun, 06 May 2007)
Log Message:
-----------
Removed several goto statements
Modified Paths:
--------------
scummvm/trunk/engines/agi/checks.cpp
scummvm/trunk/engines/agi/inv.cpp
scummvm/trunk/engines/agi/op_test.cpp
Modified: scummvm/trunk/engines/agi/checks.cpp
===================================================================
--- scummvm/trunk/engines/agi/checks.cpp 2007-05-06 10:31:17 UTC (rev 26762)
+++ scummvm/trunk/engines/agi/checks.cpp 2007-05-06 10:35:47 UTC (rev 26763)
@@ -74,21 +74,21 @@
continue;
/* Same y, return error! */
- if (v->yPos == u->yPos)
- goto return_1;
+ if (v->yPos == u->yPos) {
+ debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
+ return 1;
+ }
/* Crossed the baseline, return error! */
if ((v->yPos > u->yPos && v->yPos2 < u->yPos2) ||
(v->yPos < u->yPos && v->yPos2 > u->yPos2)) {
- goto return_1;
+ debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
+ return 1;
}
}
return 0;
- return_1:
- debugC(4, kDebugLevelSprites, "check returns 1 (object %d)", v->entry);
- return 1;
}
int AgiEngine::checkPriority(VtEntry *v) {
@@ -104,9 +104,16 @@
water = 0;
pass = 1;
- if (v->priority == 0x0f)
- goto check_ego;
+ if (v->priority == 0x0f) {
+ // Check ego
+ if (v->entry == 0) {
+ setflag(fEgoTouchedP2, trigger ? true : false);
+ setflag(fEgoWater, water ? true : false);
+ }
+ return pass;
+ }
+
water = 1;
p0 = &_game.sbuf[v->xPos + v->yPos * _WIDTH];
@@ -147,7 +154,7 @@
pass = 0;
}
-check_ego:
+ // Check ego
if (v->entry == 0) {
setflag(fEgoTouchedP2, trigger ? true : false);
setflag(fEgoWater, water ? true : false);
Modified: scummvm/trunk/engines/agi/inv.cpp
===================================================================
--- scummvm/trunk/engines/agi/inv.cpp 2007-05-06 10:31:17 UTC (rev 26762)
+++ scummvm/trunk/engines/agi/inv.cpp 2007-05-06 10:35:47 UTC (rev 26763)
@@ -91,18 +91,21 @@
void AgiEngine::selectItems(int n) {
int fsel = 0;
+ bool exit_select = false;
- for (;;) {
+ while (!exit_select) {
if (n > 0)
printItem(fsel, STATUS_BG, STATUS_FG);
switch (waitAnyKey()) {
case KEY_ENTER:
setvar(vSelItem, _intobj[fsel]);
- goto exit_select;
+ exit_select = true;
+ break;
case KEY_ESCAPE:
setvar(vSelItem, 0xff);
- goto exit_select;
+ exit_select = true;
+ break;
case KEY_UP:
if (fsel >= 2)
fsel -= 2;
@@ -127,19 +130,20 @@
showItems();
printItem(fsel, STATUS_BG, STATUS_FG);
_gfx->doUpdate();
- goto exit_select;
+ exit_select = true;
}
break;
}
default:
break;
}
-
- showItems();
- _gfx->doUpdate();
+
+ if (!exit_select) {
+ showItems();
+ _gfx->doUpdate();
+ }
}
-exit_select:
debugC(6, kDebugLevelInventory, "selected: %d", fsel);
}
Modified: scummvm/trunk/engines/agi/op_test.cpp
===================================================================
--- scummvm/trunk/engines/agi/op_test.cpp 2007-05-06 10:31:17 UTC (rev 26762)
+++ scummvm/trunk/engines/agi/op_test.cpp 2007-05-06 10:35:47 UTC (rev 26763)
@@ -229,8 +229,9 @@
uint8 orTest = false;
uint16 lastIp = ip;
uint8 p[16] = { 0 };
+ bool end_test = false;
- while (retval && !game.quitProgNow) {
+ while (retval && !game.quitProgNow && !end_test) {
if (_debug.enabled && (_debug.logic0 || lognum))
debugConsole(lognum, lTEST_MODE, NULL);
@@ -240,7 +241,8 @@
switch (op) {
case 0xFF: /* END IF, TEST true */
- goto end_test;
+ end_test = true;
+ break;
case 0xFD:
notTest = !notTest;
continue;
@@ -251,7 +253,7 @@
if (orTest) {
ec = false;
retval = false;
- goto end_test;
+ end_test = true;
}
orTest = true;
@@ -259,7 +261,8 @@
case 0x00:
/* return true? */
- goto end_test;
+ end_test = true;
+ break;
case 0x01:
ec = testEqual(p[0], p[1]);
if (p[0] == 11)
@@ -333,62 +336,63 @@
break;
default:
ec = false;
- goto end_test;
+ end_test = true;
}
- if (op <= 0x12)
- ip += logicNamesTest[op].numArgs;
+ if (!end_test) {
+ if (op <= 0x12)
+ ip += logicNamesTest[op].numArgs;
- /* exchange ec value */
- if (notTest)
- ec = !ec;
+ /* exchange ec value */
+ if (notTest)
+ ec = !ec;
- /* not is only enabled for 1 test command */
- notTest = false;
+ /* not is only enabled for 1 test command */
+ notTest = false;
- if (orTest && ec) {
- /* a true inside an OR statement passes
- * ENTIRE statement scan for end of OR
- */
+ if (orTest && ec) {
+ /* a true inside an OR statement passes
+ * ENTIRE statement scan for end of OR
+ */
- /* CM: test for opcode < 0xfc changed from 'op' to
- * '*(code+ip)', to avoid problem with the 0xfd (NOT)
- * opcode byte. Changed a bad ip += ... ip++ construct.
- * This should fix the crash with Larry's logic.0 code:
- *
- * if ((isset(4) ||
- * !isset(2) ||
- * v30 == 2 ||
- * v30 == 1)) {
- * goto Label1;
- * }
- *
- * The bytecode is:
- * ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
- */
+ /* CM: test for opcode < 0xfc changed from 'op' to
+ * '*(code+ip)', to avoid problem with the 0xfd (NOT)
+ * opcode byte. Changed a bad ip += ... ip++ construct.
+ * This should fix the crash with Larry's logic.0 code:
+ *
+ * if ((isset(4) ||
+ * !isset(2) ||
+ * v30 == 2 ||
+ * v30 == 1)) {
+ * goto Label1;
+ * }
+ *
+ * The bytecode is:
+ * ff fc 07 04 fd 07 02 01 1e 02 01 1e 01 fc ff
+ */
- /* find end of OR */
- while (*(code + ip) != 0xFC) {
- if (*(code + ip) == 0x0E) { /* said */
+ /* find end of OR */
+ while (*(code + ip) != 0xFC) {
+ if (*(code + ip) == 0x0E) { /* said */
+ ip++;
+ /* cover count + ^words */
+ ip += 1 + ((*(code + ip)) * 2);
+ continue;
+ }
+
+ if (*(code + ip) < 0xFC)
+ ip += logicNamesTest[*(code + ip)].numArgs;
ip++;
- /* cover count + ^words */
- ip += 1 + ((*(code + ip)) * 2);
- continue;
}
+ ip++;
- if (*(code + ip) < 0xFC)
- ip += logicNamesTest[*(code + ip)].numArgs;
- ip++;
+ orTest = false;
+ retval = true;
+ } else {
+ retval = orTest ? retval || ec : retval && ec;
}
- ip++;
-
- orTest = false;
- retval = true;
- } else {
- retval = orTest ? retval || ec : retval && ec;
}
}
- end_test:
/* if false, scan for end of IP? */
if (retval)
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