]> git.xonotic.org Git - xonotic/darkplaces.git/commit
cvar: fix many bugs in gamedir, loadconfig, unset, cvar_resettodefaults* commands
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 4 Feb 2024 16:18:03 +0000 (02:18 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 5 Feb 2024 23:56:24 +0000 (09:56 +1000)
commit32c99c7b0a58545b273fa713d81d6bbfb3b8ebe6
tree214f802ac114e586de2e85176e1e2a77cc7f7413
parentd70b5d66b8030e78abe8129b274a0779dd9aae43
cvar: fix many bugs in gamedir, loadconfig, unset, cvar_resettodefaults* commands

Fixes a segfault when Cvar_RestoreInitState() deleted cvars (null ptr deref).

Fixes an infinite loop in Host_LoadConfig_f() due to calling Cbuf_Execute()
from inside Cbuf_Execute() via Host_AddConfigText().

Fixes `unset` being able to delete autocvars while they're in use by QC.
Fixes Cvar_RestoreInitState() not updating autocvars when necessary.

Fixes Cvar_RestoreInitState() not calling cvar callbacks.

Fixes Cvar_RestoreInitState() sometimes restoring such that .string
doesn't match .value, or such that .defstring is wrong.  This was caused
by Cvar_SaveInitState() saving only string pointers and not strings.

Fixes CF_READONLY cvars like gl_info_* getting restored/reset. It
doesn't make sense for any of these to be changed by code outside their
own subsystems.

Fixes Xonotic menu QC errors caused by Host_LoadConfig_f deleting cvars
before calling QC's m_shutdown().

Deduplicates and simplifies cvar deletion code, see also
05a5ed884366d3a1c8e211168efc19b61867cfca

Saves a little memory by storing only minimal init state data for
Cvar_RestoreInitState(), and by relaxing alignment requirements in
_Mem_strdup().

Improves some warns and docs and tidies up a little.

Removes `vid_restart` from `gamedir`, it usually isn't needed because
current DP applies many vid_ cvar changes without it, and because of
the ubiquity of flat panel displays.

Fixes https://gitlab.com/xonotic/darkplaces/-/issues/354

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cmd.h
cvar.c
cvar.h
fs.c
host.c
menu.c
zone.c
zone.h