heum well

This commit is contained in:
MarcEricMartel
2023-11-06 17:59:57 -05:00
parent 253e49b1cc
commit bc1f4f750b
6 changed files with 70 additions and 30 deletions

View File

@@ -1111,6 +1111,7 @@ void Engine::Render(float elapsedTime) {
using namespace std::chrono;
using namespace netprot;
Input input;
static std::vector<char*> lsPck;
input.sid = m_conn.getId();
input.direction = m_player.GetDirection();
@@ -1123,10 +1124,27 @@ void Engine::Render(float elapsedTime) {
input.keys.block = m_mouseR;
input.keys.shoot = m_mouseL;
sendPackTo<Input>(m_conn.m_sock_udp, &input, &m_buf, &m_conn.m_srvsockaddr);
sendPackTo<Input>(m_conn.m_sock_udp, &input, &m_bufout, &m_conn.m_srvsockaddr);
// TODO: Faire la gestion de la réception de paquets.
lsPck = recvPacks(m_conn.m_sock_udp, &m_buf);
for (auto& pck : lsPck) {
uint32_t bsize = m_buf.len - (pck - m_buf.ptr);
netprot::Sync sync;
netprot::Output out;
switch (netprot::getType(pck, 1)) {
using enum netprot::PACKET_TYPE;
case SYNC:
if (!netprot::Deserialize(&sync, pck, &bsize)) {}
break;
case OUTPUT:
if (!netprot::Deserialize(&out, pck, &bsize)) {}
break;
default:
break;
}
}
lsPck.clear();
}
}
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)