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>
        /// Broacoasts the placement of a floor item to all room users.
        /// </summary>
        /// <param name="pItem">The floorItem instance of the wall item that is placed.</param>
        /// <param name="isPlacement">True if this item is new in the room, false otherwise.</param>
        private void broadcoastFloorItemMove(floorItem pItem, bool isPlacement)
        {
            serverMessage Message = new serverMessage();

            if (isPlacement)
            {
                Message.Initialize(93); // "A]"
            }
            else
            {
                Message.Initialize(95); // "A_"
            }
            Message.Append(pItem.ToString());

            this.sendMessage(Message);
        }
Beispiel #3
0
 /// <summary>
 /// 199 - "CG"
 /// </summary>
 public void MESSAGETOCALLER()
 {
     string[] args = Request.getMixedParameters();
     if (Session.User.hasFuseRight("fuse_receive_calls_for_help"))
     {
         Database Database = new Database(false, false);
         Database.addParameterWithValue("id", args[0]);
         Database.addParameterWithValue("msg", args[1]);
         Database.Open();
         if (Database.Ready)
         {
             DataRow dRow = Database.getRow("SELECT * FROM callforhelp WHERE id = @id");
             if (dRow != null)
             {
                 Session S = Engine.Game.Users.getUserSession(Convert.ToInt32(dRow["uid"]));
                 if (S == null)
                 {
                     return;
                 }
                 serverMessage Message = new serverMessage();
                 Message.Initialize(274);
                 Message.Append(args[1]);
                 Message.appendChar(2);
                 S.gameConnection.sendMessage(Message);
                 Database.runQuery("INSERT INTO callforhelp_msg VALUES ('', @id, @msg, '" + Session.User.ID + "', '" + Session.ipAddress + "', '" + DateTime.Now.ToString() + "')");
             }
         }
     }
 }
Beispiel #4
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 #5
0
        public void broadcoastTeleportActivity(int itemID, string Username, bool disappearUser)
        {
            floorItem pItem = this.getFloorItem(itemID);
            if (pItem != null && pItem.Definition.Behaviour.isTeleporter)
            {
                serverMessage Message = new serverMessage();
                if (disappearUser)
                    Message.Initialize(89); // "AY"
                else
                    Message.Initialize(92); // "A\"
                Message.Append(pItem.ID);
                Message.Append("/");
                Message.Append(Username);
                Message.Append("/");
                Message.Append(pItem.Definition.Sprite);

                this.sendMessage(Message);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 86 - "AV"
        /// </summary>
        public void CRYFORHELP()
        {
            string[] args     = Request.getMixedParameters();
            Database Database = new Database(false, false);

            Database.addParameterWithValue("userid", Session.User.ID);
            Database.addParameterWithValue("senderip", Session.ipAddress);
            Database.addParameterWithValue("msg", args[0]);
            Database.addParameterWithValue("roomid", Session.roomID);
            Database.addParameterWithValue("ip", Session.ipAddress);
            Database.addParameterWithValue("sended", DateTime.Now.ToString());
            Database.Open();
            string row  = "";
            string room = "";

            if (Database.Ready)
            {
                Database.runQuery("INSERT INTO callforhelp (id, sended, uid, rid, date, message, send_ip, pickedup, pickedup_person, pickedup_ip, pickedup_date) VALUES ('', @sended, @userid, @roomid, @msg, '" + DateTime.Now.ToString() + "', @senderip, '0', '', '', '')");
                row  = Database.getString("SELECT id FROM `callforhelp` ORDER BY `callforhelp`.`id` DESC LIMIT 1");
                room = Database.getString("SELECT roomname FROM `rooms` WHERE `id` = '" + Session.roomID + "' LIMIT 1");
                Database.Close();
            }

            ArrayList list = Engine.Game.Users.UserFuses("fuse_receive_calls_for_help");

            foreach (int x in list)
            {
                Session S = Engine.Game.Users.getUserSession(x);
                if (S == null)
                {
                    return;
                }
                serverMessage Message = new serverMessage();
                Message.Initialize(148);
                Message.Append(row);
                Message.appendChar(2);
                Message.Append("ISent: ");
                Message.Append(DateTime.Now.ToString());
                Message.appendChar(2);
                Message.Append(Session.User.Username);
                Message.appendChar(2);
                Message.Append(args[0]);
                Message.appendChar(2);
                Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID));
                Message.appendChar(2);
                Message.Append("Room: " + room);
                Message.appendChar(2);
                Message.Append("I");
                Message.appendChar(2);
                Message.Append(Specialized.Encoding.wireEncoding.Encode(Session.roomID));
                S.gameConnection.sendMessage(Message);
            }
        }
