The Modding Q&A Thread

You need Victory.setGoal(iPlayer, iGoal, iValue) for this, where iGoal is 0, 1 or 2 representing the goals and iValue = 1 means goal completed.
 
How do I disable dynamic civ names?

Where is the code that uses civSpreadFactor and settlersMaps from CvRhyes.cpp?
 
does the barbs.py checkTurn method stop checking for that turn once it places a barb spawn?

also, do you have to make the excel city name maps by hand or is there a way of exporting the data from a WB save with landmark/sign info?

re: dynamic names
I found it really easy to just delete the civ and religion specific parts and use the kingdom>empire part for all civs. thats modding SoI, not RFC.
 
does the barbs.py checkTurn method stop checking for that turn once it places a barb spawn?

also, do you have to make the excel city name maps by hand or is there a way of exporting the data from a WB save with landmark/sign info?

re: dynamic names
I found it really easy to just delete the civ and religion specific parts and use the kingdom>empire part for all civs. thats modding SoI, not RFC.
yeah but right now i'm focusing on the important parts first, then last will be stuff that won't directly affect gameplay(art, dynamic names)
 
does the barbs.py checkTurn method stop checking for that turn once it places a barb spawn?

No, no function stops until it ends, a return statement is called, or an exception (error) is raised.

also, do you have to make the excel city name maps by hand or is there a way of exporting the data from a WB save with landmark/sign info?

Look at the last post of my tech documentation for SoI - I added a python script that generates basic water/land/peak data based on WB; you can copy it to excel and add colors to have the basic sheet you can use to create others. I haven't touched landmarks, but having water/land data should be enough to know exactly where stuff is.

re: dynamic names
I found it really easy to just delete the civ and religion specific parts and use the kingdom>empire part for all civs. thats modding SoI, not RFC.

In SoI dynamic civs are in python so it is that easy. In RFC you have to edit the DLL in many places - look for "dynamic civ names" keyword in C++ sourcecode (with windows search narrowed to CvGameCoreDLL folder).
 
How do I make a civ only attack specific areas? For example, in my Africa scenario Arabia is attacking Antioch instead of egypt, even though egypt is high in their settler & war maps and antioch is low.
 
I'm removing some unneeded units and buildings from my mod and it seems that I have to remove them one at a time and run the game between each removal or I get a ctd with no error message. is this normal?

edit: actually it seems I get crashes sooner or later any time I try to remove units or buildings, even one at a time. I am editing Consts.py, Civ4UnitInfos and Civ4UnitClassInfos and I'm getting no python or xml error messages. what am I missing?
 
- Buildings also have indexes in CvRhyes.h
- Compile a debug DLL to learn what exactly is causing the crash; most of the time you'll get a failed assert or access violation just before the CTD.
 
the building references in CvRhyes.h were removed some time ago and their removal seemed to cause no problems.

I made the debug DLL and got a bunch of assert failures. some I understood and fixed. here are the ones I didn't understand:

these 3 occur while loading:

Spoiler :
Assert Failed

File: CvGlobals.cpp
Line: 3612
Expression: strcmp(szType, "NONE")==0 || strcmp(szType, "")==0
Message: info type ERA_ANCIENT not found, Current XML file is: xml\GameInfo/CIV4GraphicOptionInfos.xm

Assert Failed

File: CvXMLLoadUtilityGet.cpp
Line: 656
Expression: false
Message: Error in GetChildXmlVal function, unable to find a child node


Assert Failed

File: CvXMLLoadUtilitySet.cpp
Line: 1301
Expression: bSuccess
Message:


then the civ selection screen comes up, I pick the 1st civ, more loading and the map and dawn of man screen comes up, I click continue, a slight pause with everything looking normal, about 2 seconds, then ctd with no error. the funny thing is this is running a version that runs fine for hundreds of turns on the release DLL.

if I select a later starting civ I get these before the auto-play starts:

Spoiler :
Assert Failed

File: CvCity.cpp
Line: 10561
Expression: eIndex >= 0
Message: eIndex expected to be >= 0

Assert Failed

File: CvUnitAI.cpp
Line: 12884
Expression: !atPlot(pBestPlot)
Message:

and these mutiple times during the auto-play:

Spoiler :
Assert Failed

File: CvArea.cpp
Line: 643
Expression: getPower(eIndex) >= 0
Message:

Assert Failed

File: CvPlayer.cpp
Line: 13526
Expression: isHuman() || isBarbarian() || ((getGold() + iGoldChange) >= 0) || isAnarchy()
Message:


and then the same ctd as above.
 
Many asserts happen due to the way RFC is set up and are harmless. From the above list, everything can be ignored, except this one:

Assert Failed

File: CvCity.cpp
Line: 10561
Expression: eIndex >= 0
Message: eIndex expected to be >= 0

You'd have to check what exactly is at line 10561 in your CvCity.cpp, but looking at SoI's files this is probably isHasReligion or setHasReligion, right? It means that something (i.e. Python script) checks for, or tries to put a non-existing Religion in a city. Stuff like that can cause a CTD.

To get more info attach a debugger, Asaf made a tutorial on how to do it: http://forums.civfanatics.com/showthread.php?t=405444#BeforeDebugging

With a debugger you'll be able to stop the game at a given point (i.e. when the assert fires) and then go step by step, following every line of code to see what happens, and at which exact line the game crashes. Even if it's not related to that religion part, it should give you useful info.
 
How do I make a civ only attack specific areas? For example, in my Africa scenario Arabia is attacking Antioch instead of egypt, even though egypt is high in their settler & war maps and antioch is low.

message too short

edit: found it, it is in CvPlayerAI.cpp in the int ai_targetcityvalue, basically it is determined by settler maps. bigger value = higher chance of attacking


anyone know why the smiley faces that indicate stabily aren't showing in my modmod? it looks like this:

 
I can run the debugger in autoplay and have fixed some bugs there but when the main screen comes up I get this:

Run-Time Check Failure #2 - Stack around the variable 'szBuffer' was corrupted.

and it occurs in CvPlot, here:

Spoiler :
Code:
// returns region name as translated wstring
CvWString CvPlot::getRegionName(bool bTooltip) const
{
	char szBuffer[20];
	CvWString szResult;
	if (bTooltip)
		sprintf(szBuffer, "TXT_KEY_REGION_TOOLTIP_%d", regionMap[EARTH_Y - 1 - getY_INLINE()][getX_INLINE()]);
	else
		sprintf(szBuffer, "TXT_KEY_REGION_%d", regionMap[EARTH_Y - 1 - getY_INLINE()][getX_INLINE()]);
	szResult = gDLL->getText(szBuffer);
	return gDLL->getText(szResult);
}

the region tooltips seem to work fine running a regular dll.
 
anyone know why the smiley faces that indicate stabily aren't showing in my modmod? it looks like this:


You need to copy font files from RFC, located in Assets/Res/Fonts
 
I can run the debugger in autoplay and have fixed some bugs there but when the main screen comes up I get this:

Run-Time Check Failure #2 - Stack around the variable 'szBuffer' was corrupted.

and it occurs in CvPlot, here:

Bad news. This is unrelated to the tooltip, it's just the first place when the stack gets corrupted when the screen loads. I get it the exact same result whenever I screw something up with new variables. Unfortunately it's impossible to tell what is the cause of stack corruption. For me only revert worked, though I knew more or less what it was (some new vars I added to CvPlayer & CvInfo). Think of any stuff you've been adding/editing in the DLL, particularly variables that are class members. It's possible that some are not properly saved or initialized.
 
well I went back and made a debug DLL with the unmodded SoI source files plus Asaf's project files and ran SoI with it and got the same result as above. I also got the same result with all my backups.
 
well I went back and made a debug DLL with the unmodded SoI source files plus Asaf's project files and ran SoI with it and got the same result as above. I also got the same result with all my backups.

What, stack corruption? It doesn't happen in SoI and it means CTD while SoI works quite fine atm. Most asserts are fine and you'll get them in RFC & SoI, but you need to get to a point where there's no stack corruption.
 
yes I did get the stack corruption attempting to run SoI. perhaps I am not doing the debug thing properly. I have to use the "attach to process" method, launching from visual studio gives a message about not finding the path. I will try it again. my mod also runs fine as far as I can tell, on a release DLL, no crashes. so to be clear my situation is both mods (mine and SoI) run fine on a release DLL and both get stack corruption on a debug DLL.
 
yes I did get the stack corruption attempting to run SoI. perhaps I am not doing the debug thing properly. I have to use the "attach to process" method, launching from visual studio gives a message about not finding the path. I will try it again. my mod also runs fine as far as I can tell, on a release DLL, no crashes. so to be clear my situation is both mods (mine and SoI) run fine on a release DLL and both get stack corruption on a debug DLL.

There's definitely no stack corruption when I debug SoI. I do it without attaching to process, instead running it from the compiler (it works if proper path is given in the configuration, but that's in Asaf's guide).

For me stack corruption in SoI always translates to CTD on game load with final release DLL. I thought your original problem was CTD?
 
I did have a ctd but I found it with the debugger, which runs fine in the autoplay. it was just a missing art define. the stack corruption only occurs when you click "continue" on the dawn of man popup. I think I must be doing something wrong in setting up the debugger. I checked the path to the CivBeyondSword.exe and its definitely correct, I don't know why visual studio can't find it. I am trying again with a fresh download of SoI and Asaf's files.
 
Top Bottom