From 876a8f9377b6c5533ca81c3c358e8b74014dc93f Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 14:10:39 -0400 Subject: LASTEXPRESS: Replace COMPARTMENT_TO and COMPARTMENT_FROM_TO macros --- engines/lastexpress/entities/alouan.cpp | 8 ++-- engines/lastexpress/entities/entity.cpp | 68 ++++++++++++++++++++++++++++ engines/lastexpress/entities/entity.h | 51 +++++++++++++++++---- engines/lastexpress/entities/entity_intern.h | 60 ------------------------ engines/lastexpress/entities/hadija.cpp | 8 ++-- 5 files changed, 118 insertions(+), 77 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/alouan.cpp b/engines/lastexpress/entities/alouan.cpp index 3ae38dcf27..8e56ae4c5b 100644 --- a/engines/lastexpress/entities/alouan.cpp +++ b/engines/lastexpress/entities/alouan.cpp @@ -86,22 +86,22 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(6, Alouan, compartment6) - COMPARTMENT_TO(Alouan, kObjectCompartment6, kPosition_4070, "621Cf", "621Df"); + Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Cf", "621Df", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(7, Alouan, compartment8) - COMPARTMENT_TO(Alouan, kObjectCompartment8, kPosition_2740, "621Ch", "621Dh"); + Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Ch", "621Dh", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(8, Alouan, compartment6to8) - COMPARTMENT_FROM_TO(Alouan, kObjectCompartment6, kPosition_4070, "621Bf", kObjectCompartment8, kPosition_2740, "621Ah"); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Bf", kObjectCompartment8, kPosition_2740, "621Ah", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Alouan, setup_updateEntity)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(9, Alouan, compartment8to6) - COMPARTMENT_FROM_TO(Alouan, kObjectCompartment8, kPosition_2740, "621Bh", kObjectCompartment6, kPosition_4070, "621Af"); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Bh", kObjectCompartment6, kPosition_4070, "621Af", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Alouan, setup_updateEntity)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 7fdfd53d2f..776b9f6c40 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -464,6 +464,74 @@ void Entity::enterExitCompartment(const SavePoint &savepoint, EntityPosition pos } } +void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo, Entity::EnterFunction *enterFunction) { + switch (savepoint.action) { + default: + break; + + case kActionDefault: + getData()->entityPosition = positionFrom; + setCallback(1); + (*enterFunction)(sequenceFrom.c_str(), compartmentFrom); + break; + + case kActionCallback: + switch (getCallback()) { + default: + break; + + case 1: + setCallback(2); + (*enterFunction)(sequenceTo.c_str(), compartmentFrom); + break; + + case 2: + getData()->entityPosition = positionFrom; + getEntities()->clearSequences(_entityIndex); + callbackAction(); + break; + } + break; + } +} + +void Entity::goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo, Entity::EnterFunction *enterFunction, Entity::UpdateFunction *updateFunction) { + switch (savepoint.action) { + default: + break; + + case kActionDefault: + getData()->entityPosition = positionFrom; + getData()->location = kLocationOutsideCompartment; + setCallback(1); + (*enterFunction)(sequenceFrom.c_str(), compartmentFrom); + break; + + case kActionCallback: + switch (getCallback()) { + default: + break; + + case 1: + setCallback(2); + (*updateFunction)(kCarGreenSleeping, positionTo); + break; + + case 2: + setCallback(3); + (*enterFunction)(sequenceTo.c_str(), compartmentTo); + break; + + case 3: + getData()->location = kLocationInsideCompartment; + getEntities()->clearSequences(_entityIndex); + callbackAction(); + break; + } + break; + } +} + void Entity::updatePosition(const SavePoint &savepoint, bool handleExcuseMe) { EXPOSE_PARAMS(EntityData::EntityParametersSIII) diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 3fd2009313..bb2b96618e 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -616,19 +616,19 @@ public: EntityParameters *getParameters(uint callback, byte index) const; EntityParameters *getCurrentParameters(byte index = 0) { return getParameters(_data.currentCall, index); } - int getCallback(uint callback) const; - int getCurrentCallback() { return getCallback(_data.currentCall); } - void setCallback(uint callback, byte index); - void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); } + int getCallback(uint callback) const; + int getCurrentCallback() { return getCallback(_data.currentCall); } + void setCallback(uint callback, byte index); + void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); } void updateParameters(uint32 index) const; // Serializable - void saveLoadWithSerializer(Common::Serializer &ser); + void saveLoadWithSerializer(Common::Serializer &ser); private: - EntityCallData _data; + EntityCallData _data; EntityCallParameters _parameters[9]; }; @@ -665,9 +665,15 @@ public: protected: LastExpressEngine *_engine; - EntityIndex _entityIndex; - EntityData *_data; - Common::Array _callbacks; + EntityIndex _entityIndex; + EntityData *_data; + Common::Array _callbacks; + + typedef Common::Functor2 EnterFunction; + typedef Common::Functor2 UpdateFunction; + + #define WRAP_ENTER_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) + #define WRAP_UPDATE_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) /** * Saves the game @@ -781,6 +787,33 @@ protected: */ void enterExitCompartment(const SavePoint &savepoint, EntityPosition position1 = kPositionNone, EntityPosition position2 = kPositionNone, CarIndex car = kCarNone, ObjectIndex compartment = kObjectNone, bool alternate = false, bool updateLocation = false); + /** + * Go to compartment. + * + * @param savepoint The savepoint. + * @param compartmentFrom The compartment from. + * @param positionFrom The position from. + * @param sequenceFrom The sequence from. + * @param sequenceTo The sequence to. + * @param enterFunction The enter/exit compartment function. + */ + void goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo, EnterFunction *enterFunction); + + /** + * Go to compartment from compartment. + * + * @param savepoint The savepoint. + * @param compartmentFrom The compartment from. + * @param positionFrom The position from. + * @param sequenceFrom The sequence from. + * @param compartmentTo The compartment to. + * @param positionTo The position to. + * @param sequenceTo The sequence to. + * @param enterFunction The enter/exit compartment function. + * @param enterFunction The update entity function. + */ + void goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo, Entity::EnterFunction *enterFunction, Entity::UpdateFunction *updateFunction); + /** * Updates the position * diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index c21f2c14e2..0613b7bb0b 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -451,66 +451,6 @@ void class::setup_##name() { \ if (!parameter) \ parameter = (uint)(type + value); -////////////////////////////////////////////////////////////////////////// -// Compartments -////////////////////////////////////////////////////////////////////////// -// Go from one compartment to another (or the same one if no optional args are passed -#define COMPARTMENT_TO(class, compartmentFrom, positionFrom, sequenceFrom, sequenceTo) \ - switch (savepoint.action) { \ - default: \ - break; \ - case kActionDefault: \ - getData()->entityPosition = positionFrom; \ - setCallback(1); \ - setup_enterExitCompartment(sequenceFrom, compartmentFrom); \ - break; \ - case kActionCallback: \ - switch (getCallback()) { \ - default: \ - break; \ - case 1: \ - setCallback(2); \ - setup_enterExitCompartment(sequenceTo, compartmentFrom); \ - break; \ - case 2: \ - getData()->entityPosition = positionFrom; \ - getEntities()->clearSequences(_entityIndex); \ - callbackAction(); \ - } \ - break; \ - } - -#define COMPARTMENT_FROM_TO(class, compartmentFrom, positionFrom, sequenceFrom, compartmentTo, positionTo, sequenceTo) \ - switch (savepoint.action) { \ - default: \ - break; \ - case kActionDefault: \ - getData()->entityPosition = positionFrom; \ - getData()->location = kLocationOutsideCompartment; \ - setCallback(1); \ - setup_enterExitCompartment(sequenceFrom, compartmentFrom); \ - break; \ - case kActionCallback: \ - switch (getCallback()) { \ - default: \ - break; \ - case 1: \ - setCallback(2); \ - setup_updateEntity(kCarGreenSleeping, positionTo); \ - break; \ - case 2: \ - setCallback(3); \ - setup_enterExitCompartment(sequenceTo, compartmentTo); \ - break; \ - case 3: \ - getData()->location = kLocationInsideCompartment; \ - getEntities()->clearSequences(_entityIndex); \ - callbackAction(); \ - break; \ - } \ - break; \ - } - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/hadija.cpp b/engines/lastexpress/entities/hadija.cpp index 09c80247d4..2dd239d4c9 100644 --- a/engines/lastexpress/entities/hadija.cpp +++ b/engines/lastexpress/entities/hadija.cpp @@ -86,22 +86,22 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(6, Hadija, compartment6) - COMPARTMENT_TO(Hadija, kObjectCompartment6, kPosition_4070, "619Cf", "619Df"); + Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Cf", "619Df", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(7, Hadija, compartment8) - COMPARTMENT_TO(Hadija, kObjectCompartment8, kPosition_2740, "619Ch", "619Dh"); + Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Ch", "619Dh", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(8, Hadija, compartment6to8) - COMPARTMENT_FROM_TO(Hadija, kObjectCompartment6, kPosition_4070, "619Bf", kObjectCompartment8, kPosition_2740, "619Ah"); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Bf", kObjectCompartment8, kPosition_2740, "619Ah", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Hadija, setup_updateEntity)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(9, Hadija, compartment8to6) - COMPARTMENT_FROM_TO(Hadija, kObjectCompartment8, kPosition_2740, "619Bh", kObjectCompartment6, kPosition_4070, "619Af"); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Bh", kObjectCompartment6, kPosition_4070, "619Af", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Hadija, setup_updateEntity)); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 96d0aedba93e4ba2691a5ee1eba24a1f07539c96 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 17:21:36 -0400 Subject: LASTEXPRESS: Replace SAVEGAME_BLOOD_JACKET macro by function --- engines/lastexpress/entities/coudert.cpp | 39 ++++++++++++++++---------------- engines/lastexpress/entities/coudert.h | 1 + 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index dc7beb3167..66733acc16 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -37,15 +37,6 @@ namespace LastExpress { -#define SAVEGAME_BLOOD_JACKET() \ - if (getProgress().jacket == kJacketBlood \ - && getEntities()->isDistanceBetweenEntities(kEntityCoudert, kEntityPlayer, 1000) \ - && !getEntities()->isInsideCompartments(kEntityPlayer) \ - && !getEntities()->checkFields10(kEntityPlayer)) { \ - setCallback(1); \ - setup_savegame(kSavegameTypeEvent, kEventMertensBloodJacket); \ - } - Coudert::Coudert(LastExpressEngine *engine) : Entity(engine, kEntityCoudert) { ADD_CALLBACK_FUNCTION(Coudert, reset); ADD_CALLBACK_FUNCTION(Coudert, bloodJacket); @@ -124,7 +115,7 @@ IMPLEMENT_FUNCTION_S(2, Coudert, bloodJacket) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); break; case kActionExitCompartment: @@ -151,7 +142,7 @@ IMPLEMENT_FUNCTION_SI(3, Coudert, enterExitCompartment, ObjectIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); return; case kActionCallback: @@ -177,7 +168,7 @@ IMPLEMENT_FUNCTION(4, Coudert, callbackActionOnDirection) break; } - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); break; case kActionExitCompartment: @@ -200,7 +191,7 @@ IMPLEMENT_FUNCTION_SIII(5, Coudert, enterExitCompartment2, ObjectIndex, EntityPo break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); return; case kActionCallback: @@ -221,7 +212,7 @@ IMPLEMENT_FUNCTION_S(6, Coudert, playSound) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); break; case kActionEndSound: @@ -250,7 +241,7 @@ IMPLEMENT_FUNCTION_NOSETUP(7, Coudert, playSound16) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); break; case kActionEndSound: @@ -363,7 +354,7 @@ IMPLEMENT_FUNCTION_I(10, Coudert, updateFromTime, uint32) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); UPDATE_PARAM(params->param2, getState()->time, params->param1); @@ -386,7 +377,7 @@ IMPLEMENT_FUNCTION_I(11, Coudert, updateFromTicks, uint32) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1); @@ -460,7 +451,7 @@ IMPLEMENT_FUNCTION_II(13, Coudert, function13, bool, EntityIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); if (!params->param2 && !params->param3) { @@ -582,7 +573,7 @@ IMPLEMENT_FUNCTION_I(14, Coudert, function14, EntityIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + savegameBloodJacket(); break; case kActionDefault: @@ -4173,4 +4164,14 @@ void Coudert::visitCompartment(const SavePoint &savepoint, EntityPosition positi } } +void Coudert::savegameBloodJacket() { + if (getProgress().jacket == kJacketBlood + && getEntities()->isDistanceBetweenEntities(kEntityCoudert, kEntityPlayer, 1000) + && !getEntities()->isInsideCompartments(kEntityPlayer) + && !getEntities()->checkFields10(kEntityPlayer)) { + setCallback(1); + setup_savegame(kSavegameTypeEvent, kEventMertensBloodJacket); + } +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/coudert.h b/engines/lastexpress/entities/coudert.h index 45d13ce9bb..d06bb95ce9 100644 --- a/engines/lastexpress/entities/coudert.h +++ b/engines/lastexpress/entities/coudert.h @@ -219,6 +219,7 @@ public: private: void visitCompartment(const SavePoint &savepoint, EntityPosition position, const char *seq1, ObjectIndex compartment, const char *seq2, const char *seq3, EntityPosition sittingPosition, ObjectIndex object, const char *seq4); + void savegameBloodJacket(); }; } // End of namespace LastExpress -- cgit v1.2.3 From d4f7c0232380b94b42d280c3680e473cd0c2d9b5 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 19:24:11 -0400 Subject: LASTEXPRESS: Replace PLAY_STEAM macro by function --- engines/lastexpress/entities/chapters.cpp | 40 +++++++++++++++---------------- engines/lastexpress/entities/chapters.h | 1 + 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index eab4dfe2c1..b4978165b9 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -384,12 +384,6 @@ IMPLEMENT_FUNCTION(7, Chapters, chapter1Init) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -#define PLAY_STEAM() { \ - getSoundQueue()->resetState(); \ - getSound()->playSteam((CityIndex)ENTITY_PARAM(0, 4)); \ - ENTITY_PARAM(0, 2) = 0; \ - } - IMPLEMENT_FUNCTION(8, Chapters, chapter1Handler) switch (savepoint.action) { default: @@ -522,43 +516,43 @@ label_chapter1_next: getSavePoints()->push(kEntityChapters, kEntityTrain, kActionTrainStopRunning); if (getEntityData(kEntityPlayer)->location != kLocationOutsideTrain) { - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isOutsideAlexeiWindow()) { getScenes()->loadSceneFromPosition(kCarGreenSleeping, 49); - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isOutsideAnnaWindow()) { getScenes()->loadSceneFromPosition(kCarRedSleeping, 49); - PLAY_STEAM(); + playSteam(); break; } CarIndex car = getEntityData(kEntityPlayer)->car; if (car < kCarRedSleeping || car > kCarCoalTender) { if (car < kCarBaggageRear || car > kCarGreenSleeping) { - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isPlayerPosition(kCarGreenSleeping, 98)) { getSound()->playSound(kEntityPlayer, "LIB015"); getScenes()->loadSceneFromPosition(kCarGreenSleeping, 71); - PLAY_STEAM(); + playSteam(); break; } getScenes()->loadSceneFromPosition(kCarGreenSleeping, 82); - PLAY_STEAM(); + playSteam(); break; } getScenes()->loadSceneFromPosition(kCarRestaurant, 82); - PLAY_STEAM(); + playSteam(); break; } @@ -1278,43 +1272,43 @@ label_callback_4: getSavePoints()->push(kEntityChapters, kEntityTrain, kActionTrainStopRunning); if (getEntityData(kEntityPlayer)->location != kLocationOutsideTrain) { - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isOutsideAlexeiWindow()) { getScenes()->loadSceneFromPosition(kCarGreenSleeping, 49); - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isOutsideAnnaWindow()) { getScenes()->loadSceneFromPosition(kCarRedSleeping, 49); - PLAY_STEAM(); + playSteam(); break; } CarIndex car = getEntityData(kEntityPlayer)->car; if (car < kCarRedSleeping || car > kCarCoalTender) { if (car < kCarBaggageRear || car > kCarGreenSleeping) { - PLAY_STEAM(); + playSteam(); break; } if (getEntities()->isPlayerPosition(kCarGreenSleeping, 98)) { getSound()->playSound(kEntityPlayer, "LIB015"); getScenes()->loadSceneFromPosition(kCarGreenSleeping, 71); - PLAY_STEAM(); + playSteam(); break; } getScenes()->loadSceneFromPosition(kCarGreenSleeping, 82); - PLAY_STEAM(); + playSteam(); break; } getScenes()->loadSceneFromPosition(kCarRestaurant, 82); - PLAY_STEAM(); + playSteam(); break; } @@ -1816,4 +1810,10 @@ void Chapters::enterExitHelper(bool isEnteringStation) { callbackAction(); } +void Chapters::playSteam() { + getSoundQueue()->resetState(); + getSound()->playSteam((CityIndex)ENTITY_PARAM(0, 4)); + ENTITY_PARAM(0, 2) = 0; +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/chapters.h b/engines/lastexpress/entities/chapters.h index 353d3a6b5b..62b8af9270 100644 --- a/engines/lastexpress/entities/chapters.h +++ b/engines/lastexpress/entities/chapters.h @@ -156,6 +156,7 @@ public: private: void enterExitStation(const SavePoint &savepoint, bool isEnteringStation); void enterExitHelper(bool isEnteringStation); + void playSteam(); }; } // End of namespace LastExpress -- cgit v1.2.3 From 132dd5b4bc236f805babe0187797ef03bbb16310 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 19:25:16 -0400 Subject: LASTEXPRESS: Replace SYNC_STRING macro by function --- engines/lastexpress/entities/entity.cpp | 29 +++++++++++++++-------------- engines/lastexpress/entities/entity.h | 9 +++++++++ 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 776b9f6c40..120c1f2d85 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -51,6 +51,17 @@ EntityData::EntityCallData::~EntityCallData() { SAFE_DELETE(sequence3); } +void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, int length) { + char seqName[13]; + memset(&seqName, 0, length); + + if (s.isSaving()) strcpy((char *)&seqName, string.c_str()); + s.syncBytes((byte *)&seqName, length); + + if (s.isLoading()) + string = seqName; +} + void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { for (uint i = 0; i < ARRAYSIZE(callbacks); i++) s.syncAsByte(callbacks[i]); @@ -77,20 +88,10 @@ void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsByte(directionSwitch); // Sync strings -#define SYNC_STRING(varName, count) { \ - char seqName[13]; \ - memset(&seqName, 0, count); \ - if (s.isSaving()) strcpy((char *)&seqName, varName.c_str()); \ - s.syncBytes((byte *)&seqName, count); \ - if (s.isLoading()) varName = seqName; \ -} - - SYNC_STRING(sequenceName, 13); - SYNC_STRING(sequenceName2, 13); - SYNC_STRING(sequenceNamePrefix, 7); - SYNC_STRING(sequenceNameCopy, 13); - -#undef SYNC_STRING + syncString(s, sequenceName, 13); + syncString(s, sequenceName2, 13); + syncString(s, sequenceNamePrefix, 7); + syncString(s, sequenceNameCopy, 13); // Skip pointers to frame & sequences s.skip(5 * 4); diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index bb2b96618e..4dca5424b1 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -596,6 +596,15 @@ public: return str; } + /** + * Synchronizes a string. + * + * @param s The Common::Serializer to use. + * @param string The string. + * @param length Length of the string. + */ + void syncString(Common::Serializer &s, Common::String &string, int length); + // Serializable void saveLoadWithSerializer(Common::Serializer &s); }; -- cgit v1.2.3 From e517c1199a0a187d865fbf22ce964a7dad069eb9 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 19:26:35 -0400 Subject: LASTEXPRESS: Move LOW_BYTE macro to helpers.h --- engines/lastexpress/entities/entity_intern.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 0613b7bb0b..c622ff9f0e 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -25,8 +25,6 @@ namespace LastExpress { -#define LOW_BYTE(w) ((unsigned char)(((unsigned long)(w)) & 0xff)) - ////////////////////////////////////////////////////////////////////////// // Callbacks #define ENTITY_CALLBACK(class, name, pointer) \ -- cgit v1.2.3 From 3d1b7b2d962ac37d8fb706ac8b884d3e560f97b5 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 22:36:29 -0400 Subject: LASTEXPRESS: Merge the two savegameBloodJacket functions into the base Entity class --- engines/lastexpress/entities/coudert.cpp | 30 ++++++++++-------------------- engines/lastexpress/entities/coudert.h | 1 - engines/lastexpress/entities/entity.cpp | 22 ++++++++++++++++++++++ engines/lastexpress/entities/entity.h | 7 +++++++ engines/lastexpress/entities/entity39.h | 2 +- engines/lastexpress/entities/mertens.cpp | 28 ++++++++++------------------ engines/lastexpress/entities/mertens.h | 3 +++ 7 files changed, 53 insertions(+), 40 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index 66733acc16..eea9dda718 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -115,7 +115,7 @@ IMPLEMENT_FUNCTION_S(2, Coudert, bloodJacket) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); break; case kActionExitCompartment: @@ -142,7 +142,7 @@ IMPLEMENT_FUNCTION_SI(3, Coudert, enterExitCompartment, ObjectIndex) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); return; case kActionCallback: @@ -168,7 +168,7 @@ IMPLEMENT_FUNCTION(4, Coudert, callbackActionOnDirection) break; } - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); break; case kActionExitCompartment: @@ -191,7 +191,7 @@ IMPLEMENT_FUNCTION_SIII(5, Coudert, enterExitCompartment2, ObjectIndex, EntityPo break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); return; case kActionCallback: @@ -212,7 +212,7 @@ IMPLEMENT_FUNCTION_S(6, Coudert, playSound) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); break; case kActionEndSound: @@ -241,7 +241,7 @@ IMPLEMENT_FUNCTION_NOSETUP(7, Coudert, playSound16) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); break; case kActionEndSound: @@ -354,7 +354,7 @@ IMPLEMENT_FUNCTION_I(10, Coudert, updateFromTime, uint32) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); UPDATE_PARAM(params->param2, getState()->time, params->param1); @@ -377,7 +377,7 @@ IMPLEMENT_FUNCTION_I(11, Coudert, updateFromTicks, uint32) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1); @@ -451,7 +451,7 @@ IMPLEMENT_FUNCTION_II(13, Coudert, function13, bool, EntityIndex) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); if (!params->param2 && !params->param3) { @@ -573,7 +573,7 @@ IMPLEMENT_FUNCTION_I(14, Coudert, function14, EntityIndex) break; case kActionNone: - savegameBloodJacket(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); break; case kActionDefault: @@ -4164,14 +4164,4 @@ void Coudert::visitCompartment(const SavePoint &savepoint, EntityPosition positi } } -void Coudert::savegameBloodJacket() { - if (getProgress().jacket == kJacketBlood - && getEntities()->isDistanceBetweenEntities(kEntityCoudert, kEntityPlayer, 1000) - && !getEntities()->isInsideCompartments(kEntityPlayer) - && !getEntities()->checkFields10(kEntityPlayer)) { - setCallback(1); - setup_savegame(kSavegameTypeEvent, kEventMertensBloodJacket); - } -} - } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/coudert.h b/engines/lastexpress/entities/coudert.h index d06bb95ce9..45d13ce9bb 100644 --- a/engines/lastexpress/entities/coudert.h +++ b/engines/lastexpress/entities/coudert.h @@ -219,7 +219,6 @@ public: private: void visitCompartment(const SavePoint &savepoint, EntityPosition position, const char *seq1, ObjectIndex compartment, const char *seq2, const char *seq3, EntityPosition sittingPosition, ObjectIndex object, const char *seq4); - void savegameBloodJacket(); }; } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 120c1f2d85..a412dc9b65 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -253,6 +253,28 @@ void Entity::savegame(const SavePoint &savepoint) { } } +void Entity::savegameBloodJacket(SaveFunction *savegame) { + if (getProgress().jacket == kJacketBlood + && getEntities()->isDistanceBetweenEntities(_entityIndex, kEntityPlayer, 1000) + && !getEntities()->isInsideCompartments(kEntityPlayer) + && !getEntities()->checkFields10(kEntityPlayer)) { + setCallback(1); + + switch (_entityIndex) { + default: + break; + + case kEntityCoudert: + (*savegame)(kSavegameTypeEvent, kEventCoudertBloodJacket); + break; + + case kEntityMertens: + (*savegame)(kSavegameTypeEvent, kEventCoudertBloodJacket); + break; + } + } +} + void Entity::playSound(const SavePoint &savepoint, bool resetItem, SoundFlag flag) { EXPOSE_PARAMS(EntityData::EntityParametersSIIS) diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 4dca5424b1..01a19553ec 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -680,9 +680,11 @@ protected: typedef Common::Functor2 EnterFunction; typedef Common::Functor2 UpdateFunction; + typedef Common::Functor2 SaveFunction; #define WRAP_ENTER_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) #define WRAP_UPDATE_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) + #define WRAP_SAVE_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) /** * Saves the game @@ -693,6 +695,11 @@ protected: */ void savegame(const SavePoint &savepoint); + /** + * Saves the game before being found out with a blood covered jacket + */ + void savegameBloodJacket(SaveFunction *savegame); + /** * Play sound * diff --git a/engines/lastexpress/entities/entity39.h b/engines/lastexpress/entities/entity39.h index 4335a9566e..148bca5c33 100644 --- a/engines/lastexpress/entities/entity39.h +++ b/engines/lastexpress/entities/entity39.h @@ -72,4 +72,4 @@ private: } // End of namespace LastExpress -#endif // LASTEXPRESS_##define##_H +#endif // LASTEXPRESS_ENTITY39_H diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index 5672fe4d49..dd69aea2a6 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -37,14 +37,6 @@ namespace LastExpress { -#define SAVEGAME_BLOOD_JACKET() \ - if (getProgress().jacket == kJacketBlood \ - && getEntities()->isDistanceBetweenEntities(kEntityMertens, kEntityPlayer, 1000) \ - && !getEntities()->isInsideCompartments(kEntityPlayer) \ - && !getEntities()->checkFields10(kEntityPlayer)) { \ - setCallback(1); \ - setup_savegame(kSavegameTypeEvent, kEventMertensBloodJacket); \ - } Mertens::Mertens(LastExpressEngine *engine) : Entity(engine, kEntityMertens) { ADD_CALLBACK_FUNCTION(Mertens, reset); @@ -115,7 +107,7 @@ IMPLEMENT_FUNCTION_S(2, Mertens, bloodJacket) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionExitCompartment: @@ -142,7 +134,7 @@ IMPLEMENT_FUNCTION_SI(3, Mertens, enterExitCompartment, ObjectIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); return; case kActionCallback: @@ -163,7 +155,7 @@ IMPLEMENT_FUNCTION_SI(4, Mertens, enterExitCompartment2, ObjectIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); return; case kAction4: @@ -189,7 +181,7 @@ IMPLEMENT_FUNCTION_SIII(5, Mertens, enterExitCompartment3, ObjectIndex, EntityPo break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionExitCompartment: @@ -231,7 +223,7 @@ IMPLEMENT_FUNCTION(6, Mertens, callbackActionOnDirection) break; } - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionExitCompartment: @@ -254,7 +246,7 @@ IMPLEMENT_FUNCTION_S(7, Mertens, playSound) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionEndSound: @@ -281,7 +273,7 @@ IMPLEMENT_FUNCTION_S(8, Mertens, playSound16) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionEndSound: @@ -480,7 +472,7 @@ IMPLEMENT_FUNCTION_I(11, Mertens, function11, uint32) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); UPDATE_PARAM(params->param2, getState()->time, params->param1) @@ -548,7 +540,7 @@ IMPLEMENT_FUNCTION_II(13, Mertens, function13, bool, bool) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); if (!params->param2 && !params->param3) { UPDATE_PARAM_PROC(params->param4, getState()->timeTicks, 75) @@ -670,7 +662,7 @@ IMPLEMENT_FUNCTION_I(14, Mertens, function14, EntityIndex) break; case kActionNone: - SAVEGAME_BLOOD_JACKET(); + Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/mertens.h b/engines/lastexpress/entities/mertens.h index 31b7a97dcd..55c2a76140 100644 --- a/engines/lastexpress/entities/mertens.h +++ b/engines/lastexpress/entities/mertens.h @@ -210,6 +210,9 @@ public: DECLARE_FUNCTION(function53) DECLARE_NULL_FUNCTION() + +private: + void loadSceneFromPosition(); }; } // End of namespace LastExpress -- cgit v1.2.3 From 2b116592cb5654656d2b8118e1a3674e195bb00e Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 22:39:26 -0400 Subject: LASTEXPRESS: Remove LOADSCENE_FROM_POSITION macro --- engines/lastexpress/entities/mertens.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index dd69aea2a6..517ff76362 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -300,14 +300,6 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION_II(10, Mertens, updateEntity, CarIndex, EntityPosition) - -#define LOADSCENE_FROM_POSITION() \ - if (getData()->direction != kDirectionUp) { \ - getEntities()->loadSceneFromEntityPosition(getData()->car, (EntityPosition)(getData()->entityPosition + 750)); \ - } else { \ - getEntities()->loadSceneFromEntityPosition(getData()->car, (EntityPosition)(getData()->entityPosition - 750), true); \ - } - switch (savepoint.action) { default: break; @@ -406,7 +398,7 @@ IMPLEMENT_FUNCTION_II(10, Mertens, updateEntity, CarIndex, EntityPosition) ENTITY_PARAM(0, 7) = 0; if (params->param1 != 3 || (params->param2 != kPosition_8200 && params->param2 != kPosition_9510)) { - LOADSCENE_FROM_POSITION(); + loadSceneFromPosition(); break; } @@ -438,31 +430,29 @@ IMPLEMENT_FUNCTION_II(10, Mertens, updateEntity, CarIndex, EntityPosition) break; } - LOADSCENE_FROM_POSITION(); + loadSceneFromPosition(); break; case 4: getAction()->playAnimation(kEventMertensKronosConcertInvitation); ENTITY_PARAM(2, 4) = 0; - LOADSCENE_FROM_POSITION(); + loadSceneFromPosition(); break; case 5: getAction()->playAnimation(getData()->entityPosition < getEntityData(kEntityPlayer)->entityPosition ? kEventMertensAskTylerCompartmentD : kEventMertensAskTylerCompartment); - LOADSCENE_FROM_POSITION(); + loadSceneFromPosition(); break; case 6: getAction()->playAnimation(kEventMertensDontMakeBed); - LOADSCENE_FROM_POSITION(); + loadSceneFromPosition(); ENTITY_PARAM(0, 4) = 0; break; } break; } - -#undef LOADSCENE_FROM_POSITION IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// @@ -4098,4 +4088,15 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_NULL_FUNCTION(54, Mertens) +////////////////////////////////////////////////////////////////////////// +// Helper functions +////////////////////////////////////////////////////////////////////////// + +void Mertens::loadSceneFromPosition() { + if (getData()->direction != kDirectionUp) + getEntities()->loadSceneFromEntityPosition(getData()->car, (EntityPosition)(getData()->entityPosition + 750)); + else + getEntities()->loadSceneFromEntityPosition(getData()->car, (EntityPosition)(getData()->entityPosition - 750), true); +} + } // End of namespace LastExpress -- cgit v1.2.3 From 04a181a787befb9ef5bc2a3d524f622a5fcfaeeb Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 15 Jul 2012 22:48:00 -0400 Subject: LASTEXPRESS: Replace 2 macros in Sophie entity implementation --- engines/lastexpress/entities/sophie.cpp | 68 ++++++++++++++++++--------------- engines/lastexpress/entities/sophie.h | 4 ++ 2 files changed, 42 insertions(+), 30 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/sophie.cpp b/engines/lastexpress/entities/sophie.cpp index c2f25b7eb1..10c414763c 100644 --- a/engines/lastexpress/entities/sophie.cpp +++ b/engines/lastexpress/entities/sophie.cpp @@ -31,31 +31,6 @@ namespace LastExpress { -#define CHAPTER_IMPLEMENTATION() \ - switch (savepoint.action) { \ - default: \ - break; \ - case kActionNone: \ - setup_chaptersHandler(); \ - break; \ - case kActionDefault: \ - getEntities()->clearSequences(kEntitySophie); \ - getData()->entityPosition = kPosition_4840; \ - getData()->location = kLocationInsideCompartment; \ - getData()->car = kCarRedSleeping; \ - getData()->clothes = kClothesDefault; \ - getData()->inventoryItem = kItemNone; \ - break; \ - } - -#define DEFAULT_ACTION_IMPLEMENTATION() \ - if (savepoint.action == kActionDefault) { \ - getData()->entityPosition = kPosition_4840; \ - getData()->location = kLocationInsideCompartment; \ - getData()->car = kCarRedSleeping; \ - getEntities()->clearSequences(kEntitySophie); \ - } - Sophie::Sophie(LastExpressEngine *engine) : Entity(engine, kEntitySophie) { ADD_CALLBACK_FUNCTION(Sophie, reset); ADD_CALLBACK_FUNCTION(Sophie, updateEntity); @@ -217,27 +192,27 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(5, Sophie, function5) - DEFAULT_ACTION_IMPLEMENTATION() + handleAction(savepoint); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(6, Sophie, chapter2) - CHAPTER_IMPLEMENTATION() + handleChapter(savepoint); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(7, Sophie, chapter3) - CHAPTER_IMPLEMENTATION() + handleChapter(savepoint); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(8, Sophie, chapter4) - CHAPTER_IMPLEMENTATION() + handleChapter(savepoint); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(9, Sophie, function9) - DEFAULT_ACTION_IMPLEMENTATION() + handleAction(savepoint); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// @@ -271,4 +246,37 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_NULL_FUNCTION(12, Sophie) +////////////////////////////////////////////////////////////////////////// +// Helpers functions +////////////////////////////////////////////////////////////////////////// + +void Sophie::handleAction(const SavePoint &savepoint) { + if (savepoint.action == kActionDefault) { + getData()->entityPosition = kPosition_4840; + getData()->location = kLocationInsideCompartment; + getData()->car = kCarRedSleeping; + getEntities()->clearSequences(kEntitySophie); + } +} + +void Sophie::handleChapter(const SavePoint &savepoint) { + switch (savepoint.action) { + default: + break; + + case kActionNone: + setup_chaptersHandler(); + break; + + case kActionDefault: + getEntities()->clearSequences(kEntitySophie); + getData()->entityPosition = kPosition_4840; + getData()->location = kLocationInsideCompartment; + getData()->car = kCarRedSleeping; + getData()->clothes = kClothesDefault; + getData()->inventoryItem = kItemNone; + break; + } +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/sophie.h b/engines/lastexpress/entities/sophie.h index c2ca348027..47cfa8065c 100644 --- a/engines/lastexpress/entities/sophie.h +++ b/engines/lastexpress/entities/sophie.h @@ -88,6 +88,10 @@ public: DECLARE_FUNCTION(chapter5Handler) DECLARE_NULL_FUNCTION() + +private: + void handleAction(const SavePoint &savepoint); + void handleChapter(const SavePoint &savepoint); }; } // End of namespace LastExpress -- cgit v1.2.3 From d830c0edc9e53b5a3274535139179c2ef029a5d5 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Mon, 16 Jul 2012 23:47:49 -0400 Subject: LASTEXPRESS: Replace TIME_CHECK_SAVEPOINT and TIME_CHECK_OBJECT macros --- engines/lastexpress/entities/abbot.cpp | 4 ++-- engines/lastexpress/entities/august.cpp | 6 +++--- engines/lastexpress/entities/coudert.cpp | 12 ++++++------ engines/lastexpress/entities/entity.cpp | 19 +++++++++++++++++++ engines/lastexpress/entities/entity.h | 7 +++++++ engines/lastexpress/entities/entity_intern.h | 22 +++++----------------- engines/lastexpress/entities/kahina.cpp | 2 +- engines/lastexpress/entities/mertens.cpp | 2 +- engines/lastexpress/entities/milos.cpp | 4 ++-- engines/lastexpress/entities/rebecca.cpp | 2 +- engines/lastexpress/entities/tatiana.cpp | 2 +- 11 files changed, 48 insertions(+), 34 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index eef64bdf07..9280068fae 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -415,7 +415,7 @@ IMPLEMENT_FUNCTION(22, Abbot, function22) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1971000, params->param1, kEntityAbbot, kEntityServers0, kAction218586752); + Entity::timeCheckSavepoint(kTime1971000, params->param1, kEntityAbbot, kEntityServers0, kAction218586752); if (getState()->time > kTime1989000 && getEntities()->isSomebodyInsideRestaurantOrSalon()) { getData()->inventoryItem = kItemNone; @@ -1319,7 +1319,7 @@ IMPLEMENT_FUNCTION(41, Abbot, chapter4Handler) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime2358000, params->param1, kEntityAbbot, kEntityServers0, kAction218128129); + Entity::timeCheckSavepoint(kTime2358000, params->param1, kEntityAbbot, kEntityServers0, kAction218128129); if (getState()->time > kTime2389500 && getEntities()->isSomebodyInsideRestaurantOrSalon()) setup_function42(); diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index 86c02e4301..f255d041f8 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -1811,7 +1811,7 @@ IMPLEMENT_FUNCTION(36, August, chapter2Handler) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1755000, params->param2, kEntityAugust, kEntityServers0, kAction252568704); + Entity::timeCheckSavepoint(kTime1755000, params->param2, kEntityAugust, kEntityServers0, kAction252568704); if (getState()->time > kTime1773000 && params->param1 && getEntities()->isSomebodyInsideRestaurantOrSalon()) { getData()->inventoryItem = kItemNone; @@ -1960,7 +1960,7 @@ IMPLEMENT_FUNCTION(38, August, function38) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1801800, params->param1, kEntityAugust, kEntityRebecca, kAction155980128); + Entity::timeCheckSavepoint(kTime1801800, params->param1, kEntityAugust, kEntityRebecca, kAction155980128); TIME_CHECK_CALLBACK(kTime1820700, params->param2, 3, setup_callbackActionRestaurantOrSalon); break; @@ -2210,7 +2210,7 @@ IMPLEMENT_FUNCTION(43, August, chapter3Handler) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1953000, params->param2, kEntityAugust, kEntityAnna, kAction291662081); + Entity::timeCheckSavepoint(kTime1953000, params->param2, kEntityAugust, kEntityAnna, kAction291662081); // Set as same position as Anna if (params->param1) { diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index eea9dda718..77cddddf48 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -2285,9 +2285,9 @@ label_callback_10: if (!ENTITY_PARAM(0, 2)) break; - TIME_CHECK_OBJECT(kTime1107000, params->param4, kObject111, kObjectLocation2); - TIME_CHECK_OBJECT(kTime1161000, params->param5, kObject111, kObjectLocation3); - TIME_CHECK_OBJECT(kTime1206000, params->param6, kObject111, kObjectLocation4); + timeCheckObject(kTime1107000, params->param4, kObject111, kObjectLocation2); + timeCheckObject(kTime1161000, params->param5, kObject111, kObjectLocation3); + timeCheckObject(kTime1206000, params->param6, kObject111, kObjectLocation4); break; case kAction1: @@ -2835,9 +2835,9 @@ label_callback_18: label_callback_19: if (ENTITY_PARAM(0, 2)) { - TIME_CHECK_OBJECT(kTime2025000, params->param7, kObject111, kObjectLocation7); - TIME_CHECK_OBJECT(kTime2133000, params->param8, kObject111, kObjectLocation8); - TIME_CHECK_OBJECT(kTime2173500, CURRENT_PARAM(1, 1), kObject111, kObjectLocation9); + timeCheckObject(kTime2025000, params->param7, kObject111, kObjectLocation7); + timeCheckObject(kTime2133000, params->param8, kObject111, kObjectLocation8); + timeCheckObject(kTime2173500, CURRENT_PARAM(1, 1), kObject111, kObjectLocation9); } break; diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index a412dc9b65..743adc3201 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -29,6 +29,7 @@ #include "lastexpress/game/action.h" #include "lastexpress/game/entities.h" #include "lastexpress/game/logic.h" +#include "lastexpress/game/object.h" #include "lastexpress/game/scenes.h" #include "lastexpress/game/state.h" #include "lastexpress/game/savegame.h" @@ -592,4 +593,22 @@ void Entity::callbackAction() { getSavePoints()->call(_entityIndex, _entityIndex, kActionCallback); } +////////////////////////////////////////////////////////////////////////// +// Helper functions +////////////////////////////////////////////////////////////////////////// + +void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + getSavePoints()->push(entity1, entity2, action); + } +} + +void Entity::timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex object, ObjectLocation location) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + getObjects()->updateLocation2(object, location); + } +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 01a19553ec..f29d78e181 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -845,6 +845,13 @@ protected: * Store the current callback information and perform the callback action */ void callbackAction(); + + ////////////////////////////////////////////////////////////////////////// + // Helper functions + ////////////////////////////////////////////////////////////////////////// + + void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); + void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); }; diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index c622ff9f0e..64814a1b40 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -326,12 +326,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_SAVEPOINT(timeValue, parameter, entity1, entity2, action) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - getSavePoints()->push(entity1, entity2, action); \ - } - #define TIME_CHECK_CALLBACK(timeValue, parameter, callback, function) \ if (getState()->time > timeValue && !parameter) { \ parameter = 1; \ @@ -366,11 +360,11 @@ void class::setup_##name() { \ #define TIME_CHECK_CALLBACK_INVENTORY(timeValue, parameter, callback, function) \ if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - getData()->inventoryItem = kItemNone; \ - setCallback(callback); \ - function(); \ - break; \ + parameter = 1; \ + getData()->inventoryItem = kItemNone; \ + setCallback(callback); \ + function(); \ + break; \ } #define TIME_CHECK_CALLBACK_ACTION(timeValue, parameter) \ @@ -389,12 +383,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_OBJECT(timeValue, parameter, object, location) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - getObjects()->updateLocation2(object, location); \ - } - #define TIME_CHECK_CAR(timeValue, parameter, callback, function) {\ if ((getState()->time <= timeValue && !getEntities()->isPlayerInCar(kCarGreenSleeping)) || !parameter) \ parameter = (uint)getState()->time + 75; \ diff --git a/engines/lastexpress/entities/kahina.cpp b/engines/lastexpress/entities/kahina.cpp index 0c4045097a..6bb2e6b90a 100644 --- a/engines/lastexpress/entities/kahina.cpp +++ b/engines/lastexpress/entities/kahina.cpp @@ -267,7 +267,7 @@ IMPLEMENT_FUNCTION(11, Kahina, chapter1Handler) return; if (getProgress().jacket != kJacketOriginal) - TIME_CHECK_SAVEPOINT(kTime1107000, params->param1, kEntityKahina, kEntityMertens, kAction238732837); + Entity::timeCheckSavepoint(kTime1107000, params->param1, kEntityKahina, kEntityMertens, kAction238732837); if (getProgress().eventMertensKronosInvitation) setup_function12(); diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index 517ff76362..328c8e88d8 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -2993,7 +2993,7 @@ IMPLEMENT_FUNCTION(42, Mertens, function42) getData()->inventoryItem = kItemInvalid; if (!params->param2) { - TIME_CHECK_SAVEPOINT(kTime1125000, params->param3, kEntityMertens, kEntityMahmud, kAction170483072); + Entity::timeCheckSavepoint(kTime1125000, params->param3, kEntityMertens, kEntityMahmud, kAction170483072); if (params->param4 != kTimeInvalid && getState()->time > kTimeCityChalons) { diff --git a/engines/lastexpress/entities/milos.cpp b/engines/lastexpress/entities/milos.cpp index 21f3b06896..c33a8b887e 100644 --- a/engines/lastexpress/entities/milos.cpp +++ b/engines/lastexpress/entities/milos.cpp @@ -720,7 +720,7 @@ IMPLEMENT_FUNCTION(15, Milos, chapter1Handler) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1071000, params->param3, kEntityMilos, kEntityServers1, kAction223002560); + Entity::timeCheckSavepoint(kTime1071000, params->param3, kEntityMilos, kEntityServers1, kAction223002560); if (getState()->time > kTime1089000 && getEntities()->isSomebodyInsideRestaurantOrSalon()) { setup_function16(); @@ -1534,7 +1534,7 @@ IMPLEMENT_FUNCTION(29, Milos, chapter4Handler) TIME_CHECK_PLAYSOUND_MILOS(kTime2370600, params->param5, "Mil4015"); - TIME_CHECK_SAVEPOINT(kTime2407500, params->param6, kEntityMilos, kEntityVesna, kAction55996766); + Entity::timeCheckSavepoint(kTime2407500, params->param6, kEntityMilos, kEntityVesna, kAction55996766); break; case kActionCallback: diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 4f7be385ce..3ef266994f 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -841,7 +841,7 @@ IMPLEMENT_FUNCTION(24, Rebecca, function24) break; case kActionNone: - TIME_CHECK_SAVEPOINT(kTime1134000, params->param2, kEntityRebecca, kEntityServers0, kAction223712416); + Entity::timeCheckSavepoint(kTime1134000, params->param2, kEntityRebecca, kEntityServers0, kAction223712416); if (!params->param1) break; diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index 3b9cc6d322..b15a0a18b2 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -440,7 +440,7 @@ IMPLEMENT_FUNCTION(19, Tatiana, chapter1Handler) } label_tatiana_chapter1_2: - TIME_CHECK_SAVEPOINT(kTime1084500, params->param7, kEntityTatiana, kEntityPascale, kAction257489762); + Entity::timeCheckSavepoint(kTime1084500, params->param7, kEntityTatiana, kEntityPascale, kAction257489762); if (params->param1) { UPDATE_PARAM(params->param8, getState()->timeTicks, 90); -- cgit v1.2.3 From 6a8d037af1703f6820ae2d42217e2bc8367e46b8 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Mon, 16 Jul 2012 23:56:35 -0400 Subject: LASTEXPRESS: Fix variable shadowing and update comments --- engines/lastexpress/entities/entity.cpp | 6 +++--- engines/lastexpress/entities/entity.h | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 743adc3201..1ad6d08035 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -254,7 +254,7 @@ void Entity::savegame(const SavePoint &savepoint) { } } -void Entity::savegameBloodJacket(SaveFunction *savegame) { +void Entity::savegameBloodJacket(SaveFunction *saveFunction) { if (getProgress().jacket == kJacketBlood && getEntities()->isDistanceBetweenEntities(_entityIndex, kEntityPlayer, 1000) && !getEntities()->isInsideCompartments(kEntityPlayer) @@ -266,11 +266,11 @@ void Entity::savegameBloodJacket(SaveFunction *savegame) { break; case kEntityCoudert: - (*savegame)(kSavegameTypeEvent, kEventCoudertBloodJacket); + (*saveFunction)(kSavegameTypeEvent, kEventCoudertBloodJacket); break; case kEntityMertens: - (*savegame)(kSavegameTypeEvent, kEventCoudertBloodJacket); + (*saveFunction)(kSavegameTypeEvent, kEventCoudertBloodJacket); break; } } diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index f29d78e181..5ba78abc17 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -696,9 +696,11 @@ protected: void savegame(const SavePoint &savepoint); /** - * Saves the game before being found out with a blood covered jacket + * Saves the game before being found out with a blood covered jacket. + * + * @param saveFunction The setup function to call to save the game */ - void savegameBloodJacket(SaveFunction *savegame); + void savegameBloodJacket(SaveFunction *saveFunction); /** * Play sound @@ -826,7 +828,7 @@ protected: * @param positionTo The position to. * @param sequenceTo The sequence to. * @param enterFunction The enter/exit compartment function. - * @param enterFunction The update entity function. + * @param updateFunction The update entity function. */ void goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo, Entity::EnterFunction *enterFunction, Entity::UpdateFunction *updateFunction); -- cgit v1.2.3 From 2c4518d6154a0ae9772fe19a629f05c750ab19c8 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 19:22:49 -0400 Subject: LASTEXPRESS: Move some macros to entity.h --- engines/lastexpress/entities/entity.h | 23 +++++++++++++++++++++++ engines/lastexpress/entities/entity_intern.h | 20 -------------------- 2 files changed, 23 insertions(+), 20 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 5ba78abc17..7ff574ddbe 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -41,6 +41,29 @@ class Sequence; class SequenceFrame; struct SavePoint; + +////////////////////////////////////////////////////////////////////////// +// Callbacks +#define ENTITY_CALLBACK(class, name, pointer) \ + Common::Functor1Mem(pointer, &class::name) + +#define ADD_CALLBACK_FUNCTION(class, name) \ + _callbacks.push_back(new ENTITY_CALLBACK(class, name, this)); + +#define ADD_NULL_FUNCTION() \ + _callbacks.push_back(new ENTITY_CALLBACK(Entity, nullfunction, this)); + +////////////////////////////////////////////////////////////////////////// +// Parameters macros +////////////////////////////////////////////////////////////////////////// +#define CURRENT_PARAM(index, id) \ + ((EntityData::EntityParametersIIII*)_data->getCurrentParameters(index))->param##id + +#define ENTITY_PARAM(index, id) \ + ((EntityData::EntityParametersIIII*)_data->getParameters(8, index))->param##id + + + class EntityData : Common::Serializable { public: diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 64814a1b40..576765620f 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -25,17 +25,6 @@ namespace LastExpress { -////////////////////////////////////////////////////////////////////////// -// Callbacks -#define ENTITY_CALLBACK(class, name, pointer) \ - Common::Functor1Mem(pointer, &class::name) - -#define ADD_CALLBACK_FUNCTION(class, name) \ - _callbacks.push_back(new ENTITY_CALLBACK(class, name, this)); - -#define ADD_NULL_FUNCTION() \ - _callbacks.push_back(new ENTITY_CALLBACK(Entity, nullfunction, this)); - ////////////////////////////////////////////////////////////////////////// // Declaration ////////////////////////////////////////////////////////////////////////// @@ -307,15 +296,6 @@ void class::setup_##name() { \ getEntities()->resetState(entity); \ ((class *)getEntities()->get(entity))->function(); -////////////////////////////////////////////////////////////////////////// -// Parameters macros (for default IIII parameters) -////////////////////////////////////////////////////////////////////////// -#define CURRENT_PARAM(index, id) \ - ((EntityData::EntityParametersIIII*)_data->getCurrentParameters(index))->param##id - -#define ENTITY_PARAM(index, id) \ - ((EntityData::EntityParametersIIII*)_data->getParameters(8, index))->param##id - ////////////////////////////////////////////////////////////////////////// // Time check macros ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 5d4a8f1e15c9b90209cbd4572ef17552cc06d65c Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 20:27:23 -0400 Subject: LASTEXPRESS: Remove use of function wrappers in shared entity functions --- engines/lastexpress/entities/alouan.cpp | 8 ++++---- engines/lastexpress/entities/coudert.cpp | 20 ++++++++++---------- engines/lastexpress/entities/entity.cpp | 20 ++++++++++---------- engines/lastexpress/entities/entity.h | 22 ++++++++-------------- engines/lastexpress/entities/hadija.cpp | 8 ++++---- engines/lastexpress/entities/mertens.cpp | 20 ++++++++++---------- 6 files changed, 46 insertions(+), 52 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/alouan.cpp b/engines/lastexpress/entities/alouan.cpp index 8e56ae4c5b..589b712b16 100644 --- a/engines/lastexpress/entities/alouan.cpp +++ b/engines/lastexpress/entities/alouan.cpp @@ -86,22 +86,22 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(6, Alouan, compartment6) - Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Cf", "621Df", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment)); + Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Cf", "621Df"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(7, Alouan, compartment8) - Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Ch", "621Dh", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment)); + Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Ch", "621Dh"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(8, Alouan, compartment6to8) - Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Bf", kObjectCompartment8, kPosition_2740, "621Ah", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Alouan, setup_updateEntity)); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "621Bf", kObjectCompartment8, kPosition_2740, "621Ah"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(9, Alouan, compartment8to6) - Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Bh", kObjectCompartment6, kPosition_4070, "621Af", WRAP_ENTER_FUNCTION(Alouan, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Alouan, setup_updateEntity)); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "621Bh", kObjectCompartment6, kPosition_4070, "621Af"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index 77cddddf48..e79d4cdff7 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -115,7 +115,7 @@ IMPLEMENT_FUNCTION_S(2, Coudert, bloodJacket) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionExitCompartment: @@ -142,7 +142,7 @@ IMPLEMENT_FUNCTION_SI(3, Coudert, enterExitCompartment, ObjectIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); return; case kActionCallback: @@ -168,7 +168,7 @@ IMPLEMENT_FUNCTION(4, Coudert, callbackActionOnDirection) break; } - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionExitCompartment: @@ -191,7 +191,7 @@ IMPLEMENT_FUNCTION_SIII(5, Coudert, enterExitCompartment2, ObjectIndex, EntityPo break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); return; case kActionCallback: @@ -212,7 +212,7 @@ IMPLEMENT_FUNCTION_S(6, Coudert, playSound) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionEndSound: @@ -241,7 +241,7 @@ IMPLEMENT_FUNCTION_NOSETUP(7, Coudert, playSound16) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionEndSound: @@ -354,7 +354,7 @@ IMPLEMENT_FUNCTION_I(10, Coudert, updateFromTime, uint32) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); UPDATE_PARAM(params->param2, getState()->time, params->param1); @@ -377,7 +377,7 @@ IMPLEMENT_FUNCTION_I(11, Coudert, updateFromTicks, uint32) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1); @@ -451,7 +451,7 @@ IMPLEMENT_FUNCTION_II(13, Coudert, function13, bool, EntityIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); if (!params->param2 && !params->param3) { @@ -573,7 +573,7 @@ IMPLEMENT_FUNCTION_I(14, Coudert, function14, EntityIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Coudert, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionDefault: diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 1ad6d08035..4c661a4915 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -254,7 +254,7 @@ void Entity::savegame(const SavePoint &savepoint) { } } -void Entity::savegameBloodJacket(SaveFunction *saveFunction) { +void Entity::savegameBloodJacket() { if (getProgress().jacket == kJacketBlood && getEntities()->isDistanceBetweenEntities(_entityIndex, kEntityPlayer, 1000) && !getEntities()->isInsideCompartments(kEntityPlayer) @@ -266,11 +266,11 @@ void Entity::savegameBloodJacket(SaveFunction *saveFunction) { break; case kEntityCoudert: - (*saveFunction)(kSavegameTypeEvent, kEventCoudertBloodJacket); + setup_savegame(kSavegameTypeEvent, kEventCoudertBloodJacket); break; case kEntityMertens: - (*saveFunction)(kSavegameTypeEvent, kEventCoudertBloodJacket); + setup_savegame(kSavegameTypeEvent, kEventCoudertBloodJacket); break; } } @@ -488,7 +488,7 @@ void Entity::enterExitCompartment(const SavePoint &savepoint, EntityPosition pos } } -void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo, Entity::EnterFunction *enterFunction) { +void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo) { switch (savepoint.action) { default: break; @@ -496,7 +496,7 @@ void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartment case kActionDefault: getData()->entityPosition = positionFrom; setCallback(1); - (*enterFunction)(sequenceFrom.c_str(), compartmentFrom); + setup_enterExitCompartment(sequenceFrom.c_str(), compartmentFrom); break; case kActionCallback: @@ -506,7 +506,7 @@ void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartment case 1: setCallback(2); - (*enterFunction)(sequenceTo.c_str(), compartmentFrom); + setup_enterExitCompartment(sequenceTo.c_str(), compartmentFrom); break; case 2: @@ -519,7 +519,7 @@ void Entity::goToCompartment(const SavePoint &savepoint, ObjectIndex compartment } } -void Entity::goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo, Entity::EnterFunction *enterFunction, Entity::UpdateFunction *updateFunction) { +void Entity::goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo) { switch (savepoint.action) { default: break; @@ -528,7 +528,7 @@ void Entity::goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIn getData()->entityPosition = positionFrom; getData()->location = kLocationOutsideCompartment; setCallback(1); - (*enterFunction)(sequenceFrom.c_str(), compartmentFrom); + setup_enterExitCompartment(sequenceFrom.c_str(), compartmentFrom); break; case kActionCallback: @@ -538,12 +538,12 @@ void Entity::goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIn case 1: setCallback(2); - (*updateFunction)(kCarGreenSleeping, positionTo); + setup_updateEntity(kCarGreenSleeping, positionTo); break; case 2: setCallback(3); - (*enterFunction)(sequenceTo.c_str(), compartmentTo); + setup_enterExitCompartment(sequenceTo.c_str(), compartmentTo); break; case 3: diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 7ff574ddbe..77c3793890 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -689,6 +689,11 @@ public: virtual void setup_chapter4() = 0; virtual void setup_chapter5() = 0; + // Shared functions + virtual void setup_savegame(SavegameType, uint32) { error("[Entity::setup_savegame] Trying to call the parent setup function. Use the specific entity function directly"); } + virtual void setup_enterExitCompartment(const char *, ObjectIndex) { error("[Entity::setup_enterExitCompartment] Trying to call the parent setup function. Use the specific entity function directly"); } + virtual void setup_updateEntity(CarIndex, EntityPosition) { error("[Entity::setup_updateEntity] Trying to call the parent setup function. Use the specific entity function directly"); } + // Serializable void saveLoadWithSerializer(Common::Serializer &ser) { _data->saveLoadWithSerializer(ser); } @@ -701,14 +706,6 @@ protected: EntityData *_data; Common::Array _callbacks; - typedef Common::Functor2 EnterFunction; - typedef Common::Functor2 UpdateFunction; - typedef Common::Functor2 SaveFunction; - - #define WRAP_ENTER_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) - #define WRAP_UPDATE_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) - #define WRAP_SAVE_FUNCTION(className, method) new Common::Functor2Mem(this, &className::method) - /** * Saves the game * @@ -723,7 +720,7 @@ protected: * * @param saveFunction The setup function to call to save the game */ - void savegameBloodJacket(SaveFunction *saveFunction); + void savegameBloodJacket(); /** * Play sound @@ -836,9 +833,8 @@ protected: * @param positionFrom The position from. * @param sequenceFrom The sequence from. * @param sequenceTo The sequence to. - * @param enterFunction The enter/exit compartment function. */ - void goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo, EnterFunction *enterFunction); + void goToCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, Common::String sequenceTo); /** * Go to compartment from compartment. @@ -850,10 +846,8 @@ protected: * @param compartmentTo The compartment to. * @param positionTo The position to. * @param sequenceTo The sequence to. - * @param enterFunction The enter/exit compartment function. - * @param updateFunction The update entity function. */ - void goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo, Entity::EnterFunction *enterFunction, Entity::UpdateFunction *updateFunction); + void goToCompartmentFromCompartment(const SavePoint &savepoint, ObjectIndex compartmentFrom, EntityPosition positionFrom, Common::String sequenceFrom, ObjectIndex compartmentTo, EntityPosition positionTo, Common::String sequenceTo); /** * Updates the position diff --git a/engines/lastexpress/entities/hadija.cpp b/engines/lastexpress/entities/hadija.cpp index 2dd239d4c9..8d757d54fd 100644 --- a/engines/lastexpress/entities/hadija.cpp +++ b/engines/lastexpress/entities/hadija.cpp @@ -86,22 +86,22 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(6, Hadija, compartment6) - Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Cf", "619Df", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment)); + Entity::goToCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Cf", "619Df"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(7, Hadija, compartment8) - Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Ch", "619Dh", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment)); + Entity::goToCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Ch", "619Dh"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(8, Hadija, compartment6to8) - Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Bf", kObjectCompartment8, kPosition_2740, "619Ah", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Hadija, setup_updateEntity)); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment6, kPosition_4070, "619Bf", kObjectCompartment8, kPosition_2740, "619Ah"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_FUNCTION(9, Hadija, compartment8to6) - Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Bh", kObjectCompartment6, kPosition_4070, "619Af", WRAP_ENTER_FUNCTION(Hadija, setup_enterExitCompartment), WRAP_UPDATE_FUNCTION(Hadija, setup_updateEntity)); + Entity::goToCompartmentFromCompartment(savepoint, kObjectCompartment8, kPosition_2740, "619Bh", kObjectCompartment6, kPosition_4070, "619Af"); IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index 328c8e88d8..37e7bf5ca6 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -107,7 +107,7 @@ IMPLEMENT_FUNCTION_S(2, Mertens, bloodJacket) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionExitCompartment: @@ -134,7 +134,7 @@ IMPLEMENT_FUNCTION_SI(3, Mertens, enterExitCompartment, ObjectIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); return; case kActionCallback: @@ -155,7 +155,7 @@ IMPLEMENT_FUNCTION_SI(4, Mertens, enterExitCompartment2, ObjectIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); return; case kAction4: @@ -181,7 +181,7 @@ IMPLEMENT_FUNCTION_SIII(5, Mertens, enterExitCompartment3, ObjectIndex, EntityPo break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionExitCompartment: @@ -223,7 +223,7 @@ IMPLEMENT_FUNCTION(6, Mertens, callbackActionOnDirection) break; } - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionExitCompartment: @@ -246,7 +246,7 @@ IMPLEMENT_FUNCTION_S(7, Mertens, playSound) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionEndSound: @@ -273,7 +273,7 @@ IMPLEMENT_FUNCTION_S(8, Mertens, playSound16) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionEndSound: @@ -462,7 +462,7 @@ IMPLEMENT_FUNCTION_I(11, Mertens, function11, uint32) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); UPDATE_PARAM(params->param2, getState()->time, params->param1) @@ -530,7 +530,7 @@ IMPLEMENT_FUNCTION_II(13, Mertens, function13, bool, bool) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); if (!params->param2 && !params->param3) { UPDATE_PARAM_PROC(params->param4, getState()->timeTicks, 75) @@ -652,7 +652,7 @@ IMPLEMENT_FUNCTION_I(14, Mertens, function14, EntityIndex) break; case kActionNone: - Entity::savegameBloodJacket(WRAP_SAVE_FUNCTION(Mertens, setup_savegame)); + Entity::savegameBloodJacket(); break; case kActionDefault: -- cgit v1.2.3 From c589e69ec9f29e59fc4358e5045fcc613f9ab6a8 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 21:14:48 -0400 Subject: LASTEXPRESS: Replace TIME_CHECK_CALLBACK_ACTION macro --- engines/lastexpress/entities/boutarel.cpp | 3 ++- engines/lastexpress/entities/entity.cpp | 10 ++++++++++ engines/lastexpress/entities/entity.h | 1 + engines/lastexpress/entities/entity_intern.h | 7 ------- engines/lastexpress/entities/gendarmes.cpp | 3 ++- 5 files changed, 15 insertions(+), 9 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/boutarel.cpp b/engines/lastexpress/entities/boutarel.cpp index 95ec37bf50..ab5f019c49 100644 --- a/engines/lastexpress/entities/boutarel.cpp +++ b/engines/lastexpress/entities/boutarel.cpp @@ -476,7 +476,8 @@ IMPLEMENT_FUNCTION_IS(17, Boutarel, function17, TimeValue) break; case kActionNone: - TIME_CHECK_CALLBACK_ACTION(params->param1, params->param6); + if (Entity::timeCheckCallbackAction((TimeValue)params->param1, params->param6)) + break; if (params->param5) { UPDATE_PARAM(params->param7, getState()->timeTicks, 90) diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 4c661a4915..9cb6825f79 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -611,4 +611,14 @@ void Entity::timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex o } } +bool Entity::timeCheckCallbackAction(TimeValue timeValue, uint ¶meter) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + callbackAction(); + return true; + } + + return false; +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 77c3793890..fb5c958464 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -871,6 +871,7 @@ protected: void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); + bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter); }; diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 576765620f..cb4f7b941b 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -347,13 +347,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_CALLBACK_ACTION(timeValue, parameter) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - callbackAction(); \ - break; \ - } - #define TIME_CHECK_PLAYSOUND_UPDATEPOSITION(timeValue, parameter, callback, sound, position) \ if (getState()->time > timeValue && !parameter) { \ parameter = 1; \ diff --git a/engines/lastexpress/entities/gendarmes.cpp b/engines/lastexpress/entities/gendarmes.cpp index 877c0c29b3..fe9f6f0aa5 100644 --- a/engines/lastexpress/entities/gendarmes.cpp +++ b/engines/lastexpress/entities/gendarmes.cpp @@ -551,7 +551,8 @@ void Gendarmes::arrest(const SavePoint &savepoint, bool shouldPlaySound, SoundFl case kActionNone: if (checkCallback) { EXPOSE_PARAMS(EntityData::EntityParametersIIII); - TIME_CHECK_CALLBACK_ACTION(params->param1, params->param2); + if (Entity::timeCheckCallbackAction((TimeValue)params->param1, params->param2)) + break; } if (shouldUpdateEntity) { -- cgit v1.2.3 From 2e20e1d1e259dc6d9de8a90fa8417245f5a481b4 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 21:41:28 -0400 Subject: LASTEXPRESS: Replace TIME_CHECK_PLAYSOUND_UPDATEPOSITION macro --- engines/lastexpress/entities/entity.cpp | 13 +++++++++++++ engines/lastexpress/entities/entity.h | 2 ++ engines/lastexpress/entities/entity_intern.h | 9 --------- engines/lastexpress/entities/hadija.cpp | 3 ++- engines/lastexpress/entities/yasmin.cpp | 6 ++++-- 5 files changed, 21 insertions(+), 12 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 9cb6825f79..43f039df43 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -621,4 +621,17 @@ bool Entity::timeCheckCallbackAction(TimeValue timeValue, uint ¶meter) { return false; } +bool Entity::timeCheckPlaySoundUpdatePosition(TimeValue timeValue, uint ¶meter, byte callback, const char* sound, EntityPosition position) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + getData()->entityPosition = position; + setCallback(callback); + setup_playSound(sound); + return true; + } + + return false; +} + + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index fb5c958464..3370659c6e 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -693,6 +693,7 @@ public: virtual void setup_savegame(SavegameType, uint32) { error("[Entity::setup_savegame] Trying to call the parent setup function. Use the specific entity function directly"); } virtual void setup_enterExitCompartment(const char *, ObjectIndex) { error("[Entity::setup_enterExitCompartment] Trying to call the parent setup function. Use the specific entity function directly"); } virtual void setup_updateEntity(CarIndex, EntityPosition) { error("[Entity::setup_updateEntity] Trying to call the parent setup function. Use the specific entity function directly"); } + virtual void setup_playSound(const char*) { error("[Entity::setup_playSound] Trying to call the parent setup function. Use the specific entity function directly"); } // Serializable void saveLoadWithSerializer(Common::Serializer &ser) { _data->saveLoadWithSerializer(ser); } @@ -872,6 +873,7 @@ protected: void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter); + bool timeCheckPlaySoundUpdatePosition(TimeValue timeValue, uint ¶meter, byte callback, const char* sound, EntityPosition position); }; diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index cb4f7b941b..15a0a37c2f 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -347,15 +347,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_PLAYSOUND_UPDATEPOSITION(timeValue, parameter, callback, sound, position) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - getData()->entityPosition = position; \ - setCallback(callback); \ - setup_playSound(sound); \ - break; \ - } - #define TIME_CHECK_CAR(timeValue, parameter, callback, function) {\ if ((getState()->time <= timeValue && !getEntities()->isPlayerInCar(kCarGreenSleeping)) || !parameter) \ parameter = (uint)getState()->time + 75; \ diff --git a/engines/lastexpress/entities/hadija.cpp b/engines/lastexpress/entities/hadija.cpp index 8d757d54fd..4e72ce56f1 100644 --- a/engines/lastexpress/entities/hadija.cpp +++ b/engines/lastexpress/entities/hadija.cpp @@ -130,7 +130,8 @@ IMPLEMENT_FUNCTION(11, Hadija, chapter1Handler) break; case kActionNone: - TIME_CHECK_PLAYSOUND_UPDATEPOSITION(kTimeParisEpernay, params->param1, 1, "Har1100", kPosition_4840); + if (Entity::timeCheckPlaySoundUpdatePosition(kTimeParisEpernay, params->param1, 1, "Har1100", kPosition_4840)) + break; label_callback1: TIME_CHECK_CALLBACK(kTime1084500, params->param2, 2, setup_compartment6to8); diff --git a/engines/lastexpress/entities/yasmin.cpp b/engines/lastexpress/entities/yasmin.cpp index ebf90744f5..6fb1936303 100644 --- a/engines/lastexpress/entities/yasmin.cpp +++ b/engines/lastexpress/entities/yasmin.cpp @@ -204,7 +204,8 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) case kActionNone: TIME_CHECK_CALLBACK(kTime1093500, params->param1, 1, setup_function6); TIME_CHECK_CALLBACK(kTime1161000, params->param2, 3, setup_function7); - TIME_CHECK_PLAYSOUND_UPDATEPOSITION(kTime1162800, params->param3, 4, "Har1102", kPosition_4070); + if (Entity::timeCheckPlaySoundUpdatePosition(kTime1162800, params->param3, 4, "Har1102", kPosition_4070)) + break; TIME_CHECK_CALLBACK_1(kTime1165500, params->param4, 5, setup_playSound, "Har1104"); TIME_CHECK_CALLBACK_1(kTime1174500, params->param5, 6, setup_playSound, "Har1106"); TIME_CHECK_CALLBACK(kTime1183500, params->param6, 7, setup_function6); @@ -226,7 +227,8 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) // Fallback to case 3 case 3: - TIME_CHECK_PLAYSOUND_UPDATEPOSITION(kTime1162800, params->param3, 4, "Har1102", kPosition_4070); + if (Entity::timeCheckPlaySoundUpdatePosition(kTime1162800, params->param3, 4, "Har1102", kPosition_4070)) + break; // Fallback to case 4 case 4: -- cgit v1.2.3 From 95503250f82c71b4ca6849c5eb5581d3c6645202 Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 22:24:27 -0400 Subject: LASTEXPRESS: Replace UPDATE_PARAM macro --- engines/lastexpress/entities/abbot.cpp | 21 +++++++++----- engines/lastexpress/entities/alexei.cpp | 13 ++++++--- engines/lastexpress/entities/alouan.cpp | 4 ++- engines/lastexpress/entities/anna.cpp | 43 +++++++++++++++++++--------- engines/lastexpress/entities/august.cpp | 24 ++++++++++------ engines/lastexpress/entities/boutarel.cpp | 7 +++-- engines/lastexpress/entities/chapters.cpp | 3 +- engines/lastexpress/entities/cooks.cpp | 9 ++++-- engines/lastexpress/entities/coudert.cpp | 33 ++++++++++++++------- engines/lastexpress/entities/entity.cpp | 20 +++++++++++-- engines/lastexpress/entities/entity.h | 2 ++ engines/lastexpress/entities/entity_intern.h | 7 ----- engines/lastexpress/entities/gendarmes.cpp | 3 +- engines/lastexpress/entities/hadija.cpp | 4 ++- engines/lastexpress/entities/kahina.cpp | 3 +- engines/lastexpress/entities/mahmud.cpp | 9 ++++-- engines/lastexpress/entities/max.cpp | 15 ++++++---- engines/lastexpress/entities/mertens.cpp | 21 +++++++++----- engines/lastexpress/entities/milos.cpp | 18 ++++++++---- engines/lastexpress/entities/mmeboutarel.cpp | 15 ++++++---- engines/lastexpress/entities/pascale.cpp | 3 +- engines/lastexpress/entities/rebecca.cpp | 10 +++++-- engines/lastexpress/entities/salko.cpp | 6 ++-- engines/lastexpress/entities/tatiana.cpp | 16 +++++++---- engines/lastexpress/entities/vassili.cpp | 9 ++++-- engines/lastexpress/entities/verges.cpp | 3 +- engines/lastexpress/entities/vesna.cpp | 9 ++++-- engines/lastexpress/entities/yasmin.cpp | 4 ++- 28 files changed, 226 insertions(+), 108 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index 9280068fae..c224b57abc 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -514,7 +514,8 @@ IMPLEMENT_FUNCTION(24, Abbot, function24) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 900); + if (!Entity::updateParameter(params->param1, getState()->time, 900)) + break; setup_function25(); break; @@ -615,7 +616,8 @@ IMPLEMENT_FUNCTION(26, Abbot, function26) break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, 4500); + if (!Entity::updateParameter(params->param2, getState()->time, 4500)) + break; if (getEntities()->isSomebodyInsideRestaurantOrSalon()) setup_function27(); @@ -862,7 +864,8 @@ IMPLEMENT_FUNCTION(31, Abbot, function31) if (!params->param1) break; - UPDATE_PARAM(params->param5, getState()->time, 450); + if (!Entity::updateParameter(params->param5, getState()->time, 450)) + break; setCallback(6); setup_callbackActionRestaurantOrSalon(); @@ -918,7 +921,8 @@ IMPLEMENT_FUNCTION(31, Abbot, function31) getSavePoints()->push(kEntityAbbot, kEntityAlexei, kAction122288808); params->param1 = 1; - UPDATE_PARAM(params->param5, getState()->time, 450); + if (!Entity::updateParameter(params->param5, getState()->time, 450)) + break; setCallback(6); setup_callbackActionRestaurantOrSalon(); @@ -1161,7 +1165,8 @@ IMPLEMENT_FUNCTION(36, Abbot, function36) break; case 2: - UPDATE_PARAM(params->param4, getState()->time, 900); + if (!Entity::updateParameter(params->param4, getState()->time, 900)) + break; getSound()->playSound(kEntityAbbot, "Abb3042"); break; @@ -1426,7 +1431,8 @@ label_callback_1: TIME_CHECK(kTime2466000, params->param5, setup_function44); if (params->param3) { - UPDATE_PARAM(params->param6, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param6, getState()->timeTicks, 75)) + break; params->param2 = 1; params->param3 = 0; @@ -1748,7 +1754,8 @@ IMPLEMENT_FUNCTION(49, Abbot, pickBomb) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->timeTicks, 150); + if (!Entity::updateParameter(params->param1, getState()->timeTicks, 150)) + break; getSavePoints()->push(kEntityAbbot, kEntityAbbot, kAction157489665); break; diff --git a/engines/lastexpress/entities/alexei.cpp b/engines/lastexpress/entities/alexei.cpp index 437c31c476..c77b103f4d 100644 --- a/engines/lastexpress/entities/alexei.cpp +++ b/engines/lastexpress/entities/alexei.cpp @@ -314,7 +314,8 @@ IMPLEMENT_FUNCTION_IS(16, Alexei, function16, TimeValue) } if (params->param5) { - UPDATE_PARAM(CURRENT_PARAM(1, 1), getState()->timeTicks, 75); + if (!Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->timeTicks, 75)) + break; params->param5 = 0; params->param6 = 1; @@ -482,7 +483,9 @@ IMPLEMENT_FUNCTION(18, Alexei, chapter1Handler) } if (params->param1) { - UPDATE_PARAM(params->param3, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 90)) + break; + getScenes()->loadSceneFromPosition(kCarRestaurant, 61); } else { params->param3 = 0; @@ -1348,7 +1351,8 @@ IMPLEMENT_FUNCTION(35, Alexei, function35) UPDATE_PARAM_PROC_END label_callback_3: - UPDATE_PARAM(params->param4, getState()->time, 9000); + if (!Entity::updateParameter(params->param4, getState()->time, 9000)) + break; setCallback(4); setup_callbackActionRestaurantOrSalon(); @@ -1397,7 +1401,8 @@ IMPLEMENT_FUNCTION(36, Alexei, function36) if (params->param3 || params->param2) break; - UPDATE_PARAM(params->param4, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, params->param1)) + break; getEntities()->drawSequenceRight(kEntityAlexei, "124B"); diff --git a/engines/lastexpress/entities/alouan.cpp b/engines/lastexpress/entities/alouan.cpp index 589b712b16..7549aaf6e6 100644 --- a/engines/lastexpress/entities/alouan.cpp +++ b/engines/lastexpress/entities/alouan.cpp @@ -438,7 +438,9 @@ IMPLEMENT_FUNCTION(22, Alouan, function22) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 2700); + if (!Entity::updateParameter(params->param1, getState()->time, 2700)) + break; + setup_function23(); break; diff --git a/engines/lastexpress/entities/anna.cpp b/engines/lastexpress/entities/anna.cpp index 806beaee9d..80a5144bbe 100644 --- a/engines/lastexpress/entities/anna.cpp +++ b/engines/lastexpress/entities/anna.cpp @@ -207,7 +207,8 @@ IMPLEMENT_FUNCTION(12, Anna, function12) } if (params->param4) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 75)) + break; params->param4 = 0; params->param5 = 1; @@ -427,7 +428,8 @@ IMPLEMENT_FUNCTION_IS(15, Anna, function15, TimeValue) } if (params->param5) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 75)) + break; params->param5 = 0; params->param6 = 1; @@ -675,7 +677,8 @@ IMPLEMENT_FUNCTION_I(18, Anna, function18, TimeValue) } if (params->param3) { - UPDATE_PARAM(params->param7, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param7, getState()->timeTicks, 90)) + break; getScenes()->loadSceneFromPosition(kCarRestaurant, 61); } else { @@ -1157,7 +1160,8 @@ IMPLEMENT_FUNCTION(29, Anna, function29) } if (params->param1) { - UPDATE_PARAM(params->param4, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 90)) + break; getScenes()->loadSceneFromPosition(kCarRestaurant, 55); } else { @@ -1279,7 +1283,9 @@ IMPLEMENT_FUNCTION(30, Anna, function30) } if (params->param1) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 90)) + break; + getScenes()->loadSceneFromPosition(kCarRestaurant, 55); } else { params->param5 = 0; @@ -1483,7 +1489,8 @@ IMPLEMENT_FUNCTION(35, Anna, function35) if (!params->param1) break; - UPDATE_PARAM(params->param3, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 75)) + break; switch (params->param2) { default: @@ -1797,7 +1804,8 @@ IMPLEMENT_FUNCTION(41, Anna, function41) break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, 2700); + if (!Entity::updateParameter(params->param2, getState()->time, 2700)) + break; params->param5++; switch (params->param5) { @@ -2399,7 +2407,8 @@ IMPLEMENT_FUNCTION(53, Anna, function53) } if (params->param1) { - UPDATE_PARAM(params->param7, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param7, getState()->timeTicks, 75)) + break; CursorStyle cursor = getEntities()->isInsideCompartment(kEntityMax, kCarRedSleeping, kPosition_4070) ? kCursorHand : kCursorNormal; @@ -2545,7 +2554,8 @@ IMPLEMENT_FUNCTION(54, Anna, function54) } if (params->param1) { - UPDATE_PARAM(params->param7, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param7, getState()->timeTicks, 75)) + break; CursorStyle cursor = getEntities()->isInsideCompartment(kEntityMax, kCarRedSleeping, kPosition_4070) ? kCursorHand : kCursorNormal; @@ -2892,7 +2902,8 @@ IMPLEMENT_FUNCTION(59, Anna, function59) } if (params->param1) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; CursorStyle style = getEntities()->isInsideCompartment(kEntityMax, kCarRedSleeping, kPosition_4070) ? kCursorHand : kCursorNormal; getObjects()->update(kObjectCompartmentF, kEntityAnna, kObjectLocation1, kCursorNormal, style); @@ -3275,7 +3286,8 @@ IMPLEMENT_FUNCTION(67, Anna, chapter4Handler) label_next: if (params->param1) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; @@ -3405,7 +3417,8 @@ IMPLEMENT_FUNCTION(69, Anna, function69) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param2, getState()->time, 4500); + if (!Entity::updateParameter(params->param2, getState()->time, 4500)) + break; getData()->car = kCarRedSleeping; getData()->entityPosition = kPosition_9270; @@ -3909,7 +3922,8 @@ IMPLEMENT_FUNCTION(80, Anna, function80) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->timeTicks, 450); + if (!Entity::updateParameter(params->param1, getState()->timeTicks, 450)) + break; getSound()->playSound(kEntityPlayer, "Kro5001", kFlagDefault); break; @@ -3978,7 +3992,8 @@ IMPLEMENT_FUNCTION(81, Anna, finalSequence) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->timeTicks, 180); + if (!Entity::updateParameter(params->param1, getState()->timeTicks, 180)) + break; getSound()->playSound(kEntityTrain, "LIB069"); getLogic()->gameOver(kSavegameTypeIndex, 2, kSceneNone, true); diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index f255d041f8..d874c666f7 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -840,7 +840,8 @@ label_callback_9: break; if (getObjects()->get(kObjectCompartment1).location == kObjectLocation1) { - UPDATE_PARAM(CURRENT_PARAM(1, 2), getState()->timeTicks, 75); + if (!Entity::updateParameter(CURRENT_PARAM(1, 2), getState()->timeTicks, 75)) + break; getObjects()->update(kObjectCompartment1, kEntityAugust, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal); @@ -1483,7 +1484,8 @@ IMPLEMENT_FUNCTION(30, August, restaurant) break; case kActionNone: - UPDATE_PARAM(params->param3, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 75)) + break; getData()->inventoryItem = kItemInvalid; break; @@ -1654,7 +1656,8 @@ IMPLEMENT_FUNCTION(32, August, function32) } if (params->param3) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 90)) + break; getScenes()->loadSceneFromPosition(kCarRestaurant, 55); } else { @@ -2768,7 +2771,8 @@ IMPLEMENT_FUNCTION(54, August, function54) getData()->inventoryItem = kItemInvalid; if (!params->param2 && params->param1) { - UPDATE_PARAM(params->param5, getState()->time, params->param1); + if (!Entity::updateParameter(params->param5, getState()->time, params->param1)) + break; getData()->inventoryItem = kItemNone; setup_function55(); @@ -3044,7 +3048,8 @@ IMPLEMENT_FUNCTION(60, August, function60) if (!params->param1) break; - UPDATE_PARAM(params->param3, getState()->time, 9000); + if (!Entity::updateParameter(params->param3, getState()->time, 9000)) + break; setCallback(1); setup_callbackActionRestaurantOrSalon(); @@ -3140,7 +3145,8 @@ IMPLEMENT_FUNCTION(62, August, function62) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 900); + if (!Entity::updateParameter(params->param1, getState()->time, 900)) + break; getSound()->playSound(kEntityAugust, "Aug4003A"); @@ -3229,7 +3235,8 @@ IMPLEMENT_FUNCTION(63, August, function63) break; } - UPDATE_PARAM(params->param5, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, params->param1)) + break; params->param2 = (params->param6 < 1 ? 1 : 0); @@ -3386,7 +3393,8 @@ IMPLEMENT_FUNCTION(68, August, function68) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param4, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; diff --git a/engines/lastexpress/entities/boutarel.cpp b/engines/lastexpress/entities/boutarel.cpp index ab5f019c49..ab8a0b9003 100644 --- a/engines/lastexpress/entities/boutarel.cpp +++ b/engines/lastexpress/entities/boutarel.cpp @@ -480,7 +480,9 @@ IMPLEMENT_FUNCTION_IS(17, Boutarel, function17, TimeValue) break; if (params->param5) { - UPDATE_PARAM(params->param7, getState()->timeTicks, 90) + if (!Entity::updateParameter(params->param7, getState()->timeTicks, 90)) + break; + getScenes()->loadSceneFromPosition(kCarRestaurant, 51); } else { params->param7 = 0; @@ -515,7 +517,8 @@ IMPLEMENT_FUNCTION_I(18, Boutarel, function18, TimeValue) } if (params->param2) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param2 = 0; params->param3 = 1; diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index b4978165b9..76165800f2 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -809,7 +809,8 @@ IMPLEMENT_FUNCTION(12, Chapters, chapter2Handler) if (!getProgress().isTrainRunning) break; - UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, params->param1)) + break; getSound()->playLocomotiveSound(); diff --git a/engines/lastexpress/entities/cooks.cpp b/engines/lastexpress/entities/cooks.cpp index 63494e6062..a3fb69aeb9 100644 --- a/engines/lastexpress/entities/cooks.cpp +++ b/engines/lastexpress/entities/cooks.cpp @@ -260,7 +260,8 @@ IMPLEMENT_FUNCTION(6, Cooks, chapter1Handler) break; case kActionNone: - UPDATE_PARAM(params->param4, getState()->time, params->param2); + if (!Entity::updateParameter(params->param4, getState()->time, params->param2)) + break; // Broken plate sound getSound()->playSound(kEntityPlayer, "LIB122", getSound()->getSoundFlag(kEntityCooks)); @@ -373,7 +374,8 @@ IMPLEMENT_FUNCTION(9, Cooks, chapter2Handler) break; case kActionNone: - UPDATE_PARAM(params->param3, getState()->time, params->param1); + if (!Entity::updateParameter(params->param3, getState()->time, params->param1)) + break; // Broken plate sound getSound()->playSound(kEntityPlayer, "LIB122", getSound()->getSoundFlag(kEntityCooks)); @@ -524,7 +526,8 @@ IMPLEMENT_FUNCTION(13, Cooks, chapter4Handler) break; case kActionNone: - UPDATE_PARAM(params->param3, getState()->time, params->param1) + if (!Entity::updateParameter(params->param3, getState()->time, params->param1)) + break; // Broken plate sound getSound()->playSound(kEntityPlayer, "LIB122", getSound()->getSoundFlag(kEntityCooks)); diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index e79d4cdff7..c589b8f0f8 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -356,7 +356,8 @@ IMPLEMENT_FUNCTION_I(10, Coudert, updateFromTime, uint32) case kActionNone: Entity::savegameBloodJacket(); - UPDATE_PARAM(params->param2, getState()->time, params->param1); + if (!Entity::updateParameter(params->param2, getState()->time, params->param1)) + break; callbackAction(); break; @@ -379,7 +380,8 @@ IMPLEMENT_FUNCTION_I(11, Coudert, updateFromTicks, uint32) case kActionNone: Entity::savegameBloodJacket(); - UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, params->param1)) + break; callbackAction(); break; @@ -476,7 +478,8 @@ IMPLEMENT_FUNCTION_II(13, Coudert, function13, bool, EntityIndex) } } - UPDATE_PARAM(params->param5, getState()->timeTicks, 225); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 225)) + break; getData()->inventoryItem = kItemNone; setCallback(5); @@ -909,7 +912,8 @@ IMPLEMENT_FUNCTION_II(20, Coudert, function20, ObjectIndex, ObjectIndex) getSound()->playSound(kEntityPlayer, "ZFX1004", getSound()->getSoundFlag(kEntityCoudert)); UPDATE_PARAM_PROC_END - UPDATE_PARAM(CURRENT_PARAM(1, 4), getState()->time, 900); + if (!Entity::updateParameter(CURRENT_PARAM(1, 4), getState()->time, 900)) + break; getObjects()->updateLocation2((ObjectIndex)params->param1, kObjectLocation1); @@ -988,7 +992,8 @@ IMPLEMENT_FUNCTION(21, Coudert, function21) case kActionNone: if (!params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment("627Zh", kObjectCompartmentH); @@ -1089,7 +1094,8 @@ IMPLEMENT_FUNCTION(22, Coudert, function22) case kActionNone: if (!params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment("627Rg", kObjectCompartmentG); @@ -1300,7 +1306,8 @@ IMPLEMENT_FUNCTION(26, Coudert, function26) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment2("627Zd", kObjectCompartmentD, kPosition_5790, kPosition_6130); @@ -1391,7 +1398,8 @@ IMPLEMENT_FUNCTION(27, Coudert, function27) case kActionNone: if (!params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment2("627Rc", kObjectCompartmentC, kPosition_6470, kPosition_6130); @@ -1891,7 +1899,8 @@ IMPLEMENT_FUNCTION_I(35, Coudert, function35, bool) getScenes()->loadSceneFromPosition(kCarRestaurant, 65); } - UPDATE_PARAM(params->param2, getState()->time, 2700); + if (!Entity::updateParameter(params->param2, getState()->time, 2700)) + break; getSavePoints()->push(kEntityCoudert, kEntityMax, kActionMaxFreeFromCage); @@ -3558,7 +3567,8 @@ label_callback_5: label_callback_6: if (getState()->time > kTime2538000 && !ENTITY_PARAM(0, 1) && !ENTITY_PARAM(2, 1)) { - UPDATE_PARAM(params->param7, getState()->time, 2700); + if (!Entity::updateParameter(params->param7, getState()->time, 2700)) + break; ENTITY_PARAM(0, 2) = 0; ENTITY_PARAM(0, 1) = 1; @@ -4023,7 +4033,8 @@ IMPLEMENT_FUNCTION(62, Coudert, function62) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param4, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 43f039df43..1989c4607b 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -346,7 +346,9 @@ void Entity::updateFromTicks(const SavePoint &savepoint) { break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->timeTicks, params->param1) + if (Entity::updateParameter(params->param2, getState()->timeTicks, params->param1)) + break; + callbackAction(); break; } @@ -360,7 +362,9 @@ void Entity::updateFromTime(const SavePoint &savepoint) { break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, params->param1) + if (Entity::updateParameter(params->param2, getState()->time, params->param1)) + break; + callbackAction(); break; } @@ -597,6 +601,18 @@ void Entity::callbackAction() { // Helper functions ////////////////////////////////////////////////////////////////////////// +bool Entity::updateParameter(uint ¶meter, uint timeValue, uint delta) { + if (!parameter) + parameter = (uint)(timeValue + delta); + + if (parameter >= timeValue) + return false; + + parameter = kTimeInvalid; + + return true; +} + void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) { if (getState()->time > timeValue && !parameter) { parameter = 1; diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 3370659c6e..139f8ec418 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -870,6 +870,8 @@ protected: // Helper functions ////////////////////////////////////////////////////////////////////////// + bool updateParameter(uint ¶meter, uint time, uint delta); + void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter); diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 15a0a37c2f..23f5e49120 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -361,13 +361,6 @@ void class::setup_##name() { \ ////////////////////////////////////////////////////////////////////////// // Param update ////////////////////////////////////////////////////////////////////////// -#define UPDATE_PARAM(parameter, type, value) { \ - if (!parameter) \ - parameter = (uint)(type + value); \ - if (parameter >= type) \ - break; \ - parameter = kTimeInvalid; \ -} // Todo: replace with UPDATE_PARAM_PROC as appropriate #define UPDATE_PARAM_GOTO(parameter, type, value, label) { \ diff --git a/engines/lastexpress/entities/gendarmes.cpp b/engines/lastexpress/entities/gendarmes.cpp index fe9f6f0aa5..22697b396c 100644 --- a/engines/lastexpress/entities/gendarmes.cpp +++ b/engines/lastexpress/entities/gendarmes.cpp @@ -266,7 +266,8 @@ IMPLEMENT_FUNCTION_III(10, Gendarmes, function10, CarIndex, EntityPosition, Obje getSound()->playSound(kEntityGendarmes, "POL1046A", kFlagDefault); } - UPDATE_PARAM(params->param7, getState()->timeTicks, 300); + if (!Entity::updateParameter(params->param7, getState()->timeTicks, 300)) + break; if (!params->param4 && getEntities()->isOutsideAlexeiWindow()) { getObjects()->update((ObjectIndex)params->param3, kEntityPlayer, kObjectLocationNone, kCursorHandKnock, kCursorHand); diff --git a/engines/lastexpress/entities/hadija.cpp b/engines/lastexpress/entities/hadija.cpp index 4e72ce56f1..62badc46a6 100644 --- a/engines/lastexpress/entities/hadija.cpp +++ b/engines/lastexpress/entities/hadija.cpp @@ -466,7 +466,9 @@ IMPLEMENT_FUNCTION(22, Hadija, function22) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 2700); + if (!Entity::updateParameter(params->param1, getState()->time, 2700)) + break; + setup_function23(); break; diff --git a/engines/lastexpress/entities/kahina.cpp b/engines/lastexpress/entities/kahina.cpp index 6bb2e6b90a..2124de1687 100644 --- a/engines/lastexpress/entities/kahina.cpp +++ b/engines/lastexpress/entities/kahina.cpp @@ -794,7 +794,8 @@ label_callback_2: if (getEvent(kEventKahinaAskSpeakFirebird) && !getEvent(kEventKronosConversationFirebird) && getEntities()->isInsideTrainCar(kEntityPlayer, kCarKronos)) { - UPDATE_PARAM(params->param4, getState()->time, 900); + if (!Entity::updateParameter(params->param4, getState()->time, 900)) + break; setCallback(3); setup_savegame(kSavegameTypeEvent, kEventKronosConversationFirebird); diff --git a/engines/lastexpress/entities/mahmud.cpp b/engines/lastexpress/entities/mahmud.cpp index ebe754bfa4..1e7df5c870 100644 --- a/engines/lastexpress/entities/mahmud.cpp +++ b/engines/lastexpress/entities/mahmud.cpp @@ -84,7 +84,8 @@ IMPLEMENT_FUNCTION_SIII(4, Mahmud, enterExitCompartment2, ObjectIndex, uint32, O break; case kActionNone: - UPDATE_PARAM(params->param7, getState()->timeTicks, params->param5); + if (!Entity::updateParameter(params->param7, getState()->timeTicks, params->param5)) + break; if (!getScenes()->checkPosition(kSceneNone, SceneManager::kCheckPositionLookingUp)) getScenes()->loadSceneFromObject((ObjectIndex)params->param6, true); @@ -144,7 +145,8 @@ IMPLEMENT_FUNCTION_II(10, Mahmud, function10, ObjectIndex, bool) break; case kActionNone: - UPDATE_PARAM(params->param6, getState()->time, 13500); + if (!Entity::updateParameter(params->param6, getState()->time, 13500)) + break; getObjects()->update(kObjectCompartment5, kEntityTrain, kObjectLocation3, kCursorHandKnock, kCursorHand); getObjects()->update(kObjectCompartment6, kEntityTrain, kObjectLocation3, kCursorHandKnock, kCursorHand); @@ -570,7 +572,8 @@ IMPLEMENT_FUNCTION(14, Mahmud, chaptersHandler) } if (params->param5) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 75)) + break; params->param4 = 1; params->param5 = 0; diff --git a/engines/lastexpress/entities/max.cpp b/engines/lastexpress/entities/max.cpp index cecfe64dc6..5c43346cde 100644 --- a/engines/lastexpress/entities/max.cpp +++ b/engines/lastexpress/entities/max.cpp @@ -89,7 +89,8 @@ IMPLEMENT_FUNCTION(6, Max, chapter12_handler) break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, params->param1); + if (!Entity::updateParameter(params->param2, getState()->time, params->param1)) + break; if (!getSoundQueue()->isBuffered(kEntityMax)) getSound()->playSound(kEntityMax, "Max1122"); @@ -123,7 +124,8 @@ IMPLEMENT_FUNCTION(7, Max, function7) break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, params->param1) + if (!Entity::updateParameter(params->param2, getState()->time, params->param1)) + break; if (!getSoundQueue()->isBuffered(kEntityMax)) getSound()->playSound(kEntityMax, "Max1122"); @@ -212,7 +214,8 @@ IMPLEMENT_FUNCTION(8, Max, chapter4Handler) break; case kActionNone: - UPDATE_PARAM(params->param3, getState()->time, params->param2); + if (!Entity::updateParameter(params->param3, getState()->time, params->param2)) + break; if (!getSoundQueue()->isBuffered(kEntityMax)) getSound()->playSound(kEntityMax, "Max3101"); @@ -390,7 +393,8 @@ IMPLEMENT_FUNCTION(13, Max, chapter3Handler) break; } - UPDATE_PARAM(params->param3, getState()->time, params->param1); + if (!Entity::updateParameter(params->param3, getState()->time, params->param1)) + break; if (!getSoundQueue()->isBuffered(kEntityMax)) getSound()->playSound(kEntityMax, "Max1122"); @@ -512,7 +516,8 @@ IMPLEMENT_FUNCTION(15, Max, function15) } if (!params->param1) { - UPDATE_PARAM(params->param3, getState()->time, 900); + if (!Entity::updateParameter(params->param3, getState()->time, 900)) + break; getSavePoints()->push(kEntityMax, kEntityCoudert, kAction157026693); } diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index 37e7bf5ca6..c093ac4b30 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -464,7 +464,8 @@ IMPLEMENT_FUNCTION_I(11, Mertens, function11, uint32) case kActionNone: Entity::savegameBloodJacket(); - UPDATE_PARAM(params->param2, getState()->time, params->param1) + if (!Entity::updateParameter(params->param2, getState()->time, params->param1)) + break; callbackAction(); break; @@ -1062,7 +1063,8 @@ IMPLEMENT_FUNCTION_II(21, Mertens, function21, ObjectIndex, ObjectIndex) getSound()->playSound(kEntityPlayer, "ZFX1004", getSound()->getSoundFlag(kEntityMertens)); UPDATE_PARAM_PROC_END - UPDATE_PARAM(CURRENT_PARAM(1, 5), getState()->time, 900); + if (!Entity::updateParameter(CURRENT_PARAM(1, 5), getState()->time, 900)) + break; // Update objects getObjects()->updateLocation2((ObjectIndex)params->param1, kObjectLocation1); @@ -1286,7 +1288,8 @@ IMPLEMENT_FUNCTION(24, Mertens, function24) case kActionNone: if (!params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment3("601Rc", kObjectCompartment3, kPosition_6470, kPosition_6130); @@ -1389,7 +1392,8 @@ IMPLEMENT_FUNCTION(25, Mertens, function25) case kActionNone: if (!params->param1) { - UPDATE_PARAM(params->param2, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 75)) + break; setCallback(3); setup_enterExitCompartment3("601Zb", kObjectCompartment2, kPosition_7500, kPositionNone); @@ -1626,7 +1630,8 @@ label_callback10: if (params->param3 >= getState()->timeTicks) { label_callback11: - UPDATE_PARAM(params->param4, getState()->timeTicks, 375); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 375)) + break; getSound()->playSound(kEntityPlayer, "LIB033"); @@ -3736,7 +3741,8 @@ label_callback_7: label_callback_8: if (getState()->time > kTime2538000 && !ENTITY_PARAM(0, 1) && !ENTITY_PARAM(2, 1)) { - UPDATE_PARAM(params->param6, getState()->time, 2700); + if (!Entity::updateParameter(params->param6, getState()->time, 2700)) + break; getEntities()->drawSequenceLeft(kEntityMertens, "601E"); @@ -3990,7 +3996,8 @@ IMPLEMENT_FUNCTION(53, Mertens, function53) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param4, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 0; diff --git a/engines/lastexpress/entities/milos.cpp b/engines/lastexpress/entities/milos.cpp index c33a8b887e..8ebb23b024 100644 --- a/engines/lastexpress/entities/milos.cpp +++ b/engines/lastexpress/entities/milos.cpp @@ -434,7 +434,8 @@ IMPLEMENT_FUNCTION(14, Milos, function14) if (CURRENT_PARAM(1, 1) < getState()->timeTicks) { if (getObjects()->get(kObjectCompartment1).location == kObjectLocation1) { - UPDATE_PARAM(CURRENT_PARAM(1, 2), getState()->timeTicks, 75); + if (!Entity::updateParameter(CURRENT_PARAM(1, 2), getState()->timeTicks, 75)) + break; getObjects()->update(kObjectCompartment1, kEntityMilos, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal); @@ -505,7 +506,8 @@ IMPLEMENT_FUNCTION(14, Milos, function14) } label_callback_12: - UPDATE_PARAM(CURRENT_PARAM(1, 4), getState()->timeTicks, 75); + if (!Entity::updateParameter(CURRENT_PARAM(1, 4), getState()->timeTicks, 75)) + break; getEntities()->exitCompartment(kEntityMilos, kObjectCompartment1, true); @@ -736,7 +738,8 @@ IMPLEMENT_FUNCTION(15, Milos, chapter1Handler) } if (getEntities()->isPlayerPosition(kCarRestaurant, 70) && !params->param2) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 45); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 45)) + break; setCallback(2); setup_draw("009C"); @@ -951,7 +954,8 @@ IMPLEMENT_FUNCTION(21, Milos, function21) break; case kActionNone: - UPDATE_PARAM(params->param2, getState()->time, 4500); + if (!Entity::updateParameter(params->param2, getState()->time, 4500)) + break; params->param1 = 1; break; @@ -1116,7 +1120,8 @@ IMPLEMENT_FUNCTION(24, Milos, function24) } if (params->param1) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; @@ -1289,7 +1294,8 @@ IMPLEMENT_FUNCTION(25, Milos, function25) } if (params->param1) { - UPDATE_PARAM(params->param4, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; diff --git a/engines/lastexpress/entities/mmeboutarel.cpp b/engines/lastexpress/entities/mmeboutarel.cpp index ace8637556..323e686ec3 100644 --- a/engines/lastexpress/entities/mmeboutarel.cpp +++ b/engines/lastexpress/entities/mmeboutarel.cpp @@ -427,7 +427,8 @@ label_callback_1: TIME_CHECK(kTime1094400, params->param8, setup_function14); if (params->param4) { - UPDATE_PARAM(CURRENT_PARAM(1, 1), getState()->timeTicks, 75); + if (!Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->timeTicks, 75)) + break; params->param3 = 1; params->param4 = 0; @@ -587,7 +588,8 @@ IMPLEMENT_FUNCTION(15, MmeBoutarel, function15) label_callback_5: if (params->param2) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param1 = 1; params->param2 = 0; @@ -1016,7 +1018,8 @@ IMPLEMENT_FUNCTION(23, MmeBoutarel, chapter4Handler) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param2, getState()->time, 900); + if (!Entity::updateParameter(params->param2, getState()->time, 900)) + break; getObjects()->update(kObjectCompartmentD, kEntityPlayer, kObjectLocation1, kCursorKeepValue, kCursorKeepValue); @@ -1065,7 +1068,8 @@ IMPLEMENT_FUNCTION(24, MmeBoutarel, function24) TIME_CHECK(kTime2470500, params->param4, setup_function25); if (params->param2) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param1 = 1; params->param2 = 0; @@ -1208,7 +1212,8 @@ IMPLEMENT_FUNCTION(28, MmeBoutarel, function28) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param3, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; diff --git a/engines/lastexpress/entities/pascale.cpp b/engines/lastexpress/entities/pascale.cpp index 6620634ade..e74cf3490f 100644 --- a/engines/lastexpress/entities/pascale.cpp +++ b/engines/lastexpress/entities/pascale.cpp @@ -1126,7 +1126,8 @@ IMPLEMENT_FUNCTION(33, Pascale, function33) label_callback1: if (params->param1) { - UPDATE_PARAM(params->param6, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param6, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 2; diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 3ef266994f..a890ebf258 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -708,7 +708,9 @@ label_callback_4: label_callback_5: if (params->param2) { - UPDATE_PARAM(params->param6, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param6, getState()->timeTicks, 90)) + break; + getScenes()->loadSceneFromPosition(kCarRestaurant, 55); } else { params->param6 = 0; @@ -966,7 +968,8 @@ IMPLEMENT_FUNCTION(26, Rebecca, function26) TIME_CHECK_CALLBACK_3(kTime1224000, params->param2, 1, setup_updatePosition, "118H", kCarRestaurant, 52); if (params->param1) { - UPDATE_PARAM(params->param3, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 90)) + break; getScenes()->loadSceneFromPosition(kCarRestaurant, 51); } @@ -1753,7 +1756,8 @@ IMPLEMENT_FUNCTION(48, Rebecca, function48) case kActionNone: if (params->param1) { - UPDATE_PARAM(params->param3, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 75)) + break; params->param1 = 0; params->param2 = 1; diff --git a/engines/lastexpress/entities/salko.cpp b/engines/lastexpress/entities/salko.cpp index 70a26b515a..b799564b46 100644 --- a/engines/lastexpress/entities/salko.cpp +++ b/engines/lastexpress/entities/salko.cpp @@ -299,7 +299,8 @@ IMPLEMENT_FUNCTION(15, Salko, chapter3Handler) case kActionNone: if (getState()->time < kTime2200500) { - UPDATE_PARAM(params->param1, getState()->time, 81000); + if (!Entity::updateParameter(params->param1, getState()->time, 81000)) + break; setCallback(1); setup_function16(); @@ -329,7 +330,8 @@ IMPLEMENT_FUNCTION(16, Salko, function16) } label_callback3: - UPDATE_PARAM(params->param1, getState()->time, 4500); + if (!Entity::updateParameter(params->param1, getState()->time, 4500)) + break; getSavePoints()->push(kEntitySalko, kEntitySalko, kAction101169464); break; diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index b15a0a18b2..76068aad24 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -249,7 +249,8 @@ IMPLEMENT_FUNCTION_I(16, Tatiana, function16, uint32) } if (params->param2) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; params->param2 = 0; params->param3 = 1; @@ -443,7 +444,9 @@ label_tatiana_chapter1_2: Entity::timeCheckSavepoint(kTime1084500, params->param7, kEntityTatiana, kEntityPascale, kAction257489762); if (params->param1) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 90); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 90)) + break; + getScenes()->loadSceneFromPosition(kCarRestaurant, 65); } else { params->param8 = 0; @@ -1292,7 +1295,8 @@ IMPLEMENT_FUNCTION(37, Tatiana, function37) } if (params->param1) { - UPDATE_PARAM(params->param5, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) + break; getObjects()->update(kObjectCompartmentB, kEntityTatiana, kObjectLocation1, kCursorNormal, kCursorNormal); getObjects()->update(kObject49, kEntityTatiana, kObjectLocation1, kCursorNormal, kCursorNormal); @@ -1401,7 +1405,8 @@ IMPLEMENT_FUNCTION(38, Tatiana, function38) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 450); + if (!Entity::updateParameter(params->param1, getState()->time, 450)) + break; getEntities()->exitCompartment(kEntityTatiana, kObjectCompartmentF, true); @@ -2197,7 +2202,8 @@ IMPLEMENT_FUNCTION(54, Tatiana, function54) } if (params->param1 > 3) { - UPDATE_PARAM(params->param3, getState()->timeTicks, 225); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, 225)) + break; params->param1 = 0; params->param3 = 0; diff --git a/engines/lastexpress/entities/vassili.cpp b/engines/lastexpress/entities/vassili.cpp index 5079fdb252..6504df7928 100644 --- a/engines/lastexpress/entities/vassili.cpp +++ b/engines/lastexpress/entities/vassili.cpp @@ -400,7 +400,8 @@ IMPLEMENT_FUNCTION(13, Vassili, sleeping) case kActionNone: if (getEntities()->isInsideCompartment(kEntityPlayer, kCarRedSleeping, kPosition_8200)) { - UPDATE_PARAM(params->param3, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, params->param1)) + break; setCallback(1); setup_draw("303B"); @@ -459,7 +460,8 @@ IMPLEMENT_FUNCTION(15, Vassili, stealEgg) case kActionNone: if (getEntities()->isInsideCompartment(kEntityPlayer, kCarRedSleeping, kPosition_8200)) { - UPDATE_PARAM(params->param3, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, params->param1)) + break; setCallback(1); setup_draw("303B"); @@ -543,7 +545,8 @@ IMPLEMENT_FUNCTION(17, Vassili, chapter4Handler) case kActionNone: if (getEntities()->isInsideCompartment(kEntityPlayer, kCarRedSleeping, kPosition_8200)) { - UPDATE_PARAM(params->param3, getState()->timeTicks, params->param1); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, params->param1)) + break; setCallback(1); setup_draw("303B"); diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index bdd758a5be..f459b6f8e7 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -244,7 +244,8 @@ IMPLEMENT_FUNCTION_IIS(10, Verges, function10, CarIndex, EntityPosition) } if (params->param6) { - UPDATE_PARAM(params->param8, getState()->timeTicks, 75); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 75)) + break; getSound()->playSound(kEntityVerges, (char *)¶ms->seq); diff --git a/engines/lastexpress/entities/vesna.cpp b/engines/lastexpress/entities/vesna.cpp index b0ee9bcbc1..6889be4335 100644 --- a/engines/lastexpress/entities/vesna.cpp +++ b/engines/lastexpress/entities/vesna.cpp @@ -162,7 +162,8 @@ IMPLEMENT_FUNCTION(11, Vesna, function11) case kActionNone: if (parameters->param3) { - UPDATE_PARAM(parameters->param7, getState()->timeTicks, 75); + if (!Entity::updateParameter(parameters->param7, getState()->timeTicks, 75)) + break; parameters->param2 = 1; parameters->param3 = 0; @@ -511,7 +512,8 @@ IMPLEMENT_FUNCTION(20, Vesna, chapter3Handler) } if (parameters->param2) { - UPDATE_PARAM(parameters->param8, getState()->timeTicks, 75); + if (!Entity::updateParameter(parameters->param8, getState()->timeTicks, 75)) + break; parameters->param1 = 1; parameters->param2 = 0; @@ -1086,7 +1088,8 @@ IMPLEMENT_FUNCTION(30, Vesna, function30) UPDATE_PARAM_PROC_END } - UPDATE_PARAM(params->param4, getState()->timeTicks, 180); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 180)) + break; setCallback(1); setup_savegame(kSavegameTypeEvent, kEventCathVesnaTrainTopKilled); diff --git a/engines/lastexpress/entities/yasmin.cpp b/engines/lastexpress/entities/yasmin.cpp index 6fb1936303..f2b4d2edd1 100644 --- a/engines/lastexpress/entities/yasmin.cpp +++ b/engines/lastexpress/entities/yasmin.cpp @@ -445,7 +445,9 @@ IMPLEMENT_FUNCTION(20, Yasmin, function20) break; case kActionNone: - UPDATE_PARAM(params->param1, getState()->time, 2700); + if (!Entity::updateParameter(params->param1, getState()->time, 2700)) + break; + setup_function21(); break; -- cgit v1.2.3 From e13290a0286e86ee5c76f62ad74cb945a22cb38d Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 22 Jul 2012 22:43:11 -0400 Subject: LASTEXPRESS: Replace UPDATE_PARAM_CHECK macro --- engines/lastexpress/entities/alexei.cpp | 4 ++-- engines/lastexpress/entities/entity.cpp | 10 ++++++++++ engines/lastexpress/entities/entity.h | 1 + engines/lastexpress/entities/entity_intern.h | 6 ------ engines/lastexpress/entities/rebecca.cpp | 2 +- engines/lastexpress/entities/tatiana.cpp | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/alexei.cpp b/engines/lastexpress/entities/alexei.cpp index c77b103f4d..a2564dd924 100644 --- a/engines/lastexpress/entities/alexei.cpp +++ b/engines/lastexpress/entities/alexei.cpp @@ -251,7 +251,7 @@ IMPLEMENT_FUNCTION(15, Alexei, function15) break; case kActionNone: - UPDATE_PARAM_CHECK(params->param2, getState()->time, params->param1) + if (Entity::updateParameterCheck(params->param2, getState()->time, params->param1)) { if (getEntities()->isSomebodyInsideRestaurantOrSalon()) { getData()->location = kLocationOutsideCompartment; @@ -689,7 +689,7 @@ IMPLEMENT_FUNCTION(21, Alexei, function21) break; case kActionNone: - UPDATE_PARAM_CHECK(params->param2, getState()->time, params->param1) + if (Entity::updateParameterCheck(params->param2, getState()->time, params->param1)) { getData()->location = kLocationOutsideCompartment; getData()->inventoryItem = kItemNone; diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 1989c4607b..664b3fa70b 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -613,6 +613,16 @@ bool Entity::updateParameter(uint ¶meter, uint timeValue, uint delta) { return true; } +bool Entity::updateParameterCheck(uint ¶meter, uint timeValue, uint delta) { + if (parameter && parameter >= timeValue) + return false; + + if (!parameter) + parameter = (uint)(timeValue + delta); + + return true; +} + void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) { if (getState()->time > timeValue && !parameter) { parameter = 1; diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 139f8ec418..ce8aa168a4 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -871,6 +871,7 @@ protected: ////////////////////////////////////////////////////////////////////////// bool updateParameter(uint ¶meter, uint time, uint delta); + bool updateParameterCheck(uint ¶meter, uint time, uint delta); void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 23f5e49120..4b97556a75 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -388,12 +388,6 @@ void class::setup_##name() { \ #define UPDATE_PARAM_PROC_END } -// Updating parameter with an added check (and code inside the check) -#define UPDATE_PARAM_CHECK(parameter, type, value) \ - if (!parameter || parameter < type) { \ - if (!parameter) \ - parameter = (uint)(type + value); - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index a890ebf258..96deaaf97f 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -697,7 +697,7 @@ IMPLEMENT_FUNCTION(22, Rebecca, chapter1Handler) if (params->param4 >= getState()->time) { label_callback_4: if (params->param1) { - UPDATE_PARAM_CHECK(params->param5, getState()->time, 900) + if (Entity::updateParameterCheck(params->param5, getState()->time, 900)) { if (getEntities()->isInSalon(kEntityPlayer)) { setCallback(5); setup_playSound("REB1013"); diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index 76068aad24..9c2c582130 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -1023,7 +1023,7 @@ IMPLEMENT_FUNCTION(32, Tatiana, chapter3Handler) } if (parameters->param4 && parameters->param5) { - UPDATE_PARAM_CHECK(parameters->param4, getState()->time, 6300) + if (Entity::updateParameterCheck(parameters->param4, getState()->time, 6300)) { if (getEntities()->isSomebodyInsideRestaurantOrSalon()) { getData()->location = kLocationOutsideCompartment; -- cgit v1.2.3 From 8de4cb654782107100aaa3063cac79460546ed67 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Jul 2012 01:15:20 -0400 Subject: LASTEXPRESS: Replace UPDATE_PARAM_PROC and UPDATE_PARAM_PROC_TIME macros --- engines/lastexpress/entities/abbot.cpp | 4 ++-- engines/lastexpress/entities/alexei.cpp | 12 +++++------ engines/lastexpress/entities/anna.cpp | 32 ++++++++++++++-------------- engines/lastexpress/entities/august.cpp | 20 ++++++++--------- engines/lastexpress/entities/boutarel.cpp | 8 +++---- engines/lastexpress/entities/chapters.cpp | 20 ++++++++--------- engines/lastexpress/entities/cooks.cpp | 4 ++-- engines/lastexpress/entities/coudert.cpp | 12 +++++------ engines/lastexpress/entities/entity.cpp | 26 ++++++++++++++++------ engines/lastexpress/entities/entity.h | 5 +++-- engines/lastexpress/entities/entity_intern.h | 17 --------------- engines/lastexpress/entities/francois.cpp | 8 +++---- engines/lastexpress/entities/kahina.cpp | 24 ++++++++++----------- engines/lastexpress/entities/kronos.cpp | 8 +++---- engines/lastexpress/entities/mertens.cpp | 20 ++++++++--------- engines/lastexpress/entities/milos.cpp | 16 +++++++------- engines/lastexpress/entities/mmeboutarel.cpp | 8 +++---- engines/lastexpress/entities/pascale.cpp | 4 ++-- engines/lastexpress/entities/rebecca.cpp | 4 ++-- engines/lastexpress/entities/servers0.cpp | 12 +++++------ engines/lastexpress/entities/servers1.cpp | 4 ++-- engines/lastexpress/entities/tatiana.cpp | 20 ++++++++--------- engines/lastexpress/entities/vesna.cpp | 4 ++-- 23 files changed, 145 insertions(+), 147 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index c224b57abc..7916f88662 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -1650,12 +1650,12 @@ IMPLEMENT_FUNCTION(48, Abbot, function48) if (ENTITY_PARAM(0, 1)) getData()->inventoryItem = kItemInvalid; - UPDATE_PARAM_PROC(params->param1, getState()->time, 1800) + if (Entity::updateParameter(params->param1, getState()->time, 1800)) { getData()->inventoryItem = kItemNone; setCallback(4); setup_updatePosition("126C", kCarRedSleeping, 52); - UPDATE_PARAM_PROC_END + } TIME_CHECK_CALLBACK_INVENTORY(kTime2533500, params->param2, 5, setup_callbackActionRestaurantOrSalon); break; diff --git a/engines/lastexpress/entities/alexei.cpp b/engines/lastexpress/entities/alexei.cpp index a2564dd924..b31a9956bc 100644 --- a/engines/lastexpress/entities/alexei.cpp +++ b/engines/lastexpress/entities/alexei.cpp @@ -751,7 +751,7 @@ IMPLEMENT_FUNCTION(22, Alexei, function22) break; case kActionNone: - UPDATE_PARAM_PROC(params->param2, getState()->time, params->param2) + if (Entity::updateParameter(params->param2, getState()->time, params->param2)) { if (getEntities()->isSomebodyInsideRestaurantOrSalon()) { getData()->location = kLocationOutsideCompartment; getData()->inventoryItem = kItemNone; @@ -760,7 +760,7 @@ IMPLEMENT_FUNCTION(22, Alexei, function22) setup_updatePosition("103D", kCarRestaurant, 52); break; } - UPDATE_PARAM_PROC_END + } if (params->param3 == kTimeInvalid || getState()->time <= kTime1111500) break; @@ -1333,22 +1333,22 @@ IMPLEMENT_FUNCTION(35, Alexei, function35) case kActionNone: if (getEntities()->isInSalon(kEntityPlayer)) { - UPDATE_PARAM_PROC(params->param2, getState()->time, 2700) + if (Entity::updateParameter(params->param2, getState()->time, 2700)) { setCallback(1); setup_callbackActionRestaurantOrSalon(); break; - UPDATE_PARAM_PROC_END + } } else { params->param2 = 0; } - UPDATE_PARAM_PROC(params->param3, getState()->time, params->param1) + if (Entity::updateParameter(params->param3, getState()->time, params->param1)) { if (getEntities()->isSomebodyInsideRestaurantOrSalon()) { setCallback(3); setup_function15(); break; } - UPDATE_PARAM_PROC_END + } label_callback_3: if (!Entity::updateParameter(params->param4, getState()->time, 9000)) diff --git a/engines/lastexpress/entities/anna.cpp b/engines/lastexpress/entities/anna.cpp index 80a5144bbe..ab7163a67c 100644 --- a/engines/lastexpress/entities/anna.cpp +++ b/engines/lastexpress/entities/anna.cpp @@ -198,12 +198,12 @@ IMPLEMENT_FUNCTION(12, Anna, function12) params->param2 = 1; if (params->param6) { - UPDATE_PARAM_PROC(params->param7, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param7, getState()->timeTicks, 75)) { getSavePoints()->push(kEntityAnna, kEntityAnna, kActionEndSound); params->param6 = 0; params->param7 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param4) { @@ -669,11 +669,11 @@ IMPLEMENT_FUNCTION_I(18, Anna, function18, TimeValue) } if (params->param5 && !params->param4) { - UPDATE_PARAM_PROC(params->param6, getState()->time, 900) + if (Entity::updateParameter(params->param6, getState()->time, 900)) { params->param2 |= kItemScarf; params->param5 = 0; params->param6 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param3) { @@ -1152,11 +1152,11 @@ IMPLEMENT_FUNCTION(29, Anna, function29) case kActionNone: if (params->param2) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 900) + if (Entity::updateParameter(params->param3, getState()->time, 900)) { getData()->inventoryItem = (InventoryItem)(getData()->inventoryItem | kItemScarf); params->param2 = 0; params->param3 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param1) { @@ -1415,11 +1415,11 @@ IMPLEMENT_FUNCTION(34, Anna, function34) case kActionNone: if (!params->param1 && getEntities()->isPlayerPosition(kCarRedSleeping, 60)) { - UPDATE_PARAM_PROC(params->param2, getState()->time, 150) + if (Entity::updateParameter(params->param2, getState()->time, 150)) { setCallback(1); setup_draw("419B"); break; - UPDATE_PARAM_PROC_END + } } label_callback_1: @@ -2098,11 +2098,11 @@ IMPLEMENT_FUNCTION(48, Anna, function48) break; if (params->param3 != kTimeInvalid && getState()->time > kTime1969200) { - UPDATE_PARAM_PROC_TIME(kTime1983600, (!getEntities()->isInRestaurant(kEntityPlayer) || getSoundQueue()->isBuffered(kEntityBoutarel)), params->param3, 150) + if (Entity::updateParameterTime(kTime1983600, (!getEntities()->isInRestaurant(kEntityPlayer) || getSoundQueue()->isBuffered(kEntityBoutarel)), params->param3, 150)) { setCallback(3); setup_playSound("Aug3007A"); break; - UPDATE_PARAM_PROC_END + } } label_callback_4: @@ -2392,18 +2392,18 @@ IMPLEMENT_FUNCTION(53, Anna, function53) case kActionNone: if (getProgress().field_48 && params->param5 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(kTime2065500, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param5, 150) + if (Entity::updateParameterTime(kTime2065500, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param5, 150)) { setup_function54(); break; - UPDATE_PARAM_PROC_END + } } if (params->param3) { - UPDATE_PARAM_PROC(params->param6, getState()->time, 9000) + if (Entity::updateParameter(params->param6, getState()->time, 9000)) { params->param4 = !params->param4; getEntities()->drawSequenceLeft(kEntityAnna, params->param4 ? "417B" : "417A"); params->param6 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param1) { @@ -2546,11 +2546,11 @@ IMPLEMENT_FUNCTION(54, Anna, function54) if (params->param3) { TIME_CHECK(kTime2079000, params->param5, setup_function55); - UPDATE_PARAM_PROC(params->param6, getState()->time, 9000) + if (Entity::updateParameter(params->param6, getState()->time, 9000)) { params->param4 = !params->param4; getEntities()->drawSequenceLeft(kEntityAnna, params->param4 ? "417B" : "417A"); params->param6 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param1) { diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index d874c666f7..5ae8d11b95 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -538,10 +538,10 @@ label_continue: break; if (params->param6) { - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 1), getState()->time, 6300) + if (Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->time, 6300)) { params->param6 = 0; CURRENT_PARAM(1, 1) = 0; - UPDATE_PARAM_PROC_END + } } if (!params->param4 @@ -804,7 +804,7 @@ IMPLEMENT_FUNCTION_I(23, August, function23, TimeValue) } label_callback_8: - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 4), getState()->timeTicks, 75) + if (Entity::updateParameter(CURRENT_PARAM(1, 4), getState()->timeTicks, 75)) { getEntities()->exitCompartment(kEntityAugust, kObjectCompartment1, true); if (getProgress().eventCorpseMovedFromFloor) { @@ -820,7 +820,7 @@ label_callback_8: setup_savegame(kSavegameTypeEvent, kEventAugustFindCorpse); } break; - UPDATE_PARAM_PROC_END + } label_callback_9: if (params->param3 && params->param1 < getState()->time && !CURRENT_PARAM(1, 5)) { @@ -1634,9 +1634,9 @@ IMPLEMENT_FUNCTION(32, August, function32) break; case kActionNone: - UPDATE_PARAM_PROC_TIME(kTime1179000, (!getEntities()->isInSalon(kEntityAnna) || getEntities()->isInSalon(kEntityPlayer)), params->param6, 0); + if (Entity::updateParameterTime(kTime1179000, (!getEntities()->isInSalon(kEntityAnna) || getEntities()->isInSalon(kEntityPlayer)), params->param6, 0)) { getSavePoints()->push(kEntityAugust, kEntityAnna, kAction123712592); - UPDATE_PARAM_PROC_END + } if (params->param1 && getEntities()->isSomebodyInsideRestaurantOrSalon()) { if (!params->param4) { @@ -1645,13 +1645,13 @@ IMPLEMENT_FUNCTION(32, August, function32) } if (params->param7 != kTimeInvalid && params->param4 < getState()->time) { - UPDATE_PARAM_PROC_TIME(params->param5, getEntities()->isInSalon(kEntityPlayer), params->param7, 0); + if (Entity::updateParameterTime((TimeValue)params->param5, getEntities()->isInSalon(kEntityPlayer), params->param7, 0)) { getData()->location = kLocationOutsideCompartment; setCallback(5); setup_updatePosition("109D", kCarRestaurant, 56); break; - UPDATE_PARAM_PROC_END + } } } @@ -3224,9 +3224,9 @@ IMPLEMENT_FUNCTION(63, August, function63) break; case kActionNone: - UPDATE_PARAM_PROC(params->param3, getState()->time, 1800) + if (Entity::updateParameter(params->param3, getState()->time, 1800)) { getData()->inventoryItem = kItemInvalid; - UPDATE_PARAM_PROC_END + } if (getState()->time > kTime2488500 && !params->param4) { params->param4 = 1; diff --git a/engines/lastexpress/entities/boutarel.cpp b/engines/lastexpress/entities/boutarel.cpp index ab8a0b9003..2a8c6603a4 100644 --- a/engines/lastexpress/entities/boutarel.cpp +++ b/engines/lastexpress/entities/boutarel.cpp @@ -646,11 +646,11 @@ IMPLEMENT_FUNCTION(20, Boutarel, function20) break; if (!params->param2) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 4500) + if (Entity::updateParameter(params->param3, getState()->time, 4500)) { setCallback(3); setup_playSound("MRB1078A"); break; - UPDATE_PARAM_PROC_END + } } TIME_CHECK_CALLBACK_1(kTime1138500, params->param4, 4, setup_function14, false); @@ -936,9 +936,9 @@ IMPLEMENT_FUNCTION(29, Boutarel, function29) break; case kActionNone: - UPDATE_PARAM_PROC(params->param2, getState()->time, 450) + if (Entity::updateParameter(params->param2, getState()->time, 450)) { getSavePoints()->push(kEntityBoutarel, kEntityServers1, kAction256200848); - UPDATE_PARAM_PROC_END + } if (!params->param1) break; diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index 76165800f2..c5631173b4 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -393,13 +393,13 @@ IMPLEMENT_FUNCTION(8, Chapters, chapter1Handler) if (!getProgress().isTrainRunning || getState()->time >= kTime1458000) goto label_processStations; - UPDATE_PARAM_PROC(params->param6, getState()->timeTicks, params->param2) + if (Entity::updateParameter(params->param6, getState()->timeTicks, params->param2)) { // Play sound FX getSound()->playLocomotiveSound(); params->param2 = 225 * (4 * rnd(5) + 20); params->param6 = 0; - UPDATE_PARAM_PROC_END + } label_processStations: // Process stations @@ -896,15 +896,15 @@ IMPLEMENT_FUNCTION(15, Chapters, chapter3Handler) case kActionNone: if (getProgress().isTrainRunning) { - UPDATE_PARAM_PROC(params->param4, getState()->timeTicks, params->param1) + if (Entity::updateParameter(params->param4, getState()->timeTicks, params->param1)) { getSound()->playLocomotiveSound(); params->param1 = 225 * (4 * rnd(5) + 20); params->param4 = 0; - UPDATE_PARAM_PROC_END + } } - UPDATE_PARAM_PROC(params->param5, getState()->timeTicks, params->param2) + if (Entity::updateParameter(params->param5, getState()->timeTicks, params->param2)) { switch (rnd(2)) { default: break; @@ -920,7 +920,7 @@ IMPLEMENT_FUNCTION(15, Chapters, chapter3Handler) params->param2 = 225 * (4 * rnd(6) + 8); params->param5 = 0; - UPDATE_PARAM_PROC_END + } TIME_CHECK_CALLBACK_2(kTimeEnterSalzbourg, params->param6, 1, setup_enterStation, "Salzburg", kCitySalzbourg); @@ -1195,15 +1195,15 @@ IMPLEMENT_FUNCTION(19, Chapters, chapter4Handler) case kActionNone: if (getProgress().isTrainRunning) { - UPDATE_PARAM_PROC(params->param6, getState()->timeTicks, params->param4); + if (Entity::updateParameter(params->param6, getState()->timeTicks, params->param4)) { getSound()->playLocomotiveSound(); params->param4 = 225 * (4 * rnd(5) + 20); params->param6 = 0; - UPDATE_PARAM_PROC_END + } } - UPDATE_PARAM_PROC(params->param7, getState()->timeTicks, params->param5) + if (Entity::updateParameter(params->param7, getState()->timeTicks, params->param5)) { switch (rnd(2)) { default: break; @@ -1219,7 +1219,7 @@ IMPLEMENT_FUNCTION(19, Chapters, chapter4Handler) params->param5 = 225 * (4 * rnd(6) + 8); params->param7 = 0; - UPDATE_PARAM_PROC_END + } TIME_CHECK_CALLBACK_2(kTimeEnterPoszony, params->param8, 1, setup_enterStation, "Pozsony", kCityPoszony); diff --git a/engines/lastexpress/entities/cooks.cpp b/engines/lastexpress/entities/cooks.cpp index a3fb69aeb9..62a1e0fdb6 100644 --- a/engines/lastexpress/entities/cooks.cpp +++ b/engines/lastexpress/entities/cooks.cpp @@ -434,12 +434,12 @@ IMPLEMENT_FUNCTION(11, Cooks, chapter3Handler) break; case kActionNone: - UPDATE_PARAM_PROC(params->param4, getState()->time, params->param2) + if (Entity::updateParameter(params->param4, getState()->time, params->param2)) { // Broken plate sound getSound()->playSound(kEntityPlayer, "LIB122", getSound()->getSoundFlag(kEntityCooks)); params->param2 = 225 * (4 * rnd(30) + 120); params->param4 = 0; - UPDATE_PARAM_PROC_END + } if (getState()->time > kTime2079000 && !params->param5) { params->param1 = 0; diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index c589b8f0f8..4458632f2d 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -908,9 +908,9 @@ IMPLEMENT_FUNCTION_II(20, Coudert, function20, ObjectIndex, ObjectIndex) break; case kActionNone: - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 3), getState()->time, 300) + if (Entity::updateParameter(CURRENT_PARAM(1, 3), getState()->time, 300)) { getSound()->playSound(kEntityPlayer, "ZFX1004", getSound()->getSoundFlag(kEntityCoudert)); - UPDATE_PARAM_PROC_END + } if (!Entity::updateParameter(CURRENT_PARAM(1, 4), getState()->time, 900)) break; @@ -2281,14 +2281,14 @@ label_callback_9: label_callback_10: if (getState()->time > kTime1189800 && !ENTITY_PARAM(0, 1) && !ENTITY_PARAM(2, 1)) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 2700); + if (Entity::updateParameter(params->param3, getState()->time, 2700)) { ENTITY_PARAM(0, 2) = 1; ENTITY_PARAM(0, 1) = 1; getEntities()->drawSequenceLeft(kEntityCoudert, "697F"); params->param3 = 0; - UPDATE_PARAM_PROC_END + } } if (!ENTITY_PARAM(0, 2)) @@ -3539,11 +3539,11 @@ label_callback_1: params->param2 = (uint)(getState()->time + 4500); if (params->param3 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(params->param2, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param3, 0) + if (Entity::updateParameterTime((TimeValue)params->param2, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param3, 0)) { setCallback(2); setup_function55(); break; - UPDATE_PARAM_PROC_END + } } } diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 664b3fa70b..04ae6493c3 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -601,11 +601,11 @@ void Entity::callbackAction() { // Helper functions ////////////////////////////////////////////////////////////////////////// -bool Entity::updateParameter(uint ¶meter, uint timeValue, uint delta) { +bool Entity::updateParameter(uint ¶meter, uint timeType, uint delta) { if (!parameter) - parameter = (uint)(timeValue + delta); + parameter = (uint)(timeType + delta); - if (parameter >= timeValue) + if (parameter >= timeType) return false; parameter = kTimeInvalid; @@ -613,12 +613,26 @@ bool Entity::updateParameter(uint ¶meter, uint timeValue, uint delta) { return true; } -bool Entity::updateParameterCheck(uint ¶meter, uint timeValue, uint delta) { - if (parameter && parameter >= timeValue) +bool Entity::updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta) { + if (getState()->time <= timeValue) { + if (check || !parameter) + parameter = (uint)(getState()->time + delta); + } + + if (parameter >= getState()->time && getState()->time <= timeValue) + return false; + + parameter = kTimeInvalid; + + return true; +} + +bool Entity::updateParameterCheck(uint ¶meter, uint timeType, uint delta) { + if (parameter && parameter >= timeType) return false; if (!parameter) - parameter = (uint)(timeValue + delta); + parameter = (uint)(timeType + delta); return true; } diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index ce8aa168a4..73114a1436 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -870,8 +870,9 @@ protected: // Helper functions ////////////////////////////////////////////////////////////////////////// - bool updateParameter(uint ¶meter, uint time, uint delta); - bool updateParameterCheck(uint ¶meter, uint time, uint delta); + bool updateParameter(uint ¶meter, uint timeType, uint delta); + bool updateParameterCheck(uint ¶meter, uint timeType, uint delta); + bool updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta); void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 4b97556a75..c4fc36a8ee 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -371,23 +371,6 @@ void class::setup_##name() { \ parameter = kTimeInvalid; \ } -// Updating parameter with code inside the check -#define UPDATE_PARAM_PROC(parameter, type, value) \ - if (!parameter) \ - parameter = (uint)(type + value); \ - if (parameter < type) { \ - parameter = kTimeInvalid; - -#define UPDATE_PARAM_PROC_TIME(timeValue, test, parameter, value) \ - if (getState()->time <= timeValue) { \ - if (test || !parameter) \ - parameter = (uint)(getState()->time + value); \ - } \ - if (parameter < getState()->time || getState()->time > timeValue) { \ - parameter = kTimeInvalid; - -#define UPDATE_PARAM_PROC_END } - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/francois.cpp b/engines/lastexpress/entities/francois.cpp index b99dbe466b..e4d401d202 100644 --- a/engines/lastexpress/entities/francois.cpp +++ b/engines/lastexpress/entities/francois.cpp @@ -278,7 +278,7 @@ IMPLEMENT_FUNCTION_I(11, Francois, function11, TimeValue) case kActionNone: if (!getSoundQueue()->isBuffered(kEntityFrancois)) { - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 1), getState()->timeTicks, params->param6) + if (Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->timeTicks, params->param6)) { switch (rnd(7)) { default: break; @@ -311,7 +311,7 @@ IMPLEMENT_FUNCTION_I(11, Francois, function11, TimeValue) params->param6 = 15 * rnd(7); CURRENT_PARAM(1, 1) = 0; - UPDATE_PARAM_PROC_END + } } if (!getEntities()->hasValidFrame(kEntityFrancois) || !getEntities()->isWalkingOppositeToPlayer(kEntityFrancois)) @@ -998,11 +998,11 @@ label_callback_5: } if (params->param5 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(kTimeEnd, !getEntities()->isDistanceBetweenEntities(kEntityFrancois, kEntityPlayer, 2000), params->param5, 75); + if (Entity::updateParameterTime(kTimeEnd, !getEntities()->isDistanceBetweenEntities(kEntityFrancois, kEntityPlayer, 2000), params->param5, 75)) { setCallback(6); setup_playSound("Fra2010"); break; - UPDATE_PARAM_PROC_END + } } label_callback_6: diff --git a/engines/lastexpress/entities/kahina.cpp b/engines/lastexpress/entities/kahina.cpp index 2124de1687..08f845f5ba 100644 --- a/engines/lastexpress/entities/kahina.cpp +++ b/engines/lastexpress/entities/kahina.cpp @@ -394,10 +394,10 @@ IMPLEMENT_FUNCTION(15, Kahina, function15) case kActionNone: if (params->param2 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(params->param1, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param2, 0) + if (Entity::updateParameterTime((TimeValue)params->param1, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param2, 0)) { setCallback(9); setup_updateEntity(kCarRedSleeping, kPosition_4070); - UPDATE_PARAM_PROC_END + } } break; @@ -580,18 +580,18 @@ IMPLEMENT_FUNCTION(17, Kahina, chapter2Handler) case kActionNone: if (params->param1) { - UPDATE_PARAM_PROC(params->param2, getState()->time, 9000) + if (Entity::updateParameter(params->param2, getState()->time, 9000)) { params->param1 = 1; params->param2 = 0; - UPDATE_PARAM_PROC_END + } } if (getEvent(kEventKahinaAskSpeakFirebird) && getEvent(kEventKronosConversationFirebird) && getEntities()->isInsideTrainCar(kEntityPlayer, kCarKronos)) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 900) + if (Entity::updateParameter(params->param3, getState()->time, 900)) { setCallback(1); setup_savegame(kSavegameTypeEvent, kEventKronosConversationFirebird); break; - UPDATE_PARAM_PROC_END + } } label_callback_3: @@ -785,10 +785,10 @@ label_callback_2: } if (!params->param1) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 9000) + if (Entity::updateParameter(params->param3, getState()->time, 9000)) { params->param1 = 1; params->param3 = 0; - UPDATE_PARAM_PROC_END + } } if (getEvent(kEventKahinaAskSpeakFirebird) @@ -927,11 +927,11 @@ IMPLEMENT_FUNCTION(21, Kahina, function21) params->param3 = (uint)getState()->time + 4500; if (params->param6 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(params->param3, (getEntities()->isPlayerPosition(kCarKronos, 80) || getEntities()->isPlayerPosition(kCarKronos, 88)), params->param5, 0) + if (Entity::updateParameterTime((TimeValue)params->param3, (getEntities()->isPlayerPosition(kCarKronos, 80) || getEntities()->isPlayerPosition(kCarKronos, 88)), params->param5, 0)) { setCallback(2); setup_function23(); break; - UPDATE_PARAM_PROC_END + } } } @@ -942,14 +942,14 @@ label_callback_2: params->param4 = (uint)getState()->time + 4500; if (params->param6 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(params->param3, (getEntities()->isPlayerPosition(kCarKronos, 80) || getEntities()->isPlayerPosition(kCarKronos, 88)), params->param6, 0) + if (Entity::updateParameterTime((TimeValue)params->param3, (getEntities()->isPlayerPosition(kCarKronos, 80) || getEntities()->isPlayerPosition(kCarKronos, 88)), params->param6, 0)) { getSound()->playSound(kEntityPlayer, "LIB014", getSound()->getSoundFlag(kEntityKahina)); getSound()->playSound(kEntityPlayer, "LIB015", getSound()->getSoundFlag(kEntityKahina)); getEntities()->drawSequenceLeft(kEntityKahina, "202a"); params->param2 = 0; - UPDATE_PARAM_PROC_END + } } } diff --git a/engines/lastexpress/entities/kronos.cpp b/engines/lastexpress/entities/kronos.cpp index c9fe0dcde1..5dd790ce12 100644 --- a/engines/lastexpress/entities/kronos.cpp +++ b/engines/lastexpress/entities/kronos.cpp @@ -293,10 +293,10 @@ IMPLEMENT_FUNCTION(15, Kronos, function15) case kActionNone: if (params->param1 && !getEntities()->isInSalon(kEntityBoutarel)) { - UPDATE_PARAM_PROC(params->param2, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param2, getState()->timeTicks, 75)) { setup_function16(); break; - UPDATE_PARAM_PROC_END + } } if (params->param3 != kTimeInvalid && getState()->time > kTime2002500) { @@ -526,9 +526,9 @@ IMPLEMENT_FUNCTION(20, Kronos, function20) } if (CURRENT_PARAM(1, 2) != kTimeInvalid && params->param7 < getState()->time) { - UPDATE_PARAM_PROC_TIME(params->param8, !params->param1, CURRENT_PARAM(1, 2), 450) + if (Entity::updateParameterTime((TimeValue)params->param8, !params->param1, CURRENT_PARAM(1, 2), 450)) { getSavePoints()->push(kEntityKronos, kEntityKahina, kAction237555748); - UPDATE_PARAM_PROC_END + } } if (!params->param1) diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index c093ac4b30..9d9225f49b 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -534,20 +534,20 @@ IMPLEMENT_FUNCTION_II(13, Mertens, function13, bool, bool) Entity::savegameBloodJacket(); if (!params->param2 && !params->param3) { - UPDATE_PARAM_PROC(params->param4, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param4, getState()->timeTicks, 75)) { getData()->inventoryItem = kItemNone; setCallback(5); setup_function18(); break; - UPDATE_PARAM_PROC_END + } } - UPDATE_PARAM_PROC(params->param5, getState()->timeTicks, 225) + if (Entity::updateParameter(params->param5, getState()->timeTicks, 225)) { getData()->inventoryItem = kItemNone; setCallback(6); setup_function18(); break; - UPDATE_PARAM_PROC_END + } getData()->inventoryItem = (getProgress().chapter == kChapter1 && !ENTITY_PARAM(2, 1) @@ -1059,9 +1059,9 @@ IMPLEMENT_FUNCTION_II(21, Mertens, function21, ObjectIndex, ObjectIndex) break; case kActionNone: - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 4), getState()->time, 300) + if (Entity::updateParameter(CURRENT_PARAM(1, 4), getState()->time, 300)) { getSound()->playSound(kEntityPlayer, "ZFX1004", getSound()->getSoundFlag(kEntityMertens)); - UPDATE_PARAM_PROC_END + } if (!Entity::updateParameter(CURRENT_PARAM(1, 5), getState()->time, 900)) break; @@ -1616,13 +1616,13 @@ IMPLEMENT_FUNCTION_I(27, Mertens, tylerCompartment, MertensActionType) break; } - UPDATE_PARAM_PROC(params->param2, getState()->timeTicks, 150) + if (Entity::updateParameter(params->param2, getState()->timeTicks, 150)) { getObjects()->update(kObjectCompartment1, kEntityPlayer, getObjects()->get(kObjectCompartment1).location, kCursorNormal, kCursorNormal); setCallback(10); setup_playSound16("CON1018A"); break; - UPDATE_PARAM_PROC_END + } label_callback10: if (!params->param3) @@ -3025,11 +3025,11 @@ IMPLEMENT_FUNCTION(42, Mertens, function42) label_callback_8: if (getState()->time > kTime1215000 && !ENTITY_PARAM(0, 1) && !ENTITY_PARAM(2, 1)) { - UPDATE_PARAM_PROC(params->param5, getState()->time, 2700) + if (Entity::updateParameter(params->param5, getState()->time, 2700)) { getEntities()->drawSequenceLeft(kEntityMertens, "601E"); ENTITY_PARAM(0, 1) = 1; params->param5 = 0; - UPDATE_PARAM_PROC_END + } } if (ENTITY_PARAM(0, 8)) { diff --git a/engines/lastexpress/entities/milos.cpp b/engines/lastexpress/entities/milos.cpp index 8ebb23b024..5c5d481938 100644 --- a/engines/lastexpress/entities/milos.cpp +++ b/engines/lastexpress/entities/milos.cpp @@ -176,11 +176,11 @@ IMPLEMENT_FUNCTION_I(11, Milos, function11, TimeValue) } if (params->param2) { - UPDATE_PARAM_PROC(params->param8, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param8, getState()->timeTicks, 75)) { params->param2 = 0; params->param3 = 1; getObjects()->update(kObjectCompartmentG, kEntityMilos, kObjectLocation1, kCursorNormal, kCursorNormal); - UPDATE_PARAM_PROC_END + } } params->param8 = 0; @@ -189,10 +189,10 @@ IMPLEMENT_FUNCTION_I(11, Milos, function11, TimeValue) break; if (params->param6) { - UPDATE_PARAM_PROC(CURRENT_PARAM(1, 1), getState()->time, 4500) + if (Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->time, 4500)) { params->param6 = 0; CURRENT_PARAM(1, 1) = 0; - UPDATE_PARAM_PROC_END + } } if (!getProgress().field_CC) { @@ -730,11 +730,11 @@ IMPLEMENT_FUNCTION(15, Milos, chapter1Handler) } if (getEntities()->isPlayerPosition(kCarRestaurant, 61) && !params->param1) { - UPDATE_PARAM_PROC(params->param4, getState()->timeTicks, 45) + if (Entity::updateParameter(params->param4, getState()->timeTicks, 45)) { setCallback(1); setup_draw("009C"); break; - UPDATE_PARAM_PROC_END + } } if (getEntities()->isPlayerPosition(kCarRestaurant, 70) && !params->param2) { @@ -1287,10 +1287,10 @@ IMPLEMENT_FUNCTION(25, Milos, function25) case kActionNone: if (!getEvent(kEventMilosCompartmentVisitTyler) && !getProgress().field_54 && !ENTITY_PARAM(0, 4)) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 13500) + if (Entity::updateParameter(params->param3, getState()->time, 13500)) { getSavePoints()->push(kEntityMilos, kEntityVesna, kAction155913424); params->param3 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param1) { diff --git a/engines/lastexpress/entities/mmeboutarel.cpp b/engines/lastexpress/entities/mmeboutarel.cpp index 323e686ec3..888adeb372 100644 --- a/engines/lastexpress/entities/mmeboutarel.cpp +++ b/engines/lastexpress/entities/mmeboutarel.cpp @@ -400,7 +400,7 @@ IMPLEMENT_FUNCTION(13, MmeBoutarel, function13) case kActionNone: if (!getSoundQueue()->isBuffered(kEntityMmeBoutarel) && params->param6 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(params->param1, !getEntities()->isDistanceBetweenEntities(kEntityMmeBoutarel, kEntityPlayer, 2000), params->param6, 0) + if (Entity::updateParameterTime((TimeValue)params->param1, !getEntities()->isDistanceBetweenEntities(kEntityMmeBoutarel, kEntityPlayer, 2000), params->param6, 0)) { getObjects()->update(kObjectCompartmentD, kEntityPlayer, kObjectLocation1, kCursorNormal, kCursorNormal); getObjects()->update(kObject51, kEntityPlayer, kObjectLocation1, kCursorNormal, kCursorNormal); @@ -412,16 +412,16 @@ IMPLEMENT_FUNCTION(13, MmeBoutarel, function13) setCallback(1); setup_playSound("MME1037"); break; - UPDATE_PARAM_PROC_END + } } label_callback_1: if (getProgress().field_24 && params->param7 != kTimeInvalid) { - UPDATE_PARAM_PROC_TIME(kTime1093500, (!params->param5 || !getEntities()->isPlayerInCar(kCarRedSleeping)), params->param7, 0) + if (Entity::updateParameterTime(kTime1093500, (!params->param5 || !getEntities()->isPlayerInCar(kCarRedSleeping)), params->param7, 0)) { setCallback(2); setup_function11(); break; - UPDATE_PARAM_PROC_END + } } TIME_CHECK(kTime1094400, params->param8, setup_function14); diff --git a/engines/lastexpress/entities/pascale.cpp b/engines/lastexpress/entities/pascale.cpp index e74cf3490f..6e9f992390 100644 --- a/engines/lastexpress/entities/pascale.cpp +++ b/engines/lastexpress/entities/pascale.cpp @@ -1115,13 +1115,13 @@ IMPLEMENT_FUNCTION(33, Pascale, function33) case kActionNone: if (params->param4) { - UPDATE_PARAM_PROC(params->param5, getState()->time, 4500) + if (Entity::updateParameter(params->param5, getState()->time, 4500)) { getObjects()->update(kObjectCompartmentG, kEntityPascale, kObjectLocation1, kCursorNormal, kCursorNormal); setCallback(1); setup_playSound("Wat5010"); break; - UPDATE_PARAM_PROC_END + } } label_callback1: diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 96deaaf97f..c0c22fa1da 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -498,14 +498,14 @@ IMPLEMENT_FUNCTION_I(20, Rebecca, function20, TimeValue) if (!params->param2) { params->param6 = 0; } else { - UPDATE_PARAM_PROC(params->param6, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param6, getState()->timeTicks, 75)) { params->param2 = 0; params->param3 = 1; getObjects()->update(kObjectCompartmentE, kEntityRebecca, kObjectLocation1, kCursorNormal, kCursorNormal); getObjects()->update(kObject52, kEntityRebecca, kObjectLocation1, kCursorNormal, kCursorNormal); params->param6 = 0; - UPDATE_PARAM_PROC_END + } } if (getProgress().chapter == kChapter1 && !ENTITY_PARAM(0, 3)) { diff --git a/engines/lastexpress/entities/servers0.cpp b/engines/lastexpress/entities/servers0.cpp index 56fc0e6056..73e0d34722 100644 --- a/engines/lastexpress/entities/servers0.cpp +++ b/engines/lastexpress/entities/servers0.cpp @@ -312,17 +312,17 @@ IMPLEMENT_FUNCTION(20, Servers0, chapter1Handler) case kActionNone: if (params->param2) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 2700); + if (Entity::updateParameter(params->param3, getState()->time, 2700)) { ENTITY_PARAM(0, 4) = 1; params->param2 = 0; - UPDATE_PARAM_PROC_END + } } if (params->param1) { - UPDATE_PARAM_PROC(params->param4, getState()->time, 4500) + if (Entity::updateParameter(params->param4, getState()->time, 4500)) { ENTITY_PARAM(0, 5) = 1; params->param1 = 0; - UPDATE_PARAM_PROC_END + } } if (!getEntities()->isInKitchen(kEntityServers0) && !getEntities()->isSomebodyInsideRestaurantOrSalon()) @@ -733,10 +733,10 @@ IMPLEMENT_FUNCTION(32, Servers0, chapter4Handler) break; case kActionNone: - UPDATE_PARAM_PROC(params->param2, getState()->time, 3600) + if (Entity::updateParameter(params->param2, getState()->time, 3600)) { ENTITY_PARAM(1, 8) = 1; params->param1 = 0; - UPDATE_PARAM_PROC_END + } if (!getEntities()->isInKitchen(kEntityServers1) || !getEntities()->isSomebodyInsideRestaurantOrSalon()) break; diff --git a/engines/lastexpress/entities/servers1.cpp b/engines/lastexpress/entities/servers1.cpp index 24bf678f3a..a8f4c0233c 100644 --- a/engines/lastexpress/entities/servers1.cpp +++ b/engines/lastexpress/entities/servers1.cpp @@ -563,10 +563,10 @@ IMPLEMENT_FUNCTION(26, Servers1, chapter4Handler) case kActionNone: if (params->param2) { - UPDATE_PARAM_PROC(params->param2, getState()->time, 900) + if (Entity::updateParameter(params->param2, getState()->time, 900)) { ENTITY_PARAM(1, 5) = 1; params->param1 = 0; - UPDATE_PARAM_PROC_END + } } if (!getEntities()->isInKitchen(kEntityServers1) || !getEntities()->isSomebodyInsideRestaurantOrSalon()) diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index 9c2c582130..992d38e017 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -374,10 +374,10 @@ IMPLEMENT_FUNCTION(18, Tatiana, function18) } if (!params->param1) { - UPDATE_PARAM_PROC(params->param3, getState()->time, 4500) + if (Entity::updateParameter(params->param3, getState()->time, 4500)) { getEntities()->drawSequenceRight(kEntityTatiana, "806DS"); params->param1 = 1; - UPDATE_PARAM_PROC_END + } } } @@ -424,20 +424,20 @@ IMPLEMENT_FUNCTION(19, Tatiana, chapter1Handler) if (getSoundQueue()->isBuffered(kEntityTatiana) || !params->param4 || params->param3 == 2 || getSoundQueue()->isBuffered("TAT1066")) goto label_tatiana_chapter1_2; - UPDATE_PARAM_PROC(params->param5, getState()->timeTicks, 450) + if (Entity::updateParameter(params->param5, getState()->timeTicks, 450)) { getSound()->playSound(kEntityTatiana, params->param3 ? "TAT1069B" : "TAT1069A"); getProgress().field_64 = 1; params->param3++; params->param5 = 0; - UPDATE_PARAM_PROC_END + } if (getEntities()->isPlayerPosition(kCarRestaurant, 71)) { - UPDATE_PARAM_PROC(params->param6, getState()->timeTicks, 75) + if (Entity::updateParameter(params->param6, getState()->timeTicks, 75)) { getSound()->playSound(kEntityTatiana, params->param3 ? "TAT1069B" : "TAT1069A"); getProgress().field_64 = 1; params->param3++; params->param6 = 0; - UPDATE_PARAM_PROC_END + } } label_tatiana_chapter1_2: @@ -615,7 +615,7 @@ IMPLEMENT_FUNCTION(22, Tatiana, function22) if (params->param1 == kTimeInvalid || getState()->time <= kTime1179000) goto label_update; - UPDATE_PARAM_PROC_TIME(kTime1233000, ((!getEvent(kEventTatianaAskMatchSpeakRussian) && !getEvent(kEventTatianaAskMatch)) || getEntities()->isInGreenCarEntrance(kEntityPlayer)), params->param1, 0) + if (Entity::updateParameterTime(kTime1233000, ((!getEvent(kEventTatianaAskMatchSpeakRussian) && !getEvent(kEventTatianaAskMatch)) || getEntities()->isInGreenCarEntrance(kEntityPlayer)), params->param1, 0)) { label_update: if (!getEvent(kEventTatianaAskMatchSpeakRussian) && !getEvent(kEventTatianaAskMatch) @@ -624,7 +624,7 @@ label_update: getObjects()->update(kObject25, kEntityTatiana, kObjectLocation1, kCursorNormal, kCursorForward); getObjects()->update(kObjectTrainTimeTable, kEntityTatiana, kObjectLocation1, kCursorNormal, kCursorForward); } - UPDATE_PARAM_PROC_END + } params->param1 = kTimeInvalid; @@ -1284,13 +1284,13 @@ IMPLEMENT_FUNCTION(37, Tatiana, function37) params->param3 = (uint)getState()->time + 900; if (params->param4 != kTimeInvalid && params->param3 < getState()->time) { - UPDATE_PARAM_PROC_TIME(kTime2227500, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param4, 450) + if (Entity::updateParameterTime(kTime2227500, !getEntities()->isPlayerInCar(kCarRedSleeping), params->param4, 450)) { getProgress().field_5C = 1; if (getEntities()->isInsideCompartment(kEntityAnna, kCarRedSleeping, kPosition_4070)) { setup_function38(); break; } - UPDATE_PARAM_PROC_END + } } } diff --git a/engines/lastexpress/entities/vesna.cpp b/engines/lastexpress/entities/vesna.cpp index 6889be4335..f54f0f3231 100644 --- a/engines/lastexpress/entities/vesna.cpp +++ b/engines/lastexpress/entities/vesna.cpp @@ -1082,10 +1082,10 @@ IMPLEMENT_FUNCTION(30, Vesna, function30) case kActionNone: if (!params->param1) { - UPDATE_PARAM_PROC(params->param3, getState()->timeTicks, 120) + if (Entity::updateParameter(params->param3, getState()->timeTicks, 120)) { getSound()->playSound(kEntityVesna, "Ves50001", kFlagDefault); params->param1 = 1; - UPDATE_PARAM_PROC_END + } } if (!Entity::updateParameter(params->param4, getState()->timeTicks, 180)) -- cgit v1.2.3 From 82ad017a8e8614ca4c4141c4d1a8fd2a9c45010d Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Jul 2012 01:23:41 -0400 Subject: LASTEXPRESS: Replace UPDATE_PARAM_GOTO macro --- engines/lastexpress/entities/anna.cpp | 3 ++- engines/lastexpress/entities/august.cpp | 3 ++- engines/lastexpress/entities/entity_intern.h | 13 ------------- engines/lastexpress/entities/tatiana.cpp | 3 ++- engines/lastexpress/entities/train.cpp | 16 +++++++++------- engines/lastexpress/entities/vassili.cpp | 3 ++- 6 files changed, 17 insertions(+), 24 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/anna.cpp b/engines/lastexpress/entities/anna.cpp index ab7163a67c..0f326792eb 100644 --- a/engines/lastexpress/entities/anna.cpp +++ b/engines/lastexpress/entities/anna.cpp @@ -3277,7 +3277,8 @@ IMPLEMENT_FUNCTION(67, Anna, chapter4Handler) case kActionNone: if (getEntities()->isPlayerPosition(kCarRedSleeping, 46)) { - UPDATE_PARAM_GOTO(params->param4, getState()->timeTicks, 30, label_next); + if (!Entity::updateParameter(params->param4, getState()->timeTicks, 30)) + goto label_next; getScenes()->loadSceneFromPosition(kCarRedSleeping, 8); } diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index 5ae8d11b95..e863fe1d87 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -523,7 +523,8 @@ IMPLEMENT_FUNCTION_I(21, August, function21, TimeValue) } if (params->param2) { - UPDATE_PARAM_GOTO(params->param8, getState()->timeTicks, 75, label_continue); + if (!Entity::updateParameter(params->param8, getState()->timeTicks, 75)) + goto label_continue; params->param2 = 0; params->param3 = 1; diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index c4fc36a8ee..4a7aabff28 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -358,19 +358,6 @@ void class::setup_##name() { \ } \ } -////////////////////////////////////////////////////////////////////////// -// Param update -////////////////////////////////////////////////////////////////////////// - -// Todo: replace with UPDATE_PARAM_PROC as appropriate -#define UPDATE_PARAM_GOTO(parameter, type, value, label) { \ - if (!parameter) \ - parameter = (uint)(type + value); \ - if (parameter >= type) \ - goto label; \ - parameter = kTimeInvalid; \ -} - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index 992d38e017..b7c26bdd1c 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -1955,7 +1955,8 @@ IMPLEMENT_FUNCTION(48, Tatiana, function48) if (!params->param1 || getSoundQueue()->isBuffered(kEntityTatiana)) goto label_end; - UPDATE_PARAM_GOTO(params->param2, getState()->timeTicks, 5 * (3 * rnd(5) + 30), label_end); + if (!Entity::updateParameter(params->param2, getState()->timeTicks, 5 * (3 * rnd(5) + 30))) + goto label_end; getSound()->playSound(kEntityTatiana, "LIB012", kFlagDefault); params->param2 = 0; diff --git a/engines/lastexpress/entities/train.cpp b/engines/lastexpress/entities/train.cpp index 0830dffbef..e3f530ef25 100644 --- a/engines/lastexpress/entities/train.cpp +++ b/engines/lastexpress/entities/train.cpp @@ -267,18 +267,20 @@ IMPLEMENT_FUNCTION(8, Train, process) if ((getEntities()->isPlayerInCar(kCarGreenSleeping) || getEntities()->isPlayerInCar(kCarRedSleeping)) && params->param4 && !params->param5) { - params->param4 -= 1; + params->param4 -= 1; - if (!params->param4 && getProgress().jacket == kJacketGreen) { + if (!params->param4 && getProgress().jacket == kJacketGreen) { - getAction()->playAnimation(isNight() ? kEventCathSmokeNight : kEventCathSmokeDay); - params->param5 = 1; - getScenes()->processScene(); - } + getAction()->playAnimation(isNight() ? kEventCathSmokeNight : kEventCathSmokeDay); + params->param5 = 1; + getScenes()->processScene(); + } } if (params->param6) { - UPDATE_PARAM_GOTO(params1->param7, getState()->time, 900, label_process); + if (!Entity::updateParameter(params1->param7, getState()->time, 900)) + goto label_process; + getScenes()->loadSceneFromPosition(kCarRestaurant, 58); } diff --git a/engines/lastexpress/entities/vassili.cpp b/engines/lastexpress/entities/vassili.cpp index 6504df7928..5344e705f5 100644 --- a/engines/lastexpress/entities/vassili.cpp +++ b/engines/lastexpress/entities/vassili.cpp @@ -144,7 +144,8 @@ IMPLEMENT_FUNCTION(6, Vassili, function6) case kActionNone: if (getEntities()->isInsideCompartment(kEntityPlayer, kCarRedSleeping, kPosition_8200)) { - UPDATE_PARAM_GOTO(params->param3, getState()->timeTicks, params->param1, label_function7); + if (!Entity::updateParameter(params->param3, getState()->timeTicks, params->param1)) + goto label_function7; setCallback(1); setup_draw("303B"); -- cgit v1.2.3 From e985f7374fd20efc4574bc8320967deef7489d5a Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Jul 2012 01:25:03 -0400 Subject: LASTEXPRESS: Move Entity function declaration macros to entity.h --- engines/lastexpress/entities/entity.h | 31 +++++++++++++++++++++++++++- engines/lastexpress/entities/entity_intern.h | 30 --------------------------- 2 files changed, 30 insertions(+), 31 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 73114a1436..76abab6c2f 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -41,9 +41,38 @@ class Sequence; class SequenceFrame; struct SavePoint; +////////////////////////////////////////////////////////////////////////// +// Declaration +////////////////////////////////////////////////////////////////////////// +#define DECLARE_FUNCTION(name) \ + void setup_##name(); \ + void name(const SavePoint &savepoint); + +#define DECLARE_FUNCTION_1(name, param1) \ + void setup_##name(param1); \ + void name(const SavePoint &savepoint); + +#define DECLARE_FUNCTION_2(name, param1, param2) \ + void setup_##name(param1, param2); \ + void name(const SavePoint &savepoint); + +#define DECLARE_FUNCTION_3(name, param1, param2, param3) \ + void setup_##name(param1, param2, param3); \ + void name(const SavePoint &savepoint); + +#define DECLARE_FUNCTION_4(name, param1, param2, param3, param4) \ + void setup_##name(param1, param2, param3, param4); \ + void name(const SavePoint &savepoint); + +#define DECLARE_FUNCTION_NOSETUP(name) \ + void name(const SavePoint &savepoint); + +#define DECLARE_NULL_FUNCTION() \ + void setup_nullfunction(); ////////////////////////////////////////////////////////////////////////// // Callbacks +////////////////////////////////////////////////////////////////////////// #define ENTITY_CALLBACK(class, name, pointer) \ Common::Functor1Mem(pointer, &class::name) @@ -63,7 +92,7 @@ struct SavePoint; ((EntityData::EntityParametersIIII*)_data->getParameters(8, index))->param##id - +////////////////////////////////////////////////////////////////////////// class EntityData : Common::Serializable { public: diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 4a7aabff28..e62eeb0c56 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -25,36 +25,6 @@ namespace LastExpress { -////////////////////////////////////////////////////////////////////////// -// Declaration -////////////////////////////////////////////////////////////////////////// - -#define DECLARE_FUNCTION(name) \ - void setup_##name(); \ - void name(const SavePoint &savepoint); - -#define DECLARE_FUNCTION_1(name, param1) \ - void setup_##name(param1); \ - void name(const SavePoint &savepoint); - -#define DECLARE_FUNCTION_2(name, param1, param2) \ - void setup_##name(param1, param2); \ - void name(const SavePoint &savepoint); - -#define DECLARE_FUNCTION_3(name, param1, param2, param3) \ - void setup_##name(param1, param2, param3); \ - void name(const SavePoint &savepoint); - -#define DECLARE_FUNCTION_4(name, param1, param2, param3, param4) \ - void setup_##name(param1, param2, param3, param4); \ - void name(const SavePoint &savepoint); - -#define DECLARE_FUNCTION_NOSETUP(name) \ - void name(const SavePoint &savepoint); - -#define DECLARE_NULL_FUNCTION() \ - void setup_nullfunction(); - ////////////////////////////////////////////////////////////////////////// // Setup ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 8545991739848d878e61ff058e8fa1326261e634 Mon Sep 17 00:00:00 2001 From: Julien Date: Mon, 23 Jul 2012 14:28:41 -0400 Subject: LASTEXPRESS: Remove several TIME_CHECK* macros --- engines/lastexpress/entities/abbot.cpp | 9 ++--- engines/lastexpress/entities/alexei.cpp | 4 +-- engines/lastexpress/entities/alouan.cpp | 32 +++++++++++------ engines/lastexpress/entities/anna.cpp | 9 ++--- engines/lastexpress/entities/august.cpp | 8 ++--- engines/lastexpress/entities/boutarel.cpp | 7 ++-- engines/lastexpress/entities/cooks.cpp | 2 +- engines/lastexpress/entities/coudert.cpp | 29 ++++++++++------ engines/lastexpress/entities/entity.cpp | 51 ++++++++++++++++++++++++++++ engines/lastexpress/entities/entity.h | 8 +++++ engines/lastexpress/entities/entity_intern.h | 35 ------------------- engines/lastexpress/entities/francois.cpp | 28 +++++++++------ engines/lastexpress/entities/gendarmes.cpp | 2 +- engines/lastexpress/entities/hadija.cpp | 50 +++++++++++++++++---------- engines/lastexpress/entities/ivo.cpp | 4 +-- engines/lastexpress/entities/kahina.cpp | 4 +-- engines/lastexpress/entities/kronos.cpp | 9 +++-- engines/lastexpress/entities/mahmud.cpp | 5 +-- engines/lastexpress/entities/max.cpp | 2 +- engines/lastexpress/entities/mertens.cpp | 22 +++++++----- engines/lastexpress/entities/milos.cpp | 2 +- engines/lastexpress/entities/mmeboutarel.cpp | 8 +++-- engines/lastexpress/entities/rebecca.cpp | 11 +++--- engines/lastexpress/entities/salko.cpp | 2 +- engines/lastexpress/entities/sophie.cpp | 2 +- engines/lastexpress/entities/tatiana.cpp | 2 +- engines/lastexpress/entities/vassili.cpp | 2 +- engines/lastexpress/entities/verges.cpp | 10 +++--- engines/lastexpress/entities/vesna.cpp | 2 +- engines/lastexpress/entities/yasmin.cpp | 46 +++++++++++++++++-------- 30 files changed, 251 insertions(+), 156 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index 7916f88662..e0fe429520 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -691,7 +691,7 @@ IMPLEMENT_FUNCTION(28, Abbot, function28) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime2052000, params->param1, 1, setup_function29); + Entity::timeCheckCallback(kTime2052000, params->param1, 1, WRAP_SETUP_FUNCTION(Abbot, setup_function29)); break; case kActionDefault: @@ -1428,7 +1428,8 @@ IMPLEMENT_FUNCTION(43, Abbot, function43) } label_callback_1: - TIME_CHECK(kTime2466000, params->param5, setup_function44); + if (Entity::timeCheck(kTime2466000, params->param5, WRAP_SETUP_FUNCTION(Abbot, setup_function44))) + break; if (params->param3) { if (!Entity::updateParameter(params->param6, getState()->timeTicks, 75)) @@ -1657,7 +1658,7 @@ IMPLEMENT_FUNCTION(48, Abbot, function48) setup_updatePosition("126C", kCarRedSleeping, 52); } - TIME_CHECK_CALLBACK_INVENTORY(kTime2533500, params->param2, 5, setup_callbackActionRestaurantOrSalon); + Entity::timeCheckCallbackInventory(kTime2533500, params->param2, 5, WRAP_SETUP_FUNCTION(Abbot, setup_callbackActionRestaurantOrSalon)); break; case kAction1: @@ -1709,7 +1710,7 @@ IMPLEMENT_FUNCTION(48, Abbot, function48) getEntities()->drawSequenceLeft(kEntityAbbot, "126B"); params->param1 = 0; - TIME_CHECK_CALLBACK_INVENTORY(kTime2533500, params->param2, 5, setup_callbackActionRestaurantOrSalon); + Entity::timeCheckCallbackInventory(kTime2533500, params->param2, 5, WRAP_SETUP_FUNCTION(Abbot, setup_callbackActionRestaurantOrSalon)); break; case 5: diff --git a/engines/lastexpress/entities/alexei.cpp b/engines/lastexpress/entities/alexei.cpp index b31a9956bc..115c890f6f 100644 --- a/engines/lastexpress/entities/alexei.cpp +++ b/engines/lastexpress/entities/alexei.cpp @@ -446,7 +446,7 @@ IMPLEMENT_FUNCTION(17, Alexei, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler) + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Alexei, setup_chapter1Handler)); break; case kActionDefault: @@ -978,7 +978,7 @@ IMPLEMENT_FUNCTION(26, Alexei, function26) break; case kActionNone: - TIME_CHECK(kTime1512000, params->param1, setup_function27) + Entity::timeCheck(kTime1512000, params->param1, WRAP_SETUP_FUNCTION(Alexei, setup_function27)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/alouan.cpp b/engines/lastexpress/entities/alouan.cpp index 7549aaf6e6..2f086de46b 100644 --- a/engines/lastexpress/entities/alouan.cpp +++ b/engines/lastexpress/entities/alouan.cpp @@ -111,7 +111,7 @@ IMPLEMENT_FUNCTION(10, Alouan, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Alouan, setup_chapter1Handler)); break; case kActionDefault: @@ -131,7 +131,8 @@ IMPLEMENT_FUNCTION(11, Alouan, chapter1Handler) case kActionNone: - TIME_CHECK_CALLBACK(kTime1096200, params->param1, 1, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime1096200, params->param1, 1, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8to6))) + break; label_callback1: if (getState()->time > kTime1162800 && !params->param2) { @@ -281,21 +282,27 @@ IMPLEMENT_FUNCTION(16, Alouan, chapter3Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTimeCitySalzbourg, params->param1, 1, setup_compartment8to6); + if (Entity::timeCheckCallback(kTimeCitySalzbourg, params->param1, 1, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8to6))) + break; label_callback1: - if (params->param2 != kTimeInvalid && getState()->time > kTime1989000) - TIME_CHECK_CAR(kTime2119500, params->param5, 5, setup_compartment8); + if (params->param2 != kTimeInvalid && getState()->time > kTime1989000) { + if (Entity::timeCheckCar(kTime2119500, params->param5, 5, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8))) + break; + } label_callback2: TIME_CHECK_CALLBACK_1(kTime2052000, params->param3, 3, setup_playSound, "Har1005"); label_callback3: - TIME_CHECK_CALLBACK(kTime2133000, params->param4, 4, setup_compartment6to8); + if (Entity::timeCheckCallback(kTime2133000, params->param4, 4, WRAP_SETUP_FUNCTION(Alouan, setup_compartment6to8))) + break; label_callback4: - if (params->param5 != kTimeInvalid && getState()->time > kTime2151000) - TIME_CHECK_CAR(kTime2241000, params->param5, 5, setup_compartment8); + if (params->param5 != kTimeInvalid && getState()->time > kTime2151000) { + if (Entity::timeCheckCar(kTime2241000, params->param5, 5, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8))) + break; + } break; case kActionDefault: @@ -352,11 +359,14 @@ IMPLEMENT_FUNCTION(18, Alouan, chapter4Handler) break; case kActionNone: - if (params->param1 != kTimeInvalid) - TIME_CHECK_CAR(kTime2443500, params->param1, 1, setup_compartment8); + if (params->param1 != kTimeInvalid) { + if (Entity::timeCheckCar(kTime2443500, params->param1, 1, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8))) + break; + } label_callback1: - TIME_CHECK_CALLBACK(kTime2455200, params->param2, 2, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime2455200, params->param2, 2, WRAP_SETUP_FUNCTION(Alouan, setup_compartment8to6))) + break; label_callback2: if (getState()->time > kTime2475000 && !params->param3) { diff --git a/engines/lastexpress/entities/anna.cpp b/engines/lastexpress/entities/anna.cpp index 0f326792eb..f8768032b5 100644 --- a/engines/lastexpress/entities/anna.cpp +++ b/engines/lastexpress/entities/anna.cpp @@ -547,7 +547,7 @@ IMPLEMENT_FUNCTION(16, Anna, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Anna, setup_chapter1Handler)); break; case kActionDefault: @@ -1423,7 +1423,7 @@ IMPLEMENT_FUNCTION(34, Anna, function34) } label_callback_1: - TIME_CHECK(kTime1489500, params->param3, setup_function35); + Entity::timeCheck(kTime1489500, params->param3, WRAP_SETUP_FUNCTION(Anna, setup_function35)); break; case kActionKnock: @@ -2544,7 +2544,8 @@ IMPLEMENT_FUNCTION(54, Anna, function54) case kActionNone: if (params->param3) { - TIME_CHECK(kTime2079000, params->param5, setup_function55); + if (Entity::timeCheck(kTime2079000, params->param5, WRAP_SETUP_FUNCTION(Anna, setup_function55))) + break; if (Entity::updateParameter(params->param6, getState()->time, 9000)) { params->param4 = !params->param4; @@ -3429,7 +3430,7 @@ IMPLEMENT_FUNCTION(69, Anna, function69) break; } - TIME_CHECK_CALLBACK(kTime2535300, params->param3, 4, setup_callbackActionRestaurantOrSalon); + Entity::timeCheckCallback(kTime2535300, params->param3, 4, WRAP_SETUP_FUNCTION(Anna, setup_callbackActionRestaurantOrSalon)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index e863fe1d87..0412da69ac 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -752,7 +752,7 @@ IMPLEMENT_FUNCTION(22, August, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(August, setup_chapter1Handler)); break; case kActionDefault: @@ -1966,7 +1966,7 @@ IMPLEMENT_FUNCTION(38, August, function38) case kActionNone: Entity::timeCheckSavepoint(kTime1801800, params->param1, kEntityAugust, kEntityRebecca, kAction155980128); - TIME_CHECK_CALLBACK(kTime1820700, params->param2, 3, setup_callbackActionRestaurantOrSalon); + Entity::timeCheckCallback(kTime1820700, params->param2, 3, WRAP_SETUP_FUNCTION(August, setup_callbackActionRestaurantOrSalon)); break; case kActionDefault: @@ -2404,7 +2404,7 @@ IMPLEMENT_FUNCTION_END IMPLEMENT_FUNCTION(46, August, function46) switch (savepoint.action) { default: - TIME_CHECK_CALLBACK(kTime2088000, params->param1, 1, setup_function47); + Entity::timeCheckCallback(kTime2088000, params->param1, 1, WRAP_SETUP_FUNCTION(August, setup_function47)); break; case kActionNone: @@ -2489,7 +2489,7 @@ IMPLEMENT_FUNCTION(48, August, function48) break; case kActionNone: - TIME_CHECK(kTimeCityLinz, params->param1, setup_function49); + Entity::timeCheck(kTimeCityLinz, params->param1, WRAP_SETUP_FUNCTION(August, setup_function49)); break; case kActionKnock: diff --git a/engines/lastexpress/entities/boutarel.cpp b/engines/lastexpress/entities/boutarel.cpp index 2a8c6603a4..3c13cb121e 100644 --- a/engines/lastexpress/entities/boutarel.cpp +++ b/engines/lastexpress/entities/boutarel.cpp @@ -617,7 +617,7 @@ IMPLEMENT_FUNCTION(19, Boutarel, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Boutarel, setup_chapter1Handler)); break; case kActionDefault: @@ -1047,7 +1047,7 @@ IMPLEMENT_FUNCTION(32, Boutarel, chapter4Handler) break; case kActionNone: - TIME_CHECK(kTime2367000, params->param1, setup_function33); + Entity::timeCheck(kTime2367000, params->param1, WRAP_SETUP_FUNCTION(Boutarel, setup_function33)); break; case kActionDefault: @@ -1113,7 +1113,8 @@ IMPLEMENT_FUNCTION(34, Boutarel, function34) break; case kActionNone: - TIME_CHECK(kTime2470500, params->param1, setup_function35); + if (Entity::timeCheck(kTime2470500, params->param1, WRAP_SETUP_FUNCTION(Boutarel, setup_function35))) + break; if (getState()->time > kTime2457000 && getEvent(kEventAugustDrink)) { getSavePoints()->push(kEntityBoutarel, kEntityAbbot, kAction159003408); diff --git a/engines/lastexpress/entities/cooks.cpp b/engines/lastexpress/entities/cooks.cpp index 62a1e0fdb6..5e8a2df8cb 100644 --- a/engines/lastexpress/entities/cooks.cpp +++ b/engines/lastexpress/entities/cooks.cpp @@ -239,7 +239,7 @@ IMPLEMENT_FUNCTION(5, Cooks, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Cooks, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/coudert.cpp b/engines/lastexpress/entities/coudert.cpp index 4458632f2d..b604277903 100644 --- a/engines/lastexpress/entities/coudert.cpp +++ b/engines/lastexpress/entities/coudert.cpp @@ -1963,7 +1963,7 @@ IMPLEMENT_FUNCTION(36, Coudert, chapter1) break; case kActionNone: - TIME_CHECK_CALLBACK(kTimeChapter1, params->param1, 1, setup_chapter1Handler) + Entity::timeCheckCallback(kTimeChapter1, params->param1, 1, WRAP_SETUP_FUNCTION(Coudert, setup_chapter1Handler)); break; case kActionDefault: @@ -2825,22 +2825,28 @@ label_callback_12: } label_callback_13: - TIME_CHECK_CALLBACK(kTime2088900, params->param1, 14, setup_function32); + if (Entity::timeCheckCallback(kTime2088900, params->param1, 14, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_14: - TIME_CHECK_CALLBACK(kTime2119500, params->param2, 15, setup_function32); + if (Entity::timeCheckCallback(kTime2119500, params->param2, 15, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_15: - TIME_CHECK_CALLBACK(kTime2138400, params->param3, 16, setup_function32); + if (Entity::timeCheckCallback(kTime2138400, params->param3, 16, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_16: - TIME_CHECK_CALLBACK(kTime2147400, params->param4, 17, setup_function32); + if (Entity::timeCheckCallback(kTime2147400, params->param4, 17, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_17: - TIME_CHECK_CALLBACK(kTime2160000, params->param5, 18, setup_function32); + if (Entity::timeCheckCallback(kTime2160000, params->param5, 18, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_18: - TIME_CHECK_CALLBACK(kTime2205000, params->param6, 19, setup_function32); + if (Entity::timeCheckCallback(kTime2205000, params->param6, 19, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_19: if (ENTITY_PARAM(0, 2)) { @@ -3556,13 +3562,16 @@ label_callback_2: label_callback_3: if (!params->param1) { - TIME_CHECK_CALLBACK(kTime2394000, params->param4, 4, setup_function56); + if (Entity::timeCheckCallback(kTime2394000, params->param4, 4, WRAP_SETUP_FUNCTION(Coudert, setup_function56))) + break; label_callback_4: - TIME_CHECK_CALLBACK(kTime2434500, params->param5, 5, setup_function32); + if (Entity::timeCheckCallback(kTime2434500, params->param5, 5, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; label_callback_5: - TIME_CHECK_CALLBACK(kTime2448000, params->param6, 6, setup_function32); + if (Entity::timeCheckCallback(kTime2448000, params->param6, 6, WRAP_SETUP_FUNCTION(Coudert, setup_function32))) + break; } label_callback_6: diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 04ae6493c3..48856a7bc4 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -637,6 +637,57 @@ bool Entity::updateParameterCheck(uint ¶meter, uint timeType, uint delta) { return true; } +bool Entity::timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + (*function)(); + + return true; + } + + return false; +} + +bool Entity::timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + (*function)(); + + return true; + } + + return false; +} + +bool Entity::timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + getData()->inventoryItem = kItemNone; + setCallback(callback); + (*function)(); + + return true; + } + + return false; +} + +bool Entity::timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function) { + if ((getState()->time <= timeValue && !getEntities()->isPlayerInCar(kCarGreenSleeping)) || !parameter) + parameter = (uint)getState()->time + 75; + + if (getState()->time > timeValue || parameter < getState()->time) { + parameter = kTimeInvalid; + setCallback(callback); + (*function)(); + + return true; + } + + return false; +} + void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) { if (getState()->time > timeValue && !parameter) { parameter = 1; diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 76abab6c2f..6e55e21b74 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -82,6 +82,9 @@ struct SavePoint; #define ADD_NULL_FUNCTION() \ _callbacks.push_back(new ENTITY_CALLBACK(Entity, nullfunction, this)); +#define WRAP_SETUP_FUNCTION(className, method) \ + new Common::Functor0Mem(this, &className::method) + ////////////////////////////////////////////////////////////////////////// // Parameters macros ////////////////////////////////////////////////////////////////////////// @@ -903,10 +906,15 @@ protected: bool updateParameterCheck(uint ¶meter, uint timeType, uint delta); bool updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta); + bool timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function); + bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); + bool timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); + bool timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter); bool timeCheckPlaySoundUpdatePosition(TimeValue timeValue, uint ¶meter, byte callback, const char* sound, EntityPosition position); + }; diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index e62eeb0c56..1d6c462a88 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -269,21 +269,6 @@ void class::setup_##name() { \ ////////////////////////////////////////////////////////////////////////// // Time check macros ////////////////////////////////////////////////////////////////////////// -#define TIME_CHECK(timeValue, parameter, function) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - function(); \ - break; \ - } - -#define TIME_CHECK_CALLBACK(timeValue, parameter, callback, function) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - setCallback(callback); \ - function(); \ - break; \ - } - #define TIME_CHECK_CALLBACK_1(timeValue, parameter, callback, function, param1) \ if (getState()->time > timeValue && !parameter) { \ parameter = 1; \ @@ -308,26 +293,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_CALLBACK_INVENTORY(timeValue, parameter, callback, function) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - getData()->inventoryItem = kItemNone; \ - setCallback(callback); \ - function(); \ - break; \ - } - -#define TIME_CHECK_CAR(timeValue, parameter, callback, function) {\ - if ((getState()->time <= timeValue && !getEntities()->isPlayerInCar(kCarGreenSleeping)) || !parameter) \ - parameter = (uint)getState()->time + 75; \ - if (getState()->time > timeValue || parameter < getState()->time) { \ - parameter = kTimeInvalid; \ - setCallback(callback); \ - function(); \ - break; \ - } \ -} - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/francois.cpp b/engines/lastexpress/entities/francois.cpp index e4d401d202..89fdcaf668 100644 --- a/engines/lastexpress/entities/francois.cpp +++ b/engines/lastexpress/entities/francois.cpp @@ -848,7 +848,7 @@ IMPLEMENT_FUNCTION(17, Francois, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Francois, setup_chapter1Handler)); break; case kActionDefault: @@ -883,7 +883,7 @@ IMPLEMENT_FUNCTION(19, Francois, function19) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime1161000, params->param1, 2, setup_function12); + Entity::timeCheckCallback(kTime1161000, params->param1, 2, WRAP_SETUP_FUNCTION(Francois, setup_function12)); break; case kAction101107728: @@ -981,7 +981,8 @@ label_callback_1: TIME_CHECK_CALLBACK_1(kTime1764000, params->param1, 2, setup_playSound, "Fra2011"); label_callback_2: - TIME_CHECK_CALLBACK(kTime1800000, params->param2, 3, setup_function13); + if (Entity::timeCheckCallback(kTime1800000, params->param2, 3, WRAP_SETUP_FUNCTION(Francois, setup_function13))) + break; label_callback_3: if (!getInventory()->hasItem(kItemWhistle) && getInventory()->get(kItemWhistle)->location != kObjectLocation3) { @@ -1085,25 +1086,32 @@ IMPLEMENT_FUNCTION(25, Francois, chapter3Handler) } label_callback_2: - TIME_CHECK_CALLBACK(kTime2025000, params->param3, 3, setup_function12); + if (Entity::timeCheckCallback(kTime2025000, params->param3, 3, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_3: - TIME_CHECK_CALLBACK(kTime2052000, params->param4, 4, setup_function12); + if (Entity::timeCheckCallback(kTime2052000, params->param4, 4, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_4: - TIME_CHECK_CALLBACK(kTime2079000, params->param5, 5, setup_function12); + if (Entity::timeCheckCallback(kTime2079000, params->param5, 5, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_5: - TIME_CHECK_CALLBACK(kTime2092500, params->param6, 6, setup_function12); + if (Entity::timeCheckCallback(kTime2092500, params->param6, 6, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_6: - TIME_CHECK_CALLBACK(kTime2173500, params->param7, 7, setup_function12); + if (Entity::timeCheckCallback(kTime2173500, params->param7, 7, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_7: - TIME_CHECK_CALLBACK(kTime2182500, params->param8, 8, setup_function12); + if (Entity::timeCheckCallback(kTime2182500, params->param8, 8, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_8: - TIME_CHECK_CALLBACK(kTime2241000, CURRENT_PARAM(1, 1), 9, setup_function12); + if (Entity::timeCheckCallback(kTime2241000, CURRENT_PARAM(1, 1), 9, WRAP_SETUP_FUNCTION(Francois, setup_function12))) + break; label_callback_9: if (!getInventory()->hasItem(kItemWhistle) && getInventory()->get(kItemWhistle)->location != kObjectLocation3) { diff --git a/engines/lastexpress/entities/gendarmes.cpp b/engines/lastexpress/entities/gendarmes.cpp index 22697b396c..a912fa4ecb 100644 --- a/engines/lastexpress/entities/gendarmes.cpp +++ b/engines/lastexpress/entities/gendarmes.cpp @@ -66,7 +66,7 @@ IMPLEMENT_FUNCTION(2, Gendarmes, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Gendarmes, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/hadija.cpp b/engines/lastexpress/entities/hadija.cpp index 62badc46a6..e9abcd888a 100644 --- a/engines/lastexpress/entities/hadija.cpp +++ b/engines/lastexpress/entities/hadija.cpp @@ -111,7 +111,7 @@ IMPLEMENT_FUNCTION(10, Hadija, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Hadija, setup_chapter1Handler)); break; case kActionDefault: @@ -134,7 +134,8 @@ IMPLEMENT_FUNCTION(11, Hadija, chapter1Handler) break; label_callback1: - TIME_CHECK_CALLBACK(kTime1084500, params->param2, 2, setup_compartment6to8); + if (Entity::timeCheckCallback(kTime1084500, params->param2, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6to8))) + break; label_callback2: if (params->param3 != kTimeInvalid && getState()->time > kTime1093500) { @@ -162,7 +163,8 @@ label_callback2: } label_callback3: - TIME_CHECK_CALLBACK(kTime1156500, params->param4, 4, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime1156500, params->param4, 4, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6))) + break; label_callback4: if (params->param5 != kTimeInvalid && getState()->time > kTime1165500) { @@ -252,7 +254,7 @@ IMPLEMENT_FUNCTION(14, Hadija, chapter2Handler) } if (params->param2 == kTimeInvalid || getState()->time <= kTime1786500) { - TIME_CHECK_CALLBACK(kTime1822500, params->param3, 2, setup_compartment8to6); + Entity::timeCheckCallback(kTime1822500, params->param3, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6)); break; } @@ -262,7 +264,7 @@ IMPLEMENT_FUNCTION(14, Hadija, chapter2Handler) params->param2 = (uint)getState()->time + 75; if (params->param2 >= getState()->time) { - TIME_CHECK_CALLBACK(kTime1822500, params->param3, 2, setup_compartment8to6); + Entity::timeCheckCallback(kTime1822500, params->param3, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6)); break; } } @@ -279,7 +281,7 @@ IMPLEMENT_FUNCTION(14, Hadija, chapter2Handler) break; case 1: - TIME_CHECK_CALLBACK(kTime1822500, params->param3, 2, setup_compartment8to6); + Entity::timeCheckCallback(kTime1822500, params->param3, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6)); break; case 2: @@ -319,20 +321,26 @@ IMPLEMENT_FUNCTION(16, Hadija, chapter3Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime1998000, params->param1, 1, setup_compartment6to8); + if (Entity::timeCheckCallback(kTime1998000, params->param1, 1, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6to8))) + break; label_callback1: - TIME_CHECK_CALLBACK(kTime2020500, params->param2, 2, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime2020500, params->param2, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6))) + break; label_callback2: - TIME_CHECK_CALLBACK(kTime2079000, params->param3, 3, setup_compartment6to8); + if (Entity::timeCheckCallback(kTime2079000, params->param3, 3, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6to8))) + break; label_callback3: - TIME_CHECK_CALLBACK(kTime2187000, params->param4, 4, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime2187000, params->param4, 4, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6))) + break; label_callback4: - if (params->param5 != kTimeInvalid && getState()->time > kTime2196000) - TIME_CHECK_CAR(kTime2254500, params->param5, 5, setup_compartment6); + if (params->param5 != kTimeInvalid && getState()->time > kTime2196000) { + if (Entity::timeCheckCar(kTime2254500, params->param5, 5, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6))) + break; + } break; case kActionDefault: @@ -385,18 +393,24 @@ IMPLEMENT_FUNCTION(18, Hadija, chapter4Handler) break; case kActionNone: - if (params->param1 != kTimeInvalid) - TIME_CHECK_CAR(kTime1714500, params->param1, 1, setup_compartment6); + if (params->param1 != kTimeInvalid) { + if (Entity::timeCheckCar(kTime1714500, params->param1, 1, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6))) + break; + } label_callback1: - TIME_CHECK_CALLBACK(kTime2367000, params->param2, 2, setup_compartment6to8); + if (Entity::timeCheckCallback(kTime2367000, params->param2, 2, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6to8))) + break; label_callback2: - TIME_CHECK_CALLBACK(kTime2421000, params->param3, 3, setup_compartment8to6); + if (Entity::timeCheckCallback(kTime2421000, params->param3, 3, WRAP_SETUP_FUNCTION(Hadija, setup_compartment8to6))) + break; label_callback3: - if (params->param4 != kTimeInvalid && getState()->time > kTime2425500) - TIME_CHECK_CAR(kTime2484000, params->param4, 4, setup_compartment6); + if (params->param4 != kTimeInvalid && getState()->time > kTime2425500) { + if (Entity::timeCheckCar(kTime2484000, params->param4, 4, WRAP_SETUP_FUNCTION(Hadija, setup_compartment6))) + break; + } break; case kActionCallback: diff --git a/engines/lastexpress/entities/ivo.cpp b/engines/lastexpress/entities/ivo.cpp index cb0fb92b74..c53f4689fb 100644 --- a/engines/lastexpress/entities/ivo.cpp +++ b/engines/lastexpress/entities/ivo.cpp @@ -246,7 +246,7 @@ IMPLEMENT_FUNCTION(14, Ivo, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Ivo, setup_chapter1Handler)); break; case kActionDefault: @@ -371,7 +371,7 @@ IMPLEMENT_FUNCTION(18, Ivo, chapter2) break; case kActionNone: - TIME_CHECK(kTime1777500, params->param1, setup_function19); + Entity::timeCheck(kTime1777500, params->param1, WRAP_SETUP_FUNCTION(Ivo, setup_function19)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/kahina.cpp b/engines/lastexpress/entities/kahina.cpp index 08f845f5ba..7860836a26 100644 --- a/engines/lastexpress/entities/kahina.cpp +++ b/engines/lastexpress/entities/kahina.cpp @@ -247,7 +247,7 @@ IMPLEMENT_FUNCTION(10, Kahina, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Kahina, setup_chapter1Handler)); break; case kActionDefault: @@ -280,7 +280,7 @@ IMPLEMENT_FUNCTION(12, Kahina, function12) break; case kActionNone: - TIME_CHECK(kTime1485000, params->param2, setup_function13); + Entity::timeCheck(kTime1485000, params->param2, WRAP_SETUP_FUNCTION(Kahina, setup_function13)); break; case kActionKnock: diff --git a/engines/lastexpress/entities/kronos.cpp b/engines/lastexpress/entities/kronos.cpp index 5dd790ce12..26ce3ca424 100644 --- a/engines/lastexpress/entities/kronos.cpp +++ b/engines/lastexpress/entities/kronos.cpp @@ -126,7 +126,7 @@ IMPLEMENT_FUNCTION(7, Kronos, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Kronos, setup_chapter1Handler)); break; case kActionDefault: @@ -147,7 +147,7 @@ IMPLEMENT_FUNCTION(8, Kronos, chapter1Handler) break; case kActionNone: - TIME_CHECK(kTime1489500, params->param2, setup_function11); + Entity::timeCheck(kTime1489500, params->param2, WRAP_SETUP_FUNCTION(Kronos, setup_function11)); break; case kAction171849314: @@ -189,7 +189,7 @@ IMPLEMENT_FUNCTION(10, Kronos, function10) break; case kActionNone: - TIME_CHECK(kTime1489500, params->param1, setup_function11); + Entity::timeCheck(kTime1489500, params->param1, WRAP_SETUP_FUNCTION(Kronos, setup_function11)); break; case kActionDefault: @@ -405,8 +405,7 @@ IMPLEMENT_FUNCTION(18, Kronos, function18) params->param2 = 1; } - TIME_CHECK(kTime2106000, params->param3, setup_function19) - else { + if (!Entity::timeCheck(kTime2106000, params->param3, WRAP_SETUP_FUNCTION(Kronos, setup_function19))) { if (params->param1 && getEntities()->isInKronosSanctum(kEntityPlayer)) { setCallback(1); setup_savegame(kSavegameTypeEvent, kEventKahinaPunchSuite4); diff --git a/engines/lastexpress/entities/mahmud.cpp b/engines/lastexpress/entities/mahmud.cpp index 1e7df5c870..af86ef8cdd 100644 --- a/engines/lastexpress/entities/mahmud.cpp +++ b/engines/lastexpress/entities/mahmud.cpp @@ -560,7 +560,8 @@ IMPLEMENT_FUNCTION(14, Mahmud, chaptersHandler) if (!params->param2 && getProgress().chapter == kChapter1) { - TIME_CHECK_CALLBACK(kTime1098000, params->param6, 1, setup_function13); + if (Entity::timeCheckCallback(kTime1098000, params->param6, 1, WRAP_SETUP_FUNCTION(Mahmud, setup_function13))) + break; if (!getSoundQueue()->isBuffered("HAR1104") && getState()->time > kTime1167300 && !params->param7) { params->param7 = 1; @@ -733,7 +734,7 @@ IMPLEMENT_FUNCTION(15, Mahmud, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chaptersHandler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Mahmud, setup_chaptersHandler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/max.cpp b/engines/lastexpress/entities/max.cpp index 5c43346cde..abd2aae9e4 100644 --- a/engines/lastexpress/entities/max.cpp +++ b/engines/lastexpress/entities/max.cpp @@ -324,7 +324,7 @@ IMPLEMENT_FUNCTION(10, Max, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter12_handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Max, setup_chapter12_handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index 9d9225f49b..b6ea86cd0e 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -2498,7 +2498,7 @@ IMPLEMENT_FUNCTION(34, Mertens, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Mertens, setup_chapter1Handler)); break; case kActionDefault: @@ -3535,16 +3535,18 @@ label_callback_6: TIME_CHECK_CALLBACK_1(kTime1971000, params->param1, 7, setup_function28, "CON3012"); label_callback_7: - TIME_CHECK_CALLBACK(kTime2117700, params->param2, 8, setup_function32); + if (Entity::timeCheckCallback(kTime2117700, params->param2, 8, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) + break; label_callback_8: TIME_CHECK_CALLBACK_1(kTime2124000, params->param3, 9, setup_function28, "CON2010"); label_callback_9: - TIME_CHECK_CALLBACK(kTime2146500, params->param4, 10, setup_function32); + if (Entity::timeCheckCallback(kTime2146500, params->param4, 10, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) + break; label_callback_10: - TIME_CHECK_CALLBACK(kTime2169000, params->param5, 11, setup_function32); + Entity::timeCheckCallback(kTime2169000, params->param5, 11, WRAP_SETUP_FUNCTION(Mertens, setup_function32)); break; case kAction11: @@ -3727,16 +3729,20 @@ label_callback_3: label_callback_4: if (!params->param1) { - TIME_CHECK_CALLBACK(kTime2403000, params->param2, 5, setup_function49); + if (Entity::timeCheckCallback(kTime2403000, params->param2, 5, WRAP_SETUP_FUNCTION(Mertens, setup_function49))) + break; label_callback_5: - TIME_CHECK_CALLBACK(kTime2430000, params->param3, 6, setup_function32); + if (Entity::timeCheckCallback(kTime2430000, params->param3, 6, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) + break; label_callback_6: - TIME_CHECK_CALLBACK(kTime2439000, params->param4, 7, setup_function32); + if (Entity::timeCheckCallback(kTime2439000, params->param4, 7, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) + break; label_callback_7: - TIME_CHECK_CALLBACK(kTime2448000, params->param5, 8, setup_function32); + if (Entity::timeCheckCallback(kTime2448000, params->param5, 8, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) + break; } label_callback_8: diff --git a/engines/lastexpress/entities/milos.cpp b/engines/lastexpress/entities/milos.cpp index 5c5d481938..519a613497 100644 --- a/engines/lastexpress/entities/milos.cpp +++ b/engines/lastexpress/entities/milos.cpp @@ -362,7 +362,7 @@ IMPLEMENT_FUNCTION(12, Milos, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Milos, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/mmeboutarel.cpp b/engines/lastexpress/entities/mmeboutarel.cpp index 888adeb372..950644cb8f 100644 --- a/engines/lastexpress/entities/mmeboutarel.cpp +++ b/engines/lastexpress/entities/mmeboutarel.cpp @@ -244,7 +244,7 @@ IMPLEMENT_FUNCTION(10, MmeBoutarel, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(MmeBoutarel, setup_chapter1Handler)); break; case kActionDefault: @@ -424,7 +424,8 @@ label_callback_1: } } - TIME_CHECK(kTime1094400, params->param8, setup_function14); + if (Entity::timeCheck(kTime1094400, params->param8, WRAP_SETUP_FUNCTION(MmeBoutarel, setup_function14))) + break; if (params->param4) { if (!Entity::updateParameter(CURRENT_PARAM(1, 1), getState()->timeTicks, 75)) @@ -1065,7 +1066,8 @@ IMPLEMENT_FUNCTION(24, MmeBoutarel, function24) break; case kActionNone: - TIME_CHECK(kTime2470500, params->param4, setup_function25); + if (Entity::timeCheck(kTime2470500, params->param4, WRAP_SETUP_FUNCTION(MmeBoutarel, setup_function25))) + break; if (params->param2) { if (!Entity::updateParameter(params->param5, getState()->timeTicks, 75)) diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index c0c22fa1da..5ad8a1b985 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -655,7 +655,7 @@ IMPLEMENT_FUNCTION(21, Rebecca, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Rebecca, setup_chapter1Handler)); break; case kActionDefault: @@ -848,7 +848,8 @@ IMPLEMENT_FUNCTION(24, Rebecca, function24) if (!params->param1) break; - TIME_CHECK_CALLBACK(kTime1165500, params->param3, 6, setup_function19); + if (Entity::timeCheckCallback(kTime1165500, params->param3, 6, WRAP_SETUP_FUNCTION(Rebecca, setup_function19))) + break; if (params->param4 != kTimeInvalid) { if (getState()->time <= kTime1161000) { @@ -1224,7 +1225,7 @@ IMPLEMENT_FUNCTION(34, Rebecca, function34) params->param2 = (uint)getState()->time; if (params->param2 >= getState()->time) { - TIME_CHECK_CALLBACK(kTime2052000, params->param3, 1, setup_function19); + Entity::timeCheckCallback(kTime2052000, params->param3, 1, WRAP_SETUP_FUNCTION(Rebecca, setup_function19)); break; } } @@ -1234,7 +1235,7 @@ IMPLEMENT_FUNCTION(34, Rebecca, function34) getSavePoints()->push(kEntityRebecca, kEntityServers0, kAction223712416); } - TIME_CHECK_CALLBACK(kTime2052000, params->param3, 1, setup_function19); + Entity::timeCheckCallback(kTime2052000, params->param3, 1, WRAP_SETUP_FUNCTION(Rebecca, setup_function19)); break; case kActionEndSound: @@ -1633,7 +1634,7 @@ label_next: label_callback_2: if (params->param2) - TIME_CHECK_CALLBACK(kTime2443500, params->param5, 3, setup_function19); + Entity::timeCheckCallback(kTime2443500, params->param5, 3, WRAP_SETUP_FUNCTION(Rebecca, setup_function19)); break; case kActionEndSound: diff --git a/engines/lastexpress/entities/salko.cpp b/engines/lastexpress/entities/salko.cpp index b799564b46..e8b4b4247b 100644 --- a/engines/lastexpress/entities/salko.cpp +++ b/engines/lastexpress/entities/salko.cpp @@ -156,7 +156,7 @@ IMPLEMENT_FUNCTION(9, Salko, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Salko, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/sophie.cpp b/engines/lastexpress/entities/sophie.cpp index 10c414763c..170090005f 100644 --- a/engines/lastexpress/entities/sophie.cpp +++ b/engines/lastexpress/entities/sophie.cpp @@ -179,7 +179,7 @@ IMPLEMENT_FUNCTION(4, Sophie, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chaptersHandler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Sophie, setup_chaptersHandler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/tatiana.cpp b/engines/lastexpress/entities/tatiana.cpp index b7c26bdd1c..432def6253 100644 --- a/engines/lastexpress/entities/tatiana.cpp +++ b/engines/lastexpress/entities/tatiana.cpp @@ -341,7 +341,7 @@ IMPLEMENT_FUNCTION(17, Tatiana, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Tatiana, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/vassili.cpp b/engines/lastexpress/entities/vassili.cpp index 5344e705f5..4695f8831f 100644 --- a/engines/lastexpress/entities/vassili.cpp +++ b/engines/lastexpress/entities/vassili.cpp @@ -83,7 +83,7 @@ IMPLEMENT_FUNCTION(4, Vassili, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Vassili, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index f459b6f8e7..dfeae21338 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -572,7 +572,7 @@ IMPLEMENT_FUNCTION(18, Verges, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Verges, setup_chapter1Handler)); break; case kActionDefault: @@ -910,7 +910,8 @@ label_callback3: TIME_CHECK_CALLBACK_1(kTimeChapter1, params->param7, 4, setup_function9, "TRA1001"); label_callback4: - TIME_CHECK_CALLBACK(kTime1089000, params->param8, 5, setup_function12); + if (Entity::timeCheckCallback(kTime1089000, params->param8, 5, WRAP_SETUP_FUNCTION(Verges, setup_function12))) + break; params->param8 = 1; @@ -1445,7 +1446,8 @@ label_callback_4: TIME_CHECK_CALLBACK_1(kTime1998000, params->param2, 5, setup_function9, "Tra3010a"); label_callback_5: - TIME_CHECK_CALLBACK(kTime2016000, params->param3, 6, setup_function35); + if (Entity::timeCheckCallback(kTime2016000, params->param3, 6, WRAP_SETUP_FUNCTION(Verges, setup_function35))) + break; label_callback_6: TIME_CHECK_CALLBACK_1(kTime2070000, params->param4, 7, setup_function9, "Tra3002"); @@ -1457,7 +1459,7 @@ label_callback_8: TIME_CHECK_CALLBACK_1(kTime2173500, params->param6, 9, setup_function30, "Tra3012"); label_callback_9: - TIME_CHECK_CALLBACK(kTime2218500, params->param7, 10, setup_function32); + Entity::timeCheckCallback(kTime2218500, params->param7, 10, WRAP_SETUP_FUNCTION(Verges, setup_function32)); break; case kActionOpenDoor: diff --git a/engines/lastexpress/entities/vesna.cpp b/engines/lastexpress/entities/vesna.cpp index f54f0f3231..f29bce8b2b 100644 --- a/engines/lastexpress/entities/vesna.cpp +++ b/engines/lastexpress/entities/vesna.cpp @@ -255,7 +255,7 @@ IMPLEMENT_FUNCTION(12, Vesna, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Vesna, setup_chapter1Handler)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/yasmin.cpp b/engines/lastexpress/entities/yasmin.cpp index f2b4d2edd1..acacbb547b 100644 --- a/engines/lastexpress/entities/yasmin.cpp +++ b/engines/lastexpress/entities/yasmin.cpp @@ -184,7 +184,7 @@ IMPLEMENT_FUNCTION(8, Yasmin, chapter1) break; case kActionNone: - TIME_CHECK(kTimeChapter1, params->param1, setup_chapter1Handler); + Entity::timeCheck(kTimeChapter1, params->param1, WRAP_SETUP_FUNCTION(Yasmin, setup_chapter1Handler)); break; case kActionDefault: @@ -202,13 +202,20 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime1093500, params->param1, 1, setup_function6); - TIME_CHECK_CALLBACK(kTime1161000, params->param2, 3, setup_function7); + if (Entity::timeCheckCallback(kTime1093500, params->param1, 1, WRAP_SETUP_FUNCTION(Yasmin, setup_function6))) + break; + + if (Entity::timeCheckCallback(kTime1161000, params->param2, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; + if (Entity::timeCheckPlaySoundUpdatePosition(kTime1162800, params->param3, 4, "Har1102", kPosition_4070)) break; + TIME_CHECK_CALLBACK_1(kTime1165500, params->param4, 5, setup_playSound, "Har1104"); + TIME_CHECK_CALLBACK_1(kTime1174500, params->param5, 6, setup_playSound, "Har1106"); - TIME_CHECK_CALLBACK(kTime1183500, params->param6, 7, setup_function6); + + Entity::timeCheckCallback(kTime1183500, params->param6, 7, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; case kActionCallback: @@ -223,7 +230,8 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) break; case 2: - TIME_CHECK_CALLBACK(kTime1161000, params->param2, 3, setup_function7); + if (Entity::timeCheckCallback(kTime1161000, params->param2, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; // Fallback to case 3 case 3: @@ -240,7 +248,7 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) // Fallback to case 6 case 6: - TIME_CHECK_CALLBACK(kTime1183500, params->param6, 7, setup_function6); + Entity::timeCheckCallback(kTime1183500, params->param6, 7, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; } break; @@ -281,7 +289,8 @@ IMPLEMENT_FUNCTION(12, Yasmin, chapter2Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime1759500, params->param1, 1, setup_function7); + if (Entity::timeCheckCallback(kTime1759500, params->param1, 1, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; if (getState()->time > kTime1800000 && !params->param2) { params->param2 = 1; @@ -334,9 +343,13 @@ IMPLEMENT_FUNCTION(14, Yasmin, chapter3Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime2062800, params->param1, 1, setup_function6); - TIME_CHECK_CALLBACK(kTime2106000, params->param2, 2, setup_function7); - TIME_CHECK_CALLBACK(kTime2160000, params->param3, 3, setup_function6); + if (Entity::timeCheckCallback(kTime2062800, params->param1, 1, WRAP_SETUP_FUNCTION(Yasmin, setup_function6))) + break; + + if (Entity::timeCheckCallback(kTime2106000, params->param2, 2, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; + + Entity::timeCheckCallback(kTime2160000, params->param3, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; case kActionCallback: @@ -345,11 +358,12 @@ IMPLEMENT_FUNCTION(14, Yasmin, chapter3Handler) break; case 1: - TIME_CHECK_CALLBACK(kTime2106000, params->param2, 2, setup_function7); + if (Entity::timeCheckCallback(kTime2106000, params->param2, 2, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; // Fallback to case 2 case 2: - TIME_CHECK_CALLBACK(kTime2160000, params->param3, 3, setup_function6); + Entity::timeCheckCallback(kTime2160000, params->param3, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; } break; @@ -381,8 +395,10 @@ IMPLEMENT_FUNCTION(16, Yasmin, chapter4Handler) break; case kActionNone: - TIME_CHECK_CALLBACK(kTime2457000, params->param1, 1, setup_function7); - TIME_CHECK_CALLBACK(kTime2479500, params->param2, 3, setup_function6); + if (Entity::timeCheckCallback(kTime2457000, params->param1, 1, WRAP_SETUP_FUNCTION(Yasmin, setup_function7))) + break; + + Entity::timeCheckCallback(kTime2479500, params->param2, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; case kActionCallback: @@ -397,7 +413,7 @@ IMPLEMENT_FUNCTION(16, Yasmin, chapter4Handler) break; case 2: - TIME_CHECK_CALLBACK(kTime2479500, params->param2, 3, setup_function6); + Entity::timeCheckCallback(kTime2479500, params->param2, 3, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; } break; -- cgit v1.2.3 From 7450ae23fb3c7afcaa33a35390e4c2c03238a024 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 24 Jul 2012 22:24:59 -0400 Subject: LASTEXPRESS: Move RESET_ENTITY_STATE macro to entity.h --- engines/lastexpress/entities/entity.h | 8 ++++++++ engines/lastexpress/entities/entity_intern.h | 7 ------- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 6e55e21b74..785e355481 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -94,6 +94,14 @@ struct SavePoint; #define ENTITY_PARAM(index, id) \ ((EntityData::EntityParametersIIII*)_data->getParameters(8, index))->param##id +////////////////////////////////////////////////////////////////////////// +// Misc +////////////////////////////////////////////////////////////////////////// +#define RESET_ENTITY_STATE(entity, class, function) \ + getEntities()->resetState(entity); \ + ((class *)getEntities()->get(entity))->function(); + + ////////////////////////////////////////////////////////////////////////// class EntityData : Common::Serializable { diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 1d6c462a88..306dbf8376 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -259,13 +259,6 @@ void class::setup_##name() { \ debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); -////////////////////////////////////////////////////////////////////////// -// Misc -////////////////////////////////////////////////////////////////////////// -#define RESET_ENTITY_STATE(entity, class, function) \ - getEntities()->resetState(entity); \ - ((class *)getEntities()->get(entity))->function(); - ////////////////////////////////////////////////////////////////////////// // Time check macros ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 37770212c0be36de982e16448fb62aa370a70f6a Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 24 Jul 2012 22:39:52 -0400 Subject: LASTEXPRESS: Remove TIME_CHECK_CALLBACK_2 macro --- engines/lastexpress/entities/chapters.cpp | 72 +++++++++++++++++++++------- engines/lastexpress/entities/chapters.h | 1 + engines/lastexpress/entities/entity_intern.h | 8 ---- engines/lastexpress/entities/rebecca.cpp | 8 +++- 4 files changed, 63 insertions(+), 26 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index c5631173b4..ac9387bd78 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -403,11 +403,18 @@ IMPLEMENT_FUNCTION(8, Chapters, chapter1Handler) label_processStations: // Process stations - TIME_CHECK_CALLBACK_2(kTime1039500, params->param7, 1, setup_savegame, kSavegameTypeTime, kTimeNone); + if (getState()->time > kTime1039500 && !params->param7) { + params->param7 = 1; + setCallback(1); + setup_savegame(kSavegameTypeTime, kTimeNone); + + break; + } label_enter_epernay: // Entering Epernay station - TIME_CHECK_CALLBACK_2(kTimeEnterEpernay, params->param8, 1, setup_enterStation, "Epernay", kCityEpernay); + if (timeCheckEnterStation(kTimeEnterEpernay, params->param8, 1, "Epernay", kCityEpernay)) + break; label_exit_epernay: // Exiting Epernay station @@ -437,7 +444,8 @@ label_enter_chalons: goto label_exit_strasbourg; // Entering Chalons station - TIME_CHECK_CALLBACK_2(kTimeEnterChalons, CURRENT_PARAM(1, 3), 5, setup_enterStation, "Chalons", kCityChalons); + if (timeCheckEnterStation(kTimeEnterChalons, CURRENT_PARAM(1, 3), 5, "Chalons", kCityChalons)) + break; label_exit_chalons: // Exiting Chalons station @@ -445,7 +453,8 @@ label_exit_chalons: label_enter_barleduc: // Entering Bar-Le-Duc station - TIME_CHECK_CALLBACK_2(kTimeCityBarLeDuc, CURRENT_PARAM(1, 5), 7, setup_enterStation, "BarLeDuc", kCityBarleduc); + if (timeCheckEnterStation(kTimeCityBarLeDuc, CURRENT_PARAM(1, 5), 7, "BarLeDuc", kCityBarleduc)) + break; label_exit_barleduc: // Exiting Bar-Le-Duc station @@ -458,7 +467,8 @@ label_enter_nancy: } // Entering Nancy station - TIME_CHECK_CALLBACK_2(kTimeCityNancy, CURRENT_PARAM(1, 8), 9, setup_enterStation, "Nancy", kCityNancy); + if (timeCheckEnterStation(kTimeCityNancy, CURRENT_PARAM(1, 8), 9, "Nancy", kCityNancy)) + break; label_exit_nancy: // Exiting Nancy station @@ -466,7 +476,8 @@ label_exit_nancy: label_enter_luneville: // Entering Luneville station - TIME_CHECK_CALLBACK_2(kTimeCityLuneville, CURRENT_PARAM(2, 2), 11, setup_enterStation, "Luneville", kCityLuneville); + if (timeCheckEnterStation(kTimeCityLuneville, CURRENT_PARAM(2, 2), 11, "Luneville", kCityLuneville)) + break; label_exit_luneville: // Exiting Luneville station @@ -474,7 +485,8 @@ label_exit_luneville: label_enter_avricourt: // Entering Avricourt station - TIME_CHECK_CALLBACK_2(kTimeCityAvricourt, CURRENT_PARAM(2, 4), 13, setup_enterStation, "Avricourt", kCityAvricourt); + if (timeCheckEnterStation(kTimeCityAvricourt, CURRENT_PARAM(2, 4), 13, "Avricourt", kCityAvricourt)) + break; label_exit_avricourt: // Exiting Avricourt station @@ -482,14 +494,21 @@ label_exit_avricourt: label_enter_deutschavricourt: // Entering Deutsch-Avricourt station - TIME_CHECK_CALLBACK_2(kTimeCityDeutschAvricourt, CURRENT_PARAM(2, 6), 15, setup_enterStation, "DeutschA", kCityDeutschAvricourt); + if (timeCheckEnterStation(kTimeCityDeutschAvricourt, CURRENT_PARAM(2, 6), 15, "DeutschA", kCityDeutschAvricourt)) + break; label_exit_deutschavricourt: // Exiting Avricourt station TIME_CHECK_CALLBACK_1(kTimeExitDeutschAvricourt, CURRENT_PARAM(2, 7), 16, setup_exitStation, "DeutschA"); label_enter_strasbourg: - TIME_CHECK_CALLBACK_2(kTimeCityStrasbourg, CURRENT_PARAM(2, 8), 17, setup_savegame, kSavegameTypeTime, kTimeNone); + if (getState()->time > kTimeCityStrasbourg && !CURRENT_PARAM(2, 8)) { + CURRENT_PARAM(2, 8) = 1; + setCallback(17); + setup_savegame(kSavegameTypeTime, kTimeNone); + + break; + } label_exit_strasbourg: // Exiting Strasbourg station @@ -497,7 +516,8 @@ label_exit_strasbourg: label_enter_badenoos: // Entering Baden Oos station - TIME_CHECK_CALLBACK_2(kTimeCityBadenOos, CURRENT_PARAM(3, 2), 20, setup_enterStation, "BadenOos", kCityBadenOos); + if (timeCheckEnterStation(kTimeCityBadenOos, CURRENT_PARAM(3, 2), 20, "BadenOos", kCityBadenOos)) + break; label_exit_badenoos: // Exiting Baden Oos station @@ -922,25 +942,29 @@ IMPLEMENT_FUNCTION(15, Chapters, chapter3Handler) params->param5 = 0; } - TIME_CHECK_CALLBACK_2(kTimeEnterSalzbourg, params->param6, 1, setup_enterStation, "Salzburg", kCitySalzbourg); + if (timeCheckEnterStation(kTimeEnterSalzbourg, params->param6, 1, "Salzburg", kCitySalzbourg)) + break; label_callback_1: TIME_CHECK_CALLBACK_1(kTimeExitSalzbourg, params->param7, 2, setup_exitStation, "Salzburg"); label_callback_2: - TIME_CHECK_CALLBACK_2(kTimeEnterAttnangPuchheim, params->param8, 3, setup_enterStation, "Attnang", kCityAttnangPuchheim); + if (timeCheckEnterStation(kTimeEnterAttnangPuchheim, params->param8, 3, "Attnang", kCityAttnangPuchheim)) + break; label_callback_3: TIME_CHECK_CALLBACK_1(kTimeExitAttnangPuchheim, CURRENT_PARAM(1, 1), 4, setup_exitStation, "Attnang"); label_callback_4: - TIME_CHECK_CALLBACK_2(kTimeEnterWels, CURRENT_PARAM(1, 2), 5, setup_enterStation, "Wels", kCityWels); + if (timeCheckEnterStation(kTimeEnterWels, CURRENT_PARAM(1, 2), 5, "Wels", kCityWels)) + break; label_callback_5: TIME_CHECK_CALLBACK_1(kTimeEnterWels, CURRENT_PARAM(1, 3), 6, setup_exitStation, "Wels"); label_callback_6: - TIME_CHECK_CALLBACK_2(kTimeEnterLinz, CURRENT_PARAM(1, 4), 7, setup_enterStation, "Linz", kCityLinz); + if (timeCheckEnterStation(kTimeEnterLinz, CURRENT_PARAM(1, 4), 7, "Linz", kCityLinz)) + break; label_callback_7: TIME_CHECK_CALLBACK_1(kTimeCityLinz, CURRENT_PARAM(1, 5), 8, setup_exitStation, "Linz"); @@ -951,7 +975,7 @@ label_callback_8: getState()->timeDelta = 5; } - TIME_CHECK_CALLBACK_2(kTimeCityVienna, CURRENT_PARAM(1, 7), 9, setup_enterStation, "Vienna", kCityVienna); + timeCheckEnterStation(kTimeCityVienna, CURRENT_PARAM(1, 7), 9, "Vienna", kCityVienna); break; case kActionEndSound: @@ -1221,7 +1245,8 @@ IMPLEMENT_FUNCTION(19, Chapters, chapter4Handler) params->param7 = 0; } - TIME_CHECK_CALLBACK_2(kTimeEnterPoszony, params->param8, 1, setup_enterStation, "Pozsony", kCityPoszony); + if (timeCheckEnterStation(kTimeEnterPoszony, params->param8, 1, "Pozsony", kCityPoszony)) + break; label_exitPozsony: TIME_CHECK_CALLBACK_1(kTimeExitPoszony, CURRENT_PARAM(1, 1), 2, setup_exitStation, "Pozsony"); @@ -1237,7 +1262,8 @@ label_enterGalanta: if (params->param1) goto label_callback_4; - TIME_CHECK_CALLBACK_2(kTimeEnterGalanta, CURRENT_PARAM(1, 3), 3, setup_enterStation, "Galanta", kCityGalanta); + if (timeCheckEnterStation(kTimeEnterGalanta, CURRENT_PARAM(1, 3), 3, "Galanta", kCityGalanta)) + break; label_exitGalanta: TIME_CHECK_CALLBACK_1(kTimeExitGalanta, CURRENT_PARAM(1, 4), 4, setup_exitStation, "Galanta"); @@ -1817,4 +1843,16 @@ void Chapters::playSteam() { ENTITY_PARAM(0, 2) = 0; } +bool Chapters::timeCheckEnterStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence, CityIndex cityIndex) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + setup_enterStation(sequence, cityIndex); + + return true; + } + + return false; +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/chapters.h b/engines/lastexpress/entities/chapters.h index 62b8af9270..51e6444506 100644 --- a/engines/lastexpress/entities/chapters.h +++ b/engines/lastexpress/entities/chapters.h @@ -154,6 +154,7 @@ public: DECLARE_FUNCTION(chapter5Handler) private: + bool timeCheckEnterStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence, CityIndex cityIndex); void enterExitStation(const SavePoint &savepoint, bool isEnteringStation); void enterExitHelper(bool isEnteringStation); void playSteam(); diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 306dbf8376..9818a20d64 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -270,14 +270,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_CALLBACK_2(timeValue, parameter, callback, function, param1, param2) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - setCallback(callback); \ - function(param1, param2); \ - break; \ - } - #define TIME_CHECK_CALLBACK_3(timeValue, parameter, callback, function, param1, param2, param3) \ if (getState()->time > timeValue && !parameter) { \ parameter = 1; \ diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 5ad8a1b985..0dc201be71 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -774,7 +774,13 @@ IMPLEMENT_FUNCTION(23, Rebecca, function23) break; case kActionNone: - TIME_CHECK_CALLBACK_2(kTime1111500, params->param2, 3, setup_enterExitCompartment, "623De", kObjectCompartmentE); + if (getState()->time > kTime1111500 && !params->param2) { + params->param2 = 1; + setCallback(3); + setup_enterExitCompartment("623De", kObjectCompartmentE); + + break; + } break; case kActionDefault: -- cgit v1.2.3 From b6b98483c5117ee3cee0a52607e5f5f4acb7def7 Mon Sep 17 00:00:00 2001 From: Julien Date: Tue, 24 Jul 2012 22:47:42 -0400 Subject: LASTEXPRESS: Remove TIME_CHECK_CALLBACK_3 macro --- engines/lastexpress/entities/entity_intern.h | 8 -------- engines/lastexpress/entities/francois.cpp | 30 +++++++++++++++++++++++----- engines/lastexpress/entities/francois.h | 3 +++ engines/lastexpress/entities/rebecca.cpp | 7 ++++++- engines/lastexpress/entities/verges.cpp | 7 ++++++- 5 files changed, 40 insertions(+), 15 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 9818a20d64..f12f34ac74 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -270,14 +270,6 @@ void class::setup_##name() { \ break; \ } -#define TIME_CHECK_CALLBACK_3(timeValue, parameter, callback, function, param1, param2, param3) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - setCallback(callback); \ - function(param1, param2, param3); \ - break; \ - } - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/francois.cpp b/engines/lastexpress/entities/francois.cpp index 89fdcaf668..c39eb1197c 100644 --- a/engines/lastexpress/entities/francois.cpp +++ b/engines/lastexpress/entities/francois.cpp @@ -1007,10 +1007,11 @@ label_callback_5: } label_callback_6: - TIME_CHECK_CALLBACK_3(kTime1782000, params->param6, 7, setup_function14, kObjectCompartmentC, kPosition_6470, "c"); + if (timeCheckCallbackCompartment(kTime1782000, params->param6, 7, kObjectCompartmentC, kPosition_6470, "c")) + break; label_callback_7: - TIME_CHECK_CALLBACK_3(kTime1813500, params->param7, 8, setup_function14, kObjectCompartmentF, kPosition_4070, "f"); + timeCheckCallbackCompartment(kTime1813500, params->param7, 8, kObjectCompartmentF, kPosition_4070, "f"); break; case kActionCallback: @@ -1136,13 +1137,15 @@ label_callback_11: } label_callback_12: - TIME_CHECK_CALLBACK_3(kTime2040300, CURRENT_PARAM(1, 5), 13, setup_function14, kObjectCompartmentE, kPosition_4840, "e"); + if (timeCheckCallbackCompartment(kTime2040300, CURRENT_PARAM(1, 5), 13, kObjectCompartmentE, kPosition_4840, "e")) + break; label_callback_13: - TIME_CHECK_CALLBACK_3(kTime2040300, CURRENT_PARAM(1, 6), 14, setup_function14, kObjectCompartmentF, kPosition_4070, "f"); + if (timeCheckCallbackCompartment(kTime2040300, CURRENT_PARAM(1, 6), 14, kObjectCompartmentF, kPosition_4070, "f")) + break; label_callback_14: - TIME_CHECK_CALLBACK_3(kTime2040300, CURRENT_PARAM(1, 7), 15, setup_function14, kObjectCompartmentB, kPosition_7500, "b"); + timeCheckCallbackCompartment(kTime2040300, CURRENT_PARAM(1, 7), 15, kObjectCompartmentB, kPosition_7500, "b"); } } break; @@ -1298,4 +1301,21 @@ IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// IMPLEMENT_NULL_FUNCTION(31, Francois) + +////////////////////////////////////////////////////////////////////////// +// Helper functions +////////////////////////////////////////////////////////////////////////// +bool Francois::timeCheckCallbackCompartment(TimeValue timeValue, uint ¶meter, byte callback, ObjectIndex compartment, EntityPosition position, const char* sequenceSuffix) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + setup_function14(compartment, position, sequenceSuffix); + + return true; + } + + return false; +} + + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/francois.h b/engines/lastexpress/entities/francois.h index 19eca6fb50..09715dba67 100644 --- a/engines/lastexpress/entities/francois.h +++ b/engines/lastexpress/entities/francois.h @@ -160,6 +160,9 @@ public: DECLARE_FUNCTION(function30) DECLARE_NULL_FUNCTION() + +private: + bool timeCheckCallbackCompartment(TimeValue timeValue, uint ¶meter, byte callback, ObjectIndex compartment, EntityPosition position, const char* sequenceSuffix); }; } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 0dc201be71..79d13a93f5 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -972,7 +972,12 @@ IMPLEMENT_FUNCTION(26, Rebecca, function26) break; case kActionNone: - TIME_CHECK_CALLBACK_3(kTime1224000, params->param2, 1, setup_updatePosition, "118H", kCarRestaurant, 52); + if (getState()->time > kTime1224000 && !params->param2) { + params->param2 = 1; + setCallback(1); + setup_updatePosition("118H", kCarRestaurant, 52); + break; + } if (params->param1) { if (!Entity::updateParameter(params->param3, getState()->timeTicks, 90)) diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index dfeae21338..e6526870d7 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -1280,7 +1280,12 @@ IMPLEMENT_FUNCTION(32, Verges, function32) break; case kActionNone: - TIME_CHECK_CALLBACK_3(kTime2263500, params->param1, 5, setup_function10, kCarRedSleeping, kPosition_9460, "TRA3006"); + if (getState()->time > kTime2263500 && !params->param1) { + params->param1 = 1; + setCallback(5); + setup_function10(kCarRedSleeping, kPosition_9460, "TRA3006"); + break; + } break; case kActionDefault: -- cgit v1.2.3 From 938961e23737e5ff19aee61e1ec6dd6e19ca0529 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 25 Jul 2012 17:55:17 -0400 Subject: LASTEXPRESS: Remove TIME_CHECK_CALLBACK_1 macro --- engines/lastexpress/entities/alouan.cpp | 3 +- engines/lastexpress/entities/august.cpp | 2 +- engines/lastexpress/entities/boutarel.cpp | 12 +++---- engines/lastexpress/entities/chapters.cpp | 54 ++++++++++++++++++++-------- engines/lastexpress/entities/chapters.h | 1 + engines/lastexpress/entities/entity.cpp | 24 +++++++++++++ engines/lastexpress/entities/entity.h | 8 +++++ engines/lastexpress/entities/entity_intern.h | 12 ------- engines/lastexpress/entities/francois.cpp | 29 +++++++++++---- engines/lastexpress/entities/francois.h | 1 + engines/lastexpress/entities/mertens.cpp | 6 ++-- engines/lastexpress/entities/rebecca.cpp | 3 +- engines/lastexpress/entities/verges.cpp | 54 ++++++++++++++++++---------- engines/lastexpress/entities/yasmin.cpp | 12 ++++--- 14 files changed, 155 insertions(+), 66 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/alouan.cpp b/engines/lastexpress/entities/alouan.cpp index 2f086de46b..e834e1f7cb 100644 --- a/engines/lastexpress/entities/alouan.cpp +++ b/engines/lastexpress/entities/alouan.cpp @@ -292,7 +292,8 @@ label_callback1: } label_callback2: - TIME_CHECK_CALLBACK_1(kTime2052000, params->param3, 3, setup_playSound, "Har1005"); + if (Entity::timeCheckCallback(kTime2052000, params->param3, 3, "Har1005", WRAP_SETUP_FUNCTION_S(Alouan, setup_playSound))) + break; label_callback3: if (Entity::timeCheckCallback(kTime2133000, params->param4, 4, WRAP_SETUP_FUNCTION(Alouan, setup_compartment6to8))) diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index 0412da69ac..67d810fde2 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -1906,7 +1906,7 @@ IMPLEMENT_FUNCTION(37, August, function37) break; case kActionNone: - TIME_CHECK_CALLBACK_1(kTime1791000, params->param2, 5, setup_function20, true); + Entity::timeCheckCallback(kTime1791000, params->param2, 5, true, WRAP_SETUP_FUNCTION_B(August, setup_function20)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/boutarel.cpp b/engines/lastexpress/entities/boutarel.cpp index 3c13cb121e..219ddf901b 100644 --- a/engines/lastexpress/entities/boutarel.cpp +++ b/engines/lastexpress/entities/boutarel.cpp @@ -653,7 +653,7 @@ IMPLEMENT_FUNCTION(20, Boutarel, function20) } } - TIME_CHECK_CALLBACK_1(kTime1138500, params->param4, 4, setup_function14, false); + Entity::timeCheckCallback(kTime1138500, params->param4, 4, false, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case kActionDefault: @@ -678,7 +678,7 @@ IMPLEMENT_FUNCTION(20, Boutarel, function20) break; case 3: - TIME_CHECK_CALLBACK_1(kTime1138500, params->param4, 4, setup_function14, false); + Entity::timeCheckCallback(kTime1138500, params->param4, 4, false, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case 4: @@ -836,7 +836,7 @@ IMPLEMENT_FUNCTION(24, Boutarel, chapter2Handler) break; case kActionNone: - TIME_CHECK_CALLBACK_1(kTime1759500, params->param2, 1, setup_function14, false); + Entity::timeCheckCallback(kTime1759500, params->param2, 1, false, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case kActionDefault: @@ -961,7 +961,7 @@ IMPLEMENT_FUNCTION(29, Boutarel, function29) } } - TIME_CHECK_CALLBACK_1(kTime2002500, params->param4, 1, setup_function14, true); + Entity::timeCheckCallback(kTime2002500, params->param4, 1, true, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case kActionDefault: @@ -974,7 +974,7 @@ IMPLEMENT_FUNCTION(29, Boutarel, function29) break; case 1: - TIME_CHECK_CALLBACK_1(kTime2002500, params->param4, 1, setup_function14, true); + Entity::timeCheckCallback(kTime2002500, params->param4, 1, true, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case 2: @@ -1065,7 +1065,7 @@ IMPLEMENT_FUNCTION(33, Boutarel, function33) case kActionNone: if (params->param1) - TIME_CHECK_CALLBACK_1(kTime2389500, params->param2, 3, setup_function14, false); + Entity::timeCheckCallback(kTime2389500, params->param2, 3, false, WRAP_SETUP_FUNCTION_B(Boutarel, setup_function14)); break; case kActionDefault: diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index ac9387bd78..a2f3a3d871 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -449,7 +449,8 @@ label_enter_chalons: label_exit_chalons: // Exiting Chalons station - TIME_CHECK_CALLBACK_1(kTimeExitChalons, CURRENT_PARAM(1, 4), 6, setup_exitStation, "Chalons"); + if (timeCheckExitStation(kTimeExitChalons, CURRENT_PARAM(1, 4), 6, "Chalons")) + break; label_enter_barleduc: // Entering Bar-Le-Duc station @@ -458,7 +459,8 @@ label_enter_barleduc: label_exit_barleduc: // Exiting Bar-Le-Duc station - TIME_CHECK_CALLBACK_1(kTimeExitBarLeDuc, CURRENT_PARAM(1, 6), 8, setup_exitStation, "BarLeDuc"); + if (timeCheckExitStation(kTimeExitBarLeDuc, CURRENT_PARAM(1, 6), 8, "BarLeDuc")) + break; label_enter_nancy: if (getState()->time > kTime1260000 && !CURRENT_PARAM(1, 7)) { @@ -472,7 +474,8 @@ label_enter_nancy: label_exit_nancy: // Exiting Nancy station - TIME_CHECK_CALLBACK_1(kTimeExitNancy, CURRENT_PARAM(2, 1), 10, setup_exitStation, "Nancy"); + if (timeCheckExitStation(kTimeExitNancy, CURRENT_PARAM(2, 1), 10, "Nancy")) + break; label_enter_luneville: // Entering Luneville station @@ -481,7 +484,8 @@ label_enter_luneville: label_exit_luneville: // Exiting Luneville station - TIME_CHECK_CALLBACK_1(kTimeExitLuneville, CURRENT_PARAM(2, 3), 12, setup_exitStation, "Luneville"); + if (timeCheckExitStation(kTimeExitLuneville, CURRENT_PARAM(2, 3), 12, "Luneville")) + break; label_enter_avricourt: // Entering Avricourt station @@ -490,7 +494,8 @@ label_enter_avricourt: label_exit_avricourt: // Exiting Avricourt station - TIME_CHECK_CALLBACK_1(kTimeExitAvricourt, CURRENT_PARAM(2, 5), 14, setup_exitStation, "Avricourt"); + if (timeCheckExitStation(kTimeExitAvricourt, CURRENT_PARAM(2, 5), 14, "Avricourt")) + break; label_enter_deutschavricourt: // Entering Deutsch-Avricourt station @@ -499,7 +504,8 @@ label_enter_deutschavricourt: label_exit_deutschavricourt: // Exiting Avricourt station - TIME_CHECK_CALLBACK_1(kTimeExitDeutschAvricourt, CURRENT_PARAM(2, 7), 16, setup_exitStation, "DeutschA"); + if (timeCheckExitStation(kTimeExitDeutschAvricourt, CURRENT_PARAM(2, 7), 16, "DeutschA")) + break; label_enter_strasbourg: if (getState()->time > kTimeCityStrasbourg && !CURRENT_PARAM(2, 8)) { @@ -512,7 +518,8 @@ label_enter_strasbourg: label_exit_strasbourg: // Exiting Strasbourg station - TIME_CHECK_CALLBACK_1(kTimeExitStrasbourg, CURRENT_PARAM(3, 1), 19, setup_exitStation, "Strasbou"); + if (timeCheckExitStation(kTimeExitStrasbourg, CURRENT_PARAM(3, 1), 19, "Strasbou")) + break; label_enter_badenoos: // Entering Baden Oos station @@ -521,7 +528,8 @@ label_enter_badenoos: label_exit_badenoos: // Exiting Baden Oos station - TIME_CHECK_CALLBACK_1(kTimeExitBadenOos, CURRENT_PARAM(3, 3), 21, setup_exitStation, "BadenOos"); + if (timeCheckExitStation(kTimeExitBadenOos, CURRENT_PARAM(3, 3), 21, "BadenOos")) + break; label_chapter1_next: if (getState()->time > kTimeChapter1End3 && ! CURRENT_PARAM(3, 4)) { @@ -946,28 +954,32 @@ IMPLEMENT_FUNCTION(15, Chapters, chapter3Handler) break; label_callback_1: - TIME_CHECK_CALLBACK_1(kTimeExitSalzbourg, params->param7, 2, setup_exitStation, "Salzburg"); + if (timeCheckExitStation(kTimeExitSalzbourg, params->param7, 2, "Salzburg")) + break; label_callback_2: if (timeCheckEnterStation(kTimeEnterAttnangPuchheim, params->param8, 3, "Attnang", kCityAttnangPuchheim)) break; label_callback_3: - TIME_CHECK_CALLBACK_1(kTimeExitAttnangPuchheim, CURRENT_PARAM(1, 1), 4, setup_exitStation, "Attnang"); + if (timeCheckExitStation(kTimeExitAttnangPuchheim, CURRENT_PARAM(1, 1), 4, "Attnang")) + break; label_callback_4: if (timeCheckEnterStation(kTimeEnterWels, CURRENT_PARAM(1, 2), 5, "Wels", kCityWels)) break; label_callback_5: - TIME_CHECK_CALLBACK_1(kTimeEnterWels, CURRENT_PARAM(1, 3), 6, setup_exitStation, "Wels"); + if (timeCheckExitStation(kTimeEnterWels, CURRENT_PARAM(1, 3), 6, "Wels")) + break; label_callback_6: if (timeCheckEnterStation(kTimeEnterLinz, CURRENT_PARAM(1, 4), 7, "Linz", kCityLinz)) break; label_callback_7: - TIME_CHECK_CALLBACK_1(kTimeCityLinz, CURRENT_PARAM(1, 5), 8, setup_exitStation, "Linz"); + if (timeCheckExitStation(kTimeCityLinz, CURRENT_PARAM(1, 5), 8, "Linz")) + break; label_callback_8: if (getState()->time > kTime2187000 && !CURRENT_PARAM(1, 6)) { @@ -1249,7 +1261,8 @@ IMPLEMENT_FUNCTION(19, Chapters, chapter4Handler) break; label_exitPozsony: - TIME_CHECK_CALLBACK_1(kTimeExitPoszony, CURRENT_PARAM(1, 1), 2, setup_exitStation, "Pozsony"); + if (timeCheckExitStation(kTimeExitPoszony, CURRENT_PARAM(1, 1), 2, "Pozsony")) + break; label_enterGalanta: if (getObjects()->get(kObjectCompartment1).location2 == kObjectLocation1) { @@ -1266,7 +1279,8 @@ label_enterGalanta: break; label_exitGalanta: - TIME_CHECK_CALLBACK_1(kTimeExitGalanta, CURRENT_PARAM(1, 4), 4, setup_exitStation, "Galanta"); + if (timeCheckExitStation(kTimeExitGalanta, CURRENT_PARAM(1, 4), 4, "Galanta")) + break; label_callback_4: if (getState()->time > kTime2470500 && !CURRENT_PARAM(1, 5)) { @@ -1855,4 +1869,16 @@ bool Chapters::timeCheckEnterStation(TimeValue timeValue, uint ¶meter, byte return false; } +bool Chapters::timeCheckExitStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + setup_exitStation(sequence); + + return true; + } + + return false; +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/chapters.h b/engines/lastexpress/entities/chapters.h index 51e6444506..a9a53523d4 100644 --- a/engines/lastexpress/entities/chapters.h +++ b/engines/lastexpress/entities/chapters.h @@ -155,6 +155,7 @@ public: private: bool timeCheckEnterStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence, CityIndex cityIndex); + bool timeCheckExitStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence); void enterExitStation(const SavePoint &savepoint, bool isEnteringStation); void enterExitHelper(bool isEnteringStation); void playSteam(); diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 48856a7bc4..9160b6db95 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -660,6 +660,30 @@ bool Entity::timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callba return false; } +bool Entity::timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, const char *str, Common::Functor1 *function) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + (*function)(str); + + return true; + } + + return false; +} + +bool Entity::timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, bool check, Common::Functor1 *function) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + (*function)(check); + + return true; + } + + return false; +} + bool Entity::timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function) { if (getState()->time > timeValue && !parameter) { parameter = 1; diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 785e355481..3141559081 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -85,6 +85,12 @@ struct SavePoint; #define WRAP_SETUP_FUNCTION(className, method) \ new Common::Functor0Mem(this, &className::method) +#define WRAP_SETUP_FUNCTION_S(className, method) \ + new Common::Functor1Mem(this, &className::method) + +#define WRAP_SETUP_FUNCTION_B(className, method) \ + new Common::Functor1Mem(this, &className::method) + ////////////////////////////////////////////////////////////////////////// // Parameters macros ////////////////////////////////////////////////////////////////////////// @@ -916,6 +922,8 @@ protected: bool timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function); bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); + bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, const char *str, Common::Functor1 *function); + bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, bool check, Common::Functor1 *function); bool timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); bool timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index f12f34ac74..01e997f52e 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -258,18 +258,6 @@ void class::setup_##name() { \ EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); - -////////////////////////////////////////////////////////////////////////// -// Time check macros -////////////////////////////////////////////////////////////////////////// -#define TIME_CHECK_CALLBACK_1(timeValue, parameter, callback, function, param1) \ - if (getState()->time > timeValue && !parameter) { \ - parameter = 1; \ - setCallback(callback); \ - function(param1); \ - break; \ - } - } // End of namespace LastExpress #endif // LASTEXPRESS_ENTITY_INTERN_H diff --git a/engines/lastexpress/entities/francois.cpp b/engines/lastexpress/entities/francois.cpp index c39eb1197c..d2bbc9854c 100644 --- a/engines/lastexpress/entities/francois.cpp +++ b/engines/lastexpress/entities/francois.cpp @@ -866,7 +866,7 @@ IMPLEMENT_FUNCTION(18, Francois, chapter1Handler) break; case kActionNone: - TIME_CHECK_CALLBACK_1(kTimeParisEpernay, params->param1, 1, setup_function11, kTime1093500); + timeCheckCallback(kTimeParisEpernay, params->param1, 1, kTime1093500); break; case kActionCallback: @@ -978,7 +978,8 @@ IMPLEMENT_FUNCTION(23, Francois, function23) } label_callback_1: - TIME_CHECK_CALLBACK_1(kTime1764000, params->param1, 2, setup_playSound, "Fra2011"); + if (Entity::timeCheckCallback(kTime1764000, params->param1, 2, "Fra2011", WRAP_SETUP_FUNCTION_S(Francois, setup_playSound))) + break; label_callback_2: if (Entity::timeCheckCallback(kTime1800000, params->param2, 3, WRAP_SETUP_FUNCTION(Francois, setup_function13))) @@ -986,10 +987,12 @@ label_callback_2: label_callback_3: if (!getInventory()->hasItem(kItemWhistle) && getInventory()->get(kItemWhistle)->location != kObjectLocation3) { - TIME_CHECK_CALLBACK_1(kTime1768500, params->param3, 4, setup_function11, kTime1773000); + if (timeCheckCallback(kTime1768500, params->param3, 4, kTime1773000)) + break; label_callback_4: - TIME_CHECK_CALLBACK_1(kTime1827000, params->param4, 5, setup_function11, kTime1831500); + if (timeCheckCallback(kTime1827000, params->param4, 5, kTime1831500)) + break; } label_callback_5: @@ -1116,10 +1119,12 @@ label_callback_8: label_callback_9: if (!getInventory()->hasItem(kItemWhistle) && getInventory()->get(kItemWhistle)->location != kObjectLocation3) { - TIME_CHECK_CALLBACK_1(kTime2011500, CURRENT_PARAM(1, 2), 10, setup_function11, kTime2016000); + if (timeCheckCallback(kTime2011500, CURRENT_PARAM(1, 2), 10, kTime2016000)) + break; label_callback_10: - TIME_CHECK_CALLBACK_1(kTime2115000, CURRENT_PARAM(1, 3), 11, setup_function11, kTime2119500); + if (timeCheckCallback(kTime2115000, CURRENT_PARAM(1, 3), 11, kTime2119500)) + break; } label_callback_11: @@ -1317,5 +1322,17 @@ bool Francois::timeCheckCallbackCompartment(TimeValue timeValue, uint ¶meter return false; } +bool Francois::timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, TimeValue timeValue2) { + if (getState()->time > timeValue && !parameter) { + parameter = 1; + setCallback(callback); + setup_function11(timeValue2); + + return true; + } + + return false; +} + } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/francois.h b/engines/lastexpress/entities/francois.h index 09715dba67..5a4ff4b8b2 100644 --- a/engines/lastexpress/entities/francois.h +++ b/engines/lastexpress/entities/francois.h @@ -163,6 +163,7 @@ public: private: bool timeCheckCallbackCompartment(TimeValue timeValue, uint ¶meter, byte callback, ObjectIndex compartment, EntityPosition position, const char* sequenceSuffix); + bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, TimeValue timeValue2); }; } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/mertens.cpp b/engines/lastexpress/entities/mertens.cpp index b6ea86cd0e..97dd293793 100644 --- a/engines/lastexpress/entities/mertens.cpp +++ b/engines/lastexpress/entities/mertens.cpp @@ -3532,14 +3532,16 @@ label_callback_5: } label_callback_6: - TIME_CHECK_CALLBACK_1(kTime1971000, params->param1, 7, setup_function28, "CON3012"); + if (Entity::timeCheckCallback(kTime1971000, params->param1, 7, "CON3012", WRAP_SETUP_FUNCTION_S(Mertens, setup_function28))) + break; label_callback_7: if (Entity::timeCheckCallback(kTime2117700, params->param2, 8, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) break; label_callback_8: - TIME_CHECK_CALLBACK_1(kTime2124000, params->param3, 9, setup_function28, "CON2010"); + if (Entity::timeCheckCallback(kTime2124000, params->param3, 9, "CON2010", WRAP_SETUP_FUNCTION_S(Mertens, setup_function28))) + break; label_callback_9: if (Entity::timeCheckCallback(kTime2146500, params->param4, 10, WRAP_SETUP_FUNCTION(Mertens, setup_function32))) diff --git a/engines/lastexpress/entities/rebecca.cpp b/engines/lastexpress/entities/rebecca.cpp index 79d13a93f5..5bcb6aef85 100644 --- a/engines/lastexpress/entities/rebecca.cpp +++ b/engines/lastexpress/entities/rebecca.cpp @@ -683,7 +683,8 @@ IMPLEMENT_FUNCTION(22, Rebecca, chapter1Handler) break; case kActionNone: - TIME_CHECK_CALLBACK_1(kTime1084500, params->param3, 1, setup_playSound, "REB1015"); + if (Entity::timeCheckCallback(kTime1084500, params->param3, 1, "REB1015", WRAP_SETUP_FUNCTION_S(Rebecca, setup_playSound))) + break; if (params->param4 == kTimeInvalid) goto label_callback_4; diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index e6526870d7..867f122d8f 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -907,7 +907,8 @@ label_callback3: if (params->param6) goto label_callback12; - TIME_CHECK_CALLBACK_1(kTimeChapter1, params->param7, 4, setup_function9, "TRA1001"); + if (Entity::timeCheckCallback(kTimeChapter1, params->param7, 4, "TRA1001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback4: if (Entity::timeCheckCallback(kTime1089000, params->param8, 5, WRAP_SETUP_FUNCTION(Verges, setup_function12))) @@ -922,16 +923,20 @@ label_callback4: } label_callback8: - TIME_CHECK_CALLBACK_1(kTime1107000, CURRENT_PARAM(1, 1), 9, setup_function9, "TRA1001A"); + if (Entity::timeCheckCallback(kTime1107000, CURRENT_PARAM(1, 1), 9, "TRA1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback9: - TIME_CHECK_CALLBACK_1(kTime1134000, CURRENT_PARAM(1, 2), 10, setup_function9, "TRA1002"); + if (Entity::timeCheckCallback(kTime1134000, CURRENT_PARAM(1, 2), 10, "TRA1002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback10: - TIME_CHECK_CALLBACK_1(kTime1165500, CURRENT_PARAM(1, 3), 11, setup_function9, "TRA1003"); + if (Entity::timeCheckCallback(kTime1165500, CURRENT_PARAM(1, 3), 11, "TRA1003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback11: - TIME_CHECK_CALLBACK_1(kTime1225800, CURRENT_PARAM(1, 4), 12, setup_function9, "TRA1004"); + if (Entity::timeCheckCallback(kTime1225800, CURRENT_PARAM(1, 4), 12, "TRA1004", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback12: if (ENTITY_PARAM(0, 5) && !params->param2) { @@ -1083,7 +1088,8 @@ IMPLEMENT_FUNCTION(28, Verges, chapter2Handler) } label_callback_1: - TIME_CHECK_CALLBACK_1(kTime1818900, params->param1, 2, setup_function9, "Tra2177"); + if (Entity::timeCheckCallback(kTime1818900, params->param1, 2, "Tra2177", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_2: if (params->param2 == kTimeInvalid || !getState()->time) @@ -1445,23 +1451,28 @@ label_callback_2: } label_callback_3: - TIME_CHECK_CALLBACK_1(kTime1971000, params->param1, 4, setup_function9, "Tra3001"); + if (Entity::timeCheckCallback(kTime1971000, params->param1, 4, "Tra3001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_4: - TIME_CHECK_CALLBACK_1(kTime1998000, params->param2, 5, setup_function9, "Tra3010a"); + if (Entity::timeCheckCallback(kTime1998000, params->param2, 5, "Tra3010a", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_5: if (Entity::timeCheckCallback(kTime2016000, params->param3, 6, WRAP_SETUP_FUNCTION(Verges, setup_function35))) break; label_callback_6: - TIME_CHECK_CALLBACK_1(kTime2070000, params->param4, 7, setup_function9, "Tra3002"); + if (Entity::timeCheckCallback(kTime2070000, params->param4, 7, "Tra3002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_7: - TIME_CHECK_CALLBACK_1(kTime2142000, params->param5, 8, setup_function9, "Tra3003"); + if (Entity::timeCheckCallback(kTime2142000, params->param5, 8, "Tra3003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_8: - TIME_CHECK_CALLBACK_1(kTime2173500, params->param6, 9, setup_function30, "Tra3012"); + if (Entity::timeCheckCallback(kTime2173500, params->param6, 9, "Tra3012", WRAP_SETUP_FUNCTION_S(Verges, setup_function30))) + break; label_callback_9: Entity::timeCheckCallback(kTime2218500, params->param7, 10, WRAP_SETUP_FUNCTION(Verges, setup_function32)); @@ -1611,27 +1622,32 @@ label_callback_1: } label_callback_2: - TIME_CHECK_CALLBACK_1(kTime2349000, params->param1, 3, setup_function9, "Tra1001"); + if (Entity::timeCheckCallback(kTime2349000, params->param1, 3, "Tra1001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_3: - TIME_CHECK_CALLBACK_1(kTime2378700, params->param2, 4, setup_function9, "Tra4001"); + if (Entity::timeCheckCallback(kTime2378700, params->param2, 4, "Tra4001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_4: - TIME_CHECK_CALLBACK_1(kTime2403000, params->param3, 5, setup_function9, "Tra1001A"); + if (Entity::timeCheckCallback(kTime2403000, params->param3, 5, "Tra1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_5: - TIME_CHECK_CALLBACK_1(kTime2414700, params->param4, 6, setup_function9, "Tra4002"); + if (Entity::timeCheckCallback(kTime2414700, params->param4, 6, "Tra4002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_6: - TIME_CHECK_CALLBACK_1(kTime2484000, params->param5, 7, setup_function9, "Tra4003"); + if (Entity::timeCheckCallback(kTime2484000, params->param5, 7, "Tra4003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; label_callback_7: - TIME_CHECK_CALLBACK_1(kTime2511000, params->param6, 8, setup_function9, "Tra4004"); + if (Entity::timeCheckCallback(kTime2511000, params->param6, 8, "Tra4004", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + break; } label_callback_8: - TIME_CHECK_CALLBACK_1(kTime2538000, params->param7, 9, setup_function9, "Tra4005"); - + Entity::timeCheckCallback(kTime2538000, params->param7, 9, "Tra4005", WRAP_SETUP_FUNCTION_S(Verges, setup_function9)); break; case kActionOpenDoor: diff --git a/engines/lastexpress/entities/yasmin.cpp b/engines/lastexpress/entities/yasmin.cpp index acacbb547b..1d280f51e0 100644 --- a/engines/lastexpress/entities/yasmin.cpp +++ b/engines/lastexpress/entities/yasmin.cpp @@ -211,9 +211,11 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) if (Entity::timeCheckPlaySoundUpdatePosition(kTime1162800, params->param3, 4, "Har1102", kPosition_4070)) break; - TIME_CHECK_CALLBACK_1(kTime1165500, params->param4, 5, setup_playSound, "Har1104"); + if (Entity::timeCheckCallback(kTime1165500, params->param4, 5, "Har1104", WRAP_SETUP_FUNCTION_S(Yasmin, setup_playSound))) + break; - TIME_CHECK_CALLBACK_1(kTime1174500, params->param5, 6, setup_playSound, "Har1106"); + if (Entity::timeCheckCallback(kTime1174500, params->param5, 6, "Har1106", WRAP_SETUP_FUNCTION_S(Yasmin, setup_playSound))) + break; Entity::timeCheckCallback(kTime1183500, params->param6, 7, WRAP_SETUP_FUNCTION(Yasmin, setup_function6)); break; @@ -240,11 +242,13 @@ IMPLEMENT_FUNCTION(9, Yasmin, chapter1Handler) // Fallback to case 4 case 4: - TIME_CHECK_CALLBACK_1(kTime1165500, params->param4, 5, setup_playSound, "Har1104"); + if (Entity::timeCheckCallback(kTime1165500, params->param4, 5, "Har1104", WRAP_SETUP_FUNCTION_S(Yasmin, setup_playSound))) + break; // Fallback to case 5 case 5: - TIME_CHECK_CALLBACK_1(kTime1174500, params->param5, 6, setup_playSound, "Har1106"); + if (Entity::timeCheckCallback(kTime1174500, params->param5, 6, "Har1106", WRAP_SETUP_FUNCTION_S(Yasmin, setup_playSound))) + break; // Fallback to case 6 case 6: -- cgit v1.2.3 From 813c2bb96587966cc49d34daef3bb5b5930427f1 Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 25 Jul 2012 21:34:13 -0400 Subject: LASTEXPRESS: Merge the remaining macros in entity_intern.h into entity.h --- engines/lastexpress/entities/abbot.h | 1 - engines/lastexpress/entities/alexei.h | 1 - engines/lastexpress/entities/alouan.h | 1 - engines/lastexpress/entities/anna.h | 1 - engines/lastexpress/entities/august.h | 1 - engines/lastexpress/entities/boutarel.h | 1 - engines/lastexpress/entities/chapters.h | 1 - engines/lastexpress/entities/cooks.h | 1 - engines/lastexpress/entities/coudert.h | 2 - engines/lastexpress/entities/entity.cpp | 2 - engines/lastexpress/entities/entity.h | 232 +++++++++++++++++++++++++++ engines/lastexpress/entities/entity39.h | 1 - engines/lastexpress/entities/entity_intern.h | 232 --------------------------- engines/lastexpress/entities/francois.h | 1 - engines/lastexpress/entities/gendarmes.h | 1 - engines/lastexpress/entities/hadija.h | 1 - engines/lastexpress/entities/ivo.h | 1 - engines/lastexpress/entities/kahina.h | 1 - engines/lastexpress/entities/kronos.h | 1 - engines/lastexpress/entities/mahmud.h | 1 - engines/lastexpress/entities/max.h | 1 - engines/lastexpress/entities/mertens.h | 1 - engines/lastexpress/entities/milos.h | 1 - engines/lastexpress/entities/mmeboutarel.h | 1 - engines/lastexpress/entities/pascale.h | 1 - engines/lastexpress/entities/rebecca.h | 1 - engines/lastexpress/entities/salko.h | 1 - engines/lastexpress/entities/servers0.h | 1 - engines/lastexpress/entities/servers1.h | 1 - engines/lastexpress/entities/sophie.h | 1 - engines/lastexpress/entities/tables.h | 1 - engines/lastexpress/entities/tatiana.h | 1 - engines/lastexpress/entities/train.h | 1 - engines/lastexpress/entities/vassili.h | 1 - engines/lastexpress/entities/verges.h | 1 - engines/lastexpress/entities/vesna.h | 1 - engines/lastexpress/entities/yasmin.h | 1 - 37 files changed, 232 insertions(+), 269 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.h b/engines/lastexpress/entities/abbot.h index 462f5a491e..ce52bb68ce 100644 --- a/engines/lastexpress/entities/abbot.h +++ b/engines/lastexpress/entities/abbot.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_ABBOT_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/alexei.h b/engines/lastexpress/entities/alexei.h index 262826ae42..9792385863 100644 --- a/engines/lastexpress/entities/alexei.h +++ b/engines/lastexpress/entities/alexei.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_ALEXEI_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/alouan.h b/engines/lastexpress/entities/alouan.h index c6a6beddd9..91254a449a 100644 --- a/engines/lastexpress/entities/alouan.h +++ b/engines/lastexpress/entities/alouan.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_ALOUAN_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/anna.h b/engines/lastexpress/entities/anna.h index 72c6db4bd9..205ff9d42c 100644 --- a/engines/lastexpress/entities/anna.h +++ b/engines/lastexpress/entities/anna.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_ANNA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/august.h b/engines/lastexpress/entities/august.h index 2cbb31b968..606321955b 100644 --- a/engines/lastexpress/entities/august.h +++ b/engines/lastexpress/entities/august.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_AUGUST_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/boutarel.h b/engines/lastexpress/entities/boutarel.h index 5eb264631c..04838f6527 100644 --- a/engines/lastexpress/entities/boutarel.h +++ b/engines/lastexpress/entities/boutarel.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_BOUTAREL_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/chapters.h b/engines/lastexpress/entities/chapters.h index a9a53523d4..ddb3de3bea 100644 --- a/engines/lastexpress/entities/chapters.h +++ b/engines/lastexpress/entities/chapters.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_CHAPTERS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/cooks.h b/engines/lastexpress/entities/cooks.h index 3ab7d35161..f01d0b2ca0 100644 --- a/engines/lastexpress/entities/cooks.h +++ b/engines/lastexpress/entities/cooks.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_COOKS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/coudert.h b/engines/lastexpress/entities/coudert.h index 45d13ce9bb..8303c80a32 100644 --- a/engines/lastexpress/entities/coudert.h +++ b/engines/lastexpress/entities/coudert.h @@ -24,8 +24,6 @@ #define LASTEXPRESS_COUDERT_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" - namespace LastExpress { class LastExpressEngine; diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 9160b6db95..a9ceaa16a9 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -22,8 +22,6 @@ #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" - #include "lastexpress/data/sequence.h" #include "lastexpress/game/action.h" diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 3141559081..634e4000b3 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -107,6 +107,238 @@ struct SavePoint; getEntities()->resetState(entity); \ ((class *)getEntities()->get(entity))->function(); +////////////////////////////////////////////////////////////////////////// +// Setup +////////////////////////////////////////////////////////////////////////// + +#define IMPLEMENT_SETUP(class, callback_class, name, index) \ +void class::setup_##name() { \ + BEGIN_SETUP(callback_class, name, index, EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::setup_" #name "()"); \ + END_SETUP() \ +} + +#define BEGIN_SETUP(class, name, index, type) \ + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); \ + _data->setCurrentCallback(index); \ + _data->resetCurrentParameters(); + +#define END_SETUP() \ + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + + +////////////////////////////////////////////////////////////////////////// +// Implementation +////////////////////////////////////////////////////////////////////////// + +// Expose parameters and check validity +#define EXPOSE_PARAMS(type) \ + type *params = (type *)_data->getCurrentParameters(); \ + if (!params) \ + error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ + + +// function signature without setup (we keep the index for consistency but never use it) +#define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ + void class::name(const SavePoint &savepoint) { \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(index=" #index ")"); + +// simple setup with no parameters +#define IMPLEMENT_FUNCTION(index, class, name) \ + IMPLEMENT_SETUP(class, class, name, index) \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "() - action: %s", ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_END } + +// nullfunction call +#define IMPLEMENT_NULL_FUNCTION(index, class) \ + IMPLEMENT_SETUP(class, Entity, nullfunction, index) + +// setup with one uint parameter +#define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ + void class::setup_##name(paramType param1) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ + params->param1 = (unsigned int)param1; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d) - action: %s", params->param1, ACTION_NAME(savepoint.action)); + +// setup with two uint parameters +#define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ + void class::setup_##name(paramType1 param1, paramType2 param2) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ + params->param1 = param1; \ + params->param2 = param2; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d) - action: %s", params->param1, params->param2, ACTION_NAME(savepoint.action)); + +// setup with three uint parameters +#define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ + void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ + params->param1 = param1; \ + params->param2 = param2; \ + params->param3 = param3; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %d) - action: %s", params->param1, params->param2, params->param3, ACTION_NAME(savepoint.action)); + +// setup with one char *parameter +#define IMPLEMENT_FUNCTION_S(index, class, name) \ + void class::setup_##name(const char *seq1) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s) - action: %s", (char *)¶ms->seq1, ACTION_NAME(savepoint.action)); + +// setup with one char *parameter and one uint +#define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ + void class::setup_##name(const char *seq1, paramType2 param4) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + params->param4 = param4; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d) - action: %s", (char *)¶ms->seq1, params->param4, ACTION_NAME(savepoint.action)); + +// setup with one char *parameter and two uints +#define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ + void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + params->param4 = param4; \ + params->param5 = param5; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, ACTION_NAME(savepoint.action)); + +// setup with one char *parameter and three uints +#define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ + void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIII) \ + EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq, seq, 12); \ + params->param4 = param4; \ + params->param5 = param5; \ + params->param6 = param6; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, params->param6, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ + void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + params->param4 = param4; \ + params->param5 = param5; \ + strncpy((char *)¶ms->seq2, seq2, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %s) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_SS(index, class, name) \ + void class::setup_##name(const char *seq1, const char *seq2) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + strncpy((char *)¶ms->seq2, seq2, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ + void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + strncpy((char *)¶ms->seq2, seq2, 12); \ + params->param7 = param7; \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s, %d) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, params->param7, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ + void class::setup_##name(paramType param1, const char *seq) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersISII) \ + EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); \ + params->param1 = (unsigned int)param1; \ + strncpy((char *)¶ms->seq, seq, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersISII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s) - action: %s", params->param1, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ + void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersISSI) \ + EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); \ + params->param1 = param1; \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + strncpy((char *)¶ms->seq2, seq2, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s, %s) - action: %s", params->param1, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ + void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISI) \ + EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); \ + params->param1 = param1; \ + params->param2 = param2; \ + strncpy((char *)¶ms->seq, seq, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); + +#define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ + void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ + BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISS) \ + EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); \ + params->param1 = param1; \ + params->param2 = param2; \ + strncpy((char *)¶ms->seq1, seq1, 12); \ + strncpy((char *)¶ms->seq2, seq2, 12); \ + END_SETUP() \ + } \ + void class::name(const SavePoint &savepoint) { \ + EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); ////////////////////////////////////////////////////////////////////////// diff --git a/engines/lastexpress/entities/entity39.h b/engines/lastexpress/entities/entity39.h index 148bca5c33..54b65408c7 100644 --- a/engines/lastexpress/entities/entity39.h +++ b/engines/lastexpress/entities/entity39.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_ENTITY39_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/entity_intern.h b/engines/lastexpress/entities/entity_intern.h index 01e997f52e..fd803676a9 100644 --- a/engines/lastexpress/entities/entity_intern.h +++ b/engines/lastexpress/entities/entity_intern.h @@ -25,238 +25,6 @@ namespace LastExpress { -////////////////////////////////////////////////////////////////////////// -// Setup -////////////////////////////////////////////////////////////////////////// - -#define IMPLEMENT_SETUP(class, callback_class, name, index) \ -void class::setup_##name() { \ - BEGIN_SETUP(callback_class, name, index, EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::setup_" #name "()"); \ - END_SETUP() \ -} - -#define BEGIN_SETUP(class, name, index, type) \ - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); \ - _data->setCurrentCallback(index); \ - _data->resetCurrentParameters(); - -#define END_SETUP() \ - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - - -////////////////////////////////////////////////////////////////////////// -// Implementation -////////////////////////////////////////////////////////////////////////// - -// Expose parameters and check validity -#define EXPOSE_PARAMS(type) \ - type *params = (type *)_data->getCurrentParameters(); \ - if (!params) \ - error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ - - -// function signature without setup (we keep the index for consistency but never use it) -#define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ - void class::name(const SavePoint &savepoint) { \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(index=" #index ")"); - -// simple setup with no parameters -#define IMPLEMENT_FUNCTION(index, class, name) \ - IMPLEMENT_SETUP(class, class, name, index) \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "() - action: %s", ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_END } - -// nullfunction call -#define IMPLEMENT_NULL_FUNCTION(index, class) \ - IMPLEMENT_SETUP(class, Entity, nullfunction, index) - -// setup with one uint parameter -#define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ - void class::setup_##name(paramType param1) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = (unsigned int)param1; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d) - action: %s", params->param1, ACTION_NAME(savepoint.action)); - -// setup with two uint parameters -#define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ - void class::setup_##name(paramType1 param1, paramType2 param2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d) - action: %s", params->param1, params->param2, ACTION_NAME(savepoint.action)); - -// setup with three uint parameters -#define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ - void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - params->param3 = param3; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %d) - action: %s", params->param1, params->param2, params->param3, ACTION_NAME(savepoint.action)); - -// setup with one char *parameter -#define IMPLEMENT_FUNCTION_S(index, class, name) \ - void class::setup_##name(const char *seq1) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s) - action: %s", (char *)¶ms->seq1, ACTION_NAME(savepoint.action)); - -// setup with one char *parameter and one uint -#define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ - void class::setup_##name(const char *seq1, paramType2 param4) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d) - action: %s", (char *)¶ms->seq1, params->param4, ACTION_NAME(savepoint.action)); - -// setup with one char *parameter and two uints -#define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ - void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, ACTION_NAME(savepoint.action)); - -// setup with one char *parameter and three uints -#define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ - void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIII) \ - EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq, seq, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - params->param6 = param6; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, params->param6, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ - void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %s) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_SS(index, class, name) \ - void class::setup_##name(const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ - void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - params->param7 = param7; \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s, %d) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, params->param7, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ - void class::setup_##name(paramType param1, const char *seq) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersISII) \ - EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); \ - params->param1 = (unsigned int)param1; \ - strncpy((char *)¶ms->seq, seq, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersISII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s) - action: %s", params->param1, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ - void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersISSI) \ - EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s, %s) - action: %s", params->param1, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ - void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISI) \ - EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - strncpy((char *)¶ms->seq, seq, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); - -#define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ - void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISS) \ - EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ - } \ - void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/francois.h b/engines/lastexpress/entities/francois.h index 5a4ff4b8b2..51270fa4b6 100644 --- a/engines/lastexpress/entities/francois.h +++ b/engines/lastexpress/entities/francois.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_FRANCOIS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/gendarmes.h b/engines/lastexpress/entities/gendarmes.h index d999cfc1fd..a761643531 100644 --- a/engines/lastexpress/entities/gendarmes.h +++ b/engines/lastexpress/entities/gendarmes.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_GENDARMES_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" #include "lastexpress/sound/sound.h" diff --git a/engines/lastexpress/entities/hadija.h b/engines/lastexpress/entities/hadija.h index d2495955e0..545f21ee03 100644 --- a/engines/lastexpress/entities/hadija.h +++ b/engines/lastexpress/entities/hadija.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_HADIJA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/ivo.h b/engines/lastexpress/entities/ivo.h index cd5cb7b6be..75814336e0 100644 --- a/engines/lastexpress/entities/ivo.h +++ b/engines/lastexpress/entities/ivo.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_IVO_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/kahina.h b/engines/lastexpress/entities/kahina.h index b25053e339..7479cf76f9 100644 --- a/engines/lastexpress/entities/kahina.h +++ b/engines/lastexpress/entities/kahina.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_KAHINA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/kronos.h b/engines/lastexpress/entities/kronos.h index 4c61b98620..a7693fcd46 100644 --- a/engines/lastexpress/entities/kronos.h +++ b/engines/lastexpress/entities/kronos.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_KRONOS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/mahmud.h b/engines/lastexpress/entities/mahmud.h index 5feb95cba5..685100f078 100644 --- a/engines/lastexpress/entities/mahmud.h +++ b/engines/lastexpress/entities/mahmud.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_MAHMUD_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/max.h b/engines/lastexpress/entities/max.h index 17b58475aa..acd8235e89 100644 --- a/engines/lastexpress/entities/max.h +++ b/engines/lastexpress/entities/max.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_MAX_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/mertens.h b/engines/lastexpress/entities/mertens.h index 55c2a76140..4cc58fd4ba 100644 --- a/engines/lastexpress/entities/mertens.h +++ b/engines/lastexpress/entities/mertens.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_MERTENS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/milos.h b/engines/lastexpress/entities/milos.h index d58d717f8a..e8f95dc5ff 100644 --- a/engines/lastexpress/entities/milos.h +++ b/engines/lastexpress/entities/milos.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_MILOS_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/mmeboutarel.h b/engines/lastexpress/entities/mmeboutarel.h index 772451ba15..0f6e6349fe 100644 --- a/engines/lastexpress/entities/mmeboutarel.h +++ b/engines/lastexpress/entities/mmeboutarel.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_MMEBOUTAREL_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/pascale.h b/engines/lastexpress/entities/pascale.h index 333ebcae3e..eaf0f3ba0c 100644 --- a/engines/lastexpress/entities/pascale.h +++ b/engines/lastexpress/entities/pascale.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_PASCALE_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/rebecca.h b/engines/lastexpress/entities/rebecca.h index e91ee30d4d..885632f884 100644 --- a/engines/lastexpress/entities/rebecca.h +++ b/engines/lastexpress/entities/rebecca.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_REBECCA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/salko.h b/engines/lastexpress/entities/salko.h index 6308211053..6ca73e39f6 100644 --- a/engines/lastexpress/entities/salko.h +++ b/engines/lastexpress/entities/salko.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_SALKO_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/servers0.h b/engines/lastexpress/entities/servers0.h index 2e9165a410..4c35637d65 100644 --- a/engines/lastexpress/entities/servers0.h +++ b/engines/lastexpress/entities/servers0.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_SERVERS0_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/servers1.h b/engines/lastexpress/entities/servers1.h index 13b30696f0..c8f667ec5c 100644 --- a/engines/lastexpress/entities/servers1.h +++ b/engines/lastexpress/entities/servers1.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_SERVERS1_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/sophie.h b/engines/lastexpress/entities/sophie.h index 47cfa8065c..188788bb9b 100644 --- a/engines/lastexpress/entities/sophie.h +++ b/engines/lastexpress/entities/sophie.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_SOPHIE_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/tables.h b/engines/lastexpress/entities/tables.h index 7fcfc0499e..c213aac978 100644 --- a/engines/lastexpress/entities/tables.h +++ b/engines/lastexpress/entities/tables.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_TABLES_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/tatiana.h b/engines/lastexpress/entities/tatiana.h index c457d49b1e..8ec69db5e9 100644 --- a/engines/lastexpress/entities/tatiana.h +++ b/engines/lastexpress/entities/tatiana.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_TATIANA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/train.h b/engines/lastexpress/entities/train.h index ea9e1d7a07..4b8bc10c1a 100644 --- a/engines/lastexpress/entities/train.h +++ b/engines/lastexpress/entities/train.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_TRAIN_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/vassili.h b/engines/lastexpress/entities/vassili.h index 843a065174..d006770f7b 100644 --- a/engines/lastexpress/entities/vassili.h +++ b/engines/lastexpress/entities/vassili.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_VASSILI_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/verges.h b/engines/lastexpress/entities/verges.h index 17a3c8ac40..82381043d3 100644 --- a/engines/lastexpress/entities/verges.h +++ b/engines/lastexpress/entities/verges.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_VERGES_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/vesna.h b/engines/lastexpress/entities/vesna.h index a09664096d..025d45882e 100644 --- a/engines/lastexpress/entities/vesna.h +++ b/engines/lastexpress/entities/vesna.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_VESNA_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/yasmin.h b/engines/lastexpress/entities/yasmin.h index e943a8b158..b1413f5c2f 100644 --- a/engines/lastexpress/entities/yasmin.h +++ b/engines/lastexpress/entities/yasmin.h @@ -24,7 +24,6 @@ #define LASTEXPRESS_YASMIN_H #include "lastexpress/entities/entity.h" -#include "lastexpress/entities/entity_intern.h" namespace LastExpress { -- cgit v1.2.3 From 2d6f7992351c9737f71964ad64c307fa6d1543cf Mon Sep 17 00:00:00 2001 From: Julien Date: Wed, 25 Jul 2012 21:55:18 -0400 Subject: LASTEXPRESS: Cleanup unused arguments from BEGIN_SETUP macro --- engines/lastexpress/entities/entity.h | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 634e4000b3..6a32fb6de0 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -111,14 +111,14 @@ struct SavePoint; // Setup ////////////////////////////////////////////////////////////////////////// -#define IMPLEMENT_SETUP(class, callback_class, name, index) \ +#define IMPLEMENT_SETUP(class, name, index) \ void class::setup_##name() { \ - BEGIN_SETUP(callback_class, name, index, EntityData::EntityParametersIIII) \ + BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ debugC(6, kLastExpressDebugLogic, "Entity: " #class "::setup_" #name "()"); \ END_SETUP() \ } -#define BEGIN_SETUP(class, name, index, type) \ +#define BEGIN_SETUP(index, type) \ _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); \ _data->setCurrentCallback(index); \ _data->resetCurrentParameters(); @@ -145,7 +145,7 @@ void class::setup_##name() { \ // simple setup with no parameters #define IMPLEMENT_FUNCTION(index, class, name) \ - IMPLEMENT_SETUP(class, class, name, index) \ + IMPLEMENT_SETUP(class, name, index) \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "() - action: %s", ACTION_NAME(savepoint.action)); @@ -154,12 +154,12 @@ void class::setup_##name() { \ // nullfunction call #define IMPLEMENT_NULL_FUNCTION(index, class) \ - IMPLEMENT_SETUP(class, Entity, nullfunction, index) + IMPLEMENT_SETUP(class, nullfunction, index) // setup with one uint parameter #define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ void class::setup_##name(paramType param1) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ params->param1 = (unsigned int)param1; \ END_SETUP() \ @@ -171,7 +171,7 @@ void class::setup_##name() { \ // setup with two uint parameters #define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ params->param1 = param1; \ params->param2 = param2; \ @@ -184,7 +184,7 @@ void class::setup_##name() { \ // setup with three uint parameters #define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIIII) \ + BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ params->param1 = param1; \ params->param2 = param2; \ @@ -198,7 +198,7 @@ void class::setup_##name() { \ // setup with one char *parameter #define IMPLEMENT_FUNCTION_S(index, class, name) \ void class::setup_##name(const char *seq1) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ END_SETUP() \ @@ -210,7 +210,7 @@ void class::setup_##name() { \ // setup with one char *parameter and one uint #define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ void class::setup_##name(const char *seq1, paramType2 param4) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ params->param4 = param4; \ @@ -223,7 +223,7 @@ void class::setup_##name() { \ // setup with one char *parameter and two uints #define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ params->param4 = param4; \ @@ -237,7 +237,7 @@ void class::setup_##name() { \ // setup with one char *parameter and three uints #define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIII) \ + BEGIN_SETUP(index, EntityData::EntityParametersSIII) \ EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq, seq, 12); \ params->param4 = param4; \ @@ -251,7 +251,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSIIS) \ + BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ params->param4 = param4; \ @@ -265,7 +265,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_SS(index, class, name) \ void class::setup_##name(const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ + BEGIN_SETUP(index, EntityData::EntityParametersSSII) \ EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ strncpy((char *)¶ms->seq2, seq2, 12); \ @@ -277,7 +277,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersSSII) \ + BEGIN_SETUP(index, EntityData::EntityParametersSSII) \ EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ strncpy((char *)¶ms->seq1, seq1, 12); \ strncpy((char *)¶ms->seq2, seq2, 12); \ @@ -290,7 +290,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersISII) \ + BEGIN_SETUP(index, EntityData::EntityParametersISII) \ EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); \ params->param1 = (unsigned int)param1; \ strncpy((char *)¶ms->seq, seq, 12); \ @@ -302,7 +302,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersISSI) \ + BEGIN_SETUP(index, EntityData::EntityParametersISSI) \ EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); \ params->param1 = param1; \ strncpy((char *)¶ms->seq1, seq1, 12); \ @@ -315,7 +315,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISI) \ + BEGIN_SETUP(index, EntityData::EntityParametersIISI) \ EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); \ params->param1 = param1; \ params->param2 = param2; \ @@ -328,7 +328,7 @@ void class::setup_##name() { \ #define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(class, name, index, EntityData::EntityParametersIISS) \ + BEGIN_SETUP(index, EntityData::EntityParametersIISS) \ EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); \ params->param1 = param1; \ params->param2 = param2; \ -- cgit v1.2.3 From b4b4a7d127194cf29fdfcf5ee7b41b875d26b37e Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 26 Jul 2012 16:26:35 -0400 Subject: LASTEXPRESS: Replace setup macros by functions --- engines/lastexpress/entities/entity.cpp | 40 ++++ engines/lastexpress/entities/entity.h | 375 +++++++++++++++++++++----------- 2 files changed, 285 insertions(+), 130 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index a9ceaa16a9..8595978390 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -595,6 +595,46 @@ void Entity::callbackAction() { getSavePoints()->call(_entityIndex, _entityIndex, kActionCallback); } +////////////////////////////////////////////////////////////////////////// +// Setup functions +////////////////////////////////////////////////////////////////////////// +void Entity::setup(const char *name, uint index) { + debugC(6, kLastExpressDebugLogic, "Entity: %s()", name); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupS(const char *name, uint index, const char *seq1) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s)", name, seq1); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSS(const char *name, uint index, const char *seq1, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %s)", name, seq1, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + strncpy((char *)¶ms->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 6a32fb6de0..18039e9432 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -107,26 +107,6 @@ struct SavePoint; getEntities()->resetState(entity); \ ((class *)getEntities()->get(entity))->function(); -////////////////////////////////////////////////////////////////////////// -// Setup -////////////////////////////////////////////////////////////////////////// - -#define IMPLEMENT_SETUP(class, name, index) \ -void class::setup_##name() { \ - BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::setup_" #name "()"); \ - END_SETUP() \ -} - -#define BEGIN_SETUP(index, type) \ - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); \ - _data->setCurrentCallback(index); \ - _data->resetCurrentParameters(); - -#define END_SETUP() \ - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - - ////////////////////////////////////////////////////////////////////////// // Implementation ////////////////////////////////////////////////////////////////////////// @@ -137,7 +117,6 @@ void class::setup_##name() { \ if (!params) \ error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ - // function signature without setup (we keep the index for consistency but never use it) #define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ void class::name(const SavePoint &savepoint) { \ @@ -145,7 +124,9 @@ void class::setup_##name() { \ // simple setup with no parameters #define IMPLEMENT_FUNCTION(index, class, name) \ - IMPLEMENT_SETUP(class, name, index) \ + void class::setup_##name() { \ + Entity::setup(#class "::setup_" #name, index); \ + } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "() - action: %s", ACTION_NAME(savepoint.action)); @@ -154,191 +135,128 @@ void class::setup_##name() { \ // nullfunction call #define IMPLEMENT_NULL_FUNCTION(index, class) \ - IMPLEMENT_SETUP(class, nullfunction, index) + void class::setup_nullfunction() { \ + Entity::setup(#class "::setup_nullfunction", index); \ + } // setup with one uint parameter #define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ void class::setup_##name(paramType param1) { \ - BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = (unsigned int)param1; \ - END_SETUP() \ + Entity::setupI(#class "::setup_" #name, index, param1); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d) - action: %s", params->param1, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d) - action: %s", params->param1, ACTION_NAME(savepoint.action)); // setup with two uint parameters #define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2) { \ - BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - END_SETUP() \ + Entity::setupII(#class "::setup_" #name, index, param1, param2); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d) - action: %s", params->param1, params->param2, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d) - action: %s", params->param1, params->param2, ACTION_NAME(savepoint.action)); // setup with three uint parameters #define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ - BEGIN_SETUP(index, EntityData::EntityParametersIIII) \ - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - params->param3 = param3; \ - END_SETUP() \ + Entity::setupIII(#class "::setup_" #name, index, param1, param2, param3); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %d) - action: %s", params->param1, params->param2, params->param3, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %d) - action: %s", params->param1, params->param2, params->param3, ACTION_NAME(savepoint.action)); // setup with one char *parameter #define IMPLEMENT_FUNCTION_S(index, class, name) \ void class::setup_##name(const char *seq1) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - END_SETUP() \ + Entity::setupS(#class "::setup_" #name, index, seq1); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s) - action: %s", (char *)¶ms->seq1, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s) - action: %s", (char *)¶ms->seq1, ACTION_NAME(savepoint.action)); // setup with one char *parameter and one uint #define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ void class::setup_##name(const char *seq1, paramType2 param4) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - END_SETUP() \ + Entity::setupSI(#class "::setup_" #name, index, seq1, param4); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d) - action: %s", (char *)¶ms->seq1, params->param4, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d) - action: %s", (char *)¶ms->seq1, params->param4, ACTION_NAME(savepoint.action)); // setup with one char *parameter and two uints #define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - END_SETUP() \ + Entity::setupSII(#class "::setup_" #name, index, seq1, param4, param5); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, ACTION_NAME(savepoint.action)); // setup with one char *parameter and three uints #define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSIII) \ - EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq, seq, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - params->param6 = param6; \ - END_SETUP() \ + Entity::setupSIII(#class "::setup_" #name, index, seq, param4, param5, param6); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, params->param6, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %d) - action: %s", (char *)¶ms->seq, params->param4, params->param5, params->param6, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSIIS) \ - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - params->param4 = param4; \ - params->param5 = param5; \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ + Entity::setupSIIS(#class "::setup_" #name, index, seq1, param4, param5, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %s) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %d, %d, %s) - action: %s", (char *)¶ms->seq1, params->param4, params->param5, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_SS(index, class, name) \ void class::setup_##name(const char *seq1, const char *seq2) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSSII) \ - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ + Entity::setupSS(#class "::setup_" #name, index, seq1, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ - BEGIN_SETUP(index, EntityData::EntityParametersSSII) \ - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - params->param7 = param7; \ - END_SETUP() \ + Entity::setupSSI(#class "::setup_" #name, index, seq1, seq2, param7); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s, %d) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, params->param7, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%s, %s, %d) - action: %s", (char *)¶ms->seq1, (char *)¶ms->seq2, params->param7, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq) { \ - BEGIN_SETUP(index, EntityData::EntityParametersISII) \ - EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); \ - params->param1 = (unsigned int)param1; \ - strncpy((char *)¶ms->seq, seq, 12); \ - END_SETUP() \ + Entity::setupIS(#class "::setup_" #name, index, param1, seq); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersISII) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s) - action: %s", params->param1, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersISII) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s) - action: %s", params->param1, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(index, EntityData::EntityParametersISSI) \ - EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ + Entity::setupISS(#class "::setup_" #name, index, param1, seq1, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s, %s) - action: %s", params->param1, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %s, %s) - action: %s", params->param1, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ - BEGIN_SETUP(index, EntityData::EntityParametersIISI) \ - EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - strncpy((char *)¶ms->seq, seq, 12); \ - END_SETUP() \ + Entity::setupIIS(#class "::setup_" #name, index, param1, param2, seq); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq, ACTION_NAME(savepoint.action)); #define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ - BEGIN_SETUP(index, EntityData::EntityParametersIISS) \ - EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); \ - params->param1 = param1; \ - params->param2 = param2; \ - strncpy((char *)¶ms->seq1, seq1, 12); \ - strncpy((char *)¶ms->seq2, seq2, 12); \ - END_SETUP() \ + Entity::setupIISS(#class "::setup_" #name, index, param1, param2, seq1, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ - EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ - debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); + EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ + debugC(6, kLastExpressDebugLogic, "Entity: " #class "::" #name "(%d, %d, %s, %s) - action: %s", params->param1, params->param2, (char *)¶ms->seq1, (char *)¶ms->seq2, ACTION_NAME(savepoint.action)); ////////////////////////////////////////////////////////////////////////// @@ -1144,6 +1062,203 @@ protected: */ void callbackAction(); + ////////////////////////////////////////////////////////////////////////// + // Setup functions + ////////////////////////////////////////////////////////////////////////// + void setup(const char *name, uint index); + void setupS(const char *name, uint index, const char *seq1); + void setupSS(const char *name, uint index, const char *seq1, const char *seq2); + + template + void setupI(const char *name, uint index, T param1) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d)", name, param1); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + params->param1 = (unsigned int)param1; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupII(const char *name, uint index, T1 param1, T2 param2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d)", name, param1, param2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupIII(const char *name, uint index, T1 param1, T2 param2, T3 param3) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %d)", name, param1, param2, param3); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + params->param3 = param3; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupSI(const char *name, uint index, const char *seq1, T param4) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d)", name, seq1, param4); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + params->param4 = param4; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupSII(const char *name, uint index, const char *seq1, T1 param4, T2 param5) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d)", name, seq1, param4, param5); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + params->param4 = param4; + params->param5 = param5; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupSIII(const char *name, uint index, const char *seq, T1 param4, T2 param5, T3 param6) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d, %d)", name, seq, param4, param5, param6); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq, seq, 12); + params->param4 = param4; + params->param5 = param5; + params->param6 = param6; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupSIIS(const char *name, uint index, const char *seq1, T1 param4, T2 param5, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d, %s)", name, seq1, param4, param5, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + params->param4 = param4; + params->param5 = param5; + strncpy((char *)¶ms->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupSSI(const char *name, uint index, const char *seq1, const char *seq2, T param7) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %s, %d)", name, seq1, seq2, param7); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); + strncpy((char *)¶ms->seq1, seq1, 12); + strncpy((char *)¶ms->seq2, seq2, 12); + params->param7 = param7; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupIS(const char *name, uint index, T param1, const char *seq) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %s)", name, param1, seq); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); + params->param1 = (unsigned int)param1; + strncpy((char *)¶ms->seq, seq, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupISS(const char *name, uint index, T param1, const char *seq1, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %s, %s)", name, param1, seq1, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); + params->param1 = param1; + strncpy((char *)¶ms->seq1, seq1, 12); + strncpy((char *)¶ms->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupIIS(const char *name, uint index, T1 param1, T2 param2, const char *seq) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %s)", name, param1, param2, seq); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + strncpy((char *)¶ms->seq, seq, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + + template + void setupIISS(const char *name, uint index, T1 param1, T2 param2, const char *seq1, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %s, %s)", name, param1, param2, seq1, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + strncpy((char *)¶ms->seq1, seq1, 12); + strncpy((char *)¶ms->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); + } + ////////////////////////////////////////////////////////////////////////// // Helper functions ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 115a4d36ba673579bd683cac90828f22606f7468 Mon Sep 17 00:00:00 2001 From: Julien Date: Thu, 26 Jul 2012 17:19:58 -0400 Subject: LASTEXPRESS: Move includes to header for setup function templates --- engines/lastexpress/entities/entity.cpp | 5 +---- engines/lastexpress/entities/entity.h | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 8595978390..02822256d0 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -28,12 +28,9 @@ #include "lastexpress/game/entities.h" #include "lastexpress/game/logic.h" #include "lastexpress/game/object.h" -#include "lastexpress/game/scenes.h" -#include "lastexpress/game/state.h" #include "lastexpress/game/savegame.h" #include "lastexpress/game/savepoint.h" - -#include "lastexpress/lastexpress.h" +#include "lastexpress/game/scenes.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 18039e9432..872eae188e 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -26,7 +26,9 @@ #include "lastexpress/shared.h" #include "lastexpress/sound/sound.h" +#include "lastexpress/game/state.h" +#include "lastexpress/lastexpress.h" #include "lastexpress/helpers.h" #include "common/array.h" -- cgit v1.2.3 From 6aeda2638b9bdfbbef3b0fb89c1c776415e13c2c Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 27 Jul 2012 00:54:24 -0400 Subject: LASTEXPRESS: More include re-organization --- engines/lastexpress/entities/entity.cpp | 2 -- engines/lastexpress/entities/entity.h | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 02822256d0..0842a7a78c 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -26,10 +26,8 @@ #include "lastexpress/game/action.h" #include "lastexpress/game/entities.h" -#include "lastexpress/game/logic.h" #include "lastexpress/game/object.h" #include "lastexpress/game/savegame.h" -#include "lastexpress/game/savepoint.h" #include "lastexpress/game/scenes.h" namespace LastExpress { diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 872eae188e..e890bba0b5 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -25,9 +25,12 @@ #include "lastexpress/shared.h" -#include "lastexpress/sound/sound.h" +#include "lastexpress/game/logic.h" +#include "lastexpress/game/savepoint.h" #include "lastexpress/game/state.h" +#include "lastexpress/sound/sound.h" + #include "lastexpress/lastexpress.h" #include "lastexpress/helpers.h" @@ -864,9 +867,6 @@ private: class Entity : Common::Serializable { public: - - typedef Common::Functor1 Callback; - Entity(LastExpressEngine *engine, EntityIndex index); virtual ~Entity(); @@ -900,6 +900,7 @@ public: protected: LastExpressEngine *_engine; + typedef Common::Functor1 Callback; EntityIndex _entityIndex; EntityData *_data; -- cgit v1.2.3 From e91001a1642ee8ba8b834f1908247c12d194e0b2 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 27 Jul 2012 13:36:21 -0400 Subject: LASTEXPRESS: Remove templated resetCurrentParameters() function --- engines/lastexpress/entities/entity.cpp | 6 ++-- engines/lastexpress/entities/entity.h | 59 ++++++++++++++++----------------- 2 files changed, 32 insertions(+), 33 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 0842a7a78c..aff9445326 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -598,7 +598,7 @@ void Entity::setup(const char *name, uint index) { _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIIII); _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); } @@ -608,7 +608,7 @@ void Entity::setupS(const char *name, uint index, const char *seq1) { _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSIIS); EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); @@ -621,7 +621,7 @@ void Entity::setupSS(const char *name, uint index, const char *seq1, const char _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSSII); EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index e890bba0b5..e2514a6146 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -122,6 +122,13 @@ struct SavePoint; if (!params) \ error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ +#define RESET_PARAMS(data, type) do { \ + EntityData::EntityCallParameters *callParameters = data->getCurrentCallParameters(); \ + callParameters->clear(); \ + for (int i = 0; i < 4; i++) \ + callParameters->parameters[i] = new type(); \ +} while (false) + // function signature without setup (we keep the index for consistency but never use it) #define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ void class::name(const SavePoint &savepoint) { \ @@ -835,29 +842,21 @@ public: EntityData() {} - template - void resetCurrentParameters() { - EntityCallParameters *params = &_parameters[_data.currentCall]; - params->clear(); - - for (int i = 0; i < 4; i++) - params->parameters[i] = new T(); - } - - EntityCallData *getCallData() { return &_data; } + EntityCallData *getCallData() { return &_data; } - EntityParameters *getParameters(uint callback, byte index) const; - EntityParameters *getCurrentParameters(byte index = 0) { return getParameters(_data.currentCall, index); } + EntityParameters *getParameters(uint callback, byte index) const; + EntityParameters *getCurrentParameters(byte index = 0) { return getParameters(_data.currentCall, index); } + EntityCallParameters *getCurrentCallParameters() { return &_parameters[_data.currentCall]; } - int getCallback(uint callback) const; - int getCurrentCallback() { return getCallback(_data.currentCall); } - void setCallback(uint callback, byte index); - void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); } + int getCallback(uint callback) const; + int getCurrentCallback() { return getCallback(_data.currentCall); } + void setCallback(uint callback, byte index); + void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); } - void updateParameters(uint32 index) const; + void updateParameters(uint32 index) const; // Serializable - void saveLoadWithSerializer(Common::Serializer &ser); + void saveLoadWithSerializer(Common::Serializer &ser); private: @@ -1078,7 +1077,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIIII); EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); params->param1 = (unsigned int)param1; @@ -1092,7 +1091,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIIII); EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); params->param1 = param1; @@ -1107,7 +1106,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIIII); EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); params->param1 = param1; @@ -1123,7 +1122,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSIIS); EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); @@ -1138,7 +1137,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSIIS); EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); @@ -1154,7 +1153,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSIII); EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq, seq, 12); @@ -1171,7 +1170,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSIIS); EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); @@ -1188,7 +1187,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersSSII); EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); @@ -1204,7 +1203,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersISII); EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); params->param1 = (unsigned int)param1; @@ -1219,7 +1218,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersISSI); EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); params->param1 = param1; @@ -1235,7 +1234,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIISI); EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); params->param1 = param1; @@ -1251,7 +1250,7 @@ protected: _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - _data->resetCurrentParameters(); + RESET_PARAMS(_data, EntityData::EntityParametersIISS); EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); params->param1 = param1; -- cgit v1.2.3 From 839ad1303f67b83f4383fb448463363e1e9f64fc Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 27 Jul 2012 19:58:51 -0400 Subject: LASTEXPRESS: Fix some formatting issues --- engines/lastexpress/entities/entity.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index e2514a6146..0b1db137a6 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -275,7 +275,7 @@ struct SavePoint; class EntityData : Common::Serializable { public: - struct EntityParameters : Common::Serializable{ + struct EntityParameters : Common::Serializable { virtual ~EntityParameters() {} virtual Common::String toString() = 0; @@ -1079,7 +1079,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersIIII); - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); params->param1 = (unsigned int)param1; _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); @@ -1093,7 +1093,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersIIII); - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); params->param1 = param1; params->param2 = param2; @@ -1108,7 +1108,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersIIII); - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII*)_data->getCurrentParameters(); + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); params->param1 = param1; params->param2 = param2; params->param3 = param3; @@ -1124,7 +1124,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); params->param4 = param4; @@ -1139,7 +1139,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); params->param4 = param4; params->param5 = param5; @@ -1155,7 +1155,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersSIII); - EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII*)_data->getCurrentParameters(); + EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII *)_data->getCurrentParameters(); strncpy((char *)¶ms->seq, seq, 12); params->param4 = param4; params->param5 = param5; @@ -1172,7 +1172,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); params->param4 = param4; params->param5 = param5; @@ -1189,7 +1189,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersSSII); - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII *)_data->getCurrentParameters(); strncpy((char *)¶ms->seq1, seq1, 12); strncpy((char *)¶ms->seq2, seq2, 12); params->param7 = param7; @@ -1205,7 +1205,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersISII); - EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII*)_data->getCurrentParameters(); + EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII *)_data->getCurrentParameters(); params->param1 = (unsigned int)param1; strncpy((char *)¶ms->seq, seq, 12); @@ -1220,7 +1220,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersISSI); - EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI*)_data->getCurrentParameters(); + EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI *)_data->getCurrentParameters(); params->param1 = param1; strncpy((char *)¶ms->seq1, seq1, 12); strncpy((char *)¶ms->seq2, seq2, 12); @@ -1236,7 +1236,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersIISI); - EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI*)_data->getCurrentParameters(); + EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI *)_data->getCurrentParameters(); params->param1 = param1; params->param2 = param2; strncpy((char *)¶ms->seq, seq, 12); @@ -1252,7 +1252,7 @@ protected: _data->setCurrentCallback(index); RESET_PARAMS(_data, EntityData::EntityParametersIISS); - EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS*)_data->getCurrentParameters(); + EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS *)_data->getCurrentParameters(); params->param1 = param1; params->param2 = param2; strncpy((char *)¶ms->seq1, seq1, 12); -- cgit v1.2.3 From 42c9b405f1d7a6e4e3a117579a126f290c6d895a Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 27 Jul 2012 23:23:17 -0400 Subject: LASTEXPRESS: Untemplatize setup functions --- engines/lastexpress/entities/entity.cpp | 190 ++++++++++++++++++++++++- engines/lastexpress/entities/entity.h | 242 +++++--------------------------- 2 files changed, 217 insertions(+), 215 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index aff9445326..4b1fda9c12 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -598,7 +598,49 @@ void Entity::setup(const char *name, uint index) { _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIIII); + _data->resetCurrentParameters(); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupI(const char *name, uint index, uint param1) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u)", name, param1); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); + params->param1 = (unsigned int)param1; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupII(const char *name, uint index, uint param1, uint param2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %u)", name, param1, param2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupIII(const char *name, uint index, uint param1, uint param2, uint param3) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %u, %u)", name, param1, param2, param3); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + params->param3 = param3; _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); } @@ -608,10 +650,10 @@ void Entity::setupS(const char *name, uint index, const char *seq1) { _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSIIS); + _data->resetCurrentParameters(); EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS*)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); + strncpy(params->seq1, seq1, 12); _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); } @@ -621,11 +663,147 @@ void Entity::setupSS(const char *name, uint index, const char *seq1, const char _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSSII); + _data->resetCurrentParameters(); EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII*)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); - strncpy((char *)¶ms->seq2, seq2, 12); + strncpy(params->seq1, seq1, 12); + strncpy(params->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSI(const char *name, uint index, const char *seq1, uint param4) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %u)", name, seq1, param4); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); + strncpy(params->seq1, seq1, 12); + params->param4 = param4; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSII(const char *name, uint index, const char *seq1, uint param4, uint param5) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %u, %u)", name, seq1, param4, param5); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); + strncpy(params->seq1, seq1, 12); + params->param4 = param4; + params->param5 = param5; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSIII(const char *name, uint index, const char *seq, uint param4, uint param5, uint param6) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %u, %u, %u)", name, seq, param4, param5, param6); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII *)_data->getCurrentParameters(); + strncpy(params->seq, seq, 12); + params->param4 = param4; + params->param5 = param5; + params->param6 = param6; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSIIS(const char *name, uint index, const char *seq1, uint param4, uint param5, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %u, %u, %s)", name, seq1, param4, param5, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); + strncpy(params->seq1, seq1, 12); + params->param4 = param4; + params->param5 = param5; + strncpy(params->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupSSI(const char *name, uint index, const char *seq1, const char *seq2, uint param7) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %s, %u)", name, seq1, seq2, param7); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII *)_data->getCurrentParameters(); + strncpy(params->seq1, seq1, 12); + strncpy(params->seq2, seq2, 12); + params->param7 = param7; + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupIS(const char *name, uint index, uint param1, const char *seq) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %s)", name, param1, seq); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII *)_data->getCurrentParameters(); + params->param1 = (unsigned int)param1; + strncpy(params->seq, seq, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupISS(const char *name, uint index, uint param1, const char *seq1, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %s, %s)", name, param1, seq1, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI *)_data->getCurrentParameters(); + params->param1 = param1; + strncpy(params->seq1, seq1, 12); + strncpy(params->seq2, seq2, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupIIS(const char *name, uint index, uint param1, uint param2, const char *seq) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %u, %s)", name, param1, param2, seq); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI *)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + strncpy(params->seq, seq, 12); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); +} + +void Entity::setupIISS(const char *name, uint index, uint param1, uint param2, const char *seq1, const char *seq2) { + debugC(6, kLastExpressDebugLogic, "Entity: %s(%u, %u, %s, %s)", name, param1, param2, seq1, seq2); + + _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); + _data->setCurrentCallback(index); + _data->resetCurrentParameters(); + + EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS *)_data->getCurrentParameters(); + params->param1 = param1; + params->param2 = param2; + strncpy(params->seq1, seq1, 12); + strncpy(params->seq2, seq2, 12); _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); } diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 0b1db137a6..3601f34f6f 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -122,13 +122,6 @@ struct SavePoint; if (!params) \ error("[EXPOSE_PARAMS] Trying to call an entity function with invalid parameters"); \ -#define RESET_PARAMS(data, type) do { \ - EntityData::EntityCallParameters *callParameters = data->getCurrentCallParameters(); \ - callParameters->clear(); \ - for (int i = 0; i < 4; i++) \ - callParameters->parameters[i] = new type(); \ -} while (false) - // function signature without setup (we keep the index for consistency but never use it) #define IMPLEMENT_FUNCTION_NOSETUP(index, class, name) \ void class::name(const SavePoint &savepoint) { \ @@ -154,7 +147,7 @@ struct SavePoint; // setup with one uint parameter #define IMPLEMENT_FUNCTION_I(index, class, name, paramType) \ void class::setup_##name(paramType param1) { \ - Entity::setupI(#class "::setup_" #name, index, param1); \ + Entity::setupI(#class "::setup_" #name, index, param1); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ @@ -163,7 +156,7 @@ struct SavePoint; // setup with two uint parameters #define IMPLEMENT_FUNCTION_II(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2) { \ - Entity::setupII(#class "::setup_" #name, index, param1, param2); \ + Entity::setupII(#class "::setup_" #name, index, param1, param2); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ @@ -172,7 +165,7 @@ struct SavePoint; // setup with three uint parameters #define IMPLEMENT_FUNCTION_III(index, class, name, paramType1, paramType2, paramType3) \ void class::setup_##name(paramType1 param1, paramType2 param2, paramType3 param3) { \ - Entity::setupIII(#class "::setup_" #name, index, param1, param2, param3); \ + Entity::setupIII(#class "::setup_" #name, index, param1, param2, param3); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIIII) \ @@ -190,7 +183,7 @@ struct SavePoint; // setup with one char *parameter and one uint #define IMPLEMENT_FUNCTION_SI(index, class, name, paramType2) \ void class::setup_##name(const char *seq1, paramType2 param4) { \ - Entity::setupSI(#class "::setup_" #name, index, seq1, param4); \ + Entity::setupSI(#class "::setup_" #name, index, seq1, param4); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ @@ -199,7 +192,7 @@ struct SavePoint; // setup with one char *parameter and two uints #define IMPLEMENT_FUNCTION_SII(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5) { \ - Entity::setupSII(#class "::setup_" #name, index, seq1, param4, param5); \ + Entity::setupSII(#class "::setup_" #name, index, seq1, param4, param5); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ @@ -208,7 +201,7 @@ struct SavePoint; // setup with one char *parameter and three uints #define IMPLEMENT_FUNCTION_SIII(index, class, name, paramType2, paramType3, paramType4) \ void class::setup_##name(const char *seq, paramType2 param4, paramType3 param5, paramType4 param6) { \ - Entity::setupSIII(#class "::setup_" #name, index, seq, param4, param5, param6); \ + Entity::setupSIII(#class "::setup_" #name, index, seq, param4, param5, param6); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersSIII) \ @@ -216,7 +209,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_SIIS(index, class, name, paramType2, paramType3) \ void class::setup_##name(const char *seq1, paramType2 param4, paramType3 param5, const char *seq2) { \ - Entity::setupSIIS(#class "::setup_" #name, index, seq1, param4, param5, seq2); \ + Entity::setupSIIS(#class "::setup_" #name, index, seq1, param4, param5, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersSIIS) \ @@ -232,7 +225,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_SSI(index, class, name, paramType3) \ void class::setup_##name(const char *seq1, const char *seq2, paramType3 param7) { \ - Entity::setupSSI(#class "::setup_" #name, index, seq1, seq2, param7); \ + Entity::setupSSI(#class "::setup_" #name, index, seq1, seq2, param7); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersSSII) \ @@ -240,7 +233,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_IS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq) { \ - Entity::setupIS(#class "::setup_" #name, index, param1, seq); \ + Entity::setupIS(#class "::setup_" #name, index, param1, seq); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersISII) \ @@ -248,7 +241,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_ISS(index, class, name, paramType) \ void class::setup_##name(paramType param1, const char *seq1, const char *seq2) { \ - Entity::setupISS(#class "::setup_" #name, index, param1, seq1, seq2); \ + Entity::setupISS(#class "::setup_" #name, index, param1, seq1, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersISSI) \ @@ -256,7 +249,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_IIS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq) { \ - Entity::setupIIS(#class "::setup_" #name, index, param1, param2, seq); \ + Entity::setupIIS(#class "::setup_" #name, index, param1, param2, seq); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIISI) \ @@ -264,7 +257,7 @@ struct SavePoint; #define IMPLEMENT_FUNCTION_IISS(index, class, name, paramType1, paramType2) \ void class::setup_##name(paramType1 param1, paramType2 param2, const char *seq1, const char *seq2) { \ - Entity::setupIISS(#class "::setup_" #name, index, param1, param2, seq1, seq2); \ + Entity::setupIISS(#class "::setup_" #name, index, param1, param2, seq1, seq2); \ } \ void class::name(const SavePoint &savepoint) { \ EXPOSE_PARAMS(EntityData::EntityParametersIISS) \ @@ -842,6 +835,15 @@ public: EntityData() {} + template + void resetCurrentParameters() { + EntityCallParameters *params = &_parameters[_data.currentCall]; + params->clear(); + + for (int i = 0; i < 4; i++) + params->parameters[i] = new T(); + } + EntityCallData *getCallData() { return &_data; } EntityParameters *getParameters(uint callback, byte index) const; @@ -1068,198 +1070,20 @@ protected: // Setup functions ////////////////////////////////////////////////////////////////////////// void setup(const char *name, uint index); + void setupI(const char *name, uint index, uint param1); + void setupII(const char *name, uint index, uint param1, uint param2); + void setupIII(const char *name, uint index, uint param1, uint param2, uint param3); void setupS(const char *name, uint index, const char *seq1); void setupSS(const char *name, uint index, const char *seq1, const char *seq2); - - template - void setupI(const char *name, uint index, T param1) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d)", name, param1); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIIII); - - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); - params->param1 = (unsigned int)param1; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupII(const char *name, uint index, T1 param1, T2 param2) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d)", name, param1, param2); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIIII); - - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); - params->param1 = param1; - params->param2 = param2; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupIII(const char *name, uint index, T1 param1, T2 param2, T3 param3) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %d)", name, param1, param2, param3); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIIII); - - EntityData::EntityParametersIIII *params = (EntityData::EntityParametersIIII *)_data->getCurrentParameters(); - params->param1 = param1; - params->param2 = param2; - params->param3 = param3; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupSI(const char *name, uint index, const char *seq1, T param4) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d)", name, seq1, param4); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); - params->param4 = param4; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupSII(const char *name, uint index, const char *seq1, T1 param4, T2 param5) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d)", name, seq1, param4, param5); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); - params->param4 = param4; - params->param5 = param5; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupSIII(const char *name, uint index, const char *seq, T1 param4, T2 param5, T3 param6) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d, %d)", name, seq, param4, param5, param6); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSIII); - - EntityData::EntityParametersSIII *params = (EntityData::EntityParametersSIII *)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq, seq, 12); - params->param4 = param4; - params->param5 = param5; - params->param6 = param6; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupSIIS(const char *name, uint index, const char *seq1, T1 param4, T2 param5, const char *seq2) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %d, %d, %s)", name, seq1, param4, param5, seq2); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSIIS); - - EntityData::EntityParametersSIIS *params = (EntityData::EntityParametersSIIS *)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); - params->param4 = param4; - params->param5 = param5; - strncpy((char *)¶ms->seq2, seq2, 12); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupSSI(const char *name, uint index, const char *seq1, const char *seq2, T param7) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%s, %s, %d)", name, seq1, seq2, param7); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersSSII); - - EntityData::EntityParametersSSII *params = (EntityData::EntityParametersSSII *)_data->getCurrentParameters(); - strncpy((char *)¶ms->seq1, seq1, 12); - strncpy((char *)¶ms->seq2, seq2, 12); - params->param7 = param7; - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupIS(const char *name, uint index, T param1, const char *seq) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %s)", name, param1, seq); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersISII); - - EntityData::EntityParametersISII *params = (EntityData::EntityParametersISII *)_data->getCurrentParameters(); - params->param1 = (unsigned int)param1; - strncpy((char *)¶ms->seq, seq, 12); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupISS(const char *name, uint index, T param1, const char *seq1, const char *seq2) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %s, %s)", name, param1, seq1, seq2); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersISSI); - - EntityData::EntityParametersISSI *params = (EntityData::EntityParametersISSI *)_data->getCurrentParameters(); - params->param1 = param1; - strncpy((char *)¶ms->seq1, seq1, 12); - strncpy((char *)¶ms->seq2, seq2, 12); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupIIS(const char *name, uint index, T1 param1, T2 param2, const char *seq) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %s)", name, param1, param2, seq); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIISI); - - EntityData::EntityParametersIISI *params = (EntityData::EntityParametersIISI *)_data->getCurrentParameters(); - params->param1 = param1; - params->param2 = param2; - strncpy((char *)¶ms->seq, seq, 12); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } - - template - void setupIISS(const char *name, uint index, T1 param1, T2 param2, const char *seq1, const char *seq2) { - debugC(6, kLastExpressDebugLogic, "Entity: %s(%d, %d, %s, %s)", name, param1, param2, seq1, seq2); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->setCallback(_entityIndex, _callbacks[index]); - _data->setCurrentCallback(index); - RESET_PARAMS(_data, EntityData::EntityParametersIISS); - - EntityData::EntityParametersIISS *params = (EntityData::EntityParametersIISS *)_data->getCurrentParameters(); - params->param1 = param1; - params->param2 = param2; - strncpy((char *)¶ms->seq1, seq1, 12); - strncpy((char *)¶ms->seq2, seq2, 12); - - _engine->getGameLogic()->getGameState()->getGameSavePoints()->call(_entityIndex, _entityIndex, kActionDefault); - } + void setupSI(const char *name, uint index, const char *seq1, uint param4); + void setupSII(const char *name, uint index, const char *seq1, uint param4, uint param5); + void setupSIII(const char *name, uint index, const char *seq, uint param4, uint param5, uint param6); + void setupSIIS(const char *name, uint index, const char *seq1, uint param4, uint param5, const char *seq2); + void setupSSI(const char *name, uint index, const char *seq1, const char *seq2, uint param7); + void setupIS(const char *name, uint index, uint param1, const char *seq); + void setupISS(const char *name, uint index, uint param1, const char *seq1, const char *seq2); + void setupIIS(const char *name, uint index, uint param1, uint param2, const char *seq); + void setupIISS(const char *name, uint index, uint param1, uint param2, const char *seq1, const char *seq2); ////////////////////////////////////////////////////////////////////////// // Helper functions -- cgit v1.2.3 From 7f05e1413c8b7b3913f64ddb29622dcdf40b2c65 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Wed, 1 Aug 2012 02:58:55 -0400 Subject: LASTEXPRESS: Remove use of skip from savegame functions when loading We cannot accurately skip over compressed data as it is not know before decoding how much data will be used --- engines/lastexpress/entities/entity.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 4b1fda9c12..2deca291f6 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -88,7 +88,13 @@ void EntityData::EntityCallData::saveLoadWithSerializer(Common::Serializer &s) { syncString(s, sequenceNameCopy, 13); // Skip pointers to frame & sequences - s.skip(5 * 4); + // (we are using a compressed stream, so we cannot seek on load) + if (s.isLoading()) { + byte empty[5 * 4]; + s.syncBytes(empty, 5 * 4); + } else { + s.skip(5 * 4); + } } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6f18ec2104b5cf02ebeb0c928a5c2507c99d820d Mon Sep 17 00:00:00 2001 From: Littleboy Date: Sun, 19 Aug 2012 19:58:30 -0400 Subject: LASTEXPRESS: Identify some Abbot Chapter 3 functions --- engines/lastexpress/entities/abbot.cpp | 24 ++++++++++++------------ engines/lastexpress/entities/abbot.h | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index e0fe429520..85d0d8948b 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -58,10 +58,10 @@ Abbot::Abbot(LastExpressEngine *engine) : Entity(engine, kEntityAbbot) { ADD_CALLBACK_FUNCTION(Abbot, chapter2); ADD_CALLBACK_FUNCTION(Abbot, chapter3); ADD_CALLBACK_FUNCTION(Abbot, chapter3Handler); - ADD_CALLBACK_FUNCTION(Abbot, function19); - ADD_CALLBACK_FUNCTION(Abbot, function20); - ADD_CALLBACK_FUNCTION(Abbot, function21); - ADD_CALLBACK_FUNCTION(Abbot, function22); + ADD_CALLBACK_FUNCTION(Abbot, conversationWithBoutarel); + ADD_CALLBACK_FUNCTION(Abbot, readPaper); + ADD_CALLBACK_FUNCTION(Abbot, goToLunch); + ADD_CALLBACK_FUNCTION(Abbot, haveLunch); ADD_CALLBACK_FUNCTION(Abbot, function23); ADD_CALLBACK_FUNCTION(Abbot, function24); ADD_CALLBACK_FUNCTION(Abbot, function25); @@ -259,7 +259,7 @@ IMPLEMENT_FUNCTION(18, Abbot, chapter3Handler) getData()->entityPosition = kPosition_6470; getData()->location = kLocationInsideCompartment; - setup_function19(); + setup_conversationWithBoutarel(); break; } break; @@ -272,7 +272,7 @@ IMPLEMENT_FUNCTION(18, Abbot, chapter3Handler) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(19, Abbot, function19) +IMPLEMENT_FUNCTION(19, Abbot, conversationWithBoutarel) switch (savepoint.action) { default: break; @@ -311,21 +311,21 @@ IMPLEMENT_FUNCTION(19, Abbot, function19) case 3: getSavePoints()->push(kEntityAbbot, kEntityBoutarel, kAction122288808); - setup_function20(); + setup_readPaper(); break; } } IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(20, Abbot, function20) +IMPLEMENT_FUNCTION(20, Abbot, readPaper) switch (savepoint.action) { default: break; case kActionNone: if (getState()->time > kTime1966500 && getEntities()->isInRestaurant(kEntityBoutarel)) - setup_function21(); + setup_goToLunch(); break; case kActionDefault: @@ -335,7 +335,7 @@ IMPLEMENT_FUNCTION(20, Abbot, function20) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(21, Abbot, function21) +IMPLEMENT_FUNCTION(21, Abbot, goToLunch) switch (savepoint.action) { default: break; @@ -393,7 +393,7 @@ IMPLEMENT_FUNCTION(21, Abbot, function21) break; case 7: - setup_function22(); + setup_haveLunch(); break; } break; @@ -409,7 +409,7 @@ IMPLEMENT_FUNCTION(21, Abbot, function21) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(22, Abbot, function22) +IMPLEMENT_FUNCTION(22, Abbot, haveLunch) switch (savepoint.action) { default: break; diff --git a/engines/lastexpress/entities/abbot.h b/engines/lastexpress/entities/abbot.h index ce52bb68ce..dc3e86db54 100644 --- a/engines/lastexpress/entities/abbot.h +++ b/engines/lastexpress/entities/abbot.h @@ -156,10 +156,10 @@ public: * Handle Chapter 3 events */ DECLARE_FUNCTION(chapter3Handler) - DECLARE_FUNCTION(function19) - DECLARE_FUNCTION(function20) - DECLARE_FUNCTION(function21) - DECLARE_FUNCTION(function22) + DECLARE_FUNCTION(conversationWithBoutarel) + DECLARE_FUNCTION(readPaper) + DECLARE_FUNCTION(goToLunch) + DECLARE_FUNCTION(haveLunch) DECLARE_FUNCTION(function23) DECLARE_FUNCTION(function24) DECLARE_FUNCTION(function25) -- cgit v1.2.3 From cec57e091834567552658aacfa6561fe80e1a6f8 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 21 Aug 2012 22:49:38 -0400 Subject: LASTEXPRESS: Reduce header interdependency --- engines/lastexpress/entities/entity.cpp | 11 +++++++++-- engines/lastexpress/entities/entity.h | 5 ----- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 2deca291f6..552e1a8a82 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -26,10 +26,15 @@ #include "lastexpress/game/action.h" #include "lastexpress/game/entities.h" +#include "lastexpress/game/logic.h" #include "lastexpress/game/object.h" #include "lastexpress/game/savegame.h" +#include "lastexpress/game/savepoint.h" +#include "lastexpress/game/state.h" #include "lastexpress/game/scenes.h" +#include "lastexpress/lastexpress.h" + namespace LastExpress { ////////////////////////////////////////////////////////////////////////// @@ -49,8 +54,10 @@ void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::Strin char seqName[13]; memset(&seqName, 0, length); - if (s.isSaving()) strcpy((char *)&seqName, string.c_str()); - s.syncBytes((byte *)&seqName, length); + if (s.isSaving()) + strcpy((char *)&seqName, string.c_str()); + + s.syncBytes((byte *)&seqName, length); if (s.isLoading()) string = seqName; diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index 3601f34f6f..e5c097b50a 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -25,13 +25,8 @@ #include "lastexpress/shared.h" -#include "lastexpress/game/logic.h" -#include "lastexpress/game/savepoint.h" -#include "lastexpress/game/state.h" - #include "lastexpress/sound/sound.h" -#include "lastexpress/lastexpress.h" #include "lastexpress/helpers.h" #include "common/array.h" -- cgit v1.2.3 From 2c0033c7bad5b15c9bcccbce804e244a17a7f891 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 21 Aug 2012 23:00:29 -0400 Subject: LASTEXPRESS: Add const modifiers --- engines/lastexpress/entities/chapters.cpp | 2 +- engines/lastexpress/entities/chapters.h | 2 +- engines/lastexpress/entities/entity.cpp | 14 +++++++------- engines/lastexpress/entities/entity.h | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/chapters.cpp b/engines/lastexpress/entities/chapters.cpp index a2f3a3d871..d373432710 100644 --- a/engines/lastexpress/entities/chapters.cpp +++ b/engines/lastexpress/entities/chapters.cpp @@ -1851,7 +1851,7 @@ void Chapters::enterExitHelper(bool isEnteringStation) { callbackAction(); } -void Chapters::playSteam() { +void Chapters::playSteam() const { getSoundQueue()->resetState(); getSound()->playSteam((CityIndex)ENTITY_PARAM(0, 4)); ENTITY_PARAM(0, 2) = 0; diff --git a/engines/lastexpress/entities/chapters.h b/engines/lastexpress/entities/chapters.h index ddb3de3bea..fb52ea3ee4 100644 --- a/engines/lastexpress/entities/chapters.h +++ b/engines/lastexpress/entities/chapters.h @@ -157,7 +157,7 @@ private: bool timeCheckExitStation(TimeValue timeValue, uint ¶meter, byte callback, const char *sequence); void enterExitStation(const SavePoint &savepoint, bool isEnteringStation); void enterExitHelper(bool isEnteringStation); - void playSteam(); + void playSteam() const; }; } // End of namespace LastExpress diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 552e1a8a82..88b2ada185 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -50,7 +50,7 @@ EntityData::EntityCallData::~EntityCallData() { SAFE_DELETE(sequence3); } -void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, int length) { +void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, int length) const { char seqName[13]; memset(&seqName, 0, length); @@ -825,7 +825,7 @@ void Entity::setupIISS(const char *name, uint index, uint param1, uint param2, c // Helper functions ////////////////////////////////////////////////////////////////////////// -bool Entity::updateParameter(uint ¶meter, uint timeType, uint delta) { +bool Entity::updateParameter(uint ¶meter, uint timeType, uint delta) const { if (!parameter) parameter = (uint)(timeType + delta); @@ -837,7 +837,7 @@ bool Entity::updateParameter(uint ¶meter, uint timeType, uint delta) { return true; } -bool Entity::updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta) { +bool Entity::updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta) const { if (getState()->time <= timeValue) { if (check || !parameter) parameter = (uint)(getState()->time + delta); @@ -851,7 +851,7 @@ bool Entity::updateParameterTime(TimeValue timeValue, bool check, uint ¶mete return true; } -bool Entity::updateParameterCheck(uint ¶meter, uint timeType, uint delta) { +bool Entity::updateParameterCheck(uint ¶meter, uint timeType, uint delta) const { if (parameter && parameter >= timeType) return false; @@ -861,7 +861,7 @@ bool Entity::updateParameterCheck(uint ¶meter, uint timeType, uint delta) { return true; } -bool Entity::timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function) { +bool Entity::timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function) const { if (getState()->time > timeValue && !parameter) { parameter = 1; (*function)(); @@ -936,14 +936,14 @@ bool Entity::timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback, C return false; } -void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) { +void Entity::timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) const { if (getState()->time > timeValue && !parameter) { parameter = 1; getSavePoints()->push(entity1, entity2, action); } } -void Entity::timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex object, ObjectLocation location) { +void Entity::timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex object, ObjectLocation location) const { if (getState()->time > timeValue && !parameter) { parameter = 1; getObjects()->updateLocation2(object, location); diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index e5c097b50a..c45367c43c 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -822,7 +822,7 @@ public: * @param string The string. * @param length Length of the string. */ - void syncString(Common::Serializer &s, Common::String &string, int length); + void syncString(Common::Serializer &s, Common::String &string, int length) const; // Serializable void saveLoadWithSerializer(Common::Serializer &s); @@ -1084,18 +1084,18 @@ protected: // Helper functions ////////////////////////////////////////////////////////////////////////// - bool updateParameter(uint ¶meter, uint timeType, uint delta); - bool updateParameterCheck(uint ¶meter, uint timeType, uint delta); - bool updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta); + bool updateParameter(uint ¶meter, uint timeType, uint delta) const; + bool updateParameterCheck(uint ¶meter, uint timeType, uint delta) const; + bool updateParameterTime(TimeValue timeValue, bool check, uint ¶meter, uint delta) const; - bool timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function); + bool timeCheck(TimeValue timeValue, uint ¶meter, Common::Functor0 *function) const; bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, const char *str, Common::Functor1 *function); bool timeCheckCallback(TimeValue timeValue, uint ¶meter, byte callback, bool check, Common::Functor1 *function); bool timeCheckCallbackInventory(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); bool timeCheckCar(TimeValue timeValue, uint ¶meter, byte callback, Common::Functor0 *function); - void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action); - void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location); + void timeCheckSavepoint(TimeValue timeValue, uint ¶meter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) const; + void timeCheckObject(TimeValue timeValue, uint ¶meter, ObjectIndex index, ObjectLocation location) const; bool timeCheckCallbackAction(TimeValue timeValue, uint ¶meter); bool timeCheckPlaySoundUpdatePosition(TimeValue timeValue, uint ¶meter, byte callback, const char* sound, EntityPosition position); -- cgit v1.2.3 From 275aded0b0e485eead8d5bdac48d9c8dc1a6ef9c Mon Sep 17 00:00:00 2001 From: Littleboy Date: Tue, 21 Aug 2012 23:16:52 -0400 Subject: LASTEXPRESS: Remove unnecessary casts --- engines/lastexpress/entities/entity.cpp | 4 ++-- engines/lastexpress/entities/entity.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/entity.cpp b/engines/lastexpress/entities/entity.cpp index 88b2ada185..dad5e67392 100644 --- a/engines/lastexpress/entities/entity.cpp +++ b/engines/lastexpress/entities/entity.cpp @@ -50,7 +50,7 @@ EntityData::EntityCallData::~EntityCallData() { SAFE_DELETE(sequence3); } -void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, int length) const { +void EntityData::EntityCallData::syncString(Common::Serializer &s, Common::String &string, uint length) const { char seqName[13]; memset(&seqName, 0, length); @@ -117,7 +117,7 @@ EntityData::EntityParameters *EntityData::getParameters(uint callback, byte inde return _parameters[callback].parameters[index]; } -int EntityData::getCallback(uint callback) const { +byte EntityData::getCallback(uint callback) const { if (callback >= 16) error("[EntityData::getCallback] Invalid callback value (was: %d, max: 16)", callback); diff --git a/engines/lastexpress/entities/entity.h b/engines/lastexpress/entities/entity.h index c45367c43c..c67d13db9e 100644 --- a/engines/lastexpress/entities/entity.h +++ b/engines/lastexpress/entities/entity.h @@ -822,7 +822,7 @@ public: * @param string The string. * @param length Length of the string. */ - void syncString(Common::Serializer &s, Common::String &string, int length) const; + void syncString(Common::Serializer &s, Common::String &string, uint length) const; // Serializable void saveLoadWithSerializer(Common::Serializer &s); @@ -845,8 +845,8 @@ public: EntityParameters *getCurrentParameters(byte index = 0) { return getParameters(_data.currentCall, index); } EntityCallParameters *getCurrentCallParameters() { return &_parameters[_data.currentCall]; } - int getCallback(uint callback) const; - int getCurrentCallback() { return getCallback(_data.currentCall); } + byte getCallback(uint callback) const; + byte getCurrentCallback() { return getCallback(_data.currentCall); } void setCallback(uint callback, byte index); void setCurrentCallback(uint index) { setCallback(_data.currentCall, index); } -- cgit v1.2.3 From 81c6016e8f6c670c1046be12b541b0d63c9fd5fa Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 23 Aug 2012 05:09:01 -0400 Subject: LASTEXPRESS: Identify several Verges functions --- engines/lastexpress/entities/verges.cpp | 102 ++++++++++++++++---------------- engines/lastexpress/entities/verges.h | 8 +-- 2 files changed, 55 insertions(+), 55 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index 867f122d8f..94698886bb 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -46,13 +46,13 @@ Verges::Verges(LastExpressEngine *engine) : Entity(engine, kEntityVerges) { ADD_CALLBACK_FUNCTION(Verges, callbackActionRestaurantOrSalon); ADD_CALLBACK_FUNCTION(Verges, savegame); ADD_CALLBACK_FUNCTION(Verges, updateEntity); - ADD_CALLBACK_FUNCTION(Verges, function9); - ADD_CALLBACK_FUNCTION(Verges, function10); + ADD_CALLBACK_FUNCTION(Verges, walkBetweenCars); + ADD_CALLBACK_FUNCTION(Verges, makeAnnouncement); ADD_CALLBACK_FUNCTION(Verges, function11); ADD_CALLBACK_FUNCTION(Verges, function12); - ADD_CALLBACK_FUNCTION(Verges, function13); + ADD_CALLBACK_FUNCTION(Verges, baggageCar); ADD_CALLBACK_FUNCTION(Verges, updateFromTime); - ADD_CALLBACK_FUNCTION(Verges, function15); + ADD_CALLBACK_FUNCTION(Verges, dialog); ADD_CALLBACK_FUNCTION(Verges, function16); ADD_CALLBACK_FUNCTION(Verges, function17); ADD_CALLBACK_FUNCTION(Verges, chapter1); @@ -149,7 +149,7 @@ IMPLEMENT_FUNCTION_II(8, Verges, updateEntity, CarIndex, EntityPosition) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION_S(9, Verges, function9) +IMPLEMENT_FUNCTION_S(9, Verges, walkBetweenCars) switch (savepoint.action) { default: break; @@ -201,7 +201,7 @@ switch (savepoint.action) { case 3: setCallback(4); - setup_function10(kCarGreenSleeping, kPosition_540, (char *)¶ms->seq1); + setup_makeAnnouncement(kCarGreenSleeping, kPosition_540, (char *)¶ms->seq1); break; case 4: @@ -225,7 +225,7 @@ switch (savepoint.action) { IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION_IIS(10, Verges, function10, CarIndex, EntityPosition) +IMPLEMENT_FUNCTION_IIS(10, Verges, makeAnnouncement, CarIndex, EntityPosition) switch (savepoint.action) { default: break; @@ -404,7 +404,7 @@ IMPLEMENT_FUNCTION(12, Verges, function12) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION_I(13, Verges, function13, bool) +IMPLEMENT_FUNCTION_I(13, Verges, baggageCar, bool) switch (savepoint.action) { default: break; @@ -449,7 +449,7 @@ IMPLEMENT_FUNCTION_I(14, Verges, updateFromTime, uint32) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION_IS(15, Verges, function15, EntityIndex) +IMPLEMENT_FUNCTION_IS(15, Verges, dialog, EntityIndex) switch (savepoint.action) { default: break; @@ -548,7 +548,7 @@ IMPLEMENT_FUNCTION(17, Verges, function17) case 2: setCallback(3); - setup_function15(kEntityMertens, "TRA1291"); + setup_dialog(kEntityMertens, "TRA1291"); break; case 3: @@ -774,10 +774,10 @@ IMPLEMENT_FUNCTION(25, Verges, function25) if (getData()->car == kCarRedSleeping) { setCallback(6); - setup_function10(kCarGreenSleeping, kPosition_540, "TRA1005"); + setup_makeAnnouncement(kCarGreenSleeping, kPosition_540, "TRA1005"); } else { setCallback(7); - setup_function10(kCarRedSleeping, kPosition_9460, "TRA1006"); + setup_makeAnnouncement(kCarRedSleeping, kPosition_9460, "TRA1006"); } break; } @@ -805,7 +805,7 @@ IMPLEMENT_FUNCTION(25, Verges, function25) getSavePoints()->push(kEntityVerges, kEntityCoudert, kAction168254872); setCallback(4); - setup_function10(kCarRedSleeping, kPosition_9460, "TRA1006"); + setup_makeAnnouncement(kCarRedSleeping, kPosition_9460, "TRA1006"); break; case 4: @@ -838,7 +838,7 @@ IMPLEMENT_FUNCTION(25, Verges, function25) getSavePoints()->push(kEntityVerges, kEntityCoudert, kAction168254872); setCallback(10); - setup_function10(kCarGreenSleeping, kPosition_540, "TRA1006"); + setup_makeAnnouncement(kCarGreenSleeping, kPosition_540, "TRA1006"); break; case 10: @@ -892,7 +892,7 @@ IMPLEMENT_FUNCTION(26, Verges, chapter1Handler) label_callback1: if (getEntities()->isInBaggageCarEntrance(kEntityPlayer)) { setCallback(2); - setup_function13(false); + setup_baggageCar(false); break; } @@ -907,7 +907,7 @@ label_callback3: if (params->param6) goto label_callback12; - if (Entity::timeCheckCallback(kTimeChapter1, params->param7, 4, "TRA1001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTimeChapter1, params->param7, 4, "TRA1001", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback4: @@ -923,19 +923,19 @@ label_callback4: } label_callback8: - if (Entity::timeCheckCallback(kTime1107000, CURRENT_PARAM(1, 1), 9, "TRA1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1107000, CURRENT_PARAM(1, 1), 9, "TRA1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback9: - if (Entity::timeCheckCallback(kTime1134000, CURRENT_PARAM(1, 2), 10, "TRA1002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1134000, CURRENT_PARAM(1, 2), 10, "TRA1002", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback10: - if (Entity::timeCheckCallback(kTime1165500, CURRENT_PARAM(1, 3), 11, "TRA1003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1165500, CURRENT_PARAM(1, 3), 11, "TRA1003", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback11: - if (Entity::timeCheckCallback(kTime1225800, CURRENT_PARAM(1, 4), 12, "TRA1004", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1225800, CURRENT_PARAM(1, 4), 12, "TRA1004", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback12: @@ -970,7 +970,7 @@ label_callback15: case kActionOpenDoor: setCallback(17); - setup_function13(savepoint.param.intValue < 106 ? true : false); + setup_baggageCar(savepoint.param.intValue < 106 ? true : false); break; case kActionDefault: @@ -1006,7 +1006,7 @@ label_callback15: case 6: setCallback(7); - setup_function15(kEntityMertens, "TRA1202"); + setup_dialog(kEntityMertens, "TRA1202"); break; case 7: @@ -1084,11 +1084,11 @@ IMPLEMENT_FUNCTION(28, Verges, chapter2Handler) case kActionNone: if (getEntities()->isInBaggageCarEntrance(kEntityPlayer)) { setCallback(1); - setup_function13(false); + setup_baggageCar(false); } label_callback_1: - if (Entity::timeCheckCallback(kTime1818900, params->param1, 2, "Tra2177", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1818900, params->param1, 2, "Tra2177", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_2: @@ -1130,7 +1130,7 @@ label_callback_6: case kActionOpenDoor: setCallback(8); - setup_function13(savepoint.param.intValue < 106); + setup_baggageCar(savepoint.param.intValue < 106); break; case kActionDefault: @@ -1155,7 +1155,7 @@ label_callback_6: case 4: setCallback(5); - setup_function15(kEntityCoudert, "TRA2100"); + setup_dialog(kEntityCoudert, "TRA2100"); break; case 5: @@ -1221,7 +1221,7 @@ IMPLEMENT_FUNCTION_S(30, Verges, function30) case 2: setCallback(3); - setup_function15(kEntityCoudert, (char *)¶ms->seq1); + setup_dialog(kEntityCoudert, (char *)¶ms->seq1); break; case 3: @@ -1260,7 +1260,7 @@ IMPLEMENT_FUNCTION(31, Verges, function31) case 2: setCallback(3); - setup_function15(kEntityCoudert, "TRA3015"); + setup_dialog(kEntityCoudert, "TRA3015"); break; case 3: @@ -1289,7 +1289,7 @@ IMPLEMENT_FUNCTION(32, Verges, function32) if (getState()->time > kTime2263500 && !params->param1) { params->param1 = 1; setCallback(5); - setup_function10(kCarRedSleeping, kPosition_9460, "TRA3006"); + setup_makeAnnouncement(kCarRedSleeping, kPosition_9460, "TRA3006"); break; } break; @@ -1341,7 +1341,7 @@ IMPLEMENT_FUNCTION(32, Verges, function32) case 3: setCallback(4); - setup_function10(kCarGreenSleeping, kPosition_540, "TRA3004"); + setup_makeAnnouncement(kCarGreenSleeping, kPosition_540, "TRA3004"); break; case 4: @@ -1412,7 +1412,7 @@ IMPLEMENT_FUNCTION(33, Verges, function33) getSavePoints()->push(kEntityVerges, kEntityAbbot, kAction192054567); setCallback(6); - setup_function9("Tra3010"); + setup_walkBetweenCars("Tra3010"); break; case 6: @@ -1432,7 +1432,7 @@ IMPLEMENT_FUNCTION(34, Verges, function34) case kActionNone: if (getEntities()->isInBaggageCarEntrance(kEntityPlayer)) { setCallback(1); - setup_function13(false); + setup_baggageCar(false); break; } @@ -1451,11 +1451,11 @@ label_callback_2: } label_callback_3: - if (Entity::timeCheckCallback(kTime1971000, params->param1, 4, "Tra3001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1971000, params->param1, 4, "Tra3001", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_4: - if (Entity::timeCheckCallback(kTime1998000, params->param2, 5, "Tra3010a", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime1998000, params->param2, 5, "Tra3010a", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_5: @@ -1463,11 +1463,11 @@ label_callback_5: break; label_callback_6: - if (Entity::timeCheckCallback(kTime2070000, params->param4, 7, "Tra3002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2070000, params->param4, 7, "Tra3002", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_7: - if (Entity::timeCheckCallback(kTime2142000, params->param5, 8, "Tra3003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2142000, params->param5, 8, "Tra3003", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_8: @@ -1480,7 +1480,7 @@ label_callback_9: case kActionOpenDoor: setCallback(11); - setup_function13(savepoint.param.intValue < 106); + setup_baggageCar(savepoint.param.intValue < 106); break; case kActionCallback: @@ -1542,7 +1542,7 @@ IMPLEMENT_FUNCTION(35, Verges, function35) case 2: setCallback(3); - setup_function15(kEntityMertens, "Tra3011A"); + setup_dialog(kEntityMertens, "Tra3011A"); break; case 3: @@ -1554,7 +1554,7 @@ IMPLEMENT_FUNCTION(35, Verges, function35) case 4: setCallback(5); - setup_function15(kEntityMertens, "Tra3011"); + setup_dialog(kEntityMertens, "Tra3011"); break; case 5: @@ -1609,7 +1609,7 @@ IMPLEMENT_FUNCTION(37, Verges, chapter4Handler) case kActionNone: if (getEntities()->isInBaggageCarEntrance(kEntityPlayer)) { setCallback(1); - setup_function13(false); + setup_baggageCar(false); break; } @@ -1622,37 +1622,37 @@ label_callback_1: } label_callback_2: - if (Entity::timeCheckCallback(kTime2349000, params->param1, 3, "Tra1001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2349000, params->param1, 3, "Tra1001", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_3: - if (Entity::timeCheckCallback(kTime2378700, params->param2, 4, "Tra4001", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2378700, params->param2, 4, "Tra4001", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_4: - if (Entity::timeCheckCallback(kTime2403000, params->param3, 5, "Tra1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2403000, params->param3, 5, "Tra1001A", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_5: - if (Entity::timeCheckCallback(kTime2414700, params->param4, 6, "Tra4002", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2414700, params->param4, 6, "Tra4002", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_6: - if (Entity::timeCheckCallback(kTime2484000, params->param5, 7, "Tra4003", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2484000, params->param5, 7, "Tra4003", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; label_callback_7: - if (Entity::timeCheckCallback(kTime2511000, params->param6, 8, "Tra4004", WRAP_SETUP_FUNCTION_S(Verges, setup_function9))) + if (Entity::timeCheckCallback(kTime2511000, params->param6, 8, "Tra4004", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars))) break; } label_callback_8: - Entity::timeCheckCallback(kTime2538000, params->param7, 9, "Tra4005", WRAP_SETUP_FUNCTION_S(Verges, setup_function9)); + Entity::timeCheckCallback(kTime2538000, params->param7, 9, "Tra4005", WRAP_SETUP_FUNCTION_S(Verges, setup_walkBetweenCars)); break; case kActionOpenDoor: setCallback(10); - setup_function13(savepoint.param.intValue < 106); + setup_baggageCar(savepoint.param.intValue < 106); break; case kActionDefault: @@ -1822,7 +1822,7 @@ IMPLEMENT_FUNCTION(41, Verges, function41) getData()->location = kLocationInsideCompartment; setCallback(1); - setup_function10(kCarRedSleeping, kPosition_2000, "Tra5001"); + setup_makeAnnouncement(kCarRedSleeping, kPosition_2000, "Tra5001"); break; case kActionCallback: @@ -1891,7 +1891,7 @@ void Verges::talk(const SavePoint &savepoint, const char *sound1, const char *so case 2: setCallback(3); - setup_function15(kEntityCoudert, sound1); + setup_dialog(kEntityCoudert, sound1); break; case 3: @@ -1901,7 +1901,7 @@ void Verges::talk(const SavePoint &savepoint, const char *sound1, const char *so case 4: setCallback(5); - setup_function15(kEntityMertens, sound2); + setup_dialog(kEntityMertens, sound2); break; case 5: diff --git a/engines/lastexpress/entities/verges.h b/engines/lastexpress/entities/verges.h index 82381043d3..8932f81fce 100644 --- a/engines/lastexpress/entities/verges.h +++ b/engines/lastexpress/entities/verges.h @@ -87,11 +87,11 @@ public: */ DECLARE_FUNCTION_2(updateEntity, CarIndex car, EntityPosition entityPosition) - DECLARE_FUNCTION_1(function9, const char *soundName) - DECLARE_FUNCTION_3(function10, CarIndex car, EntityPosition entityPosition, const char *soundName) + DECLARE_FUNCTION_1(walkBetweenCars, const char *soundName) + DECLARE_FUNCTION_3(makeAnnouncement, CarIndex car, EntityPosition entityPosition, const char *soundName) DECLARE_FUNCTION(function11) DECLARE_FUNCTION(function12) - DECLARE_FUNCTION_1(function13, bool) + DECLARE_FUNCTION_1(baggageCar, bool) /** * Updates parameter 2 using time value @@ -100,7 +100,7 @@ public: */ DECLARE_FUNCTION_1(updateFromTime, uint32 time) - DECLARE_FUNCTION_2(function15, EntityIndex entity, const char *soundName) + DECLARE_FUNCTION_2(dialog, EntityIndex entity, const char *soundName) DECLARE_FUNCTION_3(function16, EntityIndex entityIndex, const char *soundName1, const char *soundName2) DECLARE_FUNCTION(function17) -- cgit v1.2.3 From 8fa617556c080c4af843944e900f055f4e717e44 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Thu, 23 Aug 2012 05:09:25 -0400 Subject: LASTEXPRESS: Fix typo in Verges chapter 3 function --- engines/lastexpress/entities/verges.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index 94698886bb..ed1918d4ed 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -1177,7 +1177,7 @@ IMPLEMENT_FUNCTION(29, Verges, chapter3) break; case kActionNone: - setup_function23(); + setup_function33(); break; case kActionDefault: -- cgit v1.2.3 From 6ab3b903d46899d642fb57faad6b445242285033 Mon Sep 17 00:00:00 2001 From: Littleboy Date: Fri, 24 Aug 2012 13:44:17 -0400 Subject: LASTEXPRESS: Identify more Verges functions --- engines/lastexpress/entities/abbot.cpp | 2 +- engines/lastexpress/entities/august.cpp | 2 +- engines/lastexpress/entities/verges.cpp | 60 ++++++++++++++++----------------- engines/lastexpress/entities/verges.h | 18 +++++----- 4 files changed, 41 insertions(+), 41 deletions(-) (limited to 'engines/lastexpress/entities') diff --git a/engines/lastexpress/entities/abbot.cpp b/engines/lastexpress/entities/abbot.cpp index 85d0d8948b..406b017d3a 100644 --- a/engines/lastexpress/entities/abbot.cpp +++ b/engines/lastexpress/entities/abbot.cpp @@ -1547,7 +1547,7 @@ IMPLEMENT_FUNCTION(45, Abbot, function45) getData()->car = kCarRedSleeping; getData()->location = kLocationOutsideCompartment; - RESET_ENTITY_STATE(kEntityVerges, Verges, setup_function38); + RESET_ENTITY_STATE(kEntityVerges, Verges, setup_resetState); getEntities()->drawSequenceLeft(kEntityAbbot, "617Ec"); getEntities()->enterCompartment(kEntityAbbot, kObjectCompartmentC, true); diff --git a/engines/lastexpress/entities/august.cpp b/engines/lastexpress/entities/august.cpp index 67d810fde2..dbae7bad20 100644 --- a/engines/lastexpress/entities/august.cpp +++ b/engines/lastexpress/entities/august.cpp @@ -3530,7 +3530,7 @@ IMPLEMENT_FUNCTION(69, August, unhookCars) getScenes()->loadSceneFromPosition(kCarRestaurant, 85, 1); getSavePoints()->pushAll(kEntityAugust, kActionProceedChapter5); - RESET_ENTITY_STATE(kEntityVerges, Verges, setup_function42) + RESET_ENTITY_STATE(kEntityVerges, Verges, setup_end) } break; } diff --git a/engines/lastexpress/entities/verges.cpp b/engines/lastexpress/entities/verges.cpp index ed1918d4ed..d9ddb0a4d1 100644 --- a/engines/lastexpress/entities/verges.cpp +++ b/engines/lastexpress/entities/verges.cpp @@ -53,33 +53,33 @@ Verges::Verges(LastExpressEngine *engine) : Entity(engine, kEntityVerges) { ADD_CALLBACK_FUNCTION(Verges, baggageCar); ADD_CALLBACK_FUNCTION(Verges, updateFromTime); ADD_CALLBACK_FUNCTION(Verges, dialog); - ADD_CALLBACK_FUNCTION(Verges, function16); - ADD_CALLBACK_FUNCTION(Verges, function17); + ADD_CALLBACK_FUNCTION(Verges, dialog2); + ADD_CALLBACK_FUNCTION(Verges, talkAboutPassengerList); ADD_CALLBACK_FUNCTION(Verges, chapter1); ADD_CALLBACK_FUNCTION(Verges, talkHarem); ADD_CALLBACK_FUNCTION(Verges, talkPassengerList); ADD_CALLBACK_FUNCTION(Verges, talkGendarmes); - ADD_CALLBACK_FUNCTION(Verges, function22); + ADD_CALLBACK_FUNCTION(Verges, askMertensToRelayAugustInvitation); ADD_CALLBACK_FUNCTION(Verges, function23); ADD_CALLBACK_FUNCTION(Verges, policeGettingOffTrain); - ADD_CALLBACK_FUNCTION(Verges, function25); + ADD_CALLBACK_FUNCTION(Verges, policeSearch); ADD_CALLBACK_FUNCTION(Verges, chapter1Handler); ADD_CALLBACK_FUNCTION(Verges, chapter2); ADD_CALLBACK_FUNCTION(Verges, chapter2Handler); ADD_CALLBACK_FUNCTION(Verges, chapter3); ADD_CALLBACK_FUNCTION(Verges, function30); - ADD_CALLBACK_FUNCTION(Verges, function31); + ADD_CALLBACK_FUNCTION(Verges, talkAboutMax); ADD_CALLBACK_FUNCTION(Verges, function32); ADD_CALLBACK_FUNCTION(Verges, function33); ADD_CALLBACK_FUNCTION(Verges, function34); - ADD_CALLBACK_FUNCTION(Verges, function35); + ADD_CALLBACK_FUNCTION(Verges, organizeConcertInvitations); ADD_CALLBACK_FUNCTION(Verges, chapter4); ADD_CALLBACK_FUNCTION(Verges, chapter4Handler); - ADD_CALLBACK_FUNCTION(Verges, function38); + ADD_CALLBACK_FUNCTION(Verges, resetState); ADD_CALLBACK_FUNCTION(Verges, chapter5); ADD_CALLBACK_FUNCTION(Verges, chapter5Handler); - ADD_CALLBACK_FUNCTION(Verges, function41); - ADD_CALLBACK_FUNCTION(Verges, function42); + ADD_CALLBACK_FUNCTION(Verges, askPassengersToStayInCompartments); + ADD_CALLBACK_FUNCTION(Verges, end); } ////////////////////////////////////////////////////////////////////////// @@ -486,7 +486,7 @@ IMPLEMENT_FUNCTION_IS(15, Verges, dialog, EntityIndex) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION_ISS(16, Verges, function16, EntityIndex) +IMPLEMENT_FUNCTION_ISS(16, Verges, dialog2, EntityIndex) switch (savepoint.action) { default: break; @@ -526,7 +526,7 @@ IMPLEMENT_FUNCTION_ISS(16, Verges, function16, EntityIndex) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(17, Verges, function17) +IMPLEMENT_FUNCTION(17, Verges, talkAboutPassengerList) switch (savepoint.action) { default: break; @@ -611,7 +611,7 @@ IMPLEMENT_FUNCTION(21, Verges, talkGendarmes) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(22, Verges, function22) +IMPLEMENT_FUNCTION(22, Verges, askMertensToRelayAugustInvitation) switch (savepoint.action) { default: break; @@ -634,10 +634,10 @@ IMPLEMENT_FUNCTION(22, Verges, function22) case 2: if (getEvent(kEventMertensAskTylerCompartment) || getEvent(kEventMertensAskTylerCompartmentD) || getEvent(kEventMertensAugustWaiting)) { setCallback(3); - setup_function16(kEntityMertens, "TRA1200", "TRA1201"); + setup_dialog2(kEntityMertens, "TRA1200", "TRA1201"); } else { setCallback(4); - setup_function16(kEntityMertens, "TRA1200A", "TRA1201"); + setup_dialog2(kEntityMertens, "TRA1200A", "TRA1201"); } break; @@ -714,7 +714,7 @@ IMPLEMENT_FUNCTION(24, Verges, policeGettingOffTrain) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(25, Verges, function25) +IMPLEMENT_FUNCTION(25, Verges, policeSearch) switch (savepoint.action) { default: break; @@ -899,7 +899,7 @@ label_callback1: label_callback2: if (ENTITY_PARAM(0, 7)) { setCallback(3); - setup_function25(); + setup_policeSearch(); break; } @@ -955,7 +955,7 @@ label_callback13: label_callback14: if (ENTITY_PARAM(0, 3) && !params->param4 && (getState()->time < kTime1134000 || getState()->time > kTime1156500)) { setCallback(15); - setup_function17(); + setup_talkAboutPassengerList(); break; } @@ -963,7 +963,7 @@ label_callback15: if (ENTITY_PARAM(0, 1) && !params->param5) { if (getState()->time < kTime1134000 || getState()->time > kTime1156500) { setCallback(16); - setup_function22(); + setup_askMertensToRelayAugustInvitation(); } } break; @@ -1117,7 +1117,7 @@ label_callback_6: if (ENTITY_PARAM(0, 3)) { setCallback(7); - setup_function17(); + setup_talkAboutPassengerList(); } break; @@ -1238,7 +1238,7 @@ IMPLEMENT_FUNCTION_S(30, Verges, function30) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(31, Verges, function31) +IMPLEMENT_FUNCTION(31, Verges, talkAboutMax) switch (savepoint.action) { default: break; @@ -1439,14 +1439,14 @@ IMPLEMENT_FUNCTION(34, Verges, function34) label_callback_1: if (ENTITY_PARAM(0, 4)) { setCallback(2); - setup_function31(); + setup_talkAboutMax(); break; } label_callback_2: if (ENTITY_PARAM(0, 3)) { setCallback(3); - setup_function17(); + setup_talkAboutPassengerList(); break; } @@ -1459,7 +1459,7 @@ label_callback_4: break; label_callback_5: - if (Entity::timeCheckCallback(kTime2016000, params->param3, 6, WRAP_SETUP_FUNCTION(Verges, setup_function35))) + if (Entity::timeCheckCallback(kTime2016000, params->param3, 6, WRAP_SETUP_FUNCTION(Verges, setup_organizeConcertInvitations))) break; label_callback_6: @@ -1520,7 +1520,7 @@ label_callback_9: IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(35, Verges, function35) +IMPLEMENT_FUNCTION(35, Verges, organizeConcertInvitations) switch (savepoint.action) { default: break; @@ -1617,7 +1617,7 @@ label_callback_1: if (ENTITY_PARAM(0, 6)) { if (ENTITY_PARAM(0, 3)) { setCallback(2); - setup_function17(); + setup_talkAboutPassengerList(); break; } @@ -1697,7 +1697,7 @@ label_callback_8: IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(38, Verges, function38) +IMPLEMENT_FUNCTION(38, Verges, resetState) switch (savepoint.action) { default: break; @@ -1803,14 +1803,14 @@ IMPLEMENT_FUNCTION(40, Verges, chapter5Handler) getAction()->playAnimation(kEventCathFreePassengers); getSavePoints()->pushAll(kEntityVerges, kActionProceedChapter5); getScenes()->loadSceneFromPosition(kCarRedSleeping, 40); - setup_function41(); + setup_askPassengersToStayInCompartments(); } break; } IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(41, Verges, function41) +IMPLEMENT_FUNCTION(41, Verges, askPassengersToStayInCompartments) switch (savepoint.action) { default: break; @@ -1852,7 +1852,7 @@ IMPLEMENT_FUNCTION(41, Verges, function41) break; case 4: - setup_function42(); + setup_end(); break; } break; @@ -1860,7 +1860,7 @@ IMPLEMENT_FUNCTION(41, Verges, function41) IMPLEMENT_FUNCTION_END ////////////////////////////////////////////////////////////////////////// -IMPLEMENT_FUNCTION(42, Verges, function42) +IMPLEMENT_FUNCTION(42, Verges, end) if (savepoint.action == kActionDefault) getEntities()->clearSequences(kEntityVerges); IMPLEMENT_FUNCTION_END diff --git a/engines/lastexpress/entities/verges.h b/engines/lastexpress/entities/verges.h index 8932f81fce..93cc190d1e 100644 --- a/engines/lastexpress/entities/verges.h +++ b/engines/lastexpress/entities/verges.h @@ -101,8 +101,8 @@ public: DECLARE_FUNCTION_1(updateFromTime, uint32 time) DECLARE_FUNCTION_2(dialog, EntityIndex entity, const char *soundName) - DECLARE_FUNCTION_3(function16, EntityIndex entityIndex, const char *soundName1, const char *soundName2) - DECLARE_FUNCTION(function17) + DECLARE_FUNCTION_3(dialog2, EntityIndex entityIndex, const char *soundName1, const char *soundName2) + DECLARE_FUNCTION(talkAboutPassengerList) /** * Setup Chapter 1 @@ -112,10 +112,10 @@ public: DECLARE_FUNCTION_NOSETUP(talkHarem) DECLARE_FUNCTION(talkPassengerList) DECLARE_FUNCTION(talkGendarmes) - DECLARE_FUNCTION(function22) + DECLARE_FUNCTION(askMertensToRelayAugustInvitation) DECLARE_FUNCTION(function23) DECLARE_FUNCTION(policeGettingOffTrain) - DECLARE_FUNCTION(function25) + DECLARE_FUNCTION(policeSearch) /** * Handle Chapter 1 events @@ -138,11 +138,11 @@ public: DECLARE_FUNCTION(chapter3) DECLARE_FUNCTION_1(function30, const char *soundName) - DECLARE_FUNCTION(function31) + DECLARE_FUNCTION(talkAboutMax) DECLARE_FUNCTION(function32) DECLARE_FUNCTION(function33) DECLARE_FUNCTION(function34) - DECLARE_FUNCTION(function35) + DECLARE_FUNCTION(organizeConcertInvitations) /** * Setup Chapter 4 @@ -154,7 +154,7 @@ public: */ DECLARE_FUNCTION(chapter4Handler) - DECLARE_FUNCTION(function38) + DECLARE_FUNCTION(resetState) /** * Setup Chapter 5 @@ -166,8 +166,8 @@ public: */ DECLARE_FUNCTION(chapter5Handler) - DECLARE_FUNCTION(function41) - DECLARE_FUNCTION(function42) + DECLARE_FUNCTION(askPassengersToStayInCompartments) + DECLARE_FUNCTION(end) private: void talk(const SavePoint &savepoint, const char *sound1, const char *sound2); -- cgit v1.2.3