void sortteams(vector<teamscore> &teamscores) { if(cmode && cmode->hidefrags()) cmode->getteamscores(teamscores); loopv(players) { fpsent *o = players[i]; teamscore *ts = NULL; loopv(teamscores) if(!strcmp(teamscores[i].team, o->team)) { ts = &teamscores[i]; break; } if(!ts) teamscores.add(teamscore(o->team, cmode && cmode->hidefrags() ? 0 : o->frags)); else if(!cmode || !cmode->hidefrags()) ts->score += o->frags; } teamscores.sort(teamscore::compare); }
int setscore(int team, int score) { if(team >= 1 && team <= 2) return scores[team-1] = score; return 0; } int addscore(int team, int score) { if(team >= 1 && team <= 2) return scores[team-1] += score; return 0; } bool hidefrags() { return true; } int getteamscore(const char *team) { return totalscore(ctfteamflag(team)); } void getteamscores(vector<teamscore> &tscores) { loopk(2) if(scores[k]) tscores.add(teamscore(ctfflagteam(k+1), scores[k])); } bool insidebase(const flag &f, const vec &o) { float dx = (f.spawnloc.x-o.x), dy = (f.spawnloc.y-o.y), dz = (f.spawnloc.z-o.z); return dx*dx + dy*dy <= BASERADIUS*BASERADIUS && fabs(dz) <= BASEHEIGHT; } };