View Issue Details

IDProjectCategoryView StatusLast Update
0005453The Dark ModDesign/Codingpublic19.05.2024 09:53
Reporterduzenko Assigned Tostgatilov  
PrioritynormalSeverityfeatureReproducibilityalways
Status feedbackResolutionopen 
PlatformPCOSWindowsOS Version10
Product VersionSVN 
Target VersionTDM 2.13 
Summary0005453: Rethink how FM's should override cvars
Description1. Are the mappers supposed to override the cvars via the local copy of autoexec.cfg?
2. If so, are they supposed to include the default autoexec.cfg content in their copy?
3. If so, what about future-compatibility?
Steps To ReproduceInstall "Crucible of Omens: Behind closed doors"
Restart TDM
Press the console (tilde) key
TagsNo tags attached.

Relationships

related to 0000833 confirmed Add mapvars options for extra variations 
related to 0005926 resolvednbohr1more tdm_player_thief.def needs to contain default pm_runmod value 
related to 0003934 resolvednbohr1more some values in autocommands.cfg are not kept when starting a mission. 
parent of 0005892 resolvednbohr1more Cant mantle while carring a body 
related to 0006530 assignedstgatilov Make script constants customizable by mission 

Activities

nbohr1more

nbohr1more

05.02.2023 18:29

developer   ~0015929

Last edited: 05.02.2023 18:31

If we are to allow cvar customization per map, we should look into resurrecting \ expanding mapDef

https://modwiki.dhewm3.org/Mapdef_%28decl%29

That may also be useful for something like the mapvars proposal: 0000833
stgatilov

stgatilov

08.12.2023 12:54

administrator   ~0016227

The best long-term idea is to introduce the concept of "mission-controlled" cvars.
Also, we should add a new cvar flag CVAR_MISSION, which is used to mark cvars that can become mission-controlled (incompatible with CVAR_ARCHIVE).
The script event which now can change any cvar will only change cvars marked with CVAR_MISSION and produce warning otherwise.

The full proposal is on dev forums:
  https://forums.thedarkmod.com/index.php?/topic/22284-212-overriding-cvars/&do=findComment&comment=490062
The main idea is that calling setcvar script function becomes the only supported way for mappers to modify cvars.
If it is called, then cvar becomes "mission-controlled" for this game run and is treated as part of gameplay state (saved/loaded in save file).
If mapper does not call setcvar, then the same cvar is not mission-controlled and behaves just like ordinary cvars behave now.

Very similar but slightly different proposal (same forum post) is to allow mappers to set "override" value for CVAR_MISSION cvars.
The difference is that in this case we actually add a new "overrideValue" data to cvar (can be NONE).
We still store normal value of cvar that player can change, but the "overrideValue" takes precedence when choosing the value that takes effect.
stgatilov

stgatilov

08.12.2023 12:56

administrator   ~0016228

For now, Daft Mugi is going to commit a patch which allows mappers to override cvars in "mission.cfg" file.
Also, we have some values in player entityDef, and these values somehow (not sure about exact mechanics) can override player movement cvars.

If the proper system with mission-controlled cvar or mission overrides is implemented, the older two approaches should be deleted.
Daft Mugi

Daft Mugi

08.12.2023 18:19

developer   ~0016237

Committed code rev 10555.
Added 'mission.cfg' for mappers.
Also, resets cvars on mission change so that non-archived, modified cvars do not carry over to the next mission.

Committed code rev 10556.
Removed CVAR_ARCHIVE from some player movement cvars.

Committed assets rev 16869.
Removed some player movement cvars from player entityDef.
stgatilov

stgatilov

19.05.2024 09:53

administrator   ~0016701

Commits:
  r10733 Implemented "mission overrides" for cvars.
  r10734 Improved reports about cvar mission overrides in console.
  r10735 Cvar mission overrides are now tied to gameplay session.
  r10736 sys.setcvar script event now sets mission override instead of setting the main value directly.
  r10737 Dynamically created cvars are now created with empty value and default.


Previously, each cvar had "main value" and "default value".
Now each cvar also has optional "mission override value".
If mission override is present, then it takes effect and main value is ignored.
If mission override is missing (normally it is), then main value takes effect.

The mission overrides are tied to gameplay session.
They are written to savefile on game save, and restored from savefile on game load --- just like any game state.
Mission overrides are also dropped when game starts or ends (on success, fail, quit, restart).

Game script event sys.setcvar now always sets mission override, it can no longer affect the main value.
This is the main way for mappers to override cvar values.

Currently there is no limit on which cvars can be overridden, no "set of cvars approved for overriding".
It is even possible to override archived cvars.
Note that the main value is saved to darkmod.cfg, mission override is ignored for the sake of .cfg save.
Of course, mappers should understand that overriding most cvars can result in all kind of problems =)

You can see mission overrides in console.
Mission overrides are always printed in magenta color, and thus are easy to notice.
You can also set mission override from game console if you just want to test the override system:
  setm {name} {value} --- sets mission override of cvar {name} to value {value} (similar to sys.setcvar)
  unsetm {name} --- drops mission override of cvar {name} (currently no equivalent in game script)

Note that user can still change cvar if it is overriden by mission.
Any modification of a cvar is either "user modification" or "mission modification".
Mission modifications are described above: setm, sys.setcvar, resetting on game load, start, end.
All the other modifications are considered "user modifications": they break mission override and change the main value.

Issue History

Date Modified Username Field Change
20.12.2020 17:43 duzenko New Issue
20.12.2020 17:43 duzenko Steps to Reproduce Updated
15.03.2021 15:46 stgatilov Target Version TDM 2.10 =>
08.08.2022 12:33 nbohr1more Relationship added parent of 0005892
05.02.2023 18:29 nbohr1more Note Added: 0015929
05.02.2023 18:30 nbohr1more Relationship added related to 0000833
05.02.2023 18:31 nbohr1more Note Edited: 0015929
08.12.2023 12:46 stgatilov Relationship added related to 0005926
08.12.2023 12:47 stgatilov Relationship added related to 0003934
08.12.2023 12:54 stgatilov Note Added: 0016227
08.12.2023 12:54 stgatilov Severity minor => feature
08.12.2023 12:54 stgatilov Target Version => TDM 2.13
08.12.2023 12:56 stgatilov Note Added: 0016228
08.12.2023 18:19 Daft Mugi Note Added: 0016237
04.05.2024 16:17 stgatilov Relationship added related to 0006530
19.05.2024 09:53 stgatilov Note Added: 0016701
19.05.2024 09:53 stgatilov Assigned To => stgatilov
19.05.2024 09:53 stgatilov Status new => feedback