Skip to content

Conversation

@VMSolidus
Copy link
Member

@VMSolidus VMSolidus commented Jan 16, 2026

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

@VMSolidus
Copy link
Member Author

I had it do some final cleanup for the UI to make sure it looks the same as the regular Servers tab.
image

@VMSolidus
Copy link
Member Author

image

made it add alternating colors for the Classic Servers tab.

Copy link
Member

@DEATHB4DEFEAT DEATHB4DEFEAT left a 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.

Comment on lines 51 to 147
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;
}
Copy link
Member

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

@DEATHB4DEFEAT DEATHB4DEFEAT self-assigned this Jan 20, 2026
@DEATHB4DEFEAT DEATHB4DEFEAT added Priority: 4-Low Should be resolved at some point Size: 2-Large For large issues/PRs Status: Needs Cleanup Someone has to clean this before merging Type: Feature Creation of or significant changes to a feature labels Jan 20, 2026
Copy link
Member

@DEATHB4DEFEAT DEATHB4DEFEAT left a 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..

@DEATHB4DEFEAT DEATHB4DEFEAT merged commit 90e92d1 into Simple-Station:master Jan 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 4-Low Should be resolved at some point Size: 2-Large For large issues/PRs Status: Needs Cleanup Someone has to clean this before merging Type: Feature Creation of or significant changes to a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BYOND Integration

2 participants