From e76976799bf86c204e70576019aa5912c62182a0 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Tue, 3 Nov 2020 20:04:11 -0600 Subject: [PATCH] fix issue with partial matches for map load command --- SharedLibraryCore/Commands/NativeCommands.cs | 2 +- Tests/ApplicationTests/CommandTests.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index e3f4e97b1..9d47a2cf0 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -875,7 +875,7 @@ namespace SharedLibraryCore.Commands E.Owner.Broadcast(_translationLookup["COMMANDS_MAP_SUCCESS"].FormatExt(foundMap.Alias)); await Task.Delay(delay); - await E.Owner.LoadMap(newMap); + await E.Owner.LoadMap(foundMap?.Name ?? newMap); } } diff --git a/Tests/ApplicationTests/CommandTests.cs b/Tests/ApplicationTests/CommandTests.cs index 2bcc6c48c..fc73a2cc2 100644 --- a/Tests/ApplicationTests/CommandTests.cs +++ b/Tests/ApplicationTests/CommandTests.cs @@ -606,6 +606,25 @@ namespace ApplicationTests A.CallTo(() => rconParser.ExecuteCommandAsync(A.Ignored, A.Ignored)) .MustHaveHappened(); } + + [Test] + public async Task Test_LoadMap_FindsMapName_FromPartialAlias() + { + var cmd = serviceProvider.GetRequiredService(); + var server = serviceProvider.GetRequiredService(); + var rconParser = serviceProvider.GetRequiredService(); + server.Maps.Add(new Map() + { + Name = "mp_test", + Alias = "test" + }); + var gameEvent = EventGenerators.GenerateEvent(GameEvent.EventType.Command, server.Maps.First().Name, server); + + await cmd.ExecuteAsync(gameEvent); + + A.CallTo(() => rconParser.ExecuteCommandAsync(A.Ignored, A.That.Contains(server.Maps[0].Name))) + .MustHaveHappened(); + } #endregion } }