Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/autostart/autostart_host.js
class AutoStartHost | class AutoStartHost | ||||
{ | { | ||||
constructor(initData) | constructor(cmdLineArgs) | ||||
{ | { | ||||
this.launched = false; | this.launched = false; | ||||
this.maxPlayers = initData.maxPlayers; | |||||
this.storeReplay = initData.storeReplay; | |||||
this.playerAssignments = {}; | this.playerAssignments = {}; | ||||
this.initAttribs = initData.attribs; | this.maxPlayers = cmdLineArgs['autostart-host-players'] ?? 2; | ||||
this.cmdLineArgs = cmdLineArgs; | |||||
try | try | ||||
{ | { | ||||
const playerName = cmdLineArgs['autostart-playername'] || "anonymous"; | |||||
const port = cmdLineArgs['autostart-port'] ?? 5073; | |||||
// Stun and password not implemented for autostart. | // Stun and password not implemented for autostart. | ||||
Engine.StartNetworkHost(initData.playerName, initData.port, false, "", initData.storeReplay); | Engine.StartNetworkHost(playerName, port, false, "", !cmdLineArgs['autostart-disable-replay']); | ||||
} | } | ||||
catch (e) | catch (e) | ||||
{ | { | ||||
const message = sprintf(translate("Cannot host game: %(message)s."), { "message": e.message }); | const message = sprintf(translate("Cannot host game: %(message)s."), { "message": e.message }); | ||||
messageBox(400, 200, message, translate("Error")); | messageBox(400, 200, message, translate("Error")); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | class AutoStartHost | ||||
* In the visual autostart path, we need to show the loading screen. | * In the visual autostart path, we need to show the loading screen. | ||||
* Overload this as appropriate. | * Overload this as appropriate. | ||||
*/ | */ | ||||
onLaunch() | onLaunch() | ||||
{ | { | ||||
this.launched = true; | this.launched = true; | ||||
this.settings = new GameSettings().init(); | this.settings = new GameSettings().init(); | ||||
this.settings.fromInitAttributes(this.initAttribs); | this.settings.fromCmdLineArgs(this.cmdLineArgs); | ||||
if ('autostart-nonvisual' in this.cmdLineArgs) | |||||
this.settings.triggerScripts.customScripts.add("scripts/NonVisualTrigger.js"); | |||||
this.settings.playerCount.setNb(Object.keys(this.playerAssignments).length); | this.settings.playerCount.setNb(Object.keys(this.playerAssignments).length); | ||||
this.settings.launchGame(this.playerAssignments, this.storeReplay); | this.settings.launchGame(this.playerAssignments, this.storeReplay); | ||||
Engine.SwitchGuiPage("page_loading.xml", { | Engine.SwitchGuiPage("page_loading.xml", { | ||||
"attribs": this.initAttribs, | "attribs": this.initAttribs, | ||||
"playerAssignments": this.playerAssignments | "playerAssignments": this.playerAssignments | ||||
}); | }); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator