Exemple #1
0
        static public void Send(LobbyClient client)
        {
            client.Characters = Databases.CharacterTable.Select(c => c.AccountIndex == client.Account.Index);
            PacketOut Out = new PacketOut((uint)Opcodes.CHARACTER_LIST);

            Out.WriteByte((byte)client.Characters.Count);
            lock (Program.worldListener.Worlds)
            {
                foreach (CharacterEntry chr in client.Characters)
                {
                    Out.WriteByte(chr.Slot);
                    Out.WriteByte(chr.Faction);
                    Out.WriteByte(1);
                    Out.WriteUInt32Reverse((uint)chr.World);
                    World.World info = null;
                    Program.worldListener.Worlds.TryGetValue((uint)chr.World, out info);
                    if (info != null)
                    {
                        Out.WriteParsedString(info.Name, 32);
                    }
                    else
                    {
                        Out.WriteParsedString("(undefined)", 32);
                    }
                    Out.WriteParsedString(chr.Name, 32);
                }
            }
            client.Send(Out);
            if (client.Characters.Count <= 0)
            {
                WORLD_LIST.SendWorldList(client);
            }
        }
Exemple #2
0
        public static void Send(LobbyClient cclient, string Reason, string Information)
        {
            PacketOut Out = new PacketOut((uint)Opcodes.KICK);

            Out.WriteParsedString(Reason);
            Out.WriteParsedString(Information);
            cclient.Send(Out);
        }
Exemple #3
0
        public static void Send(LobbyClient cclient)
        {
            PacketOut Out = new PacketOut((uint)Opcodes.WORLD_LIST);

            Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
            lock (Program.worldListener.Worlds)
            {
                Out.WriteUInt16Reverse((ushort)Program.worldListener.Worlds.Count);
                foreach (KeyValuePair <uint, World.World> info in Program.worldListener.Worlds)
                {
                    Out.WriteUInt32Reverse(info.Key);
                    Out.WriteParsedString(info.Value.Name, 32);
                    Out.WriteByte((byte)info.Value.Id);
                    Out.WriteByte(0); //m_nPopulation %d
                    Out.WriteByte(0); //m_nEnfFaction %d
                    Out.WriteByte(0); //m_nCrimFaction %d
                    Out.WriteByte(0); //m_nPremiumOnly %d
                    Out.WriteByte(info.Value.IP1);
                    Out.WriteByte(info.Value.IP2);
                    Out.WriteByte(info.Value.IP3);
                    Out.WriteByte(info.Value.IP4);
                }
            }
            cclient.Send(Out);
        }
 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;
 }
Exemple #5
0
 public static void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.ANS_LOGIN_SUCCESS);
     Out.WriteParsedString("Welcome to rebornAPB", 48);
     Out.WriteUInt32Reverse(client.Account.IsAdmin);
     Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
     Out.WriteByte(0x13);
     Out.WriteByte(0x29);
     Out.WriteUInt16Reverse(0x12);
     Out.WriteByte(0x0E);
     Out.WriteByte(0x07);
     Out.WriteUInt16Reverse(9999);
     Out.WriteInt32Reverse(1450);
     Out.WriteUInt32Reverse((uint)client.Account.RTW_Points);
     for (int i = 1; i < 6; ++i) Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion((int)client.Account.Index, i, true, "", ""));
     Out.WriteInt32Reverse(0);
     Out.WriteUInt16(0x957D);
     Out.WriteUInt16(0x0400);
     Out.WriteUInt16(0x5052);
     Out.WriteUInt16(0x4F45);
     Out.WriteUInt16(0x552E);
     Out.WriteUInt16(0x3232);
     Out.WriteUInt16(0x3738);
     Out.WriteUInt16(0x3031);
     Out.WriteUInt16(0);
     Out.WriteUInt16(0x0067);
     Out.WriteUInt64(0x526C624331313256);
     Out.WriteUInt64(0x486E314100000000);
     Out.WriteUInt16(0);
     Out.WriteStringBytes("");
     Out.WriteByte(0);
     client.Send(Out);
 }
Exemple #6
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((uint)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);
        }
Exemple #7
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient  = (WorldClient)client;
            string      charName = packet.GetParsedString();

            PacketOut      Out   = new PacketOut((uint)Opcodes.ANS_CHARACTERFINDER_INFO);
            int            count = Databases.CharacterTable.Count(c => c.Name == charName);
            CharacterEntry chr   = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName);

            if (cclient.Character.Name == charName)
            {
                Out.WriteUInt32Reverse(0x01);
            }
            else
            {
                if (cclient.Account.Index == chr.AccountIndex)
                {
                    Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FAILED);
                }
                else
                {
                    if (count < 1)
                    {
                        Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER);
                    }
                    else
                    {
                        if (chr.IsOnline == 1)
                        {
                            Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
                            Out.WriteUInt32Reverse((uint)chr.Index);
                            Out.WriteParsedString(charName);
                            Out.WriteByte(chr.Faction);
                            Out.WriteByte(chr.LFG);
                            Out.WriteByte(chr.GroupStatus);
                            Out.WriteByte(chr.IsGroupPublic);
                            Out.WriteByte(chr.GroupInvite);
                            uint code = (uint)(chr.DistrictType << 24);
                            code += chr.DistrictID;
                            Districts.District d;
                            Program.districtsListener.Districts.TryGetValue(code, out d);
                            Out.WriteUInt32(code);
                            Out.WriteByte(d.isFull());
                            Out.WriteFloat(1.00f);
                        }
                        else
                        {
                            Out.WriteUInt32Reverse((uint)ResponseCodes.RC_CHARACTERFINDER_INFO_NO_CHARACTER);
                        }
                    }
                }
            }
            cclient.Send(Out);
            return(0);
        }
Exemple #8
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient  = (WorldClient)client;
            string      charName = packet.GetParsedString();

            PacketOut      Out   = new PacketOut((uint)Opcodes.ANS_FRIENDLIST_ADD);
            int            count = Databases.CharacterTable.Count(c => c.Name == charName);
            CharacterEntry chr   = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName);

            if (cclient.Character.Name == charName)
            {
                Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SELF);
            }
            else
            {
                if (cclient.Character.AccountIndex == chr.AccountIndex)
                {
                    Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_SAME_ACCOUNT);
                }
                else
                {
                    if (count < 1)
                    {
                        Out.WriteUInt32Reverse((uint)ResponseCodes.RC_FRIENDLIST_ADD_INVALID_NAME);
                    }
                    else if (count >= 1)
                    {
                        Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
                        Out.WriteParsedString(charName);
                        Out.WriteByte(chr.Faction);
                        Out.WriteByte(chr.IsOnline);
                        Out.WriteUInt32Reverse((uint)chr.Index);
                        Out.WriteByte(chr.LFG);
                        Out.WriteByte(chr.GroupStatus);
                        Out.WriteByte(chr.IsGroupPublic);
                        Out.WriteByte(chr.GroupInvite);
                        uint code = (uint)(chr.DistrictType << 24);
                        code += chr.DistrictID;
                        Districts.District d;
                        Program.districtsListener.Districts.TryGetValue(code, out d);
                        Out.WriteUInt32(code);
                        Out.WriteByte(d.isFull());
                        FriendEntry frnd = new FriendEntry();
                        frnd.Index = Databases.FriendTable.GenerateIndex();
                        frnd.CharacterOwnerIndex  = cclient.Character.Index;
                        frnd.CharacterFriendIndex = chr.Index;
                        Databases.FriendTable.Add(frnd);
                    }
                }
            }
            cclient.Send(Out);
            return(0);
        }
