2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, 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 * marc.c: March units around
30 * Known contributors to this file:
32 * Ken Stevens, 1995 (rewrite)
46 static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
51 struct nstr_item ni_land;
52 struct emp_qelem land_list;
53 double minmob, maxmob;
56 struct lndstr *lnd = 0; /* leader */
65 if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
67 lnd_sel(&ni_land, &land_list);
68 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
69 if (QEMPTY(&land_list)) {
73 set_leader(&land_list, &lnd);
74 if (player->argp[2]) {
75 strcpy(buf, player->argp[2]);
76 if (!(cp = lnd_path(together, lnd, buf)))
80 while (!QEMPTY(&land_list)) {
83 if (cp == 0 || *cp == '\0' || stopping) {
85 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
86 if (QEMPTY(&land_list)) {
87 pr("No lands left\n");
90 if (set_leader(&land_list, &lnd)) {
95 nav_map(lnd->lnd_x, lnd->lnd_y, 1);
98 sprintf(prompt, "<%.1f:%.1f: %s> ", maxmob,
99 minmob, xyas(lnd->lnd_x, lnd->lnd_y, player->cnum));
100 cp = getstring(prompt, buf);
101 /* Just in case any of our lands were shelled while we were at the
102 * prompt, we call lnd_mar() again.
104 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
105 if (QEMPTY(&land_list)) {
106 pr("No lands left\n");
109 if (set_leader(&land_list, &lnd)) {
114 if (cp == 0 || *cp == '\0')
115 cp = &dirch[DIR_STOP];
117 *cp == 'B' || *cp == 'f' || *cp == 'i' || *cp == 'm') {
120 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
121 draw_map(0, origin, 0, &ns, player->cnum);
123 } else if (cp[-1] == 'B') {
124 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
125 draw_map(EF_BMAP, origin, 0, &ns, player->cnum);
127 } else if (cp[-1] == 'f') {
128 struct emp_qelem *qp;
129 qp = land_list.q_back;
130 emp_remque(land_list.q_back);
131 emp_insque(qp, &land_list);
132 set_leader(&land_list, &lnd);
133 } else if (cp[-1] == 'i') {
134 lnd_list(&land_list);
136 lnd_sweep(&land_list, 1, 1, player->cnum);
137 stopping |= lnd_check_mines(&land_list);
140 } else if (*cp == 'r' || *cp == 'l') {
142 while ((*bp != ' ') && (*bp))
144 while ((*bp == ' ') && (*bp))
146 if ((bp != (s_char *)0) && (*bp))
147 player->argp[1] = bp;
149 sprintf(dp, "%d", lnd->lnd_uid);
150 player->argp[1] = dp;
153 player->argp[0] = "lradar";
162 dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
164 if (NULL != (cp = lnd_path(together, lnd, buf)))
166 direrr("`%c' to stop", 0, 0);
167 pr(", `i' to list units, `f' to change leader,\n");
168 pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
169 pr("and `m' to minesweep\n");
175 lnd_mar_one_sector(&land_list, dir, player->cnum, together);
181 set_leader(struct emp_qelem *list, struct lndstr **leaderp)
183 struct llist *llp = (struct llist *)(list->q_back);
187 else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
188 pr("Changing leader to ");
191 *leaderp = &llp->land;
192 pr("%s\n", prland(&llp->land));