(do_unit_move): Change unit type to be determined at the
beginning of function instead using the leader. The leader becomes unknown when stopping or unit list becomes empty. This broke printing the path for ships. Broken in rev 1.43.
This commit is contained in:
parent
4693fb6076
commit
b0a9e3579f
1 changed files with 23 additions and 21 deletions
|
@ -83,16 +83,18 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
char *pt = pathtaken;
|
char *pt = pathtaken;
|
||||||
char bmap_flag;
|
char bmap_flag;
|
||||||
int ac;
|
int ac;
|
||||||
|
short type;
|
||||||
|
|
||||||
leader = get_leader(unit_list);
|
leader = get_leader(unit_list);
|
||||||
leader_uid = leader->uid;
|
leader_uid = leader->uid;
|
||||||
|
type = leader->ef_type;
|
||||||
pr("%s is %s\n",
|
pr("%s is %s\n",
|
||||||
leader->ef_type == EF_SHIP ? "Flagship" : "Leader",
|
type == EF_SHIP ? "Flagship" : "Leader",
|
||||||
obj_nameof(leader));
|
obj_nameof(leader));
|
||||||
|
|
||||||
if (player->argp[2]) {
|
if (player->argp[2]) {
|
||||||
strcpy(buf, player->argp[2]);
|
strcpy(buf, player->argp[2]);
|
||||||
if (leader->ef_type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
if (!(cp = shp_path(*together, (struct shpstr *)leader, buf)))
|
if (!(cp = shp_path(*together, (struct shpstr *)leader, buf)))
|
||||||
cp = player->argp[2];
|
cp = player->argp[2];
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,16 +109,16 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
|
|
||||||
if (cp == NULL || *cp == '\0' || stopping) {
|
if (cp == NULL || *cp == '\0' || stopping) {
|
||||||
stopping = 0;
|
stopping = 0;
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
shp_nav(unit_list, minmob, maxmob, together, player->cnum);
|
shp_nav(unit_list, minmob, maxmob, together, player->cnum);
|
||||||
else
|
else
|
||||||
lnd_mar(unit_list, minmob, maxmob, together, player->cnum);
|
lnd_mar(unit_list, minmob, maxmob, together, player->cnum);
|
||||||
if (QEMPTY(unit_list)) {
|
if (QEMPTY(unit_list)) {
|
||||||
pr("No %s left\n",
|
pr("No %s left\n",
|
||||||
leader->ef_type == EF_SHIP ? "ships" : "lands");
|
type == EF_SHIP ? "ships" : "lands");
|
||||||
if (strlen(pathtaken) > 0) {
|
if (strlen(pathtaken) > 0) {
|
||||||
pathtaken[strlen(pathtaken) - 1] = '\0';
|
pathtaken[strlen(pathtaken) - 1] = '\0';
|
||||||
if (leader->ef_type == EF_SHIP && strlen(pathtaken) > 0)
|
if (type == EF_SHIP && strlen(pathtaken) > 0)
|
||||||
pr("Path taken: %s\n", pathtaken);
|
pr("Path taken: %s\n", pathtaken);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -130,7 +132,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
}
|
}
|
||||||
if (!skip)
|
if (!skip)
|
||||||
nav_map(leader->x, leader->y,
|
nav_map(leader->x, leader->y,
|
||||||
leader->ef_type == EF_SHIP ?
|
type == EF_SHIP ?
|
||||||
!(mchr[(int)leader->type].m_flags & M_SUB) : 1);
|
!(mchr[(int)leader->type].m_flags & M_SUB) : 1);
|
||||||
else
|
else
|
||||||
skip = 0;
|
skip = 0;
|
||||||
|
@ -140,16 +142,16 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
/* Just in case any of our units were shelled while we were
|
/* Just in case any of our units were shelled while we were
|
||||||
* at the prompt, we call shp_nav() or lnd_mar() again.
|
* at the prompt, we call shp_nav() or lnd_mar() again.
|
||||||
*/
|
*/
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
shp_nav(unit_list, minmob, maxmob, together, player->cnum);
|
shp_nav(unit_list, minmob, maxmob, together, player->cnum);
|
||||||
else
|
else
|
||||||
lnd_mar(unit_list, minmob, maxmob, together, player->cnum);
|
lnd_mar(unit_list, minmob, maxmob, together, player->cnum);
|
||||||
if (QEMPTY(unit_list)) {
|
if (QEMPTY(unit_list)) {
|
||||||
pr("No %s left\n",
|
pr("No %s left\n",
|
||||||
leader->ef_type == EF_SHIP ? "ships" : "lands");
|
type == EF_SHIP ? "ships" : "lands");
|
||||||
if (strlen(pathtaken) > 0) {
|
if (strlen(pathtaken) > 0) {
|
||||||
pathtaken[strlen(pathtaken) - 1] = '\0';
|
pathtaken[strlen(pathtaken) - 1] = '\0';
|
||||||
if (leader->ef_type == EF_SHIP && strlen(pathtaken) > 0)
|
if (type == EF_SHIP && strlen(pathtaken) > 0)
|
||||||
pr("Path taken: %s\n", pathtaken);
|
pr("Path taken: %s\n", pathtaken);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
@ -161,7 +163,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
stopping = 1;
|
stopping = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (leader->ef_type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
if (!(cp = shp_path(*together, (struct shpstr *)leader,
|
if (!(cp = shp_path(*together, (struct shpstr *)leader,
|
||||||
buf)))
|
buf)))
|
||||||
cp = buf;
|
cp = buf;
|
||||||
|
@ -171,7 +173,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
cp = buf;
|
cp = buf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (leader->ef_type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
radmapnopr(leader->x, leader->y, (int)leader->effic,
|
radmapnopr(leader->x, leader->y, (int)leader->effic,
|
||||||
(int)techfact(leader->tech,
|
(int)techfact(leader->tech,
|
||||||
mchr[(int)leader->type].m_vrnge),
|
mchr[(int)leader->type].m_vrnge),
|
||||||
|
@ -182,7 +184,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
cp = &dirch[DIR_STOP];
|
cp = &dirch[DIR_STOP];
|
||||||
dir = chkdir(*cp, DIR_STOP, DIR_LAST);
|
dir = chkdir(*cp, DIR_STOP, DIR_LAST);
|
||||||
if (dir >= 0) {
|
if (dir >= 0) {
|
||||||
if (leader->ef_type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
stopping |= shp_nav_one_sector(unit_list, dir,
|
stopping |= shp_nav_one_sector(unit_list, dir,
|
||||||
player->cnum, *together);
|
player->cnum, *together);
|
||||||
if (stopping != 2) {
|
if (stopping != 2) {
|
||||||
|
@ -227,13 +229,13 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case 'i':
|
case 'i':
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
shp_list(unit_list);
|
shp_list(unit_list);
|
||||||
else
|
else
|
||||||
lnd_list(unit_list);
|
lnd_list(unit_list);
|
||||||
continue;
|
continue;
|
||||||
case 'm':
|
case 'm':
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
stopping |= shp_sweep(unit_list, 1, 1, player->cnum);
|
stopping |= shp_sweep(unit_list, 1, 1, player->cnum);
|
||||||
else {
|
else {
|
||||||
lnd_sweep(unit_list, 1, 1, player->cnum);
|
lnd_sweep(unit_list, 1, 1, player->cnum);
|
||||||
|
@ -246,7 +248,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
player->btused++;
|
player->btused++;
|
||||||
continue;
|
continue;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
look();
|
look();
|
||||||
else
|
else
|
||||||
llook();
|
llook();
|
||||||
|
@ -265,7 +267,7 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
sprintf(dp, "%d", leader->uid);
|
sprintf(dp, "%d", leader->uid);
|
||||||
player->argp[1] = dp;
|
player->argp[1] = dp;
|
||||||
}
|
}
|
||||||
if (leader->ef_type == EF_SHIP)
|
if (type == EF_SHIP)
|
||||||
mine();
|
mine();
|
||||||
else
|
else
|
||||||
landmine();
|
landmine();
|
||||||
|
@ -279,18 +281,18 @@ do_unit_move(struct emp_qelem *unit_list, int *together,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
direrr("`%c' to stop",
|
direrr("`%c' to stop",
|
||||||
leader->ef_type == EF_SHIP ? ", `%c' to view" : NULL, NULL);
|
type == EF_SHIP ? ", `%c' to view" : NULL, NULL);
|
||||||
pr(", `i' to list %s, `f' to change %s,\n",
|
pr(", `i' to list %s, `f' to change %s,\n",
|
||||||
leader->ef_type == EF_SHIP ? "ships" : "units",
|
type == EF_SHIP ? "ships" : "units",
|
||||||
leader->ef_type == EF_SHIP ? "flagship" : "leader");
|
type == EF_SHIP ? "flagship" : "leader");
|
||||||
pr("`r' to radar, %s`l' to look, `M' to map, `B' to bmap,\n",
|
pr("`r' to radar, %s`l' to look, `M' to map, `B' to bmap,\n",
|
||||||
leader->ef_type == EF_SHIP ? "`s' to sonar, " : "");
|
type == EF_SHIP ? "`s' to sonar, " : "");
|
||||||
pr("`d' to drop mines, and `m' to minesweep\n");
|
pr("`d' to drop mines, and `m' to minesweep\n");
|
||||||
stopping = 1;
|
stopping = 1;
|
||||||
}
|
}
|
||||||
if (strlen(pathtaken) > 0) {
|
if (strlen(pathtaken) > 0) {
|
||||||
pathtaken[strlen(pathtaken) - 1] = '\0';
|
pathtaken[strlen(pathtaken) - 1] = '\0';
|
||||||
if (leader->ef_type == EF_SHIP && strlen(pathtaken) > 0)
|
if (type == EF_SHIP && strlen(pathtaken) > 0)
|
||||||
pr("Path taken: %s\n", pathtaken);
|
pr("Path taken: %s\n", pathtaken);
|
||||||
}
|
}
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue