// called at map load
// see also BuildingClass::GetSecretProduction
void ScenarioClass::GenerateSecretLabBonuses() {

  // vec_SecretLabs is a vector containing all buildings currently on the map with SecretLab=yes
  // DynamicVectorClass<BuildingClass *> vec_SecretLabs;
  if( vec_SecretLabs.Length <= 0 ) { // no secret labs on map
    return;
  }
  
  int sum = Rules->SecretSum; // SecretSum == SecretInfantry.Length + SecretUnits.Length + SecretBuildings.Length 
  if( sum <= 0 || sum < vec_SecretLabs.Length ) { // more labs than possible bonuses (!)
    return;
  }

  DynamicVectorClass<int> numbers;
  for( int i = 0; i < Rules->SecretSum; ++i ) {
    numbers.Append(i);
  }
  // now numbers is {0, 1, 2... Rules->SecretSum - 1}

  if( vec_SecretLabs.Length <= 0 ) { // whoa, deja vu
    return;
  }

  for( int idxLab = 0; idxLab < vec_SecretLabs.Length; ++idxLab ) {
    int idxBonus = Random_Ranged(0, numbers.Length - 1);
    numbers.RemoveByIndex(idxBonus);
    int lenList = Rules->SecretInfantry.Length;
    TechnoTypeClass *bonus;
    if( idxBonus <= lenList - 1 ) {
      bonus = Rules->SecretInfantry[idxBonus];
    } else {
      idxBonus -= lenList;
      lenList = Rules->SecretUnits.Length;
      if( idxBonus <= lenList - 1 ) {
        bonus = Rules->SecretUnits[idxBonus];
      } else {
        idxBonus -= lenList;
        lenList = Rules->SecretBuildings.Length;      
        if( idxBonus <= lenList - 1 ) {
          bonus = Rules->SecretBuildings[idxBonus];
        }
      }
    }

    if( bonus ) {
      vec_SecretLabs[idxLab]->SecretProduction = bonus;
    }
  }
}