Merge branch 'zmaster'

This commit is contained in:
Christoph Oelckers 2016-03-03 02:53:07 +01:00
commit 6f28735b45
21 changed files with 661 additions and 431 deletions

View file

@ -1409,21 +1409,8 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch,
struct FTranslatedLineTarget
{
AActor *linetarget;
angle_t hitangle;
fixedvec3 targetPosFromSrc;
angle_t targetAngleFromSrc;
fixedvec3 sourcePosFromTarget;
angle_t sourceAngleFromTarget;
angle_t angleFromSource;
bool unlinked; // found by a trace that went through an unlinked portal.
angle_t SourceAngleToTarget() const
{
return R_PointToAngle2(sourcePosFromTarget.x, sourcePosFromTarget.y, linetarget->X(), linetarget->Y());
}
angle_t TargetAngleToSource() const
{
return R_PointToAngle2(linetarget->X(), linetarget->Y(), sourcePosFromTarget.x, sourcePosFromTarget.y);
}
};

View file

@ -61,7 +61,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Punch)
if (t.linetarget)
{
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
self->angle = t.SourceAngleToTarget();
self->angle = t.angleFromSource;
}
return 0;
}
@ -232,7 +232,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw)
// turn to face target
if (!(flags & SF_NOTURN))
{
angle = t.SourceAngleToTarget();
angle = t.angleFromSource;
if (angle - self->angle > ANG180)
{
if (angle - self->angle < (angle_t)(-ANG90 / 20))
@ -696,7 +696,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray)
damage = defdamage;
}
int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.SourceAngleToTarget());
int newdam = P_DamageMobj(t.linetarget, self->target, self->target, damage, dmgType, dmgFlags|DMG_USEANGLE, t.angleFromSource);
P_TraceBleed(newdam > 0 ? newdam : damage, &t, self);
}
}

View file

@ -293,7 +293,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw)
S_Sound (self, CHAN_WEAPON, hitsound, 1, ATTN_NORM);
// turn to face target
angle = t.SourceAngleToTarget();
angle = t.angleFromSource;
if (angle - self->angle > ANG180)
{
if (angle - self->angle < (angle_t)(-ANG90/20))
@ -344,7 +344,7 @@ static void MarinePunch(AActor *self, int damagemul)
if (t.linetarget)
{
S_Sound (self, CHAN_WEAPON, "*fist", 1, ATTN_NORM);
self->angle = t.SourceAngleToTarget();
self->angle = t.angleFromSource;
}
}

View file

@ -189,7 +189,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL1)
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t);
if (t.linetarget)
{
player->mo->angle = t.SourceAngleToTarget();
player->mo->angle = t.angleFromSource;
}
P_PlayPeck (player->mo);
player->chickenPeck = 12;
@ -224,7 +224,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BeakAttackPL2)
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "BeakPuff", true, &t);
if (t.linetarget)
{
player->mo->angle = t.SourceAngleToTarget();
player->mo->angle = t.angleFromSource;
}
P_PlayPeck (player->mo);
player->chickenPeck = 12;

View file

@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack)
{
//S_StartSound(player->mo, sfx_stfhit);
// turn to face target
self->angle = t.SourceAngleToTarget();
self->angle = t.angleFromSource;
}
return 0;
}
@ -324,7 +324,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack)
S_Sound (self, CHAN_AUTO, "weapons/gauntletshit", 1, ATTN_NORM);
}
// turn to face target
angle = t.SourceAngleToTarget();
angle = t.angleFromSource;
if (angle-self->angle > ANG180)
{
if ((int)(angle-self->angle) < -ANG90/20)
@ -675,7 +675,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact)
if (t.linetarget && self->target != t.linetarget)
{
self->tracer = t.linetarget;
angle = t.SourceAngleToTarget();
angle = t.angleFromSource;
newAngle = true;
break;
}

View file

