[Change] Have pilots re-calculate cargo load when calculating stats.
This commit is contained in:
parent
d0171998c4
commit
61cb4a3f67
24
src/pilot.c
24
src/pilot.c
@ -55,6 +55,7 @@ static void pilot_update(Pilot* pilot, const double dt);
|
||||
static void pilot_hyperspace(Pilot* pilot);
|
||||
void pilot_render(Pilot* pilot);
|
||||
static void pilot_calcStats(Pilot* pilot);
|
||||
static void pilot_calcCargo(Pilot* pilot);
|
||||
void pilot_free(Pilot* p);
|
||||
static Fleet* fleet_parse(const xmlNodePtr parent);
|
||||
static void pilot_dead(Pilot* p);
|
||||
@ -617,6 +618,9 @@ static void pilot_calcStats(Pilot* pilot) {
|
||||
pilot->shield_regen = pilot->ship->shield_regen;
|
||||
pilot->energy_regen = pilot->ship->energy_regen;
|
||||
|
||||
// Cargo has to be reset.
|
||||
pilot_calcCargo(pilot);
|
||||
|
||||
// Now add outfit changes.
|
||||
for(i = 0; i < pilot->noutfits; i++) {
|
||||
if(outfit_isMod(pilot->outfits[i].outfit)) {
|
||||
@ -685,6 +689,14 @@ int pilot_addCargo(Pilot* pilot, Commodity* cargo, int quantity) {
|
||||
return q;
|
||||
}
|
||||
|
||||
static void pilot_calcCargo(Pilot* pilot) {
|
||||
int i;
|
||||
|
||||
pilot->cargo_free = pilot->ship->cap_cargo;
|
||||
for(i = 0; i < pilot->ncommodities; i++)
|
||||
pilot->cargo_free -= pilot->commodities[i].quantity;
|
||||
}
|
||||
|
||||
unsigned int pilot_addMissionCargo(Pilot* pilot, Commodity* cargo, int quantity) {
|
||||
int q;
|
||||
q = quantity;
|
||||
@ -814,6 +826,12 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, int faction,
|
||||
}
|
||||
}
|
||||
|
||||
// Cargo must be set before calcStats.
|
||||
pilot->credits = 0;
|
||||
pilot->commodities = NULL;
|
||||
pilot->ncommodities = 0;
|
||||
pilot->cargo_free = pilot->ship->cap_cargo;
|
||||
|
||||
// Set the pilot stats based on her ship and outfits.
|
||||
// Hack to have full armour/shield/energy/fuel.
|
||||
pilot->armour = pilot->armour_max = 1.;
|
||||
@ -822,12 +840,6 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, int faction,
|
||||
pilot->fuel = pilot->fuel_max = 1.;
|
||||
pilot_calcStats(pilot);
|
||||
|
||||
// Cargo.
|
||||
pilot->credits = 0;
|
||||
pilot->commodities = NULL;
|
||||
pilot->ncommodities = 0;
|
||||
pilot->cargo_free = pilot->ship->cap_cargo;
|
||||
|
||||
// Hooks.
|
||||
pilot->hook_type = PILOT_HOOK_NONE;
|
||||
pilot->hook = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user