Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ ROM
➜ Running the server
➜ ROM question with aggr_update
ROM question with aggr_update
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Tidus
(11 posts) Bio
|
Date
| Thu 01 Apr 2004 06:24 PM (UTC) Amended on Fri 02 Apr 2004 11:01 PM (UTC) by Nick Gammon
|
Message
| I am running a ROM 2.4 derived codebase mud and it keeps lagging out altogether. So when I attach gdb to see where it hangs it tells me the error is in the aggr_update function in update.c which looks like this:
The line that it gives as the actual problem is:
ch_next = ch->next_in_room;
right after the 2nd for loop, I just don't understand why that line is a problem, it's stock rom. If anyone could help I would appreciate.
void aggr_update( void )
{
CHAR_DATA *wch;
CHAR_DATA *wch_next;
CHAR_DATA *ch;
CHAR_DATA *ch_next;
CHAR_DATA *vch;
CHAR_DATA *vch_next;
CHAR_DATA *victim;
for ( wch = char_list; wch != NULL; wch = wch_next )
{
wch_next = wch->next;
if ( IS_NPC(wch)
|| wch->level >= LEVEL_IMMORTAL
|| wch->in_room == NULL
|| wch->in_room->area->empty
|| is_affected(wch, skill_lookup("deter"))
|| is_affected(wch, skill_lookup("sneak")))
continue;
for ( ch = wch->in_room->people; ch != NULL; ch = ch_next )
{
int count;
ch_next = ch->next_in_room;
if ( !IS_NPC(ch)
|| !IS_SET(ch->act, ACT_AGGRESSIVE)
|| IS_SET(ch->in_room->room_flags,ROOM_SAFE)
|| IS_AFFECTED(ch,AFF_CALM)
|| ch->fighting != NULL
|| IS_AFFECTED(ch, AFF_CHARM)
|| is_affected(ch, skill_lookup("charm"))
|| !IS_AWAKE(ch)
|| ( IS_SET(ch->act, ACT_WIMPY) && IS_AWAKE(wch) )
|| !can_see( ch, wch )
|| number_bits(1) == 0)
continue;
count = 0;
victim = NULL;
for ( vch = wch->in_room->people; vch != NULL; vch = vch_next )
{
vch_next = vch->next_in_room;
if ( !IS_NPC(vch)
&& vch->level < LEVEL_IMMORTAL
&& ch->level >= vch->level - 5
&& ( !IS_SET(ch->act, ACT_WIMPY) || !IS_AWAKE(vch) )
&& can_see( ch, vch ) )
{
if ( number_range( 0, count ) == 0 )
victim = vch;
count++;
}
}
if ( victim == NULL )
continue;
multi_hit( ch, victim, TYPE_UNDEFINED );
}
}
return;
}
Edited by Nick to add [code] and [/code].
| Top |
|
Posted by
| Nick Gammon
Australia (23,052 posts) Bio
Forum Administrator |
Date
| Reply #1 on Fri 02 Apr 2004 11:06 PM (UTC) |
Message
| The code looks a bit convoluted but I would guess that the mucking around with the various character lists is ending up with a situation where it gets the "next in room" being the same person as itself, and thus loops indefinitely.
One way to break that loop, although it might not fix the reason it is happening would be something like this:
Instead of:
ch_next = ch->next_in_room;
Have
if (ch_next != ch->next_in_room)
ch_next = ch->next_in_room;
else
ch_next = NULL;
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
8,572 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top