Ejemplo n.º 1
0
        public static void FriendIsOnline(LoginClient client)
        {
            LoginClient FriendOnline = null;
            BinWriter   flist        = null;

            if (client.Character.OnFriends != null)
            {
                foreach (DBFriendList Friend in client.Character.OnFriends)
                {
                    FriendOnline = LoginServer.GetLoginClientByCharacterID(Friend.Owner_ID);
                    if (FriendOnline != null)
                    {
                        flist = LoginClient.NewPacket(SMSG.FRIEND_STATUS);
                        //						Chat.System(FriendOnline, client.Character.Name+" is Online");
                        flist.Write((char)0x02);
                        flist.Write((ulong)client.Character.ObjectId);

                        flist.Write((int)client.Character.Zone);
                        flist.Write((int)client.Character.Level);
                        flist.Write((int)client.Character.Class);
                        FriendOnline.Send(flist);
                    }
                    FriendOnline = null;
                    flist        = null;
                }
            }
        }
Ejemplo n.º 2
0
 internal static void RemoveCharacter(LoginClient client)
 {
     if (client.Character != null)
     {
         m_loginCharacters.Remove(client.Character.ObjectId);
         if (client.Character.OnFriends != null)
         {
             BinWriter   flist        = null;
             LoginClient FriendOnline = null;
             foreach (DBFriendList Friend in client.Character.OnFriends)
             {
                 flist        = LoginClient.NewPacket(SMSG.FRIEND_STATUS);
                 FriendOnline = LoginServer.GetLoginClientByCharacterID(Friend.Owner_ID);
                 if (FriendOnline != null)
                 {
                     //							Chat.System(FriendOnline, client.Character.Name+" has Gone Offline");
                     flist.Write((char)0x03);
                     flist.Write((ulong)client.Character.ObjectId);
                     FriendOnline.Send(flist);
                 }
                 FriendOnline = null;
                 flist        = null;
             }
         }
         client.Character = null;
     }
 }
Ejemplo n.º 3
0
        static void OnChangeMap(WorldConnection connection, WORLDMSG msgID, BinReader data)
        {
            uint        id     = data.ReadUInt32();
            LoginClient client = LoginServer.GetLoginClientByCharacterID(id);

            client.IsChangingMap = true;
        }
Ejemplo n.º 4
0
        static bool OnMessageChat(LoginClient client, CMSG msgID, BinReader data)
        {
            CHATMESSAGETYPE type = (CHATMESSAGETYPE)data.ReadInt32();

            /*int language =*/ data.ReadInt32();
            string target = string.Empty;

            if (type == CHATMESSAGETYPE.WHISPER)
            {
                target = data.ReadString(0x100);
            }
            string msg = data.ReadString(0x100);

            if (msg.StartsWith("!") || msg.StartsWith("%"))
            {
                return(OnChatCommand(client, msg.Substring(1)));
            }
            switch (type)
            {
            case CHATMESSAGETYPE.SAY:
            case CHATMESSAGETYPE.YELL:
            case CHATMESSAGETYPE.EMOTE:
                return(false);                        // let worldserver handle it

            case CHATMESSAGETYPE.WHISPER:
            {
                DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBCharacter), "Name = '" + target + "'");
                if (objs.Length == 0)
                {
                    Chat.System(client, "No such player.");
                    return(true);
                }
                LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(objs[0].ObjectId);
                if (targetClient == null || targetClient.Character == null)
                {
                    Chat.System(client, "That player is not online.");
                    return(true);
                }
                Chat.Whisper(client, targetClient, msg);
                break;
            }

            default:
                Chat.System(client, "Received " + type + ": " + msg);
                break;
            }
            return(true);
        }
