From 33e36451fb179d14bb4b00fb295c2f7a0874b9d5 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 15 Sep 2013 14:18:38 +0200 Subject: Renamed sendFullStatus to markAllInfoAsChanged Moved the actual sending of info out of update() and into sendStatus to prevent delay issues depending on the order of the components getting updated. --- src/game-server/charactercomponent.cpp | 29 ++++++++++------------------- src/game-server/charactercomponent.h | 11 ++++++----- src/game-server/gamehandler.cpp | 2 +- 3 files changed, 17 insertions(+), 25 deletions(-) (limited to 'src/game-server') diff --git a/src/game-server/charactercomponent.cpp b/src/game-server/charactercomponent.cpp index 89f3eeb3..11e90a65 100644 --- a/src/game-server/charactercomponent.cpp +++ b/src/game-server/charactercomponent.cpp @@ -110,8 +110,6 @@ CharacterComponent::CharacterComponent(Entity &entity, MessageIn &msg): beingComponent->signal_attribute_changed.connect(sigc::mem_fun( this, &CharacterComponent::attributeChanged)); - - sendFullInfo(entity); } CharacterComponent::~CharacterComponent() @@ -276,22 +274,6 @@ void CharacterComponent::serialize(Entity &entity, MessageOut &msg) } } -void CharacterComponent::update(Entity &entity) -{ - // Dead character: don't regenerate anything else - if (entity.getComponent()->getAction() == DEAD) - return; - - if (!mModifiedAbilities.empty()) - sendAbilityUpdate(entity); - - if (mSendAbilityCooldown) - sendAbilityCooldownUpdate(entity); - - if (mSendAttributePointsStatus) - sendAttributePointsStatus(entity); -} - void CharacterComponent::characterDied(Entity *being) { executeCallback(mDeathCallback, *being); @@ -448,6 +430,15 @@ void CharacterComponent::sendStatus(Entity &entity) } if (attribMsg.getLength() > 2) gameHandler->sendTo(mClient, attribMsg); mModifiedAttributes.clear(); + + if (!mModifiedAbilities.empty()) + sendAbilityUpdate(entity); + + if (mSendAbilityCooldown) + sendAbilityCooldownUpdate(entity); + + if (mSendAttributePointsStatus) + sendAttributePointsStatus(entity); } void CharacterComponent::modifiedAllAbilities(Entity &entity) @@ -586,7 +577,7 @@ void CharacterComponent::triggerLoginCallback(Entity &entity) executeCallback(mLoginCallback, entity); } -void CharacterComponent::sendFullInfo(Entity &entity) +void CharacterComponent::markAllInfoAsChanged(Entity &entity) { modifiedAllAbilities(entity); modifiedAllAttributes(entity); diff --git a/src/game-server/charactercomponent.h b/src/game-server/charactercomponent.h index 0e5d5ffd..fe3f028d 100644 --- a/src/game-server/charactercomponent.h +++ b/src/game-server/charactercomponent.h @@ -63,10 +63,7 @@ class CharacterComponent : public Component ~CharacterComponent(); - /** - * calls Being::update and handles special recharges and status effects - */ - void update(Entity &entity); + virtual void update(Entity &entity); /** * Executes the global die script @@ -279,7 +276,7 @@ class CharacterComponent : public Component void triggerLoginCallback(Entity &entity); - void sendFullInfo(Entity &entity); + void markAllInfoAsChanged(Entity &entity); sigc::signal signal_disconnected; @@ -374,4 +371,8 @@ inline int CharacterComponent::getCorrectionPoints() const return mCorrectionPoints; } +inline void CharacterComponent::update(Entity &entity) +{ +} + #endif // CHARACTER_H diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp index fa2c273f..6546d8d3 100644 --- a/src/game-server/gamehandler.cpp +++ b/src/game-server/gamehandler.cpp @@ -405,7 +405,7 @@ void GameHandler::tokenMatched(GameClient *computer, Entity *character) computer->send(result); Inventory(character).sendFull(); - characterComponent->sendFullInfo(*character); + characterComponent->markAllInfoAsChanged(*character); } void GameHandler::deletePendingClient(GameClient *computer) -- cgit v1.2.3-60-g2f50