Another Mind-Boggler: Conditional Breakpoint Stops Bug

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.
Post Reply
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Another Mind-Boggler: Conditional Breakpoint Stops Bug

Post 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.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Post by frag.machine »

Does the bug show in the release version too ?
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
jitspoe
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Post 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.
Post Reply