From faeef00bb63623089d706c0c5b411b344d92bd9e Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 3 Feb 2022 22:57:49 +0100 Subject: Added hostname to the server configuration This is in order to avoid default lookup for local address, which usually caused the game to bind to a LAN address hence effectively disallowing any other traffic in. For now there is no option in GUI to configure the hostname. Menus definitions are in the game files, so I should avoid any changes that can cause the binary to be incompatible with currently available resource packs. --- Stars45/NetServerConfig.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Stars45/NetServerConfig.cpp') diff --git a/Stars45/NetServerConfig.cpp b/Stars45/NetServerConfig.cpp index 90b7e0d..cab2f79 100644 --- a/Stars45/NetServerConfig.cpp +++ b/Stars45/NetServerConfig.cpp @@ -63,6 +63,7 @@ NetServerConfig::NetServerConfig() { instance = this; + hostname = "0.0.0.0"; name = "Starshatter "; admin_name = "system"; admin_pass = "manager"; @@ -161,7 +162,11 @@ NetServerConfig::Load() if (term) { TermDef* def = term->isDef(); if (def) { - if (def->name()->value() == "name") { + if (def->name()->value() == "hostname") { + GetDefText(instance->hostname, def, filename); + } + + else if (def->name()->value() == "name") { GetDefText(instance->name, def, filename); } @@ -271,6 +276,7 @@ NetServerConfig::Save() fopen_s(&f, "server.cfg", "w"); if (f) { fprintf(f, "SERVER_CONFIG\n\n"); + fprintf(f, "hostname: \"%s\"\n", instance->hostname.data()); fprintf(f, "name: \"%s\"\n", instance->name.data()); fprintf(f, "admin_name: \"%s\"\n", instance->admin_name.data()); fprintf(f, "admin_pass: \"%s\"\n", instance->admin_pass.data()); -- cgit v1.1