static public void CMSG_AUTHENTICATE(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;

            UInt32 Sequence = packet.GetUint32();
            string Username = packet.GetString();
            string Token    = packet.GetString();

            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

            PacketOut Out = new PacketOut((byte)Opcodes.SMSG_AUTHENTICATE_RESPONSE);

            Out.WriteUInt32(Sequence);
            Out.WriteUInt16((UInt16)Result);
            Out.WriteByte(0);

            cclient.SendTCPCuted(Out);

            if (Result != AuthResult.AUTH_SUCCESS)
            {
                cclient.Disconnect();
            }
            else
            {
                cclient.Username = Username;
                cclient.Token    = Token;
            }
        }
Пример #2
0
        public static void F_DELETE_NAME(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            string CharName = packet.GetString(30);
            string UserName = packet.GetString(20);

            byte Bad = 0;

            if (CharName.Length < 3 || CharMgr.NameIsUsed(CharName) || !System.Text.RegularExpressions.Regex.IsMatch(CharName, @"^[a-zA-Z]+$"))
            {
                Bad = 1;
            }

            Log.Debug("F_DELETE_NAME", "Bad=" + Bad + ",Name=" + CharName);

            PacketOut Out = new PacketOut((byte)Opcodes.F_CHECK_NAME, 54);

            Out.FillString(CharName, 30);
            Out.FillString(UserName, 20);
            Out.WriteByte(Bad);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);
            cclient.SendPacket(Out);
        }
Пример #3
0
        static public void F_CONNECT(Connection conn, PacketIn packet)
        {
            Log.Debug("F_CONNECT");
            packet.Skip(8);
            UInt32 Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            Log.Debug("New Connection : " + Token + ",User="******"Emulator");
            Out.WriteByte(0);
            Out.WriteUInt16(0);
            conn.SendTCP(Out);
        }
Пример #4
0
        static public void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            UInt16 SID;
            byte   unk1, serverID, characterSlot;

            SID      = packet.GetUint16();
            unk1     = packet.GetUint8();
            serverID = packet.GetUint8();
            string CharName = packet.GetString(24);

            packet.Skip(2);
            string Language = packet.GetString(2);

            packet.Skip(4);
            characterSlot = packet.GetUint8();

            Log.Success("F_PLAYER_ENTER_FULL", "Entrer en jeu de : " + CharName + ",Slot=" + characterSlot);

            if (Program.Rm.RealmId != serverID)
            {
                cclient.Disconnect();
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN);
                Out.WriteUInt16R((ushort)cclient.Id);
                cclient.SendTCP(Out);
            }
        }
Пример #5
0
        static public void F_DELETE_NAME(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            string CharName = packet.GetString(30);
            string UserName = packet.GetString(20);

            byte Bad = 0;

            if (CharName.Length <= 0 || CharMgr.NameIsUsed(CharName))
            {
                Bad = 1;
            }

            Log.Debug("F_DELETE_NAME", "Bad=" + Bad + ",Name=" + CharName);

            PacketOut Out = new PacketOut((byte)Opcodes.F_CHECK_NAME);

            Out.WriteString(CharName, 30);
            Out.WriteString(UserName, 20);
            Out.WriteByte(Bad);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(0);
            cclient.SendTCP(Out);
        }
Пример #6
0
        public static Dictionary <string, object> readProfile(ref PacketIn packet)
        {
            Dictionary <string, object> computerProfile = new Dictionary <string, object>();
            int count = packet.GetUint8();

            for (int i = 0; i < count; i++)
            {
                string key = packet.GetString();

                switch (packet.GetUint8())
                {
                case 0:     // string
                {
                    computerProfile[key] = packet.GetString();
                }
                break;

                case 1:     // list
                {
                    computerProfile[key] = readProfile(ref packet);
                }
                break;
                }
            }


            return(computerProfile);
        }
Пример #7
0
        static public void F_CONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(8);
            UInt32 Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

            if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username);
                cclient.Disconnect();
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect();
                }
                else
                {
                    //Log.Success("F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect();
                    }

                    {
                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteUInt32(0);// this was 1// setting this at 0 removes the server population box
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }
        static public void F_CONNECT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(8);
            UInt32 Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            Log.Debug("Connect", "Connexion avec : " + Token + ",User="******"F_CONNECT", "MeId=" + cclient.Id);

                    GameClient Other = (cclient.Server as TCPServer).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect();
                    }

                    PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED);
                    Out.WriteUInt32(0);
                    Out.WriteUInt32(Tag);
                    Out.WriteByte(Program.Rm.RealmId);
                    Out.WriteUInt32(0);
                    Out.WritePascalString(Username);
                    Out.WritePascalString(Program.Rm.Name);
                    Out.WriteByte(0);
                    Out.WriteUInt16(0);
                    cclient.SendTCP(Out);
                }
            }
        }
Пример #9
0
        public static void CL_SET_PATCH_NOTES(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;
            string notes   = packet.GetString();

            cclient.OnSetPatchNotes(notes);
        }
Пример #10
0
        static public void CL_START(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;

            string Username = packet.GetString();
            UInt32 Len      = packet.GetUint32();

            byte[] Password = packet.Read((int)Len);

            bool result = Program.AcctMgr.CheckAccount(Username, Password);

            Log.Debug("CL_START", "Launching of client : " + Username + " " + result);

            PacketOut Out = new PacketOut((byte)Opcodes.LCR_START);

            if (result == true)
            {
                Out.WriteByte(0);
                Out.WriteString(Program.AcctMgr.GenerateToken(Username));
            }
            else
            {
                Out.WriteByte(1);
            }

            cclient.SendPacket(Out);
        }
Пример #11
0
        public static void CL_CREATE(BaseClient client, PacketIn packet)
        {
            Client cclient = (Client)client;

            string username = packet.GetString();
            string password = packet.GetString();

            Log.Debug("CL_CREATE", $"CL_CREATE Create Request : {username} {password} ");

            CreteAccountResult result = CreteAccountResult.ACCOUNT_BANNED;

            PacketOut Out = new PacketOut((byte)Opcodes.LCR_CREATE);

            string ip = client.GetIp().Split(':')[0];

            // Check Ip Ban
            if (Program.AcctMgr.CheckIp(ip))
            {
                Log.Debug("CL_CREATE", "Create Account Request : " + username + " " + result);

                if (Program.AcctMgr.CreateAccount(username, password, 1, ip))
                {
                    result = CreteAccountResult.ACCOUNT_NAME_SUCCESS;
                    Log.Debug("CL_CREATE", "Create Account Request SUCCESS");
                }
                else
                {
                    Log.Debug("CL_CREATE", "Create Account Request BUSY");
                    result = CreteAccountResult.ACCOUNT_NAME_BUSY;
                }


                Out.WriteByte((byte)result);
            }
            else
            {
                Out.WriteByte((byte)result); // Banned
            }
            Log.Debug("CL_CREATE", $"Writing response to Client {Out} ");
            cclient.SendPacketNoBlock(Out);
        }
Пример #12
0
        public static void CL_START(BaseClient client, PacketIn packet)
        {
            Client cclient = (Client)client;

            string username = packet.GetString();
            string password = packet.GetString();

            LoginResult result = LoginResult.LOGIN_BANNED;

            PacketOut Out = new PacketOut((byte)Opcodes.LCR_START);

            string ip = client.GetIp().Split(':')[0];

            // Check Ip Ban
            if (Program.AcctMgr.CheckIp(ip))
            {
                result = Program.AcctMgr.CheckAccount(username, password, ip);
                Log.Debug("CL_START", "Authentication Request : " + username + " " + result);

                Out.WriteByte((byte)result);

                if (result == LoginResult.LOGIN_SUCCESS)
                {
                    var token = Program.AcctMgr.GenerateToken(username);
                    Log.Debug("CL_START", "Sending token to client : " + username + " token : " + token);
                    Out.WriteString(token);
                }
            }
            else
            {
                Out.WriteByte((byte)result); // Banned
            }
            cclient.SendPacketNoBlock(Out);

#if !DEBUG
            if (result == LoginResult.LOGIN_SUCCESS && Program.Config.SeverOnConnect)
            {
                cclient.Disconnect("Transaction complete");
            }
#endif
        }
Пример #13
0
        public static void CL_LOGIN(BaseClient client, PacketIn packet)
        {
            Client cclient = client as Client;

            var username = packet.GetString16();
            var hashLen  = packet.GetUint16();
            var hash     = new byte[hashLen];

            packet.Read(hash, 0, hashLen);
            var installID = packet.GetString();

            cclient.Login(username, hash, installID);
        }
