예제 #1
0
        protected ArrayHeader DefineArray(uint array, ArrayType type, int dim2, int dim1)
        {
//            Debug.WriteLine("DefineArray: {0} {1} {2} {3}", array, type, dim2, dim1);
            Debug.Assert(0 <= type && (int)type <= 5);

            NukeArray(array);

            var id = FindFreeArrayId();

            int size;

            if (Game.Version == 8)
            {
                if ((array & 0x80000000) != 0)
                {
                    throw new InvalidOperationException("Can't define bit variable as array pointer");
                }
                size = (type == ArrayType.IntArray) ? 4 : 1;
            }
            else
            {
                if ((array & 0x8000) != 0)
                {
                    throw new InvalidOperationException("Can't define bit variable as array pointer");
                }

                size = (type == ArrayType.IntArray) ? 2 : 1;
            }

            WriteVariable(array, id);

            size *= dim2 + 1;
            size *= dim1 + 1;

            _strings[id] = new byte[size + 6 /*sizeof(ArrayHeader)*/];
            var ah = new ArrayHeader(_strings[id]);

            ah.Type = type;
            ah.Dim1 = dim1 + 1;
            ah.Dim2 = dim2 + 1;
            return(ah);
        }
예제 #2
0
        protected ArrayHeader DefineArray(uint array, ArrayType type, int dim2, int dim1)
        {
//            Debug.WriteLine("DefineArray: {0} {1} {2} {3}", array, type, dim2, dim1);
            Debug.Assert(0 <= type && (int)type <= 5);

            NukeArray(array);

            var id = FindFreeArrayId();

            int size;
            if (Game.Version == 8)
            {
                if ((array & 0x80000000) != 0)
                {
                    throw new InvalidOperationException("Can't define bit variable as array pointer");
                }
                size = (type == ArrayType.IntArray) ? 4 : 1;
            }
            else
            {
                if ((array & 0x8000) != 0)
                {
                    throw new InvalidOperationException("Can't define bit variable as array pointer");
                }

                size = (type == ArrayType.IntArray) ? 2 : 1;
            }

            WriteVariable(array, id);

            size *= dim2 + 1;
            size *= dim1 + 1;

            _strings[id] = new byte[size + 6 /*sizeof(ArrayHeader)*/];
            var ah = new ArrayHeader(_strings[id]);
            ah.Type = type;
            ah.Dim1 = dim1 + 1;
            ah.Dim2 = dim2 + 1;
            return ah;
        }