aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/DataStores/DBCEnums.h7
-rw-r--r--src/server/game/Entities/Player/Player.cpp58
-rw-r--r--src/server/game/Entities/Player/Player.h1
3 files changed, 44 insertions, 22 deletions
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index e0b85d5f243..21f89c7b301 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -130,7 +130,7 @@ enum AreaFlags
AREA_FLAG_TOWN = 0x00200000, // small towns with Inn
AREA_FLAG_REST_ZONE_HORDE = 0x00400000, // Warsong Hold, Acherus: The Ebon Hold, New Agamand Inn, Vengeance Landing Inn, Sunreaver Pavilion (Something to do with team?)
AREA_FLAG_REST_ZONE_ALLIANCE = 0x00800000, // Valgarde, Acherus: The Ebon Hold, Westguard Inn, Silver Covenant Pavilion (Something to do with team?)
- AREA_FLAG_WINTERGRASP = 0x01000000, // Wintergrasp and it's subzones
+ AREA_FLAG_COMBAT = 0x01000000, // "combat" area (Script_GetZonePVPInfo), used
AREA_FLAG_INSIDE = 0x02000000, // used for determinating spell related inside/outside questions in Map::IsOutdoors
AREA_FLAG_OUTSIDE = 0x04000000, // used for determinating spell related inside/outside questions in Map::IsOutdoors
AREA_FLAG_CAN_HEARTH_AND_RESURRECT = 0x08000000, // Can Hearth And Resurrect From Area
@@ -138,6 +138,11 @@ enum AreaFlags
AREA_FLAG_UNK9 = 0x40000000
};
+enum AreaFlags2
+{
+ AREA_FLAG_2_DONT_SHOW_SANCTUARY = 0x00000200, // Hides sanctuary status from zone text color (Script_GetZonePVPInfo)
+};
+
enum AreaMountFlags
{
AREA_MOUNT_FLAG_GROUND_ALLOWED = 0x1,
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index c26cfc99d4a..0c135e75f99 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7189,27 +7189,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
GetMap()->SendZoneDynamicInfo(newZone, this);
- // in PvP, any not controlled zone (except zone->team == 6, default case)
- // in PvE, only opposition team capital
- switch (zone->FactionGroupMask)
- {
- case AREATEAM_ALLY:
- pvpInfo.IsInHostileArea = GetTeam() != ALLIANCE && (sWorld->IsPvPRealm() || zone->Flags[0] & AREA_FLAG_CAPITAL);
- break;
- case AREATEAM_HORDE:
- pvpInfo.IsInHostileArea = GetTeam() != HORDE && (sWorld->IsPvPRealm() || zone->Flags[0] & AREA_FLAG_CAPITAL);
- break;
- case AREATEAM_NONE:
- // overwrite for battlegrounds, maybe batter some zone flags but current known not 100% fit to this
- pvpInfo.IsInHostileArea = sWorld->IsPvPRealm() || InBattleground() || zone->Flags[0] & AREA_FLAG_WINTERGRASP;
- break;
- default: // 6 in fact
- pvpInfo.IsInHostileArea = false;
- break;
- }
-
- // Treat players having a quest flagging for PvP as always in hostile area
- pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest();
+ UpdateHostileAreaState(zone);
if (zone->Flags[0] & AREA_FLAG_CAPITAL) // Is in a capital city
{
@@ -7247,6 +7227,42 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
}
}
+void Player::UpdateHostileAreaState(AreaTableEntry const* area)
+{
+ pvpInfo.IsInHostileArea = false;
+
+ if (area->IsSanctuary()) // sanctuary and arena cannot be overriden
+ pvpInfo.IsInHostileArea = false;
+ else if (area->Flags[0] & AREA_FLAG_ARENA)
+ pvpInfo.IsInHostileArea = true;
+ else
+ {
+ if (area)
+ {
+ if (InBattleground() || area->Flags[0] & AREA_FLAG_COMBAT || (area->PvpCombatWorldStateID != -1 && sWorld->getWorldState(area->PvpCombatWorldStateID) != 0))
+ pvpInfo.IsInHostileArea = true;
+ else if (sWorld->IsPvPRealm() || (area->Flags[0] & AREA_FLAG_UNK3))
+ {
+ if (area->Flags[0] & AREA_FLAG_CONTESTED_AREA)
+ pvpInfo.IsInHostileArea = sWorld->IsPvPRealm();
+ else
+ {
+ FactionTemplateEntry const* factionTemplate = GetFactionTemplateEntry();
+ if (!factionTemplate || factionTemplate->FriendGroup & area->FactionGroupMask)
+ pvpInfo.IsInHostileArea = false;
+ else if (factionTemplate->EnemyGroup & area->FactionGroupMask)
+ pvpInfo.IsInHostileArea = true;
+ else
+ pvpInfo.IsInHostileArea = sWorld->IsPvPRealm();
+ }
+ }
+ }
+ }
+
+ // Treat players having a quest flagging for PvP as always in hostile area
+ pvpInfo.IsHostile = pvpInfo.IsInHostileArea || HasPvPForcingQuest();
+}
+
//If players are too far away from the duel flag... they lose the duel
void Player::CheckDuelDistance(time_t currTime)
{
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 3b69f04b319..2952253f87f 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1698,6 +1698,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void UpdatePvP(bool state, bool override = false);
void UpdateZone(uint32 newZone, uint32 newArea);
void UpdateArea(uint32 newArea);
+ void UpdateHostileAreaState(AreaTableEntry const* area);
void UpdateZoneDependentAuras(uint32 zone_id); // zones
void UpdateAreaDependentAuras(uint32 area_id); // subzones