Engine icon indicating copy to clipboard operation
Engine copied to clipboard

autoexec.cfg runs before config.cfg

Open vrad-exe opened this issue 2 years ago • 1 comments

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

  1. Create cfg/autoexec.cfg and add a bind command to it (e.g. bind w +jump)
  2. Launch the game
  3. Run bind w in the console; it reports it's still bound to +forward, not +jump as you specified

Operating System

Tested on Windows 10

vrad-exe avatar Feb 04 '23 00:02 vrad-exe

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.

ThisAMJ avatar Feb 07 '23 21:02 ThisAMJ