Browse Source

Working reconnect mechanizm

hlzbot-dirty
mittorn 8 years ago
parent
commit
7f3a00c971
  1. 18
      dlls/client.cpp
  2. 6
      dlls/multiplay_gamerules.cpp
  3. 30
      dlls/triggers.cpp

18
dlls/client.cpp

@ -83,14 +83,14 @@ BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddres
CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ; CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ;
if( pl ) if( pl )
{ {
pl->m_state = STATE_CONNECTED; pl->m_state = STATE_UNINITIALIZED;
pl->RemoveAllItems( TRUE ); pl->RemoveAllItems( TRUE );
BecomeSpectator( pl ); BecomeSpectator( pl );
ClientPutInServer( pl->edict() ); //ClientPutInServer( pl->edict() );
} }
} }
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 ); //g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason ); return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason );
@ -698,7 +698,7 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
plr->m_state = STATE_UNINITIALIZED; plr->m_state = STATE_UNINITIALIZED;
plr->RemoveAllItems( TRUE ); plr->RemoveAllItems( TRUE );
BecomeSpectator( plr ); BecomeSpectator( plr );
plr->Spawn(); //plr->Spawn();
} }
} }
} }
@ -719,6 +719,9 @@ void PlayerPreThink( edict_t *pEntity )
entvars_t *pev = &pEntity->v; entvars_t *pev = &pEntity->v;
CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity); CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE(pEntity);
if( !pPlayer )
ClientPutInServer( pEntity );
if (pPlayer) if (pPlayer)
pPlayer->PreThink( ); pPlayer->PreThink( );
} }
@ -742,6 +745,7 @@ void PlayerPostThink( edict_t *pEntity )
} }
void CoopClearData( void ); void CoopClearData( void );
void CoopApplyData( void );
void CoopClearWeaponList( void ); void CoopClearWeaponList( void );
void ParmsNewLevel( void ) void ParmsNewLevel( void )
{ {
@ -749,7 +753,10 @@ void ParmsNewLevel( void )
SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData;
if ( pSaveData ) if ( pSaveData )
{
pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS ); pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS );
CoopApplyData();
}
else else
if( mp_coop_changelevel.value ) if( mp_coop_changelevel.value )
{ {
@ -766,7 +773,10 @@ void ParmsChangeLevel( void )
SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData; SAVERESTOREDATA *pSaveData = (SAVERESTOREDATA *)gpGlobals->pSaveData;
if ( pSaveData ) if ( pSaveData )
{
pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS ); pSaveData->connectionCount = BuildChangeList( pSaveData->levelList, MAX_LEVEL_CONNECTIONS );
CoopApplyData();
}
else else
if( mp_coop_changelevel.value ) if( mp_coop_changelevel.value )
{ {

6
dlls/multiplay_gamerules.cpp

@ -740,11 +740,11 @@ void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer )
if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) )
SpawnPlayer( pPlayer ); SpawnPlayer( pPlayer );
if( pPlayer->m_state == STATE_UNINITIALIZED ) if( pPlayer->m_state == STATE_UNINITIALIZED )
if( pPlayer->m_afButtonPressed ) if( pPlayer->m_afButtonPressed || pPlayer->pev->button )
{ {
//ClientPutInServer( pPlayer->edict() ); ClientPutInServer( pPlayer->edict() );
// clean prediction lags after changelevel // clean prediction lags after changelevel
CLIENT_COMMAND( pPlayer->edict(), "reconnect\n" ); //CLIENT_COMMAND( pPlayer->edict(), "reconnect\n" );
pPlayer->m_afButtonPressed = 0; pPlayer->m_afButtonPressed = 0;
return; return;
} }

30
dlls/triggers.cpp

@ -1495,7 +1495,8 @@ struct SavedCoords
bool trainsaved; bool trainsaved;
Vector trainoffset; Vector trainoffset;
char trainglobal[256]; char trainglobal[256];
} g_SavedCoords; } g_SavedCoords, s_SavedCoords;
void CoopClearData( void ) void CoopClearData( void )
@ -1505,6 +1506,11 @@ void CoopClearData( void )
g_SavedCoords = l_SavedCoords; g_SavedCoords = l_SavedCoords;
} }
void CoopApplyData( void )
{
g_SavedCoords = s_SavedCoords;
}
int g_iMenu; int g_iMenu;
void ShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **slot, signed char time = -1 ); void ShowMenu( CBasePlayer *pPlayer, const char *title, int count, const char **slot, signed char time = -1 );
@ -1868,7 +1874,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
if( !strcmp( m_szMapName, mp_coop_disabledmap.string ) ) if( !strcmp( m_szMapName, mp_coop_disabledmap.string ) )
{ {
UTIL_HudMessageAll( params, UTIL_VarArgs( "MAP %S IS DISABLED", m_szMapName ) ); UTIL_HudMessageAll( params, UTIL_VarArgs( "MAP %S IS DISABLED", m_szMapName ) );
return;
} }
// forget touch by some fool // forget touch by some fool
if( gpGlobals->time - pev->dmgtime > 30) if( gpGlobals->time - pev->dmgtime > 30)
@ -1997,7 +2003,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
} }
CoopSaveTrain( pActivator, &l_SavedCoords ); CoopSaveTrain( pActivator, &l_SavedCoords );
g_SavedCoords = l_SavedCoords; s_SavedCoords = l_SavedCoords;
@ -2054,8 +2060,8 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
if( !FNullEnt( pentLandmark ) ) if( !FNullEnt( pentLandmark ) )
{ {
strcpy( st_szNextSpot, m_szLandmarkName ); strcpy( st_szNextSpot, m_szLandmarkName );
strcpy( g_SavedCoords.landmark, m_szLandmarkName ); strcpy( s_SavedCoords.landmark, m_szLandmarkName );
g_SavedCoords.offset = gpGlobals->vecLandmarkOffset = VARS( pentLandmark )->origin; s_SavedCoords.offset = gpGlobals->vecLandmarkOffset = VARS( pentLandmark )->origin;
} }
//ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); //ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) );
@ -2070,19 +2076,23 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
// reset all players state // reset all players state
if( plr ) if( plr )
{ {
plr->m_state = STATE_CONNECTED; plr->m_state = STATE_UNINITIALIZED;
plr->RemoveAllItems( TRUE ); plr->RemoveAllItems( TRUE );
BecomeSpectator( plr ); BecomeSpectator( plr );
plr->SetThink( &CBasePlayer::Spawn ); //plr->SetThink( &CBasePlayer::Spawn );
plr->pev->nextthink = gpGlobals->time + 1; //plr->pev->nextthink = gpGlobals->time + 1;
//CLIENT_COMMAND( plr->edict(), "connect the-swank.pp.ua:27017\n" ); // HACK: force perform reconnection
CLIENT_COMMAND( plr->edict(), "reconnect\n" );
//CLIENT_COMMAND( plr->edict(), "alias cmd \"reconnect;unalias cmd\"\n" );
//MESSAGE_BEGIN( MSG_ONE, 2, NULL, plr->pev ); // svc_disconnect after stufftext //MESSAGE_BEGIN( MSG_ONE, 2, NULL, plr->pev ); // svc_disconnect after stufftext
//MESSAGE_END(); //MESSAGE_END();
//SERVER_COMMAND( UTIL_VarArgs( "kick %d\n", i-1 ) ); //SERVER_COMMAND( UTIL_VarArgs( "kick %d\n", i-1 ) );
//SERVER_EXECUTE(); //SERVER_EXECUTE();
} }
} }
CHANGE_LEVEL( st_szNextMap, st_szNextSpot ); SERVER_COMMAND( UTIL_VarArgs( "wait;wait;wait;wait;wait;changelevel %s %s\n", st_szNextMap, st_szNextSpot ) );
//CHANGE_LEVEL( st_szNextMap, st_szNextSpot );
} }
// //

Loading…
Cancel
Save