-
Notifications
You must be signed in to change notification settings - Fork 8
SS13 "Classic Servers" Support #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
DEATHB4DEFEAT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all notes for when I take over this PR, and this is all without the context of existing systems, I need to compare them later.
| private List<ClassicServerStatusData> ParseByondResponse(string response) | ||
| { | ||
| var list = new List<ClassicServerStatusData>(); | ||
| using var reader = new StringReader(response); | ||
|
|
||
| string? line; | ||
| string? currentName = null; | ||
| string? currentUrl = null; | ||
| string? currentStatus = null; | ||
| int currentPlayers = 0; | ||
|
|
||
| // Simple state machine to parse the text format | ||
| // The format uses 'world/ID' blocks for servers. | ||
|
|
||
| bool inServerBlock = false; | ||
|
|
||
| while ((line = reader.ReadLine()) != null) | ||
| { | ||
| var trimmed = line.Trim(); | ||
| if (string.IsNullOrWhiteSpace(trimmed)) continue; | ||
|
|
||
| if (trimmed.StartsWith("world/")) | ||
| { | ||
| // If we were parsing a server, save it | ||
| if (inServerBlock && currentUrl != null) | ||
| { | ||
| // Name might be missing, try to extract from status or use URL | ||
| var name = currentName ?? ExtractNameFromStatus(currentStatus) ?? "Unknown Server"; | ||
| var roundTime = ExtractRoundTimeFromStatus(currentStatus); | ||
| list.Add(new ClassicServerStatusData(name, currentUrl, currentPlayers, CleanStatus(currentStatus, name) ?? "", roundTime ?? "In-Lobby")); | ||
| } | ||
|
|
||
| // Reset for new server | ||
| inServerBlock = true; | ||
| currentName = null; | ||
| currentUrl = null; | ||
| currentStatus = null; | ||
| currentPlayers = 0; | ||
| } | ||
| else if (inServerBlock) | ||
| { | ||
| if (trimmed.StartsWith("name =")) | ||
| { | ||
| currentName = ParseStringValue(trimmed); | ||
| } | ||
| else if (trimmed.StartsWith("url =")) | ||
| { | ||
| currentUrl = ParseStringValue(trimmed); | ||
| } | ||
| else if (trimmed.StartsWith("status =")) | ||
| { | ||
| currentStatus = ParseStringValue(trimmed); | ||
| } | ||
| else if (trimmed.StartsWith("players = list(")) | ||
| { | ||
| // "players = list("Bob","Alice")" | ||
| // Just count the commas + 1, correcting for empty list "list()" | ||
| var content = trimmed.Substring("players = list(".Length); | ||
| if (content.EndsWith(")")) | ||
| { | ||
| content = content.Substring(0, content.Length - 1); | ||
| if (string.IsNullOrWhiteSpace(content)) | ||
| { | ||
| currentPlayers = 0; | ||
| } | ||
| else | ||
| { | ||
| // A simple Count(',') + 1 is risky if names contain commas, but usually they are quoted. | ||
| // However, parsing full CSV is safer but 'Splitting by ",' might be enough? | ||
| // Let's iterate and count quoted segments. | ||
| // Or simpler: Splitting by ',' is mostly fine for SS13 ckeys. | ||
| currentPlayers = content.Split(',').Length; | ||
| } | ||
| } | ||
| } | ||
| else if (trimmed.StartsWith("players =")) | ||
| { | ||
| // Fallback for simple number if ever used | ||
| var parts = trimmed.Split('='); | ||
| if (parts.Length > 1 && int.TryParse(parts[1].Trim(), out var p)) | ||
| { | ||
| currentPlayers = p; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Add the last one if exists | ||
| if (inServerBlock && currentUrl != null) | ||
| { | ||
| var name = currentName ?? ExtractNameFromStatus(currentStatus) ?? "Unknown Server"; | ||
| var roundTime = ExtractRoundTimeFromStatus(currentStatus); | ||
| list.Add(new ClassicServerStatusData(name, currentUrl, currentPlayers, CleanStatus(currentStatus, name) ?? "", roundTime ?? "In-Lobby")); | ||
| } | ||
|
|
||
| return list; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could all be made into a regex
SS14.Launcher/ViewModels/MainWindowTabs/ClassicServerEntryViewModel.cs
Outdated
Show resolved
Hide resolved
SS14.Launcher/ViewModels/MainWindowTabs/ClassicServerEntryViewModel.cs
Outdated
Show resolved
Hide resolved
DEATHB4DEFEAT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works, I'm not fixing the mess of AI it is, it's fine..


This PR adds a new tab for "Classic Servers", which provides the list of all Space Station 13 servers for the user to search through. These servers can be connected to via simple button, though the user is required to have the Byond client installed. If they don't have it, they'll be prompted to install it from byond's website.
Closes #68
AuroraThroughSteam.mp4