PPQ_Purple
Purple Cube (retired)
- Joined
- Oct 11, 2008
- Messages
- 5,764
Alright, here is some code I've made. I've confirmed that it builds but I did not have the time to properly test it in the game. So feel free to do that and tell me if everything works.
This should give you two lists of songs instead of one, with war and peace songs being separated out based on having the words "WAR" in their name or not. Than you just have to modify getNextSoundtrack to pick from one or the other based on the state of the game.
I'll leave that bit up to you as it's just busywork and I don't have the time to do it right now. But all you have to do is replicate the getNumSoundtracks() function into two clones, one for each of the new arrays and than add an if condition to getNextSoundtrack to pick from one or the other.
Spoiler CvEraInfo in CvInfos.h :
Code:
// Arrays
int* m_paiSoundtracks;
int* m_paiCitySoundscapeSciptIds;
// Two new lines added here
int* m_peaceSoundtracks;
int* m_warSoundtracks;
Spoiler end of CvEraInfo::read in CvInfos.cpp :
Code:
if (gDLL->getXMLIFace()->SetToChildByTagName(pXML->GetXML(), "EraInfoSoundtracks"))
{
CvString* pszSoundTrackNames = NULL;
pXML->SetStringList(&pszSoundTrackNames, &m_iNumSoundtracks);
if (m_iNumSoundtracks > 0)
{
//m_paiSoundtracks = new int[m_iNumSoundtracks];
int j;
int numberOfPeaceSongs = 0, numberOfWarSongs = 0;
for (j = 0; j < m_iNumSoundtracks; j++)
{
if (pszSoundTrackNames[j].find("WAR") != std::string::npos)
{
numberOfWarSongs++;
}
else
{
numberOfPeaceSongs++;
}
}
m_peaceSoundtracks = new int[numberOfPeaceSongs];
m_warSoundtracks = new int[numberOfWarSongs];
int peaceCounter = 0, warCounter = 0;
for (j=0;j<m_iNumSoundtracks;j++)
{
if (pszSoundTrackNames[j].find("WAR") != std::string::npos)
{
m_warSoundtracks[warCounter] = ((!gDLL->getAudioDisabled()) ? gDLL->getAudioTagIndex(pszSoundTrackNames[j], AUDIOTAG_2DSCRIPT) : -1);
warCounter++;
}
else
{
m_warSoundtracks[peaceCounter] = ((!gDLL->getAudioDisabled()) ? gDLL->getAudioTagIndex(pszSoundTrackNames[j], AUDIOTAG_2DSCRIPT) : -1);
peaceCounter++;
}
}
}
else
{
m_paiSoundtracks = NULL;
}
gDLL->getXMLIFace()->SetToParent(pXML->GetXML());
SAFE_DELETE_ARRAY(pszSoundTrackNames);
}
This should give you two lists of songs instead of one, with war and peace songs being separated out based on having the words "WAR" in their name or not. Than you just have to modify getNextSoundtrack to pick from one or the other based on the state of the game.
I'll leave that bit up to you as it's just busywork and I don't have the time to do it right now. But all you have to do is replicate the getNumSoundtracks() function into two clones, one for each of the new arrays and than add an if condition to getNextSoundtrack to pick from one or the other.