Funny "bugfixes"
Posted: Sun Oct 21, 2012 12:35 pm
Have you ever had your code behaving badly for seemingly no reason, and then you accidentally "fix" it in a way that makes even less sense?
In Makaqu, I've got this little check to make sure that the particle metadata only gets recreated when actually needed:
However, in the Windows version it wasn't working properly, so every time the FOV was changed the particle metadata would be recreated, causing lots of unnecessary stuttering in the framerate when zooming.
So, I decided to print out the contents of the aspect variables, since they were the most likely to be malfunctioning:
And then, when I typed "developer 1" in the console and zoomed in... nothing was printed. And no stuttering happened. The check was definitely working this time.
So, I removed the Con_DPrintf lines, and... the stuttering came back. I put the lines back in, and the stuttering was gone again. Then, I tried removing only the first Con_DPrintf line, and the stuttering was still gone. And finally, I put the first line back in and removed just the second line, and it was still gone. So, adding a Con_DPrintf line after the check made it so the check, which is run before the Con_DPrintf, don't fail. It makes no bloody sense at all .
Things like this can be embarrassing, but it was impossible to not laugh.
In Makaqu, I've got this little check to make sure that the particle metadata only gets recreated when actually needed:
Code: Select all
// doubled the minimum size here to make sure the particle will appear,
// since the width and height calculations reduces its drawing area
max_size = min (vid.width, vid.height) + 2;
// don't recalculate when only zooming in
if (r_particles_init
&& r_particles.h_aspect == h_aspect
&& r_particles.max_size == max_size
)
return;
So, I decided to print out the contents of the aspect variables, since they were the most likely to be malfunctioning:
Code: Select all
Con_DPrintf ("r_particles.h_aspect %d\n", r_particles.h_aspect);
Con_DPrintf ("h_aspect %d\n", h_aspect);
So, I removed the Con_DPrintf lines, and... the stuttering came back. I put the lines back in, and the stuttering was gone again. Then, I tried removing only the first Con_DPrintf line, and the stuttering was still gone. And finally, I put the first line back in and removed just the second line, and it was still gone. So, adding a Con_DPrintf line after the check made it so the check, which is run before the Con_DPrintf, don't fail. It makes no bloody sense at all .
Things like this can be embarrassing, but it was impossible to not laugh.