ManaPlus
Functions
Ea::TradeRecv Namespace Reference

Functions

void processTradeOk (Net::MessageIn &msg)
 
void processTradeCancel (Net::MessageIn &msg)
 
void processTradeComplete (Net::MessageIn &msg)
 
void processTradeRequestContinue (const std::string &partner)
 
void processTradeResponseContinue (const uint8_t type)
 

Function Documentation

◆ processTradeCancel()

void Ea::TradeRecv::processTradeCancel ( Net::MessageIn msg)

Definition at line 126 of file traderecv.cpp.

127 {
129  if (tradeWindow != nullptr)
130  {
132  tradeWindow->reset();
133  }
135 }
virtual void setVisible(Visible visible)
Definition: window.cpp:778
void notify(const unsigned int message)
void setTrading(const Trading trading)
Definition: playerinfo.cpp:396
TradeWindow * tradeWindow
Definition: tradewindow.cpp:65
const bool Trading_false
Definition: trading.h:30
const bool Visible_false
Definition: visible.h:30

References NotifyManager::notify(), TradeWindow::reset(), PlayerInfo::setTrading(), Window::setVisible(), NotifyTypes::TRADE_CANCELLED, tradeWindow, Trading_false, and Visible_false.

◆ processTradeComplete()

void Ea::TradeRecv::processTradeComplete ( Net::MessageIn msg)

◆ processTradeOk()

void Ea::TradeRecv::processTradeOk ( Net::MessageIn msg)

Definition at line 117 of file traderecv.cpp.

118 {
119  // 0 means ok from myself, 1 means ok from other;
120  if (tradeWindow != nullptr)
121  tradeWindow->receivedOk(msg.readUInt8("status") == 0U);
122  else
123  msg.readUInt8("status");
124 }
void receivedOk(const bool own)
bool msg(InputEvent &event)
Definition: chat.cpp:39

References Actions::msg(), TradeWindow::receivedOk(), and tradeWindow.

◆ processTradeRequestContinue()

void Ea::TradeRecv::processTradeRequestContinue ( const std::string &  partner)

Definition at line 145 of file traderecv.cpp.

146 {
147  if (playerRelations.hasPermission(partner,
149  {
150  if (PlayerInfo::isTrading() == Trading_true || (confirmDlg != nullptr))
151  {
152  tradeHandler->respond(false);
153  return;
154  }
155 
156  tradePartnerName = partner;
158  if (tradeWindow != nullptr)
159  {
161  != tradePartnerName)
162  {
163  tradeWindow->clear();
165  // TRANSLATORS: trade message
166  _("Request for Trade"),
167  // TRANSLATORS: trade message
168  strprintf(_("%s wants to trade with you, do"
169  " you accept?"), tradePartnerName.c_str()),
171  true,
172  Modal_false,
173  nullptr);
175  }
176  else
177  {
178  tradeHandler->respond(true);
179  }
180  }
181  }
182  else
183  {
184  tradeHandler->respond(false);
185  return;
186  }
187 }
virtual void respond(const bool accept) const
Definition: tradehandler.h:49
bool hasPermission(const Being *const being, const unsigned int flags) const
std::string getAutoTradeNick() const
Definition: tradewindow.h:167
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
#define CREATEWIDGETV(var, type,...)
Definition: createwidget.h:25
ConfirmDialog * confirmDlg
Definition: traderecv.cpp:49
#define _(s)
Definition: gettext.h:35
const bool Modal_false
Definition: modal.h:30
Trading isTrading()
Definition: playerinfo.cpp:391
RequestTradeListener listener
Definition: traderecv.cpp:56
Net::TradeHandler * tradeHandler
Definition: net.cpp:98
PlayerRelationsManager playerRelations
static const std::string SOUND_REQUEST
Definition: sound.h:29
std::string strprintf(const char *const format,...)
static const unsigned int TRADE
std::string tradePartnerName
Definition: popupmenu.cpp:101
const bool Trading_true
Definition: trading.h:30

References _, Widget::addActionListener(), TradeWindow::clear(), confirmDlg, CREATEWIDGETV, TradeWindow::getAutoTradeNick(), PlayerRelationsManager::hasPermission(), PlayerInfo::isTrading(), anonymous_namespace{traderecv.cpp}::listener, Modal_false, playerRelations, Net::TradeHandler::respond(), PlayerInfo::setTrading(), SOUND_REQUEST, strprintf(), PlayerRelation::TRADE, tradeHandler, tradePartnerName, tradeWindow, and Trading_true.

Referenced by EAthena::TradeRecv::processTradeRequest(), and TmwAthena::TradeRecv::processTradeRequest().

◆ processTradeResponseContinue()

void Ea::TradeRecv::processTradeResponseContinue ( const uint8_t  type)

Definition at line 62 of file traderecv.cpp.

63 {
64  switch (type)
65  {
66  case 0: // Too far away
69  break;
70  case 1: // Character doesn't exist
73  break;
74  case 2: // Invite request check failed...
76  break;
77  case 3: // Trade accepted
78  if (tradeWindow != nullptr)
79  {
80  tradeWindow->reset();
81  // TRANSLATORS: trade header
82  tradeWindow->setCaption(strprintf(_("Trade: You and %s"),
83  tradePartnerName.c_str()));
86  }
87  break;
88  case 4: // Trade cancelled
91  {
94  }
95  // otherwise ignore silently
96 
97  if (tradeWindow != nullptr)
98  {
100 // tradeWindow->clear();
101  }
103  break;
104  case 5:
107  break;
108  default: // Shouldn't happen as well, but to be sure
111  if (tradeWindow != nullptr)
112  tradeWindow->clear();
113  break;
114  }
115 }
void initTrade(const std::string &nick)
void setCaption(const std::string &caption)
Definition: window.h:531
@ TRADE_CANCELLED_NAME
Definition: notifytypes.h:91
@ TRADE_FAIL_CHAR_NOT_EXISTS
Definition: notifytypes.h:89
@ TRADE_FAIL_FAR_AWAY
Definition: notifytypes.h:88
@ TRADE_CANCELLED_BUSY
Definition: notifytypes.h:92
@ TRADE_ERROR_UNKNOWN
Definition: notifytypes.h:93
@ TRADE_CANCELLED_ERROR
Definition: notifytypes.h:90
static const unsigned int SPEECH_LOG
const bool Visible_true
Definition: visible.h:30

References _, TradeWindow::clear(), PlayerRelationsManager::hasPermission(), TradeWindow::initTrade(), NotifyManager::notify(), playerRelations, TradeWindow::reset(), Window::setCaption(), PlayerInfo::setTrading(), Window::setVisible(), PlayerRelation::SPEECH_LOG, strprintf(), NotifyTypes::TRADE_CANCELLED_BUSY, NotifyTypes::TRADE_CANCELLED_ERROR, NotifyTypes::TRADE_CANCELLED_NAME, NotifyTypes::TRADE_ERROR_UNKNOWN, NotifyTypes::TRADE_FAIL_CHAR_NOT_EXISTS, NotifyTypes::TRADE_FAIL_FAR_AWAY, tradePartnerName, tradeWindow, Trading_false, Visible_false, and Visible_true.

Referenced by EAthena::TradeRecv::processTradeResponse(), and TmwAthena::TradeRecv::processTradeResponse().