naev 0.10.4
Functions | Variables
pilot_cargo.c File Reference

Handles the pilot cargo stuff. More...

#include "pilot_cargo.h"
#include "array.h"
#include "economy.h"
#include "gui.h"
#include "log.h"

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

Variables

static unsigned int mission_cargo_id = 0
 

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 236 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 169 of file pilot_cargo.c.

◆ pilot_cargoAddInternal()

static 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 107 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 145 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 220 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 51 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 404 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 88 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 65 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 36 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 390 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 348 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 304 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 189 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 203 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 264 of file pilot_cargo.c.

Variable Documentation

◆ mission_cargo_id

unsigned int mission_cargo_id = 0
static

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

Definition at line 25 of file pilot_cargo.c.