From e7e61687f4851ea4c929a46ce9a08e4e08edca85 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 23 Feb 2008 08:26:04 +0100 Subject: [PATCH] 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. --- src/lib/subs/maps.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/subs/maps.c b/src/lib/subs/maps.c index 5d2eab654..6b2c6e364 100644 --- a/src/lib/subs/maps.c +++ b/src/lib/subs/maps.c @@ -345,26 +345,27 @@ map_char(int type, natid own, int owner_or_god) static int unit_map(int unit_type, int uid, struct nstr_sect *nsp, char *originp) { - struct empobj *gp; + union empobj_storage unit; struct range range; char *name; - gp = get_empobjp(unit_type, uid); - if (!gp || (gp->own != player->cnum && !player->god) || gp->own == 0) + if (!get_empobj(unit_type, uid, &unit)) + return RET_FAIL; + if (!player->owner || unit.gen.own == 0) return RET_FAIL; if (unit_type == EF_NUKE) *originp = 'n'; else { - if ((name = emp_obj_chr_name(gp)) == NULL) + if ((name = emp_obj_chr_name(&unit.gen)) == NULL) return RET_FAIL; *originp = *name; } - range.lx = xnorm(gp->x - 10); - range.hx = xnorm(gp->x + 11); - range.ly = ynorm(gp->y - 5); - range.hy = ynorm(gp->y + 6); + range.lx = xnorm(unit.gen.x - 10); + range.hx = xnorm(unit.gen.x + 11); + range.ly = ynorm(unit.gen.y - 5); + range.hy = ynorm(unit.gen.y + 6); xysize_range(&range); snxtsct_area(nsp, &range); return RET_OK; -- 2.43.0