News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Method to request map graphic from running Simutrans server

Started by Ashley, February 06, 2011, 12:19:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ashley

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.
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

prissi

A 64x64 map is already sended with the gameinfo, which is (always) in xml format.

Ashley

Quote from: prissi on February 06, 2011, 09:58:32 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 :)
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

prissi

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.

Ashley

5 seconds? I am talking about the mini-map, not taking a screenshot of the entire game. E.g. producing a graphic like this:

Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

jamespetts

Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ashley

Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

sdog

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.

prissi

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.

Ashley

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.
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

prissi

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.

Ashley

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 :)
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

prissi

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.

Ashley

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.
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.