[BtS] JCultureControl: Beyond City Borders

merge succes,

i love this mod.

thanks alot.

Glad to here you got it merged. :band:

I have been playing some games with this and I found two small problems I didn't think of before. :(

The first is that if you build a Road or Railroad on top of an Improvement then the Culture Control will be cleared and the Border lost.

This is real easy to fix on your own before I get my next version out.

Open CvUnit.cpp and go to line 6380 and change..
Code:
if ((ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != eOldImprovement)
..to..
Code:
if ((ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != NO_IMPROVEMENT && (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != eOldImprovement)
..and that will solve that problem. I forgot that Unit Builds didn't always build Improvements... :mischief:


The second glitch isn't as easyly fixed, but also isn't caused by as common a situation.

If you build two Forts and their Borders overlap, and then you Pillage or replace the Fort that was built first, then the Border will be removed for the Pillaged Fort. This will leave the second Fort will Plots missing from its Border.

The two attached Screen Shots show what I am talking about. The bottom left Fort was built first. If the other Fort had been Pillaged, then nothing abnormal would have happen.

EDIT: Well, acually, the left over Border of the non Pillaged Fort won't be removed when that Fort is then Pillaged or removed, but I have already solved that.

I have determined exactly why this happens, but I am not decided on how I am going to code to handle this situation. I will post more when I figure it out.

EDIT: I also think I have solved the problem and should have a fix version out some time tonight. I'm going to have to add one new function and call it in one place.
 

Attachments

  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    103.9 KB · Views: 215
  • Civ4ScreenShot0002.JPG
    Civ4ScreenShot0002.JPG
    101.9 KB · Views: 202
Ok, I have totally fixed the problem I mentioned in the post above. I have quick tested it and what didn't work right, now works right. :cool:

I have the day off and my girlfriend is occupied with friends today, so I am going to sit back and play some Civ4 with this mod.

If no other problems pop up, I will upload the final, fully working, version of this mod later today. :>
 
This looks potentially quite good. I've been wanting improvements to have cultural borders for a while.




Does this work with improvements purchased in advanced start?


Does this work with improvements that grow to other improvements over time, like cottages do? (I'd like to see this merged into FfH, where forts upgrade to Castles and then Citadels.)



Is there any way an improvement's nationality can be changed, such as when a fort is captured by an enemy? If not automatic, could this at least be altered in python (which would mean that in FfH I could easily add a spell with the ability to change an improvement's owner)?


Also, have you considered making it so that the improvement's culture could depend on the size/strength of the units fortified on the plot? That is ideally how I'd like forts' influence to work.
 
This looks potentially quite good. I've been wanting improvements to have cultural borders for a while.

Thanx, I have aswell.

Does this work with improvements purchased in advanced start?
Not yet. I am working on this and the World Builder screen right now.

Does this work with improvements that grow to other improvements over time, like cottages do? (I'd like to see this merged into FfH, where forts upgrade to Castles and then Citadels.)
I thought it did, but I check before I said so.. and it doesn't. I must need to reword an if statement. I will fix this and have a new version uploaded tonight.

Is there any way an improvement's nationality can be changed, such as when a fort is captured by an enemy? If not automatic, could this at least be altered in python (which would mean that in FfH I could easily add a spell with the ability to change an improvement's owner)?
Yes, this could be done in Python.

Assuming you have a pPlot object.
Code:
# This will clear the Culture Control of the current Improvement
pPlot.clearCultureControl(pPlot.getCultureControlOwner(), pPlot.getX(), pPlot.getY(), pPlot.getImprovementType(), False)
# This will change the Improvement on the plot
pPlot.setImprovementType(iNewImprovement)
# Now add the Culture Control for the new Improvement
pPlot.addCultureControl(iNewPlayer, pPlot.getX(), pPlot.getY(), iNewImprovement, True)
# And incase the new Improvement's Culture Control Range is smaller then the old one
pPlot.updateCultureControl(pPlot.getX(), pPlot.getY(), 10, True)
That is just an example that I haven't tested, but should work assuming you set pPlot, iNewImprovement, and iNewPlayer to some thing valid.

Also, have you considered making it so that the improvement's culture could depend on the size/strength of the units fortified on the plot? That is ideally how I'd like forts' influence to work.
The short answer is, yes I am considering this, but I have a few other projects to complete before I come back and start adding any new functionality to this mod.


I am going to get to work fixing the Improvement Upgrade problem and will post when that is fixed.
 
Quick update.

I have Advanced Start and World Builder fixed for Single Player games, but the way I did it Advanced Start would cause OOS errors in MP games. I am researching weather or not to handle this in Python or SDK.

I am pretty sure I have fixed Improvement Upgrades not changing Culture Control. It is just an addition of one code block in a single spot in CvPlot.cpp, so it should be easy for mergers to update to. I am going to test this a bit tonight and will upload the new version tomorrow.
 
Ok, sorry, no new version yet. :mischief:

I fell asleep last night before I got everything done. I am going to play Warhammer with some buddies tonight, but will get the next version up tomorrow.

I got the World Builder fixed to used Culture Control, and I have Advanced Start working for the Human Player, but it isn't working for the AI for some reason.. Ends up its going to be like 3 or 4 small blocks of code in 3 files.

Anyway, when I upload the next version of the mod, I will be sure to post the new code blocks so keldath and others can merge the new changes as easy as possible. :)
 
There is a change and a fix in this version.

First lets make one small change.
In CvUnit.cpp file, bool CvUnit::build(BuildTypes eBuild) change..
Code:
	if (bFinished)
	{
	    // < JCultureControl Mod Start >
	    if ((ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != NO_IMPROVEMENT && (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != eOldImprovement)
	    {
            plot()->setImprovementOwner(getOwner());
            plot()->clearCultureControl(plot()->getCultureControlOwner(), plot()->getX_INLINE(), plot()->getY_INLINE(), eOldImprovement, false);
            plot()->addCultureControl(getOwner(), plot()->getX_INLINE(), plot()->getY_INLINE(), (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement(), true);
	    }
	    // < JCultureControl Mod End >
..to..
Code:
	if (bFinished)
	{
	    // < JCultureControl Mod Start >
	    if ((ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != NO_IMPROVEMENT && (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement() != eOldImprovement)
	    {
            plot()->setImprovementOwner(getOwner());
            plot()->clearCultureControl(plot()->getCultureControlOwner(), plot()->getX_INLINE(), plot()->getY_INLINE(), eOldImprovement, false);
            plot()->addCultureControl(getOwner(), plot()->getX_INLINE(), plot()->getY_INLINE(), (ImprovementTypes) GC.getBuildInfo(eBuild).getImprovement(), true);
            [B]plot()->updateCultureControl(plot()->getX_INLINE(), plot()->getY_INLINE(), 10, true);[/B]
	    }
	    // < JCultureControl Mod End >


Now lets make it so the proper Culture Control is applied when one Improvement Upgrades to another.

In CvPlot.cpp change..
Code:
void CvPlot::doImprovementUpgrade()
{
	if (getImprovementType() != NO_IMPROVEMENT)
	{
		ImprovementTypes eImprovementUpdrade = (ImprovementTypes)GC.getImprovementInfo(getImprovementType()).getImprovementUpgrade();
		if (eImprovementUpdrade != NO_IMPROVEMENT)
		{
			if (isBeingWorked() || GC.getImprovementInfo(eImprovementUpdrade).isOutsideBorders())
			{
				changeUpgradeProgress(GET_PLAYER(getOwnerINLINE()).getImprovementUpgradeRate());

				if (getUpgradeProgress() >= GC.getGameINLINE().getImprovementUpgradeTime(getImprovementType()))
				{
				    setImprovementType(eImprovementUpdrade);
				}
			}
		}
	}
}
..to..
Code:
void CvPlot::doImprovementUpgrade()
{
	if (getImprovementType() != NO_IMPROVEMENT)
	{
		ImprovementTypes eImprovementUpdrade = (ImprovementTypes)GC.getImprovementInfo(getImprovementType()).getImprovementUpgrade();
		if (eImprovementUpdrade != NO_IMPROVEMENT)
		{
			if (isBeingWorked() || GC.getImprovementInfo(eImprovementUpdrade).isOutsideBorders())
			{
				changeUpgradeProgress(GET_PLAYER(getOwnerINLINE()).getImprovementUpgradeRate());

				if (getUpgradeProgress() >= GC.getGameINLINE().getImprovementUpgradeTime(getImprovementType()))
				{
				    [B]// < JCultureControl Mod Start >
				    PlayerTypes eCultureControlOwner = getCultureControlOwner();
				    clearCultureControl(getCultureControlOwner(), getX_INLINE(), getY_INLINE(), getImprovementType(), false);
				    addCultureControl(eCultureControlOwner, getX_INLINE(), getY_INLINE(), eImprovementUpdrade, true);
				    updateCultureControl(getX_INLINE(), getY_INLINE(), 10, true);
				    // < JCultureControl Mod End >[/B]
					setImprovementType(eImprovementUpdrade);
				}
			}
		}
	}
}

And there is one new Python file, \Beyond the Sword\Mods\JCultureControl\Assets\Python\Screens\CvWorldBuilderScreen.py, to make World Builder work.

I didn't include the Advanced Start changes because it doesn't seem to work for the AI at the moment. I will keep looking into this and will post when I get it working right.

The new version, v1.110, has been uploaded, as have the sources.
 
So, when will you release a version that includes JImprovementLimit? I'd like to work this in to my FfH modmod, but I'd only want to do the merge once. Plus, JImprovementLimit isn't actually available at all yet.

I don't suppose you could get it out by tomorrow morning, could you? Summer semester is over and I going home for 2 weeks before fall classes start. We still have dial-up at home, so I may not be able to download till the 17th if don't get it by tomorrow. (On the other hand, last time I went home I found my laptop could use a weak and intermittent connection to a neighbor's unsecured wireless network, in some parts of out house. I managed to download the BtS3.17 patch that way, which I assume if far larger than this modcomp, so there may not be a problem.)
 
Sorry, I doubt I'll have anything out by tomorrow morning, but I upload all this stuff on a dial up connection so you shouldn't have any problem downloading them on one.

I don't have any eta on when i'm going to merge these modcomps together. When I get all the kinks worked out of them and all the features added to them, then I'll merge them together, cause the only thing less fun to me then merging mods is REmerging mods. ;)
 
What happened with improvement-controlled plots after its civilisation destroyed?
In my test game they becomes impassable and stay belong to that civ.
 
What happened with improvement-controlled plots after its civilisation destroyed?
In my test game they becomes impassable and stay belong to that civ.

I will look into this and address it as needed. :)
 
Also, when i destroyed an enemy city with many improvements around that terrirory becomes no one`s, as was expected. But when i builded fort there, control over coptured lands returned to enemy.
I think its wrong..
 
Also, when i destroyed an enemy city with many improvements around that terrirory becomes no one`s, as was expected. But when i builded fort there, control over coptured lands returned to enemy.
I think its wrong..

I'm using this mod in a game with a friend of mine, accually playing Civ4 instead of just modding it, and we notice this as well. I'm glad to get some confirmation from someone else. I will look into this aswell. :king:
 
I'm using this mod in a game with a friend of mine, accually playing Civ4 instead of just modding it, and we notice this as well. I'm glad to get some confirmation from someone else. I will look into this aswell. :king:
You may have to run through all of the plots on the map whenever a civ dies, and clear the tiles that way.
 
Back
Top Bottom