DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ResolveIngredients()

bool PluginRecipesManagerBase::ResolveIngredients ( int num_of_ingredients,
int passes = 0 )
inlineprotected

См. определение в файле PluginRecipesManager.c строка 530

531 {
532 int rightmost_bit;
533 int smallest = 99999;
534 int smallest_index = 0;
535
536 for (int i = 0; i < num_of_ingredients; i++)
537 {
538 int count = m_IngredientBitMaskSize[i];
539 if ( count != 0 && count < smallest)
540 {
541 smallest = m_IngredientBitMaskSize[i];
542 smallest_index = i;
543 }
544 }
545
546 rightmost_bit = m_IngredientBitMask[smallest_index] & (-m_IngredientBitMask[smallest_index]);
547 m_BitsResults[smallest_index] = m_BitsResults[smallest_index] | rightmost_bit;
548
549 for (int x = 0; x < num_of_ingredients; x++)
550 {
551 m_IngredientBitMask[x] = ~rightmost_bit & m_IngredientBitMask[x];
552 m_IngredientBitMask[smallest_index] = 0;
553 m_IngredientBitMaskSize[smallest_index] = 0;
554 }
555
556 // check validity
557 int check_sum_vertical = 0;
558
559 for (int z = 0; z < num_of_ingredients; z++)
560 {
561 check_sum_vertical = check_sum_vertical | m_IngredientBitMask[z];//vertical sum
562 check_sum_vertical = check_sum_vertical | m_BitsResults[z];//vertical sum
563 if ((m_IngredientBitMask[z] | m_BitsResults[z]) == 0)
564 {
565 return false;//horizontal check
566 }
567 }
568
569 if ( check_sum_vertical != (Math.Pow(2, num_of_ingredients) - 1)) return false;//vertical check
570
571 passes++;
572
573 if (passes < num_of_ingredients)
574 {
575 if ( !ResolveIngredients(num_of_ingredients, passes) ) return false;
576 }
577 return true;
578 }
Icon x
int m_IngredientBitMaskSize[MAX_INGREDIENTS]
Определения PluginRecipesManager.c:29
bool ResolveIngredients(int num_of_ingredients, int passes=0)
Определения PluginRecipesManager.c:530
int m_BitsResults[MAX_INGREDIENTS]
Определения PluginRecipesManager.c:31
int m_IngredientBitMask[MAX_INGREDIENTS]
Определения PluginRecipesManager.c:28

Перекрестные ссылки m_BitsResults, m_IngredientBitMask, m_IngredientBitMaskSize, Math::Pow(), ResolveIngredients() и x.

Используется в ResolveIngredients() и SortIngredientsInRecipe().