Renamed ServerLobbyRoomProtocol to just ServerLobby, ClientLobbyRoomProtocol
to ClientLobby, and LobbyRoomProtocol to Lobbyprotocol.
This commit is contained in:
parent
09eae7e25f
commit
026e1623ec
@ -1,5 +1,5 @@
|
||||
# Modify this file to change the last-modified date when you add/remove a file.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
# This will then trigger a new cmake run automatically.
|
||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/race_event_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/protocols/stop_server.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@ -78,23 +78,23 @@ void* NetworkConsole::mainLoop(void* data)
|
||||
}
|
||||
else if (str == "start" && NetworkConfig::get()->isServer())
|
||||
{
|
||||
ServerLobbyRoomProtocol* protocol =
|
||||
dynamic_cast<ServerLobbyRoomProtocol*>(LobbyRoomProtocol::get());
|
||||
ServerLobby* protocol =
|
||||
dynamic_cast<ServerLobby*>(LobbyRoomProtocol::get());
|
||||
protocol->signalRaceStartToClients();
|
||||
}
|
||||
else if (str == "selection" && NetworkConfig::get()->isServer())
|
||||
{
|
||||
ServerLobbyRoomProtocol* protocol =
|
||||
dynamic_cast<ServerLobbyRoomProtocol*>(LobbyRoomProtocol::get());
|
||||
ServerLobby* protocol =
|
||||
dynamic_cast<ServerLobby*>(LobbyRoomProtocol::get());
|
||||
protocol->startSelection();
|
||||
}
|
||||
else if (str == "select" && NetworkConfig::get()->isClient())
|
||||
{
|
||||
std::string str2;
|
||||
getline(std::cin, str2);
|
||||
ServerLobbyRoomProtocol* protocol =
|
||||
dynamic_cast<ServerLobbyRoomProtocol*>(LobbyRoomProtocol::get());
|
||||
ClientLobbyRoomProtocol* clrp = dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ServerLobby* protocol =
|
||||
dynamic_cast<ServerLobby*>(LobbyRoomProtocol::get());
|
||||
ClientLobby* clrp = dynamic_cast<ClientLobby*>(protocol);
|
||||
std::vector<NetworkPlayerProfile*> players =
|
||||
STKHost::get()->getMyPlayerProfiles();
|
||||
// For now send a vote for each local player
|
||||
@ -110,8 +110,8 @@ void* NetworkConsole::mainLoop(void* data)
|
||||
std::string str2;
|
||||
getline(std::cin, str2);
|
||||
LobbyRoomProtocol* protocol = LobbyRoomProtocol::get();
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ClientLobby* clrp =
|
||||
dynamic_cast<ClientLobby*>(protocol);
|
||||
std::vector<NetworkPlayerProfile*> players =
|
||||
STKHost::get()->getMyPlayerProfiles();
|
||||
if (str2 == "track")
|
||||
|
@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "modes/world_with_rank.hpp"
|
||||
@ -35,31 +35,31 @@
|
||||
#include "utils/log.hpp"
|
||||
|
||||
// ============================================================================
|
||||
ClientLobbyRoomProtocol::ClientLobbyRoomProtocol()
|
||||
ClientLobby::ClientLobby()
|
||||
: LobbyRoomProtocol(NULL)
|
||||
{
|
||||
|
||||
m_server_address.clear();
|
||||
m_server = NULL;
|
||||
setHandleDisconnections(true);
|
||||
} // ClientLobbyRoomProtocol
|
||||
} // ClientLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
ClientLobbyRoomProtocol::~ClientLobbyRoomProtocol()
|
||||
ClientLobby::~ClientLobby()
|
||||
{
|
||||
} // ClientLobbyRoomProtocol
|
||||
} // ClientLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the address of the server.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::setAddress(const TransportAddress &address)
|
||||
void ClientLobby::setAddress(const TransportAddress &address)
|
||||
{
|
||||
m_server_address.copy(address);
|
||||
} // setAddress
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ClientLobbyRoomProtocol::setup()
|
||||
void ClientLobby::setup()
|
||||
{
|
||||
m_game_setup = STKHost::get()->setupNewGame(); // create a new game setup
|
||||
m_state = NONE;
|
||||
@ -70,7 +70,7 @@ void ClientLobbyRoomProtocol::setup()
|
||||
* \param player_id The global player id of the voting player.
|
||||
* \param kart_name Name of the selected kart.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::requestKartSelection(uint8_t player_id,
|
||||
void ClientLobby::requestKartSelection(uint8_t player_id,
|
||||
const std::string &kart_name)
|
||||
{
|
||||
NetworkString *request = getNetworkString(3+kart_name.size());
|
||||
@ -87,7 +87,7 @@ void ClientLobbyRoomProtocol::requestKartSelection(uint8_t player_id,
|
||||
* \param player_id The global player id of the voting player.
|
||||
* \param major Major mode voted for.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteMajor(uint8_t player_id, uint32_t major)
|
||||
void ClientLobby::voteMajor(uint8_t player_id, uint32_t major)
|
||||
{
|
||||
NetworkString *request = getNetworkString(6);
|
||||
request->addUInt8(LE_VOTE_MAJOR).addUInt8(player_id)
|
||||
@ -103,7 +103,7 @@ void ClientLobbyRoomProtocol::voteMajor(uint8_t player_id, uint32_t major)
|
||||
* \param player_id The global player id of the voting player.
|
||||
* \param count NUmber of tracks to play.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteRaceCount(uint8_t player_id, uint8_t count)
|
||||
void ClientLobby::voteRaceCount(uint8_t player_id, uint8_t count)
|
||||
{
|
||||
NetworkString *request = getNetworkString(3);
|
||||
request->addUInt8(LE_VOTE_RACE_COUNT).addUInt8(player_id).addUInt8(count);
|
||||
@ -118,7 +118,7 @@ void ClientLobbyRoomProtocol::voteRaceCount(uint8_t player_id, uint8_t count)
|
||||
* \param player_id The global player id of the voting player.
|
||||
* \param minor Voted minor mode.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteMinor(uint8_t player_id, uint32_t minor)
|
||||
void ClientLobby::voteMinor(uint8_t player_id, uint32_t minor)
|
||||
{
|
||||
NetworkString *request = getNetworkString(6);
|
||||
request->addUInt8(LE_VOTE_MINOR).addUInt8(player_id).addUInt32(minor);
|
||||
@ -134,7 +134,7 @@ void ClientLobbyRoomProtocol::voteMinor(uint8_t player_id, uint32_t minor)
|
||||
* \param track Name of the track.
|
||||
* \param At which place in the list of tracks this track should be played.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteTrack(uint8_t player_id,
|
||||
void ClientLobby::voteTrack(uint8_t player_id,
|
||||
const std::string &track,
|
||||
uint8_t track_nb)
|
||||
{
|
||||
@ -154,7 +154,7 @@ void ClientLobbyRoomProtocol::voteTrack(uint8_t player_id,
|
||||
* \param track_nb Index for the track to be voted on in the list of all
|
||||
* tracks.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteReversed(uint8_t player_id, bool reversed,
|
||||
void ClientLobby::voteReversed(uint8_t player_id, bool reversed,
|
||||
uint8_t track_nb)
|
||||
{
|
||||
NetworkString *request = getNetworkString(9);
|
||||
@ -171,7 +171,7 @@ void ClientLobbyRoomProtocol::voteReversed(uint8_t player_id, bool reversed,
|
||||
* \param laps Number of laps for the specified track.
|
||||
* \param track_nb Index of the track in the list of all tracks.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::voteLaps(uint8_t player_id, uint8_t laps,
|
||||
void ClientLobby::voteLaps(uint8_t player_id, uint8_t laps,
|
||||
uint8_t track_nb)
|
||||
{
|
||||
NetworkString *request = getNetworkString(10);
|
||||
@ -184,7 +184,7 @@ void ClientLobbyRoomProtocol::voteLaps(uint8_t player_id, uint8_t laps,
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a client selects to exit a server.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::leave()
|
||||
void ClientLobby::leave()
|
||||
{
|
||||
m_server->disconnect();
|
||||
STKHost::get()->removePeer(m_server);
|
||||
@ -197,7 +197,7 @@ void ClientLobbyRoomProtocol::leave()
|
||||
* screen. It notifies the server that this client has exited the screen and
|
||||
* is back at the lobby.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::doneWithResults()
|
||||
void ClientLobby::doneWithResults()
|
||||
{
|
||||
NetworkString *done = getNetworkString(1);
|
||||
done->addUInt8(LE_RACE_FINISHED_ACK);
|
||||
@ -207,14 +207,14 @@ void ClientLobbyRoomProtocol::doneWithResults()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
bool ClientLobby::notifyEvent(Event* event)
|
||||
{
|
||||
assert(m_game_setup); // assert that the setup exists
|
||||
|
||||
NetworkString &data = event->data();
|
||||
assert(data.size()); // assert that data isn't empty
|
||||
uint8_t message_type = data.getUInt8();
|
||||
Log::info("ClientLobbyRoomProtocol", "Synchronous message of type %d",
|
||||
Log::info("ClientLobby", "Synchronous message of type %d",
|
||||
message_type);
|
||||
switch(message_type)
|
||||
{
|
||||
@ -231,7 +231,7 @@ bool ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
bool ClientLobby::notifyEventAsynchronous(Event* event)
|
||||
{
|
||||
assert(m_game_setup); // assert that the setup exists
|
||||
if (event->getType() == EVENT_TYPE_MESSAGE)
|
||||
@ -240,7 +240,7 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
assert(data.size()); // assert that data isn't empty
|
||||
uint8_t message_type = data.getUInt8();
|
||||
|
||||
Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d",
|
||||
Log::info("ClientLobby", "Asynchronous message of type %d",
|
||||
message_type);
|
||||
switch(message_type)
|
||||
{
|
||||
@ -277,7 +277,7 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ClientLobbyRoomProtocol::update(float dt)
|
||||
void ClientLobby::update(float dt)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
@ -346,7 +346,7 @@ void ClientLobbyRoomProtocol::update(float dt)
|
||||
* Data | player_id | hostid | player name |
|
||||
* -------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
void ClientLobby::newPlayer(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 2)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -358,13 +358,13 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
// FIXME need adjusting when splitscreen is used/
|
||||
if(STKHost::get()->getGameSetup()->isLocalMaster(player_id))
|
||||
{
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"The server notified me that I'm a new player in the "
|
||||
"room (not normal).");
|
||||
}
|
||||
else if (m_game_setup->getProfile(player_id) == NULL)
|
||||
{
|
||||
Log::verbose("ClientLobbyRoomProtocol", "New player connected.");
|
||||
Log::verbose("ClientLobby", "New player connected.");
|
||||
NetworkPlayerProfile* profile =
|
||||
new NetworkPlayerProfile(name, player_id, host_id);
|
||||
m_game_setup->addPlayer(profile);
|
||||
@ -372,7 +372,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"One of the player notified in the list is myself.");
|
||||
}
|
||||
} // newPlayer
|
||||
@ -389,7 +389,7 @@ void ClientLobbyRoomProtocol::newPlayer(Event* event)
|
||||
* Data | player id *|
|
||||
* --------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
|
||||
void ClientLobby::disconnectedPlayer(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 1)) return;
|
||||
|
||||
@ -400,13 +400,13 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
|
||||
m_game_setup->getProfile(data.getUInt8());
|
||||
if (m_game_setup->removePlayer(profile))
|
||||
{
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"Player %d removed successfully.",
|
||||
profile->getGlobalPlayerId());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"The disconnected peer wasn't known.");
|
||||
}
|
||||
} // while
|
||||
@ -426,7 +426,7 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
|
||||
* Data | player_id| hostid | authorised |playernames* |
|
||||
* ---------------------------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
void ClientLobby::connectionAccepted(Event* event)
|
||||
{
|
||||
// At least 3 bytes should remain now
|
||||
if(!checkDataSize(event, 3)) return;
|
||||
@ -436,7 +436,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
|
||||
// Accepted
|
||||
// ========
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"The server accepted the connection.");
|
||||
|
||||
// self profile
|
||||
@ -498,7 +498,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
* Data | refusal code |
|
||||
* ----------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::connectionRefused(Event* event)
|
||||
void ClientLobby::connectionRefused(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 1)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -506,17 +506,17 @@ void ClientLobbyRoomProtocol::connectionRefused(Event* event)
|
||||
switch (data.getUInt8()) // the second byte
|
||||
{
|
||||
case 0:
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"Connection refused : too many players.");
|
||||
break;
|
||||
case 1:
|
||||
Log::info("ClientLobbyRoomProtocol", "Connection refused : banned.");
|
||||
Log::info("ClientLobby", "Connection refused : banned.");
|
||||
break;
|
||||
case 2:
|
||||
Log::info("ClientLobbyRoomProtocol", "Client busy.");
|
||||
Log::info("ClientLobby", "Client busy.");
|
||||
break;
|
||||
default:
|
||||
Log::info("ClientLobbyRoomProtocol", "Connection refused.");
|
||||
Log::info("ClientLobby", "Connection refused.");
|
||||
break;
|
||||
}
|
||||
} // connectionRefused
|
||||
@ -533,7 +533,7 @@ void ClientLobbyRoomProtocol::connectionRefused(Event* event)
|
||||
* Data | refusal code |
|
||||
* ----------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event)
|
||||
void ClientLobby::kartSelectionRefused(Event* event)
|
||||
{
|
||||
if(!checkDataSize(event, 1)) return;
|
||||
|
||||
@ -542,15 +542,15 @@ void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event)
|
||||
switch (data.getUInt8()) // the error code
|
||||
{
|
||||
case 0:
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"Kart selection refused : already taken.");
|
||||
break;
|
||||
case 1:
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"Kart selection refused : not available.");
|
||||
break;
|
||||
default:
|
||||
Log::info("ClientLobbyRoomProtocol", "Kart selection refused.");
|
||||
Log::info("ClientLobby", "Kart selection refused.");
|
||||
break;
|
||||
}
|
||||
} // kartSelectionRefused
|
||||
@ -567,7 +567,7 @@ void ClientLobbyRoomProtocol::kartSelectionRefused(Event* event)
|
||||
* Data | player id | N (kart name size) | kart name |
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::kartSelectionUpdate(Event* event)
|
||||
void ClientLobby::kartSelectionUpdate(Event* event)
|
||||
{
|
||||
if(!checkDataSize(event, 3)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -576,7 +576,7 @@ void ClientLobbyRoomProtocol::kartSelectionUpdate(Event* event)
|
||||
data.decodeString(&kart_name);
|
||||
if (!m_game_setup->isKartAvailable(kart_name))
|
||||
{
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"The updated kart is taken already.");
|
||||
}
|
||||
m_game_setup->setPlayerKart(player_id, kart_name);
|
||||
@ -591,11 +591,11 @@ race needs to be started.
|
||||
* \param event : Event providing the information (no additional information
|
||||
* in this case).
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::startGame(Event* event)
|
||||
void ClientLobby::startGame(Event* event)
|
||||
{
|
||||
m_state = PLAYING;
|
||||
World::getWorld()->setReadyToRace();
|
||||
Log::info("ClientLobbyRoomProtocol", "Starting new game");
|
||||
Log::info("ClientLobby", "Starting new game");
|
||||
} // startGame
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -604,10 +604,10 @@ void ClientLobbyRoomProtocol::startGame(Event* event)
|
||||
* \param event : Event providing the information (no additional information
|
||||
* in this case).
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::startSelection(Event* event)
|
||||
void ClientLobby::startSelection(Event* event)
|
||||
{
|
||||
m_state = KART_SELECTION;
|
||||
Log::info("ClientLobbyRoomProtocol", "Kart selection starts now");
|
||||
Log::info("ClientLobby", "Kart selection starts now");
|
||||
} // startSelection
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -622,12 +622,12 @@ void ClientLobbyRoomProtocol::startSelection(Event* event)
|
||||
* Data | Kart 1 ID | kart id 2 | ... |
|
||||
* -------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
void ClientLobby::raceFinished(Event* event)
|
||||
{
|
||||
if(!checkDataSize(event, 1)) return;
|
||||
|
||||
NetworkString &data = event->data();
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"Server notified that the race is finished.");
|
||||
|
||||
// stop race protocols
|
||||
@ -636,7 +636,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
if (protocol)
|
||||
ProtocolManager::getInstance()->requestTerminate(protocol);
|
||||
else
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"No controller events protocol registered.");
|
||||
|
||||
protocol = ProtocolManager::getInstance()
|
||||
@ -644,7 +644,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
if (protocol)
|
||||
ProtocolManager::getInstance()->requestTerminate(protocol);
|
||||
else
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"No kart update protocol registered.");
|
||||
|
||||
protocol = ProtocolManager::getInstance()
|
||||
@ -652,7 +652,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
if (protocol)
|
||||
ProtocolManager::getInstance()->requestTerminate(protocol);
|
||||
else
|
||||
Log::error("ClientLobbyRoomProtocol",
|
||||
Log::error("ClientLobby",
|
||||
"No game events protocol registered.");
|
||||
|
||||
// finish the race
|
||||
@ -664,7 +664,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
{
|
||||
uint8_t kart_id = data.getUInt8();
|
||||
ranked_world->setKartPosition(kart_id,position);
|
||||
Log::info("ClientLobbyRoomProtocol", "Kart %d has finished #%d",
|
||||
Log::info("ClientLobby", "Kart %d has finished #%d",
|
||||
kart_id, position);
|
||||
position++;
|
||||
}
|
||||
@ -677,7 +677,7 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
/** Called when the server informs the clients to exit the race result screen.
|
||||
* It exits the race, and goes back to the lobby.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::exitResultScreen(Event *event)
|
||||
void ClientLobby::exitResultScreen(Event *event)
|
||||
{
|
||||
RaceResultGUI::getInstance()->backToLobby();
|
||||
} // exitResultScreen
|
||||
@ -693,7 +693,7 @@ void ClientLobbyRoomProtocol::exitResultScreen(Event *event)
|
||||
* Data |player id | major mode vote |
|
||||
* ------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerMajorVote(Event* event)
|
||||
void ClientLobby::playerMajorVote(Event* event)
|
||||
{
|
||||
const NetworkString &data = event->data();
|
||||
if (!checkDataSize(event, 2))
|
||||
@ -714,7 +714,7 @@ void ClientLobbyRoomProtocol::playerMajorVote(Event* event)
|
||||
* Data | player id | races count |
|
||||
* ---------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerRaceCountVote(Event* event)
|
||||
void ClientLobby::playerRaceCountVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 2)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -734,7 +734,7 @@ void ClientLobbyRoomProtocol::playerRaceCountVote(Event* event)
|
||||
* Data | player id | minor mode vote |
|
||||
* -------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerMinorVote(Event* event)
|
||||
void ClientLobby::playerMinorVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 2)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -755,7 +755,7 @@ void ClientLobbyRoomProtocol::playerMinorVote(Event* event)
|
||||
* Data | player id | track number (gp) | N | track name |
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerTrackVote(Event* event)
|
||||
void ClientLobby::playerTrackVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 3)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -779,7 +779,7 @@ void ClientLobbyRoomProtocol::playerTrackVote(Event* event)
|
||||
* Data | player id |reversed | track number (gp) |
|
||||
* -------------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerReversedVote(Event* event)
|
||||
void ClientLobby::playerReversedVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 3)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -802,7 +802,7 @@ void ClientLobbyRoomProtocol::playerReversedVote(Event* event)
|
||||
* Data | player id | laps | track number (gp) |
|
||||
* ----------------------------------------
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::playerLapsVote(Event* event)
|
||||
void ClientLobby::playerLapsVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 3)) return;
|
||||
const NetworkString &data = event->data();
|
||||
@ -817,7 +817,7 @@ void ClientLobbyRoomProtocol::playerLapsVote(Event* event)
|
||||
* that the players on this host are ready to start the race. It is called by
|
||||
* the RaceManager after the world is loaded.
|
||||
*/
|
||||
void ClientLobbyRoomProtocol::finishedLoadingWorld()
|
||||
void ClientLobby::finishedLoadingWorld()
|
||||
{
|
||||
assert(STKHost::get()->getPeerCount() == 1);
|
||||
std::vector<NetworkPlayerProfile*> players =
|
||||
@ -828,7 +828,7 @@ void ClientLobbyRoomProtocol::finishedLoadingWorld()
|
||||
for (unsigned int i = 0; i < players.size(); i++)
|
||||
{
|
||||
ns->addUInt8(players[i]->getGlobalPlayerId());
|
||||
Log::info("ClientLobbyRoomProtocol",
|
||||
Log::info("ClientLobby",
|
||||
"Player %d ready, notifying server.",
|
||||
players[i]->getGlobalPlayerId());
|
||||
} // for i < players.size()
|
@ -1,13 +1,13 @@
|
||||
#ifndef CLIENT_LOBBY_ROOM_PROTOCOL_HPP
|
||||
#define CLIENT_LOBBY_ROOM_PROTOCOL_HPP
|
||||
#ifndef CLIENT_LOBBY_HPP
|
||||
#define CLIENT_LOBBY_HPP
|
||||
|
||||
#include "network/protocols/lobby_room_protocol.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
#include "network/transport_address.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
|
||||
class STKPeer;
|
||||
|
||||
class ClientLobbyRoomProtocol : public LobbyRoomProtocol
|
||||
class ClientLobby : public LobbyRoomProtocol
|
||||
{
|
||||
private:
|
||||
void newPlayer(Event* event);
|
||||
@ -50,8 +50,8 @@ private:
|
||||
STATE m_state;
|
||||
|
||||
public:
|
||||
ClientLobbyRoomProtocol();
|
||||
virtual ~ClientLobbyRoomProtocol();
|
||||
ClientLobby();
|
||||
virtual ~ClientLobby();
|
||||
|
||||
virtual void requestKartSelection(uint8_t player_id,
|
||||
const std::string &kart_name) OVERRIDE;
|
@ -26,7 +26,7 @@
|
||||
#include "network/protocols/hide_public_address.hpp"
|
||||
#include "network/protocols/request_connection.hpp"
|
||||
#include "network/protocols/ping_protocol.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
@ -238,8 +238,8 @@ void ConnectToServer::asynchronousUpdate()
|
||||
// lobby room protocol if we're connected only
|
||||
if(STKHost::get()->getPeers()[0]->isConnected())
|
||||
{
|
||||
ClientLobbyRoomProtocol *p =
|
||||
LobbyRoomProtocol::create<ClientLobbyRoomProtocol>();
|
||||
ClientLobby *p =
|
||||
LobbyRoomProtocol::create<ClientLobby>();
|
||||
p->setAddress(m_server_address);
|
||||
p->requestStart();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#include "network/protocols/lobby_room_protocol.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
@ -52,6 +52,7 @@ public:
|
||||
LE_RACE_FINISHED, // race has finished, display result
|
||||
LE_RACE_FINISHED_ACK, // client went back to lobby
|
||||
LE_EXIT_RESULT, // Force clients to exit race result screen
|
||||
LE_VOTE, // Any vote (race mode, track, ...)
|
||||
LE_VOTE_MAJOR, // vote of major race mode
|
||||
LE_VOTE_MINOR, // vote for minor race mode
|
||||
LE_VOTE_RACE_COUNT, // vote for number of tracks
|
@ -16,7 +16,7 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
|
||||
#include "config/player_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
@ -75,21 +75,21 @@
|
||||
* It starts with detecting the public ip address and port of this
|
||||
* host (GetPublicAddress).
|
||||
*/
|
||||
ServerLobbyRoomProtocol::ServerLobbyRoomProtocol() : LobbyRoomProtocol(NULL)
|
||||
ServerLobby::ServerLobby() : LobbyRoomProtocol(NULL)
|
||||
{
|
||||
setHandleDisconnections(true);
|
||||
} // ServerLobbyRoomProtocol
|
||||
} // ServerLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Destructor.
|
||||
*/
|
||||
ServerLobbyRoomProtocol::~ServerLobbyRoomProtocol()
|
||||
ServerLobby::~ServerLobby()
|
||||
{
|
||||
} // ~ServerLobbyRoomProtocol
|
||||
} // ~ServerLobby
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ServerLobbyRoomProtocol::setup()
|
||||
void ServerLobby::setup()
|
||||
{
|
||||
m_game_setup = STKHost::get()->setupNewGame();
|
||||
m_game_setup->setNumLocalPlayers(0); // no local players on a server
|
||||
@ -101,7 +101,7 @@ void ServerLobbyRoomProtocol::setup()
|
||||
: INIT_WAN;
|
||||
m_selection_enabled = false;
|
||||
m_current_protocol = NULL;
|
||||
Log::info("ServerLobbyRoomProtocol", "Starting the protocol.");
|
||||
Log::info("ServerLobby", "Starting the protocol.");
|
||||
|
||||
// Initialise the data structures to detect if all clients and
|
||||
// the server are ready:
|
||||
@ -120,7 +120,7 @@ void ServerLobbyRoomProtocol::setup()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
bool ServerLobby::notifyEventAsynchronous(Event* event)
|
||||
{
|
||||
assert(m_game_setup); // assert that the setup exists
|
||||
if (event->getType() == EVENT_TYPE_MESSAGE)
|
||||
@ -129,7 +129,7 @@ bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
assert(data.size()); // message not empty
|
||||
uint8_t message_type;
|
||||
message_type = data.getUInt8();
|
||||
Log::info("ServerLobbyRoomProtocol", "Message received with type %d.",
|
||||
Log::info("ServerLobby", "Message received with type %d.",
|
||||
message_type);
|
||||
switch(message_type)
|
||||
{
|
||||
@ -159,7 +159,7 @@ bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
* is known, register the server and its address with the stk server so that
|
||||
* client can find it.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::update(float dt)
|
||||
void ServerLobby::update(float dt)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
@ -173,7 +173,7 @@ void ServerLobbyRoomProtocol::update(float dt)
|
||||
break;
|
||||
case GETTING_PUBLIC_ADDRESS:
|
||||
{
|
||||
Log::debug("ServerLobbyRoomProtocol", "Public address known.");
|
||||
Log::debug("ServerLobby", "Public address known.");
|
||||
// Free GetPublicAddress protocol
|
||||
delete m_current_protocol;
|
||||
|
||||
@ -181,7 +181,7 @@ void ServerLobbyRoomProtocol::update(float dt)
|
||||
// this thread, but there is no need for the protocol manager
|
||||
// to react to any requests before the server is registered.
|
||||
registerServer();
|
||||
Log::info("ServerLobbyRoomProtocol", "Server registered.");
|
||||
Log::info("ServerLobby", "Server registered.");
|
||||
m_state = ACCEPTING_CLIENTS;
|
||||
}
|
||||
break;
|
||||
@ -262,7 +262,7 @@ void ServerLobbyRoomProtocol::update(float dt)
|
||||
/** Callback when the GetPublicAddress terminates. It will unpause this
|
||||
* protocol, which triggers the next state of the finite state machine.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::callback(Protocol *protocol)
|
||||
void ServerLobby::callback(Protocol *protocol)
|
||||
{
|
||||
requestUnpause();
|
||||
} // callback
|
||||
@ -274,7 +274,7 @@ void ServerLobbyRoomProtocol::callback(Protocol *protocol)
|
||||
* ProtocolManager thread). The information about this client is added
|
||||
* to the table 'server'.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::registerServer()
|
||||
void ServerLobby::registerServer()
|
||||
{
|
||||
Online::XMLRequest *request = new Online::XMLRequest();
|
||||
const TransportAddress& addr = NetworkConfig::get()->getMyAddress();
|
||||
@ -312,7 +312,7 @@ void ServerLobbyRoomProtocol::registerServer()
|
||||
* are therefore ready to start the race. It signals to all clients
|
||||
* to start the race and then switches state to DELAY_SERVER.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::signalRaceStartToClients()
|
||||
void ServerLobby::signalRaceStartToClients()
|
||||
{
|
||||
const std::vector<STKPeer*> &peers = STKHost::get()->getPeers();
|
||||
NetworkString *ns = getNetworkString(1);
|
||||
@ -326,7 +326,7 @@ void ServerLobbyRoomProtocol::signalRaceStartToClients()
|
||||
/** Instructs all clients to start the kart selection. If event is not NULL,
|
||||
* the command comes from a client (which needs to be authorised).
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::startSelection(const Event *event)
|
||||
void ServerLobby::startSelection(const Event *event)
|
||||
{
|
||||
if(event && !event->getPeer()->isAuthorised())
|
||||
{
|
||||
@ -352,7 +352,7 @@ void ServerLobbyRoomProtocol::startSelection(const Event *event)
|
||||
/** Query the STK server for connection requests. For each connection request
|
||||
* start a ConnectToPeer protocol.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
void ServerLobby::checkIncomingConnectionRequests()
|
||||
{
|
||||
// First poll every 5 seconds. Return if no polling needs to be done.
|
||||
const float POLL_INTERVAL = 5.0f;
|
||||
@ -378,7 +378,7 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
|
||||
if (!result->get("success", &success) || success != "yes")
|
||||
{
|
||||
Log::error("ServerLobbyRoomProtocol", "Cannot retrieve the list.");
|
||||
Log::error("ServerLobby", "Cannot retrieve the list.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
for (unsigned int i = 0; i < users_xml->getNumNodes(); i++)
|
||||
{
|
||||
users_xml->getNode(i)->get("id", &id);
|
||||
Log::debug("ServerLobbyRoomProtocol",
|
||||
Log::debug("ServerLobby",
|
||||
"User with id %d wants to connect.", id);
|
||||
Protocol *p = new ConnectToPeer(id);
|
||||
p->requestStart();
|
||||
@ -401,7 +401,7 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
* to state RESULT_DISPLAY, during which the race result gui is shown and all
|
||||
* clients can click on 'continue'.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::checkRaceFinished()
|
||||
void ServerLobby::checkRaceFinished()
|
||||
{
|
||||
assert(RaceEventManager::getInstance()->isRunning());
|
||||
assert(World::getWorld());
|
||||
@ -439,12 +439,12 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
for (unsigned int i = 0; i < karts_results.size(); i++)
|
||||
{
|
||||
total->addUInt8(karts_results[i]); // kart pos = i+1
|
||||
Log::info("ServerLobbyRoomProtocol", "Kart %d finished #%d",
|
||||
Log::info("ServerLobby", "Kart %d finished #%d",
|
||||
karts_results[i], i + 1);
|
||||
}
|
||||
sendMessageToPeersChangingToken(total, /*reliable*/ true);
|
||||
delete total;
|
||||
Log::info("ServerLobbyRoomProtocol", "End of game message sent");
|
||||
Log::info("ServerLobby", "End of game message sent");
|
||||
|
||||
} // checkRaceFinished
|
||||
|
||||
@ -452,7 +452,7 @@ void ServerLobbyRoomProtocol::checkIncomingConnectionRequests()
|
||||
/** Called when a client disconnects.
|
||||
* \param event The disconnect event.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::clientDisconnected(Event* event)
|
||||
void ServerLobby::clientDisconnected(Event* event)
|
||||
{
|
||||
std::vector<NetworkPlayerProfile*> players_on_host =
|
||||
event->getPeer()->getAllPlayerProfiles();
|
||||
@ -463,7 +463,7 @@ void ServerLobbyRoomProtocol::clientDisconnected(Event* event)
|
||||
for(unsigned int i=0; i<players_on_host.size(); i++)
|
||||
{
|
||||
msg->addUInt8(players_on_host[i]->getGlobalPlayerId());
|
||||
Log::info("ServerLobbyRoomProtocol", "Player disconnected : id %d",
|
||||
Log::info("ServerLobby", "Player disconnected : id %d",
|
||||
players_on_host[i]->getGlobalPlayerId());
|
||||
m_game_setup->removePlayer(players_on_host[i]);
|
||||
}
|
||||
@ -487,7 +487,7 @@ void ServerLobbyRoomProtocol::clientDisconnected(Event* event)
|
||||
* Data | 4 |n| player name |
|
||||
* ---------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
void ServerLobby::connectionRequested(Event* event)
|
||||
{
|
||||
STKPeer* peer = event->getPeer();
|
||||
const NetworkString &data = event->data();
|
||||
@ -504,7 +504,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
// send only to the peer that made the request
|
||||
peer->sendPacket(message);
|
||||
delete message;
|
||||
Log::verbose("ServerLobbyRoomProtocol", "Player refused");
|
||||
Log::verbose("ServerLobby", "Player refused");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -574,7 +574,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
m_game_setup->addPlayer(profile);
|
||||
NetworkingLobby::getInstance()->addPlayer(profile);
|
||||
|
||||
Log::verbose("ServerLobbyRoomProtocol", "New player.");
|
||||
Log::verbose("ServerLobby", "New player.");
|
||||
|
||||
} // connectionRequested
|
||||
|
||||
@ -590,7 +590,7 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
|
||||
* Data |player id | N (kart name size) | kart name |
|
||||
* ----------------------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::kartSelectionRequested(Event* event)
|
||||
void ServerLobby::kartSelectionRequested(Event* event)
|
||||
{
|
||||
if(m_state!=SELECTING)
|
||||
{
|
||||
@ -662,7 +662,7 @@ void ServerLobbyRoomProtocol::kartSelectionRequested(Event* event)
|
||||
* Data | player-id | major mode vote |
|
||||
* -------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerMajorVote(Event* event)
|
||||
void ServerLobby::playerMajorVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 5)) return;
|
||||
|
||||
@ -688,7 +688,7 @@ void ServerLobbyRoomProtocol::playerMajorVote(Event* event)
|
||||
* Data | player-id | races count |
|
||||
* ---------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerRaceCountVote(Event* event)
|
||||
void ServerLobby::playerRaceCountVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 1)) return;
|
||||
NetworkString &data = event->data();
|
||||
@ -715,7 +715,7 @@ void ServerLobbyRoomProtocol::playerRaceCountVote(Event* event)
|
||||
* Data | player-id | minor mode vote |
|
||||
* -------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerMinorVote(Event* event)
|
||||
void ServerLobby::playerMinorVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 1)) return;
|
||||
NetworkString &data = event->data();
|
||||
@ -742,7 +742,7 @@ void ServerLobbyRoomProtocol::playerMinorVote(Event* event)
|
||||
* Data | player id | track number (gp) | N | track name |
|
||||
* --------------------------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerTrackVote(Event* event)
|
||||
void ServerLobby::playerTrackVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 3)) return;
|
||||
NetworkString &data = event->data();
|
||||
@ -786,7 +786,7 @@ void ServerLobbyRoomProtocol::playerTrackVote(Event* event)
|
||||
* Data | player id | reversed | track number (gp) |
|
||||
* --------------------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerReversedVote(Event* event)
|
||||
void ServerLobby::playerReversedVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 3)) return;
|
||||
|
||||
@ -815,7 +815,7 @@ void ServerLobbyRoomProtocol::playerReversedVote(Event* event)
|
||||
* Data | player id | laps | track number (gp) |
|
||||
* ----------------------------------------
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerLapsVote(Event* event)
|
||||
void ServerLobby::playerLapsVote(Event* event)
|
||||
{
|
||||
if (!checkDataSize(event, 2)) return;
|
||||
NetworkString &data = event->data();
|
||||
@ -835,7 +835,7 @@ void ServerLobbyRoomProtocol::playerLapsVote(Event* event)
|
||||
/** Called from the RaceManager of the server when the world is loaded. Marks
|
||||
* the server to be ready to start the race.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::finishedLoadingWorld()
|
||||
void ServerLobby::finishedLoadingWorld()
|
||||
{
|
||||
m_server_has_loaded_world = true;
|
||||
} // finishedLoadingWorld;
|
||||
@ -844,7 +844,7 @@ void ServerLobbyRoomProtocol::finishedLoadingWorld()
|
||||
/** Called when a client notifies the server that it has loaded the world.
|
||||
* When all clients and the server are ready, the race can be started.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::finishedLoadingWorldClient(Event *event)
|
||||
void ServerLobby::finishedLoadingWorldClient(Event *event)
|
||||
{
|
||||
if (!checkDataSize(event, 1)) return;
|
||||
|
||||
@ -887,7 +887,7 @@ void ServerLobbyRoomProtocol::finishedLoadingWorldClient(Event *event)
|
||||
/** Called when a client clicks on 'ok' on the race result screen.
|
||||
* If all players have clicked on 'ok', go back to the lobby.
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::playerFinishedResult(Event *event)
|
||||
void ServerLobby::playerFinishedResult(Event *event)
|
||||
{
|
||||
m_player_ready_counter++;
|
||||
if(m_player_ready_counter == STKHost::get()->getPeerCount())
|
@ -1,11 +1,11 @@
|
||||
#ifndef SERVER_LOBBY_ROOM_PROTOCOL_HPP
|
||||
#define SERVER_LOBBY_ROOM_PROTOCOL_HPP
|
||||
|
||||
#include "network/protocols/lobby_room_protocol.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/synchronised.hpp"
|
||||
|
||||
class ServerLobbyRoomProtocol : public LobbyRoomProtocol
|
||||
class ServerLobby : public LobbyRoomProtocol
|
||||
, public CallbackObject
|
||||
{
|
||||
private:
|
||||
@ -70,8 +70,8 @@ private:
|
||||
void registerServer();
|
||||
void finishedLoadingWorldClient(Event *event);
|
||||
public:
|
||||
ServerLobbyRoomProtocol();
|
||||
virtual ~ServerLobbyRoomProtocol();
|
||||
ServerLobby();
|
||||
virtual ~ServerLobby();
|
||||
|
||||
virtual bool notifyEventAsynchronous(Event* event) OVERRIDE;
|
||||
virtual void setup() OVERRIDE;
|
||||
@ -86,6 +86,6 @@ public:
|
||||
|
||||
virtual void callback(Protocol *protocol) OVERRIDE;
|
||||
|
||||
}; // class ServerLobbyRoomProtocol
|
||||
}; // class ServerLobby
|
||||
|
||||
#endif // SERVER_LOBBY_ROOM_PROTOCOL_HPP
|
@ -126,7 +126,7 @@ bool SynchronizationProtocol::notifyEventAsynchronous(Event* event)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Waits for the countdown to be started. On the server the start of the
|
||||
* countdown is triggered by ServerLobbyRoomProtocol::finishedLoadingWorld(),
|
||||
* countdown is triggered by ServerLobby::finishedLoadingWorld(),
|
||||
* which is called once all clients have confirmed that they are ready to
|
||||
* start. The server will send a ping request to each client once a second,
|
||||
* and include the information if the countdown has started (and its current
|
||||
@ -188,7 +188,7 @@ void SynchronizationProtocol::asynchronousUpdate()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Starts the countdown on this machine. On the server side this function
|
||||
* is called from ServerLobbyRoomProtocol::finishedLoadingWorld() (when all
|
||||
* is called from ServerLobby::finishedLoadingWorld() (when all
|
||||
* players have confirmed that they are ready to play). On the client side
|
||||
* this function is called from this protocol when a message from the server
|
||||
* is received indicating that the countdown has to be started.
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "network/network_string.hpp"
|
||||
#include "network/protocols/connect_to_peer.hpp"
|
||||
#include "network/protocols/connect_to_server.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
@ -101,7 +101,7 @@ void STKHost::create()
|
||||
*
|
||||
* Server:
|
||||
*
|
||||
* 1. ServerLobbyRoomProtocol:
|
||||
* 1. ServerLobby:
|
||||
* Spawns the following sub-protocols:
|
||||
* 1. GetPublicAddress: Use STUN to discover the public ip address
|
||||
* and port number of this host.
|
||||
@ -141,7 +141,7 @@ void STKHost::create()
|
||||
*
|
||||
* Server:
|
||||
*
|
||||
* The ServerLobbyRoomProtocol (SLR) will then detect the above client
|
||||
* The ServerLobby (SLR) will then detect the above client
|
||||
* requests, and start a ConnectToPeer protocol for each incoming client.
|
||||
* The ConnectToPeer protocol uses:
|
||||
* 1. GetPeerAddress to get the ip address and port of the client.
|
||||
@ -264,7 +264,7 @@ STKHost::STKHost(uint32_t server_id, uint32_t host_id)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** The constructor for a server.
|
||||
* The server control flow starts with the ServerLobbyRoomProtocol.
|
||||
* The server control flow starts with the ServerLobby.
|
||||
*/
|
||||
STKHost::STKHost(const irr::core::stringw &server_name)
|
||||
{
|
||||
@ -289,7 +289,7 @@ STKHost::STKHost(const irr::core::stringw &server_name)
|
||||
}
|
||||
|
||||
startListening();
|
||||
Protocol *p = LobbyRoomProtocol::create<ServerLobbyRoomProtocol>();
|
||||
Protocol *p = LobbyRoomProtocol::create<ServerLobby>();
|
||||
ProtocolManager::getInstance()->requestStart(p);
|
||||
|
||||
} // STKHost(server_name)
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "states_screens/server_selection.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -135,7 +135,7 @@ void NetworkKartSelectionScreen::playerConfirm(const int playerID)
|
||||
{
|
||||
|
||||
LobbyRoomProtocol* protocol = LobbyRoomProtocol::get();
|
||||
ClientLobbyRoomProtocol *clrp = dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ClientLobby *clrp = dynamic_cast<ClientLobby*>(protocol);
|
||||
assert(clrp);
|
||||
// FIXME SPLITSCREEN: we need to supply the global player id of the
|
||||
// player selecting the kart here. For now ... just vote the same kart
|
||||
@ -180,8 +180,8 @@ void NetworkKartSelectionScreen::playerSelected(uint8_t player_id,
|
||||
{
|
||||
Protocol* protocol = ProtocolManager::getInstance()
|
||||
->getProtocol(PROTOCOL_LOBBY_ROOM);
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ClientLobby* clrp =
|
||||
dynamic_cast<ClientLobby*>(protocol);
|
||||
assert(clrp);
|
||||
// FIXME: for now we submit a vote from the authorised user
|
||||
// for the various modes based on the settings in the race manager.
|
||||
@ -213,8 +213,8 @@ bool NetworkKartSelectionScreen::onEscapePressed()
|
||||
ServerSelection::getInstance()->refresh();
|
||||
Protocol *lobby = LobbyRoomProtocol::get();
|
||||
// notify the server that we left
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(lobby);
|
||||
ClientLobby* clrp =
|
||||
dynamic_cast<ClientLobby*>(lobby);
|
||||
if (clrp)
|
||||
clrp->leave();
|
||||
return true; // remove the screen
|
||||
|
@ -34,8 +34,8 @@
|
||||
#include "input/input_manager.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/server_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/servers_manager.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
@ -163,8 +163,8 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
|
||||
if(NetworkConfig::get()->isServer())
|
||||
{
|
||||
Protocol *p = LobbyRoomProtocol::get();
|
||||
ServerLobbyRoomProtocol* slrp =
|
||||
dynamic_cast<ServerLobbyRoomProtocol*>(p);
|
||||
ServerLobby* slrp =
|
||||
dynamic_cast<ServerLobby*>(p);
|
||||
slrp->startSelection();
|
||||
}
|
||||
else // client
|
||||
@ -198,8 +198,8 @@ void NetworkingLobby::tearDown()
|
||||
bool NetworkingLobby::onEscapePressed()
|
||||
{
|
||||
// notify the server that we left
|
||||
ClientLobbyRoomProtocol* protocol =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(LobbyRoomProtocol::get());
|
||||
ClientLobby* protocol =
|
||||
dynamic_cast<ClientLobby*>(LobbyRoomProtocol::get());
|
||||
if (protocol)
|
||||
protocol->leave();
|
||||
STKHost::get()->shutdown();
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "modes/soccer_world.hpp"
|
||||
#include "modes/world_with_rank.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "race/highscores.hpp"
|
||||
#include "scriptengine/property_animator.hpp"
|
||||
#include "states_screens/feature_unlocked.hpp"
|
||||
@ -342,8 +342,8 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
{
|
||||
// Signal to the server that this client is back in the lobby now.
|
||||
Protocol* protocol = LobbyRoomProtocol::get();
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ClientLobby* clrp =
|
||||
dynamic_cast<ClientLobby*>(protocol);
|
||||
if(clrp)
|
||||
clrp->doneWithResults();
|
||||
backToLobby();
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "network/protocols/client_lobby_room_protocol.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/track_info_screen.hpp"
|
||||
@ -90,8 +90,8 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
if(STKHost::existHost())
|
||||
{
|
||||
Protocol* protocol = LobbyRoomProtocol::get();
|
||||
ClientLobbyRoomProtocol* clrp =
|
||||
dynamic_cast<ClientLobbyRoomProtocol*>(protocol);
|
||||
ClientLobby* clrp =
|
||||
dynamic_cast<ClientLobby*>(protocol);
|
||||
assert(clrp); // server never shows the track screen.
|
||||
// FIXME SPLITSCREEN: we need to supply the global player id of the
|
||||
// player selecting the track here. For now ... just vote the same
|
||||
|
Loading…
Reference in New Issue
Block a user