UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_employee.h File Reference

Header for employee related stuff. More...

Go to the source code of this file.

Data Structures

class  Employee
 

Macros

#define E_Foreach(employeeType, var)   LIST_Foreach(ccs.employees[employeeType], Employee, var)
 

Enumerations

enum  employeeType_t {
  EMPL_SOLDIER, EMPL_SCIENTIST, EMPL_WORKER, EMPL_PILOT,
  EMPL_ROBOT, MAX_EMPL
}
 The types of employees. More...
 

Functions

EmployeeE_CreateEmployee (employeeType_t type, const struct nation_s *nation, const struct ugv_s *ugvType=nullptr)
 
bool E_DeleteEmployee (Employee *employee)
 Removes the employee completely from the game (buildings + global list). More...
 
int E_CountByType (employeeType_t type)
 Returns number of employees of a type. More...
 
int E_CountHired (const base_t *const base, employeeType_t type)
 Counts hired employees of a given type in a given base. More...
 
int E_CountHiredRobotByType (const base_t *const base, const struct ugv_s *ugvType)
 
int E_CountAllHired (const base_t *const base, const bool peopleOnly=false)
 Counts all hired employees of a given base. More...
 
int E_CountUnhired (employeeType_t type)
 Counts unhired employees of a given type in a given base. More...
 
int E_CountUnhiredRobotsByType (const struct ugv_s *ugvType)
 
int E_CountUnassigned (const base_t *const base, employeeType_t type)
 Counts unassigned employees of a given type in a given base. More...
 
bool E_HireEmployee (base_t *base, Employee *employee)
 Hires the employee in a base. More...
 
bool E_HireEmployeeByType (base_t *base, employeeType_t type)
 Hires the first free employee of that type. More...
 
bool E_HireRobot (base_t *base, const struct ugv_s *ugvType)
 
bool E_UnhireEmployee (Employee *employee)
 
employeeType_t E_GetEmployeeType (const char *type)
 Convert string to employeeType_t. More...
 
const char * E_GetEmployeeString (employeeType_t type, int n)
 Convert employeeType_t to translated string. More...
 
EmployeeE_GetUnhired (employeeType_t type)
 Iterates through unhired employees. More...
 
EmployeeE_GetUnhiredRobot (const struct ugv_s *ugvType)
 
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. More...
 
EmployeeE_GetHiredRobot (const base_t *const base, const struct ugv_s *ugvType)
 
EmployeeE_GetUnassignedEmployee (const base_t *const base, employeeType_t type)
 Gets an assigned employee of a given type from the given base. More...
 
EmployeeE_GetAssignedEmployee (const base_t *const base, employeeType_t type)
 Gets an unassigned employee of a given type from the given base. More...
 
EmployeeE_GetEmployeeFromChrUCN (int uniqueCharacterNumber)
 Searches all employee for the ucn (character id) More...
 
EmployeeE_GetEmployeeByTypeFromChrUCN (employeeType_t type, int uniqueCharacterNumber)
 Searches employee from a type for the ucn (character id) More...
 
void E_UnhireAllEmployees (base_t *base, employeeType_t type)
 Reset the hired flag for all employees of a given type in a given base. More...
 
void E_DeleteAllEmployees (base_t *base)
 Removes all employees completely from the game (buildings + global list) from a given base. More...
 
void E_HireForBuilding (base_t *base, building_t *building, int num)
 Hires some employees of appropriate type for a building. More...
 
void E_InitialEmployees (const struct campaign_s *campaign)
 
bool E_MoveIntoNewBase (Employee *employee, base_t *newBase)
 
void E_RemoveInventoryFromStorage (Employee *employee)
 Removes the items of an employee (soldier) from the base storage (s)he is hired at. More...
 
void E_InitStartup (void)
 This is more or less the initial Bind some of the functions in this file to console-commands that you can call ingame. More...
 
void E_Shutdown (void)
 Closing actions for employee-subsystem. More...
 

Detailed Description

Header for employee related stuff.

Definition in file cp_employee.h.

Macro Definition Documentation

Enumeration Type Documentation

The types of employees.

Enumerator
EMPL_SOLDIER 
EMPL_SCIENTIST 
EMPL_WORKER 
EMPL_PILOT 
EMPL_ROBOT 
MAX_EMPL 

