ResourcePagesInfo: Limit number of pages to 128 and display correct block length
This updates the ResourcePagesInfo block length property so its value is not hardcoded to the max size.
Note: no behaviour is currently changed, ResourceBuilder still uses a mock ResourcePagesInfo block of the max size to assign positions. This just cleans the BlockLenght property and allows to inspect real size of the block.
Please remove the allocation of arrays for the pointers in the ResourcePagesInfo, there's no reason for them to be there and it will just slow down the performance of loading everything in CW and make it use up even more memory.
Done.
They are still being assigned objects though? Just delete the fields, I don't see why they are necessary at all because CW isn't ever going to be using them for anything...
Removed
Have you 100% tested this with many files? I only just noticed that it seems to only allocate 1/4 the amount of space in the files for this than it used to: old length: 256 * 16 = 4096 bytes new length: (64 + 64) * 8 = 1024 bytes It's just slightly at odds with your statement of "Note: no behaviour is currently changed"
You were allocating a hardcoded size of 4096 before, now since the max allowed number of pages is 128 it will use a mock block of 128 pages to ensure the ResourceBuilder will assign a correct position for it. The real length of the block is the one you see in the PR, 16 bytes + a variable length depending on the number of pages actually used by the resource. Because ResourceBuilder has to know the block size before it assigns a position to it, and because you can't know the number of pages it requires to pack the resource without running the algorithm twice, it will just use the block of max length just as it used to do before this PR, except now you know the pages are limited to 128.
Right, but it doesn't really answer my question... Since this will affect every single resource file created by CW, I want to know absolutely for sure that it's not going to be causing any mysterious random packing problems.
It doesn't break anything, I've scanned all the files back then and I've been using this code in my gta-toolkit fork since then.
Really need to at least run all the stuff in GameFileCache to basically convert everything to XML and back and make sure nothing's broken. Need to be 100% sure about this
Manually merged equivalent changes