UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_market.cpp
Go to the documentation of this file.
1
6
7/*
8Copyright (C) 2002-2025 UFO: Alien Invasion.
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19See the GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License
22along with this program; if not, write to the Free Software
23Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24*/
25
26#include "../../DateTime.h"
27#include "../../cl_shared.h"
28#include "cp_campaign.h"
29#include "cp_market.h"
30#include "cp_popup.h"
31#include "save/save_market.h"
32
33#define BID_FACTOR 0.9
34
35#define BS_GetMarket() (&ccs.eMarket)
36
42bool BS_IsOnMarket (const objDef_t* item)
43{
44 assert(item);
45 return !(item->isVirtual || item->notOnMarket);
46}
47
54{
55 const market_t* market = BS_GetMarket();
56 return BS_IsOnMarket(od) ? market->numItems[od->idx] : 0;
57}
58
64void BS_AddItemToMarket (const objDef_t* od, int amount)
65{
66 market_t* market = BS_GetMarket();
67 assert(amount >= 0);
68 market->numItems[od->idx] += amount;
69}
70
76static void BS_RemoveItemFromMarket (const objDef_t* od, int amount)
77{
78 market_t* market = BS_GetMarket();
79
80 assert(amount >= 0);
81
82 market->numItems[od->idx] = std::max(market->numItems[od->idx] - amount, 0);
83}
84
91{
92 const market_t* market = BS_GetMarket();
93 return market->bidItems[od->idx];
94}
95
102{
103 const market_t* market = BS_GetMarket();
104 return market->askItems[od->idx];
105}
106
112bool BS_AircraftIsOnMarket (const aircraft_t* aircraft)
113{
114 if (AIR_IsUFO(aircraft))
115 return false;
116 if (aircraft->price == -1)
117 return false;
118
119 return true;
120}
121
128{
129 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(aircraft->id);
130 const market_t* market = BS_GetMarket();
131
132 return BS_AircraftIsOnMarket(aircraft) ? market->numAircraft[type] : 0;
133}
134
140static void BS_AddAircraftToMarket (const aircraft_t* aircraft, int amount)
141{
142 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(aircraft->id);
143 market_t* market = BS_GetMarket();
144 assert(amount >= 0);
145 assert(!AIR_IsUFO(aircraft));
146 market->numAircraft[type] += amount;
147}
148
154static void BS_RemoveAircraftFromMarket (const aircraft_t* aircraft, int amount)
155{
156 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(aircraft->id);
157 market_t* market = BS_GetMarket();
158
159 assert(amount >= 0);
160 assert(!AIR_IsUFO(aircraft));
161
162 market->numAircraft[type] = std::max(market->numAircraft[type] - amount, 0);
163}
164
171{
172 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(aircraft->id);
173 const market_t* market = BS_GetMarket();
174 int sellPrice = market->bidAircraft[type];
175
176 assert(!AIR_IsUFO(aircraft));
177
178 if (aircraft->tpl != aircraft) {
179 int i;
180
181 if (aircraft->stats[AIR_STATS_DAMAGE] > 0)
182 sellPrice *= (float)aircraft->damage / aircraft->stats[AIR_STATS_DAMAGE];
183
184 if (aircraft->shield.item)
185 sellPrice += BS_GetItemSellingPrice(aircraft->shield.item);
186 if (aircraft->shield.ammo)
187 sellPrice += BS_GetItemSellingPrice(aircraft->shield.ammo);
188
189 for (i = 0; i < aircraft->maxWeapons; i++) {
190 if (aircraft->weapons[i].item)
191 sellPrice += BS_GetItemSellingPrice(aircraft->weapons[i].item);
192 if (aircraft->weapons[i].ammo)
193 sellPrice += BS_GetItemSellingPrice(aircraft->weapons[i].ammo);
194 }
195
196 for (i = 0; i < aircraft->maxElectronics; i++) {
197 if (aircraft->electronics[i].item)
198 sellPrice += BS_GetItemSellingPrice(aircraft->electronics[i].item);
199 if (aircraft->electronics[i].ammo)
200 sellPrice += BS_GetItemSellingPrice(aircraft->electronics[i].ammo);
201 }
202 }
203 return sellPrice;
204}
205
212{
213 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(aircraft->id);
214 const market_t* market = BS_GetMarket();
215 assert(!AIR_IsUFO(aircraft));
216 return market->askAircraft[type];
217}
218
223static void BS_ProcessCraftItemSale (const objDef_t* craftitem, const int numItems)
224{
225 if (craftitem) {
226 BS_AddItemToMarket(craftitem, numItems);
227 CP_UpdateCredits(ccs.credits + BS_GetItemSellingPrice(craftitem) * numItems);
228 }
229}
230
237bool BS_BuyAircraft (const aircraft_t* aircraftTemplate, base_t* base)
238{
239 if (!base)
240 cgi->Com_Error(ERR_DROP, "BS_BuyAircraft: No base given.");
241 if (!aircraftTemplate)
242 cgi->Com_Error(ERR_DROP, "BS_BuyAircraft: No aircraft template given.");
243
244 const int amount = BS_GetAircraftOnMarket(aircraftTemplate);
245 if (amount <= 0)
246 return false;
247
248 const int price = BS_GetAircraftBuyingPrice(aircraftTemplate);
249 if (ccs.credits < price)
250 return false;
251
252 /* Hangar capacities are being updated in AIR_NewAircraft().*/
253 BS_RemoveAircraftFromMarket(aircraftTemplate, 1);
254 CP_UpdateCredits(ccs.credits - price);
255 AIR_NewAircraft(base, aircraftTemplate);
256
257 return true;
258}
259
266{
267 int j;
268
269 if (AIR_GetTeamSize(aircraft) > 0)
270 return false;
271
272 if (!AIR_IsAircraftInBase(aircraft))
273 return false;
274
275 /* sell off any items which are mounted on it */
276 for (j = 0; j < aircraft->maxWeapons; j++) {
277 const aircraftSlot_t* slot = &aircraft->weapons[j];
280 }
281
282 BS_ProcessCraftItemSale(aircraft->shield.item, 1);
283 /* there should be no ammo here, but checking can't hurt */
284 BS_ProcessCraftItemSale(aircraft->shield.ammo, 1);
285
286 for (j = 0; j < aircraft->maxElectronics; j++) {
287 const aircraftSlot_t* slot = &aircraft->electronics[j];
289 /* there should be no ammo here, but checking can't hurt */
291 }
292
293 /* the capacities are also updated here */
294 BS_AddAircraftToMarket(aircraft, 1);
296 AIR_DeleteAircraft(aircraft);
297
298 return true;
299}
300
308bool BS_BuyUGV (const ugv_t* ugv, base_t* base)
309{
310 const objDef_t* ugvWeapon;
311
312 if (!ugv)
313 cgi->Com_Error(ERR_DROP, "BS_BuyUGV: Called on nullptr UGV!");
314 if (!base)
315 cgi->Com_Error(ERR_DROP, "BS_BuyUGV: Called on nullptr base!");
316 ugvWeapon = INVSH_GetItemByID(ugv->weapon);
317 if (!ugvWeapon)
318 cgi->Com_Error(ERR_DROP, "BS_BuyItem_f: Could not get weapon '%s' for ugv/tank '%s'.", ugv->weapon, ugv->id);
319
320 if (ccs.credits < ugv->price)
321 return false;
322 if (E_CountUnhiredRobotsByType(ugv) <= 0)
323 return false;
324 if (BS_GetItemOnMarket(ugvWeapon) <= 0)
325 return false;
326 if (CAP_GetFreeCapacity(base, CAP_ITEMS) < UGV_SIZE + ugvWeapon->size)
327 return false;
328 if (!E_HireRobot(base, ugv))
329 return false;
330
331 BS_RemoveItemFromMarket(ugvWeapon, 1);
332 CP_UpdateCredits(ccs.credits - ugv->price);
333 B_AddToStorage(base, ugvWeapon, 1);
334
335 return true;
336}
337
344bool BS_SellUGV (Employee* robot)
345{
346 const objDef_t* ugvWeapon;
347 const ugv_t* ugv;
348 base_t* base;
349
350 if (!robot)
351 cgi->Com_Error(ERR_DROP, "Selling nullptr UGV!");
352 if (!robot->getUGV())
353 cgi->Com_Error(ERR_DROP, "Selling invalid UGV with UCN: %i", robot->chr.ucn);
354 ugv = robot->getUGV();
355 base = robot->baseHired;
356
357 /* Check if we have a weapon for this ugv in the market to sell it. */
358 ugvWeapon = INVSH_GetItemByID(ugv->weapon);
359 if (!ugvWeapon)
360 cgi->Com_Error(ERR_DROP, "BS_BuyItem_f: Could not get wepaon '%s' for ugv/tank '%s'.", ugv->weapon, ugv->id);
361
362 if (!robot->unhire()) {
364 cgi->Com_DPrintf(DEBUG_CLIENT, "Couldn't sell/fire robot/ugv.\n");
365 return false;
366 }
367
368 BS_AddItemToMarket(ugvWeapon, 1);
369 CP_UpdateCredits(ccs.credits + ugv->price);
370 B_AddToStorage(base, ugvWeapon, -1);
371
372 return true;
373}
374
382bool BS_BuyItem (const objDef_t* od, base_t* base, int count)
383{
384 if (!od)
385 cgi->Com_Error(ERR_DROP, "BS_BuyItem: Called on nullptr objDef!");
386 if (!base)
387 cgi->Com_Error(ERR_DROP, "BS_BuyItem: Called on nullptr base!");
388
389 if (count <= 0)
390 return false;
391 if (!BS_IsOnMarket(od))
392 return false;
393 if (ccs.credits < BS_GetItemBuyingPrice(od) * count)
394 return false;
395 if (BS_GetItemOnMarket(od) < count)
396 return false;
397 if (CAP_GetFreeCapacity(base, CAP_ITEMS) < od->size * count)
398 return false;
399
400 B_AddToStorage(base, od, count);
403
404 return true;
405}
406
414bool BS_SellItem (const objDef_t* od, base_t* base, int count)
415{
416 if (!od)
417 cgi->Com_Error(ERR_DROP, "BS_SellItem: Called on nullptr objDef!");
418
419 if (count <= 0)
420 return false;
421 if (!BS_IsOnMarket(od))
422 return false;
423
424 if (base) {
425 if (B_ItemInBase(od, base) < count)
426 return false;
427 B_AddToStorage(base, od, -count);
428 }
429
432
433 return true;
434}
435
442bool BS_SaveXML (xmlNode_t* parent)
443{
444 int i;
445 xmlNode_t* node;
446 const market_t* market = BS_GetMarket();
447
448 /* store market */
449 node = cgi->XML_AddNode(parent, SAVE_MARKET_MARKET);
450 for (i = 0; i < cgi->csi->numODs; i++) {
451 const objDef_t* od = INVSH_GetItemByIDX(i);
452 if (BS_IsOnMarket(od)) {
453 xmlNode_t* snode = cgi->XML_AddNode(node, SAVE_MARKET_ITEM);
454 cgi->XML_AddString(snode, SAVE_MARKET_ID, od->id);
455 cgi->XML_AddIntValue(snode, SAVE_MARKET_NUM, market->numItems[i]);
456 cgi->XML_AddIntValue(snode, SAVE_MARKET_BID, market->bidItems[i]);
457 cgi->XML_AddIntValue(snode, SAVE_MARKET_ASK, market->askItems[i]);
458 cgi->XML_AddDoubleValue(snode, SAVE_MARKET_EVO, market->currentEvolutionItems[i]);
459 cgi->XML_AddBoolValue(snode, SAVE_MARKET_AUTOSELL, market->autosell[i]);
460 }
461 }
462 const int maxAircraft = cgi->Com_GetHumanAircraftIdsNum();
463 for (i = 0; i < maxAircraft; i++) {
464 if (market->bidAircraft[i] > 0 || market->askAircraft[i] > 0) {
465 xmlNode_t* snode = cgi->XML_AddNode(node, SAVE_MARKET_AIRCRAFT);
466 const char* shortName = cgi->Com_DropShipTypeToShortName((humanAircraftType_t)i);
467 cgi->XML_AddString(snode, SAVE_MARKET_ID, shortName);
468 cgi->XML_AddIntValue(snode, SAVE_MARKET_NUM, market->numAircraft[i]);
469 cgi->XML_AddIntValue(snode, SAVE_MARKET_BID, market->bidAircraft[i]);
470 cgi->XML_AddIntValue(snode, SAVE_MARKET_ASK, market->askAircraft[i]);
471 cgi->XML_AddDoubleValue(snode, SAVE_MARKET_EVO, market->currentEvolutionAircraft[i]);
472 }
473 }
474 return true;
475}
476
483bool BS_LoadXML (xmlNode_t* parent)
484{
485 xmlNode_t* node, *snode;
486 market_t* market = BS_GetMarket();
487
488 node = cgi->XML_GetNode(parent, SAVE_MARKET_MARKET);
489 if (!node)
490 return false;
491
492 for (snode = cgi->XML_GetNode(node, SAVE_MARKET_ITEM); snode; snode = cgi->XML_GetNextNode(snode, node, SAVE_MARKET_ITEM)) {
493 const char* s = cgi->XML_GetString(snode, SAVE_MARKET_ID);
494 const objDef_t* od = INVSH_GetItemByID(s);
495
496 if (!od) {
497 cgi->Com_Printf("BS_LoadXML: Could not find item '%s'\n", s);
498 continue;
499 }
500
501 market->numItems[od->idx] = cgi->XML_GetInt(snode, SAVE_MARKET_NUM, 0);
502 market->bidItems[od->idx] = cgi->XML_GetInt(snode, SAVE_MARKET_BID, 0);
503 market->askItems[od->idx] = cgi->XML_GetInt(snode, SAVE_MARKET_ASK, 0);
504 market->currentEvolutionItems[od->idx] = cgi->XML_GetDouble(snode, SAVE_MARKET_EVO, 0.0);
505 market->autosell[od->idx] = cgi->XML_GetBool(snode, SAVE_MARKET_AUTOSELL, false);
506 }
507 for (snode = cgi->XML_GetNode(node, SAVE_MARKET_AIRCRAFT); snode; snode = cgi->XML_GetNextNode(snode, node, SAVE_MARKET_AIRCRAFT)) {
508 const char* s = cgi->XML_GetString(snode, SAVE_MARKET_ID);
509 const humanAircraftType_t type = cgi->Com_DropShipShortNameToID(s);
510
511 market->numAircraft[type] = cgi->XML_GetInt(snode, SAVE_MARKET_NUM, 0);
512 market->bidAircraft[type] = cgi->XML_GetInt(snode, SAVE_MARKET_BID, 0);
513 market->askAircraft[type] = cgi->XML_GetInt(snode, SAVE_MARKET_ASK, 0);
514 market->currentEvolutionAircraft[type] = cgi->XML_GetDouble(snode, SAVE_MARKET_EVO, 0.0);
515 }
516
517 return true;
518}
519
526void BS_InitMarket (const campaign_t* campaign)
527{
528 int i;
529 market_t* market = BS_GetMarket();
530
531 for (i = 0; i < cgi->csi->numODs; i++) {
532 const objDef_t* od = INVSH_GetItemByIDX(i);
533 if (market->askItems[i] == 0) {
534 market->askItems[i] = od->price;
535 market->bidItems[i] = floor(market->askItems[i] * BID_FACTOR);
536 }
537
538 if (campaign->marketDef->numItems[i] <= 0)
539 continue;
540
542 /* the other relevant values were already set above */
543 market->numItems[i] = campaign->marketDef->numItems[i];
544 } else {
545 cgi->Com_Printf("BS_InitMarket: Could not add item %s to the market - not marked as researched in campaign %s\n",
546 od->id, campaign->id);
547 }
548 }
549
550 const int maxAircraft = cgi->Com_GetHumanAircraftIdsNum();
551 for (i = 0; i < maxAircraft; i++) {
552 const char* name = cgi->Com_DropShipTypeToShortName((humanAircraftType_t)i);
553 const aircraft_t* aircraft = AIR_GetAircraft(name);
554 if (market->askAircraft[i] == 0) {
555 market->askAircraft[i] = aircraft->price;
556 market->bidAircraft[i] = floor(market->askAircraft[i] * BID_FACTOR);
557 }
558
559 if (campaign->marketDef->numAircraft[i] <= 0)
560 continue;
561
562 if (RS_IsResearched_ptr(aircraft->tech)) {
563 /* the other relevant values were already set above */
564 market->numAircraft[i] = campaign->marketDef->numAircraft[i];
565 } else {
566 cgi->Com_Printf("BS_InitMarket: Could not add aircraft %s to the market - not marked as researched in campaign %s\n",
567 aircraft->id, campaign->id);
568 }
569 }
570}
571
580{
581 int i;
582 const float TYPICAL_TIME = 10.f;
583 const int RESEARCH_LIMIT_DELAY = 30;
585 market_t* market = BS_GetMarket();
586
587 assert(campaign->marketDef);
588 assert(campaign->asymptoticMarketDef);
589
590 for (i = 0; i < cgi->csi->numODs; i++) {
591 const objDef_t* od = INVSH_GetItemByIDX(i);
592 const technology_t* tech = RS_GetTechForItem(od);
593 int asymptoticNumber;
594
595 if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numItems[i] != 0 || ccs.date.getDateAsDays() > tech->researchedDate.getDateAsDays() + RESEARCH_LIMIT_DELAY)) {
596 /* if items are researched for more than RESEARCH_LIMIT_DELAY or was on the initial market,
597 * there number tend to the value defined in equipment.ufo.
598 * This value is the asymptotic value if it is not 0, or initial value else */
599 asymptoticNumber = campaign->asymptoticMarketDef->numItems[i] ? campaign->asymptoticMarketDef->numItems[i] : campaign->marketDef->numItems[i];
600 } else {
601 /* items that have just been researched don't appear on market, but they can disappear */
602 asymptoticNumber = 0;
603 }
604
605 /* Store the evolution of the market in currentEvolution */
606 market->currentEvolutionItems[i] += (asymptoticNumber - market->numItems[i]) / TYPICAL_TIME;
607
608 /* Check if new items appeared or disappeared on market */
609 if (fabs(market->currentEvolutionItems[i]) >= 1.0f) {
610 const int num = (int)(market->currentEvolutionItems[i]);
611 if (num >= 0)
612 BS_AddItemToMarket(od, num);
613 else
614 BS_RemoveItemFromMarket(od, -num);
615 market->currentEvolutionItems[i] -= num;
616 }
617 }
618
619 const int maxAircraft = cgi->Com_GetHumanAircraftIdsNum();
620 for (i = 0; i < maxAircraft; i++) {
622 const char* aircraftID = cgi->Com_DropShipTypeToShortName(type);
623 const aircraft_t* aircraft = AIR_GetAircraft(aircraftID);
624 const technology_t* tech = aircraft->tech;
625 int asymptoticNumber;
626
627 if (RS_IsResearched_ptr(tech) && (campaign->marketDef->numAircraft[i] != 0 || ccs.date.getDateAsDays() > tech->researchedDate.getDateAsDays() + RESEARCH_LIMIT_DELAY)) {
628 /* if aircraft is researched for more than RESEARCH_LIMIT_DELAY or was on the initial market,
629 * there number tend to the value defined in equipment.ufo.
630 * This value is the asymptotic value if it is not 0, or initial value else */
631 asymptoticNumber = campaign->asymptoticMarketDef->numAircraft[i] ? campaign->asymptoticMarketDef->numAircraft[i] : campaign->marketDef->numAircraft[i];
632 } else {
633 /* items that have just been researched don't appear on market, but they can disappear */
634 asymptoticNumber = 0;
635 }
636 /* Store the evolution of the market in currentEvolution */
637 market->currentEvolutionAircraft[i] += (asymptoticNumber - market->numAircraft[i]) / TYPICAL_TIME;
638
639 /* Check if new items appeared or disappeared on market */
640 if (fabs(market->currentEvolutionAircraft[i]) >= 1.0f) {
641 const int num = (int)(market->currentEvolutionAircraft[i]);
642 if (num >= 0)
643 BS_AddAircraftToMarket(aircraft, num);
644 else
645 BS_RemoveAircraftFromMarket(aircraft, -num);
646 market->currentEvolutionAircraft[i] -= num;
647 }
648 }
649}
650
656bool BS_BuySellAllowed (const base_t* base)
657{
658 return !B_IsUnderAttack(base) && B_GetBuildingStatus(base, B_STORAGE);
659}
DateTime class definition.
Share stuff between the different cgame implementations.
int getDateAsDays() const
Return the date part of the DateTime as days.
Definition DateTime.cpp:46
character_t chr
base_t * baseHired
const struct ugv_s * getUGV() const
bool unhire()
Fires an employee.
#define ERR_DROP
Definition common.h:211
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
aircraft_t * AIR_NewAircraft(base_t *base, const aircraft_t *aircraftTemplate)
Places a new aircraft in the given base.
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
#define AIR_IsUFO(aircraft)
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.
Definition cp_base.cpp:2133
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
Definition cp_base.cpp:2576
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Definition cp_base.cpp:478
#define B_IsUnderAttack(base)
Definition cp_base.h:53
@ B_STORAGE
Definition cp_building.h:55
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
ccs_t ccs
Header file for single player campaign control.
const cgame_import_t * cgi
int CAP_GetFreeCapacity(const base_t *base, baseCapacities_t capacityType)
Returns the free capacity of a type.
@ CAP_ITEMS
Definition cp_capacity.h:32
int E_CountUnhiredRobotsByType(const ugv_t *ugvType)
Counts all available Robots/UGVs that are for sale.
bool E_HireRobot(base_t *base, const ugv_t *ugvType)
Hires the first free employee of that type.
bool BS_LoadXML(xmlNode_t *parent)
Load callback for savegames.
static void BS_AddAircraftToMarket(const aircraft_t *aircraft, int amount)
Internal function to add aircraft to the market.
#define BS_GetMarket()
Definition cp_market.cpp:35
int BS_GetItemBuyingPrice(const objDef_t *od)
Get the price for an item that you want to buy on the market.
int BS_GetAircraftOnMarket(const aircraft_t *aircraft)
Get the number of aircraft of the given type on the market.
int BS_GetItemSellingPrice(const objDef_t *od)
Get the price for an item that you want to sell on the market.
Definition cp_market.cpp:90
bool BS_AircraftIsOnMarket(const aircraft_t *aircraft)
Checks whether a given aircraft should appear on the market.
static void BS_RemoveAircraftFromMarket(const aircraft_t *aircraft, int amount)
Internal function to remove aircraft from the market.
int BS_GetItemOnMarket(const objDef_t *od)
Get the number of items of the given type on the market.
Definition cp_market.cpp:53
int BS_GetAircraftSellingPrice(const aircraft_t *aircraft)
Get the price for an aircraft that you want to sell on the market.
bool BS_SellUGV(Employee *robot)
Sells the given UGV with all the equipment.
bool BS_BuyUGV(const ugv_t *ugv, base_t *base)
Buys the given UGV.
void BS_AddItemToMarket(const objDef_t *od, int amount)
Internal function to add items to the market.
Definition cp_market.cpp:64
static void BS_ProcessCraftItemSale(const objDef_t *craftitem, const int numItems)
Update storage, the market, and the player's credits.
#define BID_FACTOR
Definition cp_market.cpp:33
bool BS_SellAircraft(aircraft_t *aircraft)
Sells the given aircraft with all the equipment.
void BS_InitMarket(const campaign_t *campaign)
sets market prices at start of the game
int BS_GetAircraftBuyingPrice(const aircraft_t *aircraft)
Get the price for an aircraft that you want to buy on the market.
static void BS_RemoveItemFromMarket(const objDef_t *od, int amount)
Internal function to remove items from the market.
Definition cp_market.cpp:76
bool BS_SellItem(const objDef_t *od, base_t *base, int count)
Sells items from the market.
bool BS_SaveXML(xmlNode_t *parent)
Save callback for savegames.
bool BS_BuyItem(const objDef_t *od, base_t *base, int count)
Buys items from the market.
bool BS_IsOnMarket(const objDef_t *item)
Check if an item is on market.
Definition cp_market.cpp:42
void CP_CampaignRunMarket(campaign_t *campaign)
make number of items change every day.
bool BS_BuyAircraft(const aircraft_t *aircraftTemplate, base_t *base)
Buys an aircraft.
bool BS_BuySellAllowed(const base_t *base)
Returns true if you can buy or sell equipment.
Header for single player market stuff.
#define UGV_SIZE
Definition cp_produce.h:33
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 DEBUG_CLIENT
Definition defines.h:59
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
@ AIR_STATS_DAMAGE
Definition inv_shared.h:230
short humanAircraftType_t
Definition inv_shared.h:31
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
QGL_EXTERN GLuint count
Definition r_gl.h:99
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
XML tag constants for savegame.
#define SAVE_MARKET_ID
Definition save_market.h:30
#define SAVE_MARKET_ASK
Definition save_market.h:33
#define SAVE_MARKET_EVO
Definition save_market.h:34
#define SAVE_MARKET_ITEM
Definition save_market.h:28
#define SAVE_MARKET_NUM
Definition save_market.h:31
#define SAVE_MARKET_BID
Definition save_market.h:32
#define SAVE_MARKET_AIRCRAFT
Definition save_market.h:29
#define SAVE_MARKET_MARKET
Definition save_market.h:27
#define SAVE_MARKET_AUTOSELL
Definition save_market.h:35
An aircraft with all it's data.
aircraftSlot_t weapons[MAX_AIRCRAFTSLOT]
int maxElectronics
int stats[AIR_STATS_MAX]
aircraftSlot_t shield
struct aircraft_s * tpl
aircraftSlot_t electronics[MAX_AIRCRAFTSLOT]
struct technology_s * tech
slot of aircraft
Definition cp_aircraft.h:78
const objDef_t * item
Definition cp_aircraft.h:85
const objDef_t * ammo
Definition cp_aircraft.h:86
A base with all it's data.
Definition cp_base.h:84
const equipDef_t * asymptoticMarketDef
const equipDef_t * marketDef
char id[MAX_VAR]
int numItems[MAX_OBJDEFS]
Definition inv_shared.h:608
int numAircraft[AIRCRAFTTYPE_MAX]
Definition inv_shared.h:610
int numItems[MAX_OBJDEFS]
Definition cp_market.h:29
int bidAircraft[AIRCRAFTTYPE_MAX]
Definition cp_market.h:35
int numAircraft[AIRCRAFTTYPE_MAX]
Definition cp_market.h:34
int askAircraft[AIRCRAFTTYPE_MAX]
Definition cp_market.h:36
bool autosell[MAX_OBJDEFS]
Definition cp_market.h:33
int askItems[MAX_OBJDEFS]
Definition cp_market.h:31
double currentEvolutionAircraft[AIRCRAFTTYPE_MAX]
Definition cp_market.h:37
double currentEvolutionItems[MAX_OBJDEFS]
Definition cp_market.h:32
int bidItems[MAX_OBJDEFS]
Definition cp_market.h:30
Defines all attributes of objects used in the inventory.
Definition inv_shared.h:264
bool isVirtual
Definition inv_shared.h:284
bool notOnMarket
Definition inv_shared.h:336
const char * id
Definition inv_shared.h:268
This is the technology parsed from research.ufo.
class DateTime researchedDate
Defines a type of UGV/Robot.
Definition chr_shared.h:245
int price
Definition chr_shared.h:252
char weapon[MAX_VAR]
Definition chr_shared.h:248
char * id
Definition chr_shared.h:246
#define xmlNode_t
Definition xml.h:24