/** * @brief Prepare things for baseattack battle * @param[in] mission Mission to prepare battle for */ static void CP_BaseAttackPrepareBattle (mission_t* mission) { if (!mission) return; base_t* base = mission->data.base; GEO_SelectMission(mission); mission->active = true; cgi->Com_DPrintf(DEBUG_CLIENT, "Base attack: %s at %.0f:%.0f\n", mission->id, mission->pos[0], mission->pos[1]); /* Fill the fake aircraft */ OBJZERO(baseAttackFakeAircraft); baseAttackFakeAircraft.homebase = base; /* needed for transfer of alien corpses */ VectorCopy(base->pos, baseAttackFakeAircraft.pos); /* needed to spawn soldiers on map */ baseAttackFakeAircraft.maxTeamSize = std::min(MAX_ACTIVETEAM, E_CountByType(EMPL_SOLDIER) + E_CountByType(EMPL_ROBOT)); baseAttackFakeAircraft.mission = mission; base->aircraftCurrent = &baseAttackFakeAircraft; GEO_SetMissionAircraft(&baseAttackFakeAircraft); /** @todo remove me - this is not needed because we are using the base->aircraftCurrent * pointer for resolving the aircraft - only Autocombat needs this */ GEO_SetInterceptorAircraft(&baseAttackFakeAircraft); /* needed for updating soldier stats sa CHAR_UpdateStats */ B_SetCurrentSelectedBase(base); /* needed for equipment menu */ static char popupText[1024]; Com_sprintf(popupText, sizeof(popupText), _("Base '%s' is under attack! What to do?"), base->name); cgi->UI_RegisterText(TEXT_POPUP, popupText); CP_GameTimeStop(); cgi->UI_PushWindow("popup_baseattack"); }
/** * @brief Hires some employees of appropriate type for a building * @param[in] base Which base the employee should be hired in. * @param[in] building in which building * @param[in] num how many employees, if -1, hire building->maxEmployees * @sa B_SetUpBase */ void E_HireForBuilding (base_t* base, building_t * building, int num) { if (num < 0) num = building->maxEmployees; if (num) { employeeType_t employeeType; switch (building->buildingType) { case B_WORKSHOP: employeeType = EMPL_WORKER; break; case B_LAB: employeeType = EMPL_SCIENTIST; break; case B_HANGAR: /* the Dropship Hangar */ employeeType = EMPL_SOLDIER; break; case B_MISC: Com_DPrintf(DEBUG_CLIENT, "E_HireForBuilding: Misc building type: %i with employees: %i.\n", building->buildingType, num); return; default: Com_DPrintf(DEBUG_CLIENT, "E_HireForBuilding: Unknown building type: %i.\n", building->buildingType); return; } /* don't try to hire more that available - see E_CreateEmployee */ num = min(num, E_CountByType(employeeType)); for (;num--;) { assert(base); if (!E_HireEmployeeByType(base, employeeType)) { Com_DPrintf(DEBUG_CLIENT, "E_HireForBuilding: Hiring %i employee(s) of type %i failed.\n", num, employeeType); return; } } } }