2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-23 17:25:24 +01:00

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

This commit is contained in:
Alibek Omarov 2019-11-07 23:20:54 +03:00
parent 934dffd273
commit 428e8ef427

View File

@ -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 )
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 )
}
}
/*
==================
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
*/
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 )
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 )
}
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 )
#ifndef XASH_DEDICATED
if( result && !FBitSet( host.features, ENGINE_QUAKE_COMPATIBLE ))
CL_HudMessage( "GAMESAVED" ); // defined in titles.txt
#endif
#endif // XASH_DEDICATED
}
/*