Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8210 in orxonox.OLD


Ignore:
Timestamp:
Jun 7, 2006, 8:29:58 PM (18 years ago)
Author:
snellen
Message:

implemented reset function of the script manager

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/script_engine/src/lib/script_engine/script_manager.cc

    r8208 r8210  
    2323ScriptManager::~ScriptManager()
    2424{
    25 
     25  // delete all scripts since they are useless without the manager
     26  if(getScripts())
     27    for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )
     28  {
     29    ClassList::removeFromClassList( (*it) );
     30  }
    2631
    2732}
     
    3035void ScriptManager::loadParams(const TiXmlElement* root)
    3136{
     37  this->reset();
    3238  //BaseObject::loadParams(root);
    3339  {
    34   LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers); 
    35  
     40  LoadParamXML(root, "ScriptTriggers", this, ScriptManager, createTriggers);
     41
    3642  LoadParamXML(root, "Scripts", this, ScriptManager, createScripts);
    3743  } // make shure that the loading process is finished
    38  
     44
    3945  // fill the scripts and triggers (doing that on runtime is very slow!)
    4046  getTriggers();
    4147  getScripts();
    42  
    43  
     48
     49
    4450}
    4551
    4652void  ScriptManager::reset()
    4753{
    48   //TODO: delete all scripts and triggers, empty lists.
     54  //Delete all scripts as they aren't deleted automatically
     55  if(getScripts())
     56    for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )
     57  {
     58    ClassList::removeFromClassList( (*it) );
     59  }
    4960
    50 
    51 
     61  this->scripts = NULL;
     62  this->triggers = NULL;
    5263}
    5364
     
    5667  //this->setClassID("");
    5768  this->setName("ScriptManager");
    58  
     69
    5970  this->scripts = NULL;
    6071  this->triggers = NULL;
     
    6475void  ScriptManager::createScripts(const TiXmlElement* scripts)
    6576{
    66  
     77
    6778  LOAD_PARAM_START_CYCLE(scripts, object);
    6879  {
     
    94105     }
    95106   }
    96    
     107
    97108  return NULL;
    98109
     
    102113bool ScriptManager::getScripts()
    103114{
    104   return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL); 
     115  return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL);
    105116}
    106117
    107118bool ScriptManager::getTriggers()
    108119{
    109   return (this->triggers != NULL || (this->triggers = ClassList::getList(CL_SCRIPT_TRIGGER)) != NULL); 
     120  return (this->triggers != NULL || (this->triggers = ClassList::getList(CL_SCRIPT_TRIGGER)) != NULL);
    110121}
    111122
Note: See TracChangeset for help on using the changeset viewer.