commit 9fa168c399a3b6d9897c9cd80183f0ea85b9e8ba Author: akanyan Date: Thu May 30 11:02:47 2024 +0900 initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..00d2e13 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..02e4573 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +This tool upgrades OGKR charts from 1.6.0 (Act 2) to 1.7.0 (Act 3 (SDDT 1.45)). Useful for charts that were deleted in 1.45 or earlier. + +### Why +SDDT 1.45 added an extra number to `[B_PALETTE]` rows, used by Random Access Emotions and MEGALOVANIA, but seemingly set to 0 everywhere else. S*GA adjusted everything that was still in the game as of 1.45, but older deleted charts (e.g. Hibachi) load without any bullets. This script fixes that. + +### Usage +```sh +npm i +npx tsc index.ts +node index.js +``` +Where `Axyz` is an omnimix option directory. \ No newline at end of file diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..f1d1795 --- /dev/null +++ b/index.ts @@ -0,0 +1,63 @@ +import * as fs from 'fs/promises'; +import * as path from 'path'; + +let g_count = 0; +let g_countSkip = 0; + +const readChart = async (fname: string) => { + const data = (await fs.readFile(fname)).toString().split('\n'); + let res: string[] = []; + let isBPalette = false; + let isCorrectVersion = false; + for(const line of data) { + if(line.startsWith('VERSION')) { + if(line.trim() === 'VERSION\t1\t6\t0') { + res.push('VERSION\t1\t7\t0\r\n'); + isCorrectVersion = true; + } + } else if(line.startsWith('[')) { + isBPalette = line.trim() === '[B_PALETTE]'; + res.push(line); + } else if(isBPalette) { + if(line.trim().length > 0) { + res.push(`${line.trim()}\t0\r\n`); + } else { + res.push(line); + } + } else { + res.push(line); + } + } + if(!isCorrectVersion) { + g_countSkip += 1; + console.log(`Skipped ${fname}`); + } else { + g_count += 1; + await fs.writeFile(fname, res); + console.log(`Updated ${fname}`); + } +} + +(async () => { + if(process.argv.length < 3) { + console.log(`Usage: ${process.argv[0]} ${process.argv[1]} `); + return; + } + const p = process.argv[2]; + const dirs = (await fs.readdir(p)); + + const promises: Promise[] = []; + for(const dir of dirs) { + const subpath = path.join(p, dir); + const subdir = await fs.readdir(subpath); + for(const file of subdir) { + if(file.endsWith("ogkr")) { + promises.push(readChart(path.join(p, dir, file))); + } + } + } + + await Promise.all(promises); + + console.log(`${g_count} files updated, ${g_countSkip} files skipped.`); +})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..99b380d --- /dev/null +++ b/package-lock.json @@ -0,0 +1,38 @@ +{ + "name": "ogkr-upgrade-script", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@types/node": "^20.12.13", + "typescript": "^5.4.5" + } + }, + "node_modules/@types/node": { + "version": "20.12.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.13.tgz", + "integrity": "sha512-gBGeanV41c1L171rR7wjbMiEpEI/l5XFQdLLfhr/REwpgDy/4U8y89+i8kRiLzDyZdOkXh+cRaTetUnCYutoXA==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/typescript": { + "version": "5.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", + "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..16dc437 --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@types/node": "^20.12.13", + "typescript": "^5.4.5" + } +}