Skip to content

Sounds function completely without slots, use a linked list

SSNTails requested to merge SSNTails/SRB2:slotlessSounds into next

Tagging @Hanicef for his input and review. I still need to test mods to ensure that freeslots function properly.

This is a prep for eventual C++ conversion, and I plan to introduce a new Sound Lua API that abstracts the underlying implementation away.

This does

  • Removes the use of sfxinfo_t array and replaces it with a 'private' sfxinfo_Head
  • Getters for retrieving a specific sound from the Sounds collection
  • sfxinfo_t* is returned from getters, rather than the old way of an sfx enum
  • Unlimited length for sound filenames
  • Unlimited length for sound captions
  • Removed i_sound awareness of sfxinfo_t - it now only lives in the cross platform abstraction layer
  • Programming model preparing for C++ conversion

I tested the Metroid mod and it appears to work correctly.

Potential unknowns:

  • What happens when unloading sounds
  • In the current compatibility layer for lua/soc, removed sounds will cause the INT32 ids to be misaligned.
  • Solution: Add a primary-key type of field to each sfxinfo_t that is incremented with each sound add. These are passed to Lua instead.
  • Issue would be non-existent in new Lua API I am planning once this is merged, which will work only with sfxinfo_t objects and sound filename strings instead of enum IDs
Edited by SSNTails

Merge request reports