Whitespace fixes and C++ comments

svn-id: r41239
This commit is contained in:
Eugene Sandulenko 2009-06-06 17:39:13 +00:00
parent c585366ce9
commit 93d62da652
37 changed files with 1218 additions and 1040 deletions

View file

@ -52,7 +52,7 @@ static AgiEngine *g_agi;
#define testHas(obj) (g_agi->objectGetLocation(obj) == EGO_OWNED)
#define testObjInRoom(obj, v) (g_agi->objectGetLocation(obj) == g_agi->getvar(v))
extern int timerHack; /* For the timer loop in MH1 logic 153 */
extern int timerHack; // For the timer loop in MH1 logic 153
static uint8 testCompareStrings(uint8 s1, uint8 s2) {
char ms1[MAX_STRINGLEN];
@ -113,6 +113,7 @@ static uint8 testKeypressed() {
game.keypress = 0;
if (!x) {
int mode = game.inputMode;
game.inputMode = INPUT_NONE;
g_agi->mainCycle();
game.inputMode = mode;
@ -146,7 +147,7 @@ static uint8 testObjInBox(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
v->yPos >= y1 && v->xPos + v->xSize - 1 <= x2 && v->yPos <= y2;
}
/* if n is in centre of box */
// if n is in centre of box
static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
VtEntry *v = &game.viewTable[n];
@ -154,7 +155,7 @@ static uint8 testObjCentre(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
v->xPos + v->xSize / 2 <= x2 && v->yPos >= y1 && v->yPos <= y2;
}
/* if nect N is in right corner */
// if nect N is in right corner
static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
VtEntry *v = &game.viewTable[n];
@ -162,7 +163,7 @@ static uint8 testObjRight(uint8 n, uint8 x1, uint8 y1, uint8 x2, uint8 y2) {
v->xPos + v->xSize - 1 <= x2 && v->yPos >= y1 && v->yPos <= y2;
}
/* When player has entered something, it is parsed elsewhere */
// When player has entered something, it is parsed elsewhere
static uint8 testSaid(uint8 nwords, uint8 *cc) {
int c, n = game.numEgoWords;
int z = 0;
@ -170,33 +171,32 @@ static uint8 testSaid(uint8 nwords, uint8 *cc) {
if (g_agi->getflag(fSaidAcceptedInput) || !g_agi->getflag(fEnteredCli))
return false;
/* FR:
* I think the reason for the code below is to add some speed....
*
* if (nwords != num_ego_words)
* return false;
*
* In the disco scene in Larry 1 when you type "examine blonde",
* inside the logic is expected ( said("examine", "blonde", "rol") )
* where word("rol") = 9999
*
* According to the interpreter code 9999 means that whatever the
* user typed should be correct, but it looks like code 9999 means that
* if the string is empty at this point, the entry is also correct...
*
* With the removal of this code, the behaviour of the scene was
* corrected
*/
// FR:
// I think the reason for the code below is to add some speed....
//
// if (nwords != num_ego_words)
// return false;
//
// In the disco scene in Larry 1 when you type "examine blonde",
// inside the logic is expected ( said("examine", "blonde", "rol") )
// where word("rol") = 9999
//
// According to the interpreter code 9999 means that whatever the
// user typed should be correct, but it looks like code 9999 means that
// if the string is empty at this point, the entry is also correct...
//
// With the removal of this code, the behaviour of the scene was
// corrected
for (c = 0; nwords && n; c++, nwords--, n--) {
z = READ_LE_UINT16(cc);
cc += 2;
switch (z) {
case 9999: /* rest of line (empty string counts to...) */
case 9999: // rest of line (empty string counts to...)
nwords = 1;
break;
case 1: /* any word */
case 1: // any word
break;
default:
if (game.egoWords[c].id != z)
@ -205,13 +205,12 @@ static uint8 testSaid(uint8 nwords, uint8 *cc) {
}
}
/* The entry string should be entirely parsed, or last word = 9999 */
// The entry string should be entirely parsed, or last word = 9999
if (n && z != 9999)
return false;
/* The interpreter string shouldn't be entirely parsed, but next
* word must be 9999.
*/
// The interpreter string shouldn't be entirely parsed, but next
// word must be 9999.
if (nwords != 0 && READ_LE_UINT16(cc) != 9999)
return false;
@ -240,16 +239,15 @@ int AgiEngine::testIfCode(int lognum) {
memmove(p, (code + ip), 16);
switch (op) {
case 0xFF: /* END IF, TEST true */
case 0xFF: // END IF, TEST true
end_test = true;
break;
case 0xFD:
notTest = !notTest;
continue;
case 0xFC: /* OR */
/* if or_test is ON and we hit 0xFC, end of OR, then
* or is STILL false so break.
*/
case 0xFC: // OR
// if or_test is ON and we hit 0xFC, end of OR, then
// or is STILL false so break.
if (orTest) {
ec = false;
retval = false;
@ -260,7 +258,7 @@ int AgiEngine::testIfCode(int lognum) {
continue;
case 0x00:
/* return true? */
// return true?
end_test = true;
break;
case 0x01:
@ -317,9 +315,9 @@ int AgiEngine::testIfCode(int lognum) {
case 0x0E:
ec = testSaid(p[0], (uint8 *) code + (ip + 1));
ip = lastIp;
ip++; /* skip opcode */
ip += p[0] * 2; /* skip num_words * 2 */
ip++; /* skip num_words opcode */
ip++; // skip opcode
ip += p[0] * 2; // skip num_words * 2
ip++; // skip num_words opcode
break;
case 0x0F:
debugC(7, kDebugLevelScripts, "comparing [%s], [%s]", game.strings[p[0]], game.strings[p[1]]);
@ -353,39 +351,38 @@ int AgiEngine::testIfCode(int lognum) {
if (op <= 0x12)
ip += logicNamesTest[op].numArgs;
/* exchange ec value */
// exchange ec value
if (notTest)
ec = !ec;
/* not is only enabled for 1 test command */
// 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
*/
// 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 */
// find end of OR
while (*(code + ip) != 0xFC) {
if (*(code + ip) == 0x0E) { /* said */
if (*(code + ip) == 0x0E) { // said
ip++;
/* cover count + ^words */
// cover count + ^words
ip += 1 + ((*(code + ip)) * 2);
continue;
}
@ -404,7 +401,7 @@ int AgiEngine::testIfCode(int lognum) {
}
}
/* if false, scan for end of IP? */
// if false, scan for end of IP?
if (retval)
ip += 2;
else {
@ -420,7 +417,7 @@ int AgiEngine::testIfCode(int lognum) {
ip++;
}
}
ip++; /* skip over 0xFF */
ip++; // skip over 0xFF
ip += READ_LE_UINT16(code + ip) + 2;
}
@ -430,4 +427,4 @@ int AgiEngine::testIfCode(int lognum) {
return retval;
}
} // End of namespace Agi
} // End of namespace Agi