Use const & for std::string, cosmetic changes.
This commit is contained in:
parent
2b687e1051
commit
b55b91edf1
@ -54,11 +54,13 @@ void ClientLobbyRoomProtocol::setup()
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ClientLobbyRoomProtocol::requestKartSelection(std::string kart_name)
|
void ClientLobbyRoomProtocol::requestKartSelection(const std::string &kart_name)
|
||||||
{
|
{
|
||||||
NetworkString request(6+1+kart_name.size());
|
NetworkString request(6+1+kart_name.size());
|
||||||
// 0x02 : kart selection request, size_token (4), token, size kart name, kart name
|
// 0x02 : kart selection request, size_token (4), token, size kart name,
|
||||||
request.ai8(0x02).ai8(4).ai32(m_server->getClientServerToken()).add(kart_name);
|
// kart name
|
||||||
|
request.ai8(0x02).ai8(4).ai32(m_server->getClientServerToken())
|
||||||
|
.add(kart_name);
|
||||||
sendMessage(request, true);
|
sendMessage(request, true);
|
||||||
} // requestKartSelection
|
} // requestKartSelection
|
||||||
|
|
||||||
@ -88,17 +90,21 @@ void ClientLobbyRoomProtocol::voteMinor(uint8_t minor)
|
|||||||
{
|
{
|
||||||
NetworkString request(8);
|
NetworkString request(8);
|
||||||
// 0xc0 : minor vote, size_token (4), token, size minor(1),minor
|
// 0xc0 : minor vote, size_token (4), token, size minor(1),minor
|
||||||
request.ai8(0xc2).ai8(4).ai32(m_server->getClientServerToken()).ai8(1).ai8(minor);
|
request.ai8(0xc2).ai8(4).ai32(m_server->getClientServerToken())
|
||||||
|
.ai8(1).ai8(minor);
|
||||||
sendMessage(request, true);
|
sendMessage(request, true);
|
||||||
} // voteMinor
|
} // voteMinor
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ClientLobbyRoomProtocol::voteTrack(std::string track, uint8_t track_nb)
|
void ClientLobbyRoomProtocol::voteTrack(const std::string &track,
|
||||||
|
uint8_t track_nb)
|
||||||
{
|
{
|
||||||
NetworkString request(8+1+track.size());
|
NetworkString request(8+1+track.size());
|
||||||
// 0xc0 : major vote, size_token (4), token, size track, track, size #track, #track
|
// 0xc0 : major vote, size_token (4), token, size track, track, size #track,
|
||||||
request.ai8(0xc3).ai8(4).ai32(m_server->getClientServerToken()).add(track).ai8(1).ai8(track_nb);
|
// #track
|
||||||
|
request.ai8(0xc3).ai8(4).ai32(m_server->getClientServerToken()).add(track)
|
||||||
|
.ai8(1).ai8(track_nb);
|
||||||
sendMessage(request, true);
|
sendMessage(request, true);
|
||||||
} // voteTrack
|
} // voteTrack
|
||||||
|
|
||||||
@ -107,8 +113,10 @@ void ClientLobbyRoomProtocol::voteTrack(std::string track, uint8_t track_nb)
|
|||||||
void ClientLobbyRoomProtocol::voteReversed(bool reversed, uint8_t track_nb)
|
void ClientLobbyRoomProtocol::voteReversed(bool reversed, uint8_t track_nb)
|
||||||
{
|
{
|
||||||
NetworkString request(9);
|
NetworkString request(9);
|
||||||
// 0xc0 : major vote, size_token (4), token, size reversed(1),reversed, size #track, #track
|
// 0xc0 : major vote, size_token (4), token, size reversed(1),reversed,
|
||||||
request.ai8(0xc4).ai8(4).ai32(m_server->getClientServerToken()).ai8(1).ai8(reversed).ai8(1).ai8(track_nb);
|
// size #track, #track
|
||||||
|
request.ai8(0xc4).ai8(4).ai32(m_server->getClientServerToken()).ai8(1)
|
||||||
|
.ai8(reversed).ai8(1).ai8(track_nb);
|
||||||
sendMessage(request, true);
|
sendMessage(request, true);
|
||||||
} // voteReversed
|
} // voteReversed
|
||||||
|
|
||||||
@ -117,8 +125,10 @@ void ClientLobbyRoomProtocol::voteReversed(bool reversed, uint8_t track_nb)
|
|||||||
void ClientLobbyRoomProtocol::voteLaps(uint8_t laps, uint8_t track_nb)
|
void ClientLobbyRoomProtocol::voteLaps(uint8_t laps, uint8_t track_nb)
|
||||||
{
|
{
|
||||||
NetworkString request(10);
|
NetworkString request(10);
|
||||||
// 0xc0 : major vote, size_token (4), token, size laps(1),laps, size #track, #track
|
// 0xc0 : major vote, size_token (4), token, size laps(1),laps,
|
||||||
request.ai8(0xc5).ai8(4).ai32(m_server->getClientServerToken()).ai8(1).ai8(laps).ai8(1).ai8(track_nb);
|
// size #track, #track
|
||||||
|
request.ai8(0xc5).ai8(4).ai32(m_server->getClientServerToken()).ai8(1)
|
||||||
|
.ai8(laps).ai8(1).ai8(track_nb);
|
||||||
sendMessage(request, true);
|
sendMessage(request, true);
|
||||||
} // voteLaps
|
} // voteLaps
|
||||||
|
|
||||||
@ -145,7 +155,8 @@ bool ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
|||||||
return false; // don't treat the event
|
return false; // don't treat the event
|
||||||
|
|
||||||
event->removeFront(1);
|
event->removeFront(1);
|
||||||
Log::info("ClientLobbyRoomProtocol", "Synchronous message of type %d", message_type);
|
Log::info("ClientLobbyRoomProtocol", "Synchronous message of type %d",
|
||||||
|
message_type);
|
||||||
if (message_type == 0x03) // kart selection update
|
if (message_type == 0x03) // kart selection update
|
||||||
kartSelectionUpdate(event);
|
kartSelectionUpdate(event);
|
||||||
else if (message_type == 0x06) // end of race
|
else if (message_type == 0x06) // end of race
|
||||||
@ -171,7 +182,8 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
|||||||
return false; // don't treat the event
|
return false; // don't treat the event
|
||||||
|
|
||||||
event->removeFront(1);
|
event->removeFront(1);
|
||||||
Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d", message_type);
|
Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d",
|
||||||
|
message_type);
|
||||||
if (message_type == 0x01) // new player connected
|
if (message_type == 0x01) // new player connected
|
||||||
newPlayer(event);
|
newPlayer(event);
|
||||||
else if (message_type == 0x02) // player disconnected
|
else if (message_type == 0x02) // player disconnected
|
||||||
@ -205,8 +217,9 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
} // connection
|
} // connection
|
||||||
else if (event->getType() == EVENT_TYPE_DISCONNECTED) // means we left essentially
|
else if (event->getType() == EVENT_TYPE_DISCONNECTED)
|
||||||
{
|
{
|
||||||
|
// means we left essentially
|
||||||
STKHost::get()->removePeer(m_server);
|
STKHost::get()->removePeer(m_server);
|
||||||
m_server = NULL;
|
m_server = NULL;
|
||||||
STKHost::get()->deleteAllPeers();
|
STKHost::get()->deleteAllPeers();
|
||||||
@ -246,7 +259,8 @@ void ClientLobbyRoomProtocol::update()
|
|||||||
break;
|
break;
|
||||||
case KART_SELECTION:
|
case KART_SELECTION:
|
||||||
{
|
{
|
||||||
NetworkKartSelectionScreen* screen = NetworkKartSelectionScreen::getInstance();
|
NetworkKartSelectionScreen* screen =
|
||||||
|
NetworkKartSelectionScreen::getInstance();
|
||||||
screen->push();
|
screen->push();
|
||||||
m_state = SELECTING_KARTS;
|
m_state = SELECTING_KARTS;
|
||||||
}
|
}
|
||||||
@ -255,7 +269,8 @@ void ClientLobbyRoomProtocol::update()
|
|||||||
break;
|
break;
|
||||||
case PLAYING:
|
case PLAYING:
|
||||||
{
|
{
|
||||||
if (NetworkWorld::getInstance<NetworkWorld>()->isRaceOver()) // race is now over, kill race protocols and return to connected state
|
// race is now over, kill race protocols and return to connected state
|
||||||
|
if (NetworkWorld::getInstance<NetworkWorld>()->isRaceOver())
|
||||||
{
|
{
|
||||||
Log::info("ClientLobbyRoomProtocol", "Game finished.");
|
Log::info("ClientLobbyRoomProtocol", "Game finished.");
|
||||||
m_state = RACE_FINISHED;
|
m_state = RACE_FINISHED;
|
||||||
|
@ -12,11 +12,11 @@ class ClientLobbyRoomProtocol : public LobbyRoomProtocol
|
|||||||
ClientLobbyRoomProtocol(const TransportAddress& server_address);
|
ClientLobbyRoomProtocol(const TransportAddress& server_address);
|
||||||
virtual ~ClientLobbyRoomProtocol();
|
virtual ~ClientLobbyRoomProtocol();
|
||||||
|
|
||||||
void requestKartSelection(std::string kart_name);
|
void requestKartSelection(const std::string &kart_name);
|
||||||
void voteMajor(uint8_t major);
|
void voteMajor(uint8_t major);
|
||||||
void voteRaceCount(uint8_t count);
|
void voteRaceCount(uint8_t count);
|
||||||
void voteMinor(uint8_t minor);
|
void voteMinor(uint8_t minor);
|
||||||
void voteTrack(std::string track, uint8_t track_nb = 0);
|
void voteTrack(const std::string &track, uint8_t track_nb = 0);
|
||||||
void voteReversed(bool reversed, uint8_t track_nb = 0);
|
void voteReversed(bool reversed, uint8_t track_nb = 0);
|
||||||
void voteLaps(uint8_t laps, uint8_t track_nb = 0);
|
void voteLaps(uint8_t laps, uint8_t track_nb = 0);
|
||||||
void leave();
|
void leave();
|
||||||
|
Loading…
Reference in New Issue
Block a user