From 08e7a7cb4da522ac5db6de750771e2d1f3e78f99 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Mon, 17 Apr 2017 18:15:42 +0100 Subject: [PATCH] Clean up captions code to allow for different numbers defined at compile time. --- src/s_sound.c | 19 +++++-------------- src/s_sound.h | 4 +++- src/screen.c | 4 ++-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 2add1cf94..181ca5a67 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -130,21 +130,12 @@ static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL static channel_t *channels = NULL; static INT32 numofchannels = 0; -caption_t closedcaptions[8] = { - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0}, - {NULL, NULL, 0} -}; +caption_t closedcaptions[NUMCAPTIONS]; void ResetCaptions(void) { UINT8 i; - for (i = 0; i < 8; i++) + for (i = 0; i < NUMCAPTIONS; i++) { closedcaptions[i].c = NULL; closedcaptions[i].s = NULL; @@ -593,7 +584,7 @@ dontplay: // Handle closed caption input. if (cv_closedcaptioning.value && sfx->caption[0] != '/') { - UINT8 i, set = 7, moveup = 255; + UINT8 i, set = NUMCAPTIONS-1, moveup = 255; boolean same = false; for (i = 0; i < set; i++) { @@ -617,7 +608,7 @@ dontplay: break; } } - for (i = 7; i > set; i--) + for (i = NUMCAPTIONS-1; i > set; i--) { if (sfx == closedcaptions[i].s) { @@ -630,7 +621,7 @@ dontplay: if (moveup != 255) { - for (i = moveup; i < 7; i++) + for (i = moveup; i < NUMCAPTIONS-1; i++) { if (!(closedcaptions[i].c || closedcaptions[i].s)) break; diff --git a/src/s_sound.h b/src/s_sound.h index 7e72d80e5..dc0dfaf69 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -85,7 +85,9 @@ typedef struct { UINT8 t; } caption_t; -extern caption_t closedcaptions[8]; +#define NUMCAPTIONS 8 + +extern caption_t closedcaptions[NUMCAPTIONS]; // register sound vars and commands at game startup void S_RegisterSoundStuff(void); diff --git a/src/screen.c b/src/screen.c index 223f0a494..12bb9c4bd 100644 --- a/src/screen.c +++ b/src/screen.c @@ -442,7 +442,7 @@ void SCR_ClosedCaptions(void) { UINT8 i; - for (i = 0; i < 8; i++) + for (i = 0; i < NUMCAPTIONS; i++) { boolean cond = (closedcaptions[i].c && I_SoundIsPlaying(closedcaptions[i].c->handle)); @@ -462,7 +462,7 @@ void SCR_ClosedCaptions(void) } } - for (i = 0; i < 8; i++) + for (i = 0; i < NUMCAPTIONS; i++) { if (closedcaptions[i].s) {