CopyNonDefaults Issue (WoC True Modular)

Valkrionn

The Hamster King
Joined
May 23, 2008
Messages
14,450
Location
Crestview FL
Alright, we've had issues for a while in RifE (and FF, and WM afaik) with modular events. I've dug into it finally and found the cause.... But have no idea how to fix it.

The issue is with a ReadPass2 function. I've tried to find other examples of this method in the code... But it only appears with Events, Techs, and Projects, and in each case involves the exact tags that screw up modular loading for those files. :lol: So, I really don't know what's wrong with it.

Code:
void CvEventInfo::copyNonDefaultsReadPass2(CvEventInfo* pClassInfo, CvXMLLoadUtility* pXML)
{
	bool bOver = pClassInfo->isForceOverwrite();
	CvString cDefault = CvString::format("").GetCString();
	CvWString wDefault = CvWString::format(L"").GetCString();

	if(!m_piAdditionalEventChance)									pXML->InitList(&m_piAdditionalEventChance, GC.getNumEventInfos(), 0);
	if(!m_piAdditionalEventTime)									pXML->InitList(&m_piAdditionalEventTime, GC.getNumEventInfos(), 0);
	if(!m_piClearEventChance)										pXML->InitList(&m_piClearEventChance, GC.getNumEventInfos(), 0);
	for (int i = 0; i < GC.getNumEventInfos(); ++i)
	{
		if(bOver || pClassInfo->getAdditionalEventChance(i)	!= 0)	m_piAdditionalEventChance[i]	= pClassInfo->getAdditionalEventChance(i);
		if(bOver || pClassInfo->getAdditionalEventTime(i)	!= 0)	m_piAdditionalEventTime[i]		= pClassInfo->getAdditionalEventTime(i);
		if(bOver || pClassInfo->getClearEventChance(i)		!= 0)	m_piClearEventChance[i]			= pClassInfo->getClearEventChance(i);
	} 
}

As an idea of what it causes... It looks like it's loading maxints into the list. It does this even for completely unmodified events.

283bb8fc5e3a4f56abbdb16.png
 
Readpass2 is used to handle the case where a symbol is defined at one point in a file, but used earlier in the same file. If it executes at the end of reading a file, then it would not work at all for modular files. In modular files, a symbol may be defined in one file, but used in a different file of the same type. Is there any evidence that readpass2 data is handled correctly by WOC?
 
Solved. It was loading files like this:
Original XML file
Original XML file pass2
Modular files
Modular files pass2.

When it was doing pass2 for original XML file it was only adding chances for original XML files. The variables didn't store anything for the modular events, which of course caused issues (invalid index).
 
Back
Top Bottom