20#include "background.h"
22#include "damagetype.h"
23#include "dev_uniedit.h"
25#include "gatherable.h"
31#include "map_overlay.h"
39#include "nlua_pilot.h"
42#include "nlua_camera.h"
61#define XML_SPOB_TAG "spob"
62#define XML_SYSTEM_TAG "ssys"
64#define SPOB_GFX_EXTERIOR_PATH_W 400
65#define SPOB_GFX_EXTERIOR_PATH_H 400
68#define FLAG_POSSET (1<<0)
69#define FLAG_INTERFERENCESET (1<<1)
70#define FLAG_SERVICESSET (1<<2)
71#define FLAG_FACTIONSET (1<<3)
73#define DEBRIS_BUFFER 1000
75typedef struct spob_lua_file_s {
112static Spob *space_landQueueSpob = NULL;
129static int system_parse( StarSystem *system,
const char *filename );
136static int spob_cmp(
const void *p1,
const void *p2 );
140static int space_addMarkerSystem(
int sysid, MissionMarkerType type );
141static int space_addMarkerSpob(
int pntid, MissionMarkerType type );
142static int space_rmMarkerSystem(
int sysid, MissionMarkerType type );
143static int space_rmMarkerSpob(
int pntid, MissionMarkerType type );
151static int spob_lua_cmp(
const void *a,
const void *b );
152static nlua_env spob_lua_get(
int *mem,
const char *filename );
170 case SPOB_SERVICE_LAND:
return N_(
"Land");
171 case SPOB_SERVICE_INHABITED:
return N_(
"Inhabited");
172 case SPOB_SERVICE_REFUEL:
return N_(
"Refuel");
173 case SPOB_SERVICE_BAR:
return N_(
"Bar");
174 case SPOB_SERVICE_MISSIONS:
return N_(
"Missions");
175 case SPOB_SERVICE_COMMODITY:
return N_(
"Commodity");
176 case SPOB_SERVICE_OUTFITS:
return N_(
"Outfits");
177 case SPOB_SERVICE_SHIPYARD:
return N_(
"Shipyard");
178 case SPOB_SERVICE_BLACKMARKET:
return N_(
"Blackmarket");
188 if (strcasecmp(name,
"Land")==0)
189 return SPOB_SERVICE_LAND;
190 else if (strcasecmp(name,
"Inhabited")==0)
191 return SPOB_SERVICE_INHABITED;
192 else if (strcasecmp(name,
"Refuel")==0)
193 return SPOB_SERVICE_REFUEL;
194 else if (strcasecmp(name,
"Bar")==0)
195 return SPOB_SERVICE_BAR;
196 else if (strcasecmp(name,
"Missions")==0)
197 return SPOB_SERVICE_MISSIONS;
198 else if (strcasecmp(name,
"Commodity")==0)
199 return SPOB_SERVICE_COMMODITY;
200 else if (strcasecmp(name,
"Outfits")==0)
201 return SPOB_SERVICE_OUTFITS;
202 else if (strcasecmp(name,
"Shipyard")==0)
203 return SPOB_SERVICE_SHIPYARD;
204 else if (strcasecmp(name,
"Blackmarket")==0)
205 return SPOB_SERVICE_BLACKMARKET;
217 if (strcmp(
class,
"0")==0)
218 return _(
"Civilian Station");
219 else if (strcmp(
class,
"1")==0)
220 return _(
"Military Station");
221 else if (strcmp(
class,
"2")==0)
222 return _(
"Pirate Station");
223 else if (strcmp(
class,
"3")==0)
224 return _(
"Robotic Station");
225 else if (strcmp(
class,
"4")==0)
226 return _(
"Artificial Ecosystem");
227 else if (strcmp(
class,
"A")==0)
228 return _(
"Geothermal");
229 else if (strcmp(
class,
"B")==0)
230 return _(
"Geomorteus");
231 else if (strcmp(
class,
"C")==0)
232 return _(
"Geoinactive");
233 else if (strcmp(
class,
"D")==0)
234 return _(
"Asteroid/Moon");
235 else if (strcmp(
class,
"E")==0)
236 return _(
"Geoplastic");
237 else if (strcmp(
class,
"F")==0)
238 return _(
"Geometallic");
239 else if (strcmp(
class,
"G")==0)
240 return _(
"Geocrystaline");
241 else if (strcmp(
class,
"H")==0)
243 else if (strcmp(
class,
"I")==0)
244 return _(
"Gas Supergiant");
245 else if (strcmp(
class,
"J")==0)
246 return _(
"Gas Giant");
247 else if (strcmp(
class,
"K")==0)
248 return _(
"Adaptable");
249 else if (strcmp(
class,
"L")==0)
250 return _(
"Marginal");
251 else if (strcmp(
class,
"M")==0)
252 return _(
"Terrestrial");
253 else if (strcmp(
class,
"N")==0)
254 return _(
"Reducing");
255 else if (strcmp(
class,
"O")==0)
257 else if (strcmp(
class,
"P")==0)
258 return _(
"Glaciated");
259 else if (strcmp(
class,
"Q")==0)
260 return _(
"Variable");
261 else if (strcmp(
class,
"R")==0)
263 else if (strcmp(
class,
"S")==0 || strcmp(
class,
"T")==0)
264 return _(
"Ultragiants");
265 else if (strcmp(
class,
"X")==0 || strcmp(
class,
"Y")==0 || strcmp(
class,
"Z")==0)
279 const StarSystem *sys =
system_get( sysname );
293 const StarSystem *sys =
system_get( sysname );
305 economy_averageSeenPricesAtTime( p, tupdate );
329 for (
int i=0; i<
array_size(sys->asteroids); i++) {
331 density += ast->
area * ast->
density / ASTEROID_REF_AREA;
334 for (
int j=0; j<
array_size(sys->astexclude); j++) {
339 sys->asteroid_density = density;
351 p->presence.faction = faction;
378 p->services |= service;
380 if (service & SPOB_SERVICE_COMMODITY) {
385 if (p->commodities!=NULL)
401 DEBUG(_(
"Spob '%s' not in system. Not initializing economy."), p->name);
405 economy_initialiseSingleSystem( sys, p );
420 p->services &= ~service;
442 WARN(_(
"Renaming spob '%s', but not found in name stack!"),p->name);
457 double r = jp->radius * p->stats.jump_distance;
458 if (pilot_isFlag( p, PILOT_STEALTH ))
475 if (pilot_isFlag(p, PILOT_NOJUMP))
479 if (p->fuel < p->fuel_consumption)
491 d = vec2_dist2( &p->solid.pos, &jp->pos );
505 if (pilot_isFlag(p, PILOT_NOJUMP))
507 if (p->fuel < p->fuel_consumption)
513 pilot_setFlag(p, PILOT_HYP_PREP);
536 if (in->jumps[i].target == out)
541 WARN(_(
"Unable to find jump in point for '%s' in '%s': not connected"), out->name, in->name);
550 a = 2.*M_PI - jp->angle;
551 d = RNGF()*(HYPERSPACE_ENTER_MAX-HYPERSPACE_ENTER_MIN) + HYPERSPACE_ENTER_MIN;
552 if ((p!=NULL) && pilot_isFlag(p, PILOT_STEALTH))
563 ed *= p->stats.jump_distance;
564 if (pilot_isFlag(p, PILOT_STEALTH))
571 vec2_cset( pos, x, y );
575 vec2_cset( vel, HYPERSPACE_VEL*cos(a), HYPERSPACE_VEL*sin(a) );
634 int (*filter)(
Spob *p))
643 if (services && (spob_hasService(pnt, services) != services))
646 if ((filter != NULL) && !filter(pnt))
687double system_getClosest(
const StarSystem *sys,
int *pnt,
int *jp,
int *ast,
int *fie,
double x,
double y )
698 for (
int i=0; i<
array_size(sys->spobs); i++) {
700 Spob *p = sys->spobs[i];
701 if (!spob_isKnown(p))
703 td =
pow2(x-p->pos.x) +
pow2(y-p->pos.y);
711 for (
int i=0; i<
array_size(sys->asteroids); i++) {
713 for (
int k=0; k<f->nb; k++) {
718 if (as->
state != ASTEROID_FG)
736 for (
int i=0; i<
array_size(sys->jumps); i++) {
738 JumpPoint *j = &sys->jumps[i];
741 td =
pow2(x-j->pos.x) +
pow2(y-j->pos.y);
766double system_getClosestAng(
const StarSystem *sys,
int *pnt,
int *jp,
int *ast,
int *fie,
double x,
double y,
double ang )
776 for (
int i=0; i<
array_size(sys->spobs); i++) {
777 Spob *p = sys->spobs[i];
778 double ta = atan2( y - p->pos.y, x - p->pos.x);
779 if (
ABS(angle_diff(ang, ta)) <
ABS(angle_diff(ang, a))) {
786 for (
int i=0; i<
array_size(sys->asteroids); i++) {
788 for (
int k=0; k<f->nb; k++) {
793 if (as->
state != ASTEROID_FG)
797 if (
ABS(angle_diff(ang, ta)) <
ABS(angle_diff(ang, a))) {
807 for (
int i=0; i<
array_size(sys->jumps); i++) {
808 JumpPoint *j = &sys->jumps[i];
809 double ta = atan2( y - j->pos.y, x - j->pos.x);
810 if (
ABS(angle_diff(ang, ta)) <
ABS(angle_diff(ang, a))) {
828 if (sys_isKnown(sys))
832 for (
int i=0; i<
array_size(sys->jumps); i++) {
833 const JumpPoint *jp = sys->jumps[i].returnJump;
834 if (jp && jp_isUsable( jp ))
852 path = map_getJumpPath(
cur_system->name, NULL, sysname, 1, 1, NULL, NULL );
871 else if (jp_isUsable( jp ))
913 if (SDL_strcasestr( _(sys->name), sysname ) != NULL) {
914 names[len] = sys->name;
917 else if ((sys->features!=NULL) && SDL_strcasestr( _(sys->features), sysname ) != NULL) {
918 names[len] = sys->name;
922 for (
int j=0; j<
array_size(sys->spobs); j++) {
923 const Spob *spob = sys->spobs[j];
924 if ((spob->
feature != NULL) && SDL_strcasestr( _(spob->
feature), sysname ) != NULL) {
925 names[len] = sys->name;
948 const StarSystem *s1, *s2;
949 s1 = (
const StarSystem*) p1;
950 s2 = (
const StarSystem*) p2;
951 return strcmp(s1->name,s2->name);
970 WARN(_(
"System '%s' not found in stack"), sysname);
974 const StarSystem s = {.name = (
char*)sysname};
979 WARN(_(
"System '%s' not found in stack"), sysname);
1030 DEBUG(_(
"Spob '%s' is not placed in a system"), spobname);
1039 const Spob *pnt1, *pnt2;
1040 pnt1 = (
const Spob*) p1;
1041 pnt2 = (
const Spob*) p2;
1042 return strcmp(pnt1->
name,pnt2->
name);
1053 if (spobname==NULL) {
1054 WARN(_(
"Trying to find NULL spob…"));
1063 WARN(_(
"Spob '%s' not found in the universe"), spobname);
1067 const Spob p = {.name = (
char*)spobname};
1072 WARN(_(
"Spob '%s' not found in the universe"), spobname);
1117 spob_setFlag(p, SPOB_KNOWN);
1143 if (strcasecmp(
spob_stack[i].name,spobname)==0)
1163 if (SDL_strcasestr(
spob_name(spob), spobname ) != NULL) {
1164 names[len] = spob->
name;
1167 else if ((spob->
feature != NULL) && SDL_strcasestr( _(spob->
feature), spobname ) != NULL) {
1168 names[len] = spob->
name;
1199 return strcmp(v1->name,v2->name);
1211 WARN(_(
"Virtual Spob '%s' not found in the universe"), name);
1222JumpPoint*
jump_get(
const char* jumpname,
const StarSystem* sys )
1224 if (jumpname==NULL) {
1225 WARN(_(
"Trying to find NULL jump point..."));
1229 for (
int i=0; i<
array_size(sys->jumps); i++) {
1230 JumpPoint *jp = &sys->jumps[i];
1231 if (strcmp(jp->target->name,jumpname)==0)
1235 WARN(_(
"Jump point '%s' not found in %s"), jumpname, sys->name);
1248 for (
int i=0; i<
array_size(sys->jumps); i++) {
1249 JumpPoint *jp = &sys->jumps[i];
1250 if (jp->target == target)
1253 WARN(_(
"Jump point to '%s' not found in %s"), target->name, sys->name);
1262 if (jp_isFlag(jp, JP_HIDDEN))
1295 nlua_getenv( naevL, env,
"create" );
1296 if (lua_isnil(naevL,-1)) {
1297 WARN(_(
"Lua Spawn script for faction '%s' missing obligatory entry point 'create'."),
1310 nlua_getenv( naevL, env,
"spawn" );
1311 if (lua_isnil(naevL,-1)) {
1312 WARN(_(
"Lua Spawn script for faction '%s' missing obligatory entry point 'spawn'."),
1317 lua_pushnumber( naevL, p->curUsed );
1320 lua_pushnumber( naevL, p->value );
1323 if (nlua_pcall(env, n+1, 2)) {
1324 WARN(_(
"Lua Spawn script for faction '%s' : %s"),
1331 if (!lua_isnumber(naevL,-2)) {
1332 WARN(_(
"Lua spawn script for faction '%s' failed to return timer value."),
1337 p->timer += lua_tonumber(naevL,-2);
1339 if (lua_istable(naevL,-1)) {
1341 while (lua_next(naevL,-2) != 0) {
1345 if (!lua_istable(naevL,-1)) {
1346 WARN(_(
"Lua spawn script for faction '%s' returns invalid data (not a table)."),
1352 lua_getfield( naevL, -1,
"pilot" );
1354 WARN(_(
"Lua spawn script for faction '%s' returns invalid data (not a pilot)."),
1360 if (pilot == NULL) {
1365 lua_getfield( naevL, -1,
"presence" );
1366 if (!lua_isnumber(naevL,-1)) {
1367 WARN(_(
"Lua spawn script for faction '%s' returns invalid data (not a number)."),
1372 pilot->
presence = lua_tonumber(naevL,-1);
1373 if (pilot->
faction != p->faction) {
1375 WARN( _(
"Lua spawn script for faction '%s' actually spawned a '%s' pilot."),
1402 if (space_landQueueSpob != NULL) {
1403 land( space_landQueueSpob, 0 );
1404 space_landQueueSpob = NULL;
1456 int found_something = 0;
1477 hparam[0].
type = HOOK_PARAM_STRING;
1478 hparam[0].
u.
str =
"spob";
1479 hparam[1].
type = HOOK_PARAM_SPOB;
1480 hparam[1].
u.
la = pnt->
id;
1481 hparam[2].
type = HOOK_PARAM_SENTINEL;
1483 found_something = 1;
1498 if (jp_isFlag(jp,JP_EXITONLY))
1503 jp_setFlag( jp, JP_KNOWN );
1505 hparam[0].
type = HOOK_PARAM_STRING;
1506 hparam[0].
u.
str =
"jump";
1507 hparam[1].
type = HOOK_PARAM_JUMP;
1510 hparam[2].
type = HOOK_PARAM_SENTINEL;
1512 found_something = 1;
1516 if (found_something)
1551 const double fps_min_simulation =
fps_min;
1576 ERR(_(
"Cannot reinit system if there is no system previously loaded"));
1577 else if (sysname!=NULL) {
1580 WARN(_(
"System '%s' not found, trying random system!"),sysname);
1585 player_message(_(
"#oEntering System %s on %s."), _(sysname), nt);
1587 player_message(_(
"#rWARNING - Volatile nebula detected in %s! Taking %.1f %s damage!"), _(sysname),
cur_system->nebu_volatility, UNIT_POWER );
1608 if ((oldsys != NULL && oldsys->stats != NULL) ||
cur_system->stats != NULL) {
1613 if (pilot_isWithPlayer(p))
1614 pilot_setFlag( p, PILOT_HIDE );
1626 if ((
player.
p != NULL) && do_simulate)
1655 pilot_setFlag(
player.
p, PILOT_HIDE );
1658 if (pilot_isWithPlayer(p))
1659 pilot_setFlag( p, PILOT_HIDE );
1669 n = SYSTEM_SIMULATE_TIME_PRE / fps_min_simulation;
1670 for (
int i=0; i<n; i++)
1673 n = SYSTEM_SIMULATE_TIME_POST / fps_min_simulation;
1674 for (
int i=0; i<n; i++)
1686 pilot_rmFlag(
player.
p, PILOT_HIDE );
1689 if (pilot_isWithPlayer(p))
1690 pilot_rmFlag( p, PILOT_HIDE );
1711 Spob *p, *old_stack;
1721 memset( p, 0,
sizeof(
Spob) );
1723 p->presence.faction = -1;
1726 p->lua_env = LUA_NOREF;
1727 p->lua_mem = LUA_NOREF;
1728 p->lua_init = LUA_NOREF;
1729 p->lua_load = LUA_NOREF;
1730 p->lua_unload = LUA_NOREF;
1731 p->lua_can_land= LUA_NOREF;
1732 p->lua_land = LUA_NOREF;
1733 p->lua_render = LUA_NOREF;
1734 p->lua_update = LUA_NOREF;
1735 p->lua_comm = LUA_NOREF;
1736 p->lua_population = LUA_NOREF;
1737 p->lua_barbg = LUA_NOREF;
1755 return _(p->display);
1778 for (
int i=0; i<
array_size(spob_files); i++) {
1781 int ret =
spob_parse( &s, spob_files[i], stdList );
1792 free( spob_files[i] );
1820 for (
int i=0; i<
array_size(spob_files); i++) {
1825 free( spob_files[i] );
1831 free( spob_files[i] );
1835 node = doc->xmlChildrenNode;
1837 WARN(_(
"Malformed %s file: does not contain elements"), spob_files[i]);
1838 free( spob_files[i] );
1846 memset( &va, 0,
sizeof(va) );
1847 xmlr_attr_strd( node,
"name", va.
name );
1850 cur = node->children;
1853 if (xml_isNode(cur,
"presence")) {
1860 WARN(_(
"Unknown node '%s' in virtual spob '%s'"),cur->name,va.
name);
1861 }
while (xml_nextNode(cur));
1867 free( spob_files[i] );
1883 if (!spob_hasService( p, SPOB_SERVICE_INHABITED ))
1887 if (
areAllies(FACTION_PLAYER,p->presence.faction))
1892 if (
areEnemies(FACTION_PLAYER,p->presence.faction))
1902 if (!spob_hasService( p, SPOB_SERVICE_INHABITED )) {
1903 if (spob_hasService( p, SPOB_SERVICE_LAND ))
1909 if (
areAllies(FACTION_PLAYER,p->presence.faction))
1914 if (
areEnemies(FACTION_PLAYER,p->presence.faction))
1924 if (!spob_hasService( p, SPOB_SERVICE_INHABITED ))
1928 if (
areAllies(FACTION_PLAYER,p->presence.faction))
1933 if (
areEnemies(FACTION_PLAYER,p->presence.faction))
1935 return &cRestricted;
1945 if (p->land_override && (p->land_msg!=NULL)) {
1946 p->can_land = (p->land_override > 0);
1951 free( p->land_msg );
1956 if (p->lua_can_land != LUA_NOREF) {
1958 lua_rawgeti(naevL, LUA_REGISTRYINDEX, p->lua_can_land);
1959 if (nlua_pcall( p->lua_env, 0, 2 )) {
1960 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), p->name,
"can_land", lua_tostring(naevL,-1));
1965 p->can_land = lua_toboolean(naevL,-2);
1966 if (lua_isstring(naevL,-1))
1967 p->land_msg = strdup( lua_tostring(naevL,-1) );
1974 if (p->land_override<0) {
1975 p->land_msg = strdup(_(
"Landing permission denied."));
1977 else if (spob_hasService( p, SPOB_SERVICE_LAND ) || (p->land_override>0)) {
1979 p->land_msg = strdup(_(
"Landing permission granted."));
1988 lua_rawgeti( naevL, LUA_REGISTRYINDEX, spob->
lua_mem );
1989 nlua_setenv( naevL, spob->
lua_env,
"mem" );
2003 do { if ((x) != LUA_NOREF) { \
2004 luaL_unref( naevL, LUA_REGISTRYINDEX, (x) ); \
2022 if (spob->lua_file == NULL)
2026 nlua_env env = spob_lua_get( &mem, spob->lua_file );
2045 lua_newtable( naevL );
2046 lua_pushvalue( naevL, -1 );
2047 spob->
lua_mem = luaL_ref( naevL, LUA_REGISTRYINDEX );
2050 lua_rawgeti( naevL, LUA_REGISTRYINDEX, mem );
2051 lua_pushnil( naevL );
2052 while (lua_next(naevL,-2) != 0) {
2053 lua_pushvalue( naevL, -2 );
2054 lua_pushvalue( naevL, -2 );
2055 lua_remove( naevL, -3 );
2056 lua_settable( naevL, -5 );
2058 lua_pop( naevL, 2 );
2063 lua_rawgeti(naevL, LUA_REGISTRYINDEX, spob->
lua_init);
2065 if (nlua_pcall( spob->
lua_env, 1, 0 )) {
2066 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spob->
name,
"init", lua_tostring(naevL,-1));
2082 lua_rawgeti(naevL, LUA_REGISTRYINDEX, spob->
lua_load);
2083 if (nlua_pcall( spob->
lua_env, 0, 2 )) {
2084 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spob->
name,
"load", lua_tostring(naevL,-1));
2093 else if (lua_isnil(naevL,-2)) {
2097 WARN(_(
"Spob '%s' ran '%s' but got non-texture or nil return value!"), spob->
name,
"load" );
2098 spob->
radius = luaL_optnumber(naevL,-1,-1.);
2129 for (
int i=0; i<
array_size(sys->spobs); i++) {
2130 Spob *spob = sys->spobs[i];
2134 lua_rawgeti(naevL, LUA_REGISTRYINDEX, spob->
lua_unload);
2135 if (nlua_pcall( spob->
lua_env, 0, 0 )) {
2136 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spob->
name,
"unload", lua_tostring(naevL,-1));
2154 xmlNodePtr cur = node->children;
2159 xmlr_float(cur,
"base", ap->
base);
2160 xmlr_float(cur,
"bonus", ap->
bonus);
2161 xmlr_int(cur,
"range", ap->
range);
2162 if (xml_isNode(cur,
"faction")) {
2166 }
while (xml_nextNode(cur));
2181 xmlNodePtr node, parent;
2189 parent = doc->xmlChildrenNode;
2190 if (parent == NULL) {
2191 WARN(_(
"Malformed %s file: does not contain elements"), filename);
2197 memset( spob, 0,
sizeof(
Spob) );
2218 xmlr_attr_strd( parent,
"name", spob->
name );
2220 node = parent->xmlChildrenNode;
2223 xml_onlyNodes(node);
2225 xmlr_strd(node,
"display", spob->
display);
2226 xmlr_strd(node,
"feature", spob->
feature);
2227 xmlr_strd(node,
"lua", spob->lua_file);
2228 xmlr_float(node,
"radius", spob->
radius);
2229 if (xml_isNode(node,
"marker")) {
2230 const char *s = xml_get(node);
2231 spob->
marker = shaders_getSimple( s );
2232 xmlr_attr_float_def(node,
"scale",spob->
marker_scale,1.);
2233 if (spob->
marker == NULL)
2234 WARN(_(
"Spob '%s' has unknown marker shader '%s'!"), spob->
name, s );
2238 if (xml_isNode(node,
"GFX")) {
2239 xmlNodePtr cur = node->children;
2242 if (xml_isNode(cur,
"space")) {
2244 snprintf( str,
sizeof(str), SPOB_GFX_SPACE_PATH
"%s", xml_get(cur));
2249 if (xml_isNode(cur,
"exterior")) {
2251 snprintf( str,
sizeof(str), SPOB_GFX_EXTERIOR_PATH
"%s", xml_get(cur));
2256 if (xml_isNode(cur,
"comm")) {
2258 snprintf( str,
sizeof(str), SPOB_GFX_COMM_PATH
"%s", xml_get(cur));
2263 WARN(_(
"Unknown node '%s' in spob '%s'"),node->name,spob->
name);
2264 }
while (xml_nextNode(cur));
2267 else if (xml_isNode(node,
"pos")) {
2268 xmlr_attr_float( node,
"x", spob->
pos.
x );
2269 xmlr_attr_float( node,
"y", spob->
pos.
y );
2273 else if (xml_isNode(node,
"presence")) {
2279 else if (xml_isNode(node,
"general")) {
2280 xmlNodePtr cur = node->children;
2284 xmlr_strd(cur,
"class", spob->
class);
2286 xmlr_strd(cur,
"description", spob->
description );
2287 xmlr_float(cur,
"population", spob->
population );
2288 xmlr_float(cur,
"hide", spob->
hide );
2290 if (xml_isNode(cur,
"services")) {
2291 xmlNodePtr ccur = cur->children;
2295 xml_onlyNodes(ccur);
2297 if (xml_isNode(ccur,
"land"))
2298 spob->
services |= SPOB_SERVICE_LAND;
2299 else if (xml_isNode(ccur,
"refuel"))
2300 spob->
services |= SPOB_SERVICE_REFUEL | SPOB_SERVICE_INHABITED;
2301 else if (xml_isNode(ccur,
"bar"))
2302 spob->
services |= SPOB_SERVICE_BAR | SPOB_SERVICE_INHABITED;
2303 else if (xml_isNode(ccur,
"missions"))
2304 spob->
services |= SPOB_SERVICE_MISSIONS | SPOB_SERVICE_INHABITED;
2305 else if (xml_isNode(ccur,
"commodity"))
2306 spob->
services |= SPOB_SERVICE_COMMODITY | SPOB_SERVICE_INHABITED;
2307 else if (xml_isNode(ccur,
"outfits"))
2308 spob->
services |= SPOB_SERVICE_OUTFITS | SPOB_SERVICE_INHABITED;
2309 else if (xml_isNode(ccur,
"shipyard"))
2310 spob->
services |= SPOB_SERVICE_SHIPYARD | SPOB_SERVICE_INHABITED;
2311 else if (xml_isNode(ccur,
"nomissionspawn"))
2312 spob->
flags |= SPOB_NOMISNSPAWN;
2313 else if (xml_isNode(ccur,
"uninhabited"))
2314 spob->
flags |= SPOB_UNINHABITED;
2315 else if (xml_isNode(ccur,
"blackmarket"))
2316 spob->
services |= SPOB_SERVICE_BLACKMARKET;
2317 else if (xml_isNode(ccur,
"nolanes"))
2318 spob->
flags |= SPOB_NOLANES;
2320 WARN(_(
"Spob '%s' has unknown services tag '%s'"), spob->
name, ccur->name);
2321 }
while (xml_nextNode(ccur));
2324 else if (xml_isNode(cur,
"commodities")) {
2325 xmlNodePtr ccur = cur->children;
2327 if (xml_isNode(ccur,
"commodity")) {
2330 if (commodity_isFlag(com, COMMODITY_FLAG_STANDARD))
2335 }
while (xml_nextNode(ccur));
2337 else if (xml_isNode(cur,
"blackmarket")) {
2341 }
while (xml_nextNode(cur));
2344 else if (xml_isNode(node,
"tech")) {
2348 else if (xml_isNode(node,
"tags")) {
2349 xmlNodePtr cur = node->children;
2350 if (spob->
tags != NULL)
2351 WARN(_(
"Spob '%s' has duplicate '%s' node!"), spob->
name,
"tags");
2356 if (xml_isNode(cur,
"tag")) {
2357 const char *tmp = xml_get(cur);
2362 WARN(_(
"Spob '%s' has unknown node in tags '%s'."), spob->
name, cur->name );
2363 }
while (xml_nextNode(cur));
2366 WARN(_(
"Unknown node '%s' in spob '%s'"),node->name,spob->
name);
2367 }
while (xml_nextNode(node));
2370 if (spob_isFlag(spob, SPOB_UNINHABITED))
2371 spob->
services &= ~SPOB_SERVICE_INHABITED;
2374 spob_setFlag(spob, SPOB_RADIUS);
2377 if (spob->lua_file == NULL) {
2380 spob->lua_file = strdup( str );
2386 WARN(_(
"Can not find exterior graphic '%s' for spob '%s'!"), spob->
gfx_exterior, spob->
name);
2388 WARN(_(
"Can not find comm graphic '%s' for spob '%s'!"), spob->
gfx_comm, spob->
name);
2394#define MELEMENT(o,s) if (o) WARN(_("Spob '%s' missing '%s' element"), spob->name, s)
2396 MELEMENT( spob_hasService(spob,SPOB_SERVICE_LAND) &&
2398 MELEMENT( spob_hasService(spob,SPOB_SERVICE_INHABITED) &&
2401 MELEMENT(spob->
class==NULL,
"class");
2402 MELEMENT( spob_hasService(spob,SPOB_SERVICE_LAND) &&
2404 MELEMENT( spob_hasService(spob,SPOB_SERVICE_BAR) &&
2406 MELEMENT( spob_hasService(spob,SPOB_SERVICE_INHABITED) &&
2409 MELEMENT( spob_hasService(spob,SPOB_SERVICE_INHABITED) && (spob_hasService(spob,SPOB_SERVICE_OUTFITS) ||
2410 spob_hasService(spob,SPOB_SERVICE_SHIPYARD)) &&
2411 (spob->
tech==NULL),
"tech" );
2419 if (spob_hasService(spob, SPOB_SERVICE_COMMODITY)) {
2478 if (spob_hasService( spob, SPOB_SERVICE_COMMODITY ))
2479 economy_initialiseSingleSystem( sys, spob );
2499 WARN(_(
"Unable to remove spob '%s' from NULL system."), spobname);
2506 if (sys->spobs[i] == spob)
2511 WARN(_(
"Spob '%s' not found in system '%s' for removal."), spobname, sys->name);
2516 array_erase( &sys->spobs, &sys->spobs[i], &sys->spobs[i+1] );
2517 array_erase( &sys->spobsid, &sys->spobsid[i], &sys->spobsid[i+1] );
2529 WARN(_(
"Unable to find spob '%s' and system '%s' in spob<->system stack."),
2530 spobname, sys->name );
2574 WARN(_(
"Unable to remove virtual spob '%s' from NULL system."), spobname);
2579 for (i=0; i<
array_size(sys->spobs_virtual); i++)
2580 if (strcmp(sys->spobs_virtual[i]->name, spobname)==0)
2585 WARN(_(
"Virtual spob '%s' not found in system '%s' for removal."), spobname, sys->name);
2590 array_erase( &sys->spobs_virtual, &sys->spobs_virtual[i], &sys->spobs_virtual[i+1] );
2631 WARN(_(
"Unable to remove jump point '%s' from NULL system."), jumpname);
2638 if (&sys->jumps[i] == jump)
2643 WARN(_(
"Jump point '%s' not found in system '%s' for removal."), jumpname, sys->name);
2648 array_erase( &sys->jumps, &sys->jumps[i], &sys->jumps[i+1] );
2660 memset( sys, 0,
sizeof(StarSystem) );
2709 for (
int j=0; j<
array_size(sys->jumps); j++) {
2711 JumpPoint *jp = &sys->jumps[j];
2717 dx = jp->target->pos.x - sys->pos.x;
2718 dy = jp->target->pos.y - sys->pos.y;
2719 a = atan2( dy, dx );
2724 if (jp->flags & JP_AUTOPOS)
2725 vec2_pset( &jp->pos, sys->radius, a );
2729 jp->angle = 2.*M_PI-a;
2730 jp->cosa = cos(jp->angle);
2731 jp->sina = sin(jp->angle);
2746 sys->jumps[j].targetid = sys->jumps[j].target->id;
2757 for (
int j=0; j<
array_size(sys->spobsid); j++)
2758 sys->spobs[j] = &
spob_stack[ sys->spobsid[j] ];
2781 a->density = ASTEROID_DEFAULT_DENSITY;
2785 a->maxspeed = ASTEROID_DEFAULT_MAXSPEED;
2786 a->maxspin = ASTEROID_DEFAULT_MAXSPIN;
2787 a->accel = ASTEROID_DEFAULT_ACCEL;
2790 xmlr_attr_strd( node,
"label", a->label );
2793 cur = node->xmlChildrenNode;
2797 xmlr_float( cur,
"density", a->density );
2798 xmlr_float( cur,
"radius", a->radius );
2799 xmlr_float( cur,
"maxspeed", a->maxspeed );
2800 xmlr_float( cur,
"accel", a->accel );
2803 if (xml_isNode(cur,
"group")) {
2805 const char *name = xml_get(cur);
2806 xmlr_attr_float_def(cur,
"weight",w,1.);
2813 if (xml_isNode(cur,
"pos")) {
2816 xmlr_attr_float( cur,
"x", x );
2817 xmlr_attr_float( cur,
"y", y );
2820 vec2_cset( &a->pos, x, y );
2824 WARN(_(
"Asteroid Field in Star System '%s' has unknown node '%s'"), sys->name, node->name);
2825 }
while (xml_nextNode(cur));
2830#define MELEMENT(o,s) \
2831if (o) WARN(_("Asteroid Field in Star System '%s' has missing/invalid '%s' element"), sys->name, s)
2832 MELEMENT(!pos,
"pos");
2833 MELEMENT(a->radius<=0.,
"radius");
2856 memset( a, 0,
sizeof(*a) );
2862 cur = node->xmlChildrenNode;
2864 xml_onlyNodes( cur );
2866 xmlr_float( cur,
"radius", a->radius );
2869 if (xml_isNode(cur,
"pos")) {
2871 xmlr_attr_float( cur,
"x", x );
2872 xmlr_attr_float( cur,
"y", y );
2875 vec2_cset( &a->pos, x, y );
2878 WARN(_(
"Asteroid Exclusion Zone in Star System '%s' has unknown node '%s'"), sys->name, node->name);
2879 }
while (xml_nextNode(cur));
2881#define MELEMENT(o,s) \
2882if (o) WARN(_("Asteroid Exclusion Zone in Star System '%s' has missing/invalid '%s' element"), sys->name, s)
2883 MELEMENT(!pos,
"pos");
2884 MELEMENT(a->radius<=0.,
"radius");
2899 xmlNodePtr node, parent;
2908 parent = doc->xmlChildrenNode;
2909 if (parent == NULL) {
2910 WARN(_(
"Malformed %s file: does not contain elements"), filename);
2919 sys->ownerpresence = 0.;
2920 sys->nebu_hue = NEBULA_DEFAULT_HUE;
2921 sys->spacedust = -1;
2923 xmlr_attr_strd( parent,
"name", sys->name );
2925 node = parent->xmlChildrenNode;
2928 xml_onlyNodes(node);
2930 if (xml_isNode(node,
"pos")) {
2932 xmlr_attr_float( node,
"x", sys->pos.x );
2933 xmlr_attr_float( node,
"y", sys->pos.y );
2936 else if (xml_isNode(node,
"general")) {
2937 xmlNodePtr cur = node->children;
2940 xmlr_strd( cur,
"background", sys->background );
2941 xmlr_strd( cur,
"map_shader", sys->map_shader );
2942 xmlr_strd( cur,
"features", sys->features );
2943 xmlr_int( cur,
"spacedust", sys->spacedust );
2944 if (xml_isNode( cur,
"stars" )) {
2945 sys->spacedust = xml_getInt(cur);
2946 WARN(_(
"System '%s' is using deprecated field 'stars'. Use 'spacedust' instead!"), sys->name);
2948 xmlr_float( cur,
"radius", sys->radius );
2949 if (xml_isNode(cur,
"interference")) {
2951 sys->interference = xml_getFloat(cur);
2954 if (xml_isNode(cur,
"nebula")) {
2955 xmlr_attr_float( cur,
"volatility", sys->nebu_volatility );
2956 xmlr_attr_float_def( cur,
"hue", sys->nebu_hue, NEBULA_DEFAULT_HUE );
2957 sys->nebu_density = xml_getFloat(cur);
2960 if (xml_isNode(cur,
"nolanes")) {
2961 sys_setFlag( sys, SYSTEM_NOLANES );
2964 DEBUG(_(
"Unknown node '%s' in star system '%s'"),node->name,sys->name);
2965 }
while (xml_nextNode(cur));
2969 else if (xml_isNode(node,
"spobs")) {
2970 xmlNodePtr cur = node->children;
2973 if (xml_isNode(cur,
"spob")) {
2977 if (xml_isNode(cur,
"spob_virtual")) {
2981 DEBUG(_(
"Unknown node '%s' in star system '%s'"),node->name,sys->name);
2982 }
while (xml_nextNode(cur));
2986 if (xml_isNode(node,
"asteroids")) {
2987 xmlNodePtr cur = node->children;
2990 if (xml_isNode(cur,
"asteroid"))
2992 else if (xml_isNode(cur,
"exclusion"))
2994 }
while (xml_nextNode(cur));
2997 if (xml_isNode(node,
"stats")) {
2998 xmlNodePtr cur = node->children;
3003 ll->
next = sys->stats;
3007 WARN(_(
"System '%s' has unknown stat '%s'."), sys->name, cur->name);
3008 }
while (xml_nextNode(cur));
3012 if (xml_isNode(node,
"tags")) {
3013 xmlNodePtr cur = node->children;
3017 if (xml_isNode(cur,
"tag")) {
3018 const char *tmp = xml_get(cur);
3023 WARN(_(
"System '%s' has unknown node in tags '%s'."), sys->name, cur->name );
3024 }
while (xml_nextNode(cur));
3029 if (xml_isNode(node,
"jumps") || xml_isNode(node,
"asteroids"))
3032 DEBUG(_(
"Unknown node '%s' in star system '%s'"),node->name,sys->name);
3033 }
while (xml_nextNode(node));
3042 sys->nebu_hue /= 360.;
3045 if (sys->map_shader != NULL)
3048#define MELEMENT(o,s) if (o) WARN(_("Star System '%s' missing '%s' element"), sys->name, s)
3049 if (sys->name == NULL) WARN(_(
"Star System '%s' missing 'name' tag"), sys->name);
3051 MELEMENT(sys->spacedust<0,
"spacedust");
3052 MELEMENT(sys->radius==0.,
"radius");
3098 for (
int i=0; i<
array_size(sys->presence); i++) {
3099 for (
int j=0; j<
array_size(sys->spobs); j++) {
3100 Spob *pnt = sys->spobs[j];
3126 xmlr_attr_strd( node,
"target", buf );
3128 WARN(_(
"JumpPoint node for system '%s' has no target attribute."), sys->name);
3132 if (target == NULL) {
3133 WARN(_(
"JumpPoint node for system '%s' has invalid target '%s'."), sys->name, buf );
3140 for (
int i=0; i<
array_size(sys->jumps); i++) {
3141 JumpPoint *jp = &sys->jumps[i];
3142 if (jp->targetid != target->id)
3145 WARN(_(
"Star System '%s' has duplicate jump point to '%s'."),
3146 sys->name, target->name );
3153 memset( j, 0,
sizeof(JumpPoint) );
3156 xmlr_attr_float_def( node,
"x", x, HUGE_VAL );
3157 xmlr_attr_float_def( node,
"y", y, HUGE_VAL );
3160 xmlr_attr_strd( node,
"type", buf );
3162 else if (strcmp(buf,
"hidden") == 0)
3163 jp_setFlag(j,JP_HIDDEN);
3164 else if (strcmp(buf,
"exitonly") == 0)
3165 jp_setFlag(j,JP_EXITONLY);
3168 xmlr_attr_float_def( node,
"hide", j->hide, HIDE_DEFAULT_JUMP);
3172 j->targetid = j->target->id;
3175 if (x < HUGE_VAL && y < HUGE_VAL)
3176 vec2_cset( &j->pos, x, y );
3178 jp_setFlag(j,JP_AUTOPOS);
3200 xmlr_attr_strd( node,
"target", buf );
3202 WARN(_(
"JumpPoint node for system '%s' has no target attribute."), sys->name);
3206 if (target == NULL) {
3207 WARN(_(
"JumpPoint node for system '%s' has invalid target '%s'."), sys->name, buf );
3214 for (
int i=0; i<
array_size(sys->jumps); i++) {
3215 JumpPoint *jp = &sys->jumps[i];
3216 if (jp->targetid != target->id)
3219 WARN(_(
"Star System '%s' has duplicate jump point to '%s'."),
3220 sys->name, target->name );
3227 memset( j, 0,
sizeof(JumpPoint) );
3232 j->targetid = j->target->id;
3238 cur = node->xmlChildrenNode;
3240 xmlr_float( cur,
"radius", j->radius );
3243 if (xml_isNode(cur,
"pos")) {
3245 xmlr_attr_float( cur,
"x", x );
3246 xmlr_attr_float( cur,
"y", y );
3249 vec2_cset( &j->pos, x, y );
3251 else if (xml_isNode(cur,
"autopos"))
3252 jp_setFlag(j,JP_AUTOPOS);
3253 else if (xml_isNode(cur,
"hidden"))
3254 jp_setFlag(j,JP_HIDDEN);
3255 else if (xml_isNode(cur,
"exitonly"))
3256 jp_setFlag(j,JP_EXITONLY);
3257 else if (xml_isNode(cur,
"nolanes"))
3258 jp_setFlag(j,JP_NOLANES);
3259 else if (xml_isNode(cur,
"hide")) {
3260 xmlr_float( cur,
"hide", j->hide );
3262 }
while (xml_nextNode(cur));
3264 if (!jp_isFlag(j,JP_AUTOPOS) && !pos)
3265 WARN(_(
"JumpPoint in system '%s' is missing pos element but does not have autopos flag."), sys->name);
3278 xmlNodePtr parent, node;
3285 parent = doc->xmlChildrenNode;
3286 if (parent == NULL) {
3291 node = parent->xmlChildrenNode;
3293 if (xml_isNode(node,
"jumps")) {
3294 xmlNodePtr cur = node->children;
3296 if (xml_isNode(cur,
"jump"))
3298 }
while (xml_nextNode(cur));
3300 }
while (xml_nextNode(node));
3370 Uint32 time = SDL_GetTicks();
3372 char **system_files;
3383 for (
int i=0; i<
array_size(system_files); i++) {
3391 sys.filename = system_files[i];
3420 DEBUG( n_(
"Loaded %d Star System",
3422 DEBUG( n_(
" with %d Space Object in %.3f s",
3426 DEBUG( n_(
"Loaded %d Star System",
3428 DEBUG( n_(
" with %d Space Object",
3505 if (!jp_isUsable(jp))
3511 else if (jp_isFlag(jp, JP_HIDDEN))
3519 if (jp->hide == 0.) {
3530 if (p->lua_render != LUA_NOREF) {
3533 lua_rawgeti(naevL, LUA_REGISTRYINDEX, p->lua_render);
3534 if (nlua_pcall( p->lua_env, 0, 0 )) {
3535 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), p->name,
"render", lua_tostring(naevL,-1));
3539 else if (p->gfx_space)
3548 if (p->lua_update == LUA_NOREF)
3552 lua_rawgeti(naevL, LUA_REGISTRYINDEX, p->lua_update);
3553 lua_pushnumber(naevL, dt);
3554 lua_pushnumber(naevL,
real_dt);
3555 if (nlua_pcall( p->lua_env, 2, 0 )) {
3556 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), p->name,
"update", lua_tostring(naevL,-1));
3583 free(spb->lua_file);
3588 free( spb->
tags[j] );
3604 if (spb->
tech != NULL)
3631 free(sys->filename);
3633 free(sys->background);
3634 free(sys->map_shader);
3635 free(sys->features);
3644 free( sys->tags[j] );
3648 for (
int j=0; j <
array_size(sys->asteroids); j++)
3668 glDeleteProgram( ms->
program );
3681 sys_rmFlag(sys,SYSTEM_KNOWN);
3682 sys_rmFlag(sys,SYSTEM_HIDDEN);
3683 sys_rmFlag(sys,SYSTEM_PMARKED);
3685 jp_rmFlag(&sys->jumps[j],JP_KNOWN);
3700 sys_rmFlag( sys, SYSTEM_MARKED );
3701 sys->markers_computer = 0;
3702 sys->markers_plot = 0;
3703 sys->markers_high = 0;
3704 sys->markers_low = 0;
3708 spob_rmFlag( pnt, SPOB_MARKED );
3722static int space_addMarkerSystem(
int sysid, MissionMarkerType type )
3734 case SYSMARKER_COMPUTER:
3735 markers = &ssys->markers_computer;
3738 markers = &ssys->markers_low;
3740 case SYSMARKER_HIGH:
3741 markers = &ssys->markers_high;
3743 case SYSMARKER_PLOT:
3744 markers = &ssys->markers_plot;
3747 WARN(_(
"Unknown marker type."));
3753 sys_setFlag(ssys, SYSTEM_MARKED);
3758static int space_addMarkerSpob(
int pntid, MissionMarkerType type )
3761 MissionMarkerType stype;
3768 spob_setFlag( pnt, SPOB_MARKED );
3773 WARN(_(
"Marking spob '%s' that is not in any system!"), pnt->
name);
3776 stype = mission_markerTypeSpobToSystem( type );
3790 case SYSMARKER_COMPUTER:
3792 case SYSMARKER_HIGH:
3793 case SYSMARKER_PLOT:
3794 return space_addMarkerSystem( objid, type );
3795 case SPOBMARKER_COMPUTER:
3796 case SPOBMARKER_LOW:
3797 case SPOBMARKER_HIGH:
3798 case SPOBMARKER_PLOT:
3799 return space_addMarkerSpob( objid, type );
3801 WARN(_(
"Unknown marker type."));
3807static int space_rmMarkerSystem(
int sys, MissionMarkerType type )
3819 case SYSMARKER_COMPUTER:
3820 markers = &ssys->markers_computer;
3823 markers = &ssys->markers_low;
3825 case SYSMARKER_HIGH:
3826 markers = &ssys->markers_high;
3828 case SYSMARKER_PLOT:
3829 markers = &ssys->markers_plot;
3832 WARN(_(
"Unknown marker type."));
3838 if (*markers <= 0) {
3839 sys_rmFlag(ssys, SYSTEM_MARKED);
3846static int space_rmMarkerSpob(
int pntid, MissionMarkerType type )
3850 MissionMarkerType stype;
3856 spob_rmFlag( pnt, SPOB_MARKED );
3862 stype = mission_markerTypeSpobToSystem( type );
3876 case SYSMARKER_COMPUTER:
3878 case SYSMARKER_HIGH:
3879 case SYSMARKER_PLOT:
3880 return space_rmMarkerSystem( objid, type );
3881 case SPOBMARKER_COMPUTER:
3882 case SPOBMARKER_LOW:
3883 case SPOBMARKER_HIGH:
3884 case SPOBMARKER_PLOT:
3885 return space_rmMarkerSpob( objid, type );
3887 WARN(_(
"Unknown marker type."));
3900 xmlw_startElem(writer,
"space");
3904 if (!sys_isKnown(sys))
3907 xmlw_startElem(writer,
"known");
3908 xmlw_attr(writer,
"sys",
"%s",sys->name);
3909 if (sys_isFlag(sys, SYSTEM_PMARKED))
3910 xmlw_attr(writer,
"pmarked",
"%s",
"true");
3911 if (sys->note != NULL)
3912 xmlw_attr(writer,
"note",
"%s",sys->note);
3913 for (
int j=0; j<
array_size(sys->spobs); j++) {
3914 if (!spob_isKnown(sys->spobs[j]))
3916 xmlw_elem(writer,
"spob",
"%s", sys->spobs[j]->name);
3919 for (
int j=0; j<
array_size(sys->jumps); j++) {
3920 if (!jp_isKnown(&sys->jumps[j]))
3922 xmlw_elem(writer,
"jump",
"%s",(&sys->jumps[j])->target->name);
3925 xmlw_endElem(writer);
3927 xmlw_endElem(writer);
3944 node = parent->xmlChildrenNode;
3948 xml_onlyNodes(node);
3949 if (!xml_isNode(node,
"space"))
3952 cur = node->xmlChildrenNode;
3957 xml_onlyNodes( cur );
3958 if (!xml_isNode(cur,
"known"))
3961 xmlr_attr_strd(cur,
"sys",str);
3970 sys_setFlag(sys,SYSTEM_KNOWN);
3972 xmlr_attr_strd(cur,
"pmarked",str);
3974 sys_setFlag(sys,SYSTEM_PMARKED);
3978 xmlr_attr_strd(cur,
"note",str);
3980 xmlr_attr_strd(cur,
"note",sys->note);
3985 }
while (xml_nextNode(cur));
3986 }
while (xml_nextNode(node));
4000 xmlNodePtr node = parent->xmlChildrenNode;
4002 if (xml_isNode(node,
"spob")) {
4007 else if (xml_isNode(node,
"jump")) {
4008 JumpPoint *jp =
jump_get(xml_get(node), sys);
4010 jp_setFlag(jp,JP_KNOWN);
4012 }
while (xml_nextNode(node));
4031 WARN(
"sys == NULL");
4036 for (
int i=0; i <
array_size(sys->presence); i++)
4037 if (sys->presence[i].faction == faction)
4043 sys->presence[n].faction = faction;
4060 double base = ap->
base;
4061 double bonus = ap->
bonus;
4062 double range = ap->
range;
4068 WARN(
"sys == NULL");
4077 if ((base == 0.) && (bonus == 0.))
4085 sys->presence[id].base =
MAX( sys->presence[
id].base, base );
4086 sys->presence[id].bonus += bonus;
4087 sys->presence[id].value = sys->presence[id].base + sys->presence[id].bonus;
4090 sys->presence[x].base =
MAX( sys->presence[x].base,
MAX(0., base*fgens[i].weight) );
4091 sys->presence[x].bonus +=
MAX(0., bonus*fgens[i].weight);
4092 sys->presence[x].value = sys->presence[x].base + sys->presence[x].bonus;
4106 for (
int i=0; i <
array_size(sys->jumps); i++) {
4107 if (sys->jumps[i].target->spilled == 0 && (usehidden || !jp_isFlag( &sys->jumps[i], JP_HIDDEN )) && !jp_isFlag( &sys->jumps[i], JP_EXITONLY )) {
4109 sys->jumps[i].target->spilled = 1;
4122 while (curSpill < range) {
4133 for (
int i=0; i<
array_size(cur->jumps); i++) {
4134 if (cur->jumps[i].target->spilled == 0 && (usehidden || !jp_isFlag( &cur->jumps[i], JP_HIDDEN )) && !jp_isFlag( &cur->jumps[i], JP_EXITONLY )) {
4136 cur->jumps[i].target->spilled = 1;
4142 spillfactor = 1. / (2. + (double)curSpill);
4143 cur->presence[x].base =
MAX( cur->presence[x].base, base * spillfactor );
4144 cur->presence[x].bonus += bonus * spillfactor;
4145 cur->presence[x].value = cur->presence[x].base + cur->presence[x].bonus;
4149 cur->presence[y].base =
MAX( cur->presence[y].base,
MAX(0., base*spillfactor*fgens[i].weight) );
4150 cur->presence[y].bonus +=
MAX(0., bonus*spillfactor*fgens[i].weight );
4151 cur->presence[y].value = cur->presence[y].base + cur->presence[y].bonus;
4186 WARN(
"sys == NULL");
4192 for (
int i=0; i <
array_size(sys->presence); i++) {
4193 if (sys->presence[i].faction == faction)
4194 return MAX(sys->presence[i].value, 0.);
4215 WARN(
"sys == NULL");
4221 for (
int i=0; i <
array_size(sys->presence); i++) {
4222 if (sys->presence[i].faction == faction) {
4223 *base = sys->presence[i].base;
4224 *bonus = sys->presence[i].bonus;
4225 return MAX(sys->presence[i].value, 0);
4245 WARN(
"sys == NULL");
4255 for (
int i=0; i<
array_size(sys->spobs_virtual); i++)
4256 for (
int j=0; j<
array_size(sys->spobs_virtual[i]->presences); j++)
4298 WARN(
"sys == NULL");
4303 for (
int i=0; i <
array_size(sys->spobs); i++)
4320 sys->presence[id].curUsed -= amount;
4323 presence = &sys->presence[id];
4324 presence->
curUsed =
MAX( 0, sys->presence[
id].curUsed );
4330 nlua_getenv( naevL, env,
"decrease" );
4331 if (lua_isnil(naevL,-1)) {
4335 lua_pushnumber( naevL, presence->
curUsed );
4336 lua_pushnumber( naevL, presence->
value );
4337 lua_pushnumber( naevL, presence->
timer );
4340 if (nlua_pcall(env, 3, 1)) {
4341 WARN(_(
"Lua decrease script for faction '%s' : %s"),
4348 if (!lua_isnumber(naevL,-1)) {
4349 WARN(_(
"Lua spawn script for faction '%s' failed to return timer value."),
4354 presence->
timer = lua_tonumber(naevL,-1);
4366 space_landQueueSpob = pnt;
4377 static char pop[STRMAX_SHORT];
4383 if (nlua_pcall( spb->
lua_env, 0, 1 )) {
4384 WARN(_(
"Spob '%s' failed to run '%s':\n%s"), spb->
name,
"population", lua_tostring(naevL,-1));
4389 scnprintf( pop,
sizeof(pop),
"%s", luaL_checkstring(naevL,-1) );
4400 snprintf( pop,
sizeof(pop),
"%.0f", p );
4402 char scratch[STRMAX_SHORT];
4403 const char *digits[] = {
"\xe2\x81\xb0",
"\xc2\xb9",
"\xc2\xb2",
"\xc2\xb3",
"\xe2\x81\xb4",
"\xe2\x81\xb5",
"\xe2\x81\xb6",
"\xe2\x81\xb7",
"\xe2\x81\xb8",
"\xe2\x81\xb9"};
4404 int state = 0, COEF = 0, E = 1, EXP = 4;
4405 size_t l =
scnprintf( pop,
sizeof(pop), _(
"roughly ") );
4406 snprintf( scratch,
sizeof(scratch),
"%.1e", p );
4407 for (
const char *
c = scratch; *
c;
c++) {
4408 if (state == COEF && *
c !=
'e')
4409 l +=
scnprintf( &pop[l],
sizeof(pop)-l,
"%c", *
c );
4410 else if (state == COEF ) {
4411 l +=
scnprintf( &pop[l],
sizeof(pop)-l,
"%s",
"\xc2\xb7" "10" );
4414 else if (state == E && (*
c ==
'+' || *
c ==
'0'))
4418 l +=
scnprintf( &pop[l],
sizeof(pop)-l,
"%s", digits[*
c-
'0'] );
4441 if (strcmp(t->
name,name)==0)
4449 ms->
name = strdup( name );
4450 ms->
program = gl_program_vert_frag(
"system_map.vert", name, NULL );
4453 ms->
time = glGetUniformLocation( ms->
program,
"time" );
4455 ms->
alpha = glGetUniformLocation( ms->
program,
"alpha" );
4460static int spob_lua_cmp(
const void *a,
const void *b )
4467static nlua_env spob_lua_get(
int *mem,
const char *filename )
4485 WARN(_(
"Failed to read spob Lua '%s'!"), filename );
4489 nlua_env env = nlua_newEnv();
4500 lua_newtable(naevL);
4501 lua_pushvalue(naevL, -1);
4502 lf->
lua_mem = luaL_ref( naevL, LUA_REGISTRYINDEX );
4503 nlua_setenv(naevL, env,
"mem");
4506 if (nlua_dobufenv(env, dat, sz, filename) != 0) {
4508 WARN(_(
"Lua Spob '%s' error:\n%s"), filename, lua_tostring(naevL,-1));
4510 spob_lua_free( lf );
4525 nlua_freeEnv( lf->
env );
4526 luaL_unref( naevL, LUA_REGISTRYINDEX, lf->
lua_mem );
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_shrink(ptr_array)
Shrinks memory to fit only ‘size’ elements.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void asteroids_render(void)
Renders the current systems' spobs.
void asteroids_computeInternals(AsteroidAnchor *a)
Updates internal alues of an asteroid field.
void asteroids_free(void)
Cleans up the system.
int asteroids_load(void)
Loads the asteroids.
void asteroid_free(AsteroidAnchor *ast)
Frees an asteroid anchor.
AsteroidTypeGroup * astgroup_getName(const char *name)
Gets an asteroid type group by name.
void asteroids_init(void)
Initializes the system.
void asteroids_renderOverlay(void)
Renders the system overlay.
void asteroids_update(double dt)
Controls fleet spawning.
void background_clear(void)
Cleans up the background stuff.
void background_initDust(int n)
Initializes background dust.
void background_renderOverlay(double dt)
Renders the background overlay.
void background_render(double dt)
Render the background.
int background_load(const char *name)
Loads a background script by name.
double CollideCircleIntersection(const vec2 *p1, double r1, const vec2 *p2, double r2)
Calculates the area of intersection between two circles.
Commodity * commodity_get(const char *name)
Gets a commodity by name.
Commodity ** standard_commodities(void)
Return an array (array.h) of standard commodities. Free with array_free. (Don't free contents....
int dtype_get(const char *name)
Gets the id of a dtype based on name.
void economy_addQueuedUpdate(void)
Increments the queued update counter.
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.
void economy_initialiseCommodityPrices(void)
Initialises commodity prices for the sinusoidal economy model.
void economy_clearSingleSpob(Spob *p)
Clears all economy knowledge of a given spob. Used by the unidiff system.
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.
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 pl...
int faction_isFaction(int f)
Checks whether or not a faction is valid.
int areEnemies(int a, int b)
Checks whether two factions are enemies.
void factions_clearDynamic(void)
Clears dynamic factions.
const char * faction_name(int f)
Gets a factions "real" (internal) name.
const FactionGenerator * faction_generators(int f)
Gets the faction's generators.
int faction_usesHiddenJumps(int f)
Checks to see if a faction uses hidden jumps.
nlua_env faction_getScheduler(int f)
Gets the state associated to the faction scheduler.
int faction_get(const char *name)
Gets a faction ID by name.
int areAllies(int a, int b)
Checks whether two factions are allies or not.
void gatherable_free(void)
Frees all the gatherables.
void gatherable_update(double dt)
Updates all gatherable objects.
void gatherable_render(void)
Renders all the gatherables.
void gui_setSystem(void)
Player just changed their system.
void gui_updateFaction(void)
Player's relationship with a faction was modified.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
void player_messageToggle(int enable)
Toggles if player should receive messages.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
void land(Spob *p, int load)
Opens up all the land dialogue stuff.
int music_choose(const char *situation)
Actually runs the music stuff, based on situation.
void naev_renderLoadscreen(void)
Renders the loadscreen if necessary.
void update_routine(double dt, int dohooks)
Actually runs the updates.
Header file with generic functions and naev-specifics.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
int ndata_matchExt(const char *path, const char *ext)
Sees if a file matches an extension.
char ** ndata_listRecursive(const char *path)
Lists all the visible files in a directory, at any depth.
void nebu_update(double dt)
Updates visibility and stuff.
void nebu_renderOverlay(const double dt)
Renders the nebula overlay (hides what player can't see).
void nebu_render(const double dt)
Renders the nebula.
void nebu_prep(double density, double volatility, double hue)
Prepares the nebualae to be rendered.
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
int nlua_refenvtype(nlua_env env, const char *name, int type)
Gets the reference of a global in a lua environment if it matches a type.
int nlua_loadCamera(nlua_env env)
Loads the camera library.
int nlua_loadGFX(nlua_env env)
Loads the graphics library.
LuaPilot lua_topilot(lua_State *L, int ind)
Lua bindings to interact with pilots.
int lua_ispilot(lua_State *L, int ind)
Checks to see if ind is a pilot.
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
glTexture * lua_totex(lua_State *L, int ind)
Lua bindings to interact with OpenGL textures.
int lua_istex(lua_State *L, int ind)
Checks to see if ind is a texture.
void arrayShuffle(void **array)
Randomly sorts an array (array.h) of pointers in place with the Fisher-Yates shuffle.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
char * ntime_pretty(ntime_t t, int d)
Gets the time in a pretty human readable format.
void ntime_allowUpdate(int enable)
Allows the time to update when the game is updating.
xmlDocPtr xml_parsePhysFS(const char *filename)
Analogous to xmlParseMemory/xmlParseFile.
void gl_renderSprite(const glTexture *sprite, double bx, double by, int sx, int sy, const glColour *c)
Blits a sprite, position is relative to the player.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
glTexture * gl_newSprite(const char *path, const int sx, const int sy, const unsigned int flags)
Loads the texture immediately, but also sets it as a sprite.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_getSpriteFromDir(int *x, int *y, const glTexture *t, const double dir)
Sets x and y to be the appropriate sprite for glTexture using dir.
void gl_freeTexture(glTexture *texture)
Frees a texture.
void pilots_clean(int persist)
Cleans up the pilot stack - leaves the player.
void pilot_clearTimers(Pilot *pilot)
Clears the pilot's timers.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
static Pilot ** pilot_stack
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
void pilots_newSystem(void)
Updates pilot state which depends on the system (sensor range, nebula trails...)
double pilot_hit(Pilot *p, const Solid *w, const Pilot *pshooter, const Damage *dmg, const Outfit *outfit, int lua_mem, int reset)
Damages the pilot.
int pilot_inRangeSpob(const Pilot *p, int target)
Check to see if a spob is in sensor range of the pilot.
int pilot_inRangeJump(const Pilot *p, int i)
Check to see if a jump point is in sensor range of the pilot.
int pilot_inRangeAsteroid(const Pilot *p, int ast, int fie)
Check to see if an asteroid is in sensor range of the pilot.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
void pilot_lockClear(Pilot *p)
Clears pilot's missile lockon timers.
void player_checkLandAck(void)
Revokes landing authorization if the player's reputation is too low.
void player_clear(void)
Clears the targets.
void * q_dequeue(Queue q)
Dequeues an item.
int q_isEmpty(Queue q)
Checks if the queue is empty.
void q_destroy(Queue q)
Destroys a queue.
Queue q_create(void)
Creates a queue.
void q_enqueue(Queue q, void *data)
Enqueues an item.
void ss_free(ShipStatList *ll)
Frees a list of ship stats.
ShipStatList * ss_listFromXML(xmlNodePtr node)
Creates a shipstat list element from an xml node.
int ss_sort(ShipStatList **ll)
Sorts the ship stats, useful if doing saving stuff.
int sound_env(SoundEnv_t env_type, double param)
Sets up the sound environment.
static int spob_cmp(const void *p1, const void *p2)
Comparison function for qsort'ing Spob by name.
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.
int system_addJumpDiff(StarSystem *sys, xmlNodePtr node)
Adds a jump point to a star system from a diff.
static int spobs_load(void)
Loads all the spobs in the game.
void spob_averageSeenPricesAtTime(const Spob *p, const ntime_t tupdate)
Adds cost of commodities on spob p to known statistics at time t.
static int system_cmp(const void *p1, const void *p2)
Comparison function for qsort'ing StarSystem by name.
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.
static void space_renderSpob(const Spob *p)
Renders a spob.
static int sys_cmpSysFaction(const void *a, const void *b)
Compares two system presences.
int spob_luaInit(Spob *spob)
Updatse the spob's internal Lua stuff.
static void system_init(StarSystem *sys)
Initializes a new star system with null memory.
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 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.
static char ** systemname_stack
double system_getPresenceFull(const StarSystem *sys, int faction, double *base, double *bonus)
Get the presence of a faction in a system.
static int spob_parse(Spob *spob, const char *filename, Commodity **stdList)
Parses a spob from an xml node.
Spob * spob_getAll(void)
Gets an array (array.h) of all spobs.
int space_sysLoad(xmlNodePtr parent)
Loads player's space properties from an XML node.
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.
static char ** spobname_stack
int system_addVirtualSpob(StarSystem *sys, const char *spobname)
Adds a virtual spob to a system.
static int system_parseJumpPointDiff(const xmlNodePtr node, StarSystem *sys)
Parses a single jump point for a system, from unidiff.
const char * space_getRndSpob(int landable, unsigned int services, int(*filter)(Spob *p))
Gets the name of a random spob.
int system_rmJump(StarSystem *sys, const char *jumpname)
Removes a jump point from a star system.
static spob_lua_file * spob_lua_stack
void space_update(double dt, double real_dt)
Controls fleet spawning.
static int systems_load(void)
Loads the entire systems, needs to be called after spobs_load.
StarSystem * system_getIndex(int id)
Get the system by its index.
int spob_index(const Spob *p)
Gets the ID of a spob.
int spob_hasSystem(const Spob *spb)
Get whether or not a spob has a system (i.e. is on the map).
static int space_simulating
#define FLAG_INTERFERENCESET
static VirtualSpob * vspob_stack
const char * jump_getSymbol(const JumpPoint *jp)
Gets the jump point symbol.
static int systemstack_changed
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.
static glTexture * jumpbuoy_gfx
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_sysSave(xmlTextWriterPtr writer)
Saves what is needed to be saved for space.
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.
StarSystem * system_get(const char *sysname)
Get the system from its name.
const char * spob_getSystem(const char *spobname)
Get the name of a system from a spobname.
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.
static MapShader ** mapshaders
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.
static void system_scheduler(double dt, int init)
Controls fleet spawning.
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.
static int getPresenceIndex(StarSystem *sys, int faction)
Gets the index of the presence element for a faction. Creates one if it doesn't exist.
int space_addMarker(int objid, MissionMarkerType type)
Adds a marker to a system.
static int spob_parsePresence(xmlNodePtr node, SpobPresence *ap)
Parsess an spob presence from xml.
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.
static int space_simulating_effects
static void space_renderJumpPoint(const JumpPoint *jp, int i)
Renders a jump point.
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.
static int virtualspobs_load(void)
Loads all the virtual spobs.
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.
static int space_parseSpobs(xmlNodePtr parent, StarSystem *sys)
Parses spobs in a system.
void space_clearKnown(void)
Clears all system knowledge.
StarSystem * systems_stack
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.
static int system_parseJumps(StarSystem *sys)
Loads the jumps into a system.
static const MapShader * mapshader_get(const char *name)
Gets the map shader by name.
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.
static int systems_loading
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
static int spobstack_changed
static int virtualspob_cmp(const void *p1, const void *p2)
Comparison function for qsort'ing VirtuaSpob by name.
const char * spob_getClassName(const char *class)
Gets the long class name for a spob.
static int system_parseAsteroidExclusion(const xmlNodePtr node, StarSystem *sys)
Parses a single asteroid exclusion zone for a system.
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.
static void space_updateSpob(const Spob *p, double dt, double real_dt)
Renders a spob.
static int system_parseAsteroidField(const xmlNodePtr node, StarSystem *sys)
Parses a single asteroid field for a 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.
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.
static int system_parseJumpPoint(const xmlNodePtr node, StarSystem *sys)
Parses a single jump point for a system.
static int system_parse(StarSystem *system, const char *filename)
Creates a system from an XML node.
void system_reconstructJumps(StarSystem *sys)
Reconstructs the jumps for a single system.
void spfx_clear(void)
Clears all the currently running effects.
const char * start_spob_lua_default(void)
Gets the default spob Lua file.
Represents an asteroid field anchor.
Represents an asteroid exclusion zone.
Represents a group of asteroids.
Represents a single asteroid.
Core damage that an outfit does.
The actual hook parameter.
The representation of an in-game pilot.
Represents relative ship statistics as a linked list.
struct ShipStatList_ * next
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 presence in a system.
Basically modifies system parameters without creating any real objects.
Abstraction for rendering sprite sheets.
tech_group_t * tech_groupCreateXML(xmlNodePtr node)
Creates a tech group from an XML node.
void tech_groupDestroy(tech_group_t *grp)
Frees a tech group.
void weapon_clear(void)
Clears all the weapons, does NOT free the layers.
void weapon_newSystem(void)
Sets up collision stuff for a new system.