示例#1
0
        public clsResult LoadDirectory(string Path)
        {
            IEnumerator enumerator;
            clsResult result3 = new clsResult("Loading object data from \"" + Path + "\"");
            Path = modProgram.EndWithPathSeperator(Path);
            string str10 = "messages" + Conversions.ToString(modProgram.PlatformPathSeparator) + "strings" + Conversions.ToString(modProgram.PlatformPathSeparator) + "names.txt";
            string str17 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "structures.txt";
            string str5 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "brain.txt";
            string str3 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "body.txt";
            string str13 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "propulsion.txt";
            string str4 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "bodypropulsionimd.txt";
            string str6 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "construction.txt";
            string str15 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "sensor.txt";
            string str14 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "repair.txt";
            string str19 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "templates.txt";
            string str21 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "weapons.txt";
            string str7 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "ecm.txt";
            string str9 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "features.txt";
            string str11 = "pies" + Conversions.ToString(modProgram.PlatformPathSeparator);
            string str16 = str11;
            string str2 = str11;
            string str12 = str11;
            string str22 = str11;
            string str20 = "texpages" + Conversions.ToString(modProgram.PlatformPathSeparator);
            string str = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "assignweapons.txt";
            string str8 = str11;
            string str18 = "stats" + Conversions.ToString(modProgram.PlatformPathSeparator) + "structureweapons.txt";
            modLists.SimpleList<clsTextFile> list = new modLists.SimpleList<clsTextFile>();
            clsTextFile file8 = new clsTextFile {
                SubDirectory = str10,
                UniqueField = 0
            };
            result3.Add(file8.LoadNamesFile(Path));
            if (!file8.CalcUniqueField())
            {
                result3.ProblemAdd("There are two entries for the same code in " + str10 + ".");
            }
            clsTextFile newItem = new clsTextFile {
                SubDirectory = str17,
                FieldCount = 0x19
            };
            list.Add(newItem);
            clsTextFile file4 = new clsTextFile {
                SubDirectory = str5,
                FieldCount = 9
            };
            list.Add(file4);
            clsTextFile file2 = new clsTextFile {
                SubDirectory = str3,
                FieldCount = 0x19
            };
            list.Add(file2);
            clsTextFile file9 = new clsTextFile {
                SubDirectory = str13,
                FieldCount = 12
            };
            list.Add(file9);
            clsTextFile file3 = new clsTextFile {
                SubDirectory = str4,
                FieldCount = 5,
                UniqueField = -1
            };
            list.Add(file3);
            clsTextFile file5 = new clsTextFile {
                SubDirectory = str6,
                FieldCount = 12
            };
            list.Add(file5);
            clsTextFile file11 = new clsTextFile {
                SubDirectory = str15,
                FieldCount = 0x10
            };
            list.Add(file11);
            clsTextFile file10 = new clsTextFile {
                SubDirectory = str14,
                FieldCount = 14
            };
            list.Add(file10);
            clsTextFile file14 = new clsTextFile {
                SubDirectory = str19,
                FieldCount = 12
            };
            list.Add(file14);
            clsTextFile file6 = new clsTextFile {
                SubDirectory = str7,
                FieldCount = 14
            };
            list.Add(file6);
            clsTextFile file7 = new clsTextFile {
                SubDirectory = str9,
                FieldCount = 11
            };
            list.Add(file7);
            clsTextFile file = new clsTextFile {
                SubDirectory = str,
                FieldCount = 5
            };
            list.Add(file);
            clsTextFile file15 = new clsTextFile {
                SubDirectory = str21,
                FieldCount = 0x35
            };
            list.Add(file15);
            clsTextFile file13 = new clsTextFile {
                SubDirectory = str18,
                FieldCount = 6
            };
            list.Add(file13);
            try
            {
                enumerator = list.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    clsTextFile current = (clsTextFile) enumerator.Current;
                    clsResult resultToAdd = current.LoadCommaFile(Path);
                    result3.Add(resultToAdd);
                    if (!resultToAdd.HasProblems)
                    {
                        if (current.CalcIsFieldCountValid())
                        {
                            if (!current.CalcUniqueField())
                            {
                                result3.ProblemAdd("An entry in field " + Conversions.ToString(current.UniqueField) + " was not unique for file " + current.SubDirectory + ".");
                            }
                        }
                        else
                        {
                            result3.ProblemAdd("There were entries with the wrong number of fields for file " + current.SubDirectory + ".");
                        }
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            if (!result3.HasProblems)
            {
                clsUnitType.clsAttachment baseAttachment;
                clsBody body;
                clsECM secm;
                string[] strArray;
                string[] strArray2;
                clsPropulsion propulsion;
                clsSensor sensor;
                string[] files;
                clsWeapon weapon;
                IEnumerator enumerator2;
                IEnumerator enumerator3;
                IEnumerator enumerator4;
                IEnumerator enumerator5;
                IEnumerator enumerator6;
                IEnumerator enumerator7;
                IEnumerator enumerator8;
                IEnumerator enumerator9;
                IEnumerator enumerator10;
                IEnumerator enumerator11;
                IEnumerator enumerator12;
                IEnumerator enumerator13;
                try
                {
                    files = Directory.GetFiles(Path + str20);
                }
                catch (Exception exception1)
                {
                    ProjectData.SetProjectError(exception1);
                    Exception exception = exception1;
                    result3.WarningAdd("Unable to access texture pages.");
                    files = new string[0];
                    ProjectData.ClearProjectError();
                }
                System.Drawing.Bitmap resultBitmap = null;
                foreach (string str23 in files)
                {
                    if (Strings.Right(str23, 4).ToLower() == ".png")
                    {
                        clsResult result5 = new clsResult("Loading texture page \"" + str23 + "\"");
                        if (File.Exists(str23))
                        {
                            modProgram.sResult result = modBitmap.LoadBitmap(str23, ref resultBitmap);
                            clsTexturePage page = new clsTexturePage();
                            if (result.Success)
                            {
                                modBitmap.sBitmapGLTexture texture;
                                result5.Take(modBitmap.BitmapIsGLCompatible(resultBitmap));
                                texture.MagFilter = TextureMagFilter.Nearest;
                                texture.MinFilter = TextureMinFilter.Nearest;
                                texture.TextureNum = 0;
                                texture.MipMapLevel = 0;
                                texture.Texture = resultBitmap;
                                texture.Perform();
                                page.GLTexture_Num = texture.TextureNum;
                            }
                            else
                            {
                                result5.WarningAdd(result.Problem);
                            }
                            int num = Strings.InStrRev(str23, Conversions.ToString(modProgram.PlatformPathSeparator), -1, CompareMethod.Binary);
                            page.FileTitle = Strings.Mid(str23, num + 1, (str23.Length - 4) - num);
                            this.TexturePages.Add(page);
                        }
                        else
                        {
                            result5.WarningAdd("Texture page missing (" + str23 + ").");
                        }
                        result3.Add(result5);
                    }
                }
                modLists.SimpleList<clsPIE> list2 = new modLists.SimpleList<clsPIE>();
                try
                {
                    strArray2 = Directory.GetFiles(Path + str11);
                }
                catch (Exception exception3)
                {
                    ProjectData.SetProjectError(exception3);
                    Exception exception2 = exception3;
                    result3.WarningAdd("Unable to access PIE files.");
                    strArray2 = new string[0];
                    ProjectData.ClearProjectError();
                }
                foreach (string str23 in strArray2)
                {
                    modProgram.sSplitPath path = new modProgram.sSplitPath(str23);
                    if (path.FileExtension.ToLower() == "pie")
                    {
                        clsPIE spie = new clsPIE {
                            Path = str23,
                            LCaseFileTitle = path.FileTitle.ToLower()
                        };
                        list2.Add(spie);
                    }
                }
                try
                {
                    enumerator2 = file2.ResultData.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        strArray = (string[]) enumerator2.Current;
                        body = new clsBody();
                        body.ObjectDataLink.Connect(this.Bodies);
                        body.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, body, result3);
                        modIO.InvariantParse_int(strArray[6], ref body.Hitpoints);
                        body.Designable = strArray[0x18] != "0";
                        body.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[7].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator2 is IDisposable)
                    {
                        (enumerator2 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator3 = file9.ResultData.GetEnumerator();
                    while (enumerator3.MoveNext())
                    {
                        strArray = (string[]) enumerator3.Current;
                        propulsion = new clsPropulsion(this.Bodies.Count);
                        propulsion.ObjectDataLink.Connect(this.Propulsions);
                        propulsion.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, propulsion, result3);
                        modIO.InvariantParse_int(strArray[7], ref propulsion.HitPoints);
                        propulsion.Designable = strArray[11] != "0";
                    }
                }
                finally
                {
                    if (enumerator3 is IDisposable)
                    {
                        (enumerator3 as IDisposable).Dispose();
                    }
                }
                BodyProp[,] propArray = new BodyProp[(this.Bodies.Count - 1) + 1, (this.Propulsions.Count - 1) + 1];
                int num10 = this.Bodies.Count - 1;
                for (int i = 0; i <= num10; i++)
                {
                    int num11 = this.Propulsions.Count - 1;
                    for (int k = 0; k <= num11; k++)
                    {
                        propArray[i, k] = new BodyProp();
                        propArray[i, k].LeftPIE = "0";
                        propArray[i, k].RightPIE = "0";
                    }
                }
                try
                {
                    enumerator4 = file3.ResultData.GetEnumerator();
                    while (enumerator4.MoveNext())
                    {
                        strArray = (string[]) enumerator4.Current;
                        body = this.FindBodyCode(strArray[0]);
                        propulsion = this.FindPropulsionCode(strArray[1]);
                        if ((body != null) & (propulsion != null))
                        {
                            if (strArray[2] != "0")
                            {
                                propArray[body.ObjectDataLink.ArrayPosition, propulsion.ObjectDataLink.ArrayPosition].LeftPIE = strArray[2].ToLower();
                            }
                            if (strArray[3] != "0")
                            {
                                propArray[body.ObjectDataLink.ArrayPosition, propulsion.ObjectDataLink.ArrayPosition].RightPIE = strArray[3].ToLower();
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator4 is IDisposable)
                    {
                        (enumerator4 as IDisposable).Dispose();
                    }
                }
                int num12 = this.Propulsions.Count - 1;
                for (int j = 0; j <= num12; j++)
                {
                    propulsion = this.Propulsions[j];
                    int num13 = this.Bodies.Count - 1;
                    for (int m = 0; m <= num13; m++)
                    {
                        body = this.Bodies[m];
                        propulsion.Bodies[m].LeftAttachment = new clsUnitType.clsAttachment();
                        propulsion.Bodies[m].LeftAttachment.Models.Add(this.GetModelForPIE(list2, propArray[m, j].LeftPIE, result3));
                        propulsion.Bodies[m].RightAttachment = new clsUnitType.clsAttachment();
                        propulsion.Bodies[m].RightAttachment.Models.Add(this.GetModelForPIE(list2, propArray[m, j].RightPIE, result3));
                    }
                }
                try
                {
                    enumerator5 = file5.ResultData.GetEnumerator();
                    while (enumerator5.MoveNext())
                    {
                        strArray = (string[]) enumerator5.Current;
                        clsConstruct component = new clsConstruct();
                        component.ObjectDataLink.Connect(this.Constructors);
                        component.TurretObjectDataLink.Connect(this.Turrets);
                        component.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, component, result3);
                        component.Designable = strArray[11] != "0";
                        component.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[8].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator5 is IDisposable)
                    {
                        (enumerator5 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator6 = file15.ResultData.GetEnumerator();
                    while (enumerator6.MoveNext())
                    {
                        strArray = (string[]) enumerator6.Current;
                        weapon = new clsWeapon();
                        weapon.ObjectDataLink.Connect(this.Weapons);
                        weapon.TurretObjectDataLink.Connect(this.Turrets);
                        weapon.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, weapon, result3);
                        modIO.InvariantParse_int(strArray[7], ref weapon.HitPoints);
                        weapon.Designable = strArray[0x33] != "0";
                        weapon.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[8].ToLower(), result3));
                        weapon.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[9].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator6 is IDisposable)
                    {
                        (enumerator6 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator7 = file11.ResultData.GetEnumerator();
                    while (enumerator7.MoveNext())
                    {
                        strArray = (string[]) enumerator7.Current;
                        sensor = new clsSensor();
                        sensor.ObjectDataLink.Connect(this.Sensors);
                        sensor.TurretObjectDataLink.Connect(this.Turrets);
                        sensor.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, sensor, result3);
                        modIO.InvariantParse_int(strArray[7], ref sensor.HitPoints);
                        sensor.Designable = strArray[15] != "0";
                        string str27 = strArray[11].ToLower();
                        if (str27 == "turret")
                        {
                            sensor.Location = clsSensor.enumLocation.Turret;
                        }
                        else if (str27 == "default")
                        {
                            sensor.Location = clsSensor.enumLocation.Invisible;
                        }
                        else
                        {
                            sensor.Location = clsSensor.enumLocation.Invisible;
                        }
                        sensor.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[8].ToLower(), result3));
                        sensor.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[9].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator7 is IDisposable)
                    {
                        (enumerator7 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator8 = file10.ResultData.GetEnumerator();
                    while (enumerator8.MoveNext())
                    {
                        strArray = (string[]) enumerator8.Current;
                        clsRepair repair = new clsRepair();
                        repair.ObjectDataLink.Connect(this.Repairs);
                        repair.TurretObjectDataLink.Connect(this.Turrets);
                        repair.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, repair, result3);
                        repair.Designable = strArray[13] != "0";
                        repair.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[9].ToLower(), result3));
                        repair.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[10].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator8 is IDisposable)
                    {
                        (enumerator8 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator9 = file4.ResultData.GetEnumerator();
                    while (enumerator9.MoveNext())
                    {
                        strArray = (string[]) enumerator9.Current;
                        clsBrain brain = new clsBrain();
                        brain.ObjectDataLink.Connect(this.Brains);
                        brain.TurretObjectDataLink.Connect(this.Turrets);
                        brain.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, brain, result3);
                        brain.Designable = true;
                        weapon = this.FindWeaponCode(strArray[7]);
                        if (weapon != null)
                        {
                            brain.Weapon = weapon;
                            brain.Attachment = weapon.Attachment;
                        }
                    }
                }
                finally
                {
                    if (enumerator9 is IDisposable)
                    {
                        (enumerator9 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator10 = file6.ResultData.GetEnumerator();
                    while (enumerator10.MoveNext())
                    {
                        strArray = (string[]) enumerator10.Current;
                        secm = new clsECM();
                        secm.ObjectDataLink.Connect(this.ECMs);
                        secm.TurretObjectDataLink.Connect(this.Turrets);
                        secm.Code = strArray[0];
                        this.SetComponentName(file8.ResultData, secm, result3);
                        modIO.InvariantParse_int(strArray[7], ref secm.HitPoints);
                        secm.Designable = false;
                        secm.Attachment.Models.Add(this.GetModelForPIE(list2, strArray[8].ToLower(), result3));
                    }
                }
                finally
                {
                    if (enumerator10 is IDisposable)
                    {
                        (enumerator10 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator11 = file7.ResultData.GetEnumerator();
                    while (enumerator11.MoveNext())
                    {
                        strArray = (string[]) enumerator11.Current;
                        clsFeatureType featureType = new clsFeatureType();
                        featureType.UnitType_ObjectDataLink.Connect(this.UnitTypes);
                        featureType.FeatureType_ObjectDataLink.Connect(this.FeatureTypes);
                        featureType.Code = strArray[0];
                        if (strArray[7] == "OIL RESOURCE")
                        {
                            featureType.FeatureType = clsFeatureType.enumFeatureType.OilResource;
                        }
                        this.SetFeatureName(file8.ResultData, featureType, result3);
                        if (!modIO.InvariantParse_int(strArray[1], ref featureType.Footprint.X))
                        {
                            result3.WarningAdd("Feature footprint-x was not an integer for " + featureType.Code + ".");
                        }
                        if (!modIO.InvariantParse_int(strArray[2], ref featureType.Footprint.Y))
                        {
                            result3.WarningAdd("Feature footprint-y was not an integer for " + featureType.Code + ".");
                        }
                        featureType.BaseAttachment = new clsUnitType.clsAttachment();
                        baseAttachment = featureType.BaseAttachment;
                        name = strArray[6].ToLower();
                        baseAttachment.CreateAttachment().Models.Add(this.GetModelForPIE(list2, name, result3));
                    }
                }
                finally
                {
                    if (enumerator11 is IDisposable)
                    {
                        (enumerator11 as IDisposable).Dispose();
                    }
                }
                try
                {
                    enumerator12 = newItem.ResultData.GetEnumerator();
                    while (enumerator12.MoveNext())
                    {
                        modMath.sXY_int _int;
                        strArray = (string[]) enumerator12.Current;
                        string str25 = strArray[0];
                        string str26 = strArray[1];
                        string[] strArray4 = strArray[0x15].ToLower().Split(new char[] { '@' });
                        string str24 = strArray[0x16].ToLower();
                        if (!modIO.InvariantParse_int(strArray[5], ref _int.X))
                        {
                            result3.WarningAdd("Structure footprint-x was not an integer for " + str25 + ".");
                        }
                        if (!modIO.InvariantParse_int(strArray[6], ref _int.Y))
                        {
                            result3.WarningAdd("Structure footprint-y was not an integer for " + str25 + ".");
                        }
                        if ((str26 != "WALL") | (strArray4.GetLength(0) != 4))
                        {
                            clsStructureType structureType = new clsStructureType();
                            structureType.UnitType_ObjectDataLink.Connect(this.UnitTypes);
                            structureType.StructureType_ObjectDataLink.Connect(this.StructureTypes);
                            structureType.Code = str25;
                            this.SetStructureName(file8.ResultData, structureType, result3);
                            structureType.Footprint = _int;
                            string str28 = str26;
                            if (str28 == "DEMOLISH")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Demolish;
                            }
                            else if (str28 == "WALL")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Wall;
                            }
                            else if (str28 == "CORNER WALL")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.CornerWall;
                            }
                            else if (str28 == "FACTORY")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Factory;
                            }
                            else if (str28 == "CYBORG FACTORY")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.CyborgFactory;
                            }
                            else if (str28 == "VTOL FACTORY")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.VTOLFactory;
                            }
                            else if (str28 == "COMMAND")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Command;
                            }
                            else if (str28 == "HQ")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.HQ;
                            }
                            else if (str28 == "DEFENSE")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Defense;
                            }
                            else if (str28 == "POWER GENERATOR")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.PowerGenerator;
                            }
                            else if (str28 == "POWER MODULE")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.PowerModule;
                            }
                            else if (str28 == "RESEARCH")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Research;
                            }
                            else if (str28 == "RESEARCH MODULE")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.ResearchModule;
                            }
                            else if (str28 == "FACTORY MODULE")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.FactoryModule;
                            }
                            else if (str28 == "DOOR")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.DOOR;
                            }
                            else if (str28 == "REPAIR FACILITY")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.RepairFacility;
                            }
                            else if (str28 == "SAT UPLINK")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.DOOR;
                            }
                            else if (str28 == "REARM PAD")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.RearmPad;
                            }
                            else if (str28 == "MISSILE SILO")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.MissileSilo;
                            }
                            else if (str28 == "RESOURCE EXTRACTOR")
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.ResourceExtractor;
                            }
                            else
                            {
                                structureType.StructureType = clsStructureType.enumStructureType.Unknown;
                            }
                            baseAttachment = structureType.BaseAttachment;
                            if (strArray4.GetLength(0) > 0)
                            {
                                baseAttachment.Models.Add(this.GetModelForPIE(list2, strArray4[0], result3));
                            }
                            structureType.StructureBasePlate = this.GetModelForPIE(list2, str24, result3);
                            if ((baseAttachment.Models.Count == 1) && (baseAttachment.Models[0].ConnectorCount >= 1))
                            {
                                modMath.sXYZ_sng _sng = baseAttachment.Models[0].Connectors[0];
                                modLists.SimpleList<string[]> rowsWithValue = this.GetRowsWithValue(file13.ResultData, structureType.Code);
                                if (rowsWithValue.Count > 0)
                                {
                                    weapon = this.FindWeaponCode(rowsWithValue[0][1]);
                                }
                                else
                                {
                                    weapon = null;
                                }
                                secm = this.FindECMCode(strArray[0x12]);
                                sensor = this.FindSensorCode(strArray[0x13]);
                                if ((weapon != null) && (weapon.Code != "ZNULLWEAPON"))
                                {
                                    baseAttachment.CopyAttachment(weapon.Attachment).Pos_Offset = _sng;
                                }
                                if ((secm != null) && (secm.Code != "ZNULLECM"))
                                {
                                    baseAttachment.CopyAttachment(secm.Attachment).Pos_Offset = _sng;
                                }
                                if ((sensor != null) && (sensor.Code != "ZNULLSENSOR"))
                                {
                                    baseAttachment.CopyAttachment(sensor.Attachment).Pos_Offset = _sng;
                                }
                            }
                            continue;
                        }
                        clsWallType wallType = new clsWallType();
                        wallType.WallType_ObjectDataLink.Connect(this.WallTypes);
                        wallType.Code = str25;
                        this.SetWallName(file8.ResultData, wallType, result3);
                        clsModel model = this.GetModelForPIE(list2, str24, result3);
                        int index = 0;
                        do
                        {
                            clsStructureType type4 = new clsStructureType();
                            type4.UnitType_ObjectDataLink.Connect(this.UnitTypes);
                            type4.StructureType_ObjectDataLink.Connect(this.StructureTypes);
                            type4.WallLink.Connect(wallType.Segments);
                            type4.Code = str25;
                            name = wallType.Name;
                            switch (index)
                            {
                                case 0:
                                    name = name + " - ";
                                    break;

                                case 1:
                                    name = name + " + ";
                                    break;

                                case 2:
                                    name = name + " T ";
                                    break;

                                case 3:
                                    name = name + " L ";
                                    break;
                            }
                            type4.Name = name;
                            type4.Footprint = _int;
                            type4.StructureType = clsStructureType.enumStructureType.Wall;
                            baseAttachment = type4.BaseAttachment;
                            name = strArray4[index];
                            baseAttachment.Models.Add(this.GetModelForPIE(list2, name, result3));
                            type4.StructureBasePlate = model;
                            index++;
                        }
                        while (index <= 3);
                    }
                }
                finally
                {
                    if (enumerator12 is IDisposable)
                    {
                        (enumerator12 as IDisposable).Dispose();
                    }
                }
                int num2 = 0;
                try
                {
                    enumerator13 = file14.ResultData.GetEnumerator();
                    while (enumerator13.MoveNext())
                    {
                        strArray = (string[]) enumerator13.Current;
                        clsDroidTemplate template = new clsDroidTemplate();
                        template.UnitType_ObjectDataLink.Connect(this.UnitTypes);
                        template.DroidTemplate_ObjectDataLink.Connect(this.DroidTemplates);
                        template.Code = strArray[0];
                        this.SetTemplateName(file8.ResultData, template, result3);
                        string str29 = strArray[9];
                        if (str29 == "ZNULLDROID")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_Null;
                        }
                        else if (str29 == "DROID")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_Droid;
                        }
                        else if (str29 == "CYBORG")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_Cyborg;
                        }
                        else if (str29 == "CYBORG_CONSTRUCT")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_CyborgConstruct;
                        }
                        else if (str29 == "CYBORG_REPAIR")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_CyborgRepair;
                        }
                        else if (str29 == "CYBORG_SUPER")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_CyborgSuper;
                        }
                        else if (str29 == "TRANSPORTER")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_Transporter;
                        }
                        else if (str29 == "PERSON")
                        {
                            template.TemplateDroidType = modProgram.TemplateDroidType_Person;
                        }
                        else
                        {
                            template.TemplateDroidType = null;
                            result3.WarningAdd("Template " + template.GetDisplayTextCode() + " had an unrecognised type.");
                        }
                        clsDroidDesign.sLoadPartsArgs args = new clsDroidDesign.sLoadPartsArgs {
                            Body = this.FindBodyCode(strArray[2]),
                            Brain = this.FindBrainCode(strArray[3]),
                            Construct = this.FindConstructorCode(strArray[4]),
                            ECM = this.FindECMCode(strArray[5]),
                            Propulsion = this.FindPropulsionCode(strArray[7]),
                            Repair = this.FindRepairCode(strArray[8]),
                            Sensor = this.FindSensorCode(strArray[10])
                        };
                        modLists.SimpleList<string[]> list4 = this.GetRowsWithValue(file.ResultData, template.Code);
                        if (list4.Count > 0)
                        {
                            name = list4[0][1];
                            if (name != "NULL")
                            {
                                args.Weapon1 = this.FindWeaponCode(name);
                            }
                            name = list4[0][2];
                            if (name != "NULL")
                            {
                                args.Weapon2 = this.FindWeaponCode(name);
                            }
                            name = list4[0][3];
                            if (name != "NULL")
                            {
                                args.Weapon3 = this.FindWeaponCode(name);
                            }
                        }
                        if (!template.LoadParts(args))
                        {
                            if (num2 < 0x10)
                            {
                                result3.WarningAdd("Template " + template.GetDisplayTextCode() + " had multiple conflicting turrets.");
                            }
                            num2++;
                        }
                    }
                }
                finally
                {
                    if (enumerator13 is IDisposable)
                    {
                        (enumerator13 as IDisposable).Dispose();
                    }
                }
                if (num2 > 0)
                {
                    result3.WarningAdd(Conversions.ToString(num2) + " templates had multiple conflicting turrets.");
                }
            }
            return result3;
        }
示例#2
0
        public clsResult LoadDirectory(string Path)
        {
            var ReturnResult = new clsResult(string.Format("Loading object data from \"{0}\"", Path));

            Path = PathUtil.EndWithPathSeperator(Path);

            var SubDirNames = "";
            var SubDirStructures = "";
            var SubDirBrain = "";
            var SubDirBody = "";
            var SubDirPropulsion = "";
            var SubDirBodyPropulsion = "";
            var SubDirConstruction = "";
            var SubDirSensor = "";
            var SubDirRepair = "";
            var SubDirTemplates = "";
            var SubDirWeapons = "";
            var SubDirECM = "";
            var SubDirFeatures = "";
            var SubDirTexpages = "";
            var SubDirAssignWeapons = "";
            var SubDirStructureWeapons = "";
            var 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
            //SubDirBodiesPIE = "components" & ospathseperator & "bodies" & ospathseperator
            //SubDirPropPIE = "components" & ospathseperator & "prop" & ospathseperator
            //SubDirWeaponsPIE = "components" & ospathseperator & "weapons" & ospathseperator
            SubDirTexpages = "texpages" + Convert.ToString(App.PlatformPathSeparator);
            SubDirAssignWeapons = "stats" + Convert.ToString(App.PlatformPathSeparator) + "assignweapons.txt";
            //SubDirFeaturePIE = "features" & ospathseperator
            SubDirStructureWeapons = "stats" + Convert.ToString(App.PlatformPathSeparator) + "structureweapons.txt";

            var CommaFiles = new SimpleList<clsTextFile>();

            var 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 + ".");
            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            var TextFile = default(clsTextFile);

            foreach ( var tempLoopVar_TextFile in CommaFiles )
            {
                TextFile = tempLoopVar_TextFile;
                var 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];
            }

            var Text = "";
            Bitmap Bitmap = null;
            var InstrPos2 = 0;
            var BitmapTextureArgs = new BitmapGLTexture();
            var BitmapResult = new sResult();

            foreach ( var tempLoopVar_Text in TexFiles )
            {
                Text = tempLoopVar_Text;
                if ( Text.Substring(Text.Length - 4, 4).ToLower() == ".png" )
                {
                    var Result = new clsResult(string.Format("Loading texture page \"{0}\"", Text));
                    if ( File.Exists(Text) )
                    {
                        BitmapResult = BitmapUtil.LoadBitmap(Text, ref Bitmap);
                        var 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 = Text.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                        NewPage.FileTitle = Text.Substring(InstrPos2 + 1, Text.Length - 5 - InstrPos2);

                        TexturePages.Add(NewPage);
                    }
                    else
                    {
                        Result.WarningAdd("Texture page missing (" + Text + ").");
                    }
                    ReturnResult.Add(Result);
                }
            }

            //load PIEs

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

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

            var SplitPath = new sSplitPath();

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

            //interpret stats

            var Attachment = default(clsAttachment);
            var BaseAttachment = default(clsAttachment);
            var Connector = new XYZDouble();
            var structureTypeBase = default(StructureTypeBase);
            var featureTypeBase = default(FeatureTypeBase);
            var Template = default(DroidTemplate);
            var Body = default(Body);
            var Propulsion = default(Propulsion);
            var Construct = default(Construct);
            var Weapon = default(Weapon);
            var Repair = default(Repair);
            var Sensor = default(Sensor);
            var Brain = default(Brain);
            var ECM = default(Ecm);
            string[] Fields = null;

            //interpret body

            foreach ( var tempLoopVar_Fields in DataBody.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Body = new Body();
                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 ( var tempLoopVar_Fields in DataPropulsion.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Propulsion = new Propulsion(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

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

            foreach ( var 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 ( var A = 0; A <= Propulsions.Count - 1; A++ )
            {
                Propulsion = Propulsions[A];
                for ( var B = 0; B <= Bodies.Count - 1; B++ )
                {
                    Body = Bodies[B];
                    Propulsion.Bodies[B].LeftAttachment = new clsAttachment();
                    Propulsion.Bodies[B].LeftAttachment.Models.Add(GetModelForPIE(PIE_List, BodyPropulsionPIEs[B, A].LeftPIE, ReturnResult));
                    Propulsion.Bodies[B].RightAttachment = new clsAttachment();
                    Propulsion.Bodies[B].RightAttachment.Models.Add(GetModelForPIE(PIE_List, BodyPropulsionPIEs[B, A].RightPIE, ReturnResult));
                }
            }

            //interpret construction

            foreach ( var tempLoopVar_Fields in DataConstruction.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Construct = new Construct();
                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 ( var tempLoopVar_Fields in DataWeapons.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Weapon = new Weapon();
                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 ( var tempLoopVar_Fields in DataSensor.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Sensor = new Sensor();
                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 = Sensor.enumLocation.Turret;
                        break;
                    case "default":
                        Sensor.Location = Sensor.enumLocation.Invisible;
                        break;
                    default:
                        Sensor.Location = Sensor.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 ( var tempLoopVar_Fields in DataRepair.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Repair = new Repair();
                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 ( var tempLoopVar_Fields in DataBrain.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Brain = new Brain();
                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 ( var tempLoopVar_Fields in DataECM.ResultData )
            {
                Fields = tempLoopVar_Fields;
                ECM = new Ecm();
                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 ( var tempLoopVar_Fields in DataFeatures.ResultData )
            {
                Fields = tempLoopVar_Fields;
                featureTypeBase = new FeatureTypeBase();
                featureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes);
                featureTypeBase.FeatureType_ObjectDataLink.Connect(FeatureTypes);
                featureTypeBase.Code = Fields[0];
                if ( Fields[7] == "OIL RESOURCE" ) //type
                {
                    featureTypeBase.FeatureType = FeatureTypeBase.enumFeatureType.OilResource;
                }
                SetFeatureName(DataNames.ResultData, featureTypeBase, ReturnResult);
                if ( !IOUtil.InvariantParse(Fields[1], ref featureTypeBase.Footprint.X) )
                {
                    ReturnResult.WarningAdd("Feature footprint-x was not an integer for " + featureTypeBase.Code + ".");
                }
                if ( !IOUtil.InvariantParse(Fields[2], ref featureTypeBase.Footprint.Y) )
                {
                    ReturnResult.WarningAdd("Feature footprint-y was not an integer for " + featureTypeBase.Code + ".");
                }
                featureTypeBase.BaseAttachment = new clsAttachment();
                BaseAttachment = featureTypeBase.BaseAttachment;
                Text = Fields[6].ToLower();
                Attachment = BaseAttachment.CreateAttachment();
                Attachment.Models.Add(GetModelForPIE(PIE_List, Text, ReturnResult));
            }

            //interpret structure

            foreach ( var tempLoopVar_Fields in DataStructures.ResultData )
            {
                Fields = tempLoopVar_Fields;
                var StructureCode = Fields[0];
                var StructureTypeText = Fields[1];
                var StructurePIEs = Fields[21].ToLower().Split('@');
                var StructureFootprint = new XYInt();
                var 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
                    structureTypeBase = new StructureTypeBase();
                    structureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes);
                    structureTypeBase.StructureType_ObjectDataLink.Connect(StructureTypes);
                    structureTypeBase.Code = StructureCode;
                    SetStructureName(DataNames.ResultData, structureTypeBase, ReturnResult);
                    structureTypeBase.Footprint = StructureFootprint;
                    switch ( StructureTypeText )
                    {
                        case "DEMOLISH":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Demolish;
                            break;
                        case "WALL":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Wall;
                            break;
                        case "CORNER WALL":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.CornerWall;
                            break;
                        case "FACTORY":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Factory;
                            break;
                        case "CYBORG FACTORY":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.CyborgFactory;
                            break;
                        case "VTOL FACTORY":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.VTOLFactory;
                            break;
                        case "COMMAND":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Command;
                            break;
                        case "HQ":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.HQ;
                            break;
                        case "DEFENSE":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Defense;
                            break;
                        case "POWER GENERATOR":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.PowerGenerator;
                            break;
                        case "POWER MODULE":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.PowerModule;
                            break;
                        case "RESEARCH":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Research;
                            break;
                        case "RESEARCH MODULE":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.ResearchModule;
                            break;
                        case "FACTORY MODULE":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.FactoryModule;
                            break;
                        case "DOOR":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.DOOR;
                            break;
                        case "REPAIR FACILITY":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.RepairFacility;
                            break;
                        case "SAT UPLINK":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.DOOR;
                            break;
                        case "REARM PAD":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.RearmPad;
                            break;
                        case "MISSILE SILO":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.MissileSilo;
                            break;
                        case "RESOURCE EXTRACTOR":
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.ResourceExtractor;
                            break;
                        default:
                            structureTypeBase.StructureType = StructureTypeBase.enumStructureType.Unknown;
                            break;
                    }

                    BaseAttachment = structureTypeBase.BaseAttachment;
                    if ( StructurePIEs.GetLength(0) > 0 )
                    {
                        BaseAttachment.Models.Add(GetModelForPIE(PIE_List, StructurePIEs[0], ReturnResult));
                    }
                    structureTypeBase.StructureBasePlate = GetModelForPIE(PIE_List, StructureBasePIE, ReturnResult);
                    if ( BaseAttachment.Models.Count == 1 )
                    {
                        if ( BaseAttachment.Models[0].ConnectorCount >= 1 )
                        {
                            Connector = BaseAttachment.Models[0].Connectors[0];
                            var StructureWeapons = default(SimpleList<string[]>);
                            StructureWeapons = GetRowsWithValue(DataStructureWeapons.ResultData, structureTypeBase.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
                    var NewWall = new clsWallType();
                    NewWall.WallType_ObjectDataLink.Connect(WallTypes);
                    NewWall.Code = StructureCode;
                    SetWallName(DataNames.ResultData, NewWall, ReturnResult);
                    var WallBasePlate = GetModelForPIE(PIE_List, StructureBasePIE, ReturnResult);

                    var WallNum = 0;
                    var wallStructureTypeBase = default(StructureTypeBase);
                    for ( WallNum = 0; WallNum <= 3; WallNum++ )
                    {
                        wallStructureTypeBase = new StructureTypeBase();
                        wallStructureTypeBase.UnitType_ObjectDataLink.Connect(UnitTypes);
                        wallStructureTypeBase.StructureType_ObjectDataLink.Connect(StructureTypes);
                        wallStructureTypeBase.WallLink.Connect(NewWall.Segments);
                        wallStructureTypeBase.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;
                        }
                        wallStructureTypeBase.Name = Text;
                        wallStructureTypeBase.Footprint = StructureFootprint;
                        wallStructureTypeBase.StructureType = StructureTypeBase.enumStructureType.Wall;

                        BaseAttachment = wallStructureTypeBase.BaseAttachment;

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

            //interpret templates

            var TurretConflictCount = 0;
            foreach ( var tempLoopVar_Fields in DataTemplates.ResultData )
            {
                Fields = tempLoopVar_Fields;
                Template = new DroidTemplate();
                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;
                }
                var LoadPartsArgs = new DroidDesign.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]);
                var 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;
        }