summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/Makefile.am12
-rw-r--r--src/being.cpp507
-rw-r--r--src/being.h165
-rw-r--r--src/beingmanager.cpp47
-rw-r--r--src/beingmanager.h11
-rw-r--r--src/game.cpp21
-rw-r--r--src/gui/beingpopup.cpp12
-rw-r--r--src/gui/beingpopup.h4
-rw-r--r--src/gui/buy.cpp7
-rw-r--r--src/gui/buysell.cpp2
-rw-r--r--src/gui/charcreatedialog.cpp2
-rw-r--r--src/gui/charcreatedialog.h4
-rw-r--r--src/gui/charselectdialog.h2
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/minimap.cpp56
-rw-r--r--src/gui/npcdialog.cpp1
-rw-r--r--src/gui/npcdialog.h1
-rw-r--r--src/gui/npcpostdialog.cpp2
-rw-r--r--src/gui/popupmenu.cpp38
-rw-r--r--src/gui/register.h2
-rw-r--r--src/gui/sell.cpp1
-rw-r--r--src/gui/socialwindow.cpp2
-rw-r--r--src/gui/viewport.cpp44
-rw-r--r--src/gui/widgets/playerbox.cpp12
-rw-r--r--src/gui/widgets/playerbox.h8
-rw-r--r--src/guild.cpp5
-rw-r--r--src/localplayer.cpp28
-rw-r--r--src/localplayer.h14
-rw-r--r--src/monster.cpp171
-rw-r--r--src/monster.h97
-rw-r--r--src/net/charhandler.h6
-rw-r--r--src/net/guildhandler.h5
-rw-r--r--src/net/logindata.h2
-rw-r--r--src/net/manaserv/beinghandler.cpp23
-rw-r--r--src/net/manaserv/buysellhandler.cpp3
-rw-r--r--src/net/manaserv/charhandler.cpp6
-rw-r--r--src/net/manaserv/charhandler.h6
-rw-r--r--src/net/manaserv/guildhandler.cpp4
-rw-r--r--src/net/manaserv/guildhandler.h2
-rw-r--r--src/net/manaserv/npchandler.cpp3
-rw-r--r--src/net/manaserv/partyhandler.cpp6
-rw-r--r--src/net/manaserv/partyhandler.h4
-rw-r--r--src/net/manaserv/playerhandler.cpp1
-rw-r--r--src/net/partyhandler.h6
-rw-r--r--src/net/tmwa/beinghandler.cpp112
-rw-r--r--src/net/tmwa/buysellhandler.cpp1
-rw-r--r--src/net/tmwa/charserverhandler.cpp6
-rw-r--r--src/net/tmwa/charserverhandler.h6
-rw-r--r--src/net/tmwa/guildhandler.cpp4
-rw-r--r--src/net/tmwa/guildhandler.h2
-rw-r--r--src/net/tmwa/npchandler.cpp1
-rw-r--r--src/net/tmwa/partyhandler.cpp18
-rw-r--r--src/net/tmwa/partyhandler.h4
-rw-r--r--src/net/tmwa/playerhandler.cpp1
-rw-r--r--src/net/tmwa/token.h2
-rw-r--r--src/npc.cpp76
-rw-r--r--src/npc.h67
-rw-r--r--src/party.cpp4
-rw-r--r--src/player.cpp352
-rw-r--r--src/player.h161
-rw-r--r--src/playerrelations.cpp24
-rw-r--r--src/playerrelations.h3
-rw-r--r--src/resources/beinginfo.cpp89
-rw-r--r--src/resources/beinginfo.h130
-rw-r--r--src/resources/iteminfo.h2
-rw-r--r--src/resources/monsterdb.cpp50
-rw-r--r--src/resources/monsterdb.h9
-rw-r--r--src/resources/monsterinfo.cpp93
-rw-r--r--src/resources/monsterinfo.h102
-rw-r--r--src/resources/npcdb.cpp50
-rw-r--r--src/resources/npcdb.h10
-rw-r--r--src/resources/spritedef.cpp3
-rw-r--r--src/resources/spritedef.h7
74 files changed, 1131 insertions, 1625 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6ccdd4e2..5f8fd3ff 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -346,6 +346,8 @@ SET(SRCS
resources/ambientoverlay.h
resources/animation.cpp
resources/animation.h
+ resources/beinginfo.cpp
+ resources/beinginfo.h
resources/colordb.cpp
resources/colordb.h
resources/dye.cpp
@@ -368,8 +370,6 @@ SET(SRCS
resources/mapreader.h
resources/monsterdb.cpp
resources/monsterdb.h
- resources/monsterinfo.cpp
- resources/monsterinfo.h
resources/music.cpp
resources/music.h
resources/npcdb.cpp
@@ -467,10 +467,6 @@ SET(SRCS
main.h
map.cpp
map.h
- monster.cpp
- monster.h
- npc.cpp
- npc.h
openglgraphics.cpp
openglgraphics.h
particle.cpp
@@ -482,8 +478,6 @@ SET(SRCS
particleemitterprop.h
party.cpp
party.h
- player.cpp
- player.h
playerrelations.cpp
playerrelations.h
position.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index d0ee9948..a34678a4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -228,9 +228,9 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
net/messagein.h \
net/messageout.cpp \
net/messageout.h \
- net/npchandler.h \
net/net.cpp \
net/net.h \
+ net/npchandler.h \
net/partyhandler.h \
net/playerhandler.h \
net/serverinfo.h \
@@ -245,6 +245,8 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
resources/ambientoverlay.h \
resources/animation.cpp \
resources/animation.h \
+ resources/beinginfo.cpp \
+ resources/beinginfo.h \
resources/colordb.cpp \
resources/colordb.h \
resources/dye.cpp \
@@ -267,8 +269,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
resources/mapreader.h \
resources/monsterdb.cpp \
resources/monsterdb.h \
- resources/monsterinfo.cpp \
- resources/monsterinfo.h \
resources/music.cpp \
resources/music.h \
resources/npcdb.cpp \
@@ -368,10 +368,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
main.h \
map.cpp\
map.h \
- monster.cpp\
- monster.h \
- npc.cpp \
- npc.h \
openglgraphics.cpp\
openglgraphics.h \
particle.cpp \
@@ -383,8 +379,6 @@ mana_SOURCES = gui/widgets/avatarlistbox.cpp \
particleemitterprop.h \
party.cpp \
party.h \
- player.cpp \
- player.h \
playerrelations.cpp \
playerrelations.h \
position.cpp \
diff --git a/src/being.cpp b/src/being.cpp
index 2ce34f94..a2180c84 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -26,31 +26,44 @@
#include "configuration.h"
#include "effectmanager.h"
#include "graphics.h"
+#include "guild.h"
#include "localplayer.h"
#include "log.h"
#include "map.h"
#include "particle.h"
+#include "party.h"
#include "simpleanimation.h"
#include "sound.h"
#include "sprite.h"
#include "text.h"
#include "statuseffect.h"
+#include "gui/buy.h"
+#include "gui/buysell.h"
#include "gui/gui.h"
+#include "gui/npcdialog.h"
+#include "gui/npcpostdialog.h"
+#include "gui/sell.h"
+#include "gui/socialwindow.h"
#include "gui/speechbubble.h"
#include "gui/theme.h"
#include "gui/userpalette.h"
+#include "net/charhandler.h"
+#include "net/net.h"
+#include "net/npchandler.h"
+#include "net/playerhandler.h"
+
+#include "resources/beinginfo.h"
#include "resources/colordb.h"
#include "resources/emotedb.h"
#include "resources/image.h"
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
+#include "resources/monsterdb.h"
+#include "resources/npcdb.h"
#include "resources/resourcemanager.h"
-#include "net/net.h"
-#include "net/playerhandler.h"
-
#include "utils/dtor.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
@@ -62,36 +75,49 @@
static const int DEFAULT_BEING_WIDTH = 32;
static const int DEFAULT_BEING_HEIGHT = 32;
-
-
int Being::mNumberOfHairstyles = 1;
// TODO: mWalkTime used by eAthena only
-Being::Being(int id, int subtype, Map *map):
+Being::Being(int id, Type type, int subtype, Map *map):
ActorSprite(id),
+ mInfo(BeingInfo::Unknown),
mFrame(0),
mWalkTime(0),
mEmotion(0), mEmotionTime(0),
mSpeechTime(0),
+ mAttackType(1),
mAttackSpeed(350),
mAction(STAND),
- mSubType(subtype),
+ mSubType(0xFFFF),
mDirection(DOWN),
mSpriteDirection(DIRECTION_DOWN),
mDispName(0),
mShowName(false),
mEquippedWeapon(NULL),
mText(0),
+ mGender(GENDER_UNSPECIFIED),
+ mParty(NULL),
+ mIsGM(false),
+ mType(type),
mX(0), mY(0),
mDamageTaken(0)
{
setMap(map);
+ setSubtype(subtype);
mSpeechBubble = new SpeechBubble;
- mNameColor = &userPalette->getColor(UserPalette::NPC);
- mTextColor = &Theme::getThemeColor(Theme::CHAT);
mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed();
+
+ if (getType() == PLAYER)
+ mShowName = config.getValue("visiblenames", 1);
+
+ config.addListener("visiblenames", this);
+
+ if (getType() == PLAYER || getType() == NPC)
+ setShowName(true);
+
+ updateColors();
}
Being::~Being()
@@ -99,6 +125,53 @@ Being::~Being()
delete mSpeechBubble;
delete mDispName;
delete mText;
+
+ config.removeListener("visiblenames", this);
+}
+
+void Being::setSubtype(Uint16 subtype)
+{
+ if (subtype == mSubType)
+ return;
+
+ mSubType = subtype;
+
+ if (getType() == MONSTER)
+ {
+ mInfo = MonsterDB::get(mSubType);
+ setName(mInfo->getName());
+ setupSpriteDisplay(mInfo->getDisplay());
+ }
+ else if (getType() == NPC)
+ {
+ mInfo = NPCDB::get(mSubType);
+ setupSpriteDisplay(mInfo->getDisplay(), false);
+ }
+ else if (getType() == PLAYER)
+ {
+ int id = -100 - subtype;
+
+ // Prevent showing errors when sprite doesn't exist
+ if (!ItemDB::exists(id))
+ id = -100;
+
+ setSprite(Net::getCharHandler()->baseSprite(), id);
+ }
+}
+
+ActorSprite::TargetCursorSize Being::getTargetCursorSize() const
+{
+ return mInfo->getTargetCursorSize();
+}
+
+unsigned char Being::getWalkMask() const
+{
+ return mInfo->getWalkMask();
+}
+
+Map::BlockType Being::getBlockType() const
+{
+ return mInfo->getBlockType();
}
void Being::setPosition(const Vector &pos)
@@ -277,6 +350,8 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
if (amount > 0)
{
+ sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT));
+
if (getType() == MONSTER)
{
mDamageTaken += amount;
@@ -302,35 +377,48 @@ void Being::handleAttack(Being *victim, int damage, AttackType type)
fireMissile(victim, mEquippedWeapon->getMissileParticle());
}
}
+ else
+ fireMissile(victim, mInfo->getAttack(mAttackType)->missileParticle);
+
if (Net::getNetworkType() == ServerInfo::TMWATHENA)
{
mFrame = 0;
mWalkTime = tick_time;
}
+
+ sound.playSfx(mInfo->getSound((damage > 0) ?
+ SOUND_EVENT_HIT : SOUND_EVENT_MISS));
}
void Being::setName(const std::string &name)
{
- mName = name;
-
- if (getShowName())
+ if (getType() == NPC)
+ {
+ mName = name.substr(0, name.find('#', 0));
showName();
+ }
+ else
+ {
+ mName = name;
+
+ if (getType() == PLAYER && getShowName())
+ showName();
+ }
}
void Being::setShowName(bool doShowName)
{
- bool oldShow = mShowName;
+ if (mShowName == doShowName)
+ return;
+
mShowName = doShowName;
- if (doShowName != oldShow)
+ if (doShowName)
+ showName();
+ else
{
- if (doShowName)
- showName();
- else
- {
- delete mDispName;
- mDispName = 0;
- }
+ delete mDispName;
+ mDispName = 0;
}
}
@@ -345,6 +433,101 @@ void Being::setGuildPos(const std::string &pos)
logger->log("Got guild position \"%s\" for being %s(%i)", pos.c_str(), mName.c_str(), mId);
}
+void Being::addGuild(Guild *guild)
+{
+ mGuilds[guild->getId()] = guild;
+ guild->addMember(mId, mName);
+
+ if (this == player_node && socialWindow)
+ {
+ socialWindow->addTab(guild);
+ }
+}
+
+void Being::removeGuild(int id)
+{
+ if (this == player_node && socialWindow)
+ {
+ socialWindow->removeTab(mGuilds[id]);
+ }
+
+ mGuilds[id]->removeMember(mId);
+ mGuilds.erase(id);
+}
+
+Guild *Being::getGuild(const std::string &guildName) const
+{
+ std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
+ for (itr = mGuilds.begin(); itr != itr_end; ++itr)
+ {
+ Guild *guild = itr->second;
+ if (guild->getName() == guildName)
+ {
+ return guild;
+ }
+ }
+
+ return NULL;
+}
+
+Guild *Being::getGuild(int id) const
+{
+ std::map<int, Guild*>::const_iterator itr;
+ itr = mGuilds.find(id);
+ if (itr != mGuilds.end())
+ {
+ return itr->second;
+ }
+
+ return NULL;
+}
+
+void Being::clearGuilds()
+{
+ std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
+ for (itr = mGuilds.begin(); itr != itr_end; ++itr)
+ {
+ Guild *guild = itr->second;
+
+ if (this == player_node && socialWindow)
+ socialWindow->removeTab(guild);
+
+ guild->removeMember(mId);
+ }
+
+ mGuilds.clear();
+}
+
+void Being::setParty(Party *party)
+{
+ if (party == mParty)
+ return;
+
+ Party *old = mParty;
+ mParty = party;
+
+ if (old)
+ {
+ old->removeMember(mId);
+ }
+
+ if (party)
+ {
+ party->addMember(mId, mName);
+ }
+
+ updateColors();
+
+ if (this == player_node && socialWindow)
+ {
+ if (old)
+ socialWindow->removeTab(old);
+
+ if (party)
+ socialWindow->addTab(party);
+ }
+}
+
void Being::fireMissile(Being *victim, const std::string &particle)
{
if (!victim || particle.empty())
@@ -379,11 +562,37 @@ void Being::setAction(Action action, int attackType)
break;
case ATTACK:
if (mEquippedWeapon)
+ {
currentAction = mEquippedWeapon->getAttackType();
+ reset();
+ }
else
- currentAction = ACTION_ATTACK;
+ {
+ mAttackType = attackType;
+ currentAction = mInfo->getAttack(attackType)->action;
+ reset();
+
+ int rotation = 0;
+ //attack particle effect
+ std::string particleEffect = mInfo->getAttack(attackType)
+ ->particleEffect;
+ if (!particleEffect.empty() && Particle::enabled)
+ {
+ switch (mSpriteDirection)
+ {
+ case DIRECTION_DOWN: rotation = 0; break;
+ case DIRECTION_LEFT: rotation = 90; break;
+ case DIRECTION_UP: rotation = 180; break;
+ case DIRECTION_RIGHT: rotation = 270; break;
+ default: break;
+ }
+ Particle *p;
+ p = particleEngine->addEffect(particleEffect, 0, 0,
+ rotation);
+ controlParticle(p);
+ }
+ }
- reset();
break;
case HURT:
//currentAction = ACTION_HURT; // Buggy: makes the player stop
@@ -392,6 +601,7 @@ void Being::setAction(Action action, int attackType)
break;
case DEAD:
currentAction = ACTION_DEAD;
+ sound.playSfx(mInfo->getSound(SOUND_EVENT_DIE));
break;
case STAND:
currentAction = ACTION_STAND;
@@ -564,6 +774,70 @@ void Being::logic()
}
else if (Net::getNetworkType() == ServerInfo::TMWATHENA)
{
+ if (getType() == MONSTER && (mAction != STAND))
+ {
+ mFrame = (int) ((get_elapsed_time(mWalkTime) * 4) / getWalkSpeed().x);
+
+ if (mFrame >= 4 && mAction != DEAD)
+ nextTile();
+ }
+ else if (getType() == PLAYER)
+ {
+ switch (mAction)
+ {
+ case STAND:
+ case SIT:
+ case DEAD:
+ case HURT:
+ break;
+
+ case WALK:
+ mFrame = (int) ((get_elapsed_time(mWalkTime) * 6)
+ / getWalkSpeed().x);
+ if (mFrame >= 6)
+ nextTile();
+ break;
+
+ case ATTACK:
+ int rotation = 0;
+ std::string particleEffect = "";
+ int frames = 4;
+
+ if (mEquippedWeapon &&
+ mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
+ {
+ frames = 5;
+ }
+
+ mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;
+
+ //attack particle effect
+ if (mEquippedWeapon)
+ particleEffect = mEquippedWeapon->getParticleEffect();
+
+ if (!particleEffect.empty() && Particle::enabled && mFrame == 1)
+ {
+ switch (mDirection)
+ {
+ case DOWN: rotation = 0; break;
+ case LEFT: rotation = 90; break;
+ case UP: rotation = 180; break;
+ case RIGHT: rotation = 270; break;
+ default: break;
+ }
+ Particle *p;
+ p = particleEngine->addEffect("graphics/particles/" +
+ particleEffect, 0, 0, rotation);
+ controlParticle(p);
+ }
+
+ if (mFrame >= frames)
+ nextTile();
+
+ break;
+ }
+ }
+
// Update pixel coordinates
setPosition(mX * 32 + 16 + getXOffset(),
mY * 32 + 32 + getYOffset());
@@ -688,9 +962,22 @@ int Being::getHeight() const
void Being::updateCoords()
{
- if (mDispName)
- {
+ if (!mDispName)
+ return;
+
+ // Monster names show above the sprite instead of below it
+ if (getType() == MONSTER)
+ mDispName->adviseXY(getPixelX(),
+ getPixelY() - getHeight() - mDispName->getHeight());
+ else
mDispName->adviseXY(getPixelX(), getPixelY());
+}
+
+void Being::optionChanged(const std::string &value)
+{
+ if (getType() == PLAYER && value == "visiblenames")
+ {
+ setShowName(config.getValue("visiblenames", 1));
}
}
@@ -706,21 +993,15 @@ void Being::showName()
mDispName = 0;
std::string mDisplayName(mName);
- if (getType() == PLAYER)
+ if (config.getValue("showgender", false))
{
- if (config.getValue("showgender", false))
- {
- Player* player = static_cast<Player*>(this);
- if (player)
- {
- if (player->getGender() == GENDER_FEMALE)
- mDisplayName += " \u2640";
- else
- mDisplayName += " \u2642";
- }
- }
+ if (getGender() == GENDER_FEMALE)
+ mDisplayName += " \u2640";
+ else if (getGender() == GENDER_MALE)
+ mDisplayName += " \u2642";
}
- else if (getType() == MONSTER)
+
+ if (getType() == MONSTER)
{
if (config.getValue("showMonstersTakedDamage", false))
{
@@ -730,6 +1011,115 @@ void Being::showName()
mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
gcn::Graphics::CENTER, mNameColor);
+
+ updateCoords();
+}
+
+void Being::updateColors()
+{
+ if (getType() == MONSTER)
+ {
+ mNameColor = &userPalette->getColor(UserPalette::MONSTER);
+ mTextColor = &userPalette->getColor(UserPalette::MONSTER);
+ }
+ else if (getType() == NPC)
+ {
+ mNameColor = &userPalette->getColor(UserPalette::NPC);
+ mTextColor = &userPalette->getColor(UserPalette::NPC);
+ }
+ else if (this == player_node)
+ {
+ mNameColor = &userPalette->getColor(UserPalette::SELF);
+ mTextColor = &Theme::getThemeColor(Theme::PLAYER);
+ }
+ else
+ {
+ mTextColor = &userPalette->getColor(Theme::PLAYER);
+
+ if (mIsGM)
+ {
+ mTextColor = &userPalette->getColor(UserPalette::GM);
+ mNameColor = &userPalette->getColor(UserPalette::GM);
+ }
+ else if (mParty && mParty == player_node->getParty())
+ {
+ mNameColor = &userPalette->getColor(UserPalette::PARTY);
+ }
+ else
+ {
+ mNameColor = &userPalette->getColor(UserPalette::PC);
+ }
+ }
+
+ if (mDispName)
+ {
+ mDispName->setColor(mNameColor);
+ }
+}
+
+void Being::setSprite(unsigned int slot, int id, const std::string &color,
+ bool isWeapon)
+{
+ assert(slot < Net::getCharHandler()->maxSprite());
+
+ if (slot >= size())
+ resize(slot + 1, NULL);
+
+ if (slot >= mSpriteIDs.size())
+ mSpriteIDs.resize(slot + 1, 0);
+
+ if (slot >= mSpriteColors.size())
+ mSpriteColors.resize(slot + 1, "");
+
+ // id = 0 means unequip
+ if (id == 0)
+ {
+ delete at(slot);
+ at(slot) = NULL;
+
+ if (isWeapon)
+ mEquippedWeapon = NULL;
+ }
+ else
+ {
+ std::string filename = ItemDB::get(id).getSprite(mGender);
+ AnimatedSprite *equipmentSprite = NULL;
+
+ if (!filename.empty())
+ {
+ if (!color.empty())
+ filename += "|" + color;
+
+ equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
+ filename);
+ }
+
+ if (equipmentSprite)
+ equipmentSprite->setDirection(getSpriteDirection());
+
+ if (at(slot))
+ delete at(slot);
+
+ at(slot) = equipmentSprite;
+
+ if (isWeapon)
+ mEquippedWeapon = &ItemDB::get(id);
+
+ setAction(mAction);
+ }
+
+ mSpriteIDs[slot] = id;
+ mSpriteColors[slot] = color;
+}
+
+void Being::setSpriteID(unsigned int slot, int id)
+{
+ setSprite(slot, id, mSpriteColors[slot]);
+}
+
+void Being::setSpriteColor(unsigned int slot, const std::string &color)
+{
+ setSprite(slot, mSpriteIDs[slot], color);
}
int Being::getNumberOfLayers() const
@@ -754,3 +1144,44 @@ void Being::updateName()
if (mShowName)
showName();
}
+
+void Being::setGender(Gender gender)
+{
+ if (gender != mGender)
+ {
+ mGender = gender;
+
+ // Reload all subsprites
+ for (unsigned int i = 0; i < mSpriteIDs.size(); i++)
+ {
+ if (mSpriteIDs.at(i) != 0)
+ setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
+ }
+
+ updateName();
+ }
+}
+
+void Being::setGM(bool gm)
+{
+ mIsGM = gm;
+
+ updateColors();
+}
+
+bool Being::canTalk()
+{
+ return mType == NPC;
+}
+
+void Being::talkTo()
+{
+ Net::getNpcHandler()->talk(mId);
+}
+
+bool Being::isTalking()
+{
+ return NpcDialog::isActive() || BuyDialog::isActive() ||
+ SellDialog::isActive() || BuySellDialog::isActive() ||
+ NpcPostDialog::isActive();
+}
diff --git a/src/being.h b/src/being.h
index 95f8c802..76b50dec 100644
--- a/src/being.h
+++ b/src/being.h
@@ -29,12 +29,11 @@
#include "position.h"
#include "vector.h"
-#include "resources/spritedef.h"
-
#include <guichan/color.hpp>
#include <SDL_types.h>
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -45,14 +44,24 @@
#define SPEECH_TIME 500
#define SPEECH_MAX_TIME 1000
+class BeingInfo;
class FlashText;
+class Guild;
class ItemInfo;
class Item;
class Particle;
+class Party;
class Position;
class SpeechBubble;
class Text;
+enum Gender
+{
+ GENDER_MALE = 0,
+ GENDER_FEMALE = 1,
+ GENDER_UNSPECIFIED = 2
+};
+
class Being : public ActorSprite, public ConfigListener
{
public:
@@ -100,10 +109,12 @@ class Being : public ActorSprite, public ConfigListener
* @param subtype partly determines the type of the being
* @param map the map the being is on
*/
- Being(int id, int subtype, Map *map);
+ Being(int id, Type type, int subtype, Map *map);
virtual ~Being();
+ Type getType() const { return mType; }
+
/**
* Removes all path nodes from this being.
*/
@@ -188,7 +199,7 @@ class Being : public ActorSprite, public ConfigListener
* @param damage the amount of damage recieved (0 means miss)
* @param type the attack type
*/
- virtual void takeDamage(Being *attacker, int damage, AttackType type);
+ void takeDamage(Being *attacker, int damage, AttackType type);
/**
* Handles an attack of another being by this being.
@@ -210,23 +221,82 @@ class Being : public ActorSprite, public ConfigListener
*
* @param name The name that should appear.
*/
- virtual void setName(const std::string &name);
+ void setName(const std::string &name);
bool getShowName() const
{ return mShowName; }
- virtual void setShowName(bool doShowName);
+ void setShowName(bool doShowName);
/**
- * Following are set from the server (mainly for players)
+ * Sets the name of the party the being is in. Shown in BeingPopup.
*/
void setPartyName(const std::string &name) { mPartyName = name; }
const std::string &getPartyName() const { return mPartyName; }
- virtual void setGuildName(const std::string &name);
+ /**
+ * Sets the name of the primary guild the being is in. Shown in
+ * BeingPopup (eventually).
+ */
+ void setGuildName(const std::string &name);
+
+ void setGuildPos(const std::string &pos);
+
+ /**
+ * Adds a guild to the being.
+ */
+ void addGuild(Guild *guild);
+
+ /**
+ * Removers a guild from the being.
+ */
+ void removeGuild(int id);
+
+ /**
+ * Returns a pointer to the specified guild that the being is in.
+ */
+ Guild *getGuild(const std::string &guildName) const;
+
+ /**
+ * Returns a pointer to the specified guild that the being is in.
+ */
+ Guild *getGuild(int id) const;
+
+ /**
+ * Returns all guilds the being is in.
+ */
+ const std::map<int, Guild*> &getGuilds() const
+ { return mGuilds; }
+
+ /**
+ * Removes all guilds the being is in.
+ */
+ void clearGuilds();
+
+ /**
+ * Get number of guilds the being belongs to.
+ */
+ short getNumberOfGuilds() const
+ { return mGuilds.size(); }
+
+ bool isInParty() const
+ { return mParty != NULL; }
+
+ void setParty(Party *party);
+
+ Party *getParty() const
+ { return mParty; }
+
+ /**
+ * Sets visible equipments for this being.
+ */
+ void setSprite(unsigned int slot, int id,
+ const std::string &color = "", bool isWeapon = false);
+
+ void setSpriteID(unsigned int slot, int id);
- virtual void setGuildPos(const std::string &pos);
+ void setSpriteColor(unsigned int slot, const std::string &color = "");
/**
* Get the number of hairstyles implemented
@@ -254,15 +324,27 @@ class Being : public ActorSprite, public ConfigListener
*/
void drawEmotion(Graphics *graphics, int offsetX, int offsetY);
- /**
- * Return Being's current Job (player job, npc, monster, creature )
- */
Uint16 getSubType() const { return mSubType; }
/**
- * Set Being's current Job (player job, npc, monster, creature )
+ * Set Being's subtype (mostly for view for monsters and NPCs)
*/
- virtual void setSubtype(Uint16 subtype) { mSubType = subtype; }
+ void setSubtype(Uint16 subtype);
+
+ const BeingInfo *getInfo() const
+ { return mInfo; }
+
+ TargetCursorSize getTargetCursorSize() const;
+
+ /**
+ * Gets the way the object is blocked by other objects.
+ */
+ unsigned char getWalkMask() const;
+
+ /**
+ * Gets the way the monster blocks pathfinding for other objects
+ */
+ Map::BlockType getBlockType() const;
/**
* Sets the walk speed.
@@ -364,12 +446,6 @@ class Being : public ActorSprite, public ConfigListener
void fireMissile(Being *target, const std::string &particle);
/**
- * Gets the way the object is blocked by other objects.
- */
- virtual unsigned char getWalkMask() const
- { return 0x00; } //can walk through everything
-
- /**
* Returns the path this being is following. An empty path is returned
* when this being isn't following any path currently.
*/
@@ -394,7 +470,7 @@ class Being : public ActorSprite, public ConfigListener
static void load();
- virtual void optionChanged(const std::string &value) {}
+ virtual void optionChanged(const std::string &value);
void flashName(int time);
@@ -403,6 +479,31 @@ class Being : public ActorSprite, public ConfigListener
void updateName();
+ /**
+ * Sets the gender of this being.
+ */
+ virtual void setGender(Gender gender);
+
+ Gender getGender() const
+ { return mGender; }
+
+ /**
+ * Whether or not this player is a GM.
+ */
+ bool isGM() const
+ { return mIsGM; }
+
+ /**
+ * Triggers whether or not to show the name as a GM name.
+ */
+ void setGM(bool gm);
+
+ bool canTalk();
+
+ void talkTo();
+
+ static bool isTalking();
+
protected:
/**
* Sets the new path for this being.
@@ -412,9 +513,13 @@ class Being : public ActorSprite, public ConfigListener
/**
* Updates name's location.
*/
- virtual void updateCoords();
+ void updateCoords();
+
+ void showName();
- virtual void showName();
+ void updateColors();
+
+ BeingInfo *mInfo;
/** The current sprite Frame number to be displayed */
int mFrame;
@@ -429,7 +534,9 @@ class Being : public ActorSprite, public ConfigListener
/** Time until the last speech sentence disappears */
int mSpeechTime;
+ int mAttackType;
int mAttackSpeed; /**< Attack speed */
+
Action mAction; /**< Action the being is performing */
Uint16 mSubType; /**< Subtype (graphical view, basically) */
@@ -457,6 +564,16 @@ class Being : public ActorSprite, public ConfigListener
Vector mDest; /**< destination coordinates. */
+ std::vector<int> mSpriteIDs;
+ std::vector<std::string> mSpriteColors;
+ Gender mGender;
+
+ // Character guild information
+ std::map<int, Guild*> mGuilds;
+ Party *mParty;
+
+ bool mIsGM;
+
private:
/**
@@ -466,6 +583,8 @@ class Being : public ActorSprite, public ConfigListener
*/
int getOffset(char pos, char neg) const;
+ const Type mType;
+
/** Speech Bubble components */
SpeechBubble *mSpeechBubble;
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 26672de0..631aadab 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -22,9 +22,6 @@
#include "beingmanager.h"
#include "localplayer.h"
-#include "monster.h"
-#include "npc.h"
-#include "player.h"
#include "gui/viewport.h"
@@ -41,12 +38,12 @@ class FindBeingFunctor
public:
bool operator() (Being *being)
{
- Uint16 other_y = y + ((being->getType() == Being::NPC) ? 1 : 0);
+ 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 == Being::UNKNOWN || being->getType() == type));
+ (type == ActorSprite::UNKNOWN || being->getType() == type));
}
Uint16 x, y;
@@ -75,27 +72,9 @@ void BeingManager::setPlayer(LocalPlayer *player)
mBeings.push_back(player);
}
-Being *BeingManager::createBeing(int id, Being::Type type, int subtype)
+Being *BeingManager::createBeing(int id, ActorSprite::Type type, int subtype)
{
- Being *being;
-
- switch (type)
- {
- case Being::PLAYER:
- being = new Player(id, subtype, mMap);
- break;
- case Being::NPC:
- being = new NPC(id, subtype, mMap);
- break;
- case Being::MONSTER:
- being = new Monster(id, subtype, mMap);
- break;
- case Being::UNKNOWN:
- being = new Being(id, subtype, mMap);
- break;
- default:
- assert(false);
- }
+ Being *being = new Being(id, type, subtype, mMap);
mBeings.push_back(being);
return being;
@@ -120,7 +99,7 @@ Being *BeingManager::findBeing(int id) const
return NULL;
}
-Being *BeingManager::findBeing(int x, int y, Being::Type type) const
+Being *BeingManager::findBeing(int x, int y, ActorSprite::Type type) const
{
beingFinder.x = x;
beingFinder.y = y;
@@ -159,14 +138,14 @@ Being *BeingManager::findBeingByPixel(int x, int y) const
}
Being *BeingManager::findBeingByName(const std::string &name,
- Being::Type type) const
+ 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 == Being::UNKNOWN || type == being->getType()))
+ (type == ActorSprite::UNKNOWN || type == being->getType()))
return being;
}
return NULL;
@@ -214,7 +193,7 @@ void BeingManager::clear()
Being *BeingManager::findNearestLivingBeing(int x, int y,
int maxTileDist,
- Being::Type type) const
+ ActorSprite::Type type) const
{
Being *closestBeing = 0;
int dist = 0;
@@ -230,7 +209,7 @@ Being *BeingManager::findNearestLivingBeing(int x, int y,
const Vector &pos = being->getPosition();
int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
- if ((being->getType() == type || type == Being::UNKNOWN)
+ if ((being->getType() == type || type == ActorSprite::UNKNOWN)
&& (d < dist || !closestBeing) // it is closer
&& being->isAlive()) // no dead beings
{
@@ -243,7 +222,7 @@ Being *BeingManager::findNearestLivingBeing(int x, int y,
}
Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist,
- Being::Type type) const
+ ActorSprite::Type type) const
{
const Vector &pos = aroundBeing->getPosition();
return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type);
@@ -270,8 +249,8 @@ void BeingManager::getPlayerNames(std::vector<std::string> &names,
while (i != mBeings.end())
{
Being *being = (*i);
- if ((being->getType() == Being::PLAYER
- || (being->getType() == Being::NPC && npcNames))
+ if ((being->getType() == ActorSprite::PLAYER
+ || (being->getType() == ActorSprite::NPC && npcNames))
&& being->getName() != "")
{
names.push_back(being->getName());
@@ -287,7 +266,7 @@ void BeingManager::updatePlayerNames()
while (i != mBeings.end())
{
Being *being = (*i);
- if (being->getType() == Being::PLAYER && being->getName() != "")
+ if (being->getType() == ActorSprite::PLAYER && being->getName() != "")
being->updateName();
++i;
}
diff --git a/src/beingmanager.h b/src/beingmanager.h
index d81db668..1d9cc459 100644
--- a/src/beingmanager.h
+++ b/src/beingmanager.h
@@ -49,7 +49,7 @@ class BeingManager
/**
* Create a being and add it to the list of beings.
*/
- Being *createBeing(int id, Being::Type type, int subtype);
+ Being *createBeing(int id, ActorSprite::Type type, int subtype);
/**
* Remove a Being.
@@ -64,7 +64,8 @@ class BeingManager
/**
* Returns a being at specific coordinates.
*/
- Being *findBeing(int x, int y, Being::Type type = Being::UNKNOWN) const;
+ Being *findBeing(int x, int y,
+ ActorSprite::Type type = ActorSprite::UNKNOWN) const;
Being *findBeingByPixel(int x, int y) const;
/**
@@ -77,7 +78,7 @@ class BeingManager
* @param type The type of being to look for.
*/
Being *findNearestLivingBeing(int x, int y, int maxTileDist,
- Being::Type type = Being::UNKNOWN) const;
+ ActorSprite::Type type = Being::UNKNOWN) const;
/**
* Returns a being nearest to another being.
@@ -88,13 +89,13 @@ class BeingManager
* @param type The type of being to look for.
*/
Being *findNearestLivingBeing(Being *aroundBeing, int maxTileDist,
- Being::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,
- Being::Type type = Being::UNKNOWN) const;
+ ActorSprite::Type type = Being::UNKNOWN) const;
/**
* Returns the whole list of beings.
diff --git a/src/game.cpp b/src/game.cpp
index b75d3cdf..c7c1d213 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -37,7 +37,6 @@
#include "localplayer.h"
#include "log.h"
#include "map.h"
-#include "npc.h"
#include "particle.h"
#include "playerrelations.h"
#include "sound.h"
@@ -207,7 +206,7 @@ static void destroyGuiWindows()
Game *Game::mInstance = 0;
Game::Game():
- mLastTarget(Being::UNKNOWN),
+ mLastTarget(ActorSprite::UNKNOWN),
mCurrentMap(0), mMapName("")
{
assert(!mInstance);
@@ -756,7 +755,7 @@ void Game::handleInput()
return;
// Moving player around
- if (player_node->isAlive() && !NPC::isTalking() &&
+ if (player_node->isAlive() && !Being::isTalking() &&
!chatWindow->isInputFocused() && !quitDialog)
{
// Get the state of the keyboard keys
@@ -835,7 +834,7 @@ void Game::handleInput()
{
// Only auto target Monsters
target = beingManager->findNearestLivingBeing(player_node,
- 20, Being::MONSTER);
+ 20, ActorSprite::MONSTER);
}
player_node->attack(target, newTarget);
}
@@ -847,14 +846,14 @@ void Game::handleInput()
(joystick && joystick->buttonPressed(3))) &&
!keyboard.isKeyActive(keyboard.KEY_TARGET))
{
- Being::Type currentTarget = Being::UNKNOWN;
+ ActorSprite::Type currentTarget = ActorSprite::UNKNOWN;
if (keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) ||
(joystick && joystick->buttonPressed(3)))
- currentTarget = Being::MONSTER;
+ currentTarget = ActorSprite::MONSTER;
else if (keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER))
- currentTarget = Being::PLAYER;
+ currentTarget = ActorSprite::PLAYER;
else if (keyboard.isKeyActive(keyboard.KEY_TARGET_NPC))
- currentTarget = Being::NPC;
+ currentTarget = ActorSprite::NPC;
Being *target = beingManager->findNearestLivingBeing(player_node,
20, currentTarget);
@@ -868,7 +867,7 @@ void Game::handleInput()
}
else
{
- mLastTarget = Being::UNKNOWN; // Reset last target
+ mLastTarget = ActorSprite::UNKNOWN; // Reset last target
}
// Talk to the nearest NPC if 't' pressed
@@ -879,8 +878,8 @@ void Game::handleInput()
if (target)
{
- if (target->getType() == Being::NPC)
- static_cast<NPC*>(target)->talk();
+ if (target->canTalk())
+ target->talkTo();
}
}
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 687b20c2..ee9fd66d 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -20,8 +20,8 @@
#include "gui/beingpopup.h"
+#include "being.h"
#include "graphics.h"
-#include "player.h"
#include "units.h"
#include "gui/gui.h"
@@ -57,21 +57,21 @@ BeingPopup::~BeingPopup()
{
}
-void BeingPopup::show(int x, int y, Player *p)
+void BeingPopup::show(int x, int y, Being *b)
{
- if (!p)
+ if (!b)
{
setVisible(false);
return;
}
- if (!(p->getPartyName().empty()))
+ if (!(b->getPartyName().empty()))
{
- mBeingName->setCaption(p->getName());
+ mBeingName->setCaption(b->getName());
mBeingName->adjustSize();
mBeingParty->setCaption(strprintf(_("Party: %s"),
- p->getPartyName().c_str()));
+ b->getPartyName().c_str()));
mBeingParty->adjustSize();
int minWidth = std::max(mBeingName->getWidth(),
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h
index f397e374..514a6e7e 100644
--- a/src/gui/beingpopup.h
+++ b/src/gui/beingpopup.h
@@ -23,8 +23,8 @@
#include "gui/widgets/popup.h"
+class Being;
class Label;
-class Player;
/**
* A popup that displays information about a being.
@@ -45,7 +45,7 @@ class BeingPopup : public Popup
/**
* Sets the info to be displayed given a particular player.
*/
- void show(int x, int y, Player *p);
+ void show(int x, int y, Being *b);
// TODO: Add a version for monsters, NPCs, etc?
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 031c53dd..a214c075 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -21,6 +21,9 @@
#include "gui/buy.h"
+#include "shopitem.h"
+#include "units.h"
+
#include "gui/setup.h"
#include "gui/widgets/button.h"
@@ -31,10 +34,6 @@
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
-#include "npc.h"
-#include "shopitem.h"
-#include "units.h"
-
#include "net/net.h"
#include "net/npchandler.h"
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index c6b4ef41..3e810a4a 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -21,8 +21,6 @@
#include "buysell.h"
-#include "npc.h"
-
#include "gui/setup.h"
#include "gui/widgets/button.h"
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index e4a5fd01..a2cb2efb 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -54,7 +54,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mCharSelectDialog(parent),
mSlot(slot)
{
- mPlayer = new Player(0, 0, NULL);
+ mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL);
mPlayer->setGender(GENDER_MALE);
int numberOfHairColors = ColorDB::size();
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 902e650e..018de3f5 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -22,7 +22,7 @@
#ifndef CHAR_CREATE_DIALOG_H
#define CHAR_CREATE_DIALOG_H
-#include "player.h"
+#include "being.h"
#include "guichanfwd.h"
#include "gui/charselectdialog.h"
@@ -110,7 +110,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::Button *mCreateButton;
gcn::Button *mCancelButton;
- Player *mPlayer;
+ Being *mPlayer;
PlayerBox *mPlayerBox;
int mHairStyle;
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index b6e71715..6d565135 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -22,9 +22,9 @@
#ifndef CHAR_SELECT_H
#define CHAR_SELECT_H
+#include "being.h"
#include "guichanfwd.h"
#include "main.h"
-#include "player.h"
#include "gui/widgets/window.h"
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index d53bcf0a..83aaed26 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -273,7 +273,7 @@ void ChatWindow::doPresent()
for (Beings::const_iterator bi = beings.begin(), be = beings.end();
bi != be; ++bi)
{
- if ((*bi)->getType() == Being::PLAYER)
+ if ((*bi)->getType() == ActorSprite::PLAYER)
{
if (!response.empty())
{
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 53d58d2e..b4445d94 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -28,7 +28,6 @@
#include "localplayer.h"
#include "log.h"
#include "map.h"
-#include "player.h"
#include "gui/setup.h"
#include "gui/userpalette.h"
@@ -195,44 +194,35 @@ void Minimap::draw(gcn::Graphics *graphics)
const Being *being = (*bi);
int dotSize = 2;
- switch (being->getType())
+ int type = UserPalette::PC;
+
+ if (being == player_node)
+ {
+ type = UserPalette::SELF;
+ dotSize = 3;
+ }
+ else if (being->isGM())
+ type = UserPalette::GM;
+ else if (being->isInParty())
+ type = UserPalette::PARTY;
+ else
{
- case Being::PLAYER:
- {
- const Player *player = static_cast<const Player*>(being);
-
- int type = UserPalette::PC;
-
- if (being == player_node)
- {
- type = UserPalette::SELF;
- dotSize = 3;
- }
- else if (player->isGM())
- {
- type = UserPalette::GM;
- }
- else if (player->isInParty())
- {
- type = UserPalette::PARTY;
- }
-
- graphics->setColor(userPalette->getColor(type));
+ switch (being->getType())
+ {
+ case ActorSprite::MONSTER:
+ graphics->setColor(userPalette->getColor(UserPalette::MONSTER));
break;
- }
- case Being::MONSTER:
- graphics->setColor(userPalette->getColor(UserPalette::MONSTER));
- break;
-
- case Being::NPC:
- graphics->setColor(userPalette->getColor(UserPalette::NPC));
- break;
+ case ActorSprite::NPC:
+ graphics->setColor(userPalette->getColor(UserPalette::NPC));
+ break;
- default:
- continue;
+ default:
+ continue;
+ }
}
+ graphics->setColor(userPalette->getColor(type));
const int offsetHeight = (int) ((dotSize - 1) * mHeightProportion);
const int offsetWidth = (int) ((dotSize - 1) * mWidthProportion);
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 6d3995a7..4e9c0b01 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -22,7 +22,6 @@
#include "gui/npcdialog.h"
#include "configuration.h"
-#include "npc.h"
#include "gui/setup.h"
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index a8521ce9..26ff9c1a 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -23,7 +23,6 @@
#define NPCDIALOG_H
#include "configlistener.h"
-#include "npc.h"
#include "gui/widgets/window.h"
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 19d0cf61..68a91f36 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -21,8 +21,6 @@
#include "gui/npcpostdialog.h"
-#include "npc.h"
-
#include "gui/widgets/button.h"
#include "gui/widgets/chattab.h"
#include "gui/widgets/label.h"
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 77e919a9..0dae4f4b 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -28,7 +28,6 @@
#include "item.h"
#include "localplayer.h"
#include "log.h"
-#include "npc.h"
#include "playerrelations.h"
#include "gui/chat.h"
@@ -76,7 +75,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
switch (being->getType())
{
- case Being::PLAYER:
+ case ActorSprite::PLAYER:
{
// Players can be traded with.
mBrowserBox->addRow(strprintf("@@trade|%s@@",
@@ -145,7 +144,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
break;
- case Being::NPC:
+ case ActorSprite::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
mBrowserBox->addRow(strprintf("@@talk|%s@@",
@@ -153,7 +152,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
name.c_str()).c_str()));
break;
- case Being::MONSTER:
+ case ActorSprite::MONSTER:
{
// Monsters can be attacked
mBrowserBox->addRow(strprintf("@@attack|%s@@",
@@ -203,13 +202,14 @@ void PopupMenu::handleLink(const std::string &link)
Being *being = beingManager->findBeing(mBeingId);
// Talk To action
- if (link == "talk" && being && being->getType() == Being::NPC)
+ if (link == "talk" && being && being->canTalk())
{
- static_cast<NPC*>(being)->talk();
+ being->talkTo();
}
// Trade action
- else if (link == "trade" && being && being->getType() == Being::PLAYER)
+ else if (link == "trade" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
Net::getTradeHandler()->request(being);
tradePartnerName = being->getName();
@@ -223,27 +223,32 @@ void PopupMenu::handleLink(const std::string &link)
{
chatWindow->addInputText("/w \"" + being->getName() + "\" ");
}
- else if (link == "unignore" && being && being->getType() == Being::PLAYER)
+ else if (link == "unignore" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
}
- else if (link == "ignore" && being && being->getType() == Being::PLAYER)
+ else if (link == "ignore" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
}
- else if (link == "disregard" && being && being->getType() == Being::PLAYER)
+ else if (link == "disregard" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
}
- else if (link == "friend" && being && being->getType() == Being::PLAYER)
+ else if (link == "friend" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
}
// Guild action
- else if (link == "guild" && being && being->getType() == Being::PLAYER)
+ else if (link == "guild" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_node->inviteToGuild(being);
}
@@ -313,9 +318,10 @@ void PopupMenu::handleLink(const std::string &link)
mItem);
}
- else if (link == "party" && being && being->getType() == Being::PLAYER)
+ else if (link == "party" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
- Net::getPartyHandler()->invite(static_cast<Player*>(being));
+ Net::getPartyHandler()->invite(being);
}
else if (link == "name" && being)
@@ -326,8 +332,8 @@ void PopupMenu::handleLink(const std::string &link)
else if (link == "admin-kick" &&
being &&
- (being->getType() == Being::PLAYER ||
- being->getType() == Being::MONSTER))
+ (being->getType() == ActorSprite::PLAYER ||
+ being->getType() == ActorSprite::MONSTER))
{
Net::getAdminHandler()->kick(being->getId());
}
diff --git a/src/gui/register.h b/src/gui/register.h
index 645b0be8..3c65695b 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -22,8 +22,6 @@
#ifndef REGISTER_H
#define REGISTER_H
-#include "player.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 69ff7ed2..a4109033 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -21,7 +21,6 @@
#include "gui/sell.h"
-#include "npc.h"
#include "shopitem.h"
#include "units.h"
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 10ed680e..8d833123 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -20,11 +20,9 @@
#include "gui/socialwindow.h"
-#include "beingmanager.h"
#include "guild.h"
#include "localplayer.h"
#include "party.h"
-#include "player.h"
#include "gui/confirmdialog.h"
#include "gui/okdialog.h"
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 99325db8..1c793cdd 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -29,8 +29,6 @@
#include "keyboardconfig.h"
#include "localplayer.h"
#include "map.h"
-#include "monster.h"
-#include "npc.h"
#include "textmanager.h"
#include "gui/gui.h"
@@ -40,7 +38,6 @@
#include "net/net.h"
-#include "resources/monsterinfo.h"
#include "resources/resourcemanager.h"
#include "utils/stringutils.h"
@@ -345,7 +342,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
return;
// Check if we are busy
- if (NPC::isTalking())
+ if (Being::isTalking())
return;
mPlayerFollowMouse = false;
@@ -381,33 +378,20 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
// Interact with some being
if (mHoverBeing)
{
- switch (mHoverBeing->getType())
+ if (mHoverBeing->canTalk())
+ mHoverBeing->talkTo();
+ else
{
- // Talk to NPCs
- case Being::NPC:
- static_cast<NPC*>(mHoverBeing)->talk();
- break;
-
- // Attack or walk to monsters or players
- case Being::MONSTER:
- case Being::PLAYER:
- // Ignore it if its dead
- if (!mHoverBeing->isAlive())
- break;
-
+ // Ignore it if its dead
+ if (mHoverBeing->isAlive())
+ {
if (player_node->withinAttackRange(mHoverBeing) ||
keyboard.isKeyActive(keyboard.KEY_ATTACK))
- {
player_node->attack(mHoverBeing,
!keyboard.isKeyActive(keyboard.KEY_TARGET));
- }
else
- {
player_node->setGotoTarget(mHoverBeing);
- }
- break;
- default:
- break;
+ }
}
// Picks up a item if we clicked on one
}
@@ -434,7 +418,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
{
// Find the being nearest to the clicked position
Being *target = beingManager->findNearestLivingBeing(
- pixelX, pixelY, 20, Being::MONSTER);
+ pixelX, pixelY, 20, ActorSprite::MONSTER);
if (target)
player_node->setTarget(target);
@@ -508,11 +492,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
const int y = (event.getY() + (int) mPixelViewY);
mHoverBeing = beingManager->findBeingByPixel(x, y);
- if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER)
- mBeingPopup->show(getMouseX(), getMouseY(),
- static_cast<Player*>(mHoverBeing));
- else
- mBeingPopup->setVisible(false);
+ mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing);
mHoverItem = floorItemManager->findByCoordinates(x / mMap->getTileWidth(),
y / mMap->getTileHeight());
@@ -522,12 +502,12 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
switch (mHoverBeing->getType())
{
// NPCs
- case Being::NPC:
+ case ActorSprite::NPC:
gui->setCursorType(Gui::CURSOR_TALK);
break;
// Monsters
- case Being::MONSTER:
+ case ActorSprite::MONSTER:
gui->setCursorType(Gui::CURSOR_FIGHT);
break;
default:
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index a953f474..468c77f5 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -22,9 +22,9 @@
#include "gui/widgets/playerbox.h"
#include "animatedsprite.h"
+#include "being.h"
#include "configuration.h"
#include "graphics.h"
-#include "player.h"
#include "gui/theme.h"
@@ -36,8 +36,8 @@ int PlayerBox::instances = 0;
float PlayerBox::mAlpha = 1.0;
ImageRect PlayerBox::background;
-PlayerBox::PlayerBox(const Player *player):
- mPlayer(player)
+PlayerBox::PlayerBox(const Being *being):
+ mBeing(being)
{
setFrameSize(2);
@@ -72,7 +72,7 @@ PlayerBox::~PlayerBox()
{
instances--;
- mPlayer = 0;
+ mBeing = 0;
if (instances == 0)
{
@@ -82,13 +82,13 @@ PlayerBox::~PlayerBox()
void PlayerBox::draw(gcn::Graphics *graphics)
{
- if (mPlayer)
+ if (mBeing)
{
// Draw character
const int bs = getFrameSize();
const int x = getWidth() / 2 + bs - 16;
const int y = getHeight() - bs - 32;
- mPlayer->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
+ mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
if (config.getValue("guialpha", 0.8) != mAlpha)
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 33b4a628..4505367f 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -24,8 +24,8 @@
#include <guichan/widgets/scrollarea.hpp>
+class Being;
class ImageRect;
-class Player;
/**
* A box showing a player character.
@@ -39,7 +39,7 @@ class PlayerBox : public gcn::ScrollArea
* Constructor. Takes the initial player character that this box should
* display, which defaults to <code>NULL</code>.
*/
- PlayerBox(const Player *player = 0);
+ PlayerBox(const Being *being = 0);
/**
* Destructor.
@@ -51,7 +51,7 @@ class PlayerBox : public gcn::ScrollArea
* player to <code>NULL</code> causes the box not to draw any
* character.
*/
- void setPlayer(const Player *player) { mPlayer = player; }
+ void setPlayer(const Being *being) { mBeing = being; }
/**
* Draws the scroll area.
@@ -64,7 +64,7 @@ class PlayerBox : public gcn::ScrollArea
void drawFrame(gcn::Graphics *graphics);
private:
- const Player *mPlayer; /**< The character used for display */
+ const Being *mBeing; /**< The character used for display */
static float mAlpha;
static int instances;
diff --git a/src/guild.cpp b/src/guild.cpp
index 029cde7f..602e2306 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -22,7 +22,6 @@
#include "guild.h"
#include "beingmanager.h"
-#include "player.h"
GuildMember::GuildMember(Guild *guild, int id, const std::string &name):
Avatar(name), mId(id), mGuild(guild)
@@ -151,9 +150,7 @@ void Guild::removeFromMembers()
while(itr != itr_end)
{
Being *b = beingManager->findBeing((*itr)->getID());
-
- if (b->getType() == Being::PLAYER)
- static_cast<Player*>(b)->removeGuild(getId());
+ b->removeGuild(getId());
++itr;
}
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 9796b2ac..17384a1f 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -32,7 +32,6 @@
#include "item.h"
#include "log.h"
#include "map.h"
-#include "monster.h"
#include "particle.h"
#include "simpleanimation.h"
#include "sound.h"
@@ -80,7 +79,7 @@ const short walkingKeyboardDelay = 1000;
LocalPlayer *player_node = NULL;
LocalPlayer::LocalPlayer(int id, int subtype):
- Player(id, subtype, 0),
+ Being(id, PLAYER, subtype, 0),
mEquipment(new Equipment),
mAttackRange(0),
mTargetTime(-1),
@@ -113,9 +112,6 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mUpdateName = true;
- mTextColor = &Theme::getThemeColor(Theme::PLAYER);
- mNameColor = &userPalette->getColor(UserPalette::SELF);
-
config.addListener("showownname", this);
setShowName(config.getValue("showownname", 1));
}
@@ -187,7 +183,7 @@ void LocalPlayer::logic()
if (mTarget)
{
- if (mTarget->getType() == Being::NPC)
+ if (mTarget->getType() == ActorSprite::NPC)
{
// NPCs are always in range
mTarget->setTargetType(TCT_IN_RANGE);
@@ -219,7 +215,7 @@ void LocalPlayer::logic()
}
}
- Player::logic();
+ Being::logic();
}
void LocalPlayer::setAction(Action action, int attackType)
@@ -230,12 +226,7 @@ void LocalPlayer::setAction(Action action, int attackType)
setTarget(NULL);
}
- Player::setAction(action, attackType);
-}
-
-void LocalPlayer::setGM(bool gm)
-{
- mIsGM = gm;
+ Being::setAction(action, attackType);
}
void LocalPlayer::setGMLevel(int level)
@@ -621,7 +612,7 @@ void LocalPlayer::nextTile(unsigned char dir = 0)
}
- Player::nextTile();
+ Being::nextTile();
}
else
{
@@ -660,7 +651,6 @@ void LocalPlayer::inviteToGuild(Being *being)
{
if (being->getType() != PLAYER)
return;
- Player *player = static_cast<Player*>(being);
// TODO: Allow user to choose which guild to invite being to
// For now, just invite to the first guild you have permissions to invite with
@@ -670,7 +660,7 @@ void LocalPlayer::inviteToGuild(Being *being)
{
if (checkInviteRights(itr->second->getName()))
{
- Net::getGuildHandler()->invite(itr->second->getId(), player);
+ Net::getGuildHandler()->invite(itr->second->getId(), being);
return;
}
}
@@ -746,12 +736,12 @@ void LocalPlayer::setTarget(Being *target)
if (mTarget)
mTarget->untarget();
- if (mTarget && mTarget->getType() == Being::MONSTER)
+ if (mTarget && mTarget->getType() == ActorSprite::MONSTER)
mTarget->setShowName(false);
mTarget = target;
- if (target && target->getType() == Being::MONSTER)
+ if (target && target->getType() == ActorSprite::MONSTER)
target->setShowName(true);
}
@@ -952,7 +942,7 @@ void LocalPlayer::attack(Being *target, bool keep)
mKeepAttacking = keep;
- if (!target || target->getType() == Being::NPC)
+ if (!target || target->getType() == ActorSprite::NPC)
return;
if (mTarget != target || !mTarget)
diff --git a/src/localplayer.h b/src/localplayer.h
index 38212a60..a7ed33f8 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -22,7 +22,7 @@
#ifndef LOCALPLAYER_H
#define LOCALPLAYER_H
-#include "player.h"
+#include "being.h"
#include "gui/userpalette.h"
@@ -109,7 +109,7 @@ enum
/**
* The local player character.
*/
-class LocalPlayer : public Player
+class LocalPlayer : public Being
{
public:
/**
@@ -194,11 +194,6 @@ class LocalPlayer : public Player
void attack(Being *target = NULL, bool keep = false);
- /**
- * Triggers whether or not to show the name as a GM name.
- */
- virtual void setGM(bool gm);
-
void setGMLevel(int level);
void stopAttack();
@@ -403,7 +398,7 @@ class LocalPlayer : public Player
std::string getFollow() const { return mPlayerFollowed; }
/**
- * Tells the engine wether to check
+ * Tells the engine whether to check
* if the Player Name is to be displayed.
*/
void setCheckNameSetting(bool checked) { mUpdateName = checked; }
@@ -424,9 +419,6 @@ class LocalPlayer : public Player
virtual void handleStatusEffect(StatusEffect *effect, int effectId);
- // Colors don't change for local player
- virtual void updateColors() {}
-
void startWalking(unsigned char dir);
int mAttackRange;
diff --git a/src/monster.cpp b/src/monster.cpp
deleted file mode 100644
index 922bfa7a..00000000
--- a/src/monster.cpp
+++ /dev/null
@@ -1,171 +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 "monster.h"
-
-#include "animatedsprite.h"
-#include "client.h"
-#include "localplayer.h"
-#include "particle.h"
-#include "sound.h"
-#include "text.h"
-
-#include "gui/userpalette.h"
-
-#include "net/net.h"
-
-#include "resources/monsterdb.h"
-#include "resources/monsterinfo.h"
-
-Monster::Monster(int id, int subtype, Map *map):
- Being(id, subtype, map),
- mAttackType(1)
-{
- setSubtype(subtype);
-
- mNameColor = &userPalette->getColor(UserPalette::MONSTER);
- mTextColor = &userPalette->getColor(UserPalette::MONSTER);
-
- Being::setName(getInfo().getName());
-}
-
-void Monster::logic()
-{
- if ((Net::getNetworkType() == ServerInfo::TMWATHENA) && (mAction != STAND))
- {
- mFrame = (int) ((get_elapsed_time(mWalkTime) * 4) / getWalkSpeed().x);
-
- if (mFrame >= 4 && mAction != DEAD)
- nextTile();
- }
-
- Being::logic();
-}
-
-
-void Monster::setAction(Action action, int attackType)
-{
- SpriteAction currentAction = ACTION_INVALID;
- int rotation = 0;
- std::string particleEffect;
-
- switch (action)
- {
- case WALK:
- currentAction = ACTION_WALK;
- break;
- case DEAD:
- currentAction = ACTION_DEAD;
- sound.playSfx(getInfo().getSound(MONSTER_EVENT_DIE));
- break;
- case ATTACK:
- mAttackType = attackType;
- currentAction = getInfo().getAttackAction(attackType);
- reset();
-
- //attack particle effect
- particleEffect = getInfo().getAttackParticleEffect(attackType);
- if (!particleEffect.empty() && Particle::enabled)
- {
- switch (mSpriteDirection)
- {
- case DIRECTION_DOWN: rotation = 0; break;
- case DIRECTION_LEFT: rotation = 90; break;
- case DIRECTION_UP: rotation = 180; break;
- case DIRECTION_RIGHT: rotation = 270; break;
- default: break;
- }
- Particle *p;
- p = particleEngine->addEffect(particleEffect, 0, 0, rotation);
- controlParticle(p);
- }
- break;
- case STAND:
- currentAction = ACTION_STAND;
- break;
- case HURT:
- // Not implemented yet
- break;
- case SIT:
- // Also not implemented yet
- break;
- }
-
- if (currentAction != ACTION_INVALID)
- {
- play(currentAction);
- mAction = action;
- }
-}
-
-void Monster::setSubtype(Uint16 subtype)
-{
- Being::setSubtype(subtype);
-
- const MonsterInfo &info = getInfo();
-
- setupSpriteDisplay(info.getDisplay());
-}
-
-void Monster::handleAttack(Being *victim, int damage, AttackType type)
-{
- Being::handleAttack(victim, damage, type);
-
- const MonsterInfo &mi = getInfo();
- sound.playSfx(mi.getSound((damage > 0) ?
- MONSTER_EVENT_HIT : MONSTER_EVENT_MISS));
-
- fireMissile(victim, mi.getAttackMissileParticle(mAttackType));
-}
-
-void Monster::takeDamage(Being *attacker, int amount, AttackType type)
-{
- if (amount > 0)
- sound.playSfx(getInfo().getSound(MONSTER_EVENT_HURT));
-
- Being::takeDamage(attacker, amount, type);
-}
-
-Being::TargetCursorSize Monster::getTargetCursorSize() const
-{
- return getInfo().getTargetCursorSize();
-}
-
-const MonsterInfo &Monster::getInfo() const
-{
- return MonsterDB::get(mSubType);
-}
-
-void Monster::updateCoords()
-{
- if (mDispName)
- {
- mDispName->adviseXY(getPixelX(),
- getPixelY() - getHeight() - mDispName->getHeight());
- }
-}
-
-void Monster::showName()
-{
- Being::showName();
-
- updateCoords();
-}
diff --git a/src/monster.h b/src/monster.h
deleted file mode 100644
index 843c3fc8..00000000
--- a/src/monster.h
+++ /dev/null
@@ -1,97 +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 MONSTER_H
-#define MONSTER_H
-
-#include "being.h"
-
-class MonsterInfo;
-class Text;
-
-class Monster : public Being
-{
- public:
- Monster(int id, int subtype, Map *map);
-
- virtual void logic();
-
- virtual void setAction(Action action, int attackType = 0);
-
- virtual Type getType() const { return MONSTER; }
-
- virtual void setSubtype(Uint16 subtype);
-
- virtual TargetCursorSize getTargetCursorSize() const;
-
- /**
- * Handles an attack of another being by this monster. Plays a hit or
- * miss sound when appropriate.
- *
- * @param victim the victim being
- * @param damage the amount of damage dealt (0 means miss)
- * @param type the attack type
- */
- virtual void handleAttack(Being *victim, int damage, AttackType type);
-
- /**
- * Puts a damage bubble above this monster and plays the hurt sound
- *
- * @param attacker the attacking being
- * @param damage the amount of damage recieved (0 means miss)
- * @param type the attack type
- */
- virtual void takeDamage(Being *attacker, int amount, AttackType type);
-
- /**
- * Returns the MonsterInfo, with static data about this monster.
- */
- const MonsterInfo& getInfo() const;
-
- /**
- * Gets the way the monster is blocked by other objects
- */
- virtual unsigned char getWalkMask() const
- {
- return Map::BLOCKMASK_WALL
- | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER;
- }
-
- protected:
- /**
- * Gets the way the monster blocks pathfinding for other objects
- */
- virtual Map::BlockType getBlockType() const
- { return Map::BLOCKTYPE_MONSTER; }
-
- /**
- * Update the text when the monster moves
- */
- void updateCoords();
-
- void showName();
-
- private:
- int mAttackType;
-};
-
-#endif
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index 4a813e21..e3c8cfd6 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -75,11 +75,11 @@ class CharHandler
virtual void switchCharacter() = 0;
- virtual int baseSprite() const = 0;
+ virtual unsigned int baseSprite() const = 0;
- virtual int hairSprite() const = 0;
+ virtual unsigned int hairSprite() const = 0;
- virtual int maxSprite() const = 0;
+ virtual unsigned int maxSprite() const = 0;
virtual ~CharHandler() {}
diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h
index 1696b2d5..e4513cbb 100644
--- a/src/net/guildhandler.h
+++ b/src/net/guildhandler.h
@@ -23,10 +23,11 @@
#define GUILDHANDLER_H
#include "guild.h"
-#include "player.h"
#include <iosfwd>
+class Being;
+
namespace Net {
class GuildHandler
@@ -40,7 +41,7 @@ class GuildHandler
virtual void invite(int guildId, const std::string &name) = 0;
- virtual void invite(int guildId, Player *player) = 0;
+ virtual void invite(int guildId, Being *being) = 0;
virtual void inviteResponse(int guildId, bool response) = 0;
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 9bbeed4f..021a57f3 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -22,7 +22,7 @@
#ifndef LOGINDATA_H
#define LOGINDATA_H
-#include "player.h"
+#include "being.h"
#include "net/serverinfo.h"
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index bab5471b..8d3ed21b 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -27,7 +27,6 @@
#include "game.h"
#include "localplayer.h"
#include "log.h"
-#include "npc.h"
#include "particle.h"
#include "gui/okdialog.h"
@@ -121,7 +120,7 @@ Vector BeingHandler::giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds)
return speedInTicks;
}
-static void handleLooks(Player *being, Net::MessageIn &msg)
+static void handleLooks(Being *being, Net::MessageIn &msg)
{
// Order of sent slots. Has to be in sync with the server code.
static int const nb_slots = 4;
@@ -170,15 +169,14 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
}
else
{
- being = beingManager->createBeing(id, Being::PLAYER, 0);
+ being = beingManager->createBeing(id, ActorSprite::PLAYER, 0);
being->setName(name);
}
- Player *p = static_cast< Player * >(being);
int hs = msg.readInt8(), hc = msg.readInt8();
- p->setSprite(SPRITE_HAIR, hs * -1, ColorDB::get(hc));
- p->setGender(msg.readInt8() == GENDER_MALE ?
- GENDER_MALE : GENDER_FEMALE);
- handleLooks(p, msg);
+ being->setSprite(SPRITE_HAIR, hs * -1, ColorDB::get(hc));
+ being->setGender(msg.readInt8() == GENDER_MALE ?
+ GENDER_MALE : GENDER_FEMALE);
+ handleLooks(being, msg);
} break;
case OBJECT_MONSTER:
@@ -186,7 +184,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
{
int subtype = msg.readInt16();
being = beingManager->createBeing(id, type == OBJECT_MONSTER ?
- Being::MONSTER : Being::NPC, subtype);
+ ActorSprite::MONSTER : ActorSprite::NPC, subtype);
std::string name = msg.readString();
if (name.length() > 0) being->setName(name);
} break;
@@ -330,15 +328,14 @@ void BeingHandler::handleBeingActionChangeMessage(Net::MessageIn &msg)
void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
- if (!being || being->getType() != Being::PLAYER)
+ if (!being || being->getType() != ActorSprite::PLAYER)
return;
- Player *player = static_cast<Player *>(being);
- handleLooks(player, msg);
+ handleLooks(being, msg);
if (msg.getUnreadLength())
{
int style = msg.readInt16();
int color = msg.readInt16();
- player->setSprite(SPRITE_HAIR, style * -1, ColorDB::get(color));
+ being->setSprite(SPRITE_HAIR, style * -1, ColorDB::get(color));
}
}
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index a4ce6aa0..0a578a56 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -24,7 +24,6 @@
#include "beingmanager.h"
#include "item.h"
#include "localplayer.h"
-#include "npc.h"
#include "gui/buy.h"
#include "gui/chat.h"
@@ -50,7 +49,7 @@ BuySellHandler::BuySellHandler()
void BuySellHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
- if (!being || being->getType() != Being::NPC)
+ if (!being || being->getType() != ActorSprite::NPC)
{
return;
}
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index c070ab23..f8a1ac89 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -328,17 +328,17 @@ void CharHandler::switchCharacter()
gameHandler->quit(true);
}
-int CharHandler::baseSprite() const
+unsigned int CharHandler::baseSprite() const
{
return SPRITE_BASE;
}
-int CharHandler::hairSprite() const
+unsigned int CharHandler::hairSprite() const
{
return SPRITE_HAIR;
}
-int CharHandler::maxSprite() const
+unsigned int CharHandler::maxSprite() const
{
return SPRITE_VECTOREND;
}
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index 26a7bf4e..dac4a29e 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -65,11 +65,11 @@ class CharHandler : public MessageHandler, public Net::CharHandler
void switchCharacter();
- int baseSprite() const;
+ unsigned int baseSprite() const;
- int hairSprite() const;
+ unsigned int hairSprite() const;
- int maxSprite() const;
+ unsigned int maxSprite() const;
void clear();
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 253efb01..1fbfdf21 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -275,9 +275,9 @@ void GuildHandler::invite(int guildId, const std::string &name)
chatServerConnection->send(msg);
}
-void GuildHandler::invite(int guildId, Player *player)
+void GuildHandler::invite(int guildId, Being *being)
{
- invite(guildId, player->getName());
+ invite(guildId, being->getName());
}
void GuildHandler::inviteResponse(int guildId, bool response)
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index 9929d135..bde677fb 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -41,7 +41,7 @@ public:
void invite(int guildId, const std::string &name);
- void invite(int guidId, Player *player);
+ void invite(int guidId, Being *being);
void inviteResponse(int guidId, bool response);
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 258c72c0..cb8aef4c 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -22,7 +22,6 @@
#include "net/manaserv/npchandler.h"
#include "beingmanager.h"
-#include "npc.h"
#include "gui/npcdialog.h"
#include "gui/npcpostdialog.h"
@@ -57,7 +56,7 @@ NpcHandler::NpcHandler()
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
- if (!being || being->getType() != Being::NPC)
+ if (!being || being->getType() != ActorSprite::NPC)
{
return;
}
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index ec153fa8..2fd48f57 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -136,9 +136,9 @@ void PartyHandler::join(int partyId)
// TODO
}
-void PartyHandler::invite(Player *player)
+void PartyHandler::invite(Being *being)
{
- invite(player->getName());
+ invite(being->getName());
}
void PartyHandler::invite(const std::string &name)
@@ -167,7 +167,7 @@ void PartyHandler::leave()
chatServerConnection->send(msg);
}
-void PartyHandler::kick(Player *player)
+void PartyHandler::kick(Being *being)
{
// TODO
}
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index 0777b49e..29dc280d 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -43,7 +43,7 @@ public:
void join(int partyId);
- void invite(Player *player);
+ void invite(Being *being);
void invite(const std::string &name);
@@ -51,7 +51,7 @@ public:
void leave();
- void kick(Player *player);
+ void kick(Being *being);
void kick(const std::string &name);
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 3a5d68a2..4514366a 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -28,7 +28,6 @@
#include "localplayer.h"
#include "log.h"
#include "particle.h"
-#include "npc.h"
#include "gui/chat.h"
#include "gui/gui.h"
diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h
index dd1103fc..ba2ed458 100644
--- a/src/net/partyhandler.h
+++ b/src/net/partyhandler.h
@@ -24,7 +24,7 @@
#include <string>
-class Player;
+class Being;
enum PartyShare {
PARTY_SHARE_UNKNOWN = -1,
@@ -42,7 +42,7 @@ class PartyHandler
virtual void join(int partyId) = 0;
- virtual void invite(Player *player) = 0;
+ virtual void invite(Being *player) = 0;
virtual void invite(const std::string &name) = 0;
@@ -50,7 +50,7 @@ class PartyHandler
virtual void leave() = 0;
- virtual void kick(Player *player) = 0;
+ virtual void kick(Being *player) = 0;
virtual void kick(const std::string &name) = 0;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 04690c50..9eaca74c 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -28,7 +28,6 @@
#include "guild.h"
#include "localplayer.h"
#include "log.h"
-#include "npc.h"
#include "party.h"
#include "playerrelations.h"
@@ -74,19 +73,19 @@ BeingHandler::BeingHandler(bool enableSync):
Being *createBeing(int id, short job)
{
- Being::Type type = Being::UNKNOWN;
+ ActorSprite::Type type = ActorSprite::UNKNOWN;
if (job <= 25 || (job >= 4001 && job <= 4049))
- type = Being::PLAYER;
+ type = ActorSprite::PLAYER;
else if (job >= 46 && job <= 1000)
- type = Being::NPC;
+ type = ActorSprite::NPC;
else if (job > 1000 && job <= 2000)
- type = Being::MONSTER;
+ type = ActorSprite::MONSTER;
else if (job == 45)
return NULL; // Skip portals
Being *being = beingManager->createBeing(id, type, job);
- if (type == Being::PLAYER || type == Being::NPC)
+ if (type == ActorSprite::PLAYER || type == ActorSprite::NPC)
{
MessageOut outMsg(0x0094);
outMsg.writeInt32(id);//readLong(2));
@@ -112,7 +111,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
int type, guild;
Uint16 status;
Being *srcBeing, *dstBeing;
- Player *player = 0;
int hairStyle, hairColor, flag;
std::string player_followed;
@@ -145,9 +143,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
}
- if (dstBeing->getType() == Being::PLAYER)
- player = static_cast<Player*>(dstBeing);
-
if (msg.getId() == 0x0078)
{
dstBeing->clearPath();
@@ -178,16 +173,13 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
shoes = msg.readInt16(); // clothes color - "abused" as shoes
gloves = msg.readInt16(); // head dir - "abused" as gloves
guild = msg.readInt32(); // guild
- if (player)
+ if (guild == 0)
{
- if (guild == 0)
- {
- player->clearGuilds();
- }
- else
- {
- player->addGuild(Guild::getGuild(guild));
- }
+ dstBeing->clearGuilds();
+ }
+ else
+ {
+ dstBeing->addGuild(Guild::getGuild(guild));
}
msg.readInt16(); // guild emblem
msg.readInt16(); // manner
@@ -195,19 +187,19 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
msg.readInt8(); // karma
gender = msg.readInt8();
- if (player)
+ if (dstBeing->getType() == ActorSprite::PLAYER)
{
- player->setGender((gender == 0)
- ? GENDER_FEMALE : GENDER_MALE);
+ dstBeing->setGender((gender == 0)
+ ? GENDER_FEMALE : GENDER_MALE);
// Set these after the gender, as the sprites may be gender-specific
- player->setSprite(SPRITE_HAIR, hairStyle * -1, ColorDB::get(hairColor));
- player->setSprite(SPRITE_BOTTOMCLOTHES, headBottom);
- player->setSprite(SPRITE_TOPCLOTHES, headMid);
- player->setSprite(SPRITE_HAT, headTop);
- player->setSprite(SPRITE_SHOE, shoes);
- player->setSprite(SPRITE_GLOVES, gloves);
- player->setSprite(SPRITE_WEAPON, weapon, "", true);
- player->setSprite(SPRITE_SHIELD, shield);
+ dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1, ColorDB::get(hairColor));
+ dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom);
+ dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid);
+ dstBeing->setSprite(SPRITE_HAT, headTop);
+ dstBeing->setSprite(SPRITE_SHOE, shoes);
+ dstBeing->setSprite(SPRITE_GLOVES, gloves);
+ dstBeing->setSprite(SPRITE_WEAPON, weapon, "", true);
+ dstBeing->setSprite(SPRITE_SHIELD, shield);
}
if (msg.getId() == SMSG_BEING_MOVE)
@@ -420,9 +412,6 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
}
- if (dstBeing->getType() == Being::PLAYER)
- player = static_cast<Player*>(dstBeing);
-
int type = msg.readInt8();
int id = 0;
int id2 = 0;
@@ -440,41 +429,41 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
switch (type)
{
case 1: // eAthena LOOK_HAIR
- player->setSpriteID(SPRITE_HAIR, id *-1);
+ dstBeing->setSpriteID(SPRITE_HAIR, id *-1);
break;
case 2: // Weapon ID in id, Shield ID in id2
- player->setSprite(SPRITE_WEAPON, id, "", true);
- player->setSprite(SPRITE_SHIELD, id2);
+ dstBeing->setSprite(SPRITE_WEAPON, id, "", true);
+ dstBeing->setSprite(SPRITE_SHIELD, id2);
break;
case 3: // Change lower headgear for eAthena, pants for us
- player->setSprite(SPRITE_BOTTOMCLOTHES, id);
+ dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id);
break;
case 4: // Change upper headgear for eAthena, hat for us
- player->setSprite(SPRITE_HAT, id);
+ dstBeing->setSprite(SPRITE_HAT, id);
break;
case 5: // Change middle headgear for eathena, armor for us
- player->setSprite(SPRITE_TOPCLOTHES, id);
+ dstBeing->setSprite(SPRITE_TOPCLOTHES, id);
break;
case 6: // eAthena LOOK_HAIR_COLOR
- player->setSpriteColor(SPRITE_HAIR, ColorDB::get(id));
+ dstBeing->setSpriteColor(SPRITE_HAIR, ColorDB::get(id));
break;
case 8: // eAthena LOOK_SHIELD
- player->setSprite(SPRITE_SHIELD, id);
+ dstBeing->setSprite(SPRITE_SHIELD, id);
break;
case 9: // eAthena LOOK_SHOES
- player->setSprite(SPRITE_SHOE, id);
+ dstBeing->setSprite(SPRITE_SHOE, id);
break;
case 10: // LOOK_GLOVES
- player->setSprite(SPRITE_GLOVES, id);
+ dstBeing->setSprite(SPRITE_GLOVES, id);
break;
case 11: // LOOK_CAPE
- player->setSprite(SPRITE_CAPE, id);
+ dstBeing->setSprite(SPRITE_CAPE, id);
break;
case 12:
- player->setSprite(SPRITE_MISC1, id);
+ dstBeing->setSprite(SPRITE_MISC1, id);
break;
case 13:
- player->setSprite(SPRITE_MISC2, id);
+ dstBeing->setSprite(SPRITE_MISC2, id);
break;
default:
logger->log("SMSG_BEING_CHANGE_LOOKS: unsupported type: "
@@ -533,13 +522,10 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
}
- if (dstBeing->getType() == Being::PLAYER)
- player = static_cast<Player*>(dstBeing);
-
if (Party *party = player_node->getParty()){
if (party->isMember(id))
{
- player->setParty(party);
+ dstBeing->setParty(party);
}
}
@@ -565,21 +551,21 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
msg.readInt16(); // manner
dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3
msg.readInt8(); // karma
- player->setGender((msg.readInt8() == 0)
+ dstBeing->setGender((msg.readInt8() == 0)
? GENDER_FEMALE : GENDER_MALE);
// Set these after the gender, as the sprites may be gender-specific
- player->setSprite(SPRITE_WEAPON, weapon, "", true);
- player->setSprite(SPRITE_SHIELD, shield);
- //player->setSprite(SPRITE_SHOE, shoes);
- player->setSprite(SPRITE_BOTTOMCLOTHES, headBottom);
- player->setSprite(SPRITE_TOPCLOTHES, headMid);
- player->setSprite(SPRITE_HAT, headTop);
- //player->setSprite(SPRITE_GLOVES, gloves);
- //player->setSprite(SPRITE_CAPE, cape);
- //player->setSprite(SPRITE_MISC1, misc1);
- //player->setSprite(SPRITE_MISC2, misc2);
- player->setSprite(SPRITE_HAIR, hairStyle * -1, ColorDB::get(hairColor));
+ dstBeing->setSprite(SPRITE_WEAPON, weapon, "", true);
+ dstBeing->setSprite(SPRITE_SHIELD, shield);
+ //dstBeing->setSprite(SPRITE_SHOE, shoes);
+ dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, headBottom);
+ dstBeing->setSprite(SPRITE_TOPCLOTHES, headMid);
+ dstBeing->setSprite(SPRITE_HAT, headTop);
+ //dstBeing->setSprite(SPRITE_GLOVES, gloves);
+ //dstBeing->setSprite(SPRITE_CAPE, cape);
+ //dstBeing->setSprite(SPRITE_MISC1, misc1);
+ //dstBeing->setSprite(SPRITE_MISC2, misc2);
+ dstBeing->setSprite(SPRITE_HAIR, hairStyle * -1, ColorDB::get(hairColor));
if (msg.getId() == SMSG_PLAYER_MOVE)
{
@@ -609,7 +595,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
gmstatus = msg.readInt16();
if (gmstatus & 0x80)
- player->setGM(true);
+ dstBeing->setGM(true);
if (msg.getId() == SMSG_PLAYER_UPDATE_1)
{
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 209f034d..e231c54c 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -25,7 +25,6 @@
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
-#include "npc.h"
#include "gui/buy.h"
#include "gui/buysell.h"
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index f91dfc77..843e5c9f 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -314,17 +314,17 @@ void CharServerHandler::switchCharacter()
outMsg.writeInt8(1);
}
-int CharServerHandler::baseSprite() const
+unsigned int CharServerHandler::baseSprite() const
{
return SPRITE_BASE;
}
-int CharServerHandler::hairSprite() const
+unsigned int CharServerHandler::hairSprite() const
{
return SPRITE_HAIR;
}
-int CharServerHandler::maxSprite() const
+unsigned int CharServerHandler::maxSprite() const
{
return SPRITE_VECTOREND;
}
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index e80d22c4..52bac811 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -63,11 +63,11 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
void switchCharacter();
- int baseSprite() const;
+ unsigned int baseSprite() const;
- int hairSprite() const;
+ unsigned int hairSprite() const;
- int maxSprite() const;
+ unsigned int maxSprite() const;
void connect();
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index 8a106841..3d3b0ab2 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -401,10 +401,10 @@ void GuildHandler::invite(int guildId, const std::string &name)
// TODO?
}
-void GuildHandler::invite(int guildId, Player *player)
+void GuildHandler::invite(int guildId, Being *being)
{
MessageOut msg(CMSG_GUILD_INVITE);
- msg.writeInt32(player->getId());
+ msg.writeInt32(being->getId());
msg.writeInt32(0); // Unused
msg.writeInt32(0); // Unused
}
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
index 39dbe486..8bde222f 100644
--- a/src/net/tmwa/guildhandler.h
+++ b/src/net/tmwa/guildhandler.h
@@ -40,7 +40,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
void invite(int guildId, const std::string &name);
- void invite(int guildId, Player *player);
+ void invite(int guildId, Being *being);
void inviteResponse(int guildId, bool response);
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index e6b16f2d..9d7e72ea 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -23,7 +23,6 @@
#include "beingmanager.h"
#include "localplayer.h"
-#include "npc.h"
#include "gui/npcdialog.h"
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 440b75f4..90ecc0d4 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -145,10 +145,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
if (!(being = beingManager->findBeing(id)))
{
- if (being->getType() == Being::PLAYER)
- {
- nick = being->getName();
- }
+ nick = being->getName();
}
socialWindow->showPartyInvite(partyName, nick);
@@ -253,8 +250,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
nick.c_str()), BY_SERVER);
Being *b = beingManager->findBeing(id);
- if (b->getType() == Being::PLAYER)
- static_cast<Player*>(b)->setParty(NULL);
+ b->setParty(NULL);
taParty->removeMember(id);
}
@@ -276,7 +272,7 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
// lets make sure they get the party hilight.
if (Being *b = beingManager->findBeing(id))
{
- static_cast<Player*>(b)->setParty(taParty);
+ b->setParty(taParty);
}
}
break;
@@ -319,10 +315,10 @@ void PartyHandler::join(int partyId)
// TODO?
}
-void PartyHandler::invite(Player *player)
+void PartyHandler::invite(Being *being)
{
MessageOut outMsg(CMSG_PARTY_INVITE);
- outMsg.writeInt32(player->getId());
+ outMsg.writeInt32(being->getId());
}
void PartyHandler::invite(const std::string &name)
@@ -353,10 +349,10 @@ void PartyHandler::leave()
MessageOut outMsg(CMSG_PARTY_LEAVE);
}
-void PartyHandler::kick(Player *player)
+void PartyHandler::kick(Being *being)
{
MessageOut outMsg(CMSG_PARTY_KICK);
- outMsg.writeInt32(player->getId());
+ outMsg.writeInt32(being->getId());
outMsg.writeString("", 24); //Unused
}
diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h
index fc8d741f..5afc8e53 100644
--- a/src/net/tmwa/partyhandler.h
+++ b/src/net/tmwa/partyhandler.h
@@ -43,7 +43,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
void join(int partyId);
- void invite(Player *player);
+ void invite(Being *being);
void invite(const std::string &name);
@@ -51,7 +51,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
void leave();
- void kick(Player *player);
+ void kick(Being *being);
void kick(const std::string &name);
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index afa2c71b..62cdc168 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -24,7 +24,6 @@
#include "game.h"
#include "localplayer.h"
#include "log.h"
-#include "npc.h"
#include "units.h"
#include "gui/buy.h"
diff --git a/src/net/tmwa/token.h b/src/net/tmwa/token.h
index d2a21012..3e781cd8 100644
--- a/src/net/tmwa/token.h
+++ b/src/net/tmwa/token.h
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "player.h"
+#include "being.h"
#ifndef NET_TA_TOKEN_H
#define NET_TA_TOKEN_H
diff --git a/src/npc.cpp b/src/npc.cpp
deleted file mode 100644
index bdbcfb76..00000000
--- a/src/npc.cpp
+++ /dev/null
@@ -1,76 +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 "animatedsprite.h"
-#include "beingmanager.h"
-#include "npc.h"
-#include "particle.h"
-#include "text.h"
-
-#include "gui/buy.h"
-#include "gui/buysell.h"
-#include "gui/npcdialog.h"
-#include "gui/npcpostdialog.h"
-#include "gui/userpalette.h"
-#include "gui/sell.h"
-
-#include "net/net.h"
-#include "net/npchandler.h"
-
-#include "resources/npcdb.h"
-
-NPC::NPC(int id, int subtype, Map *map):
- Being(id, subtype, map)
-{
- setSubtype(subtype);
-
- setShowName(true);
-}
-
-void NPC::setName(const std::string &name)
-{
- const std::string displayName = name.substr(0, name.find('#', 0));
-
- Being::setName(displayName);
-
- mNameColor = &userPalette->getColor(UserPalette::NPC);
-
- mDispName->setColor(mNameColor);
-}
-
-void NPC::setSubtype(Uint16 subtype)
-{
- Being::setSubtype(subtype);
-
- setupSpriteDisplay(NPCDB::get(subtype), false);
-}
-
-void NPC::talk()
-{
- Net::getNpcHandler()->talk(mId);
-}
-
-bool NPC::isTalking()
-{
- return NpcDialog::isActive() || BuyDialog::isActive() ||
- SellDialog::isActive() || BuySellDialog::isActive() ||
- NpcPostDialog::isActive();
-}
diff --git a/src/npc.h b/src/npc.h
deleted file mode 100644
index a21731e7..00000000
--- a/src/npc.h
+++ /dev/null
@@ -1,67 +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 NPC_H
-#define NPC_H
-
-#include "being.h"
-
-class Graphics;
-class Text;
-
-class NPC : public Being
-{
- public:
- NPC(int id, int subtype, Map *map);
-
- void setName(const std::string &name);
-
- virtual Type getType() const { return Being::NPC; }
-
- virtual void setSubtype(Uint16 subtype);
-
- void talk();
-
- /**
- * Gets the way an NPC is blocked by other things on the map
- */
- virtual unsigned char getWalkMask() const
- {
- return Map::BLOCKMASK_WALL
- | Map::BLOCKMASK_CHARACTER
- | Map::BLOCKMASK_MONSTER;
- }
-
- /** We consider NPCs (at least for now) to be one layer-sprites */
- virtual int getNumberOfLayers() const
- { return 1; }
-
- static bool isTalking();
-
- protected:
- /**
- * Gets the way a monster blocks pathfinding for other objects
- */
- virtual Map::BlockType getBlockType() const
- { return Map::BLOCKTYPE_CHARACTER; } //blocks like a player character
-};
-
-#endif
diff --git a/src/party.cpp b/src/party.cpp
index 75283916..d29d84b3 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -21,7 +21,6 @@
#include "party.h"
#include "beingmanager.h"
-#include "player.h"
PartyMember::PartyMember(Party *party, int id, const std::string &name):
Avatar(name), mId(id), mParty(party), mLeader(false)
@@ -145,8 +144,7 @@ void Party::removeFromMembers()
while(itr != itr_end)
{
Being *b = beingManager->findBeing((*itr)->getID());
- if (b->getType() == Being::PLAYER)
- static_cast<Player*>(b)->setParty(NULL);
+ b->setParty(NULL);
++itr;
}
}
diff --git a/src/player.cpp b/src/player.cpp
deleted file mode 100644
index 10c4c500..00000000
--- a/src/player.cpp
+++ /dev/null
@@ -1,352 +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 "player.h"
-
-#include "animatedsprite.h"
-#include "client.h"
-#include "configuration.h"
-#include "guild.h"
-#include "localplayer.h"
-#include "particle.h"
-#include "party.h"
-#include "text.h"
-
-#include "gui/socialwindow.h"
-#include "gui/theme.h"
-#include "gui/userpalette.h"
-
-#include "net/charhandler.h"
-#include "net/net.h"
-
-#include "resources/colordb.h"
-#include "resources/itemdb.h"
-#include "resources/iteminfo.h"
-
-#include "utils/stringutils.h"
-
-Player::Player(int id, int subtype, Map *map):
- Being(id, subtype, map),
- mGender(GENDER_UNSPECIFIED),
- mParty(NULL),
- mIsGM(false)
-{
- for (int i = 0; i < Net::getCharHandler()->maxSprite(); i++)
- {
- push_back(NULL);
- mSpriteIDs.push_back(0);
- mSpriteColors.push_back("");
- }
-
- setSubtype(subtype);
- mShowName = config.getValue("visiblenames", 1);
- config.addListener("visiblenames", this);
-
- updateColors();
-}
-
-Player::~Player()
-{
- config.removeListener("visiblenames", this);
-}
-
-void Player::logic()
-{
- if (Net::getNetworkType() == ServerInfo::TMWATHENA)
- {
- switch (mAction)
- {
- case STAND:
- case SIT:
- case DEAD:
- case HURT:
- break;
-
- case WALK:
- mFrame = (int) ((get_elapsed_time(mWalkTime) * 6)
- / getWalkSpeed().x);
- if (mFrame >= 6)
- nextTile();
- break;
-
- case ATTACK:
- int rotation = 0;
- std::string particleEffect = "";
- int frames = 4;
-
- if (mEquippedWeapon &&
- mEquippedWeapon->getAttackType() == ACTION_ATTACK_BOW)
- {
- frames = 5;
- }
-
- mFrame = (get_elapsed_time(mWalkTime) * frames) / mAttackSpeed;
-
- //attack particle effect
- if (mEquippedWeapon)
- particleEffect = mEquippedWeapon->getParticleEffect();
-
- if (!particleEffect.empty() && Particle::enabled && mFrame == 1)
- {
- switch (mDirection)
- {
- case DOWN: rotation = 0; break;
- case LEFT: rotation = 90; break;
- case UP: rotation = 180; break;
- case RIGHT: rotation = 270; break;
- default: break;
- }
- Particle *p;
- p = particleEngine->addEffect("graphics/particles/" +
- particleEffect, 0, 0, rotation);
- controlParticle(p);
- }
-
- if (mFrame >= frames)
- nextTile();
-
- break;
- }
- }
-
- Being::logic();
-}
-
-void Player::setSubtype(Uint16 subtype)
-{
- Being::setSubtype(subtype);
-
- int id = -100 - subtype;
- if (ItemDB::exists(id)) // Prevent showing errors when sprite doesn't exist
- setSprite(Net::getCharHandler()->baseSprite(), id);
- else
- setSprite(Net::getCharHandler()->baseSprite(), -100);
-}
-
-void Player::setGender(Gender gender)
-{
- if (gender != mGender)
- {
- mGender = gender;
-
- // Reload all subsprites
- for (unsigned int i = 0; i < size(); i++)
- {
- if (mSpriteIDs.at(i) != 0)
- setSprite(i, mSpriteIDs.at(i), mSpriteColors.at(i));
- }
- }
-}
-
-void Player::setGM(bool gm)
-{
- mIsGM = gm;
-
- updateColors();
-}
-
-void Player::setSprite(int slot, int id, const std::string &color,
- bool isWeapon)
-{
- assert(slot < Net::getCharHandler()->maxSprite());
-
- // id = 0 means unequip
- if (id == 0)
- {
- delete at(slot);
- at(slot) = NULL;
-
- if (isWeapon)
- mEquippedWeapon = NULL;
- }
- else
- {
- std::string filename = ItemDB::get(id).getSprite(mGender);
- AnimatedSprite *equipmentSprite = NULL;
-
- if (!filename.empty())
- {
- if (!color.empty())
- filename += "|" + color;
-
- equipmentSprite = AnimatedSprite::load("graphics/sprites/" +
- filename);
- }
-
- if (equipmentSprite)
- equipmentSprite->setDirection(getSpriteDirection());
-
- if (at(slot))
- delete at(slot);
-
- at(slot) = equipmentSprite;
-
- if (isWeapon)
- mEquippedWeapon = &ItemDB::get(id);
-
- setAction(mAction);
- }
-
- mSpriteIDs[slot] = id;
- mSpriteColors[slot] = color;
-}
-
-void Player::setSpriteID(unsigned int slot, int id)
-{
- setSprite(slot, id, mSpriteColors[slot]);
-}
-
-void Player::setSpriteColor(unsigned int slot, const std::string &color)
-{
- setSprite(slot, mSpriteIDs[slot], color);
-}
-
-void Player::addGuild(Guild *guild)
-{
- mGuilds[guild->getId()] = guild;
- guild->addMember(mId, mName);
-
- if (this == player_node && socialWindow)
- {
- socialWindow->addTab(guild);
- }
-}
-
-void Player::removeGuild(int id)
-{
- if (this == player_node && socialWindow)
- {
- socialWindow->removeTab(mGuilds[id]);
- }
-
- mGuilds[id]->removeMember(mId);
- mGuilds.erase(id);
-}
-
-Guild *Player::getGuild(const std::string &guildName) const
-{
- std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
- for (itr = mGuilds.begin(); itr != itr_end; ++itr)
- {
- Guild *guild = itr->second;
- if (guild->getName() == guildName)
- {
- return guild;
- }
- }
-
- return NULL;
-}
-
-Guild *Player::getGuild(int id) const
-{
- std::map<int, Guild*>::const_iterator itr;
- itr = mGuilds.find(id);
- if (itr != mGuilds.end())
- {
- return itr->second;
- }
-
- return NULL;
-}
-
-const std::map<int, Guild*> &Player::getGuilds() const
-{
- return mGuilds;
-}
-
-void Player::clearGuilds()
-{
- std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
- for (itr = mGuilds.begin(); itr != itr_end; ++itr)
- {
- Guild *guild = itr->second;
-
- if (this == player_node && socialWindow)
- socialWindow->removeTab(guild);
-
- guild->removeMember(mId);
- }
-
- mGuilds.clear();
-}
-
-void Player::setParty(Party *party)
-{
- if (party == mParty)
- return;
-
- Party *old = mParty;
- mParty = party;
-
- if (old)
- {
- old->removeMember(mId);
- }
-
- if (party)
- {
- party->addMember(mId, mName);
- }
-
- updateColors();
-
- if (this == player_node && socialWindow)
- {
- if (old)
- socialWindow->removeTab(old);
-
- if (party)
- socialWindow->addTab(party);
- }
-}
-
-void Player::optionChanged(const std::string &value)
-{
- if (value == "visiblenames")
- {
- setShowName(config.getValue("visiblenames", 1));
- }
-}
-
-void Player::updateColors()
-{
- mTextColor = &userPalette->getColor(Theme::PLAYER);
-
- if (mIsGM)
- {
- mTextColor = &userPalette->getColor(Theme::GM);
- mNameColor = &userPalette->getColor(UserPalette::GM);
- }
- else if (mParty && mParty == player_node->getParty())
- {
- mNameColor = &userPalette->getColor(UserPalette::PARTY);
- }
- else
- {
- mNameColor = &userPalette->getColor(UserPalette::PC);
- }
-
- if (mDispName)
- {
- mDispName->setColor(mNameColor);
- }
-}
diff --git a/src/player.h b/src/player.h
deleted file mode 100644
index 0bb59428..00000000
--- a/src/player.h
+++ /dev/null
@@ -1,161 +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 PLAYER_H
-#define PLAYER_H
-
-#include "being.h"
-
-class Graphics;
-class Guild;
-class Map;
-class Party;
-
-enum Gender
-{
- GENDER_MALE = 0,
- GENDER_FEMALE = 1,
- GENDER_UNSPECIFIED = 2
-};
-
-/**
- * A player being. Players have their name drawn beneath them. This class also
- * implements player-specific loading of base sprite, hair sprite and equipment
- * sprites.
- */
-class Player : public Being
-{
- public:
- /**
- * Constructor.
- */
- Player(int id, int subtype, Map *map);
-
- ~Player();
-
- virtual void logic();
-
- virtual Type getType() const { return PLAYER; }
-
- virtual void setSubtype(Uint16 subtype);
-
- /**
- * Sets the gender of this being.
- */
- virtual void setGender(Gender gender);
-
- Gender getGender() const { return mGender; }
-
- /**
- * Whether or not this player is a GM.
- */
- bool isGM() const { return mIsGM; }
-
- /**
- * Triggers whether or not to show the name as a GM name.
- */
- virtual void setGM(bool gm);
-
- /**
- * Sets visible equipments for this player.
- */
- virtual void setSprite(int slot, int id,
- const std::string &color = "",
- bool isWeapon = false);
-
- virtual void setSpriteID(unsigned int slot, int id);
-
- virtual void setSpriteColor(unsigned int slot,
- const std::string &color = "");
-
- /**
- * Adds a guild to the player.
- */
- void addGuild(Guild *guild);
-
- /**
- * Removers a guild from the player.
- */
- void removeGuild(int id);
-
- /**
- * Returns a pointer to the specified guild.
- */
- Guild *getGuild(const std::string &guildName) const;
-
- /**
- * Returns a pointer to the guild with matching id.
- */
- Guild *getGuild(int id) const;
-
- /**
- * Returns all guilds the player is in.
- */
- const std::map<int, Guild*> &getGuilds() const;
-
- /**
- * Removes all guilds the player is in.
- */
- void clearGuilds();
-
- /**
- * Get number of guilds the player belongs to.
- */
- short getNumberOfGuilds() const { return mGuilds.size(); }
-
- bool isInParty() const { return mParty != NULL; }
-
- void setParty(Party *party);
-
- Party *getParty() const { return mParty; }
-
- /**
- * Gets the way the character is blocked by other objects.
- */
- virtual unsigned char getWalkMask() const
- { return Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER; }
-
- /**
- * Called when a option (set with config.addListener()) is changed
- */
- virtual void optionChanged(const std::string &value);
-
- protected:
- /**
- * Gets the way the monster blocks pathfinding for other objects.
- */
- virtual Map::BlockType getBlockType() const
- { return Map::BLOCKTYPE_CHARACTER; }
-
- virtual void updateColors();
-
- Gender mGender;
- std::vector<int> mSpriteIDs;
- std::vector<std::string> mSpriteColors;
-
- // Character guild information
- std::map<int, Guild*> mGuilds;
- Party *mParty;
-
- bool mIsGM;
-};
-
-#endif
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index bd657f4f..e8c015d1 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -25,7 +25,6 @@
#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
-#include "player.h"
#include "playerrelations.h"
#include "utils/dtor.h"
@@ -205,7 +204,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently(const std::string &
bool PlayerRelationsManager::hasPermission(Being *being, unsigned int flags)
{
- if (being->getType() == Being::PLAYER)
+ if (being->getType() == ActorSprite::PLAYER)
return hasPermission(being->getName(), flags) == flags;
return true;
}
@@ -221,9 +220,10 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
// execute `ignore' strategy, if possible
if (mIgnoreStrategy)
{
- Being *b = beingManager->findBeingByName(name, Being::PLAYER);
- if (b && b->getType() == Being::PLAYER)
- mIgnoreStrategy->ignore(static_cast<Player *>(b), rejections);
+ Being *b = beingManager->findBeingByName(name,
+ ActorSprite::PLAYER);
+ if (b && b->getType() == ActorSprite::PLAYER)
+ mIgnoreStrategy->ignore(b, rejections);
}
}
@@ -304,7 +304,7 @@ public:
mShortName = PLAYER_IGNORE_STRATEGY_NOP;
}
- virtual void ignore(Player *player, unsigned int flags)
+ virtual void ignore(Being *being, unsigned int flags)
{
}
};
@@ -318,9 +318,9 @@ public:
mShortName = "dotdotdot";
}
- virtual void ignore(Player *player, unsigned int flags)
+ virtual void ignore(Being *being, unsigned int flags)
{
- player->setSpeech("...", 500);
+ being->setSpeech("...", 500);
}
};
@@ -334,9 +334,9 @@ public:
mShortName = "blinkname";
}
- virtual void ignore(Player *player, unsigned int flags)
+ virtual void ignore(Being *being, unsigned int flags)
{
- player->flashName(200);
+ being->flashName(200);
}
};
@@ -350,9 +350,9 @@ public:
mShortName = shortname;
}
- virtual void ignore(Player *player, unsigned int flags)
+ virtual void ignore(Being *being, unsigned int flags)
{
- player->setEmote(mEmotion, IGNORE_EMOTE_TIME);
+ being->setEmote(mEmotion, IGNORE_EMOTE_TIME);
}
private:
int mEmotion;
diff --git a/src/playerrelations.h b/src/playerrelations.h
index 3ff1e5fd..d6ca31ad 100644
--- a/src/playerrelations.h
+++ b/src/playerrelations.h
@@ -28,7 +28,6 @@
#include <vector>
class Being;
-class Player;
struct PlayerRelation
{
@@ -73,7 +72,7 @@ public:
/**
* Handle the ignoring of the indicated action by the indicated player.
*/
- virtual void ignore(Player *player, unsigned int flags) = 0;
+ virtual void ignore(Being *being, unsigned int flags) = 0;
};
class PlayerRelationsListener
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
new file mode 100644
index 00000000..30b4f86f
--- /dev/null
+++ b/src/resources/beinginfo.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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 "resources/beinginfo.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+
+BeingInfo *BeingInfo::Unknown = new BeingInfo;
+
+BeingInfo::BeingInfo():
+ mName(_("unnamed")),
+ mTargetCursorSize(ActorSprite::TC_MEDIUM),
+ mWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER
+ | Map::BLOCKMASK_MONSTER),
+ mBlockType(Map::BLOCKTYPE_CHARACTER)
+{
+ SpriteDisplay display;
+ display.sprites.push_back(SpriteReference::Empty);
+
+ setDisplay(display);
+}
+
+BeingInfo::~BeingInfo()
+{
+ delete_all(mSounds);
+ delete_all(mAttacks);
+ mSounds.clear();
+}
+
+void BeingInfo::setDisplay(SpriteDisplay display)
+{
+ mDisplay = display;
+}
+
+void BeingInfo::addSound(SoundEvent event, const std::string &filename)
+{
+ if (mSounds.find(event) == mSounds.end())
+ {
+ mSounds[event] = new std::vector<std::string>;
+ }
+
+ mSounds[event]->push_back("sfx/" + filename);
+}
+
+const std::string &BeingInfo::getSound(SoundEvent event) const
+{
+ static std::string empty("");
+
+ SoundEvents::const_iterator i = mSounds.find(event);
+ return (i == mSounds.end()) ? empty :
+ i->second->at(rand() % i->second->size());
+}
+
+const Attack *BeingInfo::getAttack(int type) const
+{
+ static Attack *empty = new Attack(ACTION_DEFAULT, "", "");
+
+ Attacks::const_iterator i = mAttacks.find(type);
+ return (i == mAttacks.end()) ? empty : (*i).second;
+}
+
+void BeingInfo::addAttack(int id, SpriteAction action,
+ const std::string &particleEffect,
+ const std::string &missileParticle)
+{
+ if (mAttacks[id])
+ delete mAttacks[id];
+
+ mAttacks[id] = new Attack(action, particleEffect, missileParticle);
+}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
new file mode 100644
index 00000000..def5426e
--- /dev/null
+++ b/src/resources/beinginfo.h
@@ -0,0 +1,130 @@
+/*
+ * 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 BEINGINFO_H
+#define BEINGINFO_H
+
+#include "actorsprite.h"
+
+#include "resources/spritedef.h"
+
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+
+struct Attack {
+ SpriteAction action;
+ std::string particleEffect;
+ std::string missileParticle;
+
+ Attack(SpriteAction action, std::string particleEffect,
+ std::string missileParticle)
+ {
+ this->action = action;
+ this->particleEffect = particleEffect;
+ this->missileParticle = missileParticle;
+ }
+};
+
+typedef std::map<int, Attack*> Attacks;
+
+enum SoundEvent
+{
+ SOUND_EVENT_HIT,
+ SOUND_EVENT_MISS,
+ SOUND_EVENT_HURT,
+ SOUND_EVENT_DIE
+};
+
+typedef std::map<SoundEvent, std::vector<std::string>* > SoundEvents;
+
+/**
+ * Holds information about a certain type of monster. This includes the name
+ * of the monster, the sprite to display and the sounds the monster makes.
+ *
+ * @see MonsterDB
+ * @see NPCDB
+ */
+class BeingInfo
+{
+ public:
+ static BeingInfo *Unknown;
+
+ BeingInfo();
+
+ ~BeingInfo();
+
+ void setName(const std::string &name) { mName = name; }
+
+ const std::string &getName() const
+ { return mName; }
+
+ void setDisplay(SpriteDisplay display);
+
+ const SpriteDisplay &getDisplay() const
+ { return mDisplay; }
+
+ void setTargetCursorSize(ActorSprite::TargetCursorSize targetSize)
+ { mTargetCursorSize = targetSize; }
+
+ ActorSprite::TargetCursorSize getTargetCursorSize() const
+ { return mTargetCursorSize; }
+
+ void addSound(SoundEvent event, const std::string &filename);
+
+ const std::string &getSound(SoundEvent event) const;
+
+ void addAttack(int id, SpriteAction action,
+ const std::string &particleEffect,
+ const std::string &missileParticle);
+
+ const Attack *getAttack(int type) const;
+
+ void setWalkMask(unsigned char mask)
+ { mWalkMask = mask; }
+
+ /**
+ * Gets the way the being is blocked by other objects
+ */
+ unsigned char getWalkMask() const
+ { return mWalkMask; }
+
+ void setBlockType(Map::BlockType blockType)
+ { mBlockType = blockType; }
+
+ Map::BlockType getBlockType() const
+ { return mBlockType; }
+
+ private:
+ SpriteDisplay mDisplay;
+ std::string mName;
+ ActorSprite::TargetCursorSize mTargetCursorSize;
+ SoundEvents mSounds;
+ Attacks mAttacks;
+ unsigned char mWalkMask;
+ Map::BlockType mBlockType;
+};
+
+typedef std::map<int, BeingInfo*> BeingInfos;
+typedef BeingInfos::iterator BeingInfoIterator;
+
+#endif // BEINGINFO_H
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index f42ac8e6..d9fc05cc 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -22,7 +22,7 @@
#ifndef ITEMINFO_H
#define ITEMINFO_H
-#include "player.h"
+#include "being.h"
#include "resources/spritedef.h"
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index 658321f1..c70cee94 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -23,7 +23,7 @@
#include "log.h"
-#include "resources/monsterinfo.h"
+#include "resources/beinginfo.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -35,8 +35,7 @@
namespace
{
- MonsterDB::MonsterInfos mMonsterInfos;
- MonsterInfo mUnknown;
+ BeingInfos mMonsterInfos;
bool mLoaded = false;
}
@@ -45,17 +44,6 @@ void MonsterDB::load()
if (mLoaded)
return;
- {
- SpriteReference *unknownSprite = new SpriteReference;
- unknownSprite->sprite = "error.xml";
- unknownSprite->variant = 0;
-
- SpriteDisplay display;
- display.sprites.push_front(unknownSprite);
-
- mUnknown.setDisplay(display);
- }
-
logger->log("Initializing monster database...");
XML::Document doc("monsters.xml");
@@ -77,7 +65,12 @@ void MonsterDB::load()
continue;
}
- MonsterInfo *currentInfo = new MonsterInfo;
+ BeingInfo *currentInfo = new BeingInfo;
+
+ currentInfo->setWalkMask(Map::BLOCKMASK_WALL
+ | Map::BLOCKMASK_CHARACTER
+ | Map::BLOCKMASK_MONSTER);
+ currentInfo->setBlockType(Map::BLOCKTYPE_MONSTER);
currentInfo->setName(XML::getProperty(monsterNode, "name", _("unnamed")));
@@ -85,22 +78,22 @@ void MonsterDB::load()
targetCursor = XML::getProperty(monsterNode, "targetCursor", "medium");
if (targetCursor == "small")
{
- currentInfo->setTargetCursorSize(Being::TC_SMALL);
+ currentInfo->setTargetCursorSize(ActorSprite::TC_SMALL);
}
else if (targetCursor == "medium")
{
- currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM);
}
else if (targetCursor == "large")
{
- currentInfo->setTargetCursorSize(Being::TC_LARGE);
+ currentInfo->setTargetCursorSize(ActorSprite::TC_LARGE);
}
else
{
logger->log("MonsterDB: Unknown target cursor type \"%s\" for %s -"
"using medium sized one",
targetCursor.c_str(), currentInfo->getName().c_str());
- currentInfo->setTargetCursorSize(Being::TC_MEDIUM);
+ currentInfo->setTargetCursorSize(ActorSprite::TC_MEDIUM);
}
SpriteDisplay display;
@@ -123,19 +116,19 @@ void MonsterDB::load()
if (event == "hit")
{
- currentInfo->addSound(MONSTER_EVENT_HIT, filename);
+ currentInfo->addSound(SOUND_EVENT_HIT, filename);
}
else if (event == "miss")
{
- currentInfo->addSound(MONSTER_EVENT_MISS, filename);
+ currentInfo->addSound(SOUND_EVENT_MISS, filename);
}
else if (event == "hurt")
{
- currentInfo->addSound(MONSTER_EVENT_HURT, filename);
+ currentInfo->addSound(SOUND_EVENT_HURT, filename);
}
else if (event == "die")
{
- currentInfo->addSound(MONSTER_EVENT_DIE, filename);
+ currentInfo->addSound(SOUND_EVENT_DIE, filename);
}
else
{
@@ -154,7 +147,8 @@ void MonsterDB::load()
XML::getProperty(spriteNode, "action", "attack"));
const std::string missileParticle = XML::getProperty(
spriteNode, "missile-particle", "");
- currentInfo->addMonsterAttack(id, particleEffect, spriteAction, missileParticle);
+ currentInfo->addAttack(id, spriteAction,
+ particleEffect, missileParticle);
}
else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))
{
@@ -179,17 +173,17 @@ void MonsterDB::unload()
}
-const MonsterInfo &MonsterDB::get(int id)
+BeingInfo *MonsterDB::get(int id)
{
- MonsterInfoIterator i = mMonsterInfos.find(id);
+ BeingInfoIterator i = mMonsterInfos.find(id);
if (i == mMonsterInfos.end())
{
logger->log("MonsterDB: Warning, unknown monster ID %d requested", id);
- return mUnknown;
+ return BeingInfo::Unknown;
}
else
{
- return *(i->second);
+ return i->second;
}
}
diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h
index 0fc8d2cf..50f70438 100644
--- a/src/resources/monsterdb.h
+++ b/src/resources/monsterdb.h
@@ -22,9 +22,7 @@
#ifndef MONSTER_DB_H
#define MONSTER_DB_H
-#include <map>
-
-class MonsterInfo;
+class BeingInfo;
/**
* Monster information database.
@@ -35,10 +33,7 @@ namespace MonsterDB
void unload();
- const MonsterInfo &get(int id);
-
- typedef std::map<int, MonsterInfo*> MonsterInfos;
- typedef MonsterInfos::iterator MonsterInfoIterator;
+ BeingInfo *get(int id);
}
#endif
diff --git a/src/resources/monsterinfo.cpp b/src/resources/monsterinfo.cpp
deleted file mode 100644
index 41ce5b6b..00000000
--- a/src/resources/monsterinfo.cpp
+++ /dev/null
@@ -1,93 +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 "resources/monsterinfo.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-MonsterInfo::MonsterInfo():
- mName(_("unnamed")),
- mTargetCursorSize(Being::TC_MEDIUM)
-{
-}
-
-MonsterInfo::~MonsterInfo()
-{
- // kill vectors in mSoundEffects
- delete_all(mSounds);
- delete_all(mMonsterAttacks);
- mSounds.clear();
-}
-
-void MonsterInfo::addSound(MonsterSoundEvent event, const std::string &filename)
-{
- if (mSounds.find(event) == mSounds.end())
- {
- mSounds[event] = new std::vector<std::string>;
- }
-
- mSounds[event]->push_back("sfx/" + filename);
-}
-
-const std::string &MonsterInfo::getSound(MonsterSoundEvent event) const
-{
- static std::string empty("");
- std::map<MonsterSoundEvent, std::vector<std::string>* >::const_iterator i =
- mSounds.find(event);
- return (i == mSounds.end()) ? empty :
- i->second->at(rand() % i->second->size());
-}
-
-const std::string &MonsterInfo::getAttackParticleEffect(int attackType) const
-{
- static std::string empty("");
- std::map<int, MonsterAttack*>::const_iterator i =
- mMonsterAttacks.find(attackType);
- return (i == mMonsterAttacks.end()) ? empty : (*i).second->particleEffect;
-}
-
-const std::string &MonsterInfo::getAttackMissileParticle(int attackType) const
-{
- static std::string empty("");
- std::map<int, MonsterAttack*>::const_iterator i =
- mMonsterAttacks.find(attackType);
- return (i == mMonsterAttacks.end()) ? empty : (*i).second->missileParticle;
-}
-
-SpriteAction MonsterInfo::getAttackAction(int attackType) const
-{
- std::map<int, MonsterAttack*>::const_iterator i =
- mMonsterAttacks.find(attackType);
- return (i == mMonsterAttacks.end()) ? ACTION_ATTACK : (*i).second->action;
-}
-
-void MonsterInfo::addMonsterAttack(int id,
- const std::string &particleEffect,
- SpriteAction action,
- const std::string &missileParticle)
-{
- MonsterAttack *a = new MonsterAttack;
- a->particleEffect = particleEffect;
- a->missileParticle = missileParticle;
- a->action = action;
- mMonsterAttacks[id] = a;
-}
diff --git a/src/resources/monsterinfo.h b/src/resources/monsterinfo.h
deleted file mode 100644
index 7741f762..00000000
--- a/src/resources/monsterinfo.h
+++ /dev/null
@@ -1,102 +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 MONSTERINFO_H
-#define MONSTERINFO_H
-
-#include "being.h"
-
-#include "resources/spritedef.h"
-
-#include <list>
-#include <map>
-#include <string>
-#include <vector>
-
-enum MonsterSoundEvent
-{
- MONSTER_EVENT_HIT,
- MONSTER_EVENT_MISS,
- MONSTER_EVENT_HURT,
- MONSTER_EVENT_DIE
-};
-
-struct MonsterAttack
-{
- std::string missileParticle;
- std::string particleEffect;
- SpriteAction action;
-};
-
-/**
- * Holds information about a certain type of monster. This includes the name
- * of the monster, the sprite to display and the sounds the monster makes.
- *
- * @see MonsterDB
- */
-class MonsterInfo
-{
- public:
- MonsterInfo();
-
- ~MonsterInfo();
-
- void setName(const std::string &name) { mName = name; }
-
- void setDisplay(SpriteDisplay display)
- { mDisplay = display; }
-
- const SpriteDisplay &getDisplay() const
- { return mDisplay; }
-
- void setTargetCursorSize(Being::TargetCursorSize targetCursorSize)
- { mTargetCursorSize = targetCursorSize; }
-
- void addSound(MonsterSoundEvent event, const std::string &filename);
-
- const std::string &getName() const
- { return mName; }
-
- ActorSprite::TargetCursorSize getTargetCursorSize() const
- { return mTargetCursorSize; }
-
- const std::string &getSound(MonsterSoundEvent event) const;
-
- void addMonsterAttack(int id,
- const std::string &particleEffect,
- SpriteAction action,
- const std::string &missileParticle);
-
- const std::string &getAttackParticleEffect(int attackType) const;
-
- const std::string &getAttackMissileParticle(int attackType) const;
-
- SpriteAction getAttackAction(int attackType) const;
-
- private:
- SpriteDisplay mDisplay;
- std::string mName;
- Being::TargetCursorSize mTargetCursorSize;
- std::map<MonsterSoundEvent, std::vector<std::string>* > mSounds;
- std::map<int, MonsterAttack*> mMonsterAttacks;
-};
-
-#endif // MONSTERINFO_H
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index e2628257..72a89748 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -23,12 +23,14 @@
#include "log.h"
+#include "resources/beinginfo.h"
+
+#include "utils/dtor.h"
#include "utils/xml.h"
namespace
{
- NPCInfos mNPCInfos;
- SpriteDisplay mUnknown;
+ BeingInfos mNPCInfos;
bool mLoaded = false;
}
@@ -37,13 +39,6 @@ void NPCDB::load()
if (mLoaded)
return;
- {
- SpriteReference *unknownSprite = new SpriteReference;
- unknownSprite->sprite = "error.xml";
- unknownSprite->variant = 0;
- mUnknown.sprites.push_back(unknownSprite);
- }
-
logger->log("Initializing NPC database...");
XML::Document doc("npcs.xml");
@@ -67,7 +62,8 @@ void NPCDB::load()
continue;
}
- SpriteDisplay *currentInfo = new SpriteDisplay;
+ BeingInfo *currentInfo = new BeingInfo;
+ SpriteDisplay display;
for_each_xml_child_node(spriteNode, npcNode)
{
@@ -76,14 +72,17 @@ void NPCDB::load()
SpriteReference *currentSprite = new SpriteReference;
currentSprite->sprite = (const char*)spriteNode->xmlChildrenNode->content;
currentSprite->variant = XML::getProperty(spriteNode, "variant", 0);
- currentInfo->sprites.push_back(currentSprite);
+ display.sprites.push_back(currentSprite);
}
else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx"))
{
std::string particlefx = (const char*)spriteNode->xmlChildrenNode->content;
- currentInfo->particles.push_back(particlefx);
+ display.particles.push_back(particlefx);
}
}
+
+ currentInfo->setDisplay(display);
+
mNPCInfos[id] = currentInfo;
}
@@ -92,40 +91,23 @@ void NPCDB::load()
void NPCDB::unload()
{
- for ( NPCInfosIterator i = mNPCInfos.begin();
- i != mNPCInfos.end();
- i++)
- {
- while (!i->second->sprites.empty())
- {
- delete i->second->sprites.front();
- i->second->sprites.pop_front();
- }
- delete i->second;
- }
-
+ delete_all(mNPCInfos);
mNPCInfos.clear();
- while (!mUnknown.sprites.empty())
- {
- delete mUnknown.sprites.front();
- mUnknown.sprites.pop_front();
- }
-
mLoaded = false;
}
-const SpriteDisplay& NPCDB::get(int id)
+BeingInfo *NPCDB::get(int id)
{
- NPCInfosIterator i = mNPCInfos.find(id);
+ BeingInfoIterator i = mNPCInfos.find(id);
if (i == mNPCInfos.end())
{
logger->log("NPCDB: Warning, unknown NPC ID %d requested", id);
- return mUnknown;
+ return BeingInfo::Unknown;
}
else
{
- return *(i->second);
+ return i->second;
}
}
diff --git a/src/resources/npcdb.h b/src/resources/npcdb.h
index 84ae4e24..b0c89c80 100644
--- a/src/resources/npcdb.h
+++ b/src/resources/npcdb.h
@@ -22,11 +22,7 @@
#ifndef NPC_DB_H
#define NPC_DB_H
-#include "resources/spritedef.h"
-
-#include <map>
-
-typedef std::map<int, SpriteDisplay*> NPCInfos;
+class BeingInfo;
/**
* NPC information database.
@@ -37,9 +33,7 @@ namespace NPCDB
void unload();
- const SpriteDisplay& get(int id);
-
- typedef NPCInfos::iterator NPCInfosIterator;
+ BeingInfo *get(int id);
}
#endif
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 55b38546..03787569 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -30,10 +30,13 @@
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+#include "utils/dtor.h"
#include "utils/xml.h"
#include <set>
+SpriteReference *SpriteReference::Empty = new SpriteReference("error.xml", 0);
+
Action *SpriteDef::getAction(SpriteAction action) const
{
Actions::const_iterator i = mActions.find(action);
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index d5db542c..bc9ae45f 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -35,6 +35,13 @@ class ImageSet;
struct SpriteReference
{
+ static SpriteReference *Empty;
+
+ SpriteReference() {}
+
+ SpriteReference(std::string sprite, int variant)
+ { this->sprite = sprite; this->variant = variant; }
+
std::string sprite;
int variant;
};