diff --git a/addr2line.ps1 b/addr2line.ps1 new file mode 100644 index 0000000..ed87d05 --- /dev/null +++ b/addr2line.ps1 @@ -0,0 +1,10 @@ +param($p1, $p2) + +if ($p1 -and $p2) +{ + & C:\android-ndk-r26b\toolchains\llvm\prebuilt\windows-x86_64\bin\llvm-addr2line.exe -e .\build\debug\$p1 $p2 +} +else +{ + echo give at least 1 argument +} diff --git a/copy.ps1 b/copy.ps1 index bf36616..70fe5ae 100644 --- a/copy.ps1 +++ b/copy.ps1 @@ -46,6 +46,10 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } +& $PSScriptRoot/validate-modjson.ps1 +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} $modJson = Get-Content "./mod.json" -Raw | ConvertFrom-Json $modFiles = $modJson.modFiles @@ -58,6 +62,17 @@ foreach ($fileName in $modFiles) { } } +$lateModFiles = $modJson.lateModFiles + +foreach ($fileName in $lateModFiles) { + if ($useDebug -eq $true) { + & adb push build/debug/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName + } else { + & adb push build/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName + } +} + + & $PSScriptRoot/restart-game.ps1 if ($log -eq $true) { diff --git a/createqmod.ps1 b/createqmod.ps1 index 191c31d..89c9300 100644 --- a/createqmod.ps1 +++ b/createqmod.ps1 @@ -17,6 +17,10 @@ if ($help -eq $true) { $mod = "./mod.json" +& $PSScriptRoot/validate-modjson.ps1 +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} $modJson = Get-Content $mod -Raw | ConvertFrom-Json if ($qmodName -eq "") { @@ -42,6 +46,19 @@ foreach ($mod in $modJson.modFiles) { $filelist += $path } +foreach ($mod in $modJson.lateModFiles) { + $path = "./build/" + $mod + if (-not (Test-Path $path)) { + $path = "./extern/libs/" + $mod + } + if (-not (Test-Path $path)) { + Write-Output "Error: could not find dependency: $path" + exit 1 + } + $filelist += $path +} + + foreach ($lib in $modJson.libraryFiles) { $path = "./build/" + $lib if (-not (Test-Path $path)) { diff --git a/mod.template.json b/mod.template.json index a28d119..b6f0e79 100644 --- a/mod.template.json +++ b/mod.template.json @@ -5,9 +5,10 @@ "id": "${mod_id}", "author": "Eris", "porter": "KodenameKRAK", - "version": "1.0.0", + "version": "${version}", "packageId": "com.beatgames.beatsaber", "packageVersion": "1.28.0_4124311467", + "modloader": "QuestLoader", "description": "", "dependencies": [], "modFiles": [], diff --git a/ndk-stack.ps1 b/ndk-stack.ps1 index ac30cea..0bc1a69 100644 --- a/ndk-stack.ps1 +++ b/ndk-stack.ps1 @@ -1,29 +1,19 @@ -Param( - [Parameter(Mandatory=$false)] - [String] $logName = "log.log", - - [Parameter(Mandatory=$false)] - [Switch] $help -) - -if ($help -eq $true) { - Write-Output "`"NDK-Stack`" - Processes a tombstone using the debug .so to find file locations" - Write-Output "`n-- Arguments --`n" - - Write-Output "LogName `t`t The file name of the tombstone to process" - - exit -} - -if (Test-Path "./ndkpath.txt") { +if (Test-Path "./ndkpath.txt") +{ $NDKPath = Get-Content ./ndkpath.txt } else { $NDKPath = $ENV:ANDROID_NDK_HOME } + + $stackScript = "$NDKPath/ndk-stack" if (-not ($PSVersionTable.PSEdition -eq "Core")) { $stackScript += ".cmd" } -Get-Content $logName | & $stackScript -sym ./build/debug/ > "$($logName)_processed.log" +if ($args.Count -eq 0) { + Get-Content ./log.txt | & $stackScript -sym ./build/debug/ > log_unstripped.log +} else { + Get-Content $args[0] | & $stackScript -sym ./build/debug/ > "$($args[0])_unstripped.txt" +} diff --git a/pull-tombstone.ps1 b/pull-tombstone.ps1 new file mode 100644 index 0000000..6977df0 --- /dev/null +++ b/pull-tombstone.ps1 @@ -0,0 +1,52 @@ +Param( + [Parameter(Mandatory=$false)] + [String] $fileName = "RecentCrash.log", + + [Parameter(Mandatory=$false)] + [Switch] $analyze, + + [Parameter(Mandatory=$false)] + [Switch] $help +) + +if ($help -eq $true) { + Write-Output "`"Pull-Tombstone`" - Finds and pulls the most recent tombstone from your quest, optionally analyzing it with ndk-stack" + Write-Output "`n-- Arguments --`n" + + Write-Output "-FileName `t The name for the output file, defaulting to RecentCrash.log" + Write-Output "-Analyze `t Runs ndk-stack on the file after pulling" + + exit +} + +$global:currentDate = get-date +$global:recentDate = $Null +$global:recentTombstone = $Null + +for ($i = 0; $i -lt 3; $i++) { + $stats = & adb shell stat /sdcard/Android/data/com.beatgames.beatsaber/files/tombstone_0$i + $date = (Select-String -Input $stats -Pattern "(?<=Modify: )\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?=.\d{9})").Matches.Value + if([string]::IsNullOrEmpty($date)) { + Write-Output "Failed to pull tombstone, exiting..." + exit 1; + } + $dateObj = [datetime]::ParseExact($date, "yyyy-MM-dd HH:mm:ss", $Null) + $difference = [math]::Round(($currentDate - $dateObj).TotalMinutes) + if ($difference -eq 1) { + Write-Output "Found tombstone_0$i $difference minute ago" + } else { + Write-Output "Found tombstone_0$i $difference minutes ago" + } + if (-not $recentDate -or $recentDate -lt $dateObj) { + $recentDate = $dateObj + $recentTombstone = $i + } +} + +Write-Output "Latest tombstone was tombstone_0$recentTombstone" + +& adb pull /sdcard/Android/data/com.beatgames.beatsaber/files/tombstone_0$recentTombstone $fileName + +if ($analyze) { + & $PSScriptRoot/ndk-stack.ps1 $fileName +} diff --git a/qpm.json b/qpm.json index 681bba3..0d7c63e 100644 --- a/qpm.json +++ b/qpm.json @@ -4,7 +4,7 @@ "info": { "name": "SongChartVisualizer", "id": "songchartvisualizer", - "version": "1.0.0", + "version": "1.0.1", "url": null, "additionalData": { "overrideSoName": "libsongchartvisualizer.so", diff --git a/qpm.shared.json b/qpm.shared.json index aa6ee8e..d380f27 100644 --- a/qpm.shared.json +++ b/qpm.shared.json @@ -5,13 +5,14 @@ "info": { "name": "SongChartVisualizer", "id": "songchartvisualizer", - "version": "1.0.0", + "version": "1.0.1", "url": null, "additionalData": { "overrideSoName": "libsongchartvisualizer.so", "cmake": true } }, + "workspace": null, "dependencies": [ { "id": "beatsaber-hook", @@ -53,44 +54,43 @@ "versionRange": "^9.0.0", "additionalData": {} } - ], - "workspace": null + ] }, "restoredDependencies": [ { "dependency": { "id": "bsml", - "versionRange": "=0.3.2", + "versionRange": "=0.3.3", "additionalData": { - "soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.2/libbsml.so", - "debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.2/debug_libbsml.so", + "soLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.3/libbsml.so", + "debugSoLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.3/debug_libbsml.so", "overrideSoName": "libbsml.so", - "modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.2/BSML.qmod", - "branchName": "version-v0.3.2" + "modLink": "https://github.com/RedBrumbler/Quest-BSML/releases/download/v0.3.3/BSML.qmod", + "branchName": "version-v0.3.3" } }, - "version": "0.3.2" + "version": "0.3.3" }, { "dependency": { - "id": "rapidjson-macros", - "versionRange": "=0.4.6", + "id": "libil2cpp", + "versionRange": "=0.2.5", "additionalData": { - "headersOnly": true, - "branchName": "version-v0.4.6" + "headersOnly": true } }, - "version": "0.4.6" + "version": "0.2.5" }, { "dependency": { - "id": "libil2cpp", - "versionRange": "=0.2.3", + "id": "rapidjson-macros", + "versionRange": "=1.0.0", "additionalData": { - "headersOnly": true + "headersOnly": true, + "branchName": "version-v1.0.0" } }, - "version": "0.2.3" + "version": "1.0.0" }, { "dependency": { @@ -120,16 +120,17 @@ { "dependency": { "id": "tinyxml2", - "versionRange": "=9.0.5", + "versionRange": "=9.0.6", "additionalData": { - "soLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.5/libtinyxml2.so", - "debugSoLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.5/debug_libtinyxml2.so", + "soLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.6/libtinyxml2.so", + "debugSoLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.6/debug_libtinyxml2.so", "overrideSoName": "libtinyxml2.so", - "modLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.5/tinyxml2.qmod", - "branchName": "version-v9.0.5" + "modLink": "https://github.com/MillzyDev/NDK-tinyxml2/releases/download/v9.0.6/.qmod", + "branchName": "version/v9_0_6", + "cmake": true } }, - "version": "9.0.5" + "version": "9.0.6" }, { "dependency": { @@ -160,16 +161,15 @@ { "dependency": { "id": "config-utils", - "versionRange": "=1.0.2", + "versionRange": "=1.1.0", "additionalData": { "headersOnly": true, - "soLink": "https://github.com/darknight1050/config-utils/releases/download/v1.0.2/libconfig-utils_test.so", - "debugSoLink": "https://github.com/darknight1050/config-utils/releases/download/v1.0.2/debug_libconfig-utils_test.so", + "soLink": "https://github.com/darknight1050/config-utils/releases/download/v1.1.0/libconfig-utils_test.so", "overrideSoName": "libconfig-utils_test.so", - "branchName": "version-v1.0.2" + "branchName": "version/v1_1_0" } }, - "version": "1.0.2" + "version": "1.1.0" }, { "dependency": { diff --git a/src/UI/ChartView.cpp b/src/UI/ChartView.cpp index a3b694c..f8ad6c1 100644 --- a/src/UI/ChartView.cpp +++ b/src/UI/ChartView.cpp @@ -70,6 +70,13 @@ namespace SongChartVisualizer } _npsSections = GetNpsSections(_beatmapData); + if (_npsSections.size() <= 0) + { + getLogger().debug("_npsSections was empty, destroying graph"); + UnityEngine::Object::Destroy(_floatingScreen); + _shouldNotRunTick = true; + return; + } _windowGraph = _floatingScreen->get_gameObject()->AddComponent(); _windowGraph->_canvas = _floatingScreen->GetComponent(); diff --git a/validate-modjson.ps1 b/validate-modjson.ps1 new file mode 100644 index 0000000..f294752 --- /dev/null +++ b/validate-modjson.ps1 @@ -0,0 +1,38 @@ +$mod = "./mod.json" + +if (-not (Test-Path -Path $mod)) { + if (Test-Path -Path ".\mod.template.json") { + & qpm qmod build + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + } + else { + Write-Output "Error: mod.json and mod.template.json were not present" + exit 1 + } +} + +Write-Output "Creating qmod from mod.json" + +$psVersion = $PSVersionTable.PSVersion.Major +if ($psVersion -ge 6) { + $schemaUrl = "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher.QMod/main/QuestPatcher.QMod/Resources/qmod.schema.json" + Invoke-WebRequest $schemaUrl -OutFile ./mod.schema.json + + $schema = "./mod.schema.json" + $modJsonRaw = Get-Content $mod -Raw + $modSchemaRaw = Get-Content $schema -Raw + + Remove-Item $schema + + Write-Output "Validating mod.json..." + if (-not ($modJsonRaw | Test-Json -Schema $modSchemaRaw)) { + Write-Output "Error: mod.json is not valid" + exit 1 + } +} +else { + Write-Output "Could not validate mod.json with schema: powershell version was too low (< 6)" +} +exit