![]() |
naev 0.11.5
|
Handles economy stuff. More...
#include "economy.h"#include "array.h"#include "log.h"#include "ndata.h"#include "nstring.h"#include "ntime.h"#include "nxml.h"#include "pilot.h"#include "player.h"#include "rng.h"#include "space.h"#include "spfx.h"Go to the source code of this file.
Macros | |
| #define | ECON_BASE_RES 30. |
| #define | ECON_SELF_RES 3. |
| #define | ECON_FACTION_MOD 0.1 |
| #define | ECON_PROD_MODIFIER 500000. |
| #define | ECON_PROD_VAR 0.01 |
Functions | |
| int | economy_sysSave (xmlTextWriterPtr writer) |
| Saves what is needed to be saved for economy. | |
| int | economy_sysLoad (xmlNodePtr parent) |
| Loads player's economy properties from an XML node. | |
| credits_t | economy_getPrice (const Commodity *com, const StarSystem *sys, const Spob *p) |
| Gets the price of a good on a spob in a system. | |
| credits_t | economy_getPriceAtTime (const Commodity *com, const StarSystem *sys, const Spob *p, ntime_t tme) |
| Gets the price of a good on a spob in a system. | |
| int | economy_getAverageSpobPrice (const Commodity *com, const Spob *p, credits_t *mean, double *std) |
| Gets the average price of a good on a spob in a system, using a rolling average over the times the player has landed here. | |
| int | economy_getAveragePrice (const Commodity *com, credits_t *mean, double *std) |
| Gets the average price of a good as seen by the player (anywhere). | |
| int | economy_init (void) |
| Initializes the economy. | |
| void | economy_addQueuedUpdate (void) |
| Increments the queued update counter. | |
| int | economy_execQueued (void) |
| Calls economy_refresh if an economy update is queued. | |
| int | economy_refresh (void) |
| Regenerates the economy matrix. Should be used if the universe changes in any permanent way. | |
| int | economy_update (unsigned int dt) |
| Updates the economy. | |
| void | economy_destroy (void) |
| Destroys the economy. | |
| static int | economy_calcPrice (Spob *spob, Commodity *commodity, CommodityPrice *commodityPrice) |
| Used during startup to set price and variation of the economy, depending on spob information. | |
| static void | economy_modifySystemCommodityPrice (StarSystem *sys) |
| Modifies commodity price based on system characteristics. | |
| static void | economy_smoothCommodityPrice (StarSystem *sys) |
| Calculates smoothing of commodity price based on neighbouring systems. | |
| static void | economy_calcUpdatedCommodityPrice (StarSystem *sys) |
| Modifies commodity price based on neighbouring systems. | |
| void | economy_initialiseCommodityPrices (void) |
| Initialises commodity prices for the sinusoidal economy model. | |
| void | economy_initialiseSingleSystem (StarSystem *sys, Spob *spob) |
| void | economy_averageSeenPrices (const Spob *p) |
| void | economy_averageSeenPricesAtTime (const Spob *p, const ntime_t tupdate) |
| void | economy_clearKnown (void) |
| Clears all system knowledge. | |
| void | economy_clearSingleSpob (Spob *p) |
| Clears all economy knowledge of a given spob. Used by the unidiff system. | |
Variables | |
| StarSystem * | systems_stack |
| Commodity * | commodity_stack |
| static int | econ_initialized = 0 |
| static int | econ_queued = 0 |
| static cs * | econ_G = NULL |
| int * | econ_comm = NULL |
Handles economy stuff.
Economy is handled with Nodal Analysis. Systems are modelled as nodes, jump routes are resistances and production is modelled as node intensity. This is then solved with linear algebra after each time increment.
Definition in file economy.c.
| #define ECON_BASE_RES 30. |
| #define ECON_FACTION_MOD 0.1 |
| #define ECON_PROD_MODIFIER 500000. |
| #define ECON_PROD_VAR 0.01 |
| #define ECON_SELF_RES 3. |
| void economy_addQueuedUpdate | ( | void | ) |
Increments the queued update counter.
| void economy_averageSeenPricesAtTime | ( | const Spob * | p, |
| const ntime_t | tupdate ) |
|
static |
|
static |
| void economy_clearKnown | ( | void | ) |
| void economy_clearSingleSpob | ( | Spob * | p | ) |
| int economy_execQueued | ( | void | ) |
| int economy_getAveragePrice | ( | const Commodity * | com, |
| credits_t * | mean, | ||
| double * | std ) |
Gets the average price of a good as seen by the player (anywhere).
| com | Commodity to get price of. | |
| [out] | mean | Sample mean, rounded to nearest credit. |
| [out] | std | Sample standard deviation (via uncorrected population formula). |
| int economy_getAverageSpobPrice | ( | const Commodity * | com, |
| const Spob * | p, | ||
| credits_t * | mean, | ||
| double * | std ) |
Gets the average price of a good on a spob in a system, using a rolling average over the times the player has landed here.
| com | Commodity to get price of. | |
| p | Spob to get price of commodity. | |
| [out] | mean | Sample mean, rounded to nearest credit. |
| [out] | std | Sample standard deviation (via uncorrected population formula). |
| credits_t economy_getPriceAtTime | ( | const Commodity * | com, |
| const StarSystem * | sys, | ||
| const Spob * | p, | ||
| ntime_t | tme ) |
Gets the price of a good on a spob in a system.
| com | Commodity to get price of. |
| sys | System to get price of commodity. |
| p | Spob to get price of commodity. |
| tme | Time to get price at, eg as retunred by ntime_get() |
| int economy_init | ( | void | ) |
| void economy_initialiseCommodityPrices | ( | void | ) |
| void economy_initialiseSingleSystem | ( | StarSystem * | sys, |
| Spob * | spob ) |
|
static |
| int economy_refresh | ( | void | ) |
|
static |
| int economy_sysLoad | ( | xmlNodePtr | parent | ) |
| int economy_sysSave | ( | xmlTextWriterPtr | writer | ) |
| int economy_update | ( | unsigned int | dt | ) |
|
extern |
Contains all the commodities.
Definition at line 39 of file commodity.c.
|
static |
|
static |