1
0

Initial convertion of a_Dt to std::chrono

also refactored cWorld::m_WorldAge and cWorld::m_TimeOfDay
This commit is contained in:
Tycho
2015-01-11 21:12:26 +00:00
parent 4f75b94c99
commit 2a9664d6ca
117 changed files with 221 additions and 221 deletions

View File

@@ -61,7 +61,7 @@ void cAggressiveMonster::EventSeePlayer(cEntity * a_Entity)
void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
void cAggressiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -93,9 +93,9 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
void cAggressiveMonster::Attack(float a_Dt)
void cAggressiveMonster::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target == nullptr) || (m_AttackInterval < 3.0))
{

View File

@@ -16,11 +16,11 @@ public:
cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(float a_Dt) override;
virtual void EventSeePlayer(cEntity *) override;
virtual void Attack(float a_Dt);
virtual void Attack(std::chrono::milliseconds a_Dt);
protected:
/** Whether this mob's destination is the same as its target's position. */

View File

@@ -30,9 +30,9 @@ void cBlaze::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cBlaze::Attack(float a_Dt)
void cBlaze::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{

View File

@@ -18,5 +18,5 @@ public:
CLASS_PROTODEF(cBlaze)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
} ;

View File

@@ -16,7 +16,7 @@ cCaveSpider::cCaveSpider(void) :
void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
void cCaveSpider::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -27,7 +27,7 @@ void cCaveSpider::Tick(float a_Dt, cChunk & a_Chunk)
void cCaveSpider::Attack(float a_Dt)
void cCaveSpider::Attack(std::chrono::milliseconds a_Dt)
{
super::Attack(a_Dt);

View File

@@ -16,8 +16,8 @@ public:
CLASS_PROTODEF(cCaveSpider)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;

View File

@@ -18,7 +18,7 @@ cChicken::cChicken(void) :
void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
void cChicken::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cChicken)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_SEEDS); }

View File

@@ -23,7 +23,7 @@ cCreeper::cCreeper(void) :
void cCreeper::Tick(float a_Dt, cChunk & a_Chunk)
void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
@@ -119,7 +119,7 @@ bool cCreeper::DoTakeDamage(TakeDamageInfo & a_TDI)
void cCreeper::Attack(float a_Dt)
void cCreeper::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);

View File

@@ -19,8 +19,8 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Attack(float a_Dt) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsBlowing(void) const {return m_bIsBlowing; }

View File

@@ -186,7 +186,7 @@ bool cEnderman::CheckLight()
void cEnderman::Tick(float a_Dt, cChunk & a_Chunk)
void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -21,7 +21,7 @@ public:
virtual void CheckEventSeePlayer(void) override;
virtual void CheckEventLostPlayer(void) override;
virtual void EventLosePlayer(void) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
bool IsScreaming(void) const {return m_bIsScreaming; }
BLOCKTYPE GetCarriedBlock(void) const {return CarriedBlock; }

View File

@@ -32,9 +32,9 @@ void cGhast::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cGhast::Attack(float a_Dt)
void cGhast::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{

View File

@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cGhast)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
bool IsCharging(void) const {return false; }
} ;

View File

@@ -35,7 +35,7 @@ void cGuardian::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cGuardian::Tick(float a_Dt, cChunk & a_Chunk)
void cGuardian::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)

View File

@@ -15,7 +15,7 @@ class cGuardian :
public:
cGuardian();
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
CLASS_PROTODEF(cGuardian)

View File

@@ -30,7 +30,7 @@ cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
void cHorse::Tick(float a_Dt, cChunk & a_Chunk)
void cHorse::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cHorse)
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
bool IsSaddled (void) const {return m_bIsSaddled; }

View File