Exemple #9
0
 static public void Send(LobbyClient client)
 {
     client.Characters = Databases.CharacterTable.Select(c => c.AccountIndex == client.Account.Index);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte((Byte)client.Characters.Count);
     lock (Program.worldListener.Worlds)
     {
         foreach (CharacterEntry chr in client.Characters)
         {
             Out.WriteByte(chr.Slot);
             Out.WriteByte(chr.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse((uint)chr.World);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue((uint)chr.World, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(chr.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Count <= 0) WORLD_LIST.Send(client);
 }
Exemple #10
0
 static public void Send(LobbyClient client)
 {
     client.Characters = new Characters(client.Account.Id);
     PacketOut Out = new PacketOut((UInt32)Opcodes.CHARACTER_LIST);
     Out.WriteByte(client.Characters.Length);
     lock (Program.worldListener.Worlds)
     {
         foreach (KeyValuePair<Byte, Character> pair in client.Characters.List)
         {
             Out.WriteByte(pair.Value.Slot);
             Out.WriteByte(pair.Value.Faction);
             Out.WriteByte(1);
             Out.WriteUInt32Reverse(pair.Value.WorldId);
             World.World info = null;
             Program.worldListener.Worlds.TryGetValue(pair.Value.WorldId, out info);
             if (info != null) Out.WriteParsedString(info.Name, 32);
             else Out.WriteParsedString("(undefined)", 32);
             Out.WriteParsedString(pair.Value.Name, 32);
         }
     }
     client.Send(Out);
     if (client.Characters.Length <= 0) WORLD_LIST.Send(client);
 }
Exemple #11
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient  = (WorldClient)client;
            ushort      type     = packet.GetUint16Reversed();
            uint        charUID  = packet.GetUint32Reversed();
            string      charName = packet.GetPascalString();

            PacketOut Out = new PacketOut((uint)Opcodes.ANS_NAME_QUERY);

            Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
            Out.WriteUInt16Reverse(type);
            Out.WriteUInt32Reverse(charUID);
            Out.WriteParsedString(charName);
            cclient.Send(Out);
            return(0);
        }
Exemple #12
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient     = (WorldClient)client;
            uint        instanceUID = packet.GetUint32();

            PacketOut Out = new PacketOut((uint)Opcodes.ANS_GROUP_LIST);

            Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
            Out.WriteUInt32(instanceUID);
            Out.WriteByte(0);
            Out.WriteUInt32Reverse(0); //leader's charUID
            Out.WriteParsedString(""); //leader
            Out.WriteByte(0);          //members amount
            Out.WriteByte(0);          //rating
            Out.WriteByte(0);          //threat
            cclient.Send(Out);
            return(0);
        }
Exemple #13
0
 static public void Send(LobbyClient client)
 {
     PacketOut Out = new PacketOut((UInt32)Opcodes.WORLD_LIST);
     Out.WriteInt32Reverse((int)ResponseCodes.RC_SUCCESS);
     lock (Program.worldListener.Worlds)
     {
         Out.WriteUInt16Reverse((UInt16)Program.worldListener.Worlds.Count);
         foreach (KeyValuePair<UInt32, World.World> info in Program.worldListener.Worlds)
         {
             Out.WriteUInt32Reverse((UInt32)info.Key);
             Out.WriteParsedString(info.Value.Name, 32);
             Out.WriteByte(1);
             Out.WriteByte(info.Value.Population);
             Out.WriteByte(info.Value.EnforcerRecommended ? (Byte)1 : (Byte)0);
             Out.WriteByte(info.Value.CriminalRecommended ? (Byte)1 : (Byte)0);
         }
     }
     client.Send(Out);
 }
Exemple #14
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient  = (WorldClient)client;
            string      charName = packet.GetParsedString();

            PacketOut      Out   = new PacketOut((uint)Opcodes.ANS_IGNORELIST_ADD);
            int            count = Databases.CharacterTable.Count(c => c.Name == charName);
            CharacterEntry chr   = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName);

            if (cclient.Character.Name == charName)
            {
                Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SELF);
            }
            else
            {
                if (cclient.Character.AccountIndex == chr.AccountIndex)
                {
                    Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SAME_ACCOUNT);
                }
                else
                {
                    if (count < 1)
                    {
                        Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_NOT_FOUND);
                    }
                    else if (count >= 1)
                    {
                        Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
                        Out.WriteUInt32Reverse((uint)chr.Index);
                        Out.WriteParsedString(charName);
                        IgnoreEntry ign = new IgnoreEntry();
                        ign.Index = Databases.FriendTable.GenerateIndex();
                        ign.CharacterOwnerIndex  = cclient.Character.Index;
                        ign.CharacterIgnoreIndex = chr.Index;
                        Databases.IgnoreTable.Add(ign);
                    }
                }
            }
            cclient.Send(Out);
            return(0);
        }
Exemple #15
0
        static public void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((uint)Opcodes.ANS_LOGIN_SUCCESS);

            Out.WriteParsedString("Welcome to rebornAPB", 48);
            Out.WriteUInt32Reverse(1);
            Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
            Out.WriteUInt32Reverse(client.Account.IsAdmin);
            Out.WriteInt32Reverse(0);
            Out.WriteInt32Reverse(0);
            Out.WriteInt32Reverse(0);
            Out.WriteInt32Reverse(0);
            Out.WriteInt32Reverse(0);
            Out.WriteString("");
            Out.WriteInt32(0);
            Out.WriteInt32(0);
            Out.WriteInt32Reverse(0);
            Out.WriteString("");
            Out.WriteInt32Reverse(0);
            client.Send(Out);
        }
Exemple #16
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;
 }
Exemple #17
0
        static public void Send(LobbyClient client)
        {
            PacketOut Out = new PacketOut((uint)Opcodes.ANS_LOGIN_SUCCESS);

            Out.WriteParsedString("Welcome to rebornAPB", 48);
            Out.WriteUInt32Reverse(client.Account.IsAdmin);
            Out.WriteInt64Reverse(TCPManager.GetTimeStamp());
            Out.WriteByte(0x13);
            Out.WriteByte(0x29);
            Out.WriteUInt16Reverse(0x12);
            Out.WriteByte(0x0E);
            Out.WriteByte(0x07);
            Out.WriteUInt16Reverse(9999);
            Out.WriteInt32Reverse(1450);
            Out.WriteUInt32Reverse((uint)client.Account.RTW_Points);
            for (int i = 1; i < 6; ++i)
            {
                Out.WriteInt32Reverse(Program.FileMgr.GetFileVersion(client.Account.Index, i, true, "", ""));
            }
            Out.WriteInt32Reverse(0);
            Out.WriteUInt16(0x957D);
            Out.WriteUInt16(0x0400);
            Out.WriteUInt16(0x5052);
            Out.WriteUInt16(0x4F45);
            Out.WriteUInt16(0x552E);
            Out.WriteUInt16(0x3232);
            Out.WriteUInt16(0x3738);
            Out.WriteUInt16(0x3031);
            Out.WriteUInt16(0);
            Out.WriteUInt16(0x0067);
            Out.WriteUInt64(0x526C624331313256);
            Out.WriteUInt64(0x486E314100000000);
            Out.WriteUInt16(0);
            Out.WriteStringBytes("");
            Out.WriteByte(0);
            client.Send(Out);
        }