1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-21 11:55:43 +02:00

Clamp hotbar selection to slots that exist (#14869)

This commit is contained in:
1F616EMO~nya
2024-08-12 21:35:13 +08:00
committed by GitHub
parent 39c2af9710
commit 98e51a0159
8 changed files with 51 additions and 11 deletions

View File

@@ -852,11 +852,11 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
*pkt >> item;
if (item >= player->getHotbarItemcount()) {
if (item >= player->getMaxHotbarItemcount()) {
actionstream << "Player: " << player->getName()
<< " tried to access item=" << item
<< " out of hotbar_itemcount="
<< player->getHotbarItemcount()
<< player->getMaxHotbarItemcount()
<< "; ignoring." << std::endl;
return;
}
@@ -983,11 +983,11 @@ void Server::handleCommand_Interact(NetworkPacket *pkt)
// Update wielded item
if (item_i >= player->getHotbarItemcount()) {
if (item_i >= player->getMaxHotbarItemcount()) {
actionstream << "Player: " << player->getName()
<< " tried to access item=" << item_i
<< " out of hotbar_itemcount="
<< player->getHotbarItemcount()
<< player->getMaxHotbarItemcount()
<< "; ignoring." << std::endl;
return;
}