Skip to content

Commit

Permalink
1) +commands on the cmd line now executed AFTER server.cfg
Browse files Browse the repository at this point in the history
2) Added -game cmd line switcher, because we need set gamedir before server.cfg is executed.
3) Log code clean up, fraglog now have port num in log name.
  • Loading branch information
qqshka committed Jul 27, 2008
1 parent a0d620f commit a3440e6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 55 deletions.
2 changes: 1 addition & 1 deletion source/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void Cmd_StuffCmds_f (void)
}

if (build[0])
Cbuf_InsertText (build);
Cbuf_AddText (build);

Q_free (text);
Q_free (build);
Expand Down
7 changes: 7 additions & 0 deletions source/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ void FS_Init (void)
com_base_searchpaths = com_searchpaths;

FS_Init_Commands();

i = COM_CheckParm ("-game");
if (i && i < com_argc-1)
{
FS_Gamedir (com_argv[i + 1]);
Info_SetValueForStarKey (svs.info, "*gamedir", com_argv[i + 1], MAX_SERVERINFO_STRING);
}
}

/*
Expand Down
89 changes: 35 additions & 54 deletions source/sv_ccmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,77 +82,58 @@ void SV_Logfile (int sv_log, qbool newlog)
char name[MAX_OSPATH];
int i;

// newlog - stands for: we want open new log file

if (logs[sv_log].sv_logfile)
{
//bliP: logging ->
// turn off logging

fclose (logs[sv_log].sv_logfile);
logs[sv_log].sv_logfile = NULL;

// in case of NON "newlog" we do some additional work and exit function
if (!newlog)
{
Con_Printf ("%s", logs[sv_log].message_off);
logs[sv_log].log_level = 0;
return;
}
//<-
}

// always use new log file for frag log
if (sv_log == FRAG_LOG || sv_log == MOD_FRAG_LOG)
newlog = true;

for (i = 0; i < 1000; i++)
{
for (i = 0; i < 1000; ++i)
{
snprintf (name, sizeof(name), "%s/%s%i.log",
sv_logdir.string, logs[sv_log].file_name, i); //bliP: 24/9 logdir
if (Sys_FileTime(name) == -1)
{ // can't read it, so create this one
if (!(logs[sv_log].sv_logfile = fopen (name, "w")))
i = 1000; // give error
break;
}
}
if (i == 1000)
{
Con_Printf ("Can't open any logfiles.\n");
logs[sv_log].sv_logfile = NULL;
return;
}
Con_Printf ("Logging %s to %s\n", logs[sv_log].message_on, name); //bliP: loging to logging
logs[sv_log].log_level = 1;
snprintf (name, sizeof(name), "%s/%s%d_%04d.log", sv_logdir.string, logs[sv_log].file_name, sv_port, i);

if (Sys_FileTime(name) == -1)
break; // file doesn't exist
}
else
{
//bliP: logging ->
for (i = 0; i < 1000; i++)
{
snprintf (name, sizeof(name), "%s/%s%d_%04d.log",
sv_logdir.string, logs[sv_log].file_name, sv_port, i); //bliP: 24/9 logdir
if (Sys_FileTime(name) == -1)
break; // file doesn't exist
}

if (!newlog) //use last log if possible
snprintf (name, sizeof(name), "%s/%s%d_%04d.log",
sv_logdir.string, logs[sv_log].file_name,
sv_port, (i - 1 > 0) ? i - 1 : 0); //bliP: 24/9 logdir
if (!newlog) //use last log if possible
snprintf (name, sizeof(name), "%s/%s%d_%04d.log", sv_logdir.string, logs[sv_log].file_name, sv_port, (int)max(0, i - 1));

Con_Printf ("Logging %s to %s\n", logs[sv_log].message_on, name); //bliP: loging to logging
if (!(logs[sv_log].sv_logfile = fopen (name, "a")))
{
Con_Printf ("Failed.\n");
logs[sv_log].sv_logfile = NULL;
return;
}
Con_Printf ("Logging %s to %s\n", logs[sv_log].message_on, name);

switch (sv_log)
{
case TELNET_LOG:
logs[TELNET_LOG].log_level = Cvar_Value("telnet_log_level");
break;
case CONSOLE_LOG:
logs[CONSOLE_LOG].log_level = Cvar_Value("qconsole_log_say");
break;
default:
logs[sv_log].log_level = 1;
}
//<-
if (!(logs[sv_log].sv_logfile = fopen (name, "a")))
{
Con_Printf ("Failed.\n");
logs[sv_log].sv_logfile = NULL;
return;
}

switch (sv_log)
{
case TELNET_LOG:
logs[TELNET_LOG].log_level = Cvar_Value("telnet_log_level");
break;
case CONSOLE_LOG:
logs[CONSOLE_LOG].log_level = Cvar_Value("qconsole_log_say");
break;
default:
logs[sv_log].log_level = 1;
}
}

Expand Down

0 comments on commit a3440e6

Please sign in to comment.