public async Task<ArgumentHandleResult> ProgressRaceOnline(NameValueCollection p) {
/* required arguments */
var ip = p.Get(@"ip");
var port = FlexibleParser.TryParseInt(p.Get(@"port"));
var httpPort = FlexibleParser.TryParseInt(p.Get(@"httpPort"));
var carId = p.Get(@"car");
/* optional arguments */
var allowWithoutSteamId = p.GetFlag("allowWithoutSteamId");
var carSkinId = p.Get(@"skin");
var trackId = p.Get(@"track");
var name = p.Get(@"name");
var nationality = p.Get(@"nationality");
var password = p.Get(@"password");
if (string.IsNullOrWhiteSpace(ip)) {
throw new InformativeException("IP is missing");
}
if (!port.HasValue) {
throw new InformativeException("Port is missing or is in invalid format");
}
if (!httpPort.HasValue) {
throw new InformativeException("HTTP port is missing or is in invalid format");
}
if (string.IsNullOrWhiteSpace(carId)) {
throw new InformativeException("Car ID is missing");
}
var car = CarsManager.Instance.GetById(carId);
if (car == null) {
throw new InformativeException("Car is missing");
}
if (!string.IsNullOrWhiteSpace(carSkinId) && car.GetSkinById(carSkinId) == null) {
throw new InformativeException("Car skin is missing");
}
var track = string.IsNullOrWhiteSpace(trackId) ? null : TracksManager.Instance.GetLayoutByKunosId(trackId);
if (!string.IsNullOrWhiteSpace(trackId) && track == null) {
throw new InformativeException("Track is missing");
}
if (!SteamIdHelper.Instance.IsReady && !allowWithoutSteamId) {
throw new InformativeException(ToolsStrings.Common_SteamIdIsMissing);
}
await GameWrapper.StartAsync(new Game.StartProperties {
BasicProperties = new Game.BasicProperties {
CarId = carId,
TrackId = track?.MainTrackObject.Id ?? @"imola",
TrackConfigurationId = track?.LayoutId,
CarSkinId = carSkinId,
DriverName = name,
DriverNationality = nationality
},
ModeProperties = new Game.OnlineProperties {
Guid = SteamIdHelper.Instance.Value,
ServerIp = ip,
ServerPort = port.Value,
ServerHttpPort = httpPort.Value,
Password = password,
RequestedCar = carId
}
});
return ArgumentHandleResult.Successful;
}