Single player production stuff. More...
#include "../cl_shared.h"
#include "../ui/ui_popup.h"
#include "cp_campaign.h"
#include "cp_ufo.h"
#include "cp_produce.h"
#include "cp_produce_callbacks.h"
#include "save/save_produce.h"
Go to the source code of this file.
Functions | |
float | PR_CalculateProductionPercentDone (const base_t *base, const technology_t *tech, const storedUFO_t *const storedUFO) |
Calculates the fraction (percentage) of production of an item in 1 hour. | |
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. | |
int | PR_QueueFreeSpace (const production_queue_t const *queue) |
returns the number of free production slots of a queue | |
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. | |
void | PR_QueueDelete (base_t *base, production_queue_t *queue, int index) |
Delete the selected entry from the queue. | |
void | PR_QueueMove (production_queue_t *queue, int index, int dir) |
Moves the given queue item in the given direction. | |
void | PR_QueueNext (base_t *base) |
Queues the next production in the queue. | |
static void | PR_EmptyQueue (base_t *base) |
clears the production queue on a base | |
static void | PR_ProductionRollBottom_f (void) |
moves the first production to the bottom of the list | |
static int | PR_DisassembleItem (base_t *base, components_t *comp, float condition, qboolean calculate) |
Disassembles item, adds components to base storage and calculates all components size. | |
static void | PR_ProductionFrame (base_t *base, production_t *prod) |
Runs the production of an item or an aircraft. | |
static void | PR_DisassemblingFrame (base_t *base, production_t *prod) |
Runs the disassembling of a ufo. | |
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_ProductionRun (void) |
Checks whether an item is finished. | |
qboolean | PR_ProductionAllowed (const base_t *base) |
Returns true if the current base is able to produce items. | |
void | PR_ProductionInit (void) |
void | PR_UpdateProductionCap (base_t *base) |
Update the current capacity of Workshop. | |
qboolean | PR_ItemIsProduceable (const objDef_t const *item) |
check if an item is producable. | |
base_t * | PR_ProductionBase (production_t *production) |
Returns the base pointer the production belongs to. | |
base_t * | PR_ProductionQueueBase (const production_queue_t const *queue) |
Returns the base pointer the production queue belongs to. | |
qboolean | PR_SaveXML (mxml_node_t *p) |
Save callback for savegames in XML Format. | |
qboolean | PR_LoadXML (mxml_node_t *p) |
Load callback for xml savegames. | |
Variables | |
const int | PRODUCE_FACTOR = 1 |
Used in production costs (to allow reducing prices below 1x). | |
const int | PRODUCE_DIVISOR = 1 |
static const int | PRODUCE_WORKERS = 10 |
Default amount of workers, the produceTime for technologies is defined. | |
static cvar_t * | mn_production_limit |
static cvar_t * | mn_production_workers |
static cvar_t * | mn_production_amount |
Single player production stuff.
Definition in file cp_produce.c.
float PR_CalculateProductionPercentDone | ( | const base_t * | base, | |
const technology_t * | tech, | |||
const storedUFO_t *const | storedUFO | |||
) |
Calculates the fraction (percentage) of production of an item in 1 hour.
[in] | base | Pointer to the base with given production. |
[in] | tech | Pointer to the technology for given production. |
[in] | storedUFO | Pointer to disassembled UFO. |
Definition at line 57 of file cp_produce.c.
References CAP_WORKSPACE, base_s::capacities, Com_DPrintf(), storedUFO_s::comp, DEBUG_CLIENT, E_CountHired(), EMPL_WORKER, f, GetDistanceOnGlobe(), technology_s::id, storedUFO_s::installation, cap_maxcur_s::max, base_s::pos, installation_s::pos, PRODUCE_WORKERS, technology_s::produceTime, and components_s::time.
Referenced by PR_AircraftInfo(), PR_DisassemblingFrame(), PR_DisassemblyInfo(), PR_ItemProductionInfo(), and PR_ProductionFrame().
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 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().
static int PR_DisassembleItem | ( | base_t * | base, | |
components_t * | comp, | |||
float | condition, | |||
qboolean | calculate | |||
) | [static] |
Disassembles item, adds components to base storage and calculates all components size.
[in] | base | Pointer to base where the disassembling is being made. |
[in] | comp | Pointer to components definition. |
[in] | condition | condition of the item/UFO being disassembled, objects gathered from disassembly decreased to that factor |
[in] | calculate | True if this is only calculation of item size, false if this is real disassembling. |
Definition at line 430 of file cp_produce.c.
References ANTIMATTER_TECH_ID, B_ManageAntimatter(), B_UpdateStorageAndCapacity(), Com_DPrintf(), Com_Error(), COMP_ITEMCOUNT_SCALED, DEBUG_CLIENT, ERR_DROP, i, objDef_s::id, components_s::itemAmount, components_s::itemAmount2, components_s::items, components_s::numItemtypes, qfalse, qtrue, RS_GetTechForItem(), RS_MarkCollected(), and objDef_s::size.
Referenced by PR_DisassemblingFrame().
static void PR_DisassemblingFrame | ( | base_t * | base, | |
production_t * | prod | |||
) | [static] |
Runs the disassembling of a ufo.
base | The base to produce in | |
prod | The production that is running |
Definition at line 569 of file cp_produce.c.
References _, CAP_ITEMS, base_s::capacities, Com_sprintf(), storedUFO_s::comp, storedUFO_s::condition, cp_messageBuffer, cap_maxcur_s::cur, cap_maxcur_s::max, MINUTES_PER_HOUR, MSG_PRODUCTION, MSG_STANDARD, MSO_CheckAddNewMessage(), base_s::name, NT_PRODUCTION_FAILED, NT_PRODUCTION_FINISHED, production_s::percentDone, PR_CalculateProductionPercentDone(), PR_DisassembleItem(), PR_ProductionRollBottom_f(), production_s::production, qfalse, qtrue, production_s::spaceMessage, aircraft_s::tech, production_s::ufo, UFO_TypeToName(), storedUFO_s::ufoTemplate, aircraft_s::ufotype, and US_RemoveStoredUFO().
Referenced by PR_ProductionRun().
static void PR_EmptyQueue | ( | base_t * | base | ) | [static] |
clears the production queue on a base
Definition at line 388 of file cp_produce.c.
References ccs, base_s::idx, production_queue_s::numItems, PR_QueueDelete(), and ccs_s::productions.
Referenced by PR_UpdateProductionCap().
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 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().
check if an item is producable.
[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().
qboolean PR_LoadXML | ( | mxml_node_t * | p | ) |
Load callback for xml savegames.
[in] | p | XML Node structure, where we get the information from |
Definition at line 849 of file cp_produce.c.
References AIR_GetAircraft(), production_s::aircraft, production_s::amount, ccs, Com_Printf(), storedUFO_s::disassembly, production_s::idx, INVSH_GetItemByID(), production_s::item, production_queue_s::items, MAX_BASES, MAX_PRODUCTIONS, mxml_GetFloat(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), ccs_s::numBases, production_queue_s::numItems, production_s::percentDone, production_s::production, ccs_s::productions, qfalse, qtrue, SAVE_PRODUCE_AIRCRAFTID, SAVE_PRODUCE_AMOUNT, SAVE_PRODUCE_ITEM, SAVE_PRODUCE_ITEMID, SAVE_PRODUCE_PERCENTDONE, SAVE_PRODUCE_PRODUCTION, SAVE_PRODUCE_QUEUE, SAVE_PRODUCE_QUEUEIDX, SAVE_PRODUCE_UFOIDX, production_s::ufo, and US_GetStoredUFOByIDX().
Referenced by SAV_Init().
Returns true if the current base is able to produce items.
[in] | base | Pointer to the base. |
Definition at line 726 of file cp_produce.c.
References B_GetBuildingStatus(), B_WORKSHOP, BASE_UNDER_ATTACK, base_s::baseStatus, E_CountHired(), EMPL_WORKER, qfalse, and qtrue.
Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick(), PR_ProductionRun(), and TR_TransferStart().
base_t* PR_ProductionBase | ( | production_t * | production | ) |
Returns the base pointer the production belongs to.
[in] | production | pointer to the production entry |
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().
static void PR_ProductionFrame | ( | base_t * | base, | |
production_t * | prod | |||
) | [static] |
Runs the production of an item or an aircraft.
base | The base to produce in | |
prod | The production that is running |
Definition at line 467 of file cp_produce.c.
References _, AIR_CalculateHangarStorage(), AIR_NewAircraft(), production_s::aircraft, production_s::amount, B_UpdateStorageAndCapacity(), CAP_ITEMS, base_s::capacities, ccs, CL_UpdateCredits(), Com_sprintf(), cp_messageBuffer, production_s::creditMessage, ccs_s::credits, cap_maxcur_s::cur, aircraft_s::id, production_s::item, cap_maxcur_s::max, MINUTES_PER_HOUR, MSG_PRODUCTION, MSG_STANDARD, MSO_CheckAddNewMessage(), aircraft_s::name, objDef_s::name, name, base_s::name, NT_PRODUCTION_FAILED, NT_PRODUCTION_FINISHED, production_s::percentDone, PR_CalculateProductionPercentDone(), PR_ProductionRollBottom_f(), PR_QueueNext(), aircraft_s::price, objDef_s::price, PRODUCE_DIVISOR, PRODUCE_FACTOR, production_s::production, qfalse, qtrue, RS_GetTechForItem(), objDef_s::size, production_s::spaceMessage, aircraft_s::tech, and aircraft_s::tpl.
Referenced by PR_ProductionRun().
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.
[in] | queue | pointer to the production queue |
Definition at line 797 of file cp_produce.c.
References B_GetFoundedBaseByIDX(), ccs, and ccs_s::productions.
Referenced by PR_QueueDelete(), and PR_QueueFreeSpace().
static void PR_ProductionRollBottom_f | ( | void | ) | [static] |
moves the first production to the bottom of the list
Definition at line 406 of file cp_produce.c.
References B_GetCurrentSelectedBase(), ccs, base_s::idx, production_queue_s::numItems, PR_QueueMove(), and ccs_s::productions.
Referenced by PR_DisassemblingFrame(), and PR_ProductionFrame().
void PR_ProductionRun | ( | void | ) |
Checks whether an item is finished.
Definition at line 693 of file cp_produce.c.
References B_GetFoundedBaseByIDX(), ccs, i, production_queue_s::items, MAX_BASES, production_queue_s::numItems, PR_DisassemblingFrame(), PR_ProductionAllowed(), PR_ProductionFrame(), and ccs_s::productions.
Referenced by CL_CampaignRun().
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 295 of file cp_produce.c.
References production_s::aircraft, production_s::amount, storedUFO_s::disassembly, i, production_s::item, production_queue_s::items, production_queue_s::numItems, PR_ProductionQueueBase(), PR_UpdateRequiredItemsInBasestorage(), REMOVE_ELEM_ADJUST_IDX, technology_s::requireForProduction, RS_GetTechForItem(), aircraft_s::tech, production_s::ufo, and storedUFO_s::ufoTemplate.
Referenced by PR_DecreaseProduction(), PR_EmptyQueue(), PR_ProductionStop_f(), PR_QueueNext(), and US_RemoveStoredUFO().
int PR_QueueFreeSpace | ( | const production_queue_t const * | queue | ) |
returns the number of free production slots of a queue
[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.
[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.
[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. |
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.
[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.
[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 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().
qboolean PR_SaveXML | ( | mxml_node_t * | p | ) |
Save callback for savegames in XML Format.
[out] | p | XML Node structure, where we write the information to |
Definition at line 811 of file cp_produce.c.
References production_s::aircraft, production_s::amount, ccs, i, aircraft_s::id, objDef_s::id, storedUFO_s::idx, production_s::item, production_queue_s::items, mxml_AddFloatValue(), mxml_AddInt(), mxml_AddNode(), mxml_AddString(), ccs_s::numBases, production_queue_s::numItems, production_s::percentDone, ccs_s::productions, qtrue, SAVE_PRODUCE_AIRCRAFTID, SAVE_PRODUCE_AMOUNT, SAVE_PRODUCE_ITEM, SAVE_PRODUCE_ITEMID, SAVE_PRODUCE_PERCENTDONE, SAVE_PRODUCE_PRODUCTION, SAVE_PRODUCE_QUEUE, SAVE_PRODUCE_QUEUEIDX, SAVE_PRODUCE_UFOIDX, and production_s::ufo.
Referenced by SAV_Init().
void PR_UpdateProductionCap | ( | base_t * | base | ) |
Update the current capacity of Workshop.
[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.
[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().
cvar_t* mn_production_amount [static] |
Amount of the current production; if no production, an invalid value
Definition at line 45 of file cp_produce.c.
cvar_t* mn_production_limit [static] |
Maximum items in queue.
Definition at line 43 of file cp_produce.c.
cvar_t* mn_production_workers [static] |
Amount of hired workers in base.
Definition at line 44 of file cp_produce.c.
const int PRODUCE_DIVISOR = 1 |
Definition at line 37 of file cp_produce.c.
Referenced by PR_AircraftInfo(), PR_ItemProductionInfo(), and PR_ProductionFrame().
const int PRODUCE_FACTOR = 1 |
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().
const int PRODUCE_WORKERS = 10 [static] |
Default amount of workers, the produceTime for technologies is defined.
Definition at line 41 of file cp_produce.c.
Referenced by PR_CalculateProductionPercentDone().