Allow 'user' CVARINFO cvars to be set by ZScript

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

User avatar
Major Cooke
Posts: 8109
Joined: Sun Jan 28, 2007 3:55 pm

Allow 'user' CVARINFO cvars to be set by ZScript

Post by Major Cooke »

Whether it's by having another flag 'archive' or something to indicate they should be archived, I'm trying to set up a system where the player's selected choice when ZScript is remembered.

Specifically the CVAR struct, when using SetInt, etc. doesn't actually record it, which to me seems like an intentional decision - and it makes sense that it does so.
User avatar
phantombeta
Posts: 2038
Joined: Thu May 02, 2013 1:27 am
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Allow 'user' CVARINFO cvars to be set by ZScript

Post by phantombeta »

Major Cooke wrote:Specifically the CVAR struct, when using SetInt, etc. doesn't actually record it, which to me seems like an intentional decision - and it makes sense that it does so.
This is actually a complicated bug that no one's fixed yet because of the complexity of the code. It actually works if you use FindCVar instead of GetCVar (which is why menus work), but that doesn't work for most use-cases.

IIRC the reason it happens is because the game creates an instance of the CVar struct for the actual INI/config CVar, (which is the one FindCVar gives you) and also creates separate instances for each player number. (that are retrieved by GetCVar using a PlayerInfo)
The latter is where the problem lies, as it seems it makes no exceptions for the consoleplayer/local peer, and the changes to the latter instances don't affect the config instance, so they end up not getting saved to the INI file.
User avatar
SanyaWaffles
Posts: 765
Joined: Thu Apr 25, 2013 12:21 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11 for the Motorola Powerstack II
Graphics Processor: nVidia with Vulkan support
Location: The Corn Fields

Re: Allow 'user' CVARINFO cvars to be set by ZScript

Post by SanyaWaffles »

this has been an issue for some time, as PB has said. It's been annoying to say the least.
Ludicrous_peridot
Posts: 15
Joined: Sun Aug 09, 2020 2:46 pm

Re: Allow 'user' CVARINFO cvars to be set by ZScript

Post by Ludicrous_peridot »

Oh, yes. Have just ran into the same issue. Spent some time trying to figure out why, while being seemingly updated ingame (when accessed via GetCVar) , my user cvar was not persisted between GZDoom restarts, and then remembered previous version of DoomDelta had a "bug" where hud style would not be saved, that could be worked around by changing scope to server.

So I've used the same workaround for my mod for now.

If the bug is somewhat complex, at least an error message in console to warn dev about unexpected behaviour would be appreciated, so that they don't waste time trying to figure that out.

PS And that non-string cvars work as expected really is adding to the confusion here.
My bad. They don't.

Return to “Feature Suggestions [GZDoom]”