Raised This Month: $12 Target: $400
 3% 

KeyValues GetName returns wrong value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 08-23-2015 , 14:28   KeyValues GetName returns wrong value
Reply With Quote #1

I use KeyValues to get data from configs.
Code:
"Config"
{
	galil
	{
		...
	}
	ak47
	{
		...
	}
	m249
	{
		...
	}
	hegrenade
	{
		...
	}
}
Whan I try to get the section names, GetName returns:
Windows: "galil", "ak47", "m249", "hegrenade"
Linux: "Galil", "AK47", "M249", "HEGrenade"

How can I fix this?
kadet.89 is offline
Send a message via Skype™ to kadet.89
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 08-23-2015 , 15:42   Re: KeyValues GetName returns wrong value
Reply With Quote #2

Well :-D I would say by lower casing the string, but that's not the right way to do so...

Also I had a problems with upper case in KeyValues, but only in file path and that the SM lower cased section names.
Nothing like this...

Just a little idea: Does it help to put section name in " ? Like: galil -> "galil"

Last edited by KissLick; 08-23-2015 at 15:43.
KissLick is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-23-2015 , 17:40   Re: KeyValues GetName returns wrong value
Reply With Quote #3

just make it lowercase? o__o
Miu is offline
MaltSNS
SourceMod Donor
Join Date: Nov 2012
Old 08-23-2015 , 18:25   Re: KeyValues GetName returns wrong value
Reply With Quote #4

I'm not sure if you meant to post this in https://forums.alliedmods.net/forumdisplay.php?f=107, but if so I had a similar issue with keyvalues a few months ago. I just lowercased the string after reading it, but I'd be interested in seeing if theres a reason / fix.
MaltSNS is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-23-2015 , 19:01   Re: KeyValues GetName returns wrong value
Reply With Quote #5

KeyValue keys are case-insensitive, and get pooled internally - you can never rely on key casing matching your file.
__________________
asherkin is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 08-26-2015 , 14:53   Re: KeyValues GetName returns wrong value
Reply With Quote #6

KissLick, can't check your idea. Don't know why, but in the middle of the night (08/24/2015 - 03:431) something happend and GetName began to return correct strings

Last edited by kadet.89; 08-26-2015 at 14:54.
kadet.89 is offline
Send a message via Skype™ to kadet.89
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 08-27-2015 , 11:48   Re: KeyValues GetName returns wrong value
Reply With Quote #7

asherkin already explained why. You simply can't rely on KVs keys giving you consistent capitalization. The first string the KV system encounters is the string you'll get, regardless if other KV files have keys with differing capitalization.
__________________
VoiDeD 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:11.


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