From ed884644af83c55a561ac454736da2807d121c3f Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 5 Nov 2017 19:08:47 +0100 Subject: [PATCH] Changed: Merged changes from compatibility-develop --HG-- branch : develop --- code/ryzom/client/src/net_manager.cpp | 19 +++++++++++++------ code/ryzom/client/src/user_entity.cpp | 10 ++++++++++ code/ryzom/client/src/user_entity.h | 16 +++++++++++++++- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index d2789d2b9..2d5a4e2be 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -1407,12 +1407,19 @@ void impulseCorrectPos(NLMISC::CBitMemStream &impulse) if(UserEntity->mode() != MBEHAV::COMBAT_FLOAT) { - // Compute the destination. - CVectorD dest = CVectorD((float)x/1000.0f, (float)y/1000.0f, (float)z/1000.0f); - // Update the position for the vision. - NetMngr.setReferencePosition(dest); - // Change the user poisition. - UserEntity->correctPos(dest); + if (x == 0) // Get SpeedAdjustement + { + UserEntity->setSpeedServerAdjust(-0.2f); + } + else + { + // Compute the destination. + CVectorD dest = CVectorD((float)x/1000.0f, (float)y/1000.0f, (float)z/1000.0f); + // Update the position for the vision. + NetMngr.setReferencePosition(dest); + // Change the user poisition. + UserEntity->correctPos(dest); + } } }// impulseCorrectPos // diff --git a/code/ryzom/client/src/user_entity.cpp b/code/ryzom/client/src/user_entity.cpp index 80fccf07c..180832d7d 100644 --- a/code/ryzom/client/src/user_entity.cpp +++ b/code/ryzom/client/src/user_entity.cpp @@ -148,6 +148,8 @@ CUserEntity::CUserEntity() _FrontVelocity = 0.0f; _LateralVelocity = 0.0f; + _SpeedServerAdjust = 1.0f; + // \todo GUIGUI : do it more generic. _First_Pos = false; @@ -1209,7 +1211,11 @@ void CUserEntity::applyMotion(CEntityCL *target) speed = CVectorD::Null; } else + { speed = getVelocity()*_SpeedFactor.getValue(); + _SpeedFactor.addFactorValue(0.005f); + } + // SPEED VECTOR NULL -> NO MOVE if(speed == CVectorD::Null) return; @@ -1231,6 +1237,9 @@ void CUserEntity::applyMotion(CEntityCL *target) // Third Person View else { + double modif = (100.0f/(float)NetMngr.getMsPerTick()); + clamp(modif, 0.0, 1.0); + speed *= modif; speed += pos(); sint64 x = (sint64)((sint32)(speed.x * 1000.0)); sint64 y = (sint64)((sint32)(speed.y * 1000.0)); @@ -3483,6 +3492,7 @@ void CUserEntity::light() void CUserEntity::CSpeedFactor::init() { _Value = 1.0f; // Default speed factor is 1. + _ServerFactor = 1.0f; CInterfaceManager *IM = CInterfaceManager::getInstance (); CCDBNodeLeaf *pNodeLeaf = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:USER:SPEED_FACTOR", false); if(pNodeLeaf) diff --git a/code/ryzom/client/src/user_entity.h b/code/ryzom/client/src/user_entity.h index 1b2745cdd..11501d2a0 100644 --- a/code/ryzom/client/src/user_entity.h +++ b/code/ryzom/client/src/user_entity.h @@ -297,6 +297,8 @@ public: // get the velocity vector of the entity NLMISC::CVector getVelocity() const; + inline void setSpeedServerAdjust(float speed) {_SpeedFactor.addFactorValue(speed);} + /// Check if the mount is able to run, and force walking mode if not void checkMountAbleToRun(); @@ -497,13 +499,23 @@ protected: /// Release void release(); /// Return the speed factor. - float getValue() const {return _Value;} + float getValue() const { return _Value * _ServerFactor; } + void setFactorValue(float value) {_ServerFactor = value;} + void addFactorValue(float value) { + _ServerFactor += value; + if (_ServerFactor > 1.0) + _ServerFactor = 1.0; + if (_ServerFactor < 0.1) + _ServerFactor = 0.1; + } + virtual void serial(class NLMISC::IStream &f) throw(NLMISC::EStream) {f.serial(_Value);} protected: /// Method called when the ping message is back. virtual void update(NLMISC::ICDBNode* leaf); private: float _Value; + float _ServerFactor; }; class CMountHunger @@ -546,6 +558,8 @@ protected: /// Velocity : Front and Lateral float _FrontVelocity; float _LateralVelocity; + /// Speed adjustement from gpms + float _SpeedServerAdjust; /// Head Pitch double _HeadPitch; /// Height of the eyes (camera).