summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-09 23:02:28 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-09 23:02:28 +0300
commit94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd (patch)
treea5fd9ec3c5844ce9b8d6b4c63c25c9ded803a6a0 /src
parent51169702a6fba4626eeae44faa35ebcbf40e5fed (diff)
downloadplus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.gz
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.bz2
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.tar.xz
plus-94a9a81d9c6aa9fa287616c8b4bfc5ea86214dcd.zip
Impliment air and water block types.
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp2
-rw-r--r--src/being.h2
-rw-r--r--src/localplayer.cpp6
-rw-r--r--src/localplayer.h2
-rw-r--r--src/map.cpp8
-rw-r--r--src/map.h29
-rw-r--r--src/resources/beinginfo.cpp3
-rw-r--r--src/resources/mapreader.cpp31
-rw-r--r--src/resources/monsterdb.cpp4
9 files changed, 77 insertions, 10 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 95ba4a63a..8a9d3c1e1 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -408,6 +408,8 @@ void Being::clearPath()
void Being::setPath(const Path &path)
{
mPath = path;
+ if (mPath.empty())
+ return;
if ((Net::getNetworkType() == ServerInfo::TMWATHENA) &&
mAction != MOVE && mAction != DEAD)
diff --git a/src/being.h b/src/being.h
index 9609c2909..199cb4dc2 100644
--- a/src/being.h
+++ b/src/being.h
@@ -392,7 +392,7 @@ class Being : public ActorSprite, public ConfigListener
/**
* Gets the way the object is blocked by other objects.
*/
- unsigned char getWalkMask() const;
+ virtual unsigned char getWalkMask() const;
/**
* Gets the way the monster blocks pathfinding for other objects
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index bcc78dd1b..0dea8ddac 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -3835,6 +3835,12 @@ void LocalPlayer::resetYellowBar()
miniStatusWindow->updateStatus();
}
+unsigned char LocalPlayer::getWalkMask() const
+{
+ // for now blocking all types of collisions
+ return Map::BLOCKMASK_WALL | Map::BLOCKMASK_AIR | Map::BLOCKMASK_WATER;
+}
+
void AwayListener::action(const gcn::ActionEvent &event)
{
if (event.getId() == "ok" && player_node && player_node->getAwayMode())
diff --git a/src/localplayer.h b/src/localplayer.h
index 6a6a015b8..9cf0b9cfa 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -451,6 +451,8 @@ class LocalPlayer : public Being, public ActorSpriteListener,
void resetYellowBar();
+ virtual unsigned char getWalkMask() const;
+
protected:
/** Whether or not the name settings have changed */
bool mUpdateName;
diff --git a/src/map.cpp b/src/map.cpp
index 8d2031019..83143a7c8 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -793,6 +793,12 @@ void Map::blockTile(int x, int y, BlockType type)
case BLOCKTYPE_MONSTER:
mMetaTiles[tileNum].blockmask |= BLOCKMASK_MONSTER;
break;
+ case BLOCKTYPE_AIR:
+ mMetaTiles[tileNum].blockmask |= BLOCKMASK_AIR;
+ break;
+ case BLOCKTYPE_WATER:
+ mMetaTiles[tileNum].blockmask |= BLOCKMASK_WATER;
+ break;
default:
case BLOCKTYPE_NONE:
case NB_BLOCKTYPES:
@@ -1053,6 +1059,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
// Skip if the tile is on the closed list or is not walkable
// unless its the destination tile
+ //+++ here need check block must depend on player abilities.
if (!newTile || newTile->whichList == mOnClosedList ||
((newTile->blockmask & walkmask)
&& !(x == destX && y == destY))
@@ -1068,6 +1075,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY,
MetaTile *t1 = getMetaTile(curr.x, curr.y + dy);
MetaTile *t2 = getMetaTile(curr.x + dx, curr.y);
+ //+++ here need check block must depend on player abilities.
if (!t1 || !t2 || ((t1->blockmask | t2->blockmask)
& BLOCKMASK_WALL))
{
diff --git a/src/map.h b/src/map.h
index 1116fef4d..7e0f50dce 100644
--- a/src/map.h
+++ b/src/map.h
@@ -210,14 +210,27 @@ class Map : public Properties, public ConfigListener
BLOCKTYPE_WALL,
BLOCKTYPE_CHARACTER,
BLOCKTYPE_MONSTER,
+ BLOCKTYPE_AIR,
+ BLOCKTYPE_WATER,
NB_BLOCKTYPES
};
+ enum CollisionTypes
+ {
+ COLLISION_EMPTY = 0,
+ COLLISION_WALL = 1,
+ COLLISION_AIR = 2,
+ COLLISION_WATER = 3,
+ COLLISION_MAX = 4
+ };
+
enum BlockMask
{
- BLOCKMASK_WALL = 0x80, // = bin 1000 0000
- BLOCKMASK_CHARACTER = 0x01, // = bin 0000 0001
- BLOCKMASK_MONSTER = 0x02 // = bin 0000 0010
+ BLOCKMASK_WALL = 0x80, // 1000 0000
+ BLOCKMASK_CHARACTER = 0x01, // 0000 0001
+ BLOCKMASK_MONSTER = 0x02, // 0000 0010
+ BLOCKMASK_AIR = 0x04, // 0000 0100
+ BLOCKMASK_WATER = 0x08, // 0000 1000
};
enum DebugType
@@ -297,7 +310,8 @@ class Map : public Properties, public ConfigListener
* without walkmask, only blocks against colliding tiles.
*/
bool getWalk(int x, int y,
- unsigned char walkmask = BLOCKMASK_WALL) const;
+ unsigned char walkmask = BLOCKMASK_WALL | BLOCKMASK_AIR
+ | BLOCKMASK_WATER) const;
/**
* Tells whether a tile is occupied by a being.
@@ -440,6 +454,12 @@ class Map : public Properties, public ConfigListener
void setActorsFix(int x, int y)
{ mActorFixX = x; mActorFixY = y; }
+ int getVersion()
+ { return mVersion; }
+
+ void setVersion(int n)
+ { mVersion = n; }
+
protected:
friend class Actor;
@@ -528,6 +548,7 @@ class Map : public Properties, public ConfigListener
int mIndexedTilesetsSize;
int mActorFixX;
int mActorFixY;
+ int mVersion;
SpecialLayer *mSpecialLayer;
SpecialLayer *mTempLayer;
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index d0535ef04..438de46dd 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -33,7 +33,8 @@ BeingInfo::BeingInfo():
mName(_("unnamed")),
mTargetCursorSize(ActorSprite::TC_MEDIUM),
mWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER),
+ | Map::BLOCKMASK_MONSTER | Map::BLOCKMASK_AIR
+ | Map::BLOCKMASK_WATER),
mBlockType(Map::BLOCKTYPE_CHARACTER),
mTargetOffsetX(0), mTargetOffsetY(0),
mMaxHP(0), mStaticMaxHP(false)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 818968621..7fa088326 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -288,6 +288,8 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
else if (xmlStrEqual(childNode->name, BAD_CAST "properties"))
{
readProperties(childNode, map);
+ map->setVersion(atoi(map->getProperty(
+ "manaplus version").c_str()));
}
else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup"))
{
@@ -407,8 +409,33 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
{
// Set collision tile
// if (set && (gid - set->getFirstGid() == 1)) buggy update
- if (set && (gid - set->getFirstGid() != 0))
- map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ if (set)
+ {
+ if (map->getVersion() >= 1)
+ {
+ switch (gid - set->getFirstGid())
+ {
+ case Map::COLLISION_WALL:
+ map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ break;
+ case Map::COLLISION_AIR:
+ logger->log("air: %d, %d", x, y);
+ map->blockTile(x, y, Map::BLOCKTYPE_AIR);
+ break;
+ case Map::COLLISION_WATER:
+ logger->log("water: %d, %d", x, y);
+ map->blockTile(x, y, Map::BLOCKTYPE_WATER);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (gid - set->getFirstGid() != 0)
+ map->blockTile(x, y, Map::BLOCKTYPE_WALL);
+ }
+ }
}
}
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 9fce60306..5a80b4500 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -71,8 +71,8 @@ void MonsterDB::load()
BeingInfo *currentInfo = new BeingInfo;
currentInfo->setWalkMask(Map::BLOCKMASK_WALL
- | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER);
+ | Map::BLOCKMASK_CHARACTER | Map::BLOCKMASK_MONSTER
+ | Map::BLOCKMASK_AIR | Map::BLOCKMASK_WATER);
currentInfo->setBlockType(Map::BLOCKTYPE_MONSTER);
currentInfo->setName(XML::getProperty(