Skip to content

Commit

Permalink
- removed the dangerous pointer hackery in S_NoiseDebug
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 22, 2019
1 parent 4378cda commit ec52ba8
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/sound/s_sound.cpp
Expand Up @@ -241,10 +241,17 @@ void S_NoiseDebug (void)
listener = players[consoleplayer].camera->SoundPos();

// Display the oldest channel first.
// This function wants to step through this list backwards.
// Rather than hacking around with the pointers, let's collect everything in an array first
// and then iterate over that backwards.
TArray<FSoundChan *> list;
for (chan = ChannelList.Channels(); chan->Next() != NULL; chan = chan->Next())
{ }
while (y < SCREENHEIGHT - 16)
{
list.Push(chan);
}
for(int i = (int)list.Size()-1; i >= 0 && y < SCREENHEIGHT - 16; i--)
{
auto chan = list[i];
char temp[32];

CalcPosVel(chan, &origin, NULL);
Expand Down Expand Up @@ -302,15 +309,15 @@ void S_NoiseDebug (void)

// Flags
mysnprintf(temp, countof(temp), "%s3%sZ%sU%sM%sN%sA%sL%sE%sV",
(chan->ChanFlags & CHAN_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK);
(chan->ChanFlags & CHAN_IS3D) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_LISTENERZ) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_UI) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_MAYBE_LOCAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_NOPAUSE) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_AREA) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_LOOP) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_EVICTED) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK,
(chan->ChanFlags & CHAN_VIRTUAL) ? TEXTCOLOR_GREEN : TEXTCOLOR_BLACK);
screen->DrawText(NewConsoleFont, color, 380, y, temp, TAG_DONE);

// Audibility
Expand All @@ -323,19 +330,10 @@ void S_NoiseDebug (void)


y += NewConsoleFont->GetHeight();
#if 0
// OMG! This godawful hackery needs to be fixed before this can be reactivated.
if (chan->PrevChan == &ChannelList.Channels())
{
break;
}
chan = (FSoundChan *)((size_t)chan->PrevChan - myoffsetof(FSoundChan, NextChan));
#else
break;
#endif
}
}


static FString LastLocalSndInfo;
static FString LastLocalSndSeq;
void S_AddLocalSndInfo(int lump);
Expand Down

0 comments on commit ec52ba8

Please sign in to comment.