6#include "space_fdecl.h"
10#include "mission_markers.h"
12#include "opengl_tex.h"
17#define SYSTEM_SIMULATE_TIME_PRE \
20#define SYSTEM_SIMULATE_TIME_POST \
23#define MAX_HYPERSPACE_VEL 25.
28#define SPOB_SERVICE_LAND ( 1 << 0 )
29#define SPOB_SERVICE_REFUEL ( 1 << 1 )
30#define SPOB_SERVICE_BAR ( 1 << 2 )
31#define SPOB_SERVICE_MISSIONS ( 1 << 3 )
32#define SPOB_SERVICE_OUTFITS ( 1 << 4 )
33#define SPOB_SERVICE_SHIPYARD ( 1 << 5 )
34#define SPOB_SERVICE_COMMODITY ( 1 << 6 )
35#define SPOB_SERVICE_INHABITED ( 1 << 7 )
36#define SPOB_SERVICE_BLACKMARKET \
38#define SPOB_SERVICES_MAX ( SPOB_SERVICE_BLACKMARKET << 1 )
39#define spob_hasService( p, s ) \
40 ( ( p )->services & s )
45#define SPOB_KNOWN ( 1 << 0 )
46#define SPOB_BLACKMARKET ( 1 << 1 )
47#define SPOB_NOMISNSPAWN \
49#define SPOB_UNINHABITED ( 1 << 3 )
50#define SPOB_MARKED ( 1 << 4 )
51#define SPOB_NOLANES ( 1 << 5 )
52#define SPOB_HOSTILE ( 1 << 6 )
53#define SPOB_RADIUS ( 1 << 10 )
54#define spob_isFlag( p, f ) ( ( p )->flags & ( f ) )
55#define spob_setFlag( p, f ) \
56 ( ( p )->flags |= ( f ) )
58#define spob_rmFlag( p, f ) \
59 ( ( p )->flags &= ~( f ) )
60#define spob_isKnown( p ) \
61 spob_isFlag( p, SPOB_KNOWN )
69typedef struct MapOverlayPos_ {
78typedef struct SpobPresence_ {
91typedef struct VirtualSpob_ {
102typedef struct Spob_ {
140 double gfx_space3d_size;
142 char *gfx_space3dName;
143 char *gfx_space3dPath;
183#define SYSTEM_KNOWN ( 1 << 0 )
184#define SYSTEM_MARKED \
187#define SYSTEM_CMARKED \
189#define SYSTEM_CLAIMED ( 1 << 3 )
190#define SYSTEM_DISCOVERED \
193#define SYSTEM_HIDDEN \
196#define SYSTEM_HAS_KNOWN_LANDABLE \
199#define SYSTEM_HAS_LANDABLE \
201#define SYSTEM_HAS_KNOWN_SPOB ( 1 << 8 )
202#define SYSTEM_HAS_KNOWN_FACTION_SPOB \
204#define SYSTEM_NOLANES \
206#define SYSTEM_PMARKED ( 1 << 11 )
207#define SYSTEM_INTEREST \
210#define SYSTEM_NEBULATRAIL ( 1 << 13 )
211#define SYSTEM_HIDENEBULADAMAGE \
213#define sys_isFlag( s, f ) \
214 ( ( s )->flags & ( f ) )
216#define sys_setFlag( s, f ) \
217 ( ( s )->flags |= ( f ) )
218#define sys_rmFlag( s, f ) \
219 ( ( s )->flags &= ~( f ) )
220#define sys_isKnown( s ) \
221 ( sys_isFlag( ( s ), SYSTEM_KNOWN ) )
222#define sys_isMarked( s ) \
223 sys_isFlag( ( s ), SYSTEM_MARKED )
228typedef struct SystemPresence_ {
245#define JP_KNOWN ( 1 << 1 )
246#define JP_HIDDEN ( 1 << 2 )
247#define JP_EXITONLY ( 1 << 3 )
248#define JP_NOLANES ( 1 << 4 )
249#define jp_isFlag( j, f ) ( ( j )->flags & ( f ) )
250#define jp_setFlag( j, f ) ( ( j )->flags |= ( f ) )
251#define jp_rmFlag( j, f ) \
252 ( ( j )->flags &= ~( f ) )
253#define jp_isKnown( j ) \
254 jp_isFlag( j, JP_KNOWN )
255#define jp_isUsable( j ) ( jp_isKnown( j ) && !jp_isFlag( j, JP_EXITONLY ) )
284typedef struct MapShader_ {
374void space_init(
const char *sysname,
int do_simulate );
430JumpPoint *
jump_get(
const char *jumpname,
const StarSystem *sys );
431JumpPoint *
jump_getTarget(
const StarSystem *target,
const StarSystem *sys );
441const char *system_name(
const StarSystem *sys );
442const char *system_nameKnown(
const StarSystem *sys );
460void system_presenceCleanupAll(
void );
462SystemPresence *system_getFactionPresence( StarSystem *sys,
int faction );
463const SystemPresence *system_getFactionPresenceConst(
const StarSystem *sys,
499 const StarSystem *sys );
502 int ( *filter )(
Spob *p ) );
504 int *fie,
double x,
double y );
506 int *fie,
double x,
double y,
double ang );
525 vec2 *vel,
double *dir,
const Pilot *p );
void space_reconstructPresences(void)
Reset the presence of all systems.
void space_init(const char *sysname, int do_simulate)
Initializes the system.
double system_getClosestAng(const StarSystem *sys, int *pnt, int *jp, int *ast, int *fie, double x, double y, double ang)
Gets the feature nearest to directly ahead of a position in the system.
void spob_distress(Spob *spb, const Pilot *p, const Pilot *attacker)
Spob is receiving distress from a pilot about an attacker.
void spob_averageSeenPricesAtTime(const Spob *p, const ntime_t tupdate)
Adds cost of commodities on spob p to known statistics at time t.
double system_getClosest(const StarSystem *sys, int *pnt, int *jp, int *ast, int *fie, double x, double y)
Gets the closest feature to a position in the system.
int spob_exists(const char *spobname)
Check to see if a spob exists.
void system_rmCurrentPresence(StarSystem *sys, int faction, double amount)
Removes active presence.
void space_gfxUnload(StarSystem *sys)
Unloads all the graphics for a star system.
int space_canHyperspace(const Pilot *p)
Checks to make sure if pilot is far enough away to hyperspace.
void space_render(const double dt)
Renders the system.
int spob_luaInit(Spob *spob)
Updatse the spob's internal Lua stuff.
void systems_reconstructJumps(void)
Reconstructs the jumps.
int space_jumpDistance(const Pilot *p, const JumpPoint *jp)
Distance at which a pilot can jump.
const glColour * spob_getColour(const Spob *p)
Gets the spob colour.
int space_rmMarker(int objid, MissionMarkerType type)
Removes a marker from a system.
int system_addJump(StarSystem *sys, StarSystem *target)
Adds a jump point between two star systems.
int spob_averageSpobPrice(const Spob *p, const Commodity *c, credits_t *mean, double *std)
Gets the average price of a commodity at a spob that has been seen so far.
double system_getPresenceFull(const StarSystem *sys, int faction, double *base, double *bonus)
Get the presence of a faction in a system.
double system_getReputation(const StarSystem *sys, int faction)
Gets the local reputation of the player in a system or returns 0.
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
int spob_rename(Spob *p, char *newname)
Renames a spob.
int spob_getService(const char *name)
Converts name to spob service flag.
void system_setFaction(StarSystem *sys)
Sets the system faction based on the spobs it has.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
void space_factionChange(void)
Mark when a faction changes.
int system_addVirtualSpob(StarSystem *sys, const char *spobname)
Adds a virtual spob to a system.
const char * space_getRndSpob(int landable, unsigned int services, int(*filter)(Spob *p))
Gets the name of a random spob.
void space_update(double dt, double real_dt)
Controls fleet spawning.
StarSystem * system_getIndex(int id)
Get the system by its index.
int spob_index(const Spob *p)
Gets the ID of a spob.
double system_getReputationOrGlobal(const StarSystem *sys, int faction)
Gets the local reputation of the player in a system or returns the global standing.
int spob_hasSystem(const Spob *spb)
Get whether or not a spob has a system (i.e. is on the map).
const char * jump_getSymbol(const JumpPoint *jp)
Gets the jump point symbol.
const char * spob_getSymbol(const Spob *p)
Gets the spob symbol.
void space_renderOverlay(const double dt)
Renders the system overlay.
int spob_setFaction(Spob *p, int faction)
Changes the spobs faction.
char spob_getColourChar(const Spob *p)
Gets the spob colour char.
StarSystem * system_new(void)
Creates a new star system.
int space_sysReachable(const StarSystem *sys)
Sees if a system is reachable.
JumpPoint * jump_getTarget(const StarSystem *target, const StarSystem *sys)
Less safe version of jump_get that works with pointers.
const char * system_existsCase(const char *sysname)
Checks to see if a system exists case insensitively.
StarSystem * system_getAll(void)
Gets an array (array.h) of all star systems.
char ** spob_searchFuzzyCase(const char *spobname, int *n)
Does a fuzzy case matching. Searches spob_name() but returns internal names.
int space_sysReachableFromSys(const StarSystem *target, const StarSystem *sys)
Sees if a system is reachable from another system.
char ** system_searchFuzzyCase(const char *sysname, int *n)
Does a fuzzy case matching. Searches translated names but returns internal names.
int space_playerLoad(xmlNodePtr parent, const char *version)
Loads player's space properties from an XML node.
StarSystem * system_get(const char *sysname)
Get the system from its name.
int space_calcJumpInPos(const StarSystem *in, const StarSystem *out, vec2 *pos, vec2 *vel, double *dir, const Pilot *p)
Calculates the jump in pos for a pilot.
int spob_rmService(Spob *p, int service)
Removes a service from a spob.
void system_updateAsteroids(StarSystem *sys)
Updates some internal calculations about asteroids in a system.
void spob_setKnown(Spob *p)
Sets a spob's known status, if it's real.
void spobs_render(void)
Renders the current systems' spobs.
const char * spob_existsCase(const char *spobname)
Check to see if a spob exists (case insensitive).
int system_addSpob(StarSystem *sys, const char *spobname)
Adds a spob to a star system.
void space_exit(void)
Cleans up the system.
int space_addMarker(int objid, MissionMarkerType type)
Adds a marker to a system.
double system_getPresence(const StarSystem *sys, int faction)
Get the presence of a faction in a system.
void spob_updateLand(Spob *p)
Updates the land possibilities of a spob.
int space_sysReallyReachable(const char *sysname)
Sees if a system can be reached via jumping.
void spob_gfxLoad(Spob *spob)
Loads a spob's graphics (and radius).
int system_rmVirtualSpob(StarSystem *sys, const char *spobname)
Removes a virtual spob from a system.
void space_clearMarkers(void)
Clears all system markers.
int space_playerSave(xmlTextWriterPtr writer)
Saves what is needed to be saved for space.
VirtualSpob * virtualspob_getAll(void)
Gets all the virtual spobs.
Spob * spob_getIndex(int ind)
Gets spob by index.
void system_presenceAddSpob(StarSystem *sys, const SpobPresence *ap)
Adds (or removes) some presence to a system.
VirtualSpob * virtualspob_get(const char *name)
Gets a virtual spob by matching name.
void space_clearKnown(void)
Clears all system knowledge.
void system_addAllSpobsPresence(StarSystem *sys)
Go through all the spobs and call system_addPresence().
int spob_addCommodity(Spob *p, Commodity *c)
Adds a commodity to a spob.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
int system_hasSpob(const StarSystem *sys)
See if the system has a spob.
int spob_addService(Spob *p, int service)
Removes a service from a spob.
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
const char * spob_getClassName(const char *class)
Gets the long class name for a spob.
const char * space_populationStr(const Spob *spb)
Gets the population in an approximated string. Note this function changes the string value each call,...
void space_clearComputerMarkers(void)
Clears all the system computer markers.
void space_queueLand(Spob *pnt)
Cues a spob to be landed on. This is not done immediately, but when the engine thinks it is ok to do.
int system_rmJump(StarSystem *sys, StarSystem *target)
Removes a jump point from a star system.
credits_t spob_commodityPrice(const Spob *p, const Commodity *c)
Gets the price of a commodity at a spob.
const char * spob_getServiceName(int service)
Gets the (English) name for a service code.
void systems_reconstructSpobs(void)
Updates the system spob pointers.
Spob * spob_new(void)
Creates a new spob.
StarSystem * spob_getSystem(const Spob *spob)
Gets the system a spob is in.
int space_needsEffects(void)
returns whether or not we're simulating with effects.
char ** space_getFactionSpob(const int *factions, int landable)
Gets the name of all the spobs that belong to factions.
void spob_luaInitMem(const Spob *spob)
Initializes the memory fo a spob.
JumpPoint * jump_get(const char *jumpname, const StarSystem *sys)
Gets a jump point based on its target and system.
void space_checkLand(void)
Handles landing if necessary.
glTexture * jumppoint_gfx
void space_gfxLoad(StarSystem *sys)
Loads all the graphics for a star system.
int space_hyperspace(Pilot *p)
Tries to get the pilot into hyperspace.
int space_load(void)
Loads the entire universe into ram - pretty big feat eh?
int space_isSimulation(void)
returns whether we're just simulating.
credits_t spob_commodityPriceAtTime(const Spob *p, const Commodity *c, ntime_t t)
Gets the price of a commodity at a spob at given time.
int system_index(const StarSystem *sys)
Gets the index of a star system.
int system_rmSpob(StarSystem *sys, const char *spobname)
Removes a spob from a star system.
int space_loadLua(void)
initializes the Lua for all the spobs.
void system_reconstructJumps(StarSystem *sys)
Reconstructs the jumps for a single system.
Represents an asteroid field anchor.
Represents an asteroid exclusion zone.
Defines a complete object.
Saves the layout decisions from positioning labeled objects on the overlay.
The representation of an in-game pilot.
Represents relative ship statistics as a linked list.
Represents the presence of a spob.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
const SimpleShader * marker
CommodityPrice * commodityPrice
Represents a star system.
AsteroidAnchor * asteroids
SystemPresence * presence
VirtualSpob ** spobs_virtual
AsteroidExclusion * astexclude
Represents presence in a system.
Basically modifies system parameters without creating any real objects.
Abstraction for rendering sprite sheets.