Exemple #1
0
        internal static unsafe void InitializePlugin(PluginHeader *plugin)
        {
            _onConnected             = OnConnected;
            _onDisconnected          = OnDisconnected;
            _onReceive               = OnPacketReceive;
            _onSend                  = OnPacketSend;
            _onPlayerPositionChanged = OnPlayerPositionChanged;
            _onClientClosing         = OnClientClosing;
            _onHotkeyPressed         = OnHotkeyPressed;
            _onMouse                 = OnMouse;
            _onTick                  = OnTick;
            WindowHandle             = plugin->HWND;

            plugin->OnConnected             = Marshal.GetFunctionPointerForDelegate(_onConnected);
            plugin->OnDisconnected          = Marshal.GetFunctionPointerForDelegate(_onDisconnected);
            plugin->OnRecv                  = Marshal.GetFunctionPointerForDelegate(_onReceive);
            plugin->OnSend                  = Marshal.GetFunctionPointerForDelegate(_onSend);
            plugin->OnPlayerPositionChanged = Marshal.GetFunctionPointerForDelegate(_onPlayerPositionChanged);
            plugin->OnClientClosing         = Marshal.GetFunctionPointerForDelegate(_onClientClosing);
            plugin->OnHotkeyPressed         = Marshal.GetFunctionPointerForDelegate(_onHotkeyPressed);
            plugin->OnMouse                 = Marshal.GetFunctionPointerForDelegate(_onMouse);
            plugin->Tick = Marshal.GetFunctionPointerForDelegate(_onTick);

            _getPacketLength = Marshal.GetDelegateForFunctionPointer <OnGetPacketLength>(plugin->GetPacketLength);
            _getUOFilePath   = Marshal.GetDelegateForFunctionPointer <OnGetUOFilePath>(plugin->GetUOFilePath);
            _sendToClient    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Recv);
            _sendToServer    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Send);
            _requestMove     = Marshal.GetDelegateForFunctionPointer <RequestMove>(plugin->RequestMove);
            _setTitle        = Marshal.GetDelegateForFunctionPointer <OnSetTitle>(plugin->SetTitle);

            ClientPath    = _getUOFilePath();
            ClientVersion = new Version((byte)(plugin->ClientVersion >> 24), (byte)(plugin->ClientVersion >> 16),
                                        (byte)(plugin->ClientVersion >> 8), (byte)plugin->ClientVersion);

            if (!Path.IsPathRooted(ClientPath))
            {
                ClientPath = Path.GetFullPath(ClientPath);
            }

            Art.Initialize(ClientPath);
            Hues.Initialize(ClientPath);
            Cliloc.Initialize(ClientPath);
            Skills.Initialize(ClientPath);
            Speech.Initialize(ClientPath);
            TileData.Initialize(ClientPath);
            Statics.Initialize(ClientPath);
            MapInfo.Initialize(ClientPath);

            ClassicAssembly = AppDomain.CurrentDomain.GetAssemblies()
                              .FirstOrDefault(a => a.FullName.StartsWith("ClassicUO,"));

            InitializeExtensions();
        }
Exemple #2
0
        internal static unsafe void InitializePlugin(PluginHeader *plugin)
        {
            _onConnected             = OnConnected;
            _onDisconnected          = OnDisconnected;
            _onReceive               = OnPacketReceive;
            _onSend                  = OnPacketSend;
            _onPlayerPositionChanged = OnPlayerPositionChanged;
            _onClientClosing         = OnClientClosing;
            _onHotkeyPressed         = OnHotkeyPressed;
            _onMouse                 = OnMouse;
            _hWnd = plugin->HWND;

            plugin->OnConnected             = Marshal.GetFunctionPointerForDelegate(_onConnected);
            plugin->OnDisconnected          = Marshal.GetFunctionPointerForDelegate(_onDisconnected);
            plugin->OnRecv                  = Marshal.GetFunctionPointerForDelegate(_onReceive);
            plugin->OnSend                  = Marshal.GetFunctionPointerForDelegate(_onSend);
            plugin->OnPlayerPositionChanged = Marshal.GetFunctionPointerForDelegate(_onPlayerPositionChanged);
            plugin->OnClientClosing         = Marshal.GetFunctionPointerForDelegate(_onClientClosing);
            plugin->OnHotkeyPressed         = Marshal.GetFunctionPointerForDelegate(_onHotkeyPressed);
            plugin->OnMouse                 = Marshal.GetFunctionPointerForDelegate(_onMouse);

            _getPacketLength = Marshal.GetDelegateForFunctionPointer <OnGetPacketLength>(plugin->GetPacketLength);
            _getUOFilePath   = Marshal.GetDelegateForFunctionPointer <OnGetUOFilePath>(plugin->GetUOFilePath);
            _sendToClient    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Recv);
            _sendToServer    = Marshal.GetDelegateForFunctionPointer <OnPacketSendRecv>(plugin->Send);
            _requestMove     = Marshal.GetDelegateForFunctionPointer <RequestMove>(plugin->RequestMove);

            ClientPath = _getUOFilePath();

            if (!Path.IsPathRooted(ClientPath))
            {
                ClientPath = Path.GetFullPath(ClientPath);
            }

            Art.Initialize(ClientPath);
            Hues.Initialize(ClientPath);
            Cliloc.Initialize(ClientPath);
            Skills.Initialize(ClientPath);
            Speech.Initialize(ClientPath);
            TileData.Initialize(ClientPath);
        }