]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/mission.c
Remove struct genlist member cp
[empserver] / src / lib / subs / mission.c
index 395b170fef105b3841bf83722a973c3b0c1bd8d5..f1aefe2c30bb8dc8c36e9a3124fac59f1fea4e66 100644 (file)
@@ -51,7 +51,6 @@
 
 struct genlist {
     struct emp_qelem queue;    /* list of units */
-    void *cp;                  /* pointer to desc of thing */
     struct empobj *thing;      /* thing's struct */
 };
 
@@ -74,9 +73,9 @@ static void mission_pln_arm(struct emp_qelem *, coord, coord, int,
                            int, struct ichrstr *);
 static void mission_pln_sel(struct emp_qelem *, int, int, int);
 static int perform_mission_land(int, struct lndstr *, coord, coord,
-                               natid, int, char *, int, int);
+                               natid, int, char *, int);
 static int perform_mission_ship(int, struct shpstr *, coord, coord,
-                               natid, int, char *, int, int);
+                               natid, int, char *, int);
 static int perform_mission_msl(int, struct emp_qelem *, coord, coord,
                               natid, int);
 static int perform_mission_bomb(int, struct emp_qelem *, coord, coord,
@@ -150,15 +149,13 @@ only_subs(struct emp_qelem *list)
 {
     struct emp_qelem *qp;
     struct genlist *glp;
-    struct mchrstr *mcp;
 
     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
        glp = (struct genlist *)qp;
 
        if (glp->thing->ef_type != EF_SHIP)
            return 0;
-       mcp = glp->cp;
-       if (!(mcp->m_flags & M_SUB))
+       if (!(mchr[glp->thing->type].m_flags & M_SUB))
            return 0;
        /* It's a sub! */
     }
@@ -351,7 +348,6 @@ build_mission_list_type(struct genlist *mi, coord x, coord y, int mission,
 
        glp = malloc(sizeof(struct genlist));
        memset(glp, 0, sizeof(struct genlist));
-       glp->cp = get_empobj_chr(gp);
        glp->thing = malloc(sizeof(item));
        memcpy(glp->thing, &item, sizeof(item));
        emp_insque(&glp->queue, &mi[gp->own].queue);
@@ -388,11 +384,9 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
     struct emp_qelem *qp, missiles, bombers;
     struct genlist *glp;
     struct plist *plp;
-    struct empobj *gp;
     struct sctstr sect;
     struct plchrstr *pcp;
     int dam = 0;
-    int md;
     int targeting_ships = *s == 's'; /* "subs" or "ships" FIXME gross! */
 
     getsect(x, y, &sect);
@@ -402,20 +396,17 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
 
     for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
        glp = (struct genlist *)qp;
-       gp = glp->thing;
-
-       md = mapdist(x, y, gp->x, gp->y);
 
        if (glp->thing->ef_type == EF_LAND) {
            dam = perform_mission_land(dam, (struct lndstr *)glp->thing,
                                       x, y, victim, mission, s,
-                                      md, targeting_ships);
+                                      targeting_ships);
        } else if (glp->thing->ef_type == EF_SHIP) {
            dam = perform_mission_ship(dam, (struct shpstr *)glp->thing,
                                       x, y, victim, mission, s,
-                                      md, targeting_ships);
+                                      targeting_ships);
        } else if (glp->thing->ef_type == EF_PLANE) {
-           pcp = glp->cp;
+           pcp = &plchr[glp->thing->type];
            if (pcp->pl_flags & P_M)
                /* units have their own missile interdiction */
                if (hardtarget != SECT_HARDTARGET || pcp->pl_flags & P_MAR)
@@ -455,16 +446,17 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
 
 static int
 perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
-                    natid victim, int mission, char *s, int md,
+                    natid victim, int mission, char *s,
                     int targeting_ships)
 {
-    int range, dam2;
+    int md, range, dam2;
 
     if (mission == MI_SINTERDICT)
        return dam;
 
-    if ((mission == MI_INTERDICT) &&
-       (md > land_max_interdiction_range))
+    md = mapdist(x, y, lp->lnd_x, lp->lnd_y);
+
+    if (mission == MI_INTERDICT && md > land_max_interdiction_range)
        return dam;
 
     range = roundrange(lnd_fire_range(lp));
@@ -496,17 +488,19 @@ perform_mission_land(int dam, struct lndstr *lp, coord x, coord y,
 
 static int
 perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y,
-                    natid victim, int mission, char *s, int md,
+                    natid victim, int mission, char *s,
                     int targeting_ships)
 {
     struct mchrstr *mcp = &mchr[sp->shp_type];
     double vrange, hitchance;
-    int range, dam2;
+    int md, range, dam2;
+
+    md = mapdist(x, y, sp->shp_x, sp->shp_y);
 
-    if (((mission == MI_INTERDICT) ||
-        (mission == MI_SINTERDICT)) &&
-       (md > ship_max_interdiction_range))
+    if ((mission == MI_INTERDICT || mission == MI_SINTERDICT)
+       && md > ship_max_interdiction_range)
        return dam;
+
     if (mission == MI_SINTERDICT) {
        if (!(mcp->m_flags & M_SONAR))
            return dam;