ManaPlus
Functions | Variables
PlayerInfo Namespace Reference

Functions

void triggerAttr (const AttributesT id, const int64_t old)
 
void triggerStat (const AttributesT id, const int old1, const int old2)
 
int64_t getAttribute64 (const AttributesT id)
 
int32_t getAttribute (const AttributesT id)
 
void setAttribute (const AttributesT id, const int64_t value, const Notify notify)
 
int getSkillLevel (const int id)
 
void setSkillLevel (const int id, const int value)
 
int getStatBase (const AttributesT id)
 
void setStatBase (const AttributesT id, const int value, const Notify notify)
 
int getStatMod (const AttributesT id)
 
void setStatMod (const AttributesT id, const int value, const Notify notify)
 
int getStatEffective (const AttributesT id)
 
const std::pair< int, int > getStatExperience (const AttributesT id)
 
InventorygetInventory ()
 
InventorygetStorageInventory ()
 
InventorygetCartInventory ()
 
void clearInventory ()
 
EquipmentgetEquipment ()
 
const ItemgetEquipment (const unsigned int slot)
 
void setEquipmentBackend (Equipment::Backend *const backend)
 
void equipItem (const Item *const item, const Sfx sfx)
 
void unequipItem (const Item *const item, const Sfx sfx)
 
void useItem (const Item *const item, const Sfx sfx)
 
void useEquipItem (const Item *const item, const int16_t useType, const Sfx sfx)
 
void useEquipItem2 (const Item *const item, const int16_t useType, const Sfx sfx)
 
void dropItem (const Item *const item, const int amount, const Sfx sfx)
 
void pickUpItem (const FloorItem *const item, const Sfx sfx)
 
void setBackend (const PlayerInfoBackend &backend)
 
void setCharId (const int charId)
 
int getCharId ()
 
Trading isTrading ()
 
void setTrading (const Trading trading)
 
void updateAttrs ()
 
void init ()
 
void deinit ()
 
void loadData ()
 
void clear ()
 
bool isTalking ()
 
void gameDestroyed ()
 
void stateChange (const StateT state)
 
static void saveProtectedItems ()
 
void protectItem (const int id)
 
void unprotectItem (const int id)
 
bool isItemProtected (const int id)
 
void setMercenary (MercenaryInfo *const info)
 
void setMercenaryBeing (Being *const being)
 
void setElemental (const BeingId id)
 
BeingId getElementalId ()
 
MercenaryInfogetMercenary ()
 
void setPet (PetInfo *const info)
 
void setPetBeing (Being *const being)
 
PetInfogetPet ()
 
BeingId getPetBeingId ()
 
void setHomunculus (HomunculusInfo *const info)
 
void setHomunculusBeing (Being *const being)
 
HomunculusInfogetHomunculus ()
 
BeingId getHomunculusId ()
 
BeingId getMercenaryId ()
 
void updateAttackAi (const BeingId targetId, const Keep keep)
 
std::string getRoomName ()
 
void setRoomName (const std::string &name)
 
bool isInRoom ()
 
void setGuildPositionFlags (const GuildPositionFlags::Type pos)
 
GuildPositionFlags::Type getGuildPositionFlags ()
 
void enableVending (const bool b)
 
bool isVending ()
 
void setServerLanguage (const int lang)
 
int getServerLanguage ()
 

Variables

PlayerInfoBackend mData
 
int mCharId = 0
 
InventorymInventory = 0
 
InventorymCartInventory = 0
 
MercenaryInfomMercenary = 0
 
HomunculusInfomHomunculus = 0
 
PetInfomPet = 0
 
std::string mRoomName
 
EquipmentmEquipment = 0
 
BeingId mPetBeingId = BeingId_zero
 
GuildPositionFlags::Type mGuildPositionFlags = GuildPositionFlags::None
 
BeingId mElementalId = BeingId_zero
 
Trading mTrading = Trading_false
 
bool mVending = false
 
int mLevelProgress = 0
 
int mServerLanguage = -1
 
std::set< int > mProtectedItems
 

Detailed Description

A database like namespace which holds global info about the localplayer

Function Documentation

◆ clear()

void PlayerInfo::clear ( )

◆ clearInventory()

void PlayerInfo::clearInventory ( )

Clears the player's inventory and equipment.

Definition at line 211 of file playerinfo.cpp.

212 {
213  if (mEquipment != nullptr)
214  mEquipment->clear();
215  if (mInventory != nullptr)
216  mInventory->clear();
217 }

References Equipment::clear(), Inventory::clear(), mEquipment, and mInventory.

Referenced by deinit().

◆ deinit()

void PlayerInfo::deinit ( )

Definition at line 437 of file playerinfo.cpp.

438 {
439  clearInventory();
442 }

References BeingId_zero, clearInventory(), delete2, mMercenary, and mPetBeingId.

◆ dropItem()

void PlayerInfo::dropItem ( const Item *const  item,
const int  amount,
const Sfx  sfx 
)

Definition at line 353 of file playerinfo.cpp.

354 {
355  if (item != nullptr &&
356  mProtectedItems.find(item->getId()) == mProtectedItems.end())
357  {
358  if (sfx == Sfx_true)
360  if (inventoryHandler != nullptr)
361  inventoryHandler->dropItem(item, amount);
362  }
363 }

References ItemSoundEvent::DROP, Net::InventoryHandler::dropItem(), Item::getId(), inventoryHandler, mProtectedItems, ItemSoundManager::playSfx(), and Sfx_true.

Referenced by InventoryWindow::action(), DropShortcut::dropFirst(), DropShortcut::dropItem(), and ItemAmountWindow::finish().

◆ enableVending()

void PlayerInfo::enableVending ( const bool  b)

◆ equipItem()

void PlayerInfo::equipItem ( const Item *const  item,
const Sfx  sfx 
)

◆ gameDestroyed()

void PlayerInfo::gameDestroyed ( )

Definition at line 462 of file playerinfo.cpp.

463 {
467 }

References delete2, mCartInventory, mEquipment, and mInventory.

Referenced by Game::~Game().

◆ getAttribute()

int32_t PlayerInfo::getAttribute ( const AttributesT  id)

Definition at line 101 of file playerinfo.cpp.

102 {
103  const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
104  if (it != mData.mAttributes.end())
105  return CAST_S32(it->second);
106  return 0;
107 }

References CAST_S32, PlayerInfoBackend::mAttributes, and mData.

Referenced by ChangeDisplay::action(), ShopWindow::action(), TradeWindow::action(), DialogsManager::attributeChanged(), KillStats::attributeChanged(), StatusWindow::attributeChanged(), ChatWindow::attributeChanged(), LocalPlayer::attributeChanged(), Being::drawPlayerSpriteAt(), LocalPlayer::getLevel(), ShopWindow::giveList(), ActorManager::heal(), EAthena::PlayerHandler::increaseSkill(), TmwAthena::PlayerHandler::increaseSkill(), SpellManager::invoke(), MiniStatusWindow::mouseMoved(), InventoryWindow::mouseMoved(), EAthena::BuyingStoreRecv::processBuyingStoreItemsList(), EAthena::VendingRecv::processItemsList(), EAthena::MarketRecv::processMarketOpen(), TmwAthena::BuySellRecv::processNpcBuy(), EAthena::BuySellRecv::processNpcBuy(), TmwAthena::BuySellRecv::processNpcBuyResponse(), Ea::BuySellRecv::processNpcSell(), EAthena::PlayerRecv::processPlayerHeal(), Ea::PlayerRecv::processPlayerStatUpdate4(), KillStats::recalcStats(), EAthena::PlayerHandler::setStat(), TmwAthena::PlayerHandler::setStat(), ShopWindow::showList(), StatsPageBasic::StatsPageBasic(), StatusWindow::StatusWindow(), LocalPlayer::tryMagic(), ChangeDisplay::update(), KillStats::update(), SkillDialog::update(), StatusWindow::updateHPBar(), StatusWindow::updateJobBar(), StatusWindow::updateLevelLabel(), StatusWindow::updateMoneyBar(), StatusWindow::updateMPBar(), InventoryWindow::updateWeight(), StatusWindow::updateWeightBar(), and StatusWindow::updateXPBar().

◆ getAttribute64()

int64_t PlayerInfo::getAttribute64 ( const AttributesT  id)

Returns the value of the given attribute.

Definition at line 93 of file playerinfo.cpp.

94 {
95  const AtrIntMap::const_iterator it = mData.mAttributes.find(id);
96  if (it != mData.mAttributes.end())
97  return it->second;
98  return 0;
99 }

References PlayerInfoBackend::mAttributes, and mData.

Referenced by KillStats::action(), KillStats::gainXp(), KillStats::KillStats(), MiniStatusWindow::mouseMoved(), and StatusWindow::StatusWindow().

◆ getCartInventory()

Inventory * PlayerInfo::getCartInventory ( )

◆ getCharId()

int PlayerInfo::getCharId ( )

Definition at line 385 of file playerinfo.cpp.

386 {
387  return mCharId;
388 }

References mCharId.

Referenced by EAthena::GuildHandler::leave(), and EAthena::GuildRecv::processGuildLeave2().

◆ getElementalId()

BeingId PlayerInfo::getElementalId ( )

Definition at line 543 of file playerinfo.cpp.

544 {
545  return mElementalId;
546 }

References mElementalId.

Referenced by Being::drawElementalSpriteAt().

◆ getEquipment() [1/2]

Equipment * PlayerInfo::getEquipment ( )

◆ getEquipment() [2/2]

const Item * PlayerInfo::getEquipment ( const unsigned int  slot)

Returns the player's equipment at the given slot.

Definition at line 224 of file playerinfo.cpp.

225 {
226  if (mEquipment != nullptr)
227  return mEquipment->getEquipment(slot);
228  return nullptr;
229 }

References Equipment::getEquipment(), and mEquipment.

◆ getGuildPositionFlags()

GuildPositionFlags::Type PlayerInfo::getGuildPositionFlags ( )

Definition at line 652 of file playerinfo.cpp.

653 {
654  return mGuildPositionFlags;
655 }

References mGuildPositionFlags.

◆ getHomunculus()

HomunculusInfo * PlayerInfo::getHomunculus ( )

◆ getHomunculusId()

BeingId PlayerInfo::getHomunculusId ( )

◆ getInventory()

Inventory * PlayerInfo::getInventory ( )

Returns the player's inventory.

Definition at line 194 of file playerinfo.cpp.

195 {
196  return mInventory;
197 }

References mInventory.

