diff options
author | Max Horn | 2007-09-10 13:17:20 +0000 |
---|---|---|
committer | Max Horn | 2007-09-10 13:17:20 +0000 |
commit | 4a302b25adb34e6357506a25cbfba6e182ac9209 (patch) | |
tree | 2d1f5ac4074c70e37c556c263b109d4b659c060e /engines/cruise | |
parent | 6419311a2e361c5e265ae3796ef425700694801f (diff) | |
download | scummvm-rg350-4a302b25adb34e6357506a25cbfba6e182ac9209.tar.gz scummvm-rg350-4a302b25adb34e6357506a25cbfba6e182ac9209.tar.bz2 scummvm-rg350-4a302b25adb34e6357506a25cbfba6e182ac9209.zip |
Lots of source code formatting corrections
svn-id: r28887
Diffstat (limited to 'engines/cruise')
-rw-r--r-- | engines/cruise/actor.cpp | 21 | ||||
-rw-r--r-- | engines/cruise/background.cpp | 3 | ||||
-rw-r--r-- | engines/cruise/backgroundIncrust.cpp | 6 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 429 | ||||
-rw-r--r-- | engines/cruise/ctp.cpp | 9 | ||||
-rw-r--r-- | engines/cruise/decompiler.cpp | 166 | ||||
-rw-r--r-- | engines/cruise/font.cpp | 3 | ||||
-rw-r--r-- | engines/cruise/function.cpp | 25 | ||||
-rw-r--r-- | engines/cruise/gfxModule.cpp | 6 | ||||
-rw-r--r-- | engines/cruise/linker.cpp | 60 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 50 | ||||
-rw-r--r-- | engines/cruise/menu.cpp | 9 | ||||
-rw-r--r-- | engines/cruise/overlay.cpp | 21 | ||||
-rw-r--r-- | engines/cruise/script.cpp | 12 |
14 files changed, 260 insertions, 560 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp index 44b0c9c92d..c4af217117 100644 --- a/engines/cruise/actor.cpp +++ b/engines/cruise/actor.cpp @@ -471,8 +471,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 (*nclick)++; ctpVar19 = ctpVar11; - if (*nclick == 2) // second point - { + if (*nclick == 2) { // second point x1 = table_ptselect[0][0]; y1 = table_ptselect[0][1]; x2 = table_ptselect[1][0]; @@ -858,26 +857,18 @@ void processAnimation(void) { currentActor->phase = ANIM_PHASE_MOVE; } - if ((currentActor->counter >= - 0) - && ((currentActor->phase == - ANIM_PHASE_STATIC_END) - || (currentActor-> - phase == - ANIM_PHASE_STATIC))) + if ((currentActor->counter >= 0) + && ((currentActor->phase == ANIM_PHASE_STATIC_END) + || (currentActor->phase == ANIM_PHASE_STATIC))) { int newA; int inc = 1; - int t_inc = - currentActor-> - startDirection - 1; + int t_inc = currentActor->startDirection - 1; if (t_inc < 0) t_inc = 3; - if (currentActor-> - nextDirection == - t_inc) + if (currentActor->nextDirection == t_inc) inc = -1; if (inc > 0) diff --git a/engines/cruise/background.cpp b/engines/cruise/background.cpp index c375b37b1b..f23c331eb8 100644 --- a/engines/cruise/background.cpp +++ b/engines/cruise/background.cpp @@ -98,8 +98,7 @@ int loadBackground(char *name, int idx) { backgroundPtrtable[idx] = (uint8 *) mallocAndZero(320 * 200 /*64000 */ ); } -/* else - { +/* else { backgroundPtrtable[idx] = hwMemAddr[idx]; } */ } diff --git a/engines/cruise/backgroundIncrust.cpp b/engines/cruise/backgroundIncrust.cpp index 25713394d9..7e79c048b1 100644 --- a/engines/cruise/backgroundIncrust.cpp +++ b/engines/cruise/backgroundIncrust.cpp @@ -113,8 +113,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, newElement->ptr = NULL; strcpy(newElement->name, filesDatabase[params.fileIdx].subData.name); - if (filesDatabase[params.fileIdx].subData.resourceType == 4) // sprite - { + if (filesDatabase[params.fileIdx].subData.resourceType == 4) { // sprite int width = filesDatabase[params.fileIdx].width; int height = filesDatabase[params.fileIdx].height; @@ -125,8 +124,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, newElement->Y, newElement->X, (char *)backgroundPtr, (char *)filesDatabase[params.fileIdx].subData.ptr); // ASSERT(0); - } else // poly - { + } else { // poly /* if(param4 == 1) * { * int var_A; diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index bd6f341d24..b3b0077ee7 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -627,192 +627,98 @@ int getCursorFromObject(int mouseX, int mouseY, int *outX, int *outY) { cellStruct *currentObject = cellHead.prev; while (currentObject) { - if (currentObject->overlay >= 0) { - if (overlayTable[currentObject->overlay].alreadyLoaded) { - if (currentObject->type == 4 - || currentObject->type == 1 - || currentObject->type == 9 - || currentObject->type == 3) { - strcpy(objectName, - getObjectName(currentObject->idx, - overlayTable[currentObject-> - overlay].ovlData-> - specialString2)); - - if (strlen(objectName)) { - if (currentObject->freeze == 0) { - var_2 = - currentObject->idx; - var_4 = - currentObject-> - overlay; - var_14 = - currentObject-> - followObjectIdx; - var_16 = - currentObject-> - followObjectOverlayIdx; - - getMultipleObjectParam - (currentObject-> - overlay, - currentObject->idx, - ¶ms); - - var_10 = 0; - var_E = 0; - var_C = 0; - - if ((var_4 != var_16) - && (var_2 != - var_14)) { - getMultipleObjectParam - (var_16, - var_14, - ¶ms); - - var_C = - params.X; - var_E = - params.Y; - var_10 = - params. - fileIdx; + if (currentObject->overlay >= 0 && overlayTable[currentObject->overlay].alreadyLoaded + && (currentObject->type == 4 || currentObject->type == 1 + || currentObject->type == 9 || currentObject->type == 3)) { + strcpy(objectName, + getObjectName(currentObject->idx, + overlayTable[currentObject->overlay].ovlData->specialString2)); + + if (strlen(objectName)) { + if (currentObject->freeze == 0) { + var_2 = currentObject->idx; + var_4 = currentObject->overlay; + var_14 = currentObject->followObjectIdx; + var_16 = currentObject->followObjectOverlayIdx; + + getMultipleObjectParam(currentObject->overlay, currentObject->idx, ¶ms); + + var_10 = 0; + var_E = 0; + var_C = 0; + + if ((var_4 != var_16) + && (var_2 != var_14)) { + getMultipleObjectParam + (var_16, var_14, ¶ms); + + var_C = params.X; + var_E = params.Y; + var_10 = params.fileIdx; + } + + if (params.var5 >= 0 && params.fileIdx >= 0) { + if (currentObject->type == 3) { + assert(0); + + var_2 = params.scale; + var_A = params.X + var_C; + + // TODO: this var3 is stupid, investigate... + if ((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) { + *outX = var_16; + *outY = var_14; + + return (currentObject->type); } + } else if (currentObject->type == 4 || + currentObject->type == 1 || + currentObject->type == 9) { + int si; + int var_8; + int di; - if (params.var5 >= 0 - && params. - fileIdx >= 0) { - if (currentObject->type == 3) { - assert - (0); - - var_2 = - params. - scale; - var_A = - params. - X + - var_C; - - // TODO: this var3 is stupid, investigate... - if ((var_A <= mouseX) && (var_A + params.fileIdx >= mouseX) && (mouseY >= params.Y + var_E) && (params.Y + var_E + var2 >= mouseY)) { - *outX - = - var_16; - *outY - = - var_14; - - return - (currentObject-> - type); - } - } else - if - (currentObject-> - type == 4 - || - currentObject-> - type == 1 - || - currentObject-> - type == - 9) { - int si; - int var_8; - int di; - - var_A = - params. - X + - var_C; - var_6 = - params. - Y + - var_E; - - di = params.fileIdx; - - if (di - < - 0) - { - di += var_10; - } + var_A = params.X + var_C; + var_6 = params.Y + var_E; -/* if((filesDatabase[di].subData.resourceType == 8) && (filesDatabase[di].subData.ptr)) - { - assert(0); - } - else */ - { - var_4 - = - filesDatabase - [di]. - resType; + di = params.fileIdx; + if (di < 0) { + di += var_10; + } + +/* if((filesDatabase[di].subData.resourceType == 8) && (filesDatabase[di].subData.ptr)) { + assert(0); + } +*/ + { + var_4 = filesDatabase[di].resType; + + if (var_4 == 1) { + var_C = filesDatabase[di].widthInColumn / 2; + } else { + var_C = filesDatabase[di].width; + } + + var_8 = filesDatabase[di].height; + + var_2 = mouseX - var_A; + si = mouseY - var_6; + + if (var_2 > 0 && var_C > var_2 && si > 0 && var_8 >= si) { + if (filesDatabase[di].subData.ptr) { if (var_4 == 1) { - var_C - = - filesDatabase - [di]. - widthInColumn - / - 2; } else { - var_C - = - filesDatabase - [di]. - width; } - var_8 - = - filesDatabase - [di]. - height; - - var_2 - = - mouseX - - - var_A; - si = mouseY - var_6; - - if (var_2 > 0) { - if (var_C > var_2) { - if (si > 0) { - if (var_8 >= si) { - if (filesDatabase[di].subData.ptr) { - if (var_4 == 1) { - } else { - } - - printf - ("should compare to mask in getCursorFromObject...\n"); + printf("should compare to mask in getCursorFromObject...\n"); - *outX - = - var_16; - *outY - = - var_14; + *outX = var_16; + *outY = var_14; - printf - ("Selected: %s\n", - objectName); + printf("Selected: %s\n", objectName); - return - currentObject-> - type; - } - } - } - } - } + return currentObject->type; } } } @@ -878,52 +784,22 @@ void buildInventory(int X, int Y) { menuStruct *pMenu; pMenu = createMenu(X, Y, "Inventaire"); - menuTable[1] = pMenu; - if (pMenu) { - numObjectInInventory = 0; + if (pMenu && numOfLoadedOverlay > 1) { + for (int i = 1; i < numOfLoadedOverlay; i++) { + ovlDataStruct *pOvlData = overlayTable[i].ovlData; - if (numOfLoadedOverlay > 1) { - int i; + if (pOvlData && pOvlData->objDataTable && pOvlData->numObjData) { + for (int j = 0; j < pOvlData->numObjData; j++) { + if (buildInventorySub1(i, j) != 3) { + int16 returnVar; - for (i = 1; i < numOfLoadedOverlay; i++) { - ovlDataStruct *pOvlData = - overlayTable[i].ovlData; + getSingleObjectParam(i, j, 5, &returnVar); - if (pOvlData && pOvlData->objDataTable) { - int var_2; - - var_2 = 0; - - if (pOvlData->numObjData) { - int j; - - for (j = 0; - j < pOvlData->numObjData; - j++) { - if (buildInventorySub1 - (i, j) != 3) { - int16 - returnVar; - - getSingleObjectParam - (i, j, 5, - &returnVar); - - if (returnVar < - -1) { - addSelectableMenuEntry - (i, - j, - pMenu, - 1, - -1, - getObjectName - (j, pOvlData->specialString2)); - numObjectInInventory++; - } - } + if (returnVar < -1) { + addSelectableMenuEntry(i, j, pMenu, 1, -1, getObjectName(j, pOvlData->specialString2)); + numObjectInInventory++; } } } @@ -1014,12 +890,9 @@ int callInventoryObject(int param0, int param1, int x, int y) { var_34->stringNameOffset); if (var_2 == param0) { - if (param1 == - var_34->stringNameOffset) { + if (param1 == var_34->stringNameOffset) { if (pObject) { - if (pObject-> - type != - 3) { + if (pObject->type != 3) { char var_214[80]; char var_1C4[80]; char var_174[80]; @@ -1027,110 +900,52 @@ int callInventoryObject(int param0, int param1, int x, int y) { char var_D4[80]; char var_84[80]; - ovlDataStruct - *var_12; - ovlDataStruct - *var_22; + ovlDataStruct *var_12; + ovlDataStruct *var_22; int var_E = var_34->varIdx; - int cx - = - var_34-> - stringIdx; + int cx = var_34->stringIdx; int var_C = var_34->procIdx; - int di - = - var_E; + int di = var_E; if (var_E == 0) di = var_1E; - var_2 = - cx; - if (cx - == - 0) - var_2 - = - var_1E; + var_2 = cx; + if (cx == 0) + var_2 = var_1E; if (var_C == 0) - var_C - = - var_1E; - - var_12 - = - NULL; - var_22 - = - NULL; - - var_214 - [0] - = - 0; - var_1C4 - [0] - = - 0; - var_174 - [0] - = - 0; - var_124 - [0] - = - 0; - var_D4 - [0] - = - 0; - var_84 - [0] - = - 0; - - if (di - > - 0) - { - var_22 - = - overlayTable - [di]. - ovlData; + var_C = var_1E; + + var_12 = NULL; + var_22 = NULL; + + var_214[0] = 0; + var_1C4[0] = 0; + var_174[0] = 0; + var_124[0] = 0; + var_D4[0] = 0; + var_84[0] = 0; + + if (di > 0) { + var_22 = overlayTable[di].ovlData; } if (var_2 > 0) { - var_12 - = - overlayTable - [var_2]. - ovlData; + var_12 = overlayTable[var_2].ovlData; } if (var_12) { if (var_34->stringNameOffset) { - var_30 - = - var_34-> - field_1A; + var_30 = var_34->field_1A; if (var_28) { if (var_12->specialString2) { if (var_30 == -1 || var_30 == returnVar) { char *ptrName = getObjectName(var_34->stringNameOffset, var_12->specialString2); - menuTable - [0] - = - createMenu - (x, - y, - ptrName); - var_28 - = - 0; + menuTable[0] = createMenu(x, y, ptrName); + var_28 = 0; } } } @@ -1138,8 +953,7 @@ int callInventoryObject(int param0, int param1, int x, int y) { } if (var_22) { - if (true /*var_34->varNameOffset>=0 */ ) // FIXME: This check is always true since varNameOffset is unsigned - { + if (true /*var_34->varNameOffset>=0 */ ) { // FIXME: This check is always true since varNameOffset is unsigned if (var_22->specialString1) { char *ptr = getObjectName(var_34->varNameOffset, var_22->specialString1); @@ -1289,8 +1103,7 @@ int processInput(void) { ASSERT(0); } - if (var38 == 0) // are we in inventory mode ? - { + if (var38 == 0) { // are we in inventory mode ? if (menuTable[0] == 0) { int X; int Y; diff --git a/engines/cruise/ctp.cpp b/engines/cruise/ctp.cpp index 84e510a53f..5af2cda46c 100644 --- a/engines/cruise/ctp.cpp +++ b/engines/cruise/ctp.cpp @@ -66,16 +66,14 @@ void loadCtpSub2(short int coordCount, short int *ptr) { short int *cur_ctp_routeCoords = (short int *)ctp_routeCoords; // coordinates table int8 *cur_ctp_routes = (int8 *) ctp_routes; - for (i = 0; i < coordCount; i++) // for i < ctp_routeCoordCount - { + for (i = 0; i < coordCount; i++) { // for i < ctp_routeCoordCount int varX = cur_ctp_routeCoords[0]; // x int varY = cur_ctp_routeCoords[1]; // y int di = 0; int var4Offset = 2; - while (*(int16 *) cur_ctp_routes > di) // while (coordCount > counter++) - { + while (*(int16 *) cur_ctp_routes > di) { // while (coordCount > counter++) int idx = *(int16 *) (cur_ctp_routes + var4Offset); ptr[offset + idx] = ctpProc2(varX, varY, ctp_routeCoords[idx][0], @@ -189,8 +187,7 @@ void loadCtpSub1(int boxIdx, int scale, uint16 *_walkboxTable, ASSERT(boxIdx <= 15); - if (_walkboxTable[boxIdx * 40] > 0) // is walkbox used ? - { + if (_walkboxTable[boxIdx * 40] > 0) { // is walkbox used ? getWalkBoxCenter(boxIdx, _walkboxTable); currentWalkBoxCenterYBis = currentWalkBoxCenterY; diff --git a/engines/cruise/decompiler.cpp b/engines/cruise/decompiler.cpp index 7adfd00f3e..b027f948aa 100644 --- a/engines/cruise/decompiler.cpp +++ b/engines/cruise/decompiler.cpp @@ -136,52 +136,47 @@ void pushDecomp(char *string, ...) { void resolveDecompShort(char *buffer) { ovlData3Struct *data3Ptr = currentScript; + int i; - { - int i; + importScriptStruct *importEntry = + (importScriptStruct *) (data3Ptr->dataPtr + + data3Ptr->offsetToImportData); - importScriptStruct *importEntry = - (importScriptStruct *) (data3Ptr->dataPtr + - data3Ptr->offsetToImportData); - - for (i = 0; i < data3Ptr->numImport; i++) { - switch (importEntry->type) { - case 20: // script - case 30: - case 40: - case 50: - { - if (importEntry->offset == currentDecompScriptPtr->var4 - 3) // param1 - { - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } - if (importEntry->offset == currentDecompScriptPtr->var4 - 6) // param2 - { - sprintf(buffer, "linkedIdx"); - return; - } - break; + for (i = 0; i < data3Ptr->numImport; i++) { + switch (importEntry->type) { + case 20: // script + case 30: + case 40: + case 50: + { + if (importEntry->offset == currentDecompScriptPtr->var4 - 3) { // param1 + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } - default: - { - if (importEntry->offset == - currentDecompScriptPtr->var4 - 4) { - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } + if (importEntry->offset == currentDecompScriptPtr->var4 - 6) { // param2 + sprintf(buffer, "linkedIdx"); + return; + } + break; + } + default: + { + if (importEntry->offset == + currentDecompScriptPtr->var4 - 4) { + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } } - importEntry++; } + importEntry++; } buffer[0] = 0; @@ -190,31 +185,28 @@ void resolveDecompShort(char *buffer) { void resolveDecompChar(char *buffer) { ovlData3Struct *data3Ptr = currentScript; + int i; - { - int i; + importScriptStruct *importEntry = + (importScriptStruct *) (data3Ptr->dataPtr + + data3Ptr->offsetToImportData); - importScriptStruct *importEntry = - (importScriptStruct *) (data3Ptr->dataPtr + - data3Ptr->offsetToImportData); - - for (i = 0; i < data3Ptr->numImport; i++) { - switch (importEntry->type) { - default: - { - if (importEntry->offset == - currentDecompScriptPtr->var4 - 2) { - sprintf(buffer, - data3Ptr->dataPtr + - data3Ptr-> - offsetToImportName + - importEntry->offsetToName); - return; - } + for (i = 0; i < data3Ptr->numImport; i++) { + switch (importEntry->type) { + default: + { + if (importEntry->offset == + currentDecompScriptPtr->var4 - 2) { + sprintf(buffer, + data3Ptr->dataPtr + + data3Ptr-> + offsetToImportName + + importEntry->offsetToName); + return; } } - importEntry++; } + importEntry++; } buffer[0] = 0; @@ -342,16 +334,14 @@ void resolveVarName(char *ovlIdxString, int varType, char *varIdxString, for (i = 0; i < currentDecompOvl->numExport; i++) { if (varIdx == currentDecompOvl->exportDataPtr[i].idx) { - if (((currentDecompOvl->exportDataPtr[i].var4 & 0xF0) == 0) && varType != 0x20) // var - { + if (((currentDecompOvl->exportDataPtr[i].var4 & 0xF0) == 0) && varType != 0x20) { // var strcpy(outputName, currentDecompOvl->exportNamesPtr + currentDecompOvl->exportDataPtr[i]. offsetToName); return; } - if ((currentDecompOvl->exportDataPtr[i].var4) == 20 && varType == 0x20) // script - { + if ((currentDecompOvl->exportDataPtr[i].var4) == 20 && varType == 0x20) { // script strcpy(outputName, currentDecompOvl->exportNamesPtr + currentDecompOvl->exportDataPtr[i]. @@ -722,13 +712,11 @@ int decompCompare(void) { if(!pop) si = 1; - if(pop<0) - { + if(pop<0) { si |= 4; } - if(pop>0) - { + if(pop>0) { si |= 2; } @@ -1435,7 +1423,7 @@ int decompBreak(void) { } void generateIndentation(void) { - int i; + int i, j; for (i = 0; i < positionInDecompileLineTable; i++) { if (decompileLineTable[i].type != 0) { @@ -1449,37 +1437,25 @@ void generateIndentation(void) { gotoStatement = strchr(gotoStatement, ' ') + 1; destLine = atoi(gotoStatement); + destLineIdx = -1; - { - int j; - - destLineIdx = -1; - - for (j = 0; j < positionInDecompileLineTable; - j++) { - if (decompileLineTable[j].lineOffset == - destLine) { - destLineIdx = j; - break; - } + for (j = 0; j < positionInDecompileLineTable; j++) { + if (decompileLineTable[j].lineOffset == destLine) { + destLineIdx = j; + break; } + } - assert(destLineIdx != -1); - - if (destLineIdx > i) { - int j; + assert(destLineIdx != -1); - for (j = i + 1; j < destLineIdx; j++) { - decompileLineTable[j].indent++; - } + if (destLineIdx > i) { + for (j = i + 1; j < destLineIdx; j++) { + decompileLineTable[j].indent++; + } - if (strstr(decompileLineTable - [destLineIdx - 1].line, - "goto") == - decompileLineTable[destLineIdx - - 1].line) { - //decompileLineTable[destLineIdx-1].pendingElse = 1; - } + if (strstr(decompileLineTable[destLineIdx - 1].line, "goto") == + decompileLineTable[destLineIdx - 1].line) { + //decompileLineTable[destLineIdx-1].pendingElse = 1; } } } diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index c94bbc8f82..ee99567525 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -253,8 +253,7 @@ void renderWord(uint8 * fontPtr_Data, uint8 * outBufferPtr, outBufferPtr += heightOff * width * 2; // param2 = height , param6 = width outBufferPtr += drawPosPixel_X; // param1 = drawPosPixel_X - for (i = 0; i < height; i++) // y++ - { + for (i = 0; i < height; i++) { // y++ uint16 currentColor1 = (*(fontPtr_Data) << 8) | *(fontPtr_Data + 1); uint16 currentColor2 = diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp index 7841a5e4ce..cfb579e331 100644 --- a/engines/cruise/function.cpp +++ b/engines/cruise/function.cpp @@ -1006,8 +1006,7 @@ actorStruct *addAnimation(actorStruct * pHead, int overlay, int objIdx, int para return pNewElement; } -int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) -{ +int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) { actorStruct* pl; actorStruct* pl2; actorStruct* pl3; @@ -1019,14 +1018,12 @@ int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) pl2 = pl; pl = pl2->next; - while(pl) - { + while (pl) { pl2 = pl; - if(((pl->overlayNumber == overlay) || (overlay == -1)) && + if (((pl->overlayNumber == overlay) || (overlay == -1)) && ((pl->idx == objIdx) || (objIdx == -1)) && - ((pl->type == objType) || (objType == -1))) - { + ((pl->type == objType) || (objType == -1))) { pl->type = -1; } @@ -1037,29 +1034,25 @@ int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) pl2 = pl; pl = pl2->next; - while(pl) - { - if(pl->type == -1) - { + while (pl) { + if (pl->type == -1) { pl4 = pl->next; pl2->next = pl4; pl3 = pl4; - if(pl3 == NULL) + if (pl3 == NULL) pl3 = pHead; pl3->prev = pl->prev; dir = pl->startDirection; - if(pl->idx >= 0) + if (pl->idx >= 0) freePerso(pl->idx); free(pl); pl = pl4; - } - else - { + } else { pl2 = pl; pl = pl2->next; } diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index 881bf1d3ca..9228193560 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -526,10 +526,8 @@ void gfxModuleData_field_60(char *sourcePtr, int width, int height, int i; int j; - for(i=x;i<height+x;i++) - { - for(j=y;j<width*16+y;j++) - { + for(i=x;i<height+x;i++) { + for(j=y;j<width*16+y;j++) { if(i>=0&&i<200&&j>=0&&j<320) destPtr[i*320+j] = *(sourcePtr++); } diff --git a/engines/cruise/linker.cpp b/engines/cruise/linker.cpp index 6cd28062d3..e72218037b 100644 --- a/engines/cruise/linker.cpp +++ b/engines/cruise/linker.cpp @@ -186,70 +186,36 @@ int updateScriptImport(int ovlIdx) { int temp = ptrImportData-> offset; - if (out1) //is sub function... (ie 'invent.livre:s') - { + if (out1) { //is sub function... (ie 'invent.livre:s') uint8 *ptr = ptrData + temp; - *(ptr + - 1) - = - out2; - *(int16 - *) - (ptr - + - 2) - = - ptrDest2-> - idx; - - flipShort - ( - (int16 - *) - (ptr + 2)); + *(ptr + 1) = out2; + *(int16 *)(ptr + 2) = ptrDest2->idx; + + flipShort((int16 *)(ptr + 2)); } else { - if (param2 == 20 || param2 == 30 || param2 == 40 || param2 == 50) // this patch a double push - { - uint8 - * - ptr - = - ptrData - + - temp; + if (param2 == 20 || param2 == 30 || param2 == 40 || param2 == 50) { // this patch a double push + uint8 *ptr = ptrData + temp; *(ptr + 1) = 0; *(ptr + 2) = out2; // update the overlay number - *(int16 *) (ptr + 4) = ptrDest2->idx; + *(int16 *)(ptr + 4) = ptrDest2->idx; - flipShort - ( - (int16 - *) - (ptr + 4)); + flipShort((int16 *)(ptr + 4)); } else { int var_4 = ptrDest2->var4; if (var_4 & 1) { - param2 - = - 8; + param2 = 8; } else { - param2 - = - 16; + param2 = 16; } if (var_4 >= 0 && var_4 <= 3) { - param2 - |= - 5; + param2 |= 5; } else { - param2 - |= - 6; + param2 |= 6; } *(ptrData + temp) = param2; diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index 95142e9edf..b30dc29380 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -24,7 +24,8 @@ */ #include "cruise/cruise_main.h" -#include "polys.h" +#include "cruise/polys.h" +#include "common/util.h" namespace Cruise { @@ -131,8 +132,7 @@ void getPolyData(int fileIndex, int X, int Y, int *outScale, int *outY, newFileIndex += fileIndex; - if (true /*newFileIndex >= 0 */ ) // FIXME: comparison is always true due to limited range of data type - { + if (true /*newFileIndex >= 0 */ ) { // FIXME: comparison is always true due to limited range of data type if (filesDatabase[newFileIndex].resType == 0 && filesDatabase[newFileIndex].subData.ptr) { dataPtr = @@ -180,8 +180,7 @@ void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], int lowerBorder; m_flipLeftRight = 0; - if (scale < 0) // flip left right - { + if (scale < 0) { // flip left right m_flipLeftRight = 1; scale = -scale; } @@ -208,11 +207,8 @@ void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16; - if (upperBorder < lowerBorder) // exchange borders if lower > upper - { - int temp = upperBorder; - upperBorder = lowerBorder; - lowerBorder = temp; + if (upperBorder < lowerBorder) { // exchange borders if lower > upper + SWAP(upperBorder, lowerBorder); } sizeTable[0] = lowerBorder; // left @@ -231,11 +227,8 @@ void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], upperBorder -= *(dataPtr + 4); upperBorder = (upscaleValue(upperBorder, scale) + 0x8000) >> 16; - if (upperBorder < lowerBorder) // exchange borders if lower > upper - { - int temp = upperBorder; - upperBorder = lowerBorder; - lowerBorder = temp; + if (upperBorder < lowerBorder) { // exchange borders if lower > upper + SWAP(upperBorder, lowerBorder); } sizeTable[2] = lowerBorder; // bottom @@ -397,8 +390,7 @@ void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, m_flipLeftRight = 1; } - if (scale < 0x180) // If scale is smaller than 384 - { + if (scale < 0x180) { // If scale is smaller than 384 m_useSmallScale = 1; m_scaleValue = scale << 1; // double scale } else { @@ -448,8 +440,7 @@ void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, x = *(dataPointer++) - m_first_X; y = *(dataPointer++) - m_first_Y; - if (m_useSmallScale) // shrink all coordinates by factor 2 if a scale smaller than 384 is used - { + if (m_useSmallScale) { // shrink all coordinates by factor 2 if a scale smaller than 384 is used x >>= 1; y >>= 1; } @@ -502,8 +493,7 @@ void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, do { int linesToDraw = *dataPointer++; - if (linesToDraw > 1) // if value not zero - { + if (linesToDraw > 1) { // if value not zero uint16 minimumScale; m_color = *dataPointer; // color @@ -514,8 +504,7 @@ void buildPolyModel(int positionX, int positionY, int scale, char *ptr2, flipShort(&minimumScale); - if (minimumScale > scale) // if the scale is too small, for the model to be drawn ... - { + if (minimumScale > scale) { // if the scale is too small, for the model to be drawn ... dataPointer += linesToDraw; // ... skip ahead } else { if (m_flipLeftRight) { @@ -913,13 +902,10 @@ void mainDraw(int16 param) { } if ((params.var5 >= 0) && (objZ2 >= 0) && filesDatabase[objZ2].subData.ptr) { - if (filesDatabase[objZ2].subData.resourceType == 8) // Poly - { + if (filesDatabase[objZ2].subData.resourceType == 8) { // Poly mainDrawPolygons(objZ2, currentObjPtr, objX2, params.scale, objY2, (char *)gfxModuleData.pPage10, (char *)filesDatabase[objZ2].subData.ptr); // poly - } else if (filesDatabase[objZ2].subData.resourceType == 6) // sound - { - } else if (filesDatabase[objZ2].resType == 1) //(num plan == 1) - { + } else if (filesDatabase[objZ2].subData.resourceType == 6) { // sound + } else if (filesDatabase[objZ2].resType == 1) { //(num plan == 1) } else if (filesDatabase[objZ2].subData.resourceType == 4) { objX1 = filesDatabase[objZ2].width; // width spriteHeight = filesDatabase[objZ2].height; // height @@ -953,12 +939,10 @@ void mainDraw(int16 param) { change = false; currentObjPtr->animStep = 0; - if (currentObjPtr->animType) // should we resume the script ? - { + if (currentObjPtr->animType) { // should we resume the script ? if (currentObjPtr->parentType == 20) { changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &procHead, 0, -1); - } - else if(currentObjPtr->parentType == 30) { + } else if (currentObjPtr->parentType == 30) { changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, 0, -1); } } diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index 2ea8c4ff8c..4f828d1fd3 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -221,8 +221,7 @@ int playerMenu(int menuX, int menuY) { freeStuff2(); } /* - if(currentMenu) - { + if(currentMenu) { freeMenu(currentMenu); currentMenu = 0; var37 = 0; @@ -230,8 +229,7 @@ int playerMenu(int menuX, int menuY) { main9 = -1; } - if(inventoryMenu) - { + if(inventoryMenu) { freeMenu(inventoryMenu); inventoryMenu = 0; var37 = 0; @@ -239,8 +237,7 @@ int playerMenu(int menuX, int menuY) { main9 = -1; }*/ -/* if(mouseVar2) - { +/* if(mouseVar2) { free3(mouseVar2); } */ diff --git a/engines/cruise/overlay.cpp b/engines/cruise/overlay.cpp index 2b83e0f2b2..179c53357d 100644 --- a/engines/cruise/overlay.cpp +++ b/engines/cruise/overlay.cpp @@ -375,8 +375,7 @@ int loadOverlay(const uint8 *scriptName) { if (!ovlData->ptr8) { /* releaseScript(scriptIdx,scriptName); - if(freeIsNeeded) - { + if(freeIsNeeded) { freePtr(unpackedBuffer); } */ @@ -396,8 +395,7 @@ int loadOverlay(const uint8 *scriptName) { if (!ovlData->objDataTable) { /* releaseScript(scriptIdx,scriptName); - if(freeIsNeeded) - { + if(freeIsNeeded) { freePtr(unpackedBuffer); } */ @@ -457,8 +455,7 @@ int loadOverlay(const uint8 *scriptName) { if (!ovlData->objData2WorkTable) { /* releaseScript(scriptIdx,scriptName); - if(freeIsNeeded) - { + if(freeIsNeeded) { freePtr(unpackedBuffer); } */ @@ -474,8 +471,7 @@ int loadOverlay(const uint8 *scriptName) { if (!ovlData->objData2SourceTable) { /* releaseScript(scriptIdx,scriptName); - if(freeIsNeeded) - { + if(freeIsNeeded) { freePtr(unpackedBuffer); } */ @@ -501,8 +497,7 @@ int loadOverlay(const uint8 *scriptName) { } } -/* if(freeIsNeeded) - { +/* if(freeIsNeeded) { freePtr(unpackedBuffer); } */ @@ -701,14 +696,12 @@ int releaseOverlay(const char *name) { if (!ovlDataPtr) return -4; /* - if(overlayTable[overlayIdx].var1E) - { + if(overlayTable[overlayIdx].var1E) { free(overlayTable[overlayIdx].var1E); overlayTable[overlayIdx].var1E = NULL; } - if(overlayTable[overlayIdx].var16) - { + if(overlayTable[overlayIdx].var16) { free(overlayTable[overlayIdx].var16); overlayTable[overlayIdx].var16 = NULL; } */ diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp index d3d88a8b5f..c9ba819d75 100644 --- a/engines/cruise/script.cpp +++ b/engines/cruise/script.cpp @@ -73,8 +73,7 @@ int32 opcodeType0(void) { if (!byte2) { ptr = scriptDataPtrTable[var_E] + short1; - } else // TODO: - { + } else { // TODO: if (!overlayTable[byte2].alreadyLoaded) { return (-7); } @@ -145,8 +144,7 @@ int32 opcodeType0(void) { if (!byte2) { ptr = scriptDataPtrTable[var_E] + var_12; - } else // TODO: - { + } else { // TODO: if (!overlayTable[byte2].alreadyLoaded) { return (-7); } @@ -635,8 +633,7 @@ uint8 *attacheNewScriptToTail(int16 overlayNumber, oldTail = scriptHandlePtr; - while (oldTail->nextScriptPtr) // go to the end of the list - { + while (oldTail->nextScriptPtr) { // go to the end of the list oldTail = oldTail->nextScriptPtr; } @@ -660,8 +657,7 @@ uint8 *attacheNewScriptToTail(int16 overlayNumber, tempPtr->scriptNumber = param; tempPtr->overlayNumber = overlayNumber; - if (scriptType == 20) // Obj or not ? - { + if (scriptType == 20) { // Obj or not ? tempPtr->sysKey = useArg3Neg; } else { tempPtr->sysKey = 1; |