Skip to content

Commit

Permalink
Cleanup: drop Server::hudGetHotbarImage()
Browse files Browse the repository at this point in the history
Call directly accessible RemotePlayer::getHotbarImage() from server api & make it const ref
  • Loading branch information
nerzhul committed Mar 8, 2018
1 parent 373f1bf commit 4be46ae
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/remoteplayer.h
Expand Up @@ -71,7 +71,7 @@ class RemotePlayer : public Player

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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_object.cpp
Expand Up @@ -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;
}
Expand Down
7 changes: 0 additions & 7 deletions src/server.cpp
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/server.h
Expand Up @@ -291,7 +291,6 @@ class Server : public con::PeerHandler, public MapEventReceiver,
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;

Expand Down

0 comments on commit 4be46ae

Please sign in to comment.