r755 provided the option to have captured vessels repainted in the new owner's colours
. I've since discovered that this is the cause of some particularly bad performance problems I'm experiencing which I attributed to poor system performance when I originally wrote the code. It appears that the inclusion of the extra textures (each ship has multiple textures, one for each colour scheme it can potentially have) overloaded the texture registry. At least that's what the debugger is telling me but I don't believe it.
TR_RegistrySize is set to 6000 which according to its associated comment is "dag nammit, this is just silly large!" so I take that to mean the chances of my overloading it are less likely. The code checking the texture entry is finding it's being handed references which are out of bounds; the debugger is claiming 263405 in one instance. That's much, much bigger than 6000 which poses two problems:
(1) I cannot believe that an additional texture for my fleet colours on every other object type in the universe, let alone just ships, adds another 250,000 textures!
(2) Even if there really are 250,000 extra textures, why am I not experiencing buffer overrun errors?
That aside, because the texture reference is out of bounds, the game attempts to reload the texture again. Doing this constantly causes the game to slow down appreciably.
I'm clearly missing something here and whilst I'll keep investigating, someone else more familiar with the texture code may be able to give me some guidance. It's possibly something to do with iColorScheme which is commented to mean "0 = no player" and r755 now makes "0 = human player". I couldn't find any code showing "0 = no player" gets tested anywhere so I was happy with my code change, but maybe that's a built-in assumption populating the registry in the first place and that's what's screwing me over (an unassigned memory value being used as-is (250,000) maybe?). For reference, it all goes pear shaped here:
Mesh.c line 1399
Any hints appreciated. Thanks.