示例#1
0
        internal void HandlePublicista(string Message)
        {
            bool flag = false;

            if (this.PublicistaCount < 2)
            {
                CyberEnvironment.GetGame().GetClientManager().SendSuperNotif("Hey!!", "Please stop advertising other hotels. You will be muted if you do it again.<br /> Need more information? Click the link below.", "frank10", this, "event:", "ok", false, false);
            }
            else if (this.PublicistaCount < 3)
            {
                CyberEnvironment.GetGame().GetClientManager().SendSuperNotif("You have been muted", "Sorry but you were muted by <b>advertising other hotel</b>", "frank10", this, "event:", "ok", false, false);
                this.GetHabbo().Mute();
                flag = true;
            }
            else if (this.PublicistaCount >= 3)
            {
                return;
            }
            ServerMessage serverMessage = new ServerMessage(Outgoing.SuperNotificationMessageComposer);

            serverMessage.AppendString("staffcloud");
            serverMessage.AppendInt32(4);
            serverMessage.AppendString("title");
            serverMessage.AppendString("Possible advertiser found!");
            serverMessage.AppendString("message");
            serverMessage.AppendString(string.Concat(new string[]
            {
                "This user has been detected as advertiser: <b>",
                this.GetHabbo().Username,
                ".</b> Is he/she advertising an hotel like this?:<br />\"<b>",
                Message,
                "</b>\".<br /><br />",
                flag ? "<i>The user was automatically muted.</i>" : "The user was automatically warned.</i>"
            }));
            serverMessage.AppendString("link");
            serverMessage.AppendString("event:");
            serverMessage.AppendString("linkTitle");
            serverMessage.AppendString("ok");
            CyberEnvironment.GetGame().GetClientManager().StaffAlert(serverMessage, 0U);
        }
示例#2
0
        internal void SerializeGroupInfo(Guild Group, ServerMessage Response, GameClient Session, bool NewWindow = false)
        {
            DateTime dateTime  = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DateTime dateTime2 = dateTime.AddSeconds((double)Group.CreateTime);

            if (Group == null || Session == null)
            {
                return;
            }
            Response.Init(Outgoing.GroupDataMessageComposer);
            Response.AppendUInt(Group.Id);
            Response.AppendBoolean(true);
            Response.AppendUInt(Group.State);
            Response.AppendString(Group.Name);
            Response.AppendString(Group.Description);
            Response.AppendString(Group.Badge);
            Response.AppendUInt(Group.RoomId);
            Response.AppendString((CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId) == null) ? "No room found.." : CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId).Name);
            Response.AppendInt32((Group.CreatorId == Session.GetHabbo().Id) ? 3 : (Group.Requests.Contains(Session.GetHabbo().Id) ? 2 : (Group.Members.ContainsKey(Session.GetHabbo().Id) ? 1 : 0)));
            Response.AppendInt32(Group.Members.Count);
            Response.AppendBoolean(Session.GetHabbo().FavouriteGroup == Group.Id);
            Response.AppendString(string.Concat(new object[]
            {
                dateTime2.Day,
                "-",
                dateTime2.Month,
                "-",
                dateTime2.Year
            }));
            Response.AppendBoolean(Group.CreatorId == Session.GetHabbo().Id);
            Response.AppendBoolean(Group.Admins.ContainsKey(Session.GetHabbo().Id));
            Response.AppendString((CyberEnvironment.getHabboForId(Group.CreatorId) == null) ? "" : CyberEnvironment.getHabboForId(Group.CreatorId).Username);
            Response.AppendBoolean(NewWindow);
            Response.AppendBoolean(Group.AdminOnlyDeco == 0u);
            Response.AppendInt32(Group.Requests.Count);
            Response.AppendBoolean(Group.HasForum);
            Session.SendMessage(Response);
        }
示例#3
0
        internal GroupForumPost(DataRow Row)
        {
            this.Id        = uint.Parse(Row["id"].ToString());
            this.ParentId  = uint.Parse(Row["parent_id"].ToString());
            this.GroupId   = uint.Parse(Row["group_id"].ToString());
            this.Timestamp = int.Parse(Row["timestamp"].ToString());
            this.Pinned    = Row["pinned"].ToString() == "1";
            this.Locked    = Row["locked"].ToString() == "1";
            this.Hidden    = Row["hidden"].ToString() == "1";

            this.PosterId    = uint.Parse(Row["poster_id"].ToString());
            this.PosterName  = Row["poster_name"].ToString();
            this.PosterLook  = Row["poster_look"].ToString();
            this.Subject     = Row["subject"].ToString();
            this.PostContent = Row["post_content"].ToString();
            this.Hider       = Row["post_hider"].ToString();

            this.MessageCount = 0;
            if (ParentId == 0)
            {
                this.MessageCount = CyberEnvironment.GetGame().GetGroupManager().GetMessageCountForThread(Id);
            }
        }
示例#4
0
        internal static void Process(object Caller)
        {
            int      clientCount      = CyberEnvironment.GetGame().GetClientManager().ClientCount;
            int      loadedRoomsCount = CyberEnvironment.GetGame().GetRoomManager().LoadedRoomsCount;
            DateTime dateTime         = new DateTime((DateTime.Now - CyberEnvironment.ServerStarted).Ticks);
            string   text             = dateTime.ToString("HH:mm:ss");


            Console.Title = string.Concat(new object[]
            {
                "CYBER EMULATOR - VERSION: ", CyberEnvironment.PrettyBuild, " | TIME: ",
                text,
                " | ONLINE COUNT: ",
                clientCount,
                " | ROOM COUNT: ",
                loadedRoomsCount
            });

            if (clientCount > LowPriorityWorker.UserPeak)
            {
                LowPriorityWorker.UserPeak = clientCount;
            }
            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.runFastQuery(string.Concat(new object[]
                {
                    "UPDATE server_status SET stamp = '",
                    CyberEnvironment.GetUnixTimestamp(),
                    "', users_online = ",
                    clientCount,
                    ", rooms_loaded = ",
                    loadedRoomsCount,
                    ", server_ver = 'Cyber Emulator', userpeak = ",
                    LowPriorityWorker.UserPeak
                }));
            }
        }
示例#5
0
 private void manager_connectionEvent(ConnectionInformation connection)
 {
     connection.connectionChanged += new ConnectionInformation.ConnectionChange(this.connectionChanged);
     CyberEnvironment.GetGame().GetClientManager().CreateAndStartClient(checked ((uint)connection.getConnectionID()), connection);
 }
示例#6
0
        internal void processCommand(string data)
        {
            string text = data.Split(new char[]
            {
                Convert.ToChar(1)
            })[0];
            string text2 = data.Split(new char[]
            {
                Convert.ToChar(1)
            })[1];

            string[] array = text2.Split(new char[]
            {
                Convert.ToChar(5)
            });
            string a;

            if ((a = text.ToLower()) != null)
            {
                if (!(a == "updatemotto"))
                {
                    GameClient clientByUserID;
                    if (!(a == "updaterooms"))
                    {
                        if (!(a == "addtoinventory"))
                        {
                            if (!(a == "updatecredits"))
                            {
                                if (!(a == "updatesubscription"))
                                {
                                    goto IL_38B;
                                }
                                uint userID = Convert.ToUInt32(array[0]);
                                clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(userID);
                                if (clientByUserID != null && clientByUserID.GetHabbo() != null)
                                {
                                    clientByUserID.GetHabbo().GetSubscriptionManager().ReloadSubscription();
                                    clientByUserID.GetHabbo().SerializeClub();
                                    clientByUserID.SendMessage(new ServerMessage(Outgoing.PublishShopMessageComposer));
                                    goto IL_3A3;
                                }
                                goto IL_3A3;
                            }
                            else
                            {
                                uint userID2 = Convert.ToUInt32(array[0]);
                                int  credits = Convert.ToInt32(array[1]);
                                clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(userID2);
                                if (clientByUserID != null && clientByUserID.GetHabbo() != null)
                                {
                                    clientByUserID.GetHabbo().Credits = credits;
                                    clientByUserID.GetHabbo().UpdateCreditsBalance();
                                    goto IL_3A3;
                                }
                                goto IL_3A3;
                            }
                        }
                    }
                    else
                    {
                        uint   num       = Convert.ToUInt32(array[0]);
                        string arg_20F_0 = array[1];
                        using (Dictionary <uint, Room> .ValueCollection.Enumerator enumerator = CyberEnvironment.GetGame().GetRoomManager().loadedRooms.Values.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                Room current = enumerator.Current;
                                if ((long)current.OwnerId == (long)((ulong)num))
                                {
                                    CyberEnvironment.GetGame().GetRoomManager().UnloadRoom(current);
                                    current.RequestReload();
                                }
                            }
                            goto IL_3A3;
                        }
                    }
                    uint userID3 = Convert.ToUInt32(array[0]);
                    int  id      = Convert.ToInt32(array[1]);
                    clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(userID3);
                    if (clientByUserID != null && clientByUserID.GetHabbo() != null && clientByUserID.GetHabbo().GetInventoryComponent() != null)
                    {
                        clientByUserID.GetHabbo().GetInventoryComponent().UpdateItems(true);
                        clientByUserID.GetHabbo().GetInventoryComponent().SendNewItems((uint)id);
                    }
                }
                else
                {
                    GameClient clientByUserID       = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(Convert.ToUInt32(array[0]));
                    clientByUserID.GetHabbo().Motto = MusConnection.MergeParams(array, 1);
                    ServerMessage serverMessage     = new ServerMessage(Outgoing.UpdateUserDataMessageComposer);
                    serverMessage.AppendInt32(-1);
                    serverMessage.AppendString(clientByUserID.GetHabbo().Look);
                    serverMessage.AppendString(clientByUserID.GetHabbo().Gender.ToLower());
                    serverMessage.AppendString(clientByUserID.GetHabbo().Motto);
                    serverMessage.AppendInt32(clientByUserID.GetHabbo().AchievementPoints);
                    clientByUserID.SendMessage(serverMessage);
                    if (clientByUserID.GetHabbo().CurrentRoom != null)
                    {
                        RoomUser      roomUserByHabbo = clientByUserID.GetHabbo().CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(clientByUserID.GetHabbo().Username);
                        ServerMessage serverMessage2  = new ServerMessage(Outgoing.UpdateUserDataMessageComposer);
                        serverMessage2.AppendInt32(roomUserByHabbo.VirtualId);
                        serverMessage2.AppendString(clientByUserID.GetHabbo().Look);
                        serverMessage2.AppendString(clientByUserID.GetHabbo().Gender.ToLower());
                        serverMessage2.AppendString(clientByUserID.GetHabbo().Motto);
                        serverMessage2.AppendInt32(clientByUserID.GetHabbo().AchievementPoints);
                        clientByUserID.GetHabbo().CurrentRoom.SendMessage(serverMessage2);
                    }
                }
IL_3A3:
                Logging.WriteLine("[MUS SOCKET] Comando MUS procesado correctamente: '" + text + "'", ConsoleColor.Green);
                return;
            }
