Hey everyone, I have one WIZ command that I wrote that is giving me
trouble...It's a command (written from scratch) that lists all the mobs or
objs in a given zone along with their vnums...
It will run fine, but after it lists a certain number of mobs/objs, it
crashes the mud with a Segmentation Fault. But it doesn't necessarily do it
every time...
Here is one of the conditions under which it crashed...
-I typed 'mshow 100' to display the two mobiles in zone 100
-I typed 'oshow 100' to display the five objects in zone 100
-I typed 'mshow 30' to display all the mobs in zone 30 (a bunch)
and it crashed...
or, I also typed mshow 30 three times, and it crashed...
Can anyone help me with this problem?
There's a copy of the code at the bottom of this message...
I also have one other question (more for clarification than anything else):
What Actually Causes A Segmentation Fault?
Anyway, thank you for any help you can shed on this situation.
×Praetor×
-------Here's the Code for the command-------
ACMD(do_vshow){
struct char_data *mob;
struct obj_data *obj;
int zone_number;
int xvnum;
mob_rnum xrnum;
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
one_argument(argument, arg);
if(!*arg)
{
sprintf(buf, "You need to specify a zone.\r\n");
send_to_char(buf, ch);
}
else if(isdigit(*arg) && (atoi(arg) > 0))
{
zone_number = atoi(arg);
switch(subcmd)
{
case SCMD_VSHOW_MOB:
sprintf(buf, "-----Mobile Information for Zone #%3d-----\r\n",
zone_number);
send_to_char(buf, ch);
for(xvnum = 0; xvnum <= 99; xvnum+=1)
{
xrnum = real_mobile((zone_number * 100) + xvnum);
if(xrnum < 0)
{ continue; }
else {
mob = read_mobile(xrnum, REAL);
sprintf(buf, "[%d] - %s", (zone_number * 100) + xvnum,
mob->player.long_descr);
send_to_char(buf, ch);
}
}
break;
case SCMD_VSHOW_OBJ:
sprintf(buf, "-----Object Information for Zone #%3d-----\r\n",
zone_number);
send_to_char(buf, ch);
for(xvnum = 0; xvnum <= 99; xvnum++)
{
xrnum = real_object((zone_number * 100) + xvnum);
if(xrnum < 0)
{ continue; }
else {
obj = read_object(xrnum, REAL);
sprintf(buf, "[%d] - %s\n", (zone_number * 100) + xvnum,
obj->description);
send_to_char(buf, ch);
}
}
break;
default:
break;
}
}
}
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT