Super Flicky: returned-to-owner relinks to end of swarm

Try really hard to not lock recollected swarm from
targeting players again.
This commit is contained in:
James R 2024-01-10 01:58:04 -08:00
parent 2c5df2f418
commit 3a928f23c8

View file

@ -420,6 +420,32 @@ struct Flicky : mobj_t
} }
} }
void relink()
{
Flicky* prev = nullptr;
for (Flicky* x = controller()->flicky(); x; x = x->next())
{
if (x == this)
{
return;
}
prev = x;
}
if (prev)
{
prev->next(this);
}
else
{
controller()->flicky(this);
}
next(nullptr);
}
void chase() void chase()
{ {
if (controller()->ending()) if (controller()->ending())
@ -487,6 +513,7 @@ struct Flicky : mobj_t
{ {
unnerf(); unnerf();
mode(Mode::kReserved); mode(Mode::kReserved);
relink();
controller()->collect(); controller()->collect();
} }
else else
@ -687,7 +714,7 @@ void Controller::search()
flicky(flicky()->next()); flicky(flicky()->next());
} }
chasing(nearestMobj); chasing(flicky() ? nearestMobj : nullptr);
mode(Mode::kEnRoute); mode(Mode::kEnRoute);
// Update entire swarm // Update entire swarm
@ -701,11 +728,6 @@ void Controller::search()
void Controller::collect() void Controller::collect()
{ {
if (mode() != Mode::kReturning)
{
return;
}
// Resume searching once all Flickys return // Resume searching once all Flickys return
for (Flicky* x = flicky(); x; x = x->next()) for (Flicky* x = flicky(); x; x = x->next())
{ {