Skip to content

Commit

Permalink
Attempt to allow room duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmot committed Feb 22, 2025
1 parent 45877a4 commit e1db74c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 37 deletions.
29 changes: 6 additions & 23 deletions Randomizer/RandoConfigFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static RandoConfigFile LoadSingle(string fullPath, bool lazy = true)
}
}

public static Dictionary<string, RandoConfigRoom> LazyReload(AreaKey key)
public static List<RandoConfigRoom> LazyReload(AreaKey key)
{
char side;
switch (key.Mode)
Expand All @@ -111,7 +111,7 @@ public static Dictionary<string, RandoConfigRoom> LazyReload(AreaKey key)

var path = $"Config/{key.GetSID()}.{side}.rando";
var result = LoadSingle(path, false);
return result?.GetRoomMapping(key.Mode);
return result?.GetRooms(key.Mode);
}

public static void YamlSkeleton(MapData map, bool doUnknown = true)
Expand Down Expand Up @@ -182,35 +182,18 @@ public static void YamlSkeletonCommand(string sid, bool doUnknown = true)
YamlSkeleton(area, doUnknown);
}

public Dictionary<String, RandoConfigRoom> GetRoomMapping(AreaMode mode)
public List<RandoConfigRoom> GetRooms(AreaMode mode)
{
List<RandoConfigRoom> rooms;
switch (mode)
{
case AreaMode.Normal:
default:
rooms = this.ASide;
break;
return this.ASide;
case AreaMode.BSide:
rooms = this.BSide;
break;
return this.BSide;
case AreaMode.CSide:
rooms = this.CSide;
break;
}

if (rooms == null)
{
return null;
}

var result = new Dictionary<String, RandoConfigRoom>();
foreach (RandoConfigRoom room in rooms)
{
result.Add(room.Room, room);
return this.CSide;
}

return result;
}
}

Expand Down
30 changes: 16 additions & 14 deletions Randomizer/RandoLogic/ProcessAreas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,29 +119,31 @@ bool lookup(int x, int y)
return result;
}

private static List<StaticRoom> ProcessMap(MapData map, Dictionary<String, RandoConfigRoom> config)
private static List<StaticRoom> ProcessMap(MapData map, List<RandoConfigRoom> config)
{
var result = new List<StaticRoom>();
var resultMap = new Dictionary<string, StaticRoom>();

foreach (LevelData level in map.Levels)
{
if (level.Dummy)
{
continue;
}
if (!config.TryGetValue(level.Name, out RandoConfigRoom roomConfig))
{
var levelMapping = new Dictionary<string, LevelData>();
foreach (LevelData level in map.Levels) {
if (level.Dummy) {
continue;
}
if (roomConfig == null)
{
continue;
levelMapping[level.Name] = level;
}

foreach (var roomConfig in config) {
if (!levelMapping.TryGetValue(roomConfig.Room, out var level)) {
throw new Exception($"Nonexistent room {roomConfig.Room}");
}
var holes = RandoLogic.FindHoles(level);
var room = new StaticRoom(map.Area, roomConfig, level, holes);
result.Add(room);
resultMap[level.Name] = room;
if (resultMap.ContainsKey(level.Name)) {
resultMap[level.Name] = null;
} else {
resultMap[level.Name] = room;
}
}

foreach (var room in result)
Expand All @@ -166,7 +168,7 @@ private static void ProcessArea(AreaData area)
{
continue;
}
var mapConfig = config.GetRoomMapping((AreaMode)i);
var mapConfig = config.GetRooms((AreaMode)i);
if (mapConfig == null)
{
continue;
Expand Down
3 changes: 3 additions & 0 deletions Randomizer/RandoLogic/StaticRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ public void ProcessWarps(Dictionary<string, StaticRoom> mapRooms)
{
throw new Exception($"{this.Name}: could not find warp target {conf.Warp}");
}
if (toRoom == null) {
throw new Exception($"{this.Name}: warp target {conf.Warp} is duplicated... this can be overcome, please complain");
}
if (!toRoom.Nodes.TryGetValue(conf.To ?? "main", out StaticNode toNode))
{
throw new Exception($"{this.Name}: warp target {conf.Warp} has no node {conf.To ?? "main"}");
Expand Down

0 comments on commit e1db74c

Please sign in to comment.