internal ServerMessage SerializeUpdate(MessengerBuddy friend) { ServerMessage reply = new ServerMessage(Outgoing.FriendUpdate); reply.AppendInt32(0); // category count reply.AppendInt32(1); // number of updates reply.AppendInt32(0); // don't know friend.Serialize(reply, GetClient()); reply.AppendBoolean(false); return reply; }
internal void OnNewFriendship(uint friendID) { GameClient friend = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUserID(friendID); MessengerBuddy newFriend; if (friend == null || friend.GetHabbo() == null) { DataRow dRow; using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT id,username,motto,look,last_online,hide_inroom,hide_online FROM users " + "WHERE id = " + friendID); dRow = dbClient.getRow(); } newFriend = new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (int)dRow["last_online"], SilverwaveEnvironment.EnumToBool(dRow["hide_online"].ToString()), SilverwaveEnvironment.EnumToBool(dRow["hide_inroom"].ToString())); } else { Habbo user = friend.GetHabbo(); newFriend = new MessengerBuddy(friendID, user.Username, user.Look, user.Motto, 0, user.AppearOffline, user.HideInRoom); newFriend.UpdateUser(friend); } if (!friends.ContainsKey(friendID)) friends.Add(friendID, newFriend); GetClient().SendMessage(SerializeUpdate(newFriend)); }