Page 1 of 1

Comparison of names

Posted: Mon Feb 17, 2020 5:33 am
by Barbie
I stumbled over the case handling of names in UT. If I have two names and want to check if they are equal, I can ignore the case, because there cannot be two names that only differ in case. So, instead of

Code: Select all

string(Name1) ~= string(Name2)
I can simply use

Code: Select all

Name1 == Name2
Correct?

See also: https://wiki.beyondunreal.com/Types#Name

Re: Comparison of names

Posted: Mon Feb 17, 2020 7:33 am
by sektor2111
Barbie wrote: Mon Feb 17, 2020 5:33 am Correct?
Me having doubts... An old plain situation - I was hunting CreatureFactory VS Counters (and some known Custom Counters) for adjusting stupid spam. I got a surprise in some map (too bad I don't recall name) which has names like gasbags01 then gabags02 and or other gasbagsend.
I don't know what did I do wrong or I did not do wrong - I always do check for compiling with no errors but the result in game has made me to remove that thing. Of course I could see problem only in a map - I had maps sorted not everything found on Internet for MonsterHunt. Here I suspected an Engine problem or whatever it was and I stopped my names tweaking in that time. Right now I'm hoping to be my mistake but... I'm not convinced that I was doing something wrong...
As a matter of fact: See Editor finding an Actor based on Tag. Type there "Monster", in a MH map, perhaps actors listed immediately are about to be MonsterEvent and MonsterEnd as long as they are including sequence "Monster". If this way of doing deals with names exist in run-time too, then you might have other executions than expected. Now I really want this to be a wrong assumption but the fact which I witnessed is proving another situation...
All patch plugins for NavAdder are using "string(Name)" and for that thing I did not have any problem. Perhaps right now I will want to re-check what's the deal here but I need to look for some map with such common string parts intensively used...

Re: Comparison of names

Posted: Mon Feb 17, 2020 8:00 am
by Barbie
"gasbagsend" is used in MH-UM-Capslock. "gasbags01" is not contained in any of my MH maps.

Re: Comparison of names

Posted: Mon Feb 17, 2020 10:25 am
by sektor2111
This is a virtual sample which I've mentioned because I don't recall right now what exactly was there (gasbag, manta, whatever) but... I've stopped doing that type of deal exactly because of this problem and if I well recall it was another one where two counters have been connected with a Factory for two different things - heavy deal to match what event would do certain action. I'm heading for separate private patch files regarding to each evil map instead of testing names using 'Name' instead of "String".

Re: Comparison of names

Posted: Sat Mar 07, 2020 9:10 pm
by Feralidragon
Names are case-insensitive identifiers, meaning that "unreal" and "Unreal" are considered equal, so yeah, that's always supposed to work.

For example:

Code: Select all

function postBeginPlay()
{
	local name n1, n2;

	n1 = 'unrealpotato';
	n2 = 'UnrealPotato';

	log("n1 == n2 => " $ n1 $ " == " $ n2 $ " => " $ int(n1 == n2));
}
outputs:
n1 == n2 => unrealpotato == unrealpotato => 1

Meaning that when you assign "UnrealPotato" in this case, capitalized, since this name has already been first registered as "unrealpotato" (all lowercase), "unrealpotato" is the assumed name and not "UnrealPotato", so the direct comparison will always yield true.