Skip to content
Snippets Groups Projects
Commit 3b193768 authored by James R.'s avatar James R.
Browse files

append_hyudoro, pop_hyudoro: fix linked list handling

- Use P_SetTarget to handle reference counting properly
- Properly unlink from the start of the list
parent c8502488
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,8 @@ get_look_angle (mobj_t *thing)
static boolean
is_hyudoro (mobj_t *thing)
{
return thing && thing->type == MT_HYUDORO;
return !P_MobjWasRemoved(thing) &&
thing->type == MT_HYUDORO;
}
static mobj_t *
......@@ -346,7 +347,7 @@ append_hyudoro
}
hyudoro_stackpos(hyu) = lastpos + 1;
*head = hyu;
P_SetTarget(head, hyu);
}
static void
......@@ -354,26 +355,37 @@ pop_hyudoro (mobj_t **head)
{
mobj_t *hyu = *head;
INT32 lastpos;
INT32 thispos;
if (!is_hyudoro(hyu))
{
return;
}
INT32 lastpos = hyudoro_stackpos(hyu);
if (is_hyudoro(hyu))
{
lastpos = hyudoro_stackpos(hyu);
hyu = hyudoro_next(hyu);
mobj_t *next = hyudoro_next(hyu);
while (is_hyudoro(hyu))
{
thispos = hyudoro_stackpos(hyu);
P_SetTarget(head, next);
P_SetTarget(&hyudoro_next(hyu), NULL);
hyudoro_stackpos(hyu) = lastpos;
lastpos = thispos;
hyu = next;
}
hyu = hyudoro_next(hyu);
}
if (!is_hyudoro(hyu))
{
return;
}
*head = hyu;
do
{
INT32 thispos = hyudoro_stackpos(hyu);
hyudoro_stackpos(hyu) = lastpos;
lastpos = thispos;
hyu = hyudoro_next(hyu);
}
while (is_hyudoro(hyu));
}
static void hyudoro_set_held_item_from_player
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment