Example #1
0
        static void InitVCR(quakeparms_t parms)
        {
            if (Common.HasParam("-playback"))
            {
                if (Common.Argc != 2)
                {
                    Sys.Error("No other parameters allowed with -playback\n");
                }

                Stream file = Sys.FileOpenRead("quake.vcr");
                if (file == null)
                {
                    Sys.Error("playback file not found\n");
                }

                _VcrReader = new BinaryReader(file, Encoding.ASCII);
                int signature = _VcrReader.ReadInt32();  //Sys_FileRead(vcrFile, &i, sizeof(int));
                if (signature != Host.VCR_SIGNATURE)
                {
                    Sys.Error("Invalid signature in vcr file\n");
                }

                int      argc = _VcrReader.ReadInt32(); // Sys_FileRead(vcrFile, &com_argc, sizeof(int));
                string[] argv = new string[argc + 1];
                argv[0] = parms.argv[0];

                for (int i = 1; i < argv.Length; i++)
                {
                    argv[i] = Sys.ReadString(_VcrReader);
                }
                Common.Args = argv;
                parms.argv  = argv;
            }

            int n = Common.CheckParm("-record");

            if (n != 0)
            {
                Stream file = Sys.FileOpenWrite("quake.vcr"); // vcrFile = Sys_FileOpenWrite("quake.vcr");
                _VcrWriter = new BinaryWriter(file, Encoding.ASCII);

                _VcrWriter.Write(VCR_SIGNATURE); //  Sys_FileWrite(vcrFile, &i, sizeof(int));
                _VcrWriter.Write(Common.Argc - 1);
                for (int i = 1; i < Common.Argc; i++)
                {
                    if (i == n)
                    {
                        Sys.WriteString(_VcrWriter, "-playback");
                        continue;
                    }
                    Sys.WriteString(_VcrWriter, Common.Argv(i));
                }
            }
        }