Skip to content

Commit

Permalink
Check that there are free slots for players
Browse files Browse the repository at this point in the history
  • Loading branch information
Monsterovich authored and past-due committed Jun 14, 2024
1 parent 41afd2f commit 221be39
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/multiint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@

#include "activity.h"
#include <algorithm>
#include <set>
#include "3rdparty/gsl_finally.h"

#define MAP_PREVIEW_DISPLAY_TIME 2500 // number of milliseconds to show map in preview
Expand Down Expand Up @@ -1960,8 +1961,6 @@ class WzPlayerIndexSwapPositionRowRactory : public WzPlayerSelectPositionRowFact
}
};

#include <set>

static std::set<uint32_t> validPlayerIdxTargetsForPlayerPositionMove(uint32_t player)
{
std::set<uint32_t> validTargetPlayerIdx;
Expand Down Expand Up @@ -4016,8 +4015,8 @@ class WzPlayerRow : public WIDGET
if (playerIdx == selectedPlayer || NetPlay.isHost)
{
uint32_t player = playerIdx;
// host can move any player, clients can request to move themselves
if ((player == selectedPlayer || (NetPlay.players[player].allocated && NetPlay.isHost))
// host can move any player, clients can request to move themselves if there are available slots
if (((player == selectedPlayer && validPlayerIdxTargetsForPlayerPositionMove(player).size() > 0) || (NetPlay.players[player].allocated && NetPlay.isHost))
&& !locked.position
&& player < MAX_PLAYERS
&& !isSpectatorOnlySlot(player))
Expand Down

0 comments on commit 221be39

Please sign in to comment.