/// <summary> /// Извлекает поле из хоста /// </summary> private static string GetField(GameServerDetails server, string fieldName) { var value = server.GetOrDefault(fieldName); if (value == null) { return(string.Empty); } return(value); }
/// <summary> /// Выполняет разбор предварительных данных хоста. Сплитим все в словарь /// </summary> public static GameServerDetails ParseDetails(string serverVars) { var serverVarsSplit = serverVars.Split(new string[] { "\x00" }, StringSplitOptions.None); var details = new GameServerDetails(); for (int i = 0; i < serverVarsSplit.Length - 1; i += 2) { if (serverVarsSplit[i] == "hostname") { details.Set(serverVarsSplit[i], Regex.Replace(serverVarsSplit[i + 1], @"\s+", " ").Trim()); } else { details.Set(serverVarsSplit[i], serverVarsSplit[i + 1]); } } return(details); }
public void UpdateLocalLobbyDetails(GameServerDetails details) { _server.SendServerPrivateMessageToChat($"Lobby data updated. Hostname: {details.HostName}. HostAddress: {details.HostIP ?? details.LocalIP}:{details.HostPort ?? details.LocalPort}. Mod: {details.GameVariant} {details.GameVer}"); _localLobbyDetails = details; }