/* This is a Small function i find very very useful
 * Basicly, what it does (if it isn't obvious) is join
 * two identical affects on an object. So lets say your
 * enchant weapon adds 50 hps to an object that has 26 already.
 * well, saying it twice is lame. This consolidates the affect into
 * one single affect. This is a literal rip of affect_join, just replaced
 * CHAR_DATA with obj_data and changed ch-> to obj-> ;)
 * Its a very handy addition to any mud.
 *
 * I require no credit for this, since it isn't even my code, i just replaced
 * 4 refrences. Enjoy

 * -Thri
 * Admin/Owner/Coder/Only Builder Soulblight Mud
 * http://soulblight.slayn.net
 * telnet://soulblight.slayn.net:5500
 * AIM: CalibanL
 */




void affect_join_obj (OBJ_DATA * obj, AFFECT_DATA * paf)
{
    AFFECT_DATA *paf_old;
    bool found;

    found = FALSE;
    for (paf_old = obj->affected; paf_old != NULL; paf_old = paf_old->next)
    {
        if (paf_old->type == paf->type)
        {
            paf->level = (paf->level += paf_old->level) / 2;
            paf->duration += paf_old->duration;
            paf->modifier += paf_old->modifier;
            affect_remove_obj (obj, paf_old);
            break;
        }
    }

    affect_to_obj (obj, paf);
    return;
}