Page 1 of 1

Another Mind-Boggler: Conditional Breakpoint Stops Bug

Posted: Tue Oct 08, 2013 6:43 am
by jitspoe
My brain hurts lately. Now I have a new bizarre issue. I have this bug where, occasionally, if you hold the jump button down, you will jump multiple times, even though you're supposed to have to release and press the key again. This is in my Quake2 engine. I'm fairly sure it's related to the way I've decoupled the framerate and network packets, but here's the bizarre thing: when I try to catch it in the act by putting a conditional breakpoint in CL_BaseMove() for cmd->upmove < 200, the issue disappears.

I can type +moveup in the console and watch the character occasionally jump. Enable the breakpoint, and it stops. Disable the breakpoint, random jumping. So weird.

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Posted: Tue Oct 08, 2013 1:44 pm
by frag.machine
Does the bug show in the release version too ?

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Posted: Tue Oct 08, 2013 5:58 pm
by jitspoe
Figured out what the issue was:

in cl_input.c, CL_KeyState()

It was possible for the key down time and the sys time to be the same, making it appear as though the key was pressed for 0ms. I'm not sure if this is a proper fix, but this is what I ended up doing:

Code: Select all

	if (key->state)
	{
		if (key->downtime == sys_frame_time) // jittiming -- fix edge case where time is equal, causing keys to be "released" at high framerates
			return 1.0f;

		// still down
		msec += sys_frame_time - key->downtime;
		key->downtime = sys_frame_time;
	}
I guess the conditional breakpoint added enough cycles to ensure 1ms had passed.