public override void OnConnect(ServerSocket parent = null)
        {
            if (ClientConnection.CurrentSession == null)
            {
                throw new Exception("Realm connection with no session");
            }
            var realmparent = parent as RealmClientSocket;

            if (realmparent == null)
            {
                throw new Exception("Realm connection with non realm parent!");
            }

            ClientConnection.CurrentSession.SetRealmInfo(realmparent.GetRealmSettings());

            Random rnd = new Random();

            Seed = (UInt32)rnd.Next();

            PacketOut p = new PacketOut(RealmOp.SMSG_AUTH_CHALLENGE);

            p.Write((int)1);
            p.Write(Seed);

            p.Write(0xF3539DA3);
            p.Write(0x6E8547B9);
            p.Write(0x9A6AA2F8);
            p.Write(0xA4F170F4);
            p.Write(0xF3539DA3);
            p.Write(0x6E8547B9);
            p.Write(0x9A6AA2F8);
            p.Write(0xA4F170F4);

            SendPacket(p);
        }
Beispiel #2
0
        public async Task SendAccountDataTimes(UInt32 mask)
        {
            PacketOut p = new PacketOut(RealmOp.SMSG_ACCOUNT_DATA_TIMES);

            p.Write(Time.GetUnixTime());
            p.Write((byte)1);
            p.Write(mask);

            for (int i = 0; i < 8; ++i)
            {
                if ((mask & (1 << i)) != 0)
                {
                    if (State.Data == null || State.Data.TimeStamp == null)
                    {
                        p.Write((int)0);
                    }
                    else
                    {
                        p.Write(State.Data.TimeStamp[i]);
                    }
                }
            }

            await SendPacketRealm(p);
        }
        public void LoginPlayer(Character chr)
        {
            PacketOut outpacket = new PacketOut(WorldServerOpCode.CMSG_PLAYER_LOGIN);

            outpacket.Write(chr.GUID);
            Send(outpacket);

            outpacket = new PacketOut(WorldServerOpCode.CMSG_UPDATE_ACCOUNT_DATA);
            outpacket.Write((UInt32)7);
            outpacket.Write((UInt32)5144);
            outpacket.Write(account_data);
            Send(outpacket);

            objectMgr.MapID      = chr.MapID;
            objectMgr.playerGuid = new WoWGuid(chr.GUID);
            objectMgr.getPlayerObject().SetPlayer(chr);
            StartHeartbeat();


            movementMgr.Start();
            combatMgr.Start();
            terrainMgr.ChangeMap(chr.MapID);

            Log.WriteLine(LogType.Success, "Logged into world as {0}.", chr.Name);
        }
Beispiel #4
0
        private void _BuildValuesUpdate(ObjectUpdateType type, ObjectUpdateFlags flags, ref PacketOut pkt, IPlayer plr)
        {
            UpdateMask mask = new UpdateMask(State.UpdateFields.Length);
            PacketOut  tmp  = new PacketOut();


            UpdatefieldFlags visibilityFlags = UpdatefieldFlags.UF_FLAG_PUBLIC;

            if (plr.GetPrimaryKeyLong() == this.GetPrimaryKeyLong())
            {
                visibilityFlags |= UpdatefieldFlags.UF_FLAG_PRIVATE;
            }

            var fieldFlags = GetFlagVisibility();

            for (var i = 0; i < State.UpdateFields.Length; ++i)
            {
                //if ((fieldFlags[i] & visibilityFlags) == 0)
                //    continue;
                tmp.Write(State.UpdateFields[i].data);
                mask.SetBit(i);
            }

            pkt.Write((byte)mask.GetMaxBlockCount());
            for (var i = 0; i < mask.GetMaxBlockCount(); ++i)
            {
                pkt.Write(mask.m_blocks[i]);
            }

            pkt.Write(tmp);
        }
Beispiel #5
0
        public Task <PacketOut> BuildCreateUpdateFor(IPlayer plr)
        {
            ObjectUpdateType updateType = ObjectUpdateType.UPDATETYPE_CREATE_OBJECT;

            ObjectUpdateFlags updateFlags = State.UpdateFlags;

            if (plr.GetPrimaryKeyLong() == this.GetPrimaryKeyLong())
            {
                updateFlags |= ObjectUpdateFlags.UPDATEFLAG_SELF;
            }

            if ((updateFlags & ObjectUpdateFlags.UPDATEFLAG_STATIONARY_POSITION) != 0)
            {
                if (_IsPlayer())
                {
                    updateType = ObjectUpdateType.UPDATETYPE_CREATE_OBJECT2;
                }
            }

            PacketOut p = new PacketOut();

            p.Write((byte)updateType);
            p.Write(pGUID);
            p.Write((byte)State.MyType);
            _BuildMovementUpdate(updateType, updateFlags, ref p);
            _BuildValuesUpdate(updateType, updateFlags, ref p, plr);
            return(Task.FromResult(p));
        }
        private void SalvageDroppedOff(Player plr, Part part)
        {
            for (int i = 0; i < 2; ++i)
            {
                foreach (Player player in Players[i])
                {
                    PacketOut Out = new PacketOut((byte)Opcodes.F_LOCALIZED_STRING, 64);

                    Out.WriteUInt16((ushort)256);

                    Out.WriteUInt16(0);
                    Out.WriteUInt16((ushort)Localized_text.TEXT_FLAG_CAPTURE);
                    Out.WriteUInt16(0);
                    Out.WriteUInt16(0x0003);
                    Out.WriteUInt16(0x0100);


                    byte[] bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(plr.Name);
                    Out.WriteByte((byte)(bytes.Length + 1));
                    Out.Write(bytes, 0, bytes.Length);


                    Out.Fill(0, 5);
                    if (plr.Realm == Realms.REALMS_REALM_DESTRUCTION)
                    {
                        Out.WriteByte(0x9C);
                    }
                    else
                    {
                        Out.WriteByte(0x9B);
                    }

                    Out.WriteUInt32(0);
                    Out.WriteUInt16(0x0100);

                    bytes = Encoding.GetEncoding("iso-8859-1").GetBytes("Salvage Part");
                    Out.WriteByte((byte)(bytes.Length + 1));
                    Out.Write(bytes, 0, bytes.Length);


                    Out.WriteByte(0);

                    player.SendPacket(Out);

                    SendObjectiveStates(player);
                }
            }
            ResetPart();
            GivePoints((plr.Realm == Realms.REALMS_REALM_ORDER ? 1 : 2), 75);
            //rewarding the player turning in the salvage so it gets more focused on objectives
            plr.AddRenown(70, true);
            if (plr.Realm == Realms.REALMS_REALM_ORDER)
            {
                _orderCart.PlayEffect(1136, new Point3D(_orderCart.Spawn.WorldX, _orderCart.Spawn.WorldY, _orderCart.Spawn.WorldZ + 50));
            }
            else
            {
                _destroCart.PlayEffect(1136, new Point3D(_destroCart.Spawn.WorldX, _destroCart.Spawn.WorldY, _destroCart.Spawn.WorldZ + 50));
            }
        }
Beispiel #7
0
        public async Task OnLogonChallenge(AuthLogonChallenge challenge)
        {
            Account = GrainFactory.GetGrain <IAccount>(challenge.account);

            if (!(await Account.IsValid()))
            {
                await SendAuthError(AuthError.NoAccount);

                return;
            }


            string password = await Account.GetPassword();

            Shared.BigInteger pass = new Shared.BigInteger(password, 16);

            //test

            string passwordPlain = await Account.GetPasswordPlain();

            string SRPHash      = challenge.account.ToUpper() + ":" + passwordPlain.ToUpper();
            var    SRPHashBytes = Encoding.UTF8.GetBytes(SRPHash);
            var    SRPCreds     = BigInt.Hash(SRPHashBytes); //The bytes were g

            BigInteger x = BigInt.Hash(s, SRPCreds);

            v = g.ModPow(x, N);

            b = new Shared.BigInteger(new Random(), 160);

            Shared.BigInteger gmod = g.ModPow(b, N);

            if (gmod < 0)
            {
                gmod += N;
            }

            B = ((v * 3) + gmod) % N;

            if (B < 0)
            {
                B += N;
            }

            Shared.BigInteger unk = new Shared.BigInteger(new Random(), 128);
            //I'm sure this is used for matrix proofing (2 factor auth)

            PacketOut rtn = new PacketOut(AuthOp.AUTH_LOGON_CHALLENGE);

            rtn.Write((byte)AuthError.Success);
            rtn.Write((byte)0);  //unknown
            rtn.WriteBigInt(B, 32);
            rtn.WriteBigIntLength(g, 1);
            rtn.WriteBigIntLength(N, 32);
            rtn.WriteBigInt(s, 32);
            rtn.WriteBigInt(unk, 16);
            rtn.Write((byte)0);    //security flag
            await SendPacket(rtn); //test
        }
Beispiel #8
0
        void HandleAccountDataUpdate(PacketIn inpacket)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_UPDATE_ACCOUNT_DATA);

            packet.Write(0x00000002);
            packet.Write((UInt32)0);
            Send(packet);
        }
Beispiel #9
0
        public async Task Logout(bool instant = false)
        {
            PacketOut p = new PacketOut(RealmOp.SMSG_LOGOUT_RESPONSE);

            p.Write((UInt32)0);                   //logoutReason
            p.Write(instant ? (byte)1 : (byte)0); //hasLogoutTimer
            await SendPacket(p);
        }
        public void CreatureQuery(WoWGuid guid, UInt32 entry)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_CREATURE_QUERY);

            packet.Write(entry);
            packet.Write(guid.GetNewGuid());
            Send(packet);
        }
        public void ObjectQuery(WoWGuid guid, UInt32 entry)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_Object_QUERY);

            packet.Write(entry);
            packet.Write(guid.GetNewGuid());
            Send(packet);
        }
Beispiel #12
0
        public void SendEmote(EmoteType EmoteType)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_TEXT_EMOTE);

            packet.Write((UInt32)EmoteType);
            packet.Write((UInt32)0x00);
            packet.Write((UInt64)0x00);
            Send(packet);
        }
        public void SendEmoteMsg(ChatMsg Type, Languages Language, string Message, string To)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_TEXT_EMOTE);

            packet.Write((UInt32)Type);
            packet.Write((UInt32)Language);
            packet.Write(Message);
            Send(packet);
        }
        public void JoinChannel(string channel, string password)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_JOIN_CHANNEL);

            packet.Write((UInt32)0);
            packet.Write((UInt16)0);
            packet.Write(channel);
            packet.Write("");
            Send(packet);
        }
        private void SalvagePickedUp(Player plr, Part part)
        {
            _salvage.RemoveFromWorld();

            _carrier = plr;

            EvtInterface.RemoveEvent(PartTimer);
            EvtInterface.AddEvent(PartTimer, 120000, 1);

            for (int i = 0; i < 2; ++i)
            {
                foreach (Player player in Players[i])
                {
                    PacketOut Out = new PacketOut((byte)Opcodes.F_LOCALIZED_STRING, 64);

                    Out.WriteUInt16((ushort)256);

                    Out.WriteUInt16(0);
                    Out.WriteUInt16((ushort)Localized_text.TEXT_FLAG_PICKUP);
                    Out.WriteUInt16(0);
                    Out.WriteUInt16(0x0003);
                    Out.WriteUInt16(0x0100);


                    byte[] bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(plr.Name);
                    Out.WriteByte((byte)(bytes.Length + 1));
                    Out.Write(bytes, 0, bytes.Length);


                    Out.Fill(0, 5);
                    if (plr.Realm == Realms.REALMS_REALM_DESTRUCTION)
                    {
                        Out.WriteByte(0x9C);
                    }
                    else
                    {
                        Out.WriteByte(0x9B);
                    }

                    Out.WriteUInt32(0);
                    Out.WriteUInt16(0x0100);

                    bytes = Encoding.GetEncoding("iso-8859-1").GetBytes("Salvage Part");
                    Out.WriteByte((byte)(bytes.Length + 1));
                    Out.Write(bytes, 0, bytes.Length);


                    Out.WriteByte(0);

                    player.SendPacket(Out);
                    SendObjectiveStates(player);
                }
            }
        }
Beispiel #16
0
        public async Task SendBindPointUpdate()
        {
            PacketOut p = new PacketOut(RealmOp.SMSG_BINDPOINTUPDATE);

            p.Write(State.BindX);
            p.Write(State.BindY);
            p.Write(State.BindZ);
            p.Write(State.BindMap);
            p.Write(State.BindArea);
            await SendPacket(p);
        }
Beispiel #17
0
 public static void Send(LobbyClient client)
 {
     Log.Debug("LOGIN_SALT", "Sent to " + client.Account.Username);
     client.serverModulus = Auth.computeServerModulus(client.Verifier);
     PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);
     Out.WriteUInt32Reverse((uint)client.Account.Index);
     Out.Write(client.serverModulus.B.ToByteArrayUnsigned(), 0, 64);
     Out.WriteByte(0x40);
     Out.WriteByte(0);
     Out.Write(client.Salt, 0, 10);
     client.Send(Out);
 }
        public void DoAuthSession()
        {
            try
            {
                PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_AUTH_SESSION);


                Sha1Hash sha = new Sha1Hash();
                sha.Update(mUsername);
                sha.Update(new byte[4]); // t
                sha.Update(ClientSeed);
                sha.Update(ServerSeed);
                sha.Update(mKey);

                byte[] Digest = sha.Final();

                packet.Write((UInt32)Config.Version.build);
                packet.Write((UInt32)0);
                packet.Write(mUsername);
                packet.Write((UInt32)0);
                packet.Write(ClientSeed);
                packet.Write((UInt64)0);
                packet.Write(Digest);



                bool WantToCrash = false;
                if (WantToCrash)
                {
                    byte[] addons  = { (byte)0x00 };
                    byte[] buffer2 = mClient.Shared.Compression.Compress(addons);
                    UInt32 Size    = (UInt32)addons.Length;
                    packet.Write(Size);
                    packet.Write(buffer2);
                }
                else
                {
                    byte[] addon_data = { 0x56, 0x01, 0x00, 0x00, 0x78, 0x9c, 0x75, 0xcc, 0xbd, 0x0e, 0xc2, 0x30, 0x0c, 0x04, 0xe0, 0xf2, 0x1e, 0xbc, 0x0c, 0x61, 0x40, 0x95, 0xc8, 0x42, 0xc3, 0x8c, 0x4c, 0xe2, 0x22, 0x0b, 0xc7, 0xa9, 0x8c, 0xcb, 0x4f, 0x9f, 0x1e, 0x16, 0x24, 0x06, 0x73, 0xeb, 0x77, 0x77, 0x81, 0x69, 0x59, 0x40, 0xcb, 0x69, 0x33, 0x67, 0xa3, 0x26, 0xc7, 0xbe, 0x5b, 0xd5, 0xc7, 0x7a, 0xdf, 0x7d, 0x12, 0xbe, 0x16, 0xc0, 0x8c, 0x71, 0x24, 0xe4, 0x12, 0x49, 0xa8, 0xc2, 0xe4, 0x95, 0x48, 0x0a, 0xc9, 0xc5, 0x3d, 0xd8, 0xb6, 0x7a, 0x06, 0x4b, 0xf8, 0x34, 0x0f, 0x15, 0x46, 0x73, 0x67, 0xbb, 0x38, 0xcc, 0x7a, 0xc7, 0x97, 0x8b, 0xbd, 0xdc, 0x26, 0xcc, 0xfe, 0x30, 0x42, 0xd6, 0xe6, 0xca, 0x01, 0xa8, 0xb8, 0x90, 0x80, 0x51, 0xfc, 0xb7, 0xa4, 0x50, 0x70, 0xb8, 0x12, 0xf3, 0x3f, 0x26, 0x41, 0xfd, 0xb5, 0x37, 0x90, 0x19, 0x66, 0x8f };
                    packet.Write(addon_data);
                }

                Send(packet);


                mCrypt = new PacketCrypt(mKey);
                mCrypt.Init();
            }
            catch (Exception e)
            {
                Log.WriteLine(LogType.Error, e.StackTrace);
            }
        }
        public void SendChatMsg(ChatMsg Type, Languages Language, string Message, string To)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_MESSAGECHAT);

            packet.Write((UInt32)Type);
            packet.Write((UInt32)Language);
            if ((Type == ChatMsg.Whisper || Type == ChatMsg.Channel) && To != "")
            {
                packet.Write(To);
            }
            packet.Write(Message);
            Send(packet);
        }
Beispiel #20
0
        public async Task SendActionButtons()
        {
            PacketOut pkt = new PacketOut(RealmOp.SMSG_ACTION_BUTTONS);

            pkt.Write((byte)1);

            for (var i = 0; i < 144; ++i)
            {
                pkt.Write((UInt32)0);
            }

            await SendPacket(pkt);
        }
Beispiel #21
0
        static public void Send(LobbyClient client)
        {
            Log.Debug("LOGIN_SALT", "Sent to " + client.Account.Username);
            client.serverModulus = Auth.computeServerModulus(client.Verifier);
            PacketOut Out = new PacketOut((uint)Opcodes.LOGIN_SALT);

            Out.WriteUInt32Reverse((uint)client.Account.Index);
            Out.Write(client.serverModulus.B.ToByteArrayUnsigned(), 0, 64);
            Out.WriteByte(0x40);
            Out.WriteByte(0);
            Out.Write(client.Salt, 0, 10);
            client.Send(Out);
        }
Beispiel #22
0
        public async Task BuildInitialUpdate()
        {
            var update = await BuildCreateUpdateFor(this as IPlayer);

            PacketOut pkt = new PacketOut(RealmOp.SMSG_UPDATE_OBJECT);

            pkt.Write((UInt32)1);
            pkt.Write(update);
            await SendPacket(pkt);

            await SendTimeSyncReq();
            await SendLoginEffect();
            await SendAuraUpdateAll();
        }
Beispiel #23
0
        static public void Send(LobbyClient client)
        {
            Log.Debug("LOGIN_SALT", "Send to " + client.Account.Email);
            MakeSalt(client);

            PacketOut Out = new PacketOut((UInt32)Opcodes.LOGIN_SALT);

            Out.WriteInt32R(client.Account.Id);
            Out.Write(client.B, 0, 64);
            Out.WriteByte(0x40);
            Out.WriteByte(0);
            Out.Write(client.Salt, 0, 10);
            client.SendTCP(Out);
        }
        public void QueryName(WoWGuid guid)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_NAME_QUERY);

            packet.Write(guid.GetNewGuid());
            Send(packet);
        }
Beispiel #25
0
        static public void F_REQUEST_CHAR(BaseClient client, PacketIn packet)
        {
            GameClient cclient = client as GameClient;

            cclient.State = (int)eClientState.CharScreen;

            UInt16 Operation = packet.GetUint16();

            if (Operation == 0x2D58)
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_ERROR);
                Out.WriteByte((byte)CharMgr.GetAccountRealm(cclient._Account.AccountId));
                cclient.SendTCP(Out);
            }

            else
            {
                PacketOut Out = new PacketOut((byte)Opcodes.F_REQUEST_CHAR_RESPONSE);


                Out.FillString(cclient._Account.Username, 25); // account name
                Out.WriteByte(0xFF);
                Out.WriteByte(CharMgr.MAX_SLOT);               // Max characters 20
                Out.WriteUInt16(0);                            // unk
                Out.WriteByte(0);                              // name changing tokens, 1 will enable button
                Out.WriteUInt16(0);                            //unk

                byte[] Chars = CharMgr.BuildCharactersList(cclient._Account.AccountId);
                Out.Write(Chars, 0, Chars.Length);
                cclient.SendTCP(Out);
            }
        }
Beispiel #26
0
        public async Task SendAuraUpdateAll()
        {
            PacketOut p = new PacketOut(RealmOp.SMSG_AURA_UPDATE_ALL);

            p.Write(pGUID);
            await SendPacket(p);
        }
Beispiel #27
0
        public static void CMSG_VerifyProtocolReq(BaseClient client, PacketIn packet)
        {
            Log.Debug("LServ", "CMSG_VerifyProtocolReq");
            Client cclient = (Client)client;

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

            byte[] IV_HASH1 = { 0x01, 0x53, 0x21, 0x4d, 0x4a, 0x04, 0x27, 0xb7, 0xb4, 0x59, 0x0f, 0x3e, 0xa7, 0x9d, 0x29, 0xe9 };
            byte[] IV_HASH2 = { 0x49, 0x18, 0xa1, 0x2a, 0x64, 0xe1, 0xda, 0xbd, 0x84, 0xd9, 0xf4, 0x8a, 0x8b, 0x3c, 0x27, 0x20 };

            ByteString iv1 = ByteString.CopyFrom(IV_HASH1);
            ByteString iv2 = ByteString.CopyFrom(IV_HASH2);

            VerifyProtocolReply.Builder verify = VerifyProtocolReply.CreateBuilder();
            verify.SetResultCode(VerifyProtocolReply.Types.ResultCode.RES_SUCCESS);

            verify.SetIv1(ByteString.CopyFrom(IV_HASH1));
            verify.SetIv2(ByteString.CopyFrom(IV_HASH2));



            Out.Write(verify.Build().ToByteArray());


            cclient.SendTCPCuted(Out);
        }
        public void QueryName(UInt64 guid)
        {
            PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_NAME_QUERY);

            packet.Write(guid);
            Send(packet);
        }
Beispiel #29
0
        public override void OnWorldPlayerEvent(string EventName, Player Plr, object Data)
        {
            if (EventName == "SEND_PACKAGES")
            {
                List <PacketInfo> P;
                if (Packets.TryGetValue(Plr.Info.Career, out P))
                {
                    foreach (PacketInfo Packet in P)
                    {
                        PacketOut Out = new PacketOut(Packet.Opcode);
                        Out.Write(Packet.Data, 3, Packet.Data.Length - 3);
                        Plr.SendPacket(Out);
                    }
                }

                if (Plr.Info.FirstConnect && Plr.GmLevel == 0)
                {
                    Plr.Info.FirstConnect = false;
                    if (!Plr.IsBanned)
                    {
                        PacketInfo Packet = Intros[Plr.Info.Career];
                        PacketOut  Out    = new PacketOut(Packet.Opcode);
                        Out.Write(Packet.Data, 3, Packet.Data.Length - 3);
                        Plr.SendPacket(Out);
                    }
                }
            }
        }
Beispiel #30
0
        public void SendUploadInfo(PatcherFile file)
        {
            _uploadFile = file;

            // Send out notification of file transfer
            PacketOut Out = new PacketOut((byte)Opcodes.LCR_DATA_START);

            Out.WriteUInt32((uint)_uploadFile.ArchiveID);
            Out.WriteUInt64(_uploadFile.FilenameHash);
            Out.WriteUInt32((uint)_uploadFile.FileHash);
            Out.WriteUInt64((ulong)_uploadFile.CompressedSize);
            Out.WriteUInt64((ulong)_uploadFile.FileSize);
            Out.WriteInt32((int)_uploadFile.Compress);
            Out.WriteInt32((int)_uploadFile.Type);
            Out.WriteInt32((int)_uploadFile.OldCrc);
            if (_uploadFile.Filename != null)
            {
                Out.WriteUInt16((ushort)_uploadFile.Filename.Length);
                Out.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(_uploadFile.Filename));
            }
            else
            {
                Out.WriteUInt16(0);
            }

            SendTCPRaw(Out);
        }
Beispiel #31
0
        public async Task SendCharCreateReply(LoginErrorCode code)
        {
            PacketOut p = new PacketOut(RealmOp.SMSG_CHAR_CREATE);

            p.Write((byte)code);
            await SendPacketRealm(p);
        }
Beispiel #32
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte slotId = packet.GetUint8();
     Character Info = cclient.Characters.Get(slotId);
     MySqlCommand cmd = new MySqlCommand("DELETE FROM `clientstatus` WHERE `name` = @name", Connection.Instance);
     try
     {
         cmd.Prepare();
         cmd.Parameters.AddWithValue("@name", Info.Name);
         cmd.ExecuteNonQuery();
     }
     catch (MySqlException) { }
     finally { cmd.Dispose(); }
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
     if (Info == null) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(Info.Slot);
         Out.WriteByte(Info.Gender);
         Out.WriteUInt32Reverse(Info.Playtime);
         Out.WriteUInt32Reverse(Info.Rank);
         Out.WriteByte(Info.Threat);
         Out.WriteUInt32Reverse(Info.Money);
         Out.WriteParsedString("APB-EMU", 60);
         byte[] Custom = Info.getCustom();
         Out.Write(Custom, 0, Custom.Length);
     }
     cclient.Send(Out);
     return 0;
 }
