mirror of
https://github.com/marcrobledo/RomPatcher.js.git
synced 2025-06-27 16:25:54 +00:00
version 3.0RC3
This commit is contained in:
parent
4a928085fc
commit
b2f1b8d57e
6 changed files with 201 additions and 188 deletions
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var PRECACHE_ID = 'rom-patcher-js';
|
var PRECACHE_ID = 'rom-patcher-js';
|
||||||
var PRECACHE_VERSION = 'v30rc2c';
|
var PRECACHE_VERSION = 'v30rc3';
|
||||||
var PRECACHE_URLS = [
|
var PRECACHE_URLS = [
|
||||||
'/RomPatcher.js/', '/RomPatcher.js/index.html',
|
'/RomPatcher.js/', '/RomPatcher.js/index.html',
|
||||||
'/RomPatcher.js/manifest.json',
|
'/RomPatcher.js/manifest.json',
|
||||||
|
|
|
@ -151,7 +151,7 @@
|
||||||
<button id="button-settings" class="btn-transparent"><img src="./webapp/icon_settings.svg" loading="lazy" class="icon settings" /> <span data-localize="yes">Settings</span></button>
|
<button id="button-settings" class="btn-transparent"><img src="./webapp/icon_settings.svg" loading="lazy" class="icon settings" /> <span data-localize="yes">Settings</span></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Rom Patcher JS <small>v3.0 <a style="color:rgb(255, 197, 7)" href="legacy/" rel="nofollow">RC2</a></small> by <a href="/">Marc Robledo</a>
|
Rom Patcher JS <small>v3.0 <a style="color:rgb(255, 197, 7)" href="legacy/" rel="nofollow">RC3</a></small> by <a href="/">Marc Robledo</a>
|
||||||
<br />
|
<br />
|
||||||
<img src="./webapp/icon_github.svg" loading="lazy" class="icon github" /> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a>
|
<img src="./webapp/icon_github.svg" loading="lazy" class="icon github" /> <a href="https://github.com/marcrobledo/RomPatcher.js/" target="_blank">See on GitHub</a>
|
||||||
<img src="./webapp/icon_heart.svg" loading="lazy" class="icon heart" /> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a>
|
<img src="./webapp/icon_heart.svg" loading="lazy" class="icon heart" /> <a href="https://www.paypal.me/marcrobledo/5" target="_blank" rel="nofollow">Donate</a>
|
||||||
|
|
|
@ -736,6 +736,7 @@ var RomPatcherWeb = (function () {
|
||||||
if (ZIPManager.isZipFile(binFile)) {
|
if (ZIPManager.isZipFile(binFile)) {
|
||||||
ZIPManager.unzipPatches(binFile._u8array.buffer);
|
ZIPManager.unzipPatches(binFile._u8array.buffer);
|
||||||
} else {
|
} else {
|
||||||
|
try{
|
||||||
const parsedPatch = RomPatcher.parsePatchFile(binFile);
|
const parsedPatch = RomPatcher.parsePatchFile(binFile);
|
||||||
if (parsedPatch) {
|
if (parsedPatch) {
|
||||||
patch = parsedPatch;
|
patch = parsedPatch;
|
||||||
|
@ -837,6 +838,9 @@ var RomPatcherWeb = (function () {
|
||||||
} else {
|
} else {
|
||||||
_setToastError(_('Invalid patch file'));
|
_setToastError(_('Invalid patch file'));
|
||||||
}
|
}
|
||||||
|
}catch(ex){
|
||||||
|
_setToastError(ex.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* BinFile.js (last update: 2024-02-27)
|
* BinFile.js (last update: 2024-08-21)
|
||||||
* by Marc Robledo, https://www.marcrobledo.com
|
* by Marc Robledo, https://www.marcrobledo.com
|
||||||
*
|
*
|
||||||
* a JS class for reading/writing sequentially binary data from/to a file
|
* a JS class for reading/writing sequentially binary data from/to a file
|
||||||
|
@ -188,7 +188,7 @@ BinFile.prototype.slice = function (offset, len, doNotClone) {
|
||||||
else if (len === 0)
|
else if (len === 0)
|
||||||
throw new Error('zero length provided for slicing');
|
throw new Error('zero length provided for slicing');
|
||||||
else
|
else
|
||||||
offset = Math.floor(offset);
|
len = Math.floor(len);
|
||||||
|
|
||||||
if (offset === 0 && len === this.fileSize && doNotClone)
|
if (offset === 0 && len === this.fileSize && doNotClone)
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -204,7 +204,6 @@ APS.buildFromRoms=function(original, modified){
|
||||||
}else{
|
}else{
|
||||||
patch.addRecord(offset, differentBytes);
|
patch.addRecord(offset, differentBytes);
|
||||||
}
|
}
|
||||||
//NO se puede comentar??? why????
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
test.js
10
test.js
|
@ -132,6 +132,16 @@ const MODIFIED_TEST_DATA = (new Uint8Array([
|
||||||
const modifiedFile = new BinFile(MODIFIED_TEST_DATA);
|
const modifiedFile = new BinFile(MODIFIED_TEST_DATA);
|
||||||
const patch = RomPatcher.createPatch(originalFile, modifiedFile, patchFormat);
|
const patch = RomPatcher.createPatch(originalFile, modifiedFile, patchFormat);
|
||||||
const patchedFile = RomPatcher.applyPatch(originalFile, patch, { requireValidation: true });
|
const patchedFile = RomPatcher.applyPatch(originalFile, patch, { requireValidation: true });
|
||||||
|
|
||||||
|
if (patchFormat === 'bps') {
|
||||||
|
const patchFile = patch.export();
|
||||||
|
const patchChecksum = patchFile.hashCRC32(0, patchFile.fileSize - 4);
|
||||||
|
if (patch.patchChecksum !== patchChecksum)
|
||||||
|
throw new Error('invalid patch checksum');
|
||||||
|
else if (patchFile.hashCRC32() !== 0x2144df1c)
|
||||||
|
throw new Error('invalid BPS crc32');
|
||||||
|
}
|
||||||
|
|
||||||
if (patchedFile.hashCRC32() !== modifiedFile.hashCRC32())
|
if (patchedFile.hashCRC32() !== modifiedFile.hashCRC32())
|
||||||
throw new Error('modified and patched files\' crc32 do not match');
|
throw new Error('modified and patched files\' crc32 do not match');
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue