Ejemplo n.º 1
0
        /// <summary>
        /// Gets the player index of an individual pointer.
        /// </summary>
        /// <param name="ptr">The pointer to the player structure.</param>
        /// <returns>Returns the player index based off of the player pointer. Otherwise -1 if not found.</returns>
        public static unsafe int GetPlayerIndex(Structures.Gameplay.Player *ptr)
        {
            for (int x = 0; x < Players.Count; x++)
            {
                if (ptr == &Players.Pointer[x])
                {
                    return(x);
                }
            }

            return(-1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the player index of an individual pointer by checking if the pointer falls in
        /// the range between the start and end of any of the player structs.
        /// </summary>
        /// <param name="ptr">The pointer to somewhere inside a valid player structure.</param>
        /// <param name="result">Pointer to the player struct this mid struct ptr belongs to.</param>
        /// <returns>Returns the player index based off of the player pointer. Otherwise -1 if not found.</returns>
        public static unsafe int GetPlayerIndexFromMidStructPtr(void *ptr, out Structures.Gameplay.Player *result)
        {
            for (int x = 0; x < Players.Count; x++)
            {
                var current = &Players.Pointer[x];
                var next    = current + 1;

                if (ptr >= current && ptr < next)
                {
                    result = current;
                    return(x);
                }
            }

            result = default;
            return(-1);
        }