fix issue with partial matches for map load command

This commit is contained in:
RaidMax 2020-11-03 20:04:11 -06:00
parent 84189cf136
commit e76976799b
2 changed files with 20 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -606,6 +606,25 @@ namespace ApplicationTests
A.CallTo(() => rconParser.ExecuteCommandAsync(A<IRConConnection>.Ignored, A<string>.Ignored))
.MustHaveHappened();
}
[Test]
public async Task Test_LoadMap_FindsMapName_FromPartialAlias()
{
var cmd = serviceProvider.GetRequiredService<LoadMapCommand>();
var server = serviceProvider.GetRequiredService<IW4MServer>();
var rconParser = serviceProvider.GetRequiredService<IRConParser>();
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<IRConConnection>.Ignored, A<string>.That.Contains(server.Maps[0].Name)))
.MustHaveHappened();
}
#endregion
}
}