From 7fbfbc8e6b57729e1a5008d256b28b0571f1c3b6 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Fri, 31 Aug 2012 23:08:02 +0200 Subject: TONY: Rename some more variables and structures --- engines/tony/globals.h | 12 +- engines/tony/mpal/loadmpc.cpp | 276 ++++++++++++++++---------------- engines/tony/mpal/loadmpc.h | 4 +- engines/tony/mpal/mpal.cpp | 355 +++++++++++++++++++++--------------------- engines/tony/mpal/mpal.h | 13 +- engines/tony/mpal/mpaldll.h | 170 +++++++++----------- engines/tony/tony.cpp | 4 +- 7 files changed, 405 insertions(+), 429 deletions(-) diff --git a/engines/tony/globals.h b/engines/tony/globals.h index 0911782eac..6966bd7264 100644 --- a/engines/tony/globals.h +++ b/engines/tony/globals.h @@ -252,22 +252,22 @@ public: uint16 _nObjs; uint16 _nVars; HGLOBAL _hVars; - LPMPALVAR _lpmvVars; + LpMpalVar _lpmvVars; uint16 _nMsgs; HGLOBAL _hMsgs; - LPMPALMSG _lpmmMsgs; + LpMpalMsg _lpmmMsgs; uint16 _nDialogs; HGLOBAL _hDialogs; - LPMPALDIALOG _lpmdDialogs; + LpMpalDialog _lpmdDialogs; uint16 _nItems; HGLOBAL _hItems; - LPMPALITEM _lpmiItems; + LpMpalItem _lpmiItems; uint16 _nLocations; HGLOBAL _hLocations; - LPMPALLOCATION _lpmlLocations; + LpMpalLocation _lpmlLocations; uint16 _nScripts; HGLOBAL _hScripts; - LPMPALSCRIPT _lpmsScripts; + LpMpalScript _lpmsScripts; Common::File _hMpr; uint16 _nResources; uint32 *_lpResources; diff --git a/engines/tony/mpal/loadmpc.cpp b/engines/tony/mpal/loadmpc.cpp index 9927f9fe8e..b3c4193414 100644 --- a/engines/tony/mpal/loadmpc.cpp +++ b/engines/tony/mpal/loadmpc.cpp @@ -39,15 +39,15 @@ namespace MPAL { * Static functions \****************************************************************************/ -static bool compareCommands(struct command *cmd1, struct command *cmd2) { - if (cmd1->type == 2 && cmd2->type == 2) { - if (strcmp(cmd1->lpszVarName, cmd2->lpszVarName) == 0 && - compareExpressions(cmd1->expr, cmd2->expr)) +static bool compareCommands(struct Command *cmd1, struct Command *cmd2) { + if (cmd1->_type == 2 && cmd2->_type == 2) { + if (strcmp(cmd1->_lpszVarName, cmd2->_lpszVarName) == 0 && + compareExpressions(cmd1->_expr, cmd2->_expr)) return true; else return false; } else - return (memcmp(cmd1, cmd2, sizeof(struct command)) == 0); + return (memcmp(cmd1, cmd2, sizeof(struct Command)) == 0); } /** @@ -58,25 +58,25 @@ static bool compareCommands(struct command *cmd1, struct command *cmd2) { * data of the script. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { - lpmsScript->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseScript(const byte *lpBuf, LpMpalScript lpmsScript) { + lpmsScript->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->nMoments = READ_LE_UINT16(lpBuf); + lpmsScript->_nMoments = READ_LE_UINT16(lpBuf); lpBuf += 2; int curCmd = 0; - for (uint i = 0; i < lpmsScript->nMoments; i++) { - lpmsScript->Moment[i].dwTime = (int32)READ_LE_UINT32(lpBuf); + for (uint i = 0; i < lpmsScript->_nMoments; i++) { + lpmsScript->_moment[i]._dwTime = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmsScript->Moment[i].nCmds = *lpBuf; + lpmsScript->_moment[i]._nCmds = *lpBuf; lpBuf++; - for (int j = 0; j < lpmsScript->Moment[i].nCmds; j++) { - lpmsScript->_command[curCmd].type = *lpBuf; + for (int j = 0; j < lpmsScript->_moment[i]._nCmds; j++) { + lpmsScript->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmsScript->_command[curCmd].type) { + switch (lpmsScript->_command[curCmd]._type) { case 1: lpmsScript->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -93,13 +93,13 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { case 2: { // Variable assign int len = *lpBuf; lpBuf++; - lpmsScript->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmsScript->_command[curCmd].lpszVarName == NULL) + lpmsScript->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmsScript->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmsScript->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmsScript->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmsScript->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -108,7 +108,7 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { return NULL; } - lpmsScript->Moment[i].CmdNum[j] = curCmd; + lpmsScript->_moment[i]._cmdNum[j] = curCmd; curCmd++; } } @@ -120,12 +120,12 @@ static const byte *ParseScript(const byte *lpBuf, LPMPALSCRIPT lpmsScript) { * * @param lpmsScript Pointer to a script structure */ -static void FreeScript(LPMPALSCRIPT lpmsScript) { - for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i].type); ++i, ++lpmsScript) { - if (lpmsScript->_command[i].type == 2) { +static void FreeScript(LpMpalScript lpmsScript) { + for (int i = 0; i < MAX_COMMANDS_PER_SCRIPT && (lpmsScript->_command[i]._type); ++i, ++lpmsScript) { + if (lpmsScript->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmsScript->_command[i].lpszVarName); - freeExpression(lpmsScript->_command[i].expr); + globalDestroy(lpmsScript->_command[i]._lpszVarName); + freeExpression(lpmsScript->_command[i]._expr); } } } @@ -138,11 +138,11 @@ static void FreeScript(LPMPALSCRIPT lpmsScript) { * data of the dialog. * @returns Pointer to the buffer after the item, or NULL on failure. */ -static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { +static const byte *parseDialog(const byte *lpBuf, LpMpalDialog lpmdDialog) { uint32 num2, num3; byte *lpLock; - lpmdDialog->nObj = READ_LE_UINT32(lpBuf); + lpmdDialog->_nObj = READ_LE_UINT32(lpBuf); lpBuf += 4; // Periods @@ -150,7 +150,7 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { lpBuf += 2; if (num >= MAX_PERIODS_PER_DIALOG - 1) - error("Too much periods in dialog #%d", lpmdDialog->nObj); + error("Too much periods in dialog #%d", lpmdDialog->_nObj); uint32 i; for (i = 0; i < num; i++) { @@ -172,21 +172,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 curCmd = 0; if (num >= MAX_GROUPS_PER_DIALOG) - error("Too much groups in dialog #%d", lpmdDialog->nObj); + error("Too much groups in dialog #%d", lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_group[i].num = READ_LE_UINT16(lpBuf); + lpmdDialog->_group[i]._num = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmdDialog->_group[i].nCmds = *lpBuf; lpBuf++; + lpmdDialog->_group[i]._nCmds = *lpBuf; lpBuf++; - if (lpmdDialog->_group[i].nCmds >= MAX_COMMANDS_PER_GROUP) - error("Too much commands in group #%d in dialog #%d",lpmdDialog->_group[i].num,lpmdDialog->nObj); + if (lpmdDialog->_group[i]._nCmds >= MAX_COMMANDS_PER_GROUP) + error("Too much commands in group #%d in dialog #%d", lpmdDialog->_group[i]._num, lpmdDialog->_nObj); - for (uint32 j = 0; j < lpmdDialog->_group[i].nCmds; j++) { - lpmdDialog->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmdDialog->_group[i]._nCmds; j++) { + lpmdDialog->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmdDialog->_command[curCmd].type) { + switch (lpmdDialog->_command[curCmd]._type) { // Call custom function case 1: lpmdDialog->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); @@ -205,21 +205,21 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { case 2: { uint32 len = *lpBuf; lpBuf++; - lpmdDialog->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmdDialog->_command[curCmd].lpszVarName == NULL) + lpmdDialog->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmdDialog->_command[curCmd]._lpszVarName == NULL) return NULL; - Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd].lpszVarName); + Common::copy(lpBuf, lpBuf + len, lpmdDialog->_command[curCmd]._lpszVarName); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; } // Do Choice case 3: - lpmdDialog->_command[curCmd].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_command[curCmd]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; break; @@ -230,56 +230,56 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { uint32 kk; for (kk = 0;kk < curCmd; kk++) { if (compareCommands(&lpmdDialog->_command[kk], &lpmdDialog->_command[curCmd])) { - lpmdDialog->_group[i].CmdNum[j] = kk; + lpmdDialog->_group[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmdDialog->_command[curCmd].type == 2) { - globalDestroy(lpmdDialog->_command[curCmd].lpszVarName); - freeExpression(lpmdDialog->_command[curCmd].expr); + if (lpmdDialog->_command[curCmd]._type == 2) { + globalDestroy(lpmdDialog->_command[curCmd]._lpszVarName); + freeExpression(lpmdDialog->_command[curCmd]._expr); - lpmdDialog->_command[curCmd].lpszVarName = NULL; - lpmdDialog->_command[curCmd].expr = 0; - lpmdDialog->_command[curCmd].type = 0; + lpmdDialog->_command[curCmd]._lpszVarName = NULL; + lpmdDialog->_command[curCmd]._expr = 0; + lpmdDialog->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmdDialog->_group[i].CmdNum[j] = curCmd; + lpmdDialog->_group[i]._cmdNum[j] = curCmd; curCmd++; } } } if (curCmd >= MAX_COMMANDS_PER_DIALOG) - error("Too much commands in dialog #%d",lpmdDialog->nObj); + error("Too much commands in dialog #%d",lpmdDialog->_nObj); // Choices num = READ_LE_UINT16(lpBuf); lpBuf += 2; if (num >= MAX_CHOICES_PER_DIALOG) - error("Too much choices in dialog #%d",lpmdDialog->nObj); + error("Too much choices in dialog #%d",lpmdDialog->_nObj); for (i = 0; i < num; i++) { - lpmdDialog->_choice[i].nChoice = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._nChoice = READ_LE_UINT16(lpBuf); lpBuf += 2; num2 = *lpBuf++; if (num2 >= MAX_SELECTS_PER_CHOICE) - error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much selects in choice #%d in dialog #%d", lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 j = 0; j < num2; j++) { // When switch (*lpBuf++) { case 0: - lpmdDialog->_choice[i]._select[j].when = NULL; + lpmdDialog->_choice[i]._select[j]._when = NULL; break; case 1: - lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j].when); + lpBuf = parseExpression(lpBuf, &lpmdDialog->_choice[i]._select[j]._when); if (lpBuf == NULL) return NULL; break; @@ -289,31 +289,31 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { } // Attrib - lpmdDialog->_choice[i]._select[j].attr = *lpBuf++; + lpmdDialog->_choice[i]._select[j]._attr = *lpBuf++; // Data - lpmdDialog->_choice[i]._select[j].dwData = READ_LE_UINT32(lpBuf); + lpmdDialog->_choice[i]._select[j]._dwData = READ_LE_UINT32(lpBuf); lpBuf += 4; // PlayGroup num3 = *lpBuf++; if (num3 >= MAX_PLAYGROUPS_PER_SELECT) - error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i].nChoice, lpmdDialog->nObj); + error("Too much playgroups in select #%d in choice #%d in dialog #%d", j, lpmdDialog->_choice[i]._nChoice, lpmdDialog->_nObj); for (uint32 z = 0; z < num3; z++) { - lpmdDialog->_choice[i]._select[j].wPlayGroup[z] = READ_LE_UINT16(lpBuf); + lpmdDialog->_choice[i]._select[j]._wPlayGroup[z] = READ_LE_UINT16(lpBuf); lpBuf += 2; } - lpmdDialog->_choice[i]._select[j].wPlayGroup[num3] = 0; + lpmdDialog->_choice[i]._select[j]._wPlayGroup[num3] = 0; } // Mark the last selection - lpmdDialog->_choice[i]._select[num2].dwData = 0; + lpmdDialog->_choice[i]._select[num2]._dwData = 0; } - lpmdDialog->_choice[num].nChoice = 0; + lpmdDialog->_choice[num]._nChoice = 0; return lpBuf; } @@ -329,63 +329,63 @@ static const byte *parseDialog(const byte *lpBuf, LPMPALDIALOG lpmdDialog) { * @remarks It's necessary that the structure that is passed has been * completely initialized to 0 beforehand. */ -static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { - lpmiItem->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *parseItem(const byte *lpBuf, LpMpalItem lpmiItem) { + lpmiItem->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; byte len = *lpBuf; lpBuf++; - memcpy(lpmiItem->lpszDescribe, lpBuf, MIN((byte)127, len)); + memcpy(lpmiItem->_lpszDescribe, lpBuf, MIN((byte)127, len)); lpBuf += len; if (len >= MAX_DESCRIBE_SIZE) - error("Describe too long in item #%d", lpmiItem->nObj); + error("Describe too long in item #%d", lpmiItem->_nObj); - lpmiItem->nActions=*lpBuf; + lpmiItem->_nActions=*lpBuf; lpBuf++; // Allocation action - if (lpmiItem->nActions > 0) - lpmiItem->Action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->nActions); + if (lpmiItem->_nActions > 0) + lpmiItem->_action = (ItemAction *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(struct ItemAction) * (int)lpmiItem->_nActions); uint32 curCmd = 0; - for (uint32 i = 0; i < lpmiItem->nActions; i++) { - lpmiItem->Action[i].num = *lpBuf; + for (uint32 i = 0; i < lpmiItem->_nActions; i++) { + lpmiItem->_action[i]._num = *lpBuf; lpBuf++; - lpmiItem->Action[i].wParm = READ_LE_UINT16(lpBuf); + lpmiItem->_action[i]._wParm = READ_LE_UINT16(lpBuf); lpBuf += 2; - if (lpmiItem->Action[i].num == 0xFF) { - lpmiItem->Action[i].wTime = READ_LE_UINT16(lpBuf); + if (lpmiItem->_action[i]._num == 0xFF) { + lpmiItem->_action[i]._wTime = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmiItem->Action[i].perc = *lpBuf; + lpmiItem->_action[i]._perc = *lpBuf; lpBuf++; } if (*lpBuf == 0) { lpBuf++; - lpmiItem->Action[i].when = NULL; + lpmiItem->_action[i]._when = NULL; } else { lpBuf++; - lpBuf = parseExpression(lpBuf,&lpmiItem->Action[i].when); + lpBuf = parseExpression(lpBuf,&lpmiItem->_action[i]._when); if (lpBuf == NULL) return NULL; } - lpmiItem->Action[i].nCmds=*lpBuf; + lpmiItem->_action[i]._nCmds=*lpBuf; lpBuf++; - if (lpmiItem->Action[i].nCmds >= MAX_COMMANDS_PER_ACTION) - error("Too much commands in action #%d in item #%d",lpmiItem->Action[i].num,lpmiItem->nObj); + if (lpmiItem->_action[i]._nCmds >= MAX_COMMANDS_PER_ACTION) + error("Too much commands in action #%d in item #%d",lpmiItem->_action[i]._num, lpmiItem->_nObj); - for (uint32 j = 0; j < lpmiItem->Action[i].nCmds; j++) { - lpmiItem->_command[curCmd].type = *lpBuf; + for (uint32 j = 0; j < lpmiItem->_action[i]._nCmds; j++) { + lpmiItem->_command[curCmd]._type = *lpBuf; lpBuf++; - switch (lpmiItem->_command[curCmd].type) { + switch (lpmiItem->_command[curCmd]._type) { case 1: // Call custom function lpmiItem->_command[curCmd]._nCf = READ_LE_UINT16(lpBuf); lpBuf += 2; @@ -402,13 +402,13 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { case 2: // Variable assign len = *lpBuf; lpBuf++; - lpmiItem->_command[curCmd].lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); - if (lpmiItem->_command[curCmd].lpszVarName == NULL) + lpmiItem->_command[curCmd]._lpszVarName = (char *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, len + 1); + if (lpmiItem->_command[curCmd]._lpszVarName == NULL) return NULL; - memcpy(lpmiItem->_command[curCmd].lpszVarName, lpBuf, len); + memcpy(lpmiItem->_command[curCmd]._lpszVarName, lpBuf, len); lpBuf += len; - lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd].expr); + lpBuf = parseExpression(lpBuf, &lpmiItem->_command[curCmd]._expr); if (lpBuf == NULL) return NULL; break; @@ -420,34 +420,34 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { uint32 kk; for (kk = 0; kk < curCmd; kk++) { if (compareCommands(&lpmiItem->_command[kk], &lpmiItem->_command[curCmd])) { - lpmiItem->Action[i].CmdNum[j] = kk; + lpmiItem->_action[i]._cmdNum[j] = kk; // Free any data allocated for the duplictaed command - if (lpmiItem->_command[curCmd].type == 2) { - globalDestroy(lpmiItem->_command[curCmd].lpszVarName); - freeExpression(lpmiItem->_command[curCmd].expr); + if (lpmiItem->_command[curCmd]._type == 2) { + globalDestroy(lpmiItem->_command[curCmd]._lpszVarName); + freeExpression(lpmiItem->_command[curCmd]._expr); - lpmiItem->_command[curCmd].lpszVarName = NULL; - lpmiItem->_command[curCmd].expr = 0; - lpmiItem->_command[curCmd].type = 0; + lpmiItem->_command[curCmd]._lpszVarName = NULL; + lpmiItem->_command[curCmd]._expr = 0; + lpmiItem->_command[curCmd]._type = 0; } break; } } if (kk == curCmd) { - lpmiItem->Action[i].CmdNum[j] = curCmd; + lpmiItem->_action[i]._cmdNum[j] = curCmd; curCmd++; if (curCmd >= MAX_COMMANDS_PER_ITEM) { - error("Too much commands in item #%d",lpmiItem->nObj); + error("Too much commands in item #%d", lpmiItem->_nObj); //curCmd=0; } } } } - lpmiItem->dwRes = READ_LE_UINT32(lpBuf); + lpmiItem->_dwRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -458,23 +458,23 @@ static const byte *parseItem(const byte *lpBuf, LPMPALITEM lpmiItem) { * * @param lpmiItem Pointer to an item structure */ -static void freeItem(LPMPALITEM lpmiItem) { +static void freeItem(LpMpalItem lpmiItem) { // Free the actions - if (lpmiItem->Action) { - for (int i = 0; i < lpmiItem->nActions; ++i) { - if (lpmiItem->Action[i].when != 0) - freeExpression(lpmiItem->Action[i].when); + if (lpmiItem->_action) { + for (int i = 0; i < lpmiItem->_nActions; ++i) { + if (lpmiItem->_action[i]._when != 0) + freeExpression(lpmiItem->_action[i]._when); } - globalDestroy(lpmiItem->Action); + globalDestroy(lpmiItem->_action); } // Free the commands - for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i].type); ++i) { - if (lpmiItem->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_ITEM && (lpmiItem->_command[i]._type); ++i) { + if (lpmiItem->_command[i]._type == 2) { // Variable Assign - globalDestroy(lpmiItem->_command[i].lpszVarName); - freeExpression(lpmiItem->_command[i].expr); + globalDestroy(lpmiItem->_command[i]._lpszVarName); + freeExpression(lpmiItem->_command[i]._expr); } } } @@ -487,14 +487,14 @@ static void freeItem(LPMPALITEM lpmiItem) { * data of the location. * @returns Pointer to the buffer after the location, or NULL on failure. */ -static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) { - lpmlLocation->nObj = (int32)READ_LE_UINT32(lpBuf); +static const byte *ParseLocation(const byte *lpBuf, LpMpalLocation lpmlLocation) { + lpmlLocation->_nObj = (int32)READ_LE_UINT32(lpBuf); lpBuf += 4; - lpmlLocation->dwXlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwXlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwYlen = READ_LE_UINT16(lpBuf); + lpmlLocation->_dwYlen = READ_LE_UINT16(lpBuf); lpBuf += 2; - lpmlLocation->dwPicRes = READ_LE_UINT32(lpBuf); + lpmlLocation->_dwPicRes = READ_LE_UINT32(lpBuf); lpBuf += 4; return lpBuf; @@ -516,7 +516,7 @@ static const byte *ParseLocation(const byte *lpBuf, LPMPALLOCATION lpmlLocation) * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf) { +bool parseMpc(const byte *lpBuf) { byte *lpTemp; // 1. Variables @@ -527,18 +527,18 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nVars = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALVAR) * (uint32)GLOBALS._nVars); + GLOBALS._hVars = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalVar) * (uint32)GLOBALS._nVars); if (GLOBALS._hVars == NULL) return false; - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); for (uint16 i = 0; i < GLOBALS._nVars; i++) { uint16 wLen = *(const byte *)lpBuf; lpBuf++; - memcpy(GLOBALS._lpmvVars->lpszVarName, lpBuf, MIN(wLen, (uint16)32)); + memcpy(GLOBALS._lpmvVars->_lpszVarName, lpBuf, MIN(wLen, (uint16)32)); lpBuf += wLen; - GLOBALS._lpmvVars->dwVal = READ_LE_UINT32(lpBuf); + GLOBALS._lpmvVars->_dwVal = READ_LE_UINT32(lpBuf); lpBuf += 4; lpBuf++; // Skip 'ext' @@ -556,11 +556,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; #ifdef NEED_LOCK_MSGS - GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); + GLOBALS._hMsgs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(MpalMsg) * (uint32)GLOBALS._nMsgs); if (GLOBALS._hMsgs == NULL) return false; - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #else GLOBALS._lpmmMsgs=(LPMPALMSG)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALMSG) * (uint32)GLOBALS._nMsgs); if (GLOBALS._lpmmMsgs==NULL) @@ -611,11 +611,11 @@ bool ParseMpc(const byte *lpBuf) { GLOBALS._nDialogs = READ_LE_UINT16(lpBuf); lpBuf += 2; - GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MPALDIALOG)); + GLOBALS._hDialogs = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nDialogs * sizeof(MpalDialog)); if (GLOBALS._hDialogs == NULL) return false; - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (uint16 i = 0; i < GLOBALS._nDialogs; i++) { if ((lpBuf = parseDialog(lpBuf + 7, &GLOBALS._lpmdDialogs[i])) == NULL) @@ -633,11 +633,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MPALITEM)); + GLOBALS._hItems = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nItems * sizeof(MpalItem)); if (GLOBALS._hItems == NULL) return false; - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (uint16 i = 0; i < GLOBALS._nItems; i++) { if ((lpBuf = parseItem(lpBuf + 5, &GLOBALS._lpmiItems[i])) == NULL) @@ -655,11 +655,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory and read them in - GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MPALLOCATION)); + GLOBALS._hLocations = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nLocations * sizeof(MpalLocation)); if (GLOBALS._hLocations == NULL) return false; - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); for (uint16 i = 0; i < GLOBALS._nLocations; i++) { if ((lpBuf = ParseLocation(lpBuf + 9, &GLOBALS._lpmlLocations[i])) == NULL) @@ -677,11 +677,11 @@ bool ParseMpc(const byte *lpBuf) { lpBuf += 2; // Allocate memory - GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MPALSCRIPT)); + GLOBALS._hScripts = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, (uint32)GLOBALS._nScripts * sizeof(MpalScript)); if (GLOBALS._hScripts == NULL) return false; - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (uint16 i = 0; i < GLOBALS._nScripts; i++) { if ((lpBuf = ParseScript(lpBuf + 7, &GLOBALS._lpmsScripts[i])) == NULL) @@ -708,24 +708,24 @@ bool ParseMpc(const byte *lpBuf) { /** * Free the given dialog */ -static void freeDialog(LPMPALDIALOG lpmdDialog) { +static void freeDialog(LpMpalDialog lpmdDialog) { // Free the periods for (int i = 0; i < MAX_PERIODS_PER_DIALOG && (lpmdDialog->_periods[i]); ++i) globalFree(lpmdDialog->_periods[i]); - for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i].type); i++) { - if (lpmdDialog->_command[i].type == 2) { + for (int i = 0; i < MAX_COMMANDS_PER_DIALOG && (lpmdDialog->_command[i]._type); i++) { + if (lpmdDialog->_command[i]._type == 2) { // Variable assign - globalDestroy(lpmdDialog->_command[i].lpszVarName); - freeExpression(lpmdDialog->_command[i].expr); + globalDestroy(lpmdDialog->_command[i]._lpszVarName); + freeExpression(lpmdDialog->_command[i]._expr); } } // Free the choices for (int i = 0; i < MAX_CHOICES_PER_DIALOG; ++i) { for (int j = 0; j < MAX_SELECTS_PER_CHOICE; j++) { - if (lpmdDialog->_choice[i]._select[j].when) - freeExpression(lpmdDialog->_choice[i]._select[j].when); + if (lpmdDialog->_choice[i]._select[j]._when) + freeExpression(lpmdDialog->_choice[i]._select[j]._when); } } } @@ -733,12 +733,12 @@ static void freeDialog(LPMPALDIALOG lpmdDialog) { /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc() { +void freeMpc() { // Free variables globalFree(GLOBALS._hVars); // Free messages - LPMPALMSG lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + LpMpalMsg lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); for (int i = 0; i < GLOBALS._nMsgs; i++, ++lpmmMsgs) globalFree(lpmmMsgs->_hText); @@ -747,7 +747,7 @@ void FreeMpc() { // Free objects if (GLOBALS._hDialogs) { - LPMPALDIALOG lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + LpMpalDialog lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); for (int i = 0; i < GLOBALS._nDialogs; i++, ++lpmdDialogs) freeDialog(lpmdDialogs); @@ -757,7 +757,7 @@ void FreeMpc() { // Free items if (GLOBALS._hItems) { - LPMPALITEM lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + LpMpalItem lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); for (int i = 0; i < GLOBALS._nItems; ++i, ++lpmiItems) freeItem(lpmiItems); @@ -773,7 +773,7 @@ void FreeMpc() { // Free the scripts if (GLOBALS._hScripts) { - LPMPALSCRIPT lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + LpMpalScript lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); for (int i = 0; i < GLOBALS._nScripts; ++i, ++lpmsScripts) { FreeScript(lpmsScripts); diff --git a/engines/tony/mpal/loadmpc.h b/engines/tony/mpal/loadmpc.h index c0e2ca7fb5..20956288aa 100644 --- a/engines/tony/mpal/loadmpc.h +++ b/engines/tony/mpal/loadmpc.h @@ -44,12 +44,12 @@ namespace MPAL { * @param lpBuf Buffer containing the MPC file data, excluding the header. * @returns True if succeeded OK, false if failure. */ -bool ParseMpc(const byte *lpBuf); +bool parseMpc(const byte *lpBuf); /** * Frees any data allocated from the parsing of the MPC file */ -void FreeMpc(); +void freeMpc(); } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp index 514001eda7..9a92fd7766 100644 --- a/engines/tony/mpal/mpal.cpp +++ b/engines/tony/mpal/mpal.cpp @@ -60,7 +60,7 @@ const char *mpalCopyright = * Locks the variables for access */ void lockVar() { - GLOBALS._lpmvVars = (LPMPALVAR)globalLock(GLOBALS._hVars); + GLOBALS._lpmvVars = (LpMpalVar)globalLock(GLOBALS._hVars); } /** @@ -75,7 +75,7 @@ void unlockVar() { */ static void LockMsg() { #ifdef NEED_LOCK_MSGS - GLOBALS._lpmmMsgs = (LPMPALMSG)globalLock(GLOBALS._hMsgs); + GLOBALS._lpmmMsgs = (LpMpalMsg)globalLock(GLOBALS._hMsgs); #endif } @@ -92,7 +92,7 @@ static void UnlockMsg() { * Locks the dialogs for access */ static void lockDialogs() { - GLOBALS._lpmdDialogs = (LPMPALDIALOG)globalLock(GLOBALS._hDialogs); + GLOBALS._lpmdDialogs = (LpMpalDialog)globalLock(GLOBALS._hDialogs); } /** @@ -106,7 +106,7 @@ static void unlockDialogs() { * Locks the location data structures for access */ static void lockLocations() { - GLOBALS._lpmlLocations = (LPMPALLOCATION)globalLock(GLOBALS._hLocations); + GLOBALS._lpmlLocations = (LpMpalLocation)globalLock(GLOBALS._hLocations); } /** @@ -120,7 +120,7 @@ static void unlockLocations() { * Locks the items structures for use */ static void lockItems() { - GLOBALS._lpmiItems = (LPMPALITEM)globalLock(GLOBALS._hItems); + GLOBALS._lpmiItems = (LpMpalItem)globalLock(GLOBALS._hItems); } /** @@ -134,7 +134,7 @@ static void unlockItems() { * Locks the script data structures for use */ static void LockScripts() { - GLOBALS._lpmsScripts = (LPMPALSCRIPT)globalLock(GLOBALS._hScripts); + GLOBALS._lpmsScripts = (LpMpalScript)globalLock(GLOBALS._hScripts); } /** @@ -154,11 +154,11 @@ static void unlockScripts() { * need to remember to call UnlockVar() */ int32 varGetValue(const char *lpszVarName) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (int i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) - return v->dwVal; + if (strcmp(lpszVarName, v->_lpszVarName) == 0) + return v->_dwVal; GLOBALS._mpalError = 1; return 0; @@ -170,18 +170,18 @@ int32 varGetValue(const char *lpszVarName) { * @param val Value to set */ void varSetValue(const char *lpszVarName, int32 val) { - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; for (uint i = 0; i < GLOBALS._nVars; v++, i++) - if (strcmp(lpszVarName, v->lpszVarName) == 0) { - v->dwVal = val; - if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Pattern.", 8) == 0) { + if (strcmp(lpszVarName, v->_lpszVarName) == 0) { + v->_dwVal = val; + if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Pattern.", 8) == 0) { i = 0; - sscanf(v->lpszVarName, "Pattern.%u", &i); + sscanf(v->_lpszVarName, "Pattern.%u", &i); GLOBALS._lpiifCustom(i, val, -1); - } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->lpszVarName, "Status.", 7) == 0) { + } else if (GLOBALS._lpiifCustom != NULL && strncmp(v->_lpszVarName, "Status.", 7) == 0) { i = 0; - sscanf(v->lpszVarName,"Status.%u", &i); + sscanf(v->_lpszVarName,"Status.%u", &i); GLOBALS._lpiifCustom(i, -1, val); } return; @@ -200,10 +200,10 @@ void varSetValue(const char *lpszVarName, int32 val) { * first been locked with a call to LockLoc(). */ static int locGetOrderFromNum(uint32 nLoc) { - LPMPALLOCATION loc = GLOBALS._lpmlLocations; + LpMpalLocation loc = GLOBALS._lpmlLocations; for (int i = 0; i < GLOBALS._nLocations; i++, loc++) - if (loc->nObj == nLoc) + if (loc->_nObj == nLoc) return i; return -1; @@ -218,7 +218,7 @@ static int locGetOrderFromNum(uint32 nLoc) { * first been locked with a call to LockMsg() */ static int msgGetOrderFromNum(uint32 nMsg) { - LPMPALMSG msg = GLOBALS._lpmmMsgs; + LpMpalMsg msg = GLOBALS._lpmmMsgs; for (int i = 0; i < GLOBALS._nMsgs; i++, msg++) { if (msg->_wNum == nMsg) @@ -236,10 +236,10 @@ static int msgGetOrderFromNum(uint32 nMsg) { * first been locked with a call to LockItems() */ static int itemGetOrderFromNum(uint32 nItem) { - LPMPALITEM item = GLOBALS._lpmiItems; + LpMpalItem item = GLOBALS._lpmiItems; for (int i = 0; i < GLOBALS._nItems; i++, item++) { - if (item->nObj == nItem) + if (item->_nObj == nItem) return i; } @@ -255,10 +255,10 @@ static int itemGetOrderFromNum(uint32 nItem) { * first been locked with a call to LockScripts() */ static int scriptGetOrderFromNum(uint32 nScript) { - LPMPALSCRIPT script = GLOBALS._lpmsScripts; + LpMpalScript script = GLOBALS._lpmsScripts; for (int i = 0; i < GLOBALS._nScripts; i++, script++) { - if (script->nObj == nScript) + if (script->_nObj == nScript) return i; } @@ -274,10 +274,10 @@ static int scriptGetOrderFromNum(uint32 nScript) { * first been locked with a call to LockDialogs() */ static int dialogGetOrderFromNum(uint32 nDialog) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs; + LpMpalDialog dialog = GLOBALS._lpmdDialogs; for (int i = 0; i < GLOBALS._nDialogs; i++, dialog++) { - if (dialog->nObj == nDialog) + if (dialog->_nObj == nDialog) return i; } @@ -326,7 +326,7 @@ static char *DuplicateMessage(uint32 nMsgOrd) { static char *duplicateDialogPeriod(uint32 nPeriod) { const char *origmsg; char *clonemsg; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; for (int j = 0; dialog->_periods[j] != NULL; j++) { if (dialog->_periodNums[j] == nPeriod) { @@ -386,7 +386,7 @@ HGLOBAL resLoad(uint32 dwId) { h = globalAllocate(GMEM_MOVEABLE | GMEM_ZEROINIT, nSizeDecomp + (nSizeDecomp / 1024) * 16); buf = (byte *)globalLock(h); - temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT,nSizeComp); + temp = (byte *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, nSizeComp); nBytesRead = GLOBALS._hMpr.read(temp, nSizeComp); if (nBytesRead != nSizeComp) @@ -406,12 +406,12 @@ HGLOBAL resLoad(uint32 dwId) { static uint32 *getSelectList(uint32 i) { uint32 *sl; - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Count how many are active selects int num = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) num++; } @@ -425,9 +425,9 @@ static uint32 *getSelectList(uint32 i) { // Copy all the data inside the active select list int k = 0; - for (int j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].curActive) - sl[k++] = dialog->_choice[i]._select[j].dwData; + for (int j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._curActive) + sl[k++] = dialog->_choice[i]._select[j]._dwData; } sl[k] = (uint32)NULL; @@ -436,11 +436,11 @@ static uint32 *getSelectList(uint32 i) { static uint32 *GetItemList(uint32 nLoc) { uint32 *il; - LPMPALVAR v = GLOBALS._lpmvVars; + LpMpalVar v = GLOBALS._lpmvVars; uint32 num = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName,"Location",8) == 0 && v->dwVal == nLoc) + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) num++; } @@ -451,8 +451,8 @@ static uint32 *GetItemList(uint32 nLoc) { v = GLOBALS._lpmvVars; uint32 j = 0; for (uint32 i = 0; i < GLOBALS._nVars; i++, v++) { - if (strncmp(v->lpszVarName, "Location", 8) == 0 && v->dwVal == nLoc) { - sscanf(v->lpszVarName, "Location.%u", &il[j]); + if (strncmp(v->_lpszVarName, "Location", 8) == 0 && v->_dwVal == nLoc) { + sscanf(v->_lpszVarName, "Location.%u", &il[j]); j++; } } @@ -462,7 +462,7 @@ static uint32 *GetItemList(uint32 nLoc) { } static LPITEM getItemData(uint32 nOrdItem) { - LPMPALITEM curitem = GLOBALS._lpmiItems + nOrdItem; + LpMpalItem curitem = GLOBALS._lpmiItems + nOrdItem; LPITEM ret; HGLOBAL hDat; char *dat; @@ -474,7 +474,7 @@ static LPITEM getItemData(uint32 nOrdItem) { return NULL; ret->_speed = 150; - hDat = resLoad(curitem->dwRes); + hDat = resLoad(curitem->_dwRes); dat = (char *)globalLock(hDat); if (dat[0] == 'D' && dat[1] == 'A' && dat[2] == 'T') { @@ -597,7 +597,7 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_END_CONTEXT(_ctx); static uint32 cfHandles[MAX_COMMANDS_PER_MOMENT]; - LPMPALSCRIPT s = *(const LPMPALSCRIPT *)param; + LpMpalScript s = *(const LpMpalScript *)param; CORO_BEGIN_CODE(_ctx); @@ -605,24 +605,24 @@ void ScriptThread(CORO_PARAM, const void *param) { _ctx->numHandles = 0; // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Moments: %u\n",s->nMoments); - for (_ctx->i = 0; _ctx->i < s->nMoments; _ctx->i++) { + for (_ctx->i = 0; _ctx->i < s->_nMoments; _ctx->i++) { // Sleep for the required time - if (s->Moment[_ctx->i].dwTime == -1) { + if (s->_moment[_ctx->i]._dwTime == -1) { CORO_INVOKE_4(CoroScheduler.waitForMultipleObjects, _ctx->numHandles, cfHandles, true, CORO_INFINITE); _ctx->dwStartTime = g_vm->getTime(); } else { _ctx->dwCurTime = g_vm->getTime(); - if (_ctx->dwCurTime < _ctx->dwStartTime + (s->Moment[_ctx->i].dwTime * 100)) { + if (_ctx->dwCurTime < _ctx->dwStartTime + (s->_moment[_ctx->i]._dwTime * 100)) { // debugC(DEBUG_BASIC, kTonyDebugMPAL, "PlayScript(): Sleeping %lums\n",_ctx->dwStartTime+(s->Moment[_ctx->i].dwTime*100)-_ctx->dwCurTime); - CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->Moment[_ctx->i].dwTime * 100) - _ctx->dwCurTime); + CORO_INVOKE_1(CoroScheduler.sleep, _ctx->dwStartTime+(s->_moment[_ctx->i]._dwTime * 100) - _ctx->dwCurTime); } } _ctx->numHandles = 0; - for (_ctx->j = 0; _ctx->j < s->Moment[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = s->Moment[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < s->_moment[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = s->_moment[_ctx->i]._cmdNum[_ctx->j]; - if (s->_command[_ctx->k].type == 1) { + if (s->_command[_ctx->k]._type == 1) { _ctx->p = (LPCFCALL)globalAlloc(GMEM_FIXED, sizeof(CFCALL)); if (_ctx->p == NULL) { GLOBALS._mpalError = 1; @@ -644,11 +644,11 @@ void ScriptThread(CORO_PARAM, const void *param) { CORO_KILL_SELF(); return; } - } else if (s->_command[_ctx->k].type == 2) { + } else if (s->_command[_ctx->k]._type == 2) { lockVar(); varSetValue( - s->_command[_ctx->k].lpszVarName, - evaluateExpression(s->_command[_ctx->k].expr) + s->_command[_ctx->k]._lpszVarName, + evaluateExpression(s->_command[_ctx->k]._expr) ); unlockVar(); @@ -681,7 +681,7 @@ void ActionThread(CORO_PARAM, const void *param) { // COROUTINE CORO_BEGIN_CONTEXT; int j, k; - LPMPALITEM item; + LpMpalItem item; ~CoroContextTag() { if (item) @@ -693,13 +693,13 @@ void ActionThread(CORO_PARAM, const void *param) { // The ActionThread owns the data block pointed to, so we need to make sure it's // freed when the process exits - _ctx->item = *(LPMPALITEM *)param; + _ctx->item = *(LpMpalItem *)param; GLOBALS._mpalError = 0; - for (_ctx->j = 0; _ctx->j < _ctx->item->Action[_ctx->item->dwRes].nCmds; _ctx->j++) { - _ctx->k = _ctx->item->Action[_ctx->item->dwRes].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->item->_action[_ctx->item->_dwRes]._nCmds; _ctx->j++) { + _ctx->k = _ctx->item->_action[_ctx->item->_dwRes]._cmdNum[_ctx->j]; - if (_ctx->item->_command[_ctx->k].type == 1) { + if (_ctx->item->_command[_ctx->k]._type == 1) { // Custom function debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Call=%s params=%d,%d,%d,%d", CoroScheduler.getCurrentPID(), GLOBALS._lplpFunctionStrings[_ctx->item->_command[_ctx->k]._nCf].c_str(), @@ -714,13 +714,13 @@ void ActionThread(CORO_PARAM, const void *param) { _ctx->item->_command[_ctx->k]._arg4 ); - } else if (_ctx->item->_command[_ctx->k].type == 2) { + } else if (_ctx->item->_command[_ctx->k]._type == 2) { // Variable assign debugC(DEBUG_DETAILED, kTonyDebugActions, "Action Process %d Variable=%s", - CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k].lpszVarName); + CoroScheduler.getCurrentPID(), _ctx->item->_command[_ctx->k]._lpszVarName); lockVar(); - varSetValue(_ctx->item->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k].expr)); + varSetValue(_ctx->item->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->item->_command[_ctx->k]._expr)); unlockVar(); } else { @@ -775,20 +775,19 @@ void ShutUpActionThread(CORO_PARAM, const void *param) { */ void LocationPollThread(CORO_PARAM, const void *param) { typedef struct { - uint32 nItem, nAction; - - uint16 wTime; - byte perc; - HGLOBAL when; - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_ACTION]; - - uint32 dwLastTime; + uint32 _nItem, _nAction; + + uint16 _wTime; + byte _perc; + HGLOBAL _when; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_ACTION]; + uint32 _dwLastTime; } MYACTION; typedef struct { - uint32 nItem; - uint32 hThread; + uint32 _nItem; + uint32 _hThread; } MYTHREAD; CORO_BEGIN_CONTEXT; @@ -796,7 +795,7 @@ void LocationPollThread(CORO_PARAM, const void *param) { int i, j, k; int numitems; int nRealItems; - LPMPALITEM curItem,newItem; + LpMpalItem curItem,newItem; int nIdleActions; uint32 curTime; uint32 dwSleepTime; @@ -805,15 +804,15 @@ void LocationPollThread(CORO_PARAM, const void *param) { bool delayExpired; bool expired; - MYACTION *MyActions; - MYTHREAD *MyThreads; + MYACTION *myActions; + MYTHREAD *myThreads; ~CoroContextTag() { // Free data blocks - if (MyThreads) - globalDestroy(MyThreads); - if (MyActions) - globalDestroy(MyActions); + if (myThreads) + globalDestroy(myThreads); + if (myActions) + globalDestroy(myActions); } CORO_END_CONTEXT(_ctx); @@ -822,8 +821,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_BEGIN_CODE(_ctx); // Initialize data pointers - _ctx->MyActions = NULL; - _ctx->MyThreads = NULL; + _ctx->myActions = NULL; + _ctx->myThreads = NULL; // To begin with, we need to request the item list from the location _ctx->il = mpalQueryItemList(GLOBALS._nPollingLocations[id]); @@ -845,8 +844,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + _ctx->ord; _ctx->k = 0; - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) _ctx->k++; } @@ -867,8 +866,8 @@ void LocationPollThread(CORO_PARAM, const void *param) { return; } - _ctx->MyThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); - if (_ctx->MyThreads == NULL) { + _ctx->myThreads = (MYTHREAD *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nRealItems * sizeof(MYTHREAD)); + if (_ctx->myThreads == NULL) { globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -877,9 +876,9 @@ void LocationPollThread(CORO_PARAM, const void *param) { // We have established that there is at least one item that contains idle actions. // Now we created the mirrored copies of the idle actions. - _ctx->MyActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); - if (_ctx->MyActions == NULL) { - globalDestroy(_ctx->MyThreads); + _ctx->myActions = (MYACTION *)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, _ctx->nIdleActions * sizeof(MYACTION)); + if (_ctx->myActions == NULL) { + globalDestroy(_ctx->myThreads); globalDestroy(_ctx->il); CORO_KILL_SELF(); return; @@ -894,19 +893,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->il[_ctx->i]); - for (_ctx->j = 0; _ctx->j < _ctx->curItem->nActions; _ctx->j++) { - if (_ctx->curItem->Action[_ctx->j].num == 0xFF) { - _ctx->MyActions[_ctx->k].nItem = _ctx->il[_ctx->i]; - _ctx->MyActions[_ctx->k].nAction = _ctx->j; + for (_ctx->j = 0; _ctx->j < _ctx->curItem->_nActions; _ctx->j++) { + if (_ctx->curItem->_action[_ctx->j]._num == 0xFF) { + _ctx->myActions[_ctx->k]._nItem = _ctx->il[_ctx->i]; + _ctx->myActions[_ctx->k]._nAction = _ctx->j; - _ctx->MyActions[_ctx->k].wTime = _ctx->curItem->Action[_ctx->j].wTime; - _ctx->MyActions[_ctx->k].perc = _ctx->curItem->Action[_ctx->j].perc; - _ctx->MyActions[_ctx->k].when = _ctx->curItem->Action[_ctx->j].when; - _ctx->MyActions[_ctx->k].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; - memcpy(_ctx->MyActions[_ctx->k].CmdNum, _ctx->curItem->Action[_ctx->j].CmdNum, + _ctx->myActions[_ctx->k]._wTime = _ctx->curItem->_action[_ctx->j]._wTime; + _ctx->myActions[_ctx->k]._perc = _ctx->curItem->_action[_ctx->j]._perc; + _ctx->myActions[_ctx->k]._when = _ctx->curItem->_action[_ctx->j]._when; + _ctx->myActions[_ctx->k]._nCmds = _ctx->curItem->_action[_ctx->j]._nCmds; + memcpy(_ctx->myActions[_ctx->k]._cmdNum, _ctx->curItem->_action[_ctx->j]._cmdNum, MAX_COMMANDS_PER_ACTION * sizeof(uint16)); - _ctx->MyActions[_ctx->k].dwLastTime = g_vm->getTime(); + _ctx->myActions[_ctx->k]._dwLastTime = g_vm->getTime(); _ctx->k++; } } @@ -925,11 +924,11 @@ void LocationPollThread(CORO_PARAM, const void *param) { _ctx->dwSleepTime = (uint32)-1L; for (_ctx->k = 0;_ctx->k<_ctx->nIdleActions;_ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { _ctx->dwSleepTime = 0; break; } else - _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime - _ctx->curTime); + _ctx->dwSleepTime = MIN(_ctx->dwSleepTime, _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime - _ctx->curTime); } // We fall alseep, but always checking that the event is set when prompted for closure @@ -940,12 +939,12 @@ void LocationPollThread(CORO_PARAM, const void *param) { break; for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 0, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 0, &_ctx->delayExpired); // if result == WAIT_OBJECT_0) if (!_ctx->delayExpired) - _ctx->MyThreads[_ctx->i].nItem = 0; + _ctx->myThreads[_ctx->i]._nItem = 0; } } @@ -953,19 +952,19 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Loop through all the necessary idle actions for (_ctx->k = 0; _ctx->k < _ctx->nIdleActions; _ctx->k++) { - if (_ctx->curTime >= _ctx->MyActions[_ctx->k].dwLastTime + _ctx->MyActions[_ctx->k].wTime) { - _ctx->MyActions[_ctx->k].dwLastTime += _ctx->MyActions[_ctx->k].wTime; + if (_ctx->curTime >= _ctx->myActions[_ctx->k]._dwLastTime + _ctx->myActions[_ctx->k]._wTime) { + _ctx->myActions[_ctx->k]._dwLastTime += _ctx->myActions[_ctx->k]._wTime; // It's time to check to see if fortune is on the side of the idle action byte randomVal = (byte)g_vm->_randomSource.getRandomNumber(99); - if (randomVal < _ctx->MyActions[_ctx->k].perc) { + if (randomVal < _ctx->myActions[_ctx->k]._perc) { // Check if there is an action running on the item - if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->MyActions[_ctx->k].nItem)) + if ((GLOBALS._bExecutingAction) && (GLOBALS._nExecutingAction == _ctx->myActions[_ctx->k]._nItem)) continue; // Check to see if there already another idle funning running on the item for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == _ctx->MyActions[_ctx->k].nItem) + if (_ctx->myThreads[_ctx->i]._nItem == _ctx->myActions[_ctx->k]._nItem) break; } @@ -974,49 +973,49 @@ void LocationPollThread(CORO_PARAM, const void *param) { // Ok, we are the only ones :) lockItems(); - _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->MyActions[_ctx->k].nItem); + _ctx->curItem = GLOBALS._lpmiItems + itemGetOrderFromNum(_ctx->myActions[_ctx->k]._nItem); // Check if there is a WhenExecute expression - _ctx->j=_ctx->MyActions[_ctx->k].nAction; - if (_ctx->curItem->Action[_ctx->j].when != NULL) { - if (!evaluateExpression(_ctx->curItem->Action[_ctx->j].when)) { + _ctx->j=_ctx->myActions[_ctx->k]._nAction; + if (_ctx->curItem->_action[_ctx->j]._when != NULL) { + if (!evaluateExpression(_ctx->curItem->_action[_ctx->j]._when)) { unlockItems(); continue; } } // Ok, we can perform the action. For convenience, we do it in a new process - _ctx->newItem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + _ctx->newItem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (_ctx->newItem == false) { - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; } - memcpy(_ctx->newItem,_ctx->curItem, sizeof(MPALITEM)); + memcpy(_ctx->newItem,_ctx->curItem, sizeof(MpalItem)); unlockItems(); // We copy the action in #0 //_ctx->newItem->Action[0].nCmds = _ctx->curItem->Action[_ctx->j].nCmds; //memcpy(_ctx->newItem->Action[0].CmdNum,_ctx->curItem->Action[_ctx->j].CmdNum,_ctx->newItem->Action[0].nCmds*sizeof(_ctx->newItem->Action[0].CmdNum[0])); - _ctx->newItem->dwRes=_ctx->j; + _ctx->newItem->_dwRes = _ctx->j; // We will create an action, and will provide the necessary details for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem == 0) + if (_ctx->myThreads[_ctx->i]._nItem == 0) break; } - _ctx->MyThreads[_ctx->i].nItem = _ctx->MyActions[_ctx->k].nItem; + _ctx->myThreads[_ctx->i]._nItem = _ctx->myActions[_ctx->k]._nItem; // Create the process - if ((_ctx->MyThreads[_ctx->i].hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) { - //if ((_ctx->MyThreads[_ctx->i].hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem))= = (void*)-1) + if ((_ctx->myThreads[_ctx->i]._hThread = CoroScheduler.createProcess(ActionThread, &_ctx->newItem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) { + //if ((_ctx->myThreads[_ctx->i]._hThread = (void*)_beginthread(ActionThread, 10240,(void *)_ctx->newItem)) == (void*)-1) globalDestroy(_ctx->newItem); - globalDestroy(_ctx->MyThreads); - globalDestroy(_ctx->MyActions); + globalDestroy(_ctx->myThreads); + globalDestroy(_ctx->myActions); CORO_KILL_SELF(); return; @@ -1033,14 +1032,14 @@ void LocationPollThread(CORO_PARAM, const void *param) { CORO_INVOKE_4(GLOBALS._lplpFunctions[200], 0, 0, 0, 0); for (_ctx->i = 0; _ctx->i < _ctx->nRealItems; _ctx->i++) { - if (_ctx->MyThreads[_ctx->i].nItem != 0) { - CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->MyThreads[_ctx->i].hThread, 5000, &_ctx->delayExpired); + if (_ctx->myThreads[_ctx->i]._nItem != 0) { + CORO_INVOKE_3(CoroScheduler.waitForSingleObject, _ctx->myThreads[_ctx->i]._hThread, 5000, &_ctx->delayExpired); //if (result != WAIT_OBJECT_0) //if (_ctx->delayExpired) // TerminateThread(_ctx->MyThreads[_ctx->i].hThread, 0); - CoroScheduler.killMatchingProcess(_ctx->MyThreads[_ctx->i].hThread); + CoroScheduler.killMatchingProcess(_ctx->myThreads[_ctx->i]._hThread); } } @@ -1090,7 +1089,7 @@ void doChoice(CORO_PARAM, uint32 nChoice); */ void GroupThread(CORO_PARAM, const void *param) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; int type; CORO_END_CONTEXT(_ctx); @@ -1106,13 +1105,13 @@ void GroupThread(CORO_PARAM, const void *param) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search inside the group requesting the _ctx->dialog - for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i].num != 0; _ctx->i++) { - if (_ctx->dialog->_group[_ctx->i].num == nGroup) { + for (_ctx->i = 0; _ctx->dialog->_group[_ctx->i]._num != 0; _ctx->i++) { + if (_ctx->dialog->_group[_ctx->i]._num == nGroup) { // Cycle through executing the commands of the group - for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i].nCmds; _ctx->j++) { - _ctx->k = _ctx->dialog->_group[_ctx->i].CmdNum[_ctx->j]; + for (_ctx->j = 0; _ctx->j < _ctx->dialog->_group[_ctx->i]._nCmds; _ctx->j++) { + _ctx->k = _ctx->dialog->_group[_ctx->i]._cmdNum[_ctx->j]; - _ctx->type = _ctx->dialog->_command[_ctx->k].type; + _ctx->type = _ctx->dialog->_command[_ctx->k]._type; if (_ctx->type == 1) { // Call custom function CORO_INVOKE_4(GLOBALS._lplpFunctions[_ctx->dialog->_command[_ctx->k]._nCf], @@ -1125,12 +1124,12 @@ void GroupThread(CORO_PARAM, const void *param) { } else if (_ctx->type == 2) { // Set a variable lockVar(); - varSetValue(_ctx->dialog->_command[_ctx->k].lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k].expr)); + varSetValue(_ctx->dialog->_command[_ctx->k]._lpszVarName, evaluateExpression(_ctx->dialog->_command[_ctx->k]._expr)); unlockVar(); } else if (_ctx->type == 3) { // DoChoice: call the chosen function - CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k].nChoice); + CORO_INVOKE_1(doChoice, (uint32)_ctx->dialog->_command[_ctx->k]._nChoice); } else { GLOBALS._mpalError = 1; @@ -1166,7 +1165,7 @@ void GroupThread(CORO_PARAM, const void *param) { */ void doChoice(CORO_PARAM, uint32 nChoice) { CORO_BEGIN_CONTEXT; - LPMPALDIALOG dialog; + LpMpalDialog dialog; int i, j, k; uint32 nGroup; CORO_END_CONTEXT(_ctx); @@ -1180,13 +1179,13 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; // Search the choice between those required in the dialog - for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i].nChoice != 0; _ctx->i++) { - if (_ctx->dialog->_choice[_ctx->i].nChoice == nChoice) + for (_ctx->i = 0; _ctx->dialog->_choice[_ctx->i]._nChoice != 0; _ctx->i++) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == nChoice) break; } // If nothing has been found, exit with an error - if (_ctx->dialog->_choice[_ctx->i].nChoice == 0) { + if (_ctx->dialog->_choice[_ctx->i]._nChoice == 0) { // If we're here, we did not find the required choice GLOBALS._mpalError = 1; unlockDialogs(); @@ -1203,15 +1202,15 @@ void doChoice(CORO_PARAM, uint32 nChoice) { _ctx->k = 0; // Calculate the expression of each selection, to see if they're active or inactive - for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].dwData != 0; _ctx->j++) { - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when == NULL) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + for (_ctx->j = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._dwData != 0; _ctx->j++) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when == NULL) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; - } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].when)) { - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 1; + } else if (evaluateExpression(_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._when)) { + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 1; _ctx->k++; } else - _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].curActive = 0; + _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._curActive = 0; } // If there are no choices activated, then the dialog is finished. @@ -1227,19 +1226,19 @@ void doChoice(CORO_PARAM, uint32 nChoice) { // Now that the choice has been made, we can run the groups associated with the choice tbontbtitq _ctx->j = GLOBALS._nSelectedChoice; - for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k] != 0; _ctx->k++) { - _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j].wPlayGroup[_ctx->k]; + for (_ctx->k = 0; _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k] != 0; _ctx->k++) { + _ctx->nGroup = _ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._wPlayGroup[_ctx->k]; CORO_INVOKE_1(GroupThread, &_ctx->nGroup); } // Control attribute - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 0)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 0)) { // Bit 0 set: the end of the choice unlockDialogs(); break; } - if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j].attr & (1 << 1)) { + if (_ctx->dialog->_choice[_ctx->i]._select[_ctx->j]._attr & (1 << 1)) { // Bit 1 set: the end of the dialog unlockDialogs(); @@ -1270,52 +1269,52 @@ void doChoice(CORO_PARAM, uint32 nChoice) { * by calling LockItem(). */ static uint32 doAction(uint32 nAction, uint32 ordItem, uint32 dwParam) { - LPMPALITEM item = GLOBALS._lpmiItems; - LPMPALITEM newitem; + LpMpalItem item = GLOBALS._lpmiItems; + LpMpalItem newitem; item+=ordItem; - Common::String buf = Common::String::format("Status.%u", item->nObj); + Common::String buf = Common::String::format("Status.%u", item->_nObj); if (varGetValue(buf.c_str()) <= 0) return CORO_INVALID_PID_VALUE; - for (int i = 0; i < item->nActions; i++) { - if (item->Action[i].num != nAction) + for (int i = 0; i < item->_nActions; i++) { + if (item->_action[i]._num != nAction) continue; - if (item->Action[i].wParm != dwParam) + if (item->_action[i]._wParm != dwParam) continue; - if (item->Action[i].when != NULL) { - if (!evaluateExpression(item->Action[i].when)) + if (item->_action[i]._when != NULL) { + if (!evaluateExpression(item->_action[i]._when)) continue; } // Now we find the right action to be performed // Duplicate the item and copy the current action in #i into #0 - newitem = (LPMPALITEM)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALITEM)); + newitem = (LpMpalItem)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalItem)); if (newitem == NULL) return CORO_INVALID_PID_VALUE; // In the new version number of the action in writing dwRes - Common::copy((byte *)item, (byte *)item + sizeof(MPALITEM), (byte *)newitem); + Common::copy((byte *)item, (byte *)item + sizeof(MpalItem), (byte *)newitem); //newitem->Action[0].nCmds=item->Action[i].nCmds; //memcpy(newitem->Action[0].CmdNum,item->Action[i].CmdNum,newitem->Action[0].nCmds*sizeof(newitem->Action[0].CmdNum[0])); - newitem->dwRes = i; + newitem->_dwRes = i; // And finally we can laucnh the process that will execute the action, // and a second process to free up the memory when the action is finished. // !!! New process management uint32 h; - if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LPMPALITEM))) == CORO_INVALID_PID_VALUE) + if ((h = CoroScheduler.createProcess(ActionThread, &newitem, sizeof(LpMpalItem))) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; if (CoroScheduler.createProcess(ShutUpActionThread, &h, sizeof(uint32)) == CORO_INVALID_PID_VALUE) return CORO_INVALID_PID_VALUE; - GLOBALS._nExecutingAction = item->nObj; + GLOBALS._nExecutingAction = item->_nObj; GLOBALS._bExecutingAction = true; return h; @@ -1372,15 +1371,15 @@ static uint32 doDialog(uint32 nDlgOrd, uint32 nGroup) { * @returns True if everything is OK, false on failure */ bool doSelection(uint32 i, uint32 dwData) { - LPMPALDIALOG dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; + LpMpalDialog dialog = GLOBALS._lpmdDialogs + GLOBALS._nExecutingDialog; int j; - for (j = 0; dialog->_choice[i]._select[j].dwData != 0; j++) { - if (dialog->_choice[i]._select[j].dwData == dwData && dialog->_choice[i]._select[j].curActive != 0) + for (j = 0; dialog->_choice[i]._select[j]._dwData != 0; j++) { + if (dialog->_choice[i]._select[j]._dwData == dwData && dialog->_choice[i]._select[j]._curActive != 0) break; } - if (dialog->_choice[i]._select[j].dwData == 0) + if (dialog->_choice[i]._select[j]._dwData == 0) return false; GLOBALS._nSelectedChoice = j; @@ -1469,7 +1468,7 @@ bool mpalInit(const char *lpszMpcFileName, const char *lpszMprFileName, hMpc.close(); // Process the data - if (ParseMpc(lpMpcImage) == false) + if (parseMpc(lpMpcImage) == false) return false; globalDestroy(lpMpcImage); @@ -1601,9 +1600,9 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { int y = GETARG(uint32); if (x != -1) { if (y == MPQ_X) - dwRet = GLOBALS._lpmlLocations[x].dwXlen; + dwRet = GLOBALS._lpmlLocations[x]._dwXlen; else if (y == MPQ_Y) - dwRet = GLOBALS._lpmlLocations[x].dwYlen; + dwRet = GLOBALS._lpmlLocations[x]._dwYlen; else GLOBALS._mpalError = 1; } else @@ -1662,7 +1661,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1795,7 +1794,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { */ lockLocations(); int x = locGetOrderFromNum(GETARG(uint32)); - hRet = resLoad(GLOBALS._lpmlLocations[x].dwPicRes); + hRet = resLoad(GLOBALS._lpmlLocations[x]._dwPicRes); unlockLocations(); } else if (wQueryType == MPQ_RESOURCE) { @@ -1839,7 +1838,7 @@ HANDLE mpalQueryHANDLE(uint16 wQueryType, ...) { else { lockItems(); int y = itemGetOrderFromNum(x); - memcpy(n, (char *)(GLOBALS._lpmiItems + y)->lpszDescribe, MAX_DESCRIBE_SIZE); + memcpy(n, (char *)(GLOBALS._lpmiItems + y)->_lpszDescribe, MAX_DESCRIBE_SIZE); unlockItems(); } @@ -1959,25 +1958,24 @@ uint32 mpalGetError() { * @returns TRUE if the script 'was launched, FALSE on failure */ bool mpalExecuteScript(int nScript) { - LPMPALSCRIPT s; + LpMpalScript s; LockScripts(); int n = scriptGetOrderFromNum(nScript); - s = (LPMPALSCRIPT)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MPALSCRIPT)); + s = (LpMpalScript)globalAlloc(GMEM_FIXED | GMEM_ZEROINIT, sizeof(MpalScript)); if (s == NULL) return false; - memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MPALSCRIPT)); + memcpy(s, GLOBALS._lpmsScripts + n, sizeof(MpalScript)); unlockScripts(); // !!! New process management - if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LPMPALSCRIPT)) == CORO_INVALID_PID_VALUE) + if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LpMpalScript)) == CORO_INVALID_PID_VALUE) return false; return true; } - /** * Install a custom routine That will be called by MPAL every time the pattern * of an item has been changed. @@ -1988,7 +1986,6 @@ void mpalInstallItemIrq(LPITEMIRQFUNCTION lpiifCus) { GLOBALS._lpiifCustom = lpiifCus; } - /** * Process the idle actions of the items on one location. * @@ -2063,7 +2060,7 @@ void mpalEndIdlePoll(CORO_PARAM, int nLoc, bool *result) { * @returns Length in bytes */ int mpalGetSaveStateSize() { - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } /** @@ -2075,7 +2072,7 @@ int mpalGetSaveStateSize() { void mpalSaveState(byte *buf) { lockVar(); WRITE_LE_UINT32(buf, GLOBALS._nVars); - memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); } @@ -2092,12 +2089,12 @@ int mpalLoadState(byte *buf) { GLOBALS._nVars = READ_LE_UINT32(buf); - GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MPALVAR)); + GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MpalVar)); lockVar(); - memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MPALVAR)); + memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MpalVar)); unlockVar(); - return GLOBALS._nVars * sizeof(MPALVAR) + 4; + return GLOBALS._nVars * sizeof(MpalVar) + 4; } } // end of namespace MPAL diff --git a/engines/tony/mpal/mpal.h b/engines/tony/mpal/mpal.h index 492889d88a..1af0f2c9e9 100644 --- a/engines/tony/mpal/mpal.h +++ b/engines/tony/mpal/mpal.h @@ -120,31 +120,31 @@ enum QueryCoordinates { */ enum QueryTypes { // General Query - MPQ_VERSION=10, + MPQ_VERSION = 10, - MPQ_GLOBAL_VAR=50, + MPQ_GLOBAL_VAR = 50, MPQ_RESOURCE, MPQ_MESSAGE, // Query on leases - MPQ_LOCATION_IMAGE=100, + MPQ_LOCATION_IMAGE = 100, MPQ_LOCATION_SIZE, // Queries about items - MPQ_ITEM_LIST=200, + MPQ_ITEM_LIST = 200, MPQ_ITEM_DATA, MPQ_ITEM_PATTERN, MPQ_ITEM_NAME, MPQ_ITEM_IS_ACTIVE, // Query dialog - MPQ_DIALOG_PERIOD=300, + MPQ_DIALOG_PERIOD = 300, MPQ_DIALOG_WAITFORCHOICE, MPQ_DIALOG_SELECTLIST, MPQ_DIALOG_SELECTION, // Query execution - MPQ_DO_ACTION=400, + MPQ_DO_ACTION = 400, MPQ_DO_DIALOG }; @@ -164,7 +164,6 @@ typedef struct { short _destX, _destY; signed char _destZ; short _objectID; -// char TAG; } ITEM; typedef ITEM *LPITEM; diff --git a/engines/tony/mpal/mpaldll.h b/engines/tony/mpal/mpaldll.h index a95003ef97..853b5b2dac 100644 --- a/engines/tony/mpal/mpaldll.h +++ b/engines/tony/mpal/mpaldll.h @@ -42,32 +42,27 @@ namespace MPAL { * Defines \****************************************************************************/ -#define HEX_VERSION 0x0170 - - -#define MAX_ACTIONS_PER_ITEM 40 -#define MAX_COMMANDS_PER_ITEM 128 -#define MAX_COMMANDS_PER_ACTION 128 -#define MAX_DESCRIBE_SIZE 64 - - -#define MAX_MOMENTS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_SCRIPT 256 -#define MAX_COMMANDS_PER_MOMENT 32 - - -#define MAX_GROUPS_PER_DIALOG 128 -#define MAX_COMMANDS_PER_DIALOG 480 -#define MAX_COMMANDS_PER_GROUP 64 -#define MAX_CHOICES_PER_DIALOG 64 -#define MAX_SELECTS_PER_CHOICE 64 +#define HEX_VERSION 0x0170 + +#define MAX_ACTIONS_PER_ITEM 40 +#define MAX_COMMANDS_PER_ITEM 128 +#define MAX_COMMANDS_PER_ACTION 128 +#define MAX_DESCRIBE_SIZE 64 + +#define MAX_MOMENTS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_SCRIPT 256 +#define MAX_COMMANDS_PER_MOMENT 32 + +#define MAX_GROUPS_PER_DIALOG 128 +#define MAX_COMMANDS_PER_DIALOG 480 +#define MAX_COMMANDS_PER_GROUP 64 +#define MAX_CHOICES_PER_DIALOG 64 +#define MAX_SELECTS_PER_CHOICE 64 #define MAX_PLAYGROUPS_PER_SELECT 9 -#define MAX_PERIODS_PER_DIALOG 400 - +#define MAX_PERIODS_PER_DIALOG 400 #define NEED_LOCK_MSGS - /****************************************************************************\ * Structures \****************************************************************************/ @@ -77,42 +72,36 @@ namespace MPAL { /** * MPAL global variables */ -struct MPALVAR { - uint32 dwVal; // Variable value - char lpszVarName[33]; // Variable name +struct MpalVar { + uint32 _dwVal; // Variable value + char _lpszVarName[33]; // Variable name } PACKED_STRUCT; -typedef MPALVAR *LPMPALVAR; -typedef LPMPALVAR *LPLPMPALVAR; - +typedef MpalVar *LpMpalVar; /** * MPAL Messages */ -struct MPALMSG { - HGLOBAL _hText; // Handle to the message text - uint16 _wNum; // Message number +struct MpalMsg { + HGLOBAL _hText; // Handle to the message text + uint16 _wNum; // Message number } PACKED_STRUCT; -typedef MPALMSG *LPMPALMSG; -typedef LPMPALMSG *LPLPMPALMSG; - +typedef MpalMsg *LpMpalMsg; /** * MPAL Locations */ -struct MPALLOCATION { - uint32 nObj; // Location number - uint32 dwXlen, dwYlen; // Dimensions - uint32 dwPicRes; // Resource that contains the image +struct MpalLocation { + uint32 _nObj; // Location number + uint32 _dwXlen, _dwYlen; // Dimensions + uint32 _dwPicRes; // Resource that contains the image } PACKED_STRUCT; -typedef MPALLOCATION *LPMPALLOCATION; -typedef LPMPALLOCATION *LPLPMPALLOCATION; - +typedef MpalLocation *LpMpalLocation; /** * All the data for a command, ie. tags used by OnAction in the item, the time * in the script, and in the group dialog. */ -struct command { +struct Command { /* * Types of commands that are recognized * @@ -121,55 +110,54 @@ struct command { * #3 -> Making a choice (DIALOG) * */ - byte type; // Type of control + byte _type; // Type of control union { - int32 _nCf; // Custom function call [#1] - char *lpszVarName; // Variable name [#2] - int32 nChoice; // Number of choice you make [#3] + int32 _nCf; // Custom function call [#1] + char *_lpszVarName; // Variable name [#2] + int32 _nChoice; // Number of choice you make [#3] }; union { - int32 _arg1; // Argument for custom function [#1] - HGLOBAL expr; // Expression to assign to a variable [#2] + int32 _arg1; // Argument for custom function [#1] + HGLOBAL _expr; // Expression to assign to a variable [#2] }; - int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] + int32 _arg2, _arg3, _arg4; // Arguments for custom function [#1] } PACKED_STRUCT; /** * MPAL dialog */ -struct MPALDIALOG { - uint32 nObj; // Dialog number +struct MpalDialog { + uint32 _nObj; // Dialog number - struct command _command[MAX_COMMANDS_PER_DIALOG]; + struct Command _command[MAX_COMMANDS_PER_DIALOG]; struct { - uint16 num; - - byte nCmds; - uint16 CmdNum[MAX_COMMANDS_PER_GROUP]; + uint16 _num; + byte _nCmds; + uint16 _cmdNum[MAX_COMMANDS_PER_GROUP]; } _group[MAX_GROUPS_PER_DIALOG]; struct { // The last choice has nChoice == 0 - uint16 nChoice; + uint16 _nChoice; // The select number (we're pretty stingy with RAM). The last select has dwData == 0 struct { - HGLOBAL when; - uint32 dwData; - uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; + HGLOBAL _when; + uint32 _dwData; + uint16 _wPlayGroup[MAX_PLAYGROUPS_PER_SELECT]; // Bit 0=endchoice Bit 1=enddialog - byte attr; + byte _attr; // Modified at run-time: 0 if the select is currently disabled, // and 1 if currently active - byte curActive; + byte _curActive; } _select[MAX_SELECTS_PER_CHOICE]; } _choice[MAX_CHOICES_PER_DIALOG]; @@ -178,68 +166,60 @@ struct MPALDIALOG { HGLOBAL _periods[MAX_PERIODS_PER_DIALOG]; } PACKED_STRUCT; -typedef MPALDIALOG *LPMPALDIALOG; -typedef LPMPALDIALOG *LPLPMPALDIALOG; - +typedef MpalDialog *LpMpalDialog; /** * MPAL Item */ struct ItemAction { - byte num; // Action number - uint16 wTime; // If idle, the time which must pass - byte perc; // Percentage of the idle run - HGLOBAL when; // Expression to compute. If != 0, then + byte _num; // Action number + uint16 _wTime; // If idle, the time which must pass + byte _perc; // Percentage of the idle run + HGLOBAL _when; // Expression to compute. If != 0, then // action can be done - uint16 wParm; // Parameter for action + uint16 _wParm; // Parameter for action - byte nCmds; // Number of commands to be executed - uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute + byte _nCmds; // Number of commands to be executed + uint32 _cmdNum[MAX_COMMANDS_PER_ACTION]; // Commands to execute } PACKED_STRUCT; -struct MPALITEM { - uint32 nObj; // Item number +struct MpalItem { + uint32 _nObj; // Item number - byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Name - byte nActions; // Number of managed actions - uint32 dwRes; // Resource that contains frames and patterns + byte _lpszDescribe[MAX_DESCRIBE_SIZE]; // Name + byte _nActions; // Number of managed actions + uint32 _dwRes; // Resource that contains frames and patterns - struct command _command[MAX_COMMANDS_PER_ITEM]; + struct Command _command[MAX_COMMANDS_PER_ITEM]; // Pointer to array of structures containing various managed activities. In practice, of // every action we know what commands to run, including those defined in structures above - struct ItemAction *Action; + struct ItemAction *_action; } PACKED_STRUCT; -typedef MPALITEM *LPMPALITEM; -typedef LPMPALITEM *LPLPMPALITEM; - +typedef MpalItem *LpMpalItem; /** * MPAL Script */ -struct MPALSCRIPT { - uint32 nObj; - - uint32 nMoments; +struct MpalScript { + uint32 _nObj; + uint32 _nMoments; - struct command _command[MAX_COMMANDS_PER_SCRIPT]; + struct Command _command[MAX_COMMANDS_PER_SCRIPT]; struct { - int32 dwTime; + int32 _dwTime; + byte _nCmds; + uint32 _cmdNum[MAX_COMMANDS_PER_MOMENT]; - byte nCmds; - uint32 CmdNum[MAX_COMMANDS_PER_MOMENT]; - - } Moment[MAX_MOMENTS_PER_SCRIPT]; + } _moment[MAX_MOMENTS_PER_SCRIPT]; } PACKED_STRUCT; -typedef MPALSCRIPT *LPMPALSCRIPT; -typedef LPMPALSCRIPT *LPLPMPALSCRIPT; +typedef MpalScript *LpMpalScript; #include "common/pack-end.h" - /****************************************************************************\ * Function prototypes \****************************************************************************/ diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index d135f66fde..9426a37a8b 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -312,7 +312,7 @@ void TonyEngine::playMusic(int nChannel, const Common::String &fname, int nFX, b uint32 hThread = CoroScheduler.createProcess(doNextMusic, NULL, 0); assert(hThread != CORO_INVALID_PID_VALUE); - } else if (nFX == 44) { // Cambia canale e lascia finire il primo + } else if (nFX == 44) { // Change the channel and let the first finish if (GLOBALS._flipflop) GLOBALS._nextChannel = nChannel - 1; else @@ -704,7 +704,7 @@ void TonyEngine::close() { _theEngine.close(); _window.close(); mpalFree(); - FreeMpc(); + freeMpc(); delete[] _curThumbnail; } -- cgit v1.2.3