include/plane.h File Reference

#include <time.h>
#include "queue.h"
#include "types.h"

Include dependency graph for plane.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  plnstr
struct  plchrstr
struct  plist
struct  shiplist

Defines

#define PLN_TYPE_MAX   46
#define PLANE_MINEFF   10
#define PLN_LAUNCHED   bit(0)
#define PLN_SYNCHRONOUS   bit(1)
#define PLN_AIRBURST   bit(2)
#define P_B   bit(0)
#define P_T   bit(1)
#define P_F   bit(2)
#define P_C   bit(3)
#define P_V   bit(4)
#define P_M   bit(5)
#define P_L   bit(6)
#define P_S   bit(7)
#define P_I   bit(8)
#define P_O   bit(9)
#define P_X   bit(10)
#define P_N   bit(11)
#define P_H   bit(12)
#define P_E   bit(13)
#define P_K   bit(14)
#define P_A   bit(15)
#define P_P   bit(16)
#define P_ESC   bit(17)
#define P_MINE   bit(18)
#define P_SWEEP   bit(19)
#define P_MAR   bit(20)
#define PM_R   bit(0)
#define PM_S   bit(1)
#define getplane(n, p)   ef_read(EF_PLANE, (n), (p))
#define putplane(n, p)   ef_write(EF_PLANE, (n), (p))
#define getplanep(n)   ((struct plnstr *)ef_ptr(EF_PLANE, (n)))
#define PLN_ATTDEF(b, t)   (b + ((b?1:0) * ((t/20)>10?10:(t/20))))
#define PLN_ACC(b, t)   (b * (1.0 - (sqrt(t) / 50.)))
#define PLN_RAN(b, t)   (t ? (b + (logx(t, 2.0))) : b)
#define PLN_LOAD(b, t)
#define PLN_BLD_WORK(lcm, hcm)   (20 + (lcm) + 2 * (hcm))

Functions

void ac_combat_headers (natid, natid)
void ac_airtoair (struct emp_qelem *, struct emp_qelem *)
int ac_flak_dam (int, int, int)
void ac_encounter (struct emp_qelem *, struct emp_qelem *, coord, coord, char *, int, int, struct emp_qelem *, struct emp_qelem *)
int ac_isflying (struct plnstr *, struct emp_qelem *)
void sam_intercept (struct emp_qelem *, struct emp_qelem *, natid, natid, coord, coord, int)
int on_shiplist (short, struct shiplist *)
void add_shiplist (short, struct shiplist **)
void free_shiplist (struct shiplist **)
void print_shiplist (struct shiplist *)

Variables

plchrstr plchr [46+2]


Define Documentation

#define getplane ( n,
 )     ef_read(EF_PLANE, (n), (p))

Definition at line 138 of file plane.h.

Referenced by check_plane_ok(), edit(), nuk_postread(), nuke(), plane_bomb(), pln_prewrite(), and sate().

#define getplanep (  )     ((struct plnstr *)ef_ptr(EF_PLANE, (n)))

Definition at line 140 of file plane.h.

Referenced by lnd_prewrite(), look_land(), mob_plane(), prod_plane(), and shp_prewrite().

#define P_A   bit(15)

Definition at line 118 of file plane.h.

Referenced by ac_encounter(), air_damage(), mission_pln_arm(), mission_pln_sel(), perform_mission(), pin_bomb(), plane_sona(), pln_arm(), pln_hitchance(), reco(), and ship_bomb().

#define P_B   bit(0)

Definition at line 103 of file plane.h.

#define P_C   bit(3)

Definition at line 106 of file plane.h.

Referenced by comm_bomb(), eff_bomb(), land_bomb(), mission_pln_equip(), para(), paradrop(), plane_bomb(), pln_equip(), ship_bomb(), and strat_bomb().

#define P_E   bit(13)

Definition at line 116 of file plane.h.

Referenced by carrier_planes(), fit_plane_off_ship(), fit_plane_on_land(), fit_plane_on_ship(), load_plane_land(), load_plane_ship(), pln_airbase_ok(), and pln_capable().

#define P_ESC   bit(17)

Definition at line 120 of file plane.h.

Referenced by bomb(), drop(), fly(), mission(), para(), perform_mission(), pln_capable(), pln_mobcost(), and reco().

#define P_F   bit(2)

Definition at line 105 of file plane.h.

Referenced by ac_dog(), ac_intercept(), air_defense(), bomb(), drop(), fly(), getilist(), laun(), mission(), mission_pln_equip(), para(), perform_mission(), pln_capable(), pln_equip(), pln_mobcost(), reco(), and sam_intercept().

#define P_H   bit(12)

Definition at line 115 of file plane.h.

Referenced by ac_flak_dam(), air_defense(), bomb(), drop(), fly(), mission_pln_arm(), para(), perform_mission(), pln_arm(), and reco().

#define P_I   bit(8)

Definition at line 111 of file plane.h.

Referenced by ac_encounter(), mission_pln_arm(), pln_arm(), reco(), and satmap().

#define P_K   bit(14)

Definition at line 117 of file plane.h.

Referenced by carrier_planes(), carriersatxy(), fit_plane_off_ship(), fit_plane_on_ship(), load_plane_ship(), and pln_capable().

#define P_L   bit(6)

Definition at line 109 of file plane.h.

Referenced by carrier_planes(), carriersatxy(), fit_plane_on_ship(), load_plane_ship(), and pln_capable().

#define P_M   bit(5)

Definition at line 108 of file plane.h.

Referenced by ac_airtoair(), ac_dog(), ac_encounter(), ac_intercept(), ac_planedamage(), air_damage(), air_defense(), all_missiles(), arm(), bomb(), count_non_missiles(), drop(), fit_plane_on_ship(), fly(), hard(), init_plchr(), laun(), load_plane_ship(), msl_sel(), oprange(), para(), perform_mission(), pln_airbase_ok(), pln_damage(), reco(), and sam_intercept().

#define P_MAR   bit(20)

Definition at line 123 of file plane.h.

Referenced by launch_missile(), lnd_missile_interdiction(), msl_hit(), perform_mission(), pln_damage(), and shp_missile_interdiction().

#define P_MINE   bit(18)

Definition at line 121 of file plane.h.

Referenced by drop(), mission_pln_arm(), pln_arm(), and pln_equip().

#define P_N   bit(11)

Definition at line 114 of file plane.h.

Referenced by laun(), msl_hit(), and msl_intercept().

#define P_O   bit(9)

Definition at line 112 of file plane.h.

Referenced by arm(), bomb(), drop(), fly(), laun(), launch_sat(), msl_hit(), msl_intercept(), para(), reco(), trad(), and tran_plane().

#define P_P   bit(16)

Definition at line 119 of file plane.h.

Referenced by para().

#define P_S   bit(7)

Definition at line 110 of file plane.h.

Referenced by ac_encounter(), mission_pln_arm(), pln_arm(), reco(), sate(), and satmap().

#define P_SWEEP   bit(19)

Definition at line 122 of file plane.h.

Referenced by plane_sweep().

#define P_T   bit(1)

Definition at line 104 of file plane.h.

Referenced by ac_flak_dam(), comm_bomb(), eff_bomb(), land_bomb(), lnd_missile_interdiction(), mission(), msl_hit(), perform_mission(), plane_bomb(), pln_damage(), pln_hitchance(), ship_bomb(), shp_missile_interdiction(), and strat_bomb().

#define P_V   bit(4)

Definition at line 107 of file plane.h.

Referenced by init_plchr(), mission_pln_equip(), paradrop(), pln_airbase_ok(), pln_equip(), pln_onewaymission(), and trad().

#define P_X   bit(10)

Definition at line 113 of file plane.h.

Referenced by ac_flak_dam(), air_defense(), bomb(), drop(), fly(), mission_pln_arm(), para(), perform_mission(), pln_arm(), and reco().

#define PLANE_MINEFF   10

Definition at line 44 of file plane.h.

Referenced by ac_dog(), ac_planedamage(), build_plane(), doplane(), nuk_postread(), pinflak_planedamage(), planesatxy(), pln_postread(), pln_prewrite(), prod_plane(), takeover_land(), takeover_plane(), takeover_ship(), and upd_plane().

#define PLN_ACC ( b,
 )     (b * (1.0 - (sqrt(t) / 50.)))

Definition at line 150 of file plane.h.

Referenced by pln_set_tech(), and show_plane_stats().

#define PLN_AIRBURST   bit(2)

Definition at line 83 of file plane.h.

Referenced by arm(), disarm(), nuke(), plan(), and pln_damage().

#define PLN_ATTDEF ( b,
 )     (b + ((b?1:0) * ((t/20)>10?10:(t/20))))

Definition at line 149 of file plane.h.

Referenced by pln_set_tech(), and show_plane_stats().

#define PLN_BLD_WORK ( lcm,
hcm   )     (20 + (lcm) + 2 * (hcm))

Definition at line 156 of file plane.h.

Referenced by build_plane(), planerepair(), pupgr(), and show_plane_build().

#define PLN_LAUNCHED   bit(0)

Definition at line 81 of file plane.h.

