AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   KeyValues GetName returns wrong value (https://forums.alliedmods.net/showthread.php?t=270549)

kadet.89 08-23-2015 14:28

KeyValues GetName returns wrong value
 
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?

KissLick 08-23-2015 15:42

Re: KeyValues GetName returns wrong value
 
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"

Miu 08-23-2015 17:40

Re: KeyValues GetName returns wrong value
 
just make it lowercase? o__o

MaltSNS 08-23-2015 18:25

Re: KeyValues GetName returns wrong value
 
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.

asherkin 08-23-2015 19:01

Re: KeyValues GetName returns wrong value
 
KeyValue keys are case-insensitive, and get pooled internally - you can never rely on key casing matching your file.

kadet.89 08-26-2015 14:53

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

VoiDeD 08-27-2015 11:48

Re: KeyValues GetName returns wrong value
 
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.


All times are GMT -4. The time now is 00:17.

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