I want to help this mod

no rush, this stuff should stay compatible for a long time. and I might be wrong about the error. I actually have no idea. this is in the corporationInfos section so it looks wrong at first glance.
Spoiler CvInfos.cpp :
Code:
void CvCorporationInfo::setHeadquarterChar(int i)
{
       m_iHeadquarterChar = 8551 + (GC.getTGA_RELIGIONS() + m_iTGAIndex) * 2;
}
If nobody understands this and nothing about corporations is broken then forget I mentioned it.
 
no rush, this stuff should stay compatible for a long time. and I might be wrong about the error. I actually have no idea. this is in the corporationInfos section so it looks wrong at first glance.
Spoiler CvInfos.cpp :
Code:
void CvCorporationInfo::setHeadquarterChar(int i)
{
       m_iHeadquarterChar = 8551 + (GC.getTGA_RELIGIONS() + m_iTGAIndex) * 2;
}
If nobody understands this and nothing about corporations is broken then forget I mentioned it.
That refers to how the icons are found that refer to the corporations. If you changed anything about this, you likely broke the reference indexing matching the corps to their icons. Check by opening the mod with your changes to see if the corporations have their correct icons. I think that's something you should be able to see in the pedia.
 
That refers to how the icons are found that refer to the corporations. If you changed anything about this, you likely broke the reference indexing matching the corps to their icons. Check by opening the mod with your changes to see if the corporations have their correct icons. I think that's something you should be able to see in the pedia.
He changed TGA_RELIGIONS to GC.getTGA_RELIGIONS() if the macro TGA_RELIGIONS is recognized as a global within CvInfos.cpp then it wouldn't be a problem, though I'm not familiar enough with c++ data-structures to know either or.
 
He changed TGA_RELIGIONS to GC.getTGA_RELIGIONS() if the macro TGA_RELIGIONS is recognized as a global within CvInfos.cpp then it wouldn't be a problem, though I'm not familiar enough with c++ data-structures to know either or.
I'm not all that familiar with their use either so as long as it works and the index remains stable, I'm cool. Thing is, it's not necessarily a good thing to make it dynamic which is why it's a very hard coded and fixed variable that establishes the beginning of the indexing.
 
The having a tag to identify the icon of the religion or corporation is a RoM or Rom/AND thing. Maybe even Revolutions/BUG. It is not a BtS thing. There the icons have to be in the same order in the GameFont files as the religion and corporations are defined in the XML files.

My last attempt to add corporations failed. I don't know where the problem was but if you added one more corporation everything was good but add two or more and all these extra ones had all their buildings, units etc. show only in the last one. I added each individually and they worked but when I added any other it failed. I even put them in as individual modules so I could turn on/off individual ones.
 
the only thing used in CvDefinesModTools.h is #define TGA_RELIGIONS = GC.getTGA_RELIGIONS()
a define like that is kinda like a global. but u guys can keep the definesModTools file and ill switch that back or I can move that define to the other defines file or wherever
 
the only thing used in CvDefinesModTools.h is #define TGA_RELIGIONS = GC.getTGA_RELIGIONS()
a define like that is kinda like a global. but u guys can keep the definesModTools file and ill switch that back or I can move that define to the other defines file or wherever
Well, I don't know what it would matter then when the amount is still defined by GC.getTGA_RELIGIONS(). However, I thought that macros were defined at the time of compiling rather than inside the processing of game information on load. I suppose this sort would just be saying it's hardcoded to that definition whatever that definition is at the time, but it's a moot distinction so far as I can imagine. Such a change is basically a non-change entirely.

My last attempt to add corporations failed. I don't know where the problem was but if you added one more corporation everything was good but add two or more and all these extra ones had all their buildings, units etc. show only in the last one. I added each individually and they worked but when I added any other it failed. I even put them in as individual modules so I could turn on/off individual ones.
All icon types are given a range of indexes and if you put art outside that range in the tga files you'll cause odd problems potentially. It CAN be given more allocation but it's a pain to do. Seriously. It takes some intense work on some places I'd rather forget in the code. That said, probably eventually we'll need to give corps more slots to work with.
 
All icon types are given a range of indexes and if you put art outside that range in the tga files you'll cause odd problems potentially. It CAN be given more allocation but it's a pain to do. Seriously. It takes some intense work on some places I'd rather forget in the code. That said, probably eventually we'll need to give corps more slots to work with.
The icons were the only thing that did work :lol:. It was problems with the buildings and units all going to the one corporation rather than to the ones they were defined to.
 
