Exemplo n.º 1
0
        public void DrawTileWireframe(int TileX, int TileY)
        {
            double[] TileTerrainHeight = new double[4];
            sXYZ_sng Vertex0 = new sXYZ_sng();
            sXYZ_sng Vertex1 = new sXYZ_sng();
            sXYZ_sng Vertex2 = new sXYZ_sng();
            sXYZ_sng Vertex3 = new sXYZ_sng();

            TileTerrainHeight[0] = Terrain.Vertices[TileX, TileY].Height;
            TileTerrainHeight[1] = Terrain.Vertices[TileX + 1, TileY].Height;
            TileTerrainHeight[2] = Terrain.Vertices[TileX, TileY + 1].Height;
            TileTerrainHeight[3] = Terrain.Vertices[TileX + 1, TileY + 1].Height;

            Vertex0.X = TileX * App.TerrainGridSpacing;
            Vertex0.Y = (float)(TileTerrainHeight[0] * HeightMultiplier);
            Vertex0.Z = - TileY * App.TerrainGridSpacing;
            Vertex1.X = (TileX + 1) * App.TerrainGridSpacing;
            Vertex1.Y = (float)(TileTerrainHeight[1] * HeightMultiplier);
            Vertex1.Z = - TileY * App.TerrainGridSpacing;
            Vertex2.X = TileX * App.TerrainGridSpacing;
            Vertex2.Y = (float)(TileTerrainHeight[2] * HeightMultiplier);
            Vertex2.Z = - (TileY + 1) * App.TerrainGridSpacing;
            Vertex3.X = (TileX + 1) * App.TerrainGridSpacing;
            Vertex3.Y = (float)(TileTerrainHeight[3] * HeightMultiplier);
            Vertex3.Z = - (TileY + 1) * App.TerrainGridSpacing;

            GL.Begin(BeginMode.Lines);
            if ( Terrain.Tiles[TileX, TileY].Tri )
            {
                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));

                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
            }
            else
            {
                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));

                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
            }
            GL.End();
        }
Exemplo n.º 2
0
        public sXYZ_sng TerrainVertexNormalCalc(int X, int Y)
        {
            sXYZ_sng ReturnResult = new sXYZ_sng();
            int TerrainHeightX1 = 0;
            int TerrainHeightX2 = 0;
            int TerrainHeightY1 = 0;
            int TerrainHeightY2 = 0;
            int X2 = 0;
            int Y2 = 0;
            Position.XYZ_dbl XYZ_dbl = default(Position.XYZ_dbl);
            Position.XYZ_dbl XYZ_dbl2 = default(Position.XYZ_dbl);
            double dblTemp = 0;

            X2 = MathUtil.Clamp_int(X - 1, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(Y, 0, Terrain.TileSize.Y);
            TerrainHeightX1 = Terrain.Vertices[X2, Y2].Height;
            X2 = MathUtil.Clamp_int(X + 1, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(Y, 0, Terrain.TileSize.Y);
            TerrainHeightX2 = Terrain.Vertices[X2, Y2].Height;
            X2 = MathUtil.Clamp_int(X, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(Y - 1, 0, Terrain.TileSize.Y);
            TerrainHeightY1 = Terrain.Vertices[X2, Y2].Height;
            X2 = MathUtil.Clamp_int(X, 0, Terrain.TileSize.X);
            Y2 = MathUtil.Clamp_int(Y + 1, 0, Terrain.TileSize.Y);
            TerrainHeightY2 = Terrain.Vertices[X2, Y2].Height;
            XYZ_dbl.X = (TerrainHeightX1 - TerrainHeightX2) * HeightMultiplier;
            XYZ_dbl.Y = App.TerrainGridSpacing * 2.0D;
            XYZ_dbl.Z = 0.0D;
            XYZ_dbl2.X = 0.0D;
            XYZ_dbl2.Y = App.TerrainGridSpacing * 2.0D;
            XYZ_dbl2.Z = (TerrainHeightY1 - TerrainHeightY2) * HeightMultiplier;
            XYZ_dbl.X = XYZ_dbl.X + XYZ_dbl2.X;
            XYZ_dbl.Y = XYZ_dbl.Y + XYZ_dbl2.Y;
            XYZ_dbl.Z = XYZ_dbl.Z + XYZ_dbl2.Z;
            dblTemp = Math.Sqrt(XYZ_dbl.X * XYZ_dbl.X + XYZ_dbl.Y * XYZ_dbl.Y + XYZ_dbl.Z * XYZ_dbl.Z);
            ReturnResult.X = (float)(XYZ_dbl.X / dblTemp);
            ReturnResult.Y = (float)(XYZ_dbl.Y / dblTemp);
            ReturnResult.Z = (float)(XYZ_dbl.Z / dblTemp);
            return ReturnResult;
        }
Exemplo n.º 3
0
        public void UpdateAttachments()
        {
            BaseAttachment = new clsAttachment();

            if ( Body == null )
            {
                AlwaysDrawTextLabel = true;
                return;
            }

            clsAttachment NewBody = BaseAttachment.AddCopyOfAttachment(Body.Attachment);

            AlwaysDrawTextLabel = NewBody.Models.Count == 0;

            if ( Propulsion != null )
            {
                if ( Body.ObjectDataLink.IsConnected )
                {
                    BaseAttachment.AddCopyOfAttachment(Propulsion.Bodies[Body.ObjectDataLink.ArrayPosition].LeftAttachment);
                    BaseAttachment.AddCopyOfAttachment(Propulsion.Bodies[Body.ObjectDataLink.ArrayPosition].RightAttachment);
                }
            }

            if ( NewBody.Models.Count == 0 )
            {
                return;
            }

            if ( NewBody.Models[0].ConnectorCount <= 0 )
            {
                return;
            }

            sXYZ_sng TurretConnector = new sXYZ_sng();

            TurretConnector = Body.Attachment.Models[0].Connectors[0];

            if ( TurretCount >= 1 )
            {
                if ( Turret1 != null )
                {
                    clsAttachment NewTurret = NewBody.AddCopyOfAttachment(Turret1.Attachment);
                    NewTurret.Pos_Offset = TurretConnector;
                }
            }

            if ( Body.Attachment.Models[0].ConnectorCount <= 1 )
            {
                return;
            }

            TurretConnector = Body.Attachment.Models[0].Connectors[1];

            if ( TurretCount >= 2 )
            {
                if ( Turret2 != null )
                {
                    clsAttachment NewTurret = NewBody.AddCopyOfAttachment(Turret2.Attachment);
                    NewTurret.Pos_Offset = TurretConnector;
                }
            }
        }
Exemplo n.º 4
0
            public override void Perform()
            {
                clsTerrain Terrain = Map.Terrain;
                clsTileset Tileset = Map.Tileset;
                double[] TileTerrainHeight = new double[4];
                sXYZ_sng Vertex0 = new sXYZ_sng();
                sXYZ_sng Vertex1 = new sXYZ_sng();
                sXYZ_sng Vertex2 = new sXYZ_sng();
                sXYZ_sng Vertex3 = new sXYZ_sng();
                sXYZ_sng Normal0 = new sXYZ_sng();
                sXYZ_sng Normal1 = new sXYZ_sng();
                sXYZ_sng Normal2 = new sXYZ_sng();
                sXYZ_sng Normal3 = new sXYZ_sng();
                sXY_sng TexCoord0 = new sXY_sng();
                sXY_sng TexCoord1 = new sXY_sng();
                sXY_sng TexCoord2 = new sXY_sng();
                sXY_sng TexCoord3 = new sXY_sng();
                int A = 0;

                if ( Terrain.Tiles[TileX, TileY].Texture.TextureNum < 0 )
                {
                    GL.BindTexture(TextureTarget.Texture2D, App.GLTexture_NoTile);
                }
                else if ( Tileset == null )
                {
                    GL.BindTexture(TextureTarget.Texture2D, App.GLTexture_OverflowTile);
                }
                else if ( Terrain.Tiles[TileX, TileY].Texture.TextureNum < Tileset.TileCount )
                {
                    A = Tileset.Tiles[Terrain.Tiles[TileX, TileY].Texture.TextureNum].MapView_GL_Texture_Num;
                    if ( A == 0 )
                    {
                        GL.BindTexture(TextureTarget.Texture2D, App.GLTexture_OverflowTile);
                    }
                    else
                    {
                        GL.BindTexture(TextureTarget.Texture2D, A);
                    }
                }
                else
                {
                    GL.BindTexture(TextureTarget.Texture2D, App.GLTexture_OverflowTile);
                }
                GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Modulate);

                TileTerrainHeight[0] = Terrain.Vertices[TileX, TileY].Height;
                TileTerrainHeight[1] = Terrain.Vertices[TileX + 1, TileY].Height;
                TileTerrainHeight[2] = Terrain.Vertices[TileX, TileY + 1].Height;
                TileTerrainHeight[3] = Terrain.Vertices[TileX + 1, TileY + 1].Height;

                TileUtil.GetTileRotatedTexCoords(Terrain.Tiles[TileX, TileY].Texture.Orientation, TexCoord0, TexCoord1, TexCoord2, TexCoord3);

                Vertex0.X = TileX * App.TerrainGridSpacing;
                Vertex0.Y = (float)(TileTerrainHeight[0] * Map.HeightMultiplier);
                Vertex0.Z = - TileY * App.TerrainGridSpacing;
                Vertex1.X = (TileX + 1) * App.TerrainGridSpacing;
                Vertex1.Y = (float)(TileTerrainHeight[1] * Map.HeightMultiplier);
                Vertex1.Z = - TileY * App.TerrainGridSpacing;
                Vertex2.X = TileX * App.TerrainGridSpacing;
                Vertex2.Y = (float)(TileTerrainHeight[2] * Map.HeightMultiplier);
                Vertex2.Z = - (TileY + 1) * App.TerrainGridSpacing;
                Vertex3.X = (TileX + 1) * App.TerrainGridSpacing;
                Vertex3.Y = (float)(TileTerrainHeight[3] * Map.HeightMultiplier);
                Vertex3.Z = - (TileY + 1) * App.TerrainGridSpacing;

                Normal0 = Map.TerrainVertexNormalCalc(TileX, TileY);
                Normal1 = Map.TerrainVertexNormalCalc(TileX + 1, TileY);
                Normal2 = Map.TerrainVertexNormalCalc(TileX, TileY + 1);
                Normal3 = Map.TerrainVertexNormalCalc(TileX + 1, TileY + 1);

                GL.Begin(BeginMode.Triangles);
                if ( Terrain.Tiles[TileX, TileY].Tri )
                {
                    GL.Normal3(Normal0.X, Normal0.Y, Convert.ToDouble(- Normal0.Z));
                    GL.TexCoord2(TexCoord0.X, TexCoord0.Y);
                    GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                    GL.Normal3(Normal2.X, Normal2.Y, Convert.ToDouble(- Normal2.Z));
                    GL.TexCoord2(TexCoord2.X, TexCoord2.Y);
                    GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                    GL.Normal3(Normal1.X, Normal1.Y, Convert.ToDouble(- Normal1.Z));
                    GL.TexCoord2(TexCoord1.X, TexCoord1.Y);
                    GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));

                    GL.Normal3(Normal1.X, Normal1.Y, Convert.ToDouble(- Normal1.Z));
                    GL.TexCoord2(TexCoord1.X, TexCoord1.Y);
                    GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                    GL.Normal3(Normal2.X, Normal2.Y, Convert.ToDouble(- Normal2.Z));
                    GL.TexCoord2(TexCoord2.X, TexCoord2.Y);
                    GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                    GL.Normal3(Normal3.X, Normal3.Y, Convert.ToDouble(- Normal3.Z));
                    GL.TexCoord2(TexCoord3.X, TexCoord3.Y);
                    GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                }
                else
                {
                    GL.Normal3(Normal0.X, Normal0.Y, Convert.ToDouble(- Normal0.Z));
                    GL.TexCoord2(TexCoord0.X, TexCoord0.Y);
                    GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                    GL.Normal3(Normal2.X, Normal2.Y, Convert.ToDouble(- Normal2.Z));
                    GL.TexCoord2(TexCoord2.X, TexCoord2.Y);
                    GL.Vertex3(Vertex2.X, Vertex2.Y, Convert.ToDouble(- Vertex2.Z));
                    GL.Normal3(Normal3.X, Normal3.Y, Convert.ToDouble(- Normal3.Z));
                    GL.TexCoord2(TexCoord3.X, TexCoord3.Y);
                    GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));

                    GL.Normal3(Normal0.X, Normal0.Y, Convert.ToDouble(- Normal0.Z));
                    GL.TexCoord2(TexCoord0.X, TexCoord0.Y);
                    GL.Vertex3(Vertex0.X, Vertex0.Y, Convert.ToDouble(- Vertex0.Z));
                    GL.Normal3(Normal3.X, Normal3.Y, Convert.ToDouble(- Normal3.Z));
                    GL.TexCoord2(TexCoord3.X, TexCoord3.Y);
                    GL.Vertex3(Vertex3.X, Vertex3.Y, Convert.ToDouble(- Vertex3.Z));
                    GL.Normal3(Normal1.X, Normal1.Y, Convert.ToDouble(- Normal1.Z));
                    GL.TexCoord2(TexCoord1.X, TexCoord1.Y);
                    GL.Vertex3(Vertex1.X, Vertex1.Y, Convert.ToDouble(- Vertex1.Z));
                }
                GL.End();
            }
