Re: Help with code please

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 09/03/98


> void perform_violence(void)
> {
>   struct char_data *ch;  /* this is line 927 */
>   int attacks = 1, i;
>
>   if (IS_NPC(ch) && (GET_MOB_ATTACKS(ch) > 0))
>     attacks = GET_MOB_ATTACKS(ch);
>
>   if (!IS_NPC(ch) && (GET_PC_ATTACKS(ch) > 0))
>     attacks = GET_PC_ATTACKS(ch);

Obviously enough (to me, that is) because you've put this in the wrong
place.  'ch' isn't anything, yet.  It's undefined...Go down a bit, and...

>   for (ch = combat_list; ch; ch = next_combat_list) {

Here is where we set 'ch' to something.

>     next_combat_list = ch->next_fighting;
>

Here is where your code should be.

>    for (i = 0; i < attacks; i++) {
>     if (FIGHTING(ch) == NULL || ch->in_room != FIGHTING(ch)->in_room) {

-dak : Looks like bad quoting, but it's really for context.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST