/**********************************************************************
This file is part of Crack dot Com's free source code release of Golgotha.
for information about compiling & licensing issues visit this URL
 If that doesn't help, contact Jonathan Clark at 
  golgotha_source@usa.net (Subject should have "GOLG" in it) 
***********************************************************************/

#include "error/error.hh"
#include "remove_man.hh"
#include "g1_object.hh"

const int MAX_REMOVES = 100;

g1_remove_manager_class g1_remove_man;
 

void g1_remove_manager_class::request_remove(g1_object_class *obj)
{
  if (obj->get_flag(g1_object_class::MAP_OCCUPIED))
    i4_error("deleted object while still on map");

  if (!g1_global_id.check_id(obj->global_id))
    i4_error("removing a piece with invalid id (name=%s)!", obj->name());

  obj->flags |= g1_object_class::DELETED;

  if (obj->flags & g1_object_class::THINKING)
    obj->stop_thinking();
  
  if (removes *ref_list = &remove_list[j]->ref_list;

    while (!ref_list->empty())
    {
      i4_isl_list::iterator i=ref_list->begin();      
      ref_list->erase();

      i->ref = 0;
    }

    delete remove_list[j];
  }
  removes = 0;
}