Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2016-03-09 13:22:00 +11:00
commit f35b3d2670
5 changed files with 20 additions and 40 deletions

View File

@ -539,7 +539,7 @@ void ClientLobbyRoomProtocol::startGame(Event* event)
m_state = PLAYING;
ProtocolManager::getInstance()
->requestStart(new StartGameProtocol(m_setup));
Log::error("ClientLobbyRoomProtocol", "Starting new game");
Log::info("ClientLobbyRoomProtocol", "Starting new game");
} // startGame
//-----------------------------------------------------------------------------

View File

@ -47,42 +47,27 @@ ControllerEventsProtocol::~ControllerEventsProtocol()
bool ControllerEventsProtocol::notifyEventAsynchronous(Event* event)
{
if (event->getType() != EVENT_TYPE_MESSAGE)
return true;
if(checkDataSize(event, 13)) return true;
const NetworkString &data = event->data();
if (data.size() < 17)
{
Log::error("ControllerEventsProtocol",
"The data supplied was not complete. Size was %d.",
data.size());
return true;
}
uint32_t token = data.getUInt32();
NetworkString pure_message = data;
pure_message.removeFront(4);
if (token != event->getPeer()->getClientServerToken())
{
Log::error("ControllerEventsProtocol", "Bad token from peer.");
return true;
}
NetworkString ns = pure_message;
NetworkString &data = event->data();
float time = data.getFloat(0);
ns.removeFront(4);
data.removeFront(4); // remove time
uint8_t client_index = -1;
while (ns.size() >= 9)
while (data.size() >= 9)
{
//uint8_t controller_index = ns.gui8();
uint8_t kart_id = ns.getUInt8();
uint8_t kart_id = data.getUInt8();
if (kart_id >=World::getWorld()->getNumKarts())
{
Log::warn("ControllerEventProtocol", "No valid kart id (%s).",
kart_id);
return true;
data.removeFront(9);
continue;
}
uint8_t serialized_1 = ns.getUInt8(1);
PlayerAction action = (PlayerAction)(ns.getUInt8(4));
int action_value = ns.getUInt32(5);
uint8_t serialized_1 = data.getUInt8(1);
PlayerAction action = (PlayerAction)(data.getUInt8(4));
int action_value = data.getUInt32(5);
Controller *controller = World::getWorld()->getKart(kart_id)
->getController();
KartControl *controls = controller->getControls();
@ -94,20 +79,18 @@ bool ControllerEventsProtocol::notifyEventAsynchronous(Event* event)
controls->m_skid = KartControl::SkidControl(serialized_1 & 0x03);
controller->action(action, action_value);
ns.removeFront(9);
//Log::info("ControllerEventProtocol", "Registered one action.");
data.removeFront(9);
}
if (ns.size() > 0 && ns.size() != 9)
if (data.size() > 0 )
{
Log::warn("ControllerEventProtocol",
"The data seems corrupted. Remains %d", ns.size());
return true;
"The data seems corrupted. Remains %d", data.size());
}
if (NetworkConfig::get()->isServer())
{
// Send update to all clients except the original sender.
STKHost::get()->sendPacketExcept(event->getPeer(),
&pure_message, false);
&data, false);
} // if server
return true;
} // notifyEventAsynchronous

View File

@ -528,9 +528,6 @@ void* STKHost::mainLoop(void* self)
// Create an STKEvent with the event data. This will also
// create the peer if it doesn't exist already
Event* stk_event = new Event(&event);
if (stk_event->getType() == EVENT_TYPE_MESSAGE)
Network::logPacket(stk_event->data(), true);
Log::verbose("STKHost", "Event of type %d received",
(int)(stk_event->getType()));
STKPeer* peer = stk_event->getPeer();
@ -543,13 +540,13 @@ void* STKHost::mainLoop(void* self)
} // EVENT_TYPE_CONNECTED
else if (stk_event->getType() == EVENT_TYPE_MESSAGE)
{
Network::logPacket(stk_event->data(), true);
TransportAddress stk_addr(peer->getAddress());
Log::verbose("NetworkManager",
"Message, Sender : %s, message:",
stk_addr.toString(/*show port*/false).c_str());
Log::verbose("NetworkManager", "%s",
stk_event->data().getLogMessage().c_str());
} // if message event
// notify for the event now.

View File

@ -105,7 +105,7 @@ void GhostReplaySelection::loadList()
row.push_back(GUIEngine::ListWidget::ListCell
(rd.m_reverse ? _("Yes") : _("No"), -1, 1, true));
row.push_back(GUIEngine::ListWidget::ListCell
(rd.m_difficulty == 3 ? _("Supertux") : rd.m_difficulty == 2 ?
(rd.m_difficulty == 3 ? _("SuperTux") : rd.m_difficulty == 2 ?
_("Expert") : rd.m_difficulty == 1 ?
_("Intermediate") : _("Novice") , -1, 1, true));
row.push_back(GUIEngine::ListWidget::ListCell
@ -199,4 +199,4 @@ void GhostReplaySelection::onColumnClicked(int column_id)
loadList();
} // onColumnClicked
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------

View File

@ -67,7 +67,7 @@ void WaitingForOthersScreen::onUpdate(float dt)
const std::vector<STKPeer*>& peers = STKHost::get()->getPeers();
RaceConfig* config = STKHost::get()->getGameSetup()->getRaceConfig();
core::stringw w;
for (int i = 0; i < peers.size(); i++)
for (unsigned int i = 0; i < peers.size(); i++)
{
//race_manager->get