Well, I don't know what it would matter then when the amount is still defined by GC.getTGA_RELIGIONS(). However, I thought that macros were defined at the time of compiling rather than inside the processing of game information on load. I suppose this sort would just be saying it's hardcoded to that definition whatever that definition is at the time, but it's a moot distinction so far as I can imagine. Such a change is basically a non-change entirely.
[
ya.
My last attempt to add corporations failed. I don't know where the problem was but if you added one more corporation everything was good but add two or more and all these extra ones had all their buildings, units etc. show only in the last one. I added each individually and they worked but when I added any other it failed. I even put them in as individual modules so I could turn on/off individual ones.
u still got any of this kickin around?
 
The icons were the only thing that did work :lol:. It was problems with the buildings and units all going to the one corporation rather than to the ones they were defined to.
Hmm... not sure I know how that would happen but it's certainly an indexing issue. There's two index systems afoot there. One for the icons and another for references to the proper religion/corp.
 
u still got any of this kickin around?
Not sure. It would not take to long to recreate though. At least the basics. I was trying out the idea of ancient cults basing them on those in Pie_at's mod.
Hmm... not sure I know how that would happen but it's certainly an indexing issue. There's two index systems afoot there. One for the icons and another for references to the proper religion/corp.
The display of icons is all Python code. Although I didn't think to check the Global Defines XML to see if there was a lesser number used for a maximum number of corporations. Many of the limits used for arrays have been defined in there. Having it as big (or small) as needed helps with memory usage but if the actual number goes over the maximum defined in the XML it will cause problems. As we saw with the various OR/AND limits.

edit there is no MAX_ or NUM_ type variables in the XML for corporations. Thinking on it it would not be a memory hog anyway so would not be needed.
 
Last edited:
wow, this would make a great modmod "sheeple vs evil". the nwo led by beyonce and soros vs the sheeple led by david icke and alex jones. the nwo control everything except for a tiny part of gaul where the inhabitants still resist the imperial yoke. any ideas for unique units?
:rotfl: :ninja::sheep::assimilate::mwaha::evil:
 
Unfortunately a cold teamed up with my asthma putting me in hospital until a few hours ago. Wont be able to get to it until after Easter as, even though I no longer perform dance, I am now a judge of those who do perform :(. I need to get fit enough for at least some social dance.
 
if the tribal villages text is missing, it's probably Python -> Contib -> autologEventManager.py that needs text linked to it.
if any1 wants to check that out here's example: TXT_KEY_AUTOLOG_VILLAGE_RESULT_LITTLEGOLD
 
Code:
int CvPlayer::getCoastalAIInfluence()
{
    int iInfluence = 0;
    int iLoop;
    int iNumCities = 0;
    int iModifier = 0;
    CvCity* pLoopCity;

    for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    {
        if (pLoopCity->isCoastal(1))
        {
            iInfluence++;
        }
        iNumCities++;
    }
    iInfluence *= 100;
    if (iModifier != 0)
    {
        iModifier = iInfluence/iNumCities;
    }
    iModifier += 50;
    return std::max(0, iModifier);
}
Near the bottom: if (iModifier != 0)
I don't see how iModifier can be anything but 0.
Looks like that statement is stopping iInfluence and iNumCities from being used, and you'll get a return of 50 every time.

Also I hope you guys havn't forgotten about that food waste thing. This has a fix I havnt tested with MAX_SURPLASS = 300.
 

Attachments

  • CvCity.cpp.txt
    1,004.2 KB · Views: 50
Code:
int CvPlayer::getCoastalAIInfluence()
{
    int iInfluence = 0;
    int iLoop;
    int iNumCities = 0;
    int iModifier = 0;
    CvCity* pLoopCity;

    for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    {
        if (pLoopCity->isCoastal(1))
        {
            iInfluence++;
        }
        iNumCities++;
    }
    iInfluence *= 100;
    if (iModifier != 0)
    {
        iModifier = iInfluence/iNumCities;
    }
    iModifier += 50;
    return std::max(0, iModifier);
}
Near the bottom: if (iModifier != 0)
I don't see how iModifier can be anything but 0.
Looks like that statement is stopping iInfluence and iNumCities from being used, and you'll get a return of 50 every time.

Also I hope you guys havn't forgotten about that food waste thing. This has a fix I havnt tested with MAX_SURPLASS = 300.
Good spot.
This is in effect the current code for that function:
int CvPlayer::getCoastalAIInfluence() { return 50; }​

@Thunderbrd: This is a developing trait function only used when the AI is deciding what trait to pick.
Having many coastal cities won't currently make the AI more likely to pick sea flavored traits.
Edit: { Actually, none of the traits are currently assign the tag bCoastalAIInfluence=True in xml. So that code is never ever processed for any C2C games.
Spoiler :
if (GC.getTraitInfo(eTrait).isCoastalAIInfluence()) // Always returns False, so CvPlayer::getCoastalAIInfluence() is never actually called.
{
iFlavorValue *= getCoastalAIInfluence();
iFlavorValue /= 100;​
}
}
Suggested change
Code:
int CvPlayer::getCoastalAIInfluence()
{
    int iInfluence = 0;
    int iLoop;
    int iNumCities = 0;
    CvCity* pLoopCity;

    for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    {
        if (pLoopCity->isCoastal(1)) iInfluence++;
        iNumCities++;
    }
    if (iInfluence > 0)
    {
        return 50 + (100*iInfluence)/iNumCities; // iNumCities >= iInfluence > 0 = True
    }
    return 50;
}
 
Last edited:
The only typo here was that iNumCities should've been checked rather than iModifier:
Code:
int CvPlayer::getCoastalAIInfluence()
{
    int iInfluence = 0;
    int iLoop;
    int iNumCities = 0;
    int iModifier = 0;
    CvCity* pLoopCity;

    for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
    {
        if (pLoopCity->isCoastal(1))
        {
            iInfluence++;
        }
        iNumCities++;
    }
    iInfluence *= 100;
    if (iNumCities!= 0)
    {
        iModifier = iInfluence/iNumCities;
    }
    iModifier += 50;
    return std::max(0, iModifier);
}
It was just a protection against a divide by zero and I figure it had to be corrected at some point and the thinking during debug was a bit hasty.

Edit: Actually, no traits are currently assign the tag bCoastalAIInfluence=True in xml. So that code is never ever processed for any C2C games.
I'll have to check that too then. Seafaring should be using it on all versions of itself.

Also I hope you guys havn't forgotten about that food waste thing. This has a fix I havnt tested with MAX_SURPLASS = 300.
I was waiting for you to tell us how the test went. If it goes solid and everyone agrees we should use it, I'm happy to include it.
 
@Thunderbrd Did you know that "std::max(0, iModifier);" is usually slower to process than "if (iModifier < 0) iModifier = 0;" ?
(Edit: Depends a lot on the compiler of the language in question, smart compilers will write the same code for both)

Even more so in this example where variables don't have to be changed:

return std::max(0, iModifier);
vs
if (iModifier > 0) return iModifier;
return 0;

I don't know exactly the impact in c++ code, but in python code it's around 50 times faster. (Edit: No impact it seems in c++ code, python is uncompiled code, so what you write is what you get quite literally).

In this piece of code we never want to return 0 ever as it breaks the AI flavour valuation code completely.
It should rather be "return std::max(50, iModifier);"
Additionally, it is not possible for iModifier to be smaller than 50 in this piece of code; so there is no need for the max function call here at all.

Today's small performance tip. ^^

Edit: Did some reading, seems like modern compilers generate the same code for both versions, so it doesn't matter, as the compiler will pretty much translate an std::max( function call into an effective comparison code (with the assembler equivalent of an if statement) instead without the function call overhead. Didn't know that compilers changed code to such an extent during interpretation for cases like this.
 
Last edited:
@Thunderbrd Did you know that "std::max(0, iModifier);" is always slower to process than "if (iModifier < 0) iModifier = 0;" ?
Nope... never had any indication that there was any time delay at all with this pinch method. Nothing ever mentioned it and it would be so insignificant on profiling runs that it doesn't become obvious. I'm not saying you're wrong, just that one calculation of anything isn't going to make for any kind of delay whatsoever - it's when you get thousands or millions or more calculations in a round that we tend to see delays. I don't think this is called often. That said, no reason not to make it cheaper in processing. So it's helpful to know there's a difference. As for the rest of this statement, given that it should be impossible to get less than 50, and the std::max command is slow, might as well just return iModifier.

Next time I commit, the code will be adjusted.
 
Top Bottom