r3914 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jul 25 13:28:26 EDT 2008


Author: div0
Date: 2008-07-25 13:28:26 -0400 (Fri, 25 Jul 2008)
New Revision: 3914

Modified:
   trunk/data/qcsrc/server/cl_client.qc
   trunk/data/qcsrc/server/clientcommands.qc
   trunk/data/qcsrc/server/ctf.qc
   trunk/data/qcsrc/server/domination.qc
   trunk/data/qcsrc/server/g_damage.qc
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/gamecommand.qc
   trunk/data/qcsrc/server/miscfunctions.qc
   trunk/data/qcsrc/server/teamplay.qc
Log:
possibly a LMS fix, possibly major screwage


Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/cl_client.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -1,3 +1,6 @@
+// let's abuse an existing field
+#define SPAWNPOINT_SCORE frags
+
 .float wantswelcomemessage;
 .string netname_previous;
 
@@ -77,12 +80,12 @@
 
 	for(spot = firstspot; spot; spot = spot.chain)
 	{
-		spot.frags = Spawn_Score(spot, playerlist, teamcheck);
+		spot.SPAWNPOINT_SCORE = Spawn_Score(spot, playerlist, teamcheck);
 
 		if(cvar("spawn_debugview"))
 		{
 			setmodel(spot, "models/runematch/rune.mdl");
-			if(spot.frags < mindist)
+			if(spot.SPAWNPOINT_SCORE < mindist)
 			{
 				spot.colormod = '1 0 0';
 				spot.scale = 1;
@@ -90,13 +93,13 @@
 			else
 			{
 				spot.colormod = '0 1 0';
-				spot.scale = spot.frags / mindist;
+				spot.scale = spot.SPAWNPOINT_SCORE / mindist;
 			}
 		}
 
-		if(spot.frags >= 0) // spawning allowed here
+		if(spot.SPAWNPOINT_SCORE >= 0) // spawning allowed here
 		{
-			if(spot.frags < mindist)
+			if(spot.SPAWNPOINT_SCORE < mindist)
 			{
 				// too short distance
 				spawn_allgood = FALSE;
@@ -147,7 +150,7 @@
 
 	RandomSelection_Init();
 	for(spot = firstspot; spot; spot = spot.chain)
-		RandomSelection_Add(spot, 0, pow(bound(lower, spot.frags, upper), exponent) * spot.cnt, spot.frags >= lower);
+		RandomSelection_Add(spot, 0, pow(bound(lower, spot.SPAWNPOINT_SCORE, upper), exponent) * spot.cnt, spot.SPAWNPOINT_SCORE >= lower);
 
 	return RandomSelection_chosen_ent;
 }
@@ -202,7 +205,7 @@
 
 	if(cvar("spawn_debugview"))
 	{
-		print("spot mindistance: ", ftos(spot.frags), "\n");
+		print("spot mindistance: ", ftos(spot.SPAWNPOINT_SCORE), "\n");
 
 		entity e;
 		if(teamcheck)

Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/clientcommands.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -308,8 +308,6 @@
 		}
 		sprint(self, "\n");
 #endif
-	} else if(argv(0) == "teamstatus") {
-		PrintScoreboard(self);
 	} else if(argv(0) == "voice") {
 		VoiceMessage(argv(1));
 	} else if(argv(0) == "say") {

Modified: trunk/data/qcsrc/server/ctf.qc
===================================================================
--- trunk/data/qcsrc/server/ctf.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/ctf.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -816,7 +816,7 @@
 			if(pl.iscommander) { // don't reassign if alreay there
 				return;
 			}
-			if(plmax == world || plmax.frags < pl.frags)
+			if(plmax == world || plmax.frags < pl.frags) <<<<<<<<<<<<<<<<< BROKEN in new scoring system
 				plmax = pl;
 		}
 	}

Modified: trunk/data/qcsrc/server/domination.qc
===================================================================
--- trunk/data/qcsrc/server/domination.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/domination.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -15,6 +15,8 @@
 Note: The only teams who can use dom control points are identified by spawnfunc_dom_team entities (if none exist these default to red and blue and use only quake models/sounds).
 */
 
+#define DOMPOINT_FRAGS frags
+
 void() dom_controlpoint_setup;
 
 void LogDom(string mode, float team_before, entity actor)
@@ -126,7 +128,7 @@
 	{
 		teamfragamt = cvar("g_domination_point_teamamt");
 		if(!teamfragamt)
-			teamfragamt = self.frags;
+			teamfragamt = self.DOMPOINTFRAGS;
 		TeamScore_AddToTeam(self.goalentity.team, ST_DOM_DOMPOINTS, teamfragamt);
 	}
 
@@ -151,7 +153,7 @@
 	{
 		individualfragamt = cvar("g_domination_point_amt");
 		if(!individualfragamt)
-			individualfragamt = self.frags;
+			individualfragamt = self.DOMPOINTFRAGS;
 		UpdateFrags(self.enemy, individualfragamt);
 		PlayerScore_Add(self.enemy, SP_DOM_DOMPOINTS, individualfragamt);
 	}
@@ -269,8 +271,8 @@
 	if(!self.message)
 		self.message = " has captured a control point";
 
-	if(!self.frags)
-		self.frags = 1;
+	if(!self.DOMPOINTFRAGS)
+		self.DOMPOINTFRAGS = 1;
 	if(!self.wait)
 		self.wait = 5;
 

Modified: trunk/data/qcsrc/server/g_damage.qc
===================================================================
--- trunk/data/qcsrc/server/g_damage.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/g_damage.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -107,6 +107,8 @@
 		f = 0;
 	}
 
+	attacker.totalfrags += f;
+
 	if(f)
 		UpdateFrags(attacker, f);
 }
@@ -465,8 +467,7 @@
 				else
 					bprint ("^1",s, "^1 died\n");
 			GiveFrags(targ, targ, -1);
-			// FIXME move this into winning condition checking? or allow READING of the scores?
-			if(targ.frags == -5) {
+			if(PlayerScore_Add(targ, SP_SCORE, 0) == -5) {
 				announce(targ, "announcer/male/botlike.ogg");
 			}
 

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/g_world.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -47,14 +47,14 @@
 	else
 		dprint("*** fteqcc test: same-function-twice bug got FINALLY FIXED! HOORAY!\n");
 
-	world.frags = -10;
+	world.cnt = -10;
 	world.enemy = world;
-	world.enemy.frags += 10;
-	if(world.frags > 0.2 || world.frags < -0.2) // don't error out if it's just roundoff errors
+	world.enemy.cnt += 10;
+	if(world.cnt > 0.2 || world.cnt < -0.2) // don't error out if it's just roundoff errors
 		dprint("*** fteqcc test: found += bug\n");
 	else
 		dprint("*** fteqcc test: += bug got FINALLY FIXED! HOORAY!\n");
-	world.frags = 0;
+	world.cnt = 0;
 }
 
 /**
@@ -1203,16 +1203,6 @@
 			head.winning = 1;
 }
 
-// clear frags for all players but the team given (when they ran out of spawnpoints)
-void ClearFragsForEveryoneBut(.float field, float value)
-{
-	// FIXME make this use the new score system (probably not needed any more, can just send this as an event)
-	entity head;
-	FOR_EACH_PLAYER(head)
-		if(head.field != value)
-			head.frags = max(head.frags, 0);
-}
-
 // clear the .winning flags
 void ClearWinners(void)
 {
@@ -1415,68 +1405,6 @@
 		ServerConsoleEcho(s, TRUE);
 }
 
-void PrintScoreboardFor(entity e, string name, string colorcode, float whichteam)
-{
-	// FIXME kill this, or make it support the new scoring system
-	entity head;
-	float v;
-	float teamvalue;
-	float fragtotal;
-	string s;
-	float found;
-	found = FALSE;
-	teamvalue = 0;
-	FOR_EACH_PLAYER(head)
-	{
-		if(!whichteam || head.team == whichteam)
-		{
-			if(name != "")
-				if(!found)
-					print_to(e, strcat(" ", colorcode, name, ":"));
-			found = TRUE;
-			fragtotal = fragtotal + head.frags;
-			s = ftos(head.frags);
-			s = strcat(s, "/", ftos(head.deaths));
-			s = strcat(s, " @ ", ftos(head.ping));
-			if(clienttype(head) == CLIENTTYPE_BOT)
-				s = strcat(s, "botms");
-			else
-				s = strcat(s, "ms");
-			v = PlayerValue(head);
-			teamvalue += v;
-			s = strcat(s, " / ", ftos(v));
-			print_to(e, strcat("  ", colorcode, head.netname, colorcode, " (", s, ")"));
-		}
-	}
-	if(whichteam && found)
-	{
-		s = ftos(fragtotal);
-		s = strcat(s, " / ", ftos(teamvalue));
-		print_to(e, strcat(colorcode, "  (total: ", s, ")"));
-	}
-}
-
-void PrintScoreboard(entity e)
-{
-	// FIXME kill this, or make it support the new scoring system
-	print_to(e, strcat("Time:      ", ftos(time / 60)));
-	print_to(e, strcat("Timelimit: ", ftos(cvar("timelimit"))));
-	print_to(e, strcat("Fraglimit: ", ftos(cvar("fraglimit"))));
-	print_to(e, "Scoreboard:");
-	if(teams_matter)
-	{
-		PrintScoreboardFor(e, "Red", "^1", COLOR_TEAM1);
-		PrintScoreboardFor(e, "Blue", "^4", COLOR_TEAM2);
-		PrintScoreboardFor(e, "Yellow", "^3", COLOR_TEAM3);
-		PrintScoreboardFor(e, "Pink", "^6", COLOR_TEAM4);
-	}
-	else
-	{
-		PrintScoreboardFor(e, "", "^7", 0);
-	}
-	print_to(e, ".");
-}
-
 void ShuffleMaplist()
 {
 	string result;
@@ -1585,26 +1513,21 @@
 	}
 	else if(team1_score + team2_score + team3_score + team4_score == 1)
 	{
-		if(team1_score)
+		float t, i;
+		if(team1_score) t = COLOR_TEAM1;
+		if(team2_score) t = COLOR_TEAM2;
+		if(team3_score) t = COLOR_TEAM3;
+		if(team4_score) t = COLOR_TEAM4;
+		CheckAllowedTeams(world);
+		for(i = 0; i < MAX_TEAMSCORE; ++i)
 		{
-			AddWinners(team, COLOR_TEAM1);
-			ClearFragsForEveryoneBut(team, COLOR_TEAM1);
+			if(t != COLOR_TEAM1) if(c1 >= 0) TeamScore_Add(COLOR_TEAM1, i, -1000);
+			if(t != COLOR_TEAM2) if(c2 >= 0) TeamScore_Add(COLOR_TEAM2, i, -1000);
+			if(t != COLOR_TEAM3) if(c3 >= 0) TeamScore_Add(COLOR_TEAM3, i, -1000);
+			if(t != COLOR_TEAM4) if(c4 >= 0) TeamScore_Add(COLOR_TEAM4, i, -1000);
 		}
-		if(team2_score)
-		{
-			AddWinners(team, COLOR_TEAM2);
-			ClearFragsForEveryoneBut(team, COLOR_TEAM2);
-		}
-		if(team3_score)
-		{
-			AddWinners(team, COLOR_TEAM3);
-			ClearFragsForEveryoneBut(team, COLOR_TEAM3);
-		}
-		if(team4_score)
-		{
-			AddWinners(team, COLOR_TEAM4);
-			ClearFragsForEveryoneBut(team, COLOR_TEAM4);
-		}
+
+		AddWinners(team, t);
 		return WINNING_YES;
 	}
 	else

Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/gamecommand.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -48,12 +48,6 @@
 	if(GameCommand_Generic(command))
 		return;
 
-	if(argv(0) == "teamstatus")
-	{
-		PrintScoreboard(world);
-		return;
-	}
-
 	if(argv(0) == "printstats")
 	{
 		DumpStats(FALSE);

Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/miscfunctions.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -533,46 +533,6 @@
 	cvar_set("developer", ftos(dev));
 }
 
-#if 0
-void DistributeFragsAmongTeam(entity p, float targetteam, float factor)
-{
-	float nTeam;
-	entity head;
-	float f;
-
-	if(!teams_matter)
-		return;
-
-	//if(p.frags < 0)
-	//{
-	//	p.frags = 0; // do not harm the new team!
-	//	return; // won't distribute negative scores
-	//}
-
-	if(p.frags == -666)
-		return;
-
-	f = ceil(factor * p.frags);
-	p.frags = p.frags - f;
-
-	nTeam = 0;
-	FOR_EACH_PLAYER(head)
-		if(head != p)
-			if(head.team == targetteam)
-				nTeam = nTeam + 1;
-
-	if(nTeam == 0)
-		return;
-
-	DistributeEvenly_Init(f, nTeam);
-
-	FOR_EACH_PLAYER(head)
-		if(head != p)
-			if(head.team == targetteam)
-				head.frags = head.frags + DistributeEvenly_Get(1);
-}
-#endif
-
 string Team_ColorCode(float teamid)
 {
 	if(teamid == COLOR_TEAM1)

Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2008-07-25 17:08:00 UTC (rev 3913)
+++ trunk/data/qcsrc/server/teamplay.qc	2008-07-25 17:28:26 UTC (rev 3914)
@@ -386,27 +386,36 @@
 	{
 		if(self.classname == "observer")
 		{
-			// FIXME this is broken for LMS, fix it
-			if(g_lms && self.frags <= 0 && self.frags > -666)
-				return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players"));
-			else if(g_lms && self.frags == -666)
-				return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players"));
+			if(g_lms)
+			{
+				float p;
+				p = PlayerScore_Add(self, SP_LMS_PLACE, 0);
+				if(p >= 666)
+					return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1Match has already begun\nwait for next round\n\n\n^7press attack to spectate other players"));
+				else if(p > 0)
+					return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "^1You have no more lives left\nwait for next round\n\n\n^7press attack to spectate other players"));
+			}
 		}
 		else if(self.classname == "spectator")
 		{
-			// FIXME this is broken for LMS, fix it
-			if ((g_lms && self.frags < 1) || g_arena)
-				return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode"));
-			else {
-				local string specString;
-				specString = strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode");
-				
-				if(time < restart_countdown) //also show the countdown when being a spectator
-					specString = strcat(specString, "\n\n^1Game starts in ", ftos(restartAnnouncer.cnt + 1), " seconds^7");
-				else if (timeoutStatus != 0)
-					specString = strcat(specString, "\n\n", getTimeoutText(1));
-				return centerprint_atprio(self, CENTERPRIO_SPAM, specString);
+			if(g_lms)
+			{
+				float p;
+				p = PlayerScore_Add(self, SP_LMS_PLACE, 0);
+				if(p)
+					return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode"));
 			}
+			if (g_arena)
+				return centerprint_atprio(self, CENTERPRIO_SPAM, strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press attack for next player\npress attack2 for free fly mode"));
+
+			local string specString;
+			specString = strcat(NEWLINES, "spectating ", self.enemy.netname, "\n\n\n^7press jump to play\n^7press attack for next player\npress attack2 for free fly mode");
+			
+			if(time < restart_countdown) //also show the countdown when being a spectator
+				specString = strcat(specString, "\n\n^1Game starts in ", ftos(restartAnnouncer.cnt + 1), " seconds^7");
+			else if (timeoutStatus != 0)
+				specString = strcat(specString, "\n\n", getTimeoutText(1));
+			return centerprint_atprio(self, CENTERPRIO_SPAM, specString);
 		}
 	}
 
@@ -1123,25 +1132,24 @@
 	lowest_player_score = 999999999;
 
 	// find the lowest-scoring player & bot of that team
-	// FIXME this is broken in new scoring system, add a helper to find the worst bot of a team
 	FOR_EACH_PLAYER(head)
 	{
 		if(head.team == steam)
 		{
 			if(head.isbot)
 			{
-				if(head.frags < lowest_bot_score)
+				if(head.totalfrags < lowest_bot_score)
 				{
 					lowest_bot = head;
-					lowest_bot_score = head.frags;
+					lowest_bot_score = head.totalfrags;
 				}
 			}
 			else
 			{
-				if(head.frags < lowest_player_score)
+				if(head.totalfrags < lowest_player_score)
 				{
 					lowest_player = head;
-					lowest_player_score = head.frags;
+					lowest_player_score = head.totalfrags;
 				}
 			}
 		}
@@ -1326,28 +1334,6 @@
 
 
 
-/*void UpdateTeamScore(entity e, float first)
-{
-	clientno = e.FIXME;
-	if(first)
-	{
-		WriteByte (MSG_ALL, SVC_UPDATENAME);
-		WriteByte (MSG_ALL, clientno);
-		WriteString (MSG_ALL, e.netname);
-
-		WriteByte (MSG_ALL, SVC_UPDATECOLORS);
-		WriteByte (MSG_ALL, clientno);
-		WriteByte (MSG_ALL, e.b_shirt * 16 + who.b_pants);
-	}
-
-	WriteByte (MSG_ALL, SVC_UPDATEFRAGS);
-	WriteByte (MSG_ALL, clientno);
-	WriteShort (MSG_ALL, e.frags + 10000);
-};
-
-*/
-
-
 // code from here on is just to support maps that don't have team entities
 void tdm_spawnteam (string teamname, float teamcolor)
 {




More information about the nexuiz-commits mailing list