Referenced by check_trade(), count_sect_planes(), detonate(), grab_sect(), grab_ship(), knockdown(), laun(), launch_as(), launch_sat(), load_land_land(), load_land_ship(), look_land(), plan(), plane_bomb(), planesatxy(), prod_plane(), prplanes(), pupgr(), radmap2(), sate(), sectdamage(), skyw(), takeover_plane(), tend_land(), trad(), and tran_plane().

#define PLN_LOAD ( b,
 ) 

Value:

(t ? (b * (logx(t, 50.0) < 1.0 ? 1.0 : \
                                  logx(t, 50.0))) : b)

Definition at line 152 of file plane.h.

Referenced by pln_set_tech(), and show_plane_stats().

#define PLN_RAN ( b,
 )     (t ? (b + (logx(t, 2.0))) : b)

Definition at line 151 of file plane.h.

Referenced by pln_set_tech(), and show_plane_stats().

#define PLN_SYNCHRONOUS   bit(1)

Definition at line 82 of file plane.h.

Referenced by launch_sat(), plan(), and prod_plane().

#define PLN_TYPE_MAX   46

Definition at line 43 of file plane.h.

#define PM_R   bit(0)

Definition at line 125 of file plane.h.

Referenced by ac_encounter(), and reco().

#define PM_S   bit(1)

Definition at line 126 of file plane.h.

Referenced by ac_encounter(), and reco().

#define putplane ( n,
 )     ef_write(EF_PLANE, (n), (p))

Definition at line 139 of file plane.h.

Referenced by ac_intercept(), ac_planedamage(), arm(), build_plane(), check_trade(), detonate(), disarm(), grab_sect(), grab_ship(), hard(), knockdown(), laun(), launch_as(), launch_sat(), lnd_prewrite(), load_land_land(), load_land_ship(), load_plane_land(), load_plane_ship(), mission_pln_sel(), msl_intercept(), msl_launch_mindam(), pinflak_planedamage(), plane_bomb(), pln_put(), pln_sel(), pupgr(), put_plane_on_land(), put_plane_on_ship(), range(), scra(), scut(), scuttle_land(), scuttle_ship(), sectdamage(), shp_prewrite(), take_plane_off_land(), take_plane_off_ship(), takeover_land(), takeover_plane(), takeover_ship(), tend_land(), tran_plane(), and wing().


Function Documentation

void ac_airtoair ( struct emp_qelem ,
struct emp_qelem  
)

Definition at line 524 of file aircombat.c.

References ac_dog(), all_missiles(), P_M, plchrstr::pl_flags, plist::plane, plchr, plnstr::pln_effic, plnstr::pln_type, emp_qelem::q_forw, and QEMPTY.

Referenced by ac_intercept(), and air_defense().

00525 {
00526     struct plist *attacker;
00527     struct plist *interceptor;
00528     struct emp_qelem *att;
00529     struct emp_qelem *in;
00530     int nplanes;
00531     int more_att;
00532     int more_int;
00533     struct emp_qelem *att_next;
00534     struct emp_qelem *in_next;
00535 
00536     att = att_list->q_forw;
00537     in = int_list->q_forw;
00538     more_att = 1;
00539     more_int = 1;
00540     if (QEMPTY(att_list) || QEMPTY(int_list)) {
00541         more_att = 0;
00542         more_int = 0;
00543     }
00544     while (more_att || more_int) {
00545         in_next = in->q_forw;
00546         att_next = att->q_forw;
00547         attacker = (struct plist *)att;
00548 
00549         /* skip missiles. If only missiles left, we're done */
00550         if (plchr[(int)attacker->plane.pln_type].pl_flags & P_M) {
00551             att = att_next;
00552             if (att == att_list) {
00553                 more_att = 0;
00554                 if (QEMPTY(att_list))
00555                     more_int = 0;
00556                 else
00557                     att = att->q_forw;
00558             }
00559             if (all_missiles(att_list))
00560                 more_att = 0;
00561             continue;
00562         }
00563         interceptor = (struct plist *)in;
00564         nplanes = attacker->plane.pln_effic;
00565         if (nplanes > interceptor->plane.pln_effic)
00566             nplanes = interceptor->plane.pln_effic;
00567         ac_dog(attacker, interceptor);
00568         in = in_next;
00569         att = att_next;
00570         if (att == att_list) {
00571             more_att = 0;
00572             if (QEMPTY(att_list))
00573                 more_int = 0;
00574             else
00575                 att = att->q_forw;
00576         }
00577         if (in == int_list) {
00578             more_int = 0;
00579             if (QEMPTY(int_list))
00580                 more_att = 0;
00581             else
00582                 in = in->q_forw;
00583         }
00584     }
00585 }

Here is the call graph for this function:

void ac_combat_headers ( natid  ,
natid   
)

Definition at line 510 of file aircombat.c.

References cname(), and PR().

Referenced by ac_intercept(), air_defense(), and sam_intercept().

00511 {
00512     PR(plane_owner,
00513        " %-10.10s %-10.10s  strength int odds  damage           results\n",
00514        cname(plane_owner), cname(def_own));
00515     PR(def_own,
00516        " %-10.10s %-10.10s  strength int odds  damage           results\n",
00517        cname(def_own), cname(plane_owner));
00518 }

Here is the call graph for this function:

void ac_encounter ( struct emp_qelem ,
struct emp_qelem ,
coord  ,
coord  ,
char *  ,
int  ,
int  ,
struct emp_qelem ,
struct emp_qelem  
)

Definition at line 73 of file aircombat.c.

References ac_doflak(), ac_intercept(), ac_landflak(), ac_shipflak(), air_defense(), ALLIED, cname(), dchrstr::d_mnem, dchrstr::d_name, dchr, DIR_STOP, diridx(), diroff, do_evade(), EF_LAND, EF_SHIP, FOUND_FLY, free_shiplist(), getilist(), getnatp, getrel(), getsect, head(), HOSTILE, I_CIVIL, I_MILIT, land(), mchrstr::m_flags, M_SUB, map_set(), MAXNOC, mchr, N_OVFLY_SECT, ni, nreport(), NULL, nxtitem(), opt_HIDDEN, P_A, P_I, P_M, P_S, plchrstr::pl_flags, plist::plane, plane_sona(), plane_sweep(), plchr, plnstr::pln_own, pln_removedupes(), plnstr::pln_type, PM_R, PM_S, PR(), PRdate(), emp_qelem::q_forw, QEMPTY, roundintby(), satdisp_sect(), satdisp_units(), sathead(), sctstr::sct_effic, sctstr::sct_item, sctstr::sct_own, sctstr::sct_type, SCT_WATER, sctstr::sct_x, sctstr::sct_y, setcont(), shpstr::shp_own, shpstr::shp_type, snxtitem_xy(), writemap(), xnorm(), xyas(), and ynorm().

Referenced by air_defense(), bomb(), drop(), fly(), para(), perform_mission(), and reco().

