[Freeciv-Dev] Re: mapgenerator6 - single continent [cvs diff -u]
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
At 11:37 PM 02/10/27 -0500, =?BIG5?B?vbKr7bXY?= =?BIG5?B??= wrote:
>
>> mapgen.c is largely a replacable plugin. Ideally, one would just exec a
>> standalone program that generated a map in the starting civgame.sav.gz
>
>I would like to suggest popen() the standalone mapgen and read the
>map from its stdout. All the parameter can be passed as *argv[].
>For example: /set generator "fractal --forest=15 --xdiv=9"
>
>To load a save game: /set generator "gzcat civgame.sav.gz"
>A modularize generator could be implemented as two executables:
>/set generator "heigthmap --xdiv=9 | terrain --forest=15"
Yes, and a neat thing is you don't even need to use "C" for the mapgen
programs if you don't want to :-).
>To avoid long user specify command line arguments, frequently used
>defaults can be implemented as a shell script.
Shell scripts are a great way to glue a standard server command to
a variety of mapgen programs each with different rather hardcoded input
options. This can be used to do command transformations, or just to
load the environment with lots of property definitions for a given
generator to suck in with getenv() overrides.
>Of course, there are certain issues:
>1. Can other platforms support popen()? If not, is
>"mapgen > civgame.sav; server -f civgame.sav" an acceptable workaround?
popen is POSIX and most OSes support this nowadays in one way or another.
But it is trivial to have the server save its current pre-mapgeneration
savegame, update it with the mapgen program and have the server wait
for the OK to reload the savegame and continue. The server should save a
savegame before the start of play (as in corecleanups) anyway, so there
is nothing new one is adding. This is by far a simpler solution.
>2. Trusted/restricted shell to execute the generator? Any other
>concerns from civserver admins?
There are lots of security concerns, but generally you do not let the
client type in an arbitrary command for map generation, or allow the
mapgeneration tools to be located by an arbitrary PATH. Having the
server admin "import" a list of trusted programs in a known server
location and select them by index is usually a pretty safe way to
handle most of these.
In any event, the server internal command is pretty much going to be
the same for every mapgen program. Or it is a good idea to define the
output interface that the server uses to send its idea of what needs
to be done. All that needs to change is the way to say which program
the rulesets or commandline choice want to run.
And ...
3) popen pipes have finite capacity. There may be issues with deadlocking
if the server -> mapgen -> server transfers are not serialized properly.
This can happen if there are several interlarded exchanges and both are
trying to write to full pipes instead of one of them reading to clear the
logjam, or both are reading and no one is sending.
4) A lot of information needs to be transferred beyond the arguments of
the command in order to create a recognizable savegame map. The easiest
way to do this is to use the savegame/loadgame commands already builtin
to the server and have the mapgen program understand this to do a
loadmap/savemap update. A side effect of this is you can use preset
savegames to store many default parameter settings for a standalone
mapgen execution. You just tweak a few commandline parameters after
loading something "close" or merging several option sets.
>Regards,
>I.Q.
>--
>__________________________________________________________
>Sign-up for your own FREE Personalized E-mail at Mail.com
>http://www.mail.com/?sr=signup
This is the sort of interface you might need to run the current
mapgen. It still would need to get a lot of information from a
template savegame file in order to make the output format match
something readable by the current server. For example, none of
the TERRAIN TYPES or SPECIAL definitions (which are ruleset
modifiable) are handled by these options. This is just the map
generation control parameters.
static char *USAGE = "
Usage: civmap [--verbose [0==off|1==normal|2==debug]]
[--file {filename|$CIVMAPFILE|"civmap.sav.gz"}]
[--outfile {filename|$CIVMAPFILE|"civmap.sav.gz"}]
[--seed {1-ULONG_MAX}]
[--generator {1-5}]
[--maptype {0-7|EARTH_ISO==5}]
[--options is_earth,tinyisles,separatepoles,
has_huts,has_specials,fixedstart]
[--riches {0-landtiles/3}]
[--huts {0-landtiles/5}]
[--players {1-MAX_NUM_NATIONS}]
// Simple
[--size {small|normal|large}]
[--landtype {[~]archipelago|normal|pangea}]
[--age {old|normal|young}]
[--wet {dry|normal|wet}]
[--temperature {cold|cool|normal|warm|hot}]
// Advanced parameters
[--geometry 80x50]
[--landpercent 33]
[--terrain {"default"|index|name}.percent]
[--river {"default"|index|name}.percent]
[--special {"default"|index|name}.percent]
"
Cheers,
RossW
=====
|
|