public async Task HandleNameQuery(CMSG_NAME_QUERY pkt) { var player = GrainFactory.GetGrain<IPlayer>(pkt.guid.ToInt64()); var valid = await player.IsValid(); var guid_packed = new PackedGUID(pkt.guid); PacketOut p = new PacketOut(RealmOp.SMSG_NAME_QUERY_RESPONSE); p.Write(guid_packed); if (!valid) { p.Write((byte)1); //unknown await SendPacket(p); return; } p.Write((byte)0); //known p.WriteCString(await player.GetName()); var realmid = await player.GetRealmID(); if (realmid != await GetRealmID()) //player is on a different realm to this session, append their realm name { var realm_manager = GrainFactory.GetGrain<IRealmManager>(0); p.WriteCString(await realm_manager.GetRealmName((int)realmid)); } else p.Write((byte)0); //null string aka same realm aka dont show anything extra p.Write(await player.GetRace()); p.Write(await player.GetGender()); p.Write(await player.GetClass()); p.Write((byte)0); //isNameDeclined await SendPacket(p); }
public async Task OnRealmList() { if (!Authed) return; var realm_manager = GrainFactory.GetGrain<IRealmManager>(0); if (realm_manager == null) //something seriously went wrong! return; var realms = await realm_manager.GetRealms(); PacketOut p = new PacketOut(AuthOp.REALM_LIST); p.Write((UInt16)0); //size p.Write((int)0); //lets write a test realm! p.Write((UInt16)realms.Length); //realmCount foreach (var r in realms) { p.Write((byte)0); //type p.Write((byte)0); //status p.Write((byte)0); //flags p.WriteCString(r.RealmSettings.Name); p.WriteCString(r.RealmSettings.Address); p.Write(r.GetPopulationStatus()); p.Write((byte)1); //character count, TODO p.Write((byte)r.RealmSettings.Cat); p.Write((byte)0); //unknown } //this should be a loop based on realmcount in future //end loop p.Write((byte)0x10); p.Write((byte)0); //rewrite size p.strm.Position = 1; p.Write((UInt16)(p.strm.Length - 3)); p.strm.Position = p.strm.Length; await SendPacket(p); }