35#include "player_fleet.h"
39#define XML_MISSION_TAG "mission"
61 int create,
unsigned int *
id );
64static int mission_meetConditionals(
const MissionData *misn );
66 const Spob *pnt,
const StarSystem *sys );
105 WARN( _(
"Mission '%s' not found in stack" ), name );
145 int create,
unsigned int *
id )
147 if ( misn->
chunk == LUA_NOREF ) {
149 _(
"Trying to initialize mission '%s' that has no loaded Lua chunk!" ),
155 memset( mission, 0,
sizeof(
Mission ) );
156 mission->
env = LUA_NOREF;
163 mission->
data = misn;
166 mission->
title = strdup( _( misn->
name ) );
167 mission->
desc = strdup( _(
"No description." ) );
171 mission->
env = nlua_newEnv( misn->
name );
176 lua_newtable(
naevL );
177 nlua_setenv(
naevL, mission->
env,
"mem" );
181 WARN( _(
"Error loading mission file: %s\n"
183 "Most likely Lua file has improper syntax, please check" ),
191 int ret = misn_run( mission,
"create" );
212 return misn_run( mission,
"accept" );
238static int mission_meetConditionals(
const MissionData *misn )
242 pcre2_match_data *match_data =
245 strlen(
player.chapter ), 0, 0, match_data, NULL );
246 pcre2_match_data_free( match_data );
249 case PCRE2_ERROR_NOMATCH:
252 WARN( _(
"Matching error %d" ), rc );
255 }
else if ( rc == 0 )
260 if ( mis_isFlag( misn, MISSION_UNIQUE ) &&
269 WARN( _(
"Conditional for mission '%s' failed to run" ), misn->
name );
294 const Spob *pnt,
const StarSystem *sys )
301 if ( ( pnt == NULL ) || strcmp( misn->
avail.
spob, pnt->
name ) != 0 )
303 }
else if ( spob_isFlag( pnt, SPOB_NOMISNSPAWN ) )
308 ( sys == NULL || ( strcmp( misn->
avail.
system, sys->name ) != 0 ) ) )
315 return !mission_meetConditionals( misn );
327 const StarSystem *sys )
343 chance = (double)( misn->
avail.
chance % 100 ) / 100.;
347 if ( RNGF() < chance ) {
379 if (
landed && ( ret == 0 ) ) {
380 if ( mdat->
avail.
loc == MIS_AVAIL_BAR )
382 else if ( mdat->
avail.
loc == MIS_AVAIL_COMPUTER )
407 return mission_meetConditionals( mdat );
410const char *mission_availabilityStr( MissionAvailability loc )
413 case MIS_AVAIL_UNSET:
417 case MIS_AVAIL_COMPUTER:
423 case MIS_AVAIL_ENTER:
435 case SYSMARKER_COMPUTER:
440 case SPOBMARKER_COMPUTER:
442 case SPOBMARKER_HIGH:
443 case SPOBMARKER_PLOT:
446 WARN( _(
"Unknown marker type." ) );
451MissionMarkerType mission_markerTypeSpobToSystem( MissionMarkerType t )
454 case SYSMARKER_COMPUTER:
459 case SPOBMARKER_COMPUTER:
460 return SYSMARKER_COMPUTER;
462 return SYSMARKER_LOW;
463 case SPOBMARKER_HIGH:
464 return SYSMARKER_HIGH;
465 case SPOBMARKER_PLOT:
466 return SYSMARKER_PLOT;
468 WARN( _(
"Unknown marker type." ) );
473MissionMarkerType mission_markerTypeSystemToSpob( MissionMarkerType t )
476 case SYSMARKER_COMPUTER:
477 return SPOBMARKER_COMPUTER;
479 return SPOBMARKER_LOW;
481 return SPOBMARKER_HIGH;
483 return SPOBMARKER_PLOT;
484 case SPOBMARKER_COMPUTER:
486 case SPOBMARKER_HIGH:
487 case SPOBMARKER_PLOT:
490 WARN( _(
"Unknown marker type." ) );
495void mission_toLuaTable( lua_State *L,
const MissionData *m )
499 lua_pushstring( L, m->
name );
500 lua_setfield( L, -2,
"name" );
502 lua_pushboolean( L, mis_isFlag( m, MISSION_UNIQUE ) );
503 lua_setfield( L, -2,
"unique" );
507 lua_pushboolean( L, 1 );
508 lua_setfield( L, -2, m->
tags[j] );
510 lua_setfield( L, -2,
"tags" );
513const char **mission_loadFailed(
void )
524 osd_setHide( misn->
osd, hide );
527int misn_osdGetHide(
const Mission *misn )
531void misn_osdSetPriority(
Mission *misn,
int priority )
534 osd_setPriority( misn->
osd, priority );
536int misn_osdGetPriority(
const Mission *misn )
547 MissionMarkerType type;
551 xmlr_attr_int_def( node,
"id",
id, -1 );
552 xmlr_attr_int_def( node,
"type", type, -1 );
555 case SYSMARKER_COMPUTER:
560 if ( ssys == NULL ) {
561 WARN( _(
"Mission Marker to system '%s' does not exist" ),
566 case SPOBMARKER_COMPUTER:
568 case SPOBMARKER_HIGH:
569 case SPOBMARKER_PLOT:
572 WARN( _(
"Mission Marker to spob '%s' does not exist" ),
578 WARN( _(
"Unknown marker type." ) );
587 MissionMarkerType type )
607 marker->
objid = objid;
644 StarSystem *firstsys = NULL;
657 case SYSMARKER_COMPUTER:
663 case SPOBMARKER_COMPUTER:
665 case SPOBMARKER_HIGH:
666 case SPOBMARKER_PLOT:
669 if ( sysname == NULL ) {
670 WARN( _(
"Marked spob '%s' is not in any system!" ), pnt->
name );
676 WARN( _(
"Unknown marker type." ) );
681 sys_setFlag( sys, SYSTEM_CMARKED );
683 if ( firstsys == NULL )
706 case SYSMARKER_COMPUTER:
712 case SPOBMARKER_COMPUTER:
714 case SPOBMARKER_HIGH:
715 case SPOBMARKER_PLOT:
718 if ( sysname == NULL ) {
719 WARN( _(
"Marked spob '%s' is not in any system!" ), pnt->
name );
725 WARN( _(
"Unknown marker type." ) );
743 if ( misn->
cargo == NULL )
760 if ( misn->
cargo[i] == cargo_id )
764 DEBUG( _(
"Mission '%s' attempting to unlink nonexistent cargo %d." ),
765 misn->
title, cargo_id );
782 if ( misn->
id != 0 ) {
788 if ( (
player.p != NULL ) &&
795 WARN( _(
"Failed to remove mission cargo '%d' for mission '%s'." ),
801 osd_destroy( misn->
osd );
807 if ( misn->
env != LUA_NOREF )
808 nlua_freeEnv( misn->
env );
822 if ( misn->
claims != NULL )
826 memset( misn, 0,
sizeof(
Mission ) );
827 misn->
env = LUA_NOREF;
860 free( mission->
name );
861 free( mission->
lua );
871 if ( mission->
chunk != LUA_NOREF )
872 luaL_unref(
naevL, LUA_REGISTRYINDEX, mission->
chunk );
878 free( mission->
tags[i] );
933 if ( ( m1->
npc != NULL ) && ( m2->
npc != NULL ) )
934 return strcmp( m1->
npc, m2->
npc );
937 if ( ( m1->
title != NULL ) && ( m2->
title != NULL ) )
955 MissionAvailability loc )
960 NTracingZone( _ctx, 1 );
970 chance = (double)( misn->
avail.
chance % 100 ) / 100.;
976 for (
int j = 0; j < rep; j++ ) {
979 if ( RNGF() > chance )
997 NTracingZoneEnd( _ctx );
1010 if ( loc != NULL ) {
1011 if ( strcasecmp( loc,
"None" ) == 0 )
1012 return MIS_AVAIL_NONE;
1013 else if ( strcasecmp( loc,
"Computer" ) == 0 )
1014 return MIS_AVAIL_COMPUTER;
1015 else if ( strcasecmp( loc,
"Bar" ) == 0 )
1016 return MIS_AVAIL_BAR;
1017 else if ( strcasecmp( loc,
"Land" ) == 0 )
1018 return MIS_AVAIL_LAND;
1019 else if ( strcasecmp( loc,
"Enter" ) == 0 )
1020 return MIS_AVAIL_ENTER;
1040 temp->
chunk = LUA_NOREF;
1047 xmlr_attr_strd( parent,
"name", temp->
name );
1048 if ( temp->
name == NULL )
1049 WARN( _(
"Mission in %s has invalid or no name" ), MISSION_DATA_PATH );
1051 node = parent->xmlChildrenNode;
1055 xml_onlyNodes( node );
1057 if ( xml_isNode( node,
"unique" ) ) {
1058 mis_setFlag( temp, MISSION_UNIQUE );
1061 if ( xml_isNode( node,
"location" ) ) {
1064 WARN( _(
"Mission '%s' has unknown location '%s'!" ), temp->
name,
1069 xmlr_strd( node,
"spob", temp->
avail.
spob );
1072 if ( xml_isNode( node,
"faction" ) ) {
1079 xmlr_strd( node,
"cond", temp->
avail.
cond );
1080 xmlr_strd( node,
"done", temp->
avail.
done );
1083 if ( xml_isNode( node,
"tags" ) ) {
1084 xmlNodePtr cur = node->children;
1087 xml_onlyNodes( cur );
1088 if ( xml_isNode( cur,
"tag" ) ) {
1089 const char *tmp = xml_get( cur );
1094 WARN( _(
"Mission '%s' has unknown node in tags '%s'." ),
1095 temp->
name, cur->name );
1096 }
while ( xml_nextNode( cur ) );
1098 }
else if ( xml_isNode( node,
"notes" ) )
1102 WARN( _(
"Unknown node '%s' in mission '%s'" ), node->name, temp->
name );
1103 }
while ( xml_nextNode( node ) );
1110 WARN( _(
"Mission '%s' failed to compile Lua conditional!" ),
1117 PCRE2_SIZE erroroffset;
1119 pcre2_compile( (PCRE2_SPTR)temp->
avail.
chapter, PCRE2_ZERO_TERMINATED,
1120 0, &errornumber, &erroroffset, NULL );
1122 PCRE2_UCHAR buffer[256];
1123 pcre2_get_error_message( errornumber, buffer,
sizeof( buffer ) );
1124 WARN( _(
"Mission '%s' chapter PCRE2 compilation failed at offset %d: "
1126 temp->
name, (
int)erroroffset, buffer );
1130#define MELEMENT( o, s ) \
1132 WARN( _( "Mission '%s' missing/invalid '%s' element" ), temp->name, s )
1133 MELEMENT( temp->
avail.
loc == MIS_AVAIL_UNSET,
"location" );
1134 MELEMENT( ( temp->
avail.
loc != MIS_AVAIL_NONE ) &&
1160 return strcmp( ma->
name, mb->
name );
1171 Uint32 time = SDL_GetTicks();
1173 char **mission_files;
1179 for (
int i = 0; i <
array_size( mission_files ); i++ ) {
1181 free( mission_files[i] );
1191 WARN( _(
"Duplicate event '%s'!" ), md->
name );
1201 if ( conf.devmode ) {
1202 time = SDL_GetTicks() - time;
1203 DEBUG( n_(
"Loaded %d Mission in %.3f s",
"Loaded %d Missions in %.3f s",
1207 DEBUG( n_(
"Loaded %d Mission",
"Loaded %d Missions",
1227 const char *pos, *start_pos;
1231 if ( filebuf == NULL ) {
1232 WARN( _(
"Unable to read data from '%s'" ), file );
1235 if ( bufsize == 0 ) {
1241 pos =
strnstr( filebuf,
"</mission>", bufsize );
1242 if ( pos == NULL ) {
1243 pos =
strnstr( filebuf,
"function create", bufsize );
1244 if ( ( pos != NULL ) && !strncmp( pos,
"--common", bufsize ) )
1245 WARN( _(
"Mission '%s' has create function but no XML header!" ),
1252 start_pos =
strnstr( filebuf,
"<?xml ", bufsize );
1253 pos =
strnstr( filebuf,
"--]]", bufsize );
1254 if ( pos == NULL || start_pos == NULL ) {
1255 WARN( _(
"Mission file '%s' has missing XML header!" ), file );
1260 doc = xmlParseMemory( start_pos, pos - start_pos );
1261 if ( doc == NULL ) {
1262 WARN( _(
"Unable to parse document XML header for Mission '%s'" ), file );
1266 node = doc->xmlChildrenNode;
1268 WARN( _(
"Malformed XML header for '%s' mission: missing root element "
1277 temp->
lua = filebuf;
1281 if ( temp->
chunk != LUA_NOREF ) {
1282 luaL_unref(
naevL, LUA_REGISTRYINDEX, temp->
chunk );
1283 temp->
chunk = LUA_NOREF;
1289 if ( ret == LUA_ERRSYNTAX )
1290 WARN( _(
"Mission Lua '%s' syntax error: %s" ), file,
1291 lua_tostring(
naevL, -1 ) );
1293 temp->
chunk = luaL_ref(
naevL, LUA_REGISTRYINDEX );
1352 xmlw_startElem( writer,
"temporary_cargo" );
1353 for (
int i = 0; i <
array_size( pcom ); i++ ) {
1357 xmlw_startElem( writer,
"cargo" );
1359 xmlw_endElem( writer );
1361 xmlw_endElem( writer );
1364 xmlw_startElem( writer,
"missions" );
1367 if ( misn->
id == 0 )
1370 xmlw_startElem( writer,
"mission" );
1373 xmlw_attr( writer,
"data",
"%s", misn->
data->
name );
1374 xmlw_attr( writer,
"id",
"%u", misn->
id );
1376 xmlw_elem( writer,
"title",
"%s", misn->
title );
1377 xmlw_elem( writer,
"desc",
"%s", misn->
desc );
1378 xmlw_elem( writer,
"reward",
"%s", misn->
reward );
1379 xmlw_elem( writer,
"reward_value",
"%" CREDITS_PRI, misn->
reward_value );
1382 xmlw_startElem( writer,
"markers" );
1385 xmlw_startElem( writer,
"marker" );
1386 xmlw_attr( writer,
"id",
"%d", m->
id );
1387 xmlw_attr( writer,
"type",
"%d", m->
type );
1389 xmlw_endElem( writer );
1391 xmlw_endElem( writer );
1394 xmlw_startElem( writer,
"cargos" );
1396 xmlw_elem( writer,
"cargo",
"%u", misn->
cargo[j] );
1397 xmlw_endElem( writer );
1400 if ( misn->
osd > 0 ) {
1401 char **items = osd_getItems( misn->
osd );
1403 xmlw_startElem( writer,
"osd" );
1406 xmlw_attr( writer,
"title",
"%s", osd_getTitle( misn->
osd ) );
1407 xmlw_attr( writer,
"nitems",
"%d",
array_size( items ) );
1408 xmlw_attr( writer,
"active",
"%d", osd_getActive( misn->
osd ) );
1409 xmlw_attr( writer,
"hidden",
"%d", misn->
osd_hide );
1411 xmlw_attr( writer,
"priority",
"%d", misn->
osd_priority );
1414 for (
int j = 0; j <
array_size( items ); j++ )
1415 xmlw_elem( writer,
"msg",
"%s", items[j] );
1417 xmlw_endElem( writer );
1421 xmlw_startElem( writer,
"claims" );
1423 xmlw_endElem( writer );
1426 xmlw_startElem( writer,
"lua" );
1428 xmlw_endElem( writer );
1430 xmlw_endElem( writer );
1432 xmlw_endElem( writer );
1446 xmlw_attr( writer,
"name",
"%s",
c->name );
1447 xmlw_attr( writer,
"description",
"%s",
c->description );
1448 for (
int j = 0; j <
array_size(
c->illegalto ); j++ )
1449 xmlw_elem( writer,
"illegalto",
"%s",
faction_name(
c->illegalto[j] ) );
1464 node = parent->xmlChildrenNode;
1466 xml_onlyNodes( node );
1468 if ( xml_isNode( node,
"temporary_cargo" ) ) {
1469 xmlNodePtr cur = node->xmlChildrenNode;
1471 xml_onlyNodes( cur );
1472 if ( xml_isNode( cur,
"cargo" ) )
1474 }
while ( xml_nextNode( cur ) );
1477 }
while ( xml_nextNode( node ) );
1494 xmlr_attr_strd( cur,
"name", name );
1495 if ( name == NULL ) {
1496 WARN( _(
"Mission cargo without name!" ) );
1506 xmlr_attr_strd( cur,
"description", desc );
1507 if ( desc == NULL ) {
1508 WARN( _(
"Mission temporary cargo '%s' missing description!" ), name );
1515 ccur = cur->xmlChildrenNode;
1517 xml_onlyNodes( ccur );
1518 if ( xml_isNode( ccur,
"illegalto" ) ) {
1522 }
while ( xml_nextNode( ccur ) );
1543 node = parent->xmlChildrenNode;
1545 xml_onlyNodes( node );
1546 if ( xml_isNode( node,
"missions" ) ) {
1551 }
while ( xml_nextNode( node ) );
1577 node = parent->xmlChildrenNode;
1579 if ( xml_isNode( node,
"mission" ) ) {
1582 int misn_failed = 0;
1586 xmlr_attr_strd( node,
"data", buf );
1588 if ( data == NULL ) {
1589 WARN( _(
"Mission '%s' from saved game not found in game - "
1597 WARN( _(
"Mission '%s' from saved game failed to load properly "
1609 xmlr_attr_int( node,
"id", misn->
id );
1611 cur = node->xmlChildrenNode;
1613 xmlr_strd( cur,
"title", misn->
title );
1614 xmlr_strd( cur,
"desc", misn->
desc );
1615 xmlr_strd( cur,
"reward", misn->
reward );
1619 if ( xml_isNode( cur,
"markers" ) ) {
1620 xmlNodePtr nest = cur->xmlChildrenNode;
1622 if ( xml_isNode( nest,
"marker" ) )
1624 }
while ( xml_nextNode( nest ) );
1628 if ( xml_isNode( cur,
"cargos" ) ) {
1629 xmlNodePtr nest = cur->xmlChildrenNode;
1631 if ( xml_isNode( nest,
"cargo" ) )
1633 }
while ( xml_nextNode( nest ) );
1637 if ( xml_isNode( cur,
"osd" ) ) {
1640 xmlr_attr_int_def( cur,
"nitems", nitems, -1 );
1643 xmlr_attr_strd( cur,
"title", title );
1644 items = malloc( nitems *
sizeof(
char * ) );
1645 nest = cur->xmlChildrenNode;
1647 if ( xml_isNode( nest,
"msg" ) ) {
1650 _(
"Inconsistency with 'nitems' in save file." ) );
1653 items[i] = xml_get( nest );
1656 }
while ( xml_nextNode( nest ) );
1659 xmlr_attr_int_def( cur,
"priority", misn->
osd_priority,
1660 data->avail.priority );
1669 xmlr_attr_int_def( cur,
"active", active, -1 );
1671 osd_active( misn->
osd, active );
1673 xmlr_attr_int_def( cur,
"hidden", misn->
osd_hide, 0 );
1678 if ( xml_isNode( cur,
"claims" ) )
1681 if ( xml_isNode( cur,
"lua" ) ) {
1685 WARN( _(
"Mission '%s' from saved game failed to unpersist "
1686 "Lua properly - ignoring." ),
1692 }
while ( xml_nextNode( cur ) );
1694 if ( misn_failed ) {
1701 }
while ( xml_nextNode( node ) );
1706int mission_reload(
const char *name )
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_end(array)
Returns a pointer to the end of the reserved memory space.
#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_begin(array)
Returns a pointer to the beginning of the reserved memory space.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void claim_destroy(Claim_t *claim)
Destroys a system claim.
void claim_activate(Claim_t *claim)
Activates a claim on a system.
Claim_t * claim_xmlLoad(xmlNodePtr parent)
Loads a claim.
int claim_xmlSave(xmlTextWriterPtr writer, const Claim_t *claim)
Saves all the systems in a claim in XML.
Commodity * commodity_newTemp(const char *name, const char *desc)
Creates a new temporary commodity.
Commodity * commodity_getW(const char *name)
Gets a commodity by name without warning.
int commodity_tempIllegalto(Commodity *com, int faction)
Makes a temporary commodity illegal to something.
int cond_compile(const char *cond)
Compiles a conditional statement that can then be used as a reference.
const char * faction_name(int f)
Gets a factions "real" (internal) name.
int faction_get(const char *name)
Gets a faction ID by name.
void hook_rmMisnParent(unsigned int parent)
Removes all hooks belonging to parent mission.
void misn_patchMission(const Mission *misn)
Patches a mission into the mission computer.
int mission_accept(Mission *mission)
Small wrapper for misn_run.
int mission_compare(const void *arg1, const void *arg2)
Compares to missions to see which has more priority.
int missions_saveTempCommodity(xmlTextWriterPtr writer, const Commodity *c)
Saves a temporary commodity's defintion into the current node.
Mission ** player_missions
static int mission_markerLoad(Mission *misn, xmlNodePtr node)
Loads a mission marker from xml.
const StarSystem * mission_getSystemMarker(const Mission *misn)
Gets the first system that has been marked by a mission.
void mission_cleanup(Mission *misn)
Cleans up a mission.
Mission * missions_genList(int faction, const Spob *pnt, const StarSystem *sys, MissionAvailability loc)
Generates a mission list. This runs create() so won't work with all missions.
int mission_addMarker(Mission *misn, int id, int objid, MissionMarkerType type)
Adds a system marker to a mission.
const StarSystem * mission_sysComputerMark(const Mission *misn)
Marks the system of the computer mission to reflect where it will head to.
const MissionData * mission_getFromName(const char *name)
Gets mission data from a name.
void missions_free(void)
Frees all the mission data.
int mission_alreadyRunning(const MissionData *misn)
Checks to see if mission is already running.
static const char * mission_markerTarget(const MissionMarker *m)
Gets the name of the mission marker target.
static int mission_matchFaction(const MissionData *misn, int faction)
Checks to see if a mission matches the faction requirements.
int mission_linkCargo(Mission *misn, unsigned int cargo_id)
Links cargo to the mission for posterior cleanup.
void missions_activateClaims(void)
Activates mission claims.
void mission_sysMark(void)
Marks all active systems that need marking.
void missions_run(MissionAvailability loc, int faction, const Spob *pnt, const StarSystem *sys)
Runs missions matching location, all Lua side and one-shot.
static MissionData * mission_stack
int missions_loadActive(xmlNodePtr parent)
Loads the player's active missions from a save.
static int mission_parseFile(const char *file, MissionData *temp)
Parses a single mission.
static int mission_parseXML(MissionData *temp, const xmlNodePtr parent)
Parses a node of a mission.
static int missions_parseActive(xmlNodePtr parent)
Parses the actual individual mission nodes.
static char ** player_missions_failed
void mission_shift(int pos)
Puts the specified mission at the end of the player_missions array.
int missions_load(void)
Loads all the mission data.
static int missions_cmp(const void *a, const void *b)
Ordering function for missions.
void misn_osdSetHide(Mission *misn, int hide)
Sets the hide state of the mission OSD.
Commodity * missions_loadTempCommodity(xmlNodePtr cur)
Loads a temporary commodity.
static int mission_meetReq(const MissionData *misn, int faction, const Spob *pnt, const StarSystem *sys)
Checks to see if a mission meets the requirements.
int mission_start(const char *name, unsigned int *id)
Starts a mission.
int mission_getID(const char *name)
Gets id from mission name.
int missions_saveActive(xmlTextWriterPtr writer)
Saves the player's active missions.
static unsigned int mission_genID(void)
Generates a new id for the mission.
static unsigned int mission_id
static void mission_freeData(MissionData *mission)
Frees MissionData.
static int mission_location(const char *loc)
Gets location based on a human readable string.
static int mission_init(Mission *mission, const MissionData *misn, int genid, int create, unsigned int *id)
Initializes a mission.
int mission_unlinkCargo(Mission *misn, unsigned int cargo_id)
Unlinks cargo from the mission, removes it from the player.
const MissionData * mission_list(void)
Returns all the missions.
int missions_loadCommodity(xmlNodePtr parent)
Loads the player's special mission commodities.
int mission_test(const char *name)
Tests the conditionals of a mission.
void missions_cleanup(void)
Cleans up all the player's active missions.
const MissionData * mission_get(int id)
Gets a MissionData based on ID.
int naev_isQuit(void)
Get if Naev is trying to quit.
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).
char ** ndata_listRecursive(const char *path)
Lists all the visible files in a directory, at any depth.
int misn_loadLibs(nlua_env env)
Registers all the mission libraries.
void npc_patchMission(Mission *misn)
Patches a new mission bar npc into the bar system.
int npc_rm_parentMission(unsigned int mid)
Removes all the npc belonging to a mission.
char * strnstr(const char *haystack, const char *needle, size_t size)
A bounded version of strstr. Conforms to BSD semantics.
int nxml_persistLua(nlua_env env, xmlTextWriterPtr writer)
Persists all the nxml Lua data.
int nxml_unpersistLua(nlua_env env, xmlNodePtr parent)
Unpersists Lua data into a table named "mem".
void gl_freeTexture(glTexture *texture)
Frees a texture.
int pilot_rmMissionCargo(Pilot *pilot, unsigned int cargo_id, int jettison)
Removes special mission cargo based on id.
int player_missionAlreadyDone(int id)
Checks to see if player has already completed a mission.
PilotCommodity * pfleet_cargoList(void)
Gets a list of all the cargo in the fleet.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
StarSystem * system_getIndex(int id)
Get the system by its index.
int spob_index(const Spob *p)
Gets the ID of a spob.
StarSystem * system_get(const char *sysname)
Get the system from its name.
int space_addMarker(int objid, MissionMarkerType type)
Adds a marker to a system.
void space_clearMarkers(void)
Clears all system markers.
Spob * spob_getIndex(int ind)
Gets spob by index.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
void space_clearComputerMarkers(void)
Clears all the system computer markers.
int system_index(const StarSystem *sys)
Gets the index of a star system.
Represents an active mission.
Stores a pilot commodity.
const Commodity * commodity
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...