Such manual checking is error prone, but the best we can do right now.
unsigned char *bitmap;
int changed = 0;
+ if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
+ type = EF_SHIP;
+
if (!snxtitem(&ni, type, player->argp[1]))
return RET_SYN;
if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
char buf[1024];
char prompt[80];
+ if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
+ type = EF_SHIP;
+
sprintf(prompt, "Radar from (%s # or sector(s)) : ", ef_nameof(type));
cp = getstarg(player->argp[1], prompt, buf);
struct range range;
char *name;
+ if (CANT_HAPPEN((ef_flags(unit_type) & (EFF_OWNER | EFF_XY))
+ != (EFF_OWNER | EFF_XY)))
+ return RET_FAIL;
+
if (!get_empobj(unit_type, uid, &unit))
return RET_FAIL;
if (!player->owner || unit.gen.own == 0)
else
emp_insque(&plp->queue, &bombers);
plane_owner = plp->plane.pln_own;
+ } else {
+ CANT_REACH();
+ break;
}
}
if (!QEMPTY(&missiles)) {
next = qp->q_forw;
glp = (struct genlist *)qp;
gp = glp->thing;
+ if (CANT_HAPPEN(gp->ef_type != EF_PLANE))
+ break;
dist = mapdist(x, y, gp->x, gp->y);
case NS_ALL:
break;
case NS_DIST:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (!xyinrange(gp->x, gp->y, &np->range)) {
selected = 0;
break;
}
- np->curdist = mapdist((int)gp->x, (int)gp->y,
- (int)np->cx, (int)np->cy);
+ np->curdist = mapdist(gp->x, gp->y, np->cx, np->cy);
if (np->curdist > np->dist)
selected = 0;
break;
case NS_AREA:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (!xyinrange(gp->x, gp->y, &np->range))
selected = 0;
if (gp->x == np->range.hx || gp->y == np->range.hy)
selected = 0;
break;
case NS_XY:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy)
selected = 0;
break;
case NS_GROUP:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP)))
+ return 0;
if (np->group != gp->group)
selected = 0;
break;
struct emp_qelem *qp;
struct emp_qelem *next;
struct ulist *ulp;
+ int type;
struct empobj *unit;
struct lndstr *lnd;
struct shpstr *shp;
- CANT_HAPPEN(QEMPTY(unit_list));
-
+ if (CANT_HAPPEN(QEMPTY(unit_list)))
+ return;
qp = unit_list->q_back;
ulp = (struct ulist *)qp;
+ type = ulp->unit.ef_type;
+ if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
+ return;
- if (ulp->unit.ef_type == EF_LAND)
+ if (type == EF_LAND)
pr("lnd# land type x,y a eff sh gun xl mu tech retr fuel\n");
else
pr("shp# ship type x,y fl eff mil sh gun pn he xl ln mob tech\n");
lnd = &ulp->unit.land;
shp = &ulp->unit.ship;
unit = &ulp->unit.gen;
+ if (CANT_HAPPEN(type != unit->ef_type))
+ continue;
pr("%4d ", unit->uid);
pr("%-16.16s ", emp_obj_chr_name(unit));
prxy("%4d,%-4d ", unit->x, unit->y, unit->own);
pr("%1.1s", &unit->group);
pr("%4d%%", unit->effic);
- if (unit->ef_type == EF_LAND) {
+ if (type == EF_LAND) {
pr("%4d", lnd->lnd_item[I_SHELL]);
pr("%4d", lnd->lnd_item[I_GUN]);
count_land_planes(lnd);
}
pr("%4d", unit->mobil);
pr("%4d", unit->tech);
- if (unit->ef_type == EF_LAND) {
+ if (type == EF_LAND) {
pr("%4d%%", lnd->lnd_retreat);
pr("%5d", lnd->lnd_fuel);
}
while (qp != list) {
ulp = (struct ulist *)qp;
unit = &ulp->unit.gen;
+ if (CANT_HAPPEN(unit->ef_type != EF_LAND
+ && unit->ef_type != EF_SHIP))
+ continue;
if (actor) {
mpr(actor, "%s stopped at %s\n", obj_nameof(unit),
xyas(unit->x, unit->y, unit->own));
double dummy;
int mtype;
+ if (CANT_HAPPEN(unit->ef_type != EF_LAND && unit->ef_type != EF_SHIP))
+ return NULL;
+
if (!sarg_xy(buf, &destx, &desty))
return 0;
if (!together) {
for (qp = list->q_back; qp != list; qp = next) {
next = qp->q_back;
ulp = (struct ulist *)qp;
+ if (CANT_HAPPEN(!(ef_flags(ulp->unit.ef_type) & EFF_XY)))
+ continue;
getsect(ulp->unit.gen.x, ulp->unit.gen.y, §);
if (ulp->unit.ef_type == EF_SHIP) {
if (((struct mchrstr *)ulp->chrp)->m_flags & M_FOOD)
case NS_ALL:
break;
case NS_DIST:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (!xyinrange(gp->x, gp->y, &np->range)) {
selected = 0;
break;
}
- np->curdist = mapdist((int)gp->x, (int)gp->y,
- (int)np->cx, (int)np->cy);
+ np->curdist = mapdist(gp->x, gp->y, np->cx, np->cy);
if (np->curdist > np->dist)
selected = 0;
break;
case NS_AREA:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (!xyinrange(gp->x, gp->y, &np->range))
selected = 0;
if (gp->x == np->range.hx || gp->y == np->range.hy)
selected = 0;
break;
case NS_XY:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_XY)))
+ return 0;
if (xnorm(gp->x) != np->cx || ynorm(gp->y) != np->cy)
selected = 0;
break;
case NS_GROUP:
+ if (CANT_HAPPEN(!(ef_flags(np->type) & EFF_GROUP)))
+ return 0;
if (np->group != gp->group)
selected = 0;
break;