(tran_map, tran_nmap, tran_pmap): Split tran_map() into tran_nmap()
and tran_pmap() so that unit number arguments are interpreted sensibly. Users changed. (display_region_map): New. (cmd_move_map, tran_nmap, tran_pmap): Use it.
This commit is contained in:
parent
f65b255d18
commit
df8dc6ab5a
4 changed files with 44 additions and 14 deletions
|
@ -308,6 +308,7 @@ extern void logerror(char *, ...) ATTRIBUTE((format (printf, 1, 2)));
|
||||||
/* maps.c */
|
/* maps.c */
|
||||||
extern int draw_map(int, char, int, struct nstr_sect *);
|
extern int draw_map(int, char, int, struct nstr_sect *);
|
||||||
extern int unit_map(int, int, struct nstr_sect *, char *);
|
extern int unit_map(int, int, struct nstr_sect *, char *);
|
||||||
|
extern int display_region_map(char *cmd, coord curx, coord cury, char *arg);
|
||||||
extern int bmaps_intersect(natid, natid);
|
extern int bmaps_intersect(natid, natid);
|
||||||
extern int share_bmap(natid, natid, struct nstr_sect *, char, char *);
|
extern int share_bmap(natid, natid, struct nstr_sect *, char, char *);
|
||||||
/* move.c */
|
/* move.c */
|
||||||
|
|
|
@ -350,11 +350,7 @@ move(void)
|
||||||
static int
|
static int
|
||||||
cmd_move_map(coord curx, coord cury, char *arg)
|
cmd_move_map(coord curx, coord cury, char *arg)
|
||||||
{
|
{
|
||||||
player->argp[0] = "map";
|
return display_region_map("map", curx, cury, arg);
|
||||||
player->argp[1] = arg;
|
|
||||||
player->argp[2] = NULL;
|
|
||||||
player->condarg = NULL;
|
|
||||||
return map();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
|
|
||||||
static int tran_map(coord curx, coord cury, char *arg);
|
static int tran_pmap(coord curx, coord cury, char *arg);
|
||||||
|
static int tran_nmap(coord curx, coord cury, char *arg);
|
||||||
static int tran_nuke(void);
|
static int tran_nuke(void);
|
||||||
static int tran_plane(void);
|
static int tran_plane(void);
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ tran_nuke(void)
|
||||||
}
|
}
|
||||||
dam = 0;
|
dam = 0;
|
||||||
mcost = move_ground(§, &endsect, weight,
|
mcost = move_ground(§, &endsect, weight,
|
||||||
player->argp[3], tran_map, 0, &dam);
|
player->argp[3], tran_nmap, 0, &dam);
|
||||||
if (mcost < 0)
|
if (mcost < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -214,7 +215,7 @@ tran_plane(void)
|
||||||
}
|
}
|
||||||
dam = 1;
|
dam = 1;
|
||||||
mcost = move_ground(§, &endsect, weight,
|
mcost = move_ground(§, &endsect, weight,
|
||||||
player->argp[3], tran_map, 0, &dam);
|
player->argp[3], tran_pmap, 0, &dam);
|
||||||
dam /= count;
|
dam /= count;
|
||||||
if (mcost < 0)
|
if (mcost < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -251,11 +252,14 @@ tran_plane(void)
|
||||||
*/
|
*/
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static int
|
static int
|
||||||
tran_map(coord curx, coord cury, char *arg)
|
tran_pmap(coord curx, coord cury, char *arg)
|
||||||
{
|
{
|
||||||
player->argp[0] = "map";
|
return display_region_map("pmap", curx, cury, arg);
|
||||||
player->argp[1] = arg;
|
|
||||||
player->argp[2] = NULL;
|
|
||||||
player->condarg = NULL;
|
|
||||||
return map();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
tran_nmap(coord curx, coord cury, char *arg)
|
||||||
|
{
|
||||||
|
return display_region_map("nmap", curx, cury, arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,6 +356,35 @@ unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
display_region_map(char *cmd, coord curx, coord cury, char *arg)
|
||||||
|
{
|
||||||
|
char coordinates[80], *cp;
|
||||||
|
|
||||||
|
player->argp[0] = cmd;
|
||||||
|
if (!arg || !*arg) {
|
||||||
|
struct natstr *np;
|
||||||
|
|
||||||
|
np = getnatp(player->cnum);
|
||||||
|
sprintf(coordinates, "%d:%d,%d:%d",
|
||||||
|
xrel(np, curx - 10), xrel(np, curx + 11),
|
||||||
|
yrel(np, cury - 5), yrel(np, cury + 6));
|
||||||
|
player->argp[1] = coordinates;
|
||||||
|
player->argp[2] = NULL;
|
||||||
|
} else {
|
||||||
|
player->argp[1] = arg;
|
||||||
|
cp = strchr(arg, ' ');
|
||||||
|
if (cp != NULL) {
|
||||||
|
*cp++ = '\0';
|
||||||
|
while (isspace(*cp)) cp++;
|
||||||
|
player->argp[2] = cp;
|
||||||
|
} else
|
||||||
|
player->argp[2] = NULL;
|
||||||
|
}
|
||||||
|
player->condarg = NULL;
|
||||||
|
return map();
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
bmaps_intersect(natid a, natid b)
|
bmaps_intersect(natid a, natid b)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue