Blockade not working?

Did you make any progess in finding the error?

No, I didn't. I've tried but it looks like I'm in a dead-end and I don't know where to look. I've tried reverting back to the old code but changes are too deep for me to understand where the problem is. A shot in the dark might be void CvPlotGroup::recalculatePlots(), but I really don't know. Do you have any other advice?
 
I'am new in civ4 modding and don't know that part of the code but i take a look and see what i can find.
 
I'am new in civ4 modding and don't know that part of the code but i take a look and see what i can find.

I'm somehow new too ;) But maybe we'll be able to find a solution. Thank you alberts2 :)
 
45°38'N-13°47'E;12991525 said:
A shot in the dark might be void CvPlotGroup::recalculatePlots(), but I really don't know.

Well, on second thought it could be CvPlotGroup* CvPlotGroup::colorRegionInternal(CvPlot* pPlot, PlayerTypes eOwner, CvPlotGroup* pPlotGroup, bool bRecalculateBonuses)

Code:
CvPlotGroup* CvPlotGroup::colorRegionInternal(CvPlot* pPlot, PlayerTypes eOwner, CvPlotGroup* pPlotGroup, bool bRecalculateBonuses)
{
	PROFILE_FUNC();

	if (pPlot->isTradeNetwork(GET_PLAYER(eOwner).getTeam()))
	{
		std::vector<CvPlot*> queue;

		queue.reserve(100);
		queue.push_back(pPlot);

		int iWaterMark = 0;

		while( iWaterMark < (int) queue.size() )
		{
			CvPlot* pLoopPlot = queue[iWaterMark++];

			if ( pLoopPlot->getPlotGroup(eOwner) == NULL )
			{
				if ( pPlotGroup == NULL )
				{
					pPlotGroup = GET_PLAYER(eOwner).initPlotGroup(pLoopPlot, bRecalculateBonuses);
				}
				else
				{
					pPlotGroup->addPlot(pLoopPlot, bRecalculateBonuses);
				}

				for (int iI = 0; iI < NUM_DIRECTION_TYPES; ++iI)
				{
					CvPlot* pAdjacentPlot = plotDirection(pLoopPlot->getX_INLINE(), pLoopPlot->getY_INLINE(), ((DirectionTypes)iI));

					if (pAdjacentPlot != NULL)
					{
						if (pLoopPlot->isTradeNetworkConnected(pAdjacentPlot, GET_PLAYER(eOwner).getTeam()))
						{
							CvPlotGroup* pAdjacentPlotGroup = pAdjacentPlot->getPlotGroup(eOwner);

							if (pAdjacentPlotGroup != NULL)
							{
								if ( pAdjacentPlotGroup != pPlotGroup )
								{
									if ( pPlotGroup->getLengthPlots() > pAdjacentPlotGroup->getLengthPlots() )
									{
										pPlotGroup->mergeIn(pAdjacentPlotGroup, bRecalculateBonuses);
									}
									else
									{
										pAdjacentPlotGroup->mergeIn(pPlotGroup, bRecalculateBonuses);

										pPlotGroup = pAdjacentPlotGroup;
									}
								}
							}
							else
							{
								queue.push_back(pAdjacentPlot);
							}
						}
					}
				}
			}
		}
	}

	return pPlotGroup;
}

I think it's something there because there are connections to isTradeNetwork or isTradeNetworkConnected, but I'm still not sure about it or how to fix it.
 
It looks like i found the fix this for this bug. I only added the red marked call it checks if a Adjacent Plot is bockaded.

Code:
// XXX eventually, this needs to be done when roads are built/destroyed...
void CvCity::updateTradeRoutes()
{
	PROFILE_FUNC();
	
	int* paiBestValue;
	CvCity* pLoopCity;
	int iTradeRoutes;
	int iTradeProfit;
	int iValue;
	int iLoop;
	int iI, iJ, iK;
	int iMaxTradeRoutes = GC.getDefineINT("MAX_TRADE_ROUTES") + GET_PLAYER(getOwnerINLINE()).getMaxTradeRoutesAdjustment();

	paiBestValue = new int[iMaxTradeRoutes];

	for (iI = 0; iI < iMaxTradeRoutes; iI++)
	{
		paiBestValue[iI] = 0;
	}

	clearTradeRoutes();

	if (!isDisorder() && !isPlundered()[COLOR="Red"] && !isBlockaded()[/COLOR])

Edit:

I found a better solution for this. Remove the Red marked.
 
After more testing i don't think that i found the proper fix for this bug and have some questions.

These questions might sound stupid but it has been a while(3Years) since i played BTS and i can't remember using blockades since then.

1. Did blockades ever stop ressources or not? Only if they where on another continent or also if they where on the same?
2. If not must they block them? Only if they are on another continent or also if they are on the same?
3. What if there is also a road or a coastal trade route?


The description only says "The unit disrupts the trade route so that no intercontinental trade can pass through the blockaded tile"

This means it should only stop intercontinental trade?
 
After more testing i don't think that i found the proper fix for this bug and have some questions.

These questions might sound stupid but it has been a while(3Years) since i played BTS and i can't remember using blockades since then.

1. Did blockades ever stop ressources or not? Only if they where on another continent or also if they where on the same?
2. If not must they block them? Only if they are on another continent or also if they are on the same?
3. What if there is also a road or a coastal trade route?


The description only says "The unit disrupts the trade route so that no intercontinental trade can pass through the blockaded tile"

This means it should only stop intercontinental trade?

I can answer this because I've tried with vanilla BTS.
1. Yes. Blockade blocks both resources AND trade. IIRC privateers always block both of them, while other ships only block them if you're at war.
2&3. Blockade always blocks trade on the sea, so if there's a route or a river connecting the blockaded city to other cities, blockade won't work with that city. But if there are no roads or rivers and city is connected to other cities only via sea trade, blockading that city always prevents trade and resources from reaching that city, even when it's on the same continent.

At least that's how it works in vanilla Civ.

Edit: from a quick test it looks like your code stops trade routes but not resources.
 
45°38'N-13°47'E;13011704 said:
I can answer this because I've tried with vanilla BTS.
1. Yes. Blockade blocks both resources AND trade. IIRC privateers always block both of them, while other ships only block them if you're at war.
2&3. Blockade always blocks trade on the sea, so if there's a route or a river connecting the blockaded city to other cities, blockade won't work with that city. But if there are no roads or rivers and city is connected to other cities only via sea trade, blockading that city always prevents trade and resources from reaching that city, even when it's on the same continent.

At least that's how it works in vanilla Civ.

Edit: from a quick test it looks like your code stops trade routes but not resources.

Ok thanks i didn't have time to test it.

Yes it only stops trade this was the reason i was asking those questions.
I already test another change but i can't finish this today.
 
The other change i was talking about looks good but i do more testing later today.

Code:
bool CvPlot::isTradeNetworkConnected(const CvPlot* pPlot, TeamTypes eTeam) const
{
	FAssertMsg(eTeam != NO_TEAM, "eTeam is not assigned a valid value");

	if (atWar(eTeam, getTeam()) || atWar(eTeam, pPlot->getTeam()))
	{
		return false;
	}

	[COLOR="Red"]if (getBlockadedCount(eTeam) > 0)
	{
		return false;
	}[/COLOR]

Edit:
Ressources are now also blocked it looks like this is the solution.
 
45°38'N-13°47'E;13013713 said:
Great, it works! Thank you alberts2, I frankly thought it was something harder. I was looking in the wrong place. Now I'll import that part of the code in AND2 too. Thank you again.

Yeah i was looking at the wrong places too and it's easy to get lost because it's very complex terrain.
 
Top Bottom