mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 17:32:13 +00:00
More music-related cleanup.
git-svn-id: https://svn.eduke32.com/eduke32@4586 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5597f3faab
commit
73a252a73e
3 changed files with 54 additions and 55 deletions
|
@ -8750,21 +8750,23 @@ void G_HandleLocalKeys(void)
|
||||||
{
|
{
|
||||||
if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == QUOTE_MUSIC)
|
if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == QUOTE_MUSIC)
|
||||||
{
|
{
|
||||||
i = VOLUMEALL ? MAXVOLUMES*MAXLEVELS : 6;
|
const int32_t maxi = VOLUMEALL ? MAXVOLUMES*MAXLEVELS : 6;
|
||||||
|
int32_t res;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
g_musicIndex++;
|
g_musicIndex++;
|
||||||
if (g_musicIndex >= i)
|
if (g_musicIndex >= maxi)
|
||||||
g_musicIndex = 0;
|
g_musicIndex = 0;
|
||||||
}
|
}
|
||||||
while (MapInfo[g_musicIndex].musicfn == NULL);
|
while (MapInfo[g_musicIndex].musicfn == NULL);
|
||||||
|
|
||||||
if (S_PlayMusic(MapInfo[g_musicIndex].musicfn, g_musicIndex))
|
i = g_musicIndex;
|
||||||
Bsprintf(ScriptQuotes[QUOTE_MUSIC],"Playing %s", MapInfo[g_musicIndex].alt_musicfn);
|
res = S_PlayMusic(MapInfo[i].musicfn, i);
|
||||||
else
|
|
||||||
Bsprintf(ScriptQuotes[QUOTE_MUSIC],"Playing %s", MapInfo[g_musicIndex].musicfn);
|
Bsnprintf(ScriptQuotes[QUOTE_MUSIC], MAXQUOTELEN, "Playing %s",
|
||||||
P_DoQuote(QUOTE_MUSIC,g_player[myconnectindex].ps);
|
res ? MapInfo[i].alt_musicfn : MapInfo[i].musicfn);
|
||||||
|
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8970,15 +8972,19 @@ FAKE_F3:
|
||||||
|
|
||||||
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
|
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
|
||||||
{
|
{
|
||||||
|
map_t *map = &MapInfo[g_musicIndex];
|
||||||
|
char *const qmusic = ScriptQuotes[QUOTE_MUSIC];
|
||||||
|
|
||||||
KB_ClearKeyDown(sc_F5);
|
KB_ClearKeyDown(sc_F5);
|
||||||
if (MapInfo[g_musicIndex].alt_musicfn != NULL)
|
|
||||||
Bstrcpy(ScriptQuotes[QUOTE_MUSIC],MapInfo[g_musicIndex].alt_musicfn);
|
if (map->alt_musicfn != NULL)
|
||||||
else if (MapInfo[g_musicIndex].musicfn != NULL)
|
Bstrncpyz(qmusic, map->alt_musicfn, MAXQUOTELEN);
|
||||||
{
|
else if (map->musicfn != NULL)
|
||||||
Bstrcpy(ScriptQuotes[QUOTE_MUSIC],MapInfo[g_musicIndex].musicfn);
|
Bsnprintf(qmusic, MAXQUOTELEN, "%s. Use SHIFT-F5 to change.",
|
||||||
Bstrcat(ScriptQuotes[QUOTE_MUSIC],". Use SHIFT-F5 to change.");
|
map->musicfn);
|
||||||
}
|
else
|
||||||
else ScriptQuotes[QUOTE_MUSIC][0] = '\0';
|
qmusic[0] = '\0';
|
||||||
|
|
||||||
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
|
P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2154,6 +2154,30 @@ void G_DoGameStartup(const int32_t *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void C_DefineMusic(int32_t vol, int32_t lev, const char *fn)
|
||||||
|
{
|
||||||
|
if (vol==-1)
|
||||||
|
{
|
||||||
|
Bassert((unsigned)lev < MAXVOLUMES);
|
||||||
|
|
||||||
|
Bstrncpyz(EnvMusicFilename[lev], fn, BMAX_PATH);
|
||||||
|
check_filename_case(EnvMusicFilename[lev]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bassert((unsigned)vol < MAXVOLUMES+1);
|
||||||
|
Bassert((unsigned)lev < MAXLEVELS);
|
||||||
|
|
||||||
|
{
|
||||||
|
map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
|
||||||
|
|
||||||
|
Bfree(map->musicfn);
|
||||||
|
map->musicfn = dup_filename(fn);
|
||||||
|
check_filename_case(map->musicfn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LUNATIC
|
#ifdef LUNATIC
|
||||||
void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
|
void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
|
||||||
{
|
{
|
||||||
|
@ -2179,30 +2203,6 @@ void C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_DefineMusic(int32_t vol, int32_t lev, const char *fn)
|
|
||||||
{
|
|
||||||
if (vol==-1)
|
|
||||||
{
|
|
||||||
Bassert((unsigned)lev < MAXVOLUMES);
|
|
||||||
|
|
||||||
Bstrncpyz(EnvMusicFilename[lev], fn, BMAX_PATH);
|
|
||||||
check_filename_case(EnvMusicFilename[lev]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Bassert((unsigned)vol < MAXVOLUMES+1);
|
|
||||||
Bassert((unsigned)lev < MAXLEVELS);
|
|
||||||
|
|
||||||
{
|
|
||||||
map_t *const map = &MapInfo[(MAXLEVELS*vol)+lev];
|
|
||||||
|
|
||||||
Bfree(map->musicfn);
|
|
||||||
map->musicfn = dup_filename(fn);
|
|
||||||
check_filename_case(map->musicfn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void C_DefineQuote(int32_t qnum, const char *qstr)
|
void C_DefineQuote(int32_t qnum, const char *qstr)
|
||||||
{
|
{
|
||||||
C_AllocQuote(qnum);
|
C_AllocQuote(qnum);
|
||||||
|
@ -2961,7 +2961,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
k = *g_scriptPtr-1;
|
k = *g_scriptPtr-1;
|
||||||
|
|
||||||
if (k >= 0) // if it's background music
|
if (k >= 0 && k < MAXVOLUMES) // if it's background music
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
// get the file name...
|
// get the file name...
|
||||||
|
@ -2977,21 +2977,14 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
}
|
}
|
||||||
tempbuf[j+1] = '\0';
|
tempbuf[j+1] = '\0';
|
||||||
|
|
||||||
if (MapInfo[(k*MAXLEVELS)+i].musicfn == NULL)
|
C_DefineMusic(k, i, tempbuf);
|
||||||
MapInfo[(k*MAXLEVELS)+i].musicfn = (char *)Xcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t));
|
|
||||||
else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[(k*MAXLEVELS)+i].musicfn))
|
|
||||||
MapInfo[(k*MAXLEVELS)+i].musicfn = (char *)Xrealloc(MapInfo[(k*MAXLEVELS)+i].musicfn,(Bstrlen(tempbuf)+1));
|
|
||||||
|
|
||||||
Bstrcpy(MapInfo[(k*MAXLEVELS)+i].musicfn,tempbuf);
|
|
||||||
|
|
||||||
check_filename_case(tempbuf);
|
|
||||||
|
|
||||||
textptr += j;
|
textptr += j;
|
||||||
if (i > MAXLEVELS-1) break;
|
if (i > MAXLEVELS-1) break;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (k == -1)
|
||||||
{
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
while (C_GetKeyword() == -1)
|
while (C_GetKeyword() == -1)
|
||||||
|
|
|
@ -1726,13 +1726,13 @@ static void G_LoadMapHack(char *outbuf, const char *filename)
|
||||||
initprintf("Loaded map hack file \"%s\"\n",outbuf);
|
initprintf("Loaded map hack file \"%s\"\n",outbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void realloc_and_copy_musicfn(int32_t level_number, const char *levnamebuf, int32_t altp)
|
static void G_ReallocCopyMusicName(int32_t level_number, const char *levnamebuf, int32_t altp)
|
||||||
{
|
{
|
||||||
char **musicfn = altp ? &MapInfo[level_number].alt_musicfn : &MapInfo[level_number].musicfn;
|
char **musfn = altp ? &MapInfo[level_number].alt_musicfn : &MapInfo[level_number].musicfn;
|
||||||
int32_t dastrlen = Bstrlen(levnamebuf);
|
int32_t dastrlen = Bstrlen(levnamebuf);
|
||||||
|
|
||||||
*musicfn = (char *)Xrealloc(*musicfn, dastrlen+1);
|
*musfn = (char *)Xrealloc(*musfn, dastrlen+1);
|
||||||
Bstrcpy(*musicfn, levnamebuf);
|
Bstrcpy(*musfn, levnamebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// levnamebuf should have at least size BMAX_PATH
|
// levnamebuf should have at least size BMAX_PATH
|
||||||
|
@ -1761,7 +1761,7 @@ void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int3
|
||||||
{
|
{
|
||||||
kclose(fil);
|
kclose(fil);
|
||||||
|
|
||||||
realloc_and_copy_musicfn(level_number, levnamebuf, 1);
|
G_ReallocCopyMusicName(level_number, levnamebuf, 1);
|
||||||
}
|
}
|
||||||
else if (MapInfo[level_number].alt_musicfn != NULL)
|
else if (MapInfo[level_number].alt_musicfn != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1778,7 +1778,7 @@ void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int3
|
||||||
Bstrcpy(levnamebuf, "dethtoll.mid");
|
Bstrcpy(levnamebuf, "dethtoll.mid");
|
||||||
else kclose(fil);
|
else kclose(fil);
|
||||||
|
|
||||||
realloc_and_copy_musicfn(level_number, levnamebuf, 0);
|
G_ReallocCopyMusicName(level_number, levnamebuf, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int G_HaveUserMap(void)
|
static int G_HaveUserMap(void)
|
||||||
|
|
Loading…
Reference in a new issue