aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/entities
diff options
context:
space:
mode:
authorJulien2012-07-22 22:43:11 -0400
committerJulien2012-07-27 00:14:57 -0400
commite13290a0286e86ee5c76f62ad74cb945a22cb38d (patch)
tree28aa4aaef32ad60e09c59aeed937bab205854e50 /engines/lastexpress/entities
parent95503250f82c71b4ca6849c5eb5581d3c6645202 (diff)
downloadscummvm-rg350-e13290a0286e86ee5c76f62ad74cb945a22cb38d.tar.gz
scummvm-rg350-e13290a0286e86ee5c76f62ad74cb945a22cb38d.tar.bz2
scummvm-rg350-e13290a0286e86ee5c76f62ad74cb945a22cb38d.zip
LASTEXPRESS: Replace UPDATE_PARAM_CHECK macro
Diffstat (limited to 'engines/lastexpress/entities')
-rw-r--r--engines/lastexpress/entities/alexei.cpp4
-rw-r--r--engines/lastexpress/entities/entity.cpp10
-rw-r--r--engines/lastexpress/entities/entity.h1
-rw-r--r--engines/lastexpress/entities/entity_intern.h6
-rw-r--r--engines/lastexpress/entities/rebecca.cpp2
-rw-r--r--engines/lastexpress/entities/tatiana.cpp2
6 files changed, 15 insertions, 10 deletions
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 &parameter, uint timeValue, uint delta) {
return true;
}
+bool Entity::updateParameterCheck(uint &parameter, uint timeValue, uint delta) {
+ if (parameter && parameter >= timeValue)
+ return false;
+
+ if (!parameter)
+ parameter = (uint)(timeValue + delta);
+
+ return true;
+}
+
void Entity::timeCheckSavepoint(TimeValue timeValue, uint &parameter, 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 &parameter, uint time, uint delta);
+ bool updateParameterCheck(uint &parameter, uint time, uint delta);
void timeCheckSavepoint(TimeValue timeValue, uint &parameter, EntityIndex entity1, EntityIndex entity2, ActionIndex action);
void timeCheckObject(TimeValue timeValue, uint &parameter, 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;