sources/network/bytestream.cpp

changeset 61
cdf3c8af1545
parent 58
d175243ad169
child 73
07dda51a7a8e
equal deleted inserted replaced
60:268721e6be20 61:cdf3c8af1545
176 // ------------------------------------------------------------------------------------------------- 176 // -------------------------------------------------------------------------------------------------
177 // 177 //
178 METHOD 178 METHOD
179 Bytestream::read_float() -> float 179 Bytestream::read_float() -> float
180 { 180 {
181 int value = read_long(); 181 float value;
182 return reinterpret_cast<float&> (value); 182 int intvalue = read_long();
183 memcpy (&value, &intvalue, sizeof intvalue);
184 return value;
183 } 185 }
184 186
185 // ------------------------------------------------------------------------------------------------- 187 // -------------------------------------------------------------------------------------------------
186 // 188 //
187 METHOD 189 METHOD
290 // 292 //
291 METHOD 293 METHOD
292 Bytestream::write_float (float val) -> void 294 Bytestream::write_float (float val) -> void
293 { 295 {
294 // I know this is probably dangerous but this is what Zandronum does so yeah 296 // I know this is probably dangerous but this is what Zandronum does so yeah
295 write_long (reinterpret_cast<int&> (val)); 297 int intvalue;
298 memcpy (&intvalue, &val, sizeof val);
299 write_long (intvalue);
296 } 300 }
297 301
298 // ------------------------------------------------------------------------------------------------- 302 // -------------------------------------------------------------------------------------------------
299 // 303 //
300 METHOD 304 METHOD

mercurial