Core/Maps: Split Ebon Hold and Exile's reach by faction and removed forced sanctuary hack

Port From (https://github.com/TrinityCore/TrinityCore/commit/515c0a43ef8fcf41ffb2785c5940f0234e757ec3)
This commit is contained in:
hondacrx
2022-07-25 22:25:09 -04:00
parent a3bd0f274a
commit 888fd11477
4 changed files with 45 additions and 6 deletions
@@ -147,9 +147,6 @@ namespace Game.DataStorage
public bool IsSanctuary() public bool IsSanctuary()
{ {
if (ContinentID == 609)
return true;
return HasFlag(AreaFlags.Sanctuary); return HasFlag(AreaFlags.Sanctuary);
} }
+17 -1
View File
@@ -86,11 +86,27 @@ namespace Game.DataStorage
public bool IsContinent() public bool IsContinent()
{ {
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;
}
} }
public bool IsDynamicDifficultyMap() { return (Flags[0] & MapFlags.CanToggleDifficulty) != 0; } public bool IsDynamicDifficultyMap() { return (Flags[0] & MapFlags.CanToggleDifficulty) != 0; }
public bool IsGarrison() { return (Flags[0] & MapFlags.Garrison) != 0; } public bool IsGarrison() { return (Flags[0] & MapFlags.Garrison) != 0; }
public bool IsSplitByFaction() { return Id == 609 || Id == 2175; }
} }
public sealed class MapChallengeModeRecord public sealed class MapChallengeModeRecord
+25 -2
View File
@@ -22,6 +22,7 @@ using Game.DataStorage;
using Game.Garrisons; using Game.Garrisons;
using Game.Groups; using Game.Groups;
using Game.Maps; using Game.Maps;
using Game.Scripting;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -232,6 +233,9 @@ namespace Game.Entities
else else
{ {
newInstanceId = 0; newInstanceId = 0;
if (entry.IsSplitByFaction())
newInstanceId = (uint)player.GetTeamId();
map = FindMap_i(mapId, newInstanceId); map = FindMap_i(mapId, newInstanceId);
if (!map) if (!map)
map = CreateWorldMap(mapId, newInstanceId); map = CreateWorldMap(mapId, newInstanceId);
@@ -356,7 +360,7 @@ namespace Game.Entities
} }
public uint GenerateInstanceId() public uint GenerateInstanceId()
{ {
if (_nextInstanceId == 0xFFFFFFFF) if (_nextInstanceId == 0xFFFFFFFF)
{ {
Log.outError(LogFilter.Maps, "Instance ID overflow!! Can't continue, shutting down server. "); Log.outError(LogFilter.Maps, "Instance ID overflow!! Can't continue, shutting down server. ");
@@ -438,6 +442,13 @@ namespace Game.Entities
} }
} }
public void AddSC_BuiltInScripts()
{
foreach (var (_, mapEntry) in CliDB.MapStorage)
if (mapEntry.IsWorldMap() && mapEntry.IsSplitByFaction())
new SplitByFactionMapScript($"world_map_set_faction_worldstates_{mapEntry.Id}", mapEntry.Id);
}
public void IncreaseScheduledScriptsCount() { ++_scheduledScripts; } public void IncreaseScheduledScriptsCount() { ++_scheduledScripts; }
public void DecreaseScheduledScriptCount() { --_scheduledScripts; } public void DecreaseScheduledScriptCount() { --_scheduledScripts; }
public void DecreaseScheduledScriptCount(uint count) { _scheduledScripts -= count; } public void DecreaseScheduledScriptCount(uint count) { _scheduledScripts -= count; }
@@ -445,11 +456,23 @@ namespace Game.Entities
Dictionary<(uint mapId, uint instanceId), Map> i_maps = new(); Dictionary<(uint mapId, uint instanceId), Map> i_maps = new();
IntervalTimer i_timer = new(); IntervalTimer i_timer = new();
object _mapsLock= new(); object _mapsLock = new();
uint i_gridCleanUpDelay; uint i_gridCleanUpDelay;
BitSet _freeInstanceIds; BitSet _freeInstanceIds;
uint _nextInstanceId; uint _nextInstanceId;
MapUpdater m_updater; MapUpdater m_updater;
uint _scheduledScripts; uint _scheduledScripts;
} }
// hack to allow conditions to access what faction owns the map (these worldstates should not be set on these maps)
class SplitByFactionMapScript : WorldMapScript
{
public SplitByFactionMapScript(string name, uint mapId) : base(name, mapId) { }
public override void OnCreate(Map map)
{
Global.WorldStateMgr.SetValue(WorldStates.TeamInInstanceAlliance, map.GetInstanceId() == TeamId.Alliance ? 1 : 0, false, map);
Global.WorldStateMgr.SetValue(WorldStates.TeamInInstanceHorde, map.GetInstanceId() == TeamId.Horde ? 1 : 0, false, map);
}
}
} }
+3
View File
@@ -59,6 +59,9 @@ namespace Game.Scripting
//Load Scripts.dll //Load Scripts.dll
LoadScripts(); LoadScripts();
// MapScripts
Global.MapMgr.AddSC_BuiltInScripts();
Log.outInfo(LogFilter.ServerLoading, $"Loaded {GetScriptCount()} C# scripts in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); Log.outInfo(LogFilter.ServerLoading, $"Loaded {GetScriptCount()} C# scripts in {Time.GetMSTimeDiffToNow(oldMSTime)} ms");
} }