I'm sure there's been countless threads and numerous posts with relevant
bugfixes for how ROM by default loads the affects for players, but I haven't
been around that long to see these countless threads and numerous posts, so
I'll just go ahead and post this message anyway. :)

ROM loads affects perfectly for stock ROM (obviously) but when you start
doing quirky things like adding a bunch of affects to different races and
adding perm affects to objects, things start to get dicey.  Especially if
your MUD allows race changing and you don't want to keep the old races'
affects around (of course, you'd have to modify immunities, resistances, etc
much like affects, here, if you didn't want those hanging around too)

If objects somehow disappear off your players' bodies--say maybe you messed
with vnums, messed with the object, or what have you--by default that player
will still have that old affect stored on his pfile, forever (well, at least
for affects without spell castings, anyway--not 100% sure of affects that
spells modify).   Also, extract_obj doesn't remove spell affects cast by
items, for example (say your wand cast perm sanc on you and you overloaded
it and poof! no more wand--but you'd still be affected by sanc permanently).

To go about fixing this, I modified save.c and nanny.c:
Save.c:
ch->affected_by = ch->affected_by | race_table[ch->race].aff;
(Line 950ish)
changed to just
ch->affected_by = race_table[ch->race].aff;

(You could also remove the KEY that loads AfBy if you wanted)

And nanny.c, below
            else
            {
                char_to_room (ch, get_room_index (ROOM_VNUM_TEMPLE));
            }
(Line 829ish)
I added this:
            /*reload spell affects onto player.*/
            send_to_char("\n\rLoading spell affects..", ch);
            AFFECT_DATA *paf;
            OBJ_DATA *obj;
            int loc;

            for (loc = 0; loc < MAX_WEAR; loc++)
            {
                obj = get_eq_char (ch, loc);
                if (obj == NULL)
                    continue;
            if (!obj->enchanted)
                for (paf = obj->pIndexData->affected; paf != NULL; paf =
paf->next)
                    if (paf->location != APPLY_SPELL_AFFECT)
                        {
                         if (paf->where == TO_AFFECTS)
                         SET_BIT (ch->affected_by, paf->bitvector);
                        }
            for (paf = obj->affected; paf != NULL; paf = paf->next)
                if (paf->location == APPLY_SPELL_AFFECT)
                    affect_to_char (ch, paf);
            }

           send_to_char("..done.\n\r", ch);

Look familiar?  It should.  :)

Another solution would be fixing extract_obj, but there may be other
loopholes that develop if you just change extract_obj.

I'm sure there's probably more elegant and sophisticated ways of going about
this, but, frankly, I'm not a sophisticated nor elegant coder yet, so those
ways are as of yet unknown to me.  Anyway, I hope this may possibly help fix
a potential bug for some of you!

Jeremy Hill
'Evangelion'
Shards of Eternity  <shards.firstlight.net:7778> (pre-alpha)


Reply via email to