Пример #1
0
        internal void method_65(DatabaseClient class6_0)
        {
            try
            {
                Dictionary<uint, bool> dictionary = new Dictionary<uint, bool>();
                StringBuilder stringBuilder = new StringBuilder();
                if (this.WF_Triggers.Count > 0)
                {
                    foreach (RoomItem @class in this.WF_Triggers)
                    {
                        if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                        {
                            try
                            {
                                if (!dictionary.ContainsKey(@class.Id))
                                {
                                    if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                                    {
                                        class6_0.AddParamWithValue(@class.Id + "Extra1", @class.Extra1);
                                        class6_0.AddParamWithValue(@class.Id + "Extra2", @class.Extra2);
                                        class6_0.AddParamWithValue(@class.Id + "Extra3", @class.Extra3);
                                        class6_0.AddParamWithValue(@class.Id + "Extra4", @class.Extra4);
                                        class6_0.AddParamWithValue(@class.Id + "Extra5", @class.Extra5);
                                        stringBuilder.Append(string.Concat(new object[]
										{
											"DELETE FROM wired_items WHERE item_id = '",
											@class.Id,
											"' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('",
											@class.Id,
											"',@",
											@class.Id,
											"Extra1,@",
											@class.Id,
											"Extra2,@",
											@class.Id,
											"Extra3,@",
											@class.Id,
											"Extra4,@",
											@class.Id,
											"Extra5); "
										}));
                                    }
                                    dictionary.Add(@class.Id, true);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                if (this.WF_Effects.Count > 0)
                {
                    foreach (RoomItem @class in this.WF_Effects)
                    {
                        if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                        {
                            try
                            {
                                if (!dictionary.ContainsKey(@class.Id))
                                {
                                    if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                                    {
                                        class6_0.AddParamWithValue(@class.Id + "Extra1", @class.Extra1);
                                        class6_0.AddParamWithValue(@class.Id + "Extra2", @class.Extra2);
                                        class6_0.AddParamWithValue(@class.Id + "Extra3", @class.Extra3);
                                        class6_0.AddParamWithValue(@class.Id + "Extra4", @class.Extra4);
                                        class6_0.AddParamWithValue(@class.Id + "Extra5", @class.Extra5);
                                        stringBuilder.Append(string.Concat(new object[]
										{
											"DELETE FROM wired_items WHERE item_id = '",
											@class.Id,
											"' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('",
											@class.Id,
											"',@",
											@class.Id,
											"Extra1,@",
											@class.Id,
											"Extra2,@",
											@class.Id,
											"Extra3,@",
											@class.Id,
											"Extra4,@",
											@class.Id,
											"Extra5); "
										}));
                                    }
                                    dictionary.Add(@class.Id, true);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                if (this.WF_Conditions.Count > 0)
                {
                    foreach (RoomItem @class in this.WF_Conditions)
                    {
                        if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                        {
                            try
                            {
                                if (!dictionary.ContainsKey(@class.Id))
                                {
                                    if (@class.Extra1 != "" || @class.Extra2 != "" || @class.Extra3 != "" || @class.Extra4 != "" || @class.Extra5 != "")
                                    {
                                        class6_0.AddParamWithValue(@class.Id + "Extra1", @class.Extra1);
                                        class6_0.AddParamWithValue(@class.Id + "Extra2", @class.Extra2);
                                        class6_0.AddParamWithValue(@class.Id + "Extra3", @class.Extra3);
                                        class6_0.AddParamWithValue(@class.Id + "Extra4", @class.Extra4);
                                        class6_0.AddParamWithValue(@class.Id + "Extra5", @class.Extra5);
                                        stringBuilder.Append(string.Concat(new object[]
										{
											"DELETE FROM wired_items WHERE item_id = '",
											@class.Id,
											"' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('",
											@class.Id,
											"',@",
											@class.Id,
											"Extra1,@",
											@class.Id,
											"Extra2,@",
											@class.Id,
											"Extra3,@",
											@class.Id,
											"Extra4,@",
											@class.Id,
											"Extra5); "
										}));
                                    }
                                    dictionary.Add(@class.Id, true);
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                dictionary.Clear();
                if (this.mAddedItems.Count > 0 || this.mRemovedItems.Count > 0 || this.mMovedItems.Count > 0 || this.Boolean_4)
                {
                    foreach (RoomItem @class in this.mRemovedItems.Values)
                    {
                        stringBuilder.Append(string.Concat(new object[]
						{
							"UPDATE items SET room_id = 0 WHERE Id = '",
							@class.Id,
							"' AND room_id = '",
							this.RoomId,
							"' LIMIT 1; "
						}));
                    }
                    this.mRemovedItems.Clear();
                    IEnumerator enumerator2;
                    if (this.mAddedItems.Count > 0)
                    {
                        enumerator2 = this.mAddedItems.Values.GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                RoomItem @class = (RoomItem)enumerator2.Current;
                                stringBuilder.Append("UPDATE items SET room_id = 0 WHERE Id = '" + @class.Id + "' LIMIT 1; ");
                            }
                        }
                        finally
                        {
                            IDisposable disposable = enumerator2 as IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        int num = 0;
                        int num2 = 0;
                        enumerator2 = this.mAddedItems.Values.GetEnumerator();
                        try
                        {
                            while (enumerator2.MoveNext())
                            {
                                RoomItem @class = (RoomItem)enumerator2.Current;
                                if (@class.IsFloorItem)
                                {
                                    num2++;
                                }
                                else
                                {
                                    num++;
                                }
                            }
                        }
                        finally
                        {
                            IDisposable disposable = enumerator2 as IDisposable;
                            if (disposable != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        if (num2 > 0)
                        {
                            enumerator2 = this.mAddedItems.Values.GetEnumerator();
                            try
                            {
                                while (enumerator2.MoveNext())
                                {
                                    RoomItem @class = (RoomItem)enumerator2.Current;
                                    if (@class.IsFloorItem)
                                    {
                                        class6_0.AddParamWithValue("extra_data" + @class.Id, @class.ExtraData);
                                        stringBuilder.Append(string.Concat(new object[]
										{
											"UPDATE items SET room_id = '",
											this.RoomId,
											"', base_item = '",
											@class.BaseItem,
											"', extra_data = @extra_data",
											@class.Id,
											", x = '",
											@class.GetX,
											"', y = '",
											@class.GetY,
											"', z = '",
											@class.GetZ,
											"', rot = '",
											@class.Rot,
											"', wall_pos = '' WHERE Id = '",
											@class.Id,
											"' LIMIT 1; "
										}));
                                    }
                                }
                            }
                            finally
                            {
                                IDisposable disposable = enumerator2 as IDisposable;
                                if (disposable != null)
                                {
                                    disposable.Dispose();
                                }
                            }
                        }
                        if (num > 0)
                        {
                            enumerator2 = this.mAddedItems.Values.GetEnumerator();
                            try
                            {
                                while (enumerator2.MoveNext())
                                {
                                    RoomItem @class = (RoomItem)enumerator2.Current;
                                    if (@class.IsWallItem)
                                    {
                                        class6_0.AddParamWithValue("extra_data" + @class.Id, @class.ExtraData);
                                        class6_0.AddParamWithValue("pos" + @class.Id, @class.string_7);
                                        stringBuilder.Append(string.Concat(new object[]
										{
											"UPDATE items SET room_id = '",
											this.RoomId,
											"', base_item = '",
											@class.BaseItem,
											"', extra_data = @extra_data",
											@class.Id,
											", x = '0', y = '0', z = '0', rot = '0', wall_pos = @pos",
											@class.Id,
											" WHERE Id = '",
											@class.Id,
											"' LIMIT 1; "
										}));
                                    }
                                }
                            }
                            finally
                            {
                                IDisposable disposable = enumerator2 as IDisposable;
                                if (disposable != null)
                                {
                                    disposable.Dispose();
                                }
                            }
                        }
                        this.mAddedItems.Clear();
                    }
                    enumerator2 = this.mMovedItems.Values.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            RoomItem @class = (RoomItem)enumerator2.Current;
                            stringBuilder.Append(string.Concat(new object[]
							{
								"UPDATE items SET x = '",
								@class.GetX,
								"', y = '",
								@class.GetY,
								"', z = '",
								@class.GetZ,
								"', rot = '",
								@class.Rot,
								"', wall_pos = '' WHERE Id = '",
								@class.Id,
								"' LIMIT 1; "
							}));
                        }
                    }
                    finally
                    {
                        IDisposable disposable = enumerator2 as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    this.mMovedItems.Clear();
                    foreach (Pet current in this.method_2())
                    {
                        if (current.DBState == DatabaseUpdateState.NeedsInsert)
                        {
                            class6_0.AddParamWithValue("petname" + current.PetId, current.Name);
                            class6_0.AddParamWithValue("petcolor" + current.PetId, current.Color);
                            class6_0.AddParamWithValue("petrace" + current.PetId, current.Race);
                            stringBuilder.Append(string.Concat(new object[]
							{
								"INSERT INTO `user_pets` VALUES ('",
								current.PetId,
								"', '",
								current.OwnerId,
								"', '",
								current.RoomId,
								"', @petname",
								current.PetId,
								", @petrace",
								current.PetId,
								", @petcolor",
								current.PetId,
								", '",
								current.Type,
								"', '",
								current.Expirience,
								"', '",
								current.Energy,
								"', '",
								current.Nutrition,
								"', '",
								current.Respect,
								"', '",
								current.CreationStamp,
								"', '",
								current.X,
								"', '",
								current.Y,
								"', '",
								current.Z,
								"');"
							}));
                        }
                        else
                        {
                            if (current.DBState == DatabaseUpdateState.NeedsUpdate)
                            {
                                stringBuilder.Append(string.Concat(new object[]
								{
									"UPDATE user_pets SET room_id = '",
									current.RoomId,
									"', expirience = '",
									current.Expirience,
									"', energy = '",
									current.Energy,
									"', nutrition = '",
									current.Nutrition,
									"', respect = '",
									current.Respect,
									"', x = '",
									current.X,
									"', y = '",
									current.Y,
									"', z = '",
									current.Z,
									"' WHERE Id = '",
									current.PetId,
									"' LIMIT 1; "
								}));
                            }
                        }
                        current.DBState = DatabaseUpdateState.Updated;
                    }
                }
                if (stringBuilder.Length > 0)
                {
                    class6_0.ExecuteQuery(stringBuilder.ToString());
                }
            }
            catch (Exception ex)
            {
                Logging.LogCriticalException(string.Concat(new object[]
				{
					"Error during saving furniture for room ",
					this.RoomId,
					". Stack: ",
					ex.ToString()
				}));
            }
        }
Пример #2
0
		internal void RunDBUpdate(DatabaseClient queries, bool bool_0)
		{
			try
			{
				if (mRemovedItems.Count > 0 || mAddedItems.Count > 0 || InventoryPets.Count > 0)
				{
					StringBuilder stringBuilder = new StringBuilder();
					foreach (Pet pet in this.InventoryPets.Values)
					{
						if (pet.DBState == DatabaseUpdateState.NeedsInsert)
						{
							queries.AddParamWithValue("petname" + pet.PetId, pet.Name);
							queries.AddParamWithValue("petcolor" + pet.PetId, pet.Color);
							queries.AddParamWithValue("petrace" + pet.PetId, pet.Race);
							stringBuilder.Append(string.Concat(new object[]
							{
								"INSERT INTO `user_pets` VALUES ('",
								pet.PetId,
								"', '",
								pet.OwnerId,
								"', '",
								pet.RoomId,
								"', @petname",
								pet.PetId,
								", @petrace",
								pet.PetId,
								", @petcolor",
								pet.PetId,
								", '",
								pet.Type,
								"', '",
								pet.Expirience,
								"', '",
								pet.Energy,
								"', '",
								pet.Nutrition,
								"', '",
								pet.Respect,
								"', '",
								pet.CreationStamp,
								"', '",
								pet.X,
								"', '",
								pet.Y,
								"', '",
								pet.Z,
								"');"
							}));
						}
						else
						{
							if (pet.DBState == DatabaseUpdateState.NeedsUpdate)
							{
								stringBuilder.Append(string.Concat(new object[]
								{
									"UPDATE user_pets SET room_id = '",
									pet.RoomId,
									"', expirience = '",
									pet.Expirience,
									"', energy = '",
									pet.Energy,
									"', nutrition = '",
									pet.Nutrition,
									"', respect = '",
									pet.Respect,
									"', x = '",
									pet.X,
									"', y = '",
									pet.Y,
									"', z = '",
									pet.Z,
									"' WHERE Id = '",
									pet.PetId,
									"' LIMIT 1; "
								}));
							}
						}
						pet.DBState = DatabaseUpdateState.Updated;
					}
					if (stringBuilder.Length > 0)
					{
						queries.ExecuteQuery(stringBuilder.ToString());
					}
				}
				if (bool_0)
				{
					Console.WriteLine("Inventory for user: "******" saved.");
				}
			}
			catch (Exception ex)
			{
                Logging.LogCacheError("FATAL ERROR DURING DB UPDATE: " + ex.ToString());
			}
		}
Пример #3
0
		internal void UpdateRooms(DatabaseClient dbClient)
		{
			this.UsersRooms.Clear();
			dbClient.AddParamWithValue("name", Username);
			DataTable dataTable = dbClient.ReadDataTable("SELECT * FROM rooms WHERE owner = @name ORDER BY Id ASC");
			foreach (DataRow dataRow in dataTable.Rows)
			{
				this.UsersRooms.Add(PhoenixEnvironment.GetGame().GetRoomManager().FetchRoomData((uint)dataRow["Id"], dataRow));
			}
		}