This commit is contained in:
nashmuhandes 2016-05-14 05:55:46 +08:00
commit bed6c2d8d8
17 changed files with 162 additions and 47 deletions

View file

@ -323,6 +323,8 @@ void Net_ClearBuffers ()
memset (netcmds, 0, sizeof(netcmds));
memset (nettics, 0, sizeof(nettics));
memset (nodeingame, 0, sizeof(nodeingame));
memset (nodeforplayer, 0, sizeof(nodeforplayer));
memset (playerfornode, 0, sizeof(playerfornode));
memset (remoteresend, 0, sizeof(remoteresend));
memset (resendto, 0, sizeof(resendto));
memset (resendcount, 0, sizeof(resendcount));

View file

@ -59,13 +59,6 @@ void ASkyViewpoint::BeginPlay ()
void ASkyViewpoint::Destroy ()
{
// remove all sector references to ourselves.
for (int i = 0; i < numsectors; i++)
{
if (sectors[i].GetPortal(sector_t::floor)->mSkybox == this)
sectors[i].ClearPortal(sector_t::floor);
if (sectors[i].GetPortal(sector_t::ceiling)->mSkybox == this)
sectors[i].ClearPortal(sector_t::ceiling);
}
for (auto &s : sectorPortals)
{
if (s.mSkybox == this) s.mSkybox = 0;

View file

@ -367,11 +367,11 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags)
DAngle diffang = deltaangle(player->mo->Angles.Yaw, badguyangle);
if (diffang > 45.)
{ // turn face right
damage_angle = 0;
damage_angle = 2;
}
else if (diffang < -45.)
{ // turn face left
damage_angle = 2;
damage_angle = 0;
}
}
}

View file

@ -342,21 +342,28 @@ void FRenderState::SetClipHeight(float height, float direction)
{
mClipHeight = height;
mClipHeightDirection = direction;
#if 1
// This still doesn't work... :(
if (gl.glslversion < 1.3f) return;
#endif
if (direction != 0.f)
{
if (gl.glslversion >= 1.3f) glEnable(GL_CLIP_DISTANCE0);
else
/*
if (gl.glslversion < 1.3f)
{
// This does not work. Need someone who understands how glClipPlane works...
//glEnable(GL_CLIP_PLANE0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadMatrixf(mViewMatrix.get());
// Plane mirrors never are slopes.
//double d[4] = { 0, direction, 0, -direction * height };
//glClipPlane(GL_CLIP_PLANE0, d);
double d[4] = { 0, direction, 0, -direction * height };
glClipPlane(GL_CLIP_PLANE0, d);
glPopMatrix();
}
*/
glEnable(GL_CLIP_DISTANCE0);
}
else
{
if (gl.glslversion >= 1.3f) glDisable(GL_CLIP_DISTANCE0);
//else glDisable(GL_CLIP_PLANE0);
glDisable(GL_CLIP_DISTANCE0); // GL_CLIP_PLANE0 is the same value so no need to make a distinction
}
}

View file

@ -943,7 +943,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
bool forcedPain = false;
int fakeDamage = 0;
int holdDamage = 0;
int rawdamage = damage;
const int rawdamage = damage;
if (damage < 0) damage = 0;
@ -1268,7 +1268,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
else
return -1;
}
// Armor for players.
if (!(flags & DMG_NO_ARMOR) && player->mo->Inventory != NULL)
{
int newdam = damage;
@ -1281,15 +1281,21 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage,
// if we are telefragging don't let the damage value go below that magic value. Some further checks would fail otherwise.
damage = newdam;
}
if (damage <= 0)
{
// [MC] Godmode doesn't need checking here, it's already being handled above.
if ((target->flags5 & MF5_NOPAIN) || (inflictor && (inflictor->flags5 & MF5_PAINLESS)))
return damage;
// If MF6_FORCEPAIN is set, make the player enter the pain state.
if (!(target->flags5 & MF5_NOPAIN) && inflictor != NULL &&
(inflictor->flags6 & MF6_FORCEPAIN) && !(inflictor->flags5 & MF5_PAINLESS)
&& (!(player->mo->flags2 & MF2_INVULNERABLE)) && (!(player->cheats & CF_GODMODE)) && (!(player->cheats & CF_GODMODE2)))
{
if ((inflictor && (inflictor->flags6 & MF6_FORCEPAIN)))
goto dopain;
else if (((player->mo->flags7 & MF7_ALLOWPAIN) && (rawdamage > 0)) ||
(inflictor && (inflictor->flags7 & MF7_CAUSEPAIN)))
{
invulpain = true;
goto fakepain;
}
return damage;
}

View file

@ -344,6 +344,7 @@ enum
RADF_NOIMPACTDAMAGE = 2,
RADF_SOURCEISSPOT = 4,
RADF_NODAMAGE = 8,
RADF_THRUSTZ = 16,
};
void P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance,
FName damageType, int flags, int fulldamagedistance=0);
@ -355,7 +356,6 @@ msecnode_t* P_DelSecnode(msecnode_t *, msecnode_t *sector_t::*head);
void P_CreateSecNodeList(AActor*); // phares 3/14/98
double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98
double P_GetFriction(const AActor *mo, double *frictionfactor);
bool Check_Sides(AActor *, int, int); // phares
// [RH]
const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move);

