LASTEXPRESS: Replace TIME_CHECK_SAVEPOINT and TIME_CHECK_OBJECT macros

This commit is contained in:
Littleboy 2012-07-16 23:47:49 -04:00
parent 0181a464eb
commit d830c0edc9
11 changed files with 48 additions and 34 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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;

View File

@ -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 &parameter, EntityIndex entity1, EntityIndex entity2, ActionIndex action) {
if (getState()->time > timeValue && !parameter) {
parameter = 1;
getSavePoints()->push(entity1, entity2, action);
}
}
void Entity::timeCheckObject(TimeValue timeValue, uint &parameter, ObjectIndex object, ObjectLocation location) {
if (getState()->time > timeValue && !parameter) {
parameter = 1;
getObjects()->updateLocation2(object, location);
}
}
} // End of namespace LastExpress

View File

@ -845,6 +845,13 @@ protected:
* Store the current callback information and perform the callback action
*/
void callbackAction();
//////////////////////////////////////////////////////////////////////////
// Helper functions
//////////////////////////////////////////////////////////////////////////
void timeCheckSavepoint(TimeValue timeValue, uint &parameter, EntityIndex entity1, EntityIndex entity2, ActionIndex action);
void timeCheckObject(TimeValue timeValue, uint &parameter, ObjectIndex index, ObjectLocation location);
};

View File

@ -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; \

View File

@ -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();

View File

@ -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) {

View File

@ -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:

View File

@ -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;

View File

@ -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);