Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 685718 | Differences between
and this patch

Collapse All | Expand All

(-)a/network/ClientNetworking.cpp (-19 / +19 lines)
Lines 42-51 namespace { Link Here
42
    public:
42
    public:
43
        using ServerList = std::vector<std::pair<boost::asio::ip::address, std::string>>;
43
        using ServerList = std::vector<std::pair<boost::asio::ip::address, std::string>>;
44
44
45
        ServerDiscoverer(boost::asio::io_service& io_service) :
45
        ServerDiscoverer(boost::asio::io_context& io_context) :
46
            m_io_service(&io_service),
46
            m_io_context(&io_context),
47
            m_timer(io_service),
47
            m_timer(io_context),
48
            m_socket(io_service),
48
            m_socket(io_context),
49
            m_recv_buf(),
49
            m_recv_buf(),
50
            m_receive_successful(false),
50
            m_receive_successful(false),
51
            m_server_name()
51
            m_server_name()
Lines 56-62 namespace { Link Here
56
56
57
        void DiscoverServers() {
57
        void DiscoverServers() {
58
            using namespace boost::asio::ip;
58
            using namespace boost::asio::ip;
59
            udp::resolver resolver(*m_io_service);
59
            udp::resolver resolver(*m_io_context);
60
            udp::resolver::query query(udp::v4(), "255.255.255.255",
60
            udp::resolver::query query(udp::v4(), "255.255.255.255",
61
                                       std::to_string(Networking::DiscoveryPort()),
61
                                       std::to_string(Networking::DiscoveryPort()),
62
                                       resolver_query_base::address_configured |
62
                                       resolver_query_base::address_configured |
Lines 81-88 namespace { Link Here
81
                                boost::asio::placeholders::bytes_transferred));
81
                                boost::asio::placeholders::bytes_transferred));
82
                m_timer.expires_from_now(std::chrono::seconds(2));
82
                m_timer.expires_from_now(std::chrono::seconds(2));
83
                m_timer.async_wait(boost::bind(&ServerDiscoverer::CloseSocket, this));
83
                m_timer.async_wait(boost::bind(&ServerDiscoverer::CloseSocket, this));
84
                m_io_service->run();
84
                m_io_context->run();
85
                m_io_service->reset();
85
                m_io_context->reset();
86
                if (m_receive_successful) {
86
                if (m_receive_successful) {
87
                    boost::asio::ip::address address = m_server_name == "localhost" ?
87
                    boost::asio::ip::address address = m_server_name == "localhost" ?
88
                        boost::asio::ip::address::from_string("127.0.0.1") :
88
                        boost::asio::ip::address::from_string("127.0.0.1") :
Lines 121-127 namespace { Link Here
121
        void CloseSocket()
121
        void CloseSocket()
122
        { m_socket.close(); }
122
        { m_socket.close(); }
123
123
124
        boost::asio::io_service*       m_io_service;
124
        boost::asio::io_context*       m_io_context;
125
        boost::asio::high_resolution_timer m_timer;
125
        boost::asio::high_resolution_timer m_timer;
126
        boost::asio::ip::udp::socket   m_socket;
126
        boost::asio::ip::udp::socket   m_socket;
127
127
Lines 233-239 class ClientNetworking::Impl { Link Here
233
    int                             m_host_player_id;
233
    int                             m_host_player_id;
234
    Networking::AuthRoles           m_roles;
234
    Networking::AuthRoles           m_roles;
235
235
236
    boost::asio::io_service         m_io_service;
236
    boost::asio::io_context         m_io_context;
237
    boost::asio::ip::tcp::socket    m_socket;
237
    boost::asio::ip::tcp::socket    m_socket;
238
238
239
    // m_mutex guards m_incoming_message, m_rx_connected and m_tx_connected which are written by
239
    // m_mutex guards m_incoming_message, m_rx_connected and m_tx_connected which are written by
Lines 262-269 class ClientNetworking::Impl { Link Here
262
ClientNetworking::Impl::Impl() :
262
ClientNetworking::Impl::Impl() :
263
    m_player_id(Networking::INVALID_PLAYER_ID),
263
    m_player_id(Networking::INVALID_PLAYER_ID),
264
    m_host_player_id(Networking::INVALID_PLAYER_ID),
264
    m_host_player_id(Networking::INVALID_PLAYER_ID),
265
    m_io_service(),
265
    m_io_context(),
266
    m_socket(m_io_service),
266
    m_socket(m_io_context),
267
    m_rx_connected(false),
267
    m_rx_connected(false),
268
    m_tx_connected(false),
268
    m_tx_connected(false),
269
    m_incoming_messages(m_mutex)
269
    m_incoming_messages(m_mutex)
Lines 302-308 bool ClientNetworking::Impl::HasAuthRole(Networking::RoleType role) const Link Here
302
ClientNetworking::ServerNames ClientNetworking::Impl::DiscoverLANServerNames() {
302
ClientNetworking::ServerNames ClientNetworking::Impl::DiscoverLANServerNames() {
303
    if (!IsConnected())
303
    if (!IsConnected())
304
        return ServerNames();
304
        return ServerNames();
305
    ServerDiscoverer discoverer(m_io_service);
305
    ServerDiscoverer discoverer(m_io_context);
306
    discoverer.DiscoverServers();
306
    discoverer.DiscoverServers();
307
    ServerNames names;
307
    ServerNames names;
308
    for (const auto& server : discoverer.Servers()) {
308
    for (const auto& server : discoverer.Servers()) {
Lines 325-331 bool ClientNetworking::Impl::ConnectToServer( Link Here
325
    auto deadline = start_time + timeout;
325
    auto deadline = start_time + timeout;
326
326
327
    using namespace boost::asio::ip;
327
    using namespace boost::asio::ip;
328
    tcp::resolver resolver(m_io_service);
328
    tcp::resolver resolver(m_io_context);
329
    tcp::resolver::query query(ip_address,
329
    tcp::resolver::query query(ip_address,
330
                               std::to_string(Networking::MessagePort()),
330
                               std::to_string(Networking::MessagePort()),
331
                               boost::asio::ip::resolver_query_base::numeric_service);
331
                               boost::asio::ip::resolver_query_base::numeric_service);
Lines 347-354 bool ClientNetworking::Impl::ConnectToServer( Link Here
347
                m_socket.async_connect(*it, boost::bind(&ClientNetworking::Impl::HandleConnection, this,
347
                m_socket.async_connect(*it, boost::bind(&ClientNetworking::Impl::HandleConnection, this,
348
                                                        &it,
348
                                                        &it,
349
                                                        boost::asio::placeholders::error));
349
                                                        boost::asio::placeholders::error));
350
                m_io_service.run();
350
                m_io_context.run();
351
                m_io_service.reset();
351
                m_io_context.reset();
352
352
353
                auto connection_time = Clock::now() - start_time;
353
                auto connection_time = Clock::now() - start_time;
354
354
Lines 435-441 void ClientNetworking::Impl::DisconnectFromServer() { Link Here
435
    }
435
    }
436
436
437
    if (is_open)
437
    if (is_open)
438
        m_io_service.post(boost::bind(&ClientNetworking::Impl::DisconnectFromServerImpl, this));
438
        m_io_context.post(boost::bind(&ClientNetworking::Impl::DisconnectFromServerImpl, this));
439
}
439
}
440
440
441
void ClientNetworking::Impl::SetPlayerID(int player_id) {
441
void ClientNetworking::Impl::SetPlayerID(int player_id) {
Lines 455-461 void ClientNetworking::Impl::SendMessage(const Message& message) { Link Here
455
        return;
455
        return;
456
    }
456
    }
457
    TraceLogger(network) << "ClientNetworking::SendMessage() : sending message " << message;
457
    TraceLogger(network) << "ClientNetworking::SendMessage() : sending message " << message;
458
    m_io_service.post(boost::bind(&ClientNetworking::Impl::SendMessageImpl, this, message));
458
    m_io_context.post(boost::bind(&ClientNetworking::Impl::SendMessageImpl, this, message));
459
}
459
}
460
460
461
boost::optional<Message> ClientNetworking::Impl::GetMessage() {
461
boost::optional<Message> ClientNetworking::Impl::GetMessage() {
Lines 504-515 void ClientNetworking::Impl::NetworkingThread(const std::shared_ptr<const Client Link Here
504
        if (!m_outgoing_messages.empty())
504
        if (!m_outgoing_messages.empty())
505
            AsyncWriteMessage();
505
            AsyncWriteMessage();
506
        AsyncReadMessage(protect_from_destruction_in_other_thread);
506
        AsyncReadMessage(protect_from_destruction_in_other_thread);
507
        m_io_service.run();
507
        m_io_context.run();
508
    } catch (const boost::system::system_error& error) {
508
    } catch (const boost::system::system_error& error) {
509
        HandleException(error);
509
        HandleException(error);
510
    }
510
    }
511
    m_outgoing_messages.clear();
511
    m_outgoing_messages.clear();
512
    m_io_service.reset();
512
    m_io_context.reset();
513
    { // Mutex scope
513
    { // Mutex scope
514
        boost::mutex::scoped_lock lock(m_mutex);
514
        boost::mutex::scoped_lock lock(m_mutex);
515
        m_rx_connected = false;
515
        m_rx_connected = false;
(-)a/network/ServerNetworking.cpp (-12 / +12 lines)
Lines 23-29 namespace { Link Here
23
    on the local network and sends out responses to them. */
23
    on the local network and sends out responses to them. */
24
class DiscoveryServer {
24
class DiscoveryServer {
25
public:
25
public:
26
    DiscoveryServer(boost::asio::io_service& io_service);
26
    DiscoveryServer(boost::asio::io_context& io_context);
27
27
28
private:
28
private:
29
    void Listen();
29
    void Listen();
Lines 52-63 namespace { Link Here
52
////////////////////////////////////////////////////////////////////////////////
52
////////////////////////////////////////////////////////////////////////////////
53
// PlayerConnection
53
// PlayerConnection
54
////////////////////////////////////////////////////////////////////////////////
54
////////////////////////////////////////////////////////////////////////////////
55
PlayerConnection::PlayerConnection(boost::asio::io_service& io_service,
55
PlayerConnection::PlayerConnection(boost::asio::io_context& io_context,
56
                                   MessageAndConnectionFn nonplayer_message_callback,
56
                                   MessageAndConnectionFn nonplayer_message_callback,
57
                                   MessageAndConnectionFn player_message_callback,
57
                                   MessageAndConnectionFn player_message_callback,
58
                                   ConnectionFn disconnected_callback) :
58
                                   ConnectionFn disconnected_callback) :
59
    m_service(io_service),
59
    m_service(io_context),
60
    m_socket(io_service),
60
    m_socket(io_context),
61
    m_ID(INVALID_PLAYER_ID),
61
    m_ID(INVALID_PLAYER_ID),
62
    m_new_connection(true),
62
    m_new_connection(true),
63
    m_client_type(Networking::INVALID_CLIENT_TYPE),
63
    m_client_type(Networking::INVALID_CLIENT_TYPE),
Lines 215-227 const std::string& PlayerConnection::ClientVersionString() const Link Here
215
bool PlayerConnection::ClientVersionStringMatchesThisServer() const
215
bool PlayerConnection::ClientVersionStringMatchesThisServer() const
216
{ return !m_client_version_string.empty() && m_client_version_string == FreeOrionVersionString(); }
216
{ return !m_client_version_string.empty() && m_client_version_string == FreeOrionVersionString(); }
217
217
218
PlayerConnectionPtr PlayerConnection::NewConnection(boost::asio::io_service& io_service,
218
PlayerConnectionPtr PlayerConnection::NewConnection(boost::asio::io_context& io_context,
219
                                                    MessageAndConnectionFn nonplayer_message_callback,
219
                                                    MessageAndConnectionFn nonplayer_message_callback,
220
                                                    MessageAndConnectionFn player_message_callback,
220
                                                    MessageAndConnectionFn player_message_callback,
221
                                                    ConnectionFn disconnected_callback)
221
                                                    ConnectionFn disconnected_callback)
222
{
222
{
223
    return PlayerConnectionPtr(
223
    return PlayerConnectionPtr(
224
        new PlayerConnection(io_service, nonplayer_message_callback, player_message_callback,
224
        new PlayerConnection(io_context, nonplayer_message_callback, player_message_callback,
225
                             disconnected_callback));
225
                             disconnected_callback));
226
}
226
}
227
227
Lines 393-400 void PlayerConnection::AsyncErrorHandler(boost::system::error_code handled_error Link Here
393
////////////////////////////////////////////////////////////////////////////////
393
////////////////////////////////////////////////////////////////////////////////
394
// DiscoveryServer
394
// DiscoveryServer
395
////////////////////////////////////////////////////////////////////////////////
395
////////////////////////////////////////////////////////////////////////////////
396
DiscoveryServer::DiscoveryServer(boost::asio::io_service& io_service) :
396
DiscoveryServer::DiscoveryServer(boost::asio::io_context& io_context) :
397
    m_socket(io_service, udp::endpoint(udp::v4(), Networking::DiscoveryPort()))
397
    m_socket(io_context, udp::endpoint(udp::v4(), Networking::DiscoveryPort()))
398
{ Listen(); }
398
{ Listen(); }
399
399
400
void DiscoveryServer::Listen() {
400
void DiscoveryServer::Listen() {
Lines 421-440 bool ServerNetworking::EstablishedPlayer::operator()( Link Here
421
    const PlayerConnectionPtr& player_connection) const
421
    const PlayerConnectionPtr& player_connection) const
422
{ return player_connection->EstablishedPlayer(); }
422
{ return player_connection->EstablishedPlayer(); }
423
423
424
ServerNetworking::ServerNetworking(boost::asio::io_service& io_service,
424
ServerNetworking::ServerNetworking(boost::asio::io_context& io_context,
425
                                   MessageAndConnectionFn nonplayer_message_callback,
425
                                   MessageAndConnectionFn nonplayer_message_callback,
426
                                   MessageAndConnectionFn player_message_callback,
426
                                   MessageAndConnectionFn player_message_callback,
427
                                   ConnectionFn disconnected_callback) :
427
                                   ConnectionFn disconnected_callback) :
428
    m_host_player_id(Networking::INVALID_PLAYER_ID),
428
    m_host_player_id(Networking::INVALID_PLAYER_ID),
429
    m_discovery_server(nullptr),
429
    m_discovery_server(nullptr),
430
    m_player_connection_acceptor(io_service),
430
    m_player_connection_acceptor(io_context),
431
    m_nonplayer_message_callback(nonplayer_message_callback),
431
    m_nonplayer_message_callback(nonplayer_message_callback),
432
    m_player_message_callback(player_message_callback),
432
    m_player_message_callback(player_message_callback),
433
    m_disconnected_callback(disconnected_callback)
433
    m_disconnected_callback(disconnected_callback)
434
{
434
{
435
    if (!GetOptionsDB().Get<bool>("singleplayer")) {
435
    if (!GetOptionsDB().Get<bool>("singleplayer")) {
436
        // only start discovery service for multiplayer servers.
436
        // only start discovery service for multiplayer servers.
437
        m_discovery_server = new DiscoveryServer(io_service);
437
        m_discovery_server = new DiscoveryServer(io_context);
438
    }
438
    }
439
439
440
    Init();
440
    Init();
Lines 673-679 void ServerNetworking::Init() { Link Here
673
void ServerNetworking::AcceptNextConnection() {
673
void ServerNetworking::AcceptNextConnection() {
674
    PlayerConnectionPtr next_connection =
674
    PlayerConnectionPtr next_connection =
675
        PlayerConnection::NewConnection(
675
        PlayerConnection::NewConnection(
676
            m_player_connection_acceptor.get_io_service(),
676
            m_player_connection_acceptor.get_executor().context(),
677
            m_nonplayer_message_callback,
677
            m_nonplayer_message_callback,
678
            m_player_message_callback,
678
            m_player_message_callback,
679
            boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
679
            boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
(-)a/network/ServerNetworking.h (-4 / +4 lines)
Lines 58-64 class ServerNetworking { Link Here
58
    typedef boost::filter_iterator<EstablishedPlayer, PlayerConnections::const_iterator>    const_established_iterator;
58
    typedef boost::filter_iterator<EstablishedPlayer, PlayerConnections::const_iterator>    const_established_iterator;
59
59
60
    /** \name Structors */ //@{
60
    /** \name Structors */ //@{
61
    ServerNetworking(boost::asio::io_service& io_service,
61
    ServerNetworking(boost::asio::io_context& io_context,
62
                     MessageAndConnectionFn nonplayer_message_callback,
62
                     MessageAndConnectionFn nonplayer_message_callback,
63
                     MessageAndConnectionFn player_message_callback,
63
                     MessageAndConnectionFn player_message_callback,
64
                     ConnectionFn disconnected_callback);
64
                     ConnectionFn disconnected_callback);
Lines 286-297 class PlayerConnection : Link Here
286
286
287
    /** Creates a new PlayerConnection and returns it as a shared_ptr. */
287
    /** Creates a new PlayerConnection and returns it as a shared_ptr. */
288
    static PlayerConnectionPtr
288
    static PlayerConnectionPtr
289
    NewConnection(boost::asio::io_service& io_service, MessageAndConnectionFn nonplayer_message_callback,
289
    NewConnection(boost::asio::io_context& io_context, MessageAndConnectionFn nonplayer_message_callback,
290
                  MessageAndConnectionFn player_message_callback, ConnectionFn disconnected_callback);
290
                  MessageAndConnectionFn player_message_callback, ConnectionFn disconnected_callback);
291
291
292
private:
292
private:
293
293
294
    PlayerConnection(boost::asio::io_service& io_service, MessageAndConnectionFn nonplayer_message_callback,
294
    PlayerConnection(boost::asio::io_context& io_context, MessageAndConnectionFn nonplayer_message_callback,
295
                     MessageAndConnectionFn player_message_callback, ConnectionFn disconnected_callback);
295
                     MessageAndConnectionFn player_message_callback, ConnectionFn disconnected_callback);
296
    void HandleMessageBodyRead(boost::system::error_code error, std::size_t bytes_transferred);
296
    void HandleMessageBodyRead(boost::system::error_code error, std::size_t bytes_transferred);
297
    void HandleMessageHeaderRead(boost::system::error_code error, std::size_t bytes_transferred);
297
    void HandleMessageHeaderRead(boost::system::error_code error, std::size_t bytes_transferred);
Lines 299-305 class PlayerConnection : Link Here
299
    bool SyncWriteMessage(const Message& message);
299
    bool SyncWriteMessage(const Message& message);
300
    void AsyncErrorHandler(boost::system::error_code handled_error, boost::system::error_code error);
300
    void AsyncErrorHandler(boost::system::error_code handled_error, boost::system::error_code error);
301
301
302
    boost::asio::io_service&        m_service;
302
    boost::asio::io_context&        m_service;
303
    boost::asio::ip::tcp::socket    m_socket;
303
    boost::asio::ip::tcp::socket    m_socket;
304
    Message::HeaderBuffer           m_incoming_header_buffer;
304
    Message::HeaderBuffer           m_incoming_header_buffer;
305
    Message                         m_incoming_message;
305
    Message                         m_incoming_message;
(-)a/server/ServerApp.cpp (-3 / +3 lines)
Lines 124-131 ServerSaveGameData::ServerSaveGameData(int current_turn) : Link Here
124
////////////////////////////////////////////////
124
////////////////////////////////////////////////
125
ServerApp::ServerApp() :
125
ServerApp::ServerApp() :
126
    IApp(),
126
    IApp(),
127
    m_signals(m_io_service, SIGINT, SIGTERM),
127
    m_signals(m_io_context, SIGINT, SIGTERM),
128
    m_networking(m_io_service,
128
    m_networking(m_io_context,
129
                 boost::bind(&ServerApp::HandleNonPlayerMessage, this, _1, _2),
129
                 boost::bind(&ServerApp::HandleNonPlayerMessage, this, _1, _2),
130
                 boost::bind(&ServerApp::HandleMessage, this, _1, _2),
130
                 boost::bind(&ServerApp::HandleMessage, this, _1, _2),
131
                 boost::bind(&ServerApp::PlayerDisconnected, this, _1)),
131
                 boost::bind(&ServerApp::PlayerDisconnected, this, _1)),
Lines 336-342 void ServerApp::Run() { Link Here
336
    DebugLogger() << "FreeOrion server waiting for network events";
336
    DebugLogger() << "FreeOrion server waiting for network events";
337
    try {
337
    try {
338
        while (1) {
338
        while (1) {
339
            if (m_io_service.run_one())
339
            if (m_io_context.run_one())
340
                m_networking.HandleNextEvent();
340
                m_networking.HandleNextEvent();
341
            else
341
            else
342
                break;
342
                break;
(-)a/server/ServerApp.h (-1 / +1 lines)
Lines 333-339 class ServerApp : public IApp { Link Here
333
      * between two empires. Updates those empires of the change. */
333
      * between two empires. Updates those empires of the change. */
334
    void    HandleDiplomaticMessageChange(int empire1_id, int empire2_id);
334
    void    HandleDiplomaticMessageChange(int empire1_id, int empire2_id);
335
335
336
    boost::asio::io_service m_io_service;
336
    boost::asio::io_context m_io_context;
337
    boost::asio::signal_set m_signals;
337
    boost::asio::signal_set m_signals;
338
338
339
    Universe                m_universe;
339
    Universe                m_universe;
(-)a/server/ServerFSM.cpp (-2 / +1 lines)
Lines 2703-2709 const auto SHUTDOWN_POLLING_TIME = std::chrono::milliseconds(5000); Link Here
2703
ShuttingDownServer::ShuttingDownServer(my_context c) :
2703
ShuttingDownServer::ShuttingDownServer(my_context c) :
2704
    my_base(c),
2704
    my_base(c),
2705
    m_player_id_ack_expected(),
2705
    m_player_id_ack_expected(),
2706
    m_timeout(Server().m_io_service, Clock::now() + SHUTDOWN_POLLING_TIME)
2706
    m_timeout(Server().m_io_context, Clock::now() + SHUTDOWN_POLLING_TIME)
2707
{
2707
{
2708
    TraceLogger(FSM) << "(ServerFSM) ShuttingDownServer";
2708
    TraceLogger(FSM) << "(ServerFSM) ShuttingDownServer";
2709
2709
2710
--
2711
network/ServerNetworking.cpp | 11 +++++------
2710
network/ServerNetworking.cpp | 11 +++++------
2712
1 file changed, 5 insertions(+), 6 deletions(-)
2711
1 file changed, 5 insertions(+), 6 deletions(-)
(-)a/network/ServerNetworking.cpp (-7 / +5 lines)
Lines 671-682 void ServerNetworking::Init() { Link Here
671
}
671
}
672
672
673
void ServerNetworking::AcceptNextConnection() {
673
void ServerNetworking::AcceptNextConnection() {
674
    PlayerConnectionPtr next_connection =
674
    auto next_connection = PlayerConnection::NewConnection(
675
        PlayerConnection::NewConnection(
675
        m_player_connection_acceptor.get_executor().context(),
676
            m_player_connection_acceptor.get_executor().context(),
676
        m_nonplayer_message_callback,
677
            m_nonplayer_message_callback,
677
        m_player_message_callback,
678
            m_player_message_callback,
678
        boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
679
            boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
680
    next_connection->EventSignal.connect(
679
    next_connection->EventSignal.connect(
681
        boost::bind(&ServerNetworking::EnqueueEvent, this, _1));
680
        boost::bind(&ServerNetworking::EnqueueEvent, this, _1));
682
    m_player_connection_acceptor.async_accept(
681
    m_player_connection_acceptor.async_accept(
683
--
684
network/ServerNetworking.h | 5 +++++
682
network/ServerNetworking.h | 5 +++++
685
1 file changed, 5 insertions(+)
683
1 file changed, 5 insertions(+)
(-)a/network/ServerNetworking.h (-1 / +5 lines)
Lines 181-187 class ServerNetworking { Link Here
181
    int                             m_host_player_id;
181
    int                             m_host_player_id;
182
182
183
    DiscoveryServer*                m_discovery_server;
183
    DiscoveryServer*                m_discovery_server;
184
#if BOOST_VERSION >= 107000
185
    boost::asio::basic_socket_acceptor<boost::asio::ip::tcp, boost::asio::io_context::executor_type>
186
                                    m_player_connection_acceptor;
187
#else
184
    boost::asio::ip::tcp::acceptor  m_player_connection_acceptor;
188
    boost::asio::ip::tcp::acceptor  m_player_connection_acceptor;
189
#endif
185
    PlayerConnections               m_player_connections;
190
    PlayerConnections               m_player_connections;
186
    std::queue<NullaryFn>           m_event_queue;
191
    std::queue<NullaryFn>           m_event_queue;
187
    std::unordered_map<boost::uuids::uuid, CookieData, boost::hash<boost::uuids::uuid>> m_cookies;
192
    std::unordered_map<boost::uuids::uuid, CookieData, boost::hash<boost::uuids::uuid>> m_cookies;
188
compatibility with Boost versions before 1.66.
193
compatibility with Boost versions before 1.66.
189
--
190
network/ServerNetworking.h | 25 ++++++++++++++++++-------
194
network/ServerNetworking.h | 25 ++++++++++++++++++-------
191
1 file changed, 18 insertions(+), 7 deletions(-)
195
1 file changed, 18 insertions(+), 7 deletions(-)
(-)a/network/ServerNetworking.h (-8 / +18 lines)
Lines 22-34 typedef boost::function<void (Message, PlayerConnectionPtr)> MessageAndConnectio Link Here
22
typedef boost::function<void (PlayerConnectionPtr)> ConnectionFn;
22
typedef boost::function<void (PlayerConnectionPtr)> ConnectionFn;
23
typedef boost::function<void ()> NullaryFn;
23
typedef boost::function<void ()> NullaryFn;
24
24
25
/** Data associated with cookie
25
/** Data associated with cookie */
26
 */
27
struct CookieData {
26
struct CookieData {
28
    std::string player_name;
27
    std::string                 player_name;
29
    boost::posix_time::ptime expired;
28
    boost::posix_time::ptime    expired;
30
    Networking::AuthRoles roles;
29
    Networking::AuthRoles       roles;
31
    bool authenticated;
30
    bool                        authenticated;
32
31
33
    CookieData(const std::string& player_name_,
32
    CookieData(const std::string& player_name_,
34
               const boost::posix_time::ptime& expired_,
33
               const boost::posix_time::ptime& expired_,
Lines 38-46 struct CookieData { Link Here
38
        expired(expired_),
37
        expired(expired_),
39
        roles(roles_),
38
        roles(roles_),
40
        authenticated(authenticated_)
39
        authenticated(authenticated_)
41
    { }
40
    {}
42
};
41
};
43
42
43
44
/** In Boost 1.66, io_service was replaced with a typedef of io_context.
45
  * That typedef was removed in Boost 1.70 along with other interface changes.
46
  * This code uses io_context for future compatibility and adds the typedef
47
  * here for old versions of Boost. */
48
#if BOOST_VERSION < 106600
49
namespace boost { namespace asio {
50
    typedef io_service io_context;
51
}}
52
#endif
53
54
44
/** Encapsulates the networking facilities of the server.  This class listens
55
/** Encapsulates the networking facilities of the server.  This class listens
45
    for incoming UDP LAN server-discovery requests and TCP player connections.
56
    for incoming UDP LAN server-discovery requests and TCP player connections.
46
    The server also sends and receives messages over the TCP player
57
    The server also sends and receives messages over the TCP player
47
https://github.com/boostorg/gil/commit/2308a1a85a7b#diff-9b9e3d16308e811b90e08ebb658fca86R28
58
https://github.com/boostorg/gil/commit/2308a1a85a7b#diff-9b9e3d16308e811b90e08ebb658fca86R28
48
--
49
GG/src/Texture.cpp | 4 ++--
59
GG/src/Texture.cpp | 4 ++--
50
1 file changed, 2 insertions(+), 2 deletions(-)
60
1 file changed, 2 insertions(+), 2 deletions(-)
(-)a/GG/src/Texture.cpp (-3 / +2 lines)
Lines 262-275 void Texture::Load(const boost::filesystem::path& path, bool mipmap/* = false*/) Link Here
262
        if (extension == ".png") {
262
        if (extension == ".png") {
263
            gil::rgba8_image_t rgba_image;
263
            gil::rgba8_image_t rgba_image;
264
            gil::read_and_convert_image(filename, rgba_image, gil::image_read_settings<gil::png_tag>());
264
            gil::read_and_convert_image(filename, rgba_image, gil::image_read_settings<gil::png_tag>());
265
            image.move_in(rgba_image);
265
            image = std::move(rgba_image);
266
        }
266
        }
267
#endif
267
#endif
268
#if GG_HAVE_LIBTIFF
268
#if GG_HAVE_LIBTIFF
269
        if (extension == ".tif" || extension == ".tiff") {
269
        if (extension == ".tif" || extension == ".tiff") {
270
            gil::rgba8_image_t rgba_image;
270
            gil::rgba8_image_t rgba_image;
271
            gil::read_and_convert_image(filename, rgba_image, gil::image_read_settings<gil::tiff_tag>());
271
            gil::read_and_convert_image(filename, rgba_image, gil::image_read_settings<gil::tiff_tag>());
272
            image.move_in(rgba_image);
272
            image = std::move(rgba_image);
273
        }
273
        }
274
#endif
274
#endif
275
    }
275
    }
276
--
277
network/ServerNetworking.cpp | 4 ++++
276
network/ServerNetworking.cpp | 4 ++++
278
1 file changed, 4 insertions(+)
277
1 file changed, 4 insertions(+)
(-)a/network/ServerNetworking.cpp (-1 / +4 lines)
Lines 672-678 void ServerNetworking::Init() { Link Here
672
672
673
void ServerNetworking::AcceptNextConnection() {
673
void ServerNetworking::AcceptNextConnection() {
674
    auto next_connection = PlayerConnection::NewConnection(
674
    auto next_connection = PlayerConnection::NewConnection(
675
#if BOOST_VERSION >= 106600
675
        m_player_connection_acceptor.get_executor().context(),
676
        m_player_connection_acceptor.get_executor().context(),
677
#else
678
        m_player_connection_acceptor.get_io_service(),
679
#endif
676
        m_nonplayer_message_callback,
680
        m_nonplayer_message_callback,
677
        m_player_message_callback,
681
        m_player_message_callback,
678
        boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
682
        boost::bind(&ServerNetworking::DisconnectImpl, this, _1));
679
functions with Boost::Variant equivalents.
683
functions with Boost::Variant equivalents.
680
--
681
GG/src/Texture.cpp | 13 +++++++++++++
684
GG/src/Texture.cpp | 13 +++++++++++++
682
1 file changed, 13 insertions(+)
685
1 file changed, 13 insertions(+)
(-)a/GG/src/Texture.cpp (-1 / +13 lines)
Lines 48-53 Link Here
48
#include <iomanip>
48
#include <iomanip>
49
#include <boost/scoped_array.hpp>
49
#include <boost/scoped_array.hpp>
50
50
51
#if BOOST_VERSION >= 107000
52
#include <boost/variant/get.hpp>
53
#endif
54
51
55
52
using namespace GG;
56
using namespace GG;
53
57
Lines 279-290 void Texture::Load(const boost::filesystem::path& path, bool mipmap/* = false*/) Link Here
279
    m_default_height = Y(image.height());
283
    m_default_height = Y(image.height());
280
    m_type = GL_UNSIGNED_BYTE;
284
    m_type = GL_UNSIGNED_BYTE;
281
285
286
#if BOOST_VERSION >= 107000
287
#define IF_IMAGE_TYPE_IS(image_prefix)                                  \
288
    if (boost::get<image_prefix ## _image_t>(image)) {                  \
289
        m_bytes_pp = sizeof(image_prefix ## _pixel_t);                  \
290
        image_data = interleaved_view_get_raw_data(                     \
291
            const_view(boost::get<image_prefix ## _image_t>(image)));   \
292
    }
293
#else
282
#define IF_IMAGE_TYPE_IS(image_prefix)                                  \
294
#define IF_IMAGE_TYPE_IS(image_prefix)                                  \
283
    if (image.current_type_is<image_prefix ## _image_t>()) {            \
295
    if (image.current_type_is<image_prefix ## _image_t>()) {            \
284
        m_bytes_pp = sizeof(image_prefix ## _pixel_t);                  \
296
        m_bytes_pp = sizeof(image_prefix ## _pixel_t);                  \
285
        image_data = interleaved_view_get_raw_data(                     \
297
        image_data = interleaved_view_get_raw_data(                     \
286
            const_view(image._dynamic_cast<image_prefix ## _image_t>())); \
298
            const_view(image._dynamic_cast<image_prefix ## _image_t>())); \
287
    }
299
    }
300
#endif
288
301
289
    const unsigned char* image_data = nullptr;
302
    const unsigned char* image_data = nullptr;
290
303
291
--
292
network/ClientNetworking.cpp | 26 ++++++++++++++++++--------
304
network/ClientNetworking.cpp | 26 ++++++++++++++++++--------
293
1 file changed, 18 insertions(+), 8 deletions(-)
305
1 file changed, 18 insertions(+), 8 deletions(-)
(-)a/network/ClientNetworking.cpp (-9 / +18 lines)
Lines 33-38 Link Here
33
using boost::asio::ip::tcp;
33
using boost::asio::ip::tcp;
34
using namespace Networking;
34
using namespace Networking;
35
35
36
/** In Boost 1.66, io_service was replaced with a typedef of io_context.
37
  * That typedef was removed in Boost 1.70 along with other interface changes.
38
  * This code uses io_context for future compatibility and adds the typedef
39
  * here for old versions of Boost. */
40
#if BOOST_VERSION < 106600
41
namespace boost { namespace asio {
42
    typedef io_service io_context;
43
}}
44
#endif
45
36
namespace {
46
namespace {
37
    DeclareThreadSafeLogger(network);
47
    DeclareThreadSafeLogger(network);
38
48
Lines 121-136 namespace { Link Here
121
        void CloseSocket()
131
        void CloseSocket()
122
        { m_socket.close(); }
132
        { m_socket.close(); }
123
133
124
        boost::asio::io_context*       m_io_context;
134
        boost::asio::io_context*            m_io_context;
125
        boost::asio::high_resolution_timer m_timer;
135
        boost::asio::high_resolution_timer  m_timer;
126
        boost::asio::ip::udp::socket   m_socket;
136
        boost::asio::ip::udp::socket        m_socket;
127
137
128
        std::array<char, 1024> m_recv_buf;
138
        std::array<char, 1024>              m_recv_buf;
129
139
130
        boost::asio::ip::udp::endpoint m_sender_endpoint;
140
        boost::asio::ip::udp::endpoint      m_sender_endpoint;
131
        bool                           m_receive_successful;
141
        bool                                m_receive_successful;
132
        std::string                    m_server_name;
142
        std::string                         m_server_name;
133
        ServerList                     m_servers;
143
        ServerList                          m_servers;
134
    };
144
    };
135
}
145
}
136
146
137
BOOST_VERSION.
147
BOOST_VERSION.
138
--
139
network/ClientNetworking.cpp | 4 ++++
148
network/ClientNetworking.cpp | 4 ++++
140
1 file changed, 4 insertions(+)
149
1 file changed, 4 insertions(+)
(-)a/network/ClientNetworking.cpp (-1 / +4 lines)
Lines 89-95 namespace { Link Here
89
                                this,
89
                                this,
90
                                boost::asio::placeholders::error,
90
                                boost::asio::placeholders::error,
91
                                boost::asio::placeholders::bytes_transferred));
91
                                boost::asio::placeholders::bytes_transferred));
92
#if BOOST_VERSION >= 106600
93
                m_timer.expires_after(std::chrono::seconds(2));
94
#else
92
                m_timer.expires_from_now(std::chrono::seconds(2));
95
                m_timer.expires_from_now(std::chrono::seconds(2));
96
#endif
93
                m_timer.async_wait(boost::bind(&ServerDiscoverer::CloseSocket, this));
97
                m_timer.async_wait(boost::bind(&ServerDiscoverer::CloseSocket, this));
94
                m_io_context->run();
98
                m_io_context->run();
95
                m_io_context->reset();
99
                m_io_context->reset();
96
its type.
100
its type.
97
--
98
GG/src/Texture.cpp | 2 +-
101
GG/src/Texture.cpp | 2 +-
99
1 file changed, 1 insertion(+), 1 deletion(-)
102
1 file changed, 1 insertion(+), 1 deletion(-)
(-)a/GG/src/Texture.cpp (-1 / +1 lines)
Lines 285-291 void Texture::Load(const boost::filesystem::path& path, bool mipmap/* = false*/) Link Here
285
285
286
#if BOOST_VERSION >= 107000
286
#if BOOST_VERSION >= 107000
287
#define IF_IMAGE_TYPE_IS(image_prefix)                                  \
287
#define IF_IMAGE_TYPE_IS(image_prefix)                                  \
288
    if (boost::get<image_prefix ## _image_t>(image)) {                  \
288
    if (boost::get<image_prefix ## _image_t>(&image)) {                 \
289
        m_bytes_pp = sizeof(image_prefix ## _pixel_t);                  \
289
        m_bytes_pp = sizeof(image_prefix ## _pixel_t);                  \
290
        image_data = interleaved_view_get_raw_data(                     \
290
        image_data = interleaved_view_get_raw_data(                     \
291
            const_view(boost::get<image_prefix ## _image_t>(image)));   \
291
            const_view(boost::get<image_prefix ## _image_t>(image)));   \

Return to bug 685718