mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-07-11 03:13:10 +00:00
Merge branch 'master' of https://gitlab.com/azerothshard/azerothcore
This commit is contained in:
@@ -27,57 +27,63 @@
|
||||
return playerQuestRate;
|
||||
}
|
||||
|
||||
// uint32 AzthPlayer::getOriginalTeam() {
|
||||
// return player->TeamForRace(player->getRace());
|
||||
// }
|
||||
//
|
||||
// bool AzthPlayer::setFactionForRace(uint8 race) {
|
||||
//
|
||||
// /* [TODO] implement zone check
|
||||
// * we already notify setFactionForRace on zone change in our AzthPlayerPlg
|
||||
//
|
||||
// if (zone in limited list from custom db table) then
|
||||
// return false;
|
||||
//
|
||||
// */
|
||||
//
|
||||
// if (player->InBattleground()) {
|
||||
// if (Battleground * bg = player->GetBattleground()) {
|
||||
// player->m_team = player->GetBGTeam();
|
||||
//
|
||||
// player->setFaction(player->m_team == ALLIANCE ? 1 : 2);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// ObjectGuid leaderGuid = player->GetGroup() ? player->GetGroup()->GetLeaderGUID() : player->GetGUID();
|
||||
// if (leaderGuid != player->GetGUID()) {
|
||||
// Player* leader = ObjectAccessor::FindPlayer(leaderGuid);
|
||||
//
|
||||
// if (leader) {
|
||||
// player->m_team = leader->GetTeam();
|
||||
// player->setFaction(leader->getFaction());
|
||||
// } else {
|
||||
// // Query informations from the DB
|
||||
// PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
// stmt->setUInt32(0, leaderGuid.GetCounter());
|
||||
// PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
//
|
||||
// if (!result)
|
||||
// return false;
|
||||
//
|
||||
// Field* fields = result->Fetch();
|
||||
// uint8 raceid = fields[4].GetUInt8();
|
||||
//
|
||||
// player->m_team = Player::TeamForRace(raceid);
|
||||
//
|
||||
// ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(raceid);
|
||||
// player->setFaction(rEntry ? rEntry->FactionID : 0);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
// }
|
||||
uint32 AzthPlayer::getOriginalTeam() {
|
||||
return player->TeamIdForRace(player->getRace());
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
player->setFaction(player->m_team == ALLIANCE ? 1 : 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
uint64 leaderGuid = player->GetGroup() ? player->GetGroup()->GetLeaderGUID() : player->GetGUID();
|
||||
if (leaderGuid != player->GetGUID()) {
|
||||
Player* leader = ObjectAccessor::FindPlayer(leaderGuid);
|
||||
|
||||
if (leader) {
|
||||
player->m_team = leader->GetTeamId();
|
||||
player->setFaction(leader->getFaction());
|
||||
} else {
|
||||
// Query informations from the DB
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
|
||||
stmt->setUInt32(0, GUID_LOPART(leaderGuid));
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint8 raceid = fields[4].GetUInt8();
|
||||
|
||||
player->m_team = Player::TeamIdForRace(raceid);
|
||||
|
||||
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(raceid);
|
||||
player->setFaction(rEntry ? rEntry->FactionID : 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6934,6 +6934,12 @@ TeamId Player::TeamIdForRace(uint8 race)
|
||||
void Player::setFactionForRace(uint8 race)
|
||||
{
|
||||
m_team = TeamIdForRace(race);
|
||||
|
||||
// [AZTH] Kepler: Inject AzthPlayer's team function to get team from group leader in CrossFactionGroups
|
||||
if (azthPlayer->setFactionForRace(race))
|
||||
return;
|
||||
// [/AZTH]
|
||||
|
||||
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
|
||||
setFaction(rEntry ? rEntry->FactionID : 0);
|
||||
}
|
||||
@@ -12222,10 +12228,10 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto) const
|
||||
|
||||
if (proto)
|
||||
{
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && GetTeamId() != TEAM_HORDE)
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_HORDE_ONLY) && /*[AZTH]*/ azthPlayer->getOriginalTeam() != HORDE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && GetTeamId() != TEAM_ALLIANCE)
|
||||
if ((proto->Flags2 & ITEM_FLAGS_EXTRA_ALLIANCE_ONLY) && /*[AZTH]*/ azthPlayer->getOriginalTeam() != ALLIANCE)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if ((proto->AllowableClass & getClassMask()) == 0 || (proto->AllowableRace & getRaceMask()) == 0)
|
||||
@@ -27067,4 +27073,4 @@ void Player::UpdateKnownTitles()
|
||||
SetFlag64(PLAYER__FIELD_KNOWN_TITLES, uint64(1) << new_title);
|
||||
if (old_title > 0 && old_title < (2 * HKRANKMAX - 1) && new_title > old_title)
|
||||
SetUInt32Value(PLAYER_CHOSEN_TITLE, new_title);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user