@@ -59,7 +59,7 @@ class DActiveButton : public DThinker
59
59
DECLARE_CLASS (DActiveButton, DThinker)
60
60
public:
61
61
DActiveButton ();
62
- DActiveButton (side_t *, int , FSwitchDef *, fixed_t x, fixed_t y , bool flippable);
62
+ DActiveButton (side_t *, int , FSwitchDef *, const DVector2 &pos , bool flippable);
63
63
64
64
void Serialize (FArchive &arc);
65
65
void Tick ();
@@ -71,7 +71,7 @@ class DActiveButton : public DThinker
71
71
FSwitchDef *m_SwitchDef;
72
72
SDWORD m_Frame;
73
73
DWORD m_Timer;
74
- fixed_t m_X, m_Y; // Location of timer sound
74
+ DVector2 m_Pos;
75
75
76
76
protected:
77
77
bool AdvanceFrame ();
@@ -85,7 +85,7 @@ class DActiveButton : public DThinker
85
85
//
86
86
// ==========================================================================
87
87
88
- static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t x, fixed_t y , bool useagain)
88
+ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos , bool useagain)
89
89
{
90
90
DActiveButton *button;
91
91
TThinkerIterator<DActiveButton> iterator;
@@ -100,7 +100,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t
100
100
}
101
101
}
102
102
103
- new DActiveButton (side, Where, Switch, x, y , useagain);
103
+ new DActiveButton (side, Where, Switch, pos , useagain);
104
104
return true ;
105
105
}
106
106
@@ -185,13 +185,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
185
185
// Check 3D floors on back side
186
186
{
187
187
sector_t * back = line->sidedef [1 - sideno]->sector ;
188
- for (unsigned i = 0 ; i < back->e ->XFloor .ffloors . Size (); i++ )
188
+ for (auto rover : back->e ->XFloor .ffloors )
189
189
{
190
- F3DFloor *rover = back->e ->XFloor .ffloors [i];
191
190
if (!(rover->flags & FF_EXISTS)) continue ;
192
191
if (!(rover->flags & FF_UPPERTEXTURE)) continue ;
193
192
194
- if (user->Z () > rover->top .plane ->ZatPoint (check) ||
193
+ if (user->isAbove ( rover->top .plane ->ZatPoint (check) ) ||
195
194
user->Top () < rover->bottom .plane ->ZatPoint (check))
196
195
continue ;
197
196
@@ -213,7 +212,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
213
212
if (!(rover->flags & FF_EXISTS)) continue ;
214
213
if (!(rover->flags & FF_LOWERTEXTURE)) continue ;
215
214
216
- if (user->Z () > rover->top .plane ->ZatPoint (check) ||
215
+ if (user->isAbove ( rover->top .plane ->ZatPoint (check) ) ||
217
216
user->Top () < rover->bottom .plane ->ZatPoint (check))
218
217
continue ;
219
218
@@ -230,12 +229,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
230
229
// to keep compatibility with Eternity's implementation.
231
230
if (!P_GetMidTexturePosition (line, sideno, &checktop, &checkbot))
232
231
return false ;
233
- return user->Z () < checktop && user->Top () > checkbot;
232
+ return user->isBelow ( checktop) && user->Top () > checkbot;
234
233
}
235
234
else
236
235
{
237
236
// no switch found. Check whether the player can touch either top or bottom texture
238
- return (user->Top () > open .top ) || (user->Z () < open .bottom );
237
+ return (user->Top () > open .top ) || (user->isBelow ( open .bottom ) );
239
238
}
240
239
}
241
240
@@ -292,24 +291,21 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques
292
291
// which wasn't necessarily anywhere near the switch if it was
293
292
// facing a big sector (and which wasn't necessarily for the
294
293
// button just activated, either).
295
- fixed_t pt[2 ];
296
- line_t *line = side->linedef ;
294
+ DVector2 pt (side->linedef ->v1 ->fPos () + side->linedef ->Delta () / 2 );
297
295
bool playsound;
298
296
299
- pt[0 ] = line->v1 ->x + (line->dx >> 1 );
300
- pt[1 ] = line->v1 ->y + (line->dy >> 1 );
301
297
side->SetTexture (texture, Switch->frames [0 ].Texture );
302
298
if (useAgain || Switch->NumFrames > 1 )
303
299
{
304
- playsound = P_StartButton (side, texture, Switch, pt[ 0 ], pt[ 1 ] , !!useAgain);
300
+ playsound = P_StartButton (side, texture, Switch, pt, !!useAgain);
305
301
}
306
302
else
307
303
{
308
304
playsound = true ;
309
305
}
310
306
if (playsound)
311
307
{
312
- S_Sound (DVector3 (FIXED2DBL (pt[ 0 ]), FIXED2DBL (pt[ 1 ]) , 0 ), CHAN_VOICE|CHAN_LISTENERZ, sound, 1 , ATTN_STATIC);
308
+ S_Sound (DVector3 (pt , 0 ), CHAN_VOICE|CHAN_LISTENERZ, sound, 1 , ATTN_STATIC);
313
309
}
314
310
if (quest != NULL )
315
311
{
@@ -332,20 +328,18 @@ DActiveButton::DActiveButton ()
332
328
m_Part = -1 ;
333
329
m_SwitchDef = 0 ;
334
330
m_Timer = 0 ;
335
- m_X = 0 ;
336
- m_Y = 0 ;
331
+ m_Pos = { 0 ,0 };
337
332
bFlippable = false ;
338
333
bReturning = false ;
339
334
m_Frame = 0 ;
340
335
}
341
336
342
337
DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
343
- fixed_t x, fixed_t y , bool useagain)
338
+ const DVector2 &pos , bool useagain)
344
339
{
345
340
m_Side = side;
346
341
m_Part = SBYTE (Where);
347
- m_X = x;
348
- m_Y = y;
342
+ m_Pos = pos;
349
343
bFlippable = useagain;
350
344
bReturning = false ;
351
345
@@ -363,7 +357,7 @@ DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
363
357
void DActiveButton::Serialize (FArchive &arc)
364
358
{
365
359
Super::Serialize (arc);
366
- arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_X << m_Y << bReturning;
360
+ arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_Pos << bReturning;
367
361
}
368
362
369
363
// ==========================================================================
@@ -391,7 +385,7 @@ void DActiveButton::Tick ()
391
385
if (def != NULL )
392
386
{
393
387
m_Frame = -1 ;
394
- S_Sound (DVector3 (FIXED2DBL (m_X), FIXED2DBL (m_Y) , 0 ), CHAN_VOICE|CHAN_LISTENERZ,
388
+ S_Sound (DVector3 (m_Pos , 0 ), CHAN_VOICE|CHAN_LISTENERZ,
395
389
def->Sound != 0 ? FSoundID (def->Sound ) : FSoundID (" switches/normbutn" ),
396
390
1 , ATTN_STATIC);
397
391
bFlippable = false ;
0 commit comments