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/Boat.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 '')
-rw-r--r-- | src/Entities/Boat.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp index cd66c523b..9ad0dd5f9 100644 --- a/src/Entities/Boat.cpp +++ b/src/Entities/Boat.cpp @@ -17,17 +17,18 @@ class cBoatCollisionCallback { public: - cBoatCollisionCallback(cBoat * a_Boat, cEntity * a_Attachee) : + + cBoatCollisionCallback(cBoat & a_Boat, cEntity * a_Attachee) : m_Boat(a_Boat), m_Attachee(a_Attachee) { } bool operator()(cEntity & a_Entity) { - // Checks if boat is empty and if given entity is a mob - if ((m_Attachee == nullptr) && (a_Entity.IsMob())) + // Checks if boat is empty and if given entity is a mob: + if ((m_Attachee == nullptr) && a_Entity.IsMob()) { - // if so attach and return true + // If so attach and stop iterating: a_Entity.AttachTo(m_Boat); return true; } @@ -36,7 +37,8 @@ public: } protected: - cBoat * m_Boat; + + cBoat & m_Boat; cEntity * m_Attachee; }; @@ -159,7 +161,7 @@ void cBoat::OnRightClicked(cPlayer & a_Player) } // Attach the player to this boat - a_Player.AttachTo(this); + a_Player.AttachTo(*this); } @@ -349,7 +351,7 @@ void cBoat::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) normal physics calcualtions */ // Calculate boat's bounding box, run collision callback on all entities in said box - cBoatCollisionCallback BoatCollisionCallback(this, m_Attachee); + cBoatCollisionCallback BoatCollisionCallback(*this, m_Attachee); Vector3d BoatPosition = GetPosition(); cBoundingBox bbBoat( Vector3d(BoatPosition.x, floor(BoatPosition.y), BoatPosition.z), GetWidth() / 2, GetHeight()); |