Beispiel #33
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = (LobbyClient)client;
     byte FileId = packet.GetUint8();
     UInt32 Version = packet.GetUint32Reversed();
     byte[] File = new byte[packet.Length - packet.Position];
     packet.Read(File, 0, File.Length);
     File = ZlibMgr.Decompress(File);
     Log.Debug("ConfigSave", "Config saved! FileId = " + FileId + " | Version = " + Version + " | Size = " + File.Length);
     Program.FileMgr.SaveInfo((int)cclient.Account.Index, FileId, File);
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CONFIGFILE_SAVE);
     Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
     Out.WriteByte(FileId);
     Out.Write(File, 0, File.Length);
     cclient.Send(Out);
     return 0;
 }
Beispiel #34
0
 public int HandlePacket(BaseClient client, PacketIn packet)
 {
     LobbyClient cclient = client as LobbyClient;
     byte slotId = packet.GetUint8();
     CharacterEntry Info = Databases.CharacterTable.SingleOrDefault(c => c.AccountIndex == cclient.Account.Index && c.Slot == slotId);
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_CHARACTER_INFO);
     if (Info.Index < 1) Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
     else
     {
         Out.WriteUInt32Reverse((uint)ResponseCodes.RC_SUCCESS);
         Out.WriteByte(Info.Slot);
         Out.WriteByte(Info.Gender);
         Out.WriteUInt32Reverse((uint)Info.Playtime);
         Out.WriteUInt32Reverse((uint)Info.Rank);
         Out.WriteByte(Info.Threat);
         Out.WriteUInt32Reverse((uint)Info.Money);
         Out.WriteParsedString(Info.Clan, 60);
         byte[] Custom = getCustom(Info);
         Out.Write(Custom, 0, Custom.Length);
     }
     cclient.Send(Out);
     return 0;
 }
Beispiel #35
0
        public byte[] BuildCharacters()
        {
            PacketOut Out = new PacketOut((byte)0);
            Out.Position = 0;
            Out.WriteUInt16(GetCharacterCount());

            Character Char = null;
            for (int i = 0; i < MAX_CHARS; ++i)
            {
                Char = Chars[i];

                if (Char == null)
                    Out.Write(new byte[280], 0, 280);
                else
                {
                    Out.FillString(Char.Name, 48);
                    Out.WriteByte(Char.Info[0].Level);
                    Out.WriteByte(Char.Career);
                    Out.WriteByte(Char.Realm);
                    Out.WriteByte(Char.Sex);
                    Out.WriteByte(Char.ModelId);
                    Out.WriteUInt16(Char.Info[0].ZoneId);
                    Out.Write(new byte[5], 0, 5);

                    Character_items Item = null;
                    for (UInt16 SlotId = 14; SlotId < 30; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);

                        Out.Write(new byte[6], 0, 6);
                    }

                    Out.Write(new byte[6], 0, 6);

                    for (int j = 0; j < 5; ++j)
                    {
                        Out.Write(new byte[6], 0, 6);
                        Out.WriteUInt16(0xFF00);
                    }

                    for (UInt16 SlotId = 10; SlotId < 13; ++SlotId)
                    {
                        Item = Char.GetItemInSlot(SlotId);
                        Out.WriteUInt16(0);
                        if (Item == null)
                            Out.WriteUInt16(0);
                        else
                            Out.WriteUInt16Reverse(Item.ModelId);
                    }

                    Out.Write(new byte[10], 0, 10);
                    Out.WriteUInt16(0xFF00);
                    Out.WriteByte(0);
                    Out.WriteByte(Char.Race);
                    Out.WriteUInt16(0);
                    Out.Write(Char.bTraits, 0, Char.bTraits.Length);
                    Out.Write(new byte[10], 0, 10);
                }
            }
            return Out.ToArray();
        }