View file

@ -2534,13 +2534,9 @@ bool P_CheckMove(AActor *thing, const DVector2 &pos, int flags)
return false;
}
}
else if (flags & PCM_DROPOFF)
else if ((flags & PCM_DROPOFF) && !(thing->flags & (MF_FLOAT|MF_DROPOFF)))
{
const DVector3 oldpos = thing->Pos();
thing->SetOrigin(pos.X, pos.Y, newz, true);
bool hcheck = (newz - thing->MaxDropOffHeight > thing->dropoffz);
thing->SetOrigin(oldpos, true);
if (hcheck && !(thing->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF))
if (newz - tm.dropoffz > thing->MaxDropOffHeight)
{
return false;
}
@ -4845,7 +4841,7 @@ void P_AimCamera(AActor *t1, DVector3 &campos, DAngle &camangle, sector_t *&Came
}
else
{
campos = trace.HitPos;
campos = trace.HitPos - trace.HitVector * 1/256.;
}
CameraSector = trace.Sector;
unlinked = trace.unlinked;
@ -5326,7 +5322,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo
vz *= 0.8;
}
thing->Thrust(bombspot->AngleTo(thing), thrust);
if (!(flags & RADF_NODAMAGE))
if (!(flags & RADF_NODAMAGE) || (flags & RADF_THRUSTZ))
thing->Vel.Z += vz; // this really doesn't work well
}
}

View file

