bool nobBaseWarehouse::OrderJob(const Job job, noRoadNode* const goal, const bool allow_recruiting) { RTTR_Assert(goal); // Maybe we have to recruit one if(!inventory[job]) { if(!allow_recruiting) return false; TryRecruitJob(job); } noFigure* fig = JobFactory::CreateJob(job, pos, player, goal); // Wenn Figur nicht sofort von abgeleiteter Klasse verwenet wird, fügen wir die zur Leave-Liste hinzu if(!UseFigureAtOnce(fig, *goal)) AddLeavingFigure(fig); // Ziel Bescheid sagen, dass dortin ein neuer Arbeiter kommt (bei Flaggen als das anders machen) if(goal->GetType() != NOP_FLAG) { RTTR_Assert(dynamic_cast<noBaseBuilding*>(goal)); static_cast<noBaseBuilding*>(goal)->GotWorker(job, fig); } inventory.real.Remove(job); // Evtl. kein Gehilfe mehr da, sodass das Rekrutieren gestoppt werden muss TryStopRecruiting(); return true; }
/// Startet eine Erkundungs-Expedition oder stoppt sie, wenn bereits eine stattfindet void nobHarborBuilding::StartExplorationExpedition() { // Schon eine Expedition gestartet? if(exploration_expedition.active) { StopExplorationExpedition(); return; } // Initialisierung exploration_expedition.active = true; exploration_expedition.scouts = 0; // Look for missing scouts if(inventory[JOB_SCOUT] < SCOUTS_EXPLORATION_EXPEDITION) { unsigned missing = SCOUTS_EXPLORATION_EXPEDITION - inventory[JOB_SCOUT]; //got scouts in ANY storehouse? GameClientPlayer& owner = gwg->GetPlayer(player); for(std::list<nobBaseWarehouse*>::const_iterator it = owner.GetStorehouses().begin(); it != owner.GetStorehouses().end(); ++it) { const unsigned numScouts = (*it)->GetRealFiguresCount(JOB_SCOUT); if(numScouts >= missing) { missing = 0; break; } else if(numScouts > 0) missing -= numScouts; } // Recruit missing ones if possible while(missing > 0 && TryRecruitJob(JOB_SCOUT)) missing--; // Order scouts, we still requires for(unsigned i = inventory[JOB_SCOUT]; i < SCOUTS_EXPLORATION_EXPEDITION; ++i) owner.AddJobWanted(JOB_SCOUT, this); } if(inventory[JOB_SCOUT]) { exploration_expedition.scouts = std::min(inventory[JOB_SCOUT], SCOUTS_EXPLORATION_EXPEDITION); inventory.real.Remove(JOB_SCOUT, exploration_expedition.scouts); } CheckExplorationExpeditionReady(); }