Page 1 of 1

Auto generate map img

Posted: Tue Jul 26, 2016 8:03 am
by Shirtboy
Hi apologies if this has been posted before I couldn't find it in forum or docs.

How can I automatically generate map images from the server each turn?

Would be happy with a solution that used incron on the saves directory if that was easier

James

Re: Auto generate map img

Posted: Tue Jul 26, 2016 8:10 am
by cazfi
See server command 'mapimg'

Code: Select all

> help mapimg 
Command: mapimg  -  Create image files of the world/player map.
Synopsis: mapimg define <mapdef>
          mapimg show <id>|all
          mapimg create <id>|all
          mapimg delete <id>|all
          mapimg colortest
Level: admin
Description:
  This command controls the creation of map images. Supported arguments:
    define <mapdef>  - define a map image; returns numeric <id>
    show <id>|all    - list map image definitions or show a specific one
    create <id>|all  - manually save image(s) for current map state
    delete <id>|all  - delete map image definition(s)
    colortest        - create test image(s) showing all colors
  
  Multiple definitions can be active at once. A definition <mapdef>
  consists of colon-separated options:
  
  option                 (default)  description
  
  format=<[tool|]format> (magick|gif) file format
  show=<show>            (all)      which players to show
    plrname=<name>                    player name
    plrid=<id>                        numeric player id
    plrbv=<bit vector>                see example; first char = id 0
  turns=<turns>          (1)        save image each <turns> turns
                                    (0=no autosave, save with 'create')
  zoom=<zoom>            (2)        magnification factor (1-5)
  map=<map>              (bcku)     which map layers to draw
  
  <[tool|]format> = use image format <format>, optionally specifying
  toolkit <tool>. The following toolkits and formats are compiled in:
   - 'ppm': 'ppm'
   - 'magick': 'gif', 'png', 'ppm', 'jpg'
  
  <show> determines which players are represented and how many images
  are saved by this definition:
   - 'none'    no players, only terrain
   - 'each'    one image per player
   - 'human'   one image per human player
   - 'all'     all players on a single image
   - 'plrname' just the player named with 'plrname'
   - 'plrid'   just the player specified with 'plrid'
   - 'plrbv'   one image per player in 'plrbv'
  
  <map> can contain one or more of the following layers:
   - 'a' show area within borders of specified players
   - 'b' show borders of specified players
   - 'c' show cities of specified players
   - 'f' show fog of war (single-player images only)
   - 'k' show only player knowledge (single-player images only)
   - 't' full display of terrain types
   - 'u' show units of specified players
  
  Examples of <mapdef>:
   'zoom=1:map=tcub:show=all:format=ppm|ppm'
   'zoom=2:map=tcub:show=each:format=png'
   'zoom=1:map=tcub:show=plrname:plrname=Otto:format=gif'
   'zoom=3:map=cu:show=plrbv:plrbv=010011:format=jpg'
   'zoom=1:map=t:show=none:format=magick|jpg'
For example I have

Code: Select all

mapimg define zoom=1:map=tcub:show=all
in the .serv file I usually load.

Re: Auto generate map img

Posted: Tue Jul 26, 2016 8:41 pm
by dunnoob
Shirtboy wrote:Would be happy with a solution that used incron on the saves directory if that was easier
If you find this easier solution please post it here. What Cazfi wrote is anyway applicable.

Suggestions, stick to ppm:ppm instead of magick:png or similar if you can, the last time I tested it (on Windows) the "magick" boiled down to using 48 bits per pixel for less than 32768 colours, while ppm:ppm will only use 24 bits per pixel.

You don't get a real map in the chosen tileset, you get only a zoomed minimap independent of the tileset. And if you create it "ingame" instead of your better idea to tackle the saves directory there is a rather long "end turn" lag. Too long for me, I never tried it again, depite of plain text (=no time wasted for compression) saved games.

Unreported missing feature: The saved games in ~/.freeciv/saves have names like freeciv-T0529-Y02104-auto.sav (where auto could be also manual, final, or quitidle; T=turn; Y=year). That's not ideal for your idea if you have a mess of *.sav files for different games for different Freeciv versions in ~/.freeciv/saves. A better name could be freeXXX-T0529-Y02104-auto.sav, where XXX is the smallest unused base 32 id. 000..VVV for a new game. Starting at XXX=CIV just for fun and 'cause civilization should be free.