IL_38B:
            Logging.WriteLine("[MUS SOCKET] Paquete MUS no reconocido: " + text + "//" + data, ConsoleColor.DarkRed);
        }
示例#7
0
 private GameClient GetClient()
 {
     return(CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(this.Id));
 }
示例#8
0
 internal bool HasFuse(string Fuse)
 {
     return(CyberEnvironment.GetGame().GetRoleManager().RankHasRight(this.Rank, Fuse) || (this.GetSubscriptionManager().HasSubscription&& CyberEnvironment.GetGame().GetRoleManager().HasVIP(this.GetSubscriptionManager().GetSubscription().SubscriptionId, Fuse)));
 }
示例#9
0
 internal void SerializeQuests(ref QueuedServerMessage response)
 {
     CyberEnvironment.GetGame().GetQuestManager().GetList(this.mClient, null);
 }
示例#10
0
        internal void AddNewEvent(uint RoomId, string EventName, string EventDesc, GameClient Session, int Time = 7200)
        {
            checked
            {
                if (this.Events.ContainsKey(RoomId))
                {
                    RoomEvent roomEvent = this.Events[RoomId];
                    roomEvent.Name        = EventName;
                    roomEvent.Description = EventDesc;
                    if (roomEvent.HasExpired)
                    {
                        roomEvent.Time = CyberEnvironment.GetUnixTimestamp() + Time;
                    }
                    else
                    {
                        roomEvent.Time += Time;
                    }
                    using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                    {
                        queryreactor.setQuery(string.Concat(new object[]
                        {
                            "REPLACE INTO room_events VALUES (",
                            RoomId,
                            ", @name, @desc, ",
                            roomEvent.Time,
                            ")"
                        }));
                        queryreactor.addParameter("name", EventName);
                        queryreactor.addParameter("desc", EventDesc);
                        queryreactor.runQuery();
                        goto IL_17C;
                    }
                }
                using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor2.setQuery(string.Concat(new object[]
                    {
                        "REPLACE INTO room_events VALUES (",
                        RoomId,
                        ", @name, @desc, ",
                        CyberEnvironment.GetUnixTimestamp() + 7200,
                        ")"
                    }));
                    queryreactor2.addParameter("name", EventName);
                    queryreactor2.addParameter("desc", EventDesc);
                    queryreactor2.runQuery();
                }
                this.Events.Add(RoomId, new RoomEvent(RoomId, EventName, EventDesc, 0));
IL_17C:
                CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(RoomId).Event = this.Events[RoomId];
                Room room = CyberEnvironment.GetGame().GetRoomManager().GetRoom(RoomId);
                if (room != null)
                {
                    room.Event = this.Events[RoomId];
                }
                if (Session.GetHabbo().CurrentRoomId == RoomId)
                {
                    this.SerializeEventInfo(RoomId);
                }
            }
        }
示例#11
0
 internal void OnNewRequest(uint friendID)
 {
     if (!this.requests.ContainsKey(friendID))
     {
         this.requests.Add(friendID, new MessengerRequest(this.UserId, friendID, CyberEnvironment.GetGame().GetClientManager().GetNameById(friendID)));
     }
 }
示例#12
0
        internal bool RequestBuddy(string UserQuery)
        {
            GameClient clientByUsername = CyberEnvironment.GetGame().GetClientManager().GetClientByUsername(UserQuery);
            uint       num;
            bool       flag;

            if (clientByUsername == null)
            {
                DataRow dataRow = null;
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.setQuery("SELECT id,block_newfriends FROM users WHERE username = @query");
                    queryreactor.addParameter("query", UserQuery.ToLower());
                    dataRow = queryreactor.getRow();
                }
                if (dataRow == null)
                {
                    return(false);
                }
                num  = Convert.ToUInt32(dataRow["id"]);
                flag = CyberEnvironment.EnumToBool(dataRow["block_newfriends"].ToString());
            }
            else
            {
                num  = clientByUsername.GetHabbo().Id;
                flag = clientByUsername.GetHabbo().HasFriendRequestsDisabled;
            }
            if (flag && this.GetClient().GetHabbo().Rank < 4u)
            {
                this.GetClient().GetMessageHandler().GetResponse().Init(Outgoing.NotAcceptingRequestsMessageComposer);
                this.GetClient().GetMessageHandler().GetResponse().AppendInt32(39);
                this.GetClient().GetMessageHandler().GetResponse().AppendInt32(3);
                this.GetClient().GetMessageHandler().SendResponse();
                return(false);
            }
            uint num2 = num;

            if (this.RequestExists(num2))
            {
                return(true);
            }
            using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor2.runFastQuery(string.Concat(new object[]
                {
                    "REPLACE INTO messenger_requests (from_id,to_id) VALUES (",
                    this.UserId,
                    ",",
                    num2,
                    ")"
                }));
            }
            CyberEnvironment.GetGame().GetQuestManager().ProgressUserQuest(this.GetClient(), QuestType.ADD_FRIENDS, 0u);
            GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(num2);

            if (clientByUserID == null || clientByUserID.GetHabbo() == null)
            {
                return(true);
            }
            MessengerRequest messengerRequest = new MessengerRequest(num2, this.UserId, CyberEnvironment.GetGame().GetClientManager().GetNameById(this.UserId));

            clientByUserID.GetHabbo().GetMessenger().OnNewRequest(this.UserId);
            ServerMessage serverMessage = new ServerMessage(Outgoing.ConsoleSendFriendRequestMessageComposer);

            messengerRequest.Serialize(serverMessage);
            clientByUserID.SendMessage(serverMessage);
            this.requests.Add(num2, messengerRequest);
            return(true);
        }
