Raised This Month: $32 Target: $400
 8% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-21-2018 , 10:39   [SM bug] AutoExecConfig doesn't work if cfg too long
Reply With Quote #1

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?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 05-21-2018 at 10:48.
Dragokas is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-21-2018 , 10:51   Re: [SM bug] AutoExecConfig doesn't work if cfg too long
Reply With Quote #2

Exec'd cfgs are parsed by the game engine, not by SM.
psychonic is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-21-2018 , 11:06   Re: [SM bug] AutoExecConfig doesn't work if cfg too long
Reply With Quote #3

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.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 05-21-2018 at 11:13.
Dragokas is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 05-25-2018 , 15:41   Re: [SM bug] AutoExecConfig doesn't work if cfg too long
Reply With Quote #4

I made a fix: https://forums.alliedmods.net/showthread.php?t=307804
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 05-25-2018 at 15:41.
Dragokas is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:25.


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