News:

Simutrans Forum Archive
A complete record of the old Simutrans Forum.

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.