View Single Post
Re: POD-bot back into shape.
Old
  (#138)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: POD-bot back into shape. - 12-03-2004

I have not "fixed" the problem, I have removed the failing assert(). But it's an ugly fix because the assertion still fails, meaning that an out of bounds value exist in ideal_yaw when pfnRunPlayerMove() is called. I am completely puzzled why it fails. If somebody has an explanation I'm all ears.

The code is
Code:
   // save the previous speed (for checking if stuck)
   pBot->prev_speed = fabs (pBot->f_move_speed);
 
   // Reset Damage
   pBot->iLastDamageType = -1;
 
   UTIL_ClampVector (&pEdict->v.angles);
   UTIL_ClampVector (&pEdict->v.v_angle);
   UTIL_ClampAngle (&pEdict->v.idealpitch);
   UTIL_ClampAngle (&pEdict->v.ideal_yaw);
 
   assert ((pEdict->v.v_angle.x > -181.0) && (pEdict->v.v_angle.x < 181.0));
   assert ((pEdict->v.v_angle.y > -181.0) && (pEdict->v.v_angle.y < 181.0));
   assert ((pEdict->v.angles.x > -181.0) && (pEdict->v.angles.x < 181.0));
   assert ((pEdict->v.angles.y > -181.0) && (pEdict->v.angles.y < 181.0));
   assert ((pEdict->v.ideal_yaw > -181.0) && (pEdict->v.ideal_yaw < 181.0)); // ASSERTION FAILURE
   assert ((pEdict->v.idealpitch > -181.0) && (pEdict->v.idealpitch < 181.0));
 
   g_engfuncs.pfnRunPlayerMove (pEdict,
					 vecMoveAngles,
					 pBot->f_move_speed,
					 pBot->f_sidemove_speed,
					 0,
					 pEdict->v.button,
					 0,
					 msecval);

   return;
}
and UTIL_ClampAngle() which fixes ideal_yaw before the assert is
Code:
void UTIL_ClampAngle (float *fAngle)
{
   if (*fAngle >= 180)
	  *fAngle -= 360 * ((int) (*fAngle / 360) + 1);
   if (*fAngle < -180)
	  *fAngle += 360 * ((int) (-*fAngle / 360) + 1); // don't forget the "-"
 
   if ((*fAngle >= 180) || (*fAngle < -180))
	  *fAngle = 0; // heck, if we're still above the limit then something's REALLY fuckedup!
}



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."