✨ Allow installPatch to be configurable
This commit is contained in:
parent
2548b00684
commit
40346cadae
3 changed files with 29 additions and 19 deletions
|
@ -1,14 +0,0 @@
|
|||
import * as fs from 'fs';
|
||||
import * as zlib from 'zlib';
|
||||
|
||||
const fileReadStream = fs.createReadStream('/tmp/patcher/Assets/swtor_de-de_area_alderaan_1.tor');
|
||||
|
||||
const decompressTransform = zlib.createInflateRaw();
|
||||
decompressTransform.on('error', (error) => {
|
||||
//TODO: need to throw error sync, not async
|
||||
throw new Error(`Error during decompression: ${error.message}`);
|
||||
});
|
||||
|
||||
const fileWriteStream = fs.createWriteStream('/tmp/patcher/Assets/swtor_de-de_area_alderaan_1.tor.raw');
|
||||
|
||||
fileReadStream.pipe(decompressTransform).pipe(fileWriteStream);
|
|
@ -1,7 +1,31 @@
|
|||
import getManifest from './ssn/getManifest';
|
||||
import failWithError from './failWithError';
|
||||
import { Product } from './interfaces/ISettings';
|
||||
import getPatch from './ssn/getPatch';
|
||||
import verifyProductName from './ssn/verify/verifyProductName';
|
||||
|
||||
const failFunction = failWithError.bind(null, 'node dist/installPatch.js <product> <from> <to>');
|
||||
|
||||
if (process.argv.length !== 5) {
|
||||
failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
|
||||
}
|
||||
|
||||
//Check that product name is valid
|
||||
const product = process.argv[2];
|
||||
if (!verifyProductName(product)) {
|
||||
failFunction(`"${product.substring(0, 300)}" is not a valid product name.`);
|
||||
}
|
||||
|
||||
//Check that from and to are valid numbers
|
||||
const from = process.argv[3];
|
||||
const to = process.argv[4];
|
||||
if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) {
|
||||
failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
|
||||
}
|
||||
if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) {
|
||||
failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const patch = await getPatch('assets_swtor_de_de', -1, 0);
|
||||
const patch = await getPatch(product as Product, Number(from), Number(to));
|
||||
//console.log(patch);
|
||||
})();
|
||||
|
|
|
@ -12,9 +12,9 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) {
|
|||
let curChar = encryptedChunk.readUInt8(i);
|
||||
|
||||
//decrypt byte
|
||||
const keyPart = ((key2 | 2) >>> 0) & 0xFFFF;
|
||||
const decryptedByte = int32Mul(keyPart, keyPart ^ 1) >>> 8;
|
||||
curChar = (curChar ^ (decryptedByte & 0xFF)) & 0xFF;
|
||||
const keyPart = (key2 | 2) & 0xFFFF;
|
||||
const decryptedByte = (keyPart * (keyPart ^ 1)) >>> 8;
|
||||
curChar ^= decryptedByte & 0xFF;
|
||||
|
||||
//update keys
|
||||
[key0, key1, key2] = updateKeys([key0, key1, key2], curChar);
|
||||
|
|
Loading…
Reference in a new issue