The International Simutrans Forum

 

Author Topic: Method to request map graphic from running Simutrans server  (Read 3001 times)

0 Members and 1 Guest are viewing this topic.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Method to request map graphic from running Simutrans server
« on: February 06, 2011, 12:19:58 AM »
Another server-related request here. It'd be really useful if there was a way to query a Simutrans server for an image representation of the game map. This would be a stateless request (e.g. it could be done from a non-Simutrans program, e.g. server management software) which would make a nice addition to game server listings.

Ideally some options could be specified in the request to enable/disable the options on the map (e.g. turn on city names, or station coverage, etc.) - basically anything you can set on the map dialog in-game.

The map could be returned in any format, whatever is easiest for implementation (the format of the mini-map returned by the gameinfo request is fine). I can easily process the resulting data into an image of the appropriate format.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18679
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Method to request map graphic from running Simutrans server
« Reply #1 on: February 06, 2011, 12:50:59 AM »
I support this idea - it would be rather wonderful.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9507
  • Languages: De,EN,JP
Re: Method to request map graphic from running Simutrans server
« Reply #2 on: February 06, 2011, 09:58:32 PM »
A 64x64 map is already sended with the gameinfo, which is (always) in xml format.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #3 on: February 06, 2011, 10:49:01 PM »
A 64x64 map is already sended with the gameinfo, which is (always) in xml format.

I know - I've already written some code to convert this to a .png. It would be nice to be able to get a full-size map as well, but from a separate request (since I don't want to bloat the gameinfo request). Being able to get a full-size map out would provide some nice options for presenting information about games in progress, or to show a history of how a network game progresses over time (e.g. taking a snapshot every hour or so). Kind of like a time-lapse movie for example. I can think of lots of applications for this :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9507
  • Languages: De,EN,JP
Re: Method to request map graphic from running Simutrans server
« Reply #4 on: February 06, 2011, 11:06:23 PM »
But making a full scale map can easily take 5s on a 4096x4096 map and still a second or so on 1024x1024. It could really affect gameplay, if requested too often.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #5 on: February 06, 2011, 11:08:47 PM »
5 seconds? I am talking about the mini-map, not taking a screenshot of the entire game. E.g. producing a graphic like this:


Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 18679
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Method to request map graphic from running Simutrans server
« Reply #6 on: February 06, 2011, 11:47:29 PM »
Socks River...?

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #7 on: February 06, 2011, 11:51:03 PM »
pak96.comic has a really strange city name list :D

Offline sdog

  • Devotee
  • *
  • Posts: 2039
Re: Method to request map graphic from running Simutrans server
« Reply #8 on: February 07, 2011, 06:56:40 AM »
Even 5s for a full map image wouldn't be much if done every hour, it could provide quite interesting time lapse movies of a simutrans network game developing over days.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9507
  • Languages: De,EN,JP
Re: Method to request map graphic from running Simutrans server
« Reply #9 on: February 07, 2011, 09:19:37 AM »
The minimap is only updated once a month, or when needed (i.e.) visible. A small map like 256x256 is indeed neglible. But 2048x2048 takes time (not to mention the 100kB data transfer of the bitmap.)

One can think to render this bitmap anyway every season change. But I fail to see the point: What further information can be gained, that is not already there from the 64x64 bitmaps and the text info? A Webseite with all maps would show anyway only smaller sized images.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #10 on: February 07, 2011, 10:04:35 AM »
Ah I hadn't realised it worked this way.

Data transfer isn't necessarily an issue, since I was intending to use this locally (from the same machine).

As for more information, there's a wealth of information which can be accessed via the minimap. All of the filter views (e.g. station coverage, which can give a nice indication of how well-developed the map is by other players), location of cities, congestion etc. Having a snapshot of this every half hour or so would be really useful as a way to record the progression of a game.

Does creating the map need to interrupt gameplay? It doesn't seem to when I open the minimap in-game, even with larger maps. For the typical sizes of network games (I'd imagine 1024x768 or so would be the largest I'd personally consider running. Even 768x512 is large enough) I think this would be a really useful addition.

Maybe to prevent abuse of the feature have the ability to filter by IP address who can request the information, so you can restrict it to localhost only? That would alleviate the issue of too many people polling for the information at once.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9507
  • Languages: De,EN,JP
Re: Method to request map graphic from running Simutrans server
« Reply #11 on: February 07, 2011, 10:38:58 AM »
I think you should just consider to add this feature for yourself. But it will not be too easy on a posix server, as there are no graphics routines available (since those are explicitely deactivated). Perhaps you should rather stick with the 64x64 map and the other informations for now.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #12 on: February 07, 2011, 11:07:46 AM »
Hm, it may be easier to just parse the savegame and generate a similar map representation directly from that. I'll look into it, sometimes we don't get what we want so easily and that's fine :)

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 9507
  • Languages: De,EN,JP
Re: Method to request map graphic from running Simutrans server
« Reply #13 on: February 07, 2011, 12:19:14 PM »
The savegame is not XML, as it would take up to 3x longer to transfer it.

I mean, a height map is generated easily, as well as any functional maps from the minimap window. If you want local access, you can then just writ a binary ppm, this does not need any additional functions and would be an easy local addon. But you cannot show text, as there is no font rendering capability.

Offline Ashley

  • Coder/Patcher
  • Devotee
  • *
  • Posts: 1288
    • entropy.me.uk
Re: Method to request map graphic from running Simutrans server
« Reply #14 on: February 07, 2011, 01:52:15 PM »
The XML-ness of the gameinfo object actually doesn't make it that much easier to parse (none of the XML tags have any indication as to what they do, beyond their position in the file). The only advantage it confers is knowing where one value begins and another ends. If it wasn't XML and was just a binary representation then struct unpacking tools could do a roughly similar thing (as they could for the savegame format I believe).

I think you're probably right that this is better done locally by saving out a file from the game itself to the machine it is running on though. I'll investigate that possibility.