CodeWalker icon indicating copy to clipboard operation
CodeWalker copied to clipboard

ResourcePagesInfo: Limit number of pages to 128 and display correct block length

Open carmineos opened this issue 5 years ago • 10 comments

This updates the ResourcePagesInfo block length property so its value is not hardcoded to the max size.

carmineos avatar Jun 01 '20 16:06 carmineos

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.

carmineos avatar Jun 03 '20 17:06 carmineos

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.

dexyfex avatar Nov 07 '21 13:11 dexyfex

Done.

carmineos avatar Nov 07 '21 15:11 carmineos

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...

dexyfex avatar Nov 07 '21 15:11 dexyfex

Removed

carmineos avatar Nov 07 '21 15:11 carmineos

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"

dexyfex avatar Nov 07 '21 17:11 dexyfex

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.

carmineos avatar Nov 07 '21 21:11 carmineos

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.

dexyfex avatar Nov 07 '21 21:11 dexyfex

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.

carmineos avatar Nov 07 '21 22:11 carmineos

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

dexyfex avatar Nov 07 '21 22:11 dexyfex

Manually merged equivalent changes

dexyfex avatar Jul 10 '24 23:07 dexyfex