From 1d960d91ff1b3890dfa3caf1c7581647c9fc8537 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Thu, 13 Oct 2016 20:46:10 +0200 Subject: [PATCH 1/9] Fixed a rare case where float and double mixup would result in an incorrect speed --HG-- branch : fix_speed --- .../entities_game_service/phrase_manager/combat_attacker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp index f6c2cdb85..ca03d0cff 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp @@ -130,7 +130,8 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr) // weapon hit rate is in hit/10s and we use ticks/hits.... if (itemPtr->hitRate() != 0) { - LatencyInTicks = uint16( (10.0f / itemPtr->hitRate()) / CTickEventHandler::getGameTimeStep()); + //getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10 + LatencyInTicks = uint16 ( (10.0f / itemPtr->hitRate() ) / float(CTickEventHandler::getGameTimeStep()) ); } Quality = (uint16)itemPtr->recommended(); From 0e467cba865311745059d68916766848b3a1b507 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Fri, 14 Oct 2016 21:03:31 +0200 Subject: [PATCH 2/9] Make multiples states changes in one tick (if relevant) --HG-- branch : fix_speed --- .../phrase_manager/phrase_manager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp index 84e68dcd1..2154db628 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp @@ -456,7 +456,14 @@ void CPhraseManager::updatePhrases() } // update this phrase - updateEntityCurrentAction( (*it).first, entityPhrases); + CSPhrase::TPhraseState old_state; + do + { + old_state = phrase->state(); + updateEntityCurrentAction( (*it).first, entityPhrases); + phrase = entityPhrases.getCurrentAction(); + //Every time we get the next action, th phrase might be deleted (if the action is invalid or finished for non-cyclic actions like digging / crafting), always check ! + } while(phrase != NULL && old_state != phrase->state()); // get next entity sentences ++it; From 9c5ecea867912d5ba03586485031040d4611184b Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Fri, 14 Oct 2016 21:19:27 +0200 Subject: [PATCH 3/9] Use speed as an int instead of float to calculate latency --HG-- branch : fix_speed --- .../entities_game_service/phrase_manager/combat_attacker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp index ca03d0cff..9ec8462d1 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp @@ -131,7 +131,7 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr) if (itemPtr->hitRate() != 0) { //getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10 - LatencyInTicks = uint16 ( (10.0f / itemPtr->hitRate() ) / float(CTickEventHandler::getGameTimeStep()) ); + LatencyInTicks = uint16 ( (10.0f / uint16(itemPtr->hitRate()) ) / float(CTickEventHandler::getGameTimeStep()) ); } Quality = (uint16)itemPtr->recommended(); From 2818e9339d2361584939157c945b07a3f16b416c Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Sat, 15 Oct 2016 19:04:22 +0200 Subject: [PATCH 4/9] Uses float to calculate latency for sabrina phrases --HG-- branch : fix_speed --- .../game_item_manager/game_item.cpp | 4 +-- .../game_item_manager/game_item.h | 6 ++--- .../combat_action_simple_dynamic_effect.cpp | 2 +- .../combat_action_simple_effect.cpp | 2 +- .../phrase_manager/combat_attacker.cpp | 8 +++--- .../phrase_manager/combat_attacker.h | 4 +-- .../phrase_manager/combat_phrase.cpp | 25 ++++++++++++------- .../phrase_manager/fg_prospection_phrase.cpp | 2 +- .../phrase_manager/magic_phrase.cpp | 6 ++--- .../phrase_manager/s_phrase.h | 6 ++--- .../phrase_manager/special_power_phrase.cpp | 2 +- .../phrase_manager/timed_action_phrase.cpp | 2 +- 12 files changed, 38 insertions(+), 31 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp index 390916885..a8b60a174 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp @@ -1085,7 +1085,7 @@ void CGameItem::resetEnchantment() _SapLoad = 0; _Enchantment.clear(); contReset( _Enchantment ); - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; if (getInventory() != NULL) getInventory()->onItemChanged(getInventorySlot(), INVENTORIES::TItemChangeFlags(INVENTORIES::itc_enchant)); @@ -1351,7 +1351,7 @@ void CGameItem::clear() _Destroyable = true; _Dropable = true; // _SlotImage = 0xFFFF; - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; // _Parent = NULL; _Inventory = NULL; _InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT; diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h index 635fbf74c..0c1a03b15 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h @@ -651,9 +651,9 @@ public : bool getStats(const std::string &stats, std::string &final ); /// accessors to the action latency end date - inline NLMISC::TGameCycle getLatencyEndDate(){ return _LatencyEndDate; } + inline float getLatencyEndDate(){ return _LatencyEndDate; } - inline void setLatencyEndDate( NLMISC::TGameCycle latencyEndDate ){ _LatencyEndDate = latencyEndDate; } + inline void setLatencyEndDate( float latencyEndDate ){ _LatencyEndDate = latencyEndDate; } /// set the max sap load craft parameter inline void setMaxSapLoad(float value) @@ -950,7 +950,7 @@ private: /// string associated with this item std::string _PhraseId; /// tick when the proc will be available again - NLMISC::TGameCycle _LatencyEndDate; + float _LatencyEndDate; /// image of the item in bag / equipment // uint16 _SlotImage; NLMISC::TGameCycle _TotalSaleCycle; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_dynamic_effect.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_dynamic_effect.cpp index 4b16d63e1..ffd46e363 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_dynamic_effect.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_dynamic_effect.cpp @@ -88,7 +88,7 @@ void CCombatActionDynamicEffect::applyOnEntity( CEntityBase *entity, float succe TGameCycle endDate; if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0) { - endDate = _CombatPhrase->latencyEndDate(); + endDate = (TGameCycle) _CombatPhrase->latencyEndDate(); } else { diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_effect.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_effect.cpp index e08633ccb..5155c37b1 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_effect.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_action_simple_effect.cpp @@ -88,7 +88,7 @@ void CCombatActionSimpleEffect::applyOnEntity( CEntityBase *entity, float succes TGameCycle endDate; if ( _UsePhraseLatencyAsDuration == true && _CombatPhrase != 0) { - endDate = _CombatPhrase->latencyEndDate(); + endDate = (TGameCycle)_CombatPhrase->latencyEndDate(); } else { diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp index 9ec8462d1..48537e6c3 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp @@ -131,7 +131,7 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr) if (itemPtr->hitRate() != 0) { //getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10 - LatencyInTicks = uint16 ( (10.0f / uint16(itemPtr->hitRate()) ) / float(CTickEventHandler::getGameTimeStep()) ); + LatencyInTicks = (10.0f / itemPtr->hitRate() ) / float(CTickEventHandler::getGameTimeStep()); } Quality = (uint16)itemPtr->recommended(); @@ -298,7 +298,7 @@ void CCombatAttackerAI::initFromRowId( const TDataSetRow &rowId ) _RightHandWeapon.Damage = (float)form->getCreatureDamagePerHit() * BotDamageFactor; _RightHandWeapon.DmgType = DMGTYPE::SLASHING; - _RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); _RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON; _RightHandWeapon.Skill = BarehandCombatSkill; _RightHandWeapon.SabrinaCost = (uint16)_SkillValue; @@ -417,7 +417,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId ) { // get speed, dmg type, skill and family _RightHandWeapon = CCombatWeapon(entity->getRightHandItem()); - _RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); // check ammo if (entity->getAmmoItem() != NULL && entity->getAmmoItem()->getStaticForm() != NULL && entity->getAmmoItem()->getStaticForm()->Family == ITEMFAMILY::AMMO) @@ -427,7 +427,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId ) } else { - _RightHandWeapon.LatencyInTicks = (uint16)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); _RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON; _RightHandWeapon.Skill = BarehandCombatSkill; _RightHandWeapon.DmgType = DMGTYPE::BLUNT; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h index e5e9baa82..dbee38a93 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h @@ -92,7 +92,7 @@ public: /************************************************************************/ /* do not forget to update the operator= if attributes change /************************************************************************/ - uint16 LatencyInTicks; + float LatencyInTicks; float Damage; uint16 Quality; DMGTYPE::EDamageType DmgType; @@ -111,7 +111,7 @@ public: private: void init() { - LatencyInTicks = 0; + LatencyInTicks = 0.0f; Damage = 0; Quality = 0; DmgType = DMGTYPE::UNDEFINED; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp index 0e34f243f..136c9d6c4 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp @@ -382,7 +382,7 @@ void CCombatPhrase::init() _CriticalHit = false; _ExecutionEndDate = 0; - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; _SabrinaCost = 0; _SabrinaRelativeCost = 1.0f; @@ -892,7 +892,7 @@ bool CCombatPhrase::evaluate() _NotEnoughStaminaMsg = false; _NotEnoughHpMsg = false; _DisengageOnEnd = false; - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; _ExecutionEndDate = 0; return true; @@ -1702,7 +1702,7 @@ bool CCombatPhrase::launch() { H_AUTO(CCombatPhrase_launch); - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; _ApplyDate = 0; if ( !_Attacker ) @@ -1846,7 +1846,7 @@ bool CCombatPhrase::launch() float latency; if(_LeftWeapon.LatencyInTicks != 0) { - latency = float(_HitRateModifier + std::max( MinTwoWeaponsLatency.get(), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks); + latency = float(_HitRateModifier + std::max( float(MinTwoWeaponsLatency.get()), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks); } else { @@ -2177,8 +2177,15 @@ bool CCombatPhrase::launch() // set latency end date const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle(); - _LatencyEndDate = time + (NLMISC::TGameCycle)latency; - + if(_LatencyEndDate > 0) + { + _LatencyEndDate += latency; + } + else + { + _LatencyEndDate = (float)time + latency; + } + nlwarning("_LatencyEndDate : %f, latency: %f", _LatencyEndDate, latency); // compute the apply date if (_Targets[0].Target!=NULL && actingEntity->getEntityRowId() == _Targets[0].Target->getEntityRowId()) { @@ -2322,8 +2329,8 @@ bool CCombatPhrase::launchAttack(CEntityBase * actingEntity, bool rightHand, boo // now we use the weapon speed factor as a divisor of wear per action // (a weapon twice as fast will wear twice as slow) nlassert(ReferenceWeaponLatencyForWear > 0); - const uint16 latency = (rightHand ? _RightWeapon.LatencyInTicks : _LeftWeapon.LatencyInTicks); - const float wearFactor = (float)latency / (float)ReferenceWeaponLatencyForWear; + const float latency = (rightHand ? _RightWeapon.LatencyInTicks : _LeftWeapon.LatencyInTicks); + const float wearFactor = latency / (float)ReferenceWeaponLatencyForWear; if (rightHand) { @@ -3365,7 +3372,7 @@ void CCombatPhrase::stop() CCharacter *character = PlayerManager.getChar(_Attacker->getEntityRowId()); if (character) { - character->dateOfNextAllowedAction( _LatencyEndDate ); + character->dateOfNextAllowedAction((NLMISC::TGameCycle)_LatencyEndDate ); } } diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp index b45a6043d..1d3822878 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp @@ -716,7 +716,7 @@ void CFgProspectionPhrase::apply() MBEHAV::CBehaviour behav = player->getBehaviour(); // keep arguments behav.Behaviour = MBEHAV::PROSPECTING_END; PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, behav ); - _LatencyEndDate = ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time) + _LatencyEndDate =(float)ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time) } diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp index 16f77bc8b..9166263d8 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp @@ -1566,9 +1566,9 @@ bool CMagicPhrase::launch() // add post cast latency, only for non instant cast const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle(); if (_DivineInterventionOccured||_ShootAgainOccured?_BaseCastingTime:_CastingTime) - _LatencyEndDate = time + PostCastLatency + _PostCastTime; + _LatencyEndDate = (float)time + PostCastLatency + _PostCastTime; else - _LatencyEndDate = 0 + _PostCastTime; + _LatencyEndDate = 0.0f + _PostCastTime; // compute the apply date if ( !_Targets.empty() && _ActorRowId != _Targets[0].getId()) @@ -1898,7 +1898,7 @@ void CMagicPhrase::enchantPhrase(CCharacter * user,float successFactor) _Targets.resize(1); // user->setActionFlag( RYZOMACTIONFLAGS::Attacks, true ); - _LatencyEndDate = 0;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ; + _LatencyEndDate = 0.0f;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ; // _BeingProcessed = false; } // enchantPhrase // diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h index 01cd8ec7c..da496f33a 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h @@ -56,7 +56,7 @@ public: _Idle = false; _ExecutionEndDate = 0; _ApplyDate = ~0; // ensure apply() never called before launch() - _LatencyEndDate = 0; // by default, time between apply() and end() is immediate + _LatencyEndDate = 0.0f; // by default, time between apply() and end() is immediate _PhraseBookIndex = 0; _NextCounter = 0; _IsStatic = false; @@ -98,7 +98,7 @@ public: inline NLMISC::TGameCycle applyDate() const { return _ApplyDate; } /// get latency end date - inline NLMISC::TGameCycle latencyEndDate() const { return _LatencyEndDate; } + inline float latencyEndDate() const { return _LatencyEndDate; } /** * build the phrase from bricks, actor and main target @@ -207,7 +207,7 @@ protected: /// apply date NLMISC::TGameCycle _ApplyDate; /// latency end date - NLMISC::TGameCycle _LatencyEndDate; + float _LatencyEndDate; /// index in client phrase book (0 = not in the phrase book) uint16 _PhraseBookIndex; /// next counter diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp index 84d4d31fb..4bf951737 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp @@ -758,7 +758,7 @@ bool CSpecialPowerPhrase::launch() //----------------------------------------------- void CSpecialPowerPhrase::apply() { - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; // TODO // apply effect diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp index 1537a0ca4..16177ff8a 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp @@ -279,7 +279,7 @@ void CTimedActionPhrase::apply() // keep a ptr on this to prevent it to be deleted when timed action is deconnection CSPhrasePtr selfPtr = this; - _LatencyEndDate = 0; + _LatencyEndDate = 0.0f; CEntityBase *actor = CEntityBaseManager::getEntityBasePtr(_ActorRowId); if (!actor) From 02316b9e8dc00b325d83f91d9c2b23743c8c9b71 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Sat, 15 Oct 2016 20:12:41 +0200 Subject: [PATCH 5/9] Use double instead of float to allow big values of GameCycle (like on winchgate server) --HG-- branch : fix_speed --- .../entities_game_service/game_item_manager/game_item.h | 6 +++--- .../phrase_manager/combat_attacker.cpp | 9 ++++----- .../phrase_manager/combat_attacker.h | 2 +- .../phrase_manager/combat_phrase.cpp | 8 ++++---- .../phrase_manager/fg_prospection_phrase.cpp | 2 +- .../phrase_manager/magic_phrase.cpp | 2 +- .../src/entities_game_service/phrase_manager/s_phrase.h | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h index 0c1a03b15..7f28cfe62 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.h @@ -651,9 +651,9 @@ public : bool getStats(const std::string &stats, std::string &final ); /// accessors to the action latency end date - inline float getLatencyEndDate(){ return _LatencyEndDate; } + inline double getLatencyEndDate(){ return _LatencyEndDate; } - inline void setLatencyEndDate( float latencyEndDate ){ _LatencyEndDate = latencyEndDate; } + inline void setLatencyEndDate( double latencyEndDate ){ _LatencyEndDate = latencyEndDate; } /// set the max sap load craft parameter inline void setMaxSapLoad(float value) @@ -950,7 +950,7 @@ private: /// string associated with this item std::string _PhraseId; /// tick when the proc will be available again - float _LatencyEndDate; + double _LatencyEndDate; /// image of the item in bag / equipment // uint16 _SlotImage; NLMISC::TGameCycle _TotalSaleCycle; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp index 48537e6c3..6b0a88ff0 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp @@ -130,8 +130,7 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr) // weapon hit rate is in hit/10s and we use ticks/hits.... if (itemPtr->hitRate() != 0) { - //getGameTimeStep() is actually a double and hitRate() a float, so the precision difference will make a cast of the result fail (for example, with hitRate() == 10.0f, the cast will give a value of 9 and not 10 - LatencyInTicks = (10.0f / itemPtr->hitRate() ) / float(CTickEventHandler::getGameTimeStep()); + LatencyInTicks = (10.0f / itemPtr->hitRate() ) / CTickEventHandler::getGameTimeStep(); } Quality = (uint16)itemPtr->recommended(); @@ -298,7 +297,7 @@ void CCombatAttackerAI::initFromRowId( const TDataSetRow &rowId ) _RightHandWeapon.Damage = (float)form->getCreatureDamagePerHit() * BotDamageFactor; _RightHandWeapon.DmgType = DMGTYPE::SLASHING; - _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (double)form->getAttackLatency(); _RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON; _RightHandWeapon.Skill = BarehandCombatSkill; _RightHandWeapon.SabrinaCost = (uint16)_SkillValue; @@ -417,7 +416,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId ) { // get speed, dmg type, skill and family _RightHandWeapon = CCombatWeapon(entity->getRightHandItem()); - _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (double)form->getAttackLatency(); // check ammo if (entity->getAmmoItem() != NULL && entity->getAmmoItem()->getStaticForm() != NULL && entity->getAmmoItem()->getStaticForm()->Family == ITEMFAMILY::AMMO) @@ -427,7 +426,7 @@ void CCombatAttackerNpc::initFromRowId( const TDataSetRow &rowId ) } else { - _RightHandWeapon.LatencyInTicks = (float)form->getAttackLatency(); + _RightHandWeapon.LatencyInTicks = (double)form->getAttackLatency(); _RightHandWeapon.Family = ITEMFAMILY::MELEE_WEAPON; _RightHandWeapon.Skill = BarehandCombatSkill; _RightHandWeapon.DmgType = DMGTYPE::BLUNT; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h index dbee38a93..fb992fd77 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h @@ -92,7 +92,7 @@ public: /************************************************************************/ /* do not forget to update the operator= if attributes change /************************************************************************/ - float LatencyInTicks; + double LatencyInTicks; float Damage; uint16 Quality; DMGTYPE::EDamageType DmgType; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp index 136c9d6c4..2a781f76e 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp @@ -1843,14 +1843,14 @@ bool CCombatPhrase::launch() } // get weapon latency - float latency; + double latency; if(_LeftWeapon.LatencyInTicks != 0) { - latency = float(_HitRateModifier + std::max( float(MinTwoWeaponsLatency.get()), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks); + latency = double(_HitRateModifier + std::max( double(MinTwoWeaponsLatency.get()), std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks)) + _Ammo.LatencyInTicks); } else { - latency = float(_HitRateModifier + std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks) + _Ammo.LatencyInTicks); + latency = double(_HitRateModifier + std::max(_RightWeapon.LatencyInTicks, _LeftWeapon.LatencyInTicks) + _Ammo.LatencyInTicks); } // check for madness effect @@ -2183,7 +2183,7 @@ bool CCombatPhrase::launch() } else { - _LatencyEndDate = (float)time + latency; + _LatencyEndDate = (double)time + latency; } nlwarning("_LatencyEndDate : %f, latency: %f", _LatencyEndDate, latency); // compute the apply date diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp index 1d3822878..e3a6969fd 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/fg_prospection_phrase.cpp @@ -716,7 +716,7 @@ void CFgProspectionPhrase::apply() MBEHAV::CBehaviour behav = player->getBehaviour(); // keep arguments behav.Behaviour = MBEHAV::PROSPECTING_END; PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, behav ); - _LatencyEndDate =(float)ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time) + _LatencyEndDate =(double)ForageSourceSpawnDelay.get(); // wait a short time before spawning the source(s) (to let animation/fx time) } diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp index 9166263d8..5cd4a5c82 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp @@ -1566,7 +1566,7 @@ bool CMagicPhrase::launch() // add post cast latency, only for non instant cast const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle(); if (_DivineInterventionOccured||_ShootAgainOccured?_BaseCastingTime:_CastingTime) - _LatencyEndDate = (float)time + PostCastLatency + _PostCastTime; + _LatencyEndDate = (double)time + PostCastLatency + _PostCastTime; else _LatencyEndDate = 0.0f + _PostCastTime; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h index da496f33a..e2164f34d 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h @@ -98,7 +98,7 @@ public: inline NLMISC::TGameCycle applyDate() const { return _ApplyDate; } /// get latency end date - inline float latencyEndDate() const { return _LatencyEndDate; } + inline double latencyEndDate() const { return _LatencyEndDate; } /** * build the phrase from bricks, actor and main target @@ -207,7 +207,7 @@ protected: /// apply date NLMISC::TGameCycle _ApplyDate; /// latency end date - float _LatencyEndDate; + double _LatencyEndDate; /// index in client phrase book (0 = not in the phrase book) uint16 _PhraseBookIndex; /// next counter From 14966eef4c9247220044348f5de58f51aa386deb Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Sat, 15 Oct 2016 20:14:26 +0200 Subject: [PATCH 6/9] Remove debug message --HG-- branch : fix_speed --- .../src/entities_game_service/phrase_manager/combat_phrase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp index 2a781f76e..c25e31ea7 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp @@ -2185,7 +2185,6 @@ bool CCombatPhrase::launch() { _LatencyEndDate = (double)time + latency; } - nlwarning("_LatencyEndDate : %f, latency: %f", _LatencyEndDate, latency); // compute the apply date if (_Targets[0].Target!=NULL && actingEntity->getEntityRowId() == _Targets[0].Target->getEntityRowId()) { From a79c371598048ceae63998a0c68979bf2582d378 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Sat, 15 Oct 2016 20:15:22 +0200 Subject: [PATCH 7/9] Fix end of function comment --HG-- branch : fix_speed --- .../entities_game_service/phrase_manager/phrase_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp index 2154db628..c8d55ad72 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp @@ -473,7 +473,7 @@ void CPhraseManager::updatePhrases() sendEventReports(); // sendAIEvents(); -} +} // updatePhrases() //-------------------------------------------------------------- // updateEntityCurrentAction() @@ -710,7 +710,7 @@ afterPhraseProcessing: // go to next action for this entity entityPhrases.goToNextAction(); } -} // updatePhrases // +} // updateEntityCurrentAction // //----------------------------------------------- From 7592d3e6c40b6881db06c81b15848dd813963fcb Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Thu, 20 Oct 2016 16:02:02 +0200 Subject: [PATCH 8/9] Fix coding guidelines + double initialized as 0.0 --HG-- branch : fix_speed --- .../game_item_manager/game_item.cpp | 4 ++-- .../phrase_manager/combat_attacker.cpp | 2 +- .../phrase_manager/combat_attacker.h | 2 +- .../phrase_manager/combat_phrase.cpp | 8 ++++---- .../phrase_manager/magic_phrase.cpp | 4 ++-- .../phrase_manager/phrase_manager.cpp | 11 ++++++----- .../entities_game_service/phrase_manager/s_phrase.h | 2 +- .../phrase_manager/special_power_phrase.cpp | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp index a8b60a174..11b612781 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item.cpp @@ -1085,7 +1085,7 @@ void CGameItem::resetEnchantment() _SapLoad = 0; _Enchantment.clear(); contReset( _Enchantment ); - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; if (getInventory() != NULL) getInventory()->onItemChanged(getInventorySlot(), INVENTORIES::TItemChangeFlags(INVENTORIES::itc_enchant)); @@ -1351,7 +1351,7 @@ void CGameItem::clear() _Destroyable = true; _Dropable = true; // _SlotImage = 0xFFFF; - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; // _Parent = NULL; _Inventory = NULL; _InventorySlot = INVENTORIES::INVALID_INVENTORY_SLOT; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp index 6b0a88ff0..fa8bdb1ff 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.cpp @@ -130,7 +130,7 @@ CCombatWeapon::CCombatWeapon(CGameItemPtr itemPtr) // weapon hit rate is in hit/10s and we use ticks/hits.... if (itemPtr->hitRate() != 0) { - LatencyInTicks = (10.0f / itemPtr->hitRate() ) / CTickEventHandler::getGameTimeStep(); + LatencyInTicks = (10.0 / itemPtr->hitRate() ) / CTickEventHandler::getGameTimeStep(); } Quality = (uint16)itemPtr->recommended(); diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h index fb992fd77..02f0f39f8 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_attacker.h @@ -111,7 +111,7 @@ public: private: void init() { - LatencyInTicks = 0.0f; + LatencyInTicks = 0.0; Damage = 0; Quality = 0; DmgType = DMGTYPE::UNDEFINED; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp index c25e31ea7..6dfd7a6b2 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/combat_phrase.cpp @@ -382,7 +382,7 @@ void CCombatPhrase::init() _CriticalHit = false; _ExecutionEndDate = 0; - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; _SabrinaCost = 0; _SabrinaRelativeCost = 1.0f; @@ -892,7 +892,7 @@ bool CCombatPhrase::evaluate() _NotEnoughStaminaMsg = false; _NotEnoughHpMsg = false; _DisengageOnEnd = false; - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; _ExecutionEndDate = 0; return true; @@ -1702,7 +1702,7 @@ bool CCombatPhrase::launch() { H_AUTO(CCombatPhrase_launch); - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; _ApplyDate = 0; if ( !_Attacker ) @@ -2183,7 +2183,7 @@ bool CCombatPhrase::launch() } else { - _LatencyEndDate = (double)time + latency; + _LatencyEndDate = (double)time + latency; } // compute the apply date if (_Targets[0].Target!=NULL && actingEntity->getEntityRowId() == _Targets[0].Target->getEntityRowId()) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp index 5cd4a5c82..8895f48b9 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/magic_phrase.cpp @@ -1568,7 +1568,7 @@ bool CMagicPhrase::launch() if (_DivineInterventionOccured||_ShootAgainOccured?_BaseCastingTime:_CastingTime) _LatencyEndDate = (double)time + PostCastLatency + _PostCastTime; else - _LatencyEndDate = 0.0f + _PostCastTime; + _LatencyEndDate = 0.0 + _PostCastTime; // compute the apply date if ( !_Targets.empty() && _ActorRowId != _Targets[0].getId()) @@ -1898,7 +1898,7 @@ void CMagicPhrase::enchantPhrase(CCharacter * user,float successFactor) _Targets.resize(1); // user->setActionFlag( RYZOMACTIONFLAGS::Attacks, true ); - _LatencyEndDate = 0.0f;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ; + _LatencyEndDate = 0.0;//time + _HitRateModifier + weapon.LatencyInTicks + ammo.SpeedInTicks ; // _BeingProcessed = false; } // enchantPhrase // diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp index c8d55ad72..cf6581464 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/phrase_manager.cpp @@ -459,11 +459,12 @@ void CPhraseManager::updatePhrases() CSPhrase::TPhraseState old_state; do { - old_state = phrase->state(); - updateEntityCurrentAction( (*it).first, entityPhrases); - phrase = entityPhrases.getCurrentAction(); - //Every time we get the next action, th phrase might be deleted (if the action is invalid or finished for non-cyclic actions like digging / crafting), always check ! - } while(phrase != NULL && old_state != phrase->state()); + old_state = phrase->state(); + updateEntityCurrentAction( (*it).first, entityPhrases); + phrase = entityPhrases.getCurrentAction(); + //Every time we get the next action, th phrase might be deleted (if the action is invalid or finished for non-cyclic actions like digging / crafting), always check ! + } + while(phrase != NULL && old_state != phrase->state()); // get next entity sentences ++it; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h index e2164f34d..3edff92ad 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/s_phrase.h @@ -56,7 +56,7 @@ public: _Idle = false; _ExecutionEndDate = 0; _ApplyDate = ~0; // ensure apply() never called before launch() - _LatencyEndDate = 0.0f; // by default, time between apply() and end() is immediate + _LatencyEndDate = 0.0; // by default, time between apply() and end() is immediate _PhraseBookIndex = 0; _NextCounter = 0; _IsStatic = false; diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp index 4bf951737..7e24f427e 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/special_power_phrase.cpp @@ -758,7 +758,7 @@ bool CSpecialPowerPhrase::launch() //----------------------------------------------- void CSpecialPowerPhrase::apply() { - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; // TODO // apply effect From b19f5e3c7e034aa2223a5f0319318b21b5c43b4a Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Thu, 20 Oct 2016 16:04:47 +0200 Subject: [PATCH 9/9] Forgot one 0.0f initialisation --HG-- branch : fix_speed --- .../phrase_manager/timed_action_phrase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp index 16177ff8a..8a1ba51fc 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/timed_action_phrase.cpp @@ -279,7 +279,7 @@ void CTimedActionPhrase::apply() // keep a ptr on this to prevent it to be deleted when timed action is deconnection CSPhrasePtr selfPtr = this; - _LatencyEndDate = 0.0f; + _LatencyEndDate = 0.0; CEntityBase *actor = CEntityBaseManager::getEntityBasePtr(_ActorRowId); if (!actor)