summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-09 15:32:04 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-09 15:32:04 +0300
commitd7e0bbcc76bd6548975dfd30a50910d4967cad55 (patch)
tree4a33874bf1376be8708aaeb3f44cca1cd8279002
parente433cda19d0d1d305a7a069a7930c2c7cf852930 (diff)
downloadplus-d7e0bbcc76bd6548975dfd30a50910d4967cad55.tar.gz
plus-d7e0bbcc76bd6548975dfd30a50910d4967cad55.tar.bz2
plus-d7e0bbcc76bd6548975dfd30a50910d4967cad55.tar.xz
plus-d7e0bbcc76bd6548975dfd30a50910d4967cad55.zip
Add new notifications to tradehandler.
-rw-r--r--src/net/ea/tradehandler.cpp44
-rw-r--r--src/notifications.h57
2 files changed, 61 insertions, 40 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 01bbeb45e..12f29c4e7 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -26,6 +26,7 @@
#include "inventory.h"
#include "item.h"
#include "logger.h"
+#include "notifymanager.h"
#include "playerinfo.h"
#include "playerrelations.h"
@@ -132,15 +133,15 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
switch (msg.readInt8())
{
case 0: // Too far away
- SERVER_NOTICE(strprintf(_("Trading with %s isn't possible."
- " Trade partner is too far away."), tradePartnerName.c_str()))
+ NotifyManager::notify(NotifyManager::TRADE_FAIL_FAR_AWAY,
+ tradePartnerName);
break;
case 1: // Character doesn't exist
- SERVER_NOTICE(strprintf(_("Trading with %s isn't possible."
- " Character doesn't exist."), tradePartnerName.c_str()))
+ NotifyManager::notify(NotifyManager::TRADE_FAIL_CHAR_NOT_EXISTS,
+ tradePartnerName);
break;
case 2: // Invite request check failed...
- SERVER_NOTICE(_("Trade cancelled due to an unknown reason."))
+ NotifyManager::notify(NotifyManager::TRADE_CANCELLED_ERROR);
break;
case 3: // Trade accepted
if (tradeWindow)
@@ -156,8 +157,8 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
if (player_relations.hasPermission(tradePartnerName,
PlayerRelation::SPEECH_LOG))
{
- SERVER_NOTICE(strprintf(_("Trade with %s cancelled."),
- tradePartnerName.c_str()))
+ NotifyManager::notify(NotifyManager::TRADE_CANCELLED_NAME,
+ tradePartnerName);
}
// otherwise ignore silently
@@ -169,8 +170,8 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg)
PlayerInfo::setTrading(false);
break;
default: // Shouldn't happen as well, but to be sure
- SERVER_NOTICE(strprintf(_("Unhandled trade cancel packet with %s"),
- tradePartnerName.c_str()))
+ NotifyManager::notify(NotifyManager::TRADE_ERROR_UNKNOWN,
+ tradePartnerName);
if (tradeWindow)
tradeWindow->clear();
break;
@@ -235,22 +236,19 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
break;
case 1:
// Add item failed - player overweighted
- SERVER_NOTICE(_("Failed adding item. Trade "
- "partner is over weighted."))
+ NotifyManager::notify(NotifyManager::
+ TRADE_ADD_PARTNER_OVER_WEIGHT);
break;
case 2:
- // Add item failed - player has no free slot
- SERVER_NOTICE(_("Failed adding item. Trade "
- "partner has no free slot."))
- break;
+ // Add item failed - player has no free slot
+ NotifyManager::notify(NotifyManager::TRADE_ADD_PARTNER_NO_SLOTS);
+ break;
case 3:
- // Add item failed - non tradable item
- SERVER_NOTICE(_("Failed adding item. You "
- "can't trade this item."))
- break;
+ // Add item failed - non tradable item
+ NotifyManager::notify(NotifyManager::TRADE_ADD_UNTRADABLE_ITEM);
+ break;
default:
- SERVER_NOTICE(_("Failed adding item for "
- "unknown reason."))
+ NotifyManager::notify(NotifyManager::TRADE_ADD_ERROR);
logger->log("QQQ SMSG_TRADE_ITEM_ADD_RESPONSE: "
+ toString(res));
break;
@@ -268,7 +266,7 @@ void TradeHandler::processTradeOk(Net::MessageIn &msg)
void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED)
{
- SERVER_NOTICE(_("Trade canceled."))
+ NotifyManager::notify(NotifyManager::TRADE_CANCELLED);
if (tradeWindow)
{
tradeWindow->setVisible(false);
@@ -279,7 +277,7 @@ void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED)
void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED)
{
- SERVER_NOTICE(_("Trade completed."))
+ NotifyManager::notify(NotifyManager::TRADE_COMPLETE);
if (tradeWindow)
{
tradeWindow->setVisible(false);
diff --git a/src/notifications.h b/src/notifications.h
index f73651a06..41c0734b4 100644
--- a/src/notifications.h
+++ b/src/notifications.h
@@ -25,6 +25,23 @@
namespace NotifyManager
{
+ enum NotifyFlags
+ {
+ EMPTY,
+ INT,
+ STRING,
+ GUILD,
+ GUILD_STRING,
+ PARTY,
+ PARTY_STRING
+ };
+
+ struct NotificationInfo
+ {
+ const char *text;
+ const NotifyFlags flags;
+ };
+
enum NotifyTypes
{
BUY_DONE,
@@ -72,27 +89,21 @@ namespace NotifyManager
MONEY_SPENT,
SKILL_RAISE_ERROR,
ARROWS_EQUIP_NEEDED,
+ TRADE_FAIL_FAR_AWAY,
+ TRADE_FAIL_CHAR_NOT_EXISTS,
+ TRADE_CANCELLED_ERROR,
+ TRADE_CANCELLED_NAME,
+ TRADE_ERROR_UNKNOWN,
+ TRADE_ADD_PARTNER_OVER_WEIGHT,
+ TRADE_ADD_PARTNER_NO_SLOTS,
+ TRADE_ADD_UNTRADABLE_ITEM,
+ TRADE_ADD_ERROR,
+ TRADE_CANCELLED,
+ TRADE_COMPLETE,
TYPE_END
};
- enum NotifyFlags
- {
- EMPTY,
- INT,
- STRING,
- GUILD,
- GUILD_STRING,
- PARTY,
- PARTY_STRING
- };
-
- struct NotificationInfo
- {
- const char *text;
- const NotifyFlags flags;
- };
-
static const NotificationInfo notifications[] =
{
{N_("Thanks for buying."), EMPTY},
@@ -140,6 +151,18 @@ namespace NotifyManager
{N_("You spent %s."), STRING},
{N_("Cannot raise skill!"), EMPTY},
{N_("Equip arrows first."), EMPTY},
+ {N_("Trading with %s isn't possible. Trade partner is too far away."),
+ STRING},
+ {N_("Trading with %s isn't possible. Character doesn't exist."), STRING},
+ {N_("Trade cancelled due to an unknown reason."), EMPTY},
+ {N_("Trade with %s cancelled."), STRING},
+ {N_("Unhandled trade cancel packet with %s"), STRING},
+ {N_("Failed adding item. Trade partner is over weighted."), EMPTY},
+ {N_("Failed adding item. Trade partner has no free slot."), EMPTY},
+ {N_("Failed adding item. You can't trade this item."), EMPTY},
+ {N_("Failed adding item for unknown reason."), EMPTY},
+ {N_("Trade canceled."), EMPTY},
+ {N_("Trade completed."), EMPTY},
};
}
#endif