Beispiel #1
0
        /// <summary>
        /// Accepts a buddy request and notifies the sender (if online) and the receiver.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object of the user that accepts the request.</param>
        /// <param name="senderID">The database ID of the user that sent the request.</param>
        public void acceptBuddyRequest(ref Session Session, int senderID)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("userid", Session.User.ID);
            Database.addParameterWithValue("senderid", senderID);
            Database.Open();

            if (Database.findsResult("SELECT userid FROM messenger_buddylist WHERE userid = @senderid AND buddyid = @userid AND accepted = '0' LIMIT 1"))
            {
                Database.runQuery("UPDATE messenger_buddylist SET accepted = '1' WHERE userid = @senderid AND buddyid = @userid LIMIT 1");
                Database.Close();

                serverMessage Message = new serverMessage();
                if (ObjectTree.Game.Users.userIsLoggedIn(senderID)) // Sender is online!
                {
                    Message.Initialize(137); // "BI"
                    Message.Append(getBuddy(Session.User.ID).ToString());
                    ObjectTree.Game.Users.trySendGameMessage(senderID, Message);
                }

                Message.Initialize(137); // "BI"
                Message.Append(getBuddy(senderID).ToString());
                Session.gameConnection.sendMessage(Message);
            }
            else
                Database.Close();
        }
Beispiel #2
0
        /// <summary>
        /// 66 - "AB"
        /// </summary>
        public void FLATPROPBYITEM()
        {
            if (Session.roomInstance.sessionHasRights(Session.ID)) // Permission
            {
                int itemID = int.Parse(Request.Content.Split('/')[1]);
                stripItem pItem = Session.itemStripHandler.getHandItem(itemID);
                if (pItem != null && pItem.Definition.Behaviour.isDecoration)
                {
                    Session.itemStripHandler.removeHandItem(itemID, true);

                    int decorationValue = int.Parse(pItem.customData);
                    if (pItem.Definition.Sprite == "wallpaper")
                        Session.roomInstance.Information.Wallpaper = decorationValue;
                    else // Floor
                        Session.roomInstance.Information.Floor = decorationValue;

                    serverMessage msgUpdate = new serverMessage(46); // "@n"
                    msgUpdate.Append(pItem.Definition.Sprite);
                    msgUpdate.Append("/");
                    msgUpdate.Append(decorationValue);
                    Session.roomInstance.sendMessage(msgUpdate);

                    Session.roomInstance.Information.updateFlatProperties();
                }
            }
        }
        public static serverMessage createMessageBoxCast(string Text)
        {
            serverMessage retCast = new serverMessage(139); // "BK"
            retCast.Append(Text);

            return retCast;
        }
Beispiel #4
0
        public static serverMessage createCastAction(string target, string action)
        {
            serverMessage retCast = new serverMessage(71); // "AG"

            retCast.Append($"{target} {action}");
            return(retCast);
        }
Beispiel #5
0
        public static serverMessage createDefaultMessageBox(string Text)
        {
            serverMessage retCast = new serverMessage(139); // "BK"

            retCast.Append(Text);
            return(retCast);
        }
        public static serverMessage createBanCast(string banReason)
        {
            serverMessage retCast = new serverMessage(35); // "@c"
            retCast.Append(banReason);

            return retCast;
        }
        public static serverMessage createBanCast(string banReason)
        {
            serverMessage retCast = new serverMessage(35); // "@c"

            retCast.Append(banReason);

            return(retCast);
        }
Beispiel #8
0
        /// <summary>
        /// Refreshes the session user's credit amount. (message 6: @F)
        /// </summary>
        public void refreshCredits()
        {
            if (this.isHoldingUser)
            {
                serverMessage Message = new serverMessage(6); // "@F"
                Message.Append(this.User.Credits);
                Message.Append(".0");

                this.gameConnection.sendMessage(Message);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Refresh the trade boxes for this session's user and his/her trade partner's session user. Only works when both users are trading.
        /// </summary>
        public void refreshTradeBoxes()
        {
            if (this.itemStripHandler.isTrading)
            {
                Session partnerSession = ObjectTree.Sessions.getSession(this.itemStripHandler.tradePartnerSessionID);
                if (partnerSession == null || !partnerSession.itemStripHandler.isTrading)
                    return;

                string myBox = itemStripHandler.generateTradeBox(this);
                string partnerBox = itemStripHandler.generateTradeBox(partnerSession);

                serverMessage Message = new serverMessage(108); // "Al"
                Message.Append(myBox);
                Message.Append(partnerBox);
                this.gameConnection.sendMessage(Message);

                Message.Initialize(108); // "Al"
                Message.Append(partnerBox);
                Message.Append(myBox);
                partnerSession.gameConnection.sendMessage(Message);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Modifies the hand page index with a given mode and sends the current hand page of this user.
        /// </summary>
        /// <param name="szMode">'How-to' modify the hand page index.</param>
        public void sendHandStrip(string szMode)
        {
            if (this.itemStripHandler != null)
            {
                this.itemStripHandler.changeHandStripPage(szMode); // Switch!

                serverMessage Message = new serverMessage(140); // "BL"
                Message.Append(this.itemStripHandler.getHandItemCasts());
                Message.appendChar(13);
                Message.Append(this.itemStripHandler.handItemCount);

                this.gameConnection.sendMessage(Message);
            }
        }
Beispiel #11
0
        /// <summary>
        /// Retrieves the FUSE rights for the user on this session and sends it to the client.
        /// </summary>
        public void refreshFuseRights()
        {
            if (this.isHoldingUser)
            {
                serverMessage Message = new serverMessage(2); // "@B"
                Message.Append(ObjectTree.Game.Roles.getRightsForRole(this.User.Role, this.User.hasClub));

                this.gameConnection.sendMessage(Message);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Refreshes the session user's game ticket amount. (message 124: A|)
        /// </summary>
        public void refreshTickets()
        {
            if (this.isHoldingUser)
            {
                serverMessage Message = new serverMessage(124); // "A|"
                Message.Append(this.User.Credits);

                this.gameConnection.sendMessage(Message);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Sends the available figure parts for this session user.
        /// </summary>
        public void refreshFigureParts()
        {
            serverMessage Message = new serverMessage(8); // "@H"
            Message.Append("[");
            if (this.isHoldingUser && this.User.hasClub) // Can use 'Club' parts
                Message.Append(Configuration.getConfigurationValue("users.figure.parts.club"));
            else
                Message.Append(Configuration.getConfigurationValue("users.figure.parts.default"));
            Message.Append("]");

            this.gameConnection.sendMessage(Message);
        }
Beispiel #14
0
        /// <summary>
        /// Refreshes the session user's film amount for the camera. (message 4: @D)
        /// </summary>
        public void refreshFilm()
        {
            if (this.isHoldingUser)
            {
                serverMessage Message = new serverMessage(4); // "@D"
                Message.Append(this.User.Film);

                this.gameConnection.sendMessage(Message);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Broadcoasts the message that a user is waiting for a doorbell response. This message is only broadcoasted to users who have room rights, and True is returned if at least one room user with room rights has received it.
        /// </summary>
        /// <param name="Username">The username of the user.</param>
        public bool castDoorbellUser(string Username)
        {
            bool isHeard = false;

            serverMessage Notify = new serverMessage(91); // "A["
            Notify.Append(Username);

            lock (roomUsers)
            {
                foreach (roomUser lRoomUser in roomUsers.Values)
                {
                    if (lRoomUser.hasRights)
                    {
                        lRoomUser.Session.gameConnection.sendMessage(Notify);
                        isHeard = true;
                    }
                }
            }

            return isHeard;
        }
Beispiel #16
0
        /// <summary>
        /// Makes a room unit (so a room user, a pet, or a bot) visible to all users in the room.
        /// </summary>
        /// <param name="szDetails"></param>
        private void castRoomUnit(string szDetails)
        {
            serverMessage Cast = new serverMessage(28); // "@\"
            Cast.Append(szDetails);

            this.sendMessage(Cast);
        }
Beispiel #17
0
        private void _launchBird(int[] receiverIDs, messengerMessage pMessage)
        {
            Database Database = new Database(false, false);
            Database.addParameterWithValue("senderid", pMessage.senderID);
            Database.addParameterWithValue("sent", pMessage.Sent);
            Database.addParameterWithValue("body", pMessage.Body);
            Database.Open();
            if (Database.Ready)
            {
                //DateTime now = DateTime.Now;
                //Woodpecker.Core.Logging.Log("Start: " + now.ToString("hh:mm:ss:fff"));
                foreach (int receiverID in receiverIDs)
                {
                    if (ObjectTree.Game.Users.userIsLoggedIn(receiverID)) // Receiver is logged in, retrieve the next message ID, write the message in the database & send it to the receiver
                    {
                        int messageID = Database.getInteger("SELECT MAX(messageid) + 1 FROM messenger_messages WHERE receiverid = '" + receiverID + "' LIMIT 1");
                        Database.runQuery("INSERT INTO messenger_messages(receiverid,messageid,senderid,sent,body) VALUES ('" + receiverID + "','" + messageID + "',@senderid,@sent,@body)");

                        serverMessage Message = new serverMessage(134); // "BF"
                        Message.appendWired(1);
                        pMessage.ID = messageID;
                        Message.Append(pMessage.ToString());
                        ObjectTree.Game.Users.trySendGameMessage(receiverID, Message);
                    }
                    else // Receiver is not online, no need for getting our hands on the next message ID etc
                    {
                        Database.runQuery(
                        "INSERT INTO messenger_messages(receiverid,messageid,senderid,sent,body) " +
                        "SELECT " +
                            "'" + receiverID + "'," +
                            "(MAX(messageid) + 1)," +
                            "@senderid," +
                            "@sent," +
                            "@body " +
                       "FROM messenger_messages WHERE receiverid = '" + receiverID + "' LIMIT 1");
                    }
                }
                //now = DateTime.Now;
                //Woodpecker.Core.Logging.Log("Stop: " + now.ToString("hh:mm:ss:fff"));

                Database.Close();
            }
        }
Beispiel #18
0
 /// <summary>
 /// Sends the key of an error, whose description value is inside the external_texts of the client.
 /// </summary>
 /// <param name="localizedKey">The external_texts key of the error description.</param>
 public void sendLocalizedError(string localizedKey)
 {
     serverMessage Message = new serverMessage(33); // "@a"
     Message.Append(localizedKey);
     this.sendMessage(Message);
 }
Beispiel #19
0
        private void refreshRoomUnitStatuses()
        {
            bool isUpdated = false;
            serverMessage Updates = new serverMessage(34); // "@b"

            if (hasPets)
            {
                lock (this.roomPets)
                {
                    foreach (roomPet lPet in this.roomPets)
                    {
                        if (!lPet.requiresUpdate)
                            continue;
                        lPet.requiresUpdate = false;

                        if (lPet.Moves)
                            this.moveRoomUnit(lPet);

                        Updates.Append(lPet.ToStatusString());
                        isUpdated = true;

                        if (lPet.nextX != 0 && lPet.nextY != 0)
                        {
                            lPet.X = lPet.nextX;
                            lPet.Y = lPet.nextY;
                            lPet.Z = lPet.nextZ;
                        }
                    }
                }
            }

            lock (this.roomUsers)
            {
                foreach (roomUser lUser in this.roomUsers.Values)
                {
                    if (!lUser.requiresUpdate)
                        continue;
                    lUser.requiresUpdate = false;

                    if (lUser.Moves)
                        this.moveRoomUnit(lUser);

                    Updates.Append(lUser.ToStatusString());
                    isUpdated = true;

                    if(lUser.nextX != 0 && lUser.nextY != 0)
                    {
                        lUser.X = lUser.nextX;
                        lUser.Y = lUser.nextY;
                        lUser.Z = lUser.nextZ;
                    }
                }
            }

            if (isUpdated)
                this.sendMessage(Updates);
        }
Beispiel #20
0
        /// <summary>
        /// Gets the transactions (credit log) of a user on given user session and sends it to the session's game connection.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object to get the transaction for and to send the message to.</param>
        public void sendTransactions(ref Session Session)
        {
            if (Session.User == null)
                return;

            serverMessage Message = new serverMessage(209); // "CQ"
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", Session.User.ID);

            Database.Open();
            if (Database.Ready)
            {
                DataTable creditLogData = Database.getTable("SELECT moment,type,activity FROM users_creditlog WHERE userid = @userid LIMIT 50");
                foreach (DataRow dRow in creditLogData.Rows)
                {
                    DateTime Moment = (DateTime)dRow["moment"];
                    Message.appendTabbedValue(Moment.ToString("dd/MM/yyyy"));
                    Message.appendTabbedValue(Moment.ToString("hh:mm"));
                    Message.appendTabbedValue(dRow["activity"].ToString());
                    Message.appendTabbedValue("0");
                    Message.appendTabbedValue("");
                    Message.Append(dRow["type"].ToString());
                    Message.appendChar(13);
                }
            }

            Session.gameConnection.sendMessage(Message);
        }
Beispiel #21
0
        /// <summary>
        /// Tries to redeem a credit/item voucher for a user session.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object to redeem the voucher with.</param>
        /// <param name="Code">The vouchercode the user entered.</param>
        public void redeemVoucher(ref Session Session, string Code)
        {
            serverMessage Response = new serverMessage();
            Database Database = new Database(false, false);
            Database.addParameterWithValue("code", Code);

            Database.Open();
            if (Database.Ready)
            {
                DataRow dRow = Database.getRow("SELECT type,value FROM users_vouchers WHERE code = @code AND ISNULL(redeemer_userid)");
                if (dRow != null) // Voucher found
                {
                    // Mark voucher as redeemed
                    Database.addParameterWithValue("userid", Session.User.ID);
                    Database.runQuery("UPDATE users_vouchers SET redeemer_userid = @userid WHERE code = @code");
                    Database.Close();

                    string Type = (string)dRow["type"];
                    if (Type == "credits")
                    {
                        int Credits = int.Parse(dRow["value"].ToString());
                        Session.User.Credits += Credits;
                        Session.User.updateValueables();
                        this.logTransaction(Session.User.ID, "win_voucher", Credits);

                        Session.refreshCredits();
                    }
                    else if (Type == "item")
                    {
                        string[] Items = ((string)dRow["value"]).Split(';');

                    }

                    // Success!
                    Response.Initialize(212); // "CT"
                    Session.gameConnection.sendMessage(Response);
                    return;
                }
                else
                {
                    // Error 1! (not found)
                    Response.Initialize(213); // "CU"
                    Response.Append(1);
                }
                Session.gameConnection.sendMessage(Response);
            }
        }
Beispiel #22
0
        public bool requestRoomAlert(int userID, int roomID, string Message, string extraInfo)
        {
            if (ObjectTree.Game.Rooms.roomInstanceRunning(roomID))
            {
                serverMessage Alert = new serverMessage(33); // "@a"
                Alert.Append("mod_warn/");
                Alert.Append(Message);

                ObjectTree.Game.Rooms.getRoomInstance(roomID).sendMessage(Alert);

                logModerationAction(userID, "roomalert", roomID, Message, extraInfo);

                return true;
            }

            return false;
        }
Beispiel #23
0
        /// <summary>
        /// Notifies all room users that a given room unit has left the room and releases the map spot for the room user.
        /// </summary>
        /// <param name="roomUnitID">The room unit ID of the room unit that has left the room.</param>
        /// <param name="mapX">The current X position of the room unit on the map.</param>
        /// <param name="mapY">The current Y position of the room unit on the map.</param>
        private void releaseRoomUnit(int roomUnitID, byte mapX, byte mapY)
        {
            serverMessage Message = new serverMessage(29); // "@]"
            Message.Append(roomUnitID);
            this.sendMessage(Message);

            this.gridUnit[mapX, mapY] = false;
        }