From 06dc96b062953e6b274c6d483a2ac1bc9d740e1f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 14:21:20 +0200 Subject: [PATCH 1/7] - removed 64 bit warnings. --- src/farchive.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/farchive.cpp b/src/farchive.cpp index 1780f862a..477d22718 100644 --- a/src/farchive.cpp +++ b/src/farchive.cpp @@ -859,8 +859,8 @@ void FArchive::WriteString(const FString &str) { // The count includes the '\0' terminator, but we don't // actually write it out. - WriteCount(str.Len() + 1); - Write(str, str.Len()); + WriteCount(DWORD(str.Len() + 1)); + Write(str, DWORD(str.Len())); } FArchive &FArchive::operator<< (char *&str) From 39d03f12b1fe9fe1dfdd4289489655a4022bf183 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 15:14:26 +0200 Subject: [PATCH 2/7] - fixed float <-> fixed conversion errors in Fragglescript. --- src/fragglescript/t_script.h | 2 +- src/fragglescript/t_variable.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index 39b0b93ee..02ea444a2 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -123,7 +123,7 @@ struct svalue_t void setDouble(double dp) { - value.f = fsfix(dp/65536); + value.f = fsfix(dp * 65536); type = svt_fixed; } }; diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp index 7fd39aa14..b41b05490 100644 --- a/src/fragglescript/t_variable.cpp +++ b/src/fragglescript/t_variable.cpp @@ -93,7 +93,7 @@ double floatvalue(const svalue_t &v) { return v.type == svt_string ? atof(v.string) : - v.type == svt_fixed ? v.value.f * 65536. : + v.type == svt_fixed ? v.value.f / 65536. : v.type == svt_mobj ? -1. : (double)v.value.i; } From 919f99db61e3c4054ff48522be165cd5ab7b6b39 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 16:52:42 +0200 Subject: [PATCH 3/7] - fixed typo in actor scale assignment when spawning. --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 13670bcb1..8147f2d07 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5010,7 +5010,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) if (mthing->Scale.X != 0) mobj->Scale.X = mthing->Scale.X * mobj->Scale.X; if (mthing->Scale.Y != 0) - mobj->Scale.X = mthing->Scale.Y * mobj->Scale.Y; + mobj->Scale.Y = mthing->Scale.Y * mobj->Scale.Y; if (mthing->pitch) mobj->Angles.Pitch = (double)mthing->pitch; if (mthing->roll) From caae61de4c8f104a50ef2d2c4fb85f60e72f5fb6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 8 Apr 2016 20:44:55 +0200 Subject: [PATCH 4/7] - removed DMoveCeiling and let FS call DCeiling::Create instead. Made a minor change to DCeiling::Create to keep it compatible, because handling for instantly moving ceilings is a bit different. --- src/fragglescript/t_func.cpp | 35 +---------------------------------- src/p_ceiling.cpp | 3 ++- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 9bf043af7..965f83fd0 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1720,39 +1720,6 @@ void FParser::SF_CeilingHeight(void) } -//========================================================================== -// -// -// -//========================================================================== - -class DMoveCeiling : public DCeiling -{ -public: - - DMoveCeiling(sector_t * sec,int tag,double destheight,double speed,int silent,int crush) - : DCeiling(sec) - { - m_Crush = crush; - m_Speed2 = m_Speed = m_Speed1 = speed; - m_Silent = silent; - m_Type = DCeiling::ceilLowerByValue; // doesn't really matter as long as it's no special value - m_Tag=tag; - m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->centerspot,destheight); - m_Direction=destheight>sec->GetPlaneTexZF(sector_t::ceiling)? 1:-1; - - // Do not interpolate instant movement ceilings. - double movedist = fabs(sec->ceilingplane.fD() - m_BottomHeight); - if (m_Speed >= movedist) - { - StopInterpolation (true); - m_Silent=2; - } - PlayCeilingSound(); - } -}; - - //========================================================================== // // @@ -1784,7 +1751,7 @@ void FParser::SF_MoveCeiling(void) // Don't start a second thinker on the same floor if (sec->ceilingdata) continue; - new DMoveCeiling(sec, tagnum, destheight, platspeed, silent, crush); + DCeiling::Create(sec, DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom); } } } diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 9a506be29..76884f6c5 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -257,7 +257,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, } // new door thinker - DCeiling *ceiling = new DCeiling (sec, speed, speed2, silent); + DCeiling *ceiling = new DCeiling (sec, speed, speed2, silent & ~4); vertex_t *spot = sec->lines[0]->v1; switch (type) @@ -413,6 +413,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, if (ceiling->m_Speed >= movedist) { ceiling->StopInterpolation(true); + if (silent & 4) ceiling->m_Silent = 2; } // set texture/type change properties From bc7e159be0d62e43824100dd00fdf2d532d15b08 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 12:07:34 +0200 Subject: [PATCH 5/7] - cleaned up ceiling creation and moved the Create function out of the DCeiling class. - did the same for floors so that FraggleScript no longer needs access to the thinkers themselves. --- src/dsectoreffect.h | 2 +- src/fragglescript/t_func.cpp | 44 +--- src/p_ceiling.cpp | 76 +++--- src/p_floor.cpp | 470 ++++++++++++++++++----------------- src/p_spec.h | 13 +- 5 files changed, 287 insertions(+), 318 deletions(-) diff --git a/src/dsectoreffect.h b/src/dsectoreffect.h index 042324416..3a564afc4 100644 --- a/src/dsectoreffect.h +++ b/src/dsectoreffect.h @@ -26,6 +26,7 @@ class DMover : public DSectorEffect HAS_OBJECT_POINTERS public: DMover (sector_t *sector); + void StopInterpolation(bool force = false); protected: TObjPtr interpolation; private: @@ -33,7 +34,6 @@ protected: DMover (); void Serialize (FArchive &arc); void Destroy(); - void StopInterpolation(bool force = false); }; class DMovingFloor : public DMover diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 965f83fd0..4826a6ca4 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1596,35 +1596,6 @@ void FParser::SF_FloorHeight(void) } -//============================================================================= -// -// -//============================================================================= -class DMoveFloor : public DFloor -{ -public: - DMoveFloor(sector_t * sec,double moveheight,int _m_Direction,int crush,double movespeed) - : DFloor(sec) - { - m_Type = floorRaiseByValue; - m_Crush = crush; - m_Speed=movespeed; - m_Direction = _m_Direction; - m_FloorDestDist = moveheight; - - // Do not interpolate instant movement floors. - double movedist = fabs(-sec->floorplane.fD() - moveheight); - if (m_Speed >= movedist) - { - StopInterpolation(true); - } - - StartFloorSound(); - } -}; - - - //========================================================================== // // @@ -1634,7 +1605,6 @@ public: void FParser::SF_MoveFloor(void) { int secnum = -1; - sector_t *sec; int tagnum, crush; double platspeed = 1, destheight; @@ -1650,12 +1620,7 @@ void FParser::SF_MoveFloor(void) FSSectorTagIterator itr(tagnum); while ((secnum = itr.Next()) >= 0) { - sec = §ors[secnum]; - // Don't start a second thinker on the same floor - if (sec->floordata) continue; - - new DMoveFloor(sec, sec->floorplane.PointToDist(sec->centerspot, destheight), - destheight < sec->CenterFloor() ? -1 : 1, crush, platspeed); + P_CreateFloor(§ors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false); } } } @@ -1729,7 +1694,6 @@ void FParser::SF_CeilingHeight(void) void FParser::SF_MoveCeiling(void) { int secnum = -1; - sector_t *sec; int tagnum; double platspeed = 1, destheight; int crush; @@ -1747,11 +1711,7 @@ void FParser::SF_MoveCeiling(void) FSSectorTagIterator itr(tagnum); while ((secnum = itr.Next()) >= 0) { - sec = §ors[secnum]; - - // Don't start a second thinker on the same floor - if (sec->ceilingdata) continue; - DCeiling::Create(sec, DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom); + P_CreateCeiling(§ors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom); } } } diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 76884f6c5..9c5d693a0 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -142,7 +142,7 @@ void DCeiling::Tick () { switch (m_Type) { - case ceilCrushAndRaise: + case DCeiling::ceilCrushAndRaise: m_Direction = -1; m_Speed = m_Speed1; if (!SN_IsMakingLoopingSound (m_Sector)) @@ -173,8 +173,8 @@ void DCeiling::Tick () { switch (m_Type) { - case ceilCrushAndRaise: - case ceilCrushRaiseAndStay: + case DCeiling::ceilCrushAndRaise: + case DCeiling::ceilCrushRaiseAndStay: m_Speed = m_Speed2; m_Direction = 1; if (!SN_IsMakingLoopingSound (m_Sector)) @@ -202,8 +202,8 @@ void DCeiling::Tick () { switch (m_Type) { - case ceilCrushAndRaise: - case ceilLowerAndCrush: + case DCeiling::ceilCrushAndRaise: + case DCeiling::ceilLowerAndCrush: if (m_CrushMode == ECrushMode::crushSlowdown) m_Speed = 1. / 8; break; @@ -244,9 +244,9 @@ DCeiling::DCeiling (sector_t *sec, double speed1, double speed2, int silent) // //============================================================================ -DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, +bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, - int crush, int silent, int change, ECrushMode hexencrush) + int crush, int silent, int change, DCeiling::ECrushMode hexencrush) { double targheight = 0; // Silence, GCC @@ -262,35 +262,35 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, switch (type) { - case ceilCrushAndRaise: - case ceilCrushRaiseAndStay: + case DCeiling::ceilCrushAndRaise: + case DCeiling::ceilCrushRaiseAndStay: ceiling->m_TopHeight = sec->ceilingplane.fD(); - case ceilLowerAndCrush: + case DCeiling::ceilLowerAndCrush: targheight = sec->FindHighestFloorPoint (&spot); targheight += height; ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseToHighest: + case DCeiling::ceilRaiseToHighest: targheight = sec->FindHighestCeilingSurrounding (&spot); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilLowerByValue: + case DCeiling::ceilLowerByValue: targheight = sec->ceilingplane.ZatPoint (spot) - height; ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseByValue: + case DCeiling::ceilRaiseByValue: targheight = sec->ceilingplane.ZatPoint (spot) + height; ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilMoveToValue: + case DCeiling::ceilMoveToValue: { double diff = height - sec->ceilingplane.ZatPoint (spot); @@ -308,81 +308,81 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, } break; - case ceilLowerToHighestFloor: + case DCeiling::ceilLowerToHighestFloor: targheight = sec->FindHighestFloorSurrounding (&spot); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseToHighestFloor: + case DCeiling::ceilRaiseToHighestFloor: targheight = sec->FindHighestFloorSurrounding (&spot); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilLowerInstant: + case DCeiling::ceilLowerInstant: targheight = sec->ceilingplane.ZatPoint (spot) - height; ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; ceiling->m_Speed = height; break; - case ceilRaiseInstant: + case DCeiling::ceilRaiseInstant: targheight = sec->ceilingplane.ZatPoint (spot) + height; ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; ceiling->m_Speed = height; break; - case ceilLowerToNearest: + case DCeiling::ceilLowerToNearest: targheight = sec->FindNextLowestCeiling (&spot); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseToNearest: + case DCeiling::ceilRaiseToNearest: targheight = sec->FindNextHighestCeiling (&spot); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilLowerToLowest: + case DCeiling::ceilLowerToLowest: targheight = sec->FindLowestCeilingSurrounding (&spot); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseToLowest: + case DCeiling::ceilRaiseToLowest: targheight = sec->FindLowestCeilingSurrounding (&spot); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilLowerToFloor: + case DCeiling::ceilLowerToFloor: targheight = sec->FindHighestFloorPoint (&spot); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseToFloor: // [RH] What's this for? + case DCeiling::ceilRaiseToFloor: // [RH] What's this for? targheight = sec->FindHighestFloorPoint (&spot); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; - case ceilLowerToHighest: + case DCeiling::ceilLowerToHighest: targheight = sec->FindHighestCeilingSurrounding (&spot); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilLowerByTexture: + case DCeiling::ceilLowerByTexture: targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround (); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; - case ceilRaiseByTexture: + case DCeiling::ceilRaiseByTexture: targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround (); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; @@ -426,9 +426,9 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, //jff 5/23/98 find model with floor at target height if target //is a floor type modelsec = (/*type == ceilRaiseToHighest ||*/ - type == ceilRaiseToFloor || + type == DCeiling::ceilRaiseToFloor || /*type == ceilLowerToHighest ||*/ - type == ceilLowerToFloor) ? + type == DCeiling::ceilLowerToFloor) ? sec->FindModelFloorSector (targheight) : sec->FindModelCeilingSector (targheight); if (modelsec != NULL) @@ -438,14 +438,14 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, { case 1: // type is zeroed ceiling->m_NewSpecial.Clear(); - ceiling->m_Type = genCeilingChg0; + ceiling->m_Type = DCeiling::genCeilingChg0; break; case 2: // type is copied sec->GetSpecial(&ceiling->m_NewSpecial); - ceiling->m_Type = genCeilingChgT; + ceiling->m_Type = DCeiling::genCeilingChgT; break; case 3: // type is left alone - ceiling->m_Type = genCeilingChg; + ceiling->m_Type = DCeiling::genCeilingChg; break; } } @@ -457,21 +457,21 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, { case 1: // type is zeroed ceiling->m_NewSpecial.Clear(); - ceiling->m_Type = genCeilingChg0; + ceiling->m_Type = DCeiling::genCeilingChg0; break; case 2: // type is copied line->frontsector->GetSpecial(&ceiling->m_NewSpecial); - ceiling->m_Type = genCeilingChgT; + ceiling->m_Type = DCeiling::genCeilingChgT; break; case 3: // type is left alone - ceiling->m_Type = genCeilingChg; + ceiling->m_Type = DCeiling::genCeilingChg; break; } } } ceiling->PlayCeilingSound (); - return ceiling; + return ceiling != NULL; } //============================================================================ @@ -502,7 +502,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, // [RH] Hack to let manual crushers be retriggerable, too tag ^= secnum | 0x1000000; P_ActivateInStasisCeiling (tag); - return !!DCeiling::Create(sec, type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); + return P_CreateCeiling(sec, type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); } // Reactivate in-stasis ceilings...for certain types. @@ -516,7 +516,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, FSectorTagIterator it(tag); while ((secnum = it.Next()) >= 0) { - rtn |= !!DCeiling::Create(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); + rtn |= P_CreateCeiling(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); } return rtn; } diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 7dc0f6e6e..94c294d2a 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -271,6 +271,244 @@ DFloor::DFloor (sector_t *sec) { } +//========================================================================== +// +// +// +//========================================================================== + +bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, + double speed, double height, int crush, int change, bool hexencrush, bool hereticlower) +{ + bool rtn; + DFloor* floor; + double ceilingheight; + double newheight; + vertex_t *spot, *spot2; + + // ALREADY MOVING? IF SO, KEEP GOING... + if (sec->PlaneMoving(sector_t::floor)) + { + return false; + } + + // new floor thinker + rtn = true; + floor = new DFloor(sec); + floor->m_Type = floortype; + floor->m_Crush = crush; + floor->m_Hexencrush = hexencrush; + floor->m_Speed = speed; + floor->m_ResetCount = 0; // [RH] + floor->m_OrgDist = sec->floorplane.fD(); // [RH] + + switch (floortype) + { + case DFloor::floorLowerToHighest: + floor->m_Direction = -1; + newheight = sec->FindHighestFloorSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + // [RH] DOOM's turboLower type did this. I've just extended it + // to be applicable to all LowerToHighest types. + if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD()) + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight + height); + break; + + case DFloor::floorLowerToLowest: + floor->m_Direction = -1; + newheight = sec->FindLowestFloorSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorLowerToNearest: + //jff 02/03/30 support lowering floor to next lowest floor + floor->m_Direction = -1; + newheight = sec->FindNextLowestFloor(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorLowerInstant: + floor->m_Speed = height; + case DFloor::floorLowerByValue: + floor->m_Direction = -1; + newheight = sec->CenterFloor() - height; + floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); + break; + + case DFloor::floorRaiseInstant: + floor->m_Speed = height; + case DFloor::floorRaiseByValue: + floor->m_Direction = 1; + newheight = sec->CenterFloor() + height; + floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); + break; + + case DFloor::floorMoveToValue: + sec->FindHighestFloorPoint(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, height); + floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1; + break; + + case DFloor::floorRaiseAndCrushDoom: + case DFloor::floorRaiseToLowestCeiling: + floor->m_Direction = 1; + newheight = sec->FindLowestCeilingSurrounding(&spot); + if (floortype == DFloor::floorRaiseAndCrushDoom) + newheight -= 8; + ceilingheight = sec->FindLowestCeilingPoint(&spot2); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight) + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot2, + floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight); + break; + + case DFloor::floorRaiseToHighest: + floor->m_Direction = 1; + newheight = sec->FindHighestFloorSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorRaiseToNearest: + floor->m_Direction = 1; + newheight = sec->FindNextHighestFloor(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorRaiseToLowest: + floor->m_Direction = 1; + newheight = sec->FindLowestFloorSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorRaiseAndCrush: + floor->m_Direction = 1; + newheight = sec->FindLowestCeilingPoint(&spot) - 8; + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorRaiseToCeiling: + floor->m_Direction = 1; + newheight = sec->FindLowestCeilingPoint(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorLowerToLowestCeiling: + floor->m_Direction = -1; + newheight = sec->FindLowestCeilingSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorLowerByTexture: + floor->m_Direction = -1; + newheight = sec->CenterFloor() - sec->FindShortestTextureAround(); + floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); + break; + + case DFloor::floorLowerToCeiling: + // [RH] Essentially instantly raises the floor to the ceiling + floor->m_Direction = -1; + newheight = sec->FindLowestCeilingPoint(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + break; + + case DFloor::floorRaiseByTexture: + floor->m_Direction = 1; + // [RH] Use P_FindShortestTextureAround from BOOM to do this + // since the code is identical to what was here. (Oddly + // enough, BOOM preserved the code here even though it + // also had this function.) + newheight = sec->CenterFloor() + sec->FindShortestTextureAround(); + floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); + break; + + case DFloor::floorRaiseAndChange: + floor->m_Direction = 1; + newheight = sec->CenterFloor() + height; + floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); + if (line != NULL) + { + FTextureID oldpic = sec->GetTexture(sector_t::floor); + sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor)); + sec->TransferSpecial(line->frontsector); + } + else + { + sec->ClearSpecial(); + } + break; + + case DFloor::floorLowerAndChange: + floor->m_Direction = -1; + newheight = sec->FindLowestFloorSurrounding(&spot); + floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); + floor->m_Texture = sec->GetTexture(sector_t::floor); + // jff 1/24/98 make sure floor->m_NewSpecial gets initialized + // in case no surrounding sector is at floordestheight + sec->GetSpecial(&floor->m_NewSpecial); + + //jff 5/23/98 use model subroutine to unify fixes and handling + sector_t *modelsec; + modelsec = sec->FindModelFloorSector(newheight); + if (modelsec != NULL) + { + floor->m_Texture = modelsec->GetTexture(sector_t::floor); + modelsec->GetSpecial(&floor->m_NewSpecial); + } + break; + + default: + break; + } + + // Do not interpolate instant movement floors. + bool silent = false; + + if ((floor->m_Direction > 0 && floor->m_FloorDestDist > sec->floorplane.fD()) || // moving up but going down + (floor->m_Direction < 0 && floor->m_FloorDestDist < sec->floorplane.fD()) || // moving down but going up + (floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step + { + floor->StopInterpolation(true); + + // [Graf Zahl] + // Don't make sounds for instant movement hacks but make an exception for + // switches that activate their own back side. + if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS)) + { + if (!line || !(line->activation & (SPAC_Use | SPAC_Push)) || line->backsector != sec) + silent = true; + } + } + if (!silent) floor->StartFloorSound(); + + if (change & 3) + { + // [RH] Need to do some transferring + if (change & 4) + { + // Numeric model change + sector_t *modelsec; + + modelsec = (floortype == DFloor::floorRaiseToLowestCeiling || + floortype == DFloor::floorLowerToLowestCeiling || + floortype == DFloor::floorRaiseToCeiling || + floortype == DFloor::floorLowerToCeiling) ? + sec->FindModelCeilingSector(-floor->m_FloorDestDist) : + sec->FindModelFloorSector(-floor->m_FloorDestDist); + + if (modelsec != NULL) + { + floor->SetFloorChangeType(modelsec, change); + } + } + else if (line) + { + // Trigger model change + floor->SetFloorChangeType(line->frontsector, change); + } + } + return true; +} + //========================================================================== // // HANDLE FLOOR TYPES @@ -283,241 +521,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, double speed, double height, int crush, int change, bool hexencrush, bool hereticlower) { int secnum; - bool rtn; - sector_t* sec; - DFloor* floor; - double ceilingheight; - double newheight; - vertex_t *spot, *spot2; - - rtn = false; + bool rtn = false; // check if a manual trigger; if so do just the sector on the backside FSectorTagIterator it(tag, line); while ((secnum = it.Next()) >= 0) { - sec = §ors[secnum]; - // ALREADY MOVING? IF SO, KEEP GOING... - if (sec->PlaneMoving(sector_t::floor)) - { - continue; - } - - - // new floor thinker - rtn = true; - floor = new DFloor (sec); - floor->m_Type = floortype; - floor->m_Crush = crush; - floor->m_Hexencrush = hexencrush; - floor->m_Speed = speed; - floor->m_ResetCount = 0; // [RH] - floor->m_OrgDist = sec->floorplane.fD(); // [RH] - - switch (floortype) - { - case DFloor::floorLowerToHighest: - floor->m_Direction = -1; - newheight = sec->FindHighestFloorSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - // [RH] DOOM's turboLower type did this. I've just extended it - // to be applicable to all LowerToHighest types. - if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD()) - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight+height); - break; - - case DFloor::floorLowerToLowest: - floor->m_Direction = -1; - newheight = sec->FindLowestFloorSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorLowerToNearest: - //jff 02/03/30 support lowering floor to next lowest floor - floor->m_Direction = -1; - newheight = sec->FindNextLowestFloor (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorLowerInstant: - floor->m_Speed = height; - case DFloor::floorLowerByValue: - floor->m_Direction = -1; - newheight = sec->CenterFloor() - height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); - break; - - case DFloor::floorRaiseInstant: - floor->m_Speed = height; - case DFloor::floorRaiseByValue: - floor->m_Direction = 1; - newheight = sec->CenterFloor() + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); - break; - - case DFloor::floorMoveToValue: - sec->FindHighestFloorPoint (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, height); - floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1; - break; - - case DFloor::floorRaiseAndCrushDoom: - case DFloor::floorRaiseToLowestCeiling: - floor->m_Direction = 1; - newheight = sec->FindLowestCeilingSurrounding (&spot); - if (floortype == DFloor::floorRaiseAndCrushDoom) - newheight -= 8; - ceilingheight = sec->FindLowestCeilingPoint (&spot2); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - if (sec->floorplane.ZatPointDist (spot2, floor->m_FloorDestDist) > ceilingheight) - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot2, - floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight); - break; - - case DFloor::floorRaiseToHighest: - floor->m_Direction = 1; - newheight = sec->FindHighestFloorSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorRaiseToNearest: - floor->m_Direction = 1; - newheight = sec->FindNextHighestFloor (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorRaiseToLowest: - floor->m_Direction = 1; - newheight = sec->FindLowestFloorSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorRaiseAndCrush: - floor->m_Direction = 1; - newheight = sec->FindLowestCeilingPoint (&spot) - 8; - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorRaiseToCeiling: - floor->m_Direction = 1; - newheight = sec->FindLowestCeilingPoint (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorLowerToLowestCeiling: - floor->m_Direction = -1; - newheight = sec->FindLowestCeilingSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorLowerByTexture: - floor->m_Direction = -1; - newheight = sec->CenterFloor() - sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); - break; - - case DFloor::floorLowerToCeiling: - // [RH] Essentially instantly raises the floor to the ceiling - floor->m_Direction = -1; - newheight = sec->FindLowestCeilingPoint (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - break; - - case DFloor::floorRaiseByTexture: - floor->m_Direction = 1; - // [RH] Use P_FindShortestTextureAround from BOOM to do this - // since the code is identical to what was here. (Oddly - // enough, BOOM preserved the code here even though it - // also had this function.) - newheight = sec->CenterFloor() + sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); - break; - - case DFloor::floorRaiseAndChange: - floor->m_Direction = 1; - newheight = sec->CenterFloor() + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); - if (line != NULL) - { - FTextureID oldpic = sec->GetTexture(sector_t::floor); - sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor)); - sec->TransferSpecial(line->frontsector); - } - else - { - sec->ClearSpecial(); - } - break; - - case DFloor::floorLowerAndChange: - floor->m_Direction = -1; - newheight = sec->FindLowestFloorSurrounding (&spot); - floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); - floor->m_Texture = sec->GetTexture(sector_t::floor); - // jff 1/24/98 make sure floor->m_NewSpecial gets initialized - // in case no surrounding sector is at floordestheight - sec->GetSpecial(&floor->m_NewSpecial); - - //jff 5/23/98 use model subroutine to unify fixes and handling - sector_t *modelsec; - modelsec = sec->FindModelFloorSector (newheight); - if (modelsec != NULL) - { - floor->m_Texture = modelsec->GetTexture(sector_t::floor); - modelsec->GetSpecial(&floor->m_NewSpecial); - } - break; - - default: - break; - } - - // Do not interpolate instant movement floors. - bool silent = false; - - if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.fD()) || // moving up but going down - (floor->m_Direction<0 && floor->m_FloorDestDistfloorplane.fD()) || // moving down but going up - (floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step - { - floor->StopInterpolation(true); - - // [Graf Zahl] - // Don't make sounds for instant movement hacks but make an exception for - // switches that activate their own back side. - if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS)) - { - if (!line || !(line->activation & (SPAC_Use|SPAC_Push)) || line->backsector!=sec) - silent = true; - } - } - if (!silent) floor->StartFloorSound (); - - if (change & 3) - { - // [RH] Need to do some transferring - if (change & 4) - { - // Numeric model change - sector_t *modelsec; - - modelsec = (floortype == DFloor::floorRaiseToLowestCeiling || - floortype == DFloor::floorLowerToLowestCeiling || - floortype == DFloor::floorRaiseToCeiling || - floortype == DFloor::floorLowerToCeiling) ? - sec->FindModelCeilingSector (-floor->m_FloorDestDist) : - sec->FindModelFloorSector (-floor->m_FloorDestDist); - - if (modelsec != NULL) - { - floor->SetFloorChangeType (modelsec, change); - } - } - else if (line) - { - // Trigger model change - floor->SetFloorChangeType (line->frontsector, change); - } - } + rtn |= P_CreateFloor(§ors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower); } return rtn; } diff --git a/src/p_spec.h b/src/p_spec.h index 409831943..75a181420 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -572,10 +572,6 @@ public: void Serialize (FArchive &arc); void Tick (); - static DCeiling *Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, - double speed, double speed2, double height, - int crush, int silent, int change, ECrushMode hexencrush); - protected: ECeiling m_Type; double m_BottomHeight; @@ -601,13 +597,13 @@ protected: private: DCeiling (); + friend bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush); friend bool EV_CeilingCrushStop (int tag); friend void P_ActivateInStasisCeiling (int tag); }; -bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, - int tag, double speed, double speed2, double height, - int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom); +bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush); +bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom); bool EV_CeilingCrushStop (int tag); void P_ActivateInStasisCeiling (int tag); @@ -711,6 +707,9 @@ private: DFloor (); }; +bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, + double speed, double height, int crush, int change, bool hexencrush, bool hereticlower); + bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, double stairsize, double speed, int delay, int reset, int igntxt, int usespecials); From ca317a87ea71345a7f404a10d435d8cd1f221758 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 12:09:06 +0200 Subject: [PATCH 6/7] - started working on tracking portal transitions for railgun shots. --- src/p_map.cpp | 20 +++++++++++++++++++- src/p_trace.cpp | 50 ++++++++++++++++++++++++++++++++++++++++--------- src/p_trace.h | 4 +++- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 5d5777d6f..61e651ce6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4463,10 +4463,17 @@ struct SRailHit DVector3 HitPos; DAngle HitAngle; }; +struct SPortalHit +{ + DVector3 HitPos; + DVector3 ContPos; + DVector3 OutDir; +}; struct RailData { AActor *Caller; TArray RailHits; + TArray PortalHits; bool StopAtOne; bool StopAtInvul; bool ThruSpecies; @@ -4475,6 +4482,16 @@ struct RailData static ETraceStatus ProcessRailHit(FTraceResults &res, void *userdata) { RailData *data = (RailData *)userdata; + if (res.HitType == TRACE_CrossingPortal) + { + SPortalHit newhit; + newhit.HitPos = res.HitPos; + newhit.ContPos = res.SrcFromTarget; + newhit.OutDir = res.HitVector; + data->PortalHits.Push(newhit); + return TRACE_Continue; + } + if (res.HitType != TRACE_HitActor) { return TRACE_Stop; @@ -4559,7 +4576,8 @@ void P_RailAttack(FRailParams *p) assert(puffclass != NULL); // Because we set it to a default above AActor *puffDefaults = GetDefaultByType(puffclass->GetReplacement()); //Contains all the flags such as FOILINVUL, etc. - flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0 : TRACE_PCross | TRACE_Impact; + // disabled because not complete yet. + flags = (puffDefaults->flags6 & MF6_NOTRIGGER) ? 0/*TRACE_ReportPortals*/ : TRACE_PCross | TRACE_Impact /*| TRACE_ReportPortals*/; rail_data.StopAtInvul = (puffDefaults->flags3 & MF3_FOILINVUL) ? false : true; rail_data.ThruSpecies = (puffDefaults->flags6 & MF6_MTHRUSPECIES) ? true : false; Trace(start, source->Sector, vec, p->distance, MF_SHOOTABLE, ML_BLOCKEVERYTHING, source, trace, flags, ProcessRailHit, &rail_data); diff --git a/src/p_trace.cpp b/src/p_trace.cpp index dabc92110..7526456e1 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -66,6 +66,8 @@ struct FTraceInfo double startfrac; int aimdir; double limitz; + double lastfloorportalheight; + double lastceilingportalheight; // These are required for 3D-floor checking // to create a fake sector with a floor @@ -141,6 +143,7 @@ bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, d inf.sectorsel=0; inf.aimdir = -1; inf.startfrac = 0; + inf.lastfloorportalheight = inf.lastceilingportalheight = start.Z; memset(&res, 0, sizeof(res)); if (inf.TraceTraverse (ptflags)) @@ -196,6 +199,7 @@ void FTraceInfo::EnterSectorPortal(int position, double frac, sector_t *entersec newtrace.aimdir = position; newtrace.limitz = portal->specialf1; newtrace.sectorsel = 0; + newtrace.lastfloorportalheight = newtrace.lastceilingportalheight = limitz; if (newtrace.TraceTraverse(ActorMask ? PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE : PT_ADDLINES)) { @@ -227,7 +231,7 @@ int FTraceInfo::EnterLinePortal(line_t *li, double frac) frac += 1 / MaxDist; double enterdist = MaxDist / frac; - DVector2 enter = newtrace.Start.XY() + enterdist * Vec.XY(); + DVector2 enter = newtrace.Start + enterdist * Vec; newtrace.ActorMask = ActorMask; newtrace.WallMask = WallMask; @@ -244,7 +248,9 @@ int FTraceInfo::EnterLinePortal(line_t *li, double frac) newtrace.startfrac = frac; newtrace.aimdir = aimdir; newtrace.limitz = limitz; + P_TranslatePortalZ(li, newtrace.limitz); + newtrace.lastfloorportalheight = newtrace.lastceilingportalheight = newtrace.limitz; newtrace.sectorsel = 0; Results->unlinked = true; return newtrace.TraceTraverse(ActorMask ? PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE : PT_ADDLINES); @@ -442,11 +448,24 @@ bool FTraceInfo::LineCheck(intercept_t *in) Results->HitType = TRACE_HitFloor; Results->HitTexture = CurSector->GetTexture(sector_t::floor); } - else if (entersector == NULL || entersector->PortalBlocksMovement(sector_t::floor)) + else { - // hit beyond a portal plane. This needs to be taken care of by the trace spawned on the other side. - Results->HitType = TRACE_HitNone; - return false; + if ((TraceFlags & TRACE_ReportPortals) && lastfloorportalheight > fc) + { + lastfloorportalheight = fc; + if (TraceCallback != NULL) + { + // Todo: calculate the intersection point. + Results->HitType = TRACE_CrossingPortal; + TraceCallback(*Results, TraceCallbackData); + } + } + if (entersector == NULL || entersector->PortalBlocksMovement(sector_t::floor)) + { + // hit beyond a portal plane. This needs to be taken care of by the trace spawned on the other side. + Results->HitType = TRACE_HitNone; + return false; + } } } else if (hit.Z >= fc) @@ -457,11 +476,24 @@ bool FTraceInfo::LineCheck(intercept_t *in) Results->HitType = TRACE_HitCeiling; Results->HitTexture = CurSector->GetTexture(sector_t::ceiling); } - else if (entersector == NULL || entersector->PortalBlocksMovement(sector_t::ceiling)) + else { - // hit beyond a portal plane. This needs to be taken care of by the trace spawned on the other side. - Results->HitType = TRACE_HitNone; - return false; + if ((TraceFlags & TRACE_ReportPortals) && lastceilingportalheight < fc) + { + lastceilingportalheight = fc; + if (TraceCallback != NULL) + { + // Todo: calculate the intersection point. + Results->HitType = TRACE_CrossingPortal; + TraceCallback(*Results, TraceCallbackData); + } + } + if (entersector == NULL || entersector->PortalBlocksMovement(sector_t::ceiling)) + { + // hit beyond a portal plane. This needs to be taken care of by the trace spawned on the other side. + Results->HitType = TRACE_HitNone; + return false; + } } } else if (in->d.line->isLinePortal()) diff --git a/src/p_trace.h b/src/p_trace.h index 2c817816e..7eaf50ce5 100644 --- a/src/p_trace.h +++ b/src/p_trace.h @@ -50,7 +50,8 @@ enum ETraceResult TRACE_HitFloor, TRACE_HitCeiling, TRACE_HitWall, - TRACE_HitActor + TRACE_HitActor, + TRACE_CrossingPortal, }; enum @@ -113,6 +114,7 @@ enum TRACE_PCross = 2, // Trigger SPAC_PCROSS lines TRACE_Impact = 4, // Trigger SPAC_IMPACT lines TRACE_PortalRestrict= 8, // Cannot go through portals without a static link offset. + TRACE_ReportPortals = 16, // Report any portal crossing to the TraceCallback }; // return values from callback From 43dd75985900132931cdb62b724124e610d41299 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 Apr 2016 12:55:12 +0200 Subject: [PATCH 7/7] - changed DrawTexture so that the parameters get parsed in the varargs function directly and that the virtual function that is getting called gets the fully prepared data. In order to avoid passing around tag lists, DrawTextV needs to parse everything itself and then pass a fully initialized structure to DrawTexture. This cannot be done if all variants require a varargs tag list. Apparently the only reason for the old approach was the 'hw' parameter which was never used. --- src/v_draw.cpp | 23 +++++++------ src/v_video.h | 73 +++++++++++++++++++++--------------------- src/win32/fb_d3d9.cpp | 9 ++---- src/win32/win32iface.h | 4 +-- 4 files changed, 55 insertions(+), 54 deletions(-) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 55ea7b871..2338c998f 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -110,23 +110,22 @@ void STACK_ARGS DCanvas::DrawTexture (FTexture *img, double x, double y, int tag { va_list tags; va_start(tags, tags_first); - DrawTextureV(img, x, y, tags_first, tags); + DrawParms parms; + + if (!ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, false)) + { + return; + } + DrawTextureParms(img, x, y, parms); } -void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) +void DCanvas::DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms) { #ifndef NO_SWRENDER FTexture::Span unmaskedSpan[2]; const FTexture::Span **spanptr, *spans; static short bottomclipper[MAXWIDTH], topclipper[MAXWIDTH]; - DrawParms parms; - - if (!ParseDrawTextureTags(img, x, y, tag, tags, &parms, false)) - { - return; - } - if (parms.masked) { spanptr = &spans; @@ -171,6 +170,10 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 BYTE *destorgsave = dc_destorg; dc_destorg = screen->GetBuffer(); + if (dc_destorg == NULL) + { + I_FatalError("Attempt to write to buffer of hardware canvas"); + } double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth; double y0 = parms.y - parms.top * parms.destheight / parms.texheight; @@ -327,7 +330,7 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 #endif } -bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool hw) const +bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool fortext) const { INTBOOL boolval; int intval; diff --git a/src/v_video.h b/src/v_video.h index 533adb52e..dbb4f5589 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -138,6 +138,40 @@ struct FRemapTable; class player_t; typedef uint32 angle_t; +struct DrawParms +{ + double x, y; + double texwidth; + double texheight; + double destwidth; + double destheight; + double virtWidth; + double virtHeight; + double windowleft; + double windowright; + int dclip; + int uclip; + int lclip; + int rclip; + double top; + double left; + float Alpha; + uint32 fillcolor; + FRemapTable *remap; + const BYTE *translation; + uint32 colorOverlay; + INTBOOL alphaChannel; + INTBOOL flipX; + fixed_t shadowAlpha; + int shadowColor; + INTBOOL keepratio; + INTBOOL masked; + INTBOOL bilinear; + FRenderStyle style; + struct FSpecialColormap *specialcolormap; + struct FColormapStyle *colormapstyle; +}; + // // VIDEO // @@ -223,40 +257,6 @@ public: void DrawTextV (FFont *font, int normalcolor, int x, int y, const char *string, va_list tags); void STACK_ARGS DrawChar (FFont *font, int normalcolor, int x, int y, BYTE character, ...); - struct DrawParms - { - double x, y; - double texwidth; - double texheight; - double destwidth; - double destheight; - double virtWidth; - double virtHeight; - double windowleft; - double windowright; - int dclip; - int uclip; - int lclip; - int rclip; - double top; - double left; - float Alpha; - uint32 fillcolor; - FRemapTable *remap; - const BYTE *translation; - uint32 colorOverlay; - INTBOOL alphaChannel; - INTBOOL flipX; - fixed_t shadowAlpha; - int shadowColor; - INTBOOL keepratio; - INTBOOL masked; - INTBOOL bilinear; - FRenderStyle style; - struct FSpecialColormap *specialcolormap; - struct FColormapStyle *colormapstyle; - }; - protected: BYTE *Buffer; int Width; @@ -265,8 +265,9 @@ protected: int LockCount; bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const; - virtual void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags); - bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const; + void DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags) = delete; + virtual void DrawTextureParms(FTexture *img, double x, double y, DrawParms &parms); + bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool fortext) const; DCanvas() {} diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 7ec394d52..c0a0dca57 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -2762,17 +2762,14 @@ void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color) // //========================================================================== -void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, double x, double y, uint32 tags_first, va_list tags) +void D3DFB::DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms) { if (In2D < 2) { - Super::DrawTextureV(img, x, y, tags_first, tags); + Super::DrawTextureParms(img, x, y, parms); return; } - - DrawParms parms; - - if (!InScene || !ParseDrawTextureTags(img, x, y, tags_first, tags, &parms, true)) + if (!InScene) { return; } diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index f8fcd1fba..ac2ad33a6 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -257,7 +257,7 @@ public: void DrawBlendingRect (); FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping); FNativePalette *CreatePalette (FRemapTable *remap); - void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags); + void DrawTextureParms (FTexture *img, double x, double y, DrawParms &parms); void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color); void Dim (PalEntry color, float amount, int x1, int y1, int w, int h); void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin); @@ -370,7 +370,7 @@ private: void DrawPackedTextures(int packnum); void DrawLetterbox(); void Draw3DPart(bool copy3d); - bool SetStyle(D3DTex *tex, DCanvas::DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad); + bool SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1, BufferedTris &quad); static D3DBLEND GetStyleAlpha(int type); static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1); void DoWindowedGamma();