Single player market stuff. More...
#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../cl_inventory.h"
#include "cp_campaign.h"
#include "cp_market.h"
#include "cp_market_callbacks.h"
#include "save/save_market.h"
Go to the source code of this file.
Functions | |
void | BS_AddItemToMarket (const objDef_t *od, int amount) |
void | BS_RemoveItemFromMarket (const objDef_t *od, int amount) |
void | BS_AddAircraftToMarket (const aircraft_t *aircraft, int amount) |
void | BS_RemoveAircraftFromMarket (const aircraft_t *aircraft, int amount) |
int | BS_GetAircraftOnMarket (const aircraft_t *aircraft) |
Get the number of aircraft of the given type on the market. | |
int | BS_GetAircraftSellingPrice (const aircraft_t *aircraft) |
Get the price for an aircraft that you want to sell on the market. | |
int | BS_GetAircraftBuyingPrice (const aircraft_t *aircraft) |
Get the price for an aircraft that you want to buy on the market. | |
int | BS_GetItemSellingPrice (const objDef_t *od) |
Get the price for an item that you want to sell on the market. | |
int | BS_GetItemBuyingPrice (const objDef_t *od) |
Get the price for an item that you want to buy on the market. | |
qboolean | BS_CheckAndDoBuyItem (base_t *base, const objDef_t *item, int number) |
Buy items. | |
void | BS_ProcessCraftItemSale (const objDef_t *craftitem, const int numItems) |
Update storage, the market, and the player's credits. | |
qboolean | BS_SaveXML (mxml_node_t *parent) |
Save callback for savegames. | |
qboolean | BS_LoadXML (mxml_node_t *parent) |
Load callback for savegames. | |
void | BS_InitMarket (void) |
sets market prices at start of the game | |
void | CL_CampaignRunMarket (void) |
make number of items change every day. | |
qboolean | BS_IsOnMarket (const objDef_t const *item) |
Check if an item is on market. | |
qboolean | BS_BuySellAllowed (const base_t *base) |
Returns true if you can buy or sell equipment. |
Single player market stuff.
Definition in file cp_market.c.
void BS_AddAircraftToMarket | ( | const aircraft_t * | aircraft, | |
int | amount | |||
) |
Definition at line 50 of file cp_market.c.
References AIRCRAFT_UFO, ccs, Com_DropShipShortNameToID(), ccs_s::eMarket, aircraft_s::id, market_s::numAircraft, aircraft_s::type, and type.
Referenced by BS_SellAircraft_f(), and CL_CampaignRunMarket().
void BS_AddItemToMarket | ( | const objDef_t * | od, | |
int | amount | |||
) |
Definition at line 36 of file cp_market.c.
References ccs, ccs_s::eMarket, objDef_s::idx, and market_s::numItems.
Referenced by B_SellOrAddItems(), BS_ProcessCraftItemSale(), BS_SellItem_f(), and CL_CampaignRunMarket().
Returns true if you can buy or sell equipment.
[in] | base | Pointer to base to check on |
Definition at line 408 of file cp_market.c.
References B_GetBuildingStatus(), B_STORAGE, BASE_UNDER_ATTACK, base_s::baseStatus, qfalse, and qtrue.
Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().
Buy items.
[in] | base | Pointer to the base where items are bought. |
[in] | item | Pointer to the item to buy. |
[in] | number | Number of items to buy. |
Definition at line 130 of file cp_market.c.
References _, B_UpdateStorageAndCapacity(), BS_GetItemBuyingPrice(), BS_RemoveItemFromMarket(), CAP_ITEMS, base_s::capacities, ccs, CL_UpdateCredits(), ccs_s::credits, cap_maxcur_s::cur, ccs_s::eMarket, objDef_s::idx, cap_maxcur_s::max, market_s::numItems, qfalse, qtrue, objDef_s::size, and UI_Popup().
Referenced by BS_BuyItem_f().
int BS_GetAircraftBuyingPrice | ( | const aircraft_t * | aircraft | ) |
Get the price for an aircraft that you want to buy on the market.
[in] | aircraft | The aircraft to buy |
Definition at line 97 of file cp_market.c.
References AIRCRAFT_UFO, market_s::askAircraft, ccs, Com_DropShipShortNameToID(), ccs_s::eMarket, aircraft_s::id, aircraft_s::type, and type.
Referenced by BS_BuyAircraft_f(), and BS_BuyType().
int BS_GetAircraftOnMarket | ( | const aircraft_t * | aircraft | ) |
Get the number of aircraft of the given type on the market.
[in] | aircraft | The aircraft to search the market for |
Definition at line 73 of file cp_market.c.
References AIRCRAFT_UFO, ccs, Com_DropShipShortNameToID(), ccs_s::eMarket, aircraft_s::id, market_s::numAircraft, aircraft_s::type, and type.
Referenced by BS_BuyType(), and BS_GetMinMaxValueByItemID().
int BS_GetAircraftSellingPrice | ( | const aircraft_t * | aircraft | ) |
Get the price for an aircraft that you want to sell on the market.
[in] | aircraft | The aircraft to sell |
Definition at line 85 of file cp_market.c.
References AIRCRAFT_UFO, market_s::bidAircraft, ccs, Com_DropShipShortNameToID(), ccs_s::eMarket, aircraft_s::id, aircraft_s::type, and type.
Referenced by BS_SellAircraft_f().
int BS_GetItemBuyingPrice | ( | const objDef_t * | od | ) |
Get the price for an item that you want to buy on the market.
[in] | od | The item to buy |
Definition at line 119 of file cp_market.c.
References market_s::askItems, ccs, ccs_s::eMarket, and objDef_s::idx.
Referenced by BS_BuyType(), and BS_CheckAndDoBuyItem().
int BS_GetItemSellingPrice | ( | const objDef_t * | od | ) |
Get the price for an item that you want to sell on the market.
[in] | od | The item to sell |
Definition at line 109 of file cp_market.c.
References market_s::bidItems, ccs, ccs_s::eMarket, and objDef_s::idx.
Referenced by BS_ProcessCraftItemSale(), and BS_SellItem_f().
void BS_InitMarket | ( | void | ) |
sets market prices at start of the game
[in] | load | Is this an attempt to init the market for a savegame? |
Definition at line 264 of file cp_market.c.
References AIR_GetAircraft(), AIRCRAFTTYPE_MAX, market_s::askAircraft, market_s::askItems, campaign_s::asymptoticMarket, campaign_s::asymptoticMarketDef, BID_FACTOR, market_s::bidAircraft, market_s::bidItems, ccs, Com_DropShipTypeToShortName(), Com_Printf(), csi, ccs_s::curCampaign, ccs_s::eMarket, i, aircraft_s::id, campaign_s::id, objDef_s::id, INV_GetEquipmentDefinitionByID(), INVSH_GetItemByIDX(), campaign_s::market, campaign_s::marketDef, name, market_s::numAircraft, equipDef_s::numAircraft, market_s::numItems, equipDef_s::numItems, csi_s::numODs, aircraft_s::price, objDef_s::price, RS_GetTechForItem(), RS_IsResearched_ptr(), and aircraft_s::tech.
Referenced by B_SetUpFirstBase(), and CP_CampaignInit().
Check if an item is on market.
[in] | item | Pointer to the item to check |
Definition at line 397 of file cp_market.c.
References objDef_s::isVirtual, and objDef_s::notOnMarket.
Referenced by BS_BuyType(), BS_SaveXML(), and CP_ItemsSanityCheck().
qboolean BS_LoadXML | ( | mxml_node_t * | parent | ) |
Load callback for savegames.
[in] | parent | XML Node structure, where we get the information from |
Definition at line 221 of file cp_market.c.
References market_s::askAircraft, market_s::askItems, market_s::autosell, market_s::bidAircraft, market_s::bidItems, ccs, Com_DropShipShortNameToID(), Com_Printf(), market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, ccs_s::eMarket, objDef_s::idx, INVSH_GetItemByID(), mxml_GetBool(), mxml_GetDouble(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), market_s::numAircraft, market_s::numItems, qfalse, qtrue, SAVE_MARKET_AIRCRAFT, SAVE_MARKET_ASK, SAVE_MARKET_AUTOSELL, SAVE_MARKET_BID, SAVE_MARKET_EVO, SAVE_MARKET_ID, SAVE_MARKET_ITEM, SAVE_MARKET_MARKET, SAVE_MARKET_NUM, and type.
Referenced by SAV_Init().
void BS_ProcessCraftItemSale | ( | const objDef_t * | craftitem, | |
const int | numItems | |||
) |
Update storage, the market, and the player's credits.
Definition at line 169 of file cp_market.c.
References BS_AddItemToMarket(), BS_GetItemSellingPrice(), ccs, CL_UpdateCredits(), and ccs_s::credits.
Referenced by BS_SellAircraft_f().
void BS_RemoveAircraftFromMarket | ( | const aircraft_t * | aircraft, | |
int | amount | |||
) |
Definition at line 58 of file cp_market.c.
References AIRCRAFT_UFO, ccs, Com_DropShipShortNameToID(), ccs_s::eMarket, aircraft_s::id, market_s::numAircraft, aircraft_s::type, and type.
Referenced by BS_BuyAircraft_f(), and CL_CampaignRunMarket().
void BS_RemoveItemFromMarket | ( | const objDef_t * | od, | |
int | amount | |||
) |
Definition at line 42 of file cp_market.c.
References ccs, ccs_s::eMarket, objDef_s::idx, and market_s::numItems.
Referenced by BS_BuyItem_f(), BS_CheckAndDoBuyItem(), and CL_CampaignRunMarket().
qboolean BS_SaveXML | ( | mxml_node_t * | parent | ) |
Save callback for savegames.
[out] | parent | XML Node structure, where we write the information to |
Definition at line 183 of file cp_market.c.
References AIRCRAFTTYPE_MAX, market_s::askAircraft, market_s::askItems, market_s::autosell, market_s::bidAircraft, market_s::bidItems, BS_IsOnMarket(), ccs, Com_DropShipTypeToShortName(), csi, market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, ccs_s::eMarket, i, objDef_s::id, INVSH_GetItemByIDX(), mxml_AddBoolValue(), mxml_AddDoubleValue(), mxml_AddIntValue(), mxml_AddNode(), mxml_AddString(), market_s::numAircraft, market_s::numItems, csi_s::numODs, qtrue, SAVE_MARKET_AIRCRAFT, SAVE_MARKET_ASK, SAVE_MARKET_AUTOSELL, SAVE_MARKET_BID, SAVE_MARKET_EVO, SAVE_MARKET_ID, SAVE_MARKET_ITEM, SAVE_MARKET_MARKET, and SAVE_MARKET_NUM.
Referenced by SAV_Init().
void CL_CampaignRunMarket | ( | void | ) |
make number of items change every day.
< Number of days to reach the asymptotic number of items
< Numbers of days after end of research to wait in order to have items added on market
Definition at line 321 of file cp_market.c.
References AIR_GetAircraft(), AIRCRAFTTYPE_MAX, campaign_s::asymptoticMarketDef, BS_AddAircraftToMarket(), BS_AddItemToMarket(), BS_RemoveAircraftFromMarket(), BS_RemoveItemFromMarket(), ccs, Com_DropShipTypeToShortName(), csi, ccs_s::curCampaign, market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, ccs_s::date, date_s::day, ccs_s::eMarket, i, int(), INVSH_GetItemByIDX(), campaign_s::marketDef, uiNode_s::num, market_s::numAircraft, equipDef_s::numAircraft, market_s::numItems, equipDef_s::numItems, csi_s::numODs, technology_s::researchedDate, RS_GetTechForItem(), RS_IsResearched_ptr(), aircraft_s::tech, and type.
Referenced by CL_CampaignRun().