diff options
author | Mattes D <github@xoft.cz> | 2015-07-31 16:49:10 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-07-31 16:49:10 +0200 |
commit | 6e4122e551eeb41d3e950b363dd837d5586fe560 (patch) | |
tree | b5ee221d8a8e63c7d3b7868da1db19bf717a6ffd /src/Entities | |
parent | Merge pull request #2400 from cuberite/OffloadBadChunks (diff) | |
download | cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar.gz cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar.bz2 cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar.lz cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar.xz cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.tar.zst cuberite-6e4122e551eeb41d3e950b363dd837d5586fe560.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/Entity.cpp | 6 | ||||
-rw-r--r-- | src/Entities/Entity.h | 131 | ||||
-rw-r--r-- | src/Entities/FallingBlock.h | 2 | ||||
-rw-r--r-- | src/Entities/Floater.cpp | 4 | ||||
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 8 | ||||
-rw-r--r-- | src/Entities/SplashPotionEntity.cpp | 6 |
6 files changed, 77 insertions, 80 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 23cc487f6..4bad6b94c 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -1603,7 +1603,6 @@ void cEntity::HandleAir(void) -/// Called when the entity starts burning void cEntity::OnStartedBurning(void) { // Broadcast the change: @@ -1614,7 +1613,6 @@ void cEntity::OnStartedBurning(void) -/// Called when the entity finishes burning void cEntity::OnFinishedBurning(void) { // Broadcast the change: @@ -1625,7 +1623,6 @@ void cEntity::OnFinishedBurning(void) -/// Sets the maximum value for the health void cEntity::SetMaxHealth(int a_MaxHealth) { m_MaxHealth = a_MaxHealth; @@ -1638,7 +1635,6 @@ void cEntity::SetMaxHealth(int a_MaxHealth) -/// Sets whether the entity is fireproof void cEntity::SetIsFireproof(bool a_IsFireproof) { m_IsFireproof = a_IsFireproof; @@ -1648,7 +1644,6 @@ void cEntity::SetIsFireproof(bool a_IsFireproof) -/// Puts the entity on fire for the specified amount of ticks void cEntity::StartBurning(int a_TicksLeftBurning) { if (m_TicksLeftBurning > 0) @@ -1666,7 +1661,6 @@ void cEntity::StartBurning(int a_TicksLeftBurning) -/// Stops the entity from burning, resets all burning timers void cEntity::StopBurning(void) { bool HasBeenBurning = (m_TicksLeftBurning > 0); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index f54e130eb..6024a5de5 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -173,7 +173,7 @@ public: bool IsItemFrame (void) const { return (m_EntityType == etItemFrame); } bool IsPainting (void) const { return (m_EntityType == etPainting); } - /// Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) + /** Returns true if the entity is of the specified class or a subclass (cPawn's IsA("cEntity") returns true) */ virtual bool IsA(const char * a_ClassName) const; /** Returns the class name of this class */ @@ -255,16 +255,16 @@ public: inline UInt32 GetUniqueID(void) const { return m_UniqueID; } inline bool IsDestroyed(void) const { return !m_IsInitialized; } - /// Schedules the entity for destroying; if a_ShouldBroadcast is set to true, broadcasts the DestroyEntity packet + /** Schedules the entity for destroying; if a_ShouldBroadcast is set to true, broadcasts the DestroyEntity packet */ void Destroy(bool a_ShouldBroadcast = true); - /// Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called + /** Makes this pawn take damage from an attack by a_Attacker. Damage values are calculated automatically and DoTakeDamage() called */ void TakeDamage(cEntity & a_Attacker); - /// Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called + /** Makes this entity take the specified damage. The final damage is calculated using current armor, then DoTakeDamage() called */ void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, double a_KnockbackAmount); - /// Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() + /** Makes this entity take the specified damage. The values are packed into a TDI, knockback calculated, then sent through DoTakeDamage() */ void TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount); float GetGravity(void) const { return m_Gravity; } @@ -275,10 +275,10 @@ public: void SetAirDrag(float a_AirDrag) { m_AirDrag = a_AirDrag; } - /// Sets the rotation to match the speed vector (entity goes "face-forward") + /** Sets the rotation to match the speed vector (entity goes "face-forward") */ void SetYawFromSpeed(void); - /// Sets the pitch to match the speed vector (entity gies "face-forward") + /** Sets the pitch to match the speed vector (entity gies "face-forward") */ void SetPitchFromSpeed(void); // tolua_end @@ -290,56 +290,56 @@ public: // tolua_begin - /// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items + /** Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items */ virtual int GetRawDamageAgainst(const cEntity & a_Receiver); - /** Returns whether armor will protect against the passed damage type **/ + /** Returns whether armor will protect against the passed damage type */ virtual bool ArmorCoversAgainst(eDamageType a_DamageType); - /// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover + /** Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover */ virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage); - /// Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit + /** Returns the knockback amount that the currently equipped items would cause to a_Receiver on a hit */ virtual double GetKnockbackAmountAgainst(const cEntity & a_Receiver); - /// Returns the curently equipped weapon; empty item if none + /** Returns the curently equipped weapon; empty item if none */ virtual cItem GetEquippedWeapon(void) const { return cItem(); } - /// Returns the currently equipped helmet; empty item if none + /** Returns the currently equipped helmet; empty item if none */ virtual cItem GetEquippedHelmet(void) const { return cItem(); } - /// Returns the currently equipped chestplate; empty item if none + /** Returns the currently equipped chestplate; empty item if none */ virtual cItem GetEquippedChestplate(void) const { return cItem(); } - /// Returns the currently equipped leggings; empty item if none + /** Returns the currently equipped leggings; empty item if none */ virtual cItem GetEquippedLeggings(void) const { return cItem(); } - /// Returns the currently equipped boots; empty item if none + /** Returns the currently equipped boots; empty item if none */ virtual cItem GetEquippedBoots(void) const { return cItem(); } - /// Called when the health drops below zero. a_Killer may be nullptr (environmental damage) + /** Called when the health drops below zero. a_Killer may be nullptr (environmental damage) */ virtual void KilledBy(TakeDamageInfo & a_TDI); - /// Called when the entity kills another entity + /** Called when the entity kills another entity */ virtual void Killed(cEntity * a_Victim) {} - /// Heals the specified amount of HPs + /** Heals the specified amount of HPs */ virtual void Heal(int a_HitPoints); - /// Returns the health of this entity + /** Returns the health of this entity */ int GetHealth(void) const { return m_Health; } - /// Sets the health of this entity; doesn't broadcast any hurt animation + /** Sets the health of this entity; doesn't broadcast any hurt animation */ void SetHealth(int a_Health); // tolua_end virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); - /// Handles the physics of the entity - updates position based on speed, updates speed based on environment + /** Handles the physics of the entity - updates position based on speed, updates speed based on environment */ virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk); - /// Updates the state related to this entity being on fire + /** Updates the state related to this entity being on fire */ virtual void TickBurning(cChunk & a_Chunk); /** Detects the time for application of cacti damage */ @@ -380,8 +380,7 @@ public: // tolua_end /** Descendants override this function to send a command to the specified client to spawn the entity on the client. - To spawn on all eligible clients, use cChunkMap::BroadcastSpawnEntity() - */ + To spawn on all eligible clients, use cChunkMap::BroadcastSpawnEntity() */ virtual void SpawnOn(cClientHandle & a_Client) = 0; // tolua_begin @@ -413,22 +412,22 @@ public: /** Sets the world the entity will be leaving */ void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; } - /// Updates clients of changes in the entity. + /** Updates clients of changes in the entity. */ virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = nullptr); - /// Attaches to the specified entity; detaches from any previous one first + /** Attaches to the specified entity; detaches from any previous one first */ void AttachTo(cEntity * a_AttachTo); - /// Detaches from the currently attached entity, if any + /** Detaches from the currently attached entity, if any */ virtual void Detach(void); - /// Makes sure head yaw is not over the specified range. + /** Makes sure head yaw is not over the specified range. */ void WrapHeadYaw(); - /// Makes sure rotation is not over the specified range. + /** Makes sure rotation is not over the specified range. */ void WrapRotation(); - /// Makes speed is not over 20. Max speed is 20 blocks / second + /** Makes speed is not over 20. Max speed is 20 blocks / second */ void WrapSpeed(); // tolua_begin @@ -443,8 +442,10 @@ public: /** Returns whether the player is swimming or not */ virtual bool IsSwimming(void) const{ return m_IsSwimming; } + /** Return whether the player is under water or not */ virtual bool IsSubmerged(void) const{ return m_IsSubmerged; } + /** Gets remaining air of a monster */ int GetAirLevel(void) const { return m_AirLevel; } @@ -462,10 +463,10 @@ public: // tolua_end - /// Called when the specified player right-clicks this entity + /** Called when the specified player right-clicks this entity */ virtual void OnRightClicked(cPlayer & a_Player) {} - /// Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). + /** Returns the list of drops for this pawn when it is killed. May check a_Killer for special handling (sword of looting etc.). Called from KilledBy(). */ virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = nullptr) { UNUSED(a_Drops); @@ -476,6 +477,17 @@ public: void SetWorld(cWorld * a_World) { m_World = a_World; } protected: + /** Structure storing the portal delay timer and cooldown boolean */ + struct sPortalCooldownData + { + /** Ticks since entry of portal, used to delay teleportation */ + unsigned short m_TicksDelayed; + + /** Whether the entity has just exited the portal, and should therefore not be teleported again. + This prevents teleportation loops, and is reset when the entity has moved out of the portal. */ + bool m_ShouldPreventTeleportation; + }; + static cCriticalSection m_CSCount; static UInt32 m_EntityCount; @@ -490,10 +502,10 @@ protected: int m_Health; int m_MaxHealth; - /// The entity to which this entity is attached (vehicle), nullptr if none + /** The entity to which this entity is attached (vehicle), nullptr if none */ cEntity * m_AttachedTo; - /// The entity which is attached to this entity (rider), nullptr if none + /** The entity which is attached to this entity (rider), nullptr if none */ cEntity * m_Attachee; /** Stores whether head yaw has been set manually */ @@ -526,10 +538,9 @@ protected: /** True when entity is initialised (Initialize()) and false when destroyed pending deletion (Destroy()) */ bool m_IsInitialized; - /** World entity is travelling from - Set to a valid world pointer by MoveToWorld; reset to nullptr when the entity is removed from the old world - Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it - */ + /** World entity is travelling from (such as when using portals). + Set to a valid world pointer by MoveToWorld; reset to nullptr when the entity is removed from the old world. + Can't be a simple boolean as context switches between worlds may leave the new chunk processing (and therefore immediately removing) the entity before the old chunk could remove it. */ cWorld * m_WorldTravellingFrom; eEntityType m_EntityType; @@ -560,6 +571,20 @@ protected: /** Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void. */ int m_TicksSinceLastVoidDamage; + /** If an entity is currently swimming in or submerged under water */ + bool m_IsSwimming, m_IsSubmerged; + + /** Air level of a mobile */ + int m_AirLevel; + int m_AirTickTimer; + + /** Portal delay timer and cooldown boolean data */ + sPortalCooldownData m_PortalCooldownData; + + /** The number of ticks this entity has been alive for */ + long int m_TicksAlive; + + /** Does the actual speed-setting. The default implementation just sets the member variable value; overrides can provide further processing, such as forcing players to move at the given speed. */ virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ); @@ -568,8 +593,7 @@ protected: /** Applies friction to an entity @param a_Speed The speed vector to apply changes to - @param a_SlowdownMultiplier The factor to reduce the speed by - */ + @param a_SlowdownMultiplier The factor to reduce the speed by */ static void ApplyFriction(Vector3d & a_Speed, double a_SlowdownMultiplier, float a_Dt); /** Called in each tick to handle air-related processing i.e. drowning */ @@ -578,31 +602,6 @@ protected: /** Called once per tick to set IsSwimming and IsSubmerged */ virtual void SetSwimState(cChunk & a_Chunk); - /** If an entity is currently swimming in or submerged under water */ - bool m_IsSwimming, m_IsSubmerged; - - /** Air level of a mobile */ - int m_AirLevel; - int m_AirTickTimer; - - /** Structure storing the portal delay timer and cooldown boolean */ - struct sPortalCooldownData - { - /** Ticks since entry of portal, used to delay teleportation */ - unsigned short m_TicksDelayed; - - /** Whether the entity has just exited the portal, and should therefore not be teleported again - This prevents teleportation loops, and is reset when the entity has moved out of the portal - */ - bool m_ShouldPreventTeleportation; - }; - - /** Portal delay timer and cooldown boolean data */ - sPortalCooldownData m_PortalCooldownData; - - /** The number of ticks this entity has been alive for */ - long int m_TicksAlive; - private: /** Measured in degrees, [-180, +180) */ double m_HeadYaw; diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h index 884938f4d..0027bfa2a 100644 --- a/src/Entities/FallingBlock.h +++ b/src/Entities/FallingBlock.h @@ -22,7 +22,7 @@ class cFallingBlock : public: CLASS_PROTODEF(cFallingBlock) - /// Creates a new falling block. a_BlockPosition is expected in world coords + /** Creates a new falling block. a_BlockPosition is expected in world coords */ cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta); BLOCKTYPE GetBlockType(void) const { return m_BlockType; } diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index c9e8167ee..29d59e6c4 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -54,10 +54,10 @@ public: return false; } - /// Returns the nearest entity that was hit, after the enumeration has been completed + /** Returns the nearest entity that was hit, after the enumeration has been completed */ cEntity * GetHitEntity(void) const { return m_HitEntity; } - /// Returns true if the callback has encountered a true hit + /** Returns true if the callback has encountered a true hit */ bool HasHit(void) const { return (m_MinCoeff < 1); } protected: diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index 8e2e412dd..064076456 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -29,7 +29,7 @@ -/// Converts an angle in radians into a byte representation used by the network protocol +/** Converts an angle in radians into a byte representation used by the network protocol */ #define ANGLE_TO_PROTO(X) static_cast<Byte>(X * 255 / 360) @@ -190,13 +190,13 @@ public: return false; } - /// Returns the nearest entity that was hit, after the enumeration has been completed + /** Returns the nearest entity that was hit, after the enumeration has been completed */ cEntity * GetHitEntity(void) const { return m_HitEntity; } - /// Returns the line coeff where the hit was encountered, after the enumeration has been completed + /** Returns the line coeff where the hit was encountered, after the enumeration has been completed */ double GetMinCoeff(void) const { return m_MinCoeff; } - /// Returns true if the callback has encountered a true hit + /** Returns true if the callback has encountered a true hit */ bool HasHit(void) const { return (m_MinCoeff < 1); } protected: diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp index 926fd1abe..9d855dfa6 100644 --- a/src/Entities/SplashPotionEntity.cpp +++ b/src/Entities/SplashPotionEntity.cpp @@ -8,9 +8,13 @@ -/// Converts an angle in radians into a byte representation used by the network protocol +/** Converts an angle in radians into a byte representation used by the network protocol */ #define ANGLE_TO_PROTO(X) static_cast<Byte>(X * 255 / 360) + + + + //////////////////////////////////////////////////////////////////////////////// // cSplashPotionEntityCallback: |