13#include "player_fleet.h"
54 char buf_amount[ECON_MASS_STRLEN], buf_free[ECON_MASS_STRLEN], buf_needed[ECON_MASS_STRLEN];
58 if (!
dialogue_YesNo( _(
"Not Enough Cargo Space"), _(
"Your ship '%s' has %s of cargo but there is only %s of free space in the rest of the fleet. Get rid of %s of cargo to shrink your fleet?"), p->name, buf_amount, buf_free, buf_needed ))
68 if (e->
type != ESCORT_TYPE_FLEET)
70 if (strcmp( pe->
name, p->name )==0) {
76 WARN(_(
"Player deployed ship '%s' not found in escort list!"), p->name);
81 for (
int i=0; i<
array_size(p->commodities); i++) {
115 a = RNGF() * 2. * M_PI;
125 pilot_setFlag( ps->
p, PILOT_INVINC_PLAYER );
126 pilot_rmFlag( ps->
p, PILOT_PLAYER );
136 for (
int i=
array_size(p->commodities)-1; i>=0; i--) {
175static int pc_cmp(
const void *pa,
const void *pb )
181 if ((pca->
id > 0) && (pcb->
id==0))
183 else if ((pca->
id == 0) && (pcb->
id > 0))
197 shipCargo( &pclist,
player.
p, 1 );
203 if (e->
type != ESCORT_TYPE_FLEET)
205 shipCargo( &pclist, pe, 1 );
221 if (
landed && (q < pc->quantity))
226 WARN(_(
"Failure to add cargo '%s' to player fleet. Only %d of %d added."), pc->
commodity->
name, q, pc->
quantity );
251 if (e->
type != ESCORT_TYPE_FLEET)
275 if (e->
type != ESCORT_TYPE_FLEET)
300 if (e->
type != ESCORT_TYPE_FLEET)
326 if (e->
type != ESCORT_TYPE_FLEET)
356 if (e->
type != ESCORT_TYPE_FLEET)
384 shipCargo( &pclist,
player.
p, 0 );
390 if (e->
type != ESCORT_TYPE_FLEET)
392 shipCargo( &pclist, pe, 0 );
416 if (e->
type != ESCORT_TYPE_FLEET)
int ai_pinit(Pilot *p, const char *ai)
Initializes the pilot in the ai.
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#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_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void tonnes2str(char *str, int tonnes)
Converts tonnes to a usable string for displaying.
int dialogue_YesNo(const char *caption, const char *fmt,...)
Runs a dialogue with both yes and no options.
void equipment_updateShips(unsigned int wid, const char *str)
Updates the player's ship window.
unsigned int escort_createRef(Pilot *p, Pilot *pe, const vec2 *pos, const vec2 *vel, double dir, EscortType_t type, int add, int dockslot)
Creates an escort from a reference.
void escort_rmListIndex(Pilot *p, int i)
Remove from escorts list.
unsigned int land_getWid(int window)
Gets the WID of a window by type.
Header file with generic functions and naev-specifics.
void pilot_free(Pilot *p)
Frees and cleans up a pilot.
void pilot_stackRemove(Pilot *p)
Tries to remove a pilot from the stack.
void pilot_reset(Pilot *pilot)
Resets a pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoRm(Pilot *pilot, const Commodity *cargo, int quantity)
Tries to get rid of quantity cargo from pilot.
int pilot_cargoOwned(const Pilot *pilot, const Commodity *cargo)
Gets how many of the commodity a pilot has.
int pilot_cargoJet(Pilot *p, const Commodity *cargo, int quantity, int simulate)
Tries to get rid of quantity cargo from pilot, jetting it into space.
int pilot_cargoAdd(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Tries to add quantity of cargo to pilot.
int pilot_cargoUsed(const Pilot *p)
Gets how much cargo ship has on board.
int pilot_cargoAddRaw(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Adds cargo without checking the pilot's free space.
void pilot_cargoCalc(Pilot *pilot)
Calculates how much cargo ship has left and such.
void pilot_weaponAuto(Pilot *p)
Tries to automatically set and create the pilot's weapon set.
const PlayerShip_t * player_getShipStack(void)
Gets the array (array.h) of the player's ships.
int pfleet_toggleDeploy(PlayerShip_t *ps, int deploy)
Toggles a player ship as deployed.
int pfleet_deploy(PlayerShip_t *ps)
Deploys a player's pilot.
PilotCommodity * pfleet_cargoList(void)
Gets a list of all the cargo in the fleet.
PFleetCargo * pfleet_cargoListShips(const Commodity *com)
Gets the list of ships that are carry a certain commodity in the player fleet and the amount they are...
int pfleet_cargoFree(void)
Gets the total amount of free cargo space in the player's fleet.
void pfleet_cargoRedistribute(void)
Redistributes the cargo in the player's fleet.
int pfleet_cargoOwned(const Commodity *com)
Gets the total amount of a commodity type owned by the player's fleet.
int pfleet_cargoAdd(const Commodity *com, int q)
Adds some cargo to the player's fleet.
int pfleet_cargoRm(const Commodity *com, int q, int jet)
Removes some cargo from the player's fleet.
int pfleet_cargoUsed(void)
Gets the total cargo space used by the player's fleet.
void pfleet_update(void)
Updates the used fleet capacity of the player.
Stores a pilot commodity.
const Commodity * commodity
The representation of an in-game pilot.