@ -4391,6 +4391,7 @@ void AActor::Deactivate (AActor *activator)
void AActor::Destroy ()
{
ClearRenderSectorList();
ClearRenderLineList();
// [RH] Destroy any inventory this actor is carrying
DestroyAllInventory ();

View file

@ -1127,11 +1127,9 @@ bool P_AlignFlat (int linenum, int side, int fc)
if (!sec)
return false;
DVector2 pos = line->v1->fPos();
DVector2 pos2 = line->v2->fPos();
DAngle angle = (pos2 - pos).Angle();
DAngle angle = line->Delta().Angle();
DAngle norm = angle - 90;
double dist = norm.Cos() * pos.X + norm.Sin() * pos.Y;
double dist = -(norm.Cos() * line->v1->fX() + norm.Sin() * line->v1->fY());
if (side)
{

View file

@ -229,6 +229,10 @@ FArchive &operator<< (FArchive &arc, FSectorPortal &port)
<< port.mDestination
<< port.mDisplacement
<< port.mPlaneZ;
if (arc.IsLoading())
{
port.mSkybox = nullptr;
}
return arc;
}

View file

@ -191,7 +191,6 @@ struct FLinePortal
double mSinRot;
double mCosRot;
portnode_t *render_thinglist;
void *mRenderData;
};
extern TArray<FLinePortal> linePortals;
@ -229,7 +228,6 @@ struct FSectorPortal
DVector2 mDisplacement;
double mPlaneZ;
TObjPtr<AActor> mSkybox;
void *mRenderData;
bool MergeAllowed() const
{

View file

@ -2352,6 +2352,7 @@ void R_CheckDrawSegs ()
ptrdiff_t R_NewOpening (ptrdiff_t len)
{
ptrdiff_t res = lastopening;
len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings...
lastopening += len;
if ((size_t)lastopening > maxopenings)
{
@ -2512,6 +2513,7 @@ void R_StoreWallRange (int start, int stop)
if(sidedef->GetTexture(side_t::mid).isValid())
ds_p->bFakeBoundary |= 4; // it is also mid texture
// note: This should never have used the openings array to store its data!
ds_p->maskedtexturecol = R_NewOpening ((stop - start) * 2);
ds_p->swall = R_NewOpening ((stop - start) * 2);

View file

@ -1397,8 +1397,6 @@ static void S_LoadSound3D(sfxinfo_t *sfx)
if(sfx->data3d.isValid())
return;
unsigned int i;
DPrintf("Loading monoized sound \"%s\" (%td)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
int size = Wads.LumpLength(sfx->lumpnum);

View file

@ -1188,7 +1188,7 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(BYTE *sfxdata, int le
int sum = 0;
for(size_t c = 0;c < chancount;c++)
sum += sfxdata[i*chancount + c];
sfxdata[i] = sum / chancount;
sfxdata[i] = short(sum / chancount);
}
}
else if(type == SampleType_UInt8)
@ -1199,10 +1199,10 @@ std::pair<SoundHandle,bool> OpenALSoundRenderer::LoadSound(BYTE *sfxdata, int le
int sum = 0;
for(size_t c = 0;c < chancount;c++)
sum += sfxdata[i*chancount + c] - 128;
sfxdata[i] = (sum / chancount) + 128;
sfxdata[i] = BYTE((sum / chancount) + 128);
}
}
data.Resize(data.Size()/chancount);
data.Resize(unsigned(data.Size()/chancount));
}
ALenum err;

View file

@ -386,6 +386,103 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth)
return 0;
}
//==========================================================================
//
// GetZAt
//
// NON-ACTION function to get the floor or ceiling z at (x, y) with
// relativity being an option.
//==========================================================================
enum GZFlags
{
GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one.
GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter.
GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor.
GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z.
GZF_NOPORTALS = 1 << 4, // Don't pass through any portals.
GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors.
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt)
{
if (numret > 0)
{
assert(ret != NULL);
PARAM_SELF_PROLOGUE(AActor);
PARAM_FLOAT_OPT(px) { px = 0.; }
PARAM_FLOAT_OPT(py) { py = 0.; }
PARAM_ANGLE_OPT(angle) { angle = 0.; }
PARAM_INT_OPT(flags) { flags = 0; }
PARAM_INT_OPT(pick_pointer) { pick_pointer = AAPTR_DEFAULT; }
AActor *mobj = COPY_AAPTR(self, pick_pointer);
if (mobj == nullptr)
{
ret->SetFloat(0);
}
else
{
// [MC] At any time, the NextLowest/Highest functions could be changed to include
// more FFC flags to check. Don't risk it by just passing flags straight to it.
DVector2 pos = { px, py };
double z = 0.;
int pflags = (flags & GZF_3DRESTRICT) ? FFCF_3DRESTRICT : 0;
if (flags & GZF_NOPORTALS) pflags |= FFCF_NOPORTALS;
if (!(flags & GZF_ABSOLUTEPOS))
{
if (!(flags & GZF_ABSOLUTEANG))
{
angle += mobj->Angles.Yaw;
}
double s = angle.Sin();
double c = angle.Cos();
pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c);
}
sector_t *sec = P_PointInSector(pos);
if (sec)
{
if (flags & GZF_CEILING)
{
if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS))
{
z = sec->ceilingplane.ZatPoint(pos);
}
else if (flags & GZF_NO3DFLOOR)
{
z = sec->HighestCeilingAt(pos);
}
else
{ // [MC] Handle strict 3D floors and portal toggling via the flags passed to it.
z = sec->NextHighestCeilingAt(pos.X, pos.Y, mobj->Z(), mobj->Top(), pflags);
}
}
else
{
if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS))
{
z = sec->floorplane.ZatPoint(pos);
}
else if (flags & GZF_NO3DFLOOR)
{
z = sec->LowestFloorAt(pos);
}
else
{
z = sec->NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight);
}
}
}
ret->SetFloat(z);
return 1;
}
}
return 0;
}
//===========================================================================
//
// __decorate_internal_state__
@ -1143,9 +1240,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Explode)
enum
{
RTF_AFFECTSOURCE = 1,
RTF_NOIMPACTDAMAGE = 2,
RTF_NOTMISSILE = 4,
RTF_AFFECTSOURCE = 1,
RTF_NOIMPACTDAMAGE = 2,
RTF_NOTMISSILE = 4,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_RadiusThrust)

View file

@ -43,6 +43,7 @@ ACTOR Actor native //: Thinker
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);
native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT);
native float GetAngle(bool relative, int ptr = AAPTR_DEFAULT);
native float GetZAt(float px = 0, float py = 0, float angle = 0, int flags = 0, int pick_pointer = AAPTR_DEFAULT);
native int GetSpawnHealth();
native int GetGibHealth();

View file

@ -178,6 +178,7 @@ const int XF_NOTMISSILE = 4;
const int RTF_AFFECTSOURCE = 1;
const int RTF_NOIMPACTDAMAGE = 2;
const int RTF_NOTMISSILE = 4;
const int RTF_THRUSTZ = 16;
// Flags for A_Blast
const int BF_USEAMMO = 1;
@ -549,3 +550,14 @@ enum
FMDF_INTERPOLATE = 1 << 1,
FMDF_NOANGLE = 1 << 2,
};
// Flags for GetZAt
enum
{
GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one.
GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter.
GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor.
GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z.
GZF_NOPORTALS = 1 << 4, // Don't pass through any portals.
GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors.
};