From 5635fc212f7822bfa32f782dfd89d2e5018e65e8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 28 May 2016 07:42:36 +0200 Subject: [PATCH] power: Include nukes in power factor, like other units Building nukes makes you rate *lower* on the power chart, because the power factor ignores nukes. Fix that. Signed-off-by: Markus Armbruster --- info/power.t | 6 +++--- src/lib/commands/powe.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/info/power.t b/info/power.t index a455f90a..d9a5f9ca 100644 --- a/info/power.t +++ b/info/power.t @@ -72,7 +72,7 @@ power factor = ( power value of money + power value of commodities in sectors + power value of commodities loaded on ships and land units) * (20 + nation tech level) / 500 - + power value of ships, planes and land units + + power value of ships, planes, land units and nukes * (20 + their tech level) / 500 .FI .s1 @@ -80,8 +80,8 @@ The power value of money is dollars / 100. .s1 The power value of a sector is efficiency / 10. .s1 -The power value of a ship, plane or land unit is the power value of -the materials and money needed to build * efficiency / 100. +The power value of a ship, plane, land unit or nuke is the power value +of the materials and money needed to build * efficiency / 100. .s1 The power value of commodities is amount * type factor. \*Qshow item\*U shows the type factor in column \*Qpower\*U. diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c index ae6e0ee1..f5585552 100644 --- a/src/lib/commands/powe.c +++ b/src/lib/commands/powe.c @@ -41,6 +41,7 @@ #include "commands.h" #include "item.h" #include "land.h" +#include "nuke.h" #include "optlist.h" #include "plane.h" #include "power.h" @@ -230,6 +231,8 @@ gen_power(struct powstr *powbuf, int save) struct mchrstr *mcp; struct lndstr land; struct lchrstr *lcp; + struct nukstr nuke; + struct nchrstr *ncp; struct nstr_item ni; struct nstr_sect ns; struct natstr *natp; @@ -282,6 +285,16 @@ gen_power(struct powstr *powbuf, int save) pcp->pl_mat, pcp->pl_cost); pow->p_planes += 1.0; } + snxtitem_all(&ni, EF_NUKE); + while (nxtitem(&ni, &nuke)) { + if (nuke.nuk_own == 0) + continue; + ncp = &nchr[nuke.nuk_type]; + pow = &powbuf[nuke.nuk_own]; + upower[nuke.nuk_own] += empunit_power(nuke.nuk_effic, + nuke.nuk_tech, + ncp->n_mat, ncp->n_cost); + } for (i = 1; NULL != (natp = getnatp(i)); i++) { pow = &powbuf[i]; pow->p_nation = i;