Johnny B. NoGood! 🎶

This commit is contained in:
MarcEricMartel 2023-11-26 12:19:05 -05:00
parent 935216e9c3
commit 0200f77be8
2 changed files with 12 additions and 7 deletions

View File

@ -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;
}
}

View File

@ -102,7 +102,7 @@ private:
Bullet* m_bullets[MAX_BULLETS];
std::unordered_map<uint64_t, Player*> m_players;
std::unordered_map<uint64_t, RemotePlayer*> m_players;
netprot::Buffer m_buf, m_bufout;
std::chrono::high_resolution_clock::time_point m_startTime;