- Fixed: The rail sound used the shooter's position for calculating the sound origin

but should use the camera position instead to get the correct position for
  the closest point along the trail.
- Fixed: Explosions no longer caused splashes.
- Fixed: Copying translations to lower decals had the shade color check wrong.
- Fixed: Waggling floors did not move attached geometry.
- Cleaned up p_floor.cpp so that related parts of the code are grouped together.

SVN r1926 (trunk)
This commit is contained in:
Christoph Oelckers 2009-10-17 11:30:44 +00:00
commit 0c39b5c66a
12 changed files with 341 additions and 219 deletions

View file

@ -29,11 +29,33 @@
#include "doomstat.h"
#include "r_state.h"
#include "tables.h"
#include "p_3dmidtex.h"
#include "r_interpolate.h"
//==========================================================================
//
//
//
//==========================================================================
static void StartFloorSound (sector_t *sec)
{
if (sec->seqType >= 0)
{
SN_StartSequence (sec, CHAN_FLOOR, sec->seqType, SEQ_PLATFORM, 0);
}
else
{
SN_StartSequence (sec, CHAN_FLOOR, "Floor", 0);
}
}
//==========================================================================
//
// FLOORS
//
//==========================================================================
IMPLEMENT_CLASS (DFloor)
@ -60,71 +82,12 @@ void DFloor::Serialize (FArchive &arc)
<< m_Hexencrush;
}
IMPLEMENT_POINTY_CLASS (DElevator)
DECLARE_POINTER(m_Interp_Floor)
DECLARE_POINTER(m_Interp_Ceiling)
END_POINTERS
DElevator::DElevator ()
{
}
void DElevator::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_Type
<< m_Direction
<< m_FloorDestDist
<< m_CeilingDestDist
<< m_Speed
<< m_Interp_Floor
<< m_Interp_Ceiling;
}
void DElevator::Destroy()
{
if (m_Interp_Ceiling != NULL)
{
m_Interp_Ceiling->DelRef();
m_Interp_Ceiling = NULL;
}
if (m_Interp_Floor != NULL)
{
m_Interp_Floor->DelRef();
m_Interp_Floor = NULL;
}
Super::Destroy();
}
IMPLEMENT_POINTY_CLASS (DWaggleBase)
DECLARE_POINTER(m_Interpolation)
END_POINTERS
IMPLEMENT_CLASS (DFloorWaggle)
IMPLEMENT_CLASS (DCeilingWaggle)
DWaggleBase::DWaggleBase ()
{
}
void DWaggleBase::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_OriginalDist
<< m_Accumulator
<< m_AccDelta
<< m_TargetScale
<< m_Scale
<< m_ScaleDelta
<< m_Ticker
<< m_State
<< m_Interpolation;
}
//==========================================================================
//
// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)
// MOVE A FLOOR TO ITS DESTINATION (UP OR DOWN)
//
//==========================================================================
void DFloor::Tick ()
{
EResult res;
@ -238,62 +201,11 @@ void DFloor::Tick ()
}
}
//==========================================================================
//
// T_MoveElevator()
//
// Move an elevator to it's destination (up or down)
// Called once per tick for each moving floor.
//
// Passed an elevator_t structure that contains all pertinent info about the
// move. See P_SPEC.H for fields.
// No return.
//
// jff 02/22/98 added to support parallel floor/ceiling motion
//
void DElevator::Tick ()
{
EResult res;
fixed_t oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.d;
oldceiling = m_Sector->ceilingplane.d;
if (m_Direction < 0) // moving down
{
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == ok || res == pastdest)
{
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == crushed)
{
MoveFloor (m_Speed, oldfloor, -m_Direction);
}
}
}
else // up
{
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == ok || res == pastdest)
{
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == crushed)
{
MoveCeiling (m_Speed, oldceiling, -m_Direction);
}
}
}
if (res == pastdest) // if destination height acheived
{
// make floor stop sound
SN_StopSequence (m_Sector);
m_Sector->floordata = NULL; //jff 2/22/98
m_Sector->ceilingdata = NULL; //jff 2/22/98
Destroy (); // remove elevator from actives
}
}
//==========================================================================
void DFloor::SetFloorChangeType (sector_t *sec, int change)
{
@ -315,37 +227,35 @@ void DFloor::SetFloorChangeType (sector_t *sec, int change)
}
}
static void StartFloorSound (sector_t *sec)
{
if (sec->seqType >= 0)
{
SN_StartSequence (sec, CHAN_FLOOR, sec->seqType, SEQ_PLATFORM, 0);
}
else
{
SN_StartSequence (sec, CHAN_FLOOR, "Floor", 0);
}
}
//==========================================================================
//
//
//
//==========================================================================
void DFloor::StartFloorSound ()
{
::StartFloorSound (m_Sector);
}
void DElevator::StartFloorSound ()
{
::StartFloorSound (m_Sector);
}
//==========================================================================
//
//
//
//==========================================================================
DFloor::DFloor (sector_t *sec)
: DMovingFloor (sec)
{
}
//==========================================================================
//
// HANDLE FLOOR TYPES
// [RH] Added tag, speed, height, crush, change params.
//
//==========================================================================
bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
fixed_t speed, fixed_t height, int crush, int change, bool hexencrush)
{
@ -601,10 +511,14 @@ manual_floor:
return rtn;
}
//==========================================================================
//
// [RH]
// EV_FloorCrushStop
// Stop a floor from crushing!
//
//==========================================================================
bool EV_FloorCrushStop (int tag)
{
int secnum = -1;
@ -624,61 +538,11 @@ bool EV_FloorCrushStop (int tag)
return true;
}
//==========================================================================
//
// EV_DoChange()
// Linear tag search to emulate stair building from Doom.exe
//
// Handle pure change types. These change floor texture and sector type
// by trigger or numeric model without moving the floor.
//
// The linedef causing the change and the type of change is passed
// Returns true if any sector changes
//
// jff 3/15/98 added to better support generalized sector types
// [RH] Added tag parameter.
//
bool EV_DoChange (line_t *line, EChange changetype, int tag)
{
int secnum;
bool rtn;
sector_t *sec;
sector_t *secm;
secnum = -1;
rtn = false;
// change all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{
sec = &sectors[secnum];
rtn = true;
// handle trigger or numeric change type
FTextureID oldpic = sec->GetTexture(sector_t::floor);
switch(changetype)
{
case trigChangeOnly:
if (line)
{ // [RH] if no line, no change
sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK);
}
break;
case numChangeOnly:
secm = sec->FindModelFloorSector (sec->CenterFloor());
if (secm)
{ // if no model, no change
sec->SetTexture(sector_t::floor, secm->GetTexture(sector_t::floor));
sec->special = secm->special;
}
break;
default:
break;
}
}
return rtn;
}
//==========================================================================
static int P_FindSectorFromTagLinear (int tag, int start)
{
@ -689,6 +553,7 @@ static int P_FindSectorFromTagLinear (int tag, int start)
return -1;
}
//==========================================================================
//
// BUILD A STAIRCASE!
// [RH] Added stairsize, srcspeed, delay, reset, igntxt, usespecials parameters
@ -696,6 +561,8 @@ static int P_FindSectorFromTagLinear (int tag, int start)
// by its special. If usespecials is 2, each sector stays in "sync" with
// the others.
//
//==========================================================================
bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
fixed_t stairsize, fixed_t speed, int delay, int reset, int igntxt,
int usespecials)
@ -897,7 +764,12 @@ manual_stair:
return rtn;
}
//==========================================================================
//
// [RH] Added pillarspeed and slimespeed parameters
//
//==========================================================================
bool EV_DoDonut (int tag, fixed_t pillarspeed, fixed_t slimespeed)
{
sector_t* s1;
@ -966,6 +838,21 @@ bool EV_DoDonut (int tag, fixed_t pillarspeed, fixed_t slimespeed)
return rtn;
}
//==========================================================================
//
// Elevators
//
//==========================================================================
IMPLEMENT_POINTY_CLASS (DElevator)
DECLARE_POINTER(m_Interp_Floor)
DECLARE_POINTER(m_Interp_Ceiling)
END_POINTERS
DElevator::DElevator ()
{
}
DElevator::DElevator (sector_t *sec)
: Super (sec)
{
@ -975,6 +862,111 @@ DElevator::DElevator (sector_t *sec)
m_Interp_Ceiling = sec->SetInterpolation(sector_t::CeilingMove, true);
}
void DElevator::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_Type
<< m_Direction
<< m_FloorDestDist
<< m_CeilingDestDist
<< m_Speed
<< m_Interp_Floor
<< m_Interp_Ceiling;
}
//==========================================================================
//
//
//
//==========================================================================
void DElevator::Destroy()
{
if (m_Interp_Ceiling != NULL)
{
m_Interp_Ceiling->DelRef();
m_Interp_Ceiling = NULL;
}
if (m_Interp_Floor != NULL)
{
m_Interp_Floor->DelRef();
m_Interp_Floor = NULL;
}
Super::Destroy();
}
//==========================================================================
//
// T_MoveElevator()
//
// Move an elevator to it's destination (up or down)
// Called once per tick for each moving floor.
//
// Passed an elevator_t structure that contains all pertinent info about the
// move. See P_SPEC.H for fields.
// No return.
//
// jff 02/22/98 added to support parallel floor/ceiling motion
//
//==========================================================================
void DElevator::Tick ()
{
EResult res;
fixed_t oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.d;
oldceiling = m_Sector->ceilingplane.d;
if (m_Direction < 0) // moving down
{
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == ok || res == pastdest)
{
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == crushed)
{
MoveFloor (m_Speed, oldfloor, -m_Direction);
}
}
}
else // up
{
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == ok || res == pastdest)
{
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == crushed)
{
MoveCeiling (m_Speed, oldceiling, -m_Direction);
}
}
}
if (res == pastdest) // if destination height acheived
{
// make floor stop sound
SN_StopSequence (m_Sector);
m_Sector->floordata = NULL; //jff 2/22/98
m_Sector->ceilingdata = NULL; //jff 2/22/98
Destroy (); // remove elevator from actives
}
}
//==========================================================================
//
//
//
//==========================================================================
void DElevator::StartFloorSound ()
{
::StartFloorSound (m_Sector);
}
//==========================================================================
//
// EV_DoElevator
//
@ -985,6 +977,8 @@ DElevator::DElevator (sector_t *sec)
// jff 2/22/98 new type to move floor and ceiling in parallel
// [RH] Added speed, tag, and height parameters and new types.
//
//==========================================================================
bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
fixed_t speed, fixed_t height, int tag)
{
@ -1071,6 +1065,96 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
}
//==========================================================================
//
// EV_DoChange()
//
// Handle pure change types. These change floor texture and sector type
// by trigger or numeric model without moving the floor.
//
// The linedef causing the change and the type of change is passed
// Returns true if any sector changes
//
// jff 3/15/98 added to better support generalized sector types
// [RH] Added tag parameter.
//
//==========================================================================
bool EV_DoChange (line_t *line, EChange changetype, int tag)
{
int secnum;
bool rtn;
sector_t *sec;
sector_t *secm;
secnum = -1;
rtn = false;
// change all sectors with the same tag as the linedef
while ((secnum = P_FindSectorFromTag (tag, secnum)) >= 0)
{
sec = &sectors[secnum];
rtn = true;
// handle trigger or numeric change type
FTextureID oldpic = sec->GetTexture(sector_t::floor);
switch(changetype)
{
case trigChangeOnly:
if (line)
{ // [RH] if no line, no change
sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
sec->special = (sec->special & SECRET_MASK) | (line->frontsector->special & ~SECRET_MASK);
}
break;
case numChangeOnly:
secm = sec->FindModelFloorSector (sec->CenterFloor());
if (secm)
{ // if no model, no change
sec->SetTexture(sector_t::floor, secm->GetTexture(sector_t::floor));
sec->special = secm->special;
}
break;
default:
break;
}
}
return rtn;
}
//==========================================================================
//
//
//
//==========================================================================
IMPLEMENT_POINTY_CLASS (DWaggleBase)
DECLARE_POINTER(m_Interpolation)
END_POINTERS
IMPLEMENT_CLASS (DFloorWaggle)
IMPLEMENT_CLASS (DCeilingWaggle)
DWaggleBase::DWaggleBase ()
{
}
void DWaggleBase::Serialize (FArchive &arc)
{
Super::Serialize (arc);
arc << m_OriginalDist
<< m_Accumulator
<< m_AccDelta
<< m_TargetScale
<< m_Scale
<< m_ScaleDelta
<< m_Ticker
<< m_State
<< m_Interpolation;
}
//==========================================================================
//
// WaggleBase
@ -1096,6 +1180,12 @@ void DWaggleBase::Destroy()
Super::Destroy();
}
//==========================================================================
//
//
//
//==========================================================================
void DWaggleBase::DoWaggle (bool ceiling)
{
secplane_t *plane;
@ -1159,7 +1249,12 @@ void DWaggleBase::DoWaggle (bool ceiling)
FixedMul (FloatBobOffsets[(m_Accumulator>>FRACBITS)&63], m_Scale));
m_Sector->ChangePlaneTexZ(pos, plane->HeightDiff (dist));
dist = plane->HeightDiff (dist);
P_ChangeSector (m_Sector, true, dist, ceiling, false);
// Interesting: Hexen passes 'true' for the crunch parameter which really is crushing damage here...
// Also, this does not reset the move if it blocks.
P_Scroll3dMidtex(m_Sector, 1, dist, ceiling);
P_MoveLinkedSectors(m_Sector, 1, dist, ceiling);
P_ChangeSector (m_Sector, 1, dist, ceiling, false);
}
//==========================================================================
@ -1176,7 +1271,7 @@ DFloorWaggle::DFloorWaggle (sector_t *sec)
: Super (sec)
{
sec->floordata = this;
m_Interpolation = sec->SetInterpolation(sector_t::FloorMove, false);
m_Interpolation = sec->SetInterpolation(sector_t::FloorMove, true);
}
void DFloorWaggle::Tick ()
@ -1198,7 +1293,7 @@ DCeilingWaggle::DCeilingWaggle (sector_t *sec)
: Super (sec)
{
sec->ceilingdata = this;
m_Interpolation = sec->SetInterpolation(sector_t::CeilingMove, false);
m_Interpolation = sec->SetInterpolation(sector_t::CeilingMove, true);
}
void DCeilingWaggle::Tick ()