27#include "difficulty.h"
39#include "land_outfits.h"
43#include "map_overlay.h"
49#include "nlua_outfit.h"
61#include "player_autonav.h"
62#include "player_fleet.h"
63#include "player_gui.h"
64#include "player_inventory.h"
95#define RADAR_RES_DEFAULT 50.
188static int preemption = 0;
231 player.last_played = time( NULL );
264 player.date_created = time( NULL );
267 const char *SAVEPATH =
"_tmp";
275 _(
"Please write your name:" ) );
278 if (
player.name == NULL) {
287 while ((
c = u8_nextchar(
player.name, &i ) )) {
296 _(
"Your chosen name '%s' does not seem to be very good. Are you "
297 "sure you wish to proceed with this name?" ),
304 snprintf( buf,
sizeof( buf ),
"%s/%s", SAVEPATH,
player.name );
305 if (PHYSFS_mkdir( buf ) !=
309 int ret = PHYSFS_stat( buf, &stat );
313 if (( ret != 0 ) && ( stat.filetype == PHYSFS_FILETYPE_DIRECTORY )) {
316 ret = PHYSFS_delete( buf );
318 WARN( _(
"Unable to delete temporary file '%s': %s" ), buf,
319 PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) );
321 ret = PHYSFS_delete( SAVEPATH );
323 WARN( _(
"Unable to delete temporary file '%s': %s" ),
325 PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) );
333 _(
"'%s' is an invalid player name as it can not be saved to your "
334 "filesystem! Please choose another." ),
336 PHYSFS_getLastErrorCode();
343 _(
"You already have a pilot named %s. Their autosave and backup save "
344 "will be overwritten. Do you wish to continue?" ),
367 WARN( _(
"Failed to run start mission '%s'." ),
start_mission() );
373 WARN( _(
"Failed to run start event '%s'." ),
start_event() );
391 const char *shipname, *acquired;
412 WARN( _(
"Ship not properly set by module." ) );
418 ( shipname == NULL ) ? 0 : 1 );
423 assert( &
player.ps == ps );
425 vec2_cset( &
player.p->solid.pos, x, y );
426 vectnull( &
player.p->solid.vel );
427 player.p->solid.dir = RNGF() * 2. * M_PI;
434 player.speed = conf.game_speed;
471 const char *acquired,
int noname )
481 _(
"Please name your new ship:" ) );
486 if (ship_name == NULL) {
490 if (def_name == NULL)
495 len = strlen( def_name ) + 10;
496 ship_name = malloc( len );
497 strcpy( ship_name, def_name );
499 snprintf( ship_name, len,
"%s %d", def_name, i );
507 _(
"Please do not give the ship the same name as another "
508 "of your ships." ) );
512 if (trade &&
player.p == NULL)
513 ERR( _(
"Player ship isn't valid… This shouldn't happen!" ) );
519 ps->
acquired = ( acquired != NULL ) ? strdup( acquired ) : NULL;
524 const char *old_name =
player.p->name;
550 pilot_clearFlagsRaw( flags );
551 pilot_setFlagRaw( flags, PILOT_PLAYER );
553 flags, PILOT_NO_EQUIP );
556 player_rmFlag( PLAYER_CREATING );
561 pilot_setFlagRaw( flags, PILOT_PLAYER_FLEET );
573 ERR( _(
"Something seriously wonky went on, newly created player does "
574 "not exist, bailing!" ) );
596 int removed, hyptarget;
608 WARN( _(
"Unable to swap player.p with ship '%s': ship does not exist!" ),
614 hyptarget =
player.p->nav_hyperspace;
630 if (e->
id == ps->
p->
id)
656 dir = angle_clean(
player.p->solid.dir );
692 player.p->solid.dir = dir;
700 player.p->nav_hyperspace =
714 hparam[0].
type = HOOK_PARAM_STRING;
716 hparam[1].
type = HOOK_PARAM_SHIP;
718 hparam[2].
type = HOOK_PARAM_STRING;
720 hparam[3].
type = HOOK_PARAM_SHIP;
722 hparam[4].
type = HOOK_PARAM_SENTINEL;
737 if (strcmp( shipname,
player.p->name ) == 0)
751 WARN( _(
"Unable to find price for player's ship '%s': ship does not "
763 pilot_rmFlag( ps->
p, PILOT_NOFREE );
781 if (strcmp( shipname, ps->
p->
name ) != 0)
785 player_rmPlayerShip( ps );
836 free(
player.ps.acquired );
837 player.ps.acquired = NULL;
886 free(
player.difficulty );
896 difficulty_setLocal( NULL );
903 free(
player.loaded_version );
904 player.loaded_version = NULL;
908 player_setFlag( PLAYER_CREATING );
1010 vec2_cset( &
player.p->solid.pos, x, y );
1012 if (target ==
player.p->id)
1027 player_rmFlag( PLAYER_NOLAND );
1060 if (player_isFlag( PLAYER_DESTROYED )) {
1069 player_isFlag( PLAYER_CREATING ) || pilot_isFlag(
player.p, PILOT_HIDE ))
1072 NTracingZone( _ctx, 1 );
1075 if (pilot_isFlag(
player.p, PILOT_STEALTH ))
1079 if ((
player.p->target != PLAYER_ID ) &&
player.p->aimLines &&
1080 !pilot_isFlag(
player.p, PILOT_HYPERSPACE ) &&
1081 !pilot_isFlag(
player.p, PILOT_DISABLED ) &&
1082 !pilot_isFlag(
player.p, PILOT_LANDING ) &&
1083 !pilot_isFlag(
player.p, PILOT_TAKEOFF ) &&
1084 !player_isFlag( PLAYER_CINEMATICS_GUI ))
1093 NTracingZoneEnd( _ctx );
1102 if ((
player.p == NULL ) || player_isFlag( PLAYER_CREATING ) ||
1103 pilot_isFlag(
player.p, PILOT_HIDE ))
1106 if (pilot_isFlag(
player.p, PILOT_STEALTH ))
1121 if (ovr_isOpen() || player_isFlag( PLAYER_CINEMATICS ))
1134 if (pilot_isDisabled( t ))
1143 glUseProgram( shaders.stealthaura.program );
1155 double x, y, r,
st, z;
1170 r = 1.2 / 2. * (double)
player.p->ship->size;
1173 glUseProgram( shaders.stealthmarker.program );
1174 glUniform1f( shaders.stealthmarker.paramf,
st );
1175 gl_renderShader( x, y, r * z, r * z, 0., &shaders.stealthmarker, &col, 1 );
1184 double a, b,
d, x1, y1, x2, y2, r, theta;
1199 theta = 22. * M_PI / 180.;
1202 d =
ABS( angle_diff( a, b ) / ( 2 * theta ) );
1208 player.p->solid.pos.x + r * cos( a + theta ),
1209 player.p->solid.pos.y + r * sin( a + theta ) );
1212 player.p->solid.pos.x + r * cos( a - theta ),
1213 player.p->solid.pos.y + r * sin( a - theta ) );
1217 c.g =
d * 0.2 + ( 1. -
d ) * 0.8;
1218 c.b = ( 1 -
d ) * 0.2;
1220 col_gammaToLinear( &
c );
1222 player.p->solid.pos.y + r * sin( a ) );
1228 glUseProgram( shaders.crosshairs.program );
1229 glUniform1f( shaders.crosshairs.paramf, 1. );
1233 player.p->solid.pos.y + r * sin( b ) );
1239 glColour c3 = cBlack;
1258 if (pilot_isFlag( pplayer, PILOT_DEAD )) {
1268 ai_think( pplayer, dt, pilot_isFlag( pplayer, PILOT_MANUAL_CONTROL ) );
1271 if (pilot_isFlag( pplayer, PILOT_MANUAL_CONTROL ) ||
1272 pilot_isFlag( pplayer, PILOT_HIDE ))
1279 if (player_isFlag( PLAYER_AUTONAV )) {
1287 if (!facing && player_isFlag( PLAYER_MFLY ))
1291 if (!facing && player_isFlag( PLAYER_FACE )) {
1293 if (
player.p->target != PLAYER_ID) {
1295 if (target != NULL) {
1305 else if (
player.p->nav_asteroid != -1) {
1314 else if ((
player.p->nav_spob != -1 ) &&
1315 ( ( preemption == 0 ) || (
player.p->nav_hyperspace == -1 ) )) {
1317 vec2_angle( &
player.p->solid.pos,
1322 }
else if (
player.p->nav_hyperspace != -1) {
1325 vec2_angle( &
player.p->solid.pos,
1334 if (player_isFlag( PLAYER_REVERSE )) {
1338 if (!
player.p->stats.misc_reverse_thrust && !facing) {
1348 if (player_isFlag( PLAYER_TURN_LEFT ))
1350 if (player_isFlag( PLAYER_TURN_RIGHT ))
1352 turn =
CLAMP( -1., 1., turn );
1359 if (!player_isFlag( PLAYER_AUTONAV )) {
1363 if (player_isFlag( PLAYER_REVERSE ) &&
1364 player.p->stats.misc_reverse_thrust &&
1365 !pilot_isFlag(
player.p, PILOT_HYP_PREP ) &&
1366 !pilot_isFlag(
player.p, PILOT_HYPERSPACE ))
1367 acc = -PILOT_REVERSE_THRUST;
1385 if (!player_isFlag( PLAYER_DESTROYED ))
1402 if (( t != NULL ) && !pilot_isFlag( t, PILOT_PLAYER_SCANNED ) &&
1404 pilot_setFlag( t, PILOT_PLAYER_SCANNED );
1408 if (pilot_isFlag( pplayer, PILOT_AFTERBURNER ))
1410 else if (pilot_isFlag( pplayer, PILOT_HYPERSPACE ))
1423 if (engsound >= 0) {
1449 if (
player.p->stats.asteroid_scan > 0.) {
1450 double range =
player.p->stats.asteroid_scan;
1456 if (vec2_dist2( &ast->
pos, &
player.p->solid.pos ) >
1468 if (vec2_dist2( &a->sol.pos, &
player.p->solid.pos ) > r2)
1474 hparam[0].
type = HOOK_PARAM_ASTEROID;
1475 hparam[0].
u.
ast.parent = ast->
id;
1476 hparam[0].
u.
ast.id = a->id;
1477 hparam[1].
type = HOOK_PARAM_SENTINEL;
1498 type = ( value >= 0 ) ? +1 : -1;
1506 if (( pilot_isFlag(
player.p, PILOT_HYP_PREP ) ||
1507 pilot_isFlag(
player.p, PILOT_HYPERSPACE ) ||
1508 pilot_isFlag(
player.p, PILOT_LANDING ) ||
1509 pilot_isFlag(
player.p, PILOT_TAKEOFF ) ))
1526 player.speed_autonav = 1.;
1540 if (reason != PINPUT_AUTONAV) {
1542 if (( !
paused || reason != PINPUT_MOVEMENT ))
1546 if (reason != PINPUT_BRAKING) {
1547 pilot_rmFlag(
player.p, PILOT_BRAKING );
1548 pilot_rmFlag(
player.p, PILOT_COOLDOWN_BRAKE );
1549 if (pilot_isFlag(
player.p, PILOT_COOLDOWN ))
1568 WARN( _(
"Trying to set player's spob target to invalid ID '%d'" ),
id );
1572 if ((
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_LANDING ))
1575 old =
player.p->nav_spob;
1579 player_rmFlag( PLAYER_LANDACK );
1586 if (
player.autonav == AUTONAV_SPOB)
1600 if ((
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_LANDING ))
1603 old =
player.p->nav_asteroid;
1604 player.p->nav_asteroid = id;
1611 player.p->nav_anchor = field;
1625 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ))
1660 return PLAYER_LAND_DENIED;
1664 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ) ||
1665 pilot_isDisabled(
player.p ))
1666 return PLAYER_LAND_DENIED;
1669 if (( pilot_isFlag(
player.p, PILOT_LANDING ) ||
1670 pilot_isFlag(
player.p, PILOT_TAKEOFF ) ))
1671 return PLAYER_LAND_DENIED;
1676 return PLAYER_LAND_DENIED;
1679 if (player_isFlag( PLAYER_NOLAND )) {
1681 return PLAYER_LAND_DENIED;
1682 }
else if (pilot_isFlag(
player.p, PILOT_NOLAND )) {
1684 _(
"Docking stabilizers malfunctioning, cannot land." ) );
1685 return PLAYER_LAND_DENIED;
1689 if (
player.p->nav_spob == -1)
1690 return PLAYER_LAND_DENIED;
1693 SPOB_UNINHABITED ) &&
1696 return PLAYER_LAND_AGAIN;
1703 !spob_hasService( spob, SPOB_SERVICE_LAND )) {
1705 return PLAYER_LAND_DENIED;
1712 return PLAYER_LAND_DENIED;
1713 }
else if (!player_isFlag( PLAYER_LANDACK )) {
1714 if (spob_hasService( spob,
1715 SPOB_SERVICE_INHABITED )) {
1721 spob_name( spob ), _(
"Landing authorized." ) );
1725 return PLAYER_LAND_DENIED;
1730 player_setFlag( PLAYER_LANDACK );
1735 }
else if (vec2_dist2( &
player.p->solid.pos, &spob->
pos ) >
1740 return PLAYER_LAND_AGAIN;
1741 }
else if (vec2_odist2( &
player.p->solid.vel ) >
1742 pow2( MAX_HYPERSPACE_VEL )) {
1746 return PLAYER_LAND_AGAIN;
1768 if (nlua_pcall( spob->
lua_env, 2, 0 )) {
1769 WARN( _(
"Spob '%s' failed to run '%s':\n%s" ), spob->
name,
"land",
1770 lua_tostring(
naevL, -1 ) );
1771 lua_pop(
naevL, 1 );
1774 return PLAYER_LAND_OK;
1781 pilot_setFlag(
player.p, PILOT_LANDING );
1785 return PLAYER_LAND_OK;
1796 if ((
player.p == NULL ) || !player_isFlag( PLAYER_LANDACK ))
1800 if (
player.p->nav_spob < 0) {
1801 WARN( _(
"Player has landing permission, but no valid spob targeted." ) );
1808 if (p->can_land || ( p->land_override > 0 ))
1811 player_rmFlag( PLAYER_LANDACK );
1832 strdup( _(
"You are not allowed to land at this moment." ) );
1841 int plt = (
player.p->target != PLAYER_ID );
1842 int lnd = (
player.p->nav_spob != -1 );
1850 if (canland == PLAYER_LAND_AGAIN)
1852 else if (canland == PLAYER_LAND_DENIED)
1862 if (( nearp != NULL ) && !pilot_isFlag( nearp, PILOT_NOBOARD ) &&
1863 (
d <
pow2( 5e3 ) ) &&
1864 ( pilot_isDisabled( nearp ) ||
1865 pilot_isFlag( nearp, PILOT_BOARDABLE ) )) {
1878 double d = vec2_dist( &
player.p->solid.pos, &spob->
pos );
1881 if (!spob_hasService( spob, SPOB_SERVICE_LAND ))
1883 if (( tp == -1 ) || ( ( td == -1 ) || ( td >
d ) )) {
1914 WARN( _(
"Trying to set player's hyperspace target to invalid ID '%d'" ),
1919 if (pilot_isFlag(
player.p, PILOT_HYP_PREP ) ||
1920 pilot_isFlag(
player.p, PILOT_HYP_BEGIN ) ||
1921 pilot_isFlag(
player.p, PILOT_HYPERSPACE ))
1924 old =
player.p->nav_hyperspace;
1925 player.p->nav_hyperspace = id;
1927 if (( old !=
id ) && (
id >= 0 ))
1931 if (!nomsg && ( old !=
id ) && (
player.autonav == AUTONAV_JUMP ))
1945 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ))
1969 map_select( NULL, 0 );
1971 map_select(
cur_system->jumps[
id].target, 0 );
1982 preemption = preempt;
2004 return player.p->stats.time_mod *
player.p->ship->dt_default;
2018 player_message( _(
"#rReceiving hail! Press #b%s#r to respond.#0" ), buf );
2034 if (pilot_isFlag(
player.p, PILOT_HYPERSPACE ))
2038 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ) ||
2039 pilot_isDisabled(
player.p ))
2043 if (
player.p->nav_hyperspace == -1) {
2045 double mindist = INFINITY;
2049 if (dist < mindist && jp_isUsable( &
cur_system->jumps[i] )) {
2057 player.p->nav_hyperspace = j;
2068 if (pilot_isFlag(
player.p, PILOT_HYP_PREP )) {
2085 _(
"You do not have enough fuel to hyperspace jump." ) );
2133 if (!pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ))
2134 jp_setFlag( jp->returnJump, JP_KNOWN );
2148 player.p->ptimer = HYPERSPACE_FADEIN;
2152 pilot_rmFlag(
player.p, PILOT_HYPERSPACE );
2153 pilot_rmFlag(
player.p, PILOT_HYP_BEGIN );
2154 pilot_rmFlag(
player.p, PILOT_HYP_BRAKE );
2155 pilot_rmFlag(
player.p, PILOT_HYP_PREP );
2163 if (pilot_isFlag( p, PILOT_PERSIST ) || pilot_isFlag( p, PILOT_PLAYER )) {
2166 &p->solid.dir,
player.p );
2173 p->itimer = PILOT_PLAYER_NONTARGETABLE_JUMPIN_DELAY;
2174 pilot_setFlag( p, PILOT_NONTARGETABLE );
2177 pilot_rmFlag( p, PILOT_HYPERSPACE );
2178 pilot_rmFlag( p, PILOT_HYP_BEGIN );
2179 pilot_rmFlag( p, PILOT_HYP_BRAKE );
2180 pilot_rmFlag( p, PILOT_HYP_PREP );
2198 player.ps.jumped_times++;
2208 if ((
player.p == NULL ) || pilot_isFlag(
player.p, PILOT_HYP_PREP ) ||
2209 pilot_isFlag(
player.p, PILOT_HYPERSPACE ))
2235 if (( old !=
id ) && (
player.p->target != PLAYER_ID )) {
2242 player.p->nav_asteroid = -1;
2243 player.p->nav_anchor = -1;
2247 if (( old !=
id ) && player_isFlag( PLAYER_AUTONAV ) &&
2248 (
player.autonav == AUTONAV_PILOT ))
2283 if (tp == PLAYER_ID || ( ( td <
d ) )) {
2318 if (
player.p->target != PLAYER_ID)
2320 else if (
player.p->nav_asteroid >= 0)
2322 else if (
player.p->nav_spob >= 0)
2324 else if (( preemption == 1 ||
player.p->nav_spob == -1 ) &&
2325 !pilot_isFlag(
player.p, PILOT_HYP_PREP )) {
2326 player.p->nav_hyperspace = -1;
2363 ?
player.p->escorts[i + 1].id
2383 if (
player.p->target != PLAYER_ID) {
2397 player.p->solid.pos.y, 1 );
2401 if ((
d >
pow2( 500. ) ) && ( pilot_isDisabled(
pilot_get( dt ) ) )) {
2419 if (PHYSFS_mkdir(
"screenshots" ) == 0) {
2420 WARN( _(
"Aborting screenshot" ) );
2426 snprintf( filename,
sizeof( filename ),
"screenshots/screenshot%03d.png",
2428 if (!PHYSFS_exists( filename ))
2433 WARN( _(
"You have reached the maximum amount of screenshots [999]" ) );
2453 if (pilot_isFlag( p, PILOT_HAILING ))
2470 player_message( _(
"#r%s is out of comm range, unable to contact." ), name );
2479 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ) ||
2480 pilot_isDisabled(
player.p ))
2485 else if (
player.p->nav_spob != -1) {
2487 if (spob_isFlag( spob, SPOB_UNINHABITED ))
2506 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ))
2509 if (
player.p->nav_spob != -1) {
2526 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ) ||
2527 pilot_isDisabled(
player.p ))
2536 if (pilot_isFlag( p, PILOT_HAILING )) {
2548 player_message(
"#r%s", _(
"You haven't been hailed by any pilots." ) );
2551void player_scan(
void )
2558 if (!pilot_isFlag( t, PILOT_PLAYER_SCANNED )) {
2564 "#o%s", _(
"You can not identify the target at this distance." ) );
2570 scan_env = nlua_newEnv(
"scanner" );
2574 char *buf =
ndata_read( SCAN_PATH, &bufsize );
2576 WARN( _(
"File '%s' not found!" ), SCAN_PATH );
2579 if (nlua_dobufenv(
scan_env, buf, bufsize, SCAN_PATH ) != 0) {
2580 WARN( _(
"Error loading file: %s\n"
2582 "Most likely Lua file has improper syntax, please check" ),
2583 SCAN_PATH, lua_tostring(
naevL, -1 ) );
2592 if (nlua_pcall(
scan_env, 0, 0 )) {
2593 WARN( _(
"Scan: '%s' : '%s'" ),
"scan", lua_tostring(
naevL, -1 ) );
2594 lua_pop(
naevL, 1 );
2603 if (!conf.mouse_fly)
2606 if (!player_isFlag( PLAYER_MFLY )) {
2609 player_setFlag( PLAYER_MFLY );
2612 player_rmFlag( PLAYER_MFLY );
2615 if (conf.mouse_accel)
2627 if (pilot_isFlag(
player.p, PILOT_TAKEOFF ) ||
2628 pilot_isFlag(
player.p, PILOT_LANDING ))
2632 if (pilot_isFlag(
player.p, PILOT_MANUAL_CONTROL ) ||
2633 pilot_isDisabled(
player.p ))
2637 if (pilot_isFlag(
player.p, PILOT_HYPERSPACE ))
2640 stopped = pilot_isStopped(
player.p );
2641 if (stopped && !pilot_isFlag(
player.p, PILOT_COOLDOWN ))
2644 pilot_setFlag(
player.p, PILOT_BRAKING );
2645 pilot_setFlag(
player.p, PILOT_COOLDOWN_BRAKE );
2657 double px, py, r, x, y;
2659 px =
player.p->solid.pos.x;
2660 py =
player.p->solid.pos.y;
2662 r = sqrt(
pow2( x - px ) +
pow2( y - py ) );
2665 if (conf.mouse_accel) {
2666 double acc =
CLAMP( 0., 1., ( r - 100. ) / 200. );
2667 acc = 3. *
pow2( acc ) - 2. * pow( acc, 3. );
2670 if (
ABS( angle_diff( atan2( y - py, x - px ),
player.p->solid.dir ) ) <
2700 if (player_isFlag( PLAYER_DESTROYED ))
2704 player_setFlag( PLAYER_DESTROYED );
2828 if ((
player.p != NULL ) && ( strcmp(
player.p->name, shipname ) == 0 ))
2846 if ((
player.p != NULL ) && ( strcmp( shipname,
player.p->name ) == 0 ))
2853 WARN( _(
"Player ship '%s' not found in stack" ), shipname );
2865 if ((
player.p != NULL ) && ( strcmp( shipname,
player.p->name ) == 0 ))
2872 WARN( _(
"Player ship '%s' not found in stack" ), shipname );
2898 if (o->
slot.
type == OUTFIT_SLOT_INTRINSIC)
2954 int ( *filter )(
const Outfit *o ),
2997 if (outfit_isProp( o, OUTFIT_PROP_UNIQUE ) &&
3020 else if (o->
slot.
type == OUTFIT_SLOT_INTRINSIC) {
3055 if (o->
slot.
type == OUTFIT_SLOT_INTRINSIC)
3082static int cmp_int(
const void *p1,
const void *p2 )
3084 const int *i1 = (
const int *)p1;
3085 const int *i2 = (
const int *)p2;
3086 return ( *i1 ) - ( *i2 );
3112 mission_toLuaTable(
naevL, m );
3113 h[0].
type = HOOK_PARAM_REF;
3114 h[0].
u.
ref = luaL_ref(
naevL, LUA_REGISTRYINDEX );
3115 h[1].
type = HOOK_PARAM_SENTINEL;
3131 sizeof(
int ), cmp_int );
3167 event_toLuaTable(
naevL,
id );
3168 h[0].
type = HOOK_PARAM_REF;
3169 h[0].
u.
ref = luaL_ref(
naevL, LUA_REGISTRYINDEX );
3170 h[1].
type = HOOK_PARAM_SENTINEL;
3186 sizeof(
int ), cmp_int );
3209 if (license == NULL)
3250 if (player_isFlag( PLAYER_HOOK_HYPER )) {
3251 player_rmFlag( PLAYER_HOOK_HYPER );
3254 if (player_isFlag( PLAYER_HOOK_JUMPIN )) {
3255 player_rmFlag( PLAYER_HOOK_JUMPIN );
3262 if (player_isFlag( PLAYER_HOOK_LAND )) {
3263 player_rmFlag( PLAYER_HOOK_LAND );
3264 if (
player.p->nav_spob >= 0)
3275 if (
player.p->outfits[i]->outfit == NULL)
3279 player.p->outfits[i]->u.ammo.deployed = 0;
3308 pe->
solid.
dir = RNGF() * 2. * M_PI;
3312 vec2_cset( &pe->
solid.
vel, 0., 0. );
3315 if (e->
type != ESCORT_TYPE_BAY)
3321 pilot_setFlag( pe, PILOT_DELETE );
3322 WARN( _(
"Escort is undeployed, removing." ) );
3332 pilot_setFlag( pe, PILOT_DELETE );
3333 WARN( _(
"Escort is deployed past outfit limits, removing." ) );
3373 case ESCORT_TYPE_BAY:
3374 xmlw_startElem( writer,
"escort" );
3375 xmlw_attr( writer,
"type",
"bay" );
3376 xmlw_attr( writer,
"name",
"%s", e->
ship->
name );
3377 xmlw_endElem( writer );
3380 case ESCORT_TYPE_FLEET:
3383 xmlw_startElem( writer,
"escort" );
3384 xmlw_attr( writer,
"type",
"fleet" );
3385 xmlw_attr( writer,
"name",
"%s", pe->
name );
3386 xmlw_endElem( writer );
3407 int cycles, periods, seconds;
3411 xmlw_startElem( writer,
"player" );
3414 xmlw_attr( writer,
"name",
"%s",
player.name );
3415 xmlw_elem( writer,
"credits",
"%" CREDITS_PRI,
player.p->credits );
3416 xmlw_elem( writer,
"chapter",
"%s",
player.chapter );
3417 if (
player.difficulty != NULL)
3418 xmlw_elem( writer,
"difficulty",
"%s",
player.difficulty );
3420 xmlw_elem( writer,
"gui",
"%s",
player.gui );
3421 xmlw_elem( writer,
"mapOverlay",
"%d", ovr_isOpen() );
3423 xmlw_elem( writer,
"radar_res",
"%f",
player.radar_res );
3424 xmlw_elem( writer,
"eq_outfitMode",
"%d",
player.eq_outfitMode );
3425 xmlw_elem( writer,
"map_minimal",
"%d",
player.map_minimal );
3426 xmlw_elem( writer,
"fleet_capacity",
"%d",
player.fleet_capacity );
3429 xmlw_startElem( writer,
"time" );
3430 ntime_getR( &cycles, &periods, &seconds, &rem );
3431 xmlw_elem( writer,
"SCU",
"%d", cycles );
3432 xmlw_elem( writer,
"STP",
"%d", periods );
3433 xmlw_elem( writer,
"STU",
"%d", seconds );
3434 xmlw_elem( writer,
"Remainder",
"%lf", rem );
3435 xmlw_endElem( writer );
3438 xmlw_elem( writer,
"location",
"%s",
land_spob->name );
3442 xmlw_startElem( writer,
"ships" );
3445 xmlw_endElem( writer );
3448 xmlw_startElem( writer,
"guis" );
3451 xmlw_elem( writer,
"gui",
"%s", guis[i] );
3452 xmlw_endElem( writer );
3455 xmlw_startElem( writer,
"outfits" );
3457 xmlw_startElem( writer,
"outfit" );
3460 xmlw_endElem( writer );
3462 xmlw_endElem( writer );
3465 xmlw_startElem( writer,
"licenses" );
3468 xmlw_endElem( writer );
3471 xmlw_startElem( writer,
"inventory" );
3475 xmlw_startElem( writer,
"item" );
3476 xmlw_attr( writer,
"quantity",
"%d", pi->
quantity );
3477 xmlw_str( writer,
"%s", pi->
name );
3478 xmlw_endElem( writer );
3480 xmlw_endElem( writer );
3482 xmlw_endElem( writer );
3485 xmlw_startElem( writer,
"missions_done" );
3489 xmlw_elem( writer,
"done",
"%s", m->
name );
3491 xmlw_endElem( writer );
3494 xmlw_startElem( writer,
"events_done" );
3498 xmlw_elem( writer,
"done",
"%s", ev );
3500 xmlw_endElem( writer );
3503 xmlw_startElem( writer,
"escorts" );
3505 xmlw_endElem( writer );
3508 xmlw_startElem( writer,
"metadata" );
3510 xmlw_endElem( writer );
3522 xmlw_startElem( writer,
"outfit" );
3523 xmlw_attr( writer,
"slot",
"%d", i );
3525 xmlw_attr( writer,
"quantity",
"%d", slot->u.
ammo.
quantity );
3526 xmlw_str( writer,
"%s", o->
name );
3527 xmlw_endElem( writer );
3542 xmlw_startElem( writer,
"ship" );
3543 xmlw_attr( writer,
"name",
"%s", ship->
name );
3544 xmlw_attr( writer,
"model",
"%s", ship->
ship->
name );
3545 xmlw_attr( writer,
"favourite",
"%d", pship->
favourite );
3546 xmlw_attr( writer,
"deployed",
"%d", pship->
deployed );
3550 xmlw_elem( writer,
"acquired",
"%s", pship->
acquired );
3551 xmlw_saveNTime( writer,
"acquired_date", pship->
acquired_date );
3552 xmlw_elem( writer,
"time_played",
"%f", pship->
time_played );
3557 xmlw_elem( writer,
"jumped_times",
"%u", pship->
jumped_times );
3558 xmlw_elem( writer,
"landed_times",
"%u", pship->
landed_times );
3559 xmlw_elem( writer,
"death_counter",
"%u", pship->
death_counter );
3562 xmlw_startElem( writer,
"ships_destroyed" );
3563 for (
int i = SHIP_CLASS_NULL + 1; i < SHIP_CLASS_TOTAL; i++) {
3564 char buf[STRMAX_SHORT];
3566 for (
size_t j = 0; j < strlen( buf ); j++)
3571 xmlw_endElem( writer );
3574 xmlw_elem( writer,
"fuel",
"%f", ship->
fuel );
3577 xmlw_startElem( writer,
"outfits_intrinsic" );
3580 xmlw_endElem( writer );
3581 xmlw_startElem( writer,
"outfits_structure" );
3587 xmlw_endElem( writer );
3588 xmlw_startElem( writer,
"outfits_utility" );
3594 xmlw_endElem( writer );
3595 xmlw_startElem( writer,
"outfits_weapon" );
3601 xmlw_endElem( writer );
3604 xmlw_startElem( writer,
"commodities" );
3628 WARN( _(
"Found mission cargo '%s' without associated mission." ),
3630 WARN( _(
"Please reload save game to remove the dead cargo." ) );
3634 WARN( _(
"Found cargo '%s' with 0 quantity." ), pc->
commodity->
name );
3635 WARN( _(
"Please reload save game to remove the dead cargo." ) );
3639 xmlw_startElem( writer,
"commodity" );
3641 xmlw_attr( writer,
"quantity",
"%d", pc->
quantity );
3643 xmlw_attr( writer,
"id",
"%d", pc->
id );
3646 xmlw_endElem( writer );
3648 xmlw_endElem( writer );
3650 xmlw_startElem( writer,
"weaponsets" );
3651 xmlw_attr( writer,
"autoweap",
"%d", ship->
autoweap );
3652 xmlw_attr( writer,
"advweap",
"%d", ship->
advweap );
3653 xmlw_attr( writer,
"aim_lines",
"%d", ship->
aimLines );
3654 for (
int i = 0; i < PILOT_WEAPON_SETS; i++) {
3657 xmlw_startElem( writer,
"weaponset" );
3659 xmlw_attr( writer,
"inrange",
"%d", ws->
inrange );
3660 xmlw_attr( writer,
"manual",
"%d", ws->
manual );
3661 xmlw_attr( writer,
"volley",
"%d", ws->
volley );
3662 xmlw_attr( writer,
"id",
"%d", i );
3664 xmlw_attr( writer,
"type",
"%d", ws->
type );
3665 for (
int j = 0; j <
array_size( weaps ); j++) {
3666 xmlw_startElem( writer,
"weapon" );
3667 xmlw_str( writer,
"%d", weaps[j].slotid );
3668 xmlw_endElem( writer );
3671 xmlw_endElem( writer );
3673 xmlw_endElem( writer );
3676 xmlw_startElem( writer,
"vars" );
3678 xmlw_endElem( writer );
3680 xmlw_endElem( writer );
3693 time_t t = time( NULL );
3694 double diff = difftime( t,
player.time_since_save );
3697 player.time_played += diff;
3698 player.ps.time_played += diff;
3699 player.time_since_save = t;
3702 xmlw_saveTime( writer,
"last_played", time( NULL ) );
3703 xmlw_saveTime( writer,
"date_created",
player.date_created );
3706 xmlw_elem( writer,
"time_played",
"%f",
player.time_played );
3707 xmlw_elem( writer,
"dmg_done_shield",
"%f",
player.dmg_done_shield );
3708 xmlw_elem( writer,
"dmg_done_armour",
"%f",
player.dmg_done_armour );
3709 xmlw_elem( writer,
"dmg_taken_shield",
"%f",
player.dmg_taken_shield );
3710 xmlw_elem( writer,
"dmg_taken_armour",
"%f",
player.dmg_taken_armour );
3711 xmlw_elem( writer,
"jumped_times",
"%u",
player.jumped_times );
3712 xmlw_elem( writer,
"landed_times",
"%u",
player.landed_times );
3713 xmlw_elem( writer,
"death_counter",
"%u",
player.death_counter );
3716 xmlw_startElem( writer,
"ships_destroyed" );
3717 for (
int i = SHIP_CLASS_NULL + 1; i < SHIP_CLASS_TOTAL; i++) {
3718 char buf[STRMAX_SHORT];
3720 for (
size_t j = 0; j < strlen( buf ); j++)
3723 xmlw_elem( writer, buf,
"%u",
player.ships_destroyed[i] );
3725 xmlw_endElem( writer );
3743 player.speed = conf.game_speed;
3748 player.last_played = time( NULL );
3757 node = parent->xmlChildrenNode;
3759 if (xml_isNode( node,
"metadata" ))
3761 else if (xml_isNode( node,
"player" ))
3763 else if (xml_isNode( node,
"missions_done" ))
3765 else if (xml_isNode( node,
"events_done" ))
3767 else if (xml_isNode( node,
"escorts" ))
3769 }
while (xml_nextNode( node ));
3772 player.time_since_save = time( NULL );
3775 if (
player.chapter == NULL)
3777 if (
player.difficulty != NULL)
3778 difficulty_setLocal( difficulty_get(
player.difficulty ) );
3780 difficulty_setLocal( NULL );
3801 static nlua_env player_updater_env = LUA_NOREF;
3806 if (player_updater_env == LUA_NOREF) {
3807 player_updater_env = nlua_newEnv(
"updater" );
3809 char *buf =
ndata_read( SAVE_UPDATER_PATH, &bufsize );
3810 if (nlua_dobufenv( player_updater_env, buf, bufsize,
3811 SAVE_UPDATER_PATH ) != 0) {
3812 WARN( _(
"Error loading file: %s\n"
3814 "Most likely Lua file has improper syntax, please check" ),
3815 SAVE_UPDATER_PATH, lua_tostring(
naevL, -1 ) );
3823 nlua_getenv(
naevL, player_updater_env, type );
3824 lua_pushstring(
naevL, name );
3825 if (nlua_pcall( player_updater_env, 1, 1 )) {
3826 WARN( _(
"Board: '%s'" ), lua_tostring(
naevL, -1 ) );
3827 lua_pop(
naevL, 1 );
3830 if (lua_type(
naevL, -1 ) == LUA_TNUMBER) {
3832 lua_pop(
naevL, 1 );
3854 else if (lua_type(
naevL, -1 ) == LUA_TSTRING)
3859 WARN( _(
"Outfit '%s' in player save not found!" ), name );
3861 lua_pop(
naevL, 1 );
3881 else if (lua_type(
naevL, -1 ) == LUA_TSTRING)
3886 WARN( _(
"Ship '%s' in player save not found!" ), name );
3888 lua_pop(
naevL, 1 );
3908 else if (lua_type(
naevL, -1 ) == LUA_TSTRING)
3911 WARN( _(
"Saved license does not exist and could not be found or "
3914 lua_pop(
naevL, 1 );
3925 const char *spob = NULL;
3927 xmlNodePtr node, cur;
3928 int map_overlay_enabled = 0;
3933 xmlr_attr_strd( parent,
"name",
player.name );
3934 assert(
player.p == NULL );
3940 node = parent->xmlChildrenNode;
3942 xmlr_str( node,
"location", spob );
3943 }
while (xml_nextNode( node ));
3946 node = parent->xmlChildrenNode;
3950 xmlr_strd( node,
"gui",
player.gui );
3951 xmlr_strd( node,
"chapter",
player.chapter );
3952 xmlr_int( node,
"mapOverlay", map_overlay_enabled );
3953 xmlr_float( node,
"radar_res",
player.radar_res );
3954 xmlr_int( node,
"eq_outfitMode",
player.eq_outfitMode );
3955 xmlr_int( node,
"map_minimal",
player.map_minimal );
3956 xmlr_int( node,
"fleet_capacity",
player.fleet_capacity );
3959 if (xml_isNode( node,
"time" )) {
3961 int cycles = -1, periods = -1, seconds = -1;
3962 cur = node->xmlChildrenNode;
3964 xmlr_int( cur,
"SCU", cycles );
3965 xmlr_int( cur,
"STP", periods );
3966 xmlr_int( cur,
"STU", seconds );
3967 xmlr_float( cur,
"Remainder", rem );
3968 }
while (xml_nextNode( cur ));
3969 if (( cycles < 0 ) || ( periods < 0 ) || ( seconds < 0 ) ||
3971 WARN( _(
"Malformed time in save game!" ) );
3973 if (( cycles >= 0 ) || ( periods >= 0 ) || ( seconds >= 0 ))
3977 if (xml_isNode( node,
"ship" ))
3981 else if (xml_isNode( node,
"ships" )) {
3982 cur = node->xmlChildrenNode;
3984 if (xml_isNode( cur,
"ship" ))
3986 }
while (xml_nextNode( cur ));
3990 else if (xml_isNode( node,
"guis" )) {
3991 cur = node->xmlChildrenNode;
3993 if (xml_isNode( cur,
"gui" ))
3995 }
while (xml_nextNode( cur ));
3999 else if (xml_isNode( node,
"outfits" )) {
4000 cur = node->xmlChildrenNode;
4002 if (xml_isNode( cur,
"outfit" )) {
4005 const char *oname = xml_get( cur );
4006 xmlr_attr_float( cur,
"quantity", q );
4008 WARN( _(
"Outfit '%s' was saved without quantity!" ),
4009 ( oname != NULL ) ? oname :
"NULL" );
4019 }
while (xml_nextNode( cur ));
4023 else if (xml_isNode( node,
"licenses" ))
4026 else if (xml_isNode( node,
"inventory" ))
4029 }
while (xml_nextNode( node ));
4034 pilot_clearFlagsRaw( flags );
4035 pilot_setFlagRaw( flags, PILOT_PLAYER );
4036 pilot_setFlagRaw( flags, PILOT_NO_OUTFITS );
4037 WARN( _(
"Player ship does not exist! Giving starting ship." ) );
4039 _(
"You acquired this ship through save corruption." ),
4046 _(
"Something went horribly wrong, player does not exist after "
4058 s->
flags |= SHIP_NEEDSGFX;
4066 player.speed = conf.game_speed;
4072 _(
"Save has no time information, setting to start information." ) );
4078 DEBUG( _(
"Player save was updated!" ) );
4080 _(
"The loaded save games has had outfits and ships "
4081 "updated to the current Naev version. You will find "
4082 "that some outfits and ships you have had have been "
4083 "changed. In the case no equivalent outfit or ship was "
4084 "found, you have been refunded the cost in credits." ) );
4091 !spob_hasService( pnt, SPOB_SERVICE_LAND )) {
4092 WARN( _(
"Player starts out in non-existent or invalid spob '%s',"
4093 "trying to find a suitable one instead." ),
4106 const char *found = NULL;
4107 for (
int i = 0; i < 3; i++) {
4108 unsigned int services =
4109 SPOB_SERVICE_LAND | SPOB_SERVICE_INHABITED | SPOB_SERVICE_REFUEL;
4112 services |= SPOB_SERVICE_SHIPYARD;
4115 services |= SPOB_SERVICE_OUTFITS;
4122 WARN( _(
"Could not find a spob satisfying criteria %d." ), i );
4125 if (found == NULL) {
4126 WARN( _(
"Could not find a suitable spob. Choosing a random spob." ) );
4136 a = RNGF() * 2. * M_PI;
4137 r = RNGF() * pnt->
radius * 0.8;
4139 player.p->solid.dir = 2. * M_PI * RNGF();
4147 ovr_setOpen( map_overlay_enabled );
4163 return !
areEnemies( p->presence.faction, FACTION_PLAYER );
4174 xmlNodePtr node = parent->xmlChildrenNode;
4176 xml_onlyNodes( node );
4178 if (!xml_isNode( node,
"done" ))
4183 DEBUG( _(
"Mission '%s' doesn't seem to exist anymore, removing from "
4188 }
while (xml_nextNode( node ));
4200 xmlNodePtr node = parent->xmlChildrenNode;
4202 xml_onlyNodes( node );
4204 if (!xml_isNode( node,
"done" ))
4209 DEBUG( _(
"Event '%s' doesn't seem to exist anymore, removing from "
4214 }
while (xml_nextNode( node ));
4226 xmlNodePtr node = parent->xmlChildrenNode;
4228 xml_onlyNodes( node );
4230 if (!xml_isNode( node,
"license" ))
4233 const char *name = xml_get( node );
4235 WARN( _(
"License node is missing name." ) );
4239 }
while (xml_nextNode( node ));
4251 xmlNodePtr node = parent->xmlChildrenNode;
4254 xml_onlyNodes( node );
4256 if (!xml_isNode( node,
"item" ))
4259 xmlr_attr_int_def( node,
"quantity", q, 1 );
4260 const char *name = xml_get( node );
4262 WARN( _(
"Inventory item node is missing name." ) );
4266 }
while (xml_nextNode( node ));
4278 xmlNodePtr node = parent->xmlChildrenNode;
4283 if (!xml_isNode( node,
"escort" ))
4286 xmlr_attr_strd( node,
"type", buf );
4287 xmlr_attr_strd( node,
"name", name );
4290 name = xml_getStrd( node );
4291 if (strcmp( buf,
"bay" ) == 0)
4294 else if (strcmp( buf,
"fleet" ) == 0) {
4299 WARN( _(
"Fleet ship '%s' is deployed despite not being marked for "
4307 DEBUG( _(
"Fleet ship '%s' is deployed despite not being space "
4313 WARN( _(
"Escort has invalid type '%s'." ), buf );
4316 }
while (xml_nextNode( node ));
4328 xmlNodePtr node = parent->xmlChildrenNode;
4330 xml_onlyNodes( node );
4332 xmlr_float( node,
"dmg_done_shield",
player.dmg_done_shield );
4333 xmlr_float( node,
"dmg_done_armour",
player.dmg_done_armour );
4334 xmlr_float( node,
"dmg_taken_shield",
player.dmg_taken_shield );
4335 xmlr_float( node,
"dmg_taken_armour",
player.dmg_taken_armour );
4336 xmlr_uint( node,
"jumped_times",
player.jumped_times );
4337 xmlr_uint( node,
"landed_times",
player.landed_times );
4338 xmlr_uint( node,
"death_counter",
player.death_counter );
4339 xmlr_float( node,
"time_played",
player.time_played );
4341 if (xml_isNode( node,
"last_played" )) {
4342 xml_parseTime( node, &
player.last_played );
4344 }
else if (xml_isNode( node,
"date_created" )) {
4345 xml_parseTime( node, &
player.date_created );
4347 }
else if (xml_isNode( node,
"ships_destroyed" )) {
4348 xmlNodePtr cur = node->xmlChildrenNode;
4350 char buf[STRMAX_SHORT];
4353 xml_onlyNodes( cur );
4355 strncpy( buf, (
const char *)cur->name,
sizeof( buf ) - 1 );
4356 for (
size_t i = 0; i < strlen( buf ); i++)
4361 if (
class == SHIP_CLASS_NULL) {
4362 WARN( _(
"Unknown ship class '%s' when parsing "
4363 "'ships_destroyed' node!" ),
4364 (
const char *)cur->name );
4368 player.ships_destroyed[
class] = xml_getULong( cur );
4369 }
while (xml_nextNode( cur ));
4371 }
while (xml_nextNode( node ));
4384 DEBUG( _(
"Outfit '%s' does not fit designated slot on player's pilot "
4385 "'%s', adding to stock." ),
4393 DEBUG( _(
"Outfit '%s' does not fit on player's pilot '%s', adding to "
4412 const char *name = xml_get( node );
4414 WARN( _(
"Empty ship slot node found, skipping." ) );
4429 xmlr_attr_int( node,
"quantity", q );
4444 int id, autoweap, fuel, aim_lines;
4445 const Ship *ship_parsed;
4455 xmlr_attr_strd( parent,
"name", name );
4456 xmlr_attr_strd( parent,
"model", model );
4457 xmlr_attr_int_def( parent,
"favourite", ps.
favourite, 0 );
4458 xmlr_attr_int_def( parent,
"deployed", ps.
deployed, 0 );
4461 pilot_clearFlagsRaw( flags );
4463 pilot_setFlagRaw( flags, PILOT_PLAYER );
4464 pilot_setFlagRaw( flags, PILOT_NO_OUTFITS );
4467 if (!is_player && (
player.p != NULL ) &&
4468 strcmp( name,
player.p->name ) == 0) {
4469 DEBUG( _(
"Ignoring player-owned ship '%s': duplicate of player's "
4479 if (ship_parsed == NULL) {
4480 WARN( _(
"Player ship '%s' not found!" ), model );
4514 node = parent->xmlChildrenNode;
4516 xml_onlyNodes( node );
4519 xmlr_strd( node,
"acquired", ps.
acquired );
4520 if (xml_isNode( node,
"acquired_date" )) {
4524 xmlr_float( node,
"time_played", ps.
time_played );
4532 if (xml_isNode( node,
"ships_destroyed" )) {
4533 xmlNodePtr cur = node->xmlChildrenNode;
4535 char buf[STRMAX_SHORT];
4538 xml_onlyNodes( cur );
4540 strncpy( buf, (
const char *)cur->name,
sizeof( buf ) - 1 );
4541 for (
size_t i = 0; i < strlen( buf ); i++)
4546 if (
class == SHIP_CLASS_NULL) {
4547 WARN( _(
"Unknown ship class '%s' when parsing "
4548 "'ships_destroyed' node!" ),
4549 (
const char *)cur->name );
4554 }
while (xml_nextNode( cur ));
4558 xmlr_int( node,
"fuel", fuel );
4561 if (xml_isNode( node,
"outfits_structure" )) {
4562 xmlNodePtr cur = node->xmlChildrenNode;
4565 xml_onlyNodes( cur );
4566 if (!xml_isNode( cur,
"outfit" )) {
4567 WARN( _(
"Save has unknown '%s' tag!" ), xml_get( cur ) );
4570 xmlr_attr_int_def( cur,
"slot", n, -1 );
4572 WARN( _(
"Outfit slot out of range, not adding to ship." ) );
4576 }
while (xml_nextNode( cur ));
4578 }
else if (xml_isNode( node,
"outfits_utility" )) {
4579 xmlNodePtr cur = node->xmlChildrenNode;
4582 xml_onlyNodes( cur );
4583 if (!xml_isNode( cur,
"outfit" )) {
4584 WARN( _(
"Save has unknown '%s' tag!" ), xml_get( cur ) );
4587 xmlr_attr_int_def( cur,
"slot", n, -1 );
4589 WARN( _(
"Outfit slot out of range, not adding." ) );
4593 }
while (xml_nextNode( cur ));
4595 }
else if (xml_isNode( node,
"outfits_weapon" )) {
4596 xmlNodePtr cur = node->xmlChildrenNode;
4599 xml_onlyNodes( cur );
4600 if (!xml_isNode( cur,
"outfit" )) {
4601 WARN( _(
"Save has unknown '%s' tag!" ), xml_get( cur ) );
4604 xmlr_attr_int_def( cur,
"slot", n, -1 );
4606 WARN( _(
"Outfit slot out of range, not adding." ) );
4610 }
while (xml_nextNode( cur ));
4612 }
else if (xml_isNode( node,
"outfits_intrinsic" )) {
4613 xmlNodePtr cur = node->xmlChildrenNode;
4615 xml_onlyNodes( cur );
4616 if (!xml_isNode( cur,
"outfit" )) {
4617 WARN( _(
"Save has unknown '%s' tag!" ), xml_get( cur ) );
4623 WARN( _(
"Player ship '%s' has intrinsic outfit '%s' "
4624 "exceeding limits! Removing." ),
4629 }
while (xml_nextNode( cur ));
4631 }
else if (xml_isNode( node,
"commodities" )) {
4632 xmlNodePtr cur = node->xmlChildrenNode;
4634 if (xml_isNode( cur,
"commodity" )) {
4637 xmlr_attr_int( cur,
"quantity", quantity );
4638 xmlr_attr_int_def( cur,
"id", cid, 0 );
4643 WARN( _(
"Unknown commodity '%s' detected, removing." ),
4650 if (( quantity == 0 ) && ( cid == 0 ))
4651 WARN( _(
"Adding cargo '%s' to ship '%s' that is not a "
4652 "mission cargo with quantity=0!" ),
4656 }
while (xml_nextNode( cur ));
4660 }
while (xml_nextNode( node ));
4671 DEBUG( _(
"Player ship '%s' failed slot validity check , removing all "
4672 "outfits and adding to stock." ),
4685 for (
int i = 0; i < PILOT_WEAPON_SETS; i++)
4689 node = parent->xmlChildrenNode;
4693 if (xml_isNode( node,
"vars" )) {
4696 }
else if (!xml_isNode( node,
"weaponsets" ))
4700 xmlr_attr_int( node,
"autoweap", autoweap );
4701 xmlr_attr_int( node,
"advweap", ship->
advweap );
4704 xmlr_attr_int( node,
"aim_lines", aim_lines );
4707 cur = node->xmlChildrenNode;
4709 int in_range, manual, weap_type, volley;
4712 xml_onlyNodes( cur );
4713 if (!xml_isNode( cur,
"weaponset" )) {
4714 WARN( _(
"Player ship '%s' has unknown node '%s' in 'weaponsets' "
4715 "(expected 'weaponset')." ),
4716 ship->
name, cur->name );
4721 xmlr_attr_int_def( cur,
"id",
id, -1 );
4723 WARN( _(
"Player ship '%s' missing 'id' tag for weapon set." ),
4727 if ((
id < 0 ) || (
id >= PILOT_WEAPON_SETS )) {
4729 _(
"Player ship '%s' has invalid weapon set id '%d' [max %d]." ),
4730 ship->
name,
id, PILOT_WEAPON_SETS - 1 );
4738 xmlr_attr_int( cur,
"inrange", in_range );
4743 xmlr_attr_int( cur,
"manual", manual );
4748 xmlr_attr_int( cur,
"volley", volley );
4757 xmlr_attr_int_def( cur,
"type", weap_type, -1 );
4758 if (weap_type == -1) {
4759 WARN( _(
"Player ship '%s' missing 'type' tag for weapon set." ),
4766 ccur = cur->xmlChildrenNode;
4770 xml_onlyNodes( ccur );
4773 if (!xml_isNode( ccur,
"weapon" )) {
4774 WARN( _(
"Player ship '%s' has unknown 'weaponset' child node "
4775 "'%s' (expected 'weapon')." ),
4776 ship->
name, ccur->name );
4780 weapid = xml_getInt( ccur );
4782 WARN( _(
"Player ship '%s' has invalid weapon id %d [max %d]." ),
4790 }
while (xml_nextNode( ccur ));
4791 }
while (xml_nextNode( cur ));
4792 }
while (xml_nextNode( node ));
4797 pilot_setFlag( ship, PILOT_PLAYER );
4830 if (pilot_isFlag(
player.p, PILOT_STEALTH )) {
4847 player_message(
"#r%s", _(
"Unable to stealth: other pilots nearby!" ) );
void ai_think(Pilot *pilot, double dt, int dotask)
Heart of the AI, brains of the pilot.
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_front(ptr_array)
Returns the first element in the array.
#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_back(ptr_array)
Returns the last element in the array.
#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’.
int player_canBoard(int noisy)
Sees if the pilot can board a pilot.
int player_tryBoard(int noisy)
Attempt to board the player's target.
void cam_setZoom(double zoom)
Sets the camera zoom.
void cam_setTargetPilot(unsigned int follow, int soft_over)
Sets the target to follow.
void cam_setTargetPos(double x, double y, int soft_over)
Sets the camera target to a position.
double cam_getZoom(void)
Gets the camera zoom.
int cam_getTarget(void)
Returns the camera's current target.
void claim_clear(void)
Clears the claims on all systems.
void col_blend(glColour *blend, const glColour *fg, const glColour *bg, float alpha)
Blends two colours.
int comm_openPilot(unsigned int pilot)
Opens the communication dialogue with a pilot.
int comm_openSpob(Spob *spob)
Opens a communication dialogue with a spob.
Commodity * commodity_get(const char *name)
Gets a commodity by name.
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
char * dialogue_input(const char *title, int min, int max, const char *fmt,...)
Creates a dialogue that allows the player to write a message.
void dialogue_msg(const char *caption, const char *fmt,...)
Opens a dialogue window with an ok button and a message.
void dialogue_alertRaw(const char *msg)
Displays an alert popup with only an ok button and a message.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
int economy_init(void)
Initializes the economy.
void economy_clearKnown(void)
Clears all system knowledge.
void equipment_regenLists(unsigned int wid, int outfits, int ships)
Regenerates the equipment window lists.
void escort_freeList(Pilot *p)
Remove all escorts from a pilot.
int escort_clearDeployed(Pilot *p, int slot)
Clears deployed escorts of a pilot.
int escort_addList(Pilot *p, const Ship *ship, EscortType_t type, unsigned int id, int persist)
Adds an escort to the escort list of a pilot.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
int escorts_jump(const Pilot *parent, const JumpPoint *jp)
Have a pilot order its escorts to jump.
int event_start(const char *name, unsigned int *id)
Starts an event.
const char * event_dataName(int dataid)
Gets the event data name from id.
void events_cleanup(void)
Cleans up and removes active events.
int event_dataID(const char *evdata)
Gets the event data id from name.
void events_trigger(EventTrigger_t trigger)
Runs all the events matching a trigger.
void factions_reset(void)
Resets player standing and flags of factions to default.
int areEnemies(int a, int b)
Checks whether two factions are enemies.
int faction_get(const char *name)
Gets a faction ID by name.
void gui_clearMessages(void)
Clears the GUI messages.
void gui_setTarget(void)
Player just changed their pilot target.
void gui_setDefaults(void)
const char * gui_pick(void)
Determines which GUI should be used.
int gui_load(const char *name)
Attempts to load the actual GUI.
void gui_radarGetRes(double *res)
Outputs the radar's resolution.
void gui_forceBlink(void)
Force sets the spob and pilot radar blink.
void gui_cleanup(void)
Cleans up the GUI.
void gui_setNav(void)
Player just changed their nav computer target.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
int hooks_runParamDeferred(const char *stack, const HookParam *param)
Runs all the hooks of stack in the next frame. Does not trigger right away.
int hooks_run(const char *stack)
Runs all the hooks of stack.
void info_buttonClear(void)
Clears all the registered buttons.
int intro_display(const char *text, const char *mus)
Displays the introduction sequence.
void takeoff(int delay, int nosave)
Makes the player take off if landed.
unsigned int land_getWid(int window)
Gets the WID of a window by type.
void land_cleanup(void)
Cleans up some land-related variables.
void land(Spob *p, int load)
Opens up all the land dialogue stuff.
void land_refuel(void)
Refuels the player's current ship, if possible.
int outfits_filter(const Outfit **outfits, int n, int(*filter)(const Outfit *), const char *name)
Applies a filter function and string to a list of outfits.
int load_refresh(void)
Loads or refreshes saved games for the player.
const nsave_t * load_getList(const char *name)
Gets the array (array.h) of loaded saves.
int lvar_save(const lvar *arr, xmlTextWriterPtr writer)
Saves the mission variables.
lvar * lvar_load(xmlNodePtr parent)
Loads the vars from XML file.
Mission ** player_missions
void missions_run(MissionAvailability loc, int faction, const Spob *pnt, const StarSystem *sys)
Runs missions matching location, all Lua side and one-shot.
int mission_start(const char *name, unsigned int *id)
Starts a mission.
int mission_getID(const char *name)
Gets id from mission name.
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 music_choose(const char *situation)
Actually runs the music stuff, based on situation.
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
int news_init(void)
Initiate news linked list with a stack.
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
int lua_isoutfit(lua_State *L, int ind)
Checks to see if ind is a outfit.
const Outfit * lua_tooutfit(lua_State *L, int ind)
Lua bindings to interact with outfits.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
int lua_isship(lua_State *L, int ind)
Checks to see if ind is a ship.
const Ship * lua_toship(lua_State *L, int ind)
Lua bindings to interact with ships.
LuaSpob * lua_pushspob(lua_State *L, LuaSpob spob)
Pushes a spob on the stack.
int nlua_loadTk(nlua_env env)
Loads the Toolkit Lua library.
void var_cleanup(void)
Cleans up all the mission variables.
int strsort(const void *p1, const void *p2)
Sort function for sorting strings with qsort().
void ntime_set(ntime_t t)
Sets the time absolutely, does NOT generate an event, used at init.
ntime_t ntime_get(void)
Gets the current time.
void ntime_inc(ntime_t t)
Sets the time relatively.
void ntime_getR(int *cycles, int *periods, int *seconds, double *rem)
Gets the current time broken into individual components.
void ntime_setR(int cycles, int periods, int seconds, double rem)
Loads time including remainder.
void gl_screenshot(const char *filename)
Takes a screenshot.
void gl_renderShader(double x, double y, double w, double h, double r, const SimpleShader *shd, const glColour *c, int center)
Renders a simple shader.
void gl_renderLine(double x1, double y1, double x2, double y2, const glColour *c)
Draws a line.
void gl_gameToScreenCoords(double *nx, double *ny, double bx, double by)
Converts in-game coordinates to screen coordinates.
void gl_screenToGameCoords(double *nx, double *ny, int bx, int by)
Converts screen coordinates to in-game coordinates.
void gl_renderCircle(double cx, double cy, double r, const glColour *c, int filled)
Draws a circle.
const Outfit * outfit_get(const char *name)
Gets an outfit by name.
int outfit_isLauncher(const Outfit *o)
Checks if outfit is a weapon launcher.
int outfit_isLocalMap(const Outfit *o)
Checks if outfit is a local space map.
int outfit_compareTech(const void *outfit1, const void *outfit2)
Function meant for use with C89, C99 algorithm qsort().
const Outfit * outfit_getW(const char *name)
Gets an outfit by name without warning on no-find.
int outfit_fitsSlot(const Outfit *o, const OutfitSlot *s)
Checks to see if an outfit fits a slot.
int outfit_isFighterBay(const Outfit *o)
Checks if outfit is a fighter bay.
int outfit_isMap(const Outfit *o)
Checks if outfit is a space map.
int outfit_isLicense(const Outfit *o)
Checks if outfit is a license.
int outfit_isGUI(const Outfit *o)
Checks if outfit is a GUI.
int outfit_licenseExists(const char *name)
Checks to see if a license exists.
void pause_setSpeed(double mod)
Adjusts the game's dt modifier.
void pilot_free(Pilot *p)
Frees and cleans up a pilot.
void pilot_stackRemove(Pilot *p)
Tries to remove a pilot from the stack.
int pilot_isHostile(const Pilot *p)
Checks to see if pilot is hostile to the player.
void pilot_cooldown(Pilot *p, int dochecks)
Begins active cooldown, reducing hull and outfit temperatures.
unsigned int pilot_getNearestPilot(const Pilot *p)
Get the nearest pilot to a pilot.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
Pilot * pilot_createEmpty(const Ship *ship, const char *name, int faction, PilotFlags flags)
Creates a pilot without adding it to the stack.
double pilot_face(Pilot *p, double dir, double dt)
Tries to turn the pilot to face dir.
double pilot_getNearestPos(const Pilot *p, unsigned int *tp, double x, double y, int disabled)
Get the nearest pilot to a pilot from a certain position.
Pilot * pilot_setPlayer(Pilot *after)
Replaces the player's pilot with an alternate ship with the same ID.
void pilot_renderOverlay(Pilot *p)
Renders the pilot overlay.
void pilot_setAccel(Pilot *p, double accel)
Sets the pilot's accel.
void pilot_cooldownEnd(Pilot *p, const char *reason)
Terminates active cooldown.
credits_t pilot_modCredits(Pilot *p, credits_t amount)
Modifies the amount of credits the pilot has.
void pilot_hyperspaceAbort(Pilot *p)
Stops the pilot from hyperspacing.
void pilot_setTurn(Pilot *p, double turn)
Sets the pilot's turn.
int pilot_validTarget(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid target for another pilot.
void pilot_reset(Pilot *pilot)
Resets a pilot.
int pilot_isFriendly(const Pilot *p)
Checks to see if pilot is friendly to the player.
PilotOutfitSlot * pilot_getDockSlot(Pilot *p)
Gets the dock slot of the pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
ntime_t pilot_hyperspaceDelay(const Pilot *p)
Calculates the hyperspace delay for a pilot.
double pilot_getNearestPosPilot(const Pilot *p, Pilot **tp, double x, double y, int disabled)
Get the nearest pilot to a pilot from a certain position.
static Pilot ** pilot_stack
void pilot_render(Pilot *p)
Renders the pilot.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_canTarget(const Pilot *p)
Same as pilot_validTarget but without the range check.
credits_t pilot_worth(const Pilot *p, int count_unique)
Gets the price or worth of a pilot in credits.
double pilot_aimAngle(Pilot *p, const vec2 *pos, const vec2 *vel)
Returns the angle for a pilot to aim at another pilot.
unsigned int pilot_getNextID(unsigned int id, int mode)
Gets the next pilot based on id.
void pilots_cleanAll(void)
Even cleans up the player.
void pilot_update(Pilot *pilot, double dt)
Updates the pilot.
unsigned int pilot_getPrevID(unsigned int id, int mode)
Gets the previous pilot based on ID.
int pilot_numOutfit(const Pilot *p, const Outfit *o)
Checks to see how many of an outfit a pilot has.
int pilot_hasCredits(const Pilot *p, credits_t amount)
Checks to see if the pilot has at least a certain amount of credits.
void pilot_setTarget(Pilot *p, unsigned int id)
Sets the target of the pilot.
int pilot_cargoMoveRaw(Pilot *dest, Pilot *src)
Moves cargo from one pilot to another without any checks.
int pilot_cargoAddRaw(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Adds cargo without checking the pilot's free space.
int pilot_inRangePilot(const Pilot *p, const Pilot *target, double *dist2)
Check to see if a pilot is in sensor range of another.
int pilot_ewScanCheck(const Pilot *p)
Checks to see if a scan is done.
int pilot_inRangeSpob(const Pilot *p, int target)
Check to see if a spob is in sensor range of the pilot.
void pilot_destealth(Pilot *p)
Destealths a pilot.
int pilot_stealth(Pilot *p)
Stealths a pilot.
int pilot_hasOutfitLimit(const Pilot *p, const char *limit)
Checks to see if a pilot has an outfit with a specific outfit type.
int pilot_slotsCheckSafety(const Pilot *p)
Pilot slot safety check - makes sure stats are safe.
int pilot_outfitLAdd(const Pilot *pilot, PilotOutfitSlot *po)
Outfit is added to a ship.
int pilot_maxAmmoO(const Pilot *p, const Outfit *o)
Gets the maximum available ammo for a pilot for a specific outfit.
void pilot_outfitLOnjumpin(Pilot *pilot)
Runs Lua outfits when pilot jumps into a system.
void pilot_calcStats(Pilot *pilot)
Recalculates the pilot's stats based on his outfits.
int pilot_addAmmo(Pilot *pilot, PilotOutfitSlot *s, int quantity)
Adds some ammo to the pilot stock.
int pilot_hasIntrinsic(const Pilot *pilot, const Outfit *outfit)
Gets how many copies of an intrinsic a pilot has.
int pilot_rmOutfitRaw(Pilot *pilot, PilotOutfitSlot *s)
Removes an outfit from the pilot without doing any checks.
int pilot_outfitLRemove(const Pilot *pilot, PilotOutfitSlot *po)
Outfit is removed froma ship.
int pilot_addOutfitRaw(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds an outfit to the pilot, ignoring CPU or other limits.
int pilot_rmOutfitIntrinsic(Pilot *pilot, const Outfit *outfit)
Removes an outfit from an intrinsic slot.
int pilot_isSpaceworthy(const Pilot *p)
Pilot safety check - makes sure stats are safe.
int pilot_addOutfitIntrinsic(Pilot *pilot, const Outfit *outfit)
Adds an outfit as an intrinsic slot.
void pilot_outfitLInitAll(Pilot *pilot)
Runs the pilot's Lua outfits init script.
void pilot_weapSetAdd(Pilot *p, int id, const PilotOutfitSlot *o)
Adds an outfit to a weapon set.
void pilot_weapSetInrange(Pilot *p, int id, int inrange)
Changes the weapon set inrange property.
void pilot_weaponSafe(Pilot *p)
Sets the weapon set as safe.
void pilot_weapSetManual(Pilot *p, int id, int manual)
Changes the weapon set manual property.
void pilot_afterburnOver(Pilot *p)
Deactivates the afterburner.
void pilot_weapSetVolley(Pilot *p, int id, int volley)
Changes the weapon set volley property.
void ws_copy(PilotWeaponSet dest[PILOT_WEAPON_SETS], const PilotWeaponSet src[PILOT_WEAPON_SETS])
Copies a weapon set over.
void ws_free(PilotWeaponSet ws[PILOT_WEAPON_SETS])
Frees a weapon set.
int pilot_outfitOffAll(Pilot *p)
Disables all active outfits for a pilot.
void pilot_weapSetUpdateOutfitState(Pilot *p)
Updates the local state of all the pilot's outfits based on the weapon sets.
void pilot_weapSetClear(Pilot *p, int id)
Clears a weapon set.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
int pilot_weapSetPress(Pilot *p, int id, int type)
Handles a weapon set press.
void pilot_weapSetType(Pilot *p, int id, WeaponSetType type)
Changes the weapon sets mode.
void player_hailStart(void)
Starts the hail sounds and aborts autoNav.
void player_stealth(void)
Input binding for toggling stealth for the player.
void player_weapSetPress(int id, double value, int repeat)
Handles keyboard events involving the player's weapon-set keys. It's valid to call this while gamepla...
int player_eventAlreadyDone(int id)
Checks to see if player has already completed a event.
int player_nships(void)
Gets the amount of ships player has in storage.
int player_save(xmlTextWriterPtr writer)
Save the freaking player in a freaking xmlfile.
void player_soundResume(void)
Resumes the ship's sounds.
static int player_saveShipSlot(xmlTextWriterPtr writer, const PilotOutfitSlot *slot, int i)
Saves an outfit slot.
int player_rmOutfit(const Outfit *o, int quantity)
Remove an outfit from the player's outfit stack.
void player_runHooks(void)
Runs hooks for the player.
static int player_shipsCompare(const void *arg1, const void *arg2)
PlayerShip_t compare function for qsort().
void player_updateSpecific(Pilot *pplayer, const double dt)
Does a player specific update.
static void player_clearEscorts(void)
Clears escorts to make sure deployment is safe.
int player_getOutfitsFiltered(const Outfit ***outfits, int(*filter)(const Outfit *o), const char *name)
Prepares two arrays for displaying in an image array.
int player_hasLicense(const char *license)
Checks to see if player has license.
void player_autohail(void)
Automatically tries to hail a pilot that hailed the player.
void player_dead(void)
Player got pwned.
void player_swapShip(const char *shipname, int move_cargo)
Swaps player's current ship with their ship named shipname.
static void player_renderAimHelper(double dt)
Renders the aim helper.
void player_cooldownBrake(void)
Starts braking or active cooldown.
void player_accel(double acc)
Start accelerating.
static double player_hailTimer
int player_ships(char **sships, glTexture **tships)
Returns a buffer with all the player's ships names.
void player_targetEscort(int prev)
Targets the pilot.
void player_targetAsteroidSet(int field, int id)
Sets the player's target asteroid.
static void player_parseShipSlot(xmlNodePtr node, Pilot *ship, PilotOutfitSlot *slot)
Parses a ship outfit slot.
static void player_renderStealthUnderlay(double dt)
Renders the stealth overlay for the player.
int player_addOutfit(const Outfit *o, int quantity)
Adds an outfit to the player outfit stack.
void player_soundPlay(int sound, int once)
Plays a sound at the player.
static int player_soundReserved
void player_new(void)
Creates a new player.
static PlayerShip_t * player_stack
void player_warp(double x, double y)
Warps the player to the new position.
static int player_parseDoneMissions(xmlNodePtr parent)
Parses player's done missions.
static PlayerShip_t * player_newShipMake(const char *name)
Actually creates the new ship.
static int player_parseEscorts(xmlNodePtr parent)
Parses the escorts from the escort node.
void player_checkLandAck(void)
Revokes landing authorization if the player's reputation is too low.
int player_numOutfits(void)
Gets the amount of different outfits in the player outfit stack.
static int player_parseShip(xmlNodePtr parent, int is_player)
Parses a player's ship.
void player_targetSet(unsigned int id)
Sets the player's target.
static int screenshot_cur
static void player_tryAddLicense(const char *name)
Tries to get an outfit for the player or looks for equivalents.
void player_render(double dt)
Renders the player.
void player_hailSpob(void)
Opens communication with the player's spob target.
credits_t player_shipPrice(const char *shipname, int count_unique)
Calculates the price of one of the player's ships.
void player_resetSpeed(void)
Resets the player speed stuff.
static int player_lastEngineSound
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
static int player_outfitCompare(const void *arg1, const void *arg2)
qsort() compare function for PlayerOutfit_t sorting.
void player_targetHyperspaceSet(int id, int nomsg)
Sets the player's hyperspace target.
static char * player_message_noland
static int player_parseMetadata(xmlNodePtr parent)
Parses the player metadata.
void player_cleanup(void)
Cleans up player stuff like player_stack.
static int player_parseLicenses(xmlNodePtr parent)
Parses player's licenses.
void player_targetHyperspace(void)
Gets a hyperspace target.
static double player_timer
PlayerShip_t * player_newShip(const Ship *ship, const char *def_name, int trade, const char *acquired, int noname)
Creates a new ship for player.
void player_rmShip(const char *shipname)
Removes one of the player's ships.
int player_outfitOwnedTotal(const Outfit *o)
void player_hyperspacePreempt(int preempt)
Enables or disables jump points preempting spobs in autoface and target clearing.
PlayerShip_t * player_getPlayerShip(const char *shipname)
Gets a specific ship.
void player_toggleMouseFly(void)
Toggles mouse flying.
void player_targetNearest(void)
Player targets nearest pilot.
static PlayerOutfit_t * player_outfits
static credits_t player_payback
double player_dt_default(void)
Returns the player's total default time delta based on time dilation stuff.
void player_update(Pilot *pplayer, const double dt)
Player update function.
static const Ship * player_tryGetShip(const char *name)
Tries to get an ship for the player or looks for equivalents.
const char ** player_getLicenses()
Gets the array (array.h) of license names in the player's inventory.
void player_brokeHyperspace(void)
Player actually broke hyperspace (entering new system).
static credits_t player_creds
int player_getHypPreempt(void)
Returns whether the jump point target should preempt the spob target.
int player_missionAlreadyDone(int id)
Checks to see if player has already completed a mission.
void player_renderUnderlay(double dt)
Renders the player underlay.
static int player_hailCounter
int player_addEscorts(void)
Adds the player's escorts.
static int player_parseDoneEvents(xmlNodePtr parent)
Parses player's done missions.
#define RADAR_RES_DEFAULT
void player_soundStop(void)
Stops playing player sounds.
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
void player_addLicense(const char *license)
Gives the player a license.
credits_t player_modCredits(credits_t amount)
Modifies the amount of credits the player has.
int * player_eventsDoneList(void)
Gets a list of all the events the player has done.
int player_jump(void)
Actually attempts to jump in hyperspace.
void player_targetSpobSet(int id)
Sets the player's target spob.
static int player_filterSuitableSpob(Spob *p)
Filter function for space_getRndSpob.
void player_clear(void)
Clears the targets.
static const Outfit * player_tryGetOutfit(const char *name, int q)
Tries to get an outfit for the player or looks for equivalents.
static void player_addOutfitToPilot(Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
Adds outfit to pilot if it can.
static void player_spobOutOfRangeMsg(void)
Displays an out of range message for the player's currently selected spob.
static int player_runUpdaterScript(const char *type, const char *name, int q)
Runs the save updater script, leaving any result on the stack of naevL.
static Spob * player_parse(xmlNodePtr parent)
Parses the player node.
int player_hasShip(const char *shipname)
Sees if player has a ship of a name.
void player_accelOver(void)
Done accelerating.
static int player_gui_group
void player_think(Pilot *pplayer, const double dt)
Basically uses keyboard input instead of AI input. Used in pilot.c.
int player_land(int loud)
Try to land or target closest spob if no land target.
static int player_newMake(void)
Actually creates a new player.
static int player_saveShip(xmlTextWriterPtr writer, PlayerShip_t *pship)
Saves a ship.
static int player_hyper_group
void player_soundPause(void)
Pauses the ship's sounds.
static int player_saveEscorts(xmlTextWriterPtr writer)
Saves the player's escorts.
int player_hasCredits(credits_t amount)
Checks to see if the player has enough credits.
static int player_engine_group
void player_shipsSort(void)
Sorts the players ships.
void player_missionFinished(int id)
Marks a mission as completed.
int player_outfitOwned(const Outfit *o)
Gets how many of the outfit the player owns.
void player_targetClearAll(void)
Clears all player targets: hyperspace, spob, asteroid, etc...
static int * missions_done
static char ** player_licenses
void player_nolandMsg(const char *str)
Sets the no land message.
void player_targetPrev(int mode)
Cycles to previous target.
const PlayerOutfit_t * player_getOutfits(void)
Gets an array (array.h) of the player's outfits.
Spob * player_load(xmlNodePtr parent)
Loads the player stuff.
static void player_newSetup()
Sets up a new player.
static int player_ran_updater
static const Ship * player_ship
void player_soundPlayGUI(int sound, int once)
Plays a GUI sound (unaffected by time accel).
static void player_renderStealthOverlay(double dt)
Renders the stealth overlay for the player.
void player_targetClear(void)
Clears the player's ship, spob or hyperspace target, in that order.
void player_targetHostile(void)
Targets the nearest hostile enemy to the player.
static void player_initSound(void)
Initializes the player sounds.
static int player_parseInventory(xmlNodePtr parent)
Parses player's inventory.
void player_eventFinished(int id)
Marks a event as completed.
void player_screenshot(void)
Takes a screenshot.
void player_approach(void)
Logic to make the player approach a target pilot to board or spob to land on.
void player_destroyed(void)
Player blew up in a fireball.
void player_targetSpob(void)
Cycle through spob targets.
int player_init(void)
Initializes player stuff.
int * player_missionsDoneList(void)
Gets a list of all the missions the player has done.
static void player_checkHail(void)
Checks to see if player is still being hailed and clears hail counters if he isn't.
Pilot * player_getShip(const char *shipname)
Gets a specific ship.
static int player_thinkMouseFly(double dt)
Handles mouse flying based on cursor position.
void player_targetNext(int mode)
Cycles to next target.
static int player_saveMetadata(xmlTextWriterPtr writer)
Saves the player meta-data.
void player_hail(void)
Opens communication with the player's target.
void player_autonavEnd(void)
Ends the autonav.
int player_autonavInit(void)
Initialize the autonav code.
void player_autonavResetSpeed(void)
Resets the game speed.
void player_autonavStart(void)
Starts autonav.
void player_autonavReset(double s)
Resets the game speed without disabling autonav.
void player_autonavBoard(unsigned int p)
Starts autonav with a pilot to board.
void player_autonavSpob(const char *name, int tryland)
Starts autonav with a spob destination.
void player_autonavEnter(void)
Signal to the autonav that a new system was entered.
void player_autonavAbort(const char *reason)
Aborts autonav.
void player_thinkAutonav(Pilot *pplayer, double dt)
Handles autonav thinking.
int pfleet_deploy(PlayerShip_t *ps)
Deploys a player's pilot.
void pfleet_update(void)
Updates the used fleet capacity of the player.
const char ** player_guiList(void)
Gets the list of GUIs.
int player_guiAdd(const char *name)
Adds a gui to the player.
int player_guiCheck(const char *name)
Check if player has a GUI.
void player_guiCleanup(void)
Cleans up the player's GUI list.
int player_inventoryAdd(const char *name, int amount)
Adds an item to the player inventory.
static PlayerItem * inventory
void player_inventoryClear(void)
Clears the inventory and frees memory.
const PlayerItem * player_inventory(void)
Gets the whole player inventory.
ShipClass ship_classFromString(const char *str)
Gets the machine ship class identifier from a human readable string.
const char * ship_classDisplay(const Ship *s)
Gets the ship's display class in human readable form.
const Ship * ship_getW(const char *name)
Gets a ship based on its name without warning.
int ship_gfxLoadNeeded(void)
Tries to load the graphics for all ships that need it.
const char * ship_classToString(ShipClass class)
Gets the ship class name in human readable form.
int ship_gfxLoaded(const Ship *s)
Checks to see if a ship has loaded graphics.
glTexture * ship_gfxStore(const Ship *s, int size, double dir, double updown, double glow)
Get the store gfx.
const Ship * ship_get(const char *name)
Gets a ship based on its name.
void shiplog_clear(void)
Clear the shiplog.
int sound_createGroup(int size)
Creates a sound group.
void sound_pitchGroup(int group, double pitch)
Sets the pitch of a group.
void sound_resumeGroup(int group)
Resumes all the sounds in a group.
void sound_speedGroup(int group, int enable)
Sets whether or not the speed affects a group.
int sound_playGroup(int group, int sound, int once)
Plays a sound in a group.
void sound_stopGroup(int group)
Stops all the sounds in a group.
void sound_stopAll(void)
Stops all the playing voices.
int sound_get(const char *name)
Gets the buffer to sound of name.
void sound_pauseGroup(int group)
Pauses all the sounds in a group.
void sound_volumeGroup(int group, double volume)
Sets the volume of a group.
void sound_setSpeed(double s)
Sets the speed to play the sound at.
void space_init(const char *sysname, int do_simulate)
Initializes the system.
void space_gfxUnload(StarSystem *sys)
Unloads all the graphics for a star system.
Spob * spob_get(const char *spobname)
Gets a spob based on its name.
const char * space_getRndSpob(int landable, unsigned int services, int(*filter)(Spob *p))
Gets the name of a random spob.
int spob_index(const Spob *p)
Gets the ID of a spob.
char spob_getColourChar(const Spob *p)
Gets the spob colour char.
StarSystem * system_get(const char *sysname)
Get the system from its name.
int space_calcJumpInPos(const StarSystem *in, const StarSystem *out, vec2 *pos, vec2 *vel, double *dir, const Pilot *p)
Calculates the jump in pos for a pilot.
void spob_updateLand(Spob *p)
Updates the land possibilities of a spob.
void space_clearKnown(void)
Clears all system knowledge.
const char * spob_getSystemName(const char *spobname)
Get the name of a system from a spobname.
const char * spob_name(const Spob *p)
Gets the translated name of a spob.
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.
const char * start_acquired(void)
Gets the module's starting ship was acquired.
const char * start_event(void)
Gets the starting event of the player.
const char * start_mission(void)
Gets the starting mission of the player.
void start_position(double *x, double *y)
Gets the starting position of the player.
const char * start_chapter(void)
Gets the player's starting chapter.
const char * start_ship(void)
Gets the module player starting ship.
ntime_t start_date(void)
Gets the starting date.
const char * start_shipname(void)
Gets the module's starting ship's name.
const char * start_system(void)
Gets the starting system name.
unsigned int start_credits(void)
Gets the player's starting credits.
Represents an asteroid field anchor.
Represents a single asteroid.
The actual hook parameter.
union HookParam::@065274143236224234262250043114351136253171035204 u
A ship outfit, depends radically on the type.
union Outfit::@264277167364127137334024361374356236341374052147 u
OutfitAfterburnerData afb
Stores a pilot commodity.
const Commodity * commodity
Stores an outfit the pilot has.
A pilot Weapon Set Outfit.
A weapon set represents a set of weapons that have an action.
PilotWeaponSetOutfit * slots
The representation of an in-game pilot.
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
PilotCommodity * commodities
PilotOutfitSlot * outfit_structure
PilotOutfitSlot ** outfits
PilotOutfitSlot * outfit_utility
PilotOutfitSlot * outfit_intrinsic
PilotOutfitSlot * afterburner
PilotOutfitSlot * outfit_weapon
Represents an item in the player inventory.
unsigned int death_counter
unsigned int landed_times
unsigned int ships_destroyed[SHIP_CLASS_TOTAL]
unsigned int jumped_times
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
Abstraction for rendering sprite sheets.
Contains a mission variable.
void diff_clear(void)
Removes all active diffs. (Call before economy_destroy().)