From: Giuseppe Bilotta Date: Wed, 10 Aug 2011 16:31:44 +0000 (+0200) Subject: Keep track of player item X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=91d1186cbb0e651de919e17e6808c75c20a0ef6f;p=zefram%2Fminetest%2Fminetest_engine.git Keep track of player item --- diff --git a/src/client.cpp b/src/client.cpp index 30bd1019..2687d01e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1953,6 +1953,14 @@ void Client::setPlayerControl(PlayerControl &control) player->control = control; } +void Client::selectPlayerItem(u16 item) +{ + LocalPlayer *player = m_env.getLocalPlayer(); + assert(player != NULL); + + player->wieldItem(item); +} + // Returns true if the inventory of the local player has been // updated from the server. If it is true, it is set to false. bool Client::getLocalInventoryUpdated() diff --git a/src/client.h b/src/client.h index 1c71b2c2..d21764f7 100644 --- a/src/client.h +++ b/src/client.h @@ -211,7 +211,9 @@ public: v3f getPlayerPosition(v3f *eye_position=NULL); void setPlayerControl(PlayerControl &control); - + + void selectPlayerItem(u16 item); + // Returns true if the inventory of the local player has been // updated from the server. If it is true, it is set to false. bool getLocalInventoryUpdated(); diff --git a/src/game.cpp b/src/game.cpp index 65f160f7..147a1fa0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2200,6 +2200,7 @@ void the_game( if(client.getLocalInventoryUpdated() || g_selected_item != old_selected_item) { + client.selectPlayerItem(g_selected_item); old_selected_item = g_selected_item; //std::cout<<"Updating local inventory"<getItem(m_selected_item); + return NULL; + } + const char * getName() { return m_name; @@ -146,6 +155,7 @@ public: protected: char m_name[PLAYERNAME_SIZE]; + u16 m_selected_item; f32 m_pitch; f32 m_yaw; v3f m_speed;