Browse Source

Autosave checkpoint

gravgun
mittorn 6 years ago
parent
commit
c372e64f31
  1. 7
      dlls/coop.cpp
  2. 2
      dlls/coop_util.h
  3. 2
      dlls/triggers.cpp

7
dlls/coop.cpp

@ -191,12 +191,17 @@ COOP_AutoSave @@ -191,12 +191,17 @@ COOP_AutoSave
Helper for trigger_autosave
=========================
*/
void COOP_AutoSave( void )
void COOP_AutoSave( CBaseEntity *pPlayer )
{
strncpy( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO2], g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1], 31 );
g_CoopState.p.iLastAutoSave ^= 1;
snprintf( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1], 31, "auto%d-%s", g_CoopState.p.iLastAutoSave, STRING( gpGlobals->mapname ) );
GGM_Save( g_CoopState.p.rgszSaveSlots[COOP_SAVE_AUTO1] );
memmove( &g_CoopState.pCurrentMap->p.rgCheckpoints[1], &g_CoopState.pCurrentMap->p.rgCheckpoints[0], sizeof ( g_CoopState.pCurrentMap->p.rgCheckpoints[0] ) * 3 );
g_CoopState.pCurrentMap->p.rgCheckpoints[0].flTime = gpGlobals->time;
snprintf( g_CoopState.pCurrentMap->p.rgCheckpoints[0].szDisplayName, 31, "autosave %d", (int)( gpGlobals->time / 60 ) );
GGM_SavePosition( (CBasePlayer*)pPlayer, &g_CoopState.pCurrentMap->p.rgCheckpoints[0].pos );
UTIL_CoopPrintMessage("%s activated autosave!\n", GGM_PlayerName( pPlayer ) );
}
#include <dirent.h>

2
dlls/coop_util.h

@ -55,7 +55,7 @@ void COOP_GiveDefaultWeapons( CBasePlayer *pPlayer ); @@ -55,7 +55,7 @@ void COOP_GiveDefaultWeapons( CBasePlayer *pPlayer );
void COOP_AddDefaultWeapon( const char *pszClassName );
void COOP_WriteState( const char *path );
bool COOP_ReadState( const char *path );
void COOP_AutoSave( void );
void COOP_AutoSave( CBaseEntity *pPlayer );
bool COOP_PlayerSpawn( CBasePlayer *pPlayer );
void COOP_ClearSaves( void );
struct COOPChangelevelData *COOP_GetTriggerData( CBaseEntity *pTrigger );

2
dlls/triggers.cpp

@ -2294,7 +2294,7 @@ void CTriggerSave::SaveTouch( CBaseEntity *pOther ) @@ -2294,7 +2294,7 @@ void CTriggerSave::SaveTouch( CBaseEntity *pOther )
SetTouch( NULL );
UTIL_Remove( this );
if( mp_coop.value )
COOP_AutoSave();
COOP_AutoSave( pOther );
else
SERVER_COMMAND( "autosave\n" );
}

Loading…
Cancel
Save