For counting over all available enums.

Definition at line 30 of file cp_employee.h.

Function Documentation

int E_CountAllHired ( const base_t *const  base,
const bool  peopleOnly 
)

Counts all hired employees of a given base.

Parameters
[in]baseThe base where we count
[in]peopleOnlyCount people only (skip robots)
Returns
count of hired employees of a given type in a given base

Definition at line 688 of file cp_employee.cpp.

References count, E_CountHired(), EMPL_ROBOT, i, MAX_EMPL, and type.

Referenced by B_ResetAllStatusAndCapacities(), and E_UpdateGUICount_f().

int E_CountByType ( employeeType_t  type)

Returns number of employees of a type.

Parameters
[in]typeEmployeetype to check

Definition at line 39 of file cp_employee.cpp.

References ccs, cgi, and ccs_s::employees.

Referenced by CP_BaseAttackPrepareBattle(), and E_HireForBuilding().

int E_CountHired ( const base_t *const  base,
employeeType_t  type 
)

Counts hired employees of a given type in a given base.

Parameters
[in]baseThe base where we count (nullptr to count all).
[in]typeThe type of employee to search.
Returns
count of hired employees of a given type in a given base

Definition at line 649 of file cp_employee.cpp.

References count, and E_Foreach.

Referenced by CAP_UpdateStorageCap(), E_CountAllHired(), E_GetCounts_f(), E_UpdateGUICount_f(), PR_ProductionAllowed(), PR_ProductionInfo(), PR_ProductionList_f(), PR_UpdateProductionCap(), PR_WorkersAvailable(), RS_Change_f(), RS_FillTechnologyList_f(), RS_Max_f(), RS_ResearchAllowed(), RS_Stop_f(), TEST_F(), and TR_FillEmployees().

int E_CountHiredRobotByType ( const base_t *const  base,
const struct ugv_s ugvType 
)
int E_CountUnassigned ( const base_t *const  base,
employeeType_t  type 
)

Counts unassigned employees of a given type in a given base.

Parameters
[in]typeThe type of employee to search.
[in]baseThe base where we count

Definition at line 741 of file cp_employee.cpp.

References count, and E_Foreach.

Referenced by RS_Change_f(), RS_FillTechnologyList_f(), RS_Max_f(), and RS_Stop_f().

int E_CountUnhired ( employeeType_t  type)

Counts unhired employees of a given type in a given base.

Parameters
[in]typeThe type of employee to search.
Returns
count of hired employees of a given type in a given base

Definition at line 709 of file cp_employee.cpp.

References count, and E_Foreach.

Referenced by TEST_F().

int E_CountUnhiredRobotsByType ( const struct ugv_s ugvType)
Employee* E_CreateEmployee ( employeeType_t  type,
const struct nation_s nation,
const struct ugv_s ugvType = nullptr 
)
void E_DeleteAllEmployees ( base_t base)

Removes all employees completely from the game (buildings + global list) from a given base.

Note
Used if the base e.g is destroyed by the aliens.
Parameters
[in]baseWhich base the employee should be fired from.

Definition at line 630 of file cp_employee.cpp.

References E_DeleteEmployee(), E_Foreach, EMPL_SOLDIER, i, MAX_EMPL, and type.

Referenced by B_Destroy(), and TEST_F().

bool E_DeleteEmployee ( Employee employee)

Removes the employee completely from the game (buildings + global list).

Parameters
[in]employeeThe pointer to the employee you want to remove.
Returns
True if the employee was removed successfully, otherwise false.
See also
E_CreateEmployee
Note
This function has the side effect, that the global employee number for the given employee type is reduced by one, also the ccs.employees pointers are moved to fill the gap of the removed employee. Thus pointers like acTeam in the aircraft can point to wrong employees now. This has to be taken into account

Definition at line 602 of file cp_employee.cpp.

References Employee::baseHired, ccs, cgi, ccs_s::employees, Employee::getType(), Employee::transfer, type, and Employee::unhire().

Referenced by AIR_DestroyAircraft(), CP_MissionEnd(), CP_SpawnRescueMission(), E_DeleteAllEmployees(), E_EmployeeDelete_f(), TEST_F(), and TR_EmptyTransferCargo().

