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
➜ SWR crash
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Destiny
(14 posts) Bio
|
| Date
| Fri 17 Jan 2003 07:38 AM (UTC) |
| Message
| Checkthis out im in do_openbay and im setting up so clan members can remotely open the bay doors.
if ( str_cmp(ch->name,target->owner) && str_cmp(ch->name,target->pilot) && str_cmp(ch->name,target->copilot) /*&& str_cmp(ch->pcdata->clan->name,target->owner)*/ )
{
send_to_char("&RAuthorization denied.\n\r",ch);
return;
}
if ( str_cmp(ch->name,target->owner) && str_cmp(ch->name,target->pilot) && str_cmp(ch->name,target->copilot) && str_cmp(ch->pcdata->clan->name,target->owner) )
{
send_to_char("&RAuthorization denied.\n\r",ch);
return;
}
the first one works fine when the condition is true and when the condition is false (condition being if they are a pilot and whatnot) the second one works properly if the condiction is true and they DO have authorization, however it crashes the mud if its false. I know i must be comparing the two strings incorrectly, but could one of you guys tell me why its not working the way it is? | | Top |
|
| Posted by
| Meerclar
USA (733 posts) Bio
|
| Date
| Reply #1 on Fri 17 Jan 2003 08:09 AM (UTC) |
| Message
| | Yer absolutely certain clan is a pcdata flag? Most often its referenced something like ch->clan. Odds are thats where your problem is so check the pfile struct for how clan is referenced for a start on how to make that check work. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | | Top |
|
| Posted by
| Boborak
USA (228 posts) Bio
|
| Date
| Reply #2 on Fri 17 Jan 2003 08:45 AM (UTC) |
| Message
| Are you checking to ensure that they are in a clan at all?
If you try to access ch->pcdata->clan->name and that char is not in a clan the mud will crash. I would reccommend either automatically denying access like so:
if (!ch || !ch->pcdata || !ch->pcdata->clan || !ch->pcdata->clan->name)
{
send_to_char("Denied!",ch);
return;
}
//now do your checks
or you could work those same checks into what you already have..
also, remember that str_cmp returns TRUE if the comparison is false. so..
if (str_cmp("The Empire", "The Empire")) //would return false
| | Top |
|
| Posted by
| Boborak
USA (228 posts) Bio
|
| Date
| Reply #3 on Fri 17 Jan 2003 08:51 AM (UTC) |
| Message
| Here's a copy of your code that at the very least shouldn't crash your mud..
if ( !str_cmp(ch->name, target->owner) ||
!str_cmp(ch->name, target->pilot) ||
!str_cmp(ch->name, target->copilot) ||
( ch->pcdata && ch->pcdata->clan && ch->pcdata->clan->name && !str_cmp(ch->pcdata->clan->name, target->owner) ) )
{
//Granted
return;
}
else
{
//Denied
} | | Top |
|
| Posted by
| Destiny
(14 posts) Bio
|
| Date
| Reply #4 on Fri 17 Jan 2003 02:23 PM (UTC) |
| Message
| | Thanks guys, Looks like it just didnt like me comparing a person's clan to something when they didnt have a clan to begin with. | | 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.
16,276 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top