void msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, int wantflags, int nowantflags, int mission) { struct plchrstr *pcp; struct plnstr plane; struct plist *irv; struct nstr_item ni; emp_initque(list); snxtitem_all(&ni, EF_PLANE); while (nxtitem(&ni, &plane)) { if (!plane.pln_own) continue; pcp = &plchr[(int)plane.pln_type]; if (!(pcp->pl_flags & P_M)) continue; if (wantflags && (pcp->pl_flags & wantflags) != wantflags) continue; if (nowantflags && pcp->pl_flags & nowantflags) continue; if (mission && plane.pln_mission != mission) continue; if (mission && plane.pln_radius < mapdist(x, y, plane.pln_opx, plane.pln_opy)) continue; if (relations_with(plane.pln_own, victim) >= NEUTRAL) continue; /* missiles go one way, so we can use all the range */ if (plane.pln_range < mapdist(x, y, plane.pln_x, plane.pln_y)) continue; if (plane.pln_mobil <= 0) continue; if (plane.pln_effic < 100) continue; if (opt_MARKET) { if (ontradingblock(EF_PLANE, &plane)) continue; } if (!pln_airbase_ok(&plane, 1, 0)) continue; /* got a valid interceptor */ irv = malloc(sizeof(*irv)); irv->load = 0; irv->pstage = PLG_HEALTHY; irv->pcp = &plchr[(int)plane.pln_type]; irv->plane = plane; emp_insque(&irv->queue, list); } }
void pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap, int ap_to_target, int rangemult, int wantflags, int nowantflags) { struct plnstr plane; int range; struct plchrstr *pcp; struct plist *plp; emp_initque(list); while (nxtitem(ni, &plane)) { /* * It would be nice to let deities fly foreign planes, but * much of the code assumes that only the plane's owner can * fly it. */ if (!plane.pln_own || plane.pln_own != player->cnum) continue; if (plane.pln_mobil <= 0) continue; if (plane.pln_effic < 40) { pr("%s not efficient enough (must be 40%%)\n", prplane(&plane)); continue; } if (!pln_capable(&plane, wantflags, nowantflags)) continue; if (opt_MARKET) { if (ontradingblock(EF_PLANE, &plane)) { pr("plane #%d inelligible - it's for sale.\n", plane.pln_uid); continue; } } range = mapdist(plane.pln_x, plane.pln_y, ap->sct_x, ap->sct_y); if (range > 4) { pr("%s too far from assembly point\n", prplane(&plane)); continue; } range += ap_to_target; range *= rangemult; pcp = &plchr[(int)plane.pln_type]; if (plane.pln_range < range) { pr("%s out of range (%d:%d)\n", prplane(&plane), plane.pln_range, range); continue; } if (!pln_airbase_ok(&plane, rangemult != 2, 1)) continue; pr("%s standing by\n", prplane(&plane)); plane.pln_mission = 0; putplane(plane.pln_uid, &plane); plp = malloc(sizeof(struct plist)); plp->load = 0; plp->pstage = PLG_HEALTHY; plp->pcp = pcp; plp->plane = plane; emp_insque(&plp->queue, list); } }