diff options
author | Ira Rice <irarice@gmail.com> | 2008-12-07 16:53:32 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-12-07 16:53:32 -0700 |
commit | aef082e6fe4fca268f9bfe401409eb342f82e4af (patch) | |
tree | 26e9f2f2be9ad59666a4c039c7717e0e5becd3eb /src/resources | |
parent | 7f24abc455a407e84f13d75099e36db77fa8931d (diff) | |
parent | a7c21e6f8add37af7412449742ec55c8daa8571a (diff) | |
download | mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.gz mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.bz2 mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.tar.xz mana-aef082e6fe4fca268f9bfe401409eb342f82e4af.zip |
Merge commit 'a7c21e6f8add37af7412449742ec55c8daa8571a'
Conflicts:
AUTHORS
CMakeLists.txt
ChangeLog
INSTALL
README
aethyra.cbp
configure.ac
data/help/changes.txt
data/help/commands.txt
data/help/header.txt
data/help/support.txt
src/Makefile.am
src/aethyra.rc
src/being.cpp
src/being.h
src/equipment.cpp
src/equipment.h
src/floor_item.h
src/game.cpp
src/gui/buddywindow.cpp
src/gui/char_select.cpp
src/gui/char_server.cpp
src/gui/chat.cpp
src/gui/chat.h
src/gui/equipmentwindow.cpp
src/gui/equipmentwindow.h
src/gui/gui.cpp
src/gui/inventorywindow.cpp
src/gui/inventorywindow.h
src/gui/itemcontainer.cpp
src/gui/itemcontainer.h
src/gui/minimap.cpp
src/gui/ministatus.cpp
src/gui/newskill.cpp
src/gui/npc_text.cpp
src/gui/npclistdialog.h
src/gui/ok_dialog.cpp
src/gui/setup_video.cpp
src/gui/skill.cpp
src/gui/skill.h
src/gui/status.h
src/gui/table_model.h
src/gui/updatewindow.cpp
src/gui/viewport.cpp
src/inventory.cpp
src/inventory.h
src/keyboardconfig.cpp
src/keyboardconfig.h
src/localplayer.cpp
src/localplayer.h
src/logindata.h
src/main.cpp
src/map.cpp
src/monster.cpp
src/monster.h
src/net/beinghandler.cpp
src/net/beinghandler.h
src/net/buysellhandler.cpp
src/net/equipmenthandler.cpp
src/net/loginhandler.cpp
src/net/loginhandler.h
src/net/network.h
src/net/npchandler.cpp
src/net/playerhandler.cpp
src/net/protocol.h
src/net/tradehandler.cpp
src/npc.cpp
src/npc.h
src/particleemitter.cpp
src/particleemitterprop.h
src/player.cpp
src/player.h
src/player_relations.cpp
src/resources/imageset.cpp
src/resources/imageset.h
src/resources/itemdb.cpp
src/resources/mapreader.cpp
src/resources/monsterinfo.h
src/text.cpp
src/text.h
src/textmanager.cpp
src/textmanager.h
src/tileset.h
src/utils/fastsqrt.h
src/utils/strprintf.cpp
src/winver.h
tools/tmxcopy/Makefile
tools/tmxcopy/base64.cpp
tools/tmxcopy/base64.h
tools/tmxcopy/tostring.h
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/colordb.cpp | 9 | ||||
-rw-r--r-- | src/resources/imageset.h | 6 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 69 |
3 files changed, 44 insertions, 40 deletions
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 46acaf39..3d2e15e0 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -56,8 +56,7 @@ void ColorDB::load() TMWHair = true; - if (doc) - delete doc; + delete doc; doc = new XML::Document(TMW_COLOR_FILE); root = doc->rootNode(); @@ -67,8 +66,7 @@ void ColorDB::load() mColors[0] = mFail; mLoaded = true; - if (doc) - delete doc; + delete doc; return; } @@ -91,8 +89,7 @@ void ColorDB::load() } } - if (doc) - delete doc; + delete doc; mLoaded = true; } diff --git a/src/resources/imageset.h b/src/resources/imageset.h index c7915212..26ce99ea 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -47,17 +47,17 @@ class ImageSet : public Resource /** * Returns the width of the images in the image set. */ - int getWidth() { return mWidth; }; + int getWidth() const { return mWidth; }; /** * Returns the height of the images in the image set. */ - int getHeight() { return mHeight; }; + int getHeight() const { return mHeight; }; typedef std::vector<Image*>::size_type size_type; Image* get(size_type i) const; - size_type size() { return mImages.size(); } + size_type size() const { return mImages.size(); } private: std::vector<Image*> mImages; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 894cc4fc..b4beb558 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -240,7 +240,8 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) { if (xmlStrEqual(objectNode->name, BAD_CAST "object")) { - const std::string objType = XML::getProperty(objectNode, "type", ""); + const std::string objType = + XML::getProperty(objectNode, "type", ""); if (objType == "WARP" || objType == "NPC" || objType == "SCRIPT" || objType == "SPAWN") @@ -249,12 +250,14 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) continue; } - const std::string objName = XML::getProperty(objectNode, "name", ""); + const std::string objName = + XML::getProperty(objectNode, "name", ""); const int objX = XML::getProperty(objectNode, "x", 0); const int objY = XML::getProperty(objectNode, "y", 0); logger->log("- Loading object name: %s type: %s at %d:%d", - objName.c_str(), objType.c_str(), objX, objY); + objName.c_str(), objType.c_str(), + objX, objY); if (objType == "PARTICLE_EFFECT") { @@ -263,7 +266,9 @@ MapReader::readMap(xmlNodePtr node, const std::string &path) continue; } - map->addParticleEffect(objName, objX + offsetX, objY + offsetY); + map->addParticleEffect(objName, + objX + offsetX, + objY + offsetY); } else { @@ -302,13 +307,14 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) // Set regular tile on a layer Image * const img = set ? set->get(gid - set->getFirstGid()) : 0; layer->setTile(x, y, img); - } else { + } else { // Set collision tile map->setWalk(x, y, (!set || (gid - set->getFirstGid() == 0))); - } + } } -void MapReader::readLayer(xmlNodePtr node, Map *map) +void +MapReader::readLayer(xmlNodePtr node, Map *map) { // Layers are not necessarily the same size as the map const int w = XML::getProperty(node, "width", map->getWidth()); @@ -323,25 +329,25 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) MapLayer *layer = 0; if (!isCollisionLayer) { - layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer); - map->addLayer(layer); + layer = new MapLayer(offsetX, offsetY, w, h, isFringeLayer); + map->addLayer(layer); } logger->log("- Loading layer \"%s\"", name.c_str()); int x = 0; int y = 0; - + // Load the tile data for_each_xml_child_node(childNode, node) { if (!xmlStrEqual(childNode->name, BAD_CAST "data")) - continue; - + continue; + const std::string encoding = - XML::getProperty(childNode, "encoding", ""); + XML::getProperty(childNode, "encoding", ""); const std::string compression = - XML::getProperty(childNode, "compression", ""); - + XML::getProperty(childNode, "compression", ""); + if (encoding == "base64") { if (!compression.empty() && compression != "gzip") { @@ -382,11 +388,11 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) unsigned char *inflated; unsigned int inflatedSize = inflateMemory(binData, binLen, inflated); - + free(binData); binData = inflated; binLen = inflatedSize; - + if (!inflated) { logger->log("Error: Could not decompress layer!"); return; @@ -400,11 +406,12 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) binData[i + 3] << 24; setTile(map, layer, x, y, gid); - + x++; - if (x == w) - { + if (x == w) { x = 0; y++; + + // When we're done, don't crash on too much data if (y == h) break; } @@ -418,17 +425,17 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) { if (!xmlStrEqual(childNode2->name, BAD_CAST "tile")) continue; - - const int gid = XML::getProperty(childNode2, "gid", -1); - setTile(map, layer, x, y, gid); - - x++; - if (x == w) { - x = 0; y++; - if (y >= h) - break; - } - } + + const int gid = XML::getProperty(childNode2, "gid", -1); + setTile(map, layer, x, y, gid); + + x++; + if (x == w) { + x = 0; y++; + if (y >= h) + break; + } + } } if (y < h) |