/*  Enable_commands() handles both the efuns enable_commands() and
    disable_commands(). This version patches disable_commands() so
    that it only sets command_giver to 0 if it's equal to 
    current_object and also frees all actions. The old version
    crashed for disable_commands() because it always set command_giver
    to 0. Exchange the one in simulate.c
		/Gwendolyn@nannymud.lysator.liu.se 2000
 */

------------------------------------------------------------------------

void enable_commands(int num)
{
   struct sentence *sen, *tmp;
   if(current_object->flags & O_DESTRUCTED)
      return;
   if(d_flag > 1)
   {
      debug_message("Enable commands %s (ref %d)\n",
	            current_object->name, current_object->ref);
   }
   if(num)
   {
      current_object->flags |= O_ENABLE_COMMANDS;
      command_giver = current_object;
   }
   else
   {
      current_object->flags &= ~O_ENABLE_COMMANDS;
      sen = current_object->sent;
      current_object->sent = (struct sentence *) 0;
      while(sen)
      {
         tmp = sen->next;
         free_sentence(sen);
         sen = tmp;
      }
      if(current_object == command_giver)
         command_giver = 0;
   }
}