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 = 0; /* leader */
67 if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
69 lnd_sel(&ni_land, &land_list);
70 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
71 if (QEMPTY(&land_list)) {
75 set_leader(&land_list, &lnd);
76 if (player->argp[2]) {
77 strcpy(buf, player->argp[2]);
78 if (!(cp = lnd_path(together, lnd, buf)))
82 while (!QEMPTY(&land_list)) {
85 if (cp == 0 || *cp == '\0' || stopping) {
87 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
88 if (QEMPTY(&land_list)) {
89 pr("No lands left\n");
92 if (set_leader(&land_list, &lnd)) {
97 nav_map(lnd->lnd_x, lnd->lnd_y, 1);
100 sprintf(prompt, "<%.1f:%.1f: %s> ", maxmob,
101 minmob, xyas(lnd->lnd_x, lnd->lnd_y, player->cnum));
102 cp = getstring(prompt, buf);
103 /* Just in case any of our lands were shelled while we were at the
104 * prompt, we call lnd_mar() again.
106 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
107 if (QEMPTY(&land_list)) {
108 pr("No lands left\n");
111 if (set_leader(&land_list, &lnd)) {
116 if (cp == 0 || *cp == '\0')
117 cp = &dirch[DIR_STOP];
119 *cp == 'B' || *cp == 'f' || *cp == 'i' || *cp == 'm') {
122 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
123 draw_map(0, origin, 0, &ns);
125 } else if (cp[-1] == 'B') {
126 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
127 draw_map('b', origin, 0, &ns);
129 } else if (cp[-1] == 'f') {
130 struct emp_qelem *qp;
131 qp = land_list.q_back;
132 emp_remque(land_list.q_back);
133 emp_insque(qp, &land_list);
134 set_leader(&land_list, &lnd);
135 } else if (cp[-1] == 'i') {
136 lnd_list(&land_list);
138 lnd_sweep(&land_list, 1, 1, player->cnum);
139 stopping |= lnd_check_mines(&land_list);
142 } else if (*cp == 'r' || *cp == 'l') {
144 while ((*bp != ' ') && (*bp))
146 while ((*bp == ' ') && (*bp))
148 if ((bp != (s_char *)0) && (*bp))
149 player->argp[1] = bp;
151 sprintf(dp, "%d", lnd->lnd_uid);
152 player->argp[1] = dp;
155 player->argp[0] = "lradar";
164 dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
166 if (NULL != (cp = lnd_path(together, lnd, buf)))
168 direrr("`%c' to stop", 0, 0);
169 pr(", `i' to list units, `f' to change leader,\n");
170 pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
171 pr("and `m' to minesweep\n");
177 lnd_mar_one_sector(&land_list, dir, player->cnum, together);
183 set_leader(struct emp_qelem *list, struct lndstr **leaderp)
185 struct llist *llp = (struct llist *)(list->q_back);
189 else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
190 pr("Changing leader to ");
193 *leaderp = &llp->land;
194 pr("%s\n", prland(&llp->land));