summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-20 17:16:37 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-02-20 17:16:37 +0000
commit38a97bac830d6afe82fe3f68f3d8a0831bb5b643 (patch)
treeae8f26697caeee74da81c7b87cda0ac90faf5fb7 /src/map.cpp
parentd332272741e8382409453b975c66235d45e66cc7 (diff)
downloadmana-38a97bac830d6afe82fe3f68f3d8a0831bb5b643.tar.gz
mana-38a97bac830d6afe82fe3f68f3d8a0831bb5b643.tar.bz2
mana-38a97bac830d6afe82fe3f68f3d8a0831bb5b643.tar.xz
mana-38a97bac830d6afe82fe3f68f3d8a0831bb5b643.zip
More progress towards loading XML maps.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/map.cpp b/src/map.cpp
index ee029af8..8b90df06 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -25,14 +25,11 @@
#include "map.h"
#include "log.h"
#include "resources/resourcemanager.h"
+#include "resources/mapreader.h"
#include "graphic/spriteset.h"
-#include <libxml/parser.h>
-#include <libxml/tree.h>
#include <queue>
-Map tiledMap;
-
#define OLD_MAP_WIDTH 200
#define OLD_MAP_HEIGHT 200
@@ -112,20 +109,20 @@ Map::~Map()
delete[] tiles;
}
-bool Map::load(const std::string &mapFile)
+Map *Map::load(const std::string &mapFile)
{
FILE *file = fopen(mapFile.c_str(), "r");
if (!file) {
log("Warning: %s", mapFile.c_str());
- return false;
+ return NULL;
}
MAP oldMap;
fread(&oldMap, sizeof(MAP), 1, file);
fclose(file);
- setSize(OLD_MAP_WIDTH, OLD_MAP_HEIGHT);
+ Map *map = new Map(OLD_MAP_WIDTH, OLD_MAP_HEIGHT);
// Load the default tileset
ResourceManager *resman = ResourceManager::getInstance();
@@ -160,33 +157,19 @@ bool Map::load(const std::string &mapFile)
}
if (id < tileset->spriteset.size() && (a == 0 || id > 0)) {
- setTile(x, y, a, tileset->spriteset[id]);
+ map->setTile(x, y, a, tileset->spriteset[id]);
}
else {
- setTile(x, y, a, NULL);
+ map->setTile(x, y, a, NULL);
}
}
// Walkability
- setWalk(x, y, (oldMap.tiles[x][y].data[3] & 0x0002) > 0);
+ map->setWalk(x, y, (oldMap.tiles[x][y].data[3] & 0x0002) > 0);
}
}
- return true;
-}
-
-bool loadXmlMap(const std::string &mapFile)
-{
- xmlDocPtr doc = xmlReadFile(mapFile.c_str(), NULL, 0);
-
- if (!doc) {
- log("Warning: %s", mapFile.c_str());
- return false;
- }
-
- xmlFreeDoc(doc);
-
- return false;
+ return map;
}
void Map::setSize(int width, int height)