(have_looked,have_found,set_have_looked,set_have_found,print_found):
collapse to shiplist function set (add,free,print,on). Fix bug where ship uid was a unsigned char instead of short. Switch to head pointer instead of head record with a linked list. Add a free().
This commit is contained in:
parent
fd700f235b
commit
042372d4c2
7 changed files with 48 additions and 144 deletions
|
@ -496,7 +496,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int ignore;
|
||||
struct shpstr ship;
|
||||
int nships = 0;
|
||||
struct shiplook head, *s, *s2;
|
||||
struct shiplist *head = NULL;
|
||||
s_char buf[1024];
|
||||
s_char prompt[128];
|
||||
s_char msg[128];
|
||||
|
@ -506,20 +506,9 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
int gun;
|
||||
int shell;
|
||||
|
||||
memset(&head, 0, sizeof(struct shiplook));
|
||||
head.uid = -1;
|
||||
for (qp = list->q_forw; qp != list && !player->aborted;
|
||||
qp = qp->q_forw) {
|
||||
if (head.uid != -1) {
|
||||
s = head.next;
|
||||
while (s != (struct shiplook *)0) {
|
||||
s2 = s;
|
||||
s = s->next;
|
||||
free(s2);
|
||||
}
|
||||
}
|
||||
memset(&head, 0, sizeof(struct shiplook));
|
||||
head.uid = -1;
|
||||
free_shiplist(&head);
|
||||
plp = (struct plist *)qp;
|
||||
if ((plp->pcp->pl_flags & P_C) && (!(plp->pcp->pl_flags & P_T)))
|
||||
continue;
|
||||
|
@ -545,7 +534,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
}
|
||||
if (*q == '?') {
|
||||
if (plp->pcp->pl_flags & P_A)
|
||||
print_found(&head);
|
||||
print_shiplist(head);
|
||||
else
|
||||
shipsatxy(target->sct_x, target->sct_y, 0, M_SUB);
|
||||
continue;
|
||||
|
@ -634,12 +623,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
next:
|
||||
;
|
||||
}
|
||||
s = head.next;
|
||||
while (s != (struct shiplook *)0) {
|
||||
s2 = s;
|
||||
s = s->next;
|
||||
free(s2);
|
||||
}
|
||||
free_shiplist(&head);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -228,7 +228,7 @@ sona(void)
|
|||
|
||||
void
|
||||
plane_sona(struct emp_qelem *plane_list, int x, int y,
|
||||
struct shiplook *head)
|
||||
struct shiplist **head)
|
||||
{
|
||||
struct plnstr *pp;
|
||||
struct plchrstr *pcp;
|
||||
|
@ -265,13 +265,8 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
|||
targ = &s;
|
||||
if (targ->shp_own == pp->pln_own || targ->shp_own == 0)
|
||||
continue;
|
||||
/*
|
||||
if (have_looked(targ->shp_uid,head))
|
||||
continue;
|
||||
*/
|
||||
if (have_found(targ->shp_uid, head))
|
||||
if (on_shiplist(targ->shp_uid, *head))
|
||||
continue;
|
||||
set_have_looked(targ->shp_uid, head);
|
||||
tmcp = &mchr[(int)targ->shp_type];
|
||||
if (!(tmcp->m_flags & M_SUB))
|
||||
continue;
|
||||
|
@ -294,7 +289,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
|||
}
|
||||
if ((dist > vrange))
|
||||
continue;
|
||||
set_have_found(targ->shp_uid, head);
|
||||
add_shiplist(targ->shp_uid, head);
|
||||
if (!found) {
|
||||
mpr(pp->pln_own,
|
||||
"\nSonar contact in %s\n", xyas(x, y, pp->pln_own));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue