void AUDRefreshSounds () {
#ifdef HAVE_AL
  static int i=0;
  if (i>=hashsize) {
    i=0;
  }else {
    for (unsigned int j=0;j<playingbuffers[i].size();j++) {
      if (!AUDIsPlaying (playingbuffers[i][j].soundname)) {
	totalplaying--;
	if (sounds[playingbuffers[i][j].soundname].source!=(ALuint)0) {
	  unusedsrcs.push_back (sounds[playingbuffers[i][j].soundname].source);
          alSourcei(sounds[playingbuffers[i][j].soundname].source,AL_BUFFER,0);
	  sounds[playingbuffers[i][j].soundname].source=(ALuint)0;
	}
	ApproxSoundVec::iterator k = playingbuffers[i].begin();
	k+=j;
	playingbuffers[i].erase (k);
	j--;
      }
    }
    ++i;
  }
  static unsigned int j=0;
  if (j>=soundstodelete.size()) {
    j=0;
  }else {
    int tmp = soundstodelete[j];
    if (!AUDIsPlaying(tmp)) {
      soundstodelete.erase (soundstodelete.begin()+j);
      AUDDeleteSound (tmp,false);
    }
    ++j;
  }
#endif
}
void symbol_to_eplison::operator()(const tinygrammar& tig, vecint& istoe, int32& eid)
{
	const symholder_proxy& sholder = tig.symbols();
	const prodholder_proxy& prods = tig.productions();
	
	kog::smart_vector<int32> IsProdUsed(prods.size());
	memset(IsProdUsed.get(), 0, IsProdUsed.size_in_bytes());

	kog::smart_vector<int32> toe(sholder.size());
	memset(toe.get(), 0, toe.size_in_bytes());
	
	eid = -2;
	try{
		const tchar* eplison = ""; // eplison is empty string
		eid = tig.index(eplison);
		if(eid >= 0 && eid < (int32)sholder.size())toe[eid] = 1;
	}catch(...){
	}

	size_t nLastCount = 1;
	size_t nNewCount = 1;

	do{
		nLastCount = nNewCount;
		for(size_t i = 0; i < prods.size(); ++ i)
		{
			const production& p = prods[i];
			if(toe[p.left()] || IsProdUsed[i]) continue;
			production::right_array::const_iterator iter = p.right().begin();
			production::right_array::const_iterator iter_end = p.right().end();
			for(; iter != iter_end; ++ iter)
			{
				if(!toe[*iter]) break;
			}
			if(iter_end == iter)
			{
				toe[p.left()] = 1;
				IsProdUsed[i] = 1;
			}
		}
		
		nNewCount = std::count(toe.begin(), toe.end(), 1);
	}while(nNewCount != nLastCount);

	istoe.swap(toe);

#ifdef DEBUG_OUTPUT
	logstring("symbol_to_eplison, Wset = { ");
	const char* sep = "";
	for(size_t i = 0; i < istoe.size(); ++ i, sep = ", ")
	{
		if(istoe[i] && i != eid) 
		{
			logstring("%s%s", sep, tig.symbols()[i].name);
		}
	}
	logstring(" }\n");
#endif
}
Example #3
0
int Dialog2::find(vecint &lst,int value)
{
   for(int i=0;i<lst.size();i++){
     if(lst[i]==value){
       return i;
     }
   }
}