52 if (!employee->isHired())
136 cgi->Com_DPrintf(
DEBUG_CLIENT,
"E_HireForBuilding: Hiring %i employee(s) of type %i failed.\n", num, employeeType);
159 if (oldBase !=
nullptr)
165 if (oldBase !=
nullptr)
170 if (oldBase !=
nullptr)
193 return ngettext(
"Soldier",
"Soldiers", n);
195 return ngettext(
"Scientist",
"Scientists", n);
197 return ngettext(
"Worker",
"Workers", n);
199 return ngettext(
"Pilot",
"Pilots", n);
256 if (!employee->isHired()) {
258 if (!ugvType || employee->getUGV() == ugvType)
276 cgi->Com_Printf(
"E_GetHiredEmployees: Unknown EmployeeType: %i\n",
type);
277 *hiredEmployees =
nullptr;
281 cgi->LIST_Delete(hiredEmployees);
284 if (!employee->isHired())
286 if (!employee->transfer && (!base || employee->isHiredInBase(base))) {
287 cgi->LIST_AddPointer(hiredEmployees, employee);
291 return cgi->LIST_Count(*hiredEmployees);
310 if ((e->getUGV() == ugvType || !ugvType)
311 && e->isHiredInBase(base)) {
312 assert(e->isHired());
318 cgi->LIST_Delete(&hiredEmployees);
337 if (!employee->isHiredInBase(base))
339 if (employee->isAssigned())
356 if (!employee->isHiredInBase(base))
358 if (employee->transfer)
360 if (!employee->isAssigned())
376 CP_Popup(
_(
"Not enough quarters"),
_(
"You don't have enough quarters for your employees.\nBuild more quarters."));
469 cgi->INV_DestroyInventory(&
chr.inv);
526 if (!employee->isHiredInBase(base))
557 Q_strncpyz(teamDefName, teamID,
sizeof(teamDefName));
561 Com_sprintf(teamDefName,
sizeof(teamDefName),
"%s_scientist", teamID);
565 Com_sprintf(teamDefName,
sizeof(teamDefName),
"%s_pilot", teamID);
569 Com_sprintf(teamDefName,
sizeof(teamDefName),
"%s_worker", teamID);
572 if (ugvType ==
nullptr)
573 cgi->Com_Error(
ERR_DROP,
"E_CreateEmployee: no type given for generation of EMPL_ROBOT employee.");
580 cgi->Com_Error(
ERR_DROP,
"E_CreateEmployee: Unknown employee type\n");
583 cgi->CL_GenerateCharacter(&employee.
chr, teamDefName);
622 return cgi->LIST_Remove(&
ccs.employees[
type], (
void*) employee);
637 if (base ==
nullptr || employee->isHiredInBase(base))
654 if (!employee->isHired())
656 if (!base || employee->isHiredInBase(base))
673 if (!employee->isHired())
675 if (employee->getUGV() == ugvType && (!base || employee->isHiredInBase(base)))
714 if (!employee->isHired())
730 if (!employee->isHired() && employee->getUGV() == ugvType)
748 if (!employee->isHiredInBase(base))
750 if (!employee->isAssigned())
772 for (
i = 0;
i < campaign->
ugvs;
i++) {
785static void E_ListHired_f (
void)
792 cgi->Com_Printf(
"Employee: %s (ucn: %i) %s at %s\n",
E_GetEmployeeString(employee->getType(), 1), employee->chr.ucn,
793 employee->chr.name, employee->baseHired->name);
794 if (employee->getType() != emplType)
795 cgi->Com_Printf(
"Warning: EmployeeType mismatch: %i != %i\n", emplType, employee->getType());
804static void CL_DebugNewEmployees_f (
void)
809 for (j = 0; j < 5; j++)
813 for (j = 0; j < 5; j++)
817 for (j = 0; j < 5; j++)
821 for (j = 0; j < 5; j++)
835 if (employee->chr.ucn == uniqueCharacterNumber)
885 if (employee->baseHired)
887 if (employee->isAssigned())
890 assert(employee->getNation());
893 if (employee->getUGV())
897 cgi->GAME_SaveCharacter(chrNode, &employee->chr);
924 cgi->Com_Printf(
"Invalid employee type '%s'\n",
type);
937 cgi->Com_Printf(
"No nation defined for employee\n");
954 cgi->Com_Printf(
"No character definition found for employee\n");
958 if (!
cgi->GAME_LoadCharacter(chrNode, &e.
chr)) {
959 cgi->Com_Printf(
"Error loading character definition for employee\n");
963 if (lastEmployee[emplType] ==
nullptr)
964 lastEmployee[emplType] =
LIST_Add(&
ccs.employees[emplType], (
void*) &e,
sizeof(e));
966 lastEmployee[emplType] =
LIST_Add(&lastEmployee[emplType], (
void*) &e,
sizeof(e));
967 if (lastEmployee[emplType] ==
nullptr) {
968 cgi->Com_Printf(
"Could not add employee to the game\n");
1004 Item* item =
nullptr;
1018 {
"debug_listhired", E_ListHired_f,
"Debug command to list all hired employee"},
1019 {
"debug_addemployees", CL_DebugNewEmployees_f,
"Debug function to add 5 new unhired employees of each type"},
1021 {
nullptr,
nullptr,
nullptr}
1040 cgi->LIST_Delete(&
ccs.employees[emplType]);
Shared game type headers.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
cgame team management headers.
Share stuff between the different cgame implementations.
Item * getNextItem(const Item *prev) const
bool isAwayFromBase() const
Tells you if a employee is away from his home base (gone in mission).
const employeeType_t _type
bool unassign()
Removes the employee from buildings and aircraft.
int salary() const
Calculates the employee's actual salary.
employeeType_t getType() const
void setAssigned(bool assigned)
bool unhire()
Fires an employee.
void unequip()
Removes the equipment from an employee.
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
item instance data, with linked list capability
const objDef_t * ammoDef(void) const
const objDef_t * def(void) const
void AIR_RemovePilotFromAssignedAircraft(const base_t *base, const Employee *pilot)
Checks to see if the pilot is in any aircraft at this base. If he is then he is removed from that air...
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
void AIR_AutoAddPilotToAircraft(const base_t *base, Employee *pilot)
Adds the pilot to the first available aircraft at the specified base.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
const aircraft_t * AIR_IsEmployeeInAircraft(const Employee *employee, const aircraft_t *aircraft)
Tells you if an employee is assigned to an aircraft.
#define AIR_Foreach(var)
iterates trough all aircraft
base_t * B_GetBaseByIDX(int baseIdx)
Array bound check for the base index. Will also return unfounded bases as long as the index is in the...
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
#define B_AtLeastOneExists()
#define B_IsUnderAttack(base)
Header file for single player campaign control.
const cgame_import_t * cgi
void CAP_AddCurrent(base_t *base, baseCapacities_t capacity, int value)
Changes the current (used) capacity on a base.
int CAP_GetFreeCapacity(const base_t *base, baseCapacities_t capacityType)
Returns the free capacity of a type.
const char * GAME_CP_GetTeamDef(void)
bool E_LoadXML(xmlNode_t *p)
Load callback for savegames in XML Format.
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
Employee * E_GetUnassignedEmployee(const base_t *const base, const employeeType_t type)
Gets an assigned employee of a given type from the given base.
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id).
static const cmdList_t debugEmployeeCmds[]
void E_InitialEmployees(const campaign_t *campaign)
Create initial hireable employees.
bool E_SaveXML(xmlNode_t *p)
Save callback for savegames in XML Format.
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
int E_CountByType(employeeType_t type)
Returns number of employees of a type.
void E_UnhireAllEmployees(base_t *base, employeeType_t type)
Reset the hired flag for all employees of a given type in a given base.
bool E_HireAllowed(const base_t *base)
Returns true if the current base is able to handle employees.
Employee * E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber)
Searches employee from a type for the ucn (character id).
int E_GetHiredEmployees(const base_t *const base, employeeType_t type, linkedList_t **hiredEmployees)
Return a list of hired employees in the given base of a given type.
void E_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
Employee * E_GetHiredRobot(const base_t *const base, const ugv_t *ugvType)
Return a "hired" ugv-employee pointer of a given ugv-type in a given base.
int E_CountUnhiredRobotsByType(const ugv_t *ugvType)
Counts all available Robots/UGVs that are for sale.
int E_CountAllHired(const base_t *const base, const bool peopleOnly)
Counts all hired employees of a given base.
Employee * E_CreateEmployee(employeeType_t type, const nation_t *nation, const ugv_t *ugvType)
Creates an entry of a new employee in the global list and assignes it to no building/base.
void E_Shutdown(void)
Closing actions for employee-subsystem.
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base.
void E_RemoveInventoryFromStorage(Employee *employee)
Removes the items of an employee (soldier) from the base storage (s)he is hired at.
Employee * E_GetUnhiredRobot(const ugv_t *ugvType)
Return a "not hired" ugv-employee pointer of a given ugv-type.
bool E_HireRobot(base_t *base, const ugv_t *ugvType)
Hires the first free employee of that type.
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
employeeType_t E_GetEmployeeType(const char *type)
Convert string to employeeType_t.
bool E_HireEmployee(base_t *base, Employee *employee)
Hires the employee in a base.
Employee * E_GetAssignedEmployee(const base_t *const base, const employeeType_t type)
Gets an unassigned employee of a given type from the given base.
int E_CountHiredRobotByType(const base_t *const base, const ugv_t *ugvType)
Counts 'hired' (i.e. bought or produced UGVs and other robots of a given ugv-type in a given base.
int E_CountUnhired(employeeType_t type)
Counts unhired employees of a given type in a given base.
void E_HireForBuilding(base_t *base, building_t *building, int num)
Hires some employees of appropriate type for a building.
Employee * E_GetUnhired(employeeType_t type)
Iterates through unhired employees.
int E_CountUnassigned(const base_t *const base, employeeType_t type)
Counts unassigned employees of a given type in a given base.
employeeType_t
The types of employees.
#define E_Foreach(employeeType, var)
void E_InitCallbacks(void)
Register UI callbacks.
void E_ShutdownCallbacks(void)
Unregister UI callbacks.
Header file for menu callback functions used for hire/fire employee menu.
nation_t * NAT_GetNationByID(const char *nationID)
Return a nation-pointer by the nations id.
nation_t * NAT_GetRandom(void)
Return a pointer to a random nation.
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
rank_t * CL_GetRankByIdx(const int index)
Returns a rank at an index.
int CL_GetRankIdx(const char *rankID)
Get the index of the given rankID in ccs.ranks array.
void RS_RemoveFiredScientist(base_t *base, Employee *employee)
Remove one scientist from research project if needed.
#define ngettext(x, y, cnt)
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
float frand(void)
Return random values between 0 and 1.
QGL_EXTERN GLint GLenum type
XML tag constants for savegame.
#define SAVE_EMPLOYEE_EMPLOYEES
static const constListEntry_t saveEmployeeConstants[]
#define SAVE_EMPLOYEE_NATION
#define SAVE_EMPLOYEE_CHR
#define SAVE_EMPLOYEE_BASEHIRED
#define SAVE_EMPLOYEE_TYPE
#define SAVE_EMPLOYEE_ASSIGNED
#define SAVE_EMPLOYEE_UGV
#define SAVE_EMPLOYEETYPE_NAMESPACE
#define SAVE_EMPLOYEE_EMPLOYEE
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
A base with all it's data.
A building with all it's data.
buildingType_t buildingType
Describes a character with all its attributes.
Describes a rank that a recruit can gain.
Defines a type of UGV/Robot.