- switches

This commit is contained in:
Christoph Oelckers 2021-11-22 21:37:33 +01:00
parent ec12eb11f6
commit 5374dafb56
10 changed files with 56 additions and 58 deletions

View file

@ -760,10 +760,10 @@ void FuncSwPressSector(int, int, int, int);
void FuncSwPressWall(int, int, int, int);
std::pair<int, int> BuildSwPause(int nChannel, int nLink, int ebx);
std::pair<int, int> BuildSwNotOnPause(int nChannel, int nLink, int nSector, int ecx);
std::pair<int, int> BuildSwNotOnPause(int nChannel, int nLink, sectortype* nSector, int ecx);
int BuildLink(int nCount, ...);
std::pair<int, int> BuildSwPressSector(int nChannel, int nLink, int nSector, int ecx);
std::pair<int, int> BuildSwStepOn(int nChannel, int nLink, int nSector);
std::pair<int, int> BuildSwPressSector(int nChannel, int nLink, sectortype* nSector, int ecx);
std::pair<int, int> BuildSwStepOn(int nChannel, int nLink, sectortype* nSector);
std::pair<int, int> BuildSwReady(int nChannel, int nLink);
std::pair<int, int> BuildSwPressWall(int nChannel, int nLink, walltype* pWall);

View file

@ -174,7 +174,7 @@ void DoRedAlert(int nVal)
if (nVal)
{
auto spri = &ac->s();
PlayFXAtXYZ(StaticSound[kSoundAlarm], spri->x, spri->y, spri->z, spri->sectnum);
PlayFXAtXYZ(StaticSound[kSoundAlarm], spri->x, spri->y, spri->z);
AddFlash(spri->sector(), spri->x, spri->y, spri->z, 192);
}
}

View file

@ -293,7 +293,7 @@ void AIFish::Damage(RunListEvent* ev)
BuildFishLimb(pActor, i);
}
PlayFXAtXYZ(StaticSound[kSound40], pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum);
PlayFXAtXYZ(StaticSound[kSound40], pSprite->x, pSprite->y, pSprite->z);
DestroyFish(pActor);
}
else

View file

@ -605,7 +605,7 @@ int CheckSectorSprites(int nSector, int nVal)
pSprite->x,
pSprite->y,
pSprite->z,
pSprite->sectnum, CHANF_NONE, 0x4000);
CHANF_NONE, 0x4000);
}
}
}
@ -836,7 +836,7 @@ void AIElev::Tick(RunListEvent* ev)
}
auto sp = &pElevSpr->s();
PlayFXAtXYZ(StaticSound[kSound26], sp->x, sp->y, sp->z, sp->sectnum);
PlayFXAtXYZ(StaticSound[kSound26], sp->x, sp->y, sp->z);
}
if (var_18 & 0x4)

View file

@ -1008,7 +1008,7 @@ void AIPlayer::Tick(RunListEvent* ev)
pPlayerSprite->yvel = 0;
StopActorSound(pPlayerActor);
PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, CHANF_NONE, 1); // CHECKME
PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, CHANF_NONE, 1); // CHECKME
}
else
{

View file

@ -1412,8 +1412,7 @@ void AIQueen::Tick(RunListEvent* ev)
StaticSound[kSound40],
pSprite->x,
pSprite->y,
pSprite->z,
pSprite->sectnum);
pSprite->z);
BuildQueenHead(nQueen);

View file

@ -671,7 +671,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a, nSwPress.first, nSwPress.second);
@ -690,7 +690,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwPress = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a, nSwPress.first, nSwPress.second);
@ -751,7 +751,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
@ -769,11 +769,11 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), nSector, 8);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), sectp, 8);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch2.first, nSwitch2.second);
return;
@ -817,11 +817,11 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), nSector, 8);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), sectp, 8);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch2.first, nSwitch2.second);
return;
@ -915,7 +915,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
@ -951,7 +951,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev2, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
@ -959,7 +959,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
case 21: // Touchplate
{
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
@ -1079,7 +1079,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
@ -1157,11 +1157,11 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), nSector, 8);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(2, -1, 0), sectp, 8);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch2.first, nSwitch2.second);
return;
@ -1281,7 +1281,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
@ -1321,7 +1321,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
@ -1337,7 +1337,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
@ -1369,7 +1369,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
case 58:
{
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
@ -1401,11 +1401,11 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(1, 1), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(1, 1), nSector, 60);
auto nSwitch2 = BuildSwNotOnPause(nChannel, BuildLink(1, 1), sectp, 60);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch2.first, nSwitch2.second);
return;
@ -1461,7 +1461,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
case 64:
{
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 0, 0), nSector);
auto nSwitch = BuildSwStepOn(nChannel, BuildLink(2, 0, 0), sectp);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);
return;
}
@ -1489,7 +1489,7 @@ void runlist_ProcessSectorTag(int nSector, int nLotag, int nHitag)
runlist_AddRunRec(sRunChannels[nChannel].a, nElev, 0);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), nSector, keyMask);
auto nSwitch = BuildSwPressSector(nChannel, BuildLink(1, 1), sectp, keyMask);
runlist_AddRunRec(sRunChannels[nChannel].a,nSwitch.first, nSwitch.second);

View file

@ -552,7 +552,6 @@ void GameInterface::UpdateSounds()
//==========================================================================
int soundx, soundy, soundz;
int soundsect;
void PlayFX2(unsigned int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags, int sprflags)
{
@ -655,12 +654,11 @@ void PlayFX2(unsigned int nSound, DExhumedActor* pActor, int sectf, EChanFlags c
//
//==========================================================================
void PlayFXAtXYZ(unsigned int ax, int x, int y, int z, int nSector, EChanFlags chanflags, int sectf)
void PlayFXAtXYZ(unsigned int ax, int x, int y, int z, EChanFlags chanflags, int sectf)
{
soundx = x;
soundy = y;
soundz = z;
soundsect = nSector;
PlayFX2(ax, nullptr, sectf, chanflags);
}

View file

@ -132,7 +132,7 @@ void CheckAmbience(int nSector);
void PlayFX2(unsigned int nSound, DExhumedActor* nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0);
void PlayFXAtXYZ(unsigned int nSound, int x, int y, int z, int nSector, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
void PlayFXAtXYZ(unsigned int nSound, int x, int y, int z, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
inline void D3PlayFX(unsigned int nSound, DExhumedActor* actor, int flags = 0)
{
PlayFX2(nSound, actor, 0, CHANF_NONE, flags);

View file

@ -38,9 +38,9 @@ struct Link
struct Switch
{
walltype* pWall;
sectortype* pSector;
int nChannel;
int nLink;
int nSector;
int16_t nWaitTimer;
int16_t nWait;
int16_t nRunPtr;
@ -68,7 +68,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Switch& w, Switch*
("channel", w.nChannel)
("link", w.nLink)
("runptr", w.nRunPtr)
("sector", w.nSector)
("sector", w.pSector)
("run2", w.nRun2)
("wall", w.pWall)
("run3", w.nRun3)
@ -234,16 +234,16 @@ void AISWPause::Process(RunListEvent* ev)
SwitchData[nSwitch].nWaitTimer = eax;
}
std::pair<int, int> BuildSwStepOn(int nChannel, int nLink, int nSector)
std::pair<int, int> BuildSwStepOn(int nChannel, int nLink, sectortype* pSector)
{
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
if (SwitchCount <= 0 || nLink < 0 || pSector == nullptr)
I_Error("Too many switches!\n");
int nSwitch = --SwitchCount;
SwitchData[nSwitch].nChannel = nChannel;
SwitchData[nSwitch].nLink = nLink;
SwitchData[nSwitch].nSector = nSector;
SwitchData[nSwitch].pSector = pSector;
SwitchData[nSwitch].nRun2 = -1;
return { nSwitch , 0x30000 };
@ -256,7 +256,7 @@ void AISWStepOn::ProcessChannel(RunListEvent* ev)
int nLink = SwitchData[nSwitch].nLink;
int nChannel = SwitchData[nSwitch].nChannel;
int nSector =SwitchData[nSwitch].nSector;
auto pSector =SwitchData[nSwitch].pSector;
assert(sRunChannels[nChannel].c < 8);
@ -270,7 +270,7 @@ void AISWStepOn::ProcessChannel(RunListEvent* ev)
if (var_14 >= 0)
{
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]);
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(pSector->lotag - 1, &RunData[ev->nRun]);
}
}
@ -281,7 +281,7 @@ void AISWStepOn::TouchFloor(RunListEvent* ev)
int nLink = SwitchData[nSwitch].nLink;
int nChannel = SwitchData[nSwitch].nChannel;
int nSector =SwitchData[nSwitch].nSector;
auto pSector = SwitchData[nSwitch].pSector;
assert(sRunChannels[nChannel].c < 8);
@ -289,8 +289,8 @@ void AISWStepOn::TouchFloor(RunListEvent* ev)
if (var_14 != sRunChannels[nChannel].c)
{
int nWall = sector[nSector].wallptr;
PlayFXAtXYZ(StaticSound[nSwitchSound], wall[nWall].x, wall[nWall].y, sector[nSector].floorz, nSector);
auto pWall = pSector->firstWall();
PlayFXAtXYZ(StaticSound[nSwitchSound], pWall->x, pWall->y, pSector->floorz);
assert(sRunChannels[nChannel].c < 8);
@ -298,9 +298,9 @@ void AISWStepOn::TouchFloor(RunListEvent* ev)
}
}
std::pair<int, int> BuildSwNotOnPause(int nChannel, int nLink, int nSector, int ecx)
std::pair<int, int> BuildSwNotOnPause(int nChannel, int nLink, sectortype* pSector, int ecx)
{
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
if (SwitchCount <= 0 || nLink < 0 || pSector == nullptr)
I_Error("Too many switches!\n");
int nSwitch = --SwitchCount;
@ -308,7 +308,7 @@ std::pair<int, int> BuildSwNotOnPause(int nChannel, int nLink, int nSector, int
SwitchData[nSwitch].nChannel = nChannel;
SwitchData[nSwitch].nLink = nLink;
SwitchData[nSwitch].nWait = ecx;
SwitchData[nSwitch].nSector = nSector;
SwitchData[nSwitch].pSector = pSector;
SwitchData[nSwitch].nRunPtr = -1;
SwitchData[nSwitch].nRun2 = -1;
@ -368,10 +368,10 @@ void AISWNotOnPause::Process(RunListEvent* ev)
{
SwitchData[nSwitch].nRunPtr = runlist_AddRunRec(NewRun, &RunData[ev->nRun]);
int nSector =SwitchData[nSwitch].nSector;
auto pSector = SwitchData[nSwitch].pSector;
SwitchData[nSwitch].nWaitTimer = SwitchData[nSwitch].nWait;
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]);
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(pSector->lotag - 1, &RunData[ev->nRun]);
}
}
}
@ -384,16 +384,16 @@ void AISWNotOnPause::TouchFloor(RunListEvent* ev)
return;
}
std::pair<int, int> BuildSwPressSector(int nChannel, int nLink, int nSector, int keyMask)
std::pair<int, int> BuildSwPressSector(int nChannel, int nLink, sectortype* pSector, int keyMask)
{
if (SwitchCount <= 0 || nLink < 0 || nSector < 0)
if (SwitchCount <= 0 || nLink < 0 || pSector == nullptr)
I_Error("Too many switches!\n");
int nSwitch = --SwitchCount;
SwitchData[nSwitch].nChannel = nChannel;
SwitchData[nSwitch].nLink = nLink;
SwitchData[nSwitch].nSector = nSector;
SwitchData[nSwitch].pSector = pSector;
SwitchData[nSwitch].nKeyMask = keyMask;
SwitchData[nSwitch].nRun2 = -1;
@ -420,9 +420,9 @@ void AISWPressSector::ProcessChannel(RunListEvent* ev)
return;
}
int nSector =SwitchData[nSwitch].nSector;
auto pSector = SwitchData[nSwitch].pSector;
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(sector[nSector].lotag - 1, &RunData[ev->nRun]);
SwitchData[nSwitch].nRun2 = runlist_AddRunRec(pSector->lotag - 1, &RunData[ev->nRun]);
}
void AISWPressSector::Use(RunListEvent* ev)
@ -443,7 +443,7 @@ void AISWPressSector::Use(RunListEvent* ev)
if (SwitchData[nSwitch].nKeyMask)
{
auto pSprite = &PlayerList[nPlayer].Actor()->s();
PlayFXAtXYZ(StaticSound[nSwitchSound], pSprite->x, pSprite->y, 0, pSprite->sectnum, CHANF_LISTENERZ);
PlayFXAtXYZ(StaticSound[nSwitchSound], pSprite->x, pSprite->y, 0, CHANF_LISTENERZ);
StatusMessage(300, "YOU NEED THE KEY FOR THIS DOOR");
}
@ -463,6 +463,7 @@ std::pair<int, int> BuildSwPressWall(int nChannel, int nLink, walltype* pWall)
SwitchData[SwitchCount].nLink = nLink;
SwitchData[SwitchCount].pWall = pWall;
SwitchData[SwitchCount].nRun3 = -1;
SwitchData[SwitchCount].pSector = nullptr;
return { SwitchCount, 0x60000 };
}
@ -507,9 +508,9 @@ void AISWPressWall::Use(RunListEvent* ev)
}
auto pWall = SwitchData[nSwitch].pWall;
int nSector =SwitchData[nSwitch].nSector; // CHECKME - where is this set??
auto pSector = SwitchData[nSwitch].pSector;
PlayFXAtXYZ(StaticSound[nSwitchSound], pWall->x, pWall->y, 0, nSector, CHANF_LISTENERZ);
PlayFXAtXYZ(StaticSound[nSwitchSound], pWall->x, pWall->y, 0, CHANF_LISTENERZ);
}
END_PS_NS