Updated VS 9 project file, and fixed compilation problems.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/networking@13139 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
587fcdec32
commit
49631c0027
@ -43,14 +43,6 @@
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||
// Use Sleep, which takes time in msecs. It must be defined after the
|
||||
// includes, since otherwise irrlicht's sleep function is changed.
|
||||
# define sleep(s) Sleep(1000*(s))
|
||||
#else
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Create a thread that handles all network functions independent of the
|
||||
* main program. NetworkHttp supports only a single thread (i.e. it's not
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <vector>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# include <WinSock2.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
|
||||
|
@ -1142,23 +1142,23 @@
|
||||
Name="network"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\network\connect_message.cpp"
|
||||
RelativePath="..\..\network\client_network_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\kart_control_message.cpp"
|
||||
RelativePath="..\..\network\event.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\kart_update_message.cpp"
|
||||
RelativePath="..\..\network\game_setup.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\message.cpp"
|
||||
RelativePath="..\..\network\http_functions.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\network_kart.cpp"
|
||||
RelativePath="..\..\network\network_interface.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -1166,17 +1166,81 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_info_message.cpp"
|
||||
RelativePath="..\..\network\network_string.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_result_message.cpp"
|
||||
RelativePath="..\..\network\protocol.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_state.cpp"
|
||||
RelativePath="..\..\network\protocol_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\server_network_manager.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\stk_host.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\stk_peer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\types.cpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="protocols"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\connect_to_peer.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\connect_to_server.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\get_peer_address.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\get_public_address.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\hide_public_address.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\lobby_room_protocol.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\ping_protocol.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\request_connection.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\show_public_address.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\start_server.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\stop_server.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="tracks"
|
||||
@ -1421,6 +1485,18 @@
|
||||
RelativePath="..\..\states_screens\main_menu_screen.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\networking_lobby.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\networking_lobby_settings.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\online_screen.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\options_screen_audio.cpp"
|
||||
>
|
||||
@ -1508,6 +1584,10 @@
|
||||
RelativePath="..\..\states_screens\dialogs\gp_info_dialog.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\login_dialog.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\message_dialog.cpp"
|
||||
>
|
||||
@ -1524,6 +1604,10 @@
|
||||
RelativePath="..\..\states_screens\dialogs\race_paused_dialog.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\registration_dialog.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\select_challenge.cpp"
|
||||
>
|
||||
@ -1638,6 +1722,22 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="online"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\online\current_online_user.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\online\http_connector.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\online\online_user.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
@ -1780,47 +1880,23 @@
|
||||
Name="network"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\network\character_confirm_message.hpp"
|
||||
RelativePath="..\..\network\client_network_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\character_info_message.hpp"
|
||||
RelativePath="..\..\network\event.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\character_selected_message.hpp"
|
||||
RelativePath="..\..\network\game_setup.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\connect_message.hpp"
|
||||
RelativePath="..\..\network\http_functions.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\flyable_info.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\item_info.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\kart_control_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\kart_packet.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\kart_update_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\network_kart.hpp"
|
||||
RelativePath="..\..\network\network_interface.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -1828,23 +1904,15 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_info_message.hpp"
|
||||
RelativePath="..\..\network\network_string.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_result_ack_message.hpp"
|
||||
RelativePath="..\..\network\protocol.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_result_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_start_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\race_state.hpp"
|
||||
RelativePath="..\..\network\protocol_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
@ -1852,9 +1920,73 @@
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\world_loaded_message.hpp"
|
||||
RelativePath="..\..\network\server_network_manager.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\singleton.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\stk_host.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\stk_peer.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\types.hpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="protocols"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\connect_to_peer.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\connect_to_server.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\get_peer_address.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\get_public_address.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\hide_public_address.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\lobby_room_protocol.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\ping_protocol.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\request_connection.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\show_public_address.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\start_server.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\network\protocols\stop_server.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="utils"
|
||||
@ -2623,6 +2755,18 @@
|
||||
RelativePath="..\..\states_screens\main_menu_screen.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\networking_lobby.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\networking_lobby_settings.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\online_screen.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\options_screen_audio.hpp"
|
||||
>
|
||||
@ -2710,6 +2854,10 @@
|
||||
RelativePath="..\..\states_screens\dialogs\gp_info_dialog.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\login_dialog.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\message_dialog.hpp"
|
||||
>
|
||||
@ -2726,6 +2874,10 @@
|
||||
RelativePath="..\..\states_screens\dialogs\race_paused_dialog.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\registration_dialog.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\states_screens\dialogs\select_challenge.hpp"
|
||||
>
|
||||
@ -2828,6 +2980,22 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="online"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\online\current_online_user.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\online\http_connector.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\online\online_user.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Ressourcendateien"
|
||||
|
@ -419,6 +419,8 @@ void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
|
||||
// at it directly, stop interpolating, instead fly straight
|
||||
// towards it.
|
||||
Vec3 diff = m_target->getXYZ()-getXYZ();
|
||||
if(diff.length()==0)
|
||||
printf("diff=0\n");
|
||||
*next_xyz = getXYZ() + (dt*m_speed/diff.length())*diff;
|
||||
|
||||
Vec3 old_vec = getXYZ()-m_previous_xyz;
|
||||
|
@ -21,8 +21,7 @@
|
||||
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "network/network_string.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils/types.hpp"
|
||||
|
||||
/*!
|
||||
* \enum EVENT_TYPE
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "network/types.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
#ifndef NETWORK_STRING_HPP
|
||||
#define NETWORK_STRING_HPP
|
||||
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
|
@ -21,8 +21,7 @@
|
||||
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/types.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "utils/types.hpp"
|
||||
|
||||
/** \enum PROTOCOL_TYPE
|
||||
* \brief The types that protocols can have. This is used to select which protocol receives which event.
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "network/singleton.hpp"
|
||||
#include "network/event.hpp"
|
||||
#include "network/network_string.hpp"
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
class Protocol;
|
||||
|
||||
|
@ -97,13 +97,15 @@ void ConnectToPeer::update()
|
||||
}
|
||||
break;
|
||||
case CONNECTING: // waiting the peer to connect
|
||||
static double timer = 0;
|
||||
if (Time::getRealTime() > timer+5.0) // every 5 seconds
|
||||
{
|
||||
timer = Time::getRealTime();
|
||||
NetworkManager::getInstance()->connect(m_peer_address);
|
||||
static double timer = 0;
|
||||
if (Time::getRealTime() > timer+5.0) // every 5 seconds
|
||||
{
|
||||
timer = Time::getRealTime();
|
||||
NetworkManager::getInstance()->connect(m_peer_address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
{
|
||||
m_listener->requestTerminate( m_listener->getProtocol(m_current_protocol_id)); // kill the ping protocol because we're connected
|
||||
|
@ -115,13 +115,15 @@ void ConnectToServer::update()
|
||||
}
|
||||
break;
|
||||
case CONNECTING: // waiting the server to answer our connection
|
||||
static double timer = 0;
|
||||
if (Time::getRealTime() > timer+5.0) // every 5 seconds
|
||||
{
|
||||
timer = Time::getRealTime();
|
||||
NetworkManager::getInstance()->connect(m_server_address);
|
||||
static double timer = 0;
|
||||
if (Time::getRealTime() > timer+5.0) // every 5 seconds
|
||||
{
|
||||
timer = Time::getRealTime();
|
||||
NetworkManager::getInstance()->connect(m_server_address);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CONNECTED:
|
||||
{
|
||||
m_listener->requestTerminate( m_listener->getProtocol(m_current_protocol_id)); // kill the ping protocol because we're connected
|
||||
|
@ -32,7 +32,7 @@ int stunRand()
|
||||
static bool init = false;
|
||||
if (!init)
|
||||
{
|
||||
srand(time(NULL));
|
||||
srand((unsigned int)time(NULL));
|
||||
init = true;
|
||||
}
|
||||
return rand();
|
||||
@ -61,7 +61,7 @@ void GetPublicAddress::update()
|
||||
if (m_state == NOTHING_DONE)
|
||||
{
|
||||
// format : 00MMMMMCMMMCMMMM (cf rfc 5389)
|
||||
uint16_t message_type = 0b0000000000000001; // binding request
|
||||
uint16_t message_type = 0x0001; // binding request
|
||||
m_stun_tansaction_id[0] = stunRand();
|
||||
m_stun_tansaction_id[1] = stunRand();
|
||||
m_stun_tansaction_id[2] = stunRand();
|
||||
@ -110,12 +110,12 @@ void GetPublicAddress::update()
|
||||
assert(data);
|
||||
|
||||
// check that the stun response is a response, contains the magic cookie and the transaction ID
|
||||
if ( data[0] == 0b01 &&
|
||||
data[1] == 0b01 &&
|
||||
if ( data[0] == 0x01 &&
|
||||
data[1] == 0x01 &&
|
||||
data[4] == (uint8_t)(m_stun_magic_cookie>>24) &&
|
||||
data[5] == (uint8_t)(m_stun_magic_cookie>>16) &&
|
||||
data[6] == (uint8_t)(m_stun_magic_cookie>>8) &&
|
||||
data[7] == (uint8_t)(m_stun_magic_cookie))
|
||||
data[7] == (uint8_t)(m_stun_magic_cookie) )
|
||||
{
|
||||
if(
|
||||
data[8] == (uint8_t)(m_stun_tansaction_id[0]>>24) &&
|
||||
|
@ -102,7 +102,7 @@ void ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
m_setup->addPlayer(profile);
|
||||
}
|
||||
} // new player connected
|
||||
else if (message_type == 0b10000001) // connection accepted
|
||||
else if (message_type == 0x81) // connection accepted
|
||||
{
|
||||
if (event->data.size() != 12 || event->data[0] != 1 || event->data[2] != 4 || event->data[7] != 4) // 12 bytes remains now
|
||||
{
|
||||
@ -124,7 +124,7 @@ void ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
m_state = CONNECTED;
|
||||
}
|
||||
} // connection accepted
|
||||
else if (message_type == 0b10000000) // connection refused
|
||||
else if (message_type == 0x80) // connection refused
|
||||
{
|
||||
if (event->data.size() != 2 || event->data[0] != 1) // 2 bytes remains now
|
||||
{
|
||||
@ -203,13 +203,13 @@ void ServerLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
((token_generator.get(RAND_MAX)<<8) & 0xff) +
|
||||
((token_generator.get(RAND_MAX) & 0xff)));
|
||||
// connection success (129) -- size of token -- token
|
||||
message_ack.ai8(0b10000001).ai8(1).ai8(m_next_id).ai8(4).ai32(token).ai8(4).ai32(player_id);
|
||||
message_ack.ai8(0x81).ai8(1).ai8(m_next_id).ai8(4).ai32(token).ai8(4).ai32(player_id);
|
||||
m_listener->sendMessage(this, event->peer, message_ack);
|
||||
} // accept player
|
||||
else // refuse the connection with code 0 (too much players)
|
||||
{
|
||||
NetworkString message;
|
||||
message.ai8(0b10000000); // 128 means connection refused
|
||||
message.ai8(0x80); // 128 means connection refused
|
||||
message.ai8(1); // 1 bytes for the error code
|
||||
message.ai8(0); // 0 = too much players
|
||||
// send only to the peer that made the request
|
||||
@ -285,6 +285,7 @@ void ServerLobbyRoomProtocol::update()
|
||||
}
|
||||
break;
|
||||
case WORKING:
|
||||
{
|
||||
// first poll every 5 seconds
|
||||
static double last_poll_time = 0;
|
||||
if (Time::getRealTime() > last_poll_time+10.0)
|
||||
@ -315,13 +316,14 @@ void ServerLobbyRoomProtocol::update()
|
||||
}
|
||||
|
||||
// now
|
||||
for (int i = 0; i < m_incoming_peers_ids.size(); i++)
|
||||
for (unsigned int i = 0; i < m_incoming_peers_ids.size(); i++)
|
||||
{
|
||||
m_listener->requestStart(new ConnectToPeer(m_incoming_peers_ids[i]));
|
||||
}
|
||||
m_incoming_peers_ids.clear();
|
||||
|
||||
break;
|
||||
}
|
||||
case DONE:
|
||||
m_listener->requestTerminate(this);
|
||||
break;
|
||||
|
@ -18,11 +18,17 @@
|
||||
|
||||
#include "network/stk_host.hpp"
|
||||
|
||||
#include "graphics/irr_driver.hpp" // get access to irrlicht sleep function
|
||||
#include "network/network_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <arpa/inet.h>
|
||||
#ifdef WIN32
|
||||
# include "Ws2tcpip.h"
|
||||
# define inet_ntop InetNtop
|
||||
#else
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
|
||||
@ -133,7 +139,7 @@ void STKHost::sendRawPacket(uint8_t* data, int length, TransportAddress dst)
|
||||
to.sin_port = htons(dst.port);
|
||||
to.sin_addr.s_addr = htonl(dst.ip);
|
||||
|
||||
sendto(m_host->socket, data, length, 0,(sockaddr*)&to, to_len);
|
||||
sendto(m_host->socket, (char*)data, length, 0,(sockaddr*)&to, to_len);
|
||||
printf("Raw packet sent to %u:%u\n", dst.ip, dst.port);
|
||||
}
|
||||
|
||||
@ -145,14 +151,14 @@ uint8_t* STKHost::receiveRawPacket()
|
||||
buffer = (uint8_t*)(malloc(sizeof(uint8_t)*2048));
|
||||
memset(buffer, 0, 2048);
|
||||
|
||||
int len = recv(m_host->socket,buffer,2048, 0);
|
||||
int len = recv(m_host->socket,(char*)buffer,2048, 0);
|
||||
int i = 0;
|
||||
// wait to receive the message because enet sockets are non-blocking
|
||||
while(len < 0)
|
||||
{
|
||||
i++;
|
||||
len = recv(m_host->socket,buffer,2048, 0);
|
||||
usleep(1000);
|
||||
len = recv(m_host->socket,(char*)buffer,2048, 0);
|
||||
irr_driver->getDevice()->sleep(1);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
@ -169,7 +175,7 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender)
|
||||
struct sockaddr addr;
|
||||
|
||||
from_len = sizeof(addr);
|
||||
int len = recvfrom(m_host->socket, buffer, 2048, 0, &addr, &from_len);
|
||||
int len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, &addr, &from_len);
|
||||
|
||||
int i = 0;
|
||||
// wait to receive the message because enet sockets are non-blocking
|
||||
@ -180,8 +186,8 @@ uint8_t* STKHost::receiveRawPacket(TransportAddress sender)
|
||||
&& (uint8_t)(addr.sa_data[5]) != (sender.ip&0xff)))
|
||||
{
|
||||
i++;
|
||||
len = recvfrom(m_host->socket, buffer, 2048, 0, &addr, &from_len);
|
||||
usleep(1000); // wait 1 millisecond between two checks
|
||||
len = recvfrom(m_host->socket, (char*)buffer, 2048, 0, &addr, &from_len);
|
||||
irr_driver->getDevice()->sleep(1); // wait 1 millisecond between two checks
|
||||
}
|
||||
if (addr.sa_family == AF_INET)
|
||||
{
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <enet/enet.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/*! \class STKHost
|
||||
* \brief Represents the local host.
|
||||
* This host is either a server host or a client host. A client host is in
|
||||
|
@ -22,8 +22,9 @@
|
||||
#ifndef TYPES_HPP
|
||||
#define TYPES_HPP
|
||||
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
/*! \class CallbackObject
|
||||
* \brief Class that must be inherited to pass objects to protocols.
|
||||
|
@ -19,12 +19,13 @@
|
||||
|
||||
#include "online/current_online_user.hpp"
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
#include "online/http_connector.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "online/http_connector.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
static CurrentOnlineUser* user_singleton = NULL;
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
#define HEADER_CURRENT_ONLINE_USER_HPP
|
||||
|
||||
#include "online/online_user.hpp"
|
||||
#include <string>
|
||||
|
||||
#include <irrString.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
// ============================================================================
|
||||
|
||||
|
@ -19,12 +19,16 @@
|
||||
#ifndef HTTP_CONNECTOR_HPP
|
||||
#define HTTP_CONNECTOR_HPP
|
||||
|
||||
#include <string>
|
||||
#include "io/xml_node.hpp"
|
||||
#include <curl/curl.h>
|
||||
#include <irrString.h>
|
||||
#include "utils/string_utils.hpp"
|
||||
|
||||
#include <irrString.h>
|
||||
#ifdef WIN32
|
||||
# include <WinSock2.h>
|
||||
#endif
|
||||
#include <curl/curl.h>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* \brief Class to connect with a server over HTTP
|
||||
* \ingroup online
|
||||
|
@ -20,6 +20,8 @@
|
||||
#define HEADER_TYPES_HPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
|
Loading…
x
Reference in New Issue
Block a user