• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

[C++/Linux] Compiling old engine (sources) on Debian 10 / Ubuntu 20.04

C++:
game.cpp: W konstruktorze 'Game::Game()':
game.cpp: In constructor 'Game::Game()':
game.cpp:80:24: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
   globalSaveMessage[i] = false;
   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
game.cpp:79:23: note: within this loop
  for(int64_t i = 0; i < 3; i++)
                     ~~^~~
In file included from game.cpp:18:
game.h: In member function 'void Game::globalSave()':
game.h:613:78: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
 setGlobalSaveMessage(int64_t key, bool value) {globalSaveMessage[key] = value;}
                                                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

game.cpp:6180:23: note: within this loop
  for(int64_t i = 0; i < 3; i++)
                     ~~^~~
 
C++:
game.cpp: W konstruktorze 'Game::Game()':
game.cpp: In constructor 'Game::Game()':
game.cpp:80:24: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
   globalSaveMessage[i] = false;
   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
game.cpp:79:23: note: within this loop
  for(int64_t i = 0; i < 3; i++)
                     ~~^~~
In file included from game.cpp:18:
game.h: In member function 'void Game::globalSave()':
game.h:613:78: warning: iteration 2 invokes undefined behavior [-Waggressive-loop-optimizations]
 setGlobalSaveMessage(int64_t key, bool value) {globalSaveMessage[key] = value;}
                                                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

game.cpp:6180:23: note: within this loop
  for(int64_t i = 0; i < 3; i++)
                     ~~^~~
-waggressive in makefile?
 
no, only -Wno-strict-aliasing
compare then to mine
:
C++:
void Game::globalSave()
{
    bool close = g_config.getBool(ConfigManager::SHUTDOWN_AT_GLOBALSAVE);
    if(!close) // check are we're going to close the server
        Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::setGameState, this, GAMESTATE_CLOSED)));

    // call the global event
    g_globalEvents->execute(GLOBALEVENT_GLOBALSAVE);
    if(close)
    {
        //shutdown server
        Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::setGameState, this, GAMESTATE_SHUTDOWN)));
        return;
    }

    //pay houses
    Houses::getInstance()->check();
    //clean map if configured to
    if(g_config.getBool(ConfigManager::CLEAN_MAP_AT_GLOBALSAVE))
        cleanMap();

    //remove premium days globally if configured to
    if(g_config.getBool(ConfigManager::INIT_PREMIUM_UPDATE))
        IOLoginData::getInstance()->updatePremiumDays();

    //reload everything
    reloadInfo(RELOAD_ALL);
    //prepare for next global save after 24 hours
    Scheduler::getInstance().addEvent(createSchedulerTask(((24 * 60 * 60) - (5 * 60)) * 1000, boost::bind(&Game::prepareGlobalSave, this, 5)));
    //open server
    Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::setGameState, this, GAMESTATE_NORMAL)));
}
 
game.h:613:78: warning
It says warning. Did it stop compilation?
This code is bugged, but it should compile.

To fix this bug in game.h replace:
C++:
bool globalSaveMessage[2];
with:
C++:
bool globalSaveMessage[3];

About this bug:
bool globalSaveMessage[2]; means this array has 2 elements, their keys are: 0 and 1
Compiler reports bug, because this loop (line 6180 of game.cpp):
C++:
for(int64_t i = 0; i < 3; i++)
and some other parts of code [only first bug is reported, then it stops compilation/error reporting] reads array keys 0, 1 and 2.

Reading key 2 should crash server. It does not, because of memory allocation of Game class. It just reads some not related value and handled it as 3rd key of globalSaveMessage array.

Writing key 2 of globalSaveMessage in line 6258:
Code:
globalSaveMessage[2] = true;
should crash server in moment of this line execution, but it does not. Again it gets some other variable from Game class and overwrite it's value to true. Now it gets even worse. Some other code - that is 100% fine - will crash in random moment, because it will use value modified by line I've posted above!
 
Cześć

Czy ktoś jest w stanie pomóc?

Debian 11 build na tfs 1.2

