Resolve random players and spawn points in server replays.

This commit is contained in:
Paul Chote
2020-10-19 11:33:20 +01:00
committed by abcdefg30
parent 7b75a78e38
commit 6b6b1e56e6
8 changed files with 120 additions and 35 deletions

View File

@@ -77,7 +77,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
panel.Get("REPLAY_INFO").IsVisible = () => selectedReplay != null;
var spawnOccupants = new CachedTransform<ReplayMetadata, Dictionary<int, SpawnOccupant>>(r =>
r.GameInfo.Players.ToDictionary(c => c.SpawnPoint, c => new SpawnOccupant(c)));
{
// Avoid using .ToDictionary to improve robustness against replays defining duplicate spawn assignments
var occupants = new Dictionary<int, SpawnOccupant>();
foreach (var p in r.GameInfo.Players)
if (p.SpawnPoint != 0)
occupants[p.SpawnPoint] = new SpawnOccupant(p);
return occupants;
});
Ui.LoadWidget("MAP_PREVIEW", mapPreviewRoot, new WidgetArgs
{