Slick Forums
http://slick.ninjacave.com/forum/

BUG: Last source never played
http://slick.ninjacave.com/forum/viewtopic.php?f=4&t=3659
Page 1 of 1

Author:  davedes [ Mon Aug 15, 2011 5:46 pm ]
Post subject:  BUG: Last source never played

Right now the SoundStore findFreeSource() method skips the first source (because it's music), but also skips the last source:

Code:
private int findFreeSource() {
      for (int i=1;i<sourceCount-1;i++) {
         int state = AL10.alGetSourcei(sources.get(i), AL10.AL_SOURCE_STATE);
         
         if ((state != AL10.AL_PLAYING) && (state != AL10.AL_PAUSED)) {
            return i;
         }
      }
      
      return -1;
   }


(notice sourceCount-1)

So no matter how many sounds are playing, the last source is never used.

Author:  ArtificialZero [ Fri Sep 02, 2011 5:00 pm ]
Post subject: 

eeh, no ?

sourceCount is, how many element there are
0 is skipped, there for it starts at 1

[COUNT-1] is the last element (of ANY array), because computers begin counting at 0 not 1

I surely don't tell you anything new ? =P

Author:  ArtificialZero [ Fri Sep 02, 2011 5:16 pm ]
Post subject: 

I stand corrected. Here it's LESS THEN < COUNT-1, you're actually right.
I think.

Author:  davedes [ Sun Mar 04, 2012 10:22 pm ]
Post subject:  Re: BUG: Last source never played

Fixed in dev branch.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/