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

fixed a bug in IPS patching, now it can patch files and make them bigger if needed

This commit is contained in:
Marc Robledo 2017-10-22 11:09:22 +02:00
parent ad3bbb54c7
commit 69fcad33bb
2 changed files with 8 additions and 9 deletions

15
ips.js
View file

@ -1,4 +1,4 @@
/* IPS module for RomPatcher.js v20170722 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */ /* IPS module for RomPatcher.js v20171022 - Marc Robledo 2016-2017 - http://www.marcrobledo.com/license */
/* File format specification: http://www.smwiki.net/wiki/IPS_file_format */ /* File format specification: http://www.smwiki.net/wiki/IPS_file_format */
var MAX_IPS_SIZE=16777216; var MAX_IPS_SIZE=16777216;
@ -76,22 +76,21 @@ IPS.prototype.export=function(){
return tempFile return tempFile
} }
IPS.prototype.apply=function(romFile){ IPS.prototype.apply=function(romFile){
var newFileSize=romFile.fileSize;
for(var i=0; i<this.records.length; i++){ for(var i=0; i<this.records.length; i++){
var rec=this.records[i]; var rec=this.records[i];
if(rec.type===RECORD_RLE){ if(rec.type===RECORD_RLE){
if(rec.offset+rec.length>romFile.fileSize){ if(rec.offset+rec.length>newFileSize){
MarcDialogs.alert('Invalid ROM file (too big?).'); newFileSize=rec.offset+rec.length;
return false;
} }
}else{ }else{
if(rec.offset+rec.data.length>romFile.fileSize){ if(rec.offset+rec.data.length>newFileSize){
MarcDialogs.alert('Invalid ROM file (too big?).'); newFileSize=rec.offset+rec.data.length;
return false;
} }
} }
} }
tempFile=new MarcBinFile(romFile.fileSize); tempFile=new MarcBinFile(newFileSize);
var clonedFileSize=this.truncate || romFile.fileSize; var clonedFileSize=this.truncate || romFile.fileSize;
for(var i=0; i<romFile.fileSize; i++) for(var i=0; i<romFile.fileSize; i++)

View file

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
#v2017073 #v20171021
#CACHE: #CACHE:
index.html index.html
RomPatcher.css RomPatcher.css