Пример #1
0
        protected override void HandleAppPacket(AppPacket packet)
        {
            switch ((WorldOp)packet.Opcode)
            {
            case WorldOp.GuildsList:
                break;

            case WorldOp.LogServer:
            case WorldOp.ApproveWorld:
            case WorldOp.EnterWorld:
            case WorldOp.ExpansionInfo:
                break;

            case WorldOp.SendCharInfo:
                var chars = new CharacterSelect(packet.Data);
                CharacterList?.Invoke(this, chars.Characters);
                break;

            case WorldOp.MessageOfTheDay:
                MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data));
                break;

            case WorldOp.ZoneServerInfo:
                var info = packet.Get <ZoneServerInfo>();
                ZoneServer?.Invoke(this, info);
                break;

            default:
                WriteLine($"Unhandled packet in WorldStream: {(WorldOp)packet.Opcode} (0x{packet.Opcode:X04})");
                Hexdump(packet.Data);
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Try to set the MOTD for the specified locale, if the locale does not exist returns false
        /// </summary>
        /// <param name="locale">Locale to set MOTD for</param>
        /// <param name="motd">New MOTD</param>
        /// <returns>True if the MOTD was set for the specified locale</returns>
        public static bool SetMOTD(string locale, string motd)
        {
            switch (locale.Trim().ToLower())
            {
            case "int": MOTD.eng = motd; break;

            case "det": MOTD.det = motd; break;

            case "est": MOTD.est = motd; break;

            case "frt": MOTD.frt = motd; break;

            case "itt": MOTD.itt = motd; break;

            case "kot": MOTD.kot = motd; break;

            case "tct": MOTD.tct = motd; break;

            case "rut": MOTD.rut = motd; break;

            default: return(false);
            }

            MOTD.Save();
            return(true);
        }
Пример #3
0
 public MOTD UpdateMOTD(MOTD motdUpdate)
 {
     if (motdUpdate.Id < 1)
     {
         throw new ArgumentException("You need to have an higher id than 0");
     }
     return(_MOTDRepo.UpdateMOTD(motdUpdate));
 }
Пример #4
0
 public MOTD AddMOTD(MOTD motd)
 {
     if (motd.TipOfTheDay == null)
     {
         throw new ArgumentException("You need to write a message");
     }
     return(_MOTDRepo.CreateMOTD(motd));
 }
Пример #5
0
        public void CreateMOTDWithName()
        {
            var motd = new MOTD()
            {
                TipOfTheDay = "One Dane per day, makes problems go away"
            };

            motdService.AddMOTD(motd);
        }
Пример #6
0
        public void CreateMOTDWithoutMessage()
        {
            var motd = new MOTD()
            {
            };

            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      motdService.AddMOTD(motd));

            Assert.AreEqual("You need to write a message", ex.Message);
        }
Пример #7
0
        public ActionResult <MOTD> post([FromBody] MOTD motd)
        {
            try
            {
                return(Ok(_MOTDServices.AddMOTD(motd)));
            }

            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Пример #8
0
        public void UpdateWithId0()
        {
            var motd = new MOTD()
            {
                Id          = 0,
                TipOfTheDay = "One Dane per day, makes problems go away"
            };

            Exception ex = Assert.ThrowsException <ArgumentException>(() =>
                                                                      motdService.UpdateMOTD(motd));

            Assert.AreEqual("You need to have an higher id than 0", ex.Message);
        }
Пример #9
0
        public ActionResult <MOTD> PutMOTD([FromRoute] int id, [FromBody] MOTD mOTD)
        {
            try
            {
                var entity = _MOTDServices.UpdateMOTD(mOTD);
                entity.TipOfTheDay = mOTD.TipOfTheDay;
                return(Ok(entity));
            }

            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Пример #10
0
        protected override void HandleAppPacket(AppPacket packet)
        {
            WriteLine($"Foo? {(WorldOp) packet.Opcode}");
            switch ((WorldOp)packet.Opcode)
            {
            case WorldOp.GuildsList:
                break;

            case WorldOp.LogServer:
            case WorldOp.ApproveWorld:
            case WorldOp.EnterWorld:
            case WorldOp.ExpansionInfo:
                break;

            case WorldOp.SendCharInfo:
                var chars = new CharacterSelect(packet.Data);
                CharacterList?.Invoke(this, chars.Characters);
                break;

            case WorldOp.MessageOfTheDay:
                MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data));
                break;

            case WorldOp.ZoneServerInfo:
                var info = packet.Get <ZoneServerInfo>();
                ZoneServer?.Invoke(this, info);
                break;

            case WorldOp.SetChatServer:
            case WorldOp.SetChatServer2:
                ChatServerList?.Invoke(this, packet.Data);
                break;

            case WorldOp.PostEnterWorld:
                // The emu doesn't do anything with ApproveWorld and WorldClientReady so we may be able to just skip them both.
                Send(AppPacket.Create(WorldOp.ApproveWorld));
                Send(AppPacket.Create(WorldOp.WorldClientReady));
                break;

            case WorldOp.ApproveName:
                CharacterCreateNameApproval?.Invoke(this, packet.Data[0] == 1);
                break;

            default:
                WriteLine($"Unhandled packet in WorldStream: {(WorldOp) packet.Opcode} (0x{packet.Opcode:X04})");
                Hexdump(packet.Data);
                break;
            }
        }
Пример #11
0
        protected override void HandleAppPacket(AppPacket packet)
        {
            switch ((WorldOp)packet.Opcode)
            {
            case WorldOp.GuildsList:
                UnityEngine.Debug.Log("World: GuildsList");
                break;

            case WorldOp.LogServer:
                UnityEngine.Debug.Log("World: ApproveWorld");
                break;

            case WorldOp.ApproveWorld:
                UnityEngine.Debug.Log("World: ApproveWorld");
                break;

            case WorldOp.EnterWorld:
                UnityEngine.Debug.Log("World: EnterWorld");
                break;

            case WorldOp.ExpansionInfo:
                UnityEngine.Debug.Log("World: ExpansionInfo");
                break;

            case WorldOp.SendCharInfo:
                var chars = new CharacterSelect(packet.Data);
                CharacterList?.Invoke(this, chars.Characters);
                UnityEngine.Debug.Log("World: SendCharInfo");
                break;

            case WorldOp.MessageOfTheDay:
                MOTD?.Invoke(this, Encoding.ASCII.GetString(packet.Data));
                UnityEngine.Debug.Log("World: MOTD");
                break;

            case WorldOp.ZoneServerInfo:
                var info = packet.Get <ZoneServerInfo>();
                ZoneServer?.Invoke(this, info);
                UnityEngine.Debug.Log("World: ZoneServerInfo");
                break;

            case WorldOp.SetChatServer:
                UnityEngine.Debug.Log("World: SetChatServer");
                break;

            case WorldOp.SetChatServer2:
                ChatServerList?.Invoke(this, packet.Data);
                UnityEngine.Debug.Log("World: SetChatSErver2");
                break;

            case WorldOp.PostEnterWorld:
                // The emu doesn't do anything with ApproveWorld and WorldClientReady so we may be able to just skip them both.
                Send(AppPacket.Create(WorldOp.ApproveWorld, null));
                Send(AppPacket.Create(WorldOp.WorldClientReady, null));
                UnityEngine.Debug.Log("World: ApproveWorld/WorldClientReady");
                break;

            case WorldOp.ApproveName:
                CharacterCreateNameApproval?.Invoke(this, packet.Data[0]);
                UnityEngine.Debug.Log("World: ApproveName");
                break;

            default:
                UnityEngine.Debug.LogError($"Unhandled packet in WorldStream: {(WorldOp)packet.Opcode} (0x{packet.Opcode:X04})");
                Hexdump(packet.Data);
                break;
            }
        }
Пример #12
0
        public void SendRoster(WorldSession session = null)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_GuildRoster);

            int size = GetMemberSize();

            writer.WriteBits(MOTD.Length, 11);
            writer.WriteBits(size, 18);

            foreach (Member pmember in MemberList)
            {
                var guid = pmember.CharGuid;

                writer.WriteBit(guid[3]);
                writer.WriteBit(guid[4]);
                writer.WriteBit(false); //Has Authenticator
                writer.WriteBit(false); //Can SoR
                writer.WriteBits(pmember.PublicNote.Length, 8);
                writer.WriteBits(pmember.OfficerNote.Length, 8);
                writer.WriteBit(guid[0]);
                writer.WriteBits(pmember.Name.Length, 7);
                writer.WriteBit(guid[1]);
                writer.WriteBit(guid[2]);
                writer.WriteBit(guid[6]);
                writer.WriteBit(guid[5]);
                writer.WriteBit(guid[7]);
            }
            writer.WriteBits(INFO.Length, 12);
            writer.BitFlush();
            foreach (Member pmember in MemberList)
            {
                Player pl = ObjMgr.FindPlayer(pmember.CharGuid);

                if (pl != null)
                {
                    var guid = new ObjectGuid(pl.GetGUIDLow());
                    writer.WriteUInt8(pl.getClass());
                    writer.WriteUInt32(0); //Guild Reputation
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0); //week activity
                    writer.WriteUInt32(pmember.RankId);
                    writer.WriteUInt32(0); //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }

                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Online);
                    writer.WriteUInt32(pl.GetZoneId());
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild week rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pl.getLevel());
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(guid[4]);
                    writer.WriteUInt8(0);//unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(0);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pl.Name.ToCharArray());
                }
                else
                {
                    var guid = pmember.CharGuid;

                    writer.WriteUInt8(pmember.Class);
                    writer.WriteUInt32(0);              //unk
                    writer.WriteByteSeq(guid[0]);
                    writer.WriteUInt64(0);              //week activity
                    writer.WriteUInt32(pmember.RankId); //rank
                    writer.WriteUInt32(0);              //GetAchievementPoints());

                    for (int j = 0; j < 2; j++)
                    {
                        writer.WriteUInt32(pmember.ProfessionList[j].Rank);
                        writer.WriteUInt32(pmember.ProfessionList[j].Level);
                        writer.WriteUInt32(pmember.ProfessionList[j].SkillId);
                    }
                    writer.WriteByteSeq(guid[2]);
                    writer.WriteUInt8((byte)GuildMemberFlags.Offline);
                    writer.WriteUInt32(pmember.ZoneId);
                    writer.WriteUInt64(0); //total activity
                    writer.WriteByteSeq(guid[7]);
                    writer.WriteUInt32(0); // remaining guild rep
                    writer.Write(pmember.PublicNote.ToCharArray());
                    writer.WriteByteSeq(guid[3]);
                    writer.WriteUInt8((byte)pmember.Level);
                    writer.WriteUInt32(0);//unk
                    writer.WriteByteSeq(guid[5]);
                    writer.WriteByteSeq(4);
                    writer.WriteUInt8(0);                                                                                                                   //unk
                    writer.WriteByteSeq(guid[1]);
                    writer.WriteFloat(Convert.ToSingle(new TimeSpan((DateTime.UtcNow.Ticks - (long)pmember.LogoutTime) / (int)TimeConstants.Day).Minutes)); // ?? time(NULL)-itr2->second.LogoutTime) / DAY);
                    writer.Write(pmember.OfficerNote.ToCharArray());
                    writer.WriteByteSeq(guid[6]);
                    writer.Write(pmember.Name.ToCharArray());
                }
            }
            writer.Write(INFO.ToCharArray());
            writer.Write(MOTD.ToCharArray());
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            if (session != null)
            {
                session.Send(writer);
            }
            else
            {
                BroadcastPacket(writer);
            }
        }
Пример #13
0
 public MOTD UpdateMOTD(MOTD motdUpdate)
 {
     _ctx.Attach(motdUpdate).State = EntityState.Modified;
     _ctx.SaveChanges();
     return(motdUpdate);
 }
Пример #14
0
 public MOTD CreateMOTD(MOTD motd)
 {
     _ctx.Attach(motd).State = EntityState.Added;
     _ctx.SaveChanges();
     return(motd);
 }