|
UFO: Alien Invasion
|
Single player production stuff. More...
#include "../../DateTime.h"#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. | |
| int | PR_WorkersAvailable (const base_t *base) |
| Returns the numer of workers available to produce an item. | |
| 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 base_t *base, const productionData_t *prodData) |
| Calculates the production time (in hours) for a technology. | |
| void | PR_UpdateRequiredItemsInBasestorage (base_t *base, int amount, const requirements_t *reqs) |
| Remove or add the required items from/to the a base. | |
| int | PR_RequirementsMet (int amount, const requirements_t *reqs, base_t *base) |
| Checks if the production requirements are met for a defined amount. | |
| 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. | |
| 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 offset) |
| 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 (base_t *base) |
| moves the first production to the bottom of the list | |
| static bool | PR_CheckFrame (base_t *base, production_t *prod) |
| Checks whether production can continue. | |
| static void | PR_FinishProduction (base_t *base, production_t *prod) |
| Run actions on finishing production of one item/aircraft/UGV.. | |
| static void | PR_FinishDisassembly (base_t *base, production_t *prod) |
| Run actions on finishing 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. | |
| bool | PR_ProductionAllowed (const base_t *base) |
| Returns true if the current base is able to produce items. | |
| void | PR_UpdateProductionCap (base_t *base, int workerChange) |
| Update the current capacity of Workshop. | |
| bool | PR_ItemIsProduceable (const objDef_t *item) |
| check if an item is producable. | |
| base_t * | PR_ProductionBase (const production_t *production) |
| Returns the base pointer the production belongs to. | |
| int | PR_GetPrice (const int productionCost) |
| Used in production costs (to allow reducing prices below 1x). | |
| bool | PR_SaveXML (xmlNode_t *p) |
| Save callback for savegames in XML Format. | |
| bool | PR_LoadXML (xmlNode_t *p) |
| Load callback for xml savegames. | |
| static bool | PR_PostLoadInitProgress (void) |
| Set percentDone values after loading the campaign. | |
| bool | PR_PostLoadInit (void) |
| actions to do with productions after loading a savegame | |
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 40 of file cp_produce.cpp.
References ccs, storedUFO_t::comp, productionData_t::data, GetDistanceOnGlobe(), storedUFO_t::installation, DateTime::MINUTES_PER_HOUR, base_t::pos, installation_t::pos, PR_GetTech(), PR_IsProductionData, technology_t::produceTime, 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 388 of file cp_produce.cpp.
References _, productionData_t::productionItem_t::aircraft, ccs, Com_sprintf(), cp_messageBuffer, production_t::creditMessage, production_t::data, productionData_t::data, productionData_t::productionItem_t::item, MSO_CheckAddNewMessage(), base_t::name, NT_PRODUCTION_FAILED, PR_GetPrice(), PR_IsAircraft, PR_IsItem, PR_ProductionRollBottom(), aircraft_t::productionCost, and objDef_t::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 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().
clears the production queue on a base
Definition at line 360 of file cp_produce.cpp.
References production_queue_t::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 452 of file cp_produce.cpp.
References _, ANTIMATTER_ITEM_ID, B_AddAntimatter(), B_AddToStorage(), Com_sprintf(), storedUFO_t::comp, COMP_ITEMCOUNT_SCALED, storedUFO_t::condition, cp_messageBuffer, production_t::data, productionData_t::data, aircraft_t::getUfoType(), i, objDef_t::id, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_t::name, NT_PRODUCTION_FINISHED, Q_streq, RS_GetTechForItem(), RS_MarkCollected(), aircraft_t::tech, productionData_t::productionItem_t::ufo, UFO_TypeToName(), storedUFO_t::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 420 of file cp_produce.cpp.
References _, AIR_NewAircraft(), productionData_t::productionItem_t::aircraft, production_t::amount, B_AddToStorage(), ccs, Com_sprintf(), cp_messageBuffer, CP_UpdateCredits(), production_t::data, productionData_t::data, production_t::frame, productionData_t::productionItem_t::item, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_t::name, name, NT_PRODUCTION_FINISHED, PR_GetName(), PR_GetPrice(), PR_GetTech(), PR_IsAircraft, PR_IsItem, PR_QueueNext(), and objDef_t::productionCost.
Referenced by PR_ProductionRun().
| const char * PR_GetName | ( | const productionData_t * | data | ) |
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().
Used in production costs (to allow reducing prices below 1x).
| [in] | productionCost | production cost being modified |
Definition at line 667 of file cp_produce.cpp.
References ccs.
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 100 of file cp_produce.cpp.
References DateTime::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 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().
| 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 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().
| technology_t * PR_GetTech | ( | const productionData_t * | data | ) |
Definition at line 199 of file cp_produce.cpp.
References data, PRODUCTION_TYPE_AIRCRAFT, PRODUCTION_TYPE_DISASSEMBLY, PRODUCTION_TYPE_ITEM, and RS_GetTechForItem().
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 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().
| 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 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().
| 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 713 of file cp_produce.cpp.
References AIR_GetAircraft(), production_t::amount, B_GetBaseByIDX(), cgi, production_t::data, production_t::frame, production_t::idx, INVSH_GetItemByID(), production_queue_t::items, MAX_BASES, MAX_PRODUCTIONS, production_queue_t::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_t::totalFrames, US_GetStoredUFOByIDX(), and xmlNode_t.
Referenced by SAV_Init().
| bool PR_PostLoadInit | ( | void | ) |
actions to do with productions after loading a savegame
Definition at line 803 of file cp_produce.cpp.
References PR_PostLoadInitProgress().
Referenced by SAV_GameActionsAfterLoad().
|
static |
Set percentDone values after loading the campaign.
Definition at line 785 of file cp_produce.cpp.
References B_GetNext(), production_t::data, production_queue_t::items, production_queue_t::numItems, PR_CalculateTotalFrames(), PR_GetProductionForBase, and production_t::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 596 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(), TEST_F(), 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 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().
moves the first production to the bottom of the list
Definition at line 373 of file cp_produce.cpp.
References production_queue_t::numItems, PR_GetProductionForBase, and PR_QueueMove().
Referenced by PR_CheckFrame().
Checks whether an item is finished.
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().
| 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 281 of file cp_produce.cpp.
References production_t::amount, cgi, production_t::data, ERR_DROP, i, index, production_queue_t::items, production_queue_t::numItems, PR_GetTech(), PR_ResetUFODisassembly(), PR_SetUFODisassembly(), PR_UpdateRequiredItemsInBasestorage(), REMOVE_ELEM_ADJUST_IDX, and technology_t::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 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().
| 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 234 of file cp_produce.cpp.
References production_t::amount, data, production_t::data, production_t::idx, production_queue_t::items, MAX_PRODUCTIONS, production_queue_t::numItems, OBJZERO, PR_CalculateTotalFrames(), PR_GetProductionForBase, PR_GetTech(), PR_IsDisassemblyData, PR_RequirementsMet(), PR_SetUFODisassembly(), PR_UpdateRequiredItemsInBasestorage(), technology_t::produceTime, technology_t::requireForProduction, and production_t::totalFrames.
Referenced by PR_ProductionIncrease_f(), TEST_F(), TEST_F(), and TEST_F().
Queues the next production in the queue.
| [in] | base | Pointer to the base. |
Definition at line 345 of file cp_produce.cpp.
References _, Com_sprintf(), cp_messageBuffer, MSG_PRODUCTION, MSO_CheckAddNewMessage(), base_t::name, NT_PRODUCTION_QUEUE_EMPTY, production_queue_t::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 147 of file cp_produce.cpp.
References requirement_t::amount, B_AntimatterInBase(), B_ItemInBase(), i, requirement_t::link, requirements_t::links, requirements_t::numLinks, requirement_t::typelink_t::od, RS_IsResearched_ptr(), RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, requirement_t::typelink_t::tech, and requirement_t::type.
Referenced by PR_IncreaseProduction(), PR_ProductionIncrease_f(), and PR_QueueNew().
|
static |
Definition at line 213 of file cp_produce.cpp.
References production_t::data, productionData_t::data, 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 679 of file cp_produce.cpp.
References productionData_t::productionItem_t::aircraft, production_t::amount, B_GetNext(), cgi, production_t::data, productionData_t::data, production_t::frame, objDef_t::id, base_t::idx, productionData_t::productionItem_t::item, production_queue_t::items, production_queue_t::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, and xmlNode_t.
Referenced by SAV_Init().
|
static |
Definition at line 220 of file cp_produce.cpp.
References production_t::data, productionData_t::data, 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 607 of file cp_produce.cpp.
References CAP_Get, CAP_WORKSPACE, capacities_t::cur, production_t::data, E_CountHired(), EMPL_WORKER, production_t::frame, i, production_queue_t::items, capacities_t::max, production_queue_t::numItems, PR_CalculateTotalFrames(), PR_EmptyQueue(), PR_GetProductionForBase, PR_ProductionAllowed(), and production_t::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 111 of file cp_produce.cpp.
References requirement_t::amount, B_AddAntimatter(), B_AddToStorage(), cgi, ERR_DROP, i, requirement_t::link, requirements_t::links, requirements_t::numLinks, requirement_t::typelink_t::od, RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, and requirement_t::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 64 of file cp_produce.cpp.
References CAP_GetMax, CAP_WORKSPACE, E_CountHired(), and EMPL_WORKER.
Referenced by PR_GetProductionHours(), PR_GetRemainingMinutes(), PR_ProductionRun(), TEST_F(), TEST_F(), and TEST_F().