2024-01-07
Fixing a weird crash in Dominatrix
I was planning on releasing Dominatrix 1.1 last Friday, but I've been getting crashes when loading any level in my last minute testing. The only uncommitted change I made was compiling the OpenGL renderer DLL with optimizations turned on (-O2 for GCC) - reversing this made everything work again, but I had to know where the problem was. Thankfully gdb was able to tell me the issue was in the BSP level loading code, even with no debug symbols. A whole lot of printfs later, I found that the problem was in the texture loading code, which can be seen in the diff for the fix below.
Texture info is copied between two mostly similar structs, which has a member
variable vecs
, stored as a 2 by 4 float matrix. For some reason, someone either
at id or Ritual decided to access only the first row of the matrix and increment
the column eight times. I assume the layout of the data in memory works out for
unoptimized builds, but not otherwise. The fix, as shown in the image, is to
access the matrix like a normal person.
Dominatrix v1.1 should hopefully come out tomorrow!