Client doesn't like to receive multiples SendInventory for one action, this can trigger glitches on clients (sometimes due to incorrect UDP packet ordering due to UDP protocol)
This fix issue #2544
}
}
- mgr->setInventoryModified(from_inv);
+ mgr->setInventoryModified(from_inv, false);
if(inv_from != inv_to)
- mgr->setInventoryModified(to_inv);
+ mgr->setInventoryModified(to_inv, false);
}
void IMoveAction::clientApply(InventoryManager *mgr, IGameDef *gamedef)
if(item2.count != actually_dropped_count)
errorstream<<"Could not take dropped count of items"<<std::endl;
- mgr->setInventoryModified(from_inv);
+ mgr->setInventoryModified(from_inv, false);
}
}
// Get an inventory (server and client)
virtual Inventory* getInventory(const InventoryLocation &loc){return NULL;}
// Set modified (will be saved and sent over network; only on server)
- virtual void setInventoryModified(const InventoryLocation &loc){}
+ virtual void setInventoryModified(const InventoryLocation &loc, bool playerSend = true){}
// Send inventory action to server (only on client)
virtual void inventoryAction(InventoryAction *a){}
};
ma->from_inv.applyCurrentPlayer(player->getName());
ma->to_inv.applyCurrentPlayer(player->getName());
- setInventoryModified(ma->from_inv);
- setInventoryModified(ma->to_inv);
+ setInventoryModified(ma->from_inv, false);
+ setInventoryModified(ma->to_inv, false);
bool from_inv_is_current_player =
(ma->from_inv.type == InventoryLocation::PLAYER) &&
da->from_inv.applyCurrentPlayer(player->getName());
- setInventoryModified(da->from_inv);
+ setInventoryModified(da->from_inv, false);
/*
Disable dropping items out of craftpreview
ca->craft_inv.applyCurrentPlayer(player->getName());
- setInventoryModified(ca->craft_inv);
+ setInventoryModified(ca->craft_inv, false);
//bool craft_inv_is_current_player =
// (ca->craft_inv.type == InventoryLocation::PLAYER) &&
a->apply(this, playersao, this);
// Eat the action
delete a;
+
+ SendInventory(playersao);
}
void Server::handleCommand_ChatMessage(NetworkPacket* pkt)
}
return NULL;
}
-void Server::setInventoryModified(const InventoryLocation &loc)
+void Server::setInventoryModified(const InventoryLocation &loc, bool playerSend)
{
switch(loc.type){
case InventoryLocation::UNDEFINED:
break;
case InventoryLocation::PLAYER:
{
+ if (!playerSend)
+ return;
+
Player *player = m_env->getPlayer(loc.name.c_str());
if(!player)
return;
Shall be called with the environment and the connection locked.
*/
Inventory* getInventory(const InventoryLocation &loc);
- void setInventoryModified(const InventoryLocation &loc);
+ void setInventoryModified(const InventoryLocation &loc, bool playerSend = true);
// Connection must be locked when called
std::wstring getStatusString();