Co do kompilacji innych norm 1.3
1.4
1.5
Kompiluje się bez problemu. Pozdrowienia

C++:
[KOD=cpp][ 14%] Budowa obiektu CXX CMakeFiles/tfs.dir/src/connection.cpp.o
/home/global2/src/connection.cpp: W funkcji składowej „void Connection::accept()”:
/home/global2/src/connection.cpp:120:81: błąd: brak pasującej funkcji dla wywołania „boost: osix_time::seconds::seconds(Connection::<unnamed enum>)”
  120 | wygasa_z_now(boost: osix_time::seconds(Connection::read_timeout));
      | ^

W pliku dołączonym z /usr/include/boost/date_time/posix_time/posix_time_types.hpp:16,
                 z /usr/include/boost/asio/time_traits.hpp:23,
                 z /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
                 z /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
                 z /usr/include/boost/asio/basic_deadline_timer.hpp:25,
                 z /usr/include/boost/asio.hpp:25,
                 z /home/global2/src/otpch.h:42,
                 z /home/global2/src/connection.cpp:20:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: kandydat: 'template<klasa T> boost: osix_time::seconds::seconds(const T&, nazwa boost::enable_if<boost : :is_integral<T>, void>::type*)'
   57 | BOOST_CXX14_CONSTEXPR jawne sekundy (T const& s,
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: odliczenie/podstawienie argumentu szablonu nie powiodło się:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp: Zamiast „template<klasa T> boost: oxix_time::seconds::seconds(const T&, nazwa typu boost::enable_if<boost::is_integral<T >, void>::type*) [z T = Connection::<unnamed enum>]':
/home/global2/src/connection.cpp:120:81: dzięki temu
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: błąd: brak typu o nazwie „type” w „struct boost::enable_if<boost::is_integral<Connection::<unnamed enum>>, pustka >'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(const boost: osix_time::seconds&)'
   53 | klasa BOOST_SYMBOL_VISIBLE sekunda: publiczny czas_czasu
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „const boost: osix_time::seconds&”
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(boost: osix_time::seconds&&)'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „boost: osix_time::seconds&&”
/home/global2/src/connection.cpp: W funkcji składowej „void Connection: arseHeader(const boost::system::error_code&)”:
/home/global2/src/connection.cpp:164:81: błąd: brak pasującej funkcji dla wywołania „boost: osix_time::seconds::seconds(Connection::<unnamed enum>)”
  164 | wygasa_z_now(boost: osix_time::seconds(Connection::read_timeout));
      | ^

W pliku dołączonym z /usr/include/boost/date_time/posix_time/posix_time_types.hpp:16,
                 z /usr/include/boost/asio/time_traits.hpp:23,
                 z /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
                 z /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
                 z /usr/include/boost/asio/basic_deadline_timer.hpp:25,
                 z /usr/include/boost/asio.hpp:25,
                 z /home/global2/src/otpch.h:42,
                 z /home/global2/src/connection.cpp:20:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: kandydat: 'template<klasa T> boost: osix_time::seconds::seconds(const T&, nazwa boost::enable_if<boost : :is_integral<T>, void>::type*)'
   57 | BOOST_CXX14_CONSTEXPR jawne sekundy (T const& s,
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: odliczenie/podstawienie argumentu szablonu nie powiodło się:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp: Zamiast „template<klasa T> boost: oxix_time::seconds::seconds(const T&, nazwa typu boost::enable_if<boost::is_integral<T >, void>::type*) [z T = Connection::<unnamed enum>]':
/home/global2/src/connection.cpp:164:81: dzięki temu
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: błąd: brak typu o nazwie „type” w „struct boost::enable_if<boost::is_integral<Connection::<unnamed enum>>, pustka >'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(const boost: osix_time::seconds&)'
   53 | klasa BOOST_SYMBOL_VISIBLE sekunda: publiczny czas_czasu
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „const boost: osix_time::seconds&”
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(boost: osix_time::seconds&&)'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „boost: osix_time::seconds&&”
/home/global2/src/connection.cpp: W funkcji składowej „void Connection: arsePacket(const boost::system::error_code&)”:
/home/global2/src/connection.cpp:226:81: błąd: brak pasującej funkcji dla wywołania „boost: osix_time::seconds::seconds(Connection::<unnamed enum>)”
  226 | wygasa_z_now(boost: osix_time::seconds(Connection::read_timeout));
      | ^

W pliku dołączonym z /usr/include/boost/date_time/posix_time/posix_time_types.hpp:16,
                 z /usr/include/boost/asio/time_traits.hpp:23,
                 z /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
                 z /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
                 z /usr/include/boost/asio/basic_deadline_timer.hpp:25,
                 z /usr/include/boost/asio.hpp:25,
                 z /home/global2/src/otpch.h:42,
                 z /home/global2/src/connection.cpp:20:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: kandydat: 'template<klasa T> boost: osix_time::seconds::seconds(const T&, nazwa boost::enable_if<boost : :is_integral<T>, void>::type*)'
   57 | BOOST_CXX14_CONSTEXPR jawne sekundy (T const& s,
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: odliczenie/podstawienie argumentu szablonu nie powiodło się:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp: Zamiast „template<klasa T> boost: oxix_time::seconds::seconds(const T&, nazwa typu boost::enable_if<boost::is_integral<T >, void>::type*) [z T = Connection::<unnamed enum>]':
/home/global2/src/connection.cpp:226:81: dzięki temu
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: błąd: brak typu o nazwie „type” w „struct boost::enable_if<boost::is_integral<Connection::<unnamed enum>>, pustka >'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(const boost: osix_time::seconds&)'
   53 | klasa BOOST_SYMBOL_VISIBLE sekunda: publiczny czas_czasu
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „const boost: osix_time::seconds&”
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(boost: osix_time::seconds&&)'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „boost: osix_time::seconds&&”
/home/global2/src/connection.cpp: W funkcji składowej „void Connection::internalSend(const OutputMessage_ptr&)”:
/home/global2/src/connection.cpp:262:83: błąd: brak pasującej funkcji dla wywołania „boost: osix_time::seconds::seconds(Connection::<unnamed enum>)”
  262 | xpires_from_now(boost: osix_time::seconds(Connection::write_timeout));
      | ^

W pliku dołączonym z /usr/include/boost/date_time/posix_time/posix_time_types.hpp:16,
                 z /usr/include/boost/asio/time_traits.hpp:23,
                 z /usr/include/boost/asio/detail/timer_queue_ptime.hpp:22,
                 z /usr/include/boost/asio/detail/deadline_timer_service.hpp:29,
                 z /usr/include/boost/asio/basic_deadline_timer.hpp:25,
                 z /usr/include/boost/asio.hpp:25,
                 z /home/global2/src/otpch.h:42,
                 z /home/global2/src/connection.cpp:20:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: kandydat: 'template<klasa T> boost: osix_time::seconds::seconds(const T&, nazwa boost::enable_if<boost : :is_integral<T>, void>::type*)'
   57 | BOOST_CXX14_CONSTEXPR jawne sekundy (T const& s,
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: uwaga: odliczenie/podstawienie argumentu szablonu nie powiodło się:
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp: Zamiast „template<klasa T> boost: oxix_time::seconds::seconds(const T&, nazwa typu boost::enable_if<boost::is_integral<T >, void>::type*) [z T = Connection::<unnamed enum>]':
/home/global2/src/connection.cpp:262:83: dzięki temu
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:57:38: błąd: brak typu o nazwie „type” w „struct boost::enable_if<boost::is_integral<Connection::<unnamed enum>>, pustka >'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(const boost: osix_time::seconds&)'
   53 | klasa BOOST_SYMBOL_VISIBLE sekunda: publiczny czas_czasu
      | ^~~~~~~
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „const boost: osix_time::seconds&”
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: kandydat: 'constexpr boost: osix_time::seconds::seconds(boost: osix_time::seconds&&)'
/usr/include/boost/date_time/posix_time/posix_time_duration.hpp:53:30: uwaga: brak znanej konwersji dla argumentu 1 z „Connection::<unnamed enum>” na „boost: osix_time::seconds&&”
/home/global2/src/connection.cpp: W funkcji składowej „void Connection::dispatchBroadcastMessage(const OutputMessage_ptr&)”:
/home/global2/src/connection.cpp:293:10: error: 'boost::asio::ip::tcp::socket' {aka 'zwiększenie klasy::asio::basic_stream_socket<boost::asio:: ip::tcp>'} nie ma o nazwie „get_io_service”
  293 | socket.get_io_service().dispatch(std::bind(&Connection::broadcastMessage, shared_from_this(), msgCopy));
      | ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/tfs.dir/build.make:230: CMakeFiles/tfs.dir/src/connection.cpp.o] Błąd 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/tfs.dir/all] Błąd 2
make: *** [Makefile:91: all] Błąd 2[/KOD]
 
Debian 11.7.0
TFS 0.4 rev 3884
error:
Code:
outputmessage.cpp: In member function ‘OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol*, bool)’:
outputmessage.cpp:190:57: error: ‘_1’ was not declared in this scope
  190 |   boost::bind(&OutputMessagePool::releaseMessage, this, _1));
      |                                                         ^~
