UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_produce.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23*/
24
25#pragma once
26
28#define MAX_PRODUCTIONS 40
30#define MAX_PRODUCTION_AMOUNT 500
31
33#define UGV_SIZE 300
34
42
46typedef struct {
48 const objDef_t* item;
49 const struct aircraft_s* aircraft;
50 struct storedUFO_s* ufo;
51 const void* pointer;
55
59typedef struct production_s
60{
61 int idx;
63
65 int frame;
66 signed int amount;
69
70#define PR_IsDisassemblyData(data) ((data)->type == PRODUCTION_TYPE_DISASSEMBLY)
71#define PR_IsAircraftData(data) ((data)->type == PRODUCTION_TYPE_AIRCRAFT)
72#define PR_IsItemData(data) ((data)->type == PRODUCTION_TYPE_ITEM)
73#define PR_IsProductionData(data) (!PR_IsDisassemblyData(data))
74
75#define PR_IsDisassembly(prod) (PR_IsDisassemblyData(&(prod)->data))
76#define PR_IsAircraft(prod) (PR_IsAircraftData(&(prod)->data))
77#define PR_IsItem(prod) (PR_IsItemData(&(prod)->data))
78#define PR_IsProduction(prod) (!PR_IsDisassembly(prod))
79
80#define PR_SetData(dataPtr, typeVal, ptr) do { assert(ptr); (dataPtr)->data.pointer = (ptr); (dataPtr)->type = (typeVal); } while (0);
81#define PR_IsDataValid(dataPtr) ((dataPtr)->data.pointer != nullptr)
82
83#define PR_GetProgress(prod) ((double)(prod)->frame / (prod)->totalFrames)
84#define PR_IsReady(prod) ((prod)->frame > (prod)->totalFrames)
85
90typedef struct production_queue_s
91{
93 struct production_s items[MAX_PRODUCTIONS];
95
96#define PR_GetProductionForBase(base) (&((base)->productions))
97
98int PR_GetPrice(const int productionCost);
99
101void PR_ProductionRun(void);
102
103bool PR_ItemIsProduceable(const objDef_t* item);
104
105struct base_s* PR_ProductionBase(const production_t* production);
106
107int PR_IncreaseProduction(production_t* prod, int amount);
108int PR_DecreaseProduction(production_t* prod, int amount);
109
110const char* PR_GetName(const productionData_t* data);
112
113void PR_UpdateProductionCap(struct base_s* base, int workerChange = 0);
114
115void PR_UpdateRequiredItemsInBasestorage(struct base_s* base, int amount, const requirements_t* reqs);
116int PR_RequirementsMet(int amount, const requirements_t* reqs, struct base_s* base);
117
118int PR_WorkersAvailable(const struct base_s* base);
119int PR_GetRemainingMinutes(const production_t* prod);
120int PR_GetRemainingHours(const production_t* prod);
121int PR_GetProductionHours(const struct base_s* base, const productionData_t* prodData);
122
123production_t* PR_QueueNew(struct base_s* base, const productionData_t* data, signed int amount);
124void PR_QueueMove(production_queue_t* queue, int index, int dir);
125void PR_QueueDelete(struct base_s* base, production_queue_t* queue, int index);
126void PR_QueueNext(struct base_s* base);
void PR_ProductionRun(void)
Checks whether an item is finished.
const char * PR_GetName(const productionData_t *data)
void PR_UpdateProductionCap(struct base_s *base, int workerChange=0)
int PR_GetPrice(const int productionCost)
Used in production costs (to allow reducing prices below 1x).
production_t * PR_QueueNew(struct base_s *base, const productionData_t *data, signed int amount)
int PR_DecreaseProduction(production_t *prod, int amount)
decreases production amount
productionType_t
Definition cp_produce.h:35
@ PRODUCTION_TYPE_MAX
Definition cp_produce.h:40
@ PRODUCTION_TYPE_DISASSEMBLY
Definition cp_produce.h:38
@ PRODUCTION_TYPE_ITEM
Definition cp_produce.h:36
@ PRODUCTION_TYPE_AIRCRAFT
Definition cp_produce.h:37
int PR_GetRemainingMinutes(const production_t *prod)
Calculates the remaining time for a technology in minutes.
int PR_IncreaseProduction(production_t *prod, int amount)
increases production amount if possible
void PR_UpdateRequiredItemsInBasestorage(struct base_s *base, int amount, const requirements_t *reqs)
int PR_RequirementsMet(int amount, const requirements_t *reqs, struct base_s *base)
int PR_GetRemainingHours(const production_t *prod)
Calculates the remaining hours for a technology.
struct base_s * PR_ProductionBase(const production_t *production)
Returns the base pointer the production belongs to.
void PR_QueueNext(struct base_s *base)
void PR_QueueDelete(struct base_s *base, production_queue_t *queue, int index)
void PR_ProductionInit(void)
int PR_GetProductionHours(const struct base_s *base, const productionData_t *prodData)
void PR_QueueMove(production_queue_t *queue, int index, int dir)
Moves the given queue item in the given direction.
technology_t * PR_GetTech(const productionData_t *data)
#define MAX_PRODUCTIONS
Maximum number of productions queued in any one base.
Definition cp_produce.h:28
bool PR_ItemIsProduceable(const objDef_t *item)
check if an item is producable.
int PR_WorkersAvailable(const struct base_s *base)
QGL_EXTERN GLsizei const GLvoid * data
Definition r_gl.h:89
QGL_EXTERN GLuint index
Definition r_gl.h:110
Defines all attributes of objects used in the inventory.
Definition inv_shared.h:264
A production queue. Lists all items to be produced.
Definition cp_produce.h:91
struct production_s items[MAX_PRODUCTIONS]
Definition cp_produce.h:93
Holds all information for the production of one item-type.
Definition cp_produce.h:60
signed int amount
Definition cp_produce.h:66
productionData_t data
Definition cp_produce.h:62
bool creditMessage
Definition cp_produce.h:67
productionType_t type
Definition cp_produce.h:53
This is the technology parsed from research.ufo.
const struct aircraft_s * aircraft
Definition cp_produce.h:49