diff --git a/Common/Configuration/ConfigContainer.cs b/Common/Configuration/ConfigContainer.cs index 01edc573..72fdad59 100644 --- a/Common/Configuration/ConfigContainer.cs +++ b/Common/Configuration/ConfigContainer.cs @@ -78,7 +78,6 @@ public class ServerOption public int StartTrailblazerLevel { get; set; } = 1; public bool AutoUpgradeWorldLevel { get; set; } = true; public bool EnableMission { get; set; } = true; // experimental - public bool AutoLightSection { get; set; } = true; public string DefaultGender { get; set; } = "Woman"; public string Language { get; set; } = "EN"; public string FallbackLanguage { get; set; } = "EN"; diff --git a/Common/Data/Config/Scene/FloorInfo.cs b/Common/Data/Config/Scene/FloorInfo.cs index e5252ac8..4aa06f2a 100644 --- a/Common/Data/Config/Scene/FloorInfo.cs +++ b/Common/Data/Config/Scene/FloorInfo.cs @@ -10,9 +10,13 @@ public class FloorInfo public int FloorID { get; set; } public int StartGroupIndex { get; set; } public int StartAnchorID { get; set; } + public string NavmapConfigPath { get; set; } = ""; public List GroupInstanceList { get; set; } = []; public List DimensionList { get; set; } = []; + [JsonConverter(typeof(ConcurrentBagConverter))] + public ConcurrentBag MapSections = []; + [JsonConverter(typeof(ConcurrentDictionaryConverter))] public ConcurrentDictionary CachedTeleports = []; diff --git a/Common/Data/Config/Scene/MapInfo.cs b/Common/Data/Config/Scene/MapInfo.cs new file mode 100644 index 00000000..5af2d4ff --- /dev/null +++ b/Common/Data/Config/Scene/MapInfo.cs @@ -0,0 +1,28 @@ +namespace EggLink.DanhengServer.Data.Config.Scene; + +public class MapInfo +{ + public List AreaList { get; set; } = []; + public List MapLayerList { get; set; } = []; +} + +public class AreaInfo +{ + public int ID { get; set; } + public MinimapVolumeInfo MinimapVolume { get; set; } = new(); + public List RegionIDList { get; set; } = []; + public List MapLayerList { get; set; } = []; +} + +public class MinimapVolumeInfo +{ + public List Sections { get; set; } = new(); +} + +public class SectionsInfo +{ + public int ID { get; set; } + public int MapLayerID { get; set; } + public bool IsRect { get; set; } + public List Indices { get; set; } = []; +} \ No newline at end of file diff --git a/Common/Data/ResourceManager.cs b/Common/Data/ResourceManager.cs index d1c6aa44..bbba9e99 100644 --- a/Common/Data/ResourceManager.cs +++ b/Common/Data/ResourceManager.cs @@ -196,6 +196,30 @@ public class ResourceManager if (info == null) return; GameData.FloorInfoData[name] = info; + // Load navmap infos + FileInfo navmapFile = new(ConfigManager.Config.Path.ResourcePath + "/" + info.NavmapConfigPath); + if (navmapFile.Exists) + { + try + { + using var navmapReader = navmapFile.OpenRead(); + using StreamReader navmapReader2 = new(navmapReader); + var navmapText = navmapReader2.ReadToEnd(); + var navmap = JsonConvert.DeserializeObject(navmapText); + if (navmap != null) + foreach (var area in navmap.AreaList) + foreach (var section in area.MinimapVolume.Sections) + info.MapSections.Add(section.ID); + } + catch (Exception ex) + { + ResourceCache.IsComplete = false; + Logger.Error( + I18NManager.Translate("Server.ServerInfo.FailedToReadItem", navmapFile.Name, + I18NManager.Translate("Word.Error")), ex); + } + } + // Load group infos sequentially to maintain order foreach (var groupInfo in info.GroupInstanceList) { diff --git a/GameServer/Game/Scene/SceneInstance.cs b/GameServer/Game/Scene/SceneInstance.cs index ff5c9d94..5026cbda 100644 --- a/GameServer/Game/Scene/SceneInstance.cs +++ b/GameServer/Game/Scene/SceneInstance.cs @@ -129,7 +129,7 @@ public class SceneInstance Player.MissionManager!.OnLoadScene(sceneInfo); // unlock section - if (!ConfigManager.Config.ServerOption.AutoLightSection) + if (ConfigManager.Config.ServerOption.EnableMission) { Player.SceneData!.UnlockSectionIdList.TryGetValue(FloorId, out var unlockSectionList); if (unlockSectionList != null) @@ -138,7 +138,8 @@ public class SceneInstance } else { - for (uint i = 1; i <= 100; i++) sceneInfo.LightenSectionList.Add(i); + GameData.GetFloorInfo(PlaneId, FloorId, out var floorInfo); + sceneInfo.LightenSectionList.AddRange(floorInfo.MapSections.Select(x => (uint)x)); } return sceneInfo; diff --git a/GameServer/Server/Packet/Send/Scene/PacketGetSceneMapInfoScRsp.cs b/GameServer/Server/Packet/Send/Scene/PacketGetSceneMapInfoScRsp.cs index 1d41c5bc..b8ca4e5e 100644 --- a/GameServer/Server/Packet/Send/Scene/PacketGetSceneMapInfoScRsp.cs +++ b/GameServer/Server/Packet/Send/Scene/PacketGetSceneMapInfoScRsp.cs @@ -83,16 +83,13 @@ public class PacketGetSceneMapInfoScRsp : BasePacket mazeMap.MazePropList.Add(mazeProp); } - if (!ConfigManager.Config.ServerOption.AutoLightSection) + if (ConfigManager.Config.ServerOption.EnableMission) { player.SceneData!.UnlockSectionIdList.TryGetValue(mapData.FloorID, out var sections); foreach (var section in sections ?? []) mazeMap.LightenSectionList.Add((uint)section); } else - { - for (uint i = 0; i < 100; i++) - mazeMap.LightenSectionList.Add(i); - } + mazeMap.LightenSectionList.AddRange(floorInfo.MapSections.Select(x => (uint)x)); rsp.SceneMapInfo.Add(mazeMap); }