Paintjobs 11+ in MM2
Posted: Tue Apr 24, 2018 9:06 am
So, we've always had the sailboat/tugboat/somekindofboat in our car issue with paintjobs over 10.
Today I dug into this issue, and dear god is the cause amusing.
When the game initializes your car, it starts initializing level geometry. The game goes through each item in the car (hardcoded list, basically), and adds body, shadow, tlight, etc. Finally, it adds the variantPAINTJOB items, which I recently posted a topic about.
Here's the catch. It only adds 10 of these.
This wouldn't be a big deal, but later on in the initialization, it adds a breakable to your car. It tries to use the banger "carname_variantPAINTJOB", but it also passes in a model ID. The model ID = paintjob + car items.
The memory layout of models is
[CAR STUFF][VARIANT STUFF (ONLY 10)][OTHER GEOMETRY]
So, to sum up
This bug is caused by an unused feature in the base game, because they don't check if your paintjob is less than 11, and then it overflows into other geometry.
I did some tests and was able to fix this by initializing 64 objects instead of 10.
Today I dug into this issue, and dear god is the cause amusing.
When the game initializes your car, it starts initializing level geometry. The game goes through each item in the car (hardcoded list, basically), and adds body, shadow, tlight, etc. Finally, it adds the variantPAINTJOB items, which I recently posted a topic about.
Here's the catch. It only adds 10 of these.
This wouldn't be a big deal, but later on in the initialization, it adds a breakable to your car. It tries to use the banger "carname_variantPAINTJOB", but it also passes in a model ID. The model ID = paintjob + car items.
The memory layout of models is
[CAR STUFF][VARIANT STUFF (ONLY 10)][OTHER GEOMETRY]
So, to sum up
This bug is caused by an unused feature in the base game, because they don't check if your paintjob is less than 11, and then it overflows into other geometry.
I did some tests and was able to fix this by initializing 64 objects instead of 10.