Nation Set Modifiability

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
User avatar
GriffonSpade
Elite
Posts: 578
Joined: Mon Apr 29, 2013 4:41 pm

Nation Set Modifiability

Postby GriffonSpade » Fri Dec 22, 2017 9:22 pm

So, I'm looking at the Nation Set implementation, and it's very...tedious. It works perfectly for existing nation sets, of course, but modification and creation are not so. Instead of being able to easily modify or create nation sets (and groups) to personal taste, instead, each and every nation ruleset file is a dependency that has to be modified. Worse, these files aren't ruleset specific, but a common set of dependent files used by most rulesets.

For example, if you want to make a new nation set of 100 of the existing nations, you need to not only edit nationlist.ruleset, but every single one of the 100 nations you want to add to the list.

It feels like instead of declaring a nation set in each nation's ruleset file, it would do better if each nation set had a ruleset file that listed nations in it. This would make adding more nation sets similar to adding more individual nations, easily added and modified in individual files needing only adding references in their master file.
So, in addition to the default 'all' nation set, "Core" nation set file would be *included, along with an override file for easily adding new nation lists, same as nations, as such:

*include "nationset/core.ruleset"
*include "override/nationset.ruleset"

As an aside, it would also allow an "initial_government" to be declared for each nation if declared like things in nation ruleset files.

User avatar
dunnoob
Elite
Posts: 326
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Re: Nation Set Modifiability

Postby dunnoob » Sat Dec 23, 2017 7:35 am

GriffonSpade wrote:Instead of being able to easily modify or create nation sets (and groups) to personal taste, instead, each and every nation ruleset file is a dependency that has to be modified.
Yeah, it's rather odd, and whatever problem the override feature tried to solve, I fear that it's useless on Windows: Known FREECIV_DATA_PATH issue, on Windows the last resort install/data is simultaneously the second choice ./data after the current directory . as first choice.)

The alien ruleset is often a good place to check how non-standard stuff works, e.g., it shows how to add various nations. Roll your own nation group is arguably hopeless, you'd need copies of all affected nations, and edit the groups = lines. For one private nation it's relatively simple, I added a group sisters to the natives, and defined the group in my radius/nations.ruleset:

Code: Select all

[datafile]
description             = "Add radius/native.ruleset in nationgroup Sisters"
options                 = "+Freeciv-2.6-ruleset"

[ruledit]
; Nationlist to add include statement for. If this entry is omitted, nations
; will be saved to nations.ruleset itself.
nationlist              = "default/nationlist.ruleset"

; List of nations to embed to main nations.ruleset despite separate nationlist
; being used for other nations.
embedded_nations        = "barbarian", "pirate", "native"

[compatibility]
default_government      = "Despotism"

;allowed_govs            = "Anarchy"     ; ... handled in included defaults.
;allowed_terrains        = "Ocean"       ; ... handled in included defaults.
;allowed_city_styles     =               ; ... handled in included defaults.

[default_traits]
; If a nation defines no trait values the defaults defined here are used.
; If the server option 'traitdistribution' is FIXED (default) the values
; defined as <trait>_default are used.  For EVEN distributions a random
; value from <trait>_min up to <trait>_max is used.
; The maximal trait value is 2500 (50*50).  For a missing <trait>_min or
; <trait>_max the ultimate default is 50.  For a missing <trait>_default
; the ultimate default is (min+max)/2.

; Used as val/50 (daidomestic) or 50/val (aicity)
expansionist_min         = 10            ; \/ FIXED default 40=(10+70)/2
expansionist_max         = 70            ; /\

; Used as val/50 (daieffects+daidomestic) or as is (daidomestic)
trader_min               = 30            ; \/ FIXED default 60=(30+90)/2
trader_max               = 90            ; /\

; ONLY used as sqrt(val/50) in daidiplomacy
aggressive_min           = 20            ; \/ FIXED default 50=(20+80)/2
aggressive_max           = 80            ; /\

;[nset_full]
;name                    = _("?nationset:Full")
;rule_name               = "all"

; The included "default/nationlist.ruleset" defines "core" and "all",
; and this ruleset needs no additional nation sets.

[ngroup_sisters]
name                    = _("?nationgroup:Sisters")
match                   = 2

; The included "default/nationlist.ruleset" defines the traditional
; nation groups Medieval, Imaginary, Modern, Oceanian, etc.

*include "default/nationlist.ruleset"
*include "nation/barbarian.ruleset"
*include "nation/pirate.ruleset"
*include "radius/native.ruleset"


In theory I want group sisters in all nations with more than one female leader, but that's for later after all invalid SVGs are valid. :D But at least the sisters group (with one member natives) is now offered as first choice on the "pick a nation" window, only the Aleut flag is still not as it should be (after four years, everything about flags takes five or more years.)

