Cleanup: drop Server::hudGetHotbarImage()
authorLoic Blot <loic.blot@unix-experience.fr>
Thu, 8 Mar 2018 21:05:47 +0000 (22:05 +0100)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 8 Mar 2018 22:00:17 +0000 (23:00 +0100)
Call directly accessible RemotePlayer::getHotbarImage() from server api & make it const ref

src/remoteplayer.h
src/script/lua_api/l_object.cpp
src/server.cpp
src/server.h

index 6ecdb2798d932b21b31ff62219353b82658ebada..ed0f21b424c07432051664fea1533728f32ae8c3 100644 (file)
@@ -71,7 +71,7 @@ public:
 
        void setHotbarImage(const std::string &name) { hud_hotbar_image = name; }
 
-       std::string getHotbarImage() const { return hud_hotbar_image; }
+       const std::string &getHotbarImage() const { return hud_hotbar_image; }
 
        void setHotbarSelectedImage(const std::string &name)
        {
index ce2bce85e35c6ed5e3a07c1d932ed4d25a2e2afe..13b538f0ca0262ff0da1f9eaf6b94b5a66092beb 100644 (file)
@@ -1490,7 +1490,7 @@ int ObjectRef::l_hud_get_hotbar_image(lua_State *L)
        if (player == NULL)
                return 0;
 
-       std::string name = getServer(L)->hudGetHotbarImage(player);
+       const std::string &name = player->getHotbarImage();
        lua_pushlstring(L, name.c_str(), name.size());
        return 1;
 }
index aa0961f9a930bb2c223b95bfc8e21e5defed003f..fbd656f37ea3127f6e6ddeb2d5648cbc7768d3bb 100644 (file)
@@ -3099,13 +3099,6 @@ void Server::hudSetHotbarImage(RemotePlayer *player, std::string name)
        SendHUDSetParam(player->getPeerId(), HUD_PARAM_HOTBAR_IMAGE, name);
 }
 
-std::string Server::hudGetHotbarImage(RemotePlayer *player)
-{
-       if (!player)
-               return "";
-       return player->getHotbarImage();
-}
-
 void Server::hudSetHotbarSelectedImage(RemotePlayer *player, std::string name)
 {
        if (!player)
index c189860a580d7043c6e578452f30940d7af2e561..7b3fe61e2c1277f0b966f96a8140a53255be2983 100644 (file)
@@ -291,7 +291,6 @@ public:
        bool hudSetFlags(RemotePlayer *player, u32 flags, u32 mask);
        bool hudSetHotbarItemcount(RemotePlayer *player, s32 hotbar_itemcount);
        void hudSetHotbarImage(RemotePlayer *player, std::string name);
-       std::string hudGetHotbarImage(RemotePlayer *player);
        void hudSetHotbarSelectedImage(RemotePlayer *player, std::string name);
        const std::string &hudGetHotbarSelectedImage(RemotePlayer *player) const;