et c'est un début!
This commit is contained in:
parent
fc4aa20005
commit
2c3abff96f
@ -125,6 +125,7 @@ namespace netprot {
|
||||
send(sock, *buf, *buflen, 0);
|
||||
*buflen = BUFFER_LENGTH;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -164,10 +164,13 @@ void Server::Run() {
|
||||
char* buf = new char[BUFFER_LENGTH];
|
||||
uint32_t buflen = BUFFER_LENGTH;
|
||||
netprot::Input in;
|
||||
sockaddr_in sockad;
|
||||
int socklen = sizeof(sockad);
|
||||
|
||||
Log("Partie en cours...", false, false);
|
||||
|
||||
while (true) {
|
||||
if (recv(m_sock_udp, buf, BUFFER_LENGTH, 0) > 0) {
|
||||
if (recvfrom(m_sock_udp, buf, BUFFER_LENGTH, 0, (sockaddr*)&sockad, &socklen) > 0) {
|
||||
Deserialize(&in, buf, buflen);
|
||||
std::cout << "Id: " << in.sid << "\r\n"
|
||||
<< "Direction: { " << in.direction.x << ", " << in.direction.y << ", " << in.direction.z << " }" << "\r\n";
|
||||
|
@ -20,6 +20,7 @@ public:
|
||||
|
||||
SOCKET m_sock_udp = 0,
|
||||
m_sock_tcp = 0;
|
||||
sockaddr_in m_srvsockaddr;
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
WSADATA m_wsaData;
|
||||
@ -31,7 +32,6 @@ private:
|
||||
netprot::LoginInfo m_loginfo;
|
||||
netprot::GameInfo m_gameinfo;
|
||||
|
||||
sockaddr_in m_srvsockaddr;
|
||||
|
||||
|
||||
};
|
||||
|
@ -783,6 +783,7 @@ void Engine::Render(float elapsedTime) {
|
||||
static char* buf = new char[BUFFER_LENGTH];
|
||||
uint32_t buflen = BUFFER_LENGTH;
|
||||
netprot::Input input;
|
||||
sockaddr_in addr = m_conn.m_srvsockaddr;
|
||||
|
||||
input.direction = m_player.GetDirection();
|
||||
input.sid = m_conn.getId();
|
||||
@ -795,7 +796,10 @@ void Engine::Render(float elapsedTime) {
|
||||
input.keys.block = m_mouseR;
|
||||
input.keys.shoot = m_mouseL;
|
||||
|
||||
netprot::sendPack<netprot::Input>(m_conn.m_sock_udp, &input, &buf, &buflen);
|
||||
netprot::Serialize(&input, &buf, &buflen);
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user