cp_employee.c File Reference

Single player employee stuff. More...

#include "../client.h"
#include "../cl_game.h"
#include "../cl_team.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "cp_campaign.h"
#include "cp_employee_callbacks.h"
#include "cp_rank.h"
#include "save/save_employee.h"
Include dependency graph for cp_employee.c:

Go to the source code of this file.

Functions

employee_tE_GetNext (employeeType_t type, employee_t *lastEmployee)
 Iterates through employees.
employee_tE_GetNextFromBase (employeeType_t type, employee_t *lastEmployee, const base_t *base)
 Iterates through employees on a base.
employee_tE_GetNextHired (employeeType_t type, employee_t *lastEmployee)
 Iterates through hired employees.
qboolean E_IsAwayFromBase (const employee_t *employee)
 Tells you if a employee is away from his home base (gone in mission).
void E_HireForBuilding (base_t *base, building_t *building, int num)
 Hires some employees of appropriate type for a building.
qboolean E_IsInBase (const employee_t *empl, const base_t *const base)
 Checks whether the given employee is in the given base.
qboolean E_MoveIntoNewBase (employee_t *employee, base_t *newBase)
const char * E_GetEmployeeString (employeeType_t type)
 Convert employeeType_t to translated string.
employeeType_t E_GetEmployeeType (const char *type)
 Convert string to employeeType_t.
void E_ResetEmployees (void)
 Clears the employees list for loaded and new games.
employee_tE_GetEmployee (const base_t *const base, employeeType_t type, int idx)
 Return a given employee pointer in the given base of a given type. Also returns those employees, that are not yet hired.
static employee_tE_GetUnhiredEmployee (employeeType_t type, int idx)
 Return a given "not hired" employee pointer in the given base of a given type.
employee_tE_GetUnhiredRobot (const ugv_t *ugvType)
 Return a "not hired" ugv-employee pointer of a given ugv-type.
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.
employee_tE_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.
static qboolean E_EmployeeIsUnassigned (const employee_t *employee)
 Returns true if the employee is _only_ listed in the global list.
employee_tE_GetAssignedEmployee (const base_t *const base, const employeeType_t type)
 Gets an unassigned employee of a given type from the given base.
employee_tE_GetUnassignedEmployee (const base_t *const base, const employeeType_t type)
 Gets an assigned employee of a given type from the given base.
qboolean E_HireEmployee (base_t *base, employee_t *employee)
 Hires the employee in a base.
qboolean E_HireEmployeeByType (base_t *base, employeeType_t type)
 Hires the first free employee of that type.
qboolean E_HireRobot (base_t *base, const ugv_t *ugvType)
 Hires the first free employee of that type.
void E_ResetEmployee (employee_t *employee)
 Removes the inventory of the employee and also removes him from buildings.
qboolean E_UnhireEmployee (employee_t *employee)
 Fires an employee.
void E_UnhireAllEmployees (base_t *base, employeeType_t type)
 Reset the hired flag for all employees of a given type in a given base.
static employee_tE_CreateEmployeeAtIndex (employeeType_t type, nation_t *nation, const ugv_t *ugvType, const int emplIdx)
 Creates an entry of a new employee at the passed index location in the global list and assignes it to no building/base.
