[Add] Mods can now add cargo. Fixed rmOutfit bug.

This commit is contained in:
Allanis 2013-05-17 01:13:27 +01:00
parent 6ec1a2a407
commit 052c40897c
4 changed files with 16 additions and 2 deletions

View File

@ -398,6 +398,11 @@ static void outfits_sell(char* str) {
dialogue_alert("You can't sell something you don't have!");
return;
}
// Can't sell when you are using it.
else if(outfit_isMod(outfit) && (player->cargo_free < outfit->u.mod.cargo * q)) {
dialogue_alert("You currently have cargo in this modification.");
return;
}
player->credits += outfit->price * pilot_rmOutfit(player, outfit, q);
outfits_update(NULL);
@ -936,8 +941,8 @@ static void spaceport_refuel(char* str) {
(void)str;
if(player->credits < refuel_price()) {
dialogue_alert("Need more Scred",
"You seem to not have enough Scred to refuel your ship");
// Player is out of moniez after landing D:
dialogue_alert("You seem to not have enough scred to refuel your ship.");
return;
}

View File

@ -323,6 +323,9 @@ static void outfit_parseSMod(Outfit* tmp, const xmlNodePtr parent) {
else if(xml_isNode(node, "energy_regen"))
tmp->u.mod.energy_regen = xml_getFloat(node)/60.0;
// Misc.
xmlr_int(node, "cargo", tmp->u.mod.cargo);
} while((node = node->next));
}

View File

@ -91,6 +91,9 @@ typedef struct Outfit_ {
double shield, shield_regen;
double energy, energy_regen;
double fuel;
// Misc.
int cargo; // Cargo space to add.
} mod;
struct { // Afterburner.
double thrust_perc, thrust_abs; // Percent and absolute thrust bonus.

View File

@ -546,6 +546,7 @@ int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity) {
pilot_setSecondary(pilot, s);
}
pilot_calcStats(pilot); // Recalculate stats.
return q;
}
WARN("Failure attempting to remove %d '%s' from pilot '%s'",
@ -619,6 +620,8 @@ static void pilot_calcStats(Pilot* pilot) {
pilot->energy_regen += o->u.mod.energy_regen * q;
// Fuel.
pilot->fuel_max += o->u.mod.fuel * q;
// Misc.
pilot->cargo_free += o->u.mod.cargo * q;
}
else if(outfit_isAfterburner(pilot->outfits[i].outfit)) {
// Set the afterburner.