Skip to content

Commit

Permalink
Fix #2774: Prevent kick during redirect (#2955)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeteX1 committed Apr 10, 2023
1 parent 84e6e90 commit c56add8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/CPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class CPlayer final : public CPed, public CClient
void SetLeavingServer(bool bLeaving) noexcept { m_bIsLeavingServer = bLeaving; }
bool IsLeavingServer() const noexcept { return m_bIsLeavingServer; }

void SetRedirecting(bool bRedirecting) noexcept { m_bIsRedirecting = bRedirecting; }
bool IsRedirecting() const noexcept { return m_bIsRedirecting; }

protected:
bool ReadSpecialData(const int iLine) override { return true; }

Expand Down Expand Up @@ -359,6 +362,7 @@ class CPlayer final : public CPed, public CClient
CMtaVersion m_strPlayerVersion;
bool m_bIsMuted;
bool m_bIsLeavingServer;
bool m_bIsRedirecting;
bool m_bIsJoined;

bool m_bNametagColorOverridden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3462,6 +3462,7 @@ bool CStaticFunctionDefinitions::RedirectPlayer(CElement* pElement, const char*
BitStream.pBitStream->Write(ucPasswordLength);
BitStream.pBitStream->Write(szPassword, ucPasswordLength);
}
pPlayer->SetRedirecting(true);
pPlayer->Send(CLuaPacket(FORCE_RECONNECT, *BitStream.pBitStream));

usPort = usPort ? usPort : g_pGame->GetConfig()->GetServerPort();
Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPlayerDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,12 @@ int CLuaPlayerDefs::KickPlayer(lua_State* luaVM)
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pPlayer);

if (pPlayer->IsRedirecting())
{
lua_pushboolean(luaVM, false);
return 1;
}

if (argStream.NextIsUserData())
{
CClient* pResponsible;
Expand Down

0 comments on commit c56add8

Please sign in to comment.