26 #include "../../cl_shared.h" 27 #include "../cl_game.h" 28 #include "../cl_game_team.h" 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."));
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);
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++) {
785 static 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());
804 static 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)
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}
bool E_SaveXML(xmlNode_t *p)
Save callback for savegames in XML Format.
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
nation_t * NAT_GetNationByID(const char *nationID)
Return a nation-pointer by the nations id.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
QGL_EXTERN GLint GLenum type
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Item * getNextItem(const Item *prev) const
employeeType_t E_GetEmployeeType(const char *type)
Convert string to employeeType_t.
#define SAVE_EMPLOYEE_UGV
nation_t * NAT_GetRandom(void)
Return a pointer to a random nation.
void E_ShutdownCallbacks(void)
Unregister UI callbacks.
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
A base with all it's data.
const employeeType_t _type
int CL_GetRankIdx(const char *rankID)
Get the index of the given rankID in ccs.ranks array.
void CAP_AddCurrent(base_t *base, baseCapacities_t capacity, int value)
Changes the current (used) capacity on a base.
#define E_Foreach(employeeType, var)
const aircraft_t * AIR_IsEmployeeInAircraft(const Employee *employee, const aircraft_t *aircraft)
Tells you if an employee is assigned to an aircraft.
Employee * E_GetUnhired(employeeType_t type)
Iterates through unhired employees.
Header file for menu callback functions used for hire/fire employee menu.
int E_CountAllHired(const base_t *const base, const bool peopleOnly)
Counts all hired employees of a given base.
const ugv_t *IMPORT * Com_GetUGVByID(const char *ugvID)
bool E_HireAllowed(const base_t *base)
Returns true if the current base is able to handle employees.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
#define B_IsUnderAttack(base)
const objDef_t * ammoDef(void) const
bool E_LoadXML(xmlNode_t *p)
Load callback for savegames in XML Format.
void E_InitCallbacks(void)
Register UI callbacks.
Describes a character with all its attributes.
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
#define B_AtLeastOneExists()
void E_HireForBuilding(base_t *base, building_t *building, int num)
Hires some employees of appropriate type for a building.
rank_t * CL_GetRankByIdx(const int index)
Returns a rank at an index.
void E_Shutdown(void)
Closing actions for employee-subsystem.
#define SAVE_EMPLOYEE_NATION
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
bool E_HireRobot(base_t *base, const ugv_t *ugvType)
Hires the first free employee of that 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.
bool isAwayFromBase() const
Tells you if a employee is away from his home base (gone in mission).
int CAP_GetFreeCapacity(const base_t *base, baseCapacities_t capacityType)
Returns the free capacity of a type.
bool E_HireEmployee(base_t *base, Employee *employee)
Hires the employee in a base.
static const cmdList_t debugEmployeeCmds[]
#define SAVE_EMPLOYEE_EMPLOYEES
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...
item instance data, with linked list capability
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
static const constListEntry_t saveEmployeeConstants[]
void AIR_AutoAddPilotToAircraft(const base_t *base, Employee *pilot)
Adds the pilot to the first available aircraft at the specified base.
#define ngettext(x, y, cnt)
void RS_RemoveFiredScientist(base_t *base, Employee *employee)
Remove one scientist from research project if needed.
employeeType_t getType() const
int E_CountUnhiredRobotsByType(const ugv_t *ugvType)
Counts all available Robots/UGVs that are for sale.
#define SAVE_EMPLOYEE_ASSIGNED
int E_CountByType(employeeType_t type)
Returns number of employees of a type.
#define SAVE_EMPLOYEE_EMPLOYEE
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.
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
const cgame_import_t * cgi
int salary() const
Calculates the employee's actual salary.
Employee * E_GetAssignedEmployee(const base_t *const base, const employeeType_t type)
Gets an unassigned employee of a given type from the given base.
void setAssigned(bool assigned)
employeeType_t
The types of employees.
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...
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
const char * GAME_CP_GetTeamDef(void)
XML tag constants for savegame.
void E_RemoveInventoryFromStorage(Employee *employee)
Removes the items of an employee (soldier) from the base storage (s)he is hired at.
#define SAVE_EMPLOYEE_TYPE
Employee * E_GetUnhiredRobot(const ugv_t *ugvType)
Return a "not hired" ugv-employee pointer of a given ugv-type.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
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_CountUnhired(employeeType_t type)
Counts unhired employees of a given type in a given base.
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 unassign()
Removes the employee from buildings and aircraft.
float frand(void)
Return random values between 0 and 1.
#define SAVE_EMPLOYEE_CHR
bool unhire()
Fires an employee.
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
#define SAVE_EMPLOYEE_BASEHIRED
int E_CountUnassigned(const base_t *const base, employeeType_t type)
Counts unassigned employees of a given type in a given base.
#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 ...
void E_InitialEmployees(const campaign_t *campaign)
Create initial hireable employees.
buildingType_t buildingType
Header file for single player campaign control.
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base...
const ugv_t *IMPORT * Com_GetUGVByIDSilent(const char *ugvID)
Employee * E_GetUnassignedEmployee(const base_t *const base, const employeeType_t type)
Gets an assigned employee of a given type from the given base.
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
A building with all it's data.
#define SAVE_EMPLOYEETYPE_NAMESPACE
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
#define AIR_Foreach(var)
iterates trough all aircraft
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
const objDef_t * def(void) const
Describes a rank that a recruit can gain.
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
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...
linkedList_t * employees[MAX_EMPL]
Employee * E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber)
Searches employee from a type for the ucn (character id)
Defines a type of UGV/Robot.
void unequip()
Removes the equipment from an employee.