Referenced by EquipmentWindow::action(), ShopWindow::action(), NpcDialog::action(), NpcDialog::addCraftItem(), LocalPlayer::changeEquipmentBeforeAttack(), Ea::EquipBackend::clear(), OutfitWindow::copyFromEquiped(), createGuiWindows(), ItemShortcutContainer::draw(), VirtShortcutContainer::draw(), OutfitWindow::draw(), DropShortcut::dropFirst(), DropShortcut::dropItem(), ItemShortcut::equipItem(), Ea::EquipBackend::getEquipment(), Actions::getItemByInvIndex(), ShopWindow::giveList(), LocalPlayer::imitateOutfit(), TradeWindow::initTrade(), MiniStatusWindow::MiniStatusWindow(), ItemShortcutContainer::mouseDragged(), VirtShortcutContainer::mouseDragged(), OutfitWindow::mouseDragged(), ItemShortcutContainer::mouseMoved(), MiniStatusWindow::mouseMoved(), VirtShortcutContainer::mouseMoved(), VirtShortcutContainer::mousePressed(), ShopListBox::mouseReleased(), ItemContainer::mouseReleased(), EquipmentWindow::mouseReleased(), EAthena::InventoryRecv::processBindItem(), EAthena::BuyingStoreRecv::processBuyingStoreDeleteItem(), EAthena::BuyingStoreRecv::processBuyingStoreItemsList(), EAthena::PetRecv::processEggsList(), EAthena::InventoryRecv::processInventoryEndContinue(), EAthena::InventoryRecv::processInventoryExpansionInfo(), EAthena::InventoryRecv::processInventoryStartContinue(), EAthena::InventoryRecv::processItemMoveFailed(), Ea::InventoryRecv::processItemUseResponse(), Ea::BuySellRecv::processNpcSell(), TmwAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerEquipment(), EAthena::InventoryRecv::processPlayerInsertCard(), TmwAthena::InventoryRecv::processPlayerInventory(), EAthena::InventoryRecv::processPlayerInventory(), TmwAthena::InventoryRecv::processPlayerInventoryAdd(), EAthena::InventoryRecv::processPlayerInventoryAdd(), TmwAthena::InventoryRecv::processPlayerInventoryRemove(), EAthena::InventoryRecv::processPlayerInventoryRemove(), EAthena::InventoryRecv::processPlayerInventoryRemove2(), TmwAthena::InventoryRecv::processPlayerInventoryUse(), EAthena::InventoryRecv::processPlayerInventoryUse(), EAthena::InventoryRecv::processPlayerItemRentalExpired(), EAthena::InventoryRecv::processPlayerRefine(), EAthena::InventoryRecv::processPlayerUseCard(), EAthena::Mail2Recv::processRemoveItemResult(), ShopWindow::processRequest(), TmwAthena::TradeRecv::processTradeItemAddResponse(), EAthena::TradeRecv::processTradeItemAddResponse(), NpcDialog::restoreVirtuals(), ItemShortcutContainer::safeDraw(), VirtShortcutContainer::safeDraw(), OutfitWindow::safeDraw(), BuyingStoreSellDialog::sellAction(), MailEditWindow::sendMail(), Ea::EquipBackend::setEquipment(), PopupMenu::showItemPopup(), ShopWindow::showList(), ShopWindow::sumAmount(), ItemShortcut::unequipItem(), OutfitWindow::unequipNotInOutfit(), StatusWindow::updateInvSlotsBar(), ItemShortcut::useItem(), OutfitWindow::wearOutfit(), and MiniStatusWindow::~MiniStatusWindow().

◆ getMercenary()

MercenaryInfo * PlayerInfo::getMercenary ( )

Definition at line 548 of file playerinfo.cpp.

549 {
550  return mMercenary;
551 }

References mMercenary.

Referenced by EAthena::BeingRecv::createBeing2(), and Being::drawMercenarySpriteAt().

◆ getMercenaryId()

BeingId PlayerInfo::getMercenaryId ( )

◆ getPet()

PetInfo * PlayerInfo::getPet ( )

Definition at line 575 of file playerinfo.cpp.

576 {
577  return mPet;
578 }

References mPet.

Referenced by EAthena::PetRecv::processPetData(), EAthena::PetRecv::processPetStatus(), and BeingPopup::show().

◆ getPetBeingId()

BeingId PlayerInfo::getPetBeingId ( )

Definition at line 580 of file playerinfo.cpp.

581 {
582  return mPetBeingId;
583 }

References mPetBeingId.

Referenced by EAthena::BeingRecv::createBeing2(), and Actions::getPet().

◆ getRoomName()

std::string PlayerInfo::getRoomName ( )

Definition at line 632 of file playerinfo.cpp.

633 {
634  return mRoomName;
635 }

References mRoomName.

Referenced by ChatWindow::joinRoom().

◆ getServerLanguage()

int PlayerInfo::getServerLanguage ( )

Definition at line 676 of file playerinfo.cpp.

677 {
678  return mServerLanguage;
679 }

References mServerLanguage.

Referenced by getServerLang().

◆ getSkillLevel()

int PlayerInfo::getSkillLevel ( const int  id)

◆ getStatBase()

int PlayerInfo::getStatBase ( const AttributesT  id)

Returns the base value of the given stat.

Definition at line 134 of file playerinfo.cpp.

135 {
136  const StatMap::const_iterator it = mData.mStats.find(id);
137  if (it != mData.mStats.end())
138  return it->second.base;
139  return 0;
140 }

References mData, and PlayerInfoBackend::mStats.

Referenced by ChangeDisplay::action(), Being::drawElementalSpriteAt(), Being::drawHomunculusSpriteAt(), Being::drawMercenarySpriteAt(), Ea::PlayerRecv::processPlayerStatUpdate4(), and AttrDisplay::update().

◆ getStatEffective()

int PlayerInfo::getStatEffective ( const AttributesT  id)

Returns the current effective value of the given stat. Effective is base

  • mod

Definition at line 166 of file playerinfo.cpp.

167 {
168  const StatMap::const_iterator it = mData.mStats.find(id);
169  if (it != mData.mStats.end())
170  return it->second.base + it->second.mod;
171  return 0;
172 }

References mData, and PlayerInfoBackend::mStats.

Referenced by Ea::PlayerHandler::canUseMagic().

◆ getStatExperience()

const std::pair< int, int > PlayerInfo::getStatExperience ( const AttributesT  id)

Returns the experience of the given stat.

Definition at line 174 of file playerinfo.cpp.

175 {
176  const StatMap::const_iterator it = mData.mStats.find(id);
177  int a;
178  int b;
179  if (it != mData.mStats.end())
180  {
181  a = it->second.exp;
182  b = it->second.expNeed;
183  }
184  else
185  {
186  a = 0;
187  b = 0;
188  }
189  return std::pair<int, int>(a, b);
190 }

References mData, and PlayerInfoBackend::mStats.

Referenced by StatusWindow::updateProgressBar().

◆ getStatMod()

int PlayerInfo::getStatMod ( const AttributesT  id)

Returns the modifier for the given stat.

Definition at line 150 of file playerinfo.cpp.

151 {
152  const StatMap::const_iterator it = mData.mStats.find(id);
153  if (it != mData.mStats.end())
154  return it->second.mod;
155  return 0;
156 }

References mData, and PlayerInfoBackend::mStats.

Referenced by AttrDisplay::update().

◆ getStorageInventory()

Inventory * PlayerInfo::getStorageInventory ( )

Definition at line 199 of file playerinfo.cpp.

200 {
201  if (inventoryHandler != nullptr)
202  return inventoryHandler->getStorage();
203  return nullptr;
204 }

References Net::InventoryHandler::getStorage(), and inventoryHandler.

Referenced by Actions::getItemByInvIndex(), and ItemContainer::mouseReleased().

◆ init()

void PlayerInfo::init ( )

Initializes some internals.

Definition at line 433 of file playerinfo.cpp.

434 {
435 }

Referenced by Client::gameInit(), and Dirs::initLocalDataDir().

◆ isInRoom()

bool PlayerInfo::isInRoom ( )

Definition at line 642 of file playerinfo.cpp.

643 {
644  return !mRoomName.empty();
645 }

References mRoomName.

Referenced by InputManager::updateConditionMask().

◆ isItemProtected()

bool PlayerInfo::isItemProtected ( const int  id)

◆ isTalking()

bool PlayerInfo::isTalking ( )

Definition at line 457 of file playerinfo.cpp.

458 {
460 }

References NpcDialog::isActive(), and InventoryWindow::isStorageActive().

◆ isTrading()

Trading PlayerInfo::isTrading ( )

Returns true if the player is involved in a trade at the moment, false otherwise.

Definition at line 390 of file playerinfo.cpp.

391 {
392  return mTrading;
393 }

References mTrading.

Referenced by ShopWindow::processRequest(), and Ea::TradeRecv::processTradeRequestContinue().

◆ isVending()

bool PlayerInfo::isVending ( )

Definition at line 662 of file playerinfo.cpp.

663 {
664  return mVending;
665 }

References mVending.

Referenced by InputManager::updateConditionMask().

◆ loadData()

void PlayerInfo::loadData ( )

Definition at line 444 of file playerinfo.cpp.

445 {
446  mProtectedItems.clear();
448  serverConfig.getStringValue("protectedItems"), ',');
449 }

References Configuration::getStringValue(), mProtectedItems, serverConfig, and splitToIntSet().

Referenced by Client::runValidate(), and Client::stateConnectServer1().

◆ pickUpItem()

void PlayerInfo::pickUpItem ( const FloorItem *const  item,
const Sfx  sfx 
)

Definition at line 365 of file playerinfo.cpp.

366 {
367  if (sfx == Sfx_true)
369  if (playerHandler != nullptr)
370  playerHandler->pickUp(item);
371 }

References ItemSoundEvent::PICKUP, Net::PlayerHandler::pickUp(), playerHandler, ItemSoundManager::playSfx(), and Sfx_true.

Referenced by LocalPlayer::pickUp().

◆ protectItem()

void PlayerInfo::protectItem ( const int  id)

Definition at line 502 of file playerinfo.cpp.

503 {
504  mProtectedItems.insert(id);
506 }

References mProtectedItems, and saveProtectedItems().

◆ saveProtectedItems()

static void PlayerInfo::saveProtectedItems ( )
static

Definition at line 483 of file playerinfo.cpp.

484 {
485  std::string str;
486  std::set<int>::const_iterator it = mProtectedItems.begin();
487  std::set<int>::const_iterator it_end = mProtectedItems.end();
488  if (it != it_end)
489  {
490  str.append(toString(*it));
491  ++ it;
492  }
493  while (it != it_end)
494  {
495  str.append(",").append(toString(*it));
496  ++ it;
497  }
498  serverConfig.setValue("protectedItems", str);
500 }

References mProtectedItems, serverConfig, Configuration::setValue(), Catch::toString(), and Configuration::write().

Referenced by protectItem(), and unprotectItem().

◆ setAttribute()

void PlayerInfo::setAttribute ( const AttributesT  id,
const int64_t  value,
const Notify  notify 
)

◆ setBackend()

void PlayerInfo::setBackend ( const PlayerInfoBackend backend)

Changes the internal PlayerInfoBackend reference;

Definition at line 375 of file playerinfo.cpp.

376 {
377  mData = backend;
378 }

References mData.

Referenced by TmwAthena::CharServerRecv::processCharMapInfo(), and EAthena::CharServerRecv::processCharMapInfo().

◆ setCharId()

void PlayerInfo::setCharId ( const int  charId)

Definition at line 380 of file playerinfo.cpp.

381 {
382  mCharId = charId;
383 }

References mCharId.

Referenced by TmwAthena::CharServerRecv::processCharMapInfo(), and EAthena::CharServerRecv::processCharMapInfo().

◆ setElemental()

void PlayerInfo::setElemental ( const BeingId  id)

Definition at line 538 of file playerinfo.cpp.

539 {
540  mElementalId = id;
541 }

References mElementalId.

Referenced by EAthena::ElementalRecv::processElementalInfo().

◆ setEquipmentBackend()

void PlayerInfo::setEquipmentBackend ( Equipment::Backend *const  backend)

Definition at line 231 of file playerinfo.cpp.

232 {
233  if (mEquipment != nullptr)
234  mEquipment->setBackend(backend);
235 }

References mEquipment, and Equipment::setBackend().

◆ setGuildPositionFlags()

void PlayerInfo::setGuildPositionFlags ( const GuildPositionFlags::Type  pos)

Definition at line 647 of file playerinfo.cpp.

648 {
649  mGuildPositionFlags = pos;
650 }

References mGuildPositionFlags.

Referenced by EAthena::GuildRecv::processGuildPositionInfo().

◆ setHomunculus()

void PlayerInfo::setHomunculus ( HomunculusInfo *const  info)

Definition at line 585 of file playerinfo.cpp.

586 {
587  delete mHomunculus;
588  mHomunculus = info;
589 }

References Actions::info(), and mHomunculus.

Referenced by EAthena::HomunculusRecv::processHomunculusData().

◆ setHomunculusBeing()

void PlayerInfo::setHomunculusBeing ( Being *const  being)

◆ setMercenary()

void PlayerInfo::setMercenary ( MercenaryInfo *const  info)

Definition at line 519 of file playerinfo.cpp.

520 {
521  delete mMercenary;
522  mMercenary = info;
523 }

References Actions::info(), and mMercenary.

Referenced by EAthena::MercenaryRecv::handleMercenaryMessage(), and EAthena::MercenaryRecv::processMercenaryInfo().

◆ setMercenaryBeing()

void PlayerInfo::setMercenaryBeing ( Being *const  being)

Definition at line 525 of file playerinfo.cpp.

526 {
527  if (being == nullptr ||
528  mMercenary == nullptr)
529  {
530  return;
531  }
532  being->setName(mMercenary->name);
533  being->setOwner(localPlayer);
534  being->setLevel(mMercenary->level);
536 }

References MercenaryInfo::level, localPlayer, mMercenary, MercenaryInfo::name, MercenaryInfo::range, Being::setAttackRange(), Being::setLevel(), Being::setName(), and Being::setOwner().

Referenced by EAthena::BeingRecv::createBeing2(), and EAthena::MercenaryRecv::processMercenaryInfo().

◆ setPet()

void PlayerInfo::setPet ( PetInfo *const  info)

Definition at line 553 of file playerinfo.cpp.

554 {
555  delete mPet;
556  mPet = info;
557 }

References Actions::info(), and mPet.

Referenced by EAthena::PetRecv::processPetData(), and EAthena::PetHandler::returnToEgg().

◆ setPetBeing()

void PlayerInfo::setPetBeing ( Being *const  being)

Definition at line 559 of file playerinfo.cpp.

560 {
561  if (being != nullptr)
562  mPetBeingId = being->getId();
563  else
565  if (being == nullptr ||
566  mPet == nullptr)
567  {
568  return;
569  }
570  being->setName(mPet->name);
571  being->setOwner(localPlayer);
572  being->setLevel(mPet->level);
573 }

References BeingId_zero, ActorSprite::getId(), PetInfo::level, localPlayer, mPet, mPetBeingId, PetInfo::name, Being::setLevel(), Being::setName(), and Being::setOwner().

Referenced by EAthena::BeingRecv::createBeing2(), and EAthena::PetRecv::processPetData().

◆ setRoomName()

void PlayerInfo::setRoomName ( const std::string &  name)

◆ setServerLanguage()

void PlayerInfo::setServerLanguage ( const int  lang)

Definition at line 667 of file playerinfo.cpp.

668 {
669  if (lang != mServerLanguage)
670  {
671  mServerLanguage = lang;
673  }
674 }

References TranslationManager::loadDictionaryLang(), and mServerLanguage.

Referenced by EAthena::BeingRecv::processBeingAttrs().

◆ setSkillLevel()

void PlayerInfo::setSkillLevel ( const int  id,
const int  value 
)

◆ setStatBase()

void PlayerInfo::setStatBase ( const AttributesT  id,
const int  value,
const Notify  notify 
)

◆ setStatMod()

void PlayerInfo::setStatMod ( const AttributesT  id,
const int  value,
const Notify  notify 
)

◆ setTrading()

void PlayerInfo::setTrading ( const Trading  trading)

◆ stateChange()

void PlayerInfo::stateChange ( const StateT  state)

◆ triggerAttr()

void PlayerInfo::triggerAttr ( const AttributesT  id,
const int64_t  old 
)

Definition at line 77 of file playerinfo.cpp.

79 {
81  mData.mAttributes.find(id)->second);
82 }

References AttributeListener::distributeEvent(), PlayerInfoBackend::mAttributes, and mData.

Referenced by setAttribute().

◆ triggerStat()

void PlayerInfo::triggerStat ( const AttributesT  id,
const int  old1,
const int  old2 
)

Definition at line 84 of file playerinfo.cpp.

87 {
88  StatListener::distributeEvent(id, old1, old2);
89 }

References StatListener::distributeEvent().

Referenced by setStatBase(), and setStatMod().

◆ unequipItem()

void PlayerInfo::unequipItem ( const Item *const  item,
const Sfx  sfx 
)

◆ unprotectItem()

void PlayerInfo::unprotectItem ( const int  id)

Definition at line 508 of file playerinfo.cpp.

509 {
510  mProtectedItems.erase(id);
512 }

References mProtectedItems, and saveProtectedItems().

