- got rid of DistanceI.

This commit is contained in:
Christoph Oelckers 2022-09-08 17:34:34 +02:00
parent 9a464e81e7
commit fdabd75422
2 changed files with 5 additions and 29 deletions

View file

@ -1594,29 +1594,6 @@ extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS];
ANIMATOR NullAnimator;
inline int Distance(int x1, int y1, int x2, int y2)
{
int min;
if ((x2 = x2 - x1) < 0)
x2 = -x2;
if ((y2 = y2 - y1) < 0)
y2 = -y2;
if (x2 > y2)
min = y2;
else
min = x2;
return x2 + y2 - (min >> 1);
}
inline int DistanceI(const DVector2& pos1, const DVector2& pos2)
{
return Distance(int(pos1.X * worldtoint), int(pos1.Y * worldtoint), int(pos2.X * worldtoint), int(pos2.Y * worldtoint));
}
int NewStateGroup(DSWActor* actor, STATE* SpriteGroup[]);
DVector3 SectorMidPoint(sectortype* sectp);
void SpawnUser(DSWActor* actor, short id, STATE* state);

View file

@ -14113,7 +14113,6 @@ int InitEnemyNuke(DSWActor* actor)
int InitMicro(PLAYER* pp)
{
DSWActor* actor = pp->actor;
int dist;
short i;
DAngle angle;
TARGET_SORT* ts = TargetSort;
@ -14206,11 +14205,11 @@ int InitMicro(PLAYER* pp)
if (picked)
{
dist = DistanceI(actorNew->spr.pos, picked->spr.pos);
double dist = (actorNew->spr.pos.XY() - picked->spr.pos.XY()).Length();
if (dist != 0)
{
double zh = ActorZOfTop(picked) + (ActorSizeZ(picked) * 0.25);
actorNew->set_int_zvel((actorNew->int_xvel() * (zh - actorNew->spr.pos.Z) * zworldtoint) / dist);
actorNew->vel.Z = (actorNew->vel.X * (zh - actorNew->spr.pos.Z)) / dist;
}
actorNew->user.WpnGoalActor = ts->actor;
@ -15878,7 +15877,7 @@ int InitTankShell(DSWActor* actor, PLAYER* pp)
int InitTurretMicro(DSWActor* actor, PLAYER* pp)
{
DSWActor* plActor = pp->actor;
int nx, ny, nz, dist;
int nx, ny, nz;
short i,ang;
TARGET_SORT* ts = TargetSort;
DSWActor* picked = nullptr;
@ -15948,11 +15947,11 @@ int InitTurretMicro(DSWActor* actor, PLAYER* pp)
if (picked)
{
dist = DistanceI(actorNew->spr.pos, picked->spr.pos);
double dist = (actorNew->spr.pos.XY() - picked->spr.pos.XY()).Length();
if (dist != 0)
{
double zh = ActorZOfTop(picked) + (ActorSizeZ(picked) * 0.25);
actorNew->set_int_zvel((actorNew->int_xvel() * (zh - actorNew->spr.pos.Z) * zworldtoint) / dist);
actorNew->vel.Z = (actorNew->vel.X * (zh - actorNew->spr.pos.Z)) / dist;
}
actorNew->user.WpnGoalActor = ts->actor;