- callsound

This commit is contained in:
Christoph Oelckers 2020-10-23 17:38:49 +02:00
parent 3c19f8e44e
commit b2a2232260
4 changed files with 19 additions and 20 deletions

View file

@ -289,9 +289,9 @@ inline void detonate(int i, int explosion)
detonate(&hittype[i], explosion);
}
inline void callsound(int sect, DDukeActor* a)
inline int callsound(int sect, int a)
{
callsound(sect, a->GetIndex());
return callsound(sect, a == -1? nullptr : &hittype[a]);
}
inline int hits(DDukeActor* snum)

View file

@ -140,8 +140,7 @@ int haskey(int sect, int snum);
void shootbloodsplat(int i, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST);
void breakwall(short newpn, short spr, short dawallnum);
void callsound2(int soundNum, int playerNum);
int callsound(int sectnum,int snum);
int callsound(int sectnum,DDukeActor* snum);
int hitasprite(int snum,short *hitSprite);
int findplayer(const spritetype* s, int* dist);
void operatejaildoors(int hitag);

View file

@ -50,7 +50,7 @@ BEGIN_DUKE_NS
//---------------------------------------------------------------------------
static bool haltsoundhack;
int callsound(int sn, int whatsprite)
int callsound(int sn, DDukeActor* whatsprite)
{
if (!isRRRA() && haltsoundhack)
{
@ -58,49 +58,48 @@ int callsound(int sn, int whatsprite)
return -1;
}
int i;
SectIterator it(sn);
while ((i = it.NextIndex()) >= 0)
DukeSectIterator it(sn);
while (auto act = it.Next())
{
auto si = &sprite[i];
auto si = &act->s;
if (si->picnum == MUSICANDSFX && si->lotag < 1000)
{
if (whatsprite == -1) whatsprite = i;
if (whatsprite == nullptr) whatsprite = act;
int snum = si->lotag;
auto flags = S_GetUserFlags(snum);
// Reset if the desired actor isn't playing anything.
bool hival = S_IsSoundValid(si->hitag);
if (hittype[i].temp_data[0] == 1 && !hival)
if (act->temp_data[0] == 1 && !hival)
{
if (!S_CheckActorSoundPlaying(hittype[i].temp_data[5], snum))
hittype[i].temp_data[0] = 0;
if (!S_CheckActorSoundPlaying(act->temp_actor, snum))
act->temp_data[0] = 0;
}
if (hittype[i].temp_data[0] == 0)
if (act->temp_data[0] == 0)
{
if ((flags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL)
{
if (snum)
{
if (si->hitag && snum != si->hitag)
S_StopSound(si->hitag, hittype[i].temp_data[5]);
S_StopSound(si->hitag, act->temp_actor);
S_PlayActorSound(snum, whatsprite);
hittype[i].temp_data[5] = whatsprite;
act->temp_actor = whatsprite;
}
if ((sector[si->sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR)
hittype[i].temp_data[0] = 1;
act->temp_data[0] = 1;
}
}
else if (si->hitag < 1000)
{
if ((flags & SF_LOOP) || (si->hitag && si->hitag != si->lotag))
S_StopSound(si->lotag, hittype[i].temp_data[5]);
S_StopSound(si->lotag, act->temp_actor);
if (si->hitag) S_PlayActorSound(si->hitag, whatsprite);
hittype[i].temp_data[0] = 0;
hittype[i].temp_data[5] = whatsprite;
act->temp_data[0] = 0;
act->temp_actor = whatsprite;
}
return si->lotag;
}

View file

@ -172,6 +172,7 @@ int initspriteforspawn(int j, int pn, const std::initializer_list<int> &excludes
act->actorstayput = -1;
t[0] = t[1] = t[2] = t[3] = t[4] = t[5] = 0;
hittype[i].temp_actor = nullptr;
if (sp->cstat & 48)
if (!isIn(sp->picnum, excludes) && (sp->cstat & 48))