Author Topic: Lag when player left  (Read 1057 times)

spectrator

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Lag when player left
« on: January 12, 2016, 05:57:05 am »
Hello, does anyone know, why lags when player left game?
It looks like
Code: [Select]
[Tue Jan 12 11:58:47 2016] [DENY] Denying connections from 213.230.73.186 for 5 seconds: user left game: 7
[Tue Jan 12 11:58:47 2016] deny count: 0 1441813633 1441303393 510240
[Tue Jan 12 11:58:47 2016] [GAME: gamename] deleting player [Playername]: left.
[Tue Jan 12 11:58:47 2016] [GAME: gamename] [Local]: Playername left.
[Tue Jan 12 11:58:47 2016] [GAME: gamename] warning - the latency is 10ms but the last update was late by 95ms


[Tue Jan 12 13:44:21 2016] [DENY] Denying connections from 217.25.213.240 for 5 seconds: user left game: 7
[Tue Jan 12 13:44:21 2016] deny count: 0 1448147800 1448022572 125228
[Tue Jan 12 13:44:21 2016] [GAME: gamename] deleting player [Playername]:left.
[Tue Jan 12 13:44:21 2016] [GAME: gamename] [Local]: Playername left..
[Tue Jan 12 13:44:21 2016] [GAME: gamename] warning - the latency is 50ms but the last update was late by 60ms
And this cause micro lag in game.
How to minimize lags?
I look on code, and didn`t find anything, what may cause this lags, it didn`t write anything in db, when player leave.
Code: [Select]
void CBaseGame :: EventPlayerLeft( CGamePlayer *player, uint32_t reason )
{
// this function is only called when a player leave packet is received, not when there's a socket error, kick, etc...
if( !m_GameLoading && !m_GameLoaded&& !IsOwner(player->GetName())&&!IsAdmin(player->GetName())&&!IsRootAdmin(player->GetName()) )
m_GHost->DenyIP( player->GetExternalIPString( ), 5000, "user left lobby: " + UTIL_ToString( reason ) );
else
if(!IsAdmin(player->GetName())&&!IsRootAdmin(player->GetName()))
m_GHost->DenyIP( player->GetExternalIPString( ), 5000, "user left game: " + UTIL_ToString( reason ) );

uint32_t GameNr = GetGameNr();

bool show = true;
if (m_GHost->m_CurrentGame)
if (m_GHost->m_CurrentGame->GetCreationTime()==GetCreationTime())
show = false;
if (show && !m_GameEnded)
m_LastLeaverTicks = GetTicks();
player->SetDeleteMe( true );
if( reason == PLAYERLEAVE_GPROXY )
player->SetLeftReason( m_GHost->m_Language->WasUnrecoverablyDroppedFromGProxy( ) );
else
player->SetLeftReason( m_GHost->m_Language->HasLeftVoluntarily() );
player->SetLeftCode( PLAYERLEAVE_LOST );

ReCalculateTeams();

if( !m_GameLoading && !m_GameLoaded )
OpenSlot( GetSIDFromPID( player->GetPID( ) ), false );
}





void CBaseGame :: EventPlayerDeleted( CGamePlayer *player )
{
CONSOLE_Print( "[GAME: " + m_GameName + "] deleting player [" + player->GetName( ) + "]: " + player->GetLeftReason( ) );

// remove any queued spoofcheck messages for this player

if( player->GetWhoisSent( ) && !player->GetJoinedRealm( ).empty( ) && player->GetSpoofedRealm( ).empty( ) )
{
for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ )
{
if( (*i)->GetServer( ) == player->GetJoinedRealm( ) )
{
// hackhack: there must be a better way to do this

if( (*i)->GetPasswordHashType( ) == "pvpgn" )
(*i)->UnqueueChatCommand( "/whereis " + player->GetName( ) );
else
(*i)->UnqueueChatCommand( "/whois " + player->GetName( ) );

(*i)->UnqueueChatCommand( "/w " + player->GetName( ) + " " + m_GHost->m_Language->SpoofCheckByReplying( ) );
}
}
}

