aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/mpal/mpal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tony/mpal/mpal.cpp')
-rw-r--r--engines/tony/mpal/mpal.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/engines/tony/mpal/mpal.cpp b/engines/tony/mpal/mpal.cpp
index fff8676a89..89cc28130d 100644
--- a/engines/tony/mpal/mpal.cpp
+++ b/engines/tony/mpal/mpal.cpp
@@ -8,17 +8,16 @@
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
-
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
-
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- *
*/
/*
* This code is based on original Tony Tough source code
@@ -409,7 +408,7 @@ static uint32 *getSelectList(uint32 i) {
sl[k++] = dialog->_choice[i]._select[j]._dwData;
}
- sl[k] = (uint32)NULL;
+ sl[k] = 0;
return sl;
}
@@ -436,7 +435,7 @@ static uint32 *GetItemList(uint32 nLoc) {
}
}
- il[j] = (uint32)NULL;
+ il[j] = 0;
return il;
}
@@ -710,6 +709,10 @@ void ActionThread(CORO_PARAM, const void *param) {
CORO_SLEEP(1);
}
+ // WORKAROUND: User interface sometimes remaining disabled after capturing guard on Ferris wheel
+ if (_ctx->item->_nObj == 3601 && _ctx->item->_dwRes == 9)
+ g_vm->getEngine()->enableInput();
+
globalDestroy(_ctx->item);
_ctx->item = NULL;
@@ -832,7 +835,7 @@ void LocationPollThread(CORO_PARAM, const void *param) {
if (_ctx->k == 0)
// We can remove this item from the list
- _ctx->il[_ctx->i] = (uint32)NULL;
+ _ctx->il[_ctx->i] = 0;
else
_ctx->nRealItems++;
}
@@ -963,7 +966,7 @@ void LocationPollThread(CORO_PARAM, const void *param) {
// 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));
- if (_ctx->newItem == false) {
+ if (!_ctx->newItem) {
globalDestroy(_ctx->myThreads);
globalDestroy(_ctx->myActions);
@@ -1519,13 +1522,12 @@ void mpalFree() {
*
* @param wQueryType Type of query. The list is in the QueryTypes enum.
* @returns 4 bytes depending on the type of query
- * @remarks This is the specialised version of the original single mpalQuery
+ * @remarks This is the specialized version of the original single mpalQuery
* method that returns numeric results.
*/
uint32 mpalQueryDWORD(uint16 wQueryType, ...) {
Common::String buf;
uint32 dwRet = 0;
- char *n;
va_list v;
va_start(v, wQueryType);
@@ -1626,7 +1628,7 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) {
*/
lockVar();
int x = GETARG(uint32);
- n = GETARG(char *);
+ char *n = GETARG(char *);
buf = Common::String::format("Status.%u", x);
if (varGetValue(buf.c_str()) <= 0)
n[0]='\0';
@@ -1716,11 +1718,10 @@ uint32 mpalQueryDWORD(uint16 wQueryType, ...) {
*
* @param wQueryType Type of query. The list is in the QueryTypes enum.
* @returns 4 bytes depending on the type of query
- * @remarks This is the specialised version of the original single mpalQuery
+ * @remarks This is the specialized version of the original single mpalQuery
* method that returns a pointer or handle.
*/
MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) {
- char *n;
Common::String buf;
va_list v;
va_start(v, wQueryType);
@@ -1798,12 +1799,9 @@ MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) {
error("mpalQuery(MPQ_ITEM_IS_ACTIVE, uint32 nItem) used incorrect variant");
} else if (wQueryType == MPQ_ITEM_NAME) {
- /*
- * uint32 mpalQuery(MPQ_ITEM_NAME, uint32 nItem, char *lpszName);
- */
lockVar();
int x = GETARG(uint32);
- n = GETARG(char *);
+ char *n = GETARG(char *);
buf = Common::String::format("Status.%u", x);
if (varGetValue(buf.c_str()) <= 0)
n[0] = '\0';
@@ -1873,7 +1871,7 @@ MpalHandle mpalQueryHANDLE(uint16 wQueryType, ...) {
*
* @param wQueryType Type of query. The list is in the QueryTypes enum.
* @returns 4 bytes depending on the type of query
- * @remarks This is the specialised version of the original single mpalQuery
+ * @remarks This is the specialized version of the original single mpalQuery
* method that needs to run within a co-routine context.
*/
void mpalQueryCORO(CORO_PARAM, uint16 wQueryType, uint32 *dwRet) {
@@ -1935,7 +1933,7 @@ bool mpalExecuteScript(int nScript) {
// !!! New process management
if (CoroScheduler.createProcess(ScriptThread, &s, sizeof(LpMpalScript)) == CORO_INVALID_PID_VALUE)
- return false;
+ return false;
return true;
}
@@ -2035,7 +2033,13 @@ int mpalGetSaveStateSize() {
void mpalSaveState(byte *buf) {
lockVar();
WRITE_LE_UINT32(buf, GLOBALS._nVars);
- memcpy(buf + 4, (byte *)GLOBALS._lpmvVars, GLOBALS._nVars * sizeof(MpalVar));
+ buf += 4;
+ for (uint i = 0; i < GLOBALS._nVars; ++i) {
+ LpMpalVar var = &GLOBALS._lpmvVars[i];
+ WRITE_LE_UINT32(buf, var->_dwVal);
+ memcpy(buf + 4, var->_lpszVarName, sizeof(var->_lpszVarName));
+ buf += (4 + sizeof(var->_lpszVarName));
+ }
unlockVar();
}
@@ -2050,10 +2054,16 @@ int mpalLoadState(byte *buf) {
globalFree(GLOBALS._hVars);
GLOBALS._nVars = READ_LE_UINT32(buf);
+ buf += 4;
GLOBALS._hVars = globalAllocate(GMEM_ZEROINIT | GMEM_MOVEABLE, GLOBALS._nVars * sizeof(MpalVar));
lockVar();
- memcpy((byte *)GLOBALS._lpmvVars, buf + 4, GLOBALS._nVars * sizeof(MpalVar));
+ for (uint i = 0; i < GLOBALS._nVars; ++i) {
+ LpMpalVar var = &GLOBALS._lpmvVars[i];
+ var->_dwVal = READ_LE_UINT32(buf);
+ memcpy(var->_lpszVarName, buf + 4, sizeof(var->_lpszVarName));
+ buf += (4 + sizeof(var->_lpszVarName));
+ }
unlockVar();
return GLOBALS._nVars * sizeof(MpalVar) + 4;