@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
P_LineAttack(pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, puff, false, &t);
if (t.linetarget != NULL)
{
pmo->angle = t.SourceAngleToTarget();
pmo->angle = t.angleFromSource;
if (((t.linetarget->player && (!t.linetarget->IsTeammate(pmo) || level.teamdamage != 0)) || t.linetarget->flags3&MF3_ISMONSTER)
&& (!(t.linetarget->flags2&(MF2_DORMANT | MF2_INVULNERABLE))))
{

View file

@ -245,7 +245,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
{
if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player)
{
P_ThrustMobj(t.linetarget, t.hitangle, power);
P_ThrustMobj(t.linetarget, t.angleFromSource, power);
}
AdjustPlayerAngle(pmo, &t);
useMana++;

View file

@ -57,7 +57,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
AdjustPlayerAngle(pmo, &t);
if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player)
{
P_ThrustMobj(t.linetarget, t.hitangle, power);
P_ThrustMobj(t.linetarget, t.angleFromSource, power);
}
pmo->weaponspecial = false; // Don't throw a hammer
goto hammerdone;
@ -73,7 +73,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
AdjustPlayerAngle(pmo, &t);
if (t.linetarget->flags3 & MF3_ISMONSTER || t.linetarget->player)
{
P_ThrustMobj(t.linetarget, t.hitangle, power);
P_ThrustMobj(t.linetarget, t.angleFromSource, power);
}
pmo->weaponspecial = false; // Don't throw a hammer
goto hammerdone;

View file

@ -30,7 +30,7 @@ void AdjustPlayerAngle (AActor *pmo, FTranslatedLineTarget *t)
angle_t angle;
int difference;
angle = t->SourceAngleToTarget();
angle = t->angleFromSource;
difference = (int)angle - (int)pmo->angle;
if (abs(difference) > MAX_ANGLE_ADJUST)
{
@ -82,7 +82,7 @@ static bool TryPunch(APlayerPawn *pmo, angle_t angle, int damage, fixed_t power)
if (t.linetarget->player != NULL ||
(t.linetarget->Mass != INT_MAX && (t.linetarget->flags3 & MF3_ISMONSTER)))
{
P_ThrustMobj (t.linetarget, t.hitangle, power);
P_ThrustMobj (t.linetarget, t.angleFromSource, power);
}
AdjustPlayerAngle (pmo, &t);
return true;

View file

@ -82,7 +82,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireConePL1)
slope = P_AimLineAttack (self, angle, MELEERANGE, &t, 0, ALF_CHECK3D);
if (t.linetarget)
{
P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, t.SourceAngleToTarget());
P_DamageMobj (t.linetarget, self, self, damage, NAME_Ice, DMG_USEANGLE, t.angleFromSource);
conedone = true;
break;
}

View file

@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_JabDagger)
S_Sound (self, CHAN_WEAPON,
t.linetarget->flags & MF_NOBLOOD ? "misc/metalhit" : "misc/meathit",
1, ATTN_NORM);
self->angle = t.SourceAngleToTarget();
self->angle = t.angleFromSource;
self->flags |= MF_JUSTATTACKED;
P_DaggerAlert (self, t.linetarget);
}

View file

@ -690,4 +690,5 @@ xx(Max_10_Exp)
xx(__decorate_internal_int__)
xx(__decorate_internal_bool__)
xx(__decorate_internal_state__)
xx(__decorate_internal_state__)
xx(__decorate_internal_float__)

View file

@ -300,6 +300,7 @@ enum
FFCF_NOFLOOR = 32,
FFCF_NOCEILING = 64,
FFCF_RESTRICTEDPORTAL = 128, // current values in the iterator's return are through a restricted portal type (i.e. some features are blocked.)
FFCF_NODROPOFF = 256, // Caller does not need a dropoff (saves some time when checking portals)
};
void P_FindFloorCeiling (AActor *actor, int flags=0);

File diff suppressed because it is too large Load diff

View file

@ -210,7 +210,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
open.floorpic = front->GetTexture(sector_t::floor);
open.floorterrain = front->GetTerrain(sector_t::floor);
if (bf != FIXED_MIN) open.lowfloor = bf;
else
else if (!(flags & FFCF_NODROPOFF))
{
// We must check through the portal for the actual dropoff.
// If there's no lines in the lower sections we'd never get a usable value otherwise.
@ -224,7 +224,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
open.floorpic = back->GetTexture(sector_t::floor);
open.floorterrain = back->GetTerrain(sector_t::floor);
if (ff != FIXED_MIN) open.lowfloor = ff;
else
else if (!(flags & FFCF_NODROPOFF))
{
// We must check through the portal for the actual dropoff.
// If there's no lines in the lower sections we'd never get a usable value otherwise.
@ -264,7 +264,8 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
open.abovemidtex = open.touchmidtex = false;
}
open.range = open.top - open.bottom;
// avoid overflows in the opening.
open.range = (fixed_t)MIN<QWORD>((QWORD)open.top - open.bottom, FIXED_MAX);
}
@ -1286,9 +1287,33 @@ void FPathTraverse::AddThingIntercepts (int bx, int by, FBlockThingsIterator &it
fixed_t frac = P_InterceptVector (&trace, &line);
if (frac < startfrac)
{ // behind source
if (startfrac > 0)
{
// check if the trace starts within this actor
switch (i)
{
case 0:
line.y -= 2 * thing->radius;
break;
case 1:
line.x -= 2 * thing->radius;
break;
case 2:
line.y += 2 * thing->radius;
break;
case 3:
line.x += 2 * thing->radius;
break;
}
fixed_t frac2 = P_InterceptVector(&trace, &line);
if (frac2 >= startfrac) goto addit;
}
continue;
}
addit:
intercept_t newintercept;
newintercept.frac = frac;
newintercept.isaline = false;
@ -1421,16 +1446,6 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
int mapystep;
int count;
validcount++;
intercept_index = intercepts.Size();
this->startfrac = startfrac;
if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
x1 += FRACUNIT; // don't side exactly on a line
if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
y1 += FRACUNIT; // don't side exactly on a line
trace.x = x1;
trace.y = y1;
@ -1444,9 +1459,30 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
trace.dx = x2 - x1;
trace.dy = y2 - y1;
}
if (startfrac > 0)
{
fixed_t startdx = FixedMul(trace.dx, startfrac);
fixed_t startdy = FixedMul(trace.dy, startfrac);
_x1 = (long long)x1 + FixedMul(trace.dx, startfrac) - bmaporgx;
_y1 = (long long)y1 + FixedMul(trace.dy, startfrac) - bmaporgy;
x1 += startdx;
y1 += startdy;
x2 = trace.dx - startdx;
y2 = trace.dy - startdy;
flags |= PT_DELTA;
}
validcount++;
intercept_index = intercepts.Size();
this->startfrac = startfrac;
if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
x1 += FRACUNIT; // don't side exactly on a line
if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
y1 += FRACUNIT; // don't side exactly on a line
_x1 = (long long)x1 - bmaporgx;
_y1 = (long long)y1 - bmaporgy;
x1 -= bmaporgx;
y1 -= bmaporgy;
xt1 = int(_x1 >> MAPBLOCKSHIFT);
@ -1615,7 +1651,7 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl
//
//===========================================================================
bool FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos)
int FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos)
{
if (!in->isaline || !in->d.line->isLinePortal()) return false;
if (P_PointOnLineSidePrecise(trace.x, trace.y, in->d.line) == 1) return false;
@ -1635,7 +1671,7 @@ bool FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos
}
intercepts.Resize(intercept_index);
init(hitx, hity, endx, endy, flags, in->frac);
return true;
return in->d.line->getPortal()->mType == PORTT_LINKED? 1:-1;
}
//===========================================================================

View file

@ -26,7 +26,6 @@ struct intercept_t
} d;
};
//==========================================================================
//
// P_PointOnLineSide
@ -107,6 +106,10 @@ struct FLineOpening
};
void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0, int flags=0);
inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixedvec2 xy, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0)
{
P_LineOpening(open, thing, linedef, xy.x, xy.y, refx, refy, flags);
}
class FBoundingBox;
struct polyblock_t;
@ -351,14 +354,24 @@ public:
intercept_t *Next();
FPathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags)
FPathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0)
{
init(x1, y1, x2, y2, flags);
init(x1, y1, x2, y2, flags, startfrac);
}
void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0);
bool PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL);
int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL);
virtual ~FPathTraverse();
const divline_t &Trace() const { return trace; }
inline fixedvec2 InterceptPoint(const intercept_t *in)
{
return
{
trace.x + FixedMul(trace.dx, in->frac),
trace.y + FixedMul(trace.dy, in->frac)
};
}
};
//============================================================================

View file

