From 4e62ba084fc6d2c16b3f8c6e9ff0085cb43e6035 Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Mon, 31 May 2010 19:28:16 +0000 Subject: [PATCH] points to score git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5122 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 1 + source/src/main.cpp | 6 +++--- source/src/protos.h | 2 +- source/src/scoreboard.cpp | 21 +++++++++++++-------- source/src/server.cpp | 1 + 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 9ba95c5c..04692de5 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -709,6 +709,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) ds.flags = getint(p); ds.frags = getint(p); ds.deaths = getint(p); + ds.points = getint(p); } break; } diff --git a/source/src/main.cpp b/source/src/main.cpp index 0d446559..51b169a9 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -845,9 +845,9 @@ int main(int argc, char **argv) initlog("cfg"); extern void *scoremenu, *teammenu, *ctfmenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu; - scoremenu = addmenu("score", "frags\tdeath\tratio\tpoints\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); - teammenu = addmenu("team score", "frags\tdeath\tratio\tpoints\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); - ctfmenu = addmenu("ctf score", "flags\tfrags\tdeath\tratio\tpoints\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + scoremenu = addmenu("score", "frags\tdeath\tratio\tscore\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + teammenu = addmenu("team score", "frags\tdeath\tratio\tscore\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + ctfmenu = addmenu("ctf score", "flags\tfrags\tdeath\tratio\tscore\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); servmenu = addmenu("server", NULL, true, refreshservers, serverskey); searchmenu = addmenu("search", NULL, true, refreshservers, serverskey); serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey); diff --git a/source/src/protos.h b/source/src/protos.h index 4b11316f..bd02e5f7 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -392,7 +392,7 @@ extern void votecount(int v); extern void clearvote(); // scoreboard -struct discscore { int team, flags, frags, deaths; char name[MAXNAMELEN + 1]; }; +struct discscore { int team, flags, frags, deaths, points; char name[MAXNAMELEN + 1]; }; extern vector discscores; extern void showscores(int on); extern void renderscores(void *menu, bool init); diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index f8dd9aaf..5cfd3210 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -47,7 +47,7 @@ struct teamscore { frags += d.frags; deaths += d.deaths; -// points += d.points; + points += d.points; if(m_flags) flagscore += d.flags; } }; @@ -56,6 +56,8 @@ static int teamscorecmp(const teamscore *x, const teamscore *y) { if(x->flagscore > y->flagscore) return -1; if(x->flagscore < y->flagscore) return 1; + if(x->points > y->points) return -1; + if(x->points < y->points) return 1; if(x->frags > y->frags) return -1; if(x->frags < y->frags) return 1; if(x->deaths < y->deaths) return -1; @@ -66,6 +68,8 @@ static int scorecmp(const playerent **x, const playerent **y) { if((*x)->flagscore > (*y)->flagscore) return -1; if((*x)->flagscore < (*y)->flagscore) return 1; + if((*x)->points > (*y)->points) return -1; + if((*x)->points < (*y)->points) return 1; if((*x)->frags > (*y)->frags) return -1; if((*x)->frags < (*y)->frags) return 1; if((*x)->deaths > (*y)->deaths) return 1; @@ -106,10 +110,11 @@ void renderdiscscores(int team) discscore &d = discscores[i]; sline &line = scorelines.add(); const char *spect = team_isspect(d.team) ? "\f4" : ""; - const char *sr = scoreratio(d.frags, d.deaths); +// const char *sr = scoreratio(d.frags, d.deaths); + float ratio = (float)(d.frags >= 0 ? d.frags : 0) / (float)(d.deaths > 0 ? d.deaths : 1); const char *clag = team_isspect(d.team) ? "SPECT" : ""; - if(m_flags) formatstring(line.s)("%s%d\t%d\t%d\t%s\t%s\tDISC\t\t%s", spect, d.flags, d.frags, d.deaths, sr, clag, d.name); - else formatstring(line.s)("%s%d\t%d\t%s\t%s\tDISC\t\t%s", spect, d.frags, d.deaths, sr, clag, d.name); + if(m_flags) formatstring(line.s)("%s%d\t%d\t%d\t%.1f\t%d\t%s\tDISC\t\t%s", spect, d.flags, d.frags, d.deaths, ratio, d.points, clag, d.name); + else formatstring(line.s)("%s%d\t%d\t%.1f\t%d\t%s\tDISC\t\t%s", spect, d.frags, d.deaths, ratio, d.points, clag, d.name); } } @@ -128,8 +133,8 @@ void renderscore(playerent *d) sline &line = scorelines.add(); line.bgcolor = d==player1 ? &localplayerc : NULL; string &s = line.s; - if(m_flags) formatstring(s)("%s%d\t%d\t%d\t%.1f\t%.1f\t%s\t%s\t%d\t%s%s%s", spect, d->flagscore, d->frags, d->deaths, ratio, 0.1f * d->points, clag, cping, d->clientnum, status, colorname(d), ign); - else formatstring(s)("%s%d\t%d\t%.1f\t%.1f\t%s\t%s\t%d\t%s%s%s", spect, d->frags, d->deaths, ratio, 0.1f * d->points, clag, cping, d->clientnum, status, colorname(d), ign); + if(m_flags) formatstring(s)("%s%d\t%d\t%d\t%.1f\t%d\t%s\t%s\t%d\t%s%s%s", spect, d->flagscore, d->frags, d->deaths, ratio, d->points, clag, cping, d->clientnum, status, colorname(d), ign); + else formatstring(s)("%s%d\t%d\t%.1f\t%d\t%s\t%s\t%d\t%s%s%s", spect, d->frags, d->deaths, ratio, d->points, clag, cping, d->clientnum, status, colorname(d), ign); } void renderteamscore(teamscore *t) @@ -143,8 +148,8 @@ void renderteamscore(teamscore *t) defformatstring(plrs)("(%d %s)", t->teammembers.length(), t->teammembers.length() == 1 ? "player" : "players"); // const char *sr = scoreratio(t->frags, t->deaths); float ratio = (float)(t->frags >= 0 ? t->frags : 0) / (float)(t->deaths > 0 ? t->deaths : 1); - if(m_flags) formatstring(line.s)("%d\t%d\t%d\t%.1f\t%.1f\t\t\t\t%s\t\t%s", t->flagscore, t->frags, t->deaths, ratio, 0.1f * t->points, team_string(t->team), plrs); - else formatstring(line.s)("%d\t%d\t%.1f\t%.1f\t\t\t\t%s\t\t%s", t->frags, t->deaths, ratio, 0.1f * t->points, team_string(t->team), plrs); + if(m_flags) formatstring(line.s)("%d\t%d\t%d\t%.1f\t%d\t\t\t\t%s\t\t%s", t->flagscore, t->frags, t->deaths, ratio, t->points, team_string(t->team), plrs); + else formatstring(line.s)("%d\t%d\t%.1f\t%d\t\t\t\t%s\t\t%s", t->frags, t->deaths, ratio, t->points, team_string(t->team), plrs); static color teamcolors[2] = { color(1.0f, 0, 0, 0.2f), color(0, 0, 1.0f, 0.2f) }; line.bgcolor = &teamcolors[team_base(t->team)]; loopv(t->teammembers) renderscore(t->teammembers[i]); diff --git a/source/src/server.cpp b/source/src/server.cpp index 299ec560..2c5b9b5a 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1952,6 +1952,7 @@ void senddisconnectedscores(int cn) putint(p, sc.flagscore); putint(p, sc.frags); putint(p, sc.deaths); + putint(p, sc.points); } } }