13#include "pilot_cargo.h"
22 int quantity,
unsigned int id );
92 WARN(_(
"Unable to copy cargo over from pilot '%s' to '%s'. Leaving cargo as is."), src->
name, dest->
name );
108 int quantity,
unsigned int id )
146 int quantity,
unsigned int id )
170 int quantity,
unsigned int id )
174 if (freespace < quantity) {
175 quantity = freespace;
176 if ((quantity==0) && (
id==0))
192 for (
int i=0; i<
array_size(p->commodities); i++)
193 q += p->commodities[i].quantity;
206 for (
int i=0; i<
array_size(p->commodities); i++) {
237 unsigned int id, max_id;
406 double px,py, bvx, bvy;
411 n =
MAX( 1, RNG((
int)(quantity/10), (
int)(quantity/5)) );
414 bvx = p->solid.vel.x;
415 bvy = p->solid.vel.y;
416 for (
int i=0; i<n; i++) {
420 double r = RNGF()*25. - 12.5;
421 double a = 2. * M_PI * RNGF();
422 double vx = bvx + r*cos(a);
423 double vy = bvy + r*sin(a);
426 spfx_add( effect, px, py, vx, vy, SPFX_LAYER_BACK );
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_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void gui_setGeneric(const Pilot *pilot)
Calls trigger functions depending on who the pilot is.
Header file with generic functions and naev-specifics.
int pilot_cargoRmAll(Pilot *pilot, int cleanup)
Gets rid of all cargo from pilot. Can remove mission cargo.
int pilot_cargoFree(const Pilot *p)
Gets the pilot's free cargo space.
int pilot_cargoMove(Pilot *dest, Pilot *src)
Moves cargo from one pilot to another.
int pilot_cargoMoveRaw(Pilot *dest, Pilot *src)
Moves cargo from one pilot to another without any checks.
unsigned int pilot_addMissionCargo(Pilot *pilot, const Commodity *cargo, int quantity)
Adds special mission cargo, can't sell it and such.
int pilot_cargoRm(Pilot *pilot, const Commodity *cargo, int quantity)
Tries to get rid of quantity cargo from pilot.
static int pilot_cargoAddInternal(Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
Adds cargo to the pilot's "commodities" array only.
int pilot_cargoRmRaw(Pilot *pilot, const Commodity *cargo, int quantity, int cleanup)
Tries to get rid of quantity cargo from pilot. Can remove mission cargo.
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_cargoUsedMission(const Pilot *p)
Gets how much mission cargo ship has on board.
int pilot_rmMissionCargo(Pilot *pilot, unsigned int cargo_id, int jettison)
Removes special mission cargo based on id.
static unsigned int mission_cargo_id
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_updateMass(Pilot *pilot)
Updates the pilot stats after mass change.
int spfx_get(const char *name)
Gets the id of an spfx based on name.
void spfx_add(int effect, const double px, const double py, const double vx, const double vy, int layer)
Creates a new special effect.
Stores a pilot commodity.
const Commodity * commodity
The representation of an in-game pilot.
PilotCommodity * commodities