|
UFO: Alien Invasion
|
Single player employee stuff. More...
#include "../../cl_shared.h"#include "../cl_game.h"#include "../cl_game_team.h"#include "cp_campaign.h"#include "cp_employee_callbacks.h"#include "cp_rank.h"#include "cp_popup.h"#include "save/save_employee.h"
Go to the source code of this file.
Functions | |
| int | E_CountByType (employeeType_t type) |
| Returns number of employees of a type. | |
| Employee * | E_GetUnhired (employeeType_t type) |
| Iterates through unhired employees. | |
| void | E_HireForBuilding (base_t *base, building_t *building, int num) |
| Hires some employees of appropriate type for a building. | |
| bool | E_MoveIntoNewBase (Employee *employee, base_t *newBase) |
| const char * | E_GetEmployeeString (employeeType_t type, int n) |
| Convert employeeType_t to translated string. | |
| employeeType_t | E_GetEmployeeType (const char *type) |
| Convert string to employeeType_t. | |
| Employee * | E_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 * | 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. | |
| Employee * | E_GetAssignedEmployee (const base_t *const base, const employeeType_t type) |
| Gets an unassigned employee of a given type from the given base. | |
| Employee * | E_GetUnassignedEmployee (const base_t *const base, const employeeType_t type) |
| Gets an assigned employee of a given type from the given base. | |
| bool | E_HireEmployee (base_t *base, Employee *employee) |
| Hires the employee in a base. | |
| bool | E_HireEmployeeByType (base_t *base, employeeType_t type) |
| Hires the first free employee of that type. | |
| bool | E_HireRobot (base_t *base, const ugv_t *ugvType) |
| Hires the first free employee of that 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. | |
| 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. | |
| bool | E_DeleteEmployee (Employee *employee) |
| 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. | |
| 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, const bool peopleOnly) |
| 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. | |
| void | E_InitialEmployees (const campaign_t *campaign) |
| Create initial hireable employees. | |
| Employee * | E_GetEmployeeByTypeFromChrUCN (employeeType_t type, int uniqueCharacterNumber) |
| Searches employee from a type for the ucn (character id). | |
| Employee * | E_GetEmployeeFromChrUCN (int uniqueCharacterNumber) |
| Searches all employee for the ucn (character id). | |
| bool | E_SaveXML (xmlNode_t *p) |
| Save callback for savegames in XML Format. | |
| bool | E_LoadXML (xmlNode_t *p) |
| Load callback for savegames in XML Format. | |
| bool | E_HireAllowed (const base_t *base) |
| Returns true if the current base is able to handle employees. | |
| void | E_RemoveInventoryFromStorage (Employee *employee) |
| Removes the items of an employee (soldier) from the base storage (s)he is hired at. | |
| 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. | |
| void | E_Shutdown (void) |
| Closing actions for employee-subsystem. | |
Variables | |
| static const cmdList_t | debugEmployeeCmds [] |
Single player employee stuff.
Definition in file cp_employee.cpp.
Counts all hired employees of a given base.
| [in] | base | The base where we count |
| [in] | peopleOnly | Count people only (skip robots) |
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.
| [in] | type | Employeetype to check |
Definition at line 39 of file cp_employee.cpp.
References ccs, cgi, and type.
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.
| [in] | base | The base where we count (nullptr to count all). |
| [in] | type | The type of employee to search. |
Definition at line 649 of file cp_employee.cpp.
References count, E_Foreach, and type.
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(), TEST_F(), TEST_F(), TEST_F(), and TR_FillEmployees().
Counts 'hired' (i.e. bought or produced UGVs and other robots of a given ugv-type in a given base.
| [in] | base | The base where we count (nullptr to count all). |
| [in] | ugvType | What type of robot/ugv we are looking for. |
Definition at line 668 of file cp_employee.cpp.
References count, E_Foreach, and EMPL_ROBOT.
| int E_CountUnassigned | ( | const base_t *const | base, |
| employeeType_t | type ) |
Counts unassigned employees of a given type in a given base.
| [in] | type | The type of employee to search. |
| [in] | base | The base where we count |
Definition at line 741 of file cp_employee.cpp.
References count, E_Foreach, and type.
Referenced by RS_Change_f(), RS_FillTechnologyList_f(), RS_Max_f(), and RS_Stop_f().
| int E_CountUnhired | ( | employeeType_t | type | ) |
Counts all available Robots/UGVs that are for sale.
| [in] | ugvType | What type of robot/ugv we are looking for. |
Definition at line 725 of file cp_employee.cpp.
References count, E_Foreach, and EMPL_ROBOT.
Referenced by BS_Buy_f(), BS_BuyUGV(), and BS_FillMarket_f().
| 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.
| [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. |
Definition at line 540 of file cp_employee.cpp.
References ugv_t::actors, ccs, cgi, Employee::chr, CL_GetRankIdx(), Com_sprintf(), DEBUG_CLIENT, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ERR_DROP, GAME_CP_GetTeamDef(), LIST_Add(), MAX_EMPL, MAX_VAR, Q_strncpyz(), chrScoreGlobal_t::rank, character_t::score, and type.
Referenced by E_InitialEmployees(), NAT_HandleBudget(), TEST_F(), and TEST_F().
Removes all employees completely from the game (buildings + global list) from a given base.
| [in] | base | Which 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(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
| bool E_DeleteEmployee | ( | Employee * | employee | ) |
Removes the employee completely from the game (buildings + global list).
| [in] | employee | The pointer to the employee you want to remove. |
Definition at line 602 of file cp_employee.cpp.
References Employee::baseHired, ccs, cgi, 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.
| [in] | base | Which base the employee should be hired in. |
| [in] | type | The type of employee to search. |
Definition at line 334 of file cp_employee.cpp.
References E_Foreach, and type.
Referenced by RS_RemoveScientist().
| Employee * E_GetEmployeeByTypeFromChrUCN | ( | employeeType_t | type, |
| int | uniqueCharacterNumber ) |
Searches employee from a type for the ucn (character id).
| [in] | type | employee type |
| [in] | uniqueCharacterNumber | unique character number (UCN) |
Definition at line 832 of file cp_employee.cpp.
References E_Foreach, and type.
Referenced by AIR_GetPilot(), BS_Buy_f(), BS_ShowInfo_f(), and E_GetEmployeeFromChrUCN().
Searches all employee for the ucn (character id).
| [in] | uniqueCharacterNumber | unique 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.
| type | employeeType_t value |
| n | number of persons of that kind (for plural detection) |
Definition at line 189 of file cp_employee.cpp.
References cgi, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ERR_DROP, ngettext, and type.
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.
| type | Pointer to employee type string |
Definition at line 213 of file cp_employee.cpp.
References EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, MAX_EMPL, Q_streq, and type.
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.
| [in] | base | Which base the employee should be searched in. If nullptr 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. |
-1 in case of an error. Definition at line 273 of file cp_employee.cpp.
References cgi, E_Foreach, MAX_EMPL, and type.
Referenced by E_GetHiredRobot().
Return a "hired" ugv-employee pointer of a given ugv-type in a given base.
| [in] | base | Which base the ugv should be searched in.c |
| [in] | ugvType | What type of robot we want. |
Definition at line 301 of file cp_employee.cpp.
References cgi, DEBUG_CLIENT, E_GetHiredEmployees(), EMPL_ROBOT, and LIST_Foreach.
| Employee * E_GetUnassignedEmployee | ( | const base_t *const | base, |
| const employeeType_t | type ) |
Gets an assigned employee of a given type from the given base.
| [in] | base | Which base the employee should be hired in. |
| [in] | type | The type of employee to search. |
Definition at line 353 of file cp_employee.cpp.
References E_Foreach, and type.
Referenced by RS_AssignScientist(), RS_Max_f(), and RS_RemoveFiredScientist().
| Employee * E_GetUnhired | ( | employeeType_t | type | ) |
Iterates through unhired employees.
Definition at line 49 of file cp_employee.cpp.
References E_Foreach, and type.
Referenced by E_HireEmployeeByType().
Return a "not hired" ugv-employee pointer of a given ugv-type.
| [in] | ugvType | What type of robot we want. |
Definition at line 253 of file cp_employee.cpp.
References E_Foreach, and EMPL_ROBOT.
Referenced by E_HireRobot().
| bool E_HireAllowed | ( | const base_t * | base | ) |
Returns true if the current base is able to handle employees.
Definition at line 985 of file cp_employee.cpp.
References B_GetBuildingStatus(), B_IsUnderAttack, and B_QUARTERS.
Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().
Hires the employee in a base.
| [in] | base | Which base the employee should be hired in |
| [in] | employee | Which employee to hire |
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.
| [in] | base | Which base the employee should be hired in |
| [in] | type | Which employee type do we search |
Definition at line 414 of file cp_employee.cpp.
References E_GetUnhired(), E_HireEmployee(), and type.
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.
| [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 |
Definition at line 107 of file cp_employee.cpp.
References B_HANGAR, B_LAB, B_MISC, B_WORKSHOP, building_t::buildingType, cgi, DEBUG_CLIENT, E_CountByType(), E_HireEmployeeByType(), EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, and building_t::maxEmployees.
Referenced by B_AddBuildingToBasePos().
Hires the first free employee of that type.
| [in] | base | Which base the ugv/robot should be hired in. |
| [in] | ugvType | What type of ugv/robot should be hired. |
Definition at line 426 of file cp_employee.cpp.
References E_GetUnhiredRobot(), and E_HireEmployee().
Referenced by BS_BuyUGV().
| void E_InitialEmployees | ( | const campaign_t * | campaign | ) |
Create initial hireable employees.
Definition at line 759 of file cp_employee.cpp.
References cgi, E_CreateEmployee(), EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, frand(), i, NAT_GetRandom(), campaign_t::pilots, campaign_t::scientists, campaign_t::soldiers, campaign_t::ugvs, and campaign_t::workers.
Referenced by CP_CampaignInit(), and CreateBase().
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, debugEmployeeCmds, and E_InitCallbacks().
Referenced by CP_InitStartup().
| bool E_LoadXML | ( | xmlNode_t * | p | ) |
Load callback for savegames in XML Format.
| [in] | p | XML Node structure, where we get the information from |
Definition at line 909 of file cp_employee.cpp.
References B_AtLeastOneExists, B_GetBaseByIDX(), Employee::baseHired, ccs, cgi, Employee::chr, LIST_Add(), MAX_EMPL, NAT_GetNationByID(), OBJZERO, SAVE_EMPLOYEE_ASSIGNED, SAVE_EMPLOYEE_BASEHIRED, SAVE_EMPLOYEE_CHR, SAVE_EMPLOYEE_EMPLOYEE, SAVE_EMPLOYEE_EMPLOYEES, SAVE_EMPLOYEE_NATION, SAVE_EMPLOYEE_TYPE, SAVE_EMPLOYEE_UGV, SAVE_EMPLOYEETYPE_NAMESPACE, saveEmployeeConstants, Employee::setAssigned(), type, and xmlNode_t.
Referenced by SAV_Init().
Will change the base where the employee is located in and will also update the capacity in the affected bases.
| employee | The employee to change the base for |
| newBase | The base where the employee should be located at |
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().
Removes the items of an employee (soldier) from the base storage (s)he is hired at.
| [in] | employee | Pointer 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_t::inv.
Referenced by AIR_DestroyAircraft(), and AM_UpdateSurivorsAfterBattle().
| bool E_SaveXML | ( | xmlNode_t * | p | ) |
Save callback for savegames in XML Format.
| [out] | p | XML Node structure, where we write the information to |
Definition at line 870 of file cp_employee.cpp.
References cgi, E_Foreach, i, MAX_EMPL, SAVE_EMPLOYEE_ASSIGNED, SAVE_EMPLOYEE_BASEHIRED, SAVE_EMPLOYEE_CHR, SAVE_EMPLOYEE_EMPLOYEE, SAVE_EMPLOYEE_EMPLOYEES, SAVE_EMPLOYEE_NATION, SAVE_EMPLOYEE_TYPE, SAVE_EMPLOYEE_UGV, SAVE_EMPLOYEETYPE_NAMESPACE, saveEmployeeConstants, and xmlNode_t.
Referenced by SAV_Init().
Closing actions for employee-subsystem.
Definition at line 1036 of file cp_employee.cpp.
References ccs, cgi, debugEmployeeCmds, E_ShutdownCallbacks(), EMPL_SOLDIER, i, and MAX_EMPL.
Referenced by CP_Shutdown().
| void E_UnhireAllEmployees | ( | base_t * | base, |
| employeeType_t | type ) |
|
static |
Definition at line 1016 of file cp_employee.cpp.
Referenced by E_InitStartup(), and E_Shutdown().