SWR crash

Posted by Destiny on Fri 17 Jan 2003 07:38 AM — 5 posts, 18,916 views.

#0
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?
USA #1
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.
USA #2
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

USA #3
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
}
#4
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.