Program: 19981
Project: 19981
Buggy source:
/** 
 * Asettaa TouchListenerit ja k�sittelee kosketustapahtumat.
 */
private final void setSurfaceListeners(){
  surface.setOnTouchListener(new OnTouchListener(){
    public boolean onTouch(    View v,    MotionEvent event){
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        xClickOffset=(int)event.getX() - screenWidth / 2;
        yClickOffset=screenHeight / 2 - (int)event.getY();
        Log.v("String_Node_Str","String_Node_Str" + xClickOffset + "String_Node_Str"+ yClickOffset);
        if (xClickOffset > screenWidth - 100 * Options.scaleX && xClickOffset < screenWidth && yClickOffset < yClickFirstBorder) {
          if (yClickOffset < yClickThirdBorder && yClickOffset > 0) {
            hud.triggerClick(Hud.BUTTON_3);
          }
 else           if (yClickOffset < yClickSecondBorder && yClickOffset > yClickThirdBorder) {
            hud.triggerClick(Hud.BUTTON_2);
          }
 else           if (yClickOffset < yClickFirstBorder && yClickOffset > yClickSecondBorder) {
            hud.triggerClick(Hud.BUTTON_1);
          }
        }
        if (joystickX != 0 && joystickY != 0 && xClickOffset > joystickX - 64 && xClickOffset < joystickX + 64 && yClickOffset > joystickY - 64 && yClickOffset < joystickY + 64) {
          Joystick.joystickDown=true;
        }
 else {
          weaponManager.triggerPlayerShoot(event.getX() - screenWidth / 2,-((-screenHeight / 2) + event.getY()));
        }
      }
      if (event.getAction() == MotionEvent.ACTION_MOVE) {
        xClickOffset=(int)event.getX() - screenWidth / 2;
        yClickOffset=screenHeight / 2 - (int)event.getY();
        if (weaponManager.isUsingMotionEvents) {
          if (pointerCount < 10) {
            if (Math.abs(touchPath[pointerCount - 1][0] - xClickOffset) >= 8 || Math.abs(touchPath[pointerCount - 1][1] - yClickOffset) >= 8) {
              setPathPoint(xClickOffset,yClickOffset,pointerCount);
              pointerCount++;
            }
          }
        }
        if (!Joystick.joystickInUse && Joystick.joystickDown && xClickOffset > joystickX - 64 && xClickOffset < joystickX + 64 && yClickOffset > joystickY - 64 && yClickOffset < joystickY + 64) {
          Joystick.joystickInUse=true;
        }
 else         if (Joystick.joystickInUse) {
          Joystick.useJoystick(xClickOffset,yClickOffset,(int)event.getX(),(int)event.getY(),wrapper);
          if (Utility.getDistance((float)xClickOffset,(float)yClickOffset,(float)joystickX,(float)joystickY) > 64) {
            Joystick.joystickDown=false;
            Joystick.joystickInUse=false;
          }
        }
        return true;
      }
      if (event.getAction() == MotionEvent.ACTION_UP) {
        Joystick.joystickInUse=false;
        Joystick.joystickDown=false;
        wrapper.player.movementAcceleration=-6;
        if (weaponManager.isUsingMotionEvents) {
          for (int i=0; i < 10; i++) {
            touchPath[i][0]=0;
            touchPath[i][1]=0;
          }
          pointerCount=1;
        }
        if (Math.abs(event.getX() - (xClickOffset - screenWidth / 2)) < touchMarginal && Math.abs(event.getY() - (yClickOffset - screenHeight / 2)) < touchMarginal) {
        }
      }
      return true;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Asettaa TouchListenerit ja k�sittelee kosketustapahtumat.
 */
private final void setSurfaceListeners(){
  surface.setOnTouchListener(new OnTouchListener(){
    public boolean onTouch(    View v,    MotionEvent event){
      dumpEvent(event);
      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        xClickOffset=(int)event.getX() - screenWidth / 2;
        yClickOffset=screenHeight / 2 - (int)event.getY();
        Log.v("String_Node_Str","String_Node_Str" + xClickOffset + "String_Node_Str"+ yClickOffset);
        if (xClickOffset > screenWidth - 100 * Options.scaleX && xClickOffset < screenWidth && yClickOffset < yClickFirstBorder) {
          if (yClickOffset < yClickThirdBorder && yClickOffset > 0) {
            hud.triggerClick(Hud.BUTTON_3);
          }
 else           if (yClickOffset < yClickSecondBorder && yClickOffset > yClickThirdBorder) {
            hud.triggerClick(Hud.BUTTON_2);
          }
 else           if (yClickOffset < yClickFirstBorder && yClickOffset > yClickSecondBorder) {
            hud.triggerClick(Hud.BUTTON_1);
          }
        }
        if (joystickX != 0 && joystickY != 0 && xClickOffset > joystickX - 64 && xClickOffset < joystickX + 64 && yClickOffset > joystickY - 64 && yClickOffset < joystickY + 64) {
          Joystick.joystickDown=true;
        }
 else {
          weaponManager.triggerPlayerShoot(event.getX() - screenWidth / 2,-((-screenHeight / 2) + event.getY()));
        }
      }
      if (event.getAction() == MotionEvent.ACTION_MOVE) {
        xClickOffset=(int)event.getX() - screenWidth / 2;
        yClickOffset=screenHeight / 2 - (int)event.getY();
        if (weaponManager.isUsingMotionEvents) {
          if (pointerCount < 10) {
            if (Math.abs(touchPath[pointerCount - 1][0] - xClickOffset) >= 8 || Math.abs(touchPath[pointerCount - 1][1] - yClickOffset) >= 8) {
              setPathPoint(xClickOffset,yClickOffset,pointerCount);
              pointerCount++;
            }
          }
        }
        if (!Joystick.joystickInUse && Joystick.joystickDown && xClickOffset > joystickX - 64 && xClickOffset < joystickX + 64 && yClickOffset > joystickY - 64 && yClickOffset < joystickY + 64) {
          Joystick.joystickInUse=true;
        }
 else         if (Joystick.joystickInUse) {
          Joystick.useJoystick(xClickOffset,yClickOffset,(int)event.getX(),(int)event.getY(),wrapper);
          if (Utility.getDistance((float)xClickOffset,(float)yClickOffset,(float)joystickX,(float)joystickY) > 64) {
            Joystick.joystickDown=false;
            Joystick.joystickInUse=false;
          }
        }
        return true;
      }
      if (event.getAction() == MotionEvent.ACTION_UP) {
        Joystick.joystickInUse=false;
        Joystick.joystickDown=false;
        wrapper.player.movementAcceleration=-6;
        if (weaponManager.isUsingMotionEvents) {
          for (int i=0; i < 10; i++) {
            touchPath[i][0]=0;
            touchPath[i][1]=0;
          }
          pointerCount=1;
        }
        if (Math.abs(event.getX() - (xClickOffset - screenWidth / 2)) < touchMarginal && Math.abs(event.getY() - (yClickOffset - screenHeight / 2)) < touchMarginal) {
        }
      }
      return true;
    }
  }
);
}