◆ updateAttackAi()

void PlayerInfo::updateAttackAi ( const BeingId  targetId,
const Keep  keep 
)

Definition at line 617 of file playerinfo.cpp.

619 {
620  if (mMercenary != nullptr &&
621  mercenaryHandler != nullptr)
622  {
623  mercenaryHandler->attack(targetId, keep);
624  }
625  if (mHomunculus != nullptr &&
626  homunculusHandler != nullptr)
627  {
628  homunculusHandler->attack(targetId, keep);
629  }
630 }

References Net::MercenaryHandler::attack(), Net::HomunculusHandler::attack(), homunculusHandler, mercenaryHandler, mHomunculus, and mMercenary.

Referenced by LocalPlayer::attack().

◆ updateAttrs()

void PlayerInfo::updateAttrs ( )

◆ useEquipItem()

void PlayerInfo::useEquipItem ( const Item *const  item,
const int16_t  useType,
const Sfx  sfx 
)

Definition at line 261 of file playerinfo.cpp.

264 {
265  if (item != nullptr)
266  {
267  if (item->getType() == ItemType::Card)
268  {
269  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
270  {
271  if (inventoryHandler != nullptr)
272  inventoryHandler->useCard(item);
273  if (sfx == Sfx_true)
275  }
276  }
277  else if (item->isEquipment() == Equipm_true)
278  {
279  if (item->isEquipped() == Equipped_true)
280  {
281  if (sfx == Sfx_true)
283  if (inventoryHandler != nullptr)
285  }
286  else
287  {
288  if (sfx == Sfx_true)
290  if (inventoryHandler != nullptr)
292  }
293  }
294  else
295  {
296  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
297  {
298  if (inventoryHandler != nullptr)
299  {
300  if (useType == 0)
301  inventoryHandler->useItem(item);
302  else
303  inventoryHandler->useItem(item, useType);
304  }
305  if (sfx == Sfx_true)
307  }
308  }
309  }
310 }

References ItemType::Card, ItemSoundEvent::EQUIP, Net::InventoryHandler::equipItem(), Equipm_true, Equipped_true, Item::getId(), Item::getType(), inventoryHandler, Item::isEquipment(), Item::isEquipped(), mProtectedItems, ItemSoundManager::playSfx(), Sfx_true, ItemSoundEvent::UNEQUIP, Net::InventoryHandler::unequipItem(), ItemSoundEvent::USE, ItemSoundEvent::USECARD, Net::InventoryHandler::useCard(), and Net::InventoryHandler::useItem().

Referenced by InventoryWindow::action(), InventoryWindow::mouseClicked(), and ItemShortcut::useItem().

◆ useEquipItem2()

void PlayerInfo::useEquipItem2 ( const Item *const  item,
const int16_t  useType,
const Sfx  sfx 
)

Definition at line 312 of file playerinfo.cpp.

315 {
316  if (item != nullptr)
317  {
318  if (item->isEquipment() == Equipm_false)
319  {
320  if (item->isEquipped() == Equipped_true)
321  {
322  if (sfx == Sfx_true)
324  if (inventoryHandler != nullptr)
326  }
327  else
328  {
329  if (sfx == Sfx_true)
331  if (inventoryHandler != nullptr)
333  }
334  }
335  else
336  {
337  if (mProtectedItems.find(item->getId()) == mProtectedItems.end())
338  {
339  if (sfx == Sfx_true)
341  if (inventoryHandler != nullptr)
342  {
343  if (useType == 0)
344  inventoryHandler->useItem(item);
345  else
346  inventoryHandler->useItem(item, useType);
347  }
348  }
349  }
350  }
351 }

References ItemSoundEvent::EQUIP, Net::InventoryHandler::equipItem(), Equipm_false, Equipped_true, Item::getId(), inventoryHandler, Item::isEquipment(), Item::isEquipped(), mProtectedItems, ItemSoundManager::playSfx(), Sfx_true, ItemSoundEvent::UNEQUIP, Net::InventoryHandler::unequipItem(), ItemSoundEvent::USE, and Net::InventoryHandler::useItem().

Referenced by InventoryWindow::action().

◆ useItem()

void PlayerInfo::useItem ( const Item *const  item,
const Sfx  sfx 
)

Definition at line 253 of file playerinfo.cpp.

254 {
255  if (sfx == Sfx_true)
257  if (inventoryHandler != nullptr)
258  inventoryHandler->useItem(item);
259 }

References inventoryHandler, ItemSoundManager::playSfx(), Sfx_true, ItemSoundEvent::USE, and Net::InventoryHandler::useItem().

Variable Documentation

◆ mCartInventory

Inventory* PlayerInfo::mCartInventory = 0

Definition at line 59 of file playerinfo.cpp.

Referenced by gameDestroyed(), getCartInventory(), and stateChange().

◆ mCharId

int PlayerInfo::mCharId = 0

Definition at line 56 of file playerinfo.cpp.

Referenced by getCharId(), and setCharId().

◆ mData

PlayerInfoBackend PlayerInfo::mData

◆ mElementalId

BeingId PlayerInfo::mElementalId = BeingId_zero

Definition at line 67 of file playerinfo.cpp.

Referenced by getElementalId(), and setElemental().

◆ mEquipment

Equipment* PlayerInfo::mEquipment = 0

◆ mGuildPositionFlags

GuildPositionFlags::Type PlayerInfo::mGuildPositionFlags = GuildPositionFlags::None

Definition at line 66 of file playerinfo.cpp.

Referenced by getGuildPositionFlags(), and setGuildPositionFlags().

◆ mHomunculus

HomunculusInfo* PlayerInfo::mHomunculus = 0

