Exemple #1
0
        public void InitializeUserInput()
        {
            if ( _ReadyForUserInput )
            {
                return;
            }

            _ReadyForUserInput = true;

            int X = 0;
            int Y = 0;

            SectorCount.X = (int)(Math.Ceiling((double)(Terrain.TileSize.X / Constants.SectorTileSize)));
            SectorCount.Y = (int)(Math.Ceiling((double)(Terrain.TileSize.Y / Constants.SectorTileSize)));
            Sectors = new clsSector[SectorCount.X, SectorCount.Y];
            for ( Y = 0; Y <= SectorCount.Y - 1; Y++ )
            {
                for ( X = 0; X <= SectorCount.X - 1; X++ )
                {
                    Sectors[X, Y] = new clsSector(new sXY_int(X, Y));
                }
            }

            clsUnit Unit = default(clsUnit);
            foreach ( clsUnit tempLoopVar_Unit in Units )
            {
                Unit = tempLoopVar_Unit;
                UnitSectorsCalc(Unit);
            }

            ShadowSectors = new clsShadowSector[SectorCount.X, SectorCount.Y];
            for ( Y = 0; Y <= SectorCount.Y - 1; Y++ )
            {
                for ( X = 0; X <= SectorCount.X - 1; X++ )
                {
                    ShadowSector_Create(new sXY_int(X, Y));
                }
            }

            SectorGraphicsChanges = new clsSectorChanges(this);
            SectorGraphicsChanges.SetAllChanged();
            SectorUnitHeightsChanges = new clsSectorChanges(this);
            SectorTerrainUndoChanges = new clsSectorChanges(this);
            AutoTextureChanges = new clsAutoTextureChanges(this);
            TerrainInterpretChanges = new clsTerrainUpdate(Terrain.TileSize);

            UnitChanges = new SimpleClassList<clsUnitChange>();
            UnitChanges.MaintainOrder = true;
            GatewayChanges = new SimpleClassList<clsGatewayChange>();
            GatewayChanges.MaintainOrder = true;
            Undos = new SimpleClassList<clsUndo>();
            Undos.MaintainOrder = true;
            UndoPosition = 0;

            SelectedUnits = new ConnectedList<clsUnit, clsMap>(this);

            if ( InterfaceOptions == null )
            {
                InterfaceOptions = new clsInterfaceOptions();
            }

            ViewInfo = new clsViewInfo(this, Program.frmMainInstance.MapViewControl);

            _SelectedUnitGroup = new clsUnitGroupContainer();
            SelectedUnitGroup.Item = ScavengerUnitGroup;

            Messages = new SimpleClassList<clsMessage>();
            Messages.MaintainOrder = true;
        }
Exemple #2
0
        public void CancelUserInput()
        {
            if ( !_ReadyForUserInput )
            {
                return;
            }

            _ReadyForUserInput = false;

            int X = 0;
            int Y = 0;

            if ( CompileScreen != null )
            {
                CompileScreen.Close();
                CompileScreen = null;
            }

            SectorAll_GLLists_Delete();
            MinimapGLDelete();

            ShadowSectors = null;
            for ( Y = 0; Y <= SectorCount.Y - 1; Y++ )
            {
                for ( X = 0; X <= SectorCount.X - 1; X++ )
                {
                    Sectors[X, Y].Deallocate();
                }
            }
            Sectors = null;
            SectorGraphicsChanges.Deallocate();
            SectorGraphicsChanges = null;
            SectorUnitHeightsChanges.Deallocate();
            SectorUnitHeightsChanges = null;
            SectorTerrainUndoChanges.Deallocate();
            SectorTerrainUndoChanges = null;
            AutoTextureChanges.Deallocate();
            AutoTextureChanges = null;
            TerrainInterpretChanges.Deallocate();
            TerrainInterpretChanges = null;

            UnitChanges = null;
            GatewayChanges = null;
            Undos = null;

            SelectedUnits.Deallocate();
            SelectedUnits = null;

            Selected_Tile_A = null;
            Selected_Tile_B = null;
            Selected_Area_VertexA = null;
            Selected_Area_VertexB = null;
            Unit_Selected_Area_VertexA = null;

            ViewInfo = null;

            _SelectedUnitGroup = null;

            Messages = null;
        }
Exemple #3
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;
        }
Exemple #4
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;
        }
Exemple #5
0
        private App.sResult Read_WZ_Structures(BinaryReader File, SimpleClassList<clsWZBJOUnit> WZUnits)
        {
            App.sResult ReturnResult = new App.sResult();
            ReturnResult.Success = false;
            ReturnResult.Problem = "";

            string strTemp = null;
            UInt32 Version = 0;
            UInt32 uintTemp = 0;
            int A = 0;
            int B = 0;
            clsWZBJOUnit WZBJOUnit = default(clsWZBJOUnit);

            try
            {
                strTemp = IOUtil.ReadOldTextOfLength(File, 4);
                if ( strTemp != "stru" )
                {
                    ReturnResult.Problem = "Unknown struct.bjo identifier.";
                    return ReturnResult;
                }

                Version = File.ReadUInt32();
                if ( Version != 8U )
                {
                    if (
                        Interaction.MsgBox("struct.bjo version is unknown. Continue?", (MsgBoxStyle)(MsgBoxStyle.OkCancel | MsgBoxStyle.Question),
                            null) != MsgBoxResult.Ok )
                    {
                        ReturnResult.Problem = "Aborted.";
                        return ReturnResult;
                    }
                }

                uintTemp = File.ReadUInt32();
                for ( A = 0; A <= (Convert.ToInt32(uintTemp)) - 1; A++ )
                {
                    WZBJOUnit = new clsWZBJOUnit();
                    WZBJOUnit.ObjectType = clsUnitType.enumType.PlayerStructure;
                    WZBJOUnit.Code = IOUtil.ReadOldTextOfLength(File, 40);
                    B = Strings.InStr(WZBJOUnit.Code, Convert.ToString('\0'), (CompareMethod)0);
                    if ( B > 0 )
                    {
                        WZBJOUnit.Code = Strings.Left(WZBJOUnit.Code, B - 1);
                    }
                    WZBJOUnit.ID = File.ReadUInt32();
                    WZBJOUnit.Pos.Horizontal.X = (int)(File.ReadUInt32());
                    WZBJOUnit.Pos.Horizontal.Y = (int)(File.ReadUInt32());
                    WZBJOUnit.Pos.Altitude = (int)(File.ReadUInt32());
                    WZBJOUnit.Rotation = File.ReadUInt32();
                    WZBJOUnit.Player = File.ReadUInt32();
                    File.ReadBytes(56);
                    WZUnits.Add(WZBJOUnit);
                }
            }
            catch ( Exception ex )
            {
                ReturnResult.Problem = ex.Message;
                return ReturnResult;
            }

            ReturnResult.Success = true;
            return ReturnResult;
        }