Last active
March 16, 2017 04:58
-
-
Save Mkalo/2d3442d6d653f5b03009386ac08b66f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/iomap.cpp b/src/iomap.cpp | |
index 81e97d92..85a42154 100644 | |
--- a/src/iomap.cpp | |
+++ b/src/iomap.cpp | |
@@ -22,6 +22,7 @@ | |
#include "iomap.h" | |
#include "bed.h" | |
+#include "teleport.h" | |
/* | |
OTBM_ROOTV1 | |
@@ -221,6 +222,8 @@ bool IOMap::parseTileArea(OTB::Loader& loader, const OTB::Node& tileAreaNode, Ma | |
uint16_t base_y = area_coord.y; | |
uint16_t z = area_coord.z; | |
+ static std::map<uint64_t, uint64_t> teleportMap; | |
+ | |
for (auto& tileNode : tileAreaNode.children) { | |
if (tileNode.type != OTBM_TILE && tileNode.type != OTBM_HOUSETILE) { | |
setLastErrorString("Unknown tile node."); | |
@@ -368,6 +371,26 @@ bool IOMap::parseTileArea(OTB::Loader& loader, const OTB::Node& tileAreaNode, Ma | |
return false; | |
} | |
+ if (Teleport* teleport = item->getTeleport()) { | |
+ const Position& destPos = teleport->getDestPos(); | |
+ uint64_t teleportPosition = (static_cast<uint64_t>(x) << 24) | (y << 8) | z; | |
+ uint64_t destinationPosition = (static_cast<uint64_t>(destPos.x) << 24) | (destPos.y << 8) | destPos.z; | |
+ teleportMap.emplace(teleportPosition, destinationPosition); | |
+ auto it = teleportMap.find(destinationPosition); | |
+ if (it != teleportMap.end()) { | |
+ std::cout << "[Warning - IOMap::loadMap] Teleport in position [x:" << x << ", y : " << y << ", z : " << z << "] is leading to another teleport." << std::endl; | |
+ } | |
+ for (auto const& it2 : teleportMap) { | |
+ if (it2.second == teleportPosition) { | |
+ uint16_t fx = (it2.first >> 24) & 0xFFFF; | |
+ uint16_t fy = (it2.first >> 8) & 0xFFFF; | |
+ uint8_t fz = (it2.first) & 0xFF; | |
+ std::cout << "[Warning - IOMap::loadMap] Teleport in position [x:" << fx << ", y : " << fy << ", z : " << static_cast<uint16_t>(fz) << "] is leading to another teleport." << std::endl; | |
+ } | |
+ } | |
+ | |
+ } | |
+ | |
if (isHouseTile && item->isMoveable()) { | |
std::cout << "[Warning - IOMap::loadMap] Moveable item with ID: " << item->getID() << ", in house: " << house->getId() << ", at position [x: " << x << ", y: " << y << ", z: " << z << "]." << std::endl; | |
delete item; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment