diff options
-rw-r--r-- | engines/neverhood/entity.h | 16 | ||||
-rw-r--r-- | engines/neverhood/sprite.h | 27 |
2 files changed, 33 insertions, 10 deletions
diff --git a/engines/neverhood/entity.h b/engines/neverhood/entity.h index fb8941ae43..cba1bb9a7f 100644 --- a/engines/neverhood/entity.h +++ b/engines/neverhood/entity.h @@ -60,14 +60,18 @@ protected: // TODO: Disable heavy debug stuff in release mode #define SetUpdateHandler(handler) \ - _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); \ - debug(5, "SetUpdateHandler(" #handler ")"); \ - _updateHandlerCbName = #handler + do { \ + _updateHandlerCb = static_cast <void (Entity::*)(void)> (handler); \ + debug(5, "SetUpdateHandler(" #handler ")"); \ + _updateHandlerCbName = #handler; \ + } while (0) #define SetMessageHandler(handler) \ - _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam ¶m, Entity *sender)> (handler); \ - debug(5, "SetMessageHandler(" #handler ")"); \ - _messageHandlerCbName = #handler + do { \ + _messageHandlerCb = static_cast <uint32 (Entity::*)(int messageNum, const MessageParam ¶m, Entity *sender)> (handler); \ + debug(5, "SetMessageHandler(" #handler ")"); \ + _messageHandlerCbName = #handler; \ + } while (0) const uint kMaxSoundResources = 16; diff --git a/engines/neverhood/sprite.h b/engines/neverhood/sprite.h index 80da1768bd..1d17bf0e70 100644 --- a/engines/neverhood/sprite.h +++ b/engines/neverhood/sprite.h @@ -30,9 +30,24 @@ namespace Neverhood { -#define SetSpriteUpdate(callback) _spriteUpdateCb = static_cast <void (Sprite::*)(void)> (callback); debug(2, "SetSpriteUpdate(" #callback ")"); _spriteUpdateCbName = #callback -#define SetFilterX(callback) _filterXCb = static_cast <int16 (Sprite::*)(int16)> (callback); debug(2, "SetFilterX(" #callback ")") -#define SetFilterY(callback) _filterYCb = static_cast <int16 (Sprite::*)(int16)> (callback); debug(2, "SetFilterY(" #callback ")") +#define SetSpriteUpdate(callback) \ + do { \ + _spriteUpdateCb = static_cast <void (Sprite::*)(void)> (callback); \ + debug(2, "SetSpriteUpdate(" #callback ")"); \ + _spriteUpdateCbName = #callback; \ + } while (0) + +#define SetFilterX(callback) \ + do { \ + _filterXCb = static_cast <int16 (Sprite::*)(int16)> (callback); \ + debug(2, "SetFilterX(" #callback ")"); \ + } while (0) + +#define SetFilterY(callback) \ + do { \ + _filterYCb = static_cast <int16 (Sprite::*)(int16)> (callback); \ + debug(2, "SetFilterY(" #callback ")"); \ + } while (0) const int16 kDefPosition = -32768; @@ -113,7 +128,11 @@ protected: #define AnimationCallback(callback) static_cast <void (AnimatedSprite::*)()> (callback) #define GotoState(callback) gotoState(static_cast <void (AnimatedSprite::*)()> (callback)) -#define NextState(callback) _nextStateCb = static_cast <void (AnimatedSprite::*)(void)> (callback); debug(2, "NextState(" #callback ")"); _nextStateCbName = #callback +#define NextState(callback) \ + do { \ + _nextStateCb = static_cast <void (AnimatedSprite::*)(void)> (callback); \ + debug(2, "NextState(" #callback ")"); _nextStateCbName = #callback; \ + } while (0) #define FinalizeState(callback) setFinalizeState(static_cast <void (AnimatedSprite::*)()> (callback)); const int STICK_LAST_FRAME = -2; |