Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8350 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jun 13, 2006, 10:01:55 PM (19 years ago)
Author:
bensch
Message:

fixed out some warnings

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/base_object.h

    r8035 r8350  
    2121
    2222//! A class all other classes are derived from
    23 class BaseObject {
     23class BaseObject
     24{
    2425
    25  public:
    26    BaseObject (const std::string& objectName = "");
     26public:
     27  BaseObject (const std::string& objectName = "");
    2728
    2829  virtual ~BaseObject ();
     
    4950  bool operator==(ClassID classID) { return this->isA(classID); };
    5051
    51  protected:
    52    void setClassID(ClassID classID, const std::string& className);
    53    std::string        objectName;        //!< The name of this object
     52protected:
     53  void setClassID(ClassID classID, const std::string& className);
    5454
    55  private:
    56     std::string        className;        //!< the name of the class
    57     long               classID;          //!< this is the id from the class_id.h enumeration
    58     ClassID            leafClassID;      //!< The Leaf Class ID
     55protected:
     56  std::string        objectName;       //!< The name of this object
    5957
    60     ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
     58private:
    6159
    62     TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved).
     60  std::string        className;        //!< the name of the class
     61  long               classID;          //!< this is the id from the class_id.h enumeration
     62  ClassID            leafClassID;      //!< The Leaf Class ID
     63
     64  ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
     65
     66  TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved).
    6367};
    6468
  • trunk/src/lib/physics/physics_interface.cc

    r7130 r8350  
    100100void PhysicsInterface::applyForce(const Vector& force)
    101101{
    102   PNode* tmp = dynamic_cast<PNode*>((BaseObject*)this);
    103102  this->forceSum += force;
    104103  this->bForceApplied = true;
  • trunk/src/lib/shell/shell_buffer.cc

    r8145 r8350  
    9999    std::string inputBuffer = this->keepBuffer + line;
    100100
    101     int lineBegin = 0;
    102     int lineEnd = 0;
     101    unsigned int lineBegin = 0;
     102    unsigned int lineEnd = 0;
    103103    // adding all the new Lines
    104104    while (lineEnd < inputBuffer.size())
  • trunk/src/lib/shell/shell_command.cc

    r7771 r8350  
    149149  const ShellCommand* const ShellCommand::getCommandFromInput(const std::string& inputLine, unsigned int& paramBegin, std::vector<BaseObject*>* boList)
    150150  {
    151     ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin);
     151    return ShellCommand::getCommandFromInput(SubString(inputLine, SubString::WhiteSpaces), paramBegin);
    152152  }
    153153
     
    194194    if (cmdClass != NULL)
    195195    {
    196       const ShellCommand* retCmd;
     196      const ShellCommand* retCmd = NULL;
    197197      // Function/Command right after Class
    198198      if (strings.size() >= 1)
  • trunk/src/lib/sound/ogg_player.cc

    r8316 r8350  
    275275    }
    276276    PRINTF(4)("End the AudioThread\n");
     277    return 0;
    277278  }
    278279
  • trunk/src/lib/sound/sound_engine.cc

    r7729 r8350  
    302302    this->allocateSources(this->maxSourceCount);
    303303    this->checkError("Allocating Sources", __LINE__);
     304
     305    return true;
    304306  }
    305307
     
    336338    {
    337339      PRINTF(2)("Failed to allocate %d of %d SoundSources\n", failCount, count);
     340      return false;
    338341    }
    339342  }
     
    388391    switch(err)
    389392    {
    390     case AL_NO_ERROR:
    391       return ("AL_NO_ERROR");
    392     case AL_INVALID_NAME:
    393       return ("AL_INVALID_NAME");
    394     case AL_INVALID_ENUM:
    395       return ("AL_INVALID_ENUM");
    396     case AL_INVALID_VALUE:
    397       return ("AL_INVALID_VALUE");
    398     case AL_INVALID_OPERATION:
    399       return ("AL_INVALID_OPERATION");
    400     case AL_OUT_OF_MEMORY:
    401       return ("AL_OUT_OF_MEMORY");
     393      default:
     394      case AL_NO_ERROR:
     395        return ("AL_NO_ERROR");
     396      case AL_INVALID_NAME:
     397        return ("AL_INVALID_NAME");
     398      case AL_INVALID_ENUM:
     399        return ("AL_INVALID_ENUM");
     400      case AL_INVALID_VALUE:
     401        return ("AL_INVALID_VALUE");
     402      case AL_INVALID_OPERATION:
     403        return ("AL_INVALID_OPERATION");
     404      case AL_OUT_OF_MEMORY:
     405        return ("AL_OUT_OF_MEMORY");
    402406    };
    403407  }
     
    408412    switch(err)
    409413    {
    410     case ALC_NO_ERROR:
    411       return ("AL_NO_ERROR");
    412     case ALC_INVALID_DEVICE:
    413       return ("ALC_INVALID_DEVICE");
    414     case ALC_INVALID_CONTEXT:
    415       return("ALC_INVALID_CONTEXT");
    416     case ALC_INVALID_ENUM:
    417       return("ALC_INVALID_ENUM");
    418     case ALC_INVALID_VALUE:
    419       return ("ALC_INVALID_VALUE");
    420     case ALC_OUT_OF_MEMORY:
    421       return("ALC_OUT_OF_MEMORY");
     414      default:
     415      case ALC_NO_ERROR:
     416        return ("AL_NO_ERROR");
     417      case ALC_INVALID_DEVICE:
     418        return ("ALC_INVALID_DEVICE");
     419      case ALC_INVALID_CONTEXT:
     420        return("ALC_INVALID_CONTEXT");
     421      case ALC_INVALID_ENUM:
     422        return("ALC_INVALID_ENUM");
     423      case ALC_INVALID_VALUE:
     424        return ("ALC_INVALID_VALUE");
     425      case ALC_OUT_OF_MEMORY:
     426        return("ALC_OUT_OF_MEMORY");
    422427    };
    423428  }
  • trunk/src/lib/sound/sound_source.cc

    r8255 r8350  
    2424namespace OrxSound
    2525{
    26         /**
    27         * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
    28         */
    29         SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
    30         {
    31                 this->setClassID(CL_SOUND_SOURCE, "SoundSource");
    32 
    33                 // adding the Source to the SourcesList of the SoundEngine
    34                 this->buffer = buffer;
    35                 this->sourceNode = sourceNode;
    36                 this->resident = false;
    37 
    38                 this->sourceID = 0;
    39                 this->bPlay = false;
    40         }
    41 
    42 
    43         /**
    44         * @brief construct a SoundSource out of the another soundSource
    45         * @param source the Source to create this source from.
    46         *
    47         * Copies the buffer from source to this Source.
    48         * Acquires a new SourceID if source is Playing.
    49         */
    50         SoundSource::SoundSource(const SoundSource& source)
    51         {
    52                 this->setClassID(CL_SOUND_SOURCE, "SoundSource");
    53 
    54                 // adding the Source to the SourcesList of the SoundEngine
    55                 this->buffer = source.buffer;
    56                 this->sourceNode = source.sourceNode;
    57                 this->resident = source.resident;
    58 
    59                 this->sourceID = 0;
    60                 if (source.bPlay == true)
    61                 {
    62                         this->bPlay = true;
    63                         SoundEngine::getInstance()->popALSource(this->sourceID);
    64                 }
    65                 else
    66                         this->bPlay = false;
    67         }
    68 
    69 
    70         /**
    71         * @brief paste a copy of the source into this Source.
    72         * @param source the SoundSource to paste into this one.
    73         * @returns a Reference to this Source.
    74         *
    75         */
    76         SoundSource& SoundSource::operator=(const SoundSource& source)
    77         {
    78                 this->buffer = source.buffer;
    79                 this->sourceNode = sourceNode;
    80                 this->resident = source.resident;
    81 
    82                 if (source.bPlay)
    83                         this->play();
    84                 else
    85                         this->stop();
    86         }
    87 
    88 
    89         /**
    90         * @brief compares two Sources with each other.
    91         * @param source the Source to compare against this One.
    92         * Two Sources are the same, if the PNodes match, and the Sound Played are the same.
    93         * The alSource must not match, because no two Sources can have the same alSource.
    94         */
    95         bool SoundSource::operator==(const SoundSource& source)
    96         {
    97                 return (this->buffer == source.buffer &&
    98                                                 this->bPlay == source.bPlay &&
    99                                                 this->sourceNode == source.sourceNode);
    100         }
    101 
    102 
    103         /**
    104         * @brief deletes a SoundSource
    105         */
    106         SoundSource::~SoundSource()
    107         {
    108                 this->stop();
    109                 if (this->sourceID != 0)
    110                         SoundEngine::getInstance()->pushALSource(this->sourceID);
    111         }
    112 
    113 
    114         /**
    115         * @brief Plays back a SoundSource
    116         */
    117         void SoundSource::play()
    118         {
    119                 if (this->buffer && this->retrieveSource())
    120                 {
    121                         if (this->bPlay)
    122                                 alSourceStop(this->sourceID);
    123                        
    124                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    125                         alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    126                         alSourcef (this->sourceID, AL_GAIN, 1);
    127                         alSourcePlay(this->sourceID);
    128 
    129                         if (DEBUG_LEVEL >= 3)
    130                                 SoundEngine::checkError("Play Source", __LINE__);
    131                         this->bPlay = true;
    132                 }
    133         }
    134 
    135 
    136         /**
    137         * @brief Plays back buffer on this Source
    138         * @param buffer the buffer to play back on this Source
    139         */
    140         void SoundSource::play(const SoundBuffer* buffer)
    141         {
    142                 if (!this->retrieveSource())
    143                 {
    144                         PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
    145                         return;
    146                 }
    147 
    148                 alSourceStop(this->sourceID);
    149                 alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
    150                 alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    151                 alSourcef (this->sourceID, AL_GAIN, 1);
    152 
    153                 alSourcePlay(this->sourceID);
    154 
    155                 if (unlikely(this->buffer != NULL))
    156                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    157                 this->bPlay = true;
    158 
    159                 if (DEBUG_LEVEL >= 3)
    160                         SoundEngine::checkError("Play Source", __LINE__);
    161         }
    162 
    163 
    164         /**
    165         * @brief Plays back buffer on this Source with gain
    166         * @param buffer the buffer to play back on this Source
    167         */
    168         void SoundSource::play(const SoundBuffer* buffer, float gain)
    169         {
    170                 if (!this->retrieveSource())
    171                 {
    172                         PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
    173                         return;
    174                 }
    175 
    176                 alSourceStop(this->sourceID);
    177                 alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
    178                 alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
    179                 alSourcef (this->sourceID, AL_GAIN, gain);
    180 
    181                 alSourcePlay(this->sourceID);
    182 
    183                 if (unlikely(this->buffer != NULL))
    184                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    185                 this->bPlay = true;
    186 
    187                 if (DEBUG_LEVEL >= 3)
    188                         SoundEngine::checkError("Play Source", __LINE__);
    189         }
    190 
    191 
    192         /**
    193         * @brief Plays and loops back a SoundSource
    194         */
    195         void SoundSource::loop()
    196         {
    197                 if (this->buffer && this->retrieveSource())
    198                 {
    199                         if (this->bPlay)
    200                                 alSourceStop(this->sourceID);
    201                        
    202                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    203                         alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    204                         alSourcef (this->sourceID, AL_GAIN, 1);
    205                         alSourcePlay(this->sourceID);
    206 
    207                         if (DEBUG_LEVEL >= 3)
    208                                 SoundEngine::checkError("Play Source", __LINE__);
    209                         this->bPlay = true;
    210                 }
    211         }
    212 
    213         /**
    214         * @brief Plays and loops buffer on this Source
    215         * @param buffer the buffer to play back on this Source
    216         */
    217         void SoundSource::loop(const SoundBuffer* buffer)
    218         {
    219                 if (this->buffer && this->retrieveSource())
    220                 {
    221                         if (this->bPlay)
    222                                 alSourceStop(this->sourceID);
    223        
    224                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    225                         alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    226                         alSourcef (this->sourceID, AL_GAIN, 1);
    227        
    228                         alSourcePlay(this->sourceID);
    229        
    230                         if (DEBUG_LEVEL >= 3)
    231                                 SoundEngine::checkError("Loop Source", __LINE__);
    232                         this->bPlay = true;
    233                 }
    234         }
    235        
    236        
    237         /**
    238         * @brief Plays and loops buffer on this Source with gain control
    239         * @param buffer the buffer to play back on this Source
    240         */
    241         void SoundSource::loop(const SoundBuffer* buffer, float gain)
    242         {
    243                 if (this->buffer && this->retrieveSource())
    244                 {
    245                         if (this->bPlay)
    246                                 alSourceStop(this->sourceID);
    247        
    248                         alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    249                         alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    250                         alSourcef (this->sourceID, AL_GAIN, gain);
    251        
    252                         alSourcePlay(this->sourceID);
    253        
    254                         if (DEBUG_LEVEL >= 3)
    255                                 SoundEngine::checkError("Loop Source", __LINE__);
    256                         this->bPlay = true;
    257                 }
    258         }
    259        
    260        
    261         /**
    262         * @brief Stops playback of a SoundSource
    263         */
    264         void SoundSource::stop()
    265         {
    266                 this->bPlay = false;
    267                 if (this->sourceID != 0)
    268                 {
    269                         this->bPlay = false;
    270                         if (this->sourceID != 0)
    271                         {
    272                                 alSourceStop(this->sourceID);
    273                                 if (DEBUG_LEVEL >= 3)
    274                                         SoundEngine::checkError("StopSource", __LINE__);
    275                                 alSourcei(this->sourceID, AL_BUFFER, 0);
    276                                 if (!this->resident)
    277                                         SoundEngine::getInstance()->pushALSource(this->sourceID);
    278                                 this->sourceID = 0;
    279                         }
    280                 }
    281         }
    282 
    283         /**
    284         * @brief Pauses Playback of a SoundSource
    285         */
    286         void SoundSource::pause()
    287         {
    288                 alSourcePause(this->sourceID);
    289                 if (DEBUG_LEVEL >= 3)
    290                         SoundEngine::checkError("Pause Source", __LINE__);
    291         }
    292 
    293 
    294         /**
    295         * @brief Rewinds Playback of a SoundSource
    296         */
    297         void SoundSource::rewind()
    298         {
    299                 alSourceRewind(this->sourceID);
    300 
    301                 if (DEBUG_LEVEL >= 3)
    302                         SoundEngine::checkError("Rewind Source", __LINE__);
    303         }
    304 
    305 
    306         /**
    307         * @brief sets the RolloffFactor of the Sound emitted from the SoundSource
    308         * @param rolloffFactor The Factor described
    309         *
    310         * this tells openAL how fast the Sounds decay outward from the Source
    311         */
    312         void SoundSource::setRolloffFactor(ALfloat rolloffFactor)
    313         {
    314                 alSourcef(this->sourceID, AL_ROLLOFF_FACTOR, rolloffFactor);
    315 
    316                 if (DEBUG_LEVEL >= 3)
    317                         SoundEngine::checkError("Set Source Rolloff-factor", __LINE__);
    318         }
    319 
    320 
    321         /**
    322         * @brief sets the Positional this Source should be attached to.
    323         * @param sourceNode the Source this is attached to.
    324         * If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels.
    325         */
    326         void SoundSource::setSourceNode(const PNode* sourceNode)
    327         {
    328                 this->sourceNode = sourceNode;
    329         }
    330 
    331         /**
    332         * @brief retrieve a Source.
    333         */
    334         bool SoundSource::retrieveSource()
    335         {
    336                 if (this->sourceID != 0)
    337                         return true;
    338                 else
    339                 {
    340                         SoundEngine::getInstance()->popALSource(this->sourceID);
    341                         if (this->sourceID != 0)
    342                         {
    343                                 if (unlikely(this->sourceNode == NULL))
    344                                         resetSource(this->sourceID);
    345                                 return true;
    346                         }
    347                 }
    348                 return false;
    349         }
    350 
    351 
    352         /**
    353         * @brief reset an alSource to its default Values.
    354         */
    355         void SoundSource::resetSource(ALuint sourceID)
    356         {
    357                 alSource3f(sourceID, AL_POSITION,        0.0, 0.0, 0.0);
    358                 alSource3f(sourceID, AL_VELOCITY,        0.0, 0.0, 0.0);
    359                 alSource3f(sourceID, AL_DIRECTION,       0.0, 0.0, 0.0);
    360                 alSourcef (sourceID, AL_ROLLOFF_FACTOR,  0.0          );
    361                 //alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE      );
    362                 alSourcef (sourceID, AL_GAIN,            SoundEngine::getInstance()->getEffectsVolume());
    363         }
    364 
    365 
    366         /**
    367         * @brief Fades in a Source over a time period
    368         * @param duration time perios to fade in
    369         */
    370         void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
    371         {
    372                 //if (this->buffer && this->retrieveSource())
    373                 //{
    374 
    375                 for (ALfloat n = 0.0; n < 1.0; n+=.01)
    376                 {
    377                         alSourcef(this->sourceID, AL_GAIN, n);
    378                         // sleep(1);
    379                 }
    380 
    381                 //      alSourcePlay(this->sourceID);
    382        
    383                 //      if (DEBUG_LEVEL >= 3)
    384                 //              SoundEngine::checkError("Loop Source", __LINE__);
    385                 //      this->bPlay = true;
    386                 //}
    387 
    388         }
     26  /**
     27  * @brief creates a SoundSource at position sourceNode with the SoundBuffer buffer
     28  */
     29  SoundSource::SoundSource(const PNode* sourceNode, const SoundBuffer* buffer)
     30  {
     31    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     32
     33    // adding the Source to the SourcesList of the SoundEngine
     34    this->buffer = buffer;
     35    this->sourceNode = sourceNode;
     36    this->resident = false;
     37
     38    this->sourceID = 0;
     39    this->bPlay = false;
     40  }
     41
     42
     43  /**
     44  * @brief construct a SoundSource out of the another soundSource
     45  * @param source the Source to create this source from.
     46  *
     47  * Copies the buffer from source to this Source.
     48  * Acquires a new SourceID if source is Playing.
     49  */
     50  SoundSource::SoundSource(const SoundSource& source)
     51  {
     52    this->setClassID(CL_SOUND_SOURCE, "SoundSource");
     53
     54    // adding the Source to the SourcesList of the SoundEngine
     55    this->buffer = source.buffer;
     56    this->sourceNode = source.sourceNode;
     57    this->resident = source.resident;
     58
     59    this->sourceID = 0;
     60    if (source.bPlay == true)
     61    {
     62      this->bPlay = true;
     63      SoundEngine::getInstance()->popALSource(this->sourceID);
     64    }
     65    else
     66      this->bPlay = false;
     67  }
     68
     69
     70  /**
     71  * @brief paste a copy of the source into this Source.
     72  * @param source the SoundSource to paste into this one.
     73  * @returns a Reference to this Source.
     74  *
     75  */
     76  SoundSource& SoundSource::operator=(const SoundSource& source)
     77  {
     78    this->buffer = source.buffer;
     79    this->sourceNode = sourceNode;
     80    this->resident = source.resident;
     81
     82    if (source.bPlay)
     83      this->play();
     84    else
     85      this->stop();
     86    return *this;
     87  }
     88
     89
     90  /**
     91  * @brief compares two Sources with each other.
     92  * @param source the Source to compare against this One.
     93  * Two Sources are the same, if the PNodes match, and the Sound Played are the same.
     94  * The alSource must not match, because no two Sources can have the same alSource.
     95  */
     96  bool SoundSource::operator==(const SoundSource& source)
     97  {
     98    return (this->buffer == source.buffer &&
     99            this->bPlay == source.bPlay &&
     100            this->sourceNode == source.sourceNode);
     101  }
     102
     103
     104  /**
     105  * @brief deletes a SoundSource
     106  */
     107  SoundSource::~SoundSource()
     108  {
     109    this->stop();
     110    if (this->sourceID != 0)
     111      SoundEngine::getInstance()->pushALSource(this->sourceID);
     112  }
     113
     114
     115  /**
     116  * @brief Plays back a SoundSource
     117  */
     118  void SoundSource::play()
     119  {
     120    if (this->buffer && this->retrieveSource())
     121    {
     122      if (this->bPlay)
     123        alSourceStop(this->sourceID);
     124
     125      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     126      alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     127      alSourcef (this->sourceID, AL_GAIN, 1);
     128      alSourcePlay(this->sourceID);
     129
     130      if (DEBUG_LEVEL >= 3)
     131        SoundEngine::checkError("Play Source", __LINE__);
     132      this->bPlay = true;
     133    }
     134  }
     135
     136
     137  /**
     138  * @brief Plays back buffer on this Source
     139  * @param buffer the buffer to play back on this Source
     140  */
     141  void SoundSource::play(const SoundBuffer* buffer)
     142  {
     143    if (!this->retrieveSource())
     144    {
     145      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     146      return;
     147    }
     148
     149    alSourceStop(this->sourceID);
     150    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     151    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     152    alSourcef (this->sourceID, AL_GAIN, 1);
     153
     154    alSourcePlay(this->sourceID);
     155
     156    if (unlikely(this->buffer != NULL))
     157      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     158    this->bPlay = true;
     159
     160    if (DEBUG_LEVEL >= 3)
     161      SoundEngine::checkError("Play Source", __LINE__);
     162  }
     163
     164
     165  /**
     166  * @brief Plays back buffer on this Source with gain
     167  * @param buffer the buffer to play back on this Source
     168  */
     169  void SoundSource::play(const SoundBuffer* buffer, float gain)
     170  {
     171    if (!this->retrieveSource())
     172    {
     173      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     174      return;
     175    }
     176
     177    alSourceStop(this->sourceID);
     178    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     179    alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     180    alSourcef (this->sourceID, AL_GAIN, gain);
     181
     182    alSourcePlay(this->sourceID);
     183
     184    if (unlikely(this->buffer != NULL))
     185      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     186    this->bPlay = true;
     187
     188    if (DEBUG_LEVEL >= 3)
     189      SoundEngine::checkError("Play Source", __LINE__);
     190  }
     191
     192
     193  /**
     194  * @brief Plays and loops back a SoundSource
     195  */
     196  void SoundSource::loop()
     197  {
     198    if (this->buffer && this->retrieveSource())
     199    {
     200      if (this->bPlay)
     201        alSourceStop(this->sourceID);
     202
     203      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     204      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     205      alSourcef (this->sourceID, AL_GAIN, 1);
     206      alSourcePlay(this->sourceID);
     207
     208      if (DEBUG_LEVEL >= 3)
     209        SoundEngine::checkError("Play Source", __LINE__);
     210      this->bPlay = true;
     211    }
     212  }
     213
     214  /**
     215  * @brief Plays and loops buffer on this Source
     216  * @param buffer the buffer to play back on this Source
     217  */
     218  void SoundSource::loop(const SoundBuffer* buffer)
     219  {
     220    if (this->buffer && this->retrieveSource())
     221    {
     222      if (this->bPlay)
     223        alSourceStop(this->sourceID);
     224
     225      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     226      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     227      alSourcef (this->sourceID, AL_GAIN, 1);
     228
     229      alSourcePlay(this->sourceID);
     230
     231      if (DEBUG_LEVEL >= 3)
     232        SoundEngine::checkError("Loop Source", __LINE__);
     233      this->bPlay = true;
     234    }
     235  }
     236
     237
     238  /**
     239  * @brief Plays and loops buffer on this Source with gain control
     240  * @param buffer the buffer to play back on this Source
     241  */
     242  void SoundSource::loop(const SoundBuffer* buffer, float gain)
     243  {
     244    if (this->buffer && this->retrieveSource())
     245    {
     246      if (this->bPlay)
     247        alSourceStop(this->sourceID);
     248
     249      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
     250      alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     251      alSourcef (this->sourceID, AL_GAIN, gain);
     252
     253      alSourcePlay(this->sourceID);
     254
     255      if (DEBUG_LEVEL >= 3)
     256        SoundEngine::checkError("Loop Source", __LINE__);
     257      this->bPlay = true;
     258    }
     259  }
     260
     261
     262  /**
     263  * @brief Stops playback of a SoundSource
     264  */
     265  void SoundSource::stop()
     266  {
     267    this->bPlay = false;
     268    if (this->sourceID != 0)
     269    {
     270      this->bPlay = false;
     271      if (this->sourceID != 0)
     272      {
     273        alSourceStop(this->sourceID);
     274        if (DEBUG_LEVEL >= 3)
     275          SoundEngine::checkError("StopSource", __LINE__);
     276        alSourcei(this->sourceID, AL_BUFFER, 0);
     277        if (!this->resident)
     278          SoundEngine::getInstance()->pushALSource(this->sourceID);
     279        this->sourceID = 0;
     280      }
     281    }
     282  }
     283
     284  /**
     285  * @brief Pauses Playback of a SoundSource
     286  */
     287  void SoundSource::pause()
     288  {
     289    alSourcePause(this->sourceID);
     290    if (DEBUG_LEVEL >= 3)
     291      SoundEngine::checkError("Pause Source", __LINE__);
     292  }
     293
     294
     295  /**
     296  * @brief Rewinds Playback of a SoundSource
     297  */
     298  void SoundSource::rewind()
     299  {
     300    alSourceRewind(this->sourceID);
     301
     302    if (DEBUG_LEVEL >= 3)
     303      SoundEngine::checkError("Rewind Source", __LINE__);
     304  }
     305
     306
     307  /**
     308  * @brief sets the RolloffFactor of the Sound emitted from the SoundSource
     309  * @param rolloffFactor The Factor described
     310  *
     311  * this tells openAL how fast the Sounds decay outward from the Source
     312  */
     313  void SoundSource::setRolloffFactor(ALfloat rolloffFactor)
     314  {
     315    alSourcef(this->sourceID, AL_ROLLOFF_FACTOR, rolloffFactor);
     316
     317    if (DEBUG_LEVEL >= 3)
     318      SoundEngine::checkError("Set Source Rolloff-factor", __LINE__);
     319  }
     320
     321
     322  /**
     323  * @brief sets the Positional this Source should be attached to.
     324  * @param sourceNode the Source this is attached to.
     325  * If sourceNode == NULL then the Source will be centered, and Audio will be played on all channels.
     326  */
     327  void SoundSource::setSourceNode(const PNode* sourceNode)
     328  {
     329    this->sourceNode = sourceNode;
     330  }
     331
     332  /**
     333  * @brief retrieve a Source.
     334  */
     335  bool SoundSource::retrieveSource()
     336  {
     337    if (this->sourceID != 0)
     338      return true;
     339    else
     340    {
     341      SoundEngine::getInstance()->popALSource(this->sourceID);
     342      if (this->sourceID != 0)
     343      {
     344        if (unlikely(this->sourceNode == NULL))
     345          resetSource(this->sourceID);
     346        return true;
     347      }
     348    }
     349    return false;
     350  }
     351
     352
     353  /**
     354  * @brief reset an alSource to its default Values.
     355  */
     356  void SoundSource::resetSource(ALuint sourceID)
     357  {
     358    alSource3f(sourceID, AL_POSITION,        0.0, 0.0, 0.0);
     359    alSource3f(sourceID, AL_VELOCITY,        0.0, 0.0, 0.0);
     360    alSource3f(sourceID, AL_DIRECTION,       0.0, 0.0, 0.0);
     361    alSourcef (sourceID, AL_ROLLOFF_FACTOR,  0.0          );
     362    //alSourcei (sourceID, AL_SOURCE_RELATIVE, AL_TRUE      );
     363    alSourcef (sourceID, AL_GAIN,            SoundEngine::getInstance()->getEffectsVolume());
     364  }
     365
     366
     367  /**
     368  * @brief Fades in a Source over a time period
     369  * @param duration time perios to fade in
     370  */
     371  void SoundSource::fadein(const SoundBuffer* buffer, ALfloat duration)
     372  {
     373    //if (this->buffer && this->retrieveSource())
     374    //{
     375
     376    for (ALfloat n = 0.0; n < 1.0; n+=.01)
     377    {
     378      alSourcef(this->sourceID, AL_GAIN, n);
     379      // sleep(1);
     380    }
     381
     382    //  alSourcePlay(this->sourceID);
     383
     384    //  if (DEBUG_LEVEL >= 3)
     385    //          SoundEngine::checkError("Loop Source", __LINE__);
     386    //  this->bPlay = true;
     387    //}
     388
     389  }
    389390
    390391
  • trunk/src/util/fast_factory.cc

    r7221 r8350  
    190190  PRINTF(3)("not creating new Objects for class %s, because the requested count already exists\n", this->getClassName());
    191191}*/
    192   for (int i = this->storedDeadObjects; i < count; i++)
     192  for (unsigned int i = this->storedDeadObjects; i < count; i++)
    193193  {
    194194    this->fabricate();
  • trunk/src/world_entities/power_ups/power_up.cc

    r7954 r8350  
    137137        this->respawnTime = this->respawnStart;
    138138        break;
     139        default:
     140          /* NOT HANDLED */
     141          break;
    139142      }
    140143    }
Note: See TracChangeset for help on using the changeset viewer.