UFO: Alien Invasion
|
Single player production stuff. More...
#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_capacity.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 | |
static int | PR_CalculateTotalFrames (const base_t *base, const productionData_t *prodData) |
Calculates the total frame count (minutes) needed for producing an item for a single worker. More... | |
int | PR_WorkersAvailable (const base_t *base) |
Returns the numer of workers available to produce an item. More... | |
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 base_t *base, const productionData_t *prodData) |
Calculates the production time (in hours) for a technology. More... | |
void | PR_UpdateRequiredItemsInBasestorage (base_t *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, base_t *base) |
Checks if the production requirements are met for a defined amount. More... | |
const char * | PR_GetName (const productionData_t *data) |
technology_t * | PR_GetTech (const productionData_t *data) |
static void | PR_ResetUFODisassembly (production_t *prod) |
static void | PR_SetUFODisassembly (production_t *prod) |
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. More... | |
void | PR_QueueDelete (base_t *base, production_queue_t *queue, int index) |
Delete the selected entry from the queue. More... | |
void | PR_QueueMove (production_queue_t *queue, int index, int offset) |
Moves the given queue item in the given direction. More... | |
void | PR_QueueNext (base_t *base) |
Queues the next production in the queue. More... | |
static void | PR_EmptyQueue (base_t *base) |
clears the production queue on a base More... | |
static void | PR_ProductionRollBottom (base_t *base) |
moves the first production to the bottom of the list More... | |
static bool | PR_CheckFrame (base_t *base, production_t *prod) |
Checks whether production can continue. More... | |
static void | PR_FinishProduction (base_t *base, production_t *prod) |
Run actions on finishing production of one item/aircraft/UGV.. More... | |
static void | PR_FinishDisassembly (base_t *base, production_t *prod) |
Run actions on finishing disassembling of a ufo. 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... | |
void | PR_ProductionRun (void) |
Checks whether an item is finished. More... | |
bool | PR_ProductionAllowed (const base_t *base) |
Returns true if the current base is able to produce items. More... | |
void | PR_UpdateProductionCap (base_t *base, int workerChange) |
Update the current capacity of Workshop. More... | |
bool | PR_ItemIsProduceable (const objDef_t *item) |
check if an item is producable. More... | |
base_t * | PR_ProductionBase (const production_t *production) |
Returns the base pointer the production belongs to. More... | |
int | PR_GetPrice (const int productionCost) |
Used in production costs (to allow reducing prices below 1x). More... | |
bool | PR_SaveXML (xmlNode_t *p) |
Save callback for savegames in XML Format. More... | |
bool | PR_LoadXML (xmlNode_t *p) |
Load callback for xml savegames. More... | |
static bool | PR_PostLoadInitProgress (void) |
Set percentDone values after loading the campaign. More... | |
bool | PR_PostLoadInit (void) |
actions to do with productions after loading a savegame More... | |
Single player production stuff.
Definition in file cp_produce.cpp.
|
static |
Calculates the total frame count (minutes) needed for producing an item for a single worker.
[in] | base | Pointer to the base the production happen |
[in] | prodData | Pointer to the productionData structure |
Definition at line 39 of file cp_produce.cpp.
References ccs, storedUFO_s::comp, ccs_s::curCampaign, productionData_t::data, GetDistanceOnGlobe(), storedUFO_s::installation, MINUTES_PER_HOUR, installation_s::pos, base_s::pos, PR_GetTech(), PR_IsProductionData, campaign_s::produceRate, technology_s::produceTime, components_s::time, and productionData_t::productionItem_t::ufo.
Referenced by PR_GetProductionHours(), PR_LoadXML(), PR_PostLoadInitProgress(), PR_QueueNew(), and PR_UpdateProductionCap().
|
static |
Checks whether production can continue.
base | The base the production is running in |
prod | The production |
false
if production is stopped, true
if production can be continued. Definition at line 387 of file cp_produce.cpp.
References _, productionData_t::productionItem_t::aircraft, ccs, Com_sprintf(), cp_messageBuffer, production_s::creditMessage, ccs_s::credits, productionData_t::data, production_s::data, productionData_t::productionItem_t::item, MSO_CheckAddNewMessage(), base_s::name, NT_PRODUCTION_FAILED, PR_GetPrice(), PR_IsAircraft, PR_IsItem, PR_ProductionRollBottom(), aircraft_s::productionCost, and objDef_s::productionCost.
Referenced by PR_ProductionRun().
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().
clears the production queue on a base
Definition at line 359 of file cp_produce.cpp.
References production_queue_s::numItems, PR_GetProductionForBase, and PR_QueueDelete().
Referenced by PR_UpdateProductionCap().
|
static |
Run actions on finishing disassembling of a ufo.
base | The base to produce in |
prod | The production that is running |
Definition at line 451 of file cp_produce.cpp.
References _, ANTIMATTER_ITEM_ID, B_AddAntimatter(), B_AddToStorage(), Com_sprintf(), storedUFO_s::comp, COMP_ITEMCOUNT_SCALED, storedUFO_s::condition, cp_messageBuffer, productionData_t::data, production_s::data, aircraft_s::getUfoType(), i, objDef_s::id, components_s::itemAmount, components_s::itemAmount2, components_s::items, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_s::name, NT_PRODUCTION_FINISHED, components_s::numItemtypes, Q_streq, RS_GetTechForItem(), RS_MarkCollected(), aircraft_s::tech, productionData_t::productionItem_t::ufo, UFO_TypeToName(), storedUFO_s::ufoTemplate, and US_RemoveStoredUFO().
Referenced by PR_ProductionRun().
|
static |
Run actions on finishing production of one item/aircraft/UGV..
base | The base to produce in |
prod | The production that is running |
Definition at line 419 of file cp_produce.cpp.
References _, AIR_NewAircraft(), productionData_t::productionItem_t::aircraft, production_s::amount, B_AddToStorage(), ccs, Com_sprintf(), cp_messageBuffer, CP_UpdateCredits(), ccs_s::credits, productionData_t::data, production_s::data, production_s::frame, productionData_t::productionItem_t::item, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_s::name, name, NT_PRODUCTION_FINISHED, PR_GetName(), PR_GetPrice(), PR_GetTech(), PR_IsAircraft, PR_IsItem, PR_QueueNext(), aircraft_s::productionCost, and objDef_s::productionCost.
Referenced by PR_ProductionRun().
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 base_t * | base, |
const productionData_t * | prodData | ||
) |
Calculates the production time (in hours) for a technology.
[in] | base | Pointer to the base to calculate production time at |
[in] | prodData | Pointer to the production data structure |
Definition at line 99 of file cp_produce.cpp.
References MINUTES_PER_HOUR, PR_CalculateTotalFrames(), and PR_WorkersAvailable().
Referenced by PR_ProductionInfo().
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().
bool PR_LoadXML | ( | xmlNode_t * | p | ) |
Load callback for xml savegames.
[in] | p | XML Node structure, where we get the information from |
Definition at line 712 of file cp_produce.cpp.
References AIR_GetAircraft(), production_s::amount, B_GetBaseByIDX(), cgi, production_s::data, production_s::frame, production_s::idx, INVSH_GetItemByID(), production_queue_s::items, MAX_BASES, MAX_PRODUCTIONS, production_queue_s::numItems, PR_CalculateTotalFrames(), PR_GetProductionForBase, PR_IsDataValid, PR_SetData, PR_SetUFODisassembly(), PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, SAVE_PRODUCE_AIRCRAFTID, SAVE_PRODUCE_AMOUNT, SAVE_PRODUCE_ITEM, SAVE_PRODUCE_ITEMID, SAVE_PRODUCE_PRODUCTION, SAVE_PRODUCE_PROGRESS, SAVE_PRODUCE_QUEUE, SAVE_PRODUCE_QUEUEIDX, SAVE_PRODUCE_UFOIDX, production_s::totalFrames, US_GetStoredUFOByIDX(), cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetString(), and xmlNode_t.
Referenced by SAV_Init().
bool PR_PostLoadInit | ( | void | ) |
actions to do with productions after loading a savegame
Definition at line 802 of file cp_produce.cpp.
References PR_PostLoadInitProgress().
Referenced by SAV_GameActionsAfterLoad().
|
static |
Set percentDone values after loading the campaign.
Definition at line 784 of file cp_produce.cpp.
References B_GetNext(), production_s::data, production_queue_s::items, production_queue_s::numItems, PR_CalculateTotalFrames(), PR_GetProductionForBase, and production_s::totalFrames.
Referenced by PR_PostLoadInit().
bool PR_ProductionAllowed | ( | const base_t * | base | ) |
Returns true if the current base is able to produce items.
[in] | base | Pointer to the base. |
Definition at line 595 of file cp_produce.cpp.
References B_GetBuildingStatus(), B_IsUnderAttack, B_WORKSHOP, E_CountHired(), and EMPL_WORKER.
Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick_f(), PR_ProductionRun(), PR_ShowActiveProduction_f(), PR_UpdateProductionCap(), TEST_F(), and TR_TransferStart().
base_t* 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().
moves the first production to the bottom of the list
Definition at line 372 of file cp_produce.cpp.
References production_queue_s::numItems, PR_GetProductionForBase, and PR_QueueMove().
Referenced by PR_CheckFrame().
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().
|
static |
Definition at line 212 of file cp_produce.cpp.
References productionData_t::data, production_s::data, storedUFO_s::disassembly, PR_IsDisassembly, and productionData_t::productionItem_t::ufo.
Referenced by PR_QueueDelete().
bool PR_SaveXML | ( | xmlNode_t * | p | ) |
Save callback for savegames in XML Format.
[out] | p | XML Node structure, where we write the information to |
Definition at line 678 of file cp_produce.cpp.
References productionData_t::productionItem_t::aircraft, production_s::amount, B_GetNext(), cgi, productionData_t::data, production_s::data, production_s::frame, aircraft_s::id, objDef_s::id, storedUFO_s::idx, base_s::idx, productionData_t::productionItem_t::item, production_queue_s::items, production_queue_s::numItems, PR_GetProductionForBase, PR_IsAircraft, PR_IsDisassembly, PR_IsItem, SAVE_PRODUCE_AIRCRAFTID, SAVE_PRODUCE_AMOUNT, SAVE_PRODUCE_ITEM, SAVE_PRODUCE_ITEMID, SAVE_PRODUCE_PRODUCTION, SAVE_PRODUCE_PROGRESS, SAVE_PRODUCE_QUEUE, SAVE_PRODUCE_QUEUEIDX, SAVE_PRODUCE_UFOIDX, productionData_t::productionItem_t::ufo, cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by SAV_Init().
|
static |
Definition at line 219 of file cp_produce.cpp.
References productionData_t::data, production_s::data, storedUFO_s::disassembly, PR_IsDisassembly, and productionData_t::productionItem_t::ufo.
Referenced by PR_LoadXML(), PR_QueueDelete(), PR_QueueMove(), 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().
Returns the numer of workers available to produce an item.
[in] | base | Pointer to the base the production happen |
Definition at line 63 of file cp_produce.cpp.
References CAP_GetMax, CAP_WORKSPACE, E_CountHired(), and EMPL_WORKER.
Referenced by PR_GetProductionHours(), PR_GetRemainingMinutes(), PR_ProductionRun(), and TEST_F().