mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Remove usage of strcpy and use _s versions of file opening
This commit is contained in:
parent
65f78a3653
commit
3a22f1b916
|
|
@ -1321,26 +1321,23 @@ void SoundEngine::playMusicUpdate()
|
||||||
const bool isCD = (m_musicID >= m_iStream_CD_1);
|
const bool isCD = (m_musicID >= m_iStream_CD_1);
|
||||||
const char* folder = isCD ? "cds/" : "music/";
|
const char* folder = isCD ? "cds/" : "music/";
|
||||||
|
|
||||||
FILE* pFile = fopen((char*)m_szStreamName, "rb");
|
FILE* pFile = nullptr;
|
||||||
if (pFile)
|
if (fopen_s(&pFile, reinterpret_cast<char*>(m_szStreamName), "rb") == 0 && pFile)
|
||||||
{
|
{
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* extensions[] = { ".wav" }; // only wav works outside of binka files to my knowledge, i've only tested ogg, wav, mp3 and only wav worked out of the bunch
|
const char* extensions[] = { ".wav" }; // only wav works outside of binka files to my knowledge, i've only tested ogg, wav, mp3 and only wav worked out of the bunch
|
||||||
|
int count = sizeof(extensions) / sizeof(extensions[0]);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
strcpy((char*)m_szStreamName, m_szMusicPath);
|
int n = sprintf_s(reinterpret_cast<char*>(m_szStreamName), 512, "%s%s%s%s", m_szMusicPath, folder, m_szStreamFileA[m_musicID], extensions[i]);
|
||||||
strcat((char*)m_szStreamName, folder);
|
if (n < 0) continue;
|
||||||
strcat((char*)m_szStreamName, m_szStreamFileA[m_musicID]);
|
|
||||||
strcat((char*)m_szStreamName, extensions[i]);
|
|
||||||
|
|
||||||
pFile = fopen((char*)m_szStreamName, "rb");
|
if (fopen_s(&pFile, reinterpret_cast<char*>(m_szStreamName), "rb") == 0 && pFile)
|
||||||
if (pFile) // probably a better way to check if the file exists
|
|
||||||
{
|
{
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
found = true;
|
found = true;
|
||||||
|
|
@ -1354,7 +1351,6 @@ void SoundEngine::playMusicUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.DebugPrintf("Starting streaming - %s\n",m_szStreamName);
|
app.DebugPrintf("Starting streaming - %s\n",m_szStreamName);
|
||||||
|
|
||||||
// Don't actually open in this thread, as it can block for ~300ms.
|
// Don't actually open in this thread, as it can block for ~300ms.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue