correcting a bug in the controller events protocol
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13300 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
38f32b14cc
commit
3bf42045f6
@ -44,6 +44,15 @@ void ControllerEventsProtocol::setup()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (peers.size() > 0)
|
||||
peer = peers[0];
|
||||
}
|
||||
if (peer == NULL)
|
||||
{
|
||||
Log::error("ControllerEventsProtocol", "Couldn't find the peer corresponding to the kart.");
|
||||
}
|
||||
m_controllers.push_back(std::pair<Controller*, STKPeer*>(karts[i]->getController(), peer));
|
||||
}
|
||||
}
|
||||
@ -54,7 +63,7 @@ void ControllerEventsProtocol::notifyEvent(Event* event)
|
||||
{
|
||||
if (event->data.size() < 13)
|
||||
{
|
||||
Log::error("ControllerEventsProtocol", "The data supplied was not complete.");
|
||||
Log::error("ControllerEventsProtocol", "The data supplied was not complete. Size was %d.", event->data.size());
|
||||
return;
|
||||
}
|
||||
uint32_t token = event->data.gui32();
|
||||
@ -69,9 +78,9 @@ void ControllerEventsProtocol::notifyEvent(Event* event)
|
||||
float event_timestamp = ns.getFloat();
|
||||
ns.removeFront(4);
|
||||
uint8_t client_index = 0;
|
||||
while (ns.size() == 5)
|
||||
while (ns.size() == 9)
|
||||
{
|
||||
uint8_t controller_index = ns.gui8(0);
|
||||
uint8_t controller_index = ns.gui8();
|
||||
client_index = controller_index;
|
||||
uint8_t serialized_1 = ns.gui8(1), serialized_2 = ns.gui8(2), serialized_3 = ns.gui8(3);
|
||||
PlayerAction action = (PlayerAction)(ns.gui8(4));
|
||||
@ -86,9 +95,9 @@ void ControllerEventsProtocol::notifyEvent(Event* event)
|
||||
controls->m_skid = KartControl::SkidControl(serialized_1 & 0b00000011);
|
||||
|
||||
m_controllers[controller_index].first->action(action, action_value);
|
||||
ns.removeFront(5);
|
||||
ns.removeFront(9);
|
||||
}
|
||||
if (ns.size() > 0 && ns.size() != 5)
|
||||
if (ns.size() > 0 && ns.size() != 9)
|
||||
{
|
||||
Log::warn("ControllerEventProtocol", "The data seems corrupted.");
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void KartUpdateProtocol::update()
|
||||
Vec3 v = kart->getXYZ();
|
||||
ns.ai32( kart->getWorldKartId());
|
||||
ns.af(v[0]).af(v[1]).af(v[2]);
|
||||
Log::info("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
|
||||
Log::verbose("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
|
||||
}
|
||||
m_listener->sendMessage(this, ns, false);
|
||||
}
|
||||
@ -89,7 +89,7 @@ void KartUpdateProtocol::update()
|
||||
ns.af( World::getWorld()->getTime());
|
||||
ns.ai32( kart->getWorldKartId());
|
||||
ns.af(v[0]).af(v[1]).af(v[2]);
|
||||
Log::info("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
|
||||
Log::verbose("KartUpdateProtocol", "Sending %d's positions %f %f %f", kart->getWorldKartId(), v[0], v[1], v[2]);
|
||||
m_listener->sendMessage(this, ns, false);
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ void KartUpdateProtocol::update()
|
||||
btTransform transform = m_karts[id]->getBody()->getInterpolationWorldTransform();
|
||||
transform.setOrigin(pos);
|
||||
m_karts[id]->getBody()->setCenterOfMassTransform(transform);
|
||||
Log::info("KartUpdateProtocol", "Update kart %i pos to %f %f %f", id, pos[0], pos[1], pos[2]);
|
||||
Log::verbose("KartUpdateProtocol", "Update kart %i pos to %f %f %f", id, pos[0], pos[1], pos[2]);
|
||||
}
|
||||
m_next_positions.pop_back();
|
||||
m_karts_ids.pop_back();
|
||||
|
@ -129,7 +129,7 @@ void SynchronizationProtocol::asynchronousUpdate()
|
||||
{
|
||||
m_has_quit = true;
|
||||
Log::info("SynchronizationProtocol", "Countdown finished. Starting now.");
|
||||
m_listener->requestStart(new KartUpdateProtocol());
|
||||
// m_listener->requestStart(new KartUpdateProtocol());
|
||||
m_listener->requestStart(new ControllerEventsProtocol());
|
||||
m_listener->requestTerminate(this);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user