Skip to content

Commit 7770005

Browse files
ksenonadvAmyrAhmady
authored andcommitted
reverse search for NPC id in player pool
1 parent 67687a5 commit 7770005

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Server/Source/player_pool.hpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1688,7 +1688,25 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
16881688
return { NewConnectionResult_BadName, nullptr };
16891689
}
16901690

1691-
Player* result = storage.emplace(*this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1691+
Player* result = nullptr;
1692+
1693+
if (params.bot)
1694+
{
1695+
for (auto index = storage.Capacity - 1; index >= 0; --index)
1696+
{
1697+
if (storage.get(index) == nullptr)
1698+
{
1699+
storage.claimHint(index, *this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1700+
result = storage.get(index);
1701+
break;
1702+
}
1703+
}
1704+
}
1705+
else
1706+
{
1707+
result = storage.emplace(*this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1708+
}
1709+
16921710
if (!result)
16931711
{
16941712
return { NewConnectionResult_NoPlayerSlot, nullptr };

0 commit comments

Comments
 (0)