summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/popupmenu.cpp31
-rw-r--r--src/gui/setup_players.cpp2
-rw-r--r--src/gui/skilldialog.cpp16
-rw-r--r--src/gui/socialwindow.cpp14
-rw-r--r--src/gui/statuswindow.cpp13
-rw-r--r--src/gui/viewport.cpp5
-rw-r--r--src/gui/widgets/avatarlistbox.cpp17
-rw-r--r--src/guild.cpp9
-rw-r--r--src/net/ea/beinghandler.cpp11
-rw-r--r--src/net/ea/partyhandler.cpp10
-rw-r--r--src/party.cpp8
-rw-r--r--src/playerrelations.cpp7
14 files changed, 62 insertions, 85 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 185fcb03..e0aa7313 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -879,7 +879,7 @@ void Game::handleInput()
if (target)
{
if (target->getType() == Being::NPC)
- dynamic_cast<NPC*>(target)->talk();
+ static_cast<NPC*>(target)->talk();
}
}
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 954ee3f0..8965ec70 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -129,7 +129,7 @@ void ChatWindow::resetToDefaultSize()
ChatTab *ChatWindow::getFocused() const
{
- return dynamic_cast<ChatTab*>(mChatTabs->getSelectedTab());
+ return static_cast<ChatTab*>(mChatTabs->getSelectedTab());
}
void ChatWindow::clearTab(ChatTab *tab)
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 8404fad1..520b4005 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -203,16 +203,13 @@ 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->getType() == Being::NPC)
{
- dynamic_cast<NPC*>(being)->talk();
+ static_cast<NPC*>(being)->talk();
}
// Trade action
- else if (link == "trade" &&
- being &&
- being->getType() == Being::PLAYER)
+ else if (link == "trade" && being && being->getType() == Being::PLAYER)
{
Net::getTradeHandler()->request(being);
tradePartnerName = being->getName();
@@ -226,37 +223,27 @@ 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() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
}
- else if (link == "ignore" &&
- being &&
- being->getType() == Being::PLAYER)
+ else if (link == "ignore" && being && being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
}
- else if (link == "disregard" &&
- being &&
- being->getType() == Being::PLAYER)
+ else if (link == "disregard" && being && being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
}
- else if (link == "friend" &&
- being &&
- being->getType() == Being::PLAYER)
+ else if (link == "friend" && being && being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
}
// Guild action
- else if (link == "guild" &&
- being != NULL &&
- being->getType() == Being::PLAYER)
+ else if (link == "guild" && being && being->getType() == Being::PLAYER)
{
player_node->inviteToGuild(being);
}
@@ -325,7 +312,7 @@ void PopupMenu::handleLink(const std::string &link)
else if (link == "party" && being && being->getType() == Being::PLAYER)
{
- Net::getPartyHandler()->invite(dynamic_cast<Player*>(being));
+ Net::getPartyHandler()->invite(static_cast<Player*>(being));
}
else if (link == "name" && being)
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 159eab78..06bae0ef 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -151,7 +151,7 @@ public:
virtual void updateModelInRow(int row)
{
- gcn::DropDown *choicebox = dynamic_cast<gcn::DropDown *>(
+ gcn::DropDown *choicebox = static_cast<gcn::DropDown *>(
getElementAt(row, RELATION_CHOICE_COLUMN));
player_relations.setRelation(getPlayerAt(row),
static_cast<PlayerRelation::Relation>(
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 943bda3a..0a5b8d71 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -138,11 +138,11 @@ public:
void draw(gcn::Graphics *gcnGraphics)
{
- SkillModel* model = dynamic_cast<SkillModel*>(mListModel);
-
- if (!model)
+ if (!mListModel)
return;
+ SkillModel* model = static_cast<SkillModel*>(mListModel);
+
updateAlpha();
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -226,13 +226,9 @@ void SkillDialog::action(const gcn::ActionEvent &event)
{
if (event.getId() == "inc")
{
- SkillTab *tab = dynamic_cast<SkillTab*>(mTabs->getSelectedTab());
-
- if (tab)
- {
- if (SkillInfo *info = tab->getSelectedInfo())
- Net::getPlayerHandler()->increaseSkill(info->id);
- }
+ SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab());
+ if (SkillInfo *info = tab->getSelectedInfo())
+ Net::getPlayerHandler()->increaseSkill(info->id);
}
else if (event.getId() == "close")
{
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 1396ab98..10ed680e 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -455,21 +455,11 @@ void SocialWindow::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "invite")
{
- SocialTab *tab = dynamic_cast<SocialTab*>(mTabs->getSelectedTab());
-
- if (tab)
- {
- tab->invite();
- }
+ static_cast<SocialTab*>(mTabs->getSelectedTab())->invite();
}
else if (event.getId() == "leave")
{
- SocialTab *tab = dynamic_cast<SocialTab*>(mTabs->getSelectedTab());
-
- if (tab)
- {
- tab->leave();
- }
+ static_cast<SocialTab*>(mTabs->getSelectedTab())->leave();
}
else if (event.getId() == "create guild")
{
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 7312078e..498a4523 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -46,7 +46,12 @@
class AttrDisplay : public Container
{
public:
+ enum Type {
+ DERIVED, CHANGEABLE, UNKNOWN
+ };
+
virtual std::string update();
+ virtual Type getType() { return UNKNOWN; }
protected:
AttrDisplay(int id, const std::string &name);
@@ -63,6 +68,7 @@ class DerDisplay : public AttrDisplay
{
public:
DerDisplay(int id, const std::string &name);
+ virtual Type getType() { return DERIVED; }
};
class ChangeDisplay : public AttrDisplay, gcn::ActionListener
@@ -70,6 +76,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
public:
ChangeDisplay(int id, const std::string &name);
std::string update();
+ virtual Type getType() { return CHANGEABLE; }
void setPointsNeeded(int needed);
private:
@@ -269,9 +276,9 @@ void StatusWindow::setPointsNeeded(int id, int needed)
if (it != mAttrs.end())
{
- ChangeDisplay *disp = dynamic_cast<ChangeDisplay*>(it->second);
- if (disp)
- disp->setPointsNeeded(needed);
+ AttrDisplay *disp = it->second;
+ if (disp->getType() == AttrDisplay::CHANGEABLE)
+ static_cast<ChangeDisplay*>(disp)->setPointsNeeded(needed);
}
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 0c281973..5edbe154 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -459,8 +459,9 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
const int y = (event.getY() + (int) mPixelViewY);
mHoverBeing = beingManager->findBeingByPixel(x, y);
- if (Player *p = dynamic_cast<Player*>(mHoverBeing))
- mBeingPopup->show(getMouseX(), getMouseY(), p);
+ if (mHoverBeing->getType() == Being::PLAYER)
+ mBeingPopup->show(getMouseX(), getMouseY(),
+ static_cast<Player*>(mHoverBeing));
else
mBeingPopup->setVisible(false);
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 0235d104..6ec4d1e8 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -65,11 +65,11 @@ AvatarListBox::~AvatarListBox()
void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
{
- AvatarListModel* model = dynamic_cast<AvatarListModel*>(mListModel);
-
- if (!model)
+ if (!mListModel)
return;
+ AvatarListModel* model = static_cast<AvatarListModel*>(mListModel);
+
updateAlpha();
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -140,15 +140,12 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
setSelected(y / getFont()->getHeight());
distributeActionEvent();
- if (event.getClickCount() == 2)
+ if (event.getClickCount() == 2 && mListModel)
{
int selected = getSelected();
- AvatarListModel *model = dynamic_cast<AvatarListModel*>(mListModel);
- if (model)
- {
- chatWindow->addWhisperTab(model->getAvatarAt(selected)
- ->getName(), true);
- }
+ AvatarListModel *model = static_cast<AvatarListModel*>(mListModel);
+ chatWindow->addWhisperTab(model->getAvatarAt(selected)->getName(),
+ true);
}
}
// TODO: Add support for context menu
diff --git a/src/guild.cpp b/src/guild.cpp
index 65515cd7..d6ef80cf 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -170,11 +170,10 @@ void Guild::removeFromMembers()
itr_end = mMembers.end();
while(itr != itr_end)
{
- Player *p = dynamic_cast<Player*>(beingManager->findBeing((*itr)->getID()));
- if (p)
- {
- p->removeGuild(getId());
- }
+ Being *b = beingManager->findBeing((*itr)->getID());
+
+ if (b->getType() == Being::PLAYER)
+ static_cast<Player*>(b)->removeGuild(getId());
++itr;
}
}
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index d3f6dd0e..90831e9f 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -107,7 +107,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
int type, guild;
Uint16 status;
Being *srcBeing, *dstBeing;
- Player *player;
+ Player *player = 0;
int hairStyle, hairColor, flag;
std::string player_followed;
@@ -140,7 +140,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
dstBeing = createBeing(id, job);
}
- player = dynamic_cast<Player*>(dstBeing);
+ if (dstBeing->getType() == Being::PLAYER)
+ player = static_cast<Player*>(dstBeing);
// Fix monster jobs
if (dstBeing->getType() == Being::MONSTER)
@@ -420,7 +421,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
}
- player = dynamic_cast<Player*>(dstBeing);
+ if (dstBeing->getType() == Being::PLAYER)
+ player = static_cast<Player*>(dstBeing);
int type = msg.readInt8();
int id = 0;
@@ -529,7 +531,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
dstBeing = createBeing(id, job);
}
- player = dynamic_cast<Player*>(dstBeing);
+ if (dstBeing->getType() == Being::PLAYER)
+ player = static_cast<Player*>(dstBeing);
if (Party *party = player_node->getParty()){
if (party->isMember(id))
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index f2f27936..f27318d6 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -251,11 +251,11 @@ void PartyHandler::handleMessage(Net::MessageIn &msg)
{
partyTab->chatLog(strprintf(_("%s has left your party."),
nick.c_str()), BY_SERVER);
- Player *p = dynamic_cast<Player*>(beingManager->findBeing(id));
- if (p)
- {
- p->setParty(NULL);
- }
+
+ Being *b = beingManager->findBeing(id);
+ if (b->getType() == Being::PLAYER)
+ static_cast<Player*>(b)->setParty(NULL);
+
eaParty->removeMember(id);
}
break;
diff --git a/src/party.cpp b/src/party.cpp
index e01aab50..b47c194a 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -172,11 +172,9 @@ void Party::removeFromMembers()
itr_end = mMembers.end();
while(itr != itr_end)
{
- Player *p = dynamic_cast<Player*>(beingManager->findBeing((*itr)->getID()));
- if (p)
- {
- p->setParty(NULL);
- }
+ Being *b = beingManager->findBeing((*itr)->getID());
+ if (b->getType() == Being::PLAYER)
+ static_cast<Player*>(b)->setParty(NULL);
++itr;
}
}
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 95463192..113ce224 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -221,10 +221,9 @@ bool PlayerRelationsManager::hasPermission(const std::string &name,
// execute `ignore' strategy, if possible
if (mIgnoreStrategy)
{
- Player *to_ignore = dynamic_cast<Player *>(beingManager->findBeingByName(name, Being::PLAYER));
-
- if (to_ignore)
- mIgnoreStrategy->ignore(to_ignore, rejections);
+ Being *b = beingManager->findBeingByName(name, Being::PLAYER);
+ if (b->getType() == Being::PLAYER)
+ mIgnoreStrategy->ignore(static_cast<Player *>(b), rejections);
}
}