Scheduled system upgrade on Sunday 21 April 2024 15:00-16:00 UTC - On that day, the wiki and other services might go down for 5-15 minutes.

ResourceSizeTable.product.rsizetable and Content/NavMesh: Difference between pages

From ZeldaMods (Breath of the Wild)
(Difference between pages)
Jump to navigation Jump to search
imported>BravelyPeculiar
No edit summary
 
imported>Leoetlino
 
Line 1: Line 1:
<onlyinclude>
{{stub}}
{{Resloc|path=System/Resource/ResourceSizeTable.product.rsizetable}}
<onlyinclude>{{Resloc|type=directory|path=NavMesh}}</onlyinclude>
'''ResourceSizeTable.product.rsizetable''' is the file where the [[resource size table]] is stored.
</onlyinclude>


== Editing ==
== Directories ==
The resource size table must be edited when making game files larger than they originally were, in order to avoid crashes. It can be edited using [https://github.com/leoetlino/rstb <code>rstb</code>].
=== MainField ===
{{Resloc|type=directory|path=NavMesh/MainField/}}


== Structure ==
=== MainFieldDungeon ===
Sections are listed in the order they appear in the file.
{{Resloc|type=directory|path=NavMesh/MainFieldDungeon/|locations=divine beast packs|aoc_locations=divine beast packs|aoc_replaces_base=1}} 


=== Header (optional) ===
=== AocField ===
<syntaxhighlight lang="c++">
{{ReslocAoc|type=directory|path=NavMesh/AocField/}}  
struct RstbHeader {
  u32 magic;          // 'RSTB'
  u32 crc32TableSize;  // number of entries - can be 0 to indicate there is no crc32 table
  u32 nameTableSize;  // number of entries - can be 0 to indicate there is no name table
}; // sizeof() = 12
</syntaxhighlight>


If the header is missing or if the magic is not correct, the game will assume there is simply no header. In that case, the game will use the size of the RSTB file, divide it by 8 to get the number of crc32 table entries and assume the whole file is a crc32 table.  
=== CDungeon ===
{{Resloc|type=directory|path=NavMesh/CDungeon/|locations=dungeon packs}}
{{ReslocAoc|type=directory|path=NavMesh/CDungeon/|locations=DLC dungeon packs (DungeonNNN with NNN > 119)}}   


=== CRC32 table (optional) ===
[[Category: Content (BotW)]]
This is a mapping of CRC32 values to resource sizes. The table must be sorted; otherwise the game will not be able to search for entries properly.
 
<syntaxhighlight lang="c++">
struct RstbCrc32TableEntry {
  u32 crc32;
  u32 size;
};  // sizeof() = 8
</syntaxhighlight>
 
=== Name table (optional) ===
This is a mapping of resource paths (strings) to resource sizes. This table is optional and is used whenever there would be conflicts in the crc32 table. Only usable if there is a RSTB header.
 
<syntaxhighlight lang="c++">
struct RstbCrc32NameEntry {
  char name[128];
  u32 size;
};  // sizeof() = 132
</syntaxhighlight>
 
== Game usage ==
The table is loaded very early in the app init process by ResourceInfoContainer (part of [[res::ResourceMgrTask]]) when the resource task starts and queried by the resource system and several other [[subsystems]] afterwards.
 
=== Lookup logic ===
<code>ResourceInfoContainer::getResourceSize</code> (non official name) starts by computing the CRC32 for the resource name/path.
 
Note: Resources that are ''explicitly'' loaded from the add-on content file device will have <code>Aoc/0010/</code> prepended to their resource path on Switch and Wii U as explained in the [[resource system]] article.
 
If a CRC32 table is present, the game will perform a binary search to find an entry for the calculated hash. If an entry is found, <code>entry.size</code> is returned.
 
Otherwise, if a name table is present, the game will go down the table until an entry that matches the specified resource name is found. If an entry is found, <code>entry.size</code> is returned.
 
Otherwise, the game returns 0.
 
=== Checks ===
The RSTB is queried by several subsystems:
* TipsMgr and EventResource use it only to check if the file they want to load exists (by checking if ret != 0).
* EffectResource, when loading Effect/Game.esetlist: must not be zero.
* VfxResourceMgr, when loading Effect/%s.esetlist files: must not be zero.
* bfres loading code at 0x7100FE3978 (v1.5.0): unclear, but must not be zero. It appears to check whether the file size listed in the RSTB is larger than the heap size.
* res::ResourceMgrTask::getHeapSizeForResLoad (0x710120BDE0 in v1.5.0): called during resource load.<syntaxhighlight lang="c++">
constant = 0x128 + 0x40;
if (auto* entry_factory = dynamic_cast<res::EntryFactoryBase*>(factory))
  resSize2 = entry_factory->getResourceSize(param->factory) + constant;
else
  resSize2 = sizeof(sead::DirectResource) + constant; // 0x20 + 0x168 = 0x188
 
totalSize = in->allocSize + resSize2;  // in this branch, in->allocSize seems to be always zero...
if (totalSize <= sizeInTable)
  out->readHeapSize = loadDataAlignment + sizeInTable + sizeof(void*);
else
  out->readHeapSize = (unsigned int)(float)(loadDataAlignment + totalSize + sizeof(void*));
</syntaxhighlight>
* 0x7100FE1630 (v1.5.0): unclear. If the file is loaded by the resource memory or loading thread, or if the file size listed in the RSTB is larger than a TempResourceLoader field, the game prints: "Texture archive size: %u MB" (translated from Japanese).
 
[[Category:Content (BotW)]]
[[Category:File formats]]

Latest revision as of 11:47, 9 September 2018

This directory is found in the unpacked content files.

Its canonical resource path is "NavMesh".

Directories

MainField

This directory is found in the unpacked content files.

Its canonical resource path is "NavMesh/MainField/".

MainFieldDungeon

This directory is found in divine beast packs.

Its canonical resource path is "NavMesh/MainFieldDungeon/".

In the add-on content, it is found in divine beast packs.

Its DLC canonical path is "Aoc/0010/NavMesh/MainFieldDungeon/".

 

AocField

If the DLC is installed, this directory can be found in the unpacked content files in the add-on content directory. Its canonical path is "Aoc/0010/NavMesh/AocField/".

  

CDungeon

This directory is found in dungeon packs.

Its canonical resource path is "NavMesh/CDungeon/".

If the DLC is installed, this directory can be found in DLC dungeon packs (DungeonNNN with NNN > 119) in the add-on content directory. Its canonical path is "Aoc/0010/NavMesh/CDungeon/".