wtf?!
This commit is contained in:
parent
5cf5eb132a
commit
408679433b
@ -154,10 +154,15 @@ int Server::Ready() {
|
|||||||
|
|
||||||
play.tid = log->tid;
|
play.tid = log->tid;
|
||||||
|
|
||||||
|
//using namespace std::chrono_literals;
|
||||||
|
//std::this_thread::sleep_for(100ms);
|
||||||
|
|
||||||
sendPack<GameInfo>(sock, &m_game, &m_buf);
|
sendPack<GameInfo>(sock, &m_game, &m_buf);
|
||||||
std::unique_ptr<Connection> conn = std::make_unique<Connection>(sock, sockad, *log, play);
|
std::unique_ptr<Connection> conn = std::make_unique<Connection>(sock, sockad, *log, play);
|
||||||
|
|
||||||
for (auto& [key, player] : m_players) {
|
for (auto& [key, player] : m_players) {
|
||||||
|
//using namespace std::chrono_literals;
|
||||||
|
//std::this_thread::sleep_for(100ms);
|
||||||
sendPack<PlayerInfo>(player->getSock(), &play, &m_buf); // Envoyer les infos de joueur distant aux joueurs d<>j<EFBFBD> connect<63>s
|
sendPack<PlayerInfo>(player->getSock(), &play, &m_buf); // Envoyer les infos de joueur distant aux joueurs d<>j<EFBFBD> connect<63>s
|
||||||
sendPack<PlayerInfo>(sock, player->getInfo(), &m_buf); // et envoyer les infos des joueurs distants au nouveau joueur.
|
sendPack<PlayerInfo>(sock, player->getInfo(), &m_buf); // et envoyer les infos des joueurs distants au nouveau joueur.
|
||||||
}
|
}
|
||||||
|
@ -1102,14 +1102,11 @@ void Engine::Render(float elapsedTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_networkgame) {
|
if (m_networkgame) {
|
||||||
static char* buf = new char[BUFFER_LENGTH];
|
|
||||||
uint32_t buflen = BUFFER_LENGTH;
|
|
||||||
netprot::Input input;
|
netprot::Input input;
|
||||||
//sockaddr_in addr = m_conn.m_srvsockaddr;
|
|
||||||
|
|
||||||
input.direction = m_player.GetDirection();
|
|
||||||
input.sid = m_conn.getId();
|
input.sid = m_conn.getId();
|
||||||
input.timestamp = 12345;
|
input.direction = m_player.GetDirection();
|
||||||
|
input.timestamp = 12345; // TODO: Implémenter
|
||||||
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;
|
||||||
@ -1118,10 +1115,7 @@ void Engine::Render(float elapsedTime) {
|
|||||||
input.keys.block = m_mouseR;
|
input.keys.block = m_mouseR;
|
||||||
input.keys.shoot = m_mouseL;
|
input.keys.shoot = m_mouseL;
|
||||||
|
|
||||||
//netprot::Serialize(&input, &buf, &buflen);
|
netprot::sendPackTo<netprot::Input>(m_conn.m_sock_udp, &input, &m_buf, &m_conn.m_srvsockaddr);
|
||||||
//sendto(m_conn.m_sock_udp, buf, buflen, 0, (sockaddr*)&addr, sizeof(addr));
|
|
||||||
|
|
||||||
netprot::sendPackTo<netprot::Input>(m_conn.m_sock_udp, &input, &buf, &buflen, &m_conn.m_srvsockaddr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
else if (m_gamestate == GameState::MAIN_MENU || m_gamestate == GameState::OPTIONS)
|
||||||
|
@ -88,6 +88,7 @@ private:
|
|||||||
Bullet* m_bullets[MAX_BULLETS];
|
Bullet* m_bullets[MAX_BULLETS];
|
||||||
|
|
||||||
std::map<uint64_t, Player*> m_players;
|
std::map<uint64_t, Player*> m_players;
|
||||||
|
netprot::Buffer m_buf;
|
||||||
|
|
||||||
//Menu
|
//Menu
|
||||||
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
enum class GameState: uint8_t { MAIN_MENU, OPTIONS, QUIT, NEWG, PLAY };
|
||||||
|
Loading…
Reference in New Issue
Block a user