Use get_empobj() instead of get_empobjp() in unit_map()

The get_FOOp() macros are generally avoided outside the update,
because direct access to the sector cache needs synchronization to be
safe.  unit_map() didn't access the cache directly until it was
converted from get_ship() & friends to get_empobjp() in commit
fec9878c.  Switching to get_empobj() reverts the change to direct
access while keeping the simplification.
This commit is contained in:
Markus Armbruster 2008-02-23 08:26:04 +01:00
parent 9a1fef87fe
commit e7e61687f4

View file

@ -345,26 +345,27 @@ map_char(int type, natid own, int owner_or_god)
static int static int
unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp) unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp)
{ {
struct empobj *gp; union empobj_storage unit;
struct range range; struct range range;
char *name; char *name;
gp = get_empobjp(unit_type, uid); if (!get_empobj(unit_type, uid, &unit))
if (!gp || (gp->own != player->cnum && !player->god) || gp->own == 0) return RET_FAIL;
if (!player->owner || unit.gen.own == 0)
return RET_FAIL; return RET_FAIL;
if (unit_type == EF_NUKE) if (unit_type == EF_NUKE)
*originp = 'n'; *originp = 'n';
else { else {
if ((name = emp_obj_chr_name(gp)) == NULL) if ((name = emp_obj_chr_name(&unit.gen)) == NULL)
return RET_FAIL; return RET_FAIL;
*originp = *name; *originp = *name;
} }
range.lx = xnorm(gp->x - 10); range.lx = xnorm(unit.gen.x - 10);
range.hx = xnorm(gp->x + 11); range.hx = xnorm(unit.gen.x + 11);
range.ly = ynorm(gp->y - 5); range.ly = ynorm(unit.gen.y - 5);
range.hy = ynorm(gp->y + 6); range.hy = ynorm(unit.gen.y + 6);
xysize_range(&range); xysize_range(&range);
snxtsct_area(nsp, &range); snxtsct_area(nsp, &range);
return RET_OK; return RET_OK;