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