Ok, so here is a different way I've come up with to try and get this function to work.
void do_claimbounty ( CHAR_DATA *ch , char *argument)
{
CHAR_DATA *victim =NULL;
CLAN_DATA *clan =NULL;
PLANET_DATA *planet =NULL;
char arg[MAX_INPUT_LENGTH];
char arg1[MAX_INPUT_LENGTH];
int value;
if ( argument[0] == '\0' || arg[0] == '\0' || arg1[0] == '\0')
{
send_to_char( "Usage claimbounty <target> <wanted by clan>\n\r", ch );
return;
if ( IS_NPC (ch) ) return;
if ( ch->mount )
{
send_to_char( "You can't do that while mounted.\n\r", ch );
return;
}
if ( victim == ch )
{
send_to_char( "That's pointless.\n\r", ch );
return;
}
if ( IS_NPC(victim) )
{
send_to_char( "You cannot claim a bounty on an NPC.\n\r", ch );
return;
}
if ( IS_SET( ch->in_room->room_flags, ROOM_SAFE ) )
{
set_char_color( AT_MAGIC, ch );
send_to_char( "This isn't a good place to do that.\n\r", ch );
return;
}
if ( ch->position == POS_FIGHTING )
{
send_to_char( "Not while you are fighting.\n\r" , ch );
return;
}
if ( ch->position <= POS_SLEEPING )
{
send_to_char( "In your dreams or what?\n\r" , ch );
return;
}
if (!IS_AFFECTED( victim, AFF_CHARM ) && (ch != victim->master))
{
send_to_char( "You will have to apprehend them first.\n\r" , ch );
return;
}
argument = one_argument( argument, arg );
argument = one_argument( argument, arg1 );
value = get_wanted_flag( arg1 );
if ( value < 0 || value < 5)
send_to_char("That is not a valid clan.\n\r", ch);
return;
if ( (value >=0 || value <=5) && !IS_SET( victim->pcdata->wanted_flags, 1 >> value))
send_to_char("They are not wanted by that clan.\n\r", ch);
return;
if ( (value >=0 || value <=5) && IS_SET( victim->pcdata->wanted_flags, 1 >> value) && !str_cmp(wantedclan_flags[value], planet->governed_by->name))
send_to_char("You must cliam this bounty on a planet controlled by the clan who posted the bounty.\n\r", ch);
return;
if ( (value >=0 || value <=5) && IS_SET( victim->pcdata->wanted_flags, 1 >> value) && str_cmp(wantedclan_flags[value], planet->governed_by->name))
ch_printf(victim,"&W&RA slight buzz comes over your comlink and you hear, 'Attention all citizens, %s has claimed the wanted bounty on %s for their crimes against %s's planets.Thank you.'\n\r", ch->name, victim->name, clan->name);
REMOVE_BIT(victim->pcdata->wanted_flags, 1 << value);
return;
}
Here's where I'm getting the value numbers
char * const wantedclan_flags [] =
{
"The Empire", "The New Republic", "The Hunters Guild", "Silence Industries", "Marauder Family",
"Galspan Network", "p6", "p7", "p8", "p9", "p10", "p11",
"p12", "p13", "p14", "p15", "p16", "p17", "p18", "p19", "p20", "p21",
"p22", "p23", "p24", "p25", "p26", "p27", "p28", "p29", "p30", "p31"
};
int get_wanted_flag( char *flag )
{
int x;
for ( x = 0; x < 32; x++ )
if ( !str_cmp( flag, wantedclan_flags[x] ) ) /* changed to wanted_clan - Gunner*/
return x;
return -1;
}
It compiles fine but I'm getting core dumps. I'm attempting to debug with LLDB and these are the results I'm getting. I do not believe this piece of code has anything to do with my crash...it has shown up in multiple different occasions of me dealing with core dumps. I think LLDB isn't working right.
[1] 30352
Johnson-iMac:src Matt$ Segmentation fault (core dumped)
lldb ../bin/swr 30352
(lldb) target create "../bin/swr"
Current executable set to '../bin/swr' (x86_64).
(lldb) settings set -- target.run-args "30352"
(lldb) list
151 {
152 struct timeval now_time;
153 bool fCopyOver = !TRUE;
154
155 /*
156 * Memory debugging if needed.
157 */
158 #if defined(MALLOC_DEBUG)
159 malloc_debug( 2 );
160 #endif
(lldb) bt
error: invalid process
(lldb) exit |