◆ mInventory

Inventory* PlayerInfo::mInventory = 0

Definition at line 58 of file playerinfo.cpp.

Referenced by clearInventory(), gameDestroyed(), getInventory(), and stateChange().

◆ mLevelProgress

int PlayerInfo::mLevelProgress = 0

Definition at line 71 of file playerinfo.cpp.

◆ mMercenary

MercenaryInfo* PlayerInfo::mMercenary = 0

◆ mPet

PetInfo* PlayerInfo::mPet = 0

Definition at line 62 of file playerinfo.cpp.

Referenced by getPet(), setPet(), and setPetBeing().

◆ mPetBeingId

BeingId PlayerInfo::mPetBeingId = BeingId_zero

Definition at line 65 of file playerinfo.cpp.

Referenced by clear(), deinit(), getPetBeingId(), and setPetBeing().

◆ mProtectedItems

std::set<int> PlayerInfo::mProtectedItems

◆ mRoomName

std::string PlayerInfo::mRoomName

Definition at line 63 of file playerinfo.cpp.

Referenced by getRoomName(), isInRoom(), and setRoomName().

◆ mServerLanguage

int PlayerInfo::mServerLanguage = -1

Definition at line 72 of file playerinfo.cpp.

Referenced by getServerLanguage(), and setServerLanguage().

◆ mTrading

Trading PlayerInfo::mTrading = Trading_false

Definition at line 69 of file playerinfo.cpp.

Referenced by isTrading(), and setTrading().

◆ mVending

bool PlayerInfo::mVending = false

Definition at line 70 of file playerinfo.cpp.

Referenced by enableVending(), and isVending().