Employee* E_GetAssignedEmployee ( const base_t *const  base,
const employeeType_t  type 
)

Gets an unassigned employee of a given type from the given base.

Parameters
[in]baseWhich base the employee should be hired in.
[in]typeThe type of employee to search.
Returns
Employee
See also
E_EmployeeIsUnassigned
Note
assigned is not hired - they are already hired in a base, in a quarter and working in another building.

Definition at line 334 of file cp_employee.cpp.

References E_Foreach.

Referenced by RS_RemoveScientist().

Employee* E_GetEmployeeByTypeFromChrUCN ( employeeType_t  type,
int  uniqueCharacterNumber 
)

Searches employee from a type for the ucn (character id)

Parameters
[in]typeemployee type
[in]uniqueCharacterNumberunique character number (UCN)

Definition at line 832 of file cp_employee.cpp.

References E_Foreach.

Referenced by AIR_GetPilot(), BS_Buy_f(), BS_ShowInfo_f(), and E_GetEmployeeFromChrUCN().

Employee* E_GetEmployeeFromChrUCN ( int  uniqueCharacterNumber)

Searches all employee for the ucn (character id)

Parameters
[in]uniqueCharacterNumberunique character number (UCN)

Definition at line 846 of file cp_employee.cpp.

References E_GetEmployeeByTypeFromChrUCN(), EMPL_SOLDIER, i, and MAX_EMPL.

Referenced by AIR_LoadAircraftXML(), CHAR_UpdateData(), CP_TEAM_AssignSoldierByUCN_f(), CP_TEAM_ChangeSkin_f(), CP_TEAM_DeEquipActor_f(), CP_TEAM_SelectActorByUCN_f(), E_ChangeName_f(), GAME_CP_GetSelectedChr(), TR_Add_f(), and TR_LoadXML().

const char* E_GetEmployeeString ( employeeType_t  type,
int  n 
)

Convert employeeType_t to translated string.

Parameters
typeemployeeType_t value
nnumber of persons of that kind (for plural detection)
Returns
translated employee string

Definition at line 189 of file cp_employee.cpp.

References cgi, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ERR_DROP, and ngettext.

Referenced by E_GetCounts_f(), HOS_GetRank(), NAT_HandleBudget(), TR_CargoList(), TR_FillEmployees(), and TR_List_f().

employeeType_t E_GetEmployeeType ( const char *  type)

Convert string to employeeType_t.

Parameters
typePointer to employee type string
Returns
employeeType_t
Todo:
use cgi->Com_ConstInt*

Definition at line 213 of file cp_employee.cpp.

References EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, MAX_EMPL, and Q_streq.

Referenced by CL_ParseRanks(), and CP_TEAM_FillEmployeeList_f().

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.

Parameters
[in]baseWhich base the employee should be searched in. If nullptr is given employees in all bases will be listed.
[in]typeWhich employee type to search for.
[out]hiredEmployeesLinked list of hired employees in the base.
Returns
Number of hired employees in the base that are currently not on a transfer. Or -1 in case of an error.

Definition at line 273 of file cp_employee.cpp.

References cgi, E_Foreach, and MAX_EMPL.

Referenced by E_GetHiredRobot().

Employee* E_GetHiredRobot ( const base_t *const  base,
const struct ugv_s ugvType 
)
Employee* E_GetUnassignedEmployee ( const base_t *const  base,
const employeeType_t  type 
)

Gets an assigned employee of a given type from the given base.

Parameters
[in]baseWhich base the employee should be hired in.
[in]typeThe type of employee to search.
Returns
Employee
See also
E_EmployeeIsUnassigned
Note
unassigned is not unhired - they are already hired in a base but are at quarters

Definition at line 353 of file cp_employee.cpp.

References E_Foreach.

Referenced by RS_AssignScientist(), RS_Max_f(), and RS_RemoveFiredScientist().

Employee* E_GetUnhired ( employeeType_t  type)

Iterates through unhired employees.

Parameters
[in]typeEmployee type to look for
See also
employeeType_t

Definition at line 49 of file cp_employee.cpp.

References E_Foreach.

Referenced by E_HireEmployeeByType().

Employee* E_GetUnhiredRobot ( const struct ugv_s ugvType)
bool E_HireEmployee ( base_t base,
Employee employee 
)

