Ok, this is a weird one. When I call create_object from the following
function, I get a segmentation fault. Everything compiles fine, no
warnings (for that function), but it crashes right when it goes to create
the object for "pammo". I know OBJ_VNUM_AMMO exists, and the index seems
to be created successfully. Any ideas?
The function:
OBJ_DATA * create_ammo( OBJ_DATA *obj )
{
OBJ_DATA *pammo;
OBJ_INDEX_DATA *pAmmoIndex;
int i;
printf("create_ammo() engaged...\n");
if (obj == NULL)
{
bug("Bad obj for create_ammo.",0);
return NULL;
}
if (obj->value[2] == 0)
{
bug("Bad obj for create_ammo. Obj exists, but has no ammo type.",0);
return NULL;
}
printf("Creating ammo index...\n");
pAmmoIndex = get_obj_index(OBJ_VNUM_AMMO);
printf("Ammo index created...\n");
printf("Creating ammo...\n");
pammo = create_object( pAmmoIndex, 0 ); /* <--- boom! */
printf("Ammo obj created...");
for (i = 0; i < MAX_AMMO; i++)
{
if (pammo == NULL)
break;
if (ammo_table[i].type == obj->value[2])
{
pammo->value[0] = ammo_table[i].type;
pammo->name = ammo_table[i].name;
pammo->short_descr = ammo_table[i].shortdesc;
pammo->description = ammo_table[i].longdesc;
break;
}
}
if (pammo != NULL)
{
if (pammo->value[2] == 0)
return NULL;
}
return pammo;
}
Here's OBJ_VNUM_AMMO (in limbo.are):
#39
ammo~
an ammo~
A generic ammo is here, but shouldn't be. Better tell an Imm about it.~
~
ammo 0 AO
0 0 0 0 0
0 0 0 P
As you can see, I've pinpointed the problem with the wonderfully advanced
tactic of putting in lots of printf() calls. Anyhow, I'd really appreciate
any help.
Thanks,
Thori