[1.0.3.276] Bug in MapGenerator.lua (goody placement)

PawelS

Ancient Druid
Joined
Dec 11, 2003
Messages
2,811
Location
Poland
This bug was probably always there, I found it lately when modding goody huts, so they can appear closer to each other - I noticed that the minimum distance between them is applied incorrectly.

In this fragment of MapGenerator.lua (CanPlaceGoodyAt function):

Code:
	-- Check for being too close to another of this goody type.
	local uniqueRange = improvement.GoodyRange;
	local plotX = plot:GetX();
	local plotY = plot:GetY();
	[b]for dx = -uniqueRange, uniqueRange - 1, 1 do
		for dy = -uniqueRange, uniqueRange - 1, 1 do[/b]
			local otherPlot = Map.PlotXYWithRangeCheck(plotX, plotY, dx, dy, uniqueRange);
			if(otherPlot and otherPlot:GetImprovementType() == improvementID) then
				return false;
			end
		end
	end

Not the entire area defined by the range around the potential goody hut site is checked. The fragment in bold should be changed to:

Code:
	for dx = -uniqueRange, uniqueRange, 1 do
		for dy = -uniqueRange, uniqueRange, 1 do

The next fragment (about being too close to a civ starting location) is also problematic, because it check plots with coordinates +/- 3, but the range is 4. In effect it checks a quasi-rectangular area instead of a hexagon-shaped one around the goody hut site.
 
Top Bottom