示例#1
0
        internal void WriteLookBackString(Stream s, GBXLBS lookbackstring)
        {
            if (_storedStringsWrite == null) //First Lookbackstring encountered, need to write version
            {
                _storedStringsWrite = new List <GBXString>();
                s.WriteUInt(LBSVersion);
            }

            if (lookbackstring._content == null)
            {
                s.WriteUInt(lookbackstring.CollectionID);
            }
            else
            {
                var index = _storedStringsWrite.IndexOf(lookbackstring._content);

                if (index < 0) // not stored, add string to stringlist, write new string
                {
                    _storedStringsWrite.Add(lookbackstring._content);
                    s.WriteUInt(LBSFlag);
                    lookbackstring._content.WriteBack(s);
                }
                else //string stored, write reference
                {
                    s.WriteUInt(((uint)index | LBSFlag) + 1);
                }
            }
        }
 public Challenge03043051(Stream s, GBXLBSContext c) : base(c, null)
 {
     AlwaysZero = new GBXUInt(s);
     TitlePack  = new GBXLBS(c);
     Version    = new GBXString(s);
     this.LBSContext.SkipVersion();
 }
 public Challenge03043051(bool dummy) : base(null, null)
 {
     this.ChunkID     = 0x03043051;
     AlwaysZero       = new GBXUInt(0);
     TitlePack        = new GBXLBS("");
     TitlePack.Parent = this;
     Version          = new GBXString("date=2019-07-03_10_37 Svn=93842 GameVersion=3.3.0"); //Good Default
     this.LBSContext.SkipVersion();
 }
示例#4
0
        public GBXLBS ReadLookBackString(Stream s)
        {
            if (!_versionHasBeenRead)
            {
                var version = s.ReadUInt();
                Trace.Assert(version == LBSVersion, "Unsupported Version of the LookBackString: " + version.ToString("X"));
                _versionHasBeenRead = true;
            }

            var index = new GBXUInt(s);

            uint id  = index.Value;
            var  lbs = new GBXLBS(this);

            if (id == GBXLBS.unassigned)
            {
                return(lbs);
            }

            switch (id >> 30)
            {
            case 0b00:
                lbs.CollectionID = id;
                return(lbs);

            case 0b01:     //no difference found
                goto case 0b10;

            case 0b10:
                if ((id & 0x3FFF) == 0)
                {
                    var newString = new GBXString(s);
                    _storedStringsRead.Add(newString);
                    lbs._content = newString;
                }
                else
                {
                    lbs._content = _storedStringsRead[(int)(id & 0x3FFF) - 1];
                }
                return(lbs);

            case 0b11: throw new Exception("Could not read LookBackString. Unknown Flags." + id);

            default: throw new Exception("Universe is broken, have you tried turning it off and on again?");
            }
        }