]> git.pond.sub.org Git - empserver/commitdiff
(prmobcost): New.
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 15 Jun 2006 19:46:27 +0000 (19:46 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 15 Jun 2006 19:46:27 +0000 (19:46 +0000)
(sinfra): Use it to display inaccessible sectors sensibly.
Inaccessible occurs for rail since src/lib/common/move.c rev. 1.12.

src/lib/commands/sinf.c

index 77219c61fdccbff4fb0f1919888d30309351ee14..96ff871600f35949d1a750ca7e668a5fdea649b9 100644 (file)
@@ -44,6 +44,8 @@
 #include "commands.h"
 #include "combat.h"
 
+static void prmobcost(struct sctstr *, int);
+
 int
 sinfra(void)
 {
@@ -76,9 +78,9 @@ sinfra(void)
            pr(" ");
        pr("%4d%% ", sect.sct_effic);
        pr("%4d%% ", sect.sct_road);
-       pr("%4.3f ", sector_mcost(&sect, MOB_MOVE));
+       prmobcost(&sect, MOB_MOVE);
        pr("%4d%% ", sect.sct_rail);
-       pr("%4.3f ", sector_mcost(&sect, MOB_RAIL));
+       prmobcost(&sect, MOB_RAIL);
        pr("%4d%% ", SCT_DEFENSE(&sect));
        pr("%5.2f\n", sector_strength(&sect));
     }
@@ -92,3 +94,14 @@ sinfra(void)
        pr("%d sector%s\n", nsect, splur(nsect));
     return 0;
 }
+
+static void
+prmobcost(struct sctstr *sp, int mobtype)
+{
+    double cost = sector_mcost(sp, mobtype);
+
+    if (cost < 0)
+       pr(" N/A  ");
+    else
+       pr("%5.3f ", cost);
+}