From 02316b9e8dc00b325d83f91d9c2b23743c8c9b71 Mon Sep 17 00:00:00 2001 From: Guillaume Dupuy Date: Sat, 15 Oct 2016 20:12:41 +0200 Subject: [PATCH] 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