Avoid importing spawn points with the same location.
This commit is contained in:
@@ -9,6 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -50,5 +52,15 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
|
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<TSource> DistinctBy<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
|
||||||
|
{
|
||||||
|
var knownKeys = new HashSet<TKey>();
|
||||||
|
foreach (TSource element in source)
|
||||||
|
{
|
||||||
|
if (knownKeys.Add(keySelector(element)))
|
||||||
|
yield return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,8 +255,8 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.Select(kv => Pair.New(Exts.ParseIntegerInvariant(kv.Key),
|
.Select(kv => Pair.New(Exts.ParseIntegerInvariant(kv.Key),
|
||||||
LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
||||||
|
|
||||||
// Add waypoint actors
|
// Add waypoint actors skipping duplicate entries
|
||||||
foreach (var kv in wps)
|
foreach (var kv in wps.DistinctBy(location => location.Second))
|
||||||
{
|
{
|
||||||
if (!singlePlayer && kv.First <= 7)
|
if (!singlePlayer && kv.First <= 7)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user