Пример #1
0
 public SecondGenCacheFile(IReader reader, BuildInformation buildInfo, string buildString)
 {
     _buildInfo = buildInfo;
     _segmenter = new FileSegmenter(buildInfo.SegmentAlignment);
     Allocator = new MetaAllocator(this, 0x10000);
     Load(reader, buildInfo, buildString);
 }
Пример #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;
        }
Пример #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);
		}
Пример #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);
		}
Пример #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;
		}
Пример #7
0
		public FourthGenZoneSetTable(FourthGenResourceGestalt gestalt, IReader reader, FileSegmentGroup metaArea,
			MetaAllocator allocator, EngineDescription buildInfo)
		{
			_gestalt = gestalt;
			_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;
			Load(reader);
		}
Пример #8
0
		public FourthGenTagTable(IReader reader, MetaAllocator allocator, EngineDescription buildInfo)
		{
			//_indexHeaderLocation = indexHeaderLocation;
			//_metaArea = metaArea;
			_allocator = allocator;
			_buildInfo = buildInfo;

			Load(reader);
		}
Пример #9
0
		/// <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;
		}
Пример #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);
		}
Пример #12
0
        public ThirdGenTagTable(IReader reader, SegmentPointer indexHeaderLocation, FileSegmentGroup metaArea,
			MetaAllocator allocator, EngineDescription buildInfo)
        {
            _indexHeaderLocation = indexHeaderLocation;
            _metaArea = metaArea;
            _allocator = allocator;
            _buildInfo = buildInfo;

            Load(reader);
        }
Пример #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));
 }
Пример #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);
		}
Пример #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);
		}
Пример #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;
		}
Пример #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);
        }
Пример #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));
 }
Пример #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);
        }
Пример #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));
 }
Пример #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);
        }