rendered paste bodyFrom 2ff36b260f222240f7a6f673830d96859345f02e Mon Sep 17 00:00:00 2001
From: Tim Mazid <timmazid@hotmail.com>
Date: Wed, 2 Dec 2009 00:20:38 +1100
Subject: [PATCH] * Changed security to presence
It now shows guard/hostile presence for systems.
---
src/map.c | 2 +-
src/space.c | 19 ++++++++++++++-----
src/space.h | 2 ++
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/map.c b/src/map.c
index 46d51ff..4469c09 100644
--- a/src/map.c
+++ b/src/map.c
@@ -339,7 +339,7 @@ static void map_update( unsigned int wid )
if (sys->nfleets == 0)
snprintf(buf, PATH_MAX, "NA" );
else
- snprintf(buf, PATH_MAX, "%.0f %%", sys->security * 100.);
+ snprintf(buf, PATH_MAX, "%.0f/%.0f", sys->presenceGuard, sys->presenceHostile);
window_moveWidget( wid, "txtSSecurity", -20, y );
window_moveWidget( wid, "txtSecurity", -20, y-gl_smallFont.h-5 );
window_modifyText( wid, "txtSecurity", buf );
diff --git a/src/space.c b/src/space.c
index 233739f..526c63a 100644
--- a/src/space.c
+++ b/src/space.c
@@ -1510,7 +1510,7 @@ int space_load (void)
static int system_calcSecurity( StarSystem *sys )
{
int i;
- double guard, hostile, c, mod;
+ double guard, hostile, presenceGuard, presenceHostile, c, mod;
Fleet *f;
/* Do not run while loading to speed up. */
@@ -1520,18 +1520,27 @@ static int system_calcSecurity( StarSystem *sys )
/* Defaults. */
guard = 0.;
hostile = 0.;
+ presenceGuard = 0;
+ presenceHostile = 0;
/* Calculate hostiles/friendlies. */
for (i=0; i<sys->nfleets; i++) {
f = sys->fleets[i].fleet;
c = (double)sys->fleets[i].chance / 100.;
mod = c * f->pilot_avg * pow(f->mass_avg, 1./3.);
- if (fleet_isFlag(f, FLEET_FLAG_GUARD))
- guard += mod;
- else if (faction_getPlayerDef(f->faction) < 0)
- hostile += mod;
+ if (fleet_isFlag(f, FLEET_FLAG_GUARD)) {
+ guard += mod;
+ presenceGuard += mod;
+ } else if (faction_getPlayerDef(f->faction) < 0) {
+ hostile += mod;
+ presenceHostile += mod;
+ }
}
+ /* Set presence */
+ sys->presenceGuard = presenceGuard;
+ sys->presenceHostile = presenceHostile;
+
/* Set security. */
if (guard == 0.)
sys->security = 0.;
diff --git a/src/space.h b/src/space.h
index 6a45555..57bab48 100644
--- a/src/space.h
+++ b/src/space.h
@@ -160,6 +160,8 @@ typedef struct StarSystem_ {
/* Calculated. */
double *prices; /**< Handles the prices in the system. */
double security; /**< % of security in this system. */
+ double presenceGuard; /**< Guard presence in this system. */
+ double presenceHostile; /**< Hostile presence in this system. */
/* Markers. */
int markers_misc; /**< Number of misc mission markers on system. */
--
1.6.5.3