]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/revolt.c
Get rid of the need to fix up lchr[].
[empserver] / src / lib / update / revolt.c
index 5ac712923b0eb918781a0e2e65869f0bd4d706ef..8684eaa2a00d8d07823056adfb5270ef461fa0d1 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-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
 
 #include <config.h>
 
-#include "misc.h"
-#include "sect.h"
-#include "nat.h"
-#include "news.h"
-#include "file.h"
-#include "path.h"
-#include "xy.h"
 #include "land.h"
+#include "lost.h"
+#include "news.h"
 #include "nsc.h"
+#include "path.h"
 #include "plane.h"
 #include "update.h"
-#include "common.h"
-#include "gen.h"
-#include "lost.h"
-#include "subs.h"
 
 static void take_casualties(struct sctstr *, int);
 
@@ -176,7 +168,10 @@ guerrilla(struct sctstr *sp)
 
        mil += lp->lnd_item[I_MILIT];
 
-       /* Security troops can now kill up to 1/2 their complement each
+       if (sp->sct_che_target != sp->sct_own)
+           continue;
+
+       /* Security troops can now kill up to 1/5 their complement each
           update, before doing anything else. */
        if (lchr[(int)lp->lnd_type].l_flags & L_SECURITY) {
            int che_kill, r;
@@ -374,7 +369,7 @@ guerrilla(struct sctstr *sp)
        for (n = 1; n <= 6; n++) {
            nsp = getsectp(sp->sct_x + diroff[n][0],
                           sp->sct_y + diroff[n][1]);
-           if (dchr[nsp->sct_type].d_mcst == 0)
+           if (dchr[nsp->sct_type].d_mob0 < 0)
                continue;
            if (nsp->sct_own != target)
                continue;
@@ -470,21 +465,20 @@ take_casualties(struct sctstr *sp, int mc)
        if (!(lchr[(int)lp->lnd_type].l_flags & L_SECURITY))
            continue;
 
-       cantake = ((lp->lnd_effic - 40) / 100.0)
-           * lp->lnd_item[I_MILIT] * 2.0;
+       cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
 
        if (cantake >= each) {
-           deq = (each / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
-           mc -= each;
+           deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
+           mc -= 2 * each;
        } else if (cantake > 0) {
-           deq = (cantake / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
-           mc -= (deq / 100.0) * lp->lnd_item[I_MILIT] * 2.0;
+           deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
+           mc -= 2 * cantake;
        } else
            deq = 0;
 
        lp->lnd_effic -= deq;
        lp->lnd_mobil -= deq / 2;
-       deq = lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
+       deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
        lnd_submil(lp, deq);
        if (mc <= 0)
            return;
@@ -499,17 +493,17 @@ take_casualties(struct sctstr *sp, int mc)
        cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
 
        if (cantake >= each) {
-           deq = ((double)each / (lp->lnd_item[I_MILIT] * 2.0)) * 100.0;
+           deq = ((double)each / lp->lnd_item[I_MILIT]) * 100.0;
            mc -= each;
        } else if (cantake > 0) {
            deq = ((double)cantake / lp->lnd_item[I_MILIT]) * 100.0;
-           mc -= (deq / 100.0) * lp->lnd_item[I_MILIT];
+           mc -= cantake;
        } else
            deq = 0;
 
        lp->lnd_effic -= deq;
        lp->lnd_mobil -= deq / 2;
-       deq = lchr[(int)lp->lnd_type].l_mil * (deq / 100.0);
+       deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
        lnd_submil(lp, deq);
        if (mc <= 0)
            return;