Skip to content

Commit 3693b68

Browse files
authored
Prevent players accessing inventories of other players (#10341)
1 parent d28f1b0 commit 3693b68

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Diff for: src/network/serverpackethandler.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,19 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
630630
if (ma->from_inv != ma->to_inv)
631631
m_inventory_mgr->setInventoryModified(ma->to_inv);
632632

633-
bool from_inv_is_current_player =
634-
(ma->from_inv.type == InventoryLocation::PLAYER) &&
635-
(ma->from_inv.name == player->getName());
636-
637-
bool to_inv_is_current_player =
638-
(ma->to_inv.type == InventoryLocation::PLAYER) &&
639-
(ma->to_inv.name == player->getName());
633+
bool from_inv_is_current_player = false;
634+
if (ma->from_inv.type == InventoryLocation::PLAYER) {
635+
if (ma->from_inv.name != player->getName())
636+
return;
637+
from_inv_is_current_player = true;
638+
}
639+
640+
bool to_inv_is_current_player = false;
641+
if (ma->to_inv.type == InventoryLocation::PLAYER) {
642+
if (ma->to_inv.name != player->getName())
643+
return;
644+
to_inv_is_current_player = true;
645+
}
640646

641647
InventoryLocation *remote = from_inv_is_current_player ?
642648
&ma->to_inv : &ma->from_inv;

0 commit comments

Comments
 (0)