Beispiel #7
0
        public void broadcoastTeleportActivity(int itemID, string Username, bool disappearUser)
        {
            floorItem pItem = this.getFloorItem(itemID);

            if (pItem != null && pItem.Definition.Behaviour.isTeleporter)
            {
                serverMessage Message = new serverMessage();
                if (disappearUser)
                {
                    Message.Initialize(89); // "AY"
                }
                else
                {
                    Message.Initialize(92); // "A\"
                }
                Message.Append(pItem.ID);
                Message.Append("/");
                Message.Append(Username);
                Message.Append("/");
                Message.Append(pItem.Definition.Sprite);

                this.sendMessage(Message);
            }
        }
Beispiel #8
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 = Engine.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 #9
0
        public void requestSaleShipping(int receivingUserID, string saleCode, bool isNewPurchase, bool purchaseAsPresent, string presentNote, string customData)
        {
            storeCatalogueSale pSale = this.getSale(saleCode);

            if (pSale == null)
            {
                Logging.Log("Failed to purchase sale '" + saleCode + "' for user " + receivingUserID + ", the requested sale ('" + saleCode + "') was not found!", Logging.logType.commonWarning);
                return;
            }

            List <stripItem> shippedItems = new List <stripItem>();

            if (purchaseAsPresent)
            {
                stripItem presentBox = this.createPresent(receivingUserID, saleCode, presentNote, customData);
                if (presentBox != null)
                {
                    shippedItems.Add(presentBox);
                }
                else
                {
                    return;
                }
            }
            else
            {
                int itemIdOffset = ObjectTree.Game.Items.getItemIdOffset();
                foreach (stripItem lItem in pSale.getItemInstances())
                {
                    lItem.ID      = ++itemIdOffset;
                    lItem.ownerID = receivingUserID;

                    #region Special events upon purchase
                    if (lItem.Definition.Behaviour.isTeleporter) // Teleporter, create linking teleporter
                    {
                        stripItem Teleporter2 = new stripItem();
                        Teleporter2.ID           = ++itemIdOffset;
                        Teleporter2.ownerID      = receivingUserID;
                        Teleporter2.Definition   = lItem.Definition;
                        Teleporter2.teleporterID = lItem.ID;
                        lItem.teleporterID       = Teleporter2.ID;

                        shippedItems.Add(Teleporter2);
                    }
                    else if (lItem.Definition.Behaviour.isPostIt)
                    {
                        lItem.customData = "20";
                    }
                    else if (lItem.Definition.Behaviour.isDecoration || lItem.Definition.Behaviour.isPrizeTrophy)
                    {
                        lItem.customData = customData;
                    }
                    else if (lItem.Definition.Behaviour.isRedeemable)
                    {
                        int creditValue = 0;
                        if (int.TryParse(lItem.Definition.Sprite.Split('_')[1], out creditValue))
                        {
                            lItem.customData = creditValue.ToString();
                        }
                    }
                    else if (lItem.Definition.Sprite == "nest")
                    {
                        string[] petData = customData.Split(Convert.ToChar(2));
                        string   Name    = petData[0];
                        char     Type    = char.Parse(petData[1]);
                        byte     Race    = byte.Parse(petData[2]);
                        string   Color   = petData[3];

                        ObjectTree.Game.Items.createPet(lItem.ID, Name, Type, Race, Color);
                    }
                    #endregion

                    shippedItems.Add(lItem);
                }

                ObjectTree.Game.Items.createItemInstances(shippedItems);
            }

            Session Receiver = ObjectTree.Game.Users.getUserSession(receivingUserID);
            if (Receiver != null) // Receiver was online
            {
                Receiver.itemStripHandler.addHandItems(shippedItems);

                serverMessage Notification = new serverMessage();
                if (isNewPurchase)
                {
                    Notification.Initialize(67); // "AC"
                }
                else
                #region Open as present box
                {
                    stripItem displayItem = shippedItems[0];

                    Notification.Initialize(129); // "BA"
                    Notification.appendNewLineValue(displayItem.Definition.Sprite);

                    string displaySprite = displayItem.Definition.Sprite;
                    //if (displayItem.Definition.isPartialSprite && displayItem.customData != null)
                    //    displaySprite += " " + displayItem.customData;
                    Notification.appendNewLineValue(displaySprite);

                    if (!displayItem.Definition.Behaviour.isWallItem)
                    {
                        Notification.appendStripValue(displayItem.Definition.Length.ToString());
                        Notification.appendStripValue(displayItem.Definition.Width.ToString());
                        Notification.appendStripValue(displayItem.Definition.Color);
                    }
                }
                #endregion
                Receiver.gameConnection.sendMessage(Notification);
            }
        }
