- one third of slidor.cpp

This commit is contained in:
Christoph Oelckers 2021-11-02 22:37:33 +01:00
parent dfc557e0ec
commit 2397e4c2a5
4 changed files with 34 additions and 54 deletions

View file

@ -71,13 +71,13 @@ inline constexpr int TEXT_INFO_LINE(int line) { return (TEXT_INFO_Y + ((line)*TE
void PutStringInfo(PLAYERp pp, const char* string);
short DoSlidorMatch(PLAYERp pp, short match, bool);
void DoSlidorMatch(PLAYERp pp, short match, bool);
bool TestSlidorMatchActive(short match);
void InterpSectorSprites(short sectnum, bool state);
using INTERP_FUNC = void(*)(int, int);
void SetSlidorActive(short SpriteNum);
void SetSlidorActive(DSWActor*);
void DoSlidorInterp(short, INTERP_FUNC);
int DoBeginJump(DSWActor* actor);

View file

@ -73,8 +73,8 @@ short DoVatorOperate(PLAYERp, short);
short DoVatorMatch(PLAYERp pp, short match);
void DoRotatorOperate(PLAYERp, short);
void DoRotatorMatch(PLAYERp pp, short match, bool);
short DoSlidorOperate(PLAYERp, short);
short DoSlidorMatch(PLAYERp pp, short match, bool);
void DoSlidorOperate(PLAYERp, short);
void DoSlidorMatch(PLAYERp pp, short match, bool);
void KillMatchingCrackSprites(short match);
int DoTrapReset(short match);

View file

@ -39,9 +39,9 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
void ReverseSlidor(short SpriteNum)
void ReverseSlidor(DSWActor* actor)
{
USERp u = User[SpriteNum].Data();
USERp u = actor->u();
ROTATORp r;
r = u->rotator.Data();
@ -50,7 +50,7 @@ void ReverseSlidor(short SpriteNum)
if (u->Tics)
{
u->Tics = 0;
SetSlidorActive(SpriteNum);
SetSlidorActive(actor);
return;
}
@ -68,17 +68,15 @@ void ReverseSlidor(short SpriteNum)
}
bool
SlidorSwitch(short match, short setting)
bool SlidorSwitch(short match, short setting)
{
SPRITEp sp;
int i;
bool found = false;
StatIterator it(STAT_DEFAULT);
while ((i = it.NextIndex()) >= 0)
SWStatIterator it(STAT_DEFAULT);
while (auto actor = it.Next())
{
sp = &sprite[i];
sp = &actor->s();
if (sp->lotag == TAG_SPRITE_SWITCH_VATOR && sp->hitag == match)
{
@ -90,15 +88,15 @@ SlidorSwitch(short match, short setting)
return found;
}
void SetSlidorActive(short SpriteNum)
void SetSlidorActive(DSWActor* actor)
{
USERp u = User[SpriteNum].Data();
SPRITEp sp = u->SpriteP;
USERp u = actor->u();
SPRITEp sp = &actor->s();
ROTATORp r;
r = u->rotator.Data();
DoSlidorInterp(SpriteNum, StartInterpolation);
DoSlidorInterp(actor->GetSpriteIndex(), StartInterpolation);
// play activate sound
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
@ -127,7 +125,7 @@ void SetSlidorInactive(short SpriteNum)
}
// called for operation from the space bar
short DoSlidorOperate(PLAYERp pp, short sectnum)
void DoSlidorOperate(PLAYERp pp, short sectnum)
{
short match;
@ -136,37 +134,27 @@ short DoSlidorOperate(PLAYERp pp, short sectnum)
if (match > 0)
{
if (TestSlidorMatchActive(match))
return -1;
else
return DoSlidorMatch(pp, match, true);
if (!TestSlidorMatchActive(match))
DoSlidorMatch(pp, match, true);
}
return -1;
}
// called from switches and triggers
// returns first vator found
short
DoSlidorMatch(PLAYERp pp, short match, bool manual)
void DoSlidorMatch(PLAYERp pp, short match, bool manual)
{
USERp fu;
SPRITEp fsp;
short sectnum;
short first_vator = -1;
int i;
//SlidorSwitch(match, ON);
StatIterator it(STAT_SLIDOR);
while ((i = it.NextIndex()) >= 0)
SWStatIterator it(STAT_SLIDOR);
while (auto actor = it.Next())
{
fsp = &sprite[i];
fsp = &actor->s();
if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match)
{
fu = User[i].Data();
fu = actor->u();
// single play only vator
// bool 8 must be set for message to display
@ -184,9 +172,6 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual)
continue;
}
if (first_vator == -1)
first_vator = i;
sectnum = fsp->sectnum;
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
@ -197,40 +182,35 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual)
{
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));
return -1;
return;
}
}
if (TEST(fu->Flags, SPR_ACTIVE))
{
ReverseSlidor(i);
ReverseSlidor(actor);
continue;
}
SetSlidorActive(i);
SetSlidorActive(actor);
}
}
return first_vator;
}
bool
TestSlidorMatchActive(short match)
bool TestSlidorMatchActive(short match)
{
USERp fu;
SPRITEp fsp;
int i;
StatIterator it(STAT_SLIDOR);
while ((i = it.NextIndex()) >= 0)
SWStatIterator it(STAT_SLIDOR);
while (auto actor = it.Next())
{
fsp = &sprite[i];
fsp = &actor->s();
if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match)
{
fu = User[i].Data();
fu = actor->u();
// Does not have to be inactive to be operated
if (TEST_BOOL6(fsp))
@ -625,7 +605,7 @@ int DoSlidorMove(short SpriteNum)
if (bu && TEST(bsp->cstat, CSTAT_SPRITE_BLOCK) && TEST(bsp->extra, SPRX_PLAYER_OR_ENEMY))
{
// found something blocking so reverse to ON position
ReverseSlidor(SpriteNum);
ReverseSlidor(actor);
SET_BOOL8(sp); // tell vator that something blocking door
found = true;
break;
@ -644,7 +624,7 @@ int DoSlidorMove(short SpriteNum)
if (pp->lo_sectp == &sector[sp->sectnum] ||
pp->hi_sectp == &sector[sp->sectnum])
{
ReverseSlidor(SpriteNum);
ReverseSlidor(actor);
u->vel_rate = -u->vel_rate;
found = true;

View file

@ -6836,7 +6836,7 @@ SpriteControl(void)
if (u->Tics)
{
if ((u->Tics -= synctics) <= 0)
SetSlidorActive(i);
SetSlidorActive(actor);
else
continue;
}