comment out & remove untested stuff

This commit is contained in:
niczkx 2012-07-20 21:18:03 +02:00
parent 8a49d09b75
commit 3461761739
3 changed files with 22 additions and 39 deletions

View File

@ -167,7 +167,7 @@ BinaryTreePtr BinaryTree::makeChild(uint8 type)
{ {
BinaryTreePtr child(new BinaryTree(m_fin)); BinaryTreePtr child(new BinaryTree(m_fin));
child->setType(type); child->setType(type);
children.append(child); //children.append(child);
return child; return child;
} }
@ -227,8 +227,9 @@ void BinaryTree::writeToFile()
/// first write self data /// first write self data
m_fin->write(&m_buffer[0], m_buffer.size()); m_fin->write(&m_buffer[0], m_buffer.size());
#if 0
/// write children data /// write children data
for(const BinaryTreePtr& child : m_children) for(const BinaryTreePtr& child : m_children)
child->writeToFile(); child->writeToFile();
#endif
} }

View File

@ -85,8 +85,8 @@ void Map::loadOtbm(const std::string& fileName)
if(!headerVersion || headerVersion > 3) if(!headerVersion || headerVersion > 3)
stdext::throw_exception(stdext::format("Unknown OTBM version detected: %u.", headerVersion)); stdext::throw_exception(stdext::format("Unknown OTBM version detected: %u.", headerVersion));
setSize(root->getU16(), root->getU16()); setWidth(root->getU16());
dump << "Map size: " << m_width << "x" << m_height; setHeight(root->getU16());
uint32 headerMajorItems = root->getU8(); uint32 headerMajorItems = root->getU8();
if(headerMajorItems < 3) { if(headerMajorItems < 3) {
@ -115,13 +115,13 @@ void Map::loadOtbm(const std::string& fileName)
std::string tmp = node->getString(); std::string tmp = node->getString();
switch (attribute) { switch (attribute) {
case OTBM_ATTR_DESCRIPTION: case OTBM_ATTR_DESCRIPTION:
m_description += tmp + "\n"; setDescription(tmp);
break; break;
case OTBM_ATTR_SPAWN_FILE: case OTBM_ATTR_SPAWN_FILE:
m_spawnFile = fileName.substr(0, fileName.rfind('/') + 1) + tmp; setSpawnFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp);
break; break;
case OTBM_ATTR_HOUSE_FILE: case OTBM_ATTR_HOUSE_FILE:
m_houseFile = fileName.substr(0, fileName.rfind('/') + 1) + tmp; setHouseFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp);
break; break;
default: default:
stdext::throw_exception(stdext::format("Invalid attribute '%c'", attribute)); 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()); ItemPtr cItem = Item::createFromOtb(containerItem->getU16());
cItem->unserializeItem(containerItem); 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."); g_logger.debug("OTBM read successfully.");
fin->close(); fin->close();
loadSpawns(m_spawnFile); loadSpawns(getSpawnFile());
m_houses.load(m_houseFile); m_houses.load(getHouseFile());
} }
void Map::saveOtbm(const std::string &fileName) 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. /// 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 /// 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) if(houseFile.empty() && version > 1)
houseFile = fileName.substr(fileName.find_last_of('/')) + "-houses.xml"; houseFile = fileName.substr(fileName.find_last_of('/')) + "-houses.xml";
if(spawnFile.empty()) 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<int>(g_app.getVersion()))); mapData->writeString(stdext::format("Saved with %s v%d", g_app.getName(), stdext::unsafe_cast<int>(g_app.getVersion())));
// spawn file. // spawn file.
mapData->addU8(OTBM_ATTR_SPAWN_FILE); mapData->writeU8(OTBM_ATTR_SPAWN_FILE);
mapData->addString(spawnFile); mapData->writeString(spawnFile);
// house file. // house file.
if(ver > 1) { if(version > 1) {
mapData->addU8(OTBM_ATTR_HOUSE_FILE); mapData->writeU8(OTBM_ATTR_HOUSE_FILE);
mapData->addString(houseFile); mapData->writeString(houseFile);
} }
/// write tiles first /// write tiles first
@ -337,15 +337,15 @@ void Map::saveOtbm(const std::string &fileName)
} }
BinaryTreePtr tileNode(nullptr); BinaryTreePtr tileNode(nullptr);
tileflags_t flags = tile->getFlags(); uint32 flags = tile->getFlags();
if((flags & TILESTATE_HOUSE) == TILESTATE_HOUSE) if((flags & TILESTATE_HOUSE) == TILESTATE_HOUSE)
tileNode = tileArea->makeChild(OTBM_HOUSETILE); tileNode = tileArea->makeChild(OTBM_HOUSETILE);
else else
tileNode = tileArea->makeChild(OTBM_TILE); tileNode = tileArea->makeChild(OTBM_TILE);
tileNode->writePoint(Point(pos.x, pos.y)); tileNode->writePoint(Point(pos.x, pos.y));
if(tileNode->getType() == OTBM_HOUSETILE) // if(tileNode->getType() == OTBM_HOUSETILE)
tileNode->writeU32(tile->getHouseId()); // tileNode->writeU32(tile->getHouseId());
/// Tile flags /// Tile flags
if(flags != 0) { if(flags != 0) {
@ -386,7 +386,7 @@ void Map::saveOtbm(const std::string &fileName)
} }
root->writeToFile(); 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) void Map::loadSpawns(const std::string &fileName)

View File

@ -88,23 +88,6 @@ enum {
OTCM_VERSION = 1 OTCM_VERSION = 1
}; };
/// Temporary way for reading container items
struct MapContainer {
private:
std::vector<ItemPtr> 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<MapContainer> MapContainerPtr;
//@bindsingleton g_map //@bindsingleton g_map
class Map class Map
{ {
@ -134,7 +117,7 @@ public:
std::string getHouseFile() { return m_attribs.get<std::string>(OTBM_ATTR_HOUSE_FILE); } std::string getHouseFile() { return m_attribs.get<std::string>(OTBM_ATTR_HOUSE_FILE); }
std::string getSpawnFile() { return m_attribs.get<std::string>(OTBM_ATTR_SPAWN_FILE); } std::string getSpawnFile() { return m_attribs.get<std::string>(OTBM_ATTR_SPAWN_FILE); }
Size getSize() { return Size(m_attribs.get<uint16>(OTBM_ATTR_WIDTH), m_attribs.get<uint16>(OTBM_ATTR_HEIGHT)); } Size getSize() { return Size(m_attribs.get<uint16>(OTBM_ATTR_WIDTH), m_attribs.get<uint16>(OTBM_ATTR_HEIGHT)); }
std::vector<std::string> getDescriptions() { return stdext::split(m_attribs.get<std::string>(), "\n"; } std::vector<std::string> getDescriptions() { return stdext::split(m_attribs.get<std::string>(OTBM_ATTR_DESCRIPTION), "\n"); }
void loadMonsters(const std::string& fileName) { m_creatures.loadMonsters(fileName); } void loadMonsters(const std::string& fileName) { m_creatures.loadMonsters(fileName); }
void loadSingleCreature(const std::string& file) { m_creatures.loadSingleCreature(file); } void loadSingleCreature(const std::string& file) { m_creatures.loadSingleCreature(file); }
@ -198,7 +181,6 @@ private:
std::vector<StaticTextPtr> m_staticTexts; std::vector<StaticTextPtr> m_staticTexts;
std::vector<MapViewPtr> m_mapViews; std::vector<MapViewPtr> m_mapViews;
std::unordered_map<Position, std::string, PositionHasher> m_waypoints; std::unordered_map<Position, std::string, PositionHasher> m_waypoints;
std::vector<MapContainerPtr> m_containers;
Light m_light; Light m_light;
Position m_centralPosition; Position m_centralPosition;