- consolidated A_Warp and ACS Warp code into a subfunction.

This commit is contained in:
Christoph Oelckers 2015-07-31 08:40:33 +02:00
commit 701fc374f7
4 changed files with 155 additions and 290 deletions

View file

@ -4653,26 +4653,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_WolfAttack)
//
//==========================================================================
enum WARPF
{
WARPF_ABSOLUTEOFFSET = 0x1,
WARPF_ABSOLUTEANGLE = 0x2,
WARPF_USECALLERANGLE = 0x4,
WARPF_NOCHECKPOSITION = 0x8,
WARPF_INTERPOLATE = 0x10,
WARPF_WARPINTERPOLATION = 0x20,
WARPF_COPYINTERPOLATION = 0x40,
WARPF_STOP = 0x80,
WARPF_TOFLOOR = 0x100,
WARPF_TESTONLY = 0x200,
WARPF_ABSOLUTEPOSITION = 0x400,
WARPF_BOB = 0x800,
WARPF_MOVEPTR = 0x1000,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
{
ACTION_PARAM_START(7);
@ -4694,130 +4674,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
return;
}
AActor *caller = self;
if (flags & WARPF_MOVEPTR)
if (P_Thing_Warp(self, reference, xofs, yofs, zofs, angle, flags))
{
AActor *temp = reference;
reference = caller;
caller = temp;
}
fixed_t oldx = caller->x;
fixed_t oldy = caller->y;
fixed_t oldz = caller->z;
if (!(flags & WARPF_ABSOLUTEANGLE))
{
angle += (flags & WARPF_USECALLERANGLE) ? caller->angle : reference->angle;
}
if (!(flags & WARPF_ABSOLUTEPOSITION))
{
if (!(flags & WARPF_ABSOLUTEOFFSET))
{
angle_t fineangle = angle >> ANGLETOFINESHIFT;
fixed_t xofs1 = xofs;
// (borrowed from A_SpawnItemEx, assumed workable)
// in relative mode negative y values mean 'left' and positive ones mean 'right'
// This is the inverse orientation of the absolute mode!
xofs = FixedMul(xofs1, finecosine[fineangle]) + FixedMul(yofs, finesine[fineangle]);
yofs = FixedMul(xofs1, finesine[fineangle]) - FixedMul(yofs, finecosine[fineangle]);
}
if (flags & WARPF_TOFLOOR)
{
// set correct xy
caller->SetOrigin(
reference->x + xofs,
reference->y + yofs,
reference->z);
// now the caller's floorz should be appropriate for the assigned xy-position
// assigning position again with
if (zofs)
{
// extra unlink, link and environment calculation
caller->SetOrigin(
caller->x,
caller->y,
caller->floorz + zofs);
}
else
{
// if there is no offset, there should be no ill effect from moving down to the
// already identified floor
// A_Teleport does the same thing anyway
caller->z = caller->floorz;
}
}
else
{
caller->SetOrigin(
reference->x + xofs,
reference->y + yofs,
reference->z + zofs);
}
}
else //[MC] The idea behind "absolute" is meant to be "absolute". Override everything, just like A_SpawnItemEx's.
{
if (flags & WARPF_TOFLOOR)
{
caller->SetOrigin(xofs, yofs, caller->floorz + zofs);
}
else
{
caller->SetOrigin(xofs, yofs, zofs);
}
}
if ((flags & WARPF_NOCHECKPOSITION) || P_TestMobjLocation(caller))
{
if (flags & WARPF_TESTONLY)
{
caller->SetOrigin(oldx, oldy, oldz);
}
else
{
caller->angle = angle;
if (flags & WARPF_STOP)
{
caller->velx = 0;
caller->vely = 0;
caller->velz = 0;
}
if (flags & WARPF_WARPINTERPOLATION)
{
caller->PrevX += caller->x - oldx;
caller->PrevY += caller->y - oldy;
caller->PrevZ += caller->z - oldz;
}
else if (flags & WARPF_COPYINTERPOLATION)
{
caller->PrevX = caller->x + reference->PrevX - reference->x;
caller->PrevY = caller->y + reference->PrevY - reference->y;
caller->PrevZ = caller->z + reference->PrevZ - reference->z;
}
else if (!(flags & WARPF_INTERPOLATE))
{
caller->PrevX = caller->x;
caller->PrevY = caller->y;
caller->PrevZ = caller->z;
}
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
{
caller->z += reference->GetBobOffset();
}
}
if (success_state)
{
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!
@ -4830,7 +4688,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Warp)
}
else
{
caller->SetOrigin(oldx, oldy, oldz);
ACTION_SET_RESULT(false);
}