ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.65k stars 617 forks source link

[Half-Life] CSound issue #1652

Open tehORiON opened 8 years ago

tehORiON commented 8 years ago

Hi, noticed some issues with CSound causing trouble in the HL AI.

If you look at this function which resets sound on player death or player disconnect, it states that it doesn't "unlink" the sound, yet it clearly does with this line "m_iNext =SOUNDLIST_EMPTY;". Each client/player has their own unique reserved index in the soundlist, starting at the tail of the list 0 up to however many players might be on the server.

Now let's say that client # 10 dies and Reset is then called on his reserved sound, because m_iNext is set to -1 on reset and thus becoming the new 'tail' the rest of the list is then unlinked. And it stay's this way after he spawns again.

This is a problem in functions such as "CBaseMonster :: Listen()", which traverses the soundlist with m_iNext looking for an audible sound, which causes everyone but the one with the highest client number to be ignored by the monster.

These reserved sound slots should never get unlinked.

//=========================================================
// Reset - clears the volume, origin, and type for a sound,
// but doesn't expire or unlink it. 
//=========================================================
void CSound :: Reset ( void )
{
    m_vecOrigin     = g_vecZero;
    m_iType         = 0;
    m_iVolume       = 0;
    m_iNext         = SOUNDLIST_EMPTY;
}
JoelTroch commented 8 years ago

Bumping this because I have a question: in other words, if we remove or comment m_iNext = SOUNDLIST_EMPTY; the problem is fixed?

tehORiON commented 8 years ago

@JoelTroch That should do the trick yeah. This is obviously not an issue in singleplayer HL, but if using the AI in multiplayer scenarios an important part of the monster's AI behavior will be missing.

JoelTroch commented 8 years ago

Alright, thank you ^^