r2039 - trunk/data/qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Dec 12 05:52:36 EST 2006
Author: div0
Date: 2006-12-12 05:52:36 -0500 (Tue, 12 Dec 2006)
New Revision: 2039
Modified:
trunk/data/qcsrc/server/cl_client.qc
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/g_damage.qc
trunk/data/qcsrc/server/g_world.qc
Log:
get rid of the damn LMS player count... no LMS player count, and none can be wrong...
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2006-12-12 06:25:20 UTC (rev 2038)
+++ trunk/data/qcsrc/server/cl_client.qc 2006-12-12 10:52:36 UTC (rev 2039)
@@ -777,17 +777,11 @@
if(self.frags < 1)
self.frags = 999;
- // disallow player to join after the worst player has lost g_lms_last_join lives
- // if "g_lms_join_anytime" new players spawn with same amount of lives as the worst active player
- if(((cvar("fraglimit") - cvar("g_lms_last_join")) > lms_lowest_lives && !cvar("g_lms_join_anytime")) || lms_lowest_lives < 1)
+ self.frags = LMS_NewPlayerLives();
+ if(!self.frags)
{
self.frags = -666;
- lms_dead_count += 1;
}
- else if(cvar("fraglimit") > lms_lowest_lives)
- {
- self.frags = lms_lowest_lives;
- }
}
else if(cvar("g_arena"))
{
@@ -847,10 +841,7 @@
if(self.weaponentity.lasertarget)
remove(self.weaponentity.lasertarget);
- // player was dead, decrease dead count
- if(cvar("g_lms") && self.frags < 0)
- lms_dead_count -= 1;
- else if(cvar("g_arena"))
+ if(cvar("g_arena"))
{
Spawnqueue_Unmark(self);
Spawnqueue_Remove(self);
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2006-12-12 06:25:20 UTC (rev 2038)
+++ trunk/data/qcsrc/server/defs.qh 2006-12-12 10:52:36 UTC (rev 2039)
@@ -5,9 +5,9 @@
string string_null;
float player_count;
-float lms_dead_count;
float lms_lowest_lives;
float lms_next_place;
+float() LMS_NewPlayerLives;
float team1_score, team2_score, team3_score, team4_score;
Modified: trunk/data/qcsrc/server/g_damage.qc
===================================================================
--- trunk/data/qcsrc/server/g_damage.qc 2006-12-12 06:25:20 UTC (rev 2038)
+++ trunk/data/qcsrc/server/g_damage.qc 2006-12-12 10:52:36 UTC (rev 2039)
@@ -30,7 +30,6 @@
// player has no more lives left
if (!targ.frags)
{
- lms_dead_count += 1;
if(!lms_next_place)
lms_next_place = player_count;
targ.frags = -lms_next_place;
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2006-12-12 06:25:20 UTC (rev 2038)
+++ trunk/data/qcsrc/server/g_world.qc 2006-12-12 10:52:36 UTC (rev 2039)
@@ -328,7 +328,6 @@
lightstyle(63, "a");
player_count = 0;
- lms_dead_count = 0;
lms_lowest_lives = 0;
lms_next_place = 0;
@@ -1007,59 +1006,84 @@
}
}
+float() LMS_NewPlayerLives =
+{
+ float fl;
+ fl = cvar("fraglimit");
+ if(fl == 0)
+ fl = 999;
+
+ // first player has left the game for dying too much? Nobody else can get in.
+ if(lms_lowest_lives < 1)
+ return FALSE;
+
+ if(!cvar("g_lms_join_anytime"))
+ if(lms_lowest_lives < fl - cvar("g_lms_last_join"))
+ return FALSE;
+
+ return bound(1, lms_lowest_lives, fl);
+}
+
// LMS winning condition: game terminates if and only if there's at most one
// one player who's living lives. Top two scores being equal cancels the time
// limit.
float() WinningCondition_LMS =
{
entity head;
+ float have_player;
+ float have_players;
+ float l;
- if(cvar("developer"))
+ have_player = FALSE;
+ have_players = FALSE;
+ l = LMS_NewPlayerLives();
+
+ head = find(world, classname, "player");
+ if(head)
+ have_player = TRUE;
+ head = find(head, classname, "player");
+ if(head)
+ have_players = TRUE;
+
+ if(have_player)
{
- float real_dead_count;
- float real_player_count;
- for(head = world; (head = find(head, classname, "player")); )
+ // we have at least one player
+ if(have_players)
{
- if(head.frags < 1)
- real_dead_count += 1;
- real_player_count += 1;
+ // two or more active players - continue with the game
}
- for(head = world; (head = find(head, classname, "observer")); )
+ else
{
- if(head.frags < 1)
- real_dead_count += 1;
- real_player_count += 1;
+ // exactly one player?
+ if(l)
+ {
+ // but no game has taken place yet
+ }
+ else
+ {
+ // a winner!
+ SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
+ dprint("Have a winner, ending game.\n");
+ return WINNING_YES;
+ }
}
- for(head = world; (head = find(head, classname, "spectator")); )
+ }
+ else
+ {
+ // nobody is playing at all...
+ if(l)
{
- if(head.frags < 1)
- real_dead_count += 1;
- real_player_count += 1;
+ // wait for players...
}
-
- if(player_count != real_player_count)
+ else
{
- dprint("ERROR: ", ftos(player_count), " is not ");
- dprint(ftos(real_player_count), " -> player count mismatch\n");
+ // SNAFU (maybe a draw game?)
+ ClearWinners();
+ dprint("No players, ending game.\n");
+ return WINNING_YES;
}
-
- if(lms_dead_count != real_dead_count)
- {
- dprint("ERROR: ", ftos(lms_dead_count), " is not ");
- dprint(ftos(real_dead_count), " -> dead count mismatch\n");
- }
}
- if(player_count > 1 && lms_dead_count >= player_count - 1)
- return WINNING_YES; // He's the last man standing!
-
- if((player_count == 1 && lms_dead_count == 1))
- return WINNING_YES; // All dead... (n:n is handled by the test above)
-
- // dprint("player count = "); dprint(ftos(player_count));
- // dprint(", dead count = "); dprint(ftos(lms_dead_count));
- // dprint("\n");
-
// When we get here, we have at least two players who are actually LIVING,
// or one player who is still waiting for a victim to join the server. Now
// check if the top two players have equal score.
More information about the nexuiz-commits
mailing list