From 0200f77be8f927e147ea41e4414c2b849f0a1174 Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Sun, 26 Nov 2023 12:19:05 -0500 Subject: [PATCH] Johnny B. NoGood! :notes: --- SQCSim2021/engine.cpp | 17 +++++++++++------ SQCSim2021/engine.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index 741ee98..7ed6fde 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1324,8 +1324,10 @@ void Engine::Render(float elapsedTime) { using enum PACKET_TYPE; case SYNC: if (Deserialize(&sync, pck, &bsize)) { - if (sync.sid != m_conn.getId()) + if (sync.sid != m_conn.getId()) { + std::cout << "syncid be no good."; break; + } if (m_syncs.contains(sync.timestamp)) { Sync comp = m_syncs[sync.timestamp]; m_player.InflictDamage(sync.hp - comp.hp); @@ -1333,20 +1335,23 @@ void Engine::Render(float elapsedTime) { Vector3f diff = sync.position - comp.position; if (diff.Length() > .5) m_player.Move(diff); - - // TODO: m_timer = sync.timer; + + // TODO: Syncer sync.timer avec le timer } + else std::cout << "sync be no good."; } break; case OUTPUT: if (Deserialize(&out, pck, &bsize)) { - RemotePlayer* r = m_players[out.id]; - if (!r) + if (!m_players.contains(out.id)) { + std::cout << "id be no good. "; break; - r->Feed(out); + } + m_players[out.id]->Feed(out); } break; default: + std::cout << "packet be no good."; break; } } diff --git a/SQCSim2021/engine.h b/SQCSim2021/engine.h index d7860ed..8c5ee10 100644 --- a/SQCSim2021/engine.h +++ b/SQCSim2021/engine.h @@ -102,7 +102,7 @@ private: Bullet* m_bullets[MAX_BULLETS]; - std::unordered_map m_players; + std::unordered_map m_players; netprot::Buffer m_buf, m_bufout; std::chrono::high_resolution_clock::time_point m_startTime;