static bool OnPlayerLogoutCancel(LoginClient client, CMSG msgID, BinReader data) { BinWriter pkg = LoginClient.NewPacket(SMSG.LOGOUT_CANCEL_ACK); client.Send(pkg); client.Send(pkg); client.IsLoggingOut = false; if (logOutEvent != null) { EventManager.RemoveEvent(logOutEvent); logOutEvent = null; } return(true); }
static bool OnCreatureQuery(LoginClient client, CMSG msgID, BinReader data) { uint id = data.ReadUInt32(); DBCreature creature = (DBCreature)DataServer.Database.FindObjectByKey(typeof(DBCreature), id); if (creature == null) { client.Close("OnCreatureQuery(): id didn't exists."); return(true); } BinWriter w = LoginClient.NewPacket(SMSG.CREATURE_QUERY_RESPONSE); w.Write(creature.ObjectId); w.Write(creature.Name); w.Write(creature.Name1); w.Write(creature.Name2); w.Write(creature.Name3); w.Write(creature.Title); w.Write(creature.Flags); w.Write(creature.CreatureType); w.Write(creature.CreatureFamily); w.Write(0); // unknown client.Send(w); return(true); }
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; } } }
public static void SendWhoList(LoginClient whoClient) { BinWriter pkg = LoginClient.NewPacket(SMSG.WHO); pkg.Write((int)Instance.ClientCount); pkg.Write((int)Instance.ClientCount); IEnumerator e = Instance.Clients.GetEnumerator(); // int Group = 0; // 0 = No, 1 = Yes while (e.MoveNext()) { try { pkg.Write((string)((LoginClient)e.Current).Character.Name); pkg.Write((string)((LoginClient)e.Current).Character.GuildName); pkg.Write((int)((LoginClient)e.Current).Character.Level); pkg.Write((int)((LoginClient)e.Current).Character.Class); pkg.Write((int)((LoginClient)e.Current).Character.Race); pkg.Write((int)((LoginClient)e.Current).Character.Zone); pkg.Write((int)((LoginClient)e.Current).Character.GroupLook); } catch (Exception) { } } whoClient.Send(pkg); }
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; } }
public static void System(LoginClient client, string msg) { BinWriter pkg = LoginClient.NewPacket(SMSG.MESSAGECHAT); pkg.Write((byte)CHATMESSAGETYPE.SYSTEM); pkg.Write((int)0); pkg.Write((ulong)0); pkg.Write(msg); pkg.Write((byte)0); client.Send(pkg); }
public static void GuildSay(uint from, LoginClient client, string msg, CHATMESSAGETYPE mtype) { BinWriter pkg = LoginClient.NewPacket(SMSG.MESSAGECHAT); pkg.Write((byte)mtype); pkg.Write((int)0); pkg.Write((ulong)from); pkg.Write((int)msg.Length + 1); pkg.Write(msg); pkg.Write((byte)0); client.Send(pkg); }
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); }
public static void Whisper(LoginClient from, LoginClient to, string msg) { BinWriter pkg = LoginClient.NewPacket(SMSG.MESSAGECHAT); pkg.Write((byte)CHATMESSAGETYPE.WHISPER); pkg.Write((int)0); // language pkg.Write((ulong)from.Character.ObjectId); // guid pkg.Write(msg); pkg.Write((byte)0); // status flags 1: afk, 2: dnd, 3: gm to.Send(pkg); pkg = LoginClient.NewPacket(SMSG.MESSAGECHAT); pkg.Write((byte)CHATMESSAGETYPE.WHISPER_INFORM); pkg.Write((int)0); pkg.Write((ulong)to.Character.ObjectId); pkg.Write(msg); pkg.Write((byte)0); from.Send(pkg); }
static bool OnItemQuerySingle(LoginClient client, CMSG msgID, BinReader data) { uint id = data.ReadUInt32(); DBItemTemplate template = (DBItemTemplate)DataServer.Database.FindObjectByKey(typeof(DBItemTemplate), id); if (template == null) { Console.WriteLine("Client requested an item template that didn't exist:" + id); return(true); } BinWriter w = LoginClient.NewPacket(SMSG.ITEM_QUERY_SINGLE_RESPONSE); w.Write(id); foreach (SerializeValue value in itemTemplateValues) { value.Serialize(template, w); } client.Send(w); return(true); }
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); } }
internal static void ChangeMap(LoginClient client) { client.WorldConnection = (WorldConnection)m_worldMapServer[client.Character.WorldMapID]; if (client.WorldConnection == null) { client.Close("(ChangeMap) Missing worldserver for world map id " + client.Character.WorldMapID); return; } DBWorldMap map = (DBWorldMap)DataServer.Database.FindObjectByKey(typeof(DBWorldMap), client.Character.WorldMapID); client.Character.Continent = (uint)map.Continent; BinWriter pkg = LoginClient.NewPacket(SMSG.NEW_WORLD); pkg.Write((byte)client.Character.Continent); pkg.WriteVector(client.Character.Position); pkg.Write(client.Character.Facing); client.Send(pkg); FriendIsOnline(client); client.WorldConnection.OnEnterWorld(client.Character, client.Account.AccessLvl); }
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."); } }