Exemplo n.º 1
0
 public object LoadXYFile(string Filename)
 {
     byte[] buffer = new Decryptor().OpenFile(Filename);
     if (buffer.Length <= 0x54)
     {
         return 1;
     }
     string str = Conversions.ToString(Strings.Chr(buffer[2])) + Conversions.ToString(Strings.Chr(buffer[3])) + Conversions.ToString(Strings.Chr(buffer[4])) + Conversions.ToString(Strings.Chr(buffer[5]));
     this.GameID = ((buffer[6] + (buffer[7] * 0x100)) + (buffer[8] * 0x10000)) + ((buffer[9] * 0x10000) * 0x100);
     uint num6 = (uint) (buffer[10] + (buffer[11] * 0x100));
     uint num5 = (uint) (buffer[12] + (buffer[13] * 0x100));
     uint num4 = (uint) (buffer[14] & 0x1f);
     byte num2 = buffer[0x10];
     byte num3 = buffer[0x11];
     if (num2 != 0)
     {
         return 2;
     }
     this.UniverseSize = buffer[0x18];
     this.Density = buffer[0x1a];
     this.PlayerCount = buffer[0x1c] + (buffer[0x1d] * 0x100);
     this.PlanetCount = buffer[30] + (buffer[0x1f] * 0x100);
     this.StartingPositions = buffer[0x20];
     uint num8 = buffer[0x24];
     if ((num8 & 1L) == 1L)
     {
         this.MaxMinerals = true;
     }
     else
     {
         this.MaxMinerals = false;
     }
     if ((num8 & 2L) == 2L)
     {
         this.SlowerTechAdvances = true;
     }
     else
     {
         this.SlowerTechAdvances = false;
     }
     if ((num8 & 4L) == 4L)
     {
         this.AcceleratedBBS = true;
     }
     else
     {
         this.AcceleratedBBS = false;
     }
     if ((num8 & 8L) == 8L)
     {
         this.Tutorial = true;
     }
     else
     {
         this.Tutorial = false;
     }
     if ((num8 & 0x10L) == 0x10L)
     {
         this.NoRandomEvents = true;
     }
     else
     {
         this.NoRandomEvents = false;
     }
     if ((num8 & 0x20L) == 0x20L)
     {
         this.ComputerPlayersFormAlliances = true;
     }
     else
     {
         this.ComputerPlayersFormAlliances = false;
     }
     if ((num8 & 0x40L) == 0x40L)
     {
         this.PublicPlayerScores = true;
     }
     else
     {
         this.PublicPlayerScores = false;
     }
     if ((num8 & 0x80L) == 0x80L)
     {
         this.GalaxyClumping = true;
     }
     else
     {
         this.GalaxyClumping = false;
     }
     this.GameName = "";
     int index = 0x34;
     do
     {
         if (buffer[index] == 0)
         {
             break;
         }
         this.GameName = this.GameName + Conversions.ToString(Strings.Chr(buffer[index]));
         index++;
     }
     while (index <= 0x53);
     this.Planets = new Planet[(this.PlanetCount - 1) + 1];
     uint x = 0x3e8;
     int num12 = this.PlanetCount - 1;
     for (int i = 0; i <= num12; i++)
     {
         uint num11 = (uint) (buffer[0x54 + (i * 4)] + (buffer[(0x54 + (i * 4)) + 1] * 0x100));
         num11 += (uint) (buffer[(0x54 + (i * 4)) + 2] * 0x10000);
         num11 += (uint) (buffer[(0x54 + (i * 4)) + 3] * 0x1000000L);
         Planet planet = new Planet();
         planet.PlanetID = i;
         planet.X = (int) (x + (num11 & 0x3ffL));
         x = (uint) planet.X;
         planet.Y = (int) (((long) Math.Round(Conversion.Int((double) (((double) num11) / 1024.0)))) & 0xfffL);
         planet.NameID = (int) Math.Round(Conversion.Int((double) ((((double) num11) / 1024.0) / 4096.0)));
         this.Planets[i] = planet;
     }
     return 0;
 }
Exemplo n.º 2
0
        public object LoadHSTFile(string Filename)
        {
            byte[] sourceArray = new Decryptor().OpenFile(Filename);
            int num2 = 0;
            do
            {
                int planetID;
                int length = sourceArray[num2 + 0] + ((sourceArray[num2 + 1] & 3) * 0x100);
                double num4 = Conversion.Int((double) (((double) sourceArray[num2 + 1]) / 4.0));
                byte[] destinationArray = new byte[(length - 1) + 1];
                if (length > 0)
                {
                    Array.Copy(sourceArray, num2 + 2, destinationArray, 0, length);
                }
                double num6 = num4;
                switch (num6)
                {
                    case 0.0:
                    case 9.0:
                    case 16.0:
                    case 20.0:
                    case 26.0:
                        break;

                    case 6.0:
                        Race race;
                        this.Races[race.RaceID] = new Race(destinationArray);
                        break;

                    case 8.0:
                    {
                        Header header = new Header(destinationArray);
                        break;
                    }
                    case 13.0:
                    {
                        Planet planet = new Planet(destinationArray);
                        planet.X = this.Planets[planet.PlanetID].X;
                        planet.Y = this.Planets[planet.PlanetID].Y;
                        planet.NameID = this.Planets[planet.PlanetID].NameID;
                        planet.ProductionQueue = null;
                        planetID = planet.PlanetID;
                        break;
                    }
                    case 28.0:
                    {
                        Planet planet2 = this.Planets[planetID];
                        planet2.ProductionQueue = new QueueItem[((int) Math.Round((double) ((((double) destinationArray.Length) / 4.0) - 1.0))) + 1];
                        int num7 = destinationArray.Length - 1;
                        for (int i = 0; i <= num7; i += 4)
                        {
                            byte[] data = new byte[] { destinationArray[i], destinationArray[i + 1], destinationArray[i + 2], destinationArray[i + 3] };
                            QueueItem item = new QueueItem(data);
                            planet2.ProductionQueue[(int) Math.Round((double) (((double) i) / 4.0))] = item;
                        }
                        break;
                    }
                    default:
                        if ((num6 != 30.0) && (num6 != 43.0))
                        {
                            Debug.Print(Conversions.ToString(num4));
                        }
                        break;
                }
                num2 = (num2 + 2) + length;
            }
            while (num2 < sourceArray.Length);
            return 0;
        }