mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-25 03:11:58 +01:00
-fixed codedumps and wrong cached banners if games are switched
too fast, that may slow downs game switching but makes it way more secure
This commit is contained in:
parent
e4212aaf23
commit
558abcd0fb
@ -410,7 +410,7 @@ void CMenu::_game(bool launch)
|
|||||||
m_gameSelected = true;
|
m_gameSelected = true;
|
||||||
startGameSound = 1;
|
startGameSound = 1;
|
||||||
}
|
}
|
||||||
if (BTN_B_PRESSED && (m_btnMgr.selected(m_gameBtnFavoriteOn) || m_btnMgr.selected(m_gameBtnFavoriteOff)))
|
if(BTN_B_PRESSED && (m_btnMgr.selected(m_gameBtnFavoriteOn) || m_btnMgr.selected(m_gameBtnFavoriteOff)))
|
||||||
{
|
{
|
||||||
_hideGame();
|
_hideGame();
|
||||||
m_banner->DeleteBanner();
|
m_banner->DeleteBanner();
|
||||||
@ -597,21 +597,29 @@ void CMenu::_game(bool launch)
|
|||||||
}
|
}
|
||||||
if((startGameSound == 1 || startGameSound < -8) && (BTN_UP_REPEAT || RIGHT_STICK_UP))
|
if((startGameSound == 1 || startGameSound < -8) && (BTN_UP_REPEAT || RIGHT_STICK_UP))
|
||||||
{
|
{
|
||||||
|
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||||
|
CheckGameSoundThread();
|
||||||
m_cf.up();
|
m_cf.up();
|
||||||
startGameSound = -10;
|
startGameSound = -10;
|
||||||
}
|
}
|
||||||
if((startGameSound == 1 || startGameSound < -8) && (BTN_RIGHT_REPEAT || RIGHT_STICK_RIGHT))
|
if((startGameSound == 1 || startGameSound < -8) && (BTN_RIGHT_REPEAT || RIGHT_STICK_RIGHT))
|
||||||
{
|
{
|
||||||
|
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||||
|
CheckGameSoundThread();
|
||||||
m_cf.right();
|
m_cf.right();
|
||||||
startGameSound = -10;
|
startGameSound = -10;
|
||||||
}
|
}
|
||||||
if((startGameSound == 1 || startGameSound < -8) && (BTN_DOWN_REPEAT || RIGHT_STICK_DOWN))
|
if((startGameSound == 1 || startGameSound < -8) && (BTN_DOWN_REPEAT || RIGHT_STICK_DOWN))
|
||||||
{
|
{
|
||||||
|
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||||
|
CheckGameSoundThread();
|
||||||
m_cf.down();
|
m_cf.down();
|
||||||
startGameSound = -10;
|
startGameSound = -10;
|
||||||
}
|
}
|
||||||
if((startGameSound == 1 || startGameSound < -8) && (BTN_LEFT_REPEAT || RIGHT_STICK_LEFT))
|
if((startGameSound == 1 || startGameSound < -8) && (BTN_LEFT_REPEAT || RIGHT_STICK_LEFT))
|
||||||
{
|
{
|
||||||
|
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||||
|
CheckGameSoundThread();
|
||||||
m_cf.left();
|
m_cf.left();
|
||||||
startGameSound = -10;
|
startGameSound = -10;
|
||||||
}
|
}
|
||||||
@ -1523,15 +1531,16 @@ struct IMD5Header
|
|||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
SmartBuf gameSoundThreadStack;
|
SmartBuf gameSoundThreadStack;
|
||||||
unsigned int gameSoundThreadStackSize = (unsigned int)32768;
|
u32 gameSoundThreadStackSize = (u32)32768;
|
||||||
|
|
||||||
void CMenu::_gameSoundThread(CMenu *m)
|
void CMenu::_gameSoundThread(CMenu *m)
|
||||||
{
|
{
|
||||||
|
m->m_gameSoundHdr = m->m_cf.getHdr();
|
||||||
if(m->m_cf.getHdr()->type == TYPE_PLUGIN)
|
if(m->m_cf.getHdr()->type == TYPE_PLUGIN)
|
||||||
{
|
{
|
||||||
m_banner->DeleteBanner();
|
m_banner->DeleteBanner();
|
||||||
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize(), false);
|
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize(), false);
|
||||||
m->m_gamesound_changed = true;
|
m->m_gamesound_changed = true;
|
||||||
|
m->m_gameSoundHdr = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,6 +1587,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
|
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
|
||||||
m->m_gamesound_changed = true;
|
m->m_gamesound_changed = true;
|
||||||
disc.clear();
|
disc.clear();
|
||||||
|
m->m_gameSoundHdr = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1593,7 +1603,6 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m->m_gameSoundHdr = m->m_cf.getHdr();
|
|
||||||
m->m_gamesound_changed = false;
|
m->m_gamesound_changed = false;
|
||||||
u32 sndSize = 0;
|
u32 sndSize = 0;
|
||||||
|
|
||||||
@ -1601,13 +1610,13 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
(custom ? new Banner((u8 *)custom_bnr_file, custom_bnr_size, 0, true) :
|
(custom ? new Banner((u8 *)custom_bnr_file, custom_bnr_size, 0, true) :
|
||||||
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
(m->m_gameSoundHdr->type == TYPE_WII_GAME ? _extractBnr(m->m_gameSoundHdr) : (m->m_gameSoundHdr->type == TYPE_CHANNEL ?
|
||||||
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL)));
|
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],m->m_gameSoundHdr->settings[1])) : NULL)));
|
||||||
m->m_gameSoundHdr = NULL;
|
|
||||||
|
|
||||||
if (banner == NULL || !banner->IsValid())
|
if (banner == NULL || !banner->IsValid())
|
||||||
{
|
{
|
||||||
gprintf("no valid banner found\n");
|
gprintf("no valid banner found\n");
|
||||||
m_banner->DeleteBanner();
|
m_banner->DeleteBanner();
|
||||||
delete banner;
|
delete banner;
|
||||||
|
m->m_gameSoundHdr = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(!custom && !cached)
|
else if(!custom && !cached)
|
||||||
@ -1627,11 +1636,13 @@ void CMenu::_gameSoundThread(CMenu *m)
|
|||||||
gprintf("Failed to load banner sound!\n\n");
|
gprintf("Failed to load banner sound!\n\n");
|
||||||
if(soundBin != NULL)
|
if(soundBin != NULL)
|
||||||
delete soundBin;
|
delete soundBin;
|
||||||
|
m->m_gameSoundHdr = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m->m_gameSound.Load(soundBin, sndSize, false);
|
m->m_gameSound.Load(soundBin, sndSize, false);
|
||||||
m->m_gamesound_changed = true;
|
m->m_gamesound_changed = true;
|
||||||
|
m->m_gameSoundHdr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMenu::_playGameSound(void)
|
void CMenu::_playGameSound(void)
|
||||||
@ -1640,6 +1651,7 @@ void CMenu::_playGameSound(void)
|
|||||||
if(m_bnrSndVol == 0)
|
if(m_bnrSndVol == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||||
CheckGameSoundThread();
|
CheckGameSoundThread();
|
||||||
if(!gameSoundThreadStack.get())
|
if(!gameSoundThreadStack.get())
|
||||||
gameSoundThreadStack = smartMem2Alloc(gameSoundThreadStackSize);
|
gameSoundThreadStack = smartMem2Alloc(gameSoundThreadStackSize);
|
||||||
@ -1652,6 +1664,8 @@ void CMenu::CheckGameSoundThread()
|
|||||||
if(LWP_ThreadIsSuspended(m_gameSoundThread))
|
if(LWP_ThreadIsSuspended(m_gameSoundThread))
|
||||||
LWP_ResumeThread(m_gameSoundThread);
|
LWP_ResumeThread(m_gameSoundThread);
|
||||||
|
|
||||||
|
while(m_gameSoundHdr != NULL)
|
||||||
|
usleep(50);
|
||||||
LWP_JoinThread(m_gameSoundThread, NULL);
|
LWP_JoinThread(m_gameSoundThread, NULL);
|
||||||
m_gameSoundThread = LWP_THREAD_NULL;
|
m_gameSoundThread = LWP_THREAD_NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user