(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:
Ron Koenderink 2006-07-26 00:21:58 +00:00
parent b70653815c
commit fec9878ca4
5 changed files with 41 additions and 24 deletions

View file

@ -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)
{