r4148 - in trunk/data/qcsrc: client common server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sat Aug 23 02:10:58 EDT 2008
Author: div0
Date: 2008-08-23 02:10:54 -0400 (Sat, 23 Aug 2008)
New Revision: 4148
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/common/constants.qh
trunk/data/qcsrc/server/defs.qh
trunk/data/qcsrc/server/scores.qc
Log:
smaller score updates (requires new engine on the server)
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-08-22 19:38:47 UTC (rev 4147)
+++ trunk/data/qcsrc/client/Main.qc 2008-08-23 06:10:54 UTC (rev 4148)
@@ -338,8 +338,21 @@
SetTeam(o, Team);
+#if MAX_SCORE <= 3
for(i = 0; i < MAX_SCORE; ++i)
o.(scores[i]) = ReadShort();
+#else
+ float sf;
+#if MAX_SCORE <= 8
+ sf = ReadByte();
+#else
+ sf = ReadShort();
+#endif
+ float p;
+ for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
+ if(sf & p)
+ o.(scores[i]) = ReadShort();
+#endif
Sbar_UpdatePlayerPos(o);
}
@@ -352,8 +365,21 @@
self.team = ReadByte();
o = self.owner = GetTeam(self.team, true);
+#if MAX_TEAMSCORE <= 3
for(i = 0; i < MAX_TEAMSCORE; ++i)
o.(teamscores[i]) = ReadShort();
+#else
+ float sf;
+#if MAX_TEAMSCORE <= 8
+ sf = ReadByte();
+#else
+ sf = ReadShort();
+#endif
+ float p;
+ for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
+ if(sf & p)
+ o.(teamscores[i]) = ReadShort();
+#endif
Sbar_UpdateTeamPos(o);
}
Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh 2008-08-22 19:38:47 UTC (rev 4147)
+++ trunk/data/qcsrc/common/constants.qh 2008-08-23 06:10:54 UTC (rev 4148)
@@ -10,7 +10,8 @@
// Revision 9: race delta
// Revision 10: scoreboard force
// Revision 11: scoreboard unforce; spectator support beginning
-#define CSQC_REVISION 11
+// Revision 12: smaller scores updates (SERVER: requires new engine)
+#define CSQC_REVISION 12
// probably put these in common/
// so server/ and client/ can be synced better
Modified: trunk/data/qcsrc/server/defs.qh
===================================================================
--- trunk/data/qcsrc/server/defs.qh 2008-08-22 19:38:47 UTC (rev 4147)
+++ trunk/data/qcsrc/server/defs.qh 2008-08-23 06:10:54 UTC (rev 4148)
@@ -446,7 +446,8 @@
float next_pingtime;
.float Version;
-.float(entity to) SendEntity;
+.float SendFlags;
+.float(entity to, float sendflags) SendEntity;
// player sounds, voice messages
.string playersound_attack;
Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc 2008-08-22 19:38:47 UTC (rev 4147)
+++ trunk/data/qcsrc/server/scores.qc 2008-08-23 06:10:54 UTC (rev 4148)
@@ -57,14 +57,26 @@
* teamscore entities
*/
-float TeamScore_SendEntity(entity to)
+float TeamScore_SendEntity(entity to, float sendflags)
{
float i;
WriteByte(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
WriteByte(MSG_ENTITY, self.team - 1);
+#if MAX_TEAMSCORE <= 3
for(i = 0; i < MAX_TEAMSCORE; ++i)
WriteShort(MSG_ENTITY, self.teamscores[i]);
+#else
+#if MAX_TEAMSCORE <= 8
+ WriteByte(MSG_ENTITY, sendflags);
+#else
+ WriteShort(MSG_ENTITY, sendflags);
+#endif
+ float p;
+ for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
+ if(sendflags & p)
+ WriteShort(MSG_ENTITY, self.teamscores[i]);
+#endif
return TRUE;
}
@@ -76,7 +88,7 @@
ts.classname = "csqc_score_team";
ts.SendEntity = TeamScore_SendEntity;
ts.netname = name; // not used yet, FIXME
- ts.Version = 1; // immediately send, so csqc knows about the team
+ //ts.SendFlags = SENDFLAGS_CREATE; // immediately send, so csqc knows about the team
ts.team = t;
Net_LinkEntity(ts);
teamscorekeepers[t - 1] = ts;
@@ -93,7 +105,8 @@
if(!s)
error("Adding score to unknown team!");
if(score)
- s.Version += 1;
+ if(teamscores_label[scorefield] != "")
+ s.SendFlags |= pow(2, scorefield);
return (s.(teamscores[scorefield]) += score);
}
@@ -181,14 +194,26 @@
* per-player score entities
*/
-float PlayerScore_SendEntity()
+float PlayerScore_SendEntity(entity to, float sendflags)
{
float i;
WriteByte(MSG_ENTITY, ENT_CLIENT_SCORES);
WriteByte(MSG_ENTITY, num_for_edict(self.owner));
+#if MAX_SCORE <= 3
for(i = 0; i < MAX_SCORE; ++i)
WriteShort(MSG_ENTITY, self.scores[i]);
+#else
+#if MAX_SCORE <= 8
+ WriteByte(MSG_ENTITY, sendflags);
+#else
+ WriteShort(MSG_ENTITY, sendflags);
+#endif
+ float p;
+ for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
+ if(sendflags & p)
+ WriteShort(MSG_ENTITY, self.scores[i]);
+#endif
return TRUE;
}
@@ -206,8 +231,12 @@
sk = player.scorekeeper;
for(i = 0; i < MAX_SCORE; ++i)
+ {
+ if(sk.(scores[i]) != 0)
+ if(scores_label[i] != "")
+ sk.SendFlags |= pow(2, i);
sk.(scores[i]) = 0;
- sk.Version += 1;
+ }
}
void Score_ClearAll()
@@ -220,8 +249,12 @@
if(!sk)
continue;
for(i = 0; i < MAX_SCORE; ++i)
+ {
+ if(sk.(scores[i]) != 0)
+ if(scores_label[i] != "")
+ sk.SendFlags |= pow(2, i);
sk.(scores[i]) = 0;
- sk.Version += 1;
+ }
}
for(i = 0; i < 16; ++i)
{
@@ -229,8 +262,12 @@
if(!sk)
continue;
for(i = 0; i < MAX_SCORE; ++i)
+ {
+ if(sk.(teamscores[i]) != 0)
+ if(teamscores_label[i] != "")
+ sk.SendFlags |= pow(2, i);
sk.(teamscores[i]) = 0;
- sk.Version += 1;
+ }
}
}
@@ -241,7 +278,6 @@
error("player already has a scorekeeper");
sk = spawn();
sk.owner = player;
- sk.Version = 1;
sk.SendEntity = PlayerScore_SendEntity;
Net_LinkEntity(sk);
player.scorekeeper = sk;
@@ -263,7 +299,8 @@
if(!s)
error("Adding score to unknown player!");
if(score)
- s.Version += 1;
+ if(scores_label[scorefield] != "")
+ s.SendFlags |= pow(2, scorefield);
return (s.(scores[scorefield]) += score);
}
More information about the nexuiz-commits
mailing list