diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-09-30 00:17:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 00:17:03 +0200 |
commit | 028a5735c5f98aa10718c94de07d2f4b4c1fa6b3 (patch) | |
tree | 53d4bdd7c5c3f9abd6416b27ba893341a042ffea /src/Entities/Minecart.cpp | |
parent | Permission-based player chat message formatting (#5304) (diff) | |
download | cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.gz cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.bz2 cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.lz cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.xz cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.tar.zst cuberite-028a5735c5f98aa10718c94de07d2f4b4c1fa6b3.zip |
Diffstat (limited to 'src/Entities/Minecart.cpp')
-rw-r--r-- | src/Entities/Minecart.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index 123965916..c8dadbcdd 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -24,17 +24,17 @@ class cMinecartAttachCallback { public: - cMinecartAttachCallback(cMinecart * a_Minecart, cEntity * a_Attachee) : + cMinecartAttachCallback(cMinecart & a_Minecart, cEntity * a_Attachee) : m_Minecart(a_Minecart), m_Attachee(a_Attachee) { } - bool operator () (cEntity & a_Entity) + bool operator()(cEntity & a_Entity) { - // Check if minecart is empty and if given entity is a mob - if ((m_Attachee == nullptr) && (a_Entity.IsMob())) + // Check if minecart is empty and if given entity is a mob: + if ((m_Attachee == nullptr) && a_Entity.IsMob()) { - // if so, attach to minecart and return true + // If so, attach to minecart and stop iterating: a_Entity.AttachTo(m_Minecart); return true; } @@ -42,7 +42,8 @@ public: } protected: - cMinecart * m_Minecart; + + cMinecart & m_Minecart; cEntity * m_Attachee; }; @@ -1084,7 +1085,7 @@ bool cMinecart::TestEntityCollision(NIBBLETYPE a_RailMeta) } // Collision was true, create bounding box for minecart, call attach callback for all entities within that box - cMinecartAttachCallback MinecartAttachCallback(this, m_Attachee); + cMinecartAttachCallback MinecartAttachCallback(*this, m_Attachee); Vector3d MinecartPosition = GetPosition(); cBoundingBox bbMinecart(Vector3d(MinecartPosition.x, floor(MinecartPosition.y), MinecartPosition.z), GetWidth() / 2, GetHeight()); m_World->ForEachEntityInBox(bbMinecart, MinecartAttachCallback); @@ -1350,8 +1351,8 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player) m_Attachee->Detach(); } - // Attach the player to this minecart - a_Player.AttachTo(this); + // Attach the player to this minecart: + a_Player.AttachTo(*this); } |