Ejemplo n.º 1
0
 private ArchAddressSpace(L4Handle value, Pointer UTCBStart, int utcb_size_log2)
 {
     this._value = value;
     this.UTCBStart = UTCBStart;
     this.utcb_num = (1 << utcb_size_log2) / ArchDefinition.UTCBOffset;
     this.allocated_utcb = 0;
 }
Ejemplo n.º 2
0
		static public void memcpy(Pointer<byte> destination, Pointer<byte> source, int num)
		{
			for (int n = 0; n < num; n++)
			{
				destination[n] = source[n];
			}
		}
Ejemplo n.º 3
0
 public override bool Intersect(Ray r, Pointer<float> tHit, Pointer<float> rayEpsilon, Pointer<DifferentialGeometry> dg)
 {
     Ray ray = (WorldToObject)[r];
     if (MathHelper.Abs(ray.Direction.Z) < 1e-7) return false;
     float thit = (Height - ray.Origin.Z) / ray.Direction.Z;
     if (thit < ray.MinT || thit > ray.MaxT)
         return false;
     Point phit = ray[thit];
     float dist2 = phit.X * phit.X + phit.Y * phit.Y;
     if (dist2 > Radius * Radius || dist2 < InnerRadius * InnerRadius)
         return false;
     float phi = MathHelper.Atan2(phit.Y, phit.X);
     if (phi < 0) phi += 2.0f * MathHelper.PI;
     if (phi > PhiMax)
         return false;
     float u = phi / PhiMax;
     float oneMinusV = ((MathHelper.Sqrt(dist2) - InnerRadius) /
                        (Radius - InnerRadius));
     float invOneMinusV = (oneMinusV > 0.0f) ? (1.0f / oneMinusV) : 0.0f;
     float v = 1.0f - oneMinusV;
     Vector dpdu = new Vector(-PhiMax * phit.Y, PhiMax * phit.X, 0);
     Vector dpdv = new Vector(-phit.X * invOneMinusV, -phit.Y * invOneMinusV, 0);
     dpdu *= PhiMax * MathHelper.InvTwoPI;
     dpdv *= (Radius - InnerRadius) / Radius;
     Normal dndu = new Normal(0, 0, 0), dndv = new Normal(0, 0, 0);
     Transform o2w = ObjectToWorld;
     dg[0] = new DifferentialGeometry(o2w[phit], o2w[dpdu], o2w[dpdv],
                                o2w[dndu], o2w[dndv], u, v, this);
     tHit[0] = thit;
     rayEpsilon[0] = 5e-4f * ~tHit;
     return true;
 }
Ejemplo n.º 4
0
		static public int get_bufferu(ref GetByteContext g, Pointer<byte> dst, int size)
		{

			CLib.memcpy(dst, g.buffer, size);
			g.buffer += size;
			return size;
		}
Ejemplo n.º 5
0
 public void CmpPtrIntPtrInt()
 {
     Pointer p1 = new Pointer(PrimitiveType.Int32, 4);
     Pointer p2 = new Pointer(PrimitiveType.Int32, 4);
     DataTypeComparer c = new DataTypeComparer();
     Assert.AreEqual(0, c.Compare(p1, p2));
 }
Ejemplo n.º 6
0
 protected override Span CurrentSpan(Pointer.Type pointer)
 {
     var now = Now.Value;
     DateTime minuteBegin;
     DateTime minuteEnd;
     if (pointer == Pointer.Type.Future)
     {
         minuteBegin = now;
         minuteEnd = Time.New(now, now.Hour, now.Minute);
     }
     else if (pointer == Pointer.Type.Past)
     {
         minuteBegin = Time.New(now, now.Hour, now.Minute);
         minuteEnd = now;
     }
     else if (pointer == Pointer.Type.None)
     {
         minuteBegin = Time.New(now, now.Hour, now.Minute);
         minuteEnd = Time.New(now, now.Hour, now.Minute).AddSeconds(RepeaterMinute.MINUTE_SECONDS);
     }
     else
     {
         throw new ArgumentException("Unable to handle pointer " + pointer + ".");
     }
     return new Span(minuteBegin, minuteEnd);
 }
Ejemplo n.º 7
0
        protected override Span CurrentSpan(Pointer.Type pointer)
        {
            DateTime monthStart;
            DateTime monthEnd;
            var now = Now.Value;

            if (pointer == Pointer.Type.Future)
            {
                monthStart = now.Date.AddDays(1);
                monthEnd = Time.New(now.Year, now.Month).AddMonths(1);
            }
            else if (pointer == Pointer.Type.Past)
            {
                monthStart = Time.New(now.Year, now.Month);
                monthEnd = now.Date;
            }
            else if (pointer == Pointer.Type.None)
            {
                monthStart = Time.New(now.Year, now.Month);
                monthEnd = Time.New(now.Year, now.Month).AddMonths(1);
            }
            else
            {
                throw new ArgumentException("Unable to handle pointer " + pointer + ".", "pointer");
            }
            return new Span(monthStart, monthEnd);
        }
Ejemplo n.º 8
0
        protected override Span NextSpan(Pointer.Type pointer)
        {
            if (_start == null)
            {
                var now = Now.Value;
                if (pointer == Pointer.Type.Future)
                {
                    _start = Time.New(now.Date.Year + 1);
                }
                else if (pointer == Pointer.Type.Past)
                {
                    _start = Time.New(now.Date.Year - 1);
                }
                else
                {
                    throw new ArgumentException("Unable to handle pointer " + pointer + ".", "pointer");
                }
            }
            else
            {
                var direction = (int)pointer;
                _start = _start.Value.AddYears(direction * 1);
            }

            return new Span(_start.Value, _start.Value.AddYears(1));
        }
Ejemplo n.º 9
0
        public void SubtractPointers()
        {
            var a = new Pointer(_buffer);
            var b = new Pointer(_buffer, 8);

            Assert.That((int )(b - a), Is.EqualTo(8));
        }
Ejemplo n.º 10
0
 public bool Activate(GameObject character, Pointer pointer)
 {
     StopAllCoroutines();
     Screen.lockCursor = false;
     StartCoroutine("ZoomToPanel", character);
     return true;
 }
Ejemplo n.º 11
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     var direction = (int)pointer;
     var newBegin = BuildOffsetTime(span.Start.Value, amount, direction);
     var newEnd = BuildOffsetTime(span.End.Value, amount, direction);
     return new Span(newBegin, newEnd);
 }
Ejemplo n.º 12
0
        private static byte[] GetUIntBytes(Pointer bytes)
		{
			if (BitConverter.IsLittleEndian)
				return new byte [] { bytes [0], bytes [1], bytes [2], bytes [3] };
			else
				return new byte [] { bytes [3], bytes [2], bytes [1], bytes [0] };
		}
Ejemplo n.º 13
0
 protected override Span NextSpan(Pointer.Type pointer)
 {
     if (_start == null)
     {
         if (pointer == Pointer.Type.Future)
         {
             var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
             saturdayRepeater.Now = Now;
             var nextSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Future);
             _start = nextSaturdaySpan.Start.Value;
         }
         else if (pointer == Pointer.Type.Past)
         {
             var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
             saturdayRepeater.Now = Now.Value.AddSeconds(RepeaterDay.DAY_SECONDS);
             var lastSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Past);
             _start = lastSaturdaySpan.Start.Value;
         }
     }
     else
     {
         var direction = (pointer == Pointer.Type.Future) ? 1 : -1;
         _start = _start.Value.AddSeconds(direction * RepeaterWeek.WEEK_SECONDS);
     }
     return new Span(
         _start.Value,
         _start.Value.AddSeconds(RepeaterWeekend.WEEKEND_SECONDS));
 }
Ejemplo n.º 14
0
 protected override Span CurrentSpan(Pointer.Type pointer)
 {
     Span thisSpan;
     if (pointer == Pointer.Type.Future || pointer == Pointer.Type.None)
     {
         var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
         saturdayRepeater.Now = Now;
         var thisSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Future);
         thisSpan = new Span(
             thisSaturdaySpan.Start.Value,
             thisSaturdaySpan.Start.Value.AddSeconds(WEEKEND_SECONDS));
     }
     else if (pointer == Pointer.Type.Past)
     {
         var saturdayRepeater = new RepeaterDayName(DayOfWeek.Saturday);
         saturdayRepeater.Now = Now;
         var lastSaturdaySpan = saturdayRepeater.GetNextSpan(Pointer.Type.Past);
         thisSpan = new Span(
             lastSaturdaySpan.Start.Value,
             lastSaturdaySpan.Start.Value.AddSeconds(RepeaterWeekend.WEEKEND_SECONDS));
     }
     else
     {
         throw new ArgumentException("Unable to handle pointer " + pointer + ".", "pointer");
     }
     return thisSpan;
 }
Ejemplo n.º 15
0
        public bool AppendFromSelf(int offset, int len)
        {
            int spaceLeft = _length - _index;

            if(_index <= offset - 1u)
            {
                // -1u catches offset==0
                return false;
            }

            var op = new Pointer(_buffer, _index);
            if(len <= 16 && offset >= 8 && spaceLeft >= 16)
            {
                var src = new Pointer(_buffer, _index - offset);
                op.Copy64(src);
                op.Copy64(src + 8, 8);
            }
            else
            {
                if(spaceLeft >= len + CompressorConstants.MaxIncrementCopyOverflow)
                    IncrementalCopyFastPath(op - offset, op, len);
                else
                {
                    if(spaceLeft < len)
                        return false;

                    IncrementalCopy(op - offset, op, len);
                }
            }

            _index += len;
            return true;
        }
Ejemplo n.º 16
0
        public void AddPointers()
        {
            var a = new Pointer(_buffer);
            var b = new Pointer(_buffer, 8);

            Assert.That(b, Is.EqualTo(a + 8));
        }
Ejemplo n.º 17
0
        protected override Span NextSpan(Pointer.Type pointer)
        {
            var now = Now.Value;

            if (_start == null)
            {
                if (pointer == Pointer.Type.Future)
                {
                    _start = Time.New(now, now.Hour, now.Minute).AddMinutes(1);
                }
                else if (pointer == Pointer.Type.Past)
                {
                    _start = Time.New(now, now.Hour, now.Minute).AddMinutes(-1);
                }
                else
                {
                    throw new ArgumentException("Unable to handle pointer " + pointer + ".");
                }
            }
            else
            {
                int direction = (pointer == Pointer.Type.Future) ? 1 : -1;
                _start.Value.AddMinutes(direction);
            }

            return new Span(_start.Value, _start.Value.AddSeconds(RepeaterMinute.MINUTE_SECONDS));
        }
Ejemplo n.º 18
0
 public override Span GetOffset(Span span, int amount,
     Pointer.Type pointer)
 {
     int direction = (pointer == Pointer.Type.Future) ? 1 : -1;
     // WARN: Does not use Calendar
     return span.Add(direction * amount * RepeaterSecond.SECOND_SECONDS);
 }
Ejemplo n.º 19
0
 public override Span GetOffset(Span span, int amount, Pointer.Type pointer)
 {
     int direction = (pointer == Pointer.Type.Future) ? 1 : -1;
     return new Span(
         span.Start.Value.AddMonths(amount * direction),
         span.End.Value.AddMonths(amount * direction)
     );
 }
Ejemplo n.º 20
0
 public static void ReturnFromPageFault(L4Handle target, out Msgtag tag, ref MessageRegisters mr, uint pfa, Pointer physicalPage, uint permssion)
 {
     var virt_page_addr = ArchDefinition.PageIndex(physicalPage.ToUInt32());
     var fpage = new L4FPage(virt_page_addr, ArchDefinition.PageShift, (int)permssion);
     tag = new Msgtag(0, 0, 1, 0);
     mr.mr0 = (int)(ArchDefinition.PageIndex(pfa) | Msgtag.L4_ITEM_MAP);
     mr.mr1 = (int)fpage.raw;
     NativeMethods.l4api_ipc_send(target, NativeMethods.l4api_utcb(), tag, Timeout.Never);
 }
Ejemplo n.º 21
0
    public bool Activate(GameObject character, Pointer pointer)
    {
        if (pointer.stored != null) return false;

        StopAllCoroutines();
        StartCoroutine("GrabItem", character);
        pointer.delayed = DelayedActivate;
        return false;
    }
Ejemplo n.º 22
0
		static public uint get_le32(ref Pointer<byte> g)
		{
			var v0 = get_byte(ref g);
			var v1 = get_byte(ref g);
			var v2 = get_byte(ref g);
			var v3 = get_byte(ref g);

			return (uint)((v0 << 0) | (v1 << 8) | (v2 << 16) | (v3 << 24));
		}
Ejemplo n.º 23
0
 public override bool Intersect(Ray r, Pointer<float> tHit, Pointer<float> rayEpsilon, Pointer<DifferentialGeometry> dg)
 {
     float phi;
     Point phit;
     Ray ray = (WorldToObject)[r];
     float A = ray.Direction.X * ray.Direction.X + ray.Direction.Y * ray.Direction.Y;
     float B = 2 * (ray.Direction.X * ray.Origin.X + ray.Direction.Y * ray.Origin.Y);
     float C = ray.Origin.X * ray.Origin.X + ray.Origin.Y * ray.Origin.Y - Radius * Radius;
     float t0 = 0, t1 = 0;
     if (!MathHelper.Quadratic(A, B, C, ref t0, ref t1))
         return false;
     if (t0 > ray.MaxT || t1 < ray.MinT)
         return false;
     float thit = t0;
     if (t0 < ray.MinT)
     {
         thit = t1;
         if (thit > ray.MaxT) return false;
     }
     phit = ray[thit];
     phi = MathHelper.Atan2(phit.Y, phit.X);
     if (phi < 0) phi += 2.0f * MathHelper.PI;
     if (phit.Z < ZMin || phit.Z > ZMax || phi > PhiMax)
     {
         if (thit == t1) return false;
         thit = t1;
         if (t1 > ray.MaxT) return false;
         phit = ray[thit];
         phi = MathHelper.Atan2(phit.Y, phit.X);
         if (phi < 0) phi += 2.0f * MathHelper.PI;
         if (phit.Z < ZMin || phit.Z > ZMax || phi > PhiMax)
             return false;
     }
     float u = phi / PhiMax;
     float v = (phit.Z - ZMin) / (ZMax - ZMin);
     Vector dpdu = new Vector(-PhiMax * phit.Y, PhiMax * phit.X, 0);
     Vector dpdv = new Vector(0, 0, ZMax - ZMin);
     Vector d2Pduu = -PhiMax * PhiMax * new Vector(phit.X, phit.Y, 0);
     Vector d2Pduv = new Vector(0, 0, 0), d2Pdvv = new Vector(0, 0, 0);
     float E = Vector.Dot(dpdu, dpdu);
     float F = Vector.Dot(dpdu, dpdv);
     float G = Vector.Dot(dpdv, dpdv);
     Vector N = Vector.Normalize(Vector.Cross(dpdu, dpdv));
     float e = Vector.Dot(N, d2Pduu);
     float f = Vector.Dot(N, d2Pduv);
     float g = Vector.Dot(N, d2Pdvv);
     float invEGF2 = 1.0f / (E * G - F * F);
     Normal dndu = new Normal((f * F - e * G) * invEGF2 * dpdu + (e * F - f * E) * invEGF2 * dpdv);
     Normal dndv = new Normal((g * F - f * G) * invEGF2 * dpdu + (f * F - g * E) * invEGF2 * dpdv);
     Transform o2w = ObjectToWorld;
     dg[0] = new DifferentialGeometry(o2w[phit], o2w[dpdu], o2w[dpdv],
                                o2w[dndu], o2w[dndv], u, v, this);
     tHit[0] = thit;
     rayEpsilon[0] = 5e-4f * ~tHit;
     return true;
 }
Ejemplo n.º 24
0
        public void TestToString()
        {
            var a = new Pointer(_buffer, name:"a");
            var b = new Pointer(_buffer, 8, name:"b");
            var anon = new Pointer(_buffer);

            Assert.That(a.ToString(), Is.EqualTo("a[16]"));
            Assert.That(b.ToString(), Is.EqualTo("b[16]+8"));
            Assert.That(anon.ToString(), Is.EqualTo("<???>[16]"));
        }
Ejemplo n.º 25
0
 public void Pointer_operator() {
     Pointer pointer = new Pointer(message, 0);
     Assert.AreEqual(message[0], pointer[0]);
     Assert.AreEqual(message[1], (++pointer as Pointer).GetByte());
     Assert.AreEqual(message[2], pointer.GetByte());
     Assert.AreEqual(message[3], pointer.GetByte());
     Assert.AreEqual(message[4], pointer.GetByte());
     Assert.AreEqual(message[5], pointer.GetByte());
     Assert.AreEqual(message[6], pointer.GetByte());
 }
Ejemplo n.º 26
0
 public void Pointer_GetShort() {
     Pointer pointer = new Pointer(message, 0);
     Assert.AreEqual(message[0] << 8 | message[1], pointer.GetShort());
     Assert.AreEqual(message[2] << 8 | message[3], pointer.GetShort());
     Assert.AreEqual(message[4] << 8 | message[5], pointer.GetShort());
     Assert.Throws<IndexOutOfRangeException>(delegate()
     {
         pointer.GetShort();
     });
 }
Ejemplo n.º 27
0
 public void Pointer_GetByte() {
     Pointer pointer = new Pointer(message, 0);
     Assert.AreEqual(message[0], pointer.GetByte());
     Assert.AreEqual(message[1], pointer.GetByte());
     Assert.AreEqual(message[2], pointer.GetByte());
     Assert.AreEqual(message[3], pointer.GetByte());
     Assert.AreEqual(message[4], pointer.GetByte());
     Assert.AreEqual(message[5], pointer.GetByte());
     Assert.AreEqual(message[6], pointer.GetByte());
 }
Ejemplo n.º 28
0
 protected unsafe override long ReadData(Pointer<sbyte> data, long maxsize)
 {
     int max = (maxsize > int.MaxValue)? int.MaxValue : (int) maxsize;
     byte[] buffer = new byte[max];
     int read = m_stream.Read(buffer, 0, max);
     for (int i = 0; i < max; i++) {
         data[i] = (sbyte) buffer[i];
     }
     return read;
 }
Ejemplo n.º 29
0
		static byte[] GetBytes (Pointer ptr, int count)
		{
			byte [] ret = new byte [count];

			for (int i = 0; i < count; i++) {
				ret [i] = ptr [i];
			}

			return ret;
		}
Ejemplo n.º 30
0
 public void SubPointer()
 {
     var ptr = new Pointer(new StructureType("tmp", 16), 4);
     var id = new Identifier("id", ptr, null);
     var emitter = new CodeEmitterImpl();
     var sub = emitter.ISub(id, 3);
     Assert.AreEqual("(ptr (struct \"tmp\" 0010))", sub.DataType.ToString());
     Assert.AreEqual(PrimitiveType.Word32, sub.Right.DataType);
     Assert.AreEqual("id - 0x00000003", sub.ToString());
 }
Ejemplo n.º 31
0
 public EntryAction(Pointer offset)
 {
     this.offset = offset;
 }
        /// <summary>
        /// Free previously allocated space (the location and amount of space to free must be specified by using
        /// a <see cref="Pointer"/> to indicate the location and a number of units to indicate the amount).
        /// </summary>
        /// <param name="pointer"></param>
        /// <param name="unitCount"></param>
        public void FreeUnits(Pointer pointer, uint unitCount)
        {
            uint index = unitsToIndex[unitCount - 1];

            MemoryNodes[index].Insert(pointer, indexToUnits[index]);
        }
Ejemplo n.º 33
0
 public UInt16Buffer(byte[] bytes)
     : base(bytes)
 {
     _arrPtr = (UInt16 *)Pointer.ToPointer();
 }
Ejemplo n.º 34
0
        public static GeometricObjectCollide Read(Reader reader, Pointer offset, CollideType type = CollideType.None, bool isBoundingVolume = false)
        {
            MapLoader l = MapLoader.Loader;
            //l.print("CollideMesh " + offset);
            GeometricObjectCollide m = new GeometricObjectCollide(offset, type);

            m.isBoundingVolume = isBoundingVolume;
            if (Settings.s.engineVersion == Settings.EngineVersion.R3 || Settings.s.game == Settings.Game.R2Revolution)
            {
                m.num_vertices = reader.ReadUInt16();
                m.num_elements = reader.ReadUInt16();
                if (Settings.s.engineVersion == Settings.EngineVersion.R3 && Settings.s.game != Settings.Game.LargoWinch)
                {
                    reader.ReadUInt32();
                }
            }
            if (Settings.s.engineVersion <= Settings.EngineVersion.Montreal)
            {
                m.num_vertices = (ushort)reader.ReadUInt32();
            }
            m.off_vertices = Pointer.Read(reader);
            if (Settings.s.engineVersion < Settings.EngineVersion.R3 && Settings.s.game != Settings.Game.R2Revolution)
            {
                m.off_normals = Pointer.Read(reader);
                Pointer.Read(reader);
                reader.ReadInt32();
            }
            if (Settings.s.engineVersion <= Settings.EngineVersion.Montreal)
            {
                m.num_elements = (ushort)reader.ReadUInt32();
            }
            m.off_element_types = Pointer.Read(reader);
            m.off_elements      = Pointer.Read(reader);
            if (Settings.s.game != Settings.Game.R2Revolution && Settings.s.game != Settings.Game.LargoWinch)
            {
                Pointer.Read(reader);
                if (Settings.s.engineVersion < Settings.EngineVersion.R3)
                {
                    if (Settings.s.engineVersion == Settings.EngineVersion.R2)
                    {
                        reader.ReadInt32();
                        reader.ReadInt32();
                        reader.ReadInt32();
                        reader.ReadInt32();
                        m.num_vertices = reader.ReadUInt16();
                        m.num_elements = reader.ReadUInt16();
                    }
                    if (Settings.s.engineVersion <= Settings.EngineVersion.Montreal)
                    {
                        reader.ReadInt32();
                        reader.ReadInt32();
                    }
                    reader.ReadUInt16();
                    m.num_parallelBoxes = reader.ReadUInt16();
                }
                else
                {
                    //l.print((Pointer.Current(reader).FileOffset - offset.FileOffset));
                    m.off_parallelBoxes = Pointer.Read(reader);
                }
            }
            else
            {
                reader.ReadUInt32();
            }
            if (Settings.s.engineVersion != Settings.EngineVersion.Montreal)
            {
                m.sphereRadius = reader.ReadSingle(); // bounding volume radius
                float sphereX = reader.ReadSingle();  // x
                float sphereZ = reader.ReadSingle();  // z
                float sphereY = reader.ReadSingle();  // y
                m.sphereCenter = new Vector3(sphereX, sphereY, sphereZ);

                if (Settings.s.engineVersion == Settings.EngineVersion.R2)
                {
                    reader.ReadUInt32();
                }
            }

            // Vertices
            Pointer off_current = Pointer.Goto(ref reader, m.off_vertices);

            m.vertices = new Vector3[m.num_vertices];
            for (int i = 0; i < m.num_vertices; i++)
            {
                float x = reader.ReadSingle();
                float z = reader.ReadSingle();
                float y = reader.ReadSingle();
                m.vertices[i] = new Vector3(x, y, z);
            }

            // Normals
            if (m.off_normals != null)
            {
                off_current = Pointer.Goto(ref reader, m.off_normals);
                m.normals   = new Vector3[m.num_vertices];
                for (int i = 0; i < m.num_vertices; i++)
                {
                    float x = reader.ReadSingle();
                    float z = reader.ReadSingle();
                    float y = reader.ReadSingle();
                    m.normals[i] = new Vector3(x, y, z);
                }
            }
            // Read subblock types & initialize arrays
            Pointer.Goto(ref reader, m.off_element_types);
            m.element_types = new ushort[m.num_elements];
            m.elements      = new IGeometricObjectElementCollide[m.num_elements];
            for (uint i = 0; i < m.num_elements; i++)
            {
                m.element_types[i] = reader.ReadUInt16();
            }

            for (uint i = 0; i < m.num_elements; i++)
            {
                Pointer.Goto(ref reader, m.off_elements + (i * 4));
                Pointer block_offset = Pointer.Read(reader);
                Pointer.Goto(ref reader, block_offset);
                switch (m.element_types[i])
                {
                /*1 = indexedtriangles
                 * 2 = facemap
                 * 3 = sprite
                 * 4 = TMesh
                 * 5 = points
                 * 6 = lines
                 * 7 = spheres
                 * 8 = alignedboxes
                 * 9 = cones
                 * 13 = deformationsetinfo*/
                case 1:     // Collide submesh
                    m.elements[i] = GeometricObjectElementCollideTriangles.Read(reader, block_offset, m);
                    //material_i++;
                    break;

                case 7:
                    m.elements[i] = GeometricObjectElementCollideSpheres.Read(reader, block_offset, m);
                    break;

                case 8:
                    m.elements[i] = GeometricObjectElementCollideAlignedBoxes.Read(reader, block_offset, m);
                    break;

                default:
                    m.elements[i] = null;
                    l.print("Unknown collide geometric element type " + m.element_types[i] + " at offset " + block_offset + " (Object: " + offset + ")");
                    break;
                }
            }
            return(m);
        }
Ejemplo n.º 35
0
        private void ReleasePointerCaptureNative(Pointer pointer)
        {
            var command = "Uno.UI.WindowManager.current.releasePointerCapture(\"" + HtmlId + "\", " + pointer.PointerId + ");";

            WebAssemblyRuntime.InvokeJS(command);
        }
 public void saveVar(string key, Pointer pointer)     //storing the ref to an int
 {
     MyDict.Add(key, pointer);
 }
Ejemplo n.º 37
0
 private Pointer(Pointer parent, int pointerId)
     : this(parent.ShortName, parent.Id, pointerId, parent.IsPositiveAndNegative)
 {
 }
Ejemplo n.º 38
0
        private void DragDropTarget_PointerPressed(object sender, PointerRoutedEventArgs e)
#endif
        {
            //----------------------------------
            // DRAG OPERATION STARTS HERE
            //----------------------------------

            // Prevent the PointerPressed event from bubbling up so that if there are two nested DragDropTargets, only the inner one will be dragged:
            e.Handled = true;

            // We verify that drag operation is not taking place, which can lead a case if we missed the pointer released event due to a glitch such as moving the mouse outside the browser and releasing
            if (!_isPointerCaptured)
            {
                // Reset some variables:
                _isDragCancelled = false;
                _previousdragDropTargetUnderPointer = null;

                // Remember the current pointer position:
#if MIGRATION
                _pointerX = e.GetPosition(null).X;
                _pointerY = e.GetPosition(null).Y;
#else
                _pointerX = e.GetCurrentPoint(null).Position.X;
                _pointerY = e.GetCurrentPoint(null).Position.Y;
#endif
                // Get the source DragDropTarget element that is under the pointer, if any:
                DragDropTarget <TItemsControlType, TItemContainerType> sourceDragDropTarget = GetDragDropTargetUnderPointer(_pointerX, _pointerY, out _sourceItemContainer);
                if (sourceDragDropTarget != this)
                {
                    throw new Exception("The DragDropTarget is not supposed to support dragging an outer DragDropTarget in case of nested DragDropTargets.");
                }

                // We do something only if the source exists (ie. if an item was found under the pointer):
                if (_sourceItemContainer != null)
                {
                    // Get a reference to the ItemsControl:
                    _sourceItemsControl = (TItemsControlType)this.Content; // Note: there is no risk of InvalidCastException because the type has been tested before, and the derived class (PanelDragDropTarget) also verifies the type in the "OnContentChanged" method.

                    // Capture the pointer so that when dragged outside the DragDropPanel, we can still get its position:
    #if MIGRATION
                    this.CaptureMouse();
    #else
                    this.CapturePointer(e.Pointer);
    #endif
                    // Remember that the pointer is currently captured:
                    _isPointerCaptured = true;
                    _capturedPointer   = e.Pointer;

                    //Size of the content
                    double height;
                    double width;
                    if (_sourceItemContainer is FrameworkElement)
                    {
                        Size actualSize = (_sourceItemContainer as FrameworkElement).INTERNAL_GetActualWidthAndHeight();
                        height = actualSize.Height;
                        width  = actualSize.Width;
                    }
                    else
                    {
                        height = double.NaN;
                        width  = double.NaN;
                    }

                    // Prepare the arguments of the "ItemDragStarting" event:
                    Selection           selection                 = new Selection(_sourceItemContainer);
                    SelectionCollection selectionCollection       = SelectionCollection.ToSelectionCollection(selection);
                    ItemDragEventArgs   itemDragStartingEventArgs = new ItemDragEventArgs(selectionCollection);

                    // Raise the "ItemDragStarting" event:
                    if (ItemDragStarting != null)
                    {
                        ItemDragStarting(this, itemDragStartingEventArgs);
                    }

                    // Show the popup, unless the user has cancelled the drag operation:
                    if (itemDragStartingEventArgs.Handled && itemDragStartingEventArgs.Cancel)
                    {
                        //----------------------------------
                        // CANCELLED BY USER
                        //----------------------------------

                        if (_isPointerCaptured)
                        {
                            // Stop capturing the pointer:
                            _isPointerCaptured = false;

#if MIGRATION
                            this.ReleaseMouseCapture();
#else
                            this.ReleasePointerCapture(_capturedPointer);
#endif
                        }
                    }
                    else
                    {
                        //----------------------------------
                        // SHOW POPUP
                        //----------------------------------

                        // Put a placeholder in place of the source that will occupy the same space. This is useful to: 1) let the user drop over the source itself (cf. "ItemDroppedOnSource" event), and 2) prevent the other elements from being displaced during the drag operation.
                        RemoveSourceAndPutTransparentPlaceholderInPlace(height, width);

                        // Put the source into a popup:
                        StackPanel stackPanelInPopUp = GeneratePopupContent(_sourceItemContainer, out _iconStop, out _iconArrow);
                        this._popup = new Popup()
                        {
                            Child = stackPanelInPopUp,
                            HorizontalAlignment        = HorizontalAlignment.Left,
                            VerticalAlignment          = VerticalAlignment.Top,
                            HorizontalContentAlignment = HorizontalAlignment.Left,
                            VerticalContentAlignment   = VerticalAlignment.Top,
                            IsHitTestVisible           = false
                        };

                        // Set the popup position:
                        this._popup.HorizontalOffset = this._pointerX;
                        this._popup.VerticalOffset   = this._pointerY;

                        // Show the popup:
                        this._popup.IsOpen = true;
                    }
                }
            }
        }
Ejemplo n.º 39
0
 /// <summary>
 /// Gets the physical address.
 /// </summary>
 /// <param name="memory">The memory.</param>
 /// <returns></returns>
 public override Pointer TranslateVirtualToPhysicalAddress(Pointer virtualAddress)
 {
     return(PageTable.GetPhysicalAddressFromVirtual(virtualAddress));
 }
Ejemplo n.º 40
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddIntList(ref m_SerializeBuffer, p, CharacterIdOrder);
     return(m_SerializeBuffer);
 }
Ejemplo n.º 41
0
 public Behavior(Pointer offset)
 {
     this.offset = offset;
 }
Ejemplo n.º 42
0
 public void Visit(Pointer pointer, byte data) => Result = pointer.DestinationAsText;
Ejemplo n.º 43
0
 public int VisitPointer(Pointer ptr)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 44
0
 public override string ToString()
 {
     return(Pointer.ToString() + "." + Value.ToString());
 }
Ejemplo n.º 45
0
 public override byte[] Serialize(Pointer p)
 {
     base.Serialize(p);
     BitPacker.AddLong(ref m_SerializeBuffer, p, StartTime);
     return(m_SerializeBuffer);
 }
Ejemplo n.º 46
0
 public override int GetHashCode() => Pointer.GetHashCode();
Ejemplo n.º 47
0
 public override bool DeSerialize(byte[] data, Pointer p)
 {
     base.DeSerialize(data, p);
     StartTime = BitPacker.GetLong(data, p);
     return(true);
 }
Ejemplo n.º 48
0
        public void Crawl(TextWriter output, bool includeDataWords, Pointer root = default(Pointer))
        {
            bool oldAutoDereference = AutoDereference;

            try
            {
                AutoDereference = false;
                var pending = new SortedDictionary <Pointer, Pointer>();
                if (!root.IsValid)
                {
                    root = this.Root;
                }
                pending.Add(root, root);
                HashSet <Pointer> seen = new HashSet <Pointer>();
                while (pending.Count != 0)
                {
                    Pointer next, from;
                    using (var iter = pending.GetEnumerator())
                    {
                        if (!iter.MoveNext())
                        {
                            break;
                        }
                        next = iter.Current.Key;
                        from = iter.Current.Value;
                    }
                    pending.Remove(next);

                    if (!next.IsValid)
                    {
                        continue;
                    }

                    output.WriteLine(next.ToString());
                    if (next != from)
                    {
                        output.WriteLine("     < {0}", from);
                    }

                    if (!seen.Add(next))
                    {
                        output.WriteLine("   (duplicated; recursion is likely)");
                        continue;
                    }

                    if (next.IsFar)
                    {
                        var child = next.Dereference();
                        output.WriteLine("     > {0}", child);
                        if (child.IsValid)
                        {
                            pending.Add(child, next);
                        }
                    }
                    else
                    {
                        if (next.IsList())
                        {
                            int  count         = next.Count();
                            bool isPointerList = next.IsPointerList();
                            for (int i = 0; i < count; i++)
                            {
                                var child = isPointerList ? next.GetListPointer(i)
                                    : next.GetListStruct(i);
                                output.WriteLine("  {0:00} > {1}", i, child);
                                if (child.IsValid)
                                {
                                    pending.Add(child, next);
                                }
                            }
                        }
                        int pointers = next.Pointers();
                        if (includeDataWords)
                        {
                            int words = next.DataWords();
                            for (int i = 0; i < words; i++)
                            {
                                output.WriteLine("  {0:00} : {1}", i, Segments.ToString(next.GetUInt64(i)));
                            }
                        }
                        for (int i = 0; i < pointers; i++)
                        {
                            var child = next.GetPointer(i);
                            output.WriteLine("  {0:00} > {1}", i, child);
                            if (child.IsValid)
                            {
                                pending.Add(child, next);
                            }
                        }
                    }
                    output.WriteLine();
                }
            }
            finally
            {
                AutoDereference = oldAutoDereference;
            }
        }
Ejemplo n.º 49
0
 internal MetaIL(Pointer <ILMethod> ptr) : base(ptr)
 {
 }
Ejemplo n.º 50
0
 public IntPtr At(IntPtr offset)
 {
     return((IntPtr)(Pointer.ToInt64() + offset.ToInt64()));
 }
Ejemplo n.º 51
0
 public override bool DeSerialize(byte[] data, Pointer p)
 {
     base.DeSerialize(data, p);
     CharacterIdOrder = BitPacker.GetIntList(ref data, p);
     return(true);
 }
Ejemplo n.º 52
0
 public static bool TryGetAddressOfHeap <T>(T value, out Pointer <byte> ptr)
 {
     return(TryGetAddressOfHeap(value, OffsetOptions.NONE, out ptr));
 }
Ejemplo n.º 53
0
 public MetaField(Pointer <FieldDesc> ptr) : base(ptr)
 {
 }
Ejemplo n.º 54
0
 public static unsafe object Wrap <T>(T *ptr)
     where T : unmanaged => Pointer.Box(ptr, typeof(T *));
Ejemplo n.º 55
0
 public GeometricObjectCollide(Pointer offset, CollideType type = CollideType.None)
 {
     this.offset = offset;
     this.type   = type;
 }
Ejemplo n.º 56
0
 public void Write(Writer writer) {
     Pointer.Goto(ref writer, Offset + 8);
     Pointer.Write(writer, off_comport);
 }
Ejemplo n.º 57
0
 public static void ReleaseIfNotNull <TUnknown>(Pointer <TUnknown> unknown)
     where TUnknown : unmanaged => ReleaseIfNotNull(unknown.Value);
Ejemplo n.º 58
0
        public static EntryAction Read(Reader reader, Pointer offset)
        {
            MapLoader   l  = MapLoader.Loader;
            EntryAction ea = new EntryAction(offset);

            //l.print("EntryAction " + offset);
            l.entryActions.Add(ea);

            if (Settings.s.game == Settings.Game.TTSE)
            {
                ea.off_entryAction_next = Pointer.Read(reader);
                ea.off_entryAction_prev = Pointer.Read(reader);
                reader.ReadUInt32(); //element.off_entryAction_hdr = Pointer.Read(reader); // hdr pointer doesn't work here
                ea.keywords = LinkedList <KeyWord> .Read(ref reader, Pointer.Current(reader),
                                                         (off_element) => {
                    return(KeyWord.Read(reader, off_element));
                },
                                                         flags : Settings.s.hasLinkedListHeaderPointers?
                                                         LinkedList.Flags.HasHeaderPointers :
                                                         LinkedList.Flags.NoPreviousPointersForDouble,
                                                         type : LinkedList.Type.Default);

                ea.off_name = Pointer.Read(reader);
                reader.ReadInt32(); // -2
                reader.ReadUInt32();
                reader.ReadByte();
                ea.active = reader.ReadByte();
                reader.ReadBytes(2);
            }
            else
            {
                if (Settings.s.hasExtraInputData)
                {
                    reader.ReadBytes(0x18);
                }
                if (Settings.s.platform == Settings.Platform.PS2 &&
                    (Settings.s.game == Settings.Game.RM ||
                     Settings.s.game == Settings.Game.RA ||
                     Settings.s.mode == Settings.Mode.Rayman3PS2Demo_2002_12_18))
                {
                    reader.ReadBytes(0x8);
                }
                ea.num_keywords = reader.ReadUInt32();
                ea.off_keywords = Pointer.Read(reader);
                ea.keywords     = new LinkedList <KeyWord>(Pointer.Current(reader), ea.off_keywords, ea.num_keywords, type: LinkedList.Type.SingleNoElementPointers);
                if (Settings.s.engineVersion < Settings.EngineVersion.R2)
                {
                    reader.ReadUInt32();                                                       // Offset of extra input data in tmp memory? It's different by 0x18 every time
                }
                ea.off_name = Pointer.Read(reader);
                if (Settings.s.hasExtraInputData || Settings.s.platform == Settings.Platform.DC || Settings.s.engineVersion == Settings.EngineVersion.R3)
                {
                    ea.off_name2 = Pointer.Read(reader);
                }
                reader.ReadInt32();                 // -2
                reader.ReadUInt32();
                ea.active = reader.ReadByte();
                reader.ReadBytes(3);

                ea.keywords.ReadEntries(ref reader, (off_element) => {
                    return(KeyWord.Read(reader, off_element));
                });
            }
            if (ea.keywords != null && ea.keywords.Count > 0)
            {
                int keywordsRead = ea.keywords[0].FillInSubKeywords(ref reader, ea.keywords, 0);
                if (keywordsRead != ea.keywords.Count)
                {
                    Debug.LogError(offset + " - Keywords read was: " + keywordsRead + " vs " + ea.keywords.Count);
                    Debug.LogError(ea.ToString());
                }
            }
            Pointer.DoAt(ref reader, ea.off_name, () => {
                ea.name = reader.ReadNullDelimitedString();
            });
            Pointer.DoAt(ref reader, ea.off_name2, () => {
                ea.name2 = reader.ReadNullDelimitedString();
            });

            return(ea);
        }
Ejemplo n.º 59
0
    public void Init()
    {
        if (MapLoader.Loader is OpenSpace.Loader.R2ROMLoader)
        {
            OpenSpace.Loader.R2ROMLoader l = MapLoader.Loader as OpenSpace.Loader.R2ROMLoader;
            foreach (OpenSpace.ROM.WayPoint wp in l.waypointsROM)
            {
                AddWaypoint(wp.GetGameObject());
            }
            if (graphRoot == null && l.graphsROM.Count > 0)
            {
                graphRoot = new GameObject("Graphs");
                graphRoot.transform.SetParent(transform);
                graphRoot.SetActive(false);
            }
            foreach (OpenSpace.ROM.Graph graph in l.graphsROM)
            {
                GameObject go_graph = new GameObject("Graph " + graph.Offset);
                go_graph.transform.SetParent(graphRoot.transform);
                GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>();
                graphs.Add(gb);
                gb.graphROM         = graph;
                graphROMDict[graph] = gb;

                for (int i = 0; i < graph.num_nodes; i++)
                {
                    OpenSpace.ROM.GraphNode node = graph.nodes.Value.nodes[i].Value;
                    if (node.waypoint.Value != null)
                    {
                        WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpROM == node.waypoint.Value);
                        if (wp != null)
                        {
                            gb.nodes.Add(wp);
                            wp.nodesROM.Add(node);
                            if (!wp.graphs.Contains(gb))
                            {
                                wp.graphs.Add(gb);
                            }
                            wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpROM.Offset + ")";
                            if (i == 0)
                            {
                                go_graph.transform.position = wp.transform.position;
                            }
                            wp.transform.SetParent(go_graph.transform);
                        }
                    }
                }
            }
        }
        else if (MapLoader.Loader is OpenSpace.Loader.R2PS1Loader)
        {
            OpenSpace.Loader.R2PS1Loader l = MapLoader.Loader as OpenSpace.Loader.R2PS1Loader;
            if (l.levelHeader?.wayPoints != null)
            {
                foreach (OpenSpace.PS1.WayPoint wp in l.levelHeader.wayPoints)
                {
                    AddWaypoint(wp.GetGameObject());
                }
            }
            if (l.levelHeader?.graphs != null)
            {
                if (graphRoot == null && l.levelHeader?.graphs.Length > 0)
                {
                    graphRoot = new GameObject("Graphs");
                    graphRoot.transform.SetParent(transform);
                    graphRoot.SetActive(false);
                }
                foreach (OpenSpace.PS1.Graph graph in l.levelHeader?.graphs)
                {
                    GameObject go_graph = new GameObject("Graph " + graph.Offset);
                    go_graph.transform.SetParent(graphRoot.transform);
                    GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>();
                    graphs.Add(gb);
                    gb.graphPS1         = graph;
                    graphPS1Dict[graph] = gb;

                    for (int i = 0; i < graph.arcs.Length; i++)
                    {
                        OpenSpace.PS1.Arc arc = graph.arcs[i];
                        if (arc.node1 != null)
                        {
                            WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpPS1 == arc.node1);
                            if (wp != null)
                            {
                                if (!gb.nodes.Contains(wp))
                                {
                                    gb.nodes.Add(wp);
                                }
                                wp.arcsPS1.Add(arc);
                                if (!wp.graphs.Contains(gb))
                                {
                                    wp.graphs.Add(gb);
                                }
                                wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpPS1.Offset + ")";

                                /*if (i == 0) {
                                 *      go_graph.transform.position = wp.transform.position;
                                 * }*/
                                wp.transform.SetParent(go_graph.transform);
                            }
                        }
                        if (arc.node2 != null)
                        {
                            WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wpPS1 == arc.node2);
                            if (wp != null)
                            {
                                if (!gb.nodes.Contains(wp))
                                {
                                    gb.nodes.Add(wp);
                                }
                                wp.arcsPS1.Add(arc);
                                if (!wp.graphs.Contains(gb))
                                {
                                    wp.graphs.Add(gb);
                                }
                                wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wpPS1.Offset + ")";

                                /*if (i == 0) {
                                 *      go_graph.transform.position = wp.transform.position;
                                 * }*/
                                wp.transform.SetParent(go_graph.transform);
                            }
                        }
                    }
                }
            }
        }
        else
        {
            MapLoader l = MapLoader.Loader;
            foreach (WayPoint wp in l.waypoints)
            {
                AddWaypoint(wp.Gao.GetComponent <WayPointBehaviour>());
            }
            if (graphRoot == null && l.graphs.Count > 0)
            {
                graphRoot = new GameObject("Graphs");
                graphRoot.transform.SetParent(transform);
                graphRoot.SetActive(false);
            }
            foreach (Graph graph in l.graphs)
            {
                GameObject go_graph = new GameObject(graph.name ?? "Graph " + graph.offset.ToString());
                go_graph.transform.SetParent(graphRoot.transform);
                GraphBehaviour gb = go_graph.AddComponent <GraphBehaviour>();
                graphs.Add(gb);
                gb.graph         = graph;
                graphDict[graph] = gb;

                for (int i = 0; i < graph.nodes.Count; i++)
                {
                    GraphNode node = graph.nodes[i];
                    if (node == null)
                    {
                        continue;
                    }
                    if (node.wayPoint != null)
                    {
                        WayPointBehaviour wp = waypoints.FirstOrDefault(w => w.wp == node.wayPoint);
                        if (wp != null)
                        {
                            gb.nodes.Add(wp);
                            wp.nodes.Add(node);
                            if (!wp.graphs.Contains(gb))
                            {
                                wp.graphs.Add(gb);
                            }
                            wp.name = "GraphNode[" + i + "].WayPoint (" + wp.wp.offset + ")";
                            if (i == 0)
                            {
                                go_graph.transform.position = wp.transform.position;
                            }
                            wp.transform.SetParent(go_graph.transform);
                        }
                    }
                }
            }
        }

        List <WayPointBehaviour> isolateWaypoints = waypoints.Where(w => w.nodes.Count == 0 && w.nodesROM.Count == 0 && w.arcsPS1.Count == 0).ToList();

        if (isolateWaypointRoot == null && isolateWaypoints.Count > 0)
        {
            isolateWaypointRoot = new GameObject("Isolate WayPoints");
            isolateWaypointRoot.transform.SetParent(transform);
            isolateWaypointRoot.SetActive(false);
        }
        foreach (WayPointBehaviour wp in isolateWaypoints)
        {
            Pointer offset = (wp.wpROM != null ? wp.wpROM.Offset : (wp.wpPS1 != null ? wp.wpPS1.Offset : wp.wp.offset));
            wp.name = "Isolate WayPoint @" + offset;
            wp.transform.SetParent(isolateWaypointRoot.transform);
        }
        foreach (WayPointBehaviour wp in waypoints)
        {
            wp.Init();
        }
        UpdateViewGraphs();
        //loaded = true;
    }
Ejemplo n.º 60
0
 public DataType VisitPointer(Pointer ptr)
 {
     ptr.Pointee = ptr.Pointee.Accept(this);
     return(ptr);
 }