(unit_put): New, create by combining shp_put() and lnd_put().

(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.
This commit is contained in:
Ron Koenderink 2007-01-23 23:51:02 +00:00
parent 038cc74d4e
commit d94d269769
8 changed files with 39 additions and 56 deletions

View 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);

View 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 *);

View 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);

View 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);
}
/*

View 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];

View 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];

View 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;
}
}

View 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;