summaryrefslogtreecommitdiff
path: root/sound.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-11-18 16:47:02 +0000
committerDarkvater <darkvater@openttd.org>2006-11-18 16:47:02 +0000
commitb3c48c0a84323838b5104e422d11b8a1250325c8 (patch)
tree8112ec497b55f459780ad628193295c31cabfe28 /sound.c
parentaa97b61a27cecfb6e06526fa74d95629cc7259a5 (diff)
downloadopenttd-b3c48c0a84323838b5104e422d11b8a1250325c8.tar.xz
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
structs inside their array, and possibly invalidating pointers higher up. Meaning that any function called within an wndproc could cause unknown/invalid pointers once control was returned to this function. Solved by the introduction of an extra abstraction layer, an array of z-window positions that is only concerned with the pointers.
Diffstat (limited to 'sound.c')
-rw-r--r--sound.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sound.c b/sound.c
index af8c6ca53..e1719e08a 100644
--- a/sound.c
+++ b/sound.c
@@ -194,12 +194,12 @@ void SndCopyToPool(void)
static void SndPlayScreenCoordFx(SoundFx sound, int x, int y)
{
- const Window *w;
+ const Window* const *wz;
if (msf.effect_vol == 0) return;
- for (w = _windows; w != _last_window; w++) {
- const ViewPort* vp = w->viewport;
+ FOR_ALL_WINDOWS(wz) {
+ const ViewPort *vp = (*wz)->viewport;
if (vp != NULL &&
IS_INSIDE_1D(x, vp->virtual_left, vp->virtual_width) &&