Combined struct llist and struct mlist into superset struct ulist.

(assa, set_leader, switch_leader, set_flagship, switch_flagship,
take_move_in_mob, get_land, ask_olist, att_get_defense,
get_dlist, get_ototal, get_dtotal, kill_land, att_infect_units,
put_land, att_reacting_units, count_bodies, att_fight,
send_reacting_units_home, take_def, ask_move_in, move_in_land,
lnd_print, lnd_delete, lnd_take_casualty, lnd_takemob,
lnd_sel, lnd_mar, lnd_put, lnd_sweep, contains_engineer,
lnd_check_mines, lnd_list, lnd_mess,
lnd_damage, lnd_easiest_target, lnd_mar_one_sector, shp_sel,
shp_nav, shp_put, shp_sweep, shp_check_one_mines, shp_check_mines,
shp_list, shp_mess, shp_count, shp_damage_one, shp_damage,
shp_contains, most_valuable_ship, shp_easiest_target,
shp_missile_interdiction, notify_coastguard,
shp_view, shp_nav_one_sector, shp_missdef, nav_ship,
fltp_to_list): Switch to struct ulist from either struct mlist
or struct llist.
This commit is contained in:
Ron Koenderink 2006-09-25 03:29:06 +00:00
parent 7d90028f20
commit cd8d742392
11 changed files with 514 additions and 471 deletions

View file

@ -36,10 +36,10 @@
#include "combat.h"
#include "commands.h"
#include "land.h"
#include "mission.h"
#include "path.h"
#include "ship.h"
#include "empobj.h"
#include "unit.h"
int
assa(void)
@ -59,7 +59,7 @@ assa(void)
int n;
int ourtotal;
struct emp_qelem *qp, *next;
struct llist *llp;
struct ulist *llp;
int rel;
att_combat_init(off, EF_SHIP);
@ -149,8 +149,8 @@ assa(void)
}
for (qp = olist.q_forw; qp != &olist; qp = next) {
next = qp->q_forw;
llp = (struct llist *)qp;
if (lchr[(int)llp->land.lnd_type].l_flags & L_SPY)
llp = (struct ulist *)qp;
if (lchr[(int)llp->unit.land.lnd_type].l_flags & L_SPY)
continue;
ourtotal++;
}
@ -163,34 +163,34 @@ assa(void)
for (qp = olist.q_forw; qp != &olist; qp = next) {
next = qp->q_forw;
llp = (struct llist *)qp;
llp = (struct ulist *)qp;
rel = getrel(getnatp(def->own), player->cnum);
if (chance(0.10) || rel == ALLIED || !def->own) {
pr("%s made it on shore safely.\n", prland(&llp->land));
llp->land.lnd_x = def->x;
llp->land.lnd_y = def->y;
llp->land.lnd_ship = -1;
putland(llp->land.lnd_uid, &llp->land);
pr("%s made it on shore safely.\n", prland(&llp->unit.land));
llp->unit.land.lnd_x = def->x;
llp->unit.land.lnd_y = def->y;
llp->unit.land.lnd_ship = -1;
putland(llp->unit.land.lnd_uid, &llp->unit.land);
} else {
pr("%s was spotted", prland(&llp->land));
pr("%s was spotted", prland(&llp->unit.land));
if (rel == HOSTILE || rel == AT_WAR || rel == SITZKRIEG ||
rel == MOBILIZATION) {
wu(0, def->own, "%s spy shot and killed in %s.\n",
cname(player->cnum), xyas(def->x, def->y,
def->own));
pr(" and was killed in the attempt.\n");
llp->land.lnd_effic = 0;
putland(llp->land.lnd_uid, &llp->land);
llp->unit.land.lnd_effic = 0;
putland(llp->unit.land.lnd_uid, &llp->unit.land);
lnd_delete(llp, "");
} else {
wu(0, def->own, "%s spy spotted in %s.\n",
cname(player->cnum), xyas(def->x, def->y,
def->own));
pr(" but made it ok.\n");
llp->land.lnd_x = def->x;
llp->land.lnd_y = def->y;
llp->land.lnd_ship = -1;
putland(llp->land.lnd_uid, &llp->land);
llp->unit.land.lnd_x = def->x;
llp->unit.land.lnd_y = def->y;
llp->unit.land.lnd_ship = -1;
putland(llp->unit.land.lnd_uid, &llp->unit.land);
}
}
}

