2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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)
50 static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
55 struct nstr_item ni_land;
56 struct emp_qelem land_list;
57 double minmob, maxmob;
60 struct lndstr *lnd = 0; /* leader */
69 if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
71 lnd_sel(&ni_land, &land_list);
72 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
73 if (QEMPTY(&land_list)) {
77 set_leader(&land_list, &lnd);
78 if (player->argp[2]) {
79 strcpy(buf, player->argp[2]);
80 if (!(cp = lnd_path(together, lnd, buf)))
84 while (!QEMPTY(&land_list)) {
87 if (cp == 0 || *cp == '\0' || stopping) {
89 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
90 if (QEMPTY(&land_list)) {
91 pr("No lands left\n");
94 if (set_leader(&land_list, &lnd)) {
99 nav_map(lnd->lnd_x, lnd->lnd_y, 1);
102 sprintf(prompt, "<%.1f:%.1f: %s> ", maxmob,
103 minmob, xyas(lnd->lnd_x, lnd->lnd_y, player->cnum));
104 cp = getstring(prompt, buf);
105 /* Just in case any of our lands were shelled while we were at the
106 * prompt, we call lnd_mar() again.
108 lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
109 if (QEMPTY(&land_list)) {
110 pr("No lands left\n");
113 if (set_leader(&land_list, &lnd)) {
118 if (cp == 0 || *cp == '\0')
119 cp = &dirch[DIR_STOP];
121 *cp == 'B' || *cp == 'f' || *cp == 'i' || *cp == 'm') {
124 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
125 draw_map(0, origin, 0, &ns, player->cnum);
127 } else if (cp[-1] == 'B') {
128 unit_map(EF_LAND, lnd->lnd_uid, &ns, &origin);
129 draw_map(EF_BMAP, origin, 0, &ns, player->cnum);
131 } else if (cp[-1] == 'f') {
132 struct emp_qelem *qp;
133 qp = land_list.q_back;
134 emp_remque(land_list.q_back);
135 emp_insque(qp, &land_list);
136 set_leader(&land_list, &lnd);
137 } else if (cp[-1] == 'i') {
138 lnd_list(&land_list);
140 lnd_sweep(&land_list, 1, 1, player->cnum);
141 stopping |= lnd_check_mines(&land_list);
144 } else if (*cp == 'r' || *cp == 'l') {
146 while ((*bp != ' ') && (*bp))
148 while ((*bp == ' ') && (*bp))
150 if ((bp != (s_char *)0) && (*bp))
151 player->argp[1] = bp;
153 sprintf(dp, "%d", lnd->lnd_uid);
154 player->argp[1] = dp;
157 player->argp[0] = "lradar";
166 dir = chkdir(*cp++, DIR_STOP, DIR_LAST);
168 if (NULL != (cp = lnd_path(together, lnd, buf)))
170 direrr("`%c' to stop", 0, 0);
171 pr(", `i' to list units, `f' to change leader,\n");
172 pr("`r' to radar, `l' to look, `M' to map, `B' to bmap,\n");
173 pr("and `m' to minesweep\n");
179 lnd_mar_one_sector(&land_list, dir, player->cnum, together);
185 set_leader(struct emp_qelem *list, struct lndstr **leaderp)
187 struct llist *llp = (struct llist *)(list->q_back);
191 else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
192 pr("Changing leader to ");
195 *leaderp = &llp->land;
196 pr("%s\n", prland(&llp->land));