]> git.pond.sub.org Git - empserver/commitdiff
Use get_empobj() instead of get_empobjp() in unit_map()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Feb 2008 07:26:04 +0000 (08:26 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 25 Feb 2008 20:50:25 +0000 (21:50 +0100)
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

index 5d2eab654e3b6ce3137fdc29c4806ad568a4be9d..6b2c6e3641a978540fa03c19fca35dd1f65766b2 100644 (file)
@@ -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;