Skip to content

Commit

Permalink
Fix OneSaber crash with customjsondata
Browse files Browse the repository at this point in the history
  • Loading branch information
kodenamekrak committed Dec 20, 2023
1 parent 363de39 commit f324211
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 50 deletions.
10 changes: 10 additions & 0 deletions addr2line.ps1
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 15 additions & 0 deletions copy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
17 changes: 17 additions & 0 deletions createqmod.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 "") {
Expand All @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion mod.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down
28 changes: 9 additions & 19 deletions ndk-stack.ps1
Original file line number Diff line number Diff line change
@@ -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"
}
52 changes: 52 additions & 0 deletions pull-tombstone.ps1
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"info": {
"name": "SongChartVisualizer",
"id": "songchartvisualizer",
"version": "1.0.0",
"version": "1.0.1",
"url": null,
"additionalData": {
"overrideSoName": "libsongchartvisualizer.so",
Expand Down
58 changes: 29 additions & 29 deletions qpm.shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand Down
7 changes: 7 additions & 0 deletions src/UI/ChartView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *>();
_windowGraph->_canvas = _floatingScreen->GetComponent<Canvas *>();
Expand Down
38 changes: 38 additions & 0 deletions validate-modjson.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f324211

Please sign in to comment.