[QUESTION - BUG] Problem with the new cvGlobals.cpp architecture

jojoweb

Chimpa-Z
Joined
Jun 6, 2004
Messages
493
Location
Lyon, France
Hi !

I have a problem with the BTS's SDK. In the warlord's version of my mod, i have added some variables (like Attitudes) : GovernorAttitude, Policy, Ideology, etc... They needed tags in BasicInfo File, so i added them in the Warlord's CvGlobals.cpp file. It worked well.

But, the same variables, adapted to the new SDK's architecture seems to be rejected. When i launch a game with my modified SDK, the game crash during the initialization (after choosing difficulty, leader, land type, etc...). I have detected that the error come from the cvGlobals.cpp/CvGlobals.h files or from the CvXMLLoadUtilitySet.cpp file.

Is somebody know this type of issue ? Is new variable types prohibited in the new SDK ? Can we do something :D ?

Thx.
 
Nothing particullary, the game crash and window say me that the game must close.

What i put in the CvGlobals.cpp file :

Spoiler :

std::vector<CvInfoBase*>& CvGlobals::getIdeologyInfo()
{
return m_paIdeologyInfos;
}

CvInfoBase& CvGlobals::getIdeologyInfo(IdeologyTypes eIdeologyNum)
{
FAssert(eIdeologyNum >= 0);
FAssert(eIdeologyNum < NUM_IDEOLOGY_TYPES);
return *(m_paIdeologyInfos[eIdeologyNum]);
}

std::vector<CvInfoBase*>& CvGlobals::getPolicyInfo()
{
return m_paPolicyInfos;
}

CvInfoBase& CvGlobals::getPolicyInfo(PolicyTypes ePolicyNum)
{
FAssert(ePolicyNum >= 0);
FAssert(ePolicyNum < NUM_POLICY_TYPES);
return *(m_paPolicyInfos[ePolicyNum]);
}

std::vector<CvInfoBase*>& CvGlobals::getLoyaltyInfo()
{
return m_paLoyaltyInfos;
}

CvInfoBase& CvGlobals::getLoyaltyInfo(LoyaltyTypes eLoyaltyNum)
{
FAssert(eLoyaltyNum >= 0);
FAssert(eLoyaltyNum < NUM_LOYALTY_TYPES);
return *(m_paLoyaltyInfos[eLoyaltyNum]);
}

std::vector<CvInfoBase*>& CvGlobals::getGovernorInfo()
{
return m_paGovernorInfos;
}

CvInfoBase& CvGlobals::getGovernorInfo(GovernorTypes eGovernorNum)
{
FAssert(eGovernorNum >= 0);
FAssert(eGovernorNum < NUM_GOVERNOR_TYPES);
return *(m_paGovernorInfos[eGovernorNum]);
}

[...]

deleteInfoArray(m_paIdeologyInfos);
deleteInfoArray(m_paPolicyInfos);
deleteInfoArray(m_paLoyaltyInfos);
deleteInfoArray(m_paGovernorInfos);


In the CvGlobals.h file :

Spoiler :
std::vector<CvInfoBase*>& getIdeologyInfo();
DllExport CvInfoBase& getIdeologyInfo(IdeologyTypes eIdeologyNum);

std::vector<CvInfoBase*>& getPolicyInfo();
DllExport CvInfoBase& getPolicyInfo(PolicyTypes ePolicyNum);

std::vector<CvInfoBase*>& getLoyaltyInfo();
DllExport CvInfoBase& getLoyaltyInfo(LoyaltyTypes eLoyaltyNum);

std::vector<CvInfoBase*>& getGovernorInfo();
DllExport CvInfoBase& getGovernorInfo(GovernorTypes eGovernorNum);

[...]

std::vector<CvInfoBase*> m_paIdeologyInfos;
std::vector<CvInfoBase*> m_paPolicyInfos;
std::vector<CvInfoBase*> m_paLoyaltyInfos;
std::vector<CvInfoBase*> m_paGovernorInfos;


And in the CvXMLLoadUtilitySet.cpp file :

Spoiler :
LoadGlobalClassInfo(GC.getIdeologyInfo(), "CIV4IdeologyInfos", "BasicInfos", "Civ4IdeologyInfos/IdeologyInfos/IdeologyInfo", false);
LoadGlobalClassInfo(GC.getPolicyInfo(), "CIV4PolicyInfos", "BasicInfos", "Civ4PolicyInfos/PolicyInfos/PolicyInfo", false);
LoadGlobalClassInfo(GC.getLoyaltyInfo(), "CIV4LoyaltyInfos", "BasicInfos", "Civ4LoyaltyInfos/LoyaltyInfos/LoyaltyInfo", false);
LoadGlobalClassInfo(GC.getGovernorInfo(), "CIV4GovernorInfos", "BasicInfos", "Civ4GovernorInfos/GovernorInfos/GovernorInfo", false);


In CyGlobalContext.cpp file :

Spoiler :
CvInfoBase* CyGlobalContext::getIdeologyInfo(int i) const
{
return (i>=0 && i<NUM_IDEOLOGY_TYPES) ? &GC.getIdeologyInfo((IdeologyTypes)i) : NULL;
}

CvInfoBase* CyGlobalContext::getPolicyInfo(int i) const
{
return (i>=0 && i<NUM_POLICY_TYPES) ? &GC.getPolicyInfo((PolicyTypes)i) : NULL;
}

CvInfoBase* CyGlobalContext::getLoyaltyInfo(int i) const
{
return (i>=0 && i<NUM_LOYALTY_TYPES) ? &GC.getLoyaltyInfo((LoyaltyTypes)i) : NULL;
}

CvInfoBase* CyGlobalContext::getGovernorInfo(int i) const
{
return (i>=0 && i<NUM_GOVERNOR_TYPES) ? &GC.getGovernorInfo((GovernorTypes)i) : NULL;
}


In the CyGlobalContext.h file :

Spoiler :
CvInfoBase* getIdeologyInfo(int i) const;
CvInfoBase* getPolicyInfo(int i) const;
CvInfoBase* getLoyaltyInfo(int i) const;
CvInfoBase* getGovernorInfo(int i) const;


and in the CyGlobalContextInterface3.cpp file :

Spoiler :
.def("getIdeologyInfo", &CyGlobalContext::getIdeologyInfo, python::return_value_policy<python::reference_existing_object>(), "IdeologyInfo (int id)")
.def("getPolicyInfo", &CyGlobalContext::getPolicyInfo, python::return_value_policy<python::reference_existing_object>(), "PolicyInfo (int id)")
.def("getLoyaltyInfo", &CyGlobalContext::getLoyaltyInfo, python::return_value_policy<python::reference_existing_object>(), "LoyaltyInfo (int id)")
.def("getGovernorInfo", &CyGlobalContext::getGovernorInfo, python::return_value_policy<python::reference_existing_object>(), "GovernorInfo (int id)")


I will try a last thing : i added this codes after Attitude and before Memory. Perhaps i must change the order. But i don't thing that it will change anything ^^. Perhaps i made an error too.


Edit : i tried to modify the order, it didn't change anything.
 
Many of these Info types apear to be linked with hard coded Enums in the Dll, any mismatch between xml and Dll results in a crash, I belive changes in BtS makes it more sensitive to this then Warlords was. In Warlords only having a greater number of types in the Enum then were loaded in xml caused a crash, in BtS have more OR less crashes you which is what your experiencing.
 
Before anything else, I'd recommend doing a clean recompile (if you haven't already). I've had similar problems when adding methods to classes, and often this fixes the problem. I don't know if the problem exists when using CodeBlocks as a compiler, but using the Makefile provided in one of the tutorials here does not correctly determine which objects needs to be recompiled when various headers are modified.
 
Impaler ==> i have the same number of types in the enum files and in he xml files.

macsbug ==> i rebuilt many and many times the sdk, and it didn't change anything.

I'm totally desperate ^^.
 
When i launch a game with my modified SDK, the game crash during the initialization (after choosing difficulty, leader, land type, etc...). I have detected that the error come from the cvGlobals.cpp/CvGlobals.h files or from the CvXMLLoadUtilitySet.cpp file.

Assuming that you've put your "LoadGlobalClassInfo" calls into CvXMLLoadUtility::LoadBasicInfos(), this is called even before the PreMenuGlobals are loaded, so it's unlikely that the problem is in the code you posted. (Providing it's reading in the data you want.)

I'd guess that it has something to do with the initialization of your chosen leaders or civs.

Edit: What shows up in your xml.log?
 
Impaler ==> i have the same number of types in the enum files and in he xml files.

macsbug ==> i rebuilt many and many times the sdk, and it didn't change anything.

I'm totally desperate ^^.

In that case (you did do this by deleting the Final_Release folder I'm assuming) I'd recommend hooking up a debugger to Civ4 prior to the crash. Ideally, this would use a debug build of the DLL, although if that is not possible you may have some success hooking up debugger to the release build and taking a careful look at the assembly code around the crash. If you're reasonably familiar with that sort of thing, you should be able to work out more or less where the crash occurs.

Alternatively, if you want to upload the modified .cpp and .h files I'd be willing to rebuild the DLL in debug mode and let you know where the crash occurs.
 
Arglll, i'm sorry i made an error : the problem don't come from globals files (shame on me) :blush: . I made a verification thanks to all of you and the problem seems to come from an other file. Between Fractal and GameAI ^^. I continue to search. Thank a lot for your support ;-)
 
Back
Top Bottom