paavohtl Claude Opus 4.6 (1M context) commited on
Commit
ae2f611
Β·
1 Parent(s): 04e939e

fix: set sound_available early to match original constructor

Browse files

The original sets sound_available = (headless_mode == 0) immediately
after storing params, NOT at the end. This enables:
- Loading progress bar visibility
- Message pump during construction (FUN_572E30)
- Sound playback during loading ticks
- Proper flag initialization in DDGameWrapper__LoadingProgressTick

Previously deferred to avoid message pump crashes, but all critical
DDGame fields are initialized before the first loading tick call.

This should fix the missing loading screen ticks and sounds, and may
fix the forced "teleport worms in" mode.

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

crates/openwa-core/src/engine/ddgame.rs CHANGED
@@ -1030,12 +1030,11 @@ pub unsafe fn create_ddgame(
1030
 
1031
  // ── 6. Sound available + always-1 flags ──
1032
  let is_headless = (*game_info).headless_mode != 0;
1033
- // Defer sound_available β€” keep at 0 during construction.
1034
- // DDGame__LoadWeaponSprites checks this flag; when set, it calls
1035
- // FUN_572E30 which pumps PeekMessage/DispatchMessage. That can
1036
- // trigger game task code that reads uninitialized DDGame fields.
1037
- // Set to final value at the end of init_graphics_and_resources.
1038
- (*ddgame).sound_available = 0;
1039
  (*ddgame)._field_7efc = 1;
1040
 
1041
  // ── 7. DDGameWrapper+0x48C init ──
@@ -1062,9 +1061,6 @@ pub unsafe fn create_ddgame(
1062
  // ── 10. GfxHandler, landscape, sprites, audio, resources ──
1063
  init_graphics_and_resources(wrapper, game_info, net_game, display, is_headless);
1064
 
1065
- // Construction complete β€” set final flag values.
1066
- (*ddgame).sound_available = if is_headless { 0 } else { 1 };
1067
-
1068
  let _ = crate::log::log_line("[DDGame] create_ddgame complete");
1069
  ddgame
1070
  }
 
1030
 
1031
  // ── 6. Sound available + always-1 flags ──
1032
  let is_headless = (*game_info).headless_mode != 0;
1033
+ // Original: sound_available = (headless_mode == 0) β€” set EARLY.
1034
+ // This enables the loading progress bar, message pump, and sound during
1035
+ // construction. Previously deferred to avoid message pump crashes, but all
1036
+ // critical DDGame fields (game_info, display, sound, etc.) are now set.
1037
+ (*ddgame).sound_available = if is_headless { 0 } else { 1 };
 
1038
  (*ddgame)._field_7efc = 1;
1039
 
1040
  // ── 7. DDGameWrapper+0x48C init ──
 
1061
  // ── 10. GfxHandler, landscape, sprites, audio, resources ──
1062
  init_graphics_and_resources(wrapper, game_info, net_game, display, is_headless);
1063
 
 
 
 
1064
  let _ = crate::log::log_line("[DDGame] create_ddgame complete");
1065
  ddgame
1066
  }