From 224fdd1d5b29a12b669b7619ca947c28c0288b2c Mon Sep 17 00:00:00 2001 From: miniduikboot Date: Wed, 25 May 2022 19:53:32 +0200 Subject: [PATCH] Allow adding custom tasks on standard maps (#481) This is needed for mods that add tasks to standard maps, but also mods that add custom maps: because their custom netobjects don't get registered Impostor thinks people are still on the old map when people switch to the custom map after playing a game. --- src/Impostor.Server/Net/Inner/Objects/InnerGameData.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerGameData.cs b/src/Impostor.Server/Net/Inner/Objects/InnerGameData.cs index 4510729..835ddc5 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerGameData.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerGameData.cs @@ -140,12 +140,9 @@ namespace Impostor.Server.Net.Inner.Objects var taskId = 0u; foreach (var taskTypeId in taskTypeIds.Span) { - player.Tasks.Add(new TaskInfo( - player, - _eventManager, - taskId++, - Game.GameNet!.ShipStatus?.Data.Tasks[taskTypeId] - )); + var mapTasks = Game.GameNet!.ShipStatus?.Data.Tasks; + var taskType = mapTasks?.ContainsKey(taskTypeId) ?? false ? mapTasks[taskTypeId] : null; + player.Tasks.Add(new TaskInfo(player, _eventManager, taskId++, taskType)); } } } -- 2.39.5