]> git.pond.sub.org Git - empserver/commitdiff
(deli, do_demo, lnd_sweep, guerrilla): Saturate items at ITEM_MAX.
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 06:48:57 +0000 (06:48 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 5 Mar 2004 06:48:57 +0000 (06:48 +0000)
With variables, item increases beyond the capacity of variables
(65535) were ignored here.

This should cover all item changes not going through putvec().

src/lib/commands/deli.c
src/lib/commands/demo.c
src/lib/subs/lndsub.c
src/lib/update/revolt.c

index f589dfff958c557b2a5e9b2adf304b2fda14e233..6328e7e03e50878c1f8e698c6225e346f6cf882d 100644 (file)
@@ -101,7 +101,8 @@ deli(void)
            if (!check_sect_ok(&sect))
                continue;
 
-           del = thresh + dir;
+           thresh = min(thresh, ITEM_MAX) & ~7;
+           del = thresh | dir;
            sect.sct_del[ich->i_vtype] = del;
            putsect(&sect);
        }
index 437d2f0acd474609c1964cb8d29f84f0476b4b4c..74fbb71c23a7a757201b3293fab13710f57b5a64 100644 (file)
@@ -105,6 +105,8 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
                continue;
        } else if ((deltamil = min(mil, number)) <= 0)
            continue;
+       if (deltamil > ITEM_MAX - civ)
+           deltamil = ITEM_MAX - civ;
        civ += deltamil;
        mil -= deltamil;
        mil_demob += deltamil;
index 849959c81ab657438e99f02b4db302246e517f3c..221286f2070ba4685a1d1af54f2940093645eab9 100644 (file)
@@ -715,7 +715,7 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
                mines--;
                if (lshells < max)
                    ++lshells;
-               else
+               else if (sshells < ITEM_MAX)
                    ++sshells;
            }
        }
index 5f550024e2b88c41ca6fa5bbc8b3a1adc558e843..e6f27d826036c7a2468a7e7cd6e750497c50c895 100644 (file)
@@ -220,10 +220,9 @@ guerrilla(struct sctstr *sp)
     if ((tnat->nat_stat & STAT_INUSE) == 0) {
        /* target nation has dissolved: che's retire.  */
        logerror("%d Che targeted at country %d retiring", che, target);
-       civ += che;
        sp->sct_che = 0;
        sp->sct_che_target = 0;
-       sp->sct_item[I_CIVIL] = civ;
+       sp->sct_item[I_CIVIL] = min(civ + che, ITEM_MAX);
        return;
     }
 
@@ -347,6 +346,10 @@ guerrilla(struct sctstr *sp)
            sp->sct_newtype = SCT_AGRI;
        n = civ / 20;
        civ -= n;
+       if (civ > ITEM_MAX) {
+           uw = ITEM_MAX - civ;
+           civ = ITEM_MAX;
+       }
        sp->sct_item[I_CIVIL] = civ;
        sp->sct_item[I_UW] = uw;
        sp->sct_item[I_MILIT] = n;