Problems adding stuff to OBJ_DATA

Posted by Andre on Sun 21 Dec 2003 12:15 AM — 2 posts, 11,270 views.

#0
Im trying to add a new enchant type for a class...to do this I went to OBJ_DATA and added

bool customized;
char * custom_name;

I also went to create_object function and set

obj->customized = FALSE;
obj->custom_name = NULL;

now my code is a lot like the enchant weapon code...and goes something like:

ch_ret spell_custom_enchant( int sn, int level, CHAR_DATA *ch, void *vo)
{

OBJ_DATA *obj = (OBJ_DATA *) vo;
AFFECT_DATA *paf;
if (obj->item_type != ITEM_WEAPON)
{
act( AT_MAGIC, "Only weapons can be customized.", ch, obj, NULL, TO_CHAR);
return rSPELL_FAILED;
}
if (obj->customized == TRUE )
{
act( AT_MAGIC, "This already is already customed to someone.", ch, obj, NULL, TO_CHAR );
return rSPELL_FAILED;
}
separate_obj(obj);
obj->customized = TRUE;
strncpy(obj->custom_name, ch->short_descr, 15);
act( AT_MAGIC, "You customize this weapon for yourself.", ch, obj, NULL, TO_CHAR);

if(ch->max_hit > 2200 && ch->damroll > 150)
{
CREATE( paf, AFFECT_DATA, 1 );
paf->type = -1;
paf->duration = -1;
paf->location = APPLY_DAMROLL;
paf->modifier = 50;
xCLEAR_BITS(paf->bitvector);
LINK( paf, obj->first_affect, obj->last_affect, next, prev );
}

return rNONE;
}
everything compiles fine...but when I cast the spell the mud crashes and i get a Segmentation fault (core dumped)

I've tried almost everything I can think of but still stuck after 2 hours...any help is appreciated
#1
Ok so I'm indeed retarded...all that was wrong was ssetting the target to objinv.

All fixed