aboutsummaryrefslogtreecommitdiff
path: root/src/client/client.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-08-07 19:16:31 +0200
committerGitHub <noreply@github.com>2019-08-07 19:16:31 +0200
commite462a9a5ef46776d974203bb44e0b89e8c980b29 (patch)
tree4562ef5587bd896890d843877031d5818de19bbc /src/client/client.cpp
parent003af7421352ec1b8ba0d230b807862e1e4cc7e9 (diff)
downloadminetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.gz
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.tar.bz2
minetest-e462a9a5ef46776d974203bb44e0b89e8c980b29.zip
Unify wield item handling (#8677)
This moves the wield item functions to Player and the tool utils for range calculation Also 'local_inventory' was removed due to redundancy in Client
Diffstat (limited to 'src/client/client.cpp')
-rw-r--r--src/client/client.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp
index 4dc05dc09..430784b95 100644
--- a/src/client/client.cpp
+++ b/src/client/client.cpp
@@ -940,7 +940,7 @@ void Client::interact(u8 action, const PointedThing& pointed)
NetworkPacket pkt(TOSERVER_INTERACT, 1 + 2 + 0);
pkt << action;
- pkt << (u16)getPlayerItem();
+ pkt << myplayer->getWieldIndex();
std::ostringstream tmp_os(std::ios::binary);
pointed.serialize(tmp_os);
@@ -1277,19 +1277,6 @@ void Client::sendPlayerPos()
Send(&pkt);
}
-void Client::sendPlayerItem(u16 item)
-{
- LocalPlayer *myplayer = m_env.getLocalPlayer();
- if (!myplayer)
- return;
-
- NetworkPacket pkt(TOSERVER_PLAYERITEM, 2);
-
- pkt << item;
-
- Send(&pkt);
-}
-
void Client::removeNode(v3s16 p)
{
std::map<v3s16, MapBlock*> modified_blocks;
@@ -1349,11 +1336,14 @@ void Client::setPlayerControl(PlayerControl &control)
player->control = control;
}
-void Client::selectPlayerItem(u16 item)
+void Client::setPlayerItem(u16 item)
{
- m_playeritem = item;
+ m_env.getLocalPlayer()->setWieldIndex(item);
m_inventory_updated = true;
- sendPlayerItem(item);
+
+ NetworkPacket pkt(TOSERVER_PLAYERITEM, 2);
+ pkt << item;
+ Send(&pkt);
}
// Returns true if the inventory of the local player has been