News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

New feature: "-easyserver" switch to make hosting easier

Started by prissi, May 12, 2018, 03:29:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prissi

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.

DrSuperGood

Where are...
#include <miniupnpc.h>
#include <upnpcommands.h>

(miniupnpc.lib)
Coming from? I do not think they are part of the standard C++ API...

prissi

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..

prissi

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.

Yona-TYT

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

Yona-TYT

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



DrSuperGood

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.

Yona-TYT

Yes, I'm doing the tests from the same computer.  :P

Yona-TYT

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

prissi

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)

Yona-TYT

Another problem, when I try to load a saved game, or a scenario, the password entry window appears, is this normal?  ???


prissi

Is this already r8433? Otherwise it may be fixed there. Did not happen for me at least.

Yona-TYT

It's the r8433 !.
Tonight I continue with the tests .  ;)

Yona-TYT

Now I can not activate new players, the button does not work? .  :o

Using  r8433.


prissi

Are you using a scenario or just a normal savegame? It works for me with normal savegames.

Yona-TYT

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 .

Yona-TYT

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.  ;)

Yona-TYT

@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.  ;)

prissi

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 ...

Yona-TYT

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.


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

Yona-TYT

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.

prissi

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.

Yona-TYT


/// 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?

prissi

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.

MobileRod

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.

prissi

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.

MobileRod

I think I still need to learn a lot before I set a new server. I've been trying, but...

Dwachs

@Yona-TT: I cannot reproduce those problems you describe. I think this is a problem of the scenario script.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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


Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

prissi

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.

Dwachs

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

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.  :-[

prissi

No, it means it should work with the latest nightly. I had just to move the logic. Please continue to test.

Yona-TYT

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

Yona-TYT

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)

prissi



prissi