naev 0.10.4
commodity.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <stdint.h>
10#include "opengl.h"
11
12#define ECON_CRED_STRLEN 32
13#define ECON_MASS_STRLEN 32
15typedef int64_t credits_t;
16#define CREDITS_MAX (((credits_t)1) << 53)
17#define CREDITS_MIN (-CREDITS_MAX)
18#define CREDITS_PRI PRIu64
19
20#define COMMODITY_FLAG_STANDARD (1<<0)
21#define COMMODITY_FLAG_ALWAYS_CAN_SELL (1<<1)
22#define COMMODITY_FLAG_PRICE_CONSTANT (1<<2)
23#define commodity_isFlag(c,f) ((c)->flags & (f))
24#define commodity_setFlag(c,f) ((c)->flags |= (f))
25#define commodity_rmFlag(c,f) ((c)->flags &= ~(f))
32typedef struct CommodityModifier_ {
33 char *name;
34 float value;
35 struct CommodityModifier_ *next;
37
43typedef struct Commodity_ {
44 char *name;
46 unsigned int flags;
48 /* Prices. */
49 char *price_ref;
50 double price_mod;
51 double raw_price;
52 double price;
56 /* Misc stuff. */
58 int istemp;
59 int *illegalto;
61 /* Dynamic economy stuff. */
63 double period;
66} Commodity;
67
68typedef struct CommodityPrice_ {
69 double price;
70 double spobPeriod;
71 double sysPeriod;
73 double sysVariation;
74 int64_t updateTime;
75 char *name;
76 double sum;
77 double sum2;
78 int cnt;
80
81/*
82 * Commodity stuff.
83 */
84Commodity* commodity_getAll (void);
85Commodity* commodity_get( const char* name );
86Commodity* commodity_getW( const char* name );
87int commodity_getN( void );
88
89Commodity* commodity_getByIndex( const int indx );
90int commodity_load (void);
91void commodity_free (void);
92
93int commodity_checkIllegal( const Commodity *com, int faction );
94
95/*
96 * Temporary commodities.
97 */
98int commodity_isTemp( const char* name );
99Commodity* commodity_newTemp( const char* name, const char* desc );
100int commodity_tempIllegalto( Commodity *com, int faction );
101
102/*
103 * Misc stuff.
104 */
105void credits2str( char *str, credits_t credits, int decimals );
106void price2str( char *str, credits_t price, credits_t credits, int decimals );
107void tonnes2str( char *str, int tonnes );
108int commodity_compareTech( const void *commodity1, const void *commodity2 );
109Commodity ** standard_commodities (void);
Represents a dictionary of values used to modify a commodity.
Definition: commodity.h:32
double sum
Definition: commodity.h:76
double price
Definition: commodity.h:69
double sysVariation
Definition: commodity.h:73
char * name
Definition: commodity.h:75
double sum2
Definition: commodity.h:77
double spobVariation
Definition: commodity.h:72
int64_t updateTime
Definition: commodity.h:74
double spobPeriod
Definition: commodity.h:70
Represents a commodity.
Definition: commodity.h:43
char * description
Definition: commodity.h:45
CommodityModifier * spob_modifier
Definition: commodity.h:62
glTexture * gfx_store
Definition: commodity.h:53
int * illegalto
Definition: commodity.h:59
double population_modifier
Definition: commodity.h:64
char * name
Definition: commodity.h:44
credits_t lastPurchasePrice
Definition: commodity.h:57
CommodityModifier * faction_modifier
Definition: commodity.h:65
double price_mod
Definition: commodity.h:50
double price
Definition: commodity.h:52
glTexture * gfx_space
Definition: commodity.h:54
double period
Definition: commodity.h:63
double raw_price
Definition: commodity.h:51
int istemp
Definition: commodity.h:58
char * price_ref
Definition: commodity.h:49
unsigned int flags
Definition: commodity.h:46
Abstraction for rendering sprite sheets.
Definition: opengl_tex.h:34