paavohtl Claude Opus 4.6 (1M context) commited on
Commit
985fb50
·
1 Parent(s): 487fa54

refactor: call load_wav directly instead of through vtable

Browse files

Both load_effect_wavs and load_speech_wav were calling DSSound::load_wav
through the vtable indirection. Since load_wav is already a Rust function,
call it directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

crates/openwa-core/src/audio/speech_ops.rs CHANGED
@@ -291,8 +291,7 @@ pub unsafe fn load_speech_wav(
291
  }
292
 
293
  let slot_idx = count as u32 + SpeechSlotTable::BUFFER_OFFSET;
294
- let vtable = (*wrapper.sound).vtable;
295
- let result = ((*vtable).load_wav)(wrapper.sound, slot_idx as i32, full_path as *const u8);
296
 
297
  if result != 0 {
298
  slot_table.set(team_index as usize, line_id, slot_idx);
 
291
  }
292
 
293
  let slot_idx = count as u32 + SpeechSlotTable::BUFFER_OFFSET;
294
+ let result = crate::audio::dssound::load_wav(wrapper.sound, slot_idx as i32, full_path as *const u8);
 
295
 
296
  if result != 0 {
297
  slot_table.set(team_index as usize, line_id, slot_idx);
crates/openwa-core/src/engine/ddgame_constructor.rs CHANGED
@@ -209,6 +209,7 @@ static mut GFX_LOAD_SPRITES_ADDR: u32 = 0;
209
  /// null-terminated). For each entry, builds "data\wav\Effects\{name}.wav" and calls
210
  /// DSSound::load_wav (vtable slot 12, already Rust).
211
  unsafe fn load_effect_wavs(wrapper: *mut DDGameWrapper) {
 
212
  use std::ffi::CStr;
213
 
214
  /// Sound effect name table entry: (slot_id, name_ptr).
@@ -223,7 +224,6 @@ unsafe fn load_effect_wavs(wrapper: *mut DDGameWrapper) {
223
  if sound.is_null() {
224
  return;
225
  }
226
- let sound_vt = &*(*sound).vtable;
227
 
228
  let mut i = 0;
229
  loop {
@@ -238,7 +238,7 @@ unsafe fn load_effect_wavs(wrapper: *mut DDGameWrapper) {
238
  let name = CStr::from_ptr(entry.name_ptr).to_str().unwrap_or("");
239
  let path = format!("data\\wav\\Effects\\{}.wav\0", name);
240
 
241
- (sound_vt.load_wav)(sound, entry.slot_id, path.as_ptr());
242
 
243
  // Update loading progress bar
244
  call_usercall_ecx(wrapper, LOADING_PROGRESS_TICK_ADDR);
 
209
  /// null-terminated). For each entry, builds "data\wav\Effects\{name}.wav" and calls
210
  /// DSSound::load_wav (vtable slot 12, already Rust).
211
  unsafe fn load_effect_wavs(wrapper: *mut DDGameWrapper) {
212
+ use crate::audio::dssound::load_wav;
213
  use std::ffi::CStr;
214
 
215
  /// Sound effect name table entry: (slot_id, name_ptr).
 
224
  if sound.is_null() {
225
  return;
226
  }
 
227
 
228
  let mut i = 0;
229
  loop {
 
238
  let name = CStr::from_ptr(entry.name_ptr).to_str().unwrap_or("");
239
  let path = format!("data\\wav\\Effects\\{}.wav\0", name);
240
 
241
+ load_wav(sound, entry.slot_id, path.as_ptr());
242
 
243
  // Update loading progress bar
244
  call_usercall_ecx(wrapper, LOADING_PROGRESS_TICK_ADDR);