Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e17f76340 | |||
| 1f9c95d6ac |
Binary file not shown.
@@ -25,11 +25,10 @@ export function CutData(gamePath) {
|
|||||||
/**
|
/**
|
||||||
* @param {string} gamePath
|
* @param {string} gamePath
|
||||||
* @param {string} patchPath
|
* @param {string} patchPath
|
||||||
* @param {boolean} isSkipVerify
|
|
||||||
* @returns {$CancellablePromise<[boolean, string]>}
|
* @returns {$CancellablePromise<[boolean, string]>}
|
||||||
*/
|
*/
|
||||||
export function DataExtract(gamePath, patchPath, isSkipVerify) {
|
export function DataExtract(gamePath, patchPath) {
|
||||||
return $Call.ByID(2161622254, gamePath, patchPath, isSkipVerify);
|
return $Call.ByID(2161622254, gamePath, patchPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,9 +58,8 @@ export function LDiffPatchData(gamePath) {
|
|||||||
/**
|
/**
|
||||||
* @param {string} gamePath
|
* @param {string} gamePath
|
||||||
* @param {string} patchPath
|
* @param {string} patchPath
|
||||||
* @param {boolean} isNeedHDiff
|
|
||||||
* @returns {$CancellablePromise<[boolean, string]>}
|
* @returns {$CancellablePromise<[boolean, string]>}
|
||||||
*/
|
*/
|
||||||
export function VersionValidate(gamePath, patchPath, isNeedHDiff) {
|
export function VersionValidate(gamePath, patchPath) {
|
||||||
return $Call.ByID(2105077257, gamePath, patchPath, isNeedHDiff);
|
return $Call.ByID(2105077257, gamePath, patchPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,15 +131,13 @@ export default function DiffPage() {
|
|||||||
setStageType('Version Validate')
|
setStageType('Version Validate')
|
||||||
setProgressUpdate(0)
|
setProgressUpdate(0)
|
||||||
setMaxProgressUpdate(1)
|
setMaxProgressUpdate(1)
|
||||||
const isNeedHDiff = validType !== 'hdiffmap.json'
|
const [validVersion, errorVersion] = await DiffService.VersionValidate(gameDir, diffDir)
|
||||||
const [validVersion, errorVersion] = await DiffService.VersionValidate(gameDir, diffDir, isNeedHDiff)
|
|
||||||
if (!handleResult(validVersion, errorVersion)) return
|
if (!handleResult(validVersion, errorVersion)) return
|
||||||
setProgressUpdate(1)
|
setProgressUpdate(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSkipVerify = ['manifest', 'hdifffiles.txt', 'hdifffiles.json'].includes(validType)
|
|
||||||
setStageType('Data Extract')
|
setStageType('Data Extract')
|
||||||
const [validData, errorData] = await DiffService.DataExtract(gameDir, diffDir, isSkipVerify)
|
const [validData, errorData] = await DiffService.DataExtract(gameDir, diffDir)
|
||||||
if (!handleResult(validData, errorData)) return
|
if (!handleResult(validData, errorData)) return
|
||||||
|
|
||||||
setStageType('Cut Data')
|
setStageType('Cut Data')
|
||||||
|
|||||||
@@ -35,13 +35,11 @@ func (h *DiffService) CheckTypeHDiff(patchPath string) (bool, string, string) {
|
|||||||
return false, "", "not found hdifffiles.txt or hdiffmap.json"
|
return false, "", "not found hdifffiles.txt or hdiffmap.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *DiffService) VersionValidate(gamePath, patchPath string, isNeedHDiff bool) (bool, string) {
|
func (h *DiffService) VersionValidate(gamePath, patchPath string) (bool, string) {
|
||||||
oldBinPath := filepath.Join(gamePath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes")
|
oldBinPath := filepath.Join(gamePath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes")
|
||||||
oldVersionData, err := models.ParseBinaryVersion(oldBinPath)
|
if _, err := os.Stat(oldBinPath); err != nil {
|
||||||
if err != nil {
|
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(patchPath); err != nil {
|
if _, err := os.Stat(patchPath); err != nil {
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
@@ -52,38 +50,33 @@ func (h *DiffService) VersionValidate(gamePath, patchPath string, isNeedHDiff bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isNeedHDiff {
|
okFull, errFull := sevenzip.IsFileIn7z(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes")
|
||||||
|
okDiff, errDiff := sevenzip.IsFileIn7z(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes.hdiff")
|
||||||
|
|
||||||
|
if (errFull != nil && errDiff != nil) || (!okFull && !okDiff) {
|
||||||
|
return false, "BinaryVersion file not found in patch"
|
||||||
|
}
|
||||||
|
|
||||||
|
var tempBinFile string
|
||||||
|
|
||||||
|
if okFull {
|
||||||
if err := sevenzip.ExtractAFileFromZip(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes", constant.TempUrl); err != nil {
|
if err := sevenzip.ExtractAFileFromZip(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes", constant.TempUrl); err != nil {
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
|
tempBinFile = filepath.Join(constant.TempUrl, "BinaryVersion.bytes")
|
||||||
binPath := filepath.Join(constant.TempUrl, "BinaryVersion.bytes")
|
} else {
|
||||||
newVersionData, err := models.ParseBinaryVersion(binPath)
|
|
||||||
if err != nil {
|
|
||||||
return false, err.Error()
|
|
||||||
}
|
|
||||||
defer os.Remove(binPath)
|
|
||||||
|
|
||||||
v := newVersionData.Subtract(oldVersionData)
|
|
||||||
if v != 0 && v != 1 {
|
|
||||||
return false, fmt.Sprintf("the diff version %s not valid with game version %s", newVersionData, oldVersionData)
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, "validated"
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := sevenzip.ExtractAFileFromZip(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes.hdiff", constant.TempUrl); err != nil {
|
if err := sevenzip.ExtractAFileFromZip(patchPath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes.hdiff", constant.TempUrl); err != nil {
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
patchBinFile := filepath.Join(constant.TempUrl, "BinaryVersion.bytes.hdiff")
|
patchBinFile := filepath.Join(constant.TempUrl, "BinaryVersion.bytes.hdiff")
|
||||||
sourceBinFile := filepath.Join(gamePath, "StarRail_Data\\StreamingAssets\\BinaryVersion.bytes")
|
sourceBinFile := oldBinPath
|
||||||
tempBinFile := filepath.Join(constant.TempUrl, "BinaryVersion.bytes")
|
tempBinFile = filepath.Join(constant.TempUrl, "BinaryVersion.bytes")
|
||||||
if err := hpatchz.ApplyPatch(sourceBinFile, patchBinFile, tempBinFile); err != nil {
|
if err := hpatchz.ApplyPatch(sourceBinFile, patchBinFile, tempBinFile); err != nil {
|
||||||
os.Remove(patchBinFile)
|
os.Remove(patchBinFile)
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
os.Remove(patchBinFile)
|
os.Remove(patchBinFile)
|
||||||
|
}
|
||||||
|
|
||||||
okFullPkg, err1 := sevenzip.IsFileIn7z(patchPath, "pkg_version")
|
okFullPkg, err1 := sevenzip.IsFileIn7z(patchPath, "pkg_version")
|
||||||
okDiffPkg, err2 := sevenzip.IsFileIn7z(patchPath, "pkg_version.hdiff")
|
okDiffPkg, err2 := sevenzip.IsFileIn7z(patchPath, "pkg_version.hdiff")
|
||||||
@@ -96,7 +89,6 @@ func (h *DiffService) VersionValidate(gamePath, patchPath string, isNeedHDiff bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if okDiffPkg {
|
if okDiffPkg {
|
||||||
|
|
||||||
if err := sevenzip.ExtractAFileFromZip(patchPath, "pkg_version.hdiff", constant.TempUrl); err != nil {
|
if err := sevenzip.ExtractAFileFromZip(patchPath, "pkg_version.hdiff", constant.TempUrl); err != nil {
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
@@ -119,8 +111,11 @@ func (h *DiffService) VersionValidate(gamePath, patchPath string, isNeedHDiff bo
|
|||||||
}
|
}
|
||||||
os.Remove(tempPkgFile)
|
os.Remove(tempPkgFile)
|
||||||
|
|
||||||
|
// MD5 check BinaryVersion
|
||||||
|
flags := false
|
||||||
for _, pkgData := range pkgDataList {
|
for _, pkgData := range pkgDataList {
|
||||||
if filepath.ToSlash(pkgData.RemoteFile) == "StarRail_Data/StreamingAssets/BinaryVersion.bytes" {
|
if filepath.ToSlash(pkgData.RemoteFile) == "StarRail_Data/StreamingAssets/BinaryVersion.bytes" {
|
||||||
|
flags = true
|
||||||
md5, err := verifier.FileMD5(tempBinFile)
|
md5, err := verifier.FileMD5(tempBinFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(tempBinFile)
|
os.Remove(tempBinFile)
|
||||||
@@ -134,15 +129,18 @@ func (h *DiffService) VersionValidate(gamePath, patchPath string, isNeedHDiff bo
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !flags {
|
||||||
|
os.Remove(tempBinFile)
|
||||||
|
return false, "BinaryVersion file not found in patch"
|
||||||
|
}
|
||||||
_, err = models.ParseBinaryVersion(tempBinFile)
|
_, err = models.ParseBinaryVersion(tempBinFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Remove(tempBinFile)
|
os.Remove(tempBinFile)
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Remove(tempBinFile)
|
os.Remove(tempBinFile)
|
||||||
return true, "validated"
|
return true, "validated"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *DiffService) HDiffPatchData(gamePath string) (bool, string) {
|
func (h *DiffService) HDiffPatchData(gamePath string) (bool, string) {
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ package diffService
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"firefly-launcher/pkg/constant"
|
"firefly-launcher/pkg/constant"
|
||||||
"firefly-launcher/pkg/verifier"
|
|
||||||
"firefly-launcher/pkg/sevenzip"
|
"firefly-launcher/pkg/sevenzip"
|
||||||
"github.com/wailsapp/wails/v3/pkg/application"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"io"
|
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *DiffService) DataExtract(gamePath, patchPath string, isSkipVerify bool) (bool, string) {
|
func (h *DiffService) DataExtract(gamePath, patchPath string) (bool, string) {
|
||||||
os.RemoveAll(constant.TempUrl)
|
os.RemoveAll(constant.TempUrl)
|
||||||
if _, err := os.Stat(gamePath); err != nil {
|
if _, err := os.Stat(gamePath); err != nil {
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
@@ -30,20 +30,7 @@ func (h *DiffService) DataExtract(gamePath, patchPath string, isSkipVerify bool)
|
|||||||
os.RemoveAll(constant.TempUrl)
|
os.RemoveAll(constant.TempUrl)
|
||||||
return false, err.Error()
|
return false, err.Error()
|
||||||
}
|
}
|
||||||
|
return true, "extract completed"
|
||||||
if !isSkipVerify {
|
|
||||||
validator, err := verifier.NewVerifier(gamePath, constant.TempUrl)
|
|
||||||
if err != nil {
|
|
||||||
os.RemoveAll(constant.TempUrl)
|
|
||||||
return false, err.Error()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := validator.VerifyAll(); err != nil {
|
|
||||||
os.RemoveAll(constant.TempUrl)
|
|
||||||
return false, err.Error()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true, "validated"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *DiffService) CutData(gamePath string) (bool, string) {
|
func (h *DiffService) CutData(gamePath string) (bool, string) {
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -98,7 +98,6 @@ func main() {
|
|||||||
DevToolsEnabled: true,
|
DevToolsEnabled: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
err = app.Run()
|
err = app.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const ProxyZipFile = "64bit.zip"
|
|||||||
const LauncherFile = "firefly-launcher.exe"
|
const LauncherFile = "firefly-launcher.exe"
|
||||||
const TempUrl = "./temp"
|
const TempUrl = "./temp"
|
||||||
|
|
||||||
const CurrentLauncherVersion = "1.7.0"
|
const CurrentLauncherVersion = "1.8.0"
|
||||||
|
|
||||||
type ToolFile string
|
type ToolFile string
|
||||||
|
|
||||||
@@ -19,15 +19,13 @@ const (
|
|||||||
Tool7zaDLL ToolFile = "bin/7za.dll"
|
Tool7zaDLL ToolFile = "bin/7za.dll"
|
||||||
Tool7zxaDLL ToolFile = "bin/7zxa.dll"
|
Tool7zxaDLL ToolFile = "bin/7zxa.dll"
|
||||||
ToolHPatchzExe ToolFile = "bin/hpatchz.exe"
|
ToolHPatchzExe ToolFile = "bin/hpatchz.exe"
|
||||||
ToolHDiffzExe ToolFile = "bin/hdiffz.exe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var RequiredFiles = map[ToolFile]string{
|
var RequiredFiles = map[ToolFile]string{
|
||||||
Tool7zaExe: "assets/7zip/7za.exe",
|
Tool7zaExe: "assets/7za.exe",
|
||||||
Tool7zaDLL: "assets/7zip/7za.dll",
|
Tool7zaDLL: "assets/7za.dll",
|
||||||
Tool7zxaDLL: "assets/7zip/7zxa.dll",
|
Tool7zxaDLL: "assets/7zxa.dll",
|
||||||
ToolHPatchzExe: "assets/HDiffPatch/hpatchz.exe",
|
ToolHPatchzExe: "assets/hpatchz.exe",
|
||||||
ToolHDiffzExe: "assets/HDiffPatch/hdiffz.exe",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t ToolFile) GetEmbedPath() string {
|
func (t ToolFile) GetEmbedPath() string {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BinaryVersion struct {
|
type BinaryVersion struct {
|
||||||
@@ -24,45 +23,25 @@ func ParseBinaryVersion(path string) (*BinaryVersion, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content := string(data)
|
content := string(data)
|
||||||
|
fmt.Println(content)
|
||||||
|
|
||||||
lastDash := strings.LastIndex(content, "-")
|
re := regexp.MustCompile(`([A-Za-z]+)(\d+)(?:\.(\d+))?(?:\.(\d+))?`)
|
||||||
if lastDash == -1 {
|
matches := re.FindStringSubmatch(content)
|
||||||
return nil, errors.New("no dash found in version string")
|
if len(matches) < 2 {
|
||||||
}
|
|
||||||
|
|
||||||
secondLastDash := strings.LastIndex(content[:lastDash], "-")
|
|
||||||
if secondLastDash == -1 {
|
|
||||||
return nil, errors.New("only one dash found in version string")
|
|
||||||
}
|
|
||||||
|
|
||||||
versionSlice := content[secondLastDash+1 : lastDash]
|
|
||||||
re := regexp.MustCompile(`^([A-Za-z]+)([\d\.]+)$`)
|
|
||||||
matches := re.FindStringSubmatch(versionSlice)
|
|
||||||
if len(matches) < 3 {
|
|
||||||
return nil, errors.New("invalid version format")
|
return nil, errors.New("invalid version format")
|
||||||
}
|
}
|
||||||
|
|
||||||
binaryVersion := BinaryVersion{
|
binaryVersion := BinaryVersion{
|
||||||
Name: matches[1],
|
Name: matches[1],
|
||||||
}
|
}
|
||||||
numbers := strings.Split(matches[2], ".")
|
if matches[2] != "" {
|
||||||
|
binaryVersion.Major, _ = strconv.Atoi(matches[2])
|
||||||
if len(numbers) > 0 {
|
|
||||||
binaryVersion.Major, err = strconv.Atoi(numbers[0])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
if len(matches) > 3 && matches[3] != "" {
|
||||||
|
binaryVersion.Minor, _ = strconv.Atoi(matches[3])
|
||||||
}
|
}
|
||||||
if len(numbers) > 1 {
|
if len(matches) > 4 && matches[4] != "" {
|
||||||
binaryVersion.Minor, err = strconv.Atoi(numbers[1])
|
binaryVersion.Patch, _ = strconv.Atoi(matches[4])
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(numbers) > 2 {
|
|
||||||
binaryVersion.Patch, err = strconv.Atoi(numbers[2])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binaryVersion.Data = data
|
binaryVersion.Data = data
|
||||||
|
|||||||
Reference in New Issue
Block a user