🕐 Implémentation de la synchro basique.
This commit is contained in:
parent
8bd46ba831
commit
e5e3c19137
@ -1107,15 +1107,26 @@ void Engine::Render(float elapsedTime) {
|
|||||||
fell = false;
|
fell = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_networkgame) {
|
if (m_networkgame) { // Pour se gerer le paquet.
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using namespace netprot;
|
using namespace netprot;
|
||||||
|
Timestamp tstamp = duration_cast<milliseconds>(high_resolution_clock::now() - m_startTime).count();
|
||||||
Input input;
|
Input input;
|
||||||
|
Sync sync;
|
||||||
|
uint64_t id = m_conn.getId();
|
||||||
static std::vector<char*> lsPck;
|
static std::vector<char*> 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.direction = m_player.GetDirection();
|
||||||
input.timestamp = duration_cast<milliseconds>(high_resolution_clock::now() - m_startTime).count();
|
input.timestamp = tstamp;
|
||||||
input.keys.forward = m_keyW;
|
input.keys.forward = m_keyW;
|
||||||
input.keys.backward = m_keyS;
|
input.keys.backward = m_keyS;
|
||||||
input.keys.left = m_keyA;
|
input.keys.left = m_keyA;
|
||||||
@ -1141,7 +1152,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
if (Deserialize(&sync, pck, &bsize)) {
|
if (Deserialize(&sync, pck, &bsize)) {
|
||||||
if (sync.sid != m_conn.getId())
|
if (sync.sid != m_conn.getId())
|
||||||
break;
|
break;
|
||||||
// TODO: Vérifier si les positions concordent.
|
// TODO: Vérifier si les positions concordent au sync local.
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OUTPUT:
|
case OUTPUT:
|
||||||
|
Loading…
Reference in New Issue
Block a user