Example #1
0
        /// <summary>
        /// Opens the in-game map with a flag on the location of the parameter.
        /// </summary>
        /// <param name="mapLink">Link to the map to be opened.</param>
        /// <returns>True if there were no errors and it could open the map.</returns>
        public bool OpenMapWithMapLink(MapLinkPayload mapLink)
        {
            var uiObjectPtr = this.getUIObject();

            if (uiObjectPtr.Equals(IntPtr.Zero))
            {
                Log.Error("OpenMapWithMapLink: Null pointer returned from getUIObject()");
                return(false);
            }

            this.getUIMapObject = this.address.GetVirtualFunction <GetUIMapObjectDelegate>(uiObjectPtr, 0, 8);

            var uiMapObjectPtr = this.getUIMapObject(uiObjectPtr);

            if (uiMapObjectPtr.Equals(IntPtr.Zero))
            {
                Log.Error("OpenMapWithMapLink: Null pointer returned from GetUIMapObject()");
                return(false);
            }

            this.openMapWithFlag = this.address.GetVirtualFunction <OpenMapWithFlagDelegate>(uiMapObjectPtr, 0, 63);

            var mapLinkString = mapLink.DataString;

            Log.Debug($"OpenMapWithMapLink: Opening Map Link: {mapLinkString}");

            return(this.openMapWithFlag(uiMapObjectPtr, mapLinkString));
        }
Example #2
0
        public bool OpenMapWithMapLink(MapLinkPayload mapLink)
        {
            var uiObjectPtr = getUIObject();

            if (uiObjectPtr.Equals(IntPtr.Zero))
            {
                Log.Error("OpenMapWithMapLink: Null pointer returned from getUIObject()");
                return(false);
            }

            getUIMapObject =
                Address.GetVirtualFunction <GetUIMapObjectDelegate>(uiObjectPtr, 0, 8);


            var uiMapObjectPtr = this.getUIMapObject(uiObjectPtr);

            if (uiMapObjectPtr.Equals(IntPtr.Zero))
            {
                Log.Error("OpenMapWithMapLink: Null pointer returned from GetUIMapObject()");
                return(false);
            }

            openMapWithFlag =
                Address.GetVirtualFunction <OpenMapWithFlagDelegate>(uiMapObjectPtr, 0, 63);

            var mapLinkString =
                $"m:{mapLink.TerritoryTypeId},{mapLink.MapId},{unchecked((int)mapLink.RawX)},{unchecked((int)mapLink.RawY)}";

            Log.Debug($"OpenMapWithMapLink: Opening Map Link: {mapLinkString}");

            return(this.openMapWithFlag(uiMapObjectPtr, mapLinkString));
        }