00077 {
00078     int val, non_missiles;
00079     int rel;
00080     int dir;
00081     int nats[MAXNOC];
00082     int lnats[MAXNOC];
00083     int gotilist[MAXNOC];
00084     int unfriendly[MAXNOC];
00085     int overfly[MAXNOC];
00086     struct emp_qelem ilist[MAXNOC], *qp;
00087     char mypath[1024];
00088     int myp;
00089     int civ, mil;
00090     natid plane_owner;
00091     struct sctstr sect;
00092     struct shpstr ship;
00093     struct lndstr land;
00094     struct nstr_item ni;
00095     natid cn;
00096     struct natstr *over, *mynatp;
00097     struct plist *plp;
00098     int evaded;
00099     struct shiplist *head = NULL;
00100     int changed = 0;
00101     int intown = 0;             /* Last owner to intercept */
00102 /* We want to only intercept once per sector per owner.  So, if we overfly
00103    a sector, and then overfly some land units or ships, we don't want to
00104    potentially intercept 3 times. */
00105 
00106     plp = (struct plist *)bomb_list->q_forw;
00107     plane_owner = plp->plane.pln_own;
00108 
00109     strncpy(mypath, path, sizeof(mypath));
00110     myp = 0;
00111 
00112     memset(overfly, 0, sizeof(overfly));
00113     memset(gotilist, 0, sizeof(gotilist));
00114     memset(unfriendly, 0, sizeof(unfriendly));
00115     for (cn = 1; cn < MAXNOC; cn++) {
00116         if ((mynatp = getnatp(cn)) == 0)
00117             continue;
00118         rel = getrel(mynatp, plane_owner);
00119         if (rel > HOSTILE)
00120             continue;
00121         if (plane_owner == cn)
00122             continue;
00123         unfriendly[cn]++;
00124     }
00125     if (mission_flags & PM_R) {
00126         if (mission_flags & P_S) {
00127             PR(plane_owner, "\nSPY Plane report\n");
00128             PRdate(plane_owner);
00129             sathead();
00130         } else if (mission_flags & P_A) {
00131             PR(plane_owner, "\nAnti-Sub Patrol report\n");
00132         } else {
00133             PR(plane_owner, "\nReconnaissance report\n");
00134             PRdate(plane_owner);
00135         }
00136     }
00137 
00138     pln_removedupes(bomb_list, esc_list);
00139     while ((dir = mypath[myp++]) && !QEMPTY(bomb_list)) {
00140         if ((val = diridx(dir)) == DIR_STOP)
00141             break;
00142         /* XXX using xnorm is probably bad */
00143         x = xnorm(x + diroff[val][0]);
00144         y = ynorm(y + diroff[val][1]);
00145         getsect(x, y, &sect);
00146         over = getnatp(sect.sct_own);
00147 
00148         if (mission_flags & PM_R) {
00149             if (opt_HIDDEN)
00150                 setcont(plane_owner, sect.sct_own, FOUND_FLY);
00151             if (sect.sct_type == SCT_WATER) {
00152                 PR(plane_owner, "flying over %s at %s\n",
00153                    dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
00154                 if (mission_flags & PM_S)
00155                     plane_sweep(bomb_list, x, y);
00156                 if (mission_flags & P_A) {
00157                     plane_sona(bomb_list, x, y, &head);
00158                 }
00159                 changed += map_set(plane_owner,
00160                                    sect.sct_x, sect.sct_y,
00161                                    dchr[sect.sct_type].d_mnem, 0);
00162             } else if (mission_flags & P_S) {
00163                 satdisp_sect(&sect, (mission_flags & P_I) ? 10 : 50);
00164             } else {
00165                 /* This is borrowed from lookout */
00166                 if (sect.sct_own == plane_owner)
00167                     PR(plane_owner, "Your ");
00168                 else
00169                     PR(plane_owner, "%s (#%d) ",
00170                        cname(sect.sct_own), sect.sct_own);
00171                 PR(plane_owner, "%s", dchr[sect.sct_type].d_name);
00172                 changed += map_set(plane_owner,
00173                                    sect.sct_x, sect.sct_y,
00174                                    dchr[sect.sct_type].d_mnem, 0);
00175                 PR(plane_owner, " %d%% efficient ",
00176                    (sect.sct_own == plane_owner) ?
00177                    sect.sct_effic : roundintby((int)sect.sct_effic, 25));
00178                 civ = sect.sct_item[I_CIVIL];
00179                 mil = sect.sct_item[I_MILIT];
00180                 if (civ)
00181                     PR(plane_owner, "with %s%d civ ",
00182                        (sect.sct_own == plane_owner) ?
00183                        "" : "approx ",
00184                        (sect.sct_own == plane_owner) ?
00185                        civ : roundintby(civ, 25));
00186                 if (mil)
00187                     PR(plane_owner, "with %s%d mil ",
00188                        (sect.sct_own == plane_owner) ?
00189                        "" : "approx ",
00190                        (sect.sct_own == plane_owner) ?
00191                        mil : roundintby(mil, 25));
00192                 PR(plane_owner, "@ %s\n", xyas(x, y, plane_owner));
00193             }
00194             if (mission_flags & P_S)
00195                 satdisp_units(sect.sct_x, sect.sct_y);
00196         } else {
00197             PR(plane_owner, "flying over %s at %s\n",
00198                dchr[sect.sct_type].d_name, xyas(x, y, plane_owner));
00199             changed += map_set(plane_owner, sect.sct_x, sect.sct_y,
00200                                dchr[sect.sct_type].d_mnem, 0);
00201         }
00202         if ((rel = getrel(over, plane_owner)) == ALLIED)
00203             continue;
00204 
00205         evaded = do_evade(bomb_list, esc_list);
00206 
00207         if (sect.sct_own != 0 && sect.sct_own != plane_owner && !evaded) {
00208             /* We only show planes overhead if they didn't
00209              * evade radar */
00210             overfly[sect.sct_own]++;
00211             PR(sect.sct_own, "%s planes spotted over %s\n",
00212                cname(plane_owner), xyas(x, y, sect.sct_own));
00213             if (opt_HIDDEN)
00214                 setcont(cn, plane_owner, FOUND_FLY);
00215         }
00216 
00217         if (!evaded) {
00218             /* Fire flak */
00219             if (unfriendly[sect.sct_own])
00220                 ac_doflak(bomb_list, &sect);
00221             /* If bombers left, fire flak from units and ships */
00222             if (!QEMPTY(bomb_list))
00223                 ac_landflak(bomb_list, x, y);
00224             if (!QEMPTY(bomb_list))
00225                 ac_shipflak(bomb_list, x, y);
00226         }
00227         /* mission planes aborted due to flak -- don't send escorts */
00228         if (QEMPTY(bomb_list))
00229             break;
00230         if (!no_air_defense && !evaded)
00231             air_defense(x, y, plane_owner, bomb_list, esc_list);
00232 
00233         if (sect.sct_own == 0 || sect.sct_own == plane_owner)
00234             continue;
00235 
00236         if (evaded)
00237             continue;
00238 
00239         non_missiles = 0;
00240         for (qp = bomb_list->q_forw; qp != bomb_list; qp = qp->q_forw) {
00241             struct plist *ip = (struct plist *)qp;
00242             if (!(plchr[(int)ip->plane.pln_type].pl_flags & P_M))
00243                 non_missiles = 1;
00244         }
00245 
00246         if (!non_missiles)
00247             continue;
00248 
00249         if (unfriendly[sect.sct_own] && !gotilist[sect.sct_own]) {
00250             getilist(&ilist[sect.sct_own], sect.sct_own,
00251                      bomb_list, esc_list, obomb, oesc);
00252             gotilist[sect.sct_own]++;
00253         }
00254         if (rel > HOSTILE)
00255             continue;
00256         ac_intercept(bomb_list, esc_list, &ilist[sect.sct_own],
00257                      sect.sct_own, x, y);
00258         intown = sect.sct_own;
00259     }
00260 
00261     /* Let's report all of the overflights even if aborted */
00262     for (cn = 1; cn < MAXNOC; cn++) {
00263         if (plane_owner == cn)
00264             continue;
00265         if (overfly[cn] > 0)
00266             nreport(plane_owner, N_OVFLY_SECT, cn, overfly[cn]);
00267     }
00268     /* If the map changed, update it */
00269     if (changed)
00270         writemap(player->cnum);
00271     /* Now, if the bomber and escort lists are empty, we are done */
00272     if (QEMPTY(bomb_list) && QEMPTY(esc_list)) {
00273         if (mission_flags & P_A)
00274             free_shiplist(&head);
00275         return;
00276     }
00277 
00278     /* Something made it through */
00279     /* Go figure out if there are ships in this sector, and who's they are */
00280     memset(nats, 0, sizeof(nats));
00281     snxtitem_xy(&ni, EF_SHIP, x, y);
00282     while (nxtitem(&ni, &ship)) {
00283         if (mchr[(int)ship.shp_type].m_flags & M_SUB)
00284             continue;
00285         nats[ship.shp_own]++;
00286     }
00287     /* Go figure out if there are units in this sector, and who's they are */
00288     memset(lnats, 0, sizeof(lnats));
00289     snxtitem_xy(&ni, EF_LAND, x, y);
00290     while (nxtitem(&ni, &land)) {
00291         if (land.lnd_ship >= 0 || land.lnd_land >= 0)
00292             continue;
00293         lnats[land.lnd_own]++;
00294     }
00295 
00296     /* Now, let's make life a little rougher. */
00297     for (cn = 1; cn < MAXNOC && !QEMPTY(bomb_list); cn++) {
00298         if (plane_owner == cn)
00299             continue;
00300         intown = -1;
00301         /* Are there ships owned by this country? */
00302         if (nats[cn] != 0) {
00303             /* Yes. */
00304             if (cn != 0) {
00305                 PR(cn, "%s planes spotted over ships in %s\n",
00306                    cname(plane_owner), xyas(x, y, cn));
00307                 if (opt_HIDDEN)
00308                     setcont(cn, plane_owner, FOUND_FLY);
00309             }
00310             if (unfriendly[cn]) {
00311                 /* They are unfriendly too */
00312                 if (!gotilist[cn]) {
00313                     getilist(&ilist[cn], cn, bomb_list, esc_list, obomb,
00314                              oesc);
00315                     gotilist[cn]++;
00316                 }
00317                 PR(plane_owner, "Flying over %s ships in %s\n",
00318                    cname(cn), xyas(x, y, plane_owner));
00319                 /* This makes going for ships in harbors tough */
00320                 if (!evaded) {
00321                     /* We already fired flak up above.  Now we intercept again if we haven't already */
00322                     /* Flag that we intercepted */
00323                     intown = 1;
00324                     /* And now intercept again */
00325                     ac_intercept(bomb_list, esc_list, &ilist[cn],
00326                                  cn, x, y);
00327                 }
00328             }
00329         }
00330         /* Are there units owned by this country? */
00331         if (lnats[cn] != 0) {
00332             /* Yes. */
00333             if (cn != 0) {
00334                 PR(cn, "%s planes spotted over land units in %s\n",
00335                    cname(plane_owner), xyas(x, y, cn));
00336                 if (opt_HIDDEN)
00337                     setcont(cn, plane_owner, FOUND_FLY);
00338             }
00339             if (unfriendly[cn]) {
00340                 /* They are unfriendly too */
00341                 if (!gotilist[cn]) {
00342                     getilist(&ilist[cn], cn, bomb_list, esc_list, obomb,
00343                              oesc);
00344                     gotilist[cn]++;
00345                 }
00346                 PR(plane_owner, "Flying over %s land units in %s\n",
00347                    cname(cn), xyas(x, y, plane_owner));
00348                 if (!evaded) {
00349                     if (intown == -1) {
00350                         /* We haven't intercepted yet, so intercept */
00351                         ac_intercept(bomb_list, esc_list, &ilist[cn],
00352                                      cn, x, y);
00353                     }
00354                 }
00355             }
00356         }
00357     }
00358     if (mission_flags & P_A)
00359         free_shiplist(&head);
00360 }

Here is the call graph for this function:

int ac_flak_dam ( int  ,
int  ,
int   
)

Definition at line 966 of file aircombat.c.

References flakscale, int, P_H, P_T, P_X, and roll().

Referenced by ac_fireflak(), and pinflak_planedamage().

00967 {
00968     int flak, dam;
00969     float mult;
00970     /*                             <-7      -7     -6     -5     -4 */
00971     static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
00972     /*    -3     -2     -1      0     +1     +2     +3     +4 */
00973          0.35f, 0.40f, 0.45f, 0.50f, 0.50f, 0.55f, 0.60f, 0.65f,
00974     /*    +5    +6     +7     +8    >+8 */
00975          0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
00976     enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) - 1 };
00977 
00978     flak = guns - def;
00979     if ((pl_flags & P_T) == 0)
00980         flak--;
00981     if (pl_flags & P_X)
00982         flak -= 2;
00983     if (pl_flags & P_H)
00984         flak -= 1;
00985 
00986     if (flak > 8)
00987         mult = flaktable[FLAK_MAX];
00988     else if (flak < -7)
00989         mult = flaktable[0];
00990     else {
00991         flak += 8;
00992         mult = flaktable[flak];
00993     }
00994     mult *= flakscale;
00995     dam = (int)((roll(8) + 2) * mult);
00996     if (dam > 100)
00997         dam = 100;
00998     return dam;
00999 }

Here is the call graph for this function:

int ac_isflying ( struct plnstr ,
struct emp_qelem  
)

Definition at line 1005 of file aircombat.c.

References plist::plane, plnstr::pln_uid, and emp_qelem::q_forw.

Referenced by getilist(), knockdown(), plane_bomb(), planesatxy(), and sectdamage().

01006 {
01007     struct emp_qelem *qp;
01008     struct emp_qelem *next;
01009     struct plnstr *pp;
01010     struct plist *plp;
01011 
01012     if (!list)
01013         return 0;
01014     for (qp = list->q_forw; qp != list; qp = next) {
01015         next = qp->q_forw;
01016         plp = (struct plist *)qp;
01017         pp = &plp->plane;
01018         if (plane->pln_uid == pp->pln_uid)
01019             return 1;
01020     }
01021     return 0;
01022 }

void add_shiplist ( short  ,
struct shiplist **   
)

Definition at line 58 of file aswplnsubs.c.

References head(), shiplist::next, NULL, and shiplist::uid.

Referenced by asw_shipsatxy(), and plane_sona().

00059 {
00060     struct shiplist *s, *s2;
00061 
00062     s = *head;
00063     s2 = NULL;
00064 
00065     while (s != NULL) {
00066         if (s->uid == uid) {
00067             return;
00068         }
00069         s2 = s;
00070         s = s->next;
00071     }
00072 
00073     s = malloc(sizeof(struct shiplist));
00074     if (s2 != NULL) 
00075         s2->next = s;
00076     else
00077         *head = s;
00078     s->uid = uid;
00079     s->next = NULL;
00080 }