GriffonSpade wrote:As an aside, it would also allow an "initial_government" to be declared for each nation if declared like things in nation ruleset files.
At the moment all ( :?: ) nations have three empty lists init_techs, init_buildings, init_units.

I vaguely recall that the help for nations always reported an "init government is despotism", presumably triggered by the line default_governement = "Despotism" in the [compatibility] section of the nations.ruleset. So maybe init_government or default_government or similar also works per nation, and maybe you could overwrite these init_* strings immediately after the *include "what/ever.ruleset".

There's a trick how to permit more than one value in a ruleset, i.e., the last section.name value counts instead of an immediate crash caused by more than one value per section.name. IOW, if that works it's limited to name=value lines in the last section and depends on the options. And last section is no issue for a nation, each nation consists of one section.

cazfi
Elite
Posts: 1710
Joined: Tue Jan 29, 2013 6:54 pm

Re: Nation Set Modifiability

Postby cazfi » Wed Dec 27, 2017 10:02 am

dunnoob wrote:
GriffonSpade wrote:Instead of being able to easily modify or create nation sets (and groups) to personal taste, instead, each and every nation ruleset file is a dependency that has to be modified.
Yeah, it's rather odd, and whatever problem the override feature tried to solve, I fear that it's useless on Windows: Known FREECIV_DATA_PATH issue, on Windows the last resort install/data is simultaneously the second choice ./data after the current directory . as first choice.)

Umh... that would mean that no custom modpack (installable via modpack installer) currently works on Windows. They get installed under home directory, and work on the assumption that that directory is first in FREECIV_DATA_PATH.

User avatar
dunnoob
Elite
Posts: 326
Joined: Mon Dec 23, 2013 3:13 am
Location: Hamburg
Contact:

Re: Nation Set Modifiability

Postby dunnoob » Wed Dec 27, 2017 9:11 pm

cazfi wrote:Umh... that would mean that no custom modpack (installable via modpack installer) currently works on Windows. They get installed under home directory, and work on the assumption that that directory is first in FREECIV_DATA_PATH.
The WhatsItsName, DATA_SUBDIR, i.e., ~/.freeciv/2.5 (or 2.4, 2.6, dev), is the 3rd choice after dot and dot/data, and it works as designed (on Windows and elsewhere) for everything not already found in dot and dot/data.

But with the current scripts it does not allow to overwrite the last choice install/data on Windows, where this last choice is simultaneously the 2nd choice, HRM#696736, formerly known as Gna#22781.

My latest and greatest "one script to rule them all" makes sure, that the install directory is not the start directory, i.e., install/data and dot/data are forced to be different. While at it my ersatz-start directory ~/.freeciv is writable without admin rights even on Windows:

Code: Select all

@echo off
setlocal enableextensions
if not exist "%~dpn0.exe" goto FAIL
if /I not "%~1" == "AUTO"  set LANG=%~1
set QT_PLUGIN_PATH=%~dp0\plugins
set OPTS=
rem put arg.s %* (excl. 1st token AUTO or locale) in OPTS:
for /F "usebackq tokens=1*" %%x in ('%*') do set OPTS=%%y
rem hop to writable ~/.freeciv if CWD is installation dir:
if /I "%CD%\" == "%~dp0"  call :PATH %~dp0
start "%~n0" /D . "%~dpn0.exe" %OPTS%
if not errorlevel 1 goto :EOF
if     errorlevel 1 goto FAIL
:PATH ---------------------------------------------------------
set DSUB=%*
rem replace \freeciv- by : (will be 2nd and last colon)
set DSUB=%DSUB:\freeciv-=:%
rem 3rd token after 2nd colon in x:\where:x.y.z-stuff
set SCAN="delims=: tokens=3"
set TEST=
for /F %SCAN% %%x in ("%DSUB%") do set TEST=%%x
rem get x.y in x.y.z-what
set SCAN="delims=. tokens=1,2"
set DSUB=
for /F %SCAN% %%x in ("%TEST%") do set DSUB=%%x.%%y
if     "%DSUB%" == "" goto :EOF
rem give up if no version x.y found in path, else hop to
rem writable ~/.freeciv and adjust the FREECIV_DATA_PATH
cd %APPDATA%\.freeciv
set DSUB=%CD%\%DSUB%
set TEST=%FREECIV_DATA_PATH%
if not "%TEST%" == "" set FREECIV_DATA_PATH=%TEST%;%*data
if     "%TEST%" == "" set FREECIV_DATA_PATH=%DSUB%;%*data
goto :EOF
:FAIL ---------------------------------------------------------
echo Error: Cannot start %~dpn0.exe
echo Usage: %~nx0 [AUTO^|locale [opts]]
echo/
echo Temporarily sets LANG=locale (or ignores AUTO) and starts
echo %~dpn0.exe [opts]
echo LANG=C or LANG=en-US always work.  If LANG is undefined
echo Freeciv uses the Windows region to find a suited locale.
echo/
pause