Exemplo n.º 1
0
        /// <summary>
        /// Refreshes the session user's club status.
        /// </summary>
        public void refreshClubStatus()
        {
            if (this.isHoldingUser)
            {
                serverMessage Message = new serverMessage(7); // "@G"
                Message.appendClosedValue("club_habbo");
                Message.appendWired(this.User.clubDaysLeft);
                Message.appendWired(this.User.clubMonthsExpired);
                Message.appendWired(this.User.clubMonthsLeft);
                Message.appendWired(true); // Hide/shows 'days left' label

                this.gameConnection.sendMessage(Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 56 - "@x"
        /// </summary>
        public void WHISPER()
        {
            roomUser Me = Session.roomInstance.getRoomUser(Session.ID);
            if (!Me.isMuted)
            {
                string whisperBody = Request.getParameter(0);
                string receiverName = whisperBody.Substring(0, whisperBody.IndexOf(' '));
                string Text = whisperBody.Substring(receiverName.Length + 1);
                stringFunctions.filterVulnerableStuff(ref Text, true);

                serverMessage Whisper = new serverMessage(25); // "@Y"
                Whisper.appendWired(Me.ID);
                Whisper.appendClosedValue(Text);

                Session.gameConnection.sendMessage(Whisper);
                if (receiverName.Length > 0 && receiverName != Session.User.Username)
                {
                    roomUser Receiver = Session.roomInstance.getRoomUser(receiverName);
                    if (Receiver != null)
                        Receiver.Session.gameConnection.sendMessage(Whisper);
                    ObjectTree.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, Receiver.Session.User.ID, chatType.whisper, ref Text);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Only works if the session user is in a room. If so, then a whisper with a given message is sent to the user only.
        /// </summary>
        /// <param name="Message">The text message to whisper to the user.</param>
        public void castWhisper(string sMessage)
        {
            if (this.inRoom)
            {
                serverMessage Message = new serverMessage(25); // "@Y"
                Message.appendWired(this.roomInstance.getSessionRoomUnitID(this.ID));
                Message.appendClosedValue(sMessage);

                this.gameConnection.sendMessage(Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Refreshes the badges for this session user and re-builds the badges message. (229, "Ce")
        /// </summary>
        public void refreshBadgeList()
        {
            if (this.isHoldingUser)
            {
                List<string> myBadges = ObjectTree.Game.Roles.getDefaultBadgesForRole(this.User.Role);
                myBadges.Remove("HC1");
                ObjectTree.Game.Users.addPrivateBadgesToList(this.User.ID, this.User.Role, ref myBadges);

                if (this.User.hasClub) // Regular club member
                    myBadges.Add("HC1"); // TODO: make this configurable
                if (this.User.hasGoldClub) // Gold club member
                    myBadges.Add("HC2"); // TODO: make this configurable

                if (!myBadges.Contains(this.User.Badge)) // Set badge not valid anymore
                    this.User.Badge = "";

                serverMessage Message = new serverMessage(229); // "Ce"
                Message.appendWired(myBadges.Count);

                int badgeSlot = 0;
                int slotCounter = 0;
                foreach (string lBadge in myBadges)
                {
                    Message.appendClosedValue(lBadge);
                    if (lBadge == this.User.Badge) // Current badge, set slot
                        badgeSlot = slotCounter;

                    slotCounter++;
                }
                Message.appendWired(badgeSlot);
                Message.appendWired((this.User.Badge.Length > 0));

                this.gameConnection.sendMessage(Message);
            }
        }
Exemplo n.º 5
0
        private void runRollers()
        {
            if (mRollerTimer > DateTime.Now.TimeOfDay.TotalSeconds && mRollerDay == DateTime.Today.DayOfYear)
                return;

            StringBuilder Updates = new StringBuilder();
            List<int> movedRoomUnitIDs = new List<int>();
            List<int> movedItemIDs = new List<int>();

            try
            {
                foreach (floorItem lRoller in this.floorItems)
                {
                    if (!lRoller.Definition.Behaviour.isRoller)
                        continue; // Not a roller item

                    #region General
                    // Workout direction for roller
                    byte nextX = lRoller.X;
                    byte nextY = lRoller.Y;
                    if (lRoller.Rotation == 0)
                        nextY--;
                    else if (lRoller.Rotation == 2)
                        nextX++;
                    else if (lRoller.Rotation == 4)
                        nextY++;
                    else if (lRoller.Rotation == 6)
                        nextX--;

                    if (!tileExists(nextX, nextY) || tileBlockedByRoomUnit(nextX, nextY))
                        continue; // Can't roll off room map / on room unit
                    #endregion

                    #region Get objects on current tile and verify
                    roomUnit pUnit = this.getRoomUnitOnTile(lRoller.X, lRoller.Y); // Get room unit on this roller
                    List<floorItem> pItems = new List<floorItem>();
                    foreach (floorItem lItem in this.getFloorItems(lRoller.X, lRoller.Y))
                    {
                        if (!lItem.Definition.Behaviour.isRoller && !movedItemIDs.Contains(lItem.ID))
                            pItems.Add(lItem);
                    }

                    if (pUnit != null && (pUnit.Moves || movedRoomUnitIDs.Contains(pUnit.ID)))
                    {
                        pUnit = null; // Invalid room unit
                    }

                    if (pUnit == null && pItems.Count == 0)
                        continue; // No items on roller and no room unit aswell
                    #endregion

                    // Get items on next tile and perform some checks
                    bool nextTileIsRoller = false;
                    bool canMoveItems = (this.gridState[nextX, nextY] == roomTileState.Free);
                    bool canMoveUnit = canMoveItems;

                    bool nextTileUnitInteractiveStance = false;

                    foreach (floorItem lItem in this.getFloorItems(nextX, nextY))
                    {
                        if (lItem.Definition.Behaviour.isRoller)
                        {
                            nextTileIsRoller = true;
                            continue;
                        }

                        if (lItem.Definition.Behaviour.isSolid)
                        {
                            canMoveItems = false;
                            canMoveUnit = false;

                            if (lItem.Definition.Behaviour.isDoor)
                            {
                                if (lItem.customData == "O") // Door is open
                                    canMoveUnit = true; // Can move unit in door
                            }
                        }
                        else if (pUnit != null && lItem.Definition.isInteractiveStance)
                        {
                            nextTileUnitInteractiveStance = true;
                            if(!nextTileIsRoller)
                                canMoveUnit = true;
                        }
                    }

                    if (!canMoveItems) // Can't move items
                    {
                        if (!canMoveUnit) // Can't move unit aswell
                            continue; // Can't run this roller

                        pItems.Clear(); // Clear items to move
                    }

                    #region Generate notification and move objects
                    serverMessage eventNotification = new serverMessage(230); // "Cf"
                    eventNotification.appendWired(lRoller.X);
                    eventNotification.appendWired(lRoller.Y);
                    eventNotification.appendWired(nextX);
                    eventNotification.appendWired(nextY);

                    eventNotification.appendWired(pItems.Count);
                    foreach (floorItem lItem in pItems)
                    {
                        float nextZ = lItem.Z;
                        if (!nextTileIsRoller)
                            nextZ -= lRoller.Definition.topHeight;

                        eventNotification.appendWired(lItem.ID);
                        eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(lItem.Z));
                        eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(nextZ));

                        lItem.X = nextX;
                        lItem.Y = nextY;
                        lItem.Z = nextZ;
                        lItem.requiresUpdate = true;

                        movedItemIDs.Add(lItem.ID);
                        generateFloorMap();
                    }

                    eventNotification.appendWired(lRoller.ID);

                    if (pUnit != null) // Room unit lifting with roller
                    {
                        float nextZ = pUnit.Z;
                        if (!nextTileIsRoller)
                            nextZ -= lRoller.Definition.topHeight;

                        pUnit.X = nextX;
                        pUnit.Y = nextY;
                        pUnit.Z = nextZ;
                        pUnit.requiresUpdate = true;

                        if (!nextTileIsRoller || nextTileUnitInteractiveStance)
                            this.setRoomUnitTileState(pUnit);

                        this.gridUnit[lRoller.X, lRoller.Y] = false;
                        this.gridUnit[pUnit.X, pUnit.Y] = true;

                        eventNotification.appendWired(2);
                        eventNotification.appendWired(pUnit.ID);
                        eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(pUnit.Z));
                        eventNotification.appendClosedValue(stringFunctions.formatFloatForClient(nextZ));

                        movedRoomUnitIDs.Add(pUnit.ID);
                    }
                    #endregion

                    Updates.Append(eventNotification.ToString());
                }

                if (Updates.Length > 0)
                {
                    this.sendMessage(Updates.ToString());
                }

                this.mRollerTimer = DateTime.Now.TimeOfDay.TotalSeconds + rollerDelaySeconds;
                this.mRollerDay = DateTime.Today.DayOfYear;
            }
            catch (Exception ex)
            {
                Core.Logging.Log("Rollers in room instance of room " + this.roomID + " crashed, exception: " + ex.Message);
                this.hasRollers = false;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Writes a buddy request from a given user to another user into the database, and notifies the receiver with the new request if it's online.
        /// </summary>
        /// <param name="User">The userInformation object of the user that sends the request.</param>
        /// <param name="userID2">The database ID of the receiving user.</param>
        public void requestBuddy(userInformation User, int userID2)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", User.ID);
            Database.addParameterWithValue("userid2", userID2);
            Database.Open();
            Database.runQuery("INSERT INTO messenger_buddylist(userid,buddyid) VALUES (@userid,@userid2)");

            if (ObjectTree.Game.Users.userIsLoggedIn(userID2)) // Receiver is online
            {
                serverMessage Message = new serverMessage(132); // "BD"
                Message.appendWired(User.ID);
                Message.appendClosedValue(User.Username);

                ObjectTree.Game.Users.trySendGameMessage(userID2, Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Updates the badge status of a given room user in the room.
        /// </summary>
        /// <param name="sessionID">The session ID of the session where the target room user belongs to.</param>
        public void updateUserBadge(uint sessionID)
        {
            serverMessage Notify = new serverMessage(228); // "Cd"

            roomUser rUser = roomUsers[sessionID];
            Notify.appendWired(rUser.ID);
            if (rUser.Session.User.Badge.Length > 0)
                Notify.appendClosedValue(rUser.Session.User.Badge);

            sendMessage(Notify);
        }
Exemplo n.º 8
0
        public void sendTalk(int sourceID, byte sourceX, byte sourceY, string Text)
        {
            string sFullMessage = "";

            serverMessage Message = new serverMessage(24); // "@X"
            Message.appendWired(sourceID);
            Message.appendClosedValue(Text);
            sFullMessage = Message.ToString();
            Message = null;

            lock (roomUsers)
            {
                foreach (roomUser lRoomUser in roomUsers.Values)
                {
                    int distX = Math.Abs(sourceX - lRoomUser.X) - 1;
                    int distY = Math.Abs(sourceY - lRoomUser.Y) - 1;

                    if (distX < 9 && distY < 9) // User can hear
                    {
                        if (distX <= 6 && distY <= 6) // User can hear full message
                            lRoomUser.Session.gameConnection.sendMessage(sFullMessage);
                        else // User can hear garbled message
                        {
                            Message = new serverMessage(24); // "@X"
                            Message.appendWired(sourceID);

                            int garbleIntensity = distX;
                            if (distY < distX)
                                garbleIntensity = distY;
                            garbleIntensity -= 4;

                            string garbledText = Text;
                            stringFunctions.garbleText(ref garbledText, garbleIntensity);

                            Message.appendClosedValue(garbledText);
                            lRoomUser.Session.gameConnection.sendMessage(Message);
                            Message = null;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void sendShout(int sourceID, byte sourceX, byte sourceY, string Text)
        {
            serverMessage Message = new serverMessage(26); // "@Z"
            Message.appendWired(sourceID);
            Message.appendClosedValue(Text);

            sendMessage(Message);
            // TODO: head rotation
        }