Files
jak-project/game/sound/989snd/handle_allocator.h
T
water111 c08118509b [jak3] Add BRANCH grain, make handler IDs unique (#3950)
Two changes that fix some Jak 3 audio bugs.

In some areas, sound effects would seem to cut off randomly. This was
caused by the sound code reusing IDs, but overlord didn't realize. It
would try to kill a sound effect by ID that had already died, and the ID
was reassigned to a new sound. To fix this, I made the handle IDs always
increment. I also tested starting the ID at large numbers and confirmed
that worked.

I also added support for the BRANCH grain. This makes the
`wastelander-shot` and possibly other sound effects work. It doesn't
support all the features, but this is probably enough.

Fun fact: the wastelander shot is supposed to have 7 variations, but you
always get the same one because they set the sound mask wrong.

I added a line you can uncomment if you want to experience the other 6
variations.

---------

Co-authored-by: water111 <awaterford1111445@gmail.com>
2025-06-07 22:34:03 -04:00

21 lines
438 B
C++

// Copyright: 2021 - 2024, Ziemas
// SPDX-License-Identifier: ISC
#pragma once
#include "common/common_types.h"
namespace snd {
class IdAllocator {
public:
// Use a unique ID each time - the Overlord will sometimes do the wrong thing if handles are
// reused. The real 989snd also includes type + handle index in this.
u32 GetId() { return mNextId++; }
void FreeId(u32) {}
private:
u32 mNextId{1};
};
} // namespace snd