Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions MainServer/include/Classes/Room.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <vector>
#include <string>
#include <unordered_set>
#include "../Structures/Room/ClientRoomCreationInfo.h"
#include "../Structures/Room/RoomPlayerInfo.h"
#include "../Structures/Room/RoomsList.h"
Expand Down Expand Up @@ -41,6 +42,7 @@ namespace Main

std::vector<std::pair<std::uint32_t, std::string>> m_kickedPlayerAccountIds{};
std::vector<std::uint32_t> m_votekickStarters{}; // each player has only 1 votekick per match
std::unordered_set<std::uint32_t> m_pendingInviteAccountIds{};

// Points
std::uint32_t m_bluePoints{};
Expand Down Expand Up @@ -290,6 +292,9 @@ namespace Main
bool wasPreviouslyKicked(std::uint32_t accountId) const;
bool removeKickedPlayerByNickname(const std::string& nickname);
std::vector<std::string> getKickedPlayerNicknames() const;
void addPendingInvite(std::uint32_t accountId);
bool hasPendingInvite(std::uint32_t accountId) const;
void removePendingInvite(std::uint32_t accountId);
Main::Structures::RoomSettingsUpdateTitlePassword getRoomSettingsUpdate() const;
Main::Network::Session::AccountInfo getAccountInfoFor(const Main::Structures::UniqueId& uniqueId) const;

Expand Down
1 change: 1 addition & 0 deletions MainServer/include/Handlers/Room/RoomInviteJoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace Main
}
response.setData(reinterpret_cast<std::uint8_t*>(&roomFollow), sizeof(roomFollow));
targetSession->asyncWrite(response);
room->addPendingInvite(targetSession->getAccountInfo().accountID);
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion MainServer/include/Handlers/Room/RoomJoinHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ namespace Main
std::memcpy(roomInfo.password, room->getPassword().c_str(), Common::Constants::maxPassword);
}
// Fix: Check if room has password and player did not input any password, deny access
else if (roomSettings.hasPassword && !hasInputtedPassword)
// Exception: players who were explicitly invited already have server-side authorization
else if (roomSettings.hasPassword && !hasInputtedPassword && !room->hasPendingInvite(accountInfo.accountID))
{
response.setExtra(RoomJoinExtra::JOIN_INVALID_PASSWORD);
session->asyncWrite(response);
Expand Down Expand Up @@ -289,6 +290,7 @@ namespace Main
room->addObserverPlayer(session);
else
room->addPlayer(session, latestEnteredPlayerInfo.team);
room->removePendingInvite(accountInfo.accountID);

if (room->isAssassinMode())
{
Expand Down
15 changes: 15 additions & 0 deletions MainServer/src/Classes/Room.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,21 @@ namespace Main
!= m_kickedPlayerAccountIds.end();
}

void Room::addPendingInvite(std::uint32_t accountId)
{
m_pendingInviteAccountIds.insert(accountId);
}

bool Room::hasPendingInvite(std::uint32_t accountId) const
{
return m_pendingInviteAccountIds.contains(accountId);
}

void Room::removePendingInvite(std::uint32_t accountId)
{
m_pendingInviteAccountIds.erase(accountId);
}

bool Room::removeKickedPlayerByNickname(const std::string& nickname)
{
auto initialSize = m_kickedPlayerAccountIds.size();
Expand Down