Hide the low-level extra server info from command line

This commit is contained in:
Benau 2018-07-19 01:08:26 +08:00
parent b7569635a0
commit 6423925718
2 changed files with 30 additions and 34 deletions

View File

@ -608,6 +608,9 @@ void cmdLineHelp()
" for some time (currently his finished time * 0.25 + 15.0). \n"
" --team-choosing Allow choosing team in lobby, implicitly allowed in lan or\n"
" password protected server.\n"
" --soccer-timed Use time limit mode in network soccer game.\n"
" --soccer-goals Use goals limit mode in network soccer game.\n"
" --network-gp=n Specify number of tracks used in network grand prix.\n"
" --no-validation Allow non validated and unencrypted connection in wan.\n"
" --ranked Server will submit ranking to stk addons server.\n"
" You require permission for that.\n"
@ -1239,30 +1242,35 @@ int handleCmdLine()
NetworkConfig::get()->setAutoConnect(true);
}
if (CommandLine::has("--extra-server-info", &n))
const bool is_soccer =
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER;
if (CommandLine::has("--soccer-timed") && is_soccer)
{
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
->setSoccerGoalTarget(n != 0);
NetworkConfig::get()->setServerMode(
race_manager->getMinorMode(),
RaceManager::MAJOR_MODE_SINGLE);
}
else
{
LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
->setGrandPrixTrack(n);
NetworkConfig::get()->setServerMode(
race_manager->getMinorMode(),
RaceManager::MAJOR_MODE_GRAND_PRIX);
}
LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
->setSoccerGoalTarget(false);
NetworkConfig::get()->setServerMode(race_manager->getMinorMode(),
RaceManager::MAJOR_MODE_SINGLE);
}
else if (CommandLine::has("--soccer-goals") && is_soccer)
{
LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
->setSoccerGoalTarget(true);
NetworkConfig::get()->setServerMode(race_manager->getMinorMode(),
RaceManager::MAJOR_MODE_SINGLE);
}
else if (CommandLine::has("--network-gp", &n))
{
LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
->setGrandPrixTrack(n);
NetworkConfig::get()->setServerMode(race_manager->getMinorMode(),
RaceManager::MAJOR_MODE_GRAND_PRIX);
}
else
{
NetworkConfig::get()->setServerMode(
race_manager->getMinorMode(), RaceManager::MAJOR_MODE_SINGLE);
}
// The extra server info has to be set before server lobby started
if (server_lobby)
server_lobby->requestStart();
@ -1341,21 +1349,6 @@ int handleCmdLine()
race_manager->setDifficulty(RaceManager::Difficulty(n));
} // --mode
if(CommandLine::has("--type", &n))
{
switch (n)
{
case 0: race_manager->setMinorMode(RaceManager::MINOR_MODE_NORMAL_RACE);
break;
case 1: race_manager->setMinorMode(RaceManager::MINOR_MODE_TIME_TRIAL);
break;
case 2: race_manager->setMinorMode(RaceManager::MINOR_MODE_FOLLOW_LEADER);
break;
default:
Log::warn("main", "Invalid race type '%d' - ignored.", n);
}
} // --type
if(CommandLine::has("--track", &s) || CommandLine::has("-t", &s))
{
race_manager->setTrack(s);

View File

@ -320,11 +320,14 @@ void CreateServerScreen::createServer()
{
// Grand prix track count
if (esi > 0)
server_cfg << " --extra-server-info=" << esi;
server_cfg << " --network-gp=" << esi;
}
else
{
server_cfg << " --extra-server-info=" << esi;
if (esi == 0)
server_cfg << " --soccer-timed";
else
server_cfg << " --soccer-goals";
}
}