The International Simutrans Forum

Community => Game Servers => Topic started by: prissi on May 12, 2018, 03:29:28 PM

Title: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 12, 2018, 03:29:28 PM
Starting with the nightly r8429, simutrans has a new switch on the commandline. If started with "simutrans -easyserver -load savefilename.sve" simutrans will automatically start a server game, and will try to open a port on the router (if it supports UPnP) and will use the external IP to announce on the server.  (It may still fail do to the router not supporting UPnP.) So there is just a reason less for not hosting a game. Please try this feature.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: DrSuperGood on May 12, 2018, 10:19:30 PM
Where are...
#include <miniupnpc.h>
#include <upnpcommands.h>

(miniupnpc.lib)
Coming from? I do not think they are part of the standard C++ API...
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 13, 2018, 02:48:07 AM
They are from miniupnpc project: http://miniupnp.free.fr/. If this is not there, you can compile without, but then of course without libupnpc support. But the way, the static linking only works for Mingw binary from the site, from the sources I could only build dlls for MSVC..
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 14, 2018, 03:29:46 AM
In the new nightly (r8432 and higher) you can start a servergame directly from the GUI loading dialogue. I would be happy, if this can be tested, so I can release a new stable.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 14, 2018, 06:08:45 PM
Quote from: prissi on May 14, 2018, 03:29:46 AMIn the new nightly (r8432 and higher) you can start a servergame directly from the GUI loading dialogue. I would be happy, if this can be tested, so I can release a new stable.

