From 054a89dd9e5d6819adede9d7ba781b69f98ff2f4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 6 Jan 2021 00:35:42 +0000 Subject: Clarify cClientHandle, cPlayer ownership semantics + A cPlayer, once created, has a strong pointer to the cClientHandle. The player ticks the clienthandle. If he finds the handle destroyed, he destroys himself in turn. Nothing else can kill the player. * The client handle has a pointer to the player. Once a player is created, the client handle never outlasts the player, nor does it manage the player's lifetime. The pointer is always safe to use after FinishAuthenticate, which is also the point where cProtocol is put into the Game state that allows player manipulation. + Entities are once again never lost by constructing a chunk when they try to move into one that doesn't exist. * Fixed a forgotten Super invocation in cPlayer::OnRemoveFromWorld. * Fix SaveToDisk usage in destructor by only saving things cPlayer owns, instead of accessing cWorld. --- src/Entities/Entity.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/Entities/Entity.h') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 85cf35661..cbefc764c 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -81,7 +81,6 @@ protected: cWorld * m_NewWorld; Vector3d m_NewPosition; bool m_SetPortalCooldown; - bool m_SendRespawn; }; public: @@ -173,7 +172,7 @@ public: /** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed). Adds the entity to the world. */ - virtual bool Initialize(OwnedEntity a_Self, cWorld & a_EntityWorld); + bool Initialize(OwnedEntity a_Self, cWorld & a_EntityWorld); /** Called when the entity is added to a world. e.g after first spawning or after successfuly moving between worlds. @@ -469,13 +468,6 @@ public: /** Teleports to the coordinates specified */ virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ); - /** Schedules a MoveToWorld call to occur on the next Tick of the entity */ - [[deprecated]] void ScheduleMoveToWorld(cWorld & a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown = false, bool a_ShouldSendRespawn = true) - { - LOGWARNING("ScheduleMoveToWorld is deprecated, use MoveToWorld instead"); - MoveToWorld(a_World, a_NewPosition, a_ShouldSetPortalCooldown, a_ShouldSendRespawn); - } - bool MoveToWorld(cWorld & a_World, Vector3d a_NewPosition, bool a_ShouldSetPortalCooldown = false, bool a_ShouldSendRespawn = true); bool MoveToWorld(cWorld & a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition) @@ -718,7 +710,7 @@ protected: /** Handles the moving of this entity between worlds. Should handle degenerate cases such as moving to the same world. */ - virtual void DoMoveToWorld(const sWorldChangeInfo & a_WorldChangeInfo); + void DoMoveToWorld(const sWorldChangeInfo & a_WorldChangeInfo); /** Applies friction to an entity @param a_Speed The speed vector to apply changes to -- cgit v1.2.3