1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Client-side prediction of inventory changes, and some inventory menu fixes

This commit is contained in:
Kahrl 2012-01-22 00:49:02 +01:00 committed by Perttu Ahola
parent 1efdc36b22
commit b4dd5d3bd7
8 changed files with 210 additions and 57 deletions

View file

@ -2372,6 +2372,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
return;
}
/*
Note: Always set inventory not sent, to repair cases
where the client made a bad prediction.
*/
/*
Handle restrictions and special cases of the move action
*/
@ -2382,6 +2387,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
ma->from_inv.applyCurrentPlayer(player->getName());
ma->to_inv.applyCurrentPlayer(player->getName());
setInventoryModified(ma->from_inv);
setInventoryModified(ma->to_inv);
bool from_inv_is_current_player =
(ma->from_inv.type == InventoryLocation::PLAYER) &&
(ma->from_inv.name == player->getName());
@ -2461,6 +2469,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
da->from_inv.applyCurrentPlayer(player->getName());
setInventoryModified(da->from_inv);
// Disallow dropping items if not allowed to interact
if((getPlayerPrivs(player) & PRIV_INTERACT) == 0)
{
@ -2490,6 +2500,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
ca->craft_inv.applyCurrentPlayer(player->getName());
setInventoryModified(ca->craft_inv);
//bool craft_inv_is_current_player =
// (ca->craft_inv.type == InventoryLocation::PLAYER) &&
// (ca->craft_inv.name == player->getName());