Пример #14
0
        static public void F_RENAME_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            packet.Skip(3);

            string OldName = packet.GetString(24);
            string NewName = packet.GetString(24);

            Log.Success("F_RENAME_CHARACTER", "Renaming: '" + OldName + "' To: '" + NewName + "'");

            if (NewName.Length > 2 && !CharMgr.NameIsUsed(NewName))
            {
                Character Char = CharMgr.GetCharacter(OldName);

                if (Char == null || Char.AccountId != cclient._Account.AccountId)
                {
                    Log.Error("CharacterRename", "Hack: Tried to rename character which account dosen't own");
                    cclient.Disconnect();
                    return;
                }

                Char.Name = NewName;
                CharMgr.Database.SaveObject(Char);

                // Wrong response? Perhaps needs to send F_REQUEST_CHAR_RESPONSE again.
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
            else
            {
                // Wrong response?
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
Пример #15
0
        public static void F_TEXT(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (cclient.Plr == null)
            {
                return;
            }

            byte   Unk  = packet.GetUint8();
            string Text = packet.GetString((int)(packet.Length - packet.Position));

            CommandMgr.HandleText(cclient.Plr, Text);
        }
        public static void F_PLAYER_ENTER_FULL(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            ushort SID;
            byte   unk1, serverID, characterSlot;

            SID      = packet.GetUint16();
            unk1     = packet.GetUint8();
            serverID = packet.GetUint8();
            string CharName = packet.GetString(24);

            packet.Skip(2);
            string Language = packet.GetString(2);

            packet.Skip(4);
            characterSlot = packet.GetUint8();

            Log.Debug("F_PLAYER_ENTER_FULL", "Enter the game : " + CharName + ",Slot=" + characterSlot);

            if (Program.Rm.RealmId != serverID)
            {
                cclient.Disconnect("Requested realm ID does not match this server's ID");
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.S_PID_ASSIGN, 2);
                Out.WriteUInt16R((ushort)cclient.Id);
                cclient.SendPacket(Out);

                if (cclient.Plr != null)
                {
                    cclient.Plr.DisconnectType = Player.EDisconnectType.Unclean;
                }
            }
        }
Пример #17
0
        public static void F_GUILD_COMMAND(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            packet.Skip(2);
            UInt16 Target      = packet.GetUint16(); // ?
            uint   CharacterId = packet.GetUint32();
            byte   State       = packet.GetUint8();

            //Log.Info("state ",""+State);
            switch (State)
            {
            case 1:     // Accepted Invite
            {
                if (Plr.GldInterface.invitedTo == null)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILD_INVITE_ERR_NOINVITE);
                    return;
                }

                Plr.GldInterface.Guild     = Plr.GldInterface.invitedTo;
                Plr.GldInterface.invitedTo = null;

                Plr.GldInterface.Guild.JoinGuild(Plr);
            } break;

            case 2:     // Declined Invite
            {
                Plr.GldInterface.invitedTo = null;
            } break;

            case 3:     // Leave Guild
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                if (Plr.GldInterface.Guild.Info.LeaderId == Plr.CharacterId)
                {
                    // wrong message
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_ALLIANCE_INVITE_ERROR);
                    return;
                }

                Guild_member GldMem = Plr.GldInterface.Guild.Info.Members[Plr.CharacterId];

                Plr.GldInterface.Guild.LeaveGuild(GldMem, false);
            } break;

            case 5:     // Promote
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                Plr.GldInterface.Guild.PromoteMember(Plr, CharacterId);
            } break;

            case 6:     // Demote
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                Plr.GldInterface.Guild.DemoteMember(Plr, CharacterId);
            } break;

            case 7:     // Assign as leader
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                Plr.GldInterface.Guild.AssignLeader(Plr, CharacterId);
            } break;

            case 9:     // Guild NPC
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_INTERACT_RESPONSE, 4);
                Out.WriteByte(0x0e);
                Out.WriteByte(1);
                Out.WriteByte(1);
                Out.WriteByte(0);
                Plr.SendPacket(Out);
                Log.Info("GUILd", "CREATE");
            } break;

            case 10:     // Create guild
            {
                packet.Skip(1);
                String name = packet.GetStringToZero();
                if (Plr.GldInterface.IsInGuild())
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_INVALIDREQ_GUILDED);
                }
                else if (Guild.GetGuild(name) != null)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_BAD_NAME);
                }
                else if (Plr.GmLevel > 0)
                {
                    new GuildInvitation(Plr, name);
                }
                else if (Plr.WorldGroup == null)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_INVALIDREQ_NOTGROUPED);
                }
                else if (Plr.WorldGroup.GetLeader() != Plr)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_INVALIDREQ_NOTLEADER);
                }
                else if (!Plr.WorldGroup.HasMaxMembers)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_INVALIDREQ_NUMPLAYERS);
                }
                else
                {
                    foreach (Player groupMember in Plr.WorldGroup.GetPlayerList())
                    {
                        if (groupMember.GldInterface.IsInGuild())
                        {
                            Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILDNPC_INVALIDREQ_GUILDED);
                            return;
                        }
                    }

                    new GuildInvitation(Plr, name);
                }
            } break;

            case 16:                                        // Accepted Alliance Invite
            {
                if (Plr.GldInterface.AllianceinvitedTo > 0) // alli invite
                {
                    Plr.GldInterface.Guild.JoinAlliance(Plr.GldInterface.AllianceinvitedTo);
                    Plr.GldInterface.AllianceinvitedTo = 0;
                }
                else if (Plr.GldInterface.AllianceFormGuildId > 0)          // alli form
                {
                    Plr.GldInterface.Guild.FormAlliance(Plr.GldInterface.AllianceFormName, Plr.GldInterface.AllianceFormGuildId);
                    Plr.GldInterface.AllianceFormGuildId = 0;
                    Plr.GldInterface.AllianceFormName    = "";
                }
                else
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_GUILD_INVITE_ERR_NOINVITE);
                    return;
                }
            }
            break;

            case 17:     // Declined Alliance Invite
            {
                //CharMgr.GetCharacter().SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_SAY, GameData.Localized_text.TEXT_ALLIANCE_INVITE_DECLINED);
                Plr.GldInterface.AllianceinvitedTo = 0;
            }
            break;

            case 21:      // buy tactic
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }
                packet.Skip(1);
                string spell = packet.GetStringToZero();
                Plr.GldInterface.Guild.TrainGuildTactics((byte)CharacterId, ushort.Parse(spell));
            } break;

            case 22:      // calendar create
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }
                packet.Skip(156);
                UInt32 begin       = packet.GetUint32();
                UInt32 end         = packet.GetUint32();
                String name        = packet.GetPascalString();
                String description = packet.GetPascalString();
                byte   alliance    = packet.GetUint8();
                byte   locked      = packet.GetUint8();
                Plr.GldInterface.Guild.CreateEvent(Plr.GetPlayer().CharacterId, begin, end, name, description, alliance, locked);
            } break;

            case 23:      // calendar save
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }
                packet.Skip(151);
                byte eventid = packet.GetUint8();
                uint guildid = packet.GetUint32R();

                UInt32 begin       = packet.GetUint32();
                UInt32 end         = packet.GetUint32();
                String name        = packet.GetPascalString();
                String description = packet.GetPascalString();
                byte   alliance    = packet.GetUint8();
                byte   locked      = packet.GetUint8();
                Plr.GldInterface.Guild.EventEdit(Plr, eventid, guildid, begin, end, name, description, alliance, locked);
            }
            break;

            case 24:      // calendar delete
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(151);
                byte eventid = packet.GetUint8();
                uint guildid = packet.GetUint32R();
                Plr.GldInterface.Guild.DeleteEvent(Plr, eventid, guildid);
            }
            break;

            case 25:      // calendar signup
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(151);
                byte eventid = packet.GetUint8();
                uint guildid = packet.GetUint32R();
                Plr.GldInterface.Guild.EventSignup(Plr, eventid, guildid);
            }
            break;

            case 26:      // calendar signup cancel
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(151);
                byte eventid = packet.GetUint8();
                uint guildid = packet.GetUint32R();
                Plr.GldInterface.Guild.EventSignupCancel(Plr, eventid, guildid);
            }
            break;

            case 27:      // calendar signup kick
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(151);
                byte eventid     = packet.GetUint8();
                uint guildid     = packet.GetUint32R();
                uint characterid = packet.GetUint32R();
                Plr.GldInterface.Guild.EventSignupKick(Plr, eventid, guildid, characterid);
            }
            break;

            case 28:      // calendar signup approved
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(151);
                byte eventid = packet.GetUint8();
                uint guildid = packet.GetUint32R();
                uint charid  = packet.GetUint32R();
                Plr.GldInterface.Guild.EventSignupApproved(Plr, eventid, guildid, charid);
            }
            break;

            case 29:      // banner save
            {
                packet.Skip(151);
                byte banner = packet.GetUint8();
                byte post   = packet.GetUint8();
                packet.Skip(1);
                ushort spell1 = packet.GetUint16R();
                packet.Skip(2);
                ushort spell2 = packet.GetUint16R();
                packet.Skip(2);
                ushort spell3 = packet.GetUint16R();
                Plr.GldInterface.Guild.SaveBanner((byte)(banner - 1), post, spell1, spell2, spell3);
            } break;

            case 30:      // reserve banner
            {
                packet.Skip(151);
                ushort emblem  = packet.GetUint16R();
                ushort pattern = packet.GetUint16R();
                byte   color1  = packet.GetUint8();
                byte   color2  = packet.GetUint8();
                byte   shape   = packet.GetUint8();
                Plr.GldInterface.Guild.ReserveBanner(Plr, emblem, pattern, color1, color2, shape);
            } break;

            case 37:      //close guild vault
            {
                Plr.GldInterface.Guild.GuildVaultClosed(Plr);
            } break;

            case 38:      // Drop item to guild vault
            {
                packet.Skip(151);
                byte   sourceVault = packet.GetUint8();         // will be > 0 if item transfer from player to vault
                ushort itemSlot    = packet.GetUint16R();
                packet.Skip(2);
                byte   destVault = packet.GetUint8();
                ushort slot      = packet.GetUint16R();
                //Log.Info("slot", "" + slot + "  vault " + Vault+"         unk:"+Itemslot);
                if (sourceVault != 0 && destVault != 0)
                {
                    Plr.GldInterface.Guild.MoveVaultItem(Plr, sourceVault, itemSlot, destVault, slot);
                }
                else if (sourceVault == 0)
                {
                    Plr.GldInterface.Guild.DepositVaultItem(Plr, destVault, slot, itemSlot);
                }
                else
                {
                    Plr.GldInterface.Guild.WithdrawVaultItem(Plr, sourceVault, itemSlot, slot);
                }
            } break;

            case 39:      // Deposit money to guild vault
            {
                packet.Skip(151);
                uint Money = packet.GetUint32R();
                Plr.GldInterface.Guild.DepositMoney(Plr, Money);
            } break;

            case 40:      // Withdraw money to guild vault
            {
                packet.Skip(151);
                uint Money = packet.GetUint32R();
                Plr.GldInterface.Guild.WithdrawMoney(Plr, Money);
            } break;

            case 41:      // Lock item in guild vault
            {
                packet.Skip(151);
                byte Vault = packet.GetUint8();
                byte slot  = packet.GetUint8();
                //   Log.Info("slot", "" + slot + "  vault " + Vault);
                Plr.GldInterface.Guild.LockVaultItem(Plr, Vault, slot, 0);
            } break;

            case 42:      // cancel guild vault item move
            {
                packet.Skip(151);
                byte Vault = packet.GetUint8();
                byte slot  = packet.GetUint8();
                //   Log.Info("slot", "" + slot + "  vault " + Vault);
                Plr.GldInterface.Guild.ReleaseVaultItemLock(Plr, Vault, slot);
            } break;

            case 46:     // Update recruit page save
            {
                if (!Plr.GldInterface.IsInGuild())
                {
                    return;
                }

                packet.Skip(152);

                String BriefDescription = packet.GetPascalString();         //might be ushort for size
                String Summary          = packet.GetString(packet.GetUint16());
                byte   PlayStyle        = packet.GetUint8();
                byte   Atmosphere       = packet.GetUint8();
                uint   CareersNeeded    = packet.GetUint32();
                packet.Skip(3);
                byte RanksNeeded = packet.GetUint8();
                packet.Skip(3);
                byte Interests = packet.GetUint8();
                packet.Skip(3);
                byte ActivelyRecruiting = packet.GetUint8();
                //packet.Skip(6);

                Plr.GldInterface.Guild.SetRecruitmentInfo(BriefDescription, Summary, PlayStyle, Atmosphere, CareersNeeded, RanksNeeded, Interests, ActivelyRecruiting);
            } break;

            case 47:     // Search guilds
            {
                packet.Skip(151);
                byte Style      = packet.GetUint8();
                byte Atmosphere = packet.GetUint8();
                packet.Skip(7);
                byte MyLevelCareer = packet.GetUint8();
                packet.Skip(2);
                ushort Pop = packet.GetUint16();
                packet.Skip(3);
                byte Online = packet.GetUint8();
                packet.Skip(3);
                byte Rank = packet.GetUint8();

                Plr.GldInterface.SendGuilds(Guild.GetGuilds(Plr.Realm, Style, Atmosphere, MyLevelCareer, Plr.Level, Plr.Info.Career, Pop, Online, Rank));
            } break;

            case 52:     // guild tactic respec
            {
                Plr.GldInterface.Guild.GuildsTacticRespec(Plr);
            } break;

            case 53:     // Buy Guild Vault Slot
            {
                packet.Skip(151);
                byte Vault = packet.GetUint8();
                uint Money = packet.GetUint32R();
                //     Log.Info("", "vault " + Vault+"   prize"+Money);
                Plr.GldInterface.Guild.BuyVaultSlot(Plr, Vault, Money);
            } break;
            }
        }
Пример #18
0
        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            CreateInfo Info;

            Info.slot     = packet.GetUint8();
            Info.race     = packet.GetUint8();
            Info.career   = packet.GetUint8();
            Info.sex      = packet.GetUint8();
            Info.model    = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] Traits = new byte[8];
            packet.Read(Traits, 0, Traits.Length);
            packet.Skip(7);

            string Name = packet.GetString(Info.NameSize);

            if (!CharMgr.NameIsUsed(Name))
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                    return;
                }

                Log.Success("OnCreate", "Creating new Character : " + Name);

                Character Char = new Character();
                Char.AccountId  = cclient._Account.AccountId;
                Char.bTraits    = Traits;
                Char.Career     = Info.career;
                Char.CareerLine = CharInfo.CareerLine;
                Char.ModelId    = Info.model;
                Char.Name       = Name;
                Char.Race       = Info.race;
                Char.Realm      = CharInfo.Realm;
                Char.RealmId    = Program.Rm.RealmId;
                Char.Sex        = Info.sex;

                if (!CharMgr.CreateChar(Char))
                {
                    Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    return;
                }

                Character_items      Citm  = null;
                CharacterInfo_item[] Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                for (int i = 0; i < Items.Length; ++i)
                {
                    if (Items[i] == null)
                    {
                        continue;
                    }

                    Citm             = new Character_items();
                    Citm.Counts      = Items[i].Count;
                    Citm.CharacterId = Char.CharacterId;
                    Citm.Entry       = Items[i].Entry;
                    Citm.ModelId     = Items[i].ModelId;
                    Citm.SlotId      = Items[i].SlotId;
                    CharMgr.CreateItem(Citm);
                }

                Character_value CInfo = new Character_value();
                CInfo.CharacterId = Char.CharacterId;
                CInfo.Level       = 1;
                CInfo.Money       = 0;
                CInfo.Online      = false;
                CInfo.RallyPoint  = CharInfo.RallyPt;
                CInfo.RegionId    = CharInfo.Region;
                CInfo.Renown      = 0;
                CInfo.RenownRank  = 1;
                CInfo.RestXp      = 0;
                CInfo.Skills      = CharInfo.Skills;
                CInfo.Speed       = 100;
                CInfo.WorldO      = CharInfo.WorldO;
                CInfo.WorldX      = CharInfo.WorldX;
                CInfo.WorldY      = CharInfo.WorldY;
                CInfo.WorldZ      = CharInfo.WorldZ;
                CInfo.Xp          = 0;
                CInfo.ZoneId      = CharInfo.ZoneId;

                CharMgr.Database.AddObject(CInfo);

                Char.Value = new Character_value[1] {
                    CInfo
                };
            }


            PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);

            Out.WritePascalString(cclient._Account.Username);
            cclient.SendTCP(Out);
        }
Пример #19
0
        public static void F_CONNECT(BaseClient client, PacketIn packet)
        {
            Log.Success("F_CONNECT", "Entering F_CONNECT " + client.Id.ToString() + " " + packet.Opcode.ToString());
            GameClient cclient = (GameClient)client;

            packet.Skip(8);
            uint   Tag   = packet.GetUint32();
            string Token = packet.GetString(80);

            packet.Skip(21);
            string Username = packet.GetString(23);

            // TODO
            AuthResult Result = Program.AcctMgr.CheckToken(Username, Token);

#if DEBUG
            Result = AuthResult.AUTH_SUCCESS;
#endif

            if (Result == AuthResult.AUTH_ACCT_SUSPENDED)
            {
                Log.Error("F_CONNECT", "Banned Account =" + Username);
                cclient.Disconnect("Banned account");
            }
            else if (Result != AuthResult.AUTH_SUCCESS)
            {
                Log.Error("F_CONNECT", "Invalid Token =" + Username + " " + Result);

                // Kick people who spam the god damn button for 5 minutes straight before they clock on.
                PacketOut Out = new PacketOut((byte)Opcodes.F_PLAYER_QUIT, 4);
                Out.WriteHexStringBytes("01000000");
                cclient.SendPacket(Out);

                cclient.Disconnect("Invalid token");
            }
            else
            {
                cclient._Account = Program.AcctMgr.GetAccount(Username);
                if (cclient._Account == null)
                {
                    Log.Error("F_CONNECT", "Invalid Account =" + Username);
                    cclient.Disconnect("Invalid account");
                }
                else
                {
                    Log.Success("F_CONNECT", "MeId=" + cclient.Id);
                    Log.Success("F_CONNECT", "User connection : " + Username);

                    GameClient Other = ((TCPServer)cclient.Server).GetClientByAccount(cclient, cclient._Account.AccountId);
                    if (Other != null)
                    {
                        Other.Disconnect("Failed to get GameClient for account");
                    }

                    // Check if ip is banned. (they may have been just banned so launcher server wouldnt have picked it up)
                    if (!Program.AcctMgr.CheckIp(cclient.GetIp().Split(':')[0]))
                    {
                        Log.Error("F_CONNECT", "Banned IP =" + Username);
                        cclient.Disconnect("Banned by IP");
                    }

                    // Load characters before connection instead of later on
                    CharMgr.LoadCharacters(cclient._Account.AccountId);

                    {
                        cclient.PacketLog = cclient._Account.PacketLog;

                        PacketOut Out = new PacketOut((byte)Opcodes.S_CONNECTED, 48);
                        Out.WriteUInt32(0);
                        Out.WriteUInt32(Tag);
                        Out.WriteByte(Program.Rm.RealmId);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0);
                        Out.WriteByte(0); // TRANSFER_FLAG (1 - Low population server..free transfers...)
                        Out.WritePascalString(Username);
                        Out.WritePascalString(Program.Rm.Name);
                        Out.WriteByte(0);
                        Out.WriteUInt16(0);
                        cclient.SendPacket(Out);
                    }
                }
            }
        }
Пример #20
0
        public void SendPacketMail(PacketIn packet)
        {
            Player plr = GetPlayer();

            if (plr == null)
            {
                return;
            }

            if (_nextSend >= TCPManager.GetTimeStamp())
            {
                SendResult(MailResult.TEXT_MAIL_RESULT6);
                return;
            }

            // Recipient read
            packet.Skip(1);
            byte   nameSize = packet.GetUint8();
            string name     = packet.GetString(nameSize);



            // Subject (client is limited to send 30 chars but its probably a ushort anyway)
            ushort subjectSize = ByteSwap.Swap(packet.GetUint16());
            string subject     = packet.GetString(subjectSize);

            // Message
            ushort messageSize = ByteSwap.Swap(packet.GetUint16());
            string message     = packet.GetString(messageSize);

            // Money
            uint money = ByteSwap.Swap(packet.GetUint32());

            // COD?
            byte cr = packet.GetUint8();

            // Item
            byte itemsToSendCount = packet.GetUint8();

            var isBlackMarket = ((name.ToLower() == "black market") || (name.ToLower() == "blackmarket"));

            List <ushort> itemSlots = new List <ushort>();
            var           itemList  = new List <Item>();

            for (byte i = 0; i < itemsToSendCount; ++i)
            {
                ushort itemSlot = ByteSwap.Swap(packet.GetUint16());
                packet.Skip(2);

                Item item = plr.ItmInterface.GetItemInSlot(itemSlot);
                if (item == null || item.Info == null)
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT16);
                    return;
                }

                // Allow black market items to be sent in mail
                if (!isBlackMarket)
                {
                    if (item.BoundtoPlayer || item.Info.Bind == 1)
                    {
                        SendResult(MailResult.TEXT_MAIL_RESULT9);
                        return;
                    }
                }

                itemSlots.Add(itemSlot);
                itemList.Add(item);
            }

            if (isBlackMarket)
            {
                _logger.Debug($"Sending mail to the BLACK MARKET. Number items {itemsToSendCount}");

                // Ensure that what is being sent is a warlord item
                if (itemsToSendCount == 0)
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT9);
                    return;
                }

                var blackMarketManager = new BlackMarketManager();

                // Sending multiple items.
                foreach (var item in itemList)
                {
                    if (blackMarketManager.IsItemOnBlackMarket(item.Info.Entry))
                    {
                        _logger.Info($"Sending {item.Info.Name} ({item.Info.Entry}) to BlackMarket");
                        blackMarketManager.SendBlackMarketReward(plr, item.Info.Entry);
                        plr.SendClientMessage($"Trusting to your luck, you have sent {string.Join(",", itemList.Select(x => x.Info.Name))} to the Black Market, hoping for just recompense.");
                        _logger.Debug($"Email Sent.");
                        plr.ItmInterface.RemoveItems(item.Info.Entry, 1);
                        _logger.Info($"Removed {item.Info.Name} ({item.Info.Entry}) from {plr.Name}");
                        plr.SendClientMessage($"A suspicious looking package has arrived in your mail.", ChatLogFilters.CHATLOGFILTERS_LOOT);
                    }
                    else
                    {
                        _logger.Debug($"{MailResult.TEXT_MAIL_RESULT9}");
                        return;
                    }
                }

                SendResult(MailResult.TEXT_MAIL_RESULT4);
            }
            else
            {
                Character receiver = CharMgr.GetCharacter(Player.AsCharacterName(name), false);

                if (receiver == null || receiver.Realm != (byte)plr.Realm)
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT7);
                    return;
                }
                if (receiver.Name == plr.Name) // You cannot mail yourself
                {
                    plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF);
                    return;
                }
                if ((cr == 0 && !plr.HasMoney(money)) || !plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE))
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT8);
                    return;
                }

                SendMail(receiver, subject, message, money, cr == 1, itemSlots);

                _logger.Info($"Sending mail {subject} to {receiver.Name} from {plr.Name}. Money={money}, Item Count={itemSlots.Count}");
                foreach (var itemSlot in itemSlots)
                {
                    _logger.Info($"Item : {itemSlot}");
                }
            }
        }
Пример #21
0
        public static void F_SOCIAL_NETWORK(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
            case 7:     // World Groups
            {
            } break;

            case 8:
            {
                packet.Skip(1);
                byte NameSize = packet.GetUint8();
                packet.Skip(1);
                string Name      = packet.GetString(NameSize);
                byte   GuildSize = packet.GetUint8();
                packet.Skip(1);
                string GuildName = packet.GetString(GuildSize);
                packet.Skip(1);
                ushort Career = packet.GetUint16();
                packet.Skip(4);
                ushort ZoneId = packet.GetUint16();

                while (ZoneId > 256)
                {
                    ZoneId -= 256;
                }

                while (packet.GetUint8() != 0xFF)
                {
                    ;
                }

                packet.Skip(2 + (ZoneId == 255 ? 0 : 1));

                byte MinLevel = packet.GetUint8();
                byte MaxLevel = packet.GetUint8();

                Plr.SocInterface.SendPlayers(Player.GetPlayers(Name, GuildName, Career, ZoneId, MinLevel, MaxLevel, cclient.Plr), Plr.GmLevel != 0);         //cant hide location/details from gm
            } break;

            case 11:     // Inspection
            {
                Player Target = Plr.CbtInterface.GetTarget(GameData.TargetTypes.TARGETTYPES_TARGET_ALLY) as Player;
                if (Target == null)
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                }
                else if (!Target.Info.Anonymous || Plr.GmLevel > 0)        //do not allow inspect of anonymous players, unless by gm
                {
                    Target.ItmInterface.SendInspect(Plr);
                }
                else
                {
                    Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_UNABLE_TO_INSPECT_PLAYER_EQUIP);
                }
            } break;

            case 13:     // Nearby Groups
            {
                Group.SendWorldGroups(Plr);
            } break;

            case 18:     // AFK
            {
                packet.Skip(1);
                bool AFKState = packet.GetUint8() == 1;        // Went afk manually.
                bool AutoAFK  = packet.GetUint8() == 1;        // Kick them from SC if this happens?

                //Use
                Plr.IsAFK     = AFKState;
                Plr.IsAutoAFK = AutoAFK;
                //remove a player from an SC if they are in one and afk is toggled.
                if ((Plr.IsAFK || Plr.IsAutoAFK) && Plr.ScnInterface.Scenario != null)
                {
                    Plr.SendClientMessage("You have been removed from the scenario due to afk", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                    Plr.ScnInterface.Scenario.RemovePlayer(Plr, true);
                }

                byte length = packet.GetUint8();
                packet.Skip(1);
                string message = packet.GetString(length);
                if (message != null)
                {
                    Plr.AFKMessage = message;
                }
                else
                {
                    Plr.AFKMessage = "";
                }
            }
            break;
            }
        }
Пример #22
0
        public static void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;
            CreateInfo Info;

            Info.slot     = packet.GetUint8();
            Info.race     = packet.GetUint8();
            Info.career   = packet.GetUint8();
            Info.sex      = packet.GetUint8();
            Info.model    = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] traits = new byte[8];
            packet.Read(traits, 0, traits.Length);
            packet.Skip(7);

            string name = packet.GetString(Info.NameSize);

            ushort duplicate = 0;

            for (int i = 0; i < name.Length; i++)
            {
                if (i != 0)
                {
                    if (name[i] == name[i - 1])
                    {
                        duplicate++;
                    }
                    else
                    {
                        duplicate = 0;
                    }

                    if (duplicate > 3)
                    {
                        break;
                    }
                }
            }

            if (name.Length > 2 && !CharMgr.NameIsUsed(name) && CharMgr.AllowName(name) && !CharMgr.NameIsDeleted(name) && duplicate < 3)
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                }
                else
                {
                    //Log.Success("OnCreate", "New Character : " + Name);

                    Character Char = new Character
                    {
                        AccountId    = cclient._Account.AccountId,
                        bTraits      = traits,
                        Career       = Info.career,
                        CareerLine   = CharInfo.CareerLine,
                        ModelId      = Info.model,
                        Name         = name,
                        Race         = Info.race,
                        Realm        = CharInfo.Realm,
                        RealmId      = Program.Rm.RealmId,
                        Sex          = Info.sex,
                        FirstConnect = true
                    };

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {
                        List <CharacterInfo_item> Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                        foreach (CharacterInfo_item Itm in Items)
                        {
                            if (Itm == null)
                            {
                                continue;
                            }

                            CharacterItem Citm = new CharacterItem
                            {
                                Counts       = Itm.Count,
                                CharacterId  = Char.CharacterId,
                                Entry        = Itm.Entry,
                                ModelId      = Itm.ModelId,
                                SlotId       = Itm.SlotId,
                                PrimaryDye   = 0,
                                SecondaryDye = 0
                            };
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value
                        {
                            CharacterId = Char.CharacterId,
                            Level       = 1,
                            Money       = 2000,
                            Online      = false,
                            RallyPoint  = CharInfo.RallyPt,
                            RegionId    = CharInfo.Region,
                            Renown      = 0,
                            RenownRank  = 1,
                            RestXp      = 0,
                            Skills      = CharInfo.Skills,
                            Speed       = 100,
                            PlayedTime  = 0,
                            WorldO      = CharInfo.WorldO,
                            WorldX      = CharInfo.WorldX,
                            WorldY      = CharInfo.WorldY,
                            WorldZ      = CharInfo.WorldZ,
                            Xp          = 0,
                            ZoneId      = CharInfo.ZoneId
                        };

                        CharMgr.Database.AddObject(CInfo);
                        Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=2"));

                        CharacterClientData clientData = new CharacterClientData {
                            CharacterId = Char.CharacterId
                        };
                        CharMgr.Database.AddObject(clientData);

                        Char.Value      = CInfo;
                        Char.ClientData = clientData;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE, 32);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR, 64);
                Out.FillString(cclient._Account.Username, 24);
                Out.WriteStringBytes("You have entered a duplicate or invalid name. Please enter a new name.");
                cclient.SendPacket(Out);
            }
        }
Пример #23
0
        static public void F_CREATE_CHARACTER(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;
            CreateInfo Info;

            Info.slot     = packet.GetUint8();
            Info.race     = packet.GetUint8();
            Info.career   = packet.GetUint8();
            Info.sex      = packet.GetUint8();
            Info.model    = packet.GetUint8();
            Info.NameSize = packet.GetUint16();
            packet.Skip(2);

            byte[] Traits = new byte[8];
            packet.Read(Traits, 0, Traits.Length);
            packet.Skip(7);

            string Name = packet.GetString(Info.NameSize);

            if (Name.Length > 2 && !CharMgr.NameIsUsed(Name))
            {
                CharacterInfo CharInfo = CharMgr.GetCharacterInfo(Info.career);
                if (CharInfo == null)
                {
                    Log.Error("ON_CREATE", "Can not find career :" + Info.career);
                }
                else
                {
                    Log.Success("OnCreate", "New Character : " + Name);

                    Character Char = new Character();
                    Char.AccountId    = cclient._Account.AccountId;
                    Char.bTraits      = Traits;
                    Char.Career       = Info.career;
                    Char.CareerLine   = CharInfo.CareerLine;
                    Char.ModelId      = Info.model;
                    Char.Name         = Name;
                    Char.Race         = Info.race;
                    Char.Realm        = CharInfo.Realm;
                    Char.RealmId      = Program.Rm.RealmId;
                    Char.Sex          = Info.sex;
                    Char.FirstConnect = true;

                    if (!CharMgr.CreateChar(Char))
                    {
                        Log.Error("CreateCharacter", "Hack : can not create more than 10 characters!");
                    }
                    else
                    {
                        Character_item            Citm  = null;
                        List <CharacterInfo_item> Items = CharMgr.GetCharacterInfoItem(Char.CareerLine);

                        foreach (CharacterInfo_item Itm in Items)
                        {
                            if (Itm == null)
                            {
                                continue;
                            }

                            Citm             = new Character_item();
                            Citm.Counts      = Itm.Count;
                            Citm.CharacterId = Char.CharacterId;
                            Citm.Entry       = Itm.Entry;
                            Citm.ModelId     = Itm.ModelId;
                            Citm.SlotId      = Itm.SlotId;
                            CharMgr.CreateItem(Citm);
                        }

                        Character_value CInfo = new Character_value();
                        CInfo.CharacterId = Char.CharacterId;
                        CInfo.Level       = 1;
                        CInfo.Money       = 0;
                        CInfo.Online      = false;
                        CInfo.RallyPoint  = CharInfo.RallyPt;
                        CInfo.RegionId    = CharInfo.Region;
                        CInfo.Renown      = 0;
                        CInfo.RenownRank  = 1;
                        CInfo.RestXp      = 0;
                        CInfo.Skills      = CharInfo.Skills;
                        CInfo.Speed       = 100;
                        CInfo.WorldO      = CharInfo.WorldO;
                        CInfo.WorldX      = CharInfo.WorldX;
                        CInfo.WorldY      = CharInfo.WorldY;
                        CInfo.WorldZ      = CharInfo.WorldZ;
                        CInfo.Xp          = 0;
                        CInfo.ZoneId      = CharInfo.ZoneId;

                        CharMgr.Database.AddObject(CInfo);
                        Program.AcctMgr.UpdateRealmCharacters(Program.Rm.RealmId, (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=1"), (uint)CharMgr.Database.GetObjectCount <Character>(" Realm=2"));

                        Char.Value = CInfo;

                        PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_RESPONSE);
                        Out.WritePascalString(cclient._Account.Username);
                        cclient.SendPacket(Out);
                    }
                }
            }
            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_SEND_CHARACTER_ERROR);
                Out.WritePascalString(cclient._Account.Username);
                cclient.SendPacket(Out);
            }
        }
Пример #24
0
        public void BuildMail(PacketIn packet)
        {
            Player Plr = GetPlayer();

            if (Plr == null)
            {
                return;
            }

            if (nextSend >= TCPServer.GetTimeStamp())
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT6);
                return;
            }

            // Recipient read
            packet.Skip(1);
            byte   NameSize = packet.GetUint8();
            string Name     = packet.GetString(NameSize);

            Character Receiver = CharMgr.GetCharacter(Name);

            if (Receiver == null || Receiver.Realm != (byte)Plr.Realm)
            {
                SendResult(GameData.MailResult.TEXT_MAIL_RESULT7);
                return;
            }

            if (Receiver.Name == Plr.Name) // You cannot mail yourself
            {
                Plr.SendLocalizeString("", GameData.Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF);
                return;
            }

            // Subject
            byte SubjectSize = packet.GetUint8();

            packet.Skip(1);
            string Subject = packet.GetString(SubjectSize);

            // Message
            byte MessageSize = packet.GetUint8();

            packet.Skip(1);
            string Message = packet.GetString(MessageSize);

            // Money
            UInt32 money = ByteOperations.ByteSwap.Swap(packet.GetUint32());

            // COD?
            byte cr = packet.GetUint8();

            // Item
            byte itemcounts = packet.GetUint8();

            if (!Plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE))
            {
                SendResult(MailResult.TEXT_MAIL_RESULT8);
                return;
            }

            // Make a Mail
            Character_mail CMail = new Character_mail();

            CMail.Guid              = CharMgr.GenerateMailGUID();
            CMail.CharacterId       = Receiver.CharacterId;
            CMail.CharacterIdSender = Plr._Info.CharacterId;
            CMail.SenderName        = Plr._Info.Name;
            CMail.ReceiverName      = Name;
            CMail.SendDate          = (uint)TCPManager.GetTimeStamp();
            CMail.Title             = Subject;
            CMail.Content           = Message;
            CMail.Money             = money;
            CMail.Cr     = true;
            CMail.Opened = false;

            Log.Debug("Mail", "Itemcount: " + itemcounts + "");


            for (byte i = 0; i < itemcounts; ++i)
            {
                UInt16 itmslot = ByteOperations.ByteSwap.Swap(packet.GetUint16());
                packet.Skip(2);

                ByteOperations.ByteSwap.Swap(itmslot);

                Item itm = Plr.ItmInterface.GetItemInSlot(itmslot);
                if (itm != null)
                {
                    CMail.Items.Add(new KeyValuePair <uint, ushort>(itm.Info.Entry, itm.CharItem.Counts));
                    Plr.ItmInterface.DeleteItem(itmslot, itm.CharItem.Counts, true);
                    itm.Owner = null;
                }
            }

            SendResult(MailResult.TEXT_MAIL_RESULT4);
            CharMgr.Database.AddObject(CMail);

            //If player exists let them know they have mail.
            Player mailToPlayer = Player.GetPlayer(Name);

            if (mailToPlayer != null)
            {
                mailToPlayer.MlInterface.AddMail(CMail);
            }


            nextSend = (uint)TCPServer.GetTimeStamp() + 5;
        }
Пример #25
0
        static public void F_SOCIAL_NETWORK(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            byte Type = packet.GetUint8();

            switch (Type)
            {
            case 11:     // Inspection
            {
                Player Target = Plr.CbtInterface.GetTarget() as Player;
                if (Target == null)
                {
                    Plr.SendLocalizeString("", GameData.Localized_text.TEXT_SN_LISTS_ERR_PLAYER_NOT_FOUND);
                }
                else
                {
                    Target.ItmInterface.SendInspect(Plr);
                }
            }
            break;

            case 8:
            {
                packet.Skip(1);
                byte NameSize = packet.GetUint8();
                packet.Skip(1);
                string Name      = packet.GetString(NameSize);
                byte   GuildSize = packet.GetUint8();
                packet.Skip(1);
                string GuildName = packet.GetString(GuildSize);
                packet.Skip(1);
                UInt16 Career = packet.GetUint16();
                packet.Skip(4);
                UInt16 ZoneId = packet.GetUint16();

                while (ZoneId > 256)
                {
                    ZoneId -= 256;
                }

                while (packet.GetUint8() != 0xFF)
                {
                    ;
                }

                packet.Skip(2 + (ZoneId == 255 ? 0 : 1));

                byte MinLevel = packet.GetUint8();
                byte MaxLevel = packet.GetUint8();

                Plr.SocInterface.SendPlayers(Player.GetPlayers(Name, GuildName, Career, ZoneId, MinLevel, MaxLevel));
            } break;
            }
        }
Пример #26
0
        public static void F_HELP_DATA(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            if (!cclient.IsPlaying() || !cclient.Plr.IsInWorld())
            {
                return;
            }

            Player Plr = cclient.Plr;

            GameData.HelpType Type = (GameData.HelpType)packet.GetUint8();

            switch (Type)
            {
            case GameData.HelpType.HELPTYPE_CREATE_APPEAL_VIOLATION_REPORT: // Violation Report
            case GameData.HelpType.HELPTYPE_CREATE_APPEAL_NAMING_VIOLATION: // Name Violation
            case GameData.HelpType.HELPTYPE_CREATE_APPEAL_GOLD_SELLER:      // Gold Seller
            {
                GameData.AppealTopic Category = (GameData.AppealTopic)packet.GetUint8();
                ushort ReportTypeSize         = packet.GetUint16R();
                packet.Skip(2);
                string ReportType = "";
                if (ReportTypeSize > 0)
                {
                    ReportType = packet.GetString(ReportTypeSize - 1);
                }
                packet.Skip(1);
                ushort MessageSize = packet.GetUint16R();
                packet.Skip(2);
                string Message = "";
                if (MessageSize > 0)
                {
                    Message = packet.GetString(MessageSize - 1);
                }
                packet.Skip(1);
                ushort NameSize = packet.GetUint16R();
                packet.Skip(2);
                string Name = packet.GetString(NameSize - 1);

                Bug_report report = new Bug_report();
                report.Time        = (uint)TCPManager.GetTimeStamp();
                report.AccountId   = (uint)Plr.Client._Account.AccountId;
                report.CharacterId = Plr.CharacterId;

                //fix for when someone right clicks chat to report or report spam on mails, because mythic thought it was good to classify these as goldsellers...
                if (Message.StartsWith("[") || Message.StartsWith($"\n[") || Message.StartsWith($"\n ["))
                {
                    report.Type       = 2;         // Violation report
                    report.Category   = 4;         //Violation report
                    report.ReportType = "General"; //General subcategory of violation report
                }
                else
                {
                    report.Type       = (byte)Type;
                    report.Category   = (byte)Category;
                    report.ReportType = ReportType;
                }

                if (Message.Contains(";"))
                {
                    Message = Message.Replace(';', ':');
                }

                if (Message.Contains("^"))
                {
                    Message = Message.Replace('^', ' ');
                }

                report.Message  = Message;
                report.ZoneId   = Plr.Zone.Info.ZoneId;
                report.X        = (ushort)(Plr.X / 64);
                report.Y        = (ushort)(Plr.Y / 64);
                report.Assigned = "nobody";
                report.Fields.Add(new KeyValuePair <uint, string>(0, Name.Replace("|", "").Replace(":", "")));

                //lets not allow players to report server automated mails
                if (Message.Contains("[Mail Subject]: Public Quest Loot [Mail Message Body]: You won a Public Quest Loot Bag") || Message.Contains("[Mail Subject]: Medallion Reward [Mail Message Body]: You've received a medallion reward for your realm's victory in a recent battle in which you were a participant.") || Message.Contains(" [Mail Message Body]: Your mail expired and has been returned to you."))
                {
                    Plr.SendClientMessage("This is a server generated mail, this ticket will be discarded.", ChatLogFilters.CHATLOGFILTERS_USER_ERROR);
                    break;
                }


                CharMgr.Database.AddObject(report);
                lock (CharMgr._report)
                    CharMgr._report.Add(report);

                Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_MISC, GameData.Localized_text.TEXT_COPTER_GENERAL_FEEDBACK_SENT);

                foreach (Player plr in GmMgr.GmList)
                {
                    plr.SendClientMessage("NEW_TICKET", ChatLogFilters.CHATLOGFILTERS_CHANNEL_9);
                }
            } break;

            case GameData.HelpType.HELPTYPE_CREATE_APPEAL_NON_VALIDATED:     // CSR Appeal
            {
                GameData.AppealTopic Category = (GameData.AppealTopic)packet.GetUint8();
                ushort MessageSize            = packet.GetUint16R();
                packet.Skip(2);
                string Message = "";
                if (MessageSize > 0)
                {
                    Message = packet.GetString(MessageSize - 1);
                }

                packet.Skip(1);
                byte FieldsCount = packet.GetUint8();

                Bug_report report = new Bug_report();
                report.Time        = (uint)TCPManager.GetTimeStamp();
                report.AccountId   = (uint)Plr.Client._Account.AccountId;
                report.CharacterId = Plr.CharacterId;
                report.Type        = (byte)Type;
                report.Category    = (byte)Category;

                if (Message.Contains(";"))
                {
                    Message = Message.Replace(';', ':');
                }

                if (Message.Contains("^"))
                {
                    Message = Message.Replace('^', ' ');
                }

                report.Message  = Message;
                report.ZoneId   = Plr.Zone.Info.ZoneId;
                report.X        = (ushort)(Plr.X / 64);
                report.Y        = (ushort)(Plr.Y / 64);
                report.Assigned = "nobody";

                for (int i = 0; i < FieldsCount; i++)
                {
                    GameData.HelpField FieldType = (GameData.HelpField)packet.GetUint8();
                    ushort             FieldSize = packet.GetUint16R();
                    packet.Skip(2);
                    string Field = packet.GetString(FieldSize - 1);
                    packet.Skip(1);
                    report.Fields.Add(new KeyValuePair <uint, string>((byte)FieldType, Field.Replace("|", "").Replace(":", "")));
                }


                CharMgr.Database.AddObject(report);
                lock (CharMgr._report)
                    CharMgr._report.Add(report);

                Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_MISC, GameData.Localized_text.TEXT_COPTER_GENERAL_FEEDBACK_SENT);

                foreach (Player plr in GmMgr.GmList)
                {
                    plr.SendClientMessage("NEW_TICKET", ChatLogFilters.CHATLOGFILTERS_CHANNEL_9);
                }
            } break;

            case GameData.HelpType.HELPTYPE_CREATE_BUG_REPORT:   // Bug Report
            case GameData.HelpType.HELPTYPE_CREATE_FEEDBACK:     // Feedback
            {
                byte   Category    = packet.GetUint8();
                ushort MessageSize = packet.GetUint16R();
                packet.Skip(2);
                string Message = "";
                if (MessageSize > 0)
                {
                    Message = packet.GetString(MessageSize - 1);
                }

                Bug_report report = new Bug_report();
                report.Time        = (uint)TCPManager.GetTimeStamp();
                report.AccountId   = (uint)Plr.Client._Account.AccountId;
                report.CharacterId = Plr.CharacterId;
                report.Type        = (byte)Type;
                report.Category    = Category;

                if (Message.Contains(";"))
                {
                    Message = Message.Replace(';', ':');
                }

                if (Message.Contains("^"))
                {
                    Message = Message.Replace('^', ' ');
                }

                report.Message  = Message;
                report.ZoneId   = Plr.Zone.Info.ZoneId;
                report.X        = (ushort)(Plr.X / 64);
                report.Y        = (ushort)(Plr.Y / 64);
                report.Assigned = "nobody";

                CharMgr.Database.AddObject(report);
                lock (CharMgr._report)
                    CharMgr._report.Add(report);

                Plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, GameData.Localized_text.TEXT_COPTER_GENERAL_FEEDBACK_SENT);

                foreach (Player plr in GmMgr.GmList)
                {
                    plr.SendClientMessage("NEW_TICKET", ChatLogFilters.CHATLOGFILTERS_CHANNEL_9);
                }
            } break;
            }
        }
        public void SendPacketMail(PacketIn packet)
        {
            Player plr = GetPlayer();

            if (plr == null)
            {
                return;
            }

            if (_nextSend >= TCPManager.GetTimeStamp())
            {
                SendResult(MailResult.TEXT_MAIL_RESULT6);
                return;
            }

            // Recipient read
            packet.Skip(1);
            byte   nameSize = packet.GetUint8();
            string name     = packet.GetString(nameSize);

            Character receiver = CharMgr.GetCharacter(Player.AsCharacterName(name), false);

            if (receiver == null || receiver.Realm != (byte)plr.Realm)
            {
                SendResult(MailResult.TEXT_MAIL_RESULT7);
                return;
            }

            if (receiver.Name == plr.Name) // You cannot mail yourself
            {
                plr.SendLocalizeString("", ChatLogFilters.CHATLOGFILTERS_USER_ERROR, Localized_text.TEXT_PLAYER_CANT_MAIL_YOURSELF);
                return;
            }

            // Subject (client is limited to send 30 chars but its probably a ushort anyway)
            ushort subjectSize = ByteSwap.Swap(packet.GetUint16());
            string subject     = packet.GetString(subjectSize);

            // Message
            ushort messageSize = ByteSwap.Swap(packet.GetUint16());
            string message     = packet.GetString(messageSize);

            // Money
            uint money = ByteSwap.Swap(packet.GetUint32());

            // COD?
            byte cr = packet.GetUint8();

            // Item
            byte itemcounts = packet.GetUint8();

            Log.Debug("Mail", "Itemcount: " + itemcounts + "");

            List <ushort> itemSlots = new List <ushort>();

            for (byte i = 0; i < itemcounts; ++i)
            {
                ushort itmslot = ByteSwap.Swap(packet.GetUint16());
                packet.Skip(2);

                Item itm = plr.ItmInterface.GetItemInSlot(itmslot);
                if (itm == null || itm.Info == null)
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT16);
                    return;
                }
                if (itm.BoundtoPlayer || itm.Info.Bind == 1)
                {
                    SendResult(MailResult.TEXT_MAIL_RESULT9);
                    return;
                }

                itemSlots.Add(itmslot);
            }

            if ((cr == 0 && !plr.HasMoney(money)) || !plr.RemoveMoney((cr == 0 ? money : 0) + MAIL_PRICE))
            {
                SendResult(MailResult.TEXT_MAIL_RESULT8);
                return;
            }

            SendMail(receiver, subject, message, money, cr == 1, itemSlots);
        }