示例#13
0
        internal void UnloadRoom(Room Room)
        {
            if (Room == null)
            {
                return;
            }

            if (CyberEnvironment.GetGame().GetNavigator().PrivateCategories.Contains(Room.Category))
            {
                ((FlatCat)CyberEnvironment.GetGame().GetNavigator().PrivateCategories[Room.Category]).removeUsers(Room.UserCount);
            }
            Room.UsersNow = 0;

            StringBuilder stringBuilder = new StringBuilder();

            checked
            {
                for (int i = 0; i < Room.TagCount; i++)
                {
                    if (i > 0)
                    {
                        stringBuilder.Append(",");
                    }
                    stringBuilder.Append(Room.Tags[i]);
                }
                string text = "open";
                if (Room.State == 1)
                {
                    text = "locked";
                }
                else
                {
                    if (Room.State > 1)
                    {
                        text = "password";
                    }
                }
                using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor.setQuery(string.Concat(new object[]
                    {
                        "UPDATE rooms SET caption = @caption, description = @description, password = @password, category = ",
                        Room.Category,
                        ", state = '",
                        text,
                        "', tags = @tags, users_now = '0', users_max = ",
                        Room.UsersMax,
                        ", allow_pets = '",
                        Room.AllowPets,
                        "', allow_pets_eat = '",
                        Room.AllowPetsEating,
                        "', allow_walkthrough = '",
                        Room.AllowWalkthrough,
                        "', allow_hidewall = '",
                        Room.Hidewall,
                        "', floorthick = ",
                        Room.FloorThickness,
                        ", wallthick = ",
                        Room.WallThickness,
                        ", mute_settings='",
                        Room.WhoCanMute,
                        "', kick_settings='",
                        Room.WhoCanKick,
                        "',ban_settings='",
                        Room.WhoCanBan,
                        "', walls_height = '", Room.WallHeight, "', chat_type = @chat_t,chat_balloon = @chat_b,chat_speed = @chat_s,chat_max_distance = @chat_m,chat_flood_protection = @chat_f WHERE id = ",
                        Room.RoomId
                    }));
                    queryreactor.addParameter("caption", Room.Name);
                    queryreactor.addParameter("description", Room.Description);
                    queryreactor.addParameter("password", Room.Password);
                    queryreactor.addParameter("tags", stringBuilder.ToString());
                    queryreactor.addParameter("chat_t", Room.ChatType);
                    queryreactor.addParameter("chat_b", Room.ChatBalloon);
                    queryreactor.addParameter("chat_s", Room.ChatSpeed);
                    queryreactor.addParameter("chat_m", Room.ChatMaxDistance);
                    queryreactor.addParameter("chat_f", Room.ChatFloodProtection);
                    queryreactor.runQuery();
                }
                lock (this.roomsToRemoveQueue.SyncRoot)
                {
                    this.roomsToRemoveQueue.Enqueue(Room.RoomId);
                }
                Logging.WriteLine("[RoomMgr] Room #[" + Room.RoomId + "] was unloaded.", ConsoleColor.DarkYellow);
                foreach (RoomUser current in Room.GetRoomUserManager().UserList.Values)
                {
                    if (current.IsPet)
                    {
                        using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                        {
                            queryreactor2.setQuery("UPDATE bots SET x=@x, y=@y, z=@z WHERE id=@id LIMIT 1;");
                            queryreactor2.addParameter("x", current.X);
                            queryreactor2.addParameter("y", current.Y);
                            queryreactor2.addParameter("z", current.Z);
                            queryreactor2.addParameter("id", current.PetData.PetId);
                            queryreactor2.runQuery();
                            goto IL_4AA;
                        }
                    }
                    goto IL_38A;
IL_4AA:
                    Room.GetRoomUserManager().RemoveRoomUser(current);
                    continue;
IL_38A:
                    if (current.IsBot)
                    {
                        using (IQueryAdapter queryreactor3 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                        {
                            queryreactor3.setQuery("UPDATE bots SET x=@x, y=@y, z=@z, name=@name, motto=@motto, look=@look, rotation=@rotation, dance=@dance WHERE id=@id LIMIT 1;");
                            queryreactor3.addParameter("name", current.BotData.Name);
                            queryreactor3.addParameter("motto", current.BotData.Motto);
                            queryreactor3.addParameter("look", current.BotData.Look);
                            queryreactor3.addParameter("rotation", current.BotData.Rot);
                            queryreactor3.addParameter("dance", current.BotData.DanceId);
                            queryreactor3.addParameter("x", current.X);
                            queryreactor3.addParameter("y", current.Y);
                            queryreactor3.addParameter("z", current.Z);
                            queryreactor3.addParameter("id", current.BotData.BotId);
                            queryreactor3.runQuery();
                        }
                        goto IL_4AA;
                    }
                    goto IL_4AA;
                }
                lock (Room.RoomChat)
                {
                    foreach (Chatlog current2 in Room.RoomChat)
                    {
                        current2.Save(Room.RoomId);
                    }
                }
                Room.Destroy();
            }
        }
示例#14
0
 private void OnRoomCrash(Exception e)
 {
     Logging.LogThreadException(e.ToString(), "Room cycle task for room " + this.RoomId);
     CyberEnvironment.GetGame().GetRoomManager().UnloadRoom(this);
     this.isCrashed = true;
 }
示例#15
0
        internal void ProcessRoom()
        {
            try
            {
                if (isCrashed || mDisposed)
                {
                    return;
                }
                try
                {
                    int idle = 0;
                    GetRoomItemHandler().OnCycle();
                    GetRoomUserManager().OnCycle(ref idle);

                    if (idle > 0)
                    {
                        IdleTime++;
                    }
                    else
                    {
                        IdleTime = 0;
                    }

                    if (!mCycleEnded)
                    {
                        if (this.IdleTime >= 10 /* && usersQueueToEnter.Count == 0*/)
                        {
                            CyberEnvironment.GetGame().GetRoomManager().UnloadRoom(this);
                            return;
                        }
                        else
                        {
                            ServerMessage serverMessage = this.GetRoomUserManager().SerializeStatusUpdates(false);

                            if (serverMessage != null)
                            {
                                SendMessage(serverMessage);
                            }
                        }
                    }

                    if (gameItemHandler != null)
                    {
                        gameItemHandler.OnCycle();
                    }
                    if (game != null)
                    {
                        game.OnCycle();
                    }
                    if (GotBanzai())
                    {
                        banzai.OnCycle();
                    }
                    if (GotSoccer())
                    {
                        soccer.OnCycle();
                    }
                    roomUserManager.UserList.OnCycle();

                    GetWiredHandler().OnCycle();
                    WorkRoomKickQueue();
                }
                catch (Exception e)
                {
                    OnRoomCrash(e);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Sub crash in room cycle: " + e.ToString());
            }
        }
示例#16
0
        internal ServerMessage SerializeInfo()
        {
            ServerMessage serverMessage = new ServerMessage(Outgoing.PetInfoMessageComposer);

            serverMessage.AppendUInt(this.PetId);
            serverMessage.AppendString(this.Name);
            if (this.Type == 16)
            {
                serverMessage.AppendInt32(this.MoplaBreed.GrowingStatus);
                serverMessage.AppendInt32(7);
            }
            else
            {
                serverMessage.AppendInt32(this.Level);
                serverMessage.AppendInt32(Pet.MaxLevel);
            }
            serverMessage.AppendInt32(this.Experience);
            serverMessage.AppendInt32(this.experienceGoal);
            serverMessage.AppendInt32(this.Energy);
            serverMessage.AppendInt32(Pet.MaxEnergy);
            serverMessage.AppendInt32(this.Nutrition);
            serverMessage.AppendInt32(Pet.MaxNutrition);
            serverMessage.AppendInt32(this.Respect);
            serverMessage.AppendUInt(this.OwnerId);
            serverMessage.AppendInt32(this.Age);
            serverMessage.AppendString(this.OwnerName);
            serverMessage.AppendInt32((Type == 16) ? 0 : 1);
            serverMessage.AppendBoolean(this.HaveSaddle);
            serverMessage.AppendBoolean(CyberEnvironment.GetGame().GetRoomManager().GetRoom(this.RoomId).GetRoomUserManager().GetRoomUserByVirtualId(this.VirtualId).RidingHorse);
            serverMessage.AppendInt32(0);
            serverMessage.AppendInt32(this.AnyoneCanRide);
            if (Type == 16)
            {
                if (MoplaBreed.LiveState == MoplaState.GROWN)
                {
                    serverMessage.AppendBoolean(true);
                }
                else
                {
                    serverMessage.AppendBoolean(false);
                }
            }
            else
            {
                serverMessage.AppendBoolean(false); // Plant is grown
            }
            serverMessage.AppendBoolean(false);
            if (Type == 16)
            {
                if (MoplaBreed.LiveState == MoplaState.DEAD)
                {
                    serverMessage.AppendBoolean(true);
                }
                else
                {
                    serverMessage.AppendBoolean(false);
                }
            }
            else
            {
                serverMessage.AppendBoolean(false);
            }
            serverMessage.AppendInt32(this.Rarity);
            checked
            {
                if (this.Type == 16u)
                {
                    serverMessage.AppendInt32(129600);
                    int LastHealthSeconds = (int)(this.LastHealth - DateTime.Now).TotalSeconds;
                    int UntilGrownSeconds = (int)(this.UntilGrown - DateTime.Now).TotalSeconds;

                    if (LastHealthSeconds < 0)
                    {
                        LastHealthSeconds = 0;
                    }
                    if (UntilGrownSeconds < 0)
                    {
                        UntilGrownSeconds = 0;
                    }

                    if (this.MoplaBreed.LiveState == MoplaState.DEAD)
                    {
                        serverMessage.AppendInt32(0);
                        serverMessage.AppendInt32(0);
                    }
                    else if (this.MoplaBreed.LiveState == MoplaState.GROWN)
                    {
                        serverMessage.AppendInt32(LastHealthSeconds);
                        serverMessage.AppendInt32(0);
                    }
                    else
                    {
                        serverMessage.AppendInt32(LastHealthSeconds);
                        serverMessage.AppendInt32(UntilGrownSeconds);
                    }
                }
                else
                {
                    serverMessage.AppendInt32(-1);
                    serverMessage.AppendInt32(-1);
                    serverMessage.AppendInt32(-1);
                }

                serverMessage.AppendBoolean(true);
                return(serverMessage);
            }
        }
示例#17
0
        internal ServerMessage SerializeNavigator(GameClient session, int mode)
        {
            if (mode >= 0)
            {
                return(this.SerializeActiveRooms(mode));
            }
            ServerMessage serverMessage = new ServerMessage(Outgoing.NavigatorListingsMessageComposer);

            switch (mode)
            {
            case -16:
            {
                Dictionary <uint, RoomEvent> events = CyberEnvironment.GetGame().GetRoomEvents().GetEvents();
                serverMessage.AppendInt32(16);
                this.SerializeNavigatorRooms(ref serverMessage, events);
                return(serverMessage);
            }

            case -15:
                break;

            case -14:
            {
                serverMessage.AppendInt32(14);
                HashSet <RoomData> rooms = CyberEnvironment.GetGame().GetRoomManager().GetActiveRooms();
                this.SerializeNavigatorRooms(ref serverMessage, rooms);
                return(serverMessage);
            }

            default:
                switch (mode)
                {
                case -5:
                case -4:
                {
                    serverMessage.AppendInt32(checked (mode * -1));
                    HashSet <RoomData> rooms2 = session.GetHabbo().GetMessenger().GetActiveFriendsRooms();
                    this.SerializeNavigatorRooms(ref serverMessage, rooms2);
                    return(serverMessage);
                }

                case -3:
                    serverMessage.AppendInt32(5);
                    this.SerializeNavigatorRooms(ref serverMessage, session.GetHabbo().UsersRooms);
                    return(serverMessage);

                case -2:
                {
                    serverMessage.AppendInt32(2);
                    HashSet <RoomData> votedRooms = CyberEnvironment.GetGame().GetRoomManager().GetVotedRooms();
                    this.SerializeNavigatorRooms(ref serverMessage, votedRooms);
                    votedRooms = null;
                    return(serverMessage);
                }

                case -1:
                    serverMessage.AppendInt32(1);
                    serverMessage.AppendString("-1");
                    try
                    {
                        HashSet <RoomData> activeRooms = CyberEnvironment.GetGame().GetRoomManager().GetActiveRooms();
                        this.SerializeNavigatorPopularRooms(ref serverMessage, activeRooms);
                        activeRooms = null;
                    }
                    catch
                    {
                        serverMessage.AppendInt32(0);
                        serverMessage.AppendBoolean(false);
                    }
                    return(serverMessage);
                }
                break;
            }
            return(serverMessage);
        }
示例#18
0
        internal bool ProgressUserAchievement(GameClient Session, string AchievementGroup, int ProgressAmount, bool FromZero = false)
        {
            if (!this.Achievements.ContainsKey(AchievementGroup) || Session == null)
            {
                return(false);
            }
            Achievement achievement = null;

            achievement = this.Achievements[AchievementGroup];
            UserAchievement userAchievement = Session.GetHabbo().GetAchievementData(AchievementGroup);

            if (userAchievement == null)
            {
                userAchievement = new UserAchievement(AchievementGroup, 0, 0);
                Session.GetHabbo().Achievements.Add(AchievementGroup, userAchievement);
            }
            int count = achievement.Levels.Count;

            if (userAchievement != null && userAchievement.Level == count)
            {
                return(false);
            }
            checked
            {
                int num = (userAchievement != null) ? (userAchievement.Level + 1) : 1;
                if (num > count)
                {
                    num = count;
                }
                AchievementLevel targetLevelData = achievement.Levels[num];
                int num2 = 0;
                if (FromZero)
                {
                    num2 = ProgressAmount;
                }
                else
                {
                    num2 = ((userAchievement != null) ? (userAchievement.Progress + ProgressAmount) : ProgressAmount);
                }
                int num3 = (userAchievement != null) ? userAchievement.Level : 0;
                int num4 = num3 + 1;
                if (num4 > count)
                {
                    num4 = count;
                }
                if (num2 >= targetLevelData.Requirement)
                {
                    num3++;
                    num4++;
                    int arg_E6_0 = num2 - targetLevelData.Requirement;
                    num2 = 0;
                    if (num == 1)
                    {
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
                    }
                    else
                    {
                        Session.GetHabbo().GetBadgeComponent().RemoveBadge(Convert.ToString(AchievementGroup + (num - 1)), Session);
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + num, true, Session, false);
                    }
                    if (num4 > count)
                    {
                        num4 = count;
                    }
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementUnlockedComposer.Compose(achievement, num, targetLevelData.RewardPoints, targetLevelData.RewardPixels));
                    using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                    {
                        queryreactor.setQuery(string.Concat(new object[]
                        {
                            "REPLACE INTO user_achievement VALUES (",
                            Session.GetHabbo().Id,
                            ", @group, ",
                            num3,
                            ", ",
                            num2,
                            ")"
                        }));
                        queryreactor.addParameter("group", AchievementGroup);
                        queryreactor.runQuery();
                    }
                    userAchievement.Level    = num3;
                    userAchievement.Progress = num2;
                    Session.GetHabbo().AchievementPoints += targetLevelData.RewardPoints;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                    AchievementLevel targetLevelData2 = achievement.Levels[num4];
                    Session.SendMessage(AchievementProgressComposer.Compose(achievement, num4, targetLevelData2, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));
                    Talent talent = null;
                    if (CyberEnvironment.GetGame().GetTalentManager().TryGetTalent(AchievementGroup, out talent))
                    {
                        CyberEnvironment.GetGame().GetTalentManager().CompleteUserTalent(Session, talent);
                    }
                    return(true);
                }
                userAchievement.Level    = num3;
                userAchievement.Progress = num2;
                using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor2.setQuery(string.Concat(new object[]
                    {
                        "REPLACE INTO user_achievement VALUES (",
                        Session.GetHabbo().Id,
                        ", @group, ",
                        num3,
                        ", ",
                        num2,
                        ")"
                    }));
                    queryreactor2.addParameter("group", AchievementGroup);
                    queryreactor2.runQuery();
                }
                Session.SendMessage(AchievementProgressComposer.Compose(achievement, num, targetLevelData, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));

                Session.GetMessageHandler().GetResponse().Init(Outgoing.UpdateUserDataMessageComposer);
                Session.GetMessageHandler().GetResponse().AppendInt32(-1);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
                Session.GetMessageHandler().GetResponse().AppendInt32(Session.GetHabbo().AchievementPoints);
                Session.GetMessageHandler().SendResponse();
                return(false);
            }
        }
示例#19
0
        internal Habbo(uint Id, string Username, string RealName, uint Rank, string Motto, string Look, string Gender, int Credits, int ActivityPoints, double LastActivityPointsUpdate, bool Muted, uint HomeRoom, int Respect, int DailyRespectPoints, int DailyPetRespectPoints, bool HasFriendRequestsDisabled, uint currentQuestID, int currentQuestProgress, int achievementPoints, int RegTimestamp, int LastOnline, bool AppearOffline, bool HideInRoom, bool VIP, double CreateDate, bool Online, string Citizenship, int BelCredits, HashSet <GroupUser> Groups, uint FavId, int LastChange, bool TradeLocked, int TradeLockExpire, bool NUXPassed)
        {
            this.Id       = Id;
            this.Username = Username;
            this.RealName = RealName;
            if (Rank < 1u)
            {
                Rank = 1u;
            }
            this.Rank                      = Rank;
            this.Motto                     = Motto;
            this.Look                      = CyberEnvironment.GetGame().GetAntiMutant().RunLook(Look.ToLower());
            this.VIP                       = VIP;
            this.LastChange                = LastChange;
            this.TradeLocked               = TradeLocked;
            this.TradeLockExpire           = TradeLockExpire;
            this.Gender                    = Gender.ToLower();
            this.Credits                   = Credits;
            this.ActivityPoints            = ActivityPoints;
            this.BelCredits                = BelCredits;
            this.AchievementPoints         = achievementPoints;
            this.Muted                     = Muted;
            this.LoadingRoom               = 0u;
            this.CreateDate                = CreateDate;
            this.LoadingChecksPassed       = false;
            this.FloodTime                 = 0;
            this.NUXPassed                 = NUXPassed;
            this.CurrentRoomId             = 0u;
            this.HomeRoom                  = HomeRoom;
            this.HideInRoom                = HideInRoom;
            this.AppearOffline             = AppearOffline;
            this.FavoriteRooms             = new ArrayList();
            this.MutedUsers                = new List <uint>();
            this.Tags                      = new List <string>();
            this.Achievements              = new Dictionary <string, UserAchievement>();
            this.Talents                   = new Dictionary <int, UserTalent>();
            this.Relationships             = new Dictionary <int, Relationship>();
            this.RatedRooms                = new HashSet <uint>();
            this.Respect                   = Respect;
            this.DailyRespectPoints        = DailyRespectPoints;
            this.DailyPetRespectPoints     = DailyPetRespectPoints;
            this.IsTeleporting             = false;
            this.TeleporterId              = 0u;
            this.UsersRooms                = new HashSet <RoomData>();
            this.HasFriendRequestsDisabled = HasFriendRequestsDisabled;
            this.LastOnline                = CyberEnvironment.GetUnixTimestamp();//LastOnline;
            this.PreviousOnline            = LastOnline;
            this.RecentlyVisitedRooms      = new HashSet <uint>();
            this.CurrentQuestId            = currentQuestID;
            this.IsHopping                 = false;

            if (CyberEnvironment.GetGame().GetGroupManager().GetGroup(FavId) != null)
            {
                this.FavouriteGroup = FavId;
            }
            else
            {
                this.FavouriteGroup = 0u;
            }
            this.UserGroups = Groups;
            if (this.DailyPetRespectPoints > 99)
            {
                this.DailyPetRespectPoints = 99;
            }
            if (this.DailyRespectPoints > 99)
            {
                this.DailyRespectPoints = 99;
            }
            this.LastGiftPurchaseTime = DateTime.Now;
            this.LastGiftOpenTime     = DateTime.Now;
            this.TalentStatus         = Citizenship;
            this.CurrentTalentLevel   = this.GetCurrentTalentLevel();
        }
示例#20
0
        public bool Execute(params object[] Stuff)
        {
            RoomUser      roomUser = (RoomUser)Stuff[0];
            WiredItemType item     = (WiredItemType)Stuff[1];

            if (this.mBanned.Contains(item))
            {
                return(false);
            }
            if (roomUser == null)
            {
                return(false);
            }
            string[] array = this.OtherString.Split(new char[]
            {
                ';'
            });
            bool   flag   = true;
            Random random = new Random();

            if (!this.OtherBool)
            {
                string[] array2 = array;
                int      i      = 0;
                while (i < array2.Length)
                {
                    string   text   = array2[i];
                    string[] array3 = text.Split(new char[]
                    {
                        ','
                    });
                    bool   flag2   = false;
                    string Product = "";
                    int    num     = 0;
                    try
                    {
                        flag2   = int.Parse(array3[0]) == 0;
                        Product = array3[1];
                        num     = int.Parse(array3[2]);
                    }
                    catch
                    {
                    }
                    if (random.Next(0, 101) <= num)
                    {
                        if (flag2)
                        {
                            roomUser.GetClient().GetHabbo().GetBadgeComponent().GiveBadge(Product, true, roomUser.GetClient(), true);
                            break;
                        }
                        if (Product.StartsWith("avatar_effect"))
                        {
                            string s        = Product.Trim().Replace("avatar_effect", "");
                            int    effectId = int.Parse(s);
                            roomUser.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(effectId, 68400);
                            ServerMessage serverMessage = new ServerMessage(Outgoing.WiredRewardAlertMessageComposer);
                            serverMessage.AppendInt32(6);
                            roomUser.GetClient().SendMessage(serverMessage);
                            break;
                        }
                        Item item2 = null;
                        try
                        {
                            item2 = (
                                from x in CyberEnvironment.GetGame().GetItemManager().Items.Values
                                where x.Name == Product
                                select x).FirstOrDefault <Item>();
                        }
                        catch (Exception)
                        {
                            flag = false;
                        }
                        if (item2 == null)
                        {
                            flag = false;
                            break;
                        }
                        roomUser.GetClient().GetHabbo().GetInventoryComponent().AddNewItem(0u, item2.ItemId, "0", 0u, true, false, 0, 0, "");
                        ServerMessage serverMessage2 = new ServerMessage(Outgoing.WiredRewardAlertMessageComposer);
                        serverMessage2.AppendInt32(6);
                        roomUser.GetClient().SendMessage(serverMessage2);
                        roomUser.GetClient().SendMessage(new ServerMessage(Outgoing.UpdateInventoryMessageComposer));
                        break;
                    }
                    else
                    {
                        flag = false;
                        i++;
                    }
                }
            }
            else
            {
                string[] array4 = array;
                for (int j = 0; j < array4.Length; j++)
                {
                    string   text2  = array4[j];
                    string[] array5 = text2.Split(new char[]
                    {
                        ','
                    });
                    bool   flag3   = int.Parse(array5[0]) == 0;
                    string Product = array5[1];
                    int.Parse(array5[2]);
                    if (flag3)
                    {
                        roomUser.GetClient().GetHabbo().GetBadgeComponent().GiveBadge(Product, true, roomUser.GetClient(), true);
                    }
                    else
                    {
                        if (Product.StartsWith("avatar_effect"))
                        {
                            string s2        = Product.Trim().Replace("avatar_effect", "");
                            int    effectId2 = int.Parse(s2);
                            roomUser.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().AddNewEffect(effectId2, 68400);
                            ServerMessage serverMessage3 = new ServerMessage(Outgoing.WiredRewardAlertMessageComposer);
                            serverMessage3.AppendInt32(6);
                            roomUser.GetClient().SendMessage(serverMessage3);
                        }
                        else
                        {
                            Item item3 = null;
                            try
                            {
                                item3 = (
                                    from x in CyberEnvironment.GetGame().GetItemManager().Items.Values
                                    where x.Name == Product
                                    select x).FirstOrDefault <Item>();
                            }
                            catch (Exception)
                            {
                                flag = false;
                            }
                            if (item3 == null)
                            {
                                flag = false;
                            }
                            else
                            {
                                roomUser.GetClient().GetHabbo().GetInventoryComponent().AddNewItem(0u, item3.ItemId, "0", 0u, true, false, 0, 0, "");
                                ServerMessage serverMessage4 = new ServerMessage(Outgoing.WiredRewardAlertMessageComposer);
                                serverMessage4.AppendInt32(6);
                                roomUser.GetClient().SendMessage(serverMessage4);
                                roomUser.GetClient().SendMessage(new ServerMessage(Outgoing.UpdateInventoryMessageComposer));
                            }
                        }
                    }
                }
            }
            if (!flag)
            {
                ServerMessage serverMessage5 = new ServerMessage(Outgoing.WiredRewardAlertMessageComposer);
                serverMessage5.AppendInt32(4);
                roomUser.GetClient().SendMessage(serverMessage5);
            }
            return(true);
        }
示例#21
0
 internal bool GotCommand(string Cmd)
 {
     return(CyberEnvironment.GetGame().GetRoleManager().RankGotCommand(this.Rank, Cmd));
 }
示例#22
0
        internal static ServerMessage SerializeUserChatlog(uint UserId)
        {
            ServerMessage result;

            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery("SELECT DISTINCT room_id FROM chatlogs WHERE user_id = " + UserId + " ORDER BY timestamp DESC LIMIT 4");
                DataTable     table         = queryreactor.getTable();
                ServerMessage serverMessage = new ServerMessage(Outgoing.ModerationToolUserChatlogMessageComposer);
                serverMessage.AppendUInt(UserId);
                serverMessage.AppendString(CyberEnvironment.GetGame().GetClientManager().GetNameById(UserId));
                if (table != null)
                {
                    serverMessage.AppendInt32(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow)enumerator.Current;
                            queryreactor.setQuery(string.Concat(new object[]
                            {
                                "SELECT user_id,timestamp,message FROM chatlogs WHERE room_id = ",
                                (uint)dataRow["room_id"],
                                " AND user_id = ",
                                UserId,
                                " ORDER BY timestamp DESC LIMIT 30"
                            }));
                            DataTable table2   = queryreactor.getTable();
                            RoomData  roomData = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]);
                            if (table2 != null)
                            {
                                serverMessage.AppendByte(1);
                                serverMessage.AppendShort(2);
                                serverMessage.AppendString("roomName");
                                serverMessage.AppendByte(2);
                                if (roomData == null)
                                {
                                    serverMessage.AppendString("This room was deleted");
                                }
                                else
                                {
                                    serverMessage.AppendString(roomData.Name);
                                }
                                serverMessage.AppendString("roomId");
                                serverMessage.AppendByte(1);
                                serverMessage.AppendUInt((uint)dataRow["room_id"]);
                                serverMessage.AppendShort(table2.Rows.Count);
                                IEnumerator enumerator2 = table2.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow2   = (DataRow)enumerator2.Current;
                                        Habbo   habboForId = CyberEnvironment.getHabboForId((uint)dataRow2["user_id"]);
                                        CyberEnvironment.UnixToDateTime((double)dataRow2["timestamp"]);
                                        if (habboForId == null)
                                        {
                                            result = null;
                                            return(result);
                                        }
                                        serverMessage.AppendInt32(checked ((int)unchecked ((double)CyberEnvironment.GetUnixTimestamp() - (double)dataRow2["timestamp"])));
                                        serverMessage.AppendUInt(habboForId.Id);
                                        serverMessage.AppendString(habboForId.Username);
                                        serverMessage.AppendString(dataRow2["message"].ToString());
                                        serverMessage.AppendBoolean(false);
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;
                                    if (disposable != null)
                                    {
                                        disposable.Dispose();
                                    }
                                }
                            }
                            serverMessage.AppendByte(1);
                            serverMessage.AppendShort(0);
                            serverMessage.AppendShort(0);
                        }
                        goto IL_29B;
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator as IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }
                serverMessage.AppendInt32(0);
IL_29B:
                result = serverMessage;
            }
            return(result);
        }
