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

Defines

#define MAX_PRODUCTIONS   256
 Maximum number of productions queued in any one base.
#define MAX_PRODUCTIONS_PER_WORKSHOP   5
#define MAX_PRODUCTION_AMOUNT   500
#define UGV_SIZE   300

Typedefs

typedef struct production_s production_t
 Holds all information for the production of one item-type.
typedef struct production_queue_s production_queue_t
 A production queue. Lists all items to be produced.

Functions

void PR_ProductionInit (void)
void PR_ProductionRun (void)
 Checks whether an item is finished.
qboolean PR_ItemIsProduceable (const objDef_t const *item)
 check if an item is producable.
base_tPR_ProductionBase (production_t *production)
 Returns the base pointer the production belongs to.
base_tPR_ProductionQueueBase (const production_queue_t const *queue)
 Returns the base pointer the production queue 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
void PR_UpdateProductionCap (struct base_s *base)
 Update the current capacity of Workshop.
void PR_UpdateRequiredItemsInBasestorage (base_t *base, int amount, const requirements_t const *reqs)
 Remove or add the required items from/to the a base.
int PR_RequirementsMet (int amount, const requirements_t const *reqs, base_t *base)
 Checks if the production requirements are met for a defined amount.
float PR_CalculateProductionPercentDone (const base_t *base, const technology_t *tech, const struct storedUFO_s *const storedUFO)
production_tPR_QueueNew (base_t *base, production_queue_t *queue, objDef_t *item, aircraft_t *aircraftTemplate, struct storedUFO_s *ufo, signed int amount)
 Add a new item to the bottom of the production queue.
void PR_QueueMove (production_queue_t *queue, int index, int dir)
 Moves the given queue item in the given direction.
void PR_QueueDelete (base_t *base, production_queue_t *queue, int index)
 Delete the selected entry from the queue.
void PR_QueueNext (base_t *base)
 Queues the next production in the queue.
int PR_QueueFreeSpace (const production_queue_t const *queue)
 returns the number of free production slots of a queue

Variables

const int PRODUCE_FACTOR
 Used in production costs (to allow reducing prices below 1x).
const int PRODUCE_DIVISOR

Detailed Description

Header for production related stuff.

Definition in file cp_produce.h.


Define Documentation

#define MAX_PRODUCTION_AMOUNT   500

Maximum number of produced items.

Definition at line 33 of file cp_produce.h.

Referenced by PR_IncreaseProduction(), and PR_ProductionIncrease_f().

#define MAX_PRODUCTIONS   256

Maximum number of productions queued in any one base.

Definition at line 30 of file cp_produce.h.

Referenced by PR_LoadXML(), PR_ProductionBase(), and PR_QueueFreeSpace().

#define MAX_PRODUCTIONS_PER_WORKSHOP   5

Definition at line 31 of file cp_produce.h.

Referenced by PR_ProductionList_f(), and PR_QueueFreeSpace().

#define UGV_SIZE   300

Size of a UGV in hangar capacity

Definition at line 36 of file cp_produce.h.

Referenced by B_UpdateStorageCap(), BS_BuyItem_f(), E_HireEmployee(), and E_UnhireEmployee().


Typedef Documentation

A production queue. Lists all items to be produced.

See also:
production_t
typedef struct production_s production_t

Holds all information for the production of one item-type.

Note:
We can get the tech pointer from csi.ods. The tech struct holds the time that is needed to produce the selected equipment.

Function Documentation

float PR_CalculateProductionPercentDone ( const base_t base,
const technology_t tech,
const struct storedUFO_s *const   storedUFO 
)
int PR_DecreaseProduction ( production_t prod,
int  amount 
)

decreases production amount

Parameters:
[in,out] prod Pointer to the production
[in] amount Additional 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 650 of file cp_produce.c.

References production_s::aircraft, production_s::amount, ccs, production_s::idx, base_s::idx, production_s::item, PR_ProductionBase(), PR_QueueDelete(), PR_UpdateRequiredItemsInBasestorage(), ccs_s::productions, technology_s::requireForProduction, RS_GetTechForItem(), aircraft_s::tech, production_s::ufo, and storedUFO_s::ufoTemplate.

Referenced by PR_ProductionDecrease_f().

int PR_IncreaseProduction ( production_t prod,
int  amount 
)

increases production amount if possible

Parameters:
[in,out] prod Pointer to the production
[in] amount Additional amount to add
Returns:
the amount added

Definition at line 609 of file cp_produce.c.

References production_s::aircraft, production_s::amount, production_s::item, MAX_PRODUCTION_AMOUNT, PR_ProductionBase(), PR_RequirementsMet(), PR_UpdateRequiredItemsInBasestorage(), technology_s::requireForProduction, RS_GetTechForItem(), aircraft_s::tech, and production_s::ufo.

Referenced by PR_ProductionIncrease_f().

qboolean PR_ItemIsProduceable ( const objDef_t const *  item  ) 

check if an item is producable.

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

Definition at line 768 of file cp_produce.c.

References technology_s::produceTime, and RS_GetTechForItem().

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

base_t* PR_ProductionBase ( production_t production  ) 

Returns the base pointer the production belongs to.

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

Definition at line 779 of file cp_produce.c.

References B_GetBaseByIDX(), ccs, i, production_queue_s::items, MAX_PRODUCTIONS, ccs_s::numBases, and ccs_s::productions.

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

void PR_ProductionInit ( void   ) 

Definition at line 738 of file cp_produce.c.

References Cvar_Get().

Referenced by CP_CampaignInit().

base_t* PR_ProductionQueueBase ( const production_queue_t const *  queue  ) 

Returns the base pointer the production queue belongs to.

Parameters:
[in] queue pointer to the production queue
Returns:
base_t pointer to the base

Definition at line 797 of file cp_produce.c.

References B_GetFoundedBaseByIDX(), ccs, and ccs_s::productions.

Referenced by PR_QueueDelete(), and PR_QueueFreeSpace().

void PR_ProductionRun ( void   ) 
void PR_QueueDelete ( base_t base,
production_queue_t queue,
int  index 
)
int PR_QueueFreeSpace ( const production_queue_t const *  queue  ) 

returns the number of free production slots of a queue

Parameters:
[in] queue Pointer to the queue to check

Definition at line 186 of file cp_produce.c.

References B_GetNumberOfBuildingsInBaseByBuildingType(), B_WORKSHOP, MAX_PRODUCTIONS, MAX_PRODUCTIONS_PER_WORKSHOP, production_queue_s::numItems, and PR_ProductionQueueBase().

Referenced by PR_ProductionIncrease_f(), and PR_QueueNew().

void PR_QueueMove ( production_queue_t queue,
int  index,
int  dir 
)

Moves the given queue item in the given direction.

Parameters:
[in] queue Pointer to the queue.
[in] index 
[in] dir 

Definition at line 335 of file cp_produce.c.

References storedUFO_s::disassembly, i, production_s::idx, production_queue_s::items, production_queue_s::numItems, and production_s::ufo.

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

production_t* PR_QueueNew ( base_t base,
production_queue_t queue,
objDef_t item,
aircraft_t aircraftTemplate,
storedUFO_t ufo,
signed int  amount 
)

Add a new item to the bottom of the production queue.

Parameters:
[in] base Pointer to base, where the queue is.
[in] queue Pointer to the queue.
[in] item Item to add.
[in] aircraftTemplate aircraft to add.
[in] ufo The UFO in case of a disassemly.
[in] amount Desired amount to produce.

Todo:
move this check out into a new function
Todo:
move popup into menucode
Todo:
move popup into menucode
Todo:
we should also count aircraft that are already in the queue list

Definition at line 208 of file cp_produce.c.

References _, AIR_CalculateHangarStorage(), production_s::aircraft, production_s::amount, B_COMMAND, B_GetBuildingStatus(), B_HANGAR, B_SMALL_HANGAR, storedUFO_s::disassembly, E_CountHired(), EMPL_WORKER, production_s::idx, production_s::item, production_queue_s::items, production_queue_s::numItems, requirements_s::numLinks, production_s::percentDone, PR_QueueFreeSpace(), PR_RequirementsMet(), PR_UpdateRequiredItemsInBasestorage(), technology_s::produceTime, production_s::production, qfalse, qtrue, technology_s::requireForProduction, RS_GetTechForItem(), aircraft_s::tech, production_s::ufo, storedUFO_s::ufoTemplate, and UI_Popup().

Referenced by PR_ProductionIncrease_f().

void PR_QueueNext ( base_t base  ) 

Queues the next production in the queue.

Parameters:
[in] base Pointer to the base.

Definition at line 373 of file cp_produce.c.

References _, ccs, Com_sprintf(), cp_messageBuffer, base_s::idx, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_s::name, NT_PRODUCTION_QUEUE_EMPTY, production_queue_s::numItems, PR_QueueDelete(), ccs_s::productions, and qfalse.

Referenced by PR_ProductionFrame(), and US_RemoveStoredUFO().

int PR_RequirementsMet ( int  amount,
const requirements_t const *  reqs,
base_t base 
)

Checks if the production requirements are met for a defined amount.

Parameters:
[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.
Returns:
how much item/aircraft/etc can be produced

Definition at line 149 of file cp_produce.c.

References requirement_s::amount, B_AntimatterInBase(), B_ItemInBase(), i, requirement_s::link, requirements_s::links, requirements_s::numLinks, RS_IsResearched_ptr(), RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, and requirement_s::type.

Referenced by PR_IncreaseProduction(), PR_ProductionIncrease_f(), and PR_QueueNew().

void PR_UpdateProductionCap ( base_t base  ) 

Update the current capacity of Workshop.

Parameters:
[in] base Pointer to the base containing workshop.

Definition at line 749 of file cp_produce.c.

References CAP_WORKSPACE, base_s::capacities, cap_maxcur_s::cur, E_CountHired(), EMPL_WORKER, cap_maxcur_s::max, and PR_EmptyQueue().

Referenced by B_BuildBase_f(), B_BuildingOnDestroy_f(), B_ResetAllStatusAndCapacities(), E_HireEmployee(), E_RemoveEmployeeFromBuildingOrAircraft(), and PR_ProductionList_f().

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

Remove or add the required items from/to the a base.

Parameters:
[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 108 of file cp_produce.c.

References requirement_s::amount, B_AddToStorage(), B_ManageAntimatter(), Com_Error(), ERR_DROP, i, requirement_s::link, requirements_s::links, requirements_s::numLinks, qfalse, qtrue, 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().


Variable Documentation

const int PRODUCE_DIVISOR

Definition at line 37 of file cp_produce.c.

Referenced by PR_AircraftInfo(), PR_ItemProductionInfo(), and PR_ProductionFrame().

const int PRODUCE_FACTOR

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

Definition at line 36 of file cp_produce.c.

Referenced by PR_AircraftInfo(), PR_ItemProductionInfo(), and PR_ProductionFrame().


Generated by  doxygen 1.6.2