Allow using --auto-connect with network ai tester

This commit is contained in:
Benau
2018-09-16 19:19:42 +08:00
parent b3bffacb40
commit 8cb5e43bad
2 changed files with 9 additions and 9 deletions

View File

@@ -43,6 +43,7 @@ NetworkAIController::NetworkAIController(AbstractKart *kart,
// ----------------------------------------------------------------------------
NetworkAIController::~NetworkAIController()
{
delete m_ai_controller;
delete m_ai_controls;
} // ~NetworkAIController

View File

@@ -376,6 +376,14 @@ void ClientLobby::update(int ticks)
break;
case REQUESTING_CONNECTION:
case CONNECTED:
if (STKHost::get()->isAuthorisedToControl() &&
NetworkConfig::get()->isAutoConnect())
{
// Send a message to the server to start
NetworkString start(PROTOCOL_LOBBY_ROOM);
start.addUInt8(LobbyProtocol::LE_REQUEST_BEGIN);
STKHost::get()->sendToServer(&start, true);
}
case SELECTING_ASSETS:
case RACING:
case EXITING:
@@ -709,15 +717,6 @@ void ClientLobby::handleBadConnection()
void ClientLobby::becomingServerOwner()
{
STKHost::get()->setAuthorisedToControl(true);
if (m_state.load() == CONNECTED && NetworkConfig::get()->isAutoConnect())
{
// Send a message to the server to start
NetworkString start(PROTOCOL_LOBBY_ROOM);
start.setSynchronous(true);
start.addUInt8(LobbyProtocol::LE_REQUEST_BEGIN);
STKHost::get()->sendToServer(&start, true);
}
if (STKHost::get()->isClientServer())
return;