View Single Post
  #2  
Old 10-25-2008, 03:30 PM
Congdar
Developer
 
Join Date: Jul 2007
Location: my own little world
Posts: 751
Default

It seems CalculateHeadingToTarget() returns a sint8
Everywhere it is used as a float though since heading is a float.
Also, in FaceTarget() heading is getting updated regardless of it needing to be updated or not because it is getting set directly since it is not a private or protected variable so here's an additional change for FaceTarget()
Code:
void Mob::FaceTarget(Mob* MobToFace) {
	if(!MobToFace) {
		if(!target) {
			return;
		}
		else {
			MobToFace = target;
		}
	}

	float oldheading = heading;
	float newheading = CalculateHeadingToTarget(MobToFace->GetX(), MobToFace->GetY());
	if(oldheading != newheading) {
		SetHeading(newheading);
		SendPosUpdate();
	}
}
Would changing the return value of CalculateHeadingToTarget() be as simple as this:
waypoints.cpp
Code:
sint8 Mob::CalculateHeadingToTarget(float in_x, float in_y) {
to:
Code:
float Mob::CalculateHeadingToTarget(float in_x, float in_y) {
and
Code:
	return (sint8) (256*(360-angle)/360.0f);
to:
Code:
	return (256*(360-angle)/360.0f);
Reply With Quote