/** * @brief Callback for employee_hire command * @note a + as parameter indicates, that more than @c maxEmployeesPerPage are possible * @sa CL_AssignSoldier_f */ static void E_EmployeeHire_f (void) { /* num - menu index (line in text), button - number of button */ int num, button; const char *arg; Employee* employee; base_t *base = B_GetCurrentSelectedBase(); if (!base) return; /* Check syntax. */ if (cgi->Cmd_Argc() < 2) { Com_Printf("Usage: %s <+num>\n", cgi->Cmd_Argv(0)); return; } arg = cgi->Cmd_Argv(1); /* check whether this is called with the text node click function * with values from 0 - #available employees (bigger values than * maxEmployeesPerPage) possible ... */ if (arg[0] == '+') { num = atoi(arg + 1); button = num - employeeScrollPos; /* ... or with the hire pictures that are using only values from * 0 - maxEmployeesPerPage */ } else { button = atoi(cgi->Cmd_Argv(1)); num = button + employeeScrollPos; } employee = E_GetEmployeeByMenuIndex(num); /* empty slot selected */ if (!employee) return; if (employee->isHired()) { if (!employee->unhire()) { Com_DPrintf(DEBUG_CLIENT, "Couldn't fire employee\n"); cgi->UI_DisplayNotice(_("Could not fire employee"), 2000, "employees"); } else { cgi->UI_ExecuteConfunc("employeehire %i", button); } } else { if (!E_HireEmployee(base, employee)) { Com_DPrintf(DEBUG_CLIENT, "Couldn't hire employee\n"); cgi->UI_DisplayNotice(_("Could not hire employee"), 2000, "employees"); cgi->UI_ExecuteConfunc("employeehire %i", button); } else { cgi->UI_ExecuteConfunc("employeefire %i", button); } } E_EmployeeSelect(employee); E_UpdateGUICount_f(); }
TR_ForeachEmployee(employee, transfer, type) { employee->baseHired = transfer->srcBase; /* Restore back the original baseid. */ employee->transfer = false; employee->unhire(); E_HireEmployee(destination, employee); }
/** * @brief Hires the first free employee of that type. * @param[in] base Which base the ugv/robot should be hired in. * @param[in] ugvType What type of ugv/robot should be hired. * @return qtrue if everything went ok (the ugv was added), otherwise qfalse. */ qboolean E_HireRobot (base_t* base, const ugv_t *ugvType) { employee_t* employee = E_GetUnhiredRobot(ugvType); return employee ? E_HireEmployee(base, employee) : qfalse; }
/** * @brief Hires the first free employee of that type. * @param[in] base Which base the employee should be hired in * @param[in] type Which employee type do we search * @sa E_HireEmployee * @sa E_UnhireEmployee */ qboolean E_HireEmployeeByType (base_t* base, employeeType_t type) { employee_t* employee = E_GetUnhired(type); return employee ? E_HireEmployee(base, employee) : qfalse; }