summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemEmptyMap.h
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-17 15:27:12 +0100
committerandrew <xdotftw@gmail.com>2014-02-17 15:27:12 +0100
commit3b24bc870bb39a8b8812ed307250e1188b9ff788 (patch)
tree8b6cf830e06a0fe6bd1eb8769ba571f9316a4707 /src/Items/ItemEmptyMap.h
parentcMap::UpdateRadius (diff)
downloadcuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar.gz
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar.bz2
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar.lz
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar.xz
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.tar.zst
cuberite-3b24bc870bb39a8b8812ed307250e1188b9ff788.zip
Diffstat (limited to '')
-rw-r--r--src/Items/ItemEmptyMap.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Items/ItemEmptyMap.h b/src/Items/ItemEmptyMap.h
index 24d31151b..b06cf9d13 100644
--- a/src/Items/ItemEmptyMap.h
+++ b/src/Items/ItemEmptyMap.h
@@ -41,7 +41,21 @@ public:
int CenterX = round(a_Player->GetPosX() / (float) RegionWidth) * RegionWidth;
int CenterZ = round(a_Player->GetPosZ() / (float) RegionWidth) * RegionWidth;
- a_World->CreateMap(CenterX, CenterZ, DEFAULT_SCALE);
+ cMap * NewMap = a_World->CreateMap(CenterX, CenterZ, DEFAULT_SCALE);
+
+ // Remove empty map from inventory
+ if (!a_Player->GetInventory().RemoveOneEquippedItem())
+ {
+ ASSERT(!"Inventory mismatch");
+ return true;
+ }
+
+ if (NewMap == NULL)
+ {
+ return true;
+ }
+
+ a_Player->GetInventory().AddItem(cItem(E_ITEM_MAP, 1, NewMap->GetID()), true, true);
return true;
}