cp_market.h File Reference

Header for single player market stuff. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  market_s

Typedefs

typedef struct market_s market_t

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_IsOnMarket (const objDef_t const *item)
 Check if an item is on market.
void BS_InitMarket (void)
 sets market prices at start of the game
void CL_CampaignRunMarket (void)
 make number of items change every day.

Detailed Description

Header for single player market stuff.

Definition in file cp_market.h.


Typedef Documentation

typedef struct market_s market_t

market structure


Function Documentation

void BS_AddAircraftToMarket ( const aircraft_t aircraft,
int  amount 
)
void BS_AddItemToMarket ( const objDef_t od,
int  amount 
)
qboolean BS_CheckAndDoBuyItem ( base_t base,
const objDef_t item,
int  number 
)

Buy items.

Parameters:
[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.

Todo:
Handle items with price 0 better
Todo:
Handle items with size 0 better

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.

Parameters:
[in] aircraft The aircraft to buy
Returns:
The price of the aircraft

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.

Parameters:
[in] aircraft The aircraft to search the market for
Returns:
The amount of aircraft for the given type

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.

Parameters:
[in] aircraft The aircraft to sell
Returns:
The price of the aircraft

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.

Parameters:
[in] od The item to buy
Returns:
The price of the item

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.

Parameters:
[in] od The item to sell
Returns:
The price of the item

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   ) 
qboolean BS_IsOnMarket ( const objDef_t const *  item  ) 

Check if an item is on market.

Parameters:
[in] item Pointer to the item to check
Note:
this function doesn't check if the item is available on market (buyable > 0)

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().

void BS_ProcessCraftItemSale ( const objDef_t craftitem,
const int  numItems 
)

Update storage, the market, and the player's credits.

Note:
Don't update capacity here because we can sell items directly from aircraft (already removed from storage).

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 
)
void BS_RemoveItemFromMarket ( const objDef_t od,
int  amount 
)
void CL_CampaignRunMarket ( void   ) 

make number of items change every day.

See also:
CL_CampaignRun
daily called
Note:
This function makes items number on market slowly reach the asymptotic number of items defined in equipment.ufo If an item has just been researched, it's not available on market until RESEARCH_LIMIT_DELAY days is reached.

< 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().


Generated by  doxygen 1.6.2