ManaPlus
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
ActorManager Class Reference

#include <actormanager.h>

Inheritance diagram for ActorManager:
ConfigListener

Public Member Functions

 ActorManager ()
 
 ~ActorManager ()
 
void setMap (Map *const map)
 
void setPlayer (LocalPlayer *const player)
 
BeingcreateBeing (const BeingId id, const ActorTypeT type, const BeingTypeId subtype)
 
FloorItemcreateItem (const BeingId id, const int itemId, const int x, const int y, const ItemTypeT itemType, const int amount, const int refine, const ItemColor color, const Identified identified, const Damaged damaged, const int subX, const int subY, const int *const cards)
 
void destroy (ActorSprite *const actor)
 
void erase (ActorSprite *const actor)
 
void undelete (const ActorSprite *const actor)
 
BeingfindBeing (const BeingId id) const
 
ActorSpritefindActor (const BeingId id) const
 
BeingfindBeing (const int x, const int y, const ActorTypeT type) const
 
BeingfindBeingByPixel (const int x, const int y, const AllPlayers allPlayers) const
 
void findBeingsByPixel (std::vector< ActorSprite * > &beings, const int x, const int y, const AllPlayers allPlayers) const
 
BeingfindPortalByTile (const int x, const int y) const
 
FloorItemfindItem (const BeingId id) const
 
FloorItemfindItem (const int x, const int y) const
 
BeingfindNearestLivingBeing (const int x, const int y, int maxTileDist, const ActorTypeT type, const Being *const excluded) const
 
BeingfindNearestLivingBeing (const Being *const aroundBeing, const int maxTileDist, const ActorTypeT type, const AllowSort allowSort) const
 
BeingfindBeingByName (const std::string &name, const ActorTypeT type) const
 
BeingfindNearestByName (const std::string &name, const ActorTypeT &type) const
 
BeingfindMostDamagedPlayer (const int maxTileDist) const
 
BeingfindNearestPvpPlayer () const
 
void healTarget () const
 
void heal (const Being *const target) const
 
void itenplz () const
 
const ActorSpritesgetAll () const A_CONST
 
bool hasActorSprite (const ActorSprite *const actor) const
 
void logic ()
 
void clear ()
 
void addBlock (const BeingId id)
 
void deleteBlock (const BeingId id)
 
bool isBlocked (const BeingId id) const
 
void printAllToChat ()
 
void printBeingsToChat (const std::string &header) const
 
void getPlayerNames (StringVect &names, const NpcNames npcNames) const
 
void getMobNames (StringVect &names) const
 
void updatePlayerNames () const
 
void updatePlayerColors () const
 
void updatePlayerGuild () const
 
void parseLevels (std::string levels) const
 
bool pickUpAll (const int x1, const int y1, const int x2, const int y2, const bool serverBuggy) const
 
bool pickUpNearest (const int x, const int y, int maxdist) const
 
void optionChanged (const std::string &name)
 
void removeAttackMob (const std::string &name)
 
void removePickupItem (const std::string &name)
 
void addPriorityAttackMob (const std::string &name)
 
void addAttackMob (const std::string &name)
 
void addIgnoreAttackMob (const std::string &name)
 
void addPickupItem (const std::string &name)
 
void addIgnorePickupItem (const std::string &name)
 
void setPriorityAttackMobs (const std::list< std::string > &mobs)
 
void setAttackMobs (const std::list< std::string > &mobs)
 
int getPriorityAttackMobsSize () const
 
int getAttackMobsSize () const
 
int getPickupItemsSize () const
 
bool isInAttackList (const std::string &name) const
 
void rebuildAttackMobs ()
 
std::set< std::string > getAttackMobsSet () const
 
std::list< std::string > getAttackMobs () const
 
bool isInPriorityAttackList (const std::string &name) const
 
void rebuildPriorityAttackMobs ()
 
std::set< std::string > getPriorityAttackMobsSet () const
 
std::list< std::string > getPriorityAttackMobs () const
 
bool isInIgnoreAttackList (const std::string &name) const
 
void rebuildIgnoreAttackMobs ()
 
std::set< std::string > getIgnoreAttackMobsSet () const
 
std::list< std::string > getIgnoreAttackMobs () const
 
bool isInPickupList (const std::string &name) const
 
void rebuildPickupItems ()
 
std::set< std::string > getPickupItemsSet () const
 
std::list< std::string > getPickupItems () const
 
bool isInIgnorePickupList (const std::string &name) const
 
void rebuildIgnorePickupItems ()
 
std::set< std::string > getIgnorePickupItemsSet () const
 
std::list< std::string > getIgnorePickupItems () const
 
const StringIntMapgetAttackMobsMap () const
 
const StringIntMapgetPriorityAttackMobsMap () const
 
int getAttackMobIndex (const std::string &name) const
 
int getPriorityAttackMobIndex (const std::string &name) const
 
int getPickupItemIndex (const std::string &name) const
 
bool checkForPickup (const FloorItem *const item) const
 
bool checkDefaultPickup () const
 
void updateEffects (const std::map< BeingTypeId, int > &addEffects, const std::set< BeingTypeId > &removeEffects) const
 
void updateBadges () const
 
void updateNameId (const std::string &name, const BeingId beingId)
 
void updateSeenPlayers (const std::set< std::string > &onlinePlayers)
 
std::string getSeenPlayerById (const BeingId id) const
 
size_t size () const
 
void removeRoom (const int chatId)
 
void updateRoom (const ChatObject *const newChat)
 
std::string findCharById (const int32_t id)
 
void addChar (const int32_t id, const std::string &name)
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 

Static Public Member Functions

static BeingcloneBeing (const Being *const srcBeing, const int dx, const int dy, const int id)
 
static void printBeingsToChat (const std::vector< Being * > &beings, const std::string &header)
 
static int getIndexByName (const std::string &name, const StringIntMap &map)
 

Protected Member Functions

bool validateBeing (const Being *const aroundBeing, Being *const being, const ActorTypeT &type, const Being *const excluded, const int maxCost) const
 
BeingfindNearestLivingBeing (const Being *const aroundBeing, const int maxdist, const ActorTypeT &type, const int x, const int y, const Being *const excluded, const AllowSort allowSort) const
 
void loadAttackList ()
 
void storeAttackList () const
 

Protected Attributes

ActorSprites mActors
 
ActorSprites mDeleteActors
 
ActorSpritesMap mActorsIdMap
 
IdNameMapping mIdName
 
std::set< BeingIdmBlockedBeings
 
std::map< int32_t, std::string > mChars
 
MapmMap
 
std::string mSpellHeal1
 
std::string mSpellHeal2
 
std::string mSpellItenplz
 
bool mTargetDeadPlayers
 
bool mTargetOnlyReachable
 
bool mCyclePlayers
 
bool mCycleMonsters
 
bool mCycleNPC
 
bool mExtMouseTargeting
 
bool mEnableIdCollecting
 
std::list< std::string > mPriorityAttackMobs
 
std::set< std::string > mPriorityAttackMobsSet
 
StringIntMap mPriorityAttackMobsMap
 
std::list< std::string > mAttackMobs
 
std::set< std::string > mAttackMobsSet
 
StringIntMap mAttackMobsMap
 
std::list< std::string > mIgnoreAttackMobs
 
std::set< std::string > mIgnoreAttackMobsSet
 
std::list< std::string > mPickupItems
 
std::set< std::string > mPickupItemsSet
 
StringIntMap mPickupItemsMap
 
std::list< std::string > mIgnorePickupItems
 
std::set< std::string > mIgnorePickupItemsSet
 

Detailed Description

Definition at line 69 of file actormanager.h.

Constructor & Destructor Documentation

◆ ActorManager()

ActorManager::ActorManager ( )

Definition at line 209 of file actormanager.cpp.

209  :
210  mActors(),
211  mDeleteActors(),
212  mActorsIdMap(),
213  mIdName(),
214  mBlockedBeings(),
215  mChars(),
216  mMap(nullptr),
217 #ifdef TMWA_SUPPORT
218  mSpellHeal1(serverConfig.getValue("spellHeal1", "#lum")),
219  mSpellHeal2(serverConfig.getValue("spellHeal2", "#inma")),
220  mSpellItenplz(serverConfig.getValue("spellItenplz", "#itenplz")),
221 #endif // TMWA_SUPPORT
222  mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
223  mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
224  mCyclePlayers(config.getBoolValue("cyclePlayers")),
225  mCycleMonsters(config.getBoolValue("cycleMonsters")),
226  mCycleNPC(config.getBoolValue("cycleNPC")),
227  mExtMouseTargeting(config.getBoolValue("extMouseTargeting")),
228  mEnableIdCollecting(config.getBoolValue("enableIdCollecting")),
232  mAttackMobs(),
233  mAttackMobsSet(),
234  mAttackMobsMap(),
237  mPickupItems(),
238  mPickupItemsSet(),
239  mPickupItemsMap(),
242 {
243  config.addListener("targetDeadPlayers", this);
244  config.addListener("targetOnlyReachable", this);
245  config.addListener("cyclePlayers", this);
246  config.addListener("cycleMonsters", this);
247  config.addListener("cycleNPC", this);
248  config.addListener("extMouseTargeting", this);
249  config.addListener("showBadges", this);
250  config.addListener("enableIdCollecting", this);
251  config.addListener("visiblenamespos", this);
252 
253  loadAttackList();
254 }
ActorSprites mDeleteActors
Definition: actormanager.h:415
std::set< std::string > mIgnoreAttackMobsSet
Definition: actormanager.h:448
IdNameMapping mIdName
Definition: actormanager.h:417
std::list< std::string > mIgnorePickupItems
Definition: actormanager.h:449
bool mCycleMonsters
Definition: actormanager.h:430
bool mEnableIdCollecting
Definition: actormanager.h:433
std::string mSpellHeal1
Definition: actormanager.h:422
bool mCyclePlayers
Definition: actormanager.h:429
bool mExtMouseTargeting
Definition: actormanager.h:432
bool mTargetOnlyReachable
Definition: actormanager.h:428
std::list< std::string > mPickupItems
Definition: actormanager.h:449
std::set< std::string > mIgnorePickupItemsSet
Definition: actormanager.h:449
bool mTargetDeadPlayers
Definition: actormanager.h:427
std::list< std::string > mAttackMobs
Definition: actormanager.h:448
std::string mSpellItenplz
Definition: actormanager.h:424
std::list< std::string > mIgnoreAttackMobs
Definition: actormanager.h:448
std::set< std::string > mPriorityAttackMobsSet
Definition: actormanager.h:447
ActorSprites mActors
Definition: actormanager.h:414
StringIntMap mAttackMobsMap
Definition: actormanager.h:448
std::set< std::string > mPickupItemsSet
Definition: actormanager.h:449
std::string mSpellHeal2
Definition: actormanager.h:423
std::set< BeingId > mBlockedBeings
Definition: actormanager.h:418
std::list< std::string > mPriorityAttackMobs
Definition: actormanager.h:447
void loadAttackList()
std::set< std::string > mAttackMobsSet
Definition: actormanager.h:448
StringIntMap mPriorityAttackMobsMap
Definition: actormanager.h:447
ActorSpritesMap mActorsIdMap
Definition: actormanager.h:416
StringIntMap mPickupItemsMap
Definition: actormanager.h:449
std::map< int32_t, std::string > mChars
Definition: actormanager.h:419
std::string getValue(const std::string &key, const std::string &deflt) const
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
Configuration config
Configuration serverConfig

References Configuration::addListener(), config, and loadAttackList().

◆ ~ActorManager()

ActorManager::~ActorManager ( )

Definition at line 256 of file actormanager.cpp.

257 {
258  config.removeListeners(this);
260  storeAttackList();
261  clear();
262 }
void storeAttackList() const
void removeListeners(ConfigListener *const listener)
#define CHECKLISTENERS
Definition: localconsts.h:277

References CHECKLISTENERS, clear(), config, Configuration::removeListeners(), and storeAttackList().

Member Function Documentation

◆ addAttackMob()

void ActorManager::addAttackMob ( const std::string &  name)

Definition at line 1921 of file actormanager.cpp.

1922 {
1923  addMobToList(name, AttackMob)
1925  storeAttackList();
1926 }
#define addMobToList(name, mob)
void rebuildPriorityAttackMobs()

References addMobToList, rebuildPriorityAttackMobs(), and storeAttackList().

◆ addBlock()

void ActorManager::addBlock ( const BeingId  id)

Definition at line 1572 of file actormanager.cpp.

1573 {
1574  mBlockedBeings.insert(id);
1575 }

References mBlockedBeings.

◆ addChar()

void ActorManager::addChar ( const int32_t  id,
const std::string &  name 
)

Definition at line 2274 of file actormanager.cpp.

2276 {
2277  mChars[id] = name;
2278 
2279  if (guiInput == nullptr)
2280  return;
2281 
2282  if (localPlayer != nullptr)
2283  {
2284  Guild *const guild = localPlayer->getGuild();
2285  if (guild != nullptr)
2286  {
2287  GuildMember *const member = guild->getMemberByCharId(id);
2288  if (member != nullptr)
2289  member->setName(name);
2290  }
2291  }
2293 }
void setName(const std::string &name)
Definition: avatar.h:59
const Guild * getGuild(const std::string &guildName) const
Definition: being.cpp:1258
Definition: guild.h:70
void simulateMouseMove()
Definition: sdlinput.cpp:380
LocalPlayer * localPlayer
uint32_t guild
SDLInput * guiInput
Definition: sdlinput.cpp:101

References Being::getGuild(), guiInput, guild, localPlayer, mChars, Avatar::setName(), and SDLInput::simulateMouseMove().

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

◆ addIgnoreAttackMob()

void ActorManager::addIgnoreAttackMob ( const std::string &  name)

Definition at line 1934 of file actormanager.cpp.

1935 {
1936  mIgnoreAttackMobs.push_back(name);
1937  mIgnoreAttackMobsSet.insert(name);
1940  storeAttackList();
1941 }
void rebuildAttackMobs()

References mIgnoreAttackMobs, mIgnoreAttackMobsSet, rebuildAttackMobs(), rebuildPriorityAttackMobs(), and storeAttackList().

◆ addIgnorePickupItem()

void ActorManager::addIgnorePickupItem ( const std::string &  name)

Definition at line 1950 of file actormanager.cpp.

1951 {
1952  mIgnorePickupItems.push_back(name);
1953  mIgnorePickupItemsSet.insert(name);
1955  storeAttackList();
1956 }
void rebuildPickupItems()

References mIgnorePickupItems, mIgnorePickupItemsSet, rebuildPickupItems(), and storeAttackList().

◆ addPickupItem()

void ActorManager::addPickupItem ( const std::string &  name)

Definition at line 1943 of file actormanager.cpp.

1944 {
1945  addMobToList(name, PickupItem)
1947  storeAttackList();
1948 }

References addMobToList, rebuildPickupItems(), and storeAttackList().

◆ addPriorityAttackMob()

void ActorManager::addPriorityAttackMob ( const std::string &  name)

Definition at line 1928 of file actormanager.cpp.

1929 {
1930  addMobToList(name, PriorityAttackMob)
1931  storeAttackList();
1932 }

References addMobToList, and storeAttackList().

◆ checkDefaultPickup()

bool ActorManager::checkDefaultPickup ( ) const

Definition at line 2071 of file actormanager.cpp.

2072 {
2073  return mPickupItemsSet.find(std::string()) != mPickupItemsSet.end();
2074 }

References mPickupItemsSet.

◆ checkForPickup()

bool ActorManager::checkForPickup ( const FloorItem *const  item) const

Definition at line 2053 of file actormanager.cpp.

2054 {
2055  if (mPickupItemsSet.find(std::string()) != mPickupItemsSet.end())
2056  {
2057  if (mIgnorePickupItemsSet.find(item->getName())
2058  == mIgnorePickupItemsSet.end())
2059  {
2060  return true;
2061  }
2062  }
2063  else if ((item != nullptr) && mPickupItemsSet.find(item->getName())
2064  != mPickupItemsSet.end())
2065  {
2066  return true;
2067  }
2068  return false;
2069 }
std::string getName() const
Definition: flooritem.cpp:146

References FloorItem::getName(), mIgnorePickupItemsSet, and mPickupItemsSet.

Referenced by createItem(), and LocalPlayer::pickUp().

◆ clear()

void ActorManager::clear ( )

Destroys all ActorSprites except the local player

Definition at line 1006 of file actormanager.cpp.

1007 {
1008  if (beingEquipmentWindow != nullptr)
1009  beingEquipmentWindow->setBeing(nullptr);
1010 
1011  if (localPlayer != nullptr)
1012  {
1013  localPlayer->setTarget(nullptr);
1015  mActors.erase(localPlayer);
1016  }
1017 
1018  for_actors
1019  delete *it;
1020  mActors.clear();
1021  mDeleteActors.clear();
1022  mActorsIdMap.clear();
1023 
1024  if (localPlayer != nullptr)
1025  {
1026  mActors.insert(localPlayer);
1028  }
1029 
1030  mChars.clear();
1031 }
#define for_actors
BeingId getId() const
Definition: actorsprite.h:64
void setBeing(Being *const being)
void setTarget(Being *const target)
void unSetPickUpTarget()
Definition: localplayer.h:325
EquipmentWindow * beingEquipmentWindow

References beingEquipmentWindow, for_actors, ActorSprite::getId(), localPlayer, mActors, mActorsIdMap, mChars, mDeleteActors, EquipmentWindow::setBeing(), LocalPlayer::setTarget(), and LocalPlayer::unSetPickUpTarget().

Referenced by Game::changeMap(), and ~ActorManager().

◆ cloneBeing()

Being * ActorManager::cloneBeing ( const Being *const  srcBeing,
const int  dx,
const int  dy,
const int  id 
)
static

Definition at line 2098 of file actormanager.cpp.

2101 {
2102  returnNullptr(nullptr, srcBeing)
2103  Being *const dstBeing = actorManager->createBeing(fromInt(
2104  toInt(srcBeing->getId(), int) + id, BeingId),
2106  srcBeing->getSubType());
2107  if (dstBeing == nullptr)
2108  return nullptr;
2109  dstBeing->setGender(srcBeing->getGender());
2110  dstBeing->setAction(srcBeing->getCurrentAction(), 0);
2111  dstBeing->setTileCoords(srcBeing->getTileX() + dx,
2112  srcBeing->getTileY() + dy);
2113  dstBeing->setName(srcBeing->getName());
2114  dstBeing->setDirection(srcBeing->getDirection());
2115  const int sz = CAST_S32(srcBeing->mSprites.size());
2116  for (int slot = 0; slot < sz; slot ++)
2117  {
2118  const int spriteId = srcBeing->getSpriteID(slot);
2119  const ItemColor color = srcBeing->getSpriteColor(slot);
2120  dstBeing->setSpriteColorId(slot,
2121  spriteId,
2122  color);
2123  }
2124  const int hairSlot = charServerHandler->hairSprite();
2125  const int hairStyle = -srcBeing->getSpriteID(hairSlot);
2126  const ItemColor hairColor = srcBeing->getHairColor();
2127  if (hairStyle != 0)
2128  {
2129  dstBeing->setSpriteColor(hairSlot,
2130  hairStyle * -1,
2131  ItemDB::get(-hairStyle).getDyeColorsString(hairColor));
2132  }
2133  else
2134  {
2135  dstBeing->unSetSprite(hairSlot);
2136  }
2137  dstBeing->setHairColor(hairColor);
2138  return dstBeing;
2139 }
ActorManager * actorManager
int BeingId
Definition: beingid.h:30
#define CAST_S32
Definition: cast.h:30
Net::CharServerHandler * charServerHandler
Definition: net.cpp:85
#define returnNullptr(ret, val)
Definition: checkutils.h:259
Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype)
Definition: being.h:96
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1690
virtual void setAction(const BeingActionT &action, const int attackId)
Definition: being.cpp:1554
virtual void setTileCoords(const int x, const int y)
Definition: being.cpp:5010
int getTileX() const
Definition: being.h:168
uint8_t getDirection() const
Definition: being.h:494
BeingTypeId getSubType() const
Definition: being.h:400
int getTileY() const
Definition: being.h:174
int getSpriteID(const int slot) const
Definition: being.cpp:4894
ItemColor getHairColor() const
Definition: being.h:883
void setName(const std::string &name)
Definition: being.cpp:1136
void setHairColor(const unsigned int slot, const ItemColor color)
Definition: being.cpp:3389
const std::string & getName() const
Definition: being.h:232
virtual void setGender(const GenderT gender)
Definition: being.cpp:3581
void unSetSprite(const unsigned int slot)
Definition: being.cpp:2861
BeingActionT getCurrentAction() const
Definition: being.h:482
GenderT getGender() const
Definition: being.h:626
ItemColor getSpriteColor(const int slot) const
Definition: being.cpp:4910
void setSpriteColor(const unsigned int slot, const int id, const std::string &color)
Definition: being.cpp:2890
void setSpriteColorId(const unsigned int slot, const int id, ItemColor colorId)
Definition: being.cpp:2967
std::vector< Sprite * > mSprites
virtual unsigned int hairSprite() const =0
#define toInt(val, name)
Definition: intdefines.h:47
#define fromInt(val, name)
Definition: intdefines.h:46
uint16_t ItemColor
Definition: itemcolor.h:30
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792

References actorManager, CAST_S32, charServerHandler, createBeing(), fromInt, ItemDB::get(), Being::getCurrentAction(), Being::getDirection(), Being::getGender(), Being::getHairColor(), ActorSprite::getId(), Being::getName(), Being::getSpriteColor(), Being::getSpriteID(), Being::getSubType(), Being::getTileX(), Being::getTileY(), Net::CharServerHandler::hairSprite(), CompoundSprite::mSprites, ActorType::Player, returnNullptr, Being::setAction(), Being::setDirection(), Being::setGender(), Being::setHairColor(), Being::setName(), Being::setSpriteColor(), Being::setSpriteColorId(), Being::setTileCoords(), toInt, and Being::unSetSprite().

◆ createBeing()

Being * ActorManager::createBeing ( const BeingId  id,
const ActorTypeT  type,
const BeingTypeId  subtype 
)

Create a Being and add it to the list of ActorSprites.

Definition at line 283 of file actormanager.cpp.

286 {
287  Being *const being = Being::createBeing(id,
288  type,
289  subtype,
290  mMap);
291 
292  mActors.insert(being);
293 
294  mActorsIdMap[being->getId()] = being;
295 
296  switch (type)
297  {
298  case ActorType::Player:
300  case ActorType::Pet:
302  case ActorType::Npc:
303  being->updateFromCache();
304  if (beingHandler != nullptr)
306  if (localPlayer != nullptr)
307  localPlayer->checkNewName(being);
308  break;
309  case ActorType::Monster:
310 #ifdef TMWA_SUPPORT
312 #endif // TMWA_SUPPORT
313  {
315  }
316  break;
317  case ActorType::Portal:
318  if ((beingHandler != nullptr) &&
319  (serverFeatures != nullptr) &&
321  {
323  }
324  break;
326  if (beingHandler != nullptr)
328  break;
330  break;
331  default:
333  case ActorType::Avatar:
334  case ActorType::Unknown:
335  reportAlways("CreateBeing for unknown type %d", CAST_S32(type))
336  break;
337  }
338 
339  if (type == ActorType::Player)
340  {
341  if (socialWindow != nullptr)
343  }
344  else if (type == ActorType::Npc)
345  {
346  if (questsWindow != nullptr)
347  questsWindow->addEffect(being);
348  }
349  return being;
350 }
Net::BeingHandler * beingHandler
Definition: net.cpp:99
#define reportAlways(...)
Definition: checkutils.h:253
bool updateFromCache()
Definition: being.cpp:3464
static Being * createBeing(const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
Definition: being.cpp:5575
void checkNewName(Being *const being)
virtual void requestNameById(const BeingId id) const =0
virtual bool haveServerWarpNames() const =0
void addEffect(Being *const being)
void updateActiveList()
@ Mercenary
Definition: actortype.h:38
@ Homunculus
Definition: actortype.h:39
@ SkillUnit
Definition: actortype.h:40
@ Elemental
Definition: actortype.h:41
@ FloorItem
Definition: actortype.h:34
ServerTypeT getNetworkType()
Definition: net.cpp:189
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101
QuestsWindow * questsWindow
SocialWindow * socialWindow

References QuestsWindow::addEffect(), ActorType::Avatar, beingHandler, CAST_S32, LocalPlayer::checkNewName(), Being::createBeing(), ActorType::Elemental, ActorType::FloorItem, ActorSprite::getId(), Net::getNetworkType(), Net::ServerFeatures::haveServerWarpNames(), ActorType::Homunculus, localPlayer, mActors, mActorsIdMap, ActorType::Mercenary, mMap, ActorType::Monster, ActorType::Npc, ActorType::Pet, ActorType::Player, ActorType::Portal, questsWindow, reportAlways, Net::BeingHandler::requestNameById(), serverFeatures, ActorType::SkillUnit, socialWindow, ServerType::TMWATHENA, ActorType::Unknown, SocialWindow::updateActiveList(), and Being::updateFromCache().

Referenced by cloneBeing(), Ea::BeingRecv::createBeing(), and EAthena::BeingRecv::createBeing2().

◆ createItem()

FloorItem * ActorManager::createItem ( const BeingId  id,
const int  itemId,
const int  x,
const int  y,
const ItemTypeT  itemType,
const int  amount,
const int  refine,
const ItemColor  color,
const Identified  identified,
const Damaged  damaged,
const int  subX,
const int  subY,
const int *const  cards 
)

Create a FloorItem and add it to the list of ActorSprites.

Definition at line 352 of file actormanager.cpp.

363 {
364  FloorItem *const floorItem = new FloorItem(id,
365  itemId,
366  x, y,
367  itemType,
368  amount,
369  refine,
370  color,
371  identified,
372  damaged,
373  cards);
374  floorItem->postInit(mMap, subX, subY);
375 
376  if (!checkForPickup(floorItem))
377  floorItem->disableHightlight();
378  mActors.insert(floorItem);
379  mActorsIdMap[floorItem->getId()] = floorItem;
380  return floorItem;
381 }
bool checkForPickup(const FloorItem *const item) const
void disableHightlight()
Definition: flooritem.h:114
void postInit(Map *const map, int subX, int subY)
Definition: flooritem.cpp:81

References checkForPickup(), FloorItem::disableHightlight(), ActorType::FloorItem, ActorSprite::getId(), mActors, mActorsIdMap, mMap, FloorItem::postInit(), x, and y.

Referenced by EAthena::ItemRecv::processItemDropped(), TmwAthena::ItemRecv::processItemDropped(), EAthena::ItemRecv::processItemDropped2(), EAthena::ItemRecv::processItemVisible(), TmwAthena::ItemRecv::processItemVisible(), and EAthena::ItemRecv::processItemVisible2().

◆ deleteBlock()

void ActorManager::deleteBlock ( const BeingId  id)

Definition at line 1577 of file actormanager.cpp.

1578 {
1579  mBlockedBeings.erase(id);
1580 }

References mBlockedBeings.

◆ destroy()

void ActorManager::destroy ( ActorSprite *const  actor)

◆ erase()

void ActorManager::erase ( ActorSprite *const  actor)

Definition at line 393 of file actormanager.cpp.

394 {
395  returnNullptrV(actor)
396 
397  if (actor == localPlayer)
398  return;
399 
400  mActors.erase(actor);
401  const ActorSpritesMapIterator it = mActorsIdMap.find(actor->getId());
402  if (it != mActorsIdMap.end() && (*it).second == actor)
403  mActorsIdMap.erase(it);
404 }
ActorSpritesMap::iterator ActorSpritesMapIterator
Definition: actormanager.h:63

References ActorSprite::getId(), localPlayer, mActors, mActorsIdMap, and returnNullptrV.

Referenced by EAthena::BeingRecv::processBeingMove(), TmwAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingSpawn(), EAthena::BeingRecv::processBeingVisible(), and TmwAthena::BeingRecv::processBeingVisible().

◆ findActor()

ActorSprite * ActorManager::findActor ( const BeingId  id) const

Definition at line 439 of file actormanager.cpp.

440 {
441  const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
442  if (it != mActorsIdMap.end())
443  {
444  ActorSprite *const actor = (*it).second;
445  if ((actor != nullptr) &&
446  actor->getId() == id)
447  {
448  return actor;
449  }
450  }
451  return nullptr;
452 }
ActorSpritesMap::const_iterator ActorSpritesMapConstIterator
Definition: actormanager.h:64

References ActorSprite::getId(), and mActorsIdMap.

Referenced by Particle::~Particle().

◆ findBeing() [1/2]

Being * ActorManager::findBeing ( const BeingId  id) const

Returns a specific Being, by id;

Definition at line 423 of file actormanager.cpp.

424 {
425  const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
426  if (it != mActorsIdMap.end())
427  {
428  ActorSprite *const actor = (*it).second;
429  if ((actor != nullptr) &&
430  actor->getId() == id &&
431  actor->getType() != ActorType::FloorItem)
432  {
433  return static_cast<Being*>(actor);
434  }
435  }
436  return nullptr;
437 }
virtual ActorTypeT getType() const
Definition: actorsprite.h:73

References ActorType::FloorItem, ActorSprite::getId(), ActorSprite::getType(), and mActorsIdMap.

Referenced by BuySellDialog::action(), PopupMenu::addBeingMenu(), Actions::getPet(), PopupMenu::handleLink(), Viewport::moveCameraToActor(), NpcDialog::postInit(), EAthena::NpcRecv::processArea(), EAthena::BattleGroundRecv::processBattleEmblem2(), Ea::BeingRecv::processBeingAction(), EAthena::BeingRecv::processBeingAction2(), EAthena::BeingRecv::processBeingAttrs(), EAthena::BeingRecv::processBeingChangeDirection(), TmwAthena::BeingRecv::processBeingChangeDirection(), TmwAthena::BeingRecv::processBeingChangeLook(), EAthena::BeingRecv::processBeingChangeLook2(), TmwAthena::BeingRecv::processBeingChangeLook2(), EAthena::BeingRecv::processBeingChangeLookCards(), EAthena::ChatRecv::processBeingChat(), TmwAthena::ChatRecv::processBeingChat(), Ea::BeingRecv::processBeingEmotion(), EAthena::BeingRecv::processBeingHp(), EAthena::BeingRecv::processBeingMove(), TmwAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingMove2(), TmwAthena::BeingRecv::processBeingMove2(), Ea::BeingRecv::processBeingMove3(), Ea::BeingRecv::processBeingRemove(), EAthena::BeingRecv::processBeingRemoveSkill(), EAthena::BeingRecv::processBeingResurrect(), TmwAthena::BeingRecv::processBeingResurrect(), EAthena::BeingRecv::processBeingSelfEffect(), TmwAthena::BeingRecv::processBeingSelfEffect(), EAthena::BeingRecv::processBeingSlide(), EAthena::BeingRecv::processBeingSpawn(), EAthena::BeingRecv::processBeingSpecialEffect(), EAthena::BeingRecv::processBeingStatUpdate1(), EAthena::BeingRecv::processBeingStatusChange(), TmwAthena::BeingRecv::processBeingStatusChange(), EAthena::BeingRecv::processBeingVisible(), TmwAthena::BeingRecv::processBeingVisible(), EAthena::BuyingStoreRecv::processBuyingStoreHideBoard(), EAthena::BuyingStoreRecv::processBuyingStoreItemsList(), EAthena::BuyingStoreRecv::processBuyingStoreShowBoard(), EAthena::ChatRecv::processChatDisplay(), EAthena::GuildRecv::processGuildSetPosition(), EAthena::VendingRecv::processHideBoard(), EAthena::HomunculusRecv::processHomunculusData(), EAthena::HomunculusRecv::processHomunculusInfo1(), EAthena::HomunculusRecv::processHomunculusInfo2(), EAthena::HomunculusRecv::processHomunculusInfo3(), TmwAthena::BeingRecv::processIpResponse(), EAthena::VendingRecv::processItemsList(), EAthena::PlayerRecv::processKilledBy(), EAthena::MercenaryRecv::processMercenaryInfo(), EAthena::BeingRecv::processMobInfo(), EAthena::BeingRecv::processMonsterHp(), Ea::ChatRecv::processMVPEffect(), Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), EAthena::BeingRecv::processNameResponseTitle(), TmwAthena::PartyRecv::processPartyInvited(), Ea::PartyRecv::processPartyLeave(), TmwAthena::PartyRecv::processPartyUpdateHp(), EAthena::PetRecv::processPetData(), EAthena::BeingRecv::processPlayerGuilPartyInfo(), TmwAthena::BeingRecv::processPlayerGuilPartyInfo(), EAthena::BeingRecv::processPlayerGuilPartyInfo2(), EAthena::InventoryRecv::processPlayerInventoryUse(), TmwAthena::BeingRecv::processPlayerMove(), EAthena::BeingRecv::processPlayerStatusChange(), TmwAthena::BeingRecv::processPlayerStatusChange(), EAthena::BeingRecv::processPlayerStatusChange2(), Ea::BeingRecv::processPlayerStop(), TmwAthena::BeingRecv::processPlayerUpdate1(), TmwAthena::BeingRecv::processPlayerUpdate2(), EAthena::BeingRecv::processPvpSet(), TmwAthena::BeingRecv::processPvpSet(), EAthena::VendingRecv::processShowBoard(), EAthena::BeingRecv::processSkillCastingContinue(), EAthena::BeingRecv::processSkillDamage(), TmwAthena::BeingRecv::processSkillDamage(), Ea::BeingRecv::processSkillNoDamage(), EAthena::BeingRecv::processSpiritBalls(), Guild::removeFromMembers(), Party::removeFromMembers(), BuyingStoreSellDialog::sellAction(), PopupMenu::showPopup(), and LocalPlayer::updateCoords().

◆ findBeing() [2/2]

Being * ActorManager::findBeing ( const int  x,
const int  y,
const ActorTypeT  type 
) const

Returns a being at specific coordinates.

Definition at line 454 of file actormanager.cpp.

456 {
459  beingActorFinder.type = type;
460 
461  const ActorSpritesConstIterator it = std::find_if(
462  mActors.begin(), mActors.end(), beingActorFinder);
463 
464  return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it);
465 }
class FindBeingFunctor beingActorFinder
ActorSprites::const_iterator ActorSpritesConstIterator
Definition: actormanager.h:61
#define CAST_U16
Definition: cast.h:29
#define nullptr
Definition: localconsts.h:45

References beingActorFinder, CAST_U16, mActors, nullptr, FindBeingFunctor::type, FindBeingFunctor::x, x, FindBeingFunctor::y, and y.

◆ findBeingByName()

Being * ActorManager::findBeingByName ( const std::string &  name,
const ActorTypeT  type 
) const

Finds a being by name and (optionally) by type.

Definition at line 870 of file actormanager.cpp.

872 {
874  {
875 // disabled for performance
876 // if (reportTrue(*it == nullptr))
877 // continue;
878 
879  if ((*it)->getType() == ActorType::FloorItem
880  || (*it)->getType() == ActorType::Portal)
881  {
882  continue;
883  }
884 
885  Being *const being = static_cast<Being*>(*it);
886  if (being->getName() == name &&
887  (type == ActorType::Unknown || type == being->getType()))
888  {
889  return being;
890  }
891  }
892  return nullptr;
893 }
#define for_actorsm
ActorTypeT getType() const
Definition: being.h:116

References ActorType::FloorItem, for_actorsm, Being::getName(), Being::getType(), ActorType::Portal, and ActorType::Unknown.

Referenced by BuyDialog::action(), PlayerListener::action(), EAthena::PartyHandler::changeLeader(), Actions::findBeing(), LocalPlayer::followMoveTo(), SocialFriendsTab::getPlayersAvatars(), PopupMenu::handleLink(), WhoIsOnline::handleLink(), PlayerRelationsManager::hasPermission(), EAthena::GuildHandler::invite(), EAthena::PartyHandler::invite(), TmwAthena::PartyHandler::invite(), WhoIsOnline::loadWebList(), AvatarListBox::mousePressed(), parseLevels(), GuildManager::process(), EAthena::ChatRecv::processChatRoomLeave(), EAthena::GuildRecv::processGuildExpulsionContinue(), EAthena::GuildRecv::processGuildLeave(), EAthena::GuildRecv::processGuildLeave2(), EAthena::GuildRecv::processGuildMemberList(), ShopWindow::processRequest(), SocialPlayersTab::resetDamage(), WhoIsOnline::setNeutralColor(), OnlinePlayer::setText(), PopupMenu::showChatPopup(), PopupMenu::showPlayerGMCommands(), PlayerRelationsManager::signalUpdate(), ShopWindow::startTrade(), SocialPlayersTab::updateAvatar(), ChatWindow::updateOnline(), and updateSeenPlayers().

◆ findBeingByPixel()

Being * ActorManager::findBeingByPixel ( const int  x,
const int  y,
const AllPlayers  allPlayers 
) const

Returns a being at the specific pixel.

Definition at line 467 of file actormanager.cpp.

469 {
470  if (mMap == nullptr)
471  return nullptr;
472 
473  const bool targetDead = mTargetDeadPlayers;
474  const bool modActive = inputManager.isActionActive(
476 
477  if (mExtMouseTargeting)
478  {
479  Being *tempBeing = nullptr;
480  bool noBeing(false);
481 
483  {
484 // disabled for performance
485 // if (reportTrue(*it == nullptr))
486 // continue;
487 
488  if ((*it)->getType() == ActorType::Portal)
489  continue;
490 
491  if ((*it)->getType() == ActorType::FloorItem)
492  {
493  if (!noBeing)
494  {
495  const FloorItem *const floor
496  = static_cast<const FloorItem*>(*it);
497  const int px = floor->getPixelX();
498  const int py = floor->getPixelY();
499  if ((px - mapTileSize <= x) &&
500  (px + mapTileSize > x) &&
501  (py - mapTileSize * 2 <= y) &&
502  (py + mapTileSize / 2 > y))
503  {
504  noBeing = true;
505  }
506  }
507  continue;
508  }
509 
510  Being *const being = static_cast<Being*>(*it);
511 
512  if (being->getInfo() != nullptr &&
513  !(being->getInfo()->isTargetSelection() || modActive))
514  {
515  continue;
516  }
517 
518  if ((being->mAction != BeingAction::DEAD ||
519  (targetDead && being->getType() == ActorType::Player)) &&
520  (allPlayers == AllPlayers_true || being != localPlayer))
521  {
522  const int px = being->getPixelX();
523  const int py = being->getPixelY();
524  if ((px - mapTileSize / 2 <= x) &&
525  (px + mapTileSize / 2 > x) &&
526  (py - mapTileSize <= y) &&
527  (py > y))
528  {
529  return being;
530  }
531  else if (!noBeing &&
532  (px - mapTileSize <= x) &&
533  (px + mapTileSize > x) &&
534  (py - mapTileSize * 2 <= y) &&
535  (py + mapTileSize / 2 > y))
536  {
537  if (tempBeing != nullptr)
538  noBeing = true;
539  else
540  tempBeing = being;
541  }
542  }
543  }
544 
545  if (noBeing)
546  return nullptr;
547  return tempBeing;
548  }
550  {
551 // disabled for performance
552 // if (reportTrue(*it == nullptr))
553 // continue;
554 
555  if ((*it)->getType() == ActorType::Portal ||
556  (*it)->getType() == ActorType::FloorItem)
557  {
558  continue;
559  }
560 
561  Being *const being = static_cast<Being*>(*it);
562 
563  if (being->getInfo() != nullptr &&
564  !(being->getInfo()->isTargetSelection() || modActive))
565  {
566  continue;
567  }
568 
569  const int px = being->getPixelX();
570  const int py = being->getPixelY();
571  if ((px - mapTileSize / 2 <= x) &&
572  (px + mapTileSize / 2 > x) &&
573  (py - mapTileSize <= y) &&
574  (py > y))
575  {
576  return being;
577  }
578  }
579  return nullptr;
580 }
const bool AllPlayers_true
Definition: allplayers.h:30
virtual int getPixelY() const
Definition: actor.h:93
int getPixelX() const
Definition: actor.h:87
bool isTargetSelection() const
Definition: beinginfo.h:183
BeingActionT mAction
Definition: being.h:1229
const BeingInfo * getInfo() const
Definition: being.h:409
bool isActionActive(const InputActionT index) const
static const int mapTileSize
Definition: map.h:27
InputManager inputManager

References AllPlayers_true, BeingAction::DEAD, ActorType::FloorItem, for_actorsm, Being::getInfo(), Actor::getPixelX(), Actor::getPixelY(), Being::getType(), inputManager, InputManager::isActionActive(), BeingInfo::isTargetSelection(), localPlayer, Being::mAction, mapTileSize, mExtMouseTargeting, mMap, mTargetDeadPlayers, ActorType::Player, ActorType::Portal, InputAction::STOP_ATTACK, x, and y.

◆ findBeingsByPixel()

void ActorManager::findBeingsByPixel ( std::vector< ActorSprite * > &  beings,
const int  x,
const int  y,
const AllPlayers  allPlayers 
) const

Returns a beings at the specific pixel.

Definition at line 582 of file actormanager.cpp.

585 {
586  if (mMap == nullptr)
587  return;
588 
589  const int xtol = mapTileSize / 2;
590  const int uptol = mapTileSize;
591  const bool modActive = inputManager.isActionActive(
593 
594  for_actors
595  {
596  ActorSprite *const actor = *it;
597 
598 // disabled for performance
599 // if (reportTrue(actor == nullptr))
600 // continue;
601 
602  const ActorTypeT actorType = actor->getType();
603  switch (actorType)
604  {
605  default:
606  case ActorType::Unknown:
607  case ActorType::Avatar:
608  case ActorType::Portal:
609  break;
611  if ((actor->getPixelX() - xtol <= x) &&
612  (actor->getPixelX() + xtol > x) &&
613  (actor->getPixelY() - uptol <= y) &&
614  (actor->getPixelY() > y))
615  {
616  beings.push_back(actor);
617  }
618  break;
619  case ActorType::Player:
620  case ActorType::Npc:
621  case ActorType::Monster:
622  case ActorType::Pet:
627  {
628  const Being *const being = static_cast<const Being*>(*it);
629  if (being == nullptr)
630  continue;
631  if ((being->getInfo() != nullptr) &&
632  !(being->getInfo()->isTargetSelection() || modActive))
633  {
634  continue;
635  }
636  if ((being->isAlive() ||
638  actorType == ActorType::Player)) &&
639  (allPlayers == AllPlayers_true ||
640  being != localPlayer))
641  {
642  if ((actor->getPixelX() - xtol <= x) &&
643  (actor->getPixelX() + xtol > x) &&
644  (actor->getPixelY() - uptol <= y) &&
645  (actor->getPixelY() > y))
646  {
647  beings.push_back(actor);
648  }
649  }
650  break;
651  }
652  }
653  }
654 }
ActorType ::T ActorTypeT
Definition: actortype.h:43
bool isAlive() const
Definition: being.h:488

References AllPlayers_true, ActorType::Avatar, ActorType::Elemental, ActorType::FloorItem, for_actors, Being::getInfo(), Actor::getPixelX(), Actor::getPixelY(), ActorSprite::getType(), ActorType::Homunculus, inputManager, InputManager::isActionActive(), Being::isAlive(), BeingInfo::isTargetSelection(), localPlayer, mapTileSize, ActorType::Mercenary, mMap, ActorType::Monster, mTargetDeadPlayers, ActorType::Npc, ActorType::Pet, ActorType::Player, ActorType::Portal, ActorType::SkillUnit, InputAction::STOP_ATTACK, ActorType::Unknown, x, and y.

◆ findCharById()

std::string ActorManager::findCharById ( const int32_t  id)

Definition at line 2266 of file actormanager.cpp.

2267 {
2268  const std::map<int32_t, std::string>::const_iterator it = mChars.find(id);
2269  if (it == mChars.end())
2270  return std::string();
2271  return (*it).second;
2272 }

References mChars.

Referenced by ItemPopup::getCardsString(), and EAthena::GuildRecv::processGuildMemberList().

◆ findItem() [1/2]

FloorItem * ActorManager::findItem ( const BeingId  id) const

Returns a specific FloorItem, by id.

Definition at line 679 of file actormanager.cpp.

680 {
681  const ActorSpritesMapConstIterator it = mActorsIdMap.find(id);
682  if (it != mActorsIdMap.end())
683  {
684  ActorSprite *const actor = (*it).second;
685  returnNullptr(nullptr, actor)
686  if (actor->getId() == id &&
687  actor->getType() == ActorType::FloorItem)
688  {
689  return static_cast<FloorItem*>(actor);
690  }
691  }
692  return nullptr;
693 }

References ActorType::FloorItem, ActorSprite::getId(), ActorSprite::getType(), mActorsIdMap, and returnNullptr.

Referenced by PopupMenu::handleLink(), LocalPlayer::pickedUp(), and LocalPlayer::pickUpItems().

◆ findItem() [2/2]

FloorItem * ActorManager::findItem ( const int  x,
const int  y 
) const

Returns a FloorItem at specific coordinates.

Definition at line 695 of file actormanager.cpp.

696 {
698  {
699 // disabled for performance
700 // if (reportTrue(*it == nullptr))
701 // continue;
702 
703  if ((*it)->getTileX() == x && (*it)->getTileY() == y &&
704  (*it)->getType() == ActorType::FloorItem)
705  {
706  return static_cast<FloorItem*>(*it);
707  }
708  }
709 
710  return nullptr;
711 }

References ActorType::FloorItem, for_actorsm, x, and y.

◆ findMostDamagedPlayer()

Being * ActorManager::findMostDamagedPlayer ( const int  maxTileDist) const

Finds most damaged player, non-enemy and alive

Parameters
maxTileDistmaximal distance.

Definition at line 1501 of file actormanager.cpp.

1502 {
1503  if (localPlayer == nullptr)
1504  return nullptr;
1505 
1506  int maxDamageTaken = 0;
1507  Being *target = nullptr;
1508 
1509  for_actors
1510  {
1511  if ((*it)->getType() != ActorType::Player)
1512  continue;
1513 
1514  Being *const being = static_cast<Being*>(*it);
1515 
1516  if ((being == nullptr) || !being->isAlive() || // don't heal dead
1517  playerRelations.getRelation(being->getName()) ==
1518  Relation::ENEMY2 || // don't heal enemy
1519  localPlayer == being) // don't heal self
1520  {
1521  continue;
1522  }
1523 
1524  const int dx = being->getTileX() - localPlayer->getTileX();
1525  const int dy = being->getTileY() - localPlayer->getTileY();
1526  const int distance = fastSqrtInt(dx * dx + dy * dy);
1527 
1528  if (distance > maxTileDist)
1529  continue;
1530 
1531  if (being->getDamageTaken() > maxDamageTaken)
1532  {
1533  maxDamageTaken = being->getDamageTaken();
1534  target = being;
1535  }
1536  }
1537 
1538  return target;
1539 }
int getDamageTaken() const
Definition: being.h:593
RelationT getRelation(const std::string &name) const
int fastSqrtInt(const unsigned int n)
Definition: mathutils.h:245
@ ENEMY2
Definition: relation.h:37
PlayerRelationsManager playerRelations

References Relation::ENEMY2, fastSqrtInt(), for_actors, Being::getDamageTaken(), Being::getName(), PlayerRelationsManager::getRelation(), Being::getTileX(), Being::getTileY(), Being::isAlive(), localPlayer, ActorType::Player, and playerRelations.

◆ findNearestByName()

Being * ActorManager::findNearestByName ( const std::string &  name,
const ActorTypeT type 
) const

Finds a nearest being by name and (optionally) by type.

Definition at line 895 of file actormanager.cpp.

897 {
898  if (localPlayer == nullptr)
899  return nullptr;
900 
901  int dist = 0;
902  Being* closestBeing = nullptr;
903  int x = localPlayer->getTileX();
904  int y = localPlayer->getTileY();
905 
907  {
908 // disabled for performance
909 // if (reportTrue(*it == nullptr))
910 // continue;
911 
912  if ((*it)->getType() == ActorType::FloorItem
913  || (*it)->getType() == ActorType::Portal)
914  {
915  continue;
916  }
917 
918  Being *const being = static_cast<Being*>(*it);
919 
920  if ((being != nullptr) && being->getName() == name &&
921  (type == ActorType::Unknown || type == being->getType()))
922  {
923  if (being->getType() == ActorType::Player)
924  {
925  return being;
926  }
927  const int d = (being->getTileX() - x) * (being->getTileX() - x)
928  + (being->getTileY() - y) * (being->getTileY() - y);
929 
930  if (validateBeing(nullptr, being, type, nullptr, 50)
931  && (d < dist || closestBeing == nullptr))
932  {
933  dist = d;
934  closestBeing = being;
935  }
936  }
937  }
938  return closestBeing;
939 }
bool validateBeing(const Being *const aroundBeing, Being *const being, const ActorTypeT &type, const Being *const excluded, const int maxCost) const

References ActorType::FloorItem, for_actorsm, Being::getName(), Being::getTileX(), Being::getTileY(), Being::getType(), localPlayer, ActorType::Player, ActorType::Portal, ActorType::Unknown, validateBeing(), x, and y.

◆ findNearestLivingBeing() [1/3]

Being * ActorManager::findNearestLivingBeing ( const Being *const  aroundBeing,
const int  maxdist,
const ActorTypeT type,
const int  x,
const int  y,
const Being *const  excluded,
const AllowSort  allowSort 
) const
protected

Definition at line 1121 of file actormanager.cpp.

1127 {
1128  if ((aroundBeing == nullptr) || (localPlayer == nullptr))
1129  return nullptr;
1130 
1131  std::set<std::string> attackMobs;
1132  std::set<std::string> priorityMobs;
1133  std::set<std::string> ignoreAttackMobs;
1134  StringIntMap attackMobsMap;
1135  StringIntMap priorityMobsMap;
1136  int defaultAttackIndex = 10000;
1137  int defaultPriorityIndex = 10000;
1138  const int attackRange = localPlayer->getAttackRange();
1139 
1140  bool specialDistance = false;
1141  if (settings.moveToTargetType == 11
1142  && localPlayer->getAttackRange() > 2)
1143  {
1144  specialDistance = true;
1145  }
1146 
1147  maxDist = maxDist * maxDist;
1148 
1149  const bool cycleSelect = allowSort == AllowSort_true
1150  && ((mCyclePlayers && type == ActorType::Player)
1151  || (mCycleMonsters && type == ActorType::Monster)
1152  || (mCycleNPC && type == ActorType::Npc));
1153 
1154  const bool filtered = allowSort == AllowSort_true
1155  && config.getBoolValue("enableAttackFilter")
1156  && type == ActorType::Monster;
1157  const bool modActive = inputManager.isActionActive(
1159 
1160  bool ignoreDefault = false;
1161  if (filtered)
1162  {
1163  attackMobs = mAttackMobsSet;
1164  priorityMobs = mPriorityAttackMobsSet;
1165  ignoreAttackMobs = mIgnoreAttackMobsSet;
1166  attackMobsMap = mAttackMobsMap;
1167  priorityMobsMap = mPriorityAttackMobsMap;
1168  beingActorSorter.attackBeings = &attackMobsMap;
1169  beingActorSorter.priorityBeings = &priorityMobsMap;
1170  beingActorSorter.specialDistance = specialDistance;
1171  beingActorSorter.attackRange = attackRange;
1172  if (ignoreAttackMobs.find(std::string()) != ignoreAttackMobs.end())
1173  ignoreDefault = true;
1174  StringIntMapCIter itr = attackMobsMap.find(std::string());
1175  if (itr != attackMobsMap.end())
1176  defaultAttackIndex = (*itr).second;
1177  itr = priorityMobsMap.find(std::string());
1178  if (itr != priorityMobsMap.end())
1179  defaultPriorityIndex = (*itr).second;
1180  }
1181 
1182  if (cycleSelect)
1183  {
1184  STD_VECTOR<Being*> sortedBeings;
1185 
1186  FOR_EACH (ActorSprites::iterator, i, mActors)
1187  {
1188 // disabled for performance
1189 // if (reportTrue(*i == nullptr))
1190 // continue;
1191 
1192  if ((*i)->getType() == ActorType::FloorItem
1193  || (*i)->getType() == ActorType::Portal)
1194  {
1195  continue;
1196  }
1197 
1198  Being *const being = static_cast<Being*>(*i);
1199 
1200  if (filtered)
1201  {
1202  if (ignoreAttackMobs.find(being->getName())
1203  != ignoreAttackMobs.end())
1204  {
1205  continue;
1206  }
1207  if (ignoreDefault && attackMobs.find(being->getName())
1208  == attackMobs.end() && priorityMobs.find(being->getName())
1209  == priorityMobs.end())
1210  {
1211  continue;
1212  }
1213  }
1214 
1215  if ((being->getInfo() != nullptr)
1216  && !(being->getInfo()->isTargetSelection() || modActive))
1217  {
1218  continue;
1219  }
1220 
1221  if (validateBeing(aroundBeing, being, type, nullptr, maxDist))
1222  {
1223  if (being != excluded)
1224  sortedBeings.push_back(being);
1225  }
1226  }
1227 
1228  // no selectable beings
1229  if (sortedBeings.empty())
1230  return nullptr;
1231 
1232  beingActorSorter.x = x;
1233  beingActorSorter.y = y;
1234  if (filtered)
1235  {
1236  beingActorSorter.attackBeings = &attackMobsMap;
1237  beingActorSorter.defaultAttackIndex = defaultAttackIndex;
1238  beingActorSorter.priorityBeings = &priorityMobsMap;
1239  beingActorSorter.defaultPriorityIndex = defaultPriorityIndex;
1240  }
1241  else
1242  {
1243  beingActorSorter.attackBeings = nullptr;
1244  beingActorSorter.priorityBeings = nullptr;
1245  }
1246  std::sort(sortedBeings.begin(), sortedBeings.end(), beingActorSorter);
1247  if (filtered)
1248  {
1249  beingActorSorter.attackBeings = nullptr;
1250  beingActorSorter.priorityBeings = nullptr;
1251  }
1252 
1253  if (localPlayer->getTarget() == nullptr)
1254  {
1255  Being *const target = sortedBeings.at(0);
1256 
1257  if (specialDistance && target->getType() == ActorType::Monster
1258  && target->getDistance() <= 2)
1259  {
1260  return nullptr;
1261  }
1262  // if no selected being in vector, return first nearest being
1263  return target;
1264  }
1265 
1267  STD_VECTOR<Being*>::const_iterator i = std::find_if(
1268  sortedBeings.begin(), sortedBeings.end(), beingEqualActorFinder);
1269 
1270  if (i == sortedBeings.end() || ++i == sortedBeings.end())
1271  {
1272  // if no selected being in vector, return first nearest being
1273  return sortedBeings.at(0);
1274  }
1275 
1276  // we find next being after target
1277  return *i;
1278  }
1279 
1280  int dist = 0;
1281  int index = defaultPriorityIndex;
1282  Being *closestBeing = nullptr;
1283 
1284  FOR_EACH (ActorSprites::iterator, i, mActors)
1285  {
1286 // disabled for performance
1287 // if (reportTrue(*i == nullptr))
1288 // continue;
1289 
1290  if ((*i)->getType() == ActorType::FloorItem ||
1291  (*i)->getType() == ActorType::Portal)
1292  {
1293  continue;
1294  }
1295  Being *const being = static_cast<Being*>(*i);
1296 
1297  if (filtered)
1298  {
1299  if (ignoreAttackMobs.find(being->getName())
1300  != ignoreAttackMobs.end())
1301  {
1302  continue;
1303  }
1304  if (ignoreDefault && attackMobs.find(being->getName())
1305  == attackMobs.end() && priorityMobs.find(being->getName())
1306  == priorityMobs.end())
1307  {
1308  continue;
1309  }
1310  }
1311 
1312  if ((being->getInfo() != nullptr)
1313  && !(being->getInfo()->isTargetSelection() || modActive))
1314  {
1315  continue;
1316  }
1317 
1318  const bool valid = validateBeing(aroundBeing, being,
1319  type, excluded, 50);
1320  int d = being->getDistance();
1321  if (being->getType() != ActorType::Monster
1323  { // if distance not calculated, use old distance
1324  d = (being->getTileX() - x) * (being->getTileX() - x)
1325  + (being->getTileY() - y) * (being->getTileY() - y);
1326  }
1327 
1328  if (!valid)
1329  continue;
1330 
1331  if (specialDistance && being->getDistance() <= 2
1332  && being->getType() == type)
1333  {
1334  continue;
1335  }
1336 
1337 // logger->log("being name:" + being->getName());
1338 // logger->log("index:" + toString(index));
1339 // logger->log("d:" + toString(d));
1340 
1341  if (!filtered && (d <= dist || (closestBeing == nullptr)))
1342  {
1343  dist = d;
1344  closestBeing = being;
1345  }
1346  else if (filtered)
1347  {
1348  int w2 = defaultPriorityIndex;
1349  if (closestBeing != nullptr)
1350  {
1351  const StringIntMapCIter it2 = priorityMobsMap.find(
1352  being->getName());
1353  if (it2 != priorityMobsMap.end())
1354  w2 = (*it2).second;
1355 
1356  if (w2 < index)
1357  {
1358  dist = d;
1359  closestBeing = being;
1360  index = w2;
1361  continue;
1362  }
1363  if (w2 == index && d <= dist)
1364  {
1365  dist = d;
1366  closestBeing = being;
1367  index = w2;
1368  continue;
1369  }
1370  }
1371 
1372  if (closestBeing == nullptr)
1373  {
1374  dist = d;
1375  closestBeing = being;
1376  const StringIntMapCIter it1 = priorityMobsMap.find(
1377  being->getName());
1378  if (it1 != priorityMobsMap.end())
1379  index = (*it1).second;
1380  else
1381  index = defaultPriorityIndex;
1382  }
1383  }
1384  }
1385  return (maxDist >= dist) ? closestBeing : nullptr;
1386 }
class SortBeingFunctor beingActorSorter
class FindBeingEqualFunctor beingEqualActorFinder
const bool AllowSort_true
Definition: allowsort.h:30
int getDistance() const
Definition: being.h:552
Being * getTarget() const
int getAttackRange() const
unsigned int moveToTargetType
Definition: settings.h:135
StringIntMap * priorityBeings
StringIntMap * attackBeings
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
if(!vert) return
Settings settings
Definition: settings.cpp:32
std::map< std::string, int > StringIntMap
Definition: stringmap.h:28
StringIntMap::const_iterator StringIntMapCIter
Definition: stringmap.h:30

References AllowSort_true, SortBeingFunctor::attackBeings, SortBeingFunctor::attackRange, beingActorSorter, beingEqualActorFinder, config, SortBeingFunctor::defaultAttackIndex, SortBeingFunctor::defaultPriorityIndex, FindBeingEqualFunctor::findBeing, ActorType::FloorItem, FOR_EACH, LocalPlayer::getAttackRange(), Configuration::getBoolValue(), Being::getDistance(), Being::getInfo(), Being::getName(), LocalPlayer::getTarget(), Being::getTileX(), Being::getTileY(), Being::getType(), if(), inputManager, InputManager::isActionActive(), BeingInfo::isTargetSelection(), localPlayer, mActors, mAttackMobsMap, mAttackMobsSet, mCycleMonsters, mCycleNPC, mCyclePlayers, mIgnoreAttackMobsSet, ActorType::Monster, Settings::moveToTargetType, mPriorityAttackMobsMap, mPriorityAttackMobsSet, mTargetOnlyReachable, ActorType::Npc, ActorType::Player, ActorType::Portal, SortBeingFunctor::priorityBeings, settings, SortBeingFunctor::specialDistance, InputAction::STOP_ATTACK, anonymous_namespace{libxml.cpp}::valid, validateBeing(), SortBeingFunctor::x, x, SortBeingFunctor::y, and y.

◆ findNearestLivingBeing() [2/3]

Being * ActorManager::findNearestLivingBeing ( const Being *const  aroundBeing,
const int  maxTileDist,
const ActorTypeT  type,
const AllowSort  allowSort 
) const

Returns a being nearest to another being.

Parameters
aroundBeingThe being to search around.
maxTileDistMaximal distance in tiles. If minimal distance is larger, no being is returned.
typeThe type of being to look for.

Definition at line 1104 of file actormanager.cpp.

1108 {
1109  if (aroundBeing == nullptr)
1110  return nullptr;
1111 
1112  return findNearestLivingBeing(aroundBeing,
1113  maxDist,
1114  type,
1115  aroundBeing->getTileX(),
1116  aroundBeing->getTileY(),
1117  aroundBeing,
1118  allowSort);
1119 }
Being * findNearestLivingBeing(const int x, const int y, int maxTileDist, const ActorTypeT type, const Being *const excluded) const

References findNearestLivingBeing(), Being::getTileX(), and Being::getTileY().

◆ findNearestLivingBeing() [3/3]

Being * ActorManager::findNearestLivingBeing ( const int  x,
const int  y,
int  maxTileDist,
const ActorTypeT  type,
const Being *const  excluded 
) const

Returns a being nearest to specific coordinates.

Parameters
xX coordinate in pixels.
yY coordinate in pixels.
maxTileDistMaximal distance in tiles. If minimal distance is larger, no being is returned.
typeThe type of being to look for.

Definition at line 1090 of file actormanager.cpp.

1094 {
1095  const int maxDist = maxTileDist * mapTileSize;
1096 
1097  return findNearestLivingBeing(nullptr, maxDist,
1098  type,
1099  x, y,
1100  excluded,
1101  AllowSort_true);
1102 }

References AllowSort_true, mapTileSize, x, and y.

Referenced by Actions::findBeing(), findNearestLivingBeing(), replaceVars(), and LocalPlayer::setNewTarget().

◆ findNearestPvpPlayer()

Being * ActorManager::findNearestPvpPlayer ( ) const

Finds the nearest player who has PVP on, or just the nearest player if map pvp is on

Definition at line 1033 of file actormanager.cpp.

1034 {
1035  if (localPlayer == nullptr)
1036  return nullptr;
1037 
1038  // don't attack players
1039  if (settings.pvpAttackType == 3)
1040  return nullptr;
1041 
1042  const Game *const game = Game::instance();
1043  if (game == nullptr)
1044  return nullptr;
1045 
1046  const Map *const map = game->getCurrentMap();
1047  if (map == nullptr)
1048  return nullptr;
1049 
1050  const int mapPvpMode = map->getPvpMode();
1051  Being *target = nullptr;
1052  int minDistSquared = 20000;
1053 
1054  for_actors
1055  {
1056  if ((*it)->getType() != ActorType::Player)
1057  continue;
1058 
1059  Being *const being = static_cast<Being*>(*it);
1060 
1061  if (reportTrue(being == nullptr) ||
1062  !being->isAlive() ||
1063  localPlayer == being)
1064  {
1065  continue;
1066  }
1067 
1068  const int teamId = being->getTeamId();
1069  // this condition is very TMW-specific
1070  if (!((mapPvpMode != 0) || (teamId != 0)))
1071  continue;
1072 
1074  continue;
1075 
1076  const int dx = being->getTileX() - localPlayer->getTileX();
1077  const int dy = being->getTileY() - localPlayer->getTileY();
1078  const int distSquared = dx * dx + dy * dy;
1079  if (distSquared < minDistSquared)
1080  {
1081  minDistSquared = distSquared;
1082  target = being;
1083  }
1084  }
1085 
1086  return target;
1087 }
#define reportTrue(val)
Definition: checkutils.h:252
uint16_t getTeamId() const
Definition: being.h:1082
Definition: game.h:64
Map * getCurrentMap() const
Definition: game.h:107
static Game * instance()
Definition: game.h:82
static bool checAttackPermissions(const Being *const target)
Definition: map.h:75
int getPvpMode() const
Definition: map.h:292
unsigned int pvpAttackType
Definition: settings.h:142

References LocalPlayer::checAttackPermissions(), for_actors, Game::getCurrentMap(), Map::getPvpMode(), Being::getTeamId(), Being::getTileX(), Being::getTileY(), Game::instance(), Being::isAlive(), localPlayer, ActorType::Player, Settings::pvpAttackType, reportTrue, and settings.

◆ findPortalByTile()

Being * ActorManager::findPortalByTile ( const int  x,
const int  y 
) const

Returns a portal at the specific tile.

Definition at line 656 of file actormanager.cpp.

657 {
658  if (mMap == nullptr)
659  return nullptr;
660 
662  {
663 // disabled for performance
664 // if (reportTrue(*it == nullptr))
665 // continue;
666 
667  if ((*it)->getType() != ActorType::Portal)
668  continue;
669 
670  Being *const being = static_cast<Being*>(*it);
671 
672  if (being->getTileX() == x && being->getTileY() == y)
673  return being;
674  }
675 
676  return nullptr;
677 }

References for_actorsm, Being::getTileX(), Being::getTileY(), mMap, ActorType::Portal, x, and y.

Referenced by SocialNavigationTab::updateList().

◆ getAll()

const ActorSprites & ActorManager::getAll ( ) const

Returns the whole list of beings.

Definition at line 941 of file actormanager.cpp.

942 {
943  return mActors;
944 }

References mActors.

Referenced by ChatWindow::doPresent(), and Minimap::draw2().

◆ getAttackMobIndex()

int ActorManager::getAttackMobIndex ( const std::string &  name) const

Definition at line 1988 of file actormanager.cpp.

1989 {
1990  return getIndexByName(name, mAttackMobsMap);
1991 }
static int getIndexByName(const std::string &name, const StringIntMap &map)

References getIndexByName(), and mAttackMobsMap.

Referenced by PopupMenu::showAttackMonsterPopup().

◆ getAttackMobs()

std::list<std::string> ActorManager::getAttackMobs ( ) const
inline

Definition at line 341 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getAttackMobsMap()

const StringIntMap& ActorManager::getAttackMobsMap ( ) const
inline

Definition at line 347 of file actormanager.h.

348  { return mAttackMobsMap; }

References mAttackMobsMap.

◆ getAttackMobsSet()

std::set<std::string> ActorManager::getAttackMobsSet ( ) const
inline

Definition at line 341 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getAttackMobsSize()

int ActorManager::getAttackMobsSize ( ) const
inline

Definition at line 325 of file actormanager.h.

326  { return CAST_S32(mAttackMobs.size()); }

References CAST_S32, and mAttackMobs.

Referenced by PopupMenu::showAttackMonsterPopup().

◆ getIgnoreAttackMobs()

std::list<std::string> ActorManager::getIgnoreAttackMobs ( ) const
inline

Definition at line 343 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getIgnoreAttackMobsSet()

std::set<std::string> ActorManager::getIgnoreAttackMobsSet ( ) const
inline

Definition at line 343 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getIgnorePickupItems()

std::list<std::string> ActorManager::getIgnorePickupItems ( ) const
inline

Definition at line 345 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getIgnorePickupItemsSet()

std::set<std::string> ActorManager::getIgnorePickupItemsSet ( ) const
inline

Definition at line 345 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getIndexByName()

int ActorManager::getIndexByName ( const std::string &  name,
const StringIntMap map 
)
static

Definition at line 1973 of file actormanager.cpp.

1975 {
1976  const StringIntMapCIter i = map.find(name);
1977  if (i == map.end())
1978  return -1;
1979 
1980  return (*i).second;
1981 }

Referenced by getAttackMobIndex(), getPickupItemIndex(), and getPriorityAttackMobIndex().

◆ getMobNames()

void ActorManager::getMobNames ( StringVect names) const

Definition at line 1723 of file actormanager.cpp.

1724 {
1725  names.clear();
1726 
1727  for_actors
1728  {
1729 // disabled for performance
1730 // if (reportTrue(*it == nullptr))
1731 // continue;
1732 
1733  if ((*it)->getType() == ActorType::FloorItem
1734  || (*it)->getType() == ActorType::Portal)
1735  {
1736  continue;
1737  }
1738 
1739  const Being *const being = static_cast<const Being*>(*it);
1740  if (being->getType() == ActorType::Monster &&
1741  !being->getName().empty())
1742  {
1743  names.push_back(being->getName());
1744  }
1745  }
1746 }

References ActorType::FloorItem, for_actors, Being::getName(), Being::getType(), ActorType::Monster, and ActorType::Portal.

Referenced by ChatWindow::autoComplete().

◆ getPickupItemIndex()

int ActorManager::getPickupItemIndex ( const std::string &  name) const

Definition at line 1993 of file actormanager.cpp.

1994 {
1995  return getIndexByName(name, mPickupItemsMap);
1996 }

References getIndexByName(), and mPickupItemsMap.

◆ getPickupItems()

std::list<std::string> ActorManager::getPickupItems ( ) const
inline

Definition at line 344 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getPickupItemsSet()

std::set<std::string> ActorManager::getPickupItemsSet ( ) const
inline

Definition at line 344 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getPickupItemsSize()

int ActorManager::getPickupItemsSize ( ) const
inline

Definition at line 328 of file actormanager.h.

329  { return CAST_S32(mPickupItems.size()); }

References CAST_S32, and mPickupItems.

◆ getPlayerNames()

void ActorManager::getPlayerNames ( StringVect names,
const NpcNames  npcNames 
) const

Definition at line 1695 of file actormanager.cpp.

1697 {
1698  names.clear();
1699 
1700  for_actors
1701  {
1702 // disabled for performance
1703 // if (reportTrue(*it == nullptr))
1704 // continue;
1705 
1706  if ((*it)->getType() == ActorType::FloorItem ||
1707  (*it)->getType() == ActorType::Portal)
1708  {
1709  continue;
1710  }
1711 
1712  const Being *const being = static_cast<const Being*>(*it);
1713  if ((being->getType() == ActorType::Player ||
1714  (being->getType() == ActorType::Npc &&
1715  npcNames == NpcNames_true)) &&
1716  !being->getName().empty())
1717  {
1718  names.push_back(being->getName());
1719  }
1720  }
1721 }
const bool NpcNames_true
Definition: npcnames.h:30

References ActorType::FloorItem, for_actors, Being::getName(), Being::getType(), ActorType::Npc, NpcNames_true, ActorType::Player, and ActorType::Portal.

Referenced by ChatWindow::autoComplete(), SocialPlayersTab::getPlayersAvatars(), and replaceVars().

◆ getPriorityAttackMobIndex()

int ActorManager::getPriorityAttackMobIndex ( const std::string &  name) const

Definition at line 1983 of file actormanager.cpp.

1984 {
1985  return getIndexByName(name, mPriorityAttackMobsMap);
1986 }

References getIndexByName(), and mPriorityAttackMobsMap.

◆ getPriorityAttackMobs()

std::list<std::string> ActorManager::getPriorityAttackMobs ( ) const
inline

Definition at line 342 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getPriorityAttackMobsMap()

const StringIntMap& ActorManager::getPriorityAttackMobsMap ( ) const
inline

Definition at line 350 of file actormanager.h.

352  { return mPriorityAttackMobsMap; }

References mPriorityAttackMobsMap.

◆ getPriorityAttackMobsSet()

std::set<std::string> ActorManager::getPriorityAttackMobsSet ( ) const
inline

Definition at line 342 of file actormanager.h.

348 { return mAttackMobsMap; }

◆ getPriorityAttackMobsSize()

int ActorManager::getPriorityAttackMobsSize ( ) const
inline

Definition at line 322 of file actormanager.h.

323  { return CAST_S32(mPriorityAttackMobs.size()); }

References CAST_S32, and mPriorityAttackMobs.

Referenced by PopupMenu::showAttackMonsterPopup().

◆ getSeenPlayerById()

std::string ActorManager::getSeenPlayerById ( const BeingId  id) const

Definition at line 2212 of file actormanager.cpp.

2213 {
2214  if (!mEnableIdCollecting)
2215  return std::string();
2216 
2217  const IdNameMappingCIter it = mIdName.find(id);
2218  if (it != mIdName.end())
2219  {
2220  if (!it->second.empty())
2221  return *(it->second.begin());
2222  }
2223  return std::string();
2224 }
IdNameMapping::const_iterator IdNameMappingCIter
Definition: actormanager.h:67

References mEnableIdCollecting, and mIdName.

Referenced by TmwAthena::ChatRecv::processBeingChat(), and PopupMenu::showPopup().

◆ hasActorSprite()

bool ActorManager::hasActorSprite ( const ActorSprite *const  actor) const

Returns true if the given ActorSprite is in the manager's list, false otherwise.

Parameters
actorthe ActorSprite to search for

Definition at line 1561 of file actormanager.cpp.

1562 {
1563  for_actors
1564  {
1565  if (actor == *it)
1566  return true;
1567  }
1568 
1569  return false;
1570 }

References for_actors.

◆ heal()

void ActorManager::heal ( const Being *const  target) const

Definition at line 1413 of file actormanager.cpp.

1414 {
1416  return;
1417 
1418  if (localPlayer == nullptr ||
1419  chatWindow == nullptr ||
1420  !localPlayer->isAlive() ||
1422  {
1423  return;
1424  }
1425 
1426  // self
1427  if (target != nullptr &&
1428  localPlayer->getName() == target->getName())
1429  {
1433  {
1435  return;
1437  }
1438  }
1439  // magic levels < 2
1440  else if (PlayerInfo::getSkillLevel(340) < 2 ||
1441  PlayerInfo::getSkillLevel(341) < 2)
1442  {
1444  {
1445  if (target != nullptr &&
1446  target->getType() != ActorType::Monster)
1447  {
1449  return;
1451  + target->getName());
1452  }
1455  {
1457  return;
1459  }
1460  }
1461  }
1462  // magic level >= 2 and not self
1463  else
1464  {
1465  // mp > 10 and target not monster
1467  target != nullptr &&
1468  target->getType() != ActorType::Monster)
1469  {
1470  // target not enemy
1471  if (playerRelations.getRelation(target->getName()) !=
1473  {
1475  return;
1477  + target->getName());
1478  }
1479  // target enemy
1480  else
1481  {
1483  return;
1485  }
1486  }
1487  // heal self if selected monster or selection empty
1488  else if ((target == nullptr || target->getType() == ActorType::Monster)
1492  {
1494  return;
1496  }
1497  }
1498 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
void localChatInput(const std::string &msg) const
Definition: chatwindow.cpp:691
virtual bool canUseMagic() const =0
@ PLAYER_MAX_HP
Definition: attributes.h:33
bool limitPackets(const PacketTypeT type)
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102
int getSkillLevel(const int id)
Definition: playerinfo.cpp:120
Net::PlayerHandler * playerHandler
Definition: net.cpp:96

References Net::PlayerHandler::canUseMagic(), chatWindow, Relation::ENEMY2, PlayerInfo::getAttribute(), Being::getName(), Net::getNetworkType(), PlayerRelationsManager::getRelation(), PlayerInfo::getSkillLevel(), Being::getType(), Being::isAlive(), PacketLimiter::limitPackets(), ChatWindow::localChatInput(), localPlayer, ActorType::Monster, mSpellHeal1, mSpellHeal2, PacketType::PACKET_CHAT, Attributes::PLAYER_HP, Attributes::PLAYER_MAX_HP, Attributes::PLAYER_MP, playerHandler, playerRelations, and ServerType::TMWATHENA.

Referenced by healTarget(), and AvatarListBox::mousePressed().

◆ healTarget()

void ActorManager::healTarget ( ) const

Heal all players in distance.

Parameters
maxdistmaximal distance. If minimal distance is larger, no being is returned

Definition at line 1405 of file actormanager.cpp.

1406 {
1407  if (localPlayer == nullptr)
1408  return;
1409 
1411 }
void heal(const Being *const target) const

References LocalPlayer::getTarget(), heal(), and localPlayer.

◆ isBlocked()

bool ActorManager::isBlocked ( const BeingId  id) const

◆ isInAttackList()

bool ActorManager::isInAttackList ( const std::string &  name) const
inline

Definition at line 341 of file actormanager.h.

348 { return mAttackMobsMap; }

Referenced by PopupMenu::showPopup().

◆ isInIgnoreAttackList()

bool ActorManager::isInIgnoreAttackList ( const std::string &  name) const
inline

Definition at line 343 of file actormanager.h.

348 { return mAttackMobsMap; }

Referenced by PopupMenu::showPopup().

◆ isInIgnorePickupList()

bool ActorManager::isInIgnorePickupList ( const std::string &  name) const
inline

Definition at line 345 of file actormanager.h.

348 { return mAttackMobsMap; }

Referenced by PopupMenu::addPickupFilter(), and PopupMenu::showPopup().

◆ isInPickupList()

bool ActorManager::isInPickupList ( const std::string &  name) const
inline

Definition at line 344 of file actormanager.h.

348 { return mAttackMobsMap; }

Referenced by PopupMenu::addPickupFilter(), and PopupMenu::showPopup().

◆ isInPriorityAttackList()

bool ActorManager::isInPriorityAttackList ( const std::string &  name) const
inline

Definition at line 342 of file actormanager.h.

348 { return mAttackMobsMap; }

Referenced by PopupMenu::showPopup().

◆ itenplz()

void ActorManager::itenplz ( ) const

Definition at line 1542 of file actormanager.cpp.

1543 {
1545  return;
1546  if (localPlayer == nullptr ||
1547  chatWindow == nullptr ||
1548  !localPlayer->isAlive() ||
1550  {
1551  return;
1552  }
1553 
1555  return;
1556 
1558 }

References Net::PlayerHandler::canUseMagic(), chatWindow, Net::getNetworkType(), Being::isAlive(), PacketLimiter::limitPackets(), ChatWindow::localChatInput(), localPlayer, mSpellItenplz, PacketType::PACKET_CHAT, playerHandler, and ServerType::TMWATHENA.

◆ loadAttackList()

void ActorManager::loadAttackList ( )
protected

Definition at line 2013 of file actormanager.cpp.

2014 {
2015  bool empty = false;
2016  std::list<std::string> list;
2017  std::list<std::string>::const_iterator i;
2018  std::list<std::string>::const_iterator i_end;
2019 
2020  loadList("attackPriorityMobs", PriorityAttackMob)
2021  loadList("attackMobs", AttackMob)
2022  loadList("ignoreAttackMobs", IgnoreAttackMob)
2023  if (!empty)
2024  {
2025  mAttackMobs.push_back("");
2026  mAttackMobsSet.insert("");
2027  }
2028  empty = false;
2029 
2030  loadList("pickupItems", PickupItem)
2031  loadList("ignorePickupItems", IgnorePickupItem)
2032  if (!empty)
2033  {
2034  mPickupItems.push_back("");
2035  mPickupItemsSet.insert("");
2036  }
2037 
2041 }
#define loadList(key, mob)
std::string empty
Definition: podict.cpp:26

References empty, loadList, mAttackMobs, mAttackMobsSet, mPickupItems, mPickupItemsSet, rebuildAttackMobs(), rebuildPickupItems(), and rebuildPriorityAttackMobs().

Referenced by ActorManager().

◆ logic()

void ActorManager::logic ( )

Performs ActorSprite logic and deletes ActorSprite scheduled to be deleted.

Definition at line 946 of file actormanager.cpp.

947 {
948  BLOCK_START("ActorManager::logic")
949  for_actors
950  {
951 // disabled for performance
952 // if (reportFalse(*it))
953  (*it)->logic();
954  }
955 
956  if (mDeleteActors.empty())
957  {
958  BLOCK_END("ActorManager::logic")
959  return;
960  }
961 
964  {
965  const ActorSprite *const actor = *it;
966  const ActorTypeT &type = actor->getType();
967  if (type == ActorType::Player)
968  {
969  const Being *const being = static_cast<const Being*>(actor);
970  being->addToCache();
971  if (beingEquipmentWindow != nullptr)
973  }
974  if (localPlayer != nullptr)
975  {
976  if (localPlayer->getTarget() == actor)
977  localPlayer->setTarget(nullptr);
978  if (localPlayer->getPickUpTarget() == actor)
980  }
981  if (viewport != nullptr)
982  viewport->clearHover(*it);
983  }
984 
986  {
987  ActorSprite *actor = *it;
988  mActors.erase(actor);
989 
990  if (actor != nullptr)
991  {
992  const ActorSpritesMapIterator itr = mActorsIdMap.find(
993  actor->getId());
994  if (itr != mActorsIdMap.end() && (*itr).second == actor)
995  mActorsIdMap.erase(itr);
996 
997  delete actor;
998  }
999  }
1000 
1001  mDeleteActors.clear();
1002  BLOCK_END("ActorManager::logic 1")
1004 }
void addToCache() const
Definition: being.cpp:3513
void resetBeing(const Being *const being)
const FloorItem * getPickUpTarget() const
Definition: localplayer.h:322
void clearHover(const ActorSprite *const actor)
Clears any matching hovers.
Definition: viewport.cpp:1054
Viewport * viewport
Definition: viewport.cpp:36
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References Being::addToCache(), beingEquipmentWindow, BLOCK_END, BLOCK_START, Viewport::clearHover(), for_actors, FOR_EACH, ActorSprite::getId(), LocalPlayer::getPickUpTarget(), LocalPlayer::getTarget(), ActorSprite::getType(), localPlayer, mActors, mActorsIdMap, mDeleteActors, ActorType::Player, EquipmentWindow::resetBeing(), LocalPlayer::setTarget(), LocalPlayer::unSetPickUpTarget(), and viewport.

Referenced by Game::logic().

◆ optionChanged()

void ActorManager::optionChanged ( const std::string &  name)
virtual

Called when an option changed. The config listener will have to be registered to the option name first.

Implements ConfigListener.

Definition at line 1840 of file actormanager.cpp.

1841 {
1842  if (name == "targetDeadPlayers")
1843  mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
1844  else if (name == "targetOnlyReachable")
1845  mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
1846  else if (name == "cyclePlayers")
1847  mCyclePlayers = config.getBoolValue("cyclePlayers");
1848  else if (name == "cycleMonsters")
1849  mCycleMonsters = config.getBoolValue("cycleMonsters");
1850  else if (name == "cycleNPC")
1851  mCycleNPC = config.getBoolValue("cycleNPC");
1852  else if (name == "extMouseTargeting")
1853  mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
1854  else if (name == "showBadges" || name == "visiblenamespos")
1855  updateBadges();
1856  else if (name == "enableIdCollecting")
1857  mEnableIdCollecting = config.getBoolValue("enableIdCollecting");
1858 }
void updateBadges() const

References config, Configuration::getBoolValue(), mCycleMonsters, mCycleNPC, mCyclePlayers, mEnableIdCollecting, mExtMouseTargeting, mTargetDeadPlayers, mTargetOnlyReachable, and updateBadges().

◆ parseLevels()

void ActorManager::parseLevels ( std::string  levels) const

Definition at line 1810 of file actormanager.cpp.

1811 {
1812  levels.append(", ");
1813  size_t f = 0;
1814  const std::string brkEnd("), ");
1815  size_t pos = levels.find(brkEnd, f);
1816 
1817  while (pos != std::string::npos)
1818  {
1819  std::string part = levels.substr(f, pos - f);
1820  if (part.empty())
1821  break;
1822  const size_t bktPos = part.rfind('(');
1823  if (bktPos != std::string::npos)
1824  {
1825  Being *const being = findBeingByName(part.substr(0, bktPos),
1827  if (being != nullptr)
1828  {
1829  being->setLevel(atoi(part.substr(bktPos + 1).c_str()));
1830  being->addToCache();
1831  }
1832  }
1833  f = CAST_SIZE(pos + brkEnd.length());
1834  pos = levels.find(brkEnd, f);
1835  }
1837 }
#define CAST_SIZE
Definition: cast.h:34
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
void updatePlayerNames() const
void setLevel(const int n)
Definition: being.h:601

References Being::addToCache(), CAST_SIZE, findBeingByName(), ActorType::Player, Being::setLevel(), and updatePlayerNames().

Referenced by TmwAthena::ChatRecv::processChatContinue().

◆ pickUpAll()

bool ActorManager::pickUpAll ( const int  x1,
const int  y1,
const int  x2,
const int  y2,
const bool  serverBuggy 
) const

Definition at line 713 of file actormanager.cpp.

716 {
717  if (localPlayer == nullptr)
718  return false;
719 
720  bool finded(false);
721  const bool allowAll = mPickupItemsSet.find(std::string()) !=
722  mPickupItemsSet.end();
723  if (!serverBuggy)
724  {
726  {
727 // disabled for performance
728 // if (reportTrue(*it == nullptr))
729 // continue;
730 
731  if ((*it)->getType() == ActorType::FloorItem
732  && ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
733  && ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
734  {
735  FloorItem *const item = static_cast<FloorItem*>(*it);
736  if (allowAll)
737  {
738  if (mIgnorePickupItemsSet.find(item->getName())
739  == mIgnorePickupItemsSet.end())
740  {
741  if (localPlayer->pickUp(item))
742  finded = true;
743  }
744  }
745  else
746  {
747  if (mPickupItemsSet.find(item->getName())
748  != mPickupItemsSet.end())
749  {
750  if (localPlayer->pickUp(item))
751  finded = true;
752  }
753  }
754  }
755  }
756  }
758  {
759  FloorItem *item = nullptr;
760  unsigned cnt = 65535;
762  {
763 // disabled for performance
764 // if (reportTrue(*it == nullptr))
765 // continue;
766 
767  if ((*it)->getType() == ActorType::FloorItem
768  && ((*it)->getTileX() >= x1 && (*it)->getTileX() <= x2)
769  && ((*it)->getTileY() >= y1 && (*it)->getTileY() <= y2))
770  {
771  FloorItem *const tempItem = static_cast<FloorItem*>(*it);
772  if (tempItem->getPickupCount() < cnt)
773  {
774  if (allowAll)
775  {
776  if (mIgnorePickupItemsSet.find(tempItem->getName())
777  == mIgnorePickupItemsSet.end())
778  {
779  item = tempItem;
780  cnt = item->getPickupCount();
781  if (cnt == 0)
782  {
783  item->incrementPickup();
784  localPlayer->pickUp(item);
785  return true;
786  }
787  }
788  }
789  else
790  {
791  if (mPickupItemsSet.find(tempItem->getName())
792  != mPickupItemsSet.end())
793  {
794  item = tempItem;
795  cnt = item->getPickupCount();
796  if (cnt == 0)
797  {
798  item->incrementPickup();
799  localPlayer->pickUp(item);
800  return true;
801  }
802  }
803  }
804  }
805  }
806  }
807  if ((item != nullptr) && localPlayer->pickUp(item))
808  finded = true;
809  }
810  return finded;
811 }
unsigned getPickupCount() const
Definition: flooritem.h:102
void incrementPickup()
Definition: flooritem.h:99
bool pickUp(FloorItem *const item)
bool checkPackets(const PacketTypeT type)
@ PACKET_PICKUP
Definition: packettype.h:30

References PacketLimiter::checkPackets(), ActorType::FloorItem, for_actorsm, FloorItem::getName(), FloorItem::getPickupCount(), FloorItem::incrementPickup(), localPlayer, mIgnorePickupItemsSet, mPickupItemsSet, PacketType::PACKET_PICKUP, and LocalPlayer::pickUp().

Referenced by LocalPlayer::pickUpItems().

◆ pickUpNearest()

bool ActorManager::pickUpNearest ( const int  x,
const int  y,
int  maxdist 
) const

Definition at line 813 of file actormanager.cpp.

815 {
816  if (localPlayer == nullptr)
817  return false;
818 
819  maxdist = maxdist * maxdist;
820  FloorItem *closestItem = nullptr;
821  int dist = 0;
822  const bool allowAll = mPickupItemsSet.find(std::string()) !=
823  mPickupItemsSet.end();
824 
826  {
827 // disabled for performance
828 // if (reportTrue(*it == nullptr))
829 // continue;
830 
831  if ((*it)->getType() == ActorType::FloorItem)
832  {
833  FloorItem *const item = static_cast<FloorItem*>(*it);
834 
835  const int d = (item->getTileX() - x) * (item->getTileX() - x)
836  + (item->getTileY() - y) * (item->getTileY() - y);
837 
838  if ((d < dist || closestItem == nullptr) &&
840  item->getTileX(), item->getTileY(),
841  false)))
842  {
843  if (allowAll)
844  {
845  if (mIgnorePickupItemsSet.find(item->getName())
846  == mIgnorePickupItemsSet.end())
847  {
848  dist = d;
849  closestItem = item;
850  }
851  }
852  else
853  {
854  if (mPickupItemsSet.find(item->getName())
855  != mPickupItemsSet.end())
856  {
857  dist = d;
858  closestItem = item;
859  }
860  }
861  }
862  }
863  }
864  if ((closestItem != nullptr) && dist <= maxdist)
865  return localPlayer->pickUp(closestItem);
866 
867  return false;
868 }
int getTileY() const
Definition: flooritem.h:96
int getTileX() const
Definition: flooritem.h:93
bool isReachable(Being *const being, const int maxCost)

References ActorType::FloorItem, for_actorsm, FloorItem::getName(), FloorItem::getTileX(), FloorItem::getTileY(), LocalPlayer::isReachable(), localPlayer, mIgnorePickupItemsSet, mPickupItemsSet, mTargetOnlyReachable, LocalPlayer::pickUp(), x, and y.

Referenced by LocalPlayer::pickUpItems().

◆ printAllToChat()

void ActorManager::printAllToChat ( )

Definition at line 1587 of file actormanager.cpp.

1588 {
1589  // TRANSLATORS: visible beings on map
1590  printBeingsToChat(_("Visible on map"));
1591 }
void printBeingsToChat(const std::string &header) const
#define _(s)
Definition: gettext.h:35

References _, and printBeingsToChat().

◆ printBeingsToChat() [1/2]

void ActorManager::printBeingsToChat ( const std::string &  header) const

Definition at line 1593 of file actormanager.cpp.

1594 {
1595  if (debugChatTab == nullptr)
1596  return;
1597 
1598  debugChatTab->chatLog("---------------------------------------",
1602  debugChatTab->chatLog(header,
1606  for_actors
1607  {
1608 // disabled for performance
1609 // if (reportTrue(*it == nullptr))
1610 // continue;
1611 
1612  if ((*it)->getType() == ActorType::FloorItem)
1613  continue;
1614 
1615  const Being *const being = static_cast<const Being*>(*it);
1616 
1617  debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
1618  being->getName().c_str(), being->getTileX(), being->getTileY(),
1619  toInt(being->getSubType(), int)),
1623  if (mActorsIdMap.find(being->getId()) == mActorsIdMap.end())
1624  {
1625  debugChatTab->chatLog("missing in id map: %s",
1626  being->getName().c_str());
1627  }
1628  }
1629  debugChatTab->chatLog("---------------------------------------",
1634  {
1635  const ActorSprite *const actor = (*itr).second;
1636  if (actor == nullptr)
1637  continue;
1638  if (actor->getId() != (*itr).first)
1639  debugChatTab->chatLog("Actor with wrong key in map", "");
1640 
1641  bool found(false);
1642 
1643  for_actors
1644  {
1645 // disabled for performance
1646 // if (!*it)
1647 // continue;
1648 
1649  if ((*it)->getId() == actor->getId())
1650  {
1651  found = true;
1652  break;
1653  }
1654  }
1655  if (!found)
1656  debugChatTab->chatLog("Actor present in map but not in set", "");
1657  }
1658 }
ChatTab * debugChatTab
Definition: chattab.cpp:63
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
std::string strprintf(const char *const format,...)
const bool TryRemoveColors_true

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), debugChatTab, ActorType::FloorItem, for_actors, FOR_EACH, ActorSprite::getId(), Being::getName(), Being::getSubType(), Being::getTileX(), Being::getTileY(), IgnoreRecord_false, mActorsIdMap, strprintf(), toInt, and TryRemoveColors_true.

Referenced by printAllToChat().

◆ printBeingsToChat() [2/2]

void ActorManager::printBeingsToChat ( const std::vector< Being * > &  beings,
const std::string &  header 
)
static

Definition at line 1660 of file actormanager.cpp.

1662 {
1663  if (debugChatTab == nullptr)
1664  return;
1665 
1666  debugChatTab->chatLog("---------------------------------------",
1670  debugChatTab->chatLog(header,
1674 
1675  FOR_EACH (STD_VECTOR<Being*>::const_iterator, i, beings)
1676  {
1677  if (*i == nullptr)
1678  continue;
1679 
1680  const Being *const being = *i;
1681 
1682  debugChatTab->chatLog(strprintf("%s (%d,%d) %d",
1683  being->getName().c_str(), being->getTileX(), being->getTileY(),
1684  toInt(being->getSubType(), int)),
1688  }
1689  debugChatTab->chatLog("---------------------------------------",
1693 }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), debugChatTab, FOR_EACH, Being::getName(), Being::getSubType(), Being::getTileX(), Being::getTileY(), IgnoreRecord_false, strprintf(), toInt, and TryRemoveColors_true.

◆ rebuildAttackMobs()

void ActorManager::rebuildAttackMobs ( )

Definition at line 1963 of file actormanager.cpp.

1964 {
1965  rebuildMobsList(AttackMob)
1966 }
#define rebuildMobsList(mob)

References rebuildMobsList.

Referenced by addIgnoreAttackMob(), loadAttackList(), and removeAttackMob().

◆ rebuildIgnoreAttackMobs()

void ActorManager::rebuildIgnoreAttackMobs ( )

◆ rebuildIgnorePickupItems()

void ActorManager::rebuildIgnorePickupItems ( )

◆ rebuildPickupItems()

void ActorManager::rebuildPickupItems ( )

Definition at line 1968 of file actormanager.cpp.

1969 {
1970  rebuildMobsList(PickupItem)
1971 }

References rebuildMobsList.

Referenced by addIgnorePickupItem(), addPickupItem(), loadAttackList(), and removePickupItem().

◆ rebuildPriorityAttackMobs()

void ActorManager::rebuildPriorityAttackMobs ( )

Definition at line 1958 of file actormanager.cpp.

1959 {
1960  rebuildMobsList(PriorityAttackMob)
1961 }

References rebuildMobsList.

Referenced by addAttackMob(), addIgnoreAttackMob(), loadAttackList(), and removeAttackMob().

◆ removeAttackMob()

void ActorManager::removeAttackMob ( const std::string &  name)

Definition at line 1860 of file actormanager.cpp.

1861 {
1862  mPriorityAttackMobs.remove(name);
1863  mAttackMobs.remove(name);
1864  mIgnoreAttackMobs.remove(name);
1865  mPriorityAttackMobsSet.erase(name);
1866  mAttackMobsSet.erase(name);
1867  mIgnoreAttackMobsSet.erase(name);
1870  storeAttackList();
1871 }

References mAttackMobs, mAttackMobsSet, mIgnoreAttackMobs, mIgnoreAttackMobsSet, mPriorityAttackMobs, mPriorityAttackMobsSet, rebuildAttackMobs(), rebuildPriorityAttackMobs(), and storeAttackList().

◆ removePickupItem()

void ActorManager::removePickupItem ( const std::string &  name)

Definition at line 1873 of file actormanager.cpp.

1874 {
1875  mPickupItems.remove(name);
1876  mPickupItemsSet.erase(name);
1877  mIgnorePickupItems.remove(name);
1878  mIgnorePickupItemsSet.erase(name);
1880  storeAttackList();
1881 }

References mIgnorePickupItems, mIgnorePickupItemsSet, mPickupItems, mPickupItemsSet, rebuildPickupItems(), and storeAttackList().

◆ removeRoom()

void ActorManager::removeRoom ( const int  chatId)

Definition at line 2226 of file actormanager.cpp.

2227 {
2228  for_actors
2229  {
2230  ActorSprite *const actor = *it;
2231  if (actor->getType() == ActorType::Npc)
2232  {
2233  Being *const being = static_cast<Being*>(actor);
2234  const ChatObject *const chat = being->getChat();
2235  if ((chat != nullptr) && chat->chatId == chatId)
2236  {
2237  being->setChat(nullptr);
2238  }
2239  }
2240  }
2241 }
void setChat(ChatObject *const obj)
Definition: being.cpp:5322
ChatObject * getChat() const
Definition: being.h:999
int chatId
Definition: chatobject.h:47

References ChatObject::chatId, for_actors, Being::getChat(), ActorSprite::getType(), ActorType::Npc, and Being::setChat().

Referenced by EAthena::ChatRecv::processChatRoomDestroy().

◆ setAttackMobs()

void ActorManager::setAttackMobs ( const std::list< std::string > &  mobs)
inline

Definition at line 319 of file actormanager.h.

320  { mAttackMobs = mobs; }

References mAttackMobs.

◆ setMap()

void ActorManager::setMap ( Map *const  map)

Sets the map on which ActorSprites are created.

Definition at line 264 of file actormanager.cpp.

265 {
266  mMap = map;
267 
268  if (localPlayer != nullptr)
269  localPlayer->setMap(map);
270 }
void setMap(Map *const map)

References localPlayer, mMap, and LocalPlayer::setMap().

Referenced by Game::changeMap().

◆ setPlayer()

void ActorManager::setPlayer ( LocalPlayer *const  player)

Sets the current player.

Definition at line 272 of file actormanager.cpp.

273 {
274  localPlayer = player;
275  mActors.insert(player);
276  mActorsIdMap[player->getId()] = player;
277  if (socialWindow != nullptr)
279  if (socialWindow != nullptr)
281 }
void updatePickupFilter()
void updateAttackFilter()

References ActorSprite::getId(), localPlayer, mActors, mActorsIdMap, socialWindow, SocialWindow::updateAttackFilter(), and SocialWindow::updatePickupFilter().

Referenced by Game::Game().

◆ setPriorityAttackMobs()

void ActorManager::setPriorityAttackMobs ( const std::list< std::string > &  mobs)
inline

Definition at line 316 of file actormanager.h.

317  { mPriorityAttackMobs = mobs; }

References mPriorityAttackMobs.

◆ size()

size_t ActorManager::size ( ) const
inline

Definition at line 381 of file actormanager.h.

382  { return mActors.size(); }

References mActors.

◆ storeAttackList()

void ActorManager::storeAttackList ( ) const
protected

Definition at line 2043 of file actormanager.cpp.

2044 {
2045  serverConfig.setValue("attackPriorityMobs", packList(mPriorityAttackMobs));
2046  serverConfig.setValue("attackMobs", packList(mAttackMobs));
2047  serverConfig.setValue("ignoreAttackMobs", packList(mIgnoreAttackMobs));
2048 
2049  serverConfig.setValue("pickupItems", packList(mPickupItems));
2050  serverConfig.setValue("ignorePickupItems", packList(mIgnorePickupItems));
2051 }
void setValue(const std::string &key, const std::string &value)
std::string packList(const std::list< std::string > &list)

References mAttackMobs, mIgnoreAttackMobs, mIgnorePickupItems, mPickupItems, mPriorityAttackMobs, packList(), serverConfig, and Configuration::setValue().

Referenced by addAttackMob(), addIgnoreAttackMob(), addIgnorePickupItem(), addPickupItem(), addPriorityAttackMob(), removeAttackMob(), removePickupItem(), and ~ActorManager().

◆ undelete()

void ActorManager::undelete ( const ActorSprite *const  actor)

◆ updateBadges()

void ActorManager::updateBadges ( ) const

Definition at line 2141 of file actormanager.cpp.

2142 {
2143  const BadgeDrawType::Type showBadges = static_cast<BadgeDrawType::Type>(
2144  config.getIntValue("showBadges"));
2145  Being::mShowBadges = showBadges;
2147  config.getIntValue("visiblenamespos"));
2148 
2149  for_actors
2150  {
2151  ActorSprite *const actor = *it;
2152  if (actor->getType() == ActorType::Player)
2153  {
2154  Being *const being = static_cast<Being*>(actor);
2155  being->showBadges(showBadges != BadgeDrawType::Hide);
2156  }
2157  }
2158 }
void showBadges(const bool show)
Definition: being.cpp:5214
static BadgeDrawType::Type mShowBadges
Definition: being.h:1348
static VisibleNamePos::Type mVisibleNamePos
Definition: being.h:1350
int getIntValue(const std::string &key) const

References config, for_actors, Configuration::getIntValue(), ActorSprite::getType(), BadgeDrawType::Hide, Being::mShowBadges, Being::mVisibleNamePos, ActorType::Player, and Being::showBadges().

Referenced by optionChanged().

◆ updateEffects()

void ActorManager::updateEffects ( const std::map< BeingTypeId, int > &  addEffects,
const std::set< BeingTypeId > &  removeEffects 
) const

Definition at line 2076 of file actormanager.cpp.

2079 {
2080  for_actorsm
2081  {
2082 // disabled for performance
2083 // if (reportTrue(*it == nullptr))
2084 // continue;
2085  if ((*it)->getType() != ActorType::Npc)
2086  continue;
2087  Being *const being = static_cast<Being*>(*it);
2088  const BeingTypeId type = being->getSubType();
2089  if (removeEffects.find(type) != removeEffects.end())
2090  being->removeSpecialEffect();
2091  const std::map<BeingTypeId, int>::const_iterator
2092  idAdd = addEffects.find(type);
2093  if (idAdd != addEffects.end())
2094  being->addSpecialEffect((*idAdd).second);
2095  }
2096 }
int BeingTypeId
Definition: beingtypeid.h:30
void removeSpecialEffect()
Definition: being.cpp:4941
void addSpecialEffect(const int effect)
Definition: being.cpp:4928

References Being::addSpecialEffect(), for_actorsm, Being::getSubType(), ActorType::Npc, and Being::removeSpecialEffect().

Referenced by QuestsWindow::updateEffects().

◆ updateNameId()

void ActorManager::updateNameId ( const std::string &  name,
const BeingId  beingId 
)

Definition at line 2160 of file actormanager.cpp.

2162 {
2163  if (!mEnableIdCollecting)
2164  return;
2165  const int id = CAST_S32(beingId);
2166  if ((id != 0) &&
2167  (id < 2000000 ||
2168  id >= 110000000))
2169  {
2170  return;
2171  }
2172 
2173  if (mIdName.find(beingId) == mIdName.end() ||
2174  mIdName[beingId].find(name) == mIdName[beingId].end())
2175  {
2176  mIdName[beingId].insert(name);
2177  const std::string idStr = toString(id);
2178  const std::string dateStr = getDateTimeString();
2179  std::string dir;
2180  if (beingId != BeingId_zero)
2181  {
2183  idStr,
2184  stringToHexPath(name));
2185  Files::saveTextFile(dir,
2186  "info.txt",
2187  (name + "\n").append(dateStr));
2188  }
2189 
2190  dir = settings.usersDir;
2191  dir.append(stringToHexPath(name));
2192  Files::saveTextFile(dir,
2193  "seen.txt",
2194  (name + "\n").append(idStr).append("\n").append(dateStr));
2195  }
2196 }
const BeingId BeingId_zero
Definition: beingid.h:30
std::string usersIdDir
Definition: settings.h:119
std::string usersDir
Definition: settings.h:118
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
void saveTextFile(const std::string &path, const std::string &name, const std::string &text)
Definition: files.cpp:250
std::string stringToHexPath(const std::string &str)
std::string getDateTimeString()
std::string pathJoin(std::string str1, const std::string &str2)

References BeingId_zero, CAST_S32, getDateTimeString(), mEnableIdCollecting, mIdName, pathJoin(), Files::saveTextFile(), settings, stringToHexPath(), Catch::toString(), Settings::usersDir, and Settings::usersIdDir.

Referenced by Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), EAthena::BeingRecv::processNameResponseTitle(), TmwAthena::PlayerRecv::processOnlineList(), EAthena::BeingRecv::processPlayerGuilPartyInfo(), EAthena::BeingRecv::processPlayerGuilPartyInfo2(), and updateSeenPlayers().

◆ updatePlayerColors()

void ActorManager::updatePlayerColors ( ) const

Definition at line 1769 of file actormanager.cpp.

1770 {
1771  for_actorsm
1772  {
1773 // disabled for performance
1774 // if (reportTrue(*it == nullptr))
1775 // continue;
1776 
1777  if ((*it)->getType() == ActorType::FloorItem
1778  || (*it)->getType() == ActorType::Portal)
1779  {
1780  continue;
1781  }
1782 
1783  Being *const being = static_cast<Being*>(*it);
1784  if (being->getType() == ActorType::Player && !being->getName().empty())
1785  being->updateColors();
1786  }
1787 }
void updateColors()
Definition: being.cpp:2663

References ActorType::FloorItem, for_actorsm, Being::getName(), Being::getType(), ActorType::Player, ActorType::Portal, and Being::updateColors().

Referenced by GuildManager::afterRemove(), EAthena::GuildRecv::processGuildExpulsionContinue(), EAthena::GuildRecv::processGuildLeave(), EAthena::GuildRecv::processGuildLeave2(), EAthena::GuildRecv::processGuildMemberList(), and GuildManager::updateList().

◆ updatePlayerGuild()

void ActorManager::updatePlayerGuild ( ) const

Definition at line 1789 of file actormanager.cpp.

1790 {
1791  for_actorsm
1792  {
1793 // disabled for performance
1794 // if (reportTrue(*it == nullptr))
1795 // continue;
1796 
1797  if ((*it)->getType() == ActorType::FloorItem
1798  || (*it)->getType() == ActorType::Portal)
1799  {
1800  continue;
1801  }
1802 
1803  Being *const being = static_cast<Being*>(*it);
1804  if (being->getType() == ActorType::Player && !being->getName().empty())
1805  being->updateGuild();
1806  }
1807 }
void updateGuild()
Definition: being.cpp:1333

References ActorType::FloorItem, for_actorsm, Being::getName(), Being::getType(), ActorType::Player, ActorType::Portal, and Being::updateGuild().

Referenced by GuildManager::afterRemove(), EAthena::GuildRecv::processGuildMemberList(), and GuildManager::updateList().

◆ updatePlayerNames()

void ActorManager::updatePlayerNames ( ) const

Definition at line 1748 of file actormanager.cpp.

1749 {
1750  for_actorsm
1751  {
1752 // disabled for performance
1753 // if (reportTrue(*it == nullptr))
1754 // continue;
1755 
1756  if ((*it)->getType() == ActorType::FloorItem
1757  || (*it)->getType() == ActorType::Portal)
1758  {
1759  continue;
1760  }
1761 
1762  Being *const being = static_cast<Being*>(*it);
1763  being->setGoodStatus(-1);
1764  if (being->getType() == ActorType::Player && !being->getName().empty())
1765  being->updateName();
1766  }
1767 }
void updateName()
Definition: being.cpp:3425
void setGoodStatus(const int n)
Definition: being.h:803

References ActorType::FloorItem, for_actorsm, Being::getName(), Being::getType(), ActorType::Player, ActorType::Portal, Being::setGoodStatus(), and Being::updateName().

Referenced by Setup_Relations::apply(), and parseLevels().

◆ updateRoom()

void ActorManager::updateRoom ( const ChatObject *const  newChat)

Definition at line 2243 of file actormanager.cpp.

2244 {
2245  if (newChat == nullptr)
2246  return;
2247 
2248  for_actors
2249  {
2250  const ActorSprite *const actor = *it;
2251  if (actor->getType() == ActorType::Npc)
2252  {
2253  const Being *const being = static_cast<const Being*>(actor);
2254  ChatObject *const chat = being->getChat();
2255  if ((chat != nullptr) && chat->chatId == newChat->chatId)
2256  {
2257  chat->ownerId = newChat->ownerId;
2258  chat->maxUsers = newChat->maxUsers;
2259  chat->type = newChat->type;
2260  chat->title = newChat->title;
2261  }
2262  }
2263  }
2264 }
std::string title
Definition: chatobject.h:51
uint16_t maxUsers
Definition: chatobject.h:48
uint8_t type
Definition: chatobject.h:50
BeingId ownerId
Definition: chatobject.h:46

References ChatObject::chatId, for_actors, Being::getChat(), ActorSprite::getType(), ChatObject::maxUsers, ActorType::Npc, ChatObject::ownerId, ChatObject::title, and ChatObject::type.

Referenced by EAthena::ChatRecv::processChatRoomSettings().

◆ updateSeenPlayers()

void ActorManager::updateSeenPlayers ( const std::set< std::string > &  onlinePlayers)

Definition at line 2198 of file actormanager.cpp.

2200 {
2201  if (!mEnableIdCollecting)
2202  return;
2203 
2204  FOR_EACH (std::set<std::string>::const_iterator, it, onlinePlayers)
2205  {
2206  const std::string name = *it;
2207  if (findBeingByName(name, ActorType::Player) == nullptr)
2208  updateNameId(name, BeingId_zero);
2209  }
2210 }
void updateNameId(const std::string &name, const BeingId beingId)

References BeingId_zero, findBeingByName(), FOR_EACH, mEnableIdCollecting, ActorType::Player, and updateNameId().

Referenced by WhoIsOnline::loadList(), and WhoIsOnline::slowLogic().

◆ validateBeing()

bool ActorManager::validateBeing ( const Being *const  aroundBeing,
Being *const  being,
const ActorTypeT type,
const Being *const  excluded,
const int  maxCost 
) const
protected

Definition at line 1388 of file actormanager.cpp.

1393 {
1394  if (localPlayer == nullptr)
1395  return false;
1396  return (being != nullptr) && ((being->getType() == type
1397  || type == ActorType::Unknown) && (being->isAlive()
1398  || (mTargetDeadPlayers && type == ActorType::Player))
1399  && being != aroundBeing) && being != excluded
1401  || localPlayer->isReachable(being, maxCost));
1402 }

References Being::getType(), Being::isAlive(), LocalPlayer::isReachable(), localPlayer, ActorType::Monster, mTargetDeadPlayers, mTargetOnlyReachable, ActorType::Player, and ActorType::Unknown.

Referenced by findNearestByName(), and findNearestLivingBeing().

Field Documentation

◆ mActors

ActorSprites ActorManager::mActors
protected

◆ mActorsIdMap

ActorSpritesMap ActorManager::mActorsIdMap
protected

◆ mAttackMobs

std::list<std::string> ActorManager::mAttackMobs
protected

◆ mAttackMobsMap

StringIntMap ActorManager::mAttackMobsMap
protected

Definition at line 448 of file actormanager.h.

Referenced by findNearestLivingBeing(), getAttackMobIndex(), and getAttackMobsMap().

◆ mAttackMobsSet

std::set<std::string> ActorManager::mAttackMobsSet
protected

Definition at line 448 of file actormanager.h.

Referenced by findNearestLivingBeing(), loadAttackList(), and removeAttackMob().

◆ mBlockedBeings

std::set<BeingId> ActorManager::mBlockedBeings
protected

Definition at line 418 of file actormanager.h.

Referenced by addBlock(), deleteBlock(), and isBlocked().

◆ mChars

std::map<int32_t, std::string> ActorManager::mChars
protected

Definition at line 419 of file actormanager.h.

Referenced by addChar(), clear(), and findCharById().

◆ mCycleMonsters

bool ActorManager::mCycleMonsters
protected

Definition at line 430 of file actormanager.h.

Referenced by findNearestLivingBeing(), and optionChanged().

◆ mCycleNPC

bool ActorManager::mCycleNPC
protected

Definition at line 431 of file actormanager.h.

Referenced by findNearestLivingBeing(), and optionChanged().

◆ mCyclePlayers

bool ActorManager::mCyclePlayers
protected

Definition at line 429 of file actormanager.h.

Referenced by findNearestLivingBeing(), and optionChanged().

◆ mDeleteActors

ActorSprites ActorManager::mDeleteActors
protected

Definition at line 415 of file actormanager.h.

Referenced by clear(), destroy(), logic(), and undelete().

◆ mEnableIdCollecting

bool ActorManager::mEnableIdCollecting
protected

Definition at line 433 of file actormanager.h.

Referenced by getSeenPlayerById(), optionChanged(), updateNameId(), and updateSeenPlayers().

◆ mExtMouseTargeting

bool ActorManager::mExtMouseTargeting
protected

Definition at line 432 of file actormanager.h.

Referenced by findBeingByPixel(), and optionChanged().

◆ mIdName

IdNameMapping ActorManager::mIdName
protected

Definition at line 417 of file actormanager.h.

Referenced by getSeenPlayerById(), and updateNameId().

◆ mIgnoreAttackMobs

std::list<std::string> ActorManager::mIgnoreAttackMobs
protected

Definition at line 448 of file actormanager.h.

Referenced by addIgnoreAttackMob(), removeAttackMob(), and storeAttackList().

◆ mIgnoreAttackMobsSet

std::set<std::string> ActorManager::mIgnoreAttackMobsSet
protected

Definition at line 448 of file actormanager.h.

Referenced by addIgnoreAttackMob(), findNearestLivingBeing(), and removeAttackMob().

◆ mIgnorePickupItems

std::list<std::string> ActorManager::mIgnorePickupItems
protected

Definition at line 449 of file actormanager.h.

Referenced by addIgnorePickupItem(), removePickupItem(), and storeAttackList().

◆ mIgnorePickupItemsSet

std::set<std::string> ActorManager::mIgnorePickupItemsSet
protected

◆ mMap

Map* ActorManager::mMap
protected

◆ mPickupItems

std::list<std::string> ActorManager::mPickupItems
protected

◆ mPickupItemsMap

StringIntMap ActorManager::mPickupItemsMap
protected

Definition at line 449 of file actormanager.h.

Referenced by getPickupItemIndex().

◆ mPickupItemsSet

std::set<std::string> ActorManager::mPickupItemsSet
protected

◆ mPriorityAttackMobs

std::list<std::string> ActorManager::mPriorityAttackMobs
protected

◆ mPriorityAttackMobsMap

StringIntMap ActorManager::mPriorityAttackMobsMap
protected

◆ mPriorityAttackMobsSet

std::set<std::string> ActorManager::mPriorityAttackMobsSet
protected

Definition at line 447 of file actormanager.h.

Referenced by findNearestLivingBeing(), and removeAttackMob().

◆ mSpellHeal1

std::string ActorManager::mSpellHeal1
protected

Definition at line 422 of file actormanager.h.

Referenced by heal().

◆ mSpellHeal2

std::string ActorManager::mSpellHeal2
protected

Definition at line 423 of file actormanager.h.

Referenced by heal().

◆ mSpellItenplz

std::string ActorManager::mSpellItenplz
protected

Definition at line 424 of file actormanager.h.

Referenced by itenplz().

◆ mTargetDeadPlayers

bool ActorManager::mTargetDeadPlayers
protected

Definition at line 427 of file actormanager.h.

Referenced by findBeingByPixel(), findBeingsByPixel(), optionChanged(), and validateBeing().

◆ mTargetOnlyReachable

bool ActorManager::mTargetOnlyReachable
protected

The documentation for this class was generated from the following files: