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