2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * enli.c: Enlist some military
29 * Known contributors to this file:
41 struct nstr_sect nstr;
55 if (!snxtsct(&nstr, player->argp[1]))
57 natp = getnatp(player->cnum);
59 sprintf(prompt, "Number to enlist (max %d) : ", newmil);
60 if (!(p = getstarg(player->argp[2], prompt, buf)))
62 if ((milwant = atoi(p)) > newmil)
64 if (0 != (quota = (milwant < 0)))
67 reserve = natp->nat_reserve;
69 pr("No military reserves left\n");
72 while (nxtsct(&nstr, §)) {
75 if (sect.sct_oldown != player->cnum)
77 civ = sect.sct_item[I_CIVIL];
80 if (sect.sct_loyal > 70) {
81 pr("civilians refuse to report in %s!\n",
82 xyas(sect.sct_x, sect.sct_y, player->cnum));
85 if (sect.sct_mobil <= 0) {
86 pr("%s is out of mobility!\n",
87 xyas(sect.sct_x, sect.sct_y, player->cnum));
89 mil = sect.sct_item[I_MILIT];
92 if (newmil > milwant - mil)
93 newmil = milwant - mil;
96 } else if (newmil > milwant)
98 if (newmil > 999 - mil)
102 if (newmil > reserve)
104 sect.sct_item[I_MILIT] = newmil + mil;
107 sect.sct_item[I_CIVIL] = civ - newmil;
108 pr("%3d enlisted in %s (%d)\n", newmil,
109 xyas(sect.sct_x, sect.sct_y, player->cnum), mil + newmil);
110 if (sect.sct_mobil > 0)
111 sect.sct_mobil *= 1.0 - (double)newmil / (double)civ;
113 if (totalmil >= 10000) {
114 pr("Rioting in induction center interrupts enlistment\n");
118 pr("Military reserve exhausted\n");
122 pr("Total new enlistment : %d\n", totalmil);
123 pr("Military reserves stand at %d\n", reserve);
125 natp->nat_reserve -= totalmil;
128 if ((player->btused += roundavg(totalmil * 0.02)) > 0)
129 pr("Paperwork at recruiting stations ... %d\n", player->btused);