Optimize interaction distance checker (#8193)
authorJozef Behran <jozuejozef@gmail.com>
Thu, 7 Mar 2019 07:19:13 +0000 (02:19 -0500)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 7 Mar 2019 07:19:13 +0000 (08:19 +0100)
The "what" parameter is being passed by value, most likely by
accident as the type is "const std::string". Convert it to a
reference by adding the missing "&".

src/network/serverpackethandler.cpp
src/server.h

index 6f17d666a7c828c5819d6712c953da6538414f03..7e9495d16ce240bdfc5dace9d308d25c4c910d45 100644 (file)
@@ -952,7 +952,7 @@ void Server::handleCommand_Respawn(NetworkPacket* pkt)
        // the previous addition has been successfully removed
 }
 
-bool Server::checkInteractDistance(RemotePlayer *player, const f32 d, const std::string what)
+bool Server::checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what)
 {
        PlayerSAO *playersao = player->getPlayerSAO();
        const InventoryList *hlist = playersao->getInventory()->getList("hand");
index 0a3e48072b2fead374149cc3f04b066f6c9d510c..5949d9bf153eb9c099ee1830c5ea2a33bcebd09b 100644 (file)
@@ -477,7 +477,7 @@ private:
        void RespawnPlayer(session_t peer_id);
        void DeleteClient(session_t peer_id, ClientDeletionReason reason);
        void UpdateCrafting(RemotePlayer *player);
-       bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string what);
+       bool checkInteractDistance(RemotePlayer *player, const f32 d, const std::string &what);
 
        void handleChatInterfaceEvent(ChatEvent *evt);