Modder's Documentation

I just wanted to swap the sounds of the Entertainer and Bard. It sounds easy, but apparently not so. I got as far as SpySurrVox in Sounds/Units. At least that's where the AudioDefines says it is. Where is it really?
 
I just wanted to swap the sounds of the Entertainer and Bard. It sounds easy, but apparently not so. I got as far as SpySurrVox in Sounds/Units. At least that's where the AudioDefines says it is. Where is it really?
Not sure, sorry.

@AIAndy or @raxo2222 or @Toffer90 or @Dancing Hoskuld or @ anyone who can answer this for me...
This should mean 1 Crime per 2 population in your cities.

upload_2019-3-5_19-32-38.png


My programming is, as Raxo recently helped to further define on existing traits:
Code:
            <PropertyManipulators>
                <PropertySource>
                    <PropertySourceType>PROPERTYSOURCE_CONSTANT</PropertySourceType>
                    <PropertyType>PROPERTY_CRIME</PropertyType>
                    <GameObjectType>GAMEOBJECT_CITY</GameObjectType>
                    <RelationType>RELATION_ASSOCIATED</RelationType>
                    <iAmountPerTurn>
                        <Div>
                            <Mult>
                                <AttributeType>ATTRIBUTE_POPULATION</AttributeType>
                                <Constant>1</Constant>
                            </Mult>
                            <Constant>2</Constant>
                        </Div>
                    </iAmountPerTurn>
                </PropertySource>
            </PropertyManipulators>
As I get ready to commit my optional trait set here, I wanted to ensure that I am programming these correct. The way I read the display seems more like it's saying 2 crime per population per turn and this is kinda difficult to confirm by watching the game in progress. IF I'm wrong about how this is arranged, I need to be shown how it SHOULD be arranged. I originally had it a bit incorrect with my first attempt.
 
Not sure, sorry.
Thanks for replying. I found it, in vanilla vanilla assets. That's the (feminine) sound effect used for the (male) Entertainer, which I want to swap to the (female) Bard. Now to find the Bard's current sound effect.
 
@AIAndy or @raxo2222 or @Toffer90 or @Dancing Hoskuld or @ anyone who can answer this for me...
This should mean 1 Crime per 2 population in your cities.

My programming is, as Raxo recently helped to further define on existing traits:
Code:
            <PropertyManipulators>
                <PropertySource>
                    <PropertySourceType>PROPERTYSOURCE_CONSTANT</PropertySourceType>
                    <PropertyType>PROPERTY_CRIME</PropertyType>
                    <GameObjectType>GAMEOBJECT_CITY</GameObjectType>
                    <RelationType>RELATION_ASSOCIATED</RelationType>
                    <iAmountPerTurn>
                        <Div>
                            <Mult>
                                <AttributeType>ATTRIBUTE_POPULATION</AttributeType>
                                <Constant>1</Constant>
                            </Mult>
                            <Constant>2</Constant>
                        </Div>
                    </iAmountPerTurn>
                </PropertySource>
            </PropertyManipulators>
As I get ready to commit my optional trait set here, I wanted to ensure that I am programming these correct. The way I read the display seems more like it's saying 2 crime per population per turn and this is kinda difficult to confirm by watching the game in progress. IF I'm wrong about how this is arranged, I need to be shown how it SHOULD be arranged. I originally had it a bit incorrect with my first attempt.
Yes, the xml you have there means:
Extra Crime per turn in city = ( population * 1 ) / 2​

Why not simplify it like this?
<PropertySource>
<PropertySourceType>PROPERTYSOURCE_CONSTANT</PropertySourceType>
<PropertyType>PROPERTY_CRIME</PropertyType>
<GameObjectType>GAMEOBJECT_CITY</GameObjectType>
<RelationType>RELATION_ASSOCIATED</RelationType>
<iAmountPerTurn>
<Div>
<AttributeType>ATTRIBUTE_POPULATION</AttributeType>
<Constant>2</Constant>​
</Div>​
</iAmountPerTurn>​
</PropertySource>
 
I second Toffer's opinion.

We can also change that text string to make it clearer what it does.
Well the "* + 1" goes away if you do it Toffer's way. The main remaining problem (imho) is something better (less ambiguous than) a citizen icon to represent "population (level)".
 
Remember Afforess' warning, that Civ IV BtS always rounds Down. So if the Pop is creating 1 1/2 Crime/turn in the calculations it will get rounded down to 1. Same applies to every instance were a 1/2 comes into play.

I talked with AIAndy long ago about this, because Sgt Slick used multiple instances of this type programming with properties in his Original Trait set. Using this will give you duplicate set of Crime level for every Odd step up in City Pop. So a size 6 and size 7 city will see no change until the city hits pop 8.

