diff options
author | Evgeny Grechnikov | 2018-08-25 15:11:24 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-26 12:09:43 +0200 |
commit | f771fa40ad474d78d32ce5bff67afc937547e5de (patch) | |
tree | 483ee750c81169142fc58a68e87d5a321a4a96f3 /engines/lastexpress/entities/abbot.cpp | |
parent | f3cb1fcd84d7ca1dd25b7adb4b54f08c535008ac (diff) | |
download | scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.gz scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.tar.bz2 scummvm-rg350-f771fa40ad474d78d32ce5bff67afc937547e5de.zip |
LASTEXPRESS: multiple fixes in NPC logic
Checked the logic against the original game
(to be precise, DOS English version from GOG, although I think
AI logic has no significant differences with other versions).
Fixed a *lot* of errors with varying visibility for the user.
Also, save+exit+load sometimes resulted in memory corruption like
((EntityParametersSSII*)(new EntityParametersIIII))->param8 = 0;
load operation did not restore the correct type of NPC logic context,
the default one was used (which also has the smallest sizeof).
Should be fixed now. Save+load is still unusable because it locks
everybody waiting for kActionEndSound (the sound state is not restored),
but, at least, it should not corrupt the memory. Hopefully.
Diffstat (limited to 'engines/lastexpress/entities/abbot.cpp')
-rw-r--r-- | engines/lastexpress/entities/abbot.cpp | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index 1581916e07..99b9ee3bc2 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -41,18 +41,18 @@ namespace LastExpress { Abbot::Abbot(LastExpressEngine *engine) : Entity(engine, kEntityAbbot) { ADD_CALLBACK_FUNCTION(Abbot, reset); - ADD_CALLBACK_FUNCTION(Abbot, draw); - ADD_CALLBACK_FUNCTION(Abbot, enterExitCompartment); - ADD_CALLBACK_FUNCTION(Abbot, enterExitCompartment2); + ADD_CALLBACK_FUNCTION_S(Abbot, draw); + ADD_CALLBACK_FUNCTION_SI(Abbot, enterExitCompartment); + ADD_CALLBACK_FUNCTION_SI(Abbot, enterExitCompartment2); ADD_CALLBACK_FUNCTION(Abbot, callbackActionOnDirection); - ADD_CALLBACK_FUNCTION(Abbot, draw2); - ADD_CALLBACK_FUNCTION(Abbot, updateFromTime); - ADD_CALLBACK_FUNCTION(Abbot, updateFromTicks); - ADD_CALLBACK_FUNCTION(Abbot, playSound); - ADD_CALLBACK_FUNCTION(Abbot, savegame); - ADD_CALLBACK_FUNCTION(Abbot, updateEntity); - ADD_CALLBACK_FUNCTION(Abbot, callSavepoint); - ADD_CALLBACK_FUNCTION(Abbot, updatePosition); + ADD_CALLBACK_FUNCTION_SSI(Abbot, draw2); + ADD_CALLBACK_FUNCTION_I(Abbot, updateFromTime); + ADD_CALLBACK_FUNCTION_I(Abbot, updateFromTicks); + ADD_CALLBACK_FUNCTION_S(Abbot, playSound); + ADD_CALLBACK_FUNCTION_II(Abbot, savegame); + ADD_CALLBACK_FUNCTION_II(Abbot, updateEntity); + ADD_CALLBACK_FUNCTION_SIIS(Abbot, callSavepoint); + ADD_CALLBACK_FUNCTION_SII(Abbot, updatePosition); ADD_CALLBACK_FUNCTION(Abbot, callbackActionRestaurantOrSalon); ADD_CALLBACK_FUNCTION(Abbot, chapter1); ADD_CALLBACK_FUNCTION(Abbot, chapter2); @@ -79,7 +79,7 @@ Abbot::Abbot(LastExpressEngine *engine) : Entity(engine, kEntityAbbot) { ADD_CALLBACK_FUNCTION(Abbot, goCompartment4); ADD_CALLBACK_FUNCTION(Abbot, inCompartment4); ADD_CALLBACK_FUNCTION(Abbot, chapter4); - ADD_CALLBACK_FUNCTION(Abbot, doWalkSearchingForCath); + ADD_CALLBACK_FUNCTION_II(Abbot, doWalkSearchingForCath); ADD_CALLBACK_FUNCTION(Abbot, chapter4Handler); ADD_CALLBACK_FUNCTION(Abbot, leaveDinner); ADD_CALLBACK_FUNCTION(Abbot, inCompartment); @@ -616,7 +616,7 @@ IMPLEMENT_FUNCTION(26, Abbot, inSalon1) break; case kActionNone: - if (!Entity::updateParameter(params->param2, getState()->time, 4500)) + if (!params->param1 || !Entity::updateParameterCheck(params->param2, getState()->time, 4500)) break; if (getEntities()->isSomebodyInsideRestaurantOrSalon()) @@ -691,7 +691,7 @@ IMPLEMENT_FUNCTION(28, Abbot, openCompartment2) break; case kActionNone: - Entity::timeCheckCallback(kTime2052000, params->param1, 1, WRAP_SETUP_FUNCTION(Abbot, setup_goWander)); + Entity::timeCheckCallback(kTime2052000, params->param1, 2, WRAP_SETUP_FUNCTION(Abbot, setup_goWander)); break; case kActionDefault: @@ -699,7 +699,7 @@ IMPLEMENT_FUNCTION(28, Abbot, openCompartment2) getEntities()->drawSequenceLeft(kEntityAbbot, "508A"); setCallback(1); - setup_playSound("abb3013"); + setup_playSound("Abb3013"); break; case kActionCallback: @@ -749,6 +749,9 @@ IMPLEMENT_FUNCTION(29, Abbot, goWander) break; case 4: + // compare with callback 2. + // This is taken from the original game as is, + // but do we really want real-time 30s in case 2 but simulated-time 15s (aka real-time 5s) here? setCallback(5); setup_updateFromTime(225); break; @@ -962,7 +965,7 @@ IMPLEMENT_FUNCTION(32, Abbot, goCompartment3) case 1: getObjects()->update(kObjectCompartmentC, kEntityPlayer, kObjectLocation1, kCursorKeepValue, kCursorKeepValue); - setCallback(1); + setCallback(2); setup_enterExitCompartment("617Ac", kObjectCompartmentC); break; @@ -1355,7 +1358,7 @@ IMPLEMENT_FUNCTION(42, Abbot, leaveDinner) case kActionDefault: getData()->location = kLocationOutsideCompartment; - getEntities()->updatePositionExit(kEntityAbbot, kCarRestaurant, 67); + getEntities()->updatePositionEnter(kEntityAbbot, kCarRestaurant, 67); setCallback(1); setup_callSavepoint("029F", kEntityTables4, kActionDrawTablesWithChairs, "029G"); @@ -1406,8 +1409,8 @@ IMPLEMENT_FUNCTION(43, Abbot, inCompartment) break; case kActionNone: - if (params->param1 && params->param4 != kTimeInvalid && params->param2 < getState()->time) { - if (getState()->time < kTime2452500) { + if (params->param1 && params->param4 != kTimeInvalid) { + if (getState()->time > kTime2452500) { params->param4 = kTimeInvalid; setCallback(1); @@ -1415,7 +1418,7 @@ IMPLEMENT_FUNCTION(43, Abbot, inCompartment) break; } else { if (!getEntities()->isDistanceBetweenEntities(kEntityAbbot, kEntityPlayer, 1000) || getSoundQueue()->isBuffered(kEntityBoutarel) || !params->param4) - params->param4 = (uint)getState()->time + 450; + params->param4 = (uint)getState()->time; if (params->param4 < getState()->time) { params->param4 = kTimeInvalid; @@ -1655,7 +1658,8 @@ IMPLEMENT_FUNCTION(48, Abbot, afterBomb) getData()->inventoryItem = kItemNone; setCallback(4); - setup_updatePosition("126C", kCarRedSleeping, 52); + setup_updatePosition("126C", kCarRestaurant, 52); + break; } Entity::timeCheckCallbackInventory(kTime2533500, params->param2, 5, WRAP_SETUP_FUNCTION(Abbot, setup_callbackActionRestaurantOrSalon)); @@ -1771,6 +1775,9 @@ IMPLEMENT_FUNCTION(49, Abbot, catchCath) getSavePoints()->push(kEntityAbbot, kEntityTatiana, kAction238790488); getObjects()->update(kObjectCompartment2, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand); getObjects()->update(kObjectHandleInsideBathroom, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand); + + setCallback(1); + setup_savegame(kSavegameTypeEvent, kEventAbbotWrongCompartment); break; case kActionDefault: @@ -1791,7 +1798,7 @@ IMPLEMENT_FUNCTION(49, Abbot, catchCath) break; case 1: - getAction()->playAnimation(getObjects()->get(kObjectCompartment2).model < kObjectModel2 ? kEventAbbotWrongCompartmentBed : kEventAbbotWrongCompartment); + getAction()->playAnimation(getObjects()->get(kObjectCompartment2).model == kObjectModel1 ? kEventAbbotWrongCompartmentBed : kEventAbbotWrongCompartment); getEntities()->updateEntity(kEntityAbbot, kCarRedSleeping, kPosition_6470); getSound()->playSound(kEntityPlayer, "LIB015"); getScenes()->loadSceneFromObject(kObjectCompartment2, true); |