]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/move.c
Update copyright notice.
[empserver] / src / lib / common / move.c
index f6e338d78ec2745c80bd536d4e0011846b984007..f59cb12279a689b44514c8904b7e801ab07fad45 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  move.c: Misc. move routines
  * 
  *  Known contributors to this file:
- *     
+ *     Markus Armbruster, 2006
  */
 
 #include <config.h>
 
 #include "misc.h"
-#include "xy.h"
-#include "sect.h"
-#include "path.h"
 #include "nat.h"
-#include "common.h"
+#include "path.h"
+#include "sect.h"
+#include "xy.h"
 
 double
 sector_mcost(struct sctstr *sp, int mobtype)
 {
     double base, cost;
 
-    base = dchr[sp->sct_type].d_mcst;
-    if (base <= 0)
+    base = dchr[sp->sct_type].d_mob0;
+    if (base < 0)
        return -1.0;
 
-    /* linear function in eff, d_mcst at 0%, d_emcst at 100% */
-    base += (dchr[sp->sct_type].d_emcst - base) * sp->sct_effic / 100;
-    base /= 5;
+    /* linear function in eff, d_mob0 at 0%, d_mob1 at 100% */
+    base += (dchr[sp->sct_type].d_mob1 - base) * sp->sct_effic / 100;
     if (CANT_HAPPEN(base < 0))
        base = 0;
 
     if (mobtype == MOB_MOVE || mobtype == MOB_MARCH) {
        /* linear function in road, base at 0%, base/10 at 100% */
-       cost = base * (1.0 - 0.009 * sp->sct_road);
+       cost = base;
+       if (intrchr[INT_ROAD].in_enable)
+           cost -= base * 0.009 * sp->sct_road;
     } else if (mobtype == MOB_RAIL) {
-       if (sp->sct_rail <= 0)
+       if (!intrchr[INT_RAIL].in_enable || sp->sct_rail <= 0)
            return -1.0;
        /* linear function in rail, base at 0%, base/100 at 100% */
-       cost = base * (1.0 - 0.0099 * sp->sct_rail);
+       cost = base - base * 0.0099 * sp->sct_rail;
     } else {
        CANT_REACH();
        cost = base;