I already want to try it! this looks great !!  ;D
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 14, 2018, 06:48:01 PM
I created a server, but it does not work.
Simutrans freezes for several minutes, and in the end the server does not respond.
(https://www.mediafire.com/convkey/50ab/arb3li6vwap757r6g.jpg?size_id=5)
I mentioned it here: https://forum.simutrans.com/index.php/topic,18138.msg172859.html#msg172859


Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: DrSuperGood on May 14, 2018, 07:17:48 PM
I assume you tried connecting to it from another computer? I had some problems in the past with joining games hosted on the same computer from the server list. One has to connect via the local loop-back adapter IP instead. Likely because ones NAT gets confused with a local IP requesting to be sent back to itself.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 14, 2018, 09:06:29 PM
Yes, I'm doing the tests from the same computer.  :P
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 14, 2018, 09:41:11 PM
It seems that I found an error, although I'm not sure if it has to do with the new function.

The problem is that the public service (no player can in fact.) can not change or build anything when it is in server mode.
To replicate, just load the scenario in server mode, from the GUI.

Edit.
I am using a script: regions-lite.zip (http://files.simutrans.com/index.php/s/1iFZZNXRju4jo7A)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 15, 2018, 02:47:23 AM
The serverlist uses the external IP. To connect on the same computer, you have to load the game "net:127.0.0.1" as filename. To join in a local network, you have to use the local computer, which is printed if you time "ipconfig" in the Command window. And about scenarios, indeed, I found the same. I do not understand why, because normal savegames work. Maybe the server has to be started before the scenario loads. I will investigate.

EDIT: The server was not running in the correct frame mode. Should work with next nightly (r8433 or higher)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 15, 2018, 11:21:20 AM
Another problem, when I try to load a saved game, or a scenario, the password entry window appears, is this normal?  ???
(https://www.mediafire.com/convkey/94f6/bcjnkm8aeqacaws6g.jpg)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 15, 2018, 01:09:44 PM
Is this already r8433? Otherwise it may be fixed there. Did not happen for me at least.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 15, 2018, 05:33:04 PM
It's the r8433 !.
Tonight I continue with the tests .  ;)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 16, 2018, 02:06:29 AM
Now I can not activate new players, the button does not work? .  :o

Using  r8433.

(https://www.mediafire.com/convkey/d6a4/j645d3u9b5mqlnb6g.jpg)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 16, 2018, 08:39:45 AM
Are you using a scenario or just a normal savegame? It works for me with normal savegames.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 16, 2018, 11:34:36 AM
Quote from: prissi on May 16, 2018, 08:39:45 AMAre you using a scenario or just a normal savegame? It works for me with normal savegames.

I am using a script: regions-lite.zip (http://files.simutrans.com/index.php/s/1iFZZNXRju4jo7A) .
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 16, 2018, 11:44:47 AM
It seems that only happens when simutrans starts the first time, load the scenario in server mode and you will see that it can not activate players.  ;)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 18, 2018, 11:34:21 AM
@Prissi

I have an idea!. What do you think of a window to configure the server from the GUI ?.

So one can choose the name and if the server is going to announce or not, and a quick configuration (default) for the lazy ones.  ;)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 18, 2018, 12:12:12 PM
Of course I though of that. But UI in Simutrans (or any software) is the most time consuming action. Even the simple button was not as simple ...
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 21, 2018, 12:40:25 AM
Quote from: Yona-TYT on May 16, 2018, 02:06:29 AMNow I can not activate new players, the button does not work? .  :o Using  r8433. (https://www.mediafire.com/convkey/d6a4/j645d3u9b5mqlnb6g.jpg)


I have compiled the latest revision from github and I still have problems activating the players .  :-[
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 21, 2018, 12:56:41 AM
I tried to run a server from the same PC and without internet, but it takes too long.  :-[

Server paparing game ...(https://www.mediafire.com/convkey/2869/ncy537q675mh8136g.jpg)
And in the end this message.(https://www.mediafire.com/convkey/6b58/529qkf93fihcigo6g.jpg)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 21, 2018, 03:32:05 AM
I think without internet the network stack might not be initialised. But you may be able to use the normal commandline switches (-server for the server and -load net:127.0.0.1) for the client. That worked for ages.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 22, 2018, 02:03:11 AM

/// specify the savegame to load
map.file = "<attach>"
my script uses the current map, is it possible that this is what causes the problem when activating the players?
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 22, 2018, 03:38:25 AM
Honestly, I did not look into it, because I usually never touch the scenario code. Does starting a server on the cmmandline and then connecting to another client works? Otherwise I need the files to test it.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: MobileRod on May 22, 2018, 02:36:43 PM
I don't know if it has anything to do with the new tool, but the number of servers is on the increase by now - unfortunately all offline.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 22, 2018, 02:45:05 PM
That is very likely from players testing the new option. You are welcome to host a server on your own. Just generate a game without trees (to have a small file size) and load it as a server. Even for a fixed time every night will contribute to more online servers.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: MobileRod on May 23, 2018, 12:39:10 PM
I think I still need to learn a lot before I set a new server. I've been trying, but...
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Dwachs on May 28, 2018, 06:23:50 PM
@Yona-TT: I cannot reproduce those problems you describe. I think this is a problem of the scenario script.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 29, 2018, 03:35:26 AM
Quote from: Dwachs on May 28, 2018, 06:23:50 PM@Yona-TT: I cannot reproduce those problems you describe. I think this is a problem of the scenario script.
I do not think so, there is no function that prevents the player from activating, do you? ... and something curious is that if I create a new map, the game starts with active players (all that I tried to activate before).  :o
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 29, 2018, 04:21:12 AM
I leave a video.  ;)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Dwachs on May 29, 2018, 05:20:18 PM
This feature is still completely broken:

-- stepmode is not set to FIX_RATIO (the bug report about new players not activated, no play possible as no commands will be executed ever)
-- clear_command_queue is not called (the bug that these new players suddenly are active in the next game)

All the logic to properly stop and restart server in karte::load(const char* file) is there for some reason. I suggest to put all the easy-server logic into this method. Then call this method from the load-dialog. If this works, then I can do the implementation for scenarios.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 30, 2018, 01:46:42 AM
Sorry, the ratio is set to FIX_RATIO from the world loading routine, because the server is initialised before loading a map, at least for normal loading. Also if somebody joined a network game, and then wants to start the following game as a server, the core has to shut down and then reopened as a server. This closing logic when starting a server and a networkgame was running before was not correctly handled. And saving should cause a sync, if there are connectd clients. That I fixed as well.

If you aim at attaching a scenario to a running game, then karte_t::load is never called.

In r8476 the network starting and stopping logic is in a new function karte_t::server_switch I works also with scenarios which attach to a running gmae, at least I could connect locally. But the rule etc. are not displayed, when one joines.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Dwachs on May 30, 2018, 06:38:15 AM
Thank you!
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 30, 2018, 02:26:30 PM
This means that it will not be possible to create a server from the GUI?

It would be a shame, because with that button things are much more practical.  :-[
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 31, 2018, 12:14:24 AM
No, it means it should work with the latest nightly. I had just to move the logic. Please continue to test.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 31, 2018, 12:57:25 AM
Quote from: prissi on May 31, 2018, 12:14:24 AMNo, it means it should work with the latest nightly. I had just to move the logic. Please continue to test.
Unfortunately the nightly does not generate the executable for linux, I compiled from Github, but the button to start the game in server mode does not appear.
It works.  ;D
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 31, 2018, 01:45:35 AM
I got this error when trying to connect 2 clients on the same pc.  :o
(gdb) where
#0  0xb7fd5d21 in __kernel_vsyscall ()
#1  0xb7eeef28 in send () from /usr/lib/libpthread.so.0
#2  0x08188b4e in network_send_data (dest=14, buf=0x9c8708d "\016", size=14,
    count=@0xbfffc56e: 0, timeout_ms=250) at network/network.cc:669
#3  0x0819476f in packet_t::send (this=0x9c87080, s=14, complete=true)
    at network/network_packet.cc:118
#4  0x0818a908 in network_command_t::send (this=0xbfffc5c4, s=14)
    at network/network_cmd.cc:70
#5  0x0818ea49 in nwc_gameinfo_t::execute (this=0x9cb9bd0, welt=0x89db200)
    at network/network_cmd_ingame.cc:97
#6  0x082caad4 in karte_t::process_network_commands (this=0x89db200,
    ms_difference=0xbfffcc94) at simworld.cc:6503
#7  0x082cd0d3 in karte_t::interactive (this=0x89db200, quit_month=2147483647)
    at simworld.cc:6676
#8  0x08286e39 in simu_main (argc=1, argv=0xbfffe7a4) at simmain.cc:1360
#9  0x082969b3 in sysmain (argc=1, argv=0xbfffe7a4) at simsys.cc:1038
#10 0x0804f9f2 in main (argc=1, argv=0xbfffe7a4) at simsys_s.cc:729
(gdb)

Edit.
Update some debug libraries. ;)
(gdb) where
#0  0xb7fd5d21 in __kernel_vsyscall ()
#1  0xb7eeef28 in send () from /usr/lib/libpthread.so.0
#2  0x08188b4e in network_send_data (dest=14,
    buf=0xbfffc6f0 "BZh91AY&SY\270z", size=1024, count=@0xbfffc5c2: 0,
    timeout_ms=250) at network/network.cc:669
#3  0x0818ea89 in nwc_gameinfo_t::execute (this=0x9cc3a10, welt=0x89db250)
    at network/network_cmd_ingame.cc:103
#4  0x082caad4 in karte_t::process_network_commands (this=0x89db250,
    ms_difference=0xbfffcc94) at simworld.cc:6503
#5  0x082cd0d3 in karte_t::interactive (this=0x89db250, quit_month=2147483647)
    at simworld.cc:6676
#6  0x08286e39 in simu_main (argc=1, argv=0xbfffe7a4) at simmain.cc:1360
#7  0x082969b3 in sysmain (argc=1, argv=0xbfffe7a4) at simsys.cc:1038
#8  0x0804f9f2 in main (argc=1, argv=0xbfffe7a4) at simsys_s.cc:729
(gdb)
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 31, 2018, 02:14:40 AM
It works for me, but I am on windows.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: Yona-TYT on May 31, 2018, 02:20:05 AM
try using my script.
Title: Re: New feature: "-easyserver" switch to make hosting easier
Post by: prissi on May 31, 2018, 03:00:14 AM
I did and it worked.