add result table
parent
020d82cab8
commit
e42aba3ee4
|
@ -19,8 +19,9 @@ void Client::updatePacket() {
|
||||||
void Client::processInit(sf::Packet& packet) {
|
void Client::processInit(sf::Packet& packet) {
|
||||||
sf::Uint16 targetId;
|
sf::Uint16 targetId;
|
||||||
double buf[4];
|
double buf[4];
|
||||||
|
int kills, deaths;
|
||||||
|
|
||||||
while (packet >> targetId >> buf[0] >> buf[1] >> buf[2] >> buf[3])
|
while (packet >> targetId >> buf[0] >> buf[1] >> buf[2] >> buf[3] >> kills >> deaths)
|
||||||
{
|
{
|
||||||
if(targetId != _socket.ownId()) {
|
if(targetId != _socket.ownId()) {
|
||||||
if(_spawnPlayerCallBack != nullptr)
|
if(_spawnPlayerCallBack != nullptr)
|
||||||
|
@ -28,6 +29,8 @@ void Client::processInit(sf::Packet& packet) {
|
||||||
|
|
||||||
_players[targetId]->translateToPoint(Vec3D{ buf[0], buf[1], buf[2]});
|
_players[targetId]->translateToPoint(Vec3D{ buf[0], buf[1], buf[2]});
|
||||||
_players[targetId]->setHealth(buf[3]);
|
_players[targetId]->setHealth(buf[3]);
|
||||||
|
_players[targetId]->setKills(kills);
|
||||||
|
_players[targetId]->setDeaths(deaths);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
Player.h
3
Player.h
|
@ -72,6 +72,9 @@ public:
|
||||||
void addKill() { _kills++; }
|
void addKill() { _kills++; }
|
||||||
void addDeath() { _deaths++; }
|
void addDeath() { _deaths++; }
|
||||||
|
|
||||||
|
void setKills(int kills) { _kills = kills; }
|
||||||
|
void setDeaths(int deaths) { _deaths = deaths; }
|
||||||
|
|
||||||
void setDamagePlayerCallBack(std::function<void(sf::Uint16 targetId, double)> hit) {
|
void setDamagePlayerCallBack(std::function<void(sf::Uint16 targetId, double)> hit) {
|
||||||
_damagePlayerCallBack = std::move(hit);
|
_damagePlayerCallBack = std::move(hit);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ void Server::processConnect(sf::Uint16 targetId) {
|
||||||
extraPacket << MsgType::NewClient << targetId;
|
extraPacket << MsgType::NewClient << targetId;
|
||||||
sendPacket1 << MsgType::Init << targetId;
|
sendPacket1 << MsgType::Init << targetId;
|
||||||
_players.insert({ targetId, std::make_shared<Player>() });
|
_players.insert({ targetId, std::make_shared<Player>() });
|
||||||
for (const auto& player : _players)
|
for (const auto& [playerId, player] : _players)
|
||||||
{
|
{
|
||||||
sendPacket1 << player.first << player.second->position().x() << player.second->position().y() << player.second->position().z() << player.second->health();
|
sendPacket1 << playerId << player->position().x() << player->position().y() << player->position().z() << player->health() << player->kills() << player->deaths();
|
||||||
if (player.first != targetId)
|
if (playerId != targetId)
|
||||||
_socket.sendRely(extraPacket, player.first);
|
_socket.sendRely(extraPacket, playerId);
|
||||||
}
|
}
|
||||||
_socket.sendRely(sendPacket1, targetId);
|
_socket.sendRely(sendPacket1, targetId);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue