Exemplo n.º 1
0
 public void WriteFlaggedVariables(CVAR flags, string setCmd, VFile f)
 {
     foreach (var cvar in cvars.Values)
     {
         if ((cvar.Flags & flags) != 0)
         {
             Printf($"{setCmd} {cvar.Name} \"{cvar.String}\"\n");
         }
     }
 }
Exemplo n.º 2
0
        public static void WriteZASCII(this VFile source, string value)
        {
            var len = value.Length;

            if (len >= MAX_STRING_CHARS - 1)
            {
                Error("WriteZASCII: bad string");
            }
            source.Write(Encoding.ASCII.GetBytes(value), len);
            source.Write((byte)0);
        }
Exemplo n.º 3
0
        public static void WriteDictionary(this VFile source, Dictionary <string, string> value)
        {
            var count = LittleInt(value.Count);

            source.Write(count);
            foreach (var kv in value)
            {
                source.WriteZASCII(kv.Key);
                source.WriteZASCII(kv.Value);
            }
        }
Exemplo n.º 4
0
 public static void ReadDictionary(this VFile source, Dictionary <string, string> value)
 {
     value.Clear();
     source.Read(out int count);
     count = LittleInt(count);
     for (var i = 0; i < count; i++)
     {
         var key = source.ReadZASCII();
         var val = source.ReadZASCII();
         value[key] = val;
     }
 }
Exemplo n.º 5
0
        public unsafe static string ReadZASCII(this VFile source)
        {
            int len; char *str = stackalloc char[MAX_STRING_CHARS];

            for (len = 0; len < MAX_STRING_CHARS; len++)
            {
                source.Read((byte *)&str[len], 1);
                if (str[len] == 0)
                {
                    break;
                }
            }
            if (len == MAX_STRING_CHARS)
            {
                Error("ReadZASCII: bad string");
            }
            return(new string(str, 0, len));
        }
Exemplo n.º 6
0
 public static int ReadTMany <T>(this VFile source, out T[] value, int count) where T : struct => throw new NotImplementedException();
Exemplo n.º 7
0
 public static int ReadT <T>(this VFile source, out T value) where T : struct => throw new NotImplementedException();
Exemplo n.º 8
0
 public static int Read <E>(this VFile source, out E value) where E : Enum => throw new NotImplementedException();
Exemplo n.º 9
0
 public static int Read(this VFile source, out bool value)
 {
     bool val; var r = source.Read((byte *)&val, sizeof(bool)); value = val; return(r);
 }
Exemplo n.º 10
0
 public static int Read(this VFile source, out ushort value)
 {
     ushort val; var r = source.Read((byte *)&val, sizeof(ushort)); value = val; return(r);
 }
Exemplo n.º 11
0
 public static int Read(this VFile source, out float value)
 {
     float val; var r = source.Read((byte *)&val, sizeof(float)); value = val; return(r);
 }
Exemplo n.º 12
0
 public static int Write(this VFile source, float value) => source.Write((byte *)&value, sizeof(float));
Exemplo n.º 13
0
 public static int WriteASCII(this VFile source, string value, int length) => source.Write(Encoding.ASCII.GetBytes(value), value.Length);
Exemplo n.º 14
0
 public static int WriteTMany <T>(this VFile source, T[] value) where T : struct => throw new NotImplementedException();
Exemplo n.º 15
0
 public static int Write(this VFile source, bool value) => source.Write((byte *)&value, sizeof(bool));
Exemplo n.º 16
0
 public static int Write(this VFile source, ushort value) => source.Write((byte *)&value, sizeof(ushort));
Exemplo n.º 17
0
 public static int Read(this VFile source, out long value)
 {
     long val; var r = source.Read((byte *)&val, sizeof(long)); value = val; return(r);
 }
Exemplo n.º 18
0
 public static int ReadASCII(this VFile source, out string value, int length) => throw new NotImplementedException();
Exemplo n.º 19
0
 public static int Write(this VFile source, ulong value) => source.Write((byte *)&value, sizeof(ulong));