ManaPlus
playerinfo.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2010 The Mana Developers
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "being/playerinfo.h"
24 
25 #include "configuration.h"
26 #include "itemsoundmanager.h"
27 #include "settings.h"
28 
29 #include "being/localplayer.h"
30 
31 #include "being/homunculusinfo.h"
32 #include "being/mercenaryinfo.h"
33 #include "being/petinfo.h"
34 
36 #include "gui/windows/npcdialog.h"
37 
38 #include "listeners/statlistener.h"
39 
40 #include "net/homunculushandler.h"
41 #include "net/inventoryhandler.h"
42 #include "net/mercenaryhandler.h"
43 #include "net/playerhandler.h"
44 
45 #include "resources/item/item.h"
46 
47 #include "utils/delete2.h"
48 
50 
51 #include "debug.h"
52 
53 namespace PlayerInfo
54 {
55 
57 int mCharId = 0;
58 
59 Inventory *mInventory = nullptr;
63 PetInfo *mPet = nullptr;
64 std::string mRoomName;
65 Equipment *mEquipment = nullptr;
69 
71 bool mVending = false;
73 int mServerLanguage = -1;
74 std::set<int> mProtectedItems;
75 
76 // --- Triggers ---------------------------------------------------------------
77 
78 void triggerAttr(const AttributesT id,
79  const int64_t old)
80 {
82  mData.mAttributes.find(id)->second);
83 }
84 
85 void triggerStat(const AttributesT id,
86  const int old1,
87  const int old2)
88 {
89  StatListener::distributeEvent(id, old1, old2);
90 }
91 
92 // --- Attributes -------------------------------------------------------------
93 
94 int64_t getAttribute64(const AttributesT id)
95 {
96  const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
97  if (it != mData.mAttributes.end())
98  return it->second;
99  return 0;
100 }
101 
102 int32_t getAttribute(const AttributesT id)
103 {
104  const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
105  if (it != mData.mAttributes.end())
106  return CAST_S32(it->second);
107  return 0;
108 }
109 
110 void setAttribute(const AttributesT id,
111  const int64_t value,
112  const Notify notify)
113 {
114  const int64_t old = mData.mAttributes[id];
115  mData.mAttributes[id] = value;
116  if (notify == Notify_true)
117  triggerAttr(id, old);
118 }
119 
120 int getSkillLevel(const int id)
121 {
122  const IntMap::const_iterator it = mData.mSkills.find(id);
123  if (it != mData.mSkills.end())
124  return it->second;
125  return 0;
126 }
127 
128 void setSkillLevel(const int id, const int value)
129 {
130  mData.mSkills[id] = value;
131 }
132 
133 // --- Stats ------------------------------------------------------------------
134 
136 {
137  const StatMap::const_iterator it = mData.mStats.find(id);
138  if (it != mData.mStats.end())
139  return it->second.base;
140  return 0;
141 }
142 
143 void setStatBase(const AttributesT id, const int value, const Notify notify)
144 {
145  const int old = mData.mStats[id].base;
146  mData.mStats[id].base = value;
147  if (notify == Notify_true)
148  triggerStat(id, old, 0);
149 }
150 
151 int getStatMod(const AttributesT id)
152 {
153  const StatMap::const_iterator it = mData.mStats.find(id);
154  if (it != mData.mStats.end())
155  return it->second.mod;
156  return 0;
157 }
158 
159 void setStatMod(const AttributesT id, const int value, const Notify notify)
160 {
161  const int old = mData.mStats[id].mod;
162  mData.mStats[id].mod = value;
163  if (notify == Notify_true)
164  triggerStat(id, old, 0);
165 }
166 
168 {
169  const StatMap::const_iterator it = mData.mStats.find(id);
170  if (it != mData.mStats.end())
171  return it->second.base + it->second.mod;
172  return 0;
173 }
174 
175 const std::pair<int, int> getStatExperience(const AttributesT id)
176 {
177  const StatMap::const_iterator it = mData.mStats.find(id);
178  int a;
179  int b;
180  if (it != mData.mStats.end())
181  {
182  a = it->second.exp;
183  b = it->second.expNeed;
184  }
185  else
186  {
187  a = 0;
188  b = 0;
189  }
190  return std::pair<int, int>(a, b);
191 }
192 
193 // --- Inventory / Equipment --------------------------------------------------
194 
196 {
197  return mInventory;
198 }
199 
201 {
202  if (inventoryHandler != nullptr)
203  return inventoryHandler->getStorage();
204  return nullptr;
205 }
206 
208 {
209  return mCartInventory;
210 }
211 
213 {
214  if (mEquipment != nullptr)
215  mEquipment->clear();
216  if (mInventory != nullptr)
217  mInventory->clear();
218 }
219 
221 {
222  return mEquipment;
223 }
224 
225 const Item *getEquipment(const unsigned int slot)
226 {
227  if (mEquipment != nullptr)
228  return mEquipment->getEquipment(slot);
229  return nullptr;
230 }
231 
233 {
234  if (mEquipment != nullptr)
235  mEquipment->setBackend(backend);
236 }
237 
238 void equipItem(const Item *const item, const Sfx sfx)
239 {
240  if (sfx == Sfx_true)
242  if (inventoryHandler != nullptr)
244 }
245 
246 void unequipItem(const Item *const item, const Sfx sfx)
247 {
248  if (sfx == Sfx_true)
250  if (inventoryHandler != nullptr)
252 }
253 
254 void useItem(const Item *const item, const Sfx sfx)
255 {
256  if (sfx == Sfx_true)
258  if (inventoryHandler != nullptr)
259  inventoryHandler->useItem(item);
260 }
261 
262 void useEquipItem(const Item *const item,
263  const int16_t useType,
264  const Sfx sfx)
265 {
266  if (item != nullptr)
267  {
268  if (item->getType() == ItemType::Card)
269  {
270  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
271  {
272  if (inventoryHandler != nullptr)
273  inventoryHandler->useCard(item);
274  if (sfx == Sfx_true)
276  }
277  }
278  else if (item->isEquipment() == Equipm_true)
279  {
280  if (item->isEquipped() == Equipped_true)
281  {
282  if (sfx == Sfx_true)
284  if (inventoryHandler != nullptr)
286  }
287  else
288  {
289  if (sfx == Sfx_true)
291  if (inventoryHandler != nullptr)
293  }
294  }
295  else
296  {
297  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
298  {
299  if (inventoryHandler != nullptr)
300  {
301  if (useType == 0)
302  inventoryHandler->useItem(item);
303  else
304  inventoryHandler->useItem(item, useType);
305  }
306  if (sfx == Sfx_true)
308  }
309  }
310  }
311 }
312 
313 void useEquipItem2(const Item *const item,
314  const int16_t useType,
315  const Sfx sfx)
316 {
317  if (item != nullptr)
318  {
319  if (item->isEquipment() == Equipm_false)
320  {
321  if (item->isEquipped() == Equipped_true)
322  {
323  if (sfx == Sfx_true)
325  if (inventoryHandler != nullptr)
327  }
328  else
329  {
330  if (sfx == Sfx_true)
332  if (inventoryHandler != nullptr)
334  }
335  }
336  else
337  {
338  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
339  {
340  if (sfx == Sfx_true)
342  if (inventoryHandler != nullptr)
343  {
344  if (useType == 0)
345  inventoryHandler->useItem(item);
346  else
347  inventoryHandler->useItem(item, useType);
348  }
349  }
350  }
351  }
352 }
353 
354 void dropItem(const Item *const item, const int amount, const Sfx sfx)
355 {
356  if (item != nullptr &&
357  mProtectedItems.find(item->getId()) == mProtectedItems.end())
358  {
359  if (sfx == Sfx_true)
361  if (inventoryHandler != nullptr)
362  inventoryHandler->dropItem(item, amount);
363  }
364 }
365 
366 void pickUpItem(const FloorItem *const item, const Sfx sfx)
367 {
368  if (sfx == Sfx_true)
370  if (playerHandler != nullptr)
371  playerHandler->pickUp(item);
372 }
373 
374 // --- Misc -------------------------------------------------------------------
375 
376 void setBackend(const PlayerInfoBackend &backend)
377 {
378  mData = backend;
379 }
380 
381 void setCharId(const int charId)
382 {
383  mCharId = charId;
384 }
385 
387 {
388  return mCharId;
389 }
390 
392 {
393  return mTrading;
394 }
395 
396 void setTrading(const Trading trading)
397 {
398  mTrading = trading;
399 }
400 
401 #define updateAttackStat(atk, delay, speed) \
402  attackDelay = getStatBase(delay); \
403  if (attackDelay != 0) \
404  { \
405  setStatBase(speed, \
406  getStatBase(atk) * 1000 / attackDelay, \
407  Notify_false); \
408  setStatMod(speed, \
409  getStatMod(atk) * 1000 / attackDelay, \
410  Notify_true); \
411  } \
412  else \
413  { \
414  setStatBase(speed, 0, \
415  Notify_false); \
416  setStatMod(speed, 0, \
417  Notify_true); \
418  }
419 
421 {
422  int attackDelay;
432 }
433 
434 void init()
435 {
436 }
437 
438 void deinit()
439 {
440  clearInventory();
443 }
444 
445 void loadData()
446 {
447  mProtectedItems.clear();
449  serverConfig.getStringValue("protectedItems"), ',');
450 }
451 
452 void clear()
453 {
454  mData.mSkills.clear();
456 }
457 
458 bool isTalking()
459 {
461 }
462 
464 {
468 }
469 
470 void stateChange(const StateT state)
471 {
472  if (state == State::GAME)
473  {
474  if (mInventory == nullptr)
475  {
478  mEquipment = new Equipment;
480  }
481  }
482 }
483 
484 static void saveProtectedItems()
485 {
486  std::string str;
487  std::set<int>::const_iterator it = mProtectedItems.begin();
488  std::set<int>::const_iterator it_end = mProtectedItems.end();
489  if (it != it_end)
490  {
491  str.append(toString(*it));
492  ++ it;
493  }
494  while (it != it_end)
495  {
496  str.append(",").append(toString(*it));
497  ++ it;
498  }
499  serverConfig.setValue("protectedItems", str);
501 }
502 
503 void protectItem(const int id)
504 {
505  mProtectedItems.insert(id);
507 }
508 
509 void unprotectItem(const int id)
510 {
511  mProtectedItems.erase(id);
513 }
514 
515 bool isItemProtected(const int id)
516 {
517  return mProtectedItems.find(id) != mProtectedItems.end();
518 }
519 
521 {
522  delete mMercenary;
523  mMercenary = info;
524 }
525 
526 void setMercenaryBeing(Being *const being)
527 {
528  if (being == nullptr ||
529  mMercenary == nullptr)
530  {
531  return;
532  }
533  being->setName(mMercenary->name);
534  being->setOwner(localPlayer);
535  being->setLevel(mMercenary->level);
537 }
538 
539 void setElemental(const BeingId id)
540 {
541  mElementalId = id;
542 }
543 
545 {
546  return mElementalId;
547 }
548 
550 {
551  return mMercenary;
552 }
553 
554 void setPet(PetInfo *const info)
555 {
556  delete mPet;
557  mPet = info;
558 }
559 
560 void setPetBeing(Being *const being)
561 {
562  if (being != nullptr)
563  mPetBeingId = being->getId();
564  else
566  if (being == nullptr ||
567  mPet == nullptr)
568  {
569  return;
570  }
571  being->setName(mPet->name);
572  being->setOwner(localPlayer);
573  being->setLevel(mPet->level);
574 }
575 
577 {
578  return mPet;
579 }
580 
582 {
583  return mPetBeingId;
584 }
585 
587 {
588  delete mHomunculus;
589  mHomunculus = info;
590 }
591 
592 void setHomunculusBeing(Being *const being)
593 {
594  if (being == nullptr ||
595  mHomunculus == nullptr)
596  {
597  return;
598  }
599  being->setName(mHomunculus->name);
600  being->setOwner(localPlayer);
601 }
602 
604 {
605  return mHomunculus;
606 }
607 
609 {
610  return mHomunculus != nullptr ? mHomunculus->id : BeingId_zero;
611 }
612 
614 {
615  return mMercenary != nullptr ? mMercenary->id : BeingId_zero;
616 }
617 
618 void updateAttackAi(const BeingId targetId,
619  const Keep keep)
620 {
621  if (mMercenary != nullptr &&
622  mercenaryHandler != nullptr)
623  {
624  mercenaryHandler->attack(targetId, keep);
625  }
626  if (mHomunculus != nullptr &&
627  homunculusHandler != nullptr)
628  {
629  homunculusHandler->attack(targetId, keep);
630  }
631 }
632 
633 std::string getRoomName()
634 {
635  return mRoomName;
636 }
637 
638 void setRoomName(const std::string &name)
639 {
640  mRoomName = name;
641 }
642 
643 bool isInRoom()
644 {
645  return !mRoomName.empty();
646 }
647 
649 {
650  mGuildPositionFlags = pos;
651 }
652 
654 {
655  return mGuildPositionFlags;
656 }
657 
658 void enableVending(const bool b)
659 {
660  mVending = b;
661 }
662 
663 bool isVending()
664 {
665  return mVending;
666 }
667 
668 void setServerLanguage(const int lang)
669 {
670  if (lang != mServerLanguage)
671  {
672  mServerLanguage = lang;
674  }
675 }
676 
678 {
679  return mServerLanguage;
680 }
681 
682 } // namespace PlayerInfo
Attributes ::T AttributesT
Definition: attributes.h:118
int BeingId
Definition: beingid.h:30
const BeingId BeingId_zero
Definition: beingid.h:30
#define CAST_S32
Definition: cast.h:30
BeingId getId() const
Definition: actorsprite.h:64
static void distributeEvent(const AttributesT id, const int64_t oldVal, const int64_t newVal)
Definition: being.h:96
void setOwner(Being *const owner)
Definition: being.h:911
void setLevel(const int n)
Definition: being.h:601
void setName(const std::string &name)
Definition: being.cpp:1136
void setAttackRange(const int range)
Definition: being.h:843
std::string getStringValue(const std::string &key) const
void setValue(const std::string &key, const std::string &value)
void clear()
Definition: equipment.h:78
void setBackend(Backend *const backend)
Definition: equipment.h:88
const Item * getEquipment(const int index) const
Definition: equipment.h:69
static bool isStorageActive()
void clear()
Definition: inventory.cpp:238
static void playSfx(const int item, const ItemSoundEvent::Type sound)
Definition: item.h:50
Equipm isEquipment() const
Definition: item.h:117
Equipped isEquipped() const
Definition: item.h:129
int getId() const
Definition: item.h:81
ItemTypeT getType() const
Definition: item.h:225
virtual void attack(const BeingId targetId, const Keep keep) const =0
virtual void useCard(const Item *const item)=0
virtual void dropItem(const Item *const item, const int amount) const =0
virtual void equipItem(const Item *const item) const =0
virtual void unequipItem(const Item *const item) const =0
virtual Inventory * getStorage() const =0
virtual void useItem(const Item *const item) const =0
virtual void attack(const BeingId targetId, const Keep keep) const =0
virtual void pickUp(const FloorItem *const floorItem) const =0
static bool isActive()
Definition: npcdialog.h:191
unsigned int fixedInventorySize
Definition: settings.h:148
static void distributeEvent(const AttributesT id, const int oldVal1, const int oldVal2)
static void loadDictionaryLang()
Configuration serverConfig
#define delete2(var)
Definition: delete2.h:25
const bool Equipm_false
Definition: equipm.h:30
const bool Equipm_true
Definition: equipm.h:30
const bool Equipped_true
Definition: equipped.h:30
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:112
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89
bool Keep
Definition: keep.h:30
LocalPlayer * localPlayer
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:118
bool info(InputEvent &event)
Definition: commands.cpp:57
@ PLAYER_ATTACK_SPEED
Definition: attributes.h:54
@ MERC_ATTACK_DELAY
Definition: attributes.h:95
@ HOMUN_ATTACK_SPEED
Definition: attributes.h:80
@ PLAYER_ATTACK_DELAY
Definition: attributes.h:51
@ MERC_ATTACK_SPEED
Definition: attributes.h:97
@ HOMUN_ATTACK_DELAY
Definition: attributes.h:78
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
@ Card
Definition: itemtype.h:35
void notify(const unsigned int message)
int mServerLanguage
Definition: playerinfo.cpp:73
void setServerLanguage(const int lang)
Definition: playerinfo.cpp:668
Trading isTrading()
Definition: playerinfo.cpp:391
void useEquipItem(const Item *const item, const int16_t useType, const Sfx sfx)
Definition: playerinfo.cpp:262
bool isInRoom()
Definition: playerinfo.cpp:643
int64_t getAttribute64(const AttributesT id)
Definition: playerinfo.cpp:94
void dropItem(const Item *const item, const int amount, const Sfx sfx)
Definition: playerinfo.cpp:354
Inventory * getInventory()
Definition: playerinfo.cpp:195
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:159
MercenaryInfo * mMercenary
Definition: playerinfo.cpp:61
int getStatBase(const AttributesT id)
Definition: playerinfo.cpp:135
void setPetBeing(Being *const being)
Definition: playerinfo.cpp:560
void stateChange(const StateT state)
Definition: playerinfo.cpp:470
PetInfo * mPet
Definition: playerinfo.cpp:63
BeingId getHomunculusId()
Definition: playerinfo.cpp:608
void setMercenaryBeing(Being *const being)
Definition: playerinfo.cpp:526
Inventory * getStorageInventory()
Definition: playerinfo.cpp:200
void useEquipItem2(const Item *const item, const int16_t useType, const Sfx sfx)
Definition: playerinfo.cpp:313
void setBackend(const PlayerInfoBackend &backend)
Definition: playerinfo.cpp:376
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:238
void enableVending(const bool b)
Definition: playerinfo.cpp:658
PlayerInfoBackend mData
Definition: playerinfo.cpp:56
BeingId mElementalId
Definition: playerinfo.cpp:68
BeingId getPetBeingId()
Definition: playerinfo.cpp:581
void loadData()
Definition: playerinfo.cpp:445
Equipment * getEquipment()
Definition: playerinfo.cpp:220
void pickUpItem(const FloorItem *const item, const Sfx sfx)
Definition: playerinfo.cpp:366
void useItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:254
void setPet(PetInfo *const info)
Definition: playerinfo.cpp:554
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102
bool isTalking()
Definition: playerinfo.cpp:458
static void saveProtectedItems()
Definition: playerinfo.cpp:484
void setTrading(const Trading trading)
Definition: playerinfo.cpp:396
Inventory * getCartInventory()
Definition: playerinfo.cpp:207
std::string getRoomName()
Definition: playerinfo.cpp:633
void setElemental(const BeingId id)
Definition: playerinfo.cpp:539
void unprotectItem(const int id)
Definition: playerinfo.cpp:509
bool isItemProtected(const int id)
Definition: playerinfo.cpp:515
HomunculusInfo * getHomunculus()
Definition: playerinfo.cpp:603
BeingId getElementalId()
Definition: playerinfo.cpp:544
void init()
Definition: playerinfo.cpp:434
void clear()
Definition: playerinfo.cpp:452
void setAttribute(const AttributesT id, const int64_t value, const Notify notify)
Definition: playerinfo.cpp:110
BeingId mPetBeingId
Definition: playerinfo.cpp:66
Trading mTrading
Definition: playerinfo.cpp:70
int getServerLanguage()
Definition: playerinfo.cpp:677
void setHomunculusBeing(Being *const being)
Definition: playerinfo.cpp:592
int getStatEffective(const AttributesT id)
Definition: playerinfo.cpp:167
int getSkillLevel(const int id)
Definition: playerinfo.cpp:120
Inventory * mInventory
Definition: playerinfo.cpp:59
BeingId getMercenaryId()
Definition: playerinfo.cpp:613
Inventory * mCartInventory
Definition: playerinfo.cpp:60
bool mVending
Definition: playerinfo.cpp:71
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:246
void clearInventory()
Definition: playerinfo.cpp:212
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128
void setEquipmentBackend(Equipment::Backend *const backend)
Definition: playerinfo.cpp:232
int mLevelProgress
Definition: playerinfo.cpp:72
Equipment * mEquipment
Definition: playerinfo.cpp:65
const std::pair< int, int > getStatExperience(const AttributesT id)
Definition: playerinfo.cpp:175
void triggerStat(const AttributesT id, const int old1, const int old2)
Definition: playerinfo.cpp:85
std::string mRoomName
Definition: playerinfo.cpp:64
void deinit()
Definition: playerinfo.cpp:438
void setGuildPositionFlags(const GuildPositionFlags::Type pos)
Definition: playerinfo.cpp:648
void updateAttrs()
Definition: playerinfo.cpp:420
int getStatMod(const AttributesT id)
Definition: playerinfo.cpp:151
std::set< int > mProtectedItems
Definition: playerinfo.cpp:74
void updateAttackAi(const BeingId targetId, const Keep keep)
Definition: playerinfo.cpp:618
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:143
void setRoomName(const std::string &name)
Definition: playerinfo.cpp:638
MercenaryInfo * getMercenary()
Definition: playerinfo.cpp:549
void gameDestroyed()
Definition: playerinfo.cpp:463
PetInfo * getPet()
Definition: playerinfo.cpp:576
HomunculusInfo * mHomunculus
Definition: playerinfo.cpp:62
void setCharId(const int charId)
Definition: playerinfo.cpp:381
void setMercenary(MercenaryInfo *const info)
Definition: playerinfo.cpp:520
GuildPositionFlags::Type getGuildPositionFlags()
Definition: playerinfo.cpp:653
bool isVending()
Definition: playerinfo.cpp:663
void setHomunculus(HomunculusInfo *const info)
Definition: playerinfo.cpp:586
int getCharId()
Definition: playerinfo.cpp:386
void protectItem(const int id)
Definition: playerinfo.cpp:503
GuildPositionFlags::Type mGuildPositionFlags
Definition: playerinfo.cpp:67
void triggerAttr(const AttributesT id, const int64_t old)
Definition: playerinfo.cpp:78
@ GAME
Definition: state.h:49
Net::PlayerHandler * playerHandler
Definition: net.cpp:96
bool Notify
Definition: notify.h:30
const bool Notify_true
Definition: notify.h:30
#define updateAttackStat(atk, delay, speed)
Definition: playerinfo.cpp:401
Settings settings
Definition: settings.cpp:32
const bool Sfx_true
Definition: sfx.h:30
bool Sfx
Definition: sfx.h:30
State ::T StateT
Definition: state.h:71
void splitToIntSet(std::set< int > &tokens, const std::string &text, const char separator)
std::string name
std::string name
Definition: mercenaryinfo.h:41
int level
Definition: petinfo.h:49
std::string name
Definition: petinfo.h:47
AtrIntMap mAttributes
Definition: playerinfo.h:73
const bool Trading_false
Definition: trading.h:30
bool Trading
Definition: trading.h:30