UFO: Alien Invasion
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. 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))
 

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_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. 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_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. More...
 
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.

◆ MAX_PRODUCTIONS

#define MAX_PRODUCTIONS   40

Maximum number of productions queued in any one base.

Definition at line 28 of file cp_produce.h.

◆ PR_GetProductionForBase

#define PR_GetProductionForBase (   base)    (&((base)->productions))

Definition at line 96 of file cp_produce.h.

◆ PR_GetProgress

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

Definition at line 83 of file cp_produce.h.

◆ PR_IsAircraft

#define PR_IsAircraft (   prod)    (PR_IsAircraftData(&(prod)->data))

Definition at line 76 of file cp_produce.h.

◆ PR_IsAircraftData

#define PR_IsAircraftData (   data)    ((data)->type == PRODUCTION_TYPE_AIRCRAFT)

Definition at line 71 of file cp_produce.h.

◆ PR_IsDataValid

#define PR_IsDataValid (   dataPtr)    ((dataPtr)->data.pointer != nullptr)

Definition at line 81 of file cp_produce.h.

◆ PR_IsDisassembly

#define PR_IsDisassembly (   prod)    (PR_IsDisassemblyData(&(prod)->data))

Definition at line 75 of file cp_produce.h.

◆ PR_IsDisassemblyData

#define PR_IsDisassemblyData (   data)    ((data)->type == PRODUCTION_TYPE_DISASSEMBLY)

Definition at line 70 of file cp_produce.h.

◆ PR_IsItem

#define PR_IsItem (   prod)    (PR_IsItemData(&(prod)->data))

Definition at line 77 of file cp_produce.h.

◆ PR_IsItemData

#define PR_IsItemData (   data)    ((data)->type == PRODUCTION_TYPE_ITEM)

Definition at line 72 of file cp_produce.h.

◆ PR_IsProduction

#define PR_IsProduction (   prod)    (!PR_IsDisassembly(prod))

Definition at line 78 of file cp_produce.h.

◆ PR_IsProductionData

#define PR_IsProductionData (   data)    (!PR_IsDisassemblyData(data))

Definition at line 73 of file cp_produce.h.

◆ PR_IsReady

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

Definition at line 84 of file cp_produce.h.

◆ PR_SetData

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

◆ UGV_SIZE

#define UGV_SIZE   300

Size of a UGV in hangar capacity

Definition at line 33 of file cp_produce.h.

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, campaign_t::componentRate, and ccs_t::curCampaign.

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

◆ 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(), and TEST_F().

◆ PR_QueueDelete()

void PR_QueueDelete ( struct base_s *  base,
production_queue_t queue,
int  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 
)

◆ 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)