Question about commands/skills firing

Posted by Gatz on Sat 27 Aug 2005 02:33 PM — 4 posts, 18,265 views.

#0
I feel almost embarrassed to ask but it something that I have thought about for awhile. When coding new skills or commands I typically do what most people do and have something like:

if(!argument || argument[0] == '\0')
{
}

However, I was thinking; do I even need the "!argument"
section? The only way a problem would arise would be if I called said code from in the code itself and sent NULL. Otherwise wouldn't it always send "" if you just typed a command/skill, right?
USA #1
I think so, yes. I think the null check is there because it's such a standard check, moreso than because it's necessary.
#2
I was never taught to code, so I probably do alot of things differently from the rest of you..and probably alot of things that are wrong, but work, for instance I never include the '!argument'..havent had a problem yet.
Canada #3
Based on the fact that a check like this is used so often all over the place I just use a simple macro for the two check. At least then you can include the check for safety purposes with less typing.
[code]#define NULLSTR( str ) ( str == NULL || str[0] == '\0' )[/code]
I only time I can see a command actually stopping on the !argument check would be if it was called from another command and NULL was passed intead of "".