WizzardMaker / AirlineTycoon

Source code of Airline Tycoon based on the GOG source code release
https://www.gog.com/game/airline_tycoon_deluxe
Other
25 stars 9 forks source link

Join a Raknet-Network Game crash the game [BUG] #33

Open mr-dev-cmd opened 1 year ago

mr-dev-cmd commented 1 year ago

Your current version 1.6.2 Linux (ubuntu 22.04) -> Develop Branch

Describe the bug The good thing first: It is finally possible to create/host a game in the Raknet-Mode This game is visible for other Players in the Raknet-Join "room", but when they try to join the game crash with a segmentation fault

To Reproduce Steps to reproduce the behavior:

  1. Build the AT executable in ubuntu 22.04 of the develop branch
  2. Start the game and klick on Network -> Raknet-Host and create a new game
  3. On a second PC start the same game version and click on Network -> Raknet-Join
  4. Choose the Game that the Host created in the list and join
  5. The game will crash on the joining PC (segmentation fault)

Expected behavior a successful connection

WizzardMaker commented 1 year ago

I can't quite reproduce the issue on my side

Does the crash happen when you run 2 instances of ATD on the same machine? (The game can be run from the same location multiple times, just saving doesn't work)

mr-dev-cmd commented 1 year ago

Hi. Yes the crash happens even on the same machine. But also with 2 independent machines. The joining part always crash with segmentation fault.

WizzardMaker commented 1 year ago

Seems to be a Linux related issue then.

Does RAKNet direct join/host work?

mr-dev-cmd commented 1 year ago

The only way (for me in linux) to play multiplayer is the direct ip. If it is with 2 instances on the same machine I can even enter localhost as the ip address at the joining instance. I dont know if that is also a raknet connection.

By the way: The enet does not even show me opened games.

WizzardMaker commented 1 year ago

By the way: The enet does not even show me opened games.

The enet implementation is rather flaky - same machine game discovery doesn't really work and sometimes enet doesn't use the correct adapter

I dont know if that is also a raknet connection.

Yes, Direct-IP is implemented with RAKNet

Could you maybe send me a log (debug.txt) of the crashing client?

mr-dev-cmd commented 1 year ago

Finally I found time... here are the log files:

These are the logs when the game crash on the client side: debug_host.txt debug_client.txt

These are the logs with direct IP when everything works well: debug_host_direct.txt debug_client_direct.txt

In case of a crash I see a "segmentation fault" in the terminal from where I start the game. Thats not in the log file.

WizzardMaker commented 1 year ago

Okay, I just tried it with my WSL ubuntu version. There was a bug in the server code and a potential bug in the NAT to UDP fallback code, but that shouldn't be run when on the same machine.

How exactly are you building and what version of SDL are you using? How are you connected to the internet? Can you check with Wine or Windows, to rule out a bug in the Linux version?

Are you using the DEBUG or RELEASE build? (Check the main menu, bottom right corner)

mr-dev-cmd commented 1 year ago
  1. How exactly I am building: My build is from the develop branch. I just do: cmake -DCMAKE_TOOLCHAIN_FILE=../Toolchain-i686.cmake .. followed by make

that gave me a Release build (lower right corner in menu)

  1. SDL Version is 2.0.20

  2. WIFI

  3. I tried your last release with wine. Here everything works like expected. So it is related to the (or especially my) Linux build. Here is a Log (host and client in one File) from the wine tests with no crash. logs.txt

  4. The branch "master-server-config" I can not build. Error at Checkup.cpp:

[ 78%] Building CXX object src/CMakeFiles/AT.dir/Checkup.cpp.o In file included from /home/xxx/AirlineTycoon/src/Checkup.cpp:22: /home/xxx/AirlineTycoon/src/Checkup.h:34:5: error: ‘HKEY’ does not name a type 34 | HKEY hKey; | ^~~~ /home/xxx/AirlineTycoon/src/Checkup.cpp: In member function ‘bool CRegistryAccess::Open(const CString&)’: /home/xxx/AirlineTycoon/src/Checkup.cpp:40:43: warning: unused parameter ‘RegistryPath’ [-Wunused-parameter]

I tried it with: cmake -DJANSSON_BUILD_DOCS=OFF -DCMAKE_TOOLCHAIN_FILE=../Toolchain-i686.cmake .. followed by make

mr-dev-cmd commented 1 year ago

Just one more interesting behavior: When I use start one game in Linux and the other in the wine environment, the Linux instance always crash. Wine stay in game. Very interesting is the case when Linux is Host and Wine is Client. In the moment Wine wants to join, the Linux Host crash and Wine stay in game. Here are the logs for that case: logs2.txt The IPs I changed to xxx in this log.

WizzardMaker commented 1 year ago

Yeah, I noticed that the master-server-config branch is not yet ready for linux

I always build cmake without the toolchain file (cmake ./CMake in my case), have you tried that yet? Everything else looks the same for me

Could you maybe try to run AT with GDB if the above compile fails? Maybe that could give a trace on where the segfault occured

mr-dev-cmd commented 1 year ago

I can try to use cmake without the toolchain option, but I guess it will not work. I test as soon as I can.

how to use GDB? Do I need to build AT before in a special way? I am completely new to that and need detailed instructions, unfortunately.

mr-dev-cmd commented 1 year ago

You was right! It works now!!!

I run cmake without the toolchain file and it gave me the a warning that the sdl2 librarys were not all found. So I remembered that the toolchain file actually uses a 32bit compiler option.

I removed my i386 dev librarys and installed the normal (64bit) instead. Run the cmake without toolchain file again and it worked. After the make I got a AT executable that had no problems to join a Raknet game.

Maybe its time to change the building instructions for Linux (or at least ubuntu 64bit).

mr-dev-cmd commented 1 year ago

Hm. I tested with a friend not in my local network and we could not join a raknet NAT game. The game did not crash but both players got single games and could not see each other in the choose character menu. It did not matter who hosted or joined. I have seen "incapable port stride" in the terminal from where I started. I not yet have logs or tried the windows version. Can make this as soon as its possible.

Seems its only working in local networks so far.

WizzardMaker commented 1 year ago

Yes, if the NAT traversal fails to find a route between the clients, it is supposed to switch to a UDP tunnel. There was a bug in the code where sometimes the udp tunnel does not get properly opened, resulting in a semi failed connection where all clients move into a "singleplayer" game, like you experienced.

I fixed the compilation issues for linux in the feature/master-server-config branch, could you try that one again, if it isn't too much of a hassle?

But just for clarification, what systems are trying to connect together in your scenario? Both on Linux x64? What network conditions are all clients in? Router restarted?

mr-dev-cmd commented 1 year ago

I could compile it now, but when I start I get directly a segmentation fault. I guess it is a problem with the config file format. In the old version the entries seemed to be in a line. Now its in many lines (what is actually better). I just guess, but it can be the different 'new line' in Linux what cause this issue.

about the network test: It was with 2 Linux x64 PC. Both are behind a router with different local IP networks.

mr-dev-cmd commented 1 year ago

Now a little more detailed what I tested:

  1. Local on the same machine with many instances running: everything works like expected. If I use native Linux or the last Windows Release over wine

  2. 2 separate linux (ubuntu 22.04 x64) machines on different locations connected to the Internet with their private provider contract. Both connected to their router over WiFi. Raknet host and join result in those kind of single player games. That happened with the last Windows Release over wine and with the native Linux Version too.

  3. I was able to compile the feature/master-server-config branch for Linux. Unfortunately I get a segmentation fault when I start the game. This is most likely because if the new config file. I exchanged the checkup.cpp and checkup.h with the files from the develop branch. After I could compile and start the game (I dont know if that is a useful test). Unfortunately the network behave like before. I still get strange single player games when joining.

WizzardMaker commented 1 year ago

I could compile it now, but when I start I get directly a segmentation fault. I guess it is a problem with the config file format. In the old version the entries seemed to be in a line. Now its in many lines (what is actually better). I just guess, but it can be the different 'new line' in Linux what cause this issue.

about the network test: It was with 2 Linux x64 PC. Both are behind a router with different local IP networks.

I fixed that issue. It was a bug in the init of the settings file, causing an invalid state in the game's settings. This resulted in a crash when loading sound files (where the seg fault happened)

mr-dev-cmd commented 1 year ago

Yes. Works now. But the connection over the raknet Server is still not working. Always result in those Strang Single player games. Everything works when I use more instances on the same System. At least nothing crash anymore. And the multiplayer is possible by portfarding and using direkt IP after sharing the WAN IP.

mr-dev-cmd commented 1 year ago

Just to update the Ubuntu build instructions (the way it works for me so far):

Prepare:

sudo apt-get install libsdl2*-dev

git submodule update --init

Build:

mkdir build

cd build

cmake -DJANSSON_BUILD_DOCS=OFF ..

make