]> git.pond.sub.org Git - empserver/blobdiff - src/lib/update/revolt.c
update/revolt: Spread only actual casualties to land units
[empserver] / src / lib / update / revolt.c
index b6ea43cb7f4a76f40df55983113c22011b877cc7..822679fc75a499c68343678e17661344fe5b84a6 100644 (file)
@@ -437,6 +437,7 @@ take_casualties(struct sctstr *sp, int mc)
      * them amongst the land units in the sector
      * Do security troops first, then others.
      * Try not to kill any unit.
+     * TODO Spread proportionally to mil instead of evenly
      */
     snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
     while (NULL != (lp = nxtitemp(&ni))) {
@@ -465,7 +466,7 @@ take_casualties(struct sctstr *sp, int mc)
 
        cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
        cantake = MIN(lp->lnd_item[I_MILIT], cantake);
-       deq = MIN(cantake, each);
+       deq = MIN(cantake, MIN(each, mc - taken));
        if (deq <= 0)
            continue;
 
@@ -490,7 +491,7 @@ take_casualties(struct sctstr *sp, int mc)
 
        cantake = ((lp->lnd_effic - 40) / 100.0) * lp->lnd_item[I_MILIT];
        cantake = MIN(lp->lnd_item[I_MILIT], cantake);
-       deq = MIN(cantake, each);
+       deq = MIN(cantake, MIN(each, mc - taken));
        if (deq <= 0)
            continue;