48 time = storedUFO->
comp->time;
57 return std::max(1.0, time) + 1;
135 cgi->Com_Error(
ERR_DROP,
"Invalid requirement for production!\n");
149 int producibleAmount = amount;
157 producibleAmount = std::min(producibleAmount, items);
162 producibleAmount = std::min(producibleAmount, am);
176 return producibleAmount;
184 switch (
data->type) {
186 return _(
data->data.item->name);
188 return _(
data->data.aircraft->tpl->name);
192 cgi->Com_Error(
ERR_DROP,
"Invalid production type given: %i",
data->type);
201 switch (
data->type) {
205 return data->data.aircraft->tech;
207 return data->data.ufo->ufoTemplate->tech;
286 cgi->Com_Error(
ERR_DROP,
"No tech pointer for production");
312 if (newIndex ==
index)
318 for (
int i =
index;
i < newIndex;
i++) {
327 for (
int i =
index;
i > newIndex;
i--) {
336 queue->
items[newIndex] = saved;
337 queue->
items[newIndex].idx = newIndex;
401 if (price > 0 && price >
ccs.credits) {
457 for (
int i = 0;
i < ufo->
comp->numItemtypes;
i++) {
532 if (prod->
amount <= amount) {
541 cgi->Com_Error(
ERR_DROP,
"No tech pointer for production");
562 while ((base =
B_GetNext(base)) !=
nullptr) {
612 if (workspaceCapacity->
max <= 0)
616 if (workspaceCapacity->
max >= workers)
617 workspaceCapacity->
cur = workers;
619 workspaceCapacity->
cur = workspaceCapacity->
max;
654 while ((base =
B_GetNext(base)) !=
nullptr) {
670 price = productionCost *
ccs.curCampaign->componentRate;
684 while ((base =
B_GetNext(base)) !=
nullptr) {
691 for (
int j = 0; j < pq->
numItems; j++) {
724 if (base ==
nullptr) {
725 cgi->Com_Printf(
"Invalid production queue index %i\n", baseIDX);
742 cgi->Com_Printf(
"PR_LoadXML: Production with amount <= 0 dropped (baseidx=%i, production idx=%i).\n",
755 cgi->Com_Printf(
"PR_LoadXML: Could not find ufo idx: %i\n", ufoIDX);
768 cgi->Com_Printf(
"PR_LoadXML: Production is not an item an aircraft nor a disassembly\n");
788 while ((base =
B_GetNext(base)) !=
nullptr) {
790 for (
int j = 0; j < pq->
numItems; j++) {
DateTime class definition.
Share stuff between the different cgame implementations.
static const short MINUTES_PER_HOUR
#define REMOVE_ELEM_ADJUST_IDX(array, index, n)
aircraft_t * AIR_NewAircraft(base_t *base, const aircraft_t *aircraftTemplate)
Places a new aircraft in the given base.
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
base_t * B_GetBaseByIDX(int baseIdx)
Array bound check for the base index. Will also return unfounded bases as long as the index is in the...
int B_AntimatterInBase(const base_t *base)
returns the amount of antimatter stored in a base
int B_ItemInBase(const objDef_t *item, const base_t *base)
Check if the item has been collected (i.e it is in the storage) in the given base.
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
#define B_IsUnderAttack(base)
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
Header file for single player campaign control.
const cgame_import_t * cgi
#define CAP_GetMax(base, capacity)
#define CAP_Get(base, capacity)
Capacity macros.
#define COMP_ITEMCOUNT_SCALED
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
uiMessageListNodeMessage_t * MSO_CheckAddNewMessage(const notify_t messagecategory, const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup)
Adds a new message to message stack. It uses message settings to verify whether sound should be playe...
@ NT_PRODUCTION_QUEUE_EMPTY
char cp_messageBuffer[MAX_MESSAGE_TEXT]
void PR_UpdateRequiredItemsInBasestorage(base_t *base, int amount, const requirements_t *reqs)
Remove or add the required items from/to the a base.
void PR_ProductionRun(void)
Checks whether an item is finished.
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.
void PR_QueueDelete(base_t *base, production_queue_t *queue, int index)
Delete the selected entry from the queue.
const char * PR_GetName(const productionData_t *data)
int PR_GetPrice(const int productionCost)
Used in production costs (to allow reducing prices below 1x).
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.
int PR_DecreaseProduction(production_t *prod, int amount)
decreases production amount
bool PR_LoadXML(xmlNode_t *p)
Load callback for xml savegames.
bool PR_ProductionAllowed(const base_t *base)
Returns true if the current base is able to produce items.
int PR_GetRemainingMinutes(const production_t *prod)
Calculates the remaining time for a technology in minutes.
static void PR_ResetUFODisassembly(production_t *prod)
int PR_IncreaseProduction(production_t *prod, int amount)
increases production amount if possible
static bool PR_PostLoadInitProgress(void)
Set percentDone values after loading the campaign.
static void PR_FinishProduction(base_t *base, production_t *prod)
Run actions on finishing production of one item/aircraft/UGV..
bool PR_SaveXML(xmlNode_t *p)
Save callback for savegames in XML Format.
int PR_RequirementsMet(int amount, const requirements_t *reqs, base_t *base)
Checks if the production requirements are met for a defined amount.
static void PR_FinishDisassembly(base_t *base, production_t *prod)
Run actions on finishing disassembling of a ufo.
int PR_GetRemainingHours(const production_t *prod)
Calculates the remaining hours for a technology.
static void PR_SetUFODisassembly(production_t *prod)
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
int PR_GetProductionHours(const base_t *base, const productionData_t *prodData)
Calculates the production time (in hours) for a technology.
static void PR_ProductionRollBottom(base_t *base)
moves the first production to the bottom of the list
base_t * PR_ProductionBase(const production_t *production)
Returns the base pointer the production belongs to.
void PR_QueueMove(production_queue_t *queue, int index, int offset)
Moves the given queue item in the given direction.
static bool PR_CheckFrame(base_t *base, production_t *prod)
Checks whether production can continue.
technology_t * PR_GetTech(const productionData_t *data)
static void PR_EmptyQueue(base_t *base)
clears the production queue on a base
bool PR_ItemIsProduceable(const objDef_t *item)
check if an item is producable.
void PR_QueueNext(base_t *base)
Queues the next production in the queue.
bool PR_PostLoadInit(void)
actions to do with productions after loading a savegame
Header for production related stuff.
#define PR_IsProduction(prod)
#define PR_IsDataValid(dataPtr)
@ PRODUCTION_TYPE_DISASSEMBLY
@ PRODUCTION_TYPE_AIRCRAFT
#define PR_IsProductionData(data)
#define PR_IsAircraft(prod)
#define MAX_PRODUCTION_AMOUNT
#define PR_IsDisassemblyData(data)
#define PR_SetData(dataPtr, typeVal, ptr)
#define PR_GetProductionForBase(base)
#define MAX_PRODUCTIONS
Maximum number of productions queued in any one base.
#define PR_IsDisassembly(prod)
Header file for menu related console command callbacks for production menu.
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
#define ANTIMATTER_ITEM_ID
const char * UFO_TypeToName(const ufoType_t type)
Translate UFO type to name.
storedUFO_t * US_GetStoredUFOByIDX(const int idx)
Returns a stored ufo.
void US_RemoveStoredUFO(storedUFO_t *ufo)
Removes an UFO from the storage.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
QGL_EXTERN GLsizei const GLvoid * data
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
#define SAVE_PRODUCE_QUEUEIDX
#define SAVE_PRODUCE_AIRCRAFTID
#define SAVE_PRODUCE_ITEM
#define SAVE_PRODUCE_ITEMID
#define SAVE_PRODUCE_QUEUE
#define SAVE_PRODUCE_AMOUNT
#define SAVE_PRODUCE_PROGRESS
#define SAVE_PRODUCE_UFOIDX
#define SAVE_PRODUCE_PRODUCTION
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
An aircraft with all it's data.
ufoType_t getUfoType() const
struct technology_s * tech
A base with all it's data.
Store capacities in base.
Defines all attributes of objects used in the inventory.
A production queue. Lists all items to be produced.
struct production_s items[MAX_PRODUCTIONS]
Holds all information for the production of one item-type.
union productionData_t::productionItem_t data
union requirement_t::typelink_t link
requirement_t links[MAX_TECHLINKS]
Structure for stored UFOs.
struct components_s * comp
const aircraft_t * ufoTemplate
installation_t * installation
This is the technology parsed from research.ufo.
requirements_t requireForProduction
const struct aircraft_s * aircraft
const struct objDef_s * od
const struct technology_s * tech