Exemplo n.º 5
0
        public clsResult LoadDirectory(string Path)
        {
            clsResult ReturnResult =
                new clsResult("Loading object data from " + Convert.ToString(ControlChars.Quote) + Path + Convert.ToString(ControlChars.Quote));

            Path = App.EndWithPathSeperator(Path);

            string SubDirNames = "";
            string SubDirStructures = "";
            string SubDirBrain = "";
            string SubDirBody = "";
            string SubDirPropulsion = "";
            string SubDirBodyPropulsion = "";
            string SubDirConstruction = "";
            string SubDirSensor = "";
            string SubDirRepair = "";
            string SubDirTemplates = "";
            string SubDirWeapons = "";
            string SubDirECM = "";
            string SubDirFeatures = "";
            string SubDirStructurePIE;
            string SubDirBodiesPIE;
            string SubDirPropPIE;
            string SubDirWeaponsPIE;
            string SubDirTexpages = "";
            string SubDirAssignWeapons = "";
            string SubDirFeaturePIE;
            string SubDirStructureWeapons = "";
            string SubDirPIEs = "";

            SubDirNames = "messages" + Convert.ToString(App.PlatformPathSeparator) + "strings" +
                          Convert.ToString(App.PlatformPathSeparator) + "names.txt";
            SubDirStructures = "stats" + Convert.ToString(App.PlatformPathSeparator) + "structures.txt";
            SubDirBrain = "stats" + Convert.ToString(App.PlatformPathSeparator) + "brain.txt";
            SubDirBody = "stats" + Convert.ToString(App.PlatformPathSeparator) + "body.txt";
            SubDirPropulsion = "stats" + Convert.ToString(App.PlatformPathSeparator) + "propulsion.txt";
            SubDirBodyPropulsion = "stats" + Convert.ToString(App.PlatformPathSeparator) + "bodypropulsionimd.txt";
            SubDirConstruction = "stats" + Convert.ToString(App.PlatformPathSeparator) + "construction.txt";
            SubDirSensor = "stats" + Convert.ToString(App.PlatformPathSeparator) + "sensor.txt";
            SubDirRepair = "stats" + Convert.ToString(App.PlatformPathSeparator) + "repair.txt";
            SubDirTemplates = "stats" + Convert.ToString(App.PlatformPathSeparator) + "templates.txt";
            SubDirWeapons = "stats" + Convert.ToString(App.PlatformPathSeparator) + "weapons.txt";
            SubDirECM = "stats" + Convert.ToString(App.PlatformPathSeparator) + "ecm.txt";
            SubDirFeatures = "stats" + Convert.ToString(App.PlatformPathSeparator) + "features.txt";
            SubDirPIEs = "pies" + Convert.ToString(App.PlatformPathSeparator);
            //SubDirStructurePIE = "structs" & ospathseperator
            SubDirStructurePIE = SubDirPIEs;
            //SubDirBodiesPIE = "components" & ospathseperator & "bodies" & ospathseperator
            SubDirBodiesPIE = SubDirPIEs;
            //SubDirPropPIE = "components" & ospathseperator & "prop" & ospathseperator
            SubDirPropPIE = SubDirPIEs;
            //SubDirWeaponsPIE = "components" & ospathseperator & "weapons" & ospathseperator
            SubDirWeaponsPIE = SubDirPIEs;
            SubDirTexpages = "texpages" + Convert.ToString(App.PlatformPathSeparator);
            SubDirAssignWeapons = "stats" + Convert.ToString(App.PlatformPathSeparator) + "assignweapons.txt";
            //SubDirFeaturePIE = "features" & ospathseperator
            SubDirFeaturePIE = SubDirPIEs;
            SubDirStructureWeapons = "stats" + Convert.ToString(App.PlatformPathSeparator) + "structureweapons.txt";

            SimpleList<clsTextFile> CommaFiles = new SimpleList<clsTextFile>();

            clsTextFile DataNames = new clsTextFile();
            DataNames.SubDirectory = SubDirNames;
            DataNames.UniqueField = 0;

            ReturnResult.Add(DataNames.LoadNamesFile(Path));
            if ( !DataNames.CalcUniqueField() )
            {
                ReturnResult.ProblemAdd("There are two entries for the same code in " + SubDirNames + ".");
            }

            clsTextFile DataStructures = new clsTextFile();
            DataStructures.SubDirectory = SubDirStructures;
            DataStructures.FieldCount = 25;
            CommaFiles.Add(DataStructures);

            clsTextFile DataBrain = new clsTextFile();
            DataBrain.SubDirectory = SubDirBrain;
            DataBrain.FieldCount = 9;
            CommaFiles.Add(DataBrain);

            clsTextFile DataBody = new clsTextFile();
            DataBody.SubDirectory = SubDirBody;
            DataBody.FieldCount = 25;
            CommaFiles.Add(DataBody);

            clsTextFile DataPropulsion = new clsTextFile();
            DataPropulsion.SubDirectory = SubDirPropulsion;
            DataPropulsion.FieldCount = 12;
            CommaFiles.Add(DataPropulsion);

            clsTextFile DataBodyPropulsion = new clsTextFile();
            DataBodyPropulsion.SubDirectory = SubDirBodyPropulsion;
            DataBodyPropulsion.FieldCount = 5;
            DataBodyPropulsion.UniqueField = -1; //no unique requirement
            CommaFiles.Add(DataBodyPropulsion);

            clsTextFile DataConstruction = new clsTextFile();
            DataConstruction.SubDirectory = SubDirConstruction;
            DataConstruction.FieldCount = 12;
            CommaFiles.Add(DataConstruction);

            clsTextFile DataSensor = new clsTextFile();
            DataSensor.SubDirectory = SubDirSensor;
            DataSensor.FieldCount = 16;
            CommaFiles.Add(DataSensor);

            clsTextFile DataRepair = new clsTextFile();
            DataRepair.SubDirectory = SubDirRepair;
            DataRepair.FieldCount = 14;
            CommaFiles.Add(DataRepair);

            clsTextFile DataTemplates = new clsTextFile();
            DataTemplates.SubDirectory = SubDirTemplates;
            DataTemplates.FieldCount = 12;
            CommaFiles.Add(DataTemplates);

            clsTextFile DataECM = new clsTextFile();
            DataECM.SubDirectory = SubDirECM;
            DataECM.FieldCount = 14;
            CommaFiles.Add(DataECM);

            clsTextFile DataFeatures = new clsTextFile();
            DataFeatures.SubDirectory = SubDirFeatures;
            DataFeatures.FieldCount = 11;
            CommaFiles.Add(DataFeatures);

            clsTextFile DataAssignWeapons = new clsTextFile();
            DataAssignWeapons.SubDirectory = SubDirAssignWeapons;
            DataAssignWeapons.FieldCount = 5;
            CommaFiles.Add(DataAssignWeapons);

            clsTextFile DataWeapons = new clsTextFile();
            DataWeapons.SubDirectory = SubDirWeapons;
            DataWeapons.FieldCount = 53;
            CommaFiles.Add(DataWeapons);

            clsTextFile DataStructureWeapons = new clsTextFile();
            DataStructureWeapons.SubDirectory = SubDirStructureWeapons;
            DataStructureWeapons.FieldCount = 6;
            CommaFiles.Add(DataStructureWeapons);

            clsTextFile TextFile = default(clsTextFile);

            foreach ( clsTextFile tempLoopVar_TextFile in CommaFiles )
            {
                TextFile = tempLoopVar_TextFile;
                clsResult Result = TextFile.LoadCommaFile(Path);
                ReturnResult.Add(Result);
                if ( !Result.HasProblems )
                {
                    if ( TextFile.CalcIsFieldCountValid() )
                    {
                        if ( !TextFile.CalcUniqueField() )
                        {
                            ReturnResult.ProblemAdd("An entry in field " + Convert.ToString(TextFile.UniqueField) + " was not unique for file " +
                                                    TextFile.SubDirectory + ".");
                        }
                    }
                    else
                    {
                        ReturnResult.ProblemAdd("There were entries with the wrong number of fields for file " + TextFile.SubDirectory + ".");
                    }
                }
            }

            if ( ReturnResult.HasProblems )
            {
                return ReturnResult;
            }

            //load texpages

            string[] TexFiles = null;

            try
            {
                TexFiles = Directory.GetFiles(Path + SubDirTexpages);
            }
            catch ( Exception )
            {
                ReturnResult.WarningAdd("Unable to access texture pages.");
                TexFiles = new string[0];
            }

            string Text = "";
            Bitmap Bitmap = null;
            int InstrPos2 = 0;
            BitmapGLTexture BitmapTextureArgs = new BitmapGLTexture();
            App.sResult BitmapResult = new App.sResult();

            foreach ( string tempLoopVar_Text in TexFiles )
            {
                Text = tempLoopVar_Text;
                if ( Text.Substring(Text.Length - 4, 4).ToLower() == ".png" )
                {
                    clsResult Result =
                        new clsResult("Loading texture page " + Convert.ToString(ControlChars.Quote) + Text + Convert.ToString(ControlChars.Quote));
                    if ( File.Exists(Text) )
                    {
                        BitmapResult = BitmapUtil.LoadBitmap(Text, ref Bitmap);
                        clsTexturePage NewPage = new clsTexturePage();
                        if ( BitmapResult.Success )
                        {
                            Result.Take(BitmapUtil.BitmapIsGLCompatible(Bitmap));
                            BitmapTextureArgs.MagFilter = TextureMagFilter.Nearest;
                            BitmapTextureArgs.MinFilter = TextureMinFilter.Nearest;
                            BitmapTextureArgs.TextureNum = 0;
                            BitmapTextureArgs.MipMapLevel = 0;
                            BitmapTextureArgs.Texture = Bitmap;
                            BitmapTextureArgs.Perform();
                            NewPage.GLTexture_Num = BitmapTextureArgs.TextureNum;
                        }
                        else
                        {
                            Result.WarningAdd(BitmapResult.Problem);
                        }
                        InstrPos2 = Strings.InStrRev(Text, App.PlatformPathSeparator.ToString(), -1, (CompareMethod)0);
                        NewPage.FileTitle = Strings.Mid(Text, InstrPos2 + 1, Text.Length - 4 - InstrPos2);
                        TexturePages.Add(NewPage);
                    }
                    else
                    {
                        Result.WarningAdd("Texture page missing (" + Text + ").");
                    }
                    ReturnResult.Add(Result);
                }
            }

            //load PIEs

            string[] PIE_Files = null;
            SimpleList<clsPIE> PIE_List = new SimpleList<clsPIE>();
            clsPIE NewPIE = default(clsPIE);

            try
            {
                PIE_Files = Directory.GetFiles(Path + SubDirPIEs);
            }
            catch ( Exception )
            {
                ReturnResult.WarningAdd("Unable to access PIE files.");
                PIE_Files = new string[0];
            }

            App.sSplitPath SplitPath = new App.sSplitPath();

            foreach ( string tempLoopVar_Text in PIE_Files )
            {
                Text = tempLoopVar_Text;
                SplitPath = new App.sSplitPath(Text);
                if ( SplitPath.FileExtension.ToLower() == "pie" )
                {
                    NewPIE = new clsPIE();
                    NewPIE.Path = Text;
                    NewPIE.LCaseFileTitle = SplitPath.FileTitle.ToLower();
                    PIE_List.Add(NewPIE);
                }
            }

            //interpret stats

            clsUnitType.clsAttachment Attachment = default(clsUnitType.clsAttachment);
            clsUnitType.clsAttachment BaseAttachment = default(clsUnitType.clsAttachment);
            sXYZ_sng Connector = new sXYZ_sng();
            clsStructureType StructureType = default(clsStructureType);
            clsFeatureType FeatureType = default(clsFeatureType);
            clsDroidTemplate Template = default(clsDroidTemplate);
            clsBody Body = default(clsBody);
            clsPropulsion Propulsion = default(clsPropulsion);
            clsConstruct Construct = default(clsConstruct);
            clsWeapon Weapon = default(clsWeapon);
            clsRepair Repair = default(clsRepair);
            clsSensor Sensor = default(clsSensor);
            clsBrain Brain = default(clsBrain);
            clsECM ECM = default(clsECM);
            string[] Fields = null;

            //interpret body

            foreach ( string[] tempLoopVar_Fields in DataBody.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Body = new clsBody();
                Body.ObjectDataLink.Connect(Bodies);
                Body.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Body, ReturnResult);
                IOUtil.InvariantParse(Fields[6], ref Body.Hitpoints);
                Body.Designable = Fields[24] != "0";
                Body.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[7].ToLower(), ReturnResult));
            }

            //interpret propulsion

            foreach ( string[] tempLoopVar_Fields in DataPropulsion.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Propulsion = new clsPropulsion(Bodies.Count);
                Propulsion.ObjectDataLink.Connect(Propulsions);
                Propulsion.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Propulsion, ReturnResult);
                IOUtil.InvariantParse(Fields[7], ref Propulsion.HitPoints);
                //.Propulsions(Propulsion_Num).PIE = LCase(DataPropulsion.Entries(Propulsion_Num).FieldValues(8))
                Propulsion.Designable = Fields[11] != "0";
            }

            //interpret body-propulsions

            BodyProp[,] BodyPropulsionPIEs = new BodyProp[Bodies.Count, Propulsions.Count];
            for ( int A = 0; A <= Bodies.Count - 1; A++ )
            {
                for ( int B = 0; B <= Propulsions.Count - 1; B++ )
                {
                    BodyPropulsionPIEs[A, B] = new BodyProp();
                    BodyPropulsionPIEs[A, B].LeftPIE = "0";
                    BodyPropulsionPIEs[A, B].RightPIE = "0";
                }
            }

            foreach ( string[] tempLoopVar_Fields in DataBodyPropulsion.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Body = FindBodyCode(Fields[0]);
                Propulsion = FindPropulsionCode(Fields[1]);
                if ( Body != null && Propulsion != null )
                {
                    if ( Fields[2] != "0" )
                    {
                        BodyPropulsionPIEs[Body.ObjectDataLink.ArrayPosition, Propulsion.ObjectDataLink.ArrayPosition].LeftPIE = Fields[2].ToLower();
                    }
                    if ( Fields[3] != "0" )
                    {
                        BodyPropulsionPIEs[Body.ObjectDataLink.ArrayPosition, Propulsion.ObjectDataLink.ArrayPosition].RightPIE = Fields[3].ToLower();
                    }
                }
            }

            //set propulsion-body PIEs

            for ( int A = 0; A <= Propulsions.Count - 1; A++ )
            {
                Propulsion = Propulsions[A];
                for ( int B = 0; B <= Bodies.Count - 1; B++ )
                {
                    Body = Bodies[B];
                    Propulsion.Bodies[B].LeftAttachment = new clsUnitType.clsAttachment();
                    Propulsion.Bodies[B].LeftAttachment.Models.Add(GetModelForPIE(PIE_List, BodyPropulsionPIEs[B, A].LeftPIE, ReturnResult));
                    Propulsion.Bodies[B].RightAttachment = new clsUnitType.clsAttachment();
                    Propulsion.Bodies[B].RightAttachment.Models.Add(GetModelForPIE(PIE_List, BodyPropulsionPIEs[B, A].RightPIE, ReturnResult));
                }
            }

            //interpret construction

            foreach ( string[] tempLoopVar_Fields in DataConstruction.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Construct = new clsConstruct();
                Construct.ObjectDataLink.Connect(Constructors);
                Construct.TurretObjectDataLink.Connect(Turrets);
                Construct.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Construct, ReturnResult);
                Construct.Designable = Fields[11] != "0";
                Construct.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[8].ToLower(), ReturnResult));
            }

            //interpret weapons

            foreach ( string[] tempLoopVar_Fields in DataWeapons.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Weapon = new clsWeapon();
                Weapon.ObjectDataLink.Connect(Weapons);
                Weapon.TurretObjectDataLink.Connect(Turrets);
                Weapon.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Weapon, ReturnResult);
                IOUtil.InvariantParse(Fields[7], ref Weapon.HitPoints);
                Weapon.Designable = Fields[51] != "0";
                Weapon.Attachment.Models.Add(GetModelForPIE(PIE_List, Convert.ToString(Fields[8].ToLower()), ReturnResult));
                Weapon.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[9].ToLower(), ReturnResult));
            }

            //interpret sensor

            foreach ( string[] tempLoopVar_Fields in DataSensor.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Sensor = new clsSensor();
                Sensor.ObjectDataLink.Connect(Sensors);
                Sensor.TurretObjectDataLink.Connect(Turrets);
                Sensor.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Sensor, ReturnResult);
                IOUtil.InvariantParse(Fields[7], ref Sensor.HitPoints);
                Sensor.Designable = Fields[15] != "0";
                switch ( Fields[11].ToLower() )
                {
                    case "turret":
                        Sensor.Location = clsSensor.enumLocation.Turret;
                        break;
                    case "default":
                        Sensor.Location = clsSensor.enumLocation.Invisible;
                        break;
                    default:
                        Sensor.Location = clsSensor.enumLocation.Invisible;
                        break;
                }
                Sensor.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[8].ToLower(), ReturnResult));
                Sensor.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[9].ToLower(), ReturnResult));
            }

            //interpret repair

            foreach ( string[] tempLoopVar_Fields in DataRepair.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Repair = new clsRepair();
                Repair.ObjectDataLink.Connect(Repairs);
                Repair.TurretObjectDataLink.Connect(Turrets);
                Repair.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Repair, ReturnResult);
                Repair.Designable = Fields[13] != "0";
                Repair.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[9].ToLower(), ReturnResult));
                Repair.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[10].ToLower(), ReturnResult));
            }

            //interpret brain

            foreach ( string[] tempLoopVar_Fields in DataBrain.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Brain = new clsBrain();
                Brain.ObjectDataLink.Connect(Brains);
                Brain.TurretObjectDataLink.Connect(Turrets);
                Brain.Code = Fields[0];
                SetComponentName(DataNames.ResultData, Brain, ReturnResult);
                Brain.Designable = true;
                Weapon = FindWeaponCode(Fields[7]);
                if ( Weapon != null )
                {
                    Brain.Weapon = Weapon;
                    Brain.Attachment = Weapon.Attachment;
                }
            }

            //interpret ecm

            foreach ( string[] tempLoopVar_Fields in DataECM.ResultData )
            {
                Fields = tempLoopVar_Fields;
                ECM = new clsECM();
                ECM.ObjectDataLink.Connect(ECMs);
                ECM.TurretObjectDataLink.Connect(Turrets);
                ECM.Code = Fields[0];
                SetComponentName(DataNames.ResultData, ECM, ReturnResult);
                IOUtil.InvariantParse(Fields[7], ref ECM.HitPoints);
                ECM.Designable = false;
                ECM.Attachment.Models.Add(GetModelForPIE(PIE_List, Fields[8].ToLower(), ReturnResult));
            }

            //interpret feature

            foreach ( string[] tempLoopVar_Fields in DataFeatures.ResultData )
            {
                Fields = tempLoopVar_Fields;
                FeatureType = new clsFeatureType();
                FeatureType.UnitType_ObjectDataLink.Connect(UnitTypes);
                FeatureType.FeatureType_ObjectDataLink.Connect(FeatureTypes);
                FeatureType.Code = Fields[0];
                if ( Fields[7] == "OIL RESOURCE" ) //type
                {
                    FeatureType.FeatureType = clsFeatureType.enumFeatureType.OilResource;
                }
                SetFeatureName(DataNames.ResultData, FeatureType, ReturnResult);
                if ( !IOUtil.InvariantParse(Fields[1], ref FeatureType.Footprint.X) )
                {
                    ReturnResult.WarningAdd("Feature footprint-x was not an integer for " + FeatureType.Code + ".");
                }
                if ( !IOUtil.InvariantParse(Fields[2], ref FeatureType.Footprint.Y) )
                {
                    ReturnResult.WarningAdd("Feature footprint-y was not an integer for " + FeatureType.Code + ".");
                }
                FeatureType.BaseAttachment = new clsUnitType.clsAttachment();
                BaseAttachment = FeatureType.BaseAttachment;
                Text = Fields[6].ToLower();
                Attachment = BaseAttachment.CreateAttachment();
                Attachment.Models.Add(GetModelForPIE(PIE_List, Text, ReturnResult));
            }

            //interpret structure

            foreach ( string[] tempLoopVar_Fields in DataStructures.ResultData )
            {
                Fields = tempLoopVar_Fields;
                string StructureCode = Fields[0];
                string StructureTypeText = Fields[1];
                string[] StructurePIEs = Fields[21].ToLower().Split('@');
                sXY_int StructureFootprint = new sXY_int();
                string StructureBasePIE = Fields[22].ToLower();
                if ( !IOUtil.InvariantParse(Fields[5], ref StructureFootprint.X) )
                {
                    ReturnResult.WarningAdd("Structure footprint-x was not an integer for " + StructureCode + ".");
                }
                if ( !IOUtil.InvariantParse(Fields[6], ref StructureFootprint.Y) )
                {
                    ReturnResult.WarningAdd("Structure footprint-y was not an integer for " + StructureCode + ".");
                }
                if ( StructureTypeText != "WALL" || StructurePIEs.GetLength(0) != 4 )
                {
                    //this is NOT a generic wall
                    StructureType = new clsStructureType();
                    StructureType.UnitType_ObjectDataLink.Connect(UnitTypes);
                    StructureType.StructureType_ObjectDataLink.Connect(StructureTypes);
                    StructureType.Code = StructureCode;
                    SetStructureName(DataNames.ResultData, StructureType, ReturnResult);
                    StructureType.Footprint = StructureFootprint;
                    switch ( StructureTypeText )
                    {
                        case "DEMOLISH":
                            StructureType.StructureType = clsStructureType.enumStructureType.Demolish;
                            break;
                        case "WALL":
                            StructureType.StructureType = clsStructureType.enumStructureType.Wall;
                            break;
                        case "CORNER WALL":
                            StructureType.StructureType = clsStructureType.enumStructureType.CornerWall;
                            break;
                        case "FACTORY":
                            StructureType.StructureType = clsStructureType.enumStructureType.Factory;
                            break;
                        case "CYBORG FACTORY":
                            StructureType.StructureType = clsStructureType.enumStructureType.CyborgFactory;
                            break;
                        case "VTOL FACTORY":
                            StructureType.StructureType = clsStructureType.enumStructureType.VTOLFactory;
                            break;
                        case "COMMAND":
                            StructureType.StructureType = clsStructureType.enumStructureType.Command;
                            break;
                        case "HQ":
                            StructureType.StructureType = clsStructureType.enumStructureType.HQ;
                            break;
                        case "DEFENSE":
                            StructureType.StructureType = clsStructureType.enumStructureType.Defense;
                            break;
                        case "POWER GENERATOR":
                            StructureType.StructureType = clsStructureType.enumStructureType.PowerGenerator;
                            break;
                        case "POWER MODULE":
                            StructureType.StructureType = clsStructureType.enumStructureType.PowerModule;
                            break;
                        case "RESEARCH":
                            StructureType.StructureType = clsStructureType.enumStructureType.Research;
                            break;
                        case "RESEARCH MODULE":
                            StructureType.StructureType = clsStructureType.enumStructureType.ResearchModule;
                            break;
                        case "FACTORY MODULE":
                            StructureType.StructureType = clsStructureType.enumStructureType.FactoryModule;
                            break;
                        case "DOOR":
                            StructureType.StructureType = clsStructureType.enumStructureType.DOOR;
                            break;
                        case "REPAIR FACILITY":
                            StructureType.StructureType = clsStructureType.enumStructureType.RepairFacility;
                            break;
                        case "SAT UPLINK":
                            StructureType.StructureType = clsStructureType.enumStructureType.DOOR;
                            break;
                        case "REARM PAD":
                            StructureType.StructureType = clsStructureType.enumStructureType.RearmPad;
                            break;
                        case "MISSILE SILO":
                            StructureType.StructureType = clsStructureType.enumStructureType.MissileSilo;
                            break;
                        case "RESOURCE EXTRACTOR":
                            StructureType.StructureType = clsStructureType.enumStructureType.ResourceExtractor;
                            break;
                        default:
                            StructureType.StructureType = clsStructureType.enumStructureType.Unknown;
                            break;
                    }

                    BaseAttachment = StructureType.BaseAttachment;
                    if ( StructurePIEs.GetLength(0) > 0 )
                    {
                        BaseAttachment.Models.Add(GetModelForPIE(PIE_List, StructurePIEs[0], ReturnResult));
                    }
                    StructureType.StructureBasePlate = GetModelForPIE(PIE_List, StructureBasePIE, ReturnResult);
                    if ( BaseAttachment.Models.Count == 1 )
                    {
                        if ( BaseAttachment.Models[0].ConnectorCount >= 1 )
                        {
                            Connector = BaseAttachment.Models[0].Connectors[0];
                            SimpleList<string[]> StructureWeapons = default(SimpleList<string[]>);
                            StructureWeapons = GetRowsWithValue(DataStructureWeapons.ResultData, StructureType.Code);
                            if ( StructureWeapons.Count > 0 )
                            {
                                Weapon = FindWeaponCode(Convert.ToString(StructureWeapons[0][1]));
                            }
                            else
                            {
                                Weapon = null;
                            }
                            ECM = FindECMCode(Fields[18]);
                            Sensor = FindSensorCode(Fields[19]);
                            if ( Weapon != null )
                            {
                                if ( Weapon.Code != "ZNULLWEAPON" )
                                {
                                    Attachment = BaseAttachment.CopyAttachment(Weapon.Attachment);
                                    Attachment.Pos_Offset = Connector;
                                }
                            }
                            if ( ECM != null )
                            {
                                if ( ECM.Code != "ZNULLECM" )
                                {
                                    Attachment = BaseAttachment.CopyAttachment(ECM.Attachment);
                                    Attachment.Pos_Offset = Connector;
                                }
                            }
                            if ( Sensor != null )
                            {
                                if ( Sensor.Code != "ZNULLSENSOR" )
                                {
                                    Attachment = BaseAttachment.CopyAttachment(Sensor.Attachment);
                                    Attachment.Pos_Offset = Connector;
                                }
                            }
                        }
                    }
                }
                else
                {
                    //this is a generic wall
                    clsWallType NewWall = new clsWallType();
                    NewWall.WallType_ObjectDataLink.Connect(WallTypes);
                    NewWall.Code = StructureCode;
                    SetWallName(DataNames.ResultData, NewWall, ReturnResult);
                    clsModel WallBasePlate = GetModelForPIE(PIE_List, StructureBasePIE, ReturnResult);

                    int WallNum = 0;
                    clsStructureType WallStructureType = default(clsStructureType);
                    for ( WallNum = 0; WallNum <= 3; WallNum++ )
                    {
                        WallStructureType = new clsStructureType();
                        WallStructureType.UnitType_ObjectDataLink.Connect(UnitTypes);
                        WallStructureType.StructureType_ObjectDataLink.Connect(StructureTypes);
                        WallStructureType.WallLink.Connect(NewWall.Segments);
                        WallStructureType.Code = StructureCode;
                        Text = NewWall.Name;
                        switch ( WallNum )
                        {
                            case 0:
                                Text += " - ";
                                break;
                            case 1:
                                Text += " + ";
                                break;
                            case 2:
                                Text += " T ";
                                break;
                            case 3:
                                Text += " L ";
                                break;
                        }
                        WallStructureType.Name = Text;
                        WallStructureType.Footprint = StructureFootprint;
                        WallStructureType.StructureType = clsStructureType.enumStructureType.Wall;

                        BaseAttachment = WallStructureType.BaseAttachment;

                        Text = StructurePIEs[WallNum];
                        BaseAttachment.Models.Add(GetModelForPIE(PIE_List, Text, ReturnResult));
                        WallStructureType.StructureBasePlate = WallBasePlate;
                    }
                }
            }

            //interpret templates

            int TurretConflictCount = 0;
            foreach ( string[] tempLoopVar_Fields in DataTemplates.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Template = new clsDroidTemplate();
                Template.UnitType_ObjectDataLink.Connect(UnitTypes);
                Template.DroidTemplate_ObjectDataLink.Connect(DroidTemplates);
                Template.Code = Fields[0];
                SetTemplateName(DataNames.ResultData, Template, ReturnResult);
                switch ( Fields[9] ) //type
                {
                    case "ZNULLDROID":
                        Template.TemplateDroidType = App.TemplateDroidType_Null;
                        break;
                    case "DROID":
                        Template.TemplateDroidType = App.TemplateDroidType_Droid;
                        break;
                    case "CYBORG":
                        Template.TemplateDroidType = App.TemplateDroidType_Cyborg;
                        break;
                    case "CYBORG_CONSTRUCT":
                        Template.TemplateDroidType = App.TemplateDroidType_CyborgConstruct;
                        break;
                    case "CYBORG_REPAIR":
                        Template.TemplateDroidType = App.TemplateDroidType_CyborgRepair;
                        break;
                    case "CYBORG_SUPER":
                        Template.TemplateDroidType = App.TemplateDroidType_CyborgSuper;
                        break;
                    case "TRANSPORTER":
                        Template.TemplateDroidType = App.TemplateDroidType_Transporter;
                        break;
                    case "PERSON":
                        Template.TemplateDroidType = App.TemplateDroidType_Person;
                        break;
                    default:
                        Template.TemplateDroidType = null;
                        ReturnResult.WarningAdd("Template " + Template.GetDisplayTextCode() + " had an unrecognised type.");
                        break;
                }
                clsDroidDesign.sLoadPartsArgs LoadPartsArgs = new clsDroidDesign.sLoadPartsArgs();
                LoadPartsArgs.Body = FindBodyCode(Fields[2]);
                LoadPartsArgs.Brain = FindBrainCode(Fields[3]);
                LoadPartsArgs.Construct = FindConstructorCode(Fields[4]);
                LoadPartsArgs.ECM = FindECMCode(Fields[5]);
                LoadPartsArgs.Propulsion = FindPropulsionCode(Fields[7]);
                LoadPartsArgs.Repair = FindRepairCode(Fields[8]);
                LoadPartsArgs.Sensor = FindSensorCode(Fields[10]);
                SimpleList<string[]> TemplateWeapons = GetRowsWithValue(DataAssignWeapons.ResultData, Template.Code);
                if ( TemplateWeapons.Count > 0 )
                {
                    Text = Convert.ToString(TemplateWeapons[0][1]);
                    if ( Text != "NULL" )
                    {
                        LoadPartsArgs.Weapon1 = FindWeaponCode(Text);
                    }
                    Text = Convert.ToString(TemplateWeapons[0][2]);
                    if ( Text != "NULL" )
                    {
                        LoadPartsArgs.Weapon2 = FindWeaponCode(Text);
                    }
                    Text = Convert.ToString(TemplateWeapons[0][3]);
                    if ( Text != "NULL" )
                    {
                        LoadPartsArgs.Weapon3 = FindWeaponCode(Text);
                    }
                }
                if ( !Template.LoadParts(LoadPartsArgs) )
                {
                    if ( TurretConflictCount < 16 )
                    {
                        ReturnResult.WarningAdd("Template " + Template.GetDisplayTextCode() + " had multiple conflicting turrets.");
                    }
                    TurretConflictCount++;
                }
            }
            if ( TurretConflictCount > 0 )
            {
                ReturnResult.WarningAdd(TurretConflictCount + " templates had multiple conflicting turrets.");
            }

            return ReturnResult;
        }