Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5155 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Aug 27, 2005, 3:39:26 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now one should be able to create entities on the Fly

Location:
trunk/src/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/loading/factory.cc

    r4836 r5155  
    1616
    1717#include "factory.h"
     18
     19#include "shell_command.h"
    1820#include "game_loader.h"
    19 
    2021using namespace std;
    2122
     
    6869
    6970  if( Factory::first == NULL)
     71  {
    7072    Factory::first = factory;
     73    ShellCommand<Factory>::registerCommand("create", CL_FACTORY, &Factory::fabricate);
     74  }
    7175  else
    7276  {
     
    7983  }
    8084}
     85
     86void Factory::fabricate(const char* className, const char* entityName)
     87{
     88  if (className == NULL)
     89    return;
     90  Factory* fac = Factory::first;
     91
     92  while (fac != NULL)
     93  {
     94    if (!strcmp(className, fac->getName()))
     95    {
     96      PRINTF(3)("Create a new Object of type %s\n", fac->getName());
     97      BaseObject* object = fac->fabricate(NULL);
     98      if (object != NULL)
     99      {
     100        object->setName(entityName);
     101      }
     102      break;
     103    }
     104    fac = fac->next;
     105  }
     106}
  • trunk/src/util/loading/factory.h

    r4932 r5155  
    2626
    2727#include "tinyxml.h"
    28 #include "load_param.h"
    2928#include "base_object.h"
    3029#include "debug.h"
     
    4443  ~Factory ();
    4544
    46 
     45  void fabricate(const char* className, const char* entityName);
    4746  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    4847
  • trunk/src/util/shell_command.cc

    r5154 r5155  
    139139  while(elem != NULL)
    140140  {
    141     printf("%s\n", elem->getName());
     141    printf("%s::%s\n", elem->className, elem->getName());
    142142    if (!strncasecmp (executionString, elem->className, strlen(elem->className)) &&
    143143         (*(executionString+strlen(elem->className)) == ' ' ||
     
    170170        while(*commandBegin == ' ')
    171171          commandBegin++;
    172         tList<BaseObject>* list =  ClassList::getList(elem->classID);
     172        tList<BaseObject>* list = ClassList::getList(elem->classID);
    173173        if (list == NULL)
    174174          break;
  • trunk/src/util/shell_command.h

    r5153 r5155  
    1010
    1111#include "helper_functions.h"
    12 #include "functor_list.h"
    1312#include "substring.h"
     13#include "functor_list.h"
    1414
    1515#include <stdarg.h>
Note: See TracChangeset for help on using the changeset viewer.