[nexuiz-commits] r7616 - in trunk/data/qcsrc: client server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Sep 3 16:25:26 EDT 2009
Author: div0
Date: 2009-09-03 16:25:26 -0400 (Thu, 03 Sep 2009)
New Revision: 7616
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/server/race.qc
trunk/data/qcsrc/server/scores.qc
Log:
send scores as long when needed, and race times always as long. PLEASE TEST, this may crash!
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2009-09-03 20:03:07 UTC (rev 7615)
+++ trunk/data/qcsrc/client/Main.qc 2009-09-03 20:25:26 UTC (rev 7616)
@@ -617,21 +617,23 @@
// 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)
- o.(scores[i]) = ReadShort();
-#else
- float sf;
+ float sf, lf;
#if MAX_SCORE <= 8
sf = ReadByte();
+ lf = ReadByte();
#else
sf = ReadShort();
+ lf = ReadShort();
#endif
float p;
for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
if(sf & p)
- o.(scores[i]) = ReadShort();
-#endif
+ {
+ if(lf & p)
+ o.(scores[i]) = ReadLong();
+ else
+ o.(scores[i]) = ReadShort();
+ }
if(o.sort_prev)
Sbar_UpdatePlayerPos(o); // if not registered, we cannot do this yet!
@@ -647,21 +649,23 @@
self.team = ReadByte();
o = self.owner = GetTeam(self.team, true); // these team numbers can always be trusted
-#if MAX_TEAMSCORE <= 3
- for(i = 0; i < MAX_TEAMSCORE; ++i)
- o.(teamscores[i]) = ReadShort();
-#else
float sf;
#if MAX_TEAMSCORE <= 8
sf = ReadByte();
+ lf = ReadByte();
#else
sf = ReadShort();
+ lf = ReadShort();
#endif
float p;
for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
if(sf & p)
- o.(teamscores[i]) = ReadShort();
-#endif
+ {
+ if(lf & p)
+ o.(teamscores[i]) = ReadLong();
+ else
+ o.(teamscores[i]) = ReadShort();
+ }
Sbar_UpdateTeamPos(o);
}
@@ -928,8 +932,8 @@
{
case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
race_checkpoint = ReadByte();
- race_time = ReadShort();
- race_previousbesttime = ReadShort();
+ race_time = ReadLong();
+ race_previousbesttime = ReadLong();
if(race_previousbestname)
strunzone(race_previousbestname);
race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
@@ -956,7 +960,7 @@
case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
race_nextcheckpoint = ReadByte();
- race_nextbesttime = ReadShort();
+ race_nextbesttime = ReadLong();
if(race_nextbestname)
strunzone(race_nextbestname);
race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
@@ -965,7 +969,7 @@
case RACE_NET_CHECKPOINT_HIT_RACE:
race_mycheckpoint = ReadByte();
race_mycheckpointtime = time;
- race_mycheckpointdelta = ReadShort();
+ race_mycheckpointdelta = ReadLong();
race_mycheckpointlapsdelta = ReadByte();
if(race_mycheckpointlapsdelta >= 128)
race_mycheckpointlapsdelta -= 256;
@@ -977,7 +981,7 @@
case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
race_othercheckpoint = ReadByte();
race_othercheckpointtime = time;
- race_othercheckpointdelta = ReadShort();
+ race_othercheckpointdelta = ReadLong();
race_othercheckpointlapsdelta = ReadByte();
if(race_othercheckpointlapsdelta >= 128)
race_othercheckpointlapsdelta -= 256;
Modified: trunk/data/qcsrc/server/race.qc
===================================================================
--- trunk/data/qcsrc/server/race.qc 2009-09-03 20:03:07 UTC (rev 7615)
+++ trunk/data/qcsrc/server/race.qc 2009-09-03 20:25:26 UTC (rev 7616)
@@ -80,7 +80,7 @@
else
WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_NEXT_QUALIFYING);
WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player will be at next
- WriteShort(MSG_ONE, recordtime);
+ WriteLong(MSG_ONE, recordtime);
WriteString(MSG_ONE, recordholder);
});
}
@@ -217,8 +217,8 @@
WriteByte(MSG_ONE, TE_CSQC_RACE);
WriteByte(MSG_ONE, RACE_NET_CHECKPOINT_HIT_QUALIFYING);
WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
- WriteShort(MSG_ONE, t); // time to that intermediate
- WriteShort(MSG_ONE, recordtime); // previously best time
+ WriteLong(MSG_ONE, t); // time to that intermediate
+ WriteLong(MSG_ONE, recordtime); // previously best time
WriteString(MSG_ONE, recordholder); // record holder
});
}
@@ -245,13 +245,13 @@
WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
if(e == oth)
{
- WriteShort(MSG_ONE, 0);
+ WriteLong(MSG_ONE, 0);
WriteByte(MSG_ONE, 0);
WriteString(MSG_ONE, "");
}
else
{
- WriteShort(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp]));
+ WriteLong(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp]));
WriteByte(MSG_ONE, lself - lother);
WriteString(MSG_ONE, oth.netname); // record holder
}
@@ -269,13 +269,13 @@
WriteByte(MSG_ONE, race_CheckpointNetworkID(cp)); // checkpoint the player now is at
if(e == oth)
{
- WriteShort(MSG_ONE, 0);
+ WriteLong(MSG_ONE, 0);
WriteByte(MSG_ONE, 0);
WriteString(MSG_ONE, "");
}
else
{
- WriteShort(MSG_ONE, TIME_ENCODE(time - othtime));
+ WriteLong(MSG_ONE, TIME_ENCODE(time - othtime));
WriteByte(MSG_ONE, lother - lself);
WriteString(MSG_ONE, e.netname); // record holder
}
Modified: trunk/data/qcsrc/server/scores.qc
===================================================================
--- trunk/data/qcsrc/server/scores.qc 2009-09-03 20:03:07 UTC (rev 7615)
+++ trunk/data/qcsrc/server/scores.qc 2009-09-03 20:25:26 UTC (rev 7616)
@@ -49,24 +49,32 @@
float TeamScore_SendEntity(entity to, float sendflags)
{
- float i;
+ float i, longflags;
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
+
+ longflags = 0;
+ for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
+ if(self.teamscores[i] > 32767 || self.teamscores[i] <= -32768)
+ longflags |= p;
+
#if MAX_TEAMSCORE <= 8
WriteByte(MSG_ENTITY, sendflags);
+ WriteByte(MSG_ENTITY, longflags);
#else
WriteShort(MSG_ENTITY, sendflags);
+ WriteShort(MSG_ENTITY, longflags);
#endif
float p;
for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
if(sendflags & p)
- WriteShort(MSG_ENTITY, self.teamscores[i]);
-#endif
+ {
+ if(longflags & p)
+ WriteLong(MSG_ENTITY, self.teamscores[i]);
+ else
+ WriteShort(MSG_ENTITY, self.teamscores[i]);
+ }
return TRUE;
}
@@ -206,20 +214,28 @@
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
+
+ longflags = 0;
+ for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
+ if(self.scores[i] > 32767 || self.scores[i] <= -32768)
+ longflags |= p;
+
#if MAX_SCORE <= 8
WriteByte(MSG_ENTITY, sendflags);
+ WriteByte(MSG_ENTITY, longflags);
#else
WriteShort(MSG_ENTITY, sendflags);
+ WriteShort(MSG_ENTITY, longflags);
#endif
float p;
for(i = 0, p = 1; i < MAX_SCORE; ++i, p *= 2)
if(sendflags & p)
- WriteShort(MSG_ENTITY, self.scores[i]);
-#endif
+ {
+ if(longflags & p)
+ WriteLong(MSG_ENTITY, self.scores[i]);
+ else
+ WriteShort(MSG_ENTITY, self.scores[i]);
+ }
return TRUE;
}
More information about the nexuiz-commits
mailing list