naev 0.10.4
Macros | Functions | Variables
player.c File Reference

Contains all the player related stuff. More...

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

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 88 of file player.c.

Function Documentation

◆ cmp_int()

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

Definition at line 2884 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 2088 of file player.c.

◆ player_accelOver()

void player_accelOver ( void  )

Done accelerating.

Definition at line 2102 of file player.c.

◆ player_addEscorts()

int player_addEscorts ( void  )

Adds the player's escorts.

Returns
0 on success.

Definition at line 3074 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 3012 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 2803 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 4138 of file player.c.

◆ player_autohail()

void player_autohail ( void  )

Automatically tries to hail a pilot that hailed the player.

Definition at line 2405 of file player.c.

◆ player_board()

void player_board ( void  )

Definition at line 1746 of file player.c.

◆ player_brake()

void player_brake ( void  )

Starts braking or active cooldown.

Definition at line 2461 of file player.c.

◆ player_brokeHyperspace()

void player_brokeHyperspace ( void  )

Player actually broke hyperspace (entering new system).

Definition at line 1976 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 2329 of file player.c.

◆ player_checkLandAck()

void player_checkLandAck ( void  )

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

Definition at line 1703 of file player.c.

◆ player_cleanup()

void player_cleanup ( void  )

Cleans up player stuff like player_stack.

Definition at line 697 of file player.c.

◆ player_clear()

void player_clear ( void  )

Clears the targets.

Definition at line 919 of file player.c.

◆ player_clearEscorts()

static void player_clearEscorts ( void  )
static

Clears escorts to make sure deployment is safe.

Definition at line 3058 of file player.c.

◆ player_dead()

void player_dead ( void  )

Player got pwned.

Definition at line 2515 of file player.c.

◆ player_destroyed()

void player_destroyed ( void  )

Player blew up in a fireball.

Definition at line 2528 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 1871 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 2971 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 2951 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 2985 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 3929 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 1861 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 3026 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 2757 of file player.c.

◆ player_getOutfitsFiltered()

int player_getOutfitsFiltered ( const Outfit **  outfits,
int(*)(const Outfit *o)  filter,
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 2770 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 2682 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 2663 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 2623 of file player.c.

◆ player_hail()

void player_hail ( void  )

Opens communication with the player's target.

Definition at line 2358 of file player.c.

◆ player_hailSpob()

void player_hailSpob ( void  )

Opens communication with the player's spob target.

Definition at line 2386 of file player.c.

◆ player_hailStart()

void player_hailStart ( void  )

Starts the hail sounds and aborts autoNav.

Definition at line 1881 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 936 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 2996 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 2644 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 1851 of file player.c.

◆ player_init()

int player_init ( void  )

Initializes player stuff.

Definition at line 184 of file player.c.

◆ player_initSound()

static void player_initSound ( void  )
static

Initializes the player sounds.

Definition at line 817 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 1900 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 1549 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 3519 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 2927 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 2896 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 2941 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 947 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 238 of file player.c.

◆ player_newMake()

static int player_newMake ( void  )
static

Actually creates a new player.

Returns
0 on success.

Definition at line 302 of file player.c.

◆ player_newSetup()

static void player_newSetup ( )
static

Sets up a new player.

Definition at line 198 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 382 of file player.c.

◆ player_newShipMake()

static PlayerShip_t * player_newShipMake ( const char *  name)
static

Actually creates the new ship.

Definition at line 455 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 1733 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 2633 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 2791 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 2742 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 2701 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 2729 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 3703 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 3965 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 3940 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 4042 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 4015 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 3990 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 4086 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 4198 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 4164 of file player.c.

◆ player_render()

void player_render ( double  dt)

Renders the player.

Definition at line 955 of file player.c.

◆ player_renderAimHelper()

static void player_renderAimHelper ( double  dt)
static

Renders the aim helper.

Definition at line 1074 of file player.c.

◆ player_renderStealthOverlay()

static void player_renderStealthOverlay ( double  dt)
static

Renders the stealth overlay for the player.

Definition at line 1046 of file player.c.

◆ player_renderStealthUnderlay()

static void player_renderStealthUnderlay ( double  dt)
static

Renders the stealth overlay for the player.

Definition at line 1007 of file player.c.

◆ player_renderUnderlay()

void player_renderUnderlay ( double  dt)

Renders the player underlay.

Definition at line 993 of file player.c.

◆ player_resetSpeed()

void player_resetSpeed ( void  )

Resets the player speed stuff.

Definition at line 1416 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 1429 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 2859 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 669 of file player.c.

◆ player_runHooks()

void player_runHooks ( void  )

Runs hooks for the player.

Definition at line 3034 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 3582 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 3189 of file player.c.

◆ player_saveEscorts()

static int player_saveEscorts ( xmlTextWriterPtr  writer)
static

Saves the player's escorts.

Definition at line 3150 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 3474 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 3323 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 3303 of file player.c.

◆ player_screenshot()

void player_screenshot ( void  )

Takes a screenshot.

Definition at line 2299 of file player.c.

◆ player_shipPrice()

credits_t player_shipPrice ( const char *  shipname)

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

Parameters
shipnameName of the ship.
Returns
The price of the ship in credits.

Definition at line 639 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 2606 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 2553 of file player.c.

◆ player_shipsSort()

void player_shipsSort ( void  )

Sorts the players ships.

Definition at line 2589 of file player.c.

◆ player_soundPause()

void player_soundPause ( void  )

Pauses the ship's sounds.

Definition at line 882 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 858 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 847 of file player.c.

◆ player_soundResume()

void player_soundResume ( void  )

Resumes the ship's sounds.

Definition at line 893 of file player.c.

◆ player_soundStop()

void player_soundStop ( void  )

Stops playing player sounds.

Definition at line 866 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 2348 of file player.c.

◆ player_stealth()

void player_stealth ( void  )

Input binding for toggling stealth for the player.

Definition at line 4565 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 501 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 1492 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 2198 of file player.c.

◆ player_targetClearAll()

void player_targetClearAll ( void  )

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

Definition at line 2219 of file player.c.

◆ player_targetEscort()

void player_targetEscort ( int  prev)

Targets the pilot.

Parameters
prev1 if is cycling backwards.

Definition at line 2232 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 2141 of file player.c.

◆ player_targetHyperspace()

void player_targetHyperspace ( void  )

Gets a hyperspace target.

Definition at line 1813 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 1778 of file player.c.

◆ player_targetNearest()

void player_targetNearest ( void  )

Player targets nearest pilot.

Definition at line 2275 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 2180 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 2190 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 2112 of file player.c.

◆ player_targetSpob()

void player_targetSpob ( void  )

Cycle through spob targets.

Definition at line 1516 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 1453 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 1142 of file player.c.

◆ player_thinkMouseFly()

static int player_thinkMouseFly ( void  )
static

Handles mouse flying based on cursor position.

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

Definition at line 2487 of file player.c.

◆ player_toggleMouseFly()

void player_toggleMouseFly ( void  )

Toggles mouse flying.

Definition at line 2438 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 3678 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 3624 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 3651 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 1288 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 1304 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 907 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 1392 of file player.c.

Variable Documentation

◆ events_done

int* events_done = NULL
static

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

Definition at line 130 of file player.c.

◆ missions_done

int* missions_done = NULL
static

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

Definition at line 129 of file player.c.

◆ player

Player_t player

Local player.

Definition at line 73 of file player.c.

◆ player_acc

double player_acc = 0.

Accel velocity from input.

Definition at line 122 of file player.c.

◆ player_creds

credits_t player_creds = 0
static

Temporary hack for when creating.

Definition at line 75 of file player.c.

◆ player_engine_group

int player_engine_group = -1
static

Player engine sound group.

Definition at line 93 of file player.c.

◆ player_gui_group

int player_gui_group = -1
static

Player GUI sound group.

Definition at line 95 of file player.c.

◆ player_hailCounter

int player_hailCounter = 0
static

Number of times to play the hail.

Definition at line 107 of file player.c.

◆ player_hailTimer

double player_hailTimer = 0.
static

Timer for hailing.

Definition at line 108 of file player.c.

◆ player_hyper_group

int player_hyper_group = -1
static

Player hyperspace sound group.

Definition at line 94 of file player.c.

◆ player_lastEngineSound

int player_lastEngineSound = -1
static

Last engine sound.

Definition at line 106 of file player.c.

◆ player_left

double player_left = 0.

Player left turn velocity from input.

Definition at line 120 of file player.c.

◆ player_licenses

char** player_licenses = NULL
static

Licenses player has.

Definition at line 83 of file player.c.

◆ player_message_noland

char* player_message_noland = NULL
static

No landing message (when PLAYER_NOLAND is set).

Definition at line 78 of file player.c.

◆ player_outfits

PlayerOutfit_t* player_outfits = NULL
static

Outfits player has.

Definition at line 114 of file player.c.

◆ player_payback

credits_t player_payback = 0
static

Temporary hack for when creating.

Definition at line 76 of file player.c.

◆ player_ran_updater

int player_ran_updater = 0
static

Temporary hack for when creating.

Definition at line 77 of file player.c.

◆ player_right

double player_right = 0.

Player right turn velocity from input.

Definition at line 121 of file player.c.

◆ player_ship

const Ship* player_ship = NULL
static

Temporary ship to hold when naming it

Definition at line 74 of file player.c.

◆ player_soundReserved

int player_soundReserved = 0
static

Has the player already reserved sound?

Definition at line 813 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 113 of file player.c.

◆ player_timer

double player_timer = 0.
static

For death and such.

Definition at line 124 of file player.c.

◆ preemption

int preemption = 0
static

Definition at line 173 of file player.c.

◆ screenshot_cur

int screenshot_cur = 0
static

Current screenshot at.

Definition at line 2295 of file player.c.

◆ snd_hail

int snd_hail = -1

Sound when being hailed.

Definition at line 99 of file player.c.

◆ snd_hypEng

int snd_hypEng = -1

Hyperspace engine sound.

Definition at line 102 of file player.c.

◆ snd_hypJump

int snd_hypJump = -1

Hyperspace jump sound.

Definition at line 105 of file player.c.

◆ snd_hypPowDown

int snd_hypPowDown = -1

Hyperspace power down sound.

Definition at line 103 of file player.c.

◆ snd_hypPowUp

int snd_hypPowUp = -1

Hyperspace power up sound.

Definition at line 101 of file player.c.

◆ snd_hypPowUpJump

int snd_hypPowUpJump = -1

Hyperspace Power up to jump sound.

Definition at line 104 of file player.c.

◆ snd_jump

int snd_jump = -1

Sound when can jump.

Definition at line 97 of file player.c.

◆ snd_nav

int snd_nav = -1

Sound when changing nav computer.

Definition at line 98 of file player.c.

◆ snd_target

int snd_target = -1

Sound when targeting.

Definition at line 96 of file player.c.