Greetings and salutations,
This question concerns the snippet 'addapply' which adds new affects to
objects (not related to OLC's addapply). For all I can tell, it seems to
work well and correctly adds the affect to the object. However, save.c
(fwrite_obj) doesn't seem to save the object correctly if there are 2
applies of the same type. For instance:
>addapply mace damroll 50
Ok.
> stat mace
...
Affects damage roll by 50, level 210. (I added this)
Affects damage roll by 1, level 6. (naturally occurs on object)
I now saved and popped the pfile open to take a look.
#O
Vnum 3024
Enchanted
Nest 0
Wt 0
Cond 0
Wear 16
Cost 390
Val 4 20 20 7 0
Affc 'reserved' 0 6 -1 1 19 0
End
Eek! It didn't add the damroll by 50! Is the error in addapply, or in
fwrite_obj?
here's the fwrite_obj part of where it saves affects:
for (paf = obj->affected; paf != NULL; paf = paf->next)
{
if (paf->type < 0 || paf->type >= MAX_SKILL)
continue;
fprintf (fp, "Affc '%s' %3d %3d %3d %3d %3d %10d\n",
skill_table[paf->type].name,
paf->where,
paf->level,
paf->duration, paf->modifier, paf->location,
paf->bitvector);
}
And, also for reference, here's how addapply adds affects (fairly long)
if (!obj->enchanted)
{
obj->enchanted = TRUE;
for (paf = obj->pIndexData->affected; paf != NULL; paf = paf->next)
{
if (affect_free == NULL)
af_new = alloc_perm(sizeof(*af_new));
else
{
af_new = affect_free;
affect_free = affect_free->next;
}
af_new->next = obj->affected;
obj->affected = af_new;
af_new->type = UMAX(0,paf->type);
af_new->level = paf->level;
af_new->duration = paf->duration;
af_new->location = paf->location;
af_new->modifier = paf->modifier;
af_new->bitvector = paf->bitvector;
} /*ends for loop*/
}/*ends if !obj->enchanted*/
if (affect_free == NULL)
paf = alloc_perm(sizeof(*paf));
else
{
paf = affect_free;
affect_free = affect_free->next;
}
paf->type = -1;
paf->level = ch->level;
paf->duration = -1;
paf->location = enchant_type;
paf->modifier = affect_modify;
paf->bitvector = bit;
... (skipping spell affects)
paf->next = obj->affected;
obj->affected = paf;
send_to_char("Ok.\n\r", ch);
} /*end of function*/
Any ideas? Thank you in advance.