Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for irregular shaped lb groups #4166

Merged
merged 1 commit into from
May 12, 2024
Merged
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
Allow for irregular shaped lb groups
Mag-nus committed Apr 28, 2024
commit d7a0eff16d97b8450853074f3a7e877852c228d1
19 changes: 18 additions & 1 deletion Source/ACE.Server/Entity/LandblockGroup.cs
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ private LandblockGroup DoTrySplit()

for (int i = remainingLandblocks.Count - 1; i >= 0; i--)
{
if (landblockGroupSplitHelper.BoundaryDistance(remainingLandblocks[i]) < LandblockGroupMinSpacing)
if (landblockGroupSplitHelper.ClosestLandblock(remainingLandblocks[i]) < LandblockGroupMinSpacing)
{
landblockGroupSplitHelper.Add(remainingLandblocks[i]);
remainingLandblocks.RemoveAt(i);
@@ -269,6 +269,23 @@ public List<LandblockGroup> TryThrottledSplit()
}


public int ClosestLandblock(Landblock landblock)
{
int closest = int.MaxValue;

foreach (var value in landblocks)
{
var distance = Math.Max(
Math.Abs(value.Id.LandblockX - landblock.Id.LandblockX),
Math.Abs(value.Id.LandblockY - landblock.Id.LandblockY));

if (distance < closest)
closest = distance;
}

return closest;
}

/// <summary>
/// This will calculate the distance from the landblock group boarder.<para />
/// -X = Inside the bounds, where -1 is the outer perimeter<para />
17 changes: 17 additions & 0 deletions Source/ACE.Server/Entity/LandblockGroupSplitHelper.cs
Original file line number Diff line number Diff line change
@@ -49,6 +49,23 @@ IEnumerator IEnumerable.GetEnumerator()
}


public int ClosestLandblock(Landblock landblock)
{
int closest = int.MaxValue;

foreach (var value in landblocks)
{
var distance = Math.Max(
Math.Abs(value.Id.LandblockX - landblock.Id.LandblockX),
Math.Abs(value.Id.LandblockY - landblock.Id.LandblockY));

if (distance < closest)
closest = distance;
}

return closest;
}

/// <summary>
/// This will calculate the distance from the landblock group boarder.<para />
/// -X = Inside the bounds, where -1 is the outer perimeter<para />
2 changes: 1 addition & 1 deletion Source/ACE.Server/Managers/LandblockManager.cs
Original file line number Diff line number Diff line change
@@ -193,7 +193,7 @@ private static void ProcessPendingLandblockGroupAdditions()
if (landblockGroups[j].IsDungeon)
continue;

var distance = landblockGroups[j].BoundaryDistance(landblockGroupPendingAdditions[i]);
var distance = landblockGroups[j].ClosestLandblock(landblockGroupPendingAdditions[i]);

if (distance < LandblockGroup.LandblockGroupMinSpacing)
landblockGroupsIndexMatchesByDistance.Add(j);