r2274 - in branches/nexuiz-2.0/data: . qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Apr 1 08:39:08 EDT 2007
Author: div0
Date: 2007-04-01 08:39:08 -0400 (Sun, 01 Apr 2007)
New Revision: 2274
Modified:
branches/nexuiz-2.0/data/default.cfg
branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc
branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
Log:
g_balance_teams_complain to nag about team balance being off
Modified: branches/nexuiz-2.0/data/default.cfg
===================================================================
--- branches/nexuiz-2.0/data/default.cfg 2007-04-01 12:38:45 UTC (rev 2273)
+++ branches/nexuiz-2.0/data/default.cfg 2007-04-01 12:39:08 UTC (rev 2274)
@@ -265,6 +265,7 @@
set deathmatch_force_teamplay 0 // always play TDM on dm maps
seta g_balance_teams 0 // automatically balance out players entering instead of asking them for their preferred team
seta g_balance_teams_force 0 // automatically balance out teams when players move or disconnect
+seta g_balance_teams_complain 0 // when 1, complain when team balance is off
seta g_balance_teams_prevent_imbalance 0 // prevent players from changing to larger teams
seta g_tdm_teams 2 // how many teams are in team deathmatch
set g_changeteam_banned 0 // not allowed to change team
Modified: branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc 2007-04-01 12:38:45 UTC (rev 2273)
+++ branches/nexuiz-2.0/data/qcsrc/server/miscfunctions.qc 2007-04-01 12:39:08 UTC (rev 2274)
@@ -507,6 +507,7 @@
}
#define CENTERPRIO_POINT 1
+#define CENTERPRIO_REBALANCE 2
#define CENTERPRIO_VOTE 4
#define CENTERPRIO_NORMAL 5
#define CENTERPRIO_MAPVOTE 9
Modified: branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc 2007-04-01 12:38:45 UTC (rev 2273)
+++ branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc 2007-04-01 12:39:08 UTC (rev 2274)
@@ -16,13 +16,13 @@
float audit_teams_time;
float() IsTeamBalanceForced = {
+ if(!cvar("teamplay"))
+ return 0;
if(cvar("g_campaign"))
- return FALSE;
+ return 0;
if(!cvar("g_balance_teams_force"))
- return FALSE;
- if(!cvar("teamplay"))
- return FALSE;
- return TRUE;
+ return -1;
+ return 1;
}
void TeamchangeFrags(entity e)
@@ -549,7 +549,7 @@
float PlayerValue(entity p)
{
- if(IsTeamBalanceForced())
+ if(IsTeamBalanceForced() == 1)
return 1;
return 1;
}
@@ -1092,13 +1092,53 @@
centerprint(selected, m);
}
+float lastRebalanceInfo;
+void CauseRebalance(float source_team, float howmany_toomany)
+{
+ float steam;
+ entity head;
+
+ if(IsTeamBalanceForced() == 1)
+ {
+ bprint("Rebalancing Teams\n");
+ ShufflePlayerOutOfTeam(source_team);
+ }
+ else
+ {
+ if(1+floor(howmany_toomany) < cvar("g_balance_teams_complain"))
+ return;
+ if(time < lastRebalanceInfo + 90)
+ return;
+ lastRebalanceInfo = time;
+ if(source_team == 1)
+ steam = COLOR_TEAM1;
+ else if(source_team == 2)
+ steam = COLOR_TEAM2;
+ else if(source_team == 3)
+ steam = COLOR_TEAM3;
+ else if(source_team == 4)
+ steam = COLOR_TEAM4;
+ ServerConsoleEcho(strcat("Team ", ftos(source_team), " too large, complaining."), TRUE);
+ FOR_EACH_REALPLAYER(head)
+ {
+ if(head.team == steam)
+ {
+ sprint(head, "\{1}\{13}^3SERVER NOTICE:^7 One of you please change teams!\n");
+ centerprint_atprio(head, CENTERPRIO_REBALANCE, "^3SERVER NOTICE:\n\n^7Someone of you please change teams!");
+ }
+ }
+ }
+}
+
// part of g_balance_teams_force
// occasionally perform an audit of the teams to make
// sure they're more or less balanced in player count.
void AuditTeams()
{
- float numplayers, numteams, average;
- if(!IsTeamBalanceForced())
+ float numplayers, numteams, toomany;
+ float balance;
+ balance = IsTeamBalanceForced();
+ if(balance == 0)
return;
if(audit_teams_time > time)
@@ -1139,35 +1179,19 @@
if(numteams < 2)
return; // don't bother shuffling if for some reason there aren't any teams
- average = (numplayers / numteams) + 1;
+ toomany = (numplayers / numteams) + 1;
- if(average <= 0)
+ if(toomany <= 0)
return; // that's weird...
- if(c1 && c1 > average)
- {
- bprint("Rebalancing Teams\n");
- //bprint("Shuffle from team 1\n");
- ShufflePlayerOutOfTeam(1);
- }
- if(c2 && c2 > average)
- {
- bprint("Rebalancing Teams\n");
- //bprint("Shuffle from team 2\n");
- ShufflePlayerOutOfTeam(2);
- }
- if(c3 && c3 > average)
- {
- bprint("Rebalancing Teams\n");
- //bprint("Shuffle from team 3\n");
- ShufflePlayerOutOfTeam(3);
- }
- if(c4 && c4 > average)
- {
- bprint("Rebalancing Teams\n");
- //bprint("Shuffle from team 4\n");
- ShufflePlayerOutOfTeam(4);
- }
+ if(c1 && c1 >= toomany)
+ CauseRebalance(1, c1 - toomany);
+ if(c2 && c2 >= toomany)
+ CauseRebalance(2, c2 - toomany);
+ if(c3 && c3 >= toomany)
+ CauseRebalance(3, c3 - toomany);
+ if(c4 && c4 >= toomany)
+ CauseRebalance(4, c4 - toomany);
// if teams are still unbalanced, balance them further in the next audit,
// which will happen sooner (keep doing rapid audits until things are in order)
More information about the nexuiz-commits
mailing list