From 052c40897c6e97aa66798c3c59d3de7ee7c19190 Mon Sep 17 00:00:00 2001 From: Allanis <allanis@saracraft.net> Date: Fri, 17 May 2013 01:13:27 +0100 Subject: [PATCH] [Add] Mods can now add cargo. Fixed rmOutfit bug. --- src/land.c | 9 +++++++-- src/outfit.c | 3 +++ src/outfit.h | 3 +++ src/pilot.c | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/land.c b/src/land.c index 9d80c1f..2de1023 100644 --- a/src/land.c +++ b/src/land.c @@ -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; } diff --git a/src/outfit.c b/src/outfit.c index 4b0c063..d0c9d71 100644 --- a/src/outfit.c +++ b/src/outfit.c @@ -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)); } diff --git a/src/outfit.h b/src/outfit.h index a311f47..3a9a8a6 100644 --- a/src/outfit.h +++ b/src/outfit.h @@ -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. diff --git a/src/pilot.c b/src/pilot.c index cda06ad..ef84866 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -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.