示例#23
0
 internal void OnDisconnect()
 {
     if (this.Disconnected)
     {
         return;
     }
     this.Disconnected = true;
     if (this.InventoryComponent != null)
     {
         this.InventoryComponent.RunDBUpdate();
         this.InventoryComponent.SetIdleState();
     }
     CyberEnvironment.GetGame().GetClientManager().UnregisterClient(this.Id, this.Username);
     SessionManagement.IncreaseDisconnection();
     Logging.WriteLine("[UserMgr] [ " + this.Username + " ] got disconnected.", ConsoleColor.DarkRed);
     if (!this.HabboinfoSaved)
     {
         this.HabboinfoSaved = true;
         using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
         {
             queryreactor.runFastQuery(string.Concat(new object[]
             {
                 "UPDATE users SET activity_points = ",
                 this.ActivityPoints,
                 ", credits = ",
                 this.Credits,
                 ", seasonal_currency = ",
                 this.BelCredits,
                 ",online='0' WHERE id = ",
                 this.Id,
                 " LIMIT 1;UPDATE user_stats SET achievement_score=",
                 this.AchievementPoints,
                 " WHERE id=",
                 this.Id,
                 " LIMIT 1;"
             }));
             if (this.Rank >= 4u)
             {
                 queryreactor.runFastQuery("UPDATE moderation_tickets SET status='open', moderator_id=0 WHERE status='picked' AND moderator_id=" + this.Id);
             }
         }
     }
     if (this.InRoom && this.CurrentRoom != null)
     {
         this.CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(this.mClient, false, false);
     }
     if (this.Messenger != null)
     {
         this.Messenger.AppearOffline = true;
         this.Messenger.Destroy();
     }
     if (this.AppearOffline)
     {
         this.Messenger.AppearOffline = true;
     }
     if (this.AvatarEffectsInventoryComponent != null)
     {
         this.AvatarEffectsInventoryComponent.Dispose();
     }
     this.mClient = null;
 }
示例#24
0
 internal static Game getGame()
 {
     return(CyberEnvironment.GetGame());
 }
示例#25
0
 internal void Serialize(ServerMessage Message, bool gotPublicRoom)
 {
     if (Message == null)
     {
         return;
     }
     if (this.IsSpectator)
     {
         return;
     }
     if (!this.IsBot)
     {
         if (!this.IsBot && this.GetClient() != null && this.GetClient().GetHabbo() != null)
         {
             Guild group = CyberEnvironment.GetGame().GetGroupManager().GetGroup(this.GetClient().GetHabbo().FavouriteGroup);
             Habbo habbo = this.GetClient().GetHabbo();
             Message.AppendUInt(habbo.Id);
             Message.AppendString(habbo.Username);
             Message.AppendString(habbo.Motto);
             Message.AppendString(habbo.Look);
             Message.AppendInt32(this.VirtualId);
             Message.AppendInt32(this.X);
             Message.AppendInt32(this.Y);
             Message.AppendString(TextHandling.GetString(this.Z));
             Message.AppendInt32(0);
             Message.AppendInt32(1);
             Message.AppendString(habbo.Gender.ToLower());
             if (group != null)
             {
                 Message.AppendUInt(group.Id);
                 Message.AppendInt32(0);
                 Message.AppendString(group.Name);
             }
             else
             {
                 Message.AppendInt32(0);
                 Message.AppendInt32(0);
                 Message.AppendString("");
             }
             Message.AppendString("");
             Message.AppendInt32(habbo.AchievementPoints);
             Message.AppendBoolean(false);
         }
         return;
     }
     Message.AppendUInt(this.BotAI.BaseId);
     Message.AppendString(this.BotData.Name);
     Message.AppendString(this.BotData.Motto);
     if (this.BotData.AiType == AIType.Pet)
     {
         if (this.PetData.Type == 16u)
         {
             Message.AppendString(this.PetData.MoplaBreed.PlantData);
         }
         else
         {
             if (this.PetData.HaveSaddle == Convert.ToBoolean(2))
             {
                 Message.AppendString(string.Concat(new object[]
                 {
                     this.BotData.Look.ToLower(),
                     " 3 4 10 0 2 ",
                     this.PetData.PetHair,
                     " ",
                     this.PetData.HairDye,
                     " 3 ",
                     this.PetData.PetHair,
                     " ",
                     this.PetData.HairDye
                 }));
             }
             else
             {
                 if (this.PetData.HaveSaddle == Convert.ToBoolean(1))
                 {
                     Message.AppendString(string.Concat(new object[]
                     {
                         this.BotData.Look.ToLower(),
                         " 3 2 ",
                         this.PetData.PetHair,
                         " ",
                         this.PetData.HairDye,
                         " 3 ",
                         this.PetData.PetHair,
                         " ",
                         this.PetData.HairDye,
                         " 4 9 0"
                     }));
                 }
                 else
                 {
                     Message.AppendString(string.Concat(new object[]
                     {
                         this.BotData.Look.ToLower(),
                         " 2 2 ",
                         this.PetData.PetHair,
                         " ",
                         this.PetData.HairDye,
                         " 3 ",
                         this.PetData.PetHair,
                         " ",
                         this.PetData.HairDye
                     }));
                 }
             }
         }
     }
     else
     {
         Message.AppendString(this.BotData.Look.ToLower());
     }
     Message.AppendInt32(this.VirtualId);
     Message.AppendInt32(this.X);
     Message.AppendInt32(this.Y);
     Message.AppendString(TextHandling.GetString(this.Z));
     Message.AppendInt32(0);
     Message.AppendInt32((this.BotData.AiType == AIType.Generic) ? 4 : 2);
     if (this.BotData.AiType == AIType.Pet)
     {
         Message.AppendUInt(this.PetData.Type);
         Message.AppendUInt(this.PetData.OwnerId);
         Message.AppendString(this.PetData.OwnerName);
         Message.AppendInt32((this.PetData.Type == 16u) ? 0 : 1);
         Message.AppendBoolean(this.PetData.HaveSaddle);
         Message.AppendBoolean(this.RidingHorse);
         Message.AppendInt32(0);
         Message.AppendInt32((this.PetData.Type == 16u) ? 1 : 0);
         Message.AppendString((this.PetData.Type == 16u) ? this.PetData.MoplaBreed.GrowStatus : "");
         return;
     }
     Message.AppendString(this.BotData.Gender.ToLower());
     Message.AppendUInt(this.BotData.OwnerId);
     Message.AppendString(CyberEnvironment.GetGame().GetClientManager().GetNameById(this.BotData.OwnerId));
     Message.AppendInt32(4);
     Message.AppendShort(1);
     Message.AppendShort(2);
     Message.AppendShort(5);
     Message.AppendShort(4);
 }
示例#26
0
 internal GameClient GetClient()
 {
     return(CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId));
 }
示例#27
0
 internal Item GetBaseItem()
 {
     return(CyberEnvironment.GetGame().GetItemManager().GetItem(this.BaseId));
 }
