halflife icon indicating copy to clipboard operation
halflife copied to clipboard

[Half-Life] CSound issue

Open tehORiON opened this issue 11 years ago • 3 comments

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;
}

tehORiON avatar Sep 12 '15 13:09 tehORiON

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

JoelTroch avatar Jan 06 '16 20:01 JoelTroch

@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.

tehORiON avatar Jan 12 '16 13:01 tehORiON

Alright, thank you ^^

JoelTroch avatar Jan 12 '16 13:01 JoelTroch