2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future 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)
48 static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
53 struct nstr_item ni_land;
54 struct emp_qelem land_list;
55 double minmob, maxmob;
58 struct lndstr *lnd = NULL; /* leader */
70 if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
72 lnd_sel(&ni_land, &land_list);
73 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
74 if (QEMPTY(&land_list)) {
78 set_leader(&land_list, &lnd);
79 if (player->argp[2]) {
80 strcpy(buf, player->argp[2]);
81 if (!(cp = lnd_path(together, lnd, buf)))
85 while (!QEMPTY(&land_list)) {
88 if (cp == NULL || *cp == '\0' || stopping) {
90 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
91 if (QEMPTY(&land_list)) {
92 pr("No lands left\n");
95 if (set_leader(&land_list, &lnd)) {
100 nav_map(lnd->lnd_x, lnd->lnd_y, 1);
103 sprintf(prompt, "<%.1f:%.1f: %s> ", maxmob,
104 minmob, xyas(lnd->lnd_x, lnd->lnd_y, player->cnum));
105 cp = getstring(prompt, buf);
106 /* Just in case any of our lands were shelled while we were at the
107 * prompt, we call lnd_mar() again.
109 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
110 if (QEMPTY(&land_list)) {
111 pr("No lands left\n");
114 if (set_leader(&land_list, &lnd)) {
118 if (cp && !(cp = lnd_path(together, lnd, buf)))
121 if (cp == NULL || *cp == '\0')
122 cp = &dirch[DIR_STOP];
123 dir = chkdir(*cp, DIR_STOP, DIR_LAST);
126 lnd_mar_one_sector(&land_list, dir, player->cnum, together);
130 ac = parse(cp, player->argp, NULL, scanspace, NULL);
132 sprintf(dp, "%d", lnd->lnd_uid);
133 player->argp[1] = dp;
138 switch (*player->argp[0]) {
145 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
146 draw_map(bmap_flag, origin, 0, &ns);
151 struct emp_qelem *qp;
153 qp = land_list.q_back;
154 emp_remque(land_list.q_back);
155 emp_insque(qp, &land_list);
156 set_leader(&land_list, &lnd);
160 lnd_list(&land_list);
163 lnd_sweep(&land_list, 1, 1, player->cnum);
164 stopping |= lnd_check_mines(&land_list);
167 player->argp[0] = "lradar";
178 player->argp[2] = player->argp[1];
179 sprintf(dp, "%d", lnd->lnd_uid);
180 player->argp[1] = dp;
187 direrr("`%c' to stop", 0, 0);
188 pr(", `i' to list units, `f' to change leader,\n");
189 pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
190 pr("`d' to drop mines, and `m' to minesweep\n");
198 set_leader(struct emp_qelem *list, struct lndstr **leaderp)
200 struct llist *llp = (struct llist *)(list->q_back);
204 else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
205 pr("Changing leader to ");
208 *leaderp = &llp->land;
209 pr("%s\n", prland(&llp->land));