From ab4fde8764b2748b1ecf4e4e2a2a4d03de7dd5e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Mar 2019 03:03:46 -1100 Subject: [PATCH] Test --- src/cc/rogue/fight.c | 26 ++++++++++++-------------- src/cc/rogue/list.c | 35 +++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/cc/rogue/fight.c b/src/cc/rogue/fight.c index e65e96d76..ae2db635d 100644 --- a/src/cc/rogue/fight.c +++ b/src/cc/rogue/fight.c @@ -290,8 +290,7 @@ attack(struct rogue_state *rs,THING *mp) } when 'N': { - register THING *obj, *steal; - register int nobj; + THING *obj, *steal; int nobj; /* * Nymph's steal a magic item, look through the pack @@ -594,26 +593,25 @@ void remove_mon(struct rogue_state *rs,coord *mp, THING *tp, bool waskill) { register THING *obj, *nexti; - for (obj = tp->t_pack; obj != NULL; obj = nexti) { - nexti = next(obj); - obj->o_pos = tp->t_pos; - detach(tp->t_pack, obj); - if (waskill) - fall(rs,obj, FALSE); - else - discard(obj); + nexti = next(obj); + obj->o_pos = tp->t_pos; + detach(tp->t_pack, obj); + if (waskill) + fall(rs,obj, FALSE); + else + discard(obj); } moat(mp->y, mp->x) = NULL; mvaddch(mp->y, mp->x, tp->t_oldch); detach(mlist, tp); if (on(*tp, ISTARGET)) { - kamikaze = FALSE; - to_death = FALSE; - if (fight_flush) - flush_type(); + kamikaze = FALSE; + to_death = FALSE; + if (fight_flush) + flush_type(); } discard(tp); } diff --git a/src/cc/rogue/list.c b/src/cc/rogue/list.c index 68d889d8b..60eac8b16 100644 --- a/src/cc/rogue/list.c +++ b/src/cc/rogue/list.c @@ -61,6 +61,16 @@ discard(THING *item) break; } } + THING *list = pack; + for (; list != NULL; list = next(list)) + { + if ( list == item ) + { + fprintf(stderr,"pack item discarded? (%s)\n",inv_name(list,FALSE)); + sleep(3); + break; + } + } #endif itemcounter--; free((char *) item); @@ -89,11 +99,11 @@ void _detach(THING **list, THING *item) { if (*list == item) - *list = next(item); + *list = next(item); if (prev(item) != NULL) - item->l_prev->l_next = next(item); + item->l_prev->l_next = next(item); if (next(item) != NULL) - item->l_next->l_prev = prev(item); + item->l_next->l_prev = prev(item); item->l_next = NULL; item->l_prev = NULL; } @@ -108,14 +118,14 @@ _attach(THING **list, THING *item) { if (*list != NULL) { - item->l_next = *list; - (*list)->l_prev = item; - item->l_prev = NULL; + item->l_next = *list; + (*list)->l_prev = item; + item->l_prev = NULL; } else { - item->l_next = NULL; - item->l_prev = NULL; + item->l_next = NULL; + item->l_prev = NULL; } *list = item; } @@ -129,17 +139,14 @@ void _free_list(THING **ptr) { THING *item; - while (*ptr != NULL) { - item = *ptr; - *ptr = next(item); - discard(item); + item = *ptr; + *ptr = next(item); + discard(item); } } - - /* * new_item * Get a new item with a specified size