aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-07-25 21:43:19 +0200
committerShauren <shauren.trinity@gmail.com>2022-07-25 21:43:19 +0200
commit515c0a43ef8fcf41ffb2785c5940f0234e757ec3 (patch)
tree0037e3bed226299ca806680edd074827bb6db2ca /src/server
parent47aa69ca32c79dfdab9cd2cdbd64e69c9716e413 (diff)
Core/Maps: Split Ebon Hold and Exile's reach by faction and removed forced sanctuary hack
Diffstat (limited to 'src/server')
-rw-r--r--src/server/game/DataStores/DB2Structure.h20
-rw-r--r--src/server/game/Maps/MapManager.cpp27
-rw-r--r--src/server/game/Maps/MapManager.h2
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp3
4 files changed, 49 insertions, 3 deletions
diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h
index 13da4dff96d..e7b4578dac9 100644
--- a/src/server/game/DataStores/DB2Structure.h
+++ b/src/server/game/DataStores/DB2Structure.h
@@ -152,8 +152,6 @@ struct AreaTableEntry
// helpers
bool IsSanctuary() const
{
- if (ContinentID == 609)
- return true;
return (Flags[0] & AREA_FLAG_SANCTUARY) != 0;
}
@@ -2538,11 +2536,27 @@ struct MapEntry
bool IsContinent() const
{
- return ID == 0 || ID == 1 || ID == 530 || ID == 571 || ID == 870 || ID == 1116 || ID == 1220;
+ switch (ID)
+ {
+ case 0:
+ case 1:
+ case 530:
+ case 571:
+ case 870:
+ case 1116:
+ case 1220:
+ case 1642:
+ case 1643:
+ case 2222:
+ return true;
+ default:
+ return false;
+ }
}
bool IsDynamicDifficultyMap() const { return (Flags[0] & MAP_FLAG_CAN_TOGGLE_DIFFICULTY) != 0; }
bool IsGarrison() const { return (Flags[0] & MAP_FLAG_GARRISON) != 0; }
+ bool IsSplitByFaction() const { return ID == 609 || ID == 2175; }
};
struct MapChallengeModeEntry
diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp
index 6bf66b153ff..5ad256d18bf 100644
--- a/src/server/game/Maps/MapManager.cpp
+++ b/src/server/game/Maps/MapManager.cpp
@@ -27,7 +27,9 @@
#include "Map.h"
#include "Player.h"
#include "ScenarioMgr.h"
+#include "ScriptMgr.h"
#include "World.h"
+#include "WorldStateMgr.h"
#include <boost/dynamic_bitset.hpp>
#include <numeric>
@@ -236,6 +238,9 @@ Map* MapManager::CreateMap(uint32 mapId, Player* player, uint32 loginInstanceId
else
{
newInstanceId = 0;
+ if (entry->IsSplitByFaction())
+ newInstanceId = player->GetTeamId();
+
map = FindMap_i(mapId, newInstanceId);
if (!map)
map = CreateWorldMap(mapId, newInstanceId);
@@ -396,3 +401,25 @@ void MapManager::FreeInstanceId(uint32 instanceId)
_nextInstanceId = std::min(instanceId, _nextInstanceId);
_freeInstanceIds->set(instanceId, true);
}
+
+// hack to allow conditions to access what faction owns the map (these worldstates should not be set on these maps)
+class SplitByFactionMapScript : public WorldMapScript
+{
+public:
+ SplitByFactionMapScript(char const* name, uint32 mapId) : WorldMapScript(name, mapId)
+ {
+ }
+
+ void OnCreate(Map* map) override
+ {
+ sWorldStateMgr->SetValue(WS_TEAM_IN_INSTANCE_ALLIANCE, map->GetInstanceId() == TEAM_ALLIANCE, false, map);
+ sWorldStateMgr->SetValue(WS_TEAM_IN_INSTANCE_HORDE, map->GetInstanceId() == TEAM_HORDE, false, map);
+ }
+};
+
+void MapManager::AddSC_BuiltInScripts()
+{
+ for (MapEntry const* mapEntry : sMapStore)
+ if (mapEntry->IsWorldMap() && mapEntry->IsSplitByFaction())
+ new SplitByFactionMapScript(Trinity::StringFormat("world_map_set_faction_worldstates_%u", mapEntry->ID).c_str(), mapEntry->ID);
+}
diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h
index 8fb598dd8c2..304ca859c81 100644
--- a/src/server/game/Maps/MapManager.h
+++ b/src/server/game/Maps/MapManager.h
@@ -126,6 +126,8 @@ class TC_GAME_API MapManager
void DecreaseScheduledScriptCount(std::size_t count) { _scheduledScripts -= count; }
bool IsScriptScheduled() const { return _scheduledScripts > 0; }
+ void AddSC_BuiltInScripts();
+
private:
using MapKey = std::pair<uint32, uint32>;
typedef std::map<MapKey, Map*> MapMapType;
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 6733988ae85..994c02cb108 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -1229,6 +1229,9 @@ void ScriptMgr::Initialize()
// LFGScripts
lfg::AddSC_LFGScripts();
+ // MapScripts
+ sMapMgr->AddSC_BuiltInScripts();
+
// Load all static linked scripts through the script loader function.
ASSERT(_script_loader_callback,
"Script loader callback wasn't registered!");