]> git.pond.sub.org Git - empserver/commitdiff
(unit_put): New, create by combining shp_put() and lnd_put().
authorRon Koenderink <rkoenderink@yahoo.ca>
Tue, 23 Jan 2007 23:51:02 +0000 (23:51 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Tue, 23 Jan 2007 23:51:02 +0000 (23:51 +0000)
(sail_nav_fleet, shp_nav_one_sector): Replace shp_put() with unit_put().
(lnd_mar_one_sector, att_fight, move_in_land): Replace lnd_put() with unit_put().
(shp_put, lnd_put): Remove.

include/land.h
include/prototypes.h
include/unit.h
src/lib/subs/attsub.c
src/lib/subs/lndsub.c
src/lib/subs/shpsub.c
src/lib/subs/unitsub.c
src/lib/update/sail.c

index 8af468b6b45094722141633a04c860dd1b66917c..8be609a5469e9bff209926aabba579f05d41a6ce 100644 (file)
@@ -206,7 +206,6 @@ extern int count_sect_units(struct sctstr *);
 extern void count_units(struct shpstr *);
 extern void lnd_count_units(struct lndstr *);
 extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
-extern void lnd_put(struct emp_qelem *, natid);
 extern int lnd_hardtarget(struct lndstr *);
 extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
 extern int lnd_support(natid, natid, coord, coord, int);
index 26fa3193e686a17a32fd3215669d2c97b2c5db6f..77078d079c17855d44253bf5024a66fde3f94aa9 100644 (file)
@@ -665,7 +665,6 @@ extern void shp_sel(struct nstr_item *, struct emp_qelem *);
 extern void shp_nav(struct emp_qelem *, double *, double *, int *, natid);
 extern int shp_sweep(struct emp_qelem *, int, int, natid);
 extern char *shp_path(int, struct shpstr *, char *);
-extern void shp_put(struct emp_qelem *, natid);
 extern int shp_check_nav(struct sctstr *, struct shpstr *);
 extern int sect_has_dock(struct sctstr *);
 extern int shp_hardtarget(struct shpstr *);
index 6209bdcea1488c62e8edcbbad64fb6749626ac92..913532b2fa255dd466cc1886441e1e52f13e3ed5 100644 (file)
@@ -28,7 +28,7 @@
  *  unit.h: Generalize unit data structures and functions.
  * 
  *  Known contributors to this file:
- *     Ron Koenderink, 2006
+ *     Ron Koenderink, 2006-2007
  *     Markus Armbruster, 2006
  */
  
@@ -43,3 +43,4 @@ struct ulist {
 };
 
 extern void unit_list(struct emp_qelem *);
+extern void unit_put(struct emp_qelem *list, natid actor);
index 45028d5bdc7063120b6b65941661c9789aaa5c31..360da15ed24dabf615d7e951aeacbddc2b76fe46 100644 (file)
@@ -2017,7 +2017,7 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
     send_reacting_units_home(dlist);
 
     /* putland the defending land */
-    lnd_put(dlist, 0);
+    unit_put(dlist, 0);
 
     /* putland the attacking land */
     put_land(olist);
@@ -2394,7 +2394,7 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
     }
     if (QEMPTY(olist))
        return;
-    lnd_put(olist, 0);
+    unit_put(olist, 0);
 }
 
 /*
index 00c5cdd358db4de48bbdc24ae397d52c74bccc01..0b34c97bf5d7655dc432b9fdbad1966c0f230353 100644 (file)
@@ -598,32 +598,6 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
     }
 }
 
-void
-lnd_put(struct emp_qelem *list, natid actor)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *newqp;
-    struct ulist *llp;
-
-    qp = list->q_back;
-    while (qp != list) {
-       llp = (struct ulist *)qp;
-       if (actor) {
-           mpr(actor, "%s stopped at %s\n", prland(&llp->unit.land),
-               xyas(llp->unit.land.lnd_x, llp->unit.land.lnd_y,
-                    llp->unit.land.lnd_own));
-           if (llp->mobil < -127)
-               llp->mobil = -127;
-           llp->unit.land.lnd_mobil = llp->mobil;
-       }
-       putland(llp->unit.land.lnd_uid, &llp->unit.land);
-       newqp = qp->q_back;
-       emp_remque(qp);
-       free(qp);
-       qp = newqp;
-    }
-}
-
 void
 lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
          natid actor)
@@ -1014,7 +988,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
     int oldown;
 
     if (dir <= DIR_STOP || dir >= DIR_VIEW) {
-       lnd_put(list, actor);
+       unit_put(list, actor);
        return 1;
     }
     dx = diroff[dir][0];
index 679a119527ddf78055c7b9011bd75eb3359809d2..0d8c48ff6ae16651d37e5e8bf51732c80a276588 100644 (file)
@@ -186,28 +186,6 @@ shp_nav(struct emp_qelem *list, double *minmobp, double *maxmobp,
     }
 }
 
-void
-shp_put(struct emp_qelem *list, natid actor)
-{
-    struct emp_qelem *qp;
-    struct emp_qelem *newqp;
-    struct ulist *mlp;
-
-    qp = list->q_back;
-    while (qp != list) {
-       mlp = (struct ulist *)qp;
-       mpr(actor, "%s stopped at %s\n", prship(&mlp->unit.ship),
-           xyas(mlp->unit.ship.shp_x, mlp->unit.ship.shp_y,
-           mlp->unit.ship.shp_own));
-       mlp->unit.ship.shp_mobil = (int)mlp->mobil;
-       putship(mlp->unit.ship.shp_uid, &mlp->unit.ship);
-       newqp = qp->q_back;
-       emp_remque(qp);
-       free(qp);
-       qp = newqp;
-    }
-}
-
 int
 shp_sweep(struct emp_qelem *ship_list, int verbose, int takemob, natid actor)
 {
@@ -801,7 +779,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
     int navigate;
 
     if (dir <= DIR_STOP || dir >= DIR_VIEW) {
-       shp_put(list, actor);
+       unit_put(list, actor);
        return 1;
     }
     dx = diroff[dir][0];
index e19e9b9777e9186bd8758897551fe1e293d9d594..e69459c1633958047c1a4753c2787f46e4a4dc3d 100644 (file)
@@ -94,3 +94,35 @@ unit_list(struct emp_qelem *unit_list)
        pr("\n");
     }
 }
+
+void
+unit_put(struct emp_qelem *list, natid actor)
+{
+    struct emp_qelem *qp;
+    struct emp_qelem *newqp;
+    struct ulist *ulp;
+
+    qp = list->q_back;
+    while (qp != list) {
+       ulp = (struct ulist *)qp;
+       if (actor) {
+           mpr(actor, "%s stopped at %s\n", obj_nameof(&ulp->unit.gen),
+               xyas(ulp->unit.gen.x, ulp->unit.gen.y,
+                    ulp->unit.gen.own));
+           if (ulp->unit.ef_type == EF_LAND) {
+               if (ulp->mobil < -127)
+                   ulp->mobil = -127;
+               ulp->unit.land.lnd_mobil = ulp->mobil;
+           }
+       }
+       if (ulp->unit.ef_type == EF_SHIP)
+           ulp->unit.ship.shp_mobil = (int)ulp->mobil;
+       put_empobj(&ulp->unit.gen);
+       newqp = qp->q_back;
+       emp_remque(qp);
+       free(qp);
+       qp = newqp;
+    }
+}
+
+
index eb0d3931a7cab388d7445a9db43fd975df5976cd..9009f414eea0e7c77c8e5509bedc0b0bf9b85ba6 100644 (file)
@@ -251,7 +251,7 @@ sail_nav_fleet(struct fltheadstr *fltp)
            fltp->maxmoves = 1;
        --fltp->maxmoves;
     }
-    shp_put(&ship_list, own);
+    unit_put(&ship_list, own);
     getship(sp->shp_uid, &ship);
     fltp->x = ship.shp_x;
     fltp->y = ship.shp_y;