summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-11-11 21:55:25 -0500
committerChuck Miller <shadowmil@gmail.com>2010-11-11 22:45:58 -0500
commit5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e (patch)
tree994cdeb1187a94996ca38c5e274aabaa5f1fec76 /src/net
parent3dd1baab3fb00a3aa99447430f16a431a205c614 (diff)
downloadmana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.gz
mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.bz2
mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.tar.xz
mana-5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e.zip
Have the event system channels use enums instead of strings
Reviewed-by: Freeyorp
Diffstat (limited to 'src/net')
-rw-r--r--src/net/manaserv/chathandler.cpp6
-rw-r--r--src/net/manaserv/generalhandler.cpp10
-rw-r--r--src/net/manaserv/generalhandler.h2
-rw-r--r--src/net/manaserv/inventoryhandler.cpp6
-rw-r--r--src/net/manaserv/inventoryhandler.h2
-rw-r--r--src/net/manaserv/npchandler.cpp22
-rw-r--r--src/net/manaserv/npchandler.h2
-rw-r--r--src/net/manaserv/playerhandler.cpp2
-rw-r--r--src/net/tmwa/chathandler.cpp12
-rw-r--r--src/net/tmwa/gamehandler.cpp6
-rw-r--r--src/net/tmwa/gamehandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp6
-rw-r--r--src/net/tmwa/generalhandler.h2
-rw-r--r--src/net/tmwa/inventoryhandler.cpp6
-rw-r--r--src/net/tmwa/inventoryhandler.h2
-rw-r--r--src/net/tmwa/npchandler.cpp18
-rw-r--r--src/net/tmwa/npchandler.h2
-rw-r--r--src/net/tmwa/playerhandler.cpp2
18 files changed, 55 insertions, 55 deletions
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 147bab0a..70910cf6 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -171,7 +171,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations
.checkPermissionSilently(being->getName(),
PlayerRelation::SPEECH_LOG | PlayerRelation::SPEECH_FLOAT));
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
@@ -234,7 +234,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
Mana::Event event("Whisper");
event.setString("nick", userNick);
event.setString("message", chatMsg);
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
@@ -242,7 +242,7 @@ void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
std::string chatMsg = msg.readString();
Mana::Event event("Announcement");
event.setString("message", chatMsg);
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
void ChatHandler::handleChatMessage(Net::MessageIn &msg)
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 7bff8a30..178e0c48 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -91,8 +91,8 @@ GeneralHandler::GeneralHandler():
generalHandler = this;
- listen("Client");
- listen("Game");
+ listen(CHANNEL_CLIENT);
+ listen(CHANNEL_GAME);
}
void GeneralHandler::load()
@@ -171,10 +171,10 @@ void GeneralHandler::clearHandlers()
clearNetworkHandlers();
}
-void GeneralHandler::event(const std::string &channel,
+void GeneralHandler::event(Channels channel,
const Mana::Event &event)
{
- if (channel == "Client")
+ if (channel == CHANNEL_CLIENT)
{
if (event.getName() == "StateChange")
{
@@ -192,7 +192,7 @@ void GeneralHandler::event(const std::string &channel,
Attributes::informItemDB();
}
}
- else if (channel == "Game")
+ else if (channel == CHANNEL_GAME)
{
if (event.getName() == "GuiWindowsLoaded")
{
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index 2a203e8c..c8671ec1 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -46,7 +46,7 @@ class GeneralHandler : public Net::GeneralHandler, public Mana::Listener
void clearHandlers();
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
protected:
MessageHandlerPtr mBeingHandler;
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index da1abab5..45ab1ebd 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -52,7 +52,7 @@ InventoryHandler::InventoryHandler()
handledMessages = _messages;
inventoryHandler = this;
- listen("Item");
+ listen(CHANNEL_ITEM);
}
void InventoryHandler::handleMessage(Net::MessageIn &msg)
@@ -108,10 +108,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void InventoryHandler::event(const std::string &channel,
+void InventoryHandler::event(Channels channel,
const Mana::Event &event)
{
- if (channel == "Item")
+ if (channel == CHANNEL_ITEM)
{
Item *item = event.getItem("item");
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index aa44f2ee..bb68ceeb 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -66,7 +66,7 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler,
void handleMessage(Net::MessageIn &msg);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
bool canSplit(const Item *item);
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index f7e04c1b..64162cc5 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -52,7 +52,7 @@ NpcHandler::NpcHandler()
handledMessages = _messages;
npcHandler = this;
- listen("NPC");
+ listen(CHANNEL_NPC);
}
void NpcHandler::handleMessage(Net::MessageIn &msg)
@@ -77,7 +77,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event->setString("choice" + toString(count), msg.readString());
}
event->setInt("choiceCount", count);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_NUMBER:
@@ -86,52 +86,52 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event->setInt("min", msg.readInt32());
event->setInt("max", msg.readInt32());
event->setInt("default", msg.readInt32());
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_STRING:
event = new Mana::Event("StringInput");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_POST:
event = new Mana::Event("Post");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_ERROR:
event = new Mana::Event("End");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_MESSAGE:
event = new Mana::Event("Message");
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getUnreadLength()));
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
delete event;
event = new Mana::Event("Next");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_CLOSE:
event = new Mana::Event("Close");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
}
delete event;
}
-void NpcHandler::event(const std::string &channel, const Mana::Event &event)
+void NpcHandler::event(Channels channel, const Mana::Event &event)
{
- if (channel == "NPC")
+ if (channel == CHANNEL_NPC)
{
if (event.getName() == "doTalk")
{
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index 14e8a50a..397d3569 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -40,7 +40,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler,
void handleMessage(Net::MessageIn &msg);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
void startShopping(int beingId);
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index a579517f..d9bfb2b6 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -65,7 +65,7 @@ void RespawnRequestListener::action(const gcn::ActionEvent &event)
{
Net::getPlayerHandler()->respawn();
- Mana::Event::trigger("NPC", "CloseAll");
+ Mana::Event::trigger(CHANNEL_NPC, "CloseAll");
}
PlayerHandler::PlayerHandler()
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 2b647f68..9529a386 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -86,7 +86,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, %s is offline."), nick.c_str()));
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
break;
case 0x02:
@@ -95,7 +95,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, ignored by %s."), nick.c_str()));
- event.Event::trigger("Chat");
+ event.Event::trigger(CHANNEL_CHAT);
}
break;
}
@@ -118,7 +118,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
Mana::Event event("Whisper");
event.setString("nick", nick);
event.setString("message", chatMsg);
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
}
else
@@ -180,7 +180,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setString("nick", sender_name);
event.setInt("beingId", beingId);
event.setInt("permissions", perms);
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
break;
}
@@ -213,13 +213,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
event.setInt("permissions", player_relations.getDefault()
& (PlayerRelation::SPEECH_LOG
| PlayerRelation::SPEECH_FLOAT));
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
else
{
Mana::Event event("Announcement");
event.setString("message", chatMsg);
- event.trigger("Chat");
+ event.trigger(CHANNEL_CHAT);
}
break;
}
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 334a2e37..d98daa64 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -58,7 +58,7 @@ GameHandler::GameHandler()
handledMessages = _messages;
gameHandler = this;
- listen("Game");
+ listen(CHANNEL_GAME);
}
void GameHandler::handleMessage(Net::MessageIn &msg)
@@ -105,9 +105,9 @@ void GameHandler::handleMessage(Net::MessageIn &msg)
}
}
-void GameHandler::event(const std::string &channel, const Mana::Event &event)
+void GameHandler::event(Channels channel, const Mana::Event &event)
{
- if (channel == "Game")
+ if (channel == CHANNEL_GAME)
{
if (event.getName() == "EnginesInitalized")
{
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index 6bdcbaef..18317445 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -41,7 +41,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler,
void handleMessage(Net::MessageIn &msg);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
void connect();
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 79362a6d..f9ed97b0 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -108,7 +108,7 @@ GeneralHandler::GeneralHandler():
itemDb->setStatsList(stats);
- listen("Game");
+ listen(CHANNEL_GAME);
}
GeneralHandler::~GeneralHandler()
@@ -217,10 +217,10 @@ void GeneralHandler::clearHandlers()
mNetwork->clearHandlers();
}
-void GeneralHandler::event(const std::string &channel,
+void GeneralHandler::event(Channels channel,
const Mana::Event &event)
{
- if (channel == "Game")
+ if (channel == CHANNEL_GAME)
{
if (event.getName() == "GuiWindowsLoaded")
{
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index f7f78759..722c3215 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -51,7 +51,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
void clearHandlers();
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
protected:
MessageHandlerPtr mAdminHandler;
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 9fac8e8c..ae79ab09 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -110,7 +110,7 @@ InventoryHandler::InventoryHandler()
mStorage = 0;
mStorageWindow = 0;
- listen("Item");
+ listen(CHANNEL_ITEM);
}
InventoryHandler::~InventoryHandler()
@@ -430,10 +430,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
}
}
-void InventoryHandler::event(const std::string &channel,
+void InventoryHandler::event(Channels channel,
const Mana::Event &event)
{
- if (channel == "Item")
+ if (channel == CHANNEL_ITEM)
{
if (event.getName() == "doCloseInventory")
{
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 79d3bc65..dfbefaa8 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -133,7 +133,7 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
void handleMessage(Net::MessageIn &msg);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
bool canSplit(const Item *item);
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index e1615fec..1f85e9a6 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -69,7 +69,7 @@ NpcHandler::NpcHandler()
handledMessages = _messages;
npcHandler = this;
- listen("NPC");
+ listen(CHANNEL_NPC);
}
void NpcHandler::handleMessage(Net::MessageIn &msg)
@@ -88,42 +88,42 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
event = new Mana::Event("Menu");
event->setInt("id", npcId);
parseMenu(event, msg.readString(msg.getLength() - 8));
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_MESSAGE:
event = new Mana::Event("Message");
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getLength() - 8));
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_CLOSE:
// Show the close button
event = new Mana::Event("Close");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_NEXT:
// Show the next button
event = new Mana::Event("Next");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_INT_INPUT:
// Request for an integer
event = new Mana::Event("IntegerInput");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
event = new Mana::Event("StringInput");
event->setInt("id", npcId);
- event->trigger("NPC");
+ event->trigger(CHANNEL_NPC);
break;
}
@@ -133,9 +133,9 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
player_node->setAction(Being::STAND);
}
-void NpcHandler::event(const std::string &channel, const Mana::Event &event)
+void NpcHandler::event(Channels channel, const Mana::Event &event)
{
- if (channel == "NPC")
+ if (channel == CHANNEL_NPC)
{
if (event.getName() == "doTalk")
{
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 93c9f6ec..9fcb0041 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -40,7 +40,7 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler,
void handleMessage(Net::MessageIn &msg);
- void event(const std::string &channel, const Mana::Event &event);
+ void event(Channels channel, const Mana::Event &event);
void startShopping(int beingId);
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index 970d1ecd..eeba7ae7 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -81,7 +81,7 @@ namespace {
viewport->closePopupMenu();
- Mana::Event::trigger("NPC", "CloseAll");
+ Mana::Event::trigger(CHANNEL_NPC, "CloseAll");
}
} deathListener;