Beispiel #10
0
        /// <summary>
        /// 48 - "@p"
        /// </summary>
        public void PICK_CRYFORHELP()
        {
            string[] args = Request.getMixedParameters();
            if (Session.User.hasFuseRight("fuse_receive_calls_for_help"))
            {
                string   username = Session.User.Username;
                Database Database = new Database(false, false);
                Database.addParameterWithValue("id", args[0]);
                Database.Open();
                if (Database.Ready)
                {
                    DataRow dRow = Database.getRow("SELECT * FROM callforhelp WHERE id = @id");
                    if (dRow != null)
                    {
                        string room = Database.getString("SELECT roomname FROM `rooms` WHERE `id` = '" + dRow["rid"] + "' LIMIT 1");
                        if (dRow["pickedup"].ToString() == "1")
                        {
                            Response.Initialize(139);
                            Response.Append("This call has already been picked up by " + Engine.Game.Users.getUsername(Convert.ToInt32(dRow["pickedup_person"])) + ".");
                            sendResponse();
                        }
                        else
                        {
                            Database.runQuery("UPDATE callforhelp SET pickedup = '1', pickedup_person = '" + Session.User.ID + "', pickedup_ip = '" + Session.ipAddress + "', pickedup_date = '" + DateTime.Now.ToString() + "' WHERE id = @id");

                            ArrayList list = Engine.Game.Users.UserFuses("fuse_receive_calls_for_help");
                            foreach (int x in list)
                            {
                                Session S = Engine.Game.Users.getUserSession(x);
                                if (S == null)
                                {
                                    return;
                                }
                                serverMessage Message = new serverMessage();
                                Message.Initialize(148);
                                Message.Append(args[0]);
                                Message.appendChar(2);
                                Message.Append("IPicked up on: ");
                                Message.Append(DateTime.Now.ToString());
                                Message.appendChar(2);
                                Message.Append(Session.User.Username);
                                Message.appendChar(2);
                                Message.Append(dRow["message"].ToString());
                                Message.appendChar(2);
                                Message.Append(Specialized.Encoding.wireEncoding.Encode(Convert.ToInt32(dRow["rid"])));
                                Message.appendChar(2);
                                Message.Append("(Picked up by " + username + ") Room: " + room);
                                Message.appendChar(2);
                                Message.Append("I");
                                Message.appendChar(2);
                                Message.Append(Specialized.Encoding.wireEncoding.Encode(Convert.ToInt32(dRow["rid"])));
                                sendResponse();
                                S.gameConnection.sendMessage(Message);
                            }
                        }
                    }

                    Database.Close();
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Broacoasts the placement of a floor item to all room users.
        /// </summary>
        /// <param name="pItem">The floorItem instance of the wall item that is placed.</param>
        /// <param name="isPlacement">True if this item is new in the room, false otherwise.</param>
        private void broadcoastFloorItemMove(floorItem pItem, bool isPlacement)
        {
            serverMessage Message = new serverMessage();
            if (isPlacement)
                Message.Initialize(93); // "A]"
            else
                Message.Initialize(95); // "A_"
            Message.Append(pItem.ToString());

            this.sendMessage(Message);
        }