Here is the call graph for this function:

void free_shiplist ( struct shiplist **   ) 

Definition at line 83 of file aswplnsubs.c.

References head(), shiplist::next, and NULL.

Referenced by ac_encounter(), and ship_bomb().

00084 {
00085     struct shiplist *s, *s2;
00086 
00087     s = *head;
00088 
00089     while (s != NULL) {
00090         s2 = s;
00091         s = s->next;
00092         free(s2);
00093     }
00094     *head = NULL;
00095 }

Here is the call graph for this function:

int on_shiplist ( short  ,
struct shiplist  
)

Definition at line 44 of file aswplnsubs.c.

References head(), shiplist::next, NULL, and shiplist::uid.

Referenced by plane_sona(), and ship_bomb().

00045 {
00046     struct shiplist *s;
00047 
00048     s = head;
00049     while (s != NULL) {
00050         if (s->uid == uid)
00051             return 1;
00052         s = s->next;
00053     }
00054     return 0;
00055 }

Here is the call graph for this function:

void print_shiplist ( struct shiplist  ) 

Definition at line 98 of file aswplnsubs.c.

References cname(), effadv(), getship, head(), int, mchr, NULL, pr(), prship(), shpstr::shp_effic, shpstr::shp_own, shpstr::shp_type, and shpstr::shp_uid.

