diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.cpp b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.cpp index d61ded987..3fe8541cf 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.cpp @@ -145,15 +145,38 @@ void CCameraAnimationManager::sendAnimation(const NLMISC::CEntityId& eid, const void CCameraAnimationManager::TCameraAnimInfo::sendAnimationSteps(const NLMISC::CEntityId& eid) { - // We first send the first step - sendAnimationStep(eid, 0); - // Now we send the other steps after the duration - + // We first send the first step, and then the others + sendAnimationStepsFrom(eid, 0); } -void CCameraAnimationManager::TCameraAnimInfo::sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep) +bool CCameraAnimationManager::TCameraAnimInfo::sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep) { // We can send the current step + // We first check if the step exists + if (currentStep < 0 || currentStep >= Steps.size()) + return false; + + ICameraAnimationStep* step = Steps[currentStep]; + // We send the animation step to the client + step->sendAnimationStep(eid); + + return true; +} +void CCameraAnimationManager::TCameraAnimInfo::sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event) +{ + // We send the current step + if (sendAnimationStep(eid, firstStep)) + { + if (event == 0) + event = new TCameraAnimTimerEvent(this, firstStep + 1, eid); + else + event->nextStep(); + + // Now we send the other steps after the duration + //_Timer->reset(); + NLMISC::TGameCycle duration = (NLMISC::TGameCycle)(Steps[firstStep]->getDuration() / CTickEventHandler::getGameTimeStep()); + _Timer->setRemaining(duration, event); + } } \ No newline at end of file diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.h b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.h index abde9623c..ed0600cd2 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.h +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_manager.h @@ -21,6 +21,7 @@ #include #include "camera_animation_manager/camera_animation_step_factory.h" #include "nel/misc/entity_id.h" +#include "game_share/timer.h" /************************************************************************/ /* Class that manages the camera animations. (singleton). @@ -60,10 +61,14 @@ private: /// Class that contains information about an animation class TCameraAnimInfo { + private: + class TCameraAnimTimerEvent; + public: TCameraAnimInfo() { Name = ""; + _Timer = new CTimer(); } /// Function called to release the animations void release() @@ -77,16 +82,25 @@ private: Steps.clear(); Name = ""; + + delete _Timer; } + /// Function called to send the camera animation instruction specified by the current step to the client - void sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep); + /// The function returns false if the animation step does not exist + bool sendAnimationStep(const NLMISC::CEntityId& eid, int currentStep); /// Function called to send all the camera animation instructions to the client void sendAnimationSteps(const NLMISC::CEntityId& eid); + /// Function that sends the animation steps from the specified one to the last one + void sendAnimationStepsFrom(const NLMISC::CEntityId& eid, int firstStep, TCameraAnimTimerEvent* event = 0); + std::string Name; std::vector Steps; private: + CTimer* _Timer; + class TCameraAnimTimerEvent: public CTimerEvent { public: @@ -98,8 +112,13 @@ private: // Callback called when the timer finished void timerCallback(CTimer* owner) { - // We tell the camera anim info to send the current step - _Infos->sendAnimationStep(_Eid, _Next); + // We tell the camera anim info to send the current step and the next ones + _Infos->sendAnimationStepsFrom(_Eid, _Next, this); + } + + void nextStep() + { + _Next++; } private: diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.cpp b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.cpp index 23799d3af..78afbcc5a 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.cpp +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.cpp @@ -78,3 +78,8 @@ void ICameraAnimationStep::addModifier(ICameraAnimationModifier* modifier) { Modifiers.push_back(modifier); } + +void ICameraAnimationStep::sendAnimationStep(const NLMISC::CEntityId& eid) +{ + throw std::exception("The method or operation is not implemented."); +} \ No newline at end of file diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h index 4e6eed933..9de16bc9d 100644 --- a/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/camera_animation_step_factory.h @@ -40,6 +40,8 @@ public: /// Function that returns the duration of the step (in seconds) virtual float getDuration() const = 0; + /// Function that sends the animation step the to client + void sendAnimationStep(const NLMISC::CEntityId& eid); protected: // The list of modifiers std::vector Modifiers;