[BUG & SOLUTION] Technology Tree Pipe connecting Issue when modding

JANorton

Chieftain
Joined
Oct 3, 2010
Messages
11
Location
Albury, Australia
BUG -- (only applies to modding, but a bug nevertheless)

I came across this bug when trying to add a new Tech to the game, basically the tech tree won't connect downward turning pipes when they were in conjunction with a straight or upward turning pipe or both over a technology spacing distance greater than 1 along the x axis (see first screenshot).

REPLICATING BUG --

Create a mod with a single SQL file with the following code contained, then fire up a new game with that mod and inspect the tech tree.

UPDATE Technologies SET GridX = GridX + 1
WHERE GridX > 5;

SOLUTION --

I searched through the TechTree.lua file for the tech tree and found it was due to a typo by the original author, basically he forgot to add the xOffset to downward turning pipes when they were in conjuntion with upward or straight pipes.

To fix the pipe connection issue the following changes need to be made to the TechTree.lua file found in the Assets/InGame/UI/TechTree folder, first, find the section of the code in the below quote, its a fair way down (the file is too long to quote the entire thing) and add the changes highlighted in blue. The result of this Fix can be seen in the second screenshot.

for pipeIndex, thisPipe in pairs(techPipes) do

local tech = GameInfo.Technologies[thisPipe.techType];

local yOffset = (tech.GridY-5)*blockSpacingY + 12 + extraYOffset;

if thisPipe.rightConnectionType >= 1 then

local startPipe = g_PipeManager:GetInstance();
startPipe.TechPipeIcon:SetOffsetVal( tech.GridX*blockSpacingX + blockSizeX + 64, yOffset );
startPipe.TechPipeIcon:SetTexture(right1Texture);
startPipe.TechPipeIcon:SetSize(connectorSize);

local pipe = g_PipeManager:GetInstance();
if thisPipe.rightConnectionType == 1 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset ); --original
pipe.TechPipeIcon:SetTexture(right1Texture);
elseif thisPipe.rightConnectionType == 2 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72));
elseif thisPipe.rightConnectionType == 3 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 6, yOffset - 15 );
--pipe.TechPipeIcon:SetTexture(right2BTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,72));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
pipe.TechPipeIcon:SetTexture(right1Texture);
pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72));
elseif thisPipe.rightConnectionType == 4 then
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
elseif thisPipe.rightConnectionType == 5 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 6, yOffset );
--pipe.TechPipeIcon:SetTexture(right2TTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
pipe.TechPipeIcon:SetTexture(right1Texture);
pipe = g_PipeManager:GetInstance();

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


elseif thisPipe.rightConnectionType == 6 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 6 );
--pipe.TechPipeIcon:SetTexture(right2Texture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,36));

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72));
else-- thisPipe.rightConnectionType == 7 then
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 6, yOffset - 6 );
--pipe.TechPipeIcon:SetTexture(right3Texture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(36,36));
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96, yOffset );
--pipe.TechPipeIcon:SetTexture(right1Texture);
--pipe = g_PipeManager:GetInstance();

-- Modified by Jeremy Norton 05/10/10
--pipe.TechPipeIcon:SetOffsetVal( (tech.GridX)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
--pipe.TechPipeIcon:SetTexture(topRightTexture);
--pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset );
pipe.TechPipeIcon:SetTexture(topRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,0));
-- End of Changes


pipe = g_PipeManager:GetInstance();
pipe.TechPipeIcon:SetOffsetVal( (tech.GridX+thisPipe.xOffset)*blockSpacingX + blockSizeX + 96 - 12, yOffset - 15 );
pipe.TechPipeIcon:SetTexture(bottomRightTexture);
pipe.TechPipeIcon:SetTextureOffset(Vector2(72,72));
end
end

Civ 5 version --

1.0.0.20
 

Attachments

  • techtree_bug2.jpg
    techtree_bug2.jpg
    218.5 KB · Views: 116
  • TechTree_Fixed2.jpg
    TechTree_Fixed2.jpg
    235.7 KB · Views: 109
Top Bottom