Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public bool LazyLoading {
[SettingIgnore]
public int LogHistoryCountToKeep { get; set; } = 3;

[SettingNeedsRelaunch]
[SettingInGame(false)]
[SettingIgnore] // TODO: Show as advanced setting.
public bool? FastLevelLoading { get; set; } = null;

[SettingNeedsRelaunch]
[SettingInGame(false)]
[SettingIgnore] // TODO: Show as advanced setting.
Expand Down
19 changes: 16 additions & 3 deletions Celeste.Mod.mm/Patches/AreaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma warning disable CS0649 // Field is never assigned to, and will always have its default value

using Celeste.Mod;
using Celeste.Mod.Core;
using Celeste.Mod.Meta;
using Microsoft.Xna.Framework;
using Monocle;
Expand All @@ -10,6 +11,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Celeste {
public class patch_AreaData : AreaData {
Expand Down Expand Up @@ -365,7 +367,7 @@ public static patch_AreaData Get(string sid) {
}
}

for (int i = 0; i < Areas.Count; i++) {
static void ProcessMapData(int i) {
patch_AreaData area = Areas[i];
area.ID = i;

Expand All @@ -378,7 +380,9 @@ public static patch_AreaData Get(string sid) {
}
Array.Resize(ref area.Mode, modei);

Logger.Verbose("AreaData", string.Format("{0}: {1} - {2} sides", i, area.SID, area.Mode.Length));
// Do not clutter the log if Fast Level Loading is disabled
LogLevel level = (CoreModule.Settings.FastLevelLoading ?? true) ? LogLevel.Info : LogLevel.Verbose;
Logger.Log(level, "AreaData", $"{i}: {area.SID} - {area.Mode.Length} sides");

// Update old MapData areas and load any new areas.

Expand All @@ -389,7 +393,7 @@ public static patch_AreaData Get(string sid) {
area.Mode[0].MapData = new patch_MapData(area.ToKey());

if (area.IsInterludeUnsafe())
continue;
return;

// A and (some) B sides have PoemIDs. Can be overridden via empty PoemID.
if (area.Mode[0].PoemID == null)
Expand All @@ -411,6 +415,15 @@ public static patch_AreaData Get(string sid) {
}
}

if (CoreModule.Settings.FastLevelLoading ?? true) {
Logger.Info("AreaData", $"Loading map data in parallel");
Parallel.For(0, Areas.Count, ProcessMapData);
} else {
for (int i = 0; i < Areas.Count; i++) {
ProcessMapData(i);
}
}

// Load custom mountains
// This needs to be done after areas are loaded because it depends on the MapMeta
MTNExt.LoadMod();
Expand Down
2 changes: 1 addition & 1 deletion Celeste.Mod.mm/Patches/BinaryPacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Celeste {
static class patch_BinaryPacker {
[MonoModIgnore]
[ThreadStatic]
private static string[] stringLookup;

[MonoModIgnore] // We don't want to change anything about the method...
Expand Down
6 changes: 5 additions & 1 deletion Celeste.Mod.mm/Patches/MapData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
namespace Celeste {
public class patch_MapData : MapData {

private static readonly object locker = new object();

public bool DetectedCassette;
public int DetectedStrawberriesIncludingUntracked;
public List<EntityData> DashlessGoldenberries = new List<EntityData>();
Expand Down Expand Up @@ -177,7 +179,9 @@ private BinaryPacker.Element Process(BinaryPacker.Element root) {
if (root.Children.Find(element => element.Name == "meta") is BinaryPacker.Element meta)
ProcessMeta(meta);

new MapDataFixup(this).Process(root);
lock (locker) {
new MapDataFixup(this).Process(root);
}

return root;
}
Expand Down