Пример #1
0
        public static void UnpackData(string arg0, ref sbyte[] data)
        {
            sbyte[] abyte0 = link.getFile(arg0);
            // Debug.Log("Unpacking data.. " + arg0+" File loaded: "+(abyte0 != null));
            if (abyte0 != null)
            {
                int     l      = ((abyte0[0] & 0xff) << 16) + ((abyte0[1] & 0xff) << 8) + (abyte0[2] & 0xff);
                int     i1     = ((abyte0[3] & 0xff) << 16) + ((abyte0[4] & 0xff) << 8) + (abyte0[5] & 0xff);
                sbyte[] abyte1 = new sbyte[abyte0.Length - 6];
                for (int j1 = 0; j1 < abyte0.Length - 6; j1++)
                {
                    abyte1[j1] = abyte0[j1 + 6];
                }

                if (i1 != l)
                {
                    //if (!isMembers)
                    //{
                    data = new sbyte[l];
                    DataFileDecrypter.unpackData(data, l, abyte1, i1, 0);
                    //}
                    //else
                    //{
                    //	M_LandscapeDataBuffer = new sbyte[l];
                    //	DataFileDecrypter.unpackData(M_LandscapeDataBuffer, l, abyte1, i1, 0);
                    //}

                    /* if (OnContentLoaded != null)
                     * {
                     *      OnContentLoaded(this, new ContentLoadedEventArgs("Unpacking " + arg1, arg2));
                     * } */
                }
                else
                {
                    data = abyte1;
                }
            }
            else
            {
                data = unpackData2(arg0);
            }
        }
Пример #2
0
        //public void drawString(String arg1, int arg3, int arg4, Color color)
        //{
        //    //Object obj;
        //    //if (gameFrame == null)
        //    //    obj = this;
        //    //else
        //    //    obj = gameFrame;
        //    //var fontmetrics = arg2.MeasureString(arg1);//((Component)(obj)).getFontMetrics(arg2);
        //    //fontmetrics.stringWidth(arg1);
        //    //arg0.setFont(arg2);
        //    //arg0.drawString(arg1, arg3 - fontmetrics.stringWidth(arg1) / 2, arg4 + fontmetrics.getHeight() / 4);

        //    //GameImage.stringsToDraw.Add(new stringDrawDef
        //    //{
        //    //    font = arg2,
        //    //    text = arg1,
        //    //    pos = new Vector2(arg3 - fontmetrics.X / 2, arg4 + fontmetrics.Y / 4),
        //    //    forecolor = color
        //    //});

        //    //spriteBatch.BeginSafe();
        //    //spriteBatch.DrawString(arg2, arg1, new Vector2(fontmetrics.X / 2, arg4 + fontmetrics.Y / 4), color);
        //    //spriteBatch.EndSafe();
        //}

        public virtual sbyte[] unpackData(String filename, String fileTitle, int startPercentage)
        {
            Console.WriteLine("Using default load");
            int i = 0;
            int k = 0;

            sbyte[] abyte0 = link.getFile(filename);
            if (abyte0 == null)
            {
                try
                {
                    Console.WriteLine("Loading " + fileTitle + " - 0%");
                    drawLoadingBarText(startPercentage, "Loading " + fileTitle + " - 0%");
                    var inputstream = new BinaryReader(DataOperations.openInputStream(filename));
                    //DataInputStream datainputstream = new DataInputStream(inputstream);
                    sbyte[] abyte2 = new sbyte[6] {
                        inputstream.ReadSByte(), inputstream.ReadSByte(), inputstream.ReadSByte(),
                            inputstream.ReadSByte(), inputstream.ReadSByte(), inputstream.ReadSByte()
                    };

                    //inputstream.Read(abyte2, 0, 6);
                    i = ((abyte2[0] & 0xff) << 16) + ((abyte2[1] & 0xff) << 8) + (abyte2[2] & 0xff);
                    k = ((abyte2[3] & 0xff) << 16) + ((abyte2[4] & 0xff) << 8) + (abyte2[5] & 0xff);



                    Console.WriteLine("Loading " + fileTitle + " - 5%");
                    drawLoadingBarText(startPercentage, "Loading " + fileTitle + " - 5%");
#warning this could break stuff
                    // int l = 0;
                    int l = 6;
                    abyte0 = new sbyte[k];
                    while (l < k)
                    {
                        int i1 = k - l;
                        if (i1 > 1000)
                        {
                            i1 = 1000;
                        }

                        for (int t = 0; t < i1; t++)
                        {
                            abyte0[l + t] = inputstream.ReadSByte();
                        }

                        // inputstream.Read(abyte0, l, i1);

                        l += i1;
                        Console.WriteLine("Loading " + fileTitle + " - " + (5 + (l * 95) / k) + "%");
                        drawLoadingBarText(startPercentage, "Loading " + fileTitle + " - " + (5 + (l * 95) / k) + "%");
                    }

                    inputstream.Close();
                }
                catch (IOException _ex) { }
            }
            Console.WriteLine("Unpacking " + fileTitle);
            drawLoadingBarText(startPercentage, "Unpacking " + fileTitle);
            if (k != i)
            {
                sbyte[] abyte1 = new sbyte[i];
                DataFileDecrypter.unpackData(abyte1, i, abyte0, k, 0);
                return(abyte1);
            }
            else
            {
                //  return unpackData(filename, fileTitle, startPercentage); // abyte0;
                return(abyte0);
            }
        }