public bool ReadFloatNullable(ref float?value) { try { if (m_binaryReader.ReadBoolean()) { value = m_binaryReader.ReadSingle(); if (!MyCommonDebugUtils.IsValid(value.Value)) { HandleError("Invalid float"); return(false); } } else { value = null; } return(true); } catch (Exception ex) { HandleError(ex); return(false); } }
public static void WriteFloat(float val, BinaryWriter binaryWriter) { MyMwcUtils.FixDenormalizedFloat(ref val); if (!MyCommonDebugUtils.IsValid(val)) { throw new InvalidOperationException("Cannot write invalid float (infinity or NaN) to network message!"); } binaryWriter.Write(val); }
public bool ReadDouble(ref double value) { try { value = m_binaryReader.ReadDouble(); if (!MyCommonDebugUtils.IsValid(value)) { HandleError("Invalid double"); return(false); } return(true); } catch (Exception ex) { HandleError(ex); return(false); } }
public bool ReadFloat(ref float value) { try { value = m_binaryReader.ReadSingle(); if (!MyCommonDebugUtils.IsValid(value)) { HandleError("Invalid float"); return(false); } return(true); } catch (Exception ex) { HandleError(ex); return(false); } }