2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * demo.c: De-mobilize "n" military in a given sector
30 * Known contributors to this file:
46 * format: demo <SECTS> number
50 long do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p, int for_real);
61 struct nstr_sect nstr;
63 natp = getnatp(player->cnum);
64 cash = natp->nat_money;
65 if (!snxtsct(&nstr, player->argp[1]))
67 if ((p = getstarg(player->argp[2], "Number to de-mobilize : ", buf)) == 0)
70 if (!(p = getstarg(player->argp[3], "New civilians on active reserve? (y/n) ", buf)))
72 if (*p != 'y' && *p != 'n')
74 cost = do_demo(natp, nstr, number, p, 0);
75 if (chkmoney(cost, cash, player->argp[4]))
77 return (int)do_demo(natp, nstr, number, p, 1);
80 long do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p, int for_real)
92 while (nxtsct(&nstr, §)) {
93 if (!player->owner || sect.sct_effic < 60)
95 if ((mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR)) == 0)
97 if (sect.sct_own != sect.sct_oldown)
99 civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
101 if ((deltamil = mil + number) <= 0)
104 else if ((deltamil = min(mil, number)) <= 0)
108 mil_demob += deltamil;
110 cost += deltamil * 5;
113 player->dolcost += deltamil * 5;
114 pr("%d demobilized in %s (%d mil left)\n",
115 deltamil, xyas(sect.sct_x, sect.sct_y, player->cnum), mil);
117 reserves += deltamil;
118 putvar(V_MILIT, mil, (s_char *)§, EF_SECTOR);
119 putvar(V_CIVIL, civ, (s_char *)§, EF_SECTOR);
125 pr("No eligible sectors/military for demobilization\n");
126 return (long)RET_FAIL;
128 pr("Total new civilians : %d\n", mil_demob);
130 pr("Military reserve stands at %d (up %d)\n",
131 natp->nat_reserve + reserves, reserves);
133 natp->nat_reserve += reserves;