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
2004-11-29 01:21:00 +00:00
# ifndef CLIENTONLY
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
2014-03-31 17:06:41 +00:00
void SV_Savegame_f ( void ) ;
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
}
2014-03-30 08:55:06 +00:00
//expects the version to have already been parsed
void SV_Loadgame_Legacy ( char * filename , vfsfile_t * f , int version )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
//FIXME: Multiplayer save probably won't work with spectators.
2004-08-23 00:15:46 +00:00
char mapname [ MAX_QPATH ] ;
2014-03-30 08:55:06 +00:00
float time ;
2004-08-23 00:15:46 +00:00
char str [ 32768 ] ;
int i ;
edict_t * ent ;
int pt ;
2014-03-30 08:55:06 +00:00
int lstyles ;
2004-08-23 00:15:46 +00:00
int slots ;
client_t * cl ;
int clnum ;
char plname [ 32 ] ;
int filelen , filepos ;
char * file ;
2014-09-17 03:04:08 +00:00
char * modelnames [ MAX_PRECACHE_MODELS ] ;
2016-01-18 05:22:07 +00:00
char * soundnames [ MAX_PRECACHE_SOUNDS ] ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
if ( version ! = 667 & & version ! = 5 & & version ! = 6 ) //5 for NQ, 6 for ZQ/FQ
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
VFS_CLOSE ( f ) ;
Con_TPrintf ( " Unable to load savegame of version %i \n " , version ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ; //discard comment.
Con_Printf ( " loading legacy game from %s... \n " , filename ) ;
2004-08-23 00:15:46 +00:00
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
for ( clnum = 0 ; clnum < svs . allocated_client_slots ; clnum + + ) //clear the server for the level change.
2004-08-23 00:15:46 +00:00
{
cl = & svs . clients [ clnum ] ;
2014-03-30 08:55:06 +00:00
if ( cl - > state < = cs_loadzombie )
2004-08-23 00:15:46 +00:00
continue ;
2014-03-30 08:55:06 +00:00
# ifndef SERVERONLY
if ( cl - > netchan . remote_address . type = = NA_LOOPBACK )
CL_Disconnect ( ) ;
else
# endif
{
MSG_WriteByte ( & cl - > netchan . message , svc_stufftext ) ;
MSG_WriteString ( & cl - > netchan . message , " disconnect;wait;reconnect \n " ) ; //kindly ask the client to come again.
}
2004-08-23 00:15:46 +00:00
cl - > drop = true ;
}
SV_SendMessagesToAll ( ) ;
if ( version = = 5 | | version = = 6 )
{
2014-03-30 08:55:06 +00:00
slots = 1 ;
2013-10-29 17:38:22 +00:00
SV_UpdateMaxPlayers ( 1 ) ;
2004-08-23 00:15:46 +00:00
cl = & svs . clients [ 0 ] ;
# ifdef SERVERONLY
2014-03-30 08:55:06 +00:00
Q_strncpyz ( cl - > namebuf , " " , sizeof ( cl - > namebuf ) ) ;
2004-08-23 00:15:46 +00:00
# else
2014-03-30 08:55:06 +00:00
Q_strncpyz ( cl - > namebuf , name . string , sizeof ( cl - > namebuf ) ) ;
2004-08-23 00:15:46 +00:00
# endif
2014-03-30 08:55:06 +00:00
Q_strncpyz ( cl - > namebuf , com_token , sizeof ( cl - > namebuf ) ) ;
cl - > name = cl - > namebuf ;
cl - > state = cs_loadzombie ;
2004-08-23 00:15:46 +00:00
cl - > connection_started = realtime + 20 ;
cl - > istobeloaded = true ;
2009-11-05 03:07:52 +00:00
for ( i = 0 ; i < 16 ; i + + )
2014-03-30 08:55:06 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
cl - > spawn_parms [ i ] = atof ( str ) ;
}
2009-11-05 03:07:52 +00:00
for ( ; i < NUM_SPAWN_PARMS ; i + + )
cl - > spawn_parms [ i ] = 0 ;
2004-08-23 00:15:46 +00:00
}
2013-10-29 17:38:22 +00:00
else //fte saves ALL the clients on the server.
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , str , strlen ( str ) ) ;
slots = atoi ( str ) ;
2004-08-23 00:15:46 +00:00
if ( ! slots ) //err
{
2014-03-30 08:55:06 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
Con_Printf ( " Corrupted save game " ) ;
return ;
}
2013-10-29 17:38:22 +00:00
SV_UpdateMaxPlayers ( slots ) ;
2004-08-23 00:15:46 +00:00
for ( clnum = 0 ; clnum < sv . allocated_client_slots ; clnum + + ) //work out which players we had when we saved, and hope they accepted the reconnect.
{
cl = & svs . clients [ clnum ] ;
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , plname , sizeof ( plname ) ) ;
2004-08-23 00:15:46 +00:00
cl - > istobeloaded = false ;
cl - > state = cs_free ;
COM_Parse ( plname ) ;
if ( ! * com_token )
continue ;
2014-03-30 08:55:06 +00:00
Q_strncpyz ( cl - > namebuf , com_token , sizeof ( cl - > namebuf ) ) ;
cl - > name = cl - > namebuf ;
cl - > state = cs_loadzombie ;
2004-08-23 00:15:46 +00:00
cl - > connection_started = realtime + 20 ;
2005-07-03 15:16:20 +00:00
cl - > istobeloaded = true ;
2014-09-02 02:44:43 +00:00
cl - > userid = 0 ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
//probably should be 32, rather than NUM_SPAWN_PARMS(64)
2004-08-23 00:15:46 +00:00
for ( i = 0 ; i < NUM_SPAWN_PARMS ; i + + )
2014-03-30 08:55:06 +00:00
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
cl - > spawn_parms [ i ] = atof ( str ) ;
}
2004-08-23 00:15:46 +00:00
}
}
if ( version = = 5 | | version = = 6 )
{
2014-03-30 08:55:06 +00:00
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 ) ;
2004-08-23 00:15:46 +00:00
if ( version = = 5 )
{
progstype = PROG_NQ ;
2014-03-30 08:55:06 +00:00
Cvar_Set ( & pr_ssqc_progs , " progs.dat " ) ; //NQ's progs.
2004-08-23 00:15:46 +00:00
}
else
{
progstype = PROG_QW ;
2014-03-30 08:55:06 +00:00
Cvar_Set ( & pr_ssqc_progs , " spprogs.dat " ) ; //zquake's single player qw progs.
2004-08-23 00:15:46 +00:00
}
pt = 0 ;
}
else
{
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
pt = atoi ( str ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
Cvar_SetValue ( Cvar_FindVar ( " skill " ) , atof ( str ) ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
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 ) ) ;
2004-08-23 00:15:46 +00:00
}
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , mapname , sizeof ( mapname ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
time = atof ( str ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
SV_SpawnServer ( mapname , NULL , false , false ) ; //always inits MAX_CLIENTS slots. That's okay, because we can cut the max easily.
if ( sv . state ! = ss_active )
{
2014-03-30 08:55:06 +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 ;
}
sv . allocated_client_slots = slots ;
// load the light styles
2014-03-30 08:55:06 +00:00
lstyles = 64 ;
for ( i = 0 ; i < lstyles ; i + + )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
if ( sv . strings . lightstyles [ i ] )
Z_Free ( ( char * ) sv . strings . lightstyles [ i ] ) ;
sv . strings . lightstyles [ i ] = Z_StrDup ( str ) ;
}
for ( ; i < MAX_LIGHTSTYLES ; i + + )
{
if ( sv . strings . lightstyles [ i ] )
Z_Free ( ( char * ) sv . strings . lightstyles [ i ] ) ;
sv . strings . lightstyles [ i ] = 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.
2014-09-17 03:04:08 +00:00
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
2014-03-30 08:55:06 +00:00
{
if ( ! sv . strings . model_precache [ i ] )
{
modelnames [ i ] = NULL ;
break ;
}
modelnames [ i ] = Z_StrDup ( sv . strings . model_precache [ i ] ) ;
2004-08-23 00:15:46 +00:00
}
2016-01-18 05:22:07 +00:00
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 ] ) ;
}
2004-08-23 00:15:46 +00:00
// load the edicts out of the savegame file
// the rest of the file is sent directly to the progs engine.
if ( version = = 5 | | version = = 6 )
Q_InitProgs ( ) ; //reinitialize progs entirly.
else
{
Q_SetProgsParms ( false ) ;
svs . numprogs = 0 ;
2014-04-24 01:53:01 +00:00
PR_Configure ( svprogfuncs , - 1 , MAX_PROGS , pr_enable_profiling . ival ) ;
2004-08-23 00:15:46 +00:00
PR_RegisterFields ( ) ;
2014-03-30 08:55:06 +00:00
PR_InitEnts ( svprogfuncs , sv . world . max_edicts ) ; //just in case the max edicts isn't set.
2004-08-23 00:15:46 +00:00
progstype = pt ; //presumably the progs.dat will be what they were before.
}
2014-03-30 08:55:06 +00:00
//reload model names.
2014-09-17 03:04:08 +00:00
for ( i = 1 ; i < MAX_PRECACHE_MODELS ; i + + )
2014-03-30 08:55:06 +00:00
{
if ( ! modelnames [ i ] )
break ;
sv . strings . model_precache [ i ] = PR_AddString ( svprogfuncs , modelnames [ i ] , 0 , false ) ;
2016-01-18 05:22:07 +00:00
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 ] ) ;
2014-03-30 08:55:06 +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 + 8 ) ;
memset ( file , 0 , filelen + 1 + 8 ) ;
strcpy ( file , " loadgame " ) ;
2014-03-30 08:55:06 +00:00
clnum = VFS_READ ( f , file + 8 , filelen ) ;
2005-07-03 15:16:20 +00:00
file [ filelen + 8 ] = ' \0 ' ;
2014-03-30 08:55:06 +00:00
sv . world . edict_size = svprogfuncs - > load_ents ( svprogfuncs , file , 0 ) ;
2004-08-23 00:15:46 +00:00
BZ_Free ( file ) ;
2015-01-02 05:20:56 +00:00
PR_LoadGlabalStruct ( false ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
pr_global_struct - > time = sv . world . physicstime = sv . time = time ;
sv . starttime = Sys_DoubleTime ( ) - sv . time ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
VFS_CLOSE ( f ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
//FIXME: DP saved games have some / *\nkey values\nkey values\n* / thing in them to save precaches and stuff
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
World_ClearWorld ( & sv . world ) ;
2004-08-23 00:15:46 +00:00
2014-03-30 08:55:06 +00:00
for ( i = 0 ; i < sv . world . num_edicts ; i + + )
2004-08-23 00:15:46 +00:00
{
ent = EDICT_NUM ( svprogfuncs , i ) ;
if ( ! ent )
break ;
if ( ent - > isfree )
continue ;
2014-03-30 08:55:06 +00:00
World_LinkEdict ( & sv . world , ( wedict_t * ) ent , false ) ;
2004-08-23 00:15:46 +00:00
}
2014-03-30 08:55:06 +00:00
sv . spawned_client_slots = 0 ;
for ( i = 0 ; i < svs . allocated_client_slots ; i + + )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
cl = & svs . clients [ i ] ;
if ( i < sv . allocated_client_slots )
{
if ( cl - > state )
sv . spawned_client_slots + = 1 ;
ent = EDICT_NUM ( svprogfuncs , i + 1 ) ;
}
else
ent = NULL ;
cl - > edict = ent ;
cl - > name = PR_AddString ( svprogfuncs , cl - > namebuf , sizeof ( cl - > namebuf ) , false ) ;
cl - > team = PR_AddString ( svprogfuncs , cl - > teambuf , sizeof ( cl - > teambuf ) , false ) ;
2016-07-12 00:40:13 +00:00
# ifdef HEXEN2
2014-03-30 08:55:06 +00:00
if ( ent )
cl - > playerclass = ent - > xv - > playerclass ;
else
cl - > playerclass = 0 ;
2016-07-12 00:40:13 +00:00
# endif
2004-08-23 00:15:46 +00:00
}
}
2014-03-30 08:55:06 +00:00
2014-03-31 17:06:41 +00:00
void SV_LegacySavegame_f ( void )
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 ;
int version = SAVEGAME_VERSION ;
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 ( Cmd_Argc ( ) ! = 2 )
{
2014-03-31 17:06:41 +00:00
Con_TPrintf ( " save <savename> : save a game \n " ) ;
2014-03-30 08:55:06 +00:00
return ;
}
if ( strstr ( Cmd_Argv ( 1 ) , " .. " ) )
{
Con_TPrintf ( " Relative pathnames are not allowed \n " ) ;
return ;
}
if ( sv . state ! = ss_active )
{
2014-03-31 17:06:41 +00:00
Con_TPrintf ( " Can't apply: Server isn't running or is still loading \n " ) ;
return ;
}
if ( sv . allocated_client_slots ! = 1 | | svs . clients - > state ! = cs_spawned )
{
//we don't care about fte-format legacy.
Con_TPrintf ( " Unable to use legacy savegame format to save multiplayer games \n " ) ;
SV_Savegame_f ( ) ;
2014-03-30 08:55:06 +00:00
return ;
}
2014-03-31 17:06:41 +00:00
sprintf ( name , " %s " , Cmd_Argv ( 1 ) ) ;
2014-04-27 23:16:07 +00:00
COM_RequireExtension ( name , " .sav " , sizeof ( name ) ) ;
2014-03-31 17:06:41 +00:00
if ( ! FS_NativePath ( name , FS_GAMEONLY , native , sizeof ( native ) ) )
return ;
Con_TPrintf ( U8 ( " Saving game to %s... \n " ) , native ) ;
f = FS_OpenVFS ( name , " wb " , FS_GAMEONLY ) ;
2014-03-30 08:55:06 +00:00
if ( ! f )
{
2014-03-31 17:06:41 +00:00
Con_TPrintf ( " ERROR: couldn't open %s. \n " , name ) ;
2014-03-30 08:55:06 +00:00
return ;
}
//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 )
version = 6 ;
else
version = 5 ;
}
}
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
if ( version ! = SAVEGAME_VERSION )
{
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 + + )
{
if ( cl - > state < cs_spawned & & ! cl - > istobeloaded ) //don't save if they are still connecting
{
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
{
2014-03-31 17:06:41 +00:00
if ( sv . strings . lightstyles [ i ] & & * sv . strings . lightstyles [ i ] )
VFS_PRINTF ( f , " %s \n " , sv . strings . lightstyles [ i ] ) ;
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 " ) ;
2015-01-08 13:09:20 +00:00
/*
// DarkPlaces extended savegame
sv . lightstyles % i % s
sv . model_precache % i % s
sv . sound_precache % i % s
sv . buffer % i % i " string "
sv . bufstr % i % i " %s "
*/
2014-03-30 08:55:06 +00:00
svprogfuncs - > parms - > memfree ( s ) ;
2014-03-31 17:06:41 +00:00
VFS_CLOSE ( f ) ;
2014-03-30 08:55:06 +00:00
}
2004-08-23 00:15:46 +00:00
2015-01-08 13:09:20 +00:00
# define CACHEGAME_VERSION_OLD 513
# define CACHEGAME_VERSION_VERBOSE 514
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 ;
2004-08-23 00:15:46 +00:00
int filelen , filepos ;
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
{
2013-12-08 20:06:55 +00:00
flocation_t loc ;
2004-08-23 00:15:46 +00:00
SV_SpawnServer ( level , startspot , false , false ) ;
2009-11-04 21:16:50 +00:00
World_ClearWorld ( & sv . world ) ;
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 ;
}
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 ) ;
2015-01-08 13:09:20 +00:00
if ( version ! = CACHEGAME_VERSION_OLD )
2004-08-23 00:15:46 +00:00
{
2005-12-21 03:07:33 +00:00
VFS_CLOSE ( f ) ;
2015-01-08 13:09:20 +00:00
Con_TPrintf ( " Savegame is version %i, not %i \n " , version , CACHEGAME_VERSION_OLD ) ;
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 ( ) ;
2005-12-21 03:07:33 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
pt = atof ( str ) ;
2004-08-23 00:15:46 +00:00
// this silliness is so we can load 1.06 save files, which have float skill values
2005-12-21 03:07:33 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
current_skill = ( int ) ( atof ( str ) + 0.1 ) ;
2004-08-23 00:15:46 +00:00
Cvar_Set ( & skill , va ( " %i " , current_skill ) ) ;
2005-12-21 03:07:33 +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
2005-12-21 03:07:33 +00:00
VFS_GETS ( f , mapname , sizeof ( mapname ) ) ;
VFS_GETS ( f , str , sizeof ( str ) ) ;
time = atof ( str ) ;
2005-07-03 15:16:20 +00:00
2004-08-23 00:15:46 +00:00
SV_SpawnServer ( mapname , startspot , false , false ) ;
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 ;
}
// sv.paused = true; // pause until all clients connect
// sv.loadgame = true;
// load the light styles
2006-01-11 22:25:46 +00:00
VFS_GETS ( f , str , sizeof ( str ) ) ;
2012-09-30 05:52:03 +00:00
numstyles = atoi ( str ) ;
if ( numstyles > MAX_LIGHTSTYLES )
2006-01-11 22:25:46 +00:00
{
VFS_CLOSE ( f ) ;
Con_Printf ( " load failed - invalid number of lightstyles \n " ) ;
return false ;
}
2004-08-23 00:15:46 +00:00
// 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 ) ;
2014-04-24 01:53:01 +00:00
PR_Configure ( svprogfuncs , - 1 , 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
2012-09-30 05:52:03 +00:00
for ( i = 0 ; i < MAX_LIGHTSTYLES ; i + + )
2012-07-07 05:17:43 +00:00
{
if ( sv . strings . lightstyles [ i ] )
2014-03-30 08:55:06 +00:00
BZ_Free ( ( void * ) sv . strings . lightstyles [ i ] ) ;
2012-09-30 05:52:03 +00:00
sv . strings . lightstyles [ i ] = NULL ;
}
for ( i = 0 ; i < numstyles ; i + + )
{
VFS_GETS ( f , str , sizeof ( str ) ) ;
2014-03-30 08:55:06 +00:00
sv . strings . lightstyles [ i ] = Z_StrDup ( str ) ;
2012-07-07 05:17:43 +00:00
}
2012-09-30 05:52:03 +00:00
for ( ; i < MAX_LIGHTSTYLES ; i + + )
{
2014-03-30 08:55:06 +00:00
sv . strings . lightstyles [ i ] = Z_StrDup ( " " ) ;
2012-09-30 05:52:03 +00:00
}
2012-07-07 05:17:43 +00:00
2006-01-11 22:25:46 +00:00
modelpos = VFS_TELL ( f ) ;
LoadModelsAndSounds ( f ) ;
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 ' ;
2009-11-04 21:16:50 +00:00
sv . world . edict_size = svprogfuncs - > load_ents ( svprogfuncs , file , 0 ) ;
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 ;
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 ) ;
2009-11-04 21:16:50 +00:00
World_ClearWorld ( & sv . world ) ;
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 )
ent = EDICT_NUM ( svprogfuncs , i + 1 ) ;
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
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 ;
for ( j = 0 ; j < NUM_SPAWN_PARMS ; j + + )
2006-03-23 18:46:51 +00:00
{
2011-10-27 16:16:29 +00:00
if ( pr_global_ptrs - > spawnparamglobals [ j ] )
* pr_global_ptrs - > spawnparamglobals [ j ] = host_client - > spawn_parms [ j ] ;
2006-03-23 18:46:51 +00:00
}
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 ) ;
ent - > area . next = ent - > area . prev = NULL ;
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 ;
2009-11-04 21:16:50 +00:00
for ( i = 0 ; i < sv . world . num_edicts ; i + + )
2004-08-23 00:15:46 +00:00
{
ent = EDICT_NUM ( svprogfuncs , i ) ;
if ( ent - > isfree )
continue ;
2012-01-17 07:57:46 +00:00
World_LinkEdict ( & sv . world , ( wedict_t * ) ent , false ) ;
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 + + )
{
ent = EDICT_NUM ( svprogfuncs , i ) ;
if ( ent - > isfree )
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 ;
2015-01-08 13:09:20 +00:00
int version = CACHEGAME_VERSION_OLD ;
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 ) ;
2014-10-05 20:04:11 +00:00
FS_FlushFSHashReally ( true ) ;
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 ) ;
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).
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
else if ( cl - > state < cs_spawned & & ! cl - > istobeloaded ) //don't drop if they are still connecting
2012-01-24 04:24:14 +00:00
{
cl - > edict - > v - > solid = 0 ;
}
else if ( ! cl - > spectator )
{
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , cl - > edict ) ;
PR_ExecuteProgram ( svprogfuncs , pr_global_struct - > ClientDisconnect ) ;
sv . spawned_client_slots - - ;
}
else if ( SpectatorDisconnect )
{
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
pr_global_struct - > self = EDICT_TO_PROG ( svprogfuncs , cl - > edict ) ;
PR_ExecuteProgram ( svprogfuncs , SpectatorDisconnect ) ;
2013-03-12 22:35:33 +00:00
sv . spawned_observer_slots - - ;
2012-01-24 04:24:14 +00:00
}
2004-08-23 00:15:46 +00:00
}
}
2015-01-08 13:09:20 +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 ;
}
VFS_PRINTF ( f , " vmmode %s \n " , COM_QuotedString ( mode , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " skill %s \n " , COM_QuotedString ( skill . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " deathmatch %s \n " , COM_QuotedString ( deathmatch . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " coop %s \n " , COM_QuotedString ( coop . string , buf , sizeof ( buf ) , false ) ) ;
VFS_PRINTF ( f , " teamplay %s \n " , COM_QuotedString ( teamplay . string , buf , sizeof ( buf ) , false ) ) ;
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 , " map %s \n " , COM_QuotedString ( svs . name , buf , sizeof ( buf ) , false ) ) ;
2015-01-08 13:09:20 +00:00
VFS_PRINTF ( f , " time %f \n " , sv . time ) ;
for ( i = 0 ; i < MAX_LIGHTSTYLES ; i + + )
if ( sv . strings . lightstyles [ i ] )
2016-01-18 05:22:07 +00:00
VFS_PRINTF ( f , " lstyle %i %s %f %f %f \n " , i , COM_QuotedString ( sv . strings . lightstyles [ i ] , buf , sizeof ( buf ) , false ) , sv . lightstylecolours [ i ] [ 0 ] , sv . lightstylecolours [ i ] [ 1 ] , sv . lightstylecolours [ i ] [ 2 ] ) ;
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 , " model %i %s \n " , i , COM_QuotedString ( sv . strings . model_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
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 , " sound %i %s \n " , i , COM_QuotedString ( sv . strings . sound_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
for ( i = 1 ; i < MAX_SSPARTICLESPRE ; i + + )
2016-01-18 05:22:07 +00:00
if ( sv . strings . particle_precache [ i ] & & * sv . strings . particle_precache [ i ] )
2015-01-08 13:09:20 +00:00
VFS_PRINTF ( f , " particles %i %s \n " , i , sv . strings . particle_precache [ i ] ) ;
for ( i = 0 ; i < sizeof ( sv . strings . vw_model_precache ) / sizeof ( sv . strings . vw_model_precache [ 0 ] ) ; i + + )
VFS_PRINTF ( f , " vwep %i %s \n " , i , COM_QuotedString ( sv . strings . vw_model_precache [ i ] , buf , sizeof ( buf ) , false ) ) ;
//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)
//FIXME: sql queries?
//FIXME: frik files?
//FIXME: threads?
VFS_PRINTF ( f , " entities \n " ) ;
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
VFS_PRINTF ( f , " %i \n " , MAX_LIGHTSTYLES ) ;
for ( i = 0 ; i < MAX_LIGHTSTYLES ; i + + )
{
VFS_PRINTF ( f , " %s \n " , sv . strings . lightstyles [ i ] ? sv . strings . lightstyles [ i ] : " " ) ;
}
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
}
2013-08-21 07:14:39 +00:00
s = PR_SaveEnts ( svprogfuncs , NULL , & len , 0 , 1 ) ;
2010-07-25 15:06:38 +00:00
VFS_PUTS ( f , s ) ;
VFS_PUTS ( f , " \n " ) ;
2004-08-23 00:15:46 +00:00
svprogfuncs - > parms - > memfree ( s ) ;
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 + + )
{
edict_t * ed = EDICT_NUM ( svprogfuncs , clnum + 1 ) ;
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
}
2004-08-23 00:15:46 +00:00
}
# define FTESAVEGAME_VERSION 25000
2016-01-18 05:22:07 +00:00
void SV_Savegame ( const char * savename , qboolean mapchange )
2004-08-23 00:15:46 +00:00
{
extern cvar_t nomonsters ;
extern cvar_t gamecfg ;
extern cvar_t scratch1 ;
extern cvar_t scratch2 ;
extern cvar_t scratch3 ;
extern cvar_t scratch4 ;
extern cvar_t savedgamecfg ;
extern cvar_t saved1 ;
extern cvar_t saved2 ;
extern cvar_t saved3 ;
extern cvar_t saved4 ;
extern cvar_t temp1 ;
extern cvar_t noexit ;
extern cvar_t pr_maxedicts ;
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 ;
char str [ MAX_LOCALINFO_STRING + 1 ] ;
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
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 ) ;
2010-07-25 15:06:38 +00:00
f = FS_OpenVFS ( savefilename , " wb " , 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 ) ) ;
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %d \n " , FTESAVEGAME_VERSION + svs . gametype ) ;
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 )
for ( len = 0 ; len < NUM_SPAWN_PARMS ; len + + )
2009-04-01 22:03:56 +00:00
VFS_PRINTF ( f , " %i (%f) \n " , * ( int * ) & cl - > spawn_parms [ len ] , cl - > spawn_parms [ len ] ) ; //write ints as not everyone passes a float in the parms.
2004-09-20 23:25:38 +00:00
//write floats too so you can use it to debug.
2004-08-23 00:15:46 +00:00
}
Q_strncpyz ( str , svs . info , sizeof ( str ) ) ;
Info_RemovePrefixedKeys ( str , ' * ' ) ;
2010-07-25 15:06:38 +00:00
VFS_PRINTF ( f , " %s \n " , str ) ;
2004-08-23 00:15:46 +00:00
Q_strncpyz ( str , localinfo , sizeof ( str ) ) ;
Info_RemovePrefixedKeys ( str , ' * ' ) ;
2013-08-27 13:18:09 +00:00
VFS_PUTS ( f , str ) ;
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
2015-01-21 18:18:37 +00:00
# ifndef SERVERONLY
//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
{
int width ;
int height ;
2016-02-15 06:01:17 +00:00
void * rgbbuffer ;
2015-01-21 18:18:37 +00:00
image_t * img ;
//poke the various modes into redrawing the screen (without huds), to avoid any menus or console drawn over the top of the current backbuffer.
//FIXME: clear-to-black first
qboolean okay = false ;
# ifdef VM_CG
if ( ! okay & & CG_Refresh ( ) )
okay = true ;
# endif
# ifdef CSQC_DAT
if ( ! okay & & CSQC_DrawView ( ) )
okay = true ;
# endif
if ( ! okay & & r_worldentity . model )
{
V_RenderView ( ) ;
okay = true ;
}
//okay, we drew something, we're good to save a screeny.
if ( okay )
{
2015-08-14 02:46:38 +00:00
enum uploadfmt fmt ;
rgbbuffer = VID_GetRGBInfo ( & width , & height , & fmt ) ;
2015-01-21 18:18:37 +00:00
if ( rgbbuffer )
{
2016-02-15 06:01:17 +00:00
// extern cvar_t scr_sshot_type;
2016-02-10 23:23:43 +00:00
SCR_ScreenShot ( savefilename , FS_GAMEONLY , & rgbbuffer , 1 , width , height , fmt ) ;
2015-01-21 18:18:37 +00:00
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 )
{
if ( Image_UnloadTexture ( img ) )
{
//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 ) ;
}
}
}
}
}
# 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 ) ;
2014-10-05 20:04:11 +00:00
FS_FlushFSHashReally ( true ) ;
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
FS_FlushFSHashReally ( true ) ;
}
2004-08-23 00:15:46 +00:00
}
2011-06-29 18:39:11 +00:00
void SV_Savegame_f ( void )
{
2015-01-21 18:18:37 +00:00
if ( Cmd_Argc ( ) < = 2 )
2016-01-18 05:22:07 +00:00
SV_Savegame ( Cmd_Argv ( 1 ) , false ) ;
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
2016-07-12 00:40:13 +00:00
cvar_t sv_autosave = CVARD ( " sv_autosave " , " 5 " , " Interval for autosaves, in minutes. Set to 0 to disable autosave. " ) ;
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 ;
//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 + + )
{
if ( svs . clients [ i ] . state = = cs_spawned )
{
if ( svs . clients [ i ] . edict - > v - > health < = 0 )
return ; //autosaves with a dead player are just cruel.
if ( ( int ) svs . clients [ i ] . edict - > v - > flags & ( FL_GODMODE | FL_NOTARGET ) )
return ; //autosaves to highlight cheaters is also just spiteful.
if ( svs . clients [ i ] . edict - > v - > movetype ! = MOVETYPE_WALK )
return ; //noclip|fly are cheaters, toss|bounce are bad at playing. etc.
if ( ! ( ( int ) svs . clients [ i ] . edict - > v - > flags & FL_ONGROUND ) )
return ; //autosaves while people are jumping are awkward.
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
}
}
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
}
2004-08-23 00:15:46 +00:00
void SV_Loadgame_f ( void )
{
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 ;
2012-01-24 04:24:14 +00:00
int loadzombies = 0 ;
2004-08-23 00:15:46 +00:00
client_t * cl ;
2005-03-18 06:13:11 +00:00
gametype_e gametype ;
2004-08-23 00:15:46 +00:00
2009-04-01 22:03:56 +00:00
int len ;
2004-08-23 00:15:46 +00:00
Q_strncpyz ( savename , Cmd_Argv ( 1 ) , sizeof ( savename ) ) ;
if ( ! * savename | | strstr ( savename , " .. " ) )
2016-01-18 05:22:07 +00:00
strcpy ( savename , " quick " ) ;
2004-08-23 00:15:46 +00:00
2011-07-22 15:11:35 +00:00
Q_snprintfz ( filename , sizeof ( filename ) , " saves/%s/info.fsv " , savename ) ;
2010-07-25 15:06:38 +00:00
f = FS_OpenVFS ( filename , " rb " , FS_GAME ) ;
2014-03-30 08:55:06 +00:00
if ( ! f )
{
f = FS_OpenVFS ( va ( " %s.sav " , savename ) , " rb " , FS_GAME ) ;
if ( f )
Q_snprintfz ( filename , sizeof ( filename ) , " %s.sav " , savename ) ;
}
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 ) ;
2004-08-23 00:15:46 +00:00
return ;
}
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 ) ;
2005-03-18 06:13:11 +00:00
if ( version < FTESAVEGAME_VERSION | | version > = FTESAVEGAME_VERSION + GT_MAX )
2004-08-23 00:15:46 +00:00
{
2014-03-30 08:55:06 +00:00
SV_Loadgame_Legacy ( filename , f , version ) ;
2004-08-23 00:15:46 +00:00
return ;
}
2014-08-15 02:20:41 +00:00
2005-03-18 06:13:11 +00:00
gametype = version - FTESAVEGAME_VERSION ;
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
2013-10-29 17:38:22 +00:00
for ( clnum = 0 ; clnum < svs . allocated_client_slots ; clnum + + ) //clear the server for the level change.
2004-08-23 00:15:46 +00:00
{
cl = & svs . clients [ clnum ] ;
2014-03-30 08:55:06 +00:00
if ( cl - > state < = cs_loadzombie )
2004-08-23 00:15:46 +00:00
continue ;
2014-03-30 08:55:06 +00:00
# ifndef SERVERONLY
if ( cl - > netchan . remote_address . type = = NA_LOOPBACK )
2016-07-12 00:40:13 +00:00
{
// CL_Disconnect();
cl - > state = cs_zombie ;
}
2005-03-18 06:13:11 +00:00
else
2014-03-30 08:55:06 +00:00
# endif
{
if ( cl - > protocol = = SCP_QUAKE2 )
MSG_WriteByte ( & cl - > netchan . message , svcq2_stufftext ) ;
else
MSG_WriteByte ( & cl - > netchan . message , svc_stufftext ) ;
MSG_WriteString ( & cl - > netchan . message , " echo Loading Game;disconnect;wait;wait;reconnect \n " ) ; //kindly ask the client to come again.
}
2004-08-23 00:15:46 +00:00
cl - > istobeloaded = false ;
}
2016-07-12 00:40:13 +00:00
# ifndef SERVERONLY
if ( cls . state )
{
unsigned int rec = cls . demorecording ;
cls . demorecording = DPB_NONE ;
CL_Disconnect_f ( ) ;
cls . demorecording = rec ;
}
# endif
2004-08-23 00:15:46 +00:00
SV_SendMessagesToAll ( ) ;
2009-04-01 22:03:56 +00:00
VFS_GETS ( f , str , sizeof ( str ) - 1 ) ;
2004-08-23 00:15:46 +00:00
slots = atoi ( str ) ;
2013-11-29 20:35:29 +00:00
if ( slots > svs . allocated_client_slots )
SV_UpdateMaxPlayers ( slots ) ;
2004-08-23 00:15:46 +00:00
for ( cl = svs . clients , clnum = 0 ; clnum < slots ; cl + + , clnum + + )
{
if ( cl - > state > cs_zombie )
SV_DropClient ( cl ) ;
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 + + )
;
2006-01-11 22:25:46 +00:00
strcpy ( cl - > namebuf , str ) ;
cl - > name = cl - > namebuf ;
2004-08-23 00:15:46 +00:00
if ( * str )
{
2014-03-30 08:55:06 +00:00
cl - > state = cs_loadzombie ;
2004-08-23 00:15:46 +00:00
cl - > connection_started = realtime + 20 ;
cl - > istobeloaded = true ;
2014-09-02 02:44:43 +00:00
cl - > userid = 0 ;
2012-01-24 04:24:14 +00:00
loadzombies + + ;
2004-08-23 00:15:46 +00:00
memset ( & cl - > netchan , 0 , sizeof ( cl - > netchan ) ) ;
for ( len = 0 ; len < NUM_SPAWN_PARMS ; len + + )
{
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
;
if ( * trim = = ' ( ' )
cl - > spawn_parms [ len ] = atof ( trim + 1 ) ;
2004-08-23 00:15:46 +00:00
else
{
version = atoi ( str ) ;
cl - > spawn_parms [ len ] = * ( float * ) & version ;
}
}
}
}
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
Info_RemoveNonStarKeys ( svs . info ) ;
len = strlen ( svs . info ) ;
Q_strncpyz ( svs . info + len , str , sizeof ( svs . info ) - len ) ;
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
Info_RemoveNonStarKeys ( localinfo ) ;
len = strlen ( localinfo ) ;
Q_strncpyz ( localinfo + len , str , sizeof ( localinfo ) - len ) ;
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 ) ;
2004-08-23 00:15:46 +00:00
sv . allocated_client_slots = slots ;
2012-01-24 04:24:14 +00:00
sv . spawned_client_slots + = loadzombies ;
2016-01-18 05:22:07 +00:00
sv . autosave_time = sv . time + sv_autosave . value * 60 ;
2004-08-23 00:15:46 +00:00
}
# endif