--Warnings from Freeciv & scenario Lua content vs newer Freeciv versions

Various topics about the game, the website, or anything else Freeciv related that doesn't fit elsewhere.
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

--Warnings from Freeciv & scenario Lua content vs newer Freeciv versions

Post by Molo_Parko »

I get a set of warnings about unused settings in scenario files, by which I take it that the settings values are identical to what my version of Freeciv 2.6.4 would supply even if those settings were not in the file.

The settings (and default values) in question were supplied by Freeciv 2.6.4 when I start a new game, and then save the game as a scenario file.

When I remove those settings, the warnings stop and the scenario works fine, here. However, I am wondering if there is some 'gotcha' if the scenario were then run on a different version of Freeciv which might not supply the same default values? If so then I'll continue leaving those settings in the scenario files.
Last edited by Molo_Parko on Mon Dec 02, 2024 5:30 am, edited 2 times in total.
cazfi
Elite
Posts: 3335
Joined: Tue Jan 29, 2013 6:54 pm

Re: --Warnings from Freeciv

Post by cazfi »

What is the exact warning? "Unused entry" is something that is not read from the file at all - not even to compare with the default value of the setting.

Settings values identical to default values can either "follow" the default (from freeciv version to another), or to be explicit.

Freeciv-2.6.4 is really old. I can't remember what bugs related to all this it had. Can you attach an example scenario file for me to check the situation?
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

Re: --Warnings from Freeciv

Post by Molo_Parko »

"The Gridiron" is one, posted here: https://forum.freeciv.org/f/viewtopic.php?p=110033

Image

The errors are only evident when running Freeciv with --warnings command line option.
All of the warnings are resolvable by removing the "unused" entries from the scenario, but does that cause problems in any later version?

The values of the various unused entries are the same in Freeciv 2.6.4 whether or not the settings are included in the file. But would the same default values be supplied when the scenario is loaded in Freeciv 3.2? To put it another way, do future versions of Freeciv include a list of which default settings were used in prior versions of Freeciv?
cazfi
Elite
Posts: 3335
Joined: Tue Jan 29, 2013 6:54 pm

Re: --Warnings from Freeciv

Post by cazfi »

In your screenshot, there's no settings at all. All the unused entries are something else. Most of them fixed in 2.6.8 ( https://www.freeciv.org/wiki/NEWS-2.6.8 )

Loading the The Gridiron to S2_6 HEAD (latest freeciv-2.6) gives a couple of unused entry warnings, but those are not about settings.

Code: Select all

2: ./../../../saves/Gridiron.sav: unused entry: scenario.game_version
2: ./../../../saves/Gridiron.sav: unused entry: game.random_seed
2: ./../../../saves/Gridiron.sav: unused entry: game.save_known
2: ./../../../saves/Gridiron.sav: unused entry: map.random_seed
If a setting is left as "default" in the savegame/scenario, it's loaded as "default" in the newer versions even when the default has changed.
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

Re: --Warnings from Freeciv

Post by Molo_Parko »

cazfi wrote: Wed Nov 27, 2024 4:45 pm In your screenshot, there's no settings at all.
Because they are not in the [settings] section of the .sav file? I'll use the term "values" instead.

EDIT: Or did you mean that the values aren't the problem, rather it is a bug?

cazfi wrote: Wed Nov 27, 2024 4:45 pmIf a setting is left as "default" in the savegame/scenario, it's loaded as "default" in the newer versions even when the default has changed.
^ That is exactly what I was worrying about. So if a scenario or embedded Lua script expects / requires a certain value for an optional feature, then it should be explicitly included in the scenario file. For example in "The Gridiron", failing to include ' "animals",0 ' in the [settings] section of the .sav file could result in animals on the football field for any user who has a default "animals" value greater than 0.

Furthermore there is no way to know what additional features might come with as yet unreleased versions. That has actually already occurred with the "animals" option not being implemented in Freeciv 2.6.4, but it does apply to now existing later versions. In short, there is no way within a scenario to guarantee that the gameplay experience will be the same in both versions 2 and 4 (an as yet unreleased version.) Which may necessitate upgrading all scenario files for each new version (the "animals" option appeared in a minor version upgrade, I believe) to prevent new features from defaulting to an active state despite that they did not even exist in the version with which the scenario was created.

A more automated remedy might be to have the Freeciv app disable any newer features which did not exist in the version of Freeciv which created the scenario file, such that loading a 2.6.4 scenario file would result in "animals" being disabled in version 3 for the duration of the scenario game rather than being enabled with whatever default value is in use in the newer version.

EDIT: Also, it is possible via the "server.save()" command to save a game file prior to gamestart, and doing so results in incorrect or missing values compared to the chosen game options. "aifill" 1,5 just before gamestart becomes 1,1 after gamestart (and the latter is the actual value that I specified.) That should probably generate a warning on using server.save() prior to gamestart.

EDIT2: I downloaded and compiled Freeciv 2.6.11 source. Works.

Image

Image
^ Ah, the direction/facing stuff got fixed.

Image
But E.REPORT still goes to Chat pane on turn 0, Messages thereafter.

Still no documentation on Players and player traits in the 2.6.11 Help menu, nothing on Lua either, and both seem like they ought to be mentioned somewhere in the client.
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

Re: --Warnings from Freeciv

Post by Molo_Parko »

I am trying to figure out how to determine (in Lua script) whether the currently running scenario has set all possible optional values for the currently running Freeciv software version in use ( to detect if new features exist which should be disabled for a scenario generated on an older version of Freeciv. )

I moved my Freeciv client rc file, ran 2.6.4 server and "/show all", getting all default values. Repeated that for 2.6.11, and there are no differences in default values between 2.6.4 and 2.6.11. Not surprising.

But, Lua script in Freeciv apparently has no way to know what other (new) features are in the currently running version of the software, so I can't even begin to disable them to ensure that the scenario behaves the same on a newer version as it does on an older version. Is there a feature in Freeciv 3 that would allow listing all possible options that could be in a Freeciv 3 scenario file? To be able to determine within a Lua script that new options exist and should be disabled for the duration of the scenario.

I gathered the "field" or var name entries from the default values list of v2.6.11:

Code: Select all

option_names={ "aifill", "airliftingstyle", "allowtake", "alltemperate", "animals", "aqueductloss", "autoattack", "autosaves", "autotoggle", "barbarians", "borders", "citymindist", "citynames", "civilwarsize", "compress", "compresstype", "conquercost", "contactturns", "demography", "diplbulbcost", "diplchance", "diplgoldcost", "diplomacy", "disasters", "dispersion", "ec_chat", "ec_info", "ec_max_size", "ec_turns", "endspaceship", "endturn", "first_timeout", "fixedlength", "flatpoles", "foggedborders", "fogofwar", "foodbox", "freecost", "fulltradesize", "gameseed", "generator", "globalwarming", "gold", "happyborders", "homecaughtunits", "huts", "kicktime", "killcitizen", "killstack", "killunhomed", "landmass", "mapseed", "mapsize", "maxconnectionsperhost", "maxplayers", "mgr_distance", "mgr_foodneeded", "mgr_nationchance", "mgr_turninterval", "mgr_worldchance", "migration", "minplayers", "nationset", "naturalcitynames", "nettimeout", "netwait", "notradesize", "nuclearwinter", "occupychance", "onsetbarbs", "persistentready", "phasemode", "pingtime", "pingtimeout", "plrcolormode", "rapturedelay", "razechance", "restrictinfra", "revealmap", "revolen", "revolentype", "savefrequency", "savename", "savepalace", "saveturns", "sciencebox", "scorefile", "scorelog", "scoreloglevel", "separatepoles", "shieldbox", "singlepole", "size", "specials", "startcity", "startpos", "startunits", "steepness", "team_pooled_research", "teamplacement", "techlevel", "techlossforgiveness", "techlossrestore", "techlost_donor", "techlost_recv", "techpenalty", "temperature", "tilesperplayer", "timeaddenemymove", "timeout", "tinyisles", "topology", "trademindist", "trading_city", "trading_gold", "trading_tech", "traitdistribution", "turnblock", "unitwaittime", "unreachableprotects", "victories", "wetness", "xsize", "ysize" }
Then this to get the current values of those via Lua script:

Code: Select all

for i = 1, #option_names, 1 do
	log.error("%s",option_names[ i ] .. string.rep( " ", ( 21 - string.len( option_names[ i ] ) ) ) .. "\t=\t" .. server.setting.get( option_names[ i ] ) )
end
BUT, I am already stumped as to how a Lua script could determine whether the currently running Freeciv client has additional, new features and parameters ( since server.setting.get( name ) relies upon the scenario already knowing the name of the feature/option ) ?

If v3 had a new feature "alienencounters" how could a Lua script know that the new feature exists on the running version of the software?

Ideally the script would be able to /show all and get the full list of optional values from the current running version. Any entry that is not "known" is therefor a new feature. Or perhaps a "settings_iterator()" that loops through all [settings] for the running version of Freeciv?

Then the next hurdle will be whether or not the values for the new features can be disabled or otherwise changed just before gamestart. Would require knowing what constitutes "disabled" -- if the new feature's [settings] entry uses numeric values, then presumably 0. If it uses a quoted string, then possibly "DISABLED"?

EDIT3orso: Found some real-world examples of newer features by looking at Fc3 and 3.1 sav files that have been attached to posts here. These [settings] entries aren't found in prior version 2.6.11, and might alter a scenario's behavior / "feel" when the scenario is loaded in v3 or 3.1.

Freeciv 3.0
"caravan_bonus_style","CLASSIC","CLASSIC"
"multiresearch",FALSE,FALSE
"nuclearwinter_percent",100,100
"techleak",100,100
"trade_revenue_style","CLASSIC","CLASSIC"
"tradeworldrelpct",50,50

Freeciv 3.1
"caravan_bonus_style","CLASSIC","CLASSIC","Changed"
"incite_gold_capt_chance",0,0,"Internal"
"incite_gold_loss_chance",0,0,"Internal"
"multiresearch",FALSE,FALSE,"Changed"
"nuclearwinter_percent",100,100,"Changed"
"techleak",100,100,"Changed"
"tradeworldrelpct",50,50,"Changed"

Those examples are the sort of 'new settings' I would like to set to "DISABLED" or 0 via Lua script just before gamestart (in a version of FC > the version that created the scenario ) so that the scenario behavior in the newer Fc version would be as close as possible to the version of Fc on which the scenario was created.
cazfi
Elite
Posts: 3335
Joined: Tue Jan 29, 2013 6:54 pm

Re: --Warnings from Freeciv

Post by cazfi »

Note that almost always the default value of the new settings match the previously hardcoded behavior, so to reproduce old version's behavior in a newer version you would not want to change them from the default.
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

Re: --Warnings from Freeciv

Post by Molo_Parko »

^ Right, but as of this point in Lua, it can't determine whether or not Settings entries from a --newer-- version of Freeciv exist in the currently running Scenario. Lua can't "/show all" so there is no way for Lua to get a list of what Settings entries are possible. I'd have to hardcode the names of Settings from version 3 into the scenario, but then the same problem would occur again at version 4. I'd rather have a settings_iterator or Lua access to the "/show all" list and have Lua be able to react to new Settings automagically. :)
cazfi
Elite
Posts: 3335
Joined: Tue Jan 29, 2013 6:54 pm

Re: --Warnings from Freeciv

Post by cazfi »

My point is that since your lua script cannot know what is the setting value you want, it's better for it not to do anything. Instead rely on the defaults, and sometimes automatic savegame conversions (e.g. cases where a setting is renamed - you want to keep the old value)
Molo_Parko
Hardened
Posts: 200
Joined: Fri Jul 02, 2021 4:00 pm

Re: --Warnings from Freeciv

Post by Molo_Parko »

Yes, that makes sense. The scenario script could just detect a version # change and pop-up a message
"Your version of Freeciv was created after this scenario. Newer features may alter the scenario game experience. If that occurs try changing the settings for these newer features:
"alienencounters"
"probed_units_become_zombie_barbarians"
Post Reply