View file

@ -37,9 +37,10 @@
#include <ctype.h>
#include "commands.h"
#include "file.h"
#include "land.h"
#include "map.h"
#include "path.h"
#include "empobj.h"
#include "unit.h"
static int set_leader(struct emp_qelem *list, struct lndstr **leaderp);
static void switch_leader(struct emp_qelem *list, int land_uid);
@ -187,16 +188,16 @@ march(void)
static int
set_leader(struct emp_qelem *list, struct lndstr **leaderp)
{
struct llist *llp = (struct llist *)(list->q_back);
struct ulist *llp = (struct ulist *)(list->q_back);
if (!*leaderp)
pr("Leader is ");
else if ((*leaderp)->lnd_uid != llp->land.lnd_uid)
else if ((*leaderp)->lnd_uid != llp->unit.land.lnd_uid)
pr("Changing leader to ");
else
return 0;
*leaderp = &llp->land;
pr("%s\n", prland(&llp->land));
*leaderp = &llp->unit.land;
pr("%s\n", prland(&llp->unit.land));
return 1;
}
@ -204,7 +205,7 @@ static void
switch_leader(struct emp_qelem *list, int land_uid)
{
struct emp_qelem *qp, *save;
struct llist *llp;
struct ulist *llp;
if (QEMPTY(list))
return;
@ -214,8 +215,8 @@ switch_leader(struct emp_qelem *list, int land_uid)
emp_remque(qp);
emp_insque(qp, list);
qp = list->q_back;
llp = (struct llist *)qp;
if (llp->land.lnd_uid == land_uid || land_uid == -1)
llp = (struct ulist *)qp;
if (llp->unit.land.lnd_uid == land_uid || land_uid == -1)
break;
} while (list->q_back != save);
}

View file

@ -38,7 +38,8 @@
#include "map.h"
#include "optlist.h"
#include "path.h"
#include "ship.h"
#include "empobj.h"
#include "unit.h"
static int set_flagship(struct emp_qelem *list, struct shpstr **flagshipp);
static void switch_flagship(struct emp_qelem *list, int ship_uid);
@ -288,16 +289,16 @@ nav_map(int x, int y, int show_designations)
static int
set_flagship(struct emp_qelem *list, struct shpstr **flagshipp)
{
struct mlist *mlp = (struct mlist *)(list->q_back);
struct ulist *mlp = (struct ulist *)(list->q_back);
if (!*flagshipp)
pr("Flagship is ");
else if ((*flagshipp)->shp_uid != mlp->ship.shp_uid)
else if ((*flagshipp)->shp_uid != mlp->unit.ship.shp_uid)
pr("Changing flagship to ");
else
return 0;
*flagshipp = &mlp->ship;
pr("%s\n", prship(&mlp->ship));
*flagshipp = &mlp->unit.ship;
pr("%s\n", prship(&mlp->unit.ship));
return 1;
}
@ -305,7 +306,7 @@ static void
switch_flagship(struct emp_qelem *list, int ship_uid)
{
struct emp_qelem *qp, *save;
struct mlist *mlp;
struct ulist *mlp;
if (QEMPTY(list))
return;
@ -315,8 +316,8 @@ switch_flagship(struct emp_qelem *list, int ship_uid)
emp_remque(qp);
emp_insque(qp, list);
qp = list->q_back;
mlp = (struct mlist *)qp;
if (mlp->ship.shp_uid == ship_uid || ship_uid == -1)
mlp = (struct ulist *)qp;
if (mlp->unit.ship.shp_uid == ship_uid || ship_uid == -1)
break;
} while (list->q_back != save);
}