Enable the player proxy by default and give lobbies an empty save

The player proxy now listens on 34197 by default. New hosts default to
the port range 34200-34299 so they don't hand that port to instances,
and the controller logs an error and runs without the proxy if the port
is taken, as hosts with the old range only skip it when the controller
already holds it.

Lobby instances start the save lobby.zip, created on first start as a
one tile map with no autoplace and with the freeplay scenario replaced by
an empty one. This uses the new chooseSave instance hook, which lets
plugins pick or create the save to start, and setSaveScenario from
@clusterio/host, which sets the scenario the save patcher keeps loading.
Map gen settings can't use a width and height of 0 for this, as Factorio
takes 0 to mean an unlimited map.

The address players reach the proxy on moves from lobby.public_address
to controller.player_proxy_public_address. When it's set the player_auth
login page lists it once for the instances behind the proxy instead of
their own addresses, and lobbies with player_auth loaded get a button
that opens the web interface login dialog.
This commit is contained in:
Danielv123 committed 2026-10-29 20:54:11 +01:00
1 parent 3ae486143d
commit a5bd43637e
23 files changed
+391 -121

No files matched your search

+17 -9
View File
@@ -12,6 +12,7 @@ local mod_gui = require("mod-gui")
--- @class LobbyScriptData
--- @field is_lobby boolean
--- @field instance_id integer?
--- @field web_login boolean Show button for logging into the web interface with the player_auth plugin
--- @field servers LobbyServer[]
--- @field status table<string, string> Status text by player name
@@ -106,11 +107,15 @@ local function open_browser(player)
local inner = frame.add { type = "frame", name = "content", direction = "vertical",
style = "inside_shallow_frame_with_padding" }
inner.style.horizontally_stretchable = true
local buttons = frame.add { type = "flow", name = "buttons", direction = "horizontal" }
buttons.style.top_margin = 8
if data.web_login then
buttons.add { type = "button", name = "lobby_web_login", caption = "Log in to web interface",
tooltip = "Same as the /web-login command" }
end
local filler = buttons.add { type = "empty-widget" }
filler.style.horizontally_stretchable = true
if not data.is_lobby then
local buttons = frame.add { type = "flow", direction = "horizontal" }
buttons.style.top_margin = 8
local filler = buttons.add { type = "empty-widget" }
filler.style.horizontally_stretchable = true
buttons.add { type = "button", name = "lobby_close", caption = "Close" }
end
end
@@ -194,6 +199,8 @@ lobby_module.events[defines.events.on_gui_click] = function(event)
end
elseif element.name == "lobby_close" then
close_browser(player)
elseif element.name == "lobby_web_login" then
clusterio_api.send_json("player_auth", { type = "open_dialog", player = player.name })
elseif element.tags and element.tags.lobby_instance_id then
local data = get_script_data()
local instance_id = element.tags.lobby_instance_id
@@ -214,14 +221,15 @@ lobby = {}
--- @param is_lobby boolean
--- @param instance_id integer
function lobby.configure(is_lobby, instance_id)
--- @param web_login boolean?
function lobby.configure(is_lobby, instance_id, web_login)
local data = get_script_data()
data.is_lobby = is_lobby
data.instance_id = instance_id
if not is_lobby then
for _, player in pairs(game.players) do
close_browser(player)
end
data.web_login = web_login == true
-- Rebuilt so the frame matches the new configuration
for _, player in pairs(game.players) do
close_browser(player)
end
refresh_all()
end