1
0
Fork 0
mirror of https://github.com/marcrobledo/RomPatcher.js.git synced 2025-06-27 16:25:54 +00:00

Merge pull request #40 from laqieer/fix/ups_cut_glitch

Fix: UPS patch's cut glitch
This commit is contained in:
Marc Robledo 2022-03-18 10:26:07 +01:00 committed by GitHub
commit a45e635696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,10 +57,19 @@ UPS.prototype.apply=function(romFile, validate){
throw new Error('error_crc_input'); throw new Error('error_crc_input');
} }
/* fix the glitch that cut the end of the file if it's larger than the changed file patch was originally created with */
sizeOutput = this.sizeOutput
sizeInput = this.sizeInput
if(!validate && sizeInput < romFile.fileSize){
sizeInput = romFile.fileSize
if(sizeOutput < sizeInput){
sizeOutput = sizeInput
}
}
/* copy original file */ /* copy original file */
tempFile=new MarcFile(this.sizeOutput); tempFile=new MarcFile(sizeOutput);
romFile.copyToFile(tempFile, 0, this.sizeInput); romFile.copyToFile(tempFile, 0, sizeInput);
romFile.seek(0); romFile.seek(0);
@ -201,4 +210,4 @@ function createUPSFromFiles(original, modified){
patch.checksumInput=crc32(original); patch.checksumInput=crc32(original);
patch.checksumOutput=crc32(modified); patch.checksumOutput=crc32(modified);
return patch return patch
} }