(move_ground): Remove superflous parameter `mobility'. Callers
changed. Edit for clarity. No functional changes.
This commit is contained in:
parent
4fa84b5cb1
commit
cc5d78c2f0
5 changed files with 27 additions and 36 deletions
|
@ -570,7 +570,7 @@ extern int air_defense(coord, coord, natid, struct emp_qelem *,
|
||||||
/* move.c */
|
/* move.c */
|
||||||
extern int check_lmines(coord, coord, double);
|
extern int check_lmines(coord, coord, double);
|
||||||
extern int move_ground(s_char *, struct sctstr *, struct sctstr *,
|
extern int move_ground(s_char *, struct sctstr *, struct sctstr *,
|
||||||
double, double, s_char *,
|
double, s_char *,
|
||||||
int (*)(s_char *, coord, coord, s_char *),
|
int (*)(s_char *, coord, coord, s_char *),
|
||||||
int, int *);
|
int, int *);
|
||||||
extern int fly_map(coord, coord);
|
extern int fly_map(coord, coord);
|
||||||
|
|
|
@ -155,7 +155,7 @@ explore(void)
|
||||||
*/
|
*/
|
||||||
dam = 1;
|
dam = 1;
|
||||||
mcost = move_ground((s_char *)ip, §, &endsect,
|
mcost = move_ground((s_char *)ip, §, &endsect,
|
||||||
(double)sect.sct_mobil, weight, player->argp[4],
|
weight, player->argp[4],
|
||||||
explore_map, 1, &dam);
|
explore_map, 1, &dam);
|
||||||
|
|
||||||
if (dam) {
|
if (dam) {
|
||||||
|
@ -207,7 +207,7 @@ explore(void)
|
||||||
if (!player->god && chksect.sct_own && chksect.sct_own != player->cnum
|
if (!player->god && chksect.sct_own && chksect.sct_own != player->cnum
|
||||||
&& chksect.sct_type != SCT_SANCT) {
|
&& chksect.sct_type != SCT_SANCT) {
|
||||||
pr("Somebody beat you there!\n");
|
pr("Somebody beat you there!\n");
|
||||||
/* Send them xback home */
|
/* Send them back home */
|
||||||
getsect(start.sct_x, start.sct_y, §);
|
getsect(start.sct_x, start.sct_y, §);
|
||||||
if (sect.sct_own != own) {
|
if (sect.sct_own != own) {
|
||||||
pr("Someone captured the sector you started from!\n");
|
pr("Someone captured the sector you started from!\n");
|
||||||
|
|
|
@ -201,7 +201,7 @@ move(void)
|
||||||
if (dam && !chance(weight / 200.0))
|
if (dam && !chance(weight / 200.0))
|
||||||
dam = 0;
|
dam = 0;
|
||||||
mcost = move_ground((s_char *)ip, §, &endsect,
|
mcost = move_ground((s_char *)ip, §, &endsect,
|
||||||
(double)sect.sct_mobil, weight, player->argp[4],
|
weight, player->argp[4],
|
||||||
cmd_move_map, 0, &dam);
|
cmd_move_map, 0, &dam);
|
||||||
|
|
||||||
if (dam) {
|
if (dam) {
|
||||||
|
|
|
@ -176,7 +176,6 @@ tran_nuke(void)
|
||||||
}
|
}
|
||||||
dam = 0;
|
dam = 0;
|
||||||
mcost = move_ground((s_char *)&nuke, §, &endsect,
|
mcost = move_ground((s_char *)&nuke, §, &endsect,
|
||||||
(double)sect.sct_mobil,
|
|
||||||
(double)ncp->n_weight * moving,
|
(double)ncp->n_weight * moving,
|
||||||
player->argp[5], tran_map, 0, &dam);
|
player->argp[5], tran_map, 0, &dam);
|
||||||
|
|
||||||
|
@ -293,7 +292,7 @@ tran_plane(void)
|
||||||
}
|
}
|
||||||
dam = 1;
|
dam = 1;
|
||||||
mcost = move_ground((s_char *)&plane, §, &endsect,
|
mcost = move_ground((s_char *)&plane, §, &endsect,
|
||||||
(double)sect.sct_mobil, (double)weight,
|
(double)weight,
|
||||||
player->argp[3], tran_map, 0, &dam);
|
player->argp[3], tran_map, 0, &dam);
|
||||||
dam /= count;
|
dam /= count;
|
||||||
if (mcost < 0)
|
if (mcost < 0)
|
||||||
|
|
|
@ -50,12 +50,9 @@ static int move_map(s_char *what, coord curx, coord cury, s_char *arg);
|
||||||
|
|
||||||
int
|
int
|
||||||
move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
double mobility, double weight, s_char *path,
|
double weight, s_char *path,
|
||||||
int (*map)(s_char *, coord, coord, s_char *), int exploring,
|
int (*map)(s_char *, coord, coord, s_char *), int exploring,
|
||||||
int *dam)
|
int *dam)
|
||||||
|
|
||||||
|
|
||||||
/* RESULT */
|
|
||||||
{
|
{
|
||||||
struct sctstr sect, ending_sect;
|
struct sctstr sect, ending_sect;
|
||||||
struct sctstr next, dsect;
|
struct sctstr next, dsect;
|
||||||
|
@ -68,6 +65,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
double sect_mcost;
|
double sect_mcost;
|
||||||
double total_mcost;
|
double total_mcost;
|
||||||
double mv_cost;
|
double mv_cost;
|
||||||
|
double mobility = (double)start->sct_mobil;
|
||||||
int dir;
|
int dir;
|
||||||
int intcost;
|
int intcost;
|
||||||
int takedam = (*dam), out = 0;
|
int takedam = (*dam), out = 0;
|
||||||
|
@ -87,8 +85,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pr("Looking for best path to %s\n", path);
|
pr("Looking for best path to %s\n", path);
|
||||||
path =
|
path = BestLandPath(buf2, start, &ending_sect, &total_mcost,
|
||||||
BestLandPath(buf2, start, &ending_sect, &total_mcost,
|
|
||||||
MOB_ROAD);
|
MOB_ROAD);
|
||||||
if (exploring && (path != (s_char *)0)) /* take off the 'h' */
|
if (exploring && (path != (s_char *)0)) /* take off the 'h' */
|
||||||
*(path + strlen(path) - 1) = '\0';
|
*(path + strlen(path) - 1) = '\0';
|
||||||
|
@ -106,18 +103,14 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
movstr = path;
|
movstr = path;
|
||||||
tmpx = start->sct_x;
|
curx = start->sct_x;
|
||||||
curx = tmpx;
|
cury = start->sct_y;
|
||||||
tmpy = start->sct_y;
|
|
||||||
cury = tmpy;
|
|
||||||
total_mcost = 0.0;
|
total_mcost = 0.0;
|
||||||
if (getsect(curx, cury, §) < 0) {
|
if (getsect(curx, cury, §) < 0) {
|
||||||
logerror("move_path: getsect %d,%d", curx, cury);
|
logerror("move_path: getsect %d,%d", curx, cury);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
tmpx = curx;
|
|
||||||
tmpy = cury;
|
|
||||||
oldx = curx;
|
oldx = curx;
|
||||||
oldy = cury;
|
oldy = cury;
|
||||||
if (movstr == 0 || *movstr == 0) {
|
if (movstr == 0 || *movstr == 0) {
|
||||||
|
@ -133,8 +126,8 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
}
|
}
|
||||||
if (movstr && sarg_xy(movstr, &dx, &dy)) {
|
if (movstr && sarg_xy(movstr, &dx, &dy)) {
|
||||||
if (getsect(dx, dy, &dsect)) {
|
if (getsect(dx, dy, &dsect)) {
|
||||||
movstr =
|
movstr = BestLandPath(buf2, §, &dsect, &mv_cost,
|
||||||
BestLandPath(buf2, §, &dsect, &mv_cost, MOB_ROAD);
|
MOB_ROAD);
|
||||||
} else {
|
} else {
|
||||||
pr("Invalid destination sector!\n");
|
pr("Invalid destination sector!\n");
|
||||||
movstr = (s_char *)0;
|
movstr = (s_char *)0;
|
||||||
|
@ -156,8 +149,11 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (movstr == 0 || *movstr == 0)
|
if (movstr == 0 || *movstr == 0) {
|
||||||
movstr = dirch;
|
buf2[0] = dirch[DIR_STOP];
|
||||||
|
buf2[1] = 0;
|
||||||
|
movstr = buf2;
|
||||||
|
}
|
||||||
if ((dir = chkdir(*movstr, DIR_STOP, DIR_MAP)) < 0) {
|
if ((dir = chkdir(*movstr, DIR_STOP, DIR_MAP)) < 0) {
|
||||||
pr("\"%c\" is not legal...", *movstr);
|
pr("\"%c\" is not legal...", *movstr);
|
||||||
direrr("'%c' to stop ", "'%c' to view ", "& '%c' to map\n");
|
direrr("'%c' to stop ", "'%c' to view ", "& '%c' to map\n");
|
||||||
|
@ -183,8 +179,8 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
* next sector. Mobility, terrain,
|
* next sector. Mobility, terrain,
|
||||||
* or ownership may prevent us.
|
* or ownership may prevent us.
|
||||||
*/
|
*/
|
||||||
tmpx += diroff[dir][0];
|
tmpx = curx + diroff[dir][0];
|
||||||
tmpy += diroff[dir][1];
|
tmpy = cury + diroff[dir][1];
|
||||||
if (getsect(tmpx, tmpy, &next) < 0) {
|
if (getsect(tmpx, tmpy, &next) < 0) {
|
||||||
pr("You can't go there...\n");
|
pr("You can't go there...\n");
|
||||||
*movstr = 0;
|
*movstr = 0;
|
||||||
|
@ -194,17 +190,13 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
if ((next.sct_type == SCT_SANCT) &&
|
if ((next.sct_type == SCT_SANCT) &&
|
||||||
(next.sct_own != player->cnum)) {
|
(next.sct_own != player->cnum)) {
|
||||||
pr("Converts, huh?\n");
|
pr("Converts, huh?\n");
|
||||||
*end = next;
|
*movstr = 0;
|
||||||
intcost = (int)total_mcost;
|
continue;
|
||||||
if (chance(total_mcost - intcost))
|
|
||||||
intcost++;
|
|
||||||
return intcost;
|
|
||||||
}
|
}
|
||||||
getvec(VT_ITEM, vec, (s_char *)&next, EF_SECTOR);
|
getvec(VT_ITEM, vec, (s_char *)&next, EF_SECTOR);
|
||||||
sect_mcost = sector_mcost(&next, MOB_ROAD);
|
sect_mcost = sector_mcost(&next, MOB_ROAD);
|
||||||
if ((!player->owner && (!exploring ||
|
if ((!player->owner && (!exploring || vec[I_MILIT] || vec[I_CIVIL]))
|
||||||
(vec[I_MILIT] || vec[I_CIVIL]))) ||
|
|| sect_mcost == -1.0) {
|
||||||
sect_mcost == -1.0) {
|
|
||||||
/* already-owned, or prohibited terrain */
|
/* already-owned, or prohibited terrain */
|
||||||
pr("You can't go there...\n");
|
pr("You can't go there...\n");
|
||||||
*movstr = 0;
|
*movstr = 0;
|
||||||
|
@ -238,8 +230,8 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
||||||
*/
|
*/
|
||||||
if (takedam && chance(weight / 100.0) &&
|
if (takedam && chance(weight / 100.0) &&
|
||||||
((curx != oldx) || (cury != oldy)))
|
((curx != oldx) || (cury != oldy)))
|
||||||
(*dam) +=
|
(*dam) += ground_interdict(curx, cury, player->cnum,
|
||||||
ground_interdict(curx, cury, player->cnum, "commodities");
|
"commodities");
|
||||||
if (*dam >= 100)
|
if (*dam >= 100)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue