2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2012, 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 if (!trechk(player->cnum, 0, TRTENL))
59 natp = getnatp(player->cnum);
61 sprintf(prompt, "Number to enlist (max %d) : ", newmil);
62 if (!(p = getstarg(player->argp[2], prompt, buf)))
64 if ((milwant = atoi(p)) > newmil)
66 if (0 != (quota = (milwant < 0)))
69 reserve = natp->nat_reserve;
71 pr("No military reserves left\n");
74 while (nxtsct(&nstr, §)) {
77 if (sect.sct_oldown != player->cnum)
79 civ = sect.sct_item[I_CIVIL];
82 if (sect.sct_loyal > 70) {
83 pr("civilians refuse to report in %s!\n",
84 xyas(sect.sct_x, sect.sct_y, player->cnum));
87 if (sect.sct_mobil <= 0) {
88 pr("%s is out of mobility!\n",
89 xyas(sect.sct_x, sect.sct_y, player->cnum));
91 mil = sect.sct_item[I_MILIT];
94 if (newmil > milwant - mil)
95 newmil = milwant - mil;
98 } else if (newmil > milwant)
100 if (newmil > 999 - mil)
104 if (newmil > reserve)
106 sect.sct_item[I_MILIT] = newmil + mil;
109 sect.sct_item[I_CIVIL] = civ - newmil;
110 pr("%3d enlisted in %s (%d)\n", newmil,
111 xyas(sect.sct_x, sect.sct_y, player->cnum), mil + newmil);
112 if (sect.sct_mobil > 0)
113 sect.sct_mobil *= 1.0 - (double)newmil / (double)civ;
115 if (totalmil >= 10000) {
116 pr("Rioting in induction center interrupts enlistment\n");
120 pr("Military reserve exhausted\n");
124 pr("Total new enlistment : %d\n", totalmil);
125 pr("Military reserves stand at %ld\n", reserve);
127 natp->nat_reserve -= totalmil;
130 if ((player->btused += roundavg(totalmil * 0.02)) > 0)
131 pr("Paperwork at recruiting stations ... %d\n", player->btused);