From 3461761739aeb015dc38e3f535e4160c512c6e4f Mon Sep 17 00:00:00 2001 From: niczkx Date: Fri, 20 Jul 2012 21:18:03 +0200 Subject: [PATCH] comment out & remove untested stuff --- src/framework/core/binarytree.cpp | 5 +++-- src/otclient/map.cpp | 36 +++++++++++++++---------------- src/otclient/map.h | 20 +---------------- 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/framework/core/binarytree.cpp b/src/framework/core/binarytree.cpp index 122ecc5c..5e07cd39 100644 --- a/src/framework/core/binarytree.cpp +++ b/src/framework/core/binarytree.cpp @@ -167,7 +167,7 @@ BinaryTreePtr BinaryTree::makeChild(uint8 type) { BinaryTreePtr child(new BinaryTree(m_fin)); child->setType(type); - children.append(child); + //children.append(child); return child; } @@ -227,8 +227,9 @@ void BinaryTree::writeToFile() /// first write self data m_fin->write(&m_buffer[0], m_buffer.size()); - +#if 0 /// write children data for(const BinaryTreePtr& child : m_children) child->writeToFile(); +#endif } diff --git a/src/otclient/map.cpp b/src/otclient/map.cpp index 36565148..e059b7a6 100644 --- a/src/otclient/map.cpp +++ b/src/otclient/map.cpp @@ -85,8 +85,8 @@ void Map::loadOtbm(const std::string& fileName) if(!headerVersion || headerVersion > 3) stdext::throw_exception(stdext::format("Unknown OTBM version detected: %u.", headerVersion)); - setSize(root->getU16(), root->getU16()); - dump << "Map size: " << m_width << "x" << m_height; + setWidth(root->getU16()); + setHeight(root->getU16()); uint32 headerMajorItems = root->getU8(); if(headerMajorItems < 3) { @@ -115,13 +115,13 @@ void Map::loadOtbm(const std::string& fileName) std::string tmp = node->getString(); switch (attribute) { case OTBM_ATTR_DESCRIPTION: - m_description += tmp + "\n"; + setDescription(tmp); break; case OTBM_ATTR_SPAWN_FILE: - m_spawnFile = fileName.substr(0, fileName.rfind('/') + 1) + tmp; + setSpawnFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp); break; case OTBM_ATTR_HOUSE_FILE: - m_houseFile = fileName.substr(0, fileName.rfind('/') + 1) + tmp; + setHouseFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp); break; default: stdext::throw_exception(stdext::format("Invalid attribute '%c'", attribute)); @@ -196,7 +196,7 @@ void Map::loadOtbm(const std::string& fileName) ItemPtr cItem = Item::createFromOtb(containerItem->getU16()); cItem->unserializeItem(containerItem); - item->addContainerItem(cItem); + //item->addContainerItem(cItem); } } @@ -248,8 +248,8 @@ void Map::loadOtbm(const std::string& fileName) g_logger.debug("OTBM read successfully."); fin->close(); - loadSpawns(m_spawnFile); - m_houses.load(m_houseFile); + loadSpawns(getSpawnFile()); + m_houses.load(getHouseFile()); } void Map::saveOtbm(const std::string &fileName) @@ -275,7 +275,7 @@ void Map::saveOtbm(const std::string &fileName) /// Usually when a map has empty house/spawn file it means the map is new. /// TODO: Ask the user for a map name instead of those ugly uses of substr - std::string houseFile = getHousefile(), spawnFile = getSpawnFile(); + std::string houseFile = getHouseFile(), spawnFile = getSpawnFile(); if(houseFile.empty() && version > 1) houseFile = fileName.substr(fileName.find_last_of('/')) + "-houses.xml"; if(spawnFile.empty()) @@ -314,13 +314,13 @@ void Map::saveOtbm(const std::string &fileName) mapData->writeString(stdext::format("Saved with %s v%d", g_app.getName(), stdext::unsafe_cast(g_app.getVersion()))); // spawn file. - mapData->addU8(OTBM_ATTR_SPAWN_FILE); - mapData->addString(spawnFile); + mapData->writeU8(OTBM_ATTR_SPAWN_FILE); + mapData->writeString(spawnFile); // house file. - if(ver > 1) { - mapData->addU8(OTBM_ATTR_HOUSE_FILE); - mapData->addString(houseFile); + if(version > 1) { + mapData->writeU8(OTBM_ATTR_HOUSE_FILE); + mapData->writeString(houseFile); } /// write tiles first @@ -337,15 +337,15 @@ void Map::saveOtbm(const std::string &fileName) } BinaryTreePtr tileNode(nullptr); - tileflags_t flags = tile->getFlags(); + uint32 flags = tile->getFlags(); if((flags & TILESTATE_HOUSE) == TILESTATE_HOUSE) tileNode = tileArea->makeChild(OTBM_HOUSETILE); else tileNode = tileArea->makeChild(OTBM_TILE); tileNode->writePoint(Point(pos.x, pos.y)); - if(tileNode->getType() == OTBM_HOUSETILE) - tileNode->writeU32(tile->getHouseId()); +// if(tileNode->getType() == OTBM_HOUSETILE) +// tileNode->writeU32(tile->getHouseId()); /// Tile flags if(flags != 0) { @@ -386,7 +386,7 @@ void Map::saveOtbm(const std::string &fileName) } root->writeToFile(); - g_logger.debug(stdext::format("OTBM saving took %ld", time(0) - start); + g_logger.debug(stdext::format("OTBM saving took %ld", time(0) - start)); } void Map::loadSpawns(const std::string &fileName) diff --git a/src/otclient/map.h b/src/otclient/map.h index 6cc8b5e2..a505dae4 100644 --- a/src/otclient/map.h +++ b/src/otclient/map.h @@ -88,23 +88,6 @@ enum { OTCM_VERSION = 1 }; -/// Temporary way for reading container items -struct MapContainer { -private: - std::vector m_items; - -public: - void add(const ItemPtr& item) { m_items.push_back(item); } - ItemPtr operator[](uint idx) { return getItem(idx); } - ItemPtr getItem(int index) { - if(index < 0 || index > (int)m_items.size()) - return nullptr; - - return m_items[index]; - } -}; -typedef std::shared_ptr MapContainerPtr; - //@bindsingleton g_map class Map { @@ -134,7 +117,7 @@ public: std::string getHouseFile() { return m_attribs.get(OTBM_ATTR_HOUSE_FILE); } std::string getSpawnFile() { return m_attribs.get(OTBM_ATTR_SPAWN_FILE); } Size getSize() { return Size(m_attribs.get(OTBM_ATTR_WIDTH), m_attribs.get(OTBM_ATTR_HEIGHT)); } - std::vector getDescriptions() { return stdext::split(m_attribs.get(), "\n"; } + std::vector getDescriptions() { return stdext::split(m_attribs.get(OTBM_ATTR_DESCRIPTION), "\n"); } void loadMonsters(const std::string& fileName) { m_creatures.loadMonsters(fileName); } void loadSingleCreature(const std::string& file) { m_creatures.loadSingleCreature(file); } @@ -198,7 +181,6 @@ private: std::vector m_staticTexts; std::vector m_mapViews; std::unordered_map m_waypoints; - std::vector m_containers; Light m_light; Position m_centralPosition;