summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mana.cbp6
-rw-r--r--mana.files6
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/Makefile.am6
-rw-r--r--src/actorsprite.h6
-rw-r--r--src/actorspritemanager.cpp312
-rw-r--r--src/actorspritemanager.h (renamed from src/beingmanager.h)79
-rw-r--r--src/being.cpp4
-rw-r--r--src/beingmanager.cpp276
-rw-r--r--src/flooritemmanager.cpp89
-rw-r--r--src/flooritemmanager.h59
-rw-r--r--src/game.cpp38
-rw-r--r--src/gui/chat.cpp14
-rw-r--r--src/gui/minimap.cpp13
-rw-r--r--src/gui/popupmenu.cpp4
-rw-r--r--src/gui/setup_players.cpp6
-rw-r--r--src/gui/viewport.cpp32
-rw-r--r--src/gui/viewport.h9
-rw-r--r--src/guild.cpp4
-rw-r--r--src/map.cpp12
-rw-r--r--src/net/manaserv/beinghandler.cpp25
-rw-r--r--src/net/manaserv/buysellhandler.cpp4
-rw-r--r--src/net/manaserv/chathandler.cpp4
-rw-r--r--src/net/manaserv/effecthandler.cpp4
-rw-r--r--src/net/manaserv/itemhandler.cpp9
-rw-r--r--src/net/manaserv/npchandler.cpp4
-rw-r--r--src/net/manaserv/tradehandler.cpp4
-rw-r--r--src/net/tmwa/adminhandler.cpp2
-rw-r--r--src/net/tmwa/beinghandler.cpp46
-rw-r--r--src/net/tmwa/buysellhandler.cpp2
-rw-r--r--src/net/tmwa/chathandler.cpp4
-rw-r--r--src/net/tmwa/itemhandler.cpp8
-rw-r--r--src/net/tmwa/npchandler.cpp2
-rw-r--r--src/net/tmwa/partyhandler.cpp8
-rw-r--r--src/party.cpp4
-rw-r--r--src/playerrelations.cpp6
36 files changed, 514 insertions, 603 deletions
diff --git a/mana.cbp b/mana.cbp
index 3a7f7403..3416db75 100644
--- a/mana.cbp
+++ b/mana.cbp
@@ -98,6 +98,8 @@
<Unit filename="src\actor.h" />
<Unit filename="src\actorsprite.cpp" />
<Unit filename="src\actorsprite.h" />
+ <Unit filename="src\actorspritemanager.cpp" />
+ <Unit filename="src\actorspritemanager.h" />
<Unit filename="src\animatedsprite.cpp" />
<Unit filename="src\animatedsprite.h" />
<Unit filename="src\animationparticle.cpp" />
@@ -106,8 +108,6 @@
<Unit filename="src\avatar.h" />
<Unit filename="src\being.cpp" />
<Unit filename="src\being.h" />
- <Unit filename="src\beingmanager.cpp" />
- <Unit filename="src\beingmanager.h" />
<Unit filename="src\channel.cpp" />
<Unit filename="src\channel.h" />
<Unit filename="src\channelmanager.cpp" />
@@ -131,8 +131,6 @@
<Unit filename="src\equipment.h" />
<Unit filename="src\flooritem.cpp" />
<Unit filename="src\flooritem.h" />
- <Unit filename="src\flooritemmanager.cpp" />
- <Unit filename="src\flooritemmanager.h" />
<Unit filename="src\game.cpp" />
<Unit filename="src\game.h" />
<Unit filename="src\graphics.cpp" />
diff --git a/mana.files b/mana.files
index 169cfdbe..d27ca32a 100644
--- a/mana.files
+++ b/mana.files
@@ -42,6 +42,8 @@
./src/actor.h
./src/actorsprite.cpp
./src/actorsprite.h
+./src/actorspritemanager.cpp
+./src/actorspritemanager.h
./src/animatedsprite.cpp
./src/animatedsprite.h
./src/animationparticle.cpp
@@ -50,8 +52,6 @@
./src/avatar.h
./src/being.cpp
./src/being.h
-./src/beingmanager.cpp
-./src/beingmanager.h
./src/channel.cpp
./src/channel.h
./src/channelmanager.cpp
@@ -75,8 +75,6 @@
./src/equipment.h
./src/flooritem.cpp
./src/flooritem.h
-./src/flooritemmanager.cpp
-./src/flooritemmanager.h
./src/game.cpp
./src/game.h
./src/graphics.cpp
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b287ec5e..2df9ef49 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -406,6 +406,8 @@ SET(SRCS
actor.h
actorsprite.cpp
actorsprite.h
+ actorspritemanager.cpp
+ actorspritemanager.h
animatedsprite.cpp
animatedsprite.h
animationparticle.cpp
@@ -414,8 +416,6 @@ SET(SRCS
avatar.h
being.cpp
being.h
- beingmanager.cpp
- beingmanager.h
chatlog.cpp
chatlog.h
client.cpp
@@ -438,8 +438,6 @@ SET(SRCS
equipment.h
flooritem.cpp
flooritem.h
- flooritemmanager.cpp
- flooritemmanager.h
game.cpp
game.h
graphics.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 2b36250c..2b18b693 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -305,6 +305,8 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
actor.h \
actorsprite.cpp \
actorsprite.h \
+ actorspritemanager.cpp \
+ actorspritemanager.h \
animatedsprite.cpp \
animatedsprite.h \
animationparticle.cpp \
@@ -313,8 +315,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
avatar.h \
being.cpp \
being.h \
- beingmanager.cpp \
- beingmanager.h \
chatlog.cpp \
chatlog.h \
client.cpp \
@@ -337,8 +337,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
equipment.h \
flooritem.cpp \
flooritem.h \
- flooritemmanager.cpp \
- flooritemmanager.h \
game.cpp \
game.h \
graphics.cpp \
diff --git a/src/actorsprite.h b/src/actorsprite.h
index a56be125..6c5885e6 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -150,6 +150,12 @@ public:
virtual float getAlpha() const
{ return CompoundSprite::getAlpha(); }
+ virtual int getWidth() const
+ { return CompoundSprite::getWidth(); }
+
+ virtual int getHeight() const
+ { return CompoundSprite::getHeight(); }
+
static void load();
static void unload();
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
new file mode 100644
index 00000000..04e17b47
--- /dev/null
+++ b/src/actorspritemanager.cpp
@@ -0,0 +1,312 @@
+/*
+ * The Mana Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ *
+ * This file is part of The Mana Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "actorspritemanager.h"
+
+#include "localplayer.h"
+
+#include "gui/viewport.h"
+
+#include "utils/stringutils.h"
+#include "utils/dtor.h"
+
+#include <cassert>
+
+#define for_actors ActorSpritesConstIterator it, it_end; \
+for (it = mActors.begin(), it_end = mActors.end() ; it != it_end; it++)
+
+class FindBeingFunctor
+{
+ public:
+ bool operator() (ActorSprite *actor)
+ {
+ if (actor->getType() == ActorSprite::FLOOR_ITEM)
+ return false;
+ Being* b = static_cast<Being*>(actor);
+
+ Uint16 other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0);
+ const Vector &pos = b->getPosition();
+ return ((int) pos.x / 32 == x &&
+ ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) &&
+ b->isAlive() &&
+ (type == ActorSprite::UNKNOWN || b->getType() == type));
+ }
+
+ Uint16 x, y;
+ ActorSprite::Type type;
+} beingFinder;
+
+ActorSpriteManager::ActorSpriteManager()
+{
+}
+
+ActorSpriteManager::~ActorSpriteManager()
+{
+ clear();
+}
+
+void ActorSpriteManager::setMap(Map *map)
+{
+ mMap = map;
+
+ if (player_node)
+ player_node->setMap(map);
+}
+
+void ActorSpriteManager::setPlayer(LocalPlayer *player)
+{
+ player_node = player;
+ mActors.push_back(player);
+}
+
+Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type, int subtype)
+{
+ Being *being = new Being(id, type, subtype, mMap);
+
+ mActors.push_back(being);
+ return being;
+}
+
+FloorItem *ActorSpriteManager::createItem(int id, int itemId, int x, int y)
+{
+ FloorItem *floorItem = new FloorItem(id, itemId, x, y, mMap);
+
+ mActors.push_back(floorItem);
+ return floorItem;
+}
+
+void ActorSpriteManager::destroy(ActorSprite *actor)
+{
+ mDeleteActors.push_back(actor);
+}
+
+Being *ActorSpriteManager::findBeing(int id) const
+{
+ for_actors
+ {
+ ActorSprite *actor = *it;
+ if (actor->getId() == id &&
+ actor->getType() != ActorSprite::FLOOR_ITEM)
+ return static_cast<Being*>(actor);
+ }
+
+ return NULL;
+}
+
+Being *ActorSpriteManager::findBeing(int x, int y, ActorSprite::Type type) const
+{
+ beingFinder.x = x;
+ beingFinder.y = y;
+ beingFinder.type = type;
+
+ ActorSpritesConstIterator it = find_if(mActors.begin(), mActors.end(),
+ beingFinder);
+
+ return (it == mActors.end()) ? NULL : static_cast<Being*>(*it);
+}
+
+Being *ActorSpriteManager::findBeingByPixel(int x, int y) const
+{
+ for_actors
+ {
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *being = static_cast<Being*>(*it);
+
+ int xtol = being->getWidth() / 2;
+ int uptol = being->getHeight();
+
+ if ((being->isAlive()) &&
+ (being != player_node) &&
+ (being->getPixelX() - xtol <= x) &&
+ (being->getPixelX() + xtol >= x) &&
+ (being->getPixelY() - uptol <= y) &&
+ (being->getPixelY() >= y))
+ return being;
+ }
+
+ return NULL;
+}
+
+FloorItem *ActorSpriteManager::findItem(int id) const
+{
+ for_actors
+ {
+ if ((*it)->getId() == id &&
+ (*it)->getType() == ActorSprite::FLOOR_ITEM)
+ {
+ return static_cast<FloorItem*>(*it);
+ }
+ }
+
+ return NULL;
+}
+
+FloorItem *ActorSpriteManager::findItem(int x, int y) const
+{
+ for_actors
+ {
+ if ((*it)->getTileX() == x && (*it)->getTileY() == y &&
+ (*it)->getType() == ActorSprite::FLOOR_ITEM)
+ {
+ return static_cast<FloorItem*>(*it);
+ }
+ }
+
+ return NULL;
+}
+
+Being *ActorSpriteManager::findBeingByName(const std::string &name,
+ ActorSprite::Type type) const
+{
+ for_actors
+ {
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *being = static_cast<Being*>(*it);
+ if (being->getName() == name &&
+ (type == ActorSprite::UNKNOWN || type == being->getType()))
+ return being;
+ }
+ return NULL;
+}
+
+const ActorSprites &ActorSpriteManager::getAll() const
+{
+ return mActors;
+}
+
+void ActorSpriteManager::logic()
+{
+ for_actors
+ (*it)->logic();
+
+ for (it = mDeleteActors.begin(), it_end = mDeleteActors.end();
+ it != it_end; ++it)
+ {
+ viewport->clearHover(*it);
+ mActors.remove(*it);
+ delete *it;
+ }
+
+ mDeleteActors.clear();
+}
+
+void ActorSpriteManager::clear()
+{
+ if (player_node)
+ {
+ player_node->setTarget(0);
+ mActors.remove(player_node);
+ }
+
+ delete_all(mActors);
+ mActors.clear();
+ mDeleteActors.clear();
+
+ if (player_node)
+ mActors.push_back(player_node);
+}
+
+Being *ActorSpriteManager::findNearestLivingBeing(int x, int y,
+ int maxTileDist,
+ ActorSprite::Type type,
+ Being *excluded) const
+{
+ Being *closestBeing = 0;
+ int dist = 0;
+
+ const int maxDist = maxTileDist * 32;
+
+ for_actors
+ {
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *being = static_cast<Being*>(*it);
+ const Vector &pos = being->getPosition();
+ int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
+
+ if ((being->getType() == type || type == ActorSprite::UNKNOWN)
+ && (d < dist || !closestBeing) // it is closer
+ && being->isAlive() // no dead beings
+ && being != excluded)
+ {
+ dist = d;
+ closestBeing = being;
+ }
+ }
+
+ return (maxDist >= dist) ? closestBeing : 0;
+}
+
+Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
+ int maxDist,
+ ActorSprite::Type type) const
+{
+ const Vector &pos = aroundBeing->getPosition();
+ return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type,
+ aroundBeing);
+}
+
+bool ActorSpriteManager::hasActorSprite(ActorSprite *actor) const
+{
+ for_actors
+ {
+ if (actor == *it)
+ return true;
+ }
+
+ return false;
+}
+
+void ActorSpriteManager::getPlayerNames(std::vector<std::string> &names,
+ bool npcNames)
+{
+ names.clear();
+
+ for_actors
+ {
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *being = static_cast<Being*>(*it);
+ if ((being->getType() == ActorSprite::PLAYER
+ || (being->getType() == ActorSprite::NPC && npcNames))
+ && being->getName() != "")
+ names.push_back(being->getName());
+ }
+}
+
+void ActorSpriteManager::updatePlayerNames()
+{
+ for_actors
+ {
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *being = static_cast<Being*>(*it);
+ if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
+ being->updateName();
+ }
+}
diff --git a/src/beingmanager.h b/src/actorspritemanager.h
index d4a39168..93a2f4ed 100644
--- a/src/beingmanager.h
+++ b/src/actorspritemanager.h
@@ -19,25 +19,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BEINGMANAGER_H
-#define BEINGMANAGER_H
+#ifndef ACTORSPRITEMANAGER_H
+#define ACTORSPRITEMANAGER_H
+#include "actorsprite.h"
#include "being.h"
+#include "flooritem.h"
class LocalPlayer;
class Map;
-typedef std::list<Being*> Beings;
+typedef std::list<ActorSprite*> ActorSprites;
+typedef ActorSprites::iterator ActorSpritesIterator;
+typedef ActorSprites::const_iterator ActorSpritesConstIterator;
-class BeingManager
+class ActorSpriteManager
{
public:
- BeingManager();
+ ActorSpriteManager();
- ~BeingManager();
+ ~ActorSpriteManager();
/**
- * Sets the map on which beings are created.
+ * Sets the map on which ActorSprites are created.
*/
void setMap(Map *map);
@@ -47,17 +51,23 @@ class BeingManager
void setPlayer(LocalPlayer *player);
/**
- * Create a being and add it to the list of beings.
+ * Create a Being and add it to the list of ActorSprites.
*/
Being *createBeing(int id, ActorSprite::Type type, int subtype);
/**
- * Remove a Being.
+ * Create a FloorItem and add it to the list of ActorSprites.
*/
- void destroyBeing(Being *being);
+ FloorItem *createItem(int id, int itemId, int x, int y);
/**
- * Returns a specific id Being.
+ * Destroys the given ActorSprite at the end of
+ * ActorSpriteManager::logic.
+ */
+ void destroy(ActorSprite *actor);
+
+ /**
+ * Returns a specific Being, by id;
*/
Being *findBeing(int id) const;
@@ -66,9 +76,23 @@ class BeingManager
*/
Being *findBeing(int x, int y,
ActorSprite::Type type = ActorSprite::UNKNOWN) const;
+
+ /**
+ * Returns a being at the specific pixel.
+ */
Being *findBeingByPixel(int x, int y) const;
/**
+ * Returns a specific FloorItem, by id.
+ */
+ FloorItem *findItem(int id) const;
+
+ /**
+ * Returns a FloorItem at specific coordinates.
+ */
+ FloorItem *findItem(int x, int y) const;
+
+ /**
* Returns a being nearest to specific coordinates.
*
* @param x X coordinate in pixels.
@@ -91,35 +115,35 @@ class BeingManager
* @param type The type of being to look for.
*/
Being *findNearestLivingBeing(Being *aroundBeing, int maxTileDist,
- ActorSprite::Type type = Being::UNKNOWN) const;
+ ActorSprite::Type type = Being::UNKNOWN) const;
/**
* Finds a being by name and (optionally) by type.
*/
Being *findBeingByName(const std::string &name,
- ActorSprite::Type type = Being::UNKNOWN) const;
+ ActorSprite::Type type = Being::UNKNOWN) const;
/**
* Returns the whole list of beings.
*/
- const Beings &getAll() const;
+ const ActorSprites &getAll() const;
/**
- * Returns true if the given being is in the manager's list, false
- * otherwise.
+ * Returns true if the given ActorSprite is in the manager's list,
+ * false otherwise.
*
- * \param being the being to search for
+ * \param actor the ActorSprite to search for
*/
- bool hasBeing(Being *being) const;
+ bool hasActorSprite(ActorSprite *actor) const;
/**
- * Performs being logic and deletes dead beings when they have been
- * dead long enough.
+ * Performs ActorSprite logic and deletes ActorSprite scheduled to be
+ * deleted.
*/
void logic();
/**
- * Destroys all beings except the local player
+ * Destroys all ActorSprites except the local player
*/
void clear();
@@ -128,17 +152,12 @@ class BeingManager
void updatePlayerNames();
- /**
- * Destroys the given Being at the end of BeingManager::logic
- */
- void scheduleDelete(Being *being);
-
protected:
- Beings mBeings;
- Beings mDeleteBeings;
+ ActorSprites mActors;
+ ActorSprites mDeleteActors;
Map *mMap;
};
-extern BeingManager *beingManager;
+extern ActorSpriteManager *actorSpriteManager;
-#endif
+#endif // ACTORSPRITEMANAGER_H
diff --git a/src/being.cpp b/src/being.cpp
index 0bf90558..2ff96c81 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -21,8 +21,8 @@
#include "being.h"
+#include "actorspritemanager.h"
#include "animatedsprite.h"
-#include "beingmanager.h"
#include "client.h"
#include "configuration.h"
#include "effectmanager.h"
@@ -864,7 +864,7 @@ void Being::logic()
if (!isAlive() && Net::getGameHandler()->removeDeadBeings() &&
(int) ((get_elapsed_time(mActionTime)
/ getWalkSpeed().x) >= frameCount))
- beingManager->scheduleDelete(this);
+ actorSpriteManager->destroy(this);
}
void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY)
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
deleted file mode 100644
index b2a9f07b..00000000
--- a/src/beingmanager.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "beingmanager.h"
-
-#include "localplayer.h"
-
-#include "gui/viewport.h"
-
-#include "utils/stringutils.h"
-#include "utils/dtor.h"
-
-#include <cassert>
-
-class FindBeingFunctor
-{
- public:
- bool operator() (Being *being)
- {
- Uint16 other_y = y + ((being->getType() == ActorSprite::NPC) ? 1 : 0);
- const Vector &pos = being->getPosition();
- return ((int) pos.x / 32 == x &&
- ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) &&
- being->isAlive() &&
- (type == ActorSprite::UNKNOWN || being->getType() == type));
- }
-
- Uint16 x, y;
- Being::Type type;
-} beingFinder;
-
-BeingManager::BeingManager()
-{
-}
-
-BeingManager::~BeingManager()
-{
- clear();
-}
-
-void BeingManager::setMap(Map *map)
-{
- mMap = map;
- if (player_node)
- player_node->setMap(map);
-}
-
-void BeingManager::setPlayer(LocalPlayer *player)
-{
- player_node = player;
- mBeings.push_back(player);
-}
-
-Being *BeingManager::createBeing(int id, ActorSprite::Type type, int subtype)
-{
- Being *being = new Being(id, type, subtype, mMap);
-
- mBeings.push_back(being);
- return being;
-}
-
-void BeingManager::destroyBeing(Being *being)
-{
- mBeings.remove(being);
- mDeleteBeings.remove(being);
- viewport->clearHoverBeing(being);
- delete being;
-}
-
-Being *BeingManager::findBeing(int id) const
-{
- for (Beings::const_iterator i = mBeings.begin(), i_end = mBeings.end();
- i != i_end; ++i)
- {
- Being *being = (*i);
- if (being->getId() == id)
- return being;
- }
- return NULL;
-}
-
-Being *BeingManager::findBeing(int x, int y, ActorSprite::Type type) const
-{
- beingFinder.x = x;
- beingFinder.y = y;
- beingFinder.type = type;
-
- Beings::const_iterator i = find_if(mBeings.begin(), mBeings.end(),
- beingFinder);
-
- return (i == mBeings.end()) ? NULL : *i;
-}
-
-Being *BeingManager::findBeingByPixel(int x, int y) const
-{
- Beings::const_iterator itr = mBeings.begin();
- Beings::const_iterator itr_end = mBeings.end();
-
- for (; itr != itr_end; ++itr)
- {
- Being *being = (*itr);
-
- int xtol = being->getWidth() / 2;
- int uptol = being->getHeight();
-
- if ((being->isAlive()) &&
- (being != player_node) &&
- (being->getPixelX() - xtol <= x) &&
- (being->getPixelX() + xtol >= x) &&
- (being->getPixelY() - uptol <= y) &&
- (being->getPixelY() >= y))
- {
- return being;
- }
- }
-
- return NULL;
-}
-
-Being *BeingManager::findBeingByName(const std::string &name,
- ActorSprite::Type type) const
-{
- for (Beings::const_iterator i = mBeings.begin(), i_end = mBeings.end();
- i != i_end; ++i)
- {
- Being *being = (*i);
- if (being->getName() == name &&
- (type == ActorSprite::UNKNOWN || type == being->getType()))
- return being;
- }
- return NULL;
-}
-
-const Beings &BeingManager::getAll() const
-{
- return mBeings;
-}
-
-void BeingManager::logic()
-{
- Beings::iterator it, it_end;
- for (it = mBeings.begin(), it_end = mBeings.end(); it != it_end; it++)
- (*it)->logic();
-
- for (it = mDeleteBeings.begin(), it_end = mDeleteBeings.end();
- it != it_end; it++)
- {
- mBeings.remove(*it);
- delete *it;
- }
-
- mDeleteBeings.clear();
-}
-
-void BeingManager::clear()
-{
- if (player_node)
- {
- player_node->setTarget(0);
- mBeings.remove(player_node);
- }
-
- delete_all(mBeings);
- mBeings.clear();
- mDeleteBeings.clear();
-
- if (player_node)
- mBeings.push_back(player_node);
-}
-
-Being *BeingManager::findNearestLivingBeing(int x, int y,
- int maxTileDist,
- ActorSprite::Type type,
- Being *excluded) const
-{
- Being *closestBeing = 0;
- int dist = 0;
-
- const int maxDist = maxTileDist * 32;
-
- Beings::const_iterator itr = mBeings.begin();
- Beings::const_iterator itr_end = mBeings.end();
-
- for (; itr != itr_end; ++itr)
- {
- Being *being = (*itr);
- const Vector &pos = being->getPosition();
- int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
-
- if ((being->getType() == type || type == ActorSprite::UNKNOWN)
- && (d < dist || !closestBeing) // it is closer
- && being->isAlive() // no dead beings
- && being != excluded)
- {
- dist = d;
- closestBeing = being;
- }
- }
-
- return (maxDist >= dist) ? closestBeing : 0;
-}
-
-Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist,
- ActorSprite::Type type) const
-{
- const Vector &pos = aroundBeing->getPosition();
- return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type,
- aroundBeing);
-}
-
-bool BeingManager::hasBeing(Being *being) const
-{
- for (Beings::const_iterator i = mBeings.begin(), i_end = mBeings.end();
- i != i_end; ++i)
- {
- if (being == *i)
- return true;
- }
-
- return false;
-}
-
-void BeingManager::getPlayerNames(std::vector<std::string> &names,
- bool npcNames)
-{
- Beings::iterator i = mBeings.begin();
- names.clear();
-
- while (i != mBeings.end())
- {
- Being *being = (*i);
- if ((being->getType() == ActorSprite::PLAYER
- || (being->getType() == ActorSprite::NPC && npcNames))
- && being->getName() != "")
- {
- names.push_back(being->getName());
- }
- ++i;
- }
-}
-
-void BeingManager::updatePlayerNames()
-{
- Beings::iterator i = mBeings.begin();
-
- while (i != mBeings.end())
- {
- Being *being = (*i);
- if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
- being->updateName();
- ++i;
- }
-}
-
-void BeingManager::scheduleDelete(Being *being)
-{
- mDeleteBeings.push_back(being);
-}
diff --git a/src/flooritemmanager.cpp b/src/flooritemmanager.cpp
deleted file mode 100644
index b4471db8..00000000
--- a/src/flooritemmanager.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "flooritemmanager.h"
-#include "flooritem.h"
-
-#include "game.h"
-
-#include "utils/dtor.h"
-
-FloorItemManager::~FloorItemManager()
-{
- clear();
-}
-
-FloorItem *FloorItemManager::create(int id, int itemId, int x, int y)
-{
- Map *map = Game::instance()->getCurrentMap();
- FloorItem *floorItem = new FloorItem(id, itemId, x, y, map);
- mFloorItems.push_back(floorItem);
- return floorItem;
-}
-
-void FloorItemManager::destroy(FloorItem *item)
-{
- mFloorItems.remove(item);
- delete item;
-}
-
-void FloorItemManager::clear()
-{
- delete_all(mFloorItems);
- mFloorItems.clear();
-}
-
-FloorItem *FloorItemManager::findById(int id) const
-{
- FloorItems::const_iterator i;
- for (i = mFloorItems.begin(); i != mFloorItems.end(); i++)
- {
- if ((*i)->getId() == id)
- {
- return *i;
- }
- }
-
- return NULL;
-}
-
-FloorItem *FloorItemManager::findByCoordinates(int x, int y) const
-{
- FloorItems::const_iterator i;
- for (i = mFloorItems.begin(); i != mFloorItems.end(); i++)
- {
- if ((*i)->getTileX() == x && (*i)->getTileY() == y)
- {
- return *i;
- }
- }
-
- return NULL;
-}
-
-void FloorItemManager::logic()
-{
- FloorItemIterator it, it_end;
-
- for (it = mFloorItems.begin(), it_end = mFloorItems.end(); it != it_end;
- it++)
- (*it)->logic();
-}
diff --git a/src/flooritemmanager.h b/src/flooritemmanager.h
deleted file mode 100644
index 7df6288e..00000000
--- a/src/flooritemmanager.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * The Mana Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef FLOORITEMMANAGER_H
-#define FLOORITEMMANAGER_H
-
-#include <list>
-
-class FloorItem;
-class Map;
-
-class FloorItemManager
-{
- public:
- ~FloorItemManager();
-
- FloorItem *create(int id, int itemId, int x, int y);
-
- void destroy(FloorItem *item);
-
- void clear();
-
- FloorItem *findById(int id) const;
- FloorItem *findByCoordinates(int x, int y) const;
-
- /**
- * Performs floor item logic.
- */
- void logic();
-
- private:
- typedef std::list<FloorItem*> FloorItems;
- typedef FloorItems::iterator FloorItemIterator;
- FloorItems mFloorItems;
-
-};
-
-// TODO Get rid of the global?
-extern FloorItemManager *floorItemManager;
-
-#endif
diff --git a/src/game.cpp b/src/game.cpp
index c7c1d213..c867bda9 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -21,15 +21,14 @@
#include "game.h"
+#include "actorspritemanager.h"
#include "actorsprite.h"
-#include "beingmanager.h"
#include "channelmanager.h"
#include "client.h"
#include "commandhandler.h"
#include "configuration.h"
#include "effectmanager.h"
#include "emoteshortcut.h"
-#include "flooritemmanager.h"
#include "graphics.h"
#include "itemshortcut.h"
#include "joystick.h"
@@ -115,8 +114,7 @@ OutfitWindow *outfitWindow;
SpecialsWindow *specialsWindow;
SocialWindow *socialWindow;
-BeingManager *beingManager = NULL;
-FloorItemManager *floorItemManager = NULL;
+ActorSpriteManager *actorSpriteManager = NULL;
ChannelManager *channelManager = NULL;
CommandHandler *commandHandler = NULL;
Particle *particleEngine = NULL;
@@ -130,9 +128,8 @@ ChatTab *localChatTab = NULL;
*/
static void initEngines()
{
- beingManager = new BeingManager;
+ actorSpriteManager = new ActorSpriteManager;
commandHandler = new CommandHandler;
- floorItemManager = new FloorItemManager;
channelManager = new ChannelManager;
effectManager = new EffectManager;
@@ -233,7 +230,7 @@ Game::Game():
Net::getGameHandler()->inGame();
// Initialize beings
- beingManager->setPlayer(player_node);
+ actorSpriteManager->setPlayer(player_node);
/*
* To prevent the server from sending data before the client
@@ -261,10 +258,9 @@ Game::~Game()
destroyGuiWindows();
- del_0(beingManager)
+ del_0(actorSpriteManager)
if (Client::getState() != STATE_CHANGE_MAP)
del_0(player_node)
- del_0(floorItemManager)
del_0(channelManager)
del_0(commandHandler)
del_0(joystick)
@@ -335,8 +331,7 @@ void Game::logic()
// Handle all necessary game logic
ActorSprite::actorLogic();
- beingManager->logic();
- floorItemManager->logic();
+ actorSpriteManager->logic();
particleEngine->update();
if (mCurrentMap)
mCurrentMap->update();
@@ -451,7 +446,8 @@ void Game::handleInput()
}
- if (!chatWindow->isInputFocused() || (event.key.keysym.mod & KMOD_ALT))
+ if (!chatWindow->isInputFocused() || (event.key.keysym.mod &
+ KMOD_ALT))
{
if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB))
{
@@ -603,7 +599,7 @@ void Game::handleInput()
// off under eAthena.
FloorItem *item =
- floorItemManager->findByCoordinates(x, y);
+ actorSpriteManager->findItem(x, y);
// If none below the player, try the tile in front
// of the player
@@ -620,8 +616,7 @@ void Game::handleInput()
default: break;
}
- item = floorItemManager->findByCoordinates(
- x, y);
+ item = actorSpriteManager->findItem(x, y);
}
if (item)
@@ -833,8 +828,8 @@ void Game::handleInput()
if (!player_node->getTarget())
{
// Only auto target Monsters
- target = beingManager->findNearestLivingBeing(player_node,
- 20, ActorSprite::MONSTER);
+ target = actorSpriteManager->findNearestLivingBeing(player_node,
+ 20, ActorSprite::MONSTER);
}
player_node->attack(target, newTarget);
}
@@ -855,7 +850,7 @@ void Game::handleInput()
else if (keyboard.isKeyActive(keyboard.KEY_TARGET_NPC))
currentTarget = ActorSprite::NPC;
- Being *target = beingManager->findNearestLivingBeing(player_node,
+ Being *target = actorSpriteManager->findNearestLivingBeing(player_node,
20, currentTarget);
if (target && (target != player_node->getTarget() ||
@@ -894,7 +889,7 @@ void Game::handleInput()
{
if (joystick->buttonPressed(1))
{
- FloorItem *item = floorItemManager->findByCoordinates(x, y);
+ FloorItem *item = actorSpriteManager->findItem(x, y);
if (item)
player_node->pickUp(item);
@@ -914,8 +909,7 @@ void Game::handleInput()
void Game::changeMap(const std::string &mapPath)
{
// Clean up floor items, beings and particles
- floorItemManager->clear();
- beingManager->clear();
+ actorSpriteManager->clear();
// Close the popup menu on map change so that invalid options can't be
// executed.
@@ -947,7 +941,7 @@ void Game::changeMap(const std::string &mapPath)
// Notify the minimap and beingManager about the map change
minimap->setMap(newMap);
- beingManager->setMap(newMap);
+ actorSpriteManager->setMap(newMap);
particleEngine->setMap(newMap);
viewport->setMap(newMap);
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 83aaed26..da1bd600 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -21,7 +21,7 @@
#include "chat.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configuration.h"
#include "localplayer.h"
#include "party.h"
@@ -266,20 +266,20 @@ void ChatWindow::chatInput(const std::string &msg)
void ChatWindow::doPresent()
{
- const Beings &beings = beingManager->getAll();
+ const ActorSprites &actors = actorSpriteManager->getAll();
std::string response = "";
int playercount = 0;
- for (Beings::const_iterator bi = beings.begin(), be = beings.end();
- bi != be; ++bi)
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- if ((*bi)->getType() == ActorSprite::PLAYER)
+ if ((*it)->getType() == ActorSprite::PLAYER)
{
if (!response.empty())
{
response += ", ";
}
- response += (*bi)->getName();
+ response += static_cast<Being*>(*it)->getName();
++playercount;
}
}
@@ -531,7 +531,7 @@ void ChatWindow::autoComplete()
if (newName == "")
{
- beingManager->getPlayerNames(nameList, true);
+ actorSpriteManager->getPlayerNames(nameList, true);
newName = autoComplete(nameList, name);
}
if (newName == "")
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index b4445d94..e973fa54 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -21,8 +21,8 @@
#include "gui/minimap.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
#include "localplayer.h"
@@ -186,12 +186,15 @@ void Minimap::draw(gcn::Graphics *graphics)
drawImage(mMapImage, mapOriginX, mapOriginY);
}
- const Beings &beings = beingManager->getAll();
+ const ActorSprites &actors = actorSpriteManager->getAll();
- for (Beings::const_iterator bi = beings.begin(), bi_end = beings.end();
- bi != bi_end; ++bi)
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- const Being *being = (*bi);
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ const Being *being = static_cast<Being*>(*it);
int dotSize = 2;
int type = UserPalette::PC;
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 0dae4f4b..76569d38 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -21,8 +21,8 @@
#include "gui/popupmenu.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "flooritem.h"
#include "graphics.h"
#include "item.h"
@@ -199,7 +199,7 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
void PopupMenu::handleLink(const std::string &link)
{
- Being *being = beingManager->findBeing(mBeingId);
+ Being *being = actorSpriteManager->findBeing(mBeingId);
// Talk To action
if (link == "talk" && being && being->canTalk())
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index d92d7917..15cc787a 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -21,7 +21,7 @@
#include "gui/setup_players.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configuration.h"
#include "log.h"
@@ -354,8 +354,8 @@ void Setup_Players::apply()
config.setValue("showgender", mShowGender);
- if (beingManager && mShowGender != showGender)
- beingManager->updatePlayerNames();
+ if (actorSpriteManager && mShowGender != showGender)
+ actorSpriteManager->updatePlayerNames();
config.setValue("enableChatLog", mEnableChatLog);
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 3e1f2581..66f614a8 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -21,10 +21,9 @@
#include "gui/viewport.h"
+#include "actorspritemanager.h"
#include "client.h"
-#include "beingmanager.h"
#include "configuration.h"
-#include "flooritemmanager.h"
#include "graphics.h"
#include "keyboardconfig.h"
#include "localplayer.h"
@@ -204,12 +203,16 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
}
// Draw player names, speech, and emotion sprite as needed
- const Beings &beings = beingManager->getAll();
- for (Beings::const_iterator i = beings.begin(), i_end = beings.end();
- i != i_end; ++i)
+ const ActorSprites &actors = actorSpriteManager->getAll();
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- (*i)->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
- (*i)->drawEmotion(graphics, (int) mPixelViewX, (int) mPixelViewY);
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *b = static_cast<Being*>(*it);
+ b->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
+ b->drawEmotion(graphics, (int) mPixelViewX, (int) mPixelViewY);
}
if (miniStatusWindow)
@@ -417,7 +420,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
// Find the being nearest to the clicked position
- Being *target = beingManager->findNearestLivingBeing(
+ Being *target = actorSpriteManager->findNearestLivingBeing(
pixelX, pixelY, 20, ActorSprite::MONSTER);
if (target)
@@ -491,11 +494,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
const int x = (event.getX() + (int) mPixelViewX);
const int y = (event.getY() + (int) mPixelViewY);
- mHoverBeing = beingManager->findBeingByPixel(x, y);
+ mHoverBeing = actorSpriteManager->findBeingByPixel(x, y);
mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing);
- mHoverItem = floorItemManager->findByCoordinates(x / mMap->getTileWidth(),
- y / mMap->getTileHeight());
+ mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
+ y / mMap->getTileHeight());
if (mHoverBeing)
{
@@ -542,8 +545,11 @@ void Viewport::hideBeingPopup()
mBeingPopup->setVisible(false);
}
-void Viewport::clearHoverBeing(Being *being)
+void Viewport::clearHover(ActorSprite *actor)
{
- if (mHoverBeing == being)
+ if (mHoverBeing == actor)
mHoverBeing = 0;
+
+ if (mHoverItem == actor)
+ mHoverItem = 0;
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 9658f934..f91504f2 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -22,7 +22,7 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configlistener.h"
#include "position.h"
@@ -30,6 +30,7 @@
#include <guichan/mouselistener.hpp>
+class ActorSprite;
class Being;
class BeingPopup;
class FloorItem;
@@ -159,10 +160,10 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void hideBeingPopup();
protected:
- friend class BeingManager;
+ friend class ActorSpriteManager;
- /// Clears the hovered being if it matches
- void clearHoverBeing(Being *being);
+ /// Clears any matching hovers
+ void clearHover(ActorSprite *actor);
private:
/**
diff --git a/src/guild.cpp b/src/guild.cpp
index 602e2306..00d8614e 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -21,7 +21,7 @@
#include "guild.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
GuildMember::GuildMember(Guild *guild, int id, const std::string &name):
Avatar(name), mId(id), mGuild(guild)
@@ -149,7 +149,7 @@ void Guild::removeFromMembers()
itr_end = mMembers.end();
while(itr != itr_end)
{
- Being *b = beingManager->findBeing((*itr)->getID());
+ Being *b = actorSpriteManager->findBeing((*itr)->getID());
b->removeGuild(getId());
++itr;
}
diff --git a/src/map.cpp b/src/map.cpp
index b308c775..7b62746b 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -21,7 +21,7 @@
#include "map.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "client.h"
#include "configuration.h"
#include "graphics.h"
@@ -532,12 +532,14 @@ bool Map::getWalk(int x, int y, unsigned char walkmask) const
bool Map::occupied(int x, int y) const
{
- const Beings &beings = beingManager->getAll();
- for (Beings::const_iterator i = beings.begin(); i != beings.end(); i++)
+ const ActorSprites &actors = actorSpriteManager->getAll();
+ ActorSpritesConstIterator it, it_end;
+ for (it = actors.begin(), it_end = actors.end(); it != it_end; it++)
{
- const Being *being = *i;
+ const ActorSprite *actor = *it;
- if (being->getTileX() == x && being->getTileY() == y)
+ if (actor->getTileX() == x && actor->getTileY() == y &&
+ actor->getType() != ActorSprite::FLOOR_ITEM)
return true;
}
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 705074c1..57830680 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -21,8 +21,8 @@
#include "net/manaserv/beinghandler.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "client.h"
#include "game.h"
#include "localplayer.h"
@@ -169,7 +169,8 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
}
else
{
- being = beingManager->createBeing(id, ActorSprite::PLAYER, 0);
+ being = actorSpriteManager->createBeing(id,
+ ActorSprite::PLAYER, 0);
being->setName(name);
}
int hs = msg.readInt8(), hc = msg.readInt8();
@@ -183,8 +184,8 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
case OBJECT_NPC:
{
int subtype = msg.readInt16();
- being = beingManager->createBeing(id, type == OBJECT_MONSTER ?
- ActorSprite::MONSTER : ActorSprite::NPC, subtype);
+ being = actorSpriteManager->createBeing(id, type == OBJECT_MONSTER
+ ? ActorSprite::MONSTER : ActorSprite::NPC, subtype);
std::string name = msg.readString();
if (name.length() > 0) being->setName(name);
} break;
@@ -200,11 +201,11 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingLeaveMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being)
return;
- beingManager->destroyBeing(being);
+ actorSpriteManager->destroy(being);
}
void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
@@ -213,7 +214,7 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
{
int id = msg.readInt16();
int flags = msg.readInt8();
- Being *being = beingManager->findBeing(id);
+ Being *being = actorSpriteManager->findBeing(id);
int sx = 0;
int sy = 0;
int speed = 0;
@@ -255,7 +256,7 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
const int direction = msg.readInt8();
const int attackType = msg.readInt8();
@@ -277,7 +278,7 @@ void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
{
while (msg.getUnreadLength())
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
int damage = msg.readInt16();
if (being)
{
@@ -288,7 +289,7 @@ void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
Being::Action action = (Being::Action) msg.readInt8();
if (!being)
return;
@@ -327,7 +328,7 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::PLAYER)
return;
handleLooks(being, msg);
@@ -341,7 +342,7 @@ void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingDirChangeMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being)
return;
int data = msg.readInt8();
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index 0a578a56..cfd55e2e 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/buysellhandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "item.h"
#include "localplayer.h"
@@ -48,7 +48,7 @@ BuySellHandler::BuySellHandler()
void BuySellHandler::handleMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
{
return;
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index a452281f..37ce2bf5 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -21,8 +21,8 @@
#include "net/manaserv/chathandler.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "client.h"
#include "channel.h"
#include "channelmanager.h"
@@ -153,7 +153,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
return;
}
- Being *being = beingManager->findBeing(id);
+ Being *being = actorSpriteManager->findBeing(id);
std::string mes;
if (being)
diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp
index 27db9b59..c803b441 100644
--- a/src/net/manaserv/effecthandler.cpp
+++ b/src/net/manaserv/effecthandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/effecthandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "effectmanager.h"
#include "log.h"
@@ -68,7 +68,7 @@ void EffectHandler::handleCreateEffectBeing(Net::MessageIn &msg)
{
int eid = msg.readInt16();
int bid = msg.readInt16();
- Being* b = beingManager->findBeing(bid);
+ Being* b = actorSpriteManager->findBeing(bid);
if (b)
effectManager->trigger(eid, b);
else
diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp
index dc3b9f14..200e7fac 100644
--- a/src/net/manaserv/itemhandler.cpp
+++ b/src/net/manaserv/itemhandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/itemhandler.h"
-#include "flooritemmanager.h"
+#include "actorspritemanager.h"
#include "net/manaserv/protocol.h"
#include "net/manaserv/messagein.h"
@@ -62,8 +62,7 @@ void ItemHandler::handleMessage(Net::MessageIn &msg)
{
if (Map *map = game->getCurrentMap())
{
- floorItemManager->create(id,
- itemId,
+ actorSpriteManager->createItem(id, itemId,
x / map->getTileWidth(),
y / map->getTileHeight());
}
@@ -75,9 +74,9 @@ void ItemHandler::handleMessage(Net::MessageIn &msg)
}
}
}
- else if (FloorItem *item = floorItemManager->findById(id))
+ else if (FloorItem *item = actorSpriteManager->findItem(id))
{
- floorItemManager->destroy(item);
+ actorSpriteManager->destroy(item);
}
}
} break;
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 6c4a2706..509f26e1 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/npchandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "gui/npcdialog.h"
#include "gui/npcpostdialog.h"
@@ -55,7 +55,7 @@ NpcHandler::NpcHandler()
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
{
return;
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index 234a18d6..b6169ac9 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -21,7 +21,7 @@
#include "net/manaserv/tradehandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "item.h"
#include "localplayer.h"
@@ -104,7 +104,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
{
case GPMSG_TRADE_REQUEST:
{
- Being *being = beingManager->findBeing(msg.readInt16());
+ Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || !mAcceptTradeRequests)
{
respond(false);
diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp
index e56d5a44..da089b2b 100644
--- a/src/net/tmwa/adminhandler.cpp
+++ b/src/net/tmwa/adminhandler.cpp
@@ -21,8 +21,8 @@
#include "net/tmwa/adminhandler.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "game.h"
#include "playerrelations.h"
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 0e89ad18..5c89cd31 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -21,8 +21,8 @@
#include "net/tmwa/beinghandler.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "client.h"
#include "effectmanager.h"
#include "guild.h"
@@ -83,7 +83,7 @@ Being *createBeing(int id, short job)
else if (job == 45)
return NULL; // Skip portals
- Being *being = beingManager->createBeing(id, type, job);
+ Being *being = actorSpriteManager->createBeing(id, type, job);
if (type == ActorSprite::PLAYER || type == ActorSprite::NPC)
{
@@ -96,7 +96,7 @@ Being *createBeing(int id, short job)
void BeingHandler::handleMessage(Net::MessageIn &msg)
{
- if (!beingManager)
+ if (!actorSpriteManager)
return;
int id;
@@ -126,7 +126,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
statusEffects |= ((Uint32)msg.readInt16()) << 16; // option
job = msg.readInt16(); // class
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
{
@@ -233,7 +233,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
* later versions of eAthena for both mobs and
* players
*/
- dstBeing = beingManager->findBeing(msg.readInt32());
+ dstBeing = actorSpriteManager->findBeing(msg.readInt32());
Uint16 srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
@@ -258,7 +258,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
// A being should be removed or has died
id = msg.readInt32();
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
break;
@@ -280,7 +280,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
if (msg.readInt8() == 1)
dstBeing->setAction(Being::DEAD);
else
- beingManager->destroyBeing(dstBeing);
+ actorSpriteManager->destroy(dstBeing);
break;
@@ -288,7 +288,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
// A being changed mortality status
id = msg.readInt32();
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
break;
@@ -304,8 +304,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
case SMSG_SKILL_DAMAGE:
msg.readInt16(); // Skill Id
- srcBeing = beingManager->findBeing(msg.readInt32());
- dstBeing = beingManager->findBeing(msg.readInt32());
+ srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // Server tick
msg.readInt32(); // src speed
msg.readInt32(); // dst speed
@@ -320,8 +320,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_BEING_ACTION:
- srcBeing = beingManager->findBeing(msg.readInt32());
- dstBeing = beingManager->findBeing(msg.readInt32());
+ srcBeing = actorSpriteManager->findBeing(msg.readInt32());
+ dstBeing = actorSpriteManager->findBeing(msg.readInt32());
msg.readInt32(); // server tick
msg.readInt32(); // src speed
msg.readInt32(); // dst speed
@@ -363,11 +363,11 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
case SMSG_BEING_SELFEFFECT: {
id = (Uint32)msg.readInt32();
- if (!beingManager->findBeing(id))
+ if (!actorSpriteManager->findBeing(id))
break;
int effectType = msg.readInt32();
- Being* being = beingManager->findBeing(id);
+ Being* being = actorSpriteManager->findBeing(id);
effectManager->trigger(effectType, being);
@@ -375,7 +375,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
}
case SMSG_BEING_EMOTION:
- if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
+ if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
break;
}
@@ -404,7 +404,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
* 16 bit value will be 0.
*/
- if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
+ if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
break;
}
@@ -471,13 +471,13 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_BEING_NAME_RESPONSE:
- if ((dstBeing = beingManager->findBeing(msg.readInt32())))
+ if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
dstBeing->setName(msg.readString(24));
}
break;
case SMSG_PLAYER_GUILD_PARTY_INFO:
- if ((dstBeing = beingManager->findBeing(msg.readInt32())))
+ if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
dstBeing->setPartyName(msg.readString(24));
dstBeing->setGuildName(msg.readString(24));
@@ -486,7 +486,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
}
break;
case SMSG_BEING_CHANGE_DIRECTION:
- if (!(dstBeing = beingManager->findBeing(msg.readInt32())))
+ if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
break;
}
@@ -509,7 +509,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
<< 16; // status.options; Aethyra uses this as misc2
job = msg.readInt16();
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (!dstBeing)
{
@@ -639,7 +639,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
id = msg.readInt32();
if (mSync || id != player_node->getId())
{
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
{
Uint16 x, y;
@@ -664,7 +664,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
case SMSG_PLAYER_STATUS_CHANGE:
// Change in players' flags
id = msg.readInt32();
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
stunMode = msg.readInt16();
statusEffects = msg.readInt16();
statusEffects |= ((Uint32) msg.readInt16()) << 16;
@@ -684,7 +684,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
id = msg.readInt32();
flag = msg.readInt8(); // 0: stop, 1: start
- dstBeing = beingManager->findBeing(id);
+ dstBeing = actorSpriteManager->findBeing(id);
if (dstBeing)
dstBeing->setStatusEffect(status, flag);
break;
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index e231c54c..4a478396 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/buysellhandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 640d04c1..493df0e5 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -21,8 +21,8 @@
#include "net/tmwa/chathandler.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "game.h"
#include "localplayer.h"
#include "playerrelations.h"
@@ -112,7 +112,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
// Received speech from being
case SMSG_BEING_CHAT: {
chatMsgLength = msg.readInt16() - 8;
- being = beingManager->findBeing(msg.readInt32());
+ being = actorSpriteManager->findBeing(msg.readInt32());
if (!being || chatMsgLength <= 0)
break;
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
index abc8103b..a8e98860 100644
--- a/src/net/tmwa/itemhandler.cpp
+++ b/src/net/tmwa/itemhandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/itemhandler.h"
-#include "flooritemmanager.h"
+#include "actorspritemanager.h"
#include "net/messagein.h"
@@ -54,13 +54,13 @@ void ItemHandler::handleMessage(Net::MessageIn &msg)
int y = msg.readInt16();
msg.skip(4); // amount,subX,subY / subX,subY,amount
- floorItemManager->create(id, itemId, x, y);
+ actorSpriteManager->createItem(id, itemId, x, y);
}
break;
case SMSG_ITEM_REMOVE:
- if (FloorItem *item = floorItemManager->findById(msg.readInt32()))
- floorItemManager->destroy(item);
+ if (FloorItem *item = actorSpriteManager->findItem(msg.readInt32()))
+ actorSpriteManager->destroy(item);
break;
}
}
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index b54a0ba7..bd655fa6 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -21,7 +21,7 @@
#include "net/tmwa/npchandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "localplayer.h"
#include "gui/npcdialog.h"
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 90ecc0d4..21b66e66 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -20,7 +20,7 @@
#include "net/tmwa/partyhandler.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "localplayer.h"
#include "log.h"
@@ -143,7 +143,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
std::string nick = "";
Being *being;
- if (!(being = beingManager->findBeing(id)))
+ if (!(being = actorSpriteManager->findBeing(id)))
{
nick = being->getName();
}
@@ -249,7 +249,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
partyTab->chatLog(strprintf(_("%s has left your party."),
nick.c_str()), BY_SERVER);
- Being *b = beingManager->findBeing(id);
+ Being *b = actorSpriteManager->findBeing(id);
b->setParty(NULL);
taParty->removeMember(id);
@@ -270,7 +270,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
// The server only sends this when the member is in range, so
// lets make sure they get the party hilight.
- if (Being *b = beingManager->findBeing(id))
+ if (Being *b = actorSpriteManager->findBeing(id))
{
b->setParty(taParty);
}
diff --git a/src/party.cpp b/src/party.cpp
index d29d84b3..77174d52 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -20,7 +20,7 @@
#include "party.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
PartyMember::PartyMember(Party *party, int id, const std::string &name):
Avatar(name), mId(id), mParty(party), mLeader(false)
@@ -143,7 +143,7 @@ void Party::removeFromMembers()
itr_end = mMembers.end();
while(itr != itr_end)
{
- Being *b = beingManager->findBeing((*itr)->getID());
+ Being *b = actorSpriteManager->findBeing((*itr)->getID());
b->setParty(NULL);
++itr;
}
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index e8c015d1..77d3fddd 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -21,8 +21,8 @@
#include <algorithm>
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
#include "playerrelations.h"
@@ -220,8 +220,8 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
// execute `ignore' strategy, if possible
if (mIgnoreStrategy)
{
- Being *b = beingManager->findBeingByName(name,
- ActorSprite::PLAYER);
+ Being *b = actorSpriteManager->findBeingByName(name,
+ ActorSprite::PLAYER);
if (b && b->getType() == ActorSprite::PLAYER)
mIgnoreStrategy->ignore(b, rejections);
}