Skip to content

Commit

Permalink
fix: Limit the number of players that can join a team (#1187)
Browse files Browse the repository at this point in the history
* Limit the number of players that can join a team
after being invited

* Notify player if they weren't added to the team

* check pointer
  • Loading branch information
aronwk-aaron authored Aug 18, 2023
1 parent d893ecd commit 2e386d2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dChatServer/PlayerContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Database.h"
#include "eConnectionType.h"
#include "eChatInternalMessageType.h"
#include "ChatPackets.h"

PlayerContainer::PlayerContainer() {
}
Expand Down Expand Up @@ -207,6 +208,14 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
}

void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
if (team->memberIDs.size() >= 4){
Game::logger->Log("PlayerContainer", "Tried to add player to team that already had 4 players");
auto* player = GetPlayerData(playerID);
if (!player) return;
ChatPackets::SendSystemMessage(player->sysAddr, u"The teams is full! You have not been added to a team!");
return;
}

const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);

if (index != team->memberIDs.end()) return;
Expand Down

0 comments on commit 2e386d2

Please sign in to comment.