Use double instead of float to allow big values of GameCycle (like on winchgate server)

--HG--
branch : fix_speed
This commit is contained in:
Guillaume Dupuy 2016-10-15 20:12:41 +02:00
parent 2818e9339d
commit 02316b9e8d
7 changed files with 16 additions and 17 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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)
}

View file

@ -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;

View file

@ -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