From 325c6b60f9cfa6c3d66e172a4a03260aedd1390b Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Wed, 13 Dec 2023 16:29:13 -0500 Subject: [PATCH 1/2] keep in sync when dead --- SQCSim-common/bullet.cpp | 2 +- SQCSim-srv/connection.cpp | 13 +++++++++++++ SQCSim-srv/server.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/SQCSim-common/bullet.cpp b/SQCSim-common/bullet.cpp index 72da0c1..87412da 100644 --- a/SQCSim-common/bullet.cpp +++ b/SQCSim-common/bullet.cpp @@ -18,7 +18,7 @@ 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) { + if ((m_currentpos - player->GetPosition()).Length() < 1.f) { hit = true; } if ((m_currentpos - player->GetPOV()).Length() < .2f) { diff --git a/SQCSim-srv/connection.cpp b/SQCSim-srv/connection.cpp index 700c1da..34db420 100644 --- a/SQCSim-srv/connection.cpp +++ b/SQCSim-srv/connection.cpp @@ -77,6 +77,19 @@ void Connection::getPacks(SOCKET sock) { void Connection::sendPacks(SOCKET sock, std::unordered_map conns, const uint32_t timer) { static int outs = 0; static Timestamp last = 0; + static uint32_t lasttimer = timer; + + if (m_output_vector.empty() && player->AmIDead()) { + if (timer != lasttimer) { + lasttimer = timer; + Sync sync; + sync.timestamp = sync.sid = m_loginfo.sid; + sync.hp = 0; + sync.ammo = -1; + sync.timer = timer; + sendPackTo(sock, &sync, &m_bufout, &m_addr); + } + } while (!m_output_vector.empty()) { Output out = m_output_vector.front(); diff --git a/SQCSim-srv/server.cpp b/SQCSim-srv/server.cpp index 6d7153c..2a8825e 100644 --- a/SQCSim-srv/server.cpp +++ b/SQCSim-srv/server.cpp @@ -374,7 +374,7 @@ void Server::Run() { for (auto bull = bullets.begin(); bull != bullets.end(); ++bull) { ChunkMod* cmod = nullptr; Bullet* bullet = *bull; - if (bullet->Update(m_world, (1. / 60.), 10, m_players, &cmod)) { + if (bullet->Update(m_world, (1. / 60.), 100, m_players, &cmod)) { if (cmod) chunkdiffs.emplace_back(cmod); bullit.push_back(bull); From b8899b8f8608096cdd74b7c0f03a9efbff1fe8aa Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Wed, 13 Dec 2023 16:30:20 -0500 Subject: [PATCH 2/2] NO CHEATING! --- SQCSim-srv/connection.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SQCSim-srv/connection.cpp b/SQCSim-srv/connection.cpp index 34db420..c9fd885 100644 --- a/SQCSim-srv/connection.cpp +++ b/SQCSim-srv/connection.cpp @@ -59,7 +59,9 @@ void Connection::getPacks(SOCKET sock) { switch (netprot::getType(pck, 1)) { using enum netprot::PACKET_TYPE; case INPUT: - if (Deserialize(&in, pck, &bsize)) { + if (player->AmIDead()) + break; + else if (Deserialize(&in, pck, &bsize)) { m_input_manifest[in.timestamp] = in; m_input_vector.push_back(in); }