diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-06-24 23:53:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-06-24 23:53:51 +0300 |
commit | 72168639865fb75a4c216b1058dc8412d4c81277 (patch) | |
tree | 876e745fe1b5924073faedd53d28a68a83e4593a | |
parent | f9feb8f1fd4e2dc56218aba40ef94962fa866f84 (diff) | |
download | mv-72168639865fb75a4c216b1058dc8412d4c81277.tar.gz mv-72168639865fb75a4c216b1058dc8412d4c81277.tar.bz2 mv-72168639865fb75a4c216b1058dc8412d4c81277.tar.xz mv-72168639865fb75a4c216b1058dc8412d4c81277.zip |
Add autodetection walkable tiles in maps without client data.
-rw-r--r-- | src/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/map.cpp | 8 | ||||
-rw-r--r-- | src/map.h | 9 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 3 |
4 files changed, 21 insertions, 1 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 69e2572e1..f204164ee 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -4055,6 +4055,8 @@ void LocalPlayer::setRealPos(int x, int y) mCrossX = x; mCrossY = y; } + if (mMap && mMap->isCustom()) + mMap->setWalk(x, y, true); } void LocalPlayer::fixAttackTarget() { diff --git a/src/map.cpp b/src/map.cpp index 0530b2702..f252308b6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -151,7 +151,8 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mDrawScrollX(-1), mDrawScrollY(-1), mRedrawMap(true), - mBeingOpacity(false) + mBeingOpacity(false), + mCustom(false) { const int size = mWidth * mHeight; for (int i = 0; i < NB_BLOCKTYPES; i++) @@ -659,6 +660,11 @@ bool Map::getWalk(int x, int y, unsigned char walkmask) const return !(mMetaTiles[x + y * mWidth].blockmask & walkmask); } +void Map::setWalk(int x, int y, bool walkable) +{ + blockTile(x, y, Map::BLOCKTYPE_GROUNDTOP); +} + bool Map::occupied(int x, int y) const { const ActorSprites &actors = actorSpriteManager->getAll(); @@ -219,6 +219,8 @@ class Map : public Properties, public ConfigListener unsigned char walkmask = BLOCKMASK_WALL | BLOCKMASK_AIR | BLOCKMASK_WATER) const; + void setWalk(int x, int y, bool walkable); + /** * Tells whether a tile is occupied by a being. */ @@ -376,6 +378,12 @@ class Map : public Properties, public ConfigListener bool empty() const { return mLayers.empty(); } + void setCustom(bool b) + { mCustom = b; } + + bool isCustom() + { return mCustom; } + protected: friend class Actor; friend class Minimap; @@ -483,6 +491,7 @@ class Map : public Properties, public ConfigListener int mDrawScrollY; bool mRedrawMap; bool mBeingOpacity; + bool mCustom; }; #endif diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 57524e953..67959b819 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -795,6 +795,9 @@ Map *MapReader::createEmptyMap(const std::string &filename, { logger->log("Creating empty map"); Map *map = new Map(300, 300, 32, 32); + map->setProperty("_filename", realFilename); + map->setProperty("_realfilename", filename); + map->setCustom(true); MapLayer *layer = new MapLayer(0, 0, 300, 300, false); map->addLayer(layer); layer = new MapLayer(0, 0, 300, 300, true); |