Problem with updating cultural borders after plot change

kipkuhmi

Warlord
Joined
Aug 8, 2007
Messages
131
Hi everybody,

in my mod I gave the work boats the possibility to turn coastal plots into grass land. The plot change works well, however the cultural borders look awkward. You can see this in the picture below:



It seems that the graphics engine has updated the left part of the plot, but in the right part it seems to have put the land mass on top of the cultural border. When I save the file and reopen it, everything is looking fine.

For turning water into land I used the command

Code:
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
pPlot->setPlotType(PLOT_LAND, true, true);

Does anyone know if there is a command which updated the cultural borders in the correct way?

Thanks for any help!
 
I think it's a general problem with the engine. The third parameter bRebuildGraphic should (that's what i'm guessing) force an update of the graphics, but it obviously doesn't.

In my mod i'm changing land plots to water and i have the same problem there :(.
 
This is pure guess, but try adding this line after the call to setPlotType():
Code:
CyEngine().setDirty(EngineDirtyBits.CultureBorders_DIRTY_BIT, True)
 
Thanks for the help, but I've already tried that.

To be precise, I used it slightly differently:


Code:
gDLL->getEngineIFace()->SetDirty(CultureBorders_DIRTY_BIT, true);

But I guess this should be pretty much the same.

Btw, I've been guessing about the meaning of that "SetDirty(...)" stuff for quite some time. Forgive me if I sound stupid, but am I right in supposing that it informs the graphics engine that some detail in the interface has changed and needs to be renewed and the next refreshment turn?
 
I have no idea if it will help, but there is a function called RebuildPlot in the CvDLLEngineIFaceBase class, as well as RebuildAllPlots and RebuildTileArt. The RebuildPlot function has a bRebuildHeights boolean argument that sounds like it has some potential to maybe fix this.
 
Thanks for the help, but I've already tried that.

To be precise, I used it slightly differently:


Code:
gDLL->getEngineIFace()->SetDirty(CultureBorders_DIRTY_BIT, true);

But I guess this should be pretty much the same.

Btw, I've been guessing about the meaning of that "SetDirty(...)" stuff for quite some time. Forgive me if I sound stupid, but am I right in supposing that it informs the graphics engine that some detail in the interface has changed and needs to be renewed and the next refreshment turn?

Oh! for some reason I thought you used Python code... I have no idea why (come on, '->' !) so Itranslated that line of code to Python.

Yes, that's the C++ version.

Yes, that's the meaning of set dirty.
You also have this for different items in the UI (not only in the rendering engine).
 
Thanks again for the advice to both of you.

@God-Emperor:
I'm sorry, I tried this, and it didn't work neither. Maybe it's all about the order in which you put all the update commands. I keep on trying.

Another question: Does anybody know what a "PlotGroup" is exactly? Is it a group that consists of a plot and all of its neighbor plots? Or a plot and all the adjacent plot of same terrain type (ie. water/ocean or water/coastal)? Or is it something like an area?

I ask it because I want the game to check if there's a ressource on a special plot. But it seems I can only check the whole plot group, because this is the class that owns "hasRessource".
 
To find out if a plot has a bonus (as "resources" are called), use CvPlot->getBonusType(eTeam), specifying NO_TEAM if you don't care if it is currently visible to some relevant team. If the function returns NO_BONUS (i.e. -1) then it has no bonus on it, otherwise it has the type of bonus returned (obviously).
 
This one is really driving me nuts.

The game keeps crushing at this line:

Code:
pPlot->setPlotType(PLOT_LAND, true, true);

To be more specific: I have created a "land reclamation boat" which moves to a coastal field, turns the ocean/coastal field into land/grass. This is an auto-kill build type, so the unit disappears after having completed its task.

Now the land transformation part happens at the end of Unit::kill(). In most cases all goes pretty well, but sometimes the game crushes at the spot named above. This seems to happen when the AI tries to transform a plot field which is invisible to the active player.

I tried to set the two boolean operators to "false", which results in the game not crushing, but the landscape being rather ugly because the graphics are not updated properly.

I tried to play around with commands like

Code:
pPlot->setLayoutDirty(true);

but those things don't seem to have any effect at all.


Does anyone know a way to work this out? Thanks.

---------------------
@God-Emperor
Thanks, I was just being stupid. :) I remembered this "resource/bonus" thing ten minutes after having posted. Guess I was still I bit to sleepy that day ... Again, thanks anyway.
 
Has anyone ever used the "setPlotType" command successfully?

(I mean not during map creation, but within a running game.)
 
In most cases all goes pretty well, but sometimes the game crushes at the spot named above. This seems to happen when the AI tries to transform a plot field which is invisible to the active player.

I ran across a function in CvPlot other day called ::isVisibleToWatchingHuman(). Maybe if you make two different calls to setPlotType based on whether or not a human is watching you can make it work. Something like this:

Code:
if (pPlot->isVisibleToWatchingHuman())
{
	pPlot->setPlotType(PLOT_LAND, true, true);
}
else
{
	pPlot->setPlotType(PLOT_LAND, true, false);
}

I set the bRecalculate bool to true in both cases since it looks like that makes the game recalculate trade and resource connections through that plot, which you'll want to do in this case.

There are also a couple of other isVisible functions in the same area of the code if that doesn't work.
 
yes, works perfect

That sounds good. Did you use the SDK or Python? And did you try turning Ocean into Land?

Could you post me a code fragment? This could be a great help.


@Tholal
Unfortunately, I've discovered by now that it does not seem to be related to visibility. Thanks anyway.
 
That sounds good. Did you use the SDK or Python? And did you try turning Ocean into Land?
yes. the below code is from a CvPlot method. maybe you also want to create a method in CvPlot. let that method first kill all units on the plot, then run setPlotType


Code:
	if(kProject.isCreateLand() && isWater() && getNumUnits()==0)
	{
		bValid=true;
		if(!bCountOnly)
		{
			setPlotType(PLOT_LAND,true,false);
		}

		iValue+=2*iBaseYieldValue*iMod;
	}
 
Top Bottom