From 458e0005690ea9d579588a0a12368fc2c2c9a93a Mon Sep 17 00:00:00 2001 From: untodesu Date: Tue, 1 Jul 2025 03:08:39 +0500 Subject: I hyper-focued on refactoring again - I put a cool-sounding "we are number one" remix on repeat and straight up grinded the entire repository to a better state until 03:09 AM. I guess I have something wrong in my brain that makes me do this shit --- src/game/client/voxel_sounds.cc | 86 ----------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/game/client/voxel_sounds.cc (limited to 'src/game/client/voxel_sounds.cc') diff --git a/src/game/client/voxel_sounds.cc b/src/game/client/voxel_sounds.cc deleted file mode 100644 index 996dc61..0000000 --- a/src/game/client/voxel_sounds.cc +++ /dev/null @@ -1,86 +0,0 @@ -#include "client/pch.hh" - -#include "client/voxel_sounds.hh" - -#include "client/sound_effect.hh" - -constexpr static std::size_t NUM_SURFACES = static_cast(voxel_surface::COUNT); - -static std::vector> footsteps_sounds[NUM_SURFACES]; -static std::mt19937_64 randomizer; - -static void add_footsteps_effect(voxel_surface surface, const char* name) -{ - if(auto effect = resource::load(name)) { - auto surface_index = static_cast(surface); - footsteps_sounds[surface_index].push_back(effect); - } -} - -static resource_ptr get_footsteps_effect(voxel_surface surface) -{ - auto surface_index = static_cast(surface); - - if(surface_index >= NUM_SURFACES) { - // Surface index out of range - return nullptr; - } - - const auto& sounds = footsteps_sounds[surface_index]; - - if(sounds.empty()) { - // No sounds for this surface - return nullptr; - } - - auto dist = std::uniform_int_distribution(0, sounds.size() - 1); - return sounds.at(dist(randomizer)); -} - -void voxel_sounds::init(void) -{ - add_footsteps_effect(voxel_surface::DEFAULT, "sounds/surface/default1.wav"); - add_footsteps_effect(voxel_surface::DEFAULT, "sounds/surface/default2.wav"); - add_footsteps_effect(voxel_surface::DEFAULT, "sounds/surface/default3.wav"); - add_footsteps_effect(voxel_surface::DEFAULT, "sounds/surface/default4.wav"); - - add_footsteps_effect(voxel_surface::DIRT, "sounds/surface/dirt1.wav"); - - add_footsteps_effect(voxel_surface::GRASS, "sounds/surface/grass1.wav"); - add_footsteps_effect(voxel_surface::GRASS, "sounds/surface/grass2.wav"); - add_footsteps_effect(voxel_surface::GRASS, "sounds/surface/grass3.wav"); - - add_footsteps_effect(voxel_surface::GRAVEL, "sounds/surface/gravel1.wav"); - - add_footsteps_effect(voxel_surface::SAND, "sounds/surface/sand1.wav"); - add_footsteps_effect(voxel_surface::SAND, "sounds/surface/sand2.wav"); - - add_footsteps_effect(voxel_surface::WOOD, "sounds/surface/wood1.wav"); - add_footsteps_effect(voxel_surface::WOOD, "sounds/surface/wood2.wav"); - add_footsteps_effect(voxel_surface::WOOD, "sounds/surface/wood3.wav"); -} - -void voxel_sounds::shutdown(void) -{ - for(std::size_t i = 0; i < NUM_SURFACES; ++i) { - footsteps_sounds[i].clear(); - } -} - -resource_ptr voxel_sounds::get_footsteps(voxel_surface surface) -{ - if(auto effect = get_footsteps_effect(surface)) { - return effect; - } - - if(auto effect = get_footsteps_effect(voxel_surface::DEFAULT)) { - return effect; - } - - return nullptr; -} - -resource_ptr voxel_sounds::get_placebreak(voxel_surface surface) -{ - return nullptr; -} -- cgit