Added new server state for 'selecting karts'.
This commit is contained in:
parent
078de5fe93
commit
927969e720
@ -468,6 +468,9 @@ void ClientLobbyRoomProtocol::connectionRefused(Event* event)
|
|||||||
case 1:
|
case 1:
|
||||||
Log::info("ClientLobbyRoomProtocol", "Connection refused : banned.");
|
Log::info("ClientLobbyRoomProtocol", "Connection refused : banned.");
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
Log::info("ClientLobbyRoomProtocol", "Client busy.");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log::info("ClientLobbyRoomProtocol", "Connection refused.");
|
Log::info("ClientLobbyRoomProtocol", "Connection refused.");
|
||||||
break;
|
break;
|
||||||
|
@ -59,9 +59,10 @@ void ServerLobbyRoomProtocol::setup()
|
|||||||
m_setup = STKHost::get()->setupNewGame();
|
m_setup = STKHost::get()->setupNewGame();
|
||||||
m_next_id = 0;
|
m_next_id = 0;
|
||||||
|
|
||||||
// In case of LAN we don't need our public address or register with the STK
|
// In case of LAN we don't need our public address or register with the
|
||||||
// server, so we can directly go to the working state.
|
// STK server, so we can directly go to the accepting clients state.
|
||||||
m_state = NetworkConfig::get()->isLAN() ? WORKING : NONE;
|
m_state = NetworkConfig::get()->isLAN() ? ACCEPTING_CLIENTS
|
||||||
|
: NONE;
|
||||||
m_selection_enabled = false;
|
m_selection_enabled = false;
|
||||||
m_in_race = false;
|
m_in_race = false;
|
||||||
m_current_protocol = NULL;
|
m_current_protocol = NULL;
|
||||||
@ -134,10 +135,10 @@ void ServerLobbyRoomProtocol::update()
|
|||||||
// to react to any requests before the server is registered.
|
// to react to any requests before the server is registered.
|
||||||
registerServer();
|
registerServer();
|
||||||
Log::info("ServerLobbyRoomProtocol", "Server registered.");
|
Log::info("ServerLobbyRoomProtocol", "Server registered.");
|
||||||
m_state = WORKING;
|
m_state = ACCEPTING_CLIENTS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WORKING:
|
case ACCEPTING_CLIENTS:
|
||||||
{
|
{
|
||||||
// Only poll the STK server if this is a WAN server.
|
// Only poll the STK server if this is a WAN server.
|
||||||
if(NetworkConfig::get()->isWAN())
|
if(NetworkConfig::get()->isWAN())
|
||||||
@ -150,6 +151,8 @@ void ServerLobbyRoomProtocol::update()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SELECTING_KARTS:
|
||||||
|
break; // Nothing to do, this is event based
|
||||||
case DONE:
|
case DONE:
|
||||||
m_state = EXITING;
|
m_state = EXITING;
|
||||||
requestTerminate();
|
requestTerminate();
|
||||||
@ -250,6 +253,8 @@ void ServerLobbyRoomProtocol::startSelection(const Event *event)
|
|||||||
sendMessage(peers[i], ns, true); // reliably
|
sendMessage(peers[i], ns, true); // reliably
|
||||||
}
|
}
|
||||||
m_selection_enabled = true;
|
m_selection_enabled = true;
|
||||||
|
|
||||||
|
m_state = SELECTING_KARTS;
|
||||||
} // startSelection
|
} // startSelection
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -425,7 +430,8 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
|||||||
uint32_t player_id = 0;
|
uint32_t player_id = 0;
|
||||||
player_id = data.getUInt32(1);
|
player_id = data.getUInt32(1);
|
||||||
// can we add the player ?
|
// can we add the player ?
|
||||||
if (m_setup->getPlayerCount() < NetworkConfig::get()->getMaxPlayers())
|
if (m_setup->getPlayerCount() < NetworkConfig::get()->getMaxPlayers() &&
|
||||||
|
m_state==ACCEPTING_CLIENTS )
|
||||||
{
|
{
|
||||||
// add the player to the game setup
|
// add the player to the game setup
|
||||||
m_next_id = m_setup->getPlayerCount();
|
m_next_id = m_setup->getPlayerCount();
|
||||||
@ -479,7 +485,10 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
|||||||
NetworkString message(3);
|
NetworkString message(3);
|
||||||
message.ai8(LE_CONNECTION_REFUSED);
|
message.ai8(LE_CONNECTION_REFUSED);
|
||||||
message.ai8(1); // 1 bytes for the error code
|
message.ai8(1); // 1 bytes for the error code
|
||||||
message.ai8(0); // 0 = too much players
|
if(m_state!=ACCEPTING_CLIENTS)
|
||||||
|
message.ai8(2); // 2 = Busy
|
||||||
|
else
|
||||||
|
message.ai8(0); // 0 = too many players
|
||||||
// send only to the peer that made the request
|
// send only to the peer that made the request
|
||||||
sendMessage(peer, message);
|
sendMessage(peer, message);
|
||||||
Log::verbose("ServerLobbyRoomProtocol", "Player refused");
|
Log::verbose("ServerLobbyRoomProtocol", "Player refused");
|
||||||
@ -500,6 +509,13 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
|||||||
*/
|
*/
|
||||||
void ServerLobbyRoomProtocol::kartSelectionRequested(Event* event)
|
void ServerLobbyRoomProtocol::kartSelectionRequested(Event* event)
|
||||||
{
|
{
|
||||||
|
if(m_state!=SELECTING_KARTS)
|
||||||
|
{
|
||||||
|
Log::warn("Server", "Received kart selection while in state %d.",
|
||||||
|
m_state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const NetworkString &data = event->data();
|
const NetworkString &data = event->data();
|
||||||
STKPeer* peer = event->getPeer();
|
STKPeer* peer = event->getPeer();
|
||||||
if (!checkDataSizeAndToken(event, 6))
|
if (!checkDataSizeAndToken(event, 6))
|
||||||
|
@ -13,7 +13,8 @@ private:
|
|||||||
{
|
{
|
||||||
NONE,
|
NONE,
|
||||||
GETTING_PUBLIC_ADDRESS,
|
GETTING_PUBLIC_ADDRESS,
|
||||||
WORKING,
|
ACCEPTING_CLIENTS,
|
||||||
|
SELECTING_KARTS,
|
||||||
DONE,
|
DONE,
|
||||||
EXITING
|
EXITING
|
||||||
} m_state;
|
} m_state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user