Problem with trade routes through "canals"

j_mie6

Deity
Joined
Dec 20, 2009
Messages
2,963
Location
Bristol (uni)/Swindon (home)
So, in my mod I have an improvement called a canal, and it allows any naval unit through, in order to lake jump etc. If I lay out a canal and set a trireme to auto explore it will pathfind through the canals, quite happily.

But if I try and set up a trade route between two oceans connected via a canal (the same canal the triremes will happily travel through), it will not display the trade route as valid and I can't make it.

So my question is; Where can I make it so that pathfinding for trade routes takes into account any improvement that ActsAsCanal() when working out if a route is valid?

Thanks,
Jamie
 
I'm not sure, I might have done. But it has been a while since I've been able to look at any Civ code :(
 
My DLL and the CP DLL address (and solve) this issue
 
More specifically (in case you want to do this with your own DLL), you are going to need to modify within the file CvAStar.cpp the function

Code:
int TradeRouteWaterValid(CvAStarNode* parent, CvAStarNode* node, int data, const void* pointer, CvAStar* finder)

replacing the condition that checks for a plot city with a condition that checks for improvements (and possible canal attribute).

Code:
#ifdef Your_Mod_Define
	if (!pNewPlot->isCity() && !pNewPlot->isActAsCanal())
#else
	if (!pNewPlot->isCity())
#endif
 
There are three places you need to make changes in CvAStar.cpp, TWO in TradeRouteWaterValid and ONE in TradeRouteWaterPathCost
 
Back
Top Bottom