mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
- one third of slidor.cpp
This commit is contained in:
parent
dfc557e0ec
commit
2397e4c2a5
4 changed files with 34 additions and 54 deletions
|
@ -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);
|
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);
|
bool TestSlidorMatchActive(short match);
|
||||||
void InterpSectorSprites(short sectnum, bool state);
|
void InterpSectorSprites(short sectnum, bool state);
|
||||||
|
|
||||||
using INTERP_FUNC = void(*)(int, int);
|
using INTERP_FUNC = void(*)(int, int);
|
||||||
|
|
||||||
void SetSlidorActive(short SpriteNum);
|
void SetSlidorActive(DSWActor*);
|
||||||
void DoSlidorInterp(short, INTERP_FUNC);
|
void DoSlidorInterp(short, INTERP_FUNC);
|
||||||
|
|
||||||
int DoBeginJump(DSWActor* actor);
|
int DoBeginJump(DSWActor* actor);
|
||||||
|
|
|
@ -73,8 +73,8 @@ short DoVatorOperate(PLAYERp, short);
|
||||||
short DoVatorMatch(PLAYERp pp, short match);
|
short DoVatorMatch(PLAYERp pp, short match);
|
||||||
void DoRotatorOperate(PLAYERp, short);
|
void DoRotatorOperate(PLAYERp, short);
|
||||||
void DoRotatorMatch(PLAYERp pp, short match, bool);
|
void DoRotatorMatch(PLAYERp pp, short match, bool);
|
||||||
short DoSlidorOperate(PLAYERp, short);
|
void DoSlidorOperate(PLAYERp, short);
|
||||||
short DoSlidorMatch(PLAYERp pp, short match, bool);
|
void DoSlidorMatch(PLAYERp pp, short match, bool);
|
||||||
|
|
||||||
void KillMatchingCrackSprites(short match);
|
void KillMatchingCrackSprites(short match);
|
||||||
int DoTrapReset(short match);
|
int DoTrapReset(short match);
|
||||||
|
|
|
@ -39,9 +39,9 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
|
|
||||||
BEGIN_SW_NS
|
BEGIN_SW_NS
|
||||||
|
|
||||||
void ReverseSlidor(short SpriteNum)
|
void ReverseSlidor(DSWActor* actor)
|
||||||
{
|
{
|
||||||
USERp u = User[SpriteNum].Data();
|
USERp u = actor->u();
|
||||||
ROTATORp r;
|
ROTATORp r;
|
||||||
|
|
||||||
r = u->rotator.Data();
|
r = u->rotator.Data();
|
||||||
|
@ -50,7 +50,7 @@ void ReverseSlidor(short SpriteNum)
|
||||||
if (u->Tics)
|
if (u->Tics)
|
||||||
{
|
{
|
||||||
u->Tics = 0;
|
u->Tics = 0;
|
||||||
SetSlidorActive(SpriteNum);
|
SetSlidorActive(actor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,17 +68,15 @@ void ReverseSlidor(short SpriteNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool SlidorSwitch(short match, short setting)
|
||||||
SlidorSwitch(short match, short setting)
|
|
||||||
{
|
{
|
||||||
SPRITEp sp;
|
SPRITEp sp;
|
||||||
int i;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
StatIterator it(STAT_DEFAULT);
|
SWStatIterator it(STAT_DEFAULT);
|
||||||
while ((i = it.NextIndex()) >= 0)
|
while (auto actor = it.Next())
|
||||||
{
|
{
|
||||||
sp = &sprite[i];
|
sp = &actor->s();
|
||||||
|
|
||||||
if (sp->lotag == TAG_SPRITE_SWITCH_VATOR && sp->hitag == match)
|
if (sp->lotag == TAG_SPRITE_SWITCH_VATOR && sp->hitag == match)
|
||||||
{
|
{
|
||||||
|
@ -90,15 +88,15 @@ SlidorSwitch(short match, short setting)
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSlidorActive(short SpriteNum)
|
void SetSlidorActive(DSWActor* actor)
|
||||||
{
|
{
|
||||||
USERp u = User[SpriteNum].Data();
|
USERp u = actor->u();
|
||||||
SPRITEp sp = u->SpriteP;
|
SPRITEp sp = &actor->s();
|
||||||
ROTATORp r;
|
ROTATORp r;
|
||||||
|
|
||||||
r = u->rotator.Data();
|
r = u->rotator.Data();
|
||||||
|
|
||||||
DoSlidorInterp(SpriteNum, StartInterpolation);
|
DoSlidorInterp(actor->GetSpriteIndex(), StartInterpolation);
|
||||||
|
|
||||||
// play activate sound
|
// play activate sound
|
||||||
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
|
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
|
||||||
|
@ -127,7 +125,7 @@ void SetSlidorInactive(short SpriteNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// called for operation from the space bar
|
// called for operation from the space bar
|
||||||
short DoSlidorOperate(PLAYERp pp, short sectnum)
|
void DoSlidorOperate(PLAYERp pp, short sectnum)
|
||||||
{
|
{
|
||||||
short match;
|
short match;
|
||||||
|
|
||||||
|
@ -136,37 +134,27 @@ short DoSlidorOperate(PLAYERp pp, short sectnum)
|
||||||
|
|
||||||
if (match > 0)
|
if (match > 0)
|
||||||
{
|
{
|
||||||
if (TestSlidorMatchActive(match))
|
if (!TestSlidorMatchActive(match))
|
||||||
return -1;
|
DoSlidorMatch(pp, match, true);
|
||||||
else
|
|
||||||
return DoSlidorMatch(pp, match, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from switches and triggers
|
// called from switches and triggers
|
||||||
// returns first vator found
|
// returns first vator found
|
||||||
short
|
void DoSlidorMatch(PLAYERp pp, short match, bool manual)
|
||||||
DoSlidorMatch(PLAYERp pp, short match, bool manual)
|
|
||||||
{
|
{
|
||||||
USERp fu;
|
USERp fu;
|
||||||
SPRITEp fsp;
|
SPRITEp fsp;
|
||||||
short sectnum;
|
short sectnum;
|
||||||
short first_vator = -1;
|
|
||||||
|
|
||||||
int i;
|
SWStatIterator it(STAT_SLIDOR);
|
||||||
|
while (auto actor = it.Next())
|
||||||
//SlidorSwitch(match, ON);
|
|
||||||
|
|
||||||
StatIterator it(STAT_SLIDOR);
|
|
||||||
while ((i = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
fsp = &sprite[i];
|
fsp = &actor->s();
|
||||||
|
|
||||||
if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match)
|
if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match)
|
||||||
{
|
{
|
||||||
fu = User[i].Data();
|
fu = actor->u();
|
||||||
|
|
||||||
// single play only vator
|
// single play only vator
|
||||||
// bool 8 must be set for message to display
|
// bool 8 must be set for message to display
|
||||||
|
@ -184,9 +172,6 @@ DoSlidorMatch(PLAYERp pp, short match, bool manual)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first_vator == -1)
|
|
||||||
first_vator = i;
|
|
||||||
|
|
||||||
sectnum = fsp->sectnum;
|
sectnum = fsp->sectnum;
|
||||||
|
|
||||||
if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number)
|
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));
|
PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1));
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TEST(fu->Flags, SPR_ACTIVE))
|
if (TEST(fu->Flags, SPR_ACTIVE))
|
||||||
{
|
{
|
||||||
ReverseSlidor(i);
|
ReverseSlidor(actor);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSlidorActive(i);
|
SetSlidorActive(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return first_vator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool TestSlidorMatchActive(short match)
|
||||||
TestSlidorMatchActive(short match)
|
|
||||||
{
|
{
|
||||||
USERp fu;
|
USERp fu;
|
||||||
SPRITEp fsp;
|
SPRITEp fsp;
|
||||||
|
|
||||||
int i;
|
SWStatIterator it(STAT_SLIDOR);
|
||||||
|
while (auto actor = it.Next())
|
||||||
StatIterator it(STAT_SLIDOR);
|
|
||||||
while ((i = it.NextIndex()) >= 0)
|
|
||||||
{
|
{
|
||||||
fsp = &sprite[i];
|
fsp = &actor->s();
|
||||||
|
|
||||||
if (SP_TAG1(fsp) == SECT_SLIDOR && SP_TAG2(fsp) == match)
|
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
|
// Does not have to be inactive to be operated
|
||||||
if (TEST_BOOL6(fsp))
|
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))
|
if (bu && TEST(bsp->cstat, CSTAT_SPRITE_BLOCK) && TEST(bsp->extra, SPRX_PLAYER_OR_ENEMY))
|
||||||
{
|
{
|
||||||
// found something blocking so reverse to ON position
|
// found something blocking so reverse to ON position
|
||||||
ReverseSlidor(SpriteNum);
|
ReverseSlidor(actor);
|
||||||
SET_BOOL8(sp); // tell vator that something blocking door
|
SET_BOOL8(sp); // tell vator that something blocking door
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -644,7 +624,7 @@ int DoSlidorMove(short SpriteNum)
|
||||||
if (pp->lo_sectp == §or[sp->sectnum] ||
|
if (pp->lo_sectp == §or[sp->sectnum] ||
|
||||||
pp->hi_sectp == §or[sp->sectnum])
|
pp->hi_sectp == §or[sp->sectnum])
|
||||||
{
|
{
|
||||||
ReverseSlidor(SpriteNum);
|
ReverseSlidor(actor);
|
||||||
|
|
||||||
u->vel_rate = -u->vel_rate;
|
u->vel_rate = -u->vel_rate;
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -6836,7 +6836,7 @@ SpriteControl(void)
|
||||||
if (u->Tics)
|
if (u->Tics)
|
||||||
{
|
{
|
||||||
if ((u->Tics -= synctics) <= 0)
|
if ((u->Tics -= synctics) <= 0)
|
||||||
SetSlidorActive(i);
|
SetSlidorActive(actor);
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue