From e5e3c19137fe1dcc0ece3f8adf544d21424cbdca Mon Sep 17 00:00:00 2001 From: MarcEricMartel Date: Tue, 7 Nov 2023 07:56:59 -0500 Subject: [PATCH] =?UTF-8?q?:clock1:=20=20Impl=C3=A9mentation=20de=20la=20s?= =?UTF-8?q?ynchro=20basique.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SQCSim2021/engine.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/SQCSim2021/engine.cpp b/SQCSim2021/engine.cpp index fa20611..6042225 100644 --- a/SQCSim2021/engine.cpp +++ b/SQCSim2021/engine.cpp @@ -1107,15 +1107,26 @@ void Engine::Render(float elapsedTime) { fell = false; } - if (m_networkgame) { + if (m_networkgame) { // Pour se gerer le paquet. using namespace std::chrono; using namespace netprot; + Timestamp tstamp = duration_cast(high_resolution_clock::now() - m_startTime).count(); Input input; + Sync sync; + uint64_t id = m_conn.getId(); static std::vector lsPck; - input.sid = m_conn.getId(); + if (false) { // TODO: Faire un checkup pour chaque ~1000ms. + sync.sid = id; + sync.timestamp = tstamp; + sync.position = m_player.GetPosition(); + sync.hp = m_player.GetHP(); + // TODO: Garrocher ca quelque-part. + } + + input.sid = id; input.direction = m_player.GetDirection(); - input.timestamp = duration_cast(high_resolution_clock::now() - m_startTime).count(); + input.timestamp = tstamp; input.keys.forward = m_keyW; input.keys.backward = m_keyS; input.keys.left = m_keyA; @@ -1141,7 +1152,7 @@ void Engine::Render(float elapsedTime) { if (Deserialize(&sync, pck, &bsize)) { if (sync.sid != m_conn.getId()) break; - // TODO: Vérifier si les positions concordent. + // TODO: Vérifier si les positions concordent au sync local. } break; case OUTPUT: