[nexuiz-commits] r7058 - in trunk/data: . qcsrc/client qcsrc/common qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jun 18 16:44:04 EDT 2009


Author: div0
Date: 2009-06-18 16:44:03 -0400 (Thu, 18 Jun 2009)
New Revision: 7058

Modified:
   trunk/data/defaultNexuiz.cfg
   trunk/data/qcsrc/client/Main.qc
   trunk/data/qcsrc/client/View.qc
   trunk/data/qcsrc/client/csqc_constants.qc
   trunk/data/qcsrc/client/sbar.qc
   trunk/data/qcsrc/common/constants.qh
   trunk/data/qcsrc/common/mapinfo.qc
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/constants.qh
   trunk/data/qcsrc/server/defs.qh
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/race.qc
   trunk/data/qcsrc/server/race.qh
   trunk/data/qcsrc/server/scores.qc
   trunk/data/qcsrc/server/scores.qh
   trunk/data/qcsrc/server/teamplay.qc
Log:
new parameter "leadlimit", abort the game if someone leads by that amount


Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/defaultNexuiz.cfg	2009-06-18 20:44:03 UTC (rev 7058)
@@ -24,7 +24,7 @@
 seta g_configversion 0	"Configuration file version (used to upgrade settings) 0: first run, or previous start was <2.4.1  Later, it's overridden by config.cfg, version ranges are defined in config_update.cfg"
 
 // default.cfg versioning (update using update-cvarcount.sh, run that every time after adding a new cvar)
-set cvar_check_default 4818c3038c60d7ccc5b3bfacbf13dad6
+set cvar_check_default c8e90e9a68a025f4b3fc2e6a5999baf5
 
 // Nexuiz version (formatted for machines)
 // used to determine if a client version is compatible
@@ -462,16 +462,23 @@
 set g_balance_grapplehook_health 130
 exec newhook.cfg
 
+set leadlimit 0
+
 // this means that timelimit can be overidden globally and fraglimit can be overidden for each game mode: DM/TDM, Domination, CTF, and Runematch.
 seta timelimit_override -1	"Time limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
 seta fraglimit_override -1	"Frag limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta capturelimit_override -1	"Capture limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta leadlimit_override -1	"Lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta capturelimit_override -1	"Capture limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
 seta g_ctf_capture_limit -1	"CTF capture limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta g_domination_point_limit -1	"Domination point limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta g_runematch_point_limit -1	"Runematch point limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta g_keyhunt_point_limit -1	"Keyhunt point limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta g_race_laps_limit -1	"Race laps limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
-seta g_nexball_goallimit -1 "Nexball goal limit limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_domination_point_limit -1	"Domination point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_domination_point lead_leadlimit -1	"Domination point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_runematch_point_limit -1	"Runematch point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_runematch_point_leadlimit -1	"Runematch point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_keyhunt_point_limit -1	"Keyhunt point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_keyhunt_point_leadlimit -1	"Keyhunt point lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_race_laps_limit -1	"Race laps limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_nexball_goallimit -1 "Nexball goal limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+seta g_nexball_goalleadlimit -1 "Nexball goal lead limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
 
 seta g_ctf_win_mode 0	"0: captures only, 1: captures, then points, 2: points only"
 seta g_ctf_ignore_frags 0	"1: regular frags give no points"

Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/client/Main.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -755,7 +755,7 @@
 	else
 	{
 		serverprevtime = time;
-		serverdeltatime = getstatf(STAT_SYS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+		serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
 		time = serverprevtime + serverdeltatime;
 	}
 

Modified: trunk/data/qcsrc/client/View.qc
===================================================================
--- trunk/data/qcsrc/client/View.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/client/View.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -290,7 +290,7 @@
 	dprint_load();
 	WaypointSprite_Load();
 
-	ticrate = getstatf(STAT_SYS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+	ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
 
 	// Render the Scene
 	if(!intermission || !view_set)

Modified: trunk/data/qcsrc/client/csqc_constants.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_constants.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/client/csqc_constants.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -58,6 +58,7 @@
 const float		STAT_MONSTERS					= 14;
 const float		STAT_ITEMS						= 15;
 const float		STAT_VIEWHEIGHT					= 16;
+const float		STAT_MOVEVARS_TICRATE           = 240;
 const float		STAT_MOVEVARS_TIMESCALE         = 241;
 const float		STAT_FRAGLIMIT					= 235;
 const float		STAT_TIMELIMIT					= 236;

Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/client/sbar.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -1033,10 +1033,11 @@
 	}
 
 	string str;
-	float tl, fl;
+	float tl, fl, ll;
 	str = strcat("playing on ^2", shortmapname, "^7");
 	tl = getstatf(STAT_TIMELIMIT);
 	fl = getstatf(STAT_FRAGLIMIT);
+	ll = getstatf(STAT_LEADLIMIT);
 	if(gametype == GAME_LMS)
 	{
 		if(tl > 0)
@@ -1071,6 +1072,31 @@
 					str = strcat(str, " ", scores_label[ps_primary]);
 			}
 		}
+		if(ll > 0)
+		{
+			if(tl > 0 || fl > 0)
+				str = strcat(str, " or");
+			if(teamplay)
+			{
+				str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));
+				if(teamscores_label[ts_primary] == "score")
+					str = strcat(str, " points^7");
+				else if(teamscores_label[ts_primary] == "fastest")
+					str = strcat(str, " is beaten^7");
+				else
+					str = strcat(str, " ", teamscores_label[ts_primary]);
+			}
+			else
+			{
+				str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));
+				if(scores_label[ps_primary] == "score")
+					str = strcat(str, " points^7");
+				else if(scores_label[ps_primary] == "fastest")
+					str = strcat(str, " is beaten^7");
+				else
+					str = strcat(str, " ", scores_label[ps_primary]);
+			}
+		}
 	}
 
 

Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/common/constants.qh	2009-06-18 20:44:03 UTC (rev 7058)
@@ -244,7 +244,6 @@
 
 const float STAT_KH_KEYS = 32;
 const float STAT_CTF_STATE = 33;
-const float STAT_SYS_TICRATE = 34;
 const float STAT_WEAPONS = 35;
 const float STAT_SWITCHWEAPON = 36;
 const float STAT_GAMESTARTTIME = 37;
@@ -257,6 +256,7 @@
 const float STAT_FUEL = 44;
 const float STAT_NB_METERSTART = 45;
 const float STAT_SHOTORG = 46; // compressShotOrigin
+const float STAT_LEADLIMIT = 47;
 const float CTF_STATE_ATTACK = 1;
 const float CTF_STATE_DEFEND = 2;
 const float CTF_STATE_COMMANDER = 3;

Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/common/mapinfo.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -446,6 +446,10 @@
 			cvar_set("fraglimit", sa);
 		s = cdr(s);
 	}
+
+	sa = car(s); if(sa == "") sa = "0";
+	cvar_set("leadlimit", sa);
+	s = cdr(s);
 }
 
 float MapInfo_Type_FromString(string t)

Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/cl_client.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -2218,9 +2218,9 @@
 .float items_added;
 void PlayerPreThink (void)
 {
-	self.stat_sys_ticrate = cvar("sys_ticrate");
 	self.stat_game_starttime = game_starttime;
 	self.stat_allow_oldnexbeam = cvar("g_allow_oldnexbeam");
+	self.stat_leadlimit = cvar("leadlimit");
 
 	if(blockSpectators && frametime)
 		// WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).

Modified: trunk/data/qcsrc/server/constants.qh
===================================================================
--- trunk/data/qcsrc/server/constants.qh	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/constants.qh	2009-06-18 20:44:03 UTC (rev 7058)
@@ -1,4 +1,4 @@
-string CVAR_CHECK_DEFAULT = "4818c3038c60d7ccc5b3bfacbf13dad6";
+string CVAR_CHECK_DEFAULT = "c8e90e9a68a025f4b3fc2e6a5999baf5";
 string CVAR_CHECK_WEAPONS = "4f7b4c1e2feeef4988b02a93ff35a2ca";
 
 float	FALSE					= 0;

Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/defs.qh	2009-06-18 20:44:03 UTC (rev 7058)
@@ -593,3 +593,4 @@
 
 .float damage_hits, maxdamage_fired;
 .float maycheat;
+.float stat_leadlimit;

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/g_world.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -548,7 +548,6 @@
 	Ban_LoadBans();
 
 	//initialise globals related to sv_timeout
-	sys_ticrate = cvar("sys_ticrate");
 	orig_slowmo = cvar("slowmo");
 
 	MapInfo_Enumerate();
@@ -589,7 +588,6 @@
 		}
 	}
 
-	addstat(STAT_SYS_TICRATE, AS_FLOAT, stat_sys_ticrate);
 	addstat(STAT_WEAPONS, AS_INT, weapons);
 	addstat(STAT_SWITCHWEAPON, AS_INT, switchweapon);
 	addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime);
@@ -603,6 +601,7 @@
 	addstat(STAT_DAMAGE_HITS, AS_INT, damage_hits);
  	addstat(STAT_DAMAGE_FIRED, AS_INT, maxdamage_fired);
 	addstat(STAT_SHOTORG, AS_INT, stat_shotorg);
+	addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit);
 
 	next_pingtime = time + 5;
 	InitializeEntity(self, cvar_changes_init, INITPRIO_CVARS);
@@ -1642,7 +1641,7 @@
 	ClearWinners();
 	if(WinningConditionHelper_winner)
 		WinningConditionHelper_winner.winning = TRUE;
-	if(WinningConditionHelper_equality)
+	if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore)
 		return WINNING_NEVER;
 
 	// Top two have different scores? Way to go for our beloved TIMELIMIT!
@@ -1655,7 +1654,7 @@
 }
 
 float leaderfrags;
-float WinningCondition_Scores(float limit)
+float WinningCondition_Scores(float limit, float leadlimit)
 {
 	// TODO make everything use THIS winning condition (except LMS)
 	WinningConditionHelper();
@@ -1677,9 +1676,13 @@
 	if(WinningConditionHelper_lowerisbetter)
 	{
 		WinningConditionHelper_topscore = -WinningConditionHelper_topscore;
+		WinningConditionHelper_secondscore = -WinningConditionHelper_secondscore;
 		limit = -limit;
 	}
 
+	if(WinningConditionHelper_zeroisworst)
+		leadlimit = 0; // not supported in this mode
+
 	if(g_dm || g_tdm || g_arena || (g_race && !g_race_qualifying) || g_nexball)
 	// these modes always score in increments of 1, thus this makes sense
 	{
@@ -1697,14 +1700,22 @@
 		}
 	}
 
-	return GetWinningCode(limit && WinningConditionHelper_topscore && (WinningConditionHelper_topscore >= limit), WinningConditionHelper_equality);
+	return GetWinningCode(
+		WinningConditionHelper_topscore &&
+		(
+			(limit && (WinningConditionHelper_topscore >= limit))
+			||
+			(leadlimit && (WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit))
+		),
+		WinningConditionHelper_equality
+	);
 }
 
 float WinningCondition_Race(float fraglimit)
 {
 	float wc;
 	entity p;
-	wc = WinningCondition_Scores(fraglimit);
+	wc = WinningCondition_Scores(fraglimit, 0);
 
 	// ALWAYS initiate overtime, unless EVERYONE has finished the race!
 	if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
@@ -1722,7 +1733,7 @@
 float WinningCondition_QualifyingThenRace(float limit)
 {
 	float wc;
-	wc = WinningCondition_Scores(limit);
+	wc = WinningCondition_Scores(limit, 0);
 
 	// NEVER initiate overtime
 	if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
@@ -1807,8 +1818,9 @@
 */
 void CheckRules_World()
 {
-	local float timelimit;
-	local float fraglimit;
+	float timelimit;
+	float fraglimit;
+	float leadlimit;
 
 	VoteThink();
 	MapVote_Think();
@@ -1837,6 +1849,7 @@
 
 	timelimit = cvar("timelimit") * 60;
 	fraglimit = cvar("fraglimit");
+	leadlimit = cvar("leadlimit");
 
 	if(inWarmupStage || time <= game_starttime) // NOTE: this is <= to prevent problems in the very tic where the game starts
 	{
@@ -1844,6 +1857,7 @@
 			timelimit = 0; // timelimit is not made for warmup
 		if(fraglimit > 0)
 			fraglimit = 0; // no fraglimit for now
+		leadlimit = 0; // no leadlimit for now
 	}
 
 	if(timelimit > 0)
@@ -1936,7 +1950,7 @@
 	}
 	else
 	{
-		checkrules_status = WinningCondition_Scores(fraglimit);
+		checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
 	}
 
 	if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME)

Modified: trunk/data/qcsrc/server/race.qc
===================================================================
--- trunk/data/qcsrc/server/race.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/race.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -612,6 +612,7 @@
 		g_race_qualifying = 0;
 		independent_players = 0;
 		cvar_set("fraglimit", ftos(race_fraglimit));
+		cvar_set("leadlimit", ftos(race_leadlimit));
 		ScoreRules_race();
 	}
 }

Modified: trunk/data/qcsrc/server/race.qh
===================================================================
--- trunk/data/qcsrc/server/race.qh	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/race.qh	2009-06-18 20:44:03 UTC (rev 7058)
@@ -12,6 +12,7 @@
 float race_highest_place_spawn; // number of places; a place higher gets spawned at 0
 float race_lowest_place_spawn; // where to spawn in qualifying
 float race_fraglimit;
+float race_leadlimit;
 .float race_place;
 .float race_completed;
 float race_completing;

Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/scores.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -336,6 +336,9 @@
 	string s;
 	entity p;
 	float fullstatus;
+	entity winnerscorekeeper;
+	entity secondscorekeeper;
+	entity sk;
 
 	s = GetGametype();
 	s = strcat(s, ":", cvar_string("g_nexuizversion"));
@@ -352,91 +355,110 @@
 			if(teamscorekeepers[t])
 				s = strcat(s, ":", ftos(t+1), ":", GetTeamScoreString(t+1, 1));
 
-		WinningConditionHelper_equality = 0;
-		WinningConditionHelper_winnerteam = 0;
-		for(t = 1; t < 16; ++t)
+		WinningConditionHelper_winnerteam = -1;
+		WinningConditionHelper_secondteam = -1;
+		winnerscorekeeper = world;
+		secondscorekeeper = world;
+		for(t = 0; t < 16; ++t)
 		{
-			entity sk1, sk2;
-			sk1 = teamscorekeepers[WinningConditionHelper_winnerteam];
-			sk2 = teamscorekeepers[t];
-			c = TeamScore_Compare(sk1, sk2);
-			if(c == 0)
-				WinningConditionHelper_equality = 1;
-			else if(c < 0)
+			sk = teamscorekeepers[t];
+			c = TeamScore_Compare(winnerscorekeeper, sk);
+			if(c < 0)
 			{
-				WinningConditionHelper_equality = 0;
-				WinningConditionHelper_winnerteam = t;
+				WinningConditionHelper_secondteam = WinningConditionHelper_winnerteam;
+				WinningConditionHelper_winnerteam = t + 1;
+				secondscorekeeper = winnerscorekeeper;
+				winnerscorekeeper = sk;
 			}
+			else
+			{
+				c = TeamScore_Compare(secondscorekeeper, sk);
+				if(c < 0)
+				{
+					WinningConditionHelper_secondteam = t + 1;
+					secondscorekeeper = sk;
+				}
+			}
 		}
 
-		WinningConditionHelper_topscore = teamscorekeepers[WinningConditionHelper_winnerteam].teamscores_primary;
+		WinningConditionHelper_equality = (TeamScore_Compare(winnerscorekeeper, secondscorekeeper) == 0);
+		if(WinningConditionHelper_equality)
+			WinningConditionHelper_winnerteam = WinningConditionHelper_secondteam = -1;
+
+		WinningConditionHelper_topscore = winnerscorekeeper.teamscores_primary;
+		WinningConditionHelper_secondscore = secondscorekeeper.teamscores_primary;
 		WinningConditionHelper_lowerisbetter = (teamscores_flags_primary & SFL_LOWER_IS_BETTER);
 		WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
 
-		if(teamscores_flags_primary & SFL_TIME)
-			WinningConditionHelper_topscore /= 10;
-
-		if(WinningConditionHelper_equality)
-			WinningConditionHelper_winnerteam = -1;
-
-		WinningConditionHelper_winner = world;
-		if(WinningConditionHelper_equality)
-			WinningConditionHelper_winnerteam = -1;
-		else
-			++WinningConditionHelper_winnerteam; // map to Nexuiz team numbers (as opposed to colors)
-
-		if(WinningConditionHelper_topscore == 0)
-		{
-			if(scores_flags_primary & SFL_ZERO_IS_WORST)
-			{
-				if(WinningConditionHelper_lowerisbetter)
-					WinningConditionHelper_topscore = 999999999;
-				else
-					WinningConditionHelper_topscore = -999999999;
-			}
-			WinningConditionHelper_equality = 0;
-		}
+		WinningConditionHelper_winner = world; // not supported in teamplay
+		WinningConditionHelper_second = world; // not supported in teamplay
 	}
 	else
 	{
-		WinningConditionHelper_equality = 0;
 		WinningConditionHelper_winner = world;
+		WinningConditionHelper_second = world;
+		winnerscorekeeper = world;
+		secondscorekeeper = world;
 		FOR_EACH_PLAYER(p)
 		{
-			c = PlayerScore_Compare(WinningConditionHelper_winner.scorekeeper, p.scorekeeper);
-			if(c == 0)
-				WinningConditionHelper_equality = 1;
-			else if(c < 0)
+			sk = p.scorekeeper;
+			c = PlayerScore_Compare(winnerscorekeeper, sk);
+			if(c < 0)
 			{
-				WinningConditionHelper_equality = 0;
+				WinningConditionHelper_second = WinningConditionHelper_winner;
 				WinningConditionHelper_winner = p;
+				secondscorekeeper = winnerscorekeeper;
+				winnerscorekeeper = sk;
 			}
+			else
+			{
+				c = PlayerScore_Compare(secondscorekeeper, sk);
+				if(c < 0)
+				{
+					WinningConditionHelper_second = p;
+					secondscorekeeper = sk;
+				}
+			}
 		}
 
-		WinningConditionHelper_topscore = WinningConditionHelper_winner.scorekeeper.scores_primary;
+		WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper) == 0);
+		if(WinningConditionHelper_equality)
+			WinningConditionHelper_winner = WinningConditionHelper_second = world;
+
+		WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
+		WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
 		WinningConditionHelper_lowerisbetter = (scores_flags_primary & SFL_LOWER_IS_BETTER);
-		WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
+		WinningConditionHelper_zeroisworst = (scores_flags_primary & SFL_ZERO_IS_WORST);
 
-		if(teamscores_flags_primary & SFL_TIME)
-			WinningConditionHelper_topscore /= 10;
+		WinningConditionHelper_winnerteam = -1; // no teamplay
+		WinningConditionHelper_secondteam = -1; // no teamplay
+	}
 
-		WinningConditionHelper_winnerteam = -1;
-		if(WinningConditionHelper_equality)
-			WinningConditionHelper_winner = world;
+	if(teamscores_flags_primary & SFL_TIME)
+		WinningConditionHelper_topscore /= 10;
 
-		if(WinningConditionHelper_topscore == 0)
+	if(WinningConditionHelper_topscore == 0)
+	{
+		if(scores_flags_primary & SFL_ZERO_IS_WORST)
 		{
-			if(scores_flags_primary & SFL_ZERO_IS_WORST)
-			{
-				if(WinningConditionHelper_lowerisbetter)
-					WinningConditionHelper_topscore = 999999999;
-				else
-					WinningConditionHelper_topscore = -999999999;
-			}
-			WinningConditionHelper_equality = 0;
+			if(WinningConditionHelper_lowerisbetter)
+				WinningConditionHelper_topscore = 999999999;
+			else
+				WinningConditionHelper_topscore = -999999999;
 		}
 	}
 
+	if(WinningConditionHelper_secondscore == 0)
+	{
+		if(scores_flags_primary & SFL_ZERO_IS_WORST)
+		{
+			if(WinningConditionHelper_lowerisbetter)
+				WinningConditionHelper_secondscore = 999999999;
+			else
+				WinningConditionHelper_secondscore = -999999999;
+		}
+	}
+
 	if(worldstatus)
 		strunzone(worldstatus);
 	worldstatus = strzone(s);

Modified: trunk/data/qcsrc/server/scores.qh
===================================================================
--- trunk/data/qcsrc/server/scores.qh	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/scores.qh	2009-06-18 20:44:03 UTC (rev 7058)
@@ -88,10 +88,13 @@
  * Sets the following results for the current scores entities.
  */
 void WinningConditionHelper();
-float WinningConditionHelper_topscore;   ///< highest score
-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
+float WinningConditionHelper_topscore;      ///< highest score
+float WinningConditionHelper_secondscore;   ///< second highest score
+float WinningConditionHelper_winnerteam;    ///< the color of the winning team, or -1 if none
+float WinningConditionHelper_secondteam;    ///< the color of the second team, or -1 if none
+float WinningConditionHelper_equality;      ///< we have no winner
+entity WinningConditionHelper_winner;       ///< the winning player, or world if none
+entity WinningConditionHelper_second;       ///< the second player, or world if none
 float WinningConditionHelper_lowerisbetter; ///< lower is better, duh
 float WinningConditionHelper_zeroisworst;   ///< zero is worst, duh
 #define WINNINGCONDITIONHELPER_LOWERISBETTER_WORST 999999999

Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2009-06-18 10:37:43 UTC (rev 7057)
+++ trunk/data/qcsrc/server/teamplay.qc	2009-06-18 20:44:03 UTC (rev 7058)
@@ -163,7 +163,7 @@
 
 void InitGameplayMode()
 {
-	float fraglimit_override, timelimit_override;
+	float fraglimit_override, timelimit_override, leadlimit_override;
 
 	VoteReset();
 
@@ -201,6 +201,7 @@
 	// set both here, gamemode can override it later
 	timelimit_override = cvar("timelimit_override");
 	fraglimit_override = cvar("fraglimit_override");
+	leadlimit_override = cvar("leadlimit_override");
 
 	if(g_dm)
 	{
@@ -222,6 +223,7 @@
 		gamemode_name = "Domination";
 		ActivateTeamplay();
 		fraglimit_override = cvar("g_domination_point_limit");
+		leadlimit_override = cvar("g_domination_point_leadlimit");
 		dom_init();
 	}
 
@@ -236,9 +238,15 @@
 			g_ctf_win_mode = cvar("g_ctf_win_mode");
 		g_ctf_ignore_frags = cvar("g_ctf_ignore_frags");
 		if(g_ctf_win_mode == 2)
+		{
 			fraglimit_override = cvar("g_ctf_capture_limit");
+			leadlimit_override = cvar("g_ctf_capture_leadlimit");
+		}
 		else
+		{
 			fraglimit_override = cvar("capturelimit_override");
+			leadlimit_override = cvar("captureleadlimit_override");
+		}
 		ctf_init();
 	}
 
@@ -249,6 +257,7 @@
 		if(cvar("deathmatch_force_teamplay"))
 			ActivateTeamplay();
 		fraglimit_override = cvar("g_runematch_point_limit");
+		leadlimit_override = cvar("g_runematch_point_leadlimit");
 		runematch_init();
 	}
 
@@ -257,6 +266,7 @@
 		game = GAME_LMS;
 		gamemode_name = "Last Man Standing";
 		fraglimit_override = cvar("g_lms_lives_override");
+		leadlimit_override = 0; // not supported by LMS
 		if(fraglimit_override == 0)
 			fraglimit_override = -1;
 		lms_lowest_lives = 9999;
@@ -269,6 +279,7 @@
 		game = GAME_ARENA;
 		gamemode_name = "Arena";
 		fraglimit_override = cvar("g_arena_point_limit");
+		leadlimit_override = cvar("g_arena_point_leadlimit");
 		maxspawned = cvar("g_arena_maxspawned");
 		if(maxspawned < 2)
 			maxspawned = 2;
@@ -281,6 +292,7 @@
 		gamemode_name = "Key Hunt";
 		ActivateTeamplay();
 		fraglimit_override = cvar("g_keyhunt_point_limit");
+		leadlimit_override = cvar("g_keyhunt_point_leadlimit");
 		kh_init();
 	}
 
@@ -319,6 +331,8 @@
 		else
 			fraglimit_override = cvar("g_race_laps_limit");
 
+		leadlimit_override = 0; // currently not supported by race
+
 		if(g_race_qualifying)
 			independent_players = 1;
 
@@ -330,6 +344,7 @@
 		game = GAME_NEXBALL;
 		gamemode_name = "Nexball";
 		fraglimit_override = cvar("g_nexball_goallimit");
+		leadlimit_override = cvar("g_nexball_goalleadlimit");
 		ActivateTeamplay();
 		nb_init();
 	}
@@ -350,12 +365,16 @@
 			cvar_set("fraglimit", ftos(fraglimit_override));
 		if(timelimit_override >= 0)
 			cvar_set("timelimit", ftos(timelimit_override));
+		if(leadlimit_override >= 0)
+			cvar_set("leadlimit", ftos(leadlimit_override));
 	}
 
 	if(g_race && g_race_qualifying == 2)
 	{
 		race_fraglimit = cvar("fraglimit");
 		cvar_set("fraglimit", "0");
+		race_leadlimit = cvar("leadlimit");
+		cvar_set("leadlimit", "0");
 	}
 
 	InitializeEntity(world, default_delayedinit, INITPRIO_GAMETYPE_FALLBACK);



More information about the nexuiz-commits mailing list