naev 0.11.5
player.c File Reference

Contains all the player related stuff. More...

#include "player.h"
#include "ai.h"
#include "board.h"
#include "camera.h"
#include "claim.h"
#include "comm.h"
#include "conf.h"
#include "dialogue.h"
#include "difficulty.h"
#include "economy.h"
#include "equipment.h"
#include "escort.h"
#include "event.h"
#include "font.h"
#include "gui.h"
#include "gui_omsg.h"
#include "hook.h"
#include "info.h"
#include "input.h"
#include "intro.h"
#include "land.h"
#include "land_outfits.h"
#include "load.h"
#include "log.h"
#include "map.h"
#include "map_overlay.h"
#include "menu.h"
#include "mission.h"
#include "music.h"
#include "ndata.h"
#include "news.h"
#include "nfile.h"
#include "nlua_misn.h"
#include "nlua_outfit.h"
#include "nlua_ship.h"
#include "nlua_var.h"
#include "nstring.h"
#include "ntime.h"
#include "nxml.h"
#include "opengl.h"
#include "pause.h"
#include "pilot.h"
#include "player_gui.h"
#include "player_fleet.h"
#include "player_inventory.h"
#include "rng.h"
#include "shiplog.h"
#include "sound.h"
#include "space.h"
#include "spfx.h"
#include "start.h"
#include "toolkit.h"
#include "unidiff.h"

Go to the source code of this file.

Macros

#define RADAR_RES_DEFAULT   50.
 

Functions

static void player_checkHail (void)
 Checks to see if player is still being hailed and clears hail counters if he isn't.
 
static void player_newSetup ()
 Sets up a new player.
 
static int player_newMake (void)
 Actually creates a new player.
 
static PlayerShip_tplayer_newShipMake (const char *name)
 Actually creates the new ship.
 
static void player_initSound (void)
 Initializes the player sounds.
 
static int player_saveEscorts (xmlTextWriterPtr writer)
 Saves the player's escorts.
 
static int player_saveShipSlot (xmlTextWriterPtr writer, const PilotOutfitSlot *slot, int i)
 Saves an outfit slot.
 
static int player_saveShip (xmlTextWriterPtr writer, PlayerShip_t *pship)
 Saves a ship.
 
static int player_saveMetadata (xmlTextWriterPtr writer)
 Saves the player meta-data.
 
static Spobplayer_parse (xmlNodePtr parent)
 Parses the player node.
 
static int player_parseDoneMissions (xmlNodePtr parent)
 Parses player's done missions.
 
static int player_parseDoneEvents (xmlNodePtr parent)
 Parses player's done missions.
 
static int player_parseLicenses (xmlNodePtr parent)
 Parses player's licenses.
 
static int player_parseInventory (xmlNodePtr parent)
 Parses player's inventory.
 
static void player_parseShipSlot (xmlNodePtr node, Pilot *ship, PilotOutfitSlot *slot)
 Parses a ship outfit slot.
 
static int player_parseShip (xmlNodePtr parent, int is_player)
 Parses a player's ship.
 
static int player_parseEscorts (xmlNodePtr parent)
 Parses the escorts from the escort node.
 
static int player_parseMetadata (xmlNodePtr parent)
 Parses the player metadata.
 
static void player_addOutfitToPilot (Pilot *pilot, const Outfit *outfit, PilotOutfitSlot *s)
 Adds outfit to pilot if it can.
 
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 const Outfitplayer_tryGetOutfit (const char *name, int q)
 Tries to get an outfit for the player or looks for equivalents.
 
static const Shipplayer_tryGetShip (const char *name)
 Tries to get an ship for the player or looks for equivalents.
 
static void player_tryAddLicense (const char *name)
 Tries to get an outfit for the player or looks for equivalents.
 
static void player_renderStealthUnderlay (double dt)
 Renders the stealth overlay for the player.
 
static void player_renderStealthOverlay (double dt)
 Renders the stealth overlay for the player.
 
static void player_renderAimHelper (double dt)
 Renders the aim helper.
 
static int player_filterSuitableSpob (Spob *p)
 Filter function for space_getRndSpob.
 
static void player_spobOutOfRangeMsg (void)
 Displays an out of range message for the player's currently selected spob.
 
static int player_outfitCompare (const void *arg1, const void *arg2)
 qsort() compare function for PlayerOutfit_t sorting.
 
static int player_thinkMouseFly (double dt)
 Handles mouse flying based on cursor position.
 
int player_save (xmlTextWriterPtr writer)
 Save the freaking player in a freaking xmlfile.
 
Spobplayer_load (xmlNodePtr parent)
 Loads the player stuff.
 
int player_init (void)
 Initializes player stuff.
 
void player_new (void)
 Creates a new player.
 
PlayerShip_tplayer_newShip (const Ship *ship, const char *def_name, int trade, const char *acquired, int noname)
 Creates a new ship for player.
 
void player_swapShip (const char *shipname, int move_cargo)
 Swaps player's current ship with their ship named shipname.
 
credits_t player_shipPrice (const char *shipname, int count_unique)
 Calculates the price of one of the player's ships.
 
void player_rmPlayerShip (PlayerShip_t *ps)
 
void player_rmShip (const char *shipname)
 Removes one of the player's ships.
 
void player_cleanup (void)
 Cleans up player stuff like player_stack.
 
void player_soundPlayGUI (int sound, int once)
 Plays a GUI sound (unaffected by time accel).
 
void player_soundPlay (int sound, int once)
 Plays a sound at the player.
 
void player_soundStop (void)
 Stops playing player sounds.
 
void player_soundPause (void)
 Pauses the ship's sounds.
 
void player_soundResume (void)
 Resumes the ship's sounds.
 
void player_warp (double x, double y)
 Warps the player to the new position.
 
void player_clear (void)
 Clears the targets.
 
int player_hasCredits (credits_t amount)
 Checks to see if the player has enough credits.
 
credits_t player_modCredits (credits_t amount)
 Modifies the amount of credits the player has.
 
void player_render (double dt)
 Renders the player.
 
void player_renderUnderlay (double dt)
 Renders the player underlay.
 
void player_think (Pilot *pplayer, const double dt)
 Basically uses keyboard input instead of AI input. Used in pilot.c.
 
void player_update (Pilot *pplayer, const double dt)
 Player update function.
 
void player_updateSpecific (Pilot *pplayer, const double dt)
 Does a player specific update.
 
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 gameplay is paused.
 
void player_resetSpeed (void)
 Resets the player speed stuff.
 
void player_restoreControl (int reason, const char *str)
 Aborts autonav and other states that take control of the ship.
 
void player_targetSpobSet (int id)
 Sets the player's target spob.
 
void player_targetAsteroidSet (int field, int id)
 Sets the player's target asteroid.
 
void player_targetSpob (void)
 Cycle through spob targets.
 
int player_land (int loud)
 Try to land or target closest spob if no land target.
 
void player_checkLandAck (void)
 Revokes landing authorization if the player's reputation is too low.
 
void player_nolandMsg (const char *str)
 Sets the no land message.
 
void player_approach (void)
 Logic to make the player approach a target pilot to board or spob to land on.
 
void player_targetHyperspaceSet (int id, int nomsg)
 Sets the player's hyperspace target.
 
void player_targetHyperspace (void)
 Gets a hyperspace target.
 
void player_hyperspacePreempt (int preempt)
 Enables or disables jump points preempting spobs in autoface and target clearing.
 
int player_getHypPreempt (void)
 Returns whether the jump point target should preempt the spob target.
 
double player_dt_default (void)
 Returns the player's total default time delta based on time dilation stuff.
 
void player_hailStart (void)
 Starts the hail sounds and aborts autoNav.
 
int player_jump (void)
 Actually attempts to jump in hyperspace.
 
void player_brokeHyperspace (void)
 Player actually broke hyperspace (entering new system).
 
void player_accel (double acc)
 Start accelerating.
 
void player_accelOver (void)
 Done accelerating.
 
void player_targetSet (unsigned int id)
 Sets the player's target.
 
void player_targetHostile (void)
 Targets the nearest hostile enemy to the player.
 
void player_targetNext (int mode)
 Cycles to next target.
 
void player_targetPrev (int mode)
 Cycles to previous target.
 
void player_targetClear (void)
 Clears the player's ship, spob or hyperspace target, in that order.
 
void player_targetClearAll (void)
 Clears all player targets: hyperspace, spob, asteroid, etc...
 
void player_targetEscort (int prev)
 Targets the pilot.
 
void player_targetNearest (void)
 Player targets nearest pilot.
 
void player_screenshot (void)
 Takes a screenshot.
 
void player_hail (void)
 Opens communication with the player's target.
 
void player_hailSpob (void)
 Opens communication with the player's spob target.
 
void player_autohail (void)
 Automatically tries to hail a pilot that hailed the player.
 
void player_toggleMouseFly (void)
 Toggles mouse flying.
 
void player_cooldownBrake (void)
 Starts braking or active cooldown.
 
void player_dead (void)
 Player got pwned.
 
void player_destroyed (void)
 Player blew up in a fireball.
 
static int player_shipsCompare (const void *arg1, const void *arg2)
 PlayerShip_t compare function for qsort().
 
void player_shipsSort (void)
 Sorts the players ships.
 
int player_ships (char **sships, glTexture **tships)
 Returns a buffer with all the player's ships names.
 
const PlayerShip_tplayer_getShipStack (void)
 Gets the array (array.h) of the player's ships.
 
int player_nships (void)
 Gets the amount of ships player has in storage.
 
int player_hasShip (const char *shipname)
 Sees if player has a ship of a name.
 
Pilotplayer_getShip (const char *shipname)
 Gets a specific ship.
 
PlayerShip_tplayer_getPlayerShip (const char *shipname)
 Gets a specific ship.
 
int player_outfitOwned (const Outfit *o)
 Gets how many of the outfit the player owns.
 
int player_outfitOwnedTotal (const Outfit *o)
 
const PlayerOutfit_tplayer_getOutfits (void)
 Gets an array (array.h) of the player's outfits.
 
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_numOutfits (void)
 Gets the amount of different outfits in the player outfit stack.
 
int player_addOutfit (const Outfit *o, int quantity)
 Adds an outfit to the player outfit stack.
 
int player_rmOutfit (const Outfit *o, int quantity)
 Remove an outfit from the player's outfit stack.
 
static int cmp_int (const void *p1, const void *p2)
 
void player_missionFinished (int id)
 Marks a mission as completed.
 
int player_missionAlreadyDone (int id)
 Checks to see if player has already completed a mission.
 
int * player_missionsDoneList (void)
 Gets a list of all the missions the player has done.
 
void player_eventFinished (int id)
 Marks a event as completed.
 
int player_eventAlreadyDone (int id)
 Checks to see if player has already completed a event.
 
int * player_eventsDoneList (void)
 Gets a list of all the events the player has done.
 
int player_hasLicense (const char *license)
 Checks to see if player has license.
 
void player_addLicense (const char *license)
 Gives the player a license.
 
const char ** player_getLicenses ()
 Gets the array (array.h) of license names in the player's inventory.
 
void player_runHooks (void)
 Runs hooks for the player.
 
static void player_clearEscorts (void)
 Clears escorts to make sure deployment is safe.
 
int player_addEscorts (void)
 Adds the player's escorts.
 
void player_stealth (void)
 Input binding for toggling stealth for the player.
 

Variables

Player_t player
 
static const Shipplayer_ship = NULL
 
static credits_t player_creds = 0
 
static credits_t player_payback = 0
 
static int player_ran_updater = 0
 
static char * player_message_noland = NULL
 
static char ** player_licenses = NULL
 
static int player_engine_group = -1
 
static int player_hyper_group = -1
 
static int player_gui_group = -1
 
int snd_target = -1
 
int snd_jump = -1
 
int snd_nav = -1
 
int snd_hail = -1
 
int snd_hypPowUp = -1
 
int snd_hypEng = -1
 
int snd_hypPowDown = -1
 
int snd_hypPowUpJump = -1
 
int snd_hypJump = -1
 
static int player_lastEngineSound = -1
 
static int player_hailCounter = 0
 
static double player_hailTimer = 0.
 
static PlayerShip_tplayer_stack = NULL
 
static PlayerOutfit_tplayer_outfits = NULL
 
double player_left = 0.
 
double player_right = 0.
 
double player_acc = 0.
 
static double player_timer = 0.
 
static int * missions_done = NULL
 
static int * events_done = NULL
 
static int preemption = 0
 
static int player_soundReserved = 0
 
static int screenshot_cur = 0
 

Detailed Description

Contains all the player related stuff.

Definition in file player.c.

Macro Definition Documentation

◆ RADAR_RES_DEFAULT

#define RADAR_RES_DEFAULT   50.

Default resolution.

Definition at line 89 of file player.c.

Function Documentation

◆ cmp_int()

static int cmp_int ( const void * p1,
const void * p2 )
static

Definition at line 2918 of file player.c.

◆ player_accel()

void player_accel ( double acc)

Start accelerating.

Parameters
accHow much thrust should be applied of maximum (0 - 1).

Definition at line 2113 of file player.c.

◆ player_accelOver()

void player_accelOver ( void )

Done accelerating.

Definition at line 2127 of file player.c.

◆ player_addEscorts()

int player_addEscorts ( void )

Adds the player's escorts.

Returns
0 on success.

Definition at line 3117 of file player.c.

◆ player_addLicense()

void player_addLicense ( const char * license)

Gives the player a license.

license License to give the player.

Definition at line 3055 of file player.c.

◆ player_addOutfit()

int player_addOutfit ( const Outfit * o,
int quantity )

Adds an outfit to the player outfit stack.

Parameters
oOutfit to add.
quantityAmount to add.
Returns
Amount added.

Definition at line 2828 of file player.c.

◆ player_addOutfitToPilot()

static void player_addOutfitToPilot ( Pilot * pilot,
const Outfit * outfit,
PilotOutfitSlot * s )
static

Adds outfit to pilot if it can.

Definition at line 4179 of file player.c.

◆ player_approach()

void player_approach ( void )

Logic to make the player approach a target pilot to board or spob to land on.

Definition at line 1757 of file player.c.

◆ player_autohail()

void player_autohail ( void )

Automatically tries to hail a pilot that hailed the player.

Definition at line 2425 of file player.c.

◆ player_brokeHyperspace()

void player_brokeHyperspace ( void )

Player actually broke hyperspace (entering new system).

Definition at line 2016 of file player.c.

◆ player_checkHail()

static void player_checkHail ( void )
static

Checks to see if player is still being hailed and clears hail counters if he isn't.

Definition at line 2349 of file player.c.

◆ player_checkLandAck()

void player_checkLandAck ( void )

Revokes landing authorization if the player's reputation is too low.

Definition at line 1713 of file player.c.

◆ player_cleanup()

void player_cleanup ( void )

Cleans up player stuff like player_stack.

Definition at line 730 of file player.c.

◆ player_clear()

void player_clear ( void )

Clears the targets.

Definition at line 947 of file player.c.

◆ player_clearEscorts()

static void player_clearEscorts ( void )
static

Clears escorts to make sure deployment is safe.

Definition at line 3101 of file player.c.

◆ player_cooldownBrake()

void player_cooldownBrake ( void )

Starts braking or active cooldown.

Definition at line 2481 of file player.c.

◆ player_dead()

void player_dead ( void )

Player got pwned.

Definition at line 2536 of file player.c.

◆ player_destroyed()

void player_destroyed ( void )

Player blew up in a fireball.

Definition at line 2549 of file player.c.

◆ player_dt_default()

double player_dt_default ( void )

Returns the player's total default time delta based on time dilation stuff.

Returns
The default/minimum time delta

Definition at line 1913 of file player.c.

◆ player_eventAlreadyDone()

int player_eventAlreadyDone ( int id)

Checks to see if player has already completed a event.

Parameters
idID of the event to see if player has completed.
Returns
1 if player has completed the event, 0 otherwise.

Definition at line 3014 of file player.c.

◆ player_eventFinished()

void player_eventFinished ( int id)

Marks a event as completed.

Parameters
idID of the event to mark as completed.

Definition at line 2985 of file player.c.

◆ player_eventsDoneList()

int * player_eventsDoneList ( void )

Gets a list of all the events the player has done.

Returns
Array (array.c) of all the events the player has done. Do not free!

Definition at line 3028 of file player.c.

◆ player_filterSuitableSpob()

static int player_filterSuitableSpob ( Spob * p)
static

Filter function for space_getRndSpob.

Parameters
pSpob.
Returns
Whether the spob is suitable for teleporting to.

Definition at line 3970 of file player.c.

◆ player_getHypPreempt()

int player_getHypPreempt ( void )

Returns whether the jump point target should preempt the spob target.

Returns
Boolean; 1 preempts spob target.

Definition at line 1903 of file player.c.

◆ player_getLicenses()

const char ** player_getLicenses ( void )

Gets the array (array.h) of license names in the player's inventory.

Definition at line 3069 of file player.c.

◆ player_getOutfits()

const PlayerOutfit_t * player_getOutfits ( void )

Gets an array (array.h) of the player's outfits.

Definition at line 2782 of file player.c.

◆ player_getOutfitsFiltered()

int player_getOutfitsFiltered ( const Outfit *** outfits,
int(* filter )(const Outfit *o),
const char * name )

Prepares two arrays for displaying in an image array.

Parameters
[out]outfitsOutfits the player owns.
[in]filterFunction to filter which outfits to get.
[in]nameName fragment that each outfit must contain.
Returns
Number of outfits.

Definition at line 2795 of file player.c.

◆ player_getPlayerShip()

PlayerShip_t * player_getPlayerShip ( const char * shipname)

Gets a specific ship.

Parameters
shipnameNome of the ship to get.
Returns
The ship matching name.

Definition at line 2703 of file player.c.

◆ player_getShip()

Pilot * player_getShip ( const char * shipname)

Gets a specific ship.

Parameters
shipnameNome of the ship to get.
Returns
The ship matching name.

Definition at line 2684 of file player.c.

◆ player_getShipStack()

const PlayerShip_t * player_getShipStack ( void )

Gets the array (array.h) of the player's ships.

Definition at line 2644 of file player.c.

◆ player_hail()

void player_hail ( void )

Opens communication with the player's target.

Definition at line 2378 of file player.c.

◆ player_hailSpob()

void player_hailSpob ( void )

Opens communication with the player's spob target.

Definition at line 2406 of file player.c.

◆ player_hailStart()

void player_hailStart ( void )

Starts the hail sounds and aborts autoNav.

Definition at line 1923 of file player.c.

◆ player_hasCredits()

int player_hasCredits ( credits_t amount)

Checks to see if the player has enough credits.

Parameters
amountAmount of credits to check to see if the player has.
Returns
1 if the player has enough credits.

Definition at line 964 of file player.c.

◆ player_hasLicense()

int player_hasLicense ( const char * license)

Checks to see if player has license.

Parameters
licenseLicense to check to see if the player has.
Returns
1 if has license (or none needed), 0 if doesn't.

Definition at line 3039 of file player.c.

◆ player_hasShip()

int player_hasShip ( const char * shipname)

Sees if player has a ship of a name.

Parameters
shipnameNome of the ship to get.
Returns
1 if ship exists.

Definition at line 2665 of file player.c.

◆ player_hyperspacePreempt()

void player_hyperspacePreempt ( int preempt)

Enables or disables jump points preempting spobs in autoface and target clearing.

Parameters
preemptBoolean; 1 preempts spob target.

Definition at line 1893 of file player.c.

◆ player_init()

int player_init ( void )

Initializes player stuff.

Definition at line 185 of file player.c.

◆ player_initSound()

static void player_initSound ( void )
static

Initializes the player sounds.

Definition at line 845 of file player.c.

◆ player_jump()

int player_jump ( void )

Actually attempts to jump in hyperspace.

Returns
1 if actually started a jump, 0 otherwise.

Definition at line 1941 of file player.c.

◆ player_land()

int player_land ( int loud)

Try to land or target closest spob if no land target.

Parameters
loudWhether or not to show messages irrelevant when auto-landing.
Returns
One of PLAYER_LAND_OK, PLAYER_LAND_AGAIN, or PLAYER_LAND_DENIED.

Definition at line 1579 of file player.c.

◆ player_load()

Spob * player_load ( xmlNodePtr parent)

Loads the player stuff.

Parameters
parentNode where the player stuff is to be found.
Returns
0 on success.

Definition at line 3563 of file player.c.

◆ player_missionAlreadyDone()

int player_missionAlreadyDone ( int id)

Checks to see if player has already completed a mission.

Parameters
idID of the mission to see if player has completed.
Returns
1 if player has completed the mission, 0 otherwise.

Definition at line 2961 of file player.c.

◆ player_missionFinished()

void player_missionFinished ( int id)

Marks a mission as completed.

Parameters
idID of the mission to mark as completed.

Definition at line 2930 of file player.c.

◆ player_missionsDoneList()

int * player_missionsDoneList ( void )

Gets a list of all the missions the player has done.

Returns
Array (array.c) of all the missions the player has done. Do not free!

Definition at line 2975 of file player.c.

◆ player_modCredits()

credits_t player_modCredits ( credits_t amount)

Modifies the amount of credits the player has.

Parameters
amountQuantity to modify player's credits by.
Returns
Amount of credits the player has.

Definition at line 975 of file player.c.

◆ player_new()

void player_new ( void )

Creates a new player.

  • Cleans up after old players.
  • Prompts for name.
See also
player_newMake

Definition at line 242 of file player.c.

◆ player_newMake()

static int player_newMake ( void )
static

Actually creates a new player.

Returns
0 on success.

Definition at line 330 of file player.c.

◆ player_newSetup()

static void player_newSetup ( )
static

Sets up a new player.

Definition at line 202 of file player.c.

◆ player_newShip()

PlayerShip_t * player_newShip ( const Ship * ship,
const char * def_name,
int trade,
const char * acquired,
int noname )

Creates a new ship for player.

Parameters
shipNew ship to get.
def_nameDefault name to give it if cancelled.
tradeWhether or not to trade player's current ship with the new ship.
acquiredDescription of how the ship was acquired.
nonameWhether or not to let the player name it.
Returns
Newly created pilot on success or NULL if dialogue was cancelled.
See also
player_newShipMake

Definition at line 410 of file player.c.

◆ player_newShipMake()

static PlayerShip_t * player_newShipMake ( const char * name)
static

Actually creates the new ship.

Definition at line 483 of file player.c.

◆ player_nolandMsg()

void player_nolandMsg ( const char * str)

Sets the no land message.

str Message to set when the player is not allowed to land temporarily.

Definition at line 1743 of file player.c.

◆ player_nships()

int player_nships ( void )

Gets the amount of ships player has in storage.

Returns
The number of ships the player has.

Definition at line 2654 of file player.c.

◆ player_numOutfits()

int player_numOutfits ( void )

Gets the amount of different outfits in the player outfit stack.

Returns
Amount of different outfits.

Definition at line 2816 of file player.c.

◆ player_outfitCompare()

static int player_outfitCompare ( const void * arg1,
const void * arg2 )
static

qsort() compare function for PlayerOutfit_t sorting.

Definition at line 2767 of file player.c.

◆ player_outfitOwned()

int player_outfitOwned ( const Outfit * o)

Gets how many of the outfit the player owns.

Parameters
oOutfit to check how many the player owns.
Returns
The number of outfits matching outfitname owned.

Definition at line 2722 of file player.c.

◆ player_outfitOwnedTotal()

int player_outfitOwnedTotal ( const Outfit * o)

Total number of an outfit owned by the player (including equipped).

Definition at line 2754 of file player.c.

◆ player_parse()

static Spob * player_parse ( xmlNodePtr parent)
static

Parses the player node.

Parameters
parentThe player node.
Returns
Spob to start on on success.

Definition at line 3747 of file player.c.

◆ player_parseDoneEvents()

static int player_parseDoneEvents ( xmlNodePtr parent)
static

Parses player's done missions.

Parameters
parentNode of the missions.
Returns
0 on success.

Definition at line 4006 of file player.c.

◆ player_parseDoneMissions()

static int player_parseDoneMissions ( xmlNodePtr parent)
static

Parses player's done missions.

Parameters
parentNode of the missions.
Returns
0 on success.

Definition at line 3981 of file player.c.

◆ player_parseEscorts()

static int player_parseEscorts ( xmlNodePtr parent)
static

Parses the escorts from the escort node.

Parameters
parent"escorts" node to parse.
Returns
0 on success.

Definition at line 4083 of file player.c.

◆ player_parseInventory()

static int player_parseInventory ( xmlNodePtr parent)
static

Parses player's inventory.

Parameters
parentNode of the inventory.
Returns
0 on success.

Definition at line 4056 of file player.c.

◆ player_parseLicenses()

static int player_parseLicenses ( xmlNodePtr parent)
static

Parses player's licenses.

Parameters
parentNode of the licenses.
Returns
0 on success.

Definition at line 4031 of file player.c.

◆ player_parseMetadata()

static int player_parseMetadata ( xmlNodePtr parent)
static

Parses the player metadata.

Parameters
parent"metadata" node to parse.
Returns
0 on success.

Definition at line 4127 of file player.c.

◆ player_parseShip()

static int player_parseShip ( xmlNodePtr parent,
int is_player )
static

Parses a player's ship.

Parameters
parentNode of the ship.
is_playerIs it the ship the player is currently in?
Returns
0 on success.

Definition at line 4238 of file player.c.

◆ player_parseShipSlot()

static void player_parseShipSlot ( xmlNodePtr node,
Pilot * ship,
PilotOutfitSlot * slot )
static

Parses a ship outfit slot.

Definition at line 4205 of file player.c.

◆ player_render()

void player_render ( double dt)

Renders the player.

Definition at line 983 of file player.c.

◆ player_renderAimHelper()

static void player_renderAimHelper ( double dt)
static

Renders the aim helper.

Definition at line 1102 of file player.c.

◆ player_renderStealthOverlay()

static void player_renderStealthOverlay ( double dt)
static

Renders the stealth overlay for the player.

Definition at line 1074 of file player.c.

◆ player_renderStealthUnderlay()

static void player_renderStealthUnderlay ( double dt)
static

Renders the stealth overlay for the player.

Definition at line 1035 of file player.c.

◆ player_renderUnderlay()

void player_renderUnderlay ( double dt)

Renders the player underlay.

Definition at line 1021 of file player.c.

◆ player_resetSpeed()

void player_resetSpeed ( void )

Resets the player speed stuff.

Definition at line 1448 of file player.c.

◆ player_restoreControl()

void player_restoreControl ( int reason,
const char * str )

Aborts autonav and other states that take control of the ship.

Parameters
reasonReason for aborting (see player.h)
strString accompanying the reason.

Definition at line 1461 of file player.c.

◆ player_rmOutfit()

int player_rmOutfit ( const Outfit * o,
int quantity )

Remove an outfit from the player's outfit stack.

Parameters
oOutfit to remove.
quantityAmount to remove.
Returns
Amount removed.

Definition at line 2890 of file player.c.

◆ player_rmPlayerShip()

void player_rmPlayerShip ( PlayerShip_t * ps)

Definition at line 692 of file player.c.

◆ player_rmShip()

void player_rmShip ( const char * shipname)

Removes one of the player's ships.

Parameters
shipnameName of the ship to remove.

Definition at line 705 of file player.c.

◆ player_runHooks()

void player_runHooks ( void )

Runs hooks for the player.

Definition at line 3077 of file player.c.

◆ player_runUpdaterScript()

static int player_runUpdaterScript ( const char * type,
const char * name,
int q )
static

Runs the save updater script, leaving any result on the stack of naevL.

Parameters
typeType of item to translate. Currently "outfit" and "license" are supported.
nameName of the inventory item.
qQuantity in possession.
Returns
Stack depth: 1 if player got a translated item back, 0 if they got nothing or just money.

Definition at line 3626 of file player.c.

◆ player_save()

int player_save ( xmlTextWriterPtr writer)

Save the freaking player in a freaking xmlfile.

Parameters
writerxml Writer to use.
Returns
0 on success.

Definition at line 3232 of file player.c.

◆ player_saveEscorts()

static int player_saveEscorts ( xmlTextWriterPtr writer)
static

Saves the player's escorts.

Definition at line 3193 of file player.c.

◆ player_saveMetadata()

static int player_saveMetadata ( xmlTextWriterPtr writer)
static

Saves the player meta-data.

Parameters
writerXML writer.
Returns
0 on success.

Definition at line 3518 of file player.c.

◆ player_saveShip()

static int player_saveShip ( xmlTextWriterPtr writer,
PlayerShip_t * pship )
static

Saves a ship.

Parameters
writerXML writer.
pshipShip to save.
Returns
0 on success.

Definition at line 3366 of file player.c.

◆ player_saveShipSlot()

static int player_saveShipSlot ( xmlTextWriterPtr writer,
const PilotOutfitSlot * slot,
int i )
static

Saves an outfit slot.

Definition at line 3346 of file player.c.

◆ player_screenshot()

void player_screenshot ( void )

Takes a screenshot.

Definition at line 2319 of file player.c.

◆ player_shipPrice()

credits_t player_shipPrice ( const char * shipname,
int count_unique )

Calculates the price of one of the player's ships.

Parameters
shipnameName of the ship.
count_uniqueWhether or not to count unique outfits too.
Returns
The price of the ship in credits.

Definition at line 667 of file player.c.

◆ player_ships()

int player_ships ( char ** sships,
glTexture ** tships )

Returns a buffer with all the player's ships names.

Parameters
sshipsFills sships with player_nships ship names.
tshipsFills sships with player_nships ship target textures.
Returns
Freshly allocated array with allocated ship names.
The number of ships the player has.

Definition at line 2627 of file player.c.

◆ player_shipsCompare()

static int player_shipsCompare ( const void * arg1,
const void * arg2 )
static

PlayerShip_t compare function for qsort().

Definition at line 2574 of file player.c.

◆ player_shipsSort()

void player_shipsSort ( void )

Sorts the players ships.

Definition at line 2610 of file player.c.

◆ player_soundPause()

void player_soundPause ( void )

Pauses the ship's sounds.

Definition at line 910 of file player.c.

◆ player_soundPlay()

void player_soundPlay ( int sound,
int once )

Plays a sound at the player.

Parameters
soundID of the sound to play.
oncePlay only once?

Definition at line 886 of file player.c.

◆ player_soundPlayGUI()

void player_soundPlayGUI ( int sound,
int once )

Plays a GUI sound (unaffected by time accel).

Parameters
soundID of the sound to play.
oncePlay only once?

Definition at line 875 of file player.c.

◆ player_soundResume()

void player_soundResume ( void )

Resumes the ship's sounds.

Definition at line 921 of file player.c.

◆ player_soundStop()

void player_soundStop ( void )

Stops playing player sounds.

Definition at line 894 of file player.c.

◆ player_spobOutOfRangeMsg()

static void player_spobOutOfRangeMsg ( void )
static

Displays an out of range message for the player's currently selected spob.

Definition at line 2368 of file player.c.

◆ player_stealth()

void player_stealth ( void )

Input binding for toggling stealth for the player.

Definition at line 4615 of file player.c.

◆ player_swapShip()

void player_swapShip ( const char * shipname,
int move_cargo )

Swaps player's current ship with their ship named shipname.

Parameters
shipnameShip to change to.
move_cargoWhether or not to move the cargo over or ignore it.

Definition at line 526 of file player.c.

◆ player_targetAsteroidSet()

void player_targetAsteroidSet ( int field,
int id )

Sets the player's target asteroid.

Parameters
fieldIndex of the parent field of the asteoid.
idTarget spob or -1 if none should be selected.

Definition at line 1522 of file player.c.

◆ player_targetClear()

void player_targetClear ( void )

Clears the player's ship, spob or hyperspace target, in that order.

Definition at line 2220 of file player.c.

◆ player_targetClearAll()

void player_targetClearAll ( void )

Clears all player targets: hyperspace, spob, asteroid, etc...

Definition at line 2241 of file player.c.

◆ player_targetEscort()

void player_targetEscort ( int prev)

Targets the pilot.

Parameters
prev1 if is cycling backwards.

Definition at line 2254 of file player.c.

◆ player_targetHostile()

void player_targetHostile ( void )

Targets the nearest hostile enemy to the player.

Note
This function largely duplicates pilot_getNearestEnemy, because the player's hostility with AIs is more nuanced than AI vs AI.

Definition at line 2163 of file player.c.

◆ player_targetHyperspace()

void player_targetHyperspace ( void )

Gets a hyperspace target.

Definition at line 1855 of file player.c.

◆ player_targetHyperspaceSet()

void player_targetHyperspaceSet ( int id,
int nomsg )

Sets the player's hyperspace target.

Parameters
idID of the hyperspace target.
nomsgWhether or not to display a message regarding aborting autonav.

Definition at line 1821 of file player.c.

◆ player_targetNearest()

void player_targetNearest ( void )

Player targets nearest pilot.

Definition at line 2297 of file player.c.

◆ player_targetNext()

void player_targetNext ( int mode)

Cycles to next target.

Parameters
modeMode to target. 0 is normal, 1 is hostiles.

Definition at line 2202 of file player.c.

◆ player_targetPrev()

void player_targetPrev ( int mode)

Cycles to previous target.

Parameters
modeMode to target. 0 is normal, 1 is hostiles.

Definition at line 2212 of file player.c.

◆ player_targetSet()

void player_targetSet ( unsigned int id)

Sets the player's target.

Parameters
idTarget to set for the player.

Definition at line 2137 of file player.c.

◆ player_targetSpob()

void player_targetSpob ( void )

Cycle through spob targets.

Definition at line 1546 of file player.c.

◆ player_targetSpobSet()

void player_targetSpobSet ( int id)

Sets the player's target spob.

Parameters
idTarget spob or -1 if none should be selected.

Definition at line 1485 of file player.c.

◆ player_think()

void player_think ( Pilot * pplayer,
const double dt )

Basically uses keyboard input instead of AI input. Used in pilot.c.

Parameters
pplayerPlayer to think.
dtCurrent delta tick.

Definition at line 1170 of file player.c.

◆ player_thinkMouseFly()

static int player_thinkMouseFly ( double dt)
static

Handles mouse flying based on cursor position.

Parameters
dtCurrent delta tick.
Returns
1 if cursor is outside the dead zone, 0 if it isn't.

Definition at line 2508 of file player.c.

◆ player_toggleMouseFly()

void player_toggleMouseFly ( void )

Toggles mouse flying.

Definition at line 2458 of file player.c.

◆ player_tryAddLicense()

static void player_tryAddLicense ( const char * name)
static

Tries to get an outfit for the player or looks for equivalents.

Definition at line 3722 of file player.c.

◆ player_tryGetOutfit()

static const Outfit * player_tryGetOutfit ( const char * name,
int q )
static

Tries to get an outfit for the player or looks for equivalents.

Definition at line 3668 of file player.c.

◆ player_tryGetShip()

static const Ship * player_tryGetShip ( const char * name)
static

Tries to get an ship for the player or looks for equivalents.

Definition at line 3695 of file player.c.

◆ player_update()

void player_update ( Pilot * pplayer,
const double dt )

Player update function.

Parameters
pplayerPlayer to update.
dtCurrent delta tick.

Definition at line 1318 of file player.c.

◆ player_updateSpecific()

void player_updateSpecific ( Pilot * pplayer,
const double dt )

Does a player specific update.

Parameters
pplayerPlayer to update.
dtCurrent delta tick.

Definition at line 1334 of file player.c.

◆ player_warp()

void player_warp ( double x,
double y )

Warps the player to the new position.

Parameters
xX value of the position to warp to.
yY value of the position to warp to.

Definition at line 935 of file player.c.

◆ player_weapSetPress()

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 gameplay is paused.

Definition at line 1422 of file player.c.

Variable Documentation

◆ events_done

int* events_done = NULL
static

Array (array.h): Saves position of completed events.

Definition at line 131 of file player.c.

◆ missions_done

int* missions_done = NULL
static

Array (array.h): Saves position of completed missions.

Definition at line 130 of file player.c.

◆ player

Player_t player

Local player.

Definition at line 74 of file player.c.

◆ player_acc

double player_acc = 0.

Accel velocity from input.

Definition at line 123 of file player.c.

◆ player_creds

credits_t player_creds = 0
static

Temporary hack for when creating.

Definition at line 76 of file player.c.

◆ player_engine_group

int player_engine_group = -1
static

Player engine sound group.

Definition at line 94 of file player.c.

◆ player_gui_group

int player_gui_group = -1
static

Player GUI sound group.

Definition at line 96 of file player.c.

◆ player_hailCounter

int player_hailCounter = 0
static

Number of times to play the hail.

Definition at line 108 of file player.c.

◆ player_hailTimer

double player_hailTimer = 0.
static

Timer for hailing.

Definition at line 109 of file player.c.

◆ player_hyper_group

int player_hyper_group = -1
static

Player hyperspace sound group.

Definition at line 95 of file player.c.

◆ player_lastEngineSound

int player_lastEngineSound = -1
static

Last engine sound.

Definition at line 107 of file player.c.

◆ player_left

double player_left = 0.

Player left turn velocity from input.

Definition at line 121 of file player.c.

◆ player_licenses

char** player_licenses = NULL
static

Licenses player has.

Definition at line 84 of file player.c.

◆ player_message_noland

char* player_message_noland = NULL
static

No landing message (when PLAYER_NOLAND is set).

Definition at line 79 of file player.c.

◆ player_outfits

PlayerOutfit_t* player_outfits = NULL
static

Outfits player has.

Definition at line 115 of file player.c.

◆ player_payback

credits_t player_payback = 0
static

Temporary hack for when creating.

Definition at line 77 of file player.c.

◆ player_ran_updater

int player_ran_updater = 0
static

Temporary hack for when creating.

Definition at line 78 of file player.c.

◆ player_right

double player_right = 0.

Player right turn velocity from input.

Definition at line 122 of file player.c.

◆ player_ship

const Ship* player_ship = NULL
static

Temporary ship to hold when naming it

Definition at line 75 of file player.c.

◆ player_soundReserved

int player_soundReserved = 0
static

Has the player already reserved sound?

Definition at line 841 of file player.c.

◆ player_stack

PlayerShip_t* player_stack = NULL
static

Stack of ships player has, excluding their current one (player.ps).

Definition at line 114 of file player.c.

◆ player_timer

double player_timer = 0.
static

For death and such.

Definition at line 125 of file player.c.

◆ preemption

int preemption = 0
static

Definition at line 174 of file player.c.

◆ screenshot_cur

int screenshot_cur = 0
static

Current screenshot at.

Definition at line 2315 of file player.c.

◆ snd_hail

int snd_hail = -1

Sound when being hailed.

Definition at line 100 of file player.c.

◆ snd_hypEng

int snd_hypEng = -1

Hyperspace engine sound.

Definition at line 103 of file player.c.

◆ snd_hypJump

int snd_hypJump = -1

Hyperspace jump sound.

Definition at line 106 of file player.c.

◆ snd_hypPowDown

int snd_hypPowDown = -1

Hyperspace power down sound.

Definition at line 104 of file player.c.

◆ snd_hypPowUp

int snd_hypPowUp = -1

Hyperspace power up sound.

Definition at line 102 of file player.c.

◆ snd_hypPowUpJump

int snd_hypPowUpJump = -1

Hyperspace Power up to jump sound.

Definition at line 105 of file player.c.

◆ snd_jump

int snd_jump = -1

Sound when can jump.

Definition at line 98 of file player.c.

◆ snd_nav

int snd_nav = -1

Sound when changing nav computer.

Definition at line 99 of file player.c.

◆ snd_target

int snd_target = -1

Sound when targeting.

Definition at line 97 of file player.c.