(unit_map): Simplify.

This commit is contained in:
Markus Armbruster 2006-03-27 18:42:18 +00:00
parent 707e1aad72
commit 38f4026aee

View file

@ -302,7 +302,7 @@ map_char(unsigned char type, natid own, int owner_or_god)
} }
int int
unit_map(int unit_type, int i, struct nstr_sect *nsp, s_char *originp) unit_map(int unit_type, int uid, struct nstr_sect *nsp, s_char *originp)
{ {
struct shpstr origs; struct shpstr origs;
struct lndstr origl; struct lndstr origl;
@ -312,27 +312,21 @@ unit_map(int unit_type, int i, struct nstr_sect *nsp, s_char *originp)
np = getnatp(player->cnum); np = getnatp(player->cnum);
if (unit_type == EF_LAND) { if (unit_type == EF_LAND) {
if (!getland(i, &origl) || if (!getland(uid, &origl) || !player->owner || origl.lnd_own == 0)
(origl.lnd_own != player->cnum && !player->god) ||
(origl.lnd_own == 0))
return RET_FAIL; return RET_FAIL;
sprintf(what, "%d:%d,%d:%d", xrel(np, origl.lnd_x - 10), sprintf(what, "%d:%d,%d:%d", xrel(np, origl.lnd_x - 10),
xrel(np, origl.lnd_x + 10), xrel(np, origl.lnd_x + 10),
yrel(np, origl.lnd_y - 5), yrel(np, origl.lnd_y + 5)); yrel(np, origl.lnd_y - 5), yrel(np, origl.lnd_y + 5));
*originp = *lchr[(int)origl.lnd_type].l_name; *originp = *lchr[(int)origl.lnd_type].l_name;
} else if (unit_type == EF_PLANE) { } else if (unit_type == EF_PLANE) {
if (!getplane(i, &origp) || if (!getplane(uid, &origp) || !player->owner || origp.pln_own == 0)
(origp.pln_own != player->cnum && !player->god) ||
(origp.pln_own == 0))
return RET_FAIL; return RET_FAIL;
sprintf(what, "%d:%d,%d:%d", xrel(np, origp.pln_x - 10), sprintf(what, "%d:%d,%d:%d", xrel(np, origp.pln_x - 10),
xrel(np, origp.pln_x + 10), xrel(np, origp.pln_x + 10),
yrel(np, origp.pln_y - 5), yrel(np, origp.pln_y + 5)); yrel(np, origp.pln_y - 5), yrel(np, origp.pln_y + 5));
*originp = *plchr[(int)origp.pln_type].pl_name; *originp = *plchr[(int)origp.pln_type].pl_name;
} else { } else {
if (!getship(i, &origs) || if (!getship(uid, &origs) || !player->owner || origs.shp_own == 0)
(origs.shp_own != player->cnum && !player->god) ||
(origs.shp_own == 0))
return RET_FAIL; return RET_FAIL;
sprintf(what, "%d:%d,%d:%d", xrel(np, origs.shp_x - 10), sprintf(what, "%d:%d,%d:%d", xrel(np, origs.shp_x - 10),
xrel(np, origs.shp_x + 10), xrel(np, origs.shp_x + 10),