diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-07-24 20:57:17 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-07-24 20:57:17 +0300 |
commit | 2ac20982e0772b94b21d95b53519bd2164632d98 (patch) | |
tree | 3a2e7b783ff4362ac723dee22809a8e6b7f8750a /src/inventorymanager.cpp | |
parent | 96eac87d47e4d9e815dff5c9f830326e515d4ea2 (diff) | |
download | minetest-2ac20982e0772b94b21d95b53519bd2164632d98.tar.gz minetest-2ac20982e0772b94b21d95b53519bd2164632d98.tar.bz2 minetest-2ac20982e0772b94b21d95b53519bd2164632d98.zip |
Detached inventories
Diffstat (limited to 'src/inventorymanager.cpp')
-rw-r--r-- | src/inventorymanager.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/inventorymanager.cpp b/src/inventorymanager.cpp index 25257238b..1369cb0d7 100644 --- a/src/inventorymanager.cpp +++ b/src/inventorymanager.cpp @@ -41,30 +41,25 @@ std::string InventoryLocation::dump() const void InventoryLocation::serialize(std::ostream &os) const { - switch(type){ - case InventoryLocation::UNDEFINED: - { - os<<"undefined"; - } + switch(type){ + case InventoryLocation::UNDEFINED: + os<<"undefined"; + break; + case InventoryLocation::CURRENT_PLAYER: + os<<"current_player"; break; - case InventoryLocation::CURRENT_PLAYER: - { - os<<"current_player"; - } + case InventoryLocation::PLAYER: + os<<"player:"<<name; break; - case InventoryLocation::PLAYER: - { - os<<"player:"<<name; - } + case InventoryLocation::NODEMETA: + os<<"nodemeta:"<<p.X<<","<<p.Y<<","<<p.Z; break; - case InventoryLocation::NODEMETA: - { - os<<"nodemeta:"<<p.X<<","<<p.Y<<","<<p.Z; - } + case InventoryLocation::DETACHED: + os<<"detached:"<<name; break; - default: - assert(0); - } + default: + assert(0); + } } void InventoryLocation::deSerialize(std::istream &is) @@ -94,6 +89,11 @@ void InventoryLocation::deSerialize(std::istream &is) p.Y = stoi(fn.next(",")); p.Z = stoi(fn.next(",")); } + else if(tname == "detached") + { + type = InventoryLocation::DETACHED; + std::getline(is, name, '\n'); + } else { infostream<<"Unknown InventoryLocation type=\""<<tname<<"\""<<std::endl; |