Skip to content

Commit b3da076

Browse files
authored
Merge branch 'openmultiplayer:master' into patch-1
2 parents 55c605d + 3420cf3 commit b3da076

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Server/Source/player_pool.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,26 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
16931693
return { NewConnectionResult_BadName, nullptr };
16941694
}
16951695

1696-
Player* result = storage.emplace(*this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1696+
Player* result = nullptr;
1697+
1698+
if (params.bot)
1699+
{
1700+
static const auto maxPlayers = core.getConfig().getInt("max_players");
1701+
for (auto index = *maxPlayers - 1; index >= 0; --index)
1702+
{
1703+
if (storage.get(index) == nullptr)
1704+
{
1705+
storage.claimHint(index, *this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1706+
result = storage.get(index);
1707+
break;
1708+
}
1709+
}
1710+
}
1711+
else
1712+
{
1713+
result = storage.emplace(*this, netData, params, useAllAnimations_, validateAnimations_, allowInteriorWeapons_, fixesComponent_);
1714+
}
1715+
16971716
if (!result)
16981717
{
16991718
return { NewConnectionResult_NoPlayerSlot, nullptr };

0 commit comments

Comments
 (0)