r3973 - in trunk: Docs data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Jul 29 08:45:33 EDT 2008
Author: div0
Date: 2008-07-29 08:45:33 -0400 (Tue, 29 Jul 2008)
New Revision: 3973
Modified:
trunk/Docs/eventlog.txt
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/scores.qc
trunk/data/qcsrc/server/scores.qh
Log:
add scores output
Modified: trunk/Docs/eventlog.txt
===================================================================
--- trunk/Docs/eventlog.txt 2008-07-29 08:30:12 UTC (rev 3972)
+++ trunk/Docs/eventlog.txt 2008-07-29 12:45:33 UTC (rev 3973)
@@ -40,8 +40,10 @@
:ctf:returned:<flagcolor>
:dom:taken:<previouscolor>:<ID of player>
:scores:<gametype>_<mapname>:<map runtime>
- :player:<frags>:<deaths>:<playtime>:<team>:<ID>:<nickname>
- :teamscores:<team1color>:<team1score>:<team2color>:<team2score>:...
+ :labels:player:<head1><flags>,<head2><flags>,...
+ :player:see-labels:<score1>,<score2>,...:<playtime>:<team>:<ID>:<nickname>
+ :labels:team:<head1><flags>,<head2><flags>,...
+ :teamscores:see-labels:<score1>,<score2>,...:<team>
:end
:restart
:gameover
@@ -70,6 +72,13 @@
10 = Pink Team
13 = Yellow Team
+label flags:
+ !! = primary sorting key
+ <!! = primary sorting key, lower is better
+ ! = secondary sorting key
+ <! = secondary sorting key, lower is better
+ < = lower is better
+
itemstring:
<weaponid><flags>
or
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2008-07-29 08:30:12 UTC (rev 3972)
+++ trunk/data/qcsrc/server/g_world.qc 2008-07-29 12:45:33 UTC (rev 3973)
@@ -936,6 +936,7 @@
local float to_console;
local float to_eventlog;
local float to_file;
+ local float i;
to_console = cvar("sv_logscores_console");
to_eventlog = cvar("sv_eventlog");
@@ -974,14 +975,20 @@
fputs(file, strcat(s, "\n"));
}
+ s = strcat(":labels:player:", GetPlayerScoreString(world));
+ if(to_console)
+ ServerConsoleEcho(s, TRUE);
+ if(to_eventlog)
+ GameLogEcho(s, TRUE);
+ if(to_file)
+ fputs(file, strcat(s, "\n"));
+
FOR_EACH_CLIENT(other)
{
// FIXME make this use the new score system
- /*
if ((clienttype(other) == CLIENTTYPE_REAL) || (clienttype(other) == CLIENTTYPE_BOT && cvar("sv_logscores_bots")))
{
- s = strcat(":player:", ftos(other.frags), ":");
- s = strcat(s, ftos(other.deaths), ":");
+ s = strcat(":player:see-labels:", GetPlayerScoreString(other), ":");
s = strcat(s, ftos(rint(time - other.jointime)), ":");
s = strcat(s, ftos(other.team), ":");
@@ -992,25 +999,30 @@
if(to_file)
fputs(file, strcat(s, other.netname, "\n"));
}
- */
}
- /*
- if(g_ctf)
- if(cvar("g_ctf_win_mode") != 2)
+ if(teamplay)
{
- s = strcat(":teamscores:", ftos(COLOR_TEAM1), ":");
- s = strcat(s, ftos(caps_team1), ":");
- s = strcat(s, ftos(COLOR_TEAM2), ":");
- s = strcat(s, ftos(caps_team2));
+ s = strcat(":labels:team:", GetTeamScoreString(0));
if(to_console)
ServerConsoleEcho(s, TRUE);
if(to_eventlog)
GameLogEcho(s, TRUE);
if(to_file)
fputs(file, strcat(s, "\n"));
+
+ for(i = 1; i < 16; ++i)
+ {
+ s = strcat(":team:see-labels:", GetTeamScoreString(i));
+ s = strcat(s, ":", ftos(i));
+ if(to_console)
+ ServerConsoleEcho(s, TRUE);
+ if(to_eventlog)
+ GameLogEcho(s, TRUE);
+ if(to_file)
+ fputs(file, strcat(s, "\n"));
+ }
}
- */
if(to_console)
ServerConsoleEcho(":end", FALSE);
Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc 2008-07-29 08:30:12 UTC (rev 3972)
+++ trunk/data/qcsrc/server/scores.qc 2008-07-29 12:45:33 UTC (rev 3973)
@@ -359,3 +359,118 @@
}
}
}
+
+string GetScoreLogLabel(string label, float fl)
+{
+ if(fl & SFL_LOWER_IS_BETTER)
+ label = strcat(label, "<");
+ if(fl & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_PRIMARY)
+ label = strcat(label, "!!");
+ else if(fl & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_SECONDARY)
+ label = strcat(label, "!");
+ return label;
+}
+
+string GetPlayerScoreString(entity pl)
+{
+ string out;
+ entity sk;
+ float i, f;
+ string l;
+
+ out = "";
+ if(!pl)
+ {
+ // label
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_PRIMARY)
+ {
+ f = scores_flags[i];
+ l = scores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_SECONDARY)
+ {
+ f = scores_flags[i];
+ l = scores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_PRIMARY)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_SECONDARY)
+ {
+ f = scores_flags[i];
+ l = scores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ out = substring(out, 0, strlen(out) - 1);
+ }
+ else if((sk = pl.scorekeeper))
+ {
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_PRIMARY)
+ out = strcat(out, ftos(sk.(scores[i])), ",");
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_SECONDARY)
+ out = strcat(out, ftos(sk.(scores[i])), ",");
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_PRIMARY)
+ if(scores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_SECONDARY)
+ out = strcat(out, ftos(sk.(scores[i])), ",");
+ out = substring(out, 0, strlen(out) - 1);
+ }
+ return out;
+}
+
+string GetTeamScoreString(float tm)
+{
+ string out;
+ entity sk;
+ float i, f;
+ string l;
+
+ out = "";
+ if(tm == 0)
+ {
+ // label
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_PRIMARY)
+ {
+ f = teamscores_flags[i];
+ l = teamscores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_SECONDARY)
+ {
+ f = teamscores_flags[i];
+ l = teamscores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ for(i = 0; i < MAX_SCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_PRIMARY)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_SECONDARY)
+ {
+ f = teamscores_flags[i];
+ l = teamscores_label[i];
+ out = strcat(out, GetScoreLogLabel(l, f), ",");
+ }
+ out = substring(out, 0, strlen(out) - 1);
+ }
+ else if((sk = teamscorekeepers[tm - 1]))
+ {
+ for(i = 0; i < MAX_TEAMSCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_PRIMARY)
+ out = strcat(out, ftos(sk.(teamscores[i])), ",");
+ for(i = 0; i < MAX_TEAMSCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK == SFL_SORT_PRIO_SECONDARY)
+ out = strcat(out, ftos(sk.(teamscores[i])), ",");
+ for(i = 0; i < MAX_TEAMSCORE; ++i)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_PRIMARY)
+ if(teamscores_flags[i] & SFL_SORT_PRIO_MASK != SFL_SORT_PRIO_SECONDARY)
+ out = strcat(out, ftos(sk.(teamscores[i])), ",");
+ out = substring(out, 0, strlen(out) - 1);
+ }
+ return out;
+}
Modified: trunk/data/qcsrc/server/scores.qh
===================================================================
--- trunk/data/qcsrc/server/scores.qh 2008-07-29 08:30:12 UTC (rev 3972)
+++ trunk/data/qcsrc/server/scores.qh 2008-07-29 12:45:33 UTC (rev 3973)
@@ -84,3 +84,16 @@
float WinningConditionHelper_equality; ///< 1 if and only if the top two have equal scores
float WinningConditionHelper_winnerteam; ///< the color of the winning team, or -1 if none
entity WinningConditionHelper_winner; ///< the winning player, or world if none
+
+/**
+ * Returns score strings for eventlog etc.
+ * When called with world, or 0, as argument, they return the labels in the
+ * same order.
+ * The strings are comma separated; labels that end with !! designate primary,
+ * labels that end with ! designate high priority.
+ * Labels get an appended < if the scores are better if smaller (e.g. deaths).
+ * High priorities always come first.
+ * Example label string: score!!,kills,deaths<,suicides<
+ */
+string GetPlayerScoreString(entity pl);
+string GetTeamScoreString(float tm);
More information about the nexuiz-commits
mailing list