//removes workers from factories until they are the minimum number to finish the current project //in still the same number of turns (as at the start of the function) int DecrementDueToWastedIndustry(bool max_industry) { m_pSystem->CalculateVariables(); const CAssemblyList& assembly_list = *m_pSystem->GetAssemblyList(); int unset = 0; if(assembly_list.IsEmpty() || assembly_list.GetWasBuildingBought()) return unset; const int min_rounds = m_pSystem->NeededRoundsToBuild(0, true); AssertBotE(min_rounds >= 1); if(max_industry && min_rounds > 1 || m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) == 0) return unset; while(true) { SetWorker(WORKER::INDUSTRY_WORKER, CSystem::SET_WORKER_MODE_DECREMENT); ++unset; m_pSystem->CalculateVariables(); const int current_rounds = m_pSystem->NeededRoundsToBuild(0, true, false); if(m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) == 0) { if(min_rounds < current_rounds) OnBestIndustryWorkerCountFound(unset); return unset; } if(min_rounds < current_rounds) { OnBestIndustryWorkerCountFound(unset); return unset; } } }
//puts an additional worker into industry, to prevent not finishing the project because //industry prod decreased due to loss of moral void SafeMoral() { const CAssemblyList& assembly_list = *m_pSystem->GetAssemblyList(); AssertBotE(m_WorkersLeftToSet >= 0); if(assembly_list.IsEmpty() || m_WorkersLeftToSet == 0) return; const int max_buildings = m_pSystem->GetNumberOfWorkbuildings(WORKER::INDUSTRY_WORKER, 0); if(m_pSystem->GetWorker(WORKER::INDUSTRY_WORKER) < max_buildings) SetWorker(WORKER::INDUSTRY_WORKER, CSystem::SET_WORKER_MODE_INCREMENT); }