naev 0.12.6
pilot_cargo.c File Reference

Handles the pilot cargo stuff. More...

#include "pilot_cargo.h"
#include "array.h"
#include "commodity.h"
#include "gui.h"
#include "log.h"
#include "rng.h"
Include dependency graph for pilot_cargo.c:

Go to the source code of this file.

Functions

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_cargoOwned (const Pilot *pilot, const Commodity *cargo)
 Gets how many of the commodity a pilot has.
int pilot_cargoFree (const Pilot *p)
 Gets the pilot's free cargo space.
int pilot_cargoMoveRaw (Pilot *dest, Pilot *src)
 Moves cargo from one pilot to another without any checks.
int pilot_cargoMove (Pilot *dest, Pilot *src)
 Moves cargo from one pilot to another.
int pilot_cargoAddRaw (Pilot *pilot, const Commodity *cargo, int quantity, unsigned int id)
 Adds cargo without checking the pilot's free 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_cargoUsedMission (const Pilot *p)
 Gets how much mission cargo ship has on board.
void pilot_cargoCalc (Pilot *pilot)
 Calculates how much cargo ship has left and such.
unsigned int pilot_addMissionCargo (Pilot *pilot, const Commodity *cargo, int quantity)
 Adds special mission cargo, can't sell it and such.
unsigned int pilot_genMissionCargoID (Pilot *pilot)
int pilot_rmMissionCargo (Pilot *pilot, unsigned int cargo_id, int jettison)
 Removes special mission cargo based on id.
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_cargoRmAll (Pilot *pilot, int cleanup)
 Gets rid of all cargo from pilot. Can remove mission cargo.
int pilot_cargoRm (Pilot *pilot, const Commodity *cargo, int quantity)
 Tries to get rid of quantity cargo from pilot.
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.

Variables

static unsigned int mission_cargo_id

Detailed Description

Handles the pilot cargo stuff.

Definition in file pilot_cargo.c.

Function Documentation

◆ pilot_addMissionCargo()

unsigned int pilot_addMissionCargo ( Pilot * pilot,
const Commodity * cargo,
int quantity )

Adds special mission cargo, can't sell it and such.

Parameters
pilotPilot to add it to.
cargoCommodity to add.
quantityQuantity to add.
Returns
The Mission Cargo ID of created cargo.

Definition at line 249 of file pilot_cargo.c.

◆ pilot_cargoAdd()

int pilot_cargoAdd ( Pilot * pilot,
const Commodity * cargo,
int quantity,
unsigned int id )

Tries to add quantity of cargo to pilot.

Note that the commodity will not be added as 0 quantity unless 0 is explicitly specified, or it is mission cargo.

Parameters
pilotPilot to add cargo to.
cargoCargo to add.
quantityQuantity to add.
idMission ID to add (0 is none).
Returns
Quantity actually added.

Definition at line 183 of file pilot_cargo.c.

◆ pilot_cargoAddInternal()

int pilot_cargoAddInternal ( Pilot * pilot,
const Commodity * cargo,
int quantity,
unsigned int id )
static

Adds cargo to the pilot's "commodities" array only.

Parameters
pilotPilot to add cargo to.
cargoCargo to add.
quantityQuantity to add.
idMission ID to add (0 is none).

Definition at line 113 of file pilot_cargo.c.

◆ pilot_cargoAddRaw()

int pilot_cargoAddRaw ( Pilot * pilot,
const Commodity * cargo,
int quantity,
unsigned int id )

Adds cargo without checking the pilot's free space.

Does not check if currently exists.

Parameters
pilotPilot to add cargo to.
cargoCargo to add.
quantityQuantity to add.
idMission ID to add (0 is none).

Definition at line 159 of file pilot_cargo.c.

◆ pilot_cargoCalc()

void pilot_cargoCalc ( Pilot * pilot)

Calculates how much cargo ship has left and such.

Parameters
pilotPilot to calculate free cargo space of.

Definition at line 234 of file pilot_cargo.c.

◆ pilot_cargoFree()

int pilot_cargoFree ( const Pilot * p)

Gets the pilot's free cargo space.

