Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2006, 12:03:59 AM (18 years ago)
Author:
bensch
Message:

adapted script_engine

File:
1 edited

Legend:

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

    r9003 r9699  
    2424#include "lunar.h"
    2525
    26 #include "class_list.h"
    27 
    2826#include "script.h"
    2927#include "script_trigger.h"
     
    3735{
    3836  this->setName("ScriptManager");
    39   this->scripts = NULL;
    40   this->triggers = NULL;
    4137
    4238  if (root != NULL)
     
    6258
    6359  // fill the scripts and triggers (doing that on runtime is very slow!)
    64   getTriggers();
    65   getScripts();
    6660}
    6761
     
    7165{
    7266  //Delete all scripts as they aren't deleted automatically
    73   if(this->getScripts())
    74     while(!scripts->empty())
    75       delete scripts->front();
     67  while(!Script::objectList().empty())
     68    delete Script::objectList().front();
    7669  //Delete all triggers
    77   if(this->getTriggers())
    78     while(!triggers->empty())
    79       delete triggers->front();
    80  
     70  while(!ScriptTrigger::objectList().empty())
     71    delete ScriptTrigger::objectList().front();
     72
    8173}
    8274
     
    10597Script* ScriptManager::getScriptByFile(const std::string& file)
    10698{
    107   if(getScripts())
    108     for(std::list<BaseObject*>::const_iterator it = scripts->begin(); it != scripts->end(); it++ )
    109     {
    110       if( (dynamic_cast<Script*>(*it))->getFileName().compare(file) == 0)
    111       {
    112         return dynamic_cast<Script*>(*it);
    113       }
    114     }
     99  for (NewObjectList<Script>::const_iterator it = Script::objectList().begin();
     100       it != Script::objectList().end();
     101       ++it)
     102    if( ((*it))->getFileName().compare(file) == 0)
     103      return (*it);
    115104
    116105  return NULL;
    117106
    118107}
    119 
    120 
    121 bool ScriptManager::getScripts()
    122 {
    123   return (this->scripts != NULL || (this->scripts = ClassList::getList(CL_SCRIPT)) != NULL);
    124 }
    125 
    126 bool ScriptManager::getTriggers()
    127 {
    128   return (this->triggers != NULL || (this->triggers = ClassList::getList(CL_SCRIPT_TRIGGER)) != NULL);
    129 }
    130 
    131 
    132 
Note: See TracChangeset for help on using the changeset viewer.