[nexuiz-commits] r7622 - in trunk/data/qcsrc: client common server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Sep 4 02:52:19 EDT 2009
Author: div0
Date: 2009-09-04 02:52:19 -0400 (Fri, 04 Sep 2009)
New Revision: 7622
Modified:
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/common/util.qc
trunk/data/qcsrc/common/util.qh
trunk/data/qcsrc/server/race.qc
trunk/data/qcsrc/server/scores.qc
Log:
change the values networked as "long" in scores and race times to "int24_t" (3 bytes instead of 4).
Range is now:
-8388608..8388607
In time, at 100Hz timer: 83886.07 seconds (a bit less than a day) ;)
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2009-09-04 06:45:19 UTC (rev 7621)
+++ trunk/data/qcsrc/client/Main.qc 2009-09-04 06:52:19 UTC (rev 7622)
@@ -630,7 +630,7 @@
if(sf & p)
{
if(lf & p)
- o.(scores[i]) = ReadLong();
+ o.(scores[i]) = ReadInt24_t();
else
o.(scores[i]) = ReadChar();
}
@@ -662,7 +662,7 @@
if(sf & p)
{
if(lf & p)
- o.(teamscores[i]) = ReadLong();
+ o.(teamscores[i]) = ReadInt24_t();
else
o.(teamscores[i]) = ReadChar();
}
@@ -932,8 +932,8 @@
{
case RACE_NET_CHECKPOINT_HIT_QUALIFYING:
race_checkpoint = ReadByte();
- race_time = ReadLong();
- race_previousbesttime = ReadLong();
+ race_time = ReadInt24_t();
+ race_previousbesttime = ReadInt24_t();
if(race_previousbestname)
strunzone(race_previousbestname);
race_previousbestname = strzone(ColorTranslateRGB(ReadString()));
@@ -960,7 +960,7 @@
case RACE_NET_CHECKPOINT_NEXT_QUALIFYING:
race_nextcheckpoint = ReadByte();
- race_nextbesttime = ReadLong();
+ race_nextbesttime = ReadInt24_t();
if(race_nextbestname)
strunzone(race_nextbestname);
race_nextbestname = strzone(ColorTranslateRGB(ReadString()));
@@ -969,7 +969,7 @@
case RACE_NET_CHECKPOINT_HIT_RACE:
race_mycheckpoint = ReadByte();
race_mycheckpointtime = time;
- race_mycheckpointdelta = ReadLong();
+ race_mycheckpointdelta = ReadInt24_t();
race_mycheckpointlapsdelta = ReadByte();
if(race_mycheckpointlapsdelta >= 128)
race_mycheckpointlapsdelta -= 256;
@@ -981,7 +981,7 @@
case RACE_NET_CHECKPOINT_HIT_RACE_BY_OPPONENT:
race_othercheckpoint = ReadByte();
race_othercheckpointtime = time;
- race_othercheckpointdelta = ReadLong();
+ race_othercheckpointdelta = ReadInt24_t();
race_othercheckpointlapsdelta = ReadByte();
if(race_othercheckpointlapsdelta >= 128)
race_othercheckpointlapsdelta -= 256;
Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc 2009-09-04 06:45:19 UTC (rev 7621)
+++ trunk/data/qcsrc/common/util.qc 2009-09-04 06:52:19 UTC (rev 7622)
@@ -1627,3 +1627,21 @@
else
return argv(n - 1);
}
+
+#ifndef MENUQC
+#ifdef CSQC
+float ReadInt24_t()
+{
+ float v;
+ v = ReadShort() * 256; // note: this is signed
+ v += ReadByte(); // note: this is unsigned
+}
+#else
+void WriteInt24_t(float dest, float val)
+{
+ float v;
+ WriteShort((v = floor(val / 256)));
+ WriteByte(val - v * 256); // 0..255
+}
+#endif
+#endif
Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh 2009-09-04 06:45:19 UTC (rev 7621)
+++ trunk/data/qcsrc/common/util.qh 2009-09-04 06:52:19 UTC (rev 7622)
@@ -194,3 +194,11 @@
vector healtharmor_applydamage(float a, float armorblock, float damage); // returns vector: take, save, 0
string getcurrentmod();
+
+#ifndef MENUQC
+#ifdef CSQC
+float ReadInt24_t();
+#else
+void WriteInt24_t(float dest, float val);
+#endif
+#endif
Modified: trunk/data/qcsrc/server/race.qc
===================================================================
--- trunk/data/qcsrc/server/race.qc 2009-09-04 06:45:19 UTC (rev 7621)
+++ trunk/data/qcsrc/server/race.qc 2009-09-04 06:52:19 UTC (rev 7622)
@@ -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
- WriteLong(MSG_ONE, recordtime);
+ WriteInt24_t(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
- WriteLong(MSG_ONE, t); // time to that intermediate
- WriteLong(MSG_ONE, recordtime); // previously best time
+ WriteInt24_t(MSG_ONE, t); // time to that intermediate
+ WriteInt24_t(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)
{
- WriteLong(MSG_ONE, 0);
+ WriteInt24_t(MSG_ONE, 0);
WriteByte(MSG_ONE, 0);
WriteString(MSG_ONE, "");
}
else
{
- WriteLong(MSG_ONE, TIME_ENCODE(time - race_checkpoint_lasttimes[cp]));
+ WriteInt24_t(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)
{
- WriteLong(MSG_ONE, 0);
+ WriteInt24_t(MSG_ONE, 0);
WriteByte(MSG_ONE, 0);
WriteString(MSG_ONE, "");
}
else
{
- WriteLong(MSG_ONE, TIME_ENCODE(time - othtime));
+ WriteInt24_t(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-04 06:45:19 UTC (rev 7621)
+++ trunk/data/qcsrc/server/scores.qc 2009-09-04 06:52:19 UTC (rev 7622)
@@ -70,7 +70,7 @@
if(sendflags & p)
{
if(longflags & p)
- WriteLong(MSG_ENTITY, self.teamscores[i]);
+ WriteInt24_t(MSG_ENTITY, self.teamscores[i]);
else
WriteChar(MSG_ENTITY, self.teamscores[i]);
}
@@ -230,7 +230,7 @@
if(sendflags & p)
{
if(longflags & p)
- WriteLong(MSG_ENTITY, self.scores[i]);
+ WriteInt24_t(MSG_ENTITY, self.scores[i]);
else
WriteChar(MSG_ENTITY, self.scores[i]);
}
More information about the nexuiz-commits
mailing list