Parameters
pPilot to get the free space of.
Returns
Free cargo space on pilot.

Definition at line 53 of file pilot_cargo.c.

◆ pilot_cargoJet()

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.

Parameters
pPilot to get rid of cargo.
cargoCargo to get rid of.
quantityAmount of cargo to get rid of.
simulateDoesn't actually remove cargo, just simulates the removal.
Returns
Amount of cargo gotten rid of.

Definition at line 429 of file pilot_cargo.c.

◆ pilot_cargoMove()

int pilot_cargoMove ( Pilot * dest,
Pilot * src )

Moves cargo from one pilot to another.

At the end has dest have exactly the same cargo as src and leaves src with none.

Parameters
destDestination pilot.
srcSource pilot.
Returns
0 on success.

Definition at line 92 of file pilot_cargo.c.

◆ pilot_cargoMoveRaw()

int pilot_cargoMoveRaw ( Pilot * dest,
Pilot * src )

Moves cargo from one pilot to another without any checks.

At the end has dest have exactly the same cargo as src and leaves src with none.

Parameters
destDestination pilot.
srcSource pilot.
Returns
0 on success.

Definition at line 68 of file pilot_cargo.c.

◆ pilot_cargoOwned()

int pilot_cargoOwned ( const Pilot * pilot,
const Commodity * cargo )

Gets how many of the commodity a pilot has.

Parameters
pilotPilot to check.
cargoCommodity to check how many the player.p owns.
Returns
The number of commodities owned matching cargo.

Definition at line 38 of file pilot_cargo.c.

◆ pilot_cargoRm()

int pilot_cargoRm ( Pilot * pilot,
const Commodity * cargo,
int quantity )

Tries to get rid of quantity cargo from pilot.

Parameters
pilotPilot to get rid of cargo.
cargoCargo to get rid of.
quantityAmount of cargo to get rid of.
Returns
Amount of cargo gotten rid of.

Definition at line 415 of file pilot_cargo.c.

◆ pilot_cargoRmAll()

int pilot_cargoRmAll ( Pilot * pilot,
int cleanup )

Gets rid of all cargo from pilot. Can remove mission cargo.

Parameters
pilotPilot to get rid of cargo.
cleanupWhether we're cleaning up or not (removes mission cargo).
Returns
Amount of cargo gotten rid of.

Definition at line 371 of file pilot_cargo.c.

◆ pilot_cargoRmRaw()

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.

Parameters
pilotPilot to get rid of cargo.
cargoCargo to get rid of.
quantityAmount of cargo to get rid of.
cleanupWhether we're cleaning up or not (removes mission cargo).
Returns
Amount of cargo gotten rid of.

Definition at line 325 of file pilot_cargo.c.

◆ pilot_cargoUsed()

int pilot_cargoUsed ( const Pilot * p)

Gets how much cargo ship has on board.

Parameters
pPilot to get used cargo space of.
Returns
The used cargo space by pilot.

Definition at line 203 of file pilot_cargo.c.

◆ pilot_cargoUsedMission()

int pilot_cargoUsedMission ( const Pilot * p)

Gets how much mission cargo ship has on board.

Parameters
pPilot to get used cargo space of.
Returns
The used cargo space by pilot.

Definition at line 217 of file pilot_cargo.c.

◆ pilot_genMissionCargoID()

unsigned int pilot_genMissionCargoID ( Pilot * pilot)

Definition at line 258 of file pilot_cargo.c.

◆ pilot_rmMissionCargo()

int pilot_rmMissionCargo ( Pilot * pilot,
unsigned int cargo_id,
int jettison )

Removes special mission cargo based on id.

Parameters
pilotPilot to remove cargo from.
cargo_idID of the cargo to remove.
jettisonShould jettison the cargo?
Returns
0 on success (cargo removed).

Definition at line 282 of file pilot_cargo.c.

Variable Documentation

◆ mission_cargo_id

unsigned int mission_cargo_id
static
Initial value:
=
0

ID generator for special mission cargo. Not guaranteed to be absolutely unique, only unique for each pilot.

Definition at line 26 of file pilot_cargo.c.