Accounts e-mail HP

Loading predesigned Maps (half scenarios)

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!

Loading predesigned Maps (half scenarios)

Postby Kasei » Mon Sep 02, 2013 5:10 am

Hi

Back in warciv there was/is an option to load a predesigned map, which included startpositions, tiles/layout of the map and the position of resources and rivers.
There were no nation associated which each startpos, so this was free to choose by each player.
I wrote most of the code to do this back then.
In contrast a normal scenario has a nation and its startposition fixed.

I transfered my old code from warciv over to freeciv 2.3.4, so this works again. :)
But this is still not really tested so be prepared for bugs etc.
If you find any bug please write me a note/message.

Attached you find a diff from a vanilla freeciv_2.3.4 except the new data/maps/ subdirectory and its content.
Maps should be found in this "maps" subdirectory of the data directory.
With these you have 3 new commands on a server:

Code: Select all
/showmaplist

This will list all loadable mapfiles of the server. These maps should be in any maps subdirectories.

Code: Select all
/unloadmap

This will unload a map if you loaded one but do not want to play it.

Code: Select all
/loadmap <mapnumber or mapname>

This will load a map. You can give the full mapname without the .map or the number of the map in /showmaplist to specify which map should be loaded.
Atm all players will be removed so you have to retake an AI to play.

I also wrote a python script to create the map files freeciv loads from pngs.
You need 2 pngs with the same name, one end with 1.png the second with 2.png. The first contains the tile information, the second the information for startposition,resources and rivers. You can use for examble gimp to draw maps, save these as pngs and then use the script to create the .map file.
At the moment the script does not work with ISO topology maps. You can set topology to iso, but then the map will look different from what you have drawn.
The pythonscript is easy to use: Copy pngtomaps.py and png.py into the folder containing the pngs and do:
Code: Select all
python pngtomaps.py

and follow the instructions.

Attached:
The diff from vanilla freeciv 2.3.4
The python scripts png.py and pngtomaps.py in pngtomaps.tar.gz .
Freecivmapcolors.png holds the colors for each tiletype used in the python script. You will need this if you want to draw your own maps. Open it with gimp and you can simply pick up colors from it which makes the drawing faster.
A maps.tar.gz with some maps and also examble pngs and xcf files.

Cheers,
Kasei

PS. it is late so please excuse any spelling errors etc. :D
Attachments
loadmaps_v1.diff.tar.gz
The freeciv server code patch file
(5.82 KiB) Downloaded 201 times
pngtomaps.tar.gz
Python script to create map files from pngs.
(52.11 KiB) Downloaded 186 times
maps.tar.gz
Content of a maps folder.
(96.78 KiB) Downloaded 194 times
freecivmapcolors.png
Freecivmapcolors.png holds the colors for each tiletype. You will need this if you want to draw your own maps. Open it with gimp and you can simply pick up colors from it which makes the drawing faster.
Kasei
 
Posts: 4
Joined: Fri Aug 02, 2013 2:23 pm

Re: Loading predesigned Maps (half scenarios)

Postby Davide » Mon Sep 02, 2013 9:06 am

Great job!
I'll try to have a look at the code by evening. Eventually you could also propose upstream the scenario loader, at gna.org.
User avatar
Davide
 
Posts: 864
Joined: Sat Mar 24, 2012 12:34 am

Re: Loading predesigned Maps (half scenarios)

Postby Kasei » Mon Sep 02, 2013 6:51 pm

Thanks davide.

One thing to fix is that the autosave produces a warning because of the added map_is_fixed setting.

Here is now also the pngtomaps.py script which can now also handle isometric maps.

For isometric maps the png should have a mask like in the picture below with a color that is not otherwise used, like e.g. RED.
The png should only have 2 valid pixels in the first and last row, and only 1 in the first column and last column.
By design the height of that png is also always 1 pixel less than the width. The png will be read as North pointing toward the topleft.

The attached png shows a example how a isometric map png can look like.

Cheers,
Kasei
Attachments
2seperatekingdomsofice1.png
Maplayout. The red part is the mask, not part of the final map in freeciv. See the layout of that mask if you draw your own isometric maps.
2seperatekingdomsofice1.png (600 Bytes) Viewed 2702 times
2seperatekingdomsofice.tar.gz
A isometric map; pngs, xcf and map file included.
(3.2 KiB) Downloaded 196 times
pngtomaps.tar.gz
Python script to create map files from pngs. Now also handles isometric maps.
(84 KiB) Downloaded 202 times
Kasei
 
Posts: 4
Joined: Fri Aug 02, 2013 2:23 pm

Re: Loading predesigned Maps (half scenarios)

Postby Kasei » Thu Sep 26, 2013 11:40 pm

Ok,

here is a newer version of the code, removes a savegame warning.
Also removes /showmaplist from the votable commands.

Will look into uploading it at gna.org

Cheers
Kasei
Attachments
loadmaps_v2.diff.tar.gz
The freeciv server code patch file
(5.63 KiB) Downloaded 202 times
Kasei
 
Posts: 4
Joined: Fri Aug 02, 2013 2:23 pm


Return to Contribution

Who is online

Users browsing this forum: No registered users and 1 guest

cron