diff options
| -rw-r--r-- | engines/lastexpress/entities/alouan.cpp | 8 | ||||
| -rw-r--r-- | engines/lastexpress/entities/entity.cpp | 68 | ||||
| -rw-r--r-- | engines/lastexpress/entities/entity.h | 51 | ||||
| -rw-r--r-- | engines/lastexpress/entities/entity_intern.h | 60 | ||||
| -rw-r--r-- | engines/lastexpress/entities/hadija.cpp | 8 | 
5 files changed, 118 insertions, 77 deletions
| 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<Callback *> _callbacks; +	EntityIndex                _entityIndex; +	EntityData                *_data; +	Common::Array<Callback *>  _callbacks; + +	typedef Common::Functor2<const char *, ObjectIndex, void> EnterFunction; +	typedef Common::Functor2<CarIndex, EntityPosition, void> UpdateFunction; + +	#define WRAP_ENTER_FUNCTION(className, method) new Common::Functor2Mem<const char *, ObjectIndex, void, className>(this, &className::method) +	#define WRAP_UPDATE_FUNCTION(className, method) new Common::Functor2Mem<CarIndex, EntityPosition, void, className>(this, &className::method)  	/**  	 * Saves the game @@ -782,6 +788,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  	 *  	 * @param savepoint       The savepoint 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  ////////////////////////////////////////////////////////////////////////// | 