If somebody here has more than 32*32*32 saved games in ~/.freeciv/saves please ask for professional help elsewhere. :P

Re: Auto generate map img

Posted: Tue Jul 26, 2016 9:42 pm
by Shirtboy
Hi cazfi thanks for reply. I'm confident using the mapimg command, is there a way of making it do this automaically every turn? Is that what "the .serv file I usually load" means?

Dunnoob, number and name of saves wouldn't be a problem in this case as server is running on a separate computer that only plays that one game. The incron stuff is not a problem, have set it up to send a tweet whenever a new save appears from an avcount which people have enabled notification for so they get an alert to their phone - it's a very long term game, the last one was over in 4 months due to some mass surrendering! If there was a script to generate a ppm file from the .sav then I'll happily do a guide for the incron as a workaround for people.



cazfi wrote:See server command 'mapimg'

Code: Select all

> help mapimg 
Command: mapimg  -  Create image files of the world/player map.
Synopsis: mapimg define <mapdef>
          mapimg show <id>|all
          mapimg create <id>|all
          mapimg delete <id>|all
          mapimg colortest
Level: admin
Description:
  This command controls the creation of map images. Supported arguments:
    define <mapdef>  - define a map image; returns numeric <id>
    show <id>|all    - list map image definitions or show a specific one
    create <id>|all  - manually save image(s) for current map state
    delete <id>|all  - delete map image definition(s)
    colortest        - create test image(s) showing all colors
  
  Multiple definitions can be active at once. A definition <mapdef>
  consists of colon-separated options:
  
  option                 (default)  description
  
  format=<[tool|]format> (magick|gif) file format
  show=<show>            (all)      which players to show
    plrname=<name>                    player name
    plrid=<id>                        numeric player id
    plrbv=<bit vector>                see example; first char = id 0
  turns=<turns>          (1)        save image each <turns> turns
                                    (0=no autosave, save with 'create')
  zoom=<zoom>            (2)        magnification factor (1-5)
  map=<map>              (bcku)     which map layers to draw
  
  <[tool|]format> = use image format <format>, optionally specifying
  toolkit <tool>. The following toolkits and formats are compiled in:
   - 'ppm': 'ppm'
   - 'magick': 'gif', 'png', 'ppm', 'jpg'
  
  <show> determines which players are represented and how many images
  are saved by this definition:
   - 'none'    no players, only terrain
   - 'each'    one image per player
   - 'human'   one image per human player
   - 'all'     all players on a single image
   - 'plrname' just the player named with 'plrname'
   - 'plrid'   just the player specified with 'plrid'
   - 'plrbv'   one image per player in 'plrbv'
  
  <map> can contain one or more of the following layers:
   - 'a' show area within borders of specified players
   - 'b' show borders of specified players
   - 'c' show cities of specified players
   - 'f' show fog of war (single-player images only)
   - 'k' show only player knowledge (single-player images only)
   - 't' full display of terrain types
   - 'u' show units of specified players
  
  Examples of <mapdef>:
   'zoom=1:map=tcub:show=all:format=ppm|ppm'
   'zoom=2:map=tcub:show=each:format=png'
   'zoom=1:map=tcub:show=plrname:plrname=Otto:format=gif'
   'zoom=3:map=cu:show=plrbv:plrbv=010011:format=jpg'
   'zoom=1:map=t:show=none:format=magick|jpg'
For example I have

Code: Select all

mapimg define zoom=1:map=tcub:show=all
in the .serv file I usually load.

Re: Auto generate map img

Posted: Wed Jul 27, 2016 7:26 am
by cazfi
Shirtboy wrote:is there a way of making it do this automaically every turn?
'mapimg define' is not about saving mapimg once, but it does just what you want; defined mapimgs get saved every turn.

Re: Auto generate map img

Posted: Wed Jul 27, 2016 9:43 pm
by Shirtboy
That's awesome Cazfi! Thank you!

Perhaps the documentation should be clearer on this...

James