summaryrefslogtreecommitdiff
path: root/src/net
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
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')
-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
-rw-r--r--src/net/tmwa/chathandler.cpp12
-rw-r--r--src/net/tmwa/gamehandler.cpp4
-rw-r--r--src/net/tmwa/generalhandler.cpp4
-rw-r--r--src/net/tmwa/inventoryhandler.cpp12
-rw-r--r--src/net/tmwa/npchandler.cpp24
-rw-r--r--src/net/tmwa/playerhandler.cpp2
-rw-r--r--src/net/tmwa/tradehandler.cpp2
12 files changed, 58 insertions, 57 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()
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 9529a386..33826762 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -82,7 +82,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
break;
case 0x01:
{
- Mana::Event event("WhisperError");
+ Mana::Event event(EVENT_WHISPERERROR);
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, %s is offline."), nick.c_str()));
@@ -91,7 +91,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
break;
case 0x02:
{
- Mana::Event event("WhisperError");
+ Mana::Event event(EVENT_WHISPERERROR);
event.setString("nick", nick);
event.setString("error", strprintf(_("Whisper could "
"not be sent, ignored by %s."), nick.c_str()));
@@ -115,7 +115,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
{
if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
{
- Mana::Event event("Whisper");
+ Mana::Event event(EVENT_WHISPER);
event.setString("nick", nick);
event.setString("message", chatMsg);
event.trigger(CHANNEL_CHAT);
@@ -174,7 +174,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
std::string reducedMessage = chatMsg;
chatMsg = removeColors(sender_name) + " : " + reducedMessage;
- Mana::Event event("Being");
+ Mana::Event event(EVENT_BEING);
event.setString("message", chatMsg);
event.setString("text", reducedMessage);
event.setString("nick", sender_name);
@@ -205,7 +205,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
trim(chatMsg);
- Mana::Event event("Player");
+ Mana::Event event(EVENT_PLAYER);
event.setString("message", mes);
event.setString("text", chatMsg);
event.setString("nick", player_node->getName());
@@ -217,7 +217,7 @@ void ChatHandler::handleMessage(Net::MessageIn &msg)
}
else
{
- Mana::Event event("Announcement");
+ Mana::Event event(EVENT_ANNOUNCEMENT);
event.setString("message", chatMsg);
event.trigger(CHANNEL_CHAT);
}
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index d98daa64..63f5fcec 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -109,11 +109,11 @@ void GameHandler::event(Channels channel, const Mana::Event &event)
{
if (channel == CHANNEL_GAME)
{
- if (event.getName() == "EnginesInitalized")
+ if (event.getName() == EVENT_ENGINESINITALIZED)
{
Game::instance()->changeMap(mMap);
}
- else if (event.getName() == "MapLoaded")
+ else if (event.getName() == EVENT_MAPLOADED)
{
MessageOut outMsg(CMSG_MAP_LOADED);
}
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index f9ed97b0..b4327d47 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -222,7 +222,7 @@ void GeneralHandler::event(Channels channel,
{
if (channel == CHANNEL_GAME)
{
- if (event.getName() == "GuiWindowsLoaded")
+ if (event.getName() == EVENT_GUIWINDOWSLOADED)
{
inventoryWindow->setSplitAllowed(false);
skillDialog->loadSkills("ea-skills.xml");
@@ -242,7 +242,7 @@ void GeneralHandler::event(Channels channel,
statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
}
- else if (event.getName() == "GuiWindowsUnloading")
+ else if (event.getName() == EVENT_GUIWINDOWSUNLOADING)
{
socialWindow->removeTab(taGuild);
socialWindow->removeTab(taParty);
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index ae79ab09..3a0a93e3 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -435,7 +435,7 @@ void InventoryHandler::event(Channels channel,
{
if (channel == CHANNEL_ITEM)
{
- if (event.getName() == "doCloseInventory")
+ if (event.getName() == EVENT_DOCLOSEINVENTORY)
{
// No need to worry about type
MessageOut outMsg(CMSG_CLOSE_STORAGE);
@@ -449,24 +449,24 @@ void InventoryHandler::event(Channels channel,
int index = item->getInvIndex() + INVENTORY_OFFSET;
- if (event.getName() == "doEquip")
+ if (event.getName() == EVENT_DOEQUIP)
{
MessageOut outMsg(CMSG_PLAYER_EQUIP);
outMsg.writeInt16(index);
outMsg.writeInt16(0);
}
- else if (event.getName() == "doUnequip")
+ else if (event.getName() == EVENT_DOUNEQUIP)
{
MessageOut outMsg(CMSG_PLAYER_UNEQUIP);
outMsg.writeInt16(index);
}
- else if (event.getName() == "doUse")
+ else if (event.getName() == EVENT_DOUSE)
{
MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE);
outMsg.writeInt16(index);
outMsg.writeInt32(item->getId()); // unused
}
- else if (event.getName() == "doDrop")
+ else if (event.getName() == EVENT_DODROP)
{
int amount = event.getInt("amount", 1);
@@ -476,7 +476,7 @@ void InventoryHandler::event(Channels channel,
outMsg.writeInt16(index);
outMsg.writeInt16(amount);
}
- else if (event.getName() == "doMove")
+ else if (event.getName() == EVENT_DOMOVE)
{
int newIndex = event.getInt("newIndex", -1);
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 1f85e9a6..1b12b63f 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -85,14 +85,14 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_NPC_CHOICE:
- event = new Mana::Event("Menu");
+ event = new Mana::Event(EVENT_MENU);
event->setInt("id", npcId);
parseMenu(event, msg.readString(msg.getLength() - 8));
event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_MESSAGE:
- event = new Mana::Event("Message");
+ event = new Mana::Event(EVENT_MESSAGE);
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getLength() - 8));
event->trigger(CHANNEL_NPC);
@@ -100,28 +100,28 @@ void NpcHandler::handleMessage(Net::MessageIn &msg)
case SMSG_NPC_CLOSE:
// Show the close button
- event = new Mana::Event("Close");
+ event = new Mana::Event(EVENT_CLOSE);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_NEXT:
// Show the next button
- event = new Mana::Event("Next");
+ event = new Mana::Event(EVENT_NEXT);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_INT_INPUT:
// Request for an integer
- event = new Mana::Event("IntegerInput");
+ event = new Mana::Event(EVENT_INTEGERINPUT);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
- event = new Mana::Event("StringInput");
+ event = new Mana::Event(EVENT_STRINGINPUT);
event->setInt("id", npcId);
event->trigger(CHANNEL_NPC);
break;
@@ -137,35 +137,35 @@ void NpcHandler::event(Channels channel, const Mana::Event &event)
{
if (channel == CHANNEL_NPC)
{
- if (event.getName() == "doTalk")
+ if (event.getName() == EVENT_DOTALK)
{
MessageOut outMsg(CMSG_NPC_TALK);
outMsg.writeInt32(event.getInt("npcId"));
outMsg.writeInt8(0); // Unused
}
- else if (event.getName() == "doNext")
+ else if (event.getName() == EVENT_DONEXT)
{
MessageOut outMsg(CMSG_NPC_NEXT_REQUEST);
outMsg.writeInt32(event.getInt("npcId"));
}
- else if (event.getName() == "doClose")
+ else if (event.getName() == EVENT_DOCLOSE)
{
MessageOut outMsg(CMSG_NPC_CLOSE);
outMsg.writeInt32(event.getInt("npcId"));
}
- else if (event.getName() == "doMenu")
+ else if (event.getName() == EVENT_DOMENU)
{
MessageOut outMsg(CMSG_NPC_LIST_CHOICE);
outMsg.writeInt32(event.getInt("npcId"));
outMsg.writeInt8(event.getInt("choice"));
}
- else if (event.getName() == "doIntegerInput")
+ else if (event.getName() == EVENT_DOINTEGERINPUT)
{
MessageOut outMsg(CMSG_NPC_INT_RESPONSE);
outMsg.writeInt32(event.getInt("npcId"));
outMsg.writeInt32(event.getInt("value"));
}
- else if (event.getName() == "doStringInput")
+ else if (event.getName() == EVENT_DOSTRINGINPUT)
{
const std::string &value = event.getString("value");
MessageOut outMsg(CMSG_NPC_STR_RESPONSE);
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index eeba7ae7..b82968a3 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -81,7 +81,7 @@ namespace {
viewport->closePopupMenu();
- Mana::Event::trigger(CHANNEL_NPC, "CloseAll");
+ Mana::Event::trigger(CHANNEL_NPC, EVENT_CLOSEALL);
}
} deathListener;
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index c8615485..034b959d 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -191,7 +191,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
// Successfully added item
if (item->isEquippable() && item->isEquipped())
{
- item->doEvent("doUnequip");
+ item->doEvent(EVENT_DOUNEQUIP);
}
tradeWindow->addItem(item->getId(), true, quantity);