Пример #1
0
        internal static void SerializeValue(MegaloScriptModel model, IO.BitStream s,
                                            MegaloScriptValueType valueType, ref int value)
        {
            if (valueType.EnumTraits == Proto.MegaloScriptValueEnumTraits.HasNoneMember)
            {
                s.StreamNoneable(ref value, valueType.BitLength);
            }
            else
            {
                s.Stream(ref value, valueType.BitLength);
            }

            if (s.IsReading && !model.EnumIndexIsValid(valueType, value))
            {
                throw new System.IO.InvalidDataException(string.Format("{0} doesn't have a #{1} member",
                                                                       model.Database.Enums[valueType.EnumIndex].Name, value));
            }
        }