A pesky bug fix


(jaybird) #1

Hey guys,

This bug has been a royal pain in my side for way too long.
In G_RunThink, in g_main.c, a variable called thinktime is declared as a float to hold the value of ent->nextthink, an int. This causes big problems with the scripting system, causing server stopping errors if the particular server is a bit unlucky.

For example, 33744150 + (2*100) = 33744350, but when assigned to thinktime, it ends up being 33744352 due to floating point error, causing a think to be missed, and potentially not be initialized for something that expects it.

The easy fix to this is simply declare thinktime as an int.

I finally found this, but would rather not others have to deal with this stupid issue. I hope you will consider implementing it into your mod.


(Lanz) #2

Just wanted to add to this that it doesn’t have so much to do with being a floating point error as it has to do with precision, usually float only have 6-7 significant numbers and your example have 8.


(bani) #3

good find.