Hires the employee in a base.

Parameters
[in]baseWhich base the employee should be hired in
[in]employeeWhich employee to hire
See also
E_HireEmployeeByType
Todo:
handle EMPL_ROBOT capacities here?
Todo:
shouldn't we link CID_EQUIP here already to the base inventory equip container?

Definition at line 373 of file cp_employee.cpp.

References _, AIR_AutoAddPilotToAircraft(), Employee::baseHired, CAP_AddCurrent(), CAP_EMPLOYEES, CAP_GetFreeCapacity(), CAP_ITEMS, CP_Popup(), EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, Employee::getType(), MAX_EMPL, PR_UpdateProductionCap(), and UGV_SIZE.

Referenced by E_EmployeeHire_f(), E_HireEmployeeByType(), E_HireRobot(), and TEST_F().

bool E_HireEmployeeByType ( base_t base,
employeeType_t  type 
)

Hires the first free employee of that type.

Parameters
[in]baseWhich base the employee should be hired in
[in]typeWhich employee type do we search
See also
E_HireEmployee

Definition at line 414 of file cp_employee.cpp.

References E_GetUnhired(), and E_HireEmployee().

Referenced by B_SetUpFirstBase(), and E_HireForBuilding().

void E_HireForBuilding ( base_t base,
building_t building,
int  num 
)

Hires some employees of appropriate type for a building.

Parameters
[in]baseWhich base the employee should be hired in.
[in]buildingin which building
[in]numhow many employees, if -1, hire building->maxEmployees
See also
B_SetUpBase

Definition at line 107 of file cp_employee.cpp.

References B_HANGAR, B_LAB, B_MISC, B_WORKSHOP, building_s::buildingType, cgi, DEBUG_CLIENT, E_CountByType(), E_HireEmployeeByType(), EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, and building_s::maxEmployees.

Referenced by B_AddBuildingToBasePos().

bool E_HireRobot ( base_t base,
const struct ugv_s ugvType 
)
void E_InitialEmployees ( const struct campaign_s campaign)
void E_InitStartup ( void  )

This is more or less the initial Bind some of the functions in this file to console-commands that you can call ingame.

Definition at line 1027 of file cp_employee.cpp.

References cgi, and E_InitCallbacks().

Referenced by CP_InitStartup().

bool E_MoveIntoNewBase ( Employee employee,
base_t newBase 
)

Will change the base where the employee is located in and will also update the capacity in the affected bases.

Note
Doesn't make any capacity checks and the employee must be hired already.
Parameters
employeeThe employee to change the base for
newBaseThe base where the employee should be located at
Returns
false if employee was a nullptr pointer

Definition at line 151 of file cp_employee.cpp.

References Employee::baseHired, CAP_AddCurrent(), CAP_EMPLOYEES, CAP_ITEMS, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, Employee::getType(), MAX_EMPL, PR_UpdateProductionCap(), and UGV_SIZE.

Referenced by AIR_MoveAircraftIntoNewHomebase(), and TR_TransferStart().

void E_RemoveInventoryFromStorage ( Employee employee)

Removes the items of an employee (soldier) from the base storage (s)he is hired at.

Parameters
[in]employeePointer to the soldier whose items should be removed

Definition at line 996 of file cp_employee.cpp.

References Item::ammoDef(), B_AddToStorage(), Employee::baseHired, Employee::chr, Item::def(), Inventory::getNextCont(), Container::getNextItem(), and character_s::inv.

Referenced by AIR_DestroyAircraft(), and AM_UpdateSurivorsAfterBattle().

void E_Shutdown ( void  )

Closing actions for employee-subsystem.

Definition at line 1036 of file cp_employee.cpp.

References ccs, cgi, E_ShutdownCallbacks(), EMPL_SOLDIER, ccs_s::employees, and MAX_EMPL.

Referenced by CP_Shutdown().

void E_UnhireAllEmployees ( base_t base,
employeeType_t  type 
)

Reset the hired flag for all employees of a given type in a given base.

Parameters
[in]baseWhich base the employee should be fired from.
[in]typeWhich employee type do we search.

Definition at line 518 of file cp_employee.cpp.

References E_Foreach, and MAX_EMPL.

bool E_UnhireEmployee ( Employee employee)