Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/GameSetup.cpp
Show First 20 Lines • Show All 1,543 Lines • ▼ Show 20 Lines | bool Autostart(const CmdLineArgs& args) | ||||
if (args.Has("autostart-host")) | if (args.Has("autostart-host")) | ||||
{ | { | ||||
InitPsAutostart(true, attrs); | InitPsAutostart(true, attrs); | ||||
size_t maxPlayers = 2; | size_t maxPlayers = 2; | ||||
if (args.Has("autostart-host-players")) | if (args.Has("autostart-host-players")) | ||||
maxPlayers = args.Get("autostart-host-players").ToUInt(); | maxPlayers = args.Get("autostart-host-players").ToUInt(); | ||||
g_NetServer = new CNetServer(false, maxPlayers); | std::string secret; | ||||
if (args.Has("autostart-host-secret")) | |||||
secret = args.Get("autostart-host-secret"); | |||||
g_NetServer = new CNetServer(secret, false, maxPlayers); | |||||
g_NetServer->UpdateGameAttributes(&attrs, scriptInterface); | g_NetServer->UpdateGameAttributes(&attrs, scriptInterface); | ||||
bool ok = g_NetServer->SetupConnection(PS_DEFAULT_PORT); | bool ok = g_NetServer->SetupConnection(PS_DEFAULT_PORT); | ||||
ENSURE(ok); | ENSURE(ok); | ||||
g_NetClient = new CNetClient(g_Game, true); | g_NetClient = new CNetClient(g_Game); | ||||
g_NetClient->SetUserName(userName); | g_NetClient->SetUserName(userName); | ||||
if (args.Has("autostart-host-secret")) | |||||
g_NetClient->SetControllerSecret(secret); | |||||
g_NetClient->SetupConnection("127.0.0.1", PS_DEFAULT_PORT, nullptr); | g_NetClient->SetupConnection("127.0.0.1", PS_DEFAULT_PORT, nullptr); | ||||
} | } | ||||
else if (args.Has("autostart-client")) | else if (args.Has("autostart-client")) | ||||
{ | { | ||||
InitPsAutostart(true, attrs); | InitPsAutostart(true, attrs); | ||||
g_NetClient = new CNetClient(g_Game, false); | g_NetClient = new CNetClient(g_Game); | ||||
g_NetClient->SetUserName(userName); | g_NetClient->SetUserName(userName); | ||||
if (args.Has("autostart-client-secret")) | |||||
g_NetClient->SetControllerSecret(args.Get("autostart-client-secret")); | |||||
CStr ip = args.Get("autostart-client"); | CStr ip = args.Get("autostart-client"); | ||||
if (ip.empty()) | if (ip.empty()) | ||||
ip = "127.0.0.1"; | ip = "127.0.0.1"; | ||||
bool ok = g_NetClient->SetupConnection(ip, PS_DEFAULT_PORT, nullptr); | bool ok = g_NetClient->SetupConnection(ip, PS_DEFAULT_PORT, nullptr); | ||||
ENSURE(ok); | ENSURE(ok); | ||||
} | } | ||||
else | else | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator