UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_produce.h File Reference

Header for production related stuff. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  productionData_t
union  productionData_t::productionItem_t
struct  production_t
 Holds all information for the production of one item-type. More...
struct  production_queue_t
 A production queue. Lists all items to be produced. More...

Macros

#define MAX_PRODUCTIONS   40
 Maximum number of productions queued in any one base.
#define MAX_PRODUCTION_AMOUNT   500
#define UGV_SIZE   300
#define PR_IsDisassemblyData(data)
#define PR_IsAircraftData(data)
#define PR_IsItemData(data)
#define PR_IsProductionData(data)
#define PR_IsDisassembly(prod)
#define PR_IsAircraft(prod)
#define PR_IsItem(prod)
#define PR_IsProduction(prod)
#define PR_SetData(dataPtr, typeVal, ptr)
#define PR_IsDataValid(dataPtr)
#define PR_GetProgress(prod)
#define PR_IsReady(prod)
#define PR_GetProductionForBase(base)

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).
void PR_ProductionInit (void)
void PR_ProductionRun (void)
 Checks whether an item is finished.
bool PR_ItemIsProduceable (const objDef_t *item)
 check if an item is producable.
struct base_s * PR_ProductionBase (const production_t *production)
 Returns the base pointer the production belongs to.
int PR_IncreaseProduction (production_t *prod, int amount)
 increases production amount if possible
int PR_DecreaseProduction (production_t *prod, int amount)
 decreases production amount
const char * PR_GetName (const productionData_t *data)
technology_tPR_GetTech (const productionData_t *data)
void PR_UpdateProductionCap (struct base_s *base, int workerChange=0)
void PR_UpdateRequiredItemsInBasestorage (struct base_s *base, int amount, const requirements_t *reqs)
int PR_RequirementsMet (int amount, const requirements_t *reqs, struct base_s *base)
int PR_WorkersAvailable (const struct base_s *base)
int PR_GetRemainingMinutes (const production_t *prod)
 Calculates the remaining time for a technology in minutes.
int PR_GetRemainingHours (const production_t *prod)
 Calculates the remaining hours for a technology.
int PR_GetProductionHours (const struct base_s *base, const productionData_t *prodData)
production_tPR_QueueNew (struct base_s *base, const productionData_t *data, signed int amount)
void PR_QueueMove (production_queue_t *queue, int index, int dir)
 Moves the given queue item in the given direction.
void PR_QueueDelete (struct base_s *base, production_queue_t *queue, int index)
void PR_QueueNext (struct base_s *base)

Detailed Description

Header for production related stuff.

Definition in file cp_produce.h.

Macro Definition Documentation

◆ MAX_PRODUCTION_AMOUNT

#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().

◆ MAX_PRODUCTIONS

#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().

◆ PR_GetProductionForBase

◆ PR_GetProgress

#define PR_GetProgress ( prod)
Value:
((double)(prod)->frame / (prod)->totalFrames)

Definition at line 83 of file cp_produce.h.

Referenced by PR_ShowActiveProduction_f().

◆ PR_IsAircraft

#define PR_IsAircraft ( prod)
Value:
#define PR_IsAircraftData(data)
Definition cp_produce.h:71
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89

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().

◆ PR_IsAircraftData

#define PR_IsAircraftData ( data)
Value:
@ PRODUCTION_TYPE_AIRCRAFT
Definition cp_produce.h:37

Definition at line 71 of file cp_produce.h.

Referenced by PR_ProductionIncrease_f(), and PR_ProductionInfo().

◆ PR_IsDataValid

#define PR_IsDataValid ( dataPtr)
Value:
((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().

◆ PR_IsDisassembly

◆ PR_IsDisassemblyData

#define PR_IsDisassemblyData ( data)
Value:
@ PRODUCTION_TYPE_DISASSEMBLY
Definition cp_produce.h:38

Definition at line 70 of file cp_produce.h.

Referenced by PR_ProductionInfo(), and PR_QueueNew().

◆ PR_IsItem

#define PR_IsItem ( prod)
Value:
(PR_IsItemData(&(prod)->data))
#define PR_IsItemData(data)
Definition cp_produce.h:72

Definition at line 77 of file cp_produce.h.

Referenced by PR_CheckFrame(), PR_FinishProduction(), PR_ProductionInfo(), PR_SaveXML(), and PR_UpdateProductionList().

◆ PR_IsItemData

#define PR_IsItemData ( data)
Value:
@ PRODUCTION_TYPE_ITEM
Definition cp_produce.h:36

Definition at line 72 of file cp_produce.h.

Referenced by PR_ProductionInfo().

◆ PR_IsProduction

#define PR_IsProduction ( prod)
Value:
#define PR_IsDisassembly(prod)
Definition cp_produce.h:75

Definition at line 78 of file cp_produce.h.

Referenced by PR_ProductionRun().

◆ PR_IsProductionData

#define PR_IsProductionData ( data)
Value:

Definition at line 73 of file cp_produce.h.

Referenced by PR_CalculateTotalFrames().

◆ PR_IsReady

#define PR_IsReady ( prod)
Value:
((prod)->frame > (prod)->totalFrames)

Definition at line 84 of file cp_produce.h.

Referenced by PR_ProductionRun().

◆ PR_SetData

#define PR_SetData ( dataPtr,
typeVal,
ptr )
Value:
do { assert(ptr); (dataPtr)->data.pointer = (ptr); (dataPtr)->type = (typeVal); } while (0);
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94

Definition at line 80 of file cp_produce.h.

Referenced by PR_LoadXML(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionType_f(), TEST_F(), TEST_F(), and TEST_F().

◆ UGV_SIZE

#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().

Enumeration Type Documentation

◆ productionType_t

Enumerator
PRODUCTION_TYPE_ITEM 
PRODUCTION_TYPE_AIRCRAFT 
PRODUCTION_TYPE_DISASSEMBLY 
PRODUCTION_TYPE_MAX 

Definition at line 35 of file cp_produce.h.

Function Documentation

◆ PR_DecreaseProduction()

int PR_DecreaseProduction ( production_t * prod,
int amount )

decreases production amount

Parameters
[in,out]prodPointer to the production
[in]amountAdditional amount to remove (positive number)
Returns
the amount removed
Note
if production amount falls below 1 it removes the whole production from the queue as well

Definition at line 523 of file cp_produce.cpp.

References production_t::amount, cgi, production_t::data, ERR_DROP, production_t::idx, PR_GetProductionForBase, PR_GetTech(), PR_IsDisassembly, PR_ProductionBase(), PR_QueueDelete(), PR_UpdateRequiredItemsInBasestorage(), and technology_t::requireForProduction.

Referenced by PR_ProductionDecrease_f().

◆ PR_GetName()

const char * PR_GetName ( const productionData_t * data)
Returns
The translated name of the item in production

Definition at line 182 of file cp_produce.cpp.

References _, cgi, data, ERR_DROP, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, and UFO_TypeToName().

Referenced by PR_FinishProduction(), PR_ProductionIncrease_f(), and PR_ShowActiveProduction_f().

◆ PR_GetPrice()

int PR_GetPrice ( const int productionCost)

Used in production costs (to allow reducing prices below 1x).

Parameters
[in]productionCostproduction cost being modified
Returns
price modified by the component rate in campaign.ufo

Definition at line 667 of file cp_produce.cpp.

References ccs.

Referenced by PR_AircraftInfo(), PR_CheckFrame(), PR_FinishProduction(), and PR_ItemProductionInfo().

◆ PR_GetProductionHours()

int PR_GetProductionHours ( const struct base_s * base,
const productionData_t * prodData )

◆ PR_GetRemainingHours()

int PR_GetRemainingHours ( const production_t * prod)

Calculates the remaining hours for a technology.

Parameters
[in]prodPointer to the production structure

Definition at line 90 of file cp_produce.cpp.

References DateTime::MINUTES_PER_HOUR, and PR_GetRemainingMinutes().

Referenced by PR_ProductionInfo(), TEST_F(), TEST_F(), and TEST_F().

◆ PR_GetRemainingMinutes()

int PR_GetRemainingMinutes ( const production_t * prod)

Calculates the remaining time for a technology in minutes.

Parameters
[in]prodPointer to the production structure

Definition at line 79 of file cp_produce.cpp.

References production_t::frame, PR_ProductionBase(), PR_WorkersAvailable(), and production_t::totalFrames.

Referenced by PR_GetRemainingHours(), TEST_F(), TEST_F(), and TEST_F().

◆ PR_GetTech()

◆ PR_IncreaseProduction()

int PR_IncreaseProduction ( production_t * prod,
int amount )

increases production amount if possible

Parameters
[in,out]prodPointer to the production
[in]amountAdditional amount to add
Returns
the amount added

Definition at line 490 of file cp_produce.cpp.

References production_t::amount, production_t::data, MAX_PRODUCTION_AMOUNT, PR_GetTech(), PR_IsDisassembly, PR_ProductionBase(), PR_RequirementsMet(), PR_UpdateRequiredItemsInBasestorage(), and technology_t::requireForProduction.

Referenced by PR_ProductionIncrease_f().

◆ PR_ItemIsProduceable()

bool PR_ItemIsProduceable ( const objDef_t * item)

check if an item is producable.

Parameters
[in]itemPointer to the item that should be checked.

Definition at line 640 of file cp_produce.cpp.

References technology_t::produceTime, and RS_GetTechForItem().

Referenced by CP_ItemsSanityCheck(), PR_ItemProductionInfo(), PR_ProductionListClick_f(), and PR_UpdateProductionList().

◆ PR_ProductionBase()

struct base_s * PR_ProductionBase ( const production_t * production)

Returns the base pointer the production belongs to.

Parameters
[in]productionpointer to the production entry
Returns
base_t pointer to the base

Definition at line 651 of file cp_produce.cpp.

References B_GetNext(), MAX_PRODUCTIONS, and PR_GetProductionForBase.

Referenced by PR_DecreaseProduction(), PR_GetRemainingMinutes(), PR_IncreaseProduction(), and US_RemoveStoredUFO().

◆ PR_ProductionInit()

void PR_ProductionInit ( void )

References data.

◆ PR_ProductionRun()

void PR_ProductionRun ( void )

Checks whether an item is finished.

Note
One call each game time minute
See also
CP_CampaignRun
PR_DisassemblingFrame
PR_ProductionFrame

Definition at line 556 of file cp_produce.cpp.

References B_GetNext(), production_t::frame, production_queue_t::items, production_queue_t::numItems, PR_CheckFrame(), PR_FinishDisassembly(), PR_FinishProduction(), PR_GetProductionForBase, PR_IsDisassembly, PR_IsProduction, PR_IsReady, PR_ProductionAllowed(), and PR_WorkersAvailable().

Referenced by CP_CampaignRun(), TEST_F(), TEST_F(), and TEST_F().

◆ PR_QueueDelete()

void PR_QueueDelete ( struct base_s * base,
production_queue_t * queue,
int index )

References index.

◆ PR_QueueMove()

void PR_QueueMove ( production_queue_t * queue,
int index,
int offset )

Moves the given queue item in the given direction.

Parameters
[in]queuePointer to the queue.
[in]indexThe production item index in the queue
[in]offsetThe offset relative to the given index where the item should be moved, too

Definition at line 308 of file cp_produce.cpp.

References i, production_t::idx, index, production_queue_t::items, production_queue_t::numItems, and PR_SetUFODisassembly().

Referenced by PR_ProductionDown_f(), PR_ProductionRollBottom(), and PR_ProductionUp_f().

◆ PR_QueueNew()

production_t * PR_QueueNew ( struct base_s * base,
const productionData_t * data,
signed int amount )

References data, and index.

◆ PR_QueueNext()

void PR_QueueNext ( struct base_s * base)

◆ PR_RequirementsMet()

int PR_RequirementsMet ( int amount,
const requirements_t * reqs,
struct base_s * base )

◆ PR_UpdateProductionCap()

void PR_UpdateProductionCap ( struct base_s * base,
int workerChange = 0 )

◆ PR_UpdateRequiredItemsInBasestorage()

void PR_UpdateRequiredItemsInBasestorage ( struct base_s * base,
int amount,
const requirements_t * reqs )

◆ PR_WorkersAvailable()

int PR_WorkersAvailable ( const struct base_s * base)