autoexec.cfg runs before config.cfg
Describe the bug
The autoexec.cfg file runs before config.cfg, meaning that any cvars or binds set in autoexec will be overridden by ones in config. This is a problem if you want to have keybinds that dynamically swap because it means you can't reset them when the game is restarted, whichever ones were last used (and therefore got saved into config.cfg) will take priority.
In Source 2013 this is reversed, and autoexec runs later as expected.
Issue Map
N/A
To Reproduce
- Create
cfg/autoexec.cfgand add abindcommand to it (e.g.bind w +jump) - Launch the game
- Run
bind win the console; it reports it's still bound to+forward, not+jumpas you specified
Operating System
Tested on Windows 10
Workaround: Put host_writeconfig at the end of autoexec. This saves config.cfg with the changed cvars/binds.
This issue happens because config.cfg is executed twice: once before valve.rc, and once when config.cfg is fetched from the cloud. This can be observed in Portal 2 with the SourceAutoRecord plugin by using the following snippet in autoexec:
plugin_load sar
sar_session
sar_on_config_exec sar_session
There is a delay of ~10-30 ticks (0.167-0.500 seconds), which is the time taken to download the file from Steam Cloud.