We are now sending EPlayerDamage events.

Client now listens to EPlayerDamage events and send them to Server.
Server publishes EPlayerDamage events received from Client.
This commit is contained in:
Jocke
2016-01-14 10:16:11 +01:00
parent a060640da3
commit db18a45368
5 changed files with 35 additions and 15 deletions
+12 -2
View File
@@ -298,7 +298,7 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
{
if (e.Command == "ConnectToServer") { // Connect for now
connect();
LOG_INFO("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
return true;
} else {
Packet packet(MessageType::OnInputCommand, m_SendPacketID);
@@ -306,12 +306,22 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
packet.WritePrimitive(e.PlayerID);
packet.WritePrimitive(e.Value);
send(packet);
LOG_INFO("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
return true;
}
return false;
}
bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
{
Packet packet(MessageType::OnInputCommand, m_SendPacketID);
packet.WritePrimitive(e.DamageAmount);
packet.WritePrimitive(e.PlayerDamagedID);
packet.WriteString(e.TypeOfDamage);
send(packet);
return false;
}
void Client::identifyPacketLoss()
{
// if no packets lost, difference should be equal to 1