Esempio n. 1
0
        public void UpdateUser(UserInfo userinfo)
        {
            Database db = new Database();

            db.sqlexecute.Parameters.AddWithValue("@userid", userinfo.userId);
            db.sqlexecute.Parameters.AddWithValue("@username", userinfo.sUsername);
            db.sqlexecute.Parameters.AddWithValue("@password", userinfo.sPassword);
            db.sqlexecute.Parameters.AddWithValue("@figure", SpecialFiltering.FilterOnlyNumbers(userinfo.sFigure));
            db.sqlexecute.Parameters.AddWithValue("@sex", verifyUserSex(userinfo.sSex));
            db.sqlexecute.Parameters.AddWithValue("@mission", SpecialFiltering.FilterChars("2,9,10,13", userinfo.sMission));
            db.sqlexecute.Parameters.AddWithValue("@poolfigure", userinfo.sPoolFigure);
            db.sqlexecute.Parameters.AddWithValue("@email", SpecialFiltering.FilterChars("2,9,10,13", userinfo.sEmail));
            db.sqlexecute.Parameters.AddWithValue("@dob", SpecialFiltering.FilterChars("2,9,10,13", userinfo.sDOB));
            db.sqlexecute.Parameters.AddWithValue("@credits", userinfo.iCredits);
            db.sqlexecute.Parameters.AddWithValue("@tickets", userinfo.iTickets);
            db.sqlexecute.Parameters.AddWithValue("@roleid", userinfo.iRole);
            db.sqlexecute.Parameters.AddWithValue("@clubmonthsremaining", userinfo.ClubMonthsRemaining);
            db.sqlexecute.Parameters.AddWithValue("@clubmonthspassed", userinfo.ClubMonthsPassed);
            db.sqlexecute.Parameters.AddWithValue("@clubdaysremaining", userinfo.ClubDaysRemaining);
            db.sqlexecute.Parameters.AddWithValue("@lastlogin", userinfo.LastLogin);
            db.sqlexecute.Parameters.AddWithValue("@clublast", userinfo.ClubLastUpdate);
            db.sqlexecute.Parameters.AddWithValue("@lastip", userinfo.LastIP);
            db.ExecuteSQL("UPDATE users SET Username = @username, Password = @password, figure = @figure, sex = @sex, mission = @mission, email = @email, dob = @dob, credits = @credits, tickets = @tickets, roleid = @roleid, poolfigure = @poolfigure, LastLogin = @lastlogin, ClubLastUpdate = @clublast, ClubDaysRemaining = @clubdaysremaining, ClubMonthsRemaining = @clubmonthsremaining, ClubMonthsPassed = @clubmonthspassed, LastIP = @lastip WHERE UserID = @userid;");

            db.sqlexecute.Parameters.Clear();
        }
        //199 - "MESSAGETOCALLER": "CG"
        public void Listener199()
        {
            int    callId  = ArgumentEncoding.decodeInt(FuseMessage.getArgument(1, mPacketBody));
            string message = FuseMessage.getArgument(2, mPacketBody);

            message = SpecialFiltering.FilterChars("2,9", message);
            InstanceManager.Game.Moderation.ReplyCallForHelp(callId, message, mUserInfo);
        }
Esempio n. 3
0
        //74 - "SETSTUFFDATA": "AJ"
        public void Listener74()
        {
            string sItemId = FuseMessage.getArgument(1, mPacketBody);
            string sData   = SpecialFiltering.FilterChars("2,9,13,47", FuseMessage.getArgument(2, mPacketBody));
            int    itemId;

            if (int.TryParse(sItemId, out itemId))
            {
                mRoomInstance.Interactor.RequestSetStuffDataFloorItem(itemId, sData, mRoomInstance.GetUser(mSessionID), 0);
            }
        }
Esempio n. 4
0
 //80 - "CARRYDRINK": "AP"
 public void Listener80()
 {
     if (mPacketBody.Length < 30)
     {
         if (!mRoomInstance.HasUniqueStatus(mSessionID, "swim"))
         {
             string drinkName = SpecialFiltering.FilterChars("13,47", mPacketBody);
             mRoomInstance.RemoveUniqueStatuses(mSessionID, "wave");
             ApplyUniqueStatus("carryd", 120, drinkName, true, 13, 1, "drink");
         }
     }
 }
Esempio n. 5
0
        //29 - "CREATEFLAT": "@]"
        public void Listener29()
        {
            string[] parts   = mPacketBody.Split('/');
            bool     invalid = false;

            string roomName = SpecialFiltering.FilterChars("2,9,13,47", parts[2]);

            string roomModel = parts[3];

            if (!InstanceManager.Game.Rooms.UserRoomExists(roomModel))
            {
                invalid = true;
            }
            if (InstanceManager.Game.Rooms.GetUserType(roomModel) == 2)
            {
                if (!InstanceManager.Game.Roles.HasRight(mUserInfo.iRole, "fuse_use_special_room_layouts"))
                {
                    invalid = true;
                }
            }

            string roomStatus = parts[4];

            if (InstanceManager.Game.Rooms.GetRoomStateInt(roomStatus) == -1)
            {
                invalid = true;
            }

            int showOwner = 0;

            if (!int.TryParse(parts[5], out showOwner))
            {
                invalid = true;
            }

            if (!invalid)
            {
                int roomId = InstanceManager.Game.Rooms.CreateRoom(roomName, roomModel, roomStatus, showOwner, mUserInfo.userId);
                mMessage.Init(59); // @{
                mMessage.appendInt(roomId);
                mMessage.appendChar(13);
                mMessage.appendString(roomName);
                SendMessage(mMessage);
            }
            else
            {
                mMessage.Init(139); //BK
                mMessage.appendString(Language.roomCreationFailed);
                SendMessage(mMessage);
            }
        }
Esempio n. 6
0
        public void FilterText(ref string text, long sessionId, int room, bool neverMod, string method)
        {
            text = SpecialFiltering.FilterChars("2,9,10,13", text);
            if (text.Length > 184)
            {
                text = text.Substring(0, 184);
            }

            // Log this
            InstanceManager.Game.Moderation.LogChat(InstanceManager.Sessions.GetSession(sessionId).mUserInfo.userId, text, method, room);

            //Could be a moderation command
            if (text.StartsWith(":") && !neverMod)
            {
                InstanceManager.Game.Moderation.TextCommandProcess(ref text, sessionId, room);
            }
        }
        protected void btnApply_Click(object sender, EventArgs e)
        {
            if (InstanceManager.Game.Users.UserExists(txtUsername.Text))
            {
                UserInfo user  = InstanceManager.Game.Users.GetUser(txtUsername.Text);
                int      newId = 0;

                if (!chkIsGift.Checked)
                {
                    if (InstanceManager.Game.Catalogue.BuyItem("0", ddPurchaseCode.SelectedValue, "", ref user, true, ref newId))
                    {
                        ServerCommunicator servComm = new ServerCommunicator();
                        servComm.SendModCommandToServer("updatehand", mUser.userId, user.userId, "None");

                        lblInfo.Text = "Item Spawned!";
                    }
                    else
                    {
                        lblInfo.Text = "Failed to spawn item!";
                    }
                }
                else
                {
                    int      furniId = InstanceManager.Game.Furni.CreateNewFurni(InstanceManager.Game.Furni.GetRandomPresentDefinition(), user.userId);
                    GiftInfo gift    = new GiftInfo();
                    gift.GiftId       = furniId;
                    gift.Payload      = "";
                    gift.PurchaseCode = ddPurchaseCode.SelectedValue;
                    InstanceManager.Game.Furni.AddGift(gift);
                    InstanceManager.Game.Furni.SetStuffDataFloorItem(furniId, "!" + SpecialFiltering.FilterChars("2,9,10,13,47", txtMessage.Text));

                    ServerCommunicator servComm = new ServerCommunicator();
                    servComm.SendModCommandToServer("updatehand", mUser.userId, user.userId, "None");

                    lblInfo.Text = "Gift spawned!";
                }
            }
            else
            {
                lblInfo.Text = "Invalid user!";
            }
        }
