[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);
|
static void pilot_hyperspace(Pilot* pilot);
|
||||||
void pilot_render(Pilot* pilot);
|
void pilot_render(Pilot* pilot);
|
||||||
static void pilot_calcStats(Pilot* pilot);
|
static void pilot_calcStats(Pilot* pilot);
|
||||||
|
static void pilot_calcCargo(Pilot* pilot);
|
||||||
void pilot_free(Pilot* p);
|
void pilot_free(Pilot* p);
|
||||||
static Fleet* fleet_parse(const xmlNodePtr parent);
|
static Fleet* fleet_parse(const xmlNodePtr parent);
|
||||||
static void pilot_dead(Pilot* p);
|
static void pilot_dead(Pilot* p);
|
||||||
@ -617,6 +618,9 @@ static void pilot_calcStats(Pilot* pilot) {
|
|||||||
pilot->shield_regen = pilot->ship->shield_regen;
|
pilot->shield_regen = pilot->ship->shield_regen;
|
||||||
pilot->energy_regen = pilot->ship->energy_regen;
|
pilot->energy_regen = pilot->ship->energy_regen;
|
||||||
|
|
||||||
|
// Cargo has to be reset.
|
||||||
|
pilot_calcCargo(pilot);
|
||||||
|
|
||||||
// Now add outfit changes.
|
// Now add outfit changes.
|
||||||
for(i = 0; i < pilot->noutfits; i++) {
|
for(i = 0; i < pilot->noutfits; i++) {
|
||||||
if(outfit_isMod(pilot->outfits[i].outfit)) {
|
if(outfit_isMod(pilot->outfits[i].outfit)) {
|
||||||
@ -685,6 +689,14 @@ int pilot_addCargo(Pilot* pilot, Commodity* cargo, int quantity) {
|
|||||||
return q;
|
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) {
|
unsigned int pilot_addMissionCargo(Pilot* pilot, Commodity* cargo, int quantity) {
|
||||||
int q;
|
int q;
|
||||||
q = quantity;
|
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.
|
// Set the pilot stats based on her ship and outfits.
|
||||||
// Hack to have full armour/shield/energy/fuel.
|
// Hack to have full armour/shield/energy/fuel.
|
||||||
pilot->armour = pilot->armour_max = 1.;
|
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->fuel = pilot->fuel_max = 1.;
|
||||||
pilot_calcStats(pilot);
|
pilot_calcStats(pilot);
|
||||||
|
|
||||||
// Cargo.
|
|
||||||
pilot->credits = 0;
|
|
||||||
pilot->commodities = NULL;
|
|
||||||
pilot->ncommodities = 0;
|
|
||||||
pilot->cargo_free = pilot->ship->cap_cargo;
|
|
||||||
|
|
||||||
// Hooks.
|
// Hooks.
|
||||||
pilot->hook_type = PILOT_HOOK_NONE;
|
pilot->hook_type = PILOT_HOOK_NONE;
|
||||||
pilot->hook = 0;
|
pilot->hook = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user