Example #1
0
        internal void AddSubscription(double DayLength)
        {
            int        num            = checked ((int)Math.Round(DayLength));
            GameClient clientByUserID = CyberEnvironment.GetGame().GetClientManager().GetClientByUserID(this.UserId);
            DateTime   target;
            int        num2;
            int        num3;

            if (this.Subscription != null)
            {
                target = CyberEnvironment.UnixToDateTime((double)this.Subscription.ExpireTime).AddDays((double)num);
                num2   = this.Subscription.ActivateTime;
                num3   = this.Subscription.LastGiftTime;
            }
            else
            {
                target = DateTime.Now.AddDays((double)num);
                num2   = CyberEnvironment.GetUnixTimestamp();
                num3   = CyberEnvironment.GetUnixTimestamp();
            }
            int num4 = CyberEnvironment.DateTimeToUnix(target);

            this.Subscription = new Subscription(2, num2, num4, num3);
            using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
            {
                queryreactor.runFastQuery(string.Concat(new object[]
                {
                    "REPLACE INTO user_subscriptions VALUES (",
                    this.UserId,
                    ", 2, ",
                    num2,
                    ", ",
                    num4,
                    ", ",
                    num3,
                    ");"
                }));
            }
            clientByUserID.GetHabbo().SerializeClub();
        }
Example #2
0
 internal void RunDBUpdate()
 {
     try
     {
         if (this.mRemovedItems.Count > 0 || this.mAddedItems.Count > 0 || this.InventoryPets.Count > 0)
         {
             QueryChunk queryChunk = new QueryChunk();
             if (this.mAddedItems.Count > 0)
             {
                 foreach (UserItem userItem in this.mAddedItems.Values)
                 {
                     queryChunk.AddQuery(string.Concat(new object[]
                     {
                         "UPDATE items SET user_id = ",
                         this.UserId,
                         ", room_id='0' WHERE id = ",
                         userItem.Id
                     }));
                 }
                 this.mAddedItems.Clear();
             }
             if (this.mRemovedItems.Count > 0)
             {
                 try
                 {
                     foreach (UserItem userItem2 in this.mRemovedItems.Values)
                     {
                         using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
                         {
                             this.GetClient().GetHabbo().CurrentRoom.GetRoomItemHandler().SaveFurniture(queryreactor, null);
                         }
                         if (this.discs.Contains(userItem2.Id))
                         {
                             this.discs.Remove(userItem2.Id);
                         }
                     }
                 }
                 catch (Exception)
                 {
                 }
                 this.mRemovedItems.Clear();
             }
             foreach (Pet current in this.InventoryPets.Values)
             {
                 if (current.DBState == DatabaseUpdateState.NeedsUpdate)
                 {
                     queryChunk.AddParameter(current.PetId + "name", current.Name);
                     queryChunk.AddParameter(current.PetId + "race", current.Race);
                     queryChunk.AddParameter(current.PetId + "color", current.Color);
                     queryChunk.AddQuery(string.Concat(new object[]
                     {
                         "UPDATE bots SET room_id = ",
                         current.RoomId,
                         ", name = @",
                         current.PetId,
                         "name, x = ",
                         current.X,
                         ", Y = ",
                         current.Y,
                         ", Z = ",
                         current.Z,
                         " WHERE id = ",
                         current.PetId
                     }));
                     queryChunk.AddQuery(string.Concat(new object[]
                     {
                         "UPDATE bots_petdata SET race = @",
                         current.PetId,
                         "race, color = @",
                         current.PetId,
                         "color, type = ",
                         current.Type,
                         ", experience = ",
                         current.Experience,
                         ", energy = ",
                         current.Energy,
                         ", nutrition = ",
                         current.Nutrition,
                         ", respect = ",
                         current.Respect,
                         ", createstamp = '",
                         current.CreationStamp,
                         "', lasthealth_stamp = ",
                         CyberEnvironment.DateTimeToUnix(current.LastHealth),
                         ", untilgrown_stamp = ",
                         CyberEnvironment.DateTimeToUnix(current.UntilGrown),
                         " WHERE id = ",
                         current.PetId
                     }));
                 }
                 current.DBState = DatabaseUpdateState.Updated;
             }
             using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
             {
                 queryChunk.Execute(queryreactor2);
             }
         }
     }
     catch (Exception ex)
     {
         Logging.LogCacheError("FATAL ERROR DURING USER INVENTORY DB UPDATE: " + ex.ToString());
     }
 }