diff options
author | Filippos Karapetis | 2018-12-27 16:38:16 +0200 |
---|---|---|
committer | Filippos Karapetis | 2018-12-28 13:41:39 +0200 |
commit | 1abd4bb9072148547494d85c39ca540c1a7647f9 (patch) | |
tree | fb45b6402f5162f12b6d3b56aa9a9a46a52571dc | |
parent | d96f9428b396be5342bfb0bdfe38a810a22e22fd (diff) | |
download | scummvm-rg350-1abd4bb9072148547494d85c39ca540c1a7647f9.tar.gz scummvm-rg350-1abd4bb9072148547494d85c39ca540c1a7647f9.tar.bz2 scummvm-rg350-1abd4bb9072148547494d85c39ca540c1a7647f9.zip |
GLK: ALAN2: Indentation fixes
-rw-r--r-- | engines/glk/alan2/execute.cpp | 78 | ||||
-rw-r--r-- | engines/glk/alan2/interpreter.cpp | 4 | ||||
-rw-r--r-- | engines/glk/alan2/parse.cpp | 57 |
3 files changed, 71 insertions, 68 deletions
diff --git a/engines/glk/alan2/execute.cpp b/engines/glk/alan2/execute.cpp index c60d927e98..0d72f074fd 100644 --- a/engines/glk/alan2/execute.cpp +++ b/engines/glk/alan2/execute.cpp @@ -129,12 +129,12 @@ bool Execute::checklim(Aword cnt, Aword obj) { } void Execute::print(Aword fpos, Aword len) { - char str[2 * WIDTH]; // String buffer - int outlen = 0; // Current output length + char str[2 * WIDTH]; // String buffer + int outlen = 0; // Current output length int ch; int i; - long savfp; // Temporary saved text file position - bool printFlag = false; // Printing already? + long savfp; // Temporary saved text file position + bool printFlag = false; // Printing already? bool savedPrintFlag = printFlag; DecodeInfo *info; // Saved decoding info @@ -175,7 +175,7 @@ void Execute::print(Aword fpos, Aword len) { // TODO /* #if ISO == 0 - fromIso(str, str); + fromIso(str, str); #endif */ _vm->output(str); @@ -242,7 +242,7 @@ bool Execute::confirm(MsgKind msgno) { char buf[80]; // This is a bit of a hack since we really want to compare the input, - // it could be affirmative, but for now any input is NOT! + // it could be affirmative, but for now any input is NOT! _vm->printMessage(msgno); // TODO @@ -267,17 +267,18 @@ void Execute::quit() { char choices[10]; _vm->paragraph(); + while (true) { _vm->col = 1; - _vm->statusLine(); - _vm->printMessage(M_QUITACTION); + _vm->statusLine(); + _vm->printMessage(M_QUITACTION); // TODO #if 0 #ifdef USE_READLINE - if (!readline(buf)) terminate(0); + if (!readline(buf)) terminate(0); #else - if (gets(buf) == NULL) terminate(0); + if (gets(buf) == NULL) terminate(0); #endif #endif @@ -360,9 +361,9 @@ void Execute::schedule(Aword evt, Aword whr, Aword aft) { // Bubble this event down for (i = etop; i >= 1 && eventq[i-1].time <= time; i--) { - eventq[i].event = eventq[i-1].event; - eventq[i].time = eventq[i-1].time; - eventq[i].where = eventq[i-1].where; + eventq[i].event = eventq[i-1].event; + eventq[i].time = eventq[i-1].time; + eventq[i].where = eventq[i-1].where; } eventq[i].time = time; @@ -378,8 +379,8 @@ void Execute::schedule(Aword evt, Aword whr, Aword aft) { * @param atr The attribute to read */ Aptr Execute::getatr(Aaddr atradr, Aaddr atr) { - AtrElem *at = (AtrElem *) addrTo(atradr); - return at[atr-1].val; + AtrElem *at = (AtrElem *)addrTo(atradr); + return at[atr - 1].val; } /** @@ -390,8 +391,8 @@ Aptr Execute::getatr(Aaddr atradr, Aaddr atr) { * @param val New value */ void Execute::setatr(Aaddr atradr, Aword atr, Aword val) { - AtrElem *at = (AtrElem *) addrTo(atradr); - at[atr-1].val = val; + AtrElem *at = (AtrElem *)addrTo(atradr); + at[atr - 1].val = val; } void Execute::makloc(Aword loc, Aword atr, Aword val) { @@ -408,13 +409,13 @@ void Execute::makact(Aword act, Aword atr, Aword val) { void Execute::make(Aword id, Aword atr, Aword val) { if (isObj(id)) - makobj(id, atr, val); + makobj(id, atr, val); else if (isLoc(id)) makloc(id, atr, val); else if (isAct(id)) - makact(id, atr, val); + makact(id, atr, val); else - error("Can't MAKE item (%ld).", (unsigned long)id); + error("Can't MAKE item (%ld).", (unsigned long)id); } void Execute::setloc(Aword loc, Aword atr, Aword val) { @@ -436,9 +437,9 @@ void Execute::set(Aword id, Aword atr, Aword val) { else if (isLoc(id)) setloc(id, atr, val); else if (isAct(id)) - setact(id, atr, val); + setact(id, atr, val); else - error("Can't SET item (%ld).", (unsigned long)id); + error("Can't SET item (%ld).", (unsigned long)id); } void Execute::setstr(Aword id, Aword atr, Aword str) { @@ -455,7 +456,7 @@ void Execute::setstr(Aword id, Aword atr, Aword str) { */ void Execute::incratr(Aaddr atradr, Aword atr, Aword step) { AtrElem *at = (AtrElem *) addrTo(atradr); - at[atr-1].val += step; + at[atr - 1].val += step; } void Execute::incrloc(Aword loc, Aword atr, Aword step) { @@ -486,7 +487,7 @@ void Execute::decr(Aword id, Aword atr, Aword step) { if (isObj(id)) incrobj(id, atr, -step); else if (isLoc(id)) - incrloc(id, atr, -step); + incrloc(id, atr, -step); else if (isAct(id)) incract(id, atr, -step); else @@ -516,13 +517,13 @@ Aptr Execute::attribute(Aword id, Aword atr) { if (isObj(id)) return objatr(id, atr); else if (isLoc(id)) - return locatr(id, atr); + return locatr(id, atr); else if (isAct(id)) - return actatr(id, atr); + return actatr(id, atr); else if (isLit(id)) - return litatr(id, atr); + return litatr(id, atr); else - error("Can't ATTRIBUTE item (%ld).", (unsigned long) id); + error("Can't ATTRIBUTE item (%ld).", (unsigned long) id); } Aptr Execute::strattr(Aword id, Aword atr) { @@ -655,13 +656,13 @@ void Execute::locate(Aword id, Aword whr) { if (isObj(id)) locobj(id, whr); else if (isAct(id)) - locact(id, whr); + locact(id, whr); else - error("Can't LOCATE item (%ld).", (unsigned long) id); + error("Can't LOCATE item (%ld).", (unsigned long)id); } Abool Execute::objhere(Aword obj) { - if (isCnt(_objs[obj - OBJMIN].loc)) { // In something? + if (isCnt(_objs[obj - OBJMIN].loc)) { // In something? if (isObj(_objs[obj - OBJMIN].loc) || isAct(_objs[obj - OBJMIN].loc)) return(isHere(_objs[obj - OBJMIN].loc)); else // If the container wasn't anywhere, assume where HERO is! @@ -684,7 +685,7 @@ Abool Execute::isHere(Aword id) { } Aword Execute::objnear(Aword obj) { - if (isCnt(_objs[obj-OBJMIN].loc)) { // In something? + if (isCnt(_objs[obj-OBJMIN].loc)) { // In something? if (isObj(_objs[obj-OBJMIN].loc) || isAct(_objs[obj-OBJMIN].loc)) return(isNear(_objs[obj-OBJMIN].loc)); else // If the container wasn't anywhere, assume here, so not nearby! @@ -705,7 +706,7 @@ Abool Execute::isNear(Aword id) { else if (isAct(id)) return actnear(id); else - error("Can't NEAR item (%ld).", (unsigned long) id); + error("Can't NEAR item (%ld).", (unsigned long) id); } Abool Execute::in(Aword obj, Aword cnt) { @@ -945,8 +946,7 @@ void Execute::dscrobjs() { sayarticle(i); say(i); found = true; - } - else { + } else { if (multiple) { _vm->_needSpace = false; _vm->printMessage(M_SEEOBJ2); @@ -1030,10 +1030,10 @@ Aword Execute::rnd(Aword from, Aword to) { // Between Abool Execute::btw(Aint val, Aint low, Aint high) { - if (high > low) - return low <= val && val <= high; - else - return high <= val && val <= low; + if (high > low) + return low <= val && val <= high; + else + return high <= val && val <= low; } // TODO: Replace this with Common::String functionality diff --git a/engines/glk/alan2/interpreter.cpp b/engines/glk/alan2/interpreter.cpp index c8c53a0b4a..5b5024e0bd 100644 --- a/engines/glk/alan2/interpreter.cpp +++ b/engines/glk/alan2/interpreter.cpp @@ -754,10 +754,10 @@ void Interpreter::interpret(Aaddr adr) { break; case C_CURVAR: curVar(i); - break; + break; case C_STMOP: stMop(i, oldpc); - break; + break; default: error("Unknown instruction class."); } diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp index c0777e0aed..789080f936 100644 --- a/engines/glk/alan2/parse.cpp +++ b/engines/glk/alan2/parse.cpp @@ -61,13 +61,13 @@ void Parser::unknown(char *inputStr) { int Parser::lookup(char *wrd) { #if 0 for (int i = 0; !endOfTable(&dict[i]); i++) { - if (strcmp(wrd, (char *) addrTo(dict[i].wrd)) == 0) - return (i); + if (strcmp(wrd, (char *)addrTo(dict[i].wrd)) == 0) + return i; } #endif unknown(wrd); - return(EOF); + return EOF; } char *Parser::gettoken(char *tokenBuffer) { @@ -97,6 +97,7 @@ char *Parser::gettoken(char *tokenBuffer) { oldch = *marker; *marker = '\0'; + return tokenBuffer; } @@ -116,20 +117,20 @@ void Parser::agetline() { debug("> "); #if 0 - if (logflg) + if (logflg) fprintf(logfil, "> "); #endif #ifdef USE_READLINE - if (!readline(buf)) { + if (!readline(buf)) { newline(); quit(); - } + } #else - if (fgets(buf, LISTLEN, stdin) == NULL) { + if (fgets(buf, LISTLEN, stdin) == NULL) { newline(); quit(); - } + } #endif getPageSize(); @@ -146,11 +147,11 @@ void Parser::agetline() { token = gettoken(isobuf); - if (token != NULL && strcmp("debug", token) == 0 && _vm->header->debug) { + if (token != NULL && strcmp("debug", token) == 0 && _vm->header->debug) { dbgflg = true; debug(); token = NULL; - } + } } while (token == NULL); eol = false; @@ -194,7 +195,7 @@ void Parser::scan() { } else if (token[0] == '\"') { if (litCount > MAXPARAMS) error("Too many parameters."); - + wrds[i++] = dictsize + litCount; // Word outside dictionary = literal litValues[litCount].type = TYPSTR; @@ -234,7 +235,7 @@ void Parser::nonverb() { } Abool Parser::objhere(Aword obj) { - if (isCnt(objs[obj - OBJMIN].loc)) { // In something? + if (isCnt(objs[obj - OBJMIN].loc)) { // In something? if (isObj(objs[obj - OBJMIN].loc) || isAct(objs[obj - OBJMIN].loc)) return(isHere(objs[obj - OBJMIN].loc)); // TODO @@ -279,7 +280,7 @@ void Parser::buildall(ParamElem list[]) { if (!found) _vm->printError(M_WHAT_ALL); else - list[i].code = EOF; + list[i].code = EOF; } void Parser::listCopy(ParamElem a[], ParamElem b[]) { @@ -380,7 +381,7 @@ void Parser::unambig(ParamElem plst[]) { if (isLiteral(wrds[wrdidx])) { // Transform the word into a reference to the literal value - plst[0].code = wrds[wrdidx++]-dictsize+LITMIN; + plst[0].code = wrds[wrdidx++] - dictsize + LITMIN; plst[0].firstWord = EOF; // No words used! plst[1].code = EOF; return; @@ -389,7 +390,8 @@ void Parser::unambig(ParamElem plst[]) { plst[0].code = EOF; // Make empty if (isIt(wrds[wrdidx])) { - wrdidx++; + wrdidx++; + // Use last object in previous command! for (i = listLength(pparams)-1; i >= 0 && (pparams[i].code == 0 || pparams[i].code >= LITMIN); i--); @@ -447,12 +449,13 @@ void Parser::unambig(ParamElem plst[]) { // Perhaps the last word was also a noun? listCopy(plst, savlst); // Restore to before last adjective listCopyFromDictionary(refs, (Aword *)addrTo(dict[wrds[wrdidx-1]].nounrefs)); + if (plst[0].code == EOF) listCopy(plst, refs); - else - listIntersection(plst, refs); - } else - _vm->printError(M_NOUN); + else + listIntersection(plst, refs); + } else + _vm->printError(M_NOUN); } lastWord = wrdidx - 1; @@ -465,7 +468,7 @@ void Parser::unambig(ParamElem plst[]) { listCompact(plst); } - + if (listLength(plst) > 1 || (found && listLength(plst) == 0)) { params[0].code = 0; /* Just make it anything != EOF */ params[0].firstWord = firstWord; /* Remember words for errors below */ @@ -579,15 +582,15 @@ bool Parser::claCheck(ClaElem *cla) { if ((cla->classes&(Aword)CLA_CNT) != 0) ok = ok || isCnt(params[cla->code-1].code); if ((cla->classes&(Aword)CLA_ACT) != 0) - ok = ok || isAct(params[cla->code-1].code); + ok = ok || isAct(params[cla->code-1].code); if ((cla->classes&(Aword)CLA_NUM) != 0) ok = ok || isNum(params[cla->code-1].code); if ((cla->classes&(Aword)CLA_STR) != 0) - ok = ok || isStr(params[cla->code-1].code); + ok = ok || isStr(params[cla->code-1].code); if ((cla->classes&(Aword)CLA_COBJ) != 0) - ok = ok || (isCnt(params[cla->code-1].code) && isObj(params[cla->code-1].code)); + ok = ok || (isCnt(params[cla->code-1].code) && isObj(params[cla->code-1].code)); if ((cla->classes&(Aword)CLA_CACT) != 0) - ok = ok || (isCnt(params[cla->code-1].code) && isAct(params[cla->code-1].code)); + ok = ok || (isCnt(params[cla->code-1].code) && isAct(params[cla->code-1].code)); return ok; } @@ -606,7 +609,7 @@ void Parser::resolve(ParamElem plst[]) { params[1].code = EOF; // But be sure to terminate _vm->printError(M_NO_SUCH); } - } + } } bool Parser::endOfTable(StxElem *addr) { @@ -905,7 +908,7 @@ void Parser::match(ParamElem *mlst) { tryMatch(mlst); // try to understand what the user said if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx])) - _vm->printError(M_WHAT); + _vm->printError(M_WHAT); if (wrds[wrdidx] != EOF) // More on this line? wrdidx++; // If so skip the AND } @@ -967,7 +970,7 @@ void Parser::parse() { match(mlst); action(mlst); // mlst contains possible multiple params } else { - params[0].code = EOF; + params[0].code = EOF; pmlst[0].code = EOF; nonverb(); } |