Game.GetLocationName discrepancy with unnamed Object

Started by monkey0506, Sun 05/10/2008 10:04:55

Previous topic - Next topic

monkey0506

I've found that if I have an Object with no name set, that apparently Game.GetLocationName returns the string " " (a blank whitespace character (' ', ASCII 32)). However if I check the Object.Name property I actually get a zero-length string, "".

This caused a bit of confusion for me when I was trying to compare the two and they weren't the same. I knew that the location I was testing was within the realms of the object, but the two strings weren't equating so I displayed the results of the two.

Setting a name for the object corrected the discrepancy, but I wonder if it would be an issue for "status line"-less interfaces?

Pumaman

You're right, I can replicate this behaviour.

The problem is, it's definiately doing this deliberately ... I just can't remember why. I think it might be because originally there was no GetLocationType, and so the only way to tell if there was anything at that location was to compare GetLocationName to an empty string -- and thus, an object with no name was returned as a space so that you could tell that there was actually something there.

It's one of these situations now where I'm a bit nervous about fixing it in case somebody is relying on the current behaviour.

monkey0506

I can definitely understand how being able to tell from GetLocationName whether there was anything displayed or not could be useful, but perhaps the new String type offers a better solution in that if the type is eLocationNothing a null String could be returned instead of an empty one, and in the situation described the proper name could be returned?

Clearly this would break backwards compatibility for anyone relying on the current behavior, but it's extremely counter-intuitive the way that it's currently implemented... :-\

SMF spam blocked by CleanTalk