From 31d4c595c4825f429a1ec25ba678917dd4171272 Mon Sep 17 00:00:00 2001 From: Harry Young Date: Mon, 8 Oct 2012 10:42:20 +0200 Subject: [PATCH] fixed the issue with the last commit by building a failsave around the entire use-function's math segment. I don't know why I'm calling this at this point... Signed-off-by: Harry Young --- game/g_target.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/game/g_target.c b/game/g_target.c index a5dfbf4..129d5c7 100644 --- a/game/g_target.c +++ b/game/g_target.c @@ -3007,31 +3007,35 @@ void target_shiphealth_use(gentity_t *ent, gentity_t *other, gentity_t *activato int i, num; double NSS, NHS, SD, HD, BT; gentity_t *alertEnt, *warpEnt, *turboEnt, *transEnt, *client; - - if(ent->splashDamage == 1){ //shields are active so we're just bleeding trough on the hull - BT = ((1 - (ent->count * pow(ent->health, -1))) / 10); - SD = (ent->damage - ceil(ent->damage * BT)); - if(SD > ent->n00bCount){ //we're draining the shields... - HD = (ent->damage - ent->n00bCount); - NHS = (ent->count - HD); - ent->n00bCount = 0; - ent->splashDamage = -2; - } else { //shields will survive so let's just bleed trough - HD = floor(ent->damage * BT); - NHS = (ent->count - HD); - NSS = (ent->n00bCount - SD); - ent->n00bCount = NSS; + if(ent->damage <= 0){ //failsave + return; + }else{ + if(ent->splashDamage == 1){ //shields are active so we're just bleeding trough on the hull + BT = ((1 - (ent->count * pow(ent->health, -1))) / 10); + SD = (ent->damage - ceil(ent->damage * BT)); + + if(SD > ent->n00bCount){ //we're draining the shields... + HD = (ent->damage - ent->n00bCount); + NHS = (ent->count - HD); + ent->n00bCount = 0; + ent->splashDamage = -2; + } else { //shields will survive so let's just bleed trough + HD = floor(ent->damage * BT); + NHS = (ent->count - HD); + NSS = (ent->n00bCount - SD); + ent->n00bCount = NSS; + } + } else { //shields are off, guess where the blow goes... + NHS = (ent->count - ent->damage); } - } else { //shields are off, guess where the blow goes... - NHS = (ent->count - ent->damage); + ent->count = NHS; + ent->damage = 0; } - ent->count = NHS; - //enough math, let's trigger things - //go to red alert if we are on green, this will also activate the shields + //go to red alert if we are not, this will also activate the shields if(ent->falsename){ alertEnt = G_Find(NULL, FOFS(falsename), ent->falsename); if(alertEnt->damage != 2){