Forum

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.

Moderator: InsideQC Admins

Another Mind-Boggler: Conditional Breakpoint Stops Bug

Postby jitspoe » Tue Oct 08, 2013 6:43 am

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.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Postby frag.machine » Tue Oct 08, 2013 1:44 pm

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)
User avatar
frag.machine
 
Posts: 2052
Joined: Sat Nov 25, 2006 1:49 pm

Re: Another Mind-Boggler: Conditional Breakpoint Stops Bug

Postby jitspoe » Tue Oct 08, 2013 5:58 pm

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.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest