mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-07-11 03:13:10 +00:00
[AZTH] moved zone check in our setFactionForRace function
This commit is contained in:
@@ -32,6 +32,21 @@ uint32 AzthPlayer::getOriginalTeam() {
|
||||
}
|
||||
|
||||
bool AzthPlayer::setFactionForRace(uint8 race) {
|
||||
|
||||
bool disable = true;
|
||||
|
||||
CrossFaction *cf = sCrossFaction;
|
||||
|
||||
// Check disables
|
||||
if (cf->isMapEnabled(player->GetMapId()) && cf->isZoneEnabled(player->GetZoneId()) && cf->isAreaEnabled(player->GetAreaId()))
|
||||
disable = false;
|
||||
else
|
||||
{
|
||||
player->Whisper("Quest'area ha il crossfaction disabilitato", LANG_UNIVERSAL, player->GetGUID());
|
||||
sLog->outError("Crossfaction disabled for player %s", player->GetName().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player->InBattleground()) {
|
||||
if (Battleground * bg = player->GetBattleground()) {
|
||||
player->m_team = player->GetBgTeamId();
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
#include "Config.h"
|
||||
#include "Define.h"
|
||||
#include "Player.h"
|
||||
#include "CrossFaction.h"
|
||||
|
||||
class CrossFaction;
|
||||
|
||||
/* [TODO] fix and re-enable */
|
||||
class AzthPlayer {
|
||||
class AzthPlayer {
|
||||
public:
|
||||
explicit AzthPlayer(Player *origin);
|
||||
~AzthPlayer();
|
||||
|
||||
@@ -14,28 +14,6 @@ void CrossFaction::UpdatePlayerTeam(Group* group, uint64 guid, bool reset /* = f
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
if (player)
|
||||
{
|
||||
bool disable = true;
|
||||
|
||||
// Check disables
|
||||
if (isMapEnabled(player->GetMapId()) && isZoneEnabled(player->GetZoneId()) && isAreaEnabled(player->GetAreaId()))
|
||||
disable = false;
|
||||
else
|
||||
{
|
||||
player->Whisper("This specific area has crossfaction disabled", LANG_UNIVERSAL, player->GetGUID());
|
||||
sLog->outError("Crossfaction disabled for player %s", player->GetName().c_str());
|
||||
}
|
||||
|
||||
// check conditions and set new faction
|
||||
if (!reset)
|
||||
if(!disable)
|
||||
if (group)
|
||||
if (Player* groupLeader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()))
|
||||
{
|
||||
player->setFactionForRace(groupLeader->getRace());
|
||||
return;
|
||||
}
|
||||
|
||||
// ANY OTHER CASE: just reset it back
|
||||
player->setFactionForRace(player->getRace());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ class CrossFaction
|
||||
void LoadConfig(bool reload);
|
||||
void UpdatePlayerTeam(Group* group, uint64 guid, bool reset = false);
|
||||
|
||||
// Check functions
|
||||
bool isMapEnabled(uint32 mapid) { return std::find(mapDisable.begin(), mapDisable.end(), mapid) == mapDisable.end(); };
|
||||
bool isZoneEnabled(uint32 mapid) { return std::find(zoneDisable.begin(), zoneDisable.end(), mapid) == zoneDisable.end(); };
|
||||
bool isAreaEnabled(uint32 mapid) { return std::find(areaDisable.begin(), areaDisable.end(), mapid) == areaDisable.end(); };
|
||||
|
||||
private:
|
||||
typedef std::vector<uint32> CrossFactionDisableList;
|
||||
|
||||
@@ -26,15 +31,9 @@ class CrossFaction
|
||||
CrossFactionDisableList mapDisable;
|
||||
CrossFactionDisableList zoneDisable;
|
||||
CrossFactionDisableList areaDisable;
|
||||
|
||||
// Check functions
|
||||
bool isMapEnabled(uint32 mapid) { return std::find(mapDisable.begin(), mapDisable.end(), mapid) == mapDisable.end(); };
|
||||
bool isZoneEnabled(uint32 mapid) { return std::find(zoneDisable.begin(), zoneDisable.end(), mapid) == zoneDisable.end(); };
|
||||
bool isAreaEnabled(uint32 mapid) { return std::find(areaDisable.begin(), areaDisable.end(), mapid) == areaDisable.end(); };
|
||||
|
||||
};
|
||||
|
||||
#define sCrossFaction ACE_Singleton<CrossFaction, ACE_Null_Mutex>::instance()
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user