From 283b9d706c8a1fffb7d85147ddc46d4d8651ba20 Mon Sep 17 00:00:00 2001 From: 12xx12 <44411062+12xx12@users.noreply.github.com> Date: Fri, 13 Nov 2020 22:50:46 +0100 Subject: [PATCH] Some const and inheritance correctness (#5014) * Some const and inheritance correctness * Devirtualise SendBlockTo(Vector3i) Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Tiger Wang --- src/World.cpp | 2 +- src/World.h | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/World.cpp b/src/World.cpp index 561adc4d0..bd1a52a7d 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -486,7 +486,7 @@ void cWorld::CastThunderbolt(Vector3i a_Block) -int cWorld::GetDefaultWeatherInterval(eWeather a_Weather) +int cWorld::GetDefaultWeatherInterval(eWeather a_Weather) const { auto & Random = GetRandomProvider(); switch (a_Weather) diff --git a/src/World.h b/src/World.h index e1d2a1abf..58d814d06 100644 --- a/src/World.h +++ b/src/World.h @@ -140,7 +140,7 @@ public: /** Returns the default weather interval for the specific weather type. Returns -1 for any unknown weather. */ - int GetDefaultWeatherInterval(eWeather a_Weather); + int GetDefaultWeatherInterval(eWeather a_Weather) const; /** Returns the current game mode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */ eGameMode GetGameMode(void) const { return m_GameMode; } @@ -666,6 +666,8 @@ public: /** Retrieves block types of the specified blocks. If a chunk is not loaded, doesn't modify the block. Returns true if all blocks were read. */ bool GetBlocks(sSetBlockVector & a_Blocks, bool a_ContinueOnFailure); + using cWorldInterface::SendBlockTo; + // tolua_begin /** Replaces the specified block with air, and calls the OnBroken block handler. @@ -697,14 +699,9 @@ public: Returns an empty cItems object if the chunk is not present. */ cItems PickupsFromBlock(Vector3i a_BlockPos, const cEntity * a_Digger = nullptr, const cItem * a_Tool = nullptr); - virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player) override; - /** Sends the block at the specified coords to the player. Used mainly when plugins disable block-placing or block-breaking, to restore the previous block. */ - void SendBlockTo(const Vector3i a_BlockPos, cPlayer & a_Player) - { - SendBlockTo(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Player); - } + virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player) override; /** Set default spawn at the given coordinates. Returns false if the new spawn couldn't be stored in the INI file. */