Ejemplo n.º 5
0
        static bool OnNameQuery(LoginClient client, CMSG msgID, BinReader data)
        {
            uint        id    = data.ReadUInt32();
            LoginClient other = LoginServer.GetLoginClientByCharacterID(id);

            if (other == null)
            {
                client.Close("Tried to query a char that wasn't online.");
                return(true);
            }
            BinWriter pkg = LoginClient.NewPacket(SMSG.NAME_QUERY_RESPONSE);

            pkg.Write(other.Character.ObjectId);
            pkg.Write(0);             // high id
            pkg.Write(other.Character.Name);
            pkg.Write((int)other.Character.Race);
            pkg.Write((int)other.Character.Gender);
            pkg.Write((int)other.Character.Class);
            client.Send(pkg);
            return(true);
        }
        /*
         * internal bool processWorldServerData()
         * {
         *      if(m_client.PendingSendData)
         *              m_client.SendWork();
         *      if(m_client.Connected == false)
         *              return false;
         *      byte[] data;
         *      while((data = m_client.GetNextPacketData()) != null)
         *              OnWorldServerData(data);
         *      return m_client.Connected;
         * }*/

        private void OnWorldServerData(ClientBase c, byte[] data)
        {
            BinReader read = new BinReader(data);

            read.BaseStream.Position += 4;             // skip len
            WORLDMSG msgID = (WORLDMSG)read.ReadInt32();

            if (msgID == WORLDMSG.SERVER_MESSAGE)
            {
                SMSG smsg = (SMSG)read.ReadInt32();
                Console.WriteLine("WorldServer sent: " + smsg);
                int       len = read.ReadInt32();
                BinWriter pkg = LoginClient.NewPacket(smsg);
                if (len > 0)
                {
                    pkg.Write(read.ReadBytes(len));
                }
                while (read.BaseStream.Position < read.BaseStream.Length)
                {
                    uint        plrID  = read.ReadUInt32();
                    LoginClient client = LoginServer.GetLoginClientByCharacterID(plrID);
                    if (client == null)
                    {
                        Console.WriteLine("client missing for plrID " + plrID + " while sending " + smsg.ToString());
                    }
                    else
                    {
                        client.Send(pkg);
                    }
                }
            }
            else if (msgID == WORLDMSG.SCRIPT_MESSAGE)
            {
                LoginServer.Scripts.OnScriptMessage(read.ReadInt32(), read);
            }
            else
            {
                LoginPacketManager.HandlePacket(this, msgID, read);
            }
        }
Ejemplo n.º 7
0
        static bool OnNameQuery(LoginClient client, CMSG msgID, BinReader data)
        {
            ulong       uid   = data.ReadUInt32();
            BinWriter   pkg   = LoginClient.NewPacket(SMSG.NAME_QUERY_RESPONSE);
            uint        id    = (uint)uid;
            LoginClient other = LoginServer.GetLoginClientByCharacterID(id);

            if (other == null)
            {
                DataObject[] objTemp = DataServer.Database.SelectObjects(typeof(DBCharacter), "Character_ID = '" + id + "'");
                if (objTemp.Length == 0)
                {
                    Console.WriteLine("Character not found");
                }
                else
                {
                    DBCharacter objCharacter = (DBCharacter)objTemp[0];
                    pkg.Write((ulong)objCharacter.ObjectId);
//					pkg.Write((uint)0); // high id
                    pkg.Write(objCharacter.Name);
                    pkg.Write((int)objCharacter.Race);
                    pkg.Write((int)objCharacter.Gender);
                    pkg.Write((int)objCharacter.Class);
                    client.Send(pkg);
                }
                return(true);
            }
            pkg.Write((ulong)other.Character.ObjectId);
//			pkg.Write((uint)0); // high id
//			pkg.Write(0);
            pkg.Write(other.Character.Name);
            pkg.Write((int)other.Character.Race);
            pkg.Write((int)other.Character.Gender);
            pkg.Write((int)other.Character.Class);
            client.Send(pkg);
            return(true);
        }
Ejemplo n.º 8
0
        static void OnPlayerLeaveWorld(WorldConnection connection, WORLDMSG msgID, BinReader data)
        {
            LoginClient client = LoginServer.GetLoginClientByCharacterID(data.ReadUInt32());

            if (client == null)
            {
                return;
            }
            if (client.IsLoggingOut)
            {
                LoginServer.RemoveCharacter(client);
                BinWriter pkg = LoginClient.NewPacket(SMSG.LOGOUT_COMPLETE);
                client.Send(pkg);
                client.IsLoggingOut    = false;
                client.WorldConnection = null;
            }
            else if (client.IsChangingMap)
            {
            }
            else
            {
                client.Close("Kicked from worldserver.");
            }
        }
Ejemplo n.º 9
0
        static bool OnMessageChat(LoginClient client, CMSG msgID, BinReader data)
        {
            CHATMESSAGETYPE type = (CHATMESSAGETYPE)data.ReadInt32();

            /*int language =*/ data.ReadInt32();
            string target = string.Empty;

            if (type == CHATMESSAGETYPE.WHISPER)
            {
                target = data.ReadString(0x100);
            }
            string msg = data.ReadString(0x100);

            if (msg.StartsWith("!") || msg.StartsWith("%"))
            {
                return(OnChatCommand(client, msg.Substring(1)));
            }
            switch (type)
            {
            case CHATMESSAGETYPE.PARTY:
            case CHATMESSAGETYPE.CHANNEL:
            case CHATMESSAGETYPE.CHANNEL_JOIN:
            case CHATMESSAGETYPE.CHANNEL_LEAVE:
            case CHATMESSAGETYPE.CHANNEL_LIST:
            case CHATMESSAGETYPE.CHANNEL_NOTICE:
            case CHATMESSAGETYPE.CHANNEL_NOTICE_USER:
            case CHATMESSAGETYPE.SAY:
            case CHATMESSAGETYPE.YELL:
            case CHATMESSAGETYPE.EMOTE:
                return(false);                        // let worldserver handle it

            case CHATMESSAGETYPE.WHISPER:
            {
                DataObject[] objs = DataServer.Database.SelectObjects(typeof(DBCharacter), "Name = '" + target + "'");
                if (objs.Length == 0)
                {
                    Chat.System(client, "No such player.");
                    return(true);
                }
                LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(objs[0].ObjectId);
                if (targetClient == null || targetClient.Character == null)
                {
                    Chat.System(client, "That player is not online.");
                    return(true);
                }
                Chat.Whisper(client, targetClient, msg);
                break;
            }

            case CHATMESSAGETYPE.GUILD:
            {
                DBGuild guild = client.Character.Guild;
                if (guild == null)
                {
                    return(true);
                }
                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.SAY) == (uint)GUILDFLAGS.SAY)
                {
                    foreach (DBGuildMembers member in guild.Members)
                    {
                        if ((guild.getRankFlags(member.Rank) & (uint)GUILDFLAGS.LISTEN) == (uint)GUILDFLAGS.LISTEN)
                        {
                            LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(member.MemberID);
                            if (targetClient == null || targetClient.Character == null)
                            {
                                continue;
                            }
                            else
                            {
                                Chat.GuildSay(client.Character.ObjectId, targetClient, msg, CHATMESSAGETYPE.GUILD);
                            }
                        }
                    }
                }
                else
                {
                    Chat.GuildSay(0, client, "You do not have permission", CHATMESSAGETYPE.GUILD);
                }

                break;
            }

            case CHATMESSAGETYPE.OFFICER:
            {
                DBGuild guild = client.Character.Guild;
                if (guild == null)
                {
                    return(true);
                }
                if ((guild.getRankFlags(client.Character.GuildRank) & (uint)GUILDFLAGS.OFFICER_SAY) == (uint)GUILDFLAGS.OFFICER_SAY)
                {
                    foreach (DBGuildMembers member in guild.Members)
                    {
                        if ((guild.getRankFlags(member.Rank) & (uint)GUILDFLAGS.OFFICER_LISTEN) == (uint)GUILDFLAGS.OFFICER_LISTEN)
                        {
                            LoginClient targetClient = LoginServer.GetLoginClientByCharacterID(member.MemberID);
                            if (targetClient == null || targetClient.Character == null)
                            {
                                continue;
                            }
                            else
                            {
                                Chat.GuildSay(client.Character.ObjectId, targetClient, msg, CHATMESSAGETYPE.OFFICER);
                            }
                        }
                    }
                }
                else
                {
                    Chat.GuildSay(0, client, "You do not have permission", CHATMESSAGETYPE.GUILD);
                }

                break;
            }

            default:
                Chat.System(client, "Received " + type + ": " + msg);
                break;
            }
            return(true);
        }