22
33#include " loader/component_loader.hpp"
44
5- #include " console.hpp"
65#include " filesystem.hpp"
76
87#include " game/game.hpp"
@@ -29,7 +28,8 @@ namespace sounds
2928 const char * name;
3029 };
3130
32- std::string current_override_path;
31+ thread_local std::string current_override_path;
32+ std::mutex override_notice_mutex;
3333 std::string last_notified_override;
3434
3535 std::string sanitize_name (std::string value)
@@ -120,13 +120,6 @@ namespace sounds
120120 return 0 ;
121121 }
122122
123- game::Com_Printf (
124- 0 ,
125- " sounds: AIL_open_stream file='%s' override='%s'\n " ,
126- filename ? filename : " <null>" ,
127- current_override_path.empty () ? " <none>" : current_override_path.c_str ()
128- );
129-
130123 if (!current_override_path.empty ())
131124 {
132125 filename = current_override_path.c_str ();
@@ -139,13 +132,6 @@ namespace sounds
139132 {
140133 if (!current_override_path.empty ())
141134 {
142- game::Com_Printf (
143- 0 ,
144- " sounds: skipping stock loop block %d..%d for override='%s'\n " ,
145- loop_start,
146- loop_end,
147- current_override_path.c_str ()
148- );
149135 return ;
150136 }
151137
@@ -161,14 +147,15 @@ namespace sounds
161147
162148 const auto alias = alias_name && *alias_name ? alias_name : " <unknown>" ;
163149 const auto key = std::format (" {}|{}" , alias, override_path);
150+ std::lock_guard lock (override_notice_mutex);
164151 if (last_notified_override == key)
165152 {
166153 return ;
167154 }
168155
169156 last_notified_override = key;
170157
171- console::warn ( " overriding %s with %s\n " , alias, override_path.c_str ());
158+ game::Com_Printf ( 0 , " sounds: overriding %s with %s\n " , alias, override_path.c_str ());
172159 }
173160
174161 int __cdecl open_music_stream_stub (const char *** request, int index)
@@ -177,31 +164,19 @@ namespace sounds
177164 const auto original = reinterpret_cast <open_stream_t >(game::game_offset (streamed_sound_open_function));
178165
179166 const char * alias_name = " <null>" ;
180- const char * source_name = " <null>" ;
181167 if (request && *request)
182168 {
183169 if ((*request)[0 ] && *(*request)[0 ])
184170 {
185171 alias_name = (*request)[0 ];
186172 }
187-
188- const auto * const file_info = reinterpret_cast <const streamed_sound_file_view*>((*request)[4 ]);
189- if (file_info && file_info->name && *file_info->name )
190- {
191- source_name = file_info->name ;
192- }
193173 }
194174
195175 current_override_path = find_music_override (request);
196- game::Com_Printf (
197- 0 ,
198- " sounds: music stream alias='%s' source='%s' override='%s'\n " ,
199- alias_name,
200- source_name,
201- current_override_path.empty () ? " <none>" : current_override_path.c_str ()
202- );
203-
204- show_override_notice (alias_name, current_override_path);
176+ if (!current_override_path.empty ())
177+ {
178+ show_override_notice (alias_name, current_override_path);
179+ }
205180
206181 const auto clear_override = gsl::finally ([]()
207182 {
@@ -223,11 +198,6 @@ namespace sounds
223198 utils::hook::call (game::game_offset (music_stream_callsite_3), open_music_stream_stub);
224199 utils::hook::call (game::game_offset (ail_open_stream_callsite_1), ail_open_stream_stub);
225200 utils::hook::call (game::game_offset (ail_open_stream_callsite_2), ail_open_stream_stub);
226-
227- if (const auto proc = utils::nt::library (" mss32.dll" ).get_proc <void *>(" _AIL_set_stream_loop_block@12" ))
228- {
229- ail_set_stream_loop_block_hook.create (proc, ail_set_stream_loop_block_stub);
230- }
231201 }
232202
233203 void pre_destroy () override
@@ -238,4 +208,4 @@ namespace sounds
238208}
239209
240210
241- // REGISTER_COMPONENT(sounds::component)
211+ REGISTER_COMPONENT (sounds::component)
0 commit comments