};
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
int
map(void)
{
- int unit_type = EF_BAD;
+ int unit_type = EF_SHIP;
int bmap = 0;
char *str;
char buf[1024];
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
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)
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)
{
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);