]> git.deb.at Git - rhonda/impostor.git/commitdiff
Allow adding custom tasks on standard maps (#481)
authorminiduikboot <mini@duikbo.at>
Wed, 25 May 2022 17:53:32 +0000 (19:53 +0200)
committerGitHub <noreply@github.com>
Wed, 25 May 2022 17:53:32 +0000 (19:53 +0200)
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

index 45107297a382460a65982e5d0b5b6132a1749be2..835ddc5d9dfca5112a2f19104b1bc42bb148fb3d 100644 (file)
@@ -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));
             }
         }
     }