Skip to content

Commit

Permalink
Fix regions loading hack (#375)
Browse files Browse the repository at this point in the history
Fix regions loading hack with awaiting
  • Loading branch information
Seb-stian authored Jun 16, 2023
1 parent 56ab70a commit 6900dd1
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions Obsidian/WorldData/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -800,20 +800,14 @@ internal async Task GenerateWorldAsync(bool setWorldSpawn = false)

int regionPregenRange = (pregenerationRange >> Region.CubicRegionSizeShift) + 1;

Parallel.For(-regionPregenRange, regionPregenRange, async x =>
await Parallel.ForEachAsync(Enumerable.Range(-regionPregenRange, regionPregenRange * 2 + 1), async (x, _) =>
{
for (int z = -regionPregenRange; z < regionPregenRange; z++)
{
await LoadRegionAsync(x, z);
};
});

// I don't know why we still have null regions when we get here ¯\_(ツ)_/¯
while (Regions.Any(r => r.Value is null))
{
await Task.Delay(100);
}

for (int x = -pregenerationRange; x < pregenerationRange; x++)
{
for (int z = -pregenerationRange; z < pregenerationRange; z++)
Expand Down

0 comments on commit 6900dd1

Please sign in to comment.