2013-03-31 04:21:08 +00:00
# include "quakedef.h"
2016-01-18 05:22:07 +00:00
# include "pr_common.h"
2004-08-23 00:15:46 +00:00
2018-08-04 07:05:20 +00:00
# if !defined(CLIENTONLY) && defined(SAVEDGAMES)
2018-08-23 06:03:31 +00:00
# define CACHEGAME_VERSION_DEFAULT CACHEGAME_VERSION_VERBOSE
2004-11-29 01:21:00 +00:00
2004-08-23 00:15:46 +00:00
extern cvar_t skill ;
extern cvar_t deathmatch ;
extern cvar_t coop ;
extern cvar_t teamplay ;
2014-04-24 01:53:01 +00:00
extern cvar_t pr_enable_profiling ;
2004-08-23 00:15:46 +00:00
2018-08-04 07:05:20 +00:00
cvar_t sv_savefmt = CVARFD ( " sv_savefmt " , " " , CVAR_SAVE , " Specifies the format used for the saved game. \n 0=legacy. \n 1=fte \n 2=binary " ) ;
2018-05-21 13:47:53 +00:00
cvar_t sv_autosave = CVARFD ( " sv_autosave " , " 5 " , CVAR_SAVE , " Interval for autosaves, in minutes. Set to 0 to disable autosave. " ) ;
2018-09-23 19:35:24 +00:00
extern cvar_t pr_ssqc_memsize ;
2018-05-21 13:47:53 +00:00
2014-03-31 17:06:41 +00:00
void SV_Savegame_f ( void ) ;
2020-10-26 06:30:35 +00:00
typedef struct
{
char name [ 32 ] ;
union
{
int i ;
float f ;
} parm [ NUM_SPAWN_PARMS ] ;
char * parmstr ;
client_t * source ;
} loadplayer_t ;
struct loadinfo_s
{
size_t numplayers ;
loadplayer_t * players ;
} ;
2005-07-03 15:16:20 +00:00
//Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current
2015-01-21 18:18:37 +00:00
void SV_SavegameComment ( char * text , size_t textsize )
2004-08-23 00:15:46 +00:00
{
int i ;
char kills [ 20 ] ;
2015-01-21 18:18:37 +00:00
char datetime [ 64 ] ;
time_t timeval ;
2004-08-23 00:15:46 +00:00
char * mapname = sv . mapname ;
2015-01-21 18:18:37 +00:00
for ( i = 0 ; i < textsize - 1 ; i + + )
2004-08-23 00:15:46 +00:00
text [ i ] = ' ' ;
2015-01-21 18:18:37 +00:00
text [ textsize - 1 ] = ' \0 ' ;
2004-08-23 00:15:46 +00:00
if ( ! mapname )
strcpy ( text , " Unnamed_Level " ) ;
else
{
i = strlen ( mapname ) ;
2015-01-21 18:18:37 +00:00
if ( i > 22 )
i = 22 ;
2004-08-23 00:15:46 +00:00
memcpy ( text , mapname , i ) ;
}
2015-01-21 18:18:37 +00:00
kills [ 0 ] = ' \0 ' ;
2005-07-03 15:16:20 +00:00
# ifdef Q2SERVER
2005-03-18 06:13:11 +00:00
if ( ge ) //q2
{
2006-04-16 03:55:55 +00:00
kills [ 0 ] = ' \0 ' ;
2005-03-18 06:13:11 +00:00
}
else
2009-03-03 01:52:30 +00:00
# endif
# ifdef HLSERVER
if ( svs . gametype = = GT_HALFLIFE )
{
2015-01-21 18:18:37 +00:00
sprintf ( kills , " " ) ;
2009-03-03 01:52:30 +00:00
}
else
2005-07-03 15:16:20 +00:00
# endif
2015-01-21 18:18:37 +00:00
{
if ( ( int ) pr_global_struct - > killed_monsters | | ( int ) pr_global_struct - > total_monsters )
sprintf ( kills , " kills:%3i/%3i " , ( int ) pr_global_struct - > killed_monsters , ( int ) pr_global_struct - > total_monsters ) ;
}
time ( & timeval ) ;
strftime ( datetime , sizeof ( datetime ) , " %Y-%m-%d %H:%M:%S " , localtime ( & timeval ) ) ;
2004-08-23 00:15:46 +00:00
memcpy ( text + 22 , kills , strlen ( kills ) ) ;
2015-01-21 18:18:37 +00:00
if ( textsize > 39 )
{
Q_strncpyz ( text + 39 , datetime , textsize - 39 ) ;
}
2004-08-23 00:15:46 +00:00
// convert space to _ to make stdio happy
2015-01-21 18:18:37 +00:00
for ( i = 0 ; i < textsize - 1 ; i + + )
2004-08-23 00:15:46 +00:00
{
if ( text [ i ] = = ' ' )
text [ i ] = ' _ ' ;
else if ( text [ i ] = = ' \n ' )
text [ i ] = ' \0 ' ;
}
2015-01-21 18:18:37 +00:00
text [ textsize - 1 ] = ' \0 ' ;
2004-08-23 00:15:46 +00:00
}
2019-02-16 19:09:07 +00:00
pbool PDECL SV_ExtendedSaveData ( pubprogfuncs_t * progfuncs , void * loadctx , const char * * ptr )
2018-08-23 06:03:31 +00:00
{
2020-10-26 06:30:35 +00:00
struct loadinfo_s * loadinfo = loadctx ;
char token [ 65536 ] ;
2018-08-23 06:03:31 +00:00
com_tokentype_t tt ;
const char * l = * ptr ;
size_t idx ;
if ( l [ 0 ] = = ' s ' & & l [ 1 ] = = ' v ' & & l [ 2 ] = = ' . ' )
l + = 3 ; //DPism
do
{
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ;
} while ( tt = = TTP_LINEENDING ) ;
if ( tt ! = TTP_RAWTOKEN ) return false ;
if ( ! strcmp ( token , " lightstyle " ) | | ! strcmp ( token , " lightstyles " ) )
{ //lightstyle N "STYLESTRING" 1 1 1
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
idx = atoi ( token ) ;
2019-09-10 15:40:04 +00:00
if ( idx > = sv . maxlightstyles )
{
if ( idx > = MAX_NET_LIGHTSTYLES )
return false ; //unsupported index.
Z_ReallocElements ( ( void * * ) & sv . lightstyles , & sv . maxlightstyles , idx + 1 , sizeof ( * sv . lightstyles ) ) ;
}
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
2019-09-10 15:40:04 +00:00
if ( sv . lightstyles [ idx ] . str )
Z_Free ( ( char * ) sv . lightstyles [ idx ] . str ) ;
sv . lightstyles [ idx ] . str = Z_StrDup ( token ) ;
sv . lightstyles [ idx ] . colours [ 0 ] = sv . lightstyles [ idx ] . colours [ 1 ] = sv . lightstyles [ idx ] . colours [ 2 ] = 1.0 ;
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2019-09-10 15:40:04 +00:00
sv . lightstyles [ idx ] . colours [ 0 ] = atof ( token ) ;
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2019-09-10 15:40:04 +00:00
sv . lightstyles [ idx ] . colours [ 1 ] = atof ( token ) ;
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2019-09-10 15:40:04 +00:00
sv . lightstyles [ idx ] . colours [ 2 ] = atof ( token ) ;
2018-08-23 06:03:31 +00:00
}
else if ( ! strcmp ( token , " model_precache " ) | | ! strcmp ( token , " model " ) )
{ //model_precache N "MODELNAME"
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
idx = atoi ( token ) ;
if ( ! idx | | idx > = countof ( sv . strings . model_precache ) )
return false ; //unsupported index.
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
sv . strings . model_precache [ idx ] = PR_AddString ( svprogfuncs , token , 0 , false ) ;
}
2019-04-16 22:40:05 +00:00
# ifdef HAVE_LEGACY
2018-09-29 17:31:58 +00:00
else if ( ! strcmp ( token , " vwep " ) )
{ //vwep N "MODELNAME"
//0 IS valid, and frankly this stuff sucks.
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
idx = atoi ( token ) ;
if ( idx > = countof ( sv . strings . vw_model_precache ) )
return false ; //unsupported index.
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
sv . strings . vw_model_precache [ idx ] = PR_AddString ( svprogfuncs , token , 0 , false ) ;
}
# endif
2018-08-23 06:03:31 +00:00
else if ( ! strcmp ( token , " sound_precache " ) | | ! strcmp ( token , " sound " ) )
{ //sound_precache N "MODELNAME"
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
idx = atoi ( token ) ;
if ( ! idx | | idx > = countof ( sv . strings . sound_precache ) )
return false ; //unsupported index.
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
sv . strings . sound_precache [ idx ] = PR_AddString ( svprogfuncs , token , 0 , false ) ;
}
2019-01-13 16:51:50 +00:00
else if ( ! strcmp ( token , " particle_precache " ) | | ! strcmp ( token , " particle " ) )
2018-08-23 06:03:31 +00:00
{ //particle_precache N "MODELNAME"
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
idx = atoi ( token ) ;
if ( ! idx | | idx > = countof ( sv . strings . particle_precache ) )
return false ; //unsupported index.
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
sv . strings . particle_precache [ idx ] = PR_AddString ( svprogfuncs , token , 0 , false ) ;
}
2020-10-26 06:30:35 +00:00
else if ( ! strcmp ( token , " serverflags " ) )
{ //serverflags N (for map_restart to work properly)
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2020-10-26 06:30:35 +00:00
idx = atoi ( token ) ;
svs . serverflags = idx ;
2018-08-23 06:03:31 +00:00
}
2020-10-26 06:30:35 +00:00
else if ( ! strcmp ( token , " startspot " ) )
{ //startspot "foo" (for map_restart to work properly)
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2020-10-26 06:30:35 +00:00
InfoBuf_SetStarKey ( & svs . info , " *startspot " , token ) ;
}
else if ( loadinfo & & ! strcmp ( token , " spawnparm " ) )
{ //spawnparm idx val (for map_restart to work properly)
2018-08-23 06:03:31 +00:00
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
2020-10-26 06:30:35 +00:00
idx = atoi ( token ) ;
if ( idx = = 0 )
{ //the parmstr...
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_STRING ) return false ;
loadinfo - > players [ 0 ] . parmstr = Z_StrDup ( token ) ;
}
else if ( idx > = 1 & & idx < = countof ( loadinfo - > players - > parm ) )
{ //regular parm
l = COM_ParseTokenOut ( l , NULL , token , sizeof ( token ) , & tt ) ; if ( tt ! = TTP_RAWTOKEN ) return false ;
loadinfo - > players [ 0 ] . parm [ idx - 1 ] . f = atof ( token ) ;
}
}
//strbuffer+hashtable+etc junk
else if ( PR_Common_LoadGame ( svprogfuncs , token , & l ) )
;
2018-08-23 06:03:31 +00:00
else
return false ;
* ptr = l ;
return true ;
}
2018-09-01 04:18:08 +00:00
# ifndef QUAKETC
2018-12-04 08:57:29 +00:00
static qboolean SV_LegacySavegame ( const char * savename , qboolean verbose )
2014-03-30 08:55:06 +00:00
{
2015-11-18 07:37:39 +00:00
size_t len ;
2014-03-30 08:55:06 +00:00
char * s = NULL ;
client_t * cl ;
int clnum ;
2018-08-23 06:03:31 +00:00
int version = SAVEGAME_VERSION_FTE_LEG ;
2014-03-30 08:55:06 +00:00
2014-03-31 17:06:41 +00:00
char native [ MAX_OSPATH ] ;
char name [ MAX_QPATH ] ;
vfsfile_t * f ;
2014-03-30 08:55:06 +00:00
int i ;
char comment [ SAVEGAME_COMMENT_LENGTH + 1 ] ;
if ( sv . state ! = ss_active )
{
2018-12-04 08:57:29 +00:00
if ( verbose )
Con_TPrintf ( " Can't apply: Server isn't running or is still loading \n " ) ;
2018-08-23 06:03:31 +00:00
return false ;
2014-03-31 17:06:41 +00:00
}
if ( sv . allocated_client_slots ! = 1 | | svs . clients - > state ! = cs_spawned )
{
//we don't care about fte-format legacy.
2018-12-04 08:57:29 +00:00
if ( verbose )
Con_TPrintf ( " Unable to use legacy savegame format to save multiplayer games \n " ) ;
2018-08-23 06:03:31 +00:00
return false ;
2014-03-30 08:55:06 +00:00
}
2018-05-21 13:47:53 +00:00
sprintf ( name , " %s " , savename ) ;
2018-08-04 07:05:20 +00:00
COM_RequireExtension ( name , " .sav " , sizeof ( name ) ) ; //do NOT allow .pak etc
2014-03-31 17:06:41 +00:00
if ( ! FS_NativePath ( name , FS_GAMEONLY , native , sizeof ( native ) ) )
2018-08-23 06:03:31 +00:00
return false ;
2014-03-31 17:06:41 +00:00
Con_TPrintf ( U8 ( " Saving game to %s... \n " ) , native ) ;
2018-05-21 13:47:53 +00:00
f = FS_OpenVFS ( name , " wbp " , FS_GAMEONLY ) ;
2014-03-30 08:55:06 +00:00
if ( ! f )
{
2018-12-04 08:57:29 +00:00
if ( verbose )
Con_TPrintf ( " ERROR: couldn't open %s. \n " , name ) ;
2018-08-23 06:03:31 +00:00
return false ;
2014-03-30 08:55:06 +00:00
}
//if there are 1 of 1 players connected
2014-03-31 17:06:41 +00:00
if ( sv . allocated_client_slots = = 1 & & svs . clients - > state = = cs_spawned )
2014-03-30 08:55:06 +00:00
{ //try to go for nq/zq compatability as this is a single player game.
2014-03-31 17:06:41 +00:00
s = PR_SaveEnts ( svprogfuncs , NULL , & len , 0 , 2 ) ; //get the entity state now, so that we know if we can get the full state in a q1 format.
2014-03-30 08:55:06 +00:00
if ( s )
{
if ( progstype = = PROG_QW )
2018-08-23 06:03:31 +00:00
version = SAVEGAME_VERSION_QW ;
2014-03-30 08:55:06 +00:00
else
2018-08-23 06:03:31 +00:00
version = SAVEGAME_VERSION_NQ ;
2014-03-30 08:55:06 +00:00
}
}
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %i \n " , version ) ;
2015-01-21 18:18:37 +00:00
SV_SavegameComment ( comment , sizeof ( comment ) ) ;
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %s \n " , comment ) ;
2014-03-30 08:55:06 +00:00
2018-08-23 06:03:31 +00:00
if ( version = = SAVEGAME_VERSION_NQ | | version = = SAVEGAME_VERSION_QW )
2014-03-30 08:55:06 +00:00
{
2014-03-31 17:06:41 +00:00
//only 16 spawn parms.
for ( i = 0 ; i < 16 ; i + + )
VFS_PRINTF ( f , " %f \n " , svs . clients - > spawn_parms [ i ] ) ; //client 1.
VFS_PRINTF ( f , " %f \n " , skill . value ) ;
2014-03-30 08:55:06 +00:00
}
else
{
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %i \n " , sv . allocated_client_slots ) ;
2014-03-30 08:55:06 +00:00
for ( cl = svs . clients , clnum = 0 ; clnum < sv . allocated_client_slots ; cl + + , clnum + + )
{
2020-04-19 01:23:32 +00:00
if ( cl - > state < cs_loadzombie | | ! cl - > spawned ) //don't save if they are still connecting
2014-03-30 08:55:06 +00:00
{
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " \" \" \n " ) ;
2014-03-30 08:55:06 +00:00
continue ;
}
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " \" %s \" \n " , cl - > name ) ;
2014-03-30 08:55:06 +00:00
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %f \n " , cl - > spawn_parms [ i ] ) ;
2014-03-30 08:55:06 +00:00
}
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %i \n " , progstype ) ;
VFS_PRINTF ( f , " %f \n " , skill . value ) ;
VFS_PRINTF ( f , " %f \n " , deathmatch . value ) ;
VFS_PRINTF ( f , " %f \n " , coop . value ) ;
VFS_PRINTF ( f , " %f \n " , teamplay . value ) ;
2014-03-30 08:55:06 +00:00
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
VFS_PRINTF ( f , " %s \n " , svs . name ) ;
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " %f \n " , sv . time ) ;
2014-03-30 08:55:06 +00:00
2014-03-31 17:06:41 +00:00
// write the light styles (only 64 are saved in legacy saved games)
for ( i = 0 ; i < 64 ; i + + )
2014-03-30 08:55:06 +00:00
{
2019-09-10 15:40:04 +00:00
if ( i < sv . maxlightstyles & & sv . lightstyles [ i ] . str & & * sv . lightstyles [ i ] . str )
VFS_PRINTF ( f , " %s \n " , sv . lightstyles [ i ] . str ) ;
2014-03-30 08:55:06 +00:00
else
2014-03-31 17:06:41 +00:00
VFS_PRINTF ( f , " m \n " ) ;
2014-03-30 08:55:06 +00:00
}
if ( ! s )
2014-03-31 17:06:41 +00:00
s = PR_SaveEnts ( svprogfuncs , NULL , & len , 0 , 1 ) ;
VFS_PUTS ( f , s ) ;
VFS_PUTS ( f , " \n " ) ;
2018-08-23 06:03:31 +00:00
# if 1
/* Extended save info
* * This should also be compatible with both DP and QSS .
* * WARNING : this does NOT protect against models / sounds being precached in different / random orders ( statics / baselines / ambients will be wrong ) .
* * the only protection we get is from late precaches .
* * theoretically the loader could make it work by rewriting the various tables , but that would not necessarily be reliable .
2015-01-08 13:09:20 +00:00
*/
2018-08-23 06:03:31 +00:00
VFS_PUTS ( f , " /* \n " ) ;
VFS_PUTS ( f , " // FTE extended savegame \n " ) ;
2019-09-10 15:40:04 +00:00
for ( i = 0 ; i < sv . maxlightstyles ; i + + )
{ //yes, repeat styles 0-63 again, but only list ones that are not empty.
if ( sv . lightstyles [ i ] . str )
VFS_PRINTF ( f , " sv.lightstyles %i %s \n " , i , sv . lightstyles [ i ] . str ) ;
2018-08-23 06:03:31 +00:00
}
for ( i = 1 ; i < countof ( sv . strings . model_precache ) ; i + + )
{
if ( sv . strings . model_precache [ i ] )
VFS_PRINTF ( f , " sv.model_precache %i %s \n " , i , sv . strings . model_precache [ i ] ) ;
}
for ( i = 1 ; i < countof ( sv . strings . sound_precache ) ; i + + )
{
if ( sv . strings . sound_precache [ i ] )
2020-10-26 06:30:35 +00:00
VFS_PRINTF ( f , " sv.sound_precache %i %s \n " , i , sv . strings . sound_precache [ i ] ) ;
2018-08-23 06:03:31 +00:00
}
2020-10-26 06:30:35 +00:00
for ( i = 1 ; i < countof ( sv . strings . particle_precache ) ; i + + )
{
if ( sv . strings . particle_precache [ i ] )
VFS_PRINTF ( f , " sv.particle_precache %i %s \n " , i , sv . strings . particle_precache [ i ] ) ;
}
VFS_PRINTF ( f , " sv.serverflags %i \n " , svs . serverflags ) ; //zomg! a fix for losing runes on load;restart!
// VFS_PRINTF(f, "sv.startspot %s\n", InfoBuf_ValueForKey(&svs.info, "*startspot")); //startspot, for restarts.
if ( svs . clients - > spawn_parmstring )
{
size_t maxlen = strlen ( svs . clients - > spawn_parmstring ) * 2 + 4 + 1 ;
char * buffer = BZ_Malloc ( maxlen ) ;
VFS_PRINTF ( f , " spawnparm 0 %s \n " , COM_QuotedString ( svs . clients - > spawn_parmstring , buffer , sizeof ( maxlen ) , false ) ) ;
BZ_Free ( buffer ) ;
}
if ( version = = SAVEGAME_VERSION_NQ | | version = = SAVEGAME_VERSION_QW )
for ( i = 16 ; i < countof ( svs . clients - > spawn_parms ) ; i + + )
VFS_PRINTF ( f , " spawnparm %i %g \n " , i + 1 , svs . clients - > spawn_parms [ i ] ) ;
2018-08-23 06:03:31 +00:00
// sv.buffer %i %i "string"
// sv.bufstr %i %i "%s"
VFS_PUTS ( f , " */ \n " ) ;
# endif
2014-03-30 08:55:06 +00:00
svprogfuncs - > parms - > memfree ( s ) ;
2014-03-31 17:06:41 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
2018-05-21 13:47:53 +00:00
FS_FlushFSHashWritten ( name ) ;
2018-08-23 06:03:31 +00:00
Q_strncpyz ( sv . loadgame_on_restart , savename , sizeof ( sv . loadgame_on_restart ) ) ;
return true ;
2018-05-21 13:47:53 +00:00
}
# endif
2004-08-23 00:15:46 +00:00
void SV_FlushLevelCache ( void )
{
levelcache_t * cache ;
while ( svs . levcache )
{
cache = svs . levcache - > next ;
Z_Free ( svs . levcache ) ;
svs . levcache = cache ;
}
}
2006-01-11 22:25:46 +00:00
void LoadModelsAndSounds ( vfsfile_t * f )
{
char str [ 32768 ] ;
int i ;
2013-11-21 23:02:28 +00:00
sv . strings . model_precache [ 0 ] = PR_AddString ( svprogfuncs , " " , 0 , false ) ;
2014-09-17 03:04:08 +00:00
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
2006-01-11 22:25:46 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( ! * str )
break ;
2013-11-21 23:02:28 +00:00
sv . strings . model_precache [ i ] = PR_AddString ( svprogfuncs , str , 0 , false ) ;
2006-01-11 22:25:46 +00:00
}
2014-09-17 03:04:08 +00:00
if ( i = = MAX_PRECACHE_MODELS )
2006-01-11 22:25:46 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( * str )
SV_Error ( " Too many model precaches in loadgame cache " ) ;
}
2014-09-17 03:04:08 +00:00
for ( ; i < MAX_PRECACHE_MODELS ; i + + )
2006-02-17 02:51:59 +00:00
sv . strings . model_precache [ i ] = NULL ;
2006-01-11 22:25:46 +00:00
2016-01-18 05:22:07 +00:00
sv . strings . sound_precache [ 0 ] = PR_AddString ( svprogfuncs , " " , 0 , false ) ;
2014-09-17 03:04:08 +00:00
for ( i = 1 ; i < MAX_PRECACHE_SOUNDS ; i + + )
2006-01-11 22:25:46 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( ! * str )
break ;
2016-01-18 05:22:07 +00:00
sv . strings . sound_precache [ i ] = PR_AddString ( svprogfuncs , str , 0 , false ) ;
2006-01-11 22:25:46 +00:00
}
2014-09-17 03:04:08 +00:00
if ( i = = MAX_PRECACHE_SOUNDS )
2006-01-11 22:25:46 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( * str )
SV_Error ( " Too many sound precaches in loadgame cache " ) ;
}
2014-09-17 03:04:08 +00:00
for ( ; i < MAX_PRECACHE_SOUNDS ; i + + )
2016-01-18 05:22:07 +00:00
sv . strings . sound_precache [ i ] = NULL ;
2006-01-11 22:25:46 +00:00
}
2012-05-09 15:30:53 +00:00
/*ignoreplayers - says to not tell gamecode (a loadgame rather than a level change)*/
2016-01-18 05:22:07 +00:00
qboolean SV_LoadLevelCache ( const char * savename , const char * level , const char * startspot , qboolean isloadgame )
2004-08-23 00:15:46 +00:00
{
eval_t * eval , * e2 ;
char name [ MAX_OSPATH ] ;
2005-12-21 03:07:33 +00:00
vfsfile_t * f ;
2004-08-23 00:15:46 +00:00
char mapname [ MAX_QPATH ] ;
2005-12-21 03:07:33 +00:00
float time ;
2004-08-23 00:15:46 +00:00
char str [ 32768 ] ;
2015-11-18 07:37:39 +00:00
int i ;
size_t j ;
2004-08-23 00:15:46 +00:00
edict_t * ent ;
int version ;
int current_skill ;
int pt ;
2006-01-11 22:25:46 +00:00
int modelpos ;
2017-08-14 16:38:44 +00:00
qofs_t filelen , filepos ;
2004-08-23 00:15:46 +00:00
char * file ;
2005-03-18 06:13:11 +00:00
gametype_e gametype ;
2004-08-23 00:15:46 +00:00
levelcache_t * cache ;
2012-09-30 05:52:03 +00:00
int numstyles ;
2004-08-23 00:15:46 +00:00
2012-05-09 15:30:53 +00:00
if ( isloadgame )
2004-08-23 00:15:46 +00:00
{
2012-05-09 15:30:53 +00:00
gametype = svs . gametype ;
2004-08-23 00:15:46 +00:00
}
2012-05-09 15:30:53 +00:00
else
{
cache = svs . levcache ;
while ( cache )
{
if ( ! strcmp ( cache - > mapname , level ) )
break ;
2004-08-23 00:15:46 +00:00
2012-05-09 15:30:53 +00:00
cache = cache - > next ;
}
if ( ! cache )
return false ; //not visited yet. Ignore the existing caches as fakes.
gametype = cache - > gametype ;
}
2005-03-18 06:13:11 +00:00
2010-07-25 15:06:38 +00:00
if ( savename )
2016-07-12 00:40:13 +00:00
Q_snprintfz ( name , sizeof ( name ) , " saves/%s/%s.lvc " , savename , level ) ;
2010-07-25 15:06:38 +00:00
else
2016-07-12 00:40:13 +00:00
Q_snprintfz ( name , sizeof ( name ) , " saves/%s.lvc " , level ) ;
2004-08-23 00:15:46 +00:00
2013-11-29 14:36:47 +00:00
// Con_TPrintf ("Loading game from %s...\n", name);
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2005-03-18 06:13:11 +00:00
if ( gametype = = GT_QUAKE2 )
2004-08-23 00:15:46 +00:00
{
2017-08-14 16:38:44 +00:00
char * s ;
2013-12-08 20:06:55 +00:00
flocation_t loc ;
2020-04-19 01:23:32 +00:00
SV_SpawnServer ( level , startspot , false , false , 0 ) ;
2004-08-23 00:15:46 +00:00
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
World_ClearWorld ( & sv . world , false ) ;
2005-03-18 06:13:11 +00:00
if ( ! ge )
{
Con_Printf ( " Incorrect gamecode type. \n " ) ;
return false ;
}
2015-10-11 11:34:58 +00:00
if ( ! FS_FLocateFile ( name , FSLF_IFFOUND , & loc ) )
2013-12-08 20:06:55 +00:00
{
Con_Printf ( " Couldn't find %s. \n " , name ) ;
2009-04-01 22:03:56 +00:00
return false ;
2013-12-08 20:06:55 +00:00
}
if ( ! * loc . rawname | | loc . offset )
{
Con_Printf ( " %s is inside a package and cannot be used by the quake2 gamecode. \n " , name ) ;
return false ;
}
2017-08-14 16:38:44 +00:00
if ( savename )
Q_snprintfz ( name , sizeof ( name ) , " saves/%s/%s.lvx " , savename , level ) ;
else
Q_snprintfz ( name , sizeof ( name ) , " saves/%s.lvx " , level ) ;
file = FS_MallocFile ( name , FS_GAME , & filelen ) ;
if ( file )
{
s = file ;
//Read config strings
for ( i = 0 ; i < countof ( sv . strings . configstring ) & & s < file + filelen ; i + + )
{
Z_Free ( ( char * ) sv . strings . configstring [ i ] ) ;
sv . strings . configstring [ i ] = Z_StrDup ( s ) ;
s + = strlen ( s ) + 1 ;
}
for ( i = 0 ; s < file + filelen ; i + + )
{
if ( ! * s )
break ;
if ( i < countof ( sv . strings . q2_extramodels ) )
{
Z_Free ( ( char * ) sv . strings . q2_extramodels [ i ] ) ;
sv . strings . q2_extramodels [ i ] = Z_StrDup ( s ) ;
}
s + = strlen ( s ) + 1 ;
}
for ( ; i < countof ( sv . strings . q2_extramodels ) ; i + + )
{
Z_Free ( ( char * ) sv . strings . q2_extramodels [ i ] ) ;
sv . strings . q2_extramodels [ i ] = NULL ;
}
for ( i = 0 ; s < file + filelen ; i + + )
{
if ( ! * s )
break ;
if ( i < countof ( sv . strings . q2_extrasounds ) )
{
Z_Free ( ( char * ) sv . strings . q2_extrasounds [ i ] ) ;
sv . strings . q2_extrasounds [ i ] = Z_StrDup ( s ) ;
}
s + = strlen ( s ) + 1 ;
}
for ( ; i < countof ( sv . strings . q2_extrasounds ) ; i + + )
{
Z_Free ( ( char * ) sv . strings . q2_extrasounds [ i ] ) ;
sv . strings . q2_extrasounds [ i ] = NULL ;
}
//Read portal state
CM_ReadPortalState ( sv . world . worldmodel , s , ( file + filelen ) - s ) ;
FS_FreeFile ( file ) ;
}
2013-12-08 20:06:55 +00:00
ge - > ReadLevel ( loc . rawname ) ;
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < 100 ; i + + ) //run for 10 secs to iron out a few bugs.
ge - > RunFrame ( ) ;
return true ;
}
# endif
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
// been used. The menu calls it before stuffing loadgame command
// SCR_BeginLoadingPlaque ();
2006-01-11 22:25:46 +00:00
f = FS_OpenVFS ( name , " rb " , FS_GAME ) ;
2004-08-23 00:15:46 +00:00
if ( ! f )
{
2014-08-25 07:35:41 +00:00
if ( isloadgame )
Con_Printf ( " ERROR: Couldn't load \" %s \" \n " , name ) ;
2004-08-23 00:15:46 +00:00
return false ;
}
2005-12-21 03:07:33 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
version = atoi ( str ) ;
2018-08-23 06:03:31 +00:00
if ( version ! = CACHEGAME_VERSION_OLD & & version ! = CACHEGAME_VERSION_VERBOSE )
2004-08-23 00:15:46 +00:00
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( f ) ;
2018-08-23 06:03:31 +00:00
Con_TPrintf ( " Savegame is version %i, not %i \n " , version , CACHEGAME_VERSION_DEFAULT ) ;
2004-08-23 00:15:46 +00:00
return false ;
}
2005-12-21 03:07:33 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ; //comment
2004-08-23 00:15:46 +00:00
SV_SendMessagesToAll ( ) ;
2018-08-23 06:03:31 +00:00
if ( version = = CACHEGAME_VERSION_OLD )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
pt = atof ( str ) ;
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
// this silliness is so we can load 1.06 save files, which have float skill values
VFS_GETS ( f , str , sizeof ( str ) ) ;
current_skill = ( int ) ( atof ( str ) + 0.1 ) ;
Cvar_Set ( & skill , va ( " %i " , current_skill ) ) ;
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( & deathmatch , atof ( str ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( & coop , atof ( str ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( & teamplay , atof ( str ) ) ;
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
VFS_GETS ( f , mapname , sizeof ( mapname ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
time = atof ( str ) ;
}
else
{
time = 0 ;
pt = PROG_UNKNOWN ;
while ( VFS_GETS ( f , str , sizeof ( str ) ) )
{
char * s = str ;
cvar_t * var ;
s = COM_Parse ( s ) ;
if ( ! strcmp ( com_token , " map " ) )
{ //map "foo": terminates the preamble.
COM_ParseOut ( s , mapname , sizeof ( mapname ) ) ;
break ;
}
else if ( ! strcmp ( com_token , " cvar " ) )
{
s = COM_Parse ( s ) ;
var = Cvar_FindVar ( com_token ) ;
s = COM_Parse ( s ) ;
if ( var )
Cvar_Set ( var , com_token ) ;
}
else if ( ! strcmp ( com_token , " time " ) )
{
s = COM_Parse ( s ) ;
time = atof ( com_token ) ;
}
else if ( ! strcmp ( com_token , " vmmode " ) )
{
s = COM_Parse ( s ) ;
if ( ! strcmp ( com_token , " NONE " ) ) pt = PROG_NONE ;
else if ( ! strcmp ( com_token , " QW " ) ) pt = PROG_QW ;
else if ( ! strcmp ( com_token , " NQ " ) ) pt = PROG_NQ ;
else if ( ! strcmp ( com_token , " H2 " ) ) pt = PROG_H2 ;
else if ( ! strcmp ( com_token , " PREREL " ) ) pt = PROG_PREREL ;
else if ( ! strcmp ( com_token , " TENEBRAE " ) ) pt = PROG_TENEBRAE ;
else if ( ! strcmp ( com_token , " UNKNOWN " ) ) pt = PROG_UNKNOWN ;
else pt = PROG_UNKNOWN ;
}
else
Con_TPrintf ( " Unknown savegame directive %s \n " , com_token ) ;
}
}
2005-07-03 15:16:20 +00:00
2018-08-23 06:03:31 +00:00
//NOTE: This sets up the default baselines+statics+ambients.
//FIXME: if any model names changed, then we're screwed.
2020-04-19 01:23:32 +00:00
SV_SpawnServer ( mapname , startspot , false , false , svs . allocated_client_slots ) ;
2006-01-11 22:25:46 +00:00
sv . time = time ;
2005-03-18 06:13:11 +00:00
if ( svs . gametype ! = gametype )
{
Con_Printf ( " Incorrect gamecode type. Cannot load game. \n " ) ;
return false ;
}
2004-08-23 00:15:46 +00:00
if ( sv . state ! = ss_active )
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( f ) ;
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Couldn't load map \n " ) ;
2004-08-23 00:15:46 +00:00
return false ;
}
// load the edicts out of the savegame file
// the rest of the file is sent directly to the progs engine.
2012-01-24 04:24:14 +00:00
/*hexen2's gamecode doesn't have SAVE set on all variables, in which case we must clobber them, and run the risk that they were set at map load time, but clear in the savegame.*/
if ( progstype ! = PROG_H2 )
{
Q_SetProgsParms ( false ) ;
2018-09-23 19:35:24 +00:00
PR_Configure ( svprogfuncs , PR_ReadBytesString ( pr_ssqc_memsize . string ) , MAX_PROGS , pr_enable_profiling . ival ) ;
2012-01-24 04:24:14 +00:00
PR_RegisterFields ( ) ;
PR_InitEnts ( svprogfuncs , sv . world . max_edicts ) ;
}
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
if ( version = = CACHEGAME_VERSION_OLD )
2012-09-30 05:52:03 +00:00
{
2018-08-23 06:03:31 +00:00
// load the light styles
2012-09-30 05:52:03 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
2018-08-23 06:03:31 +00:00
numstyles = atoi ( str ) ;
2019-09-10 15:40:04 +00:00
if ( numstyles > MAX_NET_LIGHTSTYLES )
2018-08-23 06:03:31 +00:00
{
VFS_CLOSE ( f ) ;
Con_Printf ( " load failed - invalid number of lightstyles \n " ) ;
return false ;
}
2019-09-10 15:40:04 +00:00
for ( i = 0 ; i < sv . maxlightstyles ; i + + )
2018-08-23 06:03:31 +00:00
{
2019-09-10 15:40:04 +00:00
if ( sv . lightstyles [ i ] . str )
BZ_Free ( ( void * ) sv . lightstyles [ i ] . str ) ;
sv . lightstyles [ i ] . str = NULL ;
2018-08-23 06:03:31 +00:00
}
2019-09-10 15:40:04 +00:00
Z_ReallocElements ( ( void * * ) & sv . lightstyles , & sv . maxlightstyles , numstyles , sizeof ( * sv . lightstyles ) ) ;
2018-08-23 06:03:31 +00:00
for ( i = 0 ; i < numstyles ; i + + )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
2019-09-10 15:40:04 +00:00
sv . lightstyles [ i ] . str = Z_StrDup ( str ) ;
2018-08-23 06:03:31 +00:00
}
2019-09-10 15:40:04 +00:00
for ( ; i < sv . maxlightstyles ; i + + )
2018-08-23 06:03:31 +00:00
{
2019-09-10 15:40:04 +00:00
sv . lightstyles [ i ] . str = Z_StrDup ( " " ) ;
2018-08-23 06:03:31 +00:00
}
2012-07-07 05:17:43 +00:00
2018-08-23 06:03:31 +00:00
modelpos = VFS_TELL ( f ) ;
LoadModelsAndSounds ( f ) ;
}
else
modelpos = 0 ;
2005-08-26 22:56:51 +00:00
2005-12-21 03:07:33 +00:00
filepos = VFS_TELL ( f ) ;
filelen = VFS_GETLEN ( f ) ;
2004-08-23 00:15:46 +00:00
filelen - = filepos ;
file = BZ_Malloc ( filelen + 1 ) ;
memset ( file , 0 , filelen + 1 ) ;
2013-05-11 05:03:07 +00:00
VFS_READ ( f , file , filelen ) ;
2005-07-03 15:16:20 +00:00
file [ filelen ] = ' \0 ' ;
2018-09-01 04:18:08 +00:00
sv . world . edict_size = svprogfuncs - > load_ents ( svprogfuncs , file , NULL , NULL , SV_ExtendedSaveData ) ;
2004-08-23 00:15:46 +00:00
BZ_Free ( file ) ;
progstype = pt ;
2015-01-02 05:20:56 +00:00
PR_LoadGlabalStruct ( false ) ;
2004-08-23 00:15:46 +00:00
2009-11-04 21:16:50 +00:00
pr_global_struct - > time = sv . time = sv . world . physicstime = time ;
2006-01-11 22:25:46 +00:00
sv . starttime = Sys_DoubleTime ( ) - sv . time ;
2018-08-23 06:03:31 +00:00
if ( modelpos ! = 0 )
{
VFS_SEEK ( f , modelpos ) ;
LoadModelsAndSounds ( f ) ;
}
2004-08-23 00:15:46 +00:00
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
2006-01-11 22:25:46 +00:00
PF_InitTempStrings ( svprogfuncs ) ;
added r_meshpitch cvar that allows for fixing the unfixable mesh pitch bug from vanilla... needs a better name... do note that this will break pretty much any mod, so this is really only for TCs designed to use it. Its likely that I missed places.
nqsv: added support for spectators with nq clients. the angles are a bit rough, but hey. need to do something about frags so nq clients know who's a spectator. use 'cmd observe' to get an nq client to spectate on an fte server (then attack/jump behave the same as in qw clients).
nqsv: rewrote EF_MUZZLEFLASH handling, so svc_muzzleflash is now translated properly to EF_MUZZLEFLASH, and vice versa. No more missing muzzleflashes!
added screenshot_cubemap, so you can actually pre-generate cubemaps with fte (which can be used for reflections or whatever).
misc fixes (server crash, a couple of other less important ones).
external files based on a model's name will now obey r_replacemodels properly, instead of needing to use foo.mdl_0.skin for foo.md3.
identify <playernum> should now use the correct masked ip, instead of abrubtly failing (reported by kt)
vid_toggle console command should now obey vid_width and vid_height when switching to fullscreen, but only if vid_fullscreen is actually set, which should make it seem better behaved (reported by kt).
qcc: cleaned up sym->symboldata[sym->ofs] to be more consistent at all stages.
qcc: typedef float vec4[4]; now works to define a float array with 4 elements (however, it will be passed by-value rather than by-reference).
qcc: cleaned up optional vs __out ordering issues.
qccgui: shift+f3 searches backwards
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5064 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-02-27 09:34:35 +00:00
World_ClearWorld ( & sv . world , true ) ;
2004-08-23 00:15:46 +00:00
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
{
2012-05-09 15:30:53 +00:00
if ( i < sv . allocated_client_slots )
2018-04-06 17:21:15 +00:00
ent = EDICT_NUM_PB ( svprogfuncs , i + 1 ) ;
2012-05-09 15:30:53 +00:00
else
ent = NULL ;
2004-08-23 00:15:46 +00:00
svs . clients [ i ] . edict = ent ;
2016-07-12 00:40:13 +00:00
ent - > ereftype = ER_ENTITY ; //should have already been allocated.
2005-08-26 22:56:51 +00:00
2013-11-21 23:02:28 +00:00
svs . clients [ i ] . name = PR_AddString ( svprogfuncs , svs . clients [ i ] . namebuf , sizeof ( svs . clients [ i ] . namebuf ) , false ) ;
svs . clients [ i ] . team = PR_AddString ( svprogfuncs , svs . clients [ i ] . teambuf , sizeof ( svs . clients [ i ] . teambuf ) , false ) ;
2008-06-01 22:06:22 +00:00
2020-04-19 01:23:32 +00:00
//svs.clients[i].spawned = (svs.clients[i].state == cs_loadzombie);
2016-07-12 00:40:13 +00:00
# ifdef HEXEN2
2012-05-09 15:30:53 +00:00
if ( ent )
svs . clients [ i ] . playerclass = ent - > xv - > playerclass ;
else
svs . clients [ i ] . playerclass = 0 ;
2016-07-12 00:40:13 +00:00
# endif
2004-08-23 00:15:46 +00:00
}
2012-05-09 15:30:53 +00:00
if ( ! isloadgame )
2004-08-23 00:15:46 +00:00
{
2011-05-20 04:10:46 +00:00
eval = PR_FindGlobal ( svprogfuncs , " startspot " , 0 , NULL ) ;
2015-01-21 18:18:37 +00:00
if ( eval ) eval - > _int = ( int ) PR_NewString ( svprogfuncs , startspot ) ;
2004-08-23 00:15:46 +00:00
2011-05-20 04:10:46 +00:00
eval = PR_FindGlobal ( svprogfuncs , " ClientReEnter " , 0 , NULL ) ;
2004-08-23 00:15:46 +00:00
if ( eval )
2013-10-29 17:38:22 +00:00
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
{
2005-07-03 15:16:20 +00:00
if ( svs . clients [ i ] . spawninfo )
2004-08-23 00:15:46 +00:00
{
globalvars_t * pr_globals = PR_globals ( svprogfuncs , PR_CURRENT ) ;
ent = svs . clients [ i ] . edict ;
j = strlen ( svs . clients [ i ] . spawninfo ) ;
svprogfuncs - > restoreent ( svprogfuncs , svs . clients [ i ] . spawninfo , & j , ent ) ;
2016-07-12 00:40:13 +00:00
e2 = svprogfuncs - > GetEdictFieldValue ( svprogfuncs , ent , " stats_restored " , ev_float , NULL ) ;
2004-08-23 00:15:46 +00:00
if ( e2 )
e2 - > _float = 1 ;
2017-05-28 15:42:32 +00:00
SV_SpawnParmsToQC ( host_client ) ;
2009-11-04 21:16:50 +00:00
pr_global_struct - > time = sv . world . physicstime ;
2004-08-23 00:15:46 +00:00
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , ent ) ;
2017-08-29 02:29:06 +00:00
World_UnlinkEdict ( ( wedict_t * ) ent ) ;
2004-08-23 00:15:46 +00:00
G_FLOAT ( OFS_PARM0 ) = sv . time - host_client - > spawninfotime ;
PR_ExecuteProgram ( svprogfuncs , eval - > function ) ;
2016-07-12 00:40:13 +00:00
// if (svs.clients[i].state == cs_loadzombie)
// svs.clients[i].istobeloaded = 1;
// else
// svs.clients[i].state = cs_spawned; //don't do a separate ClientConnect.
2004-08-23 00:15:46 +00:00
}
}
2016-07-12 00:40:13 +00:00
pr_global_struct - > serverflags = svs . serverflags ;
2004-08-23 00:15:46 +00:00
}
2016-07-12 00:40:13 +00:00
pr_global_struct - > time = sv . world . physicstime ;
2004-08-23 00:15:46 +00:00
2012-01-17 07:57:46 +00:00
for ( i = 0 ; i < sv . world . num_edicts ; i + + )
{
2018-04-06 17:21:15 +00:00
ent = EDICT_NUM_PB ( svprogfuncs , i ) ;
2016-07-21 19:27:59 +00:00
if ( ED_ISFREE ( ent ) )
2012-01-17 07:57:46 +00:00
continue ;
/*hexen2 instead overwrites ents, which can theoretically be unreliable (ents with this flag are not saved in the first place, and thus are effectively reset instead of reloaded).
fte purges all ents beforehand in a desperate attempt to remain sane .
this behaviour does not match exactly , but is enough for vanilla hexen2 / POP .
*/
if ( ( unsigned int ) ent - > v - > flags & FL_HUBSAVERESET )
{
func_t f ;
/*set some minimal fields*/
ent - > v - > solid = SOLID_NOT ;
ent - > v - > use = 0 ;
ent - > v - > touch = 0 ;
ent - > v - > think = 0 ;
ent - > v - > nextthink = 0 ;
/*reinvoke the spawn function*/
pr_global_struct - > time = 0.1 ;
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , ent ) ;
f = PR_FindFunction ( svprogfuncs , PR_GetString ( svprogfuncs , ent - > v - > classname ) , PR_ANY ) ;
if ( f )
PR_ExecuteProgram ( svprogfuncs , f ) ;
}
}
2004-08-23 00:15:46 +00:00
return true ; //yay
}
2016-01-18 05:22:07 +00:00
void SV_SaveLevelCache ( const char * savedir , qboolean dontharmgame )
2004-08-23 00:15:46 +00:00
{
2015-11-18 07:37:39 +00:00
size_t len ;
2004-08-23 00:15:46 +00:00
char * s ;
client_t * cl ;
int clnum ;
char name [ 256 ] ;
2009-04-01 22:03:56 +00:00
vfsfile_t * f ;
2004-08-23 00:15:46 +00:00
int i ;
char comment [ SAVEGAME_COMMENT_LENGTH + 1 ] ;
levelcache_t * cache ;
2018-08-23 06:03:31 +00:00
int version = CACHEGAME_VERSION_DEFAULT ;
2012-02-12 05:18:31 +00:00
2004-08-23 00:15:46 +00:00
if ( ! sv . state )
return ;
2012-02-12 05:18:31 +00:00
if ( ! dontharmgame )
2004-08-23 00:15:46 +00:00
{
2012-02-12 05:18:31 +00:00
cache = svs . levcache ;
while ( cache )
{
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( ! strcmp ( cache - > mapname , svs . name ) )
2012-02-12 05:18:31 +00:00
break ;
2004-08-23 00:15:46 +00:00
2012-02-12 05:18:31 +00:00
cache = cache - > next ;
}
if ( ! cache ) //not visited yet. Let us know that we went there.
{
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
cache = Z_Malloc ( sizeof ( levelcache_t ) + strlen ( svs . name ) + 1 ) ;
2012-02-12 05:18:31 +00:00
cache - > mapname = ( char * ) ( cache + 1 ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
strcpy ( cache - > mapname , svs . name ) ;
2004-08-23 00:15:46 +00:00
2012-02-12 05:18:31 +00:00
cache - > gametype = svs . gametype ;
cache - > next = svs . levcache ;
svs . levcache = cache ;
}
2004-08-23 00:15:46 +00:00
}
2010-07-25 15:06:38 +00:00
if ( savedir )
2016-01-18 05:22:07 +00:00
Q_snprintfz ( name , sizeof ( name ) , " saves/%s/%s.lvc " , savedir , svs . name ) ;
2010-07-25 15:06:38 +00:00
else
2016-01-18 05:22:07 +00:00
Q_snprintfz ( name , sizeof ( name ) , " saves/%s.lvc " , svs . name ) ;
2004-08-23 00:15:46 +00:00
2009-04-01 22:03:56 +00:00
FS_CreatePath ( name , FS_GAMEONLY ) ;
2005-05-13 10:42:48 +00:00
2004-08-23 00:15:46 +00:00
if ( ! dontharmgame ) //save game in progress
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Saving game to %s... \n " , name ) ;
2004-08-23 00:15:46 +00:00
# ifdef Q2SERVER
2005-03-18 06:13:11 +00:00
if ( ge )
2004-08-23 00:15:46 +00:00
{
2009-04-01 22:03:56 +00:00
char syspath [ 256 ] ;
if ( ! FS_NativePath ( name , FS_GAMEONLY , syspath , sizeof ( syspath ) ) )
return ;
ge - > WriteLevel ( syspath ) ;
2017-08-14 16:38:44 +00:00
if ( savedir )
Q_snprintfz ( name , sizeof ( name ) , " saves/%s/%s.lvx " , savedir , svs . name ) ;
else
Q_snprintfz ( name , sizeof ( name ) , " saves/%s.lvx " , svs . name ) ;
//write configstrings
f = FS_OpenVFS ( name , " wbp " , FS_GAMEONLY ) ;
if ( f )
{
2018-06-06 09:09:14 +00:00
size_t portalblobsize ;
void * portalblob = NULL ;
2017-08-14 16:38:44 +00:00
for ( i = 0 ; i < countof ( sv . strings . configstring ) ; i + + )
{
if ( sv . strings . configstring [ i ] )
VFS_WRITE ( f , sv . strings . configstring [ i ] , strlen ( sv . strings . configstring [ i ] ) + 1 ) ;
else
VFS_WRITE ( f , " " , 1 ) ;
}
for ( i = 0 ; i < countof ( sv . strings . q2_extramodels ) ; i + + )
{
if ( ! sv . strings . q2_extramodels [ i ] )
break ;
VFS_WRITE ( f , sv . strings . q2_extramodels [ i ] , strlen ( sv . strings . q2_extramodels [ i ] ) + 1 ) ;
}
VFS_WRITE ( f , " " , 1 ) ;
for ( i = 0 ; i < countof ( sv . strings . q2_extrasounds ) ; i + + )
{
if ( ! sv . strings . q2_extrasounds [ i ] )
break ;
VFS_WRITE ( f , sv . strings . q2_extrasounds [ i ] , strlen ( sv . strings . q2_extrasounds [ i ] ) + 1 ) ;
}
VFS_WRITE ( f , " " , 1 ) ;
2018-06-06 09:09:14 +00:00
portalblobsize = CM_WritePortalState ( sv . world . worldmodel , & portalblob ) ;
VFS_WRITE ( f , portalblob , portalblobsize ) ;
2017-08-14 16:38:44 +00:00
VFS_CLOSE ( f ) ;
}
2017-02-19 00:15:42 +00:00
FS_FlushFSHashFull ( ) ;
2004-08-23 00:15:46 +00:00
return ;
}
# endif
2009-03-03 01:52:30 +00:00
# ifdef HLSERVER
if ( svs . gametype = = GT_HALFLIFE )
{
SVHL_SaveLevelCache ( name ) ;
2017-02-19 00:15:42 +00:00
FS_FlushFSHashFull ( ) ;
2009-03-03 01:52:30 +00:00
return ;
}
# endif
2014-08-27 08:41:31 +00:00
f = FS_OpenVFS ( name , " wbp " , FS_GAMEONLY ) ;
2004-08-23 00:15:46 +00:00
if ( ! f )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " ERROR: couldn't open %s. \n " , name ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2015-01-08 13:09:20 +00:00
VFS_PRINTF ( f , " %i \n " , version ) ;
2015-01-21 18:18:37 +00:00
SV_SavegameComment ( comment , sizeof ( comment ) ) ;
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %s \n " , comment ) ;
2015-01-08 13:09:20 +00:00
2012-01-24 04:24:14 +00:00
if ( ! dontharmgame )
2004-08-23 00:15:46 +00:00
{
2015-01-08 13:09:20 +00:00
//map-change caches require the players to have been de-spawned
//saved games require players to retain their fields.
//probably this should happen elsewhere.
2012-02-12 05:18:31 +00:00
for ( cl = svs . clients , clnum = 0 ; clnum < sv . allocated_client_slots ; cl + + , clnum + + ) //fake dropping
2004-08-23 00:15:46 +00:00
{
2016-07-12 00:40:13 +00:00
if ( cl - > state < cs_connected )
continue ;
else if ( progstype = = PROG_H2 )
cl - > edict - > ereftype = ER_FREE ; //hexen2 has some annoying prints. it never formally dropped clients on map changes (we'll reset this later, so they'll just not appear in the saved game).
2017-08-14 16:38:44 +00:00
else if ( ! cl - > spawned ) //don't drop if they are still connecting
2012-01-24 04:24:14 +00:00
cl - > edict - > v - > solid = 0 ;
2020-04-19 01:23:32 +00:00
else
SV_DespawnClient ( cl ) ;
2004-08-23 00:15:46 +00:00
}
}
2018-05-21 13:47:53 +00:00
if ( version > = CACHEGAME_VERSION_VERBOSE )
2004-08-23 00:15:46 +00:00
{
2015-01-08 13:09:20 +00:00
char buf [ 8192 ] ;
char * mode = " ? " ;
switch ( progstype )
{
case PROG_NONE : break ;
case PROG_QW : mode = " QW " ; break ;
case PROG_NQ : mode = " NQ " ; break ;
case PROG_H2 : mode = " H2 " ; break ;
case PROG_PREREL : mode = " PREREL " ; break ;
2015-08-22 02:59:01 +00:00
case PROG_TENEBRAE : mode = " TENEBRAE " ; break ;
2015-01-08 13:09:20 +00:00
case PROG_UNKNOWN : mode = " UNKNOWN " ; break ;
}
2018-08-23 06:03:31 +00:00
VFS_PRINTF ( f , " vmmode %s \n " , COM_QuotedString ( mode , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " cvar skill %s \n " , COM_QuotedString ( skill . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " cvar deathmatch %s \n " , COM_QuotedString ( deathmatch . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " cvar coop %s \n " , COM_QuotedString ( coop . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " cvar teamplay %s \n " , COM_QuotedString ( teamplay . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " time %f \n " , sv . time ) ;
VFS_PRINTF ( f , " map %s \n " , COM_QuotedString ( svs . name , buf , sizeof ( buf ) , false ) ) ;
2005-08-26 22:56:51 +00:00
}
2015-01-08 13:09:20 +00:00
else
2005-08-26 22:56:51 +00:00
{
2015-01-08 13:09:20 +00:00
VFS_PRINTF ( f , " %d \n " , progstype ) ;
VFS_PRINTF ( f , " %f \n " , skill . value ) ;
VFS_PRINTF ( f , " %f \n " , deathmatch . value ) ;
VFS_PRINTF ( f , " %f \n " , coop . value ) ;
VFS_PRINTF ( f , " %f \n " , teamplay . value ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
VFS_PRINTF ( f , " %s \n " , svs . name ) ;
VFS_PRINTF ( f , " %f \n " , sv . time ) ;
2015-01-08 13:09:20 +00:00
// write the light styles
2019-09-10 15:40:04 +00:00
VFS_PRINTF ( f , " %u \n " , ( unsigned ) sv . maxlightstyles ) ;
for ( i = 0 ; i < sv . maxlightstyles ; i + + )
2015-01-08 13:09:20 +00:00
{
2019-09-10 15:40:04 +00:00
VFS_PRINTF ( f , " %s \n " , sv . lightstyles [ i ] . str ? sv . lightstyles [ i ] . str : " " ) ;
2015-01-08 13:09:20 +00:00
}
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
{
if ( sv . strings . model_precache [ i ] & & * sv . strings . model_precache [ i ] )
VFS_PRINTF ( f , " %s \n " , sv . strings . model_precache [ i ] ) ;
else
break ;
}
VFS_PRINTF ( f , " \n " ) ;
for ( i = 1 ; i < MAX_PRECACHE_SOUNDS ; i + + )
{
2016-01-18 05:22:07 +00:00
if ( sv . strings . sound_precache [ i ] & & * sv . strings . sound_precache [ i ] )
2015-01-08 13:09:20 +00:00
VFS_PRINTF ( f , " %s \n " , sv . strings . sound_precache [ i ] ) ;
else
break ;
}
VFS_PRINTF ( f , " \n " ) ;
2005-08-26 22:56:51 +00:00
}
2018-05-21 13:47:53 +00:00
if ( version > = CACHEGAME_VERSION_BINARY )
{
VFS_PUTS ( f , va ( " %i \n " , svprogfuncs - > stringtablesize ) ) ;
VFS_WRITE ( f , svprogfuncs - > stringtable , svprogfuncs - > stringtablesize ) ;
}
else
{
s = PR_SaveEnts ( svprogfuncs , NULL , & len , 0 , 1 ) ;
VFS_PUTS ( f , s ) ;
VFS_PUTS ( f , " \n " ) ;
svprogfuncs - > parms - > memfree ( s ) ;
}
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
if ( version > = CACHEGAME_VERSION_VERBOSE )
{
char buf [ 8192 ] ;
2019-09-10 15:40:04 +00:00
for ( i = 0 ; i < sv . maxlightstyles ; i + + )
if ( sv . lightstyles [ i ] . str )
VFS_PRINTF ( f , " lightstyle %i %s %f %f %f \n " , i , COM_QuotedString ( sv . lightstyles [ i ] . str , buf , sizeof ( buf ) , false ) , sv . lightstyles [ i ] . colours [ 0 ] , sv . lightstyles [ i ] . colours [ 1 ] , sv . lightstyles [ i ] . colours [ 2 ] ) ;
2018-08-23 06:03:31 +00:00
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
if ( sv . strings . model_precache [ i ] & & * sv . strings . model_precache [ i ] )
VFS_PRINTF ( f , " model %i %s \n " , i , COM_QuotedString ( sv . strings . model_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
for ( i = 1 ; i < MAX_PRECACHE_SOUNDS ; i + + )
if ( sv . strings . sound_precache [ i ] & & * sv . strings . sound_precache [ i ] )
VFS_PRINTF ( f , " sound %i %s \n " , i , COM_QuotedString ( sv . strings . sound_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
for ( i = 1 ; i < MAX_SSPARTICLESPRE ; i + + )
if ( sv . strings . particle_precache [ i ] & & * sv . strings . particle_precache [ i ] )
VFS_PRINTF ( f , " particle %i %s \n " , i , COM_QuotedString ( sv . strings . particle_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
2019-04-16 22:40:05 +00:00
# ifdef HAVE_LEGACY
2018-08-23 06:03:31 +00:00
for ( i = 0 ; i < sizeof ( sv . strings . vw_model_precache ) / sizeof ( sv . strings . vw_model_precache [ 0 ] ) ; i + + )
if ( sv . strings . vw_model_precache [ i ] )
VFS_PRINTF ( f , " vwep %i %s \n " , i , COM_QuotedString ( sv . strings . vw_model_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
2018-09-01 04:18:08 +00:00
# endif
2018-08-23 06:03:31 +00:00
PR_Common_SaveGame ( f , svprogfuncs , version > = CACHEGAME_VERSION_BINARY ) ;
//FIXME: string buffers
//FIXME: hash tables
//FIXME: skeletal objects?
//FIXME: static entities
//FIXME: midi track
//FIXME: custom temp-ents?
//FIXME: pending uri_gets? (if only just to report fails on load)
//FIXME: routing calls?
//FIXME: sql queries?
//FIXME: frik files?
//FIXME: qc threads?
// portalblobsize = CM_WritePortalState(sv.world.worldmodel, &portalblob);
// VFS_WRITE(f, portalblob, portalblobsize);
}
2009-04-01 22:03:56 +00:00
VFS_CLOSE ( f ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( ! dontharmgame )
{
2016-07-12 00:40:13 +00:00
for ( clnum = 0 ; clnum < sv . allocated_client_slots ; clnum + + )
{
2018-04-06 17:21:15 +00:00
edict_t * ed = EDICT_NUM_PB ( svprogfuncs , clnum + 1 ) ;
2016-07-12 00:40:13 +00:00
ed - > ereftype = ER_ENTITY ;
}
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
}
2017-02-19 00:15:42 +00:00
2018-05-21 13:47:53 +00:00
FS_FlushFSHashWritten ( name ) ;
2004-08-23 00:15:46 +00:00
}
2018-05-21 13:47:53 +00:00
//mapchange is true for Q2's map-change autosaves.
2016-01-18 05:22:07 +00:00
void SV_Savegame ( const char * savename , qboolean mapchange )
2004-08-23 00:15:46 +00:00
{
client_t * cl ;
int clnum ;
2015-01-21 18:18:37 +00:00
char comment [ ( SAVEGAME_COMMENT_LENGTH + 1 ) * 2 ] ;
2009-04-01 22:03:56 +00:00
vfsfile_t * f ;
2004-08-23 00:15:46 +00:00
int len ;
levelcache_t * cache ;
2009-08-29 15:09:35 +00:00
char * savefilename ;
2004-08-23 00:15:46 +00:00
2016-01-18 05:22:07 +00:00
if ( ! sv . state | | sv . state = = ss_clustermode )
2004-08-23 00:15:46 +00:00
{
Con_Printf ( " Server is not active - unable to save \n " ) ;
return ;
}
2016-01-18 05:22:07 +00:00
if ( sv . state = = ss_cinematic )
{
Con_Printf ( " Server is playing a cinematic - unable to save \n " ) ;
return ;
}
2004-08-23 00:15:46 +00:00
2018-08-23 06:03:31 +00:00
# ifndef QUAKETC
{
int savefmt = sv_savefmt . ival ;
2018-12-04 08:57:29 +00:00
if ( ! * sv_savefmt . string & & ( svs . gametype ! = GT_PROGS | | progstype = = PROG_H2 | | svs . levcache | | ( progstype = = PROG_QW & & strcmp ( pr_ssqc_progs . string , " spprogs " ) ) ) )
2018-08-23 06:03:31 +00:00
savefmt = 1 ; //hexen2+q2/etc must not use the legacy format by default. can't use it when using any kind of hub system either (harder to detect upfront, which might give confused saved game naming but will at least work).
else
savefmt = sv_savefmt . ival ;
if ( ! savefmt & & ! mapchange )
{
2018-12-04 08:57:29 +00:00
if ( SV_LegacySavegame ( savename , * sv_savefmt . string ) )
2018-08-23 06:03:31 +00:00
return ;
2018-12-04 08:57:29 +00:00
if ( * sv_savefmt . string )
Con_Printf ( " Unable to use legacy saved game format \n " ) ;
2018-08-23 06:03:31 +00:00
}
}
# endif
2018-04-06 17:21:15 +00:00
switch ( svs . gametype )
{
default :
case GT_Q1QVM :
# ifdef VM_LUA
case GT_LUA :
# endif
Con_Printf ( " gamecode doesn't support saving \n " ) ;
return ;
case GT_PROGS :
case GT_QUAKE2 :
break ;
}
2013-03-12 22:58:13 +00:00
if ( sv . allocated_client_slots = = 1 & & svs . gametype = = GT_PROGS )
{
if ( svs . clients - > state > cs_connected & & svs . clients [ 0 ] . edict - > v - > health < = 0 )
{
Con_Printf ( " Refusing to save while dead. \n " ) ;
return ;
}
}
//FIXME: we should probably block saving during intermission too.
2011-06-29 18:39:11 +00:00
/*catch invalid names*/
2004-08-23 00:15:46 +00:00
if ( ! * savename | | strstr ( savename , " .. " ) )
2016-01-18 05:22:07 +00:00
savename = " quick " ;
2004-08-23 00:15:46 +00:00
2009-08-29 15:09:35 +00:00
savefilename = va ( " saves/%s/info.fsv " , savename ) ;
FS_CreatePath ( savefilename , FS_GAMEONLY ) ;
2018-05-21 13:47:53 +00:00
f = FS_OpenVFS ( savefilename , " wbp " , FS_GAMEONLY ) ;
2004-08-23 00:15:46 +00:00
if ( ! f )
{
2009-04-01 22:03:56 +00:00
Con_Printf ( " Couldn't open file saves/%s/info.fsv \n " , savename ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2015-01-21 18:18:37 +00:00
SV_SavegameComment ( comment , sizeof ( comment ) ) ;
2018-08-23 06:03:31 +00:00
VFS_PRINTF ( f , " %d \n " , SAVEGAME_VERSION_FTE_HUB + svs . gametype ) ;
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %s \n " , comment ) ;
2004-08-23 00:15:46 +00:00
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %i \n " , sv . allocated_client_slots ) ;
2004-08-23 00:15:46 +00:00
for ( cl = svs . clients , clnum = 0 ; clnum < sv . allocated_client_slots ; cl + + , clnum + + )
{
2016-01-18 05:22:07 +00:00
//FIXME: the qc is only told about the new client when the client finally sends a begin.
// this means that if we save a client that is still connecting, the loading code HAS to assume that the qc already knows about the player.
// this means that such players would not be loaded properly anyway, and would bug out the server.
// so its best to not bother saving them at all. pro-top: don't save shortly after a map change in coop/sp.
//istobeloaded means that the qc has already been told about the client from a previous saved game, regardless of the fact that they're still technically connecting (this may even be a zombie with no actual client connection).
//note that autosave implies that we're saving on a map boundary. this is for q2 gamecode. q1 can't cope.
2004-08-23 00:15:46 +00:00
if ( cl - > state < cs_spawned & & ! cl - > istobeloaded ) //don't save if they are still connecting
{
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " \n " ) ;
2004-08-23 00:15:46 +00:00
continue ;
}
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %s \n " , cl - > name ) ;
2004-08-23 00:15:46 +00:00
if ( * cl - > name )
2018-08-23 06:03:31 +00:00
{
2020-04-19 01:23:32 +00:00
char tmp [ 65536 ] ;
VFS_PRINTF ( f , " { \n " ) ;
for ( len = 0 ; len < NUM_SPAWN_PARMS ; len + + )
VFS_PRINTF ( f , " \t parm%i 0x%x //%.9g \n " , len , * ( int * ) & cl - > spawn_parms [ len ] , cl - > spawn_parms [ len ] ) ; //write hex as not everyone passes a float in the parms.
VFS_PRINTF ( f , " \t parm_string %s \n " , COM_QuotedString ( cl - > spawn_parmstring ? cl - > spawn_parmstring : " " , tmp , sizeof ( tmp ) , false ) ) ;
/*if (cl->spawninfo)
2018-08-23 06:03:31 +00:00
{
2020-04-19 01:23:32 +00:00
VFS_PRINTF ( f , " \t spawninfo %s \n " , COM_QuotedString ( cl - > spawninfo , tmp , sizeof ( tmp ) , false ) ) ;
VFS_PRINTF ( f , " \t spawninfotime %9g \n " , cl - > spawninfotime ) ;
} */
VFS_PRINTF ( f , " } \n " ) ; //write ints as not everyone passes a float in the parms.
2018-08-23 06:03:31 +00:00
}
2004-08-23 00:15:46 +00:00
}
2018-07-05 16:21:44 +00:00
InfoBuf_WriteToFile ( f , & svs . info , NULL , 0 ) ;
VFS_PUTS ( f , " \n " ) ;
InfoBuf_WriteToFile ( f , & svs . localinfo , NULL , 0 ) ;
2009-04-01 22:03:56 +00:00
2013-08-27 13:18:09 +00:00
VFS_PRINTF ( f , " \n { \n " ) ; //all game vars. FIXME: Should save the ones that have been retrieved/set by progs.
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " skill \" %s \" \n " , skill . string ) ;
VFS_PRINTF ( f , " deathmatch \" %s \" \n " , deathmatch . string ) ;
VFS_PRINTF ( f , " coop \" %s \" \n " , coop . string ) ;
VFS_PRINTF ( f , " teamplay \" %s \" \n " , teamplay . string ) ;
VFS_PRINTF ( f , " nomonsters \" %s \" \n " , nomonsters . string ) ;
VFS_PRINTF ( f , " gamecfg \t \" %s \" \n " , gamecfg . string ) ;
VFS_PRINTF ( f , " scratch1 \" %s \" \n " , scratch1 . string ) ;
VFS_PRINTF ( f , " scratch2 \" %s \" \n " , scratch2 . string ) ;
VFS_PRINTF ( f , " scratch3 \" %s \" \n " , scratch3 . string ) ;
VFS_PRINTF ( f , " scratch4 \" %s \" \n " , scratch4 . string ) ;
VFS_PRINTF ( f , " savedgamecfg \t \" %s \" \n " , savedgamecfg . string ) ;
VFS_PRINTF ( f , " saved1 \" %s \" \n " , saved1 . string ) ;
VFS_PRINTF ( f , " saved2 \" %s \" \n " , saved2 . string ) ;
VFS_PRINTF ( f , " saved3 \" %s \" \n " , saved3 . string ) ;
VFS_PRINTF ( f , " saved4 \" %s \" \n " , saved4 . string ) ;
VFS_PRINTF ( f , " temp1 \" %s \" \n " , temp1 . string ) ;
VFS_PRINTF ( f , " noexit \" %s \" \n " , noexit . string ) ;
VFS_PRINTF ( f , " pr_maxedicts \t \" %s \" \n " , pr_maxedicts . string ) ;
2011-10-27 16:16:29 +00:00
VFS_PRINTF ( f , " progs \" %s \" \n " , pr_ssqc_progs . string ) ;
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " set nextserver \" %s \" \n " , Cvar_Get ( " nextserver " , " " , 0 , " " ) - > string ) ;
VFS_PRINTF ( f , " } \n " ) ;
2004-08-23 00:15:46 +00:00
2010-08-17 20:40:27 +00:00
SV_SaveLevelCache ( savename , true ) ; //add the current level.
2004-08-23 00:15:46 +00:00
cache = svs . levcache ; //state from previous levels - just copy it all accross.
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " { \n " ) ;
2004-08-23 00:15:46 +00:00
while ( cache )
{
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %s \n " , cache - > mapname ) ;
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
if ( strcmp ( cache - > mapname , svs . name ) )
2010-07-25 15:06:38 +00:00
{
FS_Copy ( va ( " saves/%s.lvc " , cache - > mapname ) , va ( " saves/%s/%s.lvc " , savename , cache - > mapname ) , FS_GAME , FS_GAME ) ;
}
2004-08-23 00:15:46 +00:00
cache = cache - > next ;
}
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " } \n " ) ;
2004-08-23 00:15:46 +00:00
Reworked client support for DPP5+. less code now, its much more graceful.
added waterfog command. waterfog overrides regular fog only when the view is in water.
fixed 64bit printf format specifiers. should work better on winxp64.
fixed some spec angle weirdness.
fixed viewsize 99.99 weirdness with ezhud.
fixed extra offset on the console (exhibited in 64bit builds, but not limited to).
fixed .avi playback, can now actually display frames again.
reimplemented line sparks.
fixed r_editlights_save flipping the light's pitch.
fixed issue with oggs failing to load.
fixed condump to cope with unicode properly.
made sv_bigcoords default except in quake. hexen2 kinda needs it for bsp angle precision.
fixed nq server to not stall weirdly on map changes.
fixed qwprogs svc_cdtrack not bugging out with nq clients on the server.
fixed restart command to load the last map run by the server, instead of start.bsp (when idle)
optimised d3d9 renderer a little. now uses less draw calls, especially with complex scenes. seems to get higher framerates than opengl now.
fixed d3d9 renderer to not bug out quite so much when run fullscreen (shader subsystem is now correctly initialised).
fixed a couple of bugs from font change. also now supports utf-8 in a few more places.
r_editlights_reload no longer generates rtlights inside the void. this resolves a few glitches (but should also help framerates a little).
fixed so corona-only lights won't generate shadowmaps and waste lots of time.
removed lots of #defines from qclib. I should never have made them in the first place, but I was lazy. obviously there's more left that I cba to remove yet.
fixed nested calls with variant-vectors. this fixes csaddon's light editor.
fixed qcc hc calling conventions using redundant stores.
disabled keywords can still be used by using __keyword instead.
fixed ftegccgui grep feature.
fixed motionless-dog qcc bug.
tweaked qcc warnings a little. -Wall is now a viable setting. you should be able to fix all those warnings.
fixed qw svc_intermission + dpp5+ clients bug.
fixed annoying spam about disconnecting in hexen2.
rewrote status command a little to cope with ipv6 addresses more gracefully
fixed significant stall when hibernating/debugging a server with a player sitting on it.
fixed truelightning.
fixed rocketlight overriding pflags.
fixed torches vanishing on vid_restart.
fixed issue with decal scaling.
fixed findentityfield builtin.
fixed fteqcc issue with ptr+1
fixed use of arrays inside class functions.
fixed/implemented fteqcc emulation of pointer opcodes.
added __inout keyword to fteqcc, so that it doesn't feel so horrendous.
fixed sizeof(*foo)
fixed *struct = struct;
fixed recursive structs.
fixed fteqcc warning report.
fixed sdl2 controller support, hopefully.
attempted to implement xinput, including per-player audio playback.
slightly fixed relaxed attitude to mouse focus when running fullscreen.
fixed weird warnings/errors with 'ent.arrayhead' terms. now generates sane errors.
implemented bindmaps (for csqc).
fixed crashing bug with eprint builtin.
implemented subset of music_playlist_* functionality. significant changes to music playback.
fixed some more dpcsqc compat.
fixed binds menu. now displays and accepts modifiers.
fixed issues with huge lightmaps.
fixed protocol determinism with dp clients connecting to fte servers. the initial getchallenge request now inhibits vanilla nq connection requests.
implemented support for 'dupe' userinfo key, allowing clients to request client->server packet duplication. should probably queue them tbh.
implemented sv_saveentfile command.
fixed resume after breaking inside a stepped-over function.
fixed erroneous footer after debugging.
(I wonder just how many things I broke with these fixes)
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4946 fc73d0e0-1445-4013-8a0c-d673dee63da5
2015-07-26 10:56:18 +00:00
VFS_PRINTF ( f , " %s \n " , svs . name ) ;
2004-08-23 00:15:46 +00:00
2014-08-16 05:33:50 +00:00
VFS_PRINTF ( f , " %g \n " , ( float ) svs . serverflags ) ;
2009-04-01 22:03:56 +00:00
VFS_CLOSE ( f ) ;
2013-12-08 20:06:55 +00:00
2019-09-25 20:23:24 +00:00
# ifdef HAVE_CLIENT
2015-01-21 18:18:37 +00:00
//try to save screenshots automagically.
2016-01-18 05:22:07 +00:00
Q_snprintfz ( comment , sizeof ( comment ) , " saves/%s/screeny.%s " , savename , " tga " ) ; //scr_sshot_type.string);
savefilename = comment ;
2015-01-21 18:18:37 +00:00
FS_Remove ( savefilename , FS_GAMEONLY ) ;
2016-07-12 00:40:13 +00:00
if ( cls . state = = ca_active & & qrenderer > QR_NONE & & qrenderer ! = QR_VULKAN /*FIXME*/ )
2015-01-21 18:18:37 +00:00
{
playdemo accepts https urls now. will start playing before the file has finished downloading, to avoid unnecessary delays.
reworked network addresses to separate address family and connection type. this should make banning people more reliable, as well as simplifying a whole load of logic (no need to check for ipv4 AND ipv6).
tcpconnect will keep trying to connect even if the connection wasn't instant, instead of giving up instantly.
rewrote tcp connections quite a bit. sv_port_tcp now handles qtv+qizmo+http+ws+rtcbroker+tls equivalents.
qtv_streamport is now a legacy cvar and now acts equivalently to sv_port_tcp (but still separate).
rewrote screenshot and video capture code to use strides. this solves image-is-upside down issues with vulkan.
ignore alt key in browser port. oh no! no more red text! oh no! no more alt-being-wrongly-down-and-being-unable-to-type-anything-without-forcing-alt-released!
reworked audio decoder interface. now has clearly defined success/unavailable/end-of-file results. this should solve a whole load of issues with audio streaming.
fixed various openal audio streaming issues too. openal also got some workarounds for emscripten's poor emulation.
fixed ogg decoder to retain sync properly if seeked.
updated menu_media a bit. now reads vorbis comments/id3v1 tags to get proper track names. also saves the playlist so you don't have to manually repopulate the list so it might actually be usable now (after how many years?)
r_stains now defaults to 0, and is no longer enabled by presets. use decals if you want that sort of thing.
added fs_noreexec cvar, so configs will not be reexeced on gamedir change. this also means defaults won't be reapplied, etc.
added 'nvvk' renderer on windows, using nvidia's vulkan-inside-opengl gl extension. mostly just to see how much slower it is.
fixed up the ftp server quite a lot. more complete, more compliant, and should do ipv6 properly to-boot. file transfers also threaded.
fixed potential crash inside runclientphys.
experimental sv_antilag=3 setting. totally untested. the aim is to avoid missing due to lagged knockbacks. may be expensive for the server.
browser port's websockets support fixed. experimental support for webrtc ('works for me', requires a broker server).
updated avplug(renamed to ffmpeg so people know what it is) to use ffmpeg 3.2.4 properly, with its new encoder api. should be much more robust... also added experimental audio decoder for game music etc (currently doesn't resample, so playback rates are screwed, disabled by cvar).
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5097 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-05-10 02:08:58 +00:00
int stride ;
2019-09-25 20:23:24 +00:00
int width = vid . pixelwidth ;
int height = vid . pixelheight ;
2015-01-21 18:18:37 +00:00
image_t * img ;
2019-09-25 20:23:24 +00:00
uploadfmt_t format ;
Too many changes, sorry.
Change revision displays, use the SVN commit date instead of using __DATE__ (when there's no local changes). This should allow reproducible builds.
Added s_al_disable cvar, to block openal and all the various problems people have had with it, without having to name an explicit fallback (which would vary by system).
Add mastervolume cvar (for ss).
Add r_shadows 2 (aka fake shadows - for ss).
Add scr_loadingscreen_aspect -1 setting, to disable levelshots entirely, also disables the progress bar (for ss).
Better support for some effectinfo hacks (for ss).
Added dpcompat_nocsqcwarnings (because of lazy+buggy mods like ss).
Rework the dpcsqc versions of project+unproject builtins for better compat (for ss).
Added dpcompat_csqcinputeventtypes to block unexpected csqc input events (for ss).
Better compat with DP's loadfont console command (for ss).
Added dpcompat_smallerfonts cvar to replicate a DP bug (for ss).
Detect dp's m_draw extension, to work around it (for ss).
Cvar dpcompat_ignoremodificationtimes added. A value of 0 favour the most recently modified file, 1 will use DP-like alphabetically sorted preferences (for ss).
loadfont builtin can now accept outline=1 in the sizes arg for slightly more readable fonts.
Fix bbox calcs for rotated entities, fix needed for r_ignorenetpvs 0.
Hackily parse emoji.json to provide :poop: etc suggestions.
Skip prediction entirely when there's no local entity info. This fixes stair-smoothing in xonotic.
screenshot_cubemap will now capture half-float images when saving to ktx or dds files.
Fix support for xcf files larger than 4gb, mostly to avoid compiler warnings.
Fixed size of gfx/loading.lmp when replacement textures are used.
Added mipmap support for rg8 and l8a8 textures.
r_hdr_framebuffer cvar updated to support format names instead of random negative numbers. Description updated to name some interesting ones.
Perform autoupdate _checks_ ONLY with explicit user confirmation (actual updating already needed user confirmation, but this extra step should reduce the chances of us getting wrongly accused of exfiltrating user data if we're run in a sandbox - we ONLY ever included the updating engine's version in the checks, though there's nothing we can do to avoid sending the user's router's IP).
Removed the 'summon satan all over your harddrive' quit message, in case paranoid security researchers are idiots and don't bother doing actual research.
Removed the triptohell.info and fte.triptohell.info certificates, they really need to stop being self-signed. The updates domain is still self-signed for autoupdates.
Video drivers are now able to report supported video resolutions, visible to menuqc. Currently only works with SDL2 builds.
Added setmousepos builtin. Should work with glx+win32 build.
VF_SKYROOM_CAMERA can now accept an extra two args, setviewprop(VF_SKYROOM_CAMERA, org, axis, degrees).
Removed v_skyroom_origin+v_skyroom_orientation cvars in favour just v_skyroom, which should make it behave more like the 'fog' command (used when csqc isn't overriding).
Added R_EndPolygonRibbon builtin to make it faster+easier to generate textured ribbon/cable/etc wide lines (for TW).
sdl: Fix up sys_sdl.c's file enumeration to support wildcards in directories.
edit command now displays end1.bin/end2.bin correctly, because we can.
Finally add support for f_modified - though ruleset_allow_larger_models and ruleset_allow_overlong_sounds generally make it redundant.
Fix threading race condition in sha1 lookups.
Updated f_ruleset to include the same extra flags reported by ezquake.
A mod's default.fmf file can now contain an eg 'mainconfig config.cfg' line (to explicitly set the main config saved with cfg_save_auto 1 etc).
fmf: basegame steam:GameName/GameDir can be used to try to load a mod directory from an installed steam game. The resulting gamedir will be read-only.
HOMEDIR CHANGE: use homedirs only if the basedir cannot be written or a homedir already exists, which should further reduce the probability of microsoft randomly uploading our data to their cloud (but mostly because its annoying to never know where your data is written).
Fixed buf_cvarlist, should work in xonotic now, and without segfaults.
Added an extra arg to URI_Get_Callback calls - the response size, also changed the tempstring to contain all bytes of the response, you need to be careful about nulls though.
Try to work around nvidia's forced-panning bug on x11 when changing video modes. This might screw with other programs.
sdl: support custom icons.
sdl: support choosing a specific display.
Added some documentation to menuqc builtins.
menusys: use outlines for slightly more readable fonts.
menusys: switch vid_width and vid_height combos into a single video mode combo to set both according to reported video modes.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5581 fc73d0e0-1445-4013-8a0c-d673dee63da5
2019-11-20 03:09:50 +00:00
void * rgbbuffer = SCR_ScreenShot_Capture ( width , height , & stride , & format , false , false ) ;
2019-09-25 20:23:24 +00:00
if ( rgbbuffer )
2015-01-21 18:18:37 +00:00
{
2019-09-25 20:23:24 +00:00
// extern cvar_t scr_sshot_type;
SCR_ScreenShot ( savefilename , FS_GAMEONLY , & rgbbuffer , 1 , stride , width , height , format , false ) ;
BZ_Free ( rgbbuffer ) ;
//if any menu code has the shader loaded, we want to avoid them using a cache.
//hopefully the menu code will unload as it goes, because these screenshots could be truely massive, as they're taken at screen resolution.
//should probably use a smaller fbo or something, but whatever.
img = Image_FindTexture ( va ( " saves/%s/screeny.%s " , savename , " tga " ) , NULL , 0 ) ;
if ( img )
2015-01-21 18:18:37 +00:00
{
2019-09-25 20:23:24 +00:00
if ( Image_UnloadTexture ( img ) )
2015-01-21 18:18:37 +00:00
{
2019-09-25 20:23:24 +00:00
//and then reload it so that any shaders using it don't get confused
Image_GetTexture ( va ( " saves/%s/screeny.%s " , savename , " tga " ) , NULL , 0 , NULL , NULL , 0 , 0 , TF_INVALID ) ;
2015-01-21 18:18:37 +00:00
}
}
}
}
# endif
2013-12-08 20:06:55 +00:00
# ifdef Q2SERVER
//save the player's inventory and other map-persistant state that is owned by the gamecode.
if ( ge )
{
char syspath [ 256 ] ;
if ( ! FS_NativePath ( va ( " saves/%s/game.gsv " , savename ) , FS_GAMEONLY , syspath , sizeof ( syspath ) ) )
return ;
2016-01-18 05:22:07 +00:00
ge - > WriteGame ( syspath , mapchange ) ;
2017-02-19 00:15:42 +00:00
FS_FlushFSHashFull ( ) ;
2013-12-08 20:06:55 +00:00
}
2014-10-05 20:04:11 +00:00
else
2013-12-08 20:06:55 +00:00
# endif
2014-10-05 20:04:11 +00:00
{
//fixme
2017-02-19 00:15:42 +00:00
FS_FlushFSHashFull ( ) ;
2014-10-05 20:04:11 +00:00
}
2018-08-23 06:03:31 +00:00
Q_strncpyz ( sv . loadgame_on_restart , savename , sizeof ( sv . loadgame_on_restart ) ) ;
2004-08-23 00:15:46 +00:00
}
2017-07-04 05:07:51 +00:00
static int QDECL CompleteSaveList ( const char * name , qofs_t flags , time_t mtime , void * parm , searchpathfuncs_t * spath )
{
struct xcommandargcompletioncb_s * ctx = parm ;
char trimmed [ 256 ] ;
size_t l ;
Q_strncpyz ( trimmed , name + 6 , sizeof ( trimmed ) ) ;
l = strlen ( trimmed ) ;
if ( l > = 9 & & ! Q_strcasecmp ( trimmed + l - 9 , " /info.fsv " ) )
{
trimmed [ l - 9 ] = 0 ;
2018-04-15 02:48:23 +00:00
ctx - > cb ( trimmed , NULL , NULL , ctx ) ;
2017-07-04 05:07:51 +00:00
}
return true ;
}
2018-05-21 13:47:53 +00:00
# ifndef QUAKETC
2017-07-04 05:07:51 +00:00
static int QDECL CompleteSaveListLegacy ( const char * name , qofs_t flags , time_t mtime , void * parm , searchpathfuncs_t * spath )
{
struct xcommandargcompletioncb_s * ctx = parm ;
char stripped [ 64 ] ;
COM_StripExtension ( name , stripped , sizeof ( stripped ) ) ;
2018-04-15 02:48:23 +00:00
ctx - > cb ( stripped , NULL , NULL , ctx ) ;
2017-07-04 05:07:51 +00:00
return true ;
}
2018-05-21 13:47:53 +00:00
# endif
2017-08-14 16:38:44 +00:00
void SV_Savegame_c ( int argn , const char * partial , struct xcommandargcompletioncb_s * ctx )
2017-07-04 05:07:51 +00:00
{
if ( argn = = 1 )
{
COM_EnumerateFiles ( va ( " saves/%s*/info.fsv " , partial ) , CompleteSaveList , ctx ) ;
2018-05-21 13:47:53 +00:00
# ifndef QUAKETC
2017-07-04 05:07:51 +00:00
COM_EnumerateFiles ( va ( " %s*.sav " , partial ) , CompleteSaveListLegacy , ctx ) ;
2018-05-21 13:47:53 +00:00
# endif
2017-07-04 05:07:51 +00:00
}
}
2011-06-29 18:39:11 +00:00
void SV_Savegame_f ( void )
{
2020-04-19 01:23:32 +00:00
if ( sv . state = = ss_clustermode & & MSV_ForwardToAutoServer ( ) )
;
else if ( Cmd_Argc ( ) < = 2 )
2018-05-21 13:47:53 +00:00
{
const char * savename = Cmd_Argv ( 1 ) ;
if ( strstr ( savename , " .. " ) )
{
Con_TPrintf ( " Relative pathnames are not allowed \n " ) ;
return ;
}
2019-01-13 16:51:50 +00:00
//make sure the name is valid, eg if its omitted.
if ( ! * savename | | strstr ( savename , " .. " ) )
savename = " quick " ;
2018-05-21 13:47:53 +00:00
# ifndef QUAKETC
if ( ! Q_strcasecmp ( Cmd_Argv ( 0 ) , " savegame_legacy " ) )
2018-08-23 06:03:31 +00:00
{
2018-12-04 08:57:29 +00:00
if ( SV_LegacySavegame ( savename , true ) )
2018-08-23 06:03:31 +00:00
return ;
Con_Printf ( " Unable to use legacy save format \n " ) ;
2018-12-04 08:57:29 +00:00
return ;
2018-08-23 06:03:31 +00:00
}
2018-05-21 13:47:53 +00:00
# endif
2018-08-23 06:03:31 +00:00
SV_Savegame ( savename , false ) ;
2018-05-21 13:47:53 +00:00
}
2015-01-21 18:18:37 +00:00
else
Con_Printf ( " %s: invalid number of arguments \n " , Cmd_Argv ( 0 ) ) ;
2011-06-29 18:39:11 +00:00
}
2016-01-18 05:22:07 +00:00
void SV_AutoSave ( void )
{
2016-02-10 23:23:43 +00:00
# ifndef NOBUILTINMENUS
2016-01-18 05:22:07 +00:00
# ifndef SERVERONLY
const char * autosavename ;
int i ;
if ( sv_autosave . value < = 0 )
return ;
if ( sv . state ! = ss_active )
return ;
2017-07-28 01:49:25 +00:00
switch ( svs . gametype )
{
default : //probably broken. don't ever try.
2016-01-18 05:22:07 +00:00
return ;
2017-07-28 01:49:25 +00:00
case GT_Q1QVM :
case GT_PROGS :
//don't bother to autosave multiplayer games.
//this may be problematic with splitscreen, but coop rules tend to apply there anyway.
if ( sv . allocated_client_slots ! = 1 )
return ;
for ( i = 0 ; i < sv . allocated_client_slots ; i + + )
2016-01-18 05:22:07 +00:00
{
2017-07-28 01:49:25 +00:00
if ( svs . clients [ i ] . state = = cs_spawned )
{
if ( svs . clients [ i ] . edict - > v - > health < = 0 )
return ; //autosaves with a dead player are just cruel.
2016-01-18 05:22:07 +00:00
2017-07-28 01:49:25 +00:00
if ( ( int ) svs . clients [ i ] . edict - > v - > flags & ( FL_GODMODE | FL_NOTARGET ) )
return ; //autosaves to highlight cheaters is also just spiteful.
2016-01-18 05:22:07 +00:00
2017-07-28 01:49:25 +00:00
if ( svs . clients [ i ] . edict - > v - > movetype ! = MOVETYPE_WALK )
return ; //noclip|fly are cheaters, toss|bounce are bad at playing. etc.
2016-01-18 05:22:07 +00:00
2017-07-28 01:49:25 +00:00
if ( ! ( ( int ) svs . clients [ i ] . edict - > v - > flags & FL_ONGROUND ) )
return ; //autosaves while people are jumping are awkward.
2016-01-18 05:22:07 +00:00
2017-07-28 01:49:25 +00:00
if ( svs . clients [ i ] . edict - > v - > velocity [ 0 ] | | svs . clients [ i ] . edict - > v - > velocity [ 1 ] | | svs . clients [ i ] . edict - > v - > velocity [ 2 ] )
return ; //people running around are likely to result in poor saves
}
2016-01-18 05:22:07 +00:00
}
2017-07-28 01:49:25 +00:00
break ;
2016-01-18 05:22:07 +00:00
}
autosavename = M_ChooseAutoSave ( ) ;
2016-02-10 23:23:43 +00:00
Con_DPrintf ( " Autosaving to %s \n " , autosavename ) ;
2016-01-18 05:22:07 +00:00
SV_Savegame ( autosavename , false ) ;
sv . autosave_time = sv . time + sv_autosave . value * 60 ;
# endif
2016-02-10 23:23:43 +00:00
# endif
2016-01-18 05:22:07 +00:00
}
2020-04-19 01:23:32 +00:00
static void SV_SwapPlayers ( client_t * a , client_t * b )
{
size_t i ;
client_t tmp ;
if ( a = = b )
return ; //o.O
tmp = * a ;
* a = * b ;
* b = tmp ;
//swap over pointers for splitscreen.
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
{
if ( svs . clients [ i ] . controller = = a )
svs . clients [ i ] . controller = b ;
else if ( svs . clients [ i ] . controller = = b )
svs . clients [ i ] . controller = a ;
if ( svs . clients [ i ] . controlled = = a )
svs . clients [ i ] . controlled = b ;
else if ( svs . clients [ i ] . controlled = = b )
svs . clients [ i ] . controlled = a ;
}
//undo some damage...
b - > edict = a - > edict ;
a - > edict = tmp . edict ;
if ( a - > name = = b - > namebuf ) a - > name = a - > namebuf ;
if ( b - > name = = a - > namebuf ) b - > name = b - > namebuf ;
if ( a - > team = = b - > teambuf ) a - > team = a - > teambuf ;
if ( b - > team = = a - > teambuf ) b - > team = b - > teambuf ;
if ( a - > netchan . message . data )
a - > netchan . message . data + = ( qbyte * ) b - ( qbyte * ) a ;
if ( a - > datagram . data )
a - > datagram . data + = ( qbyte * ) b - ( qbyte * ) a ;
if ( a - > backbuf . data )
a - > backbuf . data + = ( qbyte * ) b - ( qbyte * ) a ;
if ( b - > netchan . message . data )
b - > netchan . message . data + = ( qbyte * ) a - ( qbyte * ) b ;
if ( b - > datagram . data )
b - > datagram . data + = ( qbyte * ) a - ( qbyte * ) b ;
if ( b - > backbuf . data )
b - > backbuf . data + = ( qbyte * ) a - ( qbyte * ) b ;
}
void SV_LoadPlayers ( loadplayer_t * lp , size_t slots )
{ //loading games is messy as fuck
//we need to reorder players to the order in the saved game.
//swapping players around is really rather messy...
client_t * cl ;
size_t clnum , p , p2 ;
int to [ 255 ] ;
2020-09-08 05:11:09 +00:00
//kick any splitscreen seats. they'll get re-added after load (filling slots like connecting players would)
for ( clnum = 0 ; clnum < svs . allocated_client_slots ; clnum + + )
{
cl = & svs . clients [ clnum ] ;
cl - > controlled = NULL ; //kill the links.
if ( cl - > controller ) //its a slave
{
//unlink it
cl - > controller = NULL ;
//make it into a pseudo-bot so the kicking doesn't do weird stuff.
cl - > netchan . remote_address . type = NA_INVALID ; //so the remaining client doesn't get the kick too.
cl - > protocol = SCP_BAD ; //make it a bit like a bot, so we don't try sending any datagrams/reliables at someone that isn't able to receive anything.
//okay, it can get lost now.
cl - > drop = true ;
}
}
2020-04-19 01:23:32 +00:00
//despawn any entity data, and try to find the loaded player to move them to
for ( clnum = 0 ; clnum < svs . allocated_client_slots ; clnum + + ) //clear the server for the level change.
{
to [ clnum ] = - 1 ;
cl = & svs . clients [ clnum ] ;
if ( cl - > state < = cs_loadzombie )
continue ;
SV_DespawnClient ( cl ) ;
if ( cl - > state = = cs_spawned )
cl - > state = cs_connected ;
//FIXME: try to match by guids (but we don't have saved guid info)
//try to match the player to a slot by name.
for ( p = 0 ; p < slots ; p + + )
if ( * lp [ p ] . name )
{
if ( ! strcmp ( cl - > name , lp [ p ] . name ) | | slots = = 1 )
{ //this player matched matched...
to [ clnum ] = p ;
lp [ p ] . source = cl ;
break ;
}
}
}
//for loaded players that don't have a client go and find a player to spawn there, to try to deal with players that renamed themselves.
for ( p = 0 ; p < slots ; p + + )
{
if ( ! * lp [ p ] . name | | lp [ p ] . source )
continue ;
for ( clnum = 0 ; clnum < svs . allocated_client_slots ; clnum + + )
{
cl = & svs . clients [ clnum ] ;
if ( cl - > state < = cs_loadzombie )
continue ;
if ( to [ clnum ] > = 0 )
continue ; //was already mapped
if ( cl - > spectator )
continue ; //spectators shouldn't be pulled into a player against their will. it may still happen though.
to [ clnum ] = p ;
lp [ p ] . source = cl ;
break ;
}
}
//we walk the list in order, pulling from the appropriate slot.
//we're swapping each time, so uninteresting players will bubble to the end instead of breaking our finalised list..
//if we're swapping from an earlier slot then that slot wasn't relevant anyway.
for ( p = 0 ; p < slots ; p + + )
{
if ( lp [ p ] . source & & lp [ p ] . source ! = & svs . clients [ p ] )
{
SV_SwapPlayers ( & svs . clients [ p ] , lp [ p ] . source ) ;
for ( p2 = 0 ; p2 < slots ; p2 + + )
{
if ( p = = p2 )
continue ;
if ( lp [ p2 ] . source = = & svs . clients [ p ] )
lp [ p2 ] . source = lp [ p ] . source ;
else if ( lp [ p2 ] . source = = lp [ p ] . source )
lp [ p2 ] . source = & svs . clients [ p ] ;
}
}
}
if ( slots > svs . allocated_client_slots ) //will be trimmed later
SV_UpdateMaxPlayers ( slots ) ;
for ( cl = svs . clients , clnum = 0 ; clnum < slots ; cl + + , clnum + + )
{
if ( * lp [ clnum ] . name )
{ //okay so we have a player ready for this slot.
for ( p = 0 ; p < NUM_SPAWN_PARMS ; p + + )
cl - > spawn_parms [ p ] = lp [ clnum ] . parm [ p ] . f ;
cl - > spawn_parmstring = lp [ clnum ] . parmstr ;
continue ;
}
else if ( cl - > state > cs_zombie )
SV_DropClient ( cl ) ;
/*
Q_strncpyz ( cl - > namebuf , lp [ clnum ] . name , sizeof ( cl - > namebuf ) ) ;
cl - > name = cl - > namebuf ;
if ( * cl - > namebuf )
{
cl - > state = cs_loadzombie ;
cl - > connection_started = realtime + 20 ;
cl - > istobeloaded = true ; //the parms are known
cl - > userid = 0 ;
memset ( & cl - > netchan , 0 , sizeof ( cl - > netchan ) ) ;
for ( p = 0 ; p < NUM_SPAWN_PARMS ; p + + )
cl - > spawn_parms [ p ] = lp [ clnum ] . parm [ p ] . f ;
cl - > spawn_parmstring = lp [ clnum ] . parmstr ;
} */
}
}
static void SV_GameLoaded ( loadplayer_t * lp , size_t slots , const char * savename )
{
size_t clnum ;
client_t * cl ;
//make sure autosave doesn't save too early.
sv . autosave_time = sv . time + sv_autosave . value * 60 ;
//let the restart command know the name of the saved game to reload.
Q_strncpyz ( sv . loadgame_on_restart , savename , sizeof ( sv . loadgame_on_restart ) ) ;
slots = min ( slots , svs . allocated_client_slots ) ;
//make sure the player state is set up properly.
for ( clnum = 0 ; clnum < slots ; clnum + + )
{
cl = & svs . clients [ clnum ] ;
cl - > spawned = ! ! * lp [ clnum ] . name ;
if ( cl - > spawned )
2020-09-08 05:11:09 +00:00
{
2020-04-19 01:23:32 +00:00
sv . spawned_client_slots + + ;
2020-09-08 05:11:09 +00:00
Q_strncpyz ( cl - > namebuf , lp [ clnum ] . name , sizeof ( cl - > namebuf ) ) ;
}
2020-04-19 01:23:32 +00:00
cl - > name = PR_AddString ( svprogfuncs , cl - > namebuf , sizeof ( cl - > namebuf ) , false ) ;
cl - > team = PR_AddString ( svprogfuncs , cl - > teambuf , sizeof ( cl - > teambuf ) , false ) ;
cl - > edict = EDICT_NUM_PB ( svprogfuncs , clnum + 1 ) ;
# ifdef HEXEN2
{
if ( cl - > edict )
cl - > playerclass = cl - > edict - > xv - > playerclass ;
else
cl - > playerclass = 0 ;
}
# endif
if ( cl - > state = = cs_spawned ) //shouldn't have gotten past SV_SpawnServer, but just in case...
cl - > state = cs_connected ; //client needs new serverinfo.
if ( cl - > spawned & & cl - > state < cs_connected ) //make sure the player slot is active when the gamecode thinks it was (with a loadzombie if needed)
{
cl - > state = cs_loadzombie ;
cl - > connection_started = realtime + 20 ;
cl - > istobeloaded = true ; //the parms are known
cl - > userid = 0 ;
memset ( & cl - > netchan , 0 , sizeof ( cl - > netchan ) ) ;
}
if ( cl - > controller )
continue ;
if ( cl - > state > = cs_connected )
{
if ( cl - > protocol = = SCP_QUAKE3 )
continue ;
if ( cl - > protocol = = SCP_BAD )
continue ;
host_client = cl ;
# ifdef NQPROT
if ( ISNQCLIENT ( host_client ) )
SVNQ_New_f ( ) ;
else
# endif
SV_New_f ( ) ;
}
}
host_client = NULL ;
}
# ifndef QUAKETC
//expects the version to have already been parsed
static qboolean SV_Loadgame_Legacy ( const char * savename , const char * filename , vfsfile_t * f , int version )
{
//FIXME: Multiplayer save probably won't work with spectators.
char mapname [ MAX_QPATH ] ;
float time ;
char str [ 32768 ] ;
int i ;
int pt ;
int lstyles ;
int slots ;
int clnum ;
char plname [ 32 ] ;
int filelen , filepos ;
char * file ;
char * modelnames [ MAX_PRECACHE_MODELS ] ;
char * soundnames [ MAX_PRECACHE_SOUNDS ] ;
loadplayer_t lp [ 255 ] ;
2020-10-26 06:30:35 +00:00
struct loadinfo_s loadinfo ;
loadinfo . numplayers = countof ( lp ) ;
loadinfo . players = lp ;
2020-04-19 01:23:32 +00:00
if ( version ! = SAVEGAME_VERSION_FTE_LEG & & version ! = SAVEGAME_VERSION_NQ & & version ! = SAVEGAME_VERSION_QW )
{
VFS_CLOSE ( f ) ;
Con_TPrintf ( " Unable to load savegame of version %i \n " , version ) ;
return false ;
}
VFS_GETS ( f , str , sizeof ( str ) ) ; //discard comment.
Con_Printf ( " loading legacy game from %s... \n " , filename ) ;
if ( version = = SAVEGAME_VERSION_NQ | | version = = SAVEGAME_VERSION_QW )
{
slots = 1 ;
# ifdef SERVERONLY
Q_strncpyz ( lp [ 0 ] . name , " " , sizeof ( lp [ 0 ] . name ) ) ;
# else
Q_strncpyz ( lp [ 0 ] . name , name . string , sizeof ( lp [ 0 ] . name ) ) ;
# endif
lp [ 0 ] . parmstr = NULL ;
lp [ 0 ] . source = NULL ;
for ( i = 0 ; i < 16 ; i + + )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
lp [ 0 ] . parm [ i ] . f = atof ( str ) ;
}
for ( ; i < countof ( lp [ 0 ] . parm ) ; i + + )
lp [ 0 ] . parm [ i ] . i = 0 ;
}
else //fte saves ALL the clients on the server.
{
VFS_GETS ( f , str , strlen ( str ) ) ;
slots = atoi ( str ) ;
if ( ! slots | | slots > = countof ( lp ) ) //err
{
VFS_CLOSE ( f ) ;
Con_Printf ( " Corrupted save game " ) ;
return false ;
}
for ( clnum = 0 ; clnum < slots ; clnum + + )
{
VFS_GETS ( f , plname , sizeof ( plname ) ) ;
COM_Parse ( plname ) ;
Q_strncpyz ( lp [ clnum ] . name , com_token , sizeof ( lp [ clnum ] . name ) ) ;
lp [ clnum ] . parmstr = NULL ;
lp [ clnum ] . source = NULL ;
if ( ! * com_token )
continue ;
//probably should be 32, rather than NUM_SPAWN_PARMS(64)
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
lp [ clnum ] . parm [ i ] . f = atof ( str ) ;
}
for ( ; i < countof ( lp [ clnum ] . parm ) ; i + + )
lp [ clnum ] . parm [ i ] . i = 0 ;
}
}
SV_LoadPlayers ( lp , slots ) ;
if ( version = = SAVEGAME_VERSION_NQ | | version = = SAVEGAME_VERSION_QW )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " skill " ) , atof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " deathmatch " ) , 0 ) ;
Cvar_SetValue ( Cvar_FindVar ( " coop " ) , 0 ) ;
Cvar_SetValue ( Cvar_FindVar ( " teamplay " ) , 0 ) ;
if ( version = = SAVEGAME_VERSION_NQ )
{
progstype = PROG_NQ ;
Cvar_Set ( & pr_ssqc_progs , " progs.dat " ) ; //NQ's progs.
}
else
{
progstype = PROG_QW ;
Cvar_Set ( & pr_ssqc_progs , " spprogs " ) ; //zquake's single player qw progs.
}
pt = 0 ;
}
else
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
pt = atoi ( str ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " skill " ) , atof ( str ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " deathmatch " ) , atof ( str ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " coop " ) , atof ( str ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " teamplay " ) , atof ( str ) ) ;
}
VFS_GETS ( f , mapname , sizeof ( mapname ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
time = atof ( str ) ;
SV_SpawnServer ( mapname , NULL , false , false , slots ) ; //always inits MAX_CLIENTS slots. That's okay, because we can cut the max easily.
if ( sv . state ! = ss_active )
{
VFS_CLOSE ( f ) ;
Con_TPrintf ( " Couldn't load map \n " ) ;
return false ;
}
if ( sv . allocated_client_slots ! = slots )
{
Con_TPrintf ( " Player count changed \n " ) ;
return false ;
}
// load the light styles
lstyles = 64 ;
if ( lstyles > sv . maxlightstyles )
Z_ReallocElements ( ( void * * ) & sv . lightstyles , & sv . maxlightstyles , lstyles , sizeof ( * sv . lightstyles ) ) ;
for ( i = 0 ; i < lstyles ; i + + )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( sv . lightstyles [ i ] . str )
Z_Free ( ( char * ) sv . lightstyles [ i ] . str ) ;
sv . lightstyles [ i ] . str = Z_StrDup ( str ) ;
sv . lightstyles [ i ] . colours [ 0 ] = sv . lightstyles [ i ] . colours [ 1 ] = sv . lightstyles [ i ] . colours [ 2 ] = 1 ;
}
for ( ; i < sv . maxlightstyles ; i + + )
{
if ( sv . lightstyles [ i ] . str )
Z_Free ( ( char * ) sv . lightstyles [ i ] . str ) ;
sv . lightstyles [ i ] . str = NULL ;
}
//model names are pointers to vm-accessible memory. as that memory is going away, we need to destroy and recreate, which requires preserving them.
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
{
if ( ! sv . strings . model_precache [ i ] )
{
modelnames [ i ] = NULL ;
break ;
}
modelnames [ i ] = Z_StrDup ( sv . strings . model_precache [ i ] ) ;
}
for ( i = 1 ; i < MAX_PRECACHE_SOUNDS ; i + + )
{
if ( ! sv . strings . sound_precache [ i ] )
{
soundnames [ i ] = NULL ;
break ;
}
soundnames [ i ] = Z_StrDup ( sv . strings . sound_precache [ i ] ) ;
}
// load the edicts out of the savegame file
// the rest of the file is sent directly to the progs engine.
if ( version = = SAVEGAME_VERSION_NQ | | version = = SAVEGAME_VERSION_QW )
; //Q_InitProgs(); //reinitialize progs entirly.
else
{
Q_SetProgsParms ( false ) ;
svs . numprogs = 0 ;
PR_Configure ( svprogfuncs , PR_ReadBytesString ( pr_ssqc_memsize . string ) , MAX_PROGS , pr_enable_profiling . ival ) ;
PR_RegisterFields ( ) ;
PR_InitEnts ( svprogfuncs , sv . world . max_edicts ) ; //just in case the max edicts isn't set.
progstype = pt ; //presumably the progs.dat will be what they were before.
}
//reload model names.
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
{
if ( ! modelnames [ i ] )
break ;
sv . strings . model_precache [ i ] = PR_AddString ( svprogfuncs , modelnames [ i ] , 0 , false ) ;
Z_Free ( modelnames [ i ] ) ;
}
for ( i = 1 ; i < MAX_PRECACHE_SOUNDS ; i + + )
{
if ( ! soundnames [ i ] )
break ;
sv . strings . sound_precache [ i ] = PR_AddString ( svprogfuncs , soundnames [ i ] , 0 , false ) ;
Z_Free ( soundnames [ i ] ) ;
}
filepos = VFS_TELL ( f ) ;
filelen = VFS_GETLEN ( f ) ;
filelen - = filepos ;
file = BZ_Malloc ( filelen + 1 + 8 ) ;
memset ( file , 0 , filelen + 1 + 8 ) ;
strcpy ( file , " loadgame " ) ;
clnum = VFS_READ ( f , file + 8 , filelen ) ;
file [ filelen + 8 ] = ' \0 ' ;
2020-10-26 06:30:35 +00:00
sv . world . edict_size = svprogfuncs - > load_ents ( svprogfuncs , file , & loadinfo , NULL , SV_ExtendedSaveData ) ;
2020-04-19 01:23:32 +00:00
BZ_Free ( file ) ;
PR_LoadGlabalStruct ( false ) ;
pr_global_struct - > time = sv . world . physicstime = sv . time = time ;
sv . starttime = Sys_DoubleTime ( ) - sv . time ;
VFS_CLOSE ( f ) ;
//FIXME: QSS+DP saved games have some / *\nkey values\nkey values\n* / thing in them to save precaches and stuff
World_ClearWorld ( & sv . world , true ) ;
SV_GameLoaded ( lp , slots , savename ) ;
return true ;
}
# endif
2018-08-23 06:03:31 +00:00
//Attempts to load a named saved game.
qboolean SV_Loadgame ( const char * unsafe_savename )
2004-08-23 00:15:46 +00:00
{
levelcache_t * cache ;
2012-01-24 04:24:14 +00:00
unsigned char str [ MAX_LOCALINFO_STRING + 1 ] , * trim ;
unsigned char savename [ MAX_QPATH ] ;
2009-04-01 22:03:56 +00:00
vfsfile_t * f ;
2012-01-24 04:24:14 +00:00
unsigned char filename [ MAX_OSPATH ] ;
2004-08-23 00:15:46 +00:00
int version ;
int clnum ;
int slots ;
2020-04-19 01:23:32 +00:00
int p ;
2004-08-23 00:15:46 +00:00
client_t * cl ;
2005-03-18 06:13:11 +00:00
gametype_e gametype ;
2020-04-19 01:23:32 +00:00
loadplayer_t lp [ 255 ] ;
2004-08-23 00:15:46 +00:00
2018-05-21 13:47:53 +00:00
struct
{
char * pattern ;
flocation_t loc ;
} savefiles [ ] =
{
{ " saves/%s/info.fsv " } ,
# ifndef QUAKETC
{ " %s.sav " } ,
# endif
2019-01-29 07:18:07 +00:00
{ " %s " }
2018-05-21 13:47:53 +00:00
} ;
2019-01-29 07:18:07 +00:00
int bestd = 0x7fffffff , best = 0 ;
time_t bestt = 0 , t ;
2018-05-21 13:47:53 +00:00
2018-08-23 06:03:31 +00:00
Q_strncpyz ( savename , unsafe_savename , sizeof ( savename ) ) ;
2004-08-23 00:15:46 +00:00
if ( ! * savename | | strstr ( savename , " .. " ) )
2019-01-29 07:18:07 +00:00
{ //if no args, or its invalid, try to pick the last one that was saved (of those listed in the menu)
size_t n ;
static char * autoload [ ] = { " quick " , " a0 " , " a1 " , " a2 " ,
" s0 " , " s1 " , " s2 " , " s3 " , " s4 " , " s5 " , " s6 " , " s7 " , " s8 " , " s9 " } ;
strcpy ( savename , " quick " ) ; //default...
2004-08-23 00:15:46 +00:00
2019-01-29 07:18:07 +00:00
for ( n = 0 ; n < countof ( autoload ) ; n + + )
{
2020-04-19 01:23:32 +00:00
for ( p = 0 ; p < countof ( savefiles ) - 1 ; p + + )
2019-01-29 07:18:07 +00:00
{
2020-04-19 01:23:32 +00:00
int d = FS_FLocateFile ( va ( savefiles [ p ] . pattern , autoload [ n ] ) , FSLF_DONTREFERENCE , & savefiles [ p ] . loc ) ;
2019-01-29 07:18:07 +00:00
if ( ! d )
continue ;
2020-04-19 01:23:32 +00:00
FS_GetLocMTime ( & savefiles [ p ] . loc , & t ) ;
2019-01-29 07:18:07 +00:00
if ( d < bestd | | ( bestd = = d & & t > bestt ) )
{
bestd = d ;
bestt = t ;
2020-04-19 01:23:32 +00:00
best = p ;
2019-01-29 07:18:07 +00:00
strcpy ( savename , autoload [ n ] ) ;
}
}
}
}
2020-04-19 01:23:32 +00:00
for ( p = 0 ; p < countof ( savefiles ) ; p + + )
2014-03-30 08:55:06 +00:00
{
2020-04-19 01:23:32 +00:00
int d = FS_FLocateFile ( va ( savefiles [ p ] . pattern , savename ) , FSLF_DONTREFERENCE , & savefiles [ p ] . loc ) ;
2019-01-29 07:18:07 +00:00
if ( ! d )
continue ;
2020-04-19 01:23:32 +00:00
FS_GetLocMTime ( & savefiles [ p ] . loc , & t ) ;
2019-01-29 07:18:07 +00:00
if ( d < bestd | | ( bestd = = d & & t > bestt ) )
2018-05-21 13:47:53 +00:00
{
2019-01-29 07:18:07 +00:00
bestd = d ;
bestt = t ;
2020-04-19 01:23:32 +00:00
best = p ;
2018-05-21 13:47:53 +00:00
}
2014-03-30 08:55:06 +00:00
}
2018-05-21 13:47:53 +00:00
Q_snprintfz ( filename , sizeof ( filename ) , savefiles [ best ] . pattern , savename ) ;
f = FS_OpenReadLocation ( & savefiles [ best ] . loc ) ;
2004-08-23 00:15:46 +00:00
if ( ! f )
{
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " ERROR: couldn't open %s. \n " , filename ) ;
2018-08-23 06:03:31 +00:00
return false ;
2004-08-23 00:15:46 +00:00
}
2015-07-27 09:00:18 +00:00
# if defined(MENU_DAT) && !defined(SERVERONLY)
2015-07-27 08:21:34 +00:00
MP_Toggle ( 0 ) ;
# endif
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
version = atoi ( str ) ;
2018-08-23 06:03:31 +00:00
if ( version < SAVEGAME_VERSION_FTE_HUB | | version > = SAVEGAME_VERSION_FTE_HUB + GT_MAX )
2004-08-23 00:15:46 +00:00
{
2018-05-21 13:47:53 +00:00
# ifdef QUAKETC
VFS_CLOSE ( f ) ;
Con_TPrintf ( " Unable to load savegame of version %i \n " , version ) ;
2018-08-23 06:03:31 +00:00
return false ;
2018-05-21 13:47:53 +00:00
# else
2020-04-19 01:23:32 +00:00
return SV_Loadgame_Legacy ( savename , filename , f , version ) ;
2018-05-21 13:47:53 +00:00
# endif
2004-08-23 00:15:46 +00:00
}
2014-08-15 02:20:41 +00:00
2018-08-23 06:03:31 +00:00
gametype = version - SAVEGAME_VERSION_FTE_HUB ;
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
# ifndef SERVERONLY
if ( ! cls . state )
# endif
2013-11-29 14:36:47 +00:00
Con_TPrintf ( " Loading game from %s... \n " , filename ) ;
2004-08-23 00:15:46 +00:00
2005-03-18 06:13:11 +00:00
2004-08-23 00:15:46 +00:00
2020-04-19 01:23:32 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
slots = atoi ( str ) ;
2004-08-23 00:15:46 +00:00
2020-04-19 01:23:32 +00:00
if ( slots < 1 | | slots > countof ( lp ) )
2016-07-12 00:40:13 +00:00
{
2020-04-19 01:23:32 +00:00
VFS_CLOSE ( f ) ;
Con_Printf ( " invalid player count in saved game \n " ) ;
return false ;
2016-07-12 00:40:13 +00:00
}
2004-08-23 00:15:46 +00:00
for ( cl = svs . clients , clnum = 0 ; clnum < slots ; cl + + , clnum + + )
{
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2006-01-11 22:25:46 +00:00
str [ sizeof ( cl - > namebuf ) - 1 ] = ' \0 ' ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
2020-04-19 01:23:32 +00:00
strcpy ( lp [ clnum ] . name , str ) ;
lp [ clnum ] . parmstr = NULL ;
lp [ clnum ] . source = NULL ;
2004-08-23 00:15:46 +00:00
if ( * str )
{
2020-04-19 01:23:32 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
if ( * str = = ' { ' )
2004-08-23 00:15:46 +00:00
{
2020-04-19 01:23:32 +00:00
while ( VFS_GETS ( f , str , sizeof ( str ) - 1 ) )
2018-08-23 06:03:31 +00:00
{
2020-04-19 01:23:32 +00:00
if ( * str = = ' } ' )
break ;
trim = COM_Parse ( str ) ;
if ( ! strcmp ( com_token , " parm_string " ) )
2018-08-23 06:03:31 +00:00
{
2020-04-19 01:23:32 +00:00
COM_Parse ( trim ) ;
Z_Free ( lp [ clnum ] . parmstr ) ;
lp [ clnum ] . parmstr = Z_StrDup ( com_token ) ;
}
else if ( ! strncmp ( com_token , " parm " , 4 ) )
{
unsigned int parm = atoi ( com_token + 4 ) ;
COM_Parse ( trim ) ;
if ( parm < NUM_SPAWN_PARMS )
2018-08-23 06:03:31 +00:00
{
if ( ! strncmp ( com_token , " 0x " , 2 ) )
2020-04-19 01:23:32 +00:00
lp [ clnum ] . parm [ parm ] . i = strtoul ( com_token , NULL , 16 ) ;
2018-08-23 06:03:31 +00:00
else
2020-04-19 01:23:32 +00:00
lp [ clnum ] . parm [ parm ] . f = strtod ( com_token , NULL ) ;
2018-08-23 06:03:31 +00:00
}
}
2020-04-19 01:23:32 +00:00
else
Con_Printf ( " Unknown player data: %s \n " , com_token ) ;
2004-08-23 00:15:46 +00:00
}
}
2020-04-19 01:23:32 +00:00
else
{ //we used to have N integers, where N was some random outdated constant.
VFS_CLOSE ( f ) ;
Con_Printf ( " Incompatible saved game \n " ) ;
return false ;
}
2004-08-23 00:15:46 +00:00
}
}
2020-04-19 01:23:32 +00:00
SV_LoadPlayers ( lp , slots ) ;
2005-07-03 15:16:20 +00:00
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
Info_RemovePrefixedKeys ( str , ' * ' ) ; //just in case
2018-07-05 16:21:44 +00:00
InfoBuf_Clear ( & svs . info , false ) ;
InfoBuf_FromString ( & svs . info , str , true ) ;
2004-08-23 00:15:46 +00:00
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
Info_RemovePrefixedKeys ( str , ' * ' ) ; //just in case
2018-07-05 16:21:44 +00:00
InfoBuf_Clear ( & svs . localinfo , false ) ;
InfoBuf_FromString ( & svs . localinfo , str , true ) ;
2004-08-23 00:15:46 +00:00
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
if ( strcmp ( str , " { " ) )
SV_Error ( " Corrupt saved game \n " ) ;
while ( 1 )
{
2009-04-01 22:03:56 +00:00
if ( ! VFS_GETS ( f , str , sizeof ( str ) - 1 ) )
2004-08-23 00:15:46 +00:00
SV_Error ( " Corrupt saved game \n " ) ;
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
if ( ! strcmp ( str , " } " ) )
break ;
else if ( * str )
Cmd_ExecuteString ( str , RESTRICT_RCON ) ;
}
SV_FlushLevelCache ( ) ;
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
if ( strcmp ( str , " { " ) )
SV_Error ( " Corrupt saved game \n " ) ;
while ( 1 )
{
2009-04-01 22:03:56 +00:00
if ( ! VFS_GETS ( f , str , sizeof ( str ) - 1 ) )
2004-08-23 00:15:46 +00:00
SV_Error ( " Corrupt saved game \n " ) ;
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
if ( ! strcmp ( str , " } " ) )
break ;
if ( ! * str )
continue ;
2005-03-18 06:13:11 +00:00
cache = Z_Malloc ( sizeof ( levelcache_t ) + strlen ( str ) + 1 ) ;
2004-08-23 00:15:46 +00:00
cache - > mapname = ( char * ) ( cache + 1 ) ;
strcpy ( cache - > mapname , str ) ;
2005-03-18 06:13:11 +00:00
cache - > gametype = gametype ;
2004-08-23 00:15:46 +00:00
cache - > next = svs . levcache ;
2009-04-01 22:03:56 +00:00
FS_Copy ( va ( " saves/%s/%s.lvc " , savename , cache - > mapname ) , va ( " saves/%s.lvc " , cache - > mapname ) , FS_GAME , FS_GAMEONLY ) ;
2004-08-23 00:15:46 +00:00
svs . levcache = cache ;
}
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
for ( trim = str + strlen ( str ) - 1 ; trim > = str & & * trim < = ' ' ; trim - - )
* trim = ' \0 ' ;
for ( trim = str ; * trim < = ' ' & & * trim ; trim + + )
;
2014-08-16 05:33:50 +00:00
//serverflags is reset on restart, so we need to read the value as it was at the start of the current map.
VFS_GETS ( f , filename , sizeof ( filename ) - 1 ) ;
svs . serverflags = atof ( filename ) ;
2009-04-01 22:03:56 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
2013-12-08 20:06:55 +00:00
# ifdef Q2SERVER
if ( gametype = = GT_QUAKE2 )
{
flocation_t loc ;
char * name = va ( " saves/%s/game.gsv " , savename ) ;
2015-10-11 11:34:58 +00:00
if ( ! FS_FLocateFile ( name , FSLF_IFFOUND , & loc ) )
2013-12-08 20:06:55 +00:00
Con_Printf ( " Couldn't find %s. \n " , name ) ;
else if ( ! * loc . rawname | | loc . offset )
Con_Printf ( " %s is inside a package and cannot be used by the quake2 gamecode. \n " , name ) ;
else
{
SVQ2_InitGameProgs ( ) ;
if ( ge )
ge - > ReadGame ( loc . rawname ) ;
}
}
# endif
2012-05-09 15:30:53 +00:00
svs . gametype = gametype ;
2010-07-25 15:06:38 +00:00
SV_LoadLevelCache ( savename , str , " " , true ) ;
2016-01-18 05:22:07 +00:00
2020-04-19 01:23:32 +00:00
SV_GameLoaded ( lp , slots , savename ) ;
2018-08-23 06:03:31 +00:00
return true ;
}
void SV_Loadgame_f ( void )
{
# ifndef SERVERONLY
if ( ! Renderer_Started ( ) & & ! isDedicated )
{
Cbuf_AddText ( va ( " wait;%s %s \n " , Cmd_Argv ( 0 ) , Cmd_Args ( ) ) , Cmd_ExecLevel ) ;
return ;
}
# endif
2020-04-19 01:23:32 +00:00
if ( sv . state = = ss_clustermode & & MSV_ForwardToAutoServer ( ) )
;
else
SV_Loadgame ( Cmd_Argv ( 1 ) ) ;
}
# include "fs.h"
void SV_DeleteSavegame_f ( void )
{
const char * savename = Cmd_Argv ( 1 ) ;
//either saves/$FOO/info.fsv (rmtree) or $FOO.sav (single file)
//extensions are strictly implicit to limit damage.
const char * fname ;
flocation_t loc ;
if ( ! * savename | | * savename = = ' . ' | | strchr ( savename , ' / ' ) | | strchr ( savename , ' \\ ' ) )
{
Con_Printf ( " \" %s \" is not a valid saved game name to delete \n " , savename ) ;
return ;
}
fname = va ( " saves/%s/info.fsv " , savename ) ;
if ( FS_FLocateFile ( fname , FSLF_IGNORELINKS | FSLF_DONTREFERENCE , & loc ) )
{
fname = va ( " saves/%s/ " , savename ) ;
if ( FS_RemoveTree ( loc . search - > handle , fname ) )
Con_Printf ( " Removed %s \n " , fname ) ;
else
Con_Printf ( " Unable to remove %s \n " , fname ) ;
}
# ifndef QUAKETC
fname = va ( " %s.sav " , savename ) ;
if ( FS_FLocateFile ( fname , FSLF_IGNORELINKS | FSLF_DONTREFERENCE , & loc ) )
{
if ( loc . search - > handle - > RemoveFile & & loc . search - > handle - > RemoveFile ( loc . search - > handle , fname ) )
Con_Printf ( " Removed %s \n " , fname ) ;
else
Con_Printf ( " Unable to remove %s \n " , fname ) ;
}
# endif
2004-08-23 00:15:46 +00:00
}
# endif