/* ....[@@@..[@@@..............[@.................. MUD++ is a written from ....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and ....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++. ....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing ....[@......[@..[@@@@@..[@@@@@.................. development project. All ................................................ contributions are welcome. ....Copyright(C).1995.Melvin.Smith.............. Enjoy. ------------------------------------------------------------------------------ Melvin Smith (aka Fusion) msmith@hom.net MUD++ development mailing list mudpp@van.ml.org ------------------------------------------------------------------------------ mudobj.cc */ #include "config.h" #include "mudobj.h" #include "llist.h" #include "action.h" #include "affect.h" /* MudObject destructor */ MudObject::~MudObject() { Action * act; // Delete all actions that the object owns o_list.reset(); while ( ( act = o_list.remove() ) ) { // Call interrupt to ensure the action is removed from // BOTH owner AND target act->interrupt(); } // Now remove all actions that the object is a target for t_list.reset(); while ( ( act = t_list.remove() ) ) { // Call interrupt to ensure the action is removed from // BOTH owner AND target act->interrupt(); } Affect * aff; while( ( aff = aff_list.remove() ) ) aff->fordelete(); struct TriggerData * td; while( ( td = triggers.remove() ) ) delete td; } void MudObject::addAffect( Affect * paf ) { Modifier * mod; for_each( paf->mod_list, mod ) modify( mod, true ); SET_BIT( aff_bits, paf->getType() ); aff_list.add( paf ); } void MudObject::rmAffect( int aftype ) { Affect * paf; Modifier * mod; for_each( aff_list, paf ) { if( paf->getType() != aftype ) continue; aff_list.remove(); CLR_BIT( aff_bits, aftype ); for_each( paf->mod_list, mod ) modify( mod, false ); } } Affect * MudObject::getAffect( int aftype ) { Affect * paf; for_each( aff_list, paf ) if( paf->getType() == aftype ) return paf; return 0; } void * MudObject::findTrigger( int type ) { struct TriggerData * tmp_td; for_each( triggers, tmp_td ) { if ( tmp_td->type == type ) return tmp_td->fun; } Cout << "Trigger bit set, but no trigger function. Aborting."<< endl; abort(); // shouldn't go here return NULL; }