![]() |
naev 0.12.6
|
Handles commodities. More...
#include "commodity.h"#include "array.h"#include "conf.h"#include "faction.h"#include "gatherable.h"#include "log.h"#include "ndata.h"#include "nxml.h"#include "opengl.h"#include "threadpool.h"
Go to the source code of this file.
Data Structures | |
| struct | CommodityThreadData |
| For threaded loading of commodities. More... | |
Macros | |
| #define | XML_COMMODITY_ID "commodity" |
| #define | CRED_TEXT_MAX |
Functions | |
| static int | commodity_parseThread (void *ptr) |
| static void | commodity_freeOne (Commodity *com) |
| Frees a commodity. | |
| static int | commodity_parse (Commodity *temp, const char *filename) |
| Loads a commodity. | |
| static int | commodity_cmp (const void *p1, const void *p2) |
| void | credits2str (char *str, credits_t credits, int decimals) |
| Converts credits to a usable string for displaying. | |
| void | price2str (char *str, credits_t price, credits_t credits, int decimals) |
| Given a price and on-hand credits, outputs a colourized string. | |
| void | tonnes2str (char *str, int tonnes) |
| Converts tonnes to a usable string for displaying. | |
| Commodity * | commodity_getAll (void) |
| Gets all the commodities. | |
| Commodity * | commodity_get (const char *name) |
| Gets a commodity by name. | |
| Commodity * | commodity_getW (const char *name) |
| Gets a commodity by name without warning. | |
| int | commodity_getN (void) |
| Return the number of commodities globally. | |
| Commodity * | commodity_getByIndex (const int indx) |
| Gets a commodity by index. | |
| int | commodity_compareTech (const void *commodity1, const void *commodity2) |
| Function meant for use with C89, C99 algorithm qsort(). | |
| Commodity ** | standard_commodities (void) |
| Return an array (array.h) of standard commodities. Free with array_free. (Don't free contents.) | |
| int | commodity_checkIllegal (const Commodity *com, int faction) |
| Checks to see if a commodity is illegal to a faction. | |
| int | commodity_isTemp (const char *name) |
| Checks to see if a commodity is temporary. | |
| Commodity * | commodity_newTemp (const char *name, const char *desc) |
| Creates a new temporary commodity. | |
| int | commodity_tempIllegalto (Commodity *com, int faction) |
| Makes a temporary commodity illegal to something. | |
| int | commodity_load (void) |
| Loads all the commodity data. | |
| void | commodity_free (void) |
| Frees all the loaded commodities. | |
Variables | |
| Commodity * | commodity_stack = NULL |
| static Commodity ** | commodity_temp |
| int * | econ_comm |
Handles commodities.
Definition in file commodity.c.
| #define CRED_TEXT_MAX |
Definition at line 30 of file commodity.c.
| #define XML_COMMODITY_ID "commodity" |
XML document identifier
Definition at line 29 of file commodity.c.
| int commodity_checkIllegal | ( | const Commodity * | com, |
| int | faction ) |
Checks to see if a commodity is illegal to a faction.
Definition at line 422 of file commodity.c.
|
static |
Definition at line 60 of file commodity.c.
| int commodity_compareTech | ( | const void * | commodity1, |
| const void * | commodity2 ) |
Function meant for use with C89, C99 algorithm qsort().
| commodity1 | First argument to compare. |
| commodity2 | Second argument to compare. |
Definition at line 245 of file commodity.c.
| void commodity_free | ( | void | ) |
Frees all the loaded commodities.
Definition at line 586 of file commodity.c.
|
static |
| Commodity * commodity_get | ( | const char * | name | ) |
Gets a commodity by name.
| name | Name to match. |
Definition at line 151 of file commodity.c.
| Commodity * commodity_getAll | ( | void | ) |
Gets all the commodities.
Definition at line 140 of file commodity.c.
| Commodity * commodity_getByIndex | ( | const int | indx | ) |
Gets a commodity by index.
| indx | Index of the commodity. |
Definition at line 195 of file commodity.c.
| int commodity_getN | ( | void | ) |
Return the number of commodities globally.
Definition at line 184 of file commodity.c.
| Commodity * commodity_getW | ( | const char * | name | ) |
Gets a commodity by name without warning.
| name | Name to match. |
Definition at line 166 of file commodity.c.
| int commodity_isTemp | ( | const char * | name | ) |
Checks to see if a commodity is temporary.
Name of the commodity to check.
Definition at line 437 of file commodity.c.
| int commodity_load | ( | void | ) |
| Commodity * commodity_newTemp | ( | const char * | name, |
| const char * | desc ) |
Creates a new temporary commodity.
| name | Name of the commodity to create. |
| desc | Description of the commodity to create. |
Definition at line 457 of file commodity.c.
|
static |
Loads a commodity.
| temp | Commodity to load data into. |
| filename | File to parse. |
Definition at line 286 of file commodity.c.
|
static |
Definition at line 495 of file commodity.c.
| int commodity_tempIllegalto | ( | Commodity * | com, |
| int | faction ) |
Makes a temporary commodity illegal to something.
Definition at line 474 of file commodity.c.
| void credits2str | ( | char * | str, |
| credits_t | credits, | ||
| int | decimals ) |
Converts credits to a usable string for displaying.
| [out] | str | Output is stored here, must have at least a size of ECON_CRED_STRLEN. |
| credits | Credits to display, negative value to display full string. | |
| decimals | Decimals to use. |
Definition at line 75 of file commodity.c.
| void price2str | ( | char * | str, |
| credits_t | price, | ||
| credits_t | credits, | ||
| int | decimals ) |
Given a price and on-hand credits, outputs a colourized string.
| [out] | str | Output is stored here, must have at least a size of ECON_CRED_STRLEN. |
| price | Price to display. | |
| credits | Credits available. | |
| decimals | Decimals to use. |
Definition at line 111 of file commodity.c.
| Commodity ** standard_commodities | ( | void | ) |
Return an array (array.h) of standard commodities. Free with array_free. (Don't free contents.)
Definition at line 267 of file commodity.c.
| void tonnes2str | ( | char * | str, |
| int | tonnes ) |
Converts tonnes to a usable string for displaying.
| [out] | str | Output is stored here, must have at least a size of ECON_MASS_STRLEN. |
| tonnes | Number of tonnes to display. |
Definition at line 131 of file commodity.c.
| Commodity* commodity_stack = NULL |
Contains all the commodities.
Definition at line 35 of file commodity.c.
|
static |
Contains all the temporary commodities.
Definition at line 36 of file commodity.c.