Esempio n. 1
0
        private static void PrepareRaceDriverName(Game.StartProperties properties)
        {
            if (properties.HasAdditional <SrsMark>())
            {
                return;
            }

            if (properties.BasicProperties?.DriverName != null)
            {
                properties.SetAdditional(new DriverName(properties.BasicProperties.DriverName, properties.BasicProperties.DriverNationality));
                return;
            }

            if (properties.ModeProperties is Game.OnlineProperties online && SettingsHolder.Live.SrsEnabled && SettingsHolder.Live.SrsAutoMode)
            {
                var filter = Filter.Create(new StringTester(), SettingsHolder.Live.SrsAutoMask, true);
                if (filter.Test(online.ServerName ?? ""))
                {
                    Logging.Write("Looks like this is a SRS server, let’s use SRS name");
                    properties.SetAdditional(new SrsMark {
                        Name        = SrsMark.GetName(),
                        Nationality = "",
                        Team        = ""
                    });
                    return;
                }
            }

            properties.SetAdditional(new DriverName());
        }
Esempio n. 2
0
            public PlayerInformation(string name, string team, string nationality)
            {
                DisplayName = string.IsNullOrWhiteSpace(name) ? null : name;
                Team        = string.IsNullOrWhiteSpace(team) ? null : team;
                Nationality = string.IsNullOrWhiteSpace(nationality) ? null : nationality;

                if (name != null)
                {
                    SrsMark.SetName(name);
                }
            }
Esempio n. 3
0
            public async Task <bool> Go()
            {
                if (Server?.Ip == null || Player == null || CarId == null)
                {
                    return(false);
                }

                try {
                    if (Car == null)
                    {
                        throw new InformativeException(string.Format(ToolsStrings.AcError_CarIsMissing, CarId), AppStrings.Srs_CarIsMissing_Commentary);
                    }

                    var anyTrack = TracksManager.Instance.GetDefault();
                    Logging.Debug(CarSkinId);
                    await GameWrapper.StartAsync(new Game.StartProperties {
                        BasicProperties = new Game.BasicProperties {
                            CarId                = CarId,
                            CarSkinId            = CarSkinId,
                            TrackId              = anyTrack?.Id,
                            TrackConfigurationId = anyTrack?.LayoutId
                        },
                        ModeProperties = new Game.OnlineProperties {
                            ServerName     = Server.DisplayName,
                            ServerIp       = Server.Ip,
                            ServerPort     = Server.Port ?? 9615,
                            ServerHttpPort = Server.PortHttp,
                            Password       = Server.Password,
                            Penalties      = true,
                        },
                        AdditionalPropertieses =
                        {
                            new SrsMark {
                                Name        = Player.DisplayName ?? SrsMark.GetName(),
                                Team        = Player.Team ?? "",
                                Nationality = Player.Nationality ?? ""
                            }
                        }
                    });

                    return(true);
                } catch (Exception e) {
                    NonfatalError.Notify(AppStrings.Common_CannotStartRace, e);
                    return(false);
                }
            }