@ -709,14 +709,13 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy)
// Teleport portals are intentionally ignored since skipping this stuff is their entire reason for existence.
if (port->mFlags & PORTF_INTERACTIVE)
{
fixed_t hitdx = FixedMul(it.Trace().dx, in->frac);
fixed_t hitdy = FixedMul(it.Trace().dy, in->frac);
fixedvec2 hit = it.InterceptPoint(in);
if (port->mType == PORTT_LINKED)
{
// optimized handling for linked portals where we only need to add an offset.
actx = it.Trace().x + hitdx + port->mXDisplacement;
acty = it.Trace().y + hitdy + port->mYDisplacement;
hit.x += port->mXDisplacement;
hit.y += port->mYDisplacement;
dest.x += port->mXDisplacement;
dest.y += port->mYDisplacement;
}
@ -724,15 +723,12 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy)
{
// interactive ones are more complex because the vector may be rotated.
// Note: There is no z-translation here, there's just too much code in the engine that wouldn't be able to handle interactive portals with a height difference.
actx = it.Trace().x + hitdx;
acty = it.Trace().y + hitdy;
P_TranslatePortalXY(line, out, actx, acty);
P_TranslatePortalXY(line, out, hit.x, hit.y);
P_TranslatePortalXY(line, out, dest.x, dest.y);
}
// update the fields, end this trace and restart from the new position
dx = dest.x - actx;
dy = dest.y - acty;
dx = dest.x - hit.x;
dy = dest.y - hit.y;
repeat = true;
}
@ -1108,9 +1104,16 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
bool retval = false;
out.inited = true;
processMask.setSize(Displacements.size);
if (Displacements.size == 1)
{
processMask.setBit(startgroup);
return false;
}
if (linkedPortals.Size() != 0)
{
processMask.setSize(linkedPortals.Size());
processMask.clear();
foundPortals.Clear();

View file

@ -360,8 +360,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth)
//===========================================================================
//
// __decorate_internal_state__
// __decorate_internal_int__
// __decorate_internal_bool__
// __decorate_internal_float__
//
// Returns the state passed in.
// Placeholders for forcing DECORATE to cast numbers. If actually called,
// returns whatever was passed.
//
//===========================================================================
@ -373,14 +377,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_state__)
ACTION_RETURN_STATE(returnme);
}
//===========================================================================
//
// __decorate_internal_int__
//
// Returns the int passed in.
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_int__)
{
PARAM_PROLOGUE;
@ -389,14 +385,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_int__)
ACTION_RETURN_INT(returnme);
}
//===========================================================================
//
// __decorate_internal_bool__
//
// Returns the bool passed in.
//
//===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_bool__)
{
PARAM_PROLOGUE;
@ -405,6 +393,19 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_bool__)
ACTION_RETURN_BOOL(returnme);
}
DEFINE_ACTION_FUNCTION_PARAMS(AActor, __decorate_internal_float__)
{
PARAM_PROLOGUE;
PARAM_OBJECT(self, AActor);
PARAM_FLOAT(returnme);
if (numret > 0)
{
ret->SetFloat(returnme);
return 1;
}
return 0;
}
//==========================================================================
//
// A_RearrangePointers
@ -1796,7 +1797,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomPunch)
if (!(flags & CPF_NOTURN))
{
// turn to face target
self->angle = t.SourceAngleToTarget();
self->angle = t.angleFromSource;
}
if (flags & CPF_PULLIN) self->flags |= MF_JUSTATTACKED;

View file

@ -3420,7 +3420,8 @@ bool FxVMFunctionCall::CheckEmitCast(VMFunctionBuilder *build, bool returnit, Ex
FName funcname = Function->SymbolName;
if (funcname == NAME___decorate_internal_int__ ||
funcname == NAME___decorate_internal_bool__ ||
funcname == NAME___decorate_internal_state__)
funcname == NAME___decorate_internal_state__ ||
funcname == NAME___decorate_internal_float__)
{
FxExpression *arg = (*ArgList)[0];
if (returnit)

View file

@ -711,6 +711,8 @@ FName CheckCastKludges(FName in)
return NAME___decorate_internal_bool__;
case NAME_State:
return NAME___decorate_internal_state__;
case NAME_Float:
return NAME___decorate_internal_float__;
default:
return in;
}

View file

@ -356,4 +356,5 @@ ACTOR Actor native //: Thinker
native state __decorate_internal_state__(state);
native int __decorate_internal_int__(int);
native bool __decorate_internal_bool__(bool);
native float __decorate_internal_float__(float);
}