Register forum user name Search FAQ

Gammon Forum

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 ➜ Need some opinions on this array

Need some opinions on this array

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by MattJ820   (32 posts)  Bio
Date Reply #15 on Mon 20 Apr 2015 04:05 AM (UTC)

Amended on Mon 20 Apr 2015 04:22 AM (UTC) by MattJ820

Message
It's at the top

CLAN_DATA *clan =NULL;
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #16 on Mon 20 Apr 2015 04:59 AM (UTC)
Message
If it is NULL, this will give you an access violation:


ch->name, victim->name, clan->name);

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by MattJ820   (32 posts)  Bio
Date Reply #17 on Tue 21 Apr 2015 12:29 AM (UTC)
Message
hey Nick,

why does LLDB always give me the same info from "list"? I've had several other core dumps dealing with different code and it's always this.

Johnson-iMac:src Matt$ lldb ../bin/swr core.33791
(lldb) target create "../bin/swr"
Current executable set to '../bin/swr' (x86_64).
(lldb) settings set -- target.run-args "core.33791"
(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)
Top

Posted by MattJ820   (32 posts)  Bio
Date Reply #18 on Tue 21 Apr 2015 01:10 AM (UTC)
Message
Well I'm getting somewhere...no more core dumps at least. my last chprintf might have been what was causing it and I cleaned that up. I also had a < that should have been an > in the first IF at the bottom.

I'm getting blank returns now, nothing happens but it does accept the input without crashing

Force:1800/1800 Align:-1000
[Hp:500/500] [Mv:1000/1000] (Align:-1000) claimbounty Matt "The Empire"

Force:1800/1800 Align:-1000
[Hp:500/500] [Mv:1000/1000] (Align:-1000)



void do_claimbounty ( CHAR_DATA *ch , char *argument)
{
    CHAR_DATA *victim;
    PLANET_DATA *planet;
    char arg[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    int value;
    
    argument = one_argument( argument, arg );
   

    
        if ( arg[0] == '\0' || arg2[0] == '\0')
        {
        send_to_char( "Usage claimbounty <target> <wanted by clan>\n\r", ch );
        return;
        }
        if ( IS_NPC (ch) ) return;
    
        if ((victim = get_char_room(ch, arg)) == NULL)
        {
        send_to_char("They are not here.\n\r", 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, arg2 );
        value = get_wanted_flag( arg2 );
    
    
        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, the wanted bounty on %s for their crimes against %s has been claimed!. Thank you.'\n\r", victim->name, planet->governed_by->name);
        REMOVE_BIT(victim->pcdata->wanted_flags, 1 << value);
        return;
        
    }

Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #19 on Tue 21 Apr 2015 06:30 AM (UTC)
Message

 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;


I don't know why you have any code after "return" because it won't be executed. Indenting a few spaces doesn't achieve anything.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #20 on Tue 21 Apr 2015 06:31 AM (UTC)
Message
I don't mean this unkindly, but you need to read up on how C works. After an "if" a single statement is executed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by MattJ820   (32 posts)  Bio
Date Reply #21 on Tue 21 Apr 2015 10:37 PM (UTC)

Amended on Tue 21 Apr 2015 11:35 PM (UTC) by MattJ820

Message
This is what I was missing. planet = ch->in_room->area->planet; it didn't know what planet was. makes sense.
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.


60,798 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.