#W# Change: [Go menu now uses 1 file Data/go.json. It also excepts a 'map' destination.

This commit is contained in:
WarrentyExpired 2026-09-21 09:00:23 -04:00
parent 3aeeb3705b
commit 6388a96fa9
23 changed files with 519 additions and 38 deletions

View file

@ -159,10 +159,23 @@ public class GoGump : DynamicGump
index -= _node.Categories.Length;
if (index < _node.Locations.Length)
{
from.MoveToWorld(_node.Locations[index].Location, _tree.Map);
//from.MoveToWorld(_node.Locations[index].Location, _tree.Map);
var loc = _node.Locations[index];
Map targetMap = _tree.Map;
if (!string.IsNullOrEmpty(loc.MapName))
{
foreach (Map m in Map.AllMaps)
{
if (m != null && string.Equals(m.Name, loc.MapName, StringComparison.OrdinalIgnoreCase))
{
targetMap = m;
break;
}
}
}
from.MoveToWorld(loc.Location, targetMap);
}
}
break;
}
}

View file

@ -9,4 +9,6 @@ public class GoLocation
[JsonPropertyName("name")] public string Name { get; set; }
[JsonPropertyName("location")] public Point3D Location { get; set; }
}
[JsonPropertyName("map")] public string MapName { get; set; }
}

View file

@ -11,48 +11,18 @@ public static class GoLocations
{
private static readonly ILogger logger = LogFactory.GetLogger(typeof(GoLocations));
private static LocationTree _felucca;
private static LocationTree _trammel;
private static LocationTree _ilshenar;
private static LocationTree _malas;
private static LocationTree _tokuno;
private static LocationTree _terMur;
private static LocationTree _world;
public static LocationTree GetLocations(Map map)
{
if (map == Map.Ilshenar)
{
return _ilshenar ??= LoadLocations("ilshenar", Map.Ilshenar);
}
if (map == Map.TerMur)
{
return _terMur ??= LoadLocations("termur", Map.TerMur);
}
if (map == Map.Trammel)
{
return _trammel ??= LoadLocations("trammel", Map.Trammel);
}
if (map == Map.Malas)
{
return _malas ??= LoadLocations("malas", Map.Malas);
}
if (map == Map.Tokuno)
{
return _tokuno ??= LoadLocations("tokuno", Map.Tokuno);
}
return _felucca ??= LoadLocations("felucca", Map.Felucca);
// Always return the same world tree, regardless of which map 'GetLocations' is called with
return _world ??= LoadLocations("go", Map.Felucca);
}
private static LocationTree LoadLocations(string fileName, Map map)
{
var lastBranch = new Dictionary<Mobile, GoCategory>();
var path = Path.Combine($"Data/Locations/{fileName}.json");
var path = Path.Combine($"Data/{fileName}.json");
try
{
@ -67,7 +37,7 @@ public static class GoLocations
catch (Exception e)
{
logger.Error(e, "Failed to load file {Path}.", path);
return new LocationTree(map, [], null);
return new LocationTree(map, lastBranch, new GoCategory { Name = "Error", Categories = [], Locations = [] });
}
}
}