Added fraglogdir cvar.

This commit is contained in:
Anton E. Gavrilov 2000-03-31 13:28:23 +00:00
parent 31f07e9ab2
commit 9a9b1a01be
2 changed files with 40 additions and 10 deletions

View file

@ -127,6 +127,8 @@ void SV_Logfile_f (void)
}
extern cvar_t *sv_fraglogdir;
/*
============
SV_Fraglogfile_f
@ -135,7 +137,8 @@ SV_Fraglogfile_f
void SV_Fraglogfile_f (void)
{
char name[MAX_OSPATH];
int i;
char dir[MAX_OSPATH];
int i, len;
if (sv_fraglogfile)
{
@ -145,10 +148,42 @@ void SV_Fraglogfile_f (void)
return;
}
strncpy(dir, sv_fraglogdir->string, sizeof(dir));
if (dir[sizeof(dir)-1] || strstr(dir, ".."))
dir[0] = 0;
if (dir[0] == 0) // empty or invalid fraglogdir - use com_gamedir
{
i = MAX_OSPATH;
strcpy(dir, com_gamedir);
}
else if (dir[0] == '/' || dir[1] == ':') // e.g. A: (DOS or Win32)
{
i = 0;
}
else
{
i = strlen(com_gamedir);
strncpy(dir, va("%s/%s", com_gamedir, dir), sizeof(dir));
}
// Make sure fraglogdir exists
// FIXME: use Sys_CreatePath or something?
for (len = strlen(dir); i < len; i++)
{
if (dir[i] == '/')
{
dir[i] = 0;
Sys_mkdir(dir);
dir[i] = '/';
}
}
Sys_mkdir(va("%s", dir));
// find an unused name
for (i=0 ; i<1000 ; i++)
{
snprintf(name, sizeof(name), "%s/frag_%i.log", com_gamedir, i);
snprintf(name, sizeof(name), "%s/frag_%i.log", dir, i);
sv_fraglogfile = Qopen (name, "r");
if (!sv_fraglogfile)
{ // can't read it, so create this one

View file

@ -73,26 +73,19 @@ cvar_t *password;
//cvar_t spectator_password = {"spectator_password", ""}; // password for entering as a sepctator
cvar_t *spectator_password;
//cvar_t allow_download = {"allow_download", "1"};
cvar_t *allow_download;
//cvar_t allow_download_skins = {"allow_download_skins", "1"};
cvar_t *allow_download_skins;
//cvar_t allow_download_models = {"allow_download_models", "1"};
cvar_t *allow_download_models;
//cvar_t allow_download_sounds = {"allow_download_sounds", "1"};
cvar_t *allow_download_sounds;
//cvar_t allow_download_maps = {"allow_download_maps", "1"};
cvar_t *allow_download_maps;
//cvar_t sv_highchars = {"sv_highchars", "1"};
cvar_t *sv_highchars;
//cvar_t sv_phs = {"sv_phs", "1"};
cvar_t *sv_phs;
//cvar_t pausable = {"pausable", "1"};
cvar_t *pausable;
cvar_t *sv_fraglogdir;
//
// game rules mirrored in svs.info
@ -1432,6 +1425,8 @@ void SV_InitLocal (void)
pausable = Cvar_Get ("pausable","1",0,"None");
sv_fraglogdir = Cvar_Get ("fraglogdir","",0,"Where to store fraglog files");
Cmd_AddCommand ("addip", SV_AddIP_f);
Cmd_AddCommand ("removeip", SV_RemoveIP_f);
Cmd_AddCommand ("listip", SV_ListIP_f);