Browse Source

Always connect save bot, dup ServerActivate checking

gravgun
mittorn 6 years ago
parent
commit
cf6aa96203
  1. 18
      dlls/coop.cpp
  2. 38
      dlls/gravgunmod.cpp
  3. 1
      dlls/gravgunmod.h

18
dlls/coop.cpp

@ -426,6 +426,9 @@ bool COOP_ProcessTransition( void ) @@ -426,6 +426,9 @@ bool COOP_ProcessTransition( void )
return false;
}
memset( &g_CoopState.p.savedPos, 0, sizeof( struct GGMPosition ) );
g_CoopState.p.fSaved = false;
COOP_MarkTriggers();
g_CoopState.p.savedPos = g_CoopState.landmarkTransition.pos;
@ -484,12 +487,23 @@ void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot @@ -484,12 +487,23 @@ void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot
void COOP_ServerActivate( void )
{
memset( &g_CoopState.p.savedPos, 0, sizeof( struct GGMPosition ) );
g_CoopState.p.fSaved = false;
static float st_DupCheck;
if( g_CoopState.landmarkTransition.fLoading )
{
st_DupCheck = gpGlobals->time;
}
if( st_DupCheck && gpGlobals->time && st_DupCheck == gpGlobals->time)
{
st_DupCheck = 0.0f;
return;
}
if( !mp_coop.value )
return;
GGM_ConnectSaveBot();
if( !COOP_ProcessTransition() )
{
ALERT( at_console, "Transition failed, new game started\n");

38
dlls/gravgunmod.cpp

@ -887,6 +887,41 @@ void GGM_LoadPlayers_f( void ) @@ -887,6 +887,41 @@ void GGM_LoadPlayers_f( void )
ALERT( at_error, "Failed to load player states from %s\n", CMD_ARGV( 1 ) );
}
void GGM_ConnectSaveBot( void )
{
edict_t *client0 = INDEXENT( 1 );
edict_t *bot = NULL;
char cmd[33] = "";
float health = client0->v.health;
int deadflag = client0->v.deadflag;
float zombietime_old;
bool fNeedKick = false;
SERVER_EXECUTE();
// save even with dead player
if( health <= 0 )
client0->v.health = 1;
client0->v.deadflag = 0;
if( g_engfuncs.pfnGetInfoKeyBuffer( client0 )[0] )
return;
snprintf( cmd, 32, "kick #%d\n", GETPLAYERUSERID( client0 ) );
SERVER_COMMAND(cmd);
SERVER_EXECUTE();
bot = g_engfuncs.pfnCreateFakeClient("_save_bot");
if( bot != client0 )
ALERT( at_warning, "Bot is not player 1\n" );
bot->v.health = 1;
bot->v.deadflag = 0;
client0->v.deadflag = deadflag;
client0->v.health = health;
if( zombietime )
zombietime->value = zombietime_old;
}
// hack to make save work when client 0 not connected
void GGM_Save( const char *savename )
{
@ -916,6 +951,9 @@ void GGM_Save( const char *savename ) @@ -916,6 +951,9 @@ void GGM_Save( const char *savename )
if( !strcmp( GETPLAYERAUTHID( client0 ), "VALVE_ID_LOOPBACK" ) )
fNeedKick = false;
if( mp_coop.value )
fNeedKick = false;
// hack to make save work when client 0 not connected
if( fNeedKick )
{

1
dlls/gravgunmod.h

@ -200,5 +200,6 @@ void GGM_TempBan( CBaseEntity *pEnt ); @@ -200,5 +200,6 @@ void GGM_TempBan( CBaseEntity *pEnt );
int GGM_ChangelevelVote( CBasePlayer *pPlayer, edict_t *pTrigger, const char *pszMapName );
void GGM_ClearVote( void );
void GGM_StartVoteCommand( CBasePlayer *pPlayer, const char *pszCommand, const char *pszMessage );
void GGM_ConnectSaveBot( void );
#endif // GRAVGUNMOD_H

Loading…
Cancel
Save