(get_empobjp): New. Returns a pointer an empobj.
(emp_obj_chr_name): New. Returns a pointer to the characteristics name for an empobj. (unit_map): Simplify unit_map() by using get_empobjp() and emp_obj_chr_name(). (map, cmd_move_map): Switch to EF_SHIP as unit_map does not default to EF_SHIP for EF_BAD anymore.
This commit is contained in:
parent
b70653815c
commit
fec9878ca4
5 changed files with 41 additions and 24 deletions
|
@ -85,8 +85,10 @@ union empobj_storage {
|
|||
};
|
||||
|
||||
extern char *obj_nameof(struct empobj *gp);
|
||||
extern struct empobj *get_empobjp(int type, int id);
|
||||
extern int put_empobj(struct empobj *gp);
|
||||
extern void *get_empobj_chr(struct empobj *gp);
|
||||
extern char *emp_obj_chr_name(struct empobj *gp);
|
||||
extern int get_empobj_mob_max(int ef_type);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
int
|
||||
map(void)
|
||||
{
|
||||
int unit_type = EF_BAD;
|
||||
int unit_type = EF_SHIP;
|
||||
int bmap = 0;
|
||||
char *str;
|
||||
char buf[1024];
|
||||
|
|
|
@ -343,7 +343,7 @@ move(void)
|
|||
static int
|
||||
cmd_move_map(coord curx, coord cury, char *arg)
|
||||
{
|
||||
return display_region_map(0, EF_BAD, curx, cury, arg);
|
||||
return display_region_map(0, EF_SHIP, curx, cury, arg);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -57,6 +57,14 @@ obj_nameof(struct empobj *gp)
|
|||
return "";
|
||||
}
|
||||
|
||||
struct empobj *
|
||||
get_empobjp(int type, int id)
|
||||
{
|
||||
if (CANT_HAPPEN(type == EF_SECTOR || type == EF_BAD))
|
||||
return NULL;
|
||||
else
|
||||
return (struct empobj *)ef_ptr(type, id);
|
||||
}
|
||||
|
||||
int
|
||||
put_empobj(struct empobj *gp)
|
||||
|
@ -103,6 +111,26 @@ get_empobj_chr(struct empobj *gp)
|
|||
return cp;
|
||||
}
|
||||
|
||||
char *
|
||||
emp_obj_chr_name(struct empobj *gp)
|
||||
{
|
||||
switch (gp->ef_type) {
|
||||
case EF_LAND:
|
||||
return lchr[(int)gp->type].l_name;
|
||||
case EF_SHIP:
|
||||
return mchr[(int)gp->type].m_name;
|
||||
case EF_PLANE:
|
||||
return plchr[(int)gp->type].pl_name;
|
||||
case EF_NUKE:
|
||||
return nchr[(int)gp->type].n_name;
|
||||
case EF_SECTOR:
|
||||
return dchr[(int)gp->type].d_name;
|
||||
default:
|
||||
CANT_REACH();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
get_empobj_mob_max(int ef_type)
|
||||
{
|
||||
|
|
|
@ -376,33 +376,20 @@ map_char(unsigned char type, natid own, int owner_or_god)
|
|||
int
|
||||
unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
|
||||
{
|
||||
struct shpstr origs;
|
||||
struct lndstr origl;
|
||||
struct plnstr origp;
|
||||
struct nukstr orign;
|
||||
struct empobj *gp;
|
||||
struct range range;
|
||||
char *name;
|
||||
|
||||
if (unit_type == EF_LAND) {
|
||||
if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
|
||||
return RET_FAIL;
|
||||
gp = (struct empobj *)&origl;
|
||||
*originp = *lchr[(int)origl.lnd_type].l_name;
|
||||
} else if (unit_type == EF_PLANE) {
|
||||
if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
|
||||
return RET_FAIL;
|
||||
gp = (struct empobj *)&origp;
|
||||
*originp = *plchr[(int)origp.pln_type].pl_name;
|
||||
} else if (unit_type == EF_NUKE) {
|
||||
if (!getnuke(uid, &orign) || !player->owner || orign.nuk_own == 0)
|
||||
return RET_FAIL;
|
||||
gp = (struct empobj *)&orign;
|
||||
gp = get_empobjp(unit_type, uid);
|
||||
if (!gp || !player->owner || gp->own == 0)
|
||||
return RET_FAIL;
|
||||
|
||||
if (unit_type == EF_NUKE)
|
||||
*originp = 'n';
|
||||
} else {
|
||||
if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
|
||||
else {
|
||||
if ((name = emp_obj_chr_name(gp)) == NULL)
|
||||
return RET_FAIL;
|
||||
gp = (struct empobj *)&origs;
|
||||
*originp = *mchr[(int)origs.shp_type].m_name;
|
||||
*originp = *name;
|
||||
}
|
||||
|
||||
range.lx = xnorm(gp->x - 10);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue