AutoExecConfig() - List cvars by plugin code order instead of by *alphabetically?*

Aperta
#2,358 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
cpp

Direzione di ricerca

The issue identifies AutoExecConfig() and an example plugin's OnPluginStart(), but does not name SourceMod implementation files or tests. Start by tracing how AutoExecConfig() collects and writes cvars, then check how their ordering is determined. Done means the generated config can preserve plugin code order (or offer the requested option) without requiring numbered cvar names.

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

Descrizione

Feature Request

Help us help you

Is your feature request related to a problem? Please describe.

Managing and changing cvars especially when there's lot of them can be overwhelming, both to users and devs, when SouceMod (SM) decides to order the cvar by it's own way 🔢 , by listing the cvars alphabetically?

Describe the solution you'd like

I hopefully want SM by default ( or by an option, e.g AutoExecConfig(true, "xxx", bool alphabetorder = false) ) listing the cvars in the config file generated to mimic the order in the plugin code, so that the beautifully listed cvars 🏩 in the plugin config file is consistent with the plugin code.

Describe alternatives you've considered

I tried something like this as a workaround, but it looks ugly and less maintainable:

public void OnPluginStart()
{
	CreateConVar(PLUGIN_FILE ... "_0_version", PLUGIN_VERSION, "Whitelist Map Configuration version", FLAG_CVAR_VERSION);
	g_hEnabled = CreateConVar(PLUGIN_FILE ... "_1_enabled", "1", "Toggles plugin state (0: Off, 1: On)", FLAG_CVAR, true, 0.0, true, 1.0);
	g_hConfigFile = CreateConVar(PLUGIN_FILE ... "_2_config_file", "", "Config file to load, relative to the /cfg folder (Empty: Disables config loading)", FLAG_CVAR);
	g_hWhitelistMap = CreateConVar(PLUGIN_FILE ... "_3_whitelist_map", "", "Whitelisted map name(s), case-insensitive, comma-separated (Empty: Apply to ALL maps)", FLAG_CVAR);
	g_hLogConsole = CreateConVar(PLUGIN_FILE ... "_4_log_console", "1", "Toggles logging of config loading status in the console (0: Off, 1: On)", FLAG_CVAR, true, 0.0, true, 1.0);
	AutoExecConfig(true, PLUGIN_FILE);
}

You can see I have to put numbering to force SM lists them by order I like, without them, SM could put the main cvar PLUGIN_FILE ... "_1_enabled" to the bottom, etc

Config file:
// This file was auto-generated by SourceMod (v1.12.0.7169)
// ConVars for plugin "map_config.smx"


// Toggles plugin state (0: Off, 1: On)
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
map_config_1_enabled "1"

// Config file to load, relative to the /cfg folder (Empty: Disables config loading)
// -
// Default: ""
map_config_2_config_file ""

// Whitelisted map name(s), case-insensitive, comma-separated (Empty: Apply to ALL maps)
// -
// Default: ""
map_config_3_whitelist_map ""

// Toggles logging of config loading status in the console (0: Off, 1: On)
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
map_config_4_log_console "1"

I'm surprised no one complain about this yet...

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.