AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [SM bug] AutoExecConfig doesn't work if cfg too long (https://forums.alliedmods.net/showthread.php?t=307696)

Dragokas 05-21-2018 10:39

[SM bug] AutoExecConfig doesn't work if cfg too long
 
Hi,

this problem is partially mentioned by Silvers in his Cvar Configs Updater (see item 3.3) and still actual.

I did tons of server reboots to find out the possible cause and solution.

Here is what I have.

1) Two identical plugins with different names and cfg/cvar names:

a.
Code:

#define PLUGIN_VERSION                "1.0"

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

#define CVAR_FLAGS                                FCVAR_NOTIFY

ConVar g_hCvarNotify;
bool g_bNotify;

public Plugin myinfo =
{
        name = "[L4D] CVar update test",
        author = "Dragokas",
        description = "",
        version = PLUGIN_VERSION,
        url = ""
}

public Action CmdMessage(int client, int args)
{
        PrintToChat(client, "[TEST] %b", g_bNotify);
        return Plugin_Handled;
}

public Action CmdUpdate(int client, int args)
{
        GetCvars();
        PrintToChat(client, "[CVAR_TEST] Variables are updated.");
        return Plugin_Handled;
}

public void OnPluginStart()
{
        RegAdminCmd("sm_cvar_notify",                CmdMessage,                ADMFLAG_ROOT);
        RegAdminCmd("sm_cvar_update",                CmdUpdate,                ADMFLAG_ROOT);
       
        g_hCvarNotify =                        CreateConVar(        "l4d_cvar_test_notify",                        "1",                        "0=Off, 1=On", CVAR_FLAGS);

        AutoExecConfig(true,                                        "l4d_cvar_test");

        g_hCvarNotify.AddChangeHook(ConVarChanged_Cvars);

        GetCvars();
}

public void OnConfigsExecuted()
{
        GetCvars();
}

public void ConVarChanged_Cvars(Handle convar, const char[] oldValue, const char[] newValue)
{
        GetCvars();
}

void GetCvars()
{
        g_bNotify = g_hCvarNotify.BoolValue;
}

b.
Code:

#define PLUGIN_VERSION                "1.0"

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

#define CVAR_FLAGS                                FCVAR_NOTIFY

ConVar g_hCvarNotify;
bool g_bNotify;

public Plugin myinfo =
{
        name = "[L4D] CVar update test2",
        author = "Dragokas",
        description = "",
        version = PLUGIN_VERSION,
        url = ""
}

public Action CmdMessage(int client, int args)
{
        PrintToChat(client, "[GEAR] %b", g_bNotify);
        return Plugin_Handled;
}

public Action CmdUpdate(int client, int args)
{
        GetCvars();
        PrintToChat(client, "[GEAR] Variables are updated.");
        return Plugin_Handled;
}

public void OnPluginStart()
{
        RegAdminCmd("sm_gear_notify",                CmdMessage,                ADMFLAG_ROOT);
        RegAdminCmd("sm_gear_update",                CmdUpdate,                ADMFLAG_ROOT);
       
        g_hCvarNotify =                        CreateConVar(        "l4d_cvar_gear_notify",                        "1",                        "0=Off, 1=On", CVAR_FLAGS);

        AutoExecConfig(true,                                        "l4d_gear_transfer");

        g_hCvarNotify.AddChangeHook(ConVarChanged_Cvars);

        GetCvars();
}

public void OnConfigsExecuted()
{
        GetCvars();
}

public void ConVarChanged_Cvars(Handle convar, const char[] oldValue, const char[] newValue)
{
        GetCvars();
}

void GetCvars()
{
        g_bNotify = g_hCvarNotify.BoolValue;
}

Contents of cfgs:
Quote:

// This file was auto-generated by SourceMod (v1.10.0.6276)
// ConVars for plugin "l4d_cvar_test.smx"


// 0=Off, 1=On
// -
// Default: "1"
l4d_cvar_test_notify "0"
Quote:

// This file was auto-generated by SourceMod (v1.10.0.6276)
// ConVars for plugin "l4d_gear_transfer.smx"


// 0=Off, 1=On
// -
// Default: "1"
l4d_cvar_gear_notify "0"
Command:
Code:

sm_cvar_notify; sm_gear_notify
returns:
Quote:

[TEST] 0
[GEAR] 1
But should be identical values.
Used sm: 1.8 official and 1.10.0.6276 self-built.

Temporarily fix:

1. Bug is disappering after I comment/delete (almost) any line from server.cfg.
2. It also disappearing if I move several lines from server.cfg to separate file and execute it from server.cfg by:
Code:

exec separate.cfg
3. In some cases Silver's plugin with sm_configs_comment "1" can help (not in my case) (it comment default values of ./cfg/sourcemod/*.cfg).
4. For some plugins map reload can help.

Can you fix it in sm core?

psychonic 05-21-2018 10:51

Re: [SM bug] AutoExecConfig doesn't work if cfg too long
 
Exec'd cfgs are parsed by the game engine, not by SM.

Dragokas 05-21-2018 11:06

Re: [SM bug] AutoExecConfig doesn't work if cfg too long
 
Due to the fact cfg is an inalienable part of sm plugins, and the fact bug exists on many servers for years, is it possible sm core team to make own simple parser for cfg-files, that read cvars always reliably?

____
Edit. 4. Also, bug is disappearing after I'm changing load order of plugins, so l4d_gear_transfer.smx renamed to a.smx and sit closer to the first place.
So, it fit the logic that all cfgs has read until some overflow moment.

Dragokas 05-25-2018 15:41

Re: [SM bug] AutoExecConfig doesn't work if cfg too long
 
I made a fix: https://forums.alliedmods.net/showthread.php?t=307804


All times are GMT -4. The time now is 22:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.