Esempio n. 8
0
        public void RequestChangeStickyData(int itemId, string newMessage, int newItemType, long sessionId)
        {
            if (ContainsItem(itemId))
            {
                FurniInfo info = GetFurniObject(itemId);

                if (info != null)
                {
                    if (info.Flags.StickyNote)
                    {
                        if (newItemType > 0)
                        {
                            InstanceManager.Game.Furni.SetItemType(itemId, newItemType);
                        }

                        if (newMessage.Length > 685)
                        {
                            newMessage = newMessage.Substring(0, 685);
                        }
                        newMessage = SpecialFiltering.FilterChars("2,9,47", newMessage);

                        InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, newMessage);

                        mWallFurni = InstanceManager.Game.Furni.GetRoomWallFurni(mRoomInstance.RoomInfo.RoomID);
                        info       = GetFurniObject(itemId);

                        ClientMessage message = new ClientMessage();
                        message.Init(85); //AU
                        message.appendInt(itemId);
                        message.appendChar(9);
                        message.appendString(info.FurniSprite);
                        message.appendChar(9);
                        message.appendString(" ");
                        message.appendString(info.WallLocation);
                        message.appendChar(9);
                        message.appendString(info.Col);
                        mRoomInstance.RoomBroadcast(message);
                    }
                }
            }
        }
Esempio n. 9
0
        public void CreateUser(UserInfo newUser)
        {
            Database db = new Database();

            db.sqlexecute.Parameters.AddWithValue("@username", SpecialFiltering.FilterName(newUser.sUsername));
            db.sqlexecute.Parameters.AddWithValue("@password", newUser.sPassword);
            db.sqlexecute.Parameters.AddWithValue("@figure", SpecialFiltering.FilterOnlyNumbers(newUser.sFigure));
            db.sqlexecute.Parameters.AddWithValue("@sex", verifyUserSex(newUser.sSex));
            db.sqlexecute.Parameters.AddWithValue("@mission", SpecialFiltering.FilterChars("2,9,10,13", newUser.sMission));
            db.sqlexecute.Parameters.AddWithValue("@poolfigure", newUser.sPoolFigure);
            db.sqlexecute.Parameters.AddWithValue("@email", SpecialFiltering.FilterChars("2,9,10,13", newUser.sEmail));
            db.sqlexecute.Parameters.AddWithValue("@dob", SpecialFiltering.FilterChars("2,9,10,13", newUser.sDOB));
            db.sqlexecute.Parameters.AddWithValue("@credits", int.Parse(UserSettings.DefaultCredits));
            db.sqlexecute.Parameters.AddWithValue("@tickets", int.Parse(UserSettings.DefaultTickets));
            db.sqlexecute.Parameters.AddWithValue("@role", int.Parse(UserSettings.DefaultRole));
            db.sqlexecute.Parameters.AddWithValue("@clublast", DateTime.Now);
            db.sqlexecute.Parameters.AddWithValue("@lastlogin", DateTime.Now);
            db.sqlexecute.Parameters.AddWithValue("@lastip", newUser.LastIP);
            db.ExecuteSQL("INSERT INTO users (Username, Password, figure, sex, mission, email, dob, credits, tickets, roleid, poolfigure, ClubLastUpdate, LastLogin, LastIP) " +
                          "VALUES (@username, @password, @figure, @sex, @mission, @email, @dob, @credits, @tickets, @role, @poolfigure, @clublast, @lastlogin, @lastip);");

            db.sqlexecute.Parameters.Clear();
        }
Esempio n. 10
0
        //24 - "UPDATEFLAT": "@X"
        public void Listener24()
        {
            string[] parts   = mPacketBody.Split('/');
            bool     invalid = false;

            int roomId = 0;

            if (!int.TryParse(parts[0], out roomId))
            {
                invalid = true;
            }

            string roomName = SpecialFiltering.FilterChars("2,9,13,47", parts[1]);

            string roomStatus = parts[2];

            if (InstanceManager.Game.Rooms.GetRoomStateInt(roomStatus) == -1)
            {
                invalid = true;
            }

            int showOwner = 0;

            if (!int.TryParse(parts[3], out showOwner))
            {
                invalid = true;
            }

            if (!invalid && InstanceManager.Game.Rooms.RoomExists(roomId))
            {
                RoomInfo info = InstanceManager.Game.Rooms.GetRoom(roomId);
                info.RoomName   = roomName;
                info.RoomStatus = roomStatus;
                info.ShowOwner  = showOwner;
                InstanceManager.Game.Rooms.UpdateRoom(info);
            }
        }
Esempio n. 11
0
        //25 - "SETFLATINFO": "@Y"
        public void Listener25()
        {
            string rId    = "";
            int    roomId = 0;

            if (mPacketBody.Substring(0, 1) == "/")
            {
                rId = mPacketBody.Split('/')[1];
            }
            else
            {
                rId = mPacketBody.Split('/')[0];
            }

            if (int.TryParse(rId, out roomId))
            {
                RoomInfo roomInfo = InstanceManager.Game.Rooms.GetRoom(roomId);
                if (roomInfo.RoomOwner == mUserInfo.userId)
                {
                    string[] payLoad = mPacketBody.Split(Convert.ToChar(13));

                    for (int i = 1; i < payLoad.Length; i++)
                    {
                        string updateHeader = payLoad[i].Split('=')[0];
                        string updateBody   = "";
                        if (payLoad[i].Length > updateHeader.Length + 1)
                        {
                            updateBody = payLoad[i].Substring(updateHeader.Length + 1);
                        }

                        switch (updateHeader)
                        {
                        case "description":
                            roomInfo.RoomDescription = SpecialFiltering.FilterChars("2,9,13,47", updateBody);
                            break;

                        case "maxvisitors":
                            int maxvis = 0;
                            if (int.TryParse(updateBody, out maxvis))
                            {
                                roomInfo.MaxUsers = maxvis;
                            }
                            break;

                        case "allsuperuser":
                            int allsuper = 0;
                            if (int.TryParse(updateBody, out allsuper))
                            {
                                if (allsuper == 1 || allsuper == 0)
                                {
                                    roomInfo.SuperUsers = allsuper;
                                }
                            }
                            break;

                        case "password":
                            roomInfo.Password = SpecialFiltering.FilterChars("2,9,13,47", updateBody);
                            break;
                        }
                    }

                    InstanceManager.Game.Rooms.UpdateRoom(roomInfo);
                }
            }
        }
