示例#1
0
/* function   :: dequeue_event()
 * arguments  :: the event to dequeue.
 * ======================================================
 * This function takes an event which has _already_ been
 * enqueued, and removes it both from the event queue, and
 * from the owners local list. This function is usually
 * called when the owner is destroyed or after the event
 * is executed.
 */
void dequeue_event(EVENT_DATA *event)
{
  /* dequeue from the bucket */
  DetachFromList(event, eventqueue[event->bucket]);

  /* dequeue from owners local list */
  switch(event->ownertype)
  {
    default:
      bug("dequeue_event: event type %d has no owner.", event->type);
      break;
    case EVENT_OWNER_GAME:
      DetachFromList(event, global_events);
      break;
    case EVENT_OWNER_DMOB:
      DetachFromList(event, event->owner.dMob->events);
      break;
    case EVENT_OWNER_DSOCKET:
      DetachFromList(event, event->owner.dSock->events);
      break;
  }

  /* free argument */
  free(event->argument);

  /* attach to free stack */
  PushStack(event, event_free);
}
示例#2
0
void move_mob( D_MOBILE *dMob, const char *dir )
{
   D_EXIT *exit;
   
   if( !dMob || !dir )
      return;
      
   if( !dMob->room )
   {
      bug( "Error: Player (%s) without room. Sending to the void...", dMob->name );
      dMob->room = frbv( 1 );//default to the void if they don't have a room assigned to them
      if( !dMob->room ) //if the void doesn't even exist...
      {
         bug( "Error: Can Not Find The Void Room!" );
         return;
      }
   }
   
   exit = febn( dir, dMob->room->exits );
   if( !exit || !exit->dest )
   {
      if( exit && !exit->dest )
         bug( "Error: Exit with non-existent room in room %i.", dMob->room->vnum );
      text_to_mobile( dMob, "Alas, you can not go that way.\r\n" );
      return;
   }
   switch( exit->state )
   {
      case STATE_OPEN:
      case STATE_DOOR_OPEN:
      case STATE_DOOR_OPEN_BROKEN:
      {
         break;
      }
      case STATE_DOOR_CLOSED:
      case STATE_DOOR_CLOSED_BROKEN:
      case STATE_DOOR_CLOSED_LOCKED:
      {
         text_to_mobile( dMob, "The %s is closed.\r\n", exit->desc );
         return;
      }
      default:
      {
         bug( "Exit \'%s\' in invalid state in room %i.", exit->name, dMob->room->vnum );
         return;
      }
   }

   DetachFromList( dMob, dMob->room->mobiles );
   dMob->room = exit->dest;
   AttachToList( dMob, dMob->room->mobiles );
   
   cmd_look( dMob, "" );
   
   return;
}
示例#3
0
文件: id.c 项目: m241dan/PainProject
I_ID *check_free( ID_HANDLER *handler )
{
   ITERATOR Iter;
   I_ID *id;

   if( SizeOfList( handler->free_ids ) <= 0 )
      return NULL;

   AttachIterator( &Iter, handler->free_ids );
   id = NextInList( &Iter );
   DetachFromList( id, handler->free_ids );
   DetachIterator( &Iter );
   return id;
}
示例#4
0
文件: id.c 项目: m241dan/PainProject
/* deletion */
void free_id_handler( ID_HANDLER *handler )
{
   I_ID *id;
   ITERATOR Iter;

   /* no other pointers to free at the moment */
   DetachFromList( handler, id_handlers );
   AttachIterator( &Iter, handler->free_ids );
   while ( ( id = (I_ID *)NextInList(&Iter) ) == NULL )
      free_i_id( id );
   DetachIterator( &Iter );

   free( handler ); /*free the memory alotted for the handler*/
   return;
}