[Bug]: AutoExecConfig regression in SM 1.13

Aperta
#2,582 3 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
backend

Direzione di ricerca

Start from the commit linked in the issue (87d668afce37caea584886b29fa013a6d1b27767) to find where the config writer strips FCVAR_DONTRECORD convars — that is where the behavior revert goes. Then search the tree for the AutoExecConfig native registration and the script includes to see where a new AutoExecConfigEx plus AECFLAG_* constants and an sm_configs_cleanup_unsafe command would live. Done when a plugin config keeps manually added DONTRECORD convars across a map change while such convars are still not auto-inserted, with the new API reproducing the current stripping behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug
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

Lingua principale
C++
Stelle
1.2k
Fork
476
Merge medio
2g 9h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alliedmodders/sourcemod

Tutte le issue di alliedmodders/sourcemod

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.