Merge pull request #15 from atidot3/Playerbot

Playerbot fixes and functionnality to talk in channels
This commit is contained in:
Yunfan Li
2024-07-27 23:56:51 +08:00
committed by GitHub
5 changed files with 72 additions and 2 deletions

View File

@@ -41,6 +41,9 @@ DBCStorage <AreaGroupEntry> sAreaGroupStore(AreaGroupEntryfmt);
DBCStorage <AreaPOIEntry> sAreaPOIStore(AreaPOIEntryfmt);
static WMOAreaInfoByTripple sWMOAreaInfoByTripple;
static AreaFlagByAreaID sAreaFlagByAreaID;
// for instances without generated *.map files
static AreaFlagByMapID sAreaFlagByMapID;
DBCStorage <AchievementEntry> sAchievementStore(Achievementfmt);
DBCStorage <AchievementCategoryEntry> sAchievementCategoryStore(AchievementCategoryfmt);
@@ -396,6 +399,19 @@ void LoadDBCStores(const std::string& dataPath)
#undef LOAD_DBC
for (uint32 i = 0; i < sAreaTableStore.GetNumRows(); ++i) // areaflag numbered from 0
{
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(i))
{
// fill AreaId->DBC records
sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID), area->exploreFlag));
// fill MapId->DBC records ( skip sub zones and continents )
if (area->zone == 0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530)
sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid, area->exploreFlag));
}
}
for (CharStartOutfitEntry const* outfit : sCharStartOutfitStore)
sCharStartOutfitMap[outfit->Race | (outfit->Class << 8) | (outfit->Gender << 16)] = outfit;
@@ -960,3 +976,40 @@ const std::vector<SkillLineAbilityEntry const*>& GetSkillLineAbilitiesBySkillLin
}
return it->second;
}
uint32 GetAreaFlagByMapId(uint32 mapid)
{
AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid);
if (i == sAreaFlagByMapID.end())
return 0;
return i->second;
}
int32 GetAreaFlagByAreaID(uint32 area_id)
{
AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id);
if (i == sAreaFlagByAreaID.end())
return -1;
return i->second;
}
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id)
{
int32 areaflag = GetAreaFlagByAreaID(area_id);
if (areaflag < 0)
return nullptr;
return sAreaTableStore.LookupEntry(areaflag);
}
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id)
{
if (area_flag)
return sAreaTableStore.LookupEntry(area_flag);
if (MapEntry const* mapEntry = sMapStore.LookupEntry(map_id))
return GetAreaEntryByAreaID(mapEntry->linked_zone);
return nullptr;
}

View File

@@ -35,6 +35,13 @@ TalentSpellPos const* GetTalentSpellPos(uint32 spellId);
WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid);
// -1 if not found
int32 GetAreaFlagByAreaID(uint32 area_id);
uint32 GetAreaFlagByMapId(uint32 mapid);
AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id);
AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id);
uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId);
enum ContentLevels : uint8

View File

@@ -4955,6 +4955,15 @@ void Player::CleanupChannels()
}
}
// Playerbot helper if bot talks in a different locale
bool Player::IsInChannel(const Channel* c)
{
return std::any_of(m_channels.begin(), m_channels.end(), [c](const Channel* chan)
{
return c->GetChannelId() == chan->GetChannelId();
});
}
void Player::ClearChannelWatch()
{
for (JoinedChannelsList::iterator itr = m_channels.begin(); itr != m_channels.end(); ++itr)

View File

@@ -2043,6 +2043,7 @@ public:
void JoinedChannel(Channel* c);
void LeftChannel(Channel* c);
bool IsInChannel(const Channel* c);
void CleanupChannels();
void ClearChannelWatch();
void UpdateLocalChannels(uint32 newZone);

View File

@@ -516,8 +516,8 @@ public:
time_t m_muteTime;
// Locales
LocaleConstant GetSessionDbcLocale() const { return _isBot? LOCALE_enUS : m_sessionDbcLocale; }
LocaleConstant GetSessionDbLocaleIndex() const { return _isBot? LOCALE_enUS : m_sessionDbLocaleIndex; }
LocaleConstant GetSessionDbcLocale() const { return /*_isBot? LOCALE_enUS : */m_sessionDbcLocale; }
LocaleConstant GetSessionDbLocaleIndex() const { return /*_isBot? LOCALE_enUS : */m_sessionDbLocaleIndex; }
char const* GetAcoreString(uint32 entry) const;
uint32 GetLatency() const { return m_latency; }