diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/actor.cpp | 23 | ||||
-rw-r--r-- | src/game-server/actor.h | 2 | ||||
-rw-r--r-- | src/game-server/character.cpp | 12 | ||||
-rw-r--r-- | src/game-server/character.h | 2 | ||||
-rw-r--r-- | src/game-server/map.cpp | 3 | ||||
-rw-r--r-- | src/game-server/monster.cpp | 10 |
6 files changed, 22 insertions, 30 deletions
diff --git a/src/game-server/actor.cpp b/src/game-server/actor.cpp index 68430bca..8325c6d8 100644 --- a/src/game-server/actor.cpp +++ b/src/game-server/actor.cpp @@ -25,11 +25,25 @@ #include <cassert> +Actor::~Actor() +{ + // Free the map position + if (MapComposite *mapComposite = getMap()) + { + Map *map = mapComposite->getMap(); + int tileWidth = map->getTileWidth(); + int tileHeight = map->getTileHeight(); + Point oldP = getPosition(); + map->freeTile(oldP.x / tileWidth, oldP.y / tileHeight, getBlockType()); + } +} + void Actor::setPosition(const Point &p) { // Update blockmap - if (Map *map = getMap()->getMap()) + if (MapComposite *mapComposite = getMap()) { + Map *map = mapComposite->getMap(); int tileWidth = map->getTileWidth(); int tileHeight = map->getTileHeight(); if ((mPos.x / tileWidth != p.x / tileWidth @@ -46,11 +60,10 @@ void Actor::setPosition(const Point &p) void Actor::setMap(MapComposite *mapComposite) { - assert (mapComposite); - MapComposite *oldMapComposite = getMap(); - Point p = getPosition(); + assert(mapComposite); + const Point p = getPosition(); - if (oldMapComposite) + if (MapComposite *oldMapComposite = getMap()) { Map *oldMap = oldMapComposite->getMap(); int oldTileWidth = oldMap->getTileWidth(); diff --git a/src/game-server/actor.h b/src/game-server/actor.h index e345d579..dc3e7ad1 100644 --- a/src/game-server/actor.h +++ b/src/game-server/actor.h @@ -58,6 +58,8 @@ class Actor : public Thing mSize(0) {} + ~Actor(); + /** * Sets the coordinates. Also updates the walkmap of the map the actor * is on. diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 62464023..4688956f 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -651,18 +651,6 @@ void Character::disconnected() } } -Character::~Character() -{ - if (getMap()) - { - Map *map = getMap()->getMap(); - int tileWidth = map->getTileWidth(); - int tileHeight = map->getTileHeight(); - Point oldP = getPosition(); - map->freeTile(oldP.x / tileWidth, oldP.y / tileHeight, getBlockType()); - } -} - void Character::giveSpecial(int id) { if (mSpecials.find(id) == mSpecials.end()) diff --git a/src/game-server/character.h b/src/game-server/character.h index 5a826908..ade13a5d 100644 --- a/src/game-server/character.h +++ b/src/game-server/character.h @@ -61,8 +61,6 @@ class Character : public Being */ Character(MessageIn &msg); - ~Character(); - /** * recalculates the level when necessary and calls Being::update */ diff --git a/src/game-server/map.cpp b/src/game-server/map.cpp index d48546a2..16368e91 100644 --- a/src/game-server/map.cpp +++ b/src/game-server/map.cpp @@ -157,8 +157,9 @@ void Map::freeTile(int x, int y, BlockType type) return; MetaTile &metaTile = mMetaTiles[x + y * mWidth]; + assert(metaTile.occupation[type] > 0); - if (metaTile.occupation[type] > 0 && !(--metaTile.occupation[type])) + if (!(--metaTile.occupation[type])) { switch (type) { diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index 07916d0e..fe23ba5f 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -133,16 +133,6 @@ Monster::~Monster() { i->first->removeListener(&mTargetListener); } - - // Free the map position - if (getMap()) - { - Point oldP = getPosition(); - Map *map = getMap()->getMap(); - int tileWidth = map->getTileWidth(); - int tileHeight = map->getTileHeight(); - map->freeTile(oldP.x / tileWidth, oldP.y / tileHeight, getBlockType()); - } } void Monster::perform() |