1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00: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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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;
}