[BlockCursor] Fixed inventory update packet. [Client] Small optimization.
This commit is contained in:
parent
58043344f1
commit
633233e57e
6
TODO
6
TODO
@ -1,5 +1,11 @@
|
||||
TODO
|
||||
|
||||
# Multiplayer
|
||||
|
||||
• DONE: Fix right click on blocks
|
||||
• DONE: Spltting a stack in the inventory causes a server crash
|
||||
• TODO: Crafting only works for sticks
|
||||
|
||||
# General
|
||||
|
||||
• TODO: Use Faithful 32x for buttons, backgrounds and font (or use Minecraftia for the latter)
|
||||
|
@ -58,7 +58,7 @@ void InventoryWidget::onMouseEvent(const SDL_Event &event, MouseItemWidget &mous
|
||||
packet << *m_inventory;
|
||||
}
|
||||
else {
|
||||
packet << Network::Command::PlayerInvUpdate;
|
||||
packet << Network::Command::PlayerInvUpdate << m_client.id();
|
||||
packet << *m_inventory;
|
||||
}
|
||||
m_client.send(packet);
|
||||
@ -75,7 +75,7 @@ void InventoryWidget::onMouseEvent(const SDL_Event &event, MouseItemWidget &mous
|
||||
packet << *m_inventory;
|
||||
}
|
||||
else {
|
||||
packet << Network::Command::PlayerInvUpdate;
|
||||
packet << Network::Command::PlayerInvUpdate << m_client.id();
|
||||
packet << *m_inventory;
|
||||
}
|
||||
m_client.send(packet);
|
||||
|
@ -108,8 +108,8 @@ void BlockCursor::onEvent(const SDL_Event &event, const Hotbar &hotbar) {
|
||||
|
||||
// FIXME
|
||||
sf::Packet invPacket;
|
||||
invPacket << Network::Command::PlayerInvUpdate;
|
||||
m_player.serialize(invPacket);
|
||||
invPacket << Network::Command::PlayerInvUpdate << m_client.id();
|
||||
invPacket << m_player.inventory();
|
||||
m_client.send(invPacket);
|
||||
}
|
||||
}
|
||||
@ -157,8 +157,8 @@ void BlockCursor::update(const Hotbar &hotbar, bool useDepthBuffer) {
|
||||
|
||||
// FIXME
|
||||
sf::Packet invPacket;
|
||||
invPacket << Network::Command::PlayerInvUpdate;
|
||||
m_player.serialize(invPacket);
|
||||
invPacket << Network::Command::PlayerInvUpdate << m_client.id();
|
||||
invPacket << m_player.inventory();
|
||||
m_client.send(invPacket);
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ void Client::update() {
|
||||
|
||||
// DEBUG("TCP message received:", Network::commandToString(command));
|
||||
|
||||
for (auto &it : m_commands)
|
||||
if (command == it.first)
|
||||
it.second(packet);
|
||||
auto it = m_commands.find(command);
|
||||
if (it != m_commands.end())
|
||||
it->second(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user