UFO: Alien Invasion
|
Header for production related stuff. More...
Go to the source code of this file.
Data Structures | |
struct | productionData_t |
union | productionData_t::productionItem_t |
struct | production_s |
Holds all information for the production of one item-type. More... | |
struct | production_queue_s |
A production queue. Lists all items to be produced. More... | |
Macros | |
#define | MAX_PRODUCTIONS 40 |
Maximum number of productions queued in any one base. More... | |
#define | MAX_PRODUCTION_AMOUNT 500 |
#define | UGV_SIZE 300 |
#define | PR_IsDisassemblyData(data) ((data)->type == PRODUCTION_TYPE_DISASSEMBLY) |
#define | PR_IsAircraftData(data) ((data)->type == PRODUCTION_TYPE_AIRCRAFT) |
#define | PR_IsItemData(data) ((data)->type == PRODUCTION_TYPE_ITEM) |
#define | PR_IsProductionData(data) (!PR_IsDisassemblyData(data)) |
#define | PR_IsDisassembly(prod) (PR_IsDisassemblyData(&(prod)->data)) |
#define | PR_IsAircraft(prod) (PR_IsAircraftData(&(prod)->data)) |
#define | PR_IsItem(prod) (PR_IsItemData(&(prod)->data)) |
#define | PR_IsProduction(prod) (!PR_IsDisassembly(prod)) |
#define | PR_SetData(dataPtr, typeVal, ptr) do { assert(ptr); (dataPtr)->data.pointer = (ptr); (dataPtr)->type = (typeVal); } while (0); |
#define | PR_IsDataValid(dataPtr) ((dataPtr)->data.pointer != nullptr) |
#define | PR_GetProgress(prod) ((double)(prod)->frame / (prod)->totalFrames) |
#define | PR_IsReady(prod) ((prod)->frame > (prod)->totalFrames) |
#define | PR_GetProductionForBase(base) (&((base)->productions)) |
Typedefs | |
typedef struct production_s | production_t |
Holds all information for the production of one item-type. More... | |
typedef struct production_queue_s | production_queue_t |
A production queue. Lists all items to be produced. More... | |
Enumerations | |
enum | productionType_t { PRODUCTION_TYPE_ITEM, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_MAX } |
Functions | |
int | PR_GetPrice (const int productionCost) |
Used in production costs (to allow reducing prices below 1x). More... | |
void | PR_ProductionInit (void) |
void | PR_ProductionRun (void) |
Checks whether an item is finished. More... | |
bool | PR_ItemIsProduceable (const objDef_t *item) |
check if an item is producable. More... | |
struct base_s * | PR_ProductionBase (const production_t *production) |
Returns the base pointer the production belongs to. More... | |
int | PR_IncreaseProduction (production_t *prod, int amount) |
increases production amount if possible More... | |
int | PR_DecreaseProduction (production_t *prod, int amount) |
decreases production amount More... | |
const char * | PR_GetName (const productionData_t *data) |
technology_t * | PR_GetTech (const productionData_t *data) |
void | PR_UpdateProductionCap (struct base_s *base, int workerChange=0) |
Update the current capacity of Workshop. More... | |
void | PR_UpdateRequiredItemsInBasestorage (struct base_s *base, int amount, const requirements_t *reqs) |
Remove or add the required items from/to the a base. More... | |
int | PR_RequirementsMet (int amount, const requirements_t *reqs, struct base_s *base) |
Checks if the production requirements are met for a defined amount. More... | |
int | PR_WorkersAvailable (const struct base_s *base) |
int | PR_GetRemainingMinutes (const production_t *prod) |
Calculates the remaining time for a technology in minutes. More... | |
int | PR_GetRemainingHours (const production_t *prod) |
Calculates the remaining hours for a technology. More... | |
int | PR_GetProductionHours (const struct base_s *base, const productionData_t *prodData) |
production_t * | PR_QueueNew (struct base_s *base, const productionData_t *data, signed int amount) |
Add a new item to the bottom of the production queue. More... | |
void | PR_QueueMove (production_queue_t *queue, int index, int dir) |
Moves the given queue item in the given direction. More... | |
void | PR_QueueDelete (struct base_s *base, production_queue_t *queue, int index) |
Delete the selected entry from the queue. More... | |
void | PR_QueueNext (struct base_s *base) |
Queues the next production in the queue. More... | |
Header for production related stuff.
Definition in file cp_produce.h.
#define MAX_PRODUCTION_AMOUNT 500 |
Maximum number of produced items.
Definition at line 30 of file cp_produce.h.
Referenced by PR_IncreaseProduction(), and PR_ProductionIncrease_f().
#define MAX_PRODUCTIONS 40 |
Maximum number of productions queued in any one base.
Definition at line 28 of file cp_produce.h.
Referenced by PR_LoadXML(), PR_ProductionBase(), and PR_QueueNew().
#define PR_GetProductionForBase | ( | base | ) | (&((base)->productions)) |
Definition at line 96 of file cp_produce.h.
Referenced by PR_DecreaseProduction(), PR_EmptyQueue(), PR_LoadXML(), PR_PostLoadInitProgress(), PR_ProductionBase(), PR_ProductionDown_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionRollBottom(), PR_ProductionRun(), PR_ProductionStop_f(), PR_ProductionType_f(), PR_ProductionUp_f(), PR_QueueNew(), PR_QueueNext(), PR_SaveXML(), PR_ShowActiveProduction_f(), PR_UpdateProductionCap(), PR_UpdateProductionList(), and US_RemoveStoredUFO().
#define PR_GetProgress | ( | prod | ) | ((double)(prod)->frame / (prod)->totalFrames) |
Definition at line 83 of file cp_produce.h.
Referenced by PR_ShowActiveProduction_f().
#define PR_IsAircraft | ( | prod | ) | (PR_IsAircraftData(&(prod)->data)) |
Definition at line 76 of file cp_produce.h.
Referenced by PR_CheckFrame(), PR_FinishProduction(), PR_ProductionIncrease_f(), PR_ProductionInfo(), PR_SaveXML(), and PR_UpdateProductionList().
#define PR_IsAircraftData | ( | data | ) | ((data)->type == PRODUCTION_TYPE_AIRCRAFT) |
Definition at line 71 of file cp_produce.h.
Referenced by PR_ProductionIncrease_f(), and PR_ProductionInfo().
#define PR_IsDataValid | ( | dataPtr | ) | ((dataPtr)->data.pointer != nullptr) |
Definition at line 81 of file cp_produce.h.
Referenced by PR_LoadXML(), PR_ProductionChange_f(), PR_ProductionIncrease_f(), and PR_ProductionInfo().
#define PR_IsDisassembly | ( | prod | ) | (PR_IsDisassemblyData(&(prod)->data)) |
Definition at line 75 of file cp_produce.h.
Referenced by PR_DecreaseProduction(), PR_IncreaseProduction(), PR_ProductionIncrease_f(), PR_ProductionInfo(), PR_ProductionRun(), PR_ResetUFODisassembly(), PR_SaveXML(), PR_SetUFODisassembly(), and PR_UpdateProductionList().
#define PR_IsDisassemblyData | ( | data | ) | ((data)->type == PRODUCTION_TYPE_DISASSEMBLY) |
Definition at line 70 of file cp_produce.h.
Referenced by PR_ProductionInfo(), and PR_QueueNew().
#define PR_IsItem | ( | prod | ) | (PR_IsItemData(&(prod)->data)) |
Definition at line 77 of file cp_produce.h.
Referenced by PR_CheckFrame(), PR_FinishProduction(), PR_ProductionInfo(), PR_SaveXML(), and PR_UpdateProductionList().
#define PR_IsItemData | ( | data | ) | ((data)->type == PRODUCTION_TYPE_ITEM) |
Definition at line 72 of file cp_produce.h.
Referenced by PR_ProductionInfo().
#define PR_IsProduction | ( | prod | ) | (!PR_IsDisassembly(prod)) |
Definition at line 78 of file cp_produce.h.
Referenced by PR_ProductionRun().
#define PR_IsProductionData | ( | data | ) | (!PR_IsDisassemblyData(data)) |
Definition at line 73 of file cp_produce.h.
Referenced by PR_CalculateTotalFrames().
#define PR_IsReady | ( | prod | ) | ((prod)->frame > (prod)->totalFrames) |
Definition at line 84 of file cp_produce.h.
Referenced by PR_ProductionRun().
#define PR_SetData | ( | dataPtr, | |
typeVal, | |||
ptr | |||
) | do { assert(ptr); (dataPtr)->data.pointer = (ptr); (dataPtr)->type = (typeVal); } while (0); |
Definition at line 80 of file cp_produce.h.
Referenced by PR_LoadXML(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), and TEST_F().
#define UGV_SIZE 300 |
Size of a UGV in hangar capacity
Definition at line 33 of file cp_produce.h.
Referenced by BS_Buy_f(), BS_BuyUGV(), CAP_UpdateStorageCap(), E_HireEmployee(), E_MoveIntoNewBase(), and Employee::unhire().
typedef struct production_queue_s production_queue_t |
A production queue. Lists all items to be produced.
typedef struct production_s production_t |
Holds all information for the production of one item-type.
enum productionType_t |
Enumerator | |
---|---|
PRODUCTION_TYPE_ITEM | |
PRODUCTION_TYPE_AIRCRAFT | |
PRODUCTION_TYPE_DISASSEMBLY | |
PRODUCTION_TYPE_MAX |
Definition at line 35 of file cp_produce.h.
int PR_DecreaseProduction | ( | production_t * | prod, |
int | amount | ||
) |
decreases production amount
[in,out] | prod | Pointer to the production |
[in] | amount | Additional amount to remove (positive number) |
Definition at line 522 of file cp_produce.cpp.
References production_s::amount, cgi, production_s::data, ERR_DROP, production_s::idx, PR_GetProductionForBase, PR_GetTech(), PR_IsDisassembly, PR_ProductionBase(), PR_QueueDelete(), PR_UpdateRequiredItemsInBasestorage(), and technology_s::requireForProduction.
Referenced by PR_ProductionDecrease_f().
const char* PR_GetName | ( | const productionData_t * | data | ) |
Definition at line 181 of file cp_produce.cpp.
References _, productionData_t::productionItem_t::aircraft, cgi, productionData_t::data, ERR_DROP, aircraft_s::getUfoType(), productionData_t::productionItem_t::item, aircraft_s::name, objDef_s::name, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, aircraft_s::tpl, productionData_t::type, productionData_t::productionItem_t::ufo, UFO_TypeToName(), and storedUFO_s::ufoTemplate.
Referenced by PR_FinishProduction(), PR_ProductionIncrease_f(), and PR_ShowActiveProduction_f().
Used in production costs (to allow reducing prices below 1x).
[in] | productionCost | production cost being modified |
Definition at line 666 of file cp_produce.cpp.
References ccs, campaign_s::componentRate, and ccs_s::curCampaign.
Referenced by PR_AircraftInfo(), PR_CheckFrame(), PR_FinishProduction(), and PR_ItemProductionInfo().
int PR_GetProductionHours | ( | const struct base_s * | base, |
const productionData_t * | prodData | ||
) |
int PR_GetRemainingHours | ( | const production_t * | prod | ) |
Calculates the remaining hours for a technology.
[in] | prod | Pointer to the production structure |
Definition at line 89 of file cp_produce.cpp.
References MINUTES_PER_HOUR, and PR_GetRemainingMinutes().
Referenced by PR_ProductionInfo(), and TEST_F().
int PR_GetRemainingMinutes | ( | const production_t * | prod | ) |
Calculates the remaining time for a technology in minutes.
[in] | prod | Pointer to the production structure |
Definition at line 78 of file cp_produce.cpp.
References production_s::frame, PR_ProductionBase(), PR_WorkersAvailable(), and production_s::totalFrames.
Referenced by PR_GetRemainingHours(), and TEST_F().
technology_t* PR_GetTech | ( | const productionData_t * | data | ) |
Definition at line 198 of file cp_produce.cpp.
References productionData_t::productionItem_t::aircraft, productionData_t::data, productionData_t::productionItem_t::item, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, RS_GetTechForItem(), aircraft_s::tech, productionData_t::type, productionData_t::productionItem_t::ufo, and storedUFO_s::ufoTemplate.
Referenced by PR_CalculateTotalFrames(), PR_DecreaseProduction(), PR_FinishProduction(), PR_IncreaseProduction(), PR_ProductionIncrease_f(), PR_ProductionListRightClick_f(), PR_QueueDelete(), and PR_QueueNew().
int PR_IncreaseProduction | ( | production_t * | prod, |
int | amount | ||
) |
increases production amount if possible
[in,out] | prod | Pointer to the production |
[in] | amount | Additional amount to add |
Definition at line 489 of file cp_produce.cpp.
References production_s::amount, production_s::data, MAX_PRODUCTION_AMOUNT, PR_GetTech(), PR_IsDisassembly, PR_ProductionBase(), PR_RequirementsMet(), PR_UpdateRequiredItemsInBasestorage(), and technology_s::requireForProduction.
Referenced by PR_ProductionIncrease_f().
bool PR_ItemIsProduceable | ( | const objDef_t * | item | ) |
check if an item is producable.
[in] | item | Pointer to the item that should be checked. |
Definition at line 639 of file cp_produce.cpp.
References technology_s::produceTime, and RS_GetTechForItem().
Referenced by CP_ItemsSanityCheck(), PR_ItemProductionInfo(), PR_ProductionListClick_f(), and PR_UpdateProductionList().
struct base_s* PR_ProductionBase | ( | const production_t * | production | ) |
Returns the base pointer the production belongs to.
[in] | production | pointer to the production entry |
Definition at line 650 of file cp_produce.cpp.
References B_GetNext(), MAX_PRODUCTIONS, and PR_GetProductionForBase.
Referenced by PR_DecreaseProduction(), PR_GetRemainingMinutes(), PR_IncreaseProduction(), and US_RemoveStoredUFO().
Checks whether an item is finished.
Definition at line 555 of file cp_produce.cpp.
References B_GetNext(), production_s::frame, production_queue_s::items, production_queue_s::numItems, PR_CheckFrame(), PR_FinishDisassembly(), PR_FinishProduction(), PR_GetProductionForBase, PR_IsDisassembly, PR_IsProduction, PR_IsReady, PR_ProductionAllowed(), and PR_WorkersAvailable().
Referenced by CP_CampaignRun(), and TEST_F().
void PR_QueueDelete | ( | base_t * | base, |
production_queue_t * | queue, | ||
int | index | ||
) |
Delete the selected entry from the queue.
[in] | base | Pointer to base, where the queue is. |
[in] | queue | Pointer to the queue. |
[in] | index | Selected index in queue. |
Definition at line 280 of file cp_produce.cpp.
References production_s::amount, cgi, production_s::data, ERR_DROP, i, index, production_queue_s::items, production_queue_s::numItems, PR_GetTech(), PR_ResetUFODisassembly(), PR_SetUFODisassembly(), PR_UpdateRequiredItemsInBasestorage(), REMOVE_ELEM_ADJUST_IDX, and technology_s::requireForProduction.
Referenced by PR_DecreaseProduction(), PR_EmptyQueue(), PR_ProductionStop_f(), PR_QueueNext(), and US_RemoveStoredUFO().
void PR_QueueMove | ( | production_queue_t * | queue, |
int | index, | ||
int | offset | ||
) |
Moves the given queue item in the given direction.
[in] | queue | Pointer to the queue. |
[in] | index | The production item index in the queue |
[in] | offset | The offset relative to the given index where the item should be moved, too |
Definition at line 307 of file cp_produce.cpp.
References i, production_s::idx, index, production_queue_s::items, production_queue_s::numItems, and PR_SetUFODisassembly().
Referenced by PR_ProductionDown_f(), PR_ProductionRollBottom(), and PR_ProductionUp_f().
production_t* PR_QueueNew | ( | base_t * | base, |
const productionData_t * | data, | ||
signed int | amount | ||
) |
Add a new item to the bottom of the production queue.
[in] | base | Pointer to base, where the queue is. |
[in] | data | The production data |
[in] | amount | Desired amount to produce. |
NULL
in case the production wasn't enqueued, otherwise the production pointer Definition at line 233 of file cp_produce.cpp.
References production_s::amount, production_s::data, production_s::idx, production_queue_s::items, MAX_PRODUCTIONS, production_queue_s::numItems, OBJZERO, PR_CalculateTotalFrames(), PR_GetProductionForBase, PR_GetTech(), PR_IsDisassemblyData, PR_RequirementsMet(), PR_SetUFODisassembly(), PR_UpdateRequiredItemsInBasestorage(), technology_s::produceTime, technology_s::requireForProduction, and production_s::totalFrames.
Referenced by PR_ProductionIncrease_f(), and TEST_F().
Queues the next production in the queue.
[in] | base | Pointer to the base. |
Definition at line 344 of file cp_produce.cpp.
References _, Com_sprintf(), cp_messageBuffer, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_s::name, NT_PRODUCTION_QUEUE_EMPTY, production_queue_s::numItems, PR_GetProductionForBase, and PR_QueueDelete().
Referenced by PR_FinishProduction(), and US_RemoveStoredUFO().
int PR_RequirementsMet | ( | int | amount, |
const requirements_t * | reqs, | ||
base_t * | base | ||
) |
Checks if the production requirements are met for a defined amount.
[in] | amount | How many items are planned to be produced. |
[in] | reqs | The production requirements of the item that is to be produced. |
[in] | base | Pointer to base. |
Definition at line 146 of file cp_produce.cpp.
References requirement_s::amount, B_AntimatterInBase(), B_ItemInBase(), i, requirement_s::link, requirements_s::links, requirements_s::numLinks, requirement_s::typelink_t::od, RS_IsResearched_ptr(), RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, requirement_s::typelink_t::tech, and requirement_s::type.
Referenced by PR_IncreaseProduction(), PR_ProductionIncrease_f(), and PR_QueueNew().
Update the current capacity of Workshop.
[in] | base | Pointer to the base containing workshop. |
[in] | workerChange | Number of workers going to be hired/fired |
Definition at line 606 of file cp_produce.cpp.
References CAP_Get, CAP_WORKSPACE, capacities_s::cur, production_s::data, E_CountHired(), EMPL_WORKER, production_s::frame, i, production_queue_s::items, capacities_s::max, production_queue_s::numItems, PR_CalculateTotalFrames(), PR_EmptyQueue(), PR_GetProductionForBase, PR_ProductionAllowed(), and production_s::totalFrames.
Referenced by B_Build(), B_ResetAllStatusAndCapacities(), CAP_CheckOverflow(), E_HireEmployee(), E_MoveIntoNewBase(), PR_ProductionList_f(), TR_EmptyTransferCargo(), and Employee::unhire().
void PR_UpdateRequiredItemsInBasestorage | ( | base_t * | base, |
int | amount, | ||
const requirements_t * | reqs | ||
) |
Remove or add the required items from/to the a base.
[in] | base | Pointer to base. |
[in] | amount | How many items are planned to be added (positive number) or removed (negative number). |
[in] | reqs | The production requirements of the item that is to be produced. These included numbers are multiplied with 'amount') |
Definition at line 110 of file cp_produce.cpp.
References requirement_s::amount, B_AddAntimatter(), B_AddToStorage(), cgi, ERR_DROP, i, requirement_s::link, requirements_s::links, requirements_s::numLinks, requirement_s::typelink_t::od, RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, and requirement_s::type.
Referenced by PR_DecreaseProduction(), PR_IncreaseProduction(), PR_QueueDelete(), and PR_QueueNew().