diff --git a/SQCSim-common/bullet.cpp b/SQCSim-common/bullet.cpp index ad9e931..413c2cc 100644 --- a/SQCSim-common/bullet.cpp +++ b/SQCSim-common/bullet.cpp @@ -16,11 +16,9 @@ bool Bullet::Update(World* world, float elapsedtime, int perframe, std::unordere for (auto& [key, player] : mapPlayer) { bool hit = false; if ((m_currentpos - player->GetPosition()).Length() < .6f) { - std::cout << "hit" << std::endl; hit = true; } if ((m_currentpos - player->GetPOV()).Length() < .2f) { - std::cout << "headshot" << std::endl; damage *= 2; // HEADSHOT! hit = true; } diff --git a/SQCSim-srv/server.cpp b/SQCSim-srv/server.cpp index 41ad711..5314c31 100644 --- a/SQCSim-srv/server.cpp +++ b/SQCSim-srv/server.cpp @@ -200,6 +200,10 @@ void Server::Run() { m_world->BuildWorld(); for (auto& [key, conn] : m_conns) { // Creation des instances de joueurs et premier sync. + if (!conn) { + m_conns.erase(key); + continue; + } int x = 0,// (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1)),// -(CHUNK_SIZE_X * WORLD_SIZE_X / 2), y = 0;// (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1));// -(CHUNK_SIZE_Y * WORLD_SIZE_Y / 2); conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f)); @@ -247,7 +251,8 @@ void Server::Run() { } last = tstamp; - for (auto& [key, conn] : m_conns) { + + for (auto& [key, conn] : m_conns) { /* In */ @@ -260,8 +265,10 @@ void Server::Run() { switch (netprot::getType(pck, 1)) { using enum netprot::PACKET_TYPE; case INPUT: - if (Deserialize(&in, pck, &bsize)) - m_conns[in.sid]->AddInput(in); + if (Deserialize(&in, pck, &bsize)) { + if (m_conns.count(in.sid)) + m_conns[in.sid]->AddInput(in); + } break; case SYNC: if (Deserialize(&sync, pck, &bsize)) {} @@ -298,6 +305,9 @@ void Server::Run() { chunkdiffs.emplace_back(std::move(chmo)); conn->ChunkDiffs.clear(); + std::string str = conn->player->GetUsername(); + Log(str.append(" ").append(std::to_string(conn->player->GetHP())), false, false); + for (auto& bull : conn->Bullets) { bullets.emplace_back(bull); Log("POW!", false, false);