From 3ed6663c4c8ff3c2ae295b725da05235d8e0e167 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Fri, 11 Mar 2022 15:27:36 -0800 Subject: [PATCH] [Repositories] Update repositories (#2040) --- .../base/base_aa_ability_repository.h | 28 +- .../base/base_aa_rank_effects_repository.h | 19 +- .../base/base_aa_rank_prereqs_repository.h | 17 +- .../base/base_aa_ranks_repository.h | 27 +- .../base/base_account_flags_repository.h | 17 +- .../base/base_account_ip_repository.h | 20 +- .../base/base_account_rewards_repository.h | 17 +- .../base/base_adventure_details_repository.h | 23 +- .../base/base_adventure_members_repository.h | 16 +- .../base/base_adventure_stats_repository.h | 25 +- ...venture_template_entry_flavor_repository.h | 16 +- ...base_adventure_template_entry_repository.h | 16 +- .../base/base_adventure_template_repository.h | 49 ++- .../base/base_alternate_currency_repository.h | 16 +- .../repositories/base/base_auras_repository.h | 25 +- .../base/base_base_data_repository.h | 24 +- .../base/base_blocked_spells_repository.h | 26 +- .../repositories/base/base_books_repository.h | 326 ++++++++++++++++ .../base/base_bug_reports_repository.h | 78 +++- .../repositories/base/base_bugs_repository.h | 27 +- .../repositories/base/base_buyer_repository.h | 20 +- ...base_char_create_combinations_repository.h | 20 +- ...char_create_point_allocations_repository.h | 29 +- .../base/base_char_recipe_list_repository.h | 17 +- .../base_character_activities_repository.h | 19 +- .../base_character_alt_currency_repository.h | 17 +- ...character_alternate_abilities_repository.h | 18 +- .../base/base_character_auras_repository.h | 17 +- .../base_character_bandolier_repository.h | 20 +- .../base/base_character_bind_repository.h | 22 +- .../base/base_character_buffs_repository.h | 31 +- .../base_character_corpse_items_repository.h | 25 +- .../base/base_character_corpses_repository.h | 77 +++- .../base/base_character_currency_repository.h | 31 +- .../base/base_character_data_repository.h | 132 ++++++- .../base_character_disciplines_repository.h | 17 +- .../base_character_exp_modifiers_repository.h | 327 ++++++++++++++++ ...character_expedition_lockouts_repository.h | 37 +- ...se_character_inspect_messages_repository.h | 16 +- ...haracter_instance_safereturns_repository.h | 23 +- .../base_character_item_recast_repository.h | 17 +- .../base_character_languages_repository.h | 17 +- ...haracter_leadership_abilities_repository.h | 17 +- .../base/base_character_material_repository.h | 21 +- .../base_character_memmed_spells_repository.h | 17 +- .../base_character_pet_buffs_repository.h | 25 +- .../base/base_character_pet_info_repository.h | 23 +- .../base_character_pet_inventory_repository.h | 18 +- .../base_character_potionbelt_repository.h | 18 +- .../base/base_character_skills_repository.h | 17 +- .../base/base_character_spells_repository.h | 17 +- .../base_character_task_timers_repository.h | 12 +- .../base/base_character_tasks_repository.h | 19 +- .../base/base_completed_tasks_repository.h | 18 +- .../base/base_content_flags_repository.h | 18 +- .../base/base_damageshieldtypes_repository.h | 16 +- .../base/base_data_buckets_repository.h | 24 +- .../base/base_db_str_repository.h | 17 +- .../base/base_discovered_items_repository.h | 18 +- .../repositories/base/base_doors_repository.h | 53 ++- .../base_dynamic_zone_members_repository.h | 17 +- .../base/base_dynamic_zones_repository.h | 36 +- .../base/base_eventlog_repository.h | 26 +- .../base_expedition_lockouts_repository.h | 36 +- .../base/base_expeditions_repository.h | 18 +- .../base/base_faction_base_data_repository.h | 20 +- .../base/base_faction_list_mod_repository.h | 18 +- .../base/base_faction_list_repository.h | 17 +- .../base/base_faction_values_repository.h | 18 +- .../base/base_fishing_repository.h | 29 +- .../base/base_forage_repository.h | 27 +- .../base/base_friends_repository.h | 17 +- .../base/base_global_loot_repository.h | 35 +- .../base/base_gm_ips_repository.h | 17 +- .../base/base_goallists_repository.h | 16 +- .../base/base_graveyard_repository.h | 20 +- .../base/base_ground_spawns_repository.h | 36 +- .../base/base_group_id_repository.h | 18 +- .../base/base_group_leaders_repository.h | 23 +- .../base/base_guild_members_repository.h | 23 +- .../base/base_guild_ranks_repository.h | 25 +- .../base/base_guild_relations_repository.h | 17 +- .../base/base_guilds_repository.h | 23 +- .../base/base_hackers_repository.h | 22 +- .../base/base_horses_repository.h | 171 +++++---- .../base_instance_list_player_repository.h | 16 +- .../base/base_instance_list_repository.h | 21 +- .../base/base_inventory_repository.h | 30 +- .../base_inventory_snapshots_repository.h | 31 +- .../base/base_ip_exemptions_repository.h | 17 +- .../base/base_item_tick_repository.h | 20 +- .../repositories/base/base_items_repository.h | 349 ++++++++++++++++-- .../base/base_ldon_trap_entries_repository.h | 16 +- .../base_ldon_trap_templates_repository.h | 19 +- .../base/base_level_exp_mods_repository.h | 17 +- .../base/base_lfguild_repository.h | 23 +- .../base/base_login_accounts_repository.h | 71 ++-- .../base/base_login_api_tokens_repository.h | 52 ++- .../base_login_server_admins_repository.h | 38 +- .../base_login_server_list_types_repository.h | 16 +- .../base_login_world_servers_repository.h | 40 +- .../base/base_logsys_categories_repository.h | 19 +- .../base/base_lootdrop_entries_repository.h | 25 +- .../base/base_lootdrop_repository.h | 24 +- .../base/base_loottable_entries_repository.h | 20 +- .../base/base_loottable_repository.h | 28 +- .../repositories/base/base_mail_repository.h | 22 +- .../base/base_merchantlist_repository.h | 30 +- .../base/base_merchantlist_temp_repository.h | 18 +- .../base/base_name_filter_repository.h | 16 +- .../base/base_npc_emotes_repository.h | 19 +- .../base_npc_faction_entries_repository.h | 19 +- .../base/base_npc_faction_repository.h | 18 +- .../base_npc_scale_global_base_repository.h | 42 ++- ...se_npc_spells_effects_entries_repository.h | 22 +- .../base/base_npc_spells_effects_repository.h | 17 +- .../base/base_npc_spells_entries_repository.h | 26 +- .../base/base_npc_spells_repository.h | 35 +- .../base/base_npc_types_repository.h | 137 ++++++- .../base/base_npc_types_tint_repository.h | 43 ++- .../base/base_object_contents_repository.h | 64 +++- .../base/base_object_repository.h | 48 ++- ...se_perl_event_export_settings_repository.h | 21 +- .../base/base_petitions_repository.h | 36 +- .../base_pets_beastlord_data_repository.h | 21 +- ...ase_pets_equipmentset_entries_repository.h | 17 +- .../base/base_pets_equipmentset_repository.h | 17 +- .../repositories/base/base_pets_repository.h | 103 ++++-- .../base/base_player_titlesets_repository.h | 17 +- .../base/base_proximities_repository.h | 22 +- .../base/base_quest_globals_repository.h | 20 +- .../base/base_raid_details_repository.h | 18 +- .../base/base_raid_members_repository.h | 23 +- .../base/base_reports_repository.h | 18 +- .../base/base_respawn_times_repository.h | 18 +- .../base/base_rule_sets_repository.h | 16 +- .../base/base_rule_values_repository.h | 18 +- .../base/base_saylink_repository.h | 16 +- .../base_server_scheduled_events_repository.h | 63 +++- ...ase_shared_task_dynamic_zones_repository.h | 22 +- .../base_shared_task_members_repository.h | 29 +- .../base/base_skill_caps_repository.h | 19 +- .../base/base_spawn2_repository.h | 38 +- .../base_spawn_condition_values_repository.h | 18 +- .../base/base_spawn_conditions_repository.h | 19 +- .../base/base_spawn_events_repository.h | 28 +- .../base/base_spawnentry_repository.h | 66 +++- .../base/base_spawngroup_repository.h | 27 +- .../base/base_spell_buckets_repository.h | 23 +- .../base/base_spell_globals_repository.h | 18 +- .../base/base_spells_new_repository.h | 251 ++++++++++++- .../base/base_start_zones_repository.h | 37 +- .../base/base_starting_items_repository.h | 31 +- .../base/base_task_activities_repository.h | 29 +- .../base/base_tasksets_repository.h | 16 +- .../base/base_timers_repository.h | 19 +- .../base/base_titles_repository.h | 28 +- .../base/base_trader_repository.h | 20 +- ...ase_tradeskill_recipe_entries_repository.h | 22 +- .../base/base_tradeskill_recipe_repository.h | 33 +- .../repositories/base/base_traps_repository.h | 43 ++- .../base/base_tribute_levels_repository.h | 18 +- .../base/base_tributes_repository.h | 19 +- ...base_veteran_reward_templates_repository.h | 19 +- .../base/base_zone_points_repository.h | 42 ++- .../repositories/base/base_zone_repository.h | 118 +++++- common/repositories/books_repository.h | 70 ++++ .../character_exp_modifiers_repository.h | 70 ++++ common/repositories/horses_repository.h | 6 +- .../pets_beastlord_data_repository.h | 70 ++++ 170 files changed, 5543 insertions(+), 511 deletions(-) create mode 100644 common/repositories/base/base_books_repository.h create mode 100644 common/repositories/base/base_character_exp_modifiers_repository.h create mode 100644 common/repositories/books_repository.h create mode 100644 common/repositories/character_exp_modifiers_repository.h create mode 100644 common/repositories/pets_beastlord_data_repository.h diff --git a/common/repositories/base/base_aa_ability_repository.h b/common/repositories/base/base_aa_ability_repository.h index a6079b617..40a8e2f18 100644 --- a/common/repositories/base/base_aa_ability_repository.h +++ b/common/repositories/base/base_aa_ability_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAaAbilityRepository { public: @@ -59,11 +60,36 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "category", + "classes", + "races", + "drakkin_heritage", + "deities", + "status", + "type", + "charges", + "grant_only", + "first_rank_id", + "enabled", + "reset_on_death", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("aa_ability"); @@ -73,7 +99,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_aa_rank_effects_repository.h b/common/repositories/base/base_aa_rank_effects_repository.h index 3fca2393c..4d9c0684d 100644 --- a/common/repositories/base/base_aa_rank_effects_repository.h +++ b/common/repositories/base/base_aa_rank_effects_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAaRankEffectsRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "rank_id", + "slot", + "effect_id", + "base1", + "base2", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("aa_rank_effects"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_aa_rank_prereqs_repository.h b/common/repositories/base/base_aa_rank_prereqs_repository.h index a2d0f584a..e6e76061c 100644 --- a/common/repositories/base/base_aa_rank_prereqs_repository.h +++ b/common/repositories/base/base_aa_rank_prereqs_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAaRankPrereqsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "rank_id", + "aa_id", + "points", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("aa_rank_prereqs"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_aa_ranks_repository.h b/common/repositories/base/base_aa_ranks_repository.h index 57bf035d2..2f72f088f 100644 --- a/common/repositories/base/base_aa_ranks_repository.h +++ b/common/repositories/base/base_aa_ranks_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAaRanksRepository { public: @@ -57,11 +58,35 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "upper_hotkey_sid", + "lower_hotkey_sid", + "title_sid", + "desc_sid", + "cost", + "level_req", + "spell", + "spell_type", + "recast_time", + "expansion", + "prev_id", + "next_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("aa_ranks"); @@ -71,7 +96,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_account_flags_repository.h b/common/repositories/base/base_account_flags_repository.h index 68929ef37..00ba26713 100644 --- a/common/repositories/base/base_account_flags_repository.h +++ b/common/repositories/base/base_account_flags_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAccountFlagsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "p_accid", + "p_flag", + "p_value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("account_flags"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_account_ip_repository.h b/common/repositories/base/base_account_ip_repository.h index 2a3a93e62..e55a628c0 100644 --- a/common/repositories/base/base_account_ip_repository.h +++ b/common/repositories/base/base_account_ip_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAccountIpRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "accid", + "ip", + "count", + "lastused", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("account_ip"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -74,7 +90,7 @@ public: entry.accid = 0; entry.ip = ""; entry.count = 1; - entry.lastused = ""; + entry.lastused = std::time(nullptr); return entry; } diff --git a/common/repositories/base/base_account_rewards_repository.h b/common/repositories/base/base_account_rewards_repository.h index 4fd0ecb63..cc2fc52a2 100644 --- a/common/repositories/base/base_account_rewards_repository.h +++ b/common/repositories/base/base_account_rewards_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAccountRewardsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "account_id", + "reward_id", + "amount", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("account_rewards"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_details_repository.h b/common/repositories/base/base_adventure_details_repository.h index cf6b27197..2eac688ab 100644 --- a/common/repositories/base/base_adventure_details_repository.h +++ b/common/repositories/base/base_adventure_details_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureDetailsRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "adventure_id", + "instance_id", + "count", + "assassinate_count", + "status", + "time_created", + "time_zoned", + "time_completed", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_details"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_members_repository.h b/common/repositories/base/base_adventure_members_repository.h index 80f824175..81102350c 100644 --- a/common/repositories/base/base_adventure_members_repository.h +++ b/common/repositories/base/base_adventure_members_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureMembersRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "charid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_members"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_stats_repository.h b/common/repositories/base/base_adventure_stats_repository.h index bd21e2fef..68d3ba20d 100644 --- a/common/repositories/base/base_adventure_stats_repository.h +++ b/common/repositories/base/base_adventure_stats_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureStatsRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "player_id", + "guk_wins", + "mir_wins", + "mmc_wins", + "ruj_wins", + "tak_wins", + "guk_losses", + "mir_losses", + "mmc_losses", + "ruj_losses", + "tak_losses", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_stats"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_template_entry_flavor_repository.h b/common/repositories/base/base_adventure_template_entry_flavor_repository.h index fc586a252..808c3e9d5 100644 --- a/common/repositories/base/base_adventure_template_entry_flavor_repository.h +++ b/common/repositories/base/base_adventure_template_entry_flavor_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureTemplateEntryFlavorRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "text", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_template_entry_flavor"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_template_entry_repository.h b/common/repositories/base/base_adventure_template_entry_repository.h index 6a348b350..7ae32df88 100644 --- a/common/repositories/base/base_adventure_template_entry_repository.h +++ b/common/repositories/base/base_adventure_template_entry_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureTemplateEntryRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "template_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_template_entry"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_adventure_template_repository.h b/common/repositories/base/base_adventure_template_repository.h index b54e4fa89..f9d2e150e 100644 --- a/common/repositories/base/base_adventure_template_repository.h +++ b/common/repositories/base/base_adventure_template_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAdventureTemplateRepository { public: @@ -97,11 +98,55 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "zone_version", + "is_hard", + "is_raid", + "min_level", + "max_level", + "type", + "type_data", + "type_count", + "assa_x", + "assa_y", + "assa_z", + "assa_h", + "text", + "duration", + "zone_in_time", + "win_points", + "lose_points", + "theme", + "zone_in_zone_id", + "zone_in_x", + "zone_in_y", + "zone_in_object_id", + "dest_x", + "dest_y", + "dest_z", + "dest_h", + "graveyard_zone_id", + "graveyard_x", + "graveyard_y", + "graveyard_z", + "graveyard_radius", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("adventure_template"); @@ -111,7 +156,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -148,7 +193,7 @@ public: entry.zone_in_time = 1800; entry.win_points = 0; entry.lose_points = 0; - entry.theme = LDoNThemes::GUK; + entry.theme = 1; entry.zone_in_zone_id = 0; entry.zone_in_x = 0; entry.zone_in_y = 0; diff --git a/common/repositories/base/base_alternate_currency_repository.h b/common/repositories/base/base_alternate_currency_repository.h index 1687d66c3..187309a05 100644 --- a/common/repositories/base/base_alternate_currency_repository.h +++ b/common/repositories/base/base_alternate_currency_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAlternateCurrencyRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "item_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("alternate_currency"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_auras_repository.h b/common/repositories/base/base_auras_repository.h index 478413ffa..98838bc51 100644 --- a/common/repositories/base/base_auras_repository.h +++ b/common/repositories/base/base_auras_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseAurasRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "type", + "npc_type", + "name", + "spell_id", + "distance", + "aura_type", + "spawn_type", + "movement", + "duration", + "icon", + "cast_time", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("auras"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_base_data_repository.h b/common/repositories/base/base_base_data_repository.h index ea152964b..aa848aa75 100644 --- a/common/repositories/base/base_base_data_repository.h +++ b/common/repositories/base/base_base_data_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseBaseDataRepository { public: @@ -51,11 +52,32 @@ public: }; } + static std::vector SelectColumns() + { + return { + "level", + "`class`", + "hp", + "mana", + "end", + "unk1", + "unk2", + "hp_fac", + "mana_fac", + "end_fac", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("base_data"); @@ -65,7 +87,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_blocked_spells_repository.h b/common/repositories/base/base_blocked_spells_repository.h index 3905a30d6..31b47e448 100644 --- a/common/repositories/base/base_blocked_spells_repository.h +++ b/common/repositories/base/base_blocked_spells_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseBlockedSpellsRepository { public: @@ -55,11 +56,34 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "spellid", + "type", + "zoneid", + "x", + "y", + "z", + "x_diff", + "y_diff", + "z_diff", + "message", + "description", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("blocked_spells"); @@ -69,7 +93,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_books_repository.h b/common/repositories/base/base_books_repository.h new file mode 100644 index 000000000..11561eacc --- /dev/null +++ b/common/repositories/base/base_books_repository.h @@ -0,0 +1,326 @@ +/** + * DO NOT MODIFY THIS FILE + * + * This repository was automatically generated and is NOT to be modified directly. + * Any repository modifications are meant to be made to the repository extending the base. + * Any modifications to base repositories are to be made by the generator only + * + * @generator ./utils/scripts/generators/repository-generator.pl + * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + */ + +#ifndef EQEMU_BASE_BOOKS_REPOSITORY_H +#define EQEMU_BASE_BOOKS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" +#include + +class BaseBooksRepository { +public: + struct Books { + int id; + std::string name; + std::string txtfile; + int language; + }; + + static std::string PrimaryKey() + { + return std::string("id"); + } + + static std::vector Columns() + { + return { + "id", + "name", + "txtfile", + "language", + }; + } + + static std::vector SelectColumns() + { + return { + "id", + "name", + "txtfile", + "language", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + + static std::string TableName() + { + return std::string("books"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + SelectColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + ColumnsRaw() + ); + } + + static Books NewEntity() + { + Books entry{}; + + entry.id = 0; + entry.name = ""; + entry.txtfile = ""; + entry.language = 0; + + return entry; + } + + static Books GetBooksEntry( + const std::vector &bookss, + int books_id + ) + { + for (auto &books : bookss) { + if (books.id == books_id) { + return books; + } + } + + return NewEntity(); + } + + static Books FindOne( + Database& db, + int books_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + books_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + Books entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.txtfile = row[2] ? row[2] : ""; + entry.language = atoi(row[3]); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + Database& db, + int books_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + books_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Database& db, + Books books_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[1] + " = '" + EscapeString(books_entry.name) + "'"); + update_values.push_back(columns[2] + " = '" + EscapeString(books_entry.txtfile) + "'"); + update_values.push_back(columns[3] + " = " + std::to_string(books_entry.language)); + + auto results = db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + books_entry.id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static Books InsertOne( + Database& db, + Books books_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(books_entry.id)); + insert_values.push_back("'" + EscapeString(books_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'"); + insert_values.push_back(std::to_string(books_entry.language)); + + auto results = db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + books_entry.id = results.LastInsertedID(); + return books_entry; + } + + books_entry = NewEntity(); + + return books_entry; + } + + static int InsertMany( + Database& db, + std::vector books_entries + ) + { + std::vector insert_chunks; + + for (auto &books_entry: books_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(books_entry.id)); + insert_values.push_back("'" + EscapeString(books_entry.name) + "'"); + insert_values.push_back("'" + EscapeString(books_entry.txtfile) + "'"); + insert_values.push_back(std::to_string(books_entry.language)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = db.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All(Database& db) + { + std::vector all_entries; + + auto results = db.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + Books entry{}; + + entry.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.txtfile = row[2] ? row[2] : ""; + entry.language = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(Database& db, std::string where_filter) + { + std::vector all_entries; + + auto results = 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.id = atoi(row[0]); + entry.name = row[1] ? row[1] : ""; + entry.txtfile = row[2] ? row[2] : ""; + entry.language = atoi(row[3]); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(Database& db, std::string where_filter) + { + auto results = db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int Truncate(Database& db) + { + auto results = db.QueryDatabase( + fmt::format( + "TRUNCATE TABLE {}", + TableName() + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_BOOKS_REPOSITORY_H diff --git a/common/repositories/base/base_bug_reports_repository.h b/common/repositories/base/base_bug_reports_repository.h index 1f5385994..db65d5e05 100644 --- a/common/repositories/base/base_bug_reports_repository.h +++ b/common/repositories/base/base_bug_reports_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseBugReportsRepository { public: @@ -45,9 +46,9 @@ public: int _unknown_value; std::string bug_report; std::string system_info; - std::string report_datetime; + time_t report_datetime; int bug_status; - std::string last_review; + time_t last_review; std::string last_reviewer; std::string reviewer_notes; }; @@ -95,11 +96,54 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "client_version_id", + "client_version_name", + "account_id", + "character_id", + "character_name", + "reporter_spoof", + "category_id", + "category_name", + "reporter_name", + "ui_path", + "pos_x", + "pos_y", + "pos_z", + "heading", + "time_played", + "target_id", + "target_name", + "optional_info_mask", + "_can_duplicate", + "_crash_bug", + "_target_info", + "_character_flags", + "_unknown_value", + "bug_report", + "system_info", + "UNIX_TIMESTAMP(report_datetime)", + "bug_status", + "UNIX_TIMESTAMP(last_review)", + "last_reviewer", + "reviewer_notes", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("bug_reports"); @@ -109,7 +153,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -154,9 +198,9 @@ public: entry._unknown_value = 0; entry.bug_report = ""; entry.system_info = ""; - entry.report_datetime = ""; + entry.report_datetime = std::time(nullptr); entry.bug_status = 0; - entry.last_review = ""; + entry.last_review = std::time(nullptr); entry.last_reviewer = "None"; entry.reviewer_notes = ""; @@ -221,9 +265,9 @@ public: entry._unknown_value = atoi(row[24]); entry.bug_report = row[25] ? row[25] : ""; entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = row[27] ? row[27] : ""; + entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); entry.bug_status = atoi(row[28]); - entry.last_review = row[29] ? row[29] : ""; + entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); entry.last_reviewer = row[30] ? row[30] : ""; entry.reviewer_notes = row[31] ? row[31] : ""; @@ -285,9 +329,9 @@ public: update_values.push_back(columns[24] + " = " + std::to_string(bug_reports_entry._unknown_value)); update_values.push_back(columns[25] + " = '" + EscapeString(bug_reports_entry.bug_report) + "'"); update_values.push_back(columns[26] + " = '" + EscapeString(bug_reports_entry.system_info) + "'"); - update_values.push_back(columns[27] + " = '" + EscapeString(bug_reports_entry.report_datetime) + "'"); + update_values.push_back(columns[27] + " = FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); update_values.push_back(columns[28] + " = " + std::to_string(bug_reports_entry.bug_status)); - update_values.push_back(columns[29] + " = '" + EscapeString(bug_reports_entry.last_review) + "'"); + update_values.push_back(columns[29] + " = FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); update_values.push_back(columns[30] + " = '" + EscapeString(bug_reports_entry.last_reviewer) + "'"); update_values.push_back(columns[31] + " = '" + EscapeString(bug_reports_entry.reviewer_notes) + "'"); @@ -338,9 +382,9 @@ public: insert_values.push_back(std::to_string(bug_reports_entry._unknown_value)); insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); insert_values.push_back(std::to_string(bug_reports_entry.bug_status)); - insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'"); @@ -399,9 +443,9 @@ public: insert_values.push_back(std::to_string(bug_reports_entry._unknown_value)); insert_values.push_back("'" + EscapeString(bug_reports_entry.bug_report) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.system_info) + "'"); - insert_values.push_back("'" + EscapeString(bug_reports_entry.report_datetime) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.report_datetime > 0 ? std::to_string(bug_reports_entry.report_datetime) : "null") + ")"); insert_values.push_back(std::to_string(bug_reports_entry.bug_status)); - insert_values.push_back("'" + EscapeString(bug_reports_entry.last_review) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (bug_reports_entry.last_review > 0 ? std::to_string(bug_reports_entry.last_review) : "null") + ")"); insert_values.push_back("'" + EscapeString(bug_reports_entry.last_reviewer) + "'"); insert_values.push_back("'" + EscapeString(bug_reports_entry.reviewer_notes) + "'"); @@ -464,9 +508,9 @@ public: entry._unknown_value = atoi(row[24]); entry.bug_report = row[25] ? row[25] : ""; entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = row[27] ? row[27] : ""; + entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); entry.bug_status = atoi(row[28]); - entry.last_review = row[29] ? row[29] : ""; + entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); entry.last_reviewer = row[30] ? row[30] : ""; entry.reviewer_notes = row[31] ? row[31] : ""; @@ -520,9 +564,9 @@ public: entry._unknown_value = atoi(row[24]); entry.bug_report = row[25] ? row[25] : ""; entry.system_info = row[26] ? row[26] : ""; - entry.report_datetime = row[27] ? row[27] : ""; + entry.report_datetime = strtoll(row[27] ? row[27] : "-1", nullptr, 10); entry.bug_status = atoi(row[28]); - entry.last_review = row[29] ? row[29] : ""; + entry.last_review = strtoll(row[29] ? row[29] : "-1", nullptr, 10); entry.last_reviewer = row[30] ? row[30] : ""; entry.reviewer_notes = row[31] ? row[31] : ""; diff --git a/common/repositories/base/base_bugs_repository.h b/common/repositories/base/base_bugs_repository.h index da35828c1..6fff42ed9 100644 --- a/common/repositories/base/base_bugs_repository.h +++ b/common/repositories/base/base_bugs_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseBugsRepository { public: @@ -57,11 +58,35 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "name", + "ui", + "x", + "y", + "z", + "type", + "flag", + "target", + "bug", + "date", + "status", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("bugs"); @@ -71,7 +96,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_buyer_repository.h b/common/repositories/base/base_buyer_repository.h index 292792ddb..1299f203a 100644 --- a/common/repositories/base/base_buyer_repository.h +++ b/common/repositories/base/base_buyer_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseBuyerRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "buyslot", + "itemid", + "itemname", + "quantity", + "price", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("buyer"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_char_create_combinations_repository.h b/common/repositories/base/base_char_create_combinations_repository.h index 8423f9751..1548c96e3 100644 --- a/common/repositories/base/base_char_create_combinations_repository.h +++ b/common/repositories/base/base_char_create_combinations_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharCreateCombinationsRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "allocation_id", + "race", + "`class`", + "deity", + "start_zone", + "expansions_req", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("char_create_combinations"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_char_create_point_allocations_repository.h b/common/repositories/base/base_char_create_point_allocations_repository.h index 668fc5062..2ca6d2359 100644 --- a/common/repositories/base/base_char_create_point_allocations_repository.h +++ b/common/repositories/base/base_char_create_point_allocations_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharCreatePointAllocationsRepository { public: @@ -61,11 +62,37 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "base_str", + "base_sta", + "base_dex", + "base_agi", + "base_int", + "base_wis", + "base_cha", + "alloc_str", + "alloc_sta", + "alloc_dex", + "alloc_agi", + "alloc_int", + "alloc_wis", + "alloc_cha", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("char_create_point_allocations"); @@ -75,7 +102,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_char_recipe_list_repository.h b/common/repositories/base/base_char_recipe_list_repository.h index 541859f49..26b340f66 100644 --- a/common/repositories/base/base_char_recipe_list_repository.h +++ b/common/repositories/base/base_char_recipe_list_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharRecipeListRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "recipe_id", + "madecount", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("char_recipe_list"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_activities_repository.h b/common/repositories/base/base_character_activities_repository.h index e4014c0a4..2b3441055 100644 --- a/common/repositories/base/base_character_activities_repository.h +++ b/common/repositories/base/base_character_activities_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterActivitiesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "taskid", + "activityid", + "donecount", + "completed", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_activities"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_alt_currency_repository.h b/common/repositories/base/base_character_alt_currency_repository.h index 31228ba3b..3dad9cbbb 100644 --- a/common/repositories/base/base_character_alt_currency_repository.h +++ b/common/repositories/base/base_character_alt_currency_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterAltCurrencyRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "currency_id", + "amount", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_alt_currency"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_alternate_abilities_repository.h b/common/repositories/base/base_character_alternate_abilities_repository.h index a3616643d..ae91d1274 100644 --- a/common/repositories/base/base_character_alternate_abilities_repository.h +++ b/common/repositories/base/base_character_alternate_abilities_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterAlternateAbilitiesRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "aa_id", + "aa_value", + "charges", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_alternate_abilities"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_auras_repository.h b/common/repositories/base/base_character_auras_repository.h index 10f9d3ac4..84b165619 100644 --- a/common/repositories/base/base_character_auras_repository.h +++ b/common/repositories/base/base_character_auras_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterAurasRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot", + "spell_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_auras"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_bandolier_repository.h b/common/repositories/base/base_character_bandolier_repository.h index f4c725fb7..be3adfb2d 100644 --- a/common/repositories/base/base_character_bandolier_repository.h +++ b/common/repositories/base/base_character_bandolier_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterBandolierRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "bandolier_id", + "bandolier_slot", + "item_id", + "icon", + "bandolier_name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_bandolier"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_bind_repository.h b/common/repositories/base/base_character_bind_repository.h index c31979a8d..4cc042596 100644 --- a/common/repositories/base/base_character_bind_repository.h +++ b/common/repositories/base/base_character_bind_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterBindRepository { public: @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot", + "zone_id", + "instance_id", + "x", + "y", + "z", + "heading", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_bind"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_buffs_repository.h b/common/repositories/base/base_character_buffs_repository.h index 51d179c86..8205dac53 100644 --- a/common/repositories/base/base_character_buffs_repository.h +++ b/common/repositories/base/base_character_buffs_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterBuffsRepository { public: @@ -65,11 +66,39 @@ public: }; } + static std::vector SelectColumns() + { + return { + "character_id", + "slot_id", + "spell_id", + "caster_level", + "caster_name", + "ticsremaining", + "counters", + "numhits", + "melee_rune", + "magic_rune", + "persistent", + "dot_rune", + "caston_x", + "caston_y", + "caston_z", + "ExtraDIChance", + "instrument_mod", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_buffs"); @@ -79,7 +108,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_corpse_items_repository.h b/common/repositories/base/base_character_corpse_items_repository.h index 37343835f..b12e4c95a 100644 --- a/common/repositories/base/base_character_corpse_items_repository.h +++ b/common/repositories/base/base_character_corpse_items_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterCorpseItemsRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "corpse_id", + "equip_slot", + "item_id", + "charges", + "aug_1", + "aug_2", + "aug_3", + "aug_4", + "aug_5", + "aug_6", + "attuned", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_corpse_items"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_corpses_repository.h b/common/repositories/base/base_character_corpses_repository.h index f215a351f..e44604759 100644 --- a/common/repositories/base/base_character_corpses_repository.h +++ b/common/repositories/base/base_character_corpses_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterCorpsesRepository { public: @@ -27,7 +28,7 @@ public: float y; float z; float heading; - std::string time_of_death; + time_t time_of_death; int guild_consent_id; int is_rezzed; int is_buried; @@ -125,11 +126,69 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "charid", + "charname", + "zone_id", + "instance_id", + "x", + "y", + "z", + "heading", + "UNIX_TIMESTAMP(time_of_death)", + "guild_consent_id", + "is_rezzed", + "is_buried", + "was_at_graveyard", + "is_locked", + "exp", + "size", + "level", + "race", + "gender", + "`class`", + "deity", + "texture", + "helm_texture", + "copper", + "silver", + "gold", + "platinum", + "hair_color", + "beard_color", + "eye_color_1", + "eye_color_2", + "hair_style", + "face", + "beard", + "drakkin_heritage", + "drakkin_tattoo", + "drakkin_details", + "wc_1", + "wc_2", + "wc_3", + "wc_4", + "wc_5", + "wc_6", + "wc_7", + "wc_8", + "wc_9", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_corpses"); @@ -139,7 +198,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -166,7 +225,7 @@ public: entry.y = 0; entry.z = 0; entry.heading = 0; - entry.time_of_death = "0000-00-00 00:00:00"; + entry.time_of_death = 0; entry.guild_consent_id = 0; entry.is_rezzed = 0; entry.is_buried = 0; @@ -248,7 +307,7 @@ public: entry.y = static_cast(atof(row[6])); entry.z = static_cast(atof(row[7])); entry.heading = static_cast(atof(row[8])); - entry.time_of_death = row[9] ? row[9] : ""; + entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); entry.guild_consent_id = atoi(row[10]); entry.is_rezzed = atoi(row[11]); entry.is_buried = atoi(row[12]); @@ -327,7 +386,7 @@ public: 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[9] + " = FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); 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)); update_values.push_back(columns[12] + " = " + std::to_string(character_corpses_entry.is_buried)); @@ -395,7 +454,7 @@ public: 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("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); 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)); insert_values.push_back(std::to_string(character_corpses_entry.is_buried)); @@ -471,7 +530,7 @@ public: 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("FROM_UNIXTIME(" + (character_corpses_entry.time_of_death > 0 ? std::to_string(character_corpses_entry.time_of_death) : "null") + ")"); 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)); insert_values.push_back(std::to_string(character_corpses_entry.is_buried)); @@ -551,7 +610,7 @@ public: entry.y = static_cast(atof(row[6])); entry.z = static_cast(atof(row[7])); entry.heading = static_cast(atof(row[8])); - entry.time_of_death = row[9] ? row[9] : ""; + entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); entry.guild_consent_id = atoi(row[10]); entry.is_rezzed = atoi(row[11]); entry.is_buried = atoi(row[12]); @@ -622,7 +681,7 @@ public: entry.y = static_cast(atof(row[6])); entry.z = static_cast(atof(row[7])); entry.heading = static_cast(atof(row[8])); - entry.time_of_death = row[9] ? row[9] : ""; + entry.time_of_death = strtoll(row[9] ? row[9] : "-1", nullptr, 10); entry.guild_consent_id = atoi(row[10]); entry.is_rezzed = atoi(row[11]); entry.is_buried = atoi(row[12]); diff --git a/common/repositories/base/base_character_currency_repository.h b/common/repositories/base/base_character_currency_repository.h index a50a4cd7b..b1e561608 100644 --- a/common/repositories/base/base_character_currency_repository.h +++ b/common/repositories/base/base_character_currency_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterCurrencyRepository { public: @@ -65,11 +66,39 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "platinum", + "gold", + "silver", + "copper", + "platinum_bank", + "gold_bank", + "silver_bank", + "copper_bank", + "platinum_cursor", + "gold_cursor", + "silver_cursor", + "copper_cursor", + "radiant_crystals", + "career_radiant_crystals", + "ebon_crystals", + "career_ebon_crystals", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_currency"); @@ -79,7 +108,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_data_repository.h b/common/repositories/base/base_character_data_repository.h index b95d42447..d6c96e211 100644 --- a/common/repositories/base/base_character_data_repository.h +++ b/common/repositories/base/base_character_data_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterDataRepository { public: @@ -119,7 +120,7 @@ public: int aa_points_spent_old; int aa_points_old; int e_last_invsnapshot; - std::string deleted_at; + time_t deleted_at; }; static std::string PrimaryKey() @@ -235,11 +236,124 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "account_id", + "name", + "last_name", + "title", + "suffix", + "zone_id", + "zone_instance", + "y", + "x", + "z", + "heading", + "gender", + "race", + "`class`", + "level", + "deity", + "birthday", + "last_login", + "time_played", + "level2", + "anon", + "gm", + "face", + "hair_color", + "hair_style", + "beard", + "beard_color", + "eye_color_1", + "eye_color_2", + "drakkin_heritage", + "drakkin_tattoo", + "drakkin_details", + "ability_time_seconds", + "ability_number", + "ability_time_minutes", + "ability_time_hours", + "exp", + "aa_points_spent", + "aa_exp", + "aa_points", + "group_leadership_exp", + "raid_leadership_exp", + "group_leadership_points", + "raid_leadership_points", + "points", + "cur_hp", + "mana", + "endurance", + "intoxication", + "str", + "sta", + "cha", + "dex", + "`int`", + "agi", + "wis", + "zone_change_count", + "toxicity", + "hunger_level", + "thirst_level", + "ability_up", + "ldon_points_guk", + "ldon_points_mir", + "ldon_points_mmc", + "ldon_points_ruj", + "ldon_points_tak", + "ldon_points_available", + "tribute_time_remaining", + "career_tribute_points", + "tribute_points", + "tribute_active", + "pvp_status", + "pvp_kills", + "pvp_deaths", + "pvp_current_points", + "pvp_career_points", + "pvp_best_kill_streak", + "pvp_worst_death_streak", + "pvp_current_kill_streak", + "pvp2", + "pvp_type", + "show_helm", + "group_auto_consent", + "raid_auto_consent", + "guild_auto_consent", + "leadership_exp_on", + "RestTimer", + "air_remaining", + "autosplit_enabled", + "lfp", + "lfg", + "mailkey", + "xtargets", + "firstlogon", + "e_aa_effects", + "e_percent_to_aa", + "e_expended_aa_spent", + "aa_points_spent_old", + "aa_points_old", + "e_last_invsnapshot", + "UNIX_TIMESTAMP(deleted_at)", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_data"); @@ -249,7 +363,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -368,7 +482,7 @@ public: entry.aa_points_spent_old = 0; entry.aa_points_old = 0; entry.e_last_invsnapshot = 0; - entry.deleted_at = ""; + entry.deleted_at = 0; return entry; } @@ -505,7 +619,7 @@ public: 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] ? row[101] : ""; + entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); return entry; } @@ -639,7 +753,7 @@ public: update_values.push_back(columns[98] + " = " + std::to_string(character_data_entry.aa_points_spent_old)); update_values.push_back(columns[99] + " = " + std::to_string(character_data_entry.aa_points_old)); update_values.push_back(columns[100] + " = " + std::to_string(character_data_entry.e_last_invsnapshot)); - update_values.push_back(columns[101] + " = '" + EscapeString(character_data_entry.deleted_at) + "'"); + update_values.push_back(columns[101] + " = FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -762,7 +876,7 @@ public: insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); - insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -893,7 +1007,7 @@ public: insert_values.push_back(std::to_string(character_data_entry.aa_points_spent_old)); insert_values.push_back(std::to_string(character_data_entry.aa_points_old)); insert_values.push_back(std::to_string(character_data_entry.e_last_invsnapshot)); - insert_values.push_back("'" + EscapeString(character_data_entry.deleted_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (character_data_entry.deleted_at > 0 ? std::to_string(character_data_entry.deleted_at) : "null") + ")"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -1028,7 +1142,7 @@ public: 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] ? row[101] : ""; + entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); all_entries.push_back(entry); } @@ -1154,7 +1268,7 @@ public: 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] ? row[101] : ""; + entry.deleted_at = strtoll(row[101] ? row[101] : "-1", nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_character_disciplines_repository.h b/common/repositories/base/base_character_disciplines_repository.h index a1870e5a0..42ab05fbb 100644 --- a/common/repositories/base/base_character_disciplines_repository.h +++ b/common/repositories/base/base_character_disciplines_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterDisciplinesRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot_id", + "disc_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_disciplines"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_exp_modifiers_repository.h b/common/repositories/base/base_character_exp_modifiers_repository.h new file mode 100644 index 000000000..51cf134ad --- /dev/null +++ b/common/repositories/base/base_character_exp_modifiers_repository.h @@ -0,0 +1,327 @@ +/** + * DO NOT MODIFY THIS FILE + * + * This repository was automatically generated and is NOT to be modified directly. + * Any repository modifications are meant to be made to the repository extending the base. + * Any modifications to base repositories are to be made by the generator only + * + * @generator ./utils/scripts/generators/repository-generator.pl + * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories + */ + +#ifndef EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H +#define EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H + +#include "../../database.h" +#include "../../string_util.h" +#include + +class BaseCharacterExpModifiersRepository { +public: + struct CharacterExpModifiers { + int character_id; + int zone_id; + float aa_modifier; + float exp_modifier; + }; + + static std::string PrimaryKey() + { + return std::string("character_id"); + } + + static std::vector Columns() + { + return { + "character_id", + "zone_id", + "aa_modifier", + "exp_modifier", + }; + } + + static std::vector SelectColumns() + { + return { + "character_id", + "zone_id", + "aa_modifier", + "exp_modifier", + }; + } + + static std::string ColumnsRaw() + { + return std::string(implode(", ", Columns())); + } + + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + + static std::string TableName() + { + return std::string("character_exp_modifiers"); + } + + static std::string BaseSelect() + { + return fmt::format( + "SELECT {} FROM {}", + SelectColumnsRaw(), + TableName() + ); + } + + static std::string BaseInsert() + { + return fmt::format( + "INSERT INTO {} ({}) ", + TableName(), + ColumnsRaw() + ); + } + + static CharacterExpModifiers NewEntity() + { + CharacterExpModifiers entry{}; + + entry.character_id = 0; + entry.zone_id = 0; + entry.aa_modifier = 0; + entry.exp_modifier = 0; + + return entry; + } + + static CharacterExpModifiers GetCharacterExpModifiersEntry( + const std::vector &character_exp_modifierss, + int character_exp_modifiers_id + ) + { + for (auto &character_exp_modifiers : character_exp_modifierss) { + if (character_exp_modifiers.character_id == character_exp_modifiers_id) { + return character_exp_modifiers; + } + } + + return NewEntity(); + } + + static CharacterExpModifiers FindOne( + Database& db, + int character_exp_modifiers_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "{} WHERE id = {} LIMIT 1", + BaseSelect(), + character_exp_modifiers_id + ) + ); + + auto row = results.begin(); + if (results.RowCount() == 1) { + CharacterExpModifiers entry{}; + + entry.character_id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.aa_modifier = static_cast(atof(row[2])); + entry.exp_modifier = static_cast(atof(row[3])); + + return entry; + } + + return NewEntity(); + } + + static int DeleteOne( + Database& db, + int character_exp_modifiers_id + ) + { + auto results = db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {} = {}", + TableName(), + PrimaryKey(), + character_exp_modifiers_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int UpdateOne( + Database& db, + CharacterExpModifiers character_exp_modifiers_entry + ) + { + std::vector update_values; + + auto columns = Columns(); + + update_values.push_back(columns[0] + " = " + std::to_string(character_exp_modifiers_entry.character_id)); + update_values.push_back(columns[1] + " = " + std::to_string(character_exp_modifiers_entry.zone_id)); + update_values.push_back(columns[2] + " = " + std::to_string(character_exp_modifiers_entry.aa_modifier)); + update_values.push_back(columns[3] + " = " + std::to_string(character_exp_modifiers_entry.exp_modifier)); + + auto results = db.QueryDatabase( + fmt::format( + "UPDATE {} SET {} WHERE {} = {}", + TableName(), + implode(", ", update_values), + PrimaryKey(), + character_exp_modifiers_entry.character_id + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static CharacterExpModifiers InsertOne( + Database& db, + CharacterExpModifiers character_exp_modifiers_entry + ) + { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier)); + + auto results = db.QueryDatabase( + fmt::format( + "{} VALUES ({})", + BaseInsert(), + implode(",", insert_values) + ) + ); + + if (results.Success()) { + character_exp_modifiers_entry.character_id = results.LastInsertedID(); + return character_exp_modifiers_entry; + } + + character_exp_modifiers_entry = NewEntity(); + + return character_exp_modifiers_entry; + } + + static int InsertMany( + Database& db, + std::vector character_exp_modifiers_entries + ) + { + std::vector insert_chunks; + + for (auto &character_exp_modifiers_entry: character_exp_modifiers_entries) { + std::vector insert_values; + + insert_values.push_back(std::to_string(character_exp_modifiers_entry.character_id)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.zone_id)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.aa_modifier)); + insert_values.push_back(std::to_string(character_exp_modifiers_entry.exp_modifier)); + + insert_chunks.push_back("(" + implode(",", insert_values) + ")"); + } + + std::vector insert_values; + + auto results = db.QueryDatabase( + fmt::format( + "{} VALUES {}", + BaseInsert(), + implode(",", insert_chunks) + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static std::vector All(Database& db) + { + std::vector all_entries; + + auto results = db.QueryDatabase( + fmt::format( + "{}", + BaseSelect() + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterExpModifiers entry{}; + + entry.character_id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.aa_modifier = static_cast(atof(row[2])); + entry.exp_modifier = static_cast(atof(row[3])); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static std::vector GetWhere(Database& db, std::string where_filter) + { + std::vector all_entries; + + auto results = db.QueryDatabase( + fmt::format( + "{} WHERE {}", + BaseSelect(), + where_filter + ) + ); + + all_entries.reserve(results.RowCount()); + + for (auto row = results.begin(); row != results.end(); ++row) { + CharacterExpModifiers entry{}; + + entry.character_id = atoi(row[0]); + entry.zone_id = atoi(row[1]); + entry.aa_modifier = static_cast(atof(row[2])); + entry.exp_modifier = static_cast(atof(row[3])); + + all_entries.push_back(entry); + } + + return all_entries; + } + + static int DeleteWhere(Database& db, std::string where_filter) + { + auto results = db.QueryDatabase( + fmt::format( + "DELETE FROM {} WHERE {}", + TableName(), + where_filter + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + + static int Truncate(Database& db) + { + auto results = db.QueryDatabase( + fmt::format( + "TRUNCATE TABLE {}", + TableName() + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + +}; + +#endif //EQEMU_BASE_CHARACTER_EXP_MODIFIERS_REPOSITORY_H diff --git a/common/repositories/base/base_character_expedition_lockouts_repository.h b/common/repositories/base/base_character_expedition_lockouts_repository.h index cfdc17a3b..a8c4e9fd8 100644 --- a/common/repositories/base/base_character_expedition_lockouts_repository.h +++ b/common/repositories/base/base_character_expedition_lockouts_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterExpeditionLockoutsRepository { public: @@ -22,7 +23,7 @@ public: int character_id; std::string expedition_name; std::string event_name; - std::string expire_time; + time_t expire_time; int duration; std::string from_expedition_uuid; }; @@ -45,11 +46,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "character_id", + "expedition_name", + "event_name", + "UNIX_TIMESTAMP(expire_time)", + "duration", + "from_expedition_uuid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_expedition_lockouts"); @@ -59,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -81,7 +100,7 @@ public: entry.character_id = 0; entry.expedition_name = ""; entry.event_name = ""; - entry.expire_time = ""; + entry.expire_time = std::time(nullptr); entry.duration = 0; entry.from_expedition_uuid = ""; @@ -123,7 +142,7 @@ public: entry.character_id = atoi(row[1]); entry.expedition_name = row[2] ? row[2] : ""; entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); entry.duration = atoi(row[5]); entry.from_expedition_uuid = row[6] ? row[6] : ""; @@ -162,7 +181,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_expedition_lockouts_entry.character_id)); update_values.push_back(columns[2] + " = '" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[4] + " = '" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); update_values.push_back(columns[5] + " = " + std::to_string(character_expedition_lockouts_entry.duration)); update_values.push_back(columns[6] + " = '" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -190,7 +209,7 @@ public: insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -226,7 +245,7 @@ public: insert_values.push_back(std::to_string(character_expedition_lockouts_entry.character_id)); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expedition_name) + "'"); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (character_expedition_lockouts_entry.expire_time > 0 ? std::to_string(character_expedition_lockouts_entry.expire_time) : "null") + ")"); insert_values.push_back(std::to_string(character_expedition_lockouts_entry.duration)); insert_values.push_back("'" + EscapeString(character_expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -266,7 +285,7 @@ public: entry.character_id = atoi(row[1]); entry.expedition_name = row[2] ? row[2] : ""; entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); entry.duration = atoi(row[5]); entry.from_expedition_uuid = row[6] ? row[6] : ""; @@ -297,7 +316,7 @@ public: entry.character_id = atoi(row[1]); entry.expedition_name = row[2] ? row[2] : ""; entry.event_name = row[3] ? row[3] : ""; - entry.expire_time = row[4] ? row[4] : ""; + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); entry.duration = atoi(row[5]); entry.from_expedition_uuid = row[6] ? row[6] : ""; diff --git a/common/repositories/base/base_character_inspect_messages_repository.h b/common/repositories/base/base_character_inspect_messages_repository.h index d7158e9a4..70f381879 100644 --- a/common/repositories/base/base_character_inspect_messages_repository.h +++ b/common/repositories/base/base_character_inspect_messages_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterInspectMessagesRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "inspect_message", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_inspect_messages"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_instance_safereturns_repository.h b/common/repositories/base/base_character_instance_safereturns_repository.h index 735c2e4c0..780633f5f 100644 --- a/common/repositories/base/base_character_instance_safereturns_repository.h +++ b/common/repositories/base/base_character_instance_safereturns_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterInstanceSafereturnsRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "character_id", + "instance_zone_id", + "instance_id", + "safe_zone_id", + "safe_x", + "safe_y", + "safe_z", + "safe_heading", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_instance_safereturns"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_item_recast_repository.h b/common/repositories/base/base_character_item_recast_repository.h index fbf105e3d..c38f1e1dc 100644 --- a/common/repositories/base/base_character_item_recast_repository.h +++ b/common/repositories/base/base_character_item_recast_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterItemRecastRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "recast_type", + "timestamp", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_item_recast"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_languages_repository.h b/common/repositories/base/base_character_languages_repository.h index 96bb48e8f..169dd6f6a 100644 --- a/common/repositories/base/base_character_languages_repository.h +++ b/common/repositories/base/base_character_languages_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterLanguagesRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "lang_id", + "value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_languages"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_leadership_abilities_repository.h b/common/repositories/base/base_character_leadership_abilities_repository.h index 63ee5a0dd..0de0b5e8e 100644 --- a/common/repositories/base/base_character_leadership_abilities_repository.h +++ b/common/repositories/base/base_character_leadership_abilities_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterLeadershipAbilitiesRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot", + "rank", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_leadership_abilities"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_material_repository.h b/common/repositories/base/base_character_material_repository.h index 723828fcc..7744aaa75 100644 --- a/common/repositories/base/base_character_material_repository.h +++ b/common/repositories/base/base_character_material_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterMaterialRepository { public: @@ -45,11 +46,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot", + "blue", + "green", + "red", + "use_tint", + "color", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_material"); @@ -59,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_memmed_spells_repository.h b/common/repositories/base/base_character_memmed_spells_repository.h index 846d852d5..7ee116cc7 100644 --- a/common/repositories/base/base_character_memmed_spells_repository.h +++ b/common/repositories/base/base_character_memmed_spells_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterMemmedSpellsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot_id", + "spell_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_memmed_spells"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_pet_buffs_repository.h b/common/repositories/base/base_character_pet_buffs_repository.h index b4ef96b0a..1c0c23a9e 100644 --- a/common/repositories/base/base_character_pet_buffs_repository.h +++ b/common/repositories/base/base_character_pet_buffs_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterPetBuffsRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "pet", + "slot", + "spell_id", + "caster_level", + "castername", + "ticsremaining", + "counters", + "numhits", + "rune", + "instrument_mod", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_pet_buffs"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_pet_info_repository.h b/common/repositories/base/base_character_pet_info_repository.h index b93b2a1e5..63105d84f 100644 --- a/common/repositories/base/base_character_pet_info_repository.h +++ b/common/repositories/base/base_character_pet_info_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterPetInfoRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "pet", + "petname", + "petpower", + "spell_id", + "hp", + "mana", + "size", + "taunting", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_pet_info"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_pet_inventory_repository.h b/common/repositories/base/base_character_pet_inventory_repository.h index b12549dd1..0f12b9704 100644 --- a/common/repositories/base/base_character_pet_inventory_repository.h +++ b/common/repositories/base/base_character_pet_inventory_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterPetInventoryRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "pet", + "slot", + "item_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_pet_inventory"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_potionbelt_repository.h b/common/repositories/base/base_character_potionbelt_repository.h index 7606449ce..d8faca194 100644 --- a/common/repositories/base/base_character_potionbelt_repository.h +++ b/common/repositories/base/base_character_potionbelt_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterPotionbeltRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "potion_id", + "item_id", + "icon", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_potionbelt"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_skills_repository.h b/common/repositories/base/base_character_skills_repository.h index 16454fa21..0bd5eac23 100644 --- a/common/repositories/base/base_character_skills_repository.h +++ b/common/repositories/base/base_character_skills_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterSkillsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "skill_id", + "value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_skills"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_spells_repository.h b/common/repositories/base/base_character_spells_repository.h index 29291cf65..f9465f3df 100644 --- a/common/repositories/base/base_character_spells_repository.h +++ b/common/repositories/base/base_character_spells_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterSpellsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "slot_id", + "spell_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_spells"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_character_task_timers_repository.h b/common/repositories/base/base_character_task_timers_repository.h index f7b5fda49..73ea29182 100644 --- a/common/repositories/base/base_character_task_timers_repository.h +++ b/common/repositories/base/base_character_task_timers_repository.h @@ -134,7 +134,7 @@ public: entry.character_id = atoi(row[1]); entry.task_id = atoi(row[2]); entry.timer_type = atoi(row[3]); - entry.expire_time = strtoll(row[4], nullptr, 10); + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); return entry; } @@ -171,7 +171,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(character_task_timers_entry.character_id)); update_values.push_back(columns[2] + " = " + std::to_string(character_task_timers_entry.task_id)); update_values.push_back(columns[3] + " = " + std::to_string(character_task_timers_entry.timer_type)); - update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")"); + update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -197,7 +197,7 @@ public: insert_values.push_back(std::to_string(character_task_timers_entry.character_id)); insert_values.push_back(std::to_string(character_task_timers_entry.task_id)); insert_values.push_back(std::to_string(character_task_timers_entry.timer_type)); - insert_values.push_back("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -231,7 +231,7 @@ public: insert_values.push_back(std::to_string(character_task_timers_entry.character_id)); insert_values.push_back(std::to_string(character_task_timers_entry.task_id)); insert_values.push_back(std::to_string(character_task_timers_entry.timer_type)); - insert_values.push_back("FROM_UNIXTIME(" + std::to_string(character_task_timers_entry.expire_time) + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (character_task_timers_entry.expire_time > 0 ? std::to_string(character_task_timers_entry.expire_time) : "null") + ")"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -269,7 +269,7 @@ public: entry.character_id = atoi(row[1]); entry.task_id = atoi(row[2]); entry.timer_type = atoi(row[3]); - entry.expire_time = strtoll(row[4], nullptr, 10); + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); all_entries.push_back(entry); } @@ -298,7 +298,7 @@ public: entry.character_id = atoi(row[1]); entry.task_id = atoi(row[2]); entry.timer_type = atoi(row[3]); - entry.expire_time = strtoll(row[4], nullptr, 10); + entry.expire_time = strtoll(row[4] ? row[4] : "-1", nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_character_tasks_repository.h b/common/repositories/base/base_character_tasks_repository.h index 58ba04194..251389557 100644 --- a/common/repositories/base/base_character_tasks_repository.h +++ b/common/repositories/base/base_character_tasks_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCharacterTasksRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "taskid", + "slot", + "type", + "acceptedtime", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("character_tasks"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_completed_tasks_repository.h b/common/repositories/base/base_completed_tasks_repository.h index 61ec15cf2..f6f84bfe9 100644 --- a/common/repositories/base/base_completed_tasks_repository.h +++ b/common/repositories/base/base_completed_tasks_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseCompletedTasksRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "completedtime", + "taskid", + "activityid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("completed_tasks"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_content_flags_repository.h b/common/repositories/base/base_content_flags_repository.h index 3b57905ee..79374fd37 100644 --- a/common/repositories/base/base_content_flags_repository.h +++ b/common/repositories/base/base_content_flags_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseContentFlagsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "flag_name", + "enabled", + "notes", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("content_flags"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_damageshieldtypes_repository.h b/common/repositories/base/base_damageshieldtypes_repository.h index 9e08f4ed9..052b2e8e7 100644 --- a/common/repositories/base/base_damageshieldtypes_repository.h +++ b/common/repositories/base/base_damageshieldtypes_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDamageshieldtypesRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "spellid", + "type", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("damageshieldtypes"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_data_buckets_repository.h b/common/repositories/base/base_data_buckets_repository.h index f50e21592..e144cc3db 100644 --- a/common/repositories/base/base_data_buckets_repository.h +++ b/common/repositories/base/base_data_buckets_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDataBucketsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "key", + "value", + "expires", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("data_buckets"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -110,7 +126,7 @@ public: if (results.RowCount() == 1) { DataBuckets entry{}; - entry.id = strtoll(row[0], NULL, 10); + entry.id = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; entry.expires = atoi(row[3]); @@ -241,7 +257,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { DataBuckets entry{}; - entry.id = strtoll(row[0], NULL, 10); + entry.id = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; entry.expires = atoi(row[3]); @@ -269,7 +285,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { DataBuckets entry{}; - entry.id = strtoll(row[0], NULL, 10); + entry.id = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; entry.expires = atoi(row[3]); diff --git a/common/repositories/base/base_db_str_repository.h b/common/repositories/base/base_db_str_repository.h index e94b29772..0d84d757d 100644 --- a/common/repositories/base/base_db_str_repository.h +++ b/common/repositories/base/base_db_str_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDbStrRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "type", + "value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("db_str"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_discovered_items_repository.h b/common/repositories/base/base_discovered_items_repository.h index 03affdd09..4ee1e2e77 100644 --- a/common/repositories/base/base_discovered_items_repository.h +++ b/common/repositories/base/base_discovered_items_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDiscoveredItemsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "item_id", + "char_name", + "discovered_date", + "account_status", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("discovered_items"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_doors_repository.h b/common/repositories/base/base_doors_repository.h index bcb0d5f49..ff224387d 100644 --- a/common/repositories/base/base_doors_repository.h +++ b/common/repositories/base/base_doors_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDoorsRepository { public: @@ -101,11 +102,57 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "doorid", + "zone", + "version", + "name", + "pos_y", + "pos_x", + "pos_z", + "heading", + "opentype", + "guild", + "lockpick", + "keyitem", + "nokeyring", + "triggerdoor", + "triggertype", + "disable_timer", + "doorisopen", + "door_param", + "dest_zone", + "dest_instance", + "dest_x", + "dest_y", + "dest_z", + "dest_heading", + "invert_state", + "incline", + "size", + "buffer", + "client_version_mask", + "is_ldon_door", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("doors"); @@ -115,7 +162,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -164,8 +211,8 @@ public: entry.buffer = 0; entry.client_version_mask = 4294967295; entry.is_ldon_door = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_dynamic_zone_members_repository.h b/common/repositories/base/base_dynamic_zone_members_repository.h index b0f41ca08..4a9547140 100644 --- a/common/repositories/base/base_dynamic_zone_members_repository.h +++ b/common/repositories/base/base_dynamic_zone_members_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDynamicZoneMembersRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "dynamic_zone_id", + "character_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("dynamic_zone_members"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_dynamic_zones_repository.h b/common/repositories/base/base_dynamic_zones_repository.h index a6f43bb73..5cf186cf2 100644 --- a/common/repositories/base/base_dynamic_zones_repository.h +++ b/common/repositories/base/base_dynamic_zones_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseDynamicZonesRepository { public: @@ -75,11 +76,44 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "instance_id", + "type", + "uuid", + "name", + "leader_id", + "min_players", + "max_players", + "compass_zone_id", + "compass_x", + "compass_y", + "compass_z", + "safe_return_zone_id", + "safe_return_x", + "safe_return_y", + "safe_return_z", + "safe_return_heading", + "zone_in_x", + "zone_in_y", + "zone_in_z", + "zone_in_heading", + "has_zone_in", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("dynamic_zones"); @@ -89,7 +123,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_eventlog_repository.h b/common/repositories/base/base_eventlog_repository.h index 25b6ea1cc..328c6ad4c 100644 --- a/common/repositories/base/base_eventlog_repository.h +++ b/common/repositories/base/base_eventlog_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseEventlogRepository { public: @@ -51,11 +52,32 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "accountname", + "accountid", + "status", + "charname", + "target", + "time", + "descriptiontype", + "description", + "event_nid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("eventlog"); @@ -65,7 +87,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -89,7 +111,7 @@ public: entry.status = 0; entry.charname = ""; entry.target = "None"; - entry.time = ""; + entry.time = std::time(nullptr); entry.descriptiontype = ""; entry.description = ""; entry.event_nid = 0; diff --git a/common/repositories/base/base_expedition_lockouts_repository.h b/common/repositories/base/base_expedition_lockouts_repository.h index 68a606923..b148b1b2d 100644 --- a/common/repositories/base/base_expedition_lockouts_repository.h +++ b/common/repositories/base/base_expedition_lockouts_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseExpeditionLockoutsRepository { public: @@ -21,7 +22,7 @@ public: int id; int expedition_id; std::string event_name; - std::string expire_time; + time_t expire_time; int duration; std::string from_expedition_uuid; }; @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "expedition_id", + "event_name", + "UNIX_TIMESTAMP(expire_time)", + "duration", + "from_expedition_uuid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("expedition_lockouts"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -78,7 +96,7 @@ public: entry.id = 0; entry.expedition_id = 0; entry.event_name = ""; - entry.expire_time = ""; + entry.expire_time = std::time(nullptr); entry.duration = 0; entry.from_expedition_uuid = ""; @@ -119,7 +137,7 @@ public: entry.id = atoi(row[0]); entry.expedition_id = atoi(row[1]); entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; + entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); entry.duration = atoi(row[4]); entry.from_expedition_uuid = row[5] ? row[5] : ""; @@ -157,7 +175,7 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(expedition_lockouts_entry.expedition_id)); update_values.push_back(columns[2] + " = '" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - update_values.push_back(columns[3] + " = '" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + update_values.push_back(columns[3] + " = FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); update_values.push_back(columns[4] + " = " + std::to_string(expedition_lockouts_entry.duration)); update_values.push_back(columns[5] + " = '" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -184,7 +202,7 @@ public: insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -219,7 +237,7 @@ public: insert_values.push_back(std::to_string(expedition_lockouts_entry.id)); insert_values.push_back(std::to_string(expedition_lockouts_entry.expedition_id)); insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.event_name) + "'"); - insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.expire_time) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (expedition_lockouts_entry.expire_time > 0 ? std::to_string(expedition_lockouts_entry.expire_time) : "null") + ")"); insert_values.push_back(std::to_string(expedition_lockouts_entry.duration)); insert_values.push_back("'" + EscapeString(expedition_lockouts_entry.from_expedition_uuid) + "'"); @@ -258,7 +276,7 @@ public: entry.id = atoi(row[0]); entry.expedition_id = atoi(row[1]); entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; + entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); entry.duration = atoi(row[4]); entry.from_expedition_uuid = row[5] ? row[5] : ""; @@ -288,7 +306,7 @@ public: entry.id = atoi(row[0]); entry.expedition_id = atoi(row[1]); entry.event_name = row[2] ? row[2] : ""; - entry.expire_time = row[3] ? row[3] : ""; + entry.expire_time = strtoll(row[3] ? row[3] : "-1", nullptr, 10); entry.duration = atoi(row[4]); entry.from_expedition_uuid = row[5] ? row[5] : ""; diff --git a/common/repositories/base/base_expeditions_repository.h b/common/repositories/base/base_expeditions_repository.h index f77be8bfa..6e4cbdc0b 100644 --- a/common/repositories/base/base_expeditions_repository.h +++ b/common/repositories/base/base_expeditions_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseExpeditionsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "dynamic_zone_id", + "add_replay_on_join", + "is_locked", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("expeditions"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_faction_base_data_repository.h b/common/repositories/base/base_faction_base_data_repository.h index 9357d4ce8..cdf0f463d 100644 --- a/common/repositories/base/base_faction_base_data_repository.h +++ b/common/repositories/base/base_faction_base_data_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFactionBaseDataRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "client_faction_id", + "min", + "max", + "unk_hero1", + "unk_hero2", + "unk_hero3", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("faction_base_data"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_faction_list_mod_repository.h b/common/repositories/base/base_faction_list_mod_repository.h index 0181f5ba3..2a03a0a02 100644 --- a/common/repositories/base/base_faction_list_mod_repository.h +++ b/common/repositories/base/base_faction_list_mod_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFactionListModRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "faction_id", + "mod", + "mod_name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("faction_list_mod"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_faction_list_repository.h b/common/repositories/base/base_faction_list_repository.h index f985d7aad..51068b19b 100644 --- a/common/repositories/base/base_faction_list_repository.h +++ b/common/repositories/base/base_faction_list_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFactionListRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "base", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("faction_list"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_faction_values_repository.h b/common/repositories/base/base_faction_values_repository.h index 2176d287b..ef25a0147 100644 --- a/common/repositories/base/base_faction_values_repository.h +++ b/common/repositories/base/base_faction_values_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFactionValuesRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "faction_id", + "current_value", + "temp", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("faction_values"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_fishing_repository.h b/common/repositories/base/base_fishing_repository.h index 2c6ad7b43..ba0f9eb11 100644 --- a/common/repositories/base/base_fishing_repository.h +++ b/common/repositories/base/base_fishing_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFishingRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zoneid", + "Itemid", + "skill_level", + "chance", + "npc_id", + "npc_chance", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("fishing"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -92,8 +115,8 @@ public: entry.chance = 0; entry.npc_id = 0; entry.npc_chance = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_forage_repository.h b/common/repositories/base/base_forage_repository.h index 4f80658cc..166ee7cd4 100644 --- a/common/repositories/base/base_forage_repository.h +++ b/common/repositories/base/base_forage_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseForageRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zoneid", + "Itemid", + "level", + "chance", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("forage"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -86,8 +107,8 @@ public: entry.Itemid = 0; entry.level = 0; entry.chance = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_friends_repository.h b/common/repositories/base/base_friends_repository.h index a01746174..27115b76d 100644 --- a/common/repositories/base/base_friends_repository.h +++ b/common/repositories/base/base_friends_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseFriendsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "type", + "name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("friends"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_global_loot_repository.h b/common/repositories/base/base_global_loot_repository.h index 81ee74549..dbee15a9e 100644 --- a/common/repositories/base/base_global_loot_repository.h +++ b/common/repositories/base/base_global_loot_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGlobalLootRepository { public: @@ -65,11 +66,39 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "description", + "loottable_id", + "enabled", + "min_level", + "max_level", + "rare", + "raid", + "race", + "`class`", + "bodytype", + "zone", + "hot_zone", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("global_loot"); @@ -79,7 +108,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -110,8 +139,8 @@ public: entry.bodytype = ""; entry.zone = ""; entry.hot_zone = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_gm_ips_repository.h b/common/repositories/base/base_gm_ips_repository.h index 5fa6b1f54..84f18734d 100644 --- a/common/repositories/base/base_gm_ips_repository.h +++ b/common/repositories/base/base_gm_ips_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGmIpsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "name", + "account_id", + "ip_address", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("gm_ips"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_goallists_repository.h b/common/repositories/base/base_goallists_repository.h index ff937c169..79e0919ca 100644 --- a/common/repositories/base/base_goallists_repository.h +++ b/common/repositories/base/base_goallists_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGoallistsRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "listid", + "entry", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("goallists"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_graveyard_repository.h b/common/repositories/base/base_graveyard_repository.h index f104e2236..2df4c292d 100644 --- a/common/repositories/base/base_graveyard_repository.h +++ b/common/repositories/base/base_graveyard_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGraveyardRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone_id", + "x", + "y", + "z", + "heading", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("graveyard"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_ground_spawns_repository.h b/common/repositories/base/base_ground_spawns_repository.h index 4d8b9168d..715dfa14b 100644 --- a/common/repositories/base/base_ground_spawns_repository.h +++ b/common/repositories/base/base_ground_spawns_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGroundSpawnsRepository { public: @@ -67,11 +68,40 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zoneid", + "version", + "max_x", + "max_y", + "max_z", + "min_x", + "min_y", + "heading", + "name", + "item", + "max_allowed", + "comment", + "respawn_timer", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("ground_spawns"); @@ -81,7 +111,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -113,8 +143,8 @@ public: entry.max_allowed = 1; entry.comment = ""; entry.respawn_timer = 300; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_group_id_repository.h b/common/repositories/base/base_group_id_repository.h index 313bfffbe..ce18b2298 100644 --- a/common/repositories/base/base_group_id_repository.h +++ b/common/repositories/base/base_group_id_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGroupIdRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "groupid", + "charid", + "name", + "ismerc", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("group_id"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_group_leaders_repository.h b/common/repositories/base/base_group_leaders_repository.h index d549adaaf..15bd6af3b 100644 --- a/common/repositories/base/base_group_leaders_repository.h +++ b/common/repositories/base/base_group_leaders_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGroupLeadersRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "gid", + "leadername", + "marknpc", + "leadershipaa", + "maintank", + "assist", + "puller", + "mentoree", + "mentor_percent", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("group_leaders"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_guild_members_repository.h b/common/repositories/base/base_guild_members_repository.h index 577817241..df522d479 100644 --- a/common/repositories/base/base_guild_members_repository.h +++ b/common/repositories/base/base_guild_members_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGuildMembersRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "guild_id", + "rank", + "tribute_enable", + "total_tribute", + "last_tribute", + "banker", + "public_note", + "alt", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("guild_members"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_guild_ranks_repository.h b/common/repositories/base/base_guild_ranks_repository.h index cbf7763f7..c777fd1e7 100644 --- a/common/repositories/base/base_guild_ranks_repository.h +++ b/common/repositories/base/base_guild_ranks_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGuildRanksRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "guild_id", + "rank", + "title", + "can_hear", + "can_speak", + "can_invite", + "can_remove", + "can_promote", + "can_demote", + "can_motd", + "can_warpeace", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("guild_ranks"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_guild_relations_repository.h b/common/repositories/base/base_guild_relations_repository.h index 5afe63413..869acc23e 100644 --- a/common/repositories/base/base_guild_relations_repository.h +++ b/common/repositories/base/base_guild_relations_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGuildRelationsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "guild1", + "guild2", + "relation", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("guild_relations"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_guilds_repository.h b/common/repositories/base/base_guilds_repository.h index b38f223fc..e4f1a6700 100644 --- a/common/repositories/base/base_guilds_repository.h +++ b/common/repositories/base/base_guilds_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseGuildsRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "leader", + "minstatus", + "motd", + "tribute", + "motd_setter", + "channel", + "url", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("guilds"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_hackers_repository.h b/common/repositories/base/base_hackers_repository.h index 3d25dc90a..d8f01dced 100644 --- a/common/repositories/base/base_hackers_repository.h +++ b/common/repositories/base/base_hackers_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseHackersRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "account", + "name", + "hacked", + "zone", + "date", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("hackers"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -80,7 +98,7 @@ public: entry.name = ""; entry.hacked = ""; entry.zone = ""; - entry.date = ""; + entry.date = std::time(nullptr); return entry; } diff --git a/common/repositories/base/base_horses_repository.h b/common/repositories/base/base_horses_repository.h index 2282e3da0..5fdb0234c 100644 --- a/common/repositories/base/base_horses_repository.h +++ b/common/repositories/base/base_horses_repository.h @@ -1,29 +1,12 @@ /** - * EQEmulator: Everquest Server Emulator - * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * DO NOT MODIFY THIS FILE * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY except by those people which sell it, which - * are required to give you total support for your newly bought product; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - */ - -/** * This repository was automatically generated and is NOT to be modified directly. - * Any repository modifications are meant to be made to - * the repository extending the base. Any modifications to base repositories are to - * be made by the generator only + * Any repository modifications are meant to be made to the repository extending the base. + * Any modifications to base repositories are to be made by the generator only + * + * @generator ./utils/scripts/generators/repository-generator.pl + * @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories */ #ifndef EQEMU_BASE_HORSES_REPOSITORY_H @@ -31,26 +14,42 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseHorsesRepository { public: struct Horses { + int id; std::string filename; - int16 race; - int8 gender; - int8 texture; + int race; + int gender; + int texture; float mountspeed; std::string notes; }; static std::string PrimaryKey() { - return std::string("filename"); + return std::string("id"); } static std::vector Columns() { return { + "id", + "filename", + "race", + "gender", + "texture", + "mountspeed", + "notes", + }; + } + + static std::vector SelectColumns() + { + return { + "id", "filename", "race", "gender", @@ -65,19 +64,9 @@ public: return std::string(implode(", ", Columns())); } - static std::string InsertColumnsRaw() + static std::string SelectColumnsRaw() { - std::vector insert_columns; - - for (auto &column : Columns()) { - if (column == PrimaryKey()) { - continue; - } - - insert_columns.push_back(column); - } - - return std::string(implode(", ", insert_columns)); + return std::string(implode(", ", SelectColumns())); } static std::string TableName() @@ -89,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -99,7 +88,7 @@ public: return fmt::format( "INSERT INTO {} ({}) ", TableName(), - InsertColumnsRaw() + ColumnsRaw() ); } @@ -107,6 +96,7 @@ public: { Horses entry{}; + entry.id = 0; entry.filename = ""; entry.race = 216; entry.gender = 0; @@ -123,7 +113,7 @@ public: ) { for (auto &horses : horsess) { - if (horses.filename == horses_id) { + if (horses.id == horses_id) { return horses; } } @@ -132,10 +122,11 @@ public: } static Horses FindOne( + Database& db, int horses_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE id = {} LIMIT 1", BaseSelect(), @@ -147,12 +138,13 @@ public: if (results.RowCount() == 1) { Horses entry{}; - entry.filename = row[0] ? 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] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.filename = row[1] ? row[1] : ""; + entry.race = atoi(row[2]); + entry.gender = atoi(row[3]); + entry.texture = atoi(row[4]); + entry.mountspeed = static_cast(atof(row[5])); + entry.notes = row[6] ? row[6] : ""; return entry; } @@ -161,10 +153,11 @@ public: } static int DeleteOne( + Database& db, int horses_id ) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {} = {}", TableName(), @@ -177,6 +170,7 @@ public: } static int UpdateOne( + Database& db, Horses horses_entry ) { @@ -184,20 +178,20 @@ public: auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + EscapeString(horses_entry.filename) + "'"); - 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] + " = " + std::to_string(horses_entry.mountspeed)); - update_values.push_back(columns[5] + " = '" + EscapeString(horses_entry.notes) + "'"); + update_values.push_back(columns[1] + " = '" + EscapeString(horses_entry.filename) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(horses_entry.race)); + update_values.push_back(columns[3] + " = " + std::to_string(horses_entry.gender)); + update_values.push_back(columns[4] + " = " + std::to_string(horses_entry.texture)); + update_values.push_back(columns[5] + " = " + std::to_string(horses_entry.mountspeed)); + update_values.push_back(columns[6] + " = '" + EscapeString(horses_entry.notes) + "'"); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "UPDATE {} SET {} WHERE {} = {}", TableName(), implode(", ", update_values), PrimaryKey(), - horses_entry.filename + horses_entry.id ) ); @@ -205,11 +199,13 @@ public: } static Horses InsertOne( + Database& db, Horses horses_entry ) { std::vector insert_values; + insert_values.push_back(std::to_string(horses_entry.id)); insert_values.push_back("'" + EscapeString(horses_entry.filename) + "'"); insert_values.push_back(std::to_string(horses_entry.race)); insert_values.push_back(std::to_string(horses_entry.gender)); @@ -217,7 +213,7 @@ public: insert_values.push_back(std::to_string(horses_entry.mountspeed)); insert_values.push_back("'" + EscapeString(horses_entry.notes) + "'"); - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES ({})", BaseInsert(), @@ -226,7 +222,7 @@ public: ); if (results.Success()) { - horses_entry.filename = results.LastInsertedID(); + horses_entry.id = results.LastInsertedID(); return horses_entry; } @@ -236,6 +232,7 @@ public: } static int InsertMany( + Database& db, std::vector horses_entries ) { @@ -244,6 +241,7 @@ public: for (auto &horses_entry: horses_entries) { std::vector insert_values; + insert_values.push_back(std::to_string(horses_entry.id)); insert_values.push_back("'" + EscapeString(horses_entry.filename) + "'"); insert_values.push_back(std::to_string(horses_entry.race)); insert_values.push_back(std::to_string(horses_entry.gender)); @@ -256,7 +254,7 @@ public: std::vector insert_values; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} VALUES {}", BaseInsert(), @@ -267,11 +265,11 @@ public: return (results.Success() ? results.RowsAffected() : 0); } - static std::vector All() + static std::vector All(Database& db) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{}", BaseSelect() @@ -283,12 +281,13 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Horses entry{}; - entry.filename = row[0] ? 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] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.filename = row[1] ? row[1] : ""; + entry.race = atoi(row[2]); + entry.gender = atoi(row[3]); + entry.texture = atoi(row[4]); + entry.mountspeed = static_cast(atof(row[5])); + entry.notes = row[6] ? row[6] : ""; all_entries.push_back(entry); } @@ -296,11 +295,11 @@ public: return all_entries; } - static std::vector GetWhere(std::string where_filter) + static std::vector GetWhere(Database& db, std::string where_filter) { std::vector all_entries; - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "{} WHERE {}", BaseSelect(), @@ -313,12 +312,13 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Horses entry{}; - entry.filename = row[0] ? 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] ? row[5] : ""; + entry.id = atoi(row[0]); + entry.filename = row[1] ? row[1] : ""; + entry.race = atoi(row[2]); + entry.gender = atoi(row[3]); + entry.texture = atoi(row[4]); + entry.mountspeed = static_cast(atof(row[5])); + entry.notes = row[6] ? row[6] : ""; all_entries.push_back(entry); } @@ -326,13 +326,12 @@ public: return all_entries; } - static int DeleteWhere(std::string where_filter) + static int DeleteWhere(Database& db, std::string where_filter) { - auto results = content_db.QueryDatabase( + auto results = db.QueryDatabase( fmt::format( "DELETE FROM {} WHERE {}", TableName(), - PrimaryKey(), where_filter ) ); @@ -340,6 +339,18 @@ public: return (results.Success() ? results.RowsAffected() : 0); } + static int Truncate(Database& db) + { + auto results = db.QueryDatabase( + fmt::format( + "TRUNCATE TABLE {}", + TableName() + ) + ); + + return (results.Success() ? results.RowsAffected() : 0); + } + }; #endif //EQEMU_BASE_HORSES_REPOSITORY_H diff --git a/common/repositories/base/base_instance_list_player_repository.h b/common/repositories/base/base_instance_list_player_repository.h index 92e4687b1..4ef1123ec 100644 --- a/common/repositories/base/base_instance_list_player_repository.h +++ b/common/repositories/base/base_instance_list_player_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseInstanceListPlayerRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "charid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("instance_list_player"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_instance_list_repository.h b/common/repositories/base/base_instance_list_repository.h index bdf7abfa6..9b23c50e6 100644 --- a/common/repositories/base/base_instance_list_repository.h +++ b/common/repositories/base/base_instance_list_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseInstanceListRepository { public: @@ -45,11 +46,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "version", + "is_global", + "start_time", + "duration", + "never_expires", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("instance_list"); @@ -59,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_inventory_repository.h b/common/repositories/base/base_inventory_repository.h index d17c7ff62..07a4f282e 100644 --- a/common/repositories/base/base_inventory_repository.h +++ b/common/repositories/base/base_inventory_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseInventoryRepository { public: @@ -63,11 +64,38 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "slotid", + "itemid", + "charges", + "color", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + "instnodrop", + "custom_data", + "ornamenticon", + "ornamentidfile", + "ornament_hero_model", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("inventory"); @@ -77,7 +105,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_inventory_snapshots_repository.h b/common/repositories/base/base_inventory_snapshots_repository.h index ec91303b1..58e2685ea 100644 --- a/common/repositories/base/base_inventory_snapshots_repository.h +++ b/common/repositories/base/base_inventory_snapshots_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseInventorySnapshotsRepository { public: @@ -65,11 +66,39 @@ public: }; } + static std::vector SelectColumns() + { + return { + "time_index", + "charid", + "slotid", + "itemid", + "charges", + "color", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + "instnodrop", + "custom_data", + "ornamenticon", + "ornamentidfile", + "ornament_hero_model", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("inventory_snapshots"); @@ -79,7 +108,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_ip_exemptions_repository.h b/common/repositories/base/base_ip_exemptions_repository.h index 6952c4dab..1cc185992 100644 --- a/common/repositories/base/base_ip_exemptions_repository.h +++ b/common/repositories/base/base_ip_exemptions_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseIpExemptionsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "exemption_id", + "exemption_ip", + "exemption_amount", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("ip_exemptions"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_item_tick_repository.h b/common/repositories/base/base_item_tick_repository.h index 2579c3c40..e70289fc4 100644 --- a/common/repositories/base/base_item_tick_repository.h +++ b/common/repositories/base/base_item_tick_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseItemTickRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "it_itemid", + "it_chance", + "it_level", + "it_id", + "it_qglobal", + "it_bagslot", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("item_tick"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_items_repository.h b/common/repositories/base/base_items_repository.h index 8bbbd979e..b89de9bae 100644 --- a/common/repositories/base/base_items_repository.h +++ b/common/repositories/base/base_items_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseItemsRepository { public: @@ -152,7 +153,7 @@ public: int UNK124; int attuneable; int nopet; - std::string updated; + time_t updated; std::string comment; int UNK127; int pointtype; @@ -182,8 +183,8 @@ public: int scrolllevel2; int scrolllevel; int UNK157; - std::string serialized; - std::string verified; + time_t serialized; + time_t verified; std::string serialization; std::string source; int UNK033; @@ -601,11 +602,307 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "minstatus", + "Name", + "aagi", + "ac", + "accuracy", + "acha", + "adex", + "aint", + "artifactflag", + "asta", + "astr", + "attack", + "augrestrict", + "augslot1type", + "augslot1visible", + "augslot2type", + "augslot2visible", + "augslot3type", + "augslot3visible", + "augslot4type", + "augslot4visible", + "augslot5type", + "augslot5visible", + "augslot6type", + "augslot6visible", + "augtype", + "avoidance", + "awis", + "bagsize", + "bagslots", + "bagtype", + "bagwr", + "banedmgamt", + "banedmgraceamt", + "banedmgbody", + "banedmgrace", + "bardtype", + "bardvalue", + "book", + "casttime", + "casttime_", + "charmfile", + "charmfileid", + "classes", + "color", + "combateffects", + "extradmgskill", + "extradmgamt", + "price", + "cr", + "damage", + "damageshield", + "deity", + "delay", + "augdistiller", + "dotshielding", + "dr", + "clicktype", + "clicklevel2", + "elemdmgtype", + "elemdmgamt", + "endur", + "factionamt1", + "factionamt2", + "factionamt3", + "factionamt4", + "factionmod1", + "factionmod2", + "factionmod3", + "factionmod4", + "filename", + "focuseffect", + "fr", + "fvnodrop", + "haste", + "clicklevel", + "hp", + "regen", + "icon", + "idfile", + "itemclass", + "itemtype", + "ldonprice", + "ldontheme", + "ldonsold", + "light", + "lore", + "loregroup", + "magic", + "mana", + "manaregen", + "enduranceregen", + "material", + "herosforgemodel", + "maxcharges", + "mr", + "nodrop", + "norent", + "pendingloreflag", + "pr", + "procrate", + "races", + "range", + "reclevel", + "recskill", + "reqlevel", + "sellrate", + "shielding", + "size", + "skillmodtype", + "skillmodvalue", + "slots", + "clickeffect", + "spellshield", + "strikethrough", + "stunresist", + "summonedflag", + "tradeskills", + "favor", + "weight", + "UNK012", + "UNK013", + "benefitflag", + "UNK054", + "UNK059", + "booktype", + "recastdelay", + "recasttype", + "guildfavor", + "UNK123", + "UNK124", + "attuneable", + "nopet", + "UNIX_TIMESTAMP(updated)", + "comment", + "UNK127", + "pointtype", + "potionbelt", + "potionbeltslots", + "stacksize", + "notransfer", + "stackable", + "UNK134", + "UNK137", + "proceffect", + "proctype", + "proclevel2", + "proclevel", + "UNK142", + "worneffect", + "worntype", + "wornlevel2", + "wornlevel", + "UNK147", + "focustype", + "focuslevel2", + "focuslevel", + "UNK152", + "scrolleffect", + "scrolltype", + "scrolllevel2", + "scrolllevel", + "UNK157", + "UNIX_TIMESTAMP(serialized)", + "UNIX_TIMESTAMP(verified)", + "serialization", + "source", + "UNK033", + "lorefile", + "UNK014", + "svcorruption", + "skillmodmax", + "UNK060", + "augslot1unk2", + "augslot2unk2", + "augslot3unk2", + "augslot4unk2", + "augslot5unk2", + "augslot6unk2", + "UNK120", + "UNK121", + "questitemflag", + "UNK132", + "clickunk5", + "clickunk6", + "clickunk7", + "procunk1", + "procunk2", + "procunk3", + "procunk4", + "procunk6", + "procunk7", + "wornunk1", + "wornunk2", + "wornunk3", + "wornunk4", + "wornunk5", + "wornunk6", + "wornunk7", + "focusunk1", + "focusunk2", + "focusunk3", + "focusunk4", + "focusunk5", + "focusunk6", + "focusunk7", + "scrollunk1", + "scrollunk2", + "scrollunk3", + "scrollunk4", + "scrollunk5", + "scrollunk6", + "scrollunk7", + "UNK193", + "purity", + "evoitem", + "evoid", + "evolvinglevel", + "evomax", + "clickname", + "procname", + "wornname", + "focusname", + "scrollname", + "dsmitigation", + "heroic_str", + "heroic_int", + "heroic_wis", + "heroic_agi", + "heroic_dex", + "heroic_sta", + "heroic_cha", + "heroic_pr", + "heroic_dr", + "heroic_fr", + "heroic_cr", + "heroic_mr", + "heroic_svcorrup", + "healamt", + "spelldmg", + "clairvoyance", + "backstabdmg", + "created", + "elitematerial", + "ldonsellbackrate", + "scriptfileid", + "expendablearrow", + "powersourcecapacity", + "bardeffect", + "bardeffecttype", + "bardlevel2", + "bardlevel", + "bardunk1", + "bardunk2", + "bardunk3", + "bardunk4", + "bardunk5", + "bardname", + "bardunk7", + "UNK214", + "subtype", + "UNK220", + "UNK221", + "heirloom", + "UNK223", + "UNK224", + "UNK225", + "UNK226", + "UNK227", + "UNK228", + "UNK229", + "UNK230", + "UNK231", + "UNK232", + "UNK233", + "UNK234", + "placeable", + "UNK236", + "UNK237", + "UNK238", + "UNK239", + "UNK240", + "UNK241", + "epicitem", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("items"); @@ -615,7 +912,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -717,7 +1014,7 @@ public: entry.itemclass = 0; entry.itemtype = 0; entry.ldonprice = 0; - entry.ldontheme = LDoNThemes::Unused; + entry.ldontheme = 0; entry.ldonsold = 0; entry.light = 0; entry.lore = ""; @@ -767,7 +1064,7 @@ public: entry.UNK124 = 0; entry.attuneable = 0; entry.nopet = 0; - entry.updated = "0000-00-00 00:00:00"; + entry.updated = 0; entry.comment = ""; entry.UNK127 = 0; entry.pointtype = 0; @@ -797,8 +1094,8 @@ public: entry.scrolllevel2 = 0; entry.scrolllevel = 0; entry.UNK157 = 0; - entry.serialized = ""; - entry.verified = ""; + entry.serialized = 0; + entry.verified = 0; entry.serialization = ""; entry.source = ""; entry.UNK033 = 0; @@ -1087,7 +1384,7 @@ public: entry.UNK124 = atoi(row[131]); entry.attuneable = atoi(row[132]); entry.nopet = atoi(row[133]); - entry.updated = row[134] ? row[134] : ""; + entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); entry.comment = row[135] ? row[135] : ""; entry.UNK127 = atoi(row[136]); entry.pointtype = atoi(row[137]); @@ -1117,8 +1414,8 @@ public: entry.scrolllevel2 = atoi(row[161]); entry.scrolllevel = atoi(row[162]); entry.UNK157 = atoi(row[163]); - entry.serialized = row[164] ? row[164] : ""; - entry.verified = row[165] ? row[165] : ""; + entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); entry.serialization = row[166] ? row[166] : ""; entry.source = row[167] ? row[167] : ""; entry.UNK033 = atoi(row[168]); @@ -1405,7 +1702,7 @@ public: update_values.push_back(columns[131] + " = " + std::to_string(items_entry.UNK124)); update_values.push_back(columns[132] + " = " + std::to_string(items_entry.attuneable)); update_values.push_back(columns[133] + " = " + std::to_string(items_entry.nopet)); - update_values.push_back(columns[134] + " = '" + EscapeString(items_entry.updated) + "'"); + update_values.push_back(columns[134] + " = FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); update_values.push_back(columns[135] + " = '" + EscapeString(items_entry.comment) + "'"); update_values.push_back(columns[136] + " = " + std::to_string(items_entry.UNK127)); update_values.push_back(columns[137] + " = " + std::to_string(items_entry.pointtype)); @@ -1435,8 +1732,8 @@ public: update_values.push_back(columns[161] + " = " + std::to_string(items_entry.scrolllevel2)); update_values.push_back(columns[162] + " = " + std::to_string(items_entry.scrolllevel)); update_values.push_back(columns[163] + " = " + std::to_string(items_entry.UNK157)); - update_values.push_back(columns[164] + " = '" + EscapeString(items_entry.serialized) + "'"); - update_values.push_back(columns[165] + " = '" + EscapeString(items_entry.verified) + "'"); + update_values.push_back(columns[164] + " = FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); + update_values.push_back(columns[165] + " = FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); update_values.push_back(columns[166] + " = '" + EscapeString(items_entry.serialization) + "'"); update_values.push_back(columns[167] + " = '" + EscapeString(items_entry.source) + "'"); update_values.push_back(columns[168] + " = " + std::to_string(items_entry.UNK033)); @@ -1711,7 +2008,7 @@ public: insert_values.push_back(std::to_string(items_entry.UNK124)); insert_values.push_back(std::to_string(items_entry.attuneable)); insert_values.push_back(std::to_string(items_entry.nopet)); - insert_values.push_back("'" + EscapeString(items_entry.updated) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); insert_values.push_back("'" + EscapeString(items_entry.comment) + "'"); insert_values.push_back(std::to_string(items_entry.UNK127)); insert_values.push_back(std::to_string(items_entry.pointtype)); @@ -1741,8 +2038,8 @@ public: insert_values.push_back(std::to_string(items_entry.scrolllevel2)); insert_values.push_back(std::to_string(items_entry.scrolllevel)); insert_values.push_back(std::to_string(items_entry.UNK157)); - insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'"); - insert_values.push_back("'" + EscapeString(items_entry.verified) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'"); insert_values.push_back("'" + EscapeString(items_entry.source) + "'"); insert_values.push_back(std::to_string(items_entry.UNK033)); @@ -2025,7 +2322,7 @@ public: insert_values.push_back(std::to_string(items_entry.UNK124)); insert_values.push_back(std::to_string(items_entry.attuneable)); insert_values.push_back(std::to_string(items_entry.nopet)); - insert_values.push_back("'" + EscapeString(items_entry.updated) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.updated > 0 ? std::to_string(items_entry.updated) : "null") + ")"); insert_values.push_back("'" + EscapeString(items_entry.comment) + "'"); insert_values.push_back(std::to_string(items_entry.UNK127)); insert_values.push_back(std::to_string(items_entry.pointtype)); @@ -2055,8 +2352,8 @@ public: insert_values.push_back(std::to_string(items_entry.scrolllevel2)); insert_values.push_back(std::to_string(items_entry.scrolllevel)); insert_values.push_back(std::to_string(items_entry.UNK157)); - insert_values.push_back("'" + EscapeString(items_entry.serialized) + "'"); - insert_values.push_back("'" + EscapeString(items_entry.verified) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.serialized > 0 ? std::to_string(items_entry.serialized) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (items_entry.verified > 0 ? std::to_string(items_entry.verified) : "null") + ")"); insert_values.push_back("'" + EscapeString(items_entry.serialization) + "'"); insert_values.push_back("'" + EscapeString(items_entry.source) + "'"); insert_values.push_back(std::to_string(items_entry.UNK033)); @@ -2343,7 +2640,7 @@ public: entry.UNK124 = atoi(row[131]); entry.attuneable = atoi(row[132]); entry.nopet = atoi(row[133]); - entry.updated = row[134] ? row[134] : ""; + entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); entry.comment = row[135] ? row[135] : ""; entry.UNK127 = atoi(row[136]); entry.pointtype = atoi(row[137]); @@ -2373,8 +2670,8 @@ public: entry.scrolllevel2 = atoi(row[161]); entry.scrolllevel = atoi(row[162]); entry.UNK157 = atoi(row[163]); - entry.serialized = row[164] ? row[164] : ""; - entry.verified = row[165] ? row[165] : ""; + entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); entry.serialization = row[166] ? row[166] : ""; entry.source = row[167] ? row[167] : ""; entry.UNK033 = atoi(row[168]); @@ -2652,7 +2949,7 @@ public: entry.UNK124 = atoi(row[131]); entry.attuneable = atoi(row[132]); entry.nopet = atoi(row[133]); - entry.updated = row[134] ? row[134] : ""; + entry.updated = strtoll(row[134] ? row[134] : "-1", nullptr, 10); entry.comment = row[135] ? row[135] : ""; entry.UNK127 = atoi(row[136]); entry.pointtype = atoi(row[137]); @@ -2682,8 +2979,8 @@ public: entry.scrolllevel2 = atoi(row[161]); entry.scrolllevel = atoi(row[162]); entry.UNK157 = atoi(row[163]); - entry.serialized = row[164] ? row[164] : ""; - entry.verified = row[165] ? row[165] : ""; + entry.serialized = strtoll(row[164] ? row[164] : "-1", nullptr, 10); + entry.verified = strtoll(row[165] ? row[165] : "-1", nullptr, 10); entry.serialization = row[166] ? row[166] : ""; entry.source = row[167] ? row[167] : ""; entry.UNK033 = atoi(row[168]); diff --git a/common/repositories/base/base_ldon_trap_entries_repository.h b/common/repositories/base/base_ldon_trap_entries_repository.h index a9e8b9052..ea1dd3c43 100644 --- a/common/repositories/base/base_ldon_trap_entries_repository.h +++ b/common/repositories/base/base_ldon_trap_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLdonTrapEntriesRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "trap_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("ldon_trap_entries"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_ldon_trap_templates_repository.h b/common/repositories/base/base_ldon_trap_templates_repository.h index 022482232..b4905a521 100644 --- a/common/repositories/base/base_ldon_trap_templates_repository.h +++ b/common/repositories/base/base_ldon_trap_templates_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLdonTrapTemplatesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "type", + "spell_id", + "skill", + "locked", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("ldon_trap_templates"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_level_exp_mods_repository.h b/common/repositories/base/base_level_exp_mods_repository.h index 410d4d25c..3d1f57854 100644 --- a/common/repositories/base/base_level_exp_mods_repository.h +++ b/common/repositories/base/base_level_exp_mods_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLevelExpModsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "level", + "exp_mod", + "aa_exp_mod", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("level_exp_mods"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_lfguild_repository.h b/common/repositories/base/base_lfguild_repository.h index be7337579..1ca4f0214 100644 --- a/common/repositories/base/base_lfguild_repository.h +++ b/common/repositories/base/base_lfguild_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLfguildRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "type", + "name", + "comment", + "fromlevel", + "tolevel", + "classes", + "aacount", + "timezone", + "timeposted", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("lfguild"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_login_accounts_repository.h b/common/repositories/base/base_login_accounts_repository.h index 7b2e68f11..b8c82d6be 100644 --- a/common/repositories/base/base_login_accounts_repository.h +++ b/common/repositories/base/base_login_accounts_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoginAccountsRepository { public: @@ -24,9 +25,9 @@ public: std::string account_email; std::string source_loginserver; std::string last_ip_address; - std::string last_login_date; - std::string created_at; - std::string updated_at; + time_t last_login_date; + time_t created_at; + time_t updated_at; }; static std::string PrimaryKey() @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "account_name", + "account_password", + "account_email", + "source_loginserver", + "last_ip_address", + "UNIX_TIMESTAMP(last_login_date)", + "UNIX_TIMESTAMP(created_at)", + "UNIX_TIMESTAMP(updated_at)", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("login_accounts"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -87,9 +108,9 @@ public: entry.account_email = ""; entry.source_loginserver = ""; entry.last_ip_address = ""; - entry.last_login_date = ""; - entry.created_at = ""; - entry.updated_at = ""; + entry.last_login_date = 0; + entry.created_at = 0; + entry.updated_at = std::time(nullptr); return entry; } @@ -131,9 +152,9 @@ public: entry.account_email = row[3] ? row[3] : ""; entry.source_loginserver = row[4] ? row[4] : ""; entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = row[6] ? row[6] : ""; - entry.created_at = row[7] ? row[7] : ""; - entry.updated_at = row[8] ? row[8] : ""; + entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); return entry; } @@ -173,9 +194,9 @@ public: update_values.push_back(columns[3] + " = '" + EscapeString(login_accounts_entry.account_email) + "'"); update_values.push_back(columns[4] + " = '" + EscapeString(login_accounts_entry.source_loginserver) + "'"); update_values.push_back(columns[5] + " = '" + EscapeString(login_accounts_entry.last_ip_address) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(login_accounts_entry.last_login_date) + "'"); - update_values.push_back(columns[7] + " = '" + EscapeString(login_accounts_entry.created_at) + "'"); - update_values.push_back(columns[8] + " = '" + EscapeString(login_accounts_entry.updated_at) + "'"); + update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); + update_values.push_back(columns[7] + " = FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); + update_values.push_back(columns[8] + " = FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -203,9 +224,9 @@ public: insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'"); insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'"); insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -241,9 +262,9 @@ public: insert_values.push_back("'" + EscapeString(login_accounts_entry.account_email) + "'"); insert_values.push_back("'" + EscapeString(login_accounts_entry.source_loginserver) + "'"); insert_values.push_back("'" + EscapeString(login_accounts_entry.last_ip_address) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.last_login_date) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(login_accounts_entry.updated_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.last_login_date > 0 ? std::to_string(login_accounts_entry.last_login_date) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.created_at > 0 ? std::to_string(login_accounts_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_accounts_entry.updated_at > 0 ? std::to_string(login_accounts_entry.updated_at) : "null") + ")"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -283,9 +304,9 @@ public: entry.account_email = row[3] ? row[3] : ""; entry.source_loginserver = row[4] ? row[4] : ""; entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = row[6] ? row[6] : ""; - entry.created_at = row[7] ? row[7] : ""; - entry.updated_at = row[8] ? row[8] : ""; + entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); all_entries.push_back(entry); } @@ -316,9 +337,9 @@ public: entry.account_email = row[3] ? row[3] : ""; entry.source_loginserver = row[4] ? row[4] : ""; entry.last_ip_address = row[5] ? row[5] : ""; - entry.last_login_date = row[6] ? row[6] : ""; - entry.created_at = row[7] ? row[7] : ""; - entry.updated_at = row[8] ? row[8] : ""; + entry.last_login_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); + entry.created_at = strtoll(row[7] ? row[7] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[8] ? row[8] : "-1", nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_login_api_tokens_repository.h b/common/repositories/base/base_login_api_tokens_repository.h index 7d5f7f98f..bfd8f9a74 100644 --- a/common/repositories/base/base_login_api_tokens_repository.h +++ b/common/repositories/base/base_login_api_tokens_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoginApiTokensRepository { public: @@ -22,8 +23,8 @@ public: std::string token; int can_write; int can_read; - std::string created_at; - std::string updated_at; + time_t created_at; + time_t updated_at; }; static std::string PrimaryKey() @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "token", + "can_write", + "can_read", + "UNIX_TIMESTAMP(created_at)", + "UNIX_TIMESTAMP(updated_at)", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("login_api_tokens"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -79,8 +97,8 @@ public: entry.token = ""; entry.can_write = 0; entry.can_read = 0; - entry.created_at = ""; - entry.updated_at = ""; + entry.created_at = 0; + entry.updated_at = std::time(nullptr); return entry; } @@ -120,8 +138,8 @@ public: entry.token = row[1] ? row[1] : ""; entry.can_write = atoi(row[2]); entry.can_read = atoi(row[3]); - entry.created_at = row[4] ? row[4] : ""; - entry.updated_at = row[5] ? row[5] : ""; + entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); return entry; } @@ -158,8 +176,8 @@ public: update_values.push_back(columns[1] + " = '" + EscapeString(login_api_tokens_entry.token) + "'"); update_values.push_back(columns[2] + " = " + std::to_string(login_api_tokens_entry.can_write)); update_values.push_back(columns[3] + " = " + std::to_string(login_api_tokens_entry.can_read)); - update_values.push_back(columns[4] + " = '" + EscapeString(login_api_tokens_entry.created_at) + "'"); - update_values.push_back(columns[5] + " = '" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + update_values.push_back(columns[4] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); + update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -185,8 +203,8 @@ public: insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); - insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -220,8 +238,8 @@ public: insert_values.push_back("'" + EscapeString(login_api_tokens_entry.token) + "'"); insert_values.push_back(std::to_string(login_api_tokens_entry.can_write)); insert_values.push_back(std::to_string(login_api_tokens_entry.can_read)); - insert_values.push_back("'" + EscapeString(login_api_tokens_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(login_api_tokens_entry.updated_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.created_at > 0 ? std::to_string(login_api_tokens_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (login_api_tokens_entry.updated_at > 0 ? std::to_string(login_api_tokens_entry.updated_at) : "null") + ")"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -259,8 +277,8 @@ public: entry.token = row[1] ? row[1] : ""; entry.can_write = atoi(row[2]); entry.can_read = atoi(row[3]); - entry.created_at = row[4] ? row[4] : ""; - entry.updated_at = row[5] ? row[5] : ""; + entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); all_entries.push_back(entry); } @@ -289,8 +307,8 @@ public: entry.token = row[1] ? row[1] : ""; entry.can_write = atoi(row[2]); entry.can_read = atoi(row[3]); - entry.created_at = row[4] ? row[4] : ""; - entry.updated_at = row[5] ? row[5] : ""; + entry.created_at = strtoll(row[4] ? row[4] : "-1", nullptr, 10); + entry.updated_at = strtoll(row[5] ? row[5] : "-1", nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_login_server_admins_repository.h b/common/repositories/base/base_login_server_admins_repository.h index be6b3bcf7..901edc2f1 100644 --- a/common/repositories/base/base_login_server_admins_repository.h +++ b/common/repositories/base/base_login_server_admins_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoginServerAdminsRepository { public: @@ -24,7 +25,7 @@ public: std::string first_name; std::string last_name; std::string email; - std::string registration_date; + time_t registration_date; std::string registration_ip_address; }; @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "account_name", + "account_password", + "first_name", + "last_name", + "email", + "UNIX_TIMESTAMP(registration_date)", + "registration_ip_address", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("login_server_admins"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -85,7 +105,7 @@ public: entry.first_name = ""; entry.last_name = ""; entry.email = ""; - entry.registration_date = ""; + entry.registration_date = 0; entry.registration_ip_address = ""; return entry; @@ -128,7 +148,7 @@ public: entry.first_name = row[3] ? row[3] : ""; entry.last_name = row[4] ? row[4] : ""; entry.email = row[5] ? row[5] : ""; - entry.registration_date = row[6] ? row[6] : ""; + entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); entry.registration_ip_address = row[7] ? row[7] : ""; return entry; @@ -168,7 +188,7 @@ public: update_values.push_back(columns[3] + " = '" + EscapeString(login_server_admins_entry.first_name) + "'"); update_values.push_back(columns[4] + " = '" + EscapeString(login_server_admins_entry.last_name) + "'"); update_values.push_back(columns[5] + " = '" + EscapeString(login_server_admins_entry.email) + "'"); - update_values.push_back(columns[6] + " = '" + EscapeString(login_server_admins_entry.registration_date) + "'"); + update_values.push_back(columns[6] + " = FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); update_values.push_back(columns[7] + " = '" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); auto results = db.QueryDatabase( @@ -197,7 +217,7 @@ public: insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'"); - insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); auto results = db.QueryDatabase( @@ -234,7 +254,7 @@ public: insert_values.push_back("'" + EscapeString(login_server_admins_entry.first_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.last_name) + "'"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.email) + "'"); - insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_date) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_server_admins_entry.registration_date > 0 ? std::to_string(login_server_admins_entry.registration_date) : "null") + ")"); insert_values.push_back("'" + EscapeString(login_server_admins_entry.registration_ip_address) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); @@ -275,7 +295,7 @@ public: entry.first_name = row[3] ? row[3] : ""; entry.last_name = row[4] ? row[4] : ""; entry.email = row[5] ? row[5] : ""; - entry.registration_date = row[6] ? row[6] : ""; + entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); entry.registration_ip_address = row[7] ? row[7] : ""; all_entries.push_back(entry); @@ -307,7 +327,7 @@ public: entry.first_name = row[3] ? row[3] : ""; entry.last_name = row[4] ? row[4] : ""; entry.email = row[5] ? row[5] : ""; - entry.registration_date = row[6] ? row[6] : ""; + entry.registration_date = strtoll(row[6] ? row[6] : "-1", nullptr, 10); entry.registration_ip_address = row[7] ? row[7] : ""; all_entries.push_back(entry); diff --git a/common/repositories/base/base_login_server_list_types_repository.h b/common/repositories/base/base_login_server_list_types_repository.h index 443182c05..0f0483b54 100644 --- a/common/repositories/base/base_login_server_list_types_repository.h +++ b/common/repositories/base/base_login_server_list_types_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoginServerListTypesRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "description", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("login_server_list_types"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_login_world_servers_repository.h b/common/repositories/base/base_login_world_servers_repository.h index cce6a0bff..0c6616681 100644 --- a/common/repositories/base/base_login_world_servers_repository.h +++ b/common/repositories/base/base_login_world_servers_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoginWorldServersRepository { public: @@ -23,7 +24,7 @@ public: std::string short_name; std::string tag_description; int login_server_list_type_id; - std::string last_login_date; + time_t last_login_date; std::string last_ip_address; int login_server_admin_id; int is_server_trusted; @@ -51,11 +52,32 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "long_name", + "short_name", + "tag_description", + "login_server_list_type_id", + "UNIX_TIMESTAMP(last_login_date)", + "last_ip_address", + "login_server_admin_id", + "is_server_trusted", + "note", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("login_world_servers"); @@ -65,7 +87,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -88,7 +110,7 @@ public: entry.short_name = ""; entry.tag_description = ""; entry.login_server_list_type_id = 0; - entry.last_login_date = ""; + entry.last_login_date = 0; entry.last_ip_address = ""; entry.login_server_admin_id = 0; entry.is_server_trusted = 0; @@ -133,7 +155,7 @@ public: entry.short_name = row[2] ? row[2] : ""; entry.tag_description = row[3] ? row[3] : ""; entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = row[5] ? row[5] : ""; + entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.last_ip_address = row[6] ? row[6] : ""; entry.login_server_admin_id = atoi(row[7]); entry.is_server_trusted = atoi(row[8]); @@ -175,7 +197,7 @@ public: update_values.push_back(columns[2] + " = '" + EscapeString(login_world_servers_entry.short_name) + "'"); update_values.push_back(columns[3] + " = '" + EscapeString(login_world_servers_entry.tag_description) + "'"); update_values.push_back(columns[4] + " = " + std::to_string(login_world_servers_entry.login_server_list_type_id)); - update_values.push_back(columns[5] + " = '" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); update_values.push_back(columns[6] + " = '" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); update_values.push_back(columns[7] + " = " + std::to_string(login_world_servers_entry.login_server_admin_id)); update_values.push_back(columns[8] + " = " + std::to_string(login_world_servers_entry.is_server_trusted)); @@ -206,7 +228,7 @@ public: insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); - insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); @@ -245,7 +267,7 @@ public: insert_values.push_back("'" + EscapeString(login_world_servers_entry.short_name) + "'"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.tag_description) + "'"); insert_values.push_back(std::to_string(login_world_servers_entry.login_server_list_type_id)); - insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_login_date) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (login_world_servers_entry.last_login_date > 0 ? std::to_string(login_world_servers_entry.last_login_date) : "null") + ")"); insert_values.push_back("'" + EscapeString(login_world_servers_entry.last_ip_address) + "'"); insert_values.push_back(std::to_string(login_world_servers_entry.login_server_admin_id)); insert_values.push_back(std::to_string(login_world_servers_entry.is_server_trusted)); @@ -288,7 +310,7 @@ public: entry.short_name = row[2] ? row[2] : ""; entry.tag_description = row[3] ? row[3] : ""; entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = row[5] ? row[5] : ""; + entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.last_ip_address = row[6] ? row[6] : ""; entry.login_server_admin_id = atoi(row[7]); entry.is_server_trusted = atoi(row[8]); @@ -322,7 +344,7 @@ public: entry.short_name = row[2] ? row[2] : ""; entry.tag_description = row[3] ? row[3] : ""; entry.login_server_list_type_id = atoi(row[4]); - entry.last_login_date = row[5] ? row[5] : ""; + entry.last_login_date = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.last_ip_address = row[6] ? row[6] : ""; entry.login_server_admin_id = atoi(row[7]); entry.is_server_trusted = atoi(row[8]); diff --git a/common/repositories/base/base_logsys_categories_repository.h b/common/repositories/base/base_logsys_categories_repository.h index fd15aec24..f7ffb63bb 100644 --- a/common/repositories/base/base_logsys_categories_repository.h +++ b/common/repositories/base/base_logsys_categories_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLogsysCategoriesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "log_category_id", + "log_category_description", + "log_to_console", + "log_to_file", + "log_to_gmsay", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("logsys_categories"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_lootdrop_entries_repository.h b/common/repositories/base/base_lootdrop_entries_repository.h index 4be4630a3..d9bccef06 100644 --- a/common/repositories/base/base_lootdrop_entries_repository.h +++ b/common/repositories/base/base_lootdrop_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLootdropEntriesRepository { public: @@ -53,11 +54,33 @@ public: }; } + static std::vector SelectColumns() + { + return { + "lootdrop_id", + "item_id", + "item_charges", + "equip_item", + "chance", + "disabled_chance", + "trivial_min_level", + "trivial_max_level", + "multiplier", + "npc_min_level", + "npc_max_level", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("lootdrop_entries"); @@ -67,7 +90,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_lootdrop_repository.h b/common/repositories/base/base_lootdrop_repository.h index d70c3201c..aad7b5eef 100644 --- a/common/repositories/base/base_lootdrop_repository.h +++ b/common/repositories/base/base_lootdrop_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLootdropRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("lootdrop"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -77,8 +95,8 @@ public: entry.id = 0; entry.name = ""; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_loottable_entries_repository.h b/common/repositories/base/base_loottable_entries_repository.h index 67e073be7..371fa6f00 100644 --- a/common/repositories/base/base_loottable_entries_repository.h +++ b/common/repositories/base/base_loottable_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoottableEntriesRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "loottable_id", + "lootdrop_id", + "multiplier", + "droplimit", + "mindrop", + "probability", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("loottable_entries"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_loottable_repository.h b/common/repositories/base/base_loottable_repository.h index a41229069..420b666b3 100644 --- a/common/repositories/base/base_loottable_repository.h +++ b/common/repositories/base/base_loottable_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseLoottableRepository { public: @@ -51,11 +52,32 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "mincash", + "maxcash", + "avgcoin", + "done", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("loottable"); @@ -65,7 +87,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -89,8 +111,8 @@ public: entry.maxcash = 0; entry.avgcoin = 0; entry.done = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_mail_repository.h b/common/repositories/base/base_mail_repository.h index 2123e6396..7b4da2cd7 100644 --- a/common/repositories/base/base_mail_repository.h +++ b/common/repositories/base/base_mail_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseMailRepository { public: @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "msgid", + "charid", + "timestamp", + "from", + "subject", + "body", + "to", + "status", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("mail"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_merchantlist_repository.h b/common/repositories/base/base_merchantlist_repository.h index f7dc02df6..a447c3426 100644 --- a/common/repositories/base/base_merchantlist_repository.h +++ b/common/repositories/base/base_merchantlist_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseMerchantlistRepository { public: @@ -55,11 +56,34 @@ public: }; } + static std::vector SelectColumns() + { + return { + "merchantid", + "slot", + "item", + "faction_required", + "level_required", + "alt_currency_cost", + "classes_required", + "probability", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("merchantlist"); @@ -69,7 +93,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -95,8 +119,8 @@ public: entry.alt_currency_cost = 0; entry.classes_required = 65535; entry.probability = 100; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_merchantlist_temp_repository.h b/common/repositories/base/base_merchantlist_temp_repository.h index 21626aa3d..c31f886dd 100644 --- a/common/repositories/base/base_merchantlist_temp_repository.h +++ b/common/repositories/base/base_merchantlist_temp_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseMerchantlistTempRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "npcid", + "slot", + "itemid", + "charges", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("merchantlist_temp"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_name_filter_repository.h b/common/repositories/base/base_name_filter_repository.h index 984f2b142..fbf9da8f3 100644 --- a/common/repositories/base/base_name_filter_repository.h +++ b/common/repositories/base/base_name_filter_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNameFilterRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("name_filter"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_emotes_repository.h b/common/repositories/base/base_npc_emotes_repository.h index 6660ed59e..86f3e418c 100644 --- a/common/repositories/base/base_npc_emotes_repository.h +++ b/common/repositories/base/base_npc_emotes_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcEmotesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "emoteid", + "event_", + "type", + "text", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_emotes"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_faction_entries_repository.h b/common/repositories/base/base_npc_faction_entries_repository.h index 1084b9a5e..d7a27f6a7 100644 --- a/common/repositories/base/base_npc_faction_entries_repository.h +++ b/common/repositories/base/base_npc_faction_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcFactionEntriesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "npc_faction_id", + "faction_id", + "value", + "npc_value", + "temp", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_faction_entries"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_faction_repository.h b/common/repositories/base/base_npc_faction_repository.h index 87bff25d1..02c124608 100644 --- a/common/repositories/base/base_npc_faction_repository.h +++ b/common/repositories/base/base_npc_faction_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcFactionRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "primaryfaction", + "ignore_primary_assist", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_faction"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_scale_global_base_repository.h b/common/repositories/base/base_npc_scale_global_base_repository.h index b7eafe57a..323123ecd 100644 --- a/common/repositories/base/base_npc_scale_global_base_repository.h +++ b/common/repositories/base/base_npc_scale_global_base_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcScaleGlobalBaseRepository { public: @@ -87,11 +88,50 @@ public: }; } + static std::vector SelectColumns() + { + return { + "type", + "level", + "ac", + "hp", + "accuracy", + "slow_mitigation", + "attack", + "strength", + "stamina", + "dexterity", + "agility", + "intelligence", + "wisdom", + "charisma", + "magic_resist", + "cold_resist", + "fire_resist", + "poison_resist", + "disease_resist", + "corruption_resist", + "physical_resist", + "min_dmg", + "max_dmg", + "hp_regen_rate", + "attack_delay", + "spell_scale", + "heal_scale", + "special_abilities", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_scale_global_base"); @@ -101,7 +141,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_spells_effects_entries_repository.h b/common/repositories/base/base_npc_spells_effects_entries_repository.h index f6ca532ee..508ccc41e 100644 --- a/common/repositories/base/base_npc_spells_effects_entries_repository.h +++ b/common/repositories/base/base_npc_spells_effects_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcSpellsEffectsEntriesRepository { public: @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "npc_spells_effects_id", + "spell_effect_id", + "minlevel", + "maxlevel", + "se_base", + "se_limit", + "se_max", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_spells_effects_entries"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_spells_effects_repository.h b/common/repositories/base/base_npc_spells_effects_repository.h index 6983a002e..23e16c2a0 100644 --- a/common/repositories/base/base_npc_spells_effects_repository.h +++ b/common/repositories/base/base_npc_spells_effects_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcSpellsEffectsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "parent_list", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_spells_effects"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_spells_entries_repository.h b/common/repositories/base/base_npc_spells_entries_repository.h index a165d6965..72b39b108 100644 --- a/common/repositories/base/base_npc_spells_entries_repository.h +++ b/common/repositories/base/base_npc_spells_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcSpellsEntriesRepository { public: @@ -55,11 +56,34 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "npc_spells_id", + "spellid", + "type", + "minlevel", + "maxlevel", + "manacost", + "recast_delay", + "priority", + "resist_adjust", + "min_hp", + "max_hp", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_spells_entries"); @@ -69,7 +93,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_spells_repository.h b/common/repositories/base/base_npc_spells_repository.h index e7f9d784e..8433a208f 100644 --- a/common/repositories/base/base_npc_spells_repository.h +++ b/common/repositories/base/base_npc_spells_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcSpellsRepository { public: @@ -73,11 +74,43 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "parent_list", + "attack_proc", + "proc_chance", + "range_proc", + "rproc_chance", + "defensive_proc", + "dproc_chance", + "fail_recast", + "engaged_no_sp_recast_min", + "engaged_no_sp_recast_max", + "engaged_b_self_chance", + "engaged_b_other_chance", + "engaged_d_chance", + "pursue_no_sp_recast_min", + "pursue_no_sp_recast_max", + "pursue_d_chance", + "idle_no_sp_recast_min", + "idle_no_sp_recast_max", + "idle_b_chance", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_spells"); @@ -87,7 +120,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_types_repository.h b/common/repositories/base/base_npc_types_repository.h index 25020d8a8..bd778c0d1 100644 --- a/common/repositories/base/base_npc_types_repository.h +++ b/common/repositories/base/base_npc_types_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcTypesRepository { public: @@ -277,11 +278,145 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "lastname", + "level", + "race", + "`class`", + "bodytype", + "hp", + "mana", + "gender", + "texture", + "helmtexture", + "herosforgemodel", + "size", + "hp_regen_rate", + "mana_regen_rate", + "loottable_id", + "merchant_id", + "alt_currency_id", + "npc_spells_id", + "npc_spells_effects_id", + "npc_faction_id", + "adventure_template_id", + "trap_template", + "mindmg", + "maxdmg", + "attack_count", + "npcspecialattks", + "special_abilities", + "aggroradius", + "assistradius", + "face", + "luclin_hairstyle", + "luclin_haircolor", + "luclin_eyecolor", + "luclin_eyecolor2", + "luclin_beardcolor", + "luclin_beard", + "drakkin_heritage", + "drakkin_tattoo", + "drakkin_details", + "armortint_id", + "armortint_red", + "armortint_green", + "armortint_blue", + "d_melee_texture1", + "d_melee_texture2", + "ammo_idfile", + "prim_melee_type", + "sec_melee_type", + "ranged_type", + "runspeed", + "MR", + "CR", + "DR", + "FR", + "PR", + "Corrup", + "PhR", + "see_invis", + "see_invis_undead", + "qglobal", + "AC", + "npc_aggro", + "spawn_limit", + "attack_speed", + "attack_delay", + "findable", + "STR", + "STA", + "DEX", + "AGI", + "_INT", + "WIS", + "CHA", + "see_hide", + "see_improved_hide", + "trackable", + "isbot", + "exclude", + "ATK", + "Accuracy", + "Avoidance", + "slow_mitigation", + "version", + "maxlevel", + "scalerate", + "private_corpse", + "unique_spawn_by_name", + "underwater", + "isquest", + "emoteid", + "spellscale", + "healscale", + "no_target_hotkey", + "raid_target", + "armtexture", + "bracertexture", + "handtexture", + "legtexture", + "feettexture", + "light", + "walkspeed", + "peqid", + "unique_", + "fixed", + "ignore_despawn", + "show_name", + "untargetable", + "charm_ac", + "charm_min_dmg", + "charm_max_dmg", + "charm_attack_delay", + "charm_accuracy_rating", + "charm_avoidance_rating", + "charm_atk", + "skip_global_loot", + "rare_spawn", + "stuck_behavior", + "model", + "flymode", + "always_aggro", + "exp_mod", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_types"); @@ -291,7 +426,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_npc_types_tint_repository.h b/common/repositories/base/base_npc_types_tint_repository.h index ea01c8d01..906bb08d0 100644 --- a/common/repositories/base/base_npc_types_tint_repository.h +++ b/common/repositories/base/base_npc_types_tint_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseNpcTypesTintRepository { public: @@ -89,11 +90,51 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "tint_set_name", + "red1h", + "grn1h", + "blu1h", + "red2c", + "grn2c", + "blu2c", + "red3a", + "grn3a", + "blu3a", + "red4b", + "grn4b", + "blu4b", + "red5g", + "grn5g", + "blu5g", + "red6l", + "grn6l", + "blu6l", + "red7f", + "grn7f", + "blu7f", + "red8x", + "grn8x", + "blu8x", + "red9x", + "grn9x", + "blu9x", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("npc_types_tint"); @@ -103,7 +144,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_object_contents_repository.h b/common/repositories/base/base_object_contents_repository.h index 3ab7c70b8..d45ff7cd7 100644 --- a/common/repositories/base/base_object_contents_repository.h +++ b/common/repositories/base/base_object_contents_repository.h @@ -14,22 +14,23 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseObjectContentsRepository { public: struct ObjectContents { - int zoneid; - int parentid; - int bagidx; - int itemid; - int charges; - std::string droptime; - int augslot1; - int augslot2; - int augslot3; - int augslot4; - int augslot5; - int augslot6; + int zoneid; + int parentid; + int bagidx; + int itemid; + int charges; + time_t droptime; + int augslot1; + int augslot2; + int augslot3; + int augslot4; + int augslot5; + int augslot6; }; static std::string PrimaryKey() @@ -55,11 +56,34 @@ public: }; } + static std::vector SelectColumns() + { + return { + "zoneid", + "parentid", + "bagidx", + "itemid", + "charges", + "UNIX_TIMESTAMP(droptime)", + "augslot1", + "augslot2", + "augslot3", + "augslot4", + "augslot5", + "augslot6", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("object_contents"); @@ -69,7 +93,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -92,7 +116,7 @@ public: entry.bagidx = 0; entry.itemid = 0; entry.charges = 0; - entry.droptime = "0000-00-00 00:00:00"; + entry.droptime = 0; entry.augslot1 = 0; entry.augslot2 = 0; entry.augslot3 = 0; @@ -139,7 +163,7 @@ public: entry.bagidx = atoi(row[2]); entry.itemid = atoi(row[3]); entry.charges = atoi(row[4]); - entry.droptime = row[5] ? row[5] : ""; + entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.augslot1 = atoi(row[6]); entry.augslot2 = atoi(row[7]); entry.augslot3 = atoi(row[8]); @@ -184,7 +208,7 @@ public: update_values.push_back(columns[2] + " = " + std::to_string(object_contents_entry.bagidx)); update_values.push_back(columns[3] + " = " + std::to_string(object_contents_entry.itemid)); update_values.push_back(columns[4] + " = " + std::to_string(object_contents_entry.charges)); - update_values.push_back(columns[5] + " = '" + EscapeString(object_contents_entry.droptime) + "'"); + update_values.push_back(columns[5] + " = FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); update_values.push_back(columns[6] + " = " + std::to_string(object_contents_entry.augslot1)); update_values.push_back(columns[7] + " = " + std::to_string(object_contents_entry.augslot2)); update_values.push_back(columns[8] + " = " + std::to_string(object_contents_entry.augslot3)); @@ -217,7 +241,7 @@ public: insert_values.push_back(std::to_string(object_contents_entry.bagidx)); insert_values.push_back(std::to_string(object_contents_entry.itemid)); insert_values.push_back(std::to_string(object_contents_entry.charges)); - insert_values.push_back("'" + EscapeString(object_contents_entry.droptime) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); insert_values.push_back(std::to_string(object_contents_entry.augslot1)); insert_values.push_back(std::to_string(object_contents_entry.augslot2)); insert_values.push_back(std::to_string(object_contents_entry.augslot3)); @@ -258,7 +282,7 @@ public: insert_values.push_back(std::to_string(object_contents_entry.bagidx)); insert_values.push_back(std::to_string(object_contents_entry.itemid)); insert_values.push_back(std::to_string(object_contents_entry.charges)); - insert_values.push_back("'" + EscapeString(object_contents_entry.droptime) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (object_contents_entry.droptime > 0 ? std::to_string(object_contents_entry.droptime) : "null") + ")"); insert_values.push_back(std::to_string(object_contents_entry.augslot1)); insert_values.push_back(std::to_string(object_contents_entry.augslot2)); insert_values.push_back(std::to_string(object_contents_entry.augslot3)); @@ -303,7 +327,7 @@ public: entry.bagidx = atoi(row[2]); entry.itemid = atoi(row[3]); entry.charges = atoi(row[4]); - entry.droptime = row[5] ? row[5] : ""; + entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.augslot1 = atoi(row[6]); entry.augslot2 = atoi(row[7]); entry.augslot3 = atoi(row[8]); @@ -339,7 +363,7 @@ public: entry.bagidx = atoi(row[2]); entry.itemid = atoi(row[3]); entry.charges = atoi(row[4]); - entry.droptime = row[5] ? row[5] : ""; + entry.droptime = strtoll(row[5] ? row[5] : "-1", nullptr, 10); entry.augslot1 = atoi(row[6]); entry.augslot2 = atoi(row[7]); entry.augslot3 = atoi(row[8]); diff --git a/common/repositories/base/base_object_repository.h b/common/repositories/base/base_object_repository.h index dc098db06..9ab4cf577 100644 --- a/common/repositories/base/base_object_repository.h +++ b/common/repositories/base/base_object_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseObjectRepository { public: @@ -91,11 +92,52 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zoneid", + "version", + "xpos", + "ypos", + "zpos", + "heading", + "itemid", + "charges", + "objectname", + "type", + "icon", + "unknown08", + "unknown10", + "unknown20", + "unknown24", + "unknown60", + "unknown64", + "unknown68", + "unknown72", + "unknown76", + "unknown84", + "size", + "tilt_x", + "tilt_y", + "display_name", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("object"); @@ -105,7 +147,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -149,8 +191,8 @@ public: entry.tilt_x = 0; entry.tilt_y = 0; entry.display_name = ""; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_perl_event_export_settings_repository.h b/common/repositories/base/base_perl_event_export_settings_repository.h index 50c0a63f6..5221b7f77 100644 --- a/common/repositories/base/base_perl_event_export_settings_repository.h +++ b/common/repositories/base/base_perl_event_export_settings_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePerlEventExportSettingsRepository { public: @@ -45,11 +46,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "event_id", + "event_description", + "export_qglobals", + "export_mob", + "export_zone", + "export_item", + "export_event", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("perl_event_export_settings"); @@ -59,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_petitions_repository.h b/common/repositories/base/base_petitions_repository.h index 36a781ab0..9d62180e6 100644 --- a/common/repositories/base/base_petitions_repository.h +++ b/common/repositories/base/base_petitions_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePetitionsRepository { public: @@ -63,11 +64,38 @@ public: }; } + static std::vector SelectColumns() + { + return { + "dib", + "petid", + "charname", + "accountname", + "lastgm", + "petitiontext", + "gmtext", + "zone", + "urgency", + "charclass", + "charrace", + "charlevel", + "checkouts", + "unavailables", + "ischeckedout", + "senttime", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("petitions"); @@ -77,7 +105,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -161,7 +189,7 @@ public: entry.checkouts = atoi(row[12]); entry.unavailables = atoi(row[13]); entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], NULL, 10); + entry.senttime = strtoll(row[15], nullptr, 10); return entry; } @@ -340,7 +368,7 @@ public: entry.checkouts = atoi(row[12]); entry.unavailables = atoi(row[13]); entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], NULL, 10); + entry.senttime = strtoll(row[15], nullptr, 10); all_entries.push_back(entry); } @@ -380,7 +408,7 @@ public: entry.checkouts = atoi(row[12]); entry.unavailables = atoi(row[13]); entry.ischeckedout = atoi(row[14]); - entry.senttime = strtoll(row[15], NULL, 10); + entry.senttime = strtoll(row[15], nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_pets_beastlord_data_repository.h b/common/repositories/base/base_pets_beastlord_data_repository.h index 61c7d75ba..4b529f24c 100644 --- a/common/repositories/base/base_pets_beastlord_data_repository.h +++ b/common/repositories/base/base_pets_beastlord_data_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePetsBeastlordDataRepository { public: @@ -45,11 +46,29 @@ public: }; } + static std::vector SelectColumns() + { + return { + "player_race", + "pet_race", + "texture", + "helm_texture", + "gender", + "size_modifier", + "face", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("pets_beastlord_data"); @@ -59,7 +78,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_pets_equipmentset_entries_repository.h b/common/repositories/base/base_pets_equipmentset_entries_repository.h index 1999b35b7..778b3f457 100644 --- a/common/repositories/base/base_pets_equipmentset_entries_repository.h +++ b/common/repositories/base/base_pets_equipmentset_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePetsEquipmentsetEntriesRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "set_id", + "slot", + "item_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("pets_equipmentset_entries"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_pets_equipmentset_repository.h b/common/repositories/base/base_pets_equipmentset_repository.h index ebb04c02c..2c5c85afb 100644 --- a/common/repositories/base/base_pets_equipmentset_repository.h +++ b/common/repositories/base/base_pets_equipmentset_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePetsEquipmentsetRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "set_id", + "setname", + "nested_set", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("pets_equipmentset"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_pets_repository.h b/common/repositories/base/base_pets_repository.h index 1dc25f333..345b33ffb 100644 --- a/common/repositories/base/base_pets_repository.h +++ b/common/repositories/base/base_pets_repository.h @@ -14,10 +14,12 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePetsRepository { public: struct Pets { + int id; std::string type; int petpower; int npcID; @@ -30,12 +32,28 @@ public: static std::string PrimaryKey() { - return std::string("petpower"); + return std::string("id"); } static std::vector Columns() { return { + "id", + "type", + "petpower", + "npcID", + "temp", + "petcontrol", + "petnaming", + "monsterflag", + "equipmentset", + }; + } + + static std::vector SelectColumns() + { + return { + "id", "type", "petpower", "npcID", @@ -52,6 +70,11 @@ public: return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("pets"); @@ -61,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -79,6 +102,7 @@ public: { Pets entry{}; + entry.id = 0; entry.type = ""; entry.petpower = 0; entry.npcID = 0; @@ -97,7 +121,7 @@ public: ) { for (auto &pets : petss) { - if (pets.petpower == pets_id) { + if (pets.id == pets_id) { return pets; } } @@ -122,14 +146,15 @@ public: if (results.RowCount() == 1) { Pets entry{}; - entry.type = row[0] ? 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]); + entry.id = atoi(row[0]); + entry.type = row[1] ? row[1] : ""; + entry.petpower = atoi(row[2]); + entry.npcID = atoi(row[3]); + entry.temp = atoi(row[4]); + entry.petcontrol = atoi(row[5]); + entry.petnaming = atoi(row[6]); + entry.monsterflag = atoi(row[7]); + entry.equipmentset = atoi(row[8]); return entry; } @@ -163,14 +188,14 @@ public: auto columns = Columns(); - update_values.push_back(columns[0] + " = '" + EscapeString(pets_entry.type) + "'"); - update_values.push_back(columns[1] + " = " + std::to_string(pets_entry.petpower)); - update_values.push_back(columns[2] + " = " + std::to_string(pets_entry.npcID)); - update_values.push_back(columns[3] + " = " + std::to_string(pets_entry.temp)); - update_values.push_back(columns[4] + " = " + std::to_string(pets_entry.petcontrol)); - update_values.push_back(columns[5] + " = " + std::to_string(pets_entry.petnaming)); - update_values.push_back(columns[6] + " = " + std::to_string(pets_entry.monsterflag)); - update_values.push_back(columns[7] + " = " + std::to_string(pets_entry.equipmentset)); + update_values.push_back(columns[1] + " = '" + EscapeString(pets_entry.type) + "'"); + update_values.push_back(columns[2] + " = " + std::to_string(pets_entry.petpower)); + update_values.push_back(columns[3] + " = " + std::to_string(pets_entry.npcID)); + update_values.push_back(columns[4] + " = " + std::to_string(pets_entry.temp)); + update_values.push_back(columns[5] + " = " + std::to_string(pets_entry.petcontrol)); + update_values.push_back(columns[6] + " = " + std::to_string(pets_entry.petnaming)); + update_values.push_back(columns[7] + " = " + std::to_string(pets_entry.monsterflag)); + update_values.push_back(columns[8] + " = " + std::to_string(pets_entry.equipmentset)); auto results = db.QueryDatabase( fmt::format( @@ -178,7 +203,7 @@ public: TableName(), implode(", ", update_values), PrimaryKey(), - pets_entry.petpower + pets_entry.id ) ); @@ -192,6 +217,7 @@ public: { std::vector insert_values; + insert_values.push_back(std::to_string(pets_entry.id)); insert_values.push_back("'" + EscapeString(pets_entry.type) + "'"); insert_values.push_back(std::to_string(pets_entry.petpower)); insert_values.push_back(std::to_string(pets_entry.npcID)); @@ -210,7 +236,7 @@ public: ); if (results.Success()) { - pets_entry.petpower = results.LastInsertedID(); + pets_entry.id = results.LastInsertedID(); return pets_entry; } @@ -229,6 +255,7 @@ public: for (auto &pets_entry: pets_entries) { std::vector insert_values; + insert_values.push_back(std::to_string(pets_entry.id)); insert_values.push_back("'" + EscapeString(pets_entry.type) + "'"); insert_values.push_back(std::to_string(pets_entry.petpower)); insert_values.push_back(std::to_string(pets_entry.npcID)); @@ -270,14 +297,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Pets entry{}; - entry.type = row[0] ? 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]); + entry.id = atoi(row[0]); + entry.type = row[1] ? row[1] : ""; + entry.petpower = atoi(row[2]); + entry.npcID = atoi(row[3]); + entry.temp = atoi(row[4]); + entry.petcontrol = atoi(row[5]); + entry.petnaming = atoi(row[6]); + entry.monsterflag = atoi(row[7]); + entry.equipmentset = atoi(row[8]); all_entries.push_back(entry); } @@ -302,14 +330,15 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Pets entry{}; - entry.type = row[0] ? 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]); + entry.id = atoi(row[0]); + entry.type = row[1] ? row[1] : ""; + entry.petpower = atoi(row[2]); + entry.npcID = atoi(row[3]); + entry.temp = atoi(row[4]); + entry.petcontrol = atoi(row[5]); + entry.petnaming = atoi(row[6]); + entry.monsterflag = atoi(row[7]); + entry.equipmentset = atoi(row[8]); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_player_titlesets_repository.h b/common/repositories/base/base_player_titlesets_repository.h index dad10ca0d..1d7c2e031 100644 --- a/common/repositories/base/base_player_titlesets_repository.h +++ b/common/repositories/base/base_player_titlesets_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BasePlayerTitlesetsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "char_id", + "title_set", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("player_titlesets"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_proximities_repository.h b/common/repositories/base/base_proximities_repository.h index 8dfff3279..8126ac402 100644 --- a/common/repositories/base/base_proximities_repository.h +++ b/common/repositories/base/base_proximities_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseProximitiesRepository { public: @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "zoneid", + "exploreid", + "minx", + "maxx", + "miny", + "maxy", + "minz", + "maxz", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("proximities"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_quest_globals_repository.h b/common/repositories/base/base_quest_globals_repository.h index 7324e7c29..f6b751cfc 100644 --- a/common/repositories/base/base_quest_globals_repository.h +++ b/common/repositories/base/base_quest_globals_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseQuestGlobalsRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "charid", + "npcid", + "zoneid", + "name", + "value", + "expdate", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("quest_globals"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_raid_details_repository.h b/common/repositories/base/base_raid_details_repository.h index a53949908..075928853 100644 --- a/common/repositories/base/base_raid_details_repository.h +++ b/common/repositories/base/base_raid_details_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseRaidDetailsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "raidid", + "loottype", + "locked", + "motd", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("raid_details"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_raid_members_repository.h b/common/repositories/base/base_raid_members_repository.h index 2dc350ae1..ed90853f0 100644 --- a/common/repositories/base/base_raid_members_repository.h +++ b/common/repositories/base/base_raid_members_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseRaidMembersRepository { public: @@ -49,11 +50,31 @@ public: }; } + static std::vector SelectColumns() + { + return { + "raidid", + "charid", + "groupid", + "_class", + "level", + "name", + "isgroupleader", + "israidleader", + "islooter", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("raid_members"); @@ -63,7 +84,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_reports_repository.h b/common/repositories/base/base_reports_repository.h index 89aa474b7..46316917a 100644 --- a/common/repositories/base/base_reports_repository.h +++ b/common/repositories/base/base_reports_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseReportsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "reported", + "reported_text", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("reports"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_respawn_times_repository.h b/common/repositories/base/base_respawn_times_repository.h index 0ca8d525f..27ed4b281 100644 --- a/common/repositories/base/base_respawn_times_repository.h +++ b/common/repositories/base/base_respawn_times_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseRespawnTimesRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "start", + "duration", + "instance_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("respawn_times"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_rule_sets_repository.h b/common/repositories/base/base_rule_sets_repository.h index 181e064a8..5ca2361a8 100644 --- a/common/repositories/base/base_rule_sets_repository.h +++ b/common/repositories/base/base_rule_sets_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseRuleSetsRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "ruleset_id", + "name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("rule_sets"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_rule_values_repository.h b/common/repositories/base/base_rule_values_repository.h index 821ccfdc2..418509d96 100644 --- a/common/repositories/base/base_rule_values_repository.h +++ b/common/repositories/base/base_rule_values_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseRuleValuesRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "ruleset_id", + "rule_name", + "rule_value", + "notes", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("rule_values"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_saylink_repository.h b/common/repositories/base/base_saylink_repository.h index d9206a137..fac19e49e 100644 --- a/common/repositories/base/base_saylink_repository.h +++ b/common/repositories/base/base_saylink_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSaylinkRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "phrase", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("saylink"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_server_scheduled_events_repository.h b/common/repositories/base/base_server_scheduled_events_repository.h index 1cc319d6a..c47794b47 100644 --- a/common/repositories/base/base_server_scheduled_events_repository.h +++ b/common/repositories/base/base_server_scheduled_events_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseServerScheduledEventsRepository { public: @@ -33,8 +34,8 @@ public: int month_end; int year_end; std::string cron_expression; - std::string created_at; - std::string deleted_at; + time_t created_at; + time_t deleted_at; }; static std::string PrimaryKey() @@ -65,11 +66,39 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "description", + "event_type", + "event_data", + "minute_start", + "hour_start", + "day_start", + "month_start", + "year_start", + "minute_end", + "hour_end", + "day_end", + "month_end", + "year_end", + "cron_expression", + "UNIX_TIMESTAMP(created_at)", + "UNIX_TIMESTAMP(deleted_at)", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("server_scheduled_events"); @@ -79,7 +108,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -112,8 +141,8 @@ public: entry.month_end = 0; entry.year_end = 0; entry.cron_expression = ""; - entry.created_at = ""; - entry.deleted_at = ""; + entry.created_at = 0; + entry.deleted_at = 0; return entry; } @@ -164,8 +193,8 @@ public: entry.month_end = atoi(row[12]); entry.year_end = atoi(row[13]); entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; + entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); return entry; } @@ -213,8 +242,8 @@ public: update_values.push_back(columns[12] + " = " + std::to_string(server_scheduled_events_entry.month_end)); update_values.push_back(columns[13] + " = " + std::to_string(server_scheduled_events_entry.year_end)); update_values.push_back(columns[14] + " = '" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - update_values.push_back(columns[15] + " = '" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - update_values.push_back(columns[16] + " = '" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); + update_values.push_back(columns[15] + " = FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); + update_values.push_back(columns[16] + " = FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -251,8 +280,8 @@ public: insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -297,8 +326,8 @@ public: insert_values.push_back(std::to_string(server_scheduled_events_entry.month_end)); insert_values.push_back(std::to_string(server_scheduled_events_entry.year_end)); insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.cron_expression) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.created_at) + "'"); - insert_values.push_back("'" + EscapeString(server_scheduled_events_entry.deleted_at) + "'"); + insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.created_at > 0 ? std::to_string(server_scheduled_events_entry.created_at) : "null") + ")"); + insert_values.push_back("FROM_UNIXTIME(" + (server_scheduled_events_entry.deleted_at > 0 ? std::to_string(server_scheduled_events_entry.deleted_at) : "null") + ")"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -347,8 +376,8 @@ public: entry.month_end = atoi(row[12]); entry.year_end = atoi(row[13]); entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; + entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); all_entries.push_back(entry); } @@ -388,8 +417,8 @@ public: entry.month_end = atoi(row[12]); entry.year_end = atoi(row[13]); entry.cron_expression = row[14] ? row[14] : ""; - entry.created_at = row[15] ? row[15] : ""; - entry.deleted_at = row[16] ? row[16] : ""; + entry.created_at = strtoll(row[15] ? row[15] : "-1", nullptr, 10); + entry.deleted_at = strtoll(row[16] ? row[16] : "-1", nullptr, 10); all_entries.push_back(entry); } diff --git a/common/repositories/base/base_shared_task_dynamic_zones_repository.h b/common/repositories/base/base_shared_task_dynamic_zones_repository.h index ab60aa54d..021e398cc 100644 --- a/common/repositories/base/base_shared_task_dynamic_zones_repository.h +++ b/common/repositories/base/base_shared_task_dynamic_zones_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSharedTaskDynamicZonesRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "shared_task_id", + "dynamic_zone_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("shared_task_dynamic_zones"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -104,7 +118,7 @@ public: if (results.RowCount() == 1) { SharedTaskDynamicZones entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); entry.dynamic_zone_id = atoi(row[1]); return entry; @@ -228,7 +242,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SharedTaskDynamicZones entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); entry.dynamic_zone_id = atoi(row[1]); all_entries.push_back(entry); @@ -254,7 +268,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SharedTaskDynamicZones entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); entry.dynamic_zone_id = atoi(row[1]); all_entries.push_back(entry); diff --git a/common/repositories/base/base_shared_task_members_repository.h b/common/repositories/base/base_shared_task_members_repository.h index 6e5d36227..0ab005888 100644 --- a/common/repositories/base/base_shared_task_members_repository.h +++ b/common/repositories/base/base_shared_task_members_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSharedTaskMembersRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "shared_task_id", + "character_id", + "is_leader", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("shared_task_members"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -107,8 +122,8 @@ public: if (results.RowCount() == 1) { SharedTaskMembers entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); - entry.character_id = strtoll(row[1], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); + entry.character_id = strtoll(row[1], nullptr, 10); entry.is_leader = atoi(row[2]); return entry; @@ -235,8 +250,8 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SharedTaskMembers entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); - entry.character_id = strtoll(row[1], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); + entry.character_id = strtoll(row[1], nullptr, 10); entry.is_leader = atoi(row[2]); all_entries.push_back(entry); @@ -262,8 +277,8 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SharedTaskMembers entry{}; - entry.shared_task_id = strtoll(row[0], NULL, 10); - entry.character_id = strtoll(row[1], NULL, 10); + entry.shared_task_id = strtoll(row[0], nullptr, 10); + entry.character_id = strtoll(row[1], nullptr, 10); entry.is_leader = atoi(row[2]); all_entries.push_back(entry); diff --git a/common/repositories/base/base_skill_caps_repository.h b/common/repositories/base/base_skill_caps_repository.h index dee1ede92..5e8efdfad 100644 --- a/common/repositories/base/base_skill_caps_repository.h +++ b/common/repositories/base/base_skill_caps_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSkillCapsRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "skillID", + "`class`", + "level", + "cap", + "class_", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("skill_caps"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spawn2_repository.h b/common/repositories/base/base_spawn2_repository.h index 6ff7146ee..f771c12fe 100644 --- a/common/repositories/base/base_spawn2_repository.h +++ b/common/repositories/base/base_spawn2_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawn2Repository { public: @@ -71,11 +72,42 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "spawngroupID", + "zone", + "version", + "x", + "y", + "z", + "heading", + "respawntime", + "variance", + "pathgrid", + "path_when_zone_idle", + "_condition", + "cond_value", + "enabled", + "animation", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawn2"); @@ -85,7 +117,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -119,8 +151,8 @@ public: entry.cond_value = 1; entry.enabled = 1; entry.animation = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_spawn_condition_values_repository.h b/common/repositories/base/base_spawn_condition_values_repository.h index ca796270f..b778c7fbb 100644 --- a/common/repositories/base/base_spawn_condition_values_repository.h +++ b/common/repositories/base/base_spawn_condition_values_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawnConditionValuesRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "value", + "zone", + "instance_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawn_condition_values"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spawn_conditions_repository.h b/common/repositories/base/base_spawn_conditions_repository.h index 4a3435fd7..11a6cd6ea 100644 --- a/common/repositories/base/base_spawn_conditions_repository.h +++ b/common/repositories/base/base_spawn_conditions_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawnConditionsRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "zone", + "id", + "value", + "onchange", + "name", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawn_conditions"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spawn_events_repository.h b/common/repositories/base/base_spawn_events_repository.h index 66490d2ca..e20f07fa7 100644 --- a/common/repositories/base/base_spawn_events_repository.h +++ b/common/repositories/base/base_spawn_events_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawnEventsRepository { public: @@ -59,11 +60,36 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "cond_id", + "name", + "period", + "next_minute", + "next_hour", + "next_day", + "next_month", + "next_year", + "enabled", + "action", + "argument", + "strict", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawn_events"); @@ -73,7 +99,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spawnentry_repository.h b/common/repositories/base/base_spawnentry_repository.h index 3bfb7b5e0..e2500dae7 100644 --- a/common/repositories/base/base_spawnentry_repository.h +++ b/common/repositories/base/base_spawnentry_repository.h @@ -14,14 +14,19 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawnentryRepository { public: struct Spawnentry { - int spawngroupID; - int npcID; - int chance; - int condition_value_filter; + int spawngroupID; + int npcID; + int chance; + int condition_value_filter; + int min_expansion; + int max_expansion; + std::string content_flags; + std::string content_flags_disabled; }; static std::string PrimaryKey() @@ -36,6 +41,24 @@ public: "npcID", "chance", "condition_value_filter", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + + static std::vector SelectColumns() + { + return { + "spawngroupID", + "npcID", + "chance", + "condition_value_filter", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", }; } @@ -44,6 +67,11 @@ public: return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawnentry"); @@ -53,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -75,6 +103,10 @@ public: entry.npcID = 0; entry.chance = 0; entry.condition_value_filter = 1; + entry.min_expansion = -1; + entry.max_expansion = -1; + entry.content_flags = ""; + entry.content_flags_disabled = ""; return entry; } @@ -114,6 +146,10 @@ public: entry.npcID = atoi(row[1]); entry.chance = atoi(row[2]); entry.condition_value_filter = atoi(row[3]); + entry.min_expansion = atoi(row[4]); + entry.max_expansion = atoi(row[5]); + entry.content_flags = row[6] ? row[6] : ""; + entry.content_flags_disabled = row[7] ? row[7] : ""; return entry; } @@ -151,6 +187,10 @@ public: update_values.push_back(columns[1] + " = " + std::to_string(spawnentry_entry.npcID)); update_values.push_back(columns[2] + " = " + std::to_string(spawnentry_entry.chance)); update_values.push_back(columns[3] + " = " + std::to_string(spawnentry_entry.condition_value_filter)); + update_values.push_back(columns[4] + " = " + std::to_string(spawnentry_entry.min_expansion)); + update_values.push_back(columns[5] + " = " + std::to_string(spawnentry_entry.max_expansion)); + update_values.push_back(columns[6] + " = '" + EscapeString(spawnentry_entry.content_flags) + "'"); + update_values.push_back(columns[7] + " = '" + EscapeString(spawnentry_entry.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( @@ -176,6 +216,10 @@ public: insert_values.push_back(std::to_string(spawnentry_entry.npcID)); insert_values.push_back(std::to_string(spawnentry_entry.chance)); insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); + insert_values.push_back(std::to_string(spawnentry_entry.min_expansion)); + insert_values.push_back(std::to_string(spawnentry_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(spawnentry_entry.content_flags) + "'"); + insert_values.push_back("'" + EscapeString(spawnentry_entry.content_flags_disabled) + "'"); auto results = db.QueryDatabase( fmt::format( @@ -209,6 +253,10 @@ public: insert_values.push_back(std::to_string(spawnentry_entry.npcID)); insert_values.push_back(std::to_string(spawnentry_entry.chance)); insert_values.push_back(std::to_string(spawnentry_entry.condition_value_filter)); + insert_values.push_back(std::to_string(spawnentry_entry.min_expansion)); + insert_values.push_back(std::to_string(spawnentry_entry.max_expansion)); + insert_values.push_back("'" + EscapeString(spawnentry_entry.content_flags) + "'"); + insert_values.push_back("'" + EscapeString(spawnentry_entry.content_flags_disabled) + "'"); insert_chunks.push_back("(" + implode(",", insert_values) + ")"); } @@ -246,6 +294,10 @@ public: entry.npcID = atoi(row[1]); entry.chance = atoi(row[2]); entry.condition_value_filter = atoi(row[3]); + entry.min_expansion = atoi(row[4]); + entry.max_expansion = atoi(row[5]); + entry.content_flags = row[6] ? row[6] : ""; + entry.content_flags_disabled = row[7] ? row[7] : ""; all_entries.push_back(entry); } @@ -274,6 +326,10 @@ public: entry.npcID = atoi(row[1]); entry.chance = atoi(row[2]); entry.condition_value_filter = atoi(row[3]); + entry.min_expansion = atoi(row[4]); + entry.max_expansion = atoi(row[5]); + entry.content_flags = row[6] ? row[6] : ""; + entry.content_flags_disabled = row[7] ? row[7] : ""; all_entries.push_back(entry); } diff --git a/common/repositories/base/base_spawngroup_repository.h b/common/repositories/base/base_spawngroup_repository.h index a9ab5e3e6..782c4c9df 100644 --- a/common/repositories/base/base_spawngroup_repository.h +++ b/common/repositories/base/base_spawngroup_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpawngroupRepository { public: @@ -57,11 +58,35 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "spawn_limit", + "dist", + "max_x", + "min_x", + "max_y", + "min_y", + "delay", + "mindelay", + "despawn", + "despawn_timer", + "wp_spawns", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spawngroup"); @@ -71,7 +96,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spell_buckets_repository.h b/common/repositories/base/base_spell_buckets_repository.h index 7e6d5e46d..69e5f3974 100644 --- a/common/repositories/base/base_spell_buckets_repository.h +++ b/common/repositories/base/base_spell_buckets_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpellBucketsRepository { public: @@ -37,11 +38,25 @@ public: }; } + static std::vector SelectColumns() + { + return { + "spellid", + "key", + "value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spell_buckets"); @@ -51,7 +66,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -107,7 +122,7 @@ public: if (results.RowCount() == 1) { SpellBuckets entry{}; - entry.spellid = strtoll(row[0], NULL, 10); + entry.spellid = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; @@ -235,7 +250,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SpellBuckets entry{}; - entry.spellid = strtoll(row[0], NULL, 10); + entry.spellid = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; @@ -262,7 +277,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SpellBuckets entry{}; - entry.spellid = strtoll(row[0], NULL, 10); + entry.spellid = strtoll(row[0], nullptr, 10); entry.key = row[1] ? row[1] : ""; entry.value = row[2] ? row[2] : ""; diff --git a/common/repositories/base/base_spell_globals_repository.h b/common/repositories/base/base_spell_globals_repository.h index 26e836597..11323e9ce 100644 --- a/common/repositories/base/base_spell_globals_repository.h +++ b/common/repositories/base/base_spell_globals_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpellGlobalsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "spellid", + "spell_name", + "qglobal", + "value", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spell_globals"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_spells_new_repository.h b/common/repositories/base/base_spells_new_repository.h index 111140f27..47b40ecba 100644 --- a/common/repositories/base/base_spells_new_repository.h +++ b/common/repositories/base/base_spells_new_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseSpellsNewRepository { public: @@ -505,11 +506,259 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "player_1", + "teleport_zone", + "you_cast", + "other_casts", + "cast_on_you", + "cast_on_other", + "spell_fades", + "range", + "aoerange", + "pushback", + "pushup", + "cast_time", + "recovery_time", + "recast_time", + "buffdurationformula", + "buffduration", + "AEDuration", + "mana", + "effect_base_value1", + "effect_base_value2", + "effect_base_value3", + "effect_base_value4", + "effect_base_value5", + "effect_base_value6", + "effect_base_value7", + "effect_base_value8", + "effect_base_value9", + "effect_base_value10", + "effect_base_value11", + "effect_base_value12", + "effect_limit_value1", + "effect_limit_value2", + "effect_limit_value3", + "effect_limit_value4", + "effect_limit_value5", + "effect_limit_value6", + "effect_limit_value7", + "effect_limit_value8", + "effect_limit_value9", + "effect_limit_value10", + "effect_limit_value11", + "effect_limit_value12", + "max1", + "max2", + "max3", + "max4", + "max5", + "max6", + "max7", + "max8", + "max9", + "max10", + "max11", + "max12", + "icon", + "memicon", + "components1", + "components2", + "components3", + "components4", + "component_counts1", + "component_counts2", + "component_counts3", + "component_counts4", + "NoexpendReagent1", + "NoexpendReagent2", + "NoexpendReagent3", + "NoexpendReagent4", + "formula1", + "formula2", + "formula3", + "formula4", + "formula5", + "formula6", + "formula7", + "formula8", + "formula9", + "formula10", + "formula11", + "formula12", + "LightType", + "goodEffect", + "Activated", + "resisttype", + "effectid1", + "effectid2", + "effectid3", + "effectid4", + "effectid5", + "effectid6", + "effectid7", + "effectid8", + "effectid9", + "effectid10", + "effectid11", + "effectid12", + "targettype", + "basediff", + "skill", + "zonetype", + "EnvironmentType", + "TimeOfDay", + "classes1", + "classes2", + "classes3", + "classes4", + "classes5", + "classes6", + "classes7", + "classes8", + "classes9", + "classes10", + "classes11", + "classes12", + "classes13", + "classes14", + "classes15", + "classes16", + "CastingAnim", + "TargetAnim", + "TravelType", + "SpellAffectIndex", + "disallow_sit", + "deities0", + "deities1", + "deities2", + "deities3", + "deities4", + "deities5", + "deities6", + "deities7", + "deities8", + "deities9", + "deities10", + "deities11", + "deities12", + "deities13", + "deities14", + "deities15", + "deities16", + "field142", + "field143", + "new_icon", + "spellanim", + "uninterruptable", + "ResistDiff", + "dot_stacking_exempt", + "deleteable", + "RecourseLink", + "no_partial_resist", + "field152", + "field153", + "short_buff_box", + "descnum", + "typedescnum", + "effectdescnum", + "effectdescnum2", + "npc_no_los", + "field160", + "reflectable", + "bonushate", + "field163", + "field164", + "ldon_trap", + "EndurCost", + "EndurTimerIndex", + "IsDiscipline", + "field169", + "field170", + "field171", + "field172", + "HateAdded", + "EndurUpkeep", + "numhitstype", + "numhits", + "pvpresistbase", + "pvpresistcalc", + "pvpresistcap", + "spell_category", + "pvp_duration", + "pvp_duration_cap", + "pcnpc_only_flag", + "cast_not_standing", + "can_mgb", + "nodispell", + "npc_category", + "npc_usefulness", + "MinResist", + "MaxResist", + "viral_targets", + "viral_timer", + "nimbuseffect", + "ConeStartAngle", + "ConeStopAngle", + "sneaking", + "not_extendable", + "field198", + "field199", + "suspendable", + "viral_range", + "songcap", + "field203", + "field204", + "no_block", + "field206", + "spellgroup", + "rank", + "field209", + "field210", + "CastRestriction", + "allowrest", + "InCombat", + "OutofCombat", + "field215", + "field216", + "field217", + "aemaxtargets", + "maxtargets", + "field220", + "field221", + "field222", + "field223", + "persistdeath", + "field225", + "field226", + "min_dist", + "min_dist_mod", + "max_dist", + "max_dist_mod", + "min_range", + "field232", + "field233", + "field234", + "field235", + "field236", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("spells_new"); @@ -519,7 +768,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_start_zones_repository.h b/common/repositories/base/base_start_zones_repository.h index 9a627de40..5a970d4e3 100644 --- a/common/repositories/base/base_start_zones_repository.h +++ b/common/repositories/base/base_start_zones_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseStartZonesRepository { public: @@ -69,11 +70,41 @@ public: }; } + static std::vector SelectColumns() + { + return { + "x", + "y", + "z", + "heading", + "zone_id", + "bind_id", + "player_choice", + "player_class", + "player_deity", + "player_race", + "start_zone", + "bind_x", + "bind_y", + "bind_z", + "select_rank", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("start_zones"); @@ -83,7 +114,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -116,8 +147,8 @@ public: entry.bind_y = 0; entry.bind_z = 0; entry.select_rank = 50; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_starting_items_repository.h b/common/repositories/base/base_starting_items_repository.h index 0f40bb16d..0c17c503a 100644 --- a/common/repositories/base/base_starting_items_repository.h +++ b/common/repositories/base/base_starting_items_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseStartingItemsRepository { public: @@ -57,11 +58,35 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "race", + "`class`", + "deityid", + "zoneid", + "itemid", + "item_charges", + "gm", + "slot", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("starting_items"); @@ -71,7 +96,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -98,8 +123,8 @@ public: entry.item_charges = 1; entry.gm = 0; entry.slot = -1; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_task_activities_repository.h b/common/repositories/base/base_task_activities_repository.h index e88334e1b..0e126fdda 100644 --- a/common/repositories/base/base_task_activities_repository.h +++ b/common/repositories/base/base_task_activities_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTaskActivitiesRepository { public: @@ -61,11 +62,37 @@ public: }; } + static std::vector SelectColumns() + { + return { + "taskid", + "activityid", + "step", + "activitytype", + "target_name", + "item_list", + "skill_list", + "spell_list", + "description_override", + "goalid", + "goalmethod", + "goalcount", + "delivertonpc", + "zones", + "optional", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("task_activities"); @@ -75,7 +102,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_tasksets_repository.h b/common/repositories/base/base_tasksets_repository.h index 0944f57b3..2dd53531f 100644 --- a/common/repositories/base/base_tasksets_repository.h +++ b/common/repositories/base/base_tasksets_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTasksetsRepository { public: @@ -35,11 +36,24 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "taskid", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("tasksets"); @@ -49,7 +63,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_timers_repository.h b/common/repositories/base/base_timers_repository.h index ea3774bc2..4be6e959d 100644 --- a/common/repositories/base/base_timers_repository.h +++ b/common/repositories/base/base_timers_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTimersRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "type", + "start", + "duration", + "enable", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("timers"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_titles_repository.h b/common/repositories/base/base_titles_repository.h index e270b51d1..fec2556d4 100644 --- a/common/repositories/base/base_titles_repository.h +++ b/common/repositories/base/base_titles_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTitlesRepository { public: @@ -59,11 +60,36 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "skill_id", + "min_skill_value", + "max_skill_value", + "min_aa_points", + "max_aa_points", + "`class`", + "gender", + "char_id", + "status", + "item_id", + "prefix", + "suffix", + "title_set", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("titles"); @@ -73,7 +99,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_trader_repository.h b/common/repositories/base/base_trader_repository.h index 1481e6154..2fa33f862 100644 --- a/common/repositories/base/base_trader_repository.h +++ b/common/repositories/base/base_trader_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTraderRepository { public: @@ -43,11 +44,28 @@ public: }; } + static std::vector SelectColumns() + { + return { + "char_id", + "item_id", + "serialnumber", + "charges", + "item_cost", + "slot_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("trader"); @@ -57,7 +75,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_tradeskill_recipe_entries_repository.h b/common/repositories/base/base_tradeskill_recipe_entries_repository.h index 274c58ca1..f33dea405 100644 --- a/common/repositories/base/base_tradeskill_recipe_entries_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_entries_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTradeskillRecipeEntriesRepository { public: @@ -47,11 +48,30 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "recipe_id", + "item_id", + "successcount", + "failcount", + "componentcount", + "salvagecount", + "iscontainer", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("tradeskill_recipe_entries"); @@ -61,7 +81,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_tradeskill_recipe_repository.h b/common/repositories/base/base_tradeskill_recipe_repository.h index 019cea88f..2231a26dc 100644 --- a/common/repositories/base/base_tradeskill_recipe_repository.h +++ b/common/repositories/base/base_tradeskill_recipe_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTradeskillRecipeRepository { public: @@ -61,11 +62,37 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "name", + "tradeskill", + "skillneeded", + "trivial", + "nofail", + "replace_container", + "notes", + "must_learn", + "quest", + "enabled", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("tradeskill_recipe"); @@ -75,7 +102,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -104,8 +131,8 @@ public: entry.must_learn = 0; entry.quest = 0; entry.enabled = 1; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_traps_repository.h b/common/repositories/base/base_traps_repository.h index 07ab550b4..71048760c 100644 --- a/common/repositories/base/base_traps_repository.h +++ b/common/repositories/base/base_traps_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTrapsRepository { public: @@ -81,11 +82,47 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "version", + "x", + "y", + "z", + "chance", + "maxzdiff", + "radius", + "effect", + "effectvalue", + "effectvalue2", + "message", + "skill", + "level", + "respawn_time", + "respawn_var", + "triggered_number", + "group", + "despawn_when_triggered", + "undetectable", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("traps"); @@ -95,7 +132,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -134,8 +171,8 @@ public: entry.group = 0; entry.despawn_when_triggered = 0; entry.undetectable = 0; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; diff --git a/common/repositories/base/base_tribute_levels_repository.h b/common/repositories/base/base_tribute_levels_repository.h index fef67ff27..8ed65defc 100644 --- a/common/repositories/base/base_tribute_levels_repository.h +++ b/common/repositories/base/base_tribute_levels_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTributeLevelsRepository { public: @@ -39,11 +40,26 @@ public: }; } + static std::vector SelectColumns() + { + return { + "tribute_id", + "level", + "cost", + "item_id", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("tribute_levels"); @@ -53,7 +69,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_tributes_repository.h b/common/repositories/base/base_tributes_repository.h index c3a7f6324..a18729cd8 100644 --- a/common/repositories/base/base_tributes_repository.h +++ b/common/repositories/base/base_tributes_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseTributesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "unknown", + "name", + "descr", + "isguild", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("tributes"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_veteran_reward_templates_repository.h b/common/repositories/base/base_veteran_reward_templates_repository.h index 283742309..9055b15d5 100644 --- a/common/repositories/base/base_veteran_reward_templates_repository.h +++ b/common/repositories/base/base_veteran_reward_templates_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseVeteranRewardTemplatesRepository { public: @@ -41,11 +42,27 @@ public: }; } + static std::vector SelectColumns() + { + return { + "claim_id", + "name", + "item_id", + "charges", + "reward_slot", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("veteran_reward_templates"); @@ -55,7 +72,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } diff --git a/common/repositories/base/base_zone_points_repository.h b/common/repositories/base/base_zone_points_repository.h index b29cae43a..b1f288d75 100644 --- a/common/repositories/base/base_zone_points_repository.h +++ b/common/repositories/base/base_zone_points_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseZonePointsRepository { public: @@ -79,11 +80,46 @@ public: }; } + static std::vector SelectColumns() + { + return { + "id", + "zone", + "version", + "number", + "y", + "x", + "z", + "heading", + "target_y", + "target_x", + "target_z", + "target_heading", + "zoneinst", + "target_zone_id", + "target_instance", + "buffer", + "client_version_mask", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + "is_virtual", + "height", + "width", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("zone_points"); @@ -93,7 +129,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -128,8 +164,8 @@ public: entry.target_instance = 0; entry.buffer = 0; entry.client_version_mask = 4294967295; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; entry.is_virtual = 0; diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h index 3478c9fa1..c9db5510d 100644 --- a/common/repositories/base/base_zone_repository.h +++ b/common/repositories/base/base_zone_repository.h @@ -14,6 +14,7 @@ #include "../../database.h" #include "../../string_util.h" +#include class BaseZoneRepository { public: @@ -219,11 +220,116 @@ public: }; } + static std::vector SelectColumns() + { + return { + "short_name", + "id", + "file_name", + "long_name", + "map_file_name", + "safe_x", + "safe_y", + "safe_z", + "safe_heading", + "graveyard_id", + "min_level", + "min_status", + "zoneidnumber", + "version", + "timezone", + "maxclients", + "ruleset", + "note", + "underworld", + "minclip", + "maxclip", + "fog_minclip", + "fog_maxclip", + "fog_blue", + "fog_red", + "fog_green", + "sky", + "ztype", + "zone_exp_multiplier", + "walkspeed", + "time_type", + "fog_red1", + "fog_green1", + "fog_blue1", + "fog_minclip1", + "fog_maxclip1", + "fog_red2", + "fog_green2", + "fog_blue2", + "fog_minclip2", + "fog_maxclip2", + "fog_red3", + "fog_green3", + "fog_blue3", + "fog_minclip3", + "fog_maxclip3", + "fog_red4", + "fog_green4", + "fog_blue4", + "fog_minclip4", + "fog_maxclip4", + "fog_density", + "flag_needed", + "canbind", + "cancombat", + "canlevitate", + "castoutdoor", + "hotzone", + "insttype", + "shutdowndelay", + "peqzone", + "expansion", + "suspendbuffs", + "rain_chance1", + "rain_chance2", + "rain_chance3", + "rain_chance4", + "rain_duration1", + "rain_duration2", + "rain_duration3", + "rain_duration4", + "snow_chance1", + "snow_chance2", + "snow_chance3", + "snow_chance4", + "snow_duration1", + "snow_duration2", + "snow_duration3", + "snow_duration4", + "gravity", + "type", + "skylock", + "fast_regen_hp", + "fast_regen_mana", + "fast_regen_endurance", + "npc_max_aggro_dist", + "max_movement_update_range", + "min_expansion", + "max_expansion", + "content_flags", + "content_flags_disabled", + "underworld_teleport_index", + "lava_damage", + "min_lava_damage", + }; + } + static std::string ColumnsRaw() { return std::string(implode(", ", Columns())); } + static std::string SelectColumnsRaw() + { + return std::string(implode(", ", SelectColumns())); + } + static std::string TableName() { return std::string("zone"); @@ -233,7 +339,7 @@ public: { return fmt::format( "SELECT {} FROM {}", - ColumnsRaw(), + SelectColumnsRaw(), TableName() ); } @@ -338,8 +444,8 @@ public: entry.fast_regen_endurance = 180; entry.npc_max_aggro_dist = 600; entry.max_movement_update_range = 600; - entry.min_expansion = 0; - entry.max_expansion = 0; + entry.min_expansion = -1; + entry.max_expansion = -1; entry.content_flags = ""; entry.content_flags_disabled = ""; entry.underworld_teleport_index = 0; @@ -439,7 +545,7 @@ public: entry.castoutdoor = atoi(row[56]); entry.hotzone = atoi(row[57]); entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], NULL, 10); + entry.shutdowndelay = strtoll(row[59], nullptr, 10); entry.peqzone = atoi(row[60]); entry.expansion = atoi(row[61]); entry.suspendbuffs = atoi(row[62]); @@ -930,7 +1036,7 @@ public: entry.castoutdoor = atoi(row[56]); entry.hotzone = atoi(row[57]); entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], NULL, 10); + entry.shutdowndelay = strtoll(row[59], nullptr, 10); entry.peqzone = atoi(row[60]); entry.expansion = atoi(row[61]); entry.suspendbuffs = atoi(row[62]); @@ -1048,7 +1154,7 @@ public: entry.castoutdoor = atoi(row[56]); entry.hotzone = atoi(row[57]); entry.insttype = atoi(row[58]); - entry.shutdowndelay = strtoll(row[59], NULL, 10); + entry.shutdowndelay = strtoll(row[59], nullptr, 10); entry.peqzone = atoi(row[60]); entry.expansion = atoi(row[61]); entry.suspendbuffs = atoi(row[62]); diff --git a/common/repositories/books_repository.h b/common/repositories/books_repository.h new file mode 100644 index 000000000..6c2e3db91 --- /dev/null +++ b/common/repositories/books_repository.h @@ -0,0 +1,70 @@ +/** + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef EQEMU_BOOKS_REPOSITORY_H +#define EQEMU_BOOKS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_books_repository.h" + +class BooksRepository: public BaseBooksRepository { +public: + + /** + * This file was auto generated and can be modified and extended upon + * + * Base repository methods are automatically + * generated in the "base" version of this repository. The base repository + * is immutable and to be left untouched, while methods in this class + * are used as extension methods for more specific persistence-layer + * accessors or mutators. + * + * Base Methods (Subject to be expanded upon in time) + * + * Note: Not all tables are designed appropriately to fit functionality with all base methods + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * BooksRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * BooksRepository::GetWhereNeverExpires() + * BooksRepository::GetWhereXAndY() + * BooksRepository::DeleteWhereXAndY() + * + * Most of the above could be covered by base methods, but if you as a developer + * find yourself re-using logic for other parts of the code, its best to just make a + * method that can be re-used easily elsewhere especially if it can use a base repository + * method and encapsulate filters there + */ + + // Custom extended repository methods here + +}; + +#endif //EQEMU_BOOKS_REPOSITORY_H diff --git a/common/repositories/character_exp_modifiers_repository.h b/common/repositories/character_exp_modifiers_repository.h new file mode 100644 index 000000000..fa8dfe158 --- /dev/null +++ b/common/repositories/character_exp_modifiers_repository.h @@ -0,0 +1,70 @@ +/** + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef EQEMU_CHARACTER_EXP_MODIFIERS_REPOSITORY_H +#define EQEMU_CHARACTER_EXP_MODIFIERS_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_character_exp_modifiers_repository.h" + +class CharacterExpModifiersRepository: public BaseCharacterExpModifiersRepository { +public: + + /** + * This file was auto generated and can be modified and extended upon + * + * Base repository methods are automatically + * generated in the "base" version of this repository. The base repository + * is immutable and to be left untouched, while methods in this class + * are used as extension methods for more specific persistence-layer + * accessors or mutators. + * + * Base Methods (Subject to be expanded upon in time) + * + * Note: Not all tables are designed appropriately to fit functionality with all base methods + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * CharacterExpModifiersRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * CharacterExpModifiersRepository::GetWhereNeverExpires() + * CharacterExpModifiersRepository::GetWhereXAndY() + * CharacterExpModifiersRepository::DeleteWhereXAndY() + * + * Most of the above could be covered by base methods, but if you as a developer + * find yourself re-using logic for other parts of the code, its best to just make a + * method that can be re-used easily elsewhere especially if it can use a base repository + * method and encapsulate filters there + */ + + // Custom extended repository methods here + +}; + +#endif //EQEMU_CHARACTER_EXP_MODIFIERS_REPOSITORY_H diff --git a/common/repositories/horses_repository.h b/common/repositories/horses_repository.h index 108d7c1da..66211d3ca 100644 --- a/common/repositories/horses_repository.h +++ b/common/repositories/horses_repository.h @@ -29,16 +29,18 @@ class HorsesRepository: public BaseHorsesRepository { public: /** - * This file was auto generated on Apr 5, 2020 and can be modified and extended upon + * This file was auto generated and can be modified and extended upon * * Base repository methods are automatically * generated in the "base" version of this repository. The base repository * is immutable and to be left untouched, while methods in this class * are used as extension methods for more specific persistence-layer - * accessors or mutators + * accessors or mutators. * * Base Methods (Subject to be expanded upon in time) * + * Note: Not all tables are designed appropriately to fit functionality with all base methods + * * InsertOne * UpdateOne * DeleteOne diff --git a/common/repositories/pets_beastlord_data_repository.h b/common/repositories/pets_beastlord_data_repository.h new file mode 100644 index 000000000..8d4bb55da --- /dev/null +++ b/common/repositories/pets_beastlord_data_repository.h @@ -0,0 +1,70 @@ +/** + * EQEmulator: Everquest Server Emulator + * Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY except by those people which sell it, which + * are required to give you total support for your newly bought product; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef EQEMU_PETS_BEASTLORD_DATA_REPOSITORY_H +#define EQEMU_PETS_BEASTLORD_DATA_REPOSITORY_H + +#include "../database.h" +#include "../string_util.h" +#include "base/base_pets_beastlord_data_repository.h" + +class PetsBeastlordDataRepository: public BasePetsBeastlordDataRepository { +public: + + /** + * This file was auto generated and can be modified and extended upon + * + * Base repository methods are automatically + * generated in the "base" version of this repository. The base repository + * is immutable and to be left untouched, while methods in this class + * are used as extension methods for more specific persistence-layer + * accessors or mutators. + * + * Base Methods (Subject to be expanded upon in time) + * + * Note: Not all tables are designed appropriately to fit functionality with all base methods + * + * InsertOne + * UpdateOne + * DeleteOne + * FindOne + * GetWhere(std::string where_filter) + * DeleteWhere(std::string where_filter) + * InsertMany + * All + * + * Example custom methods in a repository + * + * PetsBeastlordDataRepository::GetByZoneAndVersion(int zone_id, int zone_version) + * PetsBeastlordDataRepository::GetWhereNeverExpires() + * PetsBeastlordDataRepository::GetWhereXAndY() + * PetsBeastlordDataRepository::DeleteWhereXAndY() + * + * Most of the above could be covered by base methods, but if you as a developer + * find yourself re-using logic for other parts of the code, its best to just make a + * method that can be re-used easily elsewhere especially if it can use a base repository + * method and encapsulate filters there + */ + + // Custom extended repository methods here + +}; + +#endif //EQEMU_PETS_BEASTLORD_DATA_REPOSITORY_H