naev 0.12.5
ship.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
6#include "collision.h"
7#include "commodity.h"
8#include "gltf.h"
9#include "opengl.h"
10#include "outfit.h"
11#include "spfx.h"
12#include "vec3.h"
13
14/* Ship Flags. */
15#define SHIP_NOPLAYER \
16 ( 1 << 0 )
18#define SHIP_NOESCORT \
19 ( 1 << 1 )
20#define SHIP_UNIQUE \
21 ( 1 << 2 )
22#define SHIP_NEEDSGFX ( 1 << 3 )
23#define SHIP_3DTRAILS ( 1 << 4 )
24#define SHIP_3DMOUNTS ( 1 << 5 )
25#define ship_isFlag( s, f ) ( ( s )->flags & ( f ) )
26#define ship_setFlag( s, f ) ( ( s )->flags |= ( f ) )
27#define ship_rmFlag( s, f ) \
28 ( ( s )->flags &= ~( f ) )
29
38typedef enum ShipClass_ {
39 SHIP_CLASS_NULL,
40 /* Civilian. */
41 SHIP_CLASS_YACHT,
42 SHIP_CLASS_COURIER,
43 SHIP_CLASS_FREIGHTER,
44 SHIP_CLASS_ARMOURED_TRANSPORT,
46 SHIP_CLASS_BULK_FREIGHTER,
47 /* Military. */
48 SHIP_CLASS_SCOUT,
49 SHIP_CLASS_INTERCEPTOR,
50 SHIP_CLASS_FIGHTER,
51 SHIP_CLASS_BOMBER,
52 SHIP_CLASS_CORVETTE,
53 SHIP_CLASS_DESTROYER,
54 SHIP_CLASS_CRUISER,
55 SHIP_CLASS_BATTLESHIP,
56 SHIP_CLASS_CARRIER,
58 SHIP_CLASS_TOTAL,
59} ShipClass;
60
64typedef struct ShipMount_ {
66} ShipMount;
67
71typedef struct ShipOutfitSlot_ {
73 char *name;
76 int locked;
77 int visible;
78 const Outfit *data;
81
82#define SHIP_TRAIL_ALWAYS_UNDER \
83 ( 1 << 0 )
84
88typedef struct ShipTrailEmitter_ {
90 unsigned int flags;
93
97typedef struct Ship_ {
98 void *rawdata;
99 char *inherits;
100 char *name;
101 char *base_type;
103 char *base_path;
105 ShipClass class;
106 char *
109 int
111 int rarity;
112 int flags;
113
114 /* store stuff */
115 credits_t price;
116 char *license;
117 char *cond;
119 char *condstr;
123
124 /* movement */
125 double accel;
126 double turn;
127 double speed;
128
129 /* characteristics */
130 int crew;
131 double mass;
132 double cpu;
133 int fuel;
135 double cap_cargo;
136 double dt_default;
137
138 /* health */
139 double armour;
141 double shield;
143 double energy;
145 double dmg_absorb;
147
148 /* Graphics */
149 double size;
150 char *gfx_path;
157 char *gfx_comm;
160 int sx; /* TODO remove this and sy when possible. */
161 int sy;
162
163 /* Collision polygon */
165
166 /* Sound */
167 int sound;
169
170 /* Outfits */
178
179 /* Statistics. */
183
184 /* Tags. */
185 char **tags;
186
187 /* Lua function references. Set to LUA_NOREF if not used. */
188 char *lua_file;
189 nlua_env
191 double lua_dt;
198} Ship;
199
200/*
201 * Load/quit
202 */
203int ships_load( void );
204void ships_free( void );
205
206/*
207 * Getters.
208 */
209const Ship *ship_get( const char *name );
210const Ship *ship_getW( const char *name );
211const char *ship_existsCase( const char *name );
212const Ship *ship_getAll( void );
213const char *ship_class( const Ship *s );
214const char *ship_classDisplay( const Ship *s );
215const char *ship_classToString( ShipClass class );
216ShipClass ship_classFromString( const char *str );
217credits_t ship_basePrice( const Ship *s );
218credits_t ship_buyPrice( const Ship *s );
219int ship_size( const Ship *s );
220
221/*
222 * Rendering.
223 */
224void ship_renderFramebuffer( const Ship *s, GLuint fbo, double fw, double fh,
225 double dir, double engine_glow, double tilt,
226 double r, int sx, int sy, const glColour *c,
227 const Lighting *L );
228USE_RESULT glTexture *ship_gfxComm( const Ship *s, int size, double tilt,
229 double dir, const Lighting *Lscene );
230void ship_renderGfxStore( GLuint fbo, const Ship *s, int size, double dir,
231 double updown, double glow );
232USE_RESULT glTexture *ship_gfxStore( const Ship *s, int size, double dir,
233 double updown, double glow );
234int ship_gfxAnimated( const Ship *s );
235
236/*
237 * Misc.
238 */
239void ships_resize( void );
240int ship_gfxLoaded( const Ship *s );
241int ship_gfxLoadNeeded( void );
242int ship_gfxLoad( Ship *temp );
243int ship_compareTech( const void *arg1, const void *arg2 );
244double ship_maxSize( void );
static const double c[]
Definition rng.c:256
int ship_size(const Ship *s)
Gets the size of the ship.
Definition ship.c:526
ShipClass ship_classFromString(const char *str)
Gets the machine ship class identifier from a human readable string.
Definition ship.c:265
const char * ship_class(const Ship *s)
Gets the ship's class name in human readable form.
Definition ship.c:192
const char * ship_classDisplay(const Ship *s)
Gets the ship's display class in human readable form.
Definition ship.c:203
credits_t ship_basePrice(const Ship *s)
Gets the ship's base price (no outfits).
Definition ship.c:295
credits_t ship_buyPrice(const Ship *s)
The ship buy price, includes default outfits.
Definition ship.c:303
double ship_maxSize(void)
Gets the maximum size of a ship.
Definition ship.c:1826
const Ship * ship_getW(const char *name)
Gets a ship based on its name without warning.
Definition ship.c:113
int ships_load(void)
Loads all the ships in the data files.
Definition ship.c:1567
const Ship * ship_getAll(void)
Gets the array (array.h) of all ships.
Definition ship.c:134
int ship_gfxLoadNeeded(void)
Tries to load the graphics for all ships that need it.
Definition ship.c:603
void ships_free(void)
Frees all the ships.
Definition ship.c:1743
glTexture * ship_gfxComm(const Ship *s, int size, double tilt, double dir, const Lighting *Lscene)
Loads the ship's comm graphic.
Definition ship.c:418
int ship_compareTech(const void *arg1, const void *arg2)
Comparison function for qsort().
Definition ship.c:142
const char * ship_classToString(ShipClass class)
Gets the ship class name in human readable form.
Definition ship.c:216
int ship_gfxLoaded(const Ship *s)
Checks to see if a ship has loaded graphics.
Definition ship.c:595
int ship_gfxAnimated(const Ship *s)
Returns whether or not the ship has animated graphics.
Definition ship.c:513
void ship_renderFramebuffer(const Ship *s, GLuint fbo, double fw, double fh, double dir, double engine_glow, double tilt, double r, int sx, int sy, const glColour *c, const Lighting *L)
Renders a ship to a framebuffer.
Definition ship.c:1489
glTexture * ship_gfxStore(const Ship *s, int size, double dir, double updown, double glow)
Get the store gfx.
Definition ship.c:383
const Ship * ship_get(const char *name)
Gets a ship based on its name.
Definition ship.c:99
const char * ship_existsCase(const char *name)
Checks to see if an ship exists matching name (case insensitive).
Definition ship.c:123
int ship_gfxLoad(Ship *s)
Loads the graphics for a ship if necessary.
Definition ship.c:628
Defines a complete object.
Definition gltf.h:182
Pilot slot that can contain outfits.
Definition outfit.h:139
A ship outfit, depends radically on the type.
Definition outfit.h:372
Represents a ship weapon mount point.
Definition ship.h:64
vec3 pos
Definition ship.h:65
Ship outfit slot.
Definition ship.h:71
int exclusive
Definition ship.h:74
int required
Definition ship.h:75
const Outfit * data
Definition ship.h:78
int visible
Definition ship.h:77
char * name
Definition ship.h:73
ShipMount mount
Definition ship.h:79
OutfitSlot slot
Definition ship.h:72
int locked
Definition ship.h:76
Represents relative ship statistics as a linked list.
Definition shipstats.h:198
Represents ship statistics, properties ship can use.
Definition shipstats.h:229
Ship trail emitter.
Definition ship.h:88
const TrailSpec * trail_spec
Definition ship.h:91
unsigned int flags
Definition ship.h:90
Represents a space ship.
Definition ship.h:97
double shield_regen
Definition ship.h:142
double dt_default
Definition ship.h:136
double cap_cargo
Definition ship.h:135
char * desc_extra
Definition ship.h:122
glTexture * gfx_space
Definition ship.h:154
ShipStats stats_array
Definition ship.h:182
int flags
Definition ship.h:112
char * license
Definition ship.h:116
char * name
Definition ship.h:100
int sound
Definition ship.h:167
int fuel
Definition ship.h:133
void * rawdata
Definition ship.h:98
char * fabricator
Definition ship.h:120
char * description
Definition ship.h:121
int faction
Definition ship.h:108
int lua_init
Definition ship.h:193
GltfObject * gfx_3d
Definition ship.h:153
char * base_type
Definition ship.h:101
char * lua_file
Definition ship.h:188
char * class_display
Definition ship.h:107
credits_t price
Definition ship.h:115
int lua_update
Definition ship.h:195
double energy_regen
Definition ship.h:144
double armour
Definition ship.h:139
int fuel_consumption
Definition ship.h:134
double lua_dt
Definition ship.h:191
double armour_regen
Definition ship.h:140
CollPoly polygon
Definition ship.h:164
int noengine
Definition ship.h:152
int crew
Definition ship.h:130
ShipStatList * stats
Definition ship.h:181
double dmg_absorb
Definition ship.h:145
double engine_pitch
Definition ship.h:168
char * condstr
Definition ship.h:119
char * cond
Definition ship.h:117
glTexture * _gfx_store
Definition ship.h:156
int points
Definition ship.h:110
int lua_descextra
Definition ship.h:192
double cpu
Definition ship.h:132
double speed
Definition ship.h:127
ShipOutfitSlot * outfit_utility
Definition ship.h:174
double turn
Definition ship.h:126
char * desc_stats
Definition ship.h:180
char ** tags
Definition ship.h:185
Outfit const ** outfit_intrinsic
Definition ship.h:176
int rarity
Definition ship.h:111
char * inherits
Definition ship.h:99
glTexture * gfx_engine
Definition ship.h:155
double accel
Definition ship.h:125
int lua_cleanup
Definition ship.h:194
ShipOutfitSlot * outfit_weapon
Definition ship.h:175
nlua_env lua_env
Definition ship.h:190
char * polygon_path
Definition ship.h:151
double size
Definition ship.h:149
double energy
Definition ship.h:143
char * gfx_comm
Definition ship.h:157
char * base_path
Definition ship.h:103
ShipTrailEmitter * trail_emitters
Definition ship.h:159
int lua_explode_init
Definition ship.h:196
glTexture ** gfx_overlays
Definition ship.h:158
double shield
Definition ship.h:141
char * gfx_path
Definition ship.h:150
double mass
Definition ship.h:131
ShipOutfitSlot * outfit_structure
Definition ship.h:172
int lua_explode_update
Definition ship.h:197
represents a set of styles for trails.
Definition spfx.h:52
Abstraction for rendering sprite sheets.
Definition opengl_tex.h:43
Definition vec3.h:6