summaryrefslogtreecommitdiff
path: root/src/net/manaserv
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2010-11-11 23:12:29 -0500
committerChuck Miller <shadowmil@gmail.com>2010-11-11 23:12:29 -0500
commita4640305fd0d88c6332112712aa69e496368e01b (patch)
tree0f039b331026ca2b9718a920b24e2344f9e56b25 /src/net/manaserv
parent5727a2d9eeb0688a16e5b7fe32f6d9836c4f7a4e (diff)
downloadmana-a4640305fd0d88c6332112712aa69e496368e01b.tar.gz
mana-a4640305fd0d88c6332112712aa69e496368e01b.tar.bz2
mana-a4640305fd0d88c6332112712aa69e496368e01b.tar.xz
mana-a4640305fd0d88c6332112712aa69e496368e01b.zip
Replace Event names with enums instead of strings
Diffstat (limited to 'src/net/manaserv')
-rw-r--r--src/net/manaserv/chathandler.cpp6
-rw-r--r--src/net/manaserv/generalhandler.cpp6
-rw-r--r--src/net/manaserv/inventoryhandler.cpp12
-rw-r--r--src/net/manaserv/npchandler.cpp29
-rw-r--r--src/net/manaserv/playerhandler.cpp2
5 files changed, 28 insertions, 27 deletions
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index 70910cf6..db0e1084 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -163,7 +163,7 @@ void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
else
mes = "Unknown : " + chatMsg;
- Mana::Event event(being == player_node ? "Player" : "Being");
+ Mana::Event event(being == player_node ? EVENT_PLAYER : EVENT_BEING);
event.setString("message", mes);
event.setString("text", chatMsg);
event.setString("nick", being->getName());
@@ -231,7 +231,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
- Mana::Event event("Whisper");
+ Mana::Event event(EVENT_WHISPER);
event.setString("nick", userNick);
event.setString("message", chatMsg);
event.trigger(CHANNEL_CHAT);
@@ -240,7 +240,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
void ChatHandler::handleAnnouncement(Net::MessageIn &msg)
{
std::string chatMsg = msg.readString();
- Mana::Event event("Announcement");
+ Mana::Event event(EVENT_ANNOUNCEMENT);
event.setString("message", chatMsg);
event.trigger(CHANNEL_CHAT);
}
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 178e0c48..d2151307 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -176,7 +176,7 @@ void GeneralHandler::event(Channels channel,
{
if (channel == CHANNEL_CLIENT)
{
- if (event.getName() == "StateChange")
+ if (event.getName() == EVENT_STATECHANGE)
{
int newState = event.getInt("newState");
@@ -186,7 +186,7 @@ void GeneralHandler::event(Channels channel,
game->gameLoading();
}
}
- else if (event.getName() == "DBsLoading")
+ else if (event.getName() == EVENT_DBSLOADING)
{
Attributes::load();
Attributes::informItemDB();
@@ -194,7 +194,7 @@ void GeneralHandler::event(Channels channel,
}
else if (channel == CHANNEL_GAME)
{
- if (event.getName() == "GuiWindowsLoaded")
+ if (event.getName() == EVENT_GUIWINDOWSLOADED)
{
inventoryWindow->setSplitAllowed(true);
skillDialog->loadSkills("mana-skills.xml");
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 45ab1ebd..9d2fdfeb 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -120,13 +120,13 @@ void InventoryHandler::event(Channels channel,
int index = item->getInvIndex();
- if (event.getName() == "doEquip")
+ if (event.getName() == EVENT_DOEQUIP)
{
MessageOut msg(PGMSG_EQUIP);
msg.writeInt8(index);
gameServerConnection->send(msg);
}
- else if (event.getName() == "doUnequip")
+ else if (event.getName() == EVENT_DOUNEQUIP)
{
MessageOut msg(PGMSG_UNEQUIP);
msg.writeInt8(index);
@@ -136,13 +136,13 @@ void InventoryHandler::event(Channels channel,
// for instance.
mEquips.setEquipment(index, 0, 0);
}
- else if (event.getName() == "doUse")
+ else if (event.getName() == EVENT_DOUSE)
{
MessageOut msg(PGMSG_USE_ITEM);
msg.writeInt8(index);
gameServerConnection->send(msg);
}
- else if (event.getName() == "doDrop")
+ else if (event.getName() == EVENT_DODROP)
{
int amount = event.getInt("amount", 1);
@@ -151,7 +151,7 @@ void InventoryHandler::event(Channels channel,
msg.writeInt8(amount);
gameServerConnection->send(msg);
}
- else if (event.getName() == "doSplit")
+ else if (event.getName() == EVENT_DOSPLIT)
{
int amount = event.getInt("amount", 1);
@@ -165,7 +165,7 @@ void InventoryHandler::event(Channels channel,
gameServerConnection->send(msg);
}
}
- else if (event.getName() == "doMove")
+ else if (event.getName() == EVENT_DOMOVE)
{
int newIndex = event.getInt("newIndex", -1);
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 64162cc5..403dedb6 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -69,7 +69,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case GPMSG_NPC_CHOICE:
- event = new Mana::Event("Menu");
+ event = new Mana::Event(EVENT_MENU);
event->setInt("id", npcId);
while (msg.getUnreadLength())
{
@@ -81,7 +81,7 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
break;
case GPMSG_NPC_NUMBER:
- event = new Mana::Event("IntegerInput");
+ event = new Mana::Event(EVENT_INTEGERINPUT);
event->setInt("id", npcId);
event->setInt("min", msg.readInt32());
event->setInt("max", msg.readInt32());
@@ -90,37 +90,37 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
break;
case GPMSG_NPC_STRING:
- event = new Mana::Event("StringInput");
+ event = new Mana::Event(EVENT_STRINGINPUT);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_POST:
- event = new Mana::Event("Post");
+ event = new Mana::Event(EVENT_POST);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_ERROR:
- event = new Mana::Event("End");
+ event = new Mana::Event(EVENT_END);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_MESSAGE:
- event = new Mana::Event("Message");
+ event = new Mana::Event(EVENT_MESSAGE);
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getUnreadLength()));
event->trigger(CHANNEL_NPC);
delete event;
- event = new Mana::Event("Next");
+ event = new Mana::Event(EVENT_NEXT);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case GPMSG_NPC_CLOSE:
- event = new Mana::Event("Close");
+ event = new Mana::Event(EVENT_CLOSE);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
@@ -133,40 +133,41 @@ void NpcHandler::event(Channels channel, const Mana::Event &event)
{
if (channel == CHANNEL_NPC)
{
- if (event.getName() == "doTalk")
+ if (event.getName() == EVENT_DOTALK)
{
MessageOut msg(PGMSG_NPC_TALK);
msg.writeInt16(event.getInt("npcId"));
gameServerConnection->send(msg);
}
- else if (event.getName() == "doNext" || event.getName() == "doClose")
+ else if (event.getName() == EVENT_DONEXT ||
+ event.getName() == EVENT_DOCLOSE)
{
MessageOut msg(PGMSG_NPC_TALK_NEXT);
msg.writeInt16(event.getInt("npcId"));
gameServerConnection->send(msg);
}
- else if (event.getName() == "doMenu")
+ else if (event.getName() == EVENT_DOMENU)
{
MessageOut msg(PGMSG_NPC_SELECT);
msg.writeInt16(event.getInt("npcId"));
msg.writeInt8(event.getInt("choice"));
gameServerConnection->send(msg);
}
- else if (event.getName() == "doIntegerInput")
+ else if (event.getName() == EVENT_DOINTEGERINPUT)
{
MessageOut msg(PGMSG_NPC_NUMBER);
msg.writeInt16(event.getInt("npcId"));
msg.writeInt32(event.getInt("value"));
gameServerConnection->send(msg);
}
- else if (event.getName() == "doStringInput")
+ else if (event.getName() == EVENT_DOSTRINGINPUT)
{
MessageOut msg(PGMSG_NPC_STRING);
msg.writeInt16(event.getInt("npcId"));
msg.writeString(event.getString("value"));
gameServerConnection->send(msg);
}
- else if (event.getName() == "doSendLetter")
+ else if (event.getName() == EVENT_DOSENDLETTER)
{
MessageOut msg(PGMSG_NPC_POST_SEND);
msg.writeString(event.getString("recipient"));
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index d9bfb2b6..be09ff69 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(CHANNEL_NPC, "CloseAll");
+ Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL);
}
PlayerHandler::PlayerHandler()