summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-29 17:48:56 +0200
committerMattes D <github@xoft.cz>2014-07-29 17:48:56 +0200
commit30e64ed4d82c9ef9ac0797a443d07c3f62649b54 (patch)
tree32ff101a034c0af7d8b4067744b367fcc08e5751 /src/Entities/Entity.h
parentMerge pull request #1254 from mc-server/SingleTopBlockFinisher (diff)
parentDetrailed whitespace (diff)
downloadcuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.gz
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.bz2
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.lz
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.xz
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.tar.zst
cuberite-30e64ed4d82c9ef9ac0797a443d07c3f62649b54.zip
Diffstat (limited to 'src/Entities/Entity.h')
-rw-r--r--src/Entities/Entity.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index efca60a6c..e66194ca2 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -336,6 +336,11 @@ public:
/** Detects the time for application of cacti damage */
virtual void DetectCacti(void);
+
+ /** Detects whether we are in a portal block and begins teleportation procedures if so
+ Returns true if MoveToWorld() was called, false if not
+ */
+ virtual bool DetectPortal(void);
/// Handles when the entity is in the void
virtual void TickInVoid(cChunk & a_Chunk);
@@ -378,8 +383,22 @@ public:
/// Teleports to the coordinates specified
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
+
+ /** Moves entity to specified world, taking a world pointer */
+ bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) { return DoMoveToWorld(a_World, a_ShouldSendRespawn); }
+
+ /** Moves entity to specified world, taking a world name */
+ bool MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn = true);
// tolua_end
+
+ virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn);
+
+ /** Returns if the entity is travelling away from a specified world */
+ bool IsWorldTravellingFrom(cWorld * a_World) const { return (m_WorldTravellingFrom == a_World); }
+
+ /** Sets the world the entity will be leaving */
+ void SetWorldTravellingFrom(cWorld * a_World) { m_WorldTravellingFrom = a_World; }
/// Updates clients of changes in the entity.
virtual void BroadcastMovementUpdate(const cClientHandle * a_Exclude = NULL);
@@ -482,6 +501,12 @@ 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 NULL 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;
cWorld * m_World;
@@ -503,7 +528,6 @@ protected:
/// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
int m_TicksSinceLastVoidDamage;
-
/** 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. */
@@ -523,6 +547,21 @@ protected:
/** 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;