The International Simutrans Forum

 

Author Topic: New feature: "-easyserver" switch to make hosting easier  (Read 2769 times)

0 Members and 1 Guest are viewing this topic.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
New feature: "-easyserver" switch to make hosting easier
« 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.
« Last Edit: May 12, 2018, 08:47:15 PM by IgorEliezer »

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2376
  • Languages: EN
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #1 on: May 12, 2018, 10:19:30 PM »
Where are...
Code: [Select]
#include <miniupnpc.h>
#include <upnpcommands.h>
(miniupnpc.lib)
Coming from? I do not think they are part of the standard C++ API...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #2 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..

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #3 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #4 on: May 14, 2018, 06:08:45 PM »
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.

I already want to try it! this looks great !!  ;D

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #5 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.

I mentioned it here: https://forum.simutrans.com/index.php/topic,18138.msg172859.html#msg172859



Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2376
  • Languages: EN
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #6 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #7 on: May 14, 2018, 09:06:29 PM »
Yes, I'm doing the tests from the same computer.  :P

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #8 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
« Last Edit: May 14, 2018, 10:19:22 PM by Yona-TYT »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #9 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)
« Last Edit: May 15, 2018, 04:30:24 AM by prissi »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #10 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?  ???

 

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #11 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #12 on: May 15, 2018, 05:33:04 PM »
It's the r8433 !.
Tonight I continue with the tests .  ;)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #13 on: May 16, 2018, 02:06:29 AM »
Now I can not activate new players, the button does not work? .  :o

Using  r8433.


Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #14 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #15 on: May 16, 2018, 11:34:36 AM »
Are you using a scenario or just a normal savegame? It works for me with normal savegames.

I am using a script: regions-lite.zip .

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #16 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.  ;)

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #17 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.  ;)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #18 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 ...

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #19 on: May 21, 2018, 12:40:25 AM »
Now I can not activate new players, the button does not work? .  :o Using  r8433.


I have compiled the latest revision from github and I still have problems activating the players .  :-[

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #20 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 ...
And in the end this message.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #21 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #22 on: May 22, 2018, 02:03:11 AM »
Code: [Select]
/// 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?

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #23 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.

Offline MobileRod

  • *
  • Posts: 29
  • Languages: PT (BR), EN
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #24 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #25 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.

Offline MobileRod

  • *
  • Posts: 29
  • Languages: PT (BR), EN
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #26 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...

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #27 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #28 on: May 29, 2018, 03:35:26 AM »
@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

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #29 on: May 29, 2018, 04:21:12 AM »
I leave a video.  ;)

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #30 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #31 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.
« Last Edit: May 30, 2018, 03:00:17 AM by prissi »

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4454
  • Languages: EN, DE, AT
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #32 on: May 30, 2018, 06:38:15 AM »
Thank you!

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #33 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.  :-[

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #34 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.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #35 on: May 31, 2018, 12:57:25 AM »
No, 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
« Last Edit: May 31, 2018, 01:08:39 AM by Yona-TYT »

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #36 on: May 31, 2018, 01:45:35 AM »
I got this error when trying to connect 2 clients on the same pc.  :o
Code: [Select]
(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. ;)
Code: [Select]
(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)
« Last Edit: May 31, 2018, 01:59:59 AM by Yona-TYT »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #37 on: May 31, 2018, 02:14:40 AM »
It works for me, but I am on windows.

Offline Yona-TYT ve

  • Devotee
  • *
  • Posts: 1091
    • Simutrans-BLOG
  • Languages: ES
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #38 on: May 31, 2018, 02:20:05 AM »
try using my script.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9132
  • Languages: De,EN,JP
Re: New feature: "-easyserver" switch to make hosting easier
« Reply #39 on: May 31, 2018, 03:00:14 AM »
I did and it worked.