Referenced by ship_bomb().

00099 {
00100     struct shiplist *s;
00101     int first;
00102     struct mchrstr *mp;
00103     struct shpstr ship;
00104 
00105     s = head;
00106     first = 1;
00107 
00108     while (s != NULL) {
00109         getship(s->uid, &ship);
00110         mp = &mchr[(int)ship.shp_type];
00111         if (first) {
00112             pr(" #          player->owner           eff        type\n");
00113             first = 0;
00114         }
00115         pr("(#%3d) %10.10s  %12.12s  %s\n", ship.shp_uid,
00116            cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
00117         s = s->next;
00118     }
00119 }

Here is the call graph for this function:

void sam_intercept ( struct emp_qelem ,
struct emp_qelem ,
natid  ,
natid  ,
coord  ,
coord  ,
int   
)

Definition at line 379 of file aircombat.c.

References ac_combat_headers(), ac_dog(), cname(), emp_remque(), mapdist(), mission_pln_equip(), P_F, P_M, plist::pcp, plchrstr::pl_cost, plchrstr::pl_flags, plist::plane, plnstr::pln_range, plnstr::pln_x, plnstr::pln_y, PR(), and emp_qelem::q_forw.

Referenced by ac_intercept(), and air_defense().

00382 {
00383     struct emp_qelem *aqp;
00384     struct emp_qelem *anext;
00385     struct emp_qelem *dqp;
00386     struct emp_qelem *dnext;
00387     struct plist *aplp;
00388     struct plist *dplp;
00389     int first = 1;
00390 
00391     for (aqp = att_list->q_forw,
00392          dqp = def_list->q_forw;
00393          aqp != att_list && dqp != def_list; aqp = anext) {
00394         anext = aqp->q_forw;
00395         aplp = (struct plist *)aqp;
00396         if (aplp->pcp->pl_flags & P_M)
00397             continue;
00398         if (aplp->pcp->pl_cost < 1000)
00399             continue;
00400         for (; dqp != def_list; dqp = dnext) {
00401             dnext = dqp->q_forw;
00402             dplp = (struct plist *)dqp;
00403             if (!(dplp->pcp->pl_flags & P_M))
00404                 continue;
00405 
00406             if (dplp->plane.pln_range <
00407                 mapdist(x, y, dplp->plane.pln_x, dplp->plane.pln_y)) {
00408                 emp_remque(dqp);
00409                 free(dqp);
00410                 continue;
00411             }
00412             if (mission_pln_equip(dplp, 0, P_F, 0) < 0) {
00413                 emp_remque(dqp);
00414                 free(dqp);
00415                 continue;
00416             }
00417             if (first) {
00418                 first = 0;
00419                 PR(plane_owner, "%s launches SAMs!\n", cname(def_own));
00420                 PR(def_own, "Launching SAMs at %s planes!\n",
00421                    cname(plane_owner));
00422                 ac_combat_headers(plane_owner, def_own);
00423             }
00424             ac_dog(aplp, dplp);
00425             dqp = dnext;
00426             break;
00427         }
00428     }
00429     if (!first) {
00430         PR(plane_owner, "\n");
00431         PR(def_own, "\n");
00432     }
00433     if (delete_missiles) {
00434         for (; dqp != def_list; dqp = dnext) {
00435             dnext = dqp->q_forw;
00436             dplp = (struct plist *)dqp;
00437             if (!(dplp->pcp->pl_flags & P_M))
00438                 continue;
00439             emp_remque(dqp);
00440             free(dqp);
00441             continue;
00442         }
00443     }
00444 }

Here is the call graph for this function:


Variable Documentation

struct plchrstr plchr[46+2]

Definition at line 47 of file plane.c.

Referenced by ac_airtoair(), ac_encounter(), all_missiles(), arm(), buil(), build_plane(), doplane(), ef_elt_byname(), emp_obj_chr_name(), find_escorts(), fit_plane_off_land(), fit_plane_off_ship(), fit_plane_on_land(), fit_plane_on_ship(), get_empobj_chr(), getilist(), hard(), init_plchr(), laun(), launch_missile(), launch_sat(), load_plane_land(), load_plane_ship(), make_new_list(), mission(), msl_equip(), msl_hit(), msl_sel(), oprange(), plan(), planerepair(), planesatxy(), pln_airbase_ok(), pln_capable(), pln_damage(), pln_hitchance(), pln_sel(), pln_set_tech(), prplane(), pstat(), pupgr(), sate(), scra(), showsat(), trad(), trade_desc(), trade_nameof(), tran_plane(), unit_type_name(), and upd_plane().


Generated on Fri Mar 28 11:01:23 2008 for empserver by  doxygen 1.5.2