fix misleading-indentation

This commit is contained in:
Chris Cromer 2019-05-01 19:16:51 -04:00
parent 3220c5f1b1
commit 655f62082d
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
1 changed files with 80 additions and 41 deletions

View File

@ -1,9 +1,9 @@
/* /*
* QT AGI Studio :: Copyright (C) 2000 Helen Zommer * QT AGI Studio :: Copyright (C) 2000 Helen Zommer
* *
* Almost all of this code was adapted from the Windows AGI Studio * Almost all of this code was adapted from the Windows AGI Studio
* developed by Peter Kelly. * developed by Peter Kelly.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
@ -75,7 +75,7 @@ static byte ReadByte(void)
static short ReadLSMSWord(void) static short ReadLSMSWord(void)
{ {
byte MSbyte,LSbyte; byte MSbyte,LSbyte;
LSbyte = ReadByte(); LSbyte = ReadByte();
MSbyte = ReadByte(); MSbyte = ReadByte();
@ -133,7 +133,7 @@ void Logic::ReadMessages(void)
} }
//*************************************************** //***************************************************
void Logic::DisplayMessages(void) void Logic::DisplayMessages(void)
{ {
int i; int i;
if(game->show_all_messages){ if(game->show_all_messages){
@ -149,7 +149,7 @@ void Logic::DisplayMessages(void)
for(i=1;i<=255;i++){ for(i=1;i<=255;i++){
if (MessageExists[i] && !MessageUsed[i]){ if (MessageExists[i] && !MessageUsed[i]){
OutputText.append("#message " + IntToStr(i)+" \""+Messages[i]+"\"\n"); OutputText.append("#message " + IntToStr(i)+" \""+Messages[i]+"\"\n");
} }
} }
} }
@ -165,7 +165,7 @@ int Logic::FindLabels_ReadIfs(void)
if(CurByte == 0xFC)CurByte = ReadByte(); // we may have 2 0xFCs in a row, e.g. (a || b) && (c || d) if(CurByte == 0xFC)CurByte = ReadByte(); // we may have 2 0xFCs in a row, e.g. (a || b) && (c || d)
if(CurByte == 0xFD)CurByte = ReadByte(); if(CurByte == 0xFD)CurByte = ReadByte();
if (CurByte > 0 && CurByte <= NumTestCommands){ if (CurByte > 0 && CurByte <= NumTestCommands){
ThisCommand = CurByte; ThisCommand = CurByte;
if (ThisCommand == 14){ // said command if (ThisCommand == 14){ // said command
NumSaidArgs = ReadByte(); NumSaidArgs = ReadByte();
@ -188,7 +188,7 @@ int Logic::FindLabels_ReadIfs(void)
BlockEnd[BlockDepth] = BlockLength[BlockDepth] + ResPos; BlockEnd[BlockDepth] = BlockLength[BlockDepth] + ResPos;
if (BlockEnd[BlockDepth] > BlockEnd[BlockDepth-1]){ if (BlockEnd[BlockDepth] > BlockEnd[BlockDepth-1]){
sprintf(tmp,"Block too long (%d bytes longer than rest of previous block)",BlockEnd[BlockDepth]-BlockEnd[BlockDepth-1]); sprintf(tmp,"Block too long (%d bytes longer than rest of previous block)",BlockEnd[BlockDepth]-BlockEnd[BlockDepth-1]);
ErrorOccured=true; ErrorOccured=true;
ErrorList.append(string(tmp)+"\n"); ErrorList.append(string(tmp)+"\n");
} }
break; break;
@ -253,12 +253,12 @@ int Logic::FindLabels(void)
ErrorList.append(tmp); ErrorList.append(tmp);
ErrorOccured=true; ErrorOccured=true;
break; break;
} }
if (LabelIndex.Data[LabelLoc] == 0){ if (LabelIndex.Data[LabelLoc] == 0){
NumLabels++; NumLabels++;
LabelIndex.Data[LabelLoc] = NumLabels; LabelIndex.Data[LabelLoc] = NumLabels;
} }
} }
} }
else{ else{
sprintf(tmp,"Unknown command (%d)",CurByte); sprintf(tmp,"Unknown command (%d)",CurByte);
@ -305,7 +305,7 @@ void Logic::AddArg(byte Arg, byte ArgType)
ThisMessage = ""; ThisMessage = "";
} }
}while(ThisMessage.length()>0); }while(ThisMessage.length()>0);
} }
else if(ShowNonExistingValues){ else if(ShowNonExistingValues){
ThisLine += ArgTypePrefix[atMsg] + IntToStr(Arg); ThisLine += ArgTypePrefix[atMsg] + IntToStr(Arg);
} }
@ -326,7 +326,7 @@ void Logic::AddArg(byte Arg, byte ArgType)
else{ else{
sprintf(tmp,"Unknown inventory item (%d)\n",Arg); sprintf(tmp,"Unknown inventory item (%d)\n",Arg);
ErrorList.append(tmp); ErrorList.append(tmp);
ErrorOccured=true; ErrorOccured=true;
} }
break; break;
default: default:
@ -360,21 +360,40 @@ void Logic::AddSpecialSyntaxCommand(void)
// assignv // assignv
case 0x04: ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(ReadByte()); break; case 0x04: ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(ReadByte()); break;
// addn // addn
case 0x05: if (SpecialSyntaxType == 0) case 0x05:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" + "+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" += "+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" + "+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" += "+IntToStr(ReadByte());
}
break;
// addv // addv
case 0x06: if (SpecialSyntaxType == 0) case 0x06:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" + v"+IntToStr(ReadByte()); if (SpecialSyntaxType == 0)
else ThisLine += "v"+IntToStr(arg1)+" += v"+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" + v"+IntToStr(ReadByte());
else {
ThisLine += "v"+IntToStr(arg1)+" += v"+IntToStr(ReadByte());
}
break;
// subn // subn
case 0x07: if (SpecialSyntaxType == 0) case 0x07:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" - "+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" -= "+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" - "+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" -= "+IntToStr(ReadByte());
}
break;
// subv // subv
case 0x08: if (SpecialSyntaxType == 0) case 0x08:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" - v"+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" -= v"+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" - v"+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" -= v"+IntToStr(ReadByte());
}
break;
// lindirectv // lindirectv
case 0x09: ThisLine += "*v"+IntToStr(arg1)+" = v"+IntToStr(ReadByte()); break; case 0x09: ThisLine += "*v"+IntToStr(arg1)+" = v"+IntToStr(ReadByte()); break;
// rindirect // rindirect
@ -382,21 +401,41 @@ void Logic::AddSpecialSyntaxCommand(void)
// lindirectn // lindirectn
case 0x0B: ThisLine += "*v"+IntToStr(arg1)+" = "+IntToStr(ReadByte()); break; case 0x0B: ThisLine += "*v"+IntToStr(arg1)+" = "+IntToStr(ReadByte()); break;
// mul.n // mul.n
case 0xA5: if (SpecialSyntaxType == 0) case 0xA5:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" * "+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" *= "+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" * "+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" *= "+IntToStr(ReadByte());
}
break;
// mul.v // mul.v
case 0xA6: if (SpecialSyntaxType == 0) case 0xA6:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" * v"+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" *= v"+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" * v"+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" *= v"+IntToStr(ReadByte());
}
break;
// div.n // div.n
case 0xA7: if (SpecialSyntaxType == 0) case 0xA7:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" / "+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" /= "+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" / "+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" /= "+IntToStr(ReadByte());
}
break;
// div.v // div.v
case 0xA8: if (SpecialSyntaxType == 0) case 0xA8:
ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" / v"+IntToStr(ReadByte()); if (SpecialSyntaxType == 0) {
else ThisLine += "v"+IntToStr(arg1)+" /= v"+IntToStr(ReadByte()); break; ThisLine += "v"+IntToStr(arg1)+" = v"+IntToStr(arg1)+" / v"+IntToStr(ReadByte());
}
else {
ThisLine += "v"+IntToStr(arg1)+" /= v"+IntToStr(ReadByte());
}
break;
} }
} }
@ -541,13 +580,13 @@ void Logic::ReadIfs(void)
BlockDepth++; BlockDepth++;
BlockIsIf[BlockDepth] = true; BlockIsIf[BlockDepth] = true;
BlockLength[BlockDepth] = ReadLSMSWord(); BlockLength[BlockDepth] = ReadLSMSWord();
BlockEnd[BlockDepth] = BlockLength[BlockDepth] + ResPos; BlockEnd[BlockDepth] = BlockLength[BlockDepth] + ResPos;
if (BlockEnd[BlockDepth] > BlockEnd[BlockDepth-1]){ if (BlockEnd[BlockDepth] > BlockEnd[BlockDepth-1]){
sprintf(tmp,"Block too long (%d bytes longer than rest of previous block)\n",BlockEnd[BlockDepth]-BlockEnd[BlockDepth-1]); sprintf(tmp,"Block too long (%d bytes longer than rest of previous block)\n",BlockEnd[BlockDepth]-BlockEnd[BlockDepth-1]);
ErrorList.append(tmp); ErrorList.append(tmp);
ErrorOccured=true; ErrorOccured=true;
break; break;
} }
} }
OutputText.append(ThisLine+"\n"); OutputText.append(ThisLine+"\n");
ThisLine = MultStr(" ",BlockDepth); ThisLine = MultStr(" ",BlockDepth);
@ -570,15 +609,15 @@ int Logic::decode(int ResNum)
sprintf(tmp,"%s/words.tok",game->dir.c_str()); sprintf(tmp,"%s/words.tok",game->dir.c_str());
ret = wordlist->read(tmp); ret = wordlist->read(tmp);
if(ret)return 1; if(ret)return 1;
sprintf(tmp,"%s/object",game->dir.c_str()); sprintf(tmp,"%s/object",game->dir.c_str());
ret = objlist->read(tmp,false); ret = objlist->read(tmp,false);
if(ret)return 1; if(ret)return 1;
objlist->ItemNames.toLower(); objlist->ItemNames.toLower();
// words already in lower case in file so we don't need to convert them // words already in lower case in file so we don't need to convert them
for(i=0;i<objlist->ItemNames.num;i++){ for(i=0;i<objlist->ItemNames.num;i++){
if(objlist->ItemNames.at(i).find_first_of("\"")==string::npos)continue; if(objlist->ItemNames.at(i).find_first_of("\"")==string::npos)continue;
//replace " with \" //replace " with \"
char *ptr=(char *)objlist->ItemNames.at(i).c_str(); char *ptr=(char *)objlist->ItemNames.at(i).c_str();
for(j=0;*ptr;ptr++){ for(j=0;*ptr;ptr++){
if(*ptr=='"'){ if(*ptr=='"'){
@ -590,7 +629,7 @@ int Logic::decode(int ResNum)
tmp[j]=0; tmp[j]=0;
objlist->ItemNames.replace(i,tmp); objlist->ItemNames.replace(i,tmp);
} }
ret = game->ReadResource(LOGIC,ResNum); ret = game->ReadResource(LOGIC,ResNum);
if(ret)return 1; if(ret)return 1;