ref: e94dc8669d801e94285d342274824c805e8a8220
parent: 4f2bd55f7f639d703d96ed263401ac31ac17837c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Oct 7 20:37:54 EDT 2015
doom: fix bogus pointer arithmetic, do sfx initialization in two passes for linked sounds
--- a/sys/src/games/doom/i_sound.c
+++ b/sys/src/games/doom/i_sound.c
@@ -135,17 +135,20 @@
/* Initialize external data (all sounds) at start, keep static. */
for (i=1 ; i<NUMSFX ; i++)
{- /* Alias? Example is the chaingun sound linked to pistol. */
if (!S_sfx[i].link)
{/* Load data from WAD file. */
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
}
- else
+ }
+ /* Alias? Example is the chaingun sound linked to pistol. */
+ for (i=1 ; i<NUMSFX ; i++)
+ {+ if (S_sfx[i].link)
{/* Previously loaded already? */
S_sfx[i].data = S_sfx[i].link->data;
- lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
+ lengths[i] = lengths[S_sfx[i].link - S_sfx];
}
}
--
⑨