From 1625d55de5135d7890a6ca3b6da1e19bedd5fcac Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 17 Oct 2019 12:18:11 +0800 Subject: [PATCH] Reset AI peer for empty server --- src/network/protocols/server_lobby.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 989553127..cb350054c 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -1744,6 +1744,16 @@ void ServerLobby::update(int ticks) RaceEventManager::getInstance()->getProtocol()->requestTerminate(); GameProtocol::lock()->requestTerminate(); } + else if (auto ai = m_ai_peer.lock()) + { + // Reset AI peer for empty server, which will delete world + NetworkString* back_to_lobby = getNetworkString(2); + back_to_lobby->setSynchronous(true); + back_to_lobby->addUInt8(LE_BACK_LOBBY).addUInt8(BLR_NONE); + ai->sendPacket(back_to_lobby, /*reliable*/true); + delete back_to_lobby; + } + resetVotingTime(); m_game_setup->stopGrandPrix(); m_rs_state.store(RS_WAITING);