UFO: Alien Invasion
|
Single player market stuff. More...
#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_market.h"
#include "cp_popup.h"
#include "save/save_market.h"
Go to the source code of this file.
Macros | |
#define | BID_FACTOR 0.9 |
#define | BS_GetMarket() (&ccs.eMarket) |
Functions | |
bool | BS_IsOnMarket (const objDef_t *item) |
Check if an item is on market. More... | |
int | BS_GetItemOnMarket (const objDef_t *od) |
Get the number of items of the given type on the market. More... | |
void | BS_AddItemToMarket (const objDef_t *od, int amount) |
Internal function to add items to the market. More... | |
static void | BS_RemoveItemFromMarket (const objDef_t *od, int amount) |
Internal function to remove items from the market. More... | |
int | BS_GetItemSellingPrice (const objDef_t *od) |
Get the price for an item that you want to sell on the market. More... | |
int | BS_GetItemBuyingPrice (const objDef_t *od) |
Get the price for an item that you want to buy on the market. More... | |
bool | BS_AircraftIsOnMarket (const aircraft_t *aircraft) |
Checks whether a given aircraft should appear on the market. More... | |
int | BS_GetAircraftOnMarket (const aircraft_t *aircraft) |
Get the number of aircraft of the given type on the market. More... | |
static void | BS_AddAircraftToMarket (const aircraft_t *aircraft, int amount) |
Internal function to add aircraft to the market. More... | |
static void | BS_RemoveAircraftFromMarket (const aircraft_t *aircraft, int amount) |
Internal function to remove aircraft from the market. More... | |
int | BS_GetAircraftSellingPrice (const aircraft_t *aircraft) |
Get the price for an aircraft that you want to sell on the market. More... | |
int | BS_GetAircraftBuyingPrice (const aircraft_t *aircraft) |
Get the price for an aircraft that you want to buy on the market. More... | |
static void | BS_ProcessCraftItemSale (const objDef_t *craftitem, const int numItems) |
Update storage, the market, and the player's credits. More... | |
bool | BS_BuyAircraft (const aircraft_t *aircraftTemplate, base_t *base) |
Buys an aircraft. More... | |
bool | BS_SellAircraft (aircraft_t *aircraft) |
Sells the given aircraft with all the equipment. More... | |
bool | BS_BuyUGV (const ugv_t *ugv, base_t *base) |
Buys the given UGV. More... | |
bool | BS_SellUGV (Employee *robot) |
Sells the given UGV with all the equipment. More... | |
bool | BS_BuyItem (const objDef_t *od, base_t *base, int count) |
Buys items from the market. More... | |
bool | BS_SellItem (const objDef_t *od, base_t *base, int count) |
Sells items from the market. More... | |
bool | BS_SaveXML (xmlNode_t *parent) |
Save callback for savegames. More... | |
bool | BS_LoadXML (xmlNode_t *parent) |
Load callback for savegames. More... | |
void | BS_InitMarket (const campaign_t *campaign) |
sets market prices at start of the game More... | |
void | CP_CampaignRunMarket (campaign_t *campaign) |
make number of items change every day. More... | |
bool | BS_BuySellAllowed (const base_t *base) |
Returns true if you can buy or sell equipment. More... | |
#define BID_FACTOR 0.9 |
Definition at line 32 of file cp_market.cpp.
Referenced by BS_InitMarket().
#define BS_GetMarket | ( | ) | (&ccs.eMarket) |
Definition at line 34 of file cp_market.cpp.
Referenced by BS_AddAircraftToMarket(), BS_AddItemToMarket(), BS_GetAircraftBuyingPrice(), BS_GetAircraftOnMarket(), BS_GetAircraftSellingPrice(), BS_GetItemBuyingPrice(), BS_GetItemOnMarket(), BS_GetItemSellingPrice(), BS_InitMarket(), BS_LoadXML(), BS_RemoveAircraftFromMarket(), BS_RemoveItemFromMarket(), BS_SaveXML(), and CP_CampaignRunMarket().
|
static |
Internal function to add aircraft to the market.
[in] | aircraft | Aircraft template definition |
[in] | amount | Non-negative number of aircraft to add |
Definition at line 139 of file cp_market.cpp.
References AIR_IsUFO, BS_GetMarket, cgi, aircraft_s::id, market_s::numAircraft, and type.
Referenced by BS_SellAircraft(), and CP_CampaignRunMarket().
Internal function to add items to the market.
[in] | od | Object definition (the item itself) |
[in] | amount | Non-negative number of items to add |
Definition at line 63 of file cp_market.cpp.
References BS_GetMarket, objDef_s::idx, and market_s::numItems.
Referenced by BS_ProcessCraftItemSale(), BS_SellItem(), BS_SellUGV(), and CP_CampaignRunMarket().
bool BS_AircraftIsOnMarket | ( | const aircraft_t * | aircraft | ) |
Checks whether a given aircraft should appear on the market.
aircraft | The aircraft to check |
true
if the aircraft should appear on the market Definition at line 111 of file cp_market.cpp.
References AIR_IsUFO, and aircraft_s::price.
Referenced by BS_FillMarket_f(), and BS_GetAircraftOnMarket().
bool BS_BuyAircraft | ( | const aircraft_t * | aircraftTemplate, |
base_t * | base | ||
) |
Buys an aircraft.
[in] | aircraftTemplate | The aircraft template to buy |
[out] | base | Base to buy at |
true
if the aircraft could get bought, false
otherwise Definition at line 236 of file cp_market.cpp.
References AIR_NewAircraft(), BS_GetAircraftBuyingPrice(), BS_GetAircraftOnMarket(), BS_RemoveAircraftFromMarket(), ccs, cgi, CP_UpdateCredits(), ccs_s::credits, and ERR_DROP.
Referenced by BS_Buy_f().
Buys items from the market.
[in] | od | pointer to the item (Object Definition record) |
[out] | base | Base to buy at |
[in] | count | Number of items to buy |
true
if the ugv could get bought, false
otherwise Definition at line 381 of file cp_market.cpp.
References B_AddToStorage(), BS_GetItemBuyingPrice(), BS_GetItemOnMarket(), BS_IsOnMarket(), BS_RemoveItemFromMarket(), CAP_GetFreeCapacity(), CAP_ITEMS, ccs, cgi, CP_UpdateCredits(), ccs_s::credits, ERR_DROP, and objDef_s::size.
Referenced by BS_Buy_f().
bool BS_BuySellAllowed | ( | const base_t * | base | ) |
Returns true if you can buy or sell equipment.
[in] | base | Pointer to base to check on |
Definition at line 655 of file cp_market.cpp.
References B_GetBuildingStatus(), B_IsUnderAttack, and B_STORAGE.
Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().
Buys the given UGV.
[in] | ugv | The ugv template of the UGV to buy |
[out] | base | Base to buy at |
true
if the ugv could get bought, false
otherwise Definition at line 307 of file cp_market.cpp.
References B_AddToStorage(), BS_GetItemOnMarket(), BS_RemoveItemFromMarket(), CAP_GetFreeCapacity(), CAP_ITEMS, ccs, cgi, CP_UpdateCredits(), ccs_s::credits, E_CountUnhiredRobotsByType(), E_HireRobot(), ERR_DROP, ugv_s::id, INVSH_GetItemByID(), ugv_s::price, objDef_s::size, UGV_SIZE, and ugv_s::weapon.
Referenced by BS_Buy_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 210 of file cp_market.cpp.
References AIR_IsUFO, market_s::askAircraft, BS_GetMarket, cgi, aircraft_s::id, and type.
Referenced by BS_Buy_f(), BS_BuyAircraft(), and BS_FillMarket_f().
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 126 of file cp_market.cpp.
References BS_AircraftIsOnMarket(), BS_GetMarket, cgi, aircraft_s::id, market_s::numAircraft, and type.
Referenced by BS_BuyAircraft(), and BS_FillMarket_f().
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 169 of file cp_market.cpp.
References AIR_IsUFO, AIR_STATS_DAMAGE, aircraftSlot_s::ammo, market_s::bidAircraft, BS_GetItemSellingPrice(), BS_GetMarket, cgi, aircraft_s::damage, aircraft_s::electronics, i, aircraft_s::id, aircraftSlot_s::item, aircraft_s::maxElectronics, aircraft_s::maxWeapons, aircraft_s::shield, aircraft_s::stats, aircraft_s::tpl, type, and aircraft_s::weapons.
Referenced by BS_FillMarket_f(), and BS_SellAircraft().
Get the price for an item that you want to buy on the market.
[in] | od | The item to buy |
Definition at line 100 of file cp_market.cpp.
References market_s::askItems, BS_GetMarket, and objDef_s::idx.
Referenced by BS_Buy_f(), BS_BuyItem(), and BS_FillMarket_f().
Get the number of items of the given type on the market.
[in] | od | the item (objDef) to search the market for |
Definition at line 52 of file cp_market.cpp.
References BS_GetMarket, BS_IsOnMarket(), objDef_s::idx, and market_s::numItems.
Referenced by BS_Buy_f(), BS_BuyItem(), BS_BuyUGV(), and BS_FillMarket_f().
Get the price for an item that you want to sell on the market.
[in] | od | The item to sell |
Definition at line 89 of file cp_market.cpp.
References market_s::bidItems, BS_GetMarket, and objDef_s::idx.
Referenced by B_SellOrAddItems(), BS_FillMarket_f(), BS_GetAircraftSellingPrice(), BS_ProcessCraftItemSale(), and BS_SellItem().
void BS_InitMarket | ( | const campaign_t * | campaign | ) |
sets market prices at start of the game
Definition at line 525 of file cp_market.cpp.
References AIR_GetAircraft(), market_s::askAircraft, market_s::askItems, BID_FACTOR, market_s::bidAircraft, market_s::bidItems, BS_GetMarket, cgi, cgame_import_s::Com_DropShipTypeToShortName(), cgame_import_s::csi, i, aircraft_s::id, campaign_s::id, objDef_s::id, INVSH_GetItemByIDX(), 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 CP_CampaignInit(), and TEST_F().
bool BS_IsOnMarket | ( | const objDef_t * | item | ) |
Check if an item is on market.
[in] | item | Pointer to the item to check |
Definition at line 41 of file cp_market.cpp.
References objDef_s::isVirtual, and objDef_s::notOnMarket.
Referenced by BS_Buy_f(), BS_BuyItem(), BS_FillMarket_f(), BS_GetItemOnMarket(), BS_SaveXML(), BS_SellItem(), BS_ShowInfo_f(), and CP_ItemsSanityCheck().
bool BS_LoadXML | ( | xmlNode_t * | parent | ) |
Load callback for savegames.
[in] | parent | XML Node structure, where we get the information from |
Definition at line 482 of file cp_market.cpp.
References market_s::askAircraft, market_s::askItems, market_s::autosell, market_s::bidAircraft, market_s::bidItems, BS_GetMarket, cgi, market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, objDef_s::idx, INVSH_GetItemByID(), market_s::numAircraft, market_s::numItems, 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, type, cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetString(), and xmlNode_t.
Referenced by SAV_Init().
Update storage, the market, and the player's credits.
Definition at line 222 of file cp_market.cpp.
References BS_AddItemToMarket(), BS_GetItemSellingPrice(), ccs, CP_UpdateCredits(), and ccs_s::credits.
Referenced by BS_SellAircraft().
|
static |
Internal function to remove aircraft from the market.
[in] | aircraft | Aircraft template definition |
[in] | amount | Non-negative number of aircraft to remove |
Definition at line 153 of file cp_market.cpp.
References AIR_IsUFO, BS_GetMarket, cgi, aircraft_s::id, market_s::numAircraft, and type.
Referenced by BS_BuyAircraft(), and CP_CampaignRunMarket().
Internal function to remove items from the market.
[in] | od | Object definition (the item itself) |
[in] | amount | Non-negative number of items to remove |
Definition at line 75 of file cp_market.cpp.
References BS_GetMarket, objDef_s::idx, and market_s::numItems.
Referenced by BS_BuyItem(), BS_BuyUGV(), and CP_CampaignRunMarket().
bool BS_SaveXML | ( | xmlNode_t * | parent | ) |
Save callback for savegames.
[out] | parent | XML Node structure, where we write the information to |
Definition at line 441 of file cp_market.cpp.
References market_s::askAircraft, market_s::askItems, market_s::autosell, market_s::bidAircraft, market_s::bidItems, BS_GetMarket, BS_IsOnMarket(), cgi, cgame_import_s::Com_DropShipTypeToShortName(), cgame_import_s::csi, market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, i, objDef_s::id, INVSH_GetItemByIDX(), market_s::numAircraft, market_s::numItems, csi_s::numODs, 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, cgame_import_s::XML_AddNode(), and xmlNode_t.
Referenced by SAV_Init().
bool BS_SellAircraft | ( | aircraft_t * | aircraft | ) |
Sells the given aircraft with all the equipment.
aircraft | The aircraft to sell |
true
if the aircraft could get sold, false
otherwise Definition at line 264 of file cp_market.cpp.
References AIR_DeleteAircraft(), AIR_GetTeamSize(), AIR_IsAircraftInBase(), aircraftSlot_s::ammo, BS_AddAircraftToMarket(), BS_GetAircraftSellingPrice(), BS_ProcessCraftItemSale(), ccs, CP_UpdateCredits(), ccs_s::credits, aircraft_s::electronics, aircraftSlot_s::item, aircraft_s::maxElectronics, aircraft_s::maxWeapons, aircraft_s::shield, and aircraft_s::weapons.
Referenced by BS_Buy_f().
Sells items from the market.
[in] | od | pointer to the item (Object Definition record) |
[out] | base | Base to sell at |
[in] | count | Number of items to sell |
true
if the ugv could get sold, false
otherwise Definition at line 413 of file cp_market.cpp.
References B_AddToStorage(), B_ItemInBase(), BS_AddItemToMarket(), BS_GetItemSellingPrice(), BS_IsOnMarket(), ccs, cgi, CP_UpdateCredits(), ccs_s::credits, and ERR_DROP.
Referenced by B_SellOrAddItems(), and BS_Buy_f().
bool BS_SellUGV | ( | Employee * | robot | ) |
Sells the given UGV with all the equipment.
robot | The employee record of the UGV to sell |
true
if the ugv could get sold, false
otherwise Definition at line 343 of file cp_market.cpp.
References B_AddToStorage(), Employee::baseHired, BS_AddItemToMarket(), ccs, cgi, Employee::chr, CP_UpdateCredits(), ccs_s::credits, DEBUG_CLIENT, ERR_DROP, Employee::getUGV(), ugv_s::id, INVSH_GetItemByID(), ugv_s::price, character_s::ucn, Employee::unhire(), and ugv_s::weapon.
Referenced by BS_Buy_f().
void CP_CampaignRunMarket | ( | campaign_t * | campaign | ) |
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 578 of file cp_market.cpp.
References AIR_GetAircraft(), campaign_s::asymptoticMarketDef, BS_AddAircraftToMarket(), BS_AddItemToMarket(), BS_GetMarket, BS_RemoveAircraftFromMarket(), BS_RemoveItemFromMarket(), ccs, cgi, cgame_import_s::Com_DropShipTypeToShortName(), cgame_import_s::csi, market_s::currentEvolutionAircraft, market_s::currentEvolutionItems, ccs_s::date, date_s::day, i, int(), INVSH_GetItemByIDX(), campaign_s::marketDef, 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 CP_CampaignRun(), and TEST_F().