GameController: Add OnPlayerConnect() like in the upstream

This commit is contained in:
Alexander Akulich 2021-01-13 03:59:29 +03:00
parent a9bc6190eb
commit a6bdda60ed
3 changed files with 16 additions and 4 deletions

View file

@ -1179,8 +1179,9 @@ void CGameContext::ProgressVoteOptions(int ClientID)
void CGameContext::OnClientEnter(int ClientID)
{
m_pController->OnPlayerConnect(m_apPlayers[ClientID]);
//world.insert_entity(&players[client_id]);
m_apPlayers[ClientID]->Respawn();
// init the player
Score()->PlayerData(ClientID)->Reset();
m_apPlayers[ClientID]->m_Score = Score()->PlayerData(ClientID)->m_BestTime ? Score()->PlayerData(ClientID)->m_BestTime : -9999;
@ -1255,9 +1256,6 @@ void CGameContext::OnClientEnter(int ClientID)
if(g_Config.m_SvWelcome[0] != 0)
SendChatTarget(ClientID, g_Config.m_SvWelcome);
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientID, Server()->ClientName(ClientID), m_apPlayers[ClientID]->GetTeam());
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
IServer::CClientInfo Info;
Server()->GetClientInfo(ClientID, &Info);

View file

@ -384,6 +384,19 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
return false;
}
void IGameController::OnPlayerConnect(CPlayer *pPlayer)
{
int ClientID = pPlayer->GetCID();
pPlayer->Respawn();
if(!Server()->ClientPrevIngame(ClientID))
{
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientID, Server()->ClientName(ClientID), pPlayer->GetTeam());
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
}
}
void IGameController::OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason)
{
pPlayer->OnDisconnect();

View file

@ -105,6 +105,7 @@ public:
*/
virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0);
virtual void OnPlayerConnect(class CPlayer *pPlayer);
virtual void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason);
void OnReset();