aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-02-10 11:51:43 -0800
committerPaul Gilbert2019-02-10 11:52:30 -0800
commit22e5913f18f597aab343ca4555714a340d86d3c8 (patch)
tree99997e63ed157da9ab3742714f9aa9400a30631a /engines/glk
parent60a30b904bb9edf15e7b21f1aa4741259de0461f (diff)
downloadscummvm-rg350-22e5913f18f597aab343ca4555714a340d86d3c8.tar.gz
scummvm-rg350-22e5913f18f597aab343ca4555714a340d86d3c8.tar.bz2
scummvm-rg350-22e5913f18f597aab343ca4555714a340d86d3c8.zip
GLK: ALAN2: Fix a bunch of comparison warnings
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/alan2/decode.cpp2
-rw-r--r--engines/glk/alan2/execute.cpp67
-rw-r--r--engines/glk/alan2/parse.cpp102
-rw-r--r--engines/glk/alan2/parse.h4
-rw-r--r--engines/glk/alan2/saveload.cpp6
5 files changed, 89 insertions, 92 deletions
diff --git a/engines/glk/alan2/decode.cpp b/engines/glk/alan2/decode.cpp
index 3a93d1d3a8..58e814f97f 100644
--- a/engines/glk/alan2/decode.cpp
+++ b/engines/glk/alan2/decode.cpp
@@ -60,7 +60,7 @@ void Decode::startDecoding() {
int Decode::decodeChar() {
const long range = (long)(_high - _low) + 1;
- const int f = (((long)(_value - _low) + 1) * _freq[0] - 1) / range;
+ const uint f = (((long)(_value - _low) + 1) * _freq[0] - 1) / range;
int symbol;
// Find the symbol
diff --git a/engines/glk/alan2/execute.cpp b/engines/glk/alan2/execute.cpp
index 64b405b7d3..fa7bdd7d7a 100644
--- a/engines/glk/alan2/execute.cpp
+++ b/engines/glk/alan2/execute.cpp
@@ -42,7 +42,7 @@ bool Execute::exitto(int to, int from) {
return false; // No exits
for (ExtElem *ext = (ExtElem *)addrTo(_locs[from - LOCMIN].exts); !endOfTable(ext); ext++)
- if (ext->next == to)
+ if ((int)ext->next == to)
return true;
return false;
@@ -51,7 +51,7 @@ bool Execute::exitto(int to, int from) {
int Execute::count(int cnt) {
int j = 0;
- for (int i = OBJMIN; i <= OBJMAX; i++)
+ for (uint i = OBJMIN; i <= OBJMAX; i++)
if (in(i, cnt))
j++; // Then it's in this container also
@@ -61,7 +61,7 @@ int Execute::count(int cnt) {
int Execute::sumAttributes(Aword atr, Aword cnt) {
int sum = 0;
- for (int i = OBJMIN; i <= OBJMAX; i++) {
+ for (uint i = OBJMIN; i <= OBJMAX; i++) {
if (_objs[i - OBJMIN].loc == cnt) { // Then it's in this container
if (_objs[i - OBJMIN].cont != 0) // This is also a container!
sum = sum + sumAttributes(atr, i);
@@ -92,7 +92,7 @@ bool Execute::checkContainerLimit(Aword cnt, Aword obj) {
if (_cnts[props - CNTMIN].lims != 0) { /* Any limits at all? */
for (lim = (LimElem *)addrTo(_cnts[props - CNTMIN].lims); !endOfTable(lim); lim++) {
if (lim->atr == 0) {
- if (count(cnt) >= lim->val) {
+ if (count(cnt) >= (int)lim->val) {
_vm->_interpreter->interpret(lim->stms);
return true; // Limit check failed
}
@@ -113,12 +113,12 @@ bool Execute::checkContainerLimit(Aword cnt, Aword obj) {
void Execute::print(Aword fpos, Aword len) {
char str[2 * WIDTH]; // String buffer
int outlen = 0; // Current output length
- int ch;
+ int ch = 0;
int i;
- long savfp; // Temporary saved text file position
+ long savfp = 0; // Temporary saved text file position
bool printFlag = false; // Printing already?
bool savedPrintFlag = printFlag;
- DecodeInfo *info; // Saved decoding info
+ DecodeInfo *info = nullptr; // Saved decoding info
if (len == 0)
@@ -138,10 +138,10 @@ void Execute::print(Aword fpos, Aword len) {
if (_vm->header->pack)
_vm->_decode->startDecoding();
- for (outlen = 0; outlen != len; outlen = outlen + strlen(str)) {
+ for (outlen = 0; outlen != (int)len; outlen = outlen + strlen(str)) {
// Fill the buffer from the beginning
for (i = 0; i <= WIDTH || (i > WIDTH && ch != ' '); i++) {
- if (outlen + i == len) // No more characters?
+ if (outlen + i == (int)len) // No more characters?
break;
if (_vm->header->pack)
ch = _vm->_decode->decodeChar();
@@ -246,7 +246,7 @@ bool Execute::confirm(MsgKind msgno) {
void Execute::quit() {
char buf[80];
- char choices[10];
+// char choices[10];
_vm->paragraph();
@@ -310,7 +310,7 @@ void Execute::cancl(Aword evt) {
int i;
for (i = etop - 1; i >= 0; i--) {
- if (eventq[i].event == evt) {
+ if (eventq[i].event == (int)evt) {
while (i < etop - 1) {
eventq[i].event = eventq[i + 1].event;
eventq[i].time = eventq[i + 1].time;
@@ -417,11 +417,11 @@ void Execute::incr(Aword id, Aword atr, Aword step) {
void Execute::decr(Aword id, Aword atr, Aword step) {
if (isObj(id))
- incObject(id, atr, -step);
+ incObject(id, atr, -(int)step);
else if (isLoc(id))
- incLocation(id, atr, -step);
+ incLocation(id, atr, -(int)step);
else if (isAct(id))
- incract(id, atr, -step);
+ incract(id, atr, -(int)step);
else
error("Can't DECR item (%ld).", (unsigned long)id);
}
@@ -473,7 +473,7 @@ Aword Execute::where(Aword id) {
Aint Execute::agrmax(Aword atr, Aword whr) {
Aword i;
- Aint max = 0;
+ uint max = 0;
for (i = OBJMIN; i <= OBJMAX; i++) {
if (isLoc(whr)) {
@@ -488,7 +488,7 @@ Aint Execute::agrmax(Aword atr, Aword whr) {
Aint Execute::agrsum(Aword atr, Aword whr) {
Aword i;
- Aint sum = 0;
+ uint sum = 0;
for (i = OBJMIN; i <= OBJMAX; i++) {
if (isLoc(whr)) {
@@ -563,7 +563,7 @@ void Execute::locact(Aword act, Aword whr) {
_vm->cur.act = prevact;
}
- if (_vm->cur.act != act)
+ if (_vm->cur.act != (int)act)
_vm->cur.loc = prevloc;
}
@@ -582,13 +582,13 @@ Abool Execute::objhere(Aword obj) {
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!
- return(where(HERO) == _vm->cur.loc);
+ return((int)where(HERO) == _vm->cur.loc);
} else
- return(_objs[obj - OBJMIN].loc == _vm->cur.loc);
+ return((int)_objs[obj - OBJMIN].loc == _vm->cur.loc);
}
Aword Execute::acthere(Aword act) {
- return _acts[act - ACTMIN].loc == _vm->cur.loc;
+ return (int)_acts[act - ACTMIN].loc == _vm->cur.loc;
}
Abool Execute::isHere(Aword id) {
@@ -705,7 +705,7 @@ void Execute::dscract(Aword act) {
}
void Execute::describe(Aword id) {
- for (int i = 0; i < _describeStack.size(); i++) {
+ for (uint i = 0; i < _describeStack.size(); i++) {
_describeStack.push(id);
if (isObj(id))
@@ -730,9 +730,9 @@ void Execute::use(Aword act, Aword scr) {
}
void Execute::list(Aword cnt) {
- int i;
+ uint i;
Aword props;
- Aword prevobj;
+ Aword prevobj = 0;
bool found = false;
bool multiple = false;
@@ -800,29 +800,26 @@ void Execute::list(Aword cnt) {
}
void Execute::empty(Aword cnt, Aword whr) {
- for (int i = OBJMIN; i <= OBJMAX; i++)
+ for (uint i = OBJMIN; i <= OBJMAX; i++)
if (in(i, cnt))
locate(i, whr);
}
void Execute::dscrobjs() {
- int i;
- int prevobj;
+ uint i;
+ int prevobj = 0;
bool found = false;
bool multiple = false;
// First describe everything here with its own description
for (i = OBJMIN; i <= OBJMAX; i++) {
- if (_objs[i - OBJMIN].loc == _vm->cur.loc &&
- _objs[i - OBJMIN].describe &&
- _objs[i - OBJMIN].dscr1)
+ if ((int)_objs[i - OBJMIN].loc == _vm->cur.loc && _objs[i - OBJMIN].describe && _objs[i - OBJMIN].dscr1)
describe(i);
}
// Then list everything else here
for (i = OBJMIN; i <= OBJMAX; i++) {
- if (_objs[i - OBJMIN].loc == _vm->cur.loc &&
- _objs[i - OBJMIN].describe) {
+ if ((int)_objs[i - OBJMIN].loc == _vm->cur.loc && _objs[i - OBJMIN].describe) {
if (!found) {
_vm->printMessage(M_SEEOBJ1);
sayarticle(i);
@@ -860,18 +857,18 @@ void Execute::dscrobjs() {
void Execute::dscracts() {
- for (int i = HERO+1; i <= ACTMAX; i++)
- if (_acts[i-ACTMIN].loc == _vm->cur.loc &&
+ for (uint i = HERO+1; i <= ACTMAX; i++)
+ if ((int)_acts[i-ACTMIN].loc == _vm->cur.loc &&
_acts[i-ACTMIN].describe)
describe(i);
// Set describe flag for all actors
- for (int i = HERO; i <= ACTMAX; i++)
+ for (uint i = HERO; i <= ACTMAX; i++)
_acts[i-ACTMIN].describe = true;
}
void Execute::look() {
- int i;
+ uint i;
_vm->looking = true;
// Set describe flag for all objects and actors
diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp
index e8b4f1f695..dd0623888e 100644
--- a/engines/glk/alan2/parse.cpp
+++ b/engines/glk/alan2/parse.cpp
@@ -162,7 +162,7 @@ void Parser::agetline() {
}
void Parser::scan() {
- int i;
+ uint i;
int w;
char *str;
@@ -258,9 +258,9 @@ Abool Parser::objhere(Aword obj) {
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!
- return where(HERO) == _vm->cur.loc;
+ return (int)where(HERO) == _vm->cur.loc;
} else
- return(objs[obj - OBJMIN].loc == _vm->cur.loc);
+ return((int)objs[obj - OBJMIN].loc == _vm->cur.loc);
}
@@ -268,7 +268,7 @@ Abool Parser::isHere(Aword id) {
if (isObj(id))
return objhere(id);
else if (isAct(id))
- return acts[id - ACTMIN].loc == _vm->cur.loc;
+ return (int)acts[id - ACTMIN].loc == _vm->cur.loc;
else
error("Can't HERE item (%ld).", (unsigned long)id);
}
@@ -276,21 +276,21 @@ Abool Parser::isHere(Aword id) {
// ----------------------------------------------------------------------------
void Parser::buildall(ParamElem list[]) {
- int o, i = 0;
+ uint o, i = 0;
bool found = false;
for (o = OBJMIN; o <= OBJMAX; o++) {
if (isHere(o)) {
found = true;
list[i].code = o;
- list[i++].firstWord = EOF;
+ list[i++].firstWord = (Aword)EOF;
}
}
if (!found)
_vm->printError(M_WHAT_ALL);
else
- list[i].code = EOF;
+ list[i].code = (Aword)EOF;
}
void Parser::listCopy(ParamElem a[], ParamElem b[]) {
@@ -299,7 +299,7 @@ void Parser::listCopy(ParamElem a[], ParamElem b[]) {
for (i = 0; b[i].code != EOF; i++)
a[i] = b[i];
- a[i].code = EOF;
+ a[i].code = (Aword)EOF;
}
bool Parser::listContains(ParamElem l[], Aword e) {
@@ -317,7 +317,7 @@ void Parser::listIntersection(ParamElem a[], ParamElem b[]) {
if (listContains(b, a[i].code))
a[last++] = a[i];
- a[last].code = EOF;
+ a[last].code = (Aword)EOF;
}
void Parser::listCopyFromDictionary(ParamElem p[], Aword r[]) {
@@ -325,10 +325,10 @@ void Parser::listCopyFromDictionary(ParamElem p[], Aword r[]) {
for (i = 0; r[i] != EOF; i++) {
p[i].code = r[i];
- p[i].firstWord = EOF;
+ p[i].firstWord = (Aword)EOF;
}
- p[i].code = EOF;
+ p[i].code = (Aword)EOF;
}
int Parser::listLength(ParamElem a[]) {
@@ -347,7 +347,7 @@ void Parser::listCompact(ParamElem a[]) {
if (a[j].code != 0)
a[i++] = a[j];
- a[i].code = EOF;
+ a[i].code = (Aword)EOF;
}
void Parser::listMerge(ParamElem a[], ParamElem b[]) {
@@ -358,7 +358,7 @@ void Parser::listMerge(ParamElem a[], ParamElem b[]) {
for (i = 0; b[i].code != EOF; i++) {
if (!listContains(a, b[i].code)) {
a[last++] = b[i];
- a[last].code = EOF;
+ a[last].code = (Aword)EOF;
}
}
}
@@ -387,12 +387,12 @@ 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].firstWord = EOF; // No words used!
- plst[1].code = EOF;
+ plst[0].firstWord = (Aword)EOF; // No words used!
+ plst[1].code = (Aword)EOF;
return;
}
- plst[0].code = EOF; // Make empty
+ plst[0].code = (Aword)EOF; // Make empty
if (isIt(wrds[wrdidx])) {
wrdidx++;
@@ -405,14 +405,14 @@ void Parser::unambig(ParamElem plst[]) {
if (!isHere(pparams[i].code)) {
params[0].code = pparams[i].code;
- params[0].firstWord = EOF;
- params[1].code = EOF;
+ params[0].firstWord = (Aword)EOF;
+ params[1].code = (Aword)EOF;
_vm->printError(M_NO_SUCH);
}
plst[0] = pparams[i];
- plst[0].firstWord = EOF; // No words used!
- plst[1].code = EOF;
+ plst[0].firstWord = (Aword)EOF; // No words used!
+ plst[1].code = (Aword)EOF;
return;
}
@@ -478,7 +478,7 @@ void Parser::unambig(ParamElem plst[]) {
params[0].code = 0; /* Just make it anything != EOF */
params[0].firstWord = firstWord; /* Remember words for errors below */
params[0].lastWord = lastWord;
- params[1].code = EOF; /* But be sure to terminate */
+ params[1].code = (Aword)EOF; /* But be sure to terminate */
if (listLength(plst) > 1)
_vm->printError(M_WHICH_ONE);
@@ -499,7 +499,7 @@ void Parser::simple(ParamElem olst[]) {
if (tlst == NULL)
tlst = new ParamElem[MAXENTITY + 1];
- tlst[0].code = EOF;
+ tlst[0].code = (Aword)EOF;
for (;;) {
if (isThem(wrds[wrdidx])) {
@@ -515,7 +515,7 @@ void Parser::simple(ParamElem olst[]) {
_vm->printError(M_WHAT_THEM);
listCopy(olst, pmlst);
- olst[0].firstWord = EOF; // No words used
+ olst[0].firstWord = (Aword)EOF; // No words used
wrdidx++;
} else {
unambig(olst); // Look for unambigous noun phrase
@@ -607,7 +607,7 @@ void Parser::resolve(ParamElem plst[]) {
if (plst[i].code < LITMIN) { // Literals are always 'here'
if (!isHere(plst[i].code)) {
params[0] = plst[i]; // Copy error param as first one for message
- params[1].code = EOF; // But be sure to terminate
+ params[1].code = (Aword)EOF; // But be sure to terminate
_vm->printError(M_NO_SUCH);
}
}
@@ -657,7 +657,7 @@ AltElem *Parser::findalt(Aword vrbsadr, Aword param) {
return NULL;
for (vrb = (VrbElem *)addrTo(vrbsadr); !endOfTable(vrb); vrb++) {
- if (vrb->code == _vm->cur.vrb) {
+ if ((int)vrb->code == _vm->cur.vrb) {
for (alt = (AltElem *)addrTo(vrb->alts); !endOfTable(alt); alt++)
if (alt->param == param || alt->param == 0)
return alt;
@@ -727,7 +727,7 @@ bool Parser::possible() {
return true;
}
-void Parser::tryMatch(ParamElem mlst[]) {
+void Parser::tryMatch(ParamElem mlstArr[]) {
ElmElem *elms; // Pointer to element list
StxElem *stx; // Pointer to syntax list
ClaElem *cla; // Pointer to class definitions
@@ -742,7 +742,7 @@ void Parser::tryMatch(ParamElem mlst[]) {
}
for (stx = stxs; !endOfTable(stx); stx++)
- if (stx->code == vrbcode)
+ if ((int)stx->code == vrbcode)
break;
if (endOfTable(stx))
@@ -795,13 +795,13 @@ void Parser::tryMatch(ParamElem mlst[]) {
// Mark this as the multiple position in which to insert
// actual parameter values later
params[paramidx++].code = 0;
- listCopy(mlst, tlst);
+ listCopy(mlstArr, tlst);
anyPlural = true;
}
} else
params[paramidx++] = tlst[0];
- params[paramidx].code = EOF;
+ params[paramidx].code = (Aword)EOF;
}
elms = (ElmElem *) addrTo(elms->next);
@@ -818,8 +818,8 @@ void Parser::tryMatch(ParamElem mlst[]) {
for (cla = (ClaElem *) addrTo(elms->next); !endOfTable(cla); cla++) {
if (params[cla->code - 1].code == 0) {
// This was a multiple parameter, so check all and remove failing
- for (i = 0; mlst[i].code != EOF; i++) {
- params[cla->code-1] = mlst[i];
+ for (i = 0; mlstArr[i].code != EOF; i++) {
+ params[cla->code-1] = mlstArr[i];
if (!claCheck(cla)) {
// Multiple could be both an explicit list of params and an ALL
if (allLength == 0) {
@@ -832,7 +832,7 @@ void Parser::tryMatch(ParamElem mlst[]) {
_vm->paragraph();
}
- mlst[i].code = 0; // In any case remove it from the list
+ mlstArr[i].code = 0; // In any case remove it from the list
}
}
@@ -852,9 +852,9 @@ void Parser::tryMatch(ParamElem mlst[]) {
if (!checked[p]) {
if (params[p].code == 0) {
// This was a multiple parameter, check all and remove failing
- for (i = 0; mlst[i].code != EOF; i++) {
- if (mlst[i].code != 0 && !isObj(mlst[i].code)) // Skip any empty slots
- mlst[i].code = 0;
+ for (i = 0; mlstArr[i].code != EOF; i++) {
+ if (mlstArr[i].code != 0 && !isObj(mlstArr[i].code)) // Skip any empty slots
+ mlstArr[i].code = 0;
}
} else if (!isObj(params[p].code))
_vm->printError(M_CANT0);
@@ -869,35 +869,35 @@ void Parser::tryMatch(ParamElem mlst[]) {
for (p = 0; params[p].code != 0; p++); // Find multiple marker
for (i = 0; i < allLength; i++) {
- if (mlst[i].code != 0) { // Already empty?
- params[p] = mlst[i];
+ if (mlstArr[i].code != 0) { // Already empty?
+ params[p] = mlstArr[i];
if (!possible())
- mlst[i].code = 0; // Remove this from list
+ mlstArr[i].code = 0; // Remove this from list
}
}
params[p].code = 0; // Restore multiple marker
- listCompact(mlst);
+ listCompact(mlstArr);
- if (listLength(mlst) == 0) {
- params[0].code = EOF;
+ if (listLength(mlstArr) == 0) {
+ params[0].code = (Aword)EOF;
_vm->printError(M_WHAT_ALL);
}
} else if (anyPlural) {
- listCompact(mlst);
+ listCompact(mlstArr);
// If there where multiple parameters but non left, exit without a
// word, assuming we have already said enough
- if (listLength(mlst) == 0)
+ if (listLength(mlstArr) == 0)
_vm->printError(MSGMAX);
}
plural = anyPlural; // Remember that we found plural objects
}
-void Parser::match(ParamElem *mlst) {
- tryMatch(mlst); // try to understand what the user said
+void Parser::match(ParamElem *mlstArr) {
+ tryMatch(mlstArr); // try to understand what the user said
if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx]))
_vm->printError(M_WHAT);
@@ -933,10 +933,10 @@ void Parser::action(ParamElem plst[]) {
void Parser::parse() {
if (mlst == NULL) { // Allocate large enough paramlists
mlst = new ParamElem[MAXENTITY + 1];
- mlst[0].code = EOF;
+ mlst[0].code = (Aword)EOF;
pmlst = new ParamElem[MAXENTITY + 1];
params = new ParamElem[MAXENTITY + 1];
- params[0].code = EOF;
+ params[0].code = (Aword)EOF;
pparams = new ParamElem[MAXENTITY + 1];
}
@@ -949,9 +949,9 @@ void Parser::parse() {
allLength = 0;
paramidx = 0;
listCopy(pparams, params);
- params[0].code = EOF;
+ params[0].code = (Aword)EOF;
listCopy(pmlst, mlst);
- mlst[0].code = EOF;
+ mlst[0].code = (Aword)EOF;
if (isVerb(wrds[wrdidx])) {
vrbwrd = wrds[wrdidx];
@@ -960,8 +960,8 @@ void Parser::parse() {
match(mlst);
action(mlst); // mlst contains possible multiple params
} else {
- params[0].code = EOF;
- pmlst[0].code = EOF;
+ params[0].code = (Aword)EOF;
+ pmlst[0].code = (Aword)EOF;
nonverb();
}
}
diff --git a/engines/glk/alan2/parse.h b/engines/glk/alan2/parse.h
index f88fd74a58..1e3601c773 100644
--- a/engines/glk/alan2/parse.h
+++ b/engines/glk/alan2/parse.h
@@ -138,8 +138,8 @@ private:
*/
bool possible();
- void tryMatch(ParamElem mlst[]);
- void match(ParamElem *mlst);
+ void tryMatch(ParamElem mlstArr[]);
+ void match(ParamElem *mlstArr);
/**
* Execute all activities commanded. Handles possible multiple actions
diff --git a/engines/glk/alan2/saveload.cpp b/engines/glk/alan2/saveload.cpp
index 8d2f7a43be..2e7e3d54d0 100644
--- a/engines/glk/alan2/saveload.cpp
+++ b/engines/glk/alan2/saveload.cpp
@@ -30,7 +30,7 @@ namespace Glk {
namespace Alan2 {
void SaveLoad::save() {
- int i;
+ uint i;
Common::SaveFileManager *saveFileMan = _vm->getSaveFileManager();
Common::OutSaveFile *saveFile = nullptr;
Common::String str;
@@ -102,7 +102,7 @@ void SaveLoad::save() {
// Save the event queue
_events[*_eventTop].time = 0; // Mark the top
- for (i = 0; i < *_eventTop + 1; i++)
+ for (i = 0; i < (uint)*_eventTop + 1; i++)
saveFile->write(&_events[i], sizeof(_events[0]));
// Save scores
@@ -113,7 +113,7 @@ void SaveLoad::save() {
}
void SaveLoad::restore() {
- int i, tmp;
+ uint i;
Common::SaveFileManager *saveFileMan = _vm->getSaveFileManager();
Common::InSaveFile *saveFile = nullptr;
Common::String str;