Skip to content

Make ConVar cache case insensitive, fixes #1166 - #1177

Merged
Headline merged 3 commits into
alliedmodders:masterfrom
sm9cc:ConVarCacheCaseInsensitive
Feb 11, 2020
Merged

Make ConVar cache case insensitive, fixes #1166#1177
Headline merged 3 commits into
alliedmodders:masterfrom
sm9cc:ConVarCacheCaseInsensitive

Conversation

@sm9cc

@sm9cc sm9cc commented Feb 10, 2020

Copy link
Copy Markdown
Contributor

Test code:

public void OnPluginStart() {
	ConVar SV_CHEATS = FindConVar("SV_CHEATS");
	ConVar sv_cheats = FindConVar("sv_cheats");
	ConVar sV_cHeAtS = FindConVar("sV_cHeAtS");
	
	LogMessage("'SV_CHEATS' = %i, 'sv_cheats' = %i, 'sV_cHeAtS' = %i", SV_CHEATS, sv_cheats, sV_cHeAtS);
}

Output:

L 02/10/2020 - 09:04:54: [ConVarLeakTest.smx] 'SV_CHEATS' = 4718664, 'sv_cheats' = 4718664, 'sV_cHeAtS' = 4718664

@sm9cc
sm9cc requested review from Headline and removed request for Headline February 10, 2020 09:36
@sm9cc
sm9cc requested a review from Headline February 11, 2020 04:37
@nosoop

nosoop commented Feb 11, 2020

Copy link
Copy Markdown
Contributor

Confirmed working on TF2 with a similar case (convar ai_LOS_mode being not all lowercase):

// Test
ConVar t = CreateConVar("TTTTT", "0.1");
PrintToServer("T0 %d %d", t, FindConVar("TTTTT")); // SAME
PrintToServer("T1 %d", FindConVar("tTTTT")); // ALWAYS DIFFERENT
PrintToServer("T2 %d", FindConVar("TtTTT")); // ALWAYS DIFFERENT
PrintToServer("T3 %d", FindConVar("TTtTT")); // ALWAYS DIFFERENT

// Real cvar registered as: Smoker_escape_range
PrintToServer("A %d", FindConVar("ai_los_mode")); // ALWAYS DIFFERENT
PrintToServer("B %d", FindConVar("ai_los_mode")); // ALWAYS DIFFERENT
PrintToServer("C %d", FindConVar("ai_los_mode")); // ALWAYS DIFFERENT
PrintToServer("D %d", FindConVar("ai_LOS_mode")); // ALWAYS SAME
PrintToServer("E %d", FindConVar("ai_LOS_mode")); // ALWAYS SAME
PrintToServer("F %d", FindConVar("ai_LOS_mode")); // ALWAYS SAME

Results on SM without PR:

T0 878053395 878053395
T1 878118929
T2 878184463
T3 878249997
A 878315531
B 878381065
C 878446599
D 878512085
E 878512085
F 878512085

Results with PR:

T0 11141280 11141280
T1 11141280
T2 11141280
T3 11141280
A 11206819
B 11206819
C 11206819
D 11206819
E 11206819
F 11206819

@sm9cc

sm9cc commented Feb 11, 2020

Copy link
Copy Markdown
Contributor Author

Confirmed working in L4D2 with original test code (After PR):

 // Test
ConVar t = CreateConVar("TTTTT", "0.1");
PrintToServer("T0 %d %d", t, FindConVar("TTTTT")); // SAME
PrintToServer("T1 %d", FindConVar("tTTTT")); // ALWAYS DIFFERENT
PrintToServer("T2 %d", FindConVar("TtTTT")); // ALWAYS DIFFERENT
PrintToServer("T3 %d", FindConVar("TTtTT")); // ALWAYS DIFFERENT

// Real cvar registered as: Smoker_escape_range
PrintToServer("A %d", FindConVar("smoker_escape_range")); // ALWAYS DIFFERENT
PrintToServer("B %d", FindConVar("smoker_escape_range")); // ALWAYS DIFFERENT
PrintToServer("C %d", FindConVar("smoker_escape_range")); // ALWAYS DIFFERENT
PrintToServer("D %d", FindConVar("Smoker_escape_range")); // ALWAYS SAME
PrintToServer("E %d", FindConVar("Smoker_escape_range")); // ALWAYS SAME
PrintToServer("F %d", FindConVar("Smoker_escape_range")); // ALWAYS SAME
] sm plugins reload ConVarLeakTest
T0 4587588 4587588
T1 4587588
T2 4587588
T3 4587588
A 4653125
B 4653125
C 4653125
D 4653125
E 4653125
F 4653125
[SM] Plugin ConVarLeakTest.smx reloaded successfully.
] sm plugins reload ConVarLeakTest
T0 4587588 4587588
T1 4587588
T2 4587588
T3 4587588
A 4653125
B 4653125
C 4653125
D 4653125
E 4653125
F 4653125
[SM] Plugin ConVarLeakTest.smx reloaded successfully.
] sm plugins reload ConVarLeakTest
T0 4587588 4587588
T1 4587588
T2 4587588
T3 4587588
A 4653125
B 4653125
C 4653125
D 4653125
E 4653125
F 4653125
[SM] Plugin ConVarLeakTest.smx reloaded successfully.
] sm plugins reload ConVarLeakTest
T0 4587588 4587588
T1 4587588
T2 4587588
T3 4587588
A 4653125
B 4653125
C 4653125
D 4653125
E 4653125
F 4653125
[SM] Plugin ConVarLeakTest.smx reloaded successfully.

@Headline Headline left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Headline
Headline merged commit 8a5d0a5 into alliedmodders:master Feb 11, 2020
Headline pushed a commit that referenced this pull request Feb 11, 2020
@sm9cc
sm9cc deleted the ConVarCacheCaseInsensitive branch February 17, 2020 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants