20 Apr, 2009, yzor wrote in the 1st comment:
Votes: 0
i mknow there was another therad on repop msg, but this one is a little different. i redid my code but for some reason after level 5 every one see's repop msgs that only the imms should see. i'm pretty shure the problem is in theis part of my code, i'm not sure where i went wrong with it.

void area_update( void )
{
AREA_DATA *pArea;
char buf[MAX_STRING_LENGTH];
DESCRIPTOR_DATA *d;

for ( pArea = area_first; pArea != NULL; pArea = pArea->next )
{

if ( ++pArea->age < 3 )
continue;

/*
* Check age and reset.
* Note: Mud School resets every 3 minutes (not 15).
*/
if ( (!pArea->empty && (pArea->nplayer == 0 || pArea->age >= 15))
|| pArea->age >= 31)
{
ROOM_INDEX_DATA *pRoomIndex;
char *msg = NULL;

reset_area( pArea );
sprintf(buf,"%s has just been reset.\n\r",pArea->name);
wiznet(buf,NULL,NULL,WIZ_RESETS,0,0);
/* if (IS_SET(pArea->area_flags, AREA_CHANGED))
{
save_area(pArea);
REMOVE_BIT( pArea->area_flags, AREA_CHANGED );
sprintf(buf, "%s has just been saved.\n\r", pArea->name);
wiznet(buf, NULL, NULL, WIZ_RESETS, 0, 0);
}*/
for (d = descriptor_list; d; d= d->next)

pArea->age = number_range( 0, 3 );
pRoomIndex = get_room_index( ROOM_VNUM_SCHOOL );
if ( pRoomIndex != NULL && pArea == pRoomIndex->area )
pArea->age = 15 - 2;
else if (pArea->nplayer == 0)
pArea->empty = TRUE;
if (!IS_NULLSTR(pArea->repop_msg))
msg = pArea->repop_msg;
else if (!pRoomIndex || pRoomIndex->area != pArea) // no defaults for mud school.
{
switch (number_range(0, 4))
{
default:
msg = "The area repopulates itself.";
break;
case 1:
msg = "You notice a change in the area.";
break;
case 2:
msg =
"Time completes another cycle bringing life to the area.";
break;
case 3:
msg =
"You feel a sudden deja-vu bringing change to the area.";
break;
case 4:
msg = "You hear noises off in the distance…";
break;
}
}
if (!IS_NULLSTR(msg))
{
CHAR_DATA *ch;

for ( ch = char_list; ch != NULL; ch = ch->next )
{
if (ch->desc && ch->desc->connected == CON_PLAYING &&
IS_AWAKE(ch) && ch->in_room
&& ch->in_room->area == pArea)
sprintf(buf, "{`%s{x\n\r", msg);
send_to_char(buf, ch);
}
}
}
}

return;
}
20 Apr, 2009, Scandum wrote in the 2nd comment:
Votes: 0
You need a pair of braces for the if check, doesn't hurt to always use braces if you ask me.

for ( ch = char_list; ch != NULL; ch = ch->next )
{
if (ch->desc && ch->desc->connected == CON_PLAYING && IS_AWAKE(ch) && ch->in_room && ch->in_room->area == pArea)
{
sprintf(buf, "{%s{x\n\r", msg);
send_to_char(buf, ch);
}
}


You'd also want to look at this:
for (d = descriptor_list; d; d= d->next)
pArea->age = number_range( 0, 3 );
pRoomIndex = get_room_index( ROOM_VNUM_SCHOOL );

That doesn't make sense, generally muds only set pArea's age to a number between 0 and 3 if it's the mud school.
04 May, 2009, yzor wrote in the 3rd comment:
Votes: 0
thanks that helped, got it to work right now. thanks again.
04 May, 2009, Skol wrote in the 4th comment:
Votes: 0
Scandum said:
You'd also want to look at this:
for (d = descriptor_list; d; d= d->next)
pArea->age = number_range( 0, 3 );
pRoomIndex = get_room_index( ROOM_VNUM_SCHOOL );

That doesn't make sense, generally muds only set pArea's age to a number between 0 and 3 if it's the mud school.

That's actually the 'randomizer' part of it, where it bumps it by 0-3 minutes. That part just makes the repops not all on the same minute on areas that are empty etc.

On the mudschool it just resets every 2 minutes period (should be three but they did bad math ;p). For the mudschool one they do: pArea->age = 15 - 2; Then add to it each time it runs area update. If it's 15 or higher it resets. So the count 'up' instead of down, it's kind of add thinking but works.

What I ended up doing was have a 'start city' check, and have those do a similar repop, just between 8-12 minutes instead of 15.
04 May, 2009, Scandum wrote in the 5th comment:
Votes: 0
I see, though I was mainly referring to the for loop it was nested inside.
04 May, 2009, Skol wrote in the 6th comment:
Votes: 0
Yeah, no kidding, fugly stuff there.
0.0/6