Esempio n. 12
0
        public bool BuyItem(string isGift, string purchaseCode, string packetBody, ref Users.UserInfo info, bool noCredits, ref int newId)
        {
            info = InstanceManager.Game.Users.GetUser(info.userId);

            ClientMessage mMessage = new ClientMessage();

            try
            {
                if (purchaseCode == "special_floor" || purchaseCode == "special_wallpaper")
                {
                    string type = "";
                    if (purchaseCode == "special_floor")
                    {
                        type = "floor";
                    }
                    if (purchaseCode == "special_wallpaper")
                    {
                        type = "wallpaper";
                    }
                    int decorationId = int.Parse(packetBody.Split(Convert.ToChar(13))[4]);
                    int typeId       = InstanceManager.Game.Furni.GetTypeFromSprite(type);

                    if (typeId > 0)
                    {
                        if (info.iCredits >= 2 || noCredits)
                        {
                            if (!noCredits)
                            {
                                info.iCredits -= 2;
                                InstanceManager.Game.Users.UpdateUser(info);
                                info = InstanceManager.Game.Users.GetUser(info.userId);
                            }

                            if (isGift == "1")
                            {
                                string targetUser = packetBody.Split(Convert.ToChar(13))[6];
                                string desc       = SpecialFiltering.FilterChars("2,9,10,13,47", packetBody.Split(Convert.ToChar(13))[7]);
                                if (desc.Length > 202)
                                {
                                    desc = desc.Substring(0, 202);
                                }

                                if (InstanceManager.Game.Users.UserExists(targetUser))
                                {
                                    Users.UserInfo giftUser = InstanceManager.Game.Users.GetUser(targetUser);

                                    newId = InstanceManager.Game.Furni.CreateNewFurni(InstanceManager.Game.Furni.GetRandomPresentDefinition(), giftUser.userId);
                                    Furni.GiftInfo gift = new ThorServer.Game.Furni.GiftInfo();
                                    gift.GiftId       = newId;
                                    gift.PurchaseCode = purchaseCode;
                                    gift.Payload      = packetBody;
                                    InstanceManager.Game.Furni.AddGift(gift);
                                    InstanceManager.Game.Furni.SetStuffDataFloorItem(newId, "!" + desc);

                                    long tmpSession = InstanceManager.Sessions.GetSessionFromUser(giftUser.userId);
                                    if (tmpSession != -1)
                                    {
                                        InstanceManager.Sessions.InvokeReactorMethod(tmpSession, "UpdateHandInvoker");
                                    }
                                    return(true);
                                }
                            }
                            else
                            {
                                int itemId = InstanceManager.Game.Furni.CreateNewFurni(typeId, info.userId);
                                newId = itemId;
                                InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, decorationId.ToString());
                                return(true);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    CatalogueItemInfo item = InstanceManager.Game.Catalogue.GetCatalogueItem(purchaseCode);
                    if (item != null)
                    {
                        if (!item.StaffOnly || InstanceManager.Game.Roles.HasRight(info.iRole, "fuse_staff_catalogue") || noCredits)
                        {
                            if (info.iCredits >= item.ItemCost || noCredits)
                            {
                                if (!noCredits)
                                {
                                    info.iCredits -= item.ItemCost;
                                    InstanceManager.Game.Users.UpdateUser(info);
                                    info = InstanceManager.Game.Users.GetUser(info.userId);
                                }

                                if (isGift == "1")
                                {
                                    string targetUser = packetBody.Split(Convert.ToChar(13))[6];
                                    string desc       = SpecialFiltering.FilterChars("2,9,10,13,47", packetBody.Split(Convert.ToChar(13))[7]);
                                    if (desc.Length > 202)
                                    {
                                        desc = desc.Substring(0, 202);
                                    }

                                    if (InstanceManager.Game.Users.UserExists(targetUser))
                                    {
                                        Users.UserInfo giftUser = InstanceManager.Game.Users.GetUser(targetUser);

                                        newId = InstanceManager.Game.Furni.CreateNewFurni(InstanceManager.Game.Furni.GetRandomPresentDefinition(), giftUser.userId);
                                        Furni.GiftInfo gift = new ThorServer.Game.Furni.GiftInfo();
                                        gift.GiftId       = newId;
                                        gift.PurchaseCode = purchaseCode;
                                        gift.Payload      = packetBody;
                                        InstanceManager.Game.Furni.AddGift(gift);
                                        InstanceManager.Game.Furni.SetStuffDataFloorItem(newId, "!" + desc);
                                        long tmpSession = InstanceManager.Sessions.GetSessionFromUser(giftUser.userId);
                                        if (tmpSession != -1)
                                        {
                                            InstanceManager.Sessions.InvokeReactorMethod(tmpSession, "UpdateHandInvoker");
                                        }
                                        return(true);
                                    }
                                }
                                else
                                {
                                    int itemId = InstanceManager.Game.Furni.CreateNewFurni(item.FurniType, info.userId);
                                    newId = itemId;
                                    if (purchaseCode.StartsWith("special_teleporter_"))
                                    {
                                        int itemId2 = InstanceManager.Game.Furni.CreateNewFurni(item.FurniType, info.userId);
                                        InstanceManager.Game.Furni.SetTeleportID(itemId, itemId2);
                                        InstanceManager.Game.Furni.SetTeleportID(itemId2, itemId);
                                    }

                                    if (item.Sticky)
                                    {
                                        InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, "20");
                                    }

                                    return(true);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch
            {
                return(false);
            }

            return(false);
        }