diff --git a/SQCSim-common/player.cpp b/SQCSim-common/player.cpp index 4227abe..3d4f56d 100644 --- a/SQCSim-common/player.cpp +++ b/SQCSim-common/player.cpp @@ -284,6 +284,9 @@ bool Player::AmIDead() void Player::InflictDamage(float hitPoints) { m_hp -= hitPoints; + + if (m_hp < 0) + m_hp == 0; //if (AmIDead()) //{ // Quand le joueur est mort. //} diff --git a/SQCSim-srv/server.cpp b/SQCSim-srv/server.cpp index bc33f34..1b9e467 100644 --- a/SQCSim-srv/server.cpp +++ b/SQCSim-srv/server.cpp @@ -218,7 +218,7 @@ void Server::Run() { int timer = m_game.countdown, sync_acc = 0, deadplayers = 0; std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); Timestamp last = 0; - std::vector chatlog; + std::vector chatlog; std::vector chunkdiffs; std::vector bullets, outbox_bullets; std::vector netbull; @@ -237,6 +237,7 @@ void Server::Run() { std::string str = "Timer: "; Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false); } + last = tstamp; for (auto& [key, conn] : m_conns) { @@ -258,8 +259,8 @@ void Server::Run() { if (Deserialize(&sync, pck, &bsize)) {} break; case CHAT: - if (Deserialize(&chat, pck, &bsize)) - chatlog.push_back(chat); + //if (Deserialize(&chat, pck, &bsize)) + //chatlog.push_back(chat); break; default: break; } @@ -272,17 +273,17 @@ void Server::Run() { Timestamp tstamp = conn->Run(m_world); if (conn->player->AmIDead() && tstamp) { - Chat chat; - chat.dest_id = chat.dest_team_id = chat.src_id = 0; + Chat* chat = new Chat(); + chat->dest_id = chat->dest_team_id = chat->src_id = 0; std::string killer = m_conns.at(key)->player->GetUsername(); std::string mess = getDeathMessage(conn->player->GetUsername(), killer); - strcpy(chat.mess, 140, mess.c_str()); - Log("You is dead", false, false); + strcpy(chat->mess, 140, mess.c_str()); + Log(mess, false, false); - m_chatlog[tstamp] = chat; + chatlog.emplace_back(chat); ++deadplayers; conn->m_nsync == false; } @@ -329,9 +330,10 @@ void Server::Run() { } for (auto& chat : chatlog) { - Log(chat.mess, false, false); + Log(chat->mess, false, false); for (auto& [key, conn] : m_conns) - sendPackTo(m_sock_udp, &chat, &m_buf, conn->getAddr()); + sendPackTo(m_sock_udp, chat, &m_buf, conn->getAddr()); + delete chat; } for (auto& chmo : chunkdiffs) { diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index cec5c3a..79fd8f1 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1421,6 +1421,7 @@ void Engine::Render(float elapsedTime) { if (m_syncs.count(sync.timestamp)) { Sync comp = m_syncs[sync.timestamp]; m_player.InflictDamage(sync.hp - comp.hp); + Vector3f diff = sync.position - comp.position;