Esempio n. 1
0
        public static void PointerSwapLoc(ResourcePointer lref, ResourcePointer rref)
        {
            int tmp = lref.Location;

            lref.Location = rref.Location;
            rref.Location = tmp;
        }
Esempio n. 2
0
        // TODO: clean this
        public List <ResourcePointer> ShuffleGFX_Accumulator(FileStream stream, Random random, float shufflechance, StreamWriter logstream)
        {
            byte[] readBuffer                  = new byte[Shuffle.WordSize];
            int    pointerNum                  = 0;
            long   pointerArrayBegin           = 0;
            List <ResourcePointer> pointerList = new List <ResourcePointer>();

            stream.Read(readBuffer, 0, 4);
            pointerNum        = BitConverter.ToInt32(readBuffer, 0);
            pointerArrayBegin = stream.Position;

            for (int i = 0; i < pointerNum; i++)
            {
                if (random.NextDouble() < shufflechance)
                {
                    byte[] _tmp = new byte[4], _tmp2 = new byte[4];
                    stream.Read(_tmp, 0, 4);
                    ResourcePointer ptr = new ResourcePointer(_tmp, (int)stream.Position - 4);
                    long            pos = stream.Position;
                    stream.Position = ptr.Address;
                    stream.Read(_tmp2, 0, 4);
                    stream.Position = BitConverter.ToInt32(_tmp2, 0);

                    List <byte> byteString  = new List <byte>();
                    bool        stringBegun = false;

                    for (int j = 0; j < 128; j++)
                    {
                        byteString.Add((byte)stream.ReadByte());

                        if (byteString[byteString.Count - 1] == 0 && stringBegun)
                        {
                            break;
                        }

                        if (byteString[byteString.Count - 1] != 0)
                        {
                            stringBegun = true;
                        }
                    }

                    string convertedString = new string(byteString.Where(x => x == '_' || (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || (x >= '0' && x <= '9')).Select(x => (char)x).ToArray());

                    if (!_friskSpriteHandles.Contains(convertedString.Trim()) || _friskMode)
                    {
                        pointerList.Add(ptr);
                    }

                    stream.Position = pos;
                }
            }

            logstream.WriteLine($"Added {pointerList.Count} out of {pointerNum} sprite pointers to SPRT List.");

            return(pointerList);
        }
Esempio n. 3
0
        public StringPointer(ResourcePointer ptr, string str)
        {
            Base = ptr;
            Str  = str;
            char[]      FormatChars = { '%', '/', 'C' };
            List <char> Ending      = new List <char>();

            for (int i = 1; i < str.Length; i++)
            {
                char C = str[str.Length - i];

                if (FormatChars.Contains(C))
                {
                    Ending.Add(C);
                }
                else
                {
                    break;
                }
            }

            Ending.Reverse();
            this.Ending = new string(Ending.ToArray());
        }