Ejemplo n.º 1
0
        public clsResult Read_FMap_Gateways(StreamReader File)
        {
            clsResult ReturnResult = new clsResult("Reading gateways");

            IniReader GatewaysINI = new IniReader();
            ReturnResult.Take(GatewaysINI.ReadFile(File));

            FMapIniGateways INIGateways = new FMapIniGateways(GatewaysINI.Sections.Count);
            ReturnResult.Take(GatewaysINI.Translate(INIGateways));

            int A = 0;
            int InvalidGatewayCount = 0;

            for ( A = 0; A <= INIGateways.GatewayCount - 1; A++ )
            {
                if ( GatewayCreate(INIGateways.Gateways[A].PosA, INIGateways.Gateways[A].PosB) == null )
                {
                    InvalidGatewayCount++;
                }
            }

            if ( InvalidGatewayCount > 0 )
            {
                ReturnResult.WarningAdd(InvalidGatewayCount + " gateways were invalid.");
            }

            return ReturnResult;
        }
Ejemplo n.º 2
0
        public clsResult Load_WZ(string Path)
        {
            clsResult ReturnResult =
                new clsResult("Loading WZ from " + Convert.ToString(ControlChars.Quote) + Path + Convert.ToString(ControlChars.Quote));
            App.sResult SubResult = new App.sResult();
            string Quote = ControlChars.Quote.ToString();
            ZipEntry ZipEntry = default(ZipEntry);
            bool GameFound = default(bool);
            bool DatasetFound = default(bool);
            SimpleList<clsWZMapEntry> Maps = new SimpleList<clsWZMapEntry>();
            clsTileset GameTileset = null;
            string GameName = "";
            string strTemp = "";
            ZipSplitPath SplitPath;
            int A = 0;
            int B = 0;
            int C = 0;
            int D = 0;

            FileStream File = default(FileStream);
            try
            {
                File = System.IO.File.OpenRead(Path);
            }
            catch ( Exception ex )
            {
                ReturnResult.ProblemAdd(ex.Message);
                return ReturnResult;
            }

            ZipInputStream ZipStream = new ZipInputStream(File);

            //get all usable lev entries
            do
            {
                ZipEntry = ZipStream.GetNextEntry();
                if ( ZipEntry == null )
                {
                    break;
                }

                SplitPath = new ZipSplitPath(ZipEntry.Name);

                if ( SplitPath.FileExtension == "lev" && SplitPath.PartCount == 1 )
                {
                    if ( ZipEntry.Size > 10 * 1024 * 1024 )
                    {
                        ReturnResult.ProblemAdd("lev file is too large.");
                        ZipStream.Close();
                        return ReturnResult;
                    }
                    BinaryReader Reader = new BinaryReader(ZipStream);
                    SimpleList<string> LineData = IOUtil.BytesToLinesRemoveComments(Reader);
                    //find each level block
                    for ( A = 0; A <= LineData.Count - 1; A++ )
                    {
                        if ( Strings.LCase(Strings.Left(LineData[A], 5)) == "level" )
                        {
                            //find each levels game file
                            GameFound = false;
                            B = 1;
                            while ( A + B < LineData.Count )
                            {
                                if ( Strings.LCase(Strings.Left(Convert.ToString(LineData[A + B]), 4)) == "game" )
                                {
                                    C = Strings.InStr(Convert.ToString(LineData[A + B]), Quote, (CompareMethod)0);
                                    D = Strings.InStrRev(Convert.ToString(LineData[A + B]), Quote, -1, (CompareMethod)0);
                                    if ( C > 0 & D > 0 & D - C > 1 )
                                    {
                                        GameName = Strings.LCase(Strings.Mid(Convert.ToString(LineData[A + B]), C + 1, D - C - 1));
                                        //see if map is already counted
                                        for ( C = 0; C <= Maps.Count - 1; C++ )
                                        {
                                            if ( GameName == Maps[C].Name )
                                            {
                                                break;
                                            }
                                        }
                                        if ( C == Maps.Count )
                                        {
                                            GameFound = true;
                                        }
                                    }
                                    break;
                                }
                                else if ( Strings.LCase(Strings.Left(Convert.ToString(LineData[A + B]), 5)) == "level" )
                                {
                                    break;
                                }
                                B++;
                            }
                            if ( GameFound )
                            {
                                //find the dataset (determines tileset)
                                DatasetFound = false;
                                B = 1;
                                while ( A + B < LineData.Count )
                                {
                                    if ( Strings.LCase(Strings.Left(Convert.ToString(LineData[A + B]), 7)) == "dataset" )
                                    {
                                        strTemp = Strings.LCase(Strings.Right(Convert.ToString(LineData[A + B]), 1));
                                        if ( strTemp == "1" )
                                        {
                                            GameTileset = App.Tileset_Arizona;
                                            DatasetFound = true;
                                        }
                                        else if ( strTemp == "2" )
                                        {
                                            GameTileset = App.Tileset_Urban;
                                            DatasetFound = true;
                                        }
                                        else if ( strTemp == "3" )
                                        {
                                            GameTileset = App.Tileset_Rockies;
                                            DatasetFound = true;
                                        }
                                        break;
                                    }
                                    else if ( Strings.LCase(Strings.Left(Convert.ToString(LineData[A + B]), 5)) == "level" )
                                    {
                                        break;
                                    }
                                    B++;
                                }
                                if ( DatasetFound )
                                {
                                    clsWZMapEntry NewMap = new clsWZMapEntry();
                                    NewMap.Name = GameName;
                                    NewMap.Tileset = GameTileset;
                                    Maps.Add(NewMap);
                                }
                            }
                        }
                    }
                }
            } while ( true );
            ZipStream.Close();

            string MapLoadName = "";

            //prompt user for which of the entries to load
            if ( Maps.Count < 1 )
            {
                ReturnResult.ProblemAdd("No maps found in file.");
                return ReturnResult;
            }
            else if ( Maps.Count == 1 )
            {
                MapLoadName = Convert.ToString(Maps[0].Name);
                Tileset = Maps[0].Tileset;
            }
            else
            {
                frmWZLoad.clsOutput SelectToLoadResult = new frmWZLoad.clsOutput();
                string[] Names = new string[Maps.Count];
                for ( A = 0; A <= Maps.Count - 1; A++ )
                {
                    Names[A] = Convert.ToString(Maps[A].Name);
                }
                frmWZLoad SelectToLoadForm = new frmWZLoad(Names, SelectToLoadResult,
                    "Select a map from " + Convert.ToString(new App.sSplitPath(Path).FileTitle));
                SelectToLoadForm.ShowDialog();
                if ( SelectToLoadResult.Result < 0 )
                {
                    ReturnResult.ProblemAdd("No map selected.");
                    return ReturnResult;
                }
                MapLoadName = Convert.ToString(Maps[SelectToLoadResult.Result].Name);
                Tileset = Maps[SelectToLoadResult.Result].Tileset;
            }

            TileType_Reset();
            SetPainterToDefaults();

            ZipSplitPath GameSplitPath = new ZipSplitPath(MapLoadName);
            string GameFilesPath = GameSplitPath.FilePath + GameSplitPath.FileTitleWithoutExtension + "/";

            ZipStreamEntry ZipSearchResult = default(ZipStreamEntry);

            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, MapLoadName);
            if ( ZipSearchResult == null )
            {
                ReturnResult.ProblemAdd("Game file not found.");
                return ReturnResult;
            }
            else
            {
                BinaryReader Map_Reader = new BinaryReader(ZipSearchResult.Stream);
                SubResult = Read_WZ_gam(Map_Reader);
                Map_Reader.Close();

                if ( !SubResult.Success )
                {
                    ReturnResult.ProblemAdd(SubResult.Problem);
                    return ReturnResult;
                }
            }

            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "game.map");
            if ( ZipSearchResult == null )
            {
                ReturnResult.ProblemAdd("game.map file not found");
                return ReturnResult;
            }
            else
            {
                BinaryReader Map_Reader = new BinaryReader(ZipSearchResult.Stream);
                SubResult = Read_WZ_map(Map_Reader);
                Map_Reader.Close();

                if ( !SubResult.Success )
                {
                    ReturnResult.ProblemAdd(SubResult.Problem);
                    return ReturnResult;
                }
            }

            SimpleClassList<clsWZBJOUnit> BJOUnits = new SimpleClassList<clsWZBJOUnit>();

            IniFeatures INIFeatures = null;

            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "feature.ini");
            if ( ZipSearchResult == null )
            {
            }
            else
            {
                clsResult Result = new clsResult("feature.ini");
                IniReader FeaturesINI = new IniReader();
                StreamReader FeaturesINI_Reader = new StreamReader(ZipSearchResult.Stream);
                Result.Take(FeaturesINI.ReadFile(FeaturesINI_Reader));
                FeaturesINI_Reader.Close();
                INIFeatures = new IniFeatures(FeaturesINI.Sections.Count);
                Result.Take(FeaturesINI.Translate(INIFeatures));
                ReturnResult.Add(Result);
            }

            if ( INIFeatures == null )
            {
                clsResult Result = new clsResult("feat.bjo");
                ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "feat.bjo");
                if ( ZipSearchResult == null )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader Features_Reader = new BinaryReader(ZipSearchResult.Stream);
                    SubResult = Read_WZ_Features(Features_Reader, BJOUnits);
                    Features_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            if ( true )
            {
                clsResult Result = new clsResult("ttypes.ttp");
                ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "ttypes.ttp");
                if ( ZipSearchResult == null )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader TileTypes_Reader = new BinaryReader(ZipSearchResult.Stream);
                    SubResult = Read_WZ_TileTypes(TileTypes_Reader);
                    TileTypes_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            IniStructures INIStructures = null;

            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "struct.ini");
            if ( ZipSearchResult == null )
            {
            }
            else
            {
                clsResult Result = new clsResult("struct.ini");
                IniReader StructuresINI = new IniReader();
                StreamReader StructuresINI_Reader = new StreamReader(ZipSearchResult.Stream);
                Result.Take(StructuresINI.ReadFile(StructuresINI_Reader));
                StructuresINI_Reader.Close();
                INIStructures = new IniStructures(StructuresINI.Sections.Count, this);
                Result.Take(StructuresINI.Translate(INIStructures));
                ReturnResult.Add(Result);
            }

            if ( INIStructures == null )
            {
                clsResult Result = new clsResult("struct.bjo");
                ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "struct.bjo");
                if ( ZipSearchResult == null )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader Structures_Reader = new BinaryReader(ZipSearchResult.Stream);
                    SubResult = Read_WZ_Structures(Structures_Reader, BJOUnits);
                    Structures_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            IniDroids INIDroids = null;

            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "droid.ini");
            if ( ZipSearchResult == null )
            {
            }
            else
            {
                clsResult Result = new clsResult("droid.ini");
                IniReader DroidsINI = new IniReader();
                StreamReader DroidsINI_Reader = new StreamReader(ZipSearchResult.Stream);
                Result.Take(DroidsINI.ReadFile(DroidsINI_Reader));
                DroidsINI_Reader.Close();
                INIDroids = new IniDroids(DroidsINI.Sections.Count, this);
                Result.Take(DroidsINI.Translate(INIDroids));
                ReturnResult.Add(Result);
            }

            if ( INIDroids == null )
            {
                clsResult Result = new clsResult("dinit.bjo");
                ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "dinit.bjo");
                if ( ZipSearchResult == null )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader Droids_Reader = new BinaryReader(ZipSearchResult.Stream);
                    SubResult = Read_WZ_Droids(Droids_Reader, BJOUnits);
                    Droids_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            sCreateWZObjectsArgs CreateObjectsArgs = new sCreateWZObjectsArgs();
            CreateObjectsArgs.BJOUnits = BJOUnits;
            CreateObjectsArgs.INIStructures = INIStructures;
            CreateObjectsArgs.INIDroids = INIDroids;
            CreateObjectsArgs.INIFeatures = INIFeatures;
            ReturnResult.Add(CreateWZObjects(CreateObjectsArgs));

            //objects are modified by this and must already exist
            ZipSearchResult = IOUtil.FindZipEntryFromPath(Path, GameFilesPath + "labels.ini");
            if ( ZipSearchResult == null )
            {
            }
            else
            {
                clsResult Result = new clsResult("labels.ini");
                IniReader LabelsINI = new IniReader();
                StreamReader LabelsINI_Reader = new StreamReader(ZipSearchResult.Stream);
                Result.Take(LabelsINI.ReadFile(LabelsINI_Reader));
                LabelsINI_Reader.Close();
                Result.Take(Read_WZ_Labels(LabelsINI, false));
                ReturnResult.Add(Result);
            }

            return ReturnResult;
        }
Ejemplo n.º 3
0
        private clsResult Read_FMap_Objects(StreamReader File)
        {
            clsResult ReturnResult = new clsResult("Reading objects");

            int A = 0;

            IniReader ObjectsINI = new IniReader();
            ReturnResult.Take(ObjectsINI.ReadFile(File));

            FMapIniObjects INIObjects = new FMapIniObjects(ObjectsINI.Sections.Count);
            ReturnResult.Take(ObjectsINI.Translate(INIObjects));

            int DroidComponentUnknownCount = 0;
            int ObjectTypeMissingCount = 0;
            int ObjectPlayerNumInvalidCount = 0;
            int ObjectPosInvalidCount = 0;
            int DesignTypeUnspecifiedCount = 0;
            int UnknownUnitTypeCount = 0;
            int MaxUnknownUnitTypeWarningCount = 16;

            clsDroidDesign DroidDesign = default(clsDroidDesign);
            clsUnit NewObject = default(clsUnit);
            clsUnitAdd UnitAdd = new clsUnitAdd();
            clsUnitType UnitType = default(clsUnitType);
            bool IsDesign = default(bool);
            clsUnitGroup UnitGroup = default(clsUnitGroup);
            sXY_int ZeroPos = new sXY_int(0, 0);
            UInt32 AvailableID = 0;

            UnitAdd.Map = this;

            AvailableID = 1U;
            for ( A = 0; A <= INIObjects.ObjectCount - 1; A++ )
            {
                if ( INIObjects.Objects[A].ID >= AvailableID )
                {
                    AvailableID = INIObjects.Objects[A].ID + 1U;
                }
            }
            for ( A = 0; A <= INIObjects.ObjectCount - 1; A++ )
            {
                if ( INIObjects.Objects[A].Pos == null )
                {
                    ObjectPosInvalidCount++;
                }
                else if ( !App.PosIsWithinTileArea(INIObjects.Objects[A].Pos.XY, ZeroPos, Terrain.TileSize) )
                {
                    ObjectPosInvalidCount++;
                }
                else
                {
                    UnitType = null;
                    if ( INIObjects.Objects[A].Type != clsUnitType.enumType.Unspecified )
                    {
                        IsDesign = false;
                        if ( INIObjects.Objects[A].Type == clsUnitType.enumType.PlayerDroid )
                        {
                            if ( !INIObjects.Objects[A].IsTemplate )
                            {
                                IsDesign = true;
                            }
                        }
                        if ( IsDesign )
                        {
                            DroidDesign = new clsDroidDesign();
                            DroidDesign.TemplateDroidType = INIObjects.Objects[A].TemplateDroidType;
                            if ( DroidDesign.TemplateDroidType == null )
                            {
                                DroidDesign.TemplateDroidType = App.TemplateDroidType_Droid;
                                DesignTypeUnspecifiedCount++;
                            }
                            if ( INIObjects.Objects[A].BodyCode != "" )
                            {
                                DroidDesign.Body = App.ObjectData.FindOrCreateBody(Convert.ToString(INIObjects.Objects[A].BodyCode));
                                if ( DroidDesign.Body.IsUnknown )
                                {
                                    DroidComponentUnknownCount++;
                                }
                            }
                            if ( INIObjects.Objects[A].PropulsionCode != "" )
                            {
                                DroidDesign.Propulsion = App.ObjectData.FindOrCreatePropulsion(INIObjects.Objects[A].PropulsionCode);
                                if ( DroidDesign.Propulsion.IsUnknown )
                                {
                                    DroidComponentUnknownCount++;
                                }
                            }
                            DroidDesign.TurretCount = (byte)(INIObjects.Objects[A].TurretCount);
                            if ( INIObjects.Objects[A].TurretCodes[0] != "" )
                            {
                                DroidDesign.Turret1 = App.ObjectData.FindOrCreateTurret(INIObjects.Objects[A].TurretTypes[0],
                                    Convert.ToString(INIObjects.Objects[A].TurretCodes[0]));
                                if ( DroidDesign.Turret1.IsUnknown )
                                {
                                    DroidComponentUnknownCount++;
                                }
                            }
                            if ( INIObjects.Objects[A].TurretCodes[1] != "" )
                            {
                                DroidDesign.Turret2 = App.ObjectData.FindOrCreateTurret(INIObjects.Objects[A].TurretTypes[1],
                                    Convert.ToString(INIObjects.Objects[A].TurretCodes[1]));
                                if ( DroidDesign.Turret2.IsUnknown )
                                {
                                    DroidComponentUnknownCount++;
                                }
                            }
                            if ( INIObjects.Objects[A].TurretCodes[2] != "" )
                            {
                                DroidDesign.Turret3 = App.ObjectData.FindOrCreateTurret(INIObjects.Objects[A].TurretTypes[2],
                                    Convert.ToString(INIObjects.Objects[A].TurretCodes[2]));
                                if ( DroidDesign.Turret3.IsUnknown )
                                {
                                    DroidComponentUnknownCount++;
                                }
                            }
                            DroidDesign.UpdateAttachments();
                            UnitType = DroidDesign;
                        }
                        else
                        {
                            UnitType = App.ObjectData.FindOrCreateUnitType(INIObjects.Objects[A].Code, INIObjects.Objects[A].Type, INIObjects.Objects[A].WallType);
                            if ( UnitType.IsUnknown )
                            {
                                if ( UnknownUnitTypeCount < MaxUnknownUnitTypeWarningCount )
                                {
                                    ReturnResult.WarningAdd(ControlChars.Quote + INIObjects.Objects[A].Code + Convert.ToString(ControlChars.Quote) +
                                                            " is not a loaded object.");
                                }
                                UnknownUnitTypeCount++;
                            }
                        }
                    }
                    if ( UnitType == null )
                    {
                        ObjectTypeMissingCount++;
                    }
                    else
                    {
                        NewObject = new clsUnit();
                        NewObject.Type = UnitType;
                        NewObject.Pos.Horizontal.X = INIObjects.Objects[A].Pos.X;
                        NewObject.Pos.Horizontal.Y = INIObjects.Objects[A].Pos.Y;
                        NewObject.Health = INIObjects.Objects[A].Health;
                        NewObject.SavePriority = INIObjects.Objects[A].Priority;
                        NewObject.Rotation = (int)(INIObjects.Objects[A].Heading);
                        if ( NewObject.Rotation >= 360 )
                        {
                            NewObject.Rotation -= 360;
                        }
                        if ( INIObjects.Objects[A].UnitGroup == null || INIObjects.Objects[A].UnitGroup == "" )
                        {
                            if ( INIObjects.Objects[A].Type != clsUnitType.enumType.Feature )
                            {
                                ObjectPlayerNumInvalidCount++;
                            }
                            NewObject.UnitGroup = ScavengerUnitGroup;
                        }
                        else
                        {
                            if ( INIObjects.Objects[A].UnitGroup.ToLower() == "scavenger" )
                            {
                                NewObject.UnitGroup = ScavengerUnitGroup;
                            }
                            else
                            {
                                UInt32 PlayerNum = 0;
                                try
                                {
                                    if ( !IOUtil.InvariantParse(INIObjects.Objects[A].UnitGroup, PlayerNum) )
                                    {
                                        throw (new Exception());
                                    }
                                    if ( PlayerNum < Constants.PlayerCountMax )
                                    {
                                        UnitGroup = UnitGroups[Convert.ToInt32(PlayerNum)];
                                    }
                                    else
                                    {
                                        UnitGroup = ScavengerUnitGroup;
                                        ObjectPlayerNumInvalidCount++;
                                    }
                                }
                                catch ( Exception )
                                {
                                    ObjectPlayerNumInvalidCount++;
                                    UnitGroup = ScavengerUnitGroup;
                                }
                                NewObject.UnitGroup = UnitGroup;
                            }
                        }
                        if ( INIObjects.Objects[A].ID == 0U )
                        {
                            INIObjects.Objects[A].ID = AvailableID;
                            App.ZeroIDWarning(NewObject, INIObjects.Objects[A].ID, ReturnResult);
                        }
                        UnitAdd.NewUnit = NewObject;
                        UnitAdd.ID = INIObjects.Objects[A].ID;
                        UnitAdd.Label = INIObjects.Objects[A].Label;
                        UnitAdd.Perform();
                        App.ErrorIDChange(INIObjects.Objects[A].ID, NewObject, "Read_FMap_Objects");
                        if ( AvailableID == INIObjects.Objects[A].ID )
                        {
                            AvailableID = NewObject.ID + 1U;
                        }
                    }
                }
            }

            if ( UnknownUnitTypeCount > MaxUnknownUnitTypeWarningCount )
            {
                ReturnResult.WarningAdd(UnknownUnitTypeCount + " objects were not in the loaded object data.");
            }
            if ( ObjectTypeMissingCount > 0 )
            {
                ReturnResult.WarningAdd(ObjectTypeMissingCount + " objects did not specify a type and were ignored.");
            }
            if ( DroidComponentUnknownCount > 0 )
            {
                ReturnResult.WarningAdd(DroidComponentUnknownCount + " components used by droids were loaded as unknowns.");
            }
            if ( ObjectPlayerNumInvalidCount > 0 )
            {
                ReturnResult.WarningAdd(ObjectPlayerNumInvalidCount + " objects had an invalid player number and were set to player 0.");
            }
            if ( ObjectPosInvalidCount > 0 )
            {
                ReturnResult.WarningAdd(ObjectPosInvalidCount + " objects had a position that was off-map and were ignored.");
            }
            if ( DesignTypeUnspecifiedCount > 0 )
            {
                ReturnResult.WarningAdd(DesignTypeUnspecifiedCount + " designed droids did not specify a template droid type and were set to droid.");
            }

            return ReturnResult;
        }
Ejemplo n.º 4
0
        public clsResult Load_Game(string Path)
        {
            clsResult ReturnResult =
                new clsResult("Loading game file from " + Convert.ToString(ControlChars.Quote) + Path + Convert.ToString(ControlChars.Quote));
            App.sResult SubResult = new App.sResult();
            string Quote = ControlChars.Quote.ToString();

            Tileset = null;

            TileType_Reset();
            SetPainterToDefaults();

            App.sSplitPath GameSplitPath = new App.sSplitPath(Path);
            string GameFilesPath = GameSplitPath.FilePath + GameSplitPath.FileTitleWithoutExtension + Convert.ToString(App.PlatformPathSeparator);
            string MapDirectory = "";
            FileStream File = null;

            SubResult = IOUtil.TryOpenFileStream(Path, ref File);
            if ( !SubResult.Success )
            {
                ReturnResult.ProblemAdd("Game file not found: " + SubResult.Problem);
                return ReturnResult;
            }
            else
            {
                BinaryReader Map_Reader = new BinaryReader(File);
                SubResult = Read_WZ_gam(Map_Reader);
                Map_Reader.Close();

                if ( !SubResult.Success )
                {
                    ReturnResult.ProblemAdd(SubResult.Problem);
                    return ReturnResult;
                }
            }

            SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "game.map", ref File);
            if ( !SubResult.Success )
            {
                MsgBoxResult PromptResult =
                    Interaction.MsgBox(
                        "game.map file not found at " + GameFilesPath + ControlChars.NewLine + "Do you want to select another directory to load the underlying map from?",
                        (MsgBoxStyle)(MsgBoxStyle.OkCancel | MsgBoxStyle.Question), null);
                if ( PromptResult != MsgBoxResult.Ok )
                {
                    ReturnResult.ProblemAdd("Aborted.");
                    return ReturnResult;
                }
                FolderBrowserDialog DirectorySelect = new FolderBrowserDialog();
                DirectorySelect.SelectedPath = GameFilesPath;
                if ( DirectorySelect.ShowDialog() != DialogResult.OK )
                {
                    ReturnResult.ProblemAdd("Aborted.");
                    return ReturnResult;
                }
                MapDirectory = DirectorySelect.SelectedPath + Convert.ToString(App.PlatformPathSeparator);

                SubResult = IOUtil.TryOpenFileStream(MapDirectory + "game.map", ref File);
                if ( !SubResult.Success )
                {
                    ReturnResult.ProblemAdd("game.map file not found: " + SubResult.Problem);
                    return ReturnResult;
                }
            }
            else
            {
                MapDirectory = GameFilesPath;
            }

            BinaryReader Map_ReaderB = new BinaryReader(File);
            SubResult = Read_WZ_map(Map_ReaderB);
            Map_ReaderB.Close();

            if ( !SubResult.Success )
            {
                ReturnResult.ProblemAdd(SubResult.Problem);
                return ReturnResult;
            }

            SimpleClassList<clsWZBJOUnit> BJOUnits = new SimpleClassList<clsWZBJOUnit>();

            IniFeatures INIFeatures = null;

            SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "feature.ini", ref File);
            if ( !SubResult.Success )
            {
            }
            else
            {
                clsResult Result = new clsResult("feature.ini");
                IniReader FeaturesINI = new IniReader();
                StreamReader FeaturesINI_Reader = new StreamReader(File);
                Result.Take(FeaturesINI.ReadFile(FeaturesINI_Reader));
                FeaturesINI_Reader.Close();
                INIFeatures = new IniFeatures(FeaturesINI.Sections.Count);
                Result.Take(FeaturesINI.Translate(INIFeatures));
                ReturnResult.Add(Result);
            }

            if ( INIFeatures == null )
            {
                clsResult Result = new clsResult("feat.bjo");
                SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "feat.bjo", ref File);
                if ( !SubResult.Success )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader Features_Reader = new BinaryReader(File);
                    SubResult = Read_WZ_Features(Features_Reader, BJOUnits);
                    Features_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            if ( true )
            {
                clsResult Result = new clsResult("ttypes.ttp");
                SubResult = IOUtil.TryOpenFileStream(MapDirectory + "ttypes.ttp", ref File);
                if ( !SubResult.Success )
                {
                    Result.WarningAdd("file not found");
                }
                else
                {
                    BinaryReader TileTypes_Reader = new BinaryReader(File);
                    SubResult = Read_WZ_TileTypes(TileTypes_Reader);
                    TileTypes_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            IniStructures INIStructures = null;

            SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "struct.ini", ref File);
            if ( !SubResult.Success )
            {
            }
            else
            {
                clsResult Result = new clsResult("struct.ini");
                IniReader StructuresINI = new IniReader();
                StreamReader StructuresINI_Reader = new StreamReader(File);
                Result.Take(StructuresINI.ReadFile(StructuresINI_Reader));
                StructuresINI_Reader.Close();
                INIStructures = new IniStructures(StructuresINI.Sections.Count, this);
                Result.Take(StructuresINI.Translate(INIStructures));
                ReturnResult.Add(Result);
            }

            if ( INIStructures == null )
            {
                clsResult Result = new clsResult("struct.bjo");
                SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "struct.bjo", ref File);
                if ( !SubResult.Success )
                {
                    Result.WarningAdd("struct.bjo file not found.");
                }
                else
                {
                    BinaryReader Structures_Reader = new BinaryReader(File);
                    SubResult = Read_WZ_Structures(Structures_Reader, BJOUnits);
                    Structures_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            IniDroids INIDroids = null;

            SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "droid.ini", ref File);
            if ( !SubResult.Success )
            {
            }
            else
            {
                clsResult Result = new clsResult("droid.ini");
                IniReader DroidsINI = new IniReader();
                StreamReader DroidsINI_Reader = new StreamReader(File);
                Result.Take(DroidsINI.ReadFile(DroidsINI_Reader));
                DroidsINI_Reader.Close();
                INIDroids = new IniDroids(DroidsINI.Sections.Count, this);
                Result.Take(DroidsINI.Translate(INIDroids));
                ReturnResult.Add(Result);
            }

            if ( INIStructures == null )
            {
                clsResult Result = new clsResult("dinit.bjo");
                SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "dinit.bjo", ref File);
                if ( !SubResult.Success )
                {
                    Result.WarningAdd("dinit.bjo file not found.");
                }
                else
                {
                    BinaryReader Droids_Reader = new BinaryReader(File);
                    SubResult = Read_WZ_Droids(Droids_Reader, BJOUnits);
                    Droids_Reader.Close();
                    if ( !SubResult.Success )
                    {
                        Result.WarningAdd(SubResult.Problem);
                    }
                }
                ReturnResult.Add(Result);
            }

            sCreateWZObjectsArgs CreateObjectsArgs = new sCreateWZObjectsArgs();
            CreateObjectsArgs.BJOUnits = BJOUnits;
            CreateObjectsArgs.INIStructures = INIStructures;
            CreateObjectsArgs.INIDroids = INIDroids;
            CreateObjectsArgs.INIFeatures = INIFeatures;
            ReturnResult.Add(CreateWZObjects(CreateObjectsArgs));

            //map objects are modified by this and must already exist
            SubResult = IOUtil.TryOpenFileStream(GameFilesPath + "labels.ini", ref File);
            if ( !SubResult.Success )
            {
            }
            else
            {
                clsResult Result = new clsResult("labels.ini");
                IniReader LabelsINI = new IniReader();
                StreamReader LabelsINI_Reader = new StreamReader(File);
                Result.Take(LabelsINI.ReadFile(LabelsINI_Reader));
                LabelsINI_Reader.Close();
                Result.Take(Read_WZ_Labels(LabelsINI, false));
                ReturnResult.Add(Result);
            }

            return ReturnResult;
        }