From e1a495ee306290b3bec2de9aa298aac1528e9243 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 2 Sep 2012 22:51:38 +0300 Subject: Make inventory GUI do sane things when server-side inventory acts unusually --- src/inventorymanager.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/inventorymanager.h') diff --git a/src/inventorymanager.h b/src/inventorymanager.h index dae14f1a6..f81f5b972 100644 --- a/src/inventorymanager.h +++ b/src/inventorymanager.h @@ -66,6 +66,29 @@ struct InventoryLocation name = name_; } + bool operator==(const InventoryLocation &other) const + { + if(type != other.type) + return false; + switch(type){ + case UNDEFINED: + return false; + case CURRENT_PLAYER: + return true; + case PLAYER: + return (name == other.name); + case NODEMETA: + return (p == other.p); + case DETACHED: + return (name == other.name); + } + return false; + } + bool operator!=(const InventoryLocation &other) const + { + return !(*this == other); + } + void applyCurrentPlayer(const std::string &name_) { if(type == CURRENT_PLAYER) -- cgit v1.2.3