Ejemplo n.º 1
0
        private static void InitiateLegacy(GameSession gameSession)
        {
            var player = gameSession.Player;
            var client = gameSession.Client;

            if (player.UsingNewClient)
            {
                client.Send(PacketBuilder.BigMessage("beta_splash_text", true).Bytes);
            }
            else
            {
                client.Send(CameraLockToHeroCommand.write());
                client.Send(
                    PacketBuilder.LegacyModule("0|A|" + ServerCommands.SERVER_VERSION + "|3.0.1 / Bug-less").Bytes);
                client.Send(PacketBuilder.BigMessage("beta_splash_text").Bytes);

                client.Send(PacketBuilder.LegacyModule("0|A|ITM|" + player.GetConsumablesPacket()).Bytes);
                client.Send(PacketBuilder.LegacyModule("0|A|BK|" + player.BootyKeys[0]).Bytes);  //green booty
                client.Send(PacketBuilder.LegacyModule("0|A|BKR|" + player.BootyKeys[1]).Bytes); //red booty
                client.Send(PacketBuilder.LegacyModule("0|A|BKB|" + player.BootyKeys[2]).Bytes); //blue booty
                client.Send(PacketBuilder.LegacyModule("0|TR").Bytes);
                client.Send(PacketBuilder.LegacyModule("0|A|CC|" + player.CurrentConfig).Bytes);
                client.Send(PacketBuilder.LegacyModule("0|ps|nüscht|").Bytes);
                client.Send(PacketBuilder.LegacyModule("0|ps|blk|0").Bytes);
                client.Send(PacketBuilder.LegacyModule("0|n|w|-1").Bytes); //enemy warning
                client.Send(
                    PacketBuilder.LegacyModule(
                        "0|g|a|b,1000,1,10000.0,C,2,500.0,U,3,1000.0,U,5,1000.0,U|r,100,1,10000,C,2,50000,C,3,500.0,U,4,700.0,").Bytes);
                //client.Send(PacketBuilder.LegacyModule("0|UI|MM|SM|0|6000|2000|1"));
            }
        }
        private static void MessageHandler(Character character, int roomId, string message)
        {
            //if (character is Moderator) ModeratorMessage(character,roomId, message);
            var session = ServerManager.GetGameSession(character.Id);
            if (message.Contains(' '))
            {
                var splitMessage = message.Split(' ');
                switch (splitMessage[0])
                {
                    case "/cam":
                        if (session == null) return;
                        switch (splitMessage[1])
                        {
                            case "cords":
                                session.Client.Send(CameraLockToCoordinatesCommand.write(int.Parse(splitMessage[2]) * 100, int.Parse(splitMessage[3]) * 100, 1));
                                break;
                            case "selected":
                                session.Client.Send(CameraLockToShipCommand.write(session.Player.Selected.Id, 1, 1));
                                break;
                            case "hero":
                                session.Client.Send(CameraLockToHeroCommand.write());
                                break;
                            default:
                                Send(character, "cords: x/y; selected; hero");
                                break;
                        }
                        break;
                    case "/send":
                        if (session == null) return;

                        var replaced = message.Replace("ATRIBUTE_SEPERATOR", "|");

                        session.Client.Send(LegacyModule.write(replaced));
                        break;
                    case "/global":
                        if (character.IsRcon())
                        {
                            byte[] packet;
                            string cutMessage;
                            switch (splitMessage[1])
                            {
                                case "big":
                                    cutMessage = message.Replace("/global big ", "");
                                    packet = Net.netty.PacketBuilder.BigMessage(cutMessage);
                                    break;
                                default:
                                    cutMessage = message.Replace("/global ", "");
                                    packet = Net.netty.PacketBuilder.LegacyModule("0|A|STD|" + cutMessage);
                                    break;
                            }
                            foreach (var gameClient in ServerManager.GameSessions.Values)
                            {
                                gameClient.Client.Send(packet);
                            }
                        }
                        break;
                    case "/rcon":
                        switch (splitMessage[1])
                        {
                            case "login":
                                if (splitMessage[2] != ServerManager.RCON_PW)
                                    break;

                                character.Rcon = true;
                                MessagesController.Send(character, "Logged in as RCON");
                                break;
                            case "auth":
                                if (character.IsRcon())
                                {
                                    if (splitMessage[2] == null)
                                    {
                                        Send(character, "/rcon auth [edit/delete]");
                                        break;
                                    }
                                    switch (splitMessage[2])
                                    {
                                        case "edit":
                                            Send(character, "Not done yet.");
                                            break;
                                        case "delete":
                                            File.Delete(Directory.GetCurrentDirectory() + "/p.auth");
                                            File.Delete(Directory.GetCurrentDirectory() + "/k.auth");
                                            Send(character, "Successfully deleted auth files.");
                                            break;
                                    }
                                }
                                break;
                            case "lock":
                                if (character.IsRcon())
                                {
                                    if (!ServerManager.RCON_LOGIN_ONLY)
                                    {
                                        Send(character, "Locking the server to RCONs only.");
                                        ServerManager.RCON_LOGIN_ONLY = true;
                                        break;
                                    }

                                    Send(character, "Unlocking..");
                                    ServerManager.RCON_LOGIN_ONLY = false;

                                    foreach (var entry in ServerManager.GameSessions)
                                    {
                                        var chatEntry = ServerManager.GetChatSession(entry.Key);
                                        if (chatEntry != null)
                                            if (chatEntry.Player.Rcon)
                                                return;

                                        entry.Value.CloseSession();
                                    }
                                }
                                break;
                            case "restart":
                                if (character.IsRcon())
                                {
                                    Send(character, "Server is restarting...");
                                    Process.Start(Directory.GetCurrentDirectory() + "/NettyRestarter.exe");
                                }
                                break;
                            case "exit":
                                if (character.IsRcon())
                                    Environment.Exit(0);
                                break;
                        }
                        break;
                    default:
                        //Console.WriteLine(splitMessage[0]);
                        break;
                }

            }
            else
            {
                switch (message)
                {
                    case "/online":
                        Send(character, "Currently there are " + ServerManager.ChatSessions.Count + " users connected to chat.");
                        break;
                }
            }
        }