employee_tE_CreateEmployee (employeeType_t type, 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.
qboolean E_DeleteEmployee (employee_t *employee, employeeType_t type)
 Removes the employee completely from the game (buildings + global list).
void E_DeleteAllEmployees (base_t *base)
 Removes all employees completely from the game (buildings + global list) from a given base.
void E_DeleteEmployeesExceedingCapacity (base_t *base)
 Removes employee until all employees fit in quarters capacity.
void E_RefreshUnhiredEmployeeGlobalList (const employeeType_t type, const qboolean excludeUnhappyNations)
 Recreates all the employees for a particular employee type in the global list. But it does not overwrite any employees already hired.
qboolean E_RemoveEmployeeFromBuildingOrAircraft (employee_t *employee)
 Remove one employee from building.
int E_CountHired (const base_t *const base, employeeType_t type)
 Counts hired employees of a given type in a 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_CountAllHired (const base_t *const base)
 Counts all hired employees of a given base.
int E_CountUnhired (employeeType_t type)
 Counts unhired employees of a given type in a given base.
int E_CountUnhiredRobotsByType (const ugv_t *ugvType)
 Counts all available Robots/UGVs that are for sale.
int E_CountUnassigned (const base_t *const base, employeeType_t type)
 Counts unassigned employees of a given type in a given base.
static nation_tE_RandomNation (void)
 Hack to get a random nation for the initial.
void E_InitialEmployees (void)
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. Called from UI_InitStartup resp. CL_InitLocal.
employee_tE_GetEmployeeFromChrUCN (int uniqueCharacterNumber)
 Searches all employee for the ucn (character id).
qboolean E_SaveXML (mxml_node_t *p)
 Save callback for savegames in XML Format.
qboolean E_LoadXML (mxml_node_t *p)
 Load callback for savegames in XML Format.
qboolean E_HireAllowed (const base_t *base)
 Returns true if the current base is able to handle employees.
void E_RemoveInventoryFromStorage (employee_t *employee)
 Removes the items of an employee (soldier) from the base storage (s)he is hired at.

Detailed Description

Single player employee stuff.

Note:
Employee related functions prefix: E_

Definition in file cp_employee.c.


Function Documentation

int E_CountAllHired ( const base_t *const   base  ) 

Counts all hired employees of a given base.

Parameters:
[in] base The base where we count
Returns:
count of hired employees of a given type in a given base
Note:
must not return 0 if hasBuilding[B_QUARTER] is qfalse: used to update capacity
Todo:
What about EMPL_ROBOT?

Definition at line 1064 of file cp_employee.c.

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

Referenced by B_ResetAllStatusAndCapacities(), and E_UpdateGUICount_f().

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

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

Parameters:
[in] base The base where we count (NULL to count all).
[in] type The type of employee to search.
Returns:
count of hired employees of a given type in a given base

Definition at line 1026 of file cp_employee.c.

References count, E_GetNextHired(), and E_IsInBase().

Referenced by B_CheckBuildingStatusForMenu_f(), B_RemoveItemsExceedingCapacity(), B_UpdateStorageCap(), BaseSummary_Init(), CL_ActorPilotSelect_f(), CL_ActorTeamSelect_f(), CL_AssignPilot_f(), CL_AssignSoldier_f(), CL_EquipSoldierState(), E_CountAllHired(), E_UpdateGUICount_f(), PR_CalculateProductionPercentDone(), PR_ProductionAllowed(), PR_ProductionList_f(), PR_QueueNew(), PR_UpdateProductionCap(), RS_ResearchAllowed(), RS_UpdateInfo(), TR_CargoListSelect_f(), and TR_TransferListSelect_f().

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.

Parameters:
[in] base The base where we count (NULL to count all).
[in] ugvType What type of robot/ugv we are looking for.
Returns:
Count of Robots/UGVs.

Definition at line 1044 of file cp_employee.c.

References count, E_GetNextHired(), E_IsInBase(), EMPL_ROBOT, and employee_s::ugv.

Referenced by BS_BuyType().

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

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

Parameters:
[in] type The type of employee to search.
[in] base The base where we count

Definition at line 1117 of file cp_employee.c.

References employee_s::building, count, and E_GetNextFromBase().

Referenced by RS_InitGUI(), and RS_UpdateInfo().

int E_CountUnhired ( employeeType_t  type  ) 

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

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

Definition at line 1084 of file cp_employee.c.

References count, E_GetNext(), and E_IsHired.

int E_CountUnhiredRobotsByType ( const ugv_t ugvType  ) 

Counts all available Robots/UGVs that are for sale.

Parameters:
[in] ugvType What type of robot/ugv we are looking for.
Returns:
count of available robots/ugvs.

Definition at line 1100 of file cp_employee.c.

References count, E_GetNext(), E_IsHired, EMPL_ROBOT, and employee_s::ugv.

Referenced by BS_BuyItem_f(), and BS_BuyType().

employee_t* E_CreateEmployee ( employeeType_t  type,
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.

Parameters:
[in] type What type of employee to create.
[in] nation What nation the employee (mainly used for soldiers in singleplayer) comes from.
[in] ugvType What type of ugv this employee is.
Returns:
Pointer to the newly created employee in the global list. NULL if something goes wrong.
See also:
E_DeleteEmployee

Definition at line 742 of file cp_employee.c.

References E_CreateEmployeeAtIndex().

Referenced by CP_NationHandleBudget(), and E_InitialEmployees().

static employee_t* E_CreateEmployeeAtIndex ( employeeType_t  type,
nation_t nation,
const ugv_t ugvType,
const int  emplIdx 
) [static]

Creates an entry of a new employee at the passed index location in the global list and assignes it to no building/base.

Parameters:
[in] type Tell the function what type of employee to create.
[in] nation Tell the function what nation the employee (mainly used for soldiers in singleplayer) comes from.
[in] ugvType Tell the function what type of ugv this employee is.
[in] emplIdx the index of the employee to create. -1 will use the next available index, >=0 will be used as the index of the employee.
Returns:
Pointer to the newly created employee in the global list. NULL if something goes wrong.
See also:
E_DeleteEmployee

Todo:
use Cvar_GetString("cl_teamdef"); for campaign games

Definition at line 638 of file cp_employee.c.

References ugv_s::actors, employee_s::baseHired, employee_s::building, ccs, employee_s::chr, CL_GenerateCharacter(), CL_GetRankIdx(), Com_DPrintf(), Com_Error(), Com_sprintf(), Com_ValueToStr(), ccs_s::curCampaign, DEBUG_CLIENT, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ccs_s::employees, ERR_DROP, GAME_GetTeamDef(), employee_s::idx, MAX_EMPL, MAX_EMPLOYEES, MAX_VAR, employee_s::nation, ccs_s::numEmployees, Q_strncpyz(), chrScoreGlobal_s::rank, character_s::score, employee_s::speed, campaign_s::team, TEAM_ALIEN, employee_s::type, employee_s::ugv, and V_TEAM.

Referenced by E_CreateEmployee(), and E_RefreshUnhiredEmployeeGlobalList().

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] base Which base the employee should be fired from.

Definition at line 851 of file cp_employee.c.

References employee_s::baseHired, ccs, Com_DPrintf(), DEBUG_CLIENT, E_DeleteEmployee(), E_IsInBase(), EMPL_SOLDIER, ccs_s::employees, i, MAX_EMPL, ccs_s::numEmployees, and type.

qboolean E_DeleteEmployee ( employee_t employee,
employeeType_t  type 
)

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

Parameters:
[in] employee The pointer to the employee you want to remove.
[in] type What type of employee to delete.
Returns:
True if the employee was removed successfully, otherwise false.
See also:
E_CreateEmployee
E_ResetEmployees
E_UnhireEmployee
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

Todo:
remove this once the employees are a linked list, too
Todo:
This might not work as expected - maybe we have to memmove the array

Definition at line 762 of file cp_employee.c.

References aircraft_s::acTeam, transfer_s::active, AIR_GetNextFromBase(), B_GetFoundedBaseByIDX(), employee_s::baseHired, ccs, Com_DPrintf(), linkedList_s::data, DEBUG_CLIENT, E_UnhireEmployee(), EMPL_PILOT, transfer_s::employeeArray, ccs_s::employees, i, employee_s::idx, MAX_BASES, MAX_EMPL, MAX_EMPLOYEES, linkedList_s::next, ccs_s::numEmployees, ccs_s::numTransfers, aircraft_s::pilot, qfalse, qtrue, employee_s::transfer, ccs_s::transfers, and employee_s::type.

Referenced by AIR_DestroyAircraft(), B_RemoveItemsExceedingCapacity(), CP_MissionEnd(), CP_SpawnRescueMission(), E_DeleteAllEmployees(), E_DeleteEmployeesExceedingCapacity(), and E_EmployeeDelete_f().

void E_DeleteEmployeesExceedingCapacity ( base_t base  ) 

Removes employee until all employees fit in quarters capacity.

Parameters:
[in] base Pointer to the base where the number of employees should be updated.
Note:
employees are killed, and not just unhired (if base is destroyed, you can't recruit the same employees elsewhere) if you want to unhire employees, you should do it before calling this function.
employees are not randomly chosen. Reason is that all Quarter will be destroyed at the same time, so all employees are going to be killed anyway.

Definition at line 889 of file cp_employee.c.

References CAP_EMPLOYEES, base_s::capacities, ccs, Com_Printf(), cap_maxcur_s::cur, E_DeleteEmployee(), E_IsInBase(), EMPL_ROBOT, ccs_s::employees, i, cap_maxcur_s::max, MAX_EMPL, base_s::name, ccs_s::numEmployees, and type.

Referenced by B_BuildingOnDestroy_f().

static qboolean E_EmployeeIsUnassigned ( const employee_t employee  )  [inline, static]

Returns true if the employee is _only_ listed in the global list.

Parameters:
[in] employee The employee_t pointer to check
Returns:
qboolean
See also:
E_EmployeeIsFree

Definition at line 438 of file cp_employee.c.

References employee_s::building, Com_Error(), and ERR_DROP.

Referenced by E_GetAssignedEmployee(), and E_GetUnassignedEmployee().

employee_t* 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] base Which base the employee should be hired in.
[in] type The type of employee to search.
Returns:
employee_t
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 454 of file cp_employee.c.

References E_EmployeeIsUnassigned(), and E_GetNextFromBase().

Referenced by RS_RemoveScientist().

employee_t* E_GetEmployee ( const base_t *const   base,
employeeType_t  type,
int  idx 
)

Return a given employee pointer in the given base of a given type. Also returns those employees, that are not yet hired.

Parameters:
[in] base Which base the employee should be hired in.
[in] type Which employee type do we search.
[in] idx Which employee id (in global employee array)
Returns:
employee_t pointer or NULL

Definition at line 292 of file cp_employee.c.

References E_GetNext(), E_IsHired, E_IsInBase(), employee_s::idx, and MAX_EMPL.

employee_t* E_GetEmployeeFromChrUCN ( int  uniqueCharacterNumber  ) 

Searches all employee for the ucn (character id).

Parameters:
[in] uniqueCharacterNumber unique character number (UCN)

Definition at line 1207 of file cp_employee.c.

References employee_s::chr, E_GetNext(), and character_s::ucn.

Referenced by AIR_LoadAircraftXML(), CP_ParseCharacterData(), E_ChangeName_f(), and TR_LoadXML().

const char* E_GetEmployeeString ( employeeType_t  type  ) 

Convert employeeType_t to translated string.

Parameters:
type employeeType_t value
Returns:
translated employee string

Definition at line 224 of file cp_employee.c.

References _, Com_Error(), EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, and ERR_DROP.

Referenced by B_CheckBuildingStatusForMenu_f(), BaseSummary_Init(), CL_StatsUpdate_f(), CP_NationHandleBudget(), HOS_UpdateMenu(), TR_CargoList(), and TR_TransferSelect().

employeeType_t E_GetEmployeeType ( const char *  type  ) 

Convert string to employeeType_t.

Parameters:
type Pointer to employee type string
Returns:
employeeType_t
Todo:
use Com_ConstInt*

Definition at line 248 of file cp_employee.c.

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

Referenced by CL_ParseRanks().

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] base Which base the employee should be searched in. If NULL is given employees in all bases will be listed.
[in] type Which employee type to search for.
[out] hiredEmployees Linked list of hired employees in the base.
Returns:
Number of hired employees in the base that are currently not on a transfer.

Definition at line 371 of file cp_employee.c.

References Com_Printf(), E_GetNextHired(), E_IsInBase(), LIST_AddPointer(), LIST_Count(), LIST_Delete(), MAX_EMPL, and employee_s::transfer.

Referenced by CL_UpdateEmployeeList(), CP_BaseAttackStartMission(), CP_GetWinProbabilty(), E_GenerateHiredEmployeesList(), and E_GetHiredRobot().

employee_t* 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.

Parameters:
[in] base Which base the ugv should be searched in.c
[in] ugvType What type of robot we want.
Returns:
employee_t pointer on success or NULL on error.
See also:
E_GetUnhiredRobot

Definition at line 402 of file cp_employee.c.

References Com_DPrintf(), linkedList_s::data, DEBUG_CLIENT, E_GetHiredEmployees(), E_IsHired, E_IsInBase(), EMPL_ROBOT, LIST_Delete(), linkedList_s::next, and employee_s::ugv.

Referenced by B_RemoveItemsExceedingCapacity(), and BS_SellItem_f().

employee_t* E_GetNext ( employeeType_t  type,
employee_t lastEmployee 
)

Iterates through employees.

Parameters:
[in] type Employee type to look for
[in] lastEmployee Pointer of the employee to iterate from. call with NULL to get the first one.
See also:
employeeType_t

Definition at line 43 of file cp_employee.c.

References ccs, ccs_s::employees, and ccs_s::numEmployees.

Referenced by E_CountUnhired(), E_CountUnhiredRobotsByType(), E_EmployeeList_f(), E_EmployeeListScroll_f(), E_GetEmployee(), E_GetEmployeeFromChrUCN(), E_GetNextFromBase(), E_GetNextHired(), E_GetUnhiredEmployee(), E_GetUnhiredRobot(), and E_SaveXML().

employee_t* E_GetNextFromBase ( employeeType_t  type,
employee_t lastEmployee,
const base_t base 
)

Iterates through employees on a base.

Parameters:
[in] type Employee type to look for
[in] lastEmployee Pointer of the employee to iterate from. call with NULL to get the first one.
[in] base Pointer to the base where employee hired at
See also:
employeeType_t

Definition at line 73 of file cp_employee.c.

References E_GetNext(), and E_IsInBase().

Referenced by CL_UpdateCharacterStats(), E_CountUnassigned(), E_GetAssignedEmployee(), E_GetUnassignedEmployee(), E_UnhireAllEmployees(), HOS_HealAll(), HOS_ListClick_f(), HOS_UpdateMenu(), TR_GetTransferEmployee(), TR_TransferListSelect_f(), and TR_TransferSelect().

employee_t* E_GetNextHired ( employeeType_t  type,
employee_t lastEmployee 
)

Iterates through hired employees.

Parameters:
[in] type Employee type to look for
[in] lastEmployee Pointer of the employee to iterate from. call with NULL to get the first one.
See also:
employeeType_t

Definition at line 91 of file cp_employee.c.

References E_GetNext(), and E_IsHired.

Referenced by CL_StatsUpdate_f(), CP_NationHandleBudget(), E_CountHired(), E_CountHiredRobotByType(), E_GetHiredEmployees(), and HOS_HospitalRun().

employee_t* 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] base Which base the employee should be hired in.
[in] type The type of employee to search.
Returns:
employee_t
See also:
E_EmployeeIsUnassigned
Note:
unassigned is not unhired - they are already hired in a base but are at quarters

Definition at line 472 of file cp_employee.c.

References E_EmployeeIsUnassigned(), and E_GetNextFromBase().

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

static employee_t* E_GetUnhiredEmployee ( employeeType_t  type,
int  idx 
) [static]

Return a given "not hired" employee pointer in the given base of a given type.

Parameters:
[in] type Which employee type to search for.
[in] idx Which employee id (in global employee array). Use -1, -2, etc.. to return the first/ second, etc... "unhired" employee.
Returns:
employee_t pointer or NULL
See also:
E_GetHiredEmployee
E_UnhireEmployee
E_HireEmployee

Definition at line 316 of file cp_employee.c.

References ccs, Com_Printf(), E_GetNext(), E_IsHired, employee_s::idx, MAX_EMPL, and ccs_s::numEmployees.

Referenced by E_HireEmployeeByType().

employee_t* E_GetUnhiredRobot ( const ugv_t ugvType  ) 

Return a "not hired" ugv-employee pointer of a given ugv-type.

Parameters:
[in] ugvType What type of robot we want.
Returns:
employee_t pointer on success or NULL on error.
See also:
E_GetHiredRobot

Definition at line 349 of file cp_employee.c.

References Com_Printf(), E_GetNext(), E_IsHired, EMPL_ROBOT, and employee_s::ugv.

Referenced by E_HireRobot().

qboolean E_HireAllowed ( const base_t base  ) 

Returns true if the current base is able to handle employees.

See also:
B_BaseInit_f

Definition at line 1350 of file cp_employee.c.

References B_GetBuildingStatus(), B_QUARTERS, BASE_UNDER_ATTACK, base_s::baseStatus, qfalse, and qtrue.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().

qboolean E_HireEmployee ( base_t base,
employee_t employee 
)

Hires the employee in a base.

Parameters:
[in] base Which base the employee should be hired in
[in] employee Which employee to hire
See also:
E_HireEmployeeByType
E_UnhireEmployee
Todo:
handle EMPL_ROBOT capacities here?

Definition at line 490 of file cp_employee.c.

References _, AIR_AutoAddPilotToAircraft(), employee_s::baseHired, CAP_EMPLOYEES, CAP_ITEMS, base_s::capacities, cap_maxcur_s::cur, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, cap_maxcur_s::max, MAX_EMPL, PR_UpdateProductionCap(), qfalse, qtrue, employee_s::type, UGV_SIZE, and UI_Popup().

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

qboolean E_HireEmployeeByType ( base_t base,
employeeType_t  type 
)

Hires the first free employee of that type.

Parameters:
[in] base Which base the employee should be hired in
[in] type Which employee type do we search
See also:
E_HireEmployee
E_UnhireEmployee

Definition at line 530 of file cp_employee.c.

References E_GetUnhiredEmployee(), E_HireEmployee(), and qfalse.

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] base Which base the employee should be hired in.
[in] building in which building
[in] num how many employees, if -1, hire building->maxEmployees
See also:
B_SetUpBase

Definition at line 144 of file cp_employee.c.

References B_HANGAR, B_LAB, B_MISC, B_WORKSHOP, building_s::buildingType, ccs, Com_DPrintf(), DEBUG_CLIENT, E_HireEmployeeByType(), EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, building_s::maxEmployees, and ccs_s::numEmployees.

Referenced by B_AddBuildingToBasePos().

qboolean E_HireRobot ( base_t base,
const ugv_t ugvType 
)

Hires the first free employee of that type.

Parameters:
[in] base Which base the ugv/robot should be hired in.
[in] ugvType What type of ugv/robot should be hired.
Returns:
qtrue if everything went ok (the ugv was added), otherwise qfalse.

Definition at line 542 of file cp_employee.c.

References E_GetUnhiredRobot(), E_HireEmployee(), and qfalse.

Referenced by BS_BuyItem_f().

void E_InitialEmployees ( void   ) 
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. Called from UI_InitStartup resp. CL_InitLocal.

Definition at line 1196 of file cp_employee.c.

References Cmd_AddCommand().

Referenced by CP_InitStartup().

qboolean E_IsAwayFromBase ( const employee_t employee  ) 

Tells you if a employee is away from his home base (gone in mission).

Parameters:
[in] employee Pointer to the employee.
Returns:
qboolean qtrue if the employee is away in mission, qfalse if he is not or he is unhired.

Definition at line 107 of file cp_employee.c.

References AIR_GetNextFromBase(), AIR_IsAircraftInBase(), AIR_IsInAircraftTeam(), employee_s::baseHired, E_IsHired, EMPL_PILOT, EMPL_ROBOT, EMPL_SOLDIER, qfalse, qtrue, employee_s::transfer, and employee_s::type.

Referenced by CP_BaseAttackStartMission(), CP_GetWinProbabilty(), HOS_ListClick_f(), and HOS_UpdateMenu().

qboolean E_IsInBase ( const employee_t empl,
const base_t *const   base 
)
qboolean E_LoadXML ( mxml_node_t p  ) 
qboolean E_MoveIntoNewBase ( employee_t 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:
employee The employee to change the base for
newBase The base where the employee should be located at
Returns:
false if employee was a NULL pointer

Definition at line 205 of file cp_employee.c.

References employee_s::baseHired, CAP_EMPLOYEES, base_s::capacities, cap_maxcur_s::cur, qfalse, and qtrue.

Referenced by AIR_MoveAircraftIntoNewHomebase().

static nation_t* E_RandomNation ( void   )  [inline, static]

Hack to get a random nation for the initial.

Definition at line 1137 of file cp_employee.c.

References ccs, ccs_s::nations, and ccs_s::numNations.

Referenced by E_InitialEmployees().

void E_RefreshUnhiredEmployeeGlobalList ( const employeeType_t  type,
const qboolean  excludeUnhappyNations 
)

Recreates all the employees for a particular employee type in the global list. But it does not overwrite any employees already hired.

Parameters:
[in] type The type of the employee list to process.
[in] excludeUnhappyNations True if a nation is unhappy then they wont send any pilots, false if happiness of nations in not considered.
See also:
CP_NationHandleBudget

Definition at line 930 of file cp_employee.c.

References ccs, E_CreateEmployeeAtIndex(), E_IsHired, ccs_s::employees, nationInfo_s::happiness, MAX_EMPLOYEES, MAX_NATIONS, ccs_s::nations, ccs_s::numNations, and nation_s::stats.

Referenced by CP_NationHandleBudget().

qboolean E_RemoveEmployeeFromBuildingOrAircraft ( employee_t employee  ) 

Remove one employee from building.

Todo:
Add check for base vs. employee_type and abort if they do not match.
Parameters:
[in] employee What employee to remove from its building.
Returns:
Returns true if removing was possible/sane otherwise false.
See also:
E_AssignEmployeeToBuilding
Todo:
are soldiers and pilots assigned to a building, too? quarters?

Definition at line 972 of file cp_employee.c.

References AIR_IsEmployeeInAircraft(), AIR_RemoveEmployee(), AIR_RemovePilotFromAssignedAircraft(), employee_s::baseHired, employee_s::building, Com_Error(), EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ERR_DROP, MAX_EMPL, PR_UpdateProductionCap(), qfalse, qtrue, RS_RemoveFiredScientist(), and employee_s::type.

Referenced by E_ResetEmployee().

void E_RemoveInventoryFromStorage ( employee_t employee  ) 

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

Parameters:
[in] employee Pointer to the soldier whose items should be removed

Definition at line 1362 of file cp_employee.c.

References B_UpdateStorageAndCapacity(), employee_s::baseHired, employee_s::chr, CONTAINER, csi, INVDEF, invList_s::item, item_s::m, invList_s::next, csi_s::numIDs, qfalse, and item_s::t.

Referenced by AIR_DestroyAircraft().

void E_ResetEmployee ( employee_t employee  ) 

Removes the inventory of the employee and also removes him from buildings.

Note:
This is used in the transfer start function (when you transfer an employee this must be called for him to make him no longer useable in the current base) and is also used when you completely unhire an employee.
See also:
E_UnhireEmployee

Definition at line 555 of file cp_employee.c.

References employee_s::chr, cls, inventoryInterface_s::DestroyInventory, E_IsHired, E_RemoveEmployeeFromBuildingOrAircraft(), character_s::i, and client_static_s::i.

Referenced by E_UnhireEmployee(), and TR_TransferStart().

void E_ResetEmployees ( void   ) 

Clears the employees list for loaded and new games.

See also:
CL_ResetSinglePlayerData
E_DeleteEmployee

Definition at line 272 of file cp_employee.c.

References ccs, Com_DPrintf(), DEBUG_CLIENT, EMPL_SOLDIER, ccs_s::employees, i, MAX_EMPL, and ccs_s::numEmployees.

Referenced by CL_ResetSinglePlayerData().

qboolean E_SaveXML ( mxml_node_t p  ) 
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] base Which base the employee should be fired from.
[in] type Which employee type do we search.

Definition at line 614 of file cp_employee.c.

References E_GetNextFromBase(), E_UnhireEmployee(), and MAX_EMPL.

qboolean E_UnhireEmployee ( employee_t employee  ) 

Generated by  doxygen 1.6.2