public unsafe void CopyFromCopyTo()
        {
            // Allocate array space for a copy and create a new fixed pointer to it.
            IntPtr copyPtr      = _currentProcess.Allocate(_fixedArrayPtr.ArraySize);
            var    arrayCopyPtr = new FixedArrayPtr <AdventurePhysics>((ulong)copyPtr, _fixedArrayPtr.Count);

            // Copy from original to new array.
            AdventurePhysics[] physicsArray = new AdventurePhysics[_fixedArrayPtr.Count];
            _fixedArrayPtr.CopyTo(physicsArray, _fixedArrayPtr.Count);
            arrayCopyPtr.CopyFrom(physicsArray, physicsArray.Length);

            // Check both copies are identical.
            for (int x = 0; x < physicsArray.Length; x++)
            {
                _fixedArrayPtr.Get(out var physicsOriginal, x);
                arrayCopyPtr.Get(out var physicsCopied, x);

                if (!physicsOriginal.Equals(physicsCopied))
                {
                    Assert.True(false, "All array entries between the two fixed array pointers should be equal.");
                }
            }

            // Cleanup
            _currentProcess.Free(copyPtr);
        }
Beispiel #2
0
        private void DumpPhysics(Game game, out AdventurePhysics[] physics)
        {
            switch (game)
            {
            case Game.Sadx:
                DumpPhysics <SadxCharacter>(out physics);
                break;

            case Game.Sa2b:
                DumpPhysics <Sa2bCharacter>(out physics);
                break;

            case Game.Heroes:
                DumpPhysics <HeroesCharacter>(out physics);
                break;

            default:
                physics = new AdventurePhysics[0];
                break;
            }
        }
 public CharacterAdventurePhysicsPair(AllCharacters character, AdventurePhysics physics)
 {
     Character = character;
     Physics   = physics;
 }