Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorvald Natvig <slicer@users.sourceforge.net>2009-11-30 14:56:55 +0300
committerThorvald Natvig <slicer@users.sourceforge.net>2009-11-30 14:56:55 +0300
commit6d9a0e06b26c1cb1fef5b928b6e6a6d84b9f08cf (patch)
treed1dbf886a25cac46449c5e6c5d29f13508f0c68b /src/PacketDataStream.h
parentdfd87b0ba5fd2fd71515eaa8408a0ee80305e756 (diff)
Change to straight 4-byte encoding for floats
Diffstat (limited to 'src/PacketDataStream.h')
-rw-r--r--src/PacketDataStream.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/PacketDataStream.h b/src/PacketDataStream.h
index db5bcb7fd..87b70c968 100644
--- a/src/PacketDataStream.h
+++ b/src/PacketDataStream.h
@@ -347,19 +347,30 @@ class PacketDataStream {
}
union float32u {
- quint32 ui;
+ quint8 ui[4];
float f;
};
PacketDataStream &operator <<(const float v) {
float32u u;
u.f = v;
- return *this << u.ui;
+ append(u.ui[0]);
+ append(u.ui[1]);
+ append(u.ui[2]);
+ append(u.ui[3]);
+ return *this;
}
PacketDataStream &operator >>(float &v) {
float32u u;
- *this >> u.ui;
+ if (left() < 4) {
+ ok = false;
+ v = 0;
+ }
+ u.ui[0] = next8();
+ u.ui[1] = next8();
+ u.ui[2] = next8();
+ u.ui[3] = next8();
v = u.f;
return *this;
}