public SecondGenCacheFile(IReader reader, BuildInformation buildInfo, string buildString)
 {
     _buildInfo = buildInfo;
     _segmenter = new FileSegmenter(buildInfo.SegmentAlignment);
     Allocator = new MetaAllocator(this, 0x10000);
     Load(reader, buildInfo, buildString);
 }
Example #2
0
        /// <summary>
        ///     Writes data to a reflexive, reallocating the original.
        /// </summary>
        /// <param name="entries">The entries to write.</param>
        /// <param name="oldCount">The old count.</param>
        /// <param name="oldAddress">The old address.</param>
        /// <param name="newCount">The number of entries to write.</param>
        /// <param name="layout">The layout of the data to write.</param>
        /// <param name="metaArea">The meta area of the cache file.</param>
        /// <param name="allocator">The cache file's meta allocator.</param>
        /// <param name="stream">The stream to manipulate.</param>
        /// <returns>The address of the new reflexive, or 0 if the entry list is empty and the reflexive was freed.</returns>
        public static uint WriteReflexive(IEnumerable<StructureValueCollection> entries, int oldCount, uint oldAddress,
			int newCount, StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
        {
            if (newCount == 0)
            {
                // Free the old reflexive and return
                if (oldCount > 0 && oldAddress != 0)
                    allocator.Free(oldAddress, oldCount*layout.Size);
                return 0;
            }

            uint newAddress = oldAddress;
            if (newCount != oldCount)
            {
                // Reallocate the reflexive
                int oldSize = oldCount*layout.Size;
                int newSize = newCount*layout.Size;
                if (oldCount > 0 && oldAddress != 0)
                    newAddress = allocator.Reallocate(oldAddress, oldSize, newSize, stream);
                else
                    newAddress = allocator.Allocate(newSize, stream);
            }

            // Write the new values
            WriteReflexive(entries.Take(newCount), newAddress, layout, metaArea, stream);
            return newAddress;
        }
Example #3
0
        public FourthGenCacheFile(IReader map_reader, IReader tag_reader, IReader string_reader, IReader tagnames_reader, EngineDescription buildInfo, string buildString)
		{
			_buildInfo = buildInfo;
			_segmenter = new FileSegmenter(buildInfo.SegmentAlignment);
			Allocator = new MetaAllocator(this, 0x10000);
            Load(map_reader, tag_reader, string_reader, tagnames_reader, buildString);
		}
Example #4
0
		public ThirdGenCacheFile(IReader reader, EngineDescription buildInfo, string buildString)
		{
			_buildInfo = buildInfo;
			_segmenter = new FileSegmenter(buildInfo.SegmentAlignment);
			Allocator = new MetaAllocator(this, 0x10000);
			Load(reader, buildString);
		}
Example #5
0
 public static void Free(StructureValueCollection values, MetaAllocator allocator)
 {
     FreeBitArray(values, "number of raw pool bitfields", "raw pool bitfield table address", allocator);
     FreeBitArray(values, "number of raw pool 2 bitfields", "raw pool 2 bitfield table address", allocator);
     FreeBitArray(values, "number of raw pool 3 bitfields", "raw pool 3 bitfield table address", allocator);
     FreeBitArray(values, "number of tag bitfields", "tag bitfield table address", allocator);
     FreeBitArray(values, "number of tag 2 bitfields", "tag 2 bitfield table address", allocator);
 }
		public FourthGenResourceLayoutTable(ITag playTag, FileSegmentGroup metaArea, MetaAllocator allocator,
			EngineDescription buildInfo)
		{
			_tag = playTag;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;
		}
		public FourthGenZoneSetTable(FourthGenResourceGestalt gestalt, IReader reader, FileSegmentGroup metaArea,
			MetaAllocator allocator, EngineDescription buildInfo)
		{
			_gestalt = gestalt;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;
			Load(reader);
		}
Example #8
0
		public FourthGenTagTable(IReader reader, MetaAllocator allocator, EngineDescription buildInfo)
		{
			//_indexHeaderLocation = indexHeaderLocation;
			//_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;

			Load(reader);
		}
		/// <summary>
		///     Initializes a new instance of the <see cref="ThirdGenResourceManager" /> class.
		/// </summary>
		/// <param name="gestalt">The cache file's resource gestalt.</param>
		/// <param name="layoutTable">The cache file's resource layout table.</param>
		/// <param name="tags">The cache file's tag table.</param>
		/// <param name="metaArea">The cache file's meta area.</param>
		/// <param name="allocator">The cache file's tag data allocator.</param>
		/// <param name="buildInfo">The cache file's build information.</param>
		public ThirdGenResourceManager(ThirdGenResourceGestalt gestalt, ThirdGenResourceLayoutTable layoutTable, TagTable tags,
			FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo)
		{
			_gestalt = gestalt;
			_layoutTable = layoutTable;
			_tags = tags;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;
		}
Example #10
0
        public ThirdGenResourceGestalt(IReader reader, ITag zoneTag, FileSegmentGroup metaArea, MetaAllocator allocator,
			StringIDSource stringIDs, EngineDescription buildInfo)
        {
            _tag = zoneTag;
            _metaArea = metaArea;
            _allocator = allocator;
            _buildInfo = buildInfo;

            Load(reader, stringIDs);
        }
		public FourthGenSimulationDefinitionTable(ITag scenario, TagTable tags, IReader reader, FileSegmentGroup metaArea, MetaAllocator allocator, EngineDescription buildInfo)
		{
			_scenario = scenario;
			_tags = tags;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;

			Load(reader);
		}
Example #12
0
        public ThirdGenTagTable(IReader reader, SegmentPointer indexHeaderLocation, FileSegmentGroup metaArea,
			MetaAllocator allocator, EngineDescription buildInfo)
        {
            _indexHeaderLocation = indexHeaderLocation;
            _metaArea = metaArea;
            _allocator = allocator;
            _buildInfo = buildInfo;

            Load(reader);
        }
Example #13
0
 /// <summary>
 ///     Writes data to a reflexive, reallocating the original.
 /// </summary>
 /// <param name="entries">The entries to write.</param>
 /// <param name="oldCount">The old count.</param>
 /// <param name="oldAddress">The old address.</param>
 /// <param name="layout">The layout of the data to write.</param>
 /// <param name="metaArea">The meta area of the cache file.</param>
 /// <param name="allocator">The cache file's meta allocator.</param>
 /// <param name="stream">The stream to manipulate.</param>
 /// <returns>The address of the new reflexive, or 0 if the entry list is empty and the reflexive was freed.</returns>
 public static uint WriteReflexive(ICollection <StructureValueCollection> entries, int oldCount, uint oldAddress,
                                   StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
 {
     return(WriteReflexive(entries, oldCount, oldAddress, entries.Count, layout, metaArea, allocator, stream));
 }
Example #14
0
		private static void FreeBitArray(StructureValueCollection values, string countName, string addressName, MetaAllocator allocator)
		{
			if (!values.HasInteger(countName) || !values.HasInteger(addressName))
				return;

			var oldCount = (int)values.GetInteger(countName);
			uint oldAddress = values.GetInteger(addressName);
			if (oldCount > 0 && oldAddress > 0)
				allocator.Free(oldAddress, oldCount*4);
		}
Example #15
0
		private void SaveBitArray(BitArray bits, string countName, string addressName, MetaAllocator allocator, IStream stream, ReflexiveCache<int> cache, StructureValueCollection values)
		{
			if (bits.Length == 0)
			{
				values.SetInteger(countName, 0);
				values.SetInteger(addressName, 0);
				return;
			}

			var ints = new int[((bits.Length + 31) & ~31)/32];
			bits.CopyTo(ints, 0);

			// If the address isn't cached, then allocate space and write a new array
			uint newAddress;
			if (!cache.TryGetAddress(ints, out newAddress))
			{
				newAddress = allocator.Allocate(ints.Length*4, stream);
				stream.SeekTo(_metaArea.PointerToOffset(newAddress));
				foreach (int i in ints)
					stream.WriteInt32(i);

				cache.Add(newAddress, ints);
			}

			values.SetInteger(countName, (uint)ints.Length);
			values.SetInteger(addressName, newAddress);
		}
Example #16
0
		public StructureValueCollection Serialize(IStream stream, MetaAllocator allocator, ReflexiveCache<int> cache)
		{
			var result = new StructureValueCollection();
			SaveBitArray(_activeResources, "number of raw pool bitfields", "raw pool bitfield table address", allocator, stream, cache, result);
			SaveBitArray(_unknownResources, "number of raw pool 2 bitfields", "raw pool 2 bitfield table address", allocator, stream, cache, result);
			SaveBitArray(_unknownResources2, "number of raw pool 3 bitfields", "raw pool 3 bitfield table address", allocator, stream, cache, result);
			SaveBitArray(_activeTags, "number of tag bitfields", "tag bitfield table address", allocator, stream, cache, result);
			SaveBitArray(_unknownTags, "number of tag 2 bitfields", "tag 2 bitfield table address", allocator, stream, cache, result);
			return result;
		}
Example #17
0
        /// <summary>
        ///     Writes data to a block, reallocating the original.
        /// </summary>
        /// <param name="elements">The entries to write.</param>
        /// <param name="oldCount">The old count.</param>
        /// <param name="oldAddress">The old address.</param>
        /// <param name="newCount">The number of entries to write.</param>
        /// <param name="layout">The layout of the data to write.</param>
        /// <param name="metaArea">The meta area of the cache file.</param>
        /// <param name="allocator">The cache file's meta allocator.</param>
        /// <param name="stream">The stream to manipulate.</param>
        /// <returns>The address of the new tag block, or 0 if the entry list is empty and the tag block was freed.</returns>
        public static long WriteTagBlock(IEnumerable <StructureValueCollection> elements, int oldCount, long oldAddress,
                                         int newCount, StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
        {
            if (newCount == 0)
            {
                // Free the old block and return
                if (oldCount > 0 && oldAddress != 0)
                {
                    allocator.Free(oldAddress, oldCount * layout.Size);
                }
                return(0);
            }

            long newAddress = oldAddress;

            if (newCount != oldCount)
            {
                // Reallocate the block
                int oldSize = oldCount * layout.Size;
                int newSize = newCount * layout.Size;
                if (oldCount > 0 && oldAddress != 0)
                {
                    newAddress = allocator.Reallocate(oldAddress, oldSize, newSize, stream);
                }
                else
                {
                    newAddress = allocator.Allocate(newSize, stream);
                }
            }

            // Write the new values
            WriteTagBlock(elements.Take(newCount), newAddress, layout, metaArea, stream);
            return(newAddress);
        }
Example #18
0
 /// <summary>
 ///     Writes data to a block, reallocating the original.
 /// </summary>
 /// <param name="elements">The entries to write.</param>
 /// <param name="oldCount">The old count.</param>
 /// <param name="oldAddress">The old address.</param>
 /// <param name="layout">The layout of the data to write.</param>
 /// <param name="metaArea">The meta area of the cache file.</param>
 /// <param name="allocator">The cache file's meta allocator.</param>
 /// <param name="stream">The stream to manipulate.</param>
 /// <returns>The address of the new tag block, or 0 if the entry list is empty and the tag block was freed.</returns>
 public static long WriteTagBlock(ICollection <StructureValueCollection> elements, int oldCount, long oldAddress,
                                  StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
 {
     return(WriteTagBlock(elements, oldCount, oldAddress, elements.Count, layout, metaArea, allocator, stream));
 }
Example #19
0
        /// <summary>
        ///     Writes data to a reflexive, reallocating the original.
        /// </summary>
        /// <param name="entries">The entries to write.</param>
        /// <param name="oldCount">The old count.</param>
        /// <param name="oldAddress">The old address.</param>
        /// <param name="newCount">The number of entries to write.</param>
        /// <param name="layout">The layout of the data to write.</param>
        /// <param name="metaArea">The meta area of the cache file.</param>
        /// <param name="allocator">The cache file's meta allocator.</param>
        /// <param name="stream">The stream to manipulate.</param>
        /// <returns>The address of the new reflexive, or 0 if the entry list is empty and the reflexive was freed.</returns>
        public static uint WriteReflexive(IEnumerable <StructureValueCollection> entries, int oldCount, uint oldAddress,
                                          int newCount, StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
        {
            if (newCount == 0)
            {
                // Free the old reflexive and return
                if (oldCount > 0 && oldAddress != 0)
                {
                    allocator.Free(oldAddress, oldCount * layout.Size);
                }
                return(0);
            }

            uint newAddress = oldAddress;

            if (newCount != oldCount)
            {
                // Reallocate the reflexive
                int oldSize = oldCount * layout.Size;
                int newSize = newCount * layout.Size;
                if (oldCount > 0 && oldAddress != 0)
                {
                    newAddress = allocator.Reallocate(oldAddress, oldSize, newSize, stream);
                }
                else
                {
                    newAddress = allocator.Allocate(newSize, stream);
                }
            }

            // Write the new values
            WriteReflexive(entries.Take(newCount), newAddress, layout, metaArea, stream);
            return(newAddress);
        }
Example #20
0
 /// <summary>
 ///     Allocates a new reflexive and writes data to it.
 /// </summary>
 /// <param name="entries">The entries to write.</param>
 /// <param name="layout">The layout of the data to write.</param>
 /// <param name="metaArea">The meta area of the cache file.</param>
 /// <param name="allocator">The cache file's meta allocator.</param>
 /// <param name="stream">The stream to manipulate.</param>
 /// <returns>The address of the new reflexive, or 0 if the entry list is empty.</returns>
 public static long WriteReflexive(ICollection <StructureValueCollection> entries, StructureLayout layout,
                                   FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
 {
     return(WriteReflexive(entries, 0, 0, layout, metaArea, allocator, stream));
 }
Example #21
0
        /// <summary>
        ///     Writes data to a reflexive, reallocating the original.
        /// </summary>
        /// <param name="entries">The entries to write.</param>
        /// <param name="oldCount">The old count.</param>
        /// <param name="oldAddress">The old address.</param>
        /// <param name="layout">The layout of the data to write.</param>
        /// <param name="metaArea">The meta area of the cache file.</param>
        /// <param name="allocator">The cache file's meta allocator.</param>
        /// <param name="stream">The stream to manipulate.</param>
        /// <returns>The address of the new reflexive, or 0 if the entry list is empty and the reflexive was freed.</returns>
        public static uint WriteReflexive(ICollection<StructureValueCollection> entries, int oldCount, uint oldAddress,
			StructureLayout layout, FileSegmentGroup metaArea, MetaAllocator allocator, IStream stream)
        {
            return WriteReflexive(entries, oldCount, oldAddress, entries.Count, layout, metaArea, allocator, stream);
        }