Prerequisites
Operating System and Version
Debian 12
Game / AppID and Version
Any
SourceMod Version
1.13.0.7472
Metamod:Source Version
1.12.0-dev+1226
Version Verification
Updated SourceMod Version
1.13.0.7472
Updated Metamod:Source Version
1.12.0-dev+1226
Description
Expected behavior:
AutoExecConfig(true, ...) generates a config file for a plugin with convars which don't have FCVAR_DONTRECORD flag set. Never removes any plugin-related settings (convars) from it which were added manually later.
Current behavior:
AutoExecConfig(true, ...) overwrites the plugin config file, removing plugin-related convars from it if they have the FCVAR_DONTRECORD flag set, even if they were added manually.
It seems like this regression was introduced in this PR. While automatically adding new convars to the config file may be useful, removing existing convars is a breaking change. IMO, this destructive behavior shouldn't have been introduced to AutoExecConfig in the first place. Instead, a separate function - such as AutoExecConfigEx - should've been created.
The proper fix would be:
- Revert the behavior change of
AutoExecConfig to maintain backward compatibility with old plugins and servers setups. FCVAR_DONTRECORD convars still should not be inserted into generated configs. This behavior should be documented (right now it is "documented" only on the wiki, but not in the includes nor docs);
- Create an
AutoExecConfigEx function. I'll describe the function signature below;
- Add an
sm_configs_cleanup_unsafe <all/specific/config/path> command for server operators so they can execute the current behavior if they need to.
AutoExecConfigEx:
The default function signature should look like this:
void AutoExecConfigEx(int iFlags = 0, int iCvarFlags = FCVAR_HIDDEN | FCVAR_PROTECTED | FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY, const char[] sConfigName = "", const char[] sFolderName = "sourcemod")
The arguments:
- iFlags -
AECFLAG_*, described below;
- iCvarFlags -
FCVAR_* flags that cause a convar to be ignored when generating the config file;
- sConfigName - name of the config. Same as in the current
AutoExecConfig;
- sFolderName - name of the parent folder. Same as in the current
AutoExecConfig.
Function flags:
AECFLAG_GENERATE_CONFIG = (1 << 0) - if set, the plugin config will be generated. Does nothing if the plugin config already exists. Respects iCvarFlags;
AECFLAG_STRIP_CONVARS = (1 << 1) - if set, convars not registered by the plugin will be removed from the config;
AECFLAG_STRIP_CONVARS_STRICT = (1 << 2) - overrides AECFLAG_STRIP_CONVARS if both are set. Extends the AECFLAG_STRIP_CONVARS behavior but respects the iCvarFlags argument. Any convar that has an ignored flag or does not belong to the plugin will be removed;
AECFLAG_INSERT_NEW_CONVARS = (1 << 3) - inserts new convars into the existing plugin config with respect to iCvarFlags. If no plugin config exists, this does nothing.
Steps to Reproduce
- Make a plugin which registers convars with
FCVAR_DONTRECORD flag set and executes AutoExecConfig(true, ...) after that.
- Add and set a convar in the config which wasn't already there (has
FCVAR_DONTRECORD flag set) but belongs to the plugin.
- Change map and you will see the convar removed from the config. This happens only in SM 1.13.
Relevant Log Output
Prerequisites
Operating System and Version
Debian 12
Game / AppID and Version
Any
SourceMod Version
1.13.0.7472
Metamod:Source Version
1.12.0-dev+1226
Version Verification
Updated SourceMod Version
1.13.0.7472
Updated Metamod:Source Version
1.12.0-dev+1226
Description
Expected behavior:
Current behavior:
It seems like this regression was introduced in this PR. While automatically adding new convars to the config file may be useful, removing existing convars is a breaking change. IMO, this destructive behavior shouldn't have been introduced to
AutoExecConfigin the first place. Instead, a separate function - such asAutoExecConfigEx- should've been created.The proper fix would be:
AutoExecConfigEx:
Steps to Reproduce
FCVAR_DONTRECORDflag set and executesAutoExecConfig(true, ...)after that.FCVAR_DONTRECORDflag set) but belongs to the plugin.Relevant Log Output