diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/database/Database/Implementation/WorldDatabase.cpp | 5 | ||||
-rw-r--r-- | src/server/database/Database/Implementation/WorldDatabase.h | 1 | ||||
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.h | 1 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 110 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/Handlers/MiscHandler.cpp | 7 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 4 | ||||
-rw-r--r-- | src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp | 7 | ||||
-rw-r--r-- | src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp | 7 |
10 files changed, 76 insertions, 89 deletions
diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp index ec9f91a548c..6d66c51a9b7 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.cpp +++ b/src/server/database/Database/Implementation/WorldDatabase.cpp @@ -30,8 +30,8 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_SMART_SCRIPTS, "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, event_param5, event_param_string, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, action_param7, target_type, target_param1, target_param2, target_param3, target_param4, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_EVENT_GAMEOBJECT, "DELETE FROM game_event_gameobject WHERE guid = ?", CONNECTION_ASYNC); - PrepareStatement(WORLD_INS_GRAVEYARD_ZONE, "INSERT INTO graveyard_zone (ID, GhostZone, Faction) VALUES (?, ?, ?)", CONNECTION_ASYNC); - PrepareStatement(WORLD_DEL_GRAVEYARD_ZONE, "DELETE FROM graveyard_zone WHERE ID = ? AND GhostZone = ? AND Faction = ?", CONNECTION_ASYNC); + PrepareStatement(WORLD_INS_GRAVEYARD_ZONE, "INSERT INTO graveyard_zone (ID, GhostZone) VALUES (?, ?)", CONNECTION_ASYNC); + PrepareStatement(WORLD_DEL_GRAVEYARD_ZONE, "DELETE FROM graveyard_zone WHERE ID = ? AND GhostZone = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_GAME_TELE, "INSERT INTO game_tele (id, position_x, position_y, position_z, orientation, map, name) VALUES (?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAME_TELE, "DELETE FROM game_tele WHERE name = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_INS_NPC_VENDOR, "INSERT INTO npc_vendor (entry, item, maxcount, incrtime, extendedcost, type) VALUES(?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); @@ -93,6 +93,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_DEL_SPAWNGROUP_MEMBER, "DELETE FROM spawn_group WHERE spawnType = ? AND spawnId = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_DEL_GAMEOBJECT_ADDON, "DELETE FROM gameobject_addon WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_SEL_GUILD_REWARDS_REQ_ACHIEVEMENTS, "SELECT AchievementRequired FROM guild_rewards_req_achievements WHERE ItemID = ?", CONNECTION_SYNCH); + PrepareStatement(WORLD_INS_CONDITION, "INSERT INTO conditions (SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName, Comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); } WorldDatabaseConnection::WorldDatabaseConnection(MySQLConnectionInfo& connInfo) : MySQLConnection(connInfo) diff --git a/src/server/database/Database/Implementation/WorldDatabase.h b/src/server/database/Database/Implementation/WorldDatabase.h index 6accb902f63..64ecb3a609c 100644 --- a/src/server/database/Database/Implementation/WorldDatabase.h +++ b/src/server/database/Database/Implementation/WorldDatabase.h @@ -99,6 +99,7 @@ enum WorldDatabaseStatements : uint32 WORLD_DEL_SPAWNGROUP_MEMBER, WORLD_DEL_GAMEOBJECT_ADDON, WORLD_SEL_GUILD_REWARDS_REQ_ACHIEVEMENTS, + WORLD_INS_CONDITION, MAX_WORLDDATABASE_STATEMENTS }; diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 5156a33ff13..0ebf2c0f807 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -1033,6 +1033,7 @@ bool ConditionMgr::CanHaveSourceGroupSet(ConditionSourceType sourceType) sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT || sourceType == CONDITION_SOURCE_TYPE_NPC_VENDOR || sourceType == CONDITION_SOURCE_TYPE_PHASE || + sourceType == CONDITION_SOURCE_TYPE_GRAVEYARD || sourceType == CONDITION_SOURCE_TYPE_AREATRIGGER || sourceType == CONDITION_SOURCE_TYPE_TRAINER_SPELL || sourceType == CONDITION_SOURCE_TYPE_OBJECT_ID_VISIBILITY); @@ -1457,6 +1458,9 @@ void ConditionMgr::LoadConditions(bool isReload) case CONDITION_SOURCE_TYPE_PHASE: valid = addToPhases(cond); break; + case CONDITION_SOURCE_TYPE_GRAVEYARD: + valid = addToGraveyardData(cond); + break; case CONDITION_SOURCE_TYPE_AREATRIGGER: { AreaTriggerConditionContainerStore[{ cond->SourceGroup, cond->SourceEntry }].push_back(cond); @@ -1715,6 +1719,18 @@ bool ConditionMgr::addToPhases(Condition* cond) const return false; } +bool ConditionMgr::addToGraveyardData(Condition* cond) const +{ + if (GraveyardData* graveyard = const_cast<GraveyardData*>(sObjectMgr->FindGraveyardData(cond->SourceEntry, cond->SourceGroup))) + { + graveyard->Conditions.push_back(cond); + return true; + } + + TC_LOG_ERROR("sql.sql", "{}, Graveyard {} does not have ghostzone {}.", cond->ToString(), cond->SourceEntry, cond->SourceGroup); + return false; +} + bool ConditionMgr::isSourceTypeValid(Condition* cond) const { switch (cond->SourceType) @@ -2088,9 +2104,9 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const case CONDITION_SOURCE_TYPE_SMART_EVENT: break; case CONDITION_SOURCE_TYPE_GRAVEYARD: - if (!sObjectMgr->GetWorldSafeLoc(cond->SourceEntry)) + if (!sObjectMgr->FindGraveyardData(cond->SourceEntry, cond->SourceGroup)) { - TC_LOG_ERROR("sql.sql", "{} SourceEntry in `condition` table, does not exist in WorldSafeLocs.db2, ignoring.", cond->ToString()); + TC_LOG_ERROR("sql.sql", "{} SourceEntry in `condition` table, does not exist in `graveyard_zone`, ignoring.", cond->ToString()); return false; } break; diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index 5c37213cb7c..b9766aa8268 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -328,6 +328,7 @@ class TC_GAME_API ConditionMgr bool addToGossipMenuItems(Condition* cond) const; bool addToSpellImplicitTargetConditions(Condition* cond) const; bool addToPhases(Condition* cond) const; + bool addToGraveyardData(Condition* cond) const; bool IsObjectMeetToConditionList(ConditionSourceInfo& sourceInfo, ConditionContainer const& conditions) const; static void LogUselessConditionValue(Condition* cond, uint8 index, uint32 value); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 78179a5534c..60ab1dfa41b 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -6822,8 +6822,8 @@ void ObjectMgr::LoadGraveyardZones() GraveyardStore.clear(); // needed for reload case - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT ID, GhostZone, Faction FROM graveyard_zone"); + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT ID, GhostZone FROM graveyard_zone"); if (!result) { @@ -6841,7 +6841,6 @@ void ObjectMgr::LoadGraveyardZones() uint32 safeLocId = fields[0].GetUInt32(); uint32 zoneId = fields[1].GetUInt32(); - uint32 team = fields[2].GetUInt16(); WorldSafeLocsEntry const* entry = GetWorldSafeLoc(safeLocId); if (!entry) @@ -6857,13 +6856,7 @@ void ObjectMgr::LoadGraveyardZones() continue; } - if (team != 0 && team != HORDE && team != ALLIANCE) - { - TC_LOG_ERROR("sql.sql", "Table `graveyard_zone` has a record for non player faction ({}), skipped.", team); - continue; - } - - if (!AddGraveyardLink(safeLocId, zoneId, team, false)) + if (!AddGraveyardLink(safeLocId, zoneId, 0, false)) TC_LOG_ERROR("sql.sql", "Table `graveyard_zone` has a duplicate record for Graveyard (ID: {}) and Zone (ID: {}), skipped.", safeLocId, zoneId); } while (result->NextRow()); @@ -6964,19 +6957,31 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyardInZone(WorldLocation con WorldSafeLocsEntry const* entry = ASSERT_NOTNULL(GetWorldSafeLoc(data.safeLocId)); - // skip enemy faction graveyard - // team == 0 case can be at call from .neargrave - if (data.team != 0 && team != 0 && data.team != team) - continue; - if (conditionObject) { - if (!sConditionMgr->IsObjectMeetingNotGroupedConditions(CONDITION_SOURCE_TYPE_GRAVEYARD, data.safeLocId, conditionSource)) + if (!sConditionMgr->IsObjectMeetToConditions(conditionSource, data.Conditions)) continue; if (int16(entry->Loc.GetMapId()) == mapEntry->ParentMapID && !conditionObject->GetPhaseShift().HasVisibleMapId(entry->Loc.GetMapId())) continue; } + else if (team != 0) + { + bool teamConditionMet = true; + for (Condition const* cond : data.Conditions) + { + if (cond->ConditionType != CONDITION_TEAM) + continue; + + if (cond->ConditionValue1 == team) + continue; + + teamConditionMet = false; + } + + if (!teamConditionMet) + continue; + } // find now nearest graveyard at other map if (MapId != entry->Loc.GetMapId() && int16(entry->Loc.GetMapId()) != mapEntry->ParentMapID) @@ -7115,7 +7120,6 @@ bool ObjectMgr::AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool per // add link to loaded data GraveyardData data; data.safeLocId = id; - data.team = team; GraveyardStore.insert(GraveyardContainer::value_type(zoneId, data)); @@ -7126,60 +7130,38 @@ bool ObjectMgr::AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool per stmt->setUInt32(0, id); stmt->setUInt32(1, zoneId); - stmt->setUInt16(2, uint16(team)); WorldDatabase.Execute(stmt); - } - return true; -} - -void ObjectMgr::RemoveGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist /*= false*/) -{ - GraveyardMapBoundsNonConst range = GraveyardStore.equal_range(zoneId); - if (range.first == range.second) - { - //TC_LOG_ERROR("sql.sql", "Table `graveyard_zone` incomplete: Zone {} Team {} does not have a linked graveyard.", zoneId, team); - return; - } - - bool found = false; - - for (; range.first != range.second; ++range.first) - { - GraveyardData & data = range.first->second; - - // skip not matching safezone id - if (data.safeLocId != id) - continue; + // Store graveyard condition if team is set + if (team != 0) + { + WorldDatabasePreparedStatement* conditionStmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CONDITION); + conditionStmt->setUInt32(0, CONDITION_SOURCE_TYPE_GRAVEYARD); // SourceTypeOrReferenceId + conditionStmt->setUInt32(1, zoneId); // SourceGroup + conditionStmt->setUInt32(2, id); // SourceEntry + conditionStmt->setUInt32(3, 0); // SourceId + conditionStmt->setUInt32(4, 0); // ElseGroup + conditionStmt->setUInt32(5, CONDITION_TEAM); // ConditionTypeOrReference + conditionStmt->setUInt8(6, 0); // ConditionTarget + conditionStmt->setUInt32(7, team); // ConditionValue1 + conditionStmt->setUInt32(8, 0); // ConditionValue2 + conditionStmt->setUInt32(9, 0); // ConditionValue3 + conditionStmt->setUInt8(10, 0); // NegativeCondition + conditionStmt->setUInt32(11, 0); // ErrorType + conditionStmt->setUInt32(12, 0); // ErrorTextId + conditionStmt->setString(13, ""); // ScriptName + conditionStmt->setString(14, ""); // Comment - // skip enemy faction graveyard at same map (normal area, city, or battleground) - // team == 0 case can be at call from .neargrave - if (data.team != 0 && team != 0 && data.team != team) - continue; + WorldDatabase.Execute(conditionStmt); - found = true; - break; + // reload conditions to make sure everything is loaded as it should be + sConditionMgr->LoadConditions(true); + sScriptMgr->NotifyScriptIDUpdate(); + } } - // no match, return - if (!found) - return; - - // remove from links - GraveyardStore.erase(range.first); - - // remove link from DB - if (persist) - { - WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE); - - stmt->setUInt32(0, id); - stmt->setUInt32(1, zoneId); - stmt->setUInt16(2, uint16(team)); - - WorldDatabase.Execute(stmt); - } + return true; } void ObjectMgr::LoadAreaTriggerTeleports() diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 939f5bcc217..592a9557547 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -839,7 +839,7 @@ struct WorldSafeLocsEntry struct GraveyardData { uint32 safeLocId; - uint32 team; + ConditionContainer Conditions; }; typedef std::multimap<uint32, GraveyardData> GraveyardContainer; @@ -1226,7 +1226,6 @@ class TC_GAME_API ObjectMgr WorldSafeLocsEntry const* GetClosestGraveyard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const; WorldSafeLocsEntry const* GetClosestGraveyardInZone(WorldLocation const& location, uint32 team, WorldObject* conditionObject, uint32 zoneId) const; bool AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true); - void RemoveGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false); void LoadGraveyardZones(); GraveyardData const* FindGraveyardData(uint32 id, uint32 zone) const; void LoadWorldSafeLocs(); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 9bcd05ade38..b0eca9c6b93 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -368,8 +368,11 @@ void WorldSession::HandleRequestCemeteryList(WorldPackets::Misc::RequestCemetery for (auto it = range.first; it != range.second && graveyardIds.size() < 16; ++it) // client max { - if (it->second.team == 0 || it->second.team == team) - graveyardIds.push_back(it->first); + ConditionSourceInfo conditionSource(_player); + if (!sConditionMgr->IsObjectMeetToConditions(conditionSource, it->second.Conditions)) + continue; + + graveyardIds.push_back(it->first); } if (graveyardIds.empty()) diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 3f2f8416699..e3722ad370d 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1020,7 +1020,7 @@ public: return false; } - if (sObjectMgr->AddGraveyardLink(graveyardId, zoneId, team)) + if (sObjectMgr->AddGraveyardLink(graveyardId, zoneId, team, true)) handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId); else handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId); @@ -1057,8 +1057,6 @@ public: return false; } - team = data->team; - std::string team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM); if (team == 0) diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp index 953cfe26d27..06691aa8a0e 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp @@ -29,7 +29,6 @@ uint32 const NA_CREDIT_MARKER = 24867; // kill credit for pks uint32 const NA_GUARDS_MAX = 15; uint32 const NA_BUFF_ZONE = 3518; -uint32 const NA_HALAA_GRAVEYARD = 993; uint32 const NA_HALAA_GRAVEYARD_ZONE = 3518; // need to add zone id, not area id uint32 const NA_RESPAWN_TIME = 3600000; // one hour to capture after defeating all guards uint32 const NA_GUARD_CHECK_TIME = 500; // every half second @@ -87,13 +86,7 @@ uint32 OPvPCapturePointNA::GetControllingFaction() const void OPvPCapturePointNA::FactionTakeOver(uint32 team) { - if (m_ControllingFaction) - sObjectMgr->RemoveGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false); - m_ControllingFaction = team; - if (m_ControllingFaction) - sObjectMgr->AddGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false); - m_GuardsAlive = NA_GUARDS_MAX; m_capturable = false; UpdateHalaaWorldState(); diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp index 7df21ba6fc2..1c8c7c1ae87 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp @@ -36,9 +36,6 @@ uint32 const OutdoorPvPZMBuffZones[OutdoorPvPZMBuffZonesNum] = { 3521, 3607, 371 // linked when the central tower is controlled uint32 const ZM_GRAVEYARD_ZONE = 3521; -// linked when the central tower is controlled -uint32 const ZM_GRAVEYARD_ID = 969; - struct zm_beacon { int32 ui_tower_n; @@ -241,8 +238,6 @@ int32 OPvPCapturePointZM_Graveyard::HandleOpenGo(Player* player, GameObject* go) if (player->HasAura(ZM_BATTLE_STANDARD_A) && m_GraveyardState != ZM_GRAVEYARD_A) { m_GraveyardState = ZM_GRAVEYARD_A; - sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE); // rem gy - sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE, false); // add gy m_PvP->TeamApplyBuff(TEAM_ALLIANCE, ZM_CAPTURE_BUFF); player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); m_PvP->SendDefenseMessage(ZM_GRAVEYARD_ZONE, TEXT_TWIN_SPIRE_RUINS_TAKEN_ALLIANCE); @@ -250,8 +245,6 @@ int32 OPvPCapturePointZM_Graveyard::HandleOpenGo(Player* player, GameObject* go) else if (player->HasAura(ZM_BATTLE_STANDARD_H) && m_GraveyardState != ZM_GRAVEYARD_H) { m_GraveyardState = ZM_GRAVEYARD_H; - sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, ALLIANCE); // rem gy - sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, HORDE, false); // add gy m_PvP->TeamApplyBuff(TEAM_HORDE, ZM_CAPTURE_BUFF); player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); m_PvP->SendDefenseMessage(ZM_GRAVEYARD_ZONE, TEXT_TWIN_SPIRE_RUINS_TAKEN_HORDE); |