m_LastPlayerLeaveTicks = GetTicks( );


uint32_t GameNr = GetGameNr();

if (m_GHost->m_CurrentGame)
if (m_GHost->m_CurrentGame->GetCreationTime()==GetCreationTime())
GameNr = 255;



// in some cases we're forced to send the left message early so don't send it again

if( player->GetLeftMessageSent( ) )
return;

player->SetLeftMessageSent(true);

ReCalculateTeams();

if( m_GameLoaded )
SendAllChat( player->GetName( ) + " " + player->GetLeftReason( ) + "." );

if( player->GetLagging( ) )
SendAll( m_Protocol->SEND_W3GS_STOP_LAG( player ) );

// autosave


if( m_GameLoading && m_LoadInGame )
{
// we must buffer player leave messages when using "load in game" to prevent desyncs
// this ensures the player leave messages are correctly interleaved with the empty updates sent to each player

for( vector<CGamePlayer *> :: iterator i = m_Players.begin( ); i != m_Players.end( ); i++ )
{
if( (*i)->GetFinishedLoading( ) )
{
if( !player->GetFinishedLoading( ) )
Send( *i, m_Protocol->SEND_W3GS_STOP_LAG( player ) );

Send( *i, m_Protocol->SEND_W3GS_PLAYERLEAVE_OTHERS( player->GetPID( ), player->GetLeftCode( ) ) );
}
else
(*i)->AddLoadInGameData( m_Protocol->SEND_W3GS_PLAYERLEAVE_OTHERS( player->GetPID( ), player->GetLeftCode( ) ) );
}
}
else
{
// tell everyone about the player leaving

SendAll( m_Protocol->SEND_W3GS_PLAYERLEAVE_OTHERS( player->GetPID( ), player->GetLeftCode( ) ) );
}

// set the replay's host PID and name to the last player to leave the game
// this will get overwritten as each player leaves the game so it will eventually be set to the last player

if( m_Replay && ( m_GameLoading || m_GameLoaded ) )
{
m_Replay->SetHostPID( player->GetPID( ) );
m_Replay->SetHostName( player->GetName( ) );

// add leave message to replay

if( m_GameLoading && !m_LoadInGame )
m_Replay->AddLeaveGameDuringLoading( 1, player->GetPID( ), player->GetLeftCode( ) );
else
m_Replay->AddLeaveGame( 1, player->GetPID( ), player->GetLeftCode( ) );
}

// abort the countdown if there was one in progress

if (!m_NormalCountdown)
if( m_CountDownStarted && !m_GameLoading && !m_GameLoaded )
{
SendAllChat( m_GHost->m_Language->CountDownAborted( ) );
m_CountDownStarted = false;
if (m_NormalCountdown)
SendAll( m_Protocol->SEND_W3GS_COUNTDOWN_END( ));



}
}




Used bot: Ghost One based, without gui
« Last Edit: January 12, 2016, 06:00:18 am by spectrator »

Grief-Code

  • Average Member
  • ***
  • Posts: 149
  • Karma: +25/-8
    • View Profile
Re: Lag when player left
« Reply #1 on: January 12, 2016, 03:41:28 pm »
Ghostone based?
So you modified it?

spectrator

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Re: Lag when player left
« Reply #2 on: January 12, 2016, 04:39:21 pm »
Yes, and this problem appears, as i remember, even on original ghost one.And in my version i didn`t modify this part of code.
Micro lags appears only when game hosted(or rehosted) and when player left.

Grief-Code

  • Average Member
  • ***
  • Posts: 149
  • Karma: +25/-8
    • View Profile
Re: Lag when player left
« Reply #3 on: January 13, 2016, 01:35:46 am »
Can you  try to use ghost one and confirm your statement?
I've never run j to issues of any kind of lags on the default ghost. Sure they have tweaks, but never that it does totally influence other running games.