outputmessage.cpp:190:57: note: suggested alternatives:
In file included from /usr/include/boost/mpl/aux_/include_preprocessed.hpp:37,
                 from /usr/include/boost/mpl/placeholders.hpp:43,
                 from /usr/include/boost/iterator/iterator_categories.hpp:16,
                 from /usr/include/boost/iterator/iterator_adaptor.hpp:14,
                 from /usr/include/boost/token_iterator.hpp:22,
                 from /usr/include/boost/tokenizer.hpp:20,
                 from otpch.h:37,
                 from outputmessage.cpp:17:
/usr/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp:29:16: note:   ‘mpl_::_1’
   29 | typedef arg<1> _1;
      |                ^~
In file included from /usr/include/boost/function.hpp:23,
                 from otpch.h:34,
                 from outputmessage.cpp:17:
/usr/include/c++/10/functional:221:34: note:   ‘std::placeholders::_1’
  221 |     extern const _Placeholder<1> _1;
      |                                  ^~
In file included from /usr/include/boost/mpl/aux_/include_preprocessed.hpp:37,
                 from /usr/include/boost/mpl/placeholders.hpp:43,
                 from /usr/include/boost/iterator/iterator_categories.hpp:16,
                 from /usr/include/boost/iterator/iterator_adaptor.hpp:14,
                 from /usr/include/boost/token_iterator.hpp:22,
                 from /usr/include/boost/tokenizer.hpp:20,
                 from otpch.h:37,
                 from outputmessage.cpp:17:
/usr/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp:29:16: note:   ‘mpl_::_1’
   29 | typedef arg<1> _1;
      |                ^~
In file included from /usr/include/boost/bind/bind.hpp:2356,
                 from otpch.h:35,
                 from outputmessage.cpp:17:
/usr/include/boost/bind/placeholders.hpp:46:38: note:   ‘boost::placeholders::_1’
   46 | BOOST_STATIC_CONSTEXPR boost::arg<1> _1;
      |                                      ^~
In file included from /usr/include/boost/mpl/aux_/include_preprocessed.hpp:37,
                 from /usr/include/boost/mpl/placeholders.hpp:43,
                 from /usr/include/boost/iterator/iterator_categories.hpp:16,
                 from /usr/include/boost/iterator/iterator_adaptor.hpp:14,
                 from /usr/include/boost/token_iterator.hpp:22,
                 from /usr/include/boost/tokenizer.hpp:20,
                 from otpch.h:37,
                 from outputmessage.cpp:17:
/usr/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp:29:16: note:   ‘mpl_::_1’
   29 | typedef arg<1> _1;
      |                ^~
make[1]: *** [Makefile:599: outputmessage.o] Error 1
 
Back
Top