internal void method_65(DatabaseClient class6_0) { try { Dictionary<uint, bool> dictionary = new Dictionary<uint, bool>(); StringBuilder stringBuilder = new StringBuilder(); if (this.list_14.Count > 0) { foreach (RoomItem @class in this.list_14) { try { if (!dictionary.ContainsKey(@class.uint_0)) { class6_0.AddParamWithValue(@class.uint_0 + "Extra1", @class.string_2); class6_0.AddParamWithValue(@class.uint_0 + "Extra2", @class.string_3); class6_0.AddParamWithValue(@class.uint_0 + "Extra3", @class.string_4); class6_0.AddParamWithValue(@class.uint_0 + "Extra4", @class.string_5); class6_0.AddParamWithValue(@class.uint_0 + "Extra5", @class.string_6); stringBuilder.Append(string.Concat(new object[] { "DELETE FROM wired_items WHERE item_id = '", @class.uint_0, "' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('", @class.uint_0, "',@", @class.uint_0, "Extra1,@", @class.uint_0, "Extra2,@", @class.uint_0, "Extra3,@", @class.uint_0, "Extra4,@", @class.uint_0, "Extra5); " })); } dictionary.Add(@class.uint_0, true); } catch { } } } if (this.list_15.Count > 0) { foreach (RoomItem @class in this.list_15) { try { if (!dictionary.ContainsKey(@class.uint_0)) { class6_0.AddParamWithValue(@class.uint_0 + "Extra1", @class.string_2); class6_0.AddParamWithValue(@class.uint_0 + "Extra2", @class.string_3); class6_0.AddParamWithValue(@class.uint_0 + "Extra3", @class.string_4); class6_0.AddParamWithValue(@class.uint_0 + "Extra4", @class.string_5); class6_0.AddParamWithValue(@class.uint_0 + "Extra5", @class.string_6); stringBuilder.Append(string.Concat(new object[] { "DELETE FROM wired_items WHERE item_id = '", @class.uint_0, "' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('", @class.uint_0, "',@", @class.uint_0, "Extra1,@", @class.uint_0, "Extra2,@", @class.uint_0, "Extra3,@", @class.uint_0, "Extra4,@", @class.uint_0, "Extra5); " })); } dictionary.Add(@class.uint_0, true); } catch { } } } if (this.list_16.Count > 0) { foreach (RoomItem @class in this.list_16) { try { if (!dictionary.ContainsKey(@class.uint_0)) { class6_0.AddParamWithValue(@class.uint_0 + "Extra1", @class.string_2); class6_0.AddParamWithValue(@class.uint_0 + "Extra2", @class.string_3); class6_0.AddParamWithValue(@class.uint_0 + "Extra3", @class.string_4); class6_0.AddParamWithValue(@class.uint_0 + "Extra4", @class.string_5); class6_0.AddParamWithValue(@class.uint_0 + "Extra5", @class.string_6); stringBuilder.Append(string.Concat(new object[] { "DELETE FROM wired_items WHERE item_id = '", @class.uint_0, "' LIMIT 1; INSERT INTO wired_items (item_id,extra1,extra2,extra3,extra4,extra5) VALUES ('", @class.uint_0, "',@", @class.uint_0, "Extra1,@", @class.uint_0, "Extra2,@", @class.uint_0, "Extra3,@", @class.uint_0, "Extra4,@", @class.uint_0, "Extra5); " })); } dictionary.Add(@class.uint_0, true); } catch { } } } dictionary.Clear(); if (this.hashtable_3.Count > 0 || this.hashtable_1.Count > 0 || this.hashtable_2.Count > 0 || this.Boolean_4) { foreach (RoomItem @class in this.hashtable_1.Values) { stringBuilder.Append(string.Concat(new object[] { "UPDATE items SET room_id = 0 WHERE Id = '", @class.uint_0, "' AND room_id = '", this.Id, "' LIMIT 1; " })); } this.hashtable_1.Clear(); IEnumerator enumerator2; if (this.hashtable_3.Count > 0) { enumerator2 = this.hashtable_3.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { RoomItem @class = (RoomItem)enumerator2.Current; stringBuilder.Append("UPDATE items SET room_id = 0 WHERE Id = '" + @class.uint_0 + "' LIMIT 1; "); } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } int num = 0; int num2 = 0; enumerator2 = this.hashtable_3.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { RoomItem @class = (RoomItem)enumerator2.Current; if (@class.Boolean_2) { num2++; } else { num++; } } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (num2 > 0) { enumerator2 = this.hashtable_3.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { RoomItem @class = (RoomItem)enumerator2.Current; if (@class.Boolean_2) { stringBuilder.Append(string.Concat(new object[] { "UPDATE items SET room_id = '", this.Id, "', base_item = '", @class.uint_2, ", x = '", @class.GetX, "', y = '", @class.Int32_1, "', z = '", @class.Double_0.ToString().Replace(",", "."), "', rot = '", @class.int_3, "', wall_pos = '' WHERE Id = '", @class.uint_0, "' LIMIT 1; " })); if (!string.IsNullOrEmpty(@class.ExtraData)) { class6_0.AddParamWithValue("extra_data" + @class.uint_0, @class.ExtraData); stringBuilder.Append(string.Concat(new object[] { "DELETE FROM items_extra_data WHERE item_id = '" + @class.uint_0 + "'; ", "INSERT INTO items_extra_data (item_id,extra_data) VALUES ('" + @class.uint_0 + "' , @extra_data" + @class.uint_0 + "); ", })); } else { stringBuilder.Append(string.Concat(new object[] { "DELETE FROM items_extra_data WHERE item_id = '" + @class.uint_0 + "'; " })); } } } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } if (num > 0) { enumerator2 = this.hashtable_3.Values.GetEnumerator(); try { while (enumerator2.MoveNext()) { RoomItem @class = (RoomItem)enumerator2.Current; if (@class.Boolean_1) { class6_0.AddParamWithValue("pos" + @class.uint_0, @class.string_7); stringBuilder.Append(string.Concat(new object[] { "UPDATE items SET room_id = '", this.Id, "', base_item = '", @class.uint_2, ", x = '0', y = '0', z = '0', rot = '0', wall_pos = @pos", @class.uint_0, " WHERE Id = '", @class.uint_0, "' LIMIT 1; " })); if (!string.IsNullOrEmpty(@class.ExtraData)) { class6_0.AddParamWithValue("extra_data" + @class.uint_0, @class.ExtraData); stringBuilder.Append(string.Concat(new object[] { "DELETE FROM items_extra_data WHERE item_id = '" + @class.uint_0 + "'; ", "INSERT INTO items_extra_data (item_id,extra_data) VALUES ('" + @class.uint_0 + "' , @extra_data" + @class.uint_0 + "); ", })); } else { stringBuilder.Append(string.Concat(new object[] { "DELETE FROM items_extra_data WHERE item_id = '" + @class.uint_0 + "'; " })); } } } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } } this.hashtable_3.Clear(); } enumerator2 = this.hashtable_2.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.Int32_1, "', z = '", @class.Double_0.ToString().Replace(",", "."), "', rot = '", @class.int_3, "', wall_pos = '' WHERE Id = '", @class.uint_0, "' LIMIT 1; " })); } } finally { IDisposable disposable = enumerator2 as IDisposable; if (disposable != null) { disposable.Dispose(); } } this.hashtable_2.Clear(); foreach (Pet current in this.GetPets()) { 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.Id, ". Stack: ", ex.ToString() })); } }
internal void SavePets(DatabaseClient dbClient, bool consoleOutput) { try { if (this.list_1.Count > 0 || this.hashtable_1.Count > 0 || this.Pets.Count > 0) { StringBuilder stringBuilder = new StringBuilder(); foreach (Pet pet in Pets.Values) { if (pet.DBState == DatabaseUpdateState.NeedsInsert) { dbClient.AddParamWithValue("petname" + pet.PetId, pet.Name); dbClient.AddParamWithValue("petcolor" + pet.PetId, pet.Color); dbClient.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) { dbClient.ExecuteQuery(stringBuilder.ToString()); } } if (consoleOutput) { Console.WriteLine("Inventory for user: "******" saved."); } } catch (Exception ex) { Logging.LogCacheError("FATAL ERROR DURING DB UPDATE: " + ex.ToString()); } }