-added support for banners without existing sound

This commit is contained in:
fix94.1 2012-08-13 05:09:40 +00:00
parent 0e5a5b4abd
commit e685842c59

View File

@ -1533,6 +1533,7 @@ u32 gameSoundThreadStackSize = (u32)32768;
void CMenu::_gameSoundThread(CMenu *m) void CMenu::_gameSoundThread(CMenu *m)
{ {
m->m_gameSoundHdr = m->m_cf.getHdr(); m->m_gameSoundHdr = m->m_cf.getHdr();
m->m_gamesound_changed = false;
if(m->m_cf.getHdr()->type == TYPE_PLUGIN) if(m->m_cf.getHdr()->type == TYPE_PLUGIN)
{ {
@ -1566,6 +1567,7 @@ void CMenu::_gameSoundThread(CMenu *m)
cached_bnr_file = (u8*)malloc(cached_bnr_size); cached_bnr_file = (u8*)malloc(cached_bnr_size);
if(cached_bnr_file == NULL) if(cached_bnr_file == NULL)
{ {
m->m_gameSound->FreeMemory();
m_banner->DeleteBanner(); m_banner->DeleteBanner();
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
return; return;
@ -1605,6 +1607,7 @@ void CMenu::_gameSoundThread(CMenu *m)
custom_bnr_file = (u8*)malloc(custom_bnr_size); custom_bnr_file = (u8*)malloc(custom_bnr_size);
if(custom_bnr_file == NULL) if(custom_bnr_file == NULL)
{ {
m->m_gameSound->FreeMemory();
m_banner->DeleteBanner(); m_banner->DeleteBanner();
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
return; return;
@ -1613,7 +1616,6 @@ void CMenu::_gameSoundThread(CMenu *m)
fclose(fp); fclose(fp);
} }
} }
m->m_gamesound_changed = false;
u32 sndSize = 0; u32 sndSize = 0;
u8 *soundBin = NULL; u8 *soundBin = NULL;
@ -1626,8 +1628,9 @@ void CMenu::_gameSoundThread(CMenu *m)
m_banner->LoadBanner(banner, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get()); m_banner->LoadBanner(banner, &m->m_vid, m_wbf1_font.get(), m_wbf2_font.get());
soundBin = banner->GetFile((char *)"sound.bin", &sndSize); soundBin = banner->GetFile((char *)"sound.bin", &sndSize);
} }
if(banner == NULL || soundBin == NULL || sndSize == 0) else
{ {
m->m_gameSound->FreeMemory();
m_banner->DeleteBanner(); m_banner->DeleteBanner();
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
delete banner; delete banner;
@ -1640,15 +1643,15 @@ void CMenu::_gameSoundThread(CMenu *m)
fclose(fp); fclose(fp);
} }
delete banner; delete banner;
if(soundBin != NULL)
{
if(((IMD5Header *)soundBin)->fcc == 'IMD5') if(((IMD5Header *)soundBin)->fcc == 'IMD5')
{ {
u32 newSize = 0; u32 newSize = 0;
u8 *newSound = DecompressCopy(soundBin, sndSize, &newSize); u8 *newSound = DecompressCopy(soundBin, sndSize, &newSize);
if(newSound == NULL || newSize == 0 || !m->m_gameSound->Load(newSound, newSize)) if(newSound == NULL || newSize == 0 || !m->m_gameSound->Load(newSound, newSize))
{ {
if(newSound != NULL) m->m_gameSound->FreeMemory();
free(newSound);
m_banner->DeleteBanner(); m_banner->DeleteBanner();
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
return; return;
@ -1661,7 +1664,17 @@ void CMenu::_gameSoundThread(CMenu *m)
if(m->m_gameSound->IsLoaded()) if(m->m_gameSound->IsLoaded())
m->m_gamesound_changed = true; m->m_gamesound_changed = true;
else else
{
m->m_gameSound->FreeMemory();
m_banner->DeleteBanner(); m_banner->DeleteBanner();
}
}
else
{
gprintf("WARNING: No sound found in banner!\n");
m->m_gamesound_changed = true;
m->m_gameSound->FreeMemory();
}
m->m_gameSoundHdr = NULL; m->m_gameSoundHdr = NULL;
} }