43 if (!aircraftTemplate || aircraftTemplate != aircraftTemplate->
tpl)
46 tech = aircraftTemplate->
tech;
49 cgi->Cvar_Set(
"mn_aircraftname",
"%s",
_(aircraftTemplate->
name));
50 cgi->Cvar_Set(
"mn_item",
"%s", aircraftTemplate->
id);
59 const char* item =
cgi->Cvar_GetString(
"mn_item");
74 if (
cgi->Cmd_Argc() < 2) {
75 cgi->Com_Printf(
"Usage: %s <item-id> [0|1]\nWhere second parameter is the state (off/on), if omitted the autosell property will be flipped.\n",
81 cgi->Com_Printf(
"Aircraft can't be autosold!\n");
91 cgi->Com_Printf(
"Item %s is virtual, can't be autosold!\n", od->
id);
95 cgi->Com_Printf(
"Item %s is not on market, can't be autosold!\n", od->
id);
101 cgi->Com_Printf(
"Item %s is not researched, can't be autosold!\n", od->
id);
104 if (
cgi->Cmd_Argc() >= 3)
105 ccs.eMarket.autosell[od->
idx] = atoi(
cgi->Cmd_Argv(2));
107 ccs.eMarket.autosell[od->
idx] = !
ccs.eMarket.autosell[od->
idx];
122 if (
cgi->Cmd_Argc() < 2) {
123 cgi->Com_Printf(
"Usage: %s <item-id> <count> [base-idx] \nNegative count means selling. If base index is omitted buys on the currently selected base.\n",
128 itemid =
cgi->Cmd_Argv(1);
131 if (
cgi->Cmd_Argc() >= 4)
134 if (
char const*
const rest =
Q_strstart(itemid,
"aircraft_")) {
136 int idx = atoi(rest);
140 cgi->Com_Printf(
"Invalid aircraft index!\n");
148 if (
char const*
const rest =
Q_strstart(itemid,
"ugv-")) {
150 int ucn = atoi(rest);
154 cgi->Com_Printf(
"Invalid UCN for UGV!\n");
163 cgi->Com_Printf(
"No/invalid base selected.\n");
170 CP_Popup(
_(
"Note"),
_(
"No Command Centre in this base.\nHangars are not functional.\n"));
175 CP_Popup(
_(
"Note"),
_(
"No power supplies in this base.\nHangars are not functional."));
180 CP_Popup(
_(
"Note"),
_(
"Build a hangar first."));
185 CP_Popup(
_(
"Notice"),
_(
"You cannot buy this aircraft.\nNot enough space in hangars.\n"));
190 CP_Popup(
_(
"Notice"),
_(
"You cannot buy this aircraft.\nNot enough credits.\n"));
198 ugv =
cgi->Com_GetUGVByIDSilent(itemid);
202 cgi->Com_Error(
ERR_DROP,
"BS_BuyItem_f: Could not get weapon '%s' for ugv/tank '%s'.", ugv->
weapon, ugv->
id);
206 if (
ccs.eMarket.numItems[ugvWeapon->
idx] < 1)
210 CP_Popup(
_(
"Not enough money"),
_(
"You cannot buy this item as you don't have enough credits."));
215 CP_Popup(
_(
"Not enough storage space"),
_(
"You cannot buy this item.\nNot enough space in storage.\nBuild more storage facilities."));
224 cgi->Com_Printf(
"Invalid number of items to buy/sell: %s\n",
cgi->Cmd_Argv(2));
251 CP_Popup(
_(
"Not enough money"),
_(
"You cannot buy this item as you don't have enough credits."));
256 cgi->Com_Printf(
"Item on market with invalid size: %s (%d)\n", od->
id, od->
size);
261 CP_Popup(
_(
"Not enough storage space"),
_(
"You cannot buy this item.\nNot enough space in storage.\nBuild more storage facilities."));
276 cgi->Com_Printf(
"Invalid item ID\n");
289 if (
cgi->Cmd_Argc() < 2) {
290 cgi->Com_Printf(
"Usage: %s <item-id>\n",
cgi->Cmd_Argv(0));
294 itemid =
cgi->Cmd_Argv(1);
296 if (
char const*
const rest =
Q_strstart(itemid,
"aircraft_")) {
298 int idx = atoi(rest);
302 cgi->Com_Printf(
"Invalid aircraft index!\n");
310 if (
char const*
const rest =
Q_strstart(itemid,
"ugv-")) {
312 int ucn = atoi(rest);
316 cgi->Com_Printf(
"Invalid UCN for UGV!\n");
331 ugv =
cgi->Com_GetUGVByIDSilent(itemid);
346 cgi->INV_ItemDescription(od);
349 cgi->Com_Printf(
"Invalid item ID\n");
360 if (
cgi->Cmd_Argc() < 2) {
361 cgi->Com_Printf(
"Usage: %s <category>\n",
cgi->Cmd_Argv(0));
364 if (
cgi->Cmd_Argc() >= 3)
367 cgi->Com_Printf(
"No/invalid base selected.\n");
371 type =
cgi->INV_GetFilterTypeID(
cgi->Cmd_Argv(1));
372 cgi->UI_ExecuteConfunc(
"ui_market_clear");
377 const ugv_t* ugv = robot->getUGV();
380 if (!robot->isHiredInBase(base))
383 cgi->UI_ExecuteConfunc(
"ui_market_add \"ugv-%d\" \"%s\" 1 0 0 %d - \"%s\"", robot->chr.ucn,
_(tech->
name), ugv->
price, robot->isAwayFromBase() ?
_(
"UGV is away from home") :
"-");
386 for (
int i = 0;
i <
cgi->csi->numUGV;
i++) {
398 cgi->UI_ExecuteConfunc(
"ui_market_add %s \"%s\" 0 %d %d %d - -", ugv->
id,
_(tech->
name), buyable, ugv->
price, ugv->
price);
410 for (
int i = 0;
i <
cgi->csi->numODs;
i++) {
428 for (
int i = 0;
i <
ccs.numAircraftTemplates;
i++) {
450static void BS_AddMarket_f (
void)
452 if (
cgi->Cmd_Argc() < 3) {
453 cgi->Com_Printf(
"Usage: %s <itemid> <count>\n",
cgi->Cmd_Argv(0));
461 const int amount = atoi(
cgi->Cmd_Argv(2));
468 {
"ui_market_setautosell",
BS_SetAutosell_f,
"Sets/unsets or flips the autosell property of an item on the market"},
469 {
"ui_market_buy",
BS_Buy_f,
"Buy/Sell item/aircraft/ugv on the market"},
470 {
"ui_market_showinfo",
BS_ShowInfo_f,
"Show information about item/aircaft/ugv in the market"},
473 {
"debug_marketadd", BS_AddMarket_f,
"Add items to the market"},
475 {
nullptr,
nullptr,
nullptr}
Header file for inventory handling and Equipment menu.
itemFilterTypes_t
A list of filter types in the market and production view.
Share stuff between the different cgame implementations.
const struct ugv_s * getUGV() const
bool AIR_AircraftAllowed(const base_t *base)
Returns true if the current base is able to handle aircraft.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
const aircraft_t * AIR_GetAircraftSilent(const char *name)
Searches the global array of aircraft types for a given aircraft.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
void AIR_RemoveEmployees(aircraft_t &aircraft)
Removes all soldiers from an aircraft.
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
base_t * B_GetCurrentSelectedBase(void)
returns the currently selected base
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.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
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.
#define CAP_GetMax(base, capacity)
Employee * E_GetEmployeeByTypeFromChrUCN(employeeType_t type, int uniqueCharacterNumber)
Searches employee from a type for the ucn (character id).
int E_CountUnhiredRobotsByType(const ugv_t *ugvType)
Counts all available Robots/UGVs that are for sale.
#define E_Foreach(employeeType, var)
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.
bool BS_AircraftIsOnMarket(const aircraft_t *aircraft)
Checks whether a given aircraft should appear on the market.
int BS_GetItemOnMarket(const objDef_t *od)
Get the number of items 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.
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.
bool BS_SellAircraft(aircraft_t *aircraft)
Sells the given aircraft with all the equipment.
int BS_GetAircraftBuyingPrice(const aircraft_t *aircraft)
Get the price for an aircraft that you want to buy on the market.
bool BS_SellItem(const objDef_t *od, base_t *base, int count)
Sells items from the market.
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.
bool BS_BuyAircraft(const aircraft_t *aircraftTemplate, base_t *base)
Buys an aircraft.
Header for single player market stuff.
static void BS_MarketAircraftDescription(const aircraft_t *aircraftTemplate)
Prints general information about aircraft for Buy/Sell menu.
static const cmdList_t marketCallbacks[]
static void BS_MarketInfoClick_f(void)
Opens the UFOpedia for the current selected item/aircraft/ugv.
void BS_ShutdownCallbacks(void)
Function unregisters the callbacks of the maket UI.
static void BS_SetAutosell_f(void)
Sets/unsets or flips the autosell property of an item on the market.
static void BS_ShowInfo_f(void)
Show information about item/aircaft/ugv in the market.
void BS_InitCallbacks(void)
Function registers the callbacks of the maket UI and do initializations.
static void BS_FillMarket_f(void)
Fill market item list.
static void BS_Buy_f(void)
Buy/Sell item/aircraft/ugv on the market.
Header file for menu related console command callbacks.
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.
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
void UP_UGVDescription(const struct ugv_s *ugvType)
void UP_AircraftDescription(const technology_t *t)
Prints the UFOpaedia description for aircraft.
void UP_OpenWith(const char *techID)
Opens the UFOpaedia from everywhere with the entry given through name.
void UP_AircraftItemDescription(const objDef_t *item)
Prints the (UFOpaedia and other) description for aircraft items.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
QGL_EXTERN GLint GLenum type
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
An aircraft with all it's data.
struct technology_s * tech
A base with all it's data.
Defines all attributes of objects used in the inventory.
This is the technology parsed from research.ufo.
Defines a type of UGV/Robot.