summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-01 00:14:51 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-04-01 00:14:51 +0000
commit05f71c98af1bc9d9aabf3e8e3dc78cae75675e1c (patch)
tree921b18da0dc52e7562f0c6a02e5343f9b582cf64 /src/resources
parent78c72d1463735ad6e3a176f89d3c41a5ed71fc40 (diff)
downloadmana-05f71c98af1bc9d9aabf3e8e3dc78cae75675e1c.tar.gz
mana-05f71c98af1bc9d9aabf3e8e3dc78cae75675e1c.tar.bz2
mana-05f71c98af1bc9d9aabf3e8e3dc78cae75675e1c.tar.xz
mana-05f71c98af1bc9d9aabf3e8e3dc78cae75675e1c.zip
* The client will now only attempt to load .tmx or .tmx.gz files.
* When unable to connect to char server, report IP to which it can't connect. * Cleaned up logger a bit.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/mapreader.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index c656edba..cf18e4bb 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -56,21 +56,27 @@ int Tileset::getFirstGid()
Map *MapReader::readMap(const std::string &filename)
{
- logger.log("Attempting to parse XML map data");
-
std::string name = /*std::string("data/") +*/ filename;
+
+ // Check that file exists before trying to parse it
+ std::fstream fin;
+ fin.open(name.c_str(), std::ios::in);
+ if (!fin.is_open()) {
+ logger.log("No such file!");
+ return NULL;
+ }
+ fin.close();
+
xmlDocPtr doc = xmlParseFile(name.c_str());
if (doc) {
- logger.log("Looking for root node");
xmlNodePtr node = xmlDocGetRootElement(doc);
if (!node || !xmlStrEqual(node->name, BAD_CAST "map")) {
- logger.log("Warning: No map file (%s)!", filename.c_str());
+ logger.log("Warning: Not a map file (%s)!", filename.c_str());
return NULL;
}
- logger.log("Loading map from XML tree");
return readMap(node, filename);
xmlFreeDoc(doc);
} else {