示例#28
0
        internal static UserData GetUserData(string sessionTicket, string ip, out byte errorCode)
        {
            DataTable dataTable = null;
            DataRow   dataRow;
            uint      Userid;
            DataTable dataTable2;
            DataTable table;
            DataRow   row;
            DataTable dataTable3;
            DataTable dataTable4;
            DataTable dataTable5;
            DataRow   dataRow2;
            DataTable dataTable6;
            DataTable dataTable7;
            DataTable dataTable8;
            DataTable dataTable9;
            DataTable dataTable10;
            DataTable dataTable11;
            DataTable dataTable12;
            DataTable dataTable13;
            DataTable table2;
            DataTable dataTable14;
            DataTable dataTable15;

            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.setQuery("SELECT * FROM users WHERE auth_ticket = @sso ");
                queryreactor.addParameter("sso", sessionTicket);
                queryreactor.addParameter("ipaddress", ip);
                dataRow = queryreactor.getRow();
                if (dataRow == null)
                {
                    errorCode = 1;
                    throw new UserDataNotFoundException(string.Format("No user found with ip {0} and sso {1}.", ip, sessionTicket));
                }
                Userid = Convert.ToUInt32(dataRow["id"]);
                queryreactor.runFastQuery("UPDATE users SET online='1' WHERE id=" + Userid + " LIMIT 1");
                if (CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(Userid) != null)
                {
                    errorCode = 2;
                    CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(Userid).Disconnect();
                    return(null);
                }
                queryreactor.setQuery("SELECT * FROM user_achievement WHERE userid = " + Userid);
                dataTable2 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM user_talents WHERE userid = " + Userid);
                table = queryreactor.getTable();
                queryreactor.setQuery("SELECT COUNT(*) FROM user_stats WHERE id=" + Userid);
                if (int.Parse(queryreactor.getString()) == 0)
                {
                    queryreactor.runFastQuery("INSERT INTO user_stats (id) VALUES (" + Userid + ");");
                }
                queryreactor.setQuery("SELECT * FROM user_stats WHERE id=" + Userid + " LIMIT 1");
                row = queryreactor.getRow();
                queryreactor.setQuery("SELECT room_id FROM user_favorites WHERE user_id = " + Userid);
                dataTable3 = queryreactor.getTable();
                queryreactor.setQuery("SELECT ignore_id FROM user_ignores WHERE user_id = " + Userid);
                dataTable4 = queryreactor.getTable();
                queryreactor.setQuery("SELECT tag FROM user_tags WHERE user_id = " + Userid);
                dataTable5 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM user_subscriptions WHERE user_id = " + Userid + " AND timestamp_expire > UNIX_TIMESTAMP() ORDER BY subscription_id DESC LIMIT 1");
                dataRow2 = queryreactor.getRow();
                queryreactor.setQuery("SELECT * FROM user_badges WHERE user_id = " + Userid);
                dataTable6 = queryreactor.getTable();
                queryreactor.setQuery("SELECT `items`.* , COALESCE(`items_groups`.`group_id`, 0) AS group_id FROM `items` LEFT OUTER JOIN `items_groups` ON `items`.`id` = `items_groups`.`id` WHERE room_id='0' AND user_id=" + Userid + " LIMIT 8000");
                dataTable7 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM user_effects WHERE user_id =  " + Userid);
                dataTable8 = queryreactor.getTable();
                queryreactor.setQuery("SELECT poll_id FROM user_polldata WHERE user_id = " + Userid + " GROUP BY poll_id;");
                dataTable9 = queryreactor.getTable();
                queryreactor.setQuery(string.Concat(new object[]
                {
                    "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.user_one_id WHERE messenger_friendships.user_two_id = ",
                    Userid,
                    " UNION ALL SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.user_two_id WHERE messenger_friendships.user_one_id = ",
                    Userid
                }));
                dataTable10 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM user_stats WHERE id=" + Userid + " LIMIT 1");
                row = queryreactor.getRow();
                queryreactor.setQuery("SELECT messenger_requests.from_id,messenger_requests.to_id,users.username FROM users JOIN messenger_requests ON users.id = messenger_requests.from_id WHERE messenger_requests.to_id = " + Userid);
                dataTable11 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM rooms WHERE owner = @name LIMIT 150");
                queryreactor.addParameter("name", (string)dataRow["username"]);
                dataTable12 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM bots WHERE user_id = " + Userid + " AND room_id = 0 AND ai_type='pet'");
                dataTable13 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM user_quests WHERE user_id = " + Userid);
                table2 = queryreactor.getTable();
                queryreactor.setQuery("SELECT * FROM bots WHERE user_id=" + Userid + " AND room_id=0 AND ai_type='generic'");
                dataTable14 = queryreactor.getTable();
                queryreactor.setQuery("SELECT group_id,rank FROM group_memberships WHERE user_id=" + Userid);
                dataTable = queryreactor.getTable();
                queryreactor.setQuery(string.Concat(new object[]
                {
                    "UPDATE user_info SET login_timestamp = '",
                    CyberEnvironment.GetUnixTimestamp(),
                    "' WHERE user_id = ",
                    Userid,
                    " ; "
                }));
                queryreactor.addParameter("ip", ip);
                queryreactor.runQuery();
                queryreactor.setQuery("SELECT * FROM user_relationships WHERE user_id=@id");
                queryreactor.addParameter("id", Userid);
                dataTable15 = queryreactor.getTable();
                queryreactor.runFastQuery("UPDATE users SET online='1' WHERE id=" + Userid + " LIMIT 1");
            }
            Dictionary <string, UserAchievement> dictionary = new Dictionary <string, UserAchievement>();

            foreach (DataRow dataRow3 in dataTable2.Rows)
            {
                string          text     = (string)dataRow3["group"];
                int             level    = (int)dataRow3["level"];
                int             progress = (int)dataRow3["progress"];
                UserAchievement value    = new UserAchievement(text, level, progress);
                dictionary.Add(text, value);
            }
            Dictionary <int, UserTalent> dictionary2 = new Dictionary <int, UserTalent>();

            foreach (DataRow dataRow4 in table.Rows)
            {
                int        num2   = (int)dataRow4["talent_id"];
                int        state  = (int)dataRow4["talent_state"];
                UserTalent value2 = new UserTalent(num2, state);
                dictionary2.Add(num2, value2);
            }
            List <uint> list = new List <uint>();

            foreach (DataRow dataRow5 in dataTable3.Rows)
            {
                uint item = Convert.ToUInt32(dataRow5["room_id"]);
                list.Add(item);
            }
            List <uint> list2 = new List <uint>();

            foreach (DataRow dataRow6 in dataTable4.Rows)
            {
                uint item2 = Convert.ToUInt32(dataRow6["ignore_id"]);
                list2.Add(item2);
            }
            List <string> list3 = new List <string>();

            foreach (DataRow dataRow7 in dataTable5.Rows)
            {
                string item3 = dataRow7["tag"].ToString().Replace(" ", "");
                list3.Add(item3);
            }
            Subscription sub = null;

            if (dataRow2 != null)
            {
                sub = new Subscription((int)dataRow2["subscription_id"], (int)dataRow2["timestamp_activated"], (int)dataRow2["timestamp_expire"], (int)dataRow2["timestamp_lastgift"]);
            }
            Dictionary <uint, RoomBot> dictionary3 = new Dictionary <uint, RoomBot>();

            foreach (DataRow row2 in dataTable14.Rows)
            {
                RoomBot roomBot = BotManager.GenerateBotFromRow(row2);
                dictionary3.Add(roomBot.BotId, roomBot);
            }
            List <Badge> list4 = new List <Badge>();

            foreach (DataRow dataRow8 in dataTable6.Rows)
            {
                string code = (string)dataRow8["badge_id"];
                int    slot = (int)dataRow8["badge_slot"];
                list4.Add(new Badge(code, slot));
            }

            int miniMailCount = 0;

            try
            {
                DataRow Rowi;
                using (IQueryAdapter dbClient = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    dbClient.setQuery("SELECT Count( IsReaded ) FROM xdrcms_minimail WHERE InBin = 0 AND IsReaded = 0 AND SenderId != " + Userid + " AND OwnerId = " + Userid);
                    Rowi = dbClient.getRow();
                }
                if (Rowi != null)
                {
                    // We are using aXDR CMS with MiniMail!
                    miniMailCount = int.Parse(Rowi[0].ToString());
                }
            }
            catch { }

            List <UserItem> list5 = new List <UserItem>();

            foreach (DataRow dataRow9 in dataTable7.Rows)
            {
                uint   id       = Convert.ToUInt32(dataRow9[0]);
                uint   baseItem = Convert.ToUInt32(dataRow9[3]);
                string extraData;
                if (!DBNull.Value.Equals(dataRow9[4]))
                {
                    extraData = (string)dataRow9[4];
                }
                else
                {
                    extraData = string.Empty;
                }
                uint   group    = Convert.ToUInt32(dataRow9["group_id"]);
                string songCode = (string)dataRow9["songcode"];
                list5.Add(new UserItem(id, baseItem, extraData, group, songCode));
            }
            List <AvatarEffect> list6 = new List <AvatarEffect>();

            foreach (DataRow dataRow10 in dataTable8.Rows)
            {
                int    effectId          = (int)dataRow10["effect_id"];
                int    totalDuration     = (int)dataRow10["total_duration"];
                bool   activated         = CyberEnvironment.EnumToBool((string)dataRow10["is_activated"]);
                double activateTimestamp = (double)dataRow10["activated_stamp"];
                list6.Add(new AvatarEffect(effectId, totalDuration, activated, activateTimestamp));
            }

            HashSet <uint> pollSuggested = new HashSet <uint>();

            foreach (DataRow Row in dataTable9.Rows)
            {
                uint pId = (uint)Row["poll_id"];
                pollSuggested.Add(pId);
            }

            Dictionary <uint, MessengerBuddy> dictionary4 = new Dictionary <uint, MessengerBuddy>();
            string arg_A3D_0 = (string)dataRow["username"];
            int    num3      = checked (dataTable10.Rows.Count - 700);

            if (num3 > 0)
            {
                using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor2.runFastQuery(string.Concat(new object[]
                    {
                        "DELETE FROM messenger_friendships WHERE user_one_id=",
                        Userid,
                        " OR user_two_id=",
                        Userid,
                        " LIMIT ",
                        num3
                    }));
                    queryreactor2.setQuery(string.Concat(new object[]
                    {
                        "SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.user_one_id WHERE messenger_friendships.user_two_id = ",
                        Userid,
                        " UNION ALL SELECT users.id,users.username,users.motto,users.look,users.last_online,users.hide_inroom,users.hide_online FROM users JOIN messenger_friendships ON users.id = messenger_friendships.user_two_id WHERE messenger_friendships.user_one_id = ",
                        Userid
                    }));
                    dataTable10 = queryreactor2.getTable();
                }
            }
            foreach (DataRow dataRow12 in dataTable10.Rows)
            {
                uint   num4           = Convert.ToUInt32(dataRow12["id"]);
                string pUsername      = (string)dataRow12["username"];
                string pLook          = (string)dataRow12["look"];
                string pMotto         = (string)dataRow12["motto"];
                int    pLastOnline    = Convert.ToInt32(dataRow12["last_online"]);
                bool   pAppearOffline = CyberEnvironment.EnumToBool(dataRow12["hide_online"].ToString());
                bool   pHideInroom    = CyberEnvironment.EnumToBool(dataRow12["hide_inroom"].ToString());
                if (num4 != Userid && !dictionary4.ContainsKey(num4))
                {
                    dictionary4.Add(num4, new MessengerBuddy(num4, pUsername, pLook, pMotto, pLastOnline, pAppearOffline, pHideInroom));
                }
            }
            Dictionary <uint, MessengerRequest> dictionary5 = new Dictionary <uint, MessengerRequest>();

            foreach (DataRow dataRow13 in dataTable11.Rows)
            {
                uint   num5       = Convert.ToUInt32(dataRow13["from_id"]);
                uint   num6       = Convert.ToUInt32(dataRow13["to_id"]);
                string pUsername2 = (string)dataRow13["username"];
                if (num5 != Userid)
                {
                    if (!dictionary5.ContainsKey(num5))
                    {
                        dictionary5.Add(num5, new MessengerRequest(Userid, num5, pUsername2));
                    }
                }
                else
                {
                    if (!dictionary5.ContainsKey(num6))
                    {
                        dictionary5.Add(num6, new MessengerRequest(Userid, num6, pUsername2));
                    }
                }
            }
            HashSet <RoomData> list8 = new HashSet <RoomData>();

            foreach (DataRow dataRow14 in dataTable12.Rows)
            {
                uint roomId = Convert.ToUInt32(dataRow14["id"]);
                list8.Add(CyberEnvironment.GetGame().GetRoomManager().FetchRoomData(roomId, dataRow14));
            }
            Dictionary <uint, Pet> dictionary6 = new Dictionary <uint, Pet>();

            foreach (DataRow dataRow15 in dataTable13.Rows)
            {
                using (IQueryAdapter queryreactor3 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                {
                    queryreactor3.setQuery("SELECT * FROM bots_petdata WHERE id=" + dataRow15[0] + " LIMIT 1");
                    DataRow row3 = queryreactor3.getRow();
                    if (row3 != null)
                    {
                        Pet pet = Catalog.GeneratePetFromRow(dataRow15, row3);
                        dictionary6.Add(pet.PetId, pet);
                    }
                }
            }
            Dictionary <uint, int> dictionary7 = new Dictionary <uint, int>();

            foreach (DataRow dataRow16 in table2.Rows)
            {
                uint key    = Convert.ToUInt32(dataRow16["quest_id"]);
                int  value3 = (int)dataRow16["progress"];
                if (dictionary7.ContainsKey(key))
                {
                    dictionary7.Remove(key);
                }
                dictionary7.Add(key, value3);
            }
            HashSet <GroupUser> list9 = new HashSet <GroupUser>();

            foreach (DataRow dataRow17 in dataTable.Rows)
            {
                list9.Add(new GroupUser(Userid, (uint)dataRow17[0], (int)Convert.ToInt16(dataRow17[1])));
            }
            Dictionary <int, Relationship> dictionary8 = new Dictionary <int, Relationship>();

            foreach (DataRow dataRow18 in dataTable15.Rows)
            {
                dictionary8.Add((int)dataRow18[0], new Relationship((int)dataRow18[0], (int)dataRow18[2], Convert.ToInt32(dataRow18[3].ToString())));
            }
            Habbo user = HabboFactory.GenerateHabbo(dataRow, row, list9);

            dataRow     = null;
            dataTable2  = null;
            dataTable3  = null;
            dataTable4  = null;
            dataTable5  = null;
            dataRow2    = null;
            dataTable6  = null;
            dataTable7  = null;
            dataTable8  = null;
            dataTable10 = null;
            dataTable11 = null;
            dataTable12 = null;
            dataTable13 = null;
            dataTable14 = null;
            dataTable15 = null;
            dataTable9  = null;
            errorCode   = 0;
            return(new UserData(Userid, dictionary, dictionary2, list, list2, list3, sub, list4, list5, list6, dictionary4, dictionary5, list8, dictionary6, dictionary7, user, dictionary3, dictionary8, pollSuggested, miniMailCount));
        }
