mirror of
https://github.com/marcrobledo/savegame-editors.git
synced 2025-04-24 16:35:10 +00:00
TOTK: added support for mods that add lots of new game variables
This commit is contained in:
parent
dc8aafc570
commit
2e5d757584
@ -1,7 +1,7 @@
|
||||
/*
|
||||
The legend of Zelda: Tears of the Kingdom savegame editor - Item class (last update 2024-01-02)
|
||||
|
||||
by Marc Robledo 2023
|
||||
by Marc Robledo 2023-2024
|
||||
item names compiled by Echocolat, Exincracci, HylianLZ and Karlos007
|
||||
*/
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
The legend of Zelda: Tears of the Kingdom savegame editor (last update 2023-09-02)
|
||||
The legend of Zelda: Tears of the Kingdom savegame editor (last update 2024-01-02)
|
||||
|
||||
by Marc Robledo 2023
|
||||
by Marc Robledo 2023-2024
|
||||
*/
|
||||
|
||||
var currentEditingItem;
|
||||
@ -9,7 +9,7 @@ var currentEditingItem;
|
||||
SavegameEditor={
|
||||
Name:'The legend of Zelda: Tears of the Kingdom',
|
||||
Filename:['progress.sav','caption.sav'],
|
||||
Version:20230902,
|
||||
Version:20240102,
|
||||
|
||||
/* Settings */
|
||||
Settings:{
|
||||
@ -260,7 +260,7 @@ SavegameEditor={
|
||||
_getOffsets:function(){
|
||||
var ret=true;
|
||||
this.Offsets={};
|
||||
for(var i=0x000028; i<0x03c800; i+=8){
|
||||
for(var i=0x000028; i<Variable.hashTableEnd; i+=8){
|
||||
var hash=tempFile.readU32(i);
|
||||
var foundHashIndex=this.Hashes.indexOf(hash);
|
||||
if(hash===0xa3db7114){ //guidsArray
|
||||
@ -294,7 +294,7 @@ SavegameEditor={
|
||||
},
|
||||
_getOffsetsByHashes:function(hashes, single){
|
||||
var offsets={};
|
||||
for(var i=0x000028; i<0x03c800; i+=8){
|
||||
for(var i=0x000028; i<Variable.hashTableEnd; i+=8){
|
||||
var hash=tempFile.readU32(i);
|
||||
var foundHashIndex=hashes.indexOf(hash);
|
||||
if(hash===0xa3db7114){ //found MetaData.SaveTypeHash
|
||||
@ -1044,6 +1044,7 @@ SavegameEditor={
|
||||
}
|
||||
}
|
||||
}else if(tempFile.readU32(0)===0x01020304 && tempFile.fileSize>=2307552 && tempFile.fileSize<4194304){
|
||||
Variable.findHashTableEnd();
|
||||
var foundAllHashes=this._getOffsets();
|
||||
if(foundAllHashes){
|
||||
var header=tempFile.readU32(4);
|
||||
@ -1055,7 +1056,7 @@ SavegameEditor={
|
||||
break;
|
||||
}
|
||||
}
|
||||
setValue('version', knownSavegameVersion || 'Unknown');
|
||||
setValue('version', knownSavegameVersion || '*Game mod*');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
The legend of Zelda: Tears of the Kingdom savegame editor - variable reader/writer (last update 2023-08-02)
|
||||
by Marc Robledo 2023
|
||||
The legend of Zelda: Tears of the Kingdom savegame editor - variable reader/writer (last update 2024-01-02)
|
||||
by Marc Robledo 2023-2024
|
||||
*/
|
||||
|
||||
|
||||
@ -704,12 +704,9 @@ Variable._getHashOffset=function(hashInt){
|
||||
if(Variable.cachedOffsets[hashInt])
|
||||
return Variable.cachedOffsets[hashInt];
|
||||
|
||||
for(var i=0x000028; i<0x03c800; i+=8){
|
||||
var currentHash=tempFile.readU32(i);
|
||||
if(currentHash===hashInt){
|
||||
for(var i=0x000028; i<Variable.hashTableEnd; i+=8){
|
||||
if(tempFile.readU32(i)===hashInt){
|
||||
return i+4;
|
||||
}else if(hashInt===0xa3db7114){ //found MetaData.SaveTypeHash
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new Error('Hash '+Variable.toHexString(hashInt)+' not found');
|
||||
@ -753,9 +750,31 @@ Variable.joinUInt64=function(lower, upper){
|
||||
|
||||
|
||||
Variable.cachedOffsets={};
|
||||
Variable.hashTableEnd=0x03c800;
|
||||
Variable.resetCache=function(){
|
||||
Variable.cachedOffsets={};
|
||||
};
|
||||
Variable.findHashTableEnd=function(){
|
||||
/*
|
||||
MetaData.SaveTypeHash defines the end of the hash table for simple data and the start
|
||||
of complex data (arrays, etc)
|
||||
in official TOTK savegames, its at 0x03c800 (or before, if v1.0)
|
||||
but we cannot rely on that offset because of game mods or even future game versions,
|
||||
which might push it further if they add new variables to the game
|
||||
|
||||
so, in order to make the editor compatible with both official game and mods, we ensure
|
||||
we will always find the exact offset for MetaData.SaveTypeHash
|
||||
this offset is just used when looking for a variable in the savegame, because we only
|
||||
need to search up to that offset
|
||||
*/
|
||||
for(var i=0x000028; i<tempFile.fileSize; i+=8){
|
||||
if(tempFile.readU32(i)===0xa3db7114){ //found MetaData.SaveTypeHash
|
||||
Variable.hashTableEnd=i+4;
|
||||
return Variable.hashTableEnd;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user