InventoryManager: fixed current window getting removed in race conditions with close window ACK

this could be observed by pressing E and immediately clicking a chest, which, if timed correctly, would lead to the chest lid closing, but the inventory being opened anyway.
This commit is contained in:
Dylan K. Taylor 2022-08-27 17:26:43 +01:00
parent 78b5be8dd0
commit fb25e05416
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -259,8 +259,10 @@ class InventoryManager{
public function onClientRemoveWindow(int $id) : void{
if($id === $this->lastInventoryNetworkId){
$this->remove($id);
$this->player->removeCurrentWindow();
if($id !== $this->pendingCloseWindowId){
$this->remove($id);
$this->player->removeCurrentWindow();
}
}else{
$this->session->getLogger()->debug("Attempted to close inventory with network ID $id, but current is $this->lastInventoryNetworkId");
}