Made fraglogging switchable. And added it to the features-menu.

cl_fraglog is the new cvar for toggling fraglogging.
This commit is contained in:
Robin Redeker 2002-03-14 19:41:49 +00:00
parent 91ca4104a2
commit 706de39c06
2 changed files with 38 additions and 17 deletions

View file

@ -193,10 +193,11 @@ integer (string text, integer key) control_options_f =
} }
break; break;
case "cl_autorecord": case "cl_autorecord":
if(cvar("cl_autorecord") == 0) Cbuf_AddText ("toggle cl_autorecord\n");
Cbuf_AddText ("set cl_autorecord 1\n"); break;
else case "cl_fraglog":
Cbuf_AddText ("set cl_autorecord 0\n"); Cbuf_AddText ("toggle cl_fraglog\n");
break;
} }
if(!(key == QFK_RIGHT || key == QFK_LEFT)) { if(!(key == QFK_RIGHT || key == QFK_LEFT)) {
return 0; return 0;
@ -269,6 +270,8 @@ integer () options_features_draw =
tmp = cvar("cl_autorecord") != 0 ? "On" : "Off"; tmp = cvar("cl_autorecord") != 0 ? "On" : "Off";
draw_val_item (70, 60, spacing, "Auto Record", tmp); draw_val_item (70, 60, spacing, "Auto Record", tmp);
tmp = cvar("cl_fraglog") != 0 ? "On" : "Off";
draw_val_item (70, 70, spacing, "Fraglogging", tmp);
opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad); opt_cursor (62, (Menu_GetIndex() * 10) + 60 + cursor_pad);
return 1; return 1;
@ -281,6 +284,7 @@ void () options_features_menu =
Menu_CenterPic (160, 4, "gfx/p_option.lmp"); Menu_CenterPic (160, 4, "gfx/p_option.lmp");
Menu_Draw (options_features_draw); Menu_Draw (options_features_draw);
Menu_Item (54, 70, "cl_autorecord", control_options_f, 0); Menu_Item (54, 70, "cl_autorecord", control_options_f, 0);
Menu_Item (54, 80, "cl_fraglog", control_options_f, 0);
Menu_End (); Menu_End ();
}; };

View file

@ -49,6 +49,7 @@ static const char rcsid[] =
#include "QF/va.h" #include "QF/va.h"
#include "QF/vid.h" #include "QF/vid.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "QF/sys.h"
#include "bothdefs.h" #include "bothdefs.h"
#include "cl_cam.h" #include "cl_cam.h"
@ -92,7 +93,7 @@ static qboolean largegame = false;
cvar_t *cl_showscoresuid; cvar_t *cl_showscoresuid;
cvar_t *fs_fraglog; cvar_t *fs_fraglog;
cvar_t *cl_fraglog;
/* /*
Sbar_ShowTeamScores Sbar_ShowTeamScores
@ -251,6 +252,8 @@ Sbar_Init (void)
fs_fraglog = Cvar_Get ("fs_fraglog", "qw-scores.log", CVAR_NONE, NULL, fs_fraglog = Cvar_Get ("fs_fraglog", "qw-scores.log", CVAR_NONE, NULL,
"filename of the automatic frag-log"); "filename of the automatic frag-log");
cl_fraglog = Cvar_Get ("cl_fraglog", "0", CVAR_NONE, NULL,
"automatic fraglogging, non-zero value will switch it on");
} }
// drawing routines are reletive to the status bar location // drawing routines are reletive to the status bar location
@ -899,13 +902,18 @@ void
Sbar_LogFrags (void) Sbar_LogFrags (void)
{ {
char num[512]; char num[512];
VFile *file; char conv[512];
int minutes, fph, total, f, i, k, l, p; char conv2[512];
player_info_t *s; char *cp = NULL;
VFile *file = NULL;
int minutes, fph, total, f, i, k, l, p, d;
player_info_t *s = NULL;
const char *t = NULL; const char *t = NULL;
time_t tt = time(NULL); time_t tt = time(NULL);
char e_path[MAX_OSPATH]; char e_path[MAX_OSPATH];
if(!cl_fraglog->int_val) return;
memset(&e_path,0,MAX_OSPATH); memset(&e_path,0,MAX_OSPATH);
Qexpand_squiggle (fs_userpath->string, e_path); Qexpand_squiggle (fs_userpath->string, e_path);
@ -967,15 +975,24 @@ Sbar_LogFrags (void)
if(fph >= 999) fph = 999; if(fph >= 999) fph = 999;
if(fph <= -999) fph = -999; if(fph <= -999) fph = -999;
memset(&conv, 0, 512);
for (cp = (unsigned char *) s->name, d = 0; *cp; cp++, d++)
conv[d] = sys_char_map[(unsigned int)*cp];
if(s->spectator) { if(s->spectator) {
snprintf(num, sizeof (num), "%3i (spec)", s->pl); snprintf(num, sizeof (num), "%-3i%% %s (spectator)", s->pl, (char*)&conv);
} else { } else {
if(cl.teamplay) { if(cl.teamplay) {
snprintf(num, sizeof (num), "%3i %3i %4i %3i %4s %s", s->pl, fph, memset(&conv2, 0, 512);
minutes, f, s->team->value, s->name); for (cp = (unsigned char *) s->team->value, d = 0; *cp; cp++, d++)
conv2[d] = sys_char_map[(unsigned int)*cp];
snprintf(num, sizeof (num), "%-3i%% %-3i %-4i %-3i %-4s %s", s->pl, fph,
minutes, f, (char*)&conv2, (char*)&conv);
} else { } else {
snprintf(num, sizeof (num), "%3i %3i %4i %3i %s", s->pl, fph, snprintf(num, sizeof (num), "%-3i%% %-3i %-4i %-3i %s", s->pl, fph,
minutes, f, s->name); minutes, f, (char*)&conv);
} }
} }
Qwrite(file, num, strlen(num)); Qwrite(file, num, strlen(num));