Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Question about commands/skills firing
Question about commands/skills firing
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Gatz
(17 posts) Bio
|
Date
| Sat 27 Aug 2005 02:33 PM (UTC) |
Message
| 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? |
Owner of NarutoMUD, a fun and fast paced Naruto MUD!
Check it out at: http://narutofor.us/ today! | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Sat 27 Aug 2005 02:56 PM (UTC) |
Message
| I think so, yes. I think the null check is there because it's such a standard check, moreso than because it's necessary. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Del
(5 posts) Bio
|
Date
| Reply #2 on Sat 27 Aug 2005 04:13 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #3 on Sat 27 Aug 2005 04:33 PM (UTC) Amended on Sat 27 Aug 2005 04:35 PM (UTC) by Greven
|
Message
| 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 "". |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,336 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top