Prevent interacting with items out of the hotbar (#10359)
parent
9faeca3290
commit
6dcc9e6331
|
@ -869,6 +869,15 @@ void Server::handleCommand_PlayerItem(NetworkPacket* pkt)
|
||||||
|
|
||||||
*pkt >> item;
|
*pkt >> item;
|
||||||
|
|
||||||
|
if (item >= player->getHotbarItemcount()) {
|
||||||
|
actionstream << "Player: " << player->getName()
|
||||||
|
<< " tried to access item=" << item
|
||||||
|
<< " out of hotbar_itemcount="
|
||||||
|
<< player->getHotbarItemcount()
|
||||||
|
<< "; ignoring." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
playersao->getPlayer()->setWieldIndex(item);
|
playersao->getPlayer()->setWieldIndex(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -984,6 +993,16 @@ void Server::handleCommand_Interact(NetworkPacket *pkt)
|
||||||
v3f player_pos = playersao->getLastGoodPosition();
|
v3f player_pos = playersao->getLastGoodPosition();
|
||||||
|
|
||||||
// Update wielded item
|
// Update wielded item
|
||||||
|
|
||||||
|
if (item_i >= player->getHotbarItemcount()) {
|
||||||
|
actionstream << "Player: " << player->getName()
|
||||||
|
<< " tried to access item=" << item_i
|
||||||
|
<< " out of hotbar_itemcount="
|
||||||
|
<< player->getHotbarItemcount()
|
||||||
|
<< "; ignoring." << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
playersao->getPlayer()->setWieldIndex(item_i);
|
playersao->getPlayer()->setWieldIndex(item_i);
|
||||||
|
|
||||||
// Get pointed to object (NULL if not POINTEDTYPE_OBJECT)
|
// Get pointed to object (NULL if not POINTEDTYPE_OBJECT)
|
||||||
|
|
Loading…
Reference in New Issue