PlayerInfoBackend::mSkills
IntMap mSkills
Definition: playerinfo.h:74
MercenaryInfo::level
int level
Definition: mercenaryinfo.h:42
MercenaryInfo::name
std::string name
Definition: mercenaryinfo.h:40
Equipment::setBackend
void setBackend(Backend *const backend)
Definition: equipment.h:87
State::GAME
@ GAME
Definition: state.h:48
PlayerInfoBackend::mStats
StatMap mStats
Definition: playerinfo.h:73
PetInfo::level
int level
Definition: petinfo.h:48
PlayerInfo::mCartInventory
Inventory * mCartInventory
Definition: playerinfo.cpp:59
Attributes::HOMUN_ATTACK_DELAY
@ HOMUN_ATTACK_DELAY
Definition: attributes.h:77
ItemSoundEvent::EQUIP
@ EQUIP
Definition: itemsoundevent.h:40
Net::InventoryHandler::dropItem
virtual void dropItem(const Item *const item, const int amount) const =0
Attributes::PLAYER_ATK
@ PLAYER_ATK
Definition: attributes.h:62
Equipm_false
const bool Equipm_false
Definition: equipm.h:29
DragDropSource::Equipment
@ Equipment
Definition: dragdropsource.h:39
PlayerInfo::triggerStat
void triggerStat(const AttributesT id, const int old1, const int old2)
Definition: playerinfo.cpp:84
updateAttackStat
#define updateAttackStat(atk, delay, speed)
Definition: playerinfo.cpp:400
Net::InventoryHandler::equipItem
virtual void equipItem(const Item *const item) const =0
DragDropSource::Inventory
@ Inventory
Definition: dragdropsource.h:29
Attributes::HOMUN_ATTACK_SPEED
@ HOMUN_ATTACK_SPEED
Definition: attributes.h:79
Attributes::PLAYER_ATTACK_SPEED
@ PLAYER_ATTACK_SPEED
Definition: attributes.h:53
Net::HomunculusHandler::attack
virtual void attack(const BeingId targetId, const Keep keep) const =0
TranslationManager::loadDictionaryLang
static void loadDictionaryLang()
Definition: translationmanager.cpp:51
PlayerInfo::mMercenary
MercenaryInfo * mMercenary
Definition: playerinfo.cpp:60
StatListener::distributeEvent
static void distributeEvent(const AttributesT id, const int oldVal1, const int oldVal2)
Definition: statlistener.cpp:29
Attributes::HOMUN_ATK
@ HOMUN_ATK
Definition: attributes.h:86
settings
Settings settings
Definition: settings.cpp:31
Item::isEquipment
Equipm isEquipment() const
Definition: item.h:116
Net::InventoryHandler::unequipItem
virtual void unequipItem(const Item *const item) const =0
ActorSprite::getId
BeingId getId() const
Definition: actorsprite.h:63
AttributeListener::distributeEvent
static void distributeEvent(const AttributesT id, const int64_t oldVal, const int64_t newVal)
Definition: attributelistener.cpp:29
Item::getId
int getId() const
Definition: item.h:80
PlayerInfo::mVending
bool mVending
Definition: playerinfo.cpp:70
PlayerInfo::mProtectedItems
std::set< int > mProtectedItems
Definition: playerinfo.cpp:73
PlayerInfo::mHomunculus
HomunculusInfo * mHomunculus
Definition: playerinfo.cpp:61
NotifyManager::notify
void notify(const unsigned int message)
Definition: notifymanager.cpp:81
MercenaryInfo::range
int range
Definition: mercenaryinfo.h:43
playerHandler
Net::PlayerHandler * playerHandler
Definition: net.cpp:95
PlayerInfo::mPetBeingId
BeingId mPetBeingId
Definition: playerinfo.cpp:65
InventoryType::Cart
@ Cart
Definition: inventorytype.h:34
NpcDialog::isActive
static bool isActive()
Definition: npcdialog.h:190
Net::InventoryHandler::useItem
virtual void useItem(const Item *const item) const =0
inventoryHandler
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:88
Attributes::MERC_ATTACK_DELAY
@ MERC_ATTACK_DELAY
Definition: attributes.h:94
delete2
#define delete2(var)
Definition: delete2.h:24
mercenaryHandler
Net::MercenaryHandler * mercenaryHandler
Definition: net.cpp:117
Equipment::clear
void clear()
Definition: equipment.h:77
Catch::toString
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
Item::getType
ItemTypeT getType() const
Definition: item.h:224
Configuration::setValue
void setValue(const std::string &key, const std::string &value)
Definition: configuration.cpp:238
Actions::info
bool info(InputEvent &event)
Definition: commands.cpp:56
ItemSoundEvent::USE
@ USE
Definition: itemsoundevent.h:42
Being::setOwner
void setOwner(Being *const owner)
Definition: being.h:910
localPlayer
LocalPlayer * localPlayer
Definition: localplayer.cpp:108
Net::MercenaryHandler::attack
virtual void attack(const BeingId targetId, const Keep keep) const =0
PlayerInfo::mServerLanguage
int mServerLanguage
Definition: playerinfo.cpp:72
Notify_true
const bool Notify_true
Definition: notify.h:29
ItemSoundEvent::USECARD
@ USECARD
Definition: itemsoundevent.h:43
MercenaryInfo::id
BeingId id
Definition: mercenaryinfo.h:41
Attributes::MERC_ATK
@ MERC_ATK
Definition: attributes.h:103
PetInfo::name
std::string name
Definition: petinfo.h:46
ItemSoundEvent::PICKUP
@ PICKUP
Definition: itemsoundevent.h:37
Configuration::getStringValue
std::string getStringValue(const std::string &key) const
Definition: configuration.cpp:487
serverConfig
Configuration serverConfig
Definition: configuration.cpp:52
Settings::fixedInventorySize
unsigned int fixedInventorySize
Definition: settings.h:147
PlayerInfo::triggerAttr
void triggerAttr(const AttributesT id, const int64_t old)
Definition: playerinfo.cpp:77
Equipment::getEquipment
const Item * getEquipment(const int index) const
Definition: equipment.h:68
PlayerInfo::mInventory
Inventory * mInventory
Definition: playerinfo.cpp:58
PlayerInfo::saveProtectedItems
static void saveProtectedItems()
Definition: playerinfo.cpp:483
Configuration::write
void write()
Definition: configuration.cpp:858
homunculusHandler
Net::HomunculusHandler * homunculusHandler
Definition: net.cpp:111
HomunculusInfo::name
std::string name
Definition: homunculusinfo.h:44
Net::PlayerHandler::pickUp
virtual void pickUp(const FloorItem *const floorItem) const =0
ItemSoundEvent::DROP
@ DROP
Definition: itemsoundevent.h:36
PlayerInfo::mCharId
int mCharId
Definition: playerinfo.cpp:56
InventoryWindow::isStorageActive
static bool isStorageActive()
Definition: inventorywindow.h:137
ItemType::Card
@ Card
Definition: itemtype.h:34
Attributes::MERC_ATTACK_SPEED
@ MERC_ATTACK_SPEED
Definition: attributes.h:96
Attributes::PLAYER_ATTACK_DELAY
@ PLAYER_ATTACK_DELAY
Definition: attributes.h:50
Net::InventoryHandler::useCard
virtual void useCard(const Item *const item)=0
Equipped_true
const bool Equipped_true
Definition: equipped.h:29
Being::setName
void setName(const std::string &name)
Definition: being.cpp:1135
PlayerInfo::mData
PlayerInfoBackend mData
Definition: playerinfo.cpp:55
Net::InventoryHandler::getStorage
virtual Inventory * getStorage() const =0
Being::setLevel
void setLevel(const int n)
Definition: being.h:600
Item::isEquipped
Equipped isEquipped() const
Definition: item.h:128
Equipm_true
const bool Equipm_true
Definition: equipm.h:29
Inventory::clear
void clear()
Definition: inventory.cpp:237
CAST_S32
#define CAST_S32
Definition: cast.h:29
PlayerInfo::mRoomName
std::string mRoomName
Definition: playerinfo.cpp:63
ItemSoundEvent::UNEQUIP
@ UNEQUIP
Definition: itemsoundevent.h:41
BeingId_zero
const BeingId BeingId_zero
Definition: beingid.h:29
ItemSoundManager::playSfx
static void playSfx(const int item, const ItemSoundEvent::Type sound)
Definition: itemsoundmanager.cpp:42
Sfx_true
const bool Sfx_true
Definition: sfx.h:29
PlayerInfo::mEquipment
Equipment * mEquipment
Definition: playerinfo.cpp:64
PlayerInfoBackend::mAttributes
AtrIntMap mAttributes
Definition: playerinfo.h:72
Being::setAttackRange
void setAttackRange(const int range)
Definition: being.h:842
PlayerInfo::mElementalId
BeingId mElementalId
Definition: playerinfo.cpp:67
PlayerInfo::mTrading
Trading mTrading
Definition: playerinfo.cpp:69
InventoryType::Inventory
@ Inventory
Definition: inventorytype.h:30
HomunculusInfo::id
BeingId id
Definition: homunculusinfo.h:45
PlayerInfo::clearInventory
void clearInventory()
Definition: playerinfo.cpp:211
splitToIntSet
void splitToIntSet(std::set< int > &tokens, const std::string &text, const char separator)
Definition: stringutils.cpp:450
PlayerInfo::mPet
PetInfo * mPet
Definition: playerinfo.cpp:62
PlayerInfo::mGuildPositionFlags
GuildPositionFlags::Type mGuildPositionFlags
Definition: playerinfo.cpp:66