From 15c9b641201cedd6fd21207ac60dfebd81534551 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 4 Apr 2020 04:44:39 -0500 Subject: [PATCH] Add GetWhere and DeleteWhere repository methods --- common/repositories/aa_ability_repository.h | 54 ++- .../repositories/aa_rank_effects_repository.h | 45 ++- .../repositories/aa_rank_prereqs_repository.h | 43 ++- common/repositories/aa_ranks_repository.h | 53 ++- .../repositories/account_flags_repository.h | 43 ++- common/repositories/account_ip_repository.h | 44 ++- common/repositories/account_repository.h | 59 +++- .../repositories/account_rewards_repository.h | 43 ++- .../adventure_details_repository.h | 49 ++- .../adventure_members_repository.h | 42 ++- .../repositories/adventure_stats_repository.h | 51 ++- ...venture_template_entry_flavor_repository.h | 42 ++- .../adventure_template_entry_repository.h | 42 ++- .../adventure_template_repository.h | 157 ++++++--- .../alternate_currency_repository.h | 42 ++- common/repositories/auras_repository.h | 51 ++- common/repositories/banned_ips_repository.h | 42 ++- common/repositories/base_data_repository.h | 98 ++++-- .../repositories/blocked_spells_repository.h | 88 ++++- common/repositories/books_repository.h | 43 ++- common/repositories/bug_reports_repository.h | 90 ++++- common/repositories/bugs_repository.h | 71 +++- common/repositories/buyer_repository.h | 46 ++- .../char_create_combinations_repository.h | 46 ++- ...char_create_point_allocations_repository.h | 55 ++- .../char_recipe_list_repository.h | 43 ++- .../character_activities_repository.h | 45 ++- .../character_alt_currency_repository.h | 43 ++- ...character_alternate_abilities_repository.h | 44 ++- .../repositories/character_auras_repository.h | 43 ++- .../character_bandolier_repository.h | 46 ++- .../repositories/character_bind_repository.h | 72 +++- .../repositories/character_buffs_repository.h | 57 ++- .../character_corpse_items_repository.h | 51 ++- .../character_corpses_repository.h | 111 +++++- .../character_currency_repository.h | 57 ++- .../repositories/character_data_repository.h | 166 ++++++++- .../character_disciplines_repository.h | 43 ++- .../character_inspect_messages_repository.h | 42 ++- .../character_item_recast_repository.h | 43 ++- .../character_languages_repository.h | 43 ++- ...haracter_leadership_abilities_repository.h | 43 ++- .../character_material_repository.h | 47 ++- .../character_memmed_spells_repository.h | 43 ++- .../character_pet_buffs_repository.h | 51 ++- .../character_pet_info_repository.h | 54 ++- .../character_pet_inventory_repository.h | 44 ++- .../character_potionbelt_repository.h | 44 ++- .../character_skills_repository.h | 43 ++- .../character_spells_repository.h | 43 ++- .../repositories/character_tasks_repository.h | 45 ++- .../character_tribute_repository.h | 43 ++- common/repositories/chatchannels_repository.h | 44 ++- .../command_settings_repository.h | 43 ++- .../repositories/completed_tasks_repository.h | 44 ++- common/repositories/data_buckets_repository.h | 44 ++- common/repositories/db_str_repository.h | 43 ++- .../discovered_items_repository.h | 44 ++- common/repositories/doors_repository.h | 125 +++++-- common/repositories/eventlog_repository.h | 50 ++- .../faction_base_data_repository.h | 46 ++- .../faction_list_mod_repository.h | 44 ++- common/repositories/faction_list_repository.h | 43 ++- .../repositories/faction_values_repository.h | 44 ++- common/repositories/fishing_repository.h | 47 ++- common/repositories/forage_repository.h | 45 ++- common/repositories/friends_repository.h | 43 ++- common/repositories/global_loot_repository.h | 53 ++- common/repositories/gm_ips_repository.h | 43 ++- common/repositories/goallists_repository.h | 42 ++- common/repositories/graveyard_repository.h | 70 +++- .../repositories/ground_spawns_repository.h | 90 ++++- common/repositories/group_id_repository.h | 44 ++- .../repositories/group_leaders_repository.h | 49 ++- .../repositories/guild_members_repository.h | 49 ++- common/repositories/guild_ranks_repository.h | 51 ++- .../repositories/guild_relations_repository.h | 43 ++- common/repositories/guilds_repository.h | 49 ++- common/repositories/hackers_repository.h | 46 ++- common/repositories/horses_repository.h | 52 ++- .../instance_list_player_repository.h | 42 ++- .../repositories/instance_list_repository.h | 45 +++ common/repositories/inventory_repository.h | 56 ++- .../inventory_snapshots_repository.h | 57 ++- .../repositories/ip_exemptions_repository.h | 43 ++- common/repositories/item_tick_repository.h | 46 ++- common/repositories/items_repository.h | 331 +++++++++++++++++- common/repositories/launcher_repository.h | 42 ++- .../repositories/launcher_zones_repository.h | 43 ++- .../ldon_trap_entries_repository.h | 42 ++- .../ldon_trap_templates_repository.h | 45 ++- .../repositories/level_exp_mods_repository.h | 55 ++- common/repositories/lfguild_repository.h | 49 ++- .../repositories/login_accounts_repository.h | 49 ++- .../login_api_tokens_repository.h | 46 ++- .../login_server_admins_repository.h | 48 ++- .../login_server_list_types_repository.h | 42 ++- .../login_world_servers_repository.h | 50 ++- .../logsys_categories_repository.h | 45 ++- .../lootdrop_entries_repository.h | 61 +++- common/repositories/lootdrop_repository.h | 42 ++- .../loottable_entries_repository.h | 52 ++- common/repositories/loottable_repository.h | 46 ++- common/repositories/mail_repository.h | 48 ++- common/repositories/merchantlist_repository.h | 48 ++- .../merchantlist_temp_repository.h | 44 ++- common/repositories/name_filter_repository.h | 42 ++- common/repositories/npc_emotes_repository.h | 45 ++- .../npc_faction_entries_repository.h | 45 ++- common/repositories/npc_faction_repository.h | 44 ++- .../npc_scale_global_base_repository.h | 68 +++- .../npc_spells_effects_entries_repository.h | 48 ++- .../npc_spells_effects_repository.h | 43 ++- .../npc_spells_entries_repository.h | 52 ++- common/repositories/npc_spells_repository.h | 61 +++- common/repositories/npc_types_repository.h | 192 +++++++++- .../repositories/npc_types_tint_repository.h | 69 +++- .../repositories/object_contents_repository.h | 52 ++- common/repositories/object_repository.h | 108 ++++-- .../perl_event_export_settings_repository.h | 47 ++- common/repositories/petitions_repository.h | 56 ++- .../pets_equipmentset_entries_repository.h | 43 ++- .../pets_equipmentset_repository.h | 43 ++- common/repositories/pets_repository.h | 48 ++- .../player_titlesets_repository.h | 43 ++- common/repositories/proximities_repository.h | 84 ++++- .../repositories/quest_globals_repository.h | 46 ++- common/repositories/raid_details_repository.h | 44 ++- common/repositories/raid_members_repository.h | 49 ++- common/repositories/reports_repository.h | 44 ++- .../repositories/respawn_times_repository.h | 44 ++- common/repositories/rule_sets_repository.h | 42 ++- common/repositories/rule_values_repository.h | 44 ++- common/repositories/saylink_repository.h | 42 ++- common/repositories/skill_caps_repository.h | 45 ++- common/repositories/spawn2_repository.h | 79 ++++- .../spawn_condition_values_repository.h | 44 ++- .../spawn_conditions_repository.h | 45 ++- common/repositories/spawn_events_repository.h | 54 ++- common/repositories/spawnentry_repository.h | 44 ++- common/repositories/spawngroup_repository.h | 83 ++++- .../repositories/spell_buckets_repository.h | 43 ++- .../repositories/spell_globals_repository.h | 44 ++- common/repositories/spells_new_repository.h | 301 +++++++++++++++- common/repositories/start_zones_repository.h | 97 +++-- .../repositories/starting_items_repository.h | 49 ++- .../repositories/task_activities_repository.h | 55 ++- common/repositories/tasks_repository.h | 56 ++- common/repositories/tasksets_repository.h | 42 ++- .../repositories/template/repository.template | 41 ++- common/repositories/timers_repository.h | 45 ++- common/repositories/titles_repository.h | 54 ++- common/repositories/trader_repository.h | 46 ++- .../tradeskill_recipe_entries_repository.h | 48 ++- common/repositories/traps_repository.h | 73 +++- .../repositories/tribute_levels_repository.h | 44 ++- common/repositories/tributes_repository.h | 45 ++- common/repositories/variables_repository.h | 44 ++- .../veteran_reward_templates_repository.h | 45 ++- common/repositories/zone_points_repository.h | 111 ++++-- common/repositories/zone_repository.h | 252 +++++++++---- .../generators/repository-generator.pl | 4 +- world/world_server_command_handler.cpp | 43 ++- world/world_server_command_handler.h | 1 + 164 files changed, 8806 insertions(+), 594 deletions(-) diff --git a/common/repositories/aa_ability_repository.h b/common/repositories/aa_ability_repository.h index b5010c627..62aeb7a4b 100644 --- a/common/repositories/aa_ability_repository.h +++ b/common/repositories/aa_ability_repository.h @@ -268,7 +268,7 @@ public: return aa_ability_entry; } - aa_ability_entry = InstanceListRepository::NewEntity(); + aa_ability_entry = AaAbilityRepository::NewEntity(); return aa_ability_entry; } @@ -349,6 +349,58 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AaAbility entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.category = atoi(row[2]); + entry.classes = atoi(row[3]); + entry.races = atoi(row[4]); + entry.drakkin_heritage = atoi(row[5]); + entry.deities = atoi(row[6]); + entry.status = atoi(row[7]); + entry.type = atoi(row[8]); + entry.charges = atoi(row[9]); + entry.grant_only = atoi(row[10]); + entry.first_rank_id = atoi(row[11]); + entry.enabled = atoi(row[12]); + entry.reset_on_death = atoi(row[13]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_AA_ABILITY_REPOSITORY_H diff --git a/common/repositories/aa_rank_effects_repository.h b/common/repositories/aa_rank_effects_repository.h index 27d830db5..17436af76 100644 --- a/common/repositories/aa_rank_effects_repository.h +++ b/common/repositories/aa_rank_effects_repository.h @@ -212,7 +212,7 @@ public: return aa_rank_effects_entry; } - aa_rank_effects_entry = InstanceListRepository::NewEntity(); + aa_rank_effects_entry = AaRankEffectsRepository::NewEntity(); return aa_rank_effects_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AaRankEffects entry{}; + + entry.rank_id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.effect_id = atoi(row[2]); + entry.base1 = atoi(row[3]); + entry.base2 = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_AA_RANK_EFFECTS_REPOSITORY_H diff --git a/common/repositories/aa_rank_prereqs_repository.h b/common/repositories/aa_rank_prereqs_repository.h index 29e102adc..bf7ccb98e 100644 --- a/common/repositories/aa_rank_prereqs_repository.h +++ b/common/repositories/aa_rank_prereqs_repository.h @@ -200,7 +200,7 @@ public: return aa_rank_prereqs_entry; } - aa_rank_prereqs_entry = InstanceListRepository::NewEntity(); + aa_rank_prereqs_entry = AaRankPrereqsRepository::NewEntity(); return aa_rank_prereqs_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AaRankPrereqs entry{}; + + entry.rank_id = atoi(row[0]); + entry.aa_id = atoi(row[1]); + entry.points = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_AA_RANK_PREREQS_REPOSITORY_H diff --git a/common/repositories/aa_ranks_repository.h b/common/repositories/aa_ranks_repository.h index fe0a556ad..27ff7b1d7 100644 --- a/common/repositories/aa_ranks_repository.h +++ b/common/repositories/aa_ranks_repository.h @@ -262,7 +262,7 @@ public: return aa_ranks_entry; } - aa_ranks_entry = InstanceListRepository::NewEntity(); + aa_ranks_entry = AaRanksRepository::NewEntity(); return aa_ranks_entry; } @@ -341,6 +341,57 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AaRanks entry{}; + + entry.id = atoi(row[0]); + entry.upper_hotkey_sid = atoi(row[1]); + entry.lower_hotkey_sid = atoi(row[2]); + entry.title_sid = atoi(row[3]); + entry.desc_sid = atoi(row[4]); + entry.cost = atoi(row[5]); + entry.level_req = atoi(row[6]); + entry.spell = atoi(row[7]); + entry.spell_type = atoi(row[8]); + entry.recast_time = atoi(row[9]); + entry.expansion = atoi(row[10]); + entry.prev_id = atoi(row[11]); + entry.next_id = atoi(row[12]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_AA_RANKS_REPOSITORY_H diff --git a/common/repositories/account_flags_repository.h b/common/repositories/account_flags_repository.h index c23871c5f..6943d1d3e 100644 --- a/common/repositories/account_flags_repository.h +++ b/common/repositories/account_flags_repository.h @@ -200,7 +200,7 @@ public: return account_flags_entry; } - account_flags_entry = InstanceListRepository::NewEntity(); + account_flags_entry = AccountFlagsRepository::NewEntity(); return account_flags_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AccountFlags entry{}; + + entry.p_accid = atoi(row[0]); + entry.p_flag = row[1]; + entry.p_value = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ACCOUNT_FLAGS_REPOSITORY_H diff --git a/common/repositories/account_ip_repository.h b/common/repositories/account_ip_repository.h index 77c7d41d0..aea63827d 100644 --- a/common/repositories/account_ip_repository.h +++ b/common/repositories/account_ip_repository.h @@ -206,7 +206,7 @@ public: return account_ip_entry; } - account_ip_entry = InstanceListRepository::NewEntity(); + account_ip_entry = AccountIpRepository::NewEntity(); return account_ip_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AccountIp entry{}; + + entry.accid = atoi(row[0]); + entry.ip = row[1]; + entry.count = atoi(row[2]); + entry.lastused = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ACCOUNT_IP_REPOSITORY_H diff --git a/common/repositories/account_repository.h b/common/repositories/account_repository.h index d78bcf866..c043dc8ee 100644 --- a/common/repositories/account_repository.h +++ b/common/repositories/account_repository.h @@ -298,7 +298,7 @@ public: return account_entry; } - account_entry = InstanceListRepository::NewEntity(); + account_entry = AccountRepository::NewEntity(); return account_entry; } @@ -389,6 +389,63 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Account entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.charname = row[2]; + entry.sharedplat = atoi(row[3]); + entry.password = row[4]; + entry.status = atoi(row[5]); + entry.ls_id = row[6]; + entry.lsaccount_id = atoi(row[7]); + entry.gmspeed = atoi(row[8]); + entry.revoked = atoi(row[9]); + entry.karma = atoi(row[10]); + entry.minilogin_ip = row[11]; + entry.hideme = atoi(row[12]); + entry.rulesflag = atoi(row[13]); + entry.suspendeduntil = row[14]; + entry.time_creation = atoi(row[15]); + entry.expansion = atoi(row[16]); + entry.ban_reason = row[17]; + entry.suspend_reason = row[18]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ACCOUNT_REPOSITORY_H diff --git a/common/repositories/account_rewards_repository.h b/common/repositories/account_rewards_repository.h index 5a0a113ba..8e2abd112 100644 --- a/common/repositories/account_rewards_repository.h +++ b/common/repositories/account_rewards_repository.h @@ -200,7 +200,7 @@ public: return account_rewards_entry; } - account_rewards_entry = InstanceListRepository::NewEntity(); + account_rewards_entry = AccountRewardsRepository::NewEntity(); return account_rewards_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AccountRewards entry{}; + + entry.account_id = atoi(row[0]); + entry.reward_id = atoi(row[1]); + entry.amount = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ACCOUNT_REWARDS_REPOSITORY_H diff --git a/common/repositories/adventure_details_repository.h b/common/repositories/adventure_details_repository.h index 19e3dbed8..fbb2a4df2 100644 --- a/common/repositories/adventure_details_repository.h +++ b/common/repositories/adventure_details_repository.h @@ -238,7 +238,7 @@ public: return adventure_details_entry; } - adventure_details_entry = InstanceListRepository::NewEntity(); + adventure_details_entry = AdventureDetailsRepository::NewEntity(); return adventure_details_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureDetails entry{}; + + entry.id = atoi(row[0]); + entry.adventure_id = atoi(row[1]); + entry.instance_id = atoi(row[2]); + entry.count = atoi(row[3]); + entry.assassinate_count = atoi(row[4]); + entry.status = atoi(row[5]); + entry.time_created = atoi(row[6]); + entry.time_zoned = atoi(row[7]); + entry.time_completed = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_DETAILS_REPOSITORY_H diff --git a/common/repositories/adventure_members_repository.h b/common/repositories/adventure_members_repository.h index 10c221f4a..4bc18a18d 100644 --- a/common/repositories/adventure_members_repository.h +++ b/common/repositories/adventure_members_repository.h @@ -196,7 +196,7 @@ public: return adventure_members_entry; } - adventure_members_entry = InstanceListRepository::NewEntity(); + adventure_members_entry = AdventureMembersRepository::NewEntity(); return adventure_members_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureMembers entry{}; + + entry.id = atoi(row[0]); + entry.charid = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_MEMBERS_REPOSITORY_H diff --git a/common/repositories/adventure_stats_repository.h b/common/repositories/adventure_stats_repository.h index 5b845f729..12a35c714 100644 --- a/common/repositories/adventure_stats_repository.h +++ b/common/repositories/adventure_stats_repository.h @@ -250,7 +250,7 @@ public: return adventure_stats_entry; } - adventure_stats_entry = InstanceListRepository::NewEntity(); + adventure_stats_entry = AdventureStatsRepository::NewEntity(); return adventure_stats_entry; } @@ -325,6 +325,55 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureStats entry{}; + + entry.player_id = atoi(row[0]); + entry.guk_wins = atoi(row[1]); + entry.mir_wins = atoi(row[2]); + entry.mmc_wins = atoi(row[3]); + entry.ruj_wins = atoi(row[4]); + entry.tak_wins = atoi(row[5]); + entry.guk_losses = atoi(row[6]); + entry.mir_losses = atoi(row[7]); + entry.mmc_losses = atoi(row[8]); + entry.ruj_losses = atoi(row[9]); + entry.tak_losses = atoi(row[10]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_STATS_REPOSITORY_H diff --git a/common/repositories/adventure_template_entry_flavor_repository.h b/common/repositories/adventure_template_entry_flavor_repository.h index d55f9a772..4c72735a5 100644 --- a/common/repositories/adventure_template_entry_flavor_repository.h +++ b/common/repositories/adventure_template_entry_flavor_repository.h @@ -196,7 +196,7 @@ public: return adventure_template_entry_flavor_entry; } - adventure_template_entry_flavor_entry = InstanceListRepository::NewEntity(); + adventure_template_entry_flavor_entry = AdventureTemplateEntryFlavorRepository::NewEntity(); return adventure_template_entry_flavor_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureTemplateEntryFlavor entry{}; + + entry.id = atoi(row[0]); + entry.text = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_TEMPLATE_ENTRY_FLAVOR_REPOSITORY_H diff --git a/common/repositories/adventure_template_entry_repository.h b/common/repositories/adventure_template_entry_repository.h index 844d3b3be..7080b87a6 100644 --- a/common/repositories/adventure_template_entry_repository.h +++ b/common/repositories/adventure_template_entry_repository.h @@ -196,7 +196,7 @@ public: return adventure_template_entry_entry; } - adventure_template_entry_entry = InstanceListRepository::NewEntity(); + adventure_template_entry_entry = AdventureTemplateEntryRepository::NewEntity(); return adventure_template_entry_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureTemplateEntry entry{}; + + entry.id = atoi(row[0]); + entry.template_id = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_TEMPLATE_ENTRY_REPOSITORY_H diff --git a/common/repositories/adventure_template_repository.h b/common/repositories/adventure_template_repository.h index 2f5f78296..4ef56ca80 100644 --- a/common/repositories/adventure_template_repository.h +++ b/common/repositories/adventure_template_repository.h @@ -293,10 +293,10 @@ public: update_values.push_back(columns[7] + " = " + std::to_string(adventure_template_entry.type)); update_values.push_back(columns[8] + " = " + std::to_string(adventure_template_entry.type_data)); update_values.push_back(columns[9] + " = " + std::to_string(adventure_template_entry.type_count)); - update_values.push_back(columns[10] + " = '" + EscapeString(adventure_template_entry.assa_x) + "'"); - update_values.push_back(columns[11] + " = '" + EscapeString(adventure_template_entry.assa_y) + "'"); - update_values.push_back(columns[12] + " = '" + EscapeString(adventure_template_entry.assa_z) + "'"); - update_values.push_back(columns[13] + " = '" + EscapeString(adventure_template_entry.assa_h) + "'"); + update_values.push_back(columns[10] + " = " + std::to_string(adventure_template_entry.assa_x)); + update_values.push_back(columns[11] + " = " + std::to_string(adventure_template_entry.assa_y)); + update_values.push_back(columns[12] + " = " + std::to_string(adventure_template_entry.assa_z)); + update_values.push_back(columns[13] + " = " + std::to_string(adventure_template_entry.assa_h)); update_values.push_back(columns[14] + " = '" + EscapeString(adventure_template_entry.text) + "'"); update_values.push_back(columns[15] + " = " + std::to_string(adventure_template_entry.duration)); update_values.push_back(columns[16] + " = " + std::to_string(adventure_template_entry.zone_in_time)); @@ -304,18 +304,18 @@ public: update_values.push_back(columns[18] + " = " + std::to_string(adventure_template_entry.lose_points)); update_values.push_back(columns[19] + " = " + std::to_string(adventure_template_entry.theme)); update_values.push_back(columns[20] + " = " + std::to_string(adventure_template_entry.zone_in_zone_id)); - update_values.push_back(columns[21] + " = '" + EscapeString(adventure_template_entry.zone_in_x) + "'"); - update_values.push_back(columns[22] + " = '" + EscapeString(adventure_template_entry.zone_in_y) + "'"); + update_values.push_back(columns[21] + " = " + std::to_string(adventure_template_entry.zone_in_x)); + update_values.push_back(columns[22] + " = " + std::to_string(adventure_template_entry.zone_in_y)); update_values.push_back(columns[23] + " = " + std::to_string(adventure_template_entry.zone_in_object_id)); - update_values.push_back(columns[24] + " = '" + EscapeString(adventure_template_entry.dest_x) + "'"); - update_values.push_back(columns[25] + " = '" + EscapeString(adventure_template_entry.dest_y) + "'"); - update_values.push_back(columns[26] + " = '" + EscapeString(adventure_template_entry.dest_z) + "'"); - update_values.push_back(columns[27] + " = '" + EscapeString(adventure_template_entry.dest_h) + "'"); + update_values.push_back(columns[24] + " = " + std::to_string(adventure_template_entry.dest_x)); + update_values.push_back(columns[25] + " = " + std::to_string(adventure_template_entry.dest_y)); + update_values.push_back(columns[26] + " = " + std::to_string(adventure_template_entry.dest_z)); + update_values.push_back(columns[27] + " = " + std::to_string(adventure_template_entry.dest_h)); update_values.push_back(columns[28] + " = " + std::to_string(adventure_template_entry.graveyard_zone_id)); - update_values.push_back(columns[29] + " = '" + EscapeString(adventure_template_entry.graveyard_x) + "'"); - update_values.push_back(columns[30] + " = '" + EscapeString(adventure_template_entry.graveyard_y) + "'"); - update_values.push_back(columns[31] + " = '" + EscapeString(adventure_template_entry.graveyard_z) + "'"); - update_values.push_back(columns[32] + " = '" + EscapeString(adventure_template_entry.graveyard_radius) + "'"); + update_values.push_back(columns[29] + " = " + std::to_string(adventure_template_entry.graveyard_x)); + update_values.push_back(columns[30] + " = " + std::to_string(adventure_template_entry.graveyard_y)); + update_values.push_back(columns[31] + " = " + std::to_string(adventure_template_entry.graveyard_z)); + update_values.push_back(columns[32] + " = " + std::to_string(adventure_template_entry.graveyard_radius)); auto results = content_db.QueryDatabase( fmt::format( @@ -345,10 +345,10 @@ public: insert_values.push_back(std::to_string(adventure_template_entry.type)); insert_values.push_back(std::to_string(adventure_template_entry.type_data)); insert_values.push_back(std::to_string(adventure_template_entry.type_count)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_h) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.assa_x)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_y)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_z)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_h)); insert_values.push_back("'" + EscapeString(adventure_template_entry.text) + "'"); insert_values.push_back(std::to_string(adventure_template_entry.duration)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time)); @@ -356,18 +356,18 @@ public: insert_values.push_back(std::to_string(adventure_template_entry.lose_points)); insert_values.push_back(std::to_string(adventure_template_entry.theme)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.zone_in_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.zone_in_y) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x)); + insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_h) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.dest_x)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_y)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_z)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_h)); insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_radius) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius)); auto results = content_db.QueryDatabase( fmt::format( @@ -382,7 +382,7 @@ public: return adventure_template_entry; } - adventure_template_entry = InstanceListRepository::NewEntity(); + adventure_template_entry = AdventureTemplateRepository::NewEntity(); return adventure_template_entry; } @@ -405,10 +405,10 @@ public: insert_values.push_back(std::to_string(adventure_template_entry.type)); insert_values.push_back(std::to_string(adventure_template_entry.type_data)); insert_values.push_back(std::to_string(adventure_template_entry.type_count)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.assa_h) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.assa_x)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_y)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_z)); + insert_values.push_back(std::to_string(adventure_template_entry.assa_h)); insert_values.push_back("'" + EscapeString(adventure_template_entry.text) + "'"); insert_values.push_back(std::to_string(adventure_template_entry.duration)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_time)); @@ -416,18 +416,18 @@ public: insert_values.push_back(std::to_string(adventure_template_entry.lose_points)); insert_values.push_back(std::to_string(adventure_template_entry.theme)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_zone_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.zone_in_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.zone_in_y) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.zone_in_x)); + insert_values.push_back(std::to_string(adventure_template_entry.zone_in_y)); insert_values.push_back(std::to_string(adventure_template_entry.zone_in_object_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.dest_h) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.dest_x)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_y)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_z)); + insert_values.push_back(std::to_string(adventure_template_entry.dest_h)); insert_values.push_back(std::to_string(adventure_template_entry.graveyard_zone_id)); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_x) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_y) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_z) + "'"); - insert_values.push_back("'" + EscapeString(adventure_template_entry.graveyard_radius) + "'"); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_x)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_y)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_z)); + insert_values.push_back(std::to_string(adventure_template_entry.graveyard_radius)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -501,6 +501,77 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AdventureTemplate entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.zone_version = atoi(row[2]); + entry.is_hard = atoi(row[3]); + entry.is_raid = atoi(row[4]); + entry.min_level = atoi(row[5]); + entry.max_level = atoi(row[6]); + entry.type = atoi(row[7]); + entry.type_data = atoi(row[8]); + entry.type_count = atoi(row[9]); + entry.assa_x = atof(row[10]); + entry.assa_y = atof(row[11]); + entry.assa_z = atof(row[12]); + entry.assa_h = atof(row[13]); + entry.text = row[14]; + entry.duration = atoi(row[15]); + entry.zone_in_time = atoi(row[16]); + entry.win_points = atoi(row[17]); + entry.lose_points = atoi(row[18]); + entry.theme = atoi(row[19]); + entry.zone_in_zone_id = atoi(row[20]); + entry.zone_in_x = atof(row[21]); + entry.zone_in_y = atof(row[22]); + entry.zone_in_object_id = atoi(row[23]); + entry.dest_x = atof(row[24]); + entry.dest_y = atof(row[25]); + entry.dest_z = atof(row[26]); + entry.dest_h = atof(row[27]); + entry.graveyard_zone_id = atoi(row[28]); + entry.graveyard_x = atof(row[29]); + entry.graveyard_y = atof(row[30]); + entry.graveyard_z = atof(row[31]); + entry.graveyard_radius = atof(row[32]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ADVENTURE_TEMPLATE_REPOSITORY_H diff --git a/common/repositories/alternate_currency_repository.h b/common/repositories/alternate_currency_repository.h index 7c68b7b6d..a47c914b9 100644 --- a/common/repositories/alternate_currency_repository.h +++ b/common/repositories/alternate_currency_repository.h @@ -196,7 +196,7 @@ public: return alternate_currency_entry; } - alternate_currency_entry = InstanceListRepository::NewEntity(); + alternate_currency_entry = AlternateCurrencyRepository::NewEntity(); return alternate_currency_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + AlternateCurrency entry{}; + + entry.id = atoi(row[0]); + entry.item_id = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ALTERNATE_CURRENCY_REPOSITORY_H diff --git a/common/repositories/auras_repository.h b/common/repositories/auras_repository.h index cd8032ce2..f76ca9e59 100644 --- a/common/repositories/auras_repository.h +++ b/common/repositories/auras_repository.h @@ -250,7 +250,7 @@ public: return auras_entry; } - auras_entry = InstanceListRepository::NewEntity(); + auras_entry = AurasRepository::NewEntity(); return auras_entry; } @@ -325,6 +325,55 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Auras entry{}; + + entry.type = atoi(row[0]); + entry.npc_type = atoi(row[1]); + entry.name = row[2]; + entry.spell_id = atoi(row[3]); + entry.distance = atoi(row[4]); + entry.aura_type = atoi(row[5]); + entry.spawn_type = atoi(row[6]); + entry.movement = atoi(row[7]); + entry.duration = atoi(row[8]); + entry.icon = atoi(row[9]); + entry.cast_time = atoi(row[10]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_AURAS_REPOSITORY_H diff --git a/common/repositories/banned_ips_repository.h b/common/repositories/banned_ips_repository.h index 7993eef5b..26e8293f0 100644 --- a/common/repositories/banned_ips_repository.h +++ b/common/repositories/banned_ips_repository.h @@ -196,7 +196,7 @@ public: return banned_ips_entry; } - banned_ips_entry = InstanceListRepository::NewEntity(); + banned_ips_entry = BannedIpsRepository::NewEntity(); return banned_ips_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + BannedIps entry{}; + + entry.ip_address = row[0]; + entry.notes = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BANNED_IPS_REPOSITORY_H diff --git a/common/repositories/base_data_repository.h b/common/repositories/base_data_repository.h index 600502a71..08a190239 100644 --- a/common/repositories/base_data_repository.h +++ b/common/repositories/base_data_repository.h @@ -192,14 +192,14 @@ public: auto columns = Columns(); - update_values.push_back(columns[2] + " = '" + EscapeString(base_data_entry.hp) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(base_data_entry.mana) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(base_data_entry.end) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(base_data_entry.unk1) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(base_data_entry.unk2) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(base_data_entry.hp_fac) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(base_data_entry.mana_fac) + "'"); - update_values.push_back(columns[9] + " = '" + EscapeString(base_data_entry.end_fac) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(base_data_entry.hp)); + update_values.push_back(columns[3] + " = " + std::to_string(base_data_entry.mana)); + update_values.push_back(columns[4] + " = " + std::to_string(base_data_entry.end)); + update_values.push_back(columns[5] + " = " + std::to_string(base_data_entry.unk1)); + update_values.push_back(columns[6] + " = " + std::to_string(base_data_entry.unk2)); + update_values.push_back(columns[7] + " = " + std::to_string(base_data_entry.hp_fac)); + update_values.push_back(columns[8] + " = " + std::to_string(base_data_entry.mana_fac)); + update_values.push_back(columns[9] + " = " + std::to_string(base_data_entry.end_fac)); auto results = content_db.QueryDatabase( fmt::format( @@ -220,14 +220,14 @@ public: { std::vector insert_values; - insert_values.push_back("'" + EscapeString(base_data_entry.hp) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.mana) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.end) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.unk1) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.unk2) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.hp_fac) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.mana_fac) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.end_fac) + "'"); + insert_values.push_back(std::to_string(base_data_entry.hp)); + insert_values.push_back(std::to_string(base_data_entry.mana)); + insert_values.push_back(std::to_string(base_data_entry.end)); + insert_values.push_back(std::to_string(base_data_entry.unk1)); + insert_values.push_back(std::to_string(base_data_entry.unk2)); + insert_values.push_back(std::to_string(base_data_entry.hp_fac)); + insert_values.push_back(std::to_string(base_data_entry.mana_fac)); + insert_values.push_back(std::to_string(base_data_entry.end_fac)); auto results = content_db.QueryDatabase( fmt::format( @@ -242,7 +242,7 @@ public: return base_data_entry; } - base_data_entry = InstanceListRepository::NewEntity(); + base_data_entry = BaseDataRepository::NewEntity(); return base_data_entry; } @@ -256,14 +256,14 @@ public: for (auto &base_data_entry: base_data_entries) { std::vector insert_values; - insert_values.push_back("'" + EscapeString(base_data_entry.hp) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.mana) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.end) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.unk1) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.unk2) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.hp_fac) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.mana_fac) + "'"); - insert_values.push_back("'" + EscapeString(base_data_entry.end_fac) + "'"); + insert_values.push_back(std::to_string(base_data_entry.hp)); + insert_values.push_back(std::to_string(base_data_entry.mana)); + insert_values.push_back(std::to_string(base_data_entry.end)); + insert_values.push_back(std::to_string(base_data_entry.unk1)); + insert_values.push_back(std::to_string(base_data_entry.unk2)); + insert_values.push_back(std::to_string(base_data_entry.hp_fac)); + insert_values.push_back(std::to_string(base_data_entry.mana_fac)); + insert_values.push_back(std::to_string(base_data_entry.end_fac)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -314,6 +314,54 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + BaseData entry{}; + + entry.level = atoi(row[0]); + entry.class = atoi(row[1]); + entry.hp = atof(row[2]); + entry.mana = atof(row[3]); + entry.end = atof(row[4]); + entry.unk1 = atof(row[5]); + entry.unk2 = atof(row[6]); + entry.hp_fac = atof(row[7]); + entry.mana_fac = atof(row[8]); + entry.end_fac = atof(row[9]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/blocked_spells_repository.h b/common/repositories/blocked_spells_repository.h index 1a9820183..c4eba3581 100644 --- a/common/repositories/blocked_spells_repository.h +++ b/common/repositories/blocked_spells_repository.h @@ -203,12 +203,12 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(blocked_spells_entry.spellid)); update_values.push_back(columns[2] + " = " + std::to_string(blocked_spells_entry.type)); update_values.push_back(columns[3] + " = " + std::to_string(blocked_spells_entry.zoneid)); - update_values.push_back(columns[4] + " = '" + EscapeString(blocked_spells_entry.x) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(blocked_spells_entry.y) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(blocked_spells_entry.z) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(blocked_spells_entry.x_diff) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(blocked_spells_entry.y_diff) + "'"); - update_values.push_back(columns[9] + " = '" + EscapeString(blocked_spells_entry.z_diff) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(blocked_spells_entry.x)); + update_values.push_back(columns[5] + " = " + std::to_string(blocked_spells_entry.y)); + update_values.push_back(columns[6] + " = " + std::to_string(blocked_spells_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(blocked_spells_entry.x_diff)); + update_values.push_back(columns[8] + " = " + std::to_string(blocked_spells_entry.y_diff)); + update_values.push_back(columns[9] + " = " + std::to_string(blocked_spells_entry.z_diff)); update_values.push_back(columns[10] + " = '" + EscapeString(blocked_spells_entry.message) + "'"); update_values.push_back(columns[11] + " = '" + EscapeString(blocked_spells_entry.description) + "'"); @@ -234,12 +234,12 @@ public: insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); insert_values.push_back(std::to_string(blocked_spells_entry.type)); insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.x_diff) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.y_diff) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.z_diff) + "'"); + insert_values.push_back(std::to_string(blocked_spells_entry.x)); + insert_values.push_back(std::to_string(blocked_spells_entry.y)); + insert_values.push_back(std::to_string(blocked_spells_entry.z)); + insert_values.push_back(std::to_string(blocked_spells_entry.x_diff)); + insert_values.push_back(std::to_string(blocked_spells_entry.y_diff)); + insert_values.push_back(std::to_string(blocked_spells_entry.z_diff)); insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'"); insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'"); @@ -256,7 +256,7 @@ public: return blocked_spells_entry; } - blocked_spells_entry = InstanceListRepository::NewEntity(); + blocked_spells_entry = BlockedSpellsRepository::NewEntity(); return blocked_spells_entry; } @@ -273,12 +273,12 @@ public: insert_values.push_back(std::to_string(blocked_spells_entry.spellid)); insert_values.push_back(std::to_string(blocked_spells_entry.type)); insert_values.push_back(std::to_string(blocked_spells_entry.zoneid)); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.x_diff) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.y_diff) + "'"); - insert_values.push_back("'" + EscapeString(blocked_spells_entry.z_diff) + "'"); + insert_values.push_back(std::to_string(blocked_spells_entry.x)); + insert_values.push_back(std::to_string(blocked_spells_entry.y)); + insert_values.push_back(std::to_string(blocked_spells_entry.z)); + insert_values.push_back(std::to_string(blocked_spells_entry.x_diff)); + insert_values.push_back(std::to_string(blocked_spells_entry.y_diff)); + insert_values.push_back(std::to_string(blocked_spells_entry.z_diff)); insert_values.push_back("'" + EscapeString(blocked_spells_entry.message) + "'"); insert_values.push_back("'" + EscapeString(blocked_spells_entry.description) + "'"); @@ -333,6 +333,56 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + BlockedSpells entry{}; + + entry.id = atoi(row[0]); + entry.spellid = atoi(row[1]); + entry.type = atoi(row[2]); + entry.zoneid = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.x_diff = atof(row[7]); + entry.y_diff = atof(row[8]); + entry.z_diff = atof(row[9]); + entry.message = row[10]; + entry.description = row[11]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BLOCKED_SPELLS_REPOSITORY_H diff --git a/common/repositories/books_repository.h b/common/repositories/books_repository.h index bd2404aff..7baa6ef7c 100644 --- a/common/repositories/books_repository.h +++ b/common/repositories/books_repository.h @@ -202,7 +202,7 @@ public: return books_entry; } - books_entry = InstanceListRepository::NewEntity(); + books_entry = BooksRepository::NewEntity(); return books_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Books entry{}; + + entry.name = row[0]; + entry.txtfile = row[1]; + entry.language = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BOOKS_REPOSITORY_H diff --git a/common/repositories/bug_reports_repository.h b/common/repositories/bug_reports_repository.h index 56ab6a7f7..f58d2e121 100644 --- a/common/repositories/bug_reports_repository.h +++ b/common/repositories/bug_reports_repository.h @@ -291,9 +291,9 @@ public: update_values.push_back(columns[9] + " = '" + EscapeString(bug_reports_entry.category_name) + "'"); update_values.push_back(columns[10] + " = '" + EscapeString(bug_reports_entry.reporter_name) + "'"); update_values.push_back(columns[11] + " = '" + EscapeString(bug_reports_entry.ui_path) + "'"); - update_values.push_back(columns[12] + " = '" + EscapeString(bug_reports_entry.pos_x) + "'"); - update_values.push_back(columns[13] + " = '" + EscapeString(bug_reports_entry.pos_y) + "'"); - update_values.push_back(columns[14] + " = '" + EscapeString(bug_reports_entry.pos_z) + "'"); + update_values.push_back(columns[12] + " = " + std::to_string(bug_reports_entry.pos_x)); + update_values.push_back(columns[13] + " = " + std::to_string(bug_reports_entry.pos_y)); + update_values.push_back(columns[14] + " = " + std::to_string(bug_reports_entry.pos_z)); update_values.push_back(columns[15] + " = " + std::to_string(bug_reports_entry.heading)); update_values.push_back(columns[16] + " = " + std::to_string(bug_reports_entry.time_played)); update_values.push_back(columns[17] + " = " + std::to_string(bug_reports_entry.target_id)); @@ -342,9 +342,9 @@ public: insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_x) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_y) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_z) + "'"); + insert_values.push_back(std::to_string(bug_reports_entry.pos_x)); + insert_values.push_back(std::to_string(bug_reports_entry.pos_y)); + insert_values.push_back(std::to_string(bug_reports_entry.pos_z)); insert_values.push_back(std::to_string(bug_reports_entry.heading)); insert_values.push_back(std::to_string(bug_reports_entry.time_played)); insert_values.push_back(std::to_string(bug_reports_entry.target_id)); @@ -376,7 +376,7 @@ public: return bug_reports_entry; } - bug_reports_entry = InstanceListRepository::NewEntity(); + bug_reports_entry = BugReportsRepository::NewEntity(); return bug_reports_entry; } @@ -401,9 +401,9 @@ public: insert_values.push_back("'" + EscapeString(bug_reports_entry.category_name) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.reporter_name) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.ui_path) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_x) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_y) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.pos_z) + "'"); + insert_values.push_back(std::to_string(bug_reports_entry.pos_x)); + insert_values.push_back(std::to_string(bug_reports_entry.pos_y)); + insert_values.push_back(std::to_string(bug_reports_entry.pos_z)); insert_values.push_back(std::to_string(bug_reports_entry.heading)); insert_values.push_back(std::to_string(bug_reports_entry.time_played)); insert_values.push_back(std::to_string(bug_reports_entry.target_id)); @@ -493,6 +493,76 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + BugReports entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.client_version_id = atoi(row[2]); + entry.client_version_name = row[3]; + entry.account_id = atoi(row[4]); + entry.character_id = atoi(row[5]); + entry.character_name = row[6]; + entry.reporter_spoof = atoi(row[7]); + entry.category_id = atoi(row[8]); + entry.category_name = row[9]; + entry.reporter_name = row[10]; + entry.ui_path = row[11]; + entry.pos_x = atof(row[12]); + entry.pos_y = atof(row[13]); + entry.pos_z = atof(row[14]); + entry.heading = atoi(row[15]); + entry.time_played = atoi(row[16]); + entry.target_id = atoi(row[17]); + entry.target_name = row[18]; + entry.optional_info_mask = atoi(row[19]); + entry._can_duplicate = atoi(row[20]); + entry._crash_bug = atoi(row[21]); + entry._target_info = atoi(row[22]); + entry._character_flags = atoi(row[23]); + entry._unknown_value = atoi(row[24]); + entry.bug_report = row[25]; + entry.system_info = row[26]; + entry.report_datetime = row[27]; + entry.bug_status = atoi(row[28]); + entry.last_review = row[29]; + entry.last_reviewer = row[30]; + entry.reviewer_notes = row[31]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BUG_REPORTS_REPOSITORY_H diff --git a/common/repositories/bugs_repository.h b/common/repositories/bugs_repository.h index 1ab30e9a1..85ebb2852 100644 --- a/common/repositories/bugs_repository.h +++ b/common/repositories/bugs_repository.h @@ -207,9 +207,9 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(bugs_entry.zone) + "'"); update_values.push_back(columns[2] + " = '" + EscapeString(bugs_entry.name) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(bugs_entry.ui) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(bugs_entry.x) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(bugs_entry.y) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(bugs_entry.z) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(bugs_entry.x)); + update_values.push_back(columns[5] + " = " + std::to_string(bugs_entry.y)); + update_values.push_back(columns[6] + " = " + std::to_string(bugs_entry.z)); update_values.push_back(columns[7] + " = '" + EscapeString(bugs_entry.type) + "'"); update_values.push_back(columns[8] + " = " + std::to_string(bugs_entry.flag)); update_values.push_back(columns[9] + " = '" + EscapeString(bugs_entry.target) + "'"); @@ -239,9 +239,9 @@ public: insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.z) + "'"); + insert_values.push_back(std::to_string(bugs_entry.x)); + insert_values.push_back(std::to_string(bugs_entry.y)); + insert_values.push_back(std::to_string(bugs_entry.z)); insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'"); insert_values.push_back(std::to_string(bugs_entry.flag)); insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'"); @@ -262,7 +262,7 @@ public: return bugs_entry; } - bugs_entry = InstanceListRepository::NewEntity(); + bugs_entry = BugsRepository::NewEntity(); return bugs_entry; } @@ -279,9 +279,9 @@ public: insert_values.push_back("'" + EscapeString(bugs_entry.zone) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.name) + "'"); insert_values.push_back("'" + EscapeString(bugs_entry.ui) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(bugs_entry.z) + "'"); + insert_values.push_back(std::to_string(bugs_entry.x)); + insert_values.push_back(std::to_string(bugs_entry.y)); + insert_values.push_back(std::to_string(bugs_entry.z)); insert_values.push_back("'" + EscapeString(bugs_entry.type) + "'"); insert_values.push_back(std::to_string(bugs_entry.flag)); insert_values.push_back("'" + EscapeString(bugs_entry.target) + "'"); @@ -341,6 +341,57 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Bugs entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.name = row[2]; + entry.ui = row[3]; + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.type = row[7]; + entry.flag = atoi(row[8]); + entry.target = row[9]; + entry.bug = row[10]; + entry.date = row[11]; + entry.status = atoi(row[12]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BUGS_REPOSITORY_H diff --git a/common/repositories/buyer_repository.h b/common/repositories/buyer_repository.h index 03f3a8946..3c3d85d9b 100644 --- a/common/repositories/buyer_repository.h +++ b/common/repositories/buyer_repository.h @@ -218,7 +218,7 @@ public: return buyer_entry; } - buyer_entry = InstanceListRepository::NewEntity(); + buyer_entry = BuyerRepository::NewEntity(); return buyer_entry; } @@ -282,6 +282,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Buyer entry{}; + + entry.charid = atoi(row[0]); + entry.buyslot = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.itemname = row[3]; + entry.quantity = atoi(row[4]); + entry.price = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BUYER_REPOSITORY_H diff --git a/common/repositories/char_create_combinations_repository.h b/common/repositories/char_create_combinations_repository.h index 3c4baf5d5..6d7a5eb24 100644 --- a/common/repositories/char_create_combinations_repository.h +++ b/common/repositories/char_create_combinations_repository.h @@ -214,7 +214,7 @@ public: return char_create_combinations_entry; } - char_create_combinations_entry = InstanceListRepository::NewEntity(); + char_create_combinations_entry = CharCreateCombinationsRepository::NewEntity(); return char_create_combinations_entry; } @@ -276,6 +276,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharCreateCombinations entry{}; + + entry.allocation_id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deity = atoi(row[3]); + entry.start_zone = atoi(row[4]); + entry.expansions_req = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHAR_CREATE_COMBINATIONS_REPOSITORY_H diff --git a/common/repositories/char_create_point_allocations_repository.h b/common/repositories/char_create_point_allocations_repository.h index 22ec0a4ea..98889b6bd 100644 --- a/common/repositories/char_create_point_allocations_repository.h +++ b/common/repositories/char_create_point_allocations_repository.h @@ -274,7 +274,7 @@ public: return char_create_point_allocations_entry; } - char_create_point_allocations_entry = InstanceListRepository::NewEntity(); + char_create_point_allocations_entry = CharCreatePointAllocationsRepository::NewEntity(); return char_create_point_allocations_entry; } @@ -357,6 +357,59 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharCreatePointAllocations entry{}; + + entry.id = atoi(row[0]); + entry.base_str = atoi(row[1]); + entry.base_sta = atoi(row[2]); + entry.base_dex = atoi(row[3]); + entry.base_agi = atoi(row[4]); + entry.base_int = atoi(row[5]); + entry.base_wis = atoi(row[6]); + entry.base_cha = atoi(row[7]); + entry.alloc_str = atoi(row[8]); + entry.alloc_sta = atoi(row[9]); + entry.alloc_dex = atoi(row[10]); + entry.alloc_agi = atoi(row[11]); + entry.alloc_int = atoi(row[12]); + entry.alloc_wis = atoi(row[13]); + entry.alloc_cha = atoi(row[14]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHAR_CREATE_POINT_ALLOCATIONS_REPOSITORY_H diff --git a/common/repositories/char_recipe_list_repository.h b/common/repositories/char_recipe_list_repository.h index a4f0c2a92..217ab1052 100644 --- a/common/repositories/char_recipe_list_repository.h +++ b/common/repositories/char_recipe_list_repository.h @@ -200,7 +200,7 @@ public: return char_recipe_list_entry; } - char_recipe_list_entry = InstanceListRepository::NewEntity(); + char_recipe_list_entry = CharRecipeListRepository::NewEntity(); return char_recipe_list_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharRecipeList entry{}; + + entry.char_id = atoi(row[0]); + entry.recipe_id = atoi(row[1]); + entry.madecount = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHAR_RECIPE_LIST_REPOSITORY_H diff --git a/common/repositories/character_activities_repository.h b/common/repositories/character_activities_repository.h index 4682b655c..ce6ee6d82 100644 --- a/common/repositories/character_activities_repository.h +++ b/common/repositories/character_activities_repository.h @@ -210,7 +210,7 @@ public: return character_activities_entry; } - character_activities_entry = InstanceListRepository::NewEntity(); + character_activities_entry = CharacterActivitiesRepository::NewEntity(); return character_activities_entry; } @@ -271,6 +271,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterActivities entry{}; + + entry.charid = atoi(row[0]); + entry.taskid = atoi(row[1]); + entry.activityid = atoi(row[2]); + entry.donecount = atoi(row[3]); + entry.completed = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/character_alt_currency_repository.h b/common/repositories/character_alt_currency_repository.h index 2f815ef98..cc7c8205d 100644 --- a/common/repositories/character_alt_currency_repository.h +++ b/common/repositories/character_alt_currency_repository.h @@ -200,7 +200,7 @@ public: return character_alt_currency_entry; } - character_alt_currency_entry = InstanceListRepository::NewEntity(); + character_alt_currency_entry = CharacterAltCurrencyRepository::NewEntity(); return character_alt_currency_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterAltCurrency entry{}; + + entry.char_id = atoi(row[0]); + entry.currency_id = atoi(row[1]); + entry.amount = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_ALT_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_alternate_abilities_repository.h b/common/repositories/character_alternate_abilities_repository.h index 7866330ac..b91a1572f 100644 --- a/common/repositories/character_alternate_abilities_repository.h +++ b/common/repositories/character_alternate_abilities_repository.h @@ -206,7 +206,7 @@ public: return character_alternate_abilities_entry; } - character_alternate_abilities_entry = InstanceListRepository::NewEntity(); + character_alternate_abilities_entry = CharacterAlternateAbilitiesRepository::NewEntity(); return character_alternate_abilities_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterAlternateAbilities entry{}; + + entry.id = atoi(row[0]); + entry.aa_id = atoi(row[1]); + entry.aa_value = atoi(row[2]); + entry.charges = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_ALTERNATE_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_auras_repository.h b/common/repositories/character_auras_repository.h index 47be33f4c..7a32f2ab4 100644 --- a/common/repositories/character_auras_repository.h +++ b/common/repositories/character_auras_repository.h @@ -200,7 +200,7 @@ public: return character_auras_entry; } - character_auras_entry = InstanceListRepository::NewEntity(); + character_auras_entry = CharacterAurasRepository::NewEntity(); return character_auras_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterAuras entry{}; + + entry.id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.spell_id = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_AURAS_REPOSITORY_H diff --git a/common/repositories/character_bandolier_repository.h b/common/repositories/character_bandolier_repository.h index f9d9ba240..138882959 100644 --- a/common/repositories/character_bandolier_repository.h +++ b/common/repositories/character_bandolier_repository.h @@ -216,7 +216,7 @@ public: return character_bandolier_entry; } - character_bandolier_entry = InstanceListRepository::NewEntity(); + character_bandolier_entry = CharacterBandolierRepository::NewEntity(); return character_bandolier_entry; } @@ -279,6 +279,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterBandolier entry{}; + + entry.id = atoi(row[0]); + entry.bandolier_id = atoi(row[1]); + entry.bandolier_slot = atoi(row[2]); + entry.item_id = atoi(row[3]); + entry.icon = atoi(row[4]); + entry.bandolier_name = row[5]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_BANDOLIER_REPOSITORY_H diff --git a/common/repositories/character_bind_repository.h b/common/repositories/character_bind_repository.h index 10b868cea..fd51b54a4 100644 --- a/common/repositories/character_bind_repository.h +++ b/common/repositories/character_bind_repository.h @@ -186,10 +186,10 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(character_bind_entry.zone_id)); update_values.push_back(columns[3] + " = " + std::to_string(character_bind_entry.instance_id)); - update_values.push_back(columns[4] + " = '" + EscapeString(character_bind_entry.x) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(character_bind_entry.y) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(character_bind_entry.z) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(character_bind_entry.heading) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(character_bind_entry.x)); + update_values.push_back(columns[5] + " = " + std::to_string(character_bind_entry.y)); + update_values.push_back(columns[6] + " = " + std::to_string(character_bind_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(character_bind_entry.heading)); auto results = database.QueryDatabase( fmt::format( @@ -212,10 +212,10 @@ public: insert_values.push_back(std::to_string(character_bind_entry.zone_id)); insert_values.push_back(std::to_string(character_bind_entry.instance_id)); - insert_values.push_back("'" + EscapeString(character_bind_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_bind_entry.x)); + insert_values.push_back(std::to_string(character_bind_entry.y)); + insert_values.push_back(std::to_string(character_bind_entry.z)); + insert_values.push_back(std::to_string(character_bind_entry.heading)); auto results = database.QueryDatabase( fmt::format( @@ -230,7 +230,7 @@ public: return character_bind_entry; } - character_bind_entry = InstanceListRepository::NewEntity(); + character_bind_entry = CharacterBindRepository::NewEntity(); return character_bind_entry; } @@ -246,10 +246,10 @@ public: insert_values.push_back(std::to_string(character_bind_entry.zone_id)); insert_values.push_back(std::to_string(character_bind_entry.instance_id)); - insert_values.push_back("'" + EscapeString(character_bind_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_bind_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_bind_entry.x)); + insert_values.push_back(std::to_string(character_bind_entry.y)); + insert_values.push_back(std::to_string(character_bind_entry.z)); + insert_values.push_back(std::to_string(character_bind_entry.heading)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -298,6 +298,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterBind entry{}; + + entry.id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.zone_id = atoi(row[2]); + entry.instance_id = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_BIND_REPOSITORY_H diff --git a/common/repositories/character_buffs_repository.h b/common/repositories/character_buffs_repository.h index d90ae8d13..cebad8ad6 100644 --- a/common/repositories/character_buffs_repository.h +++ b/common/repositories/character_buffs_repository.h @@ -284,7 +284,7 @@ public: return character_buffs_entry; } - character_buffs_entry = InstanceListRepository::NewEntity(); + character_buffs_entry = CharacterBuffsRepository::NewEntity(); return character_buffs_entry; } @@ -370,6 +370,61 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterBuffs entry{}; + + entry.character_id = atoi(row[0]); + entry.slot_id = atoi(row[1]); + entry.spell_id = atoi(row[2]); + entry.caster_level = atoi(row[3]); + entry.caster_name = row[4]; + entry.ticsremaining = atoi(row[5]); + entry.counters = atoi(row[6]); + entry.numhits = atoi(row[7]); + entry.melee_rune = atoi(row[8]); + entry.magic_rune = atoi(row[9]); + entry.persistent = atoi(row[10]); + entry.dot_rune = atoi(row[11]); + entry.caston_x = atoi(row[12]); + entry.caston_y = atoi(row[13]); + entry.caston_z = atoi(row[14]); + entry.ExtraDIChance = atoi(row[15]); + entry.instrument_mod = atoi(row[16]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_corpse_items_repository.h b/common/repositories/character_corpse_items_repository.h index 862dfa1d7..6f26f1df4 100644 --- a/common/repositories/character_corpse_items_repository.h +++ b/common/repositories/character_corpse_items_repository.h @@ -248,7 +248,7 @@ public: return character_corpse_items_entry; } - character_corpse_items_entry = InstanceListRepository::NewEntity(); + character_corpse_items_entry = CharacterCorpseItemsRepository::NewEntity(); return character_corpse_items_entry; } @@ -322,6 +322,55 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterCorpseItems entry{}; + + entry.corpse_id = atoi(row[0]); + entry.equip_slot = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.aug_1 = atoi(row[4]); + entry.aug_2 = atoi(row[5]); + entry.aug_3 = atoi(row[6]); + entry.aug_4 = atoi(row[7]); + entry.aug_5 = atoi(row[8]); + entry.aug_6 = atoi(row[9]); + entry.attuned = atoi(row[10]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_CORPSE_ITEMS_REPOSITORY_H diff --git a/common/repositories/character_corpses_repository.h b/common/repositories/character_corpses_repository.h index d2fcee9fc..7ba5f98e8 100644 --- a/common/repositories/character_corpses_repository.h +++ b/common/repositories/character_corpses_repository.h @@ -344,10 +344,10 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(character_corpses_entry.charname) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(character_corpses_entry.zone_id)); update_values.push_back(columns[4] + " = " + std::to_string(character_corpses_entry.instance_id)); - update_values.push_back(columns[5] + " = '" + EscapeString(character_corpses_entry.x) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(character_corpses_entry.y) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(character_corpses_entry.z) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(character_corpses_entry.heading) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(character_corpses_entry.x)); + update_values.push_back(columns[6] + " = " + std::to_string(character_corpses_entry.y)); + update_values.push_back(columns[7] + " = " + std::to_string(character_corpses_entry.z)); + update_values.push_back(columns[8] + " = " + std::to_string(character_corpses_entry.heading)); update_values.push_back(columns[9] + " = '" + EscapeString(character_corpses_entry.time_of_death) + "'"); update_values.push_back(columns[10] + " = " + std::to_string(character_corpses_entry.guild_consent_id)); update_values.push_back(columns[11] + " = " + std::to_string(character_corpses_entry.is_rezzed)); @@ -410,10 +410,10 @@ public: insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); insert_values.push_back(std::to_string(character_corpses_entry.instance_id)); - insert_values.push_back("'" + EscapeString(character_corpses_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_corpses_entry.x)); + insert_values.push_back(std::to_string(character_corpses_entry.y)); + insert_values.push_back(std::to_string(character_corpses_entry.z)); + insert_values.push_back(std::to_string(character_corpses_entry.heading)); insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id)); insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed)); @@ -466,7 +466,7 @@ public: return character_corpses_entry; } - character_corpses_entry = InstanceListRepository::NewEntity(); + character_corpses_entry = CharacterCorpsesRepository::NewEntity(); return character_corpses_entry; } @@ -484,10 +484,10 @@ public: insert_values.push_back("'" + EscapeString(character_corpses_entry.charname) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.zone_id)); insert_values.push_back(std::to_string(character_corpses_entry.instance_id)); - insert_values.push_back("'" + EscapeString(character_corpses_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_corpses_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_corpses_entry.x)); + insert_values.push_back(std::to_string(character_corpses_entry.y)); + insert_values.push_back(std::to_string(character_corpses_entry.z)); + insert_values.push_back(std::to_string(character_corpses_entry.heading)); insert_values.push_back("'" + EscapeString(character_corpses_entry.time_of_death) + "'"); insert_values.push_back(std::to_string(character_corpses_entry.guild_consent_id)); insert_values.push_back(std::to_string(character_corpses_entry.is_rezzed)); @@ -613,6 +613,91 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterCorpses entry{}; + + entry.id = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.charname = row[2]; + entry.zone_id = atoi(row[3]); + entry.instance_id = atoi(row[4]); + entry.x = atof(row[5]); + entry.y = atof(row[6]); + entry.z = atof(row[7]); + entry.heading = atof(row[8]); + entry.time_of_death = row[9]; + entry.guild_consent_id = atoi(row[10]); + entry.is_rezzed = atoi(row[11]); + entry.is_buried = atoi(row[12]); + entry.was_at_graveyard = atoi(row[13]); + entry.is_locked = atoi(row[14]); + entry.exp = atoi(row[15]); + entry.size = atoi(row[16]); + entry.level = atoi(row[17]); + entry.race = atoi(row[18]); + entry.gender = atoi(row[19]); + entry.class = atoi(row[20]); + entry.deity = atoi(row[21]); + entry.texture = atoi(row[22]); + entry.helm_texture = atoi(row[23]); + entry.copper = atoi(row[24]); + entry.silver = atoi(row[25]); + entry.gold = atoi(row[26]); + entry.platinum = atoi(row[27]); + entry.hair_color = atoi(row[28]); + entry.beard_color = atoi(row[29]); + entry.eye_color_1 = atoi(row[30]); + entry.eye_color_2 = atoi(row[31]); + entry.hair_style = atoi(row[32]); + entry.face = atoi(row[33]); + entry.beard = atoi(row[34]); + entry.drakkin_heritage = atoi(row[35]); + entry.drakkin_tattoo = atoi(row[36]); + entry.drakkin_details = atoi(row[37]); + entry.wc_1 = atoi(row[38]); + entry.wc_2 = atoi(row[39]); + entry.wc_3 = atoi(row[40]); + entry.wc_4 = atoi(row[41]); + entry.wc_5 = atoi(row[42]); + entry.wc_6 = atoi(row[43]); + entry.wc_7 = atoi(row[44]); + entry.wc_8 = atoi(row[45]); + entry.wc_9 = atoi(row[46]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_CORPSES_REPOSITORY_H diff --git a/common/repositories/character_currency_repository.h b/common/repositories/character_currency_repository.h index caed4ec5b..934912a2f 100644 --- a/common/repositories/character_currency_repository.h +++ b/common/repositories/character_currency_repository.h @@ -286,7 +286,7 @@ public: return character_currency_entry; } - character_currency_entry = InstanceListRepository::NewEntity(); + character_currency_entry = CharacterCurrencyRepository::NewEntity(); return character_currency_entry; } @@ -373,6 +373,61 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterCurrency entry{}; + + entry.id = atoi(row[0]); + entry.platinum = atoi(row[1]); + entry.gold = atoi(row[2]); + entry.silver = atoi(row[3]); + entry.copper = atoi(row[4]); + entry.platinum_bank = atoi(row[5]); + entry.gold_bank = atoi(row[6]); + entry.silver_bank = atoi(row[7]); + entry.copper_bank = atoi(row[8]); + entry.platinum_cursor = atoi(row[9]); + entry.gold_cursor = atoi(row[10]); + entry.silver_cursor = atoi(row[11]); + entry.copper_cursor = atoi(row[12]); + entry.radiant_crystals = atoi(row[13]); + entry.career_radiant_crystals = atoi(row[14]); + entry.ebon_crystals = atoi(row[15]); + entry.career_ebon_crystals = atoi(row[16]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_CURRENCY_REPOSITORY_H diff --git a/common/repositories/character_data_repository.h b/common/repositories/character_data_repository.h index 2d89c157b..605524bf5 100644 --- a/common/repositories/character_data_repository.h +++ b/common/repositories/character_data_repository.h @@ -567,10 +567,10 @@ public: update_values.push_back(columns[5] + " = '" + EscapeString(character_data_entry.suffix) + "'"); update_values.push_back(columns[6] + " = " + std::to_string(character_data_entry.zone_id)); update_values.push_back(columns[7] + " = " + std::to_string(character_data_entry.zone_instance)); - update_values.push_back(columns[8] + " = '" + EscapeString(character_data_entry.y) + "'"); - update_values.push_back(columns[9] + " = '" + EscapeString(character_data_entry.x) + "'"); - update_values.push_back(columns[10] + " = '" + EscapeString(character_data_entry.z) + "'"); - update_values.push_back(columns[11] + " = '" + EscapeString(character_data_entry.heading) + "'"); + update_values.push_back(columns[8] + " = " + std::to_string(character_data_entry.y)); + update_values.push_back(columns[9] + " = " + std::to_string(character_data_entry.x)); + update_values.push_back(columns[10] + " = " + std::to_string(character_data_entry.z)); + update_values.push_back(columns[11] + " = " + std::to_string(character_data_entry.heading)); update_values.push_back(columns[12] + " = " + std::to_string(character_data_entry.gender)); update_values.push_back(columns[13] + " = " + std::to_string(character_data_entry.race)); update_values.push_back(columns[14] + " = " + std::to_string(character_data_entry.class)); @@ -688,10 +688,10 @@ public: insert_values.push_back("'" + EscapeString(character_data_entry.suffix) + "'"); insert_values.push_back(std::to_string(character_data_entry.zone_id)); insert_values.push_back(std::to_string(character_data_entry.zone_instance)); - insert_values.push_back("'" + EscapeString(character_data_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_data_entry.y)); + insert_values.push_back(std::to_string(character_data_entry.x)); + insert_values.push_back(std::to_string(character_data_entry.z)); + insert_values.push_back(std::to_string(character_data_entry.heading)); insert_values.push_back(std::to_string(character_data_entry.gender)); insert_values.push_back(std::to_string(character_data_entry.race)); insert_values.push_back(std::to_string(character_data_entry.class)); @@ -796,7 +796,7 @@ public: return character_data_entry; } - character_data_entry = InstanceListRepository::NewEntity(); + character_data_entry = CharacterDataRepository::NewEntity(); return character_data_entry; } @@ -817,10 +817,10 @@ public: insert_values.push_back("'" + EscapeString(character_data_entry.suffix) + "'"); insert_values.push_back(std::to_string(character_data_entry.zone_id)); insert_values.push_back(std::to_string(character_data_entry.zone_instance)); - insert_values.push_back("'" + EscapeString(character_data_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(character_data_entry.heading) + "'"); + insert_values.push_back(std::to_string(character_data_entry.y)); + insert_values.push_back(std::to_string(character_data_entry.x)); + insert_values.push_back(std::to_string(character_data_entry.z)); + insert_values.push_back(std::to_string(character_data_entry.heading)); insert_values.push_back(std::to_string(character_data_entry.gender)); insert_values.push_back(std::to_string(character_data_entry.race)); insert_values.push_back(std::to_string(character_data_entry.class)); @@ -1053,6 +1053,146 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterData entry{}; + + entry.id = atoi(row[0]); + entry.account_id = atoi(row[1]); + entry.name = row[2]; + entry.last_name = row[3]; + entry.title = row[4]; + entry.suffix = row[5]; + entry.zone_id = atoi(row[6]); + entry.zone_instance = atoi(row[7]); + entry.y = atof(row[8]); + entry.x = atof(row[9]); + entry.z = atof(row[10]); + entry.heading = atof(row[11]); + entry.gender = atoi(row[12]); + entry.race = atoi(row[13]); + entry.class = atoi(row[14]); + entry.level = atoi(row[15]); + entry.deity = atoi(row[16]); + entry.birthday = atoi(row[17]); + entry.last_login = atoi(row[18]); + entry.time_played = atoi(row[19]); + entry.level2 = atoi(row[20]); + entry.anon = atoi(row[21]); + entry.gm = atoi(row[22]); + entry.face = atoi(row[23]); + entry.hair_color = atoi(row[24]); + entry.hair_style = atoi(row[25]); + entry.beard = atoi(row[26]); + entry.beard_color = atoi(row[27]); + entry.eye_color_1 = atoi(row[28]); + entry.eye_color_2 = atoi(row[29]); + entry.drakkin_heritage = atoi(row[30]); + entry.drakkin_tattoo = atoi(row[31]); + entry.drakkin_details = atoi(row[32]); + entry.ability_time_seconds = atoi(row[33]); + entry.ability_number = atoi(row[34]); + entry.ability_time_minutes = atoi(row[35]); + entry.ability_time_hours = atoi(row[36]); + entry.exp = atoi(row[37]); + entry.aa_points_spent = atoi(row[38]); + entry.aa_exp = atoi(row[39]); + entry.aa_points = atoi(row[40]); + entry.group_leadership_exp = atoi(row[41]); + entry.raid_leadership_exp = atoi(row[42]); + entry.group_leadership_points = atoi(row[43]); + entry.raid_leadership_points = atoi(row[44]); + entry.points = atoi(row[45]); + entry.cur_hp = atoi(row[46]); + entry.mana = atoi(row[47]); + entry.endurance = atoi(row[48]); + entry.intoxication = atoi(row[49]); + entry.str = atoi(row[50]); + entry.sta = atoi(row[51]); + entry.cha = atoi(row[52]); + entry.dex = atoi(row[53]); + entry.int = atoi(row[54]); + entry.agi = atoi(row[55]); + entry.wis = atoi(row[56]); + entry.zone_change_count = atoi(row[57]); + entry.toxicity = atoi(row[58]); + entry.hunger_level = atoi(row[59]); + entry.thirst_level = atoi(row[60]); + entry.ability_up = atoi(row[61]); + entry.ldon_points_guk = atoi(row[62]); + entry.ldon_points_mir = atoi(row[63]); + entry.ldon_points_mmc = atoi(row[64]); + entry.ldon_points_ruj = atoi(row[65]); + entry.ldon_points_tak = atoi(row[66]); + entry.ldon_points_available = atoi(row[67]); + entry.tribute_time_remaining = atoi(row[68]); + entry.career_tribute_points = atoi(row[69]); + entry.tribute_points = atoi(row[70]); + entry.tribute_active = atoi(row[71]); + entry.pvp_status = atoi(row[72]); + entry.pvp_kills = atoi(row[73]); + entry.pvp_deaths = atoi(row[74]); + entry.pvp_current_points = atoi(row[75]); + entry.pvp_career_points = atoi(row[76]); + entry.pvp_best_kill_streak = atoi(row[77]); + entry.pvp_worst_death_streak = atoi(row[78]); + entry.pvp_current_kill_streak = atoi(row[79]); + entry.pvp2 = atoi(row[80]); + entry.pvp_type = atoi(row[81]); + entry.show_helm = atoi(row[82]); + entry.group_auto_consent = atoi(row[83]); + entry.raid_auto_consent = atoi(row[84]); + entry.guild_auto_consent = atoi(row[85]); + entry.leadership_exp_on = atoi(row[86]); + entry.RestTimer = atoi(row[87]); + entry.air_remaining = atoi(row[88]); + entry.autosplit_enabled = atoi(row[89]); + entry.lfp = atoi(row[90]); + entry.lfg = atoi(row[91]); + entry.mailkey = row[92]; + entry.xtargets = atoi(row[93]); + entry.firstlogon = atoi(row[94]); + entry.e_aa_effects = atoi(row[95]); + entry.e_percent_to_aa = atoi(row[96]); + entry.e_expended_aa_spent = atoi(row[97]); + entry.aa_points_spent_old = atoi(row[98]); + entry.aa_points_old = atoi(row[99]); + entry.e_last_invsnapshot = atoi(row[100]); + entry.deleted_at = row[101]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_DATA_REPOSITORY_H diff --git a/common/repositories/character_disciplines_repository.h b/common/repositories/character_disciplines_repository.h index bcca9c77b..cb6acbae1 100644 --- a/common/repositories/character_disciplines_repository.h +++ b/common/repositories/character_disciplines_repository.h @@ -200,7 +200,7 @@ public: return character_disciplines_entry; } - character_disciplines_entry = InstanceListRepository::NewEntity(); + character_disciplines_entry = CharacterDisciplinesRepository::NewEntity(); return character_disciplines_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterDisciplines entry{}; + + entry.id = atoi(row[0]); + entry.slot_id = atoi(row[1]); + entry.disc_id = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_DISCIPLINES_REPOSITORY_H diff --git a/common/repositories/character_inspect_messages_repository.h b/common/repositories/character_inspect_messages_repository.h index 00cc7389c..4a087e994 100644 --- a/common/repositories/character_inspect_messages_repository.h +++ b/common/repositories/character_inspect_messages_repository.h @@ -196,7 +196,7 @@ public: return character_inspect_messages_entry; } - character_inspect_messages_entry = InstanceListRepository::NewEntity(); + character_inspect_messages_entry = CharacterInspectMessagesRepository::NewEntity(); return character_inspect_messages_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterInspectMessages entry{}; + + entry.id = atoi(row[0]); + entry.inspect_message = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_INSPECT_MESSAGES_REPOSITORY_H diff --git a/common/repositories/character_item_recast_repository.h b/common/repositories/character_item_recast_repository.h index 8c12e46df..da53df165 100644 --- a/common/repositories/character_item_recast_repository.h +++ b/common/repositories/character_item_recast_repository.h @@ -200,7 +200,7 @@ public: return character_item_recast_entry; } - character_item_recast_entry = InstanceListRepository::NewEntity(); + character_item_recast_entry = CharacterItemRecastRepository::NewEntity(); return character_item_recast_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterItemRecast entry{}; + + entry.id = atoi(row[0]); + entry.recast_type = atoi(row[1]); + entry.timestamp = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_ITEM_RECAST_REPOSITORY_H diff --git a/common/repositories/character_languages_repository.h b/common/repositories/character_languages_repository.h index c9598b908..46d01c183 100644 --- a/common/repositories/character_languages_repository.h +++ b/common/repositories/character_languages_repository.h @@ -200,7 +200,7 @@ public: return character_languages_entry; } - character_languages_entry = InstanceListRepository::NewEntity(); + character_languages_entry = CharacterLanguagesRepository::NewEntity(); return character_languages_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterLanguages entry{}; + + entry.id = atoi(row[0]); + entry.lang_id = atoi(row[1]); + entry.value = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_LANGUAGES_REPOSITORY_H diff --git a/common/repositories/character_leadership_abilities_repository.h b/common/repositories/character_leadership_abilities_repository.h index 6a9047662..311ee5ab5 100644 --- a/common/repositories/character_leadership_abilities_repository.h +++ b/common/repositories/character_leadership_abilities_repository.h @@ -200,7 +200,7 @@ public: return character_leadership_abilities_entry; } - character_leadership_abilities_entry = InstanceListRepository::NewEntity(); + character_leadership_abilities_entry = CharacterLeadershipAbilitiesRepository::NewEntity(); return character_leadership_abilities_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterLeadershipAbilities entry{}; + + entry.id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.rank = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_LEADERSHIP_ABILITIES_REPOSITORY_H diff --git a/common/repositories/character_material_repository.h b/common/repositories/character_material_repository.h index 28d244128..179085e8f 100644 --- a/common/repositories/character_material_repository.h +++ b/common/repositories/character_material_repository.h @@ -224,7 +224,7 @@ public: return character_material_entry; } - character_material_entry = InstanceListRepository::NewEntity(); + character_material_entry = CharacterMaterialRepository::NewEntity(); return character_material_entry; } @@ -290,6 +290,51 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterMaterial entry{}; + + entry.id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.blue = atoi(row[2]); + entry.green = atoi(row[3]); + entry.red = atoi(row[4]); + entry.use_tint = atoi(row[5]); + entry.color = atoi(row[6]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_MATERIAL_REPOSITORY_H diff --git a/common/repositories/character_memmed_spells_repository.h b/common/repositories/character_memmed_spells_repository.h index 515096fdf..f2c1d2925 100644 --- a/common/repositories/character_memmed_spells_repository.h +++ b/common/repositories/character_memmed_spells_repository.h @@ -200,7 +200,7 @@ public: return character_memmed_spells_entry; } - character_memmed_spells_entry = InstanceListRepository::NewEntity(); + character_memmed_spells_entry = CharacterMemmedSpellsRepository::NewEntity(); return character_memmed_spells_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterMemmedSpells entry{}; + + entry.id = atoi(row[0]); + entry.slot_id = atoi(row[1]); + entry.spell_id = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_MEMMED_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_pet_buffs_repository.h b/common/repositories/character_pet_buffs_repository.h index cfa6fab9d..b5de59be9 100644 --- a/common/repositories/character_pet_buffs_repository.h +++ b/common/repositories/character_pet_buffs_repository.h @@ -246,7 +246,7 @@ public: return character_pet_buffs_entry; } - character_pet_buffs_entry = InstanceListRepository::NewEntity(); + character_pet_buffs_entry = CharacterPetBuffsRepository::NewEntity(); return character_pet_buffs_entry; } @@ -319,6 +319,55 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterPetBuffs entry{}; + + entry.char_id = atoi(row[0]); + entry.pet = atoi(row[1]); + entry.slot = atoi(row[2]); + entry.spell_id = atoi(row[3]); + entry.caster_level = atoi(row[4]); + entry.castername = row[5]; + entry.ticsremaining = atoi(row[6]); + entry.counters = atoi(row[7]); + entry.numhits = atoi(row[8]); + entry.rune = atoi(row[9]); + entry.instrument_mod = atoi(row[10]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_PET_BUFFS_REPOSITORY_H diff --git a/common/repositories/character_pet_info_repository.h b/common/repositories/character_pet_info_repository.h index 9020ea285..9adb9b628 100644 --- a/common/repositories/character_pet_info_repository.h +++ b/common/repositories/character_pet_info_repository.h @@ -189,7 +189,7 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(character_pet_info_entry.spell_id)); update_values.push_back(columns[5] + " = " + std::to_string(character_pet_info_entry.hp)); update_values.push_back(columns[6] + " = " + std::to_string(character_pet_info_entry.mana)); - update_values.push_back(columns[7] + " = '" + EscapeString(character_pet_info_entry.size) + "'"); + update_values.push_back(columns[7] + " = " + std::to_string(character_pet_info_entry.size)); auto results = database.QueryDatabase( fmt::format( @@ -215,7 +215,7 @@ public: insert_values.push_back(std::to_string(character_pet_info_entry.spell_id)); insert_values.push_back(std::to_string(character_pet_info_entry.hp)); insert_values.push_back(std::to_string(character_pet_info_entry.mana)); - insert_values.push_back("'" + EscapeString(character_pet_info_entry.size) + "'"); + insert_values.push_back(std::to_string(character_pet_info_entry.size)); auto results = database.QueryDatabase( fmt::format( @@ -230,7 +230,7 @@ public: return character_pet_info_entry; } - character_pet_info_entry = InstanceListRepository::NewEntity(); + character_pet_info_entry = CharacterPetInfoRepository::NewEntity(); return character_pet_info_entry; } @@ -249,7 +249,7 @@ public: insert_values.push_back(std::to_string(character_pet_info_entry.spell_id)); insert_values.push_back(std::to_string(character_pet_info_entry.hp)); insert_values.push_back(std::to_string(character_pet_info_entry.mana)); - insert_values.push_back("'" + EscapeString(character_pet_info_entry.size) + "'"); + insert_values.push_back(std::to_string(character_pet_info_entry.size)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -298,6 +298,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterPetInfo entry{}; + + entry.char_id = atoi(row[0]); + entry.pet = atoi(row[1]); + entry.petname = row[2]; + entry.petpower = atoi(row[3]); + entry.spell_id = atoi(row[4]); + entry.hp = atoi(row[5]); + entry.mana = atoi(row[6]); + entry.size = atof(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_PET_INFO_REPOSITORY_H diff --git a/common/repositories/character_pet_inventory_repository.h b/common/repositories/character_pet_inventory_repository.h index 65aab57a7..f75349f42 100644 --- a/common/repositories/character_pet_inventory_repository.h +++ b/common/repositories/character_pet_inventory_repository.h @@ -204,7 +204,7 @@ public: return character_pet_inventory_entry; } - character_pet_inventory_entry = InstanceListRepository::NewEntity(); + character_pet_inventory_entry = CharacterPetInventoryRepository::NewEntity(); return character_pet_inventory_entry; } @@ -263,6 +263,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterPetInventory entry{}; + + entry.char_id = atoi(row[0]); + entry.pet = atoi(row[1]); + entry.slot = atoi(row[2]); + entry.item_id = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_PET_INVENTORY_REPOSITORY_H diff --git a/common/repositories/character_potionbelt_repository.h b/common/repositories/character_potionbelt_repository.h index f90b11f09..7b1039baf 100644 --- a/common/repositories/character_potionbelt_repository.h +++ b/common/repositories/character_potionbelt_repository.h @@ -206,7 +206,7 @@ public: return character_potionbelt_entry; } - character_potionbelt_entry = InstanceListRepository::NewEntity(); + character_potionbelt_entry = CharacterPotionbeltRepository::NewEntity(); return character_potionbelt_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterPotionbelt entry{}; + + entry.id = atoi(row[0]); + entry.potion_id = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.icon = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_POTIONBELT_REPOSITORY_H diff --git a/common/repositories/character_skills_repository.h b/common/repositories/character_skills_repository.h index fa260609e..3983e307b 100644 --- a/common/repositories/character_skills_repository.h +++ b/common/repositories/character_skills_repository.h @@ -200,7 +200,7 @@ public: return character_skills_entry; } - character_skills_entry = InstanceListRepository::NewEntity(); + character_skills_entry = CharacterSkillsRepository::NewEntity(); return character_skills_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterSkills entry{}; + + entry.id = atoi(row[0]); + entry.skill_id = atoi(row[1]); + entry.value = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_SKILLS_REPOSITORY_H diff --git a/common/repositories/character_spells_repository.h b/common/repositories/character_spells_repository.h index eeb745198..61cee3d92 100644 --- a/common/repositories/character_spells_repository.h +++ b/common/repositories/character_spells_repository.h @@ -200,7 +200,7 @@ public: return character_spells_entry; } - character_spells_entry = InstanceListRepository::NewEntity(); + character_spells_entry = CharacterSpellsRepository::NewEntity(); return character_spells_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterSpells entry{}; + + entry.id = atoi(row[0]); + entry.slot_id = atoi(row[1]); + entry.spell_id = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_SPELLS_REPOSITORY_H diff --git a/common/repositories/character_tasks_repository.h b/common/repositories/character_tasks_repository.h index 2e3851415..e145b7712 100644 --- a/common/repositories/character_tasks_repository.h +++ b/common/repositories/character_tasks_repository.h @@ -212,7 +212,7 @@ public: return character_tasks_entry; } - character_tasks_entry = InstanceListRepository::NewEntity(); + character_tasks_entry = CharacterTasksRepository::NewEntity(); return character_tasks_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterTasks entry{}; + + entry.charid = atoi(row[0]); + entry.taskid = atoi(row[1]); + entry.slot = atoi(row[2]); + entry.type = atoi(row[3]); + entry.acceptedtime = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_TASKS_REPOSITORY_H diff --git a/common/repositories/character_tribute_repository.h b/common/repositories/character_tribute_repository.h index ceab9f7b7..7e9ef2015 100644 --- a/common/repositories/character_tribute_repository.h +++ b/common/repositories/character_tribute_repository.h @@ -204,7 +204,7 @@ public: return character_tribute_entry; } - character_tribute_entry = InstanceListRepository::NewEntity(); + character_tribute_entry = CharacterTributeRepository::NewEntity(); return character_tribute_entry; } @@ -264,6 +264,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterTribute entry{}; + + entry.id = atoi(row[0]); + entry.tier = atoi(row[1]); + entry.tribute = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHARACTER_TRIBUTE_REPOSITORY_H diff --git a/common/repositories/chatchannels_repository.h b/common/repositories/chatchannels_repository.h index 6d6ce6f56..302526ecd 100644 --- a/common/repositories/chatchannels_repository.h +++ b/common/repositories/chatchannels_repository.h @@ -208,7 +208,7 @@ public: return chatchannels_entry; } - chatchannels_entry = InstanceListRepository::NewEntity(); + chatchannels_entry = ChatchannelsRepository::NewEntity(); return chatchannels_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Chatchannels entry{}; + + entry.name = row[0]; + entry.owner = row[1]; + entry.password = row[2]; + entry.minstatus = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_CHATCHANNELS_REPOSITORY_H diff --git a/common/repositories/command_settings_repository.h b/common/repositories/command_settings_repository.h index 92914b990..2b9fb3d50 100644 --- a/common/repositories/command_settings_repository.h +++ b/common/repositories/command_settings_repository.h @@ -202,7 +202,7 @@ public: return command_settings_entry; } - command_settings_entry = InstanceListRepository::NewEntity(); + command_settings_entry = CommandSettingsRepository::NewEntity(); return command_settings_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CommandSettings entry{}; + + entry.command = row[0]; + entry.access = atoi(row[1]); + entry.aliases = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_COMMAND_SETTINGS_REPOSITORY_H diff --git a/common/repositories/completed_tasks_repository.h b/common/repositories/completed_tasks_repository.h index f05cd03cc..1d0e5169b 100644 --- a/common/repositories/completed_tasks_repository.h +++ b/common/repositories/completed_tasks_repository.h @@ -204,7 +204,7 @@ public: return completed_tasks_entry; } - completed_tasks_entry = InstanceListRepository::NewEntity(); + completed_tasks_entry = CompletedTasksRepository::NewEntity(); return completed_tasks_entry; } @@ -263,6 +263,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CompletedTasks entry{}; + + entry.charid = atoi(row[0]); + entry.completedtime = atoi(row[1]); + entry.taskid = atoi(row[2]); + entry.activityid = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_COMPLETED_TASKS_REPOSITORY_H diff --git a/common/repositories/data_buckets_repository.h b/common/repositories/data_buckets_repository.h index 226e5449a..950111133 100644 --- a/common/repositories/data_buckets_repository.h +++ b/common/repositories/data_buckets_repository.h @@ -208,7 +208,7 @@ public: return data_buckets_entry; } - data_buckets_entry = InstanceListRepository::NewEntity(); + data_buckets_entry = DataBucketsRepository::NewEntity(); return data_buckets_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + DataBuckets entry{}; + + entry.id = atoi(row[0]); + entry.key = row[1]; + entry.value = row[2]; + entry.expires = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_DATA_BUCKETS_REPOSITORY_H diff --git a/common/repositories/db_str_repository.h b/common/repositories/db_str_repository.h index 6860ab990..fd7d3b8c1 100644 --- a/common/repositories/db_str_repository.h +++ b/common/repositories/db_str_repository.h @@ -200,7 +200,7 @@ public: return db_str_entry; } - db_str_entry = InstanceListRepository::NewEntity(); + db_str_entry = DbStrRepository::NewEntity(); return db_str_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + DbStr entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.value = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_DB_STR_REPOSITORY_H diff --git a/common/repositories/discovered_items_repository.h b/common/repositories/discovered_items_repository.h index 34fe05993..a424c02cd 100644 --- a/common/repositories/discovered_items_repository.h +++ b/common/repositories/discovered_items_repository.h @@ -208,7 +208,7 @@ public: return discovered_items_entry; } - discovered_items_entry = InstanceListRepository::NewEntity(); + discovered_items_entry = DiscoveredItemsRepository::NewEntity(); return discovered_items_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + DiscoveredItems entry{}; + + entry.item_id = atoi(row[0]); + entry.char_name = row[1]; + entry.discovered_date = atoi(row[2]); + entry.account_status = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_DISCOVERED_ITEMS_REPOSITORY_H diff --git a/common/repositories/doors_repository.h b/common/repositories/doors_repository.h index 548ffb7af..34857f08a 100644 --- a/common/repositories/doors_repository.h +++ b/common/repositories/doors_repository.h @@ -280,10 +280,10 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(doors_entry.zone) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(doors_entry.version)); update_values.push_back(columns[4] + " = '" + EscapeString(doors_entry.name) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(doors_entry.pos_y) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(doors_entry.pos_x) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(doors_entry.pos_z) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(doors_entry.heading) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(doors_entry.pos_y)); + update_values.push_back(columns[6] + " = " + std::to_string(doors_entry.pos_x)); + update_values.push_back(columns[7] + " = " + std::to_string(doors_entry.pos_z)); + update_values.push_back(columns[8] + " = " + std::to_string(doors_entry.heading)); update_values.push_back(columns[9] + " = " + std::to_string(doors_entry.opentype)); update_values.push_back(columns[10] + " = " + std::to_string(doors_entry.guild)); update_values.push_back(columns[11] + " = " + std::to_string(doors_entry.lockpick)); @@ -296,14 +296,14 @@ public: update_values.push_back(columns[18] + " = " + std::to_string(doors_entry.door_param)); update_values.push_back(columns[19] + " = '" + EscapeString(doors_entry.dest_zone) + "'"); update_values.push_back(columns[20] + " = " + std::to_string(doors_entry.dest_instance)); - update_values.push_back(columns[21] + " = '" + EscapeString(doors_entry.dest_x) + "'"); - update_values.push_back(columns[22] + " = '" + EscapeString(doors_entry.dest_y) + "'"); - update_values.push_back(columns[23] + " = '" + EscapeString(doors_entry.dest_z) + "'"); - update_values.push_back(columns[24] + " = '" + EscapeString(doors_entry.dest_heading) + "'"); + update_values.push_back(columns[21] + " = " + std::to_string(doors_entry.dest_x)); + update_values.push_back(columns[22] + " = " + std::to_string(doors_entry.dest_y)); + update_values.push_back(columns[23] + " = " + std::to_string(doors_entry.dest_z)); + update_values.push_back(columns[24] + " = " + std::to_string(doors_entry.dest_heading)); update_values.push_back(columns[25] + " = " + std::to_string(doors_entry.invert_state)); update_values.push_back(columns[26] + " = " + std::to_string(doors_entry.incline)); update_values.push_back(columns[27] + " = " + std::to_string(doors_entry.size)); - update_values.push_back(columns[28] + " = '" + EscapeString(doors_entry.buffer) + "'"); + update_values.push_back(columns[28] + " = " + std::to_string(doors_entry.buffer)); update_values.push_back(columns[29] + " = " + std::to_string(doors_entry.client_version_mask)); update_values.push_back(columns[30] + " = " + std::to_string(doors_entry.is_ldon_door)); @@ -330,10 +330,10 @@ public: insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'"); insert_values.push_back(std::to_string(doors_entry.version)); insert_values.push_back("'" + EscapeString(doors_entry.name) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_y) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_x) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_z) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.heading) + "'"); + insert_values.push_back(std::to_string(doors_entry.pos_y)); + insert_values.push_back(std::to_string(doors_entry.pos_x)); + insert_values.push_back(std::to_string(doors_entry.pos_z)); + insert_values.push_back(std::to_string(doors_entry.heading)); insert_values.push_back(std::to_string(doors_entry.opentype)); insert_values.push_back(std::to_string(doors_entry.guild)); insert_values.push_back(std::to_string(doors_entry.lockpick)); @@ -346,14 +346,14 @@ public: insert_values.push_back(std::to_string(doors_entry.door_param)); insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'"); insert_values.push_back(std::to_string(doors_entry.dest_instance)); - insert_values.push_back("'" + EscapeString(doors_entry.dest_x) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_y) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_z) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_heading) + "'"); + insert_values.push_back(std::to_string(doors_entry.dest_x)); + insert_values.push_back(std::to_string(doors_entry.dest_y)); + insert_values.push_back(std::to_string(doors_entry.dest_z)); + insert_values.push_back(std::to_string(doors_entry.dest_heading)); insert_values.push_back(std::to_string(doors_entry.invert_state)); insert_values.push_back(std::to_string(doors_entry.incline)); insert_values.push_back(std::to_string(doors_entry.size)); - insert_values.push_back("'" + EscapeString(doors_entry.buffer) + "'"); + insert_values.push_back(std::to_string(doors_entry.buffer)); insert_values.push_back(std::to_string(doors_entry.client_version_mask)); insert_values.push_back(std::to_string(doors_entry.is_ldon_door)); @@ -370,7 +370,7 @@ public: return doors_entry; } - doors_entry = InstanceListRepository::NewEntity(); + doors_entry = DoorsRepository::NewEntity(); return doors_entry; } @@ -388,10 +388,10 @@ public: insert_values.push_back("'" + EscapeString(doors_entry.zone) + "'"); insert_values.push_back(std::to_string(doors_entry.version)); insert_values.push_back("'" + EscapeString(doors_entry.name) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_y) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_x) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.pos_z) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.heading) + "'"); + insert_values.push_back(std::to_string(doors_entry.pos_y)); + insert_values.push_back(std::to_string(doors_entry.pos_x)); + insert_values.push_back(std::to_string(doors_entry.pos_z)); + insert_values.push_back(std::to_string(doors_entry.heading)); insert_values.push_back(std::to_string(doors_entry.opentype)); insert_values.push_back(std::to_string(doors_entry.guild)); insert_values.push_back(std::to_string(doors_entry.lockpick)); @@ -404,14 +404,14 @@ public: insert_values.push_back(std::to_string(doors_entry.door_param)); insert_values.push_back("'" + EscapeString(doors_entry.dest_zone) + "'"); insert_values.push_back(std::to_string(doors_entry.dest_instance)); - insert_values.push_back("'" + EscapeString(doors_entry.dest_x) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_y) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_z) + "'"); - insert_values.push_back("'" + EscapeString(doors_entry.dest_heading) + "'"); + insert_values.push_back(std::to_string(doors_entry.dest_x)); + insert_values.push_back(std::to_string(doors_entry.dest_y)); + insert_values.push_back(std::to_string(doors_entry.dest_z)); + insert_values.push_back(std::to_string(doors_entry.dest_heading)); insert_values.push_back(std::to_string(doors_entry.invert_state)); insert_values.push_back(std::to_string(doors_entry.incline)); insert_values.push_back(std::to_string(doors_entry.size)); - insert_values.push_back("'" + EscapeString(doors_entry.buffer) + "'"); + insert_values.push_back(std::to_string(doors_entry.buffer)); insert_values.push_back(std::to_string(doors_entry.client_version_mask)); insert_values.push_back(std::to_string(doors_entry.is_ldon_door)); @@ -485,6 +485,75 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Doors entry{}; + + entry.id = atoi(row[0]); + entry.doorid = atoi(row[1]); + entry.zone = row[2]; + entry.version = atoi(row[3]); + entry.name = row[4]; + entry.pos_y = atof(row[5]); + entry.pos_x = atof(row[6]); + entry.pos_z = atof(row[7]); + entry.heading = atof(row[8]); + entry.opentype = atoi(row[9]); + entry.guild = atoi(row[10]); + entry.lockpick = atoi(row[11]); + entry.keyitem = atoi(row[12]); + entry.nokeyring = atoi(row[13]); + entry.triggerdoor = atoi(row[14]); + entry.triggertype = atoi(row[15]); + entry.disable_timer = atoi(row[16]); + entry.doorisopen = atoi(row[17]); + entry.door_param = atoi(row[18]); + entry.dest_zone = row[19]; + entry.dest_instance = atoi(row[20]); + entry.dest_x = atof(row[21]); + entry.dest_y = atof(row[22]); + entry.dest_z = atof(row[23]); + entry.dest_heading = atof(row[24]); + entry.invert_state = atoi(row[25]); + entry.incline = atoi(row[26]); + entry.size = atoi(row[27]); + entry.buffer = atof(row[28]); + entry.client_version_mask = atoi(row[29]); + entry.is_ldon_door = atoi(row[30]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_DOORS_REPOSITORY_H diff --git a/common/repositories/eventlog_repository.h b/common/repositories/eventlog_repository.h index a923dbe2b..5f95682ef 100644 --- a/common/repositories/eventlog_repository.h +++ b/common/repositories/eventlog_repository.h @@ -244,7 +244,7 @@ public: return eventlog_entry; } - eventlog_entry = InstanceListRepository::NewEntity(); + eventlog_entry = EventlogRepository::NewEntity(); return eventlog_entry; } @@ -317,6 +317,54 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Eventlog entry{}; + + entry.id = atoi(row[0]); + entry.accountname = row[1]; + entry.accountid = atoi(row[2]); + entry.status = atoi(row[3]); + entry.charname = row[4]; + entry.target = row[5]; + entry.time = row[6]; + entry.descriptiontype = row[7]; + entry.description = row[8]; + entry.event_nid = atoi(row[9]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_EVENTLOG_REPOSITORY_H diff --git a/common/repositories/faction_base_data_repository.h b/common/repositories/faction_base_data_repository.h index b727df0eb..22e6be2a3 100644 --- a/common/repositories/faction_base_data_repository.h +++ b/common/repositories/faction_base_data_repository.h @@ -220,7 +220,7 @@ public: return faction_base_data_entry; } - faction_base_data_entry = InstanceListRepository::NewEntity(); + faction_base_data_entry = FactionBaseDataRepository::NewEntity(); return faction_base_data_entry; } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + FactionBaseData entry{}; + + entry.client_faction_id = atoi(row[0]); + entry.min = atoi(row[1]); + entry.max = atoi(row[2]); + entry.unk_hero1 = atoi(row[3]); + entry.unk_hero2 = atoi(row[4]); + entry.unk_hero3 = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FACTION_BASE_DATA_REPOSITORY_H diff --git a/common/repositories/faction_list_mod_repository.h b/common/repositories/faction_list_mod_repository.h index 7f98b7fcb..8e1374ce1 100644 --- a/common/repositories/faction_list_mod_repository.h +++ b/common/repositories/faction_list_mod_repository.h @@ -208,7 +208,7 @@ public: return faction_list_mod_entry; } - faction_list_mod_entry = InstanceListRepository::NewEntity(); + faction_list_mod_entry = FactionListModRepository::NewEntity(); return faction_list_mod_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + FactionListMod entry{}; + + entry.id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.mod = atoi(row[2]); + entry.mod_name = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FACTION_LIST_MOD_REPOSITORY_H diff --git a/common/repositories/faction_list_repository.h b/common/repositories/faction_list_repository.h index 772bd10ee..50c141456 100644 --- a/common/repositories/faction_list_repository.h +++ b/common/repositories/faction_list_repository.h @@ -202,7 +202,7 @@ public: return faction_list_entry; } - faction_list_entry = InstanceListRepository::NewEntity(); + faction_list_entry = FactionListRepository::NewEntity(); return faction_list_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + FactionList entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.base = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FACTION_LIST_REPOSITORY_H diff --git a/common/repositories/faction_values_repository.h b/common/repositories/faction_values_repository.h index e21fd249c..4ed0d0449 100644 --- a/common/repositories/faction_values_repository.h +++ b/common/repositories/faction_values_repository.h @@ -206,7 +206,7 @@ public: return faction_values_entry; } - faction_values_entry = InstanceListRepository::NewEntity(); + faction_values_entry = FactionValuesRepository::NewEntity(); return faction_values_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + FactionValues entry{}; + + entry.char_id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.current_value = atoi(row[2]); + entry.temp = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FACTION_VALUES_REPOSITORY_H diff --git a/common/repositories/fishing_repository.h b/common/repositories/fishing_repository.h index 23e92dffc..7d07bc364 100644 --- a/common/repositories/fishing_repository.h +++ b/common/repositories/fishing_repository.h @@ -226,7 +226,7 @@ public: return fishing_entry; } - fishing_entry = InstanceListRepository::NewEntity(); + fishing_entry = FishingRepository::NewEntity(); return fishing_entry; } @@ -293,6 +293,51 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Fishing entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.skill_level = atoi(row[3]); + entry.chance = atoi(row[4]); + entry.npc_id = atoi(row[5]); + entry.npc_chance = atoi(row[6]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FISHING_REPOSITORY_H diff --git a/common/repositories/forage_repository.h b/common/repositories/forage_repository.h index 773a11a84..02f22d0a9 100644 --- a/common/repositories/forage_repository.h +++ b/common/repositories/forage_repository.h @@ -214,7 +214,7 @@ public: return forage_entry; } - forage_entry = InstanceListRepository::NewEntity(); + forage_entry = ForageRepository::NewEntity(); return forage_entry; } @@ -277,6 +277,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Forage entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.Itemid = atoi(row[2]); + entry.level = atoi(row[3]); + entry.chance = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FORAGE_REPOSITORY_H diff --git a/common/repositories/friends_repository.h b/common/repositories/friends_repository.h index 06d0e3cc3..55746a3f2 100644 --- a/common/repositories/friends_repository.h +++ b/common/repositories/friends_repository.h @@ -200,7 +200,7 @@ public: return friends_entry; } - friends_entry = InstanceListRepository::NewEntity(); + friends_entry = FriendsRepository::NewEntity(); return friends_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Friends entry{}; + + entry.charid = atoi(row[0]); + entry.type = atoi(row[1]); + entry.name = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_FRIENDS_REPOSITORY_H diff --git a/common/repositories/global_loot_repository.h b/common/repositories/global_loot_repository.h index b49e44bf9..ad566baf7 100644 --- a/common/repositories/global_loot_repository.h +++ b/common/repositories/global_loot_repository.h @@ -262,7 +262,7 @@ public: return global_loot_entry; } - global_loot_entry = InstanceListRepository::NewEntity(); + global_loot_entry = GlobalLootRepository::NewEntity(); return global_loot_entry; } @@ -341,6 +341,57 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GlobalLoot entry{}; + + entry.id = atoi(row[0]); + entry.description = row[1]; + entry.loottable_id = atoi(row[2]); + entry.enabled = atoi(row[3]); + entry.min_level = atoi(row[4]); + entry.max_level = atoi(row[5]); + entry.rare = atoi(row[6]); + entry.raid = atoi(row[7]); + entry.race = row[8]; + entry.class = row[9]; + entry.bodytype = row[10]; + entry.zone = row[11]; + entry.hot_zone = atoi(row[12]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GLOBAL_LOOT_REPOSITORY_H diff --git a/common/repositories/gm_ips_repository.h b/common/repositories/gm_ips_repository.h index 017f2d289..6c371f26d 100644 --- a/common/repositories/gm_ips_repository.h +++ b/common/repositories/gm_ips_repository.h @@ -200,7 +200,7 @@ public: return gm_ips_entry; } - gm_ips_entry = InstanceListRepository::NewEntity(); + gm_ips_entry = GmIpsRepository::NewEntity(); return gm_ips_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GmIps entry{}; + + entry.name = row[0]; + entry.account_id = atoi(row[1]); + entry.ip_address = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GM_IPS_REPOSITORY_H diff --git a/common/repositories/goallists_repository.h b/common/repositories/goallists_repository.h index 62aed3079..ee59d139f 100644 --- a/common/repositories/goallists_repository.h +++ b/common/repositories/goallists_repository.h @@ -196,7 +196,7 @@ public: return goallists_entry; } - goallists_entry = InstanceListRepository::NewEntity(); + goallists_entry = GoallistsRepository::NewEntity(); return goallists_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Goallists entry{}; + + entry.listid = atoi(row[0]); + entry.entry = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GOALLISTS_REPOSITORY_H diff --git a/common/repositories/graveyard_repository.h b/common/repositories/graveyard_repository.h index 205f5bd4b..7efaee489 100644 --- a/common/repositories/graveyard_repository.h +++ b/common/repositories/graveyard_repository.h @@ -177,10 +177,10 @@ public: auto columns = Columns(); update_values.push_back(columns[1] + " = " + std::to_string(graveyard_entry.zone_id)); - update_values.push_back(columns[2] + " = '" + EscapeString(graveyard_entry.x) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(graveyard_entry.y) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(graveyard_entry.z) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(graveyard_entry.heading) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(graveyard_entry.x)); + update_values.push_back(columns[3] + " = " + std::to_string(graveyard_entry.y)); + update_values.push_back(columns[4] + " = " + std::to_string(graveyard_entry.z)); + update_values.push_back(columns[5] + " = " + std::to_string(graveyard_entry.heading)); auto results = content_db.QueryDatabase( fmt::format( @@ -202,10 +202,10 @@ public: std::vector insert_values; insert_values.push_back(std::to_string(graveyard_entry.zone_id)); - insert_values.push_back("'" + EscapeString(graveyard_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.heading) + "'"); + insert_values.push_back(std::to_string(graveyard_entry.x)); + insert_values.push_back(std::to_string(graveyard_entry.y)); + insert_values.push_back(std::to_string(graveyard_entry.z)); + insert_values.push_back(std::to_string(graveyard_entry.heading)); auto results = content_db.QueryDatabase( fmt::format( @@ -220,7 +220,7 @@ public: return graveyard_entry; } - graveyard_entry = InstanceListRepository::NewEntity(); + graveyard_entry = GraveyardRepository::NewEntity(); return graveyard_entry; } @@ -235,10 +235,10 @@ public: std::vector insert_values; insert_values.push_back(std::to_string(graveyard_entry.zone_id)); - insert_values.push_back("'" + EscapeString(graveyard_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(graveyard_entry.heading) + "'"); + insert_values.push_back(std::to_string(graveyard_entry.x)); + insert_values.push_back(std::to_string(graveyard_entry.y)); + insert_values.push_back(std::to_string(graveyard_entry.z)); + insert_values.push_back(std::to_string(graveyard_entry.heading)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Graveyard entry{}; + + entry.id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.x = atof(row[2]); + entry.y = atof(row[3]); + entry.z = atof(row[4]); + entry.heading = atof(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GRAVEYARD_REPOSITORY_H diff --git a/common/repositories/ground_spawns_repository.h b/common/repositories/ground_spawns_repository.h index ad73d9261..3b2e57674 100644 --- a/common/repositories/ground_spawns_repository.h +++ b/common/repositories/ground_spawns_repository.h @@ -210,12 +210,12 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(ground_spawns_entry.zoneid)); update_values.push_back(columns[2] + " = " + std::to_string(ground_spawns_entry.version)); - update_values.push_back(columns[3] + " = '" + EscapeString(ground_spawns_entry.max_x) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(ground_spawns_entry.max_y) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(ground_spawns_entry.max_z) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(ground_spawns_entry.min_x) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(ground_spawns_entry.min_y) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(ground_spawns_entry.heading) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(ground_spawns_entry.max_x)); + update_values.push_back(columns[4] + " = " + std::to_string(ground_spawns_entry.max_y)); + update_values.push_back(columns[5] + " = " + std::to_string(ground_spawns_entry.max_z)); + update_values.push_back(columns[6] + " = " + std::to_string(ground_spawns_entry.min_x)); + update_values.push_back(columns[7] + " = " + std::to_string(ground_spawns_entry.min_y)); + update_values.push_back(columns[8] + " = " + std::to_string(ground_spawns_entry.heading)); update_values.push_back(columns[9] + " = '" + EscapeString(ground_spawns_entry.name) + "'"); update_values.push_back(columns[10] + " = " + std::to_string(ground_spawns_entry.item)); update_values.push_back(columns[11] + " = " + std::to_string(ground_spawns_entry.max_allowed)); @@ -243,12 +243,12 @@ public: insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); insert_values.push_back(std::to_string(ground_spawns_entry.version)); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_x) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_y) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_z) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.min_x) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.min_y) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.heading) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.heading)); insert_values.push_back("'" + EscapeString(ground_spawns_entry.name) + "'"); insert_values.push_back(std::to_string(ground_spawns_entry.item)); insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); @@ -268,7 +268,7 @@ public: return ground_spawns_entry; } - ground_spawns_entry = InstanceListRepository::NewEntity(); + ground_spawns_entry = GroundSpawnsRepository::NewEntity(); return ground_spawns_entry; } @@ -284,12 +284,12 @@ public: insert_values.push_back(std::to_string(ground_spawns_entry.zoneid)); insert_values.push_back(std::to_string(ground_spawns_entry.version)); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_x) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_y) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.max_z) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.min_x) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.min_y) + "'"); - insert_values.push_back("'" + EscapeString(ground_spawns_entry.heading) + "'"); + insert_values.push_back(std::to_string(ground_spawns_entry.max_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.max_z)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_x)); + insert_values.push_back(std::to_string(ground_spawns_entry.min_y)); + insert_values.push_back(std::to_string(ground_spawns_entry.heading)); insert_values.push_back("'" + EscapeString(ground_spawns_entry.name) + "'"); insert_values.push_back(std::to_string(ground_spawns_entry.item)); insert_values.push_back(std::to_string(ground_spawns_entry.max_allowed)); @@ -349,6 +349,58 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GroundSpawns entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.max_x = atof(row[3]); + entry.max_y = atof(row[4]); + entry.max_z = atof(row[5]); + entry.min_x = atof(row[6]); + entry.min_y = atof(row[7]); + entry.heading = atof(row[8]); + entry.name = row[9]; + entry.item = atoi(row[10]); + entry.max_allowed = atoi(row[11]); + entry.comment = row[12]; + entry.respawn_timer = atoi(row[13]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GROUND_SPAWNS_REPOSITORY_H diff --git a/common/repositories/group_id_repository.h b/common/repositories/group_id_repository.h index 84a43786d..93f50d837 100644 --- a/common/repositories/group_id_repository.h +++ b/common/repositories/group_id_repository.h @@ -204,7 +204,7 @@ public: return group_id_entry; } - group_id_entry = InstanceListRepository::NewEntity(); + group_id_entry = GroupIdRepository::NewEntity(); return group_id_entry; } @@ -263,6 +263,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GroupId entry{}; + + entry.groupid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.name = row[2]; + entry.ismerc = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GROUP_ID_REPOSITORY_H diff --git a/common/repositories/group_leaders_repository.h b/common/repositories/group_leaders_repository.h index 39ccb6db7..55ba5da93 100644 --- a/common/repositories/group_leaders_repository.h +++ b/common/repositories/group_leaders_repository.h @@ -238,7 +238,7 @@ public: return group_leaders_entry; } - group_leaders_entry = InstanceListRepository::NewEntity(); + group_leaders_entry = GroupLeadersRepository::NewEntity(); return group_leaders_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GroupLeaders entry{}; + + entry.gid = atoi(row[0]); + entry.leadername = row[1]; + entry.marknpc = row[2]; + entry.leadershipaa = row[3]; + entry.maintank = row[4]; + entry.assist = row[5]; + entry.puller = row[6]; + entry.mentoree = row[7]; + entry.mentor_percent = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GROUP_LEADERS_REPOSITORY_H diff --git a/common/repositories/guild_members_repository.h b/common/repositories/guild_members_repository.h index 0ea708820..8ee1f3c9f 100644 --- a/common/repositories/guild_members_repository.h +++ b/common/repositories/guild_members_repository.h @@ -238,7 +238,7 @@ public: return guild_members_entry; } - guild_members_entry = InstanceListRepository::NewEntity(); + guild_members_entry = GuildMembersRepository::NewEntity(); return guild_members_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GuildMembers entry{}; + + entry.char_id = atoi(row[0]); + entry.guild_id = atoi(row[1]); + entry.rank = atoi(row[2]); + entry.tribute_enable = atoi(row[3]); + entry.total_tribute = atoi(row[4]); + entry.last_tribute = atoi(row[5]); + entry.banker = atoi(row[6]); + entry.public_note = row[7]; + entry.alt = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GUILD_MEMBERS_REPOSITORY_H diff --git a/common/repositories/guild_ranks_repository.h b/common/repositories/guild_ranks_repository.h index a2e7c437b..53c1f4f55 100644 --- a/common/repositories/guild_ranks_repository.h +++ b/common/repositories/guild_ranks_repository.h @@ -248,7 +248,7 @@ public: return guild_ranks_entry; } - guild_ranks_entry = InstanceListRepository::NewEntity(); + guild_ranks_entry = GuildRanksRepository::NewEntity(); return guild_ranks_entry; } @@ -322,6 +322,55 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GuildRanks entry{}; + + entry.guild_id = atoi(row[0]); + entry.rank = atoi(row[1]); + entry.title = row[2]; + entry.can_hear = atoi(row[3]); + entry.can_speak = atoi(row[4]); + entry.can_invite = atoi(row[5]); + entry.can_remove = atoi(row[6]); + entry.can_promote = atoi(row[7]); + entry.can_demote = atoi(row[8]); + entry.can_motd = atoi(row[9]); + entry.can_warpeace = atoi(row[10]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GUILD_RANKS_REPOSITORY_H diff --git a/common/repositories/guild_relations_repository.h b/common/repositories/guild_relations_repository.h index effe37b13..7d13cf972 100644 --- a/common/repositories/guild_relations_repository.h +++ b/common/repositories/guild_relations_repository.h @@ -200,7 +200,7 @@ public: return guild_relations_entry; } - guild_relations_entry = InstanceListRepository::NewEntity(); + guild_relations_entry = GuildRelationsRepository::NewEntity(); return guild_relations_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + GuildRelations entry{}; + + entry.guild1 = atoi(row[0]); + entry.guild2 = atoi(row[1]); + entry.relation = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GUILD_RELATIONS_REPOSITORY_H diff --git a/common/repositories/guilds_repository.h b/common/repositories/guilds_repository.h index 6c0fc5234..e6e2c92f0 100644 --- a/common/repositories/guilds_repository.h +++ b/common/repositories/guilds_repository.h @@ -238,7 +238,7 @@ public: return guilds_entry; } - guilds_entry = InstanceListRepository::NewEntity(); + guilds_entry = GuildsRepository::NewEntity(); return guilds_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Guilds entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.leader = atoi(row[2]); + entry.minstatus = atoi(row[3]); + entry.motd = row[4]; + entry.tribute = atoi(row[5]); + entry.motd_setter = row[6]; + entry.channel = row[7]; + entry.url = row[8]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_GUILDS_REPOSITORY_H diff --git a/common/repositories/hackers_repository.h b/common/repositories/hackers_repository.h index 6c0de2022..a12fcb980 100644 --- a/common/repositories/hackers_repository.h +++ b/common/repositories/hackers_repository.h @@ -220,7 +220,7 @@ public: return hackers_entry; } - hackers_entry = InstanceListRepository::NewEntity(); + hackers_entry = HackersRepository::NewEntity(); return hackers_entry; } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Hackers entry{}; + + entry.id = atoi(row[0]); + entry.account = row[1]; + entry.name = row[2]; + entry.hacked = row[3]; + entry.zone = row[4]; + entry.date = row[5]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_HACKERS_REPOSITORY_H diff --git a/common/repositories/horses_repository.h b/common/repositories/horses_repository.h index 7bec38213..93614a880 100644 --- a/common/repositories/horses_repository.h +++ b/common/repositories/horses_repository.h @@ -179,7 +179,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(horses_entry.race)); update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.gender)); update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.texture)); - update_values.push_back(columns[4] + " = '" + EscapeString(horses_entry.mountspeed) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.mountspeed)); update_values.push_back(columns[5] + " = '" + EscapeString(horses_entry.notes) + "'"); auto results = content_db.QueryDatabase( @@ -204,7 +204,7 @@ public: insert_values.push_back(std::to_string(horses_entry.race)); insert_values.push_back(std::to_string(horses_entry.gender)); insert_values.push_back(std::to_string(horses_entry.texture)); - insert_values.push_back("'" + EscapeString(horses_entry.mountspeed) + "'"); + insert_values.push_back(std::to_string(horses_entry.mountspeed)); insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'"); auto results = content_db.QueryDatabase( @@ -220,7 +220,7 @@ public: return horses_entry; } - horses_entry = InstanceListRepository::NewEntity(); + horses_entry = HorsesRepository::NewEntity(); return horses_entry; } @@ -237,7 +237,7 @@ public: insert_values.push_back(std::to_string(horses_entry.race)); insert_values.push_back(std::to_string(horses_entry.gender)); insert_values.push_back(std::to_string(horses_entry.texture)); - insert_values.push_back("'" + EscapeString(horses_entry.mountspeed) + "'"); + insert_values.push_back(std::to_string(horses_entry.mountspeed)); insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Horses entry{}; + + entry.filename = row[0]; + entry.race = atoi(row[1]); + entry.gender = atoi(row[2]); + entry.texture = atoi(row[3]); + entry.mountspeed = atof(row[4]); + entry.notes = row[5]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_HORSES_REPOSITORY_H diff --git a/common/repositories/instance_list_player_repository.h b/common/repositories/instance_list_player_repository.h index 811ae3a8d..1adde4943 100644 --- a/common/repositories/instance_list_player_repository.h +++ b/common/repositories/instance_list_player_repository.h @@ -196,7 +196,7 @@ public: return instance_list_player_entry; } - instance_list_player_entry = InstanceListRepository::NewEntity(); + instance_list_player_entry = InstanceListPlayerRepository::NewEntity(); return instance_list_player_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + InstanceListPlayer entry{}; + + entry.id = atoi(row[0]); + entry.charid = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_INSTANCE_LIST_PLAYER_REPOSITORY_H diff --git a/common/repositories/instance_list_repository.h b/common/repositories/instance_list_repository.h index cc2c113a3..763856653 100644 --- a/common/repositories/instance_list_repository.h +++ b/common/repositories/instance_list_repository.h @@ -293,6 +293,51 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + InstanceList entry{}; + + entry.id = atoi(row[0]); + entry.zone = atoi(row[1]); + entry.version = atoi(row[2]); + entry.is_global = atoi(row[3]); + entry.start_time = atoi(row[4]); + entry.duration = atoi(row[5]); + entry.never_expires = atoi(row[6]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_INSTANCE_LIST_REPOSITORY_H diff --git a/common/repositories/inventory_repository.h b/common/repositories/inventory_repository.h index d2f8f0f00..18964010a 100644 --- a/common/repositories/inventory_repository.h +++ b/common/repositories/inventory_repository.h @@ -278,7 +278,7 @@ public: return inventory_entry; } - inventory_entry = InstanceListRepository::NewEntity(); + inventory_entry = InventoryRepository::NewEntity(); return inventory_entry; } @@ -362,6 +362,60 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Inventory entry{}; + + entry.charid = atoi(row[0]); + entry.slotid = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.color = atoi(row[4]); + entry.augslot1 = atoi(row[5]); + entry.augslot2 = atoi(row[6]); + entry.augslot3 = atoi(row[7]); + entry.augslot4 = atoi(row[8]); + entry.augslot5 = atoi(row[9]); + entry.augslot6 = atoi(row[10]); + entry.instnodrop = atoi(row[11]); + entry.custom_data = row[12]; + entry.ornamenticon = atoi(row[13]); + entry.ornamentidfile = atoi(row[14]); + entry.ornament_hero_model = atoi(row[15]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_INVENTORY_REPOSITORY_H diff --git a/common/repositories/inventory_snapshots_repository.h b/common/repositories/inventory_snapshots_repository.h index dc9adfb63..670576616 100644 --- a/common/repositories/inventory_snapshots_repository.h +++ b/common/repositories/inventory_snapshots_repository.h @@ -282,7 +282,7 @@ public: return inventory_snapshots_entry; } - inventory_snapshots_entry = InstanceListRepository::NewEntity(); + inventory_snapshots_entry = InventorySnapshotsRepository::NewEntity(); return inventory_snapshots_entry; } @@ -367,6 +367,61 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + InventorySnapshots entry{}; + + entry.time_index = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.slotid = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.color = atoi(row[5]); + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + entry.instnodrop = atoi(row[12]); + entry.custom_data = row[13]; + entry.ornamenticon = atoi(row[14]); + entry.ornamentidfile = atoi(row[15]); + entry.ornament_hero_model = atoi(row[16]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_INVENTORY_SNAPSHOTS_REPOSITORY_H diff --git a/common/repositories/ip_exemptions_repository.h b/common/repositories/ip_exemptions_repository.h index 75ba5b658..544cb958b 100644 --- a/common/repositories/ip_exemptions_repository.h +++ b/common/repositories/ip_exemptions_repository.h @@ -202,7 +202,7 @@ public: return ip_exemptions_entry; } - ip_exemptions_entry = InstanceListRepository::NewEntity(); + ip_exemptions_entry = IpExemptionsRepository::NewEntity(); return ip_exemptions_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + IpExemptions entry{}; + + entry.exemption_id = atoi(row[0]); + entry.exemption_ip = row[1]; + entry.exemption_amount = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_IP_EXEMPTIONS_REPOSITORY_H diff --git a/common/repositories/item_tick_repository.h b/common/repositories/item_tick_repository.h index 56c717101..f16427c95 100644 --- a/common/repositories/item_tick_repository.h +++ b/common/repositories/item_tick_repository.h @@ -220,7 +220,7 @@ public: return item_tick_entry; } - item_tick_entry = InstanceListRepository::NewEntity(); + item_tick_entry = ItemTickRepository::NewEntity(); return item_tick_entry; } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + ItemTick entry{}; + + entry.it_itemid = atoi(row[0]); + entry.it_chance = atoi(row[1]); + entry.it_level = atoi(row[2]); + entry.it_id = atoi(row[3]); + entry.it_qglobal = row[4]; + entry.it_bagslot = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ITEM_TICK_REPOSITORY_H diff --git a/common/repositories/items_repository.h b/common/repositories/items_repository.h index b688f0dcd..395fc3a4d 100644 --- a/common/repositories/items_repository.h +++ b/common/repositories/items_repository.h @@ -1398,7 +1398,7 @@ public: update_values.push_back(columns[104] + " = " + std::to_string(items_entry.reclevel)); update_values.push_back(columns[105] + " = " + std::to_string(items_entry.recskill)); update_values.push_back(columns[106] + " = " + std::to_string(items_entry.reqlevel)); - update_values.push_back(columns[107] + " = '" + EscapeString(items_entry.sellrate) + "'"); + update_values.push_back(columns[107] + " = " + std::to_string(items_entry.sellrate)); update_values.push_back(columns[108] + " = " + std::to_string(items_entry.shielding)); update_values.push_back(columns[109] + " = " + std::to_string(items_entry.size)); update_values.push_back(columns[110] + " = " + std::to_string(items_entry.skillmodtype)); @@ -1702,7 +1702,7 @@ public: insert_values.push_back(std::to_string(items_entry.reclevel)); insert_values.push_back(std::to_string(items_entry.recskill)); insert_values.push_back(std::to_string(items_entry.reqlevel)); - insert_values.push_back("'" + EscapeString(items_entry.sellrate) + "'"); + insert_values.push_back(std::to_string(items_entry.sellrate)); insert_values.push_back(std::to_string(items_entry.shielding)); insert_values.push_back(std::to_string(items_entry.size)); insert_values.push_back(std::to_string(items_entry.skillmodtype)); @@ -1894,7 +1894,7 @@ public: return items_entry; } - items_entry = InstanceListRepository::NewEntity(); + items_entry = ItemsRepository::NewEntity(); return items_entry; } @@ -2014,7 +2014,7 @@ public: insert_values.push_back(std::to_string(items_entry.reclevel)); insert_values.push_back(std::to_string(items_entry.recskill)); insert_values.push_back(std::to_string(items_entry.reqlevel)); - insert_values.push_back("'" + EscapeString(items_entry.sellrate) + "'"); + insert_values.push_back(std::to_string(items_entry.sellrate)); insert_values.push_back(std::to_string(items_entry.shielding)); insert_values.push_back(std::to_string(items_entry.size)); insert_values.push_back(std::to_string(items_entry.skillmodtype)); @@ -2517,6 +2517,329 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Items entry{}; + + entry.id = atoi(row[0]); + entry.minstatus = atoi(row[1]); + entry.Name = row[2]; + entry.aagi = atoi(row[3]); + entry.ac = atoi(row[4]); + entry.accuracy = atoi(row[5]); + entry.acha = atoi(row[6]); + entry.adex = atoi(row[7]); + entry.aint = atoi(row[8]); + entry.artifactflag = atoi(row[9]); + entry.asta = atoi(row[10]); + entry.astr = atoi(row[11]); + entry.attack = atoi(row[12]); + entry.augrestrict = atoi(row[13]); + entry.augslot1type = atoi(row[14]); + entry.augslot1visible = atoi(row[15]); + entry.augslot2type = atoi(row[16]); + entry.augslot2visible = atoi(row[17]); + entry.augslot3type = atoi(row[18]); + entry.augslot3visible = atoi(row[19]); + entry.augslot4type = atoi(row[20]); + entry.augslot4visible = atoi(row[21]); + entry.augslot5type = atoi(row[22]); + entry.augslot5visible = atoi(row[23]); + entry.augslot6type = atoi(row[24]); + entry.augslot6visible = atoi(row[25]); + entry.augtype = atoi(row[26]); + entry.avoidance = atoi(row[27]); + entry.awis = atoi(row[28]); + entry.bagsize = atoi(row[29]); + entry.bagslots = atoi(row[30]); + entry.bagtype = atoi(row[31]); + entry.bagwr = atoi(row[32]); + entry.banedmgamt = atoi(row[33]); + entry.banedmgraceamt = atoi(row[34]); + entry.banedmgbody = atoi(row[35]); + entry.banedmgrace = atoi(row[36]); + entry.bardtype = atoi(row[37]); + entry.bardvalue = atoi(row[38]); + entry.book = atoi(row[39]); + entry.casttime = atoi(row[40]); + entry.casttime_ = atoi(row[41]); + entry.charmfile = row[42]; + entry.charmfileid = row[43]; + entry.classes = atoi(row[44]); + entry.color = atoi(row[45]); + entry.combateffects = row[46]; + entry.extradmgskill = atoi(row[47]); + entry.extradmgamt = atoi(row[48]); + entry.price = atoi(row[49]); + entry.cr = atoi(row[50]); + entry.damage = atoi(row[51]); + entry.damageshield = atoi(row[52]); + entry.deity = atoi(row[53]); + entry.delay = atoi(row[54]); + entry.augdistiller = atoi(row[55]); + entry.dotshielding = atoi(row[56]); + entry.dr = atoi(row[57]); + entry.clicktype = atoi(row[58]); + entry.clicklevel2 = atoi(row[59]); + entry.elemdmgtype = atoi(row[60]); + entry.elemdmgamt = atoi(row[61]); + entry.endur = atoi(row[62]); + entry.factionamt1 = atoi(row[63]); + entry.factionamt2 = atoi(row[64]); + entry.factionamt3 = atoi(row[65]); + entry.factionamt4 = atoi(row[66]); + entry.factionmod1 = atoi(row[67]); + entry.factionmod2 = atoi(row[68]); + entry.factionmod3 = atoi(row[69]); + entry.factionmod4 = atoi(row[70]); + entry.filename = row[71]; + entry.focuseffect = atoi(row[72]); + entry.fr = atoi(row[73]); + entry.fvnodrop = atoi(row[74]); + entry.haste = atoi(row[75]); + entry.clicklevel = atoi(row[76]); + entry.hp = atoi(row[77]); + entry.regen = atoi(row[78]); + entry.icon = atoi(row[79]); + entry.idfile = row[80]; + entry.itemclass = atoi(row[81]); + entry.itemtype = atoi(row[82]); + entry.ldonprice = atoi(row[83]); + entry.ldontheme = atoi(row[84]); + entry.ldonsold = atoi(row[85]); + entry.light = atoi(row[86]); + entry.lore = row[87]; + entry.loregroup = atoi(row[88]); + entry.magic = atoi(row[89]); + entry.mana = atoi(row[90]); + entry.manaregen = atoi(row[91]); + entry.enduranceregen = atoi(row[92]); + entry.material = atoi(row[93]); + entry.herosforgemodel = atoi(row[94]); + entry.maxcharges = atoi(row[95]); + entry.mr = atoi(row[96]); + entry.nodrop = atoi(row[97]); + entry.norent = atoi(row[98]); + entry.pendingloreflag = atoi(row[99]); + entry.pr = atoi(row[100]); + entry.procrate = atoi(row[101]); + entry.races = atoi(row[102]); + entry.range = atoi(row[103]); + entry.reclevel = atoi(row[104]); + entry.recskill = atoi(row[105]); + entry.reqlevel = atoi(row[106]); + entry.sellrate = atof(row[107]); + entry.shielding = atoi(row[108]); + entry.size = atoi(row[109]); + entry.skillmodtype = atoi(row[110]); + entry.skillmodvalue = atoi(row[111]); + entry.slots = atoi(row[112]); + entry.clickeffect = atoi(row[113]); + entry.spellshield = atoi(row[114]); + entry.strikethrough = atoi(row[115]); + entry.stunresist = atoi(row[116]); + entry.summonedflag = atoi(row[117]); + entry.tradeskills = atoi(row[118]); + entry.favor = atoi(row[119]); + entry.weight = atoi(row[120]); + entry.UNK012 = atoi(row[121]); + entry.UNK013 = atoi(row[122]); + entry.benefitflag = atoi(row[123]); + entry.UNK054 = atoi(row[124]); + entry.UNK059 = atoi(row[125]); + entry.booktype = atoi(row[126]); + entry.recastdelay = atoi(row[127]); + entry.recasttype = atoi(row[128]); + entry.guildfavor = atoi(row[129]); + entry.UNK123 = atoi(row[130]); + entry.UNK124 = atoi(row[131]); + entry.attuneable = atoi(row[132]); + entry.nopet = atoi(row[133]); + entry.updated = row[134]; + entry.comment = row[135]; + entry.UNK127 = atoi(row[136]); + entry.pointtype = atoi(row[137]); + entry.potionbelt = atoi(row[138]); + entry.potionbeltslots = atoi(row[139]); + entry.stacksize = atoi(row[140]); + entry.notransfer = atoi(row[141]); + entry.stackable = atoi(row[142]); + entry.UNK134 = row[143]; + entry.UNK137 = atoi(row[144]); + entry.proceffect = atoi(row[145]); + entry.proctype = atoi(row[146]); + entry.proclevel2 = atoi(row[147]); + entry.proclevel = atoi(row[148]); + entry.UNK142 = atoi(row[149]); + entry.worneffect = atoi(row[150]); + entry.worntype = atoi(row[151]); + entry.wornlevel2 = atoi(row[152]); + entry.wornlevel = atoi(row[153]); + entry.UNK147 = atoi(row[154]); + entry.focustype = atoi(row[155]); + entry.focuslevel2 = atoi(row[156]); + entry.focuslevel = atoi(row[157]); + entry.UNK152 = atoi(row[158]); + entry.scrolleffect = atoi(row[159]); + entry.scrolltype = atoi(row[160]); + entry.scrolllevel2 = atoi(row[161]); + entry.scrolllevel = atoi(row[162]); + entry.UNK157 = atoi(row[163]); + entry.serialized = row[164]; + entry.verified = row[165]; + entry.serialization = row[166]; + entry.source = row[167]; + entry.UNK033 = atoi(row[168]); + entry.lorefile = row[169]; + entry.UNK014 = atoi(row[170]); + entry.svcorruption = atoi(row[171]); + entry.skillmodmax = atoi(row[172]); + entry.UNK060 = atoi(row[173]); + entry.augslot1unk2 = atoi(row[174]); + entry.augslot2unk2 = atoi(row[175]); + entry.augslot3unk2 = atoi(row[176]); + entry.augslot4unk2 = atoi(row[177]); + entry.augslot5unk2 = atoi(row[178]); + entry.augslot6unk2 = atoi(row[179]); + entry.UNK120 = atoi(row[180]); + entry.UNK121 = atoi(row[181]); + entry.questitemflag = atoi(row[182]); + entry.UNK132 = row[183]; + entry.clickunk5 = atoi(row[184]); + entry.clickunk6 = row[185]; + entry.clickunk7 = atoi(row[186]); + entry.procunk1 = atoi(row[187]); + entry.procunk2 = atoi(row[188]); + entry.procunk3 = atoi(row[189]); + entry.procunk4 = atoi(row[190]); + entry.procunk6 = row[191]; + entry.procunk7 = atoi(row[192]); + entry.wornunk1 = atoi(row[193]); + entry.wornunk2 = atoi(row[194]); + entry.wornunk3 = atoi(row[195]); + entry.wornunk4 = atoi(row[196]); + entry.wornunk5 = atoi(row[197]); + entry.wornunk6 = row[198]; + entry.wornunk7 = atoi(row[199]); + entry.focusunk1 = atoi(row[200]); + entry.focusunk2 = atoi(row[201]); + entry.focusunk3 = atoi(row[202]); + entry.focusunk4 = atoi(row[203]); + entry.focusunk5 = atoi(row[204]); + entry.focusunk6 = row[205]; + entry.focusunk7 = atoi(row[206]); + entry.scrollunk1 = atoi(row[207]); + entry.scrollunk2 = atoi(row[208]); + entry.scrollunk3 = atoi(row[209]); + entry.scrollunk4 = atoi(row[210]); + entry.scrollunk5 = atoi(row[211]); + entry.scrollunk6 = row[212]; + entry.scrollunk7 = atoi(row[213]); + entry.UNK193 = atoi(row[214]); + entry.purity = atoi(row[215]); + entry.evoitem = atoi(row[216]); + entry.evoid = atoi(row[217]); + entry.evolvinglevel = atoi(row[218]); + entry.evomax = atoi(row[219]); + entry.clickname = row[220]; + entry.procname = row[221]; + entry.wornname = row[222]; + entry.focusname = row[223]; + entry.scrollname = row[224]; + entry.dsmitigation = atoi(row[225]); + entry.heroic_str = atoi(row[226]); + entry.heroic_int = atoi(row[227]); + entry.heroic_wis = atoi(row[228]); + entry.heroic_agi = atoi(row[229]); + entry.heroic_dex = atoi(row[230]); + entry.heroic_sta = atoi(row[231]); + entry.heroic_cha = atoi(row[232]); + entry.heroic_pr = atoi(row[233]); + entry.heroic_dr = atoi(row[234]); + entry.heroic_fr = atoi(row[235]); + entry.heroic_cr = atoi(row[236]); + entry.heroic_mr = atoi(row[237]); + entry.heroic_svcorrup = atoi(row[238]); + entry.healamt = atoi(row[239]); + entry.spelldmg = atoi(row[240]); + entry.clairvoyance = atoi(row[241]); + entry.backstabdmg = atoi(row[242]); + entry.created = row[243]; + entry.elitematerial = atoi(row[244]); + entry.ldonsellbackrate = atoi(row[245]); + entry.scriptfileid = atoi(row[246]); + entry.expendablearrow = atoi(row[247]); + entry.powersourcecapacity = atoi(row[248]); + entry.bardeffect = atoi(row[249]); + entry.bardeffecttype = atoi(row[250]); + entry.bardlevel2 = atoi(row[251]); + entry.bardlevel = atoi(row[252]); + entry.bardunk1 = atoi(row[253]); + entry.bardunk2 = atoi(row[254]); + entry.bardunk3 = atoi(row[255]); + entry.bardunk4 = atoi(row[256]); + entry.bardunk5 = atoi(row[257]); + entry.bardname = row[258]; + entry.bardunk7 = atoi(row[259]); + entry.UNK214 = atoi(row[260]); + entry.UNK219 = atoi(row[261]); + entry.UNK220 = atoi(row[262]); + entry.UNK221 = atoi(row[263]); + entry.heirloom = atoi(row[264]); + entry.UNK223 = atoi(row[265]); + entry.UNK224 = atoi(row[266]); + entry.UNK225 = atoi(row[267]); + entry.UNK226 = atoi(row[268]); + entry.UNK227 = atoi(row[269]); + entry.UNK228 = atoi(row[270]); + entry.UNK229 = atoi(row[271]); + entry.UNK230 = atoi(row[272]); + entry.UNK231 = atoi(row[273]); + entry.UNK232 = atoi(row[274]); + entry.UNK233 = atoi(row[275]); + entry.UNK234 = atoi(row[276]); + entry.placeable = atoi(row[277]); + entry.UNK236 = atoi(row[278]); + entry.UNK237 = atoi(row[279]); + entry.UNK238 = atoi(row[280]); + entry.UNK239 = atoi(row[281]); + entry.UNK240 = atoi(row[282]); + entry.UNK241 = atoi(row[283]); + entry.epicitem = atoi(row[284]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ITEMS_REPOSITORY_H diff --git a/common/repositories/launcher_repository.h b/common/repositories/launcher_repository.h index aa82afbc9..2471bd061 100644 --- a/common/repositories/launcher_repository.h +++ b/common/repositories/launcher_repository.h @@ -196,7 +196,7 @@ public: return launcher_entry; } - launcher_entry = InstanceListRepository::NewEntity(); + launcher_entry = LauncherRepository::NewEntity(); return launcher_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Launcher entry{}; + + entry.name = row[0]; + entry.dynamics = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LAUNCHER_REPOSITORY_H diff --git a/common/repositories/launcher_zones_repository.h b/common/repositories/launcher_zones_repository.h index a8af8fe50..225a12226 100644 --- a/common/repositories/launcher_zones_repository.h +++ b/common/repositories/launcher_zones_repository.h @@ -200,7 +200,7 @@ public: return launcher_zones_entry; } - launcher_zones_entry = InstanceListRepository::NewEntity(); + launcher_zones_entry = LauncherZonesRepository::NewEntity(); return launcher_zones_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LauncherZones entry{}; + + entry.launcher = row[0]; + entry.zone = row[1]; + entry.port = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LAUNCHER_ZONES_REPOSITORY_H diff --git a/common/repositories/ldon_trap_entries_repository.h b/common/repositories/ldon_trap_entries_repository.h index c4912fe17..edcca50be 100644 --- a/common/repositories/ldon_trap_entries_repository.h +++ b/common/repositories/ldon_trap_entries_repository.h @@ -196,7 +196,7 @@ public: return ldon_trap_entries_entry; } - ldon_trap_entries_entry = InstanceListRepository::NewEntity(); + ldon_trap_entries_entry = LdonTrapEntriesRepository::NewEntity(); return ldon_trap_entries_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LdonTrapEntries entry{}; + + entry.id = atoi(row[0]); + entry.trap_id = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LDON_TRAP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/ldon_trap_templates_repository.h b/common/repositories/ldon_trap_templates_repository.h index 8033fb684..a2610f5bd 100644 --- a/common/repositories/ldon_trap_templates_repository.h +++ b/common/repositories/ldon_trap_templates_repository.h @@ -214,7 +214,7 @@ public: return ldon_trap_templates_entry; } - ldon_trap_templates_entry = InstanceListRepository::NewEntity(); + ldon_trap_templates_entry = LdonTrapTemplatesRepository::NewEntity(); return ldon_trap_templates_entry; } @@ -277,6 +277,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LdonTrapTemplates entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.spell_id = atoi(row[2]); + entry.skill = atoi(row[3]); + entry.locked = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LDON_TRAP_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/level_exp_mods_repository.h b/common/repositories/level_exp_mods_repository.h index bce2eda13..8ca1956fe 100644 --- a/common/repositories/level_exp_mods_repository.h +++ b/common/repositories/level_exp_mods_repository.h @@ -164,8 +164,8 @@ public: auto columns = Columns(); - update_values.push_back(columns[1] + " = '" + EscapeString(level_exp_mods_entry.exp_mod) + "'"); - update_values.push_back(columns[2] + " = '" + EscapeString(level_exp_mods_entry.aa_exp_mod) + "'"); + update_values.push_back(columns[1] + " = " + std::to_string(level_exp_mods_entry.exp_mod)); + update_values.push_back(columns[2] + " = " + std::to_string(level_exp_mods_entry.aa_exp_mod)); auto results = database.QueryDatabase( fmt::format( @@ -186,8 +186,8 @@ public: { std::vector insert_values; - insert_values.push_back("'" + EscapeString(level_exp_mods_entry.exp_mod) + "'"); - insert_values.push_back("'" + EscapeString(level_exp_mods_entry.aa_exp_mod) + "'"); + insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); + insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); auto results = database.QueryDatabase( fmt::format( @@ -202,7 +202,7 @@ public: return level_exp_mods_entry; } - level_exp_mods_entry = InstanceListRepository::NewEntity(); + level_exp_mods_entry = LevelExpModsRepository::NewEntity(); return level_exp_mods_entry; } @@ -216,8 +216,8 @@ public: for (auto &level_exp_mods_entry: level_exp_mods_entries) { std::vector insert_values; - insert_values.push_back("'" + EscapeString(level_exp_mods_entry.exp_mod) + "'"); - insert_values.push_back("'" + EscapeString(level_exp_mods_entry.aa_exp_mod) + "'"); + insert_values.push_back(std::to_string(level_exp_mods_entry.exp_mod)); + insert_values.push_back(std::to_string(level_exp_mods_entry.aa_exp_mod)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LevelExpMods entry{}; + + entry.level = atoi(row[0]); + entry.exp_mod = atof(row[1]); + entry.aa_exp_mod = atof(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LEVEL_EXP_MODS_REPOSITORY_H diff --git a/common/repositories/lfguild_repository.h b/common/repositories/lfguild_repository.h index 3a129cfdb..ffc987c50 100644 --- a/common/repositories/lfguild_repository.h +++ b/common/repositories/lfguild_repository.h @@ -236,7 +236,7 @@ public: return lfguild_entry; } - lfguild_entry = InstanceListRepository::NewEntity(); + lfguild_entry = LfguildRepository::NewEntity(); return lfguild_entry; } @@ -306,6 +306,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Lfguild entry{}; + + entry.type = atoi(row[0]); + entry.name = row[1]; + entry.comment = row[2]; + entry.fromlevel = atoi(row[3]); + entry.tolevel = atoi(row[4]); + entry.classes = atoi(row[5]); + entry.aacount = atoi(row[6]); + entry.timezone = atoi(row[7]); + entry.timeposted = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LFGUILD_REPOSITORY_H diff --git a/common/repositories/login_accounts_repository.h b/common/repositories/login_accounts_repository.h index 19ad77ab7..3f35a9add 100644 --- a/common/repositories/login_accounts_repository.h +++ b/common/repositories/login_accounts_repository.h @@ -238,7 +238,7 @@ public: return login_accounts_entry; } - login_accounts_entry = InstanceListRepository::NewEntity(); + login_accounts_entry = LoginAccountsRepository::NewEntity(); return login_accounts_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoginAccounts entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1]; + entry.account_password = row[2]; + entry.account_email = row[3]; + entry.source_loginserver = row[4]; + entry.last_ip_address = row[5]; + entry.last_login_date = row[6]; + entry.created_at = row[7]; + entry.updated_at = row[8]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGIN_ACCOUNTS_REPOSITORY_H diff --git a/common/repositories/login_api_tokens_repository.h b/common/repositories/login_api_tokens_repository.h index 8a6cd454e..8c64eb69d 100644 --- a/common/repositories/login_api_tokens_repository.h +++ b/common/repositories/login_api_tokens_repository.h @@ -220,7 +220,7 @@ public: return login_api_tokens_entry; } - login_api_tokens_entry = InstanceListRepository::NewEntity(); + login_api_tokens_entry = LoginApiTokensRepository::NewEntity(); return login_api_tokens_entry; } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoginApiTokens entry{}; + + entry.id = atoi(row[0]); + entry.token = row[1]; + entry.can_write = atoi(row[2]); + entry.can_read = atoi(row[3]); + entry.created_at = row[4]; + entry.updated_at = row[5]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGIN_API_TOKENS_REPOSITORY_H diff --git a/common/repositories/login_server_admins_repository.h b/common/repositories/login_server_admins_repository.h index 21c4f9e66..92eccc7cb 100644 --- a/common/repositories/login_server_admins_repository.h +++ b/common/repositories/login_server_admins_repository.h @@ -232,7 +232,7 @@ public: return login_server_admins_entry; } - login_server_admins_entry = InstanceListRepository::NewEntity(); + login_server_admins_entry = LoginServerAdminsRepository::NewEntity(); return login_server_admins_entry; } @@ -301,6 +301,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoginServerAdmins entry{}; + + entry.id = atoi(row[0]); + entry.account_name = row[1]; + entry.account_password = row[2]; + entry.first_name = row[3]; + entry.last_name = row[4]; + entry.email = row[5]; + entry.registration_date = row[6]; + entry.registration_ip_address = row[7]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGIN_SERVER_ADMINS_REPOSITORY_H diff --git a/common/repositories/login_server_list_types_repository.h b/common/repositories/login_server_list_types_repository.h index e328109ca..f844ce5ec 100644 --- a/common/repositories/login_server_list_types_repository.h +++ b/common/repositories/login_server_list_types_repository.h @@ -196,7 +196,7 @@ public: return login_server_list_types_entry; } - login_server_list_types_entry = InstanceListRepository::NewEntity(); + login_server_list_types_entry = LoginServerListTypesRepository::NewEntity(); return login_server_list_types_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoginServerListTypes entry{}; + + entry.id = atoi(row[0]); + entry.description = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGIN_SERVER_LIST_TYPES_REPOSITORY_H diff --git a/common/repositories/login_world_servers_repository.h b/common/repositories/login_world_servers_repository.h index e2d42a36e..1aa2e40ef 100644 --- a/common/repositories/login_world_servers_repository.h +++ b/common/repositories/login_world_servers_repository.h @@ -244,7 +244,7 @@ public: return login_world_servers_entry; } - login_world_servers_entry = InstanceListRepository::NewEntity(); + login_world_servers_entry = LoginWorldServersRepository::NewEntity(); return login_world_servers_entry; } @@ -317,6 +317,54 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoginWorldServers entry{}; + + entry.id = atoi(row[0]); + entry.long_name = row[1]; + entry.short_name = row[2]; + entry.tag_description = row[3]; + entry.login_server_list_type_id = atoi(row[4]); + entry.last_login_date = row[5]; + entry.last_ip_address = row[6]; + entry.login_server_admin_id = atoi(row[7]); + entry.is_server_trusted = atoi(row[8]); + entry.note = row[9]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGIN_WORLD_SERVERS_REPOSITORY_H diff --git a/common/repositories/logsys_categories_repository.h b/common/repositories/logsys_categories_repository.h index c785c663a..2f7c5d089 100644 --- a/common/repositories/logsys_categories_repository.h +++ b/common/repositories/logsys_categories_repository.h @@ -214,7 +214,7 @@ public: return logsys_categories_entry; } - logsys_categories_entry = InstanceListRepository::NewEntity(); + logsys_categories_entry = LogsysCategoriesRepository::NewEntity(); return logsys_categories_entry; } @@ -277,6 +277,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LogsysCategories entry{}; + + entry.log_category_id = atoi(row[0]); + entry.log_category_description = row[1]; + entry.log_to_console = atoi(row[2]); + entry.log_to_file = atoi(row[3]); + entry.log_to_gmsay = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOGSYS_CATEGORIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_entries_repository.h b/common/repositories/lootdrop_entries_repository.h index 73e97c978..07bbfdbca 100644 --- a/common/repositories/lootdrop_entries_repository.h +++ b/common/repositories/lootdrop_entries_repository.h @@ -190,8 +190,8 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(lootdrop_entries_entry.item_charges)); update_values.push_back(columns[3] + " = " + std::to_string(lootdrop_entries_entry.equip_item)); - update_values.push_back(columns[4] + " = '" + EscapeString(lootdrop_entries_entry.chance) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(lootdrop_entries_entry.disabled_chance) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(lootdrop_entries_entry.chance)); + update_values.push_back(columns[5] + " = " + std::to_string(lootdrop_entries_entry.disabled_chance)); update_values.push_back(columns[6] + " = " + std::to_string(lootdrop_entries_entry.minlevel)); update_values.push_back(columns[7] + " = " + std::to_string(lootdrop_entries_entry.maxlevel)); update_values.push_back(columns[8] + " = " + std::to_string(lootdrop_entries_entry.multiplier)); @@ -217,8 +217,8 @@ public: insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); - insert_values.push_back("'" + EscapeString(lootdrop_entries_entry.chance) + "'"); - insert_values.push_back("'" + EscapeString(lootdrop_entries_entry.disabled_chance) + "'"); + insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); @@ -236,7 +236,7 @@ public: return lootdrop_entries_entry; } - lootdrop_entries_entry = InstanceListRepository::NewEntity(); + lootdrop_entries_entry = LootdropEntriesRepository::NewEntity(); return lootdrop_entries_entry; } @@ -252,8 +252,8 @@ public: insert_values.push_back(std::to_string(lootdrop_entries_entry.item_charges)); insert_values.push_back(std::to_string(lootdrop_entries_entry.equip_item)); - insert_values.push_back("'" + EscapeString(lootdrop_entries_entry.chance) + "'"); - insert_values.push_back("'" + EscapeString(lootdrop_entries_entry.disabled_chance) + "'"); + insert_values.push_back(std::to_string(lootdrop_entries_entry.chance)); + insert_values.push_back(std::to_string(lootdrop_entries_entry.disabled_chance)); insert_values.push_back(std::to_string(lootdrop_entries_entry.minlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.maxlevel)); insert_values.push_back(std::to_string(lootdrop_entries_entry.multiplier)); @@ -306,6 +306,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LootdropEntries entry{}; + + entry.lootdrop_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.item_charges = atoi(row[2]); + entry.equip_item = atoi(row[3]); + entry.chance = atof(row[4]); + entry.disabled_chance = atof(row[5]); + entry.minlevel = atoi(row[6]); + entry.maxlevel = atoi(row[7]); + entry.multiplier = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOOTDROP_ENTRIES_REPOSITORY_H diff --git a/common/repositories/lootdrop_repository.h b/common/repositories/lootdrop_repository.h index fd165c019..45069fa56 100644 --- a/common/repositories/lootdrop_repository.h +++ b/common/repositories/lootdrop_repository.h @@ -196,7 +196,7 @@ public: return lootdrop_entry; } - lootdrop_entry = InstanceListRepository::NewEntity(); + lootdrop_entry = LootdropRepository::NewEntity(); return lootdrop_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Lootdrop entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOOTDROP_REPOSITORY_H diff --git a/common/repositories/loottable_entries_repository.h b/common/repositories/loottable_entries_repository.h index f648f2142..68b6bfa2c 100644 --- a/common/repositories/loottable_entries_repository.h +++ b/common/repositories/loottable_entries_repository.h @@ -179,7 +179,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(loottable_entries_entry.multiplier)); update_values.push_back(columns[3] + " = " + std::to_string(loottable_entries_entry.droplimit)); update_values.push_back(columns[4] + " = " + std::to_string(loottable_entries_entry.mindrop)); - update_values.push_back(columns[5] + " = '" + EscapeString(loottable_entries_entry.probability) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(loottable_entries_entry.probability)); auto results = content_db.QueryDatabase( fmt::format( @@ -203,7 +203,7 @@ public: insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); - insert_values.push_back("'" + EscapeString(loottable_entries_entry.probability) + "'"); + insert_values.push_back(std::to_string(loottable_entries_entry.probability)); auto results = content_db.QueryDatabase( fmt::format( @@ -218,7 +218,7 @@ public: return loottable_entries_entry; } - loottable_entries_entry = InstanceListRepository::NewEntity(); + loottable_entries_entry = LoottableEntriesRepository::NewEntity(); return loottable_entries_entry; } @@ -235,7 +235,7 @@ public: insert_values.push_back(std::to_string(loottable_entries_entry.multiplier)); insert_values.push_back(std::to_string(loottable_entries_entry.droplimit)); insert_values.push_back(std::to_string(loottable_entries_entry.mindrop)); - insert_values.push_back("'" + EscapeString(loottable_entries_entry.probability) + "'"); + insert_values.push_back(std::to_string(loottable_entries_entry.probability)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -282,6 +282,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + LoottableEntries entry{}; + + entry.loottable_id = atoi(row[0]); + entry.lootdrop_id = atoi(row[1]); + entry.multiplier = atoi(row[2]); + entry.droplimit = atoi(row[3]); + entry.mindrop = atoi(row[4]); + entry.probability = atof(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOOTTABLE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/loottable_repository.h b/common/repositories/loottable_repository.h index 31fc0ab99..4f87c30b0 100644 --- a/common/repositories/loottable_repository.h +++ b/common/repositories/loottable_repository.h @@ -220,7 +220,7 @@ public: return loottable_entry; } - loottable_entry = InstanceListRepository::NewEntity(); + loottable_entry = LoottableRepository::NewEntity(); return loottable_entry; } @@ -285,6 +285,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Loottable entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.mincash = atoi(row[2]); + entry.maxcash = atoi(row[3]); + entry.avgcoin = atoi(row[4]); + entry.done = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_LOOTTABLE_REPOSITORY_H diff --git a/common/repositories/mail_repository.h b/common/repositories/mail_repository.h index 13a4e83d8..090d24900 100644 --- a/common/repositories/mail_repository.h +++ b/common/repositories/mail_repository.h @@ -232,7 +232,7 @@ public: return mail_entry; } - mail_entry = InstanceListRepository::NewEntity(); + mail_entry = MailRepository::NewEntity(); return mail_entry; } @@ -301,6 +301,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Mail entry{}; + + entry.msgid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.timestamp = atoi(row[2]); + entry.from = row[3]; + entry.subject = row[4]; + entry.body = row[5]; + entry.to = row[6]; + entry.status = atoi(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_MAIL_REPOSITORY_H diff --git a/common/repositories/merchantlist_repository.h b/common/repositories/merchantlist_repository.h index a0600e926..7ebb68664 100644 --- a/common/repositories/merchantlist_repository.h +++ b/common/repositories/merchantlist_repository.h @@ -230,7 +230,7 @@ public: return merchantlist_entry; } - merchantlist_entry = InstanceListRepository::NewEntity(); + merchantlist_entry = MerchantlistRepository::NewEntity(); return merchantlist_entry; } @@ -298,6 +298,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Merchantlist entry{}; + + entry.merchantid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item = atoi(row[2]); + entry.faction_required = atoi(row[3]); + entry.level_required = atoi(row[4]); + entry.alt_currency_cost = atoi(row[5]); + entry.classes_required = atoi(row[6]); + entry.probability = atoi(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_MERCHANTLIST_REPOSITORY_H diff --git a/common/repositories/merchantlist_temp_repository.h b/common/repositories/merchantlist_temp_repository.h index fc6820318..c4d560ee0 100644 --- a/common/repositories/merchantlist_temp_repository.h +++ b/common/repositories/merchantlist_temp_repository.h @@ -206,7 +206,7 @@ public: return merchantlist_temp_entry; } - merchantlist_temp_entry = InstanceListRepository::NewEntity(); + merchantlist_temp_entry = MerchantlistTempRepository::NewEntity(); return merchantlist_temp_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + MerchantlistTemp entry{}; + + entry.npcid = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.itemid = atoi(row[2]); + entry.charges = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_MERCHANTLIST_TEMP_REPOSITORY_H diff --git a/common/repositories/name_filter_repository.h b/common/repositories/name_filter_repository.h index 35bb2db62..f1190e398 100644 --- a/common/repositories/name_filter_repository.h +++ b/common/repositories/name_filter_repository.h @@ -196,7 +196,7 @@ public: return name_filter_entry; } - name_filter_entry = InstanceListRepository::NewEntity(); + name_filter_entry = NameFilterRepository::NewEntity(); return name_filter_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NameFilter entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NAME_FILTER_REPOSITORY_H diff --git a/common/repositories/npc_emotes_repository.h b/common/repositories/npc_emotes_repository.h index 14a6df2b0..7e0da33dc 100644 --- a/common/repositories/npc_emotes_repository.h +++ b/common/repositories/npc_emotes_repository.h @@ -214,7 +214,7 @@ public: return npc_emotes_entry; } - npc_emotes_entry = InstanceListRepository::NewEntity(); + npc_emotes_entry = NpcEmotesRepository::NewEntity(); return npc_emotes_entry; } @@ -277,6 +277,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcEmotes entry{}; + + entry.id = atoi(row[0]); + entry.emoteid = atoi(row[1]); + entry.event_ = atoi(row[2]); + entry.type = atoi(row[3]); + entry.text = row[4]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_EMOTES_REPOSITORY_H diff --git a/common/repositories/npc_faction_entries_repository.h b/common/repositories/npc_faction_entries_repository.h index 633444b7c..24a9bc4d8 100644 --- a/common/repositories/npc_faction_entries_repository.h +++ b/common/repositories/npc_faction_entries_repository.h @@ -212,7 +212,7 @@ public: return npc_faction_entries_entry; } - npc_faction_entries_entry = InstanceListRepository::NewEntity(); + npc_faction_entries_entry = NpcFactionEntriesRepository::NewEntity(); return npc_faction_entries_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcFactionEntries entry{}; + + entry.npc_faction_id = atoi(row[0]); + entry.faction_id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.npc_value = atoi(row[3]); + entry.temp = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_FACTION_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_faction_repository.h b/common/repositories/npc_faction_repository.h index a983c87dd..fec72a00a 100644 --- a/common/repositories/npc_faction_repository.h +++ b/common/repositories/npc_faction_repository.h @@ -208,7 +208,7 @@ public: return npc_faction_entry; } - npc_faction_entry = InstanceListRepository::NewEntity(); + npc_faction_entry = NpcFactionRepository::NewEntity(); return npc_faction_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcFaction entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.primaryfaction = atoi(row[2]); + entry.ignore_primary_assist = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_FACTION_REPOSITORY_H diff --git a/common/repositories/npc_scale_global_base_repository.h b/common/repositories/npc_scale_global_base_repository.h index a9485d79e..1d3571589 100644 --- a/common/repositories/npc_scale_global_base_repository.h +++ b/common/repositories/npc_scale_global_base_repository.h @@ -350,7 +350,7 @@ public: return npc_scale_global_base_entry; } - npc_scale_global_base_entry = InstanceListRepository::NewEntity(); + npc_scale_global_base_entry = NpcScaleGlobalBaseRepository::NewEntity(); return npc_scale_global_base_entry; } @@ -458,6 +458,72 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcScaleGlobalBase entry{}; + + entry.type = atoi(row[0]); + entry.level = atoi(row[1]); + entry.ac = atoi(row[2]); + entry.hp = atoi(row[3]); + entry.accuracy = atoi(row[4]); + entry.slow_mitigation = atoi(row[5]); + entry.attack = atoi(row[6]); + entry.strength = atoi(row[7]); + entry.stamina = atoi(row[8]); + entry.dexterity = atoi(row[9]); + entry.agility = atoi(row[10]); + entry.intelligence = atoi(row[11]); + entry.wisdom = atoi(row[12]); + entry.charisma = atoi(row[13]); + entry.magic_resist = atoi(row[14]); + entry.cold_resist = atoi(row[15]); + entry.fire_resist = atoi(row[16]); + entry.poison_resist = atoi(row[17]); + entry.disease_resist = atoi(row[18]); + entry.corruption_resist = atoi(row[19]); + entry.physical_resist = atoi(row[20]); + entry.min_dmg = atoi(row[21]); + entry.max_dmg = atoi(row[22]); + entry.hp_regen_rate = atoi(row[23]); + entry.attack_delay = atoi(row[24]); + entry.spell_scale = atoi(row[25]); + entry.heal_scale = atoi(row[26]); + entry.special_abilities = row[27]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_SCALE_GLOBAL_BASE_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_entries_repository.h b/common/repositories/npc_spells_effects_entries_repository.h index c02265f57..04a1b0e79 100644 --- a/common/repositories/npc_spells_effects_entries_repository.h +++ b/common/repositories/npc_spells_effects_entries_repository.h @@ -232,7 +232,7 @@ public: return npc_spells_effects_entries_entry; } - npc_spells_effects_entries_entry = InstanceListRepository::NewEntity(); + npc_spells_effects_entries_entry = NpcSpellsEffectsEntriesRepository::NewEntity(); return npc_spells_effects_entries_entry; } @@ -301,6 +301,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcSpellsEffectsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_effects_id = atoi(row[1]); + entry.spell_effect_id = atoi(row[2]); + entry.minlevel = atoi(row[3]); + entry.maxlevel = atoi(row[4]); + entry.se_base = atoi(row[5]); + entry.se_limit = atoi(row[6]); + entry.se_max = atoi(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_SPELLS_EFFECTS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_effects_repository.h b/common/repositories/npc_spells_effects_repository.h index f0ce4ed0b..8f4908175 100644 --- a/common/repositories/npc_spells_effects_repository.h +++ b/common/repositories/npc_spells_effects_repository.h @@ -202,7 +202,7 @@ public: return npc_spells_effects_entry; } - npc_spells_effects_entry = InstanceListRepository::NewEntity(); + npc_spells_effects_entry = NpcSpellsEffectsRepository::NewEntity(); return npc_spells_effects_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcSpellsEffects entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.parent_list = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_SPELLS_EFFECTS_REPOSITORY_H diff --git a/common/repositories/npc_spells_entries_repository.h b/common/repositories/npc_spells_entries_repository.h index d34913075..fdfd76bd1 100644 --- a/common/repositories/npc_spells_entries_repository.h +++ b/common/repositories/npc_spells_entries_repository.h @@ -256,7 +256,7 @@ public: return npc_spells_entries_entry; } - npc_spells_entries_entry = InstanceListRepository::NewEntity(); + npc_spells_entries_entry = NpcSpellsEntriesRepository::NewEntity(); return npc_spells_entries_entry; } @@ -333,6 +333,56 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcSpellsEntries entry{}; + + entry.id = atoi(row[0]); + entry.npc_spells_id = atoi(row[1]); + entry.spellid = atoi(row[2]); + entry.type = atoi(row[3]); + entry.minlevel = atoi(row[4]); + entry.maxlevel = atoi(row[5]); + entry.manacost = atoi(row[6]); + entry.recast_delay = atoi(row[7]); + entry.priority = atoi(row[8]); + entry.resist_adjust = atoi(row[9]); + entry.min_hp = atoi(row[10]); + entry.max_hp = atoi(row[11]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_SPELLS_ENTRIES_REPOSITORY_H diff --git a/common/repositories/npc_spells_repository.h b/common/repositories/npc_spells_repository.h index d0c4e7c22..ce9e56237 100644 --- a/common/repositories/npc_spells_repository.h +++ b/common/repositories/npc_spells_repository.h @@ -310,7 +310,7 @@ public: return npc_spells_entry; } - npc_spells_entry = InstanceListRepository::NewEntity(); + npc_spells_entry = NpcSpellsRepository::NewEntity(); return npc_spells_entry; } @@ -405,6 +405,65 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcSpells entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.parent_list = atoi(row[2]); + entry.attack_proc = atoi(row[3]); + entry.proc_chance = atoi(row[4]); + entry.range_proc = atoi(row[5]); + entry.rproc_chance = atoi(row[6]); + entry.defensive_proc = atoi(row[7]); + entry.dproc_chance = atoi(row[8]); + entry.fail_recast = atoi(row[9]); + entry.engaged_no_sp_recast_min = atoi(row[10]); + entry.engaged_no_sp_recast_max = atoi(row[11]); + entry.engaged_b_self_chance = atoi(row[12]); + entry.engaged_b_other_chance = atoi(row[13]); + entry.engaged_d_chance = atoi(row[14]); + entry.pursue_no_sp_recast_min = atoi(row[15]); + entry.pursue_no_sp_recast_max = atoi(row[16]); + entry.pursue_d_chance = atoi(row[17]); + entry.idle_no_sp_recast_min = atoi(row[18]); + entry.idle_no_sp_recast_max = atoi(row[19]); + entry.idle_b_chance = atoi(row[20]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_SPELLS_REPOSITORY_H diff --git a/common/repositories/npc_types_repository.h b/common/repositories/npc_types_repository.h index 47734a048..b7c2a58ff 100644 --- a/common/repositories/npc_types_repository.h +++ b/common/repositories/npc_types_repository.h @@ -652,7 +652,7 @@ public: update_values.push_back(columns[10] + " = " + std::to_string(npc_types_entry.texture)); update_values.push_back(columns[11] + " = " + std::to_string(npc_types_entry.helmtexture)); update_values.push_back(columns[12] + " = " + std::to_string(npc_types_entry.herosforgemodel)); - update_values.push_back(columns[13] + " = '" + EscapeString(npc_types_entry.size) + "'"); + update_values.push_back(columns[13] + " = " + std::to_string(npc_types_entry.size)); update_values.push_back(columns[14] + " = " + std::to_string(npc_types_entry.hp_regen_rate)); update_values.push_back(columns[15] + " = " + std::to_string(npc_types_entry.mana_regen_rate)); update_values.push_back(columns[16] + " = " + std::to_string(npc_types_entry.loottable_id)); @@ -690,7 +690,7 @@ public: update_values.push_back(columns[48] + " = " + std::to_string(npc_types_entry.prim_melee_type)); update_values.push_back(columns[49] + " = " + std::to_string(npc_types_entry.sec_melee_type)); update_values.push_back(columns[50] + " = " + std::to_string(npc_types_entry.ranged_type)); - update_values.push_back(columns[51] + " = '" + EscapeString(npc_types_entry.runspeed) + "'"); + update_values.push_back(columns[51] + " = " + std::to_string(npc_types_entry.runspeed)); update_values.push_back(columns[52] + " = " + std::to_string(npc_types_entry.MR)); update_values.push_back(columns[53] + " = " + std::to_string(npc_types_entry.CR)); update_values.push_back(columns[54] + " = " + std::to_string(npc_types_entry.DR)); @@ -704,7 +704,7 @@ public: update_values.push_back(columns[62] + " = " + std::to_string(npc_types_entry.AC)); update_values.push_back(columns[63] + " = " + std::to_string(npc_types_entry.npc_aggro)); update_values.push_back(columns[64] + " = " + std::to_string(npc_types_entry.spawn_limit)); - update_values.push_back(columns[65] + " = '" + EscapeString(npc_types_entry.attack_speed) + "'"); + update_values.push_back(columns[65] + " = " + std::to_string(npc_types_entry.attack_speed)); update_values.push_back(columns[66] + " = " + std::to_string(npc_types_entry.attack_delay)); update_values.push_back(columns[67] + " = " + std::to_string(npc_types_entry.findable)); update_values.push_back(columns[68] + " = " + std::to_string(npc_types_entry.STR)); @@ -731,8 +731,8 @@ public: update_values.push_back(columns[89] + " = " + std::to_string(npc_types_entry.underwater)); update_values.push_back(columns[90] + " = " + std::to_string(npc_types_entry.isquest)); update_values.push_back(columns[91] + " = " + std::to_string(npc_types_entry.emoteid)); - update_values.push_back(columns[92] + " = '" + EscapeString(npc_types_entry.spellscale) + "'"); - update_values.push_back(columns[93] + " = '" + EscapeString(npc_types_entry.healscale) + "'"); + update_values.push_back(columns[92] + " = " + std::to_string(npc_types_entry.spellscale)); + update_values.push_back(columns[93] + " = " + std::to_string(npc_types_entry.healscale)); update_values.push_back(columns[94] + " = " + std::to_string(npc_types_entry.no_target_hotkey)); update_values.push_back(columns[95] + " = " + std::to_string(npc_types_entry.raid_target)); update_values.push_back(columns[96] + " = " + std::to_string(npc_types_entry.armtexture)); @@ -793,7 +793,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.texture)); insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); - insert_values.push_back("'" + EscapeString(npc_types_entry.size) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.size)); insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); @@ -831,7 +831,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); - insert_values.push_back("'" + EscapeString(npc_types_entry.runspeed) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.runspeed)); insert_values.push_back(std::to_string(npc_types_entry.MR)); insert_values.push_back(std::to_string(npc_types_entry.CR)); insert_values.push_back(std::to_string(npc_types_entry.DR)); @@ -845,7 +845,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.AC)); insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); - insert_values.push_back("'" + EscapeString(npc_types_entry.attack_speed) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); insert_values.push_back(std::to_string(npc_types_entry.findable)); insert_values.push_back(std::to_string(npc_types_entry.STR)); @@ -872,8 +872,8 @@ public: insert_values.push_back(std::to_string(npc_types_entry.underwater)); insert_values.push_back(std::to_string(npc_types_entry.isquest)); insert_values.push_back(std::to_string(npc_types_entry.emoteid)); - insert_values.push_back("'" + EscapeString(npc_types_entry.spellscale) + "'"); - insert_values.push_back("'" + EscapeString(npc_types_entry.healscale) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.spellscale)); + insert_values.push_back(std::to_string(npc_types_entry.healscale)); insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); insert_values.push_back(std::to_string(npc_types_entry.raid_target)); insert_values.push_back(std::to_string(npc_types_entry.armtexture)); @@ -916,7 +916,7 @@ public: return npc_types_entry; } - npc_types_entry = InstanceListRepository::NewEntity(); + npc_types_entry = NpcTypesRepository::NewEntity(); return npc_types_entry; } @@ -942,7 +942,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.texture)); insert_values.push_back(std::to_string(npc_types_entry.helmtexture)); insert_values.push_back(std::to_string(npc_types_entry.herosforgemodel)); - insert_values.push_back("'" + EscapeString(npc_types_entry.size) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.size)); insert_values.push_back(std::to_string(npc_types_entry.hp_regen_rate)); insert_values.push_back(std::to_string(npc_types_entry.mana_regen_rate)); insert_values.push_back(std::to_string(npc_types_entry.loottable_id)); @@ -980,7 +980,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.prim_melee_type)); insert_values.push_back(std::to_string(npc_types_entry.sec_melee_type)); insert_values.push_back(std::to_string(npc_types_entry.ranged_type)); - insert_values.push_back("'" + EscapeString(npc_types_entry.runspeed) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.runspeed)); insert_values.push_back(std::to_string(npc_types_entry.MR)); insert_values.push_back(std::to_string(npc_types_entry.CR)); insert_values.push_back(std::to_string(npc_types_entry.DR)); @@ -994,7 +994,7 @@ public: insert_values.push_back(std::to_string(npc_types_entry.AC)); insert_values.push_back(std::to_string(npc_types_entry.npc_aggro)); insert_values.push_back(std::to_string(npc_types_entry.spawn_limit)); - insert_values.push_back("'" + EscapeString(npc_types_entry.attack_speed) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.attack_speed)); insert_values.push_back(std::to_string(npc_types_entry.attack_delay)); insert_values.push_back(std::to_string(npc_types_entry.findable)); insert_values.push_back(std::to_string(npc_types_entry.STR)); @@ -1021,8 +1021,8 @@ public: insert_values.push_back(std::to_string(npc_types_entry.underwater)); insert_values.push_back(std::to_string(npc_types_entry.isquest)); insert_values.push_back(std::to_string(npc_types_entry.emoteid)); - insert_values.push_back("'" + EscapeString(npc_types_entry.spellscale) + "'"); - insert_values.push_back("'" + EscapeString(npc_types_entry.healscale) + "'"); + insert_values.push_back(std::to_string(npc_types_entry.spellscale)); + insert_values.push_back(std::to_string(npc_types_entry.healscale)); insert_values.push_back(std::to_string(npc_types_entry.no_target_hotkey)); insert_values.push_back(std::to_string(npc_types_entry.raid_target)); insert_values.push_back(std::to_string(npc_types_entry.armtexture)); @@ -1213,6 +1213,166 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcTypes entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.lastname = row[2]; + entry.level = atoi(row[3]); + entry.race = atoi(row[4]); + entry.class = atoi(row[5]); + entry.bodytype = atoi(row[6]); + entry.hp = atoi(row[7]); + entry.mana = atoi(row[8]); + entry.gender = atoi(row[9]); + entry.texture = atoi(row[10]); + entry.helmtexture = atoi(row[11]); + entry.herosforgemodel = atoi(row[12]); + entry.size = atof(row[13]); + entry.hp_regen_rate = atoi(row[14]); + entry.mana_regen_rate = atoi(row[15]); + entry.loottable_id = atoi(row[16]); + entry.merchant_id = atoi(row[17]); + entry.alt_currency_id = atoi(row[18]); + entry.npc_spells_id = atoi(row[19]); + entry.npc_spells_effects_id = atoi(row[20]); + entry.npc_faction_id = atoi(row[21]); + entry.adventure_template_id = atoi(row[22]); + entry.trap_template = atoi(row[23]); + entry.mindmg = atoi(row[24]); + entry.maxdmg = atoi(row[25]); + entry.attack_count = atoi(row[26]); + entry.npcspecialattks = row[27]; + entry.special_abilities = row[28]; + entry.aggroradius = atoi(row[29]); + entry.assistradius = atoi(row[30]); + entry.face = atoi(row[31]); + entry.luclin_hairstyle = atoi(row[32]); + entry.luclin_haircolor = atoi(row[33]); + entry.luclin_eyecolor = atoi(row[34]); + entry.luclin_eyecolor2 = atoi(row[35]); + entry.luclin_beardcolor = atoi(row[36]); + entry.luclin_beard = atoi(row[37]); + entry.drakkin_heritage = atoi(row[38]); + entry.drakkin_tattoo = atoi(row[39]); + entry.drakkin_details = atoi(row[40]); + entry.armortint_id = atoi(row[41]); + entry.armortint_red = atoi(row[42]); + entry.armortint_green = atoi(row[43]); + entry.armortint_blue = atoi(row[44]); + entry.d_melee_texture1 = atoi(row[45]); + entry.d_melee_texture2 = atoi(row[46]); + entry.ammo_idfile = row[47]; + entry.prim_melee_type = atoi(row[48]); + entry.sec_melee_type = atoi(row[49]); + entry.ranged_type = atoi(row[50]); + entry.runspeed = atof(row[51]); + entry.MR = atoi(row[52]); + entry.CR = atoi(row[53]); + entry.DR = atoi(row[54]); + entry.FR = atoi(row[55]); + entry.PR = atoi(row[56]); + entry.Corrup = atoi(row[57]); + entry.PhR = atoi(row[58]); + entry.see_invis = atoi(row[59]); + entry.see_invis_undead = atoi(row[60]); + entry.qglobal = atoi(row[61]); + entry.AC = atoi(row[62]); + entry.npc_aggro = atoi(row[63]); + entry.spawn_limit = atoi(row[64]); + entry.attack_speed = atof(row[65]); + entry.attack_delay = atoi(row[66]); + entry.findable = atoi(row[67]); + entry.STR = atoi(row[68]); + entry.STA = atoi(row[69]); + entry.DEX = atoi(row[70]); + entry.AGI = atoi(row[71]); + entry._INT = atoi(row[72]); + entry.WIS = atoi(row[73]); + entry.CHA = atoi(row[74]); + entry.see_hide = atoi(row[75]); + entry.see_improved_hide = atoi(row[76]); + entry.trackable = atoi(row[77]); + entry.isbot = atoi(row[78]); + entry.exclude = atoi(row[79]); + entry.ATK = atoi(row[80]); + entry.Accuracy = atoi(row[81]); + entry.Avoidance = atoi(row[82]); + entry.slow_mitigation = atoi(row[83]); + entry.version = atoi(row[84]); + entry.maxlevel = atoi(row[85]); + entry.scalerate = atoi(row[86]); + entry.private_corpse = atoi(row[87]); + entry.unique_spawn_by_name = atoi(row[88]); + entry.underwater = atoi(row[89]); + entry.isquest = atoi(row[90]); + entry.emoteid = atoi(row[91]); + entry.spellscale = atof(row[92]); + entry.healscale = atof(row[93]); + entry.no_target_hotkey = atoi(row[94]); + entry.raid_target = atoi(row[95]); + entry.armtexture = atoi(row[96]); + entry.bracertexture = atoi(row[97]); + entry.handtexture = atoi(row[98]); + entry.legtexture = atoi(row[99]); + entry.feettexture = atoi(row[100]); + entry.light = atoi(row[101]); + entry.walkspeed = atoi(row[102]); + entry.peqid = atoi(row[103]); + entry.unique_ = atoi(row[104]); + entry.fixed = atoi(row[105]); + entry.ignore_despawn = atoi(row[106]); + entry.show_name = atoi(row[107]); + entry.untargetable = atoi(row[108]); + entry.charm_ac = atoi(row[109]); + entry.charm_min_dmg = atoi(row[110]); + entry.charm_max_dmg = atoi(row[111]); + entry.charm_attack_delay = atoi(row[112]); + entry.charm_accuracy_rating = atoi(row[113]); + entry.charm_avoidance_rating = atoi(row[114]); + entry.charm_atk = atoi(row[115]); + entry.skip_global_loot = atoi(row[116]); + entry.rare_spawn = atoi(row[117]); + entry.stuck_behavior = atoi(row[118]); + entry.model = atoi(row[119]); + entry.flymode = atoi(row[120]); + entry.always_aggro = atoi(row[121]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_TYPES_REPOSITORY_H diff --git a/common/repositories/npc_types_tint_repository.h b/common/repositories/npc_types_tint_repository.h index 45471656d..311586c1d 100644 --- a/common/repositories/npc_types_tint_repository.h +++ b/common/repositories/npc_types_tint_repository.h @@ -358,7 +358,7 @@ public: return npc_types_tint_entry; } - npc_types_tint_entry = InstanceListRepository::NewEntity(); + npc_types_tint_entry = NpcTypesTintRepository::NewEntity(); return npc_types_tint_entry; } @@ -469,6 +469,73 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + NpcTypesTint entry{}; + + entry.id = atoi(row[0]); + entry.tint_set_name = row[1]; + entry.red1h = atoi(row[2]); + entry.grn1h = atoi(row[3]); + entry.blu1h = atoi(row[4]); + entry.red2c = atoi(row[5]); + entry.grn2c = atoi(row[6]); + entry.blu2c = atoi(row[7]); + entry.red3a = atoi(row[8]); + entry.grn3a = atoi(row[9]); + entry.blu3a = atoi(row[10]); + entry.red4b = atoi(row[11]); + entry.grn4b = atoi(row[12]); + entry.blu4b = atoi(row[13]); + entry.red5g = atoi(row[14]); + entry.grn5g = atoi(row[15]); + entry.blu5g = atoi(row[16]); + entry.red6l = atoi(row[17]); + entry.grn6l = atoi(row[18]); + entry.blu6l = atoi(row[19]); + entry.red7f = atoi(row[20]); + entry.grn7f = atoi(row[21]); + entry.blu7f = atoi(row[22]); + entry.red8x = atoi(row[23]); + entry.grn8x = atoi(row[24]); + entry.blu8x = atoi(row[25]); + entry.red9x = atoi(row[26]); + entry.grn9x = atoi(row[27]); + entry.blu9x = atoi(row[28]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_NPC_TYPES_TINT_REPOSITORY_H diff --git a/common/repositories/object_contents_repository.h b/common/repositories/object_contents_repository.h index a51b90b50..2c26f1b2f 100644 --- a/common/repositories/object_contents_repository.h +++ b/common/repositories/object_contents_repository.h @@ -254,7 +254,7 @@ public: return object_contents_entry; } - object_contents_entry = InstanceListRepository::NewEntity(); + object_contents_entry = ObjectContentsRepository::NewEntity(); return object_contents_entry; } @@ -330,6 +330,56 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + ObjectContents entry{}; + + entry.zoneid = atoi(row[0]); + entry.parentid = atoi(row[1]); + entry.bagidx = atoi(row[2]); + entry.itemid = atoi(row[3]); + entry.charges = atoi(row[4]); + entry.droptime = row[5]; + entry.augslot1 = atoi(row[6]); + entry.augslot2 = atoi(row[7]); + entry.augslot3 = atoi(row[8]); + entry.augslot4 = atoi(row[9]); + entry.augslot5 = atoi(row[10]); + entry.augslot6 = atoi(row[11]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_OBJECT_CONTENTS_REPOSITORY_H diff --git a/common/repositories/object_repository.h b/common/repositories/object_repository.h index ec9749c9a..87137dbd5 100644 --- a/common/repositories/object_repository.h +++ b/common/repositories/object_repository.h @@ -258,10 +258,10 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(object_entry.zoneid)); update_values.push_back(columns[2] + " = " + std::to_string(object_entry.version)); - update_values.push_back(columns[3] + " = '" + EscapeString(object_entry.xpos) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(object_entry.ypos) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(object_entry.zpos) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(object_entry.heading) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(object_entry.xpos)); + update_values.push_back(columns[4] + " = " + std::to_string(object_entry.ypos)); + update_values.push_back(columns[5] + " = " + std::to_string(object_entry.zpos)); + update_values.push_back(columns[6] + " = " + std::to_string(object_entry.heading)); update_values.push_back(columns[7] + " = " + std::to_string(object_entry.itemid)); update_values.push_back(columns[8] + " = " + std::to_string(object_entry.charges)); update_values.push_back(columns[9] + " = '" + EscapeString(object_entry.objectname) + "'"); @@ -277,9 +277,9 @@ public: update_values.push_back(columns[19] + " = " + std::to_string(object_entry.unknown72)); update_values.push_back(columns[20] + " = " + std::to_string(object_entry.unknown76)); update_values.push_back(columns[21] + " = " + std::to_string(object_entry.unknown84)); - update_values.push_back(columns[22] + " = '" + EscapeString(object_entry.size) + "'"); - update_values.push_back(columns[23] + " = '" + EscapeString(object_entry.tilt_x) + "'"); - update_values.push_back(columns[24] + " = '" + EscapeString(object_entry.tilt_y) + "'"); + update_values.push_back(columns[22] + " = " + std::to_string(object_entry.size)); + update_values.push_back(columns[23] + " = " + std::to_string(object_entry.tilt_x)); + update_values.push_back(columns[24] + " = " + std::to_string(object_entry.tilt_y)); update_values.push_back(columns[25] + " = '" + EscapeString(object_entry.display_name) + "'"); auto results = content_db.QueryDatabase( @@ -303,10 +303,10 @@ public: insert_values.push_back(std::to_string(object_entry.zoneid)); insert_values.push_back(std::to_string(object_entry.version)); - insert_values.push_back("'" + EscapeString(object_entry.xpos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.ypos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.zpos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.heading) + "'"); + insert_values.push_back(std::to_string(object_entry.xpos)); + insert_values.push_back(std::to_string(object_entry.ypos)); + insert_values.push_back(std::to_string(object_entry.zpos)); + insert_values.push_back(std::to_string(object_entry.heading)); insert_values.push_back(std::to_string(object_entry.itemid)); insert_values.push_back(std::to_string(object_entry.charges)); insert_values.push_back("'" + EscapeString(object_entry.objectname) + "'"); @@ -322,9 +322,9 @@ public: insert_values.push_back(std::to_string(object_entry.unknown72)); insert_values.push_back(std::to_string(object_entry.unknown76)); insert_values.push_back(std::to_string(object_entry.unknown84)); - insert_values.push_back("'" + EscapeString(object_entry.size) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.tilt_x) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.tilt_y) + "'"); + insert_values.push_back(std::to_string(object_entry.size)); + insert_values.push_back(std::to_string(object_entry.tilt_x)); + insert_values.push_back(std::to_string(object_entry.tilt_y)); insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); auto results = content_db.QueryDatabase( @@ -340,7 +340,7 @@ public: return object_entry; } - object_entry = InstanceListRepository::NewEntity(); + object_entry = ObjectRepository::NewEntity(); return object_entry; } @@ -356,10 +356,10 @@ public: insert_values.push_back(std::to_string(object_entry.zoneid)); insert_values.push_back(std::to_string(object_entry.version)); - insert_values.push_back("'" + EscapeString(object_entry.xpos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.ypos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.zpos) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.heading) + "'"); + insert_values.push_back(std::to_string(object_entry.xpos)); + insert_values.push_back(std::to_string(object_entry.ypos)); + insert_values.push_back(std::to_string(object_entry.zpos)); + insert_values.push_back(std::to_string(object_entry.heading)); insert_values.push_back(std::to_string(object_entry.itemid)); insert_values.push_back(std::to_string(object_entry.charges)); insert_values.push_back("'" + EscapeString(object_entry.objectname) + "'"); @@ -375,9 +375,9 @@ public: insert_values.push_back(std::to_string(object_entry.unknown72)); insert_values.push_back(std::to_string(object_entry.unknown76)); insert_values.push_back(std::to_string(object_entry.unknown84)); - insert_values.push_back("'" + EscapeString(object_entry.size) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.tilt_x) + "'"); - insert_values.push_back("'" + EscapeString(object_entry.tilt_y) + "'"); + insert_values.push_back(std::to_string(object_entry.size)); + insert_values.push_back(std::to_string(object_entry.tilt_x)); + insert_values.push_back(std::to_string(object_entry.tilt_y)); insert_values.push_back("'" + EscapeString(object_entry.display_name) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -445,6 +445,70 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Object entry{}; + + entry.id = atoi(row[0]); + entry.zoneid = atoi(row[1]); + entry.version = atoi(row[2]); + entry.xpos = atof(row[3]); + entry.ypos = atof(row[4]); + entry.zpos = atof(row[5]); + entry.heading = atof(row[6]); + entry.itemid = atoi(row[7]); + entry.charges = atoi(row[8]); + entry.objectname = row[9]; + entry.type = atoi(row[10]); + entry.icon = atoi(row[11]); + entry.unknown08 = atoi(row[12]); + entry.unknown10 = atoi(row[13]); + entry.unknown20 = atoi(row[14]); + entry.unknown24 = atoi(row[15]); + entry.unknown60 = atoi(row[16]); + entry.unknown64 = atoi(row[17]); + entry.unknown68 = atoi(row[18]); + entry.unknown72 = atoi(row[19]); + entry.unknown76 = atoi(row[20]); + entry.unknown84 = atoi(row[21]); + entry.size = atof(row[22]); + entry.tilt_x = atof(row[23]); + entry.tilt_y = atof(row[24]); + entry.display_name = row[25]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_OBJECT_REPOSITORY_H diff --git a/common/repositories/perl_event_export_settings_repository.h b/common/repositories/perl_event_export_settings_repository.h index de4bb5a76..ba13a315a 100644 --- a/common/repositories/perl_event_export_settings_repository.h +++ b/common/repositories/perl_event_export_settings_repository.h @@ -226,7 +226,7 @@ public: return perl_event_export_settings_entry; } - perl_event_export_settings_entry = InstanceListRepository::NewEntity(); + perl_event_export_settings_entry = PerlEventExportSettingsRepository::NewEntity(); return perl_event_export_settings_entry; } @@ -293,6 +293,51 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + PerlEventExportSettings entry{}; + + entry.event_id = atoi(row[0]); + entry.event_description = row[1]; + entry.export_qglobals = atoi(row[2]); + entry.export_mob = atoi(row[3]); + entry.export_zone = atoi(row[4]); + entry.export_item = atoi(row[5]); + entry.export_event = atoi(row[6]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PERL_EVENT_EXPORT_SETTINGS_REPOSITORY_H diff --git a/common/repositories/petitions_repository.h b/common/repositories/petitions_repository.h index 150aecd31..4bd262644 100644 --- a/common/repositories/petitions_repository.h +++ b/common/repositories/petitions_repository.h @@ -280,7 +280,7 @@ public: return petitions_entry; } - petitions_entry = InstanceListRepository::NewEntity(); + petitions_entry = PetitionsRepository::NewEntity(); return petitions_entry; } @@ -365,6 +365,60 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Petitions entry{}; + + entry.dib = atoi(row[0]); + entry.petid = atoi(row[1]); + entry.charname = row[2]; + entry.accountname = row[3]; + entry.lastgm = row[4]; + entry.petitiontext = row[5]; + entry.gmtext = row[6]; + entry.zone = row[7]; + entry.urgency = atoi(row[8]); + entry.charclass = atoi(row[9]); + entry.charrace = atoi(row[10]); + entry.charlevel = atoi(row[11]); + entry.checkouts = atoi(row[12]); + entry.unavailables = atoi(row[13]); + entry.ischeckedout = atoi(row[14]); + entry.senttime = atoi(row[15]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PETITIONS_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_entries_repository.h b/common/repositories/pets_equipmentset_entries_repository.h index 23b155de3..f073eadca 100644 --- a/common/repositories/pets_equipmentset_entries_repository.h +++ b/common/repositories/pets_equipmentset_entries_repository.h @@ -200,7 +200,7 @@ public: return pets_equipmentset_entries_entry; } - pets_equipmentset_entries_entry = InstanceListRepository::NewEntity(); + pets_equipmentset_entries_entry = PetsEquipmentsetEntriesRepository::NewEntity(); return pets_equipmentset_entries_entry; } @@ -258,6 +258,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + PetsEquipmentsetEntries entry{}; + + entry.set_id = atoi(row[0]); + entry.slot = atoi(row[1]); + entry.item_id = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PETS_EQUIPMENTSET_ENTRIES_REPOSITORY_H diff --git a/common/repositories/pets_equipmentset_repository.h b/common/repositories/pets_equipmentset_repository.h index e9c4a3f10..28db32734 100644 --- a/common/repositories/pets_equipmentset_repository.h +++ b/common/repositories/pets_equipmentset_repository.h @@ -202,7 +202,7 @@ public: return pets_equipmentset_entry; } - pets_equipmentset_entry = InstanceListRepository::NewEntity(); + pets_equipmentset_entry = PetsEquipmentsetRepository::NewEntity(); return pets_equipmentset_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + PetsEquipmentset entry{}; + + entry.set_id = atoi(row[0]); + entry.setname = row[1]; + entry.nested_set = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PETS_EQUIPMENTSET_REPOSITORY_H diff --git a/common/repositories/pets_repository.h b/common/repositories/pets_repository.h index 3a5f7c7ad..56947b5d1 100644 --- a/common/repositories/pets_repository.h +++ b/common/repositories/pets_repository.h @@ -230,7 +230,7 @@ public: return pets_entry; } - pets_entry = InstanceListRepository::NewEntity(); + pets_entry = PetsRepository::NewEntity(); return pets_entry; } @@ -298,6 +298,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Pets entry{}; + + entry.type = row[0]; + entry.petpower = atoi(row[1]); + entry.npcID = atoi(row[2]); + entry.temp = atoi(row[3]); + entry.petcontrol = atoi(row[4]); + entry.petnaming = atoi(row[5]); + entry.monsterflag = atoi(row[6]); + entry.equipmentset = atoi(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PETS_REPOSITORY_H diff --git a/common/repositories/player_titlesets_repository.h b/common/repositories/player_titlesets_repository.h index 189feec6a..56ab065fd 100644 --- a/common/repositories/player_titlesets_repository.h +++ b/common/repositories/player_titlesets_repository.h @@ -202,7 +202,7 @@ public: return player_titlesets_entry; } - player_titlesets_entry = InstanceListRepository::NewEntity(); + player_titlesets_entry = PlayerTitlesetsRepository::NewEntity(); return player_titlesets_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + PlayerTitlesets entry{}; + + entry.id = atoi(row[0]); + entry.char_id = atoi(row[1]); + entry.title_set = atoi(row[2]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PLAYER_TITLESETS_REPOSITORY_H diff --git a/common/repositories/proximities_repository.h b/common/repositories/proximities_repository.h index 8b0bbd3ec..23ea49582 100644 --- a/common/repositories/proximities_repository.h +++ b/common/repositories/proximities_repository.h @@ -184,12 +184,12 @@ public: auto columns = Columns(); - update_values.push_back(columns[2] + " = '" + EscapeString(proximities_entry.minx) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(proximities_entry.maxx) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(proximities_entry.miny) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(proximities_entry.maxy) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(proximities_entry.minz) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(proximities_entry.maxz) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(proximities_entry.minx)); + update_values.push_back(columns[3] + " = " + std::to_string(proximities_entry.maxx)); + update_values.push_back(columns[4] + " = " + std::to_string(proximities_entry.miny)); + update_values.push_back(columns[5] + " = " + std::to_string(proximities_entry.maxy)); + update_values.push_back(columns[6] + " = " + std::to_string(proximities_entry.minz)); + update_values.push_back(columns[7] + " = " + std::to_string(proximities_entry.maxz)); auto results = content_db.QueryDatabase( fmt::format( @@ -210,12 +210,12 @@ public: { std::vector insert_values; - insert_values.push_back("'" + EscapeString(proximities_entry.minx) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxx) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.miny) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxy) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.minz) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxz) + "'"); + insert_values.push_back(std::to_string(proximities_entry.minx)); + insert_values.push_back(std::to_string(proximities_entry.maxx)); + insert_values.push_back(std::to_string(proximities_entry.miny)); + insert_values.push_back(std::to_string(proximities_entry.maxy)); + insert_values.push_back(std::to_string(proximities_entry.minz)); + insert_values.push_back(std::to_string(proximities_entry.maxz)); auto results = content_db.QueryDatabase( fmt::format( @@ -230,7 +230,7 @@ public: return proximities_entry; } - proximities_entry = InstanceListRepository::NewEntity(); + proximities_entry = ProximitiesRepository::NewEntity(); return proximities_entry; } @@ -244,12 +244,12 @@ public: for (auto &proximities_entry: proximities_entries) { std::vector insert_values; - insert_values.push_back("'" + EscapeString(proximities_entry.minx) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxx) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.miny) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxy) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.minz) + "'"); - insert_values.push_back("'" + EscapeString(proximities_entry.maxz) + "'"); + insert_values.push_back(std::to_string(proximities_entry.minx)); + insert_values.push_back(std::to_string(proximities_entry.maxx)); + insert_values.push_back(std::to_string(proximities_entry.miny)); + insert_values.push_back(std::to_string(proximities_entry.maxy)); + insert_values.push_back(std::to_string(proximities_entry.minz)); + insert_values.push_back(std::to_string(proximities_entry.maxz)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -298,6 +298,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Proximities entry{}; + + entry.zoneid = atoi(row[0]); + entry.exploreid = atoi(row[1]); + entry.minx = atof(row[2]); + entry.maxx = atof(row[3]); + entry.miny = atof(row[4]); + entry.maxy = atof(row[5]); + entry.minz = atof(row[6]); + entry.maxz = atof(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_PROXIMITIES_REPOSITORY_H diff --git a/common/repositories/quest_globals_repository.h b/common/repositories/quest_globals_repository.h index b5ed67ace..60f968667 100644 --- a/common/repositories/quest_globals_repository.h +++ b/common/repositories/quest_globals_repository.h @@ -214,7 +214,7 @@ public: return quest_globals_entry; } - quest_globals_entry = InstanceListRepository::NewEntity(); + quest_globals_entry = QuestGlobalsRepository::NewEntity(); return quest_globals_entry; } @@ -276,6 +276,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + QuestGlobals entry{}; + + entry.charid = atoi(row[0]); + entry.npcid = atoi(row[1]); + entry.zoneid = atoi(row[2]); + entry.name = row[3]; + entry.value = row[4]; + entry.expdate = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_QUEST_GLOBALS_REPOSITORY_H diff --git a/common/repositories/raid_details_repository.h b/common/repositories/raid_details_repository.h index 53357adaf..e1c78739d 100644 --- a/common/repositories/raid_details_repository.h +++ b/common/repositories/raid_details_repository.h @@ -208,7 +208,7 @@ public: return raid_details_entry; } - raid_details_entry = InstanceListRepository::NewEntity(); + raid_details_entry = RaidDetailsRepository::NewEntity(); return raid_details_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + RaidDetails entry{}; + + entry.raidid = atoi(row[0]); + entry.loottype = atoi(row[1]); + entry.locked = atoi(row[2]); + entry.motd = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_RAID_DETAILS_REPOSITORY_H diff --git a/common/repositories/raid_members_repository.h b/common/repositories/raid_members_repository.h index 7072d52f1..505f309d3 100644 --- a/common/repositories/raid_members_repository.h +++ b/common/repositories/raid_members_repository.h @@ -238,7 +238,7 @@ public: return raid_members_entry; } - raid_members_entry = InstanceListRepository::NewEntity(); + raid_members_entry = RaidMembersRepository::NewEntity(); return raid_members_entry; } @@ -309,6 +309,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + RaidMembers entry{}; + + entry.raidid = atoi(row[0]); + entry.charid = atoi(row[1]); + entry.groupid = atoi(row[2]); + entry._class = atoi(row[3]); + entry.level = atoi(row[4]); + entry.name = row[5]; + entry.isgroupleader = atoi(row[6]); + entry.israidleader = atoi(row[7]); + entry.islooter = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_RAID_MEMBERS_REPOSITORY_H diff --git a/common/repositories/reports_repository.h b/common/repositories/reports_repository.h index b99caa8f6..c336ebda5 100644 --- a/common/repositories/reports_repository.h +++ b/common/repositories/reports_repository.h @@ -208,7 +208,7 @@ public: return reports_entry; } - reports_entry = InstanceListRepository::NewEntity(); + reports_entry = ReportsRepository::NewEntity(); return reports_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Reports entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.reported = row[2]; + entry.reported_text = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_REPORTS_REPOSITORY_H diff --git a/common/repositories/respawn_times_repository.h b/common/repositories/respawn_times_repository.h index 2e6c8e250..4cf47bbd3 100644 --- a/common/repositories/respawn_times_repository.h +++ b/common/repositories/respawn_times_repository.h @@ -206,7 +206,7 @@ public: return respawn_times_entry; } - respawn_times_entry = InstanceListRepository::NewEntity(); + respawn_times_entry = RespawnTimesRepository::NewEntity(); return respawn_times_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + RespawnTimes entry{}; + + entry.id = atoi(row[0]); + entry.start = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.instance_id = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_RESPAWN_TIMES_REPOSITORY_H diff --git a/common/repositories/rule_sets_repository.h b/common/repositories/rule_sets_repository.h index 59b6a3102..9aea58335 100644 --- a/common/repositories/rule_sets_repository.h +++ b/common/repositories/rule_sets_repository.h @@ -196,7 +196,7 @@ public: return rule_sets_entry; } - rule_sets_entry = InstanceListRepository::NewEntity(); + rule_sets_entry = RuleSetsRepository::NewEntity(); return rule_sets_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + RuleSets entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.name = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_RULE_SETS_REPOSITORY_H diff --git a/common/repositories/rule_values_repository.h b/common/repositories/rule_values_repository.h index dcf67ba46..3e87fc53c 100644 --- a/common/repositories/rule_values_repository.h +++ b/common/repositories/rule_values_repository.h @@ -206,7 +206,7 @@ public: return rule_values_entry; } - rule_values_entry = InstanceListRepository::NewEntity(); + rule_values_entry = RuleValuesRepository::NewEntity(); return rule_values_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + RuleValues entry{}; + + entry.ruleset_id = atoi(row[0]); + entry.rule_name = row[1]; + entry.rule_value = row[2]; + entry.notes = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_RULE_VALUES_REPOSITORY_H diff --git a/common/repositories/saylink_repository.h b/common/repositories/saylink_repository.h index 0cd185bc3..2e8bb2924 100644 --- a/common/repositories/saylink_repository.h +++ b/common/repositories/saylink_repository.h @@ -196,7 +196,7 @@ public: return saylink_entry; } - saylink_entry = InstanceListRepository::NewEntity(); + saylink_entry = SaylinkRepository::NewEntity(); return saylink_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Saylink entry{}; + + entry.id = atoi(row[0]); + entry.phrase = row[1]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SAYLINK_REPOSITORY_H diff --git a/common/repositories/skill_caps_repository.h b/common/repositories/skill_caps_repository.h index a4129acdb..d059bc40b 100644 --- a/common/repositories/skill_caps_repository.h +++ b/common/repositories/skill_caps_repository.h @@ -208,7 +208,7 @@ public: return skill_caps_entry; } - skill_caps_entry = InstanceListRepository::NewEntity(); + skill_caps_entry = SkillCapsRepository::NewEntity(); return skill_caps_entry; } @@ -268,6 +268,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SkillCaps entry{}; + + entry.skillID = atoi(row[0]); + entry.class = atoi(row[1]); + entry.level = atoi(row[2]); + entry.cap = atoi(row[3]); + entry.class_ = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SKILL_CAPS_REPOSITORY_H diff --git a/common/repositories/spawn2_repository.h b/common/repositories/spawn2_repository.h index cf96b1f68..34ba80c28 100644 --- a/common/repositories/spawn2_repository.h +++ b/common/repositories/spawn2_repository.h @@ -215,10 +215,10 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(spawn2_entry.spawngroupID)); update_values.push_back(columns[2] + " = '" + EscapeString(spawn2_entry.zone) + "'"); update_values.push_back(columns[3] + " = " + std::to_string(spawn2_entry.version)); - update_values.push_back(columns[4] + " = '" + EscapeString(spawn2_entry.x) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(spawn2_entry.y) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(spawn2_entry.z) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(spawn2_entry.heading) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(spawn2_entry.x)); + update_values.push_back(columns[5] + " = " + std::to_string(spawn2_entry.y)); + update_values.push_back(columns[6] + " = " + std::to_string(spawn2_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(spawn2_entry.heading)); update_values.push_back(columns[8] + " = " + std::to_string(spawn2_entry.respawntime)); update_values.push_back(columns[9] + " = " + std::to_string(spawn2_entry.variance)); update_values.push_back(columns[10] + " = " + std::to_string(spawn2_entry.pathgrid)); @@ -249,10 +249,10 @@ public: insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn2_entry.version)); - insert_values.push_back("'" + EscapeString(spawn2_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.heading) + "'"); + insert_values.push_back(std::to_string(spawn2_entry.x)); + insert_values.push_back(std::to_string(spawn2_entry.y)); + insert_values.push_back(std::to_string(spawn2_entry.z)); + insert_values.push_back(std::to_string(spawn2_entry.heading)); insert_values.push_back(std::to_string(spawn2_entry.respawntime)); insert_values.push_back(std::to_string(spawn2_entry.variance)); insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); @@ -274,7 +274,7 @@ public: return spawn2_entry; } - spawn2_entry = InstanceListRepository::NewEntity(); + spawn2_entry = Spawn2Repository::NewEntity(); return spawn2_entry; } @@ -291,10 +291,10 @@ public: insert_values.push_back(std::to_string(spawn2_entry.spawngroupID)); insert_values.push_back("'" + EscapeString(spawn2_entry.zone) + "'"); insert_values.push_back(std::to_string(spawn2_entry.version)); - insert_values.push_back("'" + EscapeString(spawn2_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(spawn2_entry.heading) + "'"); + insert_values.push_back(std::to_string(spawn2_entry.x)); + insert_values.push_back(std::to_string(spawn2_entry.y)); + insert_values.push_back(std::to_string(spawn2_entry.z)); + insert_values.push_back(std::to_string(spawn2_entry.heading)); insert_values.push_back(std::to_string(spawn2_entry.respawntime)); insert_values.push_back(std::to_string(spawn2_entry.variance)); insert_values.push_back(std::to_string(spawn2_entry.pathgrid)); @@ -357,6 +357,59 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Spawn2 entry{}; + + entry.id = atoi(row[0]); + entry.spawngroupID = atoi(row[1]); + entry.zone = row[2]; + entry.version = atoi(row[3]); + entry.x = atof(row[4]); + entry.y = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.respawntime = atoi(row[8]); + entry.variance = atoi(row[9]); + entry.pathgrid = atoi(row[10]); + entry._condition = atoi(row[11]); + entry.cond_value = atoi(row[12]); + entry.enabled = atoi(row[13]); + entry.animation = atoi(row[14]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWN2_REPOSITORY_H diff --git a/common/repositories/spawn_condition_values_repository.h b/common/repositories/spawn_condition_values_repository.h index 8a6bbbc7f..0fb3b20ca 100644 --- a/common/repositories/spawn_condition_values_repository.h +++ b/common/repositories/spawn_condition_values_repository.h @@ -204,7 +204,7 @@ public: return spawn_condition_values_entry; } - spawn_condition_values_entry = InstanceListRepository::NewEntity(); + spawn_condition_values_entry = SpawnConditionValuesRepository::NewEntity(); return spawn_condition_values_entry; } @@ -263,6 +263,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnConditionValues entry{}; + + entry.id = atoi(row[0]); + entry.value = atoi(row[1]); + entry.zone = row[2]; + entry.instance_id = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWN_CONDITION_VALUES_REPOSITORY_H diff --git a/common/repositories/spawn_conditions_repository.h b/common/repositories/spawn_conditions_repository.h index 63a8ef8e4..46c1e965d 100644 --- a/common/repositories/spawn_conditions_repository.h +++ b/common/repositories/spawn_conditions_repository.h @@ -212,7 +212,7 @@ public: return spawn_conditions_entry; } - spawn_conditions_entry = InstanceListRepository::NewEntity(); + spawn_conditions_entry = SpawnConditionsRepository::NewEntity(); return spawn_conditions_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnConditions entry{}; + + entry.zone = row[0]; + entry.id = atoi(row[1]); + entry.value = atoi(row[2]); + entry.onchange = atoi(row[3]); + entry.name = row[4]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWN_CONDITIONS_REPOSITORY_H diff --git a/common/repositories/spawn_events_repository.h b/common/repositories/spawn_events_repository.h index bd03e80ec..760d71f9c 100644 --- a/common/repositories/spawn_events_repository.h +++ b/common/repositories/spawn_events_repository.h @@ -268,7 +268,7 @@ public: return spawn_events_entry; } - spawn_events_entry = InstanceListRepository::NewEntity(); + spawn_events_entry = SpawnEventsRepository::NewEntity(); return spawn_events_entry; } @@ -349,6 +349,58 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpawnEvents entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.cond_id = atoi(row[2]); + entry.name = row[3]; + entry.period = atoi(row[4]); + entry.next_minute = atoi(row[5]); + entry.next_hour = atoi(row[6]); + entry.next_day = atoi(row[7]); + entry.next_month = atoi(row[8]); + entry.next_year = atoi(row[9]); + entry.enabled = atoi(row[10]); + entry.action = atoi(row[11]); + entry.argument = atoi(row[12]); + entry.strict = atoi(row[13]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWN_EVENTS_REPOSITORY_H diff --git a/common/repositories/spawnentry_repository.h b/common/repositories/spawnentry_repository.h index eb16601d0..fe3ca4b35 100644 --- a/common/repositories/spawnentry_repository.h +++ b/common/repositories/spawnentry_repository.h @@ -206,7 +206,7 @@ public: return spawnentry_entry; } - spawnentry_entry = InstanceListRepository::NewEntity(); + spawnentry_entry = SpawnentryRepository::NewEntity(); return spawnentry_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Spawnentry entry{}; + + entry.spawngroupID = atoi(row[0]); + entry.npcID = atoi(row[1]); + entry.chance = atoi(row[2]); + entry.condition_value_filter = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWNENTRY_REPOSITORY_H diff --git a/common/repositories/spawngroup_repository.h b/common/repositories/spawngroup_repository.h index 356ccd0ad..74133ccf4 100644 --- a/common/repositories/spawngroup_repository.h +++ b/common/repositories/spawngroup_repository.h @@ -206,11 +206,11 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(spawngroup_entry.name) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(spawngroup_entry.spawn_limit)); - update_values.push_back(columns[3] + " = '" + EscapeString(spawngroup_entry.dist) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(spawngroup_entry.max_x) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(spawngroup_entry.min_x) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(spawngroup_entry.max_y) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(spawngroup_entry.min_y) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(spawngroup_entry.dist)); + update_values.push_back(columns[4] + " = " + std::to_string(spawngroup_entry.max_x)); + update_values.push_back(columns[5] + " = " + std::to_string(spawngroup_entry.min_x)); + update_values.push_back(columns[6] + " = " + std::to_string(spawngroup_entry.max_y)); + update_values.push_back(columns[7] + " = " + std::to_string(spawngroup_entry.min_y)); update_values.push_back(columns[8] + " = " + std::to_string(spawngroup_entry.delay)); update_values.push_back(columns[9] + " = " + std::to_string(spawngroup_entry.mindelay)); update_values.push_back(columns[10] + " = " + std::to_string(spawngroup_entry.despawn)); @@ -238,11 +238,11 @@ public: insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); - insert_values.push_back("'" + EscapeString(spawngroup_entry.dist) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.max_x) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.min_x) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.max_y) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.min_y) + "'"); + insert_values.push_back(std::to_string(spawngroup_entry.dist)); + insert_values.push_back(std::to_string(spawngroup_entry.max_x)); + insert_values.push_back(std::to_string(spawngroup_entry.min_x)); + insert_values.push_back(std::to_string(spawngroup_entry.max_y)); + insert_values.push_back(std::to_string(spawngroup_entry.min_y)); insert_values.push_back(std::to_string(spawngroup_entry.delay)); insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); insert_values.push_back(std::to_string(spawngroup_entry.despawn)); @@ -262,7 +262,7 @@ public: return spawngroup_entry; } - spawngroup_entry = InstanceListRepository::NewEntity(); + spawngroup_entry = SpawngroupRepository::NewEntity(); return spawngroup_entry; } @@ -278,11 +278,11 @@ public: insert_values.push_back("'" + EscapeString(spawngroup_entry.name) + "'"); insert_values.push_back(std::to_string(spawngroup_entry.spawn_limit)); - insert_values.push_back("'" + EscapeString(spawngroup_entry.dist) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.max_x) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.min_x) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.max_y) + "'"); - insert_values.push_back("'" + EscapeString(spawngroup_entry.min_y) + "'"); + insert_values.push_back(std::to_string(spawngroup_entry.dist)); + insert_values.push_back(std::to_string(spawngroup_entry.max_x)); + insert_values.push_back(std::to_string(spawngroup_entry.min_x)); + insert_values.push_back(std::to_string(spawngroup_entry.max_y)); + insert_values.push_back(std::to_string(spawngroup_entry.min_y)); insert_values.push_back(std::to_string(spawngroup_entry.delay)); insert_values.push_back(std::to_string(spawngroup_entry.mindelay)); insert_values.push_back(std::to_string(spawngroup_entry.despawn)); @@ -341,6 +341,57 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Spawngroup entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.spawn_limit = atoi(row[2]); + entry.dist = atof(row[3]); + entry.max_x = atof(row[4]); + entry.min_x = atof(row[5]); + entry.max_y = atof(row[6]); + entry.min_y = atof(row[7]); + entry.delay = atoi(row[8]); + entry.mindelay = atoi(row[9]); + entry.despawn = atoi(row[10]); + entry.despawn_timer = atoi(row[11]); + entry.wp_spawns = atoi(row[12]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPAWNGROUP_REPOSITORY_H diff --git a/common/repositories/spell_buckets_repository.h b/common/repositories/spell_buckets_repository.h index c923234c0..1462f1ea5 100644 --- a/common/repositories/spell_buckets_repository.h +++ b/common/repositories/spell_buckets_repository.h @@ -202,7 +202,7 @@ public: return spell_buckets_entry; } - spell_buckets_entry = InstanceListRepository::NewEntity(); + spell_buckets_entry = SpellBucketsRepository::NewEntity(); return spell_buckets_entry; } @@ -261,6 +261,47 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpellBuckets entry{}; + + entry.spellid = atoi(row[0]); + entry.key = row[1]; + entry.value = row[2]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPELL_BUCKETS_REPOSITORY_H diff --git a/common/repositories/spell_globals_repository.h b/common/repositories/spell_globals_repository.h index 2091a6486..d94cfa052 100644 --- a/common/repositories/spell_globals_repository.h +++ b/common/repositories/spell_globals_repository.h @@ -208,7 +208,7 @@ public: return spell_globals_entry; } - spell_globals_entry = InstanceListRepository::NewEntity(); + spell_globals_entry = SpellGlobalsRepository::NewEntity(); return spell_globals_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpellGlobals entry{}; + + entry.spellid = atoi(row[0]); + entry.spell_name = row[1]; + entry.qglobal = row[2]; + entry.value = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPELL_GLOBALS_REPOSITORY_H diff --git a/common/repositories/spells_new_repository.h b/common/repositories/spells_new_repository.h index d9ff5b920..19f3f51d5 100644 --- a/common/repositories/spells_new_repository.h +++ b/common/repositories/spells_new_repository.h @@ -1326,10 +1326,10 @@ public: update_values.push_back(columns[224] + " = " + std::to_string(spells_new_entry.persistdeath)); update_values.push_back(columns[225] + " = " + std::to_string(spells_new_entry.field225)); update_values.push_back(columns[226] + " = " + std::to_string(spells_new_entry.field226)); - update_values.push_back(columns[227] + " = '" + EscapeString(spells_new_entry.min_dist) + "'"); - update_values.push_back(columns[228] + " = '" + EscapeString(spells_new_entry.min_dist_mod) + "'"); - update_values.push_back(columns[229] + " = '" + EscapeString(spells_new_entry.max_dist) + "'"); - update_values.push_back(columns[230] + " = '" + EscapeString(spells_new_entry.max_dist_mod) + "'"); + update_values.push_back(columns[227] + " = " + std::to_string(spells_new_entry.min_dist)); + update_values.push_back(columns[228] + " = " + std::to_string(spells_new_entry.min_dist_mod)); + update_values.push_back(columns[229] + " = " + std::to_string(spells_new_entry.max_dist)); + update_values.push_back(columns[230] + " = " + std::to_string(spells_new_entry.max_dist_mod)); update_values.push_back(columns[231] + " = " + std::to_string(spells_new_entry.min_range)); update_values.push_back(columns[232] + " = " + std::to_string(spells_new_entry.field232)); update_values.push_back(columns[233] + " = " + std::to_string(spells_new_entry.field233)); @@ -1582,10 +1582,10 @@ public: insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); insert_values.push_back(std::to_string(spells_new_entry.field225)); insert_values.push_back(std::to_string(spells_new_entry.field226)); - insert_values.push_back("'" + EscapeString(spells_new_entry.min_dist) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.min_dist_mod) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.max_dist) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.max_dist_mod) + "'"); + insert_values.push_back(std::to_string(spells_new_entry.min_dist)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); insert_values.push_back(std::to_string(spells_new_entry.min_range)); insert_values.push_back(std::to_string(spells_new_entry.field232)); insert_values.push_back(std::to_string(spells_new_entry.field233)); @@ -1606,7 +1606,7 @@ public: return spells_new_entry; } - spells_new_entry = InstanceListRepository::NewEntity(); + spells_new_entry = SpellsNewRepository::NewEntity(); return spells_new_entry; } @@ -1846,10 +1846,10 @@ public: insert_values.push_back(std::to_string(spells_new_entry.persistdeath)); insert_values.push_back(std::to_string(spells_new_entry.field225)); insert_values.push_back(std::to_string(spells_new_entry.field226)); - insert_values.push_back("'" + EscapeString(spells_new_entry.min_dist) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.min_dist_mod) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.max_dist) + "'"); - insert_values.push_back("'" + EscapeString(spells_new_entry.max_dist_mod) + "'"); + insert_values.push_back(std::to_string(spells_new_entry.min_dist)); + insert_values.push_back(std::to_string(spells_new_entry.min_dist_mod)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist)); + insert_values.push_back(std::to_string(spells_new_entry.max_dist_mod)); insert_values.push_back(std::to_string(spells_new_entry.min_range)); insert_values.push_back(std::to_string(spells_new_entry.field232)); insert_values.push_back(std::to_string(spells_new_entry.field233)); @@ -2133,6 +2133,281 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + SpellsNew entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1]; + entry.player_1 = row[2]; + entry.teleport_zone = row[3]; + entry.you_cast = row[4]; + entry.other_casts = row[5]; + entry.cast_on_you = row[6]; + entry.cast_on_other = row[7]; + entry.spell_fades = row[8]; + entry.range = atoi(row[9]); + entry.aoerange = atoi(row[10]); + entry.pushback = atoi(row[11]); + entry.pushup = atoi(row[12]); + entry.cast_time = atoi(row[13]); + entry.recovery_time = atoi(row[14]); + entry.recast_time = atoi(row[15]); + entry.buffdurationformula = atoi(row[16]); + entry.buffduration = atoi(row[17]); + entry.AEDuration = atoi(row[18]); + entry.mana = atoi(row[19]); + entry.effect_base_value1 = atoi(row[20]); + entry.effect_base_value2 = atoi(row[21]); + entry.effect_base_value3 = atoi(row[22]); + entry.effect_base_value4 = atoi(row[23]); + entry.effect_base_value5 = atoi(row[24]); + entry.effect_base_value6 = atoi(row[25]); + entry.effect_base_value7 = atoi(row[26]); + entry.effect_base_value8 = atoi(row[27]); + entry.effect_base_value9 = atoi(row[28]); + entry.effect_base_value10 = atoi(row[29]); + entry.effect_base_value11 = atoi(row[30]); + entry.effect_base_value12 = atoi(row[31]); + entry.effect_limit_value1 = atoi(row[32]); + entry.effect_limit_value2 = atoi(row[33]); + entry.effect_limit_value3 = atoi(row[34]); + entry.effect_limit_value4 = atoi(row[35]); + entry.effect_limit_value5 = atoi(row[36]); + entry.effect_limit_value6 = atoi(row[37]); + entry.effect_limit_value7 = atoi(row[38]); + entry.effect_limit_value8 = atoi(row[39]); + entry.effect_limit_value9 = atoi(row[40]); + entry.effect_limit_value10 = atoi(row[41]); + entry.effect_limit_value11 = atoi(row[42]); + entry.effect_limit_value12 = atoi(row[43]); + entry.max1 = atoi(row[44]); + entry.max2 = atoi(row[45]); + entry.max3 = atoi(row[46]); + entry.max4 = atoi(row[47]); + entry.max5 = atoi(row[48]); + entry.max6 = atoi(row[49]); + entry.max7 = atoi(row[50]); + entry.max8 = atoi(row[51]); + entry.max9 = atoi(row[52]); + entry.max10 = atoi(row[53]); + entry.max11 = atoi(row[54]); + entry.max12 = atoi(row[55]); + entry.icon = atoi(row[56]); + entry.memicon = atoi(row[57]); + entry.components1 = atoi(row[58]); + entry.components2 = atoi(row[59]); + entry.components3 = atoi(row[60]); + entry.components4 = atoi(row[61]); + entry.component_counts1 = atoi(row[62]); + entry.component_counts2 = atoi(row[63]); + entry.component_counts3 = atoi(row[64]); + entry.component_counts4 = atoi(row[65]); + entry.NoexpendReagent1 = atoi(row[66]); + entry.NoexpendReagent2 = atoi(row[67]); + entry.NoexpendReagent3 = atoi(row[68]); + entry.NoexpendReagent4 = atoi(row[69]); + entry.formula1 = atoi(row[70]); + entry.formula2 = atoi(row[71]); + entry.formula3 = atoi(row[72]); + entry.formula4 = atoi(row[73]); + entry.formula5 = atoi(row[74]); + entry.formula6 = atoi(row[75]); + entry.formula7 = atoi(row[76]); + entry.formula8 = atoi(row[77]); + entry.formula9 = atoi(row[78]); + entry.formula10 = atoi(row[79]); + entry.formula11 = atoi(row[80]); + entry.formula12 = atoi(row[81]); + entry.LightType = atoi(row[82]); + entry.goodEffect = atoi(row[83]); + entry.Activated = atoi(row[84]); + entry.resisttype = atoi(row[85]); + entry.effectid1 = atoi(row[86]); + entry.effectid2 = atoi(row[87]); + entry.effectid3 = atoi(row[88]); + entry.effectid4 = atoi(row[89]); + entry.effectid5 = atoi(row[90]); + entry.effectid6 = atoi(row[91]); + entry.effectid7 = atoi(row[92]); + entry.effectid8 = atoi(row[93]); + entry.effectid9 = atoi(row[94]); + entry.effectid10 = atoi(row[95]); + entry.effectid11 = atoi(row[96]); + entry.effectid12 = atoi(row[97]); + entry.targettype = atoi(row[98]); + entry.basediff = atoi(row[99]); + entry.skill = atoi(row[100]); + entry.zonetype = atoi(row[101]); + entry.EnvironmentType = atoi(row[102]); + entry.TimeOfDay = atoi(row[103]); + entry.classes1 = atoi(row[104]); + entry.classes2 = atoi(row[105]); + entry.classes3 = atoi(row[106]); + entry.classes4 = atoi(row[107]); + entry.classes5 = atoi(row[108]); + entry.classes6 = atoi(row[109]); + entry.classes7 = atoi(row[110]); + entry.classes8 = atoi(row[111]); + entry.classes9 = atoi(row[112]); + entry.classes10 = atoi(row[113]); + entry.classes11 = atoi(row[114]); + entry.classes12 = atoi(row[115]); + entry.classes13 = atoi(row[116]); + entry.classes14 = atoi(row[117]); + entry.classes15 = atoi(row[118]); + entry.classes16 = atoi(row[119]); + entry.CastingAnim = atoi(row[120]); + entry.TargetAnim = atoi(row[121]); + entry.TravelType = atoi(row[122]); + entry.SpellAffectIndex = atoi(row[123]); + entry.disallow_sit = atoi(row[124]); + entry.deities0 = atoi(row[125]); + entry.deities1 = atoi(row[126]); + entry.deities2 = atoi(row[127]); + entry.deities3 = atoi(row[128]); + entry.deities4 = atoi(row[129]); + entry.deities5 = atoi(row[130]); + entry.deities6 = atoi(row[131]); + entry.deities7 = atoi(row[132]); + entry.deities8 = atoi(row[133]); + entry.deities9 = atoi(row[134]); + entry.deities10 = atoi(row[135]); + entry.deities11 = atoi(row[136]); + entry.deities12 = atoi(row[137]); + entry.deities13 = atoi(row[138]); + entry.deities14 = atoi(row[139]); + entry.deities15 = atoi(row[140]); + entry.deities16 = atoi(row[141]); + entry.field142 = atoi(row[142]); + entry.field143 = atoi(row[143]); + entry.new_icon = atoi(row[144]); + entry.spellanim = atoi(row[145]); + entry.uninterruptable = atoi(row[146]); + entry.ResistDiff = atoi(row[147]); + entry.dot_stacking_exempt = atoi(row[148]); + entry.deleteable = atoi(row[149]); + entry.RecourseLink = atoi(row[150]); + entry.no_partial_resist = atoi(row[151]); + entry.field152 = atoi(row[152]); + entry.field153 = atoi(row[153]); + entry.short_buff_box = atoi(row[154]); + entry.descnum = atoi(row[155]); + entry.typedescnum = atoi(row[156]); + entry.effectdescnum = atoi(row[157]); + entry.effectdescnum2 = atoi(row[158]); + entry.npc_no_los = atoi(row[159]); + entry.field160 = atoi(row[160]); + entry.reflectable = atoi(row[161]); + entry.bonushate = atoi(row[162]); + entry.field163 = atoi(row[163]); + entry.field164 = atoi(row[164]); + entry.ldon_trap = atoi(row[165]); + entry.EndurCost = atoi(row[166]); + entry.EndurTimerIndex = atoi(row[167]); + entry.IsDiscipline = atoi(row[168]); + entry.field169 = atoi(row[169]); + entry.field170 = atoi(row[170]); + entry.field171 = atoi(row[171]); + entry.field172 = atoi(row[172]); + entry.HateAdded = atoi(row[173]); + entry.EndurUpkeep = atoi(row[174]); + entry.numhitstype = atoi(row[175]); + entry.numhits = atoi(row[176]); + entry.pvpresistbase = atoi(row[177]); + entry.pvpresistcalc = atoi(row[178]); + entry.pvpresistcap = atoi(row[179]); + entry.spell_category = atoi(row[180]); + entry.field181 = atoi(row[181]); + entry.field182 = atoi(row[182]); + entry.pcnpc_only_flag = atoi(row[183]); + entry.cast_not_standing = atoi(row[184]); + entry.can_mgb = atoi(row[185]); + entry.nodispell = atoi(row[186]); + entry.npc_category = atoi(row[187]); + entry.npc_usefulness = atoi(row[188]); + entry.MinResist = atoi(row[189]); + entry.MaxResist = atoi(row[190]); + entry.viral_targets = atoi(row[191]); + entry.viral_timer = atoi(row[192]); + entry.nimbuseffect = atoi(row[193]); + entry.ConeStartAngle = atoi(row[194]); + entry.ConeStopAngle = atoi(row[195]); + entry.sneaking = atoi(row[196]); + entry.not_extendable = atoi(row[197]); + entry.field198 = atoi(row[198]); + entry.field199 = atoi(row[199]); + entry.suspendable = atoi(row[200]); + entry.viral_range = atoi(row[201]); + entry.songcap = atoi(row[202]); + entry.field203 = atoi(row[203]); + entry.field204 = atoi(row[204]); + entry.no_block = atoi(row[205]); + entry.field206 = atoi(row[206]); + entry.spellgroup = atoi(row[207]); + entry.rank = atoi(row[208]); + entry.field209 = atoi(row[209]); + entry.field210 = atoi(row[210]); + entry.CastRestriction = atoi(row[211]); + entry.allowrest = atoi(row[212]); + entry.InCombat = atoi(row[213]); + entry.OutofCombat = atoi(row[214]); + entry.field215 = atoi(row[215]); + entry.field216 = atoi(row[216]); + entry.field217 = atoi(row[217]); + entry.aemaxtargets = atoi(row[218]); + entry.maxtargets = atoi(row[219]); + entry.field220 = atoi(row[220]); + entry.field221 = atoi(row[221]); + entry.field222 = atoi(row[222]); + entry.field223 = atoi(row[223]); + entry.persistdeath = atoi(row[224]); + entry.field225 = atoi(row[225]); + entry.field226 = atoi(row[226]); + entry.min_dist = atof(row[227]); + entry.min_dist_mod = atof(row[228]); + entry.max_dist = atof(row[229]); + entry.max_dist_mod = atof(row[230]); + entry.min_range = atoi(row[231]); + entry.field232 = atoi(row[232]); + entry.field233 = atoi(row[233]); + entry.field234 = atoi(row[234]); + entry.field235 = atoi(row[235]); + entry.field236 = atoi(row[236]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_SPELLS_NEW_REPOSITORY_H diff --git a/common/repositories/start_zones_repository.h b/common/repositories/start_zones_repository.h index 588f2b600..54cd27bd2 100644 --- a/common/repositories/start_zones_repository.h +++ b/common/repositories/start_zones_repository.h @@ -212,16 +212,16 @@ public: auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + EscapeString(start_zones_entry.x) + "'"); - update_values.push_back(columns[1] + " = '" + EscapeString(start_zones_entry.y) + "'"); - update_values.push_back(columns[2] + " = '" + EscapeString(start_zones_entry.z) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(start_zones_entry.heading) + "'"); + update_values.push_back(columns[0] + " = " + std::to_string(start_zones_entry.x)); + update_values.push_back(columns[1] + " = " + std::to_string(start_zones_entry.y)); + update_values.push_back(columns[2] + " = " + std::to_string(start_zones_entry.z)); + update_values.push_back(columns[3] + " = " + std::to_string(start_zones_entry.heading)); update_values.push_back(columns[4] + " = " + std::to_string(start_zones_entry.zone_id)); update_values.push_back(columns[5] + " = " + std::to_string(start_zones_entry.bind_id)); update_values.push_back(columns[10] + " = " + std::to_string(start_zones_entry.start_zone)); - update_values.push_back(columns[11] + " = '" + EscapeString(start_zones_entry.bind_x) + "'"); - update_values.push_back(columns[12] + " = '" + EscapeString(start_zones_entry.bind_y) + "'"); - update_values.push_back(columns[13] + " = '" + EscapeString(start_zones_entry.bind_z) + "'"); + update_values.push_back(columns[11] + " = " + std::to_string(start_zones_entry.bind_x)); + update_values.push_back(columns[12] + " = " + std::to_string(start_zones_entry.bind_y)); + update_values.push_back(columns[13] + " = " + std::to_string(start_zones_entry.bind_z)); update_values.push_back(columns[14] + " = " + std::to_string(start_zones_entry.select_rank)); auto results = content_db.QueryDatabase( @@ -243,16 +243,16 @@ public: { std::vector insert_values; - insert_values.push_back("'" + EscapeString(start_zones_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.heading) + "'"); + insert_values.push_back(std::to_string(start_zones_entry.x)); + insert_values.push_back(std::to_string(start_zones_entry.y)); + insert_values.push_back(std::to_string(start_zones_entry.z)); + insert_values.push_back(std::to_string(start_zones_entry.heading)); insert_values.push_back(std::to_string(start_zones_entry.zone_id)); insert_values.push_back(std::to_string(start_zones_entry.bind_id)); insert_values.push_back(std::to_string(start_zones_entry.start_zone)); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_x) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_y) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_z) + "'"); + insert_values.push_back(std::to_string(start_zones_entry.bind_x)); + insert_values.push_back(std::to_string(start_zones_entry.bind_y)); + insert_values.push_back(std::to_string(start_zones_entry.bind_z)); insert_values.push_back(std::to_string(start_zones_entry.select_rank)); auto results = content_db.QueryDatabase( @@ -268,7 +268,7 @@ public: return start_zones_entry; } - start_zones_entry = InstanceListRepository::NewEntity(); + start_zones_entry = StartZonesRepository::NewEntity(); return start_zones_entry; } @@ -282,16 +282,16 @@ public: for (auto &start_zones_entry: start_zones_entries) { std::vector insert_values; - insert_values.push_back("'" + EscapeString(start_zones_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.heading) + "'"); + insert_values.push_back(std::to_string(start_zones_entry.x)); + insert_values.push_back(std::to_string(start_zones_entry.y)); + insert_values.push_back(std::to_string(start_zones_entry.z)); + insert_values.push_back(std::to_string(start_zones_entry.heading)); insert_values.push_back(std::to_string(start_zones_entry.zone_id)); insert_values.push_back(std::to_string(start_zones_entry.bind_id)); insert_values.push_back(std::to_string(start_zones_entry.start_zone)); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_x) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_y) + "'"); - insert_values.push_back("'" + EscapeString(start_zones_entry.bind_z) + "'"); + insert_values.push_back(std::to_string(start_zones_entry.bind_x)); + insert_values.push_back(std::to_string(start_zones_entry.bind_y)); + insert_values.push_back(std::to_string(start_zones_entry.bind_z)); insert_values.push_back(std::to_string(start_zones_entry.select_rank)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -348,6 +348,59 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + StartZones entry{}; + + entry.x = atof(row[0]); + entry.y = atof(row[1]); + entry.z = atof(row[2]); + entry.heading = atof(row[3]); + entry.zone_id = atoi(row[4]); + entry.bind_id = atoi(row[5]); + entry.player_choice = atoi(row[6]); + entry.player_class = atoi(row[7]); + entry.player_deity = atoi(row[8]); + entry.player_race = atoi(row[9]); + entry.start_zone = atoi(row[10]); + entry.bind_x = atof(row[11]); + entry.bind_y = atof(row[12]); + entry.bind_z = atof(row[13]); + entry.select_rank = atoi(row[14]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_START_ZONES_REPOSITORY_H diff --git a/common/repositories/starting_items_repository.h b/common/repositories/starting_items_repository.h index 5bf069ede..d1a4cc48e 100644 --- a/common/repositories/starting_items_repository.h +++ b/common/repositories/starting_items_repository.h @@ -236,7 +236,7 @@ public: return starting_items_entry; } - starting_items_entry = InstanceListRepository::NewEntity(); + starting_items_entry = StartingItemsRepository::NewEntity(); return starting_items_entry; } @@ -306,6 +306,53 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + StartingItems entry{}; + + entry.id = atoi(row[0]); + entry.race = atoi(row[1]); + entry.class = atoi(row[2]); + entry.deityid = atoi(row[3]); + entry.zoneid = atoi(row[4]); + entry.itemid = atoi(row[5]); + entry.item_charges = atoi(row[6]); + entry.gm = atoi(row[7]); + entry.slot = atoi(row[8]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_STARTING_ITEMS_REPOSITORY_H diff --git a/common/repositories/task_activities_repository.h b/common/repositories/task_activities_repository.h index 450175b2e..b6023162f 100644 --- a/common/repositories/task_activities_repository.h +++ b/common/repositories/task_activities_repository.h @@ -272,7 +272,7 @@ public: return task_activities_entry; } - task_activities_entry = InstanceListRepository::NewEntity(); + task_activities_entry = TaskActivitiesRepository::NewEntity(); return task_activities_entry; } @@ -354,6 +354,59 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + TaskActivities entry{}; + + entry.taskid = atoi(row[0]); + entry.activityid = atoi(row[1]); + entry.step = atoi(row[2]); + entry.activitytype = atoi(row[3]); + entry.target_name = row[4]; + entry.item_list = row[5]; + entry.skill_list = row[6]; + entry.spell_list = row[7]; + entry.description_override = row[8]; + entry.goalid = atoi(row[9]); + entry.goalmethod = atoi(row[10]); + entry.goalcount = atoi(row[11]); + entry.delivertonpc = atoi(row[12]); + entry.zones = row[13]; + entry.optional = atoi(row[14]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TASK_ACTIVITIES_REPOSITORY_H diff --git a/common/repositories/tasks_repository.h b/common/repositories/tasks_repository.h index bb68b5652..8817973af 100644 --- a/common/repositories/tasks_repository.h +++ b/common/repositories/tasks_repository.h @@ -280,7 +280,7 @@ public: return tasks_entry; } - tasks_entry = InstanceListRepository::NewEntity(); + tasks_entry = TasksRepository::NewEntity(); return tasks_entry; } @@ -365,6 +365,60 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Tasks entry{}; + + entry.id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.duration = atoi(row[2]); + entry.duration_code = atoi(row[3]); + entry.title = row[4]; + entry.description = row[5]; + entry.reward = row[6]; + entry.rewardid = atoi(row[7]); + entry.cashreward = atoi(row[8]); + entry.xpreward = atoi(row[9]); + entry.rewardmethod = atoi(row[10]); + entry.minlevel = atoi(row[11]); + entry.maxlevel = atoi(row[12]); + entry.repeatable = atoi(row[13]); + entry.faction_reward = atoi(row[14]); + entry.completion_emote = row[15]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TASKS_REPOSITORY_H diff --git a/common/repositories/tasksets_repository.h b/common/repositories/tasksets_repository.h index 4cf8ad54f..43f6ed782 100644 --- a/common/repositories/tasksets_repository.h +++ b/common/repositories/tasksets_repository.h @@ -196,7 +196,7 @@ public: return tasksets_entry; } - tasksets_entry = InstanceListRepository::NewEntity(); + tasksets_entry = TasksetsRepository::NewEntity(); return tasksets_entry; } @@ -253,6 +253,46 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Tasksets entry{}; + + entry.id = atoi(row[0]); + entry.taskid = atoi(row[1]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TASKSETS_REPOSITORY_H diff --git a/common/repositories/template/repository.template b/common/repositories/template/repository.template index e13624359..dacc76705 100644 --- a/common/repositories/template/repository.template +++ b/common/repositories/template/repository.template @@ -191,7 +191,7 @@ public: return {{TABLE_NAME_VAR}}_entry; } - {{TABLE_NAME_VAR}}_entry = InstanceListRepository::NewEntity(); + {{TABLE_NAME_VAR}}_entry = {{TABLE_NAME_CLASS}}Repository::NewEntity(); return {{TABLE_NAME_VAR}}_entry; } @@ -247,6 +247,45 @@ public: return all_entries; } + static std::vector<{{TABLE_NAME_STRUCT}}> GetWhere(std::string where_filter) + { + std::vector<{{TABLE_NAME_STRUCT}}> all_entries; + + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + {{TABLE_NAME_STRUCT}} entry{}; + +{{ALL_ENTRIES}} + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = {{DATABASE_CONNECTION}}.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_{{TABLE_NAME_UPPER}}_REPOSITORY_H diff --git a/common/repositories/timers_repository.h b/common/repositories/timers_repository.h index a00812fed..f6734b140 100644 --- a/common/repositories/timers_repository.h +++ b/common/repositories/timers_repository.h @@ -212,7 +212,7 @@ public: return timers_entry; } - timers_entry = InstanceListRepository::NewEntity(); + timers_entry = TimersRepository::NewEntity(); return timers_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Timers entry{}; + + entry.char_id = atoi(row[0]); + entry.type = atoi(row[1]); + entry.start = atoi(row[2]); + entry.duration = atoi(row[3]); + entry.enable = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TIMERS_REPOSITORY_H diff --git a/common/repositories/titles_repository.h b/common/repositories/titles_repository.h index fcf4f8be6..c0000289f 100644 --- a/common/repositories/titles_repository.h +++ b/common/repositories/titles_repository.h @@ -268,7 +268,7 @@ public: return titles_entry; } - titles_entry = InstanceListRepository::NewEntity(); + titles_entry = TitlesRepository::NewEntity(); return titles_entry; } @@ -349,6 +349,58 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Titles entry{}; + + entry.id = atoi(row[0]); + entry.skill_id = atoi(row[1]); + entry.min_skill_value = atoi(row[2]); + entry.max_skill_value = atoi(row[3]); + entry.min_aa_points = atoi(row[4]); + entry.max_aa_points = atoi(row[5]); + entry.class = atoi(row[6]); + entry.gender = atoi(row[7]); + entry.char_id = atoi(row[8]); + entry.status = atoi(row[9]); + entry.item_id = atoi(row[10]); + entry.prefix = row[11]; + entry.suffix = row[12]; + entry.title_set = atoi(row[13]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TITLES_REPOSITORY_H diff --git a/common/repositories/trader_repository.h b/common/repositories/trader_repository.h index ed21cee95..1b85cb55a 100644 --- a/common/repositories/trader_repository.h +++ b/common/repositories/trader_repository.h @@ -218,7 +218,7 @@ public: return trader_entry; } - trader_entry = InstanceListRepository::NewEntity(); + trader_entry = TraderRepository::NewEntity(); return trader_entry; } @@ -282,6 +282,50 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Trader entry{}; + + entry.char_id = atoi(row[0]); + entry.item_id = atoi(row[1]); + entry.serialnumber = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.item_cost = atoi(row[4]); + entry.slot_id = atoi(row[5]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TRADER_REPOSITORY_H diff --git a/common/repositories/tradeskill_recipe_entries_repository.h b/common/repositories/tradeskill_recipe_entries_repository.h index 9545aa0fd..1e3131eb0 100644 --- a/common/repositories/tradeskill_recipe_entries_repository.h +++ b/common/repositories/tradeskill_recipe_entries_repository.h @@ -232,7 +232,7 @@ public: return tradeskill_recipe_entries_entry; } - tradeskill_recipe_entries_entry = InstanceListRepository::NewEntity(); + tradeskill_recipe_entries_entry = TradeskillRecipeEntriesRepository::NewEntity(); return tradeskill_recipe_entries_entry; } @@ -301,6 +301,52 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + TradeskillRecipeEntries entry{}; + + entry.id = atoi(row[0]); + entry.recipe_id = atoi(row[1]); + entry.item_id = atoi(row[2]); + entry.successcount = atoi(row[3]); + entry.failcount = atoi(row[4]); + entry.componentcount = atoi(row[5]); + entry.salvagecount = atoi(row[6]); + entry.iscontainer = atoi(row[7]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TRADESKILL_RECIPE_ENTRIES_REPOSITORY_H diff --git a/common/repositories/traps_repository.h b/common/repositories/traps_repository.h index 45a70ab8f..3f75271f1 100644 --- a/common/repositories/traps_repository.h +++ b/common/repositories/traps_repository.h @@ -242,8 +242,8 @@ public: update_values.push_back(columns[4] + " = " + std::to_string(traps_entry.y)); update_values.push_back(columns[5] + " = " + std::to_string(traps_entry.z)); update_values.push_back(columns[6] + " = " + std::to_string(traps_entry.chance)); - update_values.push_back(columns[7] + " = '" + EscapeString(traps_entry.maxzdiff) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(traps_entry.radius) + "'"); + update_values.push_back(columns[7] + " = " + std::to_string(traps_entry.maxzdiff)); + update_values.push_back(columns[8] + " = " + std::to_string(traps_entry.radius)); update_values.push_back(columns[9] + " = " + std::to_string(traps_entry.effect)); update_values.push_back(columns[10] + " = " + std::to_string(traps_entry.effectvalue)); update_values.push_back(columns[11] + " = " + std::to_string(traps_entry.effectvalue2)); @@ -282,8 +282,8 @@ public: insert_values.push_back(std::to_string(traps_entry.y)); insert_values.push_back(std::to_string(traps_entry.z)); insert_values.push_back(std::to_string(traps_entry.chance)); - insert_values.push_back("'" + EscapeString(traps_entry.maxzdiff) + "'"); - insert_values.push_back("'" + EscapeString(traps_entry.radius) + "'"); + insert_values.push_back(std::to_string(traps_entry.maxzdiff)); + insert_values.push_back(std::to_string(traps_entry.radius)); insert_values.push_back(std::to_string(traps_entry.effect)); insert_values.push_back(std::to_string(traps_entry.effectvalue)); insert_values.push_back(std::to_string(traps_entry.effectvalue2)); @@ -310,7 +310,7 @@ public: return traps_entry; } - traps_entry = InstanceListRepository::NewEntity(); + traps_entry = TrapsRepository::NewEntity(); return traps_entry; } @@ -330,8 +330,8 @@ public: insert_values.push_back(std::to_string(traps_entry.y)); insert_values.push_back(std::to_string(traps_entry.z)); insert_values.push_back(std::to_string(traps_entry.chance)); - insert_values.push_back("'" + EscapeString(traps_entry.maxzdiff) + "'"); - insert_values.push_back("'" + EscapeString(traps_entry.radius) + "'"); + insert_values.push_back(std::to_string(traps_entry.maxzdiff)); + insert_values.push_back(std::to_string(traps_entry.radius)); insert_values.push_back(std::to_string(traps_entry.effect)); insert_values.push_back(std::to_string(traps_entry.effectvalue)); insert_values.push_back(std::to_string(traps_entry.effectvalue2)); @@ -405,6 +405,65 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Traps entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.version = atoi(row[2]); + entry.x = atoi(row[3]); + entry.y = atoi(row[4]); + entry.z = atoi(row[5]); + entry.chance = atoi(row[6]); + entry.maxzdiff = atof(row[7]); + entry.radius = atof(row[8]); + entry.effect = atoi(row[9]); + entry.effectvalue = atoi(row[10]); + entry.effectvalue2 = atoi(row[11]); + entry.message = row[12]; + entry.skill = atoi(row[13]); + entry.level = atoi(row[14]); + entry.respawn_time = atoi(row[15]); + entry.respawn_var = atoi(row[16]); + entry.triggered_number = atoi(row[17]); + entry.group = atoi(row[18]); + entry.despawn_when_triggered = atoi(row[19]); + entry.undetectable = atoi(row[20]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TRAPS_REPOSITORY_H diff --git a/common/repositories/tribute_levels_repository.h b/common/repositories/tribute_levels_repository.h index 2021eee52..9b2501606 100644 --- a/common/repositories/tribute_levels_repository.h +++ b/common/repositories/tribute_levels_repository.h @@ -206,7 +206,7 @@ public: return tribute_levels_entry; } - tribute_levels_entry = InstanceListRepository::NewEntity(); + tribute_levels_entry = TributeLevelsRepository::NewEntity(); return tribute_levels_entry; } @@ -266,6 +266,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + TributeLevels entry{}; + + entry.tribute_id = atoi(row[0]); + entry.level = atoi(row[1]); + entry.cost = atoi(row[2]); + entry.item_id = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TRIBUTE_LEVELS_REPOSITORY_H diff --git a/common/repositories/tributes_repository.h b/common/repositories/tributes_repository.h index fc01a77c1..d0ef9f6de 100644 --- a/common/repositories/tributes_repository.h +++ b/common/repositories/tributes_repository.h @@ -212,7 +212,7 @@ public: return tributes_entry; } - tributes_entry = InstanceListRepository::NewEntity(); + tributes_entry = TributesRepository::NewEntity(); return tributes_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Tributes entry{}; + + entry.id = atoi(row[0]); + entry.unknown = atoi(row[1]); + entry.name = row[2]; + entry.descr = row[3]; + entry.isguild = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_TRIBUTES_REPOSITORY_H diff --git a/common/repositories/variables_repository.h b/common/repositories/variables_repository.h index 5d7303253..2cc5de8a2 100644 --- a/common/repositories/variables_repository.h +++ b/common/repositories/variables_repository.h @@ -208,7 +208,7 @@ public: return variables_entry; } - variables_entry = InstanceListRepository::NewEntity(); + variables_entry = VariablesRepository::NewEntity(); return variables_entry; } @@ -269,6 +269,48 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = database.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Variables entry{}; + + entry.varname = row[0]; + entry.value = row[1]; + entry.information = row[2]; + entry.ts = row[3]; + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = database.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_VARIABLES_REPOSITORY_H diff --git a/common/repositories/veteran_reward_templates_repository.h b/common/repositories/veteran_reward_templates_repository.h index 18313f4ef..6e18d16b5 100644 --- a/common/repositories/veteran_reward_templates_repository.h +++ b/common/repositories/veteran_reward_templates_repository.h @@ -212,7 +212,7 @@ public: return veteran_reward_templates_entry; } - veteran_reward_templates_entry = InstanceListRepository::NewEntity(); + veteran_reward_templates_entry = VeteranRewardTemplatesRepository::NewEntity(); return veteran_reward_templates_entry; } @@ -274,6 +274,49 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + VeteranRewardTemplates entry{}; + + entry.claim_id = atoi(row[0]); + entry.name = row[1]; + entry.item_id = atoi(row[2]); + entry.charges = atoi(row[3]); + entry.reward_slot = atoi(row[4]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_VETERAN_REWARD_TEMPLATES_REPOSITORY_H diff --git a/common/repositories/zone_points_repository.h b/common/repositories/zone_points_repository.h index 00536a94a..f76c3f777 100644 --- a/common/repositories/zone_points_repository.h +++ b/common/repositories/zone_points_repository.h @@ -223,18 +223,18 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(zone_points_entry.zone) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(zone_points_entry.version)); update_values.push_back(columns[3] + " = " + std::to_string(zone_points_entry.number)); - update_values.push_back(columns[4] + " = '" + EscapeString(zone_points_entry.y) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(zone_points_entry.x) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(zone_points_entry.z) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(zone_points_entry.heading) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(zone_points_entry.target_y) + "'"); - update_values.push_back(columns[9] + " = '" + EscapeString(zone_points_entry.target_x) + "'"); - update_values.push_back(columns[10] + " = '" + EscapeString(zone_points_entry.target_z) + "'"); - update_values.push_back(columns[11] + " = '" + EscapeString(zone_points_entry.target_heading) + "'"); + update_values.push_back(columns[4] + " = " + std::to_string(zone_points_entry.y)); + update_values.push_back(columns[5] + " = " + std::to_string(zone_points_entry.x)); + update_values.push_back(columns[6] + " = " + std::to_string(zone_points_entry.z)); + update_values.push_back(columns[7] + " = " + std::to_string(zone_points_entry.heading)); + update_values.push_back(columns[8] + " = " + std::to_string(zone_points_entry.target_y)); + update_values.push_back(columns[9] + " = " + std::to_string(zone_points_entry.target_x)); + update_values.push_back(columns[10] + " = " + std::to_string(zone_points_entry.target_z)); + update_values.push_back(columns[11] + " = " + std::to_string(zone_points_entry.target_heading)); update_values.push_back(columns[12] + " = " + std::to_string(zone_points_entry.zoneinst)); update_values.push_back(columns[13] + " = " + std::to_string(zone_points_entry.target_zone_id)); update_values.push_back(columns[14] + " = " + std::to_string(zone_points_entry.target_instance)); - update_values.push_back(columns[15] + " = '" + EscapeString(zone_points_entry.buffer) + "'"); + update_values.push_back(columns[15] + " = " + std::to_string(zone_points_entry.buffer)); update_values.push_back(columns[16] + " = " + std::to_string(zone_points_entry.client_version_mask)); auto results = content_db.QueryDatabase( @@ -259,18 +259,18 @@ public: insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); insert_values.push_back(std::to_string(zone_points_entry.version)); insert_values.push_back(std::to_string(zone_points_entry.number)); - insert_values.push_back("'" + EscapeString(zone_points_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.heading) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_y) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_x) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_z) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_heading) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.y)); + insert_values.push_back(std::to_string(zone_points_entry.x)); + insert_values.push_back(std::to_string(zone_points_entry.z)); + insert_values.push_back(std::to_string(zone_points_entry.heading)); + insert_values.push_back(std::to_string(zone_points_entry.target_y)); + insert_values.push_back(std::to_string(zone_points_entry.target_x)); + insert_values.push_back(std::to_string(zone_points_entry.target_z)); + insert_values.push_back(std::to_string(zone_points_entry.target_heading)); insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); insert_values.push_back(std::to_string(zone_points_entry.target_instance)); - insert_values.push_back("'" + EscapeString(zone_points_entry.buffer) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.buffer)); insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); auto results = content_db.QueryDatabase( @@ -286,7 +286,7 @@ public: return zone_points_entry; } - zone_points_entry = InstanceListRepository::NewEntity(); + zone_points_entry = ZonePointsRepository::NewEntity(); return zone_points_entry; } @@ -303,18 +303,18 @@ public: insert_values.push_back("'" + EscapeString(zone_points_entry.zone) + "'"); insert_values.push_back(std::to_string(zone_points_entry.version)); insert_values.push_back(std::to_string(zone_points_entry.number)); - insert_values.push_back("'" + EscapeString(zone_points_entry.y) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.x) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.z) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.heading) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_y) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_x) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_z) + "'"); - insert_values.push_back("'" + EscapeString(zone_points_entry.target_heading) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.y)); + insert_values.push_back(std::to_string(zone_points_entry.x)); + insert_values.push_back(std::to_string(zone_points_entry.z)); + insert_values.push_back(std::to_string(zone_points_entry.heading)); + insert_values.push_back(std::to_string(zone_points_entry.target_y)); + insert_values.push_back(std::to_string(zone_points_entry.target_x)); + insert_values.push_back(std::to_string(zone_points_entry.target_z)); + insert_values.push_back(std::to_string(zone_points_entry.target_heading)); insert_values.push_back(std::to_string(zone_points_entry.zoneinst)); insert_values.push_back(std::to_string(zone_points_entry.target_zone_id)); insert_values.push_back(std::to_string(zone_points_entry.target_instance)); - insert_values.push_back("'" + EscapeString(zone_points_entry.buffer) + "'"); + insert_values.push_back(std::to_string(zone_points_entry.buffer)); insert_values.push_back(std::to_string(zone_points_entry.client_version_mask)); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -373,6 +373,61 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + ZonePoints entry{}; + + entry.id = atoi(row[0]); + entry.zone = row[1]; + entry.version = atoi(row[2]); + entry.number = atoi(row[3]); + entry.y = atof(row[4]); + entry.x = atof(row[5]); + entry.z = atof(row[6]); + entry.heading = atof(row[7]); + entry.target_y = atof(row[8]); + entry.target_x = atof(row[9]); + entry.target_z = atof(row[10]); + entry.target_heading = atof(row[11]); + entry.zoneinst = atoi(row[12]); + entry.target_zone_id = atoi(row[13]); + entry.target_instance = atoi(row[14]); + entry.buffer = atof(row[15]); + entry.client_version_mask = atoi(row[16]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ZONE_POINTS_REPOSITORY_H diff --git a/common/repositories/zone_repository.h b/common/repositories/zone_repository.h index 0fa15cbc6..a22e67865 100644 --- a/common/repositories/zone_repository.h +++ b/common/repositories/zone_repository.h @@ -500,10 +500,10 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(zone_entry.file_name) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(zone_entry.long_name) + "'"); update_values.push_back(columns[4] + " = '" + EscapeString(zone_entry.map_file_name) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(zone_entry.safe_x) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(zone_entry.safe_y) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(zone_entry.safe_z) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(zone_entry.graveyard_id) + "'"); + update_values.push_back(columns[5] + " = " + std::to_string(zone_entry.safe_x)); + update_values.push_back(columns[6] + " = " + std::to_string(zone_entry.safe_y)); + update_values.push_back(columns[7] + " = " + std::to_string(zone_entry.safe_z)); + update_values.push_back(columns[8] + " = " + std::to_string(zone_entry.graveyard_id)); update_values.push_back(columns[9] + " = " + std::to_string(zone_entry.min_level)); update_values.push_back(columns[10] + " = " + std::to_string(zone_entry.min_status)); update_values.push_back(columns[11] + " = " + std::to_string(zone_entry.zoneidnumber)); @@ -512,40 +512,40 @@ public: update_values.push_back(columns[14] + " = " + std::to_string(zone_entry.maxclients)); update_values.push_back(columns[15] + " = " + std::to_string(zone_entry.ruleset)); update_values.push_back(columns[16] + " = '" + EscapeString(zone_entry.note) + "'"); - update_values.push_back(columns[17] + " = '" + EscapeString(zone_entry.underworld) + "'"); - update_values.push_back(columns[18] + " = '" + EscapeString(zone_entry.minclip) + "'"); - update_values.push_back(columns[19] + " = '" + EscapeString(zone_entry.maxclip) + "'"); - update_values.push_back(columns[20] + " = '" + EscapeString(zone_entry.fog_minclip) + "'"); - update_values.push_back(columns[21] + " = '" + EscapeString(zone_entry.fog_maxclip) + "'"); + update_values.push_back(columns[17] + " = " + std::to_string(zone_entry.underworld)); + update_values.push_back(columns[18] + " = " + std::to_string(zone_entry.minclip)); + update_values.push_back(columns[19] + " = " + std::to_string(zone_entry.maxclip)); + update_values.push_back(columns[20] + " = " + std::to_string(zone_entry.fog_minclip)); + update_values.push_back(columns[21] + " = " + std::to_string(zone_entry.fog_maxclip)); update_values.push_back(columns[22] + " = " + std::to_string(zone_entry.fog_blue)); update_values.push_back(columns[23] + " = " + std::to_string(zone_entry.fog_red)); update_values.push_back(columns[24] + " = " + std::to_string(zone_entry.fog_green)); update_values.push_back(columns[25] + " = " + std::to_string(zone_entry.sky)); update_values.push_back(columns[26] + " = " + std::to_string(zone_entry.ztype)); - update_values.push_back(columns[27] + " = '" + EscapeString(zone_entry.zone_exp_multiplier) + "'"); - update_values.push_back(columns[28] + " = '" + EscapeString(zone_entry.walkspeed) + "'"); + update_values.push_back(columns[27] + " = " + std::to_string(zone_entry.zone_exp_multiplier)); + update_values.push_back(columns[28] + " = " + std::to_string(zone_entry.walkspeed)); update_values.push_back(columns[29] + " = " + std::to_string(zone_entry.time_type)); update_values.push_back(columns[30] + " = " + std::to_string(zone_entry.fog_red1)); update_values.push_back(columns[31] + " = " + std::to_string(zone_entry.fog_green1)); update_values.push_back(columns[32] + " = " + std::to_string(zone_entry.fog_blue1)); - update_values.push_back(columns[33] + " = '" + EscapeString(zone_entry.fog_minclip1) + "'"); - update_values.push_back(columns[34] + " = '" + EscapeString(zone_entry.fog_maxclip1) + "'"); + update_values.push_back(columns[33] + " = " + std::to_string(zone_entry.fog_minclip1)); + update_values.push_back(columns[34] + " = " + std::to_string(zone_entry.fog_maxclip1)); update_values.push_back(columns[35] + " = " + std::to_string(zone_entry.fog_red2)); update_values.push_back(columns[36] + " = " + std::to_string(zone_entry.fog_green2)); update_values.push_back(columns[37] + " = " + std::to_string(zone_entry.fog_blue2)); - update_values.push_back(columns[38] + " = '" + EscapeString(zone_entry.fog_minclip2) + "'"); - update_values.push_back(columns[39] + " = '" + EscapeString(zone_entry.fog_maxclip2) + "'"); + update_values.push_back(columns[38] + " = " + std::to_string(zone_entry.fog_minclip2)); + update_values.push_back(columns[39] + " = " + std::to_string(zone_entry.fog_maxclip2)); update_values.push_back(columns[40] + " = " + std::to_string(zone_entry.fog_red3)); update_values.push_back(columns[41] + " = " + std::to_string(zone_entry.fog_green3)); update_values.push_back(columns[42] + " = " + std::to_string(zone_entry.fog_blue3)); - update_values.push_back(columns[43] + " = '" + EscapeString(zone_entry.fog_minclip3) + "'"); - update_values.push_back(columns[44] + " = '" + EscapeString(zone_entry.fog_maxclip3) + "'"); + update_values.push_back(columns[43] + " = " + std::to_string(zone_entry.fog_minclip3)); + update_values.push_back(columns[44] + " = " + std::to_string(zone_entry.fog_maxclip3)); update_values.push_back(columns[45] + " = " + std::to_string(zone_entry.fog_red4)); update_values.push_back(columns[46] + " = " + std::to_string(zone_entry.fog_green4)); update_values.push_back(columns[47] + " = " + std::to_string(zone_entry.fog_blue4)); - update_values.push_back(columns[48] + " = '" + EscapeString(zone_entry.fog_minclip4) + "'"); - update_values.push_back(columns[49] + " = '" + EscapeString(zone_entry.fog_maxclip4) + "'"); - update_values.push_back(columns[50] + " = '" + EscapeString(zone_entry.fog_density) + "'"); + update_values.push_back(columns[48] + " = " + std::to_string(zone_entry.fog_minclip4)); + update_values.push_back(columns[49] + " = " + std::to_string(zone_entry.fog_maxclip4)); + update_values.push_back(columns[50] + " = " + std::to_string(zone_entry.fog_density)); update_values.push_back(columns[51] + " = '" + EscapeString(zone_entry.flag_needed) + "'"); update_values.push_back(columns[52] + " = " + std::to_string(zone_entry.canbind)); update_values.push_back(columns[53] + " = " + std::to_string(zone_entry.cancombat)); @@ -573,7 +573,7 @@ public: update_values.push_back(columns[75] + " = " + std::to_string(zone_entry.snow_duration2)); update_values.push_back(columns[76] + " = " + std::to_string(zone_entry.snow_duration3)); update_values.push_back(columns[77] + " = " + std::to_string(zone_entry.snow_duration4)); - update_values.push_back(columns[78] + " = '" + EscapeString(zone_entry.gravity) + "'"); + update_values.push_back(columns[78] + " = " + std::to_string(zone_entry.gravity)); update_values.push_back(columns[79] + " = " + std::to_string(zone_entry.type)); update_values.push_back(columns[80] + " = " + std::to_string(zone_entry.skylock)); update_values.push_back(columns[81] + " = " + std::to_string(zone_entry.fast_regen_hp)); @@ -605,10 +605,10 @@ public: insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_x) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_y) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_z) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.graveyard_id) + "'"); + insert_values.push_back(std::to_string(zone_entry.safe_x)); + insert_values.push_back(std::to_string(zone_entry.safe_y)); + insert_values.push_back(std::to_string(zone_entry.safe_z)); + insert_values.push_back(std::to_string(zone_entry.graveyard_id)); insert_values.push_back(std::to_string(zone_entry.min_level)); insert_values.push_back(std::to_string(zone_entry.min_status)); insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); @@ -617,40 +617,40 @@ public: insert_values.push_back(std::to_string(zone_entry.maxclients)); insert_values.push_back(std::to_string(zone_entry.ruleset)); insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.underworld) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.minclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.maxclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld)); + insert_values.push_back(std::to_string(zone_entry.minclip)); + insert_values.push_back(std::to_string(zone_entry.maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); insert_values.push_back(std::to_string(zone_entry.fog_blue)); insert_values.push_back(std::to_string(zone_entry.fog_red)); insert_values.push_back(std::to_string(zone_entry.fog_green)); insert_values.push_back(std::to_string(zone_entry.sky)); insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back("'" + EscapeString(zone_entry.zone_exp_multiplier) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.walkspeed) + "'"); + insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); + insert_values.push_back(std::to_string(zone_entry.walkspeed)); insert_values.push_back(std::to_string(zone_entry.time_type)); insert_values.push_back(std::to_string(zone_entry.fog_red1)); insert_values.push_back(std::to_string(zone_entry.fog_green1)); insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip1) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip1) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); insert_values.push_back(std::to_string(zone_entry.fog_red2)); insert_values.push_back(std::to_string(zone_entry.fog_green2)); insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip2) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip2) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); insert_values.push_back(std::to_string(zone_entry.fog_red3)); insert_values.push_back(std::to_string(zone_entry.fog_green3)); insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip3) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip3) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); insert_values.push_back(std::to_string(zone_entry.fog_red4)); insert_values.push_back(std::to_string(zone_entry.fog_green4)); insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip4) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip4) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_density) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_density)); insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); insert_values.push_back(std::to_string(zone_entry.canbind)); insert_values.push_back(std::to_string(zone_entry.cancombat)); @@ -678,7 +678,7 @@ public: insert_values.push_back(std::to_string(zone_entry.snow_duration2)); insert_values.push_back(std::to_string(zone_entry.snow_duration3)); insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back("'" + EscapeString(zone_entry.gravity) + "'"); + insert_values.push_back(std::to_string(zone_entry.gravity)); insert_values.push_back(std::to_string(zone_entry.type)); insert_values.push_back(std::to_string(zone_entry.skylock)); insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); @@ -700,7 +700,7 @@ public: return zone_entry; } - zone_entry = InstanceListRepository::NewEntity(); + zone_entry = ZoneRepository::NewEntity(); return zone_entry; } @@ -718,10 +718,10 @@ public: insert_values.push_back("'" + EscapeString(zone_entry.file_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.long_name) + "'"); insert_values.push_back("'" + EscapeString(zone_entry.map_file_name) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_x) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_y) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.safe_z) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.graveyard_id) + "'"); + insert_values.push_back(std::to_string(zone_entry.safe_x)); + insert_values.push_back(std::to_string(zone_entry.safe_y)); + insert_values.push_back(std::to_string(zone_entry.safe_z)); + insert_values.push_back(std::to_string(zone_entry.graveyard_id)); insert_values.push_back(std::to_string(zone_entry.min_level)); insert_values.push_back(std::to_string(zone_entry.min_status)); insert_values.push_back(std::to_string(zone_entry.zoneidnumber)); @@ -730,40 +730,40 @@ public: insert_values.push_back(std::to_string(zone_entry.maxclients)); insert_values.push_back(std::to_string(zone_entry.ruleset)); insert_values.push_back("'" + EscapeString(zone_entry.note) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.underworld) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.minclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.maxclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip) + "'"); + insert_values.push_back(std::to_string(zone_entry.underworld)); + insert_values.push_back(std::to_string(zone_entry.minclip)); + insert_values.push_back(std::to_string(zone_entry.maxclip)); + insert_values.push_back(std::to_string(zone_entry.fog_minclip)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip)); insert_values.push_back(std::to_string(zone_entry.fog_blue)); insert_values.push_back(std::to_string(zone_entry.fog_red)); insert_values.push_back(std::to_string(zone_entry.fog_green)); insert_values.push_back(std::to_string(zone_entry.sky)); insert_values.push_back(std::to_string(zone_entry.ztype)); - insert_values.push_back("'" + EscapeString(zone_entry.zone_exp_multiplier) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.walkspeed) + "'"); + insert_values.push_back(std::to_string(zone_entry.zone_exp_multiplier)); + insert_values.push_back(std::to_string(zone_entry.walkspeed)); insert_values.push_back(std::to_string(zone_entry.time_type)); insert_values.push_back(std::to_string(zone_entry.fog_red1)); insert_values.push_back(std::to_string(zone_entry.fog_green1)); insert_values.push_back(std::to_string(zone_entry.fog_blue1)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip1) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip1) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip1)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip1)); insert_values.push_back(std::to_string(zone_entry.fog_red2)); insert_values.push_back(std::to_string(zone_entry.fog_green2)); insert_values.push_back(std::to_string(zone_entry.fog_blue2)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip2) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip2) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip2)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip2)); insert_values.push_back(std::to_string(zone_entry.fog_red3)); insert_values.push_back(std::to_string(zone_entry.fog_green3)); insert_values.push_back(std::to_string(zone_entry.fog_blue3)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip3) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip3) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip3)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip3)); insert_values.push_back(std::to_string(zone_entry.fog_red4)); insert_values.push_back(std::to_string(zone_entry.fog_green4)); insert_values.push_back(std::to_string(zone_entry.fog_blue4)); - insert_values.push_back("'" + EscapeString(zone_entry.fog_minclip4) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_maxclip4) + "'"); - insert_values.push_back("'" + EscapeString(zone_entry.fog_density) + "'"); + insert_values.push_back(std::to_string(zone_entry.fog_minclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_maxclip4)); + insert_values.push_back(std::to_string(zone_entry.fog_density)); insert_values.push_back("'" + EscapeString(zone_entry.flag_needed) + "'"); insert_values.push_back(std::to_string(zone_entry.canbind)); insert_values.push_back(std::to_string(zone_entry.cancombat)); @@ -791,7 +791,7 @@ public: insert_values.push_back(std::to_string(zone_entry.snow_duration2)); insert_values.push_back(std::to_string(zone_entry.snow_duration3)); insert_values.push_back(std::to_string(zone_entry.snow_duration4)); - insert_values.push_back("'" + EscapeString(zone_entry.gravity) + "'"); + insert_values.push_back(std::to_string(zone_entry.gravity)); insert_values.push_back(std::to_string(zone_entry.type)); insert_values.push_back(std::to_string(zone_entry.skylock)); insert_values.push_back(std::to_string(zone_entry.fast_regen_hp)); @@ -925,6 +925,130 @@ public: return all_entries; } + static std::vector GetWhere(std::string where_filter) + { + std::vector all_entries; + + auto results = content_db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Zone entry{}; + + entry.short_name = row[0]; + entry.id = atoi(row[1]); + entry.file_name = row[2]; + entry.long_name = row[3]; + entry.map_file_name = row[4]; + entry.safe_x = atof(row[5]); + entry.safe_y = atof(row[6]); + entry.safe_z = atof(row[7]); + entry.graveyard_id = atof(row[8]); + entry.min_level = atoi(row[9]); + entry.min_status = atoi(row[10]); + entry.zoneidnumber = atoi(row[11]); + entry.version = atoi(row[12]); + entry.timezone = atoi(row[13]); + entry.maxclients = atoi(row[14]); + entry.ruleset = atoi(row[15]); + entry.note = row[16]; + entry.underworld = atof(row[17]); + entry.minclip = atof(row[18]); + entry.maxclip = atof(row[19]); + entry.fog_minclip = atof(row[20]); + entry.fog_maxclip = atof(row[21]); + entry.fog_blue = atoi(row[22]); + entry.fog_red = atoi(row[23]); + entry.fog_green = atoi(row[24]); + entry.sky = atoi(row[25]); + entry.ztype = atoi(row[26]); + entry.zone_exp_multiplier = atof(row[27]); + entry.walkspeed = atof(row[28]); + entry.time_type = atoi(row[29]); + entry.fog_red1 = atoi(row[30]); + entry.fog_green1 = atoi(row[31]); + entry.fog_blue1 = atoi(row[32]); + entry.fog_minclip1 = atof(row[33]); + entry.fog_maxclip1 = atof(row[34]); + entry.fog_red2 = atoi(row[35]); + entry.fog_green2 = atoi(row[36]); + entry.fog_blue2 = atoi(row[37]); + entry.fog_minclip2 = atof(row[38]); + entry.fog_maxclip2 = atof(row[39]); + entry.fog_red3 = atoi(row[40]); + entry.fog_green3 = atoi(row[41]); + entry.fog_blue3 = atoi(row[42]); + entry.fog_minclip3 = atof(row[43]); + entry.fog_maxclip3 = atof(row[44]); + entry.fog_red4 = atoi(row[45]); + entry.fog_green4 = atoi(row[46]); + entry.fog_blue4 = atoi(row[47]); + entry.fog_minclip4 = atof(row[48]); + entry.fog_maxclip4 = atof(row[49]); + entry.fog_density = atof(row[50]); + entry.flag_needed = row[51]; + entry.canbind = atoi(row[52]); + entry.cancombat = atoi(row[53]); + entry.canlevitate = atoi(row[54]); + entry.castoutdoor = atoi(row[55]); + entry.hotzone = atoi(row[56]); + entry.insttype = atoi(row[57]); + entry.shutdowndelay = atoi(row[58]); + entry.peqzone = atoi(row[59]); + entry.expansion = atoi(row[60]); + entry.suspendbuffs = atoi(row[61]); + entry.rain_chance1 = atoi(row[62]); + entry.rain_chance2 = atoi(row[63]); + entry.rain_chance3 = atoi(row[64]); + entry.rain_chance4 = atoi(row[65]); + entry.rain_duration1 = atoi(row[66]); + entry.rain_duration2 = atoi(row[67]); + entry.rain_duration3 = atoi(row[68]); + entry.rain_duration4 = atoi(row[69]); + entry.snow_chance1 = atoi(row[70]); + entry.snow_chance2 = atoi(row[71]); + entry.snow_chance3 = atoi(row[72]); + entry.snow_chance4 = atoi(row[73]); + entry.snow_duration1 = atoi(row[74]); + entry.snow_duration2 = atoi(row[75]); + entry.snow_duration3 = atoi(row[76]); + entry.snow_duration4 = atoi(row[77]); + entry.gravity = atof(row[78]); + entry.type = atoi(row[79]); + entry.skylock = atoi(row[80]); + entry.fast_regen_hp = atoi(row[81]); + entry.fast_regen_mana = atoi(row[82]); + entry.fast_regen_endurance = atoi(row[83]); + entry.npc_max_aggro_dist = atoi(row[84]); + entry.max_movement_update_range = atoi(row[85]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(std::string where_filter) + { + auto results = content_db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + PrimaryKey(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_ZONE_REPOSITORY_H diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 16706f877..77508ecb6 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -242,7 +242,7 @@ foreach my $table_to_generate (@tables) { # update one if ($column_key ne "PRI") { my $query_value = sprintf('\'" + EscapeString(%s_entry.%s) + "\'");', $table_name, $column_name); - if ($data_type =~ /int/) { + if ($data_type =~ /int|float|double|decimal/) { $query_value = sprintf('" + std::to_string(%s_entry.%s));', $table_name, $column_name); } @@ -256,7 +256,7 @@ foreach my $table_to_generate (@tables) { # insert one if ($column_key ne "PRI") { my $value = sprintf("\"'\" + EscapeString(%s_entry.%s) + \"'\"", $table_name, $column_name); - if ($data_type =~ /int/) { + if ($data_type =~ /int|float|double|decimal/) { $value = sprintf('std::to_string(%s_entry.%s)', $table_name, $column_name); } diff --git a/world/world_server_command_handler.cpp b/world/world_server_command_handler.cpp index 0c7eb0ac1..bd7e674e5 100644 --- a/world/world_server_command_handler.cpp +++ b/world/world_server_command_handler.cpp @@ -29,6 +29,7 @@ #include "../common/repositories/criteria/content_filter_criteria.h" #include "../common/rulesys.h" #include "../common/repositories/instance_list_repository.h" +#include "../common/repositories/zone_repository.h" namespace WorldserverCommandHandler { @@ -59,6 +60,7 @@ namespace WorldserverCommandHandler { function_map["database:dump"] = &WorldserverCommandHandler::DatabaseDump; function_map["test:test"] = &WorldserverCommandHandler::TestCommand; function_map["test:repository"] = &WorldserverCommandHandler::TestRepository; + function_map["test:repository2"] = &WorldserverCommandHandler::TestRepository2; EQEmuCommand::HandleMenu(function_map, cmd, argc, argv); } @@ -370,7 +372,7 @@ namespace WorldserverCommandHandler { /** * Delete one */ - int deleted = InstanceListRepository::DeleteOne(found_instance_list.id) ; + int deleted = InstanceListRepository::DeleteOne(found_instance_list.id); LogInfo("Deleting one instance [{}] deleted count [{}]", found_instance_list.id, deleted); @@ -399,10 +401,45 @@ namespace WorldserverCommandHandler { LogInfo("Bulk insertion test, inserted [{}]", inserted_count); - for (auto &entry: InstanceListRepository::All()) { + for (auto &entry: InstanceListRepository::GetWhere(fmt::format("zone = {}", 999))) { LogInfo("Iterating through entry id [{}] zone [{}]", entry.id, entry.zone); } + /** + * Delete where + */ + int deleted_count = InstanceListRepository::DeleteWhere(fmt::format("zone = {}", 999)); + + LogInfo("Bulk deletion test, deleted [{}]", deleted_count); + } -} \ No newline at end of file + /** + * @param argc + * @param argv + * @param cmd + * @param description + */ + void TestRepository2(int argc, char **argv, argh::parser &cmd, std::string &description) + { + description = "Test command"; + + if (cmd[{"-h", "--help"}]) { + return; + } + + auto zones = ZoneRepository::GetWhere("short_name = 'anguish'"); + + for (auto &zone: zones) { + LogInfo( + "Zone [{}] long_name [{}] id [{}]", + zone.short_name, + zone.long_name, + zone.id + ); + } + + + } + +} diff --git a/world/world_server_command_handler.h b/world/world_server_command_handler.h index 66f81a130..24d0c0dbf 100644 --- a/world/world_server_command_handler.h +++ b/world/world_server_command_handler.h @@ -33,6 +33,7 @@ namespace WorldserverCommandHandler { void DatabaseDump(int argc, char **argv, argh::parser &cmd, std::string &description); void TestCommand(int argc, char **argv, argh::parser &cmd, std::string &description); void TestRepository(int argc, char **argv, argh::parser &cmd, std::string &description); + void TestRepository2(int argc, char **argv, argh::parser &cmd, std::string &description); };