@@ -252,14 +252,14 @@ bool cMonster::ReachedFinalDestination()
void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
void cMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_Health <= 0)
{
// The mob is dead, but we're still animating the "puff" they leave when they die
m_DestroyTimer += a_Dt / 1000;
m_DestroyTimer += a_Dt.count() / 1000;
if (m_DestroyTimer > 1)
{
Destroy(true);
@@ -275,8 +275,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
// Burning in daylight
HandleDaylightBurning(a_Chunk);
a_Dt /= 1000;
if (m_bMovingToDestination)
{
if (m_bOnGround)
@@ -347,18 +345,18 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
case IDLE:
{
// If enemy passive we ignore checks for player visibility
InStateIdle(a_Dt);
InStateIdle(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}
case CHASING:
{
// If we do not see a player anymore skip chasing action
InStateChasing(a_Dt);
InStateChasing(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}
case ESCAPING:
{
InStateEscaping(a_Dt);
InStateEscaping(std::chrono::duration_cast<std::chrono::seconds>(a_Dt).count());
break;
}

View File

@@ -52,7 +52,7 @@ public:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;

View File

@@ -35,7 +35,7 @@ bool cPassiveMonster::DoTakeDamage(TakeDamageInfo & a_TDI)
void cPassiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
void cPassiveMonster::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -15,7 +15,7 @@ class cPassiveMonster :
public:
cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
/// When hit by someone, run away
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;

View File

@@ -80,7 +80,7 @@ void cPig::OnRightClicked(cPlayer & a_Player)
void cPig::Tick(float a_Dt, cChunk & a_Chunk)
void cPig::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -22,7 +22,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_CARROT); }

View File

@@ -84,7 +84,7 @@ void cSheep::OnRightClicked(cPlayer & a_Player)
void cSheep::Tick(float a_Dt, cChunk & a_Chunk)
void cSheep::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
int PosX = POSX_TOINT;

View File

@@ -24,7 +24,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual const cItem GetFollowedItem(void) const override { return cItem(E_ITEM_WHEAT); }

View File

@@ -67,9 +67,9 @@ void cSkeleton::MoveToPosition(const Vector3d & a_Position)
void cSkeleton::Attack(float a_Dt)
void cSkeleton::Attack(std::chrono::milliseconds a_Dt)
{
m_AttackInterval += a_Dt * m_AttackRate;
m_AttackInterval += a_Dt.count() * m_AttackRate;
if ((m_Target != nullptr) && (m_AttackInterval > 3.0))
{

View File

@@ -19,7 +19,7 @@ public:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void MoveToPosition(const Vector3d & a_Position) override;
virtual void Attack(float a_Dt) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual bool IsUndead(void) override { return true; }

View File

@@ -46,7 +46,7 @@ void cSlime::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSlime::Attack(float a_Dt)
void cSlime::Attack(std::chrono::milliseconds a_Dt)
{
if (m_Size > 1)
{

View File

@@ -20,7 +20,7 @@ public:
// cAggressiveMonster overrides:
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual void Attack(float a_Dt) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
int GetSize(void) const { return m_Size; }

View File

@@ -27,7 +27,7 @@ void cSnowGolem::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSnowGolem::Tick(float a_Dt, cChunk & a_Chunk)
void cSnowGolem::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (IsBiomeNoDownfall(m_World->GetBiomeAt((int) floor(GetPosX()), (int) floor(GetPosZ()))))

View File

@@ -17,7 +17,7 @@ public:
CLASS_PROTODEF(cSnowGolem)
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
} ;

View File

@@ -33,7 +33,7 @@ void cSquid::GetDrops(cItems & a_Drops, cEntity * a_Killer)
void cSquid::Tick(float a_Dt, cChunk & a_Chunk)
void cSquid::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// We must first process current location, and only then tick, otherwise we risk processing a location in a chunk
// that is not where the entity currently resides (FS #411)

View File

@@ -15,7 +15,7 @@ class cSquid :
public:
cSquid();
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
CLASS_PROTODEF(cSquid)

View File

@@ -51,7 +51,7 @@ bool cVillager::DoTakeDamage(TakeDamageInfo & a_TDI)
void cVillager::Tick(float a_Dt, cChunk & a_Chunk)
void cVillager::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -31,7 +31,7 @@ public:
// cEntity overrides
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
virtual void Tick (std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
// cVillager functions
/** return true if the given blocktype are: crops, potatoes or carrots.*/

View File

@@ -66,7 +66,7 @@ bool cWither::DoTakeDamage(TakeDamageInfo & a_TDI)
void cWither::Tick(float a_Dt, cChunk & a_Chunk)
void cWither::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);

View File

@@ -28,7 +28,7 @@ public:
virtual bool Initialize(cWorld & a_World) override;
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) override;
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual bool IsUndead(void) override { return true; }

View File

@@ -43,7 +43,7 @@ bool cWolf::DoTakeDamage(TakeDamageInfo & a_TDI)
void cWolf::Attack(float a_Dt)
void cWolf::Attack(std::chrono::milliseconds a_Dt)
{
UNUSED(a_Dt);
@@ -145,7 +145,7 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
void cWolf::Tick(float a_Dt, cChunk & a_Chunk)
void cWolf::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
if (!IsAngry())
{

View File

@@ -20,9 +20,9 @@ public:
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void TickFollowPlayer();
virtual void Attack(float a_Dt) override;
virtual void Attack(std::chrono::milliseconds a_Dt) override;
// Get functions
bool IsSitting (void) const { return m_IsSitting; }