private void ReadBlock(byte[] file, ref int hstPosition, ref byte[] Data, ref int type, ref int Size) { Size = file[hstPosition + 0] + ((file[hstPosition + 1] & 3) * 0x100); type = (int)Math.Round(Conversion.Int((double)(((double)file[hstPosition + 1]) / 4.0))); try { Design design; int num3; Data = new byte[(Size - 1) + 1]; if (Size > 0) { Array.Copy(file, hstPosition + 2, Data, 0, Size); } switch (type) { case 8: { int start = 12; this.xTurnNo = Conversions.ToInteger(functions.GetBytes(Data, ref start, 2)); goto Label_0375; } case 13: { int num = Data[0] + ((Data[1] & 3) * 0x100); Planet planet = (Planet)this.Planets()["ID" + Conversions.ToString(num)]; planet.PlanetData = Data; goto Label_0375; } case 0x10: { Fleet item = new Fleet(Data); this.Fleets().Add(item, null, null, null); goto Label_0375; } case 0x11: { EnemyFleet fleet2 = new EnemyFleet(Data); this.Enemyfleets().Add(fleet2, null, null, null); goto Label_0375; } case 0x1a: design = new Design(Data); if (!design.Starbase) { break; } this.StarbaseDesigns().Add(design, null, null, null); goto Label_0375; case 0x2b: { int num2 = 0; if (this.Type43CountPos != -1) { goto Label_01FC; } this.Type43CountPos = Conversions.ToInteger(functions.GetBytes(Data, ref num2, 2)); goto Label_0375; } case 0x2d: { Score score = new Score(Data); score.YearNo = this.TurnNo + 0x960; this.Scores().Add(score, null, null, null); goto Label_0375; } default: goto Label_0375; } this.ShipDesigns().Add(design, null, null, null); goto Label_0375; Label_01FC: num3 = Data[0] + (Data[1] * 0x100); if ((num3 >= 0) & (num3 <= 0x1fff)) { Minefield minefield = new Minefield(Data); this.MineFields().Add(minefield, null, null, null); } if ((num3 >= 0x2000) & (num3 <= 0x4000)) { AtlantisSoftware.Salvage salvage = new AtlantisSoftware.Salvage(Data); this.Salvage().Add(salvage, null, null, null); } if ((num3 >= 0x4000) & (num3 <= 0x5f9f)) { Wormhole wormhole = new Wormhole(Data); this.WormHoles().Add(wormhole, null, null, null); } if ((num3 >= 0x6000) & (num3 <= 0x6fff)) { MT mt = new MT(Data); this.MTs().Add(mt, null, null, null); } } catch (Exception exception1) { ProjectData.SetProjectError(exception1); this.Errors().Add("Error decoding block in .m file at file position:" + Conversions.ToString((int)hstPosition) + ", type:" + Conversions.ToString((int)type) + ", Size:" + Conversions.ToString((int)Size), null, null, null); ProjectData.ClearProjectError(); } Label_0375: hstPosition = (hstPosition + 2) + Size; }
private void ReadBlock(byte[] file, ref int hstPosition, ref byte[] Data, ref int type, ref int Size) { Size = file[hstPosition + 0] + ((file[hstPosition + 1] & 3) * 0x100); type = (int) Math.Round(Conversion.Int((double) (((double) file[hstPosition + 1]) / 4.0))); try { Design design; int num3; Data = new byte[(Size - 1) + 1]; if (Size > 0) { Array.Copy(file, hstPosition + 2, Data, 0, Size); } switch (type) { case 8: { int start = 12; this.xTurnNo = Conversions.ToInteger(functions.GetBytes(Data, ref start, 2)); goto Label_0375; } case 13: { int num = Data[0] + ((Data[1] & 3) * 0x100); Planet planet = (Planet) this.Planets()["ID" + Conversions.ToString(num)]; planet.PlanetData = Data; goto Label_0375; } case 0x10: { Fleet item = new Fleet(Data); this.Fleets().Add(item, null, null, null); goto Label_0375; } case 0x11: { EnemyFleet fleet2 = new EnemyFleet(Data); this.Enemyfleets().Add(fleet2, null, null, null); goto Label_0375; } case 0x1a: design = new Design(Data); if (!design.Starbase) { break; } this.StarbaseDesigns().Add(design, null, null, null); goto Label_0375; case 0x2b: { int num2 = 0; if (this.Type43CountPos != -1) { goto Label_01FC; } this.Type43CountPos = Conversions.ToInteger(functions.GetBytes(Data, ref num2, 2)); goto Label_0375; } case 0x2d: { Score score = new Score(Data); score.YearNo = this.TurnNo + 0x960; this.Scores().Add(score, null, null, null); goto Label_0375; } default: goto Label_0375; } this.ShipDesigns().Add(design, null, null, null); goto Label_0375; Label_01FC: num3 = Data[0] + (Data[1] * 0x100); if ((num3 >= 0) & (num3 <= 0x1fff)) { Minefield minefield = new Minefield(Data); this.MineFields().Add(minefield, null, null, null); } if ((num3 >= 0x2000) & (num3 <= 0x4000)) { AtlantisSoftware.Salvage salvage = new AtlantisSoftware.Salvage(Data); this.Salvage().Add(salvage, null, null, null); } if ((num3 >= 0x4000) & (num3 <= 0x5f9f)) { Wormhole wormhole = new Wormhole(Data); this.WormHoles().Add(wormhole, null, null, null); } if ((num3 >= 0x6000) & (num3 <= 0x6fff)) { MT mt = new MT(Data); this.MTs().Add(mt, null, null, null); } } catch (Exception exception1) { ProjectData.SetProjectError(exception1); this.Errors().Add("Error decoding block in .m file at file position:" + Conversions.ToString((int) hstPosition) + ", type:" + Conversions.ToString((int) type) + ", Size:" + Conversions.ToString((int) Size), null, null, null); ProjectData.ClearProjectError(); } Label_0375: hstPosition = (hstPosition + 2) + Size; }