- first half of rotator.cpp.

This commit is contained in:
Christoph Oelckers 2021-11-02 19:41:37 +01:00
parent 0a18edfdad
commit 1388794032
3 changed files with 23 additions and 27 deletions

View file

@ -2115,7 +2115,7 @@ int LoadGame(short save_num); // save.c
int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill); // save,c
void LoadGameDescr(short save_num, char *descr); // save.c
void SetRotatorActive(short SpriteNum); // rotator.c
void SetRotatorActive(DSWActor* actor); // rotator.c
bool VatorSwitch(short match, short setting); // vator.c
void MoveSpritesWithSector(short sectnum,int z_amt,bool type); // vator.c

View file

@ -45,9 +45,9 @@ void DoMatchEverything(PLAYERp pp, short match, short state);
void DoRotatorSetInterp(short SpriteNum);
void DoRotatorStopInterp(short SpriteNum);
void ReverseRotator(short SpriteNum)
void ReverseRotator(DSWActor* actor)
{
USERp u = User[SpriteNum].Data();
USERp u = actor->u();
ROTATORp r;
r = u->rotator.Data();
@ -56,7 +56,7 @@ void ReverseRotator(short SpriteNum)
if (u->Tics)
{
u->Tics = 0;
SetRotatorActive(SpriteNum);
SetRotatorActive(actor);
return;
}
@ -73,17 +73,15 @@ void ReverseRotator(short SpriteNum)
r->vel = -r->vel;
}
bool
RotatorSwitch(short match, short setting)
bool RotatorSwitch(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)
{
@ -95,15 +93,15 @@ RotatorSwitch(short match, short setting)
return found;
}
void SetRotatorActive(short SpriteNum)
void SetRotatorActive(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();
DoRotatorSetInterp(SpriteNum);
DoRotatorSetInterp(actor->GetSpriteIndex());
// play activate sound
DoSoundSpotMatch(SP_TAG2(sp), 1, SOUND_OBJECT_TYPE);
@ -157,20 +155,18 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual)
USERp fu;
SPRITEp fsp;
short sectnum;
short first_vator = -1;
int i;
DSWActor* firstVator = nullptr;
//RotatorSwitch(match, ON);
StatIterator it(STAT_ROTATOR);
while ((i = it.NextIndex()) >= 0)
SWStatIterator it(STAT_ROTATOR);
while (auto actor = it.Next())
{
fsp = &sprite[i];
fsp = &actor->s();
if (SP_TAG1(fsp) == SECT_ROTATOR && SP_TAG2(fsp) == match)
{
fu = User[i].Data();
fu = actor->u();
// single play only vator
// bool 8 must be set for message to display
@ -188,8 +184,8 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual)
continue;
}
if (first_vator == -1)
first_vator = i;
if (firstVator == nullptr)
firstVator = actor;
sectnum = fsp->sectnum;
@ -207,15 +203,15 @@ DoRotatorMatch(PLAYERp pp, short match, bool manual)
if (TEST(fu->Flags, SPR_ACTIVE))
{
ReverseRotator(i);
ReverseRotator(actor);
continue;
}
SetRotatorActive(i);
SetRotatorActive(actor);
}
}
return first_vator;
return firstVator->GetSpriteIndex();
}

View file

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