Skip to content

[Bug]: AutoExecConfig regression in SM 1.13 #2582

Description

@CurTInq

Prerequisites

  • I have checked that my issue doesn't exist yet in the issue tracker

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:

  1. 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);
  2. Create an AutoExecConfigEx function. I'll describe the function signature below;
  3. 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:

  1. iFlags - AECFLAG_*, described below;
  2. iCvarFlags - FCVAR_* flags that cause a convar to be ignored when generating the config file;
  3. sConfigName - name of the config. Same as in the current AutoExecConfig;
  4. sFolderName - name of the parent folder. Same as in the current AutoExecConfig.

Function flags:

  1. AECFLAG_GENERATE_CONFIG = (1 << 0) - if set, the plugin config will be generated. Does nothing if the plugin config already exists. Respects iCvarFlags;
  2. AECFLAG_STRIP_CONVARS = (1 << 1) - if set, convars not registered by the plugin will be removed from the config;
  3. 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;
  4. 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

  1. Make a plugin which registers convars with FCVAR_DONTRECORD flag set and executes AutoExecConfig(true, ...) after that.
  2. Add and set a convar in the config which wasn't already there (has FCVAR_DONTRECORD flag set) but belongs to the plugin.
  3. Change map and you will see the convar removed from the config. This happens only in SM 1.13.

Relevant Log Output

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions