forked from WolvenKit/WolvenKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from WolvenKit/master
Sync/Update
- Loading branch information
Showing
14,775 changed files
with
284,464 additions
and
20,970 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
# These are supported funding model platforms | ||
# We also welcome written motivational letters for our devs :D anyway thanks to anyone supporting this project in advance <3 | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: traderain | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] | ||
ko_fi: traderain | ||
custom: ['http://paypal.me/traderain'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,7 @@ jobs: | |
steps: | ||
- name: Checkout github repo (+ download lfs dependencies) | ||
uses: actions/checkout@v2 | ||
with: | ||
lfs: true | ||
- name: Checkout LFS objects | ||
run: git lfs checkout | ||
- name: Setup NuGet.exe for use with actions | ||
- name: Setup Nuget.exe | ||
uses: NuGet/[email protected] | ||
with: | ||
nuget-version: latest | ||
|
@@ -29,15 +25,14 @@ jobs: | |
run: msbuild WolvenKit.sln -p:Configuration=Release -p:Platform=x64 -m | ||
- name: Zip Release | ||
run: | | ||
cd $Env:GITHUB_WORKSPACE\\WolvenKit\bin | ||
Compress-Archive -Path ./x64/Release/ -DestinationPath WolvenKit.zip | ||
Compress-Archive -Path $Env:GITHUB_WORKSPACE\\WolvenKit\\bin\\Release\\net5.0-windows\\ -DestinationPath $Env:GITHUB_WORKSPACE\\WolvenKit.zip | ||
- name: Deploy Nightly | ||
uses: Maxzor/deploy-nightly@v1.0.4 | ||
uses: WebFreak001/deploy-nightly@v1.1.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: https://uploads.github.com/repos/Traderain/Wolven-kit/releases/11743470/assets{?name,label} | ||
upload_url: https://uploads.github.com/repos/WolvenKit/Wolven-kit/releases/11743470/assets{?name,label} | ||
release_id: 11743470 | ||
asset_path: WolvenKit\bin\WolvenKit.zip | ||
asset_path: WolvenKit.zip | ||
asset_name: WolvenKit-Nightly-$$.zip | ||
asset_content_type: application/zip | ||
asset_content_type: application/zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,6 @@ jobs: | |
steps: | ||
- name: Checkout github repo (+ download lfs dependencies) | ||
uses: actions/checkout@v2 | ||
with: | ||
lfs: true | ||
- name: Checkout LFS objects | ||
run: git lfs checkout | ||
- name: Setup Nuget.exe | ||
uses: NuGet/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.IO.MemoryMappedFiles; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Catel.IoC; | ||
using WolvenKit.Common.Services; | ||
using CP77.CR2W.Extensions; | ||
using CP77Tools.Model; | ||
using Newtonsoft.Json; | ||
using WolvenKit.Common; | ||
using WolvenKit.Common.Extensions; | ||
using CP77.CR2W.Types; | ||
using WolvenKit.Common.Oodle; | ||
using Index = CP77Tools.Model.Index; | ||
|
||
namespace CP77.CR2W.Archive | ||
{ | ||
public class Archive : IGameArchive | ||
{ | ||
#region constructors | ||
|
||
public Archive() | ||
{ | ||
Header = new Header(); | ||
Index = new Index(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates and reads an archive from a path | ||
/// </summary> | ||
/// <param name="path"></param> | ||
public Archive(string path) | ||
{ | ||
ArchiveAbsolutePath = path; | ||
|
||
ReadTables(); | ||
} | ||
|
||
#endregion | ||
|
||
#region properties | ||
public EArchiveType TypeName => EArchiveType.Archive; | ||
|
||
public Header Header { get; set; } | ||
|
||
|
||
public Index Index { get; set; } | ||
|
||
|
||
public string ArchiveAbsolutePath { get; set; } | ||
|
||
[JsonIgnore] | ||
public Dictionary<ulong, FileEntry> Files => Index?.FileEntries; | ||
|
||
public int FileCount => Files?.Count ?? 0; | ||
|
||
[JsonIgnore] | ||
public string Name => Path.GetFileName(ArchiveAbsolutePath); | ||
#endregion | ||
|
||
#region methods | ||
|
||
/// <summary> | ||
/// Reads the tables info to the archive. | ||
/// </summary> | ||
private void ReadTables() | ||
{ | ||
//using var mmf = MemoryMappedFile.CreateFromFile(Filepath, FileMode.Open, Mmfhash, 0, MemoryMappedFileAccess.Read); | ||
|
||
// using (var vs = mmf.CreateViewStream(0, ArHeader.SIZE, MemoryMappedFileAccess.Read)) | ||
// { | ||
// _header = new ArHeader(new BinaryReader(vs)); | ||
// } | ||
|
||
// using (var vs = mmf.CreateViewStream((long)_header.Tableoffset, (long)_header.Tablesize, | ||
// MemoryMappedFileAccess.Read)) | ||
// { | ||
// _table = new Index(new BinaryReader(vs), this); | ||
// } | ||
|
||
using var vs = new FileStream(ArchiveAbsolutePath, FileMode.Open, FileAccess.Read); | ||
Header = new Header(new BinaryReader(vs)); | ||
vs.Seek((long) Header.IndexPosition, SeekOrigin.Begin); | ||
Index = new Index(new BinaryReader(vs), this); | ||
vs.Close(); | ||
} | ||
|
||
/// <summary> | ||
/// Serializes this archive to a redengine .archive file | ||
/// </summary> | ||
public void Serialize() | ||
{ | ||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
public bool CanUncook(ulong hash) | ||
{ | ||
if (!Files.ContainsKey(hash)) | ||
return false; | ||
var archiveItem = Files[hash]; | ||
string name = archiveItem.FileName; | ||
var hasBuffers = (archiveItem.SegmentsEnd - archiveItem.SegmentsStart) > 1; | ||
|
||
var values = Enum.GetNames(typeof(ECookedFileFormat)); | ||
var b = values.Any(e => e == Path.GetExtension(name)[1..]) || hasBuffers ; | ||
return b; | ||
} | ||
|
||
public void CopyFileToStream(Stream stream, ulong hash, bool decompressBuffers) | ||
{ | ||
if (!Files.ContainsKey(hash)) return; | ||
|
||
var entry = Files[hash]; | ||
var startindex = (int)entry.SegmentsStart; | ||
var nextindex = (int)entry.SegmentsEnd; | ||
|
||
// decompress main file | ||
CopyFileSegmentToStream(stream, this.Index.FileSegments[startindex], true); | ||
|
||
// get buffers, optionally decompressing them | ||
for (int j = startindex + 1; j < nextindex; j++) | ||
{ | ||
var offsetentry = this.Index.FileSegments[j]; | ||
CopyFileSegmentToStream(stream, offsetentry, decompressBuffers); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Extracts a FileSegment to a stream | ||
/// </summary> | ||
/// <param name="outstream"></param> | ||
/// <param name="offsetentry"></param> | ||
/// <param name="decompress"></param> | ||
private void CopyFileSegmentToStream(Stream outstream, FileSegment offsetentry, bool decompress) | ||
{ | ||
using var fs = new FileStream(ArchiveAbsolutePath, FileMode.Open, FileAccess.Read); | ||
using var br = new BinaryReader(fs); | ||
br.BaseStream.Seek((long)offsetentry.Offset, SeekOrigin.Begin); | ||
|
||
|
||
var zSize = offsetentry.ZSize; | ||
var size = offsetentry.Size; | ||
|
||
if (!decompress) | ||
{ | ||
var buffer = br.ReadBytes((int)zSize); | ||
outstream.Write(buffer); | ||
} | ||
else | ||
{ | ||
br.DecompressBuffer(outstream, zSize, size); | ||
} | ||
} | ||
|
||
|
||
#endregion | ||
|
||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
Oops, something went wrong.