Browse Source

engine: server: simplify game saving code, hide GL_FreeImage under XASH_DEDICATED macro

pull/2/head
Alibek Omarov 5 years ago
parent
commit
428e8ef427
  1. 42
      engine/server/sv_save.c

42
engine/server/sv_save.c

@ -498,8 +498,10 @@ static void AgeSaveList( const char *pName, int count ) @@ -498,8 +498,10 @@ static void AgeSaveList( const char *pName, int count )
FS_Delete( newName );
FS_Delete( newShot );
#ifndef XASH_DEDICATED
// unloading the shot footprint
GL_FreeImage( newShot );
#endif // XASH_DEDICATED
while( count > 0 )
{
@ -519,8 +521,10 @@ static void AgeSaveList( const char *pName, int count ) @@ -519,8 +521,10 @@ static void AgeSaveList( const char *pName, int count )
Q_snprintf( newName, sizeof( newName ), "%s%s%02d.sav", DEFAULT_SAVE_DIRECTORY, pName, count );
Q_snprintf( newShot, sizeof( newShot ), "%s%s%02d.bmp", DEFAULT_SAVE_DIRECTORY, pName, count );
#ifndef XASH_DEDICATED
// unloading the oldshot footprint too
GL_FreeImage( oldShot );
#endif // XASH_DEDICATED
// scroll the name list down (e.g. rename quick04.sav to quick05.sav)
FS_Rename( oldName, newName );
@ -529,29 +533,6 @@ static void AgeSaveList( const char *pName, int count ) @@ -529,29 +533,6 @@ static void AgeSaveList( const char *pName, int count )
}
}
/*
==================
SaveGetName
build the savename
==================
*/
static qboolean SaveGetName( int lastnum, char *filename )
{
int a, b, c;
if( lastnum < 0 || lastnum > 999 )
return false;
a = lastnum / 100;
lastnum -= a * 100;
b = lastnum / 10;
c = lastnum % 10;
Q_sprintf( filename, "save%i%i%i", a, b, c );
return true;
}
/*
=============
DirectoryCopy
@ -2092,9 +2073,9 @@ SV_SaveGame @@ -2092,9 +2073,9 @@ SV_SaveGame
*/
void SV_SaveGame( const char *pName )
{
char comment[80];
int n, result;
string savename;
char comment[80];
int result;
string savename;
if( !COM_CheckString( pName ))
return;
@ -2104,11 +2085,12 @@ void SV_SaveGame( const char *pName ) @@ -2104,11 +2085,12 @@ void SV_SaveGame( const char *pName )
if( !Q_stricmp( pName, "new" ))
{
int n;
// scan for a free filename
for( n = 0; n < 1000; n++ )
{
if( !SaveGetName( n, savename ))
return;
Q_snprintf( savename, sizeof( savename ), "save%003d", n );
if( !FS_FileExists( va( "%s%s.sav", DEFAULT_SAVE_DIRECTORY, savename ), true ))
break;
@ -2122,8 +2104,10 @@ void SV_SaveGame( const char *pName ) @@ -2122,8 +2104,10 @@ void SV_SaveGame( const char *pName )
}
else Q_strncpy( savename, pName, sizeof( savename ));
#ifndef XASH_DEDICATED
// unload previous image from memory (it's will be overwritten)
GL_FreeImage( va( "%s%s.bmp", DEFAULT_SAVE_DIRECTORY, savename ));
#endif // XASH_DEDICATED
SaveBuildComment( comment, sizeof( comment ));
result = SaveGameSlot( savename, comment );
@ -2131,7 +2115,7 @@ void SV_SaveGame( const char *pName ) @@ -2131,7 +2115,7 @@ void SV_SaveGame( const char *pName )
#ifndef XASH_DEDICATED
if( result && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
CL_HudMessage( "GAMESAVED" ); // defined in titles.txt
#endif
#endif // XASH_DEDICATED
}
/*

Loading…
Cancel
Save