2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2014, 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:
42 struct nstr_sect nstr;
56 if (!snxtsct(&nstr, player->argp[1]))
58 if (!trechk(player->cnum, 0, TRTENL))
60 natp = getnatp(player->cnum);
62 sprintf(prompt, "Number to enlist (max %d) : ", newmil);
63 if (!(p = getstarg(player->argp[2], prompt, buf)))
65 if ((milwant = atoi(p)) > newmil)
67 if (0 != (quota = (milwant < 0)))
70 reserve = natp->nat_reserve;
72 pr("No military reserves left\n");
75 while (nxtsct(&nstr, §)) {
78 if (sect.sct_oldown != player->cnum)
80 civ = sect.sct_item[I_CIVIL];
83 if (sect.sct_loyal > 70) {
84 pr("civilians refuse to report in %s!\n",
85 xyas(sect.sct_x, sect.sct_y, player->cnum));
88 if (sect.sct_mobil <= 0) {
89 pr("%s is out of mobility!\n",
90 xyas(sect.sct_x, sect.sct_y, player->cnum));
92 mil = sect.sct_item[I_MILIT];
95 if (newmil > milwant - mil)
96 newmil = milwant - mil;
99 } else if (newmil > milwant)
101 if (newmil > 999 - mil)
105 if (newmil > reserve)
107 sect.sct_item[I_MILIT] = newmil + mil;
110 sect.sct_item[I_CIVIL] = civ - newmil;
111 pr("%3d enlisted in %s (%d)\n", newmil,
112 xyas(sect.sct_x, sect.sct_y, player->cnum), mil + newmil);
113 if (sect.sct_mobil > 0)
114 sect.sct_mobil *= 1.0 - (double)newmil / (double)civ;
116 if (totalmil >= 10000) {
117 pr("Rioting in induction center interrupts enlistment\n");
121 pr("Military reserve exhausted\n");
125 pr("Total new enlistment : %d\n", totalmil);
126 pr("Military reserves stand at %d\n", reserve);
128 natp->nat_reserve -= totalmil;
131 if ((player->btused += roundavg(totalmil * 0.02)) > 0)
132 pr("Paperwork at recruiting stations ... %d\n", player->btused);