This is why over the years I removed some instances of this type programming from Crime and Disease properties.

Not say this is not usable just saying what actually happens in game when you use this. It has uses obviously, but without knowing this it does become harder to explain when a player complains.
 
Last edited:
More clarification:
You can also use 1/3, 1/4, and so on as long as you remember the Round Down Rule. Each denominator just extends the usage of the 1st value longer ( ie = to denominators integer). And it is not until the value returns = 2 that the next range of city pop sizes activate the next level of Crime per pop.
 
Last edited:
I second Toffer's opinion.

We can also change that text string to make it clearer what it does.
Not without AIAndy's help we can't. Maybe you can. I dunno. I certainly can't. His coding is way too hard for me to follow enough to reformat things in the slightest.

Why not simplify it like this?
<PropertySource>
<PropertySourceType>PROPERTYSOURCE_CONSTANT</PropertySourceType>
<PropertyType>PROPERTY_CRIME</PropertyType>
<GameObjectType>GAMEOBJECT_CITY</GameObjectType>
<RelationType>RELATION_ASSOCIATED</RelationType>
<iAmountPerTurn>
<Div>
<AttributeType>ATTRIBUTE_POPULATION</AttributeType>
<Constant>2</Constant>
</Div></iAmountPerTurn></PropertySource>
I was hoping someone would show me how that could be done. I can't seem to trust myself to adjust the code on these expressions and have it work for the life of me.

More clarification:
You can also use 1/3, 1/4, and so on as long as you remember the Round Down Rule. Each denominator just extends the usage of the 1st value longer ( ie = to denominators integer). And it is not until the value returns = 2 that the next range of city pop sizes activate the next level of Crime per pop.
So basically it just means you get an extra crime for every 2 population you have. At 1 you get no extra but at 2 you get an additional 1. Sure I'd love to show decimal property levels but we never set it up to have the granularity to be able to do that and maybe that's better anyhow.

Yep, its number of citizens *(+1) divided by 2 in this case.
Handicaps and knowledge education pseudobuildings - those that have -1 education per pop - works similarly like this too.
And that's where I got it from but I just wanted to make sure that's how it's actually working because the expression leaves a little ambiguity.
 
Not without AIAndy's help we can't. Maybe you can. I dunno. I certainly can't. His coding is way too hard for me to follow enough to reformat things in the slightest.
The code for the integer expressions is all in IntExpr.h/.cpp. If you want to change how they are displayed, check the buildDisplayString functions. Of course it is not that easy to bring generic expressions in a pleasing text form (maybe we should allow the XML to change how it is displayed).

I was hoping someone would show me how that could be done. I can't seem to trust myself to adjust the code on these expressions and have it work for the life of me.
Toffer showed the right simplification. Multiplication with 1 does not change anything.

So basically it just means you get an extra crime for every 2 population you have. At 1 you get no extra but at 2 you get an additional 1. Sure I'd love to show decimal property levels but we never set it up to have the granularity to be able to do that and maybe that's better anyhow.
Integer division in programming languages usually truncates (rounds down), but you could easily make the Div round by changing that in IntExprDiv::evaluate.[/QUOTE][/QUOTE]
 
The code for the integer expressions is all in IntExpr.h/.cpp. If you want to change how they are displayed, check the buildDisplayString functions. Of course it is not that easy to bring generic expressions in a pleasing text form (maybe we should allow the XML to change how it is displayed).
I'm cool with how it is now - I just wanted to confirm that it was what I hoped it was and after simplifying, it should look a little better, though there are 2 every 3 population situations that will display like this.

Thanks for replying and good to see you in the forums!
 
From
Modder's Guide to A New Dawn

In CIV4EventTriggerInfo.xml, I've added:

  • EventArt
    • The path to the 256x256 dds which the image is in
Anyone knows where is the image size is defined? In the dll or in some python file? Just in case I'd like to use bigger pictures, like 800x600. Is that possible?


Sorry, if it's not the right place to ask.
 
Anyone knows where is the image size is defined? In the dll or in some python file? Just in case I'd like to use bigger pictures, like 800x600. Is that possible?
It's defined in the image pixel resolution, in other words not defined anywhere really.
The window may need resizing, not sure where the window is created, I think it's in the dll somewhere.
The image will be displayed un-stretched in whatever resolution it's in.
I suspect the image will clip away at the edge of the window if it's bigger than the window.
C2C has a dozen or so events that use images at 352x256, and they display just fine without any adjustments to the window.
 
Since DEBUG compiler flags no longer use /MDd, but use /MD (Makefile:68) since day 1, can we disable msvcprtd.lib on Makefile:88 by uncommenting the option /NODEFAULTLIB:msvcprtd.lib ?

msvcprtd comes with your Visual Studio’s compiler toolset, latter of which provides the nmake tool to build from the Makefile, as well as this debugger library. SDK guide did not include this library, as it is said to interrupt with python (for the msvcprtd that coupled with VC 7.1/2003), but I’m not sure.

I believe this library is there to provide debug entry to breakpoints you define in your own visual studio project, so it's using the toolset installed by visual studio. Are you all fine with this capability on your own computers, debugging the breakpoints? Then I'm just disabling this on my side. But, you're using /MD right? Does that really enable debugging? Else, I believe it only enables FAssert messages and the like but not the full debug feature from msvcprtd.
(My Netbeans project won't build to the Debug target because I don't set up additional libraries like this one. Only visual studio projects do set up this in the environment.)
 
Last edited:
can we disable msvcprtd.lib on Makefile:88 by uncommenting the option /NODEFAULTLIB:msvcprtd.lib ?

That is exactly what /NODEFAULTLIB does. Without that the cvgamecore.dll would be linked against the debug vc runtime and that would be very bad because the normal vc runtime and the debug runtime aren't binary compatible.
 
That is exactly what /NODEFAULTLIB does. Without that the cvgamecore.dll would be linked against the debug vc runtime and that would be very bad because the normal vc runtime and the debug runtime aren't binary compatible.
But it was commented out in the current Makefile (one hash symbol, #, before this parameter.)

I'm not sure how my linker still wants to reference msvcprtd.lib, with only /MD in Debug_CFLAGS (also, #/NODEFAULTLIB in Debug_LIBS). It could be that I'm setting up new environment wrong, or I didn't understand these parameters correctly.
 
Last edited:
One question, how does the game exe know how to use classes and their members and methods exported from the core dll? I mean, the exe imports 1207 functions from the dll (I used Dependency Walker to explore), and the vanilla BtS core dll exports 2432, half of which have matching import functions (1:1), and all exe imports are covered.
However, with our mod core dll exporting 2775 functions, two functions that are imported by the exe are not even covered. They are:
Code:
class CvUnit * CvPlot::getBestDefender(enum PlayerTypes,enum PlayerTypes,class CvUnit const *,bool,bool,bool)
void CvGame::setAIAutoPlay(int)
The first one has its signature changed. Our exported function has a new signature:
Code:
class CvUnit * CvPlot::getBestDefender(enum PlayerTypes,enum PlayerTypes,class CvUnit const *,bool,bool,bool,bool,bool)
The second one is not even exported. The original source code for the core dll has this (in CvGame.h), but in our mod the DllExport has been taken out (Seems it was since AND -- see revision 5 in our repository)
Code:
    DllExport void setAIAutoPlay(int iNewValue);

Perhaps there was some other mechanism than MS-specific dll import/exports to provide the application interface, but that's not related to this question.

I'm puzzled as to how these additional exported functions may have a use, if they were not used by the exe. Even the original core dll has extra exported functions that are not imported by the exe.

Perhaps some dynamic dependencies this tool doesn't detect, as stated in its FAQ, but I'm totally lost.

List of 1207 exe-imported functions: https://pastebin.com/93HnkEvw
Tool I used: http://www.dependencywalker.com/


What inspired me to check this: @f1rpo 's commit to AdvCiv last December.
https://github.com/f1rpo/AdvCiv/commit/f5545108ad4133fadf26ffaac1088ed0a8bb2e22
f1rpo said:
Removed all unused DLLExports and read/write functions

[advc.003i]

(There may still be some DLLExports that the executable only references in unreachable code.)

Flag SERIALIZE_CVINFOS added and set to false, which causes the preprocessor to remove all read/write(FDataStreamBase*) functions from CvInfos.h. As far as I can tell, they're unused, even if the Lock Modified Assets option is enabled.
Also, the last lines in the update note of his mod, version 0.95:
https://forums.civfanatics.com/resources/advanced-civ.26111/update?update=27306


PS. Quote from AND forum, 2015:
Q4:
Why some "CvGlobals" methods are prefixed with DLLExport ? What does that do in the code?
DllExport makes the function accessible to the game exe. Don't change number of arguments if the function is exported (you can't tell the exe how to call) and don't export your own functions as the exe will never call them anyway.
I'm looking into AND's source and revision logs for this kind of bug...
Fortunately, this is the only one in their repository currently.
 
Last edited:
Top Bottom