]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/conv.c
commands: Rename the command functions
[empserver] / src / lib / commands / conv.c
index 560180d889239f6d78f4fc1d42d09e217b2695d2..70977511ab3a0cc1739e19785c44d93b12199cef 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -28,6 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1986
+ *     Markus Armbruster, 2004-2016
  */
 
 /*
 
 #include <config.h>
 
+#include "chance.h"
 #include "commands.h"
-#include "land.h"
 
 int
-conv(void)
+c_convert(void)
 {
     struct natstr *natp;
     struct sctstr sect;
     struct nstr_sect nstr;
     int uwtoconvert, newuw, totaluw, uw;
-    int maxpop, civ, mil, adj_mob, mob;
+    int maxpop, civ, seceff, adj_mob, mob;
+    double secstr;
     double security_extra = 1.0;
-    struct lndstr land;
-    struct nstr_item ni;
 
     if (!snxtsct(&nstr, player->argp[1]))
        return RET_SYN;
@@ -66,34 +66,11 @@ conv(void)
        natp = getnatp(sect.sct_own);
        maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
        civ = sect.sct_item[I_CIVIL];
-       mil = sect.sct_item[I_MILIT];
-
-       /*
-        * Military units count according to the number of
-        * mil in them. (i.e. attack/defense modifier don't
-        * count.
-        */
-       snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
-       while (nxtitem(&ni, &land)) {
-           mil += land.lnd_item[I_MILIT];
-
-           /* Anti-terrorist units count double */
-           if (lchr[(int)land.lnd_type].l_flags & L_SECURITY) {
-
-               /*
-                * They also increase the efficiency of
-                * the conversion process by 10% each.
-                * (but they use 10 mobility doing it)
-                */
-               security_extra += .1;
-               land.lnd_mobil -= 10;
-               mil += land.lnd_item[I_MILIT];
-           }
-       }
+       secstr = security_strength(&sect, &seceff);
        /*
         * Must have military control to convert captured civs.
         */
-       if (mil * 10 < civ)
+       if (secstr * 10 < civ)
            continue;
        newuw = civ;
        if (newuw > uwtoconvert)
@@ -111,6 +88,7 @@ conv(void)
        mob = sect.sct_mobil * 5;
 
        /* security troops make conversion more effective */
+       security_extra = 1.0 + seceff / 1000.0;
        adj_mob = ldround(((double)mob * security_extra), 1);
 
        if (adj_mob < newuw)