示例#29
0
        internal void BanzaiEnd()
        {
            this.banzaiStarted = false;
            this.room.GetGameManager().StopGame();
            this.floorMap = (byte[, ])null;
            this.room.GetWiredHandler().ExecuteWired(WiredItemType.TriggerGameEnds, new object[0]);
            Team winningTeam = this.room.GetGameManager().getWinningTeam();

            this.room.GetGameManager().UnlockGates();
            foreach (RoomItem roomItem in (IEnumerable)this.banzaiTiles.Values)
            {
                if (roomItem.team == winningTeam)
                {
                    roomItem.interactionCount       = (byte)0;
                    roomItem.interactionCountHelper = (byte)0;
                    roomItem.UpdateNeeded           = true;
                }
                else if (roomItem.team == Team.none)
                {
                    roomItem.ExtraData = "0";
                    roomItem.UpdateState();
                }
            }
            if (winningTeam == Team.none)
            {
                return;
            }
            foreach (RoomUser Avatar in this.room.GetRoomUserManager().GetRoomUsers())
            {
                if (Avatar.team != Team.none && (double)CyberEnvironment.GetUnixTimestamp() - this.timestarted > 5.0)
                {
                    CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallTilesLocked", Avatar.LockedTilesCount, false);
                    CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallPlayer", 1, false);
                }

                if (winningTeam == Team.blue)
                {
                    if (Avatar.CurrentEffect == 35)
                    {
                        if ((double)CyberEnvironment.GetUnixTimestamp() - this.timestarted > 5.0)
                        {
                            CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallWinner", 1, false);
                        }
                        ServerMessage waveAtWin = new ServerMessage(Outgoing.RoomUserActionMessageComposer);
                        waveAtWin.AppendInt32(Avatar.VirtualId);
                        waveAtWin.AppendInt32(1);
                        this.room.SendMessage(waveAtWin);
                    }
                }
                else if (winningTeam == Team.red)
                {
                    if (Avatar.CurrentEffect == 33)
                    {
                        if ((double)CyberEnvironment.GetUnixTimestamp() - this.timestarted > 5.0)
                        {
                            CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallWinner", 1, false);
                        }
                        ServerMessage waveAtWin = new ServerMessage(Outgoing.RoomUserActionMessageComposer);
                        waveAtWin.AppendInt32(Avatar.VirtualId);
                        waveAtWin.AppendInt32(1);
                        this.room.SendMessage(waveAtWin);
                    }
                }
                else if (winningTeam == Team.green)
                {
                    if (Avatar.CurrentEffect == 34)
                    {
                        if ((double)CyberEnvironment.GetUnixTimestamp() - this.timestarted > 5.0)
                        {
                            CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallWinner", 1, false);
                        }
                        ServerMessage waveAtWin = new ServerMessage(Outgoing.RoomUserActionMessageComposer);
                        waveAtWin.AppendInt32(Avatar.VirtualId);
                        waveAtWin.AppendInt32(1);
                        this.room.SendMessage(waveAtWin);
                    }
                }
                else if (winningTeam == Team.yellow && Avatar.CurrentEffect == 36)
                {
                    if ((double)CyberEnvironment.GetUnixTimestamp() - this.timestarted > 5.0)
                    {
                        CyberEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Avatar.GetClient(), "ACH_BattleBallWinner", 1, false);
                    }
                    ServerMessage waveAtWin = new ServerMessage(Outgoing.RoomUserActionMessageComposer);
                    waveAtWin.AppendInt32(Avatar.VirtualId);
                    waveAtWin.AppendInt32(1);
                    this.room.SendMessage(waveAtWin);
                }
            }
            this.field.destroy();
        }
示例#30
0
        internal void AddExperience(int Amount)
        {
            checked
            {
                int oldExperienceGoal = this.experienceGoal;
                this.Experience += Amount;
                if (this.Experience >= 51900)
                {
                    return;
                }
                if (this.DBState != DatabaseUpdateState.NeedsInsert)
                {
                    this.DBState = DatabaseUpdateState.NeedsUpdate;
                }
                if (this.Room != null)
                {
                    ServerMessage serverMessage = new ServerMessage(Outgoing.AddPetExperienceMessageComposer);
                    serverMessage.AppendUInt(this.PetId);
                    serverMessage.AppendInt32(this.VirtualId);
                    serverMessage.AppendInt32(Amount);
                    this.Room.SendMessage(serverMessage);

                    if (this.Experience >= oldExperienceGoal)
                    {
                        GameClients.GameClient OwnerSession = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(OwnerId);

                        // Reset pet commands
                        PetCommands.Clear();
                        PetCommands = PetCommandHandler.GetPetCommands(this);

                        if (OwnerSession != null)
                        {
                            ServerMessage LevelNotify = new ServerMessage(Outgoing.NotifyNewPetLevelMessageComposer);
                            this.SerializeInventory(LevelNotify, true);
                            OwnerSession.SendMessage(LevelNotify);

                            ServerMessage TP = new ServerMessage();
                            TP.Init(Outgoing.PetTrainerPanelMessageComposer);
                            TP.AppendUInt(this.PetId);

                            List <short> AvailableCommands = new List <short>();

                            TP.AppendInt32(PetCommands.Count);
                            foreach (short Sh in PetCommands.Keys)
                            {
                                TP.AppendInt32(Sh);
                                if (PetCommands[Sh] == true)
                                {
                                    AvailableCommands.Add(Sh);
                                }
                            }

                            TP.AppendInt32(AvailableCommands.Count);
                            foreach (short Sh in AvailableCommands)
                            {
                                TP.AppendInt32(Sh);
                            }
                            OwnerSession.SendMessage(TP);
                        }
                    }
                }
            }
        }