Exemplo n.º 1
0
        public static void LoadDataBuffers()
        {
            //DisabledQuikEdit();

            Stopwatch allData = new Stopwatch();

            allData.Start();
            int count = 0;

            count += DataProvider.LoadEtc(@".\NX\Etc.nx");

            ManualResetEvent[] handles = new ManualResetEvent[6];
            for (int i = 0; i < handles.Count(); i++)
            {
                handles[i] = new ManualResetEvent(false);
            }

            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadMobs), handles[2]);
            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadEquips), handles[0]);
            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadItems), handles[1]);
            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadSkills), handles[3]);
            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadQuests), handles[4]);

            handles[2].WaitOne();                                                 //Wait for mob thread to finish
            ThreadPool.QueueUserWorkItem(new WaitCallback(LoadMaps), handles[5]); //Map needs mob wz info, so wait until mobs finished

            WaitHandle.WaitAll(handles);
            //Always do strings after the other WZs!
            count += DataProvider.LoadStrings(@".\NX\String.nx");
            ServerConsole.Info("{0} Strings loaded", count);

            ServerConsole.Info("Finished loading .NX in {0} ms", (int)allData.ElapsedMilliseconds);

            Stopwatch sw = new Stopwatch();

            sw.Start();
            count = DataProvider.LoadScripts();
            ServerConsole.Info("{0} Scripts loaded in {1} ms", count, (int)sw.ElapsedMilliseconds);
            sw.Reset();

            /*
             * sw.Start();
             * Count = LoadCashShopItems();
             * ServerConsole.Info(String.Format("{0} CashShop items loaded in {1} ms", Count, (int)sw.ElapsedMilliseconds));
             * sw.Reset();
             */
            sw.Start();
            count  = AdminCommands.ReloadCommands();
            count += GMCommands.ReloadCommands();
            count += PlayerCommands.ReloadCommands();
            count += DonorCommands.ReloadCommands();
            ServerConsole.Info("{0} Commands loaded in {1} ms", count, (int)sw.ElapsedMilliseconds);
            sw.Reset();
            LoadMonsterDrops();
            allData.Stop();
            ServerConsole.Info("All data loaded in {0} ms", (int)allData.ElapsedMilliseconds);
            ServerConsole.Info("==============================================");
        }
Exemplo n.º 2
0
        protected override void HandleChatAtServer(LiteNetLibMessageHandler messageHandler)
        {
            var message = FillChatChannelId(messageHandler.ReadMessage <ChatMessage>());

            // Local chat will processes immediately, not have to be sent to chat server
            if (message.channel == ChatChannel.Local &&
                !GMCommands.IsGMCommand(message.message))
            {
                ReadChatMessage(message);
                return;
            }
            // Send chat message to chat server, for MMO mode chat message handling by chat server
            if (ChatNetworkManager.IsClientConnected)
            {
                ChatNetworkManager.Client.SendEnterChat(null, MMOMessageTypes.Chat, message.channel, message.message, message.sender, message.receiver, message.channelId);
            }
        }
        private void HandleChatAtServer(LiteNetLibMessageHandler messageHandler)
        {
            var connectionId = messageHandler.connectionId;
            var message      = messageHandler.ReadMessage <ChatMessage>();

            if (LogInfo)
            {
                Debug.Log("Handle chat: " + message.channel + " sender: " + message.sender + " receiver: " + message.receiver + " message: " + message.message);
            }
            switch (message.channel)
            {
            case ChatChannel.Global:
                if (GMCommands.IsGMCommand(message.message))
                {
                    HandleGMCommand(message.sender, message.message);
                }
                else
                {
                    ServerSendPacketToAllConnections(SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                }
                break;

            case ChatChannel.Party:
            case ChatChannel.Guild:
                // Send message to all map servers, let's map servers filter messages
                ServerSendPacketToAllConnections(SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                break;

            case ChatChannel.Whisper:
                long senderConnectionId   = 0;
                long receiverConnectionId = 0;
                // Send message to map server which have the character
                if (!string.IsNullOrEmpty(message.sender) &&
                    connectionIdsByCharacterName.TryGetValue(message.sender, out senderConnectionId))
                {
                    ServerSendPacket(senderConnectionId, SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                }
                if (!string.IsNullOrEmpty(message.receiver) &&
                    connectionIdsByCharacterName.TryGetValue(message.receiver, out receiverConnectionId) &&
                    (receiverConnectionId != senderConnectionId))
                {
                    ServerSendPacket(receiverConnectionId, SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                }
                break;
            }
        }
        private void HandleGMCommand(string sender, string command)
        {
            if (string.IsNullOrEmpty(command))
            {
                return;
            }

            var splited    = command.Split(' ');
            var commandKey = splited[0];

            if (GMCommands.IsSplitedLengthValid(commandKey, splited.Length))
            {
                string receiver;
                long   receiverConnectionId;
                if (commandKey.Equals(GMCommands.GiveGold) ||
                    commandKey.Equals(GMCommands.GiveItem))
                {
                    receiver = splited[1];
                    // Send message to map server which have the character
                    if (!string.IsNullOrEmpty(receiver) &&
                        connectionIdsByCharacterName.TryGetValue(receiver, out receiverConnectionId))
                    {
                        var message = new ChatMessage();
                        message.channel = ChatChannel.Global;
                        message.message = command;
                        ServerSendPacket(receiverConnectionId, SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                    }
                }
                else
                {
                    receiver = sender;
                    // Send message to map server which have the character
                    if (!string.IsNullOrEmpty(receiver) &&
                        connectionIdsByCharacterName.TryGetValue(receiver, out receiverConnectionId))
                    {
                        var message = new ChatMessage();
                        message.channel = ChatChannel.Global;
                        message.message = command;
                        ServerSendPacket(receiverConnectionId, SendOptions.ReliableOrdered, MMOMessageTypes.Chat, message);
                    }
                }
            }
        }
Exemplo n.º 5
0
 public void EventCallBackHandler(AsyncDataItem item)
 {
     try
     {
         int      eventType = (int)item.EventType;
         object[] args      = item.Args;
         int      num       = eventType;
         if (num != 39)
         {
             if (num == 9997)
             {
                 if (GMCommands.EnableGMSetAllServerTime && item.Args.Length == 4)
                 {
                     string[] a = new string[item.Args.Length];
                     for (int i = 0; i < a.Length; i++)
                     {
                         a[i] = (item.Args[i] as string);
                         if (string.IsNullOrEmpty(a[i]))
                         {
                             return;
                         }
                     }
                     if (a[0] == "-settime")
                     {
                         GMCommands.GMSetTime(null, a, false);
                     }
                 }
             }
         }
         else
         {
             RebornManager.getInstance().OnChatListData(args[0] as byte[]);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
 }
Exemplo n.º 6
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            int    tickCount = pr.ReadInt();
            string message   = pr.ReadMapleString();
            byte   show      = pr.ReadByte();

            ServerConsole.Info(c.Account.Character.Name + ": " + message);

            if (message[0] == '@')
            {
                if (PlayerCommands.ProcessCommand(message.Substring(1).Split(' '), c))
                {
                    return;
                }
            }
            else if (message[0] == '!')
            {
                if (c.Account.IsGM)
                {
                    string[] split = message.Substring(1).Split(' ');
                    if (GMCommands.ProcessCommand(split, c))
                    {
                        return;
                    }
                    if (c.Account.IsAdmin)
                    {
                        if (AdminCommands.ProcessCommand(split, c))
                        {
                            return;
                        }
                        else
                        {
                            c.Account.Character.SendBlueMessage("Unrecognized Admin command");
                            return;
                        }
                    }
                    else
                    {
                        c.Account.Character.SendBlueMessage("Unrecognized GM command");
                        return;
                    }
                }
            }
            else if (message[0] == '#')
            {
                if (c.Account.IsGM || c.Account.IsDonor)
                {
                    string[] split = message.Substring(1).Split(' ');
                    if (DonorCommands.ProcessCommand(split, c))
                    {
                        return;
                    }
                    else
                    {
                        c.Account.Character.SendBlueMessage("Unrecognized Donor command");
                        return;
                    }
                }
            }

            PacketWriter packet = PlayerChatPacket(c.Account.Character.Id, message, show, c.Account.IsGM);

            c.Account.Character.Map.BroadcastPacket(packet);
        }
Exemplo n.º 7
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                switch (num)
                {
                case 0:
                case 1:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                        }
                    }
                    break;

                case 2:
                case 4:
                case 5:
                    break;

                case 3:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            YongZheZhanChangFuBenData fuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                            if (fuBenData != null && fuBenData.State == GameFuBenState.Start)
                            {
                                KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                {
                                    RoleId   = kuaFuRoleData.RoleId,
                                    GameType = kuaFuRoleData.GameType,
                                    GameId   = (long)kuaFuRoleData.GameId,
                                    EndTicks = kuaFuRoleData.StateEndTicks
                                };
                                kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                KuaFuServerInfo kuaFuServerInfo;
                                if (KuaFuManager.getInstance().TryGetValue(fuBenData.ServerId, out kuaFuServerInfo))
                                {
                                    kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                    kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                }
                                GameTypes gameType = (GameTypes)kuaFuRoleData.GameType;
                                switch (gameType)
                                {
                                case GameTypes.YongZheZhanChang:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 27);
                                    break;

                                case GameTypes.KuaFuBoss:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 31);
                                    break;

                                default:
                                    if (gameType == GameTypes.KingOfBattle)
                                    {
                                        this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 39);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    break;

                case 6:
                    if (args.Length == 1)
                    {
                        LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), 35);
                    }
                    break;

                case 7:
                    if (args.Length == 1)
                    {
                        LangHunLingYuCityDataEx data2 = args[0] as LangHunLingYuCityDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data2), 35);
                    }
                    break;

                case 8:
                    if (args.Length == 1)
                    {
                        Dictionary <int, List <int> > data3 = args[0] as Dictionary <int, List <int> >;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data3), 35);
                    }
                    break;

                case 9:
                    if (args.Length == 1)
                    {
                        List <LangHunLingYuKingHist> data4 = args[0] as List <LangHunLingYuKingHist>;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data4), 35);
                    }
                    break;

                case 10:
                    if (args.Length == 2)
                    {
                        int rid         = (int)args[0];
                        int admirecount = (int)args[1];
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount), 35);
                    }
                    break;

                default:
                    if (num == 9997)
                    {
                        if (GMCommands.EnableGMSetAllServerTime && item.Args.Length == 4)
                        {
                            string[] a = new string[item.Args.Length];
                            for (int i = 0; i < a.Length; i++)
                            {
                                a[i] = (item.Args[i] as string);
                                if (string.IsNullOrEmpty(a[i]))
                                {
                                    return;
                                }
                            }
                            if (a[0] == "-settime")
                            {
                                GMCommands.GMSetTime(null, a, false);
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }