Fix support for .def defined highres music replacements

git-svn-id: https://svn.eduke32.com/eduke32@1475 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-07-28 08:28:58 +00:00
parent c9c02c2773
commit 796919268c
5 changed files with 37 additions and 28 deletions

View file

@ -1048,7 +1048,7 @@ typedef struct {
typedef struct { typedef struct {
int32_t partime, designertime; int32_t partime, designertime;
char *name, *filename, *musicfn, *musicfn1; char *name, *filename, *musicfn, *alt_musicfn;
mapstate_t *savedstate; mapstate_t *savedstate;
} map_t; } map_t;

View file

@ -8416,7 +8416,7 @@ static void G_HandleLocalKeys(void)
if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL) if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL)
{ {
if (S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex)) if (S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex))
Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].musicfn1[0]); Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]);
else else
Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].musicfn[0]);
P_DoQuote(26,g_player[myconnectindex].ps); P_DoQuote(26,g_player[myconnectindex].ps);
@ -8636,8 +8636,8 @@ FAKE_F3:
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0) if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
{ {
KB_ClearKeyDown(sc_F5); KB_ClearKeyDown(sc_F5);
if (MapInfo[(uint8_t)g_musicIndex].musicfn1 != NULL) if (MapInfo[(uint8_t)g_musicIndex].alt_musicfn != NULL)
Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].musicfn1[0]); Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]);
else if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL) else if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL)
{ {
Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].musicfn[0]);
@ -9166,9 +9166,9 @@ static int32_t AL_DefineMusic(char *ID,char *name)
ID=MapInfo[sel].musicfn; ID=MapInfo[sel].musicfn;
} }
MapInfo[sel].musicfn1=makename(MapInfo[sel].musicfn1,name,ID); MapInfo[sel].alt_musicfn=makename(MapInfo[sel].alt_musicfn,name,ID);
// initprintf("%-15s | ",ID); // initprintf("%-15s | ",ID);
// initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].musicfn1); // initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].alt_musicfn);
// S_PlayMusic(ID,sel); // S_PlayMusic(ID,sel);
return 0; return 0;
} }
@ -10187,7 +10187,7 @@ static void G_FreeMemory(void)
if (MapInfo[i].name != NULL) Bfree(MapInfo[i].name); if (MapInfo[i].name != NULL) Bfree(MapInfo[i].name);
if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename); if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename);
if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn); if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn);
if (MapInfo[i].musicfn1 != NULL) Bfree(MapInfo[i].musicfn1); if (MapInfo[i].alt_musicfn != NULL) Bfree(MapInfo[i].alt_musicfn);
if (MapInfo[i].savedstate != NULL) G_FreeMapState(i); if (MapInfo[i].savedstate != NULL) G_FreeMapState(i);
} }

View file

@ -427,7 +427,7 @@ void G_CacheMapData(void)
return; return;
S_PauseMusic(1); S_PauseMusic(1);
if (MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1) if (MapInfo[MAXVOLUMES*MAXLEVELS+2].alt_musicfn)
{ {
S_StopMusic(); S_StopMusic();
S_PlayMusic(&EnvMusicFilename[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus S_PlayMusic(&EnvMusicFilename[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus
@ -1770,16 +1770,16 @@ int32_t G_EnterLevel(int32_t g)
if (fil > -1) if (fil > -1)
{ {
kclose(fil); kclose(fil);
if (MapInfo[ud.m_level_number].musicfn1 == NULL) if (MapInfo[ud.m_level_number].alt_musicfn == NULL)
MapInfo[ud.m_level_number].musicfn1 = Bcalloc(Bstrlen(levname)+1,sizeof(uint8_t)); MapInfo[ud.m_level_number].alt_musicfn = Bcalloc(Bstrlen(levname)+1,sizeof(uint8_t));
else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.m_level_number].musicfn1)) else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.m_level_number].alt_musicfn))
MapInfo[ud.m_level_number].musicfn1 = Brealloc(MapInfo[ud.m_level_number].musicfn1,(Bstrlen(levname)+1)); MapInfo[ud.m_level_number].alt_musicfn = Brealloc(MapInfo[ud.m_level_number].alt_musicfn,(Bstrlen(levname)+1));
Bstrcpy(MapInfo[ud.m_level_number].musicfn1,levname); Bstrcpy(MapInfo[ud.m_level_number].alt_musicfn,levname);
} }
else if (MapInfo[ud.m_level_number].musicfn1 != NULL) else if (MapInfo[ud.m_level_number].alt_musicfn != NULL)
{ {
Bfree(MapInfo[ud.m_level_number].musicfn1); Bfree(MapInfo[ud.m_level_number].alt_musicfn);
MapInfo[ud.m_level_number].musicfn1 = NULL; MapInfo[ud.m_level_number].alt_musicfn = NULL;
} }
p[1]='m'; p[1]='m';

View file

@ -458,16 +458,16 @@ int32_t G_LoadPlayer(int32_t spot)
if (fil > -1) if (fil > -1)
{ {
kclose(fil); kclose(fil);
if (MapInfo[ud.level_number].musicfn1 == NULL) if (MapInfo[ud.level_number].alt_musicfn == NULL)
MapInfo[ud.level_number].musicfn1 = Bcalloc(Bstrlen(levname)+1,sizeof(uint8_t)); MapInfo[ud.level_number].alt_musicfn = Bcalloc(Bstrlen(levname)+1,sizeof(uint8_t));
else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.level_number].musicfn1)) else if ((Bstrlen(levname)+1) > sizeof(MapInfo[ud.level_number].alt_musicfn))
MapInfo[ud.level_number].musicfn1 = Brealloc(MapInfo[ud.level_number].musicfn1,(Bstrlen(levname)+1)); MapInfo[ud.level_number].alt_musicfn = Brealloc(MapInfo[ud.level_number].alt_musicfn,(Bstrlen(levname)+1));
Bstrcpy(MapInfo[ud.level_number].musicfn1,levname); Bstrcpy(MapInfo[ud.level_number].alt_musicfn,levname);
} }
else if (MapInfo[ud.level_number].musicfn1 != NULL) else if (MapInfo[ud.level_number].alt_musicfn != NULL)
{ {
Bfree(MapInfo[ud.level_number].musicfn1); Bfree(MapInfo[ud.level_number].alt_musicfn);
MapInfo[ud.level_number].musicfn1 = NULL; MapInfo[ud.level_number].alt_musicfn = NULL;
} }
p[1]='m'; p[1]='m';
@ -488,7 +488,7 @@ int32_t G_LoadPlayer(int32_t spot)
Bstrcpy(MapInfo[ud.level_number].musicfn,levname); Bstrcpy(MapInfo[ud.level_number].musicfn,levname);
} }
if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL && (i != g_musicIndex || MapInfo[MAXVOLUMES*MAXLEVELS+2].musicfn1)) if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL && (i != g_musicIndex || MapInfo[MAXVOLUMES*MAXLEVELS+2].alt_musicfn))
{ {
S_StopMusic(); S_StopMusic();
S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex); S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex);

View file

@ -293,8 +293,8 @@ void _playmusic(const char *fn)
int32_t S_PlayMusic(const char *fn, const int32_t sel) int32_t S_PlayMusic(const char *fn, const int32_t sel)
{ {
g_musicSize=0; g_musicSize=0;
if (MapInfo[sel].musicfn1 != NULL) if (MapInfo[sel].alt_musicfn != NULL)
_playmusic(MapInfo[sel].musicfn1); _playmusic(MapInfo[sel].alt_musicfn);
if (!g_musicSize) if (!g_musicSize)
{ {
_playmusic(fn); _playmusic(fn);
@ -306,12 +306,18 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
int32_t S_PlayMusic(const char *fn, const int32_t sel) int32_t S_PlayMusic(const char *fn, const int32_t sel)
{ {
char *ofn = (char *)fn;
int32_t fp; int32_t fp;
char * testfn, * extension; char * testfn, * extension;
int32_t alt = 0;
if (ud.config.MusicToggle == 0) return 0; if (ud.config.MusicToggle == 0) return 0;
if (ud.config.MusicDevice < 0) return 0; if (ud.config.MusicDevice < 0) return 0;
if (MapInfo[sel].alt_musicfn != NULL)
alt = (int32_t)(fn = MapInfo[sel].alt_musicfn);
testfn = (char *) malloc(strlen(fn) + 5); testfn = (char *) malloc(strlen(fn) + 5);
strcpy(testfn, fn); strcpy(testfn, fn);
extension = strrchr(testfn, '.'); extension = strrchr(testfn, '.');
@ -335,6 +341,9 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
// just use what we've been given // just use what we've been given
fp = kopen4loadfrommod((char *)fn, 0); fp = kopen4loadfrommod((char *)fn, 0);
if (alt && fp < 0)
fp = kopen4loadfrommod(ofn, 0);
} }
while (0); while (0);
@ -359,7 +368,7 @@ int32_t S_PlayMusic(const char *fn, const int32_t sel)
FX_MUSIC_PRIORITY, MUSIC_ID); FX_MUSIC_PRIORITY, MUSIC_ID);
MusicIsWaveform = 1; MusicIsWaveform = 1;
} }
return 0; return (alt != 0);
} }
void S_StopMusic(void) void S_StopMusic(void)