Core/Maps: Split Ebon Hold by faction and removed forced sanctuary hack

original commit: 515c0a43ef8fcf41ffb2785c5940f0234e757ec3
This commit is contained in:
Shauren authored and Ovahlord committed 2022-12-29 22:58:20 +01:00
1 parent 4500ee8284
commit 55843a00c6
4 files changed
+43 -3

No files matched your search

+11 -3
View File
@@ -225,8 +225,6 @@ struct AreaTableEntry
// helpers
bool IsSanctuary() const
{
if (ContinentID == 609)
return true;
return (Flags & AREA_FLAG_SANCTUARY) != 0;
}
@@ -1256,11 +1254,21 @@ struct MapEntry
bool IsContinent() const
{
return ID == 0 || ID == 1 || ID == 530 || ID == 571;
switch (ID)
{
case 0:
case 1:
case 530:
case 571:
return true;
default:
return false;
}
}
bool IsDynamicDifficultyMap() const { return GetFlags().HasFlag(MapFlags::DynamicDifficulty); }
bool IsFlexLocking() const { return GetFlags().HasFlag(MapFlags::FlexibleRaidLocking); }
bool IsSplitByFaction() const { return ID == 609; }
EnumFlag<MapFlags> GetFlags() const { return static_cast<MapFlags>(Flags); }
};
+27
View File
@@ -28,7 +28,9 @@
#include "ObjectMgr.h"
#include "Opcodes.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "World.h"
#include "WorldStateMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include <boost/dynamic_bitset.hpp>
@@ -223,6 +225,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);
@@ -481,3 +486,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);
}
+2
View File
@@ -125,6 +125,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;
+3
View File
@@ -1052,6 +1052,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!");