r4736 - trunk/data/qcsrc/client
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Oct 13 02:04:55 EDT 2008
Author: div0
Date: 2008-10-13 02:04:55 -0400 (Mon, 13 Oct 2008)
New Revision: 4736
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/client/miscfunctions.qc
trunk/data/qcsrc/client/sbar.qc
Log:
try to improve player networking: let playerchecker do ALL the work for adding/removing players, and let scores updates JUST set the scores. Scores might come before the player, though, and a PL affected player can still get wrong scores for a short while even if networking is fixed, but well, that's PL.
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-10-12 18:01:48 UTC (rev 4735)
+++ trunk/data/qcsrc/client/Main.qc 2008-10-13 06:04:55 UTC (rev 4736)
@@ -205,7 +205,7 @@
SetTeam(playerslots[i], -1);
RemovePlayer(playerslots[i]);
playerslots[i].sort_prev = world;
- playerslots[i].gotscores = 0;
+ //playerslots[i].gotscores = 0;
}
}
else
@@ -217,8 +217,8 @@
if not(playerslots[i])
playerslots[i] = spawn();
playerslots[i].sv_entnum = i;
- playerslots[i].gotscores = 0;
- SetTeam(playerslots[i], COLOR_SPECTATOR);
+ //playerslots[i].gotscores = 0; // we might already have the scores...
+ SetTeam(playerslots[i], GetPlayerColor(i)); // will not hurt; later updates come with Sbar_UpdatePlayerTeams
RegisterPlayer(playerslots[i]);
Sbar_UpdatePlayerPos(playerslots[i]);
}
@@ -363,7 +363,7 @@
void Ent_Remove();
void Ent_ReadPlayerScore()
{
- float i, Team, n;
+ float i, n;
float isNew;
entity o;
@@ -383,17 +383,16 @@
#endif
self.sv_entnum = n;
- Team = GetPlayerColor(self.sv_entnum);
if not(playerslots[self.sv_entnum])
playerslots[self.sv_entnum] = spawn();
o = self.owner = playerslots[self.sv_entnum];
o.sv_entnum = self.sv_entnum;
o.gotscores = 1;
- if not(o.sort_prev)
- RegisterPlayer(o);
- SetTeam(o, Team);
+ //if not(o.sort_prev)
+ // RegisterPlayer(o);
+ //playerchecker will do this for us later, if it has not already done so
#if MAX_SCORE <= 3
for(i = 0; i < MAX_SCORE; ++i)
@@ -411,7 +410,8 @@
o.(scores[i]) = ReadShort();
#endif
- Sbar_UpdatePlayerPos(o);
+ if(o.sort_prev)
+ Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
}
void Ent_ReadTeamScore()
@@ -500,6 +500,7 @@
// with others, make sure it can no longer do so.
void Ent_Remove()
{
+ float i;
if(self.enttype == ENT_CLIENT_ENTCS)
{
Ent_RemoveEntCS();
@@ -508,9 +509,9 @@
if(self.owner)
{
SetTeam(self.owner, -1);
- if(self.owner.sort_prev)
- RemovePlayer(self.owner);
- self.owner.sort_prev = NULL;
+ self.owner.gotscores = 0;
+ for(i = 0; i < MAX_SCORE; ++i)
+ self.owner.(scores[i]) = 0; // clear all scores
}
} else if(self.enttype == ENT_CLIENT_TEAMSCORES)
{
Modified: trunk/data/qcsrc/client/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/client/miscfunctions.qc 2008-10-12 18:01:48 UTC (rev 4735)
+++ trunk/data/qcsrc/client/miscfunctions.qc 2008-10-13 06:04:55 UTC (rev 4736)
@@ -3,9 +3,31 @@
entity players;
entity teams;
+void AuditLists()
+{
+ entity e;
+ entity prev;
+
+ prev = players;
+ for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+ {
+ if(prev != e.sort_prev)
+ error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+ }
+
+ prev = teams;
+ for(e = prev.sort_next; e; prev = e, e = e.sort_next)
+ {
+ if(prev != e.sort_prev)
+ error(strcat("sort list chain error\nplease submit the output of 'prvm_edicts client' to the developers"));
+ }
+}
+
+
float RegisterPlayer(entity player)
{
entity pl;
+ AuditLists();
for(pl = players.sort_next; pl; pl = pl.sort_next)
if(pl == player)
error("Player already registered!");
@@ -14,12 +36,14 @@
if(players.sort_next)
players.sort_next.sort_prev = player;
players.sort_next = player;
+ AuditLists();
return true;
}
void RemovePlayer(entity player)
{
entity pl, parent;
+ AuditLists();
parent = players;
for(pl = players.sort_next; pl && pl != player; pl = pl.sort_next)
parent = pl;
@@ -32,16 +56,19 @@
parent.sort_next = player.sort_next;
if(player.sort_next)
player.sort_next.sort_prev = parent;
+ AuditLists();
}
void MoveToLast(entity e)
{
+ AuditLists();
other = e.sort_next;
while(other)
{
SORT_SWAP(other, e);
other = e.sort_next;
}
+ AuditLists();
}
// warning: Local "team" defined with name of a global
@@ -49,6 +76,7 @@
float RegisterTeam(entity Team)
{
entity tm;
+ AuditLists();
for(tm = teams.sort_next; tm; tm = tm.sort_next)
if(tm == Team)
error("Team already registered!");
@@ -57,12 +85,14 @@
if(teams.sort_next)
teams.sort_next.sort_prev = Team;
teams.sort_next = Team;
+ AuditLists();
return true;
}
void RemoveTeam(entity Team)
{
entity tm, parent;
+ AuditLists();
parent = teams;
for(tm = teams.sort_next; tm && tm != Team; tm = tm.sort_next)
parent = tm;
@@ -75,6 +105,7 @@
parent.sort_next = Team.sort_next;
if(Team.sort_next)
Team.sort_next.sort_prev = parent;
+ AuditLists();
}
entity GetTeam(float Team, float add)
Modified: trunk/data/qcsrc/client/sbar.qc
===================================================================
--- trunk/data/qcsrc/client/sbar.qc 2008-10-12 18:01:48 UTC (rev 4735)
+++ trunk/data/qcsrc/client/sbar.qc 2008-10-13 06:04:55 UTC (rev 4736)
@@ -216,6 +216,11 @@
float vl, vr;
vl = GetPlayerColor(left.sv_entnum);
vr = GetPlayerColor(right.sv_entnum);
+
+ if(!left.gotscores)
+ vl = COLOR_SPECTATOR;
+ if(!right.gotscores)
+ vr = COLOR_SPECTATOR;
if(vl > vr)
return true;
More information about the nexuiz-commits
mailing list