Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7214 in orxonox.OLD


Ignore:
Timestamp:
Mar 10, 2006, 7:18:03 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now the branche works again, as it did before

Location:
branches/std/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/std/src/lib/lang/base_object.cc

    r7203 r7214  
    3737  this->classID = CL_BASE_OBJECT;
    3838
    39   this->objectName = NULL;
     39  this->objectName = "";
    4040  this->classList = NULL;
    4141  this->xmlElem = NULL;
     
    5252
    5353  //  delete []this->className;
    54   if (this->objectName)
    55     delete[] this->objectName;
    5654  if (this->xmlElem != NULL)
    5755    delete this->xmlElem;
     
    9795void BaseObject::setName (const std::string& objectName)
    9896{
    99   if (this->objectName)
    100     delete[] this->objectName;
    101   if (!objectName.empty())
    102   {
    103     this->objectName = new char[objectName.size()+1];
    104     strcpy(this->objectName, objectName.c_str());
    105   }
    106   else
    107     this->objectName = NULL;
     97  printf("TEST\n");
     98  this->objectName = objectName;
     99  printf("TEST2\n");
    108100}
    109101
     
    175167bool BaseObject::operator==(const char* objectName)
    176168{
    177   if (likely(this->objectName != NULL && objectName != NULL))
    178     return (strcmp(this->objectName, objectName)) ? false : true;
     169  return (objectName != NULL && this->objectName == objectName);
    179170}
    180171
     
    197188int BaseObject::writeState( const byte * data, int length, int sender )
    198189{
    199   SYNCHELP_READ_BEGIN();
    200 
    201   if ( objectName )
     190  /// FIXME STD
     191
     192  /*  SYNCHELP_READ_BEGIN();
     193
     194  if ( !objectName.empty() )
    202195  {
    203196    delete[] objectName;
     
    211204  }
    212205
    213   return SYNCHELP_READ_N;
     206  return SYNCHELP_READ_N;*/
    214207}
    215208
     
    222215int BaseObject::readState( byte * data, int maxLength )
    223216{
    224   SYNCHELP_WRITE_BEGIN();
     217///FIXME STD
     218  /*  SYNCHELP_WRITE_BEGIN();
    225219
    226220  //PRINTF(0)("objectname = %s\n", this->objectName);
    227221  SYNCHELP_WRITE_STRING( this->objectName, NWT_BO_NAME );
    228222
    229   return SYNCHELP_WRITE_N;
    230 }
     223  return SYNCHELP_WRITE_N;*/
     224}
  • branches/std/src/lib/lang/base_object.h

    r7203 r7214  
    3333  void setName (const std::string& newName);
    3434  /** returns the Name of this Object */
    35   inline const char* getName ()const { return this->objectName; };
     35  inline const char* getName ()const { return this->objectName.c_str(); };
    3636  /** @returns the XML-Element with whicht this Object was loaded */
    3737  inline TiXmlNode* getXmlElem() const { return this->xmlElem; };
     
    6060    const char*        className;        //!< the name of the class
    6161    long               classID;          //!< this is the id from the class_id.h enumeration
    62     char*              objectName;       //!< The name of this object
     62    std::string        objectName;       //!< The name of this object
    6363
    6464    ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
  • branches/std/src/lib/util/executor/executor.h

    r7212 r7214  
    4848
    4949    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    50     virtual void execute (BaseObject* object, const void* parameters = NULL) = 0;
     50    virtual void execute (BaseObject* object, const std::string& parameters = "") = 0;
    5151
    5252    /** @returns the Type of this Function (either static or objective) */
     
    192192#define ExecutorExecute1(t1) \
    193193   else if (this->paramCount == 1 && this->defaultValue[0] == t1##_PARAM) \
    194     EXECUTOREXECUTER(_1_##t1)(t1##_FUNC((const char*)parameters, t1##_DEFGRAB(0)))
     194    EXECUTOREXECUTER(_1_##t1)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)))
    195195
    196196//! execute-macro for functions with two parameters
    197197#define ExecutorExecute2(t1,t2) \
    198198   else if (this->paramCount == 2 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM) \
    199     EXECUTOREXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
     199    EXECUTOREXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)))
    200200
    201201//! execute-macro for functions with three parameters
    202202#define ExecutorExecute3(t1,t2,t3) \
    203203   else if (this->paramCount == 3 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM) \
    204     EXECUTOREXECUTER(_3_##t1##_##t2##_##t3)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)))
     204    EXECUTOREXECUTER(_3_##t1##_##t2##_##t3)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2)))
    205205
    206206//! execute-macro for functions with four parameters
    207207#define ExecutorExecute4(t1,t2,t3,t4) \
    208208   else if (this->paramCount == 4 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM) \
    209     EXECUTOREXECUTER(_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3))) \
     209    EXECUTOREXECUTER(_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2)), t4##_FUNC(sub[3], t4##_DEFGRAB(3))) \
    210210
    211211
     
    213213#define ExecutorExecute5(t1,t2,t3,t4,t5) \
    214214   else if (this->paramCount == 5 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM && this->defaultValue[4] == t5##_PARAM) \
    215     EXECUTOREXECUTER(_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)), t5##_FUNC(sub.getString(4), t5##_DEFGRAB(4)))
     215    EXECUTOREXECUTER(_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2)), t4##_FUNC(sub[3], t4##_DEFGRAB(3)), t5##_FUNC(sub[4], t5##_DEFGRAB(4)))
    216216
    217217
     
    242242#define EXECUTORTYPE                   Executor_Objective
    243243//! keeps information about a Executor
    244 template<class T> class ExecutorObjective : public Executor
     244template<class T> class EXECUTOR : public Executor
    245245{
    246246  public:
    247     ExecutorObjective() : Executor() { };
     247    EXECUTOR() : Executor() { };
    248248    // COPY constuctor (virtual version)
    249249    virtual Executor* clone () const
    250250    {
    251       ExecutorObjective<T>* executor = new ExecutorObjective<T>();
     251      EXECUTOR<T>* executor = new EXECUTOR<T>();
    252252      this->cloning(executor);
    253253      executor->fp = this->fp;
     
    268268    } fp;
    269269
    270     virtual void execute (BaseObject* object, const void* parameters = NULL)
     270    virtual void execute (BaseObject* object, const std::string& parameters = "")
    271271    {
    272272      SubString sub;
    273       printf("===%s\n", (const char*)parameters);
    274       if (parameters != NULL)
    275         sub.split((const char*)parameters, " \n\t,", '\\');
     273      printf("===%s\n", parameters.c_str());
     274      sub.split(parameters, " \n\t,", '\\');
     275      sub.debug();
    276276//! FUNCTOR_LIST is the List of Executive Functions
    277277#define FUNCTOR_LIST(x) ExecutorExecute ## x
     
    309309{
    310310  public:
    311     ExecutorStatic() : Executor() { };
     311    EXECUTOR() : Executor() { };
    312312    // COPY constuctor
    313313    virtual Executor* clone () const
    314314    {
    315       ExecutorStatic<T>* executor = new ExecutorStatic<T>();
     315      EXECUTOR<T>* executor = new EXECUTOR<T>();
    316316      this->cloning(executor);
    317317      executor->fp = this->fp;
     
    333333
    334334
    335     virtual void execute (BaseObject* object, const void* parameters = NULL)
     335    virtual void execute (BaseObject* object, const std::string& parameters = "")
    336336    {
    337337      SubString sub;
    338       if (parameters != NULL)
    339         sub.split((const char*)parameters, " \n\t,", '\\');
     338      sub.split(parameters, " \n\t,", '\\');
    340339//! FUNCTOR_LIST is the List of Executive Functions
    341340#define FUNCTOR_LIST(x) ExecutorExecute ## x
  • branches/std/src/lib/util/executor/executor_specials.h

    r7197 r7214  
    6060     * @param loadString ignored in this case
    6161     */
    62     virtual void execute(BaseObject* object, const void* parameters = NULL)
     62    virtual void execute(BaseObject* object, const std::string& = "")
    6363    {
    6464      if (object != NULL && this->element != NULL)
  • branches/std/src/lib/util/executor/functor_list.h

    r7203 r7214  
    7474//#define l_VECTOR_DEFAULT   Vector(0,0,0)        //!< Default value for a VECTOR
    7575
    76 #define l_CSTRING_TYPE     const char*          //!< The type of a STRING
    77 #define l_CSTRING_FUNC     isCString            //!< The function to parse a STRING
    78 #define l_CSTRING_NAME     "cstring"            //!< The name of a STRING
    79 #define l_CSTRING_PARAM    MT_STRING            //!< the type of the parameter STRING
    80 #define l_CSTRING_DEFAULT  ""                   //!< a default Value for an STRING
     76#define l_CSTRING_TYPE     const char*          //!< The type of a CSTRING
     77#define l_CSTRING_FUNC     isCString            //!< The function to parse a CSTRING
     78#define l_CSTRING_NAME     "cstring"            //!< The name of a CSTRING
     79#define l_CSTRING_PARAM    MT_STRING            //!< the type of the parameter CSTRING
     80#define l_CSTRING_DEFAULT  ""                   //!< a default Value for an CSTRING
    8181
    8282#define l_STRING_TYPE      const std::string&   //!< The type of a STRING
    8383#define l_STRING_FUNC      isString             //!< The function to parse a STRING
    8484#define l_STRING_NAME      "string"             //!< The name of a STRING
    85 #define l_STRING_PARAM     MT_STRING            //!< the type of the parameter STRING
     85#define l_STRING_PARAM     MT_CSTRING           //!< the type of the parameter STRING
    8686#define l_STRING_DEFAULT   ""                   //!< a default Value for an STRING
    8787
  • branches/std/src/lib/util/helper_functions.cc

    r7211 r7214  
    104104{
    105105  if (STRING.size() > 0)
     106  {
     107    printf("DECISION1: %s\n", STRING.c_str());
    106108    return STRING;
     109  }
    107110  else
     111  {
     112    printf("DECISION2: %s\n", defaultValue.c_str());
    108113    return defaultValue;
     114  }
    109115}
    110116
  • branches/std/src/lib/util/loading/load_param.cc

    r7212 r7214  
    6666          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
    6767    {
    68       PRINTF(0)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName.c_str(), loadString.c_str(), this->object->getName(), this->object->getClassName());
    69       this->executor->execute(this->object, (const void*)loadString.c_str());
     68      PRINTF(0)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassName(), this->object->getName());
     69      this->executor->execute(this->object, loadString);
    7070    }
    7171    delete this->executor;
  • branches/std/src/lib/util/multi_type.cc

    r7211 r7214  
    5555      break;
    5656    case MT_STRING:
     57    case MT_CSTRING:
    5758      this->storedString = "";
    5859      break;
  • branches/std/src/lib/util/multi_type.h

    r7211 r7214  
    2424  MT_EXT1            = 32,                 //!< An external Type.
    2525  MT_EXT2            = 64,                 //!< An external Type.
     26
     27  MT_CSTRING         = 128,                //!< An entire String.
    2628} MT_Type;
    2729
  • branches/std/src/lib/util/substring.cc

    r7212 r7214  
    6363}
    6464
     65/**
     66 * An empty String
     67 */
     68const std::string SubString::emptyString = "";
     69
     70
    6571
    6672unsigned int SubString::split(const std::string& string, char splitter)
     
    101107
    102108/**
    103  * splits line into tokens and stores them in ret. Supports delimiters, escape characters,
     109 * @brief splits line into tokens and stores them in ret.
     110 * @param ret the Array, where the Splitted strings will be stored in
     111 * @param offsets an Array of Offsets, here the distance from the inputstring
     112 * to the beginning of the current token is stored
     113 * @param line the inputLine to split
     114 * @param delimiters a String of Delimiters (here the input will be splitted)
     115 * @param escape_char: Escape carater (escapes splitters)
     116 * @param safemode_char: the beginning of the safemode is marked with this
     117 * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line)
     118 * @param start_state: the Initial state on how to parse the String.
     119 * @returns SPLIT_LINE_STATE the parser was in when returning
     120 *
     121 * Supports delimiters, escape characters,
    104122 * ignores special  characters between safemode_char and between comment_char and linend '\n'.
    105123 *
    106  * @returns SPLIT_LINE_STATE the parser was in when returning
    107124 */
    108125SPLIT_LINE_STATE SubString::splitLine(std::vector<std::string>& ret, std::vector<unsigned int>& offsets,
  • branches/std/src/lib/util/substring.h

    r7212 r7214  
    3535
    3636  inline unsigned int getCount() { return this->strings.size(); };
    37   const std::string& getString(unsigned int i) { return this->strings[i]; };
     37  const std::string& getString(unsigned int i) { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
    3838  unsigned int getOffset(unsigned int i);
    3939
     
    4848   std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    4949   std::vector<unsigned int> offsets;                      //!< offsets of the beginning of the input-string to the beginning of each substring.
     50
     51   static const std::string emptyString;
    5052};
    5153
  • branches/std/src/story_entities/story_entity.cc

    r7203 r7214  
    4242  this->loadFile = "";
    4343  this->storyID = -1;
    44   this->description = NULL;
    45   this->menuItemImage = NULL;
    46   this->menuScreenshoot = NULL;
     44  this->description = "";
     45  this->menuItemImage = "";
     46  this->menuScreenshoot = "";
    4747  this->nextStoryID = WORLD_ID_GAMEEND;
    4848  this->bMenuEntry = false;
     
    117117 * @param name name
    118118 */
    119 void StoryEntity::setDescription(const char* description)
     119void StoryEntity::setDescription(const std::string& description)
    120120{
    121   if (this->description)
    122     delete[] this->description;
    123   if (description!= NULL)
    124   {
    125     this->description= new char[strlen(description)+1];
    126     strcpy(this->description, description);
    127   }
    128   else this->description= NULL;
     121  this->description = description;
    129122}
    130123
     
    178171 * @param name name
    179172 */
    180 void StoryEntity::setMenuItemImage(const char* image)
     173void StoryEntity::setMenuItemImage(const std::string& image)
    181174{
    182   if (this->menuItemImage)
    183     delete[] this->menuItemImage;
    184   if (image != NULL)
    185   {
    186     this->menuItemImage = new char[strlen(image)+1];
    187     strcpy(this->menuItemImage, image);
    188   }
    189   else this->menuItemImage = NULL;
     175  this->menuItemImage = image;
    190176}
    191177
    192178
    193 /** sets the menu screenshoot of this StoryEntity @param name name */
    194 void StoryEntity::setMenuScreenshoot(const char* image)
     179/** sets the menu screenshoot of this StoryEntity
     180 * @param name name
     181 */
     182void StoryEntity::setMenuScreenshoot(const std::string& image)
    195183{
    196   if (this->menuScreenshoot)
    197     delete[] this->menuScreenshoot;
    198   if (image != NULL)
    199   {
    200     this->menuScreenshoot = new char[strlen(image)+1];
    201     strcpy(this->menuScreenshoot, image);
    202   }
    203   else this->menuScreenshoot = NULL;
     184  this->menuScreenshoot = image;
    204185}
    205186
  • branches/std/src/story_entities/story_entity.h

    r7203 r7214  
    6868  /**  gets the story id of the current entity @returns story id */
    6969  inline int getNextStoryID() const { return this->nextStoryID; }
    70   inline void setDescription(const char* description);
     70  inline void setDescription(const std::string& description);
    7171  /** @returns the description of this StoryEntity */
    72   inline const char* getDescription() { return this->description; }
     72  inline const std::string& getDescription() { return this->description; }
    7373
    7474  void grabWorldInfo();
     
    7878  inline bool isContainedInMenu() { return this->bMenuEntry; }
    7979  /** sets the menu item image of this StoryEntity @param name name */
    80   inline void setMenuItemImage(const char* image);
     80  inline void setMenuItemImage(const std::string& image);
    8181  /** @returns the menu item image of this StoryEntity */
    82   inline const char* getMenuItemImage() { return this->menuItemImage; }
    83   inline void setMenuScreenshoot(const char* image);
     82  inline const std::string& getMenuItemImage() { return this->menuItemImage; }
     83  inline void setMenuScreenshoot(const std::string& image);
    8484  /** @returns the menu screenshoot of this StoryEntity */
    85   inline const char* getMenuScreenshoot() { return this->menuScreenshoot; }
     85  inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; }
    8686
    8787  protected:
     
    9696    std::string   loadFile;         //!< The file from which this world is loaded
    9797
    98     char*         description;      //!< the description of the StoryEntity
    99     char*         menuItemImage;    //!< the item image of the StoryEntity
    100     char*         menuScreenshoot;  //!< the screenshoot of the StoryEntity
     98    std::string   description;      //!< the description of the StoryEntity
     99    std::string   menuItemImage;    //!< the item image of the StoryEntity
     100    std::string   menuScreenshoot;  //!< the screenshoot of the StoryEntity
    101101    bool          bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    102102};
  • branches/std/src/world_entities/elements/image_entity.cc

    r7193 r7214  
    106106 * @param textureFile The texture-file to load onto the crosshair
    107107 */
    108 void ImageEntity::setTexture(const char* textureFile)
     108void ImageEntity::setTexture(const std::string& textureFile)
    109109{
    110110  this->material->setDiffuseMap(textureFile);
  • branches/std/src/world_entities/elements/image_entity.h

    r7016 r7214  
    3030
    3131  void setSize(float sizeX, float sizeY);
    32   void setTexture(const char* textureFile);
     32  void setTexture(const std::string& textureFile);
    3333  /** @param rotationSpeed the speed at what the crosshair should